Skip to content

force-warn for edition lints #85512

Closed
Closed
@nikomatsakis

Description

@nikomatsakis

Summary

Compiler changes:

  • Create MCP
  • Add a --force-warn XXX option that is given either a lint or lint group XXX
  • When this command line option is used, all other lint settings the lints covered by XXX will always issue warnings, regardless of whether they are "allowed" by the code or command-line options

Cargo fix changes:

  • This command line option is supplied by cargo fix --edition in order to force migration lints etc to be considered

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.

Metadata

Metadata

Assignees

Labels

A-edition-2021Area: The 2021 editionA-lintsArea: Lints (warnings about flaws in source code) such as unused_mut.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions