From 955979ab287037f8c1972dfc53c54f0677db04c6 Mon Sep 17 00:00:00 2001 From: Josh Stone Date: Thu, 11 Jul 2019 12:40:38 -0700 Subject: [PATCH] Make cold unwraps take &dyn Debug --- src/libcore/option.rs | 6 +++--- src/libcore/result.rs | 10 +++++----- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/libcore/option.rs b/src/libcore/option.rs index 6156b4cd393..237994a83cf 100644 --- a/src/libcore/option.rs +++ b/src/libcore/option.rs @@ -1011,7 +1011,7 @@ impl Option { #[unstable(feature = "option_expect_none", reason = "newly added", issue = "0")] pub fn expect_none(self, msg: &str) { if let Some(val) = self { - expect_none_failed(msg, val); + expect_none_failed(msg, &val); } } @@ -1053,7 +1053,7 @@ pub fn expect_none(self, msg: &str) { #[unstable(feature = "option_unwrap_none", reason = "newly added", issue = "0")] pub fn unwrap_none(self) { if let Some(val) = self { - expect_none_failed("called `Option::unwrap_none()` on a `Some` value", val); + expect_none_failed("called `Option::unwrap_none()` on a `Some` value", &val); } } } @@ -1153,7 +1153,7 @@ fn expect_failed(msg: &str) -> ! { // This is a separate function to reduce the code size of .expect_none() itself. #[inline(never)] #[cold] -fn expect_none_failed(msg: &str, value: T) -> ! { +fn expect_none_failed(msg: &str, value: &dyn fmt::Debug) -> ! { panic!("{}: {:?}", msg, value) } diff --git a/src/libcore/result.rs b/src/libcore/result.rs index b64ad149cf4..14980ce1cff 100644 --- a/src/libcore/result.rs +++ b/src/libcore/result.rs @@ -849,7 +849,7 @@ impl Result { pub fn unwrap(self) -> T { match self { Ok(t) => t, - Err(e) => unwrap_failed("called `Result::unwrap()` on an `Err` value", e), + Err(e) => unwrap_failed("called `Result::unwrap()` on an `Err` value", &e), } } @@ -876,7 +876,7 @@ pub fn unwrap(self) -> T { pub fn expect(self, msg: &str) -> T { match self { Ok(t) => t, - Err(e) => unwrap_failed(msg, e), + Err(e) => unwrap_failed(msg, &e), } } } @@ -908,7 +908,7 @@ impl Result { #[stable(feature = "rust1", since = "1.0.0")] pub fn unwrap_err(self) -> E { match self { - Ok(t) => unwrap_failed("called `Result::unwrap_err()` on an `Ok` value", t), + Ok(t) => unwrap_failed("called `Result::unwrap_err()` on an `Ok` value", &t), Err(e) => e, } } @@ -935,7 +935,7 @@ pub fn unwrap_err(self) -> E { #[stable(feature = "result_expect_err", since = "1.17.0")] pub fn expect_err(self, msg: &str) -> E { match self { - Ok(t) => unwrap_failed(msg, t), + Ok(t) => unwrap_failed(msg, &t), Err(e) => e, } } @@ -1047,7 +1047,7 @@ pub fn transpose(self) -> Option> { // This is a separate function to reduce the code size of the methods #[inline(never)] #[cold] -fn unwrap_failed(msg: &str, error: E) -> ! { +fn unwrap_failed(msg: &str, error: &dyn fmt::Debug) -> ! { panic!("{}: {:?}", msg, error) } -- 2.44.0