diff options
| author | bors <bors@rust-lang.org> | 2024-02-29 19:19:46 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2024-02-29 19:19:46 +0000 |
| commit | 14e162861b163f30e01d644e0bfcddec7662660e (patch) | |
| tree | 9b4dc4abf2f13465e24829965576024492613f4b /compiler/rustc_parse/src/parser/expr.rs | |
| parent | 5717e52d173f2cc9919900d0013e0e3eeb4afa2c (diff) | |
| parent | 2a376ceb8dc0aaef39b43eada02b9c94e0d51656 (diff) | |
| download | rust-14e162861b163f30e01d644e0bfcddec7662660e.tar.gz rust-14e162861b163f30e01d644e0bfcddec7662660e.zip | |
Auto merge of #3336 - RalfJung:rustup, r=RalfJung
Rustup Also add regression test for https://github.com/rust-lang/rust/issues/121508.
Diffstat (limited to 'compiler/rustc_parse/src/parser/expr.rs')
| -rw-r--r-- | compiler/rustc_parse/src/parser/expr.rs | 29 |
1 files changed, 15 insertions, 14 deletions
diff --git a/compiler/rustc_parse/src/parser/expr.rs b/compiler/rustc_parse/src/parser/expr.rs index f5a7bfd42ff..316a9c4f8df 100644 --- a/compiler/rustc_parse/src/parser/expr.rs +++ b/compiler/rustc_parse/src/parser/expr.rs @@ -1762,24 +1762,25 @@ impl<'a> Parser<'a> { err: impl FnOnce(&Self) -> Diag<'a>, ) -> L { assert!(could_be_unclosed_char_literal(ident)); - if let Some(diag) = self.dcx().steal_diagnostic(ident.span, StashKey::LifetimeIsChar) { - diag.with_span_suggestion_verbose( - ident.span.shrink_to_hi(), - "add `'` to close the char literal", - "'", - Applicability::MaybeIncorrect, - ) - .emit(); - } else { - err(self) - .with_span_suggestion_verbose( + self.dcx() + .try_steal_modify_and_emit_err(ident.span, StashKey::LifetimeIsChar, |err| { + err.span_suggestion_verbose( ident.span.shrink_to_hi(), "add `'` to close the char literal", "'", Applicability::MaybeIncorrect, - ) - .emit(); - } + ); + }) + .unwrap_or_else(|| { + err(self) + .with_span_suggestion_verbose( + ident.span.shrink_to_hi(), + "add `'` to close the char literal", + "'", + Applicability::MaybeIncorrect, + ) + .emit() + }); let name = ident.without_first_quote().name; mk_lit_char(name, ident.span) } |
