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

Box<dyn* Trait> to Box<dyn Trait> ICE #106488

Closed
DutchGhost opened this issue Jan 5, 2023 · 2 comments · Fixed by #106532
Closed

Box<dyn* Trait> to Box<dyn Trait> ICE #106488

DutchGhost opened this issue Jan 5, 2023 · 2 comments · Fixed by #106532
Assignees
Labels
C-bug Category: This is a bug. F-dyn_star `#![feature(dyn_star)]` 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.

Comments

@DutchGhost
Copy link
Contributor

DutchGhost commented Jan 5, 2023

Code

#![feature(dyn_star)]

fn main() {
    let x: dyn* Send = &();
    Box::new(x) as Box<dyn Send>;
}

Meta

rustc --version --verbose:

rustc 1.68.0-nightly (659e169d3 2023-01-04)

Error output

thread 'rustc' panicked at 'assertion failed: `(left == right)`
  left: `DynStar`,
 right: `Dyn`', /rustc/659e169d37990b9c730a59a96081f2ef7afbe8f1/compiler/rustc_codegen_ssa/src/base.rs:156:13
Backtrace

stack backtrace:
   0:     0x7f55bf4af31a - std::backtrace_rs::backtrace::libunwind::trace::h7b93dcf5d2bf5d8f
                               at /rustc/659e169d37990b9c730a59a96081f2ef7afbe8f1/library/std/src/../../backtrace/src/backtrace/libunwind.rs:93:5
   1:     0x7f55bf4af31a - std::backtrace_rs::backtrace::trace_unsynchronized::hca1c5fe7c860d7ad
                               at /rustc/659e169d37990b9c730a59a96081f2ef7afbe8f1/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x7f55bf4af31a - std::sys_common::backtrace::_print_fmt::h2f271e6d7d34a602
                               at /rustc/659e169d37990b9c730a59a96081f2ef7afbe8f1/library/std/src/sys_common/backtrace.rs:65:5
   3:     0x7f55bf4af31a - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h85ec760477c81cf5
                               at /rustc/659e169d37990b9c730a59a96081f2ef7afbe8f1/library/std/src/sys_common/backtrace.rs:44:22
   4:     0x7f55bf51255e - core::fmt::write::h220487fa128c817c
                               at /rustc/659e169d37990b9c730a59a96081f2ef7afbe8f1/library/core/src/fmt/mod.rs:1208:17
   5:     0x7f55bf49f7f5 - std::io::Write::write_fmt::h34dc3bc331a1c7dd
                               at /rustc/659e169d37990b9c730a59a96081f2ef7afbe8f1/library/std/src/io/mod.rs:1682:15
   6:     0x7f55bf4af0e5 - std::sys_common::backtrace::_print::h3b125ffebe3df857
                               at /rustc/659e169d37990b9c730a59a96081f2ef7afbe8f1/library/std/src/sys_common/backtrace.rs:47:5
   7:     0x7f55bf4af0e5 - std::sys_common::backtrace::print::hf7d8558de48d8cb3
                               at /rustc/659e169d37990b9c730a59a96081f2ef7afbe8f1/library/std/src/sys_common/backtrace.rs:34:9
   8:     0x7f55bf4b1eaf - std::panicking::default_hook::{{closure}}::ha651bf9954ee661b
                               at /rustc/659e169d37990b9c730a59a96081f2ef7afbe8f1/library/std/src/panicking.rs:267:22
   9:     0x7f55bf4b1beb - std::panicking::default_hook::ha6537ec9da38c7b4
                               at /rustc/659e169d37990b9c730a59a96081f2ef7afbe8f1/library/std/src/panicking.rs:286:9
  10:     0x7f55c27c1e74 - <rustc_driver[58f2a498cb46ff05]::DEFAULT_HOOK::{closure#0}::{closure#0} as core[c214e3ae48b876b8]::ops::function::FnOnce<(&core[c214e3ae48b876b8]::panic::panic_info::PanicInfo,)>>::call_once::{shim:vtable#0}
  11:     0x7f55bf4b26ed - <alloc::boxed::Box<F,A> as core::ops::function::Fn<Args>>::call::h88896c197914eaa1
                               at /rustc/659e169d37990b9c730a59a96081f2ef7afbe8f1/library/alloc/src/boxed.rs:2002:9
  12:     0x7f55bf4b26ed - std::panicking::rust_panic_with_hook::he842138d28343c68
                               at /rustc/659e169d37990b9c730a59a96081f2ef7afbe8f1/library/std/src/panicking.rs:692:13
  13:     0x7f55bf4b2469 - std::panicking::begin_panic_handler::{{closure}}::h7a35eb919cedf809
                               at /rustc/659e169d37990b9c730a59a96081f2ef7afbe8f1/library/std/src/panicking.rs:579:13
  14:     0x7f55bf4af7cc - std::sys_common::backtrace::__rust_end_short_backtrace::hb239bdeff35ec750
                               at /rustc/659e169d37990b9c730a59a96081f2ef7afbe8f1/library/std/src/sys_common/backtrace.rs:137:18
  15:     0x7f55bf4b2172 - rust_begin_unwind
                               at /rustc/659e169d37990b9c730a59a96081f2ef7afbe8f1/library/std/src/panicking.rs:575:5
  16:     0x7f55bf50ef23 - core::panicking::panic_fmt::h878a05c5eb5857ea
                               at /rustc/659e169d37990b9c730a59a96081f2ef7afbe8f1/library/core/src/panicking.rs:64:14
  17:     0x7f55bf50f33f - core::panicking::assert_failed_inner::h0329233c302fe17f
  18:     0x7f55c262a232 - core[c214e3ae48b876b8]::panicking::assert_failed::<rustc_type_ir[59ae504fef41e640]::sty::DynKind, rustc_type_ir[59ae504fef41e640]::sty::DynKind>
  19:     0x7f55c0f59bde - rustc_codegen_ssa[a97c59fdb0d9a00c]::base::unsized_info::<rustc_codegen_llvm[eb6b327ede3e8f32]::builder::Builder>
  20:     0x7f55c0f38b31 - rustc_codegen_ssa[a97c59fdb0d9a00c]::base::unsize_ptr::<rustc_codegen_llvm[eb6b327ede3e8f32]::builder::Builder>
  21:     0x7f55c0f38d31 - rustc_codegen_ssa[a97c59fdb0d9a00c]::base::unsize_ptr::<rustc_codegen_llvm[eb6b327ede3e8f32]::builder::Builder>
  22:     0x7f55c0f38d31 - rustc_codegen_ssa[a97c59fdb0d9a00c]::base::unsize_ptr::<rustc_codegen_llvm[eb6b327ede3e8f32]::builder::Builder>
  23:     0x7f55c0f38d31 - rustc_codegen_ssa[a97c59fdb0d9a00c]::base::unsize_ptr::<rustc_codegen_llvm[eb6b327ede3e8f32]::builder::Builder>
  24:     0x7f55c0ef8a20 - <rustc_codegen_ssa[a97c59fdb0d9a00c]::mir::FunctionCx<rustc_codegen_llvm[eb6b327ede3e8f32]::builder::Builder>>::codegen_block
  25:     0x7f55c0ee3777 - rustc_codegen_ssa[a97c59fdb0d9a00c]::mir::codegen_mir::<rustc_codegen_llvm[eb6b327ede3e8f32]::builder::Builder>
  26:     0x7f55c12386a6 - rustc_codegen_llvm[eb6b327ede3e8f32]::base::compile_codegen_unit::module_codegen
  27:     0x7f55c1e95993 - <rustc_query_system[45817d1f18aeef64]::dep_graph::graph::DepGraph<rustc_middle[63a206be65c00384]::dep_graph::dep_node::DepKind>>::with_task::<rustc_middle[63a206be65c00384]::ty::context::TyCtxt, rustc_span[ec779563c92f2e17]::symbol::Symbol, rustc_codegen_ssa[a97c59fdb0d9a00c]::ModuleCodegen<rustc_codegen_llvm[eb6b327ede3e8f32]::ModuleLlvm>>
  28:     0x7f55c1e957c3 - rustc_codegen_llvm[eb6b327ede3e8f32]::base::compile_codegen_unit
  29:     0x7f55c1c67925 - rustc_codegen_ssa[a97c59fdb0d9a00c]::base::codegen_crate::<rustc_codegen_llvm[eb6b327ede3e8f32]::LlvmCodegenBackend>
  30:     0x7f55c1c670f9 - <rustc_codegen_llvm[eb6b327ede3e8f32]::LlvmCodegenBackend as rustc_codegen_ssa[a97c59fdb0d9a00c]::traits::backend::CodegenBackend>::codegen_crate
  31:     0x7f55c1a13f81 - <rustc_session[75adbfaf96023e3]::session::Session>::time::<alloc[97080efe763d84b]::boxed::Box<dyn core[c214e3ae48b876b8]::any::Any>, rustc_interface[3422b3c162eb3570]::passes::start_codegen::{closure#0}>
  32:     0x7f55c1a13aa9 - rustc_interface[3422b3c162eb3570]::passes::start_codegen
  33:     0x7f55c1a117d6 - <rustc_interface[3422b3c162eb3570]::passes::QueryContext>::enter::<<rustc_interface[3422b3c162eb3570]::queries::Queries>::ongoing_codegen::{closure#0}::{closure#0}, core[c214e3ae48b876b8]::result::Result<alloc[97080efe763d84b]::boxed::Box<dyn core[c214e3ae48b876b8]::any::Any>, rustc_errors[6118211e3770648b]::ErrorGuaranteed>>
  34:     0x7f55c1a0ee06 - <rustc_interface[3422b3c162eb3570]::queries::Queries>::ongoing_codegen
  35:     0x7f55c1a0e327 - <rustc_interface[3422b3c162eb3570]::interface::Compiler>::enter::<rustc_driver[58f2a498cb46ff05]::run_compiler::{closure#1}::{closure#2}, core[c214e3ae48b876b8]::result::Result<core[c214e3ae48b876b8]::option::Option<rustc_interface[3422b3c162eb3570]::queries::Linker>, rustc_errors[6118211e3770648b]::ErrorGuaranteed>>
  36:     0x7f55c1a092d8 - rustc_span[ec779563c92f2e17]::with_source_map::<core[c214e3ae48b876b8]::result::Result<(), rustc_errors[6118211e3770648b]::ErrorGuaranteed>, rustc_interface[3422b3c162eb3570]::interface::run_compiler<core[c214e3ae48b876b8]::result::Result<(), rustc_errors[6118211e3770648b]::ErrorGuaranteed>, rustc_driver[58f2a498cb46ff05]::run_compiler::{closure#1}>::{closure#0}::{closure#0}>
  37:     0x7f55c1a08dc5 - <scoped_tls[22f0344cbf7950b5]::ScopedKey<rustc_span[ec779563c92f2e17]::SessionGlobals>>::set::<rustc_interface[3422b3c162eb3570]::interface::run_compiler<core[c214e3ae48b876b8]::result::Result<(), rustc_errors[6118211e3770648b]::ErrorGuaranteed>, rustc_driver[58f2a498cb46ff05]::run_compiler::{closure#1}>::{closure#0}, core[c214e3ae48b876b8]::result::Result<(), rustc_errors[6118211e3770648b]::ErrorGuaranteed>>
  38:     0x7f55c1a083b2 - std[9e86443dd599552f]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[3422b3c162eb3570]::util::run_in_thread_pool_with_globals<rustc_interface[3422b3c162eb3570]::interface::run_compiler<core[c214e3ae48b876b8]::result::Result<(), rustc_errors[6118211e3770648b]::ErrorGuaranteed>, rustc_driver[58f2a498cb46ff05]::run_compiler::{closure#1}>::{closure#0}, core[c214e3ae48b876b8]::result::Result<(), rustc_errors[6118211e3770648b]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[c214e3ae48b876b8]::result::Result<(), rustc_errors[6118211e3770648b]::ErrorGuaranteed>>
  39:     0x7f55c2093d8a - <<std[9e86443dd599552f]::thread::Builder>::spawn_unchecked_<rustc_interface[3422b3c162eb3570]::util::run_in_thread_pool_with_globals<rustc_interface[3422b3c162eb3570]::interface::run_compiler<core[c214e3ae48b876b8]::result::Result<(), rustc_errors[6118211e3770648b]::ErrorGuaranteed>, rustc_driver[58f2a498cb46ff05]::run_compiler::{closure#1}>::{closure#0}, core[c214e3ae48b876b8]::result::Result<(), rustc_errors[6118211e3770648b]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[c214e3ae48b876b8]::result::Result<(), rustc_errors[6118211e3770648b]::ErrorGuaranteed>>::{closure#1} as core[c214e3ae48b876b8]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  40:     0x7f55bf4bcb23 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::hec7bbc43877cbd11
                               at /rustc/659e169d37990b9c730a59a96081f2ef7afbe8f1/library/alloc/src/boxed.rs:1988:9
  41:     0x7f55bf4bcb23 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::hdfc0a3428bb0d8b0
                               at /rustc/659e169d37990b9c730a59a96081f2ef7afbe8f1/library/alloc/src/boxed.rs:1988:9
  42:     0x7f55bf4bcb23 - std::sys::unix::thread::Thread::new::thread_start::hd2dcc93e4007116d
                               at /rustc/659e169d37990b9c730a59a96081f2ef7afbe8f1/library/std/src/sys/unix/thread.rs:108:17
  43:     0x7f55bf380609 - start_thread
  44:     0x7f55bf2a3133 - clone
  45:                0x0 - <unknown>

@DutchGhost DutchGhost 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 Jan 5, 2023
@DutchGhost DutchGhost changed the title dyn* to dyn ICE Box<dyn* Trait> to Box<dyn Trait> ICE Jan 5, 2023
@clubby789
Copy link
Contributor

@rustbot label +F-dyn_star

@rustbot rustbot added the F-dyn_star `#![feature(dyn_star)]` label Jan 5, 2023
@compiler-errors
Copy link
Member

compiler-errors commented Jan 5, 2023

😆 the code thinks that this is a upcast, I think, rather than an unsize coercion. shouldn't be too hard to fix, but I may leave it for someone else.

edit: nvm I'll just fix it.

@compiler-errors compiler-errors self-assigned this Jan 6, 2023
JohnTitor pushed a commit to JohnTitor/rust that referenced this issue Jan 10, 2023
…=jackh726

Allow codegen to unsize `dyn*` to `dyn`

`dyn* Trait` is just another type that implements `Trait`, so we should be able to unsize `&dyn* Trait` into `&dyn Trait` perfectly fine, same for `Box` and other unsizeable types.

Fixes rust-lang#106488
@bors bors closed this as completed in e664cb2 Jan 12, 2023
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)]` 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.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants