Skip to content

Commit

Permalink
Improved packed repr matching.
Browse files Browse the repository at this point in the history
  • Loading branch information
TannerRogalsky authored and dtolnay committed Jun 21, 2020
1 parent d5e6436 commit 1cd10a7
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions serde_derive/src/internals/attr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -597,8 +597,19 @@ impl Container {
for attr in &item.attrs {
if attr.path.is_ident("repr") {
let _ = attr.parse_args_with(|input: ParseStream| {
is_packed |= input.parse::<Ident>()? == "packed";
Ok(())
input.step(|cursor| {
let mut rest = *cursor;
while let Some((tt, next)) = rest.token_tree() {
match &tt {
TokenTree::Ident(ident) if ident == "packed" => {
is_packed |= true;
return Ok(((), next));
}
_ => rest = next,
}
}
Err(cursor.error("no `packed` was found in the reprs"))
})
});
}
}
Expand Down

0 comments on commit 1cd10a7

Please sign in to comment.