Skip to content

2018 edition - confusing error message when declaring unnamed parameters #53990

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

Closed
EpicatSupercell opened this issue Sep 6, 2018 · 2 comments · Fixed by #56584
Closed

2018 edition - confusing error message when declaring unnamed parameters #53990

EpicatSupercell opened this issue Sep 6, 2018 · 2 comments · Fixed by #56584
Assignees
Labels
A-diagnostics Area: Messages for errors, warnings, and lints A-frontend Area: Compiler frontend (errors, parsing and HIR) T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. WG-diagnostics Working group: Diagnostics

Comments

@EpicatSupercell
Copy link

EpicatSupercell commented Sep 6, 2018

This code works correctly on nightly and stable

trait Trait {
    fn func(u8);
}

but not on 2018 edition, where it returns the error

error: expected one of `:` or `@`, found `)`
 --> src/main.rs:2:15
  |
2 |     fn func(u8);
  |               ^ expected one of `:` or `@` here

Changing it to func(_: u8) solves it.

Is this an intended change?
I couldn't find anything about it in the edition guide.

@EpicatSupercell EpicatSupercell changed the title 2018 edition regression - associated types access with Self 2018 edition regression - function parameters in traits inconsistency Sep 6, 2018
@EpicatSupercell EpicatSupercell changed the title 2018 edition regression - function parameters in traits inconsistency 2018 edition inconsistency - parameters of functions in traits Sep 6, 2018
@jonas-schievink
Copy link
Contributor

Yes, this was done in #53612

@EpicatSupercell
Copy link
Author

So apparently it was part of RFC 1685. In that case we should at least fix the error message, since it doesn't explain the source of the error at all.

@EpicatSupercell EpicatSupercell changed the title 2018 edition inconsistency - parameters of functions in traits 2018 edition - confusing error message when declaring unnamed parameters Sep 6, 2018
@Centril Centril added A-diagnostics Area: Messages for errors, warnings, and lints T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. WG-diagnostics Working group: Diagnostics A-frontend Area: Compiler frontend (errors, parsing and HIR) labels Sep 7, 2018
@davidtwco davidtwco self-assigned this Dec 7, 2018
bors added a commit that referenced this issue Dec 15, 2018
2018 edition - confusing error message when declaring unnamed parameters

Fixes #53990.

This PR adds a note providing context for the change to argument
names being required in the 2018 edition for trait methods and a
suggestion for the fix.
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 A-frontend Area: Compiler frontend (errors, parsing and HIR) T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. WG-diagnostics Working group: Diagnostics
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants