From 49e27f1c5f2415b01101f3c1201ebe9f37b8aaa3 Mon Sep 17 00:00:00 2001 From: Dirk Gadsden Date: Fri, 22 Jan 2016 13:38:28 -0500 Subject: [PATCH 1/2] Implement error::Error and fmt::Display for string::ParseError Fixes #31106. --- src/libcollections/string.rs | 7 +++++++ src/libstd/error.rs | 7 +++++++ 2 files changed, 14 insertions(+) diff --git a/src/libcollections/string.rs b/src/libcollections/string.rs index ad9c770a5a5c..d9cbc4488fca 100644 --- a/src/libcollections/string.rs +++ b/src/libcollections/string.rs @@ -1692,6 +1692,13 @@ fn fmt(&self, _: &mut fmt::Formatter) -> fmt::Result { } } +#[stable(feature = "str_parse_error2", since = "1.8.0")] +impl fmt::Display for ParseError { + fn fmt(&self, _: &mut fmt::Formatter) -> fmt::Result { + match *self {} + } +} + #[stable(feature = "str_parse_error", since = "1.5.0")] impl PartialEq for ParseError { fn eq(&self, _: &ParseError) -> bool { diff --git a/src/libstd/error.rs b/src/libstd/error.rs index c44a4bfe0f16..59dc0ea86492 100644 --- a/src/libstd/error.rs +++ b/src/libstd/error.rs @@ -182,6 +182,13 @@ fn description(&self) -> &str { } } +#[stable(feature = "str_parse_error2", since = "1.8.0")] +impl Error for string::ParseError { + fn description(&self) -> &str { + "parse error" + } +} + // copied from any.rs impl Error + 'static { /// Returns true if the boxed type is the same as `T` From 365deeb19a2cff74e3d215622b1ab411581b99e9 Mon Sep 17 00:00:00 2001 From: Dirk Gadsden Date: Fri, 22 Jan 2016 14:34:39 -0500 Subject: [PATCH 2/2] Simplify return for error::Error impl for string::ParseError --- src/libstd/error.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libstd/error.rs b/src/libstd/error.rs index 59dc0ea86492..ee367193e456 100644 --- a/src/libstd/error.rs +++ b/src/libstd/error.rs @@ -185,7 +185,7 @@ fn description(&self) -> &str { #[stable(feature = "str_parse_error2", since = "1.8.0")] impl Error for string::ParseError { fn description(&self) -> &str { - "parse error" + match *self {} } }