Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions compiler/rustc_middle/src/ty/context/impl_interner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -430,6 +430,10 @@ impl<'tcx> Interner for TyCtxt<'tcx> {
self.impl_super_outlives(impl_def_id)
}

fn supertrait_def_ids(self, trait_def_id: DefId) -> impl Iterator<Item = DefId> {
rustc_type_ir::elaborate::supertrait_def_ids(self, trait_def_id)
}

fn impl_is_const(self, def_id: DefId) -> bool {
debug_assert_matches!(self.def_kind(def_id), DefKind::Impl { of_trait: true });
self.is_conditionally_const(def_id)
Expand Down
3 changes: 2 additions & 1 deletion compiler/rustc_next_trait_solver/src/solve/trait_goals.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1109,7 +1109,8 @@ where
.auto_traits()
.into_iter()
.chain(a_data.principal_def_id().into_iter().flat_map(|principal_def_id| {
elaborate::supertrait_def_ids(self.cx(), principal_def_id)
self.cx()
.supertrait_def_ids(principal_def_id)
.filter(|def_id| self.cx().trait_is_auto(*def_id))
}))
.collect();
Expand Down
3 changes: 3 additions & 0 deletions compiler/rustc_type_ir/src/elaborate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,9 @@ impl<I: Interner, O: Elaboratable<I>> Iterator for Elaborator<I, O> {
/// 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.
///
/// rust-analyzer has a query for this, so don't use this function there.
#[cfg(feature = "nightly")]
pub fn supertrait_def_ids<I: Interner>(
cx: I,
trait_def_id: I::TraitId,
Expand Down
3 changes: 3 additions & 0 deletions compiler/rustc_type_ir/src/interner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -359,6 +359,9 @@ pub trait Interner:
impl_def_id: Self::ImplId,
) -> ty::EarlyBinder<Self, impl IntoIterator<Item = Self::Clause>>;

fn supertrait_def_ids(self, trait_def_id: Self::TraitId)
-> impl Iterator<Item = Self::TraitId>;

fn impl_is_const(self, def_id: Self::ImplId) -> bool;
fn fn_is_const(self, def_id: Self::FunctionId) -> bool;
fn closure_is_const(self, def_id: Self::ClosureId) -> bool;
Expand Down
Loading