rust/compiler/rustc_middle/src
bors ec667fbcfc Auto merge of #95031 - compiler-errors:param-env-cache, r=Aaron1011
Do not use `ParamEnv::and` when building a cache key from a param-env and trait eval candidate

Do not use `ParamEnv::and` to cache a param-env with a selection/evaluation candidate.

This is because if the param-env is `RevealAll` mode, and the candidate looks global (i.e. it has erased regions, which can show up when we normalize a projection type under a binder<sup>1</sup>), then when we use `ParamEnv::and` to pair the candidate and the param-env for use as a cache key, we will throw away the param-env's caller bounds, and we'll end up caching a candidate that we inferred from the param-env with a empty param-env, which may cause cache-hit later when we have an empty param-env, and possibly mess with normalization like we see in the referenced issue during codegen.

Not sure how to trigger this with a more structured test, but changing `check-pass` to `build-pass` triggers the case that https://github.com/rust-lang/rust/issues/94903 detected.

<sup>1.</sup> That is, we will replace the late-bound region with a placeholder, which gets canonicalized and turned into an infererence variable, which gets erased during region freshening right before we cache the result. Sorry, it's quite a few steps.

Fixes #94903
r? `@Aaron1011` (or reassign as you see fit)
2022-04-04 04:48:36 +00:00
..
dep_graph Adopt let_else in even more places 2022-02-16 22:43:39 +01:00
hir Rollup merge of #95497 - nyurik:compiler-spell-comments, r=compiler-errors 2022-03-31 04:57:28 +02:00
infer remove unused incorrect EqUnifyValue impl 2022-04-01 12:57:24 +02:00
middle Filter OnceNote in diagnostic infra. 2022-03-20 20:36:26 +01:00
mir interpret: make isize::MAX the limit for dynamic value sizes 2022-03-31 08:57:45 -04:00
query Auto merge of #95537 - GuillaumeGomez:type_of-doc, r=Dylan-DPC 2022-04-02 12:13:11 +00:00
thir use NonHirLiteral instead of ScalarLiteral, move pattern related code to pat_is_poly in IsThirPolymorphic 2022-03-23 11:34:33 +01:00
traits Auto merge of #95031 - compiler-errors:param-env-cache, r=Aaron1011 2022-04-04 04:48:36 +00:00
ty Auto merge of #94883 - cjgillot:flat-metadata, r=oli-obk 2022-04-01 21:16:41 +00:00
util Use AddAssign impl 2021-11-09 23:47:36 +01:00
arena.rs Swap DtorckConstraint to DropckConstraint 2022-03-24 20:35:35 +01:00
lib.rs remove [async output] from impl Future 2022-03-22 19:41:34 -07:00
lint.rs Spellchecking compiler comments 2022-03-30 15:14:15 -04:00
macros.rs Rename TypeFolderFallible to FallibleTypeFolder 2021-12-02 16:14:18 +00:00
metadata.rs resolve/metadata: Stop encoding macros as reexports 2022-02-24 22:55:40 +03:00
tests.rs mv compiler to compiler/ 2020-08-30 18:45:07 +03:00
thir.rs Spellchecking compiler comments 2022-03-30 15:14:15 -04:00