Remove track_errors from check_match

This commit is contained in:
Esteban Küber 2019-03-14 19:16:31 -07:00
parent 9f91bee03f
commit d1808aa509
2 changed files with 14 additions and 10 deletions

View file

@ -438,7 +438,12 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> {
// always convert all match-pairs into bindings.
self.simplify_candidate(&mut candidate);
if !candidate.match_pairs.is_empty() {
if !candidate.match_pairs.is_empty() && self.hir.tcx().sess.err_count() == 0 {
// Only abort compilation if no other errors have been emitted. This used to be a hard
// error that wouldn't be reached because `hair::pattern::check_match::check_match`
// wouldn't have let the compiler continue. In our tests this is only ever hit by
// `ui/consts/const-match-check.rs` with `--cfg eval1`, and that file already generates
// a different error before hand.
span_bug!(
candidate.match_pairs[0].pattern.span,
"match pairs {:?} remaining after simplifying \

View file

@ -37,15 +37,14 @@ pub(crate) fn check_match<'a, 'tcx>(
return Ok(());
};
tcx.sess.track_errors(|| {
MatchVisitor {
tcx,
tables: tcx.body_tables(body_id),
region_scope_tree: &tcx.region_scope_tree(def_id),
param_env: tcx.param_env(def_id),
identity_substs: InternalSubsts::identity_for_item(tcx, def_id),
}.visit_body(tcx.hir().body(body_id));
})
MatchVisitor {
tcx,
tables: tcx.body_tables(body_id),
region_scope_tree: &tcx.region_scope_tree(def_id),
param_env: tcx.param_env(def_id),
identity_substs: InternalSubsts::identity_for_item(tcx, def_id),
}.visit_body(tcx.hir().body(body_id));
Ok(())
}
fn create_e0004<'a>(sess: &'a Session, sp: Span, error_message: String) -> DiagnosticBuilder<'a> {