Skip to content

Commit 335d4d4

Browse files
authored
Unrolled build for rust-lang#128432
Rollup merge of rust-lang#128432 - g0djan:godjan/wasi_prohibit_implicit_unsafe, r=tgross35 WASI: forbid `unsafe_op_in_unsafe_fn` for `std::{os, sys}` Part of rust-lang#127747 for WASI try-job: test-various
2 parents 739b1fd + 8a61674 commit 335d4d4

File tree

14 files changed

+24
-18
lines changed

14 files changed

+24
-18
lines changed

library/std/src/os/wasi/fs.rs

-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
//!
33
//! [`std::fs`]: crate::fs
44
5-
#![deny(unsafe_op_in_unsafe_fn)]
65
#![unstable(feature = "wasi_ext", issue = "71213")]
76

87
// Used for `File::read` on intra-doc links

library/std/src/os/wasi/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
3131
#![cfg_attr(not(target_env = "p2"), stable(feature = "rust1", since = "1.0.0"))]
3232
#![cfg_attr(target_env = "p2", unstable(feature = "wasip2", issue = "none"))]
33-
#![deny(unsafe_op_in_unsafe_fn)]
33+
#![forbid(unsafe_op_in_unsafe_fn)]
3434
#![doc(cfg(target_os = "wasi"))]
3535

3636
pub mod ffi;

library/std/src/os/wasip2/mod.rs

+1
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,5 @@
22
//!
33
//! This module is currently empty, but will be filled over time as wasi-libc support for WASI Preview 2 is stabilized.
44
5+
#![forbid(unsafe_op_in_unsafe_fn)]
56
#![stable(feature = "raw_ext", since = "1.1.0")]

library/std/src/sys/pal/wasi/args.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#![deny(unsafe_op_in_unsafe_fn)]
1+
#![forbid(unsafe_op_in_unsafe_fn)]
22

33
use crate::ffi::{CStr, OsStr, OsString};
44
use crate::os::wasi::ffi::OsStrExt;

library/std/src/sys/pal/wasi/env.rs

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#![forbid(unsafe_op_in_unsafe_fn)]
2+
13
pub mod os {
24
pub const FAMILY: &str = "";
35
pub const OS: &str = "";

library/std/src/sys/pal/wasi/fd.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#![deny(unsafe_op_in_unsafe_fn)]
1+
#![forbid(unsafe_op_in_unsafe_fn)]
22
#![allow(dead_code)]
33

44
use super::err2io;

library/std/src/sys/pal/wasi/fs.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#![deny(unsafe_op_in_unsafe_fn)]
1+
#![forbid(unsafe_op_in_unsafe_fn)]
22

33
use super::fd::WasiFd;
44
use crate::ffi::{CStr, OsStr, OsString};

library/std/src/sys/pal/wasi/helpers.rs

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#![forbid(unsafe_op_in_unsafe_fn)]
2+
13
use crate::{io as std_io, mem};
24

35
#[inline]

library/std/src/sys/pal/wasi/io.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#![deny(unsafe_op_in_unsafe_fn)]
1+
#![forbid(unsafe_op_in_unsafe_fn)]
22

33
use crate::marker::PhantomData;
44
use crate::os::fd::{AsFd, AsRawFd};

library/std/src/sys/pal/wasi/net.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#![deny(unsafe_op_in_unsafe_fn)]
1+
#![forbid(unsafe_op_in_unsafe_fn)]
22

33
use super::err2io;
44
use super::fd::WasiFd;

library/std/src/sys/pal/wasi/os.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#![deny(unsafe_op_in_unsafe_fn)]
1+
#![forbid(unsafe_op_in_unsafe_fn)]
22

33
use core::slice::memchr;
44

library/std/src/sys/pal/wasi/stdio.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#![deny(unsafe_op_in_unsafe_fn)]
1+
#![forbid(unsafe_op_in_unsafe_fn)]
22

33
use super::fd::WasiFd;
44
use crate::io::{self, IoSlice, IoSliceMut};

library/std/src/sys/pal/wasi/thread.rs

+10-8
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#![forbid(unsafe_op_in_unsafe_fn)]
2+
13
use crate::ffi::CStr;
24
use crate::num::NonZero;
35
use crate::sys::unsupported;
@@ -73,13 +75,13 @@ impl Thread {
7375
if #[cfg(target_feature = "atomics")] {
7476
pub unsafe fn new(stack: usize, p: Box<dyn FnOnce()>) -> io::Result<Thread> {
7577
let p = Box::into_raw(Box::new(p));
76-
let mut native: libc::pthread_t = mem::zeroed();
77-
let mut attr: libc::pthread_attr_t = mem::zeroed();
78-
assert_eq!(libc::pthread_attr_init(&mut attr), 0);
78+
let mut native: libc::pthread_t = unsafe { mem::zeroed() };
79+
let mut attr: libc::pthread_attr_t = unsafe { mem::zeroed() };
80+
assert_eq!(unsafe { libc::pthread_attr_init(&mut attr) }, 0);
7981

8082
let stack_size = cmp::max(stack, DEFAULT_MIN_STACK_SIZE);
8183

82-
match libc::pthread_attr_setstacksize(&mut attr, stack_size) {
84+
match unsafe { libc::pthread_attr_setstacksize(&mut attr, stack_size) } {
8385
0 => {}
8486
n => {
8587
assert_eq!(n, libc::EINVAL);
@@ -90,20 +92,20 @@ impl Thread {
9092
let page_size = os::page_size();
9193
let stack_size =
9294
(stack_size + page_size - 1) & (-(page_size as isize - 1) as usize - 1);
93-
assert_eq!(libc::pthread_attr_setstacksize(&mut attr, stack_size), 0);
95+
assert_eq!(unsafe { libc::pthread_attr_setstacksize(&mut attr, stack_size) }, 0);
9496
}
9597
};
9698

97-
let ret = libc::pthread_create(&mut native, &attr, thread_start, p as *mut _);
99+
let ret = unsafe { libc::pthread_create(&mut native, &attr, thread_start, p as *mut _) };
98100
// Note: if the thread creation fails and this assert fails, then p will
99101
// be leaked. However, an alternative design could cause double-free
100102
// which is clearly worse.
101-
assert_eq!(libc::pthread_attr_destroy(&mut attr), 0);
103+
assert_eq!(unsafe {libc::pthread_attr_destroy(&mut attr) }, 0);
102104

103105
return if ret != 0 {
104106
// The thread failed to start and as a result p was not consumed. Therefore, it is
105107
// safe to reconstruct the box so that it gets deallocated.
106-
drop(Box::from_raw(p));
108+
unsafe { drop(Box::from_raw(p)); }
107109
Err(io::Error::from_raw_os_error(ret))
108110
} else {
109111
Ok(Thread { id: native })

library/std/src/sys/pal/wasi/time.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#![deny(unsafe_op_in_unsafe_fn)]
1+
#![forbid(unsafe_op_in_unsafe_fn)]
22

33
use crate::time::Duration;
44

0 commit comments

Comments
 (0)