Skip to content

ICE: Anonymous structs or unions cannot be type parameters #121299

Closed
@matthiaskrgr

Description

@matthiaskrgr

snippet:

#[derive(Eq)]
struct D {
    _: union {
    },
}

Version information

rustc 1.78.0-nightly (bea5bebf3 2024-02-19)
binary: rustc
commit-hash: bea5bebf3defc56e5e3446b4a95c685dbb885fd3
commit-date: 2024-02-19
host: x86_64-unknown-linux-gnu
release: 1.78.0-nightly
LLVM version: 18.1.0

Command:
/home/matthias/.rustup/toolchains/master/bin/rustc

Program output

thread 'rustc' panicked at compiler/rustc_builtin_macros/src/deriving/mod.rs:127:5:
Anonymous structs or unions cannot be type parameters
stack backtrace:
   0:     0x7f36a6c70b56 - std::backtrace_rs::backtrace::libunwind::trace::h3a158c8f16516afb
                               at /rustc/bea5bebf3defc56e5e3446b4a95c685dbb885fd3/library/std/src/../../backtrace/src/backtrace/libunwind.rs:104:5
   1:     0x7f36a6c70b56 - std::backtrace_rs::backtrace::trace_unsynchronized::ha89664cca04bb36e
                               at /rustc/bea5bebf3defc56e5e3446b4a95c685dbb885fd3/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x7f36a6c70b56 - std::sys_common::backtrace::_print_fmt::h03800d086403b62e
                               at /rustc/bea5bebf3defc56e5e3446b4a95c685dbb885fd3/library/std/src/sys_common/backtrace.rs:68:5
   3:     0x7f36a6c70b56 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h91d502aabce8c547
                               at /rustc/bea5bebf3defc56e5e3446b4a95c685dbb885fd3/library/std/src/sys_common/backtrace.rs:44:22
   4:     0x7f36a6cc1b0c - core::fmt::rt::Argument::fmt::h99a2d1e221afec6c
                               at /rustc/bea5bebf3defc56e5e3446b4a95c685dbb885fd3/library/core/src/fmt/rt.rs:142:9
   5:     0x7f36a6cc1b0c - core::fmt::write::h97a5ad4b86c9e005
                               at /rustc/bea5bebf3defc56e5e3446b4a95c685dbb885fd3/library/core/src/fmt/mod.rs:1120:17
   6:     0x7f36a6c654bf - std::io::Write::write_fmt::h2b40f89315aa23ff
                               at /rustc/bea5bebf3defc56e5e3446b4a95c685dbb885fd3/library/std/src/io/mod.rs:1846:15
   7:     0x7f36a6c70904 - std::sys_common::backtrace::_print::h4787d964e00e361c
                               at /rustc/bea5bebf3defc56e5e3446b4a95c685dbb885fd3/library/std/src/sys_common/backtrace.rs:47:5
   8:     0x7f36a6c70904 - std::sys_common::backtrace::print::hbf94f54b49f22c72
                               at /rustc/bea5bebf3defc56e5e3446b4a95c685dbb885fd3/library/std/src/sys_common/backtrace.rs:34:9
   9:     0x7f36a6c7364b - std::panicking::default_hook::{{closure}}::h09f29dc972c775e7
  10:     0x7f36a6c73399 - std::panicking::default_hook::hdb43b973c97e30a9
                               at /rustc/bea5bebf3defc56e5e3446b4a95c685dbb885fd3/library/std/src/panicking.rs:292:9
  11:     0x7f36a3a2c5cc - std[e3016e56fde417e8]::panicking::update_hook::<alloc[26f96968629a1477]::boxed::Box<rustc_driver_impl[1d2aada9a967b964]::install_ice_hook::{closure#0}>>::{closure#0}
  12:     0x7f36a6c73db0 - <alloc::boxed::Box<F,A> as core::ops::function::Fn<Args>>::call::h7d80339b83881141
                               at /rustc/bea5bebf3defc56e5e3446b4a95c685dbb885fd3/library/alloc/src/boxed.rs:2030:9
  13:     0x7f36a6c73db0 - std::panicking::rust_panic_with_hook::ha4f031997107b610
                               at /rustc/bea5bebf3defc56e5e3446b4a95c685dbb885fd3/library/std/src/panicking.rs:786:13
  14:     0x7f36a6c73ab9 - std::panicking::begin_panic_handler::{{closure}}::h556d855f34b40d5b
                               at /rustc/bea5bebf3defc56e5e3446b4a95c685dbb885fd3/library/std/src/panicking.rs:652:13
  15:     0x7f36a6c71036 - std::sys_common::backtrace::__rust_end_short_backtrace::hcfcfe13416eb9e24
                               at /rustc/bea5bebf3defc56e5e3446b4a95c685dbb885fd3/library/std/src/sys_common/backtrace.rs:171:18
  16:     0x7f36a6c73824 - rust_begin_unwind
                               at /rustc/bea5bebf3defc56e5e3446b4a95c685dbb885fd3/library/std/src/panicking.rs:648:5
  17:     0x7f36a6cbe015 - core::panicking::panic_fmt::h817e0acf16f85c30
                               at /rustc/bea5bebf3defc56e5e3446b4a95c685dbb885fd3/library/core/src/panicking.rs:72:14
  18:     0x7f36a57ea1dc - rustc_builtin_macros[20656e6096520b61]::deriving::assert_ty_bounds
  19:     0x7f36a57e8d7a - rustc_builtin_macros[20656e6096520b61]::deriving::eq::expand_deriving_eq::{closure#0}
  20:     0x7f36a54ac3cc - <rustc_builtin_macros[20656e6096520b61]::deriving::generic::TraitDef>::expand_struct_def
  21:     0x7f36a57e5011 - <rustc_builtin_macros[20656e6096520b61]::deriving::generic::TraitDef>::expand_ext
  22:     0x7f36a5875d17 - rustc_builtin_macros[20656e6096520b61]::deriving::eq::expand_deriving_eq
  23:     0x7f36a54aa052 - <rustc_builtin_macros[20656e6096520b61]::deriving::BuiltinDerive as rustc_expand[a0d1a98eef577773]::base::MultiItemModifier>::expand
  24:     0x7f36a55b8447 - <rustc_expand[a0d1a98eef577773]::expand::MacroExpander>::fully_expand_fragment
  25:     0x7f36a55b5ef7 - <rustc_expand[a0d1a98eef577773]::expand::MacroExpander>::expand_crate
  26:     0x7f36a5ad0092 - rustc_interface[37c35c6dbc63475a]::passes::resolver_for_lowering
  27:     0x7f36a5acf567 - rustc_query_impl[2d5ef8d54471ac61]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[2d5ef8d54471ac61]::query_impl::resolver_for_lowering::dynamic_query::{closure#2}::{closure#0}, rustc_middle[3a9dcbdbfc28ae03]::query::erase::Erased<[u8; 8usize]>>
  28:     0x7f36a5996e4e - rustc_query_system[1991136b97b46e9d]::query::plumbing::try_execute_query::<rustc_query_impl[2d5ef8d54471ac61]::DynamicConfig<rustc_query_system[1991136b97b46e9d]::query::caches::SingleCache<rustc_middle[3a9dcbdbfc28ae03]::query::erase::Erased<[u8; 8usize]>>, false, false, false>, rustc_query_impl[2d5ef8d54471ac61]::plumbing::QueryCtxt, false>
  29:     0x7f36a59965cb - rustc_query_impl[2d5ef8d54471ac61]::query_impl::resolver_for_lowering::get_query_non_incr::__rust_end_short_backtrace
  30:     0x7f36a595df14 - rustc_interface[37c35c6dbc63475a]::interface::run_compiler::<core[7975d3e35f006c71]::result::Result<(), rustc_span[64c55662242a9f4e]::ErrorGuaranteed>, rustc_driver_impl[1d2aada9a967b964]::run_compiler::{closure#0}>::{closure#0}
  31:     0x7f36a5bbf305 - std[e3016e56fde417e8]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[37c35c6dbc63475a]::util::run_in_thread_with_globals<rustc_interface[37c35c6dbc63475a]::util::run_in_thread_pool_with_globals<rustc_interface[37c35c6dbc63475a]::interface::run_compiler<core[7975d3e35f006c71]::result::Result<(), rustc_span[64c55662242a9f4e]::ErrorGuaranteed>, rustc_driver_impl[1d2aada9a967b964]::run_compiler::{closure#0}>::{closure#0}, core[7975d3e35f006c71]::result::Result<(), rustc_span[64c55662242a9f4e]::ErrorGuaranteed>>::{closure#0}, core[7975d3e35f006c71]::result::Result<(), rustc_span[64c55662242a9f4e]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[7975d3e35f006c71]::result::Result<(), rustc_span[64c55662242a9f4e]::ErrorGuaranteed>>
  32:     0x7f36a5bbf132 - <<std[e3016e56fde417e8]::thread::Builder>::spawn_unchecked_<rustc_interface[37c35c6dbc63475a]::util::run_in_thread_with_globals<rustc_interface[37c35c6dbc63475a]::util::run_in_thread_pool_with_globals<rustc_interface[37c35c6dbc63475a]::interface::run_compiler<core[7975d3e35f006c71]::result::Result<(), rustc_span[64c55662242a9f4e]::ErrorGuaranteed>, rustc_driver_impl[1d2aada9a967b964]::run_compiler::{closure#0}>::{closure#0}, core[7975d3e35f006c71]::result::Result<(), rustc_span[64c55662242a9f4e]::ErrorGuaranteed>>::{closure#0}, core[7975d3e35f006c71]::result::Result<(), rustc_span[64c55662242a9f4e]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[7975d3e35f006c71]::result::Result<(), rustc_span[64c55662242a9f4e]::ErrorGuaranteed>>::{closure#1} as core[7975d3e35f006c71]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  33:     0x7f36a6c7d785 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::hdf5fa3c582f259ae
                               at /rustc/bea5bebf3defc56e5e3446b4a95c685dbb885fd3/library/alloc/src/boxed.rs:2016:9
  34:     0x7f36a6c7d785 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h57a62cffc212fbb2
                               at /rustc/bea5bebf3defc56e5e3446b4a95c685dbb885fd3/library/alloc/src/boxed.rs:2016:9
  35:     0x7f36a6c7d785 - std::sys::pal::unix::thread::Thread::new::thread_start::hf5c20164f3984a87
                               at /rustc/bea5bebf3defc56e5e3446b4a95c685dbb885fd3/library/std/src/sys/pal/unix/thread.rs:108:17
  36:     0x7f36a0aaa9eb - <unknown>
  37:     0x7f36a0b2e7cc - <unknown>
  38:                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: rustc 1.78.0-nightly (bea5bebf3 2024-02-19) running on x86_64-unknown-linux-gnu

query stack during panic:
#0 [resolver_for_lowering] getting the resolver for lowering
end of query stack

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: This is a bug.F-unnamed_fields`#![feature(unnamed_fields)]`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.S-has-mcveStatus: A Minimal Complete and Verifiable Example has been found for this issueT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.regression-from-stable-to-nightlyPerformance or correctness regression from stable to nightly.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions