Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit c370665

Browse files
committedAug 13, 2024
Make std::os::darwin public
This includes `std::os::darwin::fs`, which is re-exported under `std::os::macos::fs` and `std::os::ios::fs`. `std::os::darwin::raw` is not exposed, which means that `MetadataExt::as_raw_stat` isn't available on tvOS, visionOS and watchOS.
1 parent 37017c0 commit c370665

File tree

6 files changed

+37
-15
lines changed

6 files changed

+37
-15
lines changed
 

‎std/src/os/darwin/fs.rs

+11-6
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1-
#![allow(dead_code)]
1+
//! Darwin-specific extension traits to [`fs`].
2+
//!
3+
//! [`fs`]: crate::fs
4+
#![stable(feature = "metadata_ext", since = "1.1.0")]
25

3-
#[allow(deprecated)]
4-
use super::raw;
56
use crate::fs::{self, Metadata};
67
use crate::sealed::Sealed;
78
use crate::sys_common::{AsInner, AsInnerMut, IntoInner};
@@ -25,7 +26,10 @@ pub trait MetadataExt {
2526
methods of this trait"
2627
)]
2728
#[allow(deprecated)]
28-
fn as_raw_stat(&self) -> &raw::stat;
29+
// Only available on macOS and iOS, since they were stably exposed there.
30+
#[cfg(any(doc, target_os = "macos", target_os = "ios"))]
31+
#[doc(cfg(any(target_os = "macos", target_os = "ios")))]
32+
fn as_raw_stat(&self) -> &super::raw::stat;
2933

3034
#[stable(feature = "metadata_ext2", since = "1.8.0")]
3135
fn st_dev(&self) -> u64;
@@ -77,8 +81,9 @@ pub trait MetadataExt {
7781
#[stable(feature = "metadata_ext", since = "1.1.0")]
7882
impl MetadataExt for Metadata {
7983
#[allow(deprecated)]
80-
fn as_raw_stat(&self) -> &raw::stat {
81-
unsafe { &*(self.as_inner().as_inner() as *const libc::stat as *const raw::stat) }
84+
#[cfg(any(doc, target_os = "macos", target_os = "ios"))]
85+
fn as_raw_stat(&self) -> &super::raw::stat {
86+
unsafe { &*(self.as_inner().as_inner() as *const libc::stat as *const super::raw::stat) }
8287
}
8388
fn st_dev(&self) -> u64 {
8489
self.as_inner().as_inner().st_dev as u64

‎std/src/os/darwin/mod.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,10 @@
1313
//! `aarch64-apple-darwin` target names, which are mostly named that way for
1414
//! legacy reasons.
1515
16-
pub(crate) mod fs;
16+
#![stable(feature = "os_darwin", since = "CURRENT_RUSTC_VERSION")]
17+
#![doc(cfg(target_vendor = "apple"))]
18+
19+
pub mod fs;
1720
// deprecated, but used for public reexport under `std::os::unix::raw`, as
1821
// well as `std::os::macos`/`std::os::ios`, because those modules precede the
1922
// decision to remove these.

‎std/src/os/ios/mod.rs

-2
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,8 @@
44

55
#[stable(feature = "metadata_ext", since = "1.1.0")]
66
pub mod fs {
7-
#[doc(inline)]
87
#[stable(feature = "file_set_times", since = "1.75.0")]
98
pub use crate::os::darwin::fs::FileTimesExt;
10-
#[doc(inline)]
119
#[stable(feature = "metadata_ext", since = "1.1.0")]
1210
pub use crate::os::darwin::fs::MetadataExt;
1311
}

‎std/src/os/macos/mod.rs

-2
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,8 @@
44

55
#[stable(feature = "metadata_ext", since = "1.1.0")]
66
pub mod fs {
7-
#[doc(inline)]
87
#[stable(feature = "file_set_times", since = "1.75.0")]
98
pub use crate::os::darwin::fs::FileTimesExt;
10-
#[doc(inline)]
119
#[stable(feature = "metadata_ext", since = "1.1.0")]
1210
pub use crate::os::darwin::fs::MetadataExt;
1311
}

‎std/src/os/mod.rs

+21-3
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,16 @@ pub mod raw;
1515
// documented don't compile (missing things in `libc` which is empty),
1616
// so just omit them with an empty module and add the "unstable" attribute.
1717

18-
// unix, linux, wasi and windows are handled a bit differently.
18+
// darwin, unix, linux, wasi and windows are handled a bit differently.
19+
#[cfg(all(
20+
doc,
21+
any(
22+
all(target_arch = "wasm32", not(target_os = "wasi")),
23+
all(target_vendor = "fortanix", target_env = "sgx")
24+
)
25+
))]
26+
#[unstable(issue = "none", feature = "std_internals")]
27+
pub mod darwin {}
1928
#[cfg(all(
2029
doc,
2130
any(
@@ -53,6 +62,17 @@ pub mod wasi {}
5362
#[unstable(issue = "none", feature = "std_internals")]
5463
pub mod windows {}
5564

65+
// darwin
66+
#[cfg(not(all(
67+
doc,
68+
any(
69+
all(target_arch = "wasm32", not(target_os = "wasi")),
70+
all(target_vendor = "fortanix", target_env = "sgx")
71+
)
72+
)))]
73+
#[cfg(any(target_vendor = "apple", doc))]
74+
pub mod darwin;
75+
5676
// unix
5777
#[cfg(not(all(
5878
doc,
@@ -105,8 +125,6 @@ pub mod windows;
105125
pub mod aix;
106126
#[cfg(target_os = "android")]
107127
pub mod android;
108-
#[cfg(target_vendor = "apple")]
109-
pub(crate) mod darwin;
110128
#[cfg(target_os = "dragonfly")]
111129
pub mod dragonfly;
112130
#[cfg(target_os = "emscripten")]

‎std/src/os/unix/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ mod platform {
4242
#[cfg(target_os = "android")]
4343
pub use crate::os::android::*;
4444
#[cfg(target_vendor = "apple")]
45-
pub(super) use crate::os::darwin::*;
45+
pub use crate::os::darwin::*;
4646
#[cfg(target_os = "dragonfly")]
4747
pub use crate::os::dragonfly::*;
4848
#[cfg(target_os = "emscripten")]

0 commit comments

Comments
 (0)
Failed to load comments.