Skip to content

Marker types should implement standard traits (Hash, Eq, etc.) #17461

Closed
@zwarich

Description

@zwarich

It was surprising to me that the program

use std::kinds::marker::ContravariantLifetime;

#[deriving(Hash, Eq, PartialEq)]
struct A<'a> {
    x: u64,
    marker: ContravariantLifetime<'a>,
}

fn main() { }

gives this error:

test.rs:6:5: 6:38 error: type `core::kinds::marker::ContravariantLifetime<'_>` does not implement any method in scope named `assert_receiver_is_total_eq`
test.rs:6     marker: ContravariantLifetime<'a>,
              ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
test.rs:3:18: 3:20 note: in expansion of #[deriving(Eq)]
test.rs:6:5: 6:38 note: expansion site
test.rs:6:5: 6:38 error: type `core::kinds::marker::ContravariantLifetime<'_>` does not implement any method in scope named `hash`
test.rs:6     marker: ContravariantLifetime<'a>,
              ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
test.rs:3:12: 3:16 note: in expansion of #[deriving(Hash)]
test.rs:6:5: 6:38 note: expansion site
error: aborting due to 2 previous errors

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions