Skip to content

Commit 57937d7

Browse files
committed
allow(unsafe_op_in_unsafe_fn) on some functions
These need to get their safety story straight
1 parent 94b381d commit 57937d7

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

std/src/sys/pal/windows/pipe.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
#![allow(unsafe_op_in_unsafe_fn)]
21
use crate::os::windows::prelude::*;
32

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

564+
#[allow(unsafe_op_in_unsafe_fn)]
564565
unsafe fn slice_to_end(v: &mut Vec<u8>) -> &mut [u8] {
565566
if v.capacity() == 0 {
566567
v.reserve(16);
567568
}
568569
if v.capacity() == v.len() {
569570
v.reserve(1);
570571
}
572+
// FIXME: Isn't this just spare_capacity_mut but worse?
571573
slice::from_raw_parts_mut(v.as_mut_ptr().add(v.len()), v.capacity() - v.len())
572574
}

std/src/sys/pal/windows/thread.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
#![allow(unsafe_op_in_unsafe_fn)]
21
use crate::ffi::CStr;
32
use crate::io;
43
use crate::num::NonZero;
@@ -23,6 +22,8 @@ pub struct Thread {
2322

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

@@ -70,7 +71,7 @@ impl Thread {
7071
///
7172
/// `name` must end with a zero value
7273
pub unsafe fn set_name_wide(name: &[u16]) {
73-
c::SetThreadDescription(c::GetCurrentThread(), name.as_ptr());
74+
unsafe { c::SetThreadDescription(c::GetCurrentThread(), name.as_ptr()) };
7475
}
7576

7677
pub fn join(self) {

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy