Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

std: #![deny(unsafe_op_in_unsafe_fn)] in platform-independent code #127744

Merged
merged 7 commits into from
Jul 15, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
std: Unsafe-wrap OSStr{,ing}::from_encoded_bytes_unchecked
  • Loading branch information
workingjubilee committed Jul 14, 2024
commit ce35265105929ead4a4e8d8c556ee3c00d35bc72
1 change: 0 additions & 1 deletion library/std/src/ffi/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions library/std/src/ffi/os_str.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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]
Expand Down