rust-lang / rust

Empowering everyone to build reliable and efficient software.
https://www.rust-lang.org
Other
98.38k stars 12.72k forks source link

ICE with `dyn*` when trait is implemented for union #119695

Closed lukas-code closed 10 months ago

lukas-code commented 10 months ago

Code

playground

#![feature(dyn_star)]

union Union {
    x: usize,
}

trait Trait {}
impl Trait for Union {}

fn bar(_: dyn* Trait) {}

fn main() {
    bar(Union { x: 0usize });
}

In particular, this also happens with MaybeUninit.

Meta

rustc --version --verbose:

1.77.0-nightly (2024-01-06 b6a8c762eed0ae038365)

Error output

error: internal compiler error: /rustc/b6a8c762eed0ae0383658c38d65cb91bbd9800a1/compiler/rustc_const_eval/src/interpret/operand.rs:558:13: primitive read not possible for type: Union
  --> src/main.rs:13:9
   |
13 |     bar(Union { x: 0usize });
   |         ^^^^^^^^^^^^^^^^^^^
Backtrace

``` 0: 0x7f7d60031806 - std::backtrace_rs::backtrace::libunwind::trace::hc8af34b4fd5a864a at /rustc/b6a8c762eed0ae0383658c38d65cb91bbd9800a1/library/std/src/../../backtrace/src/backtrace/libunwind.rs:104:5 1: 0x7f7d60031806 - std::backtrace_rs::backtrace::trace_unsynchronized::h18f53d63ca623615 at /rustc/b6a8c762eed0ae0383658c38d65cb91bbd9800a1/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5 2: 0x7f7d60031806 - std::sys_common::backtrace::_print_fmt::h943cd7e21aafa33c at /rustc/b6a8c762eed0ae0383658c38d65cb91bbd9800a1/library/std/src/sys_common/backtrace.rs:68:5 3: 0x7f7d60031806 - ::fmt::h635232b34a35adaf at /rustc/b6a8c762eed0ae0383658c38d65cb91bbd9800a1/library/std/src/sys_common/backtrace.rs:44:22 4: 0x7f7d60083f00 - core::fmt::rt::Argument::fmt::h50bc38c8fd18fbd6 at /rustc/b6a8c762eed0ae0383658c38d65cb91bbd9800a1/library/core/src/fmt/rt.rs:142:9 5: 0x7f7d60083f00 - core::fmt::write::hcbf70025ea05925d at /rustc/b6a8c762eed0ae0383658c38d65cb91bbd9800a1/library/core/src/fmt/mod.rs:1120:17 6: 0x7f7d600251ef - std::io::Write::write_fmt::hcbf632fb6405bb22 at /rustc/b6a8c762eed0ae0383658c38d65cb91bbd9800a1/library/std/src/io/mod.rs:1810:15 7: 0x7f7d600315e4 - std::sys_common::backtrace::_print::h8eaf13ff4bc3f56c at /rustc/b6a8c762eed0ae0383658c38d65cb91bbd9800a1/library/std/src/sys_common/backtrace.rs:47:5 8: 0x7f7d600315e4 - std::sys_common::backtrace::print::hd6c89746850dfcd6 at /rustc/b6a8c762eed0ae0383658c38d65cb91bbd9800a1/library/std/src/sys_common/backtrace.rs:34:9 9: 0x7f7d60034377 - std::panicking::default_hook::{{closure}}::h83e3c0fe3d256343 10: 0x7f7d600340d9 - std::panicking::default_hook::h69b664a5f52034de at /rustc/b6a8c762eed0ae0383658c38d65cb91bbd9800a1/library/std/src/panicking.rs:292:9 11: 0x7f7d62df75fc - std[c932748c3b80640d]::panicking::update_hook::>::{closure#0} 12: 0x7f7d60034ac6 - as core::ops::function::Fn>::call::h09c6ccfd38800816 at /rustc/b6a8c762eed0ae0383658c38d65cb91bbd9800a1/library/alloc/src/boxed.rs:2030:9 13: 0x7f7d60034ac6 - std::panicking::rust_panic_with_hook::h40f93821e565b644 at /rustc/b6a8c762eed0ae0383658c38d65cb91bbd9800a1/library/std/src/panicking.rs:783:13 14: 0x7f7d60034812 - std::panicking::begin_panic_handler::{{closure}}::h7a8c3b740409c5db at /rustc/b6a8c762eed0ae0383658c38d65cb91bbd9800a1/library/std/src/panicking.rs:657:13 15: 0x7f7d60031d06 - std::sys_common::backtrace::__rust_end_short_backtrace::hfcad91b8b8bca0cb at /rustc/b6a8c762eed0ae0383658c38d65cb91bbd9800a1/library/std/src/sys_common/backtrace.rs:171:18 16: 0x7f7d60034570 - rust_begin_unwind at /rustc/b6a8c762eed0ae0383658c38d65cb91bbd9800a1/library/std/src/panicking.rs:645:5 17: 0x7f7d60080605 - core::panicking::panic_fmt::h7980b100f8a83e2f at /rustc/b6a8c762eed0ae0383658c38d65cb91bbd9800a1/library/core/src/panicking.rs:72:14 18: 0x7f7d600803b3 - core::panicking::panic_display::h486cf5019caa64c4 at /rustc/b6a8c762eed0ae0383658c38d65cb91bbd9800a1/library/core/src/panicking.rs:196:5 19: 0x7f7d600803b3 - core::panicking::panic_str::ha87d3ebeb6510906 at /rustc/b6a8c762eed0ae0383658c38d65cb91bbd9800a1/library/core/src/panicking.rs:171:5 20: 0x7f7d600803b3 - core::option::expect_failed::hede16d39fbffda37 at /rustc/b6a8c762eed0ae0383658c38d65cb91bbd9800a1/library/core/src/option.rs:1980:5 21: 0x7f7d648b9838 - as core[b0f7c3f66f4f9544]::iter::traits::iterator::Iterator>::try_fold::enumerate::>>, core[b0f7c3f66f4f9544]::iter::adapters::map::map_try_fold<(usize, rustc_middle[5c0e933253c36f]::ty::Ty), core[b0f7c3f66f4f9544]::result::Result, &rustc_middle[5c0e933253c36f]::ty::layout::FnAbiError>, (), core[b0f7c3f66f4f9544]::ops::control_flow::ControlFlow>>, rustc_ty_utils[7ccf7f6b7af95c81]::abi::fn_abi_new_uncached::{closure#1}, >, core[b0f7c3f66f4f9544]::iter::adapters::copied::Copied>>, core[b0f7c3f66f4f9544]::option::IntoIter>>, rustc_ty_utils[7ccf7f6b7af95c81]::abi::fn_abi_new_uncached::{closure#1}>, core[b0f7c3f66f4f9544]::result::Result> as core[b0f7c3f66f4f9544]::iter::traits::iterator::Iterator>::try_fold<(), core[b0f7c3f66f4f9544]::iter::traits::iterator::Iterator::try_for_each::call, core[b0f7c3f66f4f9544]::ops::control_flow::ControlFlow>, core[b0f7c3f66f4f9544]::ops::control_flow::ControlFlow>::Break>::{closure#0}, core[b0f7c3f66f4f9544]::ops::control_flow::ControlFlow>>::{closure#0}>::{closure#0}>::{closure#0} 22: 0x7f7d64a57f6d - rustc_ty_utils[7ccf7f6b7af95c81]::abi::fn_abi_new_uncached 23: 0x7f7d64a54714 - rustc_ty_utils[7ccf7f6b7af95c81]::abi::fn_abi_of_instance 24: 0x7f7d64a52fb3 - rustc_query_impl[8d51d83533aab555]::plumbing::__rust_begin_short_backtrace::> 25: 0x7f7d64a51dae - rustc_query_system[467b12522657033b]::query::plumbing::try_execute_query::)>, rustc_middle[5c0e933253c36f]::query::erase::Erased<[u8; 16usize]>>, false, false, false>, rustc_query_impl[8d51d83533aab555]::plumbing::QueryCtxt, false> 26: 0x7f7d64a519bd - rustc_query_impl[8d51d83533aab555]::query_impl::fn_abi_of_instance::get_query_non_incr::__rust_end_short_backtrace 27: 0x7f7d64898c6f - >::codegen_block 28: 0x7f7d64c4288f - rustc_codegen_ssa[f9144df516ab017b]::mir::codegen_mir:: 29: 0x7f7d64c3008d - rustc_codegen_llvm[520b98953a3fa16a]::base::compile_codegen_unit::module_codegen 30: 0x7f7d6504866b - ::compile_codegen_unit 31: 0x7f7d65058fe8 - rustc_codegen_ssa[f9144df516ab017b]::base::codegen_crate:: 32: 0x7f7d6505877f - ::codegen_crate 33: 0x7f7d65056b2c - rustc_interface[b64d2c573b6a40ef]::passes::start_codegen 34: 0x7f7d650562a8 - ::codegen_and_build_linker 35: 0x7f7d64e9ebce - rustc_interface[b64d2c573b6a40ef]::interface::run_compiler::, rustc_driver_impl[ebb25202c4ed59f0]::run_compiler::{closure#0}>::{closure#0} 36: 0x7f7d65082286 - std[c932748c3b80640d]::sys_common::backtrace::__rust_begin_short_backtrace::, rustc_driver_impl[ebb25202c4ed59f0]::run_compiler::{closure#0}>::{closure#0}, core[b0f7c3f66f4f9544]::result::Result<(), rustc_span[7608ec07a6279d6f]::ErrorGuaranteed>>::{closure#0}, core[b0f7c3f66f4f9544]::result::Result<(), rustc_span[7608ec07a6279d6f]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[b0f7c3f66f4f9544]::result::Result<(), rustc_span[7608ec07a6279d6f]::ErrorGuaranteed>> 37: 0x7f7d650820b3 - <::spawn_unchecked_, rustc_driver_impl[ebb25202c4ed59f0]::run_compiler::{closure#0}>::{closure#0}, core[b0f7c3f66f4f9544]::result::Result<(), rustc_span[7608ec07a6279d6f]::ErrorGuaranteed>>::{closure#0}, core[b0f7c3f66f4f9544]::result::Result<(), rustc_span[7608ec07a6279d6f]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[b0f7c3f66f4f9544]::result::Result<(), rustc_span[7608ec07a6279d6f]::ErrorGuaranteed>>::{closure#1} as core[b0f7c3f66f4f9544]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0} 38: 0x7f7d6003e9f5 - as core::ops::function::FnOnce>::call_once::h41ef687adb0ae1b6 at /rustc/b6a8c762eed0ae0383658c38d65cb91bbd9800a1/library/alloc/src/boxed.rs:2016:9 39: 0x7f7d6003e9f5 - as core::ops::function::FnOnce>::call_once::h8a30a6ac67169adc at /rustc/b6a8c762eed0ae0383658c38d65cb91bbd9800a1/library/alloc/src/boxed.rs:2016:9 40: 0x7f7d6003e9f5 - std::sys::unix::thread::Thread::new::thread_start::h8dea3c4d6d74e810 at /rustc/b6a8c762eed0ae0383658c38d65cb91bbd9800a1/library/std/src/sys/unix/thread.rs:108:17 41: 0x7f7d5ff51609 - start_thread 42: 0x7f7d5fe74353 - clone 43: 0x0 - ```

@rustbot label F-dyn_star requires-nightly

matthiaskrgr commented 10 months ago

Regression in nightly-2022-10-16 found 7 bors merge commits in the specified range commit[0] 2022-10-14: Auto merge of https://github.com/rust-lang/rust/pull/101030 - woppopo:const_location, r=scottmcm commit[1] 2022-10-14: Auto merge of https://github.com/rust-lang/rust/pull/103069 - matthiaskrgr:rollup-xxsx6sk, r=matthiaskrgr commit[2] 2022-10-15: Auto merge of https://github.com/rust-lang/rust/pull/98033 - joshtriplett:is-terminal-fd-handle, r=thomcc commit[3] 2022-10-15: Auto merge of https://github.com/rust-lang/rust/pull/99292 - Aaron1011:stability-use-tree, r=cjgillot commit[4] 2022-10-15: Auto merge of https://github.com/rust-lang/rust/pull/101832 - compiler-errors:dyn-star-plus, r=eholk commit[5] 2022-10-15: Auto merge of https://github.com/rust-lang/rust/pull/103083 - Dylan-DPC:rollup-97cvwdv, r=Dylan-DPC commit[6] 2022-10-15: Auto merge of https://github.com/rust-lang/rust/pull/102895 - Nilstrieb:query-cleanups, r=cjgillot ERROR: no CI builds available between https://github.com/rust-lang/rust/commit/bf15a9e5263fcea065a7ae9c179b2d24c2deb670 and https://github.com/rust-lang/rust/commit/b8c35ca26b191bb9a9ac669a4b3f4d3d52d97fb1 within last 167 days

maybe https://github.com/rust-lang/rust/pull/101832 ?