Skip to content

Commit 68fcf88

Browse files
committed
Auto merge of #59199 - estebank:untrack-errors, r=<try>
Remove `track_errors` from `check_match`, `typeck_item_bodies` and `register_plugins` In the spirit of continuing through errors in type checking (#39275), remove `track_errors` from a couple of locations in the codebase.
2 parents bc44841 + eaa69d5 commit 68fcf88

File tree

5 files changed

+35
-30
lines changed

5 files changed

+35
-30
lines changed

src/librustc_interface/passes.rs

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -322,22 +322,20 @@ pub fn register_plugins<'a>(
322322
..
323323
} = registry;
324324

325-
sess.track_errors(|| {
326-
let mut ls = sess.lint_store.borrow_mut();
327-
for pass in early_lint_passes {
328-
ls.register_early_pass(Some(sess), true, false, pass);
329-
}
330-
for pass in late_lint_passes {
331-
ls.register_late_pass(Some(sess), true, pass);
332-
}
325+
let mut ls = sess.lint_store.borrow_mut();
326+
for pass in early_lint_passes {
327+
ls.register_early_pass(Some(sess), true, false, pass);
328+
}
329+
for pass in late_lint_passes {
330+
ls.register_late_pass(Some(sess), true, pass);
331+
}
333332

334-
for (name, (to, deprecated_name)) in lint_groups {
335-
ls.register_group(Some(sess), true, name, deprecated_name, to);
336-
}
333+
for (name, (to, deprecated_name)) in lint_groups {
334+
ls.register_group(Some(sess), true, name, deprecated_name, to);
335+
}
337336

338-
*sess.plugin_llvm_passes.borrow_mut() = llvm_passes;
339-
*sess.plugin_attributes.borrow_mut() = attributes.clone();
340-
})?;
337+
*sess.plugin_llvm_passes.borrow_mut() = llvm_passes;
338+
*sess.plugin_attributes.borrow_mut() = attributes.clone();
341339

342340
Ok((krate, PluginInfo {
343341
syntax_exts,

src/librustc_mir/build/matches/mod.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -438,7 +438,12 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> {
438438
// always convert all match-pairs into bindings.
439439
self.simplify_candidate(&mut candidate);
440440

441-
if !candidate.match_pairs.is_empty() {
441+
if !candidate.match_pairs.is_empty() && self.hir.tcx().sess.err_count() == 0 {
442+
// Only abort compilation if no other errors have been emitted. This used to be a hard
443+
// error that wouldn't be reached because `hair::pattern::check_match::check_match`
444+
// wouldn't have let the compiler continue. In our tests this is only ever hit by
445+
// `ui/consts/const-match-check.rs` with `--cfg eval1`, and that file already generates
446+
// a different error before hand.
442447
span_bug!(
443448
candidate.match_pairs[0].pattern.span,
444449
"match pairs {:?} remaining after simplifying \

src/librustc_mir/hair/pattern/check_match.rs

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -37,15 +37,14 @@ pub(crate) fn check_match<'a, 'tcx>(
3737
return Ok(());
3838
};
3939

40-
tcx.sess.track_errors(|| {
41-
MatchVisitor {
42-
tcx,
43-
tables: tcx.body_tables(body_id),
44-
region_scope_tree: &tcx.region_scope_tree(def_id),
45-
param_env: tcx.param_env(def_id),
46-
identity_substs: InternalSubsts::identity_for_item(tcx, def_id),
47-
}.visit_body(tcx.hir().body(body_id));
48-
})
40+
MatchVisitor {
41+
tcx,
42+
tables: tcx.body_tables(body_id),
43+
region_scope_tree: &tcx.region_scope_tree(def_id),
44+
param_env: tcx.param_env(def_id),
45+
identity_substs: InternalSubsts::identity_for_item(tcx, def_id),
46+
}.visit_body(tcx.hir().body(body_id));
47+
Ok(())
4948
}
5049

5150
fn create_e0004<'a>(sess: &'a Session, sp: Span, error_message: String) -> DiagnosticBuilder<'a> {

src/librustc_typeck/check/mod.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -706,11 +706,10 @@ fn typeck_item_bodies<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, crate_num: CrateNum
706706
-> Result<(), ErrorReported>
707707
{
708708
debug_assert!(crate_num == LOCAL_CRATE);
709-
Ok(tcx.sess.track_errors(|| {
710-
tcx.par_body_owners(|body_owner_def_id| {
711-
tcx.ensure().typeck_tables_of(body_owner_def_id);
712-
});
713-
})?)
709+
tcx.par_body_owners(|body_owner_def_id| {
710+
tcx.ensure().typeck_tables_of(body_owner_def_id);
711+
});
712+
Ok(())
714713
}
715714

716715
fn check_item_well_formed<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId) {

src/test/ui/issues/issue-26217.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
fn foo<T>() where for<'a> T: 'a {}
22

3-
fn main<'a>() {
3+
fn bar<'a>() {
44
foo::<&'a i32>();
55
//~^ ERROR the type `&'a i32` does not fulfill the required lifetime
66
}
7+
8+
fn main() {
9+
bar();
10+
}

0 commit comments

Comments
 (0)