|
| 1 | +- Feature Name: N/A |
| 2 | +- Start Date: 2020-11-04 |
| 3 | +- RFC PR: [rust-lang/rfcs#3013](https://github.com/rust-lang/rfcs/pull/3013) |
| 4 | +- Rust Issue: [rust-lang/rust#82450](https://github.com/rust-lang/rust/issues/82450) |
| 5 | + |
1 | 6 | # Checking conditional compilation at compile time
|
2 | 7 |
|
3 | 8 | # Summary
|
@@ -83,7 +88,7 @@ the option name and its argument joined by `=`, or can be specified in a two-arg
|
83 | 88 | ### Well-known condition names
|
84 | 89 |
|
85 | 90 | `rustc` defines a set of well-known conditions, such as `test`, `target_os`, etc. These conditions
|
86 |
| -are always valid; it is not necessary to enable checking for these conditions. If these conditions |
| 91 | +are always valid; it is not necessary to enable checking for these conditions. If these conditions |
87 | 92 | are specified in a `--check-cfg names(...)` option then they will be ignored. This set of well-known
|
88 | 93 | names is a part of the stable interface of the compiler. New well-known conditions may be added in
|
89 | 94 | the future, because adding a new name cannot break existing code. However, a name may not be removed
|
@@ -486,15 +491,15 @@ feature is enabled, while the `zebra` feature is disabled. Consider compiling th
|
486 | 491 |
|
487 | 492 | ```rust
|
488 | 493 | // this is valid, and tame_lion() will be compiled
|
489 |
| -#[cfg(feature = "lion")] |
| 494 | +#[cfg(feature = "lion")] |
490 | 495 | fn tame_lion(lion: Lion) { ... }
|
491 | 496 |
|
492 | 497 | // this is valid, and ride_zebra() will NOT be compiled
|
493 |
| -#[cfg(feature = "zebra")] |
| 498 | +#[cfg(feature = "zebra")] |
494 | 499 | fn ride_zebra(zebra: Zebra) { ... }
|
495 | 500 |
|
496 |
| -// this is INVALID, and will cause a compiler error |
497 |
| -#[cfg(feature = "platypus")] |
| 501 | +// this is INVALID, and will cause a compiler error |
| 502 | +#[cfg(feature = "platypus")] |
498 | 503 | fn poke_platypus() { ... }
|
499 | 504 |
|
500 | 505 | // this is INVALID, because 'feechure' is not a known condition name,
|
@@ -539,7 +544,7 @@ fn tame_lion() { ... }
|
539 | 544 |
|
540 | 545 | ## Rationale and alternatives
|
541 | 546 |
|
542 |
| -This design enables checking for a class of bugs at compile time, rather than detecting them by |
| 547 | +This design enables checking for a class of bugs at compile time, rather than detecting them by |
543 | 548 | running code.
|
544 | 549 |
|
545 | 550 | This design does not break any existing usage of Rustc. It does not change the meaning of existing
|
|
0 commit comments