Skip to content

Commit 1176d30

Browse files
authored
Rollup merge of rust-lang#86509 - CDirkx:os_str, r=m-ou-se
Move `os_str_bytes` to `sys::unix` Followup to rust-lang#84967, with `OsStrExt` and `OsStringExt` moved out of `sys_common`, there is no reason anymore for `os_str_bytes` to live in `sys_common` and not in sys. This pr moves it to the location `sys::unix::os_str` and reuses the code on other platforms via `#[path]` (as is common in `sys`) instead of importing.
2 parents a03d6da + c93cb40 commit 1176d30

File tree

10 files changed

+12
-14
lines changed

10 files changed

+12
-14
lines changed

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

+2-1
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ pub mod memchr;
3232
pub mod mutex;
3333
pub mod net;
3434
pub mod os;
35+
#[path = "../unix/os_str.rs"]
36+
pub mod os_str;
3537
#[path = "../unix/path.rs"]
3638
pub mod path;
3739
#[path = "../unsupported/pipe.rs"]
@@ -47,7 +49,6 @@ pub mod thread_local_key;
4749
pub mod time;
4850

4951
use crate::io::ErrorKind;
50-
pub use crate::sys_common::os_str_bytes as os_str;
5152

5253
#[allow(unused_extern_crates)]
5354
pub extern crate hermit_abi as abi;

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

+2-2
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ pub mod memchr;
2626
pub mod mutex;
2727
pub mod net;
2828
pub mod os;
29+
#[path = "../unix/os_str.rs"]
30+
pub mod os_str;
2931
pub mod path;
3032
#[path = "../unsupported/pipe.rs"]
3133
pub mod pipe;
@@ -37,8 +39,6 @@ pub mod thread;
3739
pub mod thread_local_key;
3840
pub mod time;
3941

40-
pub use crate::sys_common::os_str_bytes as os_str;
41-
4242
// SAFETY: must be called only once during runtime initialization.
4343
// NOTE: this is not guaranteed to run, for example when Rust code is called externally.
4444
pub unsafe fn init(argc: isize, argv: *const *const u8) {

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

+1-2
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ pub mod net;
3030
#[cfg(target_os = "l4re")]
3131
pub use self::l4re::net;
3232
pub mod os;
33+
pub mod os_str;
3334
pub mod path;
3435
pub mod pipe;
3536
pub mod process;
@@ -42,8 +43,6 @@ pub mod thread_local_dtor;
4243
pub mod thread_local_key;
4344
pub mod time;
4445

45-
pub use crate::sys_common::os_str_bytes as os_str;
46-
4746
// SAFETY: must be called only once during runtime initialization.
4847
// NOTE: this is not guaranteed to run, for example when Rust code is called externally.
4948
pub unsafe fn init(argc: isize, argv: *const *const u8) {

library/std/src/sys_common/os_str_bytes.rs library/std/src/sys/unix/os_str.rs

+1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ use crate::sys_common::{AsInner, IntoInner};
1313
use core::str::lossy::{Utf8Lossy, Utf8LossyChunk};
1414

1515
#[cfg(test)]
16+
#[path = "../unix/os_str/tests.rs"]
1617
mod tests;
1718

1819
#[derive(Hash)]

library/std/src/sys/unsupported/common.rs

-2
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@ pub mod memchr {
44
pub use core::slice::memchr::{memchr, memrchr};
55
}
66

7-
pub use crate::sys_common::os_str_bytes as os_str;
8-
97
// This is not necessarily correct. May want to consider making it part of the
108
// spec definition?
119
use crate::os::raw::c_char;

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

+2
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ pub mod io;
1111
pub mod mutex;
1212
pub mod net;
1313
pub mod os;
14+
#[path = "../unix/os_str.rs"]
15+
pub mod os_str;
1416
#[path = "../unix/path.rs"]
1517
pub mod path;
1618
pub mod pipe;

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

+2-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,8 @@ pub mod io;
3232
pub mod mutex;
3333
pub mod net;
3434
pub mod os;
35-
pub use crate::sys_common::os_str_bytes as os_str;
35+
#[path = "../unix/os_str.rs"]
36+
pub mod os_str;
3637
#[path = "../unix/path.rs"]
3738
pub mod path;
3839
#[path = "../unsupported/pipe.rs"]

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

+2-2
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ pub mod io;
3030
pub mod net;
3131
#[path = "../unsupported/os.rs"]
3232
pub mod os;
33+
#[path = "../unix/os_str.rs"]
34+
pub mod os_str;
3335
#[path = "../unix/path.rs"]
3436
pub mod path;
3537
#[path = "../unsupported/pipe.rs"]
@@ -45,8 +47,6 @@ pub mod thread_local_key;
4547
#[path = "../unsupported/time.rs"]
4648
pub mod time;
4749

48-
pub use crate::sys_common::os_str_bytes as os_str;
49-
5050
cfg_if::cfg_if! {
5151
if #[cfg(target_feature = "atomics")] {
5252
#[path = "atomics/condvar.rs"]

library/std/src/sys_common/mod.rs

-4
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,6 @@ pub mod fs;
2626
pub mod io;
2727
pub mod memchr;
2828
pub mod mutex;
29-
// `doc` is required because `sys/mod.rs` imports `unix/ext/mod.rs` on Windows
30-
// when generating documentation.
31-
#[cfg(any(doc, not(windows)))]
32-
pub mod os_str_bytes;
3329
pub mod process;
3430
pub mod remutex;
3531
#[macro_use]

0 commit comments

Comments
 (0)