Skip to content

Commit 27fe68a

Browse files
committed
Use TypeCtorId as AdtId directly, and rename the type alias StructId -> AdtId
1 parent 1d0e272 commit 27fe68a

File tree

5 files changed

+14
-14
lines changed

5 files changed

+14
-14
lines changed

crates/ra_hir_ty/src/db.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ pub trait HirDatabase: DefDatabase + Upcast<dyn DefDatabase> {
8989
fn trait_datum(&self, krate: CrateId, trait_id: chalk::TraitId) -> Arc<chalk::TraitDatum>;
9090

9191
#[salsa::invoke(chalk::struct_datum_query)]
92-
fn struct_datum(&self, krate: CrateId, struct_id: chalk::StructId) -> Arc<chalk::StructDatum>;
92+
fn struct_datum(&self, krate: CrateId, struct_id: chalk::AdtId) -> Arc<chalk::StructDatum>;
9393

9494
#[salsa::invoke(crate::traits::chalk::impl_datum_query)]
9595
fn impl_datum(&self, krate: CrateId, impl_id: chalk::ImplId) -> Arc<chalk::ImplDatum>;

crates/ra_hir_ty/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ pub enum TypeCtor {
155155
/// This exists just for Chalk, because Chalk just has a single `StructId` where
156156
/// we have different kinds of ADTs, primitive types and special type
157157
/// constructors like tuples and function pointers.
158-
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
158+
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Ord, PartialOrd)]
159159
pub struct TypeCtorId(salsa::InternId);
160160
impl_intern_key!(TypeCtorId);
161161

crates/ra_hir_ty/src/traits/chalk.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ impl<'a> chalk_solve::RustIrDatabase<Interner> for ChalkContext<'a> {
4545
fn trait_datum(&self, trait_id: TraitId) -> Arc<TraitDatum> {
4646
self.db.trait_datum(self.krate, trait_id)
4747
}
48-
fn adt_datum(&self, struct_id: StructId) -> Arc<StructDatum> {
48+
fn adt_datum(&self, struct_id: AdtId) -> Arc<StructDatum> {
4949
self.db.struct_datum(self.krate, struct_id)
5050
}
5151
fn impl_datum(&self, impl_id: ImplId) -> Arc<ImplDatum> {
@@ -94,7 +94,7 @@ impl<'a> chalk_solve::RustIrDatabase<Interner> for ChalkContext<'a> {
9494
debug!("impls_for_trait returned {} impls", result.len());
9595
result
9696
}
97-
fn impl_provided_for(&self, auto_trait_id: TraitId, struct_id: StructId) -> bool {
97+
fn impl_provided_for(&self, auto_trait_id: TraitId, struct_id: AdtId) -> bool {
9898
debug!("impl_provided_for {:?}, {:?}", auto_trait_id, struct_id);
9999
false // FIXME
100100
}
@@ -257,7 +257,7 @@ fn lang_attr_from_well_known_trait(attr: WellKnownTrait) -> &'static str {
257257
pub(crate) fn struct_datum_query(
258258
db: &dyn HirDatabase,
259259
krate: CrateId,
260-
struct_id: StructId,
260+
struct_id: AdtId,
261261
) -> Arc<StructDatum> {
262262
debug!("struct_datum {:?}", struct_id);
263263
let type_ctor: TypeCtor = from_chalk(db, TypeName::Adt(struct_id));
@@ -405,15 +405,15 @@ fn type_alias_associated_ty_value(
405405
Arc::new(value)
406406
}
407407

408-
impl From<StructId> for crate::TypeCtorId {
409-
fn from(struct_id: StructId) -> Self {
410-
InternKey::from_intern_id(struct_id.0)
408+
impl From<AdtId> for crate::TypeCtorId {
409+
fn from(struct_id: AdtId) -> Self {
410+
struct_id.0
411411
}
412412
}
413413

414-
impl From<crate::TypeCtorId> for StructId {
414+
impl From<crate::TypeCtorId> for AdtId {
415415
fn from(type_ctor_id: crate::TypeCtorId) -> Self {
416-
chalk_ir::AdtId(type_ctor_id.as_intern_id())
416+
chalk_ir::AdtId(type_ctor_id)
417417
}
418418
}
419419

crates/ra_hir_ty/src/traits/chalk/interner.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ pub type AssocTypeId = chalk_ir::AssocTypeId<Interner>;
1414
pub type AssociatedTyDatum = chalk_rust_ir::AssociatedTyDatum<Interner>;
1515
pub type TraitId = chalk_ir::TraitId<Interner>;
1616
pub type TraitDatum = chalk_rust_ir::TraitDatum<Interner>;
17-
pub type StructId = chalk_ir::AdtId<Interner>;
17+
pub type AdtId = chalk_ir::AdtId<Interner>;
1818
pub type StructDatum = chalk_rust_ir::AdtDatum<Interner>;
1919
pub type ImplId = chalk_ir::ImplId<Interner>;
2020
pub type ImplDatum = chalk_rust_ir::ImplDatum<Interner>;
@@ -36,10 +36,10 @@ impl chalk_ir::interner::Interner for Interner {
3636
type InternedVariableKinds = Vec<chalk_ir::VariableKind<Self>>;
3737
type InternedCanonicalVarKinds = Vec<chalk_ir::CanonicalVarKind<Self>>;
3838
type DefId = InternId;
39-
type InternedAdtId = InternId;
39+
type InternedAdtId = crate::TypeCtorId;
4040
type Identifier = TypeAliasId;
4141

42-
fn debug_adt_id(type_kind_id: StructId, fmt: &mut fmt::Formatter<'_>) -> Option<fmt::Result> {
42+
fn debug_adt_id(type_kind_id: AdtId, fmt: &mut fmt::Formatter<'_>) -> Option<fmt::Result> {
4343
tls::with_current_program(|prog| Some(prog?.debug_struct_id(type_kind_id, fmt)))
4444
}
4545

crates/ra_hir_ty/src/traits/chalk/tls.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ pub struct DebugContext<'a>(&'a (dyn HirDatabase + 'a));
1515
impl DebugContext<'_> {
1616
pub fn debug_struct_id(
1717
&self,
18-
id: super::StructId,
18+
id: super::AdtId,
1919
f: &mut fmt::Formatter<'_>,
2020
) -> Result<(), fmt::Error> {
2121
let type_ctor: TypeCtor = from_chalk(self.0, TypeName::Adt(id));

0 commit comments

Comments
 (0)