diff --git a/library/std/src/os/apple/fs.rs b/library/std/src/os/apple/fs.rs index 6acef4cfb95b..4acc3fb85666 100644 --- a/library/std/src/os/apple/fs.rs +++ b/library/std/src/os/apple/fs.rs @@ -6,6 +6,7 @@ use crate::sys_common::{AsInner, AsInnerMut, IntoInner}; use crate::time::SystemTime; #[allow(deprecated)] +#[cfg(any(target_os = "macos", target_os = "ios"))] use super::raw; /// OS-specific extensions to [`fs::Metadata`]. @@ -26,6 +27,8 @@ pub trait MetadataExt { methods of this trait" )] #[allow(deprecated)] + // To maintain backwards compat, is omitted on other Apple targets. + #[cfg(any(target_os = "macos", target_os = "ios"))] fn as_raw_stat(&self) -> &raw::stat; #[stable(feature = "metadata_ext2", since = "1.8.0")] @@ -78,6 +81,8 @@ pub trait MetadataExt { #[stable(feature = "metadata_ext", since = "1.1.0")] impl MetadataExt for Metadata { #[allow(deprecated)] + // To maintain backwards compat, is omitted on other Apple targets. + #[cfg(any(target_os = "macos", target_os = "ios"))] fn as_raw_stat(&self) -> &raw::stat { unsafe { &*(self.as_inner().as_inner() as *const libc::stat as *const raw::stat) } } diff --git a/library/std/src/os/apple/raw.rs b/library/std/src/os/apple/raw.rs index ffc0dcae7caf..928e453f4e7e 100644 --- a/library/std/src/os/apple/raw.rs +++ b/library/std/src/os/apple/raw.rs @@ -13,6 +13,7 @@ )] #![allow(deprecated)] +#[cfg(any(target_os = "macos", target_os = "ios"))] use crate::os::raw::c_long; #[stable(feature = "raw_ext", since = "1.1.0")] @@ -38,6 +39,8 @@ pub type pthread_t = usize; #[repr(C)] #[derive(Clone)] #[stable(feature = "raw_ext", since = "1.1.0")] +// To maintain backwards compat, is omitted on other Apple targets. +#[cfg(any(target_os = "macos", target_os = "ios"))] pub struct stat { #[stable(feature = "raw_ext", since = "1.1.0")] pub st_dev: i32,