Merge Apple std::os extensions modules into std::os::darwin · model-checking/verify-rust-std@cfb0556 (original) (raw)

16 files changed

lines changed

Original file line number Diff line number Diff line change
@@ -1638,16 +1638,8 @@ fn rename_directory() {
1638 1638
1639 1639 #[test]
1640 1640 fn test_file_times() {
1641 -#[cfg(target_os = "ios")]
1642 -use crate::os::ios::fs::FileTimesExt;
1643 -#[cfg(target_os = "macos")]
1644 -use crate::os::macos::fs::FileTimesExt;
1645 -#[cfg(target_os = "tvos")]
1646 -use crate::os::tvos::fs::FileTimesExt;
1647 -#[cfg(target_os = "visionos")]
1648 -use crate::os::visionos::fs::FileTimesExt;
1649 -#[cfg(target_os = "watchos")]
1650 -use crate::os::watchos::fs::FileTimesExt;
1641 +#[cfg(target_vendor = "apple")]
1642 +use crate::os::darwin::fs::FileTimesExt;
1651 1643 #[cfg(windows)]
1652 1644 use crate::os::windows::fs::FileTimesExt;
1653 1645
@@ -1693,16 +1685,7 @@ fn test_file_times() {
1693 1685 #[test]
1694 1686 #[cfg(target_vendor = "apple")]
1695 1687 fn test_file_times_pre_epoch_with_nanos() {
1696 -#[cfg(target_os = "ios")]
1697 -use crate::os::ios::fs::FileTimesExt;
1698 -#[cfg(target_os = "macos")]
1699 -use crate::os::macos::fs::FileTimesExt;
1700 -#[cfg(target_os = "tvos")]
1701 -use crate::os::tvos::fs::FileTimesExt;
1702 -#[cfg(target_os = "visionos")]
1703 -use crate::os::visionos::fs::FileTimesExt;
1704 -#[cfg(target_os = "watchos")]
1705 -use crate::os::watchos::fs::FileTimesExt;
1688 +use crate::os::darwin::fs::FileTimesExt;
1706 1689
1707 1690 let tmp = tmpdir();
1708 1691 let file = File::create(tmp.join("foo")).unwrap();
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
1 -#![stable(feature = "metadata_ext", since = "1.1.0")]
1 +#![allow(dead_code)]
2 2
3 3 use crate::fs::{self, Metadata};
4 4 use crate::sealed::Sealed;
5 5 use crate::sys_common::{AsInner, AsInnerMut, IntoInner};
6 6 use crate::time::SystemTime;
7 7
8 8 #[allow(deprecated)]
9 -use crate::os::macos::raw;
9 +use super::raw;
10 10
11 11 /// OS-specific extensions to [`fs::Metadata`].
12 12 ///
@@ -70,6 +70,7 @@ pub trait MetadataExt {
70 70 fn st_gen(&self) -> u32;
71 71 #[stable(feature = "metadata_ext2", since = "1.8.0")]
72 72 fn st_lspare(&self) -> u32;
73 +#[cfg(target_os = "macos")]
73 74 #[stable(feature = "metadata_ext2", since = "1.8.0")]
74 75 fn st_qspare(&self) -> [u64; 2];
75 76 }
@@ -143,6 +144,7 @@ impl MetadataExt for Metadata {
143 144 fn st_lspare(&self) -> u32 {
144 145 self.as_inner().as_inner().st_lspare as u32
145 146 }
147 +#[cfg(target_os = "macos")]
146 148 fn st_qspare(&self) -> [u64; 2] {
147 149 let qspare = self.as_inner().as_inner().st_qspare;
148 150 [qspare[0] as u64, qspare[1] as u64]
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
1 +//! Platform-specific extensions to `std` for Darwin / Apple platforms.
2 +//!
3 +//! This is available on the following operating systems:
4 +//! - macOS
5 +//! - iOS
6 +//! - tvOS
7 +//! - watchOS
8 +//! - visionOS
9 +//!
10 +//! Note: This module is called "Darwin" as that's the name of the underlying
11 +//! core OS of the above operating systems, but it should not be confused with
12 +//! the `-darwin` suffix in the `x86_64-apple-darwin` and
13 +//! `aarch64-apple-darwin` target names, which are mostly named that way for
14 +//! legacy reasons.
15 +
16 +pub(crate) mod fs;
17 +// deprecated, but used for public reexport under `std::os::unix::raw`, as
18 +// well as `std::os::macos`/`std::os::ios`, because those modules precede the
19 +// decision to remove these.
20 +pub(super) mod raw;
Original file line number Diff line number Diff line change
@@ -1,15 +1,4 @@
1 -//! iOS-specific raw type definitions
2 -
3 -#![stable(feature = "raw_ext", since = "1.1.0")]
4 -#![deprecated(
5 - since = "1.8.0",
6 - note = "these type aliases are no longer supported by \
7 - the standard library, the `libc` crate on \
8 - crates.io should be used instead for the correct \
9 - definitions"
10 -)]
11 -#![allow(deprecated)]
12 -
1 +//! Apple-specific raw type definitions
13 2 use crate::os::raw::c_long;
14 3
15 4 #[stable(feature = "raw_ext", since = "1.1.0")]
@@ -35,6 +24,7 @@ pub type pthread_t = usize;
35 24 #[repr(C)]
36 25 #[derive(Clone)]
37 26 #[stable(feature = "raw_ext", since = "1.1.0")]
27 +#[allow(dead_code)]
38 28 pub struct stat {
39 29 #[stable(feature = "raw_ext", since = "1.1.0")]
40 30 pub st_dev: i32,
Original file line number Diff line number Diff line change
@@ -2,5 +2,29 @@
2 2
3 3 #![stable(feature = "raw_ext", since = "1.1.0")]
4 4
5 -pub mod fs;
6 -pub mod raw;
5 +#[stable(feature = "metadata_ext", since = "1.1.0")]
6 +pub mod fs {
7 +#[doc(inline)]
8 +#[stable(feature = "file_set_times", since = "1.75.0")]
9 +pub use crate::os::darwin::fs::FileTimesExt;
10 +
11 +#[doc(inline)]
12 +#[stable(feature = "metadata_ext", since = "1.1.0")]
13 +pub use crate::os::darwin::fs::MetadataExt;
14 +}
15 +
16 +/// iOS-specific raw type definitions
17 +#[stable(feature = "raw_ext", since = "1.1.0")]
18 +#[deprecated(
19 + since = "1.8.0",
20 + note = "these type aliases are no longer supported by \
21 + the standard library, the `libc` crate on \
22 + crates.io should be used instead for the correct \
23 + definitions"
24 +)]
25 +#[allow(deprecated)]
26 +pub mod raw {
27 +#[doc(inline)]
28 +#[stable(feature = "raw_ext", since = "1.1.0")]
29 +pub use crate::os::darwin::raw::*;
30 +}
Original file line number Diff line number Diff line change
@@ -2,5 +2,29 @@
2 2
3 3 #![stable(feature = "raw_ext", since = "1.1.0")]
4 4
5 -pub mod fs;
6 -pub mod raw;
5 +#[stable(feature = "metadata_ext", since = "1.1.0")]
6 +pub mod fs {
7 +#[doc(inline)]
8 +#[stable(feature = "file_set_times", since = "1.75.0")]
9 +pub use crate::os::darwin::fs::FileTimesExt;
10 +
11 +#[doc(inline)]
12 +#[stable(feature = "metadata_ext", since = "1.1.0")]
13 +pub use crate::os::darwin::fs::MetadataExt;
14 +}
15 +
16 +/// macOS-specific raw type definitions
17 +#[stable(feature = "raw_ext", since = "1.1.0")]
18 +#[deprecated(
19 + since = "1.8.0",
20 + note = "these type aliases are no longer supported by \
21 + the standard library, the `libc` crate on \
22 + crates.io should be used instead for the correct \
23 + definitions"
24 +)]
25 +#[allow(deprecated)]
26 +pub mod raw {
27 +#[doc(inline)]
28 +#[stable(feature = "raw_ext", since = "1.1.0")]
29 +pub use crate::os::darwin::raw::*;
30 +}