Skip to content

Commit 0d81d85

Browse files
committed
sys: reduce visibility of some internal OsStr-related types
I’m honestly not entirely sure why this is needed, but if I try to edit the file in subsequent commit without this change I’m getting ‘missing stability attribute’ errors: error: struct has missing stability attribute --> library/std/src/sys/unix/os_str.rs:22:1 | 22 | / pub struct Buf { 23 | | pub inner: Vec<u8>, 24 | | } | |_^
1 parent fdb0aa6 commit 0d81d85

File tree

3 files changed

+11
-11
lines changed

3 files changed

+11
-11
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,12 @@ mod tests;
1919

2020
#[derive(Hash)]
2121
#[repr(transparent)]
22-
pub struct Buf {
22+
pub(crate) struct Buf {
2323
pub inner: Vec<u8>,
2424
}
2525

2626
#[repr(transparent)]
27-
pub struct Slice {
27+
pub(crate) struct Slice {
2828
pub inner: [u8],
2929
}
3030

library/std/src/sys/windows/os_str.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ use crate::sys_common::wtf8::{Wtf8, Wtf8Buf};
1010
use crate::sys_common::{AsInner, FromInner, IntoInner};
1111

1212
#[derive(Clone, Hash)]
13-
pub struct Buf {
13+
pub(crate) struct Buf {
1414
pub inner: Wtf8Buf,
1515
}
1616

@@ -46,7 +46,7 @@ impl fmt::Display for Buf {
4646
}
4747

4848
#[repr(transparent)]
49-
pub struct Slice {
49+
pub(crate) struct Slice {
5050
pub inner: Wtf8,
5151
}
5252

library/std/src/sys_common/wtf8.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ const UTF8_REPLACEMENT_CHARACTER: &str = "\u{FFFD}";
4242
/// which represents a Unicode scalar value:
4343
/// a code point that is not a surrogate (U+D800 to U+DFFF).
4444
#[derive(Eq, PartialEq, Ord, PartialOrd, Clone, Copy)]
45-
pub struct CodePoint {
45+
pub(crate) struct CodePoint {
4646
value: u32,
4747
}
4848

@@ -133,7 +133,7 @@ impl CodePoint {
133133
/// Similar to `String`, but can additionally contain surrogate code points
134134
/// if they’re not in a surrogate pair.
135135
#[derive(Eq, PartialEq, Ord, PartialOrd, Clone)]
136-
pub struct Wtf8Buf {
136+
pub(crate) struct Wtf8Buf {
137137
bytes: Vec<u8>,
138138

139139
/// Do we know that `bytes` holds a valid UTF-8 encoding? We can easily
@@ -496,7 +496,7 @@ impl Extend<CodePoint> for Wtf8Buf {
496496
/// Similar to `&str`, but can additionally contain surrogate code points
497497
/// if they’re not in a surrogate pair.
498498
#[derive(Eq, Ord, PartialEq, PartialOrd)]
499-
pub struct Wtf8 {
499+
pub(crate) struct Wtf8 {
500500
bytes: [u8],
501501
}
502502

@@ -869,7 +869,7 @@ fn decode_surrogate_pair(lead: u16, trail: u16) -> char {
869869

870870
/// Copied from core::str::StrPrelude::is_char_boundary
871871
#[inline]
872-
pub fn is_code_point_boundary(slice: &Wtf8, index: usize) -> bool {
872+
pub(crate) fn is_code_point_boundary(slice: &Wtf8, index: usize) -> bool {
873873
if index == slice.len() {
874874
return true;
875875
}
@@ -881,14 +881,14 @@ pub fn is_code_point_boundary(slice: &Wtf8, index: usize) -> bool {
881881

882882
/// Copied from core::str::raw::slice_unchecked
883883
#[inline]
884-
pub unsafe fn slice_unchecked(s: &Wtf8, begin: usize, end: usize) -> &Wtf8 {
884+
pub(crate) unsafe fn slice_unchecked(s: &Wtf8, begin: usize, end: usize) -> &Wtf8 {
885885
// memory layout of a &[u8] and &Wtf8 are the same
886886
Wtf8::from_bytes_unchecked(slice::from_raw_parts(s.bytes.as_ptr().add(begin), end - begin))
887887
}
888888

889889
/// Copied from core::str::raw::slice_error_fail
890890
#[inline(never)]
891-
pub fn slice_error_fail(s: &Wtf8, begin: usize, end: usize) -> ! {
891+
pub(crate) fn slice_error_fail(s: &Wtf8, begin: usize, end: usize) -> ! {
892892
assert!(begin <= end);
893893
panic!("index {begin} and/or {end} in `{s:?}` do not lie on character boundary");
894894
}
@@ -897,7 +897,7 @@ pub fn slice_error_fail(s: &Wtf8, begin: usize, end: usize) -> ! {
897897
///
898898
/// Created with the method `.code_points()`.
899899
#[derive(Clone)]
900-
pub struct Wtf8CodePoints<'a> {
900+
pub(crate) struct Wtf8CodePoints<'a> {
901901
bytes: slice::Iter<'a, u8>,
902902
}
903903

0 commit comments

Comments
 (0)