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 +++++++++++++------------ crates/rust-analyzer/src/semantic_tokens.rs | 2 +- 2 files changed, 14 insertions(+), 13 deletions(-) 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>, diff --git a/crates/rust-analyzer/src/semantic_tokens.rs b/crates/rust-analyzer/src/semantic_tokens.rs index ad000a3ce..e6a8eb146 100644 --- a/crates/rust-analyzer/src/semantic_tokens.rs +++ b/crates/rust-analyzer/src/semantic_tokens.rs @@ -49,7 +49,7 @@ pub(crate) fn supported_token_modifiers() -> &'static [SemanticTokenModifier] { } /// Tokens are encoded relative to each other. -/// +/// /// This is a direct port of https://github.com/microsoft/vscode-languageserver-node/blob/f425af9de46a0187adb78ec8a46b9b2ce80c5412/server/src/sematicTokens.proposed.ts#L45 #[derive(Default)] pub(crate) struct SemanticTokensBuilder { -- cgit v1.2.3