Skip to content

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

Open
@samlich

Description

@samlich

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.

Metadata

Metadata

Assignees

Labels

C-bugCategory: This is a bug.I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️S-bug-has-testStatus: This bug is tracked inside the repo by a `known-bug` test.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.glacierICE tracked in rust-lang/glacier.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions