You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/conditional-compilation.md
+11-10Lines changed: 11 additions & 10 deletions
Original file line number
Diff line number
Diff line change
@@ -27,15 +27,14 @@
27
27
Each form of conditional compilation takes a _configuration predicate_ that
28
28
evaluates to true or false. The predicate is one of the following:
29
29
30
-
* A configuration option. The predicate is true if the option is set, and false if it is
31
-
unset.
32
-
*`all()` with a comma-separated list of configuration predicates. It is true precisely if all of the given predicates are true.
33
-
*`any()` with a comma-separated list of configuration predicates. It is true precisely if at least one of the given predicates is true.
34
-
*`not()` with a configuration predicate. It is true precisely if the given predicate is false.
30
+
* A configuration option. The predicate is true if the option is set, and false if it is unset.
31
+
*`all()` with a comma-separated list of configuration predicates. It is true if all of the given predicates are true, or if the list is empty.
32
+
*`any()` with a comma-separated list of configuration predicates. It is true if at least one of the given predicates is true. If there are no predicates, it is false.
33
+
*`not()` with a configuration predicate. It is true if its predicate is false and false if its predicate is true.
35
34
36
-
_Configuration options_ are either names or key-value pairs, and are either set or
37
-
unset. Configuration options that are names, such as `unix`, are specified by simply writing them.
38
-
Configuration options that are key-value pairs are written in the form `key = "value"`, such as `target_arch = "x86_64"`.
35
+
_Configuration options_ are either names or key-value pairs, and are either set or unset.
36
+
Names are written as a single identifier, such as `unix`.
37
+
Key-value pairs are written as an identifier, `=`, and then a string, such as `target_arch = "x86_64"`.
39
38
40
39
> **Note**: Whitespace around the `=` is ignored, so `foo="bar"` and `foo = "bar"` are equivalent.
41
40
@@ -46,7 +45,7 @@ Keys do not need to be unique. For example, both `feature = "std"` and `feature
46
45
Which configuration options are set is determined statically during the
47
46
compilation of the crate. Some options are _compiler-set_ based on data
48
47
about the compilation. Other options are _arbitrarily-set_ based on input
49
-
passed to the compiler outside of the code. It is impossible to set a
48
+
passed to the compiler outside of the code. It is not possible to set a
50
49
configuration option from within the source code of the crate being compiled.
51
50
52
51
> **Note**: For `rustc`, arbitrary-set configuration options are set using the
@@ -250,7 +249,9 @@ Example values:
250
249
<!-- should we say they're active attributes here? -->
251
250
252
251
The `cfg`[attribute] conditionally includes the thing it is attached to based
253
-
on the given configuration predicate (_ConfigurationPredicate_ in the syntax above).
252
+
on a configuration predicate.
253
+
254
+
It is written as `cfg`, `(`, a configuration predicate, and finally `)`.
254
255
255
256
If the predicate is true, the thing is rewritten to not have the `cfg` attribute
256
257
on it. If the predicate is false, the thing is removed from the source code.
0 commit comments