Skip to content

&i32 as dyn* Debug causes an ICE #102544

Closed as not planned
Closed as not planned
@TaKO8Ki

Description

@TaKO8Ki

Code

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

use core::fmt::Debug;

fn main() {
    let foo = &3;
    let i = foo as dyn* Debug;
}

https://play.rust-lang.org/?version=nightly&mode=debug&edition=2021&gist=6f1145ab9ece6ef63ab5357e8147e8f9

Meta

rustc --version --verbose:

rustc 1.63.0 (4b91a6ea7 2022-08-08)
binary: rustc
commit-hash: 4b91a6ea7258a947e59c6522cd5898e7c0a6a88f
commit-date: 2022-08-08
host: aarch64-apple-darwin
release: 1.63.0
LLVM version: 14.0.5

Error output

thread 'rustc' panicked at 'assertion failed: bx.cx().is_backend_immediate(cast)', /rustc/8ce3204af9463db3192ea1eb31c45c2f6d4b5ae6/compiler/rustc_codegen_ssa/src/mir/rvalue.rs:298:25
Backtrace

Compiling playground v0.0.1 (/playground)
warning: unused variable: `i`
 --> src/main.rs:8:9
  |
8 |     let i = foo as dyn* Debug;
  |         ^ help: if this is intentional, prefix it with an underscore: `_i`
  |
  = note: `#[warn(unused_variables)]` on by default

thread 'rustc' panicked at 'assertion failed: bx.cx().is_backend_immediate(cast)', /rustc/8ce3204af9463db3192ea1eb31c45c2f6d4b5ae6/compiler/rustc_codegen_ssa/src/mir/rvalue.rs:298:25
stack backtrace:
   0:     0x7efe16478470 - std::backtrace_rs::backtrace::libunwind::trace::h48a6b877947e3b61
                               at /rustc/8ce3204af9463db3192ea1eb31c45c2f6d4b5ae6/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   1:     0x7efe16478470 - std::backtrace_rs::backtrace::trace_unsynchronized::hfe09011594941abe
                               at /rustc/8ce3204af9463db3192ea1eb31c45c2f6d4b5ae6/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x7efe16478470 - std::sys_common::backtrace::_print_fmt::h9ce2ad36264dcd3e
                               at /rustc/8ce3204af9463db3192ea1eb31c45c2f6d4b5ae6/library/std/src/sys_common/backtrace.rs:66:5
   3:     0x7efe16478470 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h4f730349406daa4f
                               at /rustc/8ce3204af9463db3192ea1eb31c45c2f6d4b5ae6/library/std/src/sys_common/backtrace.rs:45:22
   4:     0x7efe164d330e - core::fmt::write::h4545826f01b877ac
                               at /rustc/8ce3204af9463db3192ea1eb31c45c2f6d4b5ae6/library/core/src/fmt/mod.rs:1209:17
   5:     0x7efe164690f5 - std::io::Write::write_fmt::hac4d3a613c78c8e4
                               at /rustc/8ce3204af9463db3192ea1eb31c45c2f6d4b5ae6/library/std/src/io/mod.rs:1679:15
   6:     0x7efe1647b213 - std::sys_common::backtrace::_print::ha560f7b733dc8a6e
                               at /rustc/8ce3204af9463db3192ea1eb31c45c2f6d4b5ae6/library/std/src/sys_common/backtrace.rs:48:5
   7:     0x7efe1647b213 - std::sys_common::backtrace::print::hcca78599db59c8b4
                               at /rustc/8ce3204af9463db3192ea1eb31c45c2f6d4b5ae6/library/std/src/sys_common/backtrace.rs:35:9
   8:     0x7efe1647b213 - std::panicking::default_hook::{{closure}}::h0d6a74e6cb8499ce
                               at /rustc/8ce3204af9463db3192ea1eb31c45c2f6d4b5ae6/library/std/src/panicking.rs:267:22
   9:     0x7efe1647aeea - std::panicking::default_hook::hcb5d3609ae810fb1
                               at /rustc/8ce3204af9463db3192ea1eb31c45c2f6d4b5ae6/library/std/src/panicking.rs:286:9
  10:     0x7efe18cda7d1 - rustc_driver[6635a35d3e701dd7]::DEFAULT_HOOK::{closure#0}::{closure#0}
  11:     0x7efe1647ba4b - <alloc::boxed::Box<F,A> as core::ops::function::Fn<Args>>::call::hba26835306149e75
                               at /rustc/8ce3204af9463db3192ea1eb31c45c2f6d4b5ae6/library/alloc/src/boxed.rs:1952:9
  12:     0x7efe1647ba4b - std::panicking::rust_panic_with_hook::h4f2461a1c1c1a86e
                               at /rustc/8ce3204af9463db3192ea1eb31c45c2f6d4b5ae6/library/std/src/panicking.rs:673:13
  13:     0x7efe1647b861 - std::panicking::begin_panic_handler::{{closure}}::hcad64e5dfff8b9ed
                               at /rustc/8ce3204af9463db3192ea1eb31c45c2f6d4b5ae6/library/std/src/panicking.rs:558:13
  14:     0x7efe1647891c - std::sys_common::backtrace::__rust_end_short_backtrace::h2a66b4ccd8d28c5b
                               at /rustc/8ce3204af9463db3192ea1eb31c45c2f6d4b5ae6/library/std/src/sys_common/backtrace.rs:138:18
  15:     0x7efe1647b5c2 - rust_begin_unwind
                               at /rustc/8ce3204af9463db3192ea1eb31c45c2f6d4b5ae6/library/std/src/panicking.rs:556:5
  16:     0x7efe164cfee3 - core::panicking::panic_fmt::h443d402932f5c508
                               at /rustc/8ce3204af9463db3192ea1eb31c45c2f6d4b5ae6/library/core/src/panicking.rs:142:14
  17:     0x7efe164cfd2d - core::panicking::panic::hdeb9a58c7debb674
                               at /rustc/8ce3204af9463db3192ea1eb31c45c2f6d4b5ae6/library/core/src/panicking.rs:48:5
  18:     0x7efe17c1491f - <rustc_codegen_ssa[286d2b0e63c9ae5a]::mir::FunctionCx<rustc_codegen_llvm[9e888816408ee4c9]::builder::Builder>>::codegen_block
  19:     0x7efe17c03486 - rustc_codegen_ssa[286d2b0e63c9ae5a]::mir::codegen_mir::<rustc_codegen_llvm[9e888816408ee4c9]::builder::Builder>
  20:     0x7efe180a1914 - rustc_codegen_llvm[9e888816408ee4c9]::base::compile_codegen_unit::module_codegen
  21:     0x7efe189da497 - <rustc_query_system[effbf359c8fbf60]::dep_graph::graph::DepGraph<rustc_middle[cea04118b266f04d]::dep_graph::dep_node::DepKind>>::with_task::<rustc_middle[cea04118b266f04d]::ty::context::TyCtxt, rustc_span[ea709073fc09e903]::symbol::Symbol, rustc_codegen_ssa[286d2b0e63c9ae5a]::ModuleCodegen<rustc_codegen_llvm[9e888816408ee4c9]::ModuleLlvm>>
  22:     0x7efe189da298 - rustc_codegen_llvm[9e888816408ee4c9]::base::compile_codegen_unit
  23:     0x7efe187b9cda - rustc_codegen_ssa[286d2b0e63c9ae5a]::base::codegen_crate::<rustc_codegen_llvm[9e888816408ee4c9]::LlvmCodegenBackend>
  24:     0x7efe187b94dd - <rustc_codegen_llvm[9e888816408ee4c9]::LlvmCodegenBackend as rustc_codegen_ssa[286d2b0e63c9ae5a]::traits::backend::CodegenBackend>::codegen_crate
  25:     0x7efe179c940c - <rustc_session[cbaad9a29d9fac78]::session::Session>::time::<alloc[31d53a49c811d0c6]::boxed::Box<dyn core[7ac8aee7065c0cc9]::any::Any>, rustc_interface[c5619889e11552cd]::passes::start_codegen::{closure#0}>
  26:     0x7efe179c8dee - <rustc_interface[c5619889e11552cd]::passes::QueryContext>::enter::<<rustc_interface[c5619889e11552cd]::queries::Queries>::ongoing_codegen::{closure#0}::{closure#0}, core[7ac8aee7065c0cc9]::result::Result<alloc[31d53a49c811d0c6]::boxed::Box<dyn core[7ac8aee7065c0cc9]::any::Any>, rustc_errors[fbe8c5f47b14aa4]::ErrorGuaranteed>>
  27:     0x7efe1798b343 - <rustc_interface[c5619889e11552cd]::queries::Queries>::ongoing_codegen
  28:     0x7efe179895ca - rustc_interface[c5619889e11552cd]::interface::create_compiler_and_run::<core[7ac8aee7065c0cc9]::result::Result<(), rustc_errors[fbe8c5f47b14aa4]::ErrorGuaranteed>, rustc_driver[6635a35d3e701dd7]::run_compiler::{closure#1}>
  29:     0x7efe17987ed1 - <scoped_tls[d196d212a4d59b56]::ScopedKey<rustc_span[ea709073fc09e903]::SessionGlobals>>::set::<rustc_interface[c5619889e11552cd]::interface::run_compiler<core[7ac8aee7065c0cc9]::result::Result<(), rustc_errors[fbe8c5f47b14aa4]::ErrorGuaranteed>, rustc_driver[6635a35d3e701dd7]::run_compiler::{closure#1}>::{closure#0}, core[7ac8aee7065c0cc9]::result::Result<(), rustc_errors[fbe8c5f47b14aa4]::ErrorGuaranteed>>
  30:     0x7efe17987bbf - std[25baae9c6c77129a]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[c5619889e11552cd]::util::run_in_thread_pool_with_globals<rustc_interface[c5619889e11552cd]::interface::run_compiler<core[7ac8aee7065c0cc9]::result::Result<(), rustc_errors[fbe8c5f47b14aa4]::ErrorGuaranteed>, rustc_driver[6635a35d3e701dd7]::run_compiler::{closure#1}>::{closure#0}, core[7ac8aee7065c0cc9]::result::Result<(), rustc_errors[fbe8c5f47b14aa4]::ErrorGuaranteed>>::{closure#0}, core[7ac8aee7065c0cc9]::result::Result<(), rustc_errors[fbe8c5f47b14aa4]::ErrorGuaranteed>>
  31:     0x7efe18b3fbd0 - <<std[25baae9c6c77129a]::thread::Builder>::spawn_unchecked_<rustc_interface[c5619889e11552cd]::util::run_in_thread_pool_with_globals<rustc_interface[c5619889e11552cd]::interface::run_compiler<core[7ac8aee7065c0cc9]::result::Result<(), rustc_errors[fbe8c5f47b14aa4]::ErrorGuaranteed>, rustc_driver[6635a35d3e701dd7]::run_compiler::{closure#1}>::{closure#0}, core[7ac8aee7065c0cc9]::result::Result<(), rustc_errors[fbe8c5f47b14aa4]::ErrorGuaranteed>>::{closure#0}, core[7ac8aee7065c0cc9]::result::Result<(), rustc_errors[fbe8c5f47b14aa4]::ErrorGuaranteed>>::{closure#1} as core[7ac8aee7065c0cc9]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  32:     0x7efe16485663 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h15b2b49f1be836c1
                               at /rustc/8ce3204af9463db3192ea1eb31c45c2f6d4b5ae6/library/alloc/src/boxed.rs:1938:9
  33:     0x7efe16485663 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h2e516647663708b1
                               at /rustc/8ce3204af9463db3192ea1eb31c45c2f6d4b5ae6/library/alloc/src/boxed.rs:1938:9
  34:     0x7efe16485663 - std::sys::unix::thread::Thread::new::thread_start::hf5914966a92465bd
                               at /rustc/8ce3204af9463db3192ea1eb31c45c2f6d4b5ae6/library/std/src/sys/unix/thread.rs:108:17
  35:     0x7efe16358609 - start_thread
  36:     0x7efe1627b133 - clone
  37:                0x0 - <unknown>

error: internal compiler error: unexpected panic

note: the compiler unexpectedly panicked. this is a bug.

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.66.0-nightly (8ce3204af 2022-09-30) running on x86_64-unknown-linux-gnu

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: internal compiler error: no errors encountered even though `delay_span_bug` issued

error: internal compiler error: broken MIR in DefId(0:6 ~ playground[a15c]::main) (move _5 as dyn* std::fmt::Debug (Pointer(ArrayToPointer))): ArrayToPointer cast from unexpected type &i32
 --> src/main.rs:8:13
  |
8 |     let i = foo as dyn* Debug;
  |             ^^^^^^^^^^^^^^^^^
  |
  = note: delayed at compiler/rustc_borrowck/src/type_check/mod.rs:2125:29

thread 'rustc' panicked at 'Box<dyn Any>', compiler/rustc_errors/src/lib.rs:1530:13
stack backtrace:
   0:     0x7efe16478470 - std::backtrace_rs::backtrace::libunwind::trace::h48a6b877947e3b61
                               at /rustc/8ce3204af9463db3192ea1eb31c45c2f6d4b5ae6/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   1:     0x7efe16478470 - std::backtrace_rs::backtrace::trace_unsynchronized::hfe09011594941abe
                               at /rustc/8ce3204af9463db3192ea1eb31c45c2f6d4b5ae6/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x7efe16478470 - std::sys_common::backtrace::_print_fmt::h9ce2ad36264dcd3e
                               at /rustc/8ce3204af9463db3192ea1eb31c45c2f6d4b5ae6/library/std/src/sys_common/backtrace.rs:66:5
   3:     0x7efe16478470 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h4f730349406daa4f
                               at /rustc/8ce3204af9463db3192ea1eb31c45c2f6d4b5ae6/library/std/src/sys_common/backtrace.rs:45:22
   4:     0x7efe164d330e - core::fmt::write::h4545826f01b877ac
                               at /rustc/8ce3204af9463db3192ea1eb31c45c2f6d4b5ae6/library/core/src/fmt/mod.rs:1209:17
   5:     0x7efe164690f5 - std::io::Write::write_fmt::hac4d3a613c78c8e4
                               at /rustc/8ce3204af9463db3192ea1eb31c45c2f6d4b5ae6/library/std/src/io/mod.rs:1679:15
   6:     0x7efe1647b213 - std::sys_common::backtrace::_print::ha560f7b733dc8a6e
                               at /rustc/8ce3204af9463db3192ea1eb31c45c2f6d4b5ae6/library/std/src/sys_common/backtrace.rs:48:5
   7:     0x7efe1647b213 - std::sys_common::backtrace::print::hcca78599db59c8b4
                               at /rustc/8ce3204af9463db3192ea1eb31c45c2f6d4b5ae6/library/std/src/sys_common/backtrace.rs:35:9
   8:     0x7efe1647b213 - std::panicking::default_hook::{{closure}}::h0d6a74e6cb8499ce
                               at /rustc/8ce3204af9463db3192ea1eb31c45c2f6d4b5ae6/library/std/src/panicking.rs:267:22
   9:     0x7efe1647aeea - std::panicking::default_hook::hcb5d3609ae810fb1
                               at /rustc/8ce3204af9463db3192ea1eb31c45c2f6d4b5ae6/library/std/src/panicking.rs:286:9
  10:     0x7efe18cda7d1 - rustc_driver[6635a35d3e701dd7]::DEFAULT_HOOK::{closure#0}::{closure#0}
  11:     0x7efe1647ba4b - <alloc::boxed::Box<F,A> as core::ops::function::Fn<Args>>::call::hba26835306149e75
                               at /rustc/8ce3204af9463db3192ea1eb31c45c2f6d4b5ae6/library/alloc/src/boxed.rs:1952:9
  12:     0x7efe1647ba4b - std::panicking::rust_panic_with_hook::h4f2461a1c1c1a86e
                               at /rustc/8ce3204af9463db3192ea1eb31c45c2f6d4b5ae6/library/std/src/panicking.rs:673:13
  13:     0x7efe19df7751 - std[25baae9c6c77129a]::panicking::begin_panic::<rustc_errors[fbe8c5f47b14aa4]::ExplicitBug>::{closure#0}
  14:     0x7efe19df6076 - std[25baae9c6c77129a]::sys_common::backtrace::__rust_end_short_backtrace::<std[25baae9c6c77129a]::panicking::begin_panic<rustc_errors[fbe8c5f47b14aa4]::ExplicitBug>::{closure#0}, !>
  15:     0x7efe19deff56 - std[25baae9c6c77129a]::panicking::begin_panic::<rustc_errors[fbe8c5f47b14aa4]::ExplicitBug>
  16:     0x7efe19df2836 - std[25baae9c6c77129a]::panic::panic_any::<rustc_errors[fbe8c5f47b14aa4]::ExplicitBug>
  17:     0x7efe18839188 - <rustc_errors[fbe8c5f47b14aa4]::HandlerInner as core[7ac8aee7065c0cc9]::ops::drop::Drop>::drop
  18:     0x7efe179cf038 - core[7ac8aee7065c0cc9]::ptr::drop_in_place::<rustc_session[cbaad9a29d9fac78]::parse::ParseSess>
  19:     0x7efe1798f2b8 - <alloc[31d53a49c811d0c6]::rc::Rc<rustc_session[cbaad9a29d9fac78]::session::Session> as core[7ac8aee7065c0cc9]::ops::drop::Drop>::drop
  20:     0x7efe1798c33d - core[7ac8aee7065c0cc9]::ptr::drop_in_place::<rustc_interface[c5619889e11552cd]::interface::Compiler>
  21:     0x7efe1798a3e1 - rustc_interface[c5619889e11552cd]::interface::create_compiler_and_run::<core[7ac8aee7065c0cc9]::result::Result<(), rustc_errors[fbe8c5f47b14aa4]::ErrorGuaranteed>, rustc_driver[6635a35d3e701dd7]::run_compiler::{closure#1}>
  22:     0x7efe17987ed1 - <scoped_tls[d196d212a4d59b56]::ScopedKey<rustc_span[ea709073fc09e903]::SessionGlobals>>::set::<rustc_interface[c5619889e11552cd]::interface::run_compiler<core[7ac8aee7065c0cc9]::result::Result<(), rustc_errors[fbe8c5f47b14aa4]::ErrorGuaranteed>, rustc_driver[6635a35d3e701dd7]::run_compiler::{closure#1}>::{closure#0}, core[7ac8aee7065c0cc9]::result::Result<(), rustc_errors[fbe8c5f47b14aa4]::ErrorGuaranteed>>
  23:     0x7efe17987bbf - std[25baae9c6c77129a]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[c5619889e11552cd]::util::run_in_thread_pool_with_globals<rustc_interface[c5619889e11552cd]::interface::run_compiler<core[7ac8aee7065c0cc9]::result::Result<(), rustc_errors[fbe8c5f47b14aa4]::ErrorGuaranteed>, rustc_driver[6635a35d3e701dd7]::run_compiler::{closure#1}>::{closure#0}, core[7ac8aee7065c0cc9]::result::Result<(), rustc_errors[fbe8c5f47b14aa4]::ErrorGuaranteed>>::{closure#0}, core[7ac8aee7065c0cc9]::result::Result<(), rustc_errors[fbe8c5f47b14aa4]::ErrorGuaranteed>>
  24:     0x7efe18b3fbd0 - <<std[25baae9c6c77129a]::thread::Builder>::spawn_unchecked_<rustc_interface[c5619889e11552cd]::util::run_in_thread_pool_with_globals<rustc_interface[c5619889e11552cd]::interface::run_compiler<core[7ac8aee7065c0cc9]::result::Result<(), rustc_errors[fbe8c5f47b14aa4]::ErrorGuaranteed>, rustc_driver[6635a35d3e701dd7]::run_compiler::{closure#1}>::{closure#0}, core[7ac8aee7065c0cc9]::result::Result<(), rustc_errors[fbe8c5f47b14aa4]::ErrorGuaranteed>>::{closure#0}, core[7ac8aee7065c0cc9]::result::Result<(), rustc_errors[fbe8c5f47b14aa4]::ErrorGuaranteed>>::{closure#1} as core[7ac8aee7065c0cc9]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  25:     0x7efe16485663 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h15b2b49f1be836c1
                               at /rustc/8ce3204af9463db3192ea1eb31c45c2f6d4b5ae6/library/alloc/src/boxed.rs:1938:9
  26:     0x7efe16485663 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h2e516647663708b1
                               at /rustc/8ce3204af9463db3192ea1eb31c45c2f6d4b5ae6/library/alloc/src/boxed.rs:1938:9
  27:     0x7efe16485663 - std::sys::unix::thread::Thread::new::thread_start::hf5914966a92465bd
                               at /rustc/8ce3204af9463db3192ea1eb31c45c2f6d4b5ae6/library/std/src/sys/unix/thread.rs:108:17
  28:     0x7efe16358609 - start_thread
  29:     0x7efe1627b133 - clone
  30:                0x0 - <unknown>

note: the compiler unexpectedly panicked. this is a bug.

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.66.0-nightly (8ce3204af 2022-09-30) running on x86_64-unknown-linux-gnu

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
thread panicked while panicking. aborting.
warning: `playground` (bin "playground") generated 1 warning
error: could not compile `playground`; 1 warning emitted

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: This is a bug.F-dyn_star`#![feature(dyn_star)]`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

    Issue actions