From 0956263a664f226a37f7427ce049ec9df6d0532a Mon Sep 17 00:00:00 2001 From: Frank Buss Date: Fri, 8 Nov 2024 11:17:56 +0100 Subject: [PATCH 1/2] fixed panic for constants --- src/generation.rs | 5 +++++ tests/canonical/input.cddl | 2 ++ 2 files changed, 7 insertions(+) diff --git a/src/generation.rs b/src/generation.rs index d785fcc..4761b35 100644 --- a/src/generation.rs +++ b/src/generation.rs @@ -509,6 +509,11 @@ impl GenerationScope { if let AliasIdent::Rust(ident) = alias_ident { // also make sure not to generate it if we instead generated a binary wrapper type if alias_info.gen_rust_alias { + if let ConceptualRustType::Fixed(constant) = + &alias_info.base_type.conceptual_type + { + continue; + } self.rust(types, ident).push_type_alias( TypeAlias::new( ident, diff --git a/tests/canonical/input.cddl b/tests/canonical/input.cddl index 9de38c5..ca6cc9b 100644 --- a/tests/canonical/input.cddl +++ b/tests/canonical/input.cddl @@ -1,3 +1,5 @@ +constant10 = 10 + foo = #6.11([uint, text, bytes]) bar = { From 8f16931b1e393d851df34c862f6eae6e4c289443 Mon Sep 17 00:00:00 2001 From: Frank Buss Date: Fri, 8 Nov 2024 11:29:31 +0100 Subject: [PATCH 2/2] removed unused variable name --- src/generation.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/generation.rs b/src/generation.rs index 4761b35..5ba1388 100644 --- a/src/generation.rs +++ b/src/generation.rs @@ -509,7 +509,7 @@ impl GenerationScope { if let AliasIdent::Rust(ident) = alias_ident { // also make sure not to generate it if we instead generated a binary wrapper type if alias_info.gen_rust_alias { - if let ConceptualRustType::Fixed(constant) = + if let ConceptualRustType::Fixed(_) = &alias_info.base_type.conceptual_type { continue;