Improved packed repr matching.

This commit is contained in:
Tanner Rogalsky 2020-05-17 12:14:42 -04:00 committed by David Tolnay
parent d5e6436b28
commit 1cd10a7d09

View File

@ -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"))
})
});
}
}