Use fresh FulfillmentContexts in select locations
This commit is contained in:
parent
64f1a59daf
commit
0f13a3f361
8 changed files with 21 additions and 13 deletions
|
@ -283,7 +283,7 @@ impl<'a, 'tcx> CheckCrateVisitor<'a, 'tcx> {
|
|||
|
||||
fn check_static_type(&self, e: &ast::Expr) {
|
||||
let ty = self.tcx.node_id_to_type(e.id);
|
||||
let infcx = infer::new_infer_ctxt(self.tcx, &self.tcx.tables, None);
|
||||
let infcx = infer::new_infer_ctxt(self.tcx, &self.tcx.tables, None, false);
|
||||
let cause = traits::ObligationCause::new(e.span, e.id, traits::SharedStatic);
|
||||
let mut fulfill_cx = infcx.fulfillment_cx.borrow_mut();
|
||||
fulfill_cx.register_builtin_bound(&infcx, ty, ty::BoundSync, cause);
|
||||
|
|
|
@ -1031,7 +1031,7 @@ fn resolve_trait_associated_const<'a, 'tcx: 'a>(tcx: &'a ty::ctxt<'tcx>,
|
|||
substs: trait_substs });
|
||||
|
||||
tcx.populate_implementations_for_trait_if_necessary(trait_ref.def_id());
|
||||
let infcx = infer::new_infer_ctxt(tcx, &tcx.tables, None);
|
||||
let infcx = infer::new_infer_ctxt(tcx, &tcx.tables, None, false);
|
||||
|
||||
let mut selcx = traits::SelectionContext::new(&infcx, &infcx.parameter_environment);
|
||||
let obligation = traits::Obligation::new(traits::ObligationCause::dummy(),
|
||||
|
|
|
@ -1019,7 +1019,6 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
|
|||
raw_ty.adjust(self.tcx,
|
||||
expr.span,
|
||||
expr.id,
|
||||
raw_ty,
|
||||
adjustment,
|
||||
|method_call| self.tables
|
||||
.borrow()
|
||||
|
|
|
@ -85,7 +85,7 @@ pub struct FulfillmentContext<'tcx> {
|
|||
// particular node-id).
|
||||
region_obligations: NodeMap<Vec<RegionObligation<'tcx>>>,
|
||||
|
||||
errors_will_be_reported: bool,
|
||||
pub errors_will_be_reported: bool,
|
||||
}
|
||||
|
||||
#[derive(Clone)]
|
||||
|
|
|
@ -322,7 +322,7 @@ pub fn type_known_to_meet_builtin_bound<'a,'tcx>(infcx: &InferCtxt<'a,'tcx>,
|
|||
ty,
|
||||
bound);
|
||||
|
||||
let mut fulfill_cx = infcx.fulfillment_cx.borrow_mut();
|
||||
let mut fulfill_cx = FulfillmentContext::new(false);
|
||||
|
||||
// We can use a dummy node-id here because we won't pay any mind
|
||||
// to region obligations that arise (there shouldn't really be any
|
||||
|
@ -438,7 +438,17 @@ pub fn fully_normalize<'a,'tcx,T>(infcx: &InferCtxt<'a,'tcx>,
|
|||
debug!("normalize_param_env(value={:?})", value);
|
||||
|
||||
let mut selcx = &mut SelectionContext::new(infcx, closure_typer);
|
||||
let mut fulfill_cx = infcx.fulfillment_cx.borrow_mut();
|
||||
// FIXME (@jroesch): I'm not sure if this is a bug or not, needs
|
||||
// further investigation. It appears that by reusing the fulfillment_cx
|
||||
// here we incur more obligations and later trip an asssertion on
|
||||
// regionck.rs line 337. The two possibilities I see is that
|
||||
// normalization is not actually fully happening and we
|
||||
// have a bug else where or that we are adding a duplicate
|
||||
// bound into the list causing its size to change. I think
|
||||
// we should probably land this refactor and then come
|
||||
// back to this is a follow-up patch.
|
||||
let mut fulfill_cx = FulfillmentContext::new(false);
|
||||
// let mut fulfill_cx = infcx.fulfillment_cx.borrow_mut();
|
||||
|
||||
let Normalized { value: normalized_value, obligations } =
|
||||
project::normalize(selcx, cause, value);
|
||||
|
|
|
@ -4401,7 +4401,7 @@ impl<'tcx> TyS<'tcx> {
|
|||
-> bool
|
||||
{
|
||||
let tcx = param_env.tcx();
|
||||
let infcx = infer::new_infer_ctxt(tcx, &tcx.tables, Some(param_env.clone()));
|
||||
let infcx = infer::new_infer_ctxt(tcx, &tcx.tables, Some(param_env.clone()), false);
|
||||
|
||||
let is_impld = traits::type_known_to_meet_builtin_bound(&infcx, param_env,
|
||||
self, bound, span);
|
||||
|
|
|
@ -295,8 +295,7 @@ impl<'a, 'tcx> Inherited<'a, 'tcx> {
|
|||
-> Inherited<'a, 'tcx> {
|
||||
|
||||
Inherited {
|
||||
// I'm probably screwed here ... more boolean prop ...
|
||||
infcx: infer::new_infer_ctxt(tcx, tables, Some(param_env), false),
|
||||
infcx: infer::new_infer_ctxt(tcx, tables, Some(param_env), true),
|
||||
locals: RefCell::new(NodeMap()),
|
||||
tables: tables,
|
||||
fn_sig_map: RefCell::new(NodeMap()),
|
||||
|
@ -316,7 +315,8 @@ impl<'a, 'tcx> Inherited<'a, 'tcx> {
|
|||
let mut fulfillment_cx = self.infcx.fulfillment_cx.borrow_mut();
|
||||
assoc::normalize_associated_types_in(&self.infcx,
|
||||
typer,
|
||||
&mut *fulfillment_cx, span,
|
||||
&mut fulfillment_cx,
|
||||
span,
|
||||
body_id,
|
||||
value)
|
||||
}
|
||||
|
@ -1560,7 +1560,6 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||
let raw_ty = self.infcx().shallow_resolve(raw_ty);
|
||||
let resolve_ty = |ty: Ty<'tcx>| self.infcx().resolve_type_vars_if_possible(&ty);
|
||||
raw_ty.adjust(self.tcx(), expr.span, expr.id, adjustment, |method_call| {
|
||||
.method_map
|
||||
self.inh.tables.borrow().method_map.get(&method_call)
|
||||
.map(|method| resolve_ty(method.ty))
|
||||
})
|
||||
|
|
|
@ -531,7 +531,7 @@ impl<'a, 'tcx> CoherenceChecker<'a, 'tcx> {
|
|||
}
|
||||
};
|
||||
|
||||
let mut fulfill_cx = infcx.fulfillment_cx.borrow_mut();
|
||||
let mut fulfill_cx = infcx.fulfillment_cx.borrow_mut();
|
||||
|
||||
// Register an obligation for `A: Trait<B>`.
|
||||
let cause = traits::ObligationCause::misc(span, impl_did.node);
|
||||
|
@ -633,7 +633,7 @@ pub fn check_coherence(crate_context: &CrateCtxt) {
|
|||
CoherenceChecker {
|
||||
crate_context: crate_context,
|
||||
// XXXJAREDXXX: not sure if the bool is right here?
|
||||
inference_context: new_infer_ctxt(crate_context.tcx, &crate_context.tcx.tables, None, false),
|
||||
inference_context: new_infer_ctxt(crate_context.tcx, &crate_context.tcx.tables, None, true),
|
||||
inherent_impls: RefCell::new(FnvHashMap()),
|
||||
}.check(crate_context.tcx.map.krate());
|
||||
unsafety::check(crate_context.tcx);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue