Skip to content

Commit 96ee0ba

Browse files
committed
Auto merge of #60204 - jethrogb:jb/rtunwrap-debug-print, r=alexcrichton
Debug-print error when using rtunwrap When I added this macro a while back I didn't have a way to make it print the failure for all types that you might want to unwrap. Now, I came up with a solution.
2 parents 7c71bc3 + 942831e commit 96ee0ba

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

src/libstd/sys_common/mod.rs

+6-4
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,12 @@ macro_rules! rtassert {
3030

3131
#[allow(unused_macros)] // not used on all platforms
3232
macro_rules! rtunwrap {
33-
($ok:ident, $e:expr) => (if let $ok(v) = $e {
34-
v
35-
} else {
36-
rtabort!(concat!("unwrap failed: ", stringify!($e)));
33+
($ok:ident, $e:expr) => (match $e {
34+
$ok(v) => v,
35+
ref err => {
36+
let err = err.as_ref().map(|_|()); // map Ok/Some which might not be Debug
37+
rtabort!(concat!("unwrap failed: ", stringify!($e), " = {:?}"), err)
38+
},
3739
})
3840
}
3941

0 commit comments

Comments
 (0)