Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit e18d1f8

Browse files
committed
Leave it to the query system to invoke the typeck query instead of invoking it eagerly.
Later queries that are run on all body owners will invoke typeck as they need information from its result to perform their own logic
1 parent 4096619 commit e18d1f8

File tree

7 files changed

+3
-28
lines changed

7 files changed

+3
-28
lines changed

compiler/rustc_hir_analysis/src/lib.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -496,8 +496,6 @@ pub fn check_crate(tcx: TyCtxt<'_>) -> Result<(), ErrorGuaranteed> {
496496
tcx.hir().for_each_module(|module| tcx.ensure().check_mod_item_types(module))
497497
});
498498

499-
tcx.sess.time("item_bodies_checking", || tcx.typeck_item_bodies(()));
500-
501499
check_unused::check_crate(tcx);
502500
check_for_entry_fn(tcx);
503501

compiler/rustc_hir_typeck/src/lib.rs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -152,10 +152,6 @@ fn used_trait_imports(tcx: TyCtxt<'_>, def_id: LocalDefId) -> &UnordSet<LocalDef
152152
&*tcx.typeck(def_id).used_trait_imports
153153
}
154154

155-
fn typeck_item_bodies(tcx: TyCtxt<'_>, (): ()) {
156-
tcx.hir().par_body_owners(|body_owner_def_id| tcx.ensure().typeck(body_owner_def_id));
157-
}
158-
159155
fn typeck<'tcx>(tcx: TyCtxt<'tcx>, def_id: LocalDefId) -> &ty::TypeckResults<'tcx> {
160156
let fallback = move || tcx.type_of(def_id.to_def_id()).subst_identity();
161157
typeck_with_fallback(tcx, def_id, fallback)
@@ -479,7 +475,6 @@ fn has_expected_num_generic_args(
479475
pub fn provide(providers: &mut Providers) {
480476
method::provide(providers);
481477
*providers = Providers {
482-
typeck_item_bodies,
483478
typeck,
484479
diagnostic_only_typeck,
485480
has_typeck_results,

compiler/rustc_middle/src/query/mod.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -871,10 +871,6 @@ rustc_queries! {
871871
separate_provide_extern
872872
}
873873

874-
query typeck_item_bodies(_: ()) -> () {
875-
desc { "type-checking all item bodies" }
876-
}
877-
878874
query typeck(key: LocalDefId) -> &'tcx ty::TypeckResults<'tcx> {
879875
desc { |tcx| "type-checking `{}`", tcx.def_path_str(key.to_def_id()) }
880876
cache_on_disk_if { true }

src/librustdoc/core.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -258,8 +258,6 @@ pub(crate) fn create_config(
258258
override_queries: Some(|_sess, providers, _external_providers| {
259259
// Most lints will require typechecking, so just don't run them.
260260
providers.lint_mod = |_, _| {};
261-
// Prevent `rustc_hir_analysis::check_crate` from calling `typeck` on all bodies.
262-
providers.typeck_item_bodies = |_, _| {};
263261
// hack so that `used_trait_imports` won't try to call typeck
264262
providers.used_trait_imports = |_, _| {
265263
static EMPTY_SET: LazyLock<UnordSet<LocalDefId>> = LazyLock::new(UnordSet::default);

tests/ui/associated-inherent-types/bugs/ice-substitution.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@ error: the compiler unexpectedly panicked. this is a bug.
22

33
query stack during panic:
44
#0 [typeck] type-checking `weird`
5-
#1 [typeck_item_bodies] type-checking all item bodies
5+
#1 [used_trait_imports] finding used_trait_imports `weird`
66
end of query stack

tests/ui/privacy/privacy2.stderr

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,7 @@ LL | pub fn foo() {}
2323

2424
error: requires `sized` lang_item
2525

26-
error: requires `sized` lang_item
27-
28-
error: requires `sized` lang_item
29-
30-
error: requires `sized` lang_item
31-
32-
error: aborting due to 6 previous errors
26+
error: aborting due to 3 previous errors
3327

3428
Some errors have detailed explanations: E0432, E0603.
3529
For more information about an error, try `rustc --explain E0432`.

tests/ui/privacy/privacy3.stderr

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,6 @@ LL | use bar::gpriv;
66

77
error: requires `sized` lang_item
88

9-
error: requires `sized` lang_item
10-
11-
error: requires `sized` lang_item
12-
13-
error: requires `sized` lang_item
14-
15-
error: aborting due to 5 previous errors
9+
error: aborting due to 2 previous errors
1610

1711
For more information about this error, try `rustc --explain E0432`.

0 commit comments

Comments
 (0)