Skip to content

Commit

Permalink
Merge pull request #1541 from dtolnay/groupedattr
Browse files Browse the repository at this point in the history
Fix infinite loop on attr surrounded by None-delimited group
  • Loading branch information
dtolnay authored Dec 11, 2023
2 parents da0d4da + 17305ff commit 9f29f05
Showing 1 changed file with 2 additions and 17 deletions.
19 changes: 2 additions & 17 deletions src/expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1354,23 +1354,8 @@ pub(crate) mod parsing {
#[cfg(feature = "full")]
fn expr_attrs(input: ParseStream) -> Result<Vec<Attribute>> {
let mut attrs = Vec::new();
loop {
if input.peek(token::Group) {
let ahead = input.fork();
let group = crate::group::parse_group(&ahead)?;
if !group.content.peek(Token![#]) || group.content.peek2(Token![!]) {
break;
}
let attr = group.content.call(attr::parsing::single_parse_outer)?;
if !group.content.is_empty() {
break;
}
attrs.push(attr);
} else if input.peek(Token![#]) {
attrs.push(input.call(attr::parsing::single_parse_outer)?);
} else {
break;
}
while !input.peek(token::Group) && input.peek(Token![#]) {
attrs.push(input.call(attr::parsing::single_parse_outer)?);
}
Ok(attrs)
}
Expand Down

0 comments on commit 9f29f05

Please sign in to comment.