Make more new-trait-solver-things have specific ID type

This commit is contained in:
Chayim Refael Friedman 2025-10-15 16:12:41 +03:00
parent 5413f7d39c
commit 4efd70d5f0
8 changed files with 18 additions and 10 deletions

View file

@ -102,6 +102,7 @@ impl<'tcx> Interner for TyCtxt<'tcx> {
type CoroutineId = DefId;
type AdtId = DefId;
type ImplId = DefId;
type UnevaluatedConstId = DefId;
type Span = Span;
type GenericArgs = ty::GenericArgsRef<'tcx>;

View file

@ -870,7 +870,7 @@ where
// FIXME(associated_const_equality): Also add associated consts to
// the requirements here.
for associated_type_def_id in cx.associated_type_def_ids(trait_ref.def_id.into()) {
for associated_type_def_id in cx.associated_type_def_ids(trait_ref.def_id) {
// associated types that require `Self: Sized` do not show up in the built-in
// implementation of `Trait for dyn Trait`, and can be dropped here.
if cx.generics_require_sized_self(associated_type_def_id) {

View file

@ -218,7 +218,7 @@ where
return self.evaluate_added_goals_and_make_canonical_response(Certainty::Yes);
}
ty::ConstKind::Unevaluated(uv) => {
self.cx().type_of(uv.def).instantiate(self.cx(), uv.args)
self.cx().type_of(uv.def.into()).instantiate(self.cx(), uv.args)
}
ty::ConstKind::Expr(_) => unimplemented!(
"`feature(generic_const_exprs)` is not supported in the new trait solver"

View file

@ -16,7 +16,10 @@ where
) -> QueryResult<I> {
if let Some(normalized_const) = self.evaluate_const(
goal.param_env,
ty::UnevaluatedConst::new(goal.predicate.alias.def_id, goal.predicate.alias.args),
ty::UnevaluatedConst::new(
goal.predicate.alias.def_id.try_into().unwrap(),
goal.predicate.alias.args,
),
) {
self.instantiate_normalizes_to_term(goal, normalized_const.into());
self.evaluate_added_goals_and_make_canonical_response(Certainty::Yes)

View file

@ -72,7 +72,7 @@ impl<I: Interner> fmt::Debug for ConstKind<I> {
derive(Decodable_NoContext, Encodable_NoContext, HashStable_NoContext)
)]
pub struct UnevaluatedConst<I: Interner> {
pub def: I::DefId,
pub def: I::UnevaluatedConstId,
pub args: I::GenericArgs,
}
@ -80,7 +80,7 @@ impl<I: Interner> Eq for UnevaluatedConst<I> {}
impl<I: Interner> UnevaluatedConst<I> {
#[inline]
pub fn new(def: I::DefId, args: I::GenericArgs) -> UnevaluatedConst<I> {
pub fn new(def: I::UnevaluatedConstId, args: I::GenericArgs) -> UnevaluatedConst<I> {
UnevaluatedConst { def, args }
}
}

View file

@ -53,6 +53,7 @@ pub trait Interner:
type CoroutineId: SpecificDefId<Self>;
type AdtId: SpecificDefId<Self>;
type ImplId: SpecificDefId<Self>;
type UnevaluatedConstId: SpecificDefId<Self>;
type Span: Span<Self>;
type GenericArgs: GenericArgs<Self>;
@ -339,7 +340,10 @@ pub trait Interner:
fn as_adt_lang_item(self, def_id: Self::AdtId) -> Option<SolverAdtLangItem>;
fn associated_type_def_ids(self, def_id: Self::DefId) -> impl IntoIterator<Item = Self::DefId>;
fn associated_type_def_ids(
self,
def_id: Self::TraitId,
) -> impl IntoIterator<Item = Self::DefId>;
fn for_each_relevant_impl(
self,

View file

@ -655,7 +655,7 @@ impl<I: Interner> AliasTerm<I> {
| AliasTermKind::UnevaluatedConst
| AliasTermKind::ProjectionConst => I::Const::new_unevaluated(
interner,
ty::UnevaluatedConst::new(self.def_id, self.args),
ty::UnevaluatedConst::new(self.def_id.try_into().unwrap(), self.args),
)
.into(),
}
@ -747,7 +747,7 @@ impl<I: Interner> From<ty::AliasTy<I>> for AliasTerm<I> {
impl<I: Interner> From<ty::UnevaluatedConst<I>> for AliasTerm<I> {
fn from(ct: ty::UnevaluatedConst<I>) -> Self {
AliasTerm { args: ct.args, def_id: ct.def, _use_alias_term_new_instead: () }
AliasTerm { args: ct.args, def_id: ct.def.into(), _use_alias_term_new_instead: () }
}
}

View file

@ -608,8 +608,8 @@ pub fn structurally_relate_consts<I: Interner, R: TypeRelation<I>>(
// be stabilized.
(ty::ConstKind::Unevaluated(au), ty::ConstKind::Unevaluated(bu)) if au.def == bu.def => {
if cfg!(debug_assertions) {
let a_ty = cx.type_of(au.def).instantiate(cx, au.args);
let b_ty = cx.type_of(bu.def).instantiate(cx, bu.args);
let a_ty = cx.type_of(au.def.into()).instantiate(cx, au.args);
let b_ty = cx.type_of(bu.def.into()).instantiate(cx, bu.args);
assert_eq!(a_ty, b_ty);
}