Code change:
I'm afraid I haven't minimised this test case. This doesn't seem to be a very serious problem as the compiler has correctly pointed out syntax errors; fixing those syntax errors makes the ICE go away. But since it suggested filing a bug I repro'd with today's nightly and have done so. : <!-- Include a backtrace in the code block by setting in your environment. E.g. . --<details<summary<strongBacktrace</strong</summary<p</details<detailsthread 'rustc' panicked at 'Stack should be empty: finalbuf=FrameData { open: 156:12 (), inner: [(Token(Token { kind: BinOp(And), span: 156:13 () }), Alone), (Token(Token { kind: Ident("self", false), span: 156:17 () }), Joint), (Token(Token { kind: Comma, span: 156:18 () }), Alone), (Token(Token { kind: Ident("s", false), span: 156:20 () }), Joint), (Token(Token { kind: Colon, span: 156:21 () }), Alone), (Token(Token { kind: BinOp(And), span: 156:23 () }), Alone), (Token(Token { kind: Ident("dyn", false), span: 156:26 () }), Alone), (Token(Token { kind: Ident("AsRef", false), span: 156:32 () }), Joint), (Token(Token { kind: Lt, span: 156:33 () }), Alone), (Token(Token { kind: Ident("str", false), span: 156:36 () }), Joint), (Token(Token { kind: Gt, span: 156:37 () }), Alone), (Token(Token { kind: RArrow, span: 156:40 () }), Alone), (Token(Token { kind: Ident("String", false), span: 156:47 () }), Alone), (Delimited(DelimSpan { open: 156:49 (), close: 178:4 () }, Brace, TokenStream([(Token(Token { kind: Pound, span: 157:6 () }), Alone), (Delimited(DelimSpan { open: 157:7 (), close: 157:18 () }, Bracket, TokenStream([(Token(Token { kind: Ident("throws", false), span: 157:13 () }), Alone), (Delimited(DelimSpan { open: 157:14 (), close: 157:17 () }, Paren, TokenStream([(Token(Token { kind: Ident("AE", false), span: 157:16 () }), Alone)])), Alone)])), Alone), (Token(Token { kind: Ident("fn", false), span: 158:7 () }), Alone), (Token(Token { kind: Ident("inner", false), span: 158:13 () }), Alone), (Delimited(DelimSpan { open: 158:14 (), close: 178:4 () }, Paren, TokenStream([(Token(Token { kind: Ident("self", false), span: 158:19 () }), Joint), (Token(Token { kind: Colon, span: 158:20 () }), Alone), (Token(Token { kind: BinOp(And), span: 158:22 () }), Alone), (Token(Token { kind: Ident("Self", false), span: 158:26 () }), Joint), (Token(Token { kind: Comma, span: 158:27 () }), Alone), (Token(Token { kind: Ident("s", false), span: 158:29 () }), Joint), (Token(Token { kind: Colon, span: 158:30 () }), Alone), (Token(Token { kind: BinOp(And), span: 158:32 () }), Alone), (Token(Token { kind: Ident("dyn", false), span: 158:35 () }), Alone), (Token(Token { kind: Ident("AsRef", false), span: 158:41 () }), Joint), (Token(Token { kind: Lt, span: 158:42 () }), Alone), (Token(Token { kind: Ident("str", false), span: 158:45 () }), Joint), (Token(Token { kind: Gt, span: 158:46 () }), Alone), (Token(Token { kind: RArrow, span: 158:49 () }), Alone), (Token(Token { kind: Ident("String", false), span: 158:56 () }), Alone), (Delimited(DelimSpan { open: 158:58 (), close: 176:6 () }, Brace, TokenStream([(Token(Token { kind: Ident("let", false), span: 159:10 () }), Alone), (Token(Token { kind: Ident("s", false), span: 159:12 () }), Alone), (Token(Token { kind: Eq, span: 159:14 () }), Alone), (Token(Token { kind: Ident("s", false), span: 159:16 () }), Joint), (Token(Token { kind: Dot, span: 159:17 () }), Alone), (Token(Token { kind: Ident("asref", false), span: 159:23 () }), Alone), (Delimited(DelimSpan { open: 159:24 (), close: 159:25 () }, Paren, TokenStream([])), Alone), (Token(Token { kind: Semi, span: 159:26 () }), Alone), (Token(Token { kind: Ident("let", false), span: 160:10 () }), Alone), (Token(Token { kind: Ident("re", false), span: 160:13 () }), Alone), (Token(Token { kind: Eq, span: 160:15 () }), Alone), (Token(Token { kind: Ident("Regex", false), span: 160:21 () }), Joint), (Token(Token { kind: ModSep, span: 160:23 () }), Alone), (Token(Token { kind: Ident("new", false), span: 160:26 () }), Alone), (Delimited(DelimSpan { open: 160:27 (), close: 160:38 () }, Paren, TokenStream([(Token(Token { kind: Literal(Lit { kind: StrRaw(0), symbol: " suffix: None }), span: 160:37 () }), Alone)])), Alone), (Token(Token { kind: Dot, span: 160:39 () }), Alone), (Token(Token { kind: Ident("expect", false), span: 160:45 () }), Alone), (Delimited(DelimSpan { open: 160:46 (), close: 160:56 () }, Paren, TokenStream([(Token(Token { kind: Literal(Lit { kind: Str, symbol: "bad re!", suffix: None }), span: 160:55 () }), Alone)])), Alone), (Token(Token { kind: Semi, span: 160:57 () }), Alone), (Token(Token { kind: Ident("let", false), span: 161:10 () }), Alone), (Token(Token { kind: Ident("mut", false), span: 161:14 () }), Alone), (Token(Token { kind: Ident("errs", false), span: 161:19 () }), Alone), (Token(Token { kind: Eq, span: 161:21 () }), Alone), (Token(Token { kind: Ident("vec", false), span: 161:25 () }), Joint), (Token(Token { kind: Not, span: 161:26 () }), Alone), (Delimited(DelimSpan { open: 161:27 (), close: 161:28 () }, Bracket, TokenStream([])), Alone), (Token(Token { kind: Semi, span: 161:29 () }), Alone), (Token(Token { kind: Ident("let", false), span: 162:10 () }), Alone), (Token(Token { kind: Ident("out", false), span: 162:14 () }), Alone), (Token(Token { kind: Eq, span: 162:16 () }), Alone), (Token(Token { kind: Ident("re", false), span: 162:19 () }), Joint), (Token(Token { kind: Dot, span: 162:20 () }), Alone), (Token(Token { kind: Ident("replaceall", false), span: 162:31 () }), Alone), (Delimited(DelimSpan { open: 162:32 (), close: 170:9 () }, Paren, TokenStream([(Token(Token { kind: Ident("s", false), span: 162:33 () }), Joint), (Token(Token { kind: Comma, span: 162:34 () }), Alone), (Token(Token { kind: BinOp(Or), span: 162:36 () }), Alone), (Token(Token { kind: Ident("caps", false), span: 162:40 () }), Joint), (Token(Token { kind: Colon, span: 162:41 () }), Alone), (Token(Token { kind: BinOp(And), span: 162:43 () }), Alone), (Token(Token { kind: Ident("regex", false), span: 162:48 () }), Joint), (Token(Token { kind: ModSep, span: 162:50 () }), Alone), (Token(Token { kind: Ident("Captures", false), span: 162:58 () }), Joint), (Token(Token { kind: BinOp(Or), span: 162:59 () }), Alone), (Delimited(DelimSpan { open: 162:61 (), close: 170:8 () }, Brace, TokenStream([(Token(Token { kind: Ident("let", false), span: 163:12 () }), Alone), (Token(Token { kind: Ident("kw", false), span: 163:15 () }), Alone), (Token(Token { kind: Eq, span: 163:17 () }), Alone), (Token(Token { kind: Ident("caps", false), span: 163:22 () }), Joint), (Token(Token { kind: Dot, span: 163:23 () }), Alone), (Token(Token { kind: Ident("get", false), span: 163:26 () }), Alone), (Delimited(DelimSpan { open: 163:27 (), close: 163:29 () }, Paren, TokenStream([(Token(Token { kind: Literal(Lit { kind: Integer, symbol: "1", suffix: None }), span: 163:28 () }), Alone)])), Alone), (Token(Token { kind: Dot, span: 163:30 () }), Alone), (Token(Token { kind: Ident("expect", false), span: 163:36 () }), Alone), (Delimited(DelimSpan { open: 163:37 (), close: 163:51 () }, Paren, TokenStream([(Token(Token { kind: Literal(Lit { kind: Str, symbol: "$1 missing!", suffix: None }), span: 163:50 () }), Alone)])), Alone), (Token(Token { kind: Dot, span: 163:52 () }), Alone), (Token(Token { kind: Ident("asstr", false), span: 163:58 () }), Alone), (Delimited(DelimSpan { open: 163:59 (), close: 163:60 () }, Paren, TokenStream([])), Alone), (Token(Token { kind: Semi, span: 163:61 () }), Alone), (Token(Token { kind: Ident("if", false), span: 164:11 () }), Alone), (Token(Token { kind: Ident("kw", false), span: 164:14 () }), Alone), (Token(Token { kind: EqEq, span: 164:17 () }), Alone), (Token(Token { kind: Literal(Lit { kind: Str, symbol: "", suffix: None }), span: 164:20 () }), Alone), (Delimited(DelimSpan { open: 164:22 (), close: 164:45 () }, Brace, TokenStream([(Token(Token { kind: Ident("return", false), span: 164:29 () }), Alone), (Token(Token { kind: Literal(Lit { kind: Str, symbol: "", suffix: None }), span: 164:32 () }), Joint), (Token(Token { kind: Dot, span: 164:33 () }), Alone), (Token(Token { kind: Ident("toowned", false), span: 164:41 () }), Alone), (Delimited(DelimSpan { open: 164:42 (), close: 164:43 () }, Paren, TokenStream([])), Alone)])), Alone), (Token(Token { kind: Ident("let", false), span: 165:12 () }), Alone), (Token(Token { kind: Ident("v", false), span: 165:14 () }), Alone), (Token(Token { kind: Eq, span: 165:16 () }), Alone), (Token(Token { kind: Ident("self", false), span: 165:21 () }), Joint), (Token(Token { kind: Dot, span: 165:22 () }), Alone), (Token(Token { kind: Ident("get", false), span: 165:25 () }), Alone), (Delimited(DelimSpan { open: 165:26 (), close: 165:29 () }, Paren, TokenStream([(Token(Token { kind: Ident("kw", false), span: 165:28 () }), Alone)])), Alone), (Token(Token { kind: Semi, span: 165:30 () }), Alone), (Token(Token { kind: Ident("v", false), span: 166:10 () }), Joint), (Token(Token { kind: Dot, span: 166:11 () }), Alone), (Token(Token { kind: Ident("unwraporelse", false), span: 166:25 () }), Alone), (Delimited(DelimSpan { open: 166:26 (), close: 169:11 () }, Paren, TokenStream([(Token(Token { kind: OrOr, span: 166:28 () }), Alone), (Delimited(DelimSpan { open: 166:29 (), close: 169:10 () }, Brace, TokenStream([(Token(Token { kind: Ident("errs", false), span: 167:15 () }), Joint), (Token(Token { kind: Dot, span: 167:16 () }), Alone), (Token(Token { kind: Ident("push", false), span: 167:20 () }), Alone), (Delimited(DelimSpan { open: 167:21 (), close: 167:35 () }, Paren, TokenStream([(Token(Token { kind: Ident("kw", false), span: 167:23 () }), Joint), (Token(Token { kind: Dot, span: 167:24 () }), Alone), (Token(Token { kind: Ident("toowned", false), span: 167:32 () }), Alone), (Delimited(DelimSpan { open: 167:33 (), close: 167:34 () }, Paren, TokenStream([])), Alone)])), Alone), (Token(Token { kind: Semi, span: 167:36 () }), Alone), (Token(Token { kind: Literal(Lit { kind: Str, symbol: "", suffix: None }), span: 168:13 () }), Joint), (Token(Token { kind: Dot, span: 168:14 () }), Alone), (Token(Token { kind: Ident("toowned", false), span: 168:22 () }), Alone), (Delimited(DelimSpan { open: 168:23 (), close: 168:24 () }, Paren, TokenStream([])), Alone)])), Alone)])), Alone)])), Alone)])), Alone), (Token(Token { kind: Semi, span: 170:10 () }), Alone), (Token(Token { kind: Ident("if", false), span: 171:9 () }), Alone), (Token(Token { kind: Not, span: 171:11 () }), Alone), (Token(Token { kind: Ident("errs", false), span: 171:16 () }), Joint), (Token(Token { kind: Dot, span: 171:17 () }), Alone), (Token(Token { kind: Ident("isempty", false), span: 171:25 () }), Alone), (Delimited(DelimSpan { open: 171:26 (), close: 171:27 () }, Paren, TokenStream([])), Alone), (Delimited(DelimSpan { open: 171:29 (), close: 174:8 () }, Brace, TokenStream([(Token(Token { kind: Ident("throw", false), span: 172:14 () }), Joint), (Token(Token { kind: Not, span: 172:15 () }), Alone), (Delimited(DelimSpan { open: 172:16 (), close: 173:34 () }, Paren, TokenStream([(Token(Token { kind: Ident("anyhow", false), span: 172:22 () }), Joint), (Token(Token { kind: Not, span: 172:23 () }), Alone), (Delimited(DelimSpan { open: 172:24 (), close: 173:33 () }, Paren, TokenStream([(Token(Token { kind: Literal(Lit { kind: Str, symbol: "bad substitution(s) {:?} in {:?}", suffix: None }), span: 172:58 () }), Joint), (Token(Token { kind: Comma, span: 172:59 () }), Alone), (Token(Token { kind: BinOp(And), span: 173:25 () }), Alone), (Token(Token { kind: Ident("errs", false), span: 173:29 () }), Joint), (Token(Token { kind: Comma, span: 173:30 () }), Alone), (Token(Token { kind: Ident("s", false), span: 173:32 () }), Alone)])), Alone)])), Alone), (Token(Token { kind: Semi, span: 173:35 () }), Alone)])), Alone), (Token(Token { kind: Ident("out", false), span: 175:10 () }), Joint), (Token(Token { kind: Dot, span: 175:11 () }), Alone), (Token(Token { kind: Ident("into", false), span: 175:15 () }), Alone), (Delimited(DelimSpan { open: 175:16 (), close: 175:17 () }, Paren, TokenStream([])), Alone)])), Alone), (Token(Token { kind: Ident("inner", false), span: 177:10 () }), Alone), (Delimited(DelimSpan { open: 177:11 (), close: 177:19 () }, Paren, TokenStream([(Token(Token { kind: Ident("self", false), span: 177:15 () }), Joint), (Token(Token { kind: Comma, span: 177:16 () }), Alone), (Token(Token { kind: Ident("s", false), span: 177:18 () }), Alone)])), Alone), (Token(Token { kind: Question, span: 177:20 () }), Alone)])), Alone)])), Alone)] } stack=[FrameData { open: 1:1 (), inner: [(Token(Token { kind: Ident("fn", false), span: 156:5 () }), Alone), (Token(Token { kind: Ident("subst", false), span: 156:11 () }), Alone)] }]', </details
Minimized: proc macro
modify labels -E-needs-mcve +A-proc-macros
Is the solution possibly to just remove the offending assertion? The token stream will be nonsense but some other error reporting should catch the mismatched delimiters, I'd assume?
I just quickly tried the suggestion above (removing the assertion) and this is the error I got without it: Note that I tried a slightly simpler version of the small repro above: This still fails with ICE with the assertion.
I think I'm seeing the same issue with code containing a similar syntax error: The error is the fn does not have the closing paren. I see this on both release and debug builds: stable: beta: Nightly: Here is the error and stack from Rust Playground:

Related discussion:
text: <ins> macro_rules! values { ($($token:ident($value:literal) $(as $inner:ty)? => $attr:meta,)*) => { #[derive(Debug)] pub enum TokenKind { $( #[$attr] $token $($inner)? = $value, )* } }; } //~^^^^^ ERROR expected one of `(`, `,`, `=`, `{`, or `}`, found `(String)` //~| ERROR macro expansion ignores token `(String)` and any following values!(STRING(1) as (String) => cfg(test),); //~^ ERROR expected one of `!` or `::`, found `<eof>` fn main() {} </ins>