Auto merge of #139018 - oli-obk:incremental-trait-impls, r=compiler-errors

Various local trait item iteration cleanups

Adding a trait impl for `Foo` unconditionally affected all queries that are interested in a completely independent trait `Bar`. Perf has no effect on this. We probably don't have a good perf test for this tho.

r? `@compiler-errors`

I am unsure about 9d05efb66f as it doesn't improve anything wrt incremental, because we still do all the checks for valid `Drop` impls, which subsequently will still invoke many queries and basically keep the depgraph the same.

I want to do

9549077a47/compiler/rustc_middle/src/ty/trait_def.rs (L141)

but would leave that to a follow-up PR, this one changes enough things as it is
This commit is contained in:
bors 2025-04-02 10:10:50 +00:00
commit ae9173d7dd
26 changed files with 96 additions and 93 deletions

View file

@ -330,14 +330,8 @@ provide! { tcx, def_id, other, cdata,
visibility => { cdata.get_visibility(def_id.index) }
adt_def => { cdata.get_adt_def(def_id.index, tcx) }
adt_destructor => {
let _ = cdata;
tcx.calculate_dtor(def_id, |_,_| Ok(()))
}
adt_async_destructor => {
let _ = cdata;
tcx.calculate_async_dtor(def_id, |_,_| Ok(()))
}
adt_destructor => { table }
adt_async_destructor => { table }
associated_item_def_ids => {
tcx.arena.alloc_from_iter(cdata.get_associated_item_or_field_def_ids(def_id.index))
}

View file

@ -1634,6 +1634,14 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
record!(self.tables.fn_sig[variant.def_id] <- fn_sig);
}
}
if let Some(destructor) = tcx.adt_destructor(local_def_id) {
record!(self.tables.adt_destructor[def_id] <- destructor);
}
if let Some(destructor) = tcx.adt_async_destructor(local_def_id) {
record!(self.tables.adt_async_destructor[def_id] <- destructor);
}
}
#[instrument(level = "debug", skip(self))]

View file

@ -452,6 +452,8 @@ define_tables! {
fn_arg_names: Table<DefIndex, LazyArray<Option<Ident>>>,
coroutine_kind: Table<DefIndex, hir::CoroutineKind>,
coroutine_for_closure: Table<DefIndex, RawDefId>,
adt_destructor: Table<DefIndex, LazyValue<ty::Destructor>>,
adt_async_destructor: Table<DefIndex, LazyValue<ty::AsyncDestructor>>,
coroutine_by_move_body_def_id: Table<DefIndex, RawDefId>,
eval_static_initializer: Table<DefIndex, LazyValue<mir::interpret::ConstAllocation<'static>>>,
trait_def: Table<DefIndex, LazyValue<ty::TraitDef>>,