aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_ide/src
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_ide/src')
-rw-r--r--crates/ra_ide/src/inlay_hints.rs31
1 files changed, 15 insertions, 16 deletions
diff --git a/crates/ra_ide/src/inlay_hints.rs b/crates/ra_ide/src/inlay_hints.rs
index 59eced9d7..3730121af 100644
--- a/crates/ra_ide/src/inlay_hints.rs
+++ b/crates/ra_ide/src/inlay_hints.rs
@@ -122,18 +122,11 @@ fn get_leaf_pats(root_pat: ast::Pat) -> Vec<ast::Pat> {
122 122
123 while let Some(maybe_leaf_pat) = pats_to_process.pop_front() { 123 while let Some(maybe_leaf_pat) = pats_to_process.pop_front() {
124 match &maybe_leaf_pat { 124 match &maybe_leaf_pat {
125 ast::Pat::BindPat(bind_pat) => { 125 ast::Pat::BindPat(bind_pat) => match bind_pat.pat() {
126 if let Some(pat) = bind_pat.pat() { 126 Some(pat) => pats_to_process.push_back(pat),
127 pats_to_process.push_back(pat); 127 _ => leaf_pats.push(maybe_leaf_pat),
128 } else { 128 },
129 leaf_pats.push(maybe_leaf_pat); 129 ast::Pat::TuplePat(tuple_pat) => pats_to_process.extend(tuple_pat.args()),
130 }
131 }
132 ast::Pat::TuplePat(tuple_pat) => {
133 for arg_pat in tuple_pat.args() {
134 pats_to_process.push_back(arg_pat);
135 }
136 }
137 ast::Pat::RecordPat(record_pat) => { 130 ast::Pat::RecordPat(record_pat) => {
138 if let Some(pat_list) = record_pat.record_field_pat_list() { 131 if let Some(pat_list) = record_pat.record_field_pat_list() {
139 pats_to_process.extend( 132 pats_to_process.extend(
@@ -151,10 +144,9 @@ fn get_leaf_pats(root_pat: ast::Pat) -> Vec<ast::Pat> {
151 } 144 }
152 } 145 }
153 ast::Pat::TupleStructPat(tuple_struct_pat) => { 146 ast::Pat::TupleStructPat(tuple_struct_pat) => {
154 for arg_pat in tuple_struct_pat.args() { 147 pats_to_process.extend(tuple_struct_pat.args())
155 pats_to_process.push_back(arg_pat);
156 }
157 } 148 }
149 ast::Pat::RefPat(ref_pat) => pats_to_process.extend(ref_pat.pat()),
158 _ => (), 150 _ => (),
159 } 151 }
160 } 152 }
@@ -163,9 +155,10 @@ fn get_leaf_pats(root_pat: ast::Pat) -> Vec<ast::Pat> {
163 155
164#[cfg(test)] 156#[cfg(test)]
165mod tests { 157mod tests {
166 use crate::mock_analysis::single_file;
167 use insta::assert_debug_snapshot; 158 use insta::assert_debug_snapshot;
168 159
160 use crate::mock_analysis::single_file;
161
169 #[test] 162 #[test]
170 fn let_statement() { 163 fn let_statement() {
171 let (analysis, file_id) = single_file( 164 let (analysis, file_id) = single_file(
@@ -202,6 +195,7 @@ fn main() {
202 195
203 let test = (42, 'a'); 196 let test = (42, 'a');
204 let (a, (b, c, (d, e), f)) = (2, (3, 4, (6.6, 7.7), 5)); 197 let (a, (b, c, (d, e), f)) = (2, (3, 4, (6.6, 7.7), 5));
198 let &x = &92;
205}"#, 199}"#,
206 ); 200 );
207 201
@@ -257,6 +251,11 @@ fn main() {
257 kind: TypeHint, 251 kind: TypeHint,
258 label: "f64", 252 label: "f64",
259 }, 253 },
254 InlayHint {
255 range: [627; 628),
256 kind: TypeHint,
257 label: "i32",
258 },
260 ] 259 ]
261 "### 260 "###
262 ); 261 );