Skip to content

Suggest appropriate place for type argument after associated type #57385

Closed
@estebank

Description

@estebank
Contributor

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> >() {}
   |                                  ^

Activity

added
A-diagnosticsArea: Messages for errors, warnings, and lints
A-suggestion-diagnosticsArea: Suggestions generated by the compiler applied by `cargo fix`
and removed
A-diagnosticsArea: Messages for errors, warnings, and lints
on Jan 6, 2019
self-assigned this
on Jan 24, 2019
added a commit that references this issue on Jan 25, 2019

Rollup merge of rust-lang#57886 - davidtwco:issue-57385, r=estebank

7768358
davidtwco

davidtwco commented on Mar 30, 2019

@davidtwco
Member

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

removed their assignment
on Mar 30, 2019
estebank

estebank commented on Apr 1, 2019

@estebank
ContributorAuthor

Why wasn't that regression caught by our tests?

davidtwco

davidtwco commented on Apr 1, 2019

@davidtwco
Member

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

IFcoltransG commented on Jan 21, 2024

@IFcoltransG

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-suggestion-diagnosticsArea: Suggestions generated by the compiler applied by `cargo fix`

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @davidtwco@estebank@IFcoltransG

        Issue actions

          Suggest appropriate place for type argument after associated type · Issue #57385 · rust-lang/rust