Why does Equatable require conformation to Copyable?

The Equatable protocol is not non-Copyable.

It’s reasonable for Equatable to become non-Copyable, consider the code snippet below:

struct S: Equatable, ~Copyable {
    var value: Int
}

let a = S(value: 0)
let b = S(value: 1)

a == b // false

I’ve tried to suppress its conformation requirements to the 2 protocols, and the stdlib still compiles. Is there any reason for this requirement?

i think the reason is that the work hasn't yet been completed to support it (see the '(lack of) protocol generalizations' section from SE-437). FWIW there is a draft PR that was recently opened which looks like it intends to address many of these cases here: [WIP] Allow various StdLib protocols: ~Copyable, ~Escapable by airspeedswift · Pull Request #85079 · swiftlang/swift · GitHub (edit: not that i have any particular knowledge of what the actual plan is to roll out such changes – i'm just a speculative observer).

3 Likes

Got it, thanks!