fallout from removing the errors_will_be_reported
flag
This commit is contained in:
parent
2c3f0123e9
commit
20e088c4e2
@ -125,7 +125,7 @@ impl<'a, 'tcx> CheckCrateVisitor<'a, 'tcx> {
|
||||
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))
|
||||
}
|
||||
@ -295,7 +295,7 @@ impl<'a, 'tcx> CheckCrateVisitor<'a, 'tcx> {
|
||||
|
||||
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);
|
||||
|
@ -1094,8 +1094,7 @@ fn check_legality_of_move_bindings(cx: &MatchCheckCtxt,
|
||||
//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));
|
||||
}
|
||||
@ -1127,8 +1126,7 @@ fn check_for_mutation_in_guard<'a, 'tcx>(cx: &'a MatchCheckCtxt<'a, 'tcx>,
|
||||
|
||||
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);
|
||||
|
@ -44,8 +44,7 @@ impl<'a, 'tcx, 'v> intravisit::Visitor<'v> for RvalueContext<'a, 'tcx> {
|
||||
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);
|
||||
|
@ -1247,7 +1247,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, 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(),
|
||||
|
@ -354,16 +354,9 @@ pub fn fixup_err_to_string(f: FixupError) -> String {
|
||||
}
|
||||
}
|
||||
|
||||
/// 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,
|
||||
@ -373,7 +366,7 @@ pub fn new_infer_ctxt<'a, 'tcx>(tcx: &'a ty::ctxt<'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()
|
||||
@ -383,7 +376,7 @@ pub fn new_infer_ctxt<'a, 'tcx>(tcx: &'a ty::ctxt<'tcx>,
|
||||
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
|
||||
}
|
||||
@ -522,7 +515,7 @@ pub fn normalize_associated_type<'tcx,T>(tcx: &ty::ctxt<'tcx>, value: &T) -> T
|
||||
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 } =
|
||||
|
@ -356,7 +356,7 @@ pub fn type_known_to_meet_builtin_bound<'a,'tcx>(infcx: &InferCtxt<'a,'tcx>,
|
||||
// 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
|
||||
@ -434,8 +434,9 @@ pub fn normalize_param_env_or_error<'a,'tcx>(unnormalized_env: ty::ParameterEnvi
|
||||
|
||||
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) => {
|
||||
@ -444,6 +445,9 @@ pub fn normalize_param_env_or_error<'a,'tcx>(unnormalized_env: ty::ParameterEnvi
|
||||
}
|
||||
};
|
||||
|
||||
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) {
|
||||
@ -462,6 +466,9 @@ pub fn normalize_param_env_or_error<'a,'tcx>(unnormalized_env: ty::ParameterEnvi
|
||||
}
|
||||
};
|
||||
|
||||
debug!("normalize_param_env_or_error: resolved predicates={:?}",
|
||||
predicates);
|
||||
|
||||
infcx.parameter_environment.with_caller_bounds(predicates)
|
||||
}
|
||||
|
||||
@ -471,7 +478,7 @@ pub fn fully_normalize<'a,'tcx,T>(infcx: &InferCtxt<'a,'tcx>,
|
||||
-> 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
|
||||
@ -487,20 +494,28 @@ pub fn fully_normalize<'a,'tcx,T>(infcx: &InferCtxt<'a,'tcx>,
|
||||
//
|
||||
// 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)
|
||||
}
|
||||
|
||||
|
@ -182,7 +182,7 @@ impl<'a, 'tcx> ParameterEnvironment<'a, 'tcx> {
|
||||
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) => {
|
||||
@ -655,7 +655,7 @@ impl<'tcx> ty::TyS<'tcx> {
|
||||
-> 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);
|
||||
|
@ -202,7 +202,7 @@ pub fn check_loans<'a, 'b, 'c, 'tcx>(bccx: &BorrowckCtxt<'a, 'tcx>,
|
||||
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,
|
||||
|
@ -55,7 +55,7 @@ pub fn gather_loans_in_fn<'a, 'tcx>(bccx: &BorrowckCtxt<'a, 'tcx>,
|
||||
};
|
||||
|
||||
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);
|
||||
@ -525,7 +525,7 @@ struct StaticInitializerCtxt<'a, 'tcx: 'a> {
|
||||
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);
|
||||
|
@ -143,7 +143,7 @@ impl<'a, 'm, 'tcx> Visitor<'tcx> for InnerDump<'a,'m,'tcx> {
|
||||
|
||||
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) => {
|
||||
|
@ -42,7 +42,7 @@ pub fn compare_impl_method<'tcx>(tcx: &ty::ctxt<'tcx>,
|
||||
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;
|
||||
@ -416,7 +416,7 @@ pub fn compare_const_impl<'tcx>(tcx: &ty::ctxt<'tcx>,
|
||||
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
|
||||
|
@ -83,7 +83,7 @@ fn ensure_drop_params_and_item_params_correspond<'tcx>(
|
||||
// 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);
|
||||
|
@ -305,7 +305,7 @@ impl<'a, 'tcx> Inherited<'a, 'tcx> {
|
||||
-> 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()),
|
||||
|
@ -384,7 +384,7 @@ impl<'a, 'tcx> CoherenceChecker<'a, 'tcx> {
|
||||
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>| {
|
||||
@ -528,7 +528,7 @@ fn enforce_trait_manually_implementable(tcx: &ty::ctxt, sp: Span, trait_def_id:
|
||||
|
||||
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,
|
||||
|
@ -127,7 +127,7 @@ impl<'cx, 'tcx> OverlapChecker<'cx, 'tcx> {
|
||||
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);
|
||||
}
|
||||
|
@ -193,7 +193,7 @@ fn require_same_types<'a, 'tcx, M>(tcx: &ty::ctxt<'tcx>,
|
||||
{
|
||||
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) => {
|
||||
|
Loading…
Reference in New Issue
Block a user