1
Fork 0

Move supertrait_def_ids into the elaborate module like all other fns

This commit is contained in:
Michael Goulet 2025-01-18 22:02:10 +00:00
parent cd805f09ff
commit 45929a8f46
11 changed files with 27 additions and 26 deletions

View file

@ -52,7 +52,9 @@ use rustc_type_ir::TyKind::*;
use rustc_type_ir::fold::TypeFoldable;
use rustc_type_ir::lang_items::TraitSolverLangItem;
pub use rustc_type_ir::lift::Lift;
use rustc_type_ir::{CollectAndApply, Interner, TypeFlags, WithCachedTypeInfo, search_graph};
use rustc_type_ir::{
CollectAndApply, Interner, TypeFlags, WithCachedTypeInfo, elaborate, search_graph,
};
use tracing::{debug, instrument};
use crate::arena::Arena;
@ -2558,7 +2560,7 @@ impl<'tcx> TyCtxt<'tcx> {
/// Given the def_id of a Trait `trait_def_id` and the name of an associated item `assoc_name`
/// returns true if the `trait_def_id` defines an associated item of name `assoc_name`.
pub fn trait_may_define_assoc_item(self, trait_def_id: DefId, assoc_name: Ident) -> bool {
self.supertrait_def_ids(trait_def_id).any(|trait_did| {
elaborate::supertrait_def_ids(self, trait_def_id).any(|trait_did| {
self.associated_items(trait_did)
.filter_by_name_unhygienic(assoc_name.name)
.any(|item| self.hygienic_eq(assoc_name, item.ident(self), trait_did))
@ -2579,14 +2581,6 @@ impl<'tcx> TyCtxt<'tcx> {
})
}
/// Computes the def-ids of the transitive supertraits of `trait_def_id`. This (intentionally)
/// does not compute the full elaborated super-predicates but just the set of def-ids. It is used
/// to identify which traits may define a given associated type to help avoid cycle errors,
/// and to make size estimates for vtable layout computation.
pub fn supertrait_def_ids(self, trait_def_id: DefId) -> impl Iterator<Item = DefId> + 'tcx {
rustc_type_ir::elaborate::supertrait_def_ids(self, trait_def_id)
}
/// Given a closure signature, returns an equivalent fn signature. Detuples
/// and so forth -- so e.g., if we have a sig with `Fn<(u32, i32)>` then
/// you would get a `fn(u32, i32)`.

View file

@ -2,6 +2,7 @@ use std::fmt;
use rustc_ast::Mutability;
use rustc_macros::HashStable;
use rustc_type_ir::elaborate;
use crate::mir::interpret::{AllocId, Allocation, CTFE_ALLOC_SALT, Pointer, Scalar, alloc_range};
use crate::ty::{self, Instance, PolyTraitRef, Ty, TyCtxt};
@ -64,7 +65,7 @@ pub(crate) fn vtable_min_entries<'tcx>(
};
// This includes self in supertraits.
for def_id in tcx.supertrait_def_ids(trait_ref.def_id()) {
for def_id in elaborate::supertrait_def_ids(tcx, trait_ref.def_id()) {
count += tcx.own_existential_vtable_entries(def_id).len();
}