Skip to content

cargo: apply explicit lint config to build scripts - #4275

Open
jrandolf wants to merge 2 commits into
bazelbuild:mainfrom
jrandolf:codex/upstream-build-script-lints
Open

jrandolf wants to merge 2 commits into
bazelbuild:mainfrom
jrandolf:codex/upstream-build-script-lints

Conversation

@jrandolf

@jrandolf jrandolf commented Sep 24, 2026 •

Copy link
Copy Markdown
Contributor

Allow cargo_build_script to accept an explicit lint_config and forward it to build-script compilation. Explicit rustc lints also apply in execution configurations, so build scripts and procedural macros honor the configuration attached to them.

Analysis coverage checks the configured rustc lint and check-cfg flags on a library, a build script, and a proc-macro in both target and execution configurations. Existing Clippy and rustdoc cases remain in the suite.

Validation: all five tests and the real fixture builds pass locally on macOS arm64 with Bazel 9.2.0 at bfd2845 (bazel test //test/unit/lint_flags:all). The new proc-macro case checks both target and execution configurations. Formatting checks also pass.

Closes #3486.

@UebelAndre UebelAndre left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you! Could you also add a test that shows lint_config applying to a proc-macro (unless we already have a test for that then it's fine)

@jrandolf

jrandolf commented Sep 28, 2026 •

Copy link
Copy Markdown
Contributor Author

Added proc_macro_lints_apply_in_exec in 2774489. It attaches the explicit lint configuration to a rust_proc_macro and checks both --allow=unknown_lints and --check-cfg=cfg(bazel) in the target and execution configurations. The assertions also require a Rustc action so the test cannot pass by finding no compilation to inspect.

All five tests and the real fixture builds now pass locally on macOS arm64 with Bazel 9.2.0 at 2774489.

@jrandolf
jrandolf requested a review from UebelAndre September 28, 2026 19:14
@jrandolf
jrandolf force-pushed the codex/upstream-build-script-lints branch from 2774489 to bfd2845 Compare September 28, 2026 19:15

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

cargo_build_script no such attribute lint_config

2 participants