Replace deprecated ATOMIC_INIT consts
This commit is contained in:
parent
abe36c4741
commit
7a58c6d1de
27 changed files with 89 additions and 59 deletions
|
@ -2,7 +2,7 @@ use std::cmp;
|
||||||
use std::collections::BinaryHeap;
|
use std::collections::BinaryHeap;
|
||||||
use std::collections::binary_heap::{Drain, PeekMut};
|
use std::collections::binary_heap::{Drain, PeekMut};
|
||||||
use std::panic::{self, AssertUnwindSafe};
|
use std::panic::{self, AssertUnwindSafe};
|
||||||
use std::sync::atomic::{AtomicUsize, ATOMIC_USIZE_INIT, Ordering};
|
use std::sync::atomic::{AtomicUsize, Ordering};
|
||||||
|
|
||||||
use rand::{thread_rng, seq::SliceRandom};
|
use rand::{thread_rng, seq::SliceRandom};
|
||||||
|
|
||||||
|
@ -283,7 +283,7 @@ fn assert_covariance() {
|
||||||
// Destructors must be called exactly once per element.
|
// Destructors must be called exactly once per element.
|
||||||
#[test]
|
#[test]
|
||||||
fn panic_safe() {
|
fn panic_safe() {
|
||||||
static DROP_COUNTER: AtomicUsize = ATOMIC_USIZE_INIT;
|
static DROP_COUNTER: AtomicUsize = AtomicUsize::new(0);
|
||||||
|
|
||||||
#[derive(Eq, PartialEq, Ord, Clone, Debug)]
|
#[derive(Eq, PartialEq, Ord, Clone, Debug)]
|
||||||
struct PanicOrd<T>(T, bool);
|
struct PanicOrd<T>(T, bool);
|
||||||
|
|
|
@ -5,7 +5,7 @@ use std::mem;
|
||||||
use std::panic;
|
use std::panic;
|
||||||
use std::rc::Rc;
|
use std::rc::Rc;
|
||||||
use std::sync::atomic::Ordering::Relaxed;
|
use std::sync::atomic::Ordering::Relaxed;
|
||||||
use std::sync::atomic::{ATOMIC_USIZE_INIT, AtomicUsize};
|
use std::sync::atomic::AtomicUsize;
|
||||||
use std::thread;
|
use std::thread;
|
||||||
|
|
||||||
use rand::{Rng, RngCore, thread_rng, seq::SliceRandom};
|
use rand::{Rng, RngCore, thread_rng, seq::SliceRandom};
|
||||||
|
@ -1500,7 +1500,7 @@ static DROP_COUNTS: [AtomicUsize; MAX_LEN] = [
|
||||||
AtomicUsize::new(0), AtomicUsize::new(0), AtomicUsize::new(0), AtomicUsize::new(0),
|
AtomicUsize::new(0), AtomicUsize::new(0), AtomicUsize::new(0), AtomicUsize::new(0),
|
||||||
];
|
];
|
||||||
|
|
||||||
static VERSIONS: AtomicUsize = ATOMIC_USIZE_INIT;
|
static VERSIONS: AtomicUsize = AtomicUsize::new(0);
|
||||||
|
|
||||||
#[derive(Clone, Eq)]
|
#[derive(Clone, Eq)]
|
||||||
struct DropCounter {
|
struct DropCounter {
|
||||||
|
|
|
@ -2413,12 +2413,11 @@ pub fn fence(order: Ordering) {
|
||||||
///
|
///
|
||||||
/// ```
|
/// ```
|
||||||
/// use std::sync::atomic::{AtomicBool, AtomicUsize};
|
/// use std::sync::atomic::{AtomicBool, AtomicUsize};
|
||||||
/// use std::sync::atomic::{ATOMIC_BOOL_INIT, ATOMIC_USIZE_INIT};
|
|
||||||
/// use std::sync::atomic::Ordering;
|
/// use std::sync::atomic::Ordering;
|
||||||
/// use std::sync::atomic::compiler_fence;
|
/// use std::sync::atomic::compiler_fence;
|
||||||
///
|
///
|
||||||
/// static IMPORTANT_VARIABLE: AtomicUsize = ATOMIC_USIZE_INIT;
|
/// static IMPORTANT_VARIABLE: AtomicUsize = AtomicUsize::new(0);
|
||||||
/// static IS_READY: AtomicBool = ATOMIC_BOOL_INIT;
|
/// static IS_READY: AtomicBool = AtomicBool::new(false);
|
||||||
///
|
///
|
||||||
/// fn main() {
|
/// fn main() {
|
||||||
/// IMPORTANT_VARIABLE.store(42, Ordering::Relaxed);
|
/// IMPORTANT_VARIABLE.store(42, Ordering::Relaxed);
|
||||||
|
|
|
@ -91,7 +91,7 @@ use std::panic;
|
||||||
use std::path::{PathBuf, Path};
|
use std::path::{PathBuf, Path};
|
||||||
use std::process::{self, Command, Stdio};
|
use std::process::{self, Command, Stdio};
|
||||||
use std::str;
|
use std::str;
|
||||||
use std::sync::atomic::{AtomicBool, ATOMIC_BOOL_INIT, Ordering};
|
use std::sync::atomic::{AtomicBool, Ordering};
|
||||||
use std::sync::{Once, ONCE_INIT};
|
use std::sync::{Once, ONCE_INIT};
|
||||||
use std::thread;
|
use std::thread;
|
||||||
|
|
||||||
|
@ -254,7 +254,7 @@ fn get_codegen_sysroot(backend_name: &str) -> fn() -> Box<dyn CodegenBackend> {
|
||||||
// general this assertion never trips due to the once guard in `get_codegen_backend`,
|
// general this assertion never trips due to the once guard in `get_codegen_backend`,
|
||||||
// but there's a few manual calls to this function in this file we protect
|
// but there's a few manual calls to this function in this file we protect
|
||||||
// against.
|
// against.
|
||||||
static LOADED: AtomicBool = ATOMIC_BOOL_INIT;
|
static LOADED: AtomicBool = AtomicBool::new(false);
|
||||||
assert!(!LOADED.fetch_or(true, Ordering::SeqCst),
|
assert!(!LOADED.fetch_or(true, Ordering::SeqCst),
|
||||||
"cannot load the default codegen backend twice");
|
"cannot load the default codegen backend twice");
|
||||||
|
|
||||||
|
|
|
@ -1127,9 +1127,9 @@ A borrow of a constant containing interior mutability was attempted. Erroneous
|
||||||
code example:
|
code example:
|
||||||
|
|
||||||
```compile_fail,E0492
|
```compile_fail,E0492
|
||||||
use std::sync::atomic::{AtomicUsize, ATOMIC_USIZE_INIT};
|
use std::sync::atomic::AtomicUsize;
|
||||||
|
|
||||||
const A: AtomicUsize = ATOMIC_USIZE_INIT;
|
const A: AtomicUsize = AtomicUsize::new(0);
|
||||||
static B: &'static AtomicUsize = &A;
|
static B: &'static AtomicUsize = &A;
|
||||||
// error: cannot borrow a constant which may contain interior mutability,
|
// error: cannot borrow a constant which may contain interior mutability,
|
||||||
// create a static instead
|
// create a static instead
|
||||||
|
@ -1145,9 +1145,9 @@ explicitly a single memory location, which can be mutated at will.
|
||||||
So, in order to solve this error, either use statics which are `Sync`:
|
So, in order to solve this error, either use statics which are `Sync`:
|
||||||
|
|
||||||
```
|
```
|
||||||
use std::sync::atomic::{AtomicUsize, ATOMIC_USIZE_INIT};
|
use std::sync::atomic::AtomicUsize;
|
||||||
|
|
||||||
static A: AtomicUsize = ATOMIC_USIZE_INIT;
|
static A: AtomicUsize = AtomicUsize::new(0);
|
||||||
static B: &'static AtomicUsize = &A; // ok!
|
static B: &'static AtomicUsize = &A; // ok!
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
|
@ -95,11 +95,11 @@ pub use alloc_crate::alloc::*;
|
||||||
///
|
///
|
||||||
/// ```rust
|
/// ```rust
|
||||||
/// use std::alloc::{System, GlobalAlloc, Layout};
|
/// use std::alloc::{System, GlobalAlloc, Layout};
|
||||||
/// use std::sync::atomic::{AtomicUsize, ATOMIC_USIZE_INIT, Ordering::SeqCst};
|
/// use std::sync::atomic::{AtomicUsize, Ordering::SeqCst};
|
||||||
///
|
///
|
||||||
/// struct Counter;
|
/// struct Counter;
|
||||||
///
|
///
|
||||||
/// static ALLOCATED: AtomicUsize = ATOMIC_USIZE_INIT;
|
/// static ALLOCATED: AtomicUsize = AtomicUsize::new(0);
|
||||||
///
|
///
|
||||||
/// unsafe impl GlobalAlloc for Counter {
|
/// unsafe impl GlobalAlloc for Counter {
|
||||||
/// unsafe fn alloc(&self, layout: Layout) -> *mut u8 {
|
/// unsafe fn alloc(&self, layout: Layout) -> *mut u8 {
|
||||||
|
|
|
@ -2,13 +2,13 @@
|
||||||
|
|
||||||
use collections::BTreeMap;
|
use collections::BTreeMap;
|
||||||
use ptr;
|
use ptr;
|
||||||
use sync::atomic::{AtomicUsize, ATOMIC_USIZE_INIT, Ordering};
|
use sync::atomic::{AtomicUsize, Ordering};
|
||||||
|
|
||||||
pub type Key = usize;
|
pub type Key = usize;
|
||||||
|
|
||||||
type Dtor = unsafe extern fn(*mut u8);
|
type Dtor = unsafe extern fn(*mut u8);
|
||||||
|
|
||||||
static NEXT_KEY: AtomicUsize = ATOMIC_USIZE_INIT;
|
static NEXT_KEY: AtomicUsize = AtomicUsize::new(0);
|
||||||
|
|
||||||
static mut KEYS: *mut BTreeMap<Key, Option<Dtor>> = ptr::null_mut();
|
static mut KEYS: *mut BTreeMap<Key, Option<Dtor>> = ptr::null_mut();
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
use sync::atomic::{AtomicUsize, ATOMIC_USIZE_INIT, Ordering};
|
use sync::atomic::{AtomicUsize, Ordering};
|
||||||
use ptr;
|
use ptr;
|
||||||
use mem;
|
use mem;
|
||||||
use cell::Cell;
|
use cell::Cell;
|
||||||
|
@ -15,7 +15,40 @@ macro_rules! dup {
|
||||||
((* $($exp:tt)*) $($val:tt)*) => (dup!( ($($exp)*) $($val)* $($val)* ));
|
((* $($exp:tt)*) $($val:tt)*) => (dup!( ($($exp)*) $($val)* $($val)* ));
|
||||||
(() $($val:tt)*) => ([$($val),*])
|
(() $($val:tt)*) => ([$($val),*])
|
||||||
}
|
}
|
||||||
static TLS_DESTRUCTOR: [AtomicUsize; TLS_KEYS] = dup!((* * * * * * *) ATOMIC_USIZE_INIT);
|
static TLS_DESTRUCTOR: [AtomicUsize; TLS_KEYS] = [
|
||||||
|
AtomicUsize::new(0), AtomicUsize::new(0), AtomicUsize::new(0), AtomicUsize::new(0),
|
||||||
|
AtomicUsize::new(0), AtomicUsize::new(0), AtomicUsize::new(0), AtomicUsize::new(0),
|
||||||
|
AtomicUsize::new(0), AtomicUsize::new(0), AtomicUsize::new(0), AtomicUsize::new(0),
|
||||||
|
AtomicUsize::new(0), AtomicUsize::new(0), AtomicUsize::new(0), AtomicUsize::new(0),
|
||||||
|
AtomicUsize::new(0), AtomicUsize::new(0), AtomicUsize::new(0), AtomicUsize::new(0),
|
||||||
|
AtomicUsize::new(0), AtomicUsize::new(0), AtomicUsize::new(0), AtomicUsize::new(0),
|
||||||
|
AtomicUsize::new(0), AtomicUsize::new(0), AtomicUsize::new(0), AtomicUsize::new(0),
|
||||||
|
AtomicUsize::new(0), AtomicUsize::new(0), AtomicUsize::new(0), AtomicUsize::new(0),
|
||||||
|
AtomicUsize::new(0), AtomicUsize::new(0), AtomicUsize::new(0), AtomicUsize::new(0),
|
||||||
|
AtomicUsize::new(0), AtomicUsize::new(0), AtomicUsize::new(0), AtomicUsize::new(0),
|
||||||
|
AtomicUsize::new(0), AtomicUsize::new(0), AtomicUsize::new(0), AtomicUsize::new(0),
|
||||||
|
AtomicUsize::new(0), AtomicUsize::new(0), AtomicUsize::new(0), AtomicUsize::new(0),
|
||||||
|
AtomicUsize::new(0), AtomicUsize::new(0), AtomicUsize::new(0), AtomicUsize::new(0),
|
||||||
|
AtomicUsize::new(0), AtomicUsize::new(0), AtomicUsize::new(0), AtomicUsize::new(0),
|
||||||
|
AtomicUsize::new(0), AtomicUsize::new(0), AtomicUsize::new(0), AtomicUsize::new(0),
|
||||||
|
AtomicUsize::new(0), AtomicUsize::new(0), AtomicUsize::new(0), AtomicUsize::new(0),
|
||||||
|
AtomicUsize::new(0), AtomicUsize::new(0), AtomicUsize::new(0), AtomicUsize::new(0),
|
||||||
|
AtomicUsize::new(0), AtomicUsize::new(0), AtomicUsize::new(0), AtomicUsize::new(0),
|
||||||
|
AtomicUsize::new(0), AtomicUsize::new(0), AtomicUsize::new(0), AtomicUsize::new(0),
|
||||||
|
AtomicUsize::new(0), AtomicUsize::new(0), AtomicUsize::new(0), AtomicUsize::new(0),
|
||||||
|
AtomicUsize::new(0), AtomicUsize::new(0), AtomicUsize::new(0), AtomicUsize::new(0),
|
||||||
|
AtomicUsize::new(0), AtomicUsize::new(0), AtomicUsize::new(0), AtomicUsize::new(0),
|
||||||
|
AtomicUsize::new(0), AtomicUsize::new(0), AtomicUsize::new(0), AtomicUsize::new(0),
|
||||||
|
AtomicUsize::new(0), AtomicUsize::new(0), AtomicUsize::new(0), AtomicUsize::new(0),
|
||||||
|
AtomicUsize::new(0), AtomicUsize::new(0), AtomicUsize::new(0), AtomicUsize::new(0),
|
||||||
|
AtomicUsize::new(0), AtomicUsize::new(0), AtomicUsize::new(0), AtomicUsize::new(0),
|
||||||
|
AtomicUsize::new(0), AtomicUsize::new(0), AtomicUsize::new(0), AtomicUsize::new(0),
|
||||||
|
AtomicUsize::new(0), AtomicUsize::new(0), AtomicUsize::new(0), AtomicUsize::new(0),
|
||||||
|
AtomicUsize::new(0), AtomicUsize::new(0), AtomicUsize::new(0), AtomicUsize::new(0),
|
||||||
|
AtomicUsize::new(0), AtomicUsize::new(0), AtomicUsize::new(0), AtomicUsize::new(0),
|
||||||
|
AtomicUsize::new(0), AtomicUsize::new(0), AtomicUsize::new(0), AtomicUsize::new(0),
|
||||||
|
AtomicUsize::new(0), AtomicUsize::new(0), AtomicUsize::new(0), AtomicUsize::new(0),
|
||||||
|
];
|
||||||
|
|
||||||
extern "C" {
|
extern "C" {
|
||||||
fn get_tls_ptr() -> *const u8;
|
fn get_tls_ptr() -> *const u8;
|
||||||
|
@ -119,7 +152,7 @@ impl Tls {
|
||||||
}
|
}
|
||||||
|
|
||||||
mod sync_bitset {
|
mod sync_bitset {
|
||||||
use sync::atomic::{AtomicUsize, ATOMIC_USIZE_INIT, Ordering};
|
use sync::atomic::{AtomicUsize, Ordering};
|
||||||
use iter::{Enumerate, Peekable};
|
use iter::{Enumerate, Peekable};
|
||||||
use slice::Iter;
|
use slice::Iter;
|
||||||
use super::{TLS_KEYS_BITSET_SIZE, USIZE_BITS};
|
use super::{TLS_KEYS_BITSET_SIZE, USIZE_BITS};
|
||||||
|
@ -128,7 +161,7 @@ mod sync_bitset {
|
||||||
pub(super) struct SyncBitset([AtomicUsize; TLS_KEYS_BITSET_SIZE]);
|
pub(super) struct SyncBitset([AtomicUsize; TLS_KEYS_BITSET_SIZE]);
|
||||||
|
|
||||||
pub(super) const SYNC_BITSET_INIT: SyncBitset =
|
pub(super) const SYNC_BITSET_INIT: SyncBitset =
|
||||||
SyncBitset([ATOMIC_USIZE_INIT, ATOMIC_USIZE_INIT]);
|
SyncBitset([AtomicUsize::new(0), AtomicUsize::new(0)]);
|
||||||
|
|
||||||
impl SyncBitset {
|
impl SyncBitset {
|
||||||
pub fn get(&self, index: usize) -> bool {
|
pub fn get(&self, index: usize) -> bool {
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
use io;
|
use io;
|
||||||
use libc::{self, c_int};
|
use libc::{self, c_int};
|
||||||
use mem;
|
use mem;
|
||||||
use sync::atomic::{AtomicBool, ATOMIC_BOOL_INIT, Ordering};
|
use sync::atomic::{AtomicBool, Ordering};
|
||||||
use sys::fd::FileDesc;
|
use sys::fd::FileDesc;
|
||||||
use sys::{cvt, cvt_r};
|
use sys::{cvt, cvt_r};
|
||||||
|
|
||||||
|
@ -13,7 +13,7 @@ pub struct AnonPipe(FileDesc);
|
||||||
|
|
||||||
pub fn anon_pipe() -> io::Result<(AnonPipe, AnonPipe)> {
|
pub fn anon_pipe() -> io::Result<(AnonPipe, AnonPipe)> {
|
||||||
syscall! { fn pipe2(fds: *mut c_int, flags: c_int) -> c_int }
|
syscall! { fn pipe2(fds: *mut c_int, flags: c_int) -> c_int }
|
||||||
static INVALID: AtomicBool = ATOMIC_BOOL_INIT;
|
static INVALID: AtomicBool = AtomicBool::new(false);
|
||||||
|
|
||||||
let mut fds = [0; 2];
|
let mut fds = [0; 2];
|
||||||
|
|
||||||
|
|
|
@ -7,7 +7,7 @@ use path::Path;
|
||||||
use ptr;
|
use ptr;
|
||||||
use slice;
|
use slice;
|
||||||
use sync::atomic::Ordering::SeqCst;
|
use sync::atomic::Ordering::SeqCst;
|
||||||
use sync::atomic::{AtomicUsize, ATOMIC_USIZE_INIT};
|
use sync::atomic::AtomicUsize;
|
||||||
use sys::c;
|
use sys::c;
|
||||||
use sys::fs::{File, OpenOptions};
|
use sys::fs::{File, OpenOptions};
|
||||||
use sys::handle::Handle;
|
use sys::handle::Handle;
|
||||||
|
@ -148,7 +148,7 @@ pub fn anon_pipe(ours_readable: bool) -> io::Result<Pipes> {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn random_number() -> usize {
|
fn random_number() -> usize {
|
||||||
static N: AtomicUsize = ATOMIC_USIZE_INIT;
|
static N: AtomicUsize = AtomicUsize::new(0);
|
||||||
loop {
|
loop {
|
||||||
if N.load(SeqCst) != 0 {
|
if N.load(SeqCst) != 0 {
|
||||||
return N.fetch_add(1, SeqCst)
|
return N.fetch_add(1, SeqCst)
|
||||||
|
|
|
@ -4,12 +4,12 @@
|
||||||
|
|
||||||
extern crate custom;
|
extern crate custom;
|
||||||
|
|
||||||
use std::sync::atomic::{ATOMIC_USIZE_INIT, Ordering};
|
use std::sync::atomic::{AtomicUsize, Ordering};
|
||||||
|
|
||||||
use custom::A;
|
use custom::A;
|
||||||
|
|
||||||
#[global_allocator]
|
#[global_allocator]
|
||||||
static ALLOCATOR: A = A(ATOMIC_USIZE_INIT);
|
static ALLOCATOR: A = A(AtomicUsize::new(0));
|
||||||
|
|
||||||
pub fn get() -> usize {
|
pub fn get() -> usize {
|
||||||
ALLOCATOR.0.load(Ordering::SeqCst)
|
ALLOCATOR.0.load(Ordering::SeqCst)
|
||||||
|
|
|
@ -8,9 +8,9 @@
|
||||||
extern crate helper;
|
extern crate helper;
|
||||||
|
|
||||||
use std::alloc::{self, Global, Alloc, System, Layout};
|
use std::alloc::{self, Global, Alloc, System, Layout};
|
||||||
use std::sync::atomic::{AtomicUsize, Ordering, ATOMIC_USIZE_INIT};
|
use std::sync::atomic::{AtomicUsize, Ordering};
|
||||||
|
|
||||||
static HITS: AtomicUsize = ATOMIC_USIZE_INIT;
|
static HITS: AtomicUsize = AtomicUsize::new(0);
|
||||||
|
|
||||||
struct A;
|
struct A;
|
||||||
|
|
||||||
|
|
|
@ -10,10 +10,10 @@ extern crate custom;
|
||||||
extern crate helper;
|
extern crate helper;
|
||||||
|
|
||||||
use std::alloc::{Global, Alloc, System, Layout};
|
use std::alloc::{Global, Alloc, System, Layout};
|
||||||
use std::sync::atomic::{Ordering, ATOMIC_USIZE_INIT};
|
use std::sync::atomic::{Ordering, AtomicUsize};
|
||||||
|
|
||||||
#[global_allocator]
|
#[global_allocator]
|
||||||
static GLOBAL: custom::A = custom::A(ATOMIC_USIZE_INIT);
|
static GLOBAL: custom::A = custom::A(AtomicUsize::new(0));
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
unsafe {
|
unsafe {
|
||||||
|
|
|
@ -12,9 +12,9 @@ extern crate custom_as_global;
|
||||||
extern crate helper;
|
extern crate helper;
|
||||||
|
|
||||||
use std::alloc::{alloc, dealloc, GlobalAlloc, System, Layout};
|
use std::alloc::{alloc, dealloc, GlobalAlloc, System, Layout};
|
||||||
use std::sync::atomic::{Ordering, ATOMIC_USIZE_INIT};
|
use std::sync::atomic::{AtomicUsize, Ordering};
|
||||||
|
|
||||||
static GLOBAL: custom::A = custom::A(ATOMIC_USIZE_INIT);
|
static GLOBAL: custom::A = custom::A(AtomicUsize::new(0));
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
unsafe {
|
unsafe {
|
||||||
|
@ -45,4 +45,3 @@ fn main() {
|
||||||
assert_eq!(GLOBAL.0.load(Ordering::SeqCst), 2);
|
assert_eq!(GLOBAL.0.load(Ordering::SeqCst), 2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
#![allow(stable_features)]
|
#![allow(stable_features)]
|
||||||
#![feature(atomic_access)]
|
#![feature(atomic_access)]
|
||||||
use std::sync::atomic::{AtomicBool, ATOMIC_BOOL_INIT};
|
use std::sync::atomic::AtomicBool;
|
||||||
use std::sync::atomic::Ordering::*;
|
use std::sync::atomic::Ordering::*;
|
||||||
|
|
||||||
static mut ATOMIC: AtomicBool = ATOMIC_BOOL_INIT;
|
static mut ATOMIC: AtomicBool = AtomicBool::new(false);
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
unsafe {
|
unsafe {
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
#![allow(stable_features)]
|
#![allow(stable_features)]
|
||||||
|
|
||||||
#![feature(extended_compare_and_swap)]
|
#![feature(extended_compare_and_swap)]
|
||||||
use std::sync::atomic::{AtomicIsize, ATOMIC_ISIZE_INIT};
|
use std::sync::atomic::AtomicIsize;
|
||||||
use std::sync::atomic::Ordering::*;
|
use std::sync::atomic::Ordering::*;
|
||||||
|
|
||||||
static ATOMIC: AtomicIsize = ATOMIC_ISIZE_INIT;
|
static ATOMIC: AtomicIsize = AtomicIsize::new(0);
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
// Make sure codegen can emit all the intrinsics correctly
|
// Make sure codegen can emit all the intrinsics correctly
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
//! Test that #[derive(Copy, Clone)] produces a shallow copy
|
//! Test that #[derive(Copy, Clone)] produces a shallow copy
|
||||||
//! even when a member violates RFC 1521
|
//! even when a member violates RFC 1521
|
||||||
|
|
||||||
use std::sync::atomic::{AtomicBool, ATOMIC_BOOL_INIT, Ordering};
|
use std::sync::atomic::{AtomicBool, Ordering};
|
||||||
|
|
||||||
/// A struct that pretends to be Copy, but actually does something
|
/// A struct that pretends to be Copy, but actually does something
|
||||||
/// in its Clone impl
|
/// in its Clone impl
|
||||||
|
@ -10,7 +10,7 @@ use std::sync::atomic::{AtomicBool, ATOMIC_BOOL_INIT, Ordering};
|
||||||
struct Liar;
|
struct Liar;
|
||||||
|
|
||||||
/// Static cooperating with the rogue Clone impl
|
/// Static cooperating with the rogue Clone impl
|
||||||
static CLONED: AtomicBool = ATOMIC_BOOL_INIT;
|
static CLONED: AtomicBool = AtomicBool::new(false);
|
||||||
|
|
||||||
impl Clone for Liar {
|
impl Clone for Liar {
|
||||||
fn clone(&self) -> Self {
|
fn clone(&self) -> Self {
|
||||||
|
@ -36,4 +36,3 @@ fn main() {
|
||||||
// if Innocent was byte-for-byte copied, CLONED will still be false
|
// if Innocent was byte-for-byte copied, CLONED will still be false
|
||||||
assert!(!CLONED.load(Ordering::SeqCst));
|
assert!(!CLONED.load(Ordering::SeqCst));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -3,9 +3,9 @@
|
||||||
#![feature(generators, generator_trait)]
|
#![feature(generators, generator_trait)]
|
||||||
|
|
||||||
use std::ops::Generator;
|
use std::ops::Generator;
|
||||||
use std::sync::atomic::{AtomicUsize, ATOMIC_USIZE_INIT, Ordering};
|
use std::sync::atomic::{AtomicUsize, Ordering};
|
||||||
|
|
||||||
static A: AtomicUsize = ATOMIC_USIZE_INIT;
|
static A: AtomicUsize = AtomicUsize::new(0);
|
||||||
|
|
||||||
struct B;
|
struct B;
|
||||||
|
|
||||||
|
|
|
@ -3,9 +3,9 @@
|
||||||
#![feature(generators, generator_trait)]
|
#![feature(generators, generator_trait)]
|
||||||
|
|
||||||
use std::ops::Generator;
|
use std::ops::Generator;
|
||||||
use std::sync::atomic::{AtomicUsize, ATOMIC_USIZE_INIT, Ordering};
|
use std::sync::atomic::{AtomicUsize, Ordering};
|
||||||
|
|
||||||
static A: AtomicUsize = ATOMIC_USIZE_INIT;
|
static A: AtomicUsize = AtomicUsize::new(0);
|
||||||
|
|
||||||
struct B;
|
struct B;
|
||||||
|
|
||||||
|
|
|
@ -6,9 +6,9 @@
|
||||||
|
|
||||||
use std::ops::Generator;
|
use std::ops::Generator;
|
||||||
use std::panic;
|
use std::panic;
|
||||||
use std::sync::atomic::{AtomicUsize, ATOMIC_USIZE_INIT, Ordering};
|
use std::sync::atomic::{AtomicUsize, Ordering};
|
||||||
|
|
||||||
static A: AtomicUsize = ATOMIC_USIZE_INIT;
|
static A: AtomicUsize = AtomicUsize::new(0);
|
||||||
|
|
||||||
struct B;
|
struct B;
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
// run-pass
|
// run-pass
|
||||||
use std::sync::atomic::{AtomicUsize, ATOMIC_USIZE_INIT, Ordering};
|
use std::sync::atomic::{AtomicUsize, Ordering};
|
||||||
|
|
||||||
static DROP_COUNTER: AtomicUsize = ATOMIC_USIZE_INIT;
|
static DROP_COUNTER: AtomicUsize = AtomicUsize::new(0);
|
||||||
|
|
||||||
struct A(i32);
|
struct A(i32);
|
||||||
|
|
||||||
|
|
|
@ -10,7 +10,7 @@
|
||||||
use std::sync::atomic;
|
use std::sync::atomic;
|
||||||
use std::sync::atomic::Ordering::SeqCst;
|
use std::sync::atomic::Ordering::SeqCst;
|
||||||
|
|
||||||
static COUNTER: atomic::AtomicUsize = atomic::ATOMIC_USIZE_INIT;
|
static COUNTER: atomic::AtomicUsize = atomic::AtomicUsize::new(0);
|
||||||
|
|
||||||
struct DropMe {
|
struct DropMe {
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
// run-pass
|
// run-pass
|
||||||
// ignore-emscripten no threads support
|
// ignore-emscripten no threads support
|
||||||
|
|
||||||
use std::sync::atomic::{AtomicUsize, Ordering, ATOMIC_USIZE_INIT};
|
use std::sync::atomic::{AtomicUsize, Ordering};
|
||||||
use std::panic;
|
use std::panic;
|
||||||
use std::thread;
|
use std::thread;
|
||||||
|
|
||||||
static A: AtomicUsize = ATOMIC_USIZE_INIT;
|
static A: AtomicUsize = AtomicUsize::new(0);
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
panic::set_hook(Box::new(|_| {
|
panic::set_hook(Box::new(|_| {
|
||||||
|
|
|
@ -6,13 +6,13 @@
|
||||||
#![feature(thread_local_try_with)]
|
#![feature(thread_local_try_with)]
|
||||||
|
|
||||||
use std::thread;
|
use std::thread;
|
||||||
use std::sync::atomic::{AtomicUsize, Ordering, ATOMIC_USIZE_INIT};
|
use std::sync::atomic::{AtomicUsize, Ordering};
|
||||||
|
|
||||||
struct Foo { cnt: usize }
|
struct Foo { cnt: usize }
|
||||||
|
|
||||||
thread_local!(static FOO: Foo = Foo::init());
|
thread_local!(static FOO: Foo = Foo::init());
|
||||||
|
|
||||||
static CNT: AtomicUsize = ATOMIC_USIZE_INIT;
|
static CNT: AtomicUsize = AtomicUsize::new(0);
|
||||||
|
|
||||||
impl Foo {
|
impl Foo {
|
||||||
fn init() -> Foo {
|
fn init() -> Foo {
|
||||||
|
|
|
@ -10,7 +10,7 @@
|
||||||
#![feature(thread_local)]
|
#![feature(thread_local)]
|
||||||
|
|
||||||
#[thread_local]
|
#[thread_local]
|
||||||
static mut X: ::std::sync::atomic::AtomicUsize = ::std::sync::atomic::ATOMIC_USIZE_INIT;
|
static mut X: ::std::sync::atomic::AtomicUsize = ::std::sync::atomic::AtomicUsize::new(0);
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
unsafe {
|
unsafe {
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
use std::sync::atomic::{AtomicUsize, ATOMIC_USIZE_INIT};
|
use std::sync::atomic::AtomicUsize;
|
||||||
|
|
||||||
const A: AtomicUsize = ATOMIC_USIZE_INIT;
|
const A: AtomicUsize = AtomicUsize::new(0);
|
||||||
static B: &'static AtomicUsize = &A; //~ ERROR E0492
|
static B: &'static AtomicUsize = &A; //~ ERROR E0492
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
|
|
|
@ -20,7 +20,7 @@ use std::os::unix::prelude::*;
|
||||||
use std::path::{Path, PathBuf};
|
use std::path::{Path, PathBuf};
|
||||||
use std::process::{Command, Stdio};
|
use std::process::{Command, Stdio};
|
||||||
use std::str;
|
use std::str;
|
||||||
use std::sync::atomic::{AtomicUsize, ATOMIC_USIZE_INIT, Ordering};
|
use std::sync::atomic::{AtomicUsize, Ordering};
|
||||||
use std::sync::{Arc, Mutex};
|
use std::sync::{Arc, Mutex};
|
||||||
use std::thread;
|
use std::thread;
|
||||||
|
|
||||||
|
@ -31,7 +31,7 @@ macro_rules! t {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
static TEST: AtomicUsize = ATOMIC_USIZE_INIT;
|
static TEST: AtomicUsize = AtomicUsize::new(0);
|
||||||
|
|
||||||
struct Config {
|
struct Config {
|
||||||
pub remote: bool,
|
pub remote: bool,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue