Skip to content

Commit 9e54713

Browse files
committed
Auto merge of #140856 - oli-obk:merge-queries2, r=nnethercote
Merge mir query analysis invocations r? `@ghost` same thing as #140854 just a different set of queries Doing this in general has some bad cache coherence issues because the query caches are laid out in Vec<QueryResult> lists per query where each index refers to a DefId in the same order as we're iterating. Iterating two or more lists at the same time does have cache issues, so I want to poke a bit at it to see if we can't merge just a few of them at a time.
2 parents 414482f + e011c43 commit 9e54713

File tree

5 files changed

+16
-24
lines changed

5 files changed

+16
-24
lines changed

compiler/rustc_hir_analysis/src/coherence/builtin.rs

+2-4
Original file line numberDiff line numberDiff line change
@@ -214,11 +214,9 @@ fn visit_implementation_of_dispatch_from_dyn(checker: &Checker<'_>) -> Result<()
214214
let span = tcx.def_span(impl_did);
215215
let trait_name = "DispatchFromDyn";
216216

217-
let dispatch_from_dyn_trait = tcx.require_lang_item(LangItem::DispatchFromDyn, Some(span));
218-
219217
let source = trait_ref.self_ty();
220218
let target = {
221-
assert_eq!(trait_ref.def_id, dispatch_from_dyn_trait);
219+
assert!(tcx.is_lang_item(trait_ref.def_id, LangItem::DispatchFromDyn));
222220

223221
trait_ref.args.type_at(1)
224222
};
@@ -339,7 +337,7 @@ fn visit_implementation_of_dispatch_from_dyn(checker: &Checker<'_>) -> Result<()
339337
tcx,
340338
cause.clone(),
341339
param_env,
342-
ty::TraitRef::new(tcx, dispatch_from_dyn_trait, [ty_a, ty_b]),
340+
ty::TraitRef::new(tcx, trait_ref.def_id, [ty_a, ty_b]),
343341
));
344342
let errors = ocx.select_all_or_error();
345343
if !errors.is_empty() {

compiler/rustc_hir_analysis/src/lib.rs

+11-11
Original file line numberDiff line numberDiff line change
@@ -194,17 +194,6 @@ pub fn check_crate(tcx: TyCtxt<'_>) {
194194
let _: R = tcx.ensure_ok().crate_inherent_impls_overlap_check(());
195195
});
196196

197-
if tcx.features().rustc_attrs() {
198-
tcx.sess.time("dumping_rustc_attr_data", || {
199-
outlives::dump::inferred_outlives(tcx);
200-
variance::dump::variances(tcx);
201-
collect::dump::opaque_hidden_types(tcx);
202-
collect::dump::predicates_and_item_bounds(tcx);
203-
collect::dump::def_parents(tcx);
204-
collect::dump::vtables(tcx);
205-
});
206-
}
207-
208197
// Make sure we evaluate all static and (non-associated) const items, even if unused.
209198
// If any of these fail to evaluate, we do not want this crate to pass compilation.
210199
tcx.par_hir_body_owners(|item_def_id| {
@@ -228,6 +217,17 @@ pub fn check_crate(tcx: TyCtxt<'_>) {
228217
}
229218
});
230219

220+
if tcx.features().rustc_attrs() {
221+
tcx.sess.time("dumping_rustc_attr_data", || {
222+
outlives::dump::inferred_outlives(tcx);
223+
variance::dump::variances(tcx);
224+
collect::dump::opaque_hidden_types(tcx);
225+
collect::dump::predicates_and_item_bounds(tcx);
226+
collect::dump::def_parents(tcx);
227+
collect::dump::vtables(tcx);
228+
});
229+
}
230+
231231
tcx.ensure_ok().check_unused_traits(());
232232
}
233233

compiler/rustc_hir_typeck/src/closure.rs

+2-3
Original file line numberDiff line numberDiff line change
@@ -1080,15 +1080,14 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
10801080

10811081
// Check that this is a projection from the `Future` trait.
10821082
let trait_def_id = predicate.projection_term.trait_def_id(self.tcx);
1083-
let future_trait = self.tcx.require_lang_item(LangItem::Future, Some(cause_span));
1084-
if trait_def_id != future_trait {
1083+
if !self.tcx.is_lang_item(trait_def_id, LangItem::Future) {
10851084
debug!("deduce_future_output_from_projection: not a future");
10861085
return None;
10871086
}
10881087

10891088
// The `Future` trait has only one associated item, `Output`,
10901089
// so check that this is what we see.
1091-
let output_assoc_item = self.tcx.associated_item_def_ids(future_trait)[0];
1090+
let output_assoc_item = self.tcx.associated_item_def_ids(trait_def_id)[0];
10921091
if output_assoc_item != predicate.projection_term.def_id {
10931092
span_bug!(
10941093
cause_span,

compiler/rustc_interface/src/passes.rs

-4
Original file line numberDiff line numberDiff line change
@@ -1002,10 +1002,6 @@ fn run_required_analyses(tcx: TyCtxt<'_>) {
10021002
if !tcx.is_typeck_child(def_id.to_def_id()) {
10031003
tcx.ensure_ok().mir_borrowck(def_id)
10041004
}
1005-
});
1006-
});
1007-
sess.time("MIR_effect_checking", || {
1008-
tcx.par_hir_body_owners(|def_id| {
10091005
tcx.ensure_ok().has_ffi_unwind_calls(def_id);
10101006

10111007
// If we need to codegen, ensure that we emit all errors from

compiler/rustc_middle/src/ty/sty.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -1260,8 +1260,7 @@ impl<'tcx> Ty<'tcx> {
12601260
return true;
12611261
};
12621262
alloc.expect_ty().ty_adt_def().is_some_and(|alloc_adt| {
1263-
let global_alloc = tcx.require_lang_item(LangItem::GlobalAlloc, None);
1264-
alloc_adt.did() == global_alloc
1263+
tcx.is_lang_item(alloc_adt.did(), LangItem::GlobalAlloc)
12651264
})
12661265
}
12671266
_ => false,

0 commit comments

Comments
 (0)