aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_fmt
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_fmt')
-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 " "