aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_ide_api
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_ide_api')
-rw-r--r--crates/ra_ide_api/src/completion/complete_dot.rs94
-rw-r--r--crates/ra_ide_api/src/completion/complete_fn_param.rs54
-rw-r--r--crates/ra_ide_api/src/completion/complete_keyword.rs960
-rw-r--r--crates/ra_ide_api/src/completion/complete_macro_in_item_position.rs95
-rw-r--r--crates/ra_ide_api/src/completion/complete_path.rs332
-rw-r--r--crates/ra_ide_api/src/completion/complete_pattern.rs60
-rw-r--r--crates/ra_ide_api/src/completion/complete_postfix.rs298
-rw-r--r--crates/ra_ide_api/src/completion/complete_record_literal.rs102
-rw-r--r--crates/ra_ide_api/src/completion/complete_record_pattern.rs56
-rw-r--r--crates/ra_ide_api/src/completion/complete_scope.rs56
-rw-r--r--crates/ra_ide_api/src/completion/complete_snippet.rs74
-rw-r--r--crates/ra_ide_api/src/completion/presentation.rs146
-rw-r--r--crates/ra_ide_api/src/diagnostics.rs44
-rw-r--r--crates/ra_ide_api/src/display/structure.rs372
-rw-r--r--crates/ra_ide_api/src/inlay_hints.rs314
-rw-r--r--crates/ra_ide_api/src/runnables.rs128
16 files changed, 1638 insertions, 1547 deletions
diff --git a/crates/ra_ide_api/src/completion/complete_dot.rs b/crates/ra_ide_api/src/completion/complete_dot.rs
index b4df6ee2a..4e2c497e1 100644
--- a/crates/ra_ide_api/src/completion/complete_dot.rs
+++ b/crates/ra_ide_api/src/completion/complete_dot.rs
@@ -88,16 +88,16 @@ mod tests {
88 ", 88 ",
89 ), 89 ),
90 @r###" 90 @r###"
91 [ 91 [
92 CompletionItem { 92 CompletionItem {
93 label: "the_field", 93 label: "the_field",
94 source_range: [94; 94), 94 source_range: [94; 94),
95 delete: [94; 94), 95 delete: [94; 94),
96 insert: "the_field", 96 insert: "the_field",
97 kind: Field, 97 kind: Field,
98 detail: "u32", 98 detail: "u32",
99 }, 99 },
100 ] 100 ]
101 "### 101 "###
102 ); 102 );
103 } 103 }
@@ -349,24 +349,24 @@ mod tests {
349 ", 349 ",
350 ), 350 ),
351 @r###" 351 @r###"
352 [ 352 [
353 CompletionItem { 353 CompletionItem {
354 label: "0", 354 label: "0",
355 source_range: [75; 75), 355 source_range: [75; 75),
356 delete: [75; 75), 356 delete: [75; 75),
357 insert: "0", 357 insert: "0",
358 kind: Field, 358 kind: Field,
359 detail: "i32", 359 detail: "i32",
360 }, 360 },
361 CompletionItem { 361 CompletionItem {
362 label: "1", 362 label: "1",
363 source_range: [75; 75), 363 source_range: [75; 75),
364 delete: [75; 75), 364 delete: [75; 75),
365 insert: "1", 365 insert: "1",
366 kind: Field, 366 kind: Field,
367 detail: "f64", 367 detail: "f64",
368 }, 368 },
369 ] 369 ]
370 "### 370 "###
371 ); 371 );
372 } 372 }
@@ -419,16 +419,16 @@ mod tests {
419 ", 419 ",
420 ), 420 ),
421 @r###" 421 @r###"
422 [ 422 [
423 CompletionItem { 423 CompletionItem {
424 label: "the_field", 424 label: "the_field",
425 source_range: [106; 106), 425 source_range: [106; 106),
426 delete: [106; 106), 426 delete: [106; 106),
427 insert: "the_field", 427 insert: "the_field",
428 kind: Field, 428 kind: Field,
429 detail: "u32", 429 detail: "u32",
430 }, 430 },
431 ] 431 ]
432 "### 432 "###
433 ); 433 );
434 } 434 }
@@ -452,15 +452,15 @@ mod tests {
452 } 452 }
453 "###, CompletionKind::Keyword), 453 "###, CompletionKind::Keyword),
454 @r###" 454 @r###"
455 [ 455 [
456 CompletionItem { 456 CompletionItem {
457 label: "await", 457 label: "await",
458 source_range: [74; 74), 458 source_range: [74; 74),
459 delete: [74; 74), 459 delete: [74; 74),
460 insert: "await", 460 insert: "await",
461 detail: "expr.await", 461 detail: "expr.await",
462 }, 462 },
463 ] 463 ]
464 "### 464 "###
465 ) 465 )
466 } 466 }
diff --git a/crates/ra_ide_api/src/completion/complete_fn_param.rs b/crates/ra_ide_api/src/completion/complete_fn_param.rs
index 3e936e3ec..502458706 100644
--- a/crates/ra_ide_api/src/completion/complete_fn_param.rs
+++ b/crates/ra_ide_api/src/completion/complete_fn_param.rs
@@ -70,15 +70,15 @@ mod tests {
70 ", 70 ",
71 ), 71 ),
72 @r###" 72 @r###"
73 [ 73 [
74 CompletionItem { 74 CompletionItem {
75 label: "file_id: FileId", 75 label: "file_id: FileId",
76 source_range: [110; 114), 76 source_range: [110; 114),
77 delete: [110; 114), 77 delete: [110; 114),
78 insert: "file_id: FileId", 78 insert: "file_id: FileId",
79 lookup: "file_id", 79 lookup: "file_id",
80 }, 80 },
81 ] 81 ]
82 "### 82 "###
83 ); 83 );
84 } 84 }
@@ -94,15 +94,15 @@ mod tests {
94 ", 94 ",
95 ), 95 ),
96 @r###" 96 @r###"
97 [ 97 [
98 CompletionItem { 98 CompletionItem {
99 label: "file_id: FileId", 99 label: "file_id: FileId",
100 source_range: [110; 114), 100 source_range: [110; 114),
101 delete: [110; 114), 101 delete: [110; 114),
102 insert: "file_id: FileId", 102 insert: "file_id: FileId",
103 lookup: "file_id", 103 lookup: "file_id",
104 }, 104 },
105 ] 105 ]
106 "### 106 "###
107 ); 107 );
108 } 108 }
@@ -121,15 +121,15 @@ mod tests {
121 ", 121 ",
122 ), 122 ),
123 @r###" 123 @r###"
124 [ 124 [
125 CompletionItem { 125 CompletionItem {
126 label: "file_id: FileId", 126 label: "file_id: FileId",
127 source_range: [289; 293), 127 source_range: [289; 293),
128 delete: [289; 293), 128 delete: [289; 293),
129 insert: "file_id: FileId", 129 insert: "file_id: FileId",
130 lookup: "file_id", 130 lookup: "file_id",
131 }, 131 },
132 ] 132 ]
133 "### 133 "###
134 ); 134 );
135 } 135 }
diff --git a/crates/ra_ide_api/src/completion/complete_keyword.rs b/crates/ra_ide_api/src/completion/complete_keyword.rs
index 48c688a08..eb7cd9ac2 100644
--- a/crates/ra_ide_api/src/completion/complete_keyword.rs
+++ b/crates/ra_ide_api/src/completion/complete_keyword.rs
@@ -131,29 +131,31 @@ mod tests {
131 use <|> 131 use <|>
132 ", 132 ",
133 ), 133 ),
134 @r###"[ 134 @r###"
135 CompletionItem { 135 [
136 label: "crate", 136 CompletionItem {
137 source_range: [21; 21), 137 label: "crate",
138 delete: [21; 21), 138 source_range: [21; 21),
139 insert: "crate::", 139 delete: [21; 21),
140 kind: Keyword, 140 insert: "crate::",
141 }, 141 kind: Keyword,
142 CompletionItem { 142 },
143 label: "self", 143 CompletionItem {
144 source_range: [21; 21), 144 label: "self",
145 delete: [21; 21), 145 source_range: [21; 21),
146 insert: "self", 146 delete: [21; 21),
147 kind: Keyword, 147 insert: "self",
148 }, 148 kind: Keyword,
149 CompletionItem { 149 },
150 label: "super", 150 CompletionItem {
151 source_range: [21; 21), 151 label: "super",
152 delete: [21; 21), 152 source_range: [21; 21),
153 insert: "super::", 153 delete: [21; 21),
154 kind: Keyword, 154 insert: "super::",
155 }, 155 kind: Keyword,
156]"### 156 },
157 ]
158 "###
157 ); 159 );
158 160
159 assert_debug_snapshot!( 161 assert_debug_snapshot!(
@@ -162,22 +164,24 @@ mod tests {
162 use a::<|> 164 use a::<|>
163 ", 165 ",
164 ), 166 ),
165 @r###"[ 167 @r###"
166 CompletionItem { 168 [
167 label: "self", 169 CompletionItem {
168 source_range: [24; 24), 170 label: "self",
169 delete: [24; 24), 171 source_range: [24; 24),
170 insert: "self", 172 delete: [24; 24),
171 kind: Keyword, 173 insert: "self",
172 }, 174 kind: Keyword,
173 CompletionItem { 175 },
174 label: "super", 176 CompletionItem {
175 source_range: [24; 24), 177 label: "super",
176 delete: [24; 24), 178 source_range: [24; 24),
177 insert: "super::", 179 delete: [24; 24),
178 kind: Keyword, 180 insert: "super::",
179 }, 181 kind: Keyword,
180]"### 182 },
183 ]
184 "###
181 ); 185 );
182 186
183 assert_debug_snapshot!( 187 assert_debug_snapshot!(
@@ -186,22 +190,24 @@ mod tests {
186 use a::{b, <|>} 190 use a::{b, <|>}
187 ", 191 ",
188 ), 192 ),
189 @r###"[ 193 @r###"
190 CompletionItem { 194 [
191 label: "self", 195 CompletionItem {
192 source_range: [28; 28), 196 label: "self",
193 delete: [28; 28), 197 source_range: [28; 28),
194 insert: "self", 198 delete: [28; 28),
195 kind: Keyword, 199 insert: "self",
196 }, 200 kind: Keyword,
197 CompletionItem { 201 },
198 label: "super", 202 CompletionItem {
199 source_range: [28; 28), 203 label: "super",
200 delete: [28; 28), 204 source_range: [28; 28),
201 insert: "super::", 205 delete: [28; 28),
202 kind: Keyword, 206 insert: "super::",
203 }, 207 kind: Keyword,
204]"### 208 },
209 ]
210 "###
205 ); 211 );
206 } 212 }
207 213
@@ -215,43 +221,45 @@ mod tests {
215 } 221 }
216 ", 222 ",
217 ), 223 ),
218 @r###"[ 224 @r###"
219 CompletionItem { 225 [
220 label: "if", 226 CompletionItem {
221 source_range: [49; 49), 227 label: "if",
222 delete: [49; 49), 228 source_range: [49; 49),
223 insert: "if $0 {}", 229 delete: [49; 49),
224 kind: Keyword, 230 insert: "if $0 {}",
225 }, 231 kind: Keyword,
226 CompletionItem { 232 },
227 label: "loop", 233 CompletionItem {
228 source_range: [49; 49), 234 label: "loop",
229 delete: [49; 49), 235 source_range: [49; 49),
230 insert: "loop {$0}", 236 delete: [49; 49),
231 kind: Keyword, 237 insert: "loop {$0}",
232 }, 238 kind: Keyword,
233 CompletionItem { 239 },
234 label: "match", 240 CompletionItem {
235 source_range: [49; 49), 241 label: "match",
236 delete: [49; 49), 242 source_range: [49; 49),
237 insert: "match $0 {}", 243 delete: [49; 49),
238 kind: Keyword, 244 insert: "match $0 {}",
239 }, 245 kind: Keyword,
240 CompletionItem { 246 },
241 label: "return", 247 CompletionItem {
242 source_range: [49; 49), 248 label: "return",
243 delete: [49; 49), 249 source_range: [49; 49),
244 insert: "return;", 250 delete: [49; 49),
245 kind: Keyword, 251 insert: "return;",
246 }, 252 kind: Keyword,
247 CompletionItem { 253 },
248 label: "while", 254 CompletionItem {
249 source_range: [49; 49), 255 label: "while",
250 delete: [49; 49), 256 source_range: [49; 49),
251 insert: "while $0 {}", 257 delete: [49; 49),
252 kind: Keyword, 258 insert: "while $0 {}",
253 }, 259 kind: Keyword,
254]"### 260 },
261 ]
262 "###
255 ); 263 );
256 } 264 }
257 265
@@ -267,57 +275,59 @@ mod tests {
267 } 275 }
268 ", 276 ",
269 ), 277 ),
270 @r###"[ 278 @r###"
271 CompletionItem { 279 [
272 label: "else", 280 CompletionItem {
273 source_range: [108; 108), 281 label: "else",
274 delete: [108; 108), 282 source_range: [108; 108),
275 insert: "else {$0}", 283 delete: [108; 108),
276 kind: Keyword, 284 insert: "else {$0}",
277 }, 285 kind: Keyword,
278 CompletionItem { 286 },
279 label: "else if", 287 CompletionItem {
280 source_range: [108; 108), 288 label: "else if",
281 delete: [108; 108), 289 source_range: [108; 108),
282 insert: "else if $0 {}", 290 delete: [108; 108),
283 kind: Keyword, 291 insert: "else if $0 {}",
284 }, 292 kind: Keyword,
285 CompletionItem { 293 },
286 label: "if", 294 CompletionItem {
287 source_range: [108; 108), 295 label: "if",
288 delete: [108; 108), 296 source_range: [108; 108),
289 insert: "if $0 {}", 297 delete: [108; 108),
290 kind: Keyword, 298 insert: "if $0 {}",
291 }, 299 kind: Keyword,
292 CompletionItem { 300 },
293 label: "loop", 301 CompletionItem {
294 source_range: [108; 108), 302 label: "loop",
295 delete: [108; 108), 303 source_range: [108; 108),
296 insert: "loop {$0}", 304 delete: [108; 108),
297 kind: Keyword, 305 insert: "loop {$0}",
298 }, 306 kind: Keyword,
299 CompletionItem { 307 },
300 label: "match", 308 CompletionItem {
301 source_range: [108; 108), 309 label: "match",
302 delete: [108; 108), 310 source_range: [108; 108),
303 insert: "match $0 {}", 311 delete: [108; 108),
304 kind: Keyword, 312 insert: "match $0 {}",
305 }, 313 kind: Keyword,
306 CompletionItem { 314 },
307 label: "return", 315 CompletionItem {
308 source_range: [108; 108), 316 label: "return",
309 delete: [108; 108), 317 source_range: [108; 108),
310 insert: "return;", 318 delete: [108; 108),
311 kind: Keyword, 319 insert: "return;",
312 }, 320 kind: Keyword,
313 CompletionItem { 321 },
314 label: "while", 322 CompletionItem {
315 source_range: [108; 108), 323 label: "while",
316 delete: [108; 108), 324 source_range: [108; 108),
317 insert: "while $0 {}", 325 delete: [108; 108),
318 kind: Keyword, 326 insert: "while $0 {}",
319 }, 327 kind: Keyword,
320]"### 328 },
329 ]
330 "###
321 ); 331 );
322 } 332 }
323 333
@@ -332,43 +342,45 @@ mod tests {
332 } 342 }
333 ", 343 ",
334 ), 344 ),
335 @r###"[ 345 @r###"
336 CompletionItem { 346 [
337 label: "if", 347 CompletionItem {
338 source_range: [56; 56), 348 label: "if",
339 delete: [56; 56), 349 source_range: [56; 56),
340 insert: "if $0 {}", 350 delete: [56; 56),
341 kind: Keyword, 351 insert: "if $0 {}",
342 }, 352 kind: Keyword,
343 CompletionItem { 353 },
344 label: "loop", 354 CompletionItem {
345 source_range: [56; 56), 355 label: "loop",
346 delete: [56; 56), 356 source_range: [56; 56),
347 insert: "loop {$0}", 357 delete: [56; 56),
348 kind: Keyword, 358 insert: "loop {$0}",
349 }, 359 kind: Keyword,
350 CompletionItem { 360 },
351 label: "match", 361 CompletionItem {
352 source_range: [56; 56), 362 label: "match",
353 delete: [56; 56), 363 source_range: [56; 56),
354 insert: "match $0 {}", 364 delete: [56; 56),
355 kind: Keyword, 365 insert: "match $0 {}",
356 }, 366 kind: Keyword,
357 CompletionItem { 367 },
358 label: "return", 368 CompletionItem {
359 source_range: [56; 56), 369 label: "return",
360 delete: [56; 56), 370 source_range: [56; 56),
361 insert: "return $0;", 371 delete: [56; 56),
362 kind: Keyword, 372 insert: "return $0;",
363 }, 373 kind: Keyword,
364 CompletionItem { 374 },
365 label: "while", 375 CompletionItem {
366 source_range: [56; 56), 376 label: "while",
367 delete: [56; 56), 377 source_range: [56; 56),
368 insert: "while $0 {}", 378 delete: [56; 56),
369 kind: Keyword, 379 insert: "while $0 {}",
370 }, 380 kind: Keyword,
371]"### 381 },
382 ]
383 "###
372 ); 384 );
373 assert_debug_snapshot!( 385 assert_debug_snapshot!(
374 do_keyword_completion( 386 do_keyword_completion(
@@ -379,43 +391,45 @@ mod tests {
379 } 391 }
380 ", 392 ",
381 ), 393 ),
382 @r###"[ 394 @r###"
383 CompletionItem { 395 [
384 label: "if", 396 CompletionItem {
385 source_range: [49; 49), 397 label: "if",
386 delete: [49; 49), 398 source_range: [49; 49),
387 insert: "if $0 {}", 399 delete: [49; 49),
388 kind: Keyword, 400 insert: "if $0 {}",
389 }, 401 kind: Keyword,
390 CompletionItem { 402 },
391 label: "loop", 403 CompletionItem {
392 source_range: [49; 49), 404 label: "loop",
393 delete: [49; 49), 405 source_range: [49; 49),
394 insert: "loop {$0}", 406 delete: [49; 49),
395 kind: Keyword, 407 insert: "loop {$0}",
396 }, 408 kind: Keyword,
397 CompletionItem { 409 },
398 label: "match", 410 CompletionItem {
399 source_range: [49; 49), 411 label: "match",
400 delete: [49; 49), 412 source_range: [49; 49),
401 insert: "match $0 {}", 413 delete: [49; 49),
402 kind: Keyword, 414 insert: "match $0 {}",
403 }, 415 kind: Keyword,
404 CompletionItem { 416 },
405 label: "return", 417 CompletionItem {
406 source_range: [49; 49), 418 label: "return",
407 delete: [49; 49), 419 source_range: [49; 49),
408 insert: "return;", 420 delete: [49; 49),
409 kind: Keyword, 421 insert: "return;",
410 }, 422 kind: Keyword,
411 CompletionItem { 423 },
412 label: "while", 424 CompletionItem {
413 source_range: [49; 49), 425 label: "while",
414 delete: [49; 49), 426 source_range: [49; 49),
415 insert: "while $0 {}", 427 delete: [49; 49),
416 kind: Keyword, 428 insert: "while $0 {}",
417 }, 429 kind: Keyword,
418]"### 430 },
431 ]
432 "###
419 ); 433 );
420 } 434 }
421 435
@@ -431,43 +445,45 @@ mod tests {
431 } 445 }
432 ", 446 ",
433 ), 447 ),
434 @r###"[ 448 @r###"
435 CompletionItem { 449 [
436 label: "if", 450 CompletionItem {
437 source_range: [97; 97), 451 label: "if",
438 delete: [97; 97), 452 source_range: [97; 97),
439 insert: "if $0 {}", 453 delete: [97; 97),
440 kind: Keyword, 454 insert: "if $0 {}",
441 }, 455 kind: Keyword,
442 CompletionItem { 456 },
443 label: "loop", 457 CompletionItem {
444 source_range: [97; 97), 458 label: "loop",
445 delete: [97; 97), 459 source_range: [97; 97),
446 insert: "loop {$0}", 460 delete: [97; 97),
447 kind: Keyword, 461 insert: "loop {$0}",
448 }, 462 kind: Keyword,
449 CompletionItem { 463 },
450 label: "match", 464 CompletionItem {
451 source_range: [97; 97), 465 label: "match",
452 delete: [97; 97), 466 source_range: [97; 97),
453 insert: "match $0 {}", 467 delete: [97; 97),
454 kind: Keyword, 468 insert: "match $0 {}",
455 }, 469 kind: Keyword,
456 CompletionItem { 470 },
457 label: "return", 471 CompletionItem {
458 source_range: [97; 97), 472 label: "return",
459 delete: [97; 97), 473 source_range: [97; 97),
460 insert: "return $0", 474 delete: [97; 97),
461 kind: Keyword, 475 insert: "return $0",
462 }, 476 kind: Keyword,
463 CompletionItem { 477 },
464 label: "while", 478 CompletionItem {
465 source_range: [97; 97), 479 label: "while",
466 delete: [97; 97), 480 source_range: [97; 97),
467 insert: "while $0 {}", 481 delete: [97; 97),
468 kind: Keyword, 482 insert: "while $0 {}",
469 }, 483 kind: Keyword,
470]"### 484 },
485 ]
486 "###
471 ); 487 );
472 } 488 }
473 489
@@ -483,43 +499,45 @@ mod tests {
483 } 499 }
484 ", 500 ",
485 ), 501 ),
486 @r###"[ 502 @r###"
487 CompletionItem { 503 [
488 label: "if", 504 CompletionItem {
489 source_range: [95; 95), 505 label: "if",
490 delete: [95; 95), 506 source_range: [95; 95),
491 insert: "if $0 {}", 507 delete: [95; 95),
492 kind: Keyword, 508 insert: "if $0 {}",
493 }, 509 kind: Keyword,
494 CompletionItem { 510 },
495 label: "loop", 511 CompletionItem {
496 source_range: [95; 95), 512 label: "loop",
497 delete: [95; 95), 513 source_range: [95; 95),
498 insert: "loop {$0}", 514 delete: [95; 95),
499 kind: Keyword, 515 insert: "loop {$0}",
500 }, 516 kind: Keyword,
501 CompletionItem { 517 },
502 label: "match", 518 CompletionItem {
503 source_range: [95; 95), 519 label: "match",
504 delete: [95; 95), 520 source_range: [95; 95),
505 insert: "match $0 {}", 521 delete: [95; 95),
506 kind: Keyword, 522 insert: "match $0 {}",
507 }, 523 kind: Keyword,
508 CompletionItem { 524 },
509 label: "return", 525 CompletionItem {
510 source_range: [95; 95), 526 label: "return",
511 delete: [95; 95), 527 source_range: [95; 95),
512 insert: "return $0;", 528 delete: [95; 95),
513 kind: Keyword, 529 insert: "return $0;",
514 }, 530 kind: Keyword,
515 CompletionItem { 531 },
516 label: "while", 532 CompletionItem {
517 source_range: [95; 95), 533 label: "while",
518 delete: [95; 95), 534 source_range: [95; 95),
519 insert: "while $0 {}", 535 delete: [95; 95),
520 kind: Keyword, 536 insert: "while $0 {}",
521 }, 537 kind: Keyword,
522]"### 538 },
539 ]
540 "###
523 ); 541 );
524 assert_debug_snapshot!( 542 assert_debug_snapshot!(
525 do_keyword_completion( 543 do_keyword_completion(
@@ -533,43 +551,45 @@ mod tests {
533 } 551 }
534 ", 552 ",
535 ), 553 ),
536 @r###"[ 554 @r###"
537 CompletionItem { 555 [
538 label: "if", 556 CompletionItem {
539 source_range: [95; 95), 557 label: "if",
540 delete: [95; 95), 558 source_range: [95; 95),
541 insert: "if $0 {}", 559 delete: [95; 95),
542 kind: Keyword, 560 insert: "if $0 {}",
543 }, 561 kind: Keyword,
544 CompletionItem { 562 },
545 label: "loop", 563 CompletionItem {
546 source_range: [95; 95), 564 label: "loop",
547 delete: [95; 95), 565 source_range: [95; 95),
548 insert: "loop {$0}", 566 delete: [95; 95),
549 kind: Keyword, 567 insert: "loop {$0}",
550 }, 568 kind: Keyword,
551 CompletionItem { 569 },
552 label: "match", 570 CompletionItem {
553 source_range: [95; 95), 571 label: "match",
554 delete: [95; 95), 572 source_range: [95; 95),
555 insert: "match $0 {}", 573 delete: [95; 95),
556 kind: Keyword, 574 insert: "match $0 {}",
557 }, 575 kind: Keyword,
558 CompletionItem { 576 },
559 label: "return", 577 CompletionItem {
560 source_range: [95; 95), 578 label: "return",
561 delete: [95; 95), 579 source_range: [95; 95),
562 insert: "return $0;", 580 delete: [95; 95),
563 kind: Keyword, 581 insert: "return $0;",
564 }, 582 kind: Keyword,
565 CompletionItem { 583 },
566 label: "while", 584 CompletionItem {
567 source_range: [95; 95), 585 label: "while",
568 delete: [95; 95), 586 source_range: [95; 95),
569 insert: "while $0 {}", 587 delete: [95; 95),
570 kind: Keyword, 588 insert: "while $0 {}",
571 }, 589 kind: Keyword,
572]"### 590 },
591 ]
592 "###
573 ); 593 );
574 } 594 }
575 595
@@ -583,57 +603,59 @@ mod tests {
583 } 603 }
584 ", 604 ",
585 ), 605 ),
586 @r###"[ 606 @r###"
587 CompletionItem { 607 [
588 label: "break", 608 CompletionItem {
589 source_range: [63; 63), 609 label: "break",
590 delete: [63; 63), 610 source_range: [63; 63),
591 insert: "break;", 611 delete: [63; 63),
592 kind: Keyword, 612 insert: "break;",
593 }, 613 kind: Keyword,
594 CompletionItem { 614 },
595 label: "continue", 615 CompletionItem {
596 source_range: [63; 63), 616 label: "continue",
597 delete: [63; 63), 617 source_range: [63; 63),
598 insert: "continue;", 618 delete: [63; 63),
599 kind: Keyword, 619 insert: "continue;",
600 }, 620 kind: Keyword,
601 CompletionItem { 621 },
602 label: "if", 622 CompletionItem {
603 source_range: [63; 63), 623 label: "if",
604 delete: [63; 63), 624 source_range: [63; 63),
605 insert: "if $0 {}", 625 delete: [63; 63),
606 kind: Keyword, 626 insert: "if $0 {}",
607 }, 627 kind: Keyword,
608 CompletionItem { 628 },
609 label: "loop", 629 CompletionItem {
610 source_range: [63; 63), 630 label: "loop",
611 delete: [63; 63), 631 source_range: [63; 63),
612 insert: "loop {$0}", 632 delete: [63; 63),
613 kind: Keyword, 633 insert: "loop {$0}",
614 }, 634 kind: Keyword,
615 CompletionItem { 635 },
616 label: "match", 636 CompletionItem {
617 source_range: [63; 63), 637 label: "match",
618 delete: [63; 63), 638 source_range: [63; 63),
619 insert: "match $0 {}", 639 delete: [63; 63),
620 kind: Keyword, 640 insert: "match $0 {}",
621 }, 641 kind: Keyword,
622 CompletionItem { 642 },
623 label: "return", 643 CompletionItem {
624 source_range: [63; 63), 644 label: "return",
625 delete: [63; 63), 645 source_range: [63; 63),
626 insert: "return $0;", 646 delete: [63; 63),
627 kind: Keyword, 647 insert: "return $0;",
628 }, 648 kind: Keyword,
629 CompletionItem { 649 },
630 label: "while", 650 CompletionItem {
631 source_range: [63; 63), 651 label: "while",
632 delete: [63; 63), 652 source_range: [63; 63),
633 insert: "while $0 {}", 653 delete: [63; 63),
634 kind: Keyword, 654 insert: "while $0 {}",
635 }, 655 kind: Keyword,
636]"### 656 },
657 ]
658 "###
637 ); 659 );
638 660
639 // No completion: lambda isolates control flow 661 // No completion: lambda isolates control flow
@@ -645,43 +667,45 @@ mod tests {
645 } 667 }
646 ", 668 ",
647 ), 669 ),
648 @r###"[ 670 @r###"
649 CompletionItem { 671 [
650 label: "if", 672 CompletionItem {
651 source_range: [68; 68), 673 label: "if",
652 delete: [68; 68), 674 source_range: [68; 68),
653 insert: "if $0 {}", 675 delete: [68; 68),
654 kind: Keyword, 676 insert: "if $0 {}",
655 }, 677 kind: Keyword,
656 CompletionItem { 678 },
657 label: "loop", 679 CompletionItem {
658 source_range: [68; 68), 680 label: "loop",
659 delete: [68; 68), 681 source_range: [68; 68),
660 insert: "loop {$0}", 682 delete: [68; 68),
661 kind: Keyword, 683 insert: "loop {$0}",
662 }, 684 kind: Keyword,
663 CompletionItem { 685 },
664 label: "match", 686 CompletionItem {
665 source_range: [68; 68), 687 label: "match",
666 delete: [68; 68), 688 source_range: [68; 68),
667 insert: "match $0 {}", 689 delete: [68; 68),
668 kind: Keyword, 690 insert: "match $0 {}",
669 }, 691 kind: Keyword,
670 CompletionItem { 692 },
671 label: "return", 693 CompletionItem {
672 source_range: [68; 68), 694 label: "return",
673 delete: [68; 68), 695 source_range: [68; 68),
674 insert: "return $0;", 696 delete: [68; 68),
675 kind: Keyword, 697 insert: "return $0;",
676 }, 698 kind: Keyword,
677 CompletionItem { 699 },
678 label: "while", 700 CompletionItem {
679 source_range: [68; 68), 701 label: "while",
680 delete: [68; 68), 702 source_range: [68; 68),
681 insert: "while $0 {}", 703 delete: [68; 68),
682 kind: Keyword, 704 insert: "while $0 {}",
683 }, 705 kind: Keyword,
684]"### 706 },
707 ]
708 "###
685 ); 709 );
686 } 710 }
687 711
@@ -699,57 +723,59 @@ mod tests {
699 } 723 }
700 ", 724 ",
701 ), 725 ),
702 @r###"[ 726 @r###"
703 CompletionItem { 727 [
704 label: "break", 728 CompletionItem {
705 source_range: [122; 124), 729 label: "break",
706 delete: [122; 124), 730 source_range: [122; 124),
707 insert: "break", 731 delete: [122; 124),
708 kind: Keyword, 732 insert: "break",
709 }, 733 kind: Keyword,
710 CompletionItem { 734 },
711 label: "continue", 735 CompletionItem {
712 source_range: [122; 124), 736 label: "continue",
713 delete: [122; 124), 737 source_range: [122; 124),
714 insert: "continue", 738 delete: [122; 124),
715 kind: Keyword, 739 insert: "continue",
716 }, 740 kind: Keyword,
717 CompletionItem { 741 },
718 label: "if", 742 CompletionItem {
719 source_range: [122; 124), 743 label: "if",
720 delete: [122; 124), 744 source_range: [122; 124),
721 insert: "if $0 {}", 745 delete: [122; 124),
722 kind: Keyword, 746 insert: "if $0 {}",
723 }, 747 kind: Keyword,
724 CompletionItem { 748 },
725 label: "loop", 749 CompletionItem {
726 source_range: [122; 124), 750 label: "loop",
727 delete: [122; 124), 751 source_range: [122; 124),
728 insert: "loop {$0}", 752 delete: [122; 124),
729 kind: Keyword, 753 insert: "loop {$0}",
730 }, 754 kind: Keyword,
731 CompletionItem { 755 },
732 label: "match", 756 CompletionItem {
733 source_range: [122; 124), 757 label: "match",
734 delete: [122; 124), 758 source_range: [122; 124),
735 insert: "match $0 {}", 759 delete: [122; 124),
736 kind: Keyword, 760 insert: "match $0 {}",
737 }, 761 kind: Keyword,
738 CompletionItem { 762 },
739 label: "return", 763 CompletionItem {
740 source_range: [122; 124), 764 label: "return",
741 delete: [122; 124), 765 source_range: [122; 124),
742 insert: "return", 766 delete: [122; 124),
743 kind: Keyword, 767 insert: "return",
744 }, 768 kind: Keyword,
745 CompletionItem { 769 },
746 label: "while", 770 CompletionItem {
747 source_range: [122; 124), 771 label: "while",
748 delete: [122; 124), 772 source_range: [122; 124),
749 insert: "while $0 {}", 773 delete: [122; 124),
750 kind: Keyword, 774 insert: "while $0 {}",
751 }, 775 kind: Keyword,
752]"### 776 },
777 ]
778 "###
753 ) 779 )
754 } 780 }
755} 781}
diff --git a/crates/ra_ide_api/src/completion/complete_macro_in_item_position.rs b/crates/ra_ide_api/src/completion/complete_macro_in_item_position.rs
index 09f743c66..faadd1e3f 100644
--- a/crates/ra_ide_api/src/completion/complete_macro_in_item_position.rs
+++ b/crates/ra_ide_api/src/completion/complete_macro_in_item_position.rs
@@ -37,16 +37,18 @@ mod tests {
37 <|> 37 <|>
38 " 38 "
39 ), 39 ),
40 @r##"[ 40 @r###"
41 CompletionItem { 41 [
42 label: "foo!", 42 CompletionItem {
43 source_range: [46; 46), 43 label: "foo!",
44 delete: [46; 46), 44 source_range: [46; 46),
45 insert: "foo!($0)", 45 delete: [46; 46),
46 kind: Macro, 46 insert: "foo!($0)",
47 detail: "macro_rules! foo", 47 kind: Macro,
48 }, 48 detail: "macro_rules! foo",
49]"## 49 },
50 ]
51 "###
50 ); 52 );
51 } 53 }
52 54
@@ -75,19 +77,21 @@ mod tests {
75 <|> 77 <|>
76 " 78 "
77 ), 79 ),
78 @r##"[ 80 @r###"
79 CompletionItem { 81 [
80 label: "vec!", 82 CompletionItem {
81 source_range: [280; 280), 83 label: "vec!",
82 delete: [280; 280), 84 source_range: [280; 280),
83 insert: "vec![$0]", 85 delete: [280; 280),
84 kind: Macro, 86 insert: "vec![$0]",
85 detail: "macro_rules! vec", 87 kind: Macro,
86 documentation: Documentation( 88 detail: "macro_rules! vec",
87 "Creates a [`Vec`] containing the arguments.\n\n- Create a [`Vec`] containing a given list of elements:\n\n```\nlet v = vec![1, 2, 3];\nassert_eq!(v[0], 1);\nassert_eq!(v[1], 2);\nassert_eq!(v[2], 3);\n```", 89 documentation: Documentation(
88 ), 90 "Creates a [`Vec`] containing the arguments.\n\n- Create a [`Vec`] containing a given list of elements:\n\n```\nlet v = vec![1, 2, 3];\nassert_eq!(v[0], 1);\nassert_eq!(v[1], 2);\nassert_eq!(v[2], 3);\n```",
89 }, 91 ),
90]"## 92 },
93 ]
94 "###
91 ); 95 );
92 } 96 }
93 97
@@ -110,28 +114,29 @@ mod tests {
110 } 114 }
111 " 115 "
112 ), 116 ),
113 @r###"[ 117 @r###"
114 CompletionItem { 118 [
115 label: "foo!", 119 CompletionItem {
116 source_range: [163; 163), 120 label: "foo!",
117 delete: [163; 163), 121 source_range: [163; 163),
118 insert: "foo! {$0}", 122 delete: [163; 163),
119 kind: Macro, 123 insert: "foo! {$0}",
120 detail: "macro_rules! foo", 124 kind: Macro,
121 documentation: Documentation( 125 detail: "macro_rules! foo",
122 "Foo\n\nNot call `fooo!()` `fooo!()`, or `_foo![]` `_foo![]`.\nCall as `let _=foo! { hello world };`", 126 documentation: Documentation(
123 ), 127 "Foo\n\nNot call `fooo!()` `fooo!()`, or `_foo![]` `_foo![]`.\nCall as `let _=foo! { hello world };`",
124 }, 128 ),
125 CompletionItem { 129 },
126 label: "main()", 130 CompletionItem {
127 source_range: [163; 163), 131 label: "main()",
128 delete: [163; 163), 132 source_range: [163; 163),
129 insert: "main()$0", 133 delete: [163; 163),
130 kind: Function, 134 insert: "main()$0",
131 lookup: "main", 135 kind: Function,
132 detail: "fn main()", 136 lookup: "main",
133 }, 137 detail: "fn main()",
134] 138 },
139 ]
135 "### 140 "###
136 ); 141 );
137 } 142 }
diff --git a/crates/ra_ide_api/src/completion/complete_path.rs b/crates/ra_ide_api/src/completion/complete_path.rs
index 09ca40179..5d974cf6d 100644
--- a/crates/ra_ide_api/src/completion/complete_path.rs
+++ b/crates/ra_ide_api/src/completion/complete_path.rs
@@ -152,18 +152,20 @@ mod tests {
152 } 152 }
153 " 153 "
154 ), 154 ),
155 @r###"[ 155 @r###"
156 CompletionItem { 156 [
157 label: "my", 157 CompletionItem {
158 source_range: [27; 29), 158 label: "my",
159 delete: [27; 29), 159 source_range: [27; 29),
160 insert: "my", 160 delete: [27; 29),
161 kind: Module, 161 insert: "my",
162 documentation: Documentation( 162 kind: Module,
163 "Some simple\ndocs describing `mod my`.", 163 documentation: Documentation(
164 ), 164 "Some simple\ndocs describing `mod my`.",
165 }, 165 ),
166]"### 166 },
167 ]
168 "###
167 ); 169 );
168 } 170 }
169 171
@@ -179,15 +181,17 @@ mod tests {
179 } 181 }
180 " 182 "
181 ), 183 ),
182 @r###"[ 184 @r###"
183 CompletionItem { 185 [
184 label: "Bar", 186 CompletionItem {
185 source_range: [30; 30), 187 label: "Bar",
186 delete: [30; 30), 188 source_range: [30; 30),
187 insert: "Bar", 189 delete: [30; 30),
188 kind: Struct, 190 insert: "Bar",
189 }, 191 kind: Struct,
190]"### 192 },
193 ]
194 "###
191 ); 195 );
192 } 196 }
193 197
@@ -203,22 +207,24 @@ mod tests {
203 use crate::Sp<|> 207 use crate::Sp<|>
204 " 208 "
205 ), 209 ),
206 @r###"[ 210 @r###"
207 CompletionItem { 211 [
208 label: "Spam", 212 CompletionItem {
209 source_range: [11; 13), 213 label: "Spam",
210 delete: [11; 13), 214 source_range: [11; 13),
211 insert: "Spam", 215 delete: [11; 13),
212 kind: Struct, 216 insert: "Spam",
213 }, 217 kind: Struct,
214 CompletionItem { 218 },
215 label: "foo", 219 CompletionItem {
216 source_range: [11; 13), 220 label: "foo",
217 delete: [11; 13), 221 source_range: [11; 13),
218 insert: "foo", 222 delete: [11; 13),
219 kind: Module, 223 insert: "foo",
220 }, 224 kind: Module,
221]"### 225 },
226 ]
227 "###
222 ); 228 );
223 } 229 }
224 230
@@ -234,22 +240,24 @@ mod tests {
234 use crate::{Sp<|>}; 240 use crate::{Sp<|>};
235 " 241 "
236 ), 242 ),
237 @r###"[ 243 @r###"
238 CompletionItem { 244 [
239 label: "Spam", 245 CompletionItem {
240 source_range: [12; 14), 246 label: "Spam",
241 delete: [12; 14), 247 source_range: [12; 14),
242 insert: "Spam", 248 delete: [12; 14),
243 kind: Struct, 249 insert: "Spam",
244 }, 250 kind: Struct,
245 CompletionItem { 251 },
246 label: "foo", 252 CompletionItem {
247 source_range: [12; 14), 253 label: "foo",
248 delete: [12; 14), 254 source_range: [12; 14),
249 insert: "foo", 255 delete: [12; 14),
250 kind: Module, 256 insert: "foo",
251 }, 257 kind: Module,
252]"### 258 },
259 ]
260 "###
253 ); 261 );
254 } 262 }
255 263
@@ -269,15 +277,17 @@ mod tests {
269 use crate::{bar::{baz::Sp<|>}}; 277 use crate::{bar::{baz::Sp<|>}};
270 " 278 "
271 ), 279 ),
272 @r###"[ 280 @r###"
273 CompletionItem { 281 [
274 label: "Spam", 282 CompletionItem {
275 source_range: [23; 25), 283 label: "Spam",
276 delete: [23; 25), 284 source_range: [23; 25),
277 insert: "Spam", 285 delete: [23; 25),
278 kind: Struct, 286 insert: "Spam",
279 }, 287 kind: Struct,
280]"### 288 },
289 ]
290 "###
281 ); 291 );
282 } 292 }
283 293
@@ -297,30 +307,32 @@ mod tests {
297 fn foo() { let _ = E::<|> } 307 fn foo() { let _ = E::<|> }
298 " 308 "
299 ), 309 ),
300 @r###"[ 310 @r###"
301 CompletionItem { 311 [
302 label: "Bar", 312 CompletionItem {
303 source_range: [116; 116), 313 label: "Bar",
304 delete: [116; 116), 314 source_range: [116; 116),
305 insert: "Bar", 315 delete: [116; 116),
306 kind: EnumVariant, 316 insert: "Bar",
307 detail: "(i32)", 317 kind: EnumVariant,
308 documentation: Documentation( 318 detail: "(i32)",
309 "Bar Variant with i32", 319 documentation: Documentation(
310 ), 320 "Bar Variant with i32",
311 }, 321 ),
312 CompletionItem { 322 },
313 label: "Foo", 323 CompletionItem {
314 source_range: [116; 116), 324 label: "Foo",
315 delete: [116; 116), 325 source_range: [116; 116),
316 insert: "Foo", 326 delete: [116; 116),
317 kind: EnumVariant, 327 insert: "Foo",
318 detail: "()", 328 kind: EnumVariant,
319 documentation: Documentation( 329 detail: "()",
320 "Foo Variant", 330 documentation: Documentation(
321 ), 331 "Foo Variant",
322 }, 332 ),
323]"### 333 },
334 ]
335 "###
324 ); 336 );
325 } 337 }
326 338
@@ -343,41 +355,43 @@ mod tests {
343 fn foo() { let _ = E::<|> } 355 fn foo() { let _ = E::<|> }
344 " 356 "
345 ), 357 ),
346 @r###"[ 358 @r###"
347 CompletionItem { 359 [
348 label: "Bar", 360 CompletionItem {
349 source_range: [180; 180), 361 label: "Bar",
350 delete: [180; 180), 362 source_range: [180; 180),
351 insert: "Bar", 363 delete: [180; 180),
352 kind: EnumVariant, 364 insert: "Bar",
353 detail: "(i32, u32)", 365 kind: EnumVariant,
354 documentation: Documentation( 366 detail: "(i32, u32)",
355 "Bar Variant with i32 and u32", 367 documentation: Documentation(
356 ), 368 "Bar Variant with i32 and u32",
357 }, 369 ),
358 CompletionItem { 370 },
359 label: "Foo", 371 CompletionItem {
360 source_range: [180; 180), 372 label: "Foo",
361 delete: [180; 180), 373 source_range: [180; 180),
362 insert: "Foo", 374 delete: [180; 180),
363 kind: EnumVariant, 375 insert: "Foo",
364 detail: "()", 376 kind: EnumVariant,
365 documentation: Documentation( 377 detail: "()",
366 "Foo Variant (empty)", 378 documentation: Documentation(
367 ), 379 "Foo Variant (empty)",
368 }, 380 ),
369 CompletionItem { 381 },
370 label: "S", 382 CompletionItem {
371 source_range: [180; 180), 383 label: "S",
372 delete: [180; 180), 384 source_range: [180; 180),
373 insert: "S", 385 delete: [180; 180),
374 kind: EnumVariant, 386 insert: "S",
375 detail: "(S)", 387 kind: EnumVariant,
376 documentation: Documentation( 388 detail: "(S)",
377 "", 389 documentation: Documentation(
378 ), 390 "",
379 }, 391 ),
380]"### 392 },
393 ]
394 "###
381 ); 395 );
382 } 396 }
383 397
@@ -434,19 +448,21 @@ mod tests {
434 fn foo() { let _ = S::<|> } 448 fn foo() { let _ = S::<|> }
435 " 449 "
436 ), 450 ),
437 @r###"[ 451 @r###"
438 CompletionItem { 452 [
439 label: "C", 453 CompletionItem {
440 source_range: [107; 107), 454 label: "C",
441 delete: [107; 107), 455 source_range: [107; 107),
442 insert: "C", 456 delete: [107; 107),
443 kind: Const, 457 insert: "C",
444 detail: "const C: i32 = 42;", 458 kind: Const,
445 documentation: Documentation( 459 detail: "const C: i32 = 42;",
446 "An associated const", 460 documentation: Documentation(
447 ), 461 "An associated const",
448 }, 462 ),
449]"### 463 },
464 ]
465 "###
450 ); 466 );
451 } 467 }
452 468
@@ -467,19 +483,21 @@ mod tests {
467 fn foo() { let _ = S::<|> } 483 fn foo() { let _ = S::<|> }
468 " 484 "
469 ), 485 ),
470 @r###"[ 486 @r###"
471 CompletionItem { 487 [
472 label: "T", 488 CompletionItem {
473 source_range: [101; 101), 489 label: "T",
474 delete: [101; 101), 490 source_range: [101; 101),
475 insert: "T", 491 delete: [101; 101),
476 kind: TypeAlias, 492 insert: "T",
477 detail: "type T = i32;", 493 kind: TypeAlias,
478 documentation: Documentation( 494 detail: "type T = i32;",
479 "An associated type", 495 documentation: Documentation(
480 ), 496 "An associated type",
481 }, 497 ),
482]"### 498 },
499 ]
500 "###
483 ); 501 );
484 } 502 }
485 503
@@ -569,15 +587,17 @@ mod tests {
569 } 587 }
570 " 588 "
571 ), 589 ),
572 @r###"[ 590 @r###"
573 CompletionItem { 591 [
574 label: "bar", 592 CompletionItem {
575 source_range: [9; 9), 593 label: "bar",
576 delete: [9; 9), 594 source_range: [9; 9),
577 insert: "bar", 595 delete: [9; 9),
578 kind: Module, 596 insert: "bar",
579 }, 597 kind: Module,
580]"### 598 },
599 ]
600 "###
581 ); 601 );
582 } 602 }
583 603
diff --git a/crates/ra_ide_api/src/completion/complete_pattern.rs b/crates/ra_ide_api/src/completion/complete_pattern.rs
index 513ad6e5f..fd03b1c40 100644
--- a/crates/ra_ide_api/src/completion/complete_pattern.rs
+++ b/crates/ra_ide_api/src/completion/complete_pattern.rs
@@ -54,36 +54,36 @@ mod tests {
54 ", 54 ",
55 ); 55 );
56 assert_debug_snapshot!(completions, @r###" 56 assert_debug_snapshot!(completions, @r###"
57 [ 57 [
58 CompletionItem { 58 CompletionItem {
59 label: "E", 59 label: "E",
60 source_range: [246; 246), 60 source_range: [246; 246),
61 delete: [246; 246), 61 delete: [246; 246),
62 insert: "E", 62 insert: "E",
63 kind: Enum, 63 kind: Enum,
64 }, 64 },
65 CompletionItem { 65 CompletionItem {
66 label: "X", 66 label: "X",
67 source_range: [246; 246), 67 source_range: [246; 246),
68 delete: [246; 246), 68 delete: [246; 246),
69 insert: "X", 69 insert: "X",
70 kind: EnumVariant, 70 kind: EnumVariant,
71 }, 71 },
72 CompletionItem { 72 CompletionItem {
73 label: "Z", 73 label: "Z",
74 source_range: [246; 246), 74 source_range: [246; 246),
75 delete: [246; 246), 75 delete: [246; 246),
76 insert: "Z", 76 insert: "Z",
77 kind: Const, 77 kind: Const,
78 }, 78 },
79 CompletionItem { 79 CompletionItem {
80 label: "m", 80 label: "m",
81 source_range: [246; 246), 81 source_range: [246; 246),
82 delete: [246; 246), 82 delete: [246; 246),
83 insert: "m", 83 insert: "m",
84 kind: Module, 84 kind: Module,
85 }, 85 },
86 ] 86 ]
87 "###); 87 "###);
88 } 88 }
89} 89}
diff --git a/crates/ra_ide_api/src/completion/complete_postfix.rs b/crates/ra_ide_api/src/completion/complete_postfix.rs
index 99fed8689..17b75cf7e 100644
--- a/crates/ra_ide_api/src/completion/complete_postfix.rs
+++ b/crates/ra_ide_api/src/completion/complete_postfix.rs
@@ -104,64 +104,66 @@ mod tests {
104 } 104 }
105 "#, 105 "#,
106 ), 106 ),
107 @r###"[ 107 @r###"
108 CompletionItem { 108 [
109 label: "box", 109 CompletionItem {
110 source_range: [89; 89), 110 label: "box",
111 delete: [85; 89), 111 source_range: [89; 89),
112 insert: "Box::new(bar)", 112 delete: [85; 89),
113 detail: "Box::new(expr)", 113 insert: "Box::new(bar)",
114 }, 114 detail: "Box::new(expr)",
115 CompletionItem { 115 },
116 label: "dbg", 116 CompletionItem {
117 source_range: [89; 89), 117 label: "dbg",
118 delete: [85; 89), 118 source_range: [89; 89),
119 insert: "dbg!(bar)", 119 delete: [85; 89),
120 detail: "dbg!(expr)", 120 insert: "dbg!(bar)",
121 }, 121 detail: "dbg!(expr)",
122 CompletionItem { 122 },
123 label: "if", 123 CompletionItem {
124 source_range: [89; 89), 124 label: "if",
125 delete: [85; 89), 125 source_range: [89; 89),
126 insert: "if bar {$0}", 126 delete: [85; 89),
127 detail: "if expr {}", 127 insert: "if bar {$0}",
128 }, 128 detail: "if expr {}",
129 CompletionItem { 129 },
130 label: "match", 130 CompletionItem {
131 source_range: [89; 89), 131 label: "match",
132 delete: [85; 89), 132 source_range: [89; 89),
133 insert: "match bar {\n ${1:_} => {$0\\},\n}", 133 delete: [85; 89),
134 detail: "match expr {}", 134 insert: "match bar {\n ${1:_} => {$0\\},\n}",
135 }, 135 detail: "match expr {}",
136 CompletionItem { 136 },
137 label: "not", 137 CompletionItem {
138 source_range: [89; 89), 138 label: "not",
139 delete: [85; 89), 139 source_range: [89; 89),
140 insert: "!bar", 140 delete: [85; 89),
141 detail: "!expr", 141 insert: "!bar",
142 }, 142 detail: "!expr",
143 CompletionItem { 143 },
144 label: "ref", 144 CompletionItem {
145 source_range: [89; 89), 145 label: "ref",
146 delete: [85; 89), 146 source_range: [89; 89),
147 insert: "&bar", 147 delete: [85; 89),
148 detail: "&expr", 148 insert: "&bar",
149 }, 149 detail: "&expr",
150 CompletionItem { 150 },
151 label: "refm", 151 CompletionItem {
152 source_range: [89; 89), 152 label: "refm",
153 delete: [85; 89), 153 source_range: [89; 89),
154 insert: "&mut bar", 154 delete: [85; 89),
155 detail: "&mut expr", 155 insert: "&mut bar",
156 }, 156 detail: "&mut expr",
157 CompletionItem { 157 },
158 label: "while", 158 CompletionItem {
159 source_range: [89; 89), 159 label: "while",
160 delete: [85; 89), 160 source_range: [89; 89),
161 insert: "while bar {\n$0\n}", 161 delete: [85; 89),
162 detail: "while expr {}", 162 insert: "while bar {\n$0\n}",
163 }, 163 detail: "while expr {}",
164]"### 164 },
165 ]
166 "###
165 ); 167 );
166 } 168 }
167 169
@@ -176,50 +178,52 @@ mod tests {
176 } 178 }
177 "#, 179 "#,
178 ), 180 ),
179 @r###"[ 181 @r###"
180 CompletionItem { 182 [
181 label: "box", 183 CompletionItem {
182 source_range: [91; 91), 184 label: "box",
183 delete: [87; 91), 185 source_range: [91; 91),
184 insert: "Box::new(bar)", 186 delete: [87; 91),
185 detail: "Box::new(expr)", 187 insert: "Box::new(bar)",
186 }, 188 detail: "Box::new(expr)",
187 CompletionItem { 189 },
188 label: "dbg", 190 CompletionItem {
189 source_range: [91; 91), 191 label: "dbg",
190 delete: [87; 91), 192 source_range: [91; 91),
191 insert: "dbg!(bar)", 193 delete: [87; 91),
192 detail: "dbg!(expr)", 194 insert: "dbg!(bar)",
193 }, 195 detail: "dbg!(expr)",
194 CompletionItem { 196 },
195 label: "match", 197 CompletionItem {
196 source_range: [91; 91), 198 label: "match",
197 delete: [87; 91), 199 source_range: [91; 91),
198 insert: "match bar {\n ${1:_} => {$0\\},\n}", 200 delete: [87; 91),
199 detail: "match expr {}", 201 insert: "match bar {\n ${1:_} => {$0\\},\n}",
200 }, 202 detail: "match expr {}",
201 CompletionItem { 203 },
202 label: "not", 204 CompletionItem {
203 source_range: [91; 91), 205 label: "not",
204 delete: [87; 91), 206 source_range: [91; 91),
205 insert: "!bar", 207 delete: [87; 91),
206 detail: "!expr", 208 insert: "!bar",
207 }, 209 detail: "!expr",
208 CompletionItem { 210 },
209 label: "ref", 211 CompletionItem {
210 source_range: [91; 91), 212 label: "ref",
211 delete: [87; 91), 213 source_range: [91; 91),
212 insert: "&bar", 214 delete: [87; 91),
213 detail: "&expr", 215 insert: "&bar",
214 }, 216 detail: "&expr",
215 CompletionItem { 217 },
216 label: "refm", 218 CompletionItem {
217 source_range: [91; 91), 219 label: "refm",
218 delete: [87; 91), 220 source_range: [91; 91),
219 insert: "&mut bar", 221 delete: [87; 91),
220 detail: "&mut expr", 222 insert: "&mut bar",
221 }, 223 detail: "&mut expr",
222]"### 224 },
225 ]
226 "###
223 ); 227 );
224 } 228 }
225 229
@@ -233,50 +237,52 @@ mod tests {
233 } 237 }
234 "#, 238 "#,
235 ), 239 ),
236 @r###"[ 240 @r###"
237 CompletionItem { 241 [
238 label: "box", 242 CompletionItem {
239 source_range: [52; 52), 243 label: "box",
240 delete: [49; 52), 244 source_range: [52; 52),
241 insert: "Box::new(42)", 245 delete: [49; 52),
242 detail: "Box::new(expr)", 246 insert: "Box::new(42)",
243 }, 247 detail: "Box::new(expr)",
244 CompletionItem { 248 },
245 label: "dbg", 249 CompletionItem {
246 source_range: [52; 52), 250 label: "dbg",
247 delete: [49; 52), 251 source_range: [52; 52),
248 insert: "dbg!(42)", 252 delete: [49; 52),
249 detail: "dbg!(expr)", 253 insert: "dbg!(42)",
250 }, 254 detail: "dbg!(expr)",
251 CompletionItem { 255 },
252 label: "match", 256 CompletionItem {
253 source_range: [52; 52), 257 label: "match",
254 delete: [49; 52), 258 source_range: [52; 52),
255 insert: "match 42 {\n ${1:_} => {$0\\},\n}", 259 delete: [49; 52),
256 detail: "match expr {}", 260 insert: "match 42 {\n ${1:_} => {$0\\},\n}",
257 }, 261 detail: "match expr {}",
258 CompletionItem { 262 },
259 label: "not", 263 CompletionItem {
260 source_range: [52; 52), 264 label: "not",
261 delete: [49; 52), 265 source_range: [52; 52),
262 insert: "!42", 266 delete: [49; 52),
263 detail: "!expr", 267 insert: "!42",
264 }, 268 detail: "!expr",
265 CompletionItem { 269 },
266 label: "ref", 270 CompletionItem {
267 source_range: [52; 52), 271 label: "ref",
268 delete: [49; 52), 272 source_range: [52; 52),
269 insert: "&42", 273 delete: [49; 52),
270 detail: "&expr", 274 insert: "&42",
271 }, 275 detail: "&expr",
272 CompletionItem { 276 },
273 label: "refm", 277 CompletionItem {
274 source_range: [52; 52), 278 label: "refm",
275 delete: [49; 52), 279 source_range: [52; 52),
276 insert: "&mut 42", 280 delete: [49; 52),
277 detail: "&mut expr", 281 insert: "&mut 42",
278 }, 282 detail: "&mut expr",
279]"### 283 },
284 ]
285 "###
280 ); 286 );
281 } 287 }
282} 288}
diff --git a/crates/ra_ide_api/src/completion/complete_record_literal.rs b/crates/ra_ide_api/src/completion/complete_record_literal.rs
index 0295b8101..45a4a9738 100644
--- a/crates/ra_ide_api/src/completion/complete_record_literal.rs
+++ b/crates/ra_ide_api/src/completion/complete_record_literal.rs
@@ -45,17 +45,17 @@ mod tests {
45 ", 45 ",
46 ); 46 );
47 assert_debug_snapshot!(completions, @r###" 47 assert_debug_snapshot!(completions, @r###"
48 [ 48 [
49 CompletionItem { 49 CompletionItem {
50 label: "the_field", 50 label: "the_field",
51 source_range: [142; 145), 51 source_range: [142; 145),
52 delete: [142; 145), 52 delete: [142; 145),
53 insert: "the_field", 53 insert: "the_field",
54 kind: Field, 54 kind: Field,
55 detail: "u32", 55 detail: "u32",
56 deprecated: true, 56 deprecated: true,
57 }, 57 },
58 ] 58 ]
59 "###); 59 "###);
60 } 60 }
61 61
@@ -70,16 +70,16 @@ mod tests {
70 ", 70 ",
71 ); 71 );
72 assert_debug_snapshot!(completions, @r###" 72 assert_debug_snapshot!(completions, @r###"
73 [ 73 [
74 CompletionItem { 74 CompletionItem {
75 label: "the_field", 75 label: "the_field",
76 source_range: [83; 86), 76 source_range: [83; 86),
77 delete: [83; 86), 77 delete: [83; 86),
78 insert: "the_field", 78 insert: "the_field",
79 kind: Field, 79 kind: Field,
80 detail: "u32", 80 detail: "u32",
81 }, 81 },
82 ] 82 ]
83 "###); 83 "###);
84 } 84 }
85 85
@@ -96,16 +96,16 @@ mod tests {
96 ", 96 ",
97 ); 97 );
98 assert_debug_snapshot!(completions, @r###" 98 assert_debug_snapshot!(completions, @r###"
99 [ 99 [
100 CompletionItem { 100 CompletionItem {
101 label: "a", 101 label: "a",
102 source_range: [119; 119), 102 source_range: [119; 119),
103 delete: [119; 119), 103 delete: [119; 119),
104 insert: "a", 104 insert: "a",
105 kind: Field, 105 kind: Field,
106 detail: "u32", 106 detail: "u32",
107 }, 107 },
108 ] 108 ]
109 "###); 109 "###);
110 } 110 }
111 111
@@ -122,16 +122,16 @@ mod tests {
122 ", 122 ",
123 ); 123 );
124 assert_debug_snapshot!(completions, @r###" 124 assert_debug_snapshot!(completions, @r###"
125 [ 125 [
126 CompletionItem { 126 CompletionItem {
127 label: "b", 127 label: "b",
128 source_range: [119; 119), 128 source_range: [119; 119),
129 delete: [119; 119), 129 delete: [119; 119),
130 insert: "b", 130 insert: "b",
131 kind: Field, 131 kind: Field,
132 detail: "u32", 132 detail: "u32",
133 }, 133 },
134 ] 134 ]
135 "###); 135 "###);
136 } 136 }
137 137
@@ -147,16 +147,16 @@ mod tests {
147 ", 147 ",
148 ); 148 );
149 assert_debug_snapshot!(completions, @r###" 149 assert_debug_snapshot!(completions, @r###"
150 [ 150 [
151 CompletionItem { 151 CompletionItem {
152 label: "a", 152 label: "a",
153 source_range: [93; 93), 153 source_range: [93; 93),
154 delete: [93; 93), 154 delete: [93; 93),
155 insert: "a", 155 insert: "a",
156 kind: Field, 156 kind: Field,
157 detail: "u32", 157 detail: "u32",
158 }, 158 },
159 ] 159 ]
160 "###); 160 "###);
161 } 161 }
162} 162}
diff --git a/crates/ra_ide_api/src/completion/complete_record_pattern.rs b/crates/ra_ide_api/src/completion/complete_record_pattern.rs
index d20fa796c..aa0fd6d24 100644
--- a/crates/ra_ide_api/src/completion/complete_record_pattern.rs
+++ b/crates/ra_ide_api/src/completion/complete_record_pattern.rs
@@ -44,16 +44,16 @@ mod tests {
44 ", 44 ",
45 ); 45 );
46 assert_debug_snapshot!(completions, @r###" 46 assert_debug_snapshot!(completions, @r###"
47 [ 47 [
48 CompletionItem { 48 CompletionItem {
49 label: "foo", 49 label: "foo",
50 source_range: [117; 118), 50 source_range: [117; 118),
51 delete: [117; 118), 51 delete: [117; 118),
52 insert: "foo", 52 insert: "foo",
53 kind: Field, 53 kind: Field,
54 detail: "u32", 54 detail: "u32",
55 }, 55 },
56 ] 56 ]
57 "###); 57 "###);
58 } 58 }
59 59
@@ -73,24 +73,24 @@ mod tests {
73 ", 73 ",
74 ); 74 );
75 assert_debug_snapshot!(completions, @r###" 75 assert_debug_snapshot!(completions, @r###"
76 [ 76 [
77 CompletionItem { 77 CompletionItem {
78 label: "bar", 78 label: "bar",
79 source_range: [161; 161), 79 source_range: [161; 161),
80 delete: [161; 161), 80 delete: [161; 161),
81 insert: "bar", 81 insert: "bar",
82 kind: Field, 82 kind: Field,
83 detail: "()", 83 detail: "()",
84 }, 84 },
85 CompletionItem { 85 CompletionItem {
86 label: "foo", 86 label: "foo",
87 source_range: [161; 161), 87 source_range: [161; 161),
88 delete: [161; 161), 88 delete: [161; 161),
89 insert: "foo", 89 insert: "foo",
90 kind: Field, 90 kind: Field,
91 detail: "u32", 91 detail: "u32",
92 }, 92 },
93 ] 93 ]
94 "###); 94 "###);
95 } 95 }
96} 96}
diff --git a/crates/ra_ide_api/src/completion/complete_scope.rs b/crates/ra_ide_api/src/completion/complete_scope.rs
index 3e205efd1..8c57c907d 100644
--- a/crates/ra_ide_api/src/completion/complete_scope.rs
+++ b/crates/ra_ide_api/src/completion/complete_scope.rs
@@ -409,15 +409,17 @@ mod tests {
409 // nothing here 409 // nothing here
410 " 410 "
411 ), 411 ),
412 @r#"[ 412 @r###"
413 CompletionItem { 413 [
414 label: "other_crate", 414 CompletionItem {
415 source_range: [4; 4), 415 label: "other_crate",
416 delete: [4; 4), 416 source_range: [4; 4),
417 insert: "other_crate", 417 delete: [4; 4),
418 kind: Module, 418 insert: "other_crate",
419 }, 419 kind: Module,
420]"# 420 },
421 ]
422 "###
421 ); 423 );
422 } 424 }
423 425
@@ -530,23 +532,25 @@ mod tests {
530 fn completes_self_in_methods() { 532 fn completes_self_in_methods() {
531 assert_debug_snapshot!( 533 assert_debug_snapshot!(
532 do_reference_completion(r"impl S { fn foo(&self) { <|> } }"), 534 do_reference_completion(r"impl S { fn foo(&self) { <|> } }"),
533 @r#"[ 535 @r###"
534 CompletionItem { 536 [
535 label: "Self", 537 CompletionItem {
536 source_range: [25; 25), 538 label: "Self",
537 delete: [25; 25), 539 source_range: [25; 25),
538 insert: "Self", 540 delete: [25; 25),
539 kind: TypeParam, 541 insert: "Self",
540 }, 542 kind: TypeParam,
541 CompletionItem { 543 },
542 label: "self", 544 CompletionItem {
543 source_range: [25; 25), 545 label: "self",
544 delete: [25; 25), 546 source_range: [25; 25),
545 insert: "self", 547 delete: [25; 25),
546 kind: Binding, 548 insert: "self",
547 detail: "&{unknown}", 549 kind: Binding,
548 }, 550 detail: "&{unknown}",
549]"# 551 },
552 ]
553 "###
550 ); 554 );
551 } 555 }
552 556
diff --git a/crates/ra_ide_api/src/completion/complete_snippet.rs b/crates/ra_ide_api/src/completion/complete_snippet.rs
index 2df79b6c3..1f2988b36 100644
--- a/crates/ra_ide_api/src/completion/complete_snippet.rs
+++ b/crates/ra_ide_api/src/completion/complete_snippet.rs
@@ -52,22 +52,24 @@ mod tests {
52 fn completes_snippets_in_expressions() { 52 fn completes_snippets_in_expressions() {
53 assert_debug_snapshot!( 53 assert_debug_snapshot!(
54 do_snippet_completion(r"fn foo(x: i32) { <|> }"), 54 do_snippet_completion(r"fn foo(x: i32) { <|> }"),
55 @r#"[ 55 @r###"
56 CompletionItem { 56 [
57 label: "pd", 57 CompletionItem {
58 source_range: [17; 17), 58 label: "pd",
59 delete: [17; 17), 59 source_range: [17; 17),
60 insert: "eprintln!(\"$0 = {:?}\", $0);", 60 delete: [17; 17),
61 kind: Snippet, 61 insert: "eprintln!(\"$0 = {:?}\", $0);",
62 }, 62 kind: Snippet,
63 CompletionItem { 63 },
64 label: "ppd", 64 CompletionItem {
65 source_range: [17; 17), 65 label: "ppd",
66 delete: [17; 17), 66 source_range: [17; 17),
67 insert: "eprintln!(\"$0 = {:#?}\", $0);", 67 delete: [17; 17),
68 kind: Snippet, 68 insert: "eprintln!(\"$0 = {:#?}\", $0);",
69 }, 69 kind: Snippet,
70]"# 70 },
71 ]
72 "###
71 ); 73 );
72 } 74 }
73 75
@@ -75,11 +77,11 @@ mod tests {
75 fn should_not_complete_snippets_in_path() { 77 fn should_not_complete_snippets_in_path() {
76 assert_debug_snapshot!( 78 assert_debug_snapshot!(
77 do_snippet_completion(r"fn foo(x: i32) { ::foo<|> }"), 79 do_snippet_completion(r"fn foo(x: i32) { ::foo<|> }"),
78 @r#"[]"# 80 @"[]"
79 ); 81 );
80 assert_debug_snapshot!( 82 assert_debug_snapshot!(
81 do_snippet_completion(r"fn foo(x: i32) { ::<|> }"), 83 do_snippet_completion(r"fn foo(x: i32) { ::<|> }"),
82 @r#"[]"# 84 @"[]"
83 ); 85 );
84 } 86 }
85 87
@@ -94,23 +96,25 @@ mod tests {
94 } 96 }
95 " 97 "
96 ), 98 ),
97 @r###"[ 99 @r###"
98 CompletionItem { 100 [
99 label: "Test function", 101 CompletionItem {
100 source_range: [78; 78), 102 label: "Test function",
101 delete: [78; 78), 103 source_range: [78; 78),
102 insert: "#[test]\nfn ${1:feature}() {\n $0\n}", 104 delete: [78; 78),
103 kind: Snippet, 105 insert: "#[test]\nfn ${1:feature}() {\n $0\n}",
104 lookup: "tfn", 106 kind: Snippet,
105 }, 107 lookup: "tfn",
106 CompletionItem { 108 },
107 label: "pub(crate)", 109 CompletionItem {
108 source_range: [78; 78), 110 label: "pub(crate)",
109 delete: [78; 78), 111 source_range: [78; 78),
110 insert: "pub(crate) $0", 112 delete: [78; 78),
111 kind: Snippet, 113 insert: "pub(crate) $0",
112 }, 114 kind: Snippet,
113]"### 115 },
116 ]
117 "###
114 ); 118 );
115 } 119 }
116} 120}
diff --git a/crates/ra_ide_api/src/completion/presentation.rs b/crates/ra_ide_api/src/completion/presentation.rs
index c343cece6..501b7da4e 100644
--- a/crates/ra_ide_api/src/completion/presentation.rs
+++ b/crates/ra_ide_api/src/completion/presentation.rs
@@ -323,38 +323,38 @@ mod tests {
323 "#, 323 "#,
324 ), 324 ),
325 @r###" 325 @r###"
326 [ 326 [
327 CompletionItem { 327 CompletionItem {
328 label: "main()", 328 label: "main()",
329 source_range: [203; 206), 329 source_range: [203; 206),
330 delete: [203; 206), 330 delete: [203; 206),
331 insert: "main()$0", 331 insert: "main()$0",
332 kind: Function, 332 kind: Function,
333 lookup: "main", 333 lookup: "main",
334 detail: "fn main()", 334 detail: "fn main()",
335 }, 335 },
336 CompletionItem { 336 CompletionItem {
337 label: "something_deprecated()", 337 label: "something_deprecated()",
338 source_range: [203; 206), 338 source_range: [203; 206),
339 delete: [203; 206), 339 delete: [203; 206),
340 insert: "something_deprecated()$0", 340 insert: "something_deprecated()$0",
341 kind: Function, 341 kind: Function,
342 lookup: "something_deprecated", 342 lookup: "something_deprecated",
343 detail: "fn something_deprecated()", 343 detail: "fn something_deprecated()",
344 deprecated: true, 344 deprecated: true,
345 }, 345 },
346 CompletionItem { 346 CompletionItem {
347 label: "something_else_deprecated()", 347 label: "something_else_deprecated()",
348 source_range: [203; 206), 348 source_range: [203; 206),
349 delete: [203; 206), 349 delete: [203; 206),
350 insert: "something_else_deprecated()$0", 350 insert: "something_else_deprecated()$0",
351 kind: Function, 351 kind: Function,
352 lookup: "something_else_deprecated", 352 lookup: "something_else_deprecated",
353 detail: "fn something_else_deprecated()", 353 detail: "fn something_else_deprecated()",
354 deprecated: true, 354 deprecated: true,
355 }, 355 },
356 ] 356 ]
357 "### 357 "###
358 ); 358 );
359 } 359 }
360 360
@@ -459,16 +459,18 @@ mod tests {
459 use crate::m::f<|>; 459 use crate::m::f<|>;
460 " 460 "
461 ), 461 ),
462 @r#"[ 462 @r###"
463 CompletionItem { 463 [
464 label: "foo", 464 CompletionItem {
465 source_range: [40; 41), 465 label: "foo",
466 delete: [40; 41), 466 source_range: [40; 41),
467 insert: "foo", 467 delete: [40; 41),
468 kind: Function, 468 insert: "foo",
469 detail: "pub fn foo()", 469 kind: Function,
470 }, 470 detail: "pub fn foo()",
471]"# 471 },
472 ]
473 "###
472 ); 474 );
473 } 475 }
474 476
@@ -484,24 +486,26 @@ mod tests {
484 } 486 }
485 " 487 "
486 ), 488 ),
487 @r#"[ 489 @r###"
488 CompletionItem { 490 [
489 label: "frobnicate", 491 CompletionItem {
490 source_range: [35; 39), 492 label: "frobnicate",
491 delete: [35; 39), 493 source_range: [35; 39),
492 insert: "frobnicate", 494 delete: [35; 39),
493 kind: Function, 495 insert: "frobnicate",
494 detail: "fn frobnicate()", 496 kind: Function,
495 }, 497 detail: "fn frobnicate()",
496 CompletionItem { 498 },
497 label: "main", 499 CompletionItem {
498 source_range: [35; 39), 500 label: "main",
499 delete: [35; 39), 501 source_range: [35; 39),
500 insert: "main", 502 delete: [35; 39),
501 kind: Function, 503 insert: "main",
502 detail: "fn main()", 504 kind: Function,
503 }, 505 detail: "fn main()",
504]"# 506 },
507 ]
508 "###
505 ); 509 );
506 assert_debug_snapshot!( 510 assert_debug_snapshot!(
507 do_reference_completion( 511 do_reference_completion(
@@ -514,16 +518,18 @@ mod tests {
514 } 518 }
515 " 519 "
516 ), 520 ),
517 @r#"[ 521 @r###"
518 CompletionItem { 522 [
519 label: "new", 523 CompletionItem {
520 source_range: [67; 69), 524 label: "new",
521 delete: [67; 69), 525 source_range: [67; 69),
522 insert: "new", 526 delete: [67; 69),
523 kind: Function, 527 insert: "new",
524 detail: "fn new() -> Foo", 528 kind: Function,
525 }, 529 detail: "fn new() -> Foo",
526]"# 530 },
531 ]
532 "###
527 ); 533 );
528 } 534 }
529 535
diff --git a/crates/ra_ide_api/src/diagnostics.rs b/crates/ra_ide_api/src/diagnostics.rs
index 2890a3d2b..e52ffefb3 100644
--- a/crates/ra_ide_api/src/diagnostics.rs
+++ b/crates/ra_ide_api/src/diagnostics.rs
@@ -526,28 +526,28 @@ mod tests {
526 let (analysis, file_id) = single_file("mod foo;"); 526 let (analysis, file_id) = single_file("mod foo;");
527 let diagnostics = analysis.diagnostics(file_id).unwrap(); 527 let diagnostics = analysis.diagnostics(file_id).unwrap();
528 assert_debug_snapshot!(diagnostics, @r###" 528 assert_debug_snapshot!(diagnostics, @r###"
529 [ 529 [
530 Diagnostic { 530 Diagnostic {
531 message: "unresolved module", 531 message: "unresolved module",
532 range: [0; 8), 532 range: [0; 8),
533 fix: Some( 533 fix: Some(
534 SourceChange { 534 SourceChange {
535 label: "create module", 535 label: "create module",
536 source_file_edits: [], 536 source_file_edits: [],
537 file_system_edits: [ 537 file_system_edits: [
538 CreateFile { 538 CreateFile {
539 source_root: SourceRootId( 539 source_root: SourceRootId(
540 0, 540 0,
541 ), 541 ),
542 path: "foo.rs", 542 path: "foo.rs",
543 }, 543 },
544 ], 544 ],
545 cursor_position: None, 545 cursor_position: None,
546 }, 546 },
547 ), 547 ),
548 severity: Error, 548 severity: Error,
549 }, 549 },
550 ] 550 ]
551 "###); 551 "###);
552 } 552 }
553 553
diff --git a/crates/ra_ide_api/src/display/structure.rs b/crates/ra_ide_api/src/display/structure.rs
index ddd8b7b20..a80d65ac7 100644
--- a/crates/ra_ide_api/src/display/structure.rs
+++ b/crates/ra_ide_api/src/display/structure.rs
@@ -209,191 +209,193 @@ fn very_obsolete() {}
209 .unwrap(); 209 .unwrap();
210 let structure = file_structure(&file); 210 let structure = file_structure(&file);
211 assert_debug_snapshot!(structure, 211 assert_debug_snapshot!(structure,
212 @r#"[ 212 @r###"
213 StructureNode { 213 [
214 parent: None, 214 StructureNode {
215 label: "Foo", 215 parent: None,
216 navigation_range: [8; 11), 216 label: "Foo",
217 node_range: [1; 26), 217 navigation_range: [8; 11),
218 kind: STRUCT_DEF, 218 node_range: [1; 26),
219 detail: None, 219 kind: STRUCT_DEF,
220 deprecated: false, 220 detail: None,
221 }, 221 deprecated: false,
222 StructureNode { 222 },
223 parent: Some( 223 StructureNode {
224 0, 224 parent: Some(
225 ), 225 0,
226 label: "x", 226 ),
227 navigation_range: [18; 19), 227 label: "x",
228 node_range: [18; 24), 228 navigation_range: [18; 19),
229 kind: RECORD_FIELD_DEF, 229 node_range: [18; 24),
230 detail: Some( 230 kind: RECORD_FIELD_DEF,
231 "i32", 231 detail: Some(
232 ), 232 "i32",
233 deprecated: false, 233 ),
234 }, 234 deprecated: false,
235 StructureNode { 235 },
236 parent: None, 236 StructureNode {
237 label: "m", 237 parent: None,
238 navigation_range: [32; 33), 238 label: "m",
239 node_range: [28; 158), 239 navigation_range: [32; 33),
240 kind: MODULE, 240 node_range: [28; 158),
241 detail: None, 241 kind: MODULE,
242 deprecated: false, 242 detail: None,
243 }, 243 deprecated: false,
244 StructureNode { 244 },
245 parent: Some( 245 StructureNode {
246 2, 246 parent: Some(
247 ), 247 2,
248 label: "bar1", 248 ),
249 navigation_range: [43; 47), 249 label: "bar1",
250 node_range: [40; 52), 250 navigation_range: [43; 47),
251 kind: FN_DEF, 251 node_range: [40; 52),
252 detail: Some( 252 kind: FN_DEF,
253 "fn()", 253 detail: Some(
254 ), 254 "fn()",
255 deprecated: false, 255 ),
256 }, 256 deprecated: false,
257 StructureNode { 257 },
258 parent: Some( 258 StructureNode {
259 2, 259 parent: Some(
260 ), 260 2,
261 label: "bar2", 261 ),
262 navigation_range: [60; 64), 262 label: "bar2",
263 node_range: [57; 81), 263 navigation_range: [60; 64),
264 kind: FN_DEF, 264 node_range: [57; 81),
265 detail: Some( 265 kind: FN_DEF,
266 "fn<T>(t: T) -> T", 266 detail: Some(
267 ), 267 "fn<T>(t: T) -> T",
268 deprecated: false, 268 ),
269 }, 269 deprecated: false,
270 StructureNode { 270 },
271 parent: Some( 271 StructureNode {
272 2, 272 parent: Some(
273 ), 273 2,
274 label: "bar3", 274 ),
275 navigation_range: [89; 93), 275 label: "bar3",
276 node_range: [86; 156), 276 navigation_range: [89; 93),
277 kind: FN_DEF, 277 node_range: [86; 156),
278 detail: Some( 278 kind: FN_DEF,
279 "fn<A, B>(a: A, b: B) -> Vec< u32 >", 279 detail: Some(
280 ), 280 "fn<A, B>(a: A, b: B) -> Vec< u32 >",
281 deprecated: false, 281 ),
282 }, 282 deprecated: false,
283 StructureNode { 283 },
284 parent: None, 284 StructureNode {
285 label: "E", 285 parent: None,
286 navigation_range: [165; 166), 286 label: "E",
287 node_range: [160; 180), 287 navigation_range: [165; 166),
288 kind: ENUM_DEF, 288 node_range: [160; 180),
289 detail: None, 289 kind: ENUM_DEF,
290 deprecated: false, 290 detail: None,
291 }, 291 deprecated: false,
292 StructureNode { 292 },
293 parent: Some( 293 StructureNode {
294 6, 294 parent: Some(
295 ), 295 6,
296 label: "X", 296 ),
297 navigation_range: [169; 170), 297 label: "X",
298 node_range: [169; 170), 298 navigation_range: [169; 170),
299 kind: ENUM_VARIANT, 299 node_range: [169; 170),
300 detail: None, 300 kind: ENUM_VARIANT,
301 deprecated: false, 301 detail: None,
302 }, 302 deprecated: false,
303 StructureNode { 303 },
304 parent: Some( 304 StructureNode {
305 6, 305 parent: Some(
306 ), 306 6,
307 label: "Y", 307 ),
308 navigation_range: [172; 173), 308 label: "Y",
309 node_range: [172; 178), 309 navigation_range: [172; 173),
310 kind: ENUM_VARIANT, 310 node_range: [172; 178),
311 detail: None, 311 kind: ENUM_VARIANT,
312 deprecated: false, 312 detail: None,
313 }, 313 deprecated: false,
314 StructureNode { 314 },
315 parent: None, 315 StructureNode {
316 label: "T", 316 parent: None,
317 navigation_range: [186; 187), 317 label: "T",
318 node_range: [181; 193), 318 navigation_range: [186; 187),
319 kind: TYPE_ALIAS_DEF, 319 node_range: [181; 193),
320 detail: Some( 320 kind: TYPE_ALIAS_DEF,
321 "()", 321 detail: Some(
322 ), 322 "()",
323 deprecated: false, 323 ),
324 }, 324 deprecated: false,
325 StructureNode { 325 },
326 parent: None, 326 StructureNode {
327 label: "S", 327 parent: None,
328 navigation_range: [201; 202), 328 label: "S",
329 node_range: [194; 213), 329 navigation_range: [201; 202),
330 kind: STATIC_DEF, 330 node_range: [194; 213),
331 detail: Some( 331 kind: STATIC_DEF,
332 "i32", 332 detail: Some(
333 ), 333 "i32",
334 deprecated: false, 334 ),
335 }, 335 deprecated: false,
336 StructureNode { 336 },
337 parent: None, 337 StructureNode {
338 label: "C", 338 parent: None,
339 navigation_range: [220; 221), 339 label: "C",
340 node_range: [214; 232), 340 navigation_range: [220; 221),
341 kind: CONST_DEF, 341 node_range: [214; 232),
342 detail: Some( 342 kind: CONST_DEF,
343 "i32", 343 detail: Some(
344 ), 344 "i32",
345 deprecated: false, 345 ),
346 }, 346 deprecated: false,
347 StructureNode { 347 },
348 parent: None, 348 StructureNode {
349 label: "impl E", 349 parent: None,
350 navigation_range: [239; 240), 350 label: "impl E",
351 node_range: [234; 243), 351 navigation_range: [239; 240),
352 kind: IMPL_BLOCK, 352 node_range: [234; 243),
353 detail: None, 353 kind: IMPL_BLOCK,
354 deprecated: false, 354 detail: None,
355 }, 355 deprecated: false,
356 StructureNode { 356 },
357 parent: None, 357 StructureNode {
358 label: "impl fmt::Debug for E", 358 parent: None,
359 navigation_range: [265; 266), 359 label: "impl fmt::Debug for E",
360 node_range: [245; 269), 360 navigation_range: [265; 266),
361 kind: IMPL_BLOCK, 361 node_range: [245; 269),
362 detail: None, 362 kind: IMPL_BLOCK,
363 deprecated: false, 363 detail: None,
364 }, 364 deprecated: false,
365 StructureNode { 365 },
366 parent: None, 366 StructureNode {
367 label: "mc", 367 parent: None,
368 navigation_range: [284; 286), 368 label: "mc",
369 node_range: [271; 303), 369 navigation_range: [284; 286),
370 kind: MACRO_CALL, 370 node_range: [271; 303),
371 detail: None, 371 kind: MACRO_CALL,
372 deprecated: false, 372 detail: None,
373 }, 373 deprecated: false,
374 StructureNode { 374 },
375 parent: None, 375 StructureNode {
376 label: "obsolete", 376 parent: None,
377 navigation_range: [322; 330), 377 label: "obsolete",
378 node_range: [305; 335), 378 navigation_range: [322; 330),
379 kind: FN_DEF, 379 node_range: [305; 335),
380 detail: Some( 380 kind: FN_DEF,
381 "fn()", 381 detail: Some(
382 ), 382 "fn()",
383 deprecated: true, 383 ),
384 }, 384 deprecated: true,
385 StructureNode { 385 },
386 parent: None, 386 StructureNode {
387 label: "very_obsolete", 387 parent: None,
388 navigation_range: [375; 388), 388 label: "very_obsolete",
389 node_range: [337; 393), 389 navigation_range: [375; 388),
390 kind: FN_DEF, 390 node_range: [337; 393),
391 detail: Some( 391 kind: FN_DEF,
392 "fn()", 392 detail: Some(
393 ), 393 "fn()",
394 deprecated: true, 394 ),
395 }, 395 deprecated: true,
396]"# 396 },
397 ]
398 "###
397 ); 399 );
398 } 400 }
399} 401}
diff --git a/crates/ra_ide_api/src/inlay_hints.rs b/crates/ra_ide_api/src/inlay_hints.rs
index f1c0dc164..2ff10b89a 100644
--- a/crates/ra_ide_api/src/inlay_hints.rs
+++ b/crates/ra_ide_api/src/inlay_hints.rs
@@ -214,58 +214,60 @@ fn main() {
214}"#, 214}"#,
215 ); 215 );
216 216
217 assert_debug_snapshot!(analysis.inlay_hints(file_id).unwrap(), @r#"[ 217 assert_debug_snapshot!(analysis.inlay_hints(file_id).unwrap(), @r###"
218 InlayHint { 218 [
219 range: [193; 197), 219 InlayHint {
220 kind: TypeHint, 220 range: [193; 197),
221 label: "i32", 221 kind: TypeHint,
222 }, 222 label: "i32",
223 InlayHint { 223 },
224 range: [236; 244), 224 InlayHint {
225 kind: TypeHint, 225 range: [236; 244),
226 label: "i32", 226 kind: TypeHint,
227 }, 227 label: "i32",
228 InlayHint { 228 },
229 range: [275; 279), 229 InlayHint {
230 kind: TypeHint, 230 range: [275; 279),
231 label: "&str", 231 kind: TypeHint,
232 }, 232 label: "&str",
233 InlayHint { 233 },
234 range: [539; 543), 234 InlayHint {
235 kind: TypeHint, 235 range: [539; 543),
236 label: "(i32, char)", 236 kind: TypeHint,
237 }, 237 label: "(i32, char)",
238 InlayHint { 238 },
239 range: [566; 567), 239 InlayHint {
240 kind: TypeHint, 240 range: [566; 567),
241 label: "i32", 241 kind: TypeHint,
242 }, 242 label: "i32",
243 InlayHint { 243 },
244 range: [570; 571), 244 InlayHint {
245 kind: TypeHint, 245 range: [570; 571),
246 label: "i32", 246 kind: TypeHint,
247 }, 247 label: "i32",
248 InlayHint { 248 },
249 range: [573; 574), 249 InlayHint {
250 kind: TypeHint, 250 range: [573; 574),
251 label: "i32", 251 kind: TypeHint,
252 }, 252 label: "i32",
253 InlayHint { 253 },
254 range: [584; 585), 254 InlayHint {
255 kind: TypeHint, 255 range: [584; 585),
256 label: "i32", 256 kind: TypeHint,
257 }, 257 label: "i32",
258 InlayHint { 258 },
259 range: [577; 578), 259 InlayHint {
260 kind: TypeHint, 260 range: [577; 578),
261 label: "f64", 261 kind: TypeHint,
262 }, 262 label: "f64",
263 InlayHint { 263 },
264 range: [580; 581), 264 InlayHint {
265 kind: TypeHint, 265 range: [580; 581),
266 label: "f64", 266 kind: TypeHint,
267 }, 267 label: "f64",
268]"# 268 },
269 ]
270 "###
269 ); 271 );
270 } 272 }
271 273
@@ -281,18 +283,20 @@ fn main() {
281}"#, 283}"#,
282 ); 284 );
283 285
284 assert_debug_snapshot!(analysis.inlay_hints(file_id).unwrap(), @r#"[ 286 assert_debug_snapshot!(analysis.inlay_hints(file_id).unwrap(), @r###"
285 InlayHint { 287 [
286 range: [21; 30), 288 InlayHint {
287 kind: TypeHint, 289 range: [21; 30),
288 label: "i32", 290 kind: TypeHint,
289 }, 291 label: "i32",
290 InlayHint { 292 },
291 range: [57; 66), 293 InlayHint {
292 kind: TypeHint, 294 range: [57; 66),
293 label: "i32", 295 kind: TypeHint,
294 }, 296 label: "i32",
295]"# 297 },
298 ]
299 "###
296 ); 300 );
297 } 301 }
298 302
@@ -308,18 +312,20 @@ fn main() {
308}"#, 312}"#,
309 ); 313 );
310 314
311 assert_debug_snapshot!(analysis.inlay_hints(file_id).unwrap(), @r#"[ 315 assert_debug_snapshot!(analysis.inlay_hints(file_id).unwrap(), @r###"
312 InlayHint { 316 [
313 range: [21; 30), 317 InlayHint {
314 kind: TypeHint, 318 range: [21; 30),
315 label: "i32", 319 kind: TypeHint,
316 }, 320 label: "i32",
317 InlayHint { 321 },
318 range: [44; 53), 322 InlayHint {
319 kind: TypeHint, 323 range: [44; 53),
320 label: "i32", 324 kind: TypeHint,
321 }, 325 label: "i32",
322]"# 326 },
327 ]
328 "###
323 ); 329 );
324 } 330 }
325 331
@@ -354,33 +360,35 @@ fn main() {
354}"#, 360}"#,
355 ); 361 );
356 362
357 assert_debug_snapshot!(analysis.inlay_hints(file_id).unwrap(), @r#"[ 363 assert_debug_snapshot!(analysis.inlay_hints(file_id).unwrap(), @r###"
358 InlayHint { 364 [
359 range: [166; 170), 365 InlayHint {
360 kind: TypeHint, 366 range: [166; 170),
361 label: "CustomOption<Test>", 367 kind: TypeHint,
362 }, 368 label: "CustomOption<Test>",
363 InlayHint { 369 },
364 range: [334; 338), 370 InlayHint {
365 kind: TypeHint, 371 range: [334; 338),
366 label: "&Test", 372 kind: TypeHint,
367 }, 373 label: "&Test",
368 InlayHint { 374 },
369 range: [389; 390), 375 InlayHint {
370 kind: TypeHint, 376 range: [389; 390),
371 label: "&CustomOption<u32>", 377 kind: TypeHint,
372 }, 378 label: "&CustomOption<u32>",
373 InlayHint { 379 },
374 range: [392; 393), 380 InlayHint {
375 kind: TypeHint, 381 range: [392; 393),
376 label: "&u8", 382 kind: TypeHint,
377 }, 383 label: "&u8",
378 InlayHint { 384 },
379 range: [531; 532), 385 InlayHint {
380 kind: TypeHint, 386 range: [531; 532),
381 label: "&u32", 387 kind: TypeHint,
382 }, 388 label: "&u32",
383]"# 389 },
390 ]
391 "###
384 ); 392 );
385 } 393 }
386 394
@@ -416,33 +424,33 @@ fn main() {
416 ); 424 );
417 425
418 assert_debug_snapshot!(analysis.inlay_hints(file_id).unwrap(), @r###" 426 assert_debug_snapshot!(analysis.inlay_hints(file_id).unwrap(), @r###"
419 [ 427 [
420 InlayHint { 428 InlayHint {
421 range: [166; 170), 429 range: [166; 170),
422 kind: TypeHint, 430 kind: TypeHint,
423 label: "CustomOption<Test>", 431 label: "CustomOption<Test>",
424 }, 432 },
425 InlayHint { 433 InlayHint {
426 range: [343; 347), 434 range: [343; 347),
427 kind: TypeHint, 435 kind: TypeHint,
428 label: "&Test", 436 label: "&Test",
429 }, 437 },
430 InlayHint { 438 InlayHint {
431 range: [401; 402), 439 range: [401; 402),
432 kind: TypeHint, 440 kind: TypeHint,
433 label: "&CustomOption<u32>", 441 label: "&CustomOption<u32>",
434 }, 442 },
435 InlayHint { 443 InlayHint {
436 range: [404; 405), 444 range: [404; 405),
437 kind: TypeHint, 445 kind: TypeHint,
438 label: "&u8", 446 label: "&u8",
439 }, 447 },
440 InlayHint { 448 InlayHint {
441 range: [549; 550), 449 range: [549; 550),
442 kind: TypeHint, 450 kind: TypeHint,
443 label: "&u32", 451 label: "&u32",
444 }, 452 },
445 ] 453 ]
446 "### 454 "###
447 ); 455 );
448 } 456 }
@@ -478,28 +486,30 @@ fn main() {
478}"#, 486}"#,
479 ); 487 );
480 488
481 assert_debug_snapshot!(analysis.inlay_hints(file_id).unwrap(), @r#"[ 489 assert_debug_snapshot!(analysis.inlay_hints(file_id).unwrap(), @r###"
482 InlayHint { 490 [
483 range: [311; 315), 491 InlayHint {
484 kind: TypeHint, 492 range: [311; 315),
485 label: "Test", 493 kind: TypeHint,
486 }, 494 label: "Test",
487 InlayHint { 495 },
488 range: [358; 359), 496 InlayHint {
489 kind: TypeHint, 497 range: [358; 359),
490 label: "CustomOption<u32>", 498 kind: TypeHint,
491 }, 499 label: "CustomOption<u32>",
492 InlayHint { 500 },
493 range: [361; 362), 501 InlayHint {
494 kind: TypeHint, 502 range: [361; 362),
495 label: "u8", 503 kind: TypeHint,
496 }, 504 label: "u8",
497 InlayHint { 505 },
498 range: [484; 485), 506 InlayHint {
499 kind: TypeHint, 507 range: [484; 485),
500 label: "u32", 508 kind: TypeHint,
501 }, 509 label: "u32",
502]"# 510 },
511 ]
512 "###
503 ); 513 );
504 } 514 }
505} 515}
diff --git a/crates/ra_ide_api/src/runnables.rs b/crates/ra_ide_api/src/runnables.rs
index 1b5c8deea..366ac8048 100644
--- a/crates/ra_ide_api/src/runnables.rs
+++ b/crates/ra_ide_api/src/runnables.rs
@@ -97,24 +97,26 @@ mod tests {
97 ); 97 );
98 let runnables = analysis.runnables(pos.file_id).unwrap(); 98 let runnables = analysis.runnables(pos.file_id).unwrap();
99 assert_debug_snapshot!(&runnables, 99 assert_debug_snapshot!(&runnables,
100 @r#"[ 100 @r###"
101 Runnable { 101 [
102 range: [1; 21), 102 Runnable {
103 kind: Bin, 103 range: [1; 21),
104 }, 104 kind: Bin,
105 Runnable { 105 },
106 range: [22; 46), 106 Runnable {
107 kind: Test { 107 range: [22; 46),
108 name: "test_foo", 108 kind: Test {
109 }, 109 name: "test_foo",
110 }, 110 },
111 Runnable { 111 },
112 range: [47; 81), 112 Runnable {
113 kind: Test { 113 range: [47; 81),
114 name: "test_foo", 114 kind: Test {
115 }, 115 name: "test_foo",
116 }, 116 },
117]"# 117 },
118 ]
119 "###
118 ); 120 );
119 } 121 }
120 122
@@ -132,20 +134,22 @@ mod tests {
132 ); 134 );
133 let runnables = analysis.runnables(pos.file_id).unwrap(); 135 let runnables = analysis.runnables(pos.file_id).unwrap();
134 assert_debug_snapshot!(&runnables, 136 assert_debug_snapshot!(&runnables,
135 @r#"[ 137 @r###"
136 Runnable { 138 [
137 range: [1; 59), 139 Runnable {
138 kind: TestMod { 140 range: [1; 59),
139 path: "test_mod", 141 kind: TestMod {
140 }, 142 path: "test_mod",
141 }, 143 },
142 Runnable { 144 },
143 range: [28; 57), 145 Runnable {
144 kind: Test { 146 range: [28; 57),
145 name: "test_foo1", 147 kind: Test {
146 }, 148 name: "test_foo1",
147 }, 149 },
148]"# 150 },
151 ]
152 "###
149 ); 153 );
150 } 154 }
151 155
@@ -165,20 +169,22 @@ mod tests {
165 ); 169 );
166 let runnables = analysis.runnables(pos.file_id).unwrap(); 170 let runnables = analysis.runnables(pos.file_id).unwrap();
167 assert_debug_snapshot!(&runnables, 171 assert_debug_snapshot!(&runnables,
168 @r#"[ 172 @r###"
169 Runnable { 173 [
170 range: [23; 85), 174 Runnable {
171 kind: TestMod { 175 range: [23; 85),
172 path: "foo::test_mod", 176 kind: TestMod {
173 }, 177 path: "foo::test_mod",
174 }, 178 },
175 Runnable { 179 },
176 range: [46; 79), 180 Runnable {
177 kind: Test { 181 range: [46; 79),
178 name: "test_foo1", 182 kind: Test {
179 }, 183 name: "test_foo1",
180 }, 184 },
181]"# 185 },
186 ]
187 "###
182 ); 188 );
183 } 189 }
184 190
@@ -200,20 +206,22 @@ mod tests {
200 ); 206 );
201 let runnables = analysis.runnables(pos.file_id).unwrap(); 207 let runnables = analysis.runnables(pos.file_id).unwrap();
202 assert_debug_snapshot!(&runnables, 208 assert_debug_snapshot!(&runnables,
203 @r#"[ 209 @r###"
204 Runnable { 210 [
205 range: [41; 115), 211 Runnable {
206 kind: TestMod { 212 range: [41; 115),
207 path: "foo::bar::test_mod", 213 kind: TestMod {
208 }, 214 path: "foo::bar::test_mod",
209 }, 215 },
210 Runnable { 216 },
211 range: [68; 105), 217 Runnable {
212 kind: Test { 218 range: [68; 105),
213 name: "test_foo1", 219 kind: Test {
214 }, 220 name: "test_foo1",
215 }, 221 },
216]"# 222 },
223 ]
224 "###
217 ); 225 );
218 } 226 }
219 227