Skip to content

Commit 4d2a8c5

Browse files
committed
Simplify implementation of Display and Error for convert::Infallible.
1 parent 79f2439 commit 4d2a8c5

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

src/libcore/convert.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,9 @@ pub enum Infallible {}
6262

6363
#[unstable(feature = "try_from", issue = "33417")]
6464
impl fmt::Display for Infallible {
65-
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
66-
"an error of this type can never exist".fmt(f)
65+
fn fmt(&self, _: &mut fmt::Formatter) -> fmt::Result {
66+
match *self {
67+
}
6768
}
6869
}
6970
/// A cheap reference-to-reference conversion. Used to convert a value to a

src/libstd/error.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -351,7 +351,8 @@ impl Error for char::ParseCharError {
351351
#[unstable(feature = "try_from", issue = "33417")]
352352
impl Error for convert::Infallible {
353353
fn description(&self) -> &str {
354-
"an error of this type can never exist"
354+
match *self {
355+
}
355356
}
356357
}
357358

0 commit comments

Comments
 (0)