From 8aeaf93b9a1d78592a0aa146a8dd1b13b4495fef Mon Sep 17 00:00:00 2001 From: Florian Diebold Date: Tue, 24 Dec 2019 22:10:44 +0100 Subject: Make enum variant fields public --- crates/ra_hir_def/src/visibility.rs | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'crates') 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 { } VisibilityDefId::StructFieldId(it) => { let src = it.parent.child_source(db); - // TODO: enum variant fields should be public by default + let is_enum = match it.parent { + crate::VariantId::EnumVariantId(_) => true, + _ => false, + }; let vis_node = src.map(|m| match &m[it.local_id] { Either::Left(tuple) => tuple.visibility(), Either::Right(record) => record.visibility(), }); - Visibility::from_ast(db, vis_node) + if vis_node.value.is_none() && is_enum { + Visibility::Public + } else { + Visibility::from_ast(db, vis_node) + } } VisibilityDefId::AdtId(it) => match it { AdtId::StructId(it) => visibility_from_loc(it.lookup(db), db), -- cgit v1.2.3