Closed weihanglo closed 1 year ago
This issue is not meant to be used for technical discussion. There is a Zulip stream for that. Use this issue to leave procedural comments, such as volunteering to review, indicating that you second the proposal (or third, etc), or raising a concern that you would like to be addressed.
cc @rust-lang/compiler @rust-lang/compiler-contributors
@rustbot second
Proposal
Background
When you specify an unknown/renamed/removed lint name in Rust code, for example
#![deny(foo)]
, the compiler respects the lint system and emits a warning by default^1.However, if it is from the command line, such as
-D foo
, the compiler simply emits an error and exits^2. There is no way to recover from the error, since those errors are emitted directly viaSession
, not under the control ofLintContext
orLintLevelsbuilder
.Possible solution
This MCP proposes that those errors should be considered as normal lints and emitted by the lint system. Specifically,
CheckNameRenamed
error withrenamed-and-removed-lints
.CheckNameRemoved
error withrenamed-and-removed-lints
.CheckNameDeprecated
error withrenamed-and-removed-lints
.CheckNameUnknown
error withunknown-lints
The proposed behavior is more consistent from both source-code level and end-user perspective.
User-facing impact
Compiler invocations that rely on the aforementioned always-error-out behavior will become valid. This is easy to fix by adding
-D unknown-lints
or-D renamed-and-removed-lints
as a command line argument (tbh not as easy as it looks like[^3]).Motivation
With
-Zlints
unstable feature in Cargo, you can specify lint rules and levels inCargo.toml
. Under the hood Cargo aggregates those settings and passes via command line to the compiler.Without this MCP, it is not backward compatible when a user adds a new lint, and then use an old version of the compiler. The compiler will refuse to compile even
unknown-lints
lint iswarn
by default notdeny
.See https://github.com/rust-lang/cargo/issues/12495.
Compiler version
[^3]: This is another command line argument precedence issue. Think about this. Which should emit an unknown lint error?
-Dunknown-lints -Dfoo
or-Dfoo -Dunknown-lints
? Or should we make these lints a special priority likewarnings
lint group? That may lead to https://github.com/rust-lang/rust/issues/75668 though. Anyway, this belongs to a separate MCP.Mentors or Reviewers
Not sure. Perhaps @estebank or @compiler-errors?
Process
The main points of the Major Change Process are as follows:
@rustbot second
.-C flag
, then full team check-off is required.@rfcbot fcp merge
on either the MCP or the PR.You can read more about Major Change Proposals on forge.
Comments
This issue is not meant to be used for technical discussion. There is a Zulip stream for that. Use this issue to leave procedural comments, such as volunteering to review, indicating that you second the proposal (or third, etc), or raising a concern that you would like to be addressed.