Skip to content

Commit d616440

Browse files
committed
Fix compilation with --cfg doc
1 parent e862818 commit d616440

File tree

4 files changed

+16
-18
lines changed

4 files changed

+16
-18
lines changed

src/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -512,7 +512,6 @@ impl TcpKeepalive {
512512
#[cfg(all(
513513
feature = "all",
514514
any(
515-
doc,
516515
target_os = "android",
517516
target_os = "dragonfly",
518517
target_os = "freebsd",

src/socket.rs

+7-12
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ impl Socket {
147147
/// This function sets the same flags as in done for [`Socket::new`],
148148
/// [`Socket::pair_raw`] can be used if you don't want to set those flags.
149149
#[doc = man_links!(unix: socketpair(2))]
150-
#[cfg(any(doc, all(feature = "all", unix)))]
150+
#[cfg(all(feature = "all", unix))]
151151
#[cfg_attr(docsrs, doc(cfg(all(feature = "all", unix))))]
152152
pub fn pair(
153153
domain: Domain,
@@ -164,7 +164,7 @@ impl Socket {
164164
/// Creates a pair of sockets which are connected to each other.
165165
///
166166
/// This function corresponds to `socketpair(2)`.
167-
#[cfg(any(doc, all(feature = "all", unix)))]
167+
#[cfg(all(feature = "all", unix))]
168168
#[cfg_attr(docsrs, doc(cfg(all(feature = "all", unix))))]
169169
pub fn pair_raw(
170170
domain: Domain,
@@ -1091,7 +1091,7 @@ impl Socket {
10911091
/// For more information about this option, see [`set_ip_transparent`].
10921092
///
10931093
/// [`set_ip_transparent`]: Socket::set_ip_transparent
1094-
#[cfg(any(doc, all(feature = "all", target_os = "linux")))]
1094+
#[cfg(all(feature = "all", target_os = "linux"))]
10951095
#[cfg_attr(docsrs, doc(cfg(all(feature = "all", target_os = "linux"))))]
10961096
pub fn ip_transparent(&self) -> io::Result<bool> {
10971097
unsafe {
@@ -1115,7 +1115,7 @@ impl Socket {
11151115
///
11161116
/// TProxy redirection with the iptables TPROXY target also
11171117
/// requires that this option be set on the redirected socket.
1118-
#[cfg(any(doc, all(feature = "all", target_os = "linux")))]
1118+
#[cfg(all(feature = "all", target_os = "linux"))]
11191119
#[cfg_attr(docsrs, doc(cfg(all(feature = "all", target_os = "linux"))))]
11201120
pub fn set_ip_transparent(&self, transparent: bool) -> io::Result<()> {
11211121
unsafe {
@@ -1737,12 +1737,9 @@ impl Socket {
17371737
///
17381738
/// This returns the value of `TCP_KEEPALIVE` on macOS and iOS and `TCP_KEEPIDLE` on all other
17391739
/// supported Unix operating systems.
1740-
#[cfg(any(
1741-
doc,
1742-
all(
1743-
feature = "all",
1744-
not(any(windows, target_os = "haiku", target_os = "openbsd"))
1745-
)
1740+
#[cfg(all(
1741+
feature = "all",
1742+
not(any(windows, target_os = "haiku", target_os = "openbsd"))
17461743
))]
17471744
#[cfg_attr(
17481745
docsrs,
@@ -1763,7 +1760,6 @@ impl Socket {
17631760
#[cfg(all(
17641761
feature = "all",
17651762
any(
1766-
doc,
17671763
target_os = "android",
17681764
target_os = "dragonfly",
17691765
target_os = "freebsd",
@@ -1805,7 +1801,6 @@ impl Socket {
18051801
#[cfg(all(
18061802
feature = "all",
18071803
any(
1808-
doc,
18091804
target_os = "android",
18101805
target_os = "dragonfly",
18111806
target_os = "freebsd",

src/sys/unix.rs

+8-4
Original file line numberDiff line numberDiff line change
@@ -609,7 +609,8 @@ pub(crate) fn socket(family: c_int, ty: c_int, protocol: c_int) -> io::Result<So
609609
syscall!(socket(family, ty, protocol))
610610
}
611611

612-
#[cfg(feature = "all")]
612+
#[cfg(all(feature = "all", unix))]
613+
#[cfg_attr(docsrs, doc(cfg(all(feature = "all", unix))))]
613614
pub(crate) fn socketpair(family: c_int, ty: c_int, protocol: c_int) -> io::Result<[Socket; 2]> {
614615
let mut fds = [0, 0];
615616
syscall!(socketpair(family, ty, protocol, fds.as_mut_ptr())).map(|_| fds)
@@ -898,8 +899,11 @@ fn into_timeval(duration: Option<Duration>) -> libc::timeval {
898899
}
899900
}
900901

901-
#[cfg(feature = "all")]
902-
#[cfg(not(any(target_os = "haiku", target_os = "openbsd")))]
902+
#[cfg(all(feature = "all", not(any(target_os = "haiku", target_os = "openbsd"))))]
903+
#[cfg_attr(
904+
docsrs,
905+
doc(cfg(all(feature = "all", not(any(target_os = "haiku", target_os = "openbsd")))))
906+
)]
903907
pub(crate) fn keepalive_time(fd: Socket) -> io::Result<Duration> {
904908
unsafe {
905909
getsockopt::<c_int>(fd, IPPROTO_TCP, KEEPALIVE_TIME)
@@ -1158,7 +1162,7 @@ impl crate::Socket {
11581162
}
11591163

11601164
/// Sets `SO_NOSIGPIPE` on the socket.
1161-
#[cfg(all(feature = "all", any(doc, target_vendor = "apple")))]
1165+
#[cfg(all(feature = "all", target_vendor = "apple"))]
11621166
#[cfg_attr(docsrs, doc(cfg(all(feature = "all", target_vendor = "apple"))))]
11631167
pub fn set_nosigpipe(&self, nosigpipe: bool) -> io::Result<()> {
11641168
self._set_nosigpipe(nosigpipe)

tests/socket.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1366,7 +1366,7 @@ fn tcp_congestion() {
13661366
let cur_tcp_ca = cur_tcp_ca.splitn(2, |num| *num == 0).next().unwrap();
13671367
const OPTIONS: [&[u8]; 2] = [
13681368
b"cubic",
1369-
#[cfg(target_os = "linux")] // or Android.
1369+
#[cfg(target_os = "linux")]
13701370
b"reno",
13711371
#[cfg(target_os = "freebsd")]
13721372
b"newreno",

0 commit comments

Comments
 (0)