Closed as duplicate of#133025
Closed as duplicate of#133025
Description
Code
#[derive(Debug)] // The same with `PartialEq`, for example
#[repr(packed)]
enum Enum {
A(Box<u32>),
}
fn main() {}
Meta
Stable in playground
Error output
Backtrace
Exited with status 101
Standard Error
Compiling playground v0.0.1 (/playground)
error[[E0517]](https://doc.rust-lang.org/stable/error_codes/E0517.html): attribute should be applied to a struct or union
--> src/main.rs:2:8
|
2 | #[repr(packed)]
| ^^^^^^
3 | / enum SlicedIE2 {
4 | | A(Box<u32>),
5 | | }
| |_- not a struct or union
error: internal compiler error: compiler/rustc_mir_transform/src/check_packed_ref.rs:49:17: builtin derive created an unaligned reference
--> src/main.rs:4:7
|
1 | #[derive(Debug)]
| ----- in this derive macro expansion
...
4 | A(Box<u32>),
| ^^^^^^^^
|
= 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:17:
Box<dyn Any>
stack backtrace:
0: 0x7b35499d6e40 - <std::sys::backtrace::BacktraceLock::print::DisplayBacktrace as core::fmt::Display>::fmt::h6d42cc84fc840290
1: 0x7b354a22867c - core::fmt::write::h5af61a909e3ec64d
2: 0x7b354b52ca51 - std::io::Write::write_fmt::h5a7b54aa6e4a315d
3: 0x7b35499d6ca2 - std::sys::backtrace::BacktraceLock::print::h555579e7396c26ac
4: 0x7b35499d9122 - std::panicking::default_hook::{{closure}}::h9128866118196224
5: 0x7b35499d8faa - std::panicking::default_hook::h52e9e7314e0255f6
6: 0x7b3548b33449 - std[d9e466a2d75004a2]::panicking::update_hook::<alloc[54bfe2542ace865d]::boxed::Box<rustc_driver_impl[680c351c5444d7cd]::install_ice_hook::{closure#1}>>::{closure#0}
7: 0x7b35499d9ca3 - std::panicking::rust_panic_with_hook::h541791bcc774ef34
8: 0x7b3548b6e3b1 - std[d9e466a2d75004a2]::panicking::begin_panic::<rustc_errors[90b6e0e1196d63f0]::ExplicitBug>::{closure#0}
9: 0x7b3548b63326 - std[d9e466a2d75004a2]::sys::backtrace::__rust_end_short_backtrace::<std[d9e466a2d75004a2]::panicking::begin_panic<rustc_errors[90b6e0e1196d63f0]::ExplicitBug>::{closure#0}, !>
10: 0x7b3548b6330d - std[d9e466a2d75004a2]::panicking::begin_panic::<rustc_errors[90b6e0e1196d63f0]::ExplicitBug>
11: 0x7b3548b78381 - <rustc_errors[90b6e0e1196d63f0]::diagnostic::BugAbort as rustc_errors[90b6e0e1196d63f0]::diagnostic::EmissionGuarantee>::emit_producing_guarantee
12: 0x7b35490ce80c - <rustc_errors[90b6e0e1196d63f0]::DiagCtxtHandle>::span_bug::<rustc_span[15ded62729b25549]::span_encoding::Span, alloc[54bfe2542ace865d]::string::String>
13: 0x7b354914ff37 - rustc_middle[a78c8f6c75429410]::util::bug::opt_span_bug_fmt::<rustc_span[15ded62729b25549]::span_encoding::Span>::{closure#0}
14: 0x7b3549138d6a - rustc_middle[a78c8f6c75429410]::ty::context::tls::with_opt::<rustc_middle[a78c8f6c75429410]::util::bug::opt_span_bug_fmt<rustc_span[15ded62729b25549]::span_encoding::Span>::{closure#0}, !>::{closure#0}
15: 0x7b3549138bfb - rustc_middle[a78c8f6c75429410]::ty::context::tls::with_context_opt::<rustc_middle[a78c8f6c75429410]::ty::context::tls::with_opt<rustc_middle[a78c8f6c75429410]::util::bug::opt_span_bug_fmt<rustc_span[15ded62729b25549]::span_encoding::Span>::{closure#0}, !>::{closure#0}, !>
16: 0x7b35478351e7 - rustc_middle[a78c8f6c75429410]::util::bug::span_bug_fmt::<rustc_span[15ded62729b25549]::span_encoding::Span>
17: 0x7b354aa9287b - <rustc_mir_transform[65d952cda38dbfd0]::check_packed_ref::CheckPackedRef as rustc_mir_transform[65d952cda38dbfd0]::pass_manager::MirLint>::run_lint
18: 0x7b354a20a265 - rustc_mir_transform[65d952cda38dbfd0]::mir_built
19: 0x7b354a20a033 - rustc_query_impl[abff21d8349146d]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[abff21d8349146d]::query_impl::mir_built::dynamic_query::{closure#2}::{closure#0}, rustc_middle[a78c8f6c75429410]::query::erase::Erased<[u8; 8usize]>>
20: 0x7b354a609857 - rustc_query_system[9464b8c501ef87f3]::query::plumbing::try_execute_query::<rustc_query_impl[abff21d8349146d]::DynamicConfig<rustc_data_structures[6e992f72641bf6c6]::vec_cache::VecCache<rustc_span[15ded62729b25549]::def_id::LocalDefId, rustc_middle[a78c8f6c75429410]::query::erase::Erased<[u8; 8usize]>, rustc_query_system[9464b8c501ef87f3]::dep_graph::graph::DepNodeIndex>, false, false, false>, rustc_query_impl[abff21d8349146d]::plumbing::QueryCtxt, false>
21: 0x7b354a60940d - rustc_query_impl[abff21d8349146d]::query_impl::mir_built::get_query_non_incr::__rust_end_short_backtrace
22: 0x7b354ac00058 - rustc_mir_build[b55d8ca8377cfad8]::check_unsafety::check_unsafety
23: 0x7b354abffec7 - rustc_query_impl[abff21d8349146d]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[abff21d8349146d]::query_impl::check_unsafety::dynamic_query::{closure#2}::{closure#0}, rustc_middle[a78c8f6c75429410]::query::erase::Erased<[u8; 0usize]>>
24: 0x7b354abff1b0 - rustc_query_system[9464b8c501ef87f3]::query::plumbing::try_execute_query::<rustc_query_impl[abff21d8349146d]::DynamicConfig<rustc_data_structures[6e992f72641bf6c6]::vec_cache::VecCache<rustc_span[15ded62729b25549]::def_id::LocalDefId, rustc_middle[a78c8f6c75429410]::query::erase::Erased<[u8; 0usize]>, rustc_query_system[9464b8c501ef87f3]::dep_graph::graph::DepNodeIndex>, false, false, false>, rustc_query_impl[abff21d8349146d]::plumbing::QueryCtxt, false>
25: 0x7b354abfee41 - rustc_query_impl[abff21d8349146d]::query_impl::check_unsafety::get_query_non_incr::__rust_end_short_backtrace
26: 0x7b354a602e2a - rustc_interface[84ab11ffe8dacd23]::passes::run_required_analyses
27: 0x7b354ad18f1e - rustc_interface[84ab11ffe8dacd23]::passes::analysis
28: 0x7b354ad18eef - rustc_query_impl[abff21d8349146d]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[abff21d8349146d]::query_impl::analysis::dynamic_query::{closure#2}::{closure#0}, rustc_middle[a78c8f6c75429410]::query::erase::Erased<[u8; 0usize]>>
29: 0x7b354b191015 - rustc_query_system[9464b8c501ef87f3]::query::plumbing::try_execute_query::<rustc_query_impl[abff21d8349146d]::DynamicConfig<rustc_query_system[9464b8c501ef87f3]::query::caches::SingleCache<rustc_middle[a78c8f6c75429410]::query::erase::Erased<[u8; 0usize]>>, false, false, false>, rustc_query_impl[abff21d8349146d]::plumbing::QueryCtxt, false>
30: 0x7b354b190d4e - rustc_query_impl[abff21d8349146d]::query_impl::analysis::get_query_non_incr::__rust_end_short_backtrace
31: 0x7b354b19aea9 - rustc_interface[84ab11ffe8dacd23]::passes::create_and_enter_global_ctxt::<core[46aa9df3d3dcdeb1]::option::Option<rustc_interface[84ab11ffe8dacd23]::queries::Linker>, rustc_driver_impl[680c351c5444d7cd]::run_compiler::{closure#0}::{closure#2}>::{closure#2}::{closure#0}
32: 0x7b354b1ab726 - rustc_interface[84ab11ffe8dacd23]::interface::run_compiler::<(), rustc_driver_impl[680c351c5444d7cd]::run_compiler::{closure#0}>::{closure#1}
33: 0x7b354b0e0744 - std[d9e466a2d75004a2]::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface[84ab11ffe8dacd23]::util::run_in_thread_with_globals<rustc_interface[84ab11ffe8dacd23]::util::run_in_thread_pool_with_globals<rustc_interface[84ab11ffe8dacd23]::interface::run_compiler<(), rustc_driver_impl[680c351c5444d7cd]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>
34: 0x7b354b0e0419 - <<std[d9e466a2d75004a2]::thread::Builder>::spawn_unchecked_<rustc_interface[84ab11ffe8dacd23]::util::run_in_thread_with_globals<rustc_interface[84ab11ffe8dacd23]::util::run_in_thread_pool_with_globals<rustc_interface[84ab11ffe8dacd23]::interface::run_compiler<(), rustc_driver_impl[680c351c5444d7cd]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>::{closure#1} as core[46aa9df3d3dcdeb1]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
35: 0x7b354b0dfbaf - std::sys::pal::unix::thread::Thread::new::thread_start::hcc5ed016d554f327
36: 0x7b354528aaa4 - <unknown>
37: 0x7b3545317a34 - clone
38: 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.86.0 (05f9846f8 2025-03-31) running on x86_64-unknown-linux-gnu
note: compiler flags: --crate-type bin -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/main.rs:1:10: 1:15>::fmt`
#1 [check_unsafety] unsafety-checking `<impl at src/main.rs:1:10: 1:15>::fmt`
... and 1 other queries... use `env RUST_BACKTRACE=1` to see the full query stack
For more information about this error, try `rustc --explain E0517`.
error: could not compile `playground` (bin "playground") due to 1 previous error
S