diff options
Diffstat (limited to 'crates/ra_hir/src')
-rw-r--r-- | crates/ra_hir/src/code_model.rs | 8 | ||||
-rw-r--r-- | crates/ra_hir/src/ty.rs | 66 | ||||
-rw-r--r-- | crates/ra_hir/src/ty/autoderef.rs | 2 | ||||
-rw-r--r-- | crates/ra_hir/src/ty/infer/expr.rs | 12 | ||||
-rw-r--r-- | crates/ra_hir/src/ty/lower.rs | 9 | ||||
-rw-r--r-- | crates/ra_hir/src/ty/traits.rs | 5 | ||||
-rw-r--r-- | crates/ra_hir/src/ty/traits/chalk.rs | 30 |
7 files changed, 70 insertions, 62 deletions
diff --git a/crates/ra_hir/src/code_model.rs b/crates/ra_hir/src/code_model.rs index ae730beb5..f7fc80d4e 100644 --- a/crates/ra_hir/src/code_model.rs +++ b/crates/ra_hir/src/code_model.rs | |||
@@ -538,14 +538,6 @@ pub enum DefWithBody { | |||
538 | impl_froms!(DefWithBody: Function, Const, Static); | 538 | impl_froms!(DefWithBody: Function, Const, Static); |
539 | 539 | ||
540 | impl DefWithBody { | 540 | impl DefWithBody { |
541 | pub(crate) fn krate(self, db: &impl HirDatabase) -> Option<Crate> { | ||
542 | match self { | ||
543 | DefWithBody::Const(c) => c.krate(db), | ||
544 | DefWithBody::Function(f) => f.krate(db), | ||
545 | DefWithBody::Static(s) => s.krate(db), | ||
546 | } | ||
547 | } | ||
548 | |||
549 | pub fn module(self, db: &impl HirDatabase) -> Module { | 541 | pub fn module(self, db: &impl HirDatabase) -> Module { |
550 | match self { | 542 | match self { |
551 | DefWithBody::Const(c) => c.module(db), | 543 | DefWithBody::Const(c) => c.module(db), |
diff --git a/crates/ra_hir/src/ty.rs b/crates/ra_hir/src/ty.rs index 3cbcbd1d0..388530f31 100644 --- a/crates/ra_hir/src/ty.rs +++ b/crates/ra_hir/src/ty.rs | |||
@@ -17,12 +17,15 @@ use std::ops::Deref; | |||
17 | use std::sync::Arc; | 17 | use std::sync::Arc; |
18 | use std::{fmt, iter, mem}; | 18 | use std::{fmt, iter, mem}; |
19 | 19 | ||
20 | use hir_def::{generics::GenericParams, AdtId, GenericDefId}; | 20 | use hir_def::{ |
21 | generics::GenericParams, AdtId, ContainerId, DefWithBodyId, GenericDefId, HasModule, Lookup, | ||
22 | TraitId, TypeAliasId, | ||
23 | }; | ||
21 | use ra_db::{impl_intern_key, salsa}; | 24 | use ra_db::{impl_intern_key, salsa}; |
22 | 25 | ||
23 | use crate::{ | 26 | use crate::{ |
24 | db::HirDatabase, expr::ExprId, util::make_mut_slice, Adt, Crate, DefWithBody, FloatTy, IntTy, | 27 | db::HirDatabase, expr::ExprId, util::make_mut_slice, Adt, Crate, FloatTy, IntTy, Mutability, |
25 | Mutability, Name, Trait, TypeAlias, Uncertain, | 28 | Name, Trait, Uncertain, |
26 | }; | 29 | }; |
27 | use display::{HirDisplay, HirFormatter}; | 30 | use display::{HirDisplay, HirFormatter}; |
28 | 31 | ||
@@ -107,13 +110,13 @@ pub enum TypeCtor { | |||
107 | /// when we have tried to normalize a projection like `T::Item` but | 110 | /// when we have tried to normalize a projection like `T::Item` but |
108 | /// couldn't find a better representation. In that case, we generate | 111 | /// couldn't find a better representation. In that case, we generate |
109 | /// an **application type** like `(Iterator::Item)<T>`. | 112 | /// an **application type** like `(Iterator::Item)<T>`. |
110 | AssociatedType(TypeAlias), | 113 | AssociatedType(TypeAliasId), |
111 | 114 | ||
112 | /// The type of a specific closure. | 115 | /// The type of a specific closure. |
113 | /// | 116 | /// |
114 | /// The closure signature is stored in a `FnPtr` type in the first type | 117 | /// The closure signature is stored in a `FnPtr` type in the first type |
115 | /// parameter. | 118 | /// parameter. |
116 | Closure { def: DefWithBody, expr: ExprId }, | 119 | Closure { def: DefWithBodyId, expr: ExprId }, |
117 | } | 120 | } |
118 | 121 | ||
119 | /// This exists just for Chalk, because Chalk just has a single `StructId` where | 122 | /// This exists just for Chalk, because Chalk just has a single `StructId` where |
@@ -147,7 +150,7 @@ impl TypeCtor { | |||
147 | generic_params.count_params_including_parent() | 150 | generic_params.count_params_including_parent() |
148 | } | 151 | } |
149 | TypeCtor::AssociatedType(type_alias) => { | 152 | TypeCtor::AssociatedType(type_alias) => { |
150 | let generic_params = db.generic_params(type_alias.id.into()); | 153 | let generic_params = db.generic_params(type_alias.into()); |
151 | generic_params.count_params_including_parent() | 154 | generic_params.count_params_including_parent() |
152 | } | 155 | } |
153 | TypeCtor::FnPtr { num_args } => num_args as usize + 1, | 156 | TypeCtor::FnPtr { num_args } => num_args as usize + 1, |
@@ -169,10 +172,13 @@ impl TypeCtor { | |||
169 | | TypeCtor::Ref(_) | 172 | | TypeCtor::Ref(_) |
170 | | TypeCtor::FnPtr { .. } | 173 | | TypeCtor::FnPtr { .. } |
171 | | TypeCtor::Tuple { .. } => None, | 174 | | TypeCtor::Tuple { .. } => None, |
172 | TypeCtor::Closure { def, .. } => def.krate(db), | 175 | // Closure's krate is irrelevant for coherence I would think? |
176 | TypeCtor::Closure { .. } => None, | ||
173 | TypeCtor::Adt(adt) => adt.krate(db), | 177 | TypeCtor::Adt(adt) => adt.krate(db), |
174 | TypeCtor::FnDef(callable) => Some(callable.krate(db).into()), | 178 | TypeCtor::FnDef(callable) => Some(callable.krate(db).into()), |
175 | TypeCtor::AssociatedType(type_alias) => type_alias.krate(db), | 179 | TypeCtor::AssociatedType(type_alias) => { |
180 | Some(type_alias.lookup(db).module(db).krate.into()) | ||
181 | } | ||
176 | } | 182 | } |
177 | } | 183 | } |
178 | 184 | ||
@@ -193,7 +199,7 @@ impl TypeCtor { | |||
193 | | TypeCtor::Closure { .. } => None, | 199 | | TypeCtor::Closure { .. } => None, |
194 | TypeCtor::Adt(adt) => Some(adt.into()), | 200 | TypeCtor::Adt(adt) => Some(adt.into()), |
195 | TypeCtor::FnDef(callable) => Some(callable.into()), | 201 | TypeCtor::FnDef(callable) => Some(callable.into()), |
196 | TypeCtor::AssociatedType(type_alias) => Some(type_alias.id.into()), | 202 | TypeCtor::AssociatedType(type_alias) => Some(type_alias.into()), |
197 | } | 203 | } |
198 | } | 204 | } |
199 | } | 205 | } |
@@ -212,18 +218,19 @@ pub struct ApplicationTy { | |||
212 | /// trait and all its parameters are fully known. | 218 | /// trait and all its parameters are fully known. |
213 | #[derive(Clone, PartialEq, Eq, Debug, Hash)] | 219 | #[derive(Clone, PartialEq, Eq, Debug, Hash)] |
214 | pub struct ProjectionTy { | 220 | pub struct ProjectionTy { |
215 | pub associated_ty: TypeAlias, | 221 | pub associated_ty: TypeAliasId, |
216 | pub parameters: Substs, | 222 | pub parameters: Substs, |
217 | } | 223 | } |
218 | 224 | ||
219 | impl ProjectionTy { | 225 | impl ProjectionTy { |
220 | pub fn trait_ref(&self, db: &impl HirDatabase) -> TraitRef { | 226 | pub fn trait_ref(&self, db: &impl HirDatabase) -> TraitRef { |
221 | TraitRef { | 227 | TraitRef { trait_: self.trait_(db).into(), substs: self.parameters.clone() } |
222 | trait_: self | 228 | } |
223 | .associated_ty | 229 | |
224 | .parent_trait(db) | 230 | fn trait_(&self, db: &impl HirDatabase) -> TraitId { |
225 | .expect("projection ty without parent trait"), | 231 | match self.associated_ty.lookup(db).container { |
226 | substs: self.parameters.clone(), | 232 | ContainerId::TraitId(it) => it, |
233 | _ => panic!("projection ty without parent trait"), | ||
227 | } | 234 | } |
228 | } | 235 | } |
229 | } | 236 | } |
@@ -895,11 +902,12 @@ impl HirDisplay for ApplicationTy { | |||
895 | } | 902 | } |
896 | } | 903 | } |
897 | TypeCtor::AssociatedType(type_alias) => { | 904 | TypeCtor::AssociatedType(type_alias) => { |
898 | let trait_name = type_alias | 905 | let trait_ = match type_alias.lookup(f.db).container { |
899 | .parent_trait(f.db) | 906 | ContainerId::TraitId(it) => it, |
900 | .and_then(|t| t.name(f.db)) | 907 | _ => panic!("not an associated type"), |
901 | .unwrap_or_else(Name::missing); | 908 | }; |
902 | let name = type_alias.name(f.db); | 909 | let trait_name = f.db.trait_data(trait_).name.clone().unwrap_or_else(Name::missing); |
910 | let name = f.db.type_alias_data(type_alias).name.clone(); | ||
903 | write!(f, "{}::{}", trait_name, name)?; | 911 | write!(f, "{}::{}", trait_name, name)?; |
904 | if self.parameters.len() > 0 { | 912 | if self.parameters.len() > 0 { |
905 | write!(f, "<")?; | 913 | write!(f, "<")?; |
@@ -926,18 +934,15 @@ impl HirDisplay for ProjectionTy { | |||
926 | return write!(f, "…"); | 934 | return write!(f, "…"); |
927 | } | 935 | } |
928 | 936 | ||
929 | let trait_name = self | 937 | let trait_name = |
930 | .associated_ty | 938 | f.db.trait_data(self.trait_(f.db)).name.clone().unwrap_or_else(Name::missing); |
931 | .parent_trait(f.db) | ||
932 | .and_then(|t| t.name(f.db)) | ||
933 | .unwrap_or_else(Name::missing); | ||
934 | write!(f, "<{} as {}", self.parameters[0].display(f.db), trait_name,)?; | 939 | write!(f, "<{} as {}", self.parameters[0].display(f.db), trait_name,)?; |
935 | if self.parameters.len() > 1 { | 940 | if self.parameters.len() > 1 { |
936 | write!(f, "<")?; | 941 | write!(f, "<")?; |
937 | f.write_joined(&self.parameters[1..], ", ")?; | 942 | f.write_joined(&self.parameters[1..], ", ")?; |
938 | write!(f, ">")?; | 943 | write!(f, ">")?; |
939 | } | 944 | } |
940 | write!(f, ">::{}", self.associated_ty.name(f.db))?; | 945 | write!(f, ">::{}", f.db.type_alias_data(self.associated_ty).name)?; |
941 | Ok(()) | 946 | Ok(()) |
942 | } | 947 | } |
943 | } | 948 | } |
@@ -1000,7 +1005,10 @@ impl HirDisplay for Ty { | |||
1000 | write!(f, "<")?; | 1005 | write!(f, "<")?; |
1001 | angle_open = true; | 1006 | angle_open = true; |
1002 | } | 1007 | } |
1003 | let name = projection_pred.projection_ty.associated_ty.name(f.db); | 1008 | let name = |
1009 | f.db.type_alias_data(projection_pred.projection_ty.associated_ty) | ||
1010 | .name | ||
1011 | .clone(); | ||
1004 | write!(f, "{} = ", name)?; | 1012 | write!(f, "{} = ", name)?; |
1005 | projection_pred.ty.hir_fmt(f)?; | 1013 | projection_pred.ty.hir_fmt(f)?; |
1006 | } | 1014 | } |
@@ -1076,7 +1084,7 @@ impl HirDisplay for GenericPredicate { | |||
1076 | write!( | 1084 | write!( |
1077 | f, | 1085 | f, |
1078 | ">::{} = {}", | 1086 | ">::{} = {}", |
1079 | projection_pred.projection_ty.associated_ty.name(f.db), | 1087 | f.db.type_alias_data(projection_pred.projection_ty.associated_ty).name, |
1080 | projection_pred.ty.display(f.db) | 1088 | projection_pred.ty.display(f.db) |
1081 | )?; | 1089 | )?; |
1082 | } | 1090 | } |
diff --git a/crates/ra_hir/src/ty/autoderef.rs b/crates/ra_hir/src/ty/autoderef.rs index 44547197c..9e7593b8b 100644 --- a/crates/ra_hir/src/ty/autoderef.rs +++ b/crates/ra_hir/src/ty/autoderef.rs | |||
@@ -69,7 +69,7 @@ fn deref_by_trait( | |||
69 | 69 | ||
70 | let projection = super::traits::ProjectionPredicate { | 70 | let projection = super::traits::ProjectionPredicate { |
71 | ty: Ty::Bound(0), | 71 | ty: Ty::Bound(0), |
72 | projection_ty: super::ProjectionTy { associated_ty: target, parameters }, | 72 | projection_ty: super::ProjectionTy { associated_ty: target.id, parameters }, |
73 | }; | 73 | }; |
74 | 74 | ||
75 | let obligation = super::Obligation::Projection(projection); | 75 | let obligation = super::Obligation::Projection(projection); |
diff --git a/crates/ra_hir/src/ty/infer/expr.rs b/crates/ra_hir/src/ty/infer/expr.rs index 994a6d7e9..316cdc880 100644 --- a/crates/ra_hir/src/ty/infer/expr.rs +++ b/crates/ra_hir/src/ty/infer/expr.rs | |||
@@ -101,7 +101,7 @@ impl<'a, D: HirDatabase> InferenceContext<'a, D> { | |||
101 | let projection = ProjectionPredicate { | 101 | let projection = ProjectionPredicate { |
102 | ty: pat_ty.clone(), | 102 | ty: pat_ty.clone(), |
103 | projection_ty: ProjectionTy { | 103 | projection_ty: ProjectionTy { |
104 | associated_ty: into_iter_item_alias, | 104 | associated_ty: into_iter_item_alias.id, |
105 | parameters: Substs::single(iterable_ty), | 105 | parameters: Substs::single(iterable_ty), |
106 | }, | 106 | }, |
107 | }; | 107 | }; |
@@ -137,8 +137,10 @@ impl<'a, D: HirDatabase> InferenceContext<'a, D> { | |||
137 | TypeCtor::FnPtr { num_args: sig_tys.len() as u16 - 1 }, | 137 | TypeCtor::FnPtr { num_args: sig_tys.len() as u16 - 1 }, |
138 | Substs(sig_tys.into()), | 138 | Substs(sig_tys.into()), |
139 | ); | 139 | ); |
140 | let closure_ty = | 140 | let closure_ty = Ty::apply_one( |
141 | Ty::apply_one(TypeCtor::Closure { def: self.owner, expr: tgt_expr }, sig_ty); | 141 | TypeCtor::Closure { def: self.owner.into(), expr: tgt_expr }, |
142 | sig_ty, | ||
143 | ); | ||
142 | 144 | ||
143 | // Eagerly try to relate the closure type with the expected | 145 | // Eagerly try to relate the closure type with the expected |
144 | // type, otherwise we often won't have enough information to | 146 | // type, otherwise we often won't have enough information to |
@@ -281,7 +283,7 @@ impl<'a, D: HirDatabase> InferenceContext<'a, D> { | |||
281 | let projection = ProjectionPredicate { | 283 | let projection = ProjectionPredicate { |
282 | ty: ty.clone(), | 284 | ty: ty.clone(), |
283 | projection_ty: ProjectionTy { | 285 | projection_ty: ProjectionTy { |
284 | associated_ty: future_future_output_alias, | 286 | associated_ty: future_future_output_alias.id, |
285 | parameters: Substs::single(inner_ty), | 287 | parameters: Substs::single(inner_ty), |
286 | }, | 288 | }, |
287 | }; | 289 | }; |
@@ -300,7 +302,7 @@ impl<'a, D: HirDatabase> InferenceContext<'a, D> { | |||
300 | let projection = ProjectionPredicate { | 302 | let projection = ProjectionPredicate { |
301 | ty: ty.clone(), | 303 | ty: ty.clone(), |
302 | projection_ty: ProjectionTy { | 304 | projection_ty: ProjectionTy { |
303 | associated_ty: ops_try_ok_alias, | 305 | associated_ty: ops_try_ok_alias.id, |
304 | parameters: Substs::single(inner_ty), | 306 | parameters: Substs::single(inner_ty), |
305 | }, | 307 | }, |
306 | }; | 308 | }; |
diff --git a/crates/ra_hir/src/ty/lower.rs b/crates/ra_hir/src/ty/lower.rs index eb51d31bd..d7d4bb0d6 100644 --- a/crates/ra_hir/src/ty/lower.rs +++ b/crates/ra_hir/src/ty/lower.rs | |||
@@ -176,7 +176,7 @@ impl Ty { | |||
176 | Some(associated_ty) => { | 176 | Some(associated_ty) => { |
177 | // FIXME handle type parameters on the segment | 177 | // FIXME handle type parameters on the segment |
178 | Ty::Projection(ProjectionTy { | 178 | Ty::Projection(ProjectionTy { |
179 | associated_ty, | 179 | associated_ty: associated_ty.id, |
180 | parameters: trait_ref.substs, | 180 | parameters: trait_ref.substs, |
181 | }) | 181 | }) |
182 | } | 182 | } |
@@ -268,7 +268,10 @@ impl Ty { | |||
268 | .fill_with_unknown() | 268 | .fill_with_unknown() |
269 | .build(); | 269 | .build(); |
270 | // FIXME handle type parameters on the segment | 270 | // FIXME handle type parameters on the segment |
271 | return Ty::Projection(ProjectionTy { associated_ty, parameters: substs }); | 271 | return Ty::Projection(ProjectionTy { |
272 | associated_ty: associated_ty.id, | ||
273 | parameters: substs, | ||
274 | }); | ||
272 | } | 275 | } |
273 | } | 276 | } |
274 | Ty::Unknown | 277 | Ty::Unknown |
@@ -508,7 +511,7 @@ fn assoc_type_bindings_from_type_bound<'a>( | |||
508 | let associated_ty = | 511 | let associated_ty = |
509 | match trait_ref.trait_.associated_type_by_name_including_super_traits(db, &name) { | 512 | match trait_ref.trait_.associated_type_by_name_including_super_traits(db, &name) { |
510 | None => return GenericPredicate::Error, | 513 | None => return GenericPredicate::Error, |
511 | Some(t) => t, | 514 | Some(t) => t.id, |
512 | }; | 515 | }; |
513 | let projection_ty = | 516 | let projection_ty = |
514 | ProjectionTy { associated_ty, parameters: trait_ref.substs.clone() }; | 517 | ProjectionTy { associated_ty, parameters: trait_ref.substs.clone() }; |
diff --git a/crates/ra_hir/src/ty/traits.rs b/crates/ra_hir/src/ty/traits.rs index 268fa09e4..b9a5d651f 100644 --- a/crates/ra_hir/src/ty/traits.rs +++ b/crates/ra_hir/src/ty/traits.rs | |||
@@ -2,13 +2,14 @@ | |||
2 | use std::sync::{Arc, Mutex}; | 2 | use std::sync::{Arc, Mutex}; |
3 | 3 | ||
4 | use chalk_ir::{cast::Cast, family::ChalkIr}; | 4 | use chalk_ir::{cast::Cast, family::ChalkIr}; |
5 | use hir_def::DefWithBodyId; | ||
5 | use log::debug; | 6 | use log::debug; |
6 | use ra_db::{impl_intern_key, salsa}; | 7 | use ra_db::{impl_intern_key, salsa}; |
7 | use ra_prof::profile; | 8 | use ra_prof::profile; |
8 | use rustc_hash::FxHashSet; | 9 | use rustc_hash::FxHashSet; |
9 | 10 | ||
10 | use super::{Canonical, GenericPredicate, HirDisplay, ProjectionTy, TraitRef, Ty, TypeWalk}; | 11 | use super::{Canonical, GenericPredicate, HirDisplay, ProjectionTy, TraitRef, Ty, TypeWalk}; |
11 | use crate::{db::HirDatabase, expr::ExprId, Crate, DefWithBody, ImplBlock, Trait, TypeAlias}; | 12 | use crate::{db::HirDatabase, expr::ExprId, Crate, ImplBlock, Trait, TypeAlias}; |
12 | 13 | ||
13 | use self::chalk::{from_chalk, ToChalk}; | 14 | use self::chalk::{from_chalk, ToChalk}; |
14 | 15 | ||
@@ -290,7 +291,7 @@ impl FnTrait { | |||
290 | 291 | ||
291 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | 292 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] |
292 | pub struct ClosureFnTraitImplData { | 293 | pub struct ClosureFnTraitImplData { |
293 | def: DefWithBody, | 294 | def: DefWithBodyId, |
294 | expr: ExprId, | 295 | expr: ExprId, |
295 | fn_trait: FnTrait, | 296 | fn_trait: FnTrait, |
296 | } | 297 | } |
diff --git a/crates/ra_hir/src/ty/traits/chalk.rs b/crates/ra_hir/src/ty/traits/chalk.rs index 0272dd9ae..06388a3ce 100644 --- a/crates/ra_hir/src/ty/traits/chalk.rs +++ b/crates/ra_hir/src/ty/traits/chalk.rs | |||
@@ -9,7 +9,7 @@ use chalk_ir::{ | |||
9 | }; | 9 | }; |
10 | use chalk_rust_ir::{AssociatedTyDatum, AssociatedTyValue, ImplDatum, StructDatum, TraitDatum}; | 10 | use chalk_rust_ir::{AssociatedTyDatum, AssociatedTyValue, ImplDatum, StructDatum, TraitDatum}; |
11 | 11 | ||
12 | use hir_def::{lang_item::LangItemTarget, GenericDefId}; | 12 | use hir_def::{lang_item::LangItemTarget, ContainerId, GenericDefId, Lookup, TypeAliasId}; |
13 | use hir_expand::name; | 13 | use hir_expand::name; |
14 | 14 | ||
15 | use ra_db::salsa::{InternId, InternKey}; | 15 | use ra_db::salsa::{InternId, InternKey}; |
@@ -203,15 +203,15 @@ impl ToChalk for Impl { | |||
203 | } | 203 | } |
204 | } | 204 | } |
205 | 205 | ||
206 | impl ToChalk for TypeAlias { | 206 | impl ToChalk for TypeAliasId { |
207 | type Chalk = chalk_ir::TypeId; | 207 | type Chalk = chalk_ir::TypeId; |
208 | 208 | ||
209 | fn to_chalk(self, _db: &impl HirDatabase) -> chalk_ir::TypeId { | 209 | fn to_chalk(self, _db: &impl HirDatabase) -> chalk_ir::TypeId { |
210 | chalk_ir::TypeId(id_to_chalk(self.id)) | 210 | chalk_ir::TypeId(id_to_chalk(self)) |
211 | } | 211 | } |
212 | 212 | ||
213 | fn from_chalk(_db: &impl HirDatabase, type_alias_id: chalk_ir::TypeId) -> TypeAlias { | 213 | fn from_chalk(_db: &impl HirDatabase, type_alias_id: chalk_ir::TypeId) -> TypeAliasId { |
214 | TypeAlias { id: id_from_chalk(type_alias_id.0) } | 214 | id_from_chalk(type_alias_id.0) |
215 | } | 215 | } |
216 | } | 216 | } |
217 | 217 | ||
@@ -504,21 +504,21 @@ pub(crate) fn associated_ty_data_query( | |||
504 | id: TypeId, | 504 | id: TypeId, |
505 | ) -> Arc<AssociatedTyDatum<ChalkIr>> { | 505 | ) -> Arc<AssociatedTyDatum<ChalkIr>> { |
506 | debug!("associated_ty_data {:?}", id); | 506 | debug!("associated_ty_data {:?}", id); |
507 | let type_alias: TypeAlias = from_chalk(db, id); | 507 | let type_alias: TypeAliasId = from_chalk(db, id); |
508 | let trait_ = match type_alias.container(db) { | 508 | let trait_ = match type_alias.lookup(db).container { |
509 | Some(crate::Container::Trait(t)) => t, | 509 | ContainerId::TraitId(t) => t, |
510 | _ => panic!("associated type not in trait"), | 510 | _ => panic!("associated type not in trait"), |
511 | }; | 511 | }; |
512 | let generic_params = db.generic_params(type_alias.id.into()); | 512 | let generic_params = db.generic_params(type_alias.into()); |
513 | let bound_data = chalk_rust_ir::AssociatedTyDatumBound { | 513 | let bound_data = chalk_rust_ir::AssociatedTyDatumBound { |
514 | // FIXME add bounds and where clauses | 514 | // FIXME add bounds and where clauses |
515 | bounds: vec![], | 515 | bounds: vec![], |
516 | where_clauses: vec![], | 516 | where_clauses: vec![], |
517 | }; | 517 | }; |
518 | let datum = AssociatedTyDatum { | 518 | let datum = AssociatedTyDatum { |
519 | trait_id: trait_.to_chalk(db), | 519 | trait_id: Trait::from(trait_).to_chalk(db), |
520 | id, | 520 | id, |
521 | name: lalrpop_intern::intern(&type_alias.name(db).to_string()), | 521 | name: lalrpop_intern::intern(&db.type_alias_data(type_alias).name.to_string()), |
522 | binders: make_binders(bound_data, generic_params.count_params_including_parent()), | 522 | binders: make_binders(bound_data, generic_params.count_params_including_parent()), |
523 | }; | 523 | }; |
524 | Arc::new(datum) | 524 | Arc::new(datum) |
@@ -566,7 +566,7 @@ pub(crate) fn trait_datum_query( | |||
566 | .items(db) | 566 | .items(db) |
567 | .into_iter() | 567 | .into_iter() |
568 | .filter_map(|trait_item| match trait_item { | 568 | .filter_map(|trait_item| match trait_item { |
569 | crate::AssocItem::TypeAlias(type_alias) => Some(type_alias), | 569 | crate::AssocItem::TypeAlias(type_alias) => Some(type_alias.id), |
570 | _ => None, | 570 | _ => None, |
571 | }) | 571 | }) |
572 | .map(|type_alias| type_alias.to_chalk(db)) | 572 | .map(|type_alias| type_alias.to_chalk(db)) |
@@ -785,7 +785,8 @@ fn type_alias_associated_ty_value( | |||
785 | .trait_; | 785 | .trait_; |
786 | let assoc_ty = trait_ | 786 | let assoc_ty = trait_ |
787 | .associated_type_by_name(db, &type_alias.name(db)) | 787 | .associated_type_by_name(db, &type_alias.name(db)) |
788 | .expect("assoc ty value should not exist"); // validated when building the impl data as well | 788 | .expect("assoc ty value should not exist") // validated when building the impl data as well |
789 | .id; | ||
789 | let generic_params = db.generic_params(impl_block.id.into()); | 790 | let generic_params = db.generic_params(impl_block.id.into()); |
790 | let bound_vars = Substs::bound_vars(&generic_params); | 791 | let bound_vars = Substs::bound_vars(&generic_params); |
791 | let ty = db.type_for_def(type_alias.into(), crate::ty::Namespace::Types).subst(&bound_vars); | 792 | let ty = db.type_for_def(type_alias.into(), crate::ty::Namespace::Types).subst(&bound_vars); |
@@ -820,7 +821,8 @@ fn closure_fn_trait_output_assoc_ty_value( | |||
820 | 821 | ||
821 | let output_ty_id = fn_once_trait | 822 | let output_ty_id = fn_once_trait |
822 | .associated_type_by_name(db, &name::OUTPUT_TYPE) | 823 | .associated_type_by_name(db, &name::OUTPUT_TYPE) |
823 | .expect("assoc ty value should not exist"); | 824 | .expect("assoc ty value should not exist") |
825 | .id; | ||
824 | 826 | ||
825 | let value_bound = chalk_rust_ir::AssociatedTyValueBound { ty: output_ty.to_chalk(db) }; | 827 | let value_bound = chalk_rust_ir::AssociatedTyValueBound { ty: output_ty.to_chalk(db) }; |
826 | 828 | ||