From 9562981b0b6dc2d7ae6070732778623a59cfdd0a Mon Sep 17 00:00:00 2001 From: Jimmy Cuadra Date: Thu, 21 Sep 2017 20:21:54 -0700 Subject: impl std::error::Error for convert::Infallible. --- src/libstd/error.rs | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'src/libstd/error.rs') diff --git a/src/libstd/error.rs b/src/libstd/error.rs index 401552a6ec4..5cb2b00334d 100644 --- a/src/libstd/error.rs +++ b/src/libstd/error.rs @@ -55,6 +55,7 @@ use alloc::allocator; use any::TypeId; use cell; use char; +use convert; use fmt::{self, Debug, Display}; use mem::transmute; use num; @@ -347,6 +348,12 @@ impl Error for char::ParseCharError { } } +#[unstable(feature = "try_from", issue = "33417")] +impl Error for convert::Infallible { + fn description(&self) -> &str { + "an error of this type can never exist" + } +} // copied from any.rs impl Error + 'static { -- cgit 1.4.1-3-g733a5 From 4d2a8c527880a56db3b410450fa2b6cbf0cbe3a8 Mon Sep 17 00:00:00 2001 From: Jimmy Cuadra Date: Sat, 23 Sep 2017 17:08:16 -0700 Subject: Simplify implementation of Display and Error for convert::Infallible. --- src/libcore/convert.rs | 5 +++-- src/libstd/error.rs | 3 ++- 2 files changed, 5 insertions(+), 3 deletions(-) (limited to 'src/libstd/error.rs') diff --git a/src/libcore/convert.rs b/src/libcore/convert.rs index 6eb499ad8ab..e815d72d366 100644 --- a/src/libcore/convert.rs +++ b/src/libcore/convert.rs @@ -62,8 +62,9 @@ pub enum Infallible {} #[unstable(feature = "try_from", issue = "33417")] impl fmt::Display for Infallible { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - "an error of this type can never exist".fmt(f) + fn fmt(&self, _: &mut fmt::Formatter) -> fmt::Result { + match *self { + } } } /// A cheap reference-to-reference conversion. Used to convert a value to a diff --git a/src/libstd/error.rs b/src/libstd/error.rs index 5cb2b00334d..6a4de4ecbff 100644 --- a/src/libstd/error.rs +++ b/src/libstd/error.rs @@ -351,7 +351,8 @@ impl Error for char::ParseCharError { #[unstable(feature = "try_from", issue = "33417")] impl Error for convert::Infallible { fn description(&self) -> &str { - "an error of this type can never exist" + match *self { + } } } -- cgit 1.4.1-3-g733a5