aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir/src/ty/traits
diff options
context:
space:
mode:
authorSeivan Heidari <[email protected]>2019-10-31 08:43:20 +0000
committerSeivan Heidari <[email protected]>2019-10-31 08:43:20 +0000
commit8edda0e7b164009d6c03bb3d4be603fb38ad2e2a (patch)
tree744cf81075d394e2f9c06afb07642a2601800dda /crates/ra_hir/src/ty/traits
parent49562d36b97ddde34cf7585a8c2e8f232519b657 (diff)
parentd067afb064a7fa67b172abf561b7d80740cd6f18 (diff)
Merge branch 'master' into feature/themes
Diffstat (limited to 'crates/ra_hir/src/ty/traits')
-rw-r--r--crates/ra_hir/src/ty/traits/chalk.rs157
1 files changed, 82 insertions, 75 deletions
diff --git a/crates/ra_hir/src/ty/traits/chalk.rs b/crates/ra_hir/src/ty/traits/chalk.rs
index 00aaf65d9..39ef92182 100644
--- a/crates/ra_hir/src/ty/traits/chalk.rs
+++ b/crates/ra_hir/src/ty/traits/chalk.rs
@@ -4,11 +4,13 @@ use std::sync::Arc;
4use log::debug; 4use log::debug;
5 5
6use chalk_ir::{ 6use chalk_ir::{
7 cast::Cast, Identifier, ImplId, Parameter, PlaceholderIndex, TypeId, TypeKindId, TypeName, 7 cast::Cast, family::ChalkIr, Identifier, ImplId, Parameter, PlaceholderIndex, TypeId,
8 UniverseIndex, 8 TypeKindId, TypeName, UniverseIndex,
9}; 9};
10use chalk_rust_ir::{AssociatedTyDatum, ImplDatum, StructDatum, TraitDatum}; 10use chalk_rust_ir::{AssociatedTyDatum, ImplDatum, StructDatum, TraitDatum};
11 11
12use hir_expand::name;
13
12use ra_db::salsa::{InternId, InternKey}; 14use ra_db::salsa::{InternId, InternKey};
13 15
14use super::{Canonical, ChalkContext, Impl, Obligation}; 16use super::{Canonical, ChalkContext, Impl, Obligation};
@@ -38,8 +40,8 @@ where
38} 40}
39 41
40impl ToChalk for Ty { 42impl ToChalk for Ty {
41 type Chalk = chalk_ir::Ty; 43 type Chalk = chalk_ir::Ty<ChalkIr>;
42 fn to_chalk(self, db: &impl HirDatabase) -> chalk_ir::Ty { 44 fn to_chalk(self, db: &impl HirDatabase) -> chalk_ir::Ty<ChalkIr> {
43 match self { 45 match self {
44 Ty::Apply(apply_ty) => { 46 Ty::Apply(apply_ty) => {
45 let name = match apply_ty.ctor { 47 let name = match apply_ty.ctor {
@@ -62,21 +64,19 @@ impl ToChalk for Ty {
62 chalk_ir::ProjectionTy { associated_ty_id, parameters }.cast() 64 chalk_ir::ProjectionTy { associated_ty_id, parameters }.cast()
63 } 65 }
64 Ty::Param { idx, .. } => { 66 Ty::Param { idx, .. } => {
65 PlaceholderIndex { ui: UniverseIndex::ROOT, idx: idx as usize }.to_ty() 67 PlaceholderIndex { ui: UniverseIndex::ROOT, idx: idx as usize }.to_ty::<ChalkIr>()
66 } 68 }
67 Ty::Bound(idx) => chalk_ir::Ty::BoundVar(idx as usize), 69 Ty::Bound(idx) => chalk_ir::Ty::BoundVar(idx as usize),
68 Ty::Infer(_infer_ty) => panic!("uncanonicalized infer ty"), 70 Ty::Infer(_infer_ty) => panic!("uncanonicalized infer ty"),
69 // FIXME this is clearly incorrect, but probably not too incorrect 71 // FIXME use Chalk's Dyn/Opaque once the bugs with that are fixed
70 // and I'm not sure what to actually do with Ty::Unknown
71 // maybe an alternative would be `for<T> T`? (meaningless in rust, but expressible in chalk's Ty)
72 //
73 // FIXME also dyn and impl Trait are currently handled like Unknown because Chalk doesn't have them yet
74 Ty::Unknown | Ty::Dyn(_) | Ty::Opaque(_) => { 72 Ty::Unknown | Ty::Dyn(_) | Ty::Opaque(_) => {
75 PlaceholderIndex { ui: UniverseIndex::ROOT, idx: usize::max_value() }.to_ty() 73 let parameters = Vec::new();
74 let name = TypeName::Error;
75 chalk_ir::ApplicationTy { name, parameters }.cast()
76 } 76 }
77 } 77 }
78 } 78 }
79 fn from_chalk(db: &impl HirDatabase, chalk: chalk_ir::Ty) -> Self { 79 fn from_chalk(db: &impl HirDatabase, chalk: chalk_ir::Ty<ChalkIr>) -> Self {
80 match chalk { 80 match chalk {
81 chalk_ir::Ty::Apply(apply_ty) => { 81 chalk_ir::Ty::Apply(apply_ty) => {
82 // FIXME this is kind of hacky due to the fact that 82 // FIXME this is kind of hacky due to the fact that
@@ -92,6 +92,7 @@ impl ToChalk for Ty {
92 let parameters = from_chalk(db, apply_ty.parameters); 92 let parameters = from_chalk(db, apply_ty.parameters);
93 Ty::Apply(ApplicationTy { ctor, parameters }) 93 Ty::Apply(ApplicationTy { ctor, parameters })
94 } 94 }
95 TypeName::Error => Ty::Unknown,
95 // FIXME handle TypeKindId::Trait/Type here 96 // FIXME handle TypeKindId::Trait/Type here
96 TypeName::TypeKindId(_) => unimplemented!(), 97 TypeName::TypeKindId(_) => unimplemented!(),
97 TypeName::Placeholder(idx) => { 98 TypeName::Placeholder(idx) => {
@@ -108,18 +109,30 @@ impl ToChalk for Ty {
108 chalk_ir::Ty::ForAll(_) => unimplemented!(), 109 chalk_ir::Ty::ForAll(_) => unimplemented!(),
109 chalk_ir::Ty::BoundVar(idx) => Ty::Bound(idx as u32), 110 chalk_ir::Ty::BoundVar(idx) => Ty::Bound(idx as u32),
110 chalk_ir::Ty::InferenceVar(_iv) => Ty::Unknown, 111 chalk_ir::Ty::InferenceVar(_iv) => Ty::Unknown,
112 chalk_ir::Ty::Dyn(where_clauses) => {
113 assert_eq!(where_clauses.binders.len(), 1);
114 let predicates =
115 where_clauses.value.into_iter().map(|c| from_chalk(db, c)).collect();
116 Ty::Dyn(predicates)
117 }
118 chalk_ir::Ty::Opaque(where_clauses) => {
119 assert_eq!(where_clauses.binders.len(), 1);
120 let predicates =
121 where_clauses.value.into_iter().map(|c| from_chalk(db, c)).collect();
122 Ty::Opaque(predicates)
123 }
111 } 124 }
112 } 125 }
113} 126}
114 127
115impl ToChalk for Substs { 128impl ToChalk for Substs {
116 type Chalk = Vec<chalk_ir::Parameter>; 129 type Chalk = Vec<chalk_ir::Parameter<ChalkIr>>;
117 130
118 fn to_chalk(self, db: &impl HirDatabase) -> Vec<Parameter> { 131 fn to_chalk(self, db: &impl HirDatabase) -> Vec<Parameter<ChalkIr>> {
119 self.iter().map(|ty| ty.clone().to_chalk(db).cast()).collect() 132 self.iter().map(|ty| ty.clone().to_chalk(db).cast()).collect()
120 } 133 }
121 134
122 fn from_chalk(db: &impl HirDatabase, parameters: Vec<chalk_ir::Parameter>) -> Substs { 135 fn from_chalk(db: &impl HirDatabase, parameters: Vec<chalk_ir::Parameter<ChalkIr>>) -> Substs {
123 let tys = parameters 136 let tys = parameters
124 .into_iter() 137 .into_iter()
125 .map(|p| match p { 138 .map(|p| match p {
@@ -132,15 +145,15 @@ impl ToChalk for Substs {
132} 145}
133 146
134impl ToChalk for TraitRef { 147impl ToChalk for TraitRef {
135 type Chalk = chalk_ir::TraitRef; 148 type Chalk = chalk_ir::TraitRef<ChalkIr>;
136 149
137 fn to_chalk(self: TraitRef, db: &impl HirDatabase) -> chalk_ir::TraitRef { 150 fn to_chalk(self: TraitRef, db: &impl HirDatabase) -> chalk_ir::TraitRef<ChalkIr> {
138 let trait_id = self.trait_.to_chalk(db); 151 let trait_id = self.trait_.to_chalk(db);
139 let parameters = self.substs.to_chalk(db); 152 let parameters = self.substs.to_chalk(db);
140 chalk_ir::TraitRef { trait_id, parameters } 153 chalk_ir::TraitRef { trait_id, parameters }
141 } 154 }
142 155
143 fn from_chalk(db: &impl HirDatabase, trait_ref: chalk_ir::TraitRef) -> Self { 156 fn from_chalk(db: &impl HirDatabase, trait_ref: chalk_ir::TraitRef<ChalkIr>) -> Self {
144 let trait_ = from_chalk(db, trait_ref.trait_id); 157 let trait_ = from_chalk(db, trait_ref.trait_id);
145 let substs = from_chalk(db, trait_ref.parameters); 158 let substs = from_chalk(db, trait_ref.parameters);
146 TraitRef { trait_, substs } 159 TraitRef { trait_, substs }
@@ -151,11 +164,11 @@ impl ToChalk for Trait {
151 type Chalk = chalk_ir::TraitId; 164 type Chalk = chalk_ir::TraitId;
152 165
153 fn to_chalk(self, _db: &impl HirDatabase) -> chalk_ir::TraitId { 166 fn to_chalk(self, _db: &impl HirDatabase) -> chalk_ir::TraitId {
154 self.id.into() 167 chalk_ir::TraitId(id_to_chalk(self.id))
155 } 168 }
156 169
157 fn from_chalk(_db: &impl HirDatabase, trait_id: chalk_ir::TraitId) -> Trait { 170 fn from_chalk(_db: &impl HirDatabase, trait_id: chalk_ir::TraitId) -> Trait {
158 Trait { id: trait_id.into() } 171 Trait { id: id_from_chalk(trait_id.0) }
159 } 172 }
160} 173}
161 174
@@ -187,18 +200,18 @@ impl ToChalk for TypeAlias {
187 type Chalk = chalk_ir::TypeId; 200 type Chalk = chalk_ir::TypeId;
188 201
189 fn to_chalk(self, _db: &impl HirDatabase) -> chalk_ir::TypeId { 202 fn to_chalk(self, _db: &impl HirDatabase) -> chalk_ir::TypeId {
190 self.id.into() 203 chalk_ir::TypeId(id_to_chalk(self.id))
191 } 204 }
192 205
193 fn from_chalk(_db: &impl HirDatabase, impl_id: chalk_ir::TypeId) -> TypeAlias { 206 fn from_chalk(_db: &impl HirDatabase, type_alias_id: chalk_ir::TypeId) -> TypeAlias {
194 TypeAlias { id: impl_id.into() } 207 TypeAlias { id: id_from_chalk(type_alias_id.0) }
195 } 208 }
196} 209}
197 210
198impl ToChalk for GenericPredicate { 211impl ToChalk for GenericPredicate {
199 type Chalk = chalk_ir::QuantifiedWhereClause; 212 type Chalk = chalk_ir::QuantifiedWhereClause<ChalkIr>;
200 213
201 fn to_chalk(self, db: &impl HirDatabase) -> chalk_ir::QuantifiedWhereClause { 214 fn to_chalk(self, db: &impl HirDatabase) -> chalk_ir::QuantifiedWhereClause<ChalkIr> {
202 match self { 215 match self {
203 GenericPredicate::Implemented(trait_ref) => { 216 GenericPredicate::Implemented(trait_ref) => {
204 make_binders(chalk_ir::WhereClause::Implemented(trait_ref.to_chalk(db)), 0) 217 make_binders(chalk_ir::WhereClause::Implemented(trait_ref.to_chalk(db)), 0)
@@ -221,25 +234,40 @@ impl ToChalk for GenericPredicate {
221 } 234 }
222 235
223 fn from_chalk( 236 fn from_chalk(
224 _db: &impl HirDatabase, 237 db: &impl HirDatabase,
225 _where_clause: chalk_ir::QuantifiedWhereClause, 238 where_clause: chalk_ir::QuantifiedWhereClause<ChalkIr>,
226 ) -> GenericPredicate { 239 ) -> GenericPredicate {
227 // This should never need to be called 240 match where_clause.value {
228 unimplemented!() 241 chalk_ir::WhereClause::Implemented(tr) => {
242 if tr.trait_id == UNKNOWN_TRAIT {
243 // FIXME we need an Error enum on the Chalk side to avoid this
244 return GenericPredicate::Error;
245 }
246 GenericPredicate::Implemented(from_chalk(db, tr))
247 }
248 chalk_ir::WhereClause::ProjectionEq(projection_eq) => {
249 let projection_ty = from_chalk(db, projection_eq.projection);
250 let ty = from_chalk(db, projection_eq.ty);
251 GenericPredicate::Projection(super::ProjectionPredicate { projection_ty, ty })
252 }
253 }
229 } 254 }
230} 255}
231 256
232impl ToChalk for ProjectionTy { 257impl ToChalk for ProjectionTy {
233 type Chalk = chalk_ir::ProjectionTy; 258 type Chalk = chalk_ir::ProjectionTy<ChalkIr>;
234 259
235 fn to_chalk(self, db: &impl HirDatabase) -> chalk_ir::ProjectionTy { 260 fn to_chalk(self, db: &impl HirDatabase) -> chalk_ir::ProjectionTy<ChalkIr> {
236 chalk_ir::ProjectionTy { 261 chalk_ir::ProjectionTy {
237 associated_ty_id: self.associated_ty.to_chalk(db), 262 associated_ty_id: self.associated_ty.to_chalk(db),
238 parameters: self.parameters.to_chalk(db), 263 parameters: self.parameters.to_chalk(db),
239 } 264 }
240 } 265 }
241 266
242 fn from_chalk(db: &impl HirDatabase, projection_ty: chalk_ir::ProjectionTy) -> ProjectionTy { 267 fn from_chalk(
268 db: &impl HirDatabase,
269 projection_ty: chalk_ir::ProjectionTy<ChalkIr>,
270 ) -> ProjectionTy {
243 ProjectionTy { 271 ProjectionTy {
244 associated_ty: from_chalk(db, projection_ty.associated_ty_id), 272 associated_ty: from_chalk(db, projection_ty.associated_ty_id),
245 parameters: from_chalk(db, projection_ty.parameters), 273 parameters: from_chalk(db, projection_ty.parameters),
@@ -248,31 +276,31 @@ impl ToChalk for ProjectionTy {
248} 276}
249 277
250impl ToChalk for super::ProjectionPredicate { 278impl ToChalk for super::ProjectionPredicate {
251 type Chalk = chalk_ir::Normalize; 279 type Chalk = chalk_ir::Normalize<ChalkIr>;
252 280
253 fn to_chalk(self, db: &impl HirDatabase) -> chalk_ir::Normalize { 281 fn to_chalk(self, db: &impl HirDatabase) -> chalk_ir::Normalize<ChalkIr> {
254 chalk_ir::Normalize { 282 chalk_ir::Normalize {
255 projection: self.projection_ty.to_chalk(db), 283 projection: self.projection_ty.to_chalk(db),
256 ty: self.ty.to_chalk(db), 284 ty: self.ty.to_chalk(db),
257 } 285 }
258 } 286 }
259 287
260 fn from_chalk(_db: &impl HirDatabase, _normalize: chalk_ir::Normalize) -> Self { 288 fn from_chalk(_db: &impl HirDatabase, _normalize: chalk_ir::Normalize<ChalkIr>) -> Self {
261 unimplemented!() 289 unimplemented!()
262 } 290 }
263} 291}
264 292
265impl ToChalk for Obligation { 293impl ToChalk for Obligation {
266 type Chalk = chalk_ir::DomainGoal; 294 type Chalk = chalk_ir::DomainGoal<ChalkIr>;
267 295
268 fn to_chalk(self, db: &impl HirDatabase) -> chalk_ir::DomainGoal { 296 fn to_chalk(self, db: &impl HirDatabase) -> chalk_ir::DomainGoal<ChalkIr> {
269 match self { 297 match self {
270 Obligation::Trait(tr) => tr.to_chalk(db).cast(), 298 Obligation::Trait(tr) => tr.to_chalk(db).cast(),
271 Obligation::Projection(pr) => pr.to_chalk(db).cast(), 299 Obligation::Projection(pr) => pr.to_chalk(db).cast(),
272 } 300 }
273 } 301 }
274 302
275 fn from_chalk(_db: &impl HirDatabase, _goal: chalk_ir::DomainGoal) -> Self { 303 fn from_chalk(_db: &impl HirDatabase, _goal: chalk_ir::DomainGoal<ChalkIr>) -> Self {
276 unimplemented!() 304 unimplemented!()
277 } 305 }
278} 306}
@@ -296,16 +324,16 @@ where
296} 324}
297 325
298impl ToChalk for Arc<super::TraitEnvironment> { 326impl ToChalk for Arc<super::TraitEnvironment> {
299 type Chalk = Arc<chalk_ir::Environment>; 327 type Chalk = chalk_ir::Environment<ChalkIr>;
300 328
301 fn to_chalk(self, db: &impl HirDatabase) -> Arc<chalk_ir::Environment> { 329 fn to_chalk(self, db: &impl HirDatabase) -> chalk_ir::Environment<ChalkIr> {
302 let mut clauses = Vec::new(); 330 let mut clauses = Vec::new();
303 for pred in &self.predicates { 331 for pred in &self.predicates {
304 if pred.is_error() { 332 if pred.is_error() {
305 // for env, we just ignore errors 333 // for env, we just ignore errors
306 continue; 334 continue;
307 } 335 }
308 let program_clause: chalk_ir::ProgramClause = pred.clone().to_chalk(db).cast(); 336 let program_clause: chalk_ir::ProgramClause<ChalkIr> = pred.clone().to_chalk(db).cast();
309 clauses.push(program_clause.into_from_env_clause()); 337 clauses.push(program_clause.into_from_env_clause());
310 } 338 }
311 chalk_ir::Environment::new().add_clauses(clauses) 339 chalk_ir::Environment::new().add_clauses(clauses)
@@ -313,13 +341,16 @@ impl ToChalk for Arc<super::TraitEnvironment> {
313 341
314 fn from_chalk( 342 fn from_chalk(
315 _db: &impl HirDatabase, 343 _db: &impl HirDatabase,
316 _env: Arc<chalk_ir::Environment>, 344 _env: chalk_ir::Environment<ChalkIr>,
317 ) -> Arc<super::TraitEnvironment> { 345 ) -> Arc<super::TraitEnvironment> {
318 unimplemented!() 346 unimplemented!()
319 } 347 }
320} 348}
321 349
322impl<T: ToChalk> ToChalk for super::InEnvironment<T> { 350impl<T: ToChalk> ToChalk for super::InEnvironment<T>
351where
352 T::Chalk: chalk_ir::family::HasTypeFamily<TypeFamily = ChalkIr>,
353{
323 type Chalk = chalk_ir::InEnvironment<T::Chalk>; 354 type Chalk = chalk_ir::InEnvironment<T::Chalk>;
324 355
325 fn to_chalk(self, db: &impl HirDatabase) -> chalk_ir::InEnvironment<T::Chalk> { 356 fn to_chalk(self, db: &impl HirDatabase) -> chalk_ir::InEnvironment<T::Chalk> {
@@ -351,7 +382,7 @@ fn convert_where_clauses(
351 db: &impl HirDatabase, 382 db: &impl HirDatabase,
352 def: GenericDef, 383 def: GenericDef,
353 substs: &Substs, 384 substs: &Substs,
354) -> Vec<chalk_ir::QuantifiedWhereClause> { 385) -> Vec<chalk_ir::QuantifiedWhereClause<ChalkIr>> {
355 let generic_predicates = db.generic_predicates(def); 386 let generic_predicates = db.generic_predicates(def);
356 let mut result = Vec::with_capacity(generic_predicates.len()); 387 let mut result = Vec::with_capacity(generic_predicates.len());
357 for pred in generic_predicates.iter() { 388 for pred in generic_predicates.iter() {
@@ -384,7 +415,7 @@ where
384 fn impls_for_trait( 415 fn impls_for_trait(
385 &self, 416 &self,
386 trait_id: chalk_ir::TraitId, 417 trait_id: chalk_ir::TraitId,
387 parameters: &[Parameter], 418 parameters: &[Parameter<ChalkIr>],
388 ) -> Vec<ImplId> { 419 ) -> Vec<ImplId> {
389 debug!("impls_for_trait {:?}", trait_id); 420 debug!("impls_for_trait {:?}", trait_id);
390 if trait_id == UNKNOWN_TRAIT { 421 if trait_id == UNKNOWN_TRAIT {
@@ -430,13 +461,13 @@ where
430 } 461 }
431 fn split_projection<'p>( 462 fn split_projection<'p>(
432 &self, 463 &self,
433 projection: &'p chalk_ir::ProjectionTy, 464 projection: &'p chalk_ir::ProjectionTy<ChalkIr>,
434 ) -> (Arc<AssociatedTyDatum>, &'p [Parameter], &'p [Parameter]) { 465 ) -> (Arc<AssociatedTyDatum>, &'p [Parameter<ChalkIr>], &'p [Parameter<ChalkIr>]) {
435 debug!("split_projection {:?}", projection); 466 debug!("split_projection {:?}", projection);
436 // we don't support GATs, so I think this should always be correct currently 467 // we don't support GATs, so I think this should always be correct currently
437 (self.db.associated_ty_data(projection.associated_ty_id), &projection.parameters, &[]) 468 (self.db.associated_ty_data(projection.associated_ty_id), &projection.parameters, &[])
438 } 469 }
439 fn custom_clauses(&self) -> Vec<chalk_ir::ProgramClause> { 470 fn custom_clauses(&self) -> Vec<chalk_ir::ProgramClause<ChalkIr>> {
440 vec![] 471 vec![]
441 } 472 }
442 fn local_impls_to_coherence_check( 473 fn local_impls_to_coherence_check(
@@ -508,7 +539,7 @@ pub(crate) fn trait_datum_query(
508 let trait_ref = trait_.trait_ref(db).subst(&bound_vars).to_chalk(db); 539 let trait_ref = trait_.trait_ref(db).subst(&bound_vars).to_chalk(db);
509 let flags = chalk_rust_ir::TraitFlags { 540 let flags = chalk_rust_ir::TraitFlags {
510 auto: trait_.is_auto(db), 541 auto: trait_.is_auto(db),
511 upstream: trait_.module(db).krate(db) != Some(krate), 542 upstream: trait_.module(db).krate() != krate,
512 non_enumerable: true, 543 non_enumerable: true,
513 // FIXME set these flags correctly 544 // FIXME set these flags correctly
514 marker: false, 545 marker: false,
@@ -596,7 +627,7 @@ fn impl_block_datum(
596 .target_trait_ref(db) 627 .target_trait_ref(db)
597 .expect("FIXME handle unresolved impl block trait ref") 628 .expect("FIXME handle unresolved impl block trait ref")
598 .subst(&bound_vars); 629 .subst(&bound_vars);
599 let impl_type = if impl_block.module().krate(db) == Some(krate) { 630 let impl_type = if impl_block.module().krate() == krate {
600 chalk_rust_ir::ImplType::Local 631 chalk_rust_ir::ImplType::Local
601 } else { 632 } else {
602 chalk_rust_ir::ImplType::External 633 chalk_rust_ir::ImplType::External
@@ -705,7 +736,7 @@ fn closure_fn_trait_impl_datum(
705 substs: Substs::build_for_def(db, trait_).push(self_ty).push(arg_ty).build(), 736 substs: Substs::build_for_def(db, trait_).push(self_ty).push(arg_ty).build(),
706 }; 737 };
707 738
708 let output_ty_id = fn_once_trait.associated_type_by_name(db, &crate::name::OUTPUT_TYPE)?; 739 let output_ty_id = fn_once_trait.associated_type_by_name(db, &name::OUTPUT_TYPE)?;
709 740
710 let output_ty_value = chalk_rust_ir::AssociatedTyValue { 741 let output_ty_value = chalk_rust_ir::AssociatedTyValue {
711 associated_ty_id: output_ty_id.to_chalk(db), 742 associated_ty_id: output_ty_id.to_chalk(db),
@@ -746,30 +777,6 @@ fn id_to_chalk<T: InternKey>(salsa_id: T) -> chalk_ir::RawId {
746 chalk_ir::RawId { index: salsa_id.as_intern_id().as_u32() } 777 chalk_ir::RawId { index: salsa_id.as_intern_id().as_u32() }
747} 778}
748 779
749impl From<chalk_ir::TraitId> for crate::ids::TraitId {
750 fn from(trait_id: chalk_ir::TraitId) -> Self {
751 id_from_chalk(trait_id.0)
752 }
753}
754
755impl From<crate::ids::TraitId> for chalk_ir::TraitId {
756 fn from(trait_id: crate::ids::TraitId) -> Self {
757 chalk_ir::TraitId(id_to_chalk(trait_id))
758 }
759}
760
761impl From<chalk_ir::TypeId> for crate::ids::TypeAliasId {
762 fn from(type_id: chalk_ir::TypeId) -> Self {
763 id_from_chalk(type_id.0)
764 }
765}
766
767impl From<crate::ids::TypeAliasId> for chalk_ir::TypeId {
768 fn from(type_id: crate::ids::TypeAliasId) -> Self {
769 chalk_ir::TypeId(id_to_chalk(type_id))
770 }
771}
772
773impl From<chalk_ir::StructId> for crate::ids::TypeCtorId { 780impl From<chalk_ir::StructId> for crate::ids::TypeCtorId {
774 fn from(struct_id: chalk_ir::StructId) -> Self { 781 fn from(struct_id: chalk_ir::StructId) -> Self {
775 id_from_chalk(struct_id.0) 782 id_from_chalk(struct_id.0)