diff options
-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), |