Summary
Compiler changes:
Cargo fix changes:
Motivation
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 lint foo, maybe we make a foo_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.
Summary
Compiler changes:
--force-warn XXXoption that is given either a lint or lint groupXXXXXXwill always issue warnings, regardless of whether they are "allowed" by the code or command-line optionsCargo fix changes:
cargo fix --editionin 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 fixwould 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-migrationgroup.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_2021lint 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.