Fix a bunch of false-positives in join-lines

This commit is contained in:
Aleksey Kladov 2020-04-30 21:36:31 +02:00
parent 23c889694e
commit 15cfa9a808
5 changed files with 83 additions and 14 deletions

View file

@ -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,
}
}

View file

@ -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) }
}