diff options
| author | Matthias Krüger <matthias.krueger@famsik.de> | 2023-09-18 18:27:20 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-09-18 18:27:20 +0200 |
| commit | e27c3e97ca6085e90c8d16c2170894268354a085 (patch) | |
| tree | ceca908c0b52b3bbddf5ecba7ee5e64e661e502c | |
| parent | 0d0f4fd8a3253b9dd39b2bcce62d6a456e2545e3 (diff) | |
| parent | ee59531dfcd3185335322f29aa806aefe2aaa7ac (diff) | |
| download | rust-e27c3e97ca6085e90c8d16c2170894268354a085.tar.gz rust-e27c3e97ca6085e90c8d16c2170894268354a085.zip | |
Rollup merge of #115762 - oli-obk:early_const_prop_lint2, r=compiler-errors
Explain revealing of opaque types in layout_of ParamEnv r? `@compiler-errors` ~~I feel like `layout_of` is doing too many things at once, and I don't really know why. It could allow us to if callers could decide whether to reveal opaque types.~~ Looks like this also exists as a performance optimization. While we could probably figure out a way to do this, all the ones I came up with are fragile as `layout_of` callers now suddenly need to be careful what ParamEnv they pass in.
| -rw-r--r-- | compiler/rustc_ty_utils/src/layout.rs | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/compiler/rustc_ty_utils/src/layout.rs b/compiler/rustc_ty_utils/src/layout.rs index 904f1b38740..a03b82305f0 100644 --- a/compiler/rustc_ty_utils/src/layout.rs +++ b/compiler/rustc_ty_utils/src/layout.rs @@ -36,6 +36,9 @@ fn layout_of<'tcx>( let (param_env, ty) = query.into_parts(); debug!(?ty); + // Optimization: We convert to RevealAll and convert opaque types in the where bounds + // to their hidden types. This reduces overall uncached invocations of `layout_of` and + // is thus a small performance improvement. let param_env = param_env.with_reveal_all_normalized(tcx); let unnormalized_ty = ty; |
