rust/tests/ui/cfg
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
..
assume-incomplete-release Update tests to use new proc-macro header 2024-11-27 07:18:25 -08:00
auxiliary Use cfg(false) in UI tests 2025-04-03 21:41:58 +00:00
both-true-false.rs Add more tests for cfg_boolean_literals 2025-04-03 18:10:48 +00:00
both-true-false.stderr Add more tests for cfg_boolean_literals 2025-04-03 18:10:48 +00:00
cfg-attr-cfg.rs tests: remove //@ pretty-expanded usages 2024-11-26 02:50:48 +08:00
cfg-attr-crate.rs tests: remove //@ pretty-expanded usages 2024-11-26 02:50:48 +08:00
cfg-false-feature.rs Use cfg(false) in UI tests 2025-04-03 21:41:58 +00:00
cfg-false-feature.stderr Add barest-bones deref patterns 2024-03-20 22:30:27 +01:00
cfg-family.rs tests: remove //@ pretty-expanded usages 2024-11-26 02:50:48 +08:00
cfg-in-crate-1.rs compiletest: add enable-by-default check-cfg 2024-05-04 11:30:38 +02:00
cfg-macros-foo.rs compiletest: add enable-by-default check-cfg 2024-05-04 11:30:38 +02:00
cfg-macros-notfoo.rs Use cfg(false) in UI tests 2025-04-03 21:41:58 +00:00
cfg-match-arm.rs Use cfg(false) in UI tests 2025-04-03 21:41:58 +00:00
cfg-method-receiver-ok.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
cfg-method-receiver.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
cfg-method-receiver.stderr Trim suggestion parts to the subset that is purely additive 2025-02-14 00:44:10 -08:00
cfg-panic-abort.rs Remove useless configs in tests 2024-04-07 01:16:45 +02:00
cfg-panic.rs Remove useless configs in tests 2024-04-07 01:16:45 +02:00
cfg-path-error.rs compiletest: add enable-by-default check-cfg 2024-05-04 11:30:38 +02:00
cfg-path-error.stderr compiletest: add enable-by-default check-cfg 2024-05-04 11:30:38 +02:00
cfg-stmt-recovery.rs Use cfg(false) in UI tests 2025-04-03 21:41:58 +00:00
cfg-stmt-recovery.stderr Use cfg(false) in UI tests 2025-04-03 21:41:58 +00:00
cfg-target-abi.rs Stabilize cfg_target_abi 2024-02-24 17:52:03 -03:00
cfg-target-compact-errors.rs Handle gracefully true/false in cfg(target(..)) compact 2024-10-16 09:41:49 +02:00
cfg-target-compact-errors.stderr Handle gracefully true/false in cfg(target(..)) compact 2024-10-16 09:41:49 +02:00
cfg-target-compact.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
cfg-target-family.rs tests: remove //@ pretty-expanded usages 2024-11-26 02:50:48 +08:00
cfg-target-vendor.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
cfg_attr.rs compiletest: add enable-by-default check-cfg 2024-05-04 11:30:38 +02:00
cfg_false_no_std-1.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
cfg_false_no_std-2.rs compiletest: Trim the value of dont-require-annotations 2025-04-10 23:48:57 +03:00
cfg_false_no_std.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
cfg_inner_static.rs tests: remove //@ pretty-expanded usages 2024-11-26 02:50:48 +08:00
cfg_stmt_expr.rs Use cfg(false) in UI tests 2025-04-03 21:41:58 +00:00
cfgs-on-items.rs compiletest: add enable-by-default check-cfg 2024-05-04 11:30:38 +02:00
cmdline-false.rs Add more tests for cfg_boolean_literals 2025-04-03 18:10:48 +00:00
cmdline-false.stderr Add more tests for cfg_boolean_literals 2025-04-03 18:10:48 +00:00
conditional-compile-arch.rs tests: remove //@ pretty-expanded usages 2024-11-26 02:50:48 +08:00
conditional-compile.rs Use cfg(false) in UI tests 2025-04-03 21:41:58 +00:00
crate-attributes-using-cfg_attr.rs Make deprecated_cfg_attr_crate_type_name a hard error 2024-10-05 04:29:46 +02:00
crate-attributes-using-cfg_attr.stderr Make deprecated_cfg_attr_crate_type_name a hard error 2024-10-05 04:29:46 +02:00
crt-static-off-works.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
crt-static-on-works.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
diagnostics-cross-crate.rs When finding item gated behind a cfg flat, point at it 2024-07-12 18:52:52 +00:00
diagnostics-cross-crate.stderr Use cfg(false) in UI tests 2025-04-03 21:41:58 +00:00
diagnostics-not-a-def.rs RFC 2383: Stabilize lint_reasons 🎉 2024-06-25 17:22:22 +02:00
diagnostics-not-a-def.stderr RFC 2383: Stabilize lint_reasons 🎉 2024-06-25 17:22:22 +02:00
diagnostics-reexport.rs Use cfg(false) in UI tests 2025-04-03 21:41:58 +00:00
diagnostics-reexport.stderr Use cfg(false) in UI tests 2025-04-03 21:41:58 +00:00
diagnostics-same-crate.rs Use cfg(false) in UI tests 2025-04-03 21:41:58 +00:00
diagnostics-same-crate.stderr Use cfg(false) in UI tests 2025-04-03 21:41:58 +00:00
disallowed-cli-cfgs-allow.rs Disallow setting built-in cfgs via set the command-line 2024-08-07 14:08:34 +02:00
disallowed-cli-cfgs.debug_assertions_.stderr Disallow setting built-in cfgs via set the command-line 2024-08-07 14:08:34 +02:00
disallowed-cli-cfgs.emscripten_wasm_eh_.stderr Add support for wasm exception handling to Emscripten target 2025-01-06 10:29:54 +01:00
disallowed-cli-cfgs.fmt_debug_.stderr fmt-debug option 2024-08-28 23:32:40 +01:00
disallowed-cli-cfgs.overflow_checks_.stderr Disallow setting built-in cfgs via set the command-line 2024-08-07 14:08:34 +02:00
disallowed-cli-cfgs.panic_.stderr Disallow setting built-in cfgs via set the command-line 2024-08-07 14:08:34 +02:00
disallowed-cli-cfgs.proc_macro_.stderr Disallow setting built-in cfgs via set the command-line 2024-08-07 14:08:34 +02:00
disallowed-cli-cfgs.relocation_model_.stderr Disallow setting built-in cfgs via set the command-line 2024-08-07 14:08:34 +02:00
disallowed-cli-cfgs.rs compiletest: Support matching on diagnostics without a span 2025-03-25 17:33:09 +03:00
disallowed-cli-cfgs.sanitize_.stderr Disallow setting built-in cfgs via set the command-line 2024-08-07 14:08:34 +02:00
disallowed-cli-cfgs.sanitizer_cfi_generalize_pointers_.stderr Disallow setting built-in cfgs via set the command-line 2024-08-07 14:08:34 +02:00
disallowed-cli-cfgs.sanitizer_cfi_normalize_integers_.stderr Disallow setting built-in cfgs via set the command-line 2024-08-07 14:08:34 +02:00
disallowed-cli-cfgs.target_abi_.stderr Disallow setting built-in cfgs via set the command-line 2024-08-07 14:08:34 +02:00
disallowed-cli-cfgs.target_arch_.stderr Disallow setting built-in cfgs via set the command-line 2024-08-07 14:08:34 +02:00
disallowed-cli-cfgs.target_endian_.stderr Disallow setting built-in cfgs via set the command-line 2024-08-07 14:08:34 +02:00
disallowed-cli-cfgs.target_env_.stderr Disallow setting built-in cfgs via set the command-line 2024-08-07 14:08:34 +02:00
disallowed-cli-cfgs.target_family_.stderr Disallow setting built-in cfgs via set the command-line 2024-08-07 14:08:34 +02:00
disallowed-cli-cfgs.target_feature_.stderr Disallow setting built-in cfgs via set the command-line 2024-08-07 14:08:34 +02:00
disallowed-cli-cfgs.target_has_atomic_.stderr Disallow setting built-in cfgs via set the command-line 2024-08-07 14:08:34 +02:00
disallowed-cli-cfgs.target_has_atomic_equal_alignment_.stderr Disallow setting built-in cfgs via set the command-line 2024-08-07 14:08:34 +02:00
disallowed-cli-cfgs.target_has_atomic_load_store_.stderr Disallow setting built-in cfgs via set the command-line 2024-08-07 14:08:34 +02:00
disallowed-cli-cfgs.target_os_.stderr Disallow setting built-in cfgs via set the command-line 2024-08-07 14:08:34 +02:00
disallowed-cli-cfgs.target_pointer_width_.stderr Disallow setting built-in cfgs via set the command-line 2024-08-07 14:08:34 +02:00
disallowed-cli-cfgs.target_thread_local_.stderr Disallow setting built-in cfgs via set the command-line 2024-08-07 14:08:34 +02:00
disallowed-cli-cfgs.target_vendor_.stderr Disallow setting built-in cfgs via set the command-line 2024-08-07 14:08:34 +02:00
disallowed-cli-cfgs.ub_checks_.stderr Disallow setting built-in cfgs via set the command-line 2024-08-07 14:08:34 +02:00
disallowed-cli-cfgs.unix_.stderr Disallow setting built-in cfgs via set the command-line 2024-08-07 14:08:34 +02:00
disallowed-cli-cfgs.windows_.stderr Disallow setting built-in cfgs via set the command-line 2024-08-07 14:08:34 +02:00
expanded-cfg.rs compiletest: add enable-by-default check-cfg 2024-05-04 11:30:38 +02:00
raw-true-false.rs Allow boolean literals in check-cfg 2025-04-03 09:54:23 +00:00
true-false.rs Stabilize cfg_boolean_literals 2025-04-03 18:10:48 +00:00