Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ICE (Missing tokens for nt) on nightly with stmt_expr_attributes and proc_macro_hygiene #81555

Closed
ghost opened this issue Jan 30, 2021 · 5 comments · Fixed by #83015
Closed
Assignees
Labels
A-attributes Area: Attributes (`#[…]`, `#![…]`) A-macros Area: All kinds of macros (custom derive, macro_rules!, proc macros, ..) A-proc-macros Area: Procedural macros C-bug Category: This is a bug. E-needs-test 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)]` I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ P-high High priority requires-nightly This issue requires a nightly compiler in some way. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@ghost
Copy link

ghost commented Jan 30, 2021

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

cc #15701 #54727

@rustbot rustbot added A-attributes Area: Attributes (`#[…]`, `#![…]`) A-macros Area: All kinds of macros (custom derive, macro_rules!, proc macros, ..) A-proc-macros Area: Procedural macros C-bug Category: This is a bug. E-needs-bisection Call for participation: This issue needs bisection: https://github.com/rust-lang/cargo-bisect-rustc I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ regression-from-stable-to-nightly Performance or correctness regression from stable to nightly. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. I-prioritize Issue: Indicates that prioritization has been requested for this issue. requires-nightly This issue requires a nightly compiler in some way. and removed E-needs-bisection Call for participation: This issue needs bisection: https://github.com/rust-lang/cargo-bisect-rustc labels Jan 30, 2021
@camelid
Copy link
Member

camelid commented Jan 30, 2021

If this code only works on nightly, then I don't think it's a regression-from-stable-to-nightly. However, we don't have a regression-from-nightly-to-nightly label, so ...

@Aaron1011 Aaron1011 self-assigned this Jan 30, 2021
@Aaron1011
Copy link
Member

Aaron1011 commented Jan 31, 2021

This will be fixed by #81286, which handles attributes on expressions in a more systematic way.

As a side note, #[breaks_rust] _break = rust; is currently parsed as (#[breaks_rust] _break) = rust;

@camelid
Copy link
Member

camelid commented Feb 1, 2021

This will be fixed by #81286, which handles attributes on expressions in a more systematic way.

Do you want to add Fixes #81555 to that PR then?

@Aaron1011
Copy link
Member

We'll still need to add a regression test.

@rylev
Copy link
Member

rylev commented Feb 1, 2021

Assigning P-high as discussed as part of the Prioritization Working Group procedure and removing I-prioritize.

@rylev rylev added P-high High priority and removed I-prioritize Issue: Indicates that prioritization has been requested for this issue. labels Feb 1, 2021
@LeSeulArtichaut LeSeulArtichaut added E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added. and removed regression-from-stable-to-nightly Performance or correctness regression from stable to nightly. labels Feb 1, 2021
bors added a commit to rust-lang-ci/rust that referenced this issue Apr 1, 2021
Rollup of 5 pull requests

Successful merges:

 - rust-lang#83015 (Add regression tests for rust-lang#79825 and rust-lang#81555)
 - rust-lang#83699 (Add a regression test for issue-68830)
 - rust-lang#83700 (Fix documentation of conversion from String to OsString)
 - rust-lang#83711 (Clarify `--print target-list` is a rustc's option)
 - rust-lang#83712 (Update LLVM with another wasm simd fix)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors closed this as completed in 9e30e57 Apr 1, 2021
@dtolnay dtolnay added the F-stmt_expr_attributes `#![feature(stmt_expr_attributes)]` label Dec 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-attributes Area: Attributes (`#[…]`, `#![…]`) A-macros Area: All kinds of macros (custom derive, macro_rules!, proc macros, ..) A-proc-macros Area: Procedural macros C-bug Category: This is a bug. E-needs-test 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)]` I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ P-high High priority requires-nightly This issue requires a nightly compiler in some way. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants