diff options
| author | Ralf Jung <post@ralfj.de> | 2025-04-10 14:24:19 +0200 |
|---|---|---|
| committer | Ralf Jung <post@ralfj.de> | 2025-04-10 14:24:19 +0200 |
| commit | f69ea4d82fdbf0fefc36118071bb69ec6253a285 (patch) | |
| tree | 351b40fa66750fb4eac0449318a360cf1167efd3 /compiler/rustc_parse/src/parser/mod.rs | |
| parent | 830c58be89e4717ca2c1e08f17d1e027707334e9 (diff) | |
| parent | 7d7de5bf3c3cbf9c2c5bbc5cbfb9197a8a427d35 (diff) | |
| download | rust-f69ea4d82fdbf0fefc36118071bb69ec6253a285.tar.gz rust-f69ea4d82fdbf0fefc36118071bb69ec6253a285.zip | |
Merge from rustc
Diffstat (limited to 'compiler/rustc_parse/src/parser/mod.rs')
| -rw-r--r-- | compiler/rustc_parse/src/parser/mod.rs | 20 |
1 files changed, 16 insertions, 4 deletions
diff --git a/compiler/rustc_parse/src/parser/mod.rs b/compiler/rustc_parse/src/parser/mod.rs index 3b0861a9942..fafd1b1ae00 100644 --- a/compiler/rustc_parse/src/parser/mod.rs +++ b/compiler/rustc_parse/src/parser/mod.rs @@ -782,9 +782,16 @@ impl<'a> Parser<'a> { // Recovery is disabled when parsing macro arguments, so it must // also be disabled when reparsing pasted macro arguments, // otherwise we get inconsistent results (e.g. #137874). - let res = self.with_recovery(Recovery::Forbidden, |this| { - f(this).expect("failed to reparse {mv_kind:?}") - }); + let res = self.with_recovery(Recovery::Forbidden, |this| f(this)); + + let res = match res { + Ok(res) => res, + Err(err) => { + // This can occur in unusual error cases, e.g. #139445. + err.delay_as_bug(); + return None; + } + }; if let token::CloseDelim(delim) = self.token.kind && let Delimiter::Invisible(InvisibleOrigin::MetaVar(mv_kind)) = delim @@ -793,7 +800,12 @@ impl<'a> Parser<'a> { self.bump(); Some(res) } else { - panic!("no close delim when reparsing {mv_kind:?}"); + // This can occur when invalid syntax is passed to a decl macro. E.g. see #139248, + // where the reparse attempt of an invalid expr consumed the trailing invisible + // delimiter. + self.dcx() + .span_delayed_bug(self.token.span, "no close delim with reparsing {mv_kind:?}"); + None } } else { None |
