Skip to content

Commit

Permalink
fix(comb): Improve non-parser seq error messages
Browse files Browse the repository at this point in the history
This only helps in the struct case.
  • Loading branch information
epage committed Jun 4, 2024
1 parent a761e54 commit acda2d8
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions src/macros/seq.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,15 +74,13 @@
macro_rules! seq {
($($name: ident)::* { $($fields: tt)* }) => {
$crate::combinator::trace(stringify!($($name)::*), move |input: &mut _| {
use $crate::Parser;
$crate::seq_parse_struct_fields!(input; $($fields)*);
#[allow(clippy::redundant_field_names)]
Ok($crate::seq_init_struct_fields!( ($($fields)*); $($name)::*;))
})
};
($($name: ident)::* ( $($elements: tt)* )) => {
$crate::combinator::trace(stringify!($($name)::*), move |input: &mut _| {
use $crate::Parser;
$crate::seq_parse_tuple_fields!( ($($elements)*) ; ).map(|t| {
$crate::seq_init_tuple_fields!(
($($elements)*);
Expand Down Expand Up @@ -116,27 +114,27 @@ macro_rules! seq_parse_struct_fields {
$input: ident;
_ : $head_parser: expr, $($fields: tt)*
) => {
let _ = $head_parser.parse_next($input)?;
let _ = $crate::Parser::parse_next(&mut $head_parser, $input)?;
$crate::seq_parse_struct_fields!($input; $($fields)*)
};
(
$input: ident;
_ : $head_parser: expr
) => {
let _ = $head_parser.parse_next($input)?;
let _ = $crate::Parser::parse_next(&mut $head_parser, $input)?;
};
(
$input: ident;
$head_field: ident : $head_parser: expr, $($fields: tt)*
) => {
let $head_field = $head_parser.parse_next($input)?;
let $head_field = $crate::Parser::parse_next(&mut $head_parser, $input)?;
$crate::seq_parse_struct_fields!($input; $($fields)*)
};
(
$input: ident;
$head_field: ident : $head_parser: expr
) => {
let $head_field = $head_parser.parse_next($input)?;
let $head_field = $crate::Parser::parse_next(&mut $head_parser, $input)?;
};
(
$input: expr;
Expand Down

0 comments on commit acda2d8

Please sign in to comment.