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

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

Closed
mqudsi opened this issue Sep 8, 2018 · 0 comments
Labels
A-diagnostics Area: Messages for errors, warnings, and lints C-feature-request Category: A feature request, i.e: not implemented / a PR.

Comments

@mqudsi
Copy link
Contributor

mqudsi commented Sep 8, 2018

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.

@Havvy Havvy added A-diagnostics Area: Messages for errors, warnings, and lints C-feature-request Category: A feature request, i.e: not implemented / a PR. labels Sep 9, 2018
euclio added a commit to euclio/rust that referenced this issue Oct 5, 2018
pietroalbini added a commit to pietroalbini/rust that referenced this issue Oct 5, 2018
add suggestion for inverted function parameters

Fixes rust-lang#54065.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-diagnostics Area: Messages for errors, warnings, and lints C-feature-request Category: A feature request, i.e: not implemented / a PR.
Projects
None yet
Development

No branches or pull requests

2 participants