From 79f2439aa698c7eefa089ad05027826d7911780f Mon Sep 17 00:00:00 2001 From: Jimmy Cuadra Date: Thu, 21 Sep 2017 21:03:40 -0700 Subject: [PATCH] Impl fmt::Display for convert::Infallible. --- src/libcore/convert.rs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/libcore/convert.rs b/src/libcore/convert.rs index 9730de0efe9e..6eb499ad8ab2 100644 --- a/src/libcore/convert.rs +++ b/src/libcore/convert.rs @@ -48,6 +48,8 @@ #![stable(feature = "rust1", since = "1.0.0")] +use fmt; + /// A type used as the error type for implementations of fallible conversion /// traits in cases where conversions cannot actually fail. /// @@ -58,6 +60,12 @@ #[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)] 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) + } +} /// A cheap reference-to-reference conversion. Used to convert a value to a /// reference value within generic code. ///