From 00be9741bfba741d0f2a43a89eaad7c9abe7a468 Mon Sep 17 00:00:00 2001 From: Michael Baikov Date: Mon, 3 Aug 2026 06:15:53 -0400 Subject: [PATCH] std: reduce visibility of some internal OsStr related types The std::sys::os_str::{Buf, Slice} types are only used within the std crate and not actually exported. Whole `sys` module is private. They don't need to be public. This might result in a better generated code, but more importantly it avoids some compile errors down the line. --- library/std/src/sys/os_str/bytes.rs | 4 ++-- library/std/src/sys/os_str/mod.rs | 6 +++--- library/std/src/sys/os_str/utf8.rs | 4 ++-- library/std/src/sys/os_str/wtf8.rs | 4 ++-- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/library/std/src/sys/os_str/bytes.rs b/library/std/src/sys/os_str/bytes.rs index a57da01a5d85d..048e5def1369b 100644 --- a/library/std/src/sys/os_str/bytes.rs +++ b/library/std/src/sys/os_str/bytes.rs @@ -16,12 +16,12 @@ mod tests; #[derive(Hash)] #[repr(transparent)] -pub struct Buf { +pub(crate) struct Buf { pub inner: Vec, } #[repr(transparent)] -pub struct Slice { +pub(crate) struct Slice { pub inner: [u8], } diff --git a/library/std/src/sys/os_str/mod.rs b/library/std/src/sys/os_str/mod.rs index f7007cbf18b4c..dd37b558a096e 100644 --- a/library/std/src/sys/os_str/mod.rs +++ b/library/std/src/sys/os_str/mod.rs @@ -3,14 +3,14 @@ cfg_select! { any(target_os = "windows", target_os = "uefi") => { mod wtf8; - pub use wtf8::{Buf, Slice}; + pub(crate) use wtf8::{Buf, Slice}; } any(target_os = "motor") => { mod utf8; - pub use utf8::{Buf, Slice}; + pub(crate) use utf8::{Buf, Slice}; } _ => { mod bytes; - pub use bytes::{Buf, Slice}; + pub(crate) use bytes::{Buf, Slice}; } } diff --git a/library/std/src/sys/os_str/utf8.rs b/library/std/src/sys/os_str/utf8.rs index 289f58aa480f7..3648962da5eeb 100644 --- a/library/std/src/sys/os_str/utf8.rs +++ b/library/std/src/sys/os_str/utf8.rs @@ -11,12 +11,12 @@ use crate::{fmt, mem}; #[derive(Hash)] #[repr(transparent)] -pub struct Buf { +pub(crate) struct Buf { pub inner: String, } #[repr(transparent)] -pub struct Slice { +pub(crate) struct Slice { pub inner: str, } diff --git a/library/std/src/sys/os_str/wtf8.rs b/library/std/src/sys/os_str/wtf8.rs index 9a32ab3f3ea12..5f9d64dc5d09c 100644 --- a/library/std/src/sys/os_str/wtf8.rs +++ b/library/std/src/sys/os_str/wtf8.rs @@ -13,12 +13,12 @@ use crate::{fmt, mem}; #[derive(Hash)] #[repr(transparent)] -pub struct Buf { +pub(crate) struct Buf { pub inner: Wtf8Buf, } #[repr(transparent)] -pub struct Slice { +pub(crate) struct Slice { pub inner: Wtf8, }