diff options
author | Sergey Parilin <[email protected]> | 2019-05-15 13:35:47 +0100 |
---|---|---|
committer | Sergey Parilin <[email protected]> | 2019-05-15 13:35:47 +0100 |
commit | 993abedd77cf23ce2281b6c8e60cab49ab4fa97e (patch) | |
tree | b8693ce808a9ca2e7eaae5013644a1082fc7bb17 /crates/ra_fmt/src | |
parent | d77175ce28da45960a89811f273b6c614d7a9413 (diff) |
apply T! macro where it is possible
Diffstat (limited to 'crates/ra_fmt/src')
-rw-r--r-- | crates/ra_fmt/src/lib.rs | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/crates/ra_fmt/src/lib.rs b/crates/ra_fmt/src/lib.rs index 603be1854..aac5a1d23 100644 --- a/crates/ra_fmt/src/lib.rs +++ b/crates/ra_fmt/src/lib.rs | |||
@@ -3,7 +3,7 @@ | |||
3 | use std::iter::successors; | 3 | use std::iter::successors; |
4 | use itertools::Itertools; | 4 | use itertools::Itertools; |
5 | use ra_syntax::{ | 5 | use ra_syntax::{ |
6 | SyntaxNode, SyntaxKind::*, SyntaxToken, SyntaxKind, | 6 | SyntaxNode, SyntaxKind::*, SyntaxToken, SyntaxKind, T, |
7 | ast::{self, AstNode, AstToken}, | 7 | ast::{self, AstNode, AstToken}, |
8 | }; | 8 | }; |
9 | 9 | ||
@@ -38,7 +38,7 @@ pub fn extract_trivial_expression(block: &ast::Block) -> Option<&ast::Expr> { | |||
38 | return None; | 38 | return None; |
39 | } | 39 | } |
40 | let non_trivial_children = block.syntax().children().filter(|it| match it.kind() { | 40 | let non_trivial_children = block.syntax().children().filter(|it| match it.kind() { |
41 | WHITESPACE | L_CURLY | R_CURLY => false, | 41 | WHITESPACE | T!['{'] | T!['}'] => false, |
42 | _ => it != &expr.syntax(), | 42 | _ => it != &expr.syntax(), |
43 | }); | 43 | }); |
44 | if non_trivial_children.count() > 0 { | 44 | if non_trivial_children.count() > 0 { |
@@ -49,8 +49,8 @@ pub fn extract_trivial_expression(block: &ast::Block) -> Option<&ast::Expr> { | |||
49 | 49 | ||
50 | pub fn compute_ws(left: SyntaxKind, right: SyntaxKind) -> &'static str { | 50 | pub fn compute_ws(left: SyntaxKind, right: SyntaxKind) -> &'static str { |
51 | match left { | 51 | match left { |
52 | L_PAREN | L_BRACK => return "", | 52 | T!['('] | T!['['] => return "", |
53 | L_CURLY => { | 53 | T!['{'] => { |
54 | if let USE_TREE = right { | 54 | if let USE_TREE = right { |
55 | return ""; | 55 | return ""; |
56 | } | 56 | } |
@@ -58,13 +58,13 @@ pub fn compute_ws(left: SyntaxKind, right: SyntaxKind) -> &'static str { | |||
58 | _ => (), | 58 | _ => (), |
59 | } | 59 | } |
60 | match right { | 60 | match right { |
61 | R_PAREN | R_BRACK => return "", | 61 | T![')'] | T![']'] => return "", |
62 | R_CURLY => { | 62 | T!['}'] => { |
63 | if let USE_TREE = left { | 63 | if let USE_TREE = left { |
64 | return ""; | 64 | return ""; |
65 | } | 65 | } |
66 | } | 66 | } |
67 | DOT => return "", | 67 | T![.] => return "", |
68 | _ => (), | 68 | _ => (), |
69 | } | 69 | } |
70 | " " | 70 | " " |