From 002c1c74d99295e49e30a02fb98f25383f1576f8 Mon Sep 17 00:00:00 2001 From: Pyry Kontio Date: Tue, 5 Nov 2019 19:16:09 +0900 Subject: [PATCH 1/4] Improve std::thread::Result documentation --- src/libstd/thread/mod.rs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/libstd/thread/mod.rs b/src/libstd/thread/mod.rs index 0ffa6ace2e4d2..2af0a4804ef42 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 From f1bc4ef170dc27f7c186e6b00de30f66eee14f6c Mon Sep 17 00:00:00 2001 From: Pyry Kontio Date: Wed, 6 Nov 2019 14:47:52 +0900 Subject: [PATCH 2/4] Addressed review comments. --- src/libstd/thread/mod.rs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/libstd/thread/mod.rs b/src/libstd/thread/mod.rs index 2af0a4804ef42..5a936da05fd48 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. /// From 4317263a311ad4adc54529b5fdcfe1e18fb651be Mon Sep 17 00:00:00 2001 From: Pyry Kontio Date: Wed, 6 Nov 2019 16:57:59 +0900 Subject: [PATCH 3/4] Fix the Error linking. --- src/libstd/thread/mod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libstd/thread/mod.rs b/src/libstd/thread/mod.rs index 5a936da05fd48..a95ebb00714cb 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 From 8568204f4e934ff93817f948b13a9c804277a6bf Mon Sep 17 00:00:00 2001 From: Pyry Kontio Date: Thu, 7 Nov 2019 01:45:30 +0900 Subject: [PATCH 4/4] Try with crate::error::Error --- src/libstd/thread/mod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libstd/thread/mod.rs b/src/libstd/thread/mod.rs index a95ebb00714cb..0c632d2afbdd4 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