From 17305ff540080aab012ae1b69494e840389a1df6 Mon Sep 17 00:00:00 2001 From: David Tolnay Date: Sun, 10 Dec 2023 17:29:08 -0800 Subject: [PATCH] Fix infinite loop on attr surrounded by None-delimited group --- src/expr.rs | 19 ++----------------- 1 file changed, 2 insertions(+), 17 deletions(-) diff --git a/src/expr.rs b/src/expr.rs index ca6471c17b..59c0a086c7 100644 --- a/src/expr.rs +++ b/src/expr.rs @@ -1354,23 +1354,8 @@ pub(crate) mod parsing { #[cfg(feature = "full")] fn expr_attrs(input: ParseStream) -> Result> { 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) }