diff options
author | Matthias Schiffer <mschiffer@universe-factory.net> | 2024-04-29 18:50:40 +0200 |
---|---|---|
committer | Matthias Schiffer <mschiffer@universe-factory.net> | 2024-04-29 18:53:02 +0200 |
commit | 8226a8ec820987c99c24b5f6e76a8b379f9efa0a (patch) | |
tree | 3793b6aefa5b5e59a2c69ead68d96dc1e8faad89 /crates/rebel-parse | |
parent | 5a09ae2978e5fcd7a4894bd87324c0ca9c11826e (diff) | |
download | rebel-8226a8ec820987c99c24b5f6e76a8b379f9efa0a.tar rebel-8226a8ec820987c99c24b5f6e76a8b379f9efa0a.zip |
rebel-parse: limit explicit array length specification to u32
Diffstat (limited to 'crates/rebel-parse')
-rw-r--r-- | crates/rebel-parse/src/ast/typ.rs | 2 | ||||
-rw-r--r-- | 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<Type<'a>>), - Array(Box<Type<'a>>, Option<usize>), + Array(Box<Type<'a>>, Option<u32>), Struct(Vec<StructField<'a>>), } 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(';')>, <number()>)? 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)) } |