diff options
Diffstat (limited to 'crates/hir_expand')
-rw-r--r-- | crates/hir_expand/src/db.rs | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/crates/hir_expand/src/db.rs b/crates/hir_expand/src/db.rs index 2eaab1efb..1389e30db 100644 --- a/crates/hir_expand/src/db.rs +++ b/crates/hir_expand/src/db.rs | |||
@@ -3,14 +3,14 @@ | |||
3 | use std::sync::Arc; | 3 | use std::sync::Arc; |
4 | 4 | ||
5 | use base_db::{salsa, SourceDatabase}; | 5 | use base_db::{salsa, SourceDatabase}; |
6 | use mbe::{ExpandError, ExpandResult, MacroDef, MacroRules}; | 6 | use mbe::{ExpandError, ExpandResult}; |
7 | use parser::FragmentKind; | 7 | use parser::FragmentKind; |
8 | use syntax::{ | 8 | use syntax::{ |
9 | algo::diff, | 9 | algo::diff, |
10 | ast::{MacroStmts, NameOwner}, | 10 | ast::{self, NameOwner}, |
11 | AstNode, GreenNode, Parse, | 11 | AstNode, GreenNode, Parse, |
12 | SyntaxKind::*, | 12 | SyntaxKind::*, |
13 | SyntaxNode, | 13 | SyntaxNode, SyntaxToken, |
14 | }; | 14 | }; |
15 | 15 | ||
16 | use crate::{ | 16 | use crate::{ |
@@ -120,9 +120,9 @@ pub trait AstDatabase: SourceDatabase { | |||
120 | pub fn expand_hypothetical( | 120 | pub fn expand_hypothetical( |
121 | db: &dyn AstDatabase, | 121 | db: &dyn AstDatabase, |
122 | actual_macro_call: MacroCallId, | 122 | actual_macro_call: MacroCallId, |
123 | hypothetical_args: &syntax::ast::TokenTree, | 123 | hypothetical_args: &ast::TokenTree, |
124 | token_to_map: syntax::SyntaxToken, | 124 | token_to_map: SyntaxToken, |
125 | ) -> Option<(SyntaxNode, syntax::SyntaxToken)> { | 125 | ) -> Option<(SyntaxNode, SyntaxToken)> { |
126 | let macro_file = MacroFile { macro_call_id: actual_macro_call }; | 126 | let macro_file = MacroFile { macro_call_id: actual_macro_call }; |
127 | let (tt, tmap_1) = mbe::syntax_node_to_token_tree(hypothetical_args.syntax()); | 127 | let (tt, tmap_1) = mbe::syntax_node_to_token_tree(hypothetical_args.syntax()); |
128 | let range = | 128 | let range = |
@@ -146,10 +146,10 @@ fn ast_id_map(db: &dyn AstDatabase, file_id: HirFileId) -> Arc<AstIdMap> { | |||
146 | fn macro_def(db: &dyn AstDatabase, id: MacroDefId) -> Option<Arc<(TokenExpander, mbe::TokenMap)>> { | 146 | fn macro_def(db: &dyn AstDatabase, id: MacroDefId) -> Option<Arc<(TokenExpander, mbe::TokenMap)>> { |
147 | match id.kind { | 147 | match id.kind { |
148 | MacroDefKind::Declarative(ast_id) => match ast_id.to_node(db) { | 148 | MacroDefKind::Declarative(ast_id) => match ast_id.to_node(db) { |
149 | syntax::ast::Macro::MacroRules(macro_rules) => { | 149 | ast::Macro::MacroRules(macro_rules) => { |
150 | let arg = macro_rules.token_tree()?; | 150 | let arg = macro_rules.token_tree()?; |
151 | let (tt, tmap) = mbe::ast_to_token_tree(&arg); | 151 | let (tt, tmap) = mbe::ast_to_token_tree(&arg); |
152 | let rules = match MacroRules::parse(&tt) { | 152 | let rules = match mbe::MacroRules::parse(&tt) { |
153 | Ok(it) => it, | 153 | Ok(it) => it, |
154 | Err(err) => { | 154 | Err(err) => { |
155 | let name = macro_rules.name().map(|n| n.to_string()).unwrap_or_default(); | 155 | let name = macro_rules.name().map(|n| n.to_string()).unwrap_or_default(); |
@@ -159,10 +159,10 @@ fn macro_def(db: &dyn AstDatabase, id: MacroDefId) -> Option<Arc<(TokenExpander, | |||
159 | }; | 159 | }; |
160 | Some(Arc::new((TokenExpander::MacroRules(rules), tmap))) | 160 | Some(Arc::new((TokenExpander::MacroRules(rules), tmap))) |
161 | } | 161 | } |
162 | syntax::ast::Macro::MacroDef(macro_def) => { | 162 | ast::Macro::MacroDef(macro_def) => { |
163 | let arg = macro_def.body()?; | 163 | let arg = macro_def.body()?; |
164 | let (tt, tmap) = mbe::ast_to_token_tree(&arg); | 164 | let (tt, tmap) = mbe::ast_to_token_tree(&arg); |
165 | let rules = match MacroDef::parse(&tt) { | 165 | let rules = match mbe::MacroDef::parse(&tt) { |
166 | Ok(it) => it, | 166 | Ok(it) => it, |
167 | Err(err) => { | 167 | Err(err) => { |
168 | let name = macro_def.name().map(|n| n.to_string()).unwrap_or_default(); | 168 | let name = macro_def.name().map(|n| n.to_string()).unwrap_or_default(); |
@@ -408,7 +408,7 @@ fn is_self_replicating(from: &SyntaxNode, to: &SyntaxNode) -> bool { | |||
408 | if diff(from, to).is_empty() { | 408 | if diff(from, to).is_empty() { |
409 | return true; | 409 | return true; |
410 | } | 410 | } |
411 | if let Some(stmts) = MacroStmts::cast(from.clone()) { | 411 | if let Some(stmts) = ast::MacroStmts::cast(from.clone()) { |
412 | if stmts.statements().any(|stmt| diff(stmt.syntax(), to).is_empty()) { | 412 | if stmts.statements().any(|stmt| diff(stmt.syntax(), to).is_empty()) { |
413 | return true; | 413 | return true; |
414 | } | 414 | } |