mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-28 21:05:02 +00:00
Fix a bunch of false-positives in join-lines
This commit is contained in:
parent
23c889694e
commit
15cfa9a808
5 changed files with 83 additions and 14 deletions
|
@ -368,12 +368,15 @@ impl ast::BlockExpr {
|
|||
/// const FOO: () = { stand_alone };
|
||||
/// ```
|
||||
pub fn is_standalone(&self) -> bool {
|
||||
if self.unsafe_token().is_some() || self.async_token().is_some() {
|
||||
return false;
|
||||
}
|
||||
let kind = match self.syntax().parent() {
|
||||
None => return true,
|
||||
Some(it) => it.kind(),
|
||||
};
|
||||
match kind {
|
||||
FN_DEF | MATCH_ARM | IF_EXPR | WHILE_EXPR | LOOP_EXPR | TRY_BLOCK_EXPR => false,
|
||||
FN_DEF | IF_EXPR | WHILE_EXPR | LOOP_EXPR | TRY_BLOCK_EXPR => false,
|
||||
_ => true,
|
||||
}
|
||||
}
|
||||
|
|
|
@ -554,6 +554,7 @@ impl ast::AttrsOwner for BlockExpr {}
|
|||
impl BlockExpr {
|
||||
pub fn label(&self) -> Option<Label> { support::child(&self.syntax) }
|
||||
pub fn unsafe_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![unsafe]) }
|
||||
pub fn async_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![async]) }
|
||||
pub fn block(&self) -> Option<Block> { support::child(&self.syntax) }
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue