From 0f058d61cea9805897702654bcca146fd0cdc507 Mon Sep 17 00:00:00 2001 From: Florian Diebold Date: Thu, 8 Apr 2021 13:32:48 +0200 Subject: Replace remaining `fold` calls --- crates/hir_ty/src/infer.rs | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) (limited to 'crates/hir_ty/src/infer.rs') 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; use std::ops::Index; use std::sync::Arc; -use chalk_ir::{cast::Cast, Mutability}; +use chalk_ir::{cast::Cast, DebruijnIndex, Mutability}; use hir_def::{ body::Body, data::{ConstData, FunctionData, StaticData}, @@ -41,8 +41,9 @@ use super::{ TypeWalk, }; use crate::{ - db::HirDatabase, infer::diagnostics::InferenceDiagnostic, lower::ImplTraitLoweringMode, - to_assoc_type_id, AliasEq, AliasTy, Canonical, Interner, TyBuilder, TyExt, TyKind, + db::HirDatabase, fold_tys, infer::diagnostics::InferenceDiagnostic, + lower::ImplTraitLoweringMode, to_assoc_type_id, AliasEq, AliasTy, Canonical, Interner, + TyBuilder, TyExt, TyKind, }; // This lint has a false positive here. See the link below for details. @@ -323,7 +324,7 @@ impl<'a> InferenceContext<'a> { } fn insert_type_vars(&mut self, ty: Ty) -> Ty { - ty.fold(&mut |ty| self.insert_type_vars_shallow(ty)) + fold_tys(ty, |ty, _| self.insert_type_vars_shallow(ty), DebruijnIndex::INNERMOST) } fn resolve_obligations_as_possible(&mut self) { @@ -434,12 +435,16 @@ impl<'a> InferenceContext<'a> { /// to do it as well. fn normalize_associated_types_in(&mut self, ty: Ty) -> Ty { let ty = self.resolve_ty_as_possible(ty); - ty.fold(&mut |ty| match ty.kind(&Interner) { - TyKind::Alias(AliasTy::Projection(proj_ty)) => { - self.normalize_projection_ty(proj_ty.clone()) - } - _ => ty, - }) + fold_tys( + ty, + |ty, _| match ty.kind(&Interner) { + TyKind::Alias(AliasTy::Projection(proj_ty)) => { + self.normalize_projection_ty(proj_ty.clone()) + } + _ => ty, + }, + DebruijnIndex::INNERMOST, + ) } fn normalize_projection_ty(&mut self, proj_ty: ProjectionTy) -> Ty { -- cgit v1.2.3 From d992736e796501b2a5ae232644924a3dfefede92 Mon Sep 17 00:00:00 2001 From: Florian Diebold Date: Thu, 8 Apr 2021 14:35:15 +0200 Subject: Remove unused --- crates/hir_ty/src/infer.rs | 1 - 1 file changed, 1 deletion(-) (limited to 'crates/hir_ty/src/infer.rs') diff --git a/crates/hir_ty/src/infer.rs b/crates/hir_ty/src/infer.rs index 1d8184ef5..bf2da2d4a 100644 --- a/crates/hir_ty/src/infer.rs +++ b/crates/hir_ty/src/infer.rs @@ -38,7 +38,6 @@ use syntax::SmolStr; use super::{ DomainGoal, Guidance, InEnvironment, ProjectionTy, Solution, TraitEnvironment, TraitRef, Ty, - TypeWalk, }; use crate::{ db::HirDatabase, fold_tys, infer::diagnostics::InferenceDiagnostic, -- cgit v1.2.3