Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

E0119 errors are unhelpful when doing things involving types from another crate #36162

Closed
glandium opened this issue Aug 31, 2016 · 3 comments
Closed
Labels
A-diagnostics Area: Messages for errors, warnings, and lints C-bug Category: This is a bug.

Comments

@glandium
Copy link
Contributor

I was trying to do something like this:

use std::io;

enum Foo<T> {
    Bar(T),
    Qux,
}

impl<T: PartialEq> PartialEq for Foo<T> {
    fn eq(&self, other: &Self) -> bool {
        match (self, other) {
            (&Foo::Bar(ref a), &Foo::Bar(ref b)) => a == b,
            (&Foo::Qux, &Foo::Qux) => true,
            (_, _) => false,
        }
    }
}

impl PartialEq for Foo<io::Error> {
    fn eq(&self, other: &Self) -> bool {
        unimplemented!()
    }
}

And got the following error as a result:

error: conflicting implementations of trait `std::cmp::PartialEq` for type `Foo<std::io::Error>`: [--explain E0119]
  --> <anon>:18:1
   |>
18 |> impl PartialEq for Foo<io::Error> {
   |> ^
note: conflicting implementation is here:
 --> <anon>:8:1
  |>
8 |> impl<T: PartialEq> PartialEq for Foo<T> {
  |> ^

error: aborting due to previous error

In and of itself, there is no straightforward explanation as to why this is happening, since io::Error doesn't implement PartialEq.

@bluss bluss added the A-diagnostics Area: Messages for errors, warnings, and lints label Aug 31, 2016
@gnzlbg
Copy link
Contributor

gnzlbg commented Nov 14, 2016

I ran into this and it took me a while to figure out what is wrong with my code:

trait A {}
trait B {}

trait Foo<T> { } 

impl<T, U> Foo<T> for U: A { ... }
impl<T, U> Foo<T> for U: B { ... }

The only information that the error gives is that there are two conflicting implementations.

I would have understood the problem faster if the error message would tell me why are these two implementations conflicting.

@steveklabnik steveklabnik removed the T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. label Mar 9, 2017
@qnighy
Copy link
Contributor

qnighy commented Jul 23, 2017

Seems to be a duplicate of #23980.

@Mark-Simulacrum
Copy link
Member

Closing as a duplicate of #23980. (Thanks @qnighy!)

@Mark-Simulacrum Mark-Simulacrum marked this as a duplicate of #23980 Jul 26, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-diagnostics Area: Messages for errors, warnings, and lints C-bug Category: This is a bug.
Projects
None yet
Development

No branches or pull requests

6 participants