diff options
author | Jonas Schievink <[email protected]> | 2021-06-03 13:26:26 +0100 |
---|---|---|
committer | Jonas Schievink <[email protected]> | 2021-06-03 13:26:26 +0100 |
commit | 28e3e683b204050e532f49f84f2ec887f19cc91c (patch) | |
tree | 50df840065d230bce60b5d0b4065888a311aba57 /crates/hir_def/src/item_tree/lower.rs | |
parent | c7eb19ebf9d42cada8cb532c6b3cb0e11a531b93 (diff) |
ItemTree: make variant fields inherit the enum's visibility
Diffstat (limited to 'crates/hir_def/src/item_tree/lower.rs')
-rw-r--r-- | crates/hir_def/src/item_tree/lower.rs | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/crates/hir_def/src/item_tree/lower.rs b/crates/hir_def/src/item_tree/lower.rs index 6208facd5..0e467d907 100644 --- a/crates/hir_def/src/item_tree/lower.rs +++ b/crates/hir_def/src/item_tree/lower.rs | |||
@@ -276,10 +276,11 @@ impl<'a> Ctx<'a> { | |||
276 | let visibility = self.lower_visibility(enum_); | 276 | let visibility = self.lower_visibility(enum_); |
277 | let name = enum_.name()?.as_name(); | 277 | let name = enum_.name()?.as_name(); |
278 | let generic_params = self.lower_generic_params(GenericsOwner::Enum, enum_); | 278 | let generic_params = self.lower_generic_params(GenericsOwner::Enum, enum_); |
279 | let variants = match &enum_.variant_list() { | 279 | let variants = |
280 | Some(variant_list) => self.lower_variants(variant_list), | 280 | self.with_inherited_visibility(visibility, |this| match &enum_.variant_list() { |
281 | None => IdRange::new(self.next_variant_idx()..self.next_variant_idx()), | 281 | Some(variant_list) => this.lower_variants(variant_list), |
282 | }; | 282 | None => IdRange::new(this.next_variant_idx()..this.next_variant_idx()), |
283 | }); | ||
283 | let ast_id = self.source_ast_id_map.ast_id(enum_); | 284 | let ast_id = self.source_ast_id_map.ast_id(enum_); |
284 | let res = Enum { name, visibility, generic_params, variants, ast_id }; | 285 | let res = Enum { name, visibility, generic_params, variants, ast_id }; |
285 | Some(id(self.data().enums.alloc(res))) | 286 | Some(id(self.data().enums.alloc(res))) |