diff options
| author | bors <bors@rust-lang.org> | 2025-04-08 12:05:54 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2025-04-08 12:05:54 +0000 |
| commit | f820b75feef00654924c9351a2faca8d34818339 (patch) | |
| tree | 65b94a18ea2d8b893c79789df06453556793537f /compiler/rustc_parse/src/parser | |
| parent | e5fefc359bec532134013baaabc92560bfb61578 (diff) | |
| parent | 42fdd7deee08cda78283f83e5eb2ce0dd5e995d0 (diff) | |
| download | rust-f820b75feef00654924c9351a2faca8d34818339.tar.gz rust-f820b75feef00654924c9351a2faca8d34818339.zip | |
Auto merge of #139525 - Zalathar:rollup-5t5xsrw, r=Zalathar
Rollup of 10 pull requests Successful merges: - #138676 (Implement overflow for infinite implied lifetime bounds) - #139024 (Make error message for missing fields with `..` and without `..` more consistent) - #139098 (Tell LLVM about impossible niche tags) - #139124 (compiler: report error when trait object type param reference self) - #139321 (Update to new rinja version (askama)) - #139346 (Don't construct preds w escaping bound vars in `diagnostic_hir_wf_check`) - #139386 (make it possible to use stage0 libtest on compiletest) - #139421 (Fix trait upcasting to dyn type with no principal when there are projections) - #139464 (Allow for reparsing failure when reparsing a pasted metavar.) - #139490 (Update some comment/docs related to "extern intrinsic" removal) r? `@ghost` `@rustbot` modify labels: rollup
Diffstat (limited to 'compiler/rustc_parse/src/parser')
| -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 |
