Rollup merge of #146094 - mohe2015:patch-2, r=lcnr

Make `Parser::parse_for_head` public for rustfmt usage

Similar to https://github.com/rust-lang/rust/pull/138511, I want to add [dioxus rsx](https://dioxuslabs.com/learn/0.6/reference/rsx) formatting to [my rustfmt fork](https://github.com/tucant/rustfmt) and it would be much easier if that method would be public. Thanks.
This commit is contained in:
Guillaume Gomez
2025-09-02 17:08:57 +02:00
committed by GitHub

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`