8727: minor: use standard import style r=matklad a=matklad

bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
This commit is contained in:
bors[bot] 2021-05-04 17:37:09 +00:00 committed by GitHub
commit e17748e4b2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -3,14 +3,14 @@
use std::sync::Arc; use std::sync::Arc;
use base_db::{salsa, SourceDatabase}; use base_db::{salsa, SourceDatabase};
use mbe::{ExpandError, ExpandResult, MacroDef, MacroRules}; use mbe::{ExpandError, ExpandResult};
use parser::FragmentKind; use parser::FragmentKind;
use syntax::{ use syntax::{
algo::diff, algo::diff,
ast::{MacroStmts, NameOwner}, ast::{self, NameOwner},
AstNode, GreenNode, Parse, AstNode, GreenNode, Parse,
SyntaxKind::*, SyntaxKind::*,
SyntaxNode, SyntaxNode, SyntaxToken,
}; };
use crate::{ use crate::{
@ -120,9 +120,9 @@ fn parse_macro_expansion(
pub fn expand_hypothetical( pub fn expand_hypothetical(
db: &dyn AstDatabase, db: &dyn AstDatabase,
actual_macro_call: MacroCallId, actual_macro_call: MacroCallId,
hypothetical_args: &syntax::ast::TokenTree, hypothetical_args: &ast::TokenTree,
token_to_map: syntax::SyntaxToken, token_to_map: SyntaxToken,
) -> Option<(SyntaxNode, syntax::SyntaxToken)> { ) -> Option<(SyntaxNode, SyntaxToken)> {
let macro_file = MacroFile { macro_call_id: actual_macro_call }; let macro_file = MacroFile { macro_call_id: actual_macro_call };
let (tt, tmap_1) = mbe::syntax_node_to_token_tree(hypothetical_args.syntax()); let (tt, tmap_1) = mbe::syntax_node_to_token_tree(hypothetical_args.syntax());
let range = let range =
@ -146,10 +146,10 @@ fn ast_id_map(db: &dyn AstDatabase, file_id: HirFileId) -> Arc<AstIdMap> {
fn macro_def(db: &dyn AstDatabase, id: MacroDefId) -> Option<Arc<(TokenExpander, mbe::TokenMap)>> { fn macro_def(db: &dyn AstDatabase, id: MacroDefId) -> Option<Arc<(TokenExpander, mbe::TokenMap)>> {
match id.kind { match id.kind {
MacroDefKind::Declarative(ast_id) => match ast_id.to_node(db) { MacroDefKind::Declarative(ast_id) => match ast_id.to_node(db) {
syntax::ast::Macro::MacroRules(macro_rules) => { ast::Macro::MacroRules(macro_rules) => {
let arg = macro_rules.token_tree()?; let arg = macro_rules.token_tree()?;
let (tt, tmap) = mbe::ast_to_token_tree(&arg); let (tt, tmap) = mbe::ast_to_token_tree(&arg);
let rules = match MacroRules::parse(&tt) { let rules = match mbe::MacroRules::parse(&tt) {
Ok(it) => it, Ok(it) => it,
Err(err) => { Err(err) => {
let name = macro_rules.name().map(|n| n.to_string()).unwrap_or_default(); 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,
}; };
Some(Arc::new((TokenExpander::MacroRules(rules), tmap))) Some(Arc::new((TokenExpander::MacroRules(rules), tmap)))
} }
syntax::ast::Macro::MacroDef(macro_def) => { ast::Macro::MacroDef(macro_def) => {
let arg = macro_def.body()?; let arg = macro_def.body()?;
let (tt, tmap) = mbe::ast_to_token_tree(&arg); let (tt, tmap) = mbe::ast_to_token_tree(&arg);
let rules = match MacroDef::parse(&tt) { let rules = match mbe::MacroDef::parse(&tt) {
Ok(it) => it, Ok(it) => it,
Err(err) => { Err(err) => {
let name = macro_def.name().map(|n| n.to_string()).unwrap_or_default(); 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 {
if diff(from, to).is_empty() { if diff(from, to).is_empty() {
return true; return true;
} }
if let Some(stmts) = MacroStmts::cast(from.clone()) { if let Some(stmts) = ast::MacroStmts::cast(from.clone()) {
if stmts.statements().any(|stmt| diff(stmt.syntax(), to).is_empty()) { if stmts.statements().any(|stmt| diff(stmt.syntax(), to).is_empty()) {
return true; return true;
} }