mirror of
https://github.com/astral-sh/ruff.git
synced 2026-05-06 08:56:57 -04:00
eccc6ce4fb
This adds some salsa-caching to the new constraint set solver. There are many call paths that build up a constraint set for an assignability check, and then solve that constraint set to get a specialization, and we often have to perform this multiple times on the same two types. It is not just constraint set construction that is worth caching; we also want to cache as much of the solution extraction as we can. So this PR refactors the solving code slightly so that `PathBounds` is the result of the now-salsa-cached method. This is a vec with an element for each satisfiable path in the constraint set BDD, recording the combined lower and upper bound for each typevar mentioned on that path. This caches us much of the work as we can, while still allowing different callers to provide different `choose` callbacks if they need to override how to choose a specific type within that lower/upper bound, or if they need to record additional information about the solution paths.