From 5dcbf03d0f114cab1ae1748dd3c3632a52f6f52d Mon Sep 17 00:00:00 2001 From: Jonas Schievink Date: Fri, 9 Oct 2020 20:42:17 +0200 Subject: 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. --- crates/ide/src/references.rs | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'crates/ide') 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) { ); } + #[test] + fn test_find_all_refs_enum_var_privacy() { + check( + r#" +mod m { + pub enum En { + Variant { + field<|>: u8, + } + } +} + +fn f() -> m::En { + m::En::Variant { field: 0 } +} +"#, + expect![[r#" + field RECORD_FIELD FileId(0) 56..65 56..61 Other + + FileId(0) 125..130 Other Read + "#]], + ); + } + fn check(ra_fixture: &str, expect: Expect) { check_with_scope(ra_fixture, None, expect) } -- cgit v1.2.3