diff options
| author | Ben Kimock <kimockb@gmail.com> | 2024-11-18 06:07:37 +0000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-11-18 06:07:37 +0000 |
| commit | 00286e6a386123bff0326d9066125b49ef30f712 (patch) | |
| tree | 1da03fa3c2eb29aa72590b2d6163585d44a22101 /compiler/rustc_parse/src/parser/expr.rs | |
| parent | 34ad8de02d6283b81b608b1915e8c37bbd1fe764 (diff) | |
| parent | f71a0427145afabcde4d1a9b746bc0f91d6003a0 (diff) | |
| download | rust-00286e6a386123bff0326d9066125b49ef30f712.tar.gz rust-00286e6a386123bff0326d9066125b49ef30f712.zip | |
Merge pull request #4038 from rust-lang/rustup-2024-11-18
Automatic Rustup
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, |
