fallout from removing the errors_will_be_reported flag
This commit is contained in:
parent
2c3f0123e9
commit
20e088c4e2
16 changed files with 47 additions and 42 deletions
|
|
@ -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);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue