about summary refs log tree commit diff
path: root/compiler/rustc_middle/src
diff options
context:
space:
mode:
authorMatthias Krüger <matthias.krueger@famsik.de>2023-03-14 17:40:05 +0100
committerGitHub <noreply@github.com>2023-03-14 17:40:05 +0100
commit1f159b4894fe25d7d180dc32fa57a4d71a2b9a57 (patch)
treead133be471c24a0b1a3e1a14d30f97b539566846 /compiler/rustc_middle/src
parent21d15db1dff058ad0b3955ce4d5aef6d0e64c67c (diff)
parent0bb876ebe76dee4c3f00fcd3c581d87ad67940ef (diff)
Rollup merge of #109101 - compiler-errors:layout-err, r=michaelwoerister
Fall back to old metadata computation when type references errors

Projection is a bit too aggressive normalizing `<dyn Trait<[type error]> as Pointee>::Metadata` to `[type error]`, rather than to `DynMetadata<..>`. Side-step that by just falling back to the old structural metadata computation.

Fixes #109078
Diffstat (limited to 'compiler/rustc_middle/src')
-rw-r--r--compiler/rustc_middle/src/ty/layout.rs6
1 files changed, 5 insertions, 1 deletions
diff --git a/compiler/rustc_middle/src/ty/layout.rs b/compiler/rustc_middle/src/ty/layout.rs
index 254ffc33c96..42fb5d031bb 100644
--- a/compiler/rustc_middle/src/ty/layout.rs
+++ b/compiler/rustc_middle/src/ty/layout.rs
@@ -730,7 +730,11 @@ where
                         */
                     };
 
-                    let metadata = if let Some(metadata_def_id) = tcx.lang_items().metadata_type() {
+                    let metadata = if let Some(metadata_def_id) = tcx.lang_items().metadata_type()
+                        // Projection eagerly bails out when the pointee references errors,
+                        // fall back to structurally deducing metadata.
+                        && !pointee.references_error()
+                    {
                         let metadata = tcx.normalize_erasing_regions(
                             cx.param_env(),
                             tcx.mk_projection(metadata_def_id, [pointee]),