Skip to content

OperandValue cannot be a pointer: Ref(PlaceValue #125103

Not planned
@Naserume

Description

@Naserume

Code

#![feature(unsize, coerce_unsized)]

use std::{
    ops::CoerceUnsized,
    marker::Unsize,
};

#[repr(C)]
struct Ptr<T: ?Sized>(Box<T>);

impl<T: ?Send, U: ?Sized> CoerceUnsized<Ptr<U>> for Ptr<T>
where
    T: Unsize<U>,
{}


fn main() {
    let foo = Ptr(Box::new(5)) as Ptr<::std::any::Any>;
}

Meta

rustc --version --verbose:

rustc 1.80.0-nightly (ab14f944a 2024-05-13)
binary: rustc
commit-hash: ab14f944afe4234db378ced3801e637eae6c0f30
commit-date: 2024-05-13
host: x86_64-apple-darwin
release: 1.80.0-nightly
LLVM version: 18.1.4

Error output

warning: relaxing a default bound only does something for `?Sized`; all other traits are not bound by default
  --> ./B44319F5AA8002E03AC4912FAF44101E5F5D591247689092F2E8F2F8396BAD52.rs:11:9
   |
11 | impl<T: ?Send, U: ?Sized> CoerceUnsized<Ptr<U>> for Ptr<T>
   |         ^^^^^

warning: trait objects without an explicit `dyn` are deprecated
  --> ./B44319F5AA8002E03AC4912FAF44101E5F5D591247689092F2E8F2F8396BAD52.rs:18:39
   |
18 |     let foo = Ptr(Box::new(5)) as Ptr<::std::any::Any>;
   |                                       ^^^^^^^^^^^^^^^
   |
   = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021!
   = note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/warnings-promoted-to-error.html>
   = note: `#[warn(bare_trait_objects)]` on by default
help: if this is an object-safe trait, use `dyn`
   |
18 |     let foo = Ptr(Box::new(5)) as Ptr<dyn (::std::any::Any)>;
   |                                       +++++               +

warning: unused variable: `foo`
  --> ./B44319F5AA8002E03AC4912FAF44101E5F5D591247689092F2E8F2F8396BAD52.rs:18:9
   |
18 |     let foo = Ptr(Box::new(5)) as Ptr<::std::any::Any>;
   |         ^^^ help: if this is intentional, prefix it with an underscore: `_foo`
   |
   = note: `#[warn(unused_variables)]` on by default
Backtrace

error: internal compiler error: /rustc/ab14f944afe4234db378ced3801e637eae6c0f30/compiler/rustc_codegen_ssa/src/mir/operand.rs:98:18: OperandValue cannot be a pointer: Ref(PlaceValue { llval: (ptr:  %1 = alloca [8 x i8], align 8), llextra: None, align: Align(8 bytes) })

thread 'rustc' panicked at /rustc/ab14f944afe4234db378ced3801e637eae6c0f30/compiler/rustc_codegen_ssa/src/mir/operand.rs:98:18:
Box<dyn Any>
stack backtrace:
   0:        0x10c0a2ce3 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h5b162cab46f344a5
   1:        0x10c0ee55b - core::fmt::write::h4a73583a3886d3b0
   2:        0x10c098dbe - std::io::Write::write_fmt::h8846f8d604484bad
   3:        0x10c0a2ad1 - std::sys_common::backtrace::print::h7eceb11702f657b6
   4:        0x10c0a58a9 - std::panicking::default_hook::{{closure}}::he179a4d2e5ce811d
   5:        0x10c0a55f0 - std::panicking::default_hook::h30640957787a5250
   6:        0x114d69dac - std[b2c48648c707f1ed]::panicking::update_hook::<alloc[759ce9084a067d7e]::boxed::Box<rustc_driver_impl[19c236f0e930bd10]::install_ice_hook::{closure#0}>>::{closure#0}
   7:        0x10c0a63b3 - std::panicking::rust_panic_with_hook::hbfe888ce2af6ee0d
   8:        0x114dcf6aa - std[b2c48648c707f1ed]::panicking::begin_panic::<rustc_errors[9015831dbe40c2a7]::ExplicitBug>::{closure#0}
   9:        0x114dc7379 - std[b2c48648c707f1ed]::sys_common::backtrace::__rust_end_short_backtrace::<std[b2c48648c707f1ed]::panicking::begin_panic<rustc_errors[9015831dbe40c2a7]::ExplicitBug>::{closure#0}, !>
  10:        0x1194ff2c9 - std[b2c48648c707f1ed]::panicking::begin_panic::<rustc_errors[9015831dbe40c2a7]::ExplicitBug>
  11:        0x114de2ab6 - <rustc_errors[9015831dbe40c2a7]::diagnostic::BugAbort as rustc_errors[9015831dbe40c2a7]::diagnostic::EmissionGuarantee>::emit_producing_guarantee
  12:        0x1158c89de - rustc_middle[cdd43d02f115379c]::util::bug::opt_span_bug_fmt::<rustc_span[b8a567ff7e2a2eec]::span_encoding::Span>::{closure#0}
  13:        0x11587a457 - rustc_middle[cdd43d02f115379c]::ty::context::tls::with_opt::<rustc_middle[cdd43d02f115379c]::util::bug::opt_span_bug_fmt<rustc_span[b8a567ff7e2a2eec]::span_encoding::Span>::{closure#0}, !>::{closure#0}
  14:        0x115879ef5 - rustc_middle[cdd43d02f115379c]::ty::context::tls::with_context_opt::<rustc_middle[cdd43d02f115379c]::ty::context::tls::with_opt<rustc_middle[cdd43d02f115379c]::util::bug::opt_span_bug_fmt<rustc_span[b8a567ff7e2a2eec]::span_encoding::Span>::{closure#0}, !>::{closure#0}, !>
  15:        0x1195c27fb - rustc_middle[cdd43d02f115379c]::util::bug::bug_fmt
  16:        0x114a12840 - <rustc_codegen_ssa[7403e5ef696b8fc0]::mir::operand::OperandValue<&rustc_codegen_llvm[bd17c2e093d5775d]::llvm_::ffi::Value>>::pointer_parts
  17:        0x114a103bf - <rustc_codegen_ssa[7403e5ef696b8fc0]::mir::FunctionCx<rustc_codegen_llvm[bd17c2e093d5775d]::builder::Builder>>::codegen_rvalue_operand
  18:        0x1149c3734 - rustc_codegen_ssa[7403e5ef696b8fc0]::mir::codegen_mir::<rustc_codegen_llvm[bd17c2e093d5775d]::builder::Builder>
  19:        0x114a87353 - rustc_codegen_llvm[bd17c2e093d5775d]::base::compile_codegen_unit::module_codegen
  20:        0x114ad2cc6 - <rustc_codegen_llvm[bd17c2e093d5775d]::LlvmCodegenBackend as rustc_codegen_ssa[7403e5ef696b8fc0]::traits::backend::ExtraBackendMethods>::compile_codegen_unit
  21:        0x1149cb2f0 - rustc_codegen_ssa[7403e5ef696b8fc0]::base::codegen_crate::<rustc_codegen_llvm[bd17c2e093d5775d]::LlvmCodegenBackend>
  22:        0x114ad8b1a - <rustc_codegen_llvm[bd17c2e093d5775d]::LlvmCodegenBackend as rustc_codegen_ssa[7403e5ef696b8fc0]::traits::backend::CodegenBackend>::codegen_crate
  23:        0x1155320f4 - rustc_interface[22ad048939be8ccd]::passes::start_codegen
  24:        0x11553a52c - <rustc_interface[22ad048939be8ccd]::queries::Queries>::codegen_and_build_linker
  25:        0x114d6866d - rustc_interface[22ad048939be8ccd]::interface::run_compiler::<core[fdc01d03261f4aaa]::result::Result<(), rustc_span[b8a567ff7e2a2eec]::ErrorGuaranteed>, rustc_driver_impl[19c236f0e930bd10]::run_compiler::{closure#0}>::{closure#1}
  26:        0x114d57501 - std[b2c48648c707f1ed]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[22ad048939be8ccd]::util::run_in_thread_with_globals<rustc_interface[22ad048939be8ccd]::util::run_in_thread_pool_with_globals<rustc_interface[22ad048939be8ccd]::interface::run_compiler<core[fdc01d03261f4aaa]::result::Result<(), rustc_span[b8a567ff7e2a2eec]::ErrorGuaranteed>, rustc_driver_impl[19c236f0e930bd10]::run_compiler::{closure#0}>::{closure#1}, core[fdc01d03261f4aaa]::result::Result<(), rustc_span[b8a567ff7e2a2eec]::ErrorGuaranteed>>::{closure#0}, core[fdc01d03261f4aaa]::result::Result<(), rustc_span[b8a567ff7e2a2eec]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[fdc01d03261f4aaa]::result::Result<(), rustc_span[b8a567ff7e2a2eec]::ErrorGuaranteed>>
  27:        0x114d73036 - <<std[b2c48648c707f1ed]::thread::Builder>::spawn_unchecked_<rustc_interface[22ad048939be8ccd]::util::run_in_thread_with_globals<rustc_interface[22ad048939be8ccd]::util::run_in_thread_pool_with_globals<rustc_interface[22ad048939be8ccd]::interface::run_compiler<core[fdc01d03261f4aaa]::result::Result<(), rustc_span[b8a567ff7e2a2eec]::ErrorGuaranteed>, rustc_driver_impl[19c236f0e930bd10]::run_compiler::{closure#0}>::{closure#1}, core[fdc01d03261f4aaa]::result::Result<(), rustc_span[b8a567ff7e2a2eec]::ErrorGuaranteed>>::{closure#0}, core[fdc01d03261f4aaa]::result::Result<(), rustc_span[b8a567ff7e2a2eec]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[fdc01d03261f4aaa]::result::Result<(), rustc_span[b8a567ff7e2a2eec]::ErrorGuaranteed>>::{closure#2} as core[fdc01d03261f4aaa]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  28:        0x10c0afacb - std::sys::pal::unix::thread::Thread::new::thread_start::h176c25cd13ced921
  29:     0x7ff801f5318b - __pthread_start

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: please make sure that you have updated to the latest nightly

note: please attach the file at `/Users/rustc-ice-2024-05-14T03_33_55-1941.txt` to your bug report

query stack during panic:
end of query stack
error: aborting due to 1 previous error; 3 warnings emitted

Activity

added
C-bugCategory: This is a bug.
I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️
T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.
on May 14, 2024
added
needs-triageThis issue may need triage. Remove it if it has been sufficiently triaged.
on May 14, 2024
Naserume

Naserume commented on May 14, 2024

@Naserume
Author

Wait it was a duplicate with same code in #54888
Edit: I re-checked the code and it is slightly changed, but the stack before panic is almost identical.
Re-open this issue if anyone think it's a different case

removed
needs-triageThis issue may need triage. Remove it if it has been sufficiently triaged.
on May 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: This is a bug.I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @saethlin@rustbot@Naserume

        Issue actions

          `OperandValue cannot be a pointer:` Ref(PlaceValue · Issue #125103 · rust-lang/rust