-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Closed
Labels
A-attributesArea: Attributes (`#[…]`, `#![…]`)Area: Attributes (`#[…]`, `#![…]`)A-macrosArea: All kinds of macros (custom derive, macro_rules!, proc macros, ..)Area: All kinds of macros (custom derive, macro_rules!, proc macros, ..)A-proc-macrosArea: Procedural macrosArea: Procedural macrosC-bugCategory: This is a bug.Category: This is a bug.E-needs-testCall for participation: An issue has been fixed and does not reproduce, but no test has been added.Call for participation: An issue has been fixed and does not reproduce, but no test has been added.F-stmt_expr_attributes`#![feature(stmt_expr_attributes)]``#![feature(stmt_expr_attributes)]`I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️P-highHigh priorityHigh priorityT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.requires-nightlyThis issue requires a nightly compiler in some way.This issue requires a nightly compiler in some way.

Description
I tried this code:
use proc_macro::TokenStream;
#[proc_macro_attribute]
pub fn breaks_rust(_: TokenStream, input: TokenStream) -> TokenStream {
input
}
#![feature(stmt_expr_attributes, proc_macro_hygiene)]
use the_proc_macro_crate::breaks_rust;
#[breaks_rust]
fn main() {
let _break;
let rust = ();
#[breaks_rust]
_break = rust; // line 10
}
I expected the code to compile sucessfully, but got an ICE instead:
thread 'rustc' panicked at 'Missing tokens for nt at tests/ice.rs:10:5: 10:11 (#0): "_break"', compiler/rustc_parse/src/lib.rs:295:9
(This is procedural-macro-related. I can't reproduce without a procedural macro.)
This used to work and regressed in #79472.
Backtrace
0: rust_begin_unwind
at /rustc/b122908617436af187252572ed5db96850551380/library/std/src/panicking.rs:493:5
1: std::panicking::begin_panic_fmt
at /rustc/b122908617436af187252572ed5db96850551380/library/std/src/panicking.rs:435:5
2: rustc_parse::nt_to_tokenstream
3: rustc_expand::base::Annotatable::into_tokens
4: rustc_expand::expand::MacroExpander::fully_expand_fragment
5: rustc_expand::expand::MacroExpander::expand_crate
6: rustc_interface::passes::configure_and_expand_inner
7: rustc_interface::passes::configure_and_expand::{{closure}}
8: rustc_data_structures::box_region::PinnedGenerator<I,A,R>::new
9: rustc_interface::passes::configure_and_expand
10: rustc_interface::queries::Queries::expansion
11: rustc_interface::queries::<impl rustc_interface::interface::Compiler>::enter
12: rustc_span::with_source_map
13: rustc_interface::interface::create_compiler_and_run
Metadata
Metadata
Assignees
Labels
A-attributesArea: Attributes (`#[…]`, `#![…]`)Area: Attributes (`#[…]`, `#![…]`)A-macrosArea: All kinds of macros (custom derive, macro_rules!, proc macros, ..)Area: All kinds of macros (custom derive, macro_rules!, proc macros, ..)A-proc-macrosArea: Procedural macrosArea: Procedural macrosC-bugCategory: This is a bug.Category: This is a bug.E-needs-testCall for participation: An issue has been fixed and does not reproduce, but no test has been added.Call for participation: An issue has been fixed and does not reproduce, but no test has been added.F-stmt_expr_attributes`#![feature(stmt_expr_attributes)]``#![feature(stmt_expr_attributes)]`I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️P-highHigh priorityHigh priorityT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.requires-nightlyThis issue requires a nightly compiler in some way.This issue requires a nightly compiler in some way.