From 136151515abffabdedbe0087f8fc21a67c071dc6 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Tue, 25 Feb 2020 12:42:44 +0100 Subject: Replace generic with a concrete type --- crates/ra_assists/src/ast_transform.rs | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) (limited to 'crates/ra_assists/src') diff --git a/crates/ra_assists/src/ast_transform.rs b/crates/ra_assists/src/ast_transform.rs index 56b7588ef..c6d15af5f 100644 --- a/crates/ra_assists/src/ast_transform.rs +++ b/crates/ra_assists/src/ast_transform.rs @@ -1,7 +1,8 @@ //! `AstTransformer`s are functions that replace nodes in an AST and can be easily combined. use rustc_hash::FxHashMap; -use hir::{db::HirDatabase, InFile, PathResolution}; +use hir::{InFile, PathResolution}; +use ra_ide_db::RootDatabase; use ra_syntax::ast::{self, AstNode}; pub trait AstTransform<'a> { @@ -33,18 +34,18 @@ impl<'a> AstTransform<'a> for NullTransformer { } } -pub struct SubstituteTypeParams<'a, DB: HirDatabase> { - db: &'a DB, +pub struct SubstituteTypeParams<'a> { + db: &'a RootDatabase, substs: FxHashMap, previous: Box + 'a>, } -impl<'a, DB: HirDatabase> SubstituteTypeParams<'a, DB> { +impl<'a> SubstituteTypeParams<'a> { pub fn for_trait_impl( - db: &'a DB, + db: &'a RootDatabase, trait_: hir::Trait, impl_block: ast::ImplBlock, - ) -> SubstituteTypeParams<'a, DB> { + ) -> SubstituteTypeParams<'a> { let substs = get_syntactic_substs(impl_block).unwrap_or_default(); let generic_def: hir::GenericDef = trait_.into(); let substs_by_param: FxHashMap<_, _> = generic_def @@ -95,7 +96,7 @@ impl<'a, DB: HirDatabase> SubstituteTypeParams<'a, DB> { } } -impl<'a, DB: HirDatabase> AstTransform<'a> for SubstituteTypeParams<'a, DB> { +impl<'a> AstTransform<'a> for SubstituteTypeParams<'a> { fn get_substitution( &self, node: InFile<&ra_syntax::SyntaxNode>, @@ -107,14 +108,14 @@ impl<'a, DB: HirDatabase> AstTransform<'a> for SubstituteTypeParams<'a, DB> { } } -pub struct QualifyPaths<'a, DB: HirDatabase> { - db: &'a DB, +pub struct QualifyPaths<'a> { + db: &'a RootDatabase, from: Option, previous: Box + 'a>, } -impl<'a, DB: HirDatabase> QualifyPaths<'a, DB> { - pub fn new(db: &'a DB, from: Option) -> Self { +impl<'a> QualifyPaths<'a> { + pub fn new(db: &'a RootDatabase, from: Option) -> Self { Self { db, from, previous: Box::new(NullTransformer) } } @@ -168,7 +169,7 @@ pub fn apply<'a, N: AstNode>(transformer: &dyn AstTransform<'a>, node: InFile N::cast(result).unwrap() } -impl<'a, DB: HirDatabase> AstTransform<'a> for QualifyPaths<'a, DB> { +impl<'a> AstTransform<'a> for QualifyPaths<'a> { fn get_substitution( &self, node: InFile<&ra_syntax::SyntaxNode>, -- cgit v1.2.3