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

Lines changed: 2 additions & 2 deletions
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

Lines changed: 2 additions & 4 deletions
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

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
@@ -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

Lines changed: 23 additions & 8 deletions
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

Lines changed: 2 additions & 2 deletions
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

Lines changed: 1 addition & 1 deletion
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

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
@@ -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) => {

0 commit comments

Comments
 (0)