-
-
Notifications
You must be signed in to change notification settings - Fork 14.3k
Open
Labels
C-bugCategory: This is a bug.Category: This is a bug.I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️T-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.needs-triageThis issue may need triage. Remove it if it has been sufficiently triaged.This issue may need triage. Remove it if it has been sufficiently triaged.
Description
Code
trait Anything<'a> {}
#[derive(Debug)]
struct FeatureGatedGeneric<'a, #[cfg(feature = "dummy")] A: Anything<'a>> {}When removing pretty much any of the details of this example, such as the derive macro, the cfg directive or the lifetime in the trait, the compiler does not panic.
However, the following code compiled with the dummy feature enabled does compile fine:
trait Anything<'a> {}
#[derive(Debug)]
struct FeatureGatedGeneric<'a, #[cfg(feature = "dummy")] A> where A: Anything<'a>{
_a: &'a A,
}Meta
Occurs in stable, beta and nightly
rustc --version --verbose:
rustc 1.92.0 (ded5c06cf 2025-12-08)
binary: rustc
commit-hash: ded5c06cf21d2b93bffd5d884aa6e96934ee4234
commit-date: 2025-12-08
host: x86_64-unknown-linux-gnu
release: 1.92.0
LLVM version: 21.1.3
rustc 1.93.0-beta.3 (6dfb8017e 2025-12-16)
binary: rustc
commit-hash: 6dfb8017edf6382e5b6d942fd9812ca3ef904865
commit-date: 2025-12-16
host: x86_64-unknown-linux-gnu
release: 1.93.0-beta.3
LLVM version: 21.1.5
rustc 1.94.0-nightly (fcf67da03 2025-12-18)
binary: rustc
commit-hash: fcf67da039f42e3905cf6f69e33304299c45149f
commit-date: 2025-12-18
host: x86_64-unknown-linux-gnu
release: 1.94.0-nightly
LLVM version: 21.1.8
Error output
thread 'rustc' (1085814) panicked at compiler/rustc_parse/src/parser/attr_wrapper.rs:353:13:
Should not have unglued last token with cfg attr
stack backtrace:
0: 0x75181ae0bfe3 - <<std[a1521911952c6a5]::sys::backtrace::BacktraceLock>::print::DisplayBacktrace as core[4ea4c2fa426a8d3b]::fmt::Display>::fmt
1: 0x75181b4106c8 - core[4ea4c2fa426a8d3b]::fmt::write
2: 0x75181ae22756 - <std[a1521911952c6a5]::sys::stdio::unix::Stderr as std[a1521911952c6a5]::io::Write>::write_fmt
3: 0x75181ade26d8 - std[a1521911952c6a5]::panicking::default_hook::{closure#0}
4: 0x75181adffe53 - std[a1521911952c6a5]::panicking::default_hook
5: 0x751819dedb57 - std[a1521911952c6a5]::panicking::update_hook::<alloc[5350b0840b7819c6]::boxed::Box<rustc_driver_impl[bdf936d5e37c8e64]::install_ice_hook::{closure#1}>>::{closure#0}
6: 0x75181ae00132 - std[a1521911952c6a5]::panicking::panic_with_hook
7: 0x75181ade27ca - std[a1521911952c6a5]::panicking::panic_handler::{closure#0}
8: 0x75181add7029 - std[a1521911952c6a5]::sys::backtrace::__rust_end_short_backtrace::<std[a1521911952c6a5]::panicking::panic_handler::{closure#0}, !>
9: 0x75181ade434d - __rustc[f25f47d7eb20112d]::rust_begin_unwind
10: 0x751817f0a77c - core[4ea4c2fa426a8d3b]::panicking::panic_fmt
11: 0x75181c157731 - <rustc_parse[714a223ad94369c5]::parser::Parser>::parse_generic_params
12: 0x75181b741021 - <rustc_parse[714a223ad94369c5]::parser::Parser>::parse_generics
13: 0x75181b6ff314 - <rustc_parse[714a223ad94369c5]::parser::Parser>::parse_item_struct
14: 0x75181c138897 - <rustc_parse[714a223ad94369c5]::parser::Parser>::parse_item_kind
15: 0x75181c1282da - <rustc_parse[714a223ad94369c5]::parser::Parser>::parse_item_common
16: 0x75181c127eeb - <rustc_parse[714a223ad94369c5]::parser::Parser>::parse_item
17: 0x75181bfb4253 - rustc_builtin_macros[5714a33a4ac6edb2]::cfg_eval::cfg_eval
18: 0x75181bfb5f20 - <rustc_builtin_macros[5714a33a4ac6edb2]::derive::Expander as rustc_expand[f9b5266c13d5ccf8]::base::MultiItemModifier>::expand::{closure#0}
19: 0x75181c27d790 - <rustc_resolve[a04b75fb0e7ab801]::Resolver as rustc_expand[f9b5266c13d5ccf8]::base::ResolverExpand>::resolve_derives
20: 0x75181c27d514 - <rustc_builtin_macros[5714a33a4ac6edb2]::derive::Expander as rustc_expand[f9b5266c13d5ccf8]::base::MultiItemModifier>::expand
21: 0x75181c9a3698 - <rustc_expand[f9b5266c13d5ccf8]::expand::MacroExpander>::fully_expand_fragment
22: 0x75181c988018 - <rustc_expand[f9b5266c13d5ccf8]::expand::MacroExpander>::expand_crate
23: 0x75181bb72ff2 - rustc_interface[eb353023e064c6f7]::passes::configure_and_expand
24: 0x75181c66e642 - rustc_interface[eb353023e064c6f7]::passes::resolver_for_lowering_raw
25: 0x75181c66e39b - rustc_query_impl[374b6a112c69203e]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[374b6a112c69203e]::query_impl::resolver_for_lowering_raw::dynamic_query::{closure#2}::{closure#0}, rustc_middle[db1201859422fbf0]::query::erase::Erased<[u8; 16usize]>>
26: 0x75181c66e389 - <rustc_query_impl[374b6a112c69203e]::query_impl::resolver_for_lowering_raw::dynamic_query::{closure#2} as core[4ea4c2fa426a8d3b]::ops::function::FnOnce<(rustc_middle[db1201859422fbf0]::ty::context::TyCtxt, ())>>::call_once
27: 0x75181c66db1f - rustc_query_system[fee949cfe43af430]::query::plumbing::try_execute_query::<rustc_query_impl[374b6a112c69203e]::DynamicConfig<rustc_query_system[fee949cfe43af430]::query::caches::SingleCache<rustc_middle[db1201859422fbf0]::query::erase::Erased<[u8; 16usize]>>, false, false, false>, rustc_query_impl[374b6a112c69203e]::plumbing::QueryCtxt, false>
28: 0x75181c66d67c - rustc_query_impl[374b6a112c69203e]::query_impl::resolver_for_lowering_raw::get_query_non_incr::__rust_end_short_backtrace
29: 0x75181c766478 - <rustc_interface[eb353023e064c6f7]::passes::create_and_enter_global_ctxt<core[4ea4c2fa426a8d3b]::option::Option<rustc_interface[eb353023e064c6f7]::queries::Linker>, rustc_driver_impl[bdf936d5e37c8e64]::run_compiler::{closure#0}::{closure#2}>::{closure#2} as core[4ea4c2fa426a8d3b]::ops::function::FnOnce<(&rustc_session[b0fc32d37d8a7db0]::session::Session, rustc_middle[db1201859422fbf0]::ty::context::CurrentGcx, alloc[5350b0840b7819c6]::sync::Arc<rustc_data_structures[6a63967a9f39f52]::jobserver::Proxy>, &std[a1521911952c6a5]::sync::once_lock::OnceLock<rustc_middle[db1201859422fbf0]::ty::context::GlobalCtxt>, &rustc_data_structures[6a63967a9f39f52]::sync::worker_local::WorkerLocal<rustc_middle[db1201859422fbf0]::arena::Arena>, &rustc_data_structures[6a63967a9f39f52]::sync::worker_local::WorkerLocal<rustc_hir[714d8eaaf775e89e]::Arena>, rustc_driver_impl[bdf936d5e37c8e64]::run_compiler::{closure#0}::{closure#2})>>::call_once::{shim:vtable#0}
30: 0x75181c51801a - rustc_interface[eb353023e064c6f7]::interface::run_compiler::<(), rustc_driver_impl[bdf936d5e37c8e64]::run_compiler::{closure#0}>::{closure#1}
31: 0x75181c4c277a - std[a1521911952c6a5]::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface[eb353023e064c6f7]::util::run_in_thread_with_globals<rustc_interface[eb353023e064c6f7]::util::run_in_thread_pool_with_globals<rustc_interface[eb353023e064c6f7]::interface::run_compiler<(), rustc_driver_impl[bdf936d5e37c8e64]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>
32: 0x75181c4c252c - <std[a1521911952c6a5]::thread::lifecycle::spawn_unchecked<rustc_interface[eb353023e064c6f7]::util::run_in_thread_with_globals<rustc_interface[eb353023e064c6f7]::util::run_in_thread_pool_with_globals<rustc_interface[eb353023e064c6f7]::interface::run_compiler<(), rustc_driver_impl[bdf936d5e37c8e64]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>::{closure#1} as core[4ea4c2fa426a8d3b]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
33: 0x75181c4c0978 - <std[a1521911952c6a5]::sys::thread::unix::Thread>::new::thread_start
34: 0x751815e9caa4 - start_thread
at ./nptl/pthread_create.c:447:8
35: 0x751815f29c6c - clone3
at ./misc/../sysdeps/unix/sysv/linux/x86_64/clone3.S:78:0
36: 0x0 - <unknown>
error: 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: please make sure that you have updated to the latest nightly
note: please attach the file at `/home/julian/Projects/rustc-bug/rustc-ice-2025-12-19T15_27_17-1085790.txt` to your bug report
query stack during panic:
#0 [resolver_for_lowering_raw] getting the resolver for lowering
end of query stack
Backtrace
thread 'rustc' (1086874) panicked at compiler/rustc_parse/src/parser/attr_wrapper.rs:353:13:
Should not have unglued last token with cfg attr
stack backtrace:
0: __rustc::rust_begin_unwind
1: core::panicking::panic_fmt
2: <rustc_parse::parser::Parser>::parse_generic_params
3: <rustc_parse::parser::Parser>::parse_generics
4: <rustc_parse::parser::Parser>::parse_item_struct
5: <rustc_parse::parser::Parser>::parse_item_kind
6: <rustc_parse::parser::Parser>::parse_item_common
7: <rustc_parse::parser::Parser>::parse_item
8: rustc_builtin_macros::cfg_eval::cfg_eval
9: <rustc_builtin_macros::derive::Expander as rustc_expand::base::MultiItemModifier>::expand::{closure#0}
10: <rustc_resolve::Resolver as rustc_expand::base::ResolverExpand>::resolve_derives
11: <rustc_builtin_macros::derive::Expander as rustc_expand::base::MultiItemModifier>::expand
12: <rustc_expand::expand::MacroExpander>::fully_expand_fragment
13: <rustc_expand::expand::MacroExpander>::expand_crate
14: rustc_interface::passes::configure_and_expand
15: rustc_interface::passes::resolver_for_lowering_raw
[... omitted 2 frames ...]
16: <rustc_interface::passes::create_and_enter_global_ctxt<core::option::Option<rustc_interface::queries::Linker>, rustc_driver_impl::run_compiler::{closure#0}::{closure#2}>::{closure#2} as core::ops::function::FnOnce<(&rustc_session::session::Session, rustc_middle::ty::context::CurrentGcx, alloc::sync::Arc<rustc_data_structures::jobserver::Proxy>, &std::sync::once_lock::OnceLock<rustc_middle::ty::context::GlobalCtxt>, &rustc_data_structures::sync::worker_local::WorkerLocal<rustc_middle::arena::Arena>, &rustc_data_structures::sync::worker_local::WorkerLocal<rustc_hir::Arena>, rustc_driver_impl::run_compiler::{closure#0}::{closure#2})>>::call_once::{shim:vtable#0}
17: rustc_interface::interface::run_compiler::<(), rustc_driver_impl::run_compiler::{closure#0}>::{closure#1}
Metadata
Metadata
Assignees
Labels
C-bugCategory: This is a bug.Category: This is a bug.I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️T-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.needs-triageThis issue may need triage. Remove it if it has been sufficiently triaged.This issue may need triage. Remove it if it has been sufficiently triaged.