-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
Should the rust_2018_idioms lint group be mentioned in documentation? #52679
Comments
IIRC one of the original plans was something like:
|
That seems reasonable; on the other hand, you'll get less testing on the lint group if you do that... |
I think it's worth distinguishing what behavior we want from something like I think the bare-trait-objects and elided-lifetimes-in-paths lints should Just Work (absent macro shenanigans) and ellipsis-inclusive-range-patterns can easily be made to Just Work once we have pattern parentheses. It would be a shame to not autofix what we definitely can, just because other lints in the same lint-group are harder to solve. |
We can recommend --idioms to be something you run multiple times? While cargo fix for migration should report unfixed warnings, --idioms doesn't have to -- so we can have this transition by gradually marking more suggestions as applicable, and in the end just recommend a single pass (but folks following along can run it multiple times) |
@zackmdavis that's a good point yeah, if the experience is "pretty good" I think we can definitely turn it on by default. This may just be a case where we're more selective about lints in the If we trim down the lint group I think it'd also be a good solution to this problem, and then we could add more lints once they've been vetted and are known to have good suggestions. |
It also seems unfortunate to conflate "unidiomatic code that we can lint for" with "unidiomatic code that we can lint for and have an autofixable suggestion for". There may just be cases where the fix requires human judgment. (I fear Should |
That sounds appealing to me |
I agree that
Having made that division, we need to ask if this is a problem for 2018 if the set of lints in the first group is not big enough, if there are critical lints that we currently don't automatically fix. |
That doesn't quite work. There already is an existing distinction of lints:
Some lints, like dyn trait, can belong in either group; but for many there's only one logical category. This distinction must be made because the idiom lints cannot be applied on 2015, and the migration lints cannot be applied on 2018 (if you're triggering migration lints your code will not compile on 2018). This can't all be handled by cargo fix because there's the step of bumping the crate edition in between. And that can only be done once all the edition migration fixes have been applied, which won't always be the case -- there's a bit of manual work here for some crates especially whenever macros are involved. What we can do is make It's not overcomplicated; some complication here is necessary. We can make the common case smooth but we definitely need this distinction. TBH I'm getting a bit frustrated here, because this is the third time we're having this discussion. When we started this whole edition lint work I pointed out we would need the migration/idiom category split, folks disagreed, and eventually independently came to the conclusion that yes, we do need these two categories (or something roughly similar). That we're back on that discussion, starting from scratch, is frustrating. |
FWIW there is no As @Manishearth mentioned we won't be able to lump everything in with the initial That all means that we're required to have two "fixing steps" (before and after the edition switch). Orchestrating this all automatically is the subject of rust-lang/cargo#5778 to hopefully make it less confusing. I'm personally a fan of adding a So to summarize:
and... that's it! Otherwise we'd continue to mention the idioms lint, just as |
I've opened rust-lang/cargo#5843 for Cargo to add a |
These migration lints aren't all up to par in terms of a good migration experience. Some, like `unreachable_pub`, hit bugs like rust-lang#52665 and unprepared macros to be handled enough of the time. Others like linting against `#[macro_use]` are swimming upstream in an ecosystem that's not quite ready (and slightly buggy pending a few current PRs). The general idea is that we will continue to recommend the `rust_2018_idioms` lint group as part of the transition guide (as an optional step) but we'll be much more selective about which lints make it into this group. Only those with a strong track record of not causing too much churn will make the cut. cc rust-lang#52679
…li-obk rustc: Trim down the `rust_2018_idioms` lint group These migration lints aren't all up to par in terms of a good migration experience. Some, like `unreachable_pub`, hit bugs like rust-lang#52665 and unprepared macros to be handled enough of the time. Others like linting against `#[macro_use]` are swimming upstream in an ecosystem that's not quite ready (and slightly buggy pending a few current PRs). The general idea is that we will continue to recommend the `rust_2018_idioms` lint group as part of the transition guide (as an optional step) but we'll be much more selective about which lints make it into this group. Only those with a strong track record of not causing too much churn will make the cut. cc rust-lang#52679
Add a `--edition-idioms` flag to `cargo fix` This, like `--prepare-for`, will be part of the transition guide which automatically applies the necessary lint group from the compiler to associated code. cc rust-lang/rust#52679
I believe this is now done and good to go! |
Enabling the
rust_2018_idioms
lint group right now is a pretty brutal experience. Once enabled a slew of warnings show up thatcargo fix
often isn't very well to prepared. Furthermore, not all lints have automatic suggestions! This runs the risk of making the 2018 edition feel like a "big breaking change" because it takes so much effort to quelch all the lints.Should we completely not mention the
rust_2018_idioms
lint group for the edition? For the preview?I'd personally think that we should avoid talking about this lint group at all until it's received a lot more polish. Until that time it's probably best if it's left only for compiler developers and the extra intrepid who go poking around in history. Curious to hear what others think though!
The text was updated successfully, but these errors were encountered: