Skip to content

Commit 525ef2f

Browse files
authored
Rollup merge of rust-lang#141019 - ehuss:android-doctest-xcompile, r=Mark-Simulacrum
Update std doctests for android This updates some doctests that fail to run on android. We will soon be supporting cross-compiled doctests, and the `arm-android` job fails to run these tests. In summary: - Android re-exports some traits from linux under a different path. - Android doesn't seem to have common unix utilities like `true`, `false`, or `whoami`, so these are disabled.
2 parents 10ed7f5 + c6d86b4 commit 525ef2f

File tree

4 files changed

+21
-6
lines changed

4 files changed

+21
-6
lines changed

std/src/os/net/linux_ext/addr.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,10 @@ pub trait SocketAddrExt: Sealed {
2323
///
2424
/// ```no_run
2525
/// use std::os::unix::net::{UnixListener, SocketAddr};
26+
/// #[cfg(target_os = "linux")]
2627
/// use std::os::linux::net::SocketAddrExt;
28+
/// #[cfg(target_os = "android")]
29+
/// use std::os::android::net::SocketAddrExt;
2730
///
2831
/// fn main() -> std::io::Result<()> {
2932
/// let addr = SocketAddr::from_abstract_name(b"hidden")?;
@@ -48,7 +51,10 @@ pub trait SocketAddrExt: Sealed {
4851
///
4952
/// ```no_run
5053
/// use std::os::unix::net::{UnixListener, SocketAddr};
54+
/// #[cfg(target_os = "linux")]
5155
/// use std::os::linux::net::SocketAddrExt;
56+
/// #[cfg(target_os = "android")]
57+
/// use std::os::android::net::SocketAddrExt;
5258
///
5359
/// fn main() -> std::io::Result<()> {
5460
/// let name = b"hidden";

std/src/os/net/linux_ext/socket.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,10 @@ pub trait UnixSocketExt: Sealed {
2727
///
2828
/// ```no_run
2929
/// #![feature(unix_socket_ancillary_data)]
30+
/// #[cfg(target_os = "linux")]
3031
/// use std::os::linux::net::UnixSocketExt;
32+
/// #[cfg(target_os = "android")]
33+
/// use std::os::android::net::UnixSocketExt;
3134
/// use std::os::unix::net::UnixDatagram;
3235
///
3336
/// fn main() -> std::io::Result<()> {

std/src/os/net/linux_ext/tcp.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,10 @@ pub trait TcpStreamExt: Sealed {
2525
/// ```no_run
2626
/// #![feature(tcp_quickack)]
2727
/// use std::net::TcpStream;
28+
/// #[cfg(target_os = "linux")]
2829
/// use std::os::linux::net::TcpStreamExt;
30+
/// #[cfg(target_os = "android")]
31+
/// use std::os::android::net::TcpStreamExt;
2932
///
3033
/// let stream = TcpStream::connect("127.0.0.1:8080")
3134
/// .expect("Couldn't connect to the server...");
@@ -43,7 +46,10 @@ pub trait TcpStreamExt: Sealed {
4346
/// ```no_run
4447
/// #![feature(tcp_quickack)]
4548
/// use std::net::TcpStream;
49+
/// #[cfg(target_os = "linux")]
4650
/// use std::os::linux::net::TcpStreamExt;
51+
/// #[cfg(target_os = "android")]
52+
/// use std::os::android::net::TcpStreamExt;
4753
///
4854
/// let stream = TcpStream::connect("127.0.0.1:8080")
4955
/// .expect("Couldn't connect to the server...");

std/src/process.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1348,7 +1348,7 @@ impl Output {
13481348
///
13491349
/// ```
13501350
/// #![feature(exit_status_error)]
1351-
/// # #[cfg(unix)] {
1351+
/// # #[cfg(all(unix, not(target_os = "android")))] {
13521352
/// use std::process::Command;
13531353
/// assert!(Command::new("false").output().unwrap().exit_ok().is_err());
13541354
/// # }
@@ -1695,7 +1695,7 @@ impl From<io::Stdout> for Stdio {
16951695
/// # Ok(())
16961696
/// # }
16971697
/// #
1698-
/// # if cfg!(unix) {
1698+
/// # if cfg!(all(unix, not(target_os = "android"))) {
16991699
/// # test().unwrap();
17001700
/// # }
17011701
/// ```
@@ -1724,7 +1724,7 @@ impl From<io::Stderr> for Stdio {
17241724
/// # Ok(())
17251725
/// # }
17261726
/// #
1727-
/// # if cfg!(unix) {
1727+
/// # if cfg!(all(unix, not(target_os = "android"))) {
17281728
/// # test().unwrap();
17291729
/// # }
17301730
/// ```
@@ -1907,7 +1907,7 @@ impl crate::sealed::Sealed for ExitStatusError {}
19071907
///
19081908
/// ```
19091909
/// #![feature(exit_status_error)]
1910-
/// # if cfg!(unix) {
1910+
/// # if cfg!(all(unix, not(target_os = "android"))) {
19111911
/// use std::process::{Command, ExitStatusError};
19121912
///
19131913
/// fn run(cmd: &str) -> Result<(), ExitStatusError> {
@@ -1950,7 +1950,7 @@ impl ExitStatusError {
19501950
///
19511951
/// ```
19521952
/// #![feature(exit_status_error)]
1953-
/// # #[cfg(unix)] {
1953+
/// # #[cfg(all(unix, not(target_os = "android")))] {
19541954
/// use std::process::Command;
19551955
///
19561956
/// let bad = Command::new("false").status().unwrap().exit_ok().unwrap_err();
@@ -1975,7 +1975,7 @@ impl ExitStatusError {
19751975
/// ```
19761976
/// #![feature(exit_status_error)]
19771977
///
1978-
/// # if cfg!(unix) {
1978+
/// # if cfg!(all(unix, not(target_os = "android"))) {
19791979
/// use std::num::NonZero;
19801980
/// use std::process::Command;
19811981
///

0 commit comments

Comments
 (0)