Use TypeCtorId as AdtId directly, and rename the type alias StructId -> AdtId
This commit is contained in:
parent
1d0e27254d
commit
27fe68ad5c
@ -89,7 +89,7 @@ fn impls_for_trait(
|
||||
fn trait_datum(&self, krate: CrateId, trait_id: chalk::TraitId) -> Arc<chalk::TraitDatum>;
|
||||
|
||||
#[salsa::invoke(chalk::struct_datum_query)]
|
||||
fn struct_datum(&self, krate: CrateId, struct_id: chalk::StructId) -> Arc<chalk::StructDatum>;
|
||||
fn struct_datum(&self, krate: CrateId, struct_id: chalk::AdtId) -> Arc<chalk::StructDatum>;
|
||||
|
||||
#[salsa::invoke(crate::traits::chalk::impl_datum_query)]
|
||||
fn impl_datum(&self, krate: CrateId, impl_id: chalk::ImplId) -> Arc<chalk::ImplDatum>;
|
||||
|
@ -155,7 +155,7 @@ pub enum TypeCtor {
|
||||
/// This exists just for Chalk, because Chalk just has a single `StructId` where
|
||||
/// we have different kinds of ADTs, primitive types and special type
|
||||
/// constructors like tuples and function pointers.
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Ord, PartialOrd)]
|
||||
pub struct TypeCtorId(salsa::InternId);
|
||||
impl_intern_key!(TypeCtorId);
|
||||
|
||||
|
@ -45,7 +45,7 @@ fn associated_ty_data(&self, id: AssocTypeId) -> Arc<AssociatedTyDatum> {
|
||||
fn trait_datum(&self, trait_id: TraitId) -> Arc<TraitDatum> {
|
||||
self.db.trait_datum(self.krate, trait_id)
|
||||
}
|
||||
fn adt_datum(&self, struct_id: StructId) -> Arc<StructDatum> {
|
||||
fn adt_datum(&self, struct_id: AdtId) -> Arc<StructDatum> {
|
||||
self.db.struct_datum(self.krate, struct_id)
|
||||
}
|
||||
fn impl_datum(&self, impl_id: ImplId) -> Arc<ImplDatum> {
|
||||
@ -94,7 +94,7 @@ fn impls_for_trait(
|
||||
debug!("impls_for_trait returned {} impls", result.len());
|
||||
result
|
||||
}
|
||||
fn impl_provided_for(&self, auto_trait_id: TraitId, struct_id: StructId) -> bool {
|
||||
fn impl_provided_for(&self, auto_trait_id: TraitId, struct_id: AdtId) -> bool {
|
||||
debug!("impl_provided_for {:?}, {:?}", auto_trait_id, struct_id);
|
||||
false // FIXME
|
||||
}
|
||||
@ -257,7 +257,7 @@ fn lang_attr_from_well_known_trait(attr: WellKnownTrait) -> &'static str {
|
||||
pub(crate) fn struct_datum_query(
|
||||
db: &dyn HirDatabase,
|
||||
krate: CrateId,
|
||||
struct_id: StructId,
|
||||
struct_id: AdtId,
|
||||
) -> Arc<StructDatum> {
|
||||
debug!("struct_datum {:?}", struct_id);
|
||||
let type_ctor: TypeCtor = from_chalk(db, TypeName::Adt(struct_id));
|
||||
@ -405,15 +405,15 @@ fn type_alias_associated_ty_value(
|
||||
Arc::new(value)
|
||||
}
|
||||
|
||||
impl From<StructId> for crate::TypeCtorId {
|
||||
fn from(struct_id: StructId) -> Self {
|
||||
InternKey::from_intern_id(struct_id.0)
|
||||
impl From<AdtId> for crate::TypeCtorId {
|
||||
fn from(struct_id: AdtId) -> Self {
|
||||
struct_id.0
|
||||
}
|
||||
}
|
||||
|
||||
impl From<crate::TypeCtorId> for StructId {
|
||||
impl From<crate::TypeCtorId> for AdtId {
|
||||
fn from(type_ctor_id: crate::TypeCtorId) -> Self {
|
||||
chalk_ir::AdtId(type_ctor_id.as_intern_id())
|
||||
chalk_ir::AdtId(type_ctor_id)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -14,7 +14,7 @@
|
||||
pub type AssociatedTyDatum = chalk_rust_ir::AssociatedTyDatum<Interner>;
|
||||
pub type TraitId = chalk_ir::TraitId<Interner>;
|
||||
pub type TraitDatum = chalk_rust_ir::TraitDatum<Interner>;
|
||||
pub type StructId = chalk_ir::AdtId<Interner>;
|
||||
pub type AdtId = chalk_ir::AdtId<Interner>;
|
||||
pub type StructDatum = chalk_rust_ir::AdtDatum<Interner>;
|
||||
pub type ImplId = chalk_ir::ImplId<Interner>;
|
||||
pub type ImplDatum = chalk_rust_ir::ImplDatum<Interner>;
|
||||
@ -36,10 +36,10 @@ impl chalk_ir::interner::Interner for Interner {
|
||||
type InternedVariableKinds = Vec<chalk_ir::VariableKind<Self>>;
|
||||
type InternedCanonicalVarKinds = Vec<chalk_ir::CanonicalVarKind<Self>>;
|
||||
type DefId = InternId;
|
||||
type InternedAdtId = InternId;
|
||||
type InternedAdtId = crate::TypeCtorId;
|
||||
type Identifier = TypeAliasId;
|
||||
|
||||
fn debug_adt_id(type_kind_id: StructId, fmt: &mut fmt::Formatter<'_>) -> Option<fmt::Result> {
|
||||
fn debug_adt_id(type_kind_id: AdtId, fmt: &mut fmt::Formatter<'_>) -> Option<fmt::Result> {
|
||||
tls::with_current_program(|prog| Some(prog?.debug_struct_id(type_kind_id, fmt)))
|
||||
}
|
||||
|
||||
|
@ -15,7 +15,7 @@
|
||||
impl DebugContext<'_> {
|
||||
pub fn debug_struct_id(
|
||||
&self,
|
||||
id: super::StructId,
|
||||
id: super::AdtId,
|
||||
f: &mut fmt::Formatter<'_>,
|
||||
) -> Result<(), fmt::Error> {
|
||||
let type_ctor: TypeCtor = from_chalk(self.0, TypeName::Adt(id));
|
||||
|
Loading…
Reference in New Issue
Block a user