Skip to content

Fix is_cfg_test to handle all(test, ...) cfg attributes#16684

Open
Bortlesboat wants to merge 1 commit intorust-lang:masterfrom
Bortlesboat:fix-cfg-test-complex-attrs
Open

Fix is_cfg_test to handle all(test, ...) cfg attributes#16684
Bortlesboat wants to merge 1 commit intorust-lang:masterfrom
Bortlesboat:fix-cfg-test-complex-attrs

Conversation

@Bortlesboat
Copy link

@Bortlesboat Bortlesboat commented Mar 7, 2026

Fixes #16476

is_cfg_test only matched top-level CfgEntry::NameValue { name: test }, so #[cfg(all(test))] and #[cfg(all(test, not(...)))] were not recognized as test configurations. This adds a recursive check into CfgEntry::All variants.

changelog: [tests_outside_test_module]: fix false positive when using #[cfg(all(test, ...))]

Test plan

  • Added UI test cases for #[cfg(all(test))] and #[cfg(all(test, not(target_pointer_width = "16")))]
  • Verified existing tests still pass

@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties label Mar 7, 2026
@rustbot
Copy link
Collaborator

rustbot commented Mar 7, 2026

r? @llogiq

rustbot has assigned @llogiq.
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: 7 candidates
  • 7 candidates expanded to 7 candidates
  • Random selection from Jarcho, dswij, llogiq, samueltardieu

@rustbot

This comment has been minimized.

`is_cfg_test` only matched `CfgEntry::NameValue { name: test }` at the
top level, so `#[cfg(all(test))]` and `#[cfg(all(test, ...))]` were not
recognized as test cfg. Recurse into `CfgEntry::All` variants.
@Bortlesboat Bortlesboat force-pushed the fix-cfg-test-complex-attrs branch 2 times, most recently from 158233d to 3041552 Compare March 8, 2026 10:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-review Status: Awaiting review from the assignee but also interested parties

Projects

None yet

Development

Successfully merging this pull request may close these issues.

tests_outside_test_module is triggered when using "complex" cfg attributes

3 participants