rust-lang / rust

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

ICE unexpected TypeKind for left-hand side of `dyn*` cast: Double #113280

Open matthiaskrgr opened 1 year ago

matthiaskrgr commented 1 year ago

Code

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

use std::fmt::Debug;
use std::marker::PointerLike;

fn make_dyn_star<'a>(t: impl PointerLike + Debug + 'a) -> dyn* Debug + 'a {
    f32::from_bits(0x1) as f64
}

fn main() {
    println!("{:?}", make_dyn_star(Box::new(1i32)));
}

Meta

rustc --version --verbose:

rustc 1.72.0-nightly (5bd28f5ea 2023-06-28)
binary: rustc
commit-hash: 5bd28f5eac1ba3569bfa8d49ec3f5acbdfdff7a0
commit-date: 2023-06-28
host: x86_64-unknown-linux-gnu
release: 1.72.0-nightly
LLVM version: 16.0.5

Error output

<output>
Backtrace

``` warning: unused variable: `t` --> /home/matthias/vcs/github/rust/tests/ui/icemaker/1B6F4BE7A19A78BF67365C0E743A9D8944440CAE9F9A87C6D5AAC0E868B26F86.rs:15:22 | 15 | fn make_dyn_star<'a>(t: impl PointerLike + Debug + 'a) -> dyn* Debug + 'a { | ^ help: if this is intentional, prefix it with an underscore: `_t` | = note: `#[warn(unused_variables)]` on by default error: internal compiler error: /rustc/5bd28f5eac1ba3569bfa8d49ec3f5acbdfdff7a0/compiler/rustc_codegen_ssa/src/base.rs:279:17: unexpected TypeKind for left-hand side of `dyn*` cast: Double thread 'rustc' panicked at 'Box', /rustc/5bd28f5eac1ba3569bfa8d49ec3f5acbdfdff7a0/compiler/rustc_errors/src/lib.rs:1650:9 stack backtrace: 0: 0x7f1bb3b67e31 - std::backtrace_rs::backtrace::libunwind::trace::h8bc3e596fd6e6181 at /rustc/5bd28f5eac1ba3569bfa8d49ec3f5acbdfdff7a0/library/std/src/../../backtrace/src/backtrace/libunwind.rs:93:5 1: 0x7f1bb3b67e31 - std::backtrace_rs::backtrace::trace_unsynchronized::h9a0656fedca2f962 at /rustc/5bd28f5eac1ba3569bfa8d49ec3f5acbdfdff7a0/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5 2: 0x7f1bb3b67e31 - std::sys_common::backtrace::_print_fmt::h11ca79bc953fda0e at /rustc/5bd28f5eac1ba3569bfa8d49ec3f5acbdfdff7a0/library/std/src/sys_common/backtrace.rs:65:5 3: 0x7f1bb3b67e31 - ::fmt::h23585af82c540d61 at /rustc/5bd28f5eac1ba3569bfa8d49ec3f5acbdfdff7a0/library/std/src/sys_common/backtrace.rs:44:22 4: 0x7f1bb3bc95df - core::fmt::rt::Argument::fmt::h1e7f4bcecbee3fbb at /rustc/5bd28f5eac1ba3569bfa8d49ec3f5acbdfdff7a0/library/core/src/fmt/rt.rs:138:9 5: 0x7f1bb3bc95df - core::fmt::write::h41633f265152b738 at /rustc/5bd28f5eac1ba3569bfa8d49ec3f5acbdfdff7a0/library/core/src/fmt/mod.rs:1094:21 6: 0x7f1bb3b5a967 - std::io::Write::write_fmt::hdf9fdeebf4391d4c at /rustc/5bd28f5eac1ba3569bfa8d49ec3f5acbdfdff7a0/library/std/src/io/mod.rs:1714:15 7: 0x7f1bb3b67c45 - std::sys_common::backtrace::_print::h0761f433dadea582 at /rustc/5bd28f5eac1ba3569bfa8d49ec3f5acbdfdff7a0/library/std/src/sys_common/backtrace.rs:47:5 8: 0x7f1bb3b67c45 - std::sys_common::backtrace::print::hffcd468cc9baf957 at /rustc/5bd28f5eac1ba3569bfa8d49ec3f5acbdfdff7a0/library/std/src/sys_common/backtrace.rs:34:9 9: 0x7f1bb3b6a9f3 - std::panicking::default_hook::{{closure}}::h70eb212f41458c90 at /rustc/5bd28f5eac1ba3569bfa8d49ec3f5acbdfdff7a0/library/std/src/panicking.rs:269:22 10: 0x7f1bb3b6a784 - std::panicking::default_hook::hf217f8886a1385fc at /rustc/5bd28f5eac1ba3569bfa8d49ec3f5acbdfdff7a0/library/std/src/panicking.rs:288:9 11: 0x7f1bb6e2217b - >::call_once::{shim:vtable#0} 12: 0x7f1bb3b6b21e - as core::ops::function::Fn>::call::hdf84d12f536c7065 at /rustc/5bd28f5eac1ba3569bfa8d49ec3f5acbdfdff7a0/library/alloc/src/boxed.rs:2024:9 13: 0x7f1bb3b6b21e - std::panicking::rust_panic_with_hook::h7901b0073bb3ed74 at /rustc/5bd28f5eac1ba3569bfa8d49ec3f5acbdfdff7a0/library/std/src/panicking.rs:709:13 14: 0x7f1bb72f6d91 - std[4a840e81aae3439]::panicking::begin_panic::::{closure#0} 15: 0x7f1bb72f5106 - std[4a840e81aae3439]::sys_common::backtrace::__rust_end_short_backtrace::::{closure#0}, !> 16: 0x7f1bb72f4626 - std[4a840e81aae3439]::panicking::begin_panic:: 17: 0x7f1bb736ae94 - ::bug:: 18: 0x7f1bb736ad16 - ::bug:: 19: 0x7f1bb72f204c - rustc_middle[9f74ec5cb00a905a]::util::bug::opt_span_bug_fmt::::{closure#0} 20: 0x7f1bb72f1f8a - rustc_middle[9f74ec5cb00a905a]::ty::context::tls::with_opt::::{closure#0}, !>::{closure#0} 21: 0x7f1bb72f1f5a - rustc_middle[9f74ec5cb00a905a]::ty::context::tls::with_context_opt::::{closure#0}, !>::{closure#0}, !> 22: 0x7f1bb528cc4d - rustc_middle[9f74ec5cb00a905a]::util::bug::bug_fmt 23: 0x7f1bb6c877a8 - rustc_codegen_ssa[452061f54d1b0567]::base::cast_to_dyn_star:: 24: 0x7f1bb561c164 - >::codegen_rvalue_operand 25: 0x7f1bb55e6a34 - rustc_codegen_ssa[452061f54d1b0567]::mir::codegen_mir:: 26: 0x7f1bb625ca2a - rustc_codegen_llvm[b63e3bb365d5076c]::base::compile_codegen_unit::module_codegen 27: 0x7f1bb625aaa9 - rustc_codegen_llvm[b63e3bb365d5076c]::base::compile_codegen_unit 28: 0x7f1bb630c77d - rustc_codegen_ssa[452061f54d1b0567]::base::codegen_crate:: 29: 0x7f1bb630c066 - ::codegen_crate 30: 0x7f1bb60c0282 - ::time::, rustc_interface[b943f00ad50b5541]::passes::start_codegen::{closure#0}> 31: 0x7f1bb60bfdcb - rustc_interface[b943f00ad50b5541]::passes::start_codegen 32: 0x7f1bb60b9f2a - ::enter::<::ongoing_codegen::{closure#0}, core[6e72eb595340d7ba]::result::Result, rustc_span[624dabdd61f2978b]::ErrorGuaranteed>> 33: 0x7f1bb60b93a2 - ::enter::, rustc_span[624dabdd61f2978b]::ErrorGuaranteed>> 34: 0x7f1bb60b4575 - rustc_span[624dabdd61f2978b]::set_source_map::, rustc_interface[b943f00ad50b5541]::interface::run_compiler, rustc_driver_impl[ea51492c730803db]::run_compiler::{closure#1}>::{closure#0}::{closure#0}> 35: 0x7f1bb60b3996 - >::set::, rustc_driver_impl[ea51492c730803db]::run_compiler::{closure#1}>::{closure#0}, core[6e72eb595340d7ba]::result::Result<(), rustc_span[624dabdd61f2978b]::ErrorGuaranteed>> 36: 0x7f1bb60b2f46 - std[4a840e81aae3439]::sys_common::backtrace::__rust_begin_short_backtrace::, rustc_driver_impl[ea51492c730803db]::run_compiler::{closure#1}>::{closure#0}, core[6e72eb595340d7ba]::result::Result<(), rustc_span[624dabdd61f2978b]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[6e72eb595340d7ba]::result::Result<(), rustc_span[624dabdd61f2978b]::ErrorGuaranteed>> 37: 0x7f1bb60b2cee - <::spawn_unchecked_, rustc_driver_impl[ea51492c730803db]::run_compiler::{closure#1}>::{closure#0}, core[6e72eb595340d7ba]::result::Result<(), rustc_span[624dabdd61f2978b]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[6e72eb595340d7ba]::result::Result<(), rustc_span[624dabdd61f2978b]::ErrorGuaranteed>>::{closure#1} as core[6e72eb595340d7ba]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0} 38: 0x7f1bb3b75695 - as core::ops::function::FnOnce>::call_once::h61eb867555625a06 at /rustc/5bd28f5eac1ba3569bfa8d49ec3f5acbdfdff7a0/library/alloc/src/boxed.rs:2010:9 39: 0x7f1bb3b75695 - as core::ops::function::FnOnce>::call_once::hb80c29f89b136b72 at /rustc/5bd28f5eac1ba3569bfa8d49ec3f5acbdfdff7a0/library/alloc/src/boxed.rs:2010:9 40: 0x7f1bb3b75695 - std::sys::unix::thread::Thread::new::thread_start::hf4205715d65b27a6 at /rustc/5bd28f5eac1ba3569bfa8d49ec3f5acbdfdff7a0/library/std/src/sys/unix/thread.rs:108:17 41: 0x7f1bb390d44b - 42: 0x7f1bb3990e40 - 43: 0x0 - 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.72.0-nightly (5bd28f5ea 2023-06-28) running on x86_64-unknown-linux-gnu query stack during panic: end of query stack error: aborting due to previous error; 1 warning emitted ```

matthiaskrgr commented 1 year ago

Regression in nightly-2023-02-20

107772

compiler-errors commented 1 year ago

not sure if we should support this or explicitly deny floating point types in the built-in PointerLike impl. kinda leaning towards the latter, but i guess there's no reason (at least in theory) why this shouldn't work and emit a bitcast or sth in llvm.