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: builtin derive created an unaligned reference #120873

Open
matthiaskrgr opened this issue Feb 10, 2024 · 3 comments
Open

ICE: builtin derive created an unaligned reference #120873

matthiaskrgr opened this issue Feb 10, 2024 · 3 comments
Labels
C-bug Category: This is a bug. 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

@matthiaskrgr
Copy link
Member

auto-reduced (treereduce-rust):

#[repr(packed)]

struct Dealigned<T>(u8, T);

#[derive(PartialEq)]
#[repr(C)]
struct Dealigned<T>(u8, T);

original:

// run-pass
// check that derive on a packed struct does not call field
// methods with a misaligned field.

use std::mem;

#[derive(Copy, Clone)]
struct Aligned(usize);

#[inline(never)]
fn check_align(ptr: *const Aligned) {
    assert_eq!(ptr as usize % mem::align_of::<Aligned>(),
               0);
}

impl PartialEq for Aligned {
    fn eq(&self, ptr: *const Aligned) -> bool {
        check_align(self);
        check_align(other);
        self.0 == other.0
    }
}

#[repr(packed)]
#[Clone(Copy, Clone, PartialEq)]
struct Dealigned<T>(u8, T);

#[derive(PartialEq)]
#[repr(C)]
struct Dealigned<T>(u8, T);

fn main() {
    let d1 = Dealigned(0, Packed(Aligned(1), Aligned(2)));
    let ck = self.0 == other.0;
    assert!(ck);
}

Version information

rustc 1.78.0-nightly (d44e3b95c 2024-02-09)
binary: rustc
commit-hash: d44e3b95cb9d410d89cb8ab3233906a33f43756a
commit-date: 2024-02-09
host: x86_64-unknown-linux-gnu
release: 1.78.0-nightly
LLVM version: 17.0.6

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

Program output

error[E0428]: the name `Dealigned` is defined multiple times
 --> /tmp/icemaker_global_tempdir.5YBiqSYbKJwL/rustc_testrunner_tmpdir_reporting.vAXos37lSTVP/mvce.rs:7:1
  |
3 | struct Dealigned<T>(u8, T);
  | --------------------------- previous definition of the type `Dealigned` here
...
7 | struct Dealigned<T>(u8, T);
  | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ `Dealigned` redefined here
  |
  = note: `Dealigned` must be defined only once in the type namespace of this module

error[E0601]: `main` function not found in crate `mvce`
 --> /tmp/icemaker_global_tempdir.5YBiqSYbKJwL/rustc_testrunner_tmpdir_reporting.vAXos37lSTVP/mvce.rs:7:28
  |
7 | struct Dealigned<T>(u8, T);
  |                            ^ consider adding a `main` function to `/tmp/icemaker_global_tempdir.5YBiqSYbKJwL/rustc_testrunner_tmpdir_reporting.vAXos37lSTVP/mvce.rs`

error: internal compiler error: compiler/rustc_mir_transform/src/check_packed_ref.rs:49:21: builtin derive created an unaligned reference
 --> /tmp/icemaker_global_tempdir.5YBiqSYbKJwL/rustc_testrunner_tmpdir_reporting.vAXos37lSTVP/mvce.rs:7:25
  |
5 | #[derive(PartialEq)]
  |          --------- in this derive macro expansion
6 | #[repr(C)]
7 | struct Dealigned<T>(u8, T);
  |                         ^
  |
  = note: this error: internal compiler error originates in the derive macro `PartialEq` (in Nightly builds, run with -Z macro-backtrace for more info)

thread 'rustc' panicked at /rustc/d44e3b95cb9d410d89cb8ab3233906a33f43756a/compiler/rustc_middle/src/util/bug.rs:34:50:
Box<dyn Any>
stack backtrace:
   0:     0x7f42b77e5936 - std::backtrace_rs::backtrace::libunwind::trace::ha4e340d83956b6a7
                               at /rustc/d44e3b95cb9d410d89cb8ab3233906a33f43756a/library/std/src/../../backtrace/src/backtrace/libunwind.rs:104:5
   1:     0x7f42b77e5936 - std::backtrace_rs::backtrace::trace_unsynchronized::h496689f2269fc1f9
                               at /rustc/d44e3b95cb9d410d89cb8ab3233906a33f43756a/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x7f42b77e5936 - std::sys_common::backtrace::_print_fmt::h5b8d6425acdf9de2
                               at /rustc/d44e3b95cb9d410d89cb8ab3233906a33f43756a/library/std/src/sys_common/backtrace.rs:68:5
   3:     0x7f42b77e5936 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::hd1632d07f3024207
                               at /rustc/d44e3b95cb9d410d89cb8ab3233906a33f43756a/library/std/src/sys_common/backtrace.rs:44:22
   4:     0x7f42b7838380 - core::fmt::rt::Argument::fmt::h4f261889e80f123d
                               at /rustc/d44e3b95cb9d410d89cb8ab3233906a33f43756a/library/core/src/fmt/rt.rs:142:9
   5:     0x7f42b7838380 - core::fmt::write::h9bbd14542dbf2e7c
                               at /rustc/d44e3b95cb9d410d89cb8ab3233906a33f43756a/library/core/src/fmt/mod.rs:1120:17
   6:     0x7f42b77d917f - std::io::Write::write_fmt::hdb4a9a1a30b52b2c
                               at /rustc/d44e3b95cb9d410d89cb8ab3233906a33f43756a/library/std/src/io/mod.rs:1854:15
   7:     0x7f42b77e5714 - std::sys_common::backtrace::_print::h016f2aaf70be80f8
                               at /rustc/d44e3b95cb9d410d89cb8ab3233906a33f43756a/library/std/src/sys_common/backtrace.rs:47:5
   8:     0x7f42b77e5714 - std::sys_common::backtrace::print::hb9713787207c076b
                               at /rustc/d44e3b95cb9d410d89cb8ab3233906a33f43756a/library/std/src/sys_common/backtrace.rs:34:9
   9:     0x7f42b77e84d7 - std::panicking::default_hook::{{closure}}::h34ca11fbc6eb460e
  10:     0x7f42b77e8239 - std::panicking::default_hook::h3e49d202ffbf9a64
                               at /rustc/d44e3b95cb9d410d89cb8ab3233906a33f43756a/library/std/src/panicking.rs:292:9
  11:     0x7f42b4528a0c - std[4cb245a8c4fcbb2b]::panicking::update_hook::<alloc[4a1fa2d365a8ec83]::boxed::Box<rustc_driver_impl[d92334f8e0b5c69f]::install_ice_hook::{closure#0}>>::{closure#0}
  12:     0x7f42b77e8c26 - <alloc::boxed::Box<F,A> as core::ops::function::Fn<Args>>::call::h70b0dd5af17047ec
                               at /rustc/d44e3b95cb9d410d89cb8ab3233906a33f43756a/library/alloc/src/boxed.rs:2029:9
  13:     0x7f42b77e8c26 - std::panicking::rust_panic_with_hook::h5268464aa60f9bc8
                               at /rustc/d44e3b95cb9d410d89cb8ab3233906a33f43756a/library/std/src/panicking.rs:785:13
  14:     0x7f42b455a374 - std[4cb245a8c4fcbb2b]::panicking::begin_panic::<rustc_errors[c784fdfe1899a22d]::ExplicitBug>::{closure#0}
  15:     0x7f42b4556a66 - std[4cb245a8c4fcbb2b]::sys_common::backtrace::__rust_end_short_backtrace::<std[4cb245a8c4fcbb2b]::panicking::begin_panic<rustc_errors[c784fdfe1899a22d]::ExplicitBug>::{closure#0}, !>
  16:     0x7f42b4551ed6 - std[4cb245a8c4fcbb2b]::panicking::begin_panic::<rustc_errors[c784fdfe1899a22d]::ExplicitBug>
  17:     0x7f42b4565481 - <rustc_errors[c784fdfe1899a22d]::diagnostic_builder::BugAbort as rustc_errors[c784fdfe1899a22d]::diagnostic_builder::EmissionGuarantee>::emit_producing_guarantee
  18:     0x7f42b4ad7d7d - rustc_middle[f70515e6cf4402ab]::util::bug::opt_span_bug_fmt::<rustc_span[d717321976fe2f69]::span_encoding::Span>::{closure#0}
  19:     0x7f42b4ad7daa - rustc_middle[f70515e6cf4402ab]::ty::context::tls::with_opt::<rustc_middle[f70515e6cf4402ab]::util::bug::opt_span_bug_fmt<rustc_span[d717321976fe2f69]::span_encoding::Span>::{closure#0}, !>::{closure#0}
  20:     0x7f42b4ace3c8 - rustc_middle[f70515e6cf4402ab]::ty::context::tls::with_context_opt::<rustc_middle[f70515e6cf4402ab]::ty::context::tls::with_opt<rustc_middle[f70515e6cf4402ab]::util::bug::opt_span_bug_fmt<rustc_span[d717321976fe2f69]::span_encoding::Span>::{closure#0}, !>::{closure#0}, !>
  21:     0x7f42b4ace0f4 - rustc_middle[f70515e6cf4402ab]::util::bug::span_bug_fmt::<rustc_span[d717321976fe2f69]::span_encoding::Span>
  22:     0x7f42b3a6236f - <rustc_mir_transform[4191524f0088c9a1]::check_packed_ref::CheckPackedRef as rustc_mir_transform[4191524f0088c9a1]::pass_manager::MirLint>::run_lint
  23:     0x7f42b58109e6 - rustc_mir_transform[4191524f0088c9a1]::pass_manager::run_passes_inner
  24:     0x7f42b59c7b20 - rustc_mir_transform[4191524f0088c9a1]::mir_const
  25:     0x7f42b59c78a3 - rustc_query_impl[24bd5f0faa3cd235]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[24bd5f0faa3cd235]::query_impl::mir_const::dynamic_query::{closure#2}::{closure#0}, rustc_middle[f70515e6cf4402ab]::query::erase::Erased<[u8; 8usize]>>
  26:     0x7f42b59c5d3a - rustc_query_system[89d43ac98090ee26]::query::plumbing::try_execute_query::<rustc_query_impl[24bd5f0faa3cd235]::DynamicConfig<rustc_query_system[89d43ac98090ee26]::query::caches::VecCache<rustc_span[d717321976fe2f69]::def_id::LocalDefId, rustc_middle[f70515e6cf4402ab]::query::erase::Erased<[u8; 8usize]>>, false, false, false>, rustc_query_impl[24bd5f0faa3cd235]::plumbing::QueryCtxt, false>
  27:     0x7f42b59c5790 - rustc_query_impl[24bd5f0faa3cd235]::query_impl::mir_const::get_query_non_incr::__rust_end_short_backtrace
  28:     0x7f42b39ff692 - rustc_mir_transform[4191524f0088c9a1]::mir_promoted
  29:     0x7f42b5e185d2 - rustc_query_impl[24bd5f0faa3cd235]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[24bd5f0faa3cd235]::query_impl::mir_promoted::dynamic_query::{closure#2}::{closure#0}, rustc_middle[f70515e6cf4402ab]::query::erase::Erased<[u8; 16usize]>>
  30:     0x7f42b5e18886 - rustc_query_system[89d43ac98090ee26]::query::plumbing::try_execute_query::<rustc_query_impl[24bd5f0faa3cd235]::DynamicConfig<rustc_query_system[89d43ac98090ee26]::query::caches::VecCache<rustc_span[d717321976fe2f69]::def_id::LocalDefId, rustc_middle[f70515e6cf4402ab]::query::erase::Erased<[u8; 16usize]>>, false, false, false>, rustc_query_impl[24bd5f0faa3cd235]::plumbing::QueryCtxt, false>
  31:     0x7f42b65d2cd3 - rustc_query_impl[24bd5f0faa3cd235]::query_impl::mir_promoted::get_query_non_incr::__rust_end_short_backtrace
  32:     0x7f42b65d2dee - rustc_borrowck[175cb04afc6ac2bf]::mir_borrowck
  33:     0x7f42b65d2d19 - rustc_query_impl[24bd5f0faa3cd235]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[24bd5f0faa3cd235]::query_impl::mir_borrowck::dynamic_query::{closure#2}::{closure#0}, rustc_middle[f70515e6cf4402ab]::query::erase::Erased<[u8; 8usize]>>
  34:     0x7f42b59c5d3a - rustc_query_system[89d43ac98090ee26]::query::plumbing::try_execute_query::<rustc_query_impl[24bd5f0faa3cd235]::DynamicConfig<rustc_query_system[89d43ac98090ee26]::query::caches::VecCache<rustc_span[d717321976fe2f69]::def_id::LocalDefId, rustc_middle[f70515e6cf4402ab]::query::erase::Erased<[u8; 8usize]>>, false, false, false>, rustc_query_impl[24bd5f0faa3cd235]::plumbing::QueryCtxt, false>
  35:     0x7f42b59c56d0 - rustc_query_impl[24bd5f0faa3cd235]::query_impl::mir_borrowck::get_query_non_incr::__rust_end_short_backtrace
  36:     0x7f42b61dfb67 - rustc_interface[e833383f6d6bccbe]::passes::analysis
  37:     0x7f42b61df65f - rustc_query_impl[24bd5f0faa3cd235]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[24bd5f0faa3cd235]::query_impl::analysis::dynamic_query::{closure#2}::{closure#0}, rustc_middle[f70515e6cf4402ab]::query::erase::Erased<[u8; 1usize]>>
  38:     0x7f42b6508db2 - rustc_query_system[89d43ac98090ee26]::query::plumbing::try_execute_query::<rustc_query_impl[24bd5f0faa3cd235]::DynamicConfig<rustc_query_system[89d43ac98090ee26]::query::caches::SingleCache<rustc_middle[f70515e6cf4402ab]::query::erase::Erased<[u8; 1usize]>>, false, false, false>, rustc_query_impl[24bd5f0faa3cd235]::plumbing::QueryCtxt, false>
  39:     0x7f42b6508b15 - rustc_query_impl[24bd5f0faa3cd235]::query_impl::analysis::get_query_non_incr::__rust_end_short_backtrace
  40:     0x7f42b6517b82 - rustc_interface[e833383f6d6bccbe]::interface::run_compiler::<core[9c9cc17aadeb336b]::result::Result<(), rustc_span[d717321976fe2f69]::ErrorGuaranteed>, rustc_driver_impl[d92334f8e0b5c69f]::run_compiler::{closure#0}>::{closure#0}
  41:     0x7f42b6793306 - std[4cb245a8c4fcbb2b]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[e833383f6d6bccbe]::util::run_in_thread_with_globals<rustc_interface[e833383f6d6bccbe]::util::run_in_thread_pool_with_globals<rustc_interface[e833383f6d6bccbe]::interface::run_compiler<core[9c9cc17aadeb336b]::result::Result<(), rustc_span[d717321976fe2f69]::ErrorGuaranteed>, rustc_driver_impl[d92334f8e0b5c69f]::run_compiler::{closure#0}>::{closure#0}, core[9c9cc17aadeb336b]::result::Result<(), rustc_span[d717321976fe2f69]::ErrorGuaranteed>>::{closure#0}, core[9c9cc17aadeb336b]::result::Result<(), rustc_span[d717321976fe2f69]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[9c9cc17aadeb336b]::result::Result<(), rustc_span[d717321976fe2f69]::ErrorGuaranteed>>
  42:     0x7f42b6793133 - <<std[4cb245a8c4fcbb2b]::thread::Builder>::spawn_unchecked_<rustc_interface[e833383f6d6bccbe]::util::run_in_thread_with_globals<rustc_interface[e833383f6d6bccbe]::util::run_in_thread_pool_with_globals<rustc_interface[e833383f6d6bccbe]::interface::run_compiler<core[9c9cc17aadeb336b]::result::Result<(), rustc_span[d717321976fe2f69]::ErrorGuaranteed>, rustc_driver_impl[d92334f8e0b5c69f]::run_compiler::{closure#0}>::{closure#0}, core[9c9cc17aadeb336b]::result::Result<(), rustc_span[d717321976fe2f69]::ErrorGuaranteed>>::{closure#0}, core[9c9cc17aadeb336b]::result::Result<(), rustc_span[d717321976fe2f69]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[9c9cc17aadeb336b]::result::Result<(), rustc_span[d717321976fe2f69]::ErrorGuaranteed>>::{closure#1} as core[9c9cc17aadeb336b]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  43:     0x7f42b77f1eb5 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h9eb8a991c9116b63
                               at /rustc/d44e3b95cb9d410d89cb8ab3233906a33f43756a/library/alloc/src/boxed.rs:2015:9
  44:     0x7f42b77f1eb5 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h8c75f09e06980632
                               at /rustc/d44e3b95cb9d410d89cb8ab3233906a33f43756a/library/alloc/src/boxed.rs:2015:9
  45:     0x7f42b77f1eb5 - std::sys::pal::unix::thread::Thread::new::thread_start::hdaf36e3abe8ac6ae
                               at /rustc/d44e3b95cb9d410d89cb8ab3233906a33f43756a/library/std/src/sys/pal/unix/thread.rs:108:17
  46:     0x7f42b16aa9eb - <unknown>
  47:     0x7f42b172e7cc - <unknown>
  48:                0x0 - <unknown>

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 (d44e3b95c 2024-02-09) running on x86_64-unknown-linux-gnu

query stack during panic:
#0 [mir_const] preparing `<impl at /tmp/icemaker_global_tempdir.5YBiqSYbKJwL/rustc_testrunner_tmpdir_reporting.vAXos37lSTVP/mvce.rs:5:10: 5:19>::eq` for borrow checking
#1 [mir_promoted] promoting constants in MIR for `<impl at /tmp/icemaker_global_tempdir.5YBiqSYbKJwL/rustc_testrunner_tmpdir_reporting.vAXos37lSTVP/mvce.rs:5:10: 5:19>::eq`
#2 [mir_borrowck] borrow-checking `<impl at /tmp/icemaker_global_tempdir.5YBiqSYbKJwL/rustc_testrunner_tmpdir_reporting.vAXos37lSTVP/mvce.rs:5:10: 5:19>::eq`
#3 [analysis] running analysis passes on this crate
end of query stack
error: aborting due to 3 previous errors

Some errors have detailed explanations: E0428, E0601.
For more information about an error, try `rustc --explain E0428`.

@matthiaskrgr matthiaskrgr added 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. C-bug Category: This is a bug. labels Feb 10, 2024
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Feb 10, 2024
@matthiaskrgr
Copy link
Member Author

#120550 cc @oli-obk

@oli-obk oli-obk self-assigned this Feb 10, 2024
@oli-obk oli-obk removed the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Feb 10, 2024
@oli-obk
Copy link
Contributor

oli-obk commented Mar 5, 2024

This ICE was reachable since 7 years, just noone ever wrote obscure code like that: #121025 (comment)

@oli-obk oli-obk removed their assignment Mar 5, 2024
@vext01
Copy link
Contributor

vext01 commented Apr 2, 2024

I've just encountered the same ICE and reduced it down to the following (playground):

#[derive(Debug)]
#[repr(packed)]
enum E {
    A(u16),
}

#[derive(Debug)]
#[repr(packed)]
struct S {
    xs: [u8; 3],
    e: E,
}

This gives:

error[E0517]: attribute should be applied to a struct or union
 --> src/lib.rs:2:8
  |
2 |   #[repr(packed)]
  |          ^^^^^^
3 | / enum E {
4 | |     A(u16),
5 | | }
  | |_- not a struct or union

error: internal compiler error: compiler/rustc_mir_transform/src/check_packed_ref.rs:49:21: builtin derive created an unaligned reference
 --> src/lib.rs:4:7
  |
1 | #[derive(Debug)]
  |          ----- in this derive macro expansion
...
4 |     A(u16),
  |       ^^^
  |
  = note: this error: internal compiler error originates in the derive macro `Debug` (in Nightly builds, run with -Z macro-backtrace for more info)

thread 'rustc' panicked at compiler/rustc_mir_transform/src/check_packed_ref.rs:49:21:
Box<dyn Any>
stack backtrace:
   0:     0x7f9275a6bab5 - std::backtrace_rs::backtrace::libunwind::trace::h5e86bffdda571081
                               at /rustc/1684a753dbca5d23b2e03568e6fbbb48eb72d0e6/library/std/src/../../backtrace/src/backtrace/libunwind.rs:105:5
   1:     0x7f9275a6bab5 - std::backtrace_rs::backtrace::trace_unsynchronized::h4840edcbcc7e117b
                               at /rustc/1684a753dbca5d23b2e03568e6fbbb48eb72d0e6/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x7f9275a6bab5 - std::sys_common::backtrace::_print_fmt::h49f9d2a3b38d3265
                               at /rustc/1684a753dbca5d23b2e03568e6fbbb48eb72d0e6/library/std/src/sys_common/backtrace.rs:68:5
   3:     0x7f9275a6bab5 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h22fedb9c27df8384
                               at /rustc/1684a753dbca5d23b2e03568e6fbbb48eb72d0e6/library/std/src/sys_common/backtrace.rs:44:22
   4:     0x7f9275abacfb - core::fmt::rt::Argument::fmt::h7d92fedbe4ca8dae
                               at /rustc/1684a753dbca5d23b2e03568e6fbbb48eb72d0e6/library/core/src/fmt/rt.rs:142:9
   5:     0x7f9275abacfb - core::fmt::write::h239b5b3f6d552091
                               at /rustc/1684a753dbca5d23b2e03568e6fbbb48eb72d0e6/library/core/src/fmt/mod.rs:1153:17
   6:     0x7f9275a6069f - std::io::Write::write_fmt::h104f15578b8aef5e
                               at /rustc/1684a753dbca5d23b2e03568e6fbbb48eb72d0e6/library/std/src/io/mod.rs:1843:15
   7:     0x7f9275a6b88e - std::sys_common::backtrace::_print::h01bdd24d8b8cf2a6
                               at /rustc/1684a753dbca5d23b2e03568e6fbbb48eb72d0e6/library/std/src/sys_common/backtrace.rs:47:5
   8:     0x7f9275a6b88e - std::sys_common::backtrace::print::haaea7f67046a5f9d
                               at /rustc/1684a753dbca5d23b2e03568e6fbbb48eb72d0e6/library/std/src/sys_common/backtrace.rs:34:9
   9:     0x7f9275a6e2d9 - std::panicking::default_hook::{{closure}}::hfdd7194dd22830d8
  10:     0x7f9275a6e043 - std::panicking::default_hook::h2423e5cd9c76c18c
                               at /rustc/1684a753dbca5d23b2e03568e6fbbb48eb72d0e6/library/std/src/panicking.rs:291:9
  11:     0x7f9278ade82f - std[ffd0afd40c23a66b]::panicking::update_hook::<alloc[55476579ce582906]::boxed::Box<rustc_driver_impl[e4eb3d84a143a5f9]::install_ice_hook::{closure#0}>>::{closure#0}
  12:     0x7f9275a6e9dc - <alloc::boxed::Box<F,A> as core::ops::function::Fn<Args>>::call::h4f7174da91e62aae
                               at /rustc/1684a753dbca5d23b2e03568e6fbbb48eb72d0e6/library/alloc/src/boxed.rs:2032:9
  13:     0x7f9275a6e9dc - std::panicking::rust_panic_with_hook::h13aa4870c5fa7445
                               at /rustc/1684a753dbca5d23b2e03568e6fbbb48eb72d0e6/library/std/src/panicking.rs:792:13
  14:     0x7f9278b0e7b4 - std[ffd0afd40c23a66b]::panicking::begin_panic::<rustc_errors[b7d6246ad40612af]::ExplicitBug>::{closure#0}
  15:     0x7f9278b0b526 - std[ffd0afd40c23a66b]::sys_common::backtrace::__rust_end_short_backtrace::<std[ffd0afd40c23a66b]::panicking::begin_panic<rustc_errors[b7d6246ad40612af]::ExplicitBug>::{closure#0}, !>
  16:     0x7f9278b0b206 - std[ffd0afd40c23a66b]::panicking::begin_panic::<rustc_errors[b7d6246ad40612af]::ExplicitBug>
  17:     0x7f9278b17a11 - <rustc_errors[b7d6246ad40612af]::diagnostic::BugAbort as rustc_errors[b7d6246ad40612af]::diagnostic::EmissionGuarantee>::emit_producing_guarantee
  18:     0x7f92790a7138 - <rustc_errors[b7d6246ad40612af]::DiagCtxt>::span_bug::<rustc_span[b2d5999a99633be2]::span_encoding::Span, alloc[55476579ce582906]::string::String>
  19:     0x7f92790c785d - rustc_middle[b24e7ff436be1cdb]::util::bug::opt_span_bug_fmt::<rustc_span[b2d5999a99633be2]::span_encoding::Span>::{closure#0}
  20:     0x7f92790c788a - rustc_middle[b24e7ff436be1cdb]::ty::context::tls::with_opt::<rustc_middle[b24e7ff436be1cdb]::util::bug::opt_span_bug_fmt<rustc_span[b2d5999a99633be2]::span_encoding::Span>::{closure#0}, !>::{closure#0}
  21:     0x7f92790c090b - rustc_middle[b24e7ff436be1cdb]::ty::context::tls::with_context_opt::<rustc_middle[b24e7ff436be1cdb]::ty::context::tls::with_opt<rustc_middle[b24e7ff436be1cdb]::util::bug::opt_span_bug_fmt<rustc_span[b2d5999a99633be2]::span_encoding::Span>::{closure#0}, !>::{closure#0}, !>
  22:     0x7f92790c0297 - rustc_middle[b24e7ff436be1cdb]::util::bug::span_bug_fmt::<rustc_span[b2d5999a99633be2]::span_encoding::Span>
  23:     0x7f927a65a644 - <rustc_mir_transform[26553d121dafebc7]::check_packed_ref::CheckPackedRef as rustc_mir_transform[26553d121dafebc7]::pass_manager::MirLint>::run_lint
  24:     0x7f9279ee08cd - rustc_mir_transform[26553d121dafebc7]::pass_manager::run_passes_inner
  25:     0x7f927a2f26b9 - rustc_query_impl[e4150b7ad05f9ce5]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[e4150b7ad05f9ce5]::query_impl::mir_built::dynamic_query::{closure#2}::{closure#0}, rustc_middle[b24e7ff436be1cdb]::query::erase::Erased<[u8; 8usize]>>
  26:     0x7f927a0bc5b1 - rustc_query_system[e9aa61bedf025f9c]::query::plumbing::try_execute_query::<rustc_query_impl[e4150b7ad05f9ce5]::DynamicConfig<rustc_query_system[e9aa61bedf025f9c]::query::caches::VecCache<rustc_span[b2d5999a99633be2]::def_id::LocalDefId, rustc_middle[b24e7ff436be1cdb]::query::erase::Erased<[u8; 8usize]>>, false, false, false>, rustc_query_impl[e4150b7ad05f9ce5]::plumbing::QueryCtxt, false>
  27:     0x7f927a0bc18c - rustc_query_impl[e4150b7ad05f9ce5]::query_impl::mir_built::get_query_non_incr::__rust_end_short_backtrace
  28:     0x7f927a83bf8f - rustc_mir_build[74f63c492aaa1616]::check_unsafety::check_unsafety
  29:     0x7f927a83bced - rustc_query_impl[e4150b7ad05f9ce5]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[e4150b7ad05f9ce5]::query_impl::check_unsafety::dynamic_query::{closure#2}::{closure#0}, rustc_middle[b24e7ff436be1cdb]::query::erase::Erased<[u8; 0usize]>>
  30:     0x7f927a3d1ac6 - rustc_query_system[e9aa61bedf025f9c]::query::plumbing::try_execute_query::<rustc_query_impl[e4150b7ad05f9ce5]::DynamicConfig<rustc_query_system[e9aa61bedf025f9c]::query::caches::VecCache<rustc_span[b2d5999a99633be2]::def_id::LocalDefId, rustc_middle[b24e7ff436be1cdb]::query::erase::Erased<[u8; 0usize]>>, false, false, false>, rustc_query_impl[e4150b7ad05f9ce5]::plumbing::QueryCtxt, false>
  31:     0x7f927a3d16ff - rustc_query_impl[e4150b7ad05f9ce5]::query_impl::check_unsafety::get_query_non_incr::__rust_end_short_backtrace
  32:     0x7f927a3cda7c - rustc_interface[93c8c2723e408a6]::passes::analysis
  33:     0x7f927a3ccb9b - rustc_query_impl[e4150b7ad05f9ce5]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[e4150b7ad05f9ce5]::query_impl::analysis::dynamic_query::{closure#2}::{closure#0}, rustc_middle[b24e7ff436be1cdb]::query::erase::Erased<[u8; 1usize]>>
  34:     0x7f927ad0b1a5 - rustc_query_system[e9aa61bedf025f9c]::query::plumbing::try_execute_query::<rustc_query_impl[e4150b7ad05f9ce5]::DynamicConfig<rustc_query_system[e9aa61bedf025f9c]::query::caches::SingleCache<rustc_middle[b24e7ff436be1cdb]::query::erase::Erased<[u8; 1usize]>>, false, false, false>, rustc_query_impl[e4150b7ad05f9ce5]::plumbing::QueryCtxt, false>
  35:     0x7f927ad0af09 - rustc_query_impl[e4150b7ad05f9ce5]::query_impl::analysis::get_query_non_incr::__rust_end_short_backtrace
  36:     0x7f927ab9ead3 - rustc_interface[93c8c2723e408a6]::interface::run_compiler::<core[191c6f300f408019]::result::Result<(), rustc_span[b2d5999a99633be2]::ErrorGuaranteed>, rustc_driver_impl[e4eb3d84a143a5f9]::run_compiler::{closure#0}>::{closure#0}
  37:     0x7f927ac6bbd3 - std[ffd0afd40c23a66b]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[93c8c2723e408a6]::util::run_in_thread_with_globals<rustc_interface[93c8c2723e408a6]::util::run_in_thread_pool_with_globals<rustc_interface[93c8c2723e408a6]::interface::run_compiler<core[191c6f300f408019]::result::Result<(), rustc_span[b2d5999a99633be2]::ErrorGuaranteed>, rustc_driver_impl[e4eb3d84a143a5f9]::run_compiler::{closure#0}>::{closure#0}, core[191c6f300f408019]::result::Result<(), rustc_span[b2d5999a99633be2]::ErrorGuaranteed>>::{closure#0}, core[191c6f300f408019]::result::Result<(), rustc_span[b2d5999a99633be2]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[191c6f300f408019]::result::Result<(), rustc_span[b2d5999a99633be2]::ErrorGuaranteed>>
  38:     0x7f927ac6b9e1 - <<std[ffd0afd40c23a66b]::thread::Builder>::spawn_unchecked_<rustc_interface[93c8c2723e408a6]::util::run_in_thread_with_globals<rustc_interface[93c8c2723e408a6]::util::run_in_thread_pool_with_globals<rustc_interface[93c8c2723e408a6]::interface::run_compiler<core[191c6f300f408019]::result::Result<(), rustc_span[b2d5999a99633be2]::ErrorGuaranteed>, rustc_driver_impl[e4eb3d84a143a5f9]::run_compiler::{closure#0}>::{closure#0}, core[191c6f300f408019]::result::Result<(), rustc_span[b2d5999a99633be2]::ErrorGuaranteed>>::{closure#0}, core[191c6f300f408019]::result::Result<(), rustc_span[b2d5999a99633be2]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[191c6f300f408019]::result::Result<(), rustc_span[b2d5999a99633be2]::ErrorGuaranteed>>::{closure#1} as core[191c6f300f408019]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  39:     0x7f9275a783fb - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h61713b2cd6851117
                               at /rustc/1684a753dbca5d23b2e03568e6fbbb48eb72d0e6/library/alloc/src/boxed.rs:2018:9
  40:     0x7f9275a783fb - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h040bc52a2545405a
                               at /rustc/1684a753dbca5d23b2e03568e6fbbb48eb72d0e6/library/alloc/src/boxed.rs:2018:9
  41:     0x7f9275a783fb - std::sys::pal::unix::thread::Thread::new::thread_start::h5a10eabef2ee4b3d
                               at /rustc/1684a753dbca5d23b2e03568e6fbbb48eb72d0e6/library/std/src/sys/pal/unix/thread.rs:108:17
  42:     0x7f9275985609 - start_thread
  43:     0x7f92758a8353 - clone
  44:                0x0 - <unknown>

note: it seems that this compiler `1.79.0-nightly (1684a753d 2024-04-01)` is outdated, a newer nightly should have been released in the mean time
  |
  = note: please consider running `rustup update nightly` to update the nightly channel and check if this problem still persists
  = note: if the problem still persists, 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 attach the file at `/playground/rustc-ice-2024-04-02T14_11_10-36.txt` to your bug report

note: compiler flags: --crate-type lib -C embed-bitcode=no -C codegen-units=1 -C debuginfo=2

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

query stack during panic:
#0 [mir_built] building MIR for `<impl at src/lib.rs:1:10: 1:15>::fmt`
#1 [check_unsafety] unsafety-checking `<impl at src/lib.rs:1:10: 1:15>::fmt`
#2 [analysis] running analysis passes on this crate
end of query stack
error[E0507]: cannot move out of `self.e` which is behind a shared reference
  --> src/lib.rs:11:5
   |
7  | #[derive(Debug)]
   |          ----- in this derive macro expansion
...
11 |     e: E,
   |     ^^^^ move occurs because `self.e` has type `E`, which does not implement the `Copy` trait
   |
   = note: `#[derive(Debug)]` triggers a move because taking references to the fields of a packed struct is undefined behaviour
   = note: this error originates in the derive macro `Debug` (in Nightly builds, run with -Z macro-backtrace for more info)

Some errors have detailed explanations: E0507, E0517.
For more information about an error, try `rustc --explain E0507`.
error: could not compile `playground` (lib) due to 2 previous errors

#[repr(packed)] on an enum is incorrect, but it shouldn't ICE.

This is today's nightly on amd64.

Thanks

@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. 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

No branches or pull requests

4 participants