Make Parser::parse_for_head public for rustfmt usage

This commit is contained in:
Moritz Hedtke
2025-09-01 17:26:20 +02:00
parent c0bb3b98bb
commit d8df6312d5

View File

@@ -2910,7 +2910,8 @@ impl<'a> Parser<'a> {
}
}
fn parse_for_head(&mut self) -> PResult<'a, (Box<Pat>, Box<Expr>)> {
// Public to use it for custom `for` expressions in rustfmt forks like https://github.com/tucant/rustfmt
pub fn parse_for_head(&mut self) -> PResult<'a, (Box<Pat>, Box<Expr>)> {
let begin_paren = if self.token == token::OpenParen {
// Record whether we are about to parse `for (`.
// This is used below for recovery in case of `for ( $stuff ) $block`