File tree Expand file tree Collapse file tree 1 file changed +32
-0
lines changed Expand file tree Collapse file tree 1 file changed +32
-0
lines changed Original file line number Diff line number Diff line change @@ -150,6 +150,38 @@ ReachabilityVisitor::visit (HIR::Enum &enum_item)
150
150
151
151
enum_reach = ctx.update_reachability (enum_item.get_mappings (), enum_reach);
152
152
visit_generic_predicates (enum_item.get_generic_params (), enum_reach);
153
+
154
+ for (const auto &variant : enum_item.get_variants ())
155
+ {
156
+ auto variant_reach
157
+ = ctx.update_reachability (variant->get_mappings (), enum_reach);
158
+
159
+ switch (variant->get_enum_item_kind ())
160
+ {
161
+ case HIR::EnumItem::Tuple: {
162
+ // Should we update the fields only if they are public? Similarly to
163
+ // what we do in the ReachabilityVisitor for HIR::TupleStruct?
164
+ auto tuple_variant
165
+ = static_cast <HIR::EnumItemTuple *> (variant.get ());
166
+ for (const auto &field : tuple_variant->get_tuple_fields ())
167
+ ctx.update_reachability (field.get_mappings (), variant_reach);
168
+ break ;
169
+ }
170
+ case HIR::EnumItem::Struct: {
171
+ // Should we update the fields only if they are public? Similarly to
172
+ // what we do in the ReachabilityVisitor for HIR::StructStruct?
173
+ auto struct_variant
174
+ = static_cast <HIR::EnumItemStruct *> (variant.get ());
175
+ for (const auto &field : struct_variant->get_struct_fields ())
176
+ ctx.update_reachability (field.get_mappings (), variant_reach);
177
+ break ;
178
+ }
179
+ // Nothing nested to visit in that case
180
+ case HIR::EnumItem::Named:
181
+ case HIR::EnumItem::Discriminant:
182
+ break ;
183
+ }
184
+ }
153
185
}
154
186
155
187
void
You can’t perform that action at this time.
0 commit comments