Skip to content

Detect inverted (type, parameter name) function parameters and suggest fix accordingly #54065

Closed
@mqudsi

Description

@mqudsi

Each time I switch from programming in (TypeScript, rust) to programming in (C, C++, C#) or vice versa, I end up inevitably writing function parameters backwards. To me, the following message is obviously more than enough:

error: expected one of `:` or `@`, found `path`
   --> src/backup/mod.rs:113:36
    |
113 |     fn create_pipeline(&self, &str path) -> Result<Box<Write>> {
    |                                    ^^^^ expected one of `:` or `@` here

as it brings to my attention the inverted signature parameters. However, it occurs to me that this might be an easy (albeit extremely low priority) win to make the compiler emit friendlier error messages for newcomers to rust. Perhaps this can be detected an a message along the lines of "did you mean path: &str instead?" could be emitted here.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-diagnosticsArea: Messages for errors, warnings, and lintsC-feature-requestCategory: A feature request, i.e: not implemented / a PR.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions