diff options
author | Christian Poveda <christian.poveda@ferrous-systems.com> | 2022-09-12 13:45:54 -0500 |
---|---|---|
committer | Darren Kulp <darren@kulp.ch> | 2022-09-18 20:11:42 -0400 |
commit | 0d805d70d5c6e4cc99cbad7a988c38bdfe52321b (patch) | |
tree | 06ad665c3c8580858c8781a376ef7fddc6d7834d /src/codegen | |
parent | 61636e94ca315278d9ac5f1210ffca6cca697428 (diff) |
fix `--newtype-global-enum` option
Diffstat (limited to 'src/codegen')
-rw-r--r-- | src/codegen/mod.rs | 23 |
1 files changed, 9 insertions, 14 deletions
diff --git a/src/codegen/mod.rs b/src/codegen/mod.rs index 9a55ea37..f523232e 100644 --- a/src/codegen/mod.rs +++ b/src/codegen/mod.rs @@ -2814,24 +2814,19 @@ impl<'a> EnumBuilder<'a> { is_global, .. } => { - if ctx.options().rust_features().associated_const && is_ty_named + if ctx.options().rust_features().associated_const && + is_ty_named && + !is_global { let enum_ident = ctx.rust_ident(canonical_name); let variant_ident = ctx.rust_ident(variant_name); - let tokens = quote! { - #doc - pub const #variant_ident : #rust_ty = #rust_ty ( #expr ); - }; - if is_global { - result.push(tokens); - } else { - result.push(quote! { - impl #enum_ident { - #tokens - } - }); - } + result.push(quote! { + impl #enum_ident { + #doc + pub const #variant_ident : #rust_ty = #rust_ty ( #expr ); + } + }); } else { let ident = ctx.rust_ident(match mangling_prefix { Some(prefix) => { |