-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
force-warn for edition lints #85512
Comments
Some mentoring notes:
Extend the Modify the Extend Modify the |
Write some tests:
|
I was under the impression that most (if not all) migrations lints will already result in an error by means of the fact that the code will break. For example with the If the purpose of such is for users to just change edition to 2021 without running migration fixes to get an error indicating the error being 2021-edition-related, I would imagine we'd need to implement an additional bit of detection/help text for that emission of E0034. Such a help text should be possible, just detecting that one of the traits in the set of applicable items is |
@jam1garner that text was referring specifically to those warnings which will become hard errors in the new edition, eg the items in #83213 |
Support for force-warns Implements rust-lang#85512. This PR adds a new command line option `force-warns` which will force the provided lints to warn even if they are allowed by some other mechanism such as `#![allow(warnings)]`. Some remaining issues: * rust-lang#85512 mentions that `force-warns` should also be capable of taking lint groups instead of individual lints. This is not implemented. * If a lint has a higher warning level than `warn`, this will cause that lint to warn instead. We probably want to allow the lint to error if it is set to a higher lint and is not allowed somewhere else. * One test is currently ignored because it's not working - when a deny-by-default lint is allowed, it does not currently warn under `force-warns`. I'm not sure why, but I wanted to get this in before the weekend. r? `@nikomatsakis`
@rustbot label +A-lint |
Now that #85788 is merged, what steps are left? |
I'll post a Cargo PR to start using the new flag, and enable 2021 migrations. There is some follow-up working being pursued (#86009 and supporting |
I'll work on stabilization. 👍 |
…_lint, r=nikomatsakis Add `future_prelude_collision` lint Implements rust-lang#84594. (RFC rust-lang/rfcs#3114 ([rendered](https://github.com/rust-lang/rfcs/blob/master/text/3114-prelude-2021.md))) Not entirely complete but wanted to have my progress decently available while I finish off the last little bits. Things left to implement: * [x] UI tests for lints * [x] Only emit lint for 2015 and 2018 editions * [ ] Lint name/message bikeshedding * [x] Implement for `FromIterator` (from best I can tell, the current approach as mentioned from [this comment](rust-lang#84594 (comment)) won't work due to `FromIterator` instances not using dot-call syntax, but if I'm correct about this then that would also need to be fixed for `TryFrom`/`TryInto`)* * [x] Add to `rust-2021-migration` group? (See rust-lang#85512) (added to `rust-2021-compatibility` group) * [ ] Link to edition guide in lint docs *edit: looked into it, `lookup_method` will also not be hit for `TryFrom`/`TryInto` for non-dotcall syntax. If anyone who is more familiar with typecheck knows the equivalent for looking up associated functions, feel free to chime in.
…int, r=nikomatsakis Add `future_prelude_collision` lint Implements rust-lang#84594. (RFC rust-lang/rfcs#3114 ([rendered](https://github.com/rust-lang/rfcs/blob/master/text/3114-prelude-2021.md))) Not entirely complete but wanted to have my progress decently available while I finish off the last little bits. Things left to implement: * [x] UI tests for lints * [x] Only emit lint for 2015 and 2018 editions * [ ] Lint name/message bikeshedding * [x] Implement for `FromIterator` (from best I can tell, the current approach as mentioned from [this comment](rust-lang#84594 (comment)) won't work due to `FromIterator` instances not using dot-call syntax, but if I'm correct about this then that would also need to be fixed for `TryFrom`/`TryInto`)* * [x] Add to `rust-2021-migration` group? (See rust-lang#85512) (added to `rust-2021-compatibility` group) * [ ] Link to edition guide in lint docs *edit: looked into it, `lookup_method` will also not be hit for `TryFrom`/`TryInto` for non-dotcall syntax. If anyone who is more familiar with typecheck knows the equivalent for looking up associated functions, feel free to chime in.
…tsakis Force warnings even when can_emit_warnings == false Fixes an issue mentioned in rust-lang#85512 with --cap-lints overriding --force-warnings. Fixes rust-lang#86751 r? `@ehuss`
Summary
Compiler changes:
--force-warn XXX
option that is given either a lint or lint groupXXX
XXX
will always issue warnings, regardless of whether they are "allowed" by the code or command-line optionsCargo fix changes:
cargo fix --edition
in order to force migration lints etc to be consideredMotivation
We would like to take some existing warnings and make them into errors in the new edition. We anticipate this being a common pattern. The problem is that these warnings, if they already exist, may be marked a
#[allow]
in various code bases. As a result,cargo fix
would not see the migration suggestions and migration would not succeed.Proposed plan
To become part of a migration, existing lints can be directly added into
rust-2021-migration
group.Caveat: Multiple groups
This plan means that some lints are members of multiple groups. This has been discouraged but in the past but we currently believe that it should work fine. We should test the scenario where a lint is in two groups and one of those groups is allow.
Alternatives
We could instead introduce a fresh copy of these lints that is a member of
rust_2021_migrations
. For example, if there is a lintfoo
, maybe we make afoo_2021
lint that is specifically for the migration. We could perhaps make this convenient to issue in the code by having some option when creating the lint that is like.migration(RUST_2021_MIGRATioN)
. This could also make the lint into a hard error automatically in the new edition, regardless of the lint level.The text was updated successfully, but these errors were encountered: