Skip to content

Commit c19664d

Browse files
authored
Rollup merge of rust-lang#82686 - CDirkx:unix-platform, r=m-ou-se
Move `std::sys::unix::platform` to `std::sys::unix::ext` This moves the operating system dependent alias `platform` (`std::os::{linux, android, ...}`) from `std::sys::unix` to `std::sys::unix::ext` (a.k.a. `std::os::unix`), removing the need for compatibility code in `unix_ext` when documenting on another platform. This is also a step in making it possible to properly move `std::sys::unix::ext` to `std::os::unix`, as ideally `std::sys` should not depend on the rest of `std`.
2 parents 803c422 + 7539626 commit c19664d

File tree

5 files changed

+40
-38
lines changed

5 files changed

+40
-38
lines changed

library/std/src/sys/mod.rs

-2
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,6 @@ cfg_if::cfg_if! {
7070
#[allow(missing_docs)]
7171
pub mod unix_ext {}
7272
} else {
73-
// On other platforms like Windows document the bare bones of unix
74-
use crate::os::linux as platform;
7573
#[path = "unix/ext/mod.rs"]
7674
pub mod unix_ext;
7775
}

library/std/src/sys/unix/ext/fs.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22
33
#![stable(feature = "rust1", since = "1.0.0")]
44

5+
use super::platform::fs::MetadataExt as _;
56
use crate::fs::{self, OpenOptions, Permissions};
67
use crate::io;
78
use crate::path::Path;
89
use crate::sys;
9-
use crate::sys::platform::fs::MetadataExt as UnixMetadataExt;
1010
use crate::sys_common::{AsInner, AsInnerMut, FromInner};
1111
// Used for `File::read` on intra-doc links
1212
#[allow(unused_imports)]

library/std/src/sys/unix/ext/mod.rs

+36
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,42 @@
2929
#![doc(cfg(unix))]
3030
#![allow(missing_docs)]
3131

32+
cfg_if::cfg_if! {
33+
if #[cfg(doc)] {
34+
// Use linux as the default platform when documenting on other platforms like Windows
35+
use crate::os::linux as platform;
36+
} else {
37+
#[cfg(target_os = "android")]
38+
use crate::os::android as platform;
39+
#[cfg(target_os = "dragonfly")]
40+
use crate::os::dragonfly as platform;
41+
#[cfg(target_os = "emscripten")]
42+
use crate::os::emscripten as platform;
43+
#[cfg(target_os = "freebsd")]
44+
use crate::os::freebsd as platform;
45+
#[cfg(target_os = "fuchsia")]
46+
use crate::os::fuchsia as platform;
47+
#[cfg(target_os = "haiku")]
48+
use crate::os::haiku as platform;
49+
#[cfg(target_os = "illumos")]
50+
use crate::os::illumos as platform;
51+
#[cfg(target_os = "ios")]
52+
use crate::os::ios as platform;
53+
#[cfg(any(target_os = "linux", target_os = "l4re"))]
54+
use crate::os::linux as platform;
55+
#[cfg(target_os = "macos")]
56+
use crate::os::macos as platform;
57+
#[cfg(target_os = "netbsd")]
58+
use crate::os::netbsd as platform;
59+
#[cfg(target_os = "openbsd")]
60+
use crate::os::openbsd as platform;
61+
#[cfg(target_os = "redox")]
62+
use crate::os::redox as platform;
63+
#[cfg(target_os = "solaris")]
64+
use crate::os::solaris as platform;
65+
}
66+
}
67+
3268
pub mod ffi;
3369
pub mod fs;
3470
pub mod io;

library/std/src/sys/unix/ext/raw.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,10 @@ pub type pid_t = i32;
2424

2525
#[doc(inline)]
2626
#[stable(feature = "pthread_t", since = "1.8.0")]
27-
pub use crate::sys::platform::raw::pthread_t;
27+
pub use super::platform::raw::pthread_t;
2828
#[doc(inline)]
2929
#[stable(feature = "raw_ext", since = "1.1.0")]
30-
pub use crate::sys::platform::raw::{blkcnt_t, time_t};
30+
pub use super::platform::raw::{blkcnt_t, time_t};
3131
#[doc(inline)]
3232
#[stable(feature = "raw_ext", since = "1.1.0")]
33-
pub use crate::sys::platform::raw::{blksize_t, dev_t, ino_t, mode_t, nlink_t, off_t};
33+
pub use super::platform::raw::{blksize_t, dev_t, ino_t, mode_t, nlink_t, off_t};

library/std/src/sys/unix/mod.rs

-32
Original file line numberDiff line numberDiff line change
@@ -2,38 +2,6 @@
22

33
use crate::io::ErrorKind;
44

5-
#[cfg(any(doc, target_os = "linux"))]
6-
pub use crate::os::linux as platform;
7-
8-
#[cfg(all(not(doc), target_os = "android"))]
9-
pub use crate::os::android as platform;
10-
#[cfg(all(not(doc), target_os = "dragonfly"))]
11-
pub use crate::os::dragonfly as platform;
12-
#[cfg(all(not(doc), target_os = "emscripten"))]
13-
pub use crate::os::emscripten as platform;
14-
#[cfg(all(not(doc), target_os = "freebsd"))]
15-
pub use crate::os::freebsd as platform;
16-
#[cfg(all(not(doc), target_os = "fuchsia"))]
17-
pub use crate::os::fuchsia as platform;
18-
#[cfg(all(not(doc), target_os = "haiku"))]
19-
pub use crate::os::haiku as platform;
20-
#[cfg(all(not(doc), target_os = "illumos"))]
21-
pub use crate::os::illumos as platform;
22-
#[cfg(all(not(doc), target_os = "ios"))]
23-
pub use crate::os::ios as platform;
24-
#[cfg(all(not(doc), target_os = "l4re"))]
25-
pub use crate::os::linux as platform;
26-
#[cfg(all(not(doc), target_os = "macos"))]
27-
pub use crate::os::macos as platform;
28-
#[cfg(all(not(doc), target_os = "netbsd"))]
29-
pub use crate::os::netbsd as platform;
30-
#[cfg(all(not(doc), target_os = "openbsd"))]
31-
pub use crate::os::openbsd as platform;
32-
#[cfg(all(not(doc), target_os = "redox"))]
33-
pub use crate::os::redox as platform;
34-
#[cfg(all(not(doc), target_os = "solaris"))]
35-
pub use crate::os::solaris as platform;
36-
375
pub use self::rand::hashmap_random_keys;
386
pub use libc::strlen;
397

0 commit comments

Comments
 (0)