Skip to content

Cannot have the same supertrait twice, but with different type parameters #10596

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

Closed
burtonageo opened this issue Nov 21, 2013 · 6 comments
Closed
Assignees
Labels
A-trait-system Area: Trait system

Comments

@burtonageo
Copy link
Contributor

I am writing a Euclidean Vector class, and want to override some operations for it. However, when I try to add mul for both Vector-Vector multiplication and Vector-Scalar multiplication, the compiler complains that there is a Duplicate supertrait in trait declaration:

euclidean_vector.rs:5:0: 20:1 error: Duplicate supertrait in trait declaration
euclidean_vector.rs:5 pub trait EuclideanVector<T: Num + Algebraic> : 
euclidean_vector.rs:6   Add<Self, Self> +
euclidean_vector.rs:7   Sub<Self, Self> +
euclidean_vector.rs:8   Mul<Self, Self> +
euclidean_vector.rs:9   Mul<T, Self> +
euclidean_vector.rs:10   One + Zero +
@emberian
Copy link
Member

emberian commented Apr 7, 2014

cc @nikomatsakis, does your current work also include this?

@nikomatsakis
Copy link
Contributor

On Mon, Apr 07, 2014 at 10:42:04AM -0700, Corey Richardson wrote:

cc @nikomatsakis, does your current work also include this?

Yes.

@ghost ghost added the E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added. label Oct 30, 2014
@ghost
Copy link

ghost commented Nov 2, 2014

Closing, this is now supported.

@ghost ghost closed this as completed Nov 2, 2014
@nikomatsakis
Copy link
Contributor

Actually that's not true. That portion of the work never landed.

@nikomatsakis nikomatsakis reopened this Nov 3, 2014
@nikomatsakis
Copy link
Contributor

e.g. this example still fails to compile:

trait Foo<T> { }

trait Bar : Foo<int> + Foo<uint> { }

fn main() { }

I think there are some subtle issues here that would have to be addressed eventually, particularly around object types.

@ghost ghost removed the E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added. label Dec 12, 2014
@nikomatsakis nikomatsakis self-assigned this Mar 3, 2015
@nikomatsakis
Copy link
Contributor

I've wound up fixing this kind of by accident as part of another patch.

flip1995 pushed a commit to flip1995/rust that referenced this issue Sep 7, 2023
Clippy Book Chapter Updates Reborn: Writing tests

This PR adds  a new chapter to the book: "Writing tests". The changes have been mainly done from reviews from rust-lang#9426 and some minor re-writes.

## Notes

- We still need to check that the `git status`es are correct, as `cargo dev new_lint` changed a lot since 2022.
- Requires rust-lang#10598: Link to "Emitting Lints" where I flagged with `FIXME:`.
- To talk about the whole project, please use the tracking issue for the project rust-lang#10597 (It also contains a timeline, discussions and more information)

changelog: Add a new "Writing tests" chapter to the book
r? `@flip1995`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-trait-system Area: Trait system
Projects
None yet
Development

No branches or pull requests

3 participants