Skip to content

Commit fb5ed48

Browse files
committed
Auto merge of #59199 - estebank:untrack-errors, r=eddyb
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 93f5ba0 + 5723632 commit fb5ed48

File tree

8 files changed

+45
-50
lines changed

8 files changed

+45
-50
lines changed

src/librustc/ty/query/mod.rs

+2-3
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,7 @@ rustc_query_append! { [define_queries!][ <'tcx>
272272

273273
TypeChecking {
274274
[] fn typeck_item_bodies:
275-
typeck_item_bodies_dep_node(CrateNum) -> Result<(), ErrorReported>,
275+
typeck_item_bodies_dep_node(CrateNum) -> (),
276276

277277
[] fn typeck_tables_of: TypeckTables(DefId) -> &'tcx ty::TypeckTables<'tcx>,
278278
},
@@ -325,8 +325,7 @@ rustc_query_append! { [define_queries!][ <'tcx>
325325
},
326326

327327
TypeChecking {
328-
[] fn check_match: CheckMatch(DefId)
329-
-> Result<(), ErrorReported>,
328+
[] fn check_match: CheckMatch(DefId) -> (),
330329

331330
/// Performs part of the privacy check and computes "access levels".
332331
[] fn privacy_access_levels: PrivacyAccessLevels(CrateNum) -> Lrc<AccessLevels>,

src/librustc_interface/passes.rs

+12-14
Original file line numberDiff line numberDiff line change
@@ -323,22 +323,20 @@ pub fn register_plugins<'a>(
323323
..
324324
} = registry;
325325

326-
sess.track_errors(|| {
327-
let mut ls = sess.lint_store.borrow_mut();
328-
for pass in early_lint_passes {
329-
ls.register_early_pass(Some(sess), true, false, pass);
330-
}
331-
for pass in late_lint_passes {
332-
ls.register_late_pass(Some(sess), true, pass);
333-
}
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+
}
334333

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

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

343341
Ok((krate, PluginInfo {
344342
syntax_exts,

src/librustc_mir/build/matches/mod.rs

+10-4
Original file line numberDiff line numberDiff line change
@@ -439,11 +439,17 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> {
439439
self.simplify_candidate(&mut candidate);
440440

441441
if !candidate.match_pairs.is_empty() {
442-
span_bug!(
442+
// ICE if no other errors have been emitted. This used to be a hard error that wouldn't
443+
// be reached because `hair::pattern::check_match::check_match` wouldn't have let the
444+
// 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.
447+
self.hir.tcx().sess.delay_span_bug(
443448
candidate.match_pairs[0].pattern.span,
444-
"match pairs {:?} remaining after simplifying \
445-
irrefutable pattern",
446-
candidate.match_pairs
449+
&format!(
450+
"match pairs {:?} remaining after simplifying irrefutable pattern",
451+
candidate.match_pairs,
452+
),
447453
);
448454
}
449455

src/librustc_mir/const_eval.rs

+2-4
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ use rustc::ty::layout::{self, LayoutOf, VariantIdx};
1515
use rustc::ty::subst::Subst;
1616
use rustc::traits::Reveal;
1717
use rustc_data_structures::fx::FxHashMap;
18-
use rustc::util::common::ErrorReported;
1918

2019
use syntax::ast::Mutability;
2120
use syntax::source_map::{Span, DUMMY_SP};
@@ -619,9 +618,8 @@ pub fn const_eval_raw_provider<'a, 'tcx>(
619618
let tables = tcx.typeck_tables_of(def_id);
620619

621620
// Do match-check before building MIR
622-
if let Err(ErrorReported) = tcx.check_match(def_id) {
623-
return Err(ErrorHandled::Reported)
624-
}
621+
// FIXME(#59378) check_match may have errored but we're not checking for that anymore
622+
tcx.check_match(def_id);
625623

626624
if let hir::BodyOwnerKind::Const = tcx.hir().body_owner_kind_by_hir_id(id) {
627625
tcx.mir_const_qualif(def_id);

src/librustc_mir/hair/pattern/check_match.rs

+9-15
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ use rustc::ty::{self, Ty, TyCtxt, TyKind};
1414
use rustc::ty::subst::{InternalSubsts, SubstsRef};
1515
use rustc::lint;
1616
use rustc_errors::{Applicability, DiagnosticBuilder};
17-
use rustc::util::common::ErrorReported;
1817

1918
use rustc::hir::def::*;
2019
use rustc::hir::def_id::DefId;
@@ -27,25 +26,20 @@ use std::slice;
2726
use syntax::ptr::P;
2827
use syntax_pos::{Span, DUMMY_SP, MultiSpan};
2928

30-
pub(crate) fn check_match<'a, 'tcx>(
31-
tcx: TyCtxt<'a, 'tcx, 'tcx>,
32-
def_id: DefId,
33-
) -> Result<(), ErrorReported> {
29+
pub(crate) fn check_match<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId) {
3430
let body_id = if let Some(id) = tcx.hir().as_local_hir_id(def_id) {
3531
tcx.hir().body_owned_by(id)
3632
} else {
37-
return Ok(());
33+
return;
3834
};
3935

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-
})
36+
MatchVisitor {
37+
tcx,
38+
tables: tcx.body_tables(body_id),
39+
region_scope_tree: &tcx.region_scope_tree(def_id),
40+
param_env: tcx.param_env(def_id),
41+
identity_substs: InternalSubsts::identity_for_item(tcx, def_id),
42+
}.visit_body(tcx.hir().body(body_id));
4943
}
5044

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

src/librustc_typeck/check/mod.rs

+4-8
Original file line numberDiff line numberDiff line change
@@ -702,15 +702,11 @@ fn check_mod_item_types<'tcx>(tcx: TyCtxt<'_, 'tcx, 'tcx>, module_def_id: DefId)
702702
tcx.hir().visit_item_likes_in_module(module_def_id, &mut CheckItemTypesVisitor { tcx });
703703
}
704704

705-
fn typeck_item_bodies<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, crate_num: CrateNum)
706-
-> Result<(), ErrorReported>
707-
{
705+
fn typeck_item_bodies<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, crate_num: CrateNum) {
708706
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-
})?)
707+
tcx.par_body_owners(|body_owner_def_id| {
708+
tcx.ensure().typeck_tables_of(body_owner_def_id);
709+
});
714710
}
715711

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

src/librustc_typeck/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -363,7 +363,7 @@ pub fn check_crate<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>)
363363
})
364364
})?;
365365

366-
time(tcx.sess, "item-bodies checking", || tcx.typeck_item_bodies(LOCAL_CRATE))?;
366+
time(tcx.sess, "item-bodies checking", || tcx.typeck_item_bodies(LOCAL_CRATE));
367367

368368
check_unused::check_crate(tcx);
369369
check_for_entry_fn(tcx);

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

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