diff options
Diffstat (limited to 'crates/ide/src/references.rs')
-rw-r--r-- | crates/ide/src/references.rs | 87 |
1 files changed, 87 insertions, 0 deletions
diff --git a/crates/ide/src/references.rs b/crates/ide/src/references.rs index e0830eb4f..9315f7354 100644 --- a/crates/ide/src/references.rs +++ b/crates/ide/src/references.rs | |||
@@ -406,6 +406,23 @@ enum Foo { | |||
406 | } | 406 | } |
407 | 407 | ||
408 | #[test] | 408 | #[test] |
409 | fn test_find_all_refs_enum_var_field() { | ||
410 | check( | ||
411 | r#" | ||
412 | enum Foo { | ||
413 | A, | ||
414 | B { field<|>: u8 }, | ||
415 | C, | ||
416 | } | ||
417 | "#, | ||
418 | expect![[r#" | ||
419 | field RECORD_FIELD FileId(0) 26..35 26..31 Other | ||
420 | |||
421 | "#]], | ||
422 | ); | ||
423 | } | ||
424 | |||
425 | #[test] | ||
409 | fn test_find_all_refs_two_modules() { | 426 | fn test_find_all_refs_two_modules() { |
410 | check( | 427 | check( |
411 | r#" | 428 | r#" |
@@ -669,6 +686,76 @@ fn g() { f(); } | |||
669 | ); | 686 | ); |
670 | } | 687 | } |
671 | 688 | ||
689 | #[test] | ||
690 | fn test_find_all_refs_struct_pat() { | ||
691 | check( | ||
692 | r#" | ||
693 | struct S { | ||
694 | field<|>: u8, | ||
695 | } | ||
696 | |||
697 | fn f(s: S) { | ||
698 | match s { | ||
699 | S { field } => {} | ||
700 | } | ||
701 | } | ||
702 | "#, | ||
703 | expect![[r#" | ||
704 | field RECORD_FIELD FileId(0) 15..24 15..20 Other | ||
705 | |||
706 | FileId(0) 68..73 FieldShorthandForField Read | ||
707 | "#]], | ||
708 | ); | ||
709 | } | ||
710 | |||
711 | #[test] | ||
712 | fn test_find_all_refs_enum_var_pat() { | ||
713 | check( | ||
714 | r#" | ||
715 | enum En { | ||
716 | Variant { | ||
717 | field<|>: u8, | ||
718 | } | ||
719 | } | ||
720 | |||
721 | fn f(e: En) { | ||
722 | match e { | ||
723 | En::Variant { field } => {} | ||
724 | } | ||
725 | } | ||
726 | "#, | ||
727 | expect![[r#" | ||
728 | field RECORD_FIELD FileId(0) 32..41 32..37 Other | ||
729 | |||
730 | FileId(0) 102..107 FieldShorthandForField Read | ||
731 | "#]], | ||
732 | ); | ||
733 | } | ||
734 | |||
735 | #[test] | ||
736 | fn test_find_all_refs_enum_var_privacy() { | ||
737 | check( | ||
738 | r#" | ||
739 | mod m { | ||
740 | pub enum En { | ||
741 | Variant { | ||
742 | field<|>: u8, | ||
743 | } | ||
744 | } | ||
745 | } | ||
746 | |||
747 | fn f() -> m::En { | ||
748 | m::En::Variant { field: 0 } | ||
749 | } | ||
750 | "#, | ||
751 | expect![[r#" | ||
752 | field RECORD_FIELD FileId(0) 56..65 56..61 Other | ||
753 | |||
754 | FileId(0) 125..130 Other Read | ||
755 | "#]], | ||
756 | ); | ||
757 | } | ||
758 | |||
672 | fn check(ra_fixture: &str, expect: Expect) { | 759 | fn check(ra_fixture: &str, expect: Expect) { |
673 | check_with_scope(ra_fixture, None, expect) | 760 | check_with_scope(ra_fixture, None, expect) |
674 | } | 761 | } |