aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_ide/src/goto_definition.rs
diff options
context:
space:
mode:
authorAleksey Kladov <[email protected]>2019-12-20 13:47:01 +0000
committerAleksey Kladov <[email protected]>2019-12-20 13:48:14 +0000
commit3d4b48e481da35f19366514c0e22ed42fef037a0 (patch)
tree9e4ff021db736a76bc82555886d868cd7429f021 /crates/ra_ide/src/goto_definition.rs
parenta0571359f3ea5361f1676b0777b578c6deefdc7d (diff)
Fix resolve for field init shorthand
Diffstat (limited to 'crates/ra_ide/src/goto_definition.rs')
-rw-r--r--crates/ra_ide/src/goto_definition.rs57
1 files changed, 37 insertions, 20 deletions
diff --git a/crates/ra_ide/src/goto_definition.rs b/crates/ra_ide/src/goto_definition.rs
index ee4ae3e03..9b5744789 100644
--- a/crates/ra_ide/src/goto_definition.rs
+++ b/crates/ra_ide/src/goto_definition.rs
@@ -258,7 +258,7 @@ mod tests {
258 } 258 }
259 259
260 #[test] 260 #[test]
261 fn goto_definition_works_in_items() { 261 fn goto_def_in_items() {
262 check_goto( 262 check_goto(
263 " 263 "
264 //- /lib.rs 264 //- /lib.rs
@@ -271,7 +271,7 @@ mod tests {
271 } 271 }
272 272
273 #[test] 273 #[test]
274 fn goto_definition_works_at_start_of_item() { 274 fn goto_def_at_start_of_item() {
275 check_goto( 275 check_goto(
276 " 276 "
277 //- /lib.rs 277 //- /lib.rs
@@ -305,7 +305,7 @@ mod tests {
305 } 305 }
306 306
307 #[test] 307 #[test]
308 fn goto_definition_works_for_module_declaration() { 308 fn goto_def_for_module_declaration() {
309 check_goto( 309 check_goto(
310 " 310 "
311 //- /lib.rs 311 //- /lib.rs
@@ -332,8 +332,8 @@ mod tests {
332 } 332 }
333 333
334 #[test] 334 #[test]
335 fn goto_definition_works_for_macros() { 335 fn goto_def_for_macros() {
336 covers!(goto_definition_works_for_macros); 336 covers!(goto_def_for_macros);
337 check_goto( 337 check_goto(
338 " 338 "
339 //- /lib.rs 339 //- /lib.rs
@@ -349,8 +349,8 @@ mod tests {
349 } 349 }
350 350
351 #[test] 351 #[test]
352 fn goto_definition_works_for_macros_from_other_crates() { 352 fn goto_def_for_macros_from_other_crates() {
353 covers!(goto_definition_works_for_macros); 353 covers!(goto_def_for_macros);
354 check_goto( 354 check_goto(
355 " 355 "
356 //- /lib.rs 356 //- /lib.rs
@@ -369,7 +369,7 @@ mod tests {
369 } 369 }
370 370
371 #[test] 371 #[test]
372 fn goto_definition_works_for_macros_in_use_tree() { 372 fn goto_def_for_macros_in_use_tree() {
373 check_goto( 373 check_goto(
374 " 374 "
375 //- /lib.rs 375 //- /lib.rs
@@ -385,7 +385,7 @@ mod tests {
385 } 385 }
386 386
387 #[test] 387 #[test]
388 fn goto_definition_works_for_macro_defined_fn_with_arg() { 388 fn goto_def_for_macro_defined_fn_with_arg() {
389 check_goto( 389 check_goto(
390 " 390 "
391 //- /lib.rs 391 //- /lib.rs
@@ -405,7 +405,7 @@ mod tests {
405 } 405 }
406 406
407 #[test] 407 #[test]
408 fn goto_definition_works_for_macro_defined_fn_no_arg() { 408 fn goto_def_for_macro_defined_fn_no_arg() {
409 check_goto( 409 check_goto(
410 " 410 "
411 //- /lib.rs 411 //- /lib.rs
@@ -425,8 +425,8 @@ mod tests {
425 } 425 }
426 426
427 #[test] 427 #[test]
428 fn goto_definition_works_for_methods() { 428 fn goto_def_for_methods() {
429 covers!(goto_definition_works_for_methods); 429 covers!(goto_def_for_methods);
430 check_goto( 430 check_goto(
431 " 431 "
432 //- /lib.rs 432 //- /lib.rs
@@ -445,8 +445,8 @@ mod tests {
445 } 445 }
446 446
447 #[test] 447 #[test]
448 fn goto_definition_works_for_fields() { 448 fn goto_def_for_fields() {
449 covers!(goto_definition_works_for_fields); 449 covers!(goto_def_for_fields);
450 check_goto( 450 check_goto(
451 " 451 "
452 //- /lib.rs 452 //- /lib.rs
@@ -464,8 +464,8 @@ mod tests {
464 } 464 }
465 465
466 #[test] 466 #[test]
467 fn goto_definition_works_for_record_fields() { 467 fn goto_def_for_record_fields() {
468 covers!(goto_definition_works_for_record_fields); 468 covers!(goto_def_for_record_fields);
469 check_goto( 469 check_goto(
470 " 470 "
471 //- /lib.rs 471 //- /lib.rs
@@ -502,7 +502,7 @@ mod tests {
502 } 502 }
503 503
504 #[test] 504 #[test]
505 fn goto_definition_works_for_ufcs_inherent_methods() { 505 fn goto_def_for_ufcs_inherent_methods() {
506 check_goto( 506 check_goto(
507 " 507 "
508 //- /lib.rs 508 //- /lib.rs
@@ -521,7 +521,7 @@ mod tests {
521 } 521 }
522 522
523 #[test] 523 #[test]
524 fn goto_definition_works_for_ufcs_trait_methods_through_traits() { 524 fn goto_def_for_ufcs_trait_methods_through_traits() {
525 check_goto( 525 check_goto(
526 " 526 "
527 //- /lib.rs 527 //- /lib.rs
@@ -539,7 +539,7 @@ mod tests {
539 } 539 }
540 540
541 #[test] 541 #[test]
542 fn goto_definition_works_for_ufcs_trait_methods_through_self() { 542 fn goto_def_for_ufcs_trait_methods_through_self() {
543 check_goto( 543 check_goto(
544 " 544 "
545 //- /lib.rs 545 //- /lib.rs
@@ -654,7 +654,7 @@ mod tests {
654 } 654 }
655 655
656 #[test] 656 #[test]
657 fn goto_definition_works_when_used_on_definition_name_itself() { 657 fn goto_def_when_used_on_definition_name_itself() {
658 check_goto( 658 check_goto(
659 " 659 "
660 //- /lib.rs 660 //- /lib.rs
@@ -875,4 +875,21 @@ mod tests {
875 "x", 875 "x",
876 ); 876 );
877 } 877 }
878
879 #[test]
880 fn goto_def_for_field_init_shorthand() {
881 covers!(goto_def_for_field_init_shorthand);
882 check_goto(
883 "
884 //- /lib.rs
885 struct Foo { x: i32 }
886 fn main() {
887 let x = 92;
888 Foo { x<|> };
889 }
890 ",
891 "x RECORD_FIELD_DEF FileId(1) [13; 19) [13; 14)",
892 "x: i32|x",
893 )
894 }
878} 895}