Skip to content

Commit 5b1b695

Browse files
authored
docs: document we don't alias for ONLY 1 OS[skip ci] (#2346)
1 parent 945910d commit 5b1b695

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

CONVENTIONS.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,13 @@ When creating newtypes, we use Rust's `CamelCase` type naming convention.
4747
## cfg gates
4848

4949
When creating operating-system-specific functionality, we gate it by
50-
`#[cfg(target_os = ...)]`. If more than one operating system is affected, we
50+
`#[cfg(target_os = ...)]`. If **MORE THAN ONE operating system** is affected, we
5151
prefer to use the cfg aliases defined in build.rs, like `#[cfg(bsd)]`.
5252

53+
Please **DO NOT** use cfg aliases for **ONLY ONE** system as [they are bad][mismatched_target_os].
54+
55+
[mismatched_target_os]: https://rust-lang.github.io/rust-clippy/master/index.html#/mismatched_target_os
56+
5357
## Bitflags
5458

5559
Many C functions have flags parameters that are combined from constants using

build.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ fn main() {
1515
watchos: { target_os = "watchos" },
1616
tvos: { target_os = "tvos" },
1717

18+
19+
// cfg aliases we would like to use
1820
apple_targets: { any(ios, macos, watchos, tvos) },
1921
bsd: { any(freebsd, dragonfly, netbsd, openbsd, apple_targets) },
2022
linux_android: { any(android, linux) },

0 commit comments

Comments
 (0)