about summary refs log tree commit diff
path: root/compiler/rustc_hir_analysis
diff options
context:
space:
mode:
authorMichael Goulet <michael@errs.io>2023-01-12 20:28:57 +0000
committerMichael Goulet <michael@errs.io>2023-01-12 22:25:30 +0000
commit5924c2511e43dd077df78d9936ccd0d76168ad30 (patch)
treee37dddc14fe997b1da19c30318cd4de3bb57a304 /compiler/rustc_hir_analysis
parent2aabb0fd5da283129205acb9c3e4d70a01238a93 (diff)
downloadrust-5924c2511e43dd077df78d9936ccd0d76168ad30.tar.gz
rust-5924c2511e43dd077df78d9936ccd0d76168ad30.zip
Only point at impl self ty in WF if trait predicate shares self ty
Diffstat (limited to 'compiler/rustc_hir_analysis')
-rw-r--r--compiler/rustc_hir_analysis/src/check/wfcheck.rs11
1 files changed, 9 insertions, 2 deletions
diff --git a/compiler/rustc_hir_analysis/src/check/wfcheck.rs b/compiler/rustc_hir_analysis/src/check/wfcheck.rs
index 9bd49f5e053..92fd4625ee8 100644
--- a/compiler/rustc_hir_analysis/src/check/wfcheck.rs
+++ b/compiler/rustc_hir_analysis/src/check/wfcheck.rs
@@ -1267,14 +1267,21 @@ fn check_impl<'tcx>(
                     },
                     polarity: ty::ImplPolarity::Positive,
                 };
-                let obligations = traits::wf::trait_obligations(
+                let mut obligations = traits::wf::trait_obligations(
                     wfcx.infcx,
                     wfcx.param_env,
                     wfcx.body_id,
                     &trait_pred,
-                    ast_self_ty.span,
+                    ast_trait_ref.path.span,
                     item,
                 );
+                for obligation in &mut obligations {
+                    if let Some(pred) = obligation.predicate.to_opt_poly_trait_pred()
+                        && pred.self_ty().skip_binder() == trait_ref.self_ty()
+                    {
+                        obligation.cause.span = ast_self_ty.span;
+                    }
+                }
                 debug!(?obligations);
                 wfcx.register_obligations(obligations);
             }