diff options
Diffstat (limited to 'crates/hir_ty/src/infer.rs')
-rw-r--r-- | crates/hir_ty/src/infer.rs | 25 |
1 files changed, 15 insertions, 10 deletions
diff --git a/crates/hir_ty/src/infer.rs b/crates/hir_ty/src/infer.rs index 531159e54..1d8184ef5 100644 --- a/crates/hir_ty/src/infer.rs +++ b/crates/hir_ty/src/infer.rs | |||
@@ -18,7 +18,7 @@ use std::mem; | |||
18 | use std::ops::Index; | 18 | use std::ops::Index; |
19 | use std::sync::Arc; | 19 | use std::sync::Arc; |
20 | 20 | ||
21 | use chalk_ir::{cast::Cast, Mutability}; | 21 | use chalk_ir::{cast::Cast, DebruijnIndex, Mutability}; |
22 | use hir_def::{ | 22 | use hir_def::{ |
23 | body::Body, | 23 | body::Body, |
24 | data::{ConstData, FunctionData, StaticData}, | 24 | data::{ConstData, FunctionData, StaticData}, |
@@ -41,8 +41,9 @@ use super::{ | |||
41 | TypeWalk, | 41 | TypeWalk, |
42 | }; | 42 | }; |
43 | use crate::{ | 43 | use crate::{ |
44 | db::HirDatabase, infer::diagnostics::InferenceDiagnostic, lower::ImplTraitLoweringMode, | 44 | db::HirDatabase, fold_tys, infer::diagnostics::InferenceDiagnostic, |
45 | to_assoc_type_id, AliasEq, AliasTy, Canonical, Interner, TyBuilder, TyExt, TyKind, | 45 | lower::ImplTraitLoweringMode, to_assoc_type_id, AliasEq, AliasTy, Canonical, Interner, |
46 | TyBuilder, TyExt, TyKind, | ||
46 | }; | 47 | }; |
47 | 48 | ||
48 | // This lint has a false positive here. See the link below for details. | 49 | // This lint has a false positive here. See the link below for details. |
@@ -323,7 +324,7 @@ impl<'a> InferenceContext<'a> { | |||
323 | } | 324 | } |
324 | 325 | ||
325 | fn insert_type_vars(&mut self, ty: Ty) -> Ty { | 326 | fn insert_type_vars(&mut self, ty: Ty) -> Ty { |
326 | ty.fold(&mut |ty| self.insert_type_vars_shallow(ty)) | 327 | fold_tys(ty, |ty, _| self.insert_type_vars_shallow(ty), DebruijnIndex::INNERMOST) |
327 | } | 328 | } |
328 | 329 | ||
329 | fn resolve_obligations_as_possible(&mut self) { | 330 | fn resolve_obligations_as_possible(&mut self) { |
@@ -434,12 +435,16 @@ impl<'a> InferenceContext<'a> { | |||
434 | /// to do it as well. | 435 | /// to do it as well. |
435 | fn normalize_associated_types_in(&mut self, ty: Ty) -> Ty { | 436 | fn normalize_associated_types_in(&mut self, ty: Ty) -> Ty { |
436 | let ty = self.resolve_ty_as_possible(ty); | 437 | let ty = self.resolve_ty_as_possible(ty); |
437 | ty.fold(&mut |ty| match ty.kind(&Interner) { | 438 | fold_tys( |
438 | TyKind::Alias(AliasTy::Projection(proj_ty)) => { | 439 | ty, |
439 | self.normalize_projection_ty(proj_ty.clone()) | 440 | |ty, _| match ty.kind(&Interner) { |
440 | } | 441 | TyKind::Alias(AliasTy::Projection(proj_ty)) => { |
441 | _ => ty, | 442 | self.normalize_projection_ty(proj_ty.clone()) |
442 | }) | 443 | } |
444 | _ => ty, | ||
445 | }, | ||
446 | DebruijnIndex::INNERMOST, | ||
447 | ) | ||
443 | } | 448 | } |
444 | 449 | ||
445 | fn normalize_projection_ty(&mut self, proj_ty: ProjectionTy) -> Ty { | 450 | fn normalize_projection_ty(&mut self, proj_ty: ProjectionTy) -> Ty { |