From 002c1c74d99295e49e30a02fb98f25383f1576f8 Mon Sep 17 00:00:00 2001 From: Pyry Kontio Date: Tue, 5 Nov 2019 19:16:09 +0900 Subject: Improve std::thread::Result documentation --- src/libstd/thread/mod.rs | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'src/libstd/thread') diff --git a/src/libstd/thread/mod.rs b/src/libstd/thread/mod.rs index 0ffa6ace2e4..2af0a4804ef 100644 --- a/src/libstd/thread/mod.rs +++ b/src/libstd/thread/mod.rs @@ -1271,6 +1271,18 @@ impl fmt::Debug for Thread { /// /// Indicates the manner in which a thread exited. /// +/// The value contained in the `Result::Err` variant +/// is the value the thread panicked with; +/// that is, the parameter the `panic!` macro was called with. +/// Unlike with normal errors, this value doesn't implement +/// the `std::error::Error` trait. +/// +/// Thus, a sensible way to handle a thread panic is to either +/// `unwrap` the `Result`, propagating the panic, +/// or in case the thread is intended to be a subsystem boundary +/// that is supposed to isolate system-level failures, +/// match for the `Err` variant and handle the panic in an appropriate way. +/// /// A thread that completes without panicking is considered to exit successfully. /// /// # Examples -- cgit 1.4.1-3-g733a5 From f1bc4ef170dc27f7c186e6b00de30f66eee14f6c Mon Sep 17 00:00:00 2001 From: Pyry Kontio Date: Wed, 6 Nov 2019 14:47:52 +0900 Subject: Addressed review comments. --- src/libstd/thread/mod.rs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'src/libstd/thread') diff --git a/src/libstd/thread/mod.rs b/src/libstd/thread/mod.rs index 2af0a4804ef..5a936da05fd 100644 --- a/src/libstd/thread/mod.rs +++ b/src/libstd/thread/mod.rs @@ -1273,15 +1273,15 @@ impl fmt::Debug for Thread { /// /// The value contained in the `Result::Err` variant /// is the value the thread panicked with; -/// that is, the parameter the `panic!` macro was called with. +/// that is, the argument the `panic!` macro was called with. /// Unlike with normal errors, this value doesn't implement -/// the `std::error::Error` trait. +/// the [`Error`] trait. /// -/// Thus, a sensible way to handle a thread panic is to either -/// `unwrap` the `Result`, propagating the panic, -/// or in case the thread is intended to be a subsystem boundary +/// Thus, a sensible way to handle a thread panic is to either: +/// 1. `unwrap` the `Result`, propagating the panic +/// 2. or in case the thread is intended to be a subsystem boundary /// that is supposed to isolate system-level failures, -/// match for the `Err` variant and handle the panic in an appropriate way. +/// match on the `Err` variant and handle the panic in an appropriate way. /// /// A thread that completes without panicking is considered to exit successfully. /// -- cgit 1.4.1-3-g733a5 From 4317263a311ad4adc54529b5fdcfe1e18fb651be Mon Sep 17 00:00:00 2001 From: Pyry Kontio Date: Wed, 6 Nov 2019 16:57:59 +0900 Subject: Fix the Error linking. --- src/libstd/thread/mod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/libstd/thread') diff --git a/src/libstd/thread/mod.rs b/src/libstd/thread/mod.rs index 5a936da05fd..a95ebb00714 100644 --- a/src/libstd/thread/mod.rs +++ b/src/libstd/thread/mod.rs @@ -1275,7 +1275,7 @@ impl fmt::Debug for Thread { /// is the value the thread panicked with; /// that is, the argument the `panic!` macro was called with. /// Unlike with normal errors, this value doesn't implement -/// the [`Error`] trait. +/// the [`Error`](std::error::Error) trait. /// /// Thus, a sensible way to handle a thread panic is to either: /// 1. `unwrap` the `Result`, propagating the panic -- cgit 1.4.1-3-g733a5 From 936349c81b59581c7c3a834a6b61eb94168e2807 Mon Sep 17 00:00:00 2001 From: 3442853561 <21147967+3442853561@users.noreply.github.com> Date: Wed, 6 Nov 2019 16:39:48 +0800 Subject: Update local.rs Removed parameters not used in the macro --- src/libstd/thread/local.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/libstd/thread') diff --git a/src/libstd/thread/local.rs b/src/libstd/thread/local.rs index cfaab4e22e9..46453b47fca 100644 --- a/src/libstd/thread/local.rs +++ b/src/libstd/thread/local.rs @@ -149,7 +149,7 @@ macro_rules! 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) => { + (@key $t:ty, $init:expr) => { { #[inline] fn __init() -> $t { $init } @@ -184,7 +184,7 @@ macro_rules! __thread_local_inner { }; ($(#[$attr:meta])* $vis:vis $name:ident, $t:ty, $init:expr) => { $(#[$attr])* $vis const $name: $crate::thread::LocalKey<$t> = - $crate::__thread_local_inner!(@key $(#[$attr])* $vis $name, $t, $init); + $crate::__thread_local_inner!(@key $t, $init); } } -- cgit 1.4.1-3-g733a5 From 8568204f4e934ff93817f948b13a9c804277a6bf Mon Sep 17 00:00:00 2001 From: Pyry Kontio Date: Thu, 7 Nov 2019 01:45:30 +0900 Subject: Try with crate::error::Error --- src/libstd/thread/mod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/libstd/thread') diff --git a/src/libstd/thread/mod.rs b/src/libstd/thread/mod.rs index a95ebb00714..0c632d2afbd 100644 --- a/src/libstd/thread/mod.rs +++ b/src/libstd/thread/mod.rs @@ -1275,7 +1275,7 @@ impl fmt::Debug for Thread { /// is the value the thread panicked with; /// that is, the argument the `panic!` macro was called with. /// Unlike with normal errors, this value doesn't implement -/// the [`Error`](std::error::Error) trait. +/// the [`Error`](crate::error::Error) trait. /// /// Thus, a sensible way to handle a thread panic is to either: /// 1. `unwrap` the `Result`, propagating the panic -- cgit 1.4.1-3-g733a5