From 6eb05c4a14bf233b1a6774074b526b54420deb9d Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Fri, 13 Mar 2020 18:02:04 +0100 Subject: Simplify --- crates/ra_assists/src/ast_transform.rs | 9 +++------ crates/ra_assists/src/handlers/add_missing_impl_members.rs | 4 ++-- 2 files changed, 5 insertions(+), 8 deletions(-) (limited to 'crates/ra_assists') diff --git a/crates/ra_assists/src/ast_transform.rs b/crates/ra_assists/src/ast_transform.rs index 42856f0ca..45558c448 100644 --- a/crates/ra_assists/src/ast_transform.rs +++ b/crates/ra_assists/src/ast_transform.rs @@ -37,7 +37,6 @@ pub struct SubstituteTypeParams<'a> { impl<'a> SubstituteTypeParams<'a> { pub fn for_trait_impl( source_scope: &'a SemanticsScope<'a, RootDatabase>, - db: &'a RootDatabase, // FIXME: there's implicit invariant that `trait_` and `source_scope` match... trait_: hir::Trait, impl_def: ast::ImplDef, @@ -45,7 +44,7 @@ impl<'a> SubstituteTypeParams<'a> { let substs = get_syntactic_substs(impl_def).unwrap_or_default(); let generic_def: hir::GenericDef = trait_.into(); let substs_by_param: FxHashMap<_, _> = generic_def - .params(db) + .params(source_scope.db) .into_iter() // this is a trait impl, so we need to skip the first type parameter -- this is a bit hacky .skip(1) @@ -104,7 +103,6 @@ impl<'a> AstTransform<'a> for SubstituteTypeParams<'a> { pub struct QualifyPaths<'a> { target_scope: &'a SemanticsScope<'a, RootDatabase>, source_scope: &'a SemanticsScope<'a, RootDatabase>, - db: &'a RootDatabase, previous: Box + 'a>, } @@ -112,9 +110,8 @@ impl<'a> QualifyPaths<'a> { pub fn new( target_scope: &'a SemanticsScope<'a, RootDatabase>, source_scope: &'a SemanticsScope<'a, RootDatabase>, - db: &'a RootDatabase, ) -> Self { - Self { target_scope, source_scope, db, previous: Box::new(NullTransformer) } + Self { target_scope, source_scope, previous: Box::new(NullTransformer) } } fn get_substitution_inner( @@ -132,7 +129,7 @@ impl<'a> QualifyPaths<'a> { let resolution = self.source_scope.resolve_hir_path(&hir_path?)?; match resolution { PathResolution::Def(def) => { - let found_path = from.find_use_path(self.db, def)?; + let found_path = from.find_use_path(self.source_scope.db, def)?; let mut path = path_to_ast(found_path); let type_args = p diff --git a/crates/ra_assists/src/handlers/add_missing_impl_members.rs b/crates/ra_assists/src/handlers/add_missing_impl_members.rs index 639180d37..e5920b6f6 100644 --- a/crates/ra_assists/src/handlers/add_missing_impl_members.rs +++ b/crates/ra_assists/src/handlers/add_missing_impl_members.rs @@ -142,8 +142,8 @@ fn add_missing_impl_members_inner( let n_existing_items = impl_item_list.impl_items().count(); let source_scope = sema.scope_for_def(trait_); let target_scope = sema.scope(impl_item_list.syntax()); - let ast_transform = QualifyPaths::new(&target_scope, &source_scope, sema.db) - .or(SubstituteTypeParams::for_trait_impl(&source_scope, sema.db, trait_, impl_node)); + let ast_transform = QualifyPaths::new(&target_scope, &source_scope) + .or(SubstituteTypeParams::for_trait_impl(&source_scope, trait_, impl_node)); let items = missing_items .into_iter() .map(|it| ast_transform::apply(&*ast_transform, it)) -- cgit v1.2.3