From 8c3e372835243c922b0eff7ca23f79f227991e88 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Mon, 25 Nov 2019 13:10:26 +0300 Subject: Remove Resolver from autoderef Resolver holds onto too much context, including local scopes. Let's try to pass in only what is necessary -- the trait environment. --- crates/ra_hir/src/ty/lower.rs | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) (limited to 'crates/ra_hir/src/ty/lower.rs') diff --git a/crates/ra_hir/src/ty/lower.rs b/crates/ra_hir/src/ty/lower.rs index a39beb2a0..b76929501 100644 --- a/crates/ra_hir/src/ty/lower.rs +++ b/crates/ra_hir/src/ty/lower.rs @@ -19,8 +19,8 @@ use hir_def::{ use ra_arena::map::ArenaMap; use super::{ - FnSig, GenericPredicate, ProjectionPredicate, ProjectionTy, Substs, TraitRef, Ty, TypeCtor, - TypeWalk, + FnSig, GenericPredicate, ProjectionPredicate, ProjectionTy, Substs, TraitEnvironment, TraitRef, + Ty, TypeCtor, TypeWalk, }; use crate::{ db::HirDatabase, @@ -591,16 +591,15 @@ pub(crate) fn generic_predicates_for_param_query( .collect() } -pub(crate) fn trait_env( - db: &impl HirDatabase, - resolver: &Resolver, -) -> Arc { - let predicates = resolver - .where_predicates_in_scope() - .flat_map(|pred| GenericPredicate::from_where_predicate(db, &resolver, pred)) - .collect::>(); +impl TraitEnvironment { + pub(crate) fn lower(db: &impl HirDatabase, resolver: &Resolver) -> Arc { + let predicates = resolver + .where_predicates_in_scope() + .flat_map(|pred| GenericPredicate::from_where_predicate(db, &resolver, pred)) + .collect::>(); - Arc::new(super::TraitEnvironment { predicates }) + Arc::new(TraitEnvironment { predicates }) + } } /// Resolve the where clause(s) of an item with generics. -- cgit v1.2.3