rust/compiler/rustc_infer/src
bors d23e1a6894 Auto merge of #117749 - aliemjay:perf-canon-cache, r=lcnr
cache param env canonicalization

Canonicalize ParamEnv only once and store it. Then whenever we try to canonicalize `ParamEnvAnd<'tcx, T>` we only have to canonicalize `T` and then merge the results.

Prelimiary results show ~3-4% savings in diesel and serde benchmarks.

Best to review commits individually. Some commits have a short description.

Initial implementation had a soundness bug (https://github.com/rust-lang/rust/pull/117749#issuecomment-1840453387) due to cache invalidation:
- When canonicalizing `Ty<'?0>` we first try to resolve region variables in the current InferCtxt which may have a constraint `?0 == 'static`. This means that we register `Ty<'?0> => Canonical<Ty<'static>>` in the cache, which is obviously incorrect in another inference context.
- This is fixed by not doing region resolution when canonicalizing the query *input* (vs. response), which is the only place where ParamEnv is used, and then in a later commit we *statically* guard against any form of inference variable resolution of the cached canonical ParamEnv's.

r? `@ghost`
2023-12-14 04:04:10 +00:00
..
errors Move some methods from tcx.hir() to tcx 2023-12-12 06:40:29 -08:00
infer Auto merge of #117749 - aliemjay:perf-canon-cache, r=lcnr 2023-12-14 04:04:10 +00:00
traits add unused NormalizesTo predicate 2023-12-07 17:52:51 +01:00
lib.rs Use rustc_fluent_macro::fluent_messages! directly. 2023-11-26 08:38:40 +11:00