diff options
| author | bors <bors@rust-lang.org> | 2025-05-16 05:45:37 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2025-05-16 05:45:37 +0000 |
| commit | c79bbfab78dcb0a72aa3b2bc35c00334b58bfe2e (patch) | |
| tree | d6f39db82b528e67936230e39ad6c460d8904977 /compiler/rustc_parse/src/parser/stmt.rs | |
| parent | 7e19eef048ba58c28c70afbf5f95da4829c15796 (diff) | |
| parent | 5ce27f572ff4a5ba50146dc70aa5397b24a3f20a (diff) | |
| download | rust-c79bbfab78dcb0a72aa3b2bc35c00334b58bfe2e.tar.gz rust-c79bbfab78dcb0a72aa3b2bc35c00334b58bfe2e.zip | |
Auto merge of #141066 - matthiaskrgr:rollup-e7tyrj5, r=matthiaskrgr
Rollup of 9 pull requests Successful merges: - #140791 (std: explain prefer `TryInto` over `TryFrom` when specifying traits bounds on generic function) - #140834 (move (or remove) some impl Trait tests) - #140910 (Remove `stable` attribute from wasi fs (read_exact|write_all)_at) - #140984 (fix doc for UnixStream) - #140997 (Add negative test coverage for `-Clink-self-contained` and `-Zlinker-features`) - #141003 (Improve ternary operator recovery) - #141009 (Migrate to modern datetime API) - #141013 (Implement methods to set STARTUPINFO flags for Command API on Windows) - #141026 (rustc-dev-guide subtree update) r? `@ghost` `@rustbot` modify labels: rollup
Diffstat (limited to 'compiler/rustc_parse/src/parser/stmt.rs')
| -rw-r--r-- | compiler/rustc_parse/src/parser/stmt.rs | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/compiler/rustc_parse/src/parser/stmt.rs b/compiler/rustc_parse/src/parser/stmt.rs index 885a65d4de7..396ded96bde 100644 --- a/compiler/rustc_parse/src/parser/stmt.rs +++ b/compiler/rustc_parse/src/parser/stmt.rs @@ -879,7 +879,12 @@ impl<'a> Parser<'a> { { // Just check for errors and recover; do not eat semicolon yet. - let expect_result = self.expect_one_of(&[], &[exp!(Semi), exp!(CloseBrace)]); + let expect_result = + if let Err(e) = self.maybe_recover_from_ternary_operator(Some(expr.span)) { + Err(e) + } else { + self.expect_one_of(&[], &[exp!(Semi), exp!(CloseBrace)]) + }; // Try to both emit a better diagnostic, and avoid further errors by replacing // the `expr` with `ExprKind::Err`. |
