Skip to content

Commit a58c042

Browse files
committed
use cfg_match
1 parent c90accd commit a58c042

File tree

2 files changed

+21
-29
lines changed

2 files changed

+21
-29
lines changed

library/std/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -277,6 +277,7 @@
277277
#![feature(allow_internal_unstable)]
278278
#![feature(asm_experimental_arch)]
279279
#![feature(autodiff)]
280+
#![feature(cfg_match)]
280281
#![feature(cfg_sanitizer_cfi)]
281282
#![feature(cfg_target_thread_local)]
282283
#![feature(cfi_encoding)]

library/std/src/os/unix/net/stream.rs

Lines changed: 20 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,23 @@
1-
#[cfg(any(
2-
target_os = "linux",
3-
target_os = "android",
4-
target_os = "dragonfly",
5-
target_os = "freebsd",
6-
target_os = "openbsd",
7-
target_os = "netbsd",
8-
target_os = "solaris",
9-
target_os = "illumos",
10-
target_os = "haiku",
11-
target_os = "nto",
12-
target_os = "cygwin"
13-
))]
14-
use libc::MSG_NOSIGNAL;
1+
cfg_match! {
2+
any(
3+
target_os = "linux",
4+
target_os = "android",
5+
target_os = "dragonfly",
6+
target_os = "freebsd",
7+
target_os = "openbsd",
8+
target_os = "netbsd",
9+
target_os = "solaris",
10+
target_os = "illumos",
11+
target_os = "haiku",
12+
target_os = "nto",
13+
target_os = "cygwin"
14+
) => {
15+
use libc::MSG_NOSIGNAL;
16+
}
17+
_ => {
18+
const MSG_NOSIGNAL: core::ffi::c_int = 0x0;
19+
}
20+
}
1521

1622
use super::{SocketAddr, sockaddr_un};
1723
#[cfg(any(doc, target_os = "android", target_os = "linux"))]
@@ -40,21 +46,6 @@ use crate::sys_common::{AsInner, FromInner};
4046
use crate::time::Duration;
4147
use crate::{cmp, fmt};
4248

43-
#[cfg(not(any(
44-
target_os = "linux",
45-
target_os = "android",
46-
target_os = "dragonfly",
47-
target_os = "freebsd",
48-
target_os = "openbsd",
49-
target_os = "netbsd",
50-
target_os = "solaris",
51-
target_os = "illumos",
52-
target_os = "haiku",
53-
target_os = "nto",
54-
target_os = "cygwin"
55-
)))]
56-
const MSG_NOSIGNAL: core::ffi::c_int = 0x0;
57-
5849
/// A Unix stream socket.
5950
///
6051
/// # Examples

0 commit comments

Comments
 (0)