File tree Expand file tree Collapse file tree 3 files changed +51
-1
lines changed
compiler/rustc_parse/src/parser Expand file tree Collapse file tree 3 files changed +51
-1
lines changed Original file line number Diff line number Diff line change @@ -793,7 +793,10 @@ impl<'a> Parser<'a> {
793793 self . bump ( ) ;
794794 Some ( res)
795795 } else {
796- panic ! ( "no close delim when reparsing {mv_kind:?}" ) ;
796+ // This can occur when invalid syntax is passed to a decl macro. E.g. see #139248,
797+ // where the reparse attempt of an invalid expr consumed the trailing invisible
798+ // delimiter.
799+ None
797800 }
798801 } else {
799802 None
Original file line number Diff line number Diff line change 1+ // This code caused a "no close delim when reparsing Expr" ICE in #139248.
2+
3+ macro_rules! m {
4+ ( static a : ( ) = $e: expr) => {
5+ static a : ( ) = $e;
6+ //~^ ERROR macro expansion ends with an incomplete expression: expected expression
7+ }
8+ }
9+
10+ m ! { static a : ( ) = ( if b) }
11+ //~^ error: expected `{`, found `)`
12+ //~| error: expected `{`, found `)`
13+
14+ fn main ( ) { }
Original file line number Diff line number Diff line change 1+ error: expected `{`, found `)`
2+ --> $DIR/no-close-delim-issue-139248.rs:10:27
3+ |
4+ LL | m! { static a : () = (if b) }
5+ | ^ expected `{`
6+ |
7+ note: the `if` expression is missing a block after this condition
8+ --> $DIR/no-close-delim-issue-139248.rs:10:26
9+ |
10+ LL | m! { static a : () = (if b) }
11+ | ^
12+
13+ error: expected `{`, found `)`
14+ --> $DIR/no-close-delim-issue-139248.rs:10:27
15+ |
16+ LL | m! { static a : () = (if b) }
17+ | ^ expected `{`
18+ |
19+ note: the `if` expression is missing a block after this condition
20+ --> $DIR/no-close-delim-issue-139248.rs:10:26
21+ |
22+ LL | m! { static a : () = (if b) }
23+ | ^
24+ = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
25+
26+ error: macro expansion ends with an incomplete expression: expected expression
27+ --> $DIR/no-close-delim-issue-139248.rs:5:28
28+ |
29+ LL | static a : () = $e;
30+ | ^ expected expression
31+
32+ error: aborting due to 3 previous errors
33+
You can’t perform that action at this time.
0 commit comments