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

Order of type parameter declarations matters #3394

Closed
catamorphism opened this issue Sep 5, 2012 · 3 comments
Closed

Order of type parameter declarations matters #3394

catamorphism opened this issue Sep 5, 2012 · 3 comments
Labels
A-type-system Area: Type system

Comments

@catamorphism
Copy link
Contributor

trait A {
  fn a<X, Y>(c: X);
}

struct B {
 x: int;
}

impl B: A {
  fn a<Y, X>(c: X) {}
}

This fails with:

/Users/TimChevalier/rust/src/test/run-pass/issue-2611-2.rs:15:2: 15:21 error: method `a` has an incompatible type: expected type parameter but found type parameter
/Users/TimChevalier/rust/src/test/run-pass/issue-2611-2.rs:15   fn a<Y, X>(c: X) {}
                                                                ^~~~~~~~~~~~~~~~~~~

I think it should pass, since simply reordering the ty param bindings doesn't change meaning. It would be kind of a pain to fix this right now since ty params are still positional.

@catamorphism
Copy link
Contributor Author

(Separately, the "expected type parameter but found type parameter" in the error message is gratuitous.)

@nikomatsakis
Copy link
Contributor

Indeed the order does matter. There are many subtle cases to consider and allowing arbitrary re-ordering is quite a complication. I'd be inclined to mark this as a Won't Fix, myself.

@catamorphism
Copy link
Contributor Author

Ok, fair enough!

RalfJung pushed a commit to RalfJung/rust that referenced this issue Mar 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-type-system Area: Type system
Projects
None yet
Development

No branches or pull requests

2 participants