Skip to content

Commit cf4e431

Browse files
committed
Revise editorially
In most of the examples for these attributes, there's no lead-in, so let's remove the lead-in here. Let's also say "form" rather than "thing", even though "thing" does have a certain appeal to it. In our rule for duplicates, let's add a forward reference to the exception to that. Finally, we say that the attribute applied at the crate level does not remove the crate; later, for an example, let's clarify that it only removes the content of the crate. Most or all of this was preexisting to this PR.
1 parent 8e797ea commit cf4e431

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

src/conditional-compilation.md

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -319,11 +319,9 @@ r[cfg.attr]
319319
### The `cfg` attribute
320320

321321
r[cfg.attr.intro]
322-
The *`cfg` [attribute]* conditionally includes the thing it is attached to based on a configuration predicate.
322+
The *`cfg` [attribute]* conditionally includes the form to which it is attached based on a configuration predicate.
323323

324324
> [!EXAMPLE]
325-
> Some examples of using `cfg` on functions:
326-
>
327325
> ```rust
328326
> // The function is only included in the build when compiling for macOS
329327
> #[cfg(target_os = "macos")]
@@ -368,16 +366,16 @@ r[cfg.attr.allowed-positions]
368366
The `cfg` attribute is allowed anywhere attributes are allowed.
369367

370368
r[cfg.attr.duplicates]
371-
Multiple `cfg` attributes may be specified. The thing will not be included if any of the `cfg` predicates are false.
369+
Multiple `cfg` attributes may be specified. The form to which the attribute is attached will not be included if any of the `cfg` predicates are false except as described in [cfg.attr.crate-level-attrs].
372370

373371
r[cfg.attr.effect]
374-
If the predicate is true, the thing is rewritten to not have the `cfg` attribute on it. If the predicate is false, the thing is removed from the source code.
372+
If the predicate is true, the form is rewritten to not have the `cfg` attribute on it. If the predicate is false, the form is removed from the source code.
375373

376374
r[cfg.attr.crate-level-attrs]
377375
When a crate-level `cfg` has a false predicate, the crate itself still exists. Any crate attributes preceding the `cfg` are kept, and any crate attributes following the `cfg` are removed as well as removing all of the following crate contents.
378376

379377
> [!EXAMPLE]
380-
> The behavior of not removing the preceding attributes allows you to do things such as include `#![no_std]` to avoid linking `std` even if a `#![cfg(...)]` has removed the entire crate. For example:
378+
> The behavior of not removing the preceding attributes allows you to do things such as include `#![no_std]` to avoid linking `std` even if a `#![cfg(...)]` has otherwise removed the contents of the crate. For example:
381379
>
382380
> <!-- ignore: test infrastructure can't handle no_std -->
383381
> ```rust,ignore

0 commit comments

Comments
 (0)