diff options
| author | Yuki Okushi <huyuumi.dev+love@gmail.com> | 2022-12-06 12:48:54 +0900 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-12-06 12:48:54 +0900 |
| commit | e09c71e4c127e4a0fd6644a56ef06a7a0377a215 (patch) | |
| tree | 8415082514725afc9975ac8ecfd730e6f069d419 /compiler/rustc_trait_selection | |
| parent | 7ba37adbfdcbc2ca3ca220938c85400512cace97 (diff) | |
| parent | a1fbc143729b140f51c4a93dfc5a9a54a9a20486 (diff) | |
Rollup merge of #105324 - compiler-errors:gat-where-clause-binding-obl, r=jackh726
Point at GAT `where` clause when an obligation is unsatisfied Slightly helps with #105306
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, |
