about summary refs log tree commit diff
path: root/compiler
diff options
context:
space:
mode:
authorMatthias Krüger <matthias.krueger@famsik.de>2024-03-13 20:01:58 +0100
committerGitHub <noreply@github.com>2024-03-13 20:01:58 +0100
commitc52ce4eabba65fcc47ce92c20c3e7e6dd73f77df (patch)
tree17ee68472dd40a4f37c33118f0fa4c2ffd5bafe0 /compiler
parent8d2f79c3f189f552e0dbc5fdfafcf3fc6b9e6037 (diff)
parent026eb3dd6457f223ff1c3a3b40bf59898a25061a (diff)
downloadrust-c52ce4eabba65fcc47ce92c20c3e7e6dd73f77df.tar.gz
rust-c52ce4eabba65fcc47ce92c20c3e7e6dd73f77df.zip
Rollup merge of #122449 - compiler-errors:stranded-opaque, r=oli-obk
Delay a bug for stranded opaques

r? oli-obk

Fixes #122445
Diffstat (limited to 'compiler')
-rw-r--r--compiler/rustc_hir_analysis/src/check/check.rs8
1 files changed, 7 insertions, 1 deletions
diff --git a/compiler/rustc_hir_analysis/src/check/check.rs b/compiler/rustc_hir_analysis/src/check/check.rs
index 1b8174d3d18..d1fed13ee9f 100644
--- a/compiler/rustc_hir_analysis/src/check/check.rs
+++ b/compiler/rustc_hir_analysis/src/check/check.rs
@@ -381,11 +381,17 @@ fn check_opaque_meets_bounds<'tcx>(
     match ocx.eq(&misc_cause, param_env, opaque_ty, hidden_ty) {
         Ok(()) => {}
         Err(ty_err) => {
+            // Some types may be left "stranded" if they can't be reached
+            // from an astconv'd bound but they're mentioned in the HIR. This
+            // will happen, e.g., when a nested opaque is inside of a non-
+            // existent associated type, like `impl Trait<Missing = impl Trait>`.
+            // See <tests/ui/impl-trait/stranded-opaque.rs>.
             let ty_err = ty_err.to_string(tcx);
-            tcx.dcx().span_bug(
+            let guar = tcx.dcx().span_delayed_bug(
                 span,
                 format!("could not unify `{hidden_ty}` with revealed type:\n{ty_err}"),
             );
+            return Err(guar);
         }
     }