aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_fmt/src/lib.rs
diff options
context:
space:
mode:
authorbors[bot] <bors[bot]@users.noreply.github.com>2019-05-15 13:45:58 +0100
committerbors[bot] <bors[bot]@users.noreply.github.com>2019-05-15 13:45:58 +0100
commitec7d2f64ade9ffa35a64e82ac53e65ad5cbe9efd (patch)
treeb8693ce808a9ca2e7eaae5013644a1082fc7bb17 /crates/ra_fmt/src/lib.rs
parent64ab5ab10d32e7e8ec085af818d3d94211aea39b (diff)
parent993abedd77cf23ce2281b6c8e60cab49ab4fa97e (diff)
Merge #1278
1278: Apply T! macro where posible r=matklad a=pasa apply T! macro implemented in #1248 Co-authored-by: Sergey Parilin <[email protected]>
Diffstat (limited to 'crates/ra_fmt/src/lib.rs')
-rw-r--r--crates/ra_fmt/src/lib.rs14
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 @@
3use std::iter::successors; 3use std::iter::successors;
4use itertools::Itertools; 4use itertools::Itertools;
5use ra_syntax::{ 5use 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
50pub fn compute_ws(left: SyntaxKind, right: SyntaxKind) -> &'static str { 50pub 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 " "