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
1 change: 1 addition & 0 deletions compiler/rustc_middle/src/ty/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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>;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_next_trait_solver/src/solve/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_type_ir/src/const_kind.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,15 +72,15 @@ 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,
}

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 }
}
}
Expand Down
6 changes: 5 additions & 1 deletion compiler/rustc_type_ir/src/interner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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>;
Expand Down Expand Up @@ -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,
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_type_ir/src/predicate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
}
Expand Down Expand Up @@ -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: () }
}
}

Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_type_ir/src/relate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down
Loading