Skip to content

Commit 8c75111

Browse files
std: Unsafe-wrap OSStr{,ing}::from_encoded_bytes_unchecked
1 parent 4679f9a commit 8c75111

File tree

2 files changed

+2
-3
lines changed

2 files changed

+2
-3
lines changed

std/src/ffi/mod.rs

-1
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,6 @@
160160
//! [`from_wide`]: crate::os::windows::ffi::OsStringExt::from_wide "os::windows::ffi::OsStringExt::from_wide"
161161
162162
#![stable(feature = "rust1", since = "1.0.0")]
163-
#![allow(unsafe_op_in_unsafe_fn)]
164163

165164
#[unstable(feature = "c_str_module", issue = "112134")]
166165
pub mod c_str;

std/src/ffi/os_str.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ impl OsString {
184184
#[inline]
185185
#[stable(feature = "os_str_bytes", since = "1.74.0")]
186186
pub unsafe fn from_encoded_bytes_unchecked(bytes: Vec<u8>) -> Self {
187-
OsString { inner: Buf::from_encoded_bytes_unchecked(bytes) }
187+
OsString { inner: unsafe { Buf::from_encoded_bytes_unchecked(bytes) } }
188188
}
189189

190190
/// Converts to an [`OsStr`] slice.
@@ -813,7 +813,7 @@ impl OsStr {
813813
#[inline]
814814
#[stable(feature = "os_str_bytes", since = "1.74.0")]
815815
pub unsafe fn from_encoded_bytes_unchecked(bytes: &[u8]) -> &Self {
816-
Self::from_inner(Slice::from_encoded_bytes_unchecked(bytes))
816+
Self::from_inner(unsafe { Slice::from_encoded_bytes_unchecked(bytes) })
817817
}
818818

819819
#[inline]

0 commit comments

Comments
 (0)