Skip to content

Suggest fix for misplaced generic params on fn item #103366

Closed
@jruderman

Description

@jruderman

Given the following code (playground):

fn<T> id(x: T) -> T { x }

The current output is:

error: expected identifier, found `<`
 --> src/lib.rs:1:3
  |
1 | fn<T> id(x: T) -> T { x }
  |   ^ expected identifier

Ideally the output should look also include:

help: place the generic parameter list after the function name:
  |
1 | fn id<T>(x: T) -> T { x }
  |      ~~~

This is an easy mistake to make because impl items do require the generic parameters to go immediately after the keyword.

Metadata

Metadata

Assignees

Labels

A-diagnosticsArea: Messages for errors, warnings, and lintsT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions