Open weihanglo opened 1 year ago
This was acknowledged in the RFC
The potential solution mentioned there was
It would be nice if it could also point to Cargo.toml for this. This could be as simple as a --lint-source=Cargo.toml with rustc knowing just enough about the [lints] table to process it directly.
I know we also talked about a more complex CLI for lints for dealing with priority and other problems, we could potentially do some fancy stuff in there so no Cargo.toml
knowledge is needed.
Related papercut here is that command-line lint names use -
, but Cargo.toml
and #[warn()]
use lint names with _
.
This discrepancy is annoying, because copying the lint name from the error message results in an invalid syntax like #[allow(unused-variables)]
.
Cargo.toml
and the CLI support both.
rustc normalizes -
to _
when reading. When reporting to users, it turns _
to -
for the CLI but keeps _
for attributes.
Problem
The current implementation of
-Zlints
is just a transform from[lints]
table to a series of rustc lint flags. When a lint error/warning is emitted, rustc report as if the lint rule were requested on the command line:Steps
And run
cargo +nightly c -Zlints
Possible Solution(s)
Cargo hints rustc that these lint args are from
[lints]
table. However, this solution has some difficulties:build.rustflags
config,RUSTFLAGS
, orcargo rustc -- <args>
.Notes
This is a known issue around rustflags in Cargo and shouldn't be a blocker for stabilization.
Version