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

Upgrading to 2018 edition with nameless trait arguments gives opaque error message. #82729

Closed
edre opened this issue Mar 3, 2021 · 1 comment · Fixed by #82774
Closed

Upgrading to 2018 edition with nameless trait arguments gives opaque error message. #82729

edre opened this issue Mar 3, 2021 · 1 comment · Fixed by #82774
Labels
A-diagnostics Area: Messages for errors, warnings, and lints A-parser Area: The parsing of Rust source code to an AST C-enhancement Category: An issue proposing an enhancement or a PR with one. D-terse Diagnostics: An error or lint that doesn't give enough information about the problem at hand. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@edre
Copy link
Contributor

edre commented Mar 3, 2021

Given the following code: https://play.rust-lang.org/?version=stable&mode=debug&edition=2018&gist=2d5990f9266a843f299cffb49ea24f36

The current output is:

error: expected one of `(`, `...`, `..=`, `..`, `::`, `:`, `{`, or `|`, found `)`
 --> src/main.rs:3:46
  |
3 |     fn apply(&self, &mut <Self::G as Game>::S);
  |                                              ^ expected one of 8 possible tokens

Ideally the output should look like:

error: traits require argument names

This was very painful to debug, because there's some type shenanigans going on, and it wasn't clear if some of those didn't work in the 2018 edition now.

@edre edre 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. labels Mar 3, 2021
@ehuss
Copy link
Contributor

ehuss commented Mar 3, 2021

Just FYI, it is usually recommended to use cargo fix --edition to transition from 2015 to 2018. That will automatically fix the syntax so it works on both editions.

If cargo fix isn't an option, or if you want to do it manually, you can use the #![warn(rust_2018_compatibility)] attribute in the crate root while still on the 2015 edition. This will cause it to show warnings for each thing that needs to be fixed. If your editor supports "quick fixes", it can automatically fix each one.

I agree that the error could be better. It was supposed to be fixed by #53990, but it seems to be confused by reference patterns.

// Gives bad error on 2018.
trait Foo {
    fn f(&mut i32);
}

@JohnTitor JohnTitor added A-parser Area: The parsing of Rust source code to an AST C-enhancement Category: An issue proposing an enhancement or a PR with one. D-terse Diagnostics: An error or lint that doesn't give enough information about the problem at hand. labels Mar 4, 2021
@bors bors closed this as completed in a16db3d Mar 17, 2021
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-parser Area: The parsing of Rust source code to an AST C-enhancement Category: An issue proposing an enhancement or a PR with one. D-terse Diagnostics: An error or lint that doesn't give enough information about the problem at hand. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants