Skip to content

Unimplemented selecting Binder(<std::pin::Pin<std::boxed::Box<B>> as std::ops::Drop>, []) #99575

Closed
@chrisprice

Description

@chrisprice

Code

use std::pin::Pin;

fn main() {
    let a = Enum::A(Pin::new(Box::new(A())));
    let b = Enum::B(Pin::new(Box::new(B())));
    println!("{:?} {:?}", a, b);
}

#[derive(Debug)]
enum Enum {
    A(Pin<Box<A>>),
    B(Pin<Box<B>>),
}

#[derive(Debug)]
struct A();

impl Drop for Pin<Box<A>> {
    fn drop(&mut self) {}
}

#[derive(Debug)]
struct B();

// UNCOMMENT TO FIX COMPILER ERROR
// impl Drop for Pin<Box<B>> {
//     fn drop(&mut self) {}
// }

Meta

rustc --version --verbose:

rustc 1.60.0 (7737e0b5c 2022-04-04)
binary: rustc
commit-hash: 7737e0b5c4103216d6fd8cf941b7ab9bdbaace7c
commit-date: 2022-04-04
host: aarch64-apple-darwin
release: 1.60.0
LLVM version: 14.0.0

Error output

   Compiling rust-pin-box-drop-compiler-error v0.1.0 (/<snip>/rust-pin-box-drop-compiler-error)
thread 'rustc' panicked at 'called `Result::unwrap()` on an `Err` value: ErrorReported', compiler/rustc_monomorphize/src/collector.rs:902:84
stack backtrace:
   0: _rust_begin_unwind
   1: core::panicking::panic_fmt
   2: core::result::unwrap_failed
   3: <rustc_monomorphize::collector::MirNeighborCollector as rustc_middle::mir::visit::Visitor>::visit_terminator
   4: rustc_monomorphize::collector::collect_neighbours
   5: rustc_monomorphize::collector::collect_items_rec
   6: rustc_monomorphize::collector::collect_items_rec
   7: rustc_monomorphize::collector::collect_items_rec
   8: <rustc_session::session::Session>::time::<(), rustc_monomorphize::collector::collect_crate_mono_items::{closure#1}>
   9: rustc_monomorphize::collector::collect_crate_mono_items
  10: rustc_monomorphize::partitioning::collect_and_partition_mono_items
  11: <rustc_query_system::dep_graph::graph::DepGraph<rustc_middle::dep_graph::dep_node::DepKind>>::with_task::<rustc_middle::ty::context::TyCtxt, (), (&std::collections::hash::set::HashSet<rustc_span::def_id::DefId, core::hash::BuildHasherDefault<rustc_hash::FxHasher>>, &[rustc_middle::mir::mono::CodegenUnit])>
  12: rustc_data_structures::stack::ensure_sufficient_stack::<((&std::collections::hash::set::HashSet<rustc_span::def_id::DefId, core::hash::BuildHasherDefault<rustc_hash::FxHasher>>, &[rustc_middle::mir::mono::CodegenUnit]), rustc_query_system::dep_graph::graph::DepNodeIndex), rustc_query_system::query::plumbing::execute_job<rustc_query_impl::plumbing::QueryCtxt, (), (&std::collections::hash::set::HashSet<rustc_span::def_id::DefId, core::hash::BuildHasherDefault<rustc_hash::FxHasher>>, &[rustc_middle::mir::mono::CodegenUnit])>::{closure#3}>
  13: rustc_query_system::query::plumbing::try_execute_query::<rustc_query_impl::plumbing::QueryCtxt, rustc_query_system::query::caches::DefaultCache<(), (&std::collections::hash::set::HashSet<rustc_span::def_id::DefId, core::hash::BuildHasherDefault<rustc_hash::FxHasher>>, &[rustc_middle::mir::mono::CodegenUnit])>>
  14: rustc_query_system::query::plumbing::get_query::<rustc_query_impl::queries::collect_and_partition_mono_items, rustc_query_impl::plumbing::QueryCtxt>
  15: <rustc_codegen_llvm::LlvmCodegenBackend as rustc_codegen_ssa::traits::backend::CodegenBackend>::codegen_crate
  16: <rustc_session::session::Session>::time::<alloc::boxed::Box<dyn core::any::Any>, rustc_interface::passes::start_codegen::{closure#0}>
  17: <rustc_interface::passes::QueryContext>::enter::<<rustc_interface::queries::Queries>::ongoing_codegen::{closure#0}::{closure#0}, core::result::Result<alloc::boxed::Box<dyn core::any::Any>, rustc_errors::ErrorReported>>
  18: <rustc_interface::queries::Queries>::ongoing_codegen
  19: rustc_interface::interface::create_compiler_and_run::<core::result::Result<(), rustc_errors::ErrorReported>, rustc_driver::run_compiler::{closure#1}>
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

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.60.0 (7737e0b5c 2022-04-04) running on aarch64-apple-darwin

note: compiler flags: --crate-type bin -C embed-bitcode=no -C split-debuginfo=unpacked -C debuginfo=2 -C incremental

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

query stack during panic:
#0 [collect_and_partition_mono_items] collect_and_partition_mono_items
end of query stack
error: internal compiler error: Encountered error `Unimplemented` selecting `Binder(<std::pin::Pin<std::boxed::Box<B>> as std::ops::Drop>, [])` during codegen
  |
  = note: delayed at compiler/rustc_trait_selection/src/traits/codegen.rs:69:32

thread 'rustc' panicked at 'no errors encountered even though `delay_span_bug` issued', compiler/rustc_errors/src/lib.rs:1176:13
stack backtrace:
   0:        0x1035b7118 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h10cf06316d33e2a9
   1:        0x103603808 - core::fmt::write::h1faf18c959c3a8df
   2:        0x1035a9104 - std::io::Write::write_fmt::h86ab231360bc97d2
   3:        0x1035bae44 - std::panicking::default_hook::{{closure}}::h36e628ffaf3cd44f
   4:        0x1035baabc - std::panicking::default_hook::h3ee1564a7544e58f
   5:        0x10a9905c4 - rustc_driver[3e35567b0507961a]::DEFAULT_HOOK::{closure#0}::{closure#0}
   6:        0x1035bb634 - std::panicking::rust_panic_with_hook::h191339fbd2fe2360
   7:        0x1035bb388 - std::panicking::begin_panic_handler::{{closure}}::h91c230befd9929e3
   8:        0x1035b7600 - std::sys_common::backtrace::__rust_end_short_backtrace::haaaeebb1d37476b3
   9:        0x1035bb0c4 - _rust_begin_unwind
  10:        0x1036317fc - core::panicking::panic_fmt::h4fe1013b011ef602
  11:        0x10e607e3c - core[e180da0f2c78f25f]::panicking::panic_display::<&str>
  12:        0x10e605724 - <rustc_errors[677d6d214e1093d1]::HandlerInner>::flush_delayed
  13:        0x10e60183c - <rustc_errors[677d6d214e1093d1]::HandlerInner as core[e180da0f2c78f25f]::ops::drop::Drop>::drop
  14:        0x10a9816e4 - core[e180da0f2c78f25f]::ptr::drop_in_place::<rustc_session[d383daeae0c11292]::parse::ParseSess>
  15:        0x10a985e04 - <alloc[a4749b0ad82606d]::rc::Rc<rustc_session[d383daeae0c11292]::session::Session> as core[e180da0f2c78f25f]::ops::drop::Drop>::drop
  16:        0x10a92e27c - core[e180da0f2c78f25f]::ptr::drop_in_place::<rustc_interface[2280aded15839b11]::interface::Compiler>
  17:        0x10a937c70 - rustc_interface[2280aded15839b11]::interface::create_compiler_and_run::<core[e180da0f2c78f25f]::result::Result<(), rustc_errors[677d6d214e1093d1]::ErrorReported>, rustc_driver[3e35567b0507961a]::run_compiler::{closure#1}>
  18:        0x10a91ecb0 - std[8541ff70ccfedbb0]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[2280aded15839b11]::util::run_in_thread_pool_with_globals<rustc_interface[2280aded15839b11]::interface::run_compiler<core[e180da0f2c78f25f]::result::Result<(), rustc_errors[677d6d214e1093d1]::ErrorReported>, rustc_driver[3e35567b0507961a]::run_compiler::{closure#1}>::{closure#0}, core[e180da0f2c78f25f]::result::Result<(), rustc_errors[677d6d214e1093d1]::ErrorReported>>::{closure#0}, core[e180da0f2c78f25f]::result::Result<(), rustc_errors[677d6d214e1093d1]::ErrorReported>>
  19:        0x10a998648 - <<std[8541ff70ccfedbb0]::thread::Builder>::spawn_unchecked_<rustc_interface[2280aded15839b11]::util::run_in_thread_pool_with_globals<rustc_interface[2280aded15839b11]::interface::run_compiler<core[e180da0f2c78f25f]::result::Result<(), rustc_errors[677d6d214e1093d1]::ErrorReported>, rustc_driver[3e35567b0507961a]::run_compiler::{closure#1}>::{closure#0}, core[e180da0f2c78f25f]::result::Result<(), rustc_errors[677d6d214e1093d1]::ErrorReported>>::{closure#0}, core[e180da0f2c78f25f]::result::Result<(), rustc_errors[677d6d214e1093d1]::ErrorReported>>::{closure#1} as core[e180da0f2c78f25f]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  20:        0x1035c6b70 - std::sys::unix::thread::Thread::new::thread_start::h8ccdabc567c5eee0
  21:        0x1939c626c - __pthread_deallocate

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.60.0 (7737e0b5c 2022-04-04) running on aarch64-apple-darwin

note: compiler flags: --crate-type bin -C embed-bitcode=no -C split-debuginfo=unpacked -C debuginfo=2 -C incremental

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

query stack during panic:
end of query stack
thread panicked while panicking. aborting.
error: could not compile `rust-pin-box-drop-compiler-error`

Caused by:
  process didn't exit successfully: `rustc --crate-name rust_pin_box_drop_compiler_error --edition=2021 src/main.rs --error-format=json --json=diagnostic-rendered-ansi,artifacts,future-incompat --crate-type bin --emit=dep-info,link -C embed-bitcode=no -C split-debuginfo=unpacked -C debuginfo=2 -C metadata=55127a2ec1f0f6f9 -C extra-filename=-55127a2ec1f0f6f9 --out-dir /<snip>/rust-pin-box-drop-compiler-error/target/debug/deps -C incremental=/<snip>/rust-pin-box-drop-compiler-error/target/debug/incremental -L dependency=/<snip>/rust-pin-box-drop-compiler-error/target/debug/deps` (signal: 6, SIGABRT: process abort signal)```


Metadata

Metadata

Labels

C-bugCategory: This is a bug.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.glacierICE tracked in rust-lang/glacier.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions