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

Suggest appropriate place for type argument after associated type #57385

Closed
estebank opened this issue Jan 6, 2019 · 4 comments
Closed

Suggest appropriate place for type argument after associated type #57385

estebank opened this issue Jan 6, 2019 · 4 comments
Labels
A-suggestion-diagnostics Area: Suggestions generated by the compiler applied by `cargo fix`

Comments

@estebank
Copy link
Contributor

estebank commented Jan 6, 2019

Like we do for lifetimes, suggest the appropriate place for type arguments written after associated an type.

Given

trait Trait<T> { type Item; }
pub fn test<W, I: Trait<Item=(), W> >() {}
fn main() { }

we currently emit

error: type parameters must be declared prior to associated type bindings
  --> $DIR/issue-32214.rs:5:34
   |
LL | pub fn test<W, I: Trait<Item=(), W> >() {}
   |                                  ^
@estebank estebank added A-diagnostics Area: Messages for errors, warnings, and lints A-suggestion-diagnostics Area: Suggestions generated by the compiler applied by `cargo fix` and removed A-diagnostics Area: Messages for errors, warnings, and lints labels Jan 6, 2019
@davidtwco davidtwco self-assigned this Jan 24, 2019
Centril added a commit to Centril/rust that referenced this issue Jan 25, 2019
Add suggestion for moving type declaration before associated type bindings in generic arguments.

Fixes rust-lang#57385.

r? @estebank
@davidtwco
Copy link
Member

Re-opening as this was regressed by #58191 (11874a0).

@davidtwco davidtwco reopened this Mar 30, 2019
@davidtwco davidtwco removed their assignment Mar 30, 2019
@estebank
Copy link
Contributor Author

estebank commented Apr 1, 2019

Why wasn't that regression caught by our tests?

@davidtwco
Copy link
Member

davidtwco commented Apr 1, 2019

Why wasn't that regression caught by our tests?

The test was also updated. Presumably it wasn't noticed and the test got --bless'd.

@IFcoltransG
Copy link

The above code now generates a suggestion.

help: move the constraint after the generic argument
  |
2 | pub fn test<W, I: Trait<W, Item = ()> >() {}
  |                        ~~~~~~~~~~~~~~

I assume this issue can be closed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-suggestion-diagnostics Area: Suggestions generated by the compiler applied by `cargo fix`
Projects
None yet
Development

No branches or pull requests

3 participants