diff options
Diffstat (limited to 'crates/ra_hir_ty/src/infer.rs')
-rw-r--r-- | crates/ra_hir_ty/src/infer.rs | 17 |
1 files changed, 8 insertions, 9 deletions
diff --git a/crates/ra_hir_ty/src/infer.rs b/crates/ra_hir_ty/src/infer.rs index e2eda3134..e27ce6e91 100644 --- a/crates/ra_hir_ty/src/infer.rs +++ b/crates/ra_hir_ty/src/infer.rs | |||
@@ -215,12 +215,13 @@ struct InferenceContext<'a, D: HirDatabase> { | |||
215 | 215 | ||
216 | impl<'a, D: HirDatabase> InferenceContext<'a, D> { | 216 | impl<'a, D: HirDatabase> InferenceContext<'a, D> { |
217 | fn new(db: &'a D, owner: DefWithBodyId, resolver: Resolver) -> Self { | 217 | fn new(db: &'a D, owner: DefWithBodyId, resolver: Resolver) -> Self { |
218 | let ctx = crate::lower::TyLoweringContext { db, resolver: &resolver }; | ||
218 | InferenceContext { | 219 | InferenceContext { |
219 | result: InferenceResult::default(), | 220 | result: InferenceResult::default(), |
220 | table: unify::InferenceTable::new(), | 221 | table: unify::InferenceTable::new(), |
221 | obligations: Vec::default(), | 222 | obligations: Vec::default(), |
222 | return_ty: Ty::Unknown, // set in collect_fn_signature | 223 | return_ty: Ty::Unknown, // set in collect_fn_signature |
223 | trait_env: TraitEnvironment::lower(db, &resolver), | 224 | trait_env: TraitEnvironment::lower(&ctx), |
224 | coerce_unsized_map: Self::init_coerce_unsized_map(db, &resolver), | 225 | coerce_unsized_map: Self::init_coerce_unsized_map(db, &resolver), |
225 | db, | 226 | db, |
226 | owner, | 227 | owner, |
@@ -272,12 +273,9 @@ impl<'a, D: HirDatabase> InferenceContext<'a, D> { | |||
272 | } | 273 | } |
273 | 274 | ||
274 | fn make_ty(&mut self, type_ref: &TypeRef) -> Ty { | 275 | fn make_ty(&mut self, type_ref: &TypeRef) -> Ty { |
275 | let ty = Ty::from_hir( | 276 | // FIXME use right resolver for block |
276 | self.db, | 277 | let ctx = crate::lower::TyLoweringContext { db: self.db, resolver: &self.resolver }; |
277 | // FIXME use right resolver for block | 278 | let ty = Ty::from_hir(&ctx, type_ref); |
278 | &self.resolver, | ||
279 | type_ref, | ||
280 | ); | ||
281 | let ty = self.insert_type_vars(ty); | 279 | let ty = self.insert_type_vars(ty); |
282 | self.normalize_associated_types_in(ty) | 280 | self.normalize_associated_types_in(ty) |
283 | } | 281 | } |
@@ -446,17 +444,18 @@ impl<'a, D: HirDatabase> InferenceContext<'a, D> { | |||
446 | None => return (Ty::Unknown, None), | 444 | None => return (Ty::Unknown, None), |
447 | }; | 445 | }; |
448 | let resolver = &self.resolver; | 446 | let resolver = &self.resolver; |
447 | let ctx = crate::lower::TyLoweringContext { db: self.db, resolver: &self.resolver }; | ||
449 | // FIXME: this should resolve assoc items as well, see this example: | 448 | // FIXME: this should resolve assoc items as well, see this example: |
450 | // https://play.rust-lang.org/?gist=087992e9e22495446c01c0d4e2d69521 | 449 | // https://play.rust-lang.org/?gist=087992e9e22495446c01c0d4e2d69521 |
451 | match resolver.resolve_path_in_type_ns_fully(self.db, path.mod_path()) { | 450 | match resolver.resolve_path_in_type_ns_fully(self.db, path.mod_path()) { |
452 | Some(TypeNs::AdtId(AdtId::StructId(strukt))) => { | 451 | Some(TypeNs::AdtId(AdtId::StructId(strukt))) => { |
453 | let substs = Ty::substs_from_path(self.db, resolver, path, strukt.into()); | 452 | let substs = Ty::substs_from_path(&ctx, path, strukt.into()); |
454 | let ty = self.db.ty(strukt.into()); | 453 | let ty = self.db.ty(strukt.into()); |
455 | let ty = self.insert_type_vars(ty.apply_substs(substs)); | 454 | let ty = self.insert_type_vars(ty.apply_substs(substs)); |
456 | (ty, Some(strukt.into())) | 455 | (ty, Some(strukt.into())) |
457 | } | 456 | } |
458 | Some(TypeNs::EnumVariantId(var)) => { | 457 | Some(TypeNs::EnumVariantId(var)) => { |
459 | let substs = Ty::substs_from_path(self.db, resolver, path, var.into()); | 458 | let substs = Ty::substs_from_path(&ctx, path, var.into()); |
460 | let ty = self.db.ty(var.parent.into()); | 459 | let ty = self.db.ty(var.parent.into()); |
461 | let ty = self.insert_type_vars(ty.apply_substs(substs)); | 460 | let ty = self.insert_type_vars(ty.apply_substs(substs)); |
462 | (ty, Some(var.into())) | 461 | (ty, Some(var.into())) |