mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-10-02 22:54:58 +00:00
Replace SyntaxKind usage with T! macro where applicable
This commit is contained in:
parent
e1430d822e
commit
e618d12903
12 changed files with 50 additions and 44 deletions
|
@ -1,6 +1,6 @@
|
|||
use syntax::{
|
||||
ast::{self, AstNode},
|
||||
match_ast, SyntaxElement, SyntaxKind, TextRange, TextSize, T,
|
||||
match_ast, SyntaxElement, TextRange, TextSize, T,
|
||||
};
|
||||
|
||||
use crate::{AssistContext, AssistId, AssistKind, Assists};
|
||||
|
@ -136,14 +136,14 @@ fn needs_parentheses_around_macro_contents(macro_contents: Vec<SyntaxElement>) -
|
|||
symbol_kind => {
|
||||
let symbol_not_in_bracket = unpaired_brackets_in_contents.is_empty();
|
||||
if symbol_not_in_bracket
|
||||
&& symbol_kind != SyntaxKind::COLON // paths
|
||||
&& (symbol_kind != SyntaxKind::DOT // field/method access
|
||||
&& symbol_kind != T![:] // paths
|
||||
&& (symbol_kind != T![.] // field/method access
|
||||
|| macro_contents // range expressions consist of two SyntaxKind::Dot in macro invocations
|
||||
.peek()
|
||||
.map(|element| element.kind() == SyntaxKind::DOT)
|
||||
.map(|element| element.kind() == T![.])
|
||||
.unwrap_or(false))
|
||||
&& symbol_kind != SyntaxKind::QUESTION // try operator
|
||||
&& (symbol_kind.is_punct() || symbol_kind == SyntaxKind::AS_KW)
|
||||
&& symbol_kind != T![?] // try operator
|
||||
&& (symbol_kind.is_punct() || symbol_kind == T![as])
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue