diff options
| author | Matthias Krüger <matthias.krueger@famsik.de> | 2023-05-16 20:12:16 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-05-16 20:12:16 +0200 |
| commit | c78a67b710d19c556cfa279bce8b0e7eeb4e3b7b (patch) | |
| tree | e681affccaa3d178126cf7607f9820567039e482 /compiler | |
| parent | 8d162fb150a177033cf71b03b53a6bc7ec6884f3 (diff) | |
| parent | 8921391a12be89c22ca8a5724cf5c6e98ef47149 (diff) | |
| download | rust-c78a67b710d19c556cfa279bce8b0e7eeb4e3b7b.tar.gz rust-c78a67b710d19c556cfa279bce8b0e7eeb4e3b7b.zip | |
Rollup merge of #111488 - compiler-errors:error-term, r=lcnr
Use error term in projection if missing associated item in new solver We were previously delaying a bug but not bailing, leading to an ICE in the `tcx.type_of(assoc_def.item.def_id)` call below.
Diffstat (limited to 'compiler')
| -rw-r--r-- | compiler/rustc_trait_selection/src/solve/project_goals.rs | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/compiler/rustc_trait_selection/src/solve/project_goals.rs b/compiler/rustc_trait_selection/src/solve/project_goals.rs index 20ce2d9416e..d3228074421 100644 --- a/compiler/rustc_trait_selection/src/solve/project_goals.rs +++ b/compiler/rustc_trait_selection/src/solve/project_goals.rs @@ -124,10 +124,24 @@ impl<'tcx> assembly::GoalKind<'tcx> for ProjectionPredicate<'tcx> { }; if !assoc_def.item.defaultness(tcx).has_value() { - tcx.sess.delay_span_bug( + let guar = tcx.sess.delay_span_bug( tcx.def_span(assoc_def.item.def_id), "missing value for assoc item in impl", ); + let error_term = match assoc_def.item.kind { + ty::AssocKind::Const => tcx + .const_error( + tcx.type_of(goal.predicate.def_id()) + .subst(tcx, goal.predicate.projection_ty.substs), + guar, + ) + .into(), + ty::AssocKind::Type => tcx.ty_error(guar).into(), + ty::AssocKind::Fn => unreachable!(), + }; + ecx.eq(goal.param_env, goal.predicate.term, error_term) + .expect("expected goal term to be fully unconstrained"); + return ecx.evaluate_added_goals_and_make_canonical_response(Certainty::Yes); } // Getting the right substitutions here is complex, e.g. given: |
