Skip to content

Commit 7977592

Browse files
authored
Rollup merge of #138511 - mohe2015:rustc-parse-pub-parse-expr-cond, r=oli-obk
Make `Parser::parse_expr_cond` public This allows usage in rustfmt and rustfmt forks. I'm using this for custom macro formatting, see https://github.com/tucant/rustfmt/blob/30c83df9e1db10007bdd16dafce8a86b404329b2/src/parse/macros/html.rs#L57 It would be great if this could be upstreamed so I don't need to rely on a fork.
2 parents 9b8a677 + 66c49c7 commit 7977592

File tree

1 file changed

+2
-1
lines changed
  • compiler/rustc_parse/src/parser

1 file changed

+2
-1
lines changed

compiler/rustc_parse/src/parser/expr.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -2588,7 +2588,8 @@ impl<'a> Parser<'a> {
25882588
}
25892589

25902590
/// Parses the condition of a `if` or `while` expression.
2591-
fn parse_expr_cond(&mut self) -> PResult<'a, P<Expr>> {
2591+
// Public because it is used in rustfmt forks such as https://github.com/tucant/rustfmt/blob/30c83df9e1db10007bdd16dafce8a86b404329b2/src/parse/macros/html.rs#L57 for custom if expressions.
2592+
pub fn parse_expr_cond(&mut self) -> PResult<'a, P<Expr>> {
25922593
let attrs = self.parse_outer_attributes()?;
25932594
let (mut cond, _) =
25942595
self.parse_expr_res(Restrictions::NO_STRUCT_LITERAL | Restrictions::ALLOW_LET, attrs)?;

0 commit comments

Comments
 (0)