about summary refs log tree commit diff
path: root/compiler/rustc_parse/src/parser/mod.rs
diff options
context:
space:
mode:
authorNicholas Nethercote <n.nethercote@gmail.com>2025-04-03 14:23:49 +1100
committerNicholas Nethercote <n.nethercote@gmail.com>2025-04-08 12:06:40 +1000
commiteb5d8923fce0a025921368d175905c9cab481954 (patch)
tree4f7602f60107e2754ac7001668df6f9d45f5c72f /compiler/rustc_parse/src/parser/mod.rs
parente643f59f6da3a84f43e75dea99afaa5b041ea6bf (diff)
downloadrust-eb5d8923fce0a025921368d175905c9cab481954.tar.gz
rust-eb5d8923fce0a025921368d175905c9cab481954.zip
Allow for missing invisible close delim when reparsing an expression.
This can happen when invalid syntax is passed to a declarative macro. We
shouldn't be too strict about the token stream position once the parser
has rejected the invalid syntax.

Fixes #139248.
Diffstat (limited to 'compiler/rustc_parse/src/parser/mod.rs')
-rw-r--r--compiler/rustc_parse/src/parser/mod.rs7
1 files changed, 6 insertions, 1 deletions
diff --git a/compiler/rustc_parse/src/parser/mod.rs b/compiler/rustc_parse/src/parser/mod.rs
index 3b0861a9942..b277cb804fa 100644
--- a/compiler/rustc_parse/src/parser/mod.rs
+++ b/compiler/rustc_parse/src/parser/mod.rs
@@ -793,7 +793,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