Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 355d92c

Browse files
authoredApr 17, 2025··
Unrolled build for rust-lang#138632
Rollup merge of rust-lang#138632 - clubby789:stabilize-cfg-boolean-lit, r=davidtwco,Urgau,traviscross Stabilize `cfg_boolean_literals` Closes rust-lang#131204 `@rustbot` labels +T-lang +I-lang-nominated This will end up conflicting with the test in rust-lang#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](rust-lang/rfcs#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 [rust-lang#131034](rust-lang#131034). ### Summarize existing test coverage of this feature - [Basic usage, including `#[cfg()]`, `cfg!()` and `#[cfg_attr()]`](https://github.com/rust-lang/rust/blob/6d71251cf9e40326461f90f8ff9a7024706aea87/tests/ui/cfg/true-false.rs) - [`--cfg=true/false` on the command line being accessible via `r#true/r#false`](https://github.com/rust-lang/rust/blob/6d71251cf9e40326461f90f8ff9a7024706aea87/tests/ui/cfg/raw-true-false.rs) - [Interaction with the unstable `#[doc(cfg(..))]` feature](https://github.com/rust-lang/rust/tree/6d71251/tests/rustdoc-ui/cfg-boolean-literal.rs) - [Denying `--check-cfg=cfg(true/false)`](https://github.com/rust-lang/rust/tree/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.
2 parents 94015d3 + 303c1b4 commit 355d92c

File tree

160 files changed

+537
-633
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

160 files changed

+537
-633
lines changed
 

‎compiler/rustc_attr_parsing/src/attributes/cfg.rs

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ use rustc_session::config::ExpectedValues;
77
use rustc_session::lint::BuiltinLintDiag;
88
use rustc_session::lint::builtin::UNEXPECTED_CFGS;
99
use rustc_session::parse::feature_err;
10-
use rustc_span::symbol::kw;
1110
use rustc_span::{Span, Symbol, sym};
1211

1312
use crate::session_diagnostics::{self, UnsupportedLiteralReason};
@@ -89,20 +88,6 @@ pub fn eval_condition(
8988
let cfg = match cfg {
9089
MetaItemInner::MetaItem(meta_item) => meta_item,
9190
MetaItemInner::Lit(MetaItemLit { kind: LitKind::Bool(b), .. }) => {
92-
if let Some(features) = features {
93-
// we can't use `try_gate_cfg` as symbols don't differentiate between `r#true`
94-
// and `true`, and we want to keep the former working without feature gate
95-
gate_cfg(
96-
&(
97-
if *b { kw::True } else { kw::False },
98-
sym::cfg_boolean_literals,
99-
|features: &Features| features.cfg_boolean_literals(),
100-
),
101-
cfg.span(),
102-
sess,
103-
features,
104-
);
105-
}
10691
return *b;
10792
}
10893
_ => {

‎compiler/rustc_feature/src/accepted.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,8 @@ declare_features! (
9595
(accepted, c_unwind, "1.81.0", Some(74990)),
9696
/// Allows `#[cfg_attr(predicate, multiple, attributes, here)]`.
9797
(accepted, cfg_attr_multi, "1.33.0", Some(54881)),
98+
/// Allows the use of `#[cfg(<true/false>)]`.
99+
(accepted, cfg_boolean_literals, "CURRENT_RUSTC_VERSION", Some(131204)),
98100
/// Allows the use of `#[cfg(doctest)]`, set when rustdoc is collecting doctests.
99101
(accepted, cfg_doctest, "1.40.0", Some(62210)),
100102
/// Enables `#[cfg(panic = "...")]` config key.

0 commit comments

Comments
 (0)
This repository has been archived.