diff options
-rw-r--r-- | Cargo.lock | 13 | ||||
-rw-r--r-- | crates/ra_hir_ty/Cargo.toml | 6 | ||||
-rw-r--r-- | crates/ra_hir_ty/src/traits/chalk.rs | 39 |
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]] |
130 | name = "chalk-derive" | 130 | name = "chalk-derive" |
131 | version = "0.1.0" | 131 | version = "0.1.0" |
132 | source = "git+https://github.com/rust-lang/chalk.git?rev=2939913fb7bb94ac2a6721087dc086be11410702#2939913fb7bb94ac2a6721087dc086be11410702" | 132 | source = "git+https://github.com/rust-lang/chalk.git?rev=177d71340acc7a7204a33115fc63075d86452179#177d71340acc7a7204a33115fc63075d86452179" |
133 | dependencies = [ | 133 | dependencies = [ |
134 | "proc-macro2", | 134 | "proc-macro2", |
135 | "quote", | 135 | "quote", |
@@ -139,7 +139,7 @@ dependencies = [ | |||
139 | [[package]] | 139 | [[package]] |
140 | name = "chalk-engine" | 140 | name = "chalk-engine" |
141 | version = "0.9.0" | 141 | version = "0.9.0" |
142 | source = "git+https://github.com/rust-lang/chalk.git?rev=2939913fb7bb94ac2a6721087dc086be11410702#2939913fb7bb94ac2a6721087dc086be11410702" | 142 | source = "git+https://github.com/rust-lang/chalk.git?rev=177d71340acc7a7204a33115fc63075d86452179#177d71340acc7a7204a33115fc63075d86452179" |
143 | dependencies = [ | 143 | dependencies = [ |
144 | "chalk-macros", | 144 | "chalk-macros", |
145 | "rustc-hash", | 145 | "rustc-hash", |
@@ -148,18 +148,17 @@ dependencies = [ | |||
148 | [[package]] | 148 | [[package]] |
149 | name = "chalk-ir" | 149 | name = "chalk-ir" |
150 | version = "0.1.0" | 150 | version = "0.1.0" |
151 | source = "git+https://github.com/rust-lang/chalk.git?rev=2939913fb7bb94ac2a6721087dc086be11410702#2939913fb7bb94ac2a6721087dc086be11410702" | 151 | source = "git+https://github.com/rust-lang/chalk.git?rev=177d71340acc7a7204a33115fc63075d86452179#177d71340acc7a7204a33115fc63075d86452179" |
152 | dependencies = [ | 152 | dependencies = [ |
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]] |
160 | name = "chalk-macros" | 159 | name = "chalk-macros" |
161 | version = "0.1.1" | 160 | version = "0.1.1" |
162 | source = "git+https://github.com/rust-lang/chalk.git?rev=2939913fb7bb94ac2a6721087dc086be11410702#2939913fb7bb94ac2a6721087dc086be11410702" | 161 | source = "git+https://github.com/rust-lang/chalk.git?rev=177d71340acc7a7204a33115fc63075d86452179#177d71340acc7a7204a33115fc63075d86452179" |
163 | dependencies = [ | 162 | dependencies = [ |
164 | "lazy_static", | 163 | "lazy_static", |
165 | ] | 164 | ] |
@@ -167,7 +166,7 @@ dependencies = [ | |||
167 | [[package]] | 166 | [[package]] |
168 | name = "chalk-rust-ir" | 167 | name = "chalk-rust-ir" |
169 | version = "0.1.0" | 168 | version = "0.1.0" |
170 | source = "git+https://github.com/rust-lang/chalk.git?rev=2939913fb7bb94ac2a6721087dc086be11410702#2939913fb7bb94ac2a6721087dc086be11410702" | 169 | source = "git+https://github.com/rust-lang/chalk.git?rev=177d71340acc7a7204a33115fc63075d86452179#177d71340acc7a7204a33115fc63075d86452179" |
171 | dependencies = [ | 170 | dependencies = [ |
172 | "chalk-derive", | 171 | "chalk-derive", |
173 | "chalk-engine", | 172 | "chalk-engine", |
@@ -178,7 +177,7 @@ dependencies = [ | |||
178 | [[package]] | 177 | [[package]] |
179 | name = "chalk-solve" | 178 | name = "chalk-solve" |
180 | version = "0.1.0" | 179 | version = "0.1.0" |
181 | source = "git+https://github.com/rust-lang/chalk.git?rev=2939913fb7bb94ac2a6721087dc086be11410702#2939913fb7bb94ac2a6721087dc086be11410702" | 180 | source = "git+https://github.com/rust-lang/chalk.git?rev=177d71340acc7a7204a33115fc63075d86452179#177d71340acc7a7204a33115fc63075d86452179" |
182 | dependencies = [ | 181 | dependencies = [ |
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" } | |||
21 | ra_syntax = { path = "../ra_syntax" } | 21 | ra_syntax = { path = "../ra_syntax" } |
22 | test_utils = { path = "../test_utils" } | 22 | test_utils = { path = "../test_utils" } |
23 | 23 | ||
24 | chalk-solve = { git = "https://github.com/rust-lang/chalk.git", rev = "2939913fb7bb94ac2a6721087dc086be11410702" } | 24 | chalk-solve = { git = "https://github.com/rust-lang/chalk.git", rev = "177d71340acc7a7204a33115fc63075d86452179" } |
25 | chalk-rust-ir = { git = "https://github.com/rust-lang/chalk.git", rev = "2939913fb7bb94ac2a6721087dc086be11410702" } | 25 | chalk-rust-ir = { git = "https://github.com/rust-lang/chalk.git", rev = "177d71340acc7a7204a33115fc63075d86452179" } |
26 | chalk-ir = { git = "https://github.com/rust-lang/chalk.git", rev = "2939913fb7bb94ac2a6721087dc086be11410702" } | 26 | chalk-ir = { git = "https://github.com/rust-lang/chalk.git", rev = "177d71340acc7a7204a33115fc63075d86452179" } |
27 | 27 | ||
28 | lalrpop-intern = "0.15.1" | 28 | lalrpop-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)] |
21 | pub struct Interner {} | 21 | pub struct Interner; |
22 | 22 | ||
23 | impl chalk_ir::interner::Interner for Interner { | 23 | impl 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>; | |||
121 | pub type StructDatum = chalk_rust_ir::StructDatum<Interner>; | 122 | pub type StructDatum = chalk_rust_ir::StructDatum<Interner>; |
122 | pub type ImplId = chalk_ir::ImplId<Interner>; | 123 | pub type ImplId = chalk_ir::ImplId<Interner>; |
123 | pub type ImplDatum = chalk_rust_ir::ImplDatum<Interner>; | 124 | pub type ImplDatum = chalk_rust_ir::ImplDatum<Interner>; |
124 | pub type AssociatedTyValueId = chalk_rust_ir::AssociatedTyValueId; | 125 | pub type AssociatedTyValueId = chalk_rust_ir::AssociatedTyValueId<Interner>; |
125 | pub type AssociatedTyValue = chalk_rust_ir::AssociatedTyValue<Interner>; | 126 | pub type AssociatedTyValue = chalk_rust_ir::AssociatedTyValue<Interner>; |
126 | 127 | ||
127 | pub(super) trait ToChalk { | 128 | pub(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 | ||
616 | pub(crate) fn associated_ty_data_query( | 620 | pub(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 | ||
825 | fn id_from_chalk<T: InternKey>(chalk_id: chalk_ir::RawId) -> T { | ||
826 | T::from_intern_id(InternId::from(chalk_id.index)) | ||
827 | } | ||
828 | fn 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 | |||
832 | impl From<StructId> for crate::TypeCtorId { | 829 | impl 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 | ||
856 | impl From<chalk_rust_ir::AssociatedTyValueId> for crate::traits::AssocTyValueId { | 853 | impl 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 | ||
862 | impl From<crate::traits::AssocTyValueId> for chalk_rust_ir::AssociatedTyValueId { | 859 | impl 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 | } |