Skip to content

Commit

Permalink
Don't expose stat and as_raw_stat on platforms where we don't need to
Browse files Browse the repository at this point in the history
  • Loading branch information
madsmtm committed May 4, 2024
1 parent 200e11e commit e1d641f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
5 changes: 5 additions & 0 deletions library/std/src/os/apple/fs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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`].
Expand All @@ -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")]
Expand Down Expand Up @@ -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) }
}
Expand Down
3 changes: 3 additions & 0 deletions library/std/src/os/apple/raw.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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")]
Expand All @@ -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,
Expand Down

0 comments on commit e1d641f

Please sign in to comment.