aboutsummaryrefslogtreecommitdiff
path: root/crates/ide/src
diff options
context:
space:
mode:
authorJonas Schievink <[email protected]>2020-10-09 19:42:17 +0100
committerJonas Schievink <[email protected]>2020-10-09 19:46:45 +0100
commit5dcbf03d0f114cab1ae1748dd3c3632a52f6f52d (patch)
treeadfcfe50433188eec4febbfe80fe432bcc32234f /crates/ide/src
parentcde189c5d5d77afd077b067a887bbc7e3adb4f80 (diff)
adt: correctly inherit field visibility from enum
Previously, "find all references" on a variant field wouldn't find any references outside the defining module. This is because variant fields were incorrectly assumed to be private, like struct fields without explicit visibility, but they actually inherit the enum's visibility.
Diffstat (limited to 'crates/ide/src')
-rw-r--r--crates/ide/src/references.rs24
1 files changed, 24 insertions, 0 deletions
diff --git a/crates/ide/src/references.rs b/crates/ide/src/references.rs
index 571dd5452..9315f7354 100644
--- a/crates/ide/src/references.rs
+++ b/crates/ide/src/references.rs
@@ -732,6 +732,30 @@ fn f(e: En) {
732 ); 732 );
733 } 733 }
734 734
735 #[test]
736 fn test_find_all_refs_enum_var_privacy() {
737 check(
738 r#"
739mod m {
740 pub enum En {
741 Variant {
742 field<|>: u8,
743 }
744 }
745}
746
747fn 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
735 fn check(ra_fixture: &str, expect: Expect) { 759 fn check(ra_fixture: &str, expect: Expect) {
736 check_with_scope(ra_fixture, None, expect) 760 check_with_scope(ra_fixture, None, expect)
737 } 761 }