rust/tests/ui/conditional-compilation
Matthias Krüger 0de803c38d
Rollup merge of #138632 - clubby789:stabilize-cfg-boolean-lit, r=davidtwco,Urgau,traviscross
Stabilize `cfg_boolean_literals`

Closes #131204
`@rustbot` labels +T-lang +I-lang-nominated
This will end up conflicting with the test in #138293 so whichever doesn't land first will need updating

--

# Stabilization Report

## General design

### What is the RFC for this feature and what changes have occurred to the user-facing design since the RFC was finalized?

[RFC 3695](https://github.com/rust-lang/rfcs/pull/3695), none.

### What behavior are we committing to that has been controversial? Summarize the major arguments pro/con.

None

### Are there extensions to this feature that remain unstable? How do we know that we are not accidentally committing to those?

None

## Has a call-for-testing period been conducted? If so, what feedback was received?

Yes; only positive feedback was received.

## Implementation quality

### Summarize the major parts of the implementation and provide links into the code (or to PRs)

Implemented in [#131034](https://github.com/rust-lang/rust/pull/131034).

### Summarize existing test coverage of this feature

- [Basic usage, including `#[cfg()]`, `cfg!()` and `#[cfg_attr()]`](6d71251cf9/tests/ui/cfg/true-false.rs)
- [`--cfg=true/false` on the command line being accessible via `r#true/r#false`](6d71251cf9/tests/ui/cfg/raw-true-false.rs)
- [Interaction with the unstable `#[doc(cfg(..))]` feature](6d71251/tests/rustdoc-ui/cfg-boolean-literal.rs)
- [Denying `--check-cfg=cfg(true/false)`](6d71251/tests/ui/check-cfg/invalid-arguments.rs)
- Ensuring `--cfg false` on the command line doesn't change the meaning of `cfg(false)`: `tests/ui/cfg/cmdline-false.rs`
- Ensuring both `cfg(true)` and `cfg(false)` on the same item result in it being disabled: `tests/ui/cfg/both-true-false.rs`

### What outstanding bugs in the issue tracker involve this feature? Are they stabilization-blocking?

The above mentioned issue; it should not block as it interacts with another unstable feature.

### What FIXMEs are still in the code for that feature and why is it ok to leave them there?

None

### Summarize contributors to the feature by name for recognition and assuredness that people involved in the feature agree with stabilization
- `@clubby789` (RFC)
- `@Urgau` (Implementation in rustc)

### Which tools need to be adjusted to support this feature. Has this work been done?

`rustdoc`'s  unstable`#[doc(cfg(..)]` has been updated to respect it. `cargo` has been updated with a forward compatibility lint to enable supporting it in cargo once stabilized.

## Type system and execution rules

### What updates are needed to the reference/specification? (link to PRs when they exist)

A few lines to be added to the reference for configuration predicates, specified in the RFC.
2025-04-17 06:25:15 +02:00
..
auxiliary
cfg-arg-invalid-1.rs UI tests: migrate remaining compile time error-patterns to line annotations 2025-04-13 21:48:53 +03:00
cfg-arg-invalid-1.stderr
cfg-arg-invalid-2.rs UI tests: migrate remaining compile time error-patterns to line annotations 2025-04-13 21:48:53 +03:00
cfg-arg-invalid-2.stderr
cfg-arg-invalid-3.rs compiletest: Require //~ annotations even if error-pattern is specified 2025-04-03 11:08:55 +03:00
cfg-arg-invalid-3.stderr
cfg-arg-invalid-4.rs UI tests: migrate remaining compile time error-patterns to line annotations 2025-04-13 21:48:53 +03:00
cfg-arg-invalid-4.stderr
cfg-arg-invalid-5.rs compiletest: Require //~ annotations even if error-pattern is specified 2025-04-03 11:08:55 +03:00
cfg-arg-invalid-5.stderr
cfg-arg-invalid-6.rs UI tests: migrate remaining compile time error-patterns to line annotations 2025-04-13 21:48:53 +03:00
cfg-arg-invalid-6.stderr
cfg-arg-invalid-7.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
cfg-arg-invalid-7.stderr
cfg-arg-invalid-8.rs UI tests: migrate remaining compile time error-patterns to line annotations 2025-04-13 21:48:53 +03:00
cfg-arg-invalid-8.stderr
cfg-arg-invalid-9.rs UI tests: migrate remaining compile time error-patterns to line annotations 2025-04-13 21:48:53 +03:00
cfg-arg-invalid-9.stderr
cfg-attr-cfg-2.rs compiletest: Require //~ annotations even if error-pattern is specified 2025-04-03 11:08:55 +03:00
cfg-attr-cfg-2.stderr compiletest: Require //~ annotations even if error-pattern is specified 2025-04-03 11:08:55 +03:00
cfg-attr-crate-2.rs compiletest: add enable-by-default check-cfg 2024-05-04 11:30:38 +02:00
cfg-attr-crate-2.stderr
cfg-attr-empty-is-unused.rs Unify all the always-false cfgs under the FALSE cfg 2024-04-07 01:16:45 +02:00
cfg-attr-empty-is-unused.stderr Unify all the always-false cfgs under the FALSE cfg 2024-04-07 01:16:45 +02:00
cfg-attr-invalid-predicate.rs
cfg-attr-invalid-predicate.stderr
cfg-attr-multi-false.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
cfg-attr-multi-invalid-1.rs compiletest: add enable-by-default check-cfg 2024-05-04 11:30:38 +02:00
cfg-attr-multi-invalid-1.stderr
cfg-attr-multi-invalid-2.rs compiletest: add enable-by-default check-cfg 2024-05-04 11:30:38 +02:00
cfg-attr-multi-invalid-2.stderr
cfg-attr-multi-true.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
cfg-attr-multi-true.stderr
cfg-attr-parse.rs
cfg-attr-parse.stderr More sophisticated span trimming 2025-02-21 00:41:17 +00:00
cfg-attr-syntax-validation.rs Remove NtExpr and NtLiteral. 2025-04-02 06:20:35 +11:00
cfg-attr-syntax-validation.stderr Remove NtExpr and NtLiteral. 2025-04-02 06:20:35 +11:00
cfg-attr-unknown-attribute-macro-expansion.rs
cfg-attr-unknown-attribute-macro-expansion.stderr
cfg-empty-codemap.rs UI tests: migrate remaining compile time error-patterns to line annotations 2025-04-13 21:48:53 +03:00
cfg-empty-codemap.stderr
cfg-generic-params.rs Use cfg(false) in UI tests 2025-04-03 21:41:58 +00:00
cfg-generic-params.stderr Use cfg(false) in UI tests 2025-04-03 21:41:58 +00:00
cfg-in-crate-1.rs Use cfg(false) in UI tests 2025-04-03 21:41:58 +00:00
cfg-in-crate-1.stderr Use cfg(false) in UI tests 2025-04-03 21:41:58 +00:00
cfg-non-opt-expr.rs Use cfg(false) in UI tests 2025-04-03 21:41:58 +00:00
cfg-non-opt-expr.stderr Use cfg(false) in UI tests 2025-04-03 21:41:58 +00:00
cfg_accessible-bugs.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
cfg_accessible-bugs.stderr
cfg_accessible-input-validation.rs
cfg_accessible-input-validation.stderr
cfg_accessible-not_sure.edition2015.stderr
cfg_accessible-not_sure.edition2021.stderr
cfg_accessible-not_sure.rs replace //@ compile-flags: --edition with //@ edition 2025-04-10 09:56:37 +02:00
cfg_accessible-private.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
cfg_accessible-stuck.rs
cfg_accessible-stuck.stderr
cfg_accessible-unstable.rs use backticks instead of single quotes when reporting "use of unstable library feature" 2024-11-03 13:55:52 -08:00
cfg_accessible-unstable.stderr use backticks instead of single quotes when reporting "use of unstable library feature" 2024-11-03 13:55:52 -08:00
cfg_accessible.rs
cfg_accessible.stderr
cfg_attr_path.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
inner-cfg-non-inline-mod.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
invalid-node-range-issue-129166.rs expand: Leave traces when expanding cfg attributes 2025-03-26 15:30:12 +03:00
issue-34028.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
module_with_cfg.rs Use cfg(false) in UI tests 2025-04-03 21:41:58 +00:00
test-cfg.rs compiletest: add enable-by-default check-cfg 2024-05-04 11:30:38 +02:00
test-cfg.stderr