Repository navigation
Closed
Closed
Copy link
Labels
A-macrosArea: All kinds of macros (custom derive, macro_rules!, proc macros, ..)Area: All kinds of macros (custom derive, macro_rules!, proc macros, ..)A-repr-packedArea: the naughtiest reprArea: the naughtiest reprC-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.
Description
Code
#[derive(Debug)]
#[repr(packed)]
enum COption<T> {
None,
Some(T),
}
fn main() {
}Meta
rustc --version --verbose:
rustc 1.82.0 (f6e511eec 2024-10-15) (Fedora 1.82.0-1.fc40)
binary: rustc
commit-hash: f6e511eec7342f59a25f7c0534f1dbea00d01b14
commit-date: 2024-10-15
host: x86_64-unknown-linux-gnu
release: 1.82.0
LLVM version: 18.1.8
Error output
error: internal compiler error: compiler/rustc_mir_transform/src/check_packed_ref.rs:49:21: builtin derive created an unaligned reference
--> src/main.rs:5:10
|
1 | #[derive(Debug)]
| ----- in this derive macro expansion
...
5 | Some(T),
| ^
|
= 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: 0x7fd20cb85b78 - <std::sys::backtrace::BacktraceLock::print::DisplayBacktrace as core::fmt::Display>::fmt::h1ceeeb1b55e290c2
1: 0x7fd20c582b9b - core::fmt::write::hb3a48913f78b0dae
2: 0x7fd20cb78ba3 - <unknown>
3: 0x7fd20cb887ea - <unknown>
4: 0x7fd20cb8842c - std::panicking::default_hook::h49089136d7ad7532
5: 0x7fd20a1425ad - <unknown>
6: 0x7fd20cb891e6 - std::panicking::rust_panic_with_hook::ha43241025fb228f0
7: 0x7fd20a18c221 - <unknown>
8: 0x7fd20a17c246 - <unknown>
9: 0x7fd20a17bfc6 - <unknown>
10: 0x7fd20a19a8e1 - <rustc_errors[9a66caa3f8a65bb2]::diagnostic::BugAbort as rustc_errors[9a66caa3f8a65bb2]::diagnostic::EmissionGuarantee>::emit_producing_guarantee
11: 0x7fd20a92c36d - <unknown>
12: 0x7fd20a96b188 - <unknown>
13: 0x7fd20a96bada - <unknown>
14: 0x7fd20a9570db - <unknown>
15: 0x7fd20a94dd57 - <unknown>
16: 0x7fd20be2d539 - <unknown>
17: 0x7fd20bf150eb - rustc_mir_transform[ec94f2ac466ce048]::mir_built
18: 0x7fd20c1c6467 - <unknown>
19: 0x7fd20ac4e640 - <unknown>
20: 0x7fd20ac3cb28 - <unknown>
21: 0x7fd20ad4ed98 - <unknown>
22: 0x7fd20bd63e17 - rustc_mir_build[b87ccf4b6ee18353]::check_unsafety::check_unsafety
23: 0x7fd20c1b87f7 - <unknown>
24: 0x7fd20ac4dd90 - <unknown>
25: 0x7fd20ac3714e - <unknown>
26: 0x7fd20ad5d45f - <unknown>
27: 0x7fd20baa8cbb - <unknown>
28: 0x7fd20c8bd509 - rustc_interface[73b4cfe22fadb0e6]::passes::analysis
29: 0x7fd20ca728b7 - <unknown>
30: 0x7fd20ac4d70f - <unknown>
31: 0x7fd20ac06129 - <unknown>
32: 0x7fd20ad49194 - <unknown>
33: 0x7fd20c7b0ee4 - <unknown>
34: 0x7fd20c7ad945 - <unknown>
35: 0x7fd20c7b3dd0 - <unknown>
36: 0x7fd20cb952ab - <unknown>
37: 0x7fd2094a66d7 - start_thread
38: 0x7fd20952a60c - __clone3
39: 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.82.0 (f6e511eec 2024-10-15) (Fedora 1.82.0-1.fc40) running on x86_64-unknown-linux-gnu
note: compiler flags: --crate-type bin -C embed-bitcode=no -C debuginfo=2 -C incremental=[REDACTED]
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`
end of query stack
Backtrace
error: internal compiler error: compiler/rustc_mir_transform/src/check_packed_ref.rs:49:21: builtin derive created an unaligned reference
--> src/main.rs:5:10
|
1 | #[derive(Debug)]
| ----- in this derive macro expansion
...
5 | Some(T),
| ^
|
= 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:
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
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.82.0 (f6e511eec 2024-10-15) (Fedora 1.82.0-1.fc40) running on x86_64-unknown-linux-gnu
note: compiler flags: --crate-type bin -C embed-bitcode=no -C debuginfo=2 -C incremental=[REDACTED]
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`
#2 [analysis] running analysis passes on this crate
end of query stack
Metadata
Metadata
Assignees
Labels
A-macrosArea: All kinds of macros (custom derive, macro_rules!, proc macros, ..)Area: All kinds of macros (custom derive, macro_rules!, proc macros, ..)A-repr-packedArea: the naughtiest reprArea: the naughtiest reprC-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.
Activity
Noratrieb commentedon Nov 14, 2024
repr(packed)on enums is not allowed. I suspect the easiest fix is to make the derive macro error or expand to nothing when it sees repr(packed). alternatively, the MIR transform could just ignore enums.zachs18 commentedon Nov 14, 2024
This appears to have regressed in 1.78.0 on stable (1.77.0 does not ICE), or
nightly-2024-02-09.bisection
Bisection determined this regressed in
nightly-2024-02-09, but there's no CI artifacts from that far back, so I'm not sure which PR led to the ICE.Bisected with
cargo bisect-rustc --start=1.77.0 --end=1.78.0 --regress icematthiaskrgr commentedon Nov 14, 2024
Duplicate of #120873 I think
Noratrieb commentedon Nov 14, 2024
don't think so
matthiaskrgr commentedon Nov 14, 2024
What difference do you see?
The stacktrace of
is identical to #120873 (comment)
Noratrieb commentedon Nov 14, 2024
Yes, it's the exact same check firing. But I think the check is firing for entirely different reasons. It could be the same but I'd be surprised. It's nice to have the links between the two issues because they are similar but I certainly wouldn't close this.
el-ev commentedon Dec 26, 2024
Introduced by eab2adb.
moxian commentedon Mar 11, 2025
Both this and #120873 bisect same way to nightly-2024-02-09
Even though the ICE has been triggerable since 2017 (#120873 (comment))
Either way,
@rustbot label: -E-needs-bisection
Rollup merge of rust-lang#162717 - cyrgani:one-ice-less-derived, r=fo…
Rollup merge of rust-lang#162717 - cyrgani:one-ice-less-derived, r=fo…
Unrolled build for #162717 in rollup 162742