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: Should not have unglued last token with cfg attr #87577

Open
samlich opened this issue Jul 29, 2021 · 2 comments · May be fixed by #113056
Open

ICE: Should not have unglued last token with cfg attr #87577

samlich opened this issue Jul 29, 2021 · 2 comments · May be fixed by #113056
Assignees
Labels
C-bug Category: This is a bug. glacier ICE tracked in rust-lang/glacier. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ S-bug-has-test Status: This bug is tracked inside the repo by a `known-bug` test. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@samlich
Copy link
Contributor

samlich commented Jul 29, 2021

Code

#[derive(Debug)]      
struct S<#[cfg(feature = "alloc")] N: A<T>> {}

Meta

rustc --version --verbose:

rustc 1.56.0-nightly (2faabf579 2021-07-27)
binary: rustc
commit-hash: 2faabf579323f5252329264cc53ba9ff803429a3
commit-date: 2021-07-27
host: x86_64-unknown-linux-gnu
release: 1.56.0-nightly
LLVM version: 12.0.1

First fails in rustc 1.53.0-nightly (a86612456 2021-04-11).

Compiles successfully in rustc 1.53.0-nightly (a836d9b64 2021-04-10).

Perhaps related to #82608 which was merged on that date and appears when searching "unglued."

Error output

thread 'rustc' panicked at 'Should not have unglued last token with cfg attr', compiler/rustc_parse/src/parser/attr_wrapper.rs:371:13
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

error: internal compiler error: unexpected panic

note: the compiler unexpectedly panicked. this is a bug.

note: we would appreciate a bug report: https://github.com/rust-lang/rust/issues/new?labels=C-bug%2C+I-ICE%2C+T-compiler&template=ice.md

note: rustc 1.56.0-nightly (2faabf579 2021-07-27) running on x86_64-unknown-linux-gnu

note: compiler flags: -C embed-bitcode=no -C debuginfo=2 -C incremental -C link-arg=-fuse-ld=lld --crate-type lib

note: some of the compiler flags provided by cargo are hidden

query stack during panic:
end of query stack
error: could not compile `unglued`
Backtrace

thread 'rustc' panicked at 'Should not have unglued last token with cfg attr', compiler/rustc_parse/src/parser/attr_wrapper.rs:371:13
stack backtrace:
   0: std::panicking::begin_panic
   1: rustc_parse::parser::generics::<impl rustc_parse::parser::Parser>::parse_generic_params
   2: rustc_parse::parser::generics::<impl rustc_parse::parser::Parser>::parse_generics
   3: rustc_parse::parser::item::<impl rustc_parse::parser::Parser>::parse_item_kind
   4: rustc_parse::parser::item::<impl rustc_parse::parser::Parser>::parse_item_common
   5: rustc_parse::parser::item::<impl rustc_parse::parser::Parser>::parse_item
   6: rustc_builtin_macros::cfg_eval::cfg_eval
   7: <rustc_builtin_macros::derive::Expander as rustc_expand::base::MultiItemModifier>::expand
   8: rustc_expand::expand::MacroExpander::fully_expand_fragment
   9: rustc_expand::expand::MacroExpander::expand_crate
  10: rustc_session::utils::<impl rustc_session::session::Session>::time
  11: rustc_interface::passes::configure_and_expand
  12: rustc_interface::queries::Queries::expansion
  13: rustc_interface::queries::<impl rustc_interface::interface::Compiler>::enter
  14: rustc_span::with_source_map
  15: rustc_interface::interface::create_compiler_and_run
  16: scoped_tls::ScopedKey<T>::set
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

@samlich samlich added C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Jul 29, 2021
@Aaron1011 Aaron1011 self-assigned this Jul 29, 2021
@Aaron1011
Copy link
Member

As a temporary workaround, you can add a comma between the two > characters:

#[derive(Debug)]      
struct S<#[cfg(feature = "alloc")] N: A<T>,> {}

@rust-lang-glacier-bot rust-lang-glacier-bot added the glacier ICE tracked in rust-lang/glacier. label Aug 12, 2021
@Enselic
Copy link
Member

Enselic commented Sep 8, 2023

Triage: This ICE still reproduces with latest nightly:

$ echo '#[derive(Debug)] struct S<#[cfg(feature = "alloc")] N: A<T>> {}' | rustc +nightly --crate-type lib -
thread 'rustc' panicked at compiler/rustc_parse/src/parser/attr_wrapper.rs:365:13:
Should not have unglued last token with cfg attr
...
$ rustc +nightly -vV
rustc 1.74.0-nightly (1e746d774 2023-09-07)
binary: rustc
commit-hash: 1e746d7741d44551e9378daf13b8797322aa0b74
commit-date: 2023-09-07
host: x86_64-unknown-linux-gnu
release: 1.74.0-nightly
LLVM version: 17.0.0

@matthiaskrgr matthiaskrgr added the S-bug-has-test Status: This bug is tracked inside the repo by a `known-bug` test. label Apr 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: This is a bug. glacier ICE tracked in rust-lang/glacier. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ S-bug-has-test Status: This bug is tracked inside the repo by a `known-bug` test. 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.

5 participants