Rollup merge of #123967 - RalfJung:static_mut_refs, r=Nilstrieb
static_mut_refs: use raw pointers to remove the remaining FIXME Using `SyncUnsafeCell` would not make a lot of sense IMO.
This commit is contained in:
commit
ccd9880769
@ -1,4 +1,13 @@
|
|||||||
#![feature(no_core, lang_items, never_type, linkage, extern_types, thread_local, repr_simd)]
|
#![feature(
|
||||||
|
no_core,
|
||||||
|
lang_items,
|
||||||
|
never_type,
|
||||||
|
linkage,
|
||||||
|
extern_types,
|
||||||
|
thread_local,
|
||||||
|
repr_simd,
|
||||||
|
raw_ref_op
|
||||||
|
)]
|
||||||
#![no_core]
|
#![no_core]
|
||||||
#![allow(dead_code, non_camel_case_types, internal_features)]
|
#![allow(dead_code, non_camel_case_types, internal_features)]
|
||||||
|
|
||||||
@ -112,9 +121,7 @@ fn start<T: Termination + 'static>(
|
|||||||
|
|
||||||
static mut NUM: u8 = 6 * 7;
|
static mut NUM: u8 = 6 * 7;
|
||||||
|
|
||||||
// FIXME: Use `SyncUnsafeCell` instead of allowing `static_mut_refs` lint
|
static NUM_REF: &'static u8 = unsafe { &*&raw const NUM };
|
||||||
#[allow(static_mut_refs)]
|
|
||||||
static NUM_REF: &'static u8 = unsafe { &NUM };
|
|
||||||
|
|
||||||
unsafe fn zeroed<T>() -> T {
|
unsafe fn zeroed<T>() -> T {
|
||||||
let mut uninit = MaybeUninit { uninit: () };
|
let mut uninit = MaybeUninit { uninit: () };
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
#![feature(
|
#![feature(
|
||||||
no_core, unboxed_closures, start, lang_items, never_type, linkage,
|
no_core, unboxed_closures, start, lang_items, never_type, linkage,
|
||||||
extern_types, thread_local
|
extern_types, thread_local, raw_ref_op
|
||||||
)]
|
)]
|
||||||
#![no_core]
|
#![no_core]
|
||||||
#![allow(dead_code, internal_features, non_camel_case_types)]
|
#![allow(dead_code, internal_features, non_camel_case_types)]
|
||||||
@ -99,9 +99,7 @@ fn start<T: Termination + 'static>(
|
|||||||
|
|
||||||
static mut NUM: u8 = 6 * 7;
|
static mut NUM: u8 = 6 * 7;
|
||||||
|
|
||||||
// FIXME: Use `SyncUnsafeCell` instead of allowing `static_mut_refs` lint
|
static NUM_REF: &'static u8 = unsafe { &* &raw const NUM };
|
||||||
#[allow(static_mut_refs)]
|
|
||||||
static NUM_REF: &'static u8 = unsafe { &NUM };
|
|
||||||
|
|
||||||
macro_rules! assert {
|
macro_rules! assert {
|
||||||
($e:expr) => {
|
($e:expr) => {
|
||||||
|
@ -11,8 +11,6 @@ pub macro thread_local_inner {
|
|||||||
(@key $t:ty, const $init:expr) => {{
|
(@key $t:ty, const $init:expr) => {{
|
||||||
#[inline] // see comments below
|
#[inline] // see comments below
|
||||||
#[deny(unsafe_op_in_unsafe_fn)]
|
#[deny(unsafe_op_in_unsafe_fn)]
|
||||||
// FIXME: Use `SyncUnsafeCell` instead of allowing `static_mut_refs` lint
|
|
||||||
#[allow(static_mut_refs)]
|
|
||||||
unsafe fn __getit(
|
unsafe fn __getit(
|
||||||
_init: $crate::option::Option<&mut $crate::option::Option<$t>>,
|
_init: $crate::option::Option<&mut $crate::option::Option<$t>>,
|
||||||
) -> $crate::option::Option<&'static $t> {
|
) -> $crate::option::Option<&'static $t> {
|
||||||
@ -25,7 +23,8 @@ pub macro thread_local_inner {
|
|||||||
// FIXME(#84224) this should come after the `target_thread_local`
|
// FIXME(#84224) this should come after the `target_thread_local`
|
||||||
// block.
|
// block.
|
||||||
static mut VAL: $t = INIT_EXPR;
|
static mut VAL: $t = INIT_EXPR;
|
||||||
unsafe { $crate::option::Option::Some(&VAL) }
|
// SAFETY: we only ever create shared references, so there's no mutable aliasing.
|
||||||
|
unsafe { $crate::option::Option::Some(&*$crate::ptr::addr_of!(VAL)) }
|
||||||
}
|
}
|
||||||
|
|
||||||
unsafe {
|
unsafe {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user