about summary refs log tree commit diff
diff options
context:
space:
mode:
authorJubilee Young <workingjubilee@gmail.com>2024-07-14 16:59:12 -0700
committerJubilee Young <workingjubilee@gmail.com>2024-07-14 16:59:12 -0700
commitce35265105929ead4a4e8d8c556ee3c00d35bc72 (patch)
treec7c048707c0a5399e6aba7fb507d07c0b6820b57
parent87d850dff053fb622e56ec0c865a8462d379e649 (diff)
downloadrust-ce35265105929ead4a4e8d8c556ee3c00d35bc72.tar.gz
rust-ce35265105929ead4a4e8d8c556ee3c00d35bc72.zip
std: Unsafe-wrap OSStr{,ing}::from_encoded_bytes_unchecked
-rw-r--r--library/std/src/ffi/mod.rs1
-rw-r--r--library/std/src/ffi/os_str.rs4
2 files changed, 2 insertions, 3 deletions
diff --git a/library/std/src/ffi/mod.rs b/library/std/src/ffi/mod.rs
index bb64f07844b..f45fd77e8b1 100644
--- a/library/std/src/ffi/mod.rs
+++ b/library/std/src/ffi/mod.rs
@@ -160,7 +160,6 @@
 //! [`from_wide`]: crate::os::windows::ffi::OsStringExt::from_wide "os::windows::ffi::OsStringExt::from_wide"
 
 #![stable(feature = "rust1", since = "1.0.0")]
-#![allow(unsafe_op_in_unsafe_fn)]
 
 #[unstable(feature = "c_str_module", issue = "112134")]
 pub mod c_str;
diff --git a/library/std/src/ffi/os_str.rs b/library/std/src/ffi/os_str.rs
index 4a417c84a30..f9dba08da4c 100644
--- a/library/std/src/ffi/os_str.rs
+++ b/library/std/src/ffi/os_str.rs
@@ -184,7 +184,7 @@ impl OsString {
     #[inline]
     #[stable(feature = "os_str_bytes", since = "1.74.0")]
     pub unsafe fn from_encoded_bytes_unchecked(bytes: Vec<u8>) -> Self {
-        OsString { inner: Buf::from_encoded_bytes_unchecked(bytes) }
+        OsString { inner: unsafe { Buf::from_encoded_bytes_unchecked(bytes) } }
     }
 
     /// Converts to an [`OsStr`] slice.
@@ -813,7 +813,7 @@ impl OsStr {
     #[inline]
     #[stable(feature = "os_str_bytes", since = "1.74.0")]
     pub unsafe fn from_encoded_bytes_unchecked(bytes: &[u8]) -> &Self {
-        Self::from_inner(Slice::from_encoded_bytes_unchecked(bytes))
+        Self::from_inner(unsafe { Slice::from_encoded_bytes_unchecked(bytes) })
     }
 
     #[inline]