Auto merge of #123631 - oli-obk:fail_slow, r=jieyouxu
Ensure we do not accidentally insert new early aborts in the analysis passes pulling the infallible part out into a separate function makes sure that someone needs to change the signature in order to regress this. We only want to stop compilation in the presence of errors after all analyses are done, but before we start running lints. per-item we can still stop doing work if previous queries returned errors, but that's a separate story.
This commit is contained in:
commit
2805aedf9f
3 changed files with 20 additions and 22 deletions
|
@ -336,7 +336,8 @@ pub fn print<'tcx>(sess: &Session, ppm: PpMode, ex: PrintExtra<'tcx>) {
|
||||||
ThirTree => {
|
ThirTree => {
|
||||||
let tcx = ex.tcx();
|
let tcx = ex.tcx();
|
||||||
let mut out = String::new();
|
let mut out = String::new();
|
||||||
if rustc_hir_analysis::check_crate(tcx).is_err() {
|
rustc_hir_analysis::check_crate(tcx);
|
||||||
|
if tcx.dcx().has_errors().is_some() {
|
||||||
FatalError.raise();
|
FatalError.raise();
|
||||||
}
|
}
|
||||||
debug!("pretty printing THIR tree");
|
debug!("pretty printing THIR tree");
|
||||||
|
@ -348,7 +349,8 @@ pub fn print<'tcx>(sess: &Session, ppm: PpMode, ex: PrintExtra<'tcx>) {
|
||||||
ThirFlat => {
|
ThirFlat => {
|
||||||
let tcx = ex.tcx();
|
let tcx = ex.tcx();
|
||||||
let mut out = String::new();
|
let mut out = String::new();
|
||||||
if rustc_hir_analysis::check_crate(tcx).is_err() {
|
rustc_hir_analysis::check_crate(tcx);
|
||||||
|
if tcx.dcx().has_errors().is_some() {
|
||||||
FatalError.raise();
|
FatalError.raise();
|
||||||
}
|
}
|
||||||
debug!("pretty printing THIR flat");
|
debug!("pretty printing THIR flat");
|
||||||
|
|
|
@ -97,7 +97,6 @@ mod outlives;
|
||||||
pub mod structured_errors;
|
pub mod structured_errors;
|
||||||
mod variance;
|
mod variance;
|
||||||
|
|
||||||
use rustc_errors::ErrorGuaranteed;
|
|
||||||
use rustc_hir as hir;
|
use rustc_hir as hir;
|
||||||
use rustc_hir::def::DefKind;
|
use rustc_hir::def::DefKind;
|
||||||
use rustc_middle::middle;
|
use rustc_middle::middle;
|
||||||
|
@ -153,11 +152,11 @@ pub fn provide(providers: &mut Providers) {
|
||||||
hir_wf_check::provide(providers);
|
hir_wf_check::provide(providers);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn check_crate(tcx: TyCtxt<'_>) -> Result<(), ErrorGuaranteed> {
|
pub fn check_crate(tcx: TyCtxt<'_>) {
|
||||||
let _prof_timer = tcx.sess.timer("type_check_crate");
|
let _prof_timer = tcx.sess.timer("type_check_crate");
|
||||||
|
|
||||||
if tcx.features().rustc_attrs {
|
if tcx.features().rustc_attrs {
|
||||||
tcx.sess.time("outlives_testing", || outlives::test::test_inferred_outlives(tcx))?;
|
let _ = tcx.sess.time("outlives_testing", || outlives::test::test_inferred_outlives(tcx));
|
||||||
}
|
}
|
||||||
|
|
||||||
tcx.sess.time("coherence_checking", || {
|
tcx.sess.time("coherence_checking", || {
|
||||||
|
@ -174,11 +173,11 @@ pub fn check_crate(tcx: TyCtxt<'_>) -> Result<(), ErrorGuaranteed> {
|
||||||
});
|
});
|
||||||
|
|
||||||
if tcx.features().rustc_attrs {
|
if tcx.features().rustc_attrs {
|
||||||
tcx.sess.time("variance_testing", || variance::test::test_variance(tcx))?;
|
let _ = tcx.sess.time("variance_testing", || variance::test::test_variance(tcx));
|
||||||
}
|
}
|
||||||
|
|
||||||
if tcx.features().rustc_attrs {
|
if tcx.features().rustc_attrs {
|
||||||
collect::test_opaque_hidden_types(tcx)?;
|
let _ = collect::test_opaque_hidden_types(tcx);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Make sure we evaluate all static and (non-associated) const items, even if unused.
|
// Make sure we evaluate all static and (non-associated) const items, even if unused.
|
||||||
|
@ -213,8 +212,6 @@ pub fn check_crate(tcx: TyCtxt<'_>) -> Result<(), ErrorGuaranteed> {
|
||||||
});
|
});
|
||||||
|
|
||||||
tcx.ensure().check_unused_traits(());
|
tcx.ensure().check_unused_traits(());
|
||||||
|
|
||||||
Ok(())
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Lower a [`hir::Ty`] to a [`Ty`].
|
/// Lower a [`hir::Ty`] to a [`Ty`].
|
||||||
|
|
|
@ -686,18 +686,15 @@ pub fn create_global_ctxt<'tcx>(
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Runs the type-checking, region checking and other miscellaneous analysis
|
/// Runs all analyses that we guarantee to run, even if errors were reported in earlier analyses.
|
||||||
/// passes on the crate.
|
/// This function never fails.
|
||||||
fn analysis(tcx: TyCtxt<'_>, (): ()) -> Result<()> {
|
fn run_required_analyses(tcx: TyCtxt<'_>) {
|
||||||
if tcx.sess.opts.unstable_opts.hir_stats {
|
if tcx.sess.opts.unstable_opts.hir_stats {
|
||||||
rustc_passes::hir_stats::print_hir_stats(tcx);
|
rustc_passes::hir_stats::print_hir_stats(tcx);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(debug_assertions)]
|
#[cfg(debug_assertions)]
|
||||||
rustc_passes::hir_id_validator::check_crate(tcx);
|
rustc_passes::hir_id_validator::check_crate(tcx);
|
||||||
|
|
||||||
let sess = tcx.sess;
|
let sess = tcx.sess;
|
||||||
|
|
||||||
sess.time("misc_checking_1", || {
|
sess.time("misc_checking_1", || {
|
||||||
parallel!(
|
parallel!(
|
||||||
{
|
{
|
||||||
|
@ -733,10 +730,7 @@ fn analysis(tcx: TyCtxt<'_>, (): ()) -> Result<()> {
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
rustc_hir_analysis::check_crate(tcx);
|
||||||
// passes are timed inside typeck
|
|
||||||
rustc_hir_analysis::check_crate(tcx)?;
|
|
||||||
|
|
||||||
sess.time("MIR_borrow_checking", || {
|
sess.time("MIR_borrow_checking", || {
|
||||||
tcx.hir().par_body_owners(|def_id| {
|
tcx.hir().par_body_owners(|def_id| {
|
||||||
// Run unsafety check because it's responsible for stealing and
|
// Run unsafety check because it's responsible for stealing and
|
||||||
|
@ -745,7 +739,6 @@ fn analysis(tcx: TyCtxt<'_>, (): ()) -> Result<()> {
|
||||||
tcx.ensure().mir_borrowck(def_id)
|
tcx.ensure().mir_borrowck(def_id)
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
sess.time("MIR_effect_checking", || {
|
sess.time("MIR_effect_checking", || {
|
||||||
for def_id in tcx.hir().body_owners() {
|
for def_id in tcx.hir().body_owners() {
|
||||||
tcx.ensure().has_ffi_unwind_calls(def_id);
|
tcx.ensure().has_ffi_unwind_calls(def_id);
|
||||||
|
@ -761,16 +754,22 @@ fn analysis(tcx: TyCtxt<'_>, (): ()) -> Result<()> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
tcx.hir().par_body_owners(|def_id| {
|
tcx.hir().par_body_owners(|def_id| {
|
||||||
if tcx.is_coroutine(def_id.to_def_id()) {
|
if tcx.is_coroutine(def_id.to_def_id()) {
|
||||||
tcx.ensure().mir_coroutine_witnesses(def_id);
|
tcx.ensure().mir_coroutine_witnesses(def_id);
|
||||||
tcx.ensure().check_coroutine_obligations(def_id);
|
tcx.ensure().check_coroutine_obligations(def_id);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
sess.time("layout_testing", || layout_test::test_layout(tcx));
|
sess.time("layout_testing", || layout_test::test_layout(tcx));
|
||||||
sess.time("abi_testing", || abi_test::test_abi(tcx));
|
sess.time("abi_testing", || abi_test::test_abi(tcx));
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Runs the type-checking, region checking and other miscellaneous analysis
|
||||||
|
/// passes on the crate.
|
||||||
|
fn analysis(tcx: TyCtxt<'_>, (): ()) -> Result<()> {
|
||||||
|
run_required_analyses(tcx);
|
||||||
|
|
||||||
|
let sess = tcx.sess;
|
||||||
|
|
||||||
// Avoid overwhelming user with errors if borrow checking failed.
|
// Avoid overwhelming user with errors if borrow checking failed.
|
||||||
// I'm not sure how helpful this is, to be honest, but it avoids a
|
// I'm not sure how helpful this is, to be honest, but it avoids a
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue