Skip to content

Commit

Permalink
codegen: Do generate unnamed enums, as they can be referred to by mem…
Browse files Browse the repository at this point in the history
…bers.

Fixes rust-lang#1880
  • Loading branch information
emilio authored and LoganBarnett committed Dec 2, 2023
1 parent e4f2fb2 commit 542e0d0
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions src/codegen/mod.rs
Expand Up @@ -2478,7 +2478,6 @@ impl<'a> EnumBuilder<'a> {
repr: proc_macro2::TokenStream,
enum_variation: EnumVariation,
enum_codegen_depth: usize,
is_ty_named: bool,
) -> Self {
let ident = Ident::new(name, Span::call_site());

Expand Down Expand Up @@ -2507,12 +2506,10 @@ impl<'a> EnumBuilder<'a> {
EnumVariation::Consts => {
let mut variants = Vec::new();

if is_ty_named {
variants.push(quote! {
#( #attrs )*
pub type #ident = #repr;
});
}
variants.push(quote! {
#( #attrs )*
pub type #ident = #repr;
});

EnumBuilder::Consts {
repr,
Expand Down Expand Up @@ -2901,7 +2898,6 @@ impl CodeGenerator for Enum {
repr,
variation,
item.codegen_depth(ctx),
enum_ty.name().is_some(),
);

// A map where we keep a value -> variant relation.
Expand Down

0 comments on commit 542e0d0

Please sign in to comment.