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 (OperandValue cannot be a pointer) trying to convert dyn PointerLike to dyn* PointerLike with unsized_fn_params #134543

Closed
theemathas opened this issue Dec 20, 2024 · 1 comment · Fixed by #134573
Labels
C-bug Category: This is a bug. F-dyn_star `#![feature(dyn_star)]` F-unsized_fn_params `#![feature(unsized_fn_params)]` 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

@theemathas
Copy link
Contributor

theemathas commented Dec 20, 2024

Sorry if this report is unnecessary, since it uses an internal feature (unsized_fn_params), although there are other still-open issues on this repo involving this specific feature. Feel free to close it if this is the case.

Code

#![feature(pointer_like_trait, unsized_fn_params, dyn_star)]
#![allow(internal_features, incomplete_features)]

use std::marker::PointerLike;

#[no_mangle]
pub fn lol(x: dyn PointerLike) {
    foo(x);
}

fn foo<T: PointerLike + ?Sized>(x: T) {
    let _: dyn* PointerLike = x;
}

fn main() {}

I believe that the root issue here is that dyn PointerLike implements PointerLike, despite not being pointer-like.

Meta

Reproducible on the playground with version 1.85.0-nightly (2024-12-19 9e136a30a965bf4e63f0)

Error output

Backtrace

error: internal compiler error: /rustc/9e136a30a965bf4e63f03095c57df7257bf96fd6/compiler/rustc_codegen_ssa/src/mir/operand.rs:98:18: OperandValue cannot be a pointer: Ref(PlaceValue { llval: (ptr:  %6 = load ptr, ptr %4, align 8, !dbg !38), llextra: Some((ptr:  %8 = load ptr, ptr %7, align 8, !dbg !38)), align: Align(1 bytes) })

thread 'rustc' panicked at /rustc/9e136a30a965bf4e63f03095c57df7257bf96fd6/compiler/rustc_codegen_ssa/src/mir/operand.rs:98:18:
Box<dyn Any>
stack backtrace:
   0:     0x78a8af18315a - <std::sys::backtrace::BacktraceLock::print::DisplayBacktrace as core::fmt::Display>::fmt::h6c37de0361fa7462
   1:     0x78a8af813cbc - core::fmt::write::hf77fe0583268bf67
   2:     0x78a8b0742dd1 - std::io::Write::write_fmt::h3b0b8069e2435ed6
   3:     0x78a8af182fb2 - std::sys::backtrace::BacktraceLock::print::hce84519ec0e7588e
   4:     0x78a8af1854aa - std::panicking::default_hook::{{closure}}::h6e0433c33d1ed12b
   5:     0x78a8af1852f3 - std::panicking::default_hook::h19d4e9e8d7fba9e2
   6:     0x78a8ae2f7768 - std[19739dcbdd52d894]::panicking::update_hook::<alloc[d24e20bba6540ab9]::boxed::Box<rustc_driver_impl[3177e72804664110]::install_ice_hook::{closure#0}>>::{closure#0}
   7:     0x78a8af185c68 - std::panicking::rust_panic_with_hook::hd21771b96ea64164
   8:     0x78a8ae3322d1 - std[19739dcbdd52d894]::panicking::begin_panic::<rustc_errors[37abd7aad4ad5df0]::ExplicitBug>::{closure#0}
   9:     0x78a8ae3274b6 - std[19739dcbdd52d894]::sys::backtrace::__rust_end_short_backtrace::<std[19739dcbdd52d894]::panicking::begin_panic<rustc_errors[37abd7aad4ad5df0]::ExplicitBug>::{closure#0}, !>
  10:     0x78a8ae323ec9 - std[19739dcbdd52d894]::panicking::begin_panic::<rustc_errors[37abd7aad4ad5df0]::ExplicitBug>
  11:     0x78a8ae33c231 - <rustc_errors[37abd7aad4ad5df0]::diagnostic::BugAbort as rustc_errors[37abd7aad4ad5df0]::diagnostic::EmissionGuarantee>::emit_producing_guarantee
  12:     0x78a8ae910fd3 - rustc_middle[a45f2c6e02975f4b]::util::bug::opt_span_bug_fmt::<rustc_span[2a960e124d280c12]::span_encoding::Span>::{closure#0}
  13:     0x78a8ae8f67ba - rustc_middle[a45f2c6e02975f4b]::ty::context::tls::with_opt::<rustc_middle[a45f2c6e02975f4b]::util::bug::opt_span_bug_fmt<rustc_span[2a960e124d280c12]::span_encoding::Span>::{closure#0}, !>::{closure#0}
  14:     0x78a8ae8f664b - rustc_middle[a45f2c6e02975f4b]::ty::context::tls::with_context_opt::<rustc_middle[a45f2c6e02975f4b]::ty::context::tls::with_opt<rustc_middle[a45f2c6e02975f4b]::util::bug::opt_span_bug_fmt<rustc_span[2a960e124d280c12]::span_encoding::Span>::{closure#0}, !>::{closure#0}, !>
  15:     0x78a8ac645790 - rustc_middle[a45f2c6e02975f4b]::util::bug::bug_fmt
  16:     0x78a8ae14cd97 - <rustc_codegen_ssa[86572314d330a2c2]::mir::operand::OperandValue<&rustc_codegen_llvm[de1ddb382a238c68]::llvm_::ffi::Value>>::pointer_parts
  17:     0x78a8afe533d9 - <rustc_codegen_ssa[86572314d330a2c2]::mir::FunctionCx<rustc_codegen_llvm[de1ddb382a238c68]::builder::Builder>>::codegen_rvalue_operand
  18:     0x78a8b0629954 - rustc_codegen_ssa[86572314d330a2c2]::mir::codegen_mir::<rustc_codegen_llvm[de1ddb382a238c68]::builder::Builder>
  19:     0x78a8b0604849 - rustc_codegen_llvm[de1ddb382a238c68]::base::compile_codegen_unit::module_codegen
  20:     0x78a8b07e4b88 - <rustc_codegen_llvm[de1ddb382a238c68]::LlvmCodegenBackend as rustc_codegen_ssa[86572314d330a2c2]::traits::backend::ExtraBackendMethods>::compile_codegen_unit
  21:     0x78a8b07e0ee1 - <rustc_codegen_llvm[de1ddb382a238c68]::LlvmCodegenBackend as rustc_codegen_ssa[86572314d330a2c2]::traits::backend::CodegenBackend>::codegen_crate
  22:     0x78a8b087ef64 - <rustc_interface[dfcc7ff3f03a05db]::queries::Linker>::codegen_and_build_linker
  23:     0x78a8b079edd2 - rustc_interface[dfcc7ff3f03a05db]::passes::create_and_enter_global_ctxt::<core[57d68807791337c0]::option::Option<rustc_interface[dfcc7ff3f03a05db]::queries::Linker>, rustc_driver_impl[3177e72804664110]::run_compiler::{closure#0}::{closure#2}>::{closure#2}::{closure#0}
  24:     0x78a8b0810c43 - rustc_interface[dfcc7ff3f03a05db]::interface::run_compiler::<(), rustc_driver_impl[3177e72804664110]::run_compiler::{closure#0}>::{closure#1}
  25:     0x78a8b07f7711 - std[19739dcbdd52d894]::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface[dfcc7ff3f03a05db]::util::run_in_thread_with_globals<rustc_interface[dfcc7ff3f03a05db]::util::run_in_thread_pool_with_globals<rustc_interface[dfcc7ff3f03a05db]::interface::run_compiler<(), rustc_driver_impl[3177e72804664110]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>
  26:     0x78a8b07f7ba6 - <<std[19739dcbdd52d894]::thread::Builder>::spawn_unchecked_<rustc_interface[dfcc7ff3f03a05db]::util::run_in_thread_with_globals<rustc_interface[dfcc7ff3f03a05db]::util::run_in_thread_pool_with_globals<rustc_interface[dfcc7ff3f03a05db]::interface::run_compiler<(), rustc_driver_impl[3177e72804664110]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>::{closure#1} as core[57d68807791337c0]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  27:     0x78a8b07f916f - std::sys::pal::unix::thread::Thread::new::thread_start::h71fe57097907b3f8
  28:     0x78a8b1e0ca94 - <unknown>
  29:     0x78a8b1e99a34 - clone
  30:                0x0 - <unknown>

note: using internal features is not supported and expected to cause internal compiler errors when used incorrectly

note: please attach the file at `/playground/rustc-ice-2024-12-20T04_14_48-33.txt` to your bug report

note: compiler flags: --crate-type bin -C embed-bitcode=no -C codegen-units=1 -C debuginfo=2

note: some of the compiler flags provided by cargo are hidden

query stack during panic:
end of query stack
error: could not compile `playground` (bin "playground")

@rustbot labels +F-dyn_star +F-unsized_fn_params +requires-nightly

@theemathas theemathas 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 Dec 20, 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)]` F-unsized_fn_params `#![feature(unsized_fn_params)]` requires-nightly This issue requires a nightly compiler in some way. labels Dec 20, 2024
@theemathas theemathas changed the title ICE trying to convert dyn PointerLike to dyn* PointerLike with unsized_fn_params ICE (OperandValue cannot be a pointer) trying to convert dyn PointerLike to dyn* PointerLike with unsized_fn_params Dec 20, 2024
@matthiaskrgr
Copy link
Member

might be duplicate of #54888

@bors bors closed this as completed in 0b1834d Dec 20, 2024
rust-timer added a commit to rust-lang-ci/rust that referenced this issue Dec 20, 2024
Rollup merge of rust-lang#134573 - lukas-code:unimpl-dyn-pointerlike, r=compiler-errors

unimplement `PointerLike` for trait objects

Values of type `dyn* PointerLike` or `dyn PointerLike` are not pointer-like so these types should not implement `PointerLike`.

After rust-lang#133226, `PointerLike` allows user implementations, so we can't just mark it with `#[rustc_deny_explicit_impl(implement_via_object = false)]`. Instead, this PR splits the `#[rustc_deny_explicit_impl(implement_via_object = ...)]` attribute into two separate attributes `#[rustc_deny_explicit_impl]` and `#[rustc_do_not_implement_via_object]` so that we opt out of the automatic `impl PointerLike for dyn PointerLike` and still allow user implementations.

For traits that are marked with `#[do_not_implement_via_object]` but not `#[rustc_deny_explicit_impl]` I've also made it possible to add a manual `impl Trait for dyn Trait`. There is no immediate need for this, but it was one line to implement and seems nice to have.

fixes rust-lang#134545
fixes rust-lang#134543

r? `@compiler-errors`
@saethlin saethlin removed the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Dec 21, 2024
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)]` F-unsized_fn_params `#![feature(unsized_fn_params)]` 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.

4 participants