None => self.tcx.empty_parameter_environment()
};
- let infcx = infer::new_infer_ctxt(self.tcx, &self.tcx.tables, Some(param_env), false);
+ let infcx = infer::new_infer_ctxt(self.tcx, &self.tcx.tables, Some(param_env));
f(&mut euv::ExprUseVisitor::new(self, &infcx))
}
fn check_static_type(&self, e: &hir::Expr) {
let ty = self.tcx.node_id_to_type(e.id);
- let infcx = infer::new_infer_ctxt(self.tcx, &self.tcx.tables, None, false);
+ let infcx = infer::new_infer_ctxt(self.tcx, &self.tcx.tables, None);
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);
//FIXME: (@jroesch) this code should be floated up as well
let infcx = infer::new_infer_ctxt(cx.tcx,
&cx.tcx.tables,
- Some(cx.param_env.clone()),
- false);
+ Some(cx.param_env.clone()));
if infcx.type_moves_by_default(pat_ty, pat.span) {
check_move(p, sub.as_ref().map(|p| &**p));
}
let infcx = infer::new_infer_ctxt(cx.tcx,
&cx.tcx.tables,
- Some(checker.cx.param_env.clone()),
- false);
+ Some(checker.cx.param_env.clone()));
let mut visitor = ExprUseVisitor::new(&mut checker, &infcx);
visitor.walk_expr(guard);
let param_env = ParameterEnvironment::for_item(self.tcx, fn_id);
let infcx = infer::new_infer_ctxt(self.tcx,
&self.tcx.tables,
- Some(param_env.clone()),
- false);
+ Some(param_env.clone()));
let mut delegate = RvalueContextDelegate { tcx: self.tcx, param_env: ¶m_env };
let mut euv = euv::ExprUseVisitor::new(&mut delegate, &infcx);
euv.walk_fn(fd, b);
substs: trait_substs });
tcx.populate_implementations_for_trait_if_necessary(trait_ref.def_id());
- let infcx = infer::new_infer_ctxt(tcx, &tcx.tables, None, false);
+ let infcx = infer::new_infer_ctxt(tcx, &tcx.tables, None);
let mut selcx = traits::SelectionContext::new(&infcx);
let obligation = traits::Obligation::new(traits::ObligationCause::dummy(),
}
}
-/// errors_will_be_reported is required to proxy to the fulfillment context
-/// FIXME -- a better option would be to hold back on modifying
-/// the global cache until we know that all dependent obligations
-/// are also satisfied. In that case, we could actually remove
-/// this boolean flag, and we'd also avoid the problem of squelching
-/// duplicate errors that occur across fns.
pub fn new_infer_ctxt<'a, 'tcx>(tcx: &'a ty::ctxt<'tcx>,
tables: &'a RefCell<ty::Tables<'tcx>>,
- param_env: Option<ty::ParameterEnvironment<'a, 'tcx>>,
- errors_will_be_reported: bool)
+ param_env: Option<ty::ParameterEnvironment<'a, 'tcx>>)
-> InferCtxt<'a, 'tcx> {
InferCtxt {
tcx: tcx,
float_unification_table: RefCell::new(UnificationTable::new()),
region_vars: RegionVarBindings::new(tcx),
parameter_environment: param_env.unwrap_or(tcx.empty_parameter_environment()),
- fulfillment_cx: RefCell::new(traits::FulfillmentContext::new(errors_will_be_reported)),
+ fulfillment_cx: RefCell::new(traits::FulfillmentContext::new()),
reported_trait_errors: RefCell::new(FnvHashSet()),
normalize: false,
err_count_on_creation: tcx.sess.err_count()
pub fn normalizing_infer_ctxt<'a, 'tcx>(tcx: &'a ty::ctxt<'tcx>,
tables: &'a RefCell<ty::Tables<'tcx>>)
-> InferCtxt<'a, 'tcx> {
- let mut infcx = new_infer_ctxt(tcx, tables, None, false);
+ let mut infcx = new_infer_ctxt(tcx, tables, None);
infcx.normalize = true;
infcx
}
return value;
}
- let infcx = new_infer_ctxt(tcx, &tcx.tables, None, true);
+ let infcx = new_infer_ctxt(tcx, &tcx.tables, None);
let mut selcx = traits::SelectionContext::new(&infcx);
let cause = traits::ObligationCause::dummy();
let traits::Normalized { value: result, obligations } =
// this function's result remains infallible, we must confirm
// that guess. While imperfect, I believe this is sound.
- let mut fulfill_cx = FulfillmentContext::new(false);
+ let mut fulfill_cx = FulfillmentContext::new();
// 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
let elaborated_env = unnormalized_env.with_caller_bounds(predicates);
- let infcx = infer::new_infer_ctxt(tcx, &tcx.tables, Some(elaborated_env), false);
- let predicates = match fully_normalize(&infcx, cause,
+ let infcx = infer::new_infer_ctxt(tcx, &tcx.tables, Some(elaborated_env));
+ let predicates = match fully_normalize(&infcx,
+ cause,
&infcx.parameter_environment.caller_bounds) {
Ok(predicates) => predicates,
Err(errors) => {
}
};
+ debug!("normalize_param_env_or_error: normalized predicates={:?}",
+ predicates);
+
let free_regions = FreeRegionMap::new();
infcx.resolve_regions_and_report_errors(&free_regions, body_id);
let predicates = match infcx.fully_resolve(&predicates) {
}
};
+ debug!("normalize_param_env_or_error: resolved predicates={:?}",
+ predicates);
+
infcx.parameter_environment.with_caller_bounds(predicates)
}
-> Result<T, Vec<FulfillmentError<'tcx>>>
where T : TypeFoldable<'tcx>
{
- debug!("normalize_param_env(value={:?})", value);
+ debug!("fully_normalize(value={:?})", value);
let mut selcx = &mut SelectionContext::new(infcx);
// FIXME (@jroesch) ISSUE 26721
//
// 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 = FulfillmentContext::new();
let Normalized { value: normalized_value, obligations } =
project::normalize(selcx, cause, value);
- debug!("normalize_param_env: normalized_value={:?} obligations={:?}",
+ debug!("fully_normalize: normalized_value={:?} obligations={:?}",
normalized_value,
obligations);
for obligation in obligations {
fulfill_cx.register_predicate_obligation(selcx.infcx(), obligation);
}
- try!(fulfill_cx.select_all_or_error(infcx));
+ debug!("fully_normalize: select_all_or_error start");
+ match fulfill_cx.select_all_or_error(infcx) {
+ Ok(()) => { }
+ Err(e) => {
+ debug!("fully_normalize: error={:?}", e);
+ return Err(e);
+ }
+ }
+ debug!("fully_normalize: select_all_or_error complete");
let resolved_value = infcx.resolve_type_vars_if_possible(&normalized_value);
- debug!("normalize_param_env: resolved_value={:?}", resolved_value);
+ debug!("fully_normalize: resolved_value={:?}", resolved_value);
Ok(resolved_value)
}
let tcx = self.tcx;
// FIXME: (@jroesch) float this code up
- let infcx = infer::new_infer_ctxt(tcx, &tcx.tables, Some(self.clone()), false);
+ let infcx = infer::new_infer_ctxt(tcx, &tcx.tables, Some(self.clone()));
let adt = match self_type.sty {
ty::TyStruct(struct_def, substs) => {
-> bool
{
let tcx = param_env.tcx;
- let infcx = infer::new_infer_ctxt(tcx, &tcx.tables, Some(param_env.clone()), false);
+ let infcx = infer::new_infer_ctxt(tcx, &tcx.tables, Some(param_env.clone()));
let is_impld = traits::type_known_to_meet_builtin_bound(&infcx,
self, bound, span);
debug!("check_loans(body id={})", body.id);
let param_env = ty::ParameterEnvironment::for_item(bccx.tcx, fn_id);
- let infcx = infer::new_infer_ctxt(bccx.tcx, &bccx.tcx.tables, Some(param_env), false);
+ let infcx = infer::new_infer_ctxt(bccx.tcx, &bccx.tcx.tables, Some(param_env));
let mut clcx = CheckLoanCtxt {
bccx: bccx,
};
let param_env = ty::ParameterEnvironment::for_item(bccx.tcx, fn_id);
- let infcx = infer::new_infer_ctxt(bccx.tcx, &bccx.tcx.tables, Some(param_env), false);
+ let infcx = infer::new_infer_ctxt(bccx.tcx, &bccx.tcx.tables, Some(param_env));
{
let mut euv = euv::ExprUseVisitor::new(&mut glcx, &infcx);
euv.walk_fn(decl, body);
impl<'a, 'tcx, 'v> Visitor<'v> for StaticInitializerCtxt<'a, 'tcx> {
fn visit_expr(&mut self, ex: &Expr) {
if let hir::ExprAddrOf(mutbl, ref base) = ex.node {
- let infcx = infer::new_infer_ctxt(self.bccx.tcx, &self.bccx.tcx.tables, None, false);
+ let infcx = infer::new_infer_ctxt(self.bccx.tcx, &self.bccx.tcx.tables, None);
let mc = mc::MemCategorizationContext::new(&infcx);
let base_cmt = mc.cat_expr(&**base).unwrap();
let borrow_kind = ty::BorrowKind::from_mutbl(mutbl);
let param_env = ty::ParameterEnvironment::for_item(self.tcx, id);
- let infcx = infer::new_infer_ctxt(self.tcx, &self.tcx.tables, Some(param_env), true);
+ let infcx = infer::new_infer_ctxt(self.tcx, &self.tcx.tables, Some(param_env));
match build_mir(Cx::new(&infcx), implicit_arg_tys, id, span, decl, body) {
Ok(mut mir) => {
debug!("compare_impl_method: impl_trait_ref (liberated) = {:?}",
impl_trait_ref);
- let mut infcx = infer::new_infer_ctxt(tcx, &tcx.tables, None, true);
+ let mut infcx = infer::new_infer_ctxt(tcx, &tcx.tables, None);
let mut fulfillment_cx = infcx.fulfillment_cx.borrow_mut();
let trait_to_impl_substs = &impl_trait_ref.substs;
debug!("compare_const_impl(impl_trait_ref={:?})",
impl_trait_ref);
- let infcx = infer::new_infer_ctxt(tcx, &tcx.tables, None, true);
+ let infcx = infer::new_infer_ctxt(tcx, &tcx.tables, None);
let mut fulfillment_cx = infcx.fulfillment_cx.borrow_mut();
// The below is for the most part highly similar to the procedure
// check that the impl type can be made to match the trait type.
let impl_param_env = ty::ParameterEnvironment::for_item(tcx, self_type_node_id);
- let infcx = infer::new_infer_ctxt(tcx, &tcx.tables, Some(impl_param_env), true);
+ let infcx = infer::new_infer_ctxt(tcx, &tcx.tables, Some(impl_param_env));
let named_type = tcx.lookup_item_type(self_type_did).ty;
let named_type = named_type.subst(tcx, &infcx.parameter_environment.free_substs);
-> Inherited<'a, 'tcx> {
Inherited {
- infcx: infer::new_infer_ctxt(tcx, tables, Some(param_env), true),
+ infcx: infer::new_infer_ctxt(tcx, tables, Some(param_env)),
locals: RefCell::new(NodeMap()),
tables: tables,
deferred_call_resolutions: RefCell::new(DefIdMap()),
debug!("check_implementations_of_coerce_unsized: {:?} -> {:?} (free)",
source, target);
- let infcx = new_infer_ctxt(tcx, &tcx.tables, Some(param_env), true);
+ let infcx = new_infer_ctxt(tcx, &tcx.tables, Some(param_env));
let check_mutbl = |mt_a: ty::TypeAndMut<'tcx>, mt_b: ty::TypeAndMut<'tcx>,
mk_ptr: &Fn(Ty<'tcx>) -> Ty<'tcx>| {
pub fn check_coherence(crate_context: &CrateCtxt) {
let _task = crate_context.tcx.dep_graph.in_task(DepNode::Coherence);
- let infcx = new_infer_ctxt(crate_context.tcx, &crate_context.tcx.tables, None, true);
+ let infcx = new_infer_ctxt(crate_context.tcx, &crate_context.tcx.tables, None);
CoherenceChecker {
crate_context: crate_context,
inference_context: infcx,
impl1_def_id,
impl2_def_id);
- let infcx = infer::new_infer_ctxt(self.tcx, &self.tcx.tables, None, false);
+ let infcx = infer::new_infer_ctxt(self.tcx, &self.tcx.tables, None);
if let Some(trait_ref) = traits::overlapping_impls(&infcx, impl1_def_id, impl2_def_id) {
self.report_overlap_error(impl1_def_id, impl2_def_id, trait_ref);
}
{
let result = match maybe_infcx {
None => {
- let infcx = infer::new_infer_ctxt(tcx, &tcx.tables, None, false);
+ let infcx = infer::new_infer_ctxt(tcx, &tcx.tables, None);
infer::mk_eqty(&infcx, t1_is_expected, TypeOrigin::Misc(span), t1, t2)
}
Some(infcx) => {