diff options
| author | bors <bors@rust-lang.org> | 2024-11-17 16:24:54 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2024-11-17 16:24:54 +0000 |
| commit | a8e75c53d0036b5d012cbc0ee5de17f8991fe60c (patch) | |
| tree | bb4be0dcd1f6f02bd5d244beb6d1b6161f85392b /compiler/rustc_parse/src/parser/expr.rs | |
| parent | 23e7ecb34962ecd069cf28ae7db585e92ca2ee63 (diff) | |
| parent | defc8666a38c115fa46ab4ddb4e3d2eeca3c206c (diff) | |
| download | rust-a8e75c53d0036b5d012cbc0ee5de17f8991fe60c.tar.gz rust-a8e75c53d0036b5d012cbc0ee5de17f8991fe60c.zip | |
Auto merge of #133135 - jieyouxu:rollup-4q1wbyq, r=jieyouxu
Rollup of 6 pull requests Successful merges: - #133029 (ABI checks: add support for some tier3 arches, warn on others.) - #133051 (Increase accuracy of `if` condition misparse suggestion) - #133060 (Trim whitespace in RemoveLet primary span) - #133093 (Let chains tests) - #133116 (stabilize const_ptr_is_null) - #133126 (alloc: fix `String`'s doc) r? `@ghost` `@rustbot` modify labels: rollup
Diffstat (limited to 'compiler/rustc_parse/src/parser/expr.rs')
| -rw-r--r-- | compiler/rustc_parse/src/parser/expr.rs | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/compiler/rustc_parse/src/parser/expr.rs b/compiler/rustc_parse/src/parser/expr.rs index 0ac6133e828..0012db471ef 100644 --- a/compiler/rustc_parse/src/parser/expr.rs +++ b/compiler/rustc_parse/src/parser/expr.rs @@ -2683,6 +2683,13 @@ impl<'a> Parser<'a> { // ^^ // } // + // We account for macro calls that were meant as conditions as well. + // + // if ... { + // } else if macro! { foo bar } { + // ^^ + // } + // // If $cond is "statement-like" such as ExprKind::While then we // want to suggest wrapping in braces. // @@ -2693,7 +2700,9 @@ impl<'a> Parser<'a> { // } // ^ if self.check(&TokenKind::OpenDelim(Delimiter::Brace)) - && classify::expr_requires_semi_to_be_stmt(&cond) => + && (classify::expr_requires_semi_to_be_stmt(&cond) + || matches!(cond.kind, ExprKind::MacCall(..))) + => { self.dcx().emit_err(errors::ExpectedElseBlock { first_tok_span, |
