mirror of
https://github.com/rust-lang/rust.git
synced 2025-01-05 20:34:52 +00:00
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 @@ pub trait HirDatabase: DefDatabase + Upcast<dyn DefDatabase> {
|
|||||||
fn trait_datum(&self, krate: CrateId, trait_id: chalk::TraitId) -> Arc<chalk::TraitDatum>;
|
fn trait_datum(&self, krate: CrateId, trait_id: chalk::TraitId) -> Arc<chalk::TraitDatum>;
|
||||||
|
|
||||||
#[salsa::invoke(chalk::struct_datum_query)]
|
#[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)]
|
#[salsa::invoke(crate::traits::chalk::impl_datum_query)]
|
||||||
fn impl_datum(&self, krate: CrateId, impl_id: chalk::ImplId) -> Arc<chalk::ImplDatum>;
|
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
|
/// This exists just for Chalk, because Chalk just has a single `StructId` where
|
||||||
/// we have different kinds of ADTs, primitive types and special type
|
/// we have different kinds of ADTs, primitive types and special type
|
||||||
/// constructors like tuples and function pointers.
|
/// 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);
|
pub struct TypeCtorId(salsa::InternId);
|
||||||
impl_intern_key!(TypeCtorId);
|
impl_intern_key!(TypeCtorId);
|
||||||
|
|
||||||
|
@ -45,7 +45,7 @@ impl<'a> chalk_solve::RustIrDatabase<Interner> for ChalkContext<'a> {
|
|||||||
fn trait_datum(&self, trait_id: TraitId) -> Arc<TraitDatum> {
|
fn trait_datum(&self, trait_id: TraitId) -> Arc<TraitDatum> {
|
||||||
self.db.trait_datum(self.krate, trait_id)
|
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)
|
self.db.struct_datum(self.krate, struct_id)
|
||||||
}
|
}
|
||||||
fn impl_datum(&self, impl_id: ImplId) -> Arc<ImplDatum> {
|
fn impl_datum(&self, impl_id: ImplId) -> Arc<ImplDatum> {
|
||||||
@ -94,7 +94,7 @@ impl<'a> chalk_solve::RustIrDatabase<Interner> for ChalkContext<'a> {
|
|||||||
debug!("impls_for_trait returned {} impls", result.len());
|
debug!("impls_for_trait returned {} impls", result.len());
|
||||||
result
|
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);
|
debug!("impl_provided_for {:?}, {:?}", auto_trait_id, struct_id);
|
||||||
false // FIXME
|
false // FIXME
|
||||||
}
|
}
|
||||||
@ -257,7 +257,7 @@ fn lang_attr_from_well_known_trait(attr: WellKnownTrait) -> &'static str {
|
|||||||
pub(crate) fn struct_datum_query(
|
pub(crate) fn struct_datum_query(
|
||||||
db: &dyn HirDatabase,
|
db: &dyn HirDatabase,
|
||||||
krate: CrateId,
|
krate: CrateId,
|
||||||
struct_id: StructId,
|
struct_id: AdtId,
|
||||||
) -> Arc<StructDatum> {
|
) -> Arc<StructDatum> {
|
||||||
debug!("struct_datum {:?}", struct_id);
|
debug!("struct_datum {:?}", struct_id);
|
||||||
let type_ctor: TypeCtor = from_chalk(db, TypeName::Adt(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)
|
Arc::new(value)
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<StructId> for crate::TypeCtorId {
|
impl From<AdtId> for crate::TypeCtorId {
|
||||||
fn from(struct_id: StructId) -> Self {
|
fn from(struct_id: AdtId) -> Self {
|
||||||
InternKey::from_intern_id(struct_id.0)
|
struct_id.0
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<crate::TypeCtorId> for StructId {
|
impl From<crate::TypeCtorId> for AdtId {
|
||||||
fn from(type_ctor_id: crate::TypeCtorId) -> Self {
|
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 AssocTypeId = chalk_ir::AssocTypeId<Interner>;
|
|||||||
pub type AssociatedTyDatum = chalk_rust_ir::AssociatedTyDatum<Interner>;
|
pub type AssociatedTyDatum = chalk_rust_ir::AssociatedTyDatum<Interner>;
|
||||||
pub type TraitId = chalk_ir::TraitId<Interner>;
|
pub type TraitId = chalk_ir::TraitId<Interner>;
|
||||||
pub type TraitDatum = chalk_rust_ir::TraitDatum<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 StructDatum = chalk_rust_ir::AdtDatum<Interner>;
|
||||||
pub type ImplId = chalk_ir::ImplId<Interner>;
|
pub type ImplId = chalk_ir::ImplId<Interner>;
|
||||||
pub type ImplDatum = chalk_rust_ir::ImplDatum<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 InternedVariableKinds = Vec<chalk_ir::VariableKind<Self>>;
|
||||||
type InternedCanonicalVarKinds = Vec<chalk_ir::CanonicalVarKind<Self>>;
|
type InternedCanonicalVarKinds = Vec<chalk_ir::CanonicalVarKind<Self>>;
|
||||||
type DefId = InternId;
|
type DefId = InternId;
|
||||||
type InternedAdtId = InternId;
|
type InternedAdtId = crate::TypeCtorId;
|
||||||
type Identifier = TypeAliasId;
|
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)))
|
tls::with_current_program(|prog| Some(prog?.debug_struct_id(type_kind_id, fmt)))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -15,7 +15,7 @@ pub struct DebugContext<'a>(&'a (dyn HirDatabase + 'a));
|
|||||||
impl DebugContext<'_> {
|
impl DebugContext<'_> {
|
||||||
pub fn debug_struct_id(
|
pub fn debug_struct_id(
|
||||||
&self,
|
&self,
|
||||||
id: super::StructId,
|
id: super::AdtId,
|
||||||
f: &mut fmt::Formatter<'_>,
|
f: &mut fmt::Formatter<'_>,
|
||||||
) -> Result<(), fmt::Error> {
|
) -> Result<(), fmt::Error> {
|
||||||
let type_ctor: TypeCtor = from_chalk(self.0, TypeName::Adt(id));
|
let type_ctor: TypeCtor = from_chalk(self.0, TypeName::Adt(id));
|
||||||
|
Loading…
Reference in New Issue
Block a user