diff options
| author | Michael Goulet <michael@errs.io> | 2023-07-25 01:17:58 +0000 |
|---|---|---|
| committer | Michael Goulet <michael@errs.io> | 2023-08-15 03:40:19 +0000 |
| commit | 2ae4bedd859b2a42a03e9513e40e4829309af4c6 (patch) | |
| tree | 0b97f5a17ee0c7e22407f8351a0a9c9be5dd6fe3 /compiler | |
| parent | ffaa32b7b646c208f20c827655bb98ff9868852e (diff) | |
| download | rust-2ae4bedd859b2a42a03e9513e40e4829309af4c6.tar.gz rust-2ae4bedd859b2a42a03e9513e40e4829309af4c6.zip | |
more span info
Diffstat (limited to 'compiler')
| -rw-r--r-- | compiler/rustc_middle/src/ty/mod.rs | 2 | ||||
| -rw-r--r-- | compiler/rustc_trait_selection/src/traits/coherence.rs | 16 |
2 files changed, 10 insertions, 8 deletions
diff --git a/compiler/rustc_middle/src/ty/mod.rs b/compiler/rustc_middle/src/ty/mod.rs index 48aa25dba6d..377dd82a00e 100644 --- a/compiler/rustc_middle/src/ty/mod.rs +++ b/compiler/rustc_middle/src/ty/mod.rs @@ -238,7 +238,7 @@ pub struct ImplHeader<'tcx> { pub impl_def_id: DefId, pub self_ty: Ty<'tcx>, pub trait_ref: Option<TraitRef<'tcx>>, - pub predicates: Vec<Predicate<'tcx>>, + pub predicates: Vec<(Predicate<'tcx>, Span)>, } #[derive(Copy, Clone, PartialEq, Eq, Debug, TypeFoldable, TypeVisitable)] diff --git a/compiler/rustc_trait_selection/src/traits/coherence.rs b/compiler/rustc_trait_selection/src/traits/coherence.rs index e56af586ed8..dd15f1a5492 100644 --- a/compiler/rustc_trait_selection/src/traits/coherence.rs +++ b/compiler/rustc_trait_selection/src/traits/coherence.rs @@ -151,14 +151,16 @@ fn with_fresh_ty_vars<'cx, 'tcx>( .predicates_of(impl_def_id) .instantiate(tcx, impl_args) .iter() - .map(|(c, _)| c.as_predicate()) + .map(|(c, s)| (c.as_predicate(), s)) .collect(), }; - let InferOk { value: mut header, obligations } = - selcx.infcx.at(&ObligationCause::dummy(), param_env).normalize(header); + let InferOk { value: mut header, obligations } = selcx + .infcx + .at(&ObligationCause::dummy_with_span(tcx.def_span(impl_def_id)), param_env) + .normalize(header); - header.predicates.extend(obligations.into_iter().map(|o| o.predicate)); + header.predicates.extend(obligations.into_iter().map(|o| (o.predicate, o.cause.span))); header } @@ -289,7 +291,7 @@ fn impl_intersection_has_impossible_obligation<'cx, 'tcx>( ) -> bool { let infcx = selcx.infcx; - let obligation_guaranteed_to_fail = move |obligation: &PredicateObligation<'tcx>| { + let obligation_guaranteed_to_fail = |obligation: &PredicateObligation<'tcx>| { if infcx.next_trait_solver() { infcx.evaluate_obligation(obligation).map_or(false, |result| !result.may_apply()) } else { @@ -306,8 +308,8 @@ fn impl_intersection_has_impossible_obligation<'cx, 'tcx>( let opt_failing_obligation = [&impl1_header.predicates, &impl2_header.predicates] .into_iter() .flatten() - .map(|&predicate| { - Obligation::new(infcx.tcx, ObligationCause::dummy(), param_env, predicate) + .map(|&(predicate, span)| { + Obligation::new(infcx.tcx, ObligationCause::dummy_with_span(span), param_env, predicate) }) .chain(obligations) .find(obligation_guaranteed_to_fail); |
