aboutsummaryrefslogtreecommitdiff
path: root/crates/hir_ty/src/traits/chalk
diff options
context:
space:
mode:
Diffstat (limited to 'crates/hir_ty/src/traits/chalk')
-rw-r--r--crates/hir_ty/src/traits/chalk/mapping.rs191
1 files changed, 4 insertions, 187 deletions
diff --git a/crates/hir_ty/src/traits/chalk/mapping.rs b/crates/hir_ty/src/traits/chalk/mapping.rs
index 62cf0fecf..54783b58c 100644
--- a/crates/hir_ty/src/traits/chalk/mapping.rs
+++ b/crates/hir_ty/src/traits/chalk/mapping.rs
@@ -18,55 +18,6 @@ use crate::{
18use super::interner::*; 18use super::interner::*;
19use super::*; 19use super::*;
20 20
21impl ToChalk for Ty {
22 type Chalk = chalk_ir::Ty<Interner>;
23 fn to_chalk(self, db: &dyn HirDatabase) -> chalk_ir::Ty<Interner> {
24 self
25 }
26 fn from_chalk(db: &dyn HirDatabase, chalk: chalk_ir::Ty<Interner>) -> Self {
27 chalk
28 }
29}
30
31impl ToChalk for GenericArg {
32 type Chalk = chalk_ir::GenericArg<Interner>;
33
34 fn to_chalk(self, db: &dyn HirDatabase) -> Self::Chalk {
35 self
36 }
37
38 fn from_chalk(db: &dyn HirDatabase, chalk: Self::Chalk) -> Self {
39 chalk
40 }
41}
42
43impl ToChalk for Substitution {
44 type Chalk = chalk_ir::Substitution<Interner>;
45
46 fn to_chalk(self, db: &dyn HirDatabase) -> chalk_ir::Substitution<Interner> {
47 self
48 }
49
50 fn from_chalk(
51 db: &dyn HirDatabase,
52 parameters: chalk_ir::Substitution<Interner>,
53 ) -> Substitution {
54 parameters
55 }
56}
57
58impl ToChalk for TraitRef {
59 type Chalk = chalk_ir::TraitRef<Interner>;
60
61 fn to_chalk(self: TraitRef, db: &dyn HirDatabase) -> chalk_ir::TraitRef<Interner> {
62 self
63 }
64
65 fn from_chalk(db: &dyn HirDatabase, trait_ref: chalk_ir::TraitRef<Interner>) -> Self {
66 trait_ref
67 }
68}
69
70impl ToChalk for hir_def::TraitId { 21impl ToChalk for hir_def::TraitId {
71 type Chalk = TraitId; 22 type Chalk = TraitId;
72 23
@@ -120,140 +71,6 @@ impl ToChalk for TypeAliasAsValue {
120 } 71 }
121} 72}
122 73
123impl ToChalk for WhereClause {
124 type Chalk = chalk_ir::WhereClause<Interner>;
125
126 fn to_chalk(self, db: &dyn HirDatabase) -> chalk_ir::WhereClause<Interner> {
127 self
128 }
129
130 fn from_chalk(
131 db: &dyn HirDatabase,
132 where_clause: chalk_ir::WhereClause<Interner>,
133 ) -> WhereClause {
134 where_clause
135 }
136}
137
138impl ToChalk for ProjectionTy {
139 type Chalk = chalk_ir::ProjectionTy<Interner>;
140
141 fn to_chalk(self, db: &dyn HirDatabase) -> chalk_ir::ProjectionTy<Interner> {
142 self
143 }
144
145 fn from_chalk(
146 db: &dyn HirDatabase,
147 projection_ty: chalk_ir::ProjectionTy<Interner>,
148 ) -> ProjectionTy {
149 projection_ty
150 }
151}
152impl ToChalk for OpaqueTy {
153 type Chalk = chalk_ir::OpaqueTy<Interner>;
154
155 fn to_chalk(self, db: &dyn HirDatabase) -> Self::Chalk {
156 self
157 }
158
159 fn from_chalk(db: &dyn HirDatabase, chalk: Self::Chalk) -> Self {
160 chalk
161 }
162}
163
164impl ToChalk for AliasTy {
165 type Chalk = chalk_ir::AliasTy<Interner>;
166
167 fn to_chalk(self, db: &dyn HirDatabase) -> Self::Chalk {
168 self
169 }
170
171 fn from_chalk(db: &dyn HirDatabase, chalk: Self::Chalk) -> Self {
172 chalk
173 }
174}
175
176impl ToChalk for AliasEq {
177 type Chalk = chalk_ir::AliasEq<Interner>;
178
179 fn to_chalk(self, db: &dyn HirDatabase) -> chalk_ir::AliasEq<Interner> {
180 self
181 }
182
183 fn from_chalk(db: &dyn HirDatabase, alias_eq: chalk_ir::AliasEq<Interner>) -> Self {
184 alias_eq
185 }
186}
187
188impl ToChalk for DomainGoal {
189 type Chalk = chalk_ir::DomainGoal<Interner>;
190
191 fn to_chalk(self, db: &dyn HirDatabase) -> chalk_ir::DomainGoal<Interner> {
192 self
193 }
194
195 fn from_chalk(_db: &dyn HirDatabase, goal: chalk_ir::DomainGoal<Interner>) -> Self {
196 goal
197 }
198}
199
200impl<T> ToChalk for Canonical<T>
201where
202 T: HasInterner<Interner = Interner>,
203{
204 type Chalk = chalk_ir::Canonical<T>;
205
206 fn to_chalk(self, db: &dyn HirDatabase) -> chalk_ir::Canonical<T> {
207 self
208 }
209
210 fn from_chalk(db: &dyn HirDatabase, canonical: chalk_ir::Canonical<T>) -> Canonical<T> {
211 canonical
212 }
213}
214
215impl<T: ToChalk> ToChalk for InEnvironment<T>
216where
217 T: HasInterner<Interner = Interner>,
218{
219 type Chalk = chalk_ir::InEnvironment<T>;
220
221 fn to_chalk(self, db: &dyn HirDatabase) -> chalk_ir::InEnvironment<T> {
222 self
223 }
224
225 fn from_chalk(_db: &dyn HirDatabase, in_env: chalk_ir::InEnvironment<T>) -> InEnvironment<T> {
226 in_env
227 }
228}
229
230impl<T: ToChalk> ToChalk for crate::Binders<T>
231where
232 T: HasInterner<Interner = Interner>,
233{
234 type Chalk = chalk_ir::Binders<T>;
235
236 fn to_chalk(self, db: &dyn HirDatabase) -> chalk_ir::Binders<T> {
237 self
238 }
239
240 fn from_chalk(db: &dyn HirDatabase, binders: chalk_ir::Binders<T>) -> crate::Binders<T> {
241 binders
242 }
243}
244
245impl ToChalk for crate::ConstrainedSubst {
246 type Chalk = chalk_ir::ConstrainedSubst<Interner>;
247
248 fn to_chalk(self, _db: &dyn HirDatabase) -> Self::Chalk {
249 self
250 }
251
252 fn from_chalk(db: &dyn HirDatabase, chalk: Self::Chalk) -> Self {
253 chalk
254 }
255}
256
257pub(super) fn make_binders<T>(value: T, num_vars: usize) -> chalk_ir::Binders<T> 74pub(super) fn make_binders<T>(value: T, num_vars: usize) -> chalk_ir::Binders<T>
258where 75where
259 T: HasInterner<Interner = Interner>, 76 T: HasInterner<Interner = Interner>,
@@ -276,7 +93,7 @@ pub(super) fn convert_where_clauses(
276 let generic_predicates = db.generic_predicates(def); 93 let generic_predicates = db.generic_predicates(def);
277 let mut result = Vec::with_capacity(generic_predicates.len()); 94 let mut result = Vec::with_capacity(generic_predicates.len());
278 for pred in generic_predicates.iter() { 95 for pred in generic_predicates.iter() {
279 result.push(pred.clone().substitute(&Interner, substs).to_chalk(db)); 96 result.push(pred.clone().substitute(&Interner, substs));
280 } 97 }
281 result 98 result
282} 99}
@@ -299,7 +116,7 @@ pub(super) fn generic_predicate_to_inline_bound(
299 } 116 }
300 let args_no_self = trait_ref.substitution.interned()[1..] 117 let args_no_self = trait_ref.substitution.interned()[1..]
301 .iter() 118 .iter()
302 .map(|ty| ty.clone().to_chalk(db).cast(&Interner)) 119 .map(|ty| ty.clone().cast(&Interner))
303 .collect(); 120 .collect();
304 let trait_bound = rust_ir::TraitBound { trait_id: trait_ref.trait_id, args_no_self }; 121 let trait_bound = rust_ir::TraitBound { trait_id: trait_ref.trait_id, args_no_self };
305 Some(chalk_ir::Binders::new(binders, rust_ir::InlineBound::TraitBound(trait_bound))) 122 Some(chalk_ir::Binders::new(binders, rust_ir::InlineBound::TraitBound(trait_bound)))
@@ -311,10 +128,10 @@ pub(super) fn generic_predicate_to_inline_bound(
311 let trait_ = projection_ty.trait_(db); 128 let trait_ = projection_ty.trait_(db);
312 let args_no_self = projection_ty.substitution.interned()[1..] 129 let args_no_self = projection_ty.substitution.interned()[1..]
313 .iter() 130 .iter()
314 .map(|ty| ty.clone().to_chalk(db).cast(&Interner)) 131 .map(|ty| ty.clone().cast(&Interner))
315 .collect(); 132 .collect();
316 let alias_eq_bound = rust_ir::AliasEqBound { 133 let alias_eq_bound = rust_ir::AliasEqBound {
317 value: ty.clone().to_chalk(db), 134 value: ty.clone(),
318 trait_bound: rust_ir::TraitBound { trait_id: trait_.to_chalk(db), args_no_self }, 135 trait_bound: rust_ir::TraitBound { trait_id: trait_.to_chalk(db), args_no_self },
319 associated_ty_id: projection_ty.associated_ty_id, 136 associated_ty_id: projection_ty.associated_ty_id,
320 parameters: Vec::new(), // FIXME we don't support generic associated types yet 137 parameters: Vec::new(), // FIXME we don't support generic associated types yet