Skip to content

Commit bdc1c61

Browse files
committed
fallout from removing the errors_will_be_reported flag
1 parent b8b4f5f commit bdc1c61

File tree

17 files changed

+48
-43
lines changed

17 files changed

+48
-43
lines changed

src/librustc/middle/check_const.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ impl<'a, 'tcx> CheckCrateVisitor<'a, 'tcx> {
124124
None => self.tcx.empty_parameter_environment()
125125
};
126126

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

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

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

src/librustc/middle/check_match.rs

+2-4
Original file line numberDiff line numberDiff line change
@@ -1091,8 +1091,7 @@ fn check_legality_of_move_bindings(cx: &MatchCheckCtxt,
10911091
//FIXME: (@jroesch) this code should be floated up as well
10921092
let infcx = infer::new_infer_ctxt(cx.tcx,
10931093
&cx.tcx.tables,
1094-
Some(cx.param_env.clone()),
1095-
false);
1094+
Some(cx.param_env.clone()));
10961095
if infcx.type_moves_by_default(pat_ty, pat.span) {
10971096
check_move(p, sub.as_ref().map(|p| &**p));
10981097
}
@@ -1124,8 +1123,7 @@ fn check_for_mutation_in_guard<'a, 'tcx>(cx: &'a MatchCheckCtxt<'a, 'tcx>,
11241123

11251124
let infcx = infer::new_infer_ctxt(cx.tcx,
11261125
&cx.tcx.tables,
1127-
Some(checker.cx.param_env.clone()),
1128-
false);
1126+
Some(checker.cx.param_env.clone()));
11291127

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

src/librustc/middle/check_rvalues.rs

+1-2
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

+1-1
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

+4-11
Original file line numberDiff line numberDiff line change
@@ -353,16 +353,9 @@ pub fn fixup_err_to_string(f: FixupError) -> String {
353353
}
354354
}
355355

356-
/// errors_will_be_reported is required to proxy to the fulfillment context
357-
/// FIXME -- a better option would be to hold back on modifying
358-
/// the global cache until we know that all dependent obligations
359-
/// are also satisfied. In that case, we could actually remove
360-
/// this boolean flag, and we'd also avoid the problem of squelching
361-
/// duplicate errors that occur across fns.
362356
pub fn new_infer_ctxt<'a, 'tcx>(tcx: &'a ty::ctxt<'tcx>,
363357
tables: &'a RefCell<ty::Tables<'tcx>>,
364-
param_env: Option<ty::ParameterEnvironment<'a, 'tcx>>,
365-
errors_will_be_reported: bool)
358+
param_env: Option<ty::ParameterEnvironment<'a, 'tcx>>)
366359
-> InferCtxt<'a, 'tcx> {
367360
InferCtxt {
368361
tcx: tcx,
@@ -372,7 +365,7 @@ pub fn new_infer_ctxt<'a, 'tcx>(tcx: &'a ty::ctxt<'tcx>,
372365
float_unification_table: RefCell::new(UnificationTable::new()),
373366
region_vars: RegionVarBindings::new(tcx),
374367
parameter_environment: param_env.unwrap_or(tcx.empty_parameter_environment()),
375-
fulfillment_cx: RefCell::new(traits::FulfillmentContext::new(errors_will_be_reported)),
368+
fulfillment_cx: RefCell::new(traits::FulfillmentContext::new()),
376369
reported_trait_errors: RefCell::new(FnvHashSet()),
377370
normalize: false,
378371
err_count_on_creation: tcx.sess.err_count()
@@ -382,7 +375,7 @@ pub fn new_infer_ctxt<'a, 'tcx>(tcx: &'a ty::ctxt<'tcx>,
382375
pub fn normalizing_infer_ctxt<'a, 'tcx>(tcx: &'a ty::ctxt<'tcx>,
383376
tables: &'a RefCell<ty::Tables<'tcx>>)
384377
-> InferCtxt<'a, 'tcx> {
385-
let mut infcx = new_infer_ctxt(tcx, tables, None, false);
378+
let mut infcx = new_infer_ctxt(tcx, tables, None);
386379
infcx.normalize = true;
387380
infcx
388381
}
@@ -521,7 +514,7 @@ pub fn normalize_associated_type<'tcx,T>(tcx: &ty::ctxt<'tcx>, value: &T) -> T
521514
return value;
522515
}
523516

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

src/librustc/middle/traits/mod.rs

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

358-
let mut fulfill_cx = FulfillmentContext::new(false);
358+
let mut fulfill_cx = FulfillmentContext::new();
359359

360360
// We can use a dummy node-id here because we won't pay any mind
361361
// to region obligations that arise (there shouldn't really be any
@@ -433,8 +433,9 @@ pub fn normalize_param_env_or_error<'a,'tcx>(unnormalized_env: ty::ParameterEnvi
433433

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

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

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

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

@@ -470,7 +477,7 @@ pub fn fully_normalize<'a,'tcx,T>(infcx: &InferCtxt<'a,'tcx>,
470477
-> Result<T, Vec<FulfillmentError<'tcx>>>
471478
where T : TypeFoldable<'tcx> + HasTypeFlags
472479
{
473-
debug!("normalize_param_env(value={:?})", value);
480+
debug!("fully_normalize(value={:?})", value);
474481

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

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

500-
try!(fulfill_cx.select_all_or_error(infcx));
507+
debug!("fully_normalize: select_all_or_error start");
508+
match fulfill_cx.select_all_or_error(infcx) {
509+
Ok(()) => { }
510+
Err(e) => {
511+
debug!("fully_normalize: error={:?}", e);
512+
return Err(e);
513+
}
514+
}
515+
debug!("fully_normalize: select_all_or_error complete");
501516
let resolved_value = infcx.resolve_type_vars_if_possible(&normalized_value);
502-
debug!("normalize_param_env: resolved_value={:?}", resolved_value);
517+
debug!("fully_normalize: resolved_value={:?}", resolved_value);
503518
Ok(resolved_value)
504519
}
505520

src/librustc/middle/ty/util.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ impl<'a, 'tcx> ParameterEnvironment<'a, 'tcx> {
183183
let tcx = self.tcx;
184184

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

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

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

src/librustc_borrowck/borrowck/check_loans.rs

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

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

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

src/librustc_borrowck/borrowck/gather_loans/mod.rs

+2-2
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

+1-1
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ impl<'a, 'm, 'tcx> Visitor<'tcx> for InnerDump<'a,'m,'tcx> {
141141

142142
let param_env = ty::ParameterEnvironment::for_item(self.tcx, id);
143143

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

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

src/librustc_typeck/check/compare_method.rs

+2-2
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

+1-1
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

+1-1
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,7 @@ impl<'a, 'tcx> Inherited<'a, 'tcx> {
303303
-> Inherited<'a, 'tcx> {
304304

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

src/librustc_typeck/coherence/mod.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -370,7 +370,7 @@ impl<'a, 'tcx> CoherenceChecker<'a, 'tcx> {
370370
debug!("check_implementations_of_coerce_unsized: {:?} -> {:?} (free)",
371371
source, target);
372372

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

375375
let check_mutbl = |mt_a: ty::TypeAndMut<'tcx>, mt_b: ty::TypeAndMut<'tcx>,
376376
mk_ptr: &Fn(Ty<'tcx>) -> Ty<'tcx>| {
@@ -510,7 +510,7 @@ fn enforce_trait_manually_implementable(tcx: &ty::ctxt, sp: Span, trait_def_id:
510510
pub fn check_coherence(crate_context: &CrateCtxt) {
511511
CoherenceChecker {
512512
crate_context: crate_context,
513-
inference_context: new_infer_ctxt(crate_context.tcx, &crate_context.tcx.tables, None, true),
513+
inference_context: new_infer_ctxt(crate_context.tcx, &crate_context.tcx.tables, None),
514514
inherent_impls: RefCell::new(FnvHashMap()),
515515
}.check(crate_context.tcx.map.krate());
516516
unsafety::check(crate_context.tcx);

src/librustc_typeck/coherence/overlap.rs

+1-1
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/collect.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2330,7 +2330,7 @@ fn check_method_self_type<'a, 'tcx, RS:RegionScope>(
23302330
base_type,
23312331
base_type_free);
23322332

2333-
let infcx = infer::new_infer_ctxt(tcx, &tcx.tables, None, false);
2333+
let infcx = infer::new_infer_ctxt(tcx, &tcx.tables, None);
23342334
drop(::require_same_types(tcx,
23352335
Some(&infcx),
23362336
false,

src/librustc_typeck/lib.rs

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

0 commit comments

Comments
 (0)