Skip to content

Commit e03588b

Browse files
committed
Remove track_errors from check_match
1 parent 7486b9c commit e03588b

File tree

2 files changed

+14
-10
lines changed

2 files changed

+14
-10
lines changed

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

0 commit comments

Comments
 (0)