aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Cargo.lock13
-rw-r--r--crates/ra_hir_ty/Cargo.toml6
-rw-r--r--crates/ra_hir_ty/src/traits/chalk.rs39
3 files changed, 27 insertions, 31 deletions
diff --git a/Cargo.lock b/Cargo.lock
index 97034509f..cab28ad49 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -129,7 +129,7 @@ checksum = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822"
129[[package]] 129[[package]]
130name = "chalk-derive" 130name = "chalk-derive"
131version = "0.1.0" 131version = "0.1.0"
132source = "git+https://github.com/rust-lang/chalk.git?rev=2939913fb7bb94ac2a6721087dc086be11410702#2939913fb7bb94ac2a6721087dc086be11410702" 132source = "git+https://github.com/rust-lang/chalk.git?rev=177d71340acc7a7204a33115fc63075d86452179#177d71340acc7a7204a33115fc63075d86452179"
133dependencies = [ 133dependencies = [
134 "proc-macro2", 134 "proc-macro2",
135 "quote", 135 "quote",
@@ -139,7 +139,7 @@ dependencies = [
139[[package]] 139[[package]]
140name = "chalk-engine" 140name = "chalk-engine"
141version = "0.9.0" 141version = "0.9.0"
142source = "git+https://github.com/rust-lang/chalk.git?rev=2939913fb7bb94ac2a6721087dc086be11410702#2939913fb7bb94ac2a6721087dc086be11410702" 142source = "git+https://github.com/rust-lang/chalk.git?rev=177d71340acc7a7204a33115fc63075d86452179#177d71340acc7a7204a33115fc63075d86452179"
143dependencies = [ 143dependencies = [
144 "chalk-macros", 144 "chalk-macros",
145 "rustc-hash", 145 "rustc-hash",
@@ -148,18 +148,17 @@ dependencies = [
148[[package]] 148[[package]]
149name = "chalk-ir" 149name = "chalk-ir"
150version = "0.1.0" 150version = "0.1.0"
151source = "git+https://github.com/rust-lang/chalk.git?rev=2939913fb7bb94ac2a6721087dc086be11410702#2939913fb7bb94ac2a6721087dc086be11410702" 151source = "git+https://github.com/rust-lang/chalk.git?rev=177d71340acc7a7204a33115fc63075d86452179#177d71340acc7a7204a33115fc63075d86452179"
152dependencies = [ 152dependencies = [
153 "chalk-derive", 153 "chalk-derive",
154 "chalk-engine", 154 "chalk-engine",
155 "chalk-macros", 155 "chalk-macros",
156 "lalrpop-intern",
157] 156]
158 157
159[[package]] 158[[package]]
160name = "chalk-macros" 159name = "chalk-macros"
161version = "0.1.1" 160version = "0.1.1"
162source = "git+https://github.com/rust-lang/chalk.git?rev=2939913fb7bb94ac2a6721087dc086be11410702#2939913fb7bb94ac2a6721087dc086be11410702" 161source = "git+https://github.com/rust-lang/chalk.git?rev=177d71340acc7a7204a33115fc63075d86452179#177d71340acc7a7204a33115fc63075d86452179"
163dependencies = [ 162dependencies = [
164 "lazy_static", 163 "lazy_static",
165] 164]
@@ -167,7 +166,7 @@ dependencies = [
167[[package]] 166[[package]]
168name = "chalk-rust-ir" 167name = "chalk-rust-ir"
169version = "0.1.0" 168version = "0.1.0"
170source = "git+https://github.com/rust-lang/chalk.git?rev=2939913fb7bb94ac2a6721087dc086be11410702#2939913fb7bb94ac2a6721087dc086be11410702" 169source = "git+https://github.com/rust-lang/chalk.git?rev=177d71340acc7a7204a33115fc63075d86452179#177d71340acc7a7204a33115fc63075d86452179"
171dependencies = [ 170dependencies = [
172 "chalk-derive", 171 "chalk-derive",
173 "chalk-engine", 172 "chalk-engine",
@@ -178,7 +177,7 @@ dependencies = [
178[[package]] 177[[package]]
179name = "chalk-solve" 178name = "chalk-solve"
180version = "0.1.0" 179version = "0.1.0"
181source = "git+https://github.com/rust-lang/chalk.git?rev=2939913fb7bb94ac2a6721087dc086be11410702#2939913fb7bb94ac2a6721087dc086be11410702" 180source = "git+https://github.com/rust-lang/chalk.git?rev=177d71340acc7a7204a33115fc63075d86452179#177d71340acc7a7204a33115fc63075d86452179"
182dependencies = [ 181dependencies = [
183 "chalk-derive", 182 "chalk-derive",
184 "chalk-engine", 183 "chalk-engine",
diff --git a/crates/ra_hir_ty/Cargo.toml b/crates/ra_hir_ty/Cargo.toml
index 99e2fe1bf..202eca507 100644
--- a/crates/ra_hir_ty/Cargo.toml
+++ b/crates/ra_hir_ty/Cargo.toml
@@ -21,9 +21,9 @@ ra_prof = { path = "../ra_prof" }
21ra_syntax = { path = "../ra_syntax" } 21ra_syntax = { path = "../ra_syntax" }
22test_utils = { path = "../test_utils" } 22test_utils = { path = "../test_utils" }
23 23
24chalk-solve = { git = "https://github.com/rust-lang/chalk.git", rev = "2939913fb7bb94ac2a6721087dc086be11410702" } 24chalk-solve = { git = "https://github.com/rust-lang/chalk.git", rev = "177d71340acc7a7204a33115fc63075d86452179" }
25chalk-rust-ir = { git = "https://github.com/rust-lang/chalk.git", rev = "2939913fb7bb94ac2a6721087dc086be11410702" } 25chalk-rust-ir = { git = "https://github.com/rust-lang/chalk.git", rev = "177d71340acc7a7204a33115fc63075d86452179" }
26chalk-ir = { git = "https://github.com/rust-lang/chalk.git", rev = "2939913fb7bb94ac2a6721087dc086be11410702" } 26chalk-ir = { git = "https://github.com/rust-lang/chalk.git", rev = "177d71340acc7a7204a33115fc63075d86452179" }
27 27
28lalrpop-intern = "0.15.1" 28lalrpop-intern = "0.15.1"
29 29
diff --git a/crates/ra_hir_ty/src/traits/chalk.rs b/crates/ra_hir_ty/src/traits/chalk.rs
index 4001aa941..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::{
18}; 18};
19 19
20#[derive(Debug, Copy, Clone, Hash, PartialOrd, Ord, PartialEq, Eq)] 20#[derive(Debug, Copy, Clone, Hash, PartialOrd, Ord, PartialEq, Eq)]
21pub struct Interner {} 21pub struct Interner;
22 22
23impl chalk_ir::interner::Interner for Interner { 23impl chalk_ir::interner::Interner for Interner {
24 type InternedType = Box<chalk_ir::TyData<Self>>; 24 type InternedType = Box<chalk_ir::TyData<Self>>;
@@ -27,6 +27,7 @@ impl chalk_ir::interner::Interner for Interner {
27 type InternedGoal = Arc<GoalData<Self>>; 27 type InternedGoal = Arc<GoalData<Self>>;
28 type InternedGoals = Vec<Goal<Self>>; 28 type InternedGoals = Vec<Goal<Self>>;
29 type InternedSubstitution = Vec<Parameter<Self>>; 29 type InternedSubstitution = Vec<Parameter<Self>>;
30 type Identifier = lalrpop_intern::InternedString;
30 type DefId = InternId; 31 type DefId = InternId;
31 32
32 // FIXME: implement these 33 // FIXME: implement these
@@ -58,7 +59,7 @@ impl chalk_ir::interner::Interner for Interner {
58 None 59 None
59 } 60 }
60 61
61 fn intern_ty(ty: chalk_ir::TyData<Self>) -> Box<chalk_ir::TyData<Self>> { 62 fn intern_ty(&self, ty: chalk_ir::TyData<Self>) -> Box<chalk_ir::TyData<Self>> {
62 Box::new(ty) 63 Box::new(ty)
63 } 64 }
64 65
@@ -121,7 +122,7 @@ pub type StructId = chalk_ir::StructId<Interner>;
121pub type StructDatum = chalk_rust_ir::StructDatum<Interner>; 122pub type StructDatum = chalk_rust_ir::StructDatum<Interner>;
122pub type ImplId = chalk_ir::ImplId<Interner>; 123pub type ImplId = chalk_ir::ImplId<Interner>;
123pub type ImplDatum = chalk_rust_ir::ImplDatum<Interner>; 124pub type ImplDatum = chalk_rust_ir::ImplDatum<Interner>;
124pub type AssociatedTyValueId = chalk_rust_ir::AssociatedTyValueId; 125pub type AssociatedTyValueId = chalk_rust_ir::AssociatedTyValueId<Interner>;
125pub type AssociatedTyValue = chalk_rust_ir::AssociatedTyValue<Interner>; 126pub type AssociatedTyValue = chalk_rust_ir::AssociatedTyValue<Interner>;
126 127
127pub(super) trait ToChalk { 128pub(super) trait ToChalk {
@@ -144,12 +145,12 @@ impl ToChalk for Ty {
144 Ty::Apply(apply_ty) => { 145 Ty::Apply(apply_ty) => {
145 let name = apply_ty.ctor.to_chalk(db); 146 let name = apply_ty.ctor.to_chalk(db);
146 let substitution = apply_ty.parameters.to_chalk(db); 147 let substitution = apply_ty.parameters.to_chalk(db);
147 chalk_ir::ApplicationTy { name, substitution }.cast().intern() 148 chalk_ir::ApplicationTy { name, substitution }.cast().intern(&Interner)
148 } 149 }
149 Ty::Projection(proj_ty) => { 150 Ty::Projection(proj_ty) => {
150 let associated_ty_id = proj_ty.associated_ty.to_chalk(db); 151 let associated_ty_id = proj_ty.associated_ty.to_chalk(db);
151 let substitution = proj_ty.parameters.to_chalk(db); 152 let substitution = proj_ty.parameters.to_chalk(db);
152 chalk_ir::AliasTy { associated_ty_id, substitution }.cast().intern() 153 chalk_ir::AliasTy { associated_ty_id, substitution }.cast().intern(&Interner)
153 } 154 }
154 Ty::Placeholder(id) => { 155 Ty::Placeholder(id) => {
155 let interned_id = db.intern_type_param_id(id); 156 let interned_id = db.intern_type_param_id(id);
@@ -157,9 +158,9 @@ impl ToChalk for Ty {
157 ui: UniverseIndex::ROOT, 158 ui: UniverseIndex::ROOT,
158 idx: interned_id.as_intern_id().as_usize(), 159 idx: interned_id.as_intern_id().as_usize(),
159 } 160 }
160 .to_ty::<Interner>() 161 .to_ty::<Interner>(&Interner)
161 } 162 }
162 Ty::Bound(idx) => chalk_ir::TyData::BoundVar(idx as usize).intern(), 163 Ty::Bound(idx) => chalk_ir::TyData::BoundVar(idx as usize).intern(&Interner),
163 Ty::Infer(_infer_ty) => panic!("uncanonicalized infer ty"), 164 Ty::Infer(_infer_ty) => panic!("uncanonicalized infer ty"),
164 Ty::Dyn(predicates) => { 165 Ty::Dyn(predicates) => {
165 let where_clauses = predicates 166 let where_clauses = predicates
@@ -169,12 +170,12 @@ impl ToChalk for Ty {
169 .map(|p| p.to_chalk(db)) 170 .map(|p| p.to_chalk(db))
170 .collect(); 171 .collect();
171 let bounded_ty = chalk_ir::DynTy { bounds: make_binders(where_clauses, 1) }; 172 let bounded_ty = chalk_ir::DynTy { bounds: make_binders(where_clauses, 1) };
172 chalk_ir::TyData::Dyn(bounded_ty).intern() 173 chalk_ir::TyData::Dyn(bounded_ty).intern(&Interner)
173 } 174 }
174 Ty::Opaque(_) | Ty::Unknown => { 175 Ty::Opaque(_) | Ty::Unknown => {
175 let substitution = chalk_ir::Substitution::empty(); 176 let substitution = chalk_ir::Substitution::empty();
176 let name = TypeName::Error; 177 let name = TypeName::Error;
177 chalk_ir::ApplicationTy { name, substitution }.cast().intern() 178 chalk_ir::ApplicationTy { name, substitution }.cast().intern(&Interner)
178 } 179 }
179 } 180 }
180 } 181 }
@@ -611,6 +612,9 @@ where
611 _ => None, 612 _ => None,
612 } 613 }
613 } 614 }
615 fn interner(&self) -> &Interner {
616 &Interner
617 }
614} 618}
615 619
616pub(crate) fn associated_ty_data_query( 620pub(crate) fn associated_ty_data_query(
@@ -822,13 +826,6 @@ fn type_alias_associated_ty_value(
822 Arc::new(value) 826 Arc::new(value)
823} 827}
824 828
825fn id_from_chalk<T: InternKey>(chalk_id: chalk_ir::RawId) -> T {
826 T::from_intern_id(InternId::from(chalk_id.index))
827}
828fn id_to_chalk<T: InternKey>(salsa_id: T) -> chalk_ir::RawId {
829 chalk_ir::RawId { index: salsa_id.as_intern_id().as_u32() }
830}
831
832impl From<StructId> for crate::TypeCtorId { 829impl From<StructId> for crate::TypeCtorId {
833 fn from(struct_id: StructId) -> Self { 830 fn from(struct_id: StructId) -> Self {
834 InternKey::from_intern_id(struct_id.0) 831 InternKey::from_intern_id(struct_id.0)
@@ -853,14 +850,14 @@ impl From<crate::traits::GlobalImplId> for ImplId {
853 } 850 }
854} 851}
855 852
856impl From<chalk_rust_ir::AssociatedTyValueId> for crate::traits::AssocTyValueId { 853impl From<chalk_rust_ir::AssociatedTyValueId<Interner>> for crate::traits::AssocTyValueId {
857 fn from(id: chalk_rust_ir::AssociatedTyValueId) -> Self { 854 fn from(id: chalk_rust_ir::AssociatedTyValueId<Interner>) -> Self {
858 id_from_chalk(id.0) 855 Self::from_intern_id(id.0)
859 } 856 }
860} 857}
861 858
862impl From<crate::traits::AssocTyValueId> for chalk_rust_ir::AssociatedTyValueId { 859impl From<crate::traits::AssocTyValueId> for chalk_rust_ir::AssociatedTyValueId<Interner> {
863 fn from(assoc_ty_value_id: crate::traits::AssocTyValueId) -> Self { 860 fn from(assoc_ty_value_id: crate::traits::AssocTyValueId) -> Self {
864 chalk_rust_ir::AssociatedTyValueId(id_to_chalk(assoc_ty_value_id)) 861 chalk_rust_ir::AssociatedTyValueId(assoc_ty_value_id.as_intern_id())
865 } 862 }
866} 863}