Skip to content

Commit 3319e0e

Browse files
committed
Document the ordering behavior of crate cfgs
This was changed in rust-lang/rust#110141.
1 parent 862d6f4 commit 3319e0e

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

Diff for: src/conditional-compilation.md

+6
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,12 @@ It is written as `cfg`, `(`, a configuration predicate, and finally `)`.
254254
If the predicate is true, the thing is rewritten to not have the `cfg` attribute
255255
on it. If the predicate is false, the thing is removed from the source code.
256256

257+
When a crate-level `cfg` has a false predicate, the behavior is slightly
258+
different: any crate attributes preceding the `cfg` are kept, and any crate
259+
attributes following the `cfg` are removed. This allows `#![no_std]` and
260+
`#![no_core]` crates to avoid linking `std`/`core` even if a `#![cfg(...)]` has
261+
removed the entire crate.
262+
257263
Some examples on functions:
258264

259265
```rust

0 commit comments

Comments
 (0)