Skip to content

Add extra_test_rustc_flag build setting for rust_test - #4359

Open
Spikhalskiy wants to merge 1 commit into
bazelbuild:mainfrom
Spikhalskiy:dmitry/extra-test-rustc-flag
Open

Spikhalskiy wants to merge 1 commit into
bazelbuild:mainfrom
Spikhalskiy:dmitry/extra-test-rustc-flag

Conversation

@Spikhalskiy

Copy link
Copy Markdown

Adds a repeatable extra_test_rustc_flag build setting that only rust_test reads, in the non-exec configuration, as proposed in #4358. Its flags come after extra_rustc_flag and before the target's own rustc_flags, so a test can still override them. The setting is target-scoped so that setting it does not change the exec configuration. Only rust_test declares the attribute that reads it, so libraries and binaries are unaffected.

Tested in test/unit/extra_rustc_flags: the flag reaches a rust_test action before the target's own rustc_flags, and does not reach a rust_library. The new test fails with the flag collection disabled. The extra_rustc_flags, per_crate_rustc_flag and rustc_flag_ordering suites pass on Bazel 9.3.0 and the minimum 7.4.1.

Fixes #4358

Adds a repeatable build setting whose flags are passed to rust_test only, in the
non-exec configuration. They follow extra_rustc_flag and precede the target's own
rustc_flags, so a test can still override them.
Copilot AI balanced review requested due to automatic review settings October 27, 2026 04:01

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota.

An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing.

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.

Build setting to pass extra rustc flags to rust_test only

2 participants