Expose resolved lint flags in unit graph#17040
Conversation
|
r? @weihanglo rustbot has assigned @weihanglo. Use Why was this reviewer chosen?The reviewer was selected based on:
|
## Summary - move the repo Rust lint policy into `[workspace.lints]` and opt every workspace crate into inherited lints - stop the Nix Clippy policy from injecting default `-D` and `-A` flags - teach `nix-cargo-unit` to consume `lint_rustflags` and `check_cfg_args` from Cargo's unit graph instead of parsing manifest lint tables locally - opened the matching long-term Cargo change as rust-lang/cargo#17040 ## Validation - `nix run .#lint`
|
btw this was made by AI apologize if this is against terms. just wanted to let you know ahead of time! |
|
Our contrib guide asks that features generally start as issues to explore the problem and design space before going to the implementation. This is an unstable feature which offers some flexibility but this is going in a different design direction than currently exists: we expose data, not CLI flags.
A policy is still in the works. What I would say is that contributors need to take responsibility for the output. For example, the new test does not follow the pattern of the other tests. Note also the documentation I linked to above. |
I was meaning to say I did not even instruct AI to make this PR. I am not against it, but I was using this internally and Opus 4.7 decided it would be respectful to make a PR into public cargo. That said, I would love not diverging too far from rust-lang/cargo. I am expecting to be able to have time after ~June 16th to look at this again. I am demoting this to a draft for now |
Expose resolved lint-related rustc arguments in
cargo --unit-graphso external build planners can invoke rustc with the same package lint configuration Cargo would use.This adds two fields per serialized unit:
lint_rustflags: the resolved flags from the package manifest's[lints]table, including workspace inheritance and manifestcheck-cfgentries.check_cfg_args: Cargo's generated--check-cfgarguments fordocsrs,test, and package features.The fields let consumers avoid reimplementing Cargo's lint inheritance, priority sorting, and generated check-cfg logic.
Tests cover workspace lint inheritance, Clippy tool lints, manifest
check-cfg, and generated featurecheck-cfgvalues.