Question:
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:

// the location of `#[cfg]` and `#[cfg_attr]` in the token stream. The tokenization // process is lossless, so this process is invisible to proc-macros. <del> let parse_annotatable_with: fn(&mut Parser<'_>) -> _ = match annotatable { Annotatable::Item(_) => { |parser| Annotatable::Item(parser.parse_item(ForceCollect::Yes).unwrap().unwrap()) } Annotatable::TraitItem(_) => |parser| { Annotatable::TraitItem( parser.parse_trait_item(ForceCollect::Yes).unwrap().unwrap().unwrap(), ) }, Annotatable::ImplItem(_) => |parser| { Annotatable::ImplItem( parser.parse_impl_item(ForceCollect::Yes).unwrap().unwrap().unwrap(), ) }, Annotatable::ForeignItem(_) => |parser| { Annotatable::ForeignItem( parser.parse_foreign_item(ForceCollect::Yes).unwrap().unwrap().unwrap(), ) }, Annotatable::Stmt(_) => |parser| { Annotatable::Stmt(P(parser.parse_stmt(ForceCollect::Yes).unwrap().unwrap())) }, Annotatable::Expr(_) => { |parser| Annotatable::Expr(parser.parse_expr_force_collect().unwrap()) } _ => unreachable!(), }; </del> <ins> let parse_annotatable_with: for<'a> fn(&mut Parser<'a>) -> PResult<'a, _> = match annotatable { Annotatable::Item(_) => { |parser| Ok(Annotatable::Item(parser.parse_item(ForceCollect::Yes)?.unwrap())) } Annotatable::TraitItem(_) => |parser| { Ok(Annotatable::TraitItem( parser.parse_trait_item(ForceCollect::Yes)?.unwrap().unwrap(), )) }, Annotatable::ImplItem(_) => |parser| { Ok(Annotatable::ImplItem( parser.parse_impl_item(ForceCollect::Yes)?.unwrap().unwrap(), )) }, Annotatable::ForeignItem(_) => |parser| { Ok(Annotatable::ForeignItem( parser.parse_foreign_item(ForceCollect::Yes)?.unwrap().unwrap(), )) }, Annotatable::Stmt(_) => |parser| { Ok(Annotatable::Stmt(P(parser.parse_stmt(ForceCollect::Yes)?.unwrap()))) }, Annotatable::Expr(_) => { |parser| Ok(Annotatable::Expr(parser.parse_expr_force_collect()?)) } _ => unreachable!(), }; </ins> // 'Flatten' all nonterminals (i.e. `TokenKind::Interpolated`) // to `None`-delimited groups containing the corresponding tokens. This


Question:
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:

let mut parser = rustc_parse::stream_to_parser(&self.cfg.sess.parse_sess, orig_tokens, None); parser.capture_cfg = true; <del> annotatable = parse_annotatable_with(&mut parser); </del> <ins> match parse_annotatable_with(&mut parser) { Ok(a) => annotatable = a, Err(mut err) => { err.emit(); return Some(annotatable); } } </ins> // Now that we have our re-parsed `AttrTokenStream`, recursively configuring // our attribute target will correctly the tokens as well.


Question:
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:

panic!("Unexpected last token {:?}", last_token) } } <del> assert!(stack.is_empty(), "Stack should be empty: final_buf={:?} stack={:?}", final_buf, stack); </del> AttrTokenStream::new(final_buf.inner) }


Question:
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:

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


Question:
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:

<ins> error: expected one of `(`, `,`, `=`, `{`, or `}`, found `(String)` --> $DIR/syntax-error-recovery.rs:7:26 | LL |                 $token $($inner)? = $value, |                          ^^^^^^ expected one of `(`, `,`, `=`, `{`, or `}` ... LL | values!(STRING(1) as (String) => cfg(test),); | -------------------------------------------- in this macro invocation | = note: this error originates in the macro `values` (in Nightly builds, run with -Z macro-backtrace for more info) error: macro expansion ignores token `(String)` and any following --> $DIR/syntax-error-recovery.rs:7:26 | LL |                 $token $($inner)? = $value, |                          ^^^^^^ ... LL | values!(STRING(1) as (String) => cfg(test),); | -------------------------------------------- caused by the macro expansion here | = note: the usage of `values!` is likely invalid in item context error: expected one of `!` or `::`, found `<eof>` --> $DIR/syntax-error-recovery.rs:15:9 | LL | values!(STRING(1) as (String) => cfg(test),); |         ^^^^^^ expected one of `!` or `::` error: aborting due to 3 previous errors </ins>


Question:
Repro: As of current nightly: This is the unreachable line: The same crash reproduces back to 1.47.0. Older stable compilers do not crash:
Bisect: searched nightlies: from nightly-2020-07-10 to nightly-2020-08-27 regressed nightly: nightly-2020-07-22 searched commits: from to regressed commit: () Mentioning because appears the most relevant.
Assigning .

Some(Node::Item(it)) => item_scope_tag(&it), Some(Node::TraitItem(it)) => trait_item_scope_tag(&it), Some(Node::ImplItem(it)) => impl_item_scope_tag(&it), <ins> Some(Node::ForeignItem(it)) => foreign_item_scope_tag(&it), </ins> _ => unreachable!(), }; let (prefix, span) = match *region {


Question:
Repro: As of current nightly: This is the unreachable line: The same crash reproduces back to 1.47.0. Older stable compilers do not crash:
Bisect: searched nightlies: from nightly-2020-07-10 to nightly-2020-08-27 regressed nightly: nightly-2020-07-22 searched commits: from to regressed commit: () Mentioning because appears the most relevant.
Assigning .

} } <ins> fn foreign_item_scope_tag(item: &hir::ForeignItem<'_>) -> &'static str { match item.kind { hir::ForeignItemKind::Fn(..) => "method body", hir::ForeignItemKind::Static(..) | hir::ForeignItemKind::Type => "associated item", } } </ins> fn explain_span(tcx: TyCtxt<'tcx>, heading: &str, span: Span) -> (String, Option<Span>) { let lo = tcx.sess.source_map().lookup_char_pos(span.lo()); (format!("the {} at {}:{}", heading, lo.line, lo.col.to_usize() + 1), Some(span))


Question:
Repro: As of current nightly: This is the unreachable line: The same crash reproduces back to 1.47.0. Older stable compilers do not crash:
Bisect: searched nightlies: from nightly-2020-07-10 to nightly-2020-08-27 regressed nightly: nightly-2020-07-22 searched commits: from to regressed commit: () Mentioning because appears the most relevant.
Assigning .

let fcx = FnCtxt::new(&inh, param_env, id); if !inh.tcx.features().trivial_bounds { // As predicates are cached rather than obligations, this <del> // needsto be called first so that they are checked with an </del> <ins> // needs to be called first so that they are checked with an </ins> // empty `param_env`. check_false_global_bounds(&fcx, span, id); }


Question:
Repro: As of current nightly: This is the unreachable line: The same crash reproduces back to 1.47.0. Older stable compilers do not crash:
Bisect: searched nightlies: from nightly-2020-07-10 to nightly-2020-08-27 regressed nightly: nightly-2020-07-22 searched commits: from to regressed commit: () Mentioning because appears the most relevant.
Assigning .

<ins> // Regression test for #80468. #![crate_type = "lib"] pub trait Trait {} #[repr(transparent)] pub struct Wrapper<T: Trait>(T); #[repr(transparent)] pub struct Ref<'a>(&'a u8); impl Trait for Ref {} //~ ERROR:  implicit elided lifetime not allowed here extern "C" { pub fn repro(_: Wrapper<Ref>); //~ ERROR: mismatched types } </ins>


Question:
Repro: As of current nightly: This is the unreachable line: The same crash reproduces back to 1.47.0. Older stable compilers do not crash:
Bisect: searched nightlies: from nightly-2020-07-10 to nightly-2020-08-27 regressed nightly: nightly-2020-07-22 searched commits: from to regressed commit: () Mentioning because appears the most relevant.
Assigning .

<ins> error[E0726]: implicit elided lifetime not allowed here --> $DIR/wf-in-foreign-fn-decls-issue-80468.rs:13:16 | LL | impl Trait for Ref {} |                ^^^- help: indicate the anonymous lifetime: `<'_>` error[E0308]: mismatched types --> $DIR/wf-in-foreign-fn-decls-issue-80468.rs:16:21 | LL |     pub fn repro(_: Wrapper<Ref>); |                     ^^^^^^^^^^^^ lifetime mismatch | = note: expected trait `Trait` found trait `Trait` note: the anonymous lifetime #1 defined on the method body at 16:5... --> $DIR/wf-in-foreign-fn-decls-issue-80468.rs:16:5 | LL |     pub fn repro(_: Wrapper<Ref>); |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ = note: ...does not necessarily outlive the static lifetime error: aborting due to 2 previous errors For more information about this error, try `rustc --explain E0308`. </ins>


Question:
When you write a mod with a capital name of a keyword, we suggest changing it to the lowercase version of the keyword, which is, well, a keyword and not going to work. We should suggest converting the identifier to snake case and making it a raw identifier, or maybe suggest switching to an altogether separate name? <!-- TRIAGEBOTSTART --<!-- TRIAGEBOTASSIGNSTART --<!-- TRIAGEBOTASSIGNDATASTARTTRIAGEBOTASSIGNDATAEND --<!-- TRIAGEBOTASSIGNEND --<!-- TRIAGEBOTEND --
Hey you might want to comment here to claim this issue :)
claim

// We have a valid span in almost all cases, but we don't have one when linting a crate // name provided via the command line. if !ident.span.is_dummy() { <ins> let sc_ident = Ident::from_str_and_span(&sc, ident.span); let (message, suggestion) = if sc_ident.is_reserved() { // We shouldn't suggest a reserved identifier to fix non-snake-case identifiers. // Instead, recommend renaming the identifier entirely or, if permitted, // escaping it to create a raw identifier. if sc_ident.name.can_be_raw() { ("rename the identifier or convert it to a snake case raw identifier", sc_ident.to_string()) } else { err.note(&format!("`{}` cannot be used as a raw identifier", sc)); ("rename the identifier", String::new()) } } else { ("convert the identifier to snake case", sc) }; </ins> err.span_suggestion( ident.span, <del> "convert the identifier to snake case", sc, </del> <ins> message, suggestion, </ins> Applicability::MaybeIncorrect, ); } else {


Question:
When you write a mod with a capital name of a keyword, we suggest changing it to the lowercase version of the keyword, which is, well, a keyword and not going to work. We should suggest converting the identifier to snake case and making it a raw identifier, or maybe suggest switching to an altogether separate name? <!-- TRIAGEBOTSTART --<!-- TRIAGEBOTASSIGNSTART --<!-- TRIAGEBOTASSIGNDATASTARTTRIAGEBOTASSIGNDATAEND --<!-- TRIAGEBOTASSIGNEND --<!-- TRIAGEBOTEND --
Hey you might want to comment here to claim this issue :)
claim

<ins> #![warn(unused)] #![allow(dead_code)] #![deny(non_snake_case)] mod Impl {} //~^ ERROR module `Impl` should have a snake case name fn While() {} //~^ ERROR function `While` should have a snake case name fn main() { let Mod: usize = 0; //~^ ERROR variable `Mod` should have a snake case name //~^^ WARN unused variable: `Mod` let Super: usize = 0; //~^ ERROR variable `Super` should have a snake case name //~^^ WARN unused variable: `Super` } </ins>


Question:
When you write a mod with a capital name of a keyword, we suggest changing it to the lowercase version of the keyword, which is, well, a keyword and not going to work. We should suggest converting the identifier to snake case and making it a raw identifier, or maybe suggest switching to an altogether separate name? <!-- TRIAGEBOTSTART --<!-- TRIAGEBOTASSIGNSTART --<!-- TRIAGEBOTASSIGNDATASTARTTRIAGEBOTASSIGNDATAEND --<!-- TRIAGEBOTASSIGNEND --<!-- TRIAGEBOTEND --
Hey you might want to comment here to claim this issue :)
claim

<ins> warning: unused variable: `Mod` --> $DIR/lint-non-snake-case-identifiers-suggestion-reserved.rs:12:9 | LL |     let Mod: usize = 0; |         ^^^ help: if this is intentional, prefix it with an underscore: `_Mod` | note: the lint level is defined here --> $DIR/lint-non-snake-case-identifiers-suggestion-reserved.rs:1:9 | LL | #![warn(unused)] |         ^^^^^^ = note: `#[warn(unused_variables)]` implied by `#[warn(unused)]` warning: unused variable: `Super` --> $DIR/lint-non-snake-case-identifiers-suggestion-reserved.rs:16:9 | LL |     let Super: usize = 0; |         ^^^^^ help: if this is intentional, prefix it with an underscore: `_Super` error: module `Impl` should have a snake case name --> $DIR/lint-non-snake-case-identifiers-suggestion-reserved.rs:5:5 | LL | mod Impl {} |     ^^^^ | note: the lint level is defined here --> $DIR/lint-non-snake-case-identifiers-suggestion-reserved.rs:3:9 | LL | #![deny(non_snake_case)] |         ^^^^^^^^^^^^^^ help: rename the identifier or convert it to a snake case raw identifier | LL | mod r#impl {} |     ^^^^^^ error: function `While` should have a snake case name --> $DIR/lint-non-snake-case-identifiers-suggestion-reserved.rs:8:4 | LL | fn While() {} |    ^^^^^ | help: rename the identifier or convert it to a snake case raw identifier | LL | fn r#while() {} |    ^^^^^^^ error: variable `Mod` should have a snake case name --> $DIR/lint-non-snake-case-identifiers-suggestion-reserved.rs:12:9 | LL |     let Mod: usize = 0; |         ^^^ | help: rename the identifier or convert it to a snake case raw identifier | LL |     let r#mod: usize = 0; |         ^^^^^ error: variable `Super` should have a snake case name --> $DIR/lint-non-snake-case-identifiers-suggestion-reserved.rs:16:9 | LL |     let Super: usize = 0; |         ^^^^^ help: rename the identifier | = note: `super` cannot be used as a raw identifier error: aborting due to 4 previous errors; 2 warnings emitted </ins>


Question:
<!-- If you're using the stable version of the compiler, you should also check if the bug also exists in the beta or nightly versions. --: Note: Same error on stable and beta. <!-- Include a backtrace in the code block by setting in your environment. E.g. . --<details<summary<strongBacktrace</strong</summary<p</p</details
this works for me on latest nightly. If you update your version of the compiler, does it work for you?
Oh oops, I was missing , sorry:
Slightly smaller: If you change to , it works, so I think this is while trying to infer .
glacier ""
This issue has been fixed by , marking as .

<ins> // Regression test for #75883. pub struct UI {} impl UI { pub fn run() -> Result<_> { //~^ ERROR: this enum takes 2 type arguments but only 1 type argument was supplied //~| ERROR: the type placeholder `_` is not allowed within types on item signatures let mut ui = UI {}; ui.interact(); unimplemented!(); } pub fn interact(&mut self) -> Result<_> { //~^ ERROR: this enum takes 2 type arguments but only 1 type argument was supplied //~| ERROR: the type placeholder `_` is not allowed within types on item signatures unimplemented!(); } } fn main() {} </ins>


Question:
<!-- If you're using the stable version of the compiler, you should also check if the bug also exists in the beta or nightly versions. --: Note: Same error on stable and beta. <!-- Include a backtrace in the code block by setting in your environment. E.g. . --<details<summary<strongBacktrace</strong</summary<p</p</details
this works for me on latest nightly. If you update your version of the compiler, does it work for you?
Oh oops, I was missing , sorry:
Slightly smaller: If you change to , it works, so I think this is while trying to infer .
glacier ""
This issue has been fixed by , marking as .

<ins> error[E0107]: this enum takes 2 type arguments but only 1 type argument was supplied --> $DIR/issue-75883.rs:6:21 | LL |     pub fn run() -> Result<_> { |                     ^^^^^^ - supplied 1 type argument |                     | |                     expected 2 type arguments | note: enum defined here, with 2 type parameters: `T`, `E` --> $SRC_DIR/core/src/result.rs:LL:COL | LL | pub enum Result<T, E> { |          ^^^^^^ -  - help: add missing type argument | LL |     pub fn run() -> Result<_, E> { |                             ^^^ error[E0107]: this enum takes 2 type arguments but only 1 type argument was supplied --> $DIR/issue-75883.rs:15:35 | LL |     pub fn interact(&mut self) -> Result<_> { |                                   ^^^^^^ - supplied 1 type argument |                                   | |                                   expected 2 type arguments | note: enum defined here, with 2 type parameters: `T`, `E` --> $SRC_DIR/core/src/result.rs:LL:COL | LL | pub enum Result<T, E> { |          ^^^^^^ -  - help: add missing type argument | LL |     pub fn interact(&mut self) -> Result<_, E> { |                                           ^^^ error[E0121]: the type placeholder `_` is not allowed within types on item signatures --> $DIR/issue-75883.rs:15:42 | LL |     pub fn interact(&mut self) -> Result<_> { |                                          ^ not allowed in type signatures error[E0121]: the type placeholder `_` is not allowed within types on item signatures --> $DIR/issue-75883.rs:6:28 | LL |     pub fn run() -> Result<_> { |                            ^ not allowed in type signatures error: aborting due to 4 previous errors Some errors have detailed explanations: E0107, E0121. For more information about an error, try `rustc --explain E0107`. </ins>


Question:
<!-- If you're using the stable version of the compiler, you should also check if the bug also exists in the beta or nightly versions. --: Note: Same error on stable and beta. <!-- Include a backtrace in the code block by setting in your environment. E.g. . --<details<summary<strongBacktrace</strong</summary<p</p</details
this works for me on latest nightly. If you update your version of the compiler, does it work for you?
Oh oops, I was missing , sorry:
Slightly smaller: If you change to , it works, so I think this is while trying to infer .
glacier ""
This issue has been fixed by , marking as .

<ins> // Regression test for #80779. pub struct T<'a>(&'a str); pub fn f<'a>(val: T<'a>) -> _ { //~^ ERROR: the type placeholder `_` is not allowed within types on item signatures g(val) } pub fn g(_: T<'static>) -> _ {} //~^ ERROR: the type placeholder `_` is not allowed within types on item signatures fn main() {} </ins>


Question:
<!-- If you're using the stable version of the compiler, you should also check if the bug also exists in the beta or nightly versions. --: Note: Same error on stable and beta. <!-- Include a backtrace in the code block by setting in your environment. E.g. . --<details<summary<strongBacktrace</strong</summary<p</p</details
this works for me on latest nightly. If you update your version of the compiler, does it work for you?
Oh oops, I was missing , sorry:
Slightly smaller: If you change to , it works, so I think this is while trying to infer .
glacier ""
This issue has been fixed by , marking as .

<ins> error[E0121]: the type placeholder `_` is not allowed within types on item signatures --> $DIR/issue-80779.rs:10:28 | LL | pub fn g(_: T<'static>) -> _ {} |                            ^ |                            | |                            not allowed in type signatures |                            help: replace with the correct return type: `()` error[E0121]: the type placeholder `_` is not allowed within types on item signatures --> $DIR/issue-80779.rs:5:29 | LL | pub fn f<'a>(val: T<'a>) -> _ { |                             ^ |                             | |                             not allowed in type signatures |                             help: replace with the correct return type: `()` error: aborting due to 2 previous errors For more information about this error, try `rustc --explain E0121`. </ins>


Question:
As it is currently written, E0207 talks entirely about type parameters. Now that const parameters also need to constrain implementations (under the same rules described for types), they also need to be mentioned in the error explanation. Since other items don't require const parameters to be used at all, we might also want to specifically call out this difference here. Furthermore, E0207 triggers if you use an unconstrained lifetime in an associated type, and this is completely unspecified by the error as well. <!-- TRIAGEBOTSTART --<!-- TRIAGEBOTASSIGNSTART --<!-- TRIAGEBOTASSIGNDATASTARTTRIAGEBOTASSIGNDATAEND --<!-- TRIAGEBOTASSIGNEND --<!-- TRIAGEBOTEND --
claim

<del> A type parameter that is specified for `impl` is not constrained. </del> <ins> A type, const or lifetime parameter that is specified for `impl` is not constrained. </ins> Erroneous code example:


Question:
As it is currently written, E0207 talks entirely about type parameters. Now that const parameters also need to constrain implementations (under the same rules described for types), they also need to be mentioned in the error explanation. Since other items don't require const parameters to be used at all, we might also want to specifically call out this difference here. Furthermore, E0207 triggers if you use an unconstrained lifetime in an associated type, and this is completely unspecified by the error as well. <!-- TRIAGEBOTSTART --<!-- TRIAGEBOTASSIGNSTART --<!-- TRIAGEBOTASSIGNDATASTARTTRIAGEBOTASSIGNDATAEND --<!-- TRIAGEBOTASSIGNEND --<!-- TRIAGEBOTEND --
claim

} ``` <del> Any type parameter of an `impl` must meet at least one of the following criteria: </del> <ins> Any type or const parameter of an `impl` must meet at least one of the following criteria: </ins> - it appears in the _implementing type_ of the impl, e.g. `impl<T> Foo<T>` - for a trait impl, it appears in the _implemented trait_, e.g.


Question:
As it is currently written, E0207 talks entirely about type parameters. Now that const parameters also need to constrain implementations (under the same rules described for types), they also need to be mentioned in the error explanation. Since other items don't require const parameters to be used at all, we might also want to specifically call out this difference here. Furthermore, E0207 triggers if you use an unconstrained lifetime in an associated type, and this is completely unspecified by the error as well. <!-- TRIAGEBOTSTART --<!-- TRIAGEBOTASSIGNSTART --<!-- TRIAGEBOTASSIGNDATASTARTTRIAGEBOTASSIGNDATAEND --<!-- TRIAGEBOTASSIGNEND --<!-- TRIAGEBOTEND --
claim

- it is bound as an associated type, e.g. `impl<T, U> SomeTrait for T where T: AnotherTrait<AssocType=U>` <ins> Any unconstrained lifetime parameter of an `impl` is not supported if the lifetime parameter is used by an associated type. </ins> ### Error example 1 Suppose we have a struct `Foo` and we would like to define some methods for it.


Question:
As it is currently written, E0207 talks entirely about type parameters. Now that const parameters also need to constrain implementations (under the same rules described for types), they also need to be mentioned in the error explanation. Since other items don't require const parameters to be used at all, we might also want to specifically call out this difference here. Furthermore, E0207 triggers if you use an unconstrained lifetime in an associated type, and this is completely unspecified by the error as well. <!-- TRIAGEBOTSTART --<!-- TRIAGEBOTASSIGNSTART --<!-- TRIAGEBOTASSIGNDATASTARTTRIAGEBOTASSIGNDATAEND --<!-- TRIAGEBOTASSIGNEND --<!-- TRIAGEBOTEND --
claim

(`Foo`) of the impl. In this case, we can fix the error by moving the type parameter from the `impl` to the method `get`: ``` struct Foo;


Question:
As it is currently written, E0207 talks entirely about type parameters. Now that const parameters also need to constrain implementations (under the same rules described for types), they also need to be mentioned in the error explanation. Since other items don't require const parameters to be used at all, we might also want to specifically call out this difference here. Furthermore, E0207 triggers if you use an unconstrained lifetime in an associated type, and this is completely unspecified by the error as well. <!-- TRIAGEBOTSTART --<!-- TRIAGEBOTASSIGNSTART --<!-- TRIAGEBOTASSIGNDATASTARTTRIAGEBOTASSIGNDATAEND --<!-- TRIAGEBOTASSIGNEND --<!-- TRIAGEBOTEND --
claim

} ``` <ins> ### Error example 3 Suppose we have a struct `Foo` and we would like to define some methods for it. The following code example has a definition which leads to a compiler error: ```compile_fail,E0207 struct Foo; impl<const T: i32> Foo { // error: the const parameter `T` is not constrained by the impl trait, self // type, or predicates [E0207] fn get(&self) -> i32 { i32::default() } } ``` The problem is that the const parameter `T` does not appear in the implementing type (`Foo`) of the impl. In this case, we can fix the error by moving the type parameter from the `impl` to the method `get`: ``` struct Foo; // Move the const parameter from the impl to the method impl Foo { fn get<const T: i32>(&self) -> i32 { i32::default() } } ``` ### Error example 4 Suppose we have a struct `Foo` and a struct `Bar` that uses lifetime `'a`. We would like to implement trait `Contains` for `Foo`. The trait `Contains` have the associated type `B`. The following code example has a definition which leads to a compiler error: ```compile_fail,E0207 struct Foo; struct Bar<'a>; trait Contains { type B; fn get(&self) -> i32; } impl<'a> Contains for Foo { type B = Bar<'a>; // error: the lifetime parameter `'a` is not constrained by the impl trait, // self type, or predicates [E0207] fn get(&self) -> i32 { i32::default() } } ``` Please note that unconstrained lifetime parameters are not supported if they are being used by an associated type. </ins> ### Additional information For more information, please see [RFC 447].


Question:
The following code errors, and the error contains a suggestion how to fix the error: The error message states: Obviously, writing is invalid syntax.
It seems the issue is that it's inserting the suggestion after the trait name and before the generics, rather than after the generics.
No-nightly-features code that exhibits the same problem: label -requires-nightly (should the F-labels go as well?)

); } else { // Trivial case: `T` needs an extra bound: `T: Bound`. <del> let (sp, suggestion) = match super_traits { None => predicate_constraint( </del> <ins> let (sp, suggestion) = match ( generics .params .iter() .filter( |p| !matches!(p.kind, hir::GenericParamKind::Type { synthetic: Some(_), ..}), ) .next(), super_traits, ) { (_, None) => predicate_constraint( </ins> generics, trait_ref.without_const().to_predicate(tcx).to_string(), ), <del> Some((ident, bounds)) => match bounds { [.., bound] => ( bound.span().shrink_to_hi(), format!(" + {}", trait_ref.print_only_trait_path().to_string()), ), [] => ( ident.span.shrink_to_hi(), format!(": {}", trait_ref.print_only_trait_path().to_string()), ), }, </del> <ins> (None, Some((ident, []))) => ( ident.span.shrink_to_hi(), format!(": {}", trait_ref.print_only_trait_path().to_string()), ), (_, Some((_, [.., bounds]))) => ( bounds.span().shrink_to_hi(), format!(" + {}", trait_ref.print_only_trait_path().to_string()), ), (Some(_), Some((_, []))) => ( generics.span.shrink_to_hi(), format!(": {}", trait_ref.print_only_trait_path().to_string()), ), </ins> }; err.span_suggestion_verbose(


Question:
The following code errors, and the error contains a suggestion how to fix the error: The error message states: Obviously, writing is invalid syntax.
It seems the issue is that it's inserting the suggestion after the trait name and before the generics, rather than after the generics.
No-nightly-features code that exhibits the same problem: label -requires-nightly (should the F-labels go as well?)

//~^ ERROR doesn't implement } <del> pub fn main() { } </del> <ins> trait Foo<T>: Sized { const SIZE: usize = core::mem::size_of::<Self>(); //~^ ERROR the size for values of type `Self` cannot be known at compilation time } trait Bar: std::fmt::Display + Sized { const SIZE: usize = core::mem::size_of::<Self>(); //~^ ERROR the size for values of type `Self` cannot be known at compilation time } trait Baz: Sized where Self: std::fmt::Display { const SIZE: usize = core::mem::size_of::<Self>(); //~^ ERROR the size for values of type `Self` cannot be known at compilation time } trait Qux<T>: Sized where Self: std::fmt::Display { const SIZE: usize = core::mem::size_of::<Self>(); //~^ ERROR the size for values of type `Self` cannot be known at compilation time } trait Bat<T>: std::fmt::Display + Sized { const SIZE: usize = core::mem::size_of::<Self>(); //~^ ERROR the size for values of type `Self` cannot be known at compilation time } fn main() { } </ins>


Question:
The following code errors, and the error contains a suggestion how to fix the error: The error message states: Obviously, writing is invalid syntax.
It seems the issue is that it's inserting the suggestion after the trait name and before the generics, rather than after the generics.
No-nightly-features code that exhibits the same problem: label -requires-nightly (should the F-labels go as well?)

//~^ ERROR doesn't implement } <del> pub fn main() { } </del> <ins> trait Foo<T> { const SIZE: usize = core::mem::size_of::<Self>(); //~^ ERROR the size for values of type `Self` cannot be known at compilation time } trait Bar: std::fmt::Display { const SIZE: usize = core::mem::size_of::<Self>(); //~^ ERROR the size for values of type `Self` cannot be known at compilation time } trait Baz where Self: std::fmt::Display { const SIZE: usize = core::mem::size_of::<Self>(); //~^ ERROR the size for values of type `Self` cannot be known at compilation time } trait Qux<T> where Self: std::fmt::Display { const SIZE: usize = core::mem::size_of::<Self>(); //~^ ERROR the size for values of type `Self` cannot be known at compilation time } trait Bat<T>: std::fmt::Display { const SIZE: usize = core::mem::size_of::<Self>(); //~^ ERROR the size for values of type `Self` cannot be known at compilation time } fn main() { } </ins>