Skip to content

ICE on stable when trying to imitate trivial_bounds #94999

Closed
@GoldsteinE

Description

@GoldsteinE

Trying to emulate trivial bounds via generics & associated types panics on stable, beta and nightly.

Code

https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=7fd4f152df6e03d96a0f4e6c0b807cfd

trait Identity<Q> {
    type T;
}

impl<Q, T> Identity<Q> for T {
    type T = T;
}

trait Holds {
    type Q;
}


struct S;
struct X(S);

struct XHelper;

impl Holds for X {
    type Q = XHelper;
}

impl<Q> Clone for X where <S as Identity<Q>>::T: Clone, X: Holds<Q = Q> {
    fn clone(&self) -> Self {
        Self(self.0.clone())
    }
}

Meta

rustc --version --verbose:

note: rustc 1.59.0 (9d1b2106e 2022-02-23) running on x86_64-unknown-linux-gnu

Reproducible on beta and nightly

Error output

error: internal compiler error: Encountered error `Unimplemented` selecting `Binder(<S as std::clone::Clone>, [])` during codegen
  |
  = note: delayed at compiler/rustc_trait_selection/src/traits/codegen.rs:68:32

thread 'rustc' panicked at 'no errors encountered even though `delay_span_bug` issued', compiler/rustc_errors/src/lib.rs:1188:13
Backtrace

stack backtrace:
   0:     0x7ff60cfa58ad - std::backtrace_rs::backtrace::libunwind::trace::ha8f287310bdbcd77
                               at /rustc/99f967e7ed97803517e5fad18d27698cab977808/library/std/src/../../backtrace/src/backtrace/libunwind.rs:93:5
   1:     0x7ff60cfa58ad - std::backtrace_rs::backtrace::trace_unsynchronized::h7623a82dbfb4fb46
                               at /rustc/99f967e7ed97803517e5fad18d27698cab977808/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x7ff60cfa58ad - std::sys_common::backtrace::_print_fmt::hf1e6d43252933384
                               at /rustc/99f967e7ed97803517e5fad18d27698cab977808/library/std/src/sys_common/backtrace.rs:66:5
   3:     0x7ff60cfa58ad - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::hf9b8d0350fa16147
                               at /rustc/99f967e7ed97803517e5fad18d27698cab977808/library/std/src/sys_common/backtrace.rs:45:22
   4:     0x7ff60d00552c - core::fmt::write::hc4f5a0569d40abb2
                               at /rustc/99f967e7ed97803517e5fad18d27698cab977808/library/core/src/fmt/mod.rs:1190:17
   5:     0x7ff60cf95ad8 - std::io::Write::write_fmt::h61cc67cfa4ed049d
                               at /rustc/99f967e7ed97803517e5fad18d27698cab977808/library/std/src/io/mod.rs:1657:15
   6:     0x7ff60cfa9887 - std::sys_common::backtrace::_print::hb756cfd40b0abea2
                               at /rustc/99f967e7ed97803517e5fad18d27698cab977808/library/std/src/sys_common/backtrace.rs:48:5
   7:     0x7ff60cfa9887 - std::sys_common::backtrace::print::h18bde2ddc5524da3
                               at /rustc/99f967e7ed97803517e5fad18d27698cab977808/library/std/src/sys_common/backtrace.rs:35:9
   8:     0x7ff60cfa9887 - std::panicking::default_hook::{{closure}}::he75def497ad30ae6
                               at /rustc/99f967e7ed97803517e5fad18d27698cab977808/library/std/src/panicking.rs:295:22
   9:     0x7ff60cfa9550 - std::panicking::default_hook::h0635b9c9300448b4
                               at /rustc/99f967e7ed97803517e5fad18d27698cab977808/library/std/src/panicking.rs:314:9
  10:     0x7ff60d735731 - rustc_driver[fde845658e6d28a1]::DEFAULT_HOOK::{closure#0}::{closure#0}
  11:     0x7ff60cfaa164 - std::panicking::rust_panic_with_hook::hc3f0194fa4cee89d
                               at /rustc/99f967e7ed97803517e5fad18d27698cab977808/library/std/src/panicking.rs:702:17
  12:     0x7ff60cfa9e17 - std::panicking::begin_panic_handler::{{closure}}::h9a433f193b926a3c
                               at /rustc/99f967e7ed97803517e5fad18d27698cab977808/library/std/src/panicking.rs:588:13
  13:     0x7ff60cfa5d74 - std::sys_common::backtrace::__rust_end_short_backtrace::h35fa457aa178928e
                               at /rustc/99f967e7ed97803517e5fad18d27698cab977808/library/std/src/sys_common/backtrace.rs:138:18
  14:     0x7ff60cfa9b29 - rust_begin_unwind
                               at /rustc/99f967e7ed97803517e5fad18d27698cab977808/library/std/src/panicking.rs:584:5
  15:     0x7ff60cf728a3 - core::panicking::panic_fmt::h2442b4ae872c60ae
                               at /rustc/99f967e7ed97803517e5fad18d27698cab977808/library/core/src/panicking.rs:143:14
  16:     0x7ff60e821a7c - core[a1225df82ec0a19e]::panicking::panic_display::<&str>
  17:     0x7ff60fe7695d - <rustc_errors[2de1ab05ff8f630e]::HandlerInner>::flush_delayed
  18:     0x7ff60fe74dba - <rustc_errors[2de1ab05ff8f630e]::HandlerInner as core[a1225df82ec0a19e]::ops::drop::Drop>::drop
  19:     0x7ff60f5990f6 - core[a1225df82ec0a19e]::ptr::drop_in_place::<rustc_session[9bb0fc831dcf3ae9]::parse::ParseSess>
  20:     0x7ff60f59b99a - <alloc[c470e77ec7ef658d]::rc::Rc<rustc_session[9bb0fc831dcf3ae9]::session::Session> as core[a1225df82ec0a19e]::ops::drop::Drop>::drop
  21:     0x7ff60f5807bc - core[a1225df82ec0a19e]::ptr::drop_in_place::<rustc_interface[8e82cc6f61f52ee6]::interface::Compiler>
  22:     0x7ff60f58945e - rustc_interface[8e82cc6f61f52ee6]::interface::create_compiler_and_run::<core[a1225df82ec0a19e]::result::Result<(), rustc_errors[2de1ab05ff8f630e]::ErrorReported>, rustc_driver[fde845658e6d28a1]::run_compiler::{closure#1}>
  23:     0x7ff60f56e6a4 - std[eb402c9241147050]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[8e82cc6f61f52ee6]::util::run_in_thread_pool_with_globals<rustc_interface[8e82cc6f61f52ee6]::interface::run_compiler<core[a1225df82ec0a19e]::result::Result<(), rustc_errors[2de1ab05ff8f630e]::ErrorReported>, rustc_driver[fde845658e6d28a1]::run_compiler::{closure#1}>::{closure#0}, core[a1225df82ec0a19e]::result::Result<(), rustc_errors[2de1ab05ff8f630e]::ErrorReported>>::{closure#0}, core[a1225df82ec0a19e]::result::Result<(), rustc_errors[2de1ab05ff8f630e]::ErrorReported>>
  24:     0x7ff60f5a1929 - <<std[eb402c9241147050]::thread::Builder>::spawn_unchecked_<rustc_interface[8e82cc6f61f52ee6]::util::run_in_thread_pool_with_globals<rustc_interface[8e82cc6f61f52ee6]::interface::run_compiler<core[a1225df82ec0a19e]::result::Result<(), rustc_errors[2de1ab05ff8f630e]::ErrorReported>, rustc_driver[fde845658e6d28a1]::run_compiler::{closure#1}>::{closure#0}, core[a1225df82ec0a19e]::result::Result<(), rustc_errors[2de1ab05ff8f630e]::ErrorReported>>::{closure#0}, core[a1225df82ec0a19e]::result::Result<(), rustc_errors[2de1ab05ff8f630e]::ErrorReported>>::{closure#1} as core[a1225df82ec0a19e]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  25:     0x7ff60cfb5d43 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h95a31efa3bb13b59
                               at /rustc/99f967e7ed97803517e5fad18d27698cab977808/library/alloc/src/boxed.rs:1854:9
  26:     0x7ff60cfb5d43 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h65d3a2f2433c608a
                               at /rustc/99f967e7ed97803517e5fad18d27698cab977808/library/alloc/src/boxed.rs:1854:9
  27:     0x7ff60cfb5d43 - std::sys::unix::thread::Thread::new::thread_start::h28cc0caaa86ab15b
                               at /rustc/99f967e7ed97803517e5fad18d27698cab977808/library/std/src/sys/unix/thread.rs:108:17
  28:     0x7ff60cee9609 - start_thread
  29:     0x7ff60ce02163 - clone
  30:                0x0 - <unknown>

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