diff options
-rw-r--r-- | Cargo.lock | 41 | ||||
-rw-r--r-- | crates/ra_hir_ty/Cargo.toml | 6 | ||||
-rw-r--r-- | crates/ra_hir_ty/src/traits/chalk.rs | 119 | ||||
-rw-r--r-- | crates/ra_hir_ty/src/traits/chalk/tls.rs | 8 |
4 files changed, 94 insertions, 80 deletions
diff --git a/Cargo.lock b/Cargo.lock index 5ce35c5b1..007f05b4d 100644 --- a/Cargo.lock +++ b/Cargo.lock | |||
@@ -114,7 +114,7 @@ checksum = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822" | |||
114 | [[package]] | 114 | [[package]] |
115 | name = "chalk-derive" | 115 | name = "chalk-derive" |
116 | version = "0.10.1-dev" | 116 | version = "0.10.1-dev" |
117 | source = "git+https://github.com/rust-lang/chalk.git?rev=3e9c2503ae9c5277c2acb74624dc267876dd89b3#3e9c2503ae9c5277c2acb74624dc267876dd89b3" | 117 | source = "git+https://github.com/rust-lang/chalk.git?rev=eaab84b394007d1bed15f5470409a6ea02900a96#eaab84b394007d1bed15f5470409a6ea02900a96" |
118 | dependencies = [ | 118 | dependencies = [ |
119 | "proc-macro2", | 119 | "proc-macro2", |
120 | "quote", | 120 | "quote", |
@@ -125,7 +125,7 @@ dependencies = [ | |||
125 | [[package]] | 125 | [[package]] |
126 | name = "chalk-engine" | 126 | name = "chalk-engine" |
127 | version = "0.10.1-dev" | 127 | version = "0.10.1-dev" |
128 | source = "git+https://github.com/rust-lang/chalk.git?rev=3e9c2503ae9c5277c2acb74624dc267876dd89b3#3e9c2503ae9c5277c2acb74624dc267876dd89b3" | 128 | source = "git+https://github.com/rust-lang/chalk.git?rev=eaab84b394007d1bed15f5470409a6ea02900a96#eaab84b394007d1bed15f5470409a6ea02900a96" |
129 | dependencies = [ | 129 | dependencies = [ |
130 | "chalk-macros", | 130 | "chalk-macros", |
131 | "rustc-hash", | 131 | "rustc-hash", |
@@ -134,7 +134,7 @@ dependencies = [ | |||
134 | [[package]] | 134 | [[package]] |
135 | name = "chalk-ir" | 135 | name = "chalk-ir" |
136 | version = "0.10.1-dev" | 136 | version = "0.10.1-dev" |
137 | source = "git+https://github.com/rust-lang/chalk.git?rev=3e9c2503ae9c5277c2acb74624dc267876dd89b3#3e9c2503ae9c5277c2acb74624dc267876dd89b3" | 137 | source = "git+https://github.com/rust-lang/chalk.git?rev=eaab84b394007d1bed15f5470409a6ea02900a96#eaab84b394007d1bed15f5470409a6ea02900a96" |
138 | dependencies = [ | 138 | dependencies = [ |
139 | "chalk-derive", | 139 | "chalk-derive", |
140 | "chalk-engine", | 140 | "chalk-engine", |
@@ -144,7 +144,7 @@ dependencies = [ | |||
144 | [[package]] | 144 | [[package]] |
145 | name = "chalk-macros" | 145 | name = "chalk-macros" |
146 | version = "0.10.1-dev" | 146 | version = "0.10.1-dev" |
147 | source = "git+https://github.com/rust-lang/chalk.git?rev=3e9c2503ae9c5277c2acb74624dc267876dd89b3#3e9c2503ae9c5277c2acb74624dc267876dd89b3" | 147 | source = "git+https://github.com/rust-lang/chalk.git?rev=eaab84b394007d1bed15f5470409a6ea02900a96#eaab84b394007d1bed15f5470409a6ea02900a96" |
148 | dependencies = [ | 148 | dependencies = [ |
149 | "lazy_static", | 149 | "lazy_static", |
150 | ] | 150 | ] |
@@ -152,7 +152,7 @@ dependencies = [ | |||
152 | [[package]] | 152 | [[package]] |
153 | name = "chalk-rust-ir" | 153 | name = "chalk-rust-ir" |
154 | version = "0.10.1-dev" | 154 | version = "0.10.1-dev" |
155 | source = "git+https://github.com/rust-lang/chalk.git?rev=3e9c2503ae9c5277c2acb74624dc267876dd89b3#3e9c2503ae9c5277c2acb74624dc267876dd89b3" | 155 | source = "git+https://github.com/rust-lang/chalk.git?rev=eaab84b394007d1bed15f5470409a6ea02900a96#eaab84b394007d1bed15f5470409a6ea02900a96" |
156 | dependencies = [ | 156 | dependencies = [ |
157 | "chalk-derive", | 157 | "chalk-derive", |
158 | "chalk-engine", | 158 | "chalk-engine", |
@@ -163,14 +163,14 @@ dependencies = [ | |||
163 | [[package]] | 163 | [[package]] |
164 | name = "chalk-solve" | 164 | name = "chalk-solve" |
165 | version = "0.10.1-dev" | 165 | version = "0.10.1-dev" |
166 | source = "git+https://github.com/rust-lang/chalk.git?rev=3e9c2503ae9c5277c2acb74624dc267876dd89b3#3e9c2503ae9c5277c2acb74624dc267876dd89b3" | 166 | source = "git+https://github.com/rust-lang/chalk.git?rev=eaab84b394007d1bed15f5470409a6ea02900a96#eaab84b394007d1bed15f5470409a6ea02900a96" |
167 | dependencies = [ | 167 | dependencies = [ |
168 | "chalk-derive", | 168 | "chalk-derive", |
169 | "chalk-engine", | 169 | "chalk-engine", |
170 | "chalk-ir", | 170 | "chalk-ir", |
171 | "chalk-macros", | 171 | "chalk-macros", |
172 | "chalk-rust-ir", | 172 | "chalk-rust-ir", |
173 | "ena 0.13.1", | 173 | "ena", |
174 | "itertools", | 174 | "itertools", |
175 | "petgraph", | 175 | "petgraph", |
176 | "rustc-hash", | 176 | "rustc-hash", |
@@ -309,15 +309,6 @@ checksum = "bb1f6b1ce1c140482ea30ddd3335fc0024ac7ee112895426e0a629a6c20adfe3" | |||
309 | 309 | ||
310 | [[package]] | 310 | [[package]] |
311 | name = "ena" | 311 | name = "ena" |
312 | version = "0.13.1" | ||
313 | source = "registry+https://github.com/rust-lang/crates.io-index" | ||
314 | checksum = "8944dc8fa28ce4a38f778bd46bf7d923fe73eed5a439398507246c8e017e6f36" | ||
315 | dependencies = [ | ||
316 | "log", | ||
317 | ] | ||
318 | |||
319 | [[package]] | ||
320 | name = "ena" | ||
321 | version = "0.14.0" | 312 | version = "0.14.0" |
322 | source = "registry+https://github.com/rust-lang/crates.io-index" | 313 | source = "registry+https://github.com/rust-lang/crates.io-index" |
323 | checksum = "d7402b94a93c24e742487327a7cd839dc9d36fec9de9fb25b09f2dae459f36c3" | 314 | checksum = "d7402b94a93c24e742487327a7cd839dc9d36fec9de9fb25b09f2dae459f36c3" |
@@ -354,9 +345,9 @@ dependencies = [ | |||
354 | 345 | ||
355 | [[package]] | 346 | [[package]] |
356 | name = "fixedbitset" | 347 | name = "fixedbitset" |
357 | version = "0.1.9" | 348 | version = "0.2.0" |
358 | source = "registry+https://github.com/rust-lang/crates.io-index" | 349 | source = "registry+https://github.com/rust-lang/crates.io-index" |
359 | checksum = "86d4de0081402f5e88cdac65c8dcdcc73118c1a7a465e2a05f0da05843a8ea33" | 350 | checksum = "37ab347416e802de484e4d03c7316c48f1ecb56574dfd4a46a80f173ce1de04d" |
360 | 351 | ||
361 | [[package]] | 352 | [[package]] |
362 | name = "fnv" | 353 | name = "fnv" |
@@ -814,12 +805,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index" | |||
814 | checksum = "0b631f7e854af39a1739f401cf34a8a013dfe09eac4fa4dba91e9768bd28168d" | 805 | checksum = "0b631f7e854af39a1739f401cf34a8a013dfe09eac4fa4dba91e9768bd28168d" |
815 | 806 | ||
816 | [[package]] | 807 | [[package]] |
817 | name = "ordermap" | ||
818 | version = "0.3.5" | ||
819 | source = "registry+https://github.com/rust-lang/crates.io-index" | ||
820 | checksum = "a86ed3f5f244b372d6b1a00b72ef7f8876d0bc6a78a4c9985c53614041512063" | ||
821 | |||
822 | [[package]] | ||
823 | name = "parking_lot" | 808 | name = "parking_lot" |
824 | version = "0.10.2" | 809 | version = "0.10.2" |
825 | source = "registry+https://github.com/rust-lang/crates.io-index" | 810 | source = "registry+https://github.com/rust-lang/crates.io-index" |
@@ -873,12 +858,12 @@ checksum = "d4fd5641d01c8f18a23da7b6fe29298ff4b55afcccdf78973b24cf3175fee32e" | |||
873 | 858 | ||
874 | [[package]] | 859 | [[package]] |
875 | name = "petgraph" | 860 | name = "petgraph" |
876 | version = "0.4.13" | 861 | version = "0.5.0" |
877 | source = "registry+https://github.com/rust-lang/crates.io-index" | 862 | source = "registry+https://github.com/rust-lang/crates.io-index" |
878 | checksum = "9c3659d1ee90221741f65dd128d9998311b0e40c5d3c23a62445938214abce4f" | 863 | checksum = "29c127eea4a29ec6c85d153c59dc1213f33ec74cead30fe4730aecc88cc1fd92" |
879 | dependencies = [ | 864 | dependencies = [ |
880 | "fixedbitset", | 865 | "fixedbitset", |
881 | "ordermap", | 866 | "indexmap", |
882 | ] | 867 | ] |
883 | 868 | ||
884 | [[package]] | 869 | [[package]] |
@@ -1053,7 +1038,7 @@ dependencies = [ | |||
1053 | "chalk-ir", | 1038 | "chalk-ir", |
1054 | "chalk-rust-ir", | 1039 | "chalk-rust-ir", |
1055 | "chalk-solve", | 1040 | "chalk-solve", |
1056 | "ena 0.14.0", | 1041 | "ena", |
1057 | "insta", | 1042 | "insta", |
1058 | "itertools", | 1043 | "itertools", |
1059 | "log", | 1044 | "log", |
diff --git a/crates/ra_hir_ty/Cargo.toml b/crates/ra_hir_ty/Cargo.toml index 5fc0ec5e3..b2de7fa34 100644 --- a/crates/ra_hir_ty/Cargo.toml +++ b/crates/ra_hir_ty/Cargo.toml | |||
@@ -27,9 +27,9 @@ test_utils = { path = "../test_utils" } | |||
27 | 27 | ||
28 | scoped-tls = "1" | 28 | scoped-tls = "1" |
29 | 29 | ||
30 | chalk-solve = { git = "https://github.com/rust-lang/chalk.git", rev = "3e9c2503ae9c5277c2acb74624dc267876dd89b3" } | 30 | chalk-solve = { git = "https://github.com/rust-lang/chalk.git", rev = "eaab84b394007d1bed15f5470409a6ea02900a96" } |
31 | chalk-rust-ir = { git = "https://github.com/rust-lang/chalk.git", rev = "3e9c2503ae9c5277c2acb74624dc267876dd89b3" } | 31 | chalk-rust-ir = { git = "https://github.com/rust-lang/chalk.git", rev = "eaab84b394007d1bed15f5470409a6ea02900a96" } |
32 | chalk-ir = { git = "https://github.com/rust-lang/chalk.git", rev = "3e9c2503ae9c5277c2acb74624dc267876dd89b3" } | 32 | chalk-ir = { git = "https://github.com/rust-lang/chalk.git", rev = "eaab84b394007d1bed15f5470409a6ea02900a96" } |
33 | 33 | ||
34 | [dev-dependencies] | 34 | [dev-dependencies] |
35 | insta = "0.16.0" | 35 | insta = "0.16.0" |
diff --git a/crates/ra_hir_ty/src/traits/chalk.rs b/crates/ra_hir_ty/src/traits/chalk.rs index 5870618a0..c2d7abd17 100644 --- a/crates/ra_hir_ty/src/traits/chalk.rs +++ b/crates/ra_hir_ty/src/traits/chalk.rs | |||
@@ -4,7 +4,7 @@ use std::{fmt, sync::Arc}; | |||
4 | use log::debug; | 4 | use log::debug; |
5 | 5 | ||
6 | use chalk_ir::{ | 6 | use chalk_ir::{ |
7 | cast::Cast, fold::shift::Shift, interner::HasInterner, Goal, GoalData, Parameter, | 7 | cast::Cast, fold::shift::Shift, interner::HasInterner, GenericArg, Goal, GoalData, |
8 | PlaceholderIndex, TypeName, UniverseIndex, | 8 | PlaceholderIndex, TypeName, UniverseIndex, |
9 | }; | 9 | }; |
10 | 10 | ||
@@ -26,24 +26,24 @@ pub(super) mod tls; | |||
26 | pub struct Interner; | 26 | pub struct Interner; |
27 | 27 | ||
28 | impl chalk_ir::interner::Interner for Interner { | 28 | impl chalk_ir::interner::Interner for Interner { |
29 | type InternedType = Box<chalk_ir::TyData<Self>>; | 29 | type InternedType = Box<chalk_ir::TyData<Self>>; // FIXME use Arc? |
30 | type InternedLifetime = chalk_ir::LifetimeData<Self>; | 30 | type InternedLifetime = chalk_ir::LifetimeData<Self>; |
31 | type InternedParameter = chalk_ir::ParameterData<Self>; | 31 | type InternedConst = Arc<chalk_ir::ConstData<Self>>; |
32 | type InternedConcreteConst = (); | ||
33 | type InternedGenericArg = chalk_ir::GenericArgData<Self>; | ||
32 | type InternedGoal = Arc<GoalData<Self>>; | 34 | type InternedGoal = Arc<GoalData<Self>>; |
33 | type InternedGoals = Vec<Goal<Self>>; | 35 | type InternedGoals = Vec<Goal<Self>>; |
34 | type InternedSubstitution = Vec<Parameter<Self>>; | 36 | type InternedSubstitution = Vec<GenericArg<Self>>; |
35 | type InternedProgramClause = chalk_ir::ProgramClauseData<Self>; | 37 | type InternedProgramClause = chalk_ir::ProgramClauseData<Self>; |
36 | type InternedProgramClauses = Arc<[chalk_ir::ProgramClause<Self>]>; | 38 | type InternedProgramClauses = Arc<[chalk_ir::ProgramClause<Self>]>; |
37 | type InternedQuantifiedWhereClauses = Vec<chalk_ir::QuantifiedWhereClause<Self>>; | 39 | type InternedQuantifiedWhereClauses = Vec<chalk_ir::QuantifiedWhereClause<Self>>; |
38 | type InternedParameterKinds = Vec<chalk_ir::ParameterKind<()>>; | 40 | type InternedVariableKinds = Vec<chalk_ir::VariableKind<Self>>; |
39 | type InternedCanonicalVarKinds = Vec<chalk_ir::ParameterKind<UniverseIndex>>; | 41 | type InternedCanonicalVarKinds = Vec<chalk_ir::CanonicalVarKind<Self>>; |
40 | type Identifier = TypeAliasId; | ||
41 | type DefId = InternId; | 42 | type DefId = InternId; |
43 | type InternedAdtId = InternId; | ||
44 | type Identifier = TypeAliasId; | ||
42 | 45 | ||
43 | fn debug_struct_id( | 46 | fn debug_adt_id(type_kind_id: StructId, fmt: &mut fmt::Formatter<'_>) -> Option<fmt::Result> { |
44 | type_kind_id: StructId, | ||
45 | fmt: &mut fmt::Formatter<'_>, | ||
46 | ) -> Option<fmt::Result> { | ||
47 | tls::with_current_program(|prog| Some(prog?.debug_struct_id(type_kind_id, fmt))) | 47 | tls::with_current_program(|prog| Some(prog?.debug_struct_id(type_kind_id, fmt))) |
48 | } | 48 | } |
49 | 49 | ||
@@ -94,11 +94,11 @@ impl chalk_ir::interner::Interner for Interner { | |||
94 | tls::with_current_program(|prog| Some(prog?.debug_lifetime(lifetime, fmt))) | 94 | tls::with_current_program(|prog| Some(prog?.debug_lifetime(lifetime, fmt))) |
95 | } | 95 | } |
96 | 96 | ||
97 | fn debug_parameter( | 97 | fn debug_generic_arg( |
98 | parameter: &Parameter<Interner>, | 98 | parameter: &GenericArg<Interner>, |
99 | fmt: &mut fmt::Formatter<'_>, | 99 | fmt: &mut fmt::Formatter<'_>, |
100 | ) -> Option<fmt::Result> { | 100 | ) -> Option<fmt::Result> { |
101 | tls::with_current_program(|prog| Some(prog?.debug_parameter(parameter, fmt))) | 101 | tls::with_current_program(|prog| Some(prog?.debug_generic_arg(parameter, fmt))) |
102 | } | 102 | } |
103 | 103 | ||
104 | fn debug_goal(goal: &Goal<Interner>, fmt: &mut fmt::Formatter<'_>) -> Option<fmt::Result> { | 104 | fn debug_goal(goal: &Goal<Interner>, fmt: &mut fmt::Formatter<'_>) -> Option<fmt::Result> { |
@@ -164,17 +164,32 @@ impl chalk_ir::interner::Interner for Interner { | |||
164 | lifetime | 164 | lifetime |
165 | } | 165 | } |
166 | 166 | ||
167 | fn intern_parameter( | 167 | fn intern_const(&self, constant: chalk_ir::ConstData<Self>) -> Arc<chalk_ir::ConstData<Self>> { |
168 | Arc::new(constant) | ||
169 | } | ||
170 | |||
171 | fn const_data<'a>( | ||
172 | &self, | ||
173 | constant: &'a Arc<chalk_ir::ConstData<Self>>, | ||
174 | ) -> &'a chalk_ir::ConstData<Self> { | ||
175 | constant | ||
176 | } | ||
177 | |||
178 | fn const_eq(&self, _ty: &Box<chalk_ir::TyData<Self>>, _c1: &(), _c2: &()) -> bool { | ||
179 | true | ||
180 | } | ||
181 | |||
182 | fn intern_generic_arg( | ||
168 | &self, | 183 | &self, |
169 | parameter: chalk_ir::ParameterData<Self>, | 184 | parameter: chalk_ir::GenericArgData<Self>, |
170 | ) -> chalk_ir::ParameterData<Self> { | 185 | ) -> chalk_ir::GenericArgData<Self> { |
171 | parameter | 186 | parameter |
172 | } | 187 | } |
173 | 188 | ||
174 | fn parameter_data<'a>( | 189 | fn generic_arg_data<'a>( |
175 | &self, | 190 | &self, |
176 | parameter: &'a chalk_ir::ParameterData<Self>, | 191 | parameter: &'a chalk_ir::GenericArgData<Self>, |
177 | ) -> &'a chalk_ir::ParameterData<Self> { | 192 | ) -> &'a chalk_ir::GenericArgData<Self> { |
178 | parameter | 193 | parameter |
179 | } | 194 | } |
180 | 195 | ||
@@ -199,15 +214,15 @@ impl chalk_ir::interner::Interner for Interner { | |||
199 | 214 | ||
200 | fn intern_substitution<E>( | 215 | fn intern_substitution<E>( |
201 | &self, | 216 | &self, |
202 | data: impl IntoIterator<Item = Result<Parameter<Self>, E>>, | 217 | data: impl IntoIterator<Item = Result<GenericArg<Self>, E>>, |
203 | ) -> Result<Vec<Parameter<Self>>, E> { | 218 | ) -> Result<Vec<GenericArg<Self>>, E> { |
204 | data.into_iter().collect() | 219 | data.into_iter().collect() |
205 | } | 220 | } |
206 | 221 | ||
207 | fn substitution_data<'a>( | 222 | fn substitution_data<'a>( |
208 | &self, | 223 | &self, |
209 | substitution: &'a Vec<Parameter<Self>>, | 224 | substitution: &'a Vec<GenericArg<Self>>, |
210 | ) -> &'a [Parameter<Self>] { | 225 | ) -> &'a [GenericArg<Self>] { |
211 | substitution | 226 | substitution |
212 | } | 227 | } |
213 | 228 | ||
@@ -253,23 +268,23 @@ impl chalk_ir::interner::Interner for Interner { | |||
253 | clauses | 268 | clauses |
254 | } | 269 | } |
255 | 270 | ||
256 | fn intern_parameter_kinds<E>( | 271 | fn intern_generic_arg_kinds<E>( |
257 | &self, | 272 | &self, |
258 | data: impl IntoIterator<Item = Result<chalk_ir::ParameterKind<()>, E>>, | 273 | data: impl IntoIterator<Item = Result<chalk_ir::VariableKind<Self>, E>>, |
259 | ) -> Result<Self::InternedParameterKinds, E> { | 274 | ) -> Result<Self::InternedVariableKinds, E> { |
260 | data.into_iter().collect() | 275 | data.into_iter().collect() |
261 | } | 276 | } |
262 | 277 | ||
263 | fn parameter_kinds_data<'a>( | 278 | fn variable_kinds_data<'a>( |
264 | &self, | 279 | &self, |
265 | parameter_kinds: &'a Self::InternedParameterKinds, | 280 | parameter_kinds: &'a Self::InternedVariableKinds, |
266 | ) -> &'a [chalk_ir::ParameterKind<()>] { | 281 | ) -> &'a [chalk_ir::VariableKind<Self>] { |
267 | ¶meter_kinds | 282 | ¶meter_kinds |
268 | } | 283 | } |
269 | 284 | ||
270 | fn intern_canonical_var_kinds<E>( | 285 | fn intern_canonical_var_kinds<E>( |
271 | &self, | 286 | &self, |
272 | data: impl IntoIterator<Item = Result<chalk_ir::ParameterKind<UniverseIndex>, E>>, | 287 | data: impl IntoIterator<Item = Result<chalk_ir::CanonicalVarKind<Self>, E>>, |
273 | ) -> Result<Self::InternedCanonicalVarKinds, E> { | 288 | ) -> Result<Self::InternedCanonicalVarKinds, E> { |
274 | data.into_iter().collect() | 289 | data.into_iter().collect() |
275 | } | 290 | } |
@@ -277,7 +292,7 @@ impl chalk_ir::interner::Interner for Interner { | |||
277 | fn canonical_var_kinds_data<'a>( | 292 | fn canonical_var_kinds_data<'a>( |
278 | &self, | 293 | &self, |
279 | canonical_var_kinds: &'a Self::InternedCanonicalVarKinds, | 294 | canonical_var_kinds: &'a Self::InternedCanonicalVarKinds, |
280 | ) -> &'a [chalk_ir::ParameterKind<UniverseIndex>] { | 295 | ) -> &'a [chalk_ir::CanonicalVarKind<Self>] { |
281 | &canonical_var_kinds | 296 | &canonical_var_kinds |
282 | } | 297 | } |
283 | } | 298 | } |
@@ -290,8 +305,8 @@ pub type AssocTypeId = chalk_ir::AssocTypeId<Interner>; | |||
290 | pub type AssociatedTyDatum = chalk_rust_ir::AssociatedTyDatum<Interner>; | 305 | pub type AssociatedTyDatum = chalk_rust_ir::AssociatedTyDatum<Interner>; |
291 | pub type TraitId = chalk_ir::TraitId<Interner>; | 306 | pub type TraitId = chalk_ir::TraitId<Interner>; |
292 | pub type TraitDatum = chalk_rust_ir::TraitDatum<Interner>; | 307 | pub type TraitDatum = chalk_rust_ir::TraitDatum<Interner>; |
293 | pub type StructId = chalk_ir::StructId<Interner>; | 308 | pub type StructId = chalk_ir::AdtId<Interner>; |
294 | pub type StructDatum = chalk_rust_ir::StructDatum<Interner>; | 309 | pub type StructDatum = chalk_rust_ir::AdtDatum<Interner>; |
295 | pub type ImplId = chalk_ir::ImplId<Interner>; | 310 | pub type ImplId = chalk_ir::ImplId<Interner>; |
296 | pub type ImplDatum = chalk_rust_ir::ImplDatum<Interner>; | 311 | pub type ImplDatum = chalk_rust_ir::ImplDatum<Interner>; |
297 | pub type AssociatedTyValueId = chalk_rust_ir::AssociatedTyValueId<Interner>; | 312 | pub type AssociatedTyValueId = chalk_rust_ir::AssociatedTyValueId<Interner>; |
@@ -453,14 +468,14 @@ impl ToChalk for TypeCtor { | |||
453 | _ => { | 468 | _ => { |
454 | // other TypeCtors get interned and turned into a chalk StructId | 469 | // other TypeCtors get interned and turned into a chalk StructId |
455 | let struct_id = db.intern_type_ctor(self).into(); | 470 | let struct_id = db.intern_type_ctor(self).into(); |
456 | TypeName::Struct(struct_id) | 471 | TypeName::Adt(struct_id) |
457 | } | 472 | } |
458 | } | 473 | } |
459 | } | 474 | } |
460 | 475 | ||
461 | fn from_chalk(db: &dyn HirDatabase, type_name: TypeName<Interner>) -> TypeCtor { | 476 | fn from_chalk(db: &dyn HirDatabase, type_name: TypeName<Interner>) -> TypeCtor { |
462 | match type_name { | 477 | match type_name { |
463 | TypeName::Struct(struct_id) => db.lookup_intern_type_ctor(struct_id.into()), | 478 | TypeName::Adt(struct_id) => db.lookup_intern_type_ctor(struct_id.into()), |
464 | TypeName::AssociatedType(type_id) => TypeCtor::AssociatedType(from_chalk(db, type_id)), | 479 | TypeName::AssociatedType(type_id) => TypeCtor::AssociatedType(from_chalk(db, type_id)), |
465 | TypeName::OpaqueType(_) => unreachable!(), | 480 | TypeName::OpaqueType(_) => unreachable!(), |
466 | 481 | ||
@@ -471,6 +486,8 @@ impl ToChalk for TypeCtor { | |||
471 | TypeName::Ref(_) => unreachable!(), | 486 | TypeName::Ref(_) => unreachable!(), |
472 | TypeName::Str => unreachable!(), | 487 | TypeName::Str => unreachable!(), |
473 | 488 | ||
489 | TypeName::FnDef(_) => unreachable!(), | ||
490 | |||
474 | TypeName::Error => { | 491 | TypeName::Error => { |
475 | // this should not be reached, since we don't represent TypeName::Error with TypeCtor | 492 | // this should not be reached, since we don't represent TypeName::Error with TypeCtor |
476 | unreachable!() | 493 | unreachable!() |
@@ -622,7 +639,10 @@ where | |||
622 | type Chalk = chalk_ir::Canonical<T::Chalk>; | 639 | type Chalk = chalk_ir::Canonical<T::Chalk>; |
623 | 640 | ||
624 | fn to_chalk(self, db: &dyn HirDatabase) -> chalk_ir::Canonical<T::Chalk> { | 641 | fn to_chalk(self, db: &dyn HirDatabase) -> chalk_ir::Canonical<T::Chalk> { |
625 | let parameter = chalk_ir::ParameterKind::Ty(chalk_ir::UniverseIndex::ROOT); | 642 | let parameter = chalk_ir::CanonicalVarKind::new( |
643 | chalk_ir::VariableKind::Ty, | ||
644 | chalk_ir::UniverseIndex::ROOT, | ||
645 | ); | ||
626 | let value = self.value.to_chalk(db); | 646 | let value = self.value.to_chalk(db); |
627 | chalk_ir::Canonical { | 647 | chalk_ir::Canonical { |
628 | value, | 648 | value, |
@@ -738,9 +758,9 @@ where | |||
738 | T: HasInterner<Interner = Interner>, | 758 | T: HasInterner<Interner = Interner>, |
739 | { | 759 | { |
740 | chalk_ir::Binders::new( | 760 | chalk_ir::Binders::new( |
741 | chalk_ir::ParameterKinds::from( | 761 | chalk_ir::VariableKinds::from( |
742 | &Interner, | 762 | &Interner, |
743 | std::iter::repeat(chalk_ir::ParameterKind::Ty(())).take(num_vars), | 763 | std::iter::repeat(chalk_ir::VariableKind::Ty).take(num_vars), |
744 | ), | 764 | ), |
745 | value, | 765 | value, |
746 | ) | 766 | ) |
@@ -819,16 +839,25 @@ impl<'a> chalk_solve::RustIrDatabase<Interner> for ChalkContext<'a> { | |||
819 | fn trait_datum(&self, trait_id: TraitId) -> Arc<TraitDatum> { | 839 | fn trait_datum(&self, trait_id: TraitId) -> Arc<TraitDatum> { |
820 | self.db.trait_datum(self.krate, trait_id) | 840 | self.db.trait_datum(self.krate, trait_id) |
821 | } | 841 | } |
822 | fn struct_datum(&self, struct_id: StructId) -> Arc<StructDatum> { | 842 | fn adt_datum(&self, struct_id: StructId) -> Arc<StructDatum> { |
823 | self.db.struct_datum(self.krate, struct_id) | 843 | self.db.struct_datum(self.krate, struct_id) |
824 | } | 844 | } |
825 | fn impl_datum(&self, impl_id: ImplId) -> Arc<ImplDatum> { | 845 | fn impl_datum(&self, impl_id: ImplId) -> Arc<ImplDatum> { |
826 | self.db.impl_datum(self.krate, impl_id) | 846 | self.db.impl_datum(self.krate, impl_id) |
827 | } | 847 | } |
848 | |||
849 | fn fn_def_datum( | ||
850 | &self, | ||
851 | _fn_def_id: chalk_ir::FnDefId<Interner>, | ||
852 | ) -> Arc<chalk_rust_ir::FnDefDatum<Interner>> { | ||
853 | // We don't yet provide any FnDefs to Chalk | ||
854 | unimplemented!() | ||
855 | } | ||
856 | |||
828 | fn impls_for_trait( | 857 | fn impls_for_trait( |
829 | &self, | 858 | &self, |
830 | trait_id: TraitId, | 859 | trait_id: TraitId, |
831 | parameters: &[Parameter<Interner>], | 860 | parameters: &[GenericArg<Interner>], |
832 | ) -> Vec<ImplId> { | 861 | ) -> Vec<ImplId> { |
833 | debug!("impls_for_trait {:?}", trait_id); | 862 | debug!("impls_for_trait {:?}", trait_id); |
834 | let trait_: hir_def::TraitId = from_chalk(self.db, trait_id); | 863 | let trait_: hir_def::TraitId = from_chalk(self.db, trait_id); |
@@ -1000,7 +1029,7 @@ pub(crate) fn struct_datum_query( | |||
1000 | struct_id: StructId, | 1029 | struct_id: StructId, |
1001 | ) -> Arc<StructDatum> { | 1030 | ) -> Arc<StructDatum> { |
1002 | debug!("struct_datum {:?}", struct_id); | 1031 | debug!("struct_datum {:?}", struct_id); |
1003 | let type_ctor: TypeCtor = from_chalk(db, TypeName::Struct(struct_id)); | 1032 | let type_ctor: TypeCtor = from_chalk(db, TypeName::Adt(struct_id)); |
1004 | debug!("struct {:?} = {:?}", struct_id, type_ctor); | 1033 | debug!("struct {:?} = {:?}", struct_id, type_ctor); |
1005 | let num_params = type_ctor.num_ty_params(db); | 1034 | let num_params = type_ctor.num_ty_params(db); |
1006 | let upstream = type_ctor.krate(db) != Some(krate); | 1035 | let upstream = type_ctor.krate(db) != Some(krate); |
@@ -1012,12 +1041,12 @@ pub(crate) fn struct_datum_query( | |||
1012 | convert_where_clauses(db, generic_def, &bound_vars) | 1041 | convert_where_clauses(db, generic_def, &bound_vars) |
1013 | }) | 1042 | }) |
1014 | .unwrap_or_else(Vec::new); | 1043 | .unwrap_or_else(Vec::new); |
1015 | let flags = chalk_rust_ir::StructFlags { | 1044 | let flags = chalk_rust_ir::AdtFlags { |
1016 | upstream, | 1045 | upstream, |
1017 | // FIXME set fundamental flag correctly | 1046 | // FIXME set fundamental flag correctly |
1018 | fundamental: false, | 1047 | fundamental: false, |
1019 | }; | 1048 | }; |
1020 | let struct_datum_bound = chalk_rust_ir::StructDatumBound { | 1049 | let struct_datum_bound = chalk_rust_ir::AdtDatumBound { |
1021 | fields: Vec::new(), // FIXME add fields (only relevant for auto traits) | 1050 | fields: Vec::new(), // FIXME add fields (only relevant for auto traits) |
1022 | where_clauses, | 1051 | where_clauses, |
1023 | }; | 1052 | }; |
@@ -1153,7 +1182,7 @@ impl From<StructId> for crate::TypeCtorId { | |||
1153 | 1182 | ||
1154 | impl From<crate::TypeCtorId> for StructId { | 1183 | impl From<crate::TypeCtorId> for StructId { |
1155 | fn from(type_ctor_id: crate::TypeCtorId) -> Self { | 1184 | fn from(type_ctor_id: crate::TypeCtorId) -> Self { |
1156 | chalk_ir::StructId(type_ctor_id.as_intern_id()) | 1185 | chalk_ir::AdtId(type_ctor_id.as_intern_id()) |
1157 | } | 1186 | } |
1158 | } | 1187 | } |
1159 | 1188 | ||
diff --git a/crates/ra_hir_ty/src/traits/chalk/tls.rs b/crates/ra_hir_ty/src/traits/chalk/tls.rs index 4867cb17e..b7eb49d7b 100644 --- a/crates/ra_hir_ty/src/traits/chalk/tls.rs +++ b/crates/ra_hir_ty/src/traits/chalk/tls.rs | |||
@@ -1,7 +1,7 @@ | |||
1 | //! Implementation of Chalk debug helper functions using TLS. | 1 | //! Implementation of Chalk debug helper functions using TLS. |
2 | use std::fmt; | 2 | use std::fmt; |
3 | 3 | ||
4 | use chalk_ir::{AliasTy, Goal, Goals, Lifetime, Parameter, ProgramClauseImplication, TypeName}; | 4 | use chalk_ir::{AliasTy, GenericArg, Goal, Goals, Lifetime, ProgramClauseImplication, TypeName}; |
5 | use itertools::Itertools; | 5 | use itertools::Itertools; |
6 | 6 | ||
7 | use super::{from_chalk, Interner}; | 7 | use super::{from_chalk, Interner}; |
@@ -18,7 +18,7 @@ impl DebugContext<'_> { | |||
18 | id: super::StructId, | 18 | id: super::StructId, |
19 | f: &mut fmt::Formatter<'_>, | 19 | f: &mut fmt::Formatter<'_>, |
20 | ) -> Result<(), fmt::Error> { | 20 | ) -> Result<(), fmt::Error> { |
21 | let type_ctor: TypeCtor = from_chalk(self.0, TypeName::Struct(id)); | 21 | let type_ctor: TypeCtor = from_chalk(self.0, TypeName::Adt(id)); |
22 | match type_ctor { | 22 | match type_ctor { |
23 | TypeCtor::Bool => write!(f, "bool")?, | 23 | TypeCtor::Bool => write!(f, "bool")?, |
24 | TypeCtor::Char => write!(f, "char")?, | 24 | TypeCtor::Char => write!(f, "char")?, |
@@ -188,9 +188,9 @@ impl DebugContext<'_> { | |||
188 | write!(fmt, "{:?}", lifetime.data(&Interner)) | 188 | write!(fmt, "{:?}", lifetime.data(&Interner)) |
189 | } | 189 | } |
190 | 190 | ||
191 | pub fn debug_parameter( | 191 | pub fn debug_generic_arg( |
192 | &self, | 192 | &self, |
193 | parameter: &Parameter<Interner>, | 193 | parameter: &GenericArg<Interner>, |
194 | fmt: &mut fmt::Formatter<'_>, | 194 | fmt: &mut fmt::Formatter<'_>, |
195 | ) -> Result<(), fmt::Error> { | 195 | ) -> Result<(), fmt::Error> { |
196 | write!(fmt, "{:?}", parameter.data(&Interner).inner_debug()) | 196 | write!(fmt, "{:?}", parameter.data(&Interner).inner_debug()) |