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

Error duplicate definitions for impls on distinct associated types #58171

Open
dbeckwith opened this issue Feb 4, 2019 · 1 comment
Open
Labels
A-associated-items Area: Associated items (types, constants & functions) A-typesystem Area: The type system C-bug Category: This is a bug. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@dbeckwith
Copy link

dbeckwith commented Feb 4, 2019

As a minimal example of the error I'm running into (using the typenum crate although I don't think it's specific to that):

use core::{marker::PhantomData, ops::Add};
use typenum::*;

struct Wrapper<T>(PhantomData<T>);

type X = <U2 as Add<U3>>::Output;
type Y = <U7 as Add<U9>>::Output;

impl Wrapper<X> {
    fn foo() {}
}

impl Wrapper<Y> {
    fn foo() {}
}

gives

error[E0592]: duplicate definitions with name `foo`
  --> .../lib.rs:30:9
   |
30 |         fn foo() {}
   |         ^^^^^^^^^^^ duplicate definitions for `foo`
...
34 |         fn foo() {}
   |         ----------- other definition for `foo`

I think this might be related to #20400, but I'm not sure. I tried making a simpler reproduction on the playground without using typenum, but I wasn't able to.

Clearly, X and Y are distinct types, as they are not assignable to each other, so why can't I define the same function in impls for them?

Playground

@estebank estebank added A-typesystem Area: The type system A-associated-items Area: Associated items (types, constants & functions) labels Feb 5, 2019
@jonas-schievink jonas-schievink added the C-bug Category: This is a bug. label May 16, 2019
@Spoonbender
Copy link

Triage: no change

@Noratrieb Noratrieb added the T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. label Apr 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-associated-items Area: Associated items (types, constants & functions) A-typesystem Area: The type system C-bug Category: This is a bug. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

5 participants