summary refs log tree commit diff
path: root/compiler/rustc_hir_analysis/src/lib.rs
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2024-03-14 02:54:10 +0000
committerbors <bors@rust-lang.org>2024-03-14 02:54:10 +0000
commit5ac0b2d0219de2fd6fef86c69ef0cfa1e6c36f3b (patch)
tree093ee4994478e32a433204b49a338b5b289de445 /compiler/rustc_hir_analysis/src/lib.rs
parentc7fed9f85422696f67fcf76abc846827fd4dde72 (diff)
parent96d24f2dd13e8e9d0c6f9912781ffe1fc79864d3 (diff)
downloadrust-5ac0b2d0219de2fd6fef86c69ef0cfa1e6c36f3b.tar.gz
rust-5ac0b2d0219de2fd6fef86c69ef0cfa1e6c36f3b.zip
Auto merge of #122347 - oli-obk:track_errors13, r=compiler-errors
Revert "Auto merge of #122140 - oli-obk:track_errors13, r=davidtwco"

This reverts commit 65cd843ae06ad00123c131a431ed5304e4cd577a, reversing changes made to d255c6a57c393db6221b1ff700daea478436f1cd.

reverts https://github.com/rust-lang/rust/pull/122140

It was a large regression in wall time due to trashing CPU caches
Diffstat (limited to 'compiler/rustc_hir_analysis/src/lib.rs')
-rw-r--r--compiler/rustc_hir_analysis/src/lib.rs30
1 files changed, 26 insertions, 4 deletions
diff --git a/compiler/rustc_hir_analysis/src/lib.rs b/compiler/rustc_hir_analysis/src/lib.rs
index b1b36ade508..8cf70fe46aa 100644
--- a/compiler/rustc_hir_analysis/src/lib.rs
+++ b/compiler/rustc_hir_analysis/src/lib.rs
@@ -98,6 +98,7 @@ mod outlives;
 pub mod structured_errors;
 mod variance;
 
+use rustc_errors::ErrorGuaranteed;
 use rustc_hir as hir;
 use rustc_middle::middle;
 use rustc_middle::query::Providers;
@@ -155,13 +156,11 @@ pub fn provide(providers: &mut Providers) {
     hir_wf_check::provide(providers);
 }
 
-pub fn check_crate(tcx: TyCtxt<'_>) {
+pub fn check_crate(tcx: TyCtxt<'_>) -> Result<(), ErrorGuaranteed> {
     let _prof_timer = tcx.sess.timer("type_check_crate");
 
     if tcx.features().rustc_attrs {
-        tcx.sess.time("outlives_testing", || outlives::test::test_inferred_outlives(tcx));
-        tcx.sess.time("variance_testing", || variance::test::test_variance(tcx));
-        collect::test_opaque_hidden_types(tcx);
+        tcx.sess.time("outlives_testing", || outlives::test::test_inferred_outlives(tcx))?;
     }
 
     tcx.sess.time("coherence_checking", || {
@@ -177,6 +176,14 @@ pub fn check_crate(tcx: TyCtxt<'_>) {
         let _ = tcx.ensure().crate_inherent_impls_overlap_check(());
     });
 
+    if tcx.features().rustc_attrs {
+        tcx.sess.time("variance_testing", || variance::test::test_variance(tcx))?;
+    }
+
+    if tcx.features().rustc_attrs {
+        collect::test_opaque_hidden_types(tcx)?;
+    }
+
     // Make sure we evaluate all static and (non-associated) const items, even if unused.
     // If any of these fail to evaluate, we do not want this crate to pass compilation.
     tcx.hir().par_body_owners(|item_def_id| {
@@ -191,6 +198,21 @@ pub fn check_crate(tcx: TyCtxt<'_>) {
     // Freeze definitions as we don't add new ones at this point. This improves performance by
     // allowing lock-free access to them.
     tcx.untracked().definitions.freeze();
+
+    // FIXME: Remove this when we implement creating `DefId`s
+    // for anon constants during their parents' typeck.
+    // Typeck all body owners in parallel will produce queries
+    // cycle errors because it may typeck on anon constants directly.
+    tcx.hir().par_body_owners(|item_def_id| {
+        let def_kind = tcx.def_kind(item_def_id);
+        if !matches!(def_kind, DefKind::AnonConst) {
+            tcx.ensure().typeck(item_def_id);
+        }
+    });
+
+    tcx.ensure().check_unused_traits(());
+
+    Ok(())
 }
 
 /// A quasi-deprecated helper used in rustdoc and clippy to get