Skip to content

Commit 20e088c

Browse files
committed
fallout from removing the errors_will_be_reported flag
1 parent 2c3f012 commit 20e088c

File tree

16 files changed

+47
-42
lines changed

16 files changed

+47
-42
lines changed

src/librustc/middle/check_const.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ impl<'a, 'tcx> CheckCrateVisitor<'a, 'tcx> {
125125
None => self.tcx.empty_parameter_environment()
126126
};
127127

128-
let infcx = infer::new_infer_ctxt(self.tcx, &self.tcx.tables, Some(param_env), false);
128+
let infcx = infer::new_infer_ctxt(self.tcx, &self.tcx.tables, Some(param_env));
129129

130130
f(&mut euv::ExprUseVisitor::new(self, &infcx))
131131
}
@@ -295,7 +295,7 @@ impl<'a, 'tcx> CheckCrateVisitor<'a, 'tcx> {
295295

296296
fn check_static_type(&self, e: &hir::Expr) {
297297
let ty = self.tcx.node_id_to_type(e.id);
298-
let infcx = infer::new_infer_ctxt(self.tcx, &self.tcx.tables, None, false);
298+
let infcx = infer::new_infer_ctxt(self.tcx, &self.tcx.tables, None);
299299
let cause = traits::ObligationCause::new(e.span, e.id, traits::SharedStatic);
300300
let mut fulfill_cx = infcx.fulfillment_cx.borrow_mut();
301301
fulfill_cx.register_builtin_bound(&infcx, ty, ty::BoundSync, cause);

src/librustc/middle/check_match.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1094,8 +1094,7 @@ fn check_legality_of_move_bindings(cx: &MatchCheckCtxt,
10941094
//FIXME: (@jroesch) this code should be floated up as well
10951095
let infcx = infer::new_infer_ctxt(cx.tcx,
10961096
&cx.tcx.tables,
1097-
Some(cx.param_env.clone()),
1098-
false);
1097+
Some(cx.param_env.clone()));
10991098
if infcx.type_moves_by_default(pat_ty, pat.span) {
11001099
check_move(p, sub.as_ref().map(|p| &**p));
11011100
}
@@ -1127,8 +1126,7 @@ fn check_for_mutation_in_guard<'a, 'tcx>(cx: &'a MatchCheckCtxt<'a, 'tcx>,
11271126

11281127
let infcx = infer::new_infer_ctxt(cx.tcx,
11291128
&cx.tcx.tables,
1130-
Some(checker.cx.param_env.clone()),
1131-
false);
1129+
Some(checker.cx.param_env.clone()));
11321130

11331131
let mut visitor = ExprUseVisitor::new(&mut checker, &infcx);
11341132
visitor.walk_expr(guard);

src/librustc/middle/check_rvalues.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,7 @@ impl<'a, 'tcx, 'v> intravisit::Visitor<'v> for RvalueContext<'a, 'tcx> {
4444
let param_env = ParameterEnvironment::for_item(self.tcx, fn_id);
4545
let infcx = infer::new_infer_ctxt(self.tcx,
4646
&self.tcx.tables,
47-
Some(param_env.clone()),
48-
false);
47+
Some(param_env.clone()));
4948
let mut delegate = RvalueContextDelegate { tcx: self.tcx, param_env: &param_env };
5049
let mut euv = euv::ExprUseVisitor::new(&mut delegate, &infcx);
5150
euv.walk_fn(fd, b);

src/librustc/middle/const_eval.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1247,7 +1247,7 @@ fn resolve_trait_associated_const<'a, 'tcx: 'a>(tcx: &'a ty::ctxt<'tcx>,
12471247
substs: trait_substs });
12481248

12491249
tcx.populate_implementations_for_trait_if_necessary(trait_ref.def_id());
1250-
let infcx = infer::new_infer_ctxt(tcx, &tcx.tables, None, false);
1250+
let infcx = infer::new_infer_ctxt(tcx, &tcx.tables, None);
12511251

12521252
let mut selcx = traits::SelectionContext::new(&infcx);
12531253
let obligation = traits::Obligation::new(traits::ObligationCause::dummy(),

src/librustc/middle/infer/mod.rs

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -354,16 +354,9 @@ pub fn fixup_err_to_string(f: FixupError) -> String {
354354
}
355355
}
356356

357-
/// errors_will_be_reported is required to proxy to the fulfillment context
358-
/// FIXME -- a better option would be to hold back on modifying
359-
/// the global cache until we know that all dependent obligations
360-
/// are also satisfied. In that case, we could actually remove
361-
/// this boolean flag, and we'd also avoid the problem of squelching
362-
/// duplicate errors that occur across fns.
363357
pub fn new_infer_ctxt<'a, 'tcx>(tcx: &'a ty::ctxt<'tcx>,
364358
tables: &'a RefCell<ty::Tables<'tcx>>,
365-
param_env: Option<ty::ParameterEnvironment<'a, 'tcx>>,
366-
errors_will_be_reported: bool)
359+
param_env: Option<ty::ParameterEnvironment<'a, 'tcx>>)
367360
-> InferCtxt<'a, 'tcx> {
368361
InferCtxt {
369362
tcx: tcx,
@@ -373,7 +366,7 @@ pub fn new_infer_ctxt<'a, 'tcx>(tcx: &'a ty::ctxt<'tcx>,
373366
float_unification_table: RefCell::new(UnificationTable::new()),
374367
region_vars: RegionVarBindings::new(tcx),
375368
parameter_environment: param_env.unwrap_or(tcx.empty_parameter_environment()),
376-
fulfillment_cx: RefCell::new(traits::FulfillmentContext::new(errors_will_be_reported)),
369+
fulfillment_cx: RefCell::new(traits::FulfillmentContext::new()),
377370
reported_trait_errors: RefCell::new(FnvHashSet()),
378371
normalize: false,
379372
err_count_on_creation: tcx.sess.err_count()
@@ -383,7 +376,7 @@ pub fn new_infer_ctxt<'a, 'tcx>(tcx: &'a ty::ctxt<'tcx>,
383376
pub fn normalizing_infer_ctxt<'a, 'tcx>(tcx: &'a ty::ctxt<'tcx>,
384377
tables: &'a RefCell<ty::Tables<'tcx>>)
385378
-> InferCtxt<'a, 'tcx> {
386-
let mut infcx = new_infer_ctxt(tcx, tables, None, false);
379+
let mut infcx = new_infer_ctxt(tcx, tables, None);
387380
infcx.normalize = true;
388381
infcx
389382
}
@@ -522,7 +515,7 @@ pub fn normalize_associated_type<'tcx,T>(tcx: &ty::ctxt<'tcx>, value: &T) -> T
522515
return value;
523516
}
524517

525-
let infcx = new_infer_ctxt(tcx, &tcx.tables, None, true);
518+
let infcx = new_infer_ctxt(tcx, &tcx.tables, None);
526519
let mut selcx = traits::SelectionContext::new(&infcx);
527520
let cause = traits::ObligationCause::dummy();
528521
let traits::Normalized { value: result, obligations } =

src/librustc/middle/traits/mod.rs

Lines changed: 23 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -356,7 +356,7 @@ pub fn type_known_to_meet_builtin_bound<'a,'tcx>(infcx: &InferCtxt<'a,'tcx>,
356356
// this function's result remains infallible, we must confirm
357357
// that guess. While imperfect, I believe this is sound.
358358

359-
let mut fulfill_cx = FulfillmentContext::new(false);
359+
let mut fulfill_cx = FulfillmentContext::new();
360360

361361
// We can use a dummy node-id here because we won't pay any mind
362362
// 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
434434

435435
let elaborated_env = unnormalized_env.with_caller_bounds(predicates);
436436

437-
let infcx = infer::new_infer_ctxt(tcx, &tcx.tables, Some(elaborated_env), false);
438-
let predicates = match fully_normalize(&infcx, cause,
437+
let infcx = infer::new_infer_ctxt(tcx, &tcx.tables, Some(elaborated_env));
438+
let predicates = match fully_normalize(&infcx,
439+
cause,
439440
&infcx.parameter_environment.caller_bounds) {
440441
Ok(predicates) => predicates,
441442
Err(errors) => {
@@ -444,6 +445,9 @@ pub fn normalize_param_env_or_error<'a,'tcx>(unnormalized_env: ty::ParameterEnvi
444445
}
445446
};
446447

448+
debug!("normalize_param_env_or_error: normalized predicates={:?}",
449+
predicates);
450+
447451
let free_regions = FreeRegionMap::new();
448452
infcx.resolve_regions_and_report_errors(&free_regions, body_id);
449453
let predicates = match infcx.fully_resolve(&predicates) {
@@ -462,6 +466,9 @@ pub fn normalize_param_env_or_error<'a,'tcx>(unnormalized_env: ty::ParameterEnvi
462466
}
463467
};
464468

469+
debug!("normalize_param_env_or_error: resolved predicates={:?}",
470+
predicates);
471+
465472
infcx.parameter_environment.with_caller_bounds(predicates)
466473
}
467474

@@ -471,7 +478,7 @@ pub fn fully_normalize<'a,'tcx,T>(infcx: &InferCtxt<'a,'tcx>,
471478
-> Result<T, Vec<FulfillmentError<'tcx>>>
472479
where T : TypeFoldable<'tcx>
473480
{
474-
debug!("normalize_param_env(value={:?})", value);
481+
debug!("fully_normalize(value={:?})", value);
475482

476483
let mut selcx = &mut SelectionContext::new(infcx);
477484
// FIXME (@jroesch) ISSUE 26721
@@ -487,20 +494,28 @@ pub fn fully_normalize<'a,'tcx,T>(infcx: &InferCtxt<'a,'tcx>,
487494
//
488495
// I think we should probably land this refactor and then come
489496
// back to this is a follow-up patch.
490-
let mut fulfill_cx = FulfillmentContext::new(false);
497+
let mut fulfill_cx = FulfillmentContext::new();
491498

492499
let Normalized { value: normalized_value, obligations } =
493500
project::normalize(selcx, cause, value);
494-
debug!("normalize_param_env: normalized_value={:?} obligations={:?}",
501+
debug!("fully_normalize: normalized_value={:?} obligations={:?}",
495502
normalized_value,
496503
obligations);
497504
for obligation in obligations {
498505
fulfill_cx.register_predicate_obligation(selcx.infcx(), obligation);
499506
}
500507

501-
try!(fulfill_cx.select_all_or_error(infcx));
508+
debug!("fully_normalize: select_all_or_error start");
509+
match fulfill_cx.select_all_or_error(infcx) {
510+
Ok(()) => { }
511+
Err(e) => {
512+
debug!("fully_normalize: error={:?}", e);
513+
return Err(e);
514+
}
515+
}
516+
debug!("fully_normalize: select_all_or_error complete");
502517
let resolved_value = infcx.resolve_type_vars_if_possible(&normalized_value);
503-
debug!("normalize_param_env: resolved_value={:?}", resolved_value);
518+
debug!("fully_normalize: resolved_value={:?}", resolved_value);
504519
Ok(resolved_value)
505520
}
506521

src/librustc/middle/ty/util.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ impl<'a, 'tcx> ParameterEnvironment<'a, 'tcx> {
182182
let tcx = self.tcx;
183183

184184
// FIXME: (@jroesch) float this code up
185-
let infcx = infer::new_infer_ctxt(tcx, &tcx.tables, Some(self.clone()), false);
185+
let infcx = infer::new_infer_ctxt(tcx, &tcx.tables, Some(self.clone()));
186186

187187
let adt = match self_type.sty {
188188
ty::TyStruct(struct_def, substs) => {
@@ -655,7 +655,7 @@ impl<'tcx> ty::TyS<'tcx> {
655655
-> bool
656656
{
657657
let tcx = param_env.tcx;
658-
let infcx = infer::new_infer_ctxt(tcx, &tcx.tables, Some(param_env.clone()), false);
658+
let infcx = infer::new_infer_ctxt(tcx, &tcx.tables, Some(param_env.clone()));
659659

660660
let is_impld = traits::type_known_to_meet_builtin_bound(&infcx,
661661
self, bound, span);

src/librustc_borrowck/borrowck/check_loans.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ pub fn check_loans<'a, 'b, 'c, 'tcx>(bccx: &BorrowckCtxt<'a, 'tcx>,
202202
debug!("check_loans(body id={})", body.id);
203203

204204
let param_env = ty::ParameterEnvironment::for_item(bccx.tcx, fn_id);
205-
let infcx = infer::new_infer_ctxt(bccx.tcx, &bccx.tcx.tables, Some(param_env), false);
205+
let infcx = infer::new_infer_ctxt(bccx.tcx, &bccx.tcx.tables, Some(param_env));
206206

207207
let mut clcx = CheckLoanCtxt {
208208
bccx: bccx,

src/librustc_borrowck/borrowck/gather_loans/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ pub fn gather_loans_in_fn<'a, 'tcx>(bccx: &BorrowckCtxt<'a, 'tcx>,
5555
};
5656

5757
let param_env = ty::ParameterEnvironment::for_item(bccx.tcx, fn_id);
58-
let infcx = infer::new_infer_ctxt(bccx.tcx, &bccx.tcx.tables, Some(param_env), false);
58+
let infcx = infer::new_infer_ctxt(bccx.tcx, &bccx.tcx.tables, Some(param_env));
5959
{
6060
let mut euv = euv::ExprUseVisitor::new(&mut glcx, &infcx);
6161
euv.walk_fn(decl, body);
@@ -525,7 +525,7 @@ struct StaticInitializerCtxt<'a, 'tcx: 'a> {
525525
impl<'a, 'tcx, 'v> Visitor<'v> for StaticInitializerCtxt<'a, 'tcx> {
526526
fn visit_expr(&mut self, ex: &Expr) {
527527
if let hir::ExprAddrOf(mutbl, ref base) = ex.node {
528-
let infcx = infer::new_infer_ctxt(self.bccx.tcx, &self.bccx.tcx.tables, None, false);
528+
let infcx = infer::new_infer_ctxt(self.bccx.tcx, &self.bccx.tcx.tables, None);
529529
let mc = mc::MemCategorizationContext::new(&infcx);
530530
let base_cmt = mc.cat_expr(&**base).unwrap();
531531
let borrow_kind = ty::BorrowKind::from_mutbl(mutbl);

src/librustc_mir/mir_map.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ impl<'a, 'm, 'tcx> Visitor<'tcx> for InnerDump<'a,'m,'tcx> {
143143

144144
let param_env = ty::ParameterEnvironment::for_item(self.tcx, id);
145145

146-
let infcx = infer::new_infer_ctxt(self.tcx, &self.tcx.tables, Some(param_env), true);
146+
let infcx = infer::new_infer_ctxt(self.tcx, &self.tcx.tables, Some(param_env));
147147

148148
match build_mir(Cx::new(&infcx), implicit_arg_tys, id, span, decl, body) {
149149
Ok(mut mir) => {

src/librustc_typeck/check/compare_method.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ pub fn compare_impl_method<'tcx>(tcx: &ty::ctxt<'tcx>,
4242
debug!("compare_impl_method: impl_trait_ref (liberated) = {:?}",
4343
impl_trait_ref);
4444

45-
let mut infcx = infer::new_infer_ctxt(tcx, &tcx.tables, None, true);
45+
let mut infcx = infer::new_infer_ctxt(tcx, &tcx.tables, None);
4646
let mut fulfillment_cx = infcx.fulfillment_cx.borrow_mut();
4747

4848
let trait_to_impl_substs = &impl_trait_ref.substs;
@@ -416,7 +416,7 @@ pub fn compare_const_impl<'tcx>(tcx: &ty::ctxt<'tcx>,
416416
debug!("compare_const_impl(impl_trait_ref={:?})",
417417
impl_trait_ref);
418418

419-
let infcx = infer::new_infer_ctxt(tcx, &tcx.tables, None, true);
419+
let infcx = infer::new_infer_ctxt(tcx, &tcx.tables, None);
420420
let mut fulfillment_cx = infcx.fulfillment_cx.borrow_mut();
421421

422422
// The below is for the most part highly similar to the procedure

src/librustc_typeck/check/dropck.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ fn ensure_drop_params_and_item_params_correspond<'tcx>(
8383
// check that the impl type can be made to match the trait type.
8484

8585
let impl_param_env = ty::ParameterEnvironment::for_item(tcx, self_type_node_id);
86-
let infcx = infer::new_infer_ctxt(tcx, &tcx.tables, Some(impl_param_env), true);
86+
let infcx = infer::new_infer_ctxt(tcx, &tcx.tables, Some(impl_param_env));
8787

8888
let named_type = tcx.lookup_item_type(self_type_did).ty;
8989
let named_type = named_type.subst(tcx, &infcx.parameter_environment.free_substs);

src/librustc_typeck/check/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -305,7 +305,7 @@ impl<'a, 'tcx> Inherited<'a, 'tcx> {
305305
-> Inherited<'a, 'tcx> {
306306

307307
Inherited {
308-
infcx: infer::new_infer_ctxt(tcx, tables, Some(param_env), true),
308+
infcx: infer::new_infer_ctxt(tcx, tables, Some(param_env)),
309309
locals: RefCell::new(NodeMap()),
310310
tables: tables,
311311
deferred_call_resolutions: RefCell::new(DefIdMap()),

src/librustc_typeck/coherence/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -384,7 +384,7 @@ impl<'a, 'tcx> CoherenceChecker<'a, 'tcx> {
384384
debug!("check_implementations_of_coerce_unsized: {:?} -> {:?} (free)",
385385
source, target);
386386

387-
let infcx = new_infer_ctxt(tcx, &tcx.tables, Some(param_env), true);
387+
let infcx = new_infer_ctxt(tcx, &tcx.tables, Some(param_env));
388388

389389
let check_mutbl = |mt_a: ty::TypeAndMut<'tcx>, mt_b: ty::TypeAndMut<'tcx>,
390390
mk_ptr: &Fn(Ty<'tcx>) -> Ty<'tcx>| {
@@ -528,7 +528,7 @@ fn enforce_trait_manually_implementable(tcx: &ty::ctxt, sp: Span, trait_def_id:
528528

529529
pub fn check_coherence(crate_context: &CrateCtxt) {
530530
let _task = crate_context.tcx.dep_graph.in_task(DepNode::Coherence);
531-
let infcx = new_infer_ctxt(crate_context.tcx, &crate_context.tcx.tables, None, true);
531+
let infcx = new_infer_ctxt(crate_context.tcx, &crate_context.tcx.tables, None);
532532
CoherenceChecker {
533533
crate_context: crate_context,
534534
inference_context: infcx,

src/librustc_typeck/coherence/overlap.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ impl<'cx, 'tcx> OverlapChecker<'cx, 'tcx> {
127127
impl1_def_id,
128128
impl2_def_id);
129129

130-
let infcx = infer::new_infer_ctxt(self.tcx, &self.tcx.tables, None, false);
130+
let infcx = infer::new_infer_ctxt(self.tcx, &self.tcx.tables, None);
131131
if let Some(trait_ref) = traits::overlapping_impls(&infcx, impl1_def_id, impl2_def_id) {
132132
self.report_overlap_error(impl1_def_id, impl2_def_id, trait_ref);
133133
}

src/librustc_typeck/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ fn require_same_types<'a, 'tcx, M>(tcx: &ty::ctxt<'tcx>,
193193
{
194194
let result = match maybe_infcx {
195195
None => {
196-
let infcx = infer::new_infer_ctxt(tcx, &tcx.tables, None, false);
196+
let infcx = infer::new_infer_ctxt(tcx, &tcx.tables, None);
197197
infer::mk_eqty(&infcx, t1_is_expected, TypeOrigin::Misc(span), t1, t2)
198198
}
199199
Some(infcx) => {

0 commit comments

Comments
 (0)