Skip to content

Broken MIR ICE when returning dyn* Trait from a function #104501

Closed
@PatchMixolydic

Description

@PatchMixolydic

Code

(playground)

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

fn _foo() -> dyn* Unpin {
    4usize
}

This happens whether or not the returned type implements the trait in question.

Meta

1.67.0-nightly (2022-11-15 a00f8ba7fcac1b273416)

Error output

error: internal compiler error: no errors encountered even though `delay_span_bug` issued

error: internal compiler error: broken MIR in DefId(0:3 ~ playground[dad8]::_foo) (_0 = const 4_usize): bad assignment (dyn* std::marker::Unpin = usize): NoSolution
 --> src/lib.rs:5:5
  |
5 |     4usize
  |     ^^^^^^
  |
  = note: delayed at compiler/rustc_borrowck/src/type_check/mod.rs:1246:21
Backtrace

thread 'rustc' panicked at 'Box<dyn Any>', compiler/rustc_errors/src/lib.rs:1589:13
stack backtrace:
   0:     0x7f7b43dc3030 - std::backtrace_rs::backtrace::libunwind::trace::h623ca7c2545da367
                               at /rustc/a00f8ba7fcac1b27341679c51bf5a3271fa82df3/library/std/src/../../backtrace/src/backtrace/libunwind.rs:93:5
   1:     0x7f7b43dc3030 - std::backtrace_rs::backtrace::trace_unsynchronized::h339e54194b7bf843
                               at /rustc/a00f8ba7fcac1b27341679c51bf5a3271fa82df3/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x7f7b43dc3030 - std::sys_common::backtrace::_print_fmt::h39130984054109fd
                               at /rustc/a00f8ba7fcac1b27341679c51bf5a3271fa82df3/library/std/src/sys_common/backtrace.rs:65:5
   3:     0x7f7b43dc3030 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::hfa5e4aa18ece27ff
                               at /rustc/a00f8ba7fcac1b27341679c51bf5a3271fa82df3/library/std/src/sys_common/backtrace.rs:44:22
   4:     0x7f7b3feed31e - core::fmt::write::h89f6ec0de92eb2ba
                               at /rustc/a00f8ba7fcac1b27341679c51bf5a3271fa82df3/library/core/src/fmt/mod.rs:1208:17
   5:     0x7f7b43db7205 - std::io::Write::write_fmt::hf0e465d1b13cde08
                               at /rustc/a00f8ba7fcac1b27341679c51bf5a3271fa82df3/library/std/src/io/mod.rs:1682:15
   6:     0x7f7b43dc2df5 - std::sys_common::backtrace::_print::h5c3a6b9e92733123
                               at /rustc/a00f8ba7fcac1b27341679c51bf5a3271fa82df3/library/std/src/sys_common/backtrace.rs:47:5
   7:     0x7f7b43dc2df5 - std::sys_common::backtrace::print::h617c6080818fd336
                               at /rustc/a00f8ba7fcac1b27341679c51bf5a3271fa82df3/library/std/src/sys_common/backtrace.rs:34:9
   8:     0x7f7b43dc510f - std::panicking::default_hook::{{closure}}::ha4c000959a58a266
                               at /rustc/a00f8ba7fcac1b27341679c51bf5a3271fa82df3/library/std/src/panicking.rs:267:22
   9:     0x7f7b43dc4e4a - std::panicking::default_hook::h80287e6b1a8ab5a3
                               at /rustc/a00f8ba7fcac1b27341679c51bf5a3271fa82df3/library/std/src/panicking.rs:286:9
  10:     0x7f7b43047bb1 - rustc_driver[264bd666a4ec3967]::DEFAULT_HOOK::{closure#0}::{closure#0}
  11:     0x7f7b43dc58fd - <alloc::boxed::Box<F,A> as core::ops::function::Fn<Args>>::call::hf1c3b2c68f483dfb
                               at /rustc/a00f8ba7fcac1b27341679c51bf5a3271fa82df3/library/alloc/src/boxed.rs:2032:9
  12:     0x7f7b43dc58fd - std::panicking::rust_panic_with_hook::hd38f216792535192
                               at /rustc/a00f8ba7fcac1b27341679c51bf5a3271fa82df3/library/std/src/panicking.rs:692:13
  13:     0x7f7b43077cc1 - std[a12c3934657dc52f]::panicking::begin_panic::<rustc_errors[5b60f759d3f57066]::ExplicitBug>::{closure#0}
  14:     0x7f7b43076a06 - std[a12c3934657dc52f]::sys_common::backtrace::__rust_end_short_backtrace::<std[a12c3934657dc52f]::panicking::begin_panic<rustc_errors[5b60f759d3f57066]::ExplicitBug>::{closure#0}, !>
  15:     0x7f7b4306fec6 - std[a12c3934657dc52f]::panicking::begin_panic::<rustc_errors[5b60f759d3f57066]::ExplicitBug>
  16:     0x7f7b430730d6 - std[a12c3934657dc52f]::panic::panic_any::<rustc_errors[5b60f759d3f57066]::ExplicitBug>
  17:     0x7f7b425a78a8 - <rustc_errors[5b60f759d3f57066]::HandlerInner>::flush_delayed::<alloc[c53c64b3104340d2]::vec::Vec<rustc_errors[5b60f759d3f57066]::diagnostic::Diagnostic>, &str>
  18:     0x7f7b42366d58 - <rustc_interface[1c4c4049c89b9f16]::passes::QueryContext>::enter::<<rustc_interface[1c4c4049c89b9f16]::queries::Queries>::ongoing_codegen::{closure#0}::{closure#0}, core[3fabb2b3983330a3]::result::Result<alloc[c53c64b3104340d2]::boxed::Box<dyn core[3fabb2b3983330a3]::any::Any>, rustc_errors[5b60f759d3f57066]::ErrorGuaranteed>>
  19:     0x7f7b42363e83 - <rustc_interface[1c4c4049c89b9f16]::queries::Queries>::ongoing_codegen
  20:     0x7f7b42362f92 - <rustc_interface[1c4c4049c89b9f16]::interface::Compiler>::enter::<rustc_driver[264bd666a4ec3967]::run_compiler::{closure#1}::{closure#2}, core[3fabb2b3983330a3]::result::Result<core[3fabb2b3983330a3]::option::Option<rustc_interface[1c4c4049c89b9f16]::queries::Linker>, rustc_errors[5b60f759d3f57066]::ErrorGuaranteed>>
  21:     0x7f7b4235dfb2 - rustc_span[9a6606dc9b427585]::with_source_map::<core[3fabb2b3983330a3]::result::Result<(), rustc_errors[5b60f759d3f57066]::ErrorGuaranteed>, rustc_interface[1c4c4049c89b9f16]::interface::run_compiler<core[3fabb2b3983330a3]::result::Result<(), rustc_errors[5b60f759d3f57066]::ErrorGuaranteed>, rustc_driver[264bd666a4ec3967]::run_compiler::{closure#1}>::{closure#0}::{closure#1}>
  22:     0x7f7b4235da8c - <scoped_tls[1c7f0121e168e3b1]::ScopedKey<rustc_span[9a6606dc9b427585]::SessionGlobals>>::set::<rustc_interface[1c4c4049c89b9f16]::interface::run_compiler<core[3fabb2b3983330a3]::result::Result<(), rustc_errors[5b60f759d3f57066]::ErrorGuaranteed>, rustc_driver[264bd666a4ec3967]::run_compiler::{closure#1}>::{closure#0}, core[3fabb2b3983330a3]::result::Result<(), rustc_errors[5b60f759d3f57066]::ErrorGuaranteed>>
  23:     0x7f7b4235d078 - std[a12c3934657dc52f]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[1c4c4049c89b9f16]::util::run_in_thread_pool_with_globals<rustc_interface[1c4c4049c89b9f16]::interface::run_compiler<core[3fabb2b3983330a3]::result::Result<(), rustc_errors[5b60f759d3f57066]::ErrorGuaranteed>, rustc_driver[264bd666a4ec3967]::run_compiler::{closure#1}>::{closure#0}, core[3fabb2b3983330a3]::result::Result<(), rustc_errors[5b60f759d3f57066]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[3fabb2b3983330a3]::result::Result<(), rustc_errors[5b60f759d3f57066]::ErrorGuaranteed>>
  24:     0x7f7b4235cd9c - <<std[a12c3934657dc52f]::thread::Builder>::spawn_unchecked_<rustc_interface[1c4c4049c89b9f16]::util::run_in_thread_pool_with_globals<rustc_interface[1c4c4049c89b9f16]::interface::run_compiler<core[3fabb2b3983330a3]::result::Result<(), rustc_errors[5b60f759d3f57066]::ErrorGuaranteed>, rustc_driver[264bd666a4ec3967]::run_compiler::{closure#1}>::{closure#0}, core[3fabb2b3983330a3]::result::Result<(), rustc_errors[5b60f759d3f57066]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[3fabb2b3983330a3]::result::Result<(), rustc_errors[5b60f759d3f57066]::ErrorGuaranteed>>::{closure#1} as core[3fabb2b3983330a3]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  25:     0x7f7b43dccc63 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::he19adc936b97b661
                               at /rustc/a00f8ba7fcac1b27341679c51bf5a3271fa82df3/library/alloc/src/boxed.rs:2000:9
  26:     0x7f7b43dccc63 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h6b08bc0be1f88378
                               at /rustc/a00f8ba7fcac1b27341679c51bf5a3271fa82df3/library/alloc/src/boxed.rs:2000:9
  27:     0x7f7b43dccc63 - std::sys::unix::thread::Thread::new::thread_start::hb8a4d02754a9d514
                               at /rustc/a00f8ba7fcac1b27341679c51bf5a3271fa82df3/library/std/src/sys/unix/thread.rs:108:17
  28:     0x7f7b3fd60609 - start_thread
  29:     0x7f7b3fc83133 - 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.67.0-nightly (a00f8ba7f 2022-11-15) running on x86_64-unknown-linux-gnu

note: compiler flags: --crate-type lib -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

@rustbot modify labels +F-dyn_star

Metadata

Metadata

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