Skip to content

Commit

Permalink
Rollup merge of rust-lang#86509 - CDirkx:os_str, r=m-ou-se
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
JohnTitor authored Aug 2, 2021
2 parents a03d6da + c93cb40 commit 1176d30
Show file tree
Hide file tree
Showing 10 changed files with 12 additions and 14 deletions.
3 changes: 2 additions & 1 deletion library/std/src/sys/hermit/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ pub mod memchr;
pub mod mutex;
pub mod net;
pub mod os;
#[path = "../unix/os_str.rs"]
pub mod os_str;
#[path = "../unix/path.rs"]
pub mod path;
#[path = "../unsupported/pipe.rs"]
Expand All @@ -47,7 +49,6 @@ pub mod thread_local_key;
pub mod time;

use crate::io::ErrorKind;
pub use crate::sys_common::os_str_bytes as os_str;

#[allow(unused_extern_crates)]
pub extern crate hermit_abi as abi;
Expand Down
4 changes: 2 additions & 2 deletions library/std/src/sys/sgx/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ pub mod memchr;
pub mod mutex;
pub mod net;
pub mod os;
#[path = "../unix/os_str.rs"]
pub mod os_str;
pub mod path;
#[path = "../unsupported/pipe.rs"]
pub mod pipe;
Expand All @@ -37,8 +39,6 @@ pub mod thread;
pub mod thread_local_key;
pub mod time;

pub use crate::sys_common::os_str_bytes as os_str;

// SAFETY: must be called only once during runtime initialization.
// NOTE: this is not guaranteed to run, for example when Rust code is called externally.
pub unsafe fn init(argc: isize, argv: *const *const u8) {
Expand Down
3 changes: 1 addition & 2 deletions library/std/src/sys/unix/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ pub mod net;
#[cfg(target_os = "l4re")]
pub use self::l4re::net;
pub mod os;
pub mod os_str;
pub mod path;
pub mod pipe;
pub mod process;
Expand All @@ -42,8 +43,6 @@ pub mod thread_local_dtor;
pub mod thread_local_key;
pub mod time;

pub use crate::sys_common::os_str_bytes as os_str;

// SAFETY: must be called only once during runtime initialization.
// NOTE: this is not guaranteed to run, for example when Rust code is called externally.
pub unsafe fn init(argc: isize, argv: *const *const u8) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ use crate::sys_common::{AsInner, IntoInner};
use core::str::lossy::{Utf8Lossy, Utf8LossyChunk};

#[cfg(test)]
#[path = "../unix/os_str/tests.rs"]
mod tests;

#[derive(Hash)]
Expand Down
File renamed without changes.
2 changes: 0 additions & 2 deletions library/std/src/sys/unsupported/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ pub mod memchr {
pub use core::slice::memchr::{memchr, memrchr};
}

pub use crate::sys_common::os_str_bytes as os_str;

// This is not necessarily correct. May want to consider making it part of the
// spec definition?
use crate::os::raw::c_char;
Expand Down
2 changes: 2 additions & 0 deletions library/std/src/sys/unsupported/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ pub mod io;
pub mod mutex;
pub mod net;
pub mod os;
#[path = "../unix/os_str.rs"]
pub mod os_str;
#[path = "../unix/path.rs"]
pub mod path;
pub mod pipe;
Expand Down
3 changes: 2 additions & 1 deletion library/std/src/sys/wasi/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ pub mod io;
pub mod mutex;
pub mod net;
pub mod os;
pub use crate::sys_common::os_str_bytes as os_str;
#[path = "../unix/os_str.rs"]
pub mod os_str;
#[path = "../unix/path.rs"]
pub mod path;
#[path = "../unsupported/pipe.rs"]
Expand Down
4 changes: 2 additions & 2 deletions library/std/src/sys/wasm/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ pub mod io;
pub mod net;
#[path = "../unsupported/os.rs"]
pub mod os;
#[path = "../unix/os_str.rs"]
pub mod os_str;
#[path = "../unix/path.rs"]
pub mod path;
#[path = "../unsupported/pipe.rs"]
Expand All @@ -45,8 +47,6 @@ pub mod thread_local_key;
#[path = "../unsupported/time.rs"]
pub mod time;

pub use crate::sys_common::os_str_bytes as os_str;

cfg_if::cfg_if! {
if #[cfg(target_feature = "atomics")] {
#[path = "atomics/condvar.rs"]
Expand Down
4 changes: 0 additions & 4 deletions library/std/src/sys_common/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,6 @@ pub mod fs;
pub mod io;
pub mod memchr;
pub mod mutex;
// `doc` is required because `sys/mod.rs` imports `unix/ext/mod.rs` on Windows
// when generating documentation.
#[cfg(any(doc, not(windows)))]
pub mod os_str_bytes;
pub mod process;
pub mod remutex;
#[macro_use]
Expand Down

0 comments on commit 1176d30

Please sign in to comment.