diff options
author | Florian Diebold <[email protected]> | 2019-12-24 21:10:44 +0000 |
---|---|---|
committer | Florian Diebold <[email protected]> | 2019-12-26 15:23:40 +0000 |
commit | 8aeaf93b9a1d78592a0aa146a8dd1b13b4495fef (patch) | |
tree | dd28340ad3ce1884a09ac494c2393695a0b6491e | |
parent | 9e9c4be48a2efdc1e209dbb531cabb9e81840516 (diff) |
Make enum variant fields public
-rw-r--r-- | crates/ra_hir_def/src/visibility.rs | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/crates/ra_hir_def/src/visibility.rs b/crates/ra_hir_def/src/visibility.rs index 901bc7191..158d4393d 100644 --- a/crates/ra_hir_def/src/visibility.rs +++ b/crates/ra_hir_def/src/visibility.rs | |||
@@ -38,12 +38,19 @@ impl Visibility { | |||
38 | } | 38 | } |
39 | VisibilityDefId::StructFieldId(it) => { | 39 | VisibilityDefId::StructFieldId(it) => { |
40 | let src = it.parent.child_source(db); | 40 | let src = it.parent.child_source(db); |
41 | // TODO: enum variant fields should be public by default | 41 | let is_enum = match it.parent { |
42 | crate::VariantId::EnumVariantId(_) => true, | ||
43 | _ => false, | ||
44 | }; | ||
42 | let vis_node = src.map(|m| match &m[it.local_id] { | 45 | let vis_node = src.map(|m| match &m[it.local_id] { |
43 | Either::Left(tuple) => tuple.visibility(), | 46 | Either::Left(tuple) => tuple.visibility(), |
44 | Either::Right(record) => record.visibility(), | 47 | Either::Right(record) => record.visibility(), |
45 | }); | 48 | }); |
46 | Visibility::from_ast(db, vis_node) | 49 | if vis_node.value.is_none() && is_enum { |
50 | Visibility::Public | ||
51 | } else { | ||
52 | Visibility::from_ast(db, vis_node) | ||
53 | } | ||
47 | } | 54 | } |
48 | VisibilityDefId::AdtId(it) => match it { | 55 | VisibilityDefId::AdtId(it) => match it { |
49 | AdtId::StructId(it) => visibility_from_loc(it.lookup(db), db), | 56 | AdtId::StructId(it) => visibility_from_loc(it.lookup(db), db), |