From 8226a8ec820987c99c24b5f6e76a8b379f9efa0a Mon Sep 17 00:00:00 2001 From: Matthias Schiffer Date: Mon, 29 Apr 2024 18:50:40 +0200 Subject: rebel-parse: limit explicit array length specification to u32 --- crates/rebel-parse/src/ast/typ.rs | 2 +- crates/rebel-parse/src/grammar/recipe.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/crates/rebel-parse/src/ast/typ.rs b/crates/rebel-parse/src/ast/typ.rs index 4b509e6..37aa33e 100644 --- a/crates/rebel-parse/src/ast/typ.rs +++ b/crates/rebel-parse/src/ast/typ.rs @@ -11,7 +11,7 @@ pub enum Type<'a> { pub enum Literal<'a> { Unit, Tuple(Vec>), - Array(Box>, Option), + Array(Box>, Option), Struct(Vec>), } diff --git a/crates/rebel-parse/src/grammar/recipe.rs b/crates/rebel-parse/src/grammar/recipe.rs index 68d43dc..893d4b7 100644 --- a/crates/rebel-parse/src/grammar/recipe.rs +++ b/crates/rebel-parse/src/grammar/recipe.rs @@ -68,7 +68,7 @@ peg::parser! { } / p('[') typ:typ() len:tagged(, )? p(']') { ? let len = len - .map(|n| usize::try_from(n).or(Err("Invalid array length"))) + .map(|n| u32::try_from(n).or(Err("Invalid array length"))) .transpose()?; Ok(typ::Literal::Array(Box::new(typ), len)) } -- cgit v1.2.3