Skip to content

[_; 33] implements Copy, but not Clone #40796

Closed
@LunaBorowska

Description

@LunaBorowska

From https://www.reddit.com/r/rust/comments/616rc8/rcpp_discusses_rust/dfcjk09/

The following code:

fn clone_copy_type<T: Copy>(t: T) -> T {
    t.clone()
}

fn main() {
    // [_; 33] implements Copy, but not Clone, violating trait inheritance
    clone_copy_type([(); 33]);
}

Causes the following crash in playpen, due to [T; 33] (where T: Copy) implementing Copy, but not Clone, but Copy trait requiring Clone implementation.

error: internal compiler error: /checkout/src/librustc_trans/monomorphize.rs:151: Encountered error `Unimplemented` selecting `Binder(<[(); 33] as std::clone::Clone>)` during trans

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

note: we would appreciate a bug report: https://github.com/rust-lang/rust/blob/master/CONTRIBUTING.md#bug-reports

thread 'rustc' panicked at 'Box<Any>', /checkout/src/librustc_errors/lib.rs:377
note: Run with `RUST_BACKTRACE=1` for a backtrace.

Metadata

Metadata

Assignees

No one assigned

    Labels

    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