aboutsummaryrefslogtreecommitdiff
path: root/crates/hir_expand/src
diff options
context:
space:
mode:
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>2021-05-04 18:37:09 +0100
committerGitHub <[email protected]>2021-05-04 18:37:09 +0100
commite17748e4b21bb8731151219111880dcf7ac71227 (patch)
tree212a05f87effc9175e30299fe5b60263d8ab268e /crates/hir_expand/src
parent5e87f842116005d0d75364147de0f412739af622 (diff)
parent2e97dbcbb82dbcc0561d7f0bb9a225eb4d2845fc (diff)
Merge #8727
8727: minor: use standard import style r=matklad a=matklad bors r+ 🤖 Co-authored-by: Aleksey Kladov <[email protected]>
Diffstat (limited to 'crates/hir_expand/src')
-rw-r--r--crates/hir_expand/src/db.rs22
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 @@
3use std::sync::Arc; 3use std::sync::Arc;
4 4
5use base_db::{salsa, SourceDatabase}; 5use base_db::{salsa, SourceDatabase};
6use mbe::{ExpandError, ExpandResult, MacroDef, MacroRules}; 6use mbe::{ExpandError, ExpandResult};
7use parser::FragmentKind; 7use parser::FragmentKind;
8use syntax::{ 8use 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
16use crate::{ 16use crate::{
@@ -120,9 +120,9 @@ pub trait AstDatabase: SourceDatabase {
120pub fn expand_hypothetical( 120pub 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> {
146fn macro_def(db: &dyn AstDatabase, id: MacroDefId) -> Option<Arc<(TokenExpander, mbe::TokenMap)>> { 146fn 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 }