From 93b6d9e086c6910118a57e4332c9448ab550931f Mon Sep 17 00:00:00 2001 From: Taiki Endo Date: Mon, 11 Feb 2019 04:23:21 +0900 Subject: libstd => 2018 --- src/libstd/thread/local.rs | 46 ++++++++++++++++++------------------ src/libstd/thread/mod.rs | 58 +++++++++++++++++++++++----------------------- 2 files changed, 52 insertions(+), 52 deletions(-) (limited to 'src/libstd/thread') diff --git a/src/libstd/thread/local.rs b/src/libstd/thread/local.rs index 8207709e1f9..d1f53734d30 100644 --- a/src/libstd/thread/local.rs +++ b/src/libstd/thread/local.rs @@ -2,10 +2,10 @@ #![unstable(feature = "thread_local_internals", issue = "0")] -use cell::UnsafeCell; -use fmt; -use hint; -use mem; +use crate::cell::UnsafeCell; +use crate::fmt; +use crate::hint; +use crate::mem; /// A thread local storage key which owns its contents. /// @@ -310,14 +310,14 @@ impl LocalKey { #[doc(hidden)] #[cfg(all(target_arch = "wasm32", not(target_feature = "atomics")))] pub mod statik { - use cell::UnsafeCell; - use fmt; + use crate::cell::UnsafeCell; + use crate::fmt; pub struct Key { inner: UnsafeCell>, } - unsafe impl ::marker::Sync for Key { } + unsafe impl Sync for Key { } impl fmt::Debug for Key { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { @@ -341,11 +341,11 @@ pub mod statik { #[doc(hidden)] #[cfg(target_thread_local)] pub mod fast { - use cell::{Cell, UnsafeCell}; - use fmt; - use mem; - use ptr; - use sys::fast_thread_local::{register_dtor, requires_move_before_drop}; + use crate::cell::{Cell, UnsafeCell}; + use crate::fmt; + use crate::mem; + use crate::ptr; + use crate::sys::fast_thread_local::{register_dtor, requires_move_before_drop}; pub struct Key { inner: UnsafeCell>, @@ -412,11 +412,11 @@ pub mod fast { #[doc(hidden)] pub mod os { - use cell::{Cell, UnsafeCell}; - use fmt; - use marker; - use ptr; - use sys_common::thread_local::StaticKey as OsStaticKey; + use crate::cell::{Cell, UnsafeCell}; + use crate::fmt; + use crate::marker; + use crate::ptr; + use crate::sys_common::thread_local::StaticKey as OsStaticKey; pub struct Key { // OS-TLS key that we'll use to key off. @@ -430,7 +430,7 @@ pub mod os { } } - unsafe impl ::marker::Sync for Key { } + unsafe impl Sync for Key { } struct Value { key: &'static Key, @@ -484,9 +484,9 @@ pub mod os { #[cfg(all(test, not(target_os = "emscripten")))] mod tests { - use sync::mpsc::{channel, Sender}; - use cell::{Cell, UnsafeCell}; - use thread; + use crate::sync::mpsc::{channel, Sender}; + use crate::cell::{Cell, UnsafeCell}; + use crate::thread; struct Foo(Sender<()>); @@ -632,8 +632,8 @@ mod tests { #[cfg(test)] mod dynamic_tests { - use cell::RefCell; - use collections::HashMap; + use crate::cell::RefCell; + use crate::collections::HashMap; #[test] fn smoke() { diff --git a/src/libstd/thread/mod.rs b/src/libstd/thread/mod.rs index 438ea3aa3f6..08f0aa2f0d2 100644 --- a/src/libstd/thread/mod.rs +++ b/src/libstd/thread/mod.rs @@ -156,25 +156,25 @@ #![stable(feature = "rust1", since = "1.0.0")] -use any::Any; -use boxed::FnBox; -use cell::UnsafeCell; -use ffi::{CStr, CString}; -use fmt; -use io; -use mem; -use panic; -use panicking; -use str; -use sync::{Mutex, Condvar, Arc}; -use sync::atomic::AtomicUsize; -use sync::atomic::Ordering::SeqCst; -use sys::thread as imp; -use sys_common::mutex; -use sys_common::thread_info; -use sys_common::thread; -use sys_common::{AsInner, IntoInner}; -use time::Duration; +use crate::any::Any; +use crate::boxed::FnBox; +use crate::cell::UnsafeCell; +use crate::ffi::{CStr, CString}; +use crate::fmt; +use crate::io; +use crate::mem; +use crate::panic; +use crate::panicking; +use crate::str; +use crate::sync::{Mutex, Condvar, Arc}; +use crate::sync::atomic::AtomicUsize; +use crate::sync::atomic::Ordering::SeqCst; +use crate::sys::thread as imp; +use crate::sys_common::mutex; +use crate::sys_common::thread_info; +use crate::sys_common::thread; +use crate::sys_common::{AsInner, IntoInner}; +use crate::time::Duration; //////////////////////////////////////////////////////////////////////////////// // Thread-local storage @@ -466,7 +466,7 @@ impl Builder { thread_info::set(imp::guard::current(), their_thread); #[cfg(feature = "backtrace")] let try_result = panic::catch_unwind(panic::AssertUnwindSafe(|| { - ::sys_common::backtrace::__rust_begin_short_backtrace(f) + crate::sys_common::backtrace::__rust_begin_short_backtrace(f) })); #[cfg(not(feature = "backtrace"))] let try_result = panic::catch_unwind(panic::AssertUnwindSafe(f)); @@ -1051,7 +1051,7 @@ impl ThreadId { // If we somehow use up all our bits, panic so that we're not // covering up subtle bugs of IDs being reused. - if COUNTER == ::u64::MAX { + if COUNTER == crate::u64::MAX { panic!("failed to generate unique thread ID: bitspace exhausted"); } @@ -1290,7 +1290,7 @@ impl fmt::Debug for Thread { /// /// [`Result`]: ../../std/result/enum.Result.html #[stable(feature = "rust1", since = "1.0.0")] -pub type Result = ::result::Result>; +pub type Result = crate::result::Result>; // This packet is used to communicate the return value between the child thread // and the parent thread. Memory is shared through the `Arc` within and there's @@ -1482,13 +1482,13 @@ fn _assert_sync_and_send() { #[cfg(all(test, not(target_os = "emscripten")))] mod tests { - use any::Any; - use sync::mpsc::{channel, Sender}; - use result; - use super::{Builder}; - use thread; - use time::Duration; - use u32; + use super::Builder; + use crate::any::Any; + use crate::sync::mpsc::{channel, Sender}; + use crate::result; + use crate::thread; + use crate::time::Duration; + use crate::u32; // !!! These tests are dangerous. If something is buggy, they will hang, !!! // !!! instead of exiting cleanly. This might wedge the buildbots. !!! -- cgit 1.4.1-3-g733a5 From 2870015b7b7a52a23db0b68fde8b830706061fd0 Mon Sep 17 00:00:00 2001 From: Mark Rousskov Date: Wed, 27 Feb 2019 16:58:12 -0700 Subject: Bootstrap compiler update for 1.35 release --- src/bootstrap/channel.rs | 2 +- src/liballoc/macros.rs | 3 +- src/libcore/intrinsics.rs | 2 - src/libcore/macros.rs | 6 +- src/libcore/marker.rs | 2 +- src/libcore/num/mod.rs | 102 --------------------------------- src/libcore/pin.rs | 2 +- src/libcore/sync/atomic.rs | 16 ++---- src/librustc_data_structures/macros.rs | 3 +- src/libstd/macros.rs | 18 ++---- src/libstd/thread/local.rs | 8 +-- src/stage0.txt | 2 +- 12 files changed, 20 insertions(+), 146 deletions(-) (limited to 'src/libstd/thread') diff --git a/src/bootstrap/channel.rs b/src/bootstrap/channel.rs index 0b2f62485c9..aa683161b65 100644 --- a/src/bootstrap/channel.rs +++ b/src/bootstrap/channel.rs @@ -14,7 +14,7 @@ use crate::Build; use crate::config::Config; // The version number -pub const CFG_RELEASE_NUM: &str = "1.34.0"; +pub const CFG_RELEASE_NUM: &str = "1.35.0"; pub struct GitInfo { inner: Option, diff --git a/src/liballoc/macros.rs b/src/liballoc/macros.rs index eb341007851..dd128e096f9 100644 --- a/src/liballoc/macros.rs +++ b/src/liballoc/macros.rs @@ -34,8 +34,7 @@ #[cfg(not(test))] #[macro_export] #[stable(feature = "rust1", since = "1.0.0")] -#[cfg_attr(not(stage0), allow_internal_unstable(box_syntax))] -#[cfg_attr(stage0, allow_internal_unstable)] +#[allow_internal_unstable(box_syntax)] macro_rules! vec { ($elem:expr; $n:expr) => ( $crate::vec::from_elem($elem, $n) diff --git a/src/libcore/intrinsics.rs b/src/libcore/intrinsics.rs index e6098b1b24c..75a33394e3d 100644 --- a/src/libcore/intrinsics.rs +++ b/src/libcore/intrinsics.rs @@ -1282,13 +1282,11 @@ extern "rust-intrinsic" { /// The stabilized versions of this intrinsic are available on the integer /// primitives via the `saturating_add` method. For example, /// [`std::u32::saturating_add`](../../std/primitive.u32.html#method.saturating_add) - #[cfg(not(stage0))] pub fn saturating_add(a: T, b: T) -> T; /// Computes `a - b`, while saturating at numeric bounds. /// The stabilized versions of this intrinsic are available on the integer /// primitives via the `saturating_sub` method. For example, /// [`std::u32::saturating_sub`](../../std/primitive.u32.html#method.saturating_sub) - #[cfg(not(stage0))] pub fn saturating_sub(a: T, b: T) -> T; /// Returns the value of the discriminant for the variant in 'v', diff --git a/src/libcore/macros.rs b/src/libcore/macros.rs index fdbfa56000b..b052f59b0f5 100644 --- a/src/libcore/macros.rs +++ b/src/libcore/macros.rs @@ -1,7 +1,6 @@ /// Entry point of thread panic. For details, see `std::macros`. #[macro_export] -#[cfg_attr(not(stage0), allow_internal_unstable(core_panic, __rust_unstable_column))] -#[cfg_attr(stage0, allow_internal_unstable)] +#[allow_internal_unstable(core_panic, __rust_unstable_column)] #[stable(feature = "core", since = "1.6.0")] macro_rules! panic { () => ( @@ -422,8 +421,7 @@ macro_rules! write { /// ``` #[macro_export] #[stable(feature = "rust1", since = "1.0.0")] -#[cfg_attr(stage0, allow_internal_unstable)] -#[cfg_attr(not(stage0), allow_internal_unstable(format_args_nl))] +#[allow_internal_unstable(format_args_nl)] macro_rules! writeln { ($dst:expr) => ( write!($dst, "\n") diff --git a/src/libcore/marker.rs b/src/libcore/marker.rs index 29606cb1903..9b1ead7edd6 100644 --- a/src/libcore/marker.rs +++ b/src/libcore/marker.rs @@ -636,7 +636,7 @@ unsafe impl Freeze for &mut T {} /// [`Pin

`]: ../pin/struct.Pin.html /// [`pin module`]: ../../std/pin/index.html #[stable(feature = "pin", since = "1.33.0")] -#[cfg_attr(not(stage0), lang = "unpin")] +#[lang = "unpin"] pub auto trait Unpin {} /// A marker type which does not implement `Unpin`. diff --git a/src/libcore/num/mod.rs b/src/libcore/num/mod.rs index 6708a195f88..502e3de8c63 100644 --- a/src/libcore/num/mod.rs +++ b/src/libcore/num/mod.rs @@ -874,33 +874,6 @@ bounds instead of overflowing. Basic usage: -``` -", $Feature, "assert_eq!(100", stringify!($SelfT), ".saturating_add(1), 101); -assert_eq!(", stringify!($SelfT), "::max_value().saturating_add(100), ", stringify!($SelfT), -"::max_value());", -$EndFeature, " -```"), - #[stable(feature = "rust1", since = "1.0.0")] - #[inline] - #[cfg(stage0)] - pub fn saturating_add(self, rhs: Self) -> Self { - match self.checked_add(rhs) { - Some(x) => x, - None if rhs >= 0 => Self::max_value(), - None => Self::min_value(), - } - } - - } - - doc_comment! { - concat!("Saturating integer addition. Computes `self + rhs`, saturating at the numeric -bounds instead of overflowing. - -# Examples - -Basic usage: - ``` ", $Feature, "assert_eq!(100", stringify!($SelfT), ".saturating_add(1), 101); assert_eq!(", stringify!($SelfT), "::max_value().saturating_add(100), ", stringify!($SelfT), @@ -911,37 +884,11 @@ $EndFeature, " #[stable(feature = "rust1", since = "1.0.0")] #[rustc_const_unstable(feature = "const_saturating_int_methods")] #[inline] - #[cfg(not(stage0))] pub const fn saturating_add(self, rhs: Self) -> Self { intrinsics::saturating_add(self, rhs) } } - doc_comment! { - concat!("Saturating integer subtraction. Computes `self - rhs`, saturating at the -numeric bounds instead of overflowing. - -# Examples - -Basic usage: - -``` -", $Feature, "assert_eq!(100", stringify!($SelfT), ".saturating_sub(127), -27); -assert_eq!(", stringify!($SelfT), "::min_value().saturating_sub(100), ", stringify!($SelfT), -"::min_value());", -$EndFeature, " -```"), - #[stable(feature = "rust1", since = "1.0.0")] - #[inline] - #[cfg(stage0)] - pub fn saturating_sub(self, rhs: Self) -> Self { - match self.checked_sub(rhs) { - Some(x) => x, - None if rhs >= 0 => Self::min_value(), - None => Self::max_value(), - } - } - } doc_comment! { concat!("Saturating integer subtraction. Computes `self - rhs`, saturating at the @@ -960,7 +907,6 @@ $EndFeature, " #[stable(feature = "rust1", since = "1.0.0")] #[rustc_const_unstable(feature = "const_saturating_int_methods")] #[inline] - #[cfg(not(stage0))] pub const fn saturating_sub(self, rhs: Self) -> Self { intrinsics::saturating_sub(self, rhs) } @@ -2780,29 +2726,6 @@ the numeric bounds instead of overflowing. Basic usage: -``` -", $Feature, "assert_eq!(100", stringify!($SelfT), ".saturating_add(1), 101); -assert_eq!(200u8.saturating_add(127), 255);", $EndFeature, " -```"), - #[stable(feature = "rust1", since = "1.0.0")] - #[inline] - #[cfg(stage0)] - pub fn saturating_add(self, rhs: Self) -> Self { - match self.checked_add(rhs) { - Some(x) => x, - None => Self::max_value(), - } - } - } - - doc_comment! { - concat!("Saturating integer addition. Computes `self + rhs`, saturating at -the numeric bounds instead of overflowing. - -# Examples - -Basic usage: - ``` ", $Feature, "assert_eq!(100", stringify!($SelfT), ".saturating_add(1), 101); assert_eq!(200u8.saturating_add(127), 255);", $EndFeature, " @@ -2811,7 +2734,6 @@ assert_eq!(200u8.saturating_add(127), 255);", $EndFeature, " #[stable(feature = "rust1", since = "1.0.0")] #[rustc_const_unstable(feature = "const_saturating_int_methods")] #[inline] - #[cfg(not(stage0))] pub const fn saturating_add(self, rhs: Self) -> Self { intrinsics::saturating_add(self, rhs) } @@ -2825,29 +2747,6 @@ at the numeric bounds instead of overflowing. Basic usage: -``` -", $Feature, "assert_eq!(100", stringify!($SelfT), ".saturating_sub(27), 73); -assert_eq!(13", stringify!($SelfT), ".saturating_sub(127), 0);", $EndFeature, " -```"), - #[stable(feature = "rust1", since = "1.0.0")] - #[inline] - #[cfg(stage0)] - pub fn saturating_sub(self, rhs: Self) -> Self { - match self.checked_sub(rhs) { - Some(x) => x, - None => Self::min_value(), - } - } - } - - doc_comment! { - concat!("Saturating integer subtraction. Computes `self - rhs`, saturating -at the numeric bounds instead of overflowing. - -# Examples - -Basic usage: - ``` ", $Feature, "assert_eq!(100", stringify!($SelfT), ".saturating_sub(27), 73); assert_eq!(13", stringify!($SelfT), ".saturating_sub(127), 0);", $EndFeature, " @@ -2855,7 +2754,6 @@ assert_eq!(13", stringify!($SelfT), ".saturating_sub(127), 0);", $EndFeature, " #[stable(feature = "rust1", since = "1.0.0")] #[rustc_const_unstable(feature = "const_saturating_int_methods")] #[inline] - #[cfg(not(stage0))] pub const fn saturating_sub(self, rhs: Self) -> Self { intrinsics::saturating_sub(self, rhs) } diff --git a/src/libcore/pin.rs b/src/libcore/pin.rs index f9f20dcea9e..11e5b0adcc4 100644 --- a/src/libcore/pin.rs +++ b/src/libcore/pin.rs @@ -279,7 +279,7 @@ use ops::{Deref, DerefMut, Receiver, CoerceUnsized, DispatchFromDyn}; // implementations, are allowed because they all only use `&P`, so they cannot move // the value behind `pointer`. #[stable(feature = "pin", since = "1.33.0")] -#[cfg_attr(not(stage0), lang = "pin")] +#[lang = "pin"] #[fundamental] #[repr(transparent)] #[derive(Copy, Clone, Hash, Eq, Ord)] diff --git a/src/libcore/sync/atomic.rs b/src/libcore/sync/atomic.rs index d0ee5fa9e6b..04a49d25301 100644 --- a/src/libcore/sync/atomic.rs +++ b/src/libcore/sync/atomic.rs @@ -290,15 +290,11 @@ pub enum Ordering { /// [`AtomicBool`]: struct.AtomicBool.html #[cfg(target_has_atomic = "8")] #[stable(feature = "rust1", since = "1.0.0")] -#[cfg_attr(not(stage0), rustc_deprecated( +#[rustc_deprecated( since = "1.34.0", reason = "the `new` function is now preferred", suggestion = "AtomicBool::new(false)", -))] -#[cfg_attr(stage0, rustc_deprecated( - since = "1.34.0", - reason = "the `new` function is now preferred", -))] +)] pub const ATOMIC_BOOL_INIT: AtomicBool = AtomicBool::new(false); #[cfg(target_has_atomic = "8")] @@ -1158,15 +1154,11 @@ macro_rules! atomic_int { /// An atomic integer initialized to `0`. #[$stable_init_const] - #[cfg_attr(stage0, rustc_deprecated( - since = "1.34.0", - reason = "the `new` function is now preferred", - ))] - #[cfg_attr(not(stage0), rustc_deprecated( + #[rustc_deprecated( since = "1.34.0", reason = "the `new` function is now preferred", suggestion = $atomic_new, - ))] + )] pub const $atomic_init: $atomic_type = $atomic_type::new(0); #[$stable] diff --git a/src/librustc_data_structures/macros.rs b/src/librustc_data_structures/macros.rs index af1f2910461..029e7267c82 100644 --- a/src/librustc_data_structures/macros.rs +++ b/src/librustc_data_structures/macros.rs @@ -1,8 +1,7 @@ /// A simple static assertion macro. The first argument should be a unique /// ALL_CAPS identifier that describes the condition. #[macro_export] -#[cfg_attr(stage0, allow_internal_unstable)] -#[cfg_attr(not(stage0), allow_internal_unstable(type_ascription))] +#[allow_internal_unstable(type_ascription)] macro_rules! static_assert { ($name:ident: $test:expr) => { // Use the bool to access an array such that if the bool is false, the access diff --git a/src/libstd/macros.rs b/src/libstd/macros.rs index 281641c3c12..9d0eb2e6b1c 100644 --- a/src/libstd/macros.rs +++ b/src/libstd/macros.rs @@ -53,8 +53,7 @@ /// ``` #[macro_export] #[stable(feature = "rust1", since = "1.0.0")] -#[cfg_attr(stage0, allow_internal_unstable)] -#[cfg_attr(not(stage0), allow_internal_unstable(__rust_unstable_column, libstd_sys_internals))] +#[allow_internal_unstable(__rust_unstable_column, libstd_sys_internals)] macro_rules! panic { () => ({ panic!("explicit panic") @@ -112,8 +111,7 @@ macro_rules! panic { /// ``` #[macro_export] #[stable(feature = "rust1", since = "1.0.0")] -#[cfg_attr(stage0, allow_internal_unstable)] -#[cfg_attr(not(stage0), allow_internal_unstable(print_internals))] +#[allow_internal_unstable(print_internals)] macro_rules! print { ($($arg:tt)*) => ($crate::io::_print(format_args!($($arg)*))); } @@ -145,8 +143,7 @@ macro_rules! print { /// ``` #[macro_export] #[stable(feature = "rust1", since = "1.0.0")] -#[cfg_attr(stage0, allow_internal_unstable)] -#[cfg_attr(not(stage0), allow_internal_unstable(print_internals, format_args_nl))] +#[allow_internal_unstable(print_internals, format_args_nl)] macro_rules! println { () => (print!("\n")); ($($arg:tt)*) => ({ @@ -177,8 +174,7 @@ macro_rules! println { /// ``` #[macro_export] #[stable(feature = "eprint", since = "1.19.0")] -#[cfg_attr(stage0, allow_internal_unstable)] -#[cfg_attr(not(stage0), allow_internal_unstable(print_internals))] +#[allow_internal_unstable(print_internals)] macro_rules! eprint { ($($arg:tt)*) => ($crate::io::_eprint(format_args!($($arg)*))); } @@ -206,8 +202,7 @@ macro_rules! eprint { /// ``` #[macro_export] #[stable(feature = "eprint", since = "1.19.0")] -#[cfg_attr(stage0, allow_internal_unstable)] -#[cfg_attr(not(stage0), allow_internal_unstable(print_internals, format_args_nl))] +#[allow_internal_unstable(print_internals, format_args_nl)] macro_rules! eprintln { () => (eprint!("\n")); ($($arg:tt)*) => ({ @@ -330,8 +325,7 @@ macro_rules! dbg { /// A macro to await on an async call. #[macro_export] #[unstable(feature = "await_macro", issue = "50547")] -#[cfg_attr(stage0, allow_internal_unstable)] -#[cfg_attr(not(stage0), allow_internal_unstable(gen_future, generators))] +#[allow_internal_unstable(gen_future, generators)] #[allow_internal_unsafe] macro_rules! r#await { ($e:expr) => { { diff --git a/src/libstd/thread/local.rs b/src/libstd/thread/local.rs index d1f53734d30..3a876e05ecc 100644 --- a/src/libstd/thread/local.rs +++ b/src/libstd/thread/local.rs @@ -126,8 +126,7 @@ impl fmt::Debug for LocalKey { /// [`std::thread::LocalKey`]: ../std/thread/struct.LocalKey.html #[macro_export] #[stable(feature = "rust1", since = "1.0.0")] -#[cfg_attr(stage0, allow_internal_unstable)] -#[cfg_attr(not(stage0), allow_internal_unstable(thread_local_internals))] +#[allow_internal_unstable(thread_local_internals)] macro_rules! thread_local { // empty (base case for the recursion) () => {}; @@ -149,10 +148,7 @@ macro_rules! thread_local { reason = "should not be necessary", issue = "0")] #[macro_export] -#[cfg_attr(stage0, allow_internal_unstable)] -#[cfg_attr(not(stage0), allow_internal_unstable( - thread_local_internals, cfg_target_thread_local, thread_local, -))] +#[allow_internal_unstable(thread_local_internals, cfg_target_thread_local, thread_local)] #[allow_internal_unsafe] macro_rules! __thread_local_inner { (@key $(#[$attr:meta])* $vis:vis $name:ident, $t:ty, $init:expr) => { diff --git a/src/stage0.txt b/src/stage0.txt index a93ee6bc604..274c0f90442 100644 --- a/src/stage0.txt +++ b/src/stage0.txt @@ -12,7 +12,7 @@ # source tarball for a stable release you'll likely see `1.x.0` for rustc and # `0.x.0` for Cargo where they were released on `date`. -date: 2019-02-17 +date: 2019-02-27 rustc: beta cargo: beta -- cgit 1.4.1-3-g733a5 From 2293d2260a382146fe5ea62ce91580ad7a31178d Mon Sep 17 00:00:00 2001 From: benaryorg Date: Sun, 3 Mar 2019 15:21:52 +0100 Subject: race condition in thread local storage example The example had a potential race condition that would still pass the test. If the thread which was supposed to modify it's own thread local was slower than the instruction to modify in the main thread, then the test would pass even in case of a failure. This is would be minor if the child thread was waited for since it check using an `assert_eq` for the same thing, but vice versa. However, if the `assert_eq` failed this would trigger a panic, which is not at all caught by the example since the thread is not waited on. Signed-off-by: benaryorg --- src/libstd/thread/local.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'src/libstd/thread') diff --git a/src/libstd/thread/local.rs b/src/libstd/thread/local.rs index 3a876e05ecc..7ad6b124e3a 100644 --- a/src/libstd/thread/local.rs +++ b/src/libstd/thread/local.rs @@ -40,13 +40,16 @@ use crate::mem; /// }); /// /// // each thread starts out with the initial value of 1 -/// thread::spawn(move|| { +/// let t = thread::spawn(move|| { /// FOO.with(|f| { /// assert_eq!(*f.borrow(), 1); /// *f.borrow_mut() = 3; /// }); /// }); /// +/// // wait for the thread to complete and bail out on panic +/// t.join().unwrap(); +/// /// // we retain our original value of 2 despite the child thread /// FOO.with(|f| { /// assert_eq!(*f.borrow(), 2); -- cgit 1.4.1-3-g733a5