diff options
author | Aleksey Kladov <[email protected]> | 2021-05-04 18:36:48 +0100 |
---|---|---|
committer | Aleksey Kladov <[email protected]> | 2021-05-04 18:36:48 +0100 |
commit | 2e97dbcbb82dbcc0561d7f0bb9a225eb4d2845fc (patch) | |
tree | f82d46ad8fd7e904ba2870f9bddfc50ae3c84a77 /crates/hir_expand/src | |
parent | 87f827bfafc28669e896904bd162e3864350aeed (diff) |
minor: use standard import style
Diffstat (limited to 'crates/hir_expand/src')
-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 43f787b34..7e02ed036 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::{ |
@@ -115,9 +115,9 @@ pub trait AstDatabase: SourceDatabase { | |||
115 | pub fn expand_hypothetical( | 115 | pub fn expand_hypothetical( |
116 | db: &dyn AstDatabase, | 116 | db: &dyn AstDatabase, |
117 | actual_macro_call: MacroCallId, | 117 | actual_macro_call: MacroCallId, |
118 | hypothetical_args: &syntax::ast::TokenTree, | 118 | hypothetical_args: &ast::TokenTree, |
119 | token_to_map: syntax::SyntaxToken, | 119 | token_to_map: SyntaxToken, |
120 | ) -> Option<(SyntaxNode, syntax::SyntaxToken)> { | 120 | ) -> Option<(SyntaxNode, SyntaxToken)> { |
121 | let macro_file = MacroFile { macro_call_id: actual_macro_call }; | 121 | let macro_file = MacroFile { macro_call_id: actual_macro_call }; |
122 | let (tt, tmap_1) = mbe::syntax_node_to_token_tree(hypothetical_args.syntax()); | 122 | let (tt, tmap_1) = mbe::syntax_node_to_token_tree(hypothetical_args.syntax()); |
123 | let range = | 123 | let range = |
@@ -141,10 +141,10 @@ fn ast_id_map(db: &dyn AstDatabase, file_id: HirFileId) -> Arc<AstIdMap> { | |||
141 | fn macro_def(db: &dyn AstDatabase, id: MacroDefId) -> Option<Arc<(TokenExpander, mbe::TokenMap)>> { | 141 | fn macro_def(db: &dyn AstDatabase, id: MacroDefId) -> Option<Arc<(TokenExpander, mbe::TokenMap)>> { |
142 | match id.kind { | 142 | match id.kind { |
143 | MacroDefKind::Declarative(ast_id) => match ast_id.to_node(db) { | 143 | MacroDefKind::Declarative(ast_id) => match ast_id.to_node(db) { |
144 | syntax::ast::Macro::MacroRules(macro_rules) => { | 144 | ast::Macro::MacroRules(macro_rules) => { |
145 | let arg = macro_rules.token_tree()?; | 145 | let arg = macro_rules.token_tree()?; |
146 | let (tt, tmap) = mbe::ast_to_token_tree(&arg); | 146 | let (tt, tmap) = mbe::ast_to_token_tree(&arg); |
147 | let rules = match MacroRules::parse(&tt) { | 147 | let rules = match mbe::MacroRules::parse(&tt) { |
148 | Ok(it) => it, | 148 | Ok(it) => it, |
149 | Err(err) => { | 149 | Err(err) => { |
150 | let name = macro_rules.name().map(|n| n.to_string()).unwrap_or_default(); | 150 | let name = macro_rules.name().map(|n| n.to_string()).unwrap_or_default(); |
@@ -154,10 +154,10 @@ fn macro_def(db: &dyn AstDatabase, id: MacroDefId) -> Option<Arc<(TokenExpander, | |||
154 | }; | 154 | }; |
155 | Some(Arc::new((TokenExpander::MacroRules(rules), tmap))) | 155 | Some(Arc::new((TokenExpander::MacroRules(rules), tmap))) |
156 | } | 156 | } |
157 | syntax::ast::Macro::MacroDef(macro_def) => { | 157 | ast::Macro::MacroDef(macro_def) => { |
158 | let arg = macro_def.body()?; | 158 | let arg = macro_def.body()?; |
159 | let (tt, tmap) = mbe::ast_to_token_tree(&arg); | 159 | let (tt, tmap) = mbe::ast_to_token_tree(&arg); |
160 | let rules = match MacroDef::parse(&tt) { | 160 | let rules = match mbe::MacroDef::parse(&tt) { |
161 | Ok(it) => it, | 161 | Ok(it) => it, |
162 | Err(err) => { | 162 | Err(err) => { |
163 | let name = macro_def.name().map(|n| n.to_string()).unwrap_or_default(); | 163 | let name = macro_def.name().map(|n| n.to_string()).unwrap_or_default(); |
@@ -403,7 +403,7 @@ fn is_self_replicating(from: &SyntaxNode, to: &SyntaxNode) -> bool { | |||
403 | if diff(from, to).is_empty() { | 403 | if diff(from, to).is_empty() { |
404 | return true; | 404 | return true; |
405 | } | 405 | } |
406 | if let Some(stmts) = MacroStmts::cast(from.clone()) { | 406 | if let Some(stmts) = ast::MacroStmts::cast(from.clone()) { |
407 | if stmts.statements().any(|stmt| diff(stmt.syntax(), to).is_empty()) { | 407 | if stmts.statements().any(|stmt| diff(stmt.syntax(), to).is_empty()) { |
408 | return true; | 408 | return true; |
409 | } | 409 | } |