From 9e1b9ad564ecccbc925a86305d92b7aeb4f29739 Mon Sep 17 00:00:00 2001 From: Selimaj Dev Date: Thu, 28 May 2026 16:28:20 +0200 Subject: [PATCH] Fixed attributes --- crates/codegen/src/lib.rs | 4 +++- crates/parser/src/parser/items/attribute.rs | 4 ++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/crates/codegen/src/lib.rs b/crates/codegen/src/lib.rs index fe6678d..7618ebc 100644 --- a/crates/codegen/src/lib.rs +++ b/crates/codegen/src/lib.rs @@ -108,11 +108,12 @@ impl GenRust for Attribute { match self { Self::Path(path) => cg.add(&path.get_rust()), Self::NameValue { path, value } => { - cg.add(&format!("{} =", path.get_rust())); + cg.add(&format!("{} = ", path.get_rust())); value.gen_rust(ctx, cg); } Self::List { path, items } => { cg.add(&path.get_rust()); + cg.add("("); for (i, item) in items.iter().enumerate() { if i > 0 { cg.add(", "); @@ -120,6 +121,7 @@ impl GenRust for Attribute { item.gen_rust(ctx, cg); } + cg.add(")"); } } } diff --git a/crates/parser/src/parser/items/attribute.rs b/crates/parser/src/parser/items/attribute.rs index f3b22ec..7095725 100644 --- a/crates/parser/src/parser/items/attribute.rs +++ b/crates/parser/src/parser/items/attribute.rs @@ -28,11 +28,11 @@ impl<'a> TryFrom> for Attribute { } Some(next) => match next.as_rule() { - Rule::primary => { + Rule::literal => { // #[path = literal] Ok(Attribute::NameValue { path, - value: inner.next().unwrap().try_into().get()?, + value: next.try_into().get()?, }) }