Skip to content

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

Closed

Description

@burtonageo

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 +

Activity

  1. emberian commented on Apr 7, 2014

    @emberian
    Contributor

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

  2. nikomatsakis commented on Apr 9, 2014

    @nikomatsakis
    Contributor

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

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

    Yes.

  3. ghost added
    E-needs-testCall for participation: An issue has been fixed and does not reproduce, but no test has been added.
    on Oct 30, 2014
  4. ghost closed this as completedon Nov 2, 2014
  5. nikomatsakis commented on Nov 3, 2014

    @nikomatsakis
    Contributor

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

  6. nikomatsakis commented on Nov 3, 2014

    @nikomatsakis
    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.

  7. ghost removed
    E-needs-testCall for participation: An issue has been fixed and does not reproduce, but no test has been added.
    on Dec 12, 2014
  8. self-assigned this
    on Mar 3, 2015
  9. nikomatsakis commented on Mar 3, 2015

    @nikomatsakis
    Contributor

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

  10. added a commit that references this issue on Sep 7, 2023
  11. added a commit that references this issue on Aug 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions