Skip to content

Commit 1cd10a7

Browse files
TannerRogalskydtolnay
authored andcommitted
Improved packed repr matching.
1 parent d5e6436 commit 1cd10a7

1 file changed

Lines changed: 13 additions & 2 deletions

File tree

‎serde_derive/src/internals/attr.rs‎

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -597,8 +597,19 @@ impl Container {
597597
for attr in &item.attrs {
598598
if attr.path.is_ident("repr") {
599599
let _ = attr.parse_args_with(|input: ParseStream| {
600-
is_packed |= input.parse::<Ident>()? == "packed";
601-
Ok(())
600+
input.step(|cursor| {
601+
let mut rest = *cursor;
602+
while let Some((tt, next)) = rest.token_tree() {
603+
match &tt {
604+
TokenTree::Ident(ident) if ident == "packed" => {
605+
is_packed |= true;
606+
return Ok(((), next));
607+
}
608+
_ => rest = next,
609+
}
610+
}
611+
Err(cursor.error("no `packed` was found in the reprs"))
612+
})
602613
});
603614
}
604615
}

0 commit comments

Comments
 (0)