Skip to content

Commit e5a3db4

Browse files
authored
Rollup merge of #104775 - spastorino:use-obligation-ctxt-normalize, r=lcnr
Use ObligationCtxt::normalize r? ``@lcnr``
2 parents b69a9f0 + 409203a commit e5a3db4

File tree

1 file changed

+4
-17
lines changed

1 file changed

+4
-17
lines changed

compiler/rustc_hir_analysis/src/check/compare_method.rs

+4-17
Original file line numberDiff line numberDiff line change
@@ -218,14 +218,11 @@ fn compare_predicate_entailment<'tcx>(
218218

219219
debug!("compare_impl_method: caller_bounds={:?}", param_env.caller_bounds());
220220

221-
let mut selcx = traits::SelectionContext::new(&infcx);
222221
let impl_m_own_bounds = impl_m_predicates.instantiate_own(tcx, impl_to_placeholder_substs);
223222
for (predicate, span) in iter::zip(impl_m_own_bounds.predicates, impl_m_own_bounds.spans) {
224223
let normalize_cause = traits::ObligationCause::misc(span, impl_m_hir_id);
225-
let traits::Normalized { value: predicate, obligations } =
226-
traits::normalize(&mut selcx, param_env, normalize_cause, predicate);
224+
let predicate = ocx.normalize(normalize_cause, param_env, predicate);
227225

228-
ocx.register_obligations(obligations);
229226
let cause = ObligationCause::new(
230227
span,
231228
impl_m_hir_id,
@@ -1555,14 +1552,11 @@ fn compare_type_predicate_entailment<'tcx>(
15551552

15561553
debug!("compare_type_predicate_entailment: caller_bounds={:?}", param_env.caller_bounds());
15571554

1558-
let mut selcx = traits::SelectionContext::new(&infcx);
1559-
15601555
assert_eq!(impl_ty_own_bounds.predicates.len(), impl_ty_own_bounds.spans.len());
15611556
for (span, predicate) in std::iter::zip(impl_ty_own_bounds.spans, impl_ty_own_bounds.predicates)
15621557
{
15631558
let cause = ObligationCause::misc(span, impl_ty_hir_id);
1564-
let traits::Normalized { value: predicate, obligations } =
1565-
traits::normalize(&mut selcx, param_env, cause, predicate);
1559+
let predicate = ocx.normalize(cause, param_env, predicate);
15661560

15671561
let cause = ObligationCause::new(
15681562
span,
@@ -1573,7 +1567,6 @@ fn compare_type_predicate_entailment<'tcx>(
15731567
kind: impl_ty.kind,
15741568
},
15751569
);
1576-
ocx.register_obligations(obligations);
15771570
ocx.register_obligation(traits::Obligation::new(tcx, cause, param_env, predicate));
15781571
}
15791572

@@ -1756,7 +1749,6 @@ pub fn check_type_bounds<'tcx>(
17561749
let assumed_wf_types =
17571750
ocx.assumed_wf_types(param_env, impl_ty_span, impl_ty.def_id.expect_local());
17581751

1759-
let mut selcx = traits::SelectionContext::new(&infcx);
17601752
let normalize_cause = ObligationCause::new(
17611753
impl_ty_span,
17621754
impl_ty_hir_id,
@@ -1785,16 +1777,11 @@ pub fn check_type_bounds<'tcx>(
17851777
debug!("check_type_bounds: item_bounds={:?}", obligations);
17861778

17871779
for mut obligation in util::elaborate_obligations(tcx, obligations) {
1788-
let traits::Normalized { value: normalized_predicate, obligations } = traits::normalize(
1789-
&mut selcx,
1790-
normalize_param_env,
1791-
normalize_cause.clone(),
1792-
obligation.predicate,
1793-
);
1780+
let normalized_predicate =
1781+
ocx.normalize(normalize_cause.clone(), normalize_param_env, obligation.predicate);
17941782
debug!("compare_projection_bounds: normalized predicate = {:?}", normalized_predicate);
17951783
obligation.predicate = normalized_predicate;
17961784

1797-
ocx.register_obligations(obligations);
17981785
ocx.register_obligation(obligation);
17991786
}
18001787
// Check that all obligations are satisfied by the implementation's

0 commit comments

Comments
 (0)