Skip to content

Commit e8aa191

Browse files
committed
Fix name duplication for inline choice types gh#75
1 parent c4f55dc commit e8aa191

File tree

1 file changed

+8
-3
lines changed
  • asn1rs-model/src/model/rust

1 file changed

+8
-3
lines changed

asn1rs-model/src/model/rust/mod.rs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -788,11 +788,16 @@ impl Model<Rust> {
788788
extended_after_index: choice.extension_after_index(),
789789
};
790790

791-
for ChoiceVariant { name, r#type, tag } in choice.variants() {
792-
let rust_name = format!("{}{}", name, ctxt.struct_or_enum_name(name));
791+
for ChoiceVariant {
792+
name: variant_name,
793+
r#type,
794+
tag,
795+
} in choice.variants()
796+
{
797+
let rust_name = format!("{}{}", name, ctxt.struct_or_enum_name(variant_name));
793798
let rust_role =
794799
Self::definition_type_to_rust_type(&rust_name, r#type, *tag, ctxt);
795-
let rust_field_name = ctxt.variant_name(name);
800+
let rust_field_name = ctxt.variant_name(variant_name);
796801
enumeration.variants.push(
797802
DataVariant::from_name_type(rust_field_name, rust_role).with_tag_opt(*tag),
798803
);

0 commit comments

Comments
 (0)