Adopt even more custom types in the new solver

A lot of simplification and fun.
This commit is contained in:
Chayim Refael Friedman 2025-09-09 22:32:07 +03:00
parent 9621689e47
commit d03fd874d0
12 changed files with 221 additions and 223 deletions

View file

@ -84,6 +84,15 @@ impl LangItemTarget {
_ => None, _ => None,
} }
} }
pub fn as_adt(self) -> Option<AdtId> {
match self {
LangItemTarget::Union(it) => Some(it.into()),
LangItemTarget::EnumId(it) => Some(it.into()),
LangItemTarget::Struct(it) => Some(it.into()),
_ => None,
}
}
} }
/// Salsa query. This will look for lang items in a specific crate. /// Salsa query. This will look for lang items in a specific crate.
@ -289,6 +298,10 @@ impl LangItem {
lang_item(db, start_crate, self).and_then(|t| t.as_trait()) lang_item(db, start_crate, self).and_then(|t| t.as_trait())
} }
pub fn resolve_adt(self, db: &dyn DefDatabase, start_crate: Crate) -> Option<AdtId> {
lang_item(db, start_crate, self).and_then(|t| t.as_adt())
}
pub fn resolve_enum(self, db: &dyn DefDatabase, start_crate: Crate) -> Option<EnumId> { pub fn resolve_enum(self, db: &dyn DefDatabase, start_crate: Crate) -> Option<EnumId> {
lang_item(db, start_crate, self).and_then(|t| t.as_enum()) lang_item(db, start_crate, self).and_then(|t| t.as_enum())
} }

View file

@ -59,7 +59,7 @@ use crate::{
lt_from_placeholder_idx, lt_from_placeholder_idx,
mir::pad16, mir::pad16,
next_solver::{ next_solver::{
BoundExistentialPredicate, Ctor, DbInterner, GenericArgs, SolverDefId, BoundExistentialPredicate, DbInterner, GenericArgs, SolverDefId,
mapping::{ mapping::{
ChalkToNextSolver, convert_args_for_result, convert_const_for_result, ChalkToNextSolver, convert_args_for_result, convert_const_for_result,
convert_region_for_result, convert_ty_for_result, convert_region_for_result, convert_ty_for_result,
@ -911,14 +911,13 @@ fn render_const_scalar_inner(
f.write_str("&")?; f.write_str("&")?;
render_const_scalar_ns(f, bytes, memory_map, t) render_const_scalar_ns(f, bytes, memory_map, t)
} }
TyKind::Adt(adt, _) if b.len() == 2 * size_of::<usize>() => match adt.def_id() { TyKind::Adt(adt, _) if b.len() == 2 * size_of::<usize>() => match adt.def_id().0 {
SolverDefId::AdtId(hir_def::AdtId::StructId(s)) => { hir_def::AdtId::StructId(s) => {
let data = f.db.struct_signature(s); let data = f.db.struct_signature(s);
write!(f, "&{}", data.name.display(f.db, f.edition()))?; write!(f, "&{}", data.name.display(f.db, f.edition()))?;
Ok(()) Ok(())
} }
SolverDefId::AdtId(_) => f.write_str("<unsized-enum-or-union>"), _ => f.write_str("<unsized-enum-or-union>"),
_ => unreachable!(),
}, },
_ => { _ => {
let addr = usize::from_le_bytes(match b.try_into() { let addr = usize::from_le_bytes(match b.try_into() {
@ -966,10 +965,7 @@ fn render_const_scalar_inner(
f.write_str(")") f.write_str(")")
} }
TyKind::Adt(def, args) => { TyKind::Adt(def, args) => {
let def = match def.def_id() { let def = def.def_id().0;
SolverDefId::AdtId(def) => def,
_ => unreachable!(),
};
let Ok(layout) = f.db.layout_of_adt(def, args, trait_env.clone()) else { let Ok(layout) = f.db.layout_of_adt(def, args, trait_env.clone()) else {
return f.write_str("<layout-error>"); return f.write_str("<layout-error>");
}; };
@ -1300,12 +1296,7 @@ impl<'db> HirDisplay for crate::next_solver::Ty<'db> {
sig.hir_fmt(f)?; sig.hir_fmt(f)?;
} }
TyKind::FnDef(def, args) => { TyKind::FnDef(def, args) => {
let def = match def { let def = def.0;
SolverDefId::FunctionId(id) => CallableDefId::FunctionId(id),
SolverDefId::Ctor(Ctor::Enum(e)) => CallableDefId::EnumVariantId(e),
SolverDefId::Ctor(Ctor::Struct(s)) => CallableDefId::StructId(s),
_ => unreachable!(),
};
let sig = db let sig = db
.callable_item_signature(def) .callable_item_signature(def)
.substitute(Interner, &convert_args_for_result(interner, args.as_slice())); .substitute(Interner, &convert_args_for_result(interner, args.as_slice()));
@ -1406,10 +1397,7 @@ impl<'db> HirDisplay for crate::next_solver::Ty<'db> {
} }
} }
TyKind::Adt(def, parameters) => { TyKind::Adt(def, parameters) => {
let def_id = match def.def_id() { let def_id = def.def_id().0;
SolverDefId::AdtId(id) => id,
_ => unreachable!(),
};
f.start_location_link(def_id.into()); f.start_location_link(def_id.into());
match f.display_kind { match f.display_kind {
DisplayKind::Diagnostics | DisplayKind::Test => { DisplayKind::Diagnostics | DisplayKind::Test => {
@ -1448,7 +1436,7 @@ impl<'db> HirDisplay for crate::next_solver::Ty<'db> {
hir_fmt_generics( hir_fmt_generics(
f, f,
convert_args_for_result(interner, parameters.as_slice()).as_slice(Interner), convert_args_for_result(interner, parameters.as_slice()).as_slice(Interner),
def.def_id().try_into().ok(), Some(def.def_id().0.into()),
None, None,
)?; )?;
} }
@ -1466,13 +1454,9 @@ impl<'db> HirDisplay for crate::next_solver::Ty<'db> {
projection_ty.hir_fmt(f)?; projection_ty.hir_fmt(f)?;
} }
TyKind::Foreign(type_alias) => { TyKind::Foreign(alias) => {
let alias = match type_alias { let type_alias = db.type_alias_signature(alias.0);
SolverDefId::TypeAliasId(id) => id, f.start_location_link(alias.0.into());
_ => unreachable!(),
};
let type_alias = db.type_alias_signature(alias);
f.start_location_link(alias.into());
write!(f, "{}", type_alias.name.display(f.db, f.edition()))?; write!(f, "{}", type_alias.name.display(f.db, f.edition()))?;
f.end_location_link(); f.end_location_link();
} }
@ -1549,10 +1533,7 @@ impl<'db> HirDisplay for crate::next_solver::Ty<'db> {
} }
} }
TyKind::Closure(id, substs) => { TyKind::Closure(id, substs) => {
let id = match id { let id = id.0;
SolverDefId::InternedClosureId(id) => id,
_ => unreachable!(),
};
let substs = convert_args_for_result(interner, substs.as_slice()); let substs = convert_args_for_result(interner, substs.as_slice());
if f.display_kind.is_source_code() { if f.display_kind.is_source_code() {
if !f.display_kind.allows_opaque() { if !f.display_kind.allows_opaque() {

View file

@ -25,7 +25,7 @@ use crate::{
consteval_nextsolver::try_const_usize, consteval_nextsolver::try_const_usize,
db::HirDatabase, db::HirDatabase,
next_solver::{ next_solver::{
DbInterner, GenericArgs, ParamEnv, SolverDefId, Ty, TyKind, TypingMode, DbInterner, GenericArgs, ParamEnv, Ty, TyKind, TypingMode,
infer::{DbInternerInferExt, traits::ObligationCause}, infer::{DbInternerInferExt, traits::ObligationCause},
mapping::{ChalkToNextSolver, convert_args_for_result}, mapping::{ChalkToNextSolver, convert_args_for_result},
project::solve_normalize::deeply_normalize, project::solve_normalize::deeply_normalize,
@ -323,14 +323,10 @@ pub fn layout_of_ty_query<'db>(
ptr.valid_range_mut().start = 1; ptr.valid_range_mut().start = 1;
Layout::scalar(dl, ptr) Layout::scalar(dl, ptr)
} }
TyKind::Closure(c, args) => { TyKind::Closure(id, args) => {
let id = match c { let def = db.lookup_intern_closure(id.0);
SolverDefId::InternedClosureId(id) => id,
_ => unreachable!(),
};
let def = db.lookup_intern_closure(id);
let infer = db.infer(def.0); let infer = db.infer(def.0);
let (captures, _) = infer.closure_info(&id.into()); let (captures, _) = infer.closure_info(&id.0.into());
let fields = captures let fields = captures
.iter() .iter()
.map(|it| { .map(|it| {

View file

@ -161,10 +161,7 @@ impl TyFingerprint {
rustc_ast_ir::Mutability::Mut => TyFingerprint::RawPtr(Mutability::Mut), rustc_ast_ir::Mutability::Mut => TyFingerprint::RawPtr(Mutability::Mut),
rustc_ast_ir::Mutability::Not => TyFingerprint::RawPtr(Mutability::Not), rustc_ast_ir::Mutability::Not => TyFingerprint::RawPtr(Mutability::Not),
}, },
TyKind::Foreign(def) => { TyKind::Foreign(def) => TyFingerprint::ForeignType(crate::to_foreign_def_id(def.0)),
let SolverDefId::TypeAliasId(def) = def else { unreachable!() };
TyFingerprint::ForeignType(crate::to_foreign_def_id(def))
}
TyKind::Dynamic(bounds, _, _) => { TyKind::Dynamic(bounds, _, _) => {
let trait_ref = bounds let trait_ref = bounds
.as_slice() .as_slice()

View file

@ -42,7 +42,7 @@ use crate::{
layout::{Layout, LayoutError, RustcEnumVariantIdx}, layout::{Layout, LayoutError, RustcEnumVariantIdx},
method_resolution::{is_dyn_method, lookup_impl_const}, method_resolution::{is_dyn_method, lookup_impl_const},
next_solver::{ next_solver::{
Ctor, DbInterner, SolverDefId, DbInterner,
mapping::{ChalkToNextSolver, convert_args_for_result, convert_ty_for_result}, mapping::{ChalkToNextSolver, convert_args_for_result, convert_ty_for_result},
}, },
static_lifetime, static_lifetime,
@ -2366,8 +2366,8 @@ impl<'db> Evaluator<'db> {
let new_id = self.vtable_map.id(ty); let new_id = self.vtable_map.id(ty);
self.write_memory(addr, &new_id.to_le_bytes())?; self.write_memory(addr, &new_id.to_le_bytes())?;
} }
TyKind::Adt(id, args) => match id.def_id() { TyKind::Adt(id, args) => match id.def_id().0 {
SolverDefId::AdtId(AdtId::StructId(s)) => { AdtId::StructId(s) => {
for (i, (_, ty)) in self.db.field_types_ns(s.into()).iter().enumerate() { for (i, (_, ty)) in self.db.field_types_ns(s.into()).iter().enumerate() {
let offset = layout.fields.offset(i).bytes_usize(); let offset = layout.fields.offset(i).bytes_usize();
let ty = ty.instantiate(interner, args); let ty = ty.instantiate(interner, args);
@ -2380,8 +2380,8 @@ impl<'db> Evaluator<'db> {
)?; )?;
} }
} }
SolverDefId::AdtId(AdtId::UnionId(_)) => (), AdtId::UnionId(_) => (),
SolverDefId::AdtId(AdtId::EnumId(e)) => { AdtId::EnumId(e) => {
if let Some((ev, layout)) = detect_variant_from_bytes( if let Some((ev, layout)) = detect_variant_from_bytes(
&layout, &layout,
self.db, self.db,
@ -2402,7 +2402,6 @@ impl<'db> Evaluator<'db> {
} }
} }
} }
_ => unreachable!(),
}, },
TyKind::Tuple(tys) => { TyKind::Tuple(tys) => {
for (id, ty) in tys.iter().enumerate() { for (id, ty) in tys.iter().enumerate() {
@ -2472,38 +2471,24 @@ impl<'db> Evaluator<'db> {
let interner = DbInterner::new_with(self.db, None, None); let interner = DbInterner::new_with(self.db, None, None);
use rustc_type_ir::TyKind; use rustc_type_ir::TyKind;
match next_ty.kind() { match next_ty.kind() {
TyKind::FnDef(def, generic_args) => { TyKind::FnDef(def, generic_args) => self.exec_fn_def(
let def = match def { def.0,
SolverDefId::FunctionId(id) => CallableDefId::FunctionId(id), &convert_args_for_result(interner, generic_args.as_slice()),
SolverDefId::Ctor(Ctor::Struct(s)) => CallableDefId::StructId(s), destination,
SolverDefId::Ctor(Ctor::Enum(e)) => CallableDefId::EnumVariantId(e), args,
_ => unreachable!(), locals,
}; target_bb,
self.exec_fn_def( span,
def, ),
&convert_args_for_result(interner, generic_args.as_slice()), TyKind::Closure(id, generic_args) => self.exec_closure(
destination, id.0.into(),
args, bytes.slice(0..0),
locals, &convert_args_for_result(interner, generic_args.as_slice()),
target_bb, destination,
span, args,
) locals,
} span,
TyKind::Closure(id, generic_args) => { ),
let id = match id {
SolverDefId::InternedClosureId(id) => id,
_ => unreachable!(),
};
self.exec_closure(
id.into(),
bytes.slice(0..0),
&convert_args_for_result(interner, generic_args.as_slice()),
destination,
args,
locals,
span,
)
}
_ => Err(MirEvalError::InternalError("function pointer to non function".into())), _ => Err(MirEvalError::InternalError("function pointer to non function".into())),
} }
} }

View file

@ -1,8 +1,8 @@
//! Definition of `SolverDefId` //! Definition of `SolverDefId`
use hir_def::{ use hir_def::{
AdtId, ConstId, EnumId, EnumVariantId, FunctionId, GenericDefId, ImplId, StaticId, StructId, AdtId, CallableDefId, ConstId, EnumId, EnumVariantId, FunctionId, GenericDefId, ImplId,
TraitId, TypeAliasId, UnionId, StaticId, StructId, TraitId, TypeAliasId, UnionId,
}; };
use rustc_type_ir::inherent; use rustc_type_ir::inherent;
use stdx::impl_from; use stdx::impl_from;
@ -42,7 +42,8 @@ impl_from!(
TypeAliasId, TypeAliasId,
InternedClosureId, InternedClosureId,
InternedCoroutineId, InternedCoroutineId,
InternedOpaqueTyId InternedOpaqueTyId,
Ctor
for SolverDefId for SolverDefId
); );
@ -145,3 +146,59 @@ macro_rules! declare_id_wrapper {
} }
declare_id_wrapper!(TraitIdWrapper, TraitId); declare_id_wrapper!(TraitIdWrapper, TraitId);
declare_id_wrapper!(TypeAliasIdWrapper, TypeAliasId);
declare_id_wrapper!(ClosureIdWrapper, InternedClosureId);
declare_id_wrapper!(CoroutineIdWrapper, InternedCoroutineId);
declare_id_wrapper!(AdtIdWrapper, AdtId);
declare_id_wrapper!(ImplIdWrapper, ImplId);
#[derive(Clone, Copy, PartialEq, Eq, Hash)]
pub struct CallableIdWrapper(pub CallableDefId);
impl std::fmt::Debug for CallableIdWrapper {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
std::fmt::Debug::fmt(&self.0, f)
}
}
impl From<CallableIdWrapper> for CallableDefId {
#[inline]
fn from(value: CallableIdWrapper) -> CallableDefId {
value.0
}
}
impl From<CallableDefId> for CallableIdWrapper {
#[inline]
fn from(value: CallableDefId) -> CallableIdWrapper {
Self(value)
}
}
impl From<CallableIdWrapper> for SolverDefId {
#[inline]
fn from(value: CallableIdWrapper) -> SolverDefId {
match value.0 {
CallableDefId::FunctionId(it) => it.into(),
CallableDefId::StructId(it) => Ctor::Struct(it).into(),
CallableDefId::EnumVariantId(it) => Ctor::Enum(it).into(),
}
}
}
impl TryFrom<SolverDefId> for CallableIdWrapper {
type Error = ();
#[inline]
fn try_from(value: SolverDefId) -> Result<Self, Self::Error> {
match value {
SolverDefId::FunctionId(it) => Ok(Self(it.into())),
SolverDefId::Ctor(Ctor::Struct(it)) => Ok(Self(it.into())),
SolverDefId::Ctor(Ctor::Enum(it)) => Ok(Self(it.into())),
_ => Err(()),
}
}
}
impl<'db> inherent::DefId<DbInterner<'db>> for CallableIdWrapper {
fn as_local(self) -> Option<SolverDefId> {
Some(self.into())
}
fn is_local(self) -> bool {
true
}
}

View file

@ -400,7 +400,7 @@ impl<'cx, 'db> TypeFolder<DbInterner<'db>> for Canonicalizer<'cx, 'db> {
TyKind::Infer(IntVar(vid)) => { TyKind::Infer(IntVar(vid)) => {
let nt = self.infcx.opportunistic_resolve_int_var(vid); let nt = self.infcx.opportunistic_resolve_int_var(vid);
if nt != t { if nt != t {
return self.fold_ty(nt); self.fold_ty(nt)
} else { } else {
self.canonicalize_ty_var(CanonicalVarKind::Int, t) self.canonicalize_ty_var(CanonicalVarKind::Int, t)
} }
@ -408,7 +408,7 @@ impl<'cx, 'db> TypeFolder<DbInterner<'db>> for Canonicalizer<'cx, 'db> {
TyKind::Infer(FloatVar(vid)) => { TyKind::Infer(FloatVar(vid)) => {
let nt = self.infcx.opportunistic_resolve_float_var(vid); let nt = self.infcx.opportunistic_resolve_float_var(vid);
if nt != t { if nt != t {
return self.fold_ty(nt); self.fold_ty(nt)
} else { } else {
self.canonicalize_ty_var(CanonicalVarKind::Float, t) self.canonicalize_ty_var(CanonicalVarKind::Float, t)
} }

View file

@ -82,9 +82,7 @@ impl<'db> InferCtxt<'db> {
let var_values = CanonicalVarValues::instantiate( let var_values = CanonicalVarValues::instantiate(
self.interner, self.interner,
canonical.variables, canonical.variables,
|var_values, info| { |var_values, info| self.instantiate_canonical_var(info, var_values, |ui| universes[ui]),
self.instantiate_canonical_var(info, &var_values, |ui| universes[ui])
},
); );
let result = canonical.instantiate(self.interner, &var_values); let result = canonical.instantiate(self.interner, &var_values);
(result, var_values) (result, var_values)

View file

@ -19,7 +19,7 @@ use rustc_type_ir::error::TypeError;
use rustc_type_ir::inherent::{ use rustc_type_ir::inherent::{
AdtDef as _, GenericArgs as _, GenericsOf, IntoKind, SliceLike as _, Span as _, AdtDef as _, GenericArgs as _, GenericsOf, IntoKind, SliceLike as _, Span as _,
}; };
use rustc_type_ir::lang_items::{SolverLangItem, SolverTraitLangItem}; use rustc_type_ir::lang_items::{SolverAdtLangItem, SolverLangItem, SolverTraitLangItem};
use rustc_type_ir::solve::SizedTraitKind; use rustc_type_ir::solve::SizedTraitKind;
use rustc_type_ir::{ use rustc_type_ir::{
AliasTerm, AliasTermKind, AliasTy, AliasTyKind, EarlyBinder, FlagComputation, Flags, AliasTerm, AliasTermKind, AliasTy, AliasTyKind, EarlyBinder, FlagComputation, Flags,
@ -47,8 +47,9 @@ use crate::method_resolution::{ALL_FLOAT_FPS, ALL_INT_FPS, TyFingerprint};
use crate::next_solver::infer::InferCtxt; use crate::next_solver::infer::InferCtxt;
use crate::next_solver::util::{ContainsTypeErrors, explicit_item_bounds, for_trait_impls}; use crate::next_solver::util::{ContainsTypeErrors, explicit_item_bounds, for_trait_impls};
use crate::next_solver::{ use crate::next_solver::{
BoundConst, CanonicalVarKind, FxIndexMap, InternedWrapperNoDebug, RegionAssumptions, AdtIdWrapper, BoundConst, CallableIdWrapper, CanonicalVarKind, ClosureIdWrapper,
SolverContext, SolverDefIds, TraitIdWrapper, CoroutineIdWrapper, FxIndexMap, ImplIdWrapper, InternedWrapperNoDebug, RegionAssumptions,
SolverContext, SolverDefIds, TraitIdWrapper, TypeAliasIdWrapper,
}; };
use crate::{ConstScalar, FnAbi, Interner, db::HirDatabase}; use crate::{ConstScalar, FnAbi, Interner, db::HirDatabase};
@ -609,8 +610,8 @@ impl AdtDef {
} }
impl<'db> inherent::AdtDef<DbInterner<'db>> for AdtDef { impl<'db> inherent::AdtDef<DbInterner<'db>> for AdtDef {
fn def_id(self) -> <DbInterner<'db> as rustc_type_ir::Interner>::DefId { fn def_id(self) -> AdtIdWrapper {
SolverDefId::AdtId(self.inner().id) self.inner().id.into()
} }
fn is_struct(self) -> bool { fn is_struct(self) -> bool {
@ -889,6 +890,13 @@ impl<'db> rustc_type_ir::Interner for DbInterner<'db> {
type LocalDefId = SolverDefId; type LocalDefId = SolverDefId;
type LocalDefIds = SolverDefIds; type LocalDefIds = SolverDefIds;
type TraitId = TraitIdWrapper; type TraitId = TraitIdWrapper;
type ForeignId = TypeAliasIdWrapper;
type FunctionId = CallableIdWrapper;
type ClosureId = ClosureIdWrapper;
type CoroutineClosureId = CoroutineIdWrapper;
type CoroutineId = CoroutineIdWrapper;
type AdtId = AdtIdWrapper;
type ImplId = ImplIdWrapper;
type Span = Span; type Span = Span;
type GenericArgs = GenericArgs<'db>; type GenericArgs = GenericArgs<'db>;
@ -1103,12 +1111,8 @@ impl<'db> rustc_type_ir::Interner for DbInterner<'db> {
self.db().ty_ns(def_id) self.db().ty_ns(def_id)
} }
fn adt_def(self, adt_def_id: Self::DefId) -> Self::AdtDef { fn adt_def(self, def_id: Self::AdtId) -> Self::AdtDef {
let def_id = match adt_def_id { AdtDef::new(def_id.0, self)
SolverDefId::AdtId(adt_id) => adt_id,
_ => panic!("Invalid DefId passed to adt_def"),
};
AdtDef::new(def_id, self)
} }
fn alias_ty_kind(self, alias: rustc_type_ir::AliasTy<Self>) -> AliasTyKind { fn alias_ty_kind(self, alias: rustc_type_ir::AliasTy<Self>) -> AliasTyKind {
@ -1219,24 +1223,16 @@ impl<'db> rustc_type_ir::Interner for DbInterner<'db> {
fn fn_sig( fn fn_sig(
self, self,
def_id: Self::DefId, def_id: Self::FunctionId,
) -> EarlyBinder<Self, rustc_type_ir::Binder<Self, rustc_type_ir::FnSig<Self>>> { ) -> EarlyBinder<Self, rustc_type_ir::Binder<Self, rustc_type_ir::FnSig<Self>>> {
let id = match def_id { self.db().callable_item_signature_ns(def_id.0)
SolverDefId::FunctionId(id) => CallableDefId::FunctionId(id),
SolverDefId::Ctor(ctor) => match ctor {
super::Ctor::Struct(struct_id) => CallableDefId::StructId(struct_id),
super::Ctor::Enum(enum_variant_id) => CallableDefId::EnumVariantId(enum_variant_id),
},
def => unreachable!("{:?}", def),
};
self.db().callable_item_signature_ns(id)
} }
fn coroutine_movability(self, def_id: Self::DefId) -> rustc_ast_ir::Movability { fn coroutine_movability(self, def_id: Self::CoroutineId) -> rustc_ast_ir::Movability {
unimplemented!() unimplemented!()
} }
fn coroutine_for_closure(self, def_id: Self::DefId) -> Self::DefId { fn coroutine_for_closure(self, def_id: Self::CoroutineId) -> Self::CoroutineId {
unimplemented!() unimplemented!()
} }
@ -1361,13 +1357,9 @@ impl<'db> rustc_type_ir::Interner for DbInterner<'db> {
fn impl_super_outlives( fn impl_super_outlives(
self, self,
impl_def_id: Self::DefId, impl_id: Self::ImplId,
) -> EarlyBinder<Self, impl IntoIterator<Item = Self::Clause>> { ) -> EarlyBinder<Self, impl IntoIterator<Item = Self::Clause>> {
let impl_id = match impl_def_id { let trait_ref = self.db().impl_trait_ns(impl_id.0).expect("expected an impl of trait");
SolverDefId::ImplId(id) => id,
_ => unreachable!(),
};
let trait_ref = self.db().impl_trait_ns(impl_id).expect("expected an impl of trait");
trait_ref.map_bound(|trait_ref| { trait_ref.map_bound(|trait_ref| {
let clause: Clause<'_> = trait_ref.upcast(self); let clause: Clause<'_> = trait_ref.upcast(self);
Clauses::new_from_iter( Clauses::new_from_iter(
@ -1392,7 +1384,7 @@ impl<'db> rustc_type_ir::Interner for DbInterner<'db> {
EarlyBinder::bind([unimplemented!()]) EarlyBinder::bind([unimplemented!()])
} }
fn has_target_features(self, def_id: Self::DefId) -> bool { fn has_target_features(self, def_id: Self::FunctionId) -> bool {
false false
} }
@ -1407,8 +1399,6 @@ impl<'db> rustc_type_ir::Interner for DbInterner<'db> {
SolverLangItem::DynMetadata => LangItem::DynMetadata, SolverLangItem::DynMetadata => LangItem::DynMetadata,
SolverLangItem::FutureOutput => LangItem::FutureOutput, SolverLangItem::FutureOutput => LangItem::FutureOutput,
SolverLangItem::Metadata => LangItem::Metadata, SolverLangItem::Metadata => LangItem::Metadata,
SolverLangItem::Option => LangItem::Option,
SolverLangItem::Poll => LangItem::Poll,
}; };
let target = hir_def::lang_item::lang_item( let target = hir_def::lang_item::lang_item(
self.db(), self.db(),
@ -1468,24 +1458,33 @@ impl<'db> rustc_type_ir::Interner for DbInterner<'db> {
.into() .into()
} }
#[allow(clippy::match_like_matches_macro)] fn require_adt_lang_item(self, lang_item: SolverAdtLangItem) -> AdtIdWrapper {
fn is_lang_item(self, def_id: Self::DefId, lang_item: SolverLangItem) -> bool { let lang_item = match lang_item {
use SolverLangItem::*; SolverAdtLangItem::Option => LangItem::Option,
SolverAdtLangItem::Poll => LangItem::Poll,
};
lang_item
.resolve_adt(self.db(), self.krate.expect("Must have self.krate"))
.unwrap_or_else(|| panic!("Lang item {lang_item:?} required but not found."))
.into()
}
// FIXME: derive PartialEq on SolverLangItem fn is_lang_item(self, def_id: Self::DefId, lang_item: SolverLangItem) -> bool {
self.as_lang_item(def_id) self.as_lang_item(def_id)
.map_or(false, |l| std::mem::discriminant(&l) == std::mem::discriminant(&lang_item)) .map_or(false, |l| std::mem::discriminant(&l) == std::mem::discriminant(&lang_item))
} }
#[allow(clippy::match_like_matches_macro)]
fn is_trait_lang_item(self, def_id: Self::TraitId, lang_item: SolverTraitLangItem) -> bool { fn is_trait_lang_item(self, def_id: Self::TraitId, lang_item: SolverTraitLangItem) -> bool {
use SolverTraitLangItem::*;
// FIXME: derive PartialEq on SolverTraitLangItem
self.as_trait_lang_item(def_id) self.as_trait_lang_item(def_id)
.map_or(false, |l| std::mem::discriminant(&l) == std::mem::discriminant(&lang_item)) .map_or(false, |l| std::mem::discriminant(&l) == std::mem::discriminant(&lang_item))
} }
fn is_adt_lang_item(self, def_id: Self::AdtId, lang_item: SolverAdtLangItem) -> bool {
// FIXME: derive PartialEq on SolverTraitLangItem
self.as_adt_lang_item(def_id)
.map_or(false, |l| std::mem::discriminant(&l) == std::mem::discriminant(&lang_item))
}
fn as_lang_item(self, def_id: Self::DefId) -> Option<SolverLangItem> { fn as_lang_item(self, def_id: Self::DefId) -> Option<SolverLangItem> {
let def_id: AttrDefId = match def_id { let def_id: AttrDefId = match def_id {
SolverDefId::TraitId(id) => id.into(), SolverDefId::TraitId(id) => id.into(),
@ -1505,9 +1504,7 @@ impl<'db> rustc_type_ir::Interner for DbInterner<'db> {
DynMetadata, DynMetadata,
CoroutineReturn, CoroutineReturn,
CoroutineYield, CoroutineYield,
Poll,
FutureOutput, FutureOutput,
Option,
AsyncFnOnceOutput, AsyncFnOnceOutput,
CallRefFuture, CallRefFuture,
CallOnceFuture, CallOnceFuture,
@ -1556,6 +1553,19 @@ impl<'db> rustc_type_ir::Interner for DbInterner<'db> {
) )
} }
fn as_adt_lang_item(self, def_id: Self::AdtId) -> Option<SolverAdtLangItem> {
let def_id: AttrDefId = def_id.0.into();
let lang_item = self.db().lang_attr(def_id)?;
as_lang_item!(
SolverAdtLangItem, lang_item;
ignore = {}
Option,
Poll,
)
}
fn associated_type_def_ids(self, def_id: Self::DefId) -> impl IntoIterator<Item = Self::DefId> { fn associated_type_def_ids(self, def_id: Self::DefId) -> impl IntoIterator<Item = Self::DefId> {
let trait_ = match def_id { let trait_ = match def_id {
SolverDefId::TraitId(id) => id, SolverDefId::TraitId(id) => id,
@ -1568,7 +1578,7 @@ impl<'db> rustc_type_ir::Interner for DbInterner<'db> {
self, self,
trait_: Self::TraitId, trait_: Self::TraitId,
self_ty: Self::Ty, self_ty: Self::Ty,
mut f: impl FnMut(Self::DefId), mut f: impl FnMut(Self::ImplId),
) { ) {
let trait_ = trait_.0; let trait_ = trait_.0;
let self_ty_fp = TyFingerprint::for_trait_impl_ns(&self_ty); let self_ty_fp = TyFingerprint::for_trait_impl_ns(&self_ty);
@ -1595,7 +1605,7 @@ impl<'db> rustc_type_ir::Interner for DbInterner<'db> {
continue; continue;
} }
f(SolverDefId::ImplId(i)); f(i.into());
} }
ControlFlow::Continue(()) ControlFlow::Continue(())
}, },
@ -1618,7 +1628,7 @@ impl<'db> rustc_type_ir::Interner for DbInterner<'db> {
continue; continue;
} }
f(SolverDefId::ImplId(i)); f(i.into());
} }
} }
ControlFlow::Continue(()) ControlFlow::Continue(())
@ -1632,7 +1642,7 @@ impl<'db> rustc_type_ir::Interner for DbInterner<'db> {
true true
} }
fn impl_is_default(self, impl_def_id: Self::DefId) -> bool { fn impl_is_default(self, impl_def_id: Self::ImplId) -> bool {
// FIXME // FIXME
false false
} }
@ -1640,26 +1650,16 @@ impl<'db> rustc_type_ir::Interner for DbInterner<'db> {
#[tracing::instrument(skip(self), ret)] #[tracing::instrument(skip(self), ret)]
fn impl_trait_ref( fn impl_trait_ref(
self, self,
impl_def_id: Self::DefId, impl_id: Self::ImplId,
) -> EarlyBinder<Self, rustc_type_ir::TraitRef<Self>> { ) -> EarlyBinder<Self, rustc_type_ir::TraitRef<Self>> {
let impl_id = match impl_def_id {
SolverDefId::ImplId(id) => id,
_ => panic!("Unexpected SolverDefId in impl_trait_ref"),
};
let db = self.db(); let db = self.db();
db.impl_trait_ns(impl_id.0)
db.impl_trait_ns(impl_id)
// ImplIds for impls where the trait ref can't be resolved should never reach trait solving // ImplIds for impls where the trait ref can't be resolved should never reach trait solving
.expect("invalid impl passed to trait solver") .expect("invalid impl passed to trait solver")
} }
fn impl_polarity(self, impl_def_id: Self::DefId) -> rustc_type_ir::ImplPolarity { fn impl_polarity(self, impl_id: Self::ImplId) -> rustc_type_ir::ImplPolarity {
let impl_id = match impl_def_id { let impl_data = self.db().impl_signature(impl_id.0);
SolverDefId::ImplId(id) => id,
_ => unreachable!(),
};
let impl_data = self.db().impl_signature(impl_id);
if impl_data.flags.contains(ImplFlags::NEGATIVE) { if impl_data.flags.contains(ImplFlags::NEGATIVE) {
ImplPolarity::Negative ImplPolarity::Negative
} else { } else {
@ -1701,33 +1701,29 @@ impl<'db> rustc_type_ir::Interner for DbInterner<'db> {
panic!("Bug encountered in next-trait-solver.") panic!("Bug encountered in next-trait-solver.")
} }
fn is_general_coroutine(self, coroutine_def_id: Self::DefId) -> bool { fn is_general_coroutine(self, coroutine_def_id: Self::CoroutineId) -> bool {
// FIXME(next-solver) // FIXME(next-solver)
true true
} }
fn coroutine_is_async(self, coroutine_def_id: Self::DefId) -> bool { fn coroutine_is_async(self, coroutine_def_id: Self::CoroutineId) -> bool {
// FIXME(next-solver) // FIXME(next-solver)
true true
} }
fn coroutine_is_gen(self, coroutine_def_id: Self::DefId) -> bool { fn coroutine_is_gen(self, coroutine_def_id: Self::CoroutineId) -> bool {
// FIXME(next-solver) // FIXME(next-solver)
false false
} }
fn coroutine_is_async_gen(self, coroutine_def_id: Self::DefId) -> bool { fn coroutine_is_async_gen(self, coroutine_def_id: Self::CoroutineId) -> bool {
// FIXME(next-solver) // FIXME(next-solver)
false false
} }
fn unsizing_params_for_adt(self, adt_def_id: Self::DefId) -> Self::UnsizingParams { fn unsizing_params_for_adt(self, id: Self::AdtId) -> Self::UnsizingParams {
let id = match adt_def_id { let def = AdtDef::new(id.0, self);
SolverDefId::AdtId(id) => id, let num_params = self.generics_of(id.into()).count();
_ => unreachable!(),
};
let def = AdtDef::new(id, self);
let num_params = self.generics_of(adt_def_id).count();
let maybe_unsizing_param_idx = |arg: GenericArg<'db>| match arg.kind() { let maybe_unsizing_param_idx = |arg: GenericArg<'db>| match arg.kind() {
GenericArgKind::Type(ty) => match ty.kind() { GenericArgKind::Type(ty) => match ty.kind() {
@ -1835,15 +1831,15 @@ impl<'db> rustc_type_ir::Interner for DbInterner<'db> {
EarlyBinder::bind([]) EarlyBinder::bind([])
} }
fn fn_is_const(self, def_id: Self::DefId) -> bool { fn fn_is_const(self, id: Self::FunctionId) -> bool {
let id = match def_id { let id = match id.0 {
SolverDefId::FunctionId(id) => id, CallableDefId::FunctionId(id) => id,
_ => unreachable!(), _ => return false,
}; };
self.db().function_signature(id).flags.contains(FnFlags::CONST) self.db().function_signature(id).flags.contains(FnFlags::CONST)
} }
fn impl_is_const(self, def_id: Self::DefId) -> bool { fn impl_is_const(self, def_id: Self::ImplId) -> bool {
false false
} }
@ -1877,7 +1873,7 @@ impl<'db> rustc_type_ir::Interner for DbInterner<'db> {
fn coroutine_hidden_types( fn coroutine_hidden_types(
self, self,
def_id: Self::DefId, def_id: Self::CoroutineId,
) -> EarlyBinder<Self, rustc_type_ir::Binder<Self, rustc_type_ir::CoroutineWitnessTypes<Self>>> ) -> EarlyBinder<Self, rustc_type_ir::Binder<Self, rustc_type_ir::CoroutineWitnessTypes<Self>>>
{ {
// FIXME(next-solver) // FIXME(next-solver)
@ -1896,11 +1892,11 @@ impl<'db> rustc_type_ir::Interner for DbInterner<'db> {
self.db().trait_signature(trait_.0).flags.contains(TraitFlags::UNSAFE) self.db().trait_signature(trait_.0).flags.contains(TraitFlags::UNSAFE)
} }
fn impl_self_is_guaranteed_unsized(self, def_id: Self::DefId) -> bool { fn impl_self_is_guaranteed_unsized(self, def_id: Self::ImplId) -> bool {
false false
} }
fn impl_specializes(self, impl_def_id: Self::DefId, victim_def_id: Self::DefId) -> bool { fn impl_specializes(self, impl_def_id: Self::ImplId, victim_def_id: Self::ImplId) -> bool {
false false
} }
@ -2020,6 +2016,12 @@ macro_rules! TrivialTypeTraversalImpls {
TrivialTypeTraversalImpls! { TrivialTypeTraversalImpls! {
SolverDefId, SolverDefId,
TraitIdWrapper, TraitIdWrapper,
TypeAliasIdWrapper,
CallableIdWrapper,
ClosureIdWrapper,
CoroutineIdWrapper,
AdtIdWrapper,
ImplIdWrapper,
Pattern<'db>, Pattern<'db>,
Safety, Safety,
FnAbi, FnAbi,

View file

@ -243,12 +243,10 @@ impl<'db> ChalkToNextSolver<'db, Ty<'db>> for chalk_ir::Ty<Interner> {
} }
chalk_ir::TyKind::FnDef(fn_def_id, substitution) => { chalk_ir::TyKind::FnDef(fn_def_id, substitution) => {
let def_id = CallableDefId::from_chalk(interner.db(), *fn_def_id); let def_id = CallableDefId::from_chalk(interner.db(), *fn_def_id);
let id: SolverDefId = match def_id { rustc_type_ir::TyKind::FnDef(
CallableDefId::FunctionId(id) => id.into(), def_id.into(),
CallableDefId::StructId(id) => SolverDefId::Ctor(Ctor::Struct(id)), substitution.to_nextsolver(interner),
CallableDefId::EnumVariantId(id) => SolverDefId::Ctor(Ctor::Enum(id)), )
};
rustc_type_ir::TyKind::FnDef(id, substitution.to_nextsolver(interner))
} }
chalk_ir::TyKind::Str => rustc_type_ir::TyKind::Str, chalk_ir::TyKind::Str => rustc_type_ir::TyKind::Str,
chalk_ir::TyKind::Never => rustc_type_ir::TyKind::Never, chalk_ir::TyKind::Never => rustc_type_ir::TyKind::Never,
@ -271,7 +269,7 @@ impl<'db> ChalkToNextSolver<'db, Ty<'db>> for chalk_ir::Ty<Interner> {
) )
} }
chalk_ir::TyKind::Foreign(foreign_def_id) => rustc_type_ir::TyKind::Foreign( chalk_ir::TyKind::Foreign(foreign_def_id) => rustc_type_ir::TyKind::Foreign(
SolverDefId::TypeAliasId(crate::from_foreign_def_id(*foreign_def_id)), crate::from_foreign_def_id(*foreign_def_id).into(),
), ),
chalk_ir::TyKind::Error => rustc_type_ir::TyKind::Error(ErrorGuaranteed), chalk_ir::TyKind::Error => rustc_type_ir::TyKind::Error(ErrorGuaranteed),
chalk_ir::TyKind::Dyn(dyn_ty) => { chalk_ir::TyKind::Dyn(dyn_ty) => {
@ -1511,13 +1509,7 @@ pub(crate) fn convert_ty_for_result<'db>(interner: DbInterner<'db>, ty: Ty<'db>)
TyKind::Slice(ty) TyKind::Slice(ty)
} }
rustc_type_ir::TyKind::Foreign(foreign) => { rustc_type_ir::TyKind::Foreign(foreign) => TyKind::Foreign(to_foreign_def_id(foreign.0)),
let def_id = match foreign {
SolverDefId::TypeAliasId(id) => id,
_ => unreachable!(),
};
TyKind::Foreign(to_foreign_def_id(def_id))
}
rustc_type_ir::TyKind::Pat(_, _) => unimplemented!(), rustc_type_ir::TyKind::Pat(_, _) => unimplemented!(),
rustc_type_ir::TyKind::RawPtr(ty, mutability) => { rustc_type_ir::TyKind::RawPtr(ty, mutability) => {
let mutability = match mutability { let mutability = match mutability {
@ -1528,40 +1520,22 @@ pub(crate) fn convert_ty_for_result<'db>(interner: DbInterner<'db>, ty: Ty<'db>)
TyKind::Raw(mutability, ty) TyKind::Raw(mutability, ty)
} }
rustc_type_ir::TyKind::FnDef(def_id, args) => { rustc_type_ir::TyKind::FnDef(def_id, args) => {
let id = match def_id {
SolverDefId::FunctionId(id) => CallableDefId::FunctionId(id),
SolverDefId::Ctor(Ctor::Struct(id)) => CallableDefId::StructId(id),
SolverDefId::Ctor(Ctor::Enum(id)) => CallableDefId::EnumVariantId(id),
_ => unreachable!(),
};
let subst = convert_args_for_result(interner, args.as_slice()); let subst = convert_args_for_result(interner, args.as_slice());
TyKind::FnDef(id.to_chalk(interner.db()), subst) TyKind::FnDef(def_id.0.to_chalk(interner.db()), subst)
} }
rustc_type_ir::TyKind::Closure(def_id, args) => { rustc_type_ir::TyKind::Closure(def_id, args) => {
let id = match def_id {
SolverDefId::InternedClosureId(id) => id,
_ => unreachable!(),
};
let subst = convert_args_for_result(interner, args.as_slice()); let subst = convert_args_for_result(interner, args.as_slice());
TyKind::Closure(id.into(), subst) TyKind::Closure(def_id.0.into(), subst)
} }
rustc_type_ir::TyKind::CoroutineClosure(_, _) => unimplemented!(), rustc_type_ir::TyKind::CoroutineClosure(_, _) => unimplemented!(),
rustc_type_ir::TyKind::Coroutine(def_id, args) => { rustc_type_ir::TyKind::Coroutine(def_id, args) => {
let id = match def_id {
SolverDefId::InternedCoroutineId(id) => id,
_ => unreachable!(),
};
let subst = convert_args_for_result(interner, args.as_slice()); let subst = convert_args_for_result(interner, args.as_slice());
TyKind::Coroutine(id.into(), subst) TyKind::Coroutine(def_id.0.into(), subst)
} }
rustc_type_ir::TyKind::CoroutineWitness(def_id, args) => { rustc_type_ir::TyKind::CoroutineWitness(def_id, args) => {
let id = match def_id {
SolverDefId::InternedCoroutineId(id) => id,
_ => unreachable!(),
};
let subst = convert_args_for_result(interner, args.as_slice()); let subst = convert_args_for_result(interner, args.as_slice());
TyKind::CoroutineWitness(id.into(), subst) TyKind::CoroutineWitness(def_id.0.into(), subst)
} }
rustc_type_ir::TyKind::UnsafeBinder(_) => unimplemented!(), rustc_type_ir::TyKind::UnsafeBinder(_) => unimplemented!(),

View file

@ -9,8 +9,8 @@ use rustc_type_ir::{
solve::{Certainty, NoSolution}, solve::{Certainty, NoSolution},
}; };
use crate::next_solver::CanonicalVarKind;
use crate::next_solver::mapping::NextSolverToChalk; use crate::next_solver::mapping::NextSolverToChalk;
use crate::next_solver::{CanonicalVarKind, ImplIdWrapper};
use crate::{ use crate::{
TraitRefExt, TraitRefExt,
db::HirDatabase, db::HirDatabase,
@ -148,12 +148,8 @@ impl<'db> SolverDelegate for SolverContext<'db> {
&self, &self,
goal_trait_ref: rustc_type_ir::TraitRef<Self::Interner>, goal_trait_ref: rustc_type_ir::TraitRef<Self::Interner>,
trait_assoc_def_id: <Self::Interner as rustc_type_ir::Interner>::DefId, trait_assoc_def_id: <Self::Interner as rustc_type_ir::Interner>::DefId,
impl_def_id: <Self::Interner as rustc_type_ir::Interner>::DefId, impl_id: ImplIdWrapper,
) -> Result<Option<<Self::Interner as rustc_type_ir::Interner>::DefId>, ErrorGuaranteed> { ) -> Result<Option<<Self::Interner as rustc_type_ir::Interner>::DefId>, ErrorGuaranteed> {
let impl_id = match impl_def_id {
SolverDefId::ImplId(id) => id,
_ => panic!("Unexpected SolverDefId"),
};
let trait_assoc_id = match trait_assoc_def_id { let trait_assoc_id = match trait_assoc_def_id {
SolverDefId::TypeAliasId(id) => id, SolverDefId::TypeAliasId(id) => id,
_ => panic!("Unexpected SolverDefId"), _ => panic!("Unexpected SolverDefId"),
@ -162,7 +158,7 @@ impl<'db> SolverDelegate for SolverContext<'db> {
.0 .0
.interner .interner
.db() .db()
.impl_trait(impl_id) .impl_trait(impl_id.0)
// ImplIds for impls where the trait ref can't be resolved should never reach solver // ImplIds for impls where the trait ref can't be resolved should never reach solver
.expect("invalid impl passed to next-solver") .expect("invalid impl passed to next-solver")
.into_value_and_skipped_binders() .into_value_and_skipped_binders()
@ -170,7 +166,7 @@ impl<'db> SolverDelegate for SolverContext<'db> {
let trait_ = trait_ref.hir_trait_id(); let trait_ = trait_ref.hir_trait_id();
let trait_data = trait_.trait_items(self.0.interner.db()); let trait_data = trait_.trait_items(self.0.interner.db());
let id = let id =
impl_id.impl_items(self.0.interner.db()).items.iter().find_map(|item| -> Option<_> { impl_id.0.impl_items(self.0.interner.db()).items.iter().find_map(|item| -> Option<_> {
match item { match item {
(_, AssocItemId::TypeAliasId(type_alias)) => { (_, AssocItemId::TypeAliasId(type_alias)) => {
let name = &self.0.interner.db().type_alias_signature(*type_alias).name; let name = &self.0.interner.db().type_alias_signature(*type_alias).name;

View file

@ -20,7 +20,9 @@ use rustc_type_ir::{
use salsa::plumbing::{AsId, FromId}; use salsa::plumbing::{AsId, FromId};
use smallvec::SmallVec; use smallvec::SmallVec;
use crate::next_solver::GenericArg; use crate::next_solver::{
CallableIdWrapper, ClosureIdWrapper, CoroutineIdWrapper, GenericArg, TypeAliasIdWrapper,
};
use crate::{ use crate::{
db::HirDatabase, db::HirDatabase,
interner::InternedWrapperNoDebug, interner::InternedWrapperNoDebug,
@ -599,10 +601,7 @@ impl<'db> rustc_type_ir::inherent::Ty<DbInterner<'db>> for Ty<'db> {
Ty::new(interner, TyKind::Adt(adt_def, args)) Ty::new(interner, TyKind::Adt(adt_def, args))
} }
fn new_foreign( fn new_foreign(interner: DbInterner<'db>, def_id: TypeAliasIdWrapper) -> Self {
interner: DbInterner<'db>,
def_id: <DbInterner<'db> as rustc_type_ir::Interner>::DefId,
) -> Self {
Ty::new(interner, TyKind::Foreign(def_id)) Ty::new(interner, TyKind::Foreign(def_id))
} }
@ -617,7 +616,7 @@ impl<'db> rustc_type_ir::inherent::Ty<DbInterner<'db>> for Ty<'db> {
fn new_coroutine( fn new_coroutine(
interner: DbInterner<'db>, interner: DbInterner<'db>,
def_id: <DbInterner<'db> as rustc_type_ir::Interner>::DefId, def_id: CoroutineIdWrapper,
args: <DbInterner<'db> as rustc_type_ir::Interner>::GenericArgs, args: <DbInterner<'db> as rustc_type_ir::Interner>::GenericArgs,
) -> Self { ) -> Self {
Ty::new(interner, TyKind::Coroutine(def_id, args)) Ty::new(interner, TyKind::Coroutine(def_id, args))
@ -625,7 +624,7 @@ impl<'db> rustc_type_ir::inherent::Ty<DbInterner<'db>> for Ty<'db> {
fn new_coroutine_closure( fn new_coroutine_closure(
interner: DbInterner<'db>, interner: DbInterner<'db>,
def_id: <DbInterner<'db> as rustc_type_ir::Interner>::DefId, def_id: CoroutineIdWrapper,
args: <DbInterner<'db> as rustc_type_ir::Interner>::GenericArgs, args: <DbInterner<'db> as rustc_type_ir::Interner>::GenericArgs,
) -> Self { ) -> Self {
Ty::new(interner, TyKind::CoroutineClosure(def_id, args)) Ty::new(interner, TyKind::CoroutineClosure(def_id, args))
@ -633,7 +632,7 @@ impl<'db> rustc_type_ir::inherent::Ty<DbInterner<'db>> for Ty<'db> {
fn new_closure( fn new_closure(
interner: DbInterner<'db>, interner: DbInterner<'db>,
def_id: <DbInterner<'db> as rustc_type_ir::Interner>::DefId, def_id: ClosureIdWrapper,
args: <DbInterner<'db> as rustc_type_ir::Interner>::GenericArgs, args: <DbInterner<'db> as rustc_type_ir::Interner>::GenericArgs,
) -> Self { ) -> Self {
Ty::new(interner, TyKind::Closure(def_id, args)) Ty::new(interner, TyKind::Closure(def_id, args))
@ -641,7 +640,7 @@ impl<'db> rustc_type_ir::inherent::Ty<DbInterner<'db>> for Ty<'db> {
fn new_coroutine_witness( fn new_coroutine_witness(
interner: DbInterner<'db>, interner: DbInterner<'db>,
def_id: <DbInterner<'db> as rustc_type_ir::Interner>::DefId, def_id: CoroutineIdWrapper,
args: <DbInterner<'db> as rustc_type_ir::Interner>::GenericArgs, args: <DbInterner<'db> as rustc_type_ir::Interner>::GenericArgs,
) -> Self { ) -> Self {
Ty::new(interner, TyKind::CoroutineWitness(def_id, args)) Ty::new(interner, TyKind::CoroutineWitness(def_id, args))
@ -649,7 +648,7 @@ impl<'db> rustc_type_ir::inherent::Ty<DbInterner<'db>> for Ty<'db> {
fn new_coroutine_witness_for_coroutine( fn new_coroutine_witness_for_coroutine(
interner: DbInterner<'db>, interner: DbInterner<'db>,
def_id: <DbInterner<'db> as rustc_type_ir::Interner>::DefId, def_id: CoroutineIdWrapper,
coroutine_args: <DbInterner<'db> as rustc_type_ir::Interner>::GenericArgs, coroutine_args: <DbInterner<'db> as rustc_type_ir::Interner>::GenericArgs,
) -> Self { ) -> Self {
// HACK: Coroutine witness types are lifetime erased, so they // HACK: Coroutine witness types are lifetime erased, so they
@ -714,7 +713,7 @@ impl<'db> rustc_type_ir::inherent::Ty<DbInterner<'db>> for Ty<'db> {
fn new_fn_def( fn new_fn_def(
interner: DbInterner<'db>, interner: DbInterner<'db>,
def_id: <DbInterner<'db> as rustc_type_ir::Interner>::DefId, def_id: CallableIdWrapper,
args: <DbInterner<'db> as rustc_type_ir::Interner>::GenericArgs, args: <DbInterner<'db> as rustc_type_ir::Interner>::GenericArgs,
) -> Self { ) -> Self {
Ty::new(interner, TyKind::FnDef(def_id, args)) Ty::new(interner, TyKind::FnDef(def_id, args))