Skip to content

Suggest appropriate place for type argument after associated type #57385

Closed

Description

@estebank

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

  1. 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
  2. self-assigned this
    on Jan 24, 2019
  3. added a commit that references this issue on Jan 25, 2019
    7768358
  4. davidtwco commented on Mar 30, 2019

    @davidtwco
    Member

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

  5. removed their assignment
    on Mar 30, 2019
  6. estebank commented on Apr 1, 2019

    @estebank
    ContributorAuthor

    Why wasn't that regression caught by our tests?

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

  8. 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

      Issue actions