diff options
Diffstat (limited to 'crates/ide')
-rw-r--r-- | crates/ide/src/references.rs | 70 |
1 files changed, 70 insertions, 0 deletions
diff --git a/crates/ide/src/references.rs b/crates/ide/src/references.rs index ae68b4392..9315f7354 100644 --- a/crates/ide/src/references.rs +++ b/crates/ide/src/references.rs | |||
@@ -686,6 +686,76 @@ fn g() { f(); } | |||
686 | ); | 686 | ); |
687 | } | 687 | } |
688 | 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 | |||
689 | fn check(ra_fixture: &str, expect: Expect) { | 759 | fn check(ra_fixture: &str, expect: Expect) { |
690 | check_with_scope(ra_fixture, None, expect) | 760 | check_with_scope(ra_fixture, None, expect) |
691 | } | 761 | } |