Skip to content

Commit 955979a

Browse files
committed
Make cold unwraps take &dyn Debug
1 parent 5a7e730 commit 955979a

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

Diff for: src/libcore/option.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -1011,7 +1011,7 @@ impl<T: fmt::Debug> Option<T> {
10111011
#[unstable(feature = "option_expect_none", reason = "newly added", issue = "0")]
10121012
pub fn expect_none(self, msg: &str) {
10131013
if let Some(val) = self {
1014-
expect_none_failed(msg, val);
1014+
expect_none_failed(msg, &val);
10151015
}
10161016
}
10171017

@@ -1053,7 +1053,7 @@ impl<T: fmt::Debug> Option<T> {
10531053
#[unstable(feature = "option_unwrap_none", reason = "newly added", issue = "0")]
10541054
pub fn unwrap_none(self) {
10551055
if let Some(val) = self {
1056-
expect_none_failed("called `Option::unwrap_none()` on a `Some` value", val);
1056+
expect_none_failed("called `Option::unwrap_none()` on a `Some` value", &val);
10571057
}
10581058
}
10591059
}
@@ -1153,7 +1153,7 @@ fn expect_failed(msg: &str) -> ! {
11531153
// This is a separate function to reduce the code size of .expect_none() itself.
11541154
#[inline(never)]
11551155
#[cold]
1156-
fn expect_none_failed<T: fmt::Debug>(msg: &str, value: T) -> ! {
1156+
fn expect_none_failed(msg: &str, value: &dyn fmt::Debug) -> ! {
11571157
panic!("{}: {:?}", msg, value)
11581158
}
11591159

Diff for: src/libcore/result.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -849,7 +849,7 @@ impl<T, E: fmt::Debug> Result<T, E> {
849849
pub fn unwrap(self) -> T {
850850
match self {
851851
Ok(t) => t,
852-
Err(e) => unwrap_failed("called `Result::unwrap()` on an `Err` value", e),
852+
Err(e) => unwrap_failed("called `Result::unwrap()` on an `Err` value", &e),
853853
}
854854
}
855855

@@ -876,7 +876,7 @@ impl<T, E: fmt::Debug> Result<T, E> {
876876
pub fn expect(self, msg: &str) -> T {
877877
match self {
878878
Ok(t) => t,
879-
Err(e) => unwrap_failed(msg, e),
879+
Err(e) => unwrap_failed(msg, &e),
880880
}
881881
}
882882
}
@@ -908,7 +908,7 @@ impl<T: fmt::Debug, E> Result<T, E> {
908908
#[stable(feature = "rust1", since = "1.0.0")]
909909
pub fn unwrap_err(self) -> E {
910910
match self {
911-
Ok(t) => unwrap_failed("called `Result::unwrap_err()` on an `Ok` value", t),
911+
Ok(t) => unwrap_failed("called `Result::unwrap_err()` on an `Ok` value", &t),
912912
Err(e) => e,
913913
}
914914
}
@@ -935,7 +935,7 @@ impl<T: fmt::Debug, E> Result<T, E> {
935935
#[stable(feature = "result_expect_err", since = "1.17.0")]
936936
pub fn expect_err(self, msg: &str) -> E {
937937
match self {
938-
Ok(t) => unwrap_failed(msg, t),
938+
Ok(t) => unwrap_failed(msg, &t),
939939
Err(e) => e,
940940
}
941941
}
@@ -1047,7 +1047,7 @@ impl<T, E> Result<Option<T>, E> {
10471047
// This is a separate function to reduce the code size of the methods
10481048
#[inline(never)]
10491049
#[cold]
1050-
fn unwrap_failed<E: fmt::Debug>(msg: &str, error: E) -> ! {
1050+
fn unwrap_failed(msg: &str, error: &dyn fmt::Debug) -> ! {
10511051
panic!("{}: {:?}", msg, error)
10521052
}
10531053

0 commit comments

Comments
 (0)