From 99b6ecfab061396613c5f459fae43ea17b5675b8 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Tue, 29 Oct 2019 16:12:54 +0300 Subject: [PATCH] switch expand to dyn Trait --- crates/ra_hir_expand/src/db.rs | 12 ++++++------ crates/ra_hir_expand/src/lib.rs | 6 +++--- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/crates/ra_hir_expand/src/db.rs b/crates/ra_hir_expand/src/db.rs index dc4944c051..a4ee9a529a 100644 --- a/crates/ra_hir_expand/src/db.rs +++ b/crates/ra_hir_expand/src/db.rs @@ -28,13 +28,13 @@ pub trait AstDatabase: SourceDatabase { fn macro_expand(&self, macro_call: MacroCallId) -> Result, String>; } -pub(crate) fn ast_id_map(db: &impl AstDatabase, file_id: HirFileId) -> Arc { +pub(crate) fn ast_id_map(db: &dyn AstDatabase, file_id: HirFileId) -> Arc { let map = db.parse_or_expand(file_id).map_or_else(AstIdMap::default, |it| AstIdMap::from_source(&it)); Arc::new(map) } -pub(crate) fn macro_def(db: &impl AstDatabase, id: MacroDefId) -> Option> { +pub(crate) fn macro_def(db: &dyn AstDatabase, id: MacroDefId) -> Option> { let macro_call = id.ast_id.to_node(db); let arg = macro_call.token_tree()?; let (tt, _) = mbe::ast_to_token_tree(&arg).or_else(|| { @@ -48,7 +48,7 @@ pub(crate) fn macro_def(db: &impl AstDatabase, id: MacroDefId) -> Option Option> { +pub(crate) fn macro_arg(db: &dyn AstDatabase, id: MacroCallId) -> Option> { let loc = db.lookup_intern_macro(id); let macro_call = loc.ast_id.to_node(db); let arg = macro_call.token_tree()?; @@ -57,7 +57,7 @@ pub(crate) fn macro_arg(db: &impl AstDatabase, id: MacroCallId) -> Option Result, String> { let loc = db.lookup_intern_macro(id); @@ -73,7 +73,7 @@ pub(crate) fn macro_expand( Ok(Arc::new(tt)) } -pub(crate) fn parse_or_expand(db: &impl AstDatabase, file_id: HirFileId) -> Option { +pub(crate) fn parse_or_expand(db: &dyn AstDatabase, file_id: HirFileId) -> Option { match file_id.0 { HirFileIdRepr::FileId(file_id) => Some(db.parse(file_id).tree().syntax().clone()), HirFileIdRepr::MacroFile(macro_file) => { @@ -83,7 +83,7 @@ pub(crate) fn parse_or_expand(db: &impl AstDatabase, file_id: HirFileId) -> Opti } pub(crate) fn parse_macro( - db: &impl AstDatabase, + db: &dyn AstDatabase, macro_file: MacroFile, ) -> Option> { let _p = profile("parse_macro_query"); diff --git a/crates/ra_hir_expand/src/lib.rs b/crates/ra_hir_expand/src/lib.rs index 9100bd15cc..749227465f 100644 --- a/crates/ra_hir_expand/src/lib.rs +++ b/crates/ra_hir_expand/src/lib.rs @@ -63,7 +63,7 @@ impl From for HirFileId { impl HirFileId { /// For macro-expansion files, returns the file original source file the /// expansion originated from. - pub fn original_file(self, db: &impl AstDatabase) -> FileId { + pub fn original_file(self, db: &dyn AstDatabase) -> FileId { match self.0 { HirFileIdRepr::FileId(file_id) => file_id, HirFileIdRepr::MacroFile(macro_file) => { @@ -74,7 +74,7 @@ impl HirFileId { } /// Get the crate which the macro lives in, if it is a macro file. - pub fn macro_crate(self, db: &impl AstDatabase) -> Option { + pub fn macro_crate(self, db: &dyn AstDatabase) -> Option { match self.0 { HirFileIdRepr::FileId(_) => None, HirFileIdRepr::MacroFile(macro_file) => { @@ -160,7 +160,7 @@ impl AstId { self.file_id } - pub fn to_node(&self, db: &impl AstDatabase) -> N { + pub fn to_node(&self, db: &dyn AstDatabase) -> N { let root = db.parse_or_expand(self.file_id).unwrap(); db.ast_id_map(self.file_id).get(self.file_ast_id).to_node(&root) }