Closed
Description
snippet:
mod hybrid {
use std::mem::{align_of, size_of};
struct S1 {}
union UC {
s: S1,
c: u16,
}
struct S2C {
d: str,
u: UC,
}
pub fn check_hybrid() {
assert_eq!(align_of::<S2C>(), 2);
}
}
Version information
rustc 1.78.0-nightly (f8131a48a 2024-02-21)
binary: rustc
commit-hash: f8131a48a46ac3bc8a3d0fe0477055b132cffdc3
commit-date: 2024-02-21
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
warning: unused import: `size_of`
--> /tmp/icemaker_global_tempdir.CUgVl1tuIklu/rustc_testrunner_tmpdir_reporting.EkdYfKY9sLO7/mvce.rs:2:30
|
2 | use std::mem::{align_of, size_of};
| ^^^^^^^
|
= note: `#[warn(unused_imports)]` on by default
error[E0601]: `main` function not found in crate `mvce`
--> /tmp/icemaker_global_tempdir.CUgVl1tuIklu/rustc_testrunner_tmpdir_reporting.EkdYfKY9sLO7/mvce.rs:19:2
|
19 | }
| ^ consider adding a `main` function to `/tmp/icemaker_global_tempdir.CUgVl1tuIklu/rustc_testrunner_tmpdir_reporting.EkdYfKY9sLO7/mvce.rs`
error[E0740]: field must implement `Copy` or be wrapped in `ManuallyDrop<...>` to be used in a union
--> /tmp/icemaker_global_tempdir.CUgVl1tuIklu/rustc_testrunner_tmpdir_reporting.EkdYfKY9sLO7/mvce.rs:7:9
|
7 | s: S1,
| ^^^^^
|
= note: union fields must not have drop side-effects, which is currently enforced via either `Copy` or `ManuallyDrop<...>`
help: wrap the field type in `ManuallyDrop<...>`
|
7 | s: std::mem::ManuallyDrop<S1>,
| +++++++++++++++++++++++ +
error[E0277]: the size for values of type `str` cannot be known at compilation time
--> /tmp/icemaker_global_tempdir.CUgVl1tuIklu/rustc_testrunner_tmpdir_reporting.EkdYfKY9sLO7/mvce.rs:12:12
|
12 | d: str,
| ^^^ doesn't have a size known at compile-time
|
= help: the trait `Sized` is not implemented for `str`
= note: only the last field of a struct may have a dynamically sized type
= help: change the field's type to have a statically known size
help: borrowed types always have a statically known size
|
12 | d: &str,
| +
help: the `Box` type always has a statically known size and allocates its contents in the heap
|
12 | d: Box<str>,
| ++++ +
error: internal compiler error: compiler/rustc_const_eval/src/interpret/step.rs:243:21: AlignOf MIR operator called for unsized type S2C
--> /home/matthias/.rustup/toolchains/master/lib/rustlib/src/rust/library/core/src/mem/mod.rs:466:5
|
466 | intrinsics::min_align_of::<T>()
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
thread 'rustc' panicked at /rustc/f8131a48a46ac3bc8a3d0fe0477055b132cffdc3/compiler/rustc_middle/src/util/bug.rs:34:50:
Box<dyn Any>
stack backtrace:
0: 0x7f9a4218caf6 - std::backtrace_rs::backtrace::libunwind::trace::hbec2edc838b433e2
at /rustc/f8131a48a46ac3bc8a3d0fe0477055b132cffdc3/library/std/src/../../backtrace/src/backtrace/libunwind.rs:104:5
1: 0x7f9a4218caf6 - std::backtrace_rs::backtrace::trace_unsynchronized::h88c30257ee0dd166
at /rustc/f8131a48a46ac3bc8a3d0fe0477055b132cffdc3/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
2: 0x7f9a4218caf6 - std::sys_common::backtrace::_print_fmt::h9176654d509e3088
at /rustc/f8131a48a46ac3bc8a3d0fe0477055b132cffdc3/library/std/src/sys_common/backtrace.rs:68:5
3: 0x7f9a4218caf6 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h671feaee1776bf19
at /rustc/f8131a48a46ac3bc8a3d0fe0477055b132cffdc3/library/std/src/sys_common/backtrace.rs:44:22
4: 0x7f9a421dda7c - core::fmt::rt::Argument::fmt::h59605c83ae32d935
at /rustc/f8131a48a46ac3bc8a3d0fe0477055b132cffdc3/library/core/src/fmt/rt.rs:142:9
5: 0x7f9a421dda7c - core::fmt::write::hf7af8dfcfd20db5b
at /rustc/f8131a48a46ac3bc8a3d0fe0477055b132cffdc3/library/core/src/fmt/mod.rs:1120:17
6: 0x7f9a421814bf - std::io::Write::write_fmt::h92a5dbf489025e71
at /rustc/f8131a48a46ac3bc8a3d0fe0477055b132cffdc3/library/std/src/io/mod.rs:1846:15
7: 0x7f9a4218c8a4 - std::sys_common::backtrace::_print::h00080302d23998ae
at /rustc/f8131a48a46ac3bc8a3d0fe0477055b132cffdc3/library/std/src/sys_common/backtrace.rs:47:5
8: 0x7f9a4218c8a4 - std::sys_common::backtrace::print::h6b23124445400245
at /rustc/f8131a48a46ac3bc8a3d0fe0477055b132cffdc3/library/std/src/sys_common/backtrace.rs:34:9
9: 0x7f9a4218f5eb - std::panicking::default_hook::{{closure}}::hd67b2f9d36675a28
10: 0x7f9a4218f339 - std::panicking::default_hook::h10a39ef11c714e42
at /rustc/f8131a48a46ac3bc8a3d0fe0477055b132cffdc3/library/std/src/panicking.rs:292:9
11: 0x7f9a4507a94c - std[5a8e7f94216a9138]::panicking::update_hook::<alloc[e14ab1f516d287ab]::boxed::Box<rustc_driver_impl[e279e4f1fedd9109]::install_ice_hook::{closure#0}>>::{closure#0}
12: 0x7f9a4218fd50 - <alloc::boxed::Box<F,A> as core::ops::function::Fn<Args>>::call::h37ba37dc48823c1d
at /rustc/f8131a48a46ac3bc8a3d0fe0477055b132cffdc3/library/alloc/src/boxed.rs:2030:9
13: 0x7f9a4218fd50 - std::panicking::rust_panic_with_hook::he3e3bc7c345bf54b
at /rustc/f8131a48a46ac3bc8a3d0fe0477055b132cffdc3/library/std/src/panicking.rs:786:13
14: 0x7f9a450a7524 - std[5a8e7f94216a9138]::panicking::begin_panic::<rustc_errors[34364e5c712fab73]::ExplicitBug>::{closure#0}
15: 0x7f9a450a4176 - std[5a8e7f94216a9138]::sys_common::backtrace::__rust_end_short_backtrace::<std[5a8e7f94216a9138]::panicking::begin_panic<rustc_errors[34364e5c712fab73]::ExplicitBug>::{closure#0}, !>
16: 0x7f9a4509f936 - std[5a8e7f94216a9138]::panicking::begin_panic::<rustc_errors[34364e5c712fab73]::ExplicitBug>
17: 0x7f9a43a17631 - <rustc_errors[34364e5c712fab73]::diagnostic::BugAbort as rustc_errors[34364e5c712fab73]::diagnostic::EmissionGuarantee>::emit_producing_guarantee
18: 0x7f9a45001f60 - rustc_middle[446dd094ad85939e]::util::bug::opt_span_bug_fmt::<rustc_span[adb133ac03280fc1]::span_encoding::Span>::{closure#0}
19: 0x7f9a4500217a - rustc_middle[446dd094ad85939e]::ty::context::tls::with_opt::<rustc_middle[446dd094ad85939e]::util::bug::opt_span_bug_fmt<rustc_span[adb133ac03280fc1]::span_encoding::Span>::{closure#0}, !>::{closure#0}
20: 0x7f9a44ff8e48 - rustc_middle[446dd094ad85939e]::ty::context::tls::with_context_opt::<rustc_middle[446dd094ad85939e]::ty::context::tls::with_opt<rustc_middle[446dd094ad85939e]::util::bug::opt_span_bug_fmt<rustc_span[adb133ac03280fc1]::span_encoding::Span>::{closure#0}, !>::{closure#0}, !>
21: 0x7f9a44650f54 - rustc_middle[446dd094ad85939e]::util::bug::span_bug_fmt::<rustc_span[adb133ac03280fc1]::span_encoding::Span>
22: 0x7f9a472fbef6 - rustc_const_eval[b7e9a6566b8f5ff6]::const_eval::eval_queries::eval_body_using_ecx::{closure#0}
23: 0x7f9a47276f23 - rustc_const_eval[b7e9a6566b8f5ff6]::const_eval::eval_queries::eval_in_interpreter
24: 0x7f9a467fa938 - rustc_const_eval[b7e9a6566b8f5ff6]::const_eval::eval_queries::eval_to_allocation_raw_provider
25: 0x7f9a467fa706 - rustc_query_impl[9d4c51777e2bb749]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[9d4c51777e2bb749]::query_impl::eval_to_allocation_raw::dynamic_query::{closure#2}::{closure#0}, rustc_middle[446dd094ad85939e]::query::erase::Erased<[u8; 24usize]>>
26: 0x7f9a46e0ba51 - rustc_query_system[9b2ccfe41ae3bb1b]::query::plumbing::try_execute_query::<rustc_query_impl[9d4c51777e2bb749]::DynamicConfig<rustc_query_system[9b2ccfe41ae3bb1b]::query::caches::DefaultCache<rustc_middle[446dd094ad85939e]::ty::ParamEnvAnd<rustc_middle[446dd094ad85939e]::mir::interpret::GlobalId>, rustc_middle[446dd094ad85939e]::query::erase::Erased<[u8; 24usize]>>, false, false, false>, rustc_query_impl[9d4c51777e2bb749]::plumbing::QueryCtxt, false>
27: 0x7f9a46e0b62c - rustc_query_impl[9d4c51777e2bb749]::query_impl::eval_to_allocation_raw::get_query_non_incr::__rust_end_short_backtrace
28: 0x7f9a467fb60d - rustc_const_eval[b7e9a6566b8f5ff6]::const_eval::eval_queries::eval_to_const_value_raw_provider
29: 0x7f9a467fb40c - rustc_query_impl[9d4c51777e2bb749]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[9d4c51777e2bb749]::query_impl::eval_to_const_value_raw::dynamic_query::{closure#2}::{closure#0}, rustc_middle[446dd094ad85939e]::query::erase::Erased<[u8; 24usize]>>
30: 0x7f9a46e0ba14 - rustc_query_system[9b2ccfe41ae3bb1b]::query::plumbing::try_execute_query::<rustc_query_impl[9d4c51777e2bb749]::DynamicConfig<rustc_query_system[9b2ccfe41ae3bb1b]::query::caches::DefaultCache<rustc_middle[446dd094ad85939e]::ty::ParamEnvAnd<rustc_middle[446dd094ad85939e]::mir::interpret::GlobalId>, rustc_middle[446dd094ad85939e]::query::erase::Erased<[u8; 24usize]>>, false, false, false>, rustc_query_impl[9d4c51777e2bb749]::plumbing::QueryCtxt, false>
31: 0x7f9a46e0b530 - rustc_query_impl[9d4c51777e2bb749]::query_impl::eval_to_const_value_raw::get_query_non_incr::__rust_end_short_backtrace
32: 0x7f9a4461c265 - <rustc_middle[446dd094ad85939e]::ty::context::TyCtxt>::const_eval_resolve
33: 0x7f9a43c400a0 - <rustc_mir_transform[2f80b166b66099ac]::known_panics_lint::ConstPropagator as rustc_middle[446dd094ad85939e]::mir::visit::Visitor>::visit_operand
34: 0x7f9a43c41835 - <rustc_mir_transform[2f80b166b66099ac]::known_panics_lint::ConstPropagator as rustc_middle[446dd094ad85939e]::mir::visit::Visitor>::visit_assign
35: 0x7f9a46a0911b - <rustc_mir_transform[2f80b166b66099ac]::known_panics_lint::ConstPropagator as rustc_middle[446dd094ad85939e]::mir::visit::Visitor>::visit_body
36: 0x7f9a43c3cc69 - <rustc_mir_transform[2f80b166b66099ac]::known_panics_lint::KnownPanicsLint as rustc_mir_transform[2f80b166b66099ac]::pass_manager::MirLint>::run_lint
37: 0x7f9a46412689 - rustc_mir_transform[2f80b166b66099ac]::pass_manager::run_passes_inner
38: 0x7f9a46642806 - rustc_mir_transform[2f80b166b66099ac]::mir_drops_elaborated_and_const_checked
39: 0x7f9a4664213d - rustc_query_impl[9d4c51777e2bb749]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[9d4c51777e2bb749]::query_impl::mir_drops_elaborated_and_const_checked::dynamic_query::{closure#2}::{closure#0}, rustc_middle[446dd094ad85939e]::query::erase::Erased<[u8; 8usize]>>
40: 0x7f9a465098b0 - rustc_query_system[9b2ccfe41ae3bb1b]::query::plumbing::try_execute_query::<rustc_query_impl[9d4c51777e2bb749]::DynamicConfig<rustc_query_system[9b2ccfe41ae3bb1b]::query::caches::VecCache<rustc_span[adb133ac03280fc1]::def_id::LocalDefId, rustc_middle[446dd094ad85939e]::query::erase::Erased<[u8; 8usize]>>, false, false, false>, rustc_query_impl[9d4c51777e2bb749]::plumbing::QueryCtxt, false>
41: 0x7f9a4650919e - rustc_query_impl[9d4c51777e2bb749]::query_impl::mir_drops_elaborated_and_const_checked::get_query_non_incr::__rust_end_short_backtrace
42: 0x7f9a46ea333f - rustc_interface[7ca501d7f8f3a34f]::passes::analysis
43: 0x7f9a46ea2a29 - rustc_query_impl[9d4c51777e2bb749]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[9d4c51777e2bb749]::query_impl::analysis::dynamic_query::{closure#2}::{closure#0}, rustc_middle[446dd094ad85939e]::query::erase::Erased<[u8; 1usize]>>
44: 0x7f9a4713d4a5 - rustc_query_system[9b2ccfe41ae3bb1b]::query::plumbing::try_execute_query::<rustc_query_impl[9d4c51777e2bb749]::DynamicConfig<rustc_query_system[9b2ccfe41ae3bb1b]::query::caches::SingleCache<rustc_middle[446dd094ad85939e]::query::erase::Erased<[u8; 1usize]>>, false, false, false>, rustc_query_impl[9d4c51777e2bb749]::plumbing::QueryCtxt, false>
45: 0x7f9a4713d209 - rustc_query_impl[9d4c51777e2bb749]::query_impl::analysis::get_query_non_incr::__rust_end_short_backtrace
46: 0x7f9a4714c719 - rustc_interface[7ca501d7f8f3a34f]::interface::run_compiler::<core[85b4fd477ce5bb21]::result::Result<(), rustc_span[adb133ac03280fc1]::ErrorGuaranteed>, rustc_driver_impl[e279e4f1fedd9109]::run_compiler::{closure#0}>::{closure#0}
47: 0x7f9a473be705 - std[5a8e7f94216a9138]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[7ca501d7f8f3a34f]::util::run_in_thread_with_globals<rustc_interface[7ca501d7f8f3a34f]::util::run_in_thread_pool_with_globals<rustc_interface[7ca501d7f8f3a34f]::interface::run_compiler<core[85b4fd477ce5bb21]::result::Result<(), rustc_span[adb133ac03280fc1]::ErrorGuaranteed>, rustc_driver_impl[e279e4f1fedd9109]::run_compiler::{closure#0}>::{closure#0}, core[85b4fd477ce5bb21]::result::Result<(), rustc_span[adb133ac03280fc1]::ErrorGuaranteed>>::{closure#0}, core[85b4fd477ce5bb21]::result::Result<(), rustc_span[adb133ac03280fc1]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[85b4fd477ce5bb21]::result::Result<(), rustc_span[adb133ac03280fc1]::ErrorGuaranteed>>
48: 0x7f9a473be532 - <<std[5a8e7f94216a9138]::thread::Builder>::spawn_unchecked_<rustc_interface[7ca501d7f8f3a34f]::util::run_in_thread_with_globals<rustc_interface[7ca501d7f8f3a34f]::util::run_in_thread_pool_with_globals<rustc_interface[7ca501d7f8f3a34f]::interface::run_compiler<core[85b4fd477ce5bb21]::result::Result<(), rustc_span[adb133ac03280fc1]::ErrorGuaranteed>, rustc_driver_impl[e279e4f1fedd9109]::run_compiler::{closure#0}>::{closure#0}, core[85b4fd477ce5bb21]::result::Result<(), rustc_span[adb133ac03280fc1]::ErrorGuaranteed>>::{closure#0}, core[85b4fd477ce5bb21]::result::Result<(), rustc_span[adb133ac03280fc1]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[85b4fd477ce5bb21]::result::Result<(), rustc_span[adb133ac03280fc1]::ErrorGuaranteed>>::{closure#1} as core[85b4fd477ce5bb21]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
49: 0x7f9a42199725 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h1bff3efb61c3fa6b
at /rustc/f8131a48a46ac3bc8a3d0fe0477055b132cffdc3/library/alloc/src/boxed.rs:2016:9
50: 0x7f9a42199725 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h83141cf549dced8a
at /rustc/f8131a48a46ac3bc8a3d0fe0477055b132cffdc3/library/alloc/src/boxed.rs:2016:9
51: 0x7f9a42199725 - std::sys::pal::unix::thread::Thread::new::thread_start::hbe9287fdd7c325bc
at /rustc/f8131a48a46ac3bc8a3d0fe0477055b132cffdc3/library/std/src/sys/pal/unix/thread.rs:108:17
52: 0x7f9a41f819eb - <unknown>
53: 0x7f9a420057cc - <unknown>
54: 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 (f8131a48a 2024-02-21) running on x86_64-unknown-linux-gnu
query stack during panic:
#0 [eval_to_allocation_raw] const-evaluating + checking `hybrid::check_hybrid::promoted[1]`
#1 [eval_to_const_value_raw] simplifying constant for the type system `hybrid::check_hybrid::promoted[1]` | = note: this failure-note originates in the macro `assert_eq` (in Nightly builds, run with -Z macro-backtrace for more info)
#2 [mir_drops_elaborated_and_const_checked] elaborating drops for `hybrid::check_hybrid`
#3 [analysis] running analysis passes on this crate
end of query stack
error: aborting due to 4 previous errors; 1 warning emitted
Some errors have detailed explanations: E0277, E0601, E0740.
For more information about an error, try `rustc --explain E0277`.
Metadata
Metadata
Assignees
Labels
Area: Mid-level IR (MIR) - https://blog.rust-lang.org/2016/04/19/MIR.htmlCategory: This is a bug.Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️Status: A Minimal Complete and Verifiable Example has been found for this issueRelevant to the compiler team, which will review and decide on the PR/issue.