mirror of
https://github.com/rust-lang/rust-analyzer
synced 2024-12-26 13:03:31 +00:00
Make enum variant fields public
This commit is contained in:
parent
9e9c4be48a
commit
8aeaf93b9a
1 changed files with 9 additions and 2 deletions
|
@ -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),
|
||||
|
|
Loading…
Reference in a new issue