aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_ide/src
diff options
context:
space:
mode:
authorMatt Hooper <[email protected]>2020-03-24 19:31:02 +0000
committerMatt Hooper <[email protected]>2020-03-24 22:22:41 +0000
commit9d298115a62343e207992bbceb0279522324bf75 (patch)
tree3def364d8279d47f3ff73a2b3295cc457dcf6a25 /crates/ra_ide/src
parentb70ce559b8d3102c3fed3ecef8edef3038a5ceed (diff)
Fmt corrections
Diffstat (limited to 'crates/ra_ide/src')
-rw-r--r--crates/ra_ide/src/inlay_hints.rs22
1 files changed, 9 insertions, 13 deletions
diff --git a/crates/ra_ide/src/inlay_hints.rs b/crates/ra_ide/src/inlay_hints.rs
index 293944206..07aab45ee 100644
--- a/crates/ra_ide/src/inlay_hints.rs
+++ b/crates/ra_ide/src/inlay_hints.rs
@@ -5,7 +5,7 @@ use ra_ide_db::RootDatabase;
5use ra_prof::profile; 5use ra_prof::profile;
6use ra_syntax::{ 6use ra_syntax::{
7 ast::{self, ArgListOwner, AstNode, TypeAscriptionOwner}, 7 ast::{self, ArgListOwner, AstNode, TypeAscriptionOwner},
8 match_ast, SmolStr, TextRange, NodeOrToken, SyntaxKind, Direction 8 match_ast, Direction, NodeOrToken, SmolStr, SyntaxKind, TextRange,
9}; 9};
10 10
11use crate::{FileId, FunctionSignature}; 11use crate::{FileId, FunctionSignature};
@@ -20,12 +20,7 @@ pub struct InlayHintsOptions {
20 20
21impl Default for InlayHintsOptions { 21impl Default for InlayHintsOptions {
22 fn default() -> Self { 22 fn default() -> Self {
23 Self { 23 Self { type_hints: true, parameter_hints: true, chaining_hints: true, max_length: None }
24 type_hints: true,
25 parameter_hints: true,
26 chaining_hints: true,
27 max_length: None
28 }
29 } 24 }
30} 25}
31 26
@@ -86,7 +81,8 @@ fn get_chaining_hints(
86 return None; 81 return None;
87 } 82 }
88 83
89 let mut tokens = expr.syntax() 84 let mut tokens = expr
85 .syntax()
90 .siblings_with_tokens(Direction::Next) 86 .siblings_with_tokens(Direction::Next)
91 .filter_map(NodeOrToken::into_token) 87 .filter_map(NodeOrToken::into_token)
92 .filter(|t| match t.kind() { 88 .filter(|t| match t.kind() {
@@ -99,7 +95,7 @@ fn get_chaining_hints(
99 // Ignoring extra whitespace and comments 95 // Ignoring extra whitespace and comments
100 let next = tokens.next()?.kind(); 96 let next = tokens.next()?.kind();
101 let next_next = tokens.next()?.kind(); 97 let next_next = tokens.next()?.kind();
102 if next == SyntaxKind::WHITESPACE && next_next == SyntaxKind::DOT { 98 if next == SyntaxKind::WHITESPACE && next_next == SyntaxKind::DOT {
103 acc.push(InlayHint { 99 acc.push(InlayHint {
104 range: expr.syntax().text_range(), 100 range: expr.syntax().text_range(),
105 kind: InlayKind::ChainingHint, 101 kind: InlayKind::ChainingHint,
@@ -1190,11 +1186,11 @@ fn main() {
1190 fn generic_chaining_hints() { 1186 fn generic_chaining_hints() {
1191 let (analysis, file_id) = single_file( 1187 let (analysis, file_id) = single_file(
1192 r#" 1188 r#"
1193 struct A<T>(T); 1189 struct A<T>(T);
1194 struct B<T>(T); 1190 struct B<T>(T);
1195 struct C<T>(T); 1191 struct C<T>(T);
1196 struct X<T,R>(T, R); 1192 struct X<T,R>(T, R);
1197 1193
1198 impl<T> A<T> { 1194 impl<T> A<T> {
1199 fn new(t: T) -> Self { A(t) } 1195 fn new(t: T) -> Self { A(t) }
1200 fn into_b(self) -> B<T> { B(self.0) } 1196 fn into_b(self) -> B<T> { B(self.0) }
@@ -1211,12 +1207,12 @@ fn main() {
1211 assert_debug_snapshot!(analysis.inlay_hints(file_id, &InlayHintsOptions{ parameter_hints: false, type_hints: false, chaining_hints: true, max_length: None}).unwrap(), @r###" 1207 assert_debug_snapshot!(analysis.inlay_hints(file_id, &InlayHintsOptions{ parameter_hints: false, type_hints: false, chaining_hints: true, max_length: None}).unwrap(), @r###"
1212 [ 1208 [
1213 InlayHint { 1209 InlayHint {
1214 range: [416; 465), 1210 range: [403; 452),
1215 kind: ChainingHint, 1211 kind: ChainingHint,
1216 label: "B<X<i32, bool>>", 1212 label: "B<X<i32, bool>>",
1217 }, 1213 },
1218 InlayHint { 1214 InlayHint {
1219 range: [416; 435), 1215 range: [403; 422),
1220 kind: ChainingHint, 1216 kind: ChainingHint,
1221 label: "A<X<i32, bool>>", 1217 label: "A<X<i32, bool>>",
1222 }, 1218 },