Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
lukas-code opened this issue Jan 7, 2024 · 1 comment · Fixed by #119708
Closed

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

lukas-code opened this issue Jan 7, 2024 · 1 comment · Fixed by #119708
Assignees
Labels
C-bug Category: This is a bug. F-dyn_star `#![feature(dyn_star)]` I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ requires-nightly This issue requires a nightly compiler in some way. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@lukas-code
Copy link
Contributor

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 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::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::<alloc[f261ea4c0f85c6bb]::boxed::Box<rustc_driver_impl[ebb25202c4ed59f0]::install_ice_hook::{closure#0}>>::{closure#0}
  12:     0x7f7d60034ac6 - <alloc::boxed::Box<F,A> as core::ops::function::Fn<Args>>::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 - <core[b0f7c3f66f4f9544]::iter::adapters::enumerate::Enumerate<_> as core[b0f7c3f66f4f9544]::iter::traits::iterator::Iterator>::try_fold::enumerate::<rustc_middle[5c0e933253c36f]::ty::Ty, (), core[b0f7c3f66f4f9544]::ops::control_flow::ControlFlow<core[b0f7c3f66f4f9544]::ops::control_flow::ControlFlow<rustc_target[5a1d4082f1b1a00c]::abi::call::ArgAbi<rustc_middle[5c0e933253c36f]::ty::Ty>>>, core[b0f7c3f66f4f9544]::iter::adapters::map::map_try_fold<(usize, rustc_middle[5c0e933253c36f]::ty::Ty), core[b0f7c3f66f4f9544]::result::Result<rustc_target[5a1d4082f1b1a00c]::abi::call::ArgAbi<rustc_middle[5c0e933253c36f]::ty::Ty>, &rustc_middle[5c0e933253c36f]::ty::layout::FnAbiError>, (), core[b0f7c3f66f4f9544]::ops::control_flow::ControlFlow<core[b0f7c3f66f4f9544]::ops::control_flow::ControlFlow<rustc_target[5a1d4082f1b1a00c]::abi::call::ArgAbi<rustc_middle[5c0e933253c36f]::ty::Ty>>>, rustc_ty_utils[7ccf7f6b7af95c81]::abi::fn_abi_new_uncached::{closure#1}, <core[b0f7c3f66f4f9544]::iter::adapters::GenericShunt<core[b0f7c3f66f4f9544]::iter::adapters::map::Map<core[b0f7c3f66f4f9544]::iter::adapters::enumerate::Enumerate<core[b0f7c3f66f4f9544]::iter::adapters::chain::Chain<core[b0f7c3f66f4f9544]::iter::adapters::chain::Chain<core[b0f7c3f66f4f9544]::iter::adapters::copied::Copied<core[b0f7c3f66f4f9544]::slice::iter::Iter<rustc_middle[5c0e933253c36f]::ty::Ty>>, core[b0f7c3f66f4f9544]::iter::adapters::copied::Copied<core[b0f7c3f66f4f9544]::slice::iter::Iter<rustc_middle[5c0e933253c36f]::ty::Ty>>>, core[b0f7c3f66f4f9544]::option::IntoIter<rustc_middle[5c0e933253c36f]::ty::Ty>>>, rustc_ty_utils[7ccf7f6b7af95c81]::abi::fn_abi_new_uncached::{closure#1}>, core[b0f7c3f66f4f9544]::result::Result<core[b0f7c3f66f4f9544]::convert::Infallible, &rustc_middle[5c0e933253c36f]::ty::layout::FnAbiError>> as core[b0f7c3f66f4f9544]::iter::traits::iterator::Iterator>::try_fold<(), core[b0f7c3f66f4f9544]::iter::traits::iterator::Iterator::try_for_each::call<rustc_target[5a1d4082f1b1a00c]::abi::call::ArgAbi<rustc_middle[5c0e933253c36f]::ty::Ty>, core[b0f7c3f66f4f9544]::ops::control_flow::ControlFlow<rustc_target[5a1d4082f1b1a00c]::abi::call::ArgAbi<rustc_middle[5c0e933253c36f]::ty::Ty>>, core[b0f7c3f66f4f9544]::ops::control_flow::ControlFlow<rustc_target[5a1d4082f1b1a00c]::abi::call::ArgAbi<rustc_middle[5c0e933253c36f]::ty::Ty>>::Break>::{closure#0}, core[b0f7c3f66f4f9544]::ops::control_flow::ControlFlow<rustc_target[5a1d4082f1b1a00c]::abi::call::ArgAbi<rustc_middle[5c0e933253c36f]::ty::Ty>>>::{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::<rustc_query_impl[8d51d83533aab555]::query_impl::fn_abi_of_instance::dynamic_query::{closure#2}::{closure#0}, rustc_middle[5c0e933253c36f]::query::erase::Erased<[u8; 16usize]>>
  25:     0x7f7d64a51dae - rustc_query_system[467b12522657033b]::query::plumbing::try_execute_query::<rustc_query_impl[8d51d83533aab555]::DynamicConfig<rustc_query_system[467b12522657033b]::query::caches::DefaultCache<rustc_middle[5c0e933253c36f]::ty::ParamEnvAnd<(rustc_middle[5c0e933253c36f]::ty::instance::Instance, &rustc_middle[5c0e933253c36f]::ty::list::List<rustc_middle[5c0e933253c36f]::ty::Ty>)>, 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 - <rustc_codegen_ssa[f9144df516ab017b]::mir::FunctionCx<rustc_codegen_llvm[520b98953a3fa16a]::builder::Builder>>::codegen_block
  28:     0x7f7d64c4288f - rustc_codegen_ssa[f9144df516ab017b]::mir::codegen_mir::<rustc_codegen_llvm[520b98953a3fa16a]::builder::Builder>
  29:     0x7f7d64c3008d - rustc_codegen_llvm[520b98953a3fa16a]::base::compile_codegen_unit::module_codegen
  30:     0x7f7d6504866b - <rustc_codegen_llvm[520b98953a3fa16a]::LlvmCodegenBackend as rustc_codegen_ssa[f9144df516ab017b]::traits::backend::ExtraBackendMethods>::compile_codegen_unit
  31:     0x7f7d65058fe8 - rustc_codegen_ssa[f9144df516ab017b]::base::codegen_crate::<rustc_codegen_llvm[520b98953a3fa16a]::LlvmCodegenBackend>
  32:     0x7f7d6505877f - <rustc_codegen_llvm[520b98953a3fa16a]::LlvmCodegenBackend as rustc_codegen_ssa[f9144df516ab017b]::traits::backend::CodegenBackend>::codegen_crate
  33:     0x7f7d65056b2c - rustc_interface[b64d2c573b6a40ef]::passes::start_codegen
  34:     0x7f7d650562a8 - <rustc_interface[b64d2c573b6a40ef]::queries::Queries>::codegen_and_build_linker
  35:     0x7f7d64e9ebce - rustc_interface[b64d2c573b6a40ef]::interface::run_compiler::<core[b0f7c3f66f4f9544]::result::Result<(), rustc_span[7608ec07a6279d6f]::ErrorGuaranteed>, rustc_driver_impl[ebb25202c4ed59f0]::run_compiler::{closure#0}>::{closure#0}
  36:     0x7f7d65082286 - std[c932748c3b80640d]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[b64d2c573b6a40ef]::util::run_in_thread_with_globals<rustc_interface[b64d2c573b6a40ef]::util::run_in_thread_pool_with_globals<rustc_interface[b64d2c573b6a40ef]::interface::run_compiler<core[b0f7c3f66f4f9544]::result::Result<(), rustc_span[7608ec07a6279d6f]::ErrorGuaranteed>, 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 - <<std[c932748c3b80640d]::thread::Builder>::spawn_unchecked_<rustc_interface[b64d2c573b6a40ef]::util::run_in_thread_with_globals<rustc_interface[b64d2c573b6a40ef]::util::run_in_thread_pool_with_globals<rustc_interface[b64d2c573b6a40ef]::interface::run_compiler<core[b0f7c3f66f4f9544]::result::Result<(), rustc_span[7608ec07a6279d6f]::ErrorGuaranteed>, 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 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h41ef687adb0ae1b6
                               at /rustc/b6a8c762eed0ae0383658c38d65cb91bbd9800a1/library/alloc/src/boxed.rs:2016:9
  39:     0x7f7d6003e9f5 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::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 - <unknown>

@rustbot label F-dyn_star requires-nightly

@lukas-code lukas-code added C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Jan 7, 2024
@rustbot rustbot added needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. F-dyn_star `#![feature(dyn_star)]` requires-nightly This issue requires a nightly compiler in some way. labels Jan 7, 2024
@matthiaskrgr
Copy link
Member

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

maybe #101832 ?

@compiler-errors compiler-errors self-assigned this Jan 7, 2024
@fmease fmease removed the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Jan 7, 2024
@bors bors closed this as completed in 2676860 Jan 8, 2024
rust-timer added a commit to rust-lang-ci/rust that referenced this issue Jan 8, 2024
Rollup merge of rust-lang#119708 - compiler-errors:pointer-like, r=Nilstrieb

Unions are not `PointerLike`

I introduced the `PointerLike` trait to enforce `dyn*` coercions only from types that share the same ABI as a pointer. On top of needing to be scalar, they also should not be unions, since CTFE chokes on scalar reads for union types.

Fixes rust-lang#119695
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: This is a bug. F-dyn_star `#![feature(dyn_star)]` I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ requires-nightly This issue requires a nightly compiler in some way. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants