From 807a56bebfecf6f655c48c3490c296180045c44b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lauren=C8=9Biu=20Nicola?= Date: Mon, 2 Mar 2020 23:30:38 +0200 Subject: Update chalk for RawId removal --- crates/ra_hir_ty/src/traits/chalk.rs | 20 +++++++------------- 1 file changed, 7 insertions(+), 13 deletions(-) (limited to 'crates/ra_hir_ty/src') diff --git a/crates/ra_hir_ty/src/traits/chalk.rs b/crates/ra_hir_ty/src/traits/chalk.rs index 4001aa941..7a0f99dec 100644 --- a/crates/ra_hir_ty/src/traits/chalk.rs +++ b/crates/ra_hir_ty/src/traits/chalk.rs @@ -27,6 +27,7 @@ impl chalk_ir::interner::Interner for Interner { type InternedGoal = Arc>; type InternedGoals = Vec>; type InternedSubstitution = Vec>; + type Identifier = lalrpop_intern::InternedString; type DefId = InternId; // FIXME: implement these @@ -121,7 +122,7 @@ pub type StructId = chalk_ir::StructId; pub type StructDatum = chalk_rust_ir::StructDatum; pub type ImplId = chalk_ir::ImplId; pub type ImplDatum = chalk_rust_ir::ImplDatum; -pub type AssociatedTyValueId = chalk_rust_ir::AssociatedTyValueId; +pub type AssociatedTyValueId = chalk_rust_ir::AssociatedTyValueId; pub type AssociatedTyValue = chalk_rust_ir::AssociatedTyValue; pub(super) trait ToChalk { @@ -822,13 +823,6 @@ fn type_alias_associated_ty_value( Arc::new(value) } -fn id_from_chalk(chalk_id: chalk_ir::RawId) -> T { - T::from_intern_id(InternId::from(chalk_id.index)) -} -fn id_to_chalk(salsa_id: T) -> chalk_ir::RawId { - chalk_ir::RawId { index: salsa_id.as_intern_id().as_u32() } -} - impl From for crate::TypeCtorId { fn from(struct_id: StructId) -> Self { InternKey::from_intern_id(struct_id.0) @@ -853,14 +847,14 @@ impl From for ImplId { } } -impl From for crate::traits::AssocTyValueId { - fn from(id: chalk_rust_ir::AssociatedTyValueId) -> Self { - id_from_chalk(id.0) +impl From> for crate::traits::AssocTyValueId { + fn from(id: chalk_rust_ir::AssociatedTyValueId) -> Self { + Self::from_intern_id(id.0) } } -impl From for chalk_rust_ir::AssociatedTyValueId { +impl From for chalk_rust_ir::AssociatedTyValueId { fn from(assoc_ty_value_id: crate::traits::AssocTyValueId) -> Self { - chalk_rust_ir::AssociatedTyValueId(id_to_chalk(assoc_ty_value_id)) + chalk_rust_ir::AssociatedTyValueId(assoc_ty_value_id.as_intern_id()) } } -- cgit v1.2.3 From f60cf882a858e0d9f6df07f661021814d7872690 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lauren=C8=9Biu=20Nicola?= Date: Tue, 3 Mar 2020 00:01:16 +0200 Subject: Update chalk for Ty interners --- crates/ra_hir_ty/src/traits/chalk.rs | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) (limited to 'crates/ra_hir_ty/src') diff --git a/crates/ra_hir_ty/src/traits/chalk.rs b/crates/ra_hir_ty/src/traits/chalk.rs index 7a0f99dec..7f7fe93b7 100644 --- a/crates/ra_hir_ty/src/traits/chalk.rs +++ b/crates/ra_hir_ty/src/traits/chalk.rs @@ -18,7 +18,7 @@ use crate::{ }; #[derive(Debug, Copy, Clone, Hash, PartialOrd, Ord, PartialEq, Eq)] -pub struct Interner {} +pub struct Interner; impl chalk_ir::interner::Interner for Interner { type InternedType = Box>; @@ -59,7 +59,7 @@ impl chalk_ir::interner::Interner for Interner { None } - fn intern_ty(ty: chalk_ir::TyData) -> Box> { + fn intern_ty(&self, ty: chalk_ir::TyData) -> Box> { Box::new(ty) } @@ -145,12 +145,12 @@ impl ToChalk for Ty { Ty::Apply(apply_ty) => { let name = apply_ty.ctor.to_chalk(db); let substitution = apply_ty.parameters.to_chalk(db); - chalk_ir::ApplicationTy { name, substitution }.cast().intern() + chalk_ir::ApplicationTy { name, substitution }.cast().intern(&Interner) } Ty::Projection(proj_ty) => { let associated_ty_id = proj_ty.associated_ty.to_chalk(db); let substitution = proj_ty.parameters.to_chalk(db); - chalk_ir::AliasTy { associated_ty_id, substitution }.cast().intern() + chalk_ir::AliasTy { associated_ty_id, substitution }.cast().intern(&Interner) } Ty::Placeholder(id) => { let interned_id = db.intern_type_param_id(id); @@ -158,9 +158,9 @@ impl ToChalk for Ty { ui: UniverseIndex::ROOT, idx: interned_id.as_intern_id().as_usize(), } - .to_ty::() + .to_ty::(&Interner) } - Ty::Bound(idx) => chalk_ir::TyData::BoundVar(idx as usize).intern(), + Ty::Bound(idx) => chalk_ir::TyData::BoundVar(idx as usize).intern(&Interner), Ty::Infer(_infer_ty) => panic!("uncanonicalized infer ty"), Ty::Dyn(predicates) => { let where_clauses = predicates @@ -170,12 +170,12 @@ impl ToChalk for Ty { .map(|p| p.to_chalk(db)) .collect(); let bounded_ty = chalk_ir::DynTy { bounds: make_binders(where_clauses, 1) }; - chalk_ir::TyData::Dyn(bounded_ty).intern() + chalk_ir::TyData::Dyn(bounded_ty).intern(&Interner) } Ty::Opaque(_) | Ty::Unknown => { let substitution = chalk_ir::Substitution::empty(); let name = TypeName::Error; - chalk_ir::ApplicationTy { name, substitution }.cast().intern() + chalk_ir::ApplicationTy { name, substitution }.cast().intern(&Interner) } } } @@ -612,6 +612,9 @@ where _ => None, } } + fn interner(&self) -> &Interner { + &Interner + } } pub(crate) fn associated_ty_data_query( -- cgit v1.2.3