about summary refs log tree commit diff
path: root/src/doc
diff options
context:
space:
mode:
authorGuillaume Gomez <guillaume1.gomez@gmail.com>2024-10-04 15:42:53 +0200
committerGitHub <noreply@github.com>2024-10-04 15:42:53 +0200
commit2ceeeb159dc5aa13cd090ade1b013c51461949a5 (patch)
treeabfd471990fd393fbd7cc4801180085415a07d6d /src/doc
parent3002af6cb643138839537f6fd0265162610fdbbe (diff)
parenta3ffa1eae507809628decc6250b28db6ab167b11 (diff)
downloadrust-2ceeeb159dc5aa13cd090ade1b013c51461949a5.tar.gz
rust-2ceeeb159dc5aa13cd090ade1b013c51461949a5.zip
Rollup merge of #131034 - Urgau:cfg-true-false, r=nnethercote
Implement RFC3695 Allow boolean literals as cfg predicates

This PR implements https://github.com/rust-lang/rfcs/pull/3695: allow boolean literals as cfg predicates, i.e. `cfg(true)` and `cfg(false)`.

r? `@nnethercote` *(or anyone with parser knowledge)*
cc `@clubby789`
Diffstat (limited to 'src/doc')
-rw-r--r--src/doc/unstable-book/src/language-features/cfg-boolean-literals.md22
1 files changed, 22 insertions, 0 deletions
diff --git a/src/doc/unstable-book/src/language-features/cfg-boolean-literals.md b/src/doc/unstable-book/src/language-features/cfg-boolean-literals.md
new file mode 100644
index 00000000000..ad795ff9d9b
--- /dev/null
+++ b/src/doc/unstable-book/src/language-features/cfg-boolean-literals.md
@@ -0,0 +1,22 @@
+# `cfg_boolean_literals`
+
+The tracking issue for this feature is: [#131204]
+
+[#131204]: https://github.com/rust-lang/rust/issues/131204
+
+------------------------
+
+The `cfg_boolean_literals` feature makes it possible to use the `true`/`false`
+literal as cfg predicate. They always evaluate to true/false respectively.
+
+## Examples
+
+```rust
+#![feature(cfg_boolean_literals)]
+
+#[cfg(true)]
+const A: i32 = 5;
+
+#[cfg(all(false))]
+const A: i32 = 58 * 89;
+```