Skip to content

Commit 3132ff7

Browse files
ehussgitbot
authored and
gitbot
committed
std: Apply unsafe_attr_outside_unsafe
1 parent b7b093a commit 3132ff7

File tree

16 files changed

+28
-28
lines changed

16 files changed

+28
-28
lines changed

std/src/keyword_docs.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -398,7 +398,7 @@ mod enum_keyword {}
398398
/// The mirror use case of FFI is also done via the `extern` keyword:
399399
///
400400
/// ```rust
401-
/// #[no_mangle]
401+
/// #[unsafe(no_mangle)]
402402
/// pub extern "C" fn callable_from_c(x: i32) -> bool {
403403
/// x % 3 == 0
404404
/// }

std/src/sys/alloc/sgx.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ use crate::sys::pal::waitqueue::SpinMutex;
1111
// in the rust-lang/rust repository as a submodule. The crate is a port of
1212
// dlmalloc.c from C to Rust.
1313
#[cfg_attr(test, linkage = "available_externally")]
14-
#[export_name = "_ZN16__rust_internals3std3sys3sgx5alloc8DLMALLOCE"]
14+
#[unsafe(export_name = "_ZN16__rust_internals3std3sys3sgx5alloc8DLMALLOCE")]
1515
static DLMALLOC: SpinMutex<dlmalloc::Dlmalloc<Sgx>> =
1616
SpinMutex::new(dlmalloc::Dlmalloc::new_with_allocator(Sgx {}));
1717

@@ -85,13 +85,13 @@ unsafe impl GlobalAlloc for System {
8585
// The following functions are needed by libunwind. These symbols are named
8686
// in pre-link args for the target specification, so keep that in sync.
8787
#[cfg(not(test))]
88-
#[no_mangle]
88+
#[unsafe(no_mangle)]
8989
pub unsafe extern "C" fn __rust_c_alloc(size: usize, align: usize) -> *mut u8 {
9090
unsafe { crate::alloc::alloc(Layout::from_size_align_unchecked(size, align)) }
9191
}
9292

9393
#[cfg(not(test))]
94-
#[no_mangle]
94+
#[unsafe(no_mangle)]
9595
pub unsafe extern "C" fn __rust_c_dealloc(ptr: *mut u8, size: usize, align: usize) {
9696
unsafe { crate::alloc::dealloc(ptr, Layout::from_size_align_unchecked(size, align)) }
9797
}

std/src/sys/alloc/xous.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
use crate::alloc::{GlobalAlloc, Layout, System};
55

66
#[cfg(not(test))]
7-
#[export_name = "_ZN16__rust_internals3std3sys4xous5alloc8DLMALLOCE"]
7+
#[unsafe(export_name = "_ZN16__rust_internals3std3sys4xous5alloc8DLMALLOCE")]
88
static mut DLMALLOC: dlmalloc::Dlmalloc = dlmalloc::Dlmalloc::new();
99

1010
#[cfg(test)]

std/src/sys/pal/hermit/mod.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ pub fn abort_internal() -> ! {
5353
// This function is needed by the panic runtime. The symbol is named in
5454
// pre-link args for the target specification, so keep that in sync.
5555
#[cfg(not(test))]
56-
#[no_mangle]
56+
#[unsafe(no_mangle)]
5757
// NB. used by both libunwind and libpanic_abort
5858
pub extern "C" fn __rust_abort() {
5959
abort_internal();
@@ -72,7 +72,7 @@ pub unsafe fn init(argc: isize, argv: *const *const u8, _sigpipe: u8) {
7272
pub unsafe fn cleanup() {}
7373

7474
#[cfg(not(test))]
75-
#[no_mangle]
75+
#[unsafe(no_mangle)]
7676
pub unsafe extern "C" fn runtime_entry(
7777
argc: i32,
7878
argv: *const *const c_char,

std/src/sys/pal/sgx/abi/mod.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ global_asm!(include_str!("entry.S"), options(att_syntax));
2323
struct EntryReturn(u64, u64);
2424

2525
#[cfg(not(test))]
26-
#[no_mangle]
26+
#[unsafe(no_mangle)]
2727
unsafe extern "C" fn tcs_init(secondary: bool) {
2828
// Be very careful when changing this code: it runs before the binary has been
2929
// relocated. Any indirect accesses to symbols will likely fail.
@@ -60,7 +60,7 @@ unsafe extern "C" fn tcs_init(secondary: bool) {
6060
// (main function exists). If this is a library, the crate author should be
6161
// able to specify this
6262
#[cfg(not(test))]
63-
#[no_mangle]
63+
#[unsafe(no_mangle)]
6464
extern "C" fn entry(p1: u64, p2: u64, p3: u64, secondary: bool, p4: u64, p5: u64) -> EntryReturn {
6565
// FIXME: how to support TLS in library mode?
6666
let tls = Box::new(tls::Tls::new());
@@ -103,7 +103,7 @@ pub(super) fn exit_with_code(code: isize) -> ! {
103103
}
104104

105105
#[cfg(not(test))]
106-
#[no_mangle]
106+
#[unsafe(no_mangle)]
107107
extern "C" fn abort_reentry() -> ! {
108108
usercalls::exit(false)
109109
}

std/src/sys/pal/sgx/abi/tls/mod.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,14 @@ const TLS_KEYS: usize = 128; // Same as POSIX minimum
1212
const TLS_KEYS_BITSET_SIZE: usize = (TLS_KEYS + (USIZE_BITS - 1)) / USIZE_BITS;
1313

1414
#[cfg_attr(test, linkage = "available_externally")]
15-
#[export_name = "_ZN16__rust_internals3std3sys3sgx3abi3tls14TLS_KEY_IN_USEE"]
15+
#[unsafe(export_name = "_ZN16__rust_internals3std3sys3sgx3abi3tls14TLS_KEY_IN_USEE")]
1616
static TLS_KEY_IN_USE: SyncBitset = SYNC_BITSET_INIT;
1717
macro_rules! dup {
1818
((* $($exp:tt)*) $($val:tt)*) => (dup!( ($($exp)*) $($val)* $($val)* ));
1919
(() $($val:tt)*) => ([$($val),*])
2020
}
2121
#[cfg_attr(test, linkage = "available_externally")]
22-
#[export_name = "_ZN16__rust_internals3std3sys3sgx3abi3tls14TLS_DESTRUCTORE"]
22+
#[unsafe(export_name = "_ZN16__rust_internals3std3sys3sgx3abi3tls14TLS_DESTRUCTORE")]
2323
static TLS_DESTRUCTOR: [AtomicUsize; TLS_KEYS] = dup!((* * * * * * *) (AtomicUsize::new(0)));
2424

2525
unsafe extern "C" {

std/src/sys/pal/sgx/args.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use crate::sys_common::FromInner;
77
use crate::{fmt, slice};
88

99
#[cfg_attr(test, linkage = "available_externally")]
10-
#[export_name = "_ZN16__rust_internals3std3sys3sgx4args4ARGSE"]
10+
#[unsafe(export_name = "_ZN16__rust_internals3std3sys3sgx4args4ARGSE")]
1111
static ARGS: AtomicUsize = AtomicUsize::new(0);
1212
type ArgsStore = Vec<OsString>;
1313

std/src/sys/pal/sgx/libunwind_integration.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ const _: () = unsafe {
1515

1616
const EINVAL: i32 = 22;
1717

18-
#[no_mangle]
18+
#[unsafe(no_mangle)]
1919
pub unsafe extern "C" fn __rust_rwlock_rdlock(p: *mut RwLock) -> i32 {
2020
if p.is_null() {
2121
return EINVAL;
@@ -27,7 +27,7 @@ pub unsafe extern "C" fn __rust_rwlock_rdlock(p: *mut RwLock) -> i32 {
2727
return 0;
2828
}
2929

30-
#[no_mangle]
30+
#[unsafe(no_mangle)]
3131
pub unsafe extern "C" fn __rust_rwlock_wrlock(p: *mut RwLock) -> i32 {
3232
if p.is_null() {
3333
return EINVAL;
@@ -36,7 +36,7 @@ pub unsafe extern "C" fn __rust_rwlock_wrlock(p: *mut RwLock) -> i32 {
3636
return 0;
3737
}
3838

39-
#[no_mangle]
39+
#[unsafe(no_mangle)]
4040
pub unsafe extern "C" fn __rust_rwlock_unlock(p: *mut RwLock) -> i32 {
4141
if p.is_null() {
4242
return EINVAL;

std/src/sys/pal/sgx/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ pub fn abort_internal() -> ! {
123123
// This function is needed by the panic runtime. The symbol is named in
124124
// pre-link args for the target specification, so keep that in sync.
125125
#[cfg(not(test))]
126-
#[no_mangle]
126+
#[unsafe(no_mangle)]
127127
// NB. used by both libunwind and libpanic_abort
128128
pub extern "C" fn __rust_abort() {
129129
abort_internal();

std/src/sys/pal/sgx/os.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -74,10 +74,10 @@ pub fn current_exe() -> io::Result<PathBuf> {
7474
}
7575

7676
#[cfg_attr(test, linkage = "available_externally")]
77-
#[export_name = "_ZN16__rust_internals3std3sys3sgx2os3ENVE"]
77+
#[unsafe(export_name = "_ZN16__rust_internals3std3sys3sgx2os3ENVE")]
7878
static ENV: AtomicUsize = AtomicUsize::new(0);
7979
#[cfg_attr(test, linkage = "available_externally")]
80-
#[export_name = "_ZN16__rust_internals3std3sys3sgx2os8ENV_INITE"]
80+
#[unsafe(export_name = "_ZN16__rust_internals3std3sys3sgx2os8ENV_INITE")]
8181
static ENV_INIT: Once = Once::new();
8282
type EnvStore = Mutex<HashMap<OsString, OsString>>;
8383

std/src/sys/pal/sgx/stdio.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ pub fn panic_output() -> Option<impl io::Write> {
7676
// This function is needed by libunwind. The symbol is named in pre-link args
7777
// for the target specification, so keep that in sync.
7878
#[cfg(not(test))]
79-
#[no_mangle]
79+
#[unsafe(no_mangle)]
8080
pub unsafe extern "C" fn __rust_print_err(m: *mut u8, s: i32) {
8181
if s < 0 {
8282
return;

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ mod task_queue {
4646
}
4747

4848
#[cfg_attr(test, linkage = "available_externally")]
49-
#[export_name = "_ZN16__rust_internals3std3sys3sgx6thread10TASK_QUEUEE"]
49+
#[unsafe(export_name = "_ZN16__rust_internals3std3sys3sgx6thread10TASK_QUEUEE")]
5050
static TASK_QUEUE: Mutex<Vec<Task>> = Mutex::new(Vec::new());
5151

5252
pub(super) fn lock() -> MutexGuard<'static, Vec<Task>> {

std/src/sys/pal/uefi/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ pub fn abort_internal() -> ! {
169169
// This function is needed by the panic runtime. The symbol is named in
170170
// pre-link args for the target specification, so keep that in sync.
171171
#[cfg(not(test))]
172-
#[no_mangle]
172+
#[unsafe(no_mangle)]
173173
pub extern "C" fn __rust_abort() {
174174
abort_internal();
175175
}

std/src/sys/pal/wasip2/cabi_realloc.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ static FORCE_CODEGEN_OF_CABI_REALLOC: unsafe extern "C" fn(
3232
) -> *mut u8 = cabi_realloc;
3333

3434
#[linkage = "weak"]
35-
#[no_mangle]
35+
#[unsafe(no_mangle)]
3636
pub unsafe extern "C" fn cabi_realloc(
3737
old_ptr: *mut u8,
3838
old_len: usize,

std/src/sys/pal/xous/os.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -41,12 +41,12 @@ mod c_compat {
4141
fn main() -> u32;
4242
}
4343

44-
#[no_mangle]
44+
#[unsafe(no_mangle)]
4545
pub extern "C" fn abort() {
4646
exit(1);
4747
}
4848

49-
#[no_mangle]
49+
#[unsafe(no_mangle)]
5050
pub extern "C" fn _start(eh_frame: usize, params_address: usize) {
5151
#[cfg(feature = "panic_unwind")]
5252
{
@@ -67,7 +67,7 @@ mod c_compat {
6767

6868
// This function is needed by the panic runtime. The symbol is named in
6969
// pre-link args for the target specification, so keep that in sync.
70-
#[no_mangle]
70+
#[unsafe(no_mangle)]
7171
// NB. used by both libunwind and libpanic_abort
7272
pub extern "C" fn __rust_abort() -> ! {
7373
exit(101);

std/src/sys/thread_local/key/xous.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -51,11 +51,11 @@ const TLS_MEMORY_SIZE: usize = 4096;
5151

5252
/// TLS keys start at `1`. Index `0` is unused
5353
#[cfg(not(test))]
54-
#[export_name = "_ZN16__rust_internals3std3sys4xous16thread_local_key13TLS_KEY_INDEXE"]
54+
#[unsafe(export_name = "_ZN16__rust_internals3std3sys4xous16thread_local_key13TLS_KEY_INDEXE")]
5555
static TLS_KEY_INDEX: AtomicUsize = AtomicUsize::new(1);
5656

5757
#[cfg(not(test))]
58-
#[export_name = "_ZN16__rust_internals3std3sys4xous16thread_local_key9DTORSE"]
58+
#[unsafe(export_name = "_ZN16__rust_internals3std3sys4xous16thread_local_key9DTORSE")]
5959
static DTORS: AtomicPtr<Node> = AtomicPtr::new(ptr::null_mut());
6060

6161
#[cfg(test)]

0 commit comments

Comments
 (0)