Skip to content

deriving(Eq) requires Eq for type parameter even when phantom #7671

Closed
@kmcallister

Description

@kmcallister

Code:

#[deriving(Eq)]
struct Foo<T> {
    x: int,
}

struct Phantom;

fn main() {
    let x : Foo<Phantom> = Foo { x: 0 };
    println((x == x).to_str());
}

Result:

$ rust -v
rust 0.7 (a2db7c1 2013-07-02 09:25:44 -0700)
host: x86_64-unknown-linux-gnu
$ rust run foo.rs 
foo.rs:10:13: 10:19 error: failed to find an implementation of trait std::cmp::Eq for Phantom
foo.rs:10     println((x == x).to_str());

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-syntaxextArea: Syntax extensions

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions