Skip to content

Commit

Permalink
Merge pull request #1212 from dtolnay/forclosure
Browse files Browse the repository at this point in the history
Parse closures with explicit empty lifetime list
  • Loading branch information
dtolnay committed Sep 18, 2022
2 parents f9455f8 + 7d6ad91 commit eb0db05
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
9 changes: 7 additions & 2 deletions src/expr.rs
Expand Up @@ -1727,7 +1727,10 @@ pub(crate) mod parsing {
|| input.peek(Token![move])
{
expr_closure(input, allow_struct).map(Expr::Closure)
} else if input.peek(Token![for]) && input.peek2(Token![<]) && input.peek3(Lifetime) {
} else if input.peek(Token![for])
&& input.peek2(Token![<])
&& (input.peek3(Lifetime) || input.peek3(Token![>]))
{
let begin = input.fork();
input.parse::<BoundLifetimes>()?;
expr_closure(input, allow_struct)?;
Expand Down Expand Up @@ -2010,7 +2013,9 @@ pub(crate) mod parsing {
Expr::If(input.parse()?)
} else if input.peek(Token![while]) {
Expr::While(input.parse()?)
} else if input.peek(Token![for]) {
} else if input.peek(Token![for])
&& !(input.peek2(Token![<]) && (input.peek3(Lifetime) || input.peek3(Token![>])))
{
Expr::ForLoop(input.parse()?)
} else if input.peek(Token![loop]) {
Expr::Loop(input.parse()?)
Expand Down
4 changes: 0 additions & 4 deletions tests/repo/mod.rs
Expand Up @@ -14,10 +14,6 @@ const REVISION: &str = "98ad6a5519651af36e246c0335c964dd52c554ba";

#[rustfmt::skip]
static EXCLUDE_FILES: &[&str] = &[
// TODO: for<> closures with empty lifetime list
"src/tools/rustfmt/tests/source/closure.rs",
"src/tools/rustfmt/tests/target/closure.rs",

// TODO: dyn*
"src/test/ui/dyn-star/const.rs",
"src/test/ui/dyn-star/drop.rs",
Expand Down

0 comments on commit eb0db05

Please sign in to comment.