about summary refs log tree commit diff
path: root/src/libcore
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2020-04-24 23:36:52 +0000
committerbors <bors@rust-lang.org>2020-04-24 23:36:52 +0000
commit40008dcb494a00571123b7d59115068a200ebe34 (patch)
tree2fd39a8435e3a41236e0820e08646e9e7a1508ea /src/libcore
parent3360cc3a0ea33c84d0b0b1163107b1c1acbf2a69 (diff)
parent32fb77d9516ec8d781b998e5d314dc7b6a7954d8 (diff)
Auto merge of #71539 - Dylan-DPC:rollup-a2vbfh9, r=Dylan-DPC
Rollup of 8 pull requests

Successful merges:

 - #69456 (fix misleading type annotation diagonstics)
 - #71330 (Only run dataflow for const qualification if type-based check would fail)
 - #71480 (Improve PanicInfo examples readability)
 - #71485 (Add BinaryHeap::retain as suggested in #42849)
 - #71512 (Remove useless "" args)
 - #71527 (Miscellaneous cleanup in `check_consts`)
 - #71534 (Avoid unused Option::map results)
 - #71535 (Fix typos in docs for keyword "in")

Failed merges:

r? @ghost
Diffstat (limited to 'src/libcore')
-rw-r--r--src/libcore/panic.rs12
1 files changed, 9 insertions, 3 deletions
diff --git a/src/libcore/panic.rs b/src/libcore/panic.rs
index dbfcbca3ffc..575f51d0a7d 100644
--- a/src/libcore/panic.rs
+++ b/src/libcore/panic.rs
@@ -77,7 +77,11 @@ impl<'a> PanicInfo<'a> {
     /// use std::panic;
     ///
     /// panic::set_hook(Box::new(|panic_info| {
-    ///     println!("panic occurred: {:?}", panic_info.payload().downcast_ref::<&str>().unwrap());
+    ///     if let Some(s) = panic_info.payload().downcast_ref::<&str>() {
+    ///         println!("panic occurred: {:?}", s);
+    ///     } else {
+    ///         println!("panic occurred");
+    ///     }
     /// }));
     ///
     /// panic!("Normal panic");
@@ -112,8 +116,10 @@ impl<'a> PanicInfo<'a> {
     ///
     /// panic::set_hook(Box::new(|panic_info| {
     ///     if let Some(location) = panic_info.location() {
-    ///         println!("panic occurred in file '{}' at line {}", location.file(),
-    ///             location.line());
+    ///         println!("panic occurred in file '{}' at line {}",
+    ///             location.file(),
+    ///             location.line(),
+    ///         );
     ///     } else {
     ///         println!("panic occurred but can't get location information...");
     ///     }