Skip to content

Commit 3462f79

Browse files
committed
Auto merge of rust-lang#108118 - oli-obk:lazy_typeck, r=cjgillot
Run various queries from other queries instead of explicitly in phases These are just legacy leftovers from when rustc didn't have a query system. While there are more cleanups of this sort that can be done here, I want to land them in smaller steps. This phased order of query invocations was already a lie, as any query that looks at types (e.g. the wf checks run before) can invoke e.g. const eval which invokes borrowck, which invokes typeck, ...
2 parents 9e540df + 3344232 commit 3462f79

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+400
-423
lines changed

Diff for: compiler/rustc_borrowck/src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ pub fn provide(providers: &mut Providers) {
124124

125125
fn mir_borrowck(tcx: TyCtxt<'_>, def: LocalDefId) -> &BorrowCheckResult<'_> {
126126
let (input_body, promoted) = tcx.mir_promoted(def);
127-
debug!("run query mir_borrowck: {}", tcx.def_path_str(def.to_def_id()));
127+
debug!("run query mir_borrowck: {}", tcx.def_path_str(def));
128128

129129
if input_body.borrow().should_skip() {
130130
debug!("Skipping borrowck because of injected body");

Diff for: compiler/rustc_hir_analysis/src/check/check.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -494,7 +494,7 @@ fn check_item_type(tcx: TyCtxt<'_>, id: hir::ItemId) {
494494
debug!(
495495
"check_item_type(it.def_id={:?}, it.name={})",
496496
id.owner_id,
497-
tcx.def_path_str(id.owner_id.to_def_id())
497+
tcx.def_path_str(id.owner_id)
498498
);
499499
let _indenter = indenter();
500500
match tcx.def_kind(id.owner_id) {

Diff for: compiler/rustc_hir_analysis/src/check/wfcheck.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ fn check_item<'tcx>(tcx: TyCtxt<'tcx>, item: &'tcx hir::Item<'tcx>) {
155155

156156
debug!(
157157
?item.owner_id,
158-
item.name = ? tcx.def_path_str(def_id.to_def_id())
158+
item.name = ? tcx.def_path_str(def_id)
159159
);
160160

161161
match item.kind {
@@ -251,7 +251,7 @@ fn check_foreign_item(tcx: TyCtxt<'_>, item: &hir::ForeignItem<'_>) {
251251

252252
debug!(
253253
?item.owner_id,
254-
item.name = ? tcx.def_path_str(def_id.to_def_id())
254+
item.name = ? tcx.def_path_str(def_id)
255255
);
256256

257257
match item.kind {

Diff for: compiler/rustc_hir_analysis/src/coherence/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ fn check_impl(tcx: TyCtxt<'_>, impl_def_id: LocalDefId, trait_ref: ty::TraitRef<
2222
debug!(
2323
"(checking implementation) adding impl for trait '{:?}', item '{}'",
2424
trait_ref,
25-
tcx.def_path_str(impl_def_id.to_def_id())
25+
tcx.def_path_str(impl_def_id)
2626
);
2727

2828
// Skip impls where one of the self type is an error type.

Diff for: compiler/rustc_hir_analysis/src/lib.rs

-2
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

Diff for: compiler/rustc_hir_analysis/src/variance/constraints.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ impl<'a, 'tcx> ConstraintContext<'a, 'tcx> {
9292

9393
fn build_constraints_for_item(&mut self, def_id: LocalDefId) {
9494
let tcx = self.tcx();
95-
debug!("build_constraints_for_item({})", tcx.def_path_str(def_id.to_def_id()));
95+
debug!("build_constraints_for_item({})", tcx.def_path_str(def_id));
9696

9797
// Skip items with no generics - there's nothing to infer in them.
9898
if tcx.generics_of(def_id).count() == 0 {

Diff for: compiler/rustc_hir_typeck/src/lib.rs

-5
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,

Diff for: compiler/rustc_interface/src/passes.rs

-21
Original file line numberDiff line numberDiff line change
@@ -761,27 +761,6 @@ fn analysis(tcx: TyCtxt<'_>, (): ()) -> Result<()> {
761761
// passes are timed inside typeck
762762
rustc_hir_analysis::check_crate(tcx)?;
763763

764-
sess.time("misc_checking_2", || {
765-
parallel!(
766-
{
767-
sess.time("match_checking", || {
768-
tcx.hir().par_body_owners(|def_id| tcx.ensure().check_match(def_id))
769-
});
770-
},
771-
{
772-
sess.time("liveness_checking", || {
773-
tcx.hir().par_body_owners(|def_id| {
774-
// this must run before MIR dump, because
775-
// "not all control paths return a value" is reported here.
776-
//
777-
// maybe move the check to a MIR pass?
778-
tcx.ensure().check_liveness(def_id.to_def_id());
779-
});
780-
});
781-
}
782-
);
783-
});
784-
785764
sess.time("MIR_borrow_checking", || {
786765
tcx.hir().par_body_owners(|def_id| tcx.ensure().mir_borrowck(def_id));
787766
});

Diff for: compiler/rustc_middle/src/dep_graph/dep_node.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -364,7 +364,7 @@ impl<'tcx> DepNodeParams<TyCtxt<'tcx>> for HirId {
364364
#[inline(always)]
365365
fn to_debug_str(&self, tcx: TyCtxt<'tcx>) -> String {
366366
let HirId { owner, local_id } = *self;
367-
format!("{}.{}", tcx.def_path_str(owner.to_def_id()), local_id.as_u32())
367+
format!("{}.{}", tcx.def_path_str(owner), local_id.as_u32())
368368
}
369369

370370
#[inline(always)]

Diff for: compiler/rustc_middle/src/hir/map/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1217,7 +1217,7 @@ fn upstream_crates(tcx: TyCtxt<'_>) -> Vec<(StableCrateId, Svh)> {
12171217
}
12181218

12191219
fn hir_id_to_string(map: Map<'_>, id: HirId) -> String {
1220-
let path_str = |def_id: LocalDefId| map.tcx.def_path_str(def_id.to_def_id());
1220+
let path_str = |def_id: LocalDefId| map.tcx.def_path_str(def_id);
12211221

12221222
let span_str = || map.tcx.sess.source_map().span_to_snippet(map.span(id)).unwrap_or_default();
12231223
let node_str = |prefix| format!("{id} ({prefix} `{}`)", span_str());

0 commit comments

Comments
 (0)