Skip to content

Commit

Permalink
allow(unsafe_op_in_unsafe_fn) on some functions
Browse files Browse the repository at this point in the history
These need to get their safety story straight
  • Loading branch information
ChrisDenton committed Jul 15, 2024
1 parent 94b381d commit 57937d7
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
4 changes: 3 additions & 1 deletion std/src/sys/pal/windows/pipe.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#![allow(unsafe_op_in_unsafe_fn)]
use crate::os::windows::prelude::*;

use crate::ffi::OsStr;
Expand Down Expand Up @@ -325,6 +324,7 @@ impl AnonPipe {
/// [`ReadFileEx`]: https://docs.microsoft.com/en-us/windows/win32/api/fileapi/nf-fileapi-readfileex
/// [`WriteFileEx`]: https://docs.microsoft.com/en-us/windows/win32/api/fileapi/nf-fileapi-writefileex
/// [Asynchronous Procedure Call]: https://docs.microsoft.com/en-us/windows/win32/sync/asynchronous-procedure-calls
#[allow(unsafe_op_in_unsafe_fn)]
unsafe fn alertable_io_internal(
&self,
io: AlertableIoFn,
Expand Down Expand Up @@ -561,12 +561,14 @@ impl<'a> Drop for AsyncPipe<'a> {
}
}

#[allow(unsafe_op_in_unsafe_fn)]
unsafe fn slice_to_end(v: &mut Vec<u8>) -> &mut [u8] {
if v.capacity() == 0 {
v.reserve(16);
}
if v.capacity() == v.len() {
v.reserve(1);
}
// FIXME: Isn't this just spare_capacity_mut but worse?
slice::from_raw_parts_mut(v.as_mut_ptr().add(v.len()), v.capacity() - v.len())
}
5 changes: 3 additions & 2 deletions std/src/sys/pal/windows/thread.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#![allow(unsafe_op_in_unsafe_fn)]
use crate::ffi::CStr;
use crate::io;
use crate::num::NonZero;
Expand All @@ -23,6 +22,8 @@ pub struct Thread {

impl Thread {
// unsafe: see thread::Builder::spawn_unchecked for safety requirements
#[allow(unsafe_op_in_unsafe_fn)]
// FIXME: check the internal safety
pub unsafe fn new(stack: usize, p: Box<dyn FnOnce()>) -> io::Result<Thread> {
let p = Box::into_raw(Box::new(p));

Expand Down Expand Up @@ -70,7 +71,7 @@ impl Thread {
///
/// `name` must end with a zero value
pub unsafe fn set_name_wide(name: &[u16]) {
c::SetThreadDescription(c::GetCurrentThread(), name.as_ptr());
unsafe { c::SetThreadDescription(c::GetCurrentThread(), name.as_ptr()) };
}

pub fn join(self) {
Expand Down

0 comments on commit 57937d7

Please sign in to comment.