rust-lang / rust

Empowering everyone to build reliable and efficient software.
https://www.rust-lang.org
Other
96.88k stars 12.52k forks source link

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

Open matthiaskrgr opened 7 months ago

matthiaskrgr commented 7 months ago

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 - ::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::>::{closure#0} 12: 0x7f36a6c73db0 - as core::ops::function::Fn>::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 - ::expand_struct_def 21: 0x7f36a57e5011 - ::expand_ext 22: 0x7f36a5875d17 - rustc_builtin_macros[20656e6096520b61]::deriving::eq::expand_deriving_eq 23: 0x7f36a54aa052 - ::expand 24: 0x7f36a55b8447 - ::fully_expand_fragment 25: 0x7f36a55b5ef7 - ::expand_crate 26: 0x7f36a5ad0092 - rustc_interface[37c35c6dbc63475a]::passes::resolver_for_lowering 27: 0x7f36a5acf567 - rustc_query_impl[2d5ef8d54471ac61]::plumbing::__rust_begin_short_backtrace::> 28: 0x7f36a5996e4e - rustc_query_system[1991136b97b46e9d]::query::plumbing::try_execute_query::>, 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::, rustc_driver_impl[1d2aada9a967b964]::run_compiler::{closure#0}>::{closure#0} 31: 0x7f36a5bbf305 - std[e3016e56fde417e8]::sys_common::backtrace::__rust_begin_short_backtrace::, 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 - <::spawn_unchecked_, 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 - as core::ops::function::FnOnce>::call_once::hdf5fa3c582f259ae at /rustc/bea5bebf3defc56e5e3446b4a95c685dbb885fd3/library/alloc/src/boxed.rs:2016:9 34: 0x7f36a6c7d785 - as core::ops::function::FnOnce>::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 - 37: 0x7f36a0b2e7cc - 38: 0x0 - 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 ```

jieyouxu commented 7 months ago

Doesn't crash on stable, but crashes in nightly in playground (1.78.0-nightly (2024-02-18 2bf78d12d33ae02d1001)).

clubby789 commented 6 months ago

Should be fixed by #121270

lolbinarycat commented 1 week ago

triage: still broken in latest nightly