Skip to content

Commit 9543b0e

Browse files
committed
Bubble anchor out of fully_solve_obligation
1 parent ace9146 commit 9543b0e

File tree

5 files changed

+12
-6
lines changed

5 files changed

+12
-6
lines changed

compiler/rustc_hir_analysis/src/coherence/builtin.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -576,7 +576,7 @@ pub fn coerce_unsized_info<'tcx>(tcx: TyCtxt<'tcx>, impl_did: DefId) -> CoerceUn
576576
let cause = traits::ObligationCause::misc(span, impl_did);
577577
let predicate =
578578
predicate_for_trait_def(tcx, param_env, cause, trait_def_id, 0, [source, target]);
579-
let errors = traits::fully_solve_obligation(&infcx, predicate);
579+
let errors = traits::fully_solve_obligation(&infcx, predicate, infer::DefiningAnchor::Error);
580580
if !errors.is_empty() {
581581
infcx.err_ctxt().report_fulfillment_errors(&errors, None);
582582
}

compiler/rustc_hir_analysis/src/hir_wf_check.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ fn diagnostic_hir_wf_check<'tcx>(
8080
self.param_env,
8181
ty::Binder::dummy(ty::PredicateKind::WellFormed(tcx_ty.into())),
8282
),
83+
rustc_infer::infer::DefiningAnchor::Error,
8384
);
8485
if !errors.is_empty() {
8586
debug!("Wf-check got errors for {:?}: {:?}", ty, errors);

compiler/rustc_hir_typeck/src/op.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -775,7 +775,11 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
775775
(None, Some(trait_did)) => {
776776
let (obligation, _) =
777777
self.obligation_for_method(cause, trait_did, lhs_ty, Some(input_types));
778-
Err(rustc_trait_selection::traits::fully_solve_obligation(self, obligation))
778+
Err(rustc_trait_selection::traits::fully_solve_obligation(
779+
self,
780+
obligation,
781+
self.defining_use_anchor,
782+
))
779783
}
780784
}
781785
}

compiler/rustc_trait_selection/src/traits/coherence.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -376,7 +376,7 @@ fn resolve_negative_obligation<'tcx>(
376376
};
377377

378378
let param_env = o.param_env;
379-
if !super::fully_solve_obligation(&infcx, o).is_empty() {
379+
if !super::fully_solve_obligation(&infcx, o, infcx.old_defining_use_anchor).is_empty() {
380380
return false;
381381
}
382382

compiler/rustc_trait_selection/src/traits/mod.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ fn pred_known_to_hold_modulo_regions<'tcx>(
170170
// The handling of regions in this area of the code is terrible,
171171
// see issue #29149. We should be able to improve on this with
172172
// NLL.
173-
let errors = fully_solve_obligation(infcx, obligation);
173+
let errors = fully_solve_obligation(infcx, obligation, infcx.old_defining_use_anchor);
174174

175175
match &errors[..] {
176176
[] => true,
@@ -393,8 +393,9 @@ where
393393
pub fn fully_solve_obligation<'tcx>(
394394
infcx: &InferCtxt<'tcx>,
395395
obligation: PredicateObligation<'tcx>,
396+
defining_use_anchor: DefiningAnchor,
396397
) -> Vec<FulfillmentError<'tcx>> {
397-
fully_solve_obligations(infcx, [obligation], infcx.old_defining_use_anchor)
398+
fully_solve_obligations(infcx, [obligation], defining_use_anchor)
398399
}
399400

400401
/// Process a set of obligations (and any nested obligations that come from them)
@@ -423,7 +424,7 @@ pub fn fully_solve_bound<'tcx>(
423424
let trait_ref = tcx.mk_trait_ref(bound, [ty]);
424425
let obligation = Obligation::new(tcx, cause, param_env, ty::Binder::dummy(trait_ref));
425426

426-
fully_solve_obligation(infcx, obligation)
427+
fully_solve_obligation(infcx, obligation, infcx.old_defining_use_anchor)
427428
}
428429

429430
/// Normalizes the predicates and checks whether they hold in an empty environment. If this

0 commit comments

Comments
 (0)