about summary refs log tree commit diff
path: root/src/liballoc
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2020-02-20 05:18:18 +0000
committerbors <bors@rust-lang.org>2020-02-20 05:18:18 +0000
commitde362d88ea17ab23ca2483cb798bc7aeb81a48f5 (patch)
tree8dd6303cefd9491298b85fb2a01c45b001368051 /src/liballoc
parent183e893aaae581bd0ab499ba56b6c5e118557dc7 (diff)
parent883e69db950522afb73fc9ad8ea122bacdd42ee4 (diff)
downloadrust-de362d88ea17ab23ca2483cb798bc7aeb81a48f5.tar.gz
rust-de362d88ea17ab23ca2483cb798bc7aeb81a48f5.zip
Auto merge of #67925 - petertodd:2020-fromstr-infallible, r=LukasKalbertodt
Change FromStr for String to use Infallible directly

Fixes the confusing documentation on `ParseError` by making it irrelevant.

It might be fine to mark it as depreciated right now too - I can't imagine much code uses `ParseError` directly.
Diffstat (limited to 'src/liballoc')
-rw-r--r--src/liballoc/string.rs15
1 files changed, 4 insertions, 11 deletions
diff --git a/src/liballoc/string.rs b/src/liballoc/string.rs
index 3cb1f259a0b..f5afea15d65 100644
--- a/src/liballoc/string.rs
+++ b/src/liballoc/string.rs
@@ -2106,18 +2106,11 @@ impl ops::DerefMut for String {
     }
 }
 
-/// An error when parsing a `String`.
+/// A type alias for [`Infallible`].
 ///
-/// This `enum` is slightly awkward: it will never actually exist. This error is
-/// part of the type signature of the implementation of [`FromStr`] on
-/// [`String`]. The return type of [`from_str`], requires that an error be
-/// defined, but, given that a [`String`] can always be made into a new
-/// [`String`] without error, this type will never actually be returned. As
-/// such, it is only here to satisfy said signature, and is useless otherwise.
+/// This alias exists for backwards compatibility, and may be eventually deprecated.
 ///
-/// [`FromStr`]: ../../std/str/trait.FromStr.html
-/// [`String`]: struct.String.html
-/// [`from_str`]: ../../std/str/trait.FromStr.html#tymethod.from_str
+/// [`Infallible`]: ../../core/convert/enum.Infallible.html
 #[stable(feature = "str_parse_error", since = "1.5.0")]
 pub type ParseError = core::convert::Infallible;
 
@@ -2125,7 +2118,7 @@ pub type ParseError = core::convert::Infallible;
 impl FromStr for String {
     type Err = core::convert::Infallible;
     #[inline]
-    fn from_str(s: &str) -> Result<String, ParseError> {
+    fn from_str(s: &str) -> Result<String, Self::Err> {
         Ok(String::from(s))
     }
 }