From 7a58c6d1deec25c37c93ae4cf9ec2432918bc360 Mon Sep 17 00:00:00 2001 From: Mark Rousskov Date: Sat, 26 Jan 2019 09:14:49 -0700 Subject: [PATCH] Replace deprecated ATOMIC_INIT consts --- src/liballoc/tests/binary_heap.rs | 4 +- src/liballoc/tests/slice.rs | 4 +- src/libcore/sync/atomic.rs | 5 +-- src/librustc_driver/lib.rs | 4 +- src/librustc_mir/diagnostics.rs | 8 ++-- src/libstd/alloc.rs | 4 +- src/libstd/sys/redox/thread_local.rs | 4 +- src/libstd/sys/sgx/abi/tls.rs | 41 +++++++++++++++++-- src/libstd/sys/unix/pipe.rs | 4 +- src/libstd/sys/windows/pipe.rs | 4 +- .../allocator/auxiliary/custom-as-global.rs | 4 +- src/test/run-pass/allocator/custom.rs | 4 +- src/test/run-pass/allocator/xcrate-use.rs | 4 +- src/test/run-pass/allocator/xcrate-use2.rs | 5 +-- src/test/run-pass/atomic-access-bool.rs | 4 +- src/test/run-pass/atomic-compare_exchange.rs | 4 +- .../run-pass/deriving/deriving-copyclone.rs | 5 +-- .../run-pass/generator/conditional-drop.rs | 4 +- src/test/run-pass/generator/drop-env.rs | 4 +- src/test/run-pass/generator/panic-drops.rs | 4 +- src/test/run-pass/issues/issue-34053.rs | 4 +- src/test/run-pass/mir/mir_fat_ptr_drop.rs | 2 +- .../panics/panic-recover-propagate.rs | 4 +- .../threads-sendsync/tls-init-on-init.rs | 4 +- .../issue-47215-ice-from-drop-elab.rs | 2 +- src/test/ui/error-codes/E0492.rs | 4 +- src/tools/remote-test-server/src/main.rs | 4 +- 27 files changed, 89 insertions(+), 59 deletions(-) diff --git a/src/liballoc/tests/binary_heap.rs b/src/liballoc/tests/binary_heap.rs index 6af1cf40809..94ae43237d1 100644 --- a/src/liballoc/tests/binary_heap.rs +++ b/src/liballoc/tests/binary_heap.rs @@ -2,7 +2,7 @@ use std::cmp; use std::collections::BinaryHeap; use std::collections::binary_heap::{Drain, PeekMut}; 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}; @@ -283,7 +283,7 @@ fn assert_covariance() { // Destructors must be called exactly once per element. #[test] fn panic_safe() { - static DROP_COUNTER: AtomicUsize = ATOMIC_USIZE_INIT; + static DROP_COUNTER: AtomicUsize = AtomicUsize::new(0); #[derive(Eq, PartialEq, Ord, Clone, Debug)] struct PanicOrd(T, bool); diff --git a/src/liballoc/tests/slice.rs b/src/liballoc/tests/slice.rs index 8ecd17236c0..0300bd7f3f6 100644 --- a/src/liballoc/tests/slice.rs +++ b/src/liballoc/tests/slice.rs @@ -5,7 +5,7 @@ use std::mem; use std::panic; use std::rc::Rc; use std::sync::atomic::Ordering::Relaxed; -use std::sync::atomic::{ATOMIC_USIZE_INIT, AtomicUsize}; +use std::sync::atomic::AtomicUsize; use std::thread; 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), ]; -static VERSIONS: AtomicUsize = ATOMIC_USIZE_INIT; +static VERSIONS: AtomicUsize = AtomicUsize::new(0); #[derive(Clone, Eq)] struct DropCounter { diff --git a/src/libcore/sync/atomic.rs b/src/libcore/sync/atomic.rs index b9ebf19b23c..bcedff5abc7 100644 --- a/src/libcore/sync/atomic.rs +++ b/src/libcore/sync/atomic.rs @@ -2413,12 +2413,11 @@ pub fn fence(order: Ordering) { /// /// ``` /// 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::compiler_fence; /// -/// static IMPORTANT_VARIABLE: AtomicUsize = ATOMIC_USIZE_INIT; -/// static IS_READY: AtomicBool = ATOMIC_BOOL_INIT; +/// static IMPORTANT_VARIABLE: AtomicUsize = AtomicUsize::new(0); +/// static IS_READY: AtomicBool = AtomicBool::new(false); /// /// fn main() { /// IMPORTANT_VARIABLE.store(42, Ordering::Relaxed); diff --git a/src/librustc_driver/lib.rs b/src/librustc_driver/lib.rs index abcdf175ada..a95ce810ffa 100644 --- a/src/librustc_driver/lib.rs +++ b/src/librustc_driver/lib.rs @@ -91,7 +91,7 @@ use std::panic; use std::path::{PathBuf, Path}; use std::process::{self, Command, Stdio}; 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::thread; @@ -254,7 +254,7 @@ fn get_codegen_sysroot(backend_name: &str) -> fn() -> Box { // 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 // against. - static LOADED: AtomicBool = ATOMIC_BOOL_INIT; + static LOADED: AtomicBool = AtomicBool::new(false); assert!(!LOADED.fetch_or(true, Ordering::SeqCst), "cannot load the default codegen backend twice"); diff --git a/src/librustc_mir/diagnostics.rs b/src/librustc_mir/diagnostics.rs index ea9e19c75c2..74394165a5f 100644 --- a/src/librustc_mir/diagnostics.rs +++ b/src/librustc_mir/diagnostics.rs @@ -1127,9 +1127,9 @@ A borrow of a constant containing interior mutability was attempted. Erroneous code example: ```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; // error: cannot borrow a constant which may contain interior mutability, // 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`: ``` -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! ``` diff --git a/src/libstd/alloc.rs b/src/libstd/alloc.rs index 537f56a8da7..8b6e5680c2d 100644 --- a/src/libstd/alloc.rs +++ b/src/libstd/alloc.rs @@ -95,11 +95,11 @@ pub use alloc_crate::alloc::*; /// /// ```rust /// 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; /// -/// static ALLOCATED: AtomicUsize = ATOMIC_USIZE_INIT; +/// static ALLOCATED: AtomicUsize = AtomicUsize::new(0); /// /// unsafe impl GlobalAlloc for Counter { /// unsafe fn alloc(&self, layout: Layout) -> *mut u8 { diff --git a/src/libstd/sys/redox/thread_local.rs b/src/libstd/sys/redox/thread_local.rs index a1c4b10e450..a1929b94165 100644 --- a/src/libstd/sys/redox/thread_local.rs +++ b/src/libstd/sys/redox/thread_local.rs @@ -2,13 +2,13 @@ use collections::BTreeMap; use ptr; -use sync::atomic::{AtomicUsize, ATOMIC_USIZE_INIT, Ordering}; +use sync::atomic::{AtomicUsize, Ordering}; pub type Key = usize; 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> = ptr::null_mut(); diff --git a/src/libstd/sys/sgx/abi/tls.rs b/src/libstd/sys/sgx/abi/tls.rs index aba93db915f..b8e09d58deb 100644 --- a/src/libstd/sys/sgx/abi/tls.rs +++ b/src/libstd/sys/sgx/abi/tls.rs @@ -1,4 +1,4 @@ -use sync::atomic::{AtomicUsize, ATOMIC_USIZE_INIT, Ordering}; +use sync::atomic::{AtomicUsize, Ordering}; use ptr; use mem; use cell::Cell; @@ -15,7 +15,40 @@ macro_rules! dup { ((* $($exp:tt)*) $($val:tt)*) => (dup!( ($($exp)*) $($val)* $($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" { fn get_tls_ptr() -> *const u8; @@ -119,7 +152,7 @@ impl Tls { } mod sync_bitset { - use sync::atomic::{AtomicUsize, ATOMIC_USIZE_INIT, Ordering}; + use sync::atomic::{AtomicUsize, Ordering}; use iter::{Enumerate, Peekable}; use slice::Iter; 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) const SYNC_BITSET_INIT: SyncBitset = - SyncBitset([ATOMIC_USIZE_INIT, ATOMIC_USIZE_INIT]); + SyncBitset([AtomicUsize::new(0), AtomicUsize::new(0)]); impl SyncBitset { pub fn get(&self, index: usize) -> bool { diff --git a/src/libstd/sys/unix/pipe.rs b/src/libstd/sys/unix/pipe.rs index 91793a0d5ec..a746d982c6c 100644 --- a/src/libstd/sys/unix/pipe.rs +++ b/src/libstd/sys/unix/pipe.rs @@ -1,7 +1,7 @@ use io; use libc::{self, c_int}; use mem; -use sync::atomic::{AtomicBool, ATOMIC_BOOL_INIT, Ordering}; +use sync::atomic::{AtomicBool, Ordering}; use sys::fd::FileDesc; use sys::{cvt, cvt_r}; @@ -13,7 +13,7 @@ pub struct AnonPipe(FileDesc); pub fn anon_pipe() -> io::Result<(AnonPipe, AnonPipe)> { 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]; diff --git a/src/libstd/sys/windows/pipe.rs b/src/libstd/sys/windows/pipe.rs index 2b1dbe310ee..0d9195a5c97 100644 --- a/src/libstd/sys/windows/pipe.rs +++ b/src/libstd/sys/windows/pipe.rs @@ -7,7 +7,7 @@ use path::Path; use ptr; use slice; use sync::atomic::Ordering::SeqCst; -use sync::atomic::{AtomicUsize, ATOMIC_USIZE_INIT}; +use sync::atomic::AtomicUsize; use sys::c; use sys::fs::{File, OpenOptions}; use sys::handle::Handle; @@ -148,7 +148,7 @@ pub fn anon_pipe(ours_readable: bool) -> io::Result { } fn random_number() -> usize { - static N: AtomicUsize = ATOMIC_USIZE_INIT; + static N: AtomicUsize = AtomicUsize::new(0); loop { if N.load(SeqCst) != 0 { return N.fetch_add(1, SeqCst) diff --git a/src/test/run-pass/allocator/auxiliary/custom-as-global.rs b/src/test/run-pass/allocator/auxiliary/custom-as-global.rs index 6842e2c33b2..a5e96e77501 100644 --- a/src/test/run-pass/allocator/auxiliary/custom-as-global.rs +++ b/src/test/run-pass/allocator/auxiliary/custom-as-global.rs @@ -4,12 +4,12 @@ extern crate custom; -use std::sync::atomic::{ATOMIC_USIZE_INIT, Ordering}; +use std::sync::atomic::{AtomicUsize, Ordering}; use custom::A; #[global_allocator] -static ALLOCATOR: A = A(ATOMIC_USIZE_INIT); +static ALLOCATOR: A = A(AtomicUsize::new(0)); pub fn get() -> usize { ALLOCATOR.0.load(Ordering::SeqCst) diff --git a/src/test/run-pass/allocator/custom.rs b/src/test/run-pass/allocator/custom.rs index a8c6e0325e1..71f72ae46c2 100644 --- a/src/test/run-pass/allocator/custom.rs +++ b/src/test/run-pass/allocator/custom.rs @@ -8,9 +8,9 @@ extern crate helper; 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; diff --git a/src/test/run-pass/allocator/xcrate-use.rs b/src/test/run-pass/allocator/xcrate-use.rs index eb911a62e91..039c70e77be 100644 --- a/src/test/run-pass/allocator/xcrate-use.rs +++ b/src/test/run-pass/allocator/xcrate-use.rs @@ -10,10 +10,10 @@ extern crate custom; extern crate helper; use std::alloc::{Global, Alloc, System, Layout}; -use std::sync::atomic::{Ordering, ATOMIC_USIZE_INIT}; +use std::sync::atomic::{Ordering, AtomicUsize}; #[global_allocator] -static GLOBAL: custom::A = custom::A(ATOMIC_USIZE_INIT); +static GLOBAL: custom::A = custom::A(AtomicUsize::new(0)); fn main() { unsafe { diff --git a/src/test/run-pass/allocator/xcrate-use2.rs b/src/test/run-pass/allocator/xcrate-use2.rs index be657f127bb..d8478fb5eaa 100644 --- a/src/test/run-pass/allocator/xcrate-use2.rs +++ b/src/test/run-pass/allocator/xcrate-use2.rs @@ -12,9 +12,9 @@ extern crate custom_as_global; extern crate helper; 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() { unsafe { @@ -45,4 +45,3 @@ fn main() { assert_eq!(GLOBAL.0.load(Ordering::SeqCst), 2); } } - diff --git a/src/test/run-pass/atomic-access-bool.rs b/src/test/run-pass/atomic-access-bool.rs index 4f804bcdef2..8522493232f 100644 --- a/src/test/run-pass/atomic-access-bool.rs +++ b/src/test/run-pass/atomic-access-bool.rs @@ -1,9 +1,9 @@ #![allow(stable_features)] #![feature(atomic_access)] -use std::sync::atomic::{AtomicBool, ATOMIC_BOOL_INIT}; +use std::sync::atomic::AtomicBool; use std::sync::atomic::Ordering::*; -static mut ATOMIC: AtomicBool = ATOMIC_BOOL_INIT; +static mut ATOMIC: AtomicBool = AtomicBool::new(false); fn main() { unsafe { diff --git a/src/test/run-pass/atomic-compare_exchange.rs b/src/test/run-pass/atomic-compare_exchange.rs index c7b80c42c1b..77da820e07c 100644 --- a/src/test/run-pass/atomic-compare_exchange.rs +++ b/src/test/run-pass/atomic-compare_exchange.rs @@ -1,10 +1,10 @@ #![allow(stable_features)] #![feature(extended_compare_and_swap)] -use std::sync::atomic::{AtomicIsize, ATOMIC_ISIZE_INIT}; +use std::sync::atomic::AtomicIsize; use std::sync::atomic::Ordering::*; -static ATOMIC: AtomicIsize = ATOMIC_ISIZE_INIT; +static ATOMIC: AtomicIsize = AtomicIsize::new(0); fn main() { // Make sure codegen can emit all the intrinsics correctly diff --git a/src/test/run-pass/deriving/deriving-copyclone.rs b/src/test/run-pass/deriving/deriving-copyclone.rs index cdeb5d03d35..78d74a11ffc 100644 --- a/src/test/run-pass/deriving/deriving-copyclone.rs +++ b/src/test/run-pass/deriving/deriving-copyclone.rs @@ -2,7 +2,7 @@ //! Test that #[derive(Copy, Clone)] produces a shallow copy //! 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 /// in its Clone impl @@ -10,7 +10,7 @@ use std::sync::atomic::{AtomicBool, ATOMIC_BOOL_INIT, Ordering}; struct Liar; /// Static cooperating with the rogue Clone impl -static CLONED: AtomicBool = ATOMIC_BOOL_INIT; +static CLONED: AtomicBool = AtomicBool::new(false); impl Clone for Liar { fn clone(&self) -> Self { @@ -36,4 +36,3 @@ fn main() { // if Innocent was byte-for-byte copied, CLONED will still be false assert!(!CLONED.load(Ordering::SeqCst)); } - diff --git a/src/test/run-pass/generator/conditional-drop.rs b/src/test/run-pass/generator/conditional-drop.rs index b7d7681d25c..766eef9e3f3 100644 --- a/src/test/run-pass/generator/conditional-drop.rs +++ b/src/test/run-pass/generator/conditional-drop.rs @@ -3,9 +3,9 @@ #![feature(generators, generator_trait)] 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; diff --git a/src/test/run-pass/generator/drop-env.rs b/src/test/run-pass/generator/drop-env.rs index bd988897710..252f2c0f07d 100644 --- a/src/test/run-pass/generator/drop-env.rs +++ b/src/test/run-pass/generator/drop-env.rs @@ -3,9 +3,9 @@ #![feature(generators, generator_trait)] 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; diff --git a/src/test/run-pass/generator/panic-drops.rs b/src/test/run-pass/generator/panic-drops.rs index ce12f4225ef..8640a653919 100644 --- a/src/test/run-pass/generator/panic-drops.rs +++ b/src/test/run-pass/generator/panic-drops.rs @@ -6,9 +6,9 @@ use std::ops::Generator; 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; diff --git a/src/test/run-pass/issues/issue-34053.rs b/src/test/run-pass/issues/issue-34053.rs index ec5a0cbf6bb..fa23ae8f95b 100644 --- a/src/test/run-pass/issues/issue-34053.rs +++ b/src/test/run-pass/issues/issue-34053.rs @@ -1,7 +1,7 @@ // 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); diff --git a/src/test/run-pass/mir/mir_fat_ptr_drop.rs b/src/test/run-pass/mir/mir_fat_ptr_drop.rs index 9f4f3d6c5d3..d865c3499b2 100644 --- a/src/test/run-pass/mir/mir_fat_ptr_drop.rs +++ b/src/test/run-pass/mir/mir_fat_ptr_drop.rs @@ -10,7 +10,7 @@ use std::sync::atomic; use std::sync::atomic::Ordering::SeqCst; -static COUNTER: atomic::AtomicUsize = atomic::ATOMIC_USIZE_INIT; +static COUNTER: atomic::AtomicUsize = atomic::AtomicUsize::new(0); struct DropMe { } diff --git a/src/test/run-pass/panics/panic-recover-propagate.rs b/src/test/run-pass/panics/panic-recover-propagate.rs index 0a15417f72a..7969336ca74 100644 --- a/src/test/run-pass/panics/panic-recover-propagate.rs +++ b/src/test/run-pass/panics/panic-recover-propagate.rs @@ -1,11 +1,11 @@ // run-pass // 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::thread; -static A: AtomicUsize = ATOMIC_USIZE_INIT; +static A: AtomicUsize = AtomicUsize::new(0); fn main() { panic::set_hook(Box::new(|_| { diff --git a/src/test/run-pass/threads-sendsync/tls-init-on-init.rs b/src/test/run-pass/threads-sendsync/tls-init-on-init.rs index 6ac7a9253cd..193c1815105 100644 --- a/src/test/run-pass/threads-sendsync/tls-init-on-init.rs +++ b/src/test/run-pass/threads-sendsync/tls-init-on-init.rs @@ -6,13 +6,13 @@ #![feature(thread_local_try_with)] use std::thread; -use std::sync::atomic::{AtomicUsize, Ordering, ATOMIC_USIZE_INIT}; +use std::sync::atomic::{AtomicUsize, Ordering}; struct Foo { cnt: usize } thread_local!(static FOO: Foo = Foo::init()); -static CNT: AtomicUsize = ATOMIC_USIZE_INIT; +static CNT: AtomicUsize = AtomicUsize::new(0); impl Foo { fn init() -> Foo { diff --git a/src/test/ui/borrowck/issue-47215-ice-from-drop-elab.rs b/src/test/ui/borrowck/issue-47215-ice-from-drop-elab.rs index 670c6bb869d..7477947b89c 100644 --- a/src/test/ui/borrowck/issue-47215-ice-from-drop-elab.rs +++ b/src/test/ui/borrowck/issue-47215-ice-from-drop-elab.rs @@ -10,7 +10,7 @@ #![feature(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() { unsafe { diff --git a/src/test/ui/error-codes/E0492.rs b/src/test/ui/error-codes/E0492.rs index b1824941adf..2de4c12eb64 100644 --- a/src/test/ui/error-codes/E0492.rs +++ b/src/test/ui/error-codes/E0492.rs @@ -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 fn main() { diff --git a/src/tools/remote-test-server/src/main.rs b/src/tools/remote-test-server/src/main.rs index 74dde8bf0e2..3f56d4da6a3 100644 --- a/src/tools/remote-test-server/src/main.rs +++ b/src/tools/remote-test-server/src/main.rs @@ -20,7 +20,7 @@ use std::os::unix::prelude::*; use std::path::{Path, PathBuf}; use std::process::{Command, Stdio}; 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::thread; @@ -31,7 +31,7 @@ macro_rules! t { }) } -static TEST: AtomicUsize = ATOMIC_USIZE_INIT; +static TEST: AtomicUsize = AtomicUsize::new(0); struct Config { pub remote: bool,