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

Mention editions when emitting 2015 exclusive errors #61914

Open
estebank opened this issue Jun 17, 2019 · 1 comment
Open

Mention editions when emitting 2015 exclusive errors #61914

estebank opened this issue Jun 17, 2019 · 1 comment
Labels
A-diagnostics Area: Messages for errors, warnings, and lints A-docs Area: documentation for any part of the project, including the compiler, standard library, and tools A-edition-2018-lints Area: Lints supporting the 2018 edition C-enhancement Category: An issue proposing an enhancement or a PR with one. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. WG-epoch Working group: Epoch (2018) management

Comments

@estebank
Copy link
Contributor

The difference between edition defaults for new projects between cargo and rustc can lead to confusion, particularly for newcomers. All errors that would only happen on one edition should mention the discrepancy. We made an effort to have lints for 2015 to 2018 migration, but we were more lax on clarifying diagnostics when following 2018 guides when rustc is ran under 2015. Things like nll discrepancies (seen in #61855, moot point once we enable nll in 2015) come to mind, while things like let async = 6; (pass in 2015, "error: expected pattern, found reserved keyword async" without any mention of editions in 2018) which do not mention editions at all (it should recommend using r#raw_idents always, explain it was accepted in 2015 edition but it's being run in 2018).

@estebank estebank added C-enhancement Category: An issue proposing an enhancement or a PR with one. 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-epoch Working group: Epoch (2018) management A-edition-2018-lints Area: Lints supporting the 2018 edition labels Jun 17, 2019
@estebank estebank added the A-docs Area: documentation for any part of the project, including the compiler, standard library, and tools label Jun 17, 2019
@jebrosen
Copy link
Contributor

As another example, forgetting or not knowing to move a project to the 2018 edition before adopting async/await currently causes error messages such as these:

error: expected identifier, found `3`
 --> src/main.rs:2:21
  |
2 |     let x = async { 3 };
  |             -----   ^ expected identifier
  |             |
  |             while parsing this struct

error: expected one of `!`, `.`, `::`, `;`, `?`, `{`, or an operator, found `move`
 --> src/main.rs:3:19
  |
3 |     let y = async move { 3 };
  |                   ^^^^ expected one of 7 possible tokens here

error[E0422]: cannot find struct, variant or union type `async` in this scope
 --> src/main.rs:2:13
  |
2 |     let x = async { 3 };
  |             ^^^^^ not found in this scope

error: aborting due to 3 previous errors

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-docs Area: documentation for any part of the project, including the compiler, standard library, and tools A-edition-2018-lints Area: Lints supporting the 2018 edition C-enhancement Category: An issue proposing an enhancement or a PR with one. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. WG-epoch Working group: Epoch (2018) management
Projects
None yet
Development

No branches or pull requests

2 participants