Skip to content

Expose resolved lint flags in unit graph#17040

Draft
andrewgazelka wants to merge 1 commit into
rust-lang:masterfrom
indexable-inc:codex/unit-graph-lint-rustflags
Draft

Expose resolved lint flags in unit graph#17040
andrewgazelka wants to merge 1 commit into
rust-lang:masterfrom
indexable-inc:codex/unit-graph-lint-rustflags

Conversation

@andrewgazelka
Copy link
Copy Markdown

Expose resolved lint-related rustc arguments in cargo --unit-graph so 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 manifest check-cfg entries.
  • check_cfg_args: Cargo's generated --check-cfg arguments for docsrs, 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 feature check-cfg values.

@rustbot rustbot added A-build-execution Area: anything dealing with executing the compiler S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels May 28, 2026
@rustbot
Copy link
Copy Markdown
Collaborator

rustbot commented May 28, 2026

r? @weihanglo

rustbot has assigned @weihanglo.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

Why was this reviewer chosen?

The reviewer was selected based on:

  • Owners of files modified in this PR: @ehuss, @epage, @weihanglo
  • @ehuss, @epage, @weihanglo expanded to ehuss, epage, weihanglo
  • Random selection from ehuss, epage, weihanglo

andrewgazelka added a commit to indexable-inc/index that referenced this pull request May 28, 2026
## 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`
@andrewgazelka
Copy link
Copy Markdown
Author

btw this was made by AI apologize if this is against terms. just wanted to let you know ahead of time!

@epage
Copy link
Copy Markdown
Contributor

epage commented May 28, 2026

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.

btw this was made by AI apologize if this is against terms. just wanted to let you know ahead of time!

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.

@andrewgazelka
Copy link
Copy Markdown
Author

andrewgazelka commented May 28, 2026

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.

btw this was made by AI apologize if this is against terms. just wanted to let you know ahead of time!

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

@andrewgazelka andrewgazelka marked this pull request as draft May 28, 2026 14:19
@rustbot rustbot removed the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label May 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-build-execution Area: anything dealing with executing the compiler

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants