1
Fork 0

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.
This commit is contained in:
Nicholas Nethercote 2025-04-03 14:23:49 +11:00
parent e643f59f6d
commit eb5d8923fc
3 changed files with 53 additions and 1 deletions

View file

@ -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