diff options
| author | Michael Goulet <michael@errs.io> | 2022-12-05 19:06:32 +0000 |
|---|---|---|
| committer | Michael Goulet <michael@errs.io> | 2022-12-05 19:11:31 +0000 |
| commit | a1fbc143729b140f51c4a93dfc5a9a54a9a20486 (patch) | |
| tree | eded30f78d276349a1c5a963efda449eca0b98da /compiler/rustc_trait_selection | |
| parent | d1449560e31f7f801d81268a3dad783181656dff (diff) | |
Point at GAT where clause when unsatisfied
Diffstat (limited to 'compiler/rustc_trait_selection')
| -rw-r--r-- | compiler/rustc_trait_selection/src/traits/project.rs | 30 |
1 files changed, 25 insertions, 5 deletions
diff --git a/compiler/rustc_trait_selection/src/traits/project.rs b/compiler/rustc_trait_selection/src/traits/project.rs index 051660be9c4..71f6eae45aa 100644 --- a/compiler/rustc_trait_selection/src/traits/project.rs +++ b/compiler/rustc_trait_selection/src/traits/project.rs @@ -2321,11 +2321,10 @@ fn assoc_ty_own_obligations<'cx, 'tcx>( nested: &mut Vec<PredicateObligation<'tcx>>, ) { let tcx = selcx.tcx(); - for predicate in tcx + let own = tcx .predicates_of(obligation.predicate.item_def_id) - .instantiate_own(tcx, obligation.predicate.substs) - .predicates - { + .instantiate_own(tcx, obligation.predicate.substs); + for (predicate, span) in std::iter::zip(own.predicates, own.spans) { let normalized = normalize_with_depth_to( selcx, obligation.param_env, @@ -2334,9 +2333,30 @@ fn assoc_ty_own_obligations<'cx, 'tcx>( predicate, nested, ); + + let nested_cause = if matches!( + obligation.cause.code(), + super::CompareImplItemObligation { .. } + | super::CheckAssociatedTypeBounds { .. } + | super::AscribeUserTypeProvePredicate(..) + ) { + obligation.cause.clone() + } else if span.is_dummy() { + ObligationCause::new( + obligation.cause.span, + obligation.cause.body_id, + super::ItemObligation(obligation.predicate.item_def_id), + ) + } else { + ObligationCause::new( + obligation.cause.span, + obligation.cause.body_id, + super::BindingObligation(obligation.predicate.item_def_id, span), + ) + }; nested.push(Obligation::with_depth( tcx, - obligation.cause.clone(), + nested_cause, obligation.recursion_depth + 1, obligation.param_env, normalized, |
