#[repr(simd)]
enum Aligned {
Zero = 0,
One = 1,
}
fn tou8(al: Aligned) -> u8 {
al as u8
}
original:
// run-pass
// allows aligned custom discriminant enums to cast into other types
// See the issue #92464 for more info
#[allow(dead_code)]
#[repr(simd)]
enum Aligned {
Zero = 0,
One = 1,
}
fn main() {
let aligned = Aligned::Zero;
let fo = aligned as u8;
println!("foo {}", fo);
assert_eq!(fo, 0);
println!("{}", tou8(Aligned::Zero));
assert_eq!(tou8(Aligned::Zero), 0);
}
#[inline(never)]
fn tou8(al: Aligned) -> u8 {
// Cast behind a function call so ConstProp does not see it
// (so that we can test codegen).
al as u8
}
auto-reduced (treereduce-rust):
original:
Version information
Command:
/home/matthias/.rustup/toolchains/master/bin/rustc
Program output
``` error[E0601]: `main` function not found in crate `mvce` --> /tmp/icemaker_global_tempdir.SYcwJ0ZhbP03/rustc_testrunner_tmpdir_reporting.auBmqDN1Oibq/mvce.rs:9:2 | 9 | } | ^ consider adding a `main` function to `/tmp/icemaker_global_tempdir.SYcwJ0ZhbP03/rustc_testrunner_tmpdir_reporting.auBmqDN1Oibq/mvce.rs` error[E0517]: attribute should be applied to a struct --> /tmp/icemaker_global_tempdir.SYcwJ0ZhbP03/rustc_testrunner_tmpdir_reporting.auBmqDN1Oibq/mvce.rs:1:8 | 1 | #[repr(simd)] | ^^^^ 2 | / enum Aligned { 3 | | Zero = 0, 4 | | One = 1, 5 | | } | |_- not a struct thread 'rustc' panicked at compiler/rustc_mir_build/src/build/expr/as_rvalue.rs:222:57: called `Result::unwrap()` on an `Err` value: Unknown(Aligned) stack backtrace: 0: 0x7f0dba78ce46 - std::backtrace_rs::backtrace::libunwind::trace::h741b35e6ebf0ea82 at /rustc/340bb19fea20fd5f9357bbfac542fad84fc7ea2b/library/std/src/../../backtrace/src/backtrace/libunwind.rs:104:5 1: 0x7f0dba78ce46 - std::backtrace_rs::backtrace::trace_unsynchronized::hf3b09a36cbdb818e at /rustc/340bb19fea20fd5f9357bbfac542fad84fc7ea2b/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5 2: 0x7f0dba78ce46 - std::sys_common::backtrace::_print_fmt::hd9ddcb56e855ae1f at /rustc/340bb19fea20fd5f9357bbfac542fad84fc7ea2b/library/std/src/sys_common/backtrace.rs:68:5 3: 0x7f0dba78ce46 -::fmt::h1d659f3f1b376713
at /rustc/340bb19fea20fd5f9357bbfac542fad84fc7ea2b/library/std/src/sys_common/backtrace.rs:44:22
4: 0x7f0dba7dd46c - core::fmt::rt::Argument::fmt::h268aa39b6fb00372
at /rustc/340bb19fea20fd5f9357bbfac542fad84fc7ea2b/library/core/src/fmt/rt.rs:142:9
5: 0x7f0dba7dd46c - core::fmt::write::h3ca4c8a121ee4a21
at /rustc/340bb19fea20fd5f9357bbfac542fad84fc7ea2b/library/core/src/fmt/mod.rs:1120:17
6: 0x7f0dba78087f - std::io::Write::write_fmt::hbae5643614f30ef5
at /rustc/340bb19fea20fd5f9357bbfac542fad84fc7ea2b/library/std/src/io/mod.rs:1854:15
7: 0x7f0dba78cbf4 - std::sys_common::backtrace::_print::h46251963e880a6db
at /rustc/340bb19fea20fd5f9357bbfac542fad84fc7ea2b/library/std/src/sys_common/backtrace.rs:47:5
8: 0x7f0dba78cbf4 - std::sys_common::backtrace::print::hf7d8eafd5758e700
at /rustc/340bb19fea20fd5f9357bbfac542fad84fc7ea2b/library/std/src/sys_common/backtrace.rs:34:9
9: 0x7f0dba78f93b - std::panicking::default_hook::{{closure}}::h762f7d01310422ff
10: 0x7f0dba78f689 - std::panicking::default_hook::h6bf045830ee7f539
at /rustc/340bb19fea20fd5f9357bbfac542fad84fc7ea2b/library/std/src/panicking.rs:292:9
11: 0x7f0dbd5f2bac - std[3c399c9137e7035e]::panicking::update_hook::>::{closure#0}
12: 0x7f0dba7900a0 - as core::ops::function::Fn>::call::h183d4d6c4a9f8452
at /rustc/340bb19fea20fd5f9357bbfac542fad84fc7ea2b/library/alloc/src/boxed.rs:2030:9
13: 0x7f0dba7900a0 - std::panicking::rust_panic_with_hook::hf47919d70d1ff480
at /rustc/340bb19fea20fd5f9357bbfac542fad84fc7ea2b/library/std/src/panicking.rs:785:13
14: 0x7f0dba78fde2 - std::panicking::begin_panic_handler::{{closure}}::h5fbc7433175e9186
at /rustc/340bb19fea20fd5f9357bbfac542fad84fc7ea2b/library/std/src/panicking.rs:659:13
15: 0x7f0dba78d326 - std::sys_common::backtrace::__rust_end_short_backtrace::h2b0c01029bb6a245
at /rustc/340bb19fea20fd5f9357bbfac542fad84fc7ea2b/library/std/src/sys_common/backtrace.rs:171:18
16: 0x7f0dba78fb14 - rust_begin_unwind
at /rustc/340bb19fea20fd5f9357bbfac542fad84fc7ea2b/library/std/src/panicking.rs:647:5
17: 0x7f0dba7d9975 - core::panicking::panic_fmt::h213e6f8381440dd9
at /rustc/340bb19fea20fd5f9357bbfac542fad84fc7ea2b/library/core/src/panicking.rs:72:14
18: 0x7f0dba7da023 - core::result::unwrap_failed::h2846c66592a52b33
at /rustc/340bb19fea20fd5f9357bbfac542fad84fc7ea2b/library/core/src/result.rs:1653:5
19: 0x7f0dbec72962 - ::as_rvalue
20: 0x7f0dbeefc114 - ::expr_into_dest
21: 0x7f0dbeefde7c - ::expr_into_dest
22: 0x7f0dbbc25273 - ::ast_block_stmts
23: 0x7f0dbeefcf0b - ::expr_into_dest
24: 0x7f0dbeefde7c - ::expr_into_dest
25: 0x7f0dbeef451d - rustc_mir_build[b81a605d07a272cd]::build::mir_build::{closure#0}
26: 0x7f0dbeef0933 - rustc_mir_build[b81a605d07a272cd]::build::mir_built
27: 0x7f0dbeef062b - rustc_query_impl[2b06c656d5e1ef18]::plumbing::__rust_begin_short_backtrace::>
28: 0x7f0dbe9858f0 - rustc_query_system[27a374b315d29eb0]::query::plumbing::try_execute_query::>, false, false, false>, rustc_query_impl[2b06c656d5e1ef18]::plumbing::QueryCtxt, false>
29: 0x7f0dbe98534c - rustc_query_impl[2b06c656d5e1ef18]::query_impl::mir_built::get_query_non_incr::__rust_end_short_backtrace
30: 0x7f0dbec75956 - rustc_mir_build[b81a605d07a272cd]::check_unsafety::check_unsafety
31: 0x7f0dbec75761 - rustc_query_impl[2b06c656d5e1ef18]::plumbing::__rust_begin_short_backtrace::>
32: 0x7f0dbefb978a - rustc_query_system[27a374b315d29eb0]::query::plumbing::try_execute_query::>, false, false, false>, rustc_query_impl[2b06c656d5e1ef18]::plumbing::QueryCtxt, false>
33: 0x7f0dbefb94cf - rustc_query_impl[2b06c656d5e1ef18]::query_impl::check_unsafety::get_query_non_incr::__rust_end_short_backtrace
34: 0x7f0dbf21378f - rustc_interface[85a46e65fd36dd64]::passes::analysis
35: 0x7f0dbf2131e9 - rustc_query_impl[2b06c656d5e1ef18]::plumbing::__rust_begin_short_backtrace::>
36: 0x7f0dbf7b0025 - rustc_query_system[27a374b315d29eb0]::query::plumbing::try_execute_query::>, false, false, false>, rustc_query_impl[2b06c656d5e1ef18]::plumbing::QueryCtxt, false>
37: 0x7f0dbf7afd89 - rustc_query_impl[2b06c656d5e1ef18]::query_impl::analysis::get_query_non_incr::__rust_end_short_backtrace
38: 0x7f0dbf62e055 - rustc_interface[85a46e65fd36dd64]::interface::run_compiler::, rustc_driver_impl[aed52aad4ff697f9]::run_compiler::{closure#0}>::{closure#0}
39: 0x7f0dbf7c7b58 - std[3c399c9137e7035e]::sys_common::backtrace::__rust_begin_short_backtrace::, rustc_driver_impl[aed52aad4ff697f9]::run_compiler::{closure#0}>::{closure#0}, core[7e3aa1eb1ad3b865]::result::Result<(), rustc_span[193b94924c128396]::ErrorGuaranteed>>::{closure#0}, core[7e3aa1eb1ad3b865]::result::Result<(), rustc_span[193b94924c128396]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[7e3aa1eb1ad3b865]::result::Result<(), rustc_span[193b94924c128396]::ErrorGuaranteed>>
40: 0x7f0dbf7c7984 - <::spawn_unchecked_, rustc_driver_impl[aed52aad4ff697f9]::run_compiler::{closure#0}>::{closure#0}, core[7e3aa1eb1ad3b865]::result::Result<(), rustc_span[193b94924c128396]::ErrorGuaranteed>>::{closure#0}, core[7e3aa1eb1ad3b865]::result::Result<(), rustc_span[193b94924c128396]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[7e3aa1eb1ad3b865]::result::Result<(), rustc_span[193b94924c128396]::ErrorGuaranteed>>::{closure#1} as core[7e3aa1eb1ad3b865]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
41: 0x7f0dba7991e5 - as core::ops::function::FnOnce>::call_once::h1516af221a452bc1
at /rustc/340bb19fea20fd5f9357bbfac542fad84fc7ea2b/library/alloc/src/boxed.rs:2016:9
42: 0x7f0dba7991e5 - as core::ops::function::FnOnce>::call_once::hff2a9d52ad89d581
at /rustc/340bb19fea20fd5f9357bbfac542fad84fc7ea2b/library/alloc/src/boxed.rs:2016:9
43: 0x7f0dba7991e5 - std::sys::pal::unix::thread::Thread::new::thread_start::hf359248e8c5b2b25
at /rustc/340bb19fea20fd5f9357bbfac542fad84fc7ea2b/library/std/src/sys/pal/unix/thread.rs:108:17
44: 0x7f0dba54a9eb -
45: 0x7f0dba5ce7cc -
46: 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 (340bb19fe 2024-02-14) running on x86_64-unknown-linux-gnu
query stack during panic:
#0 [mir_built] building MIR for `tou8`
#1 [check_unsafety] unsafety-checking `tou8`
#2 [analysis] running analysis passes on this crate
end of query stack
error: aborting due to 2 previous errors
Some errors have detailed explanations: E0517, E0601.
For more information about an error, try `rustc --explain E0517`.
```