Skip to content

Commit 64f1a59

Browse files
committed
Update all uses of FulfillmentContext
Update all uses of FulfillmentContext to be ones obtained via an InferCtxt. This is another step of flattening the type checking context into a single piece of state.
1 parent 6947948 commit 64f1a59

File tree

6 files changed

+12
-10
lines changed

6 files changed

+12
-10
lines changed

src/librustc/middle/check_const.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -284,8 +284,8 @@ impl<'a, 'tcx> CheckCrateVisitor<'a, 'tcx> {
284284
fn check_static_type(&self, e: &ast::Expr) {
285285
let ty = self.tcx.node_id_to_type(e.id);
286286
let infcx = infer::new_infer_ctxt(self.tcx, &self.tcx.tables, None);
287-
let mut fulfill_cx = traits::FulfillmentContext::new(false);
288287
let cause = traits::ObligationCause::new(e.span, e.id, traits::SharedStatic);
288+
let mut fulfill_cx = infcx.fulfillment_cx.borrow_mut();
289289
fulfill_cx.register_builtin_bound(&infcx, ty, ty::BoundSync, cause);
290290
match fulfill_cx.select_all_or_error(&infcx, &infcx.parameter_environment) {
291291
Ok(()) => { },

src/librustc/middle/traits/mod.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -322,7 +322,7 @@ pub fn type_known_to_meet_builtin_bound<'a,'tcx>(infcx: &InferCtxt<'a,'tcx>,
322322
ty,
323323
bound);
324324

325-
let mut fulfill_cx = FulfillmentContext::new(false);
325+
let mut fulfill_cx = infcx.fulfillment_cx.borrow_mut();
326326

327327
// We can use a dummy node-id here because we won't pay any mind
328328
// to region obligations that arise (there shouldn't really be any
@@ -438,7 +438,8 @@ pub fn fully_normalize<'a,'tcx,T>(infcx: &InferCtxt<'a,'tcx>,
438438
debug!("normalize_param_env(value={:?})", value);
439439

440440
let mut selcx = &mut SelectionContext::new(infcx, closure_typer);
441-
let mut fulfill_cx = FulfillmentContext::new(false);
441+
let mut fulfill_cx = infcx.fulfillment_cx.borrow_mut();
442+
442443
let Normalized { value: normalized_value, obligations } =
443444
project::normalize(selcx, cause, value);
444445
debug!("normalize_param_env: normalized_value={:?} obligations={:?}",

src/librustc_trans/trans/common.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -994,7 +994,7 @@ pub fn fulfill_obligation<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
994994
// Currently, we use a fulfillment context to completely resolve
995995
// all nested obligations. This is because they can inform the
996996
// inference of the impl's type parameters.
997-
let mut fulfill_cx = traits::FulfillmentContext::new(true);
997+
let mut fulfill_cx = infcx.fulfillment_cx.borrow_mut();
998998
let vtable = selection.map(|predicate| {
999999
fulfill_cx.register_predicate_obligation(&infcx, predicate);
10001000
});
@@ -1019,10 +1019,10 @@ pub fn normalize_and_test_predicates<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
10191019
predicates);
10201020

10211021
let tcx = ccx.tcx();
1022-
let mut infcx = infer::new_infer_ctxt(tcx, &tcx.tables, None, false);
1022+
let infcx = infer::new_infer_ctxt(tcx, &tcx.tables, None, false);
10231023
let typer = NormalizingClosureTyper::new(tcx);
10241024
let mut selcx = traits::SelectionContext::new(&infcx, &typer);
1025-
let mut fulfill_cx = traits::FulfillmentContext::new(false);
1025+
let mut fulfill_cx = infcx.fulfillment_cx.borrow_mut();
10261026
let cause = traits::ObligationCause::dummy();
10271027
let traits::Normalized { value: predicates, obligations } =
10281028
traits::normalize(&mut selcx, cause.clone(), &predicates);

src/librustc_trans/trans/monomorphize.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -335,7 +335,8 @@ pub fn normalize_associated_type<'tcx,T>(tcx: &ty::ctxt<'tcx>, value: &T) -> T
335335
result,
336336
obligations);
337337

338-
let mut fulfill_cx = traits::FulfillmentContext::new(true);
338+
let mut fulfill_cx = infcx.fulfillment_cx.borrow_mut();
339+
339340
for obligation in obligations {
340341
fulfill_cx.register_predicate_obligation(&infcx, obligation);
341342
}

src/librustc_typeck/check/compare_method.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ pub fn compare_impl_method<'tcx>(tcx: &ty::ctxt<'tcx>,
4444
impl_trait_ref);
4545

4646
let mut infcx = infer::new_infer_ctxt(tcx, &tcx.tables, None, true);
47-
let mut fulfillment_cx = traits::FulfillmentContext::new(true);
47+
let mut fulfillment_cx = infcx.fulfillment_cx.borrow_mut();
4848

4949
let trait_to_impl_substs = &impl_trait_ref.substs;
5050

@@ -420,7 +420,7 @@ pub fn compare_const_impl<'tcx>(tcx: &ty::ctxt<'tcx>,
420420
impl_trait_ref);
421421

422422
let infcx = infer::new_infer_ctxt(tcx, &tcx.tables, None, true);
423-
let mut fulfillment_cx = traits::FulfillmentContext::new(true);
423+
let mut fulfillment_cx = infcx.fulfillment_cx.borrow_mut();
424424

425425
// The below is for the most part highly similar to the procedure
426426
// for methods above. It is simpler in many respects, especially

src/librustc_typeck/coherence/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -531,7 +531,7 @@ impl<'a, 'tcx> CoherenceChecker<'a, 'tcx> {
531531
}
532532
};
533533

534-
let mut fulfill_cx = traits::FulfillmentContext::new(true);
534+
let mut fulfill_cx = infcx.fulfillment_cx.borrow_mut();
535535

536536
// Register an obligation for `A: Trait<B>`.
537537
let cause = traits::ObligationCause::misc(span, impl_did.node);

0 commit comments

Comments
 (0)