diff --git a/src/liballoc/lib.rs b/src/liballoc/lib.rs index b93e128d50819..6a96af4642c8c 100644 --- a/src/liballoc/lib.rs +++ b/src/liballoc/lib.rs @@ -102,6 +102,7 @@ #![feature(iter_rfold)] #![feature(lang_items)] #![feature(needs_allocator)] +#![cfg_attr(stage0, feature(never_type))] #![feature(nonzero)] #![feature(offset_to)] #![feature(optin_builtin_traits)] diff --git a/src/liballoc/string.rs b/src/liballoc/string.rs index dcc814173460d..81e98c1447599 100644 --- a/src/liballoc/string.rs +++ b/src/liballoc/string.rs @@ -2032,6 +2032,10 @@ impl ops::DerefMut for String { /// An error when parsing a `String`. /// +/// As of Rust 1.26, this is a type alias for [`!`]. Code that doesn't need to +/// support compilation with older compiler versions should just use that type +/// directly; this alias will be deprecated in the future. +/// /// 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 @@ -2039,12 +2043,12 @@ impl ops::DerefMut for String { /// [`String`] without error, this type will never actually be returned. As /// such, it is only here to satisfy said signature, and is useless otherwise. /// +/// [`!`]: ../../std/primitive.never.html /// [`FromStr`]: ../../std/str/trait.FromStr.html /// [`String`]: struct.String.html /// [`from_str`]: ../../std/str/trait.FromStr.html#tymethod.from_str #[stable(feature = "str_parse_error", since = "1.5.0")] -#[derive(Copy)] -pub enum ParseError {} +pub type ParseError = !; #[stable(feature = "rust1", since = "1.0.0")] impl FromStr for String { @@ -2055,37 +2059,6 @@ impl FromStr for String { } } -#[stable(feature = "str_parse_error", since = "1.5.0")] -impl Clone for ParseError { - fn clone(&self) -> ParseError { - match *self {} - } -} - -#[stable(feature = "str_parse_error", since = "1.5.0")] -impl fmt::Debug for ParseError { - fn fmt(&self, _: &mut fmt::Formatter) -> fmt::Result { - match *self {} - } -} - -#[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 { - match *self {} - } -} - -#[stable(feature = "str_parse_error", since = "1.5.0")] -impl Eq for ParseError {} - /// A trait for converting a value to a `String`. /// /// This trait is automatically implemented for any type which implements the diff --git a/src/libstd/error.rs b/src/libstd/error.rs index f8dbe193fed27..bbeaa16474ea0 100644 --- a/src/libstd/error.rs +++ b/src/libstd/error.rs @@ -311,13 +311,6 @@ impl Error for string::FromUtf16Error { } } -#[stable(feature = "str_parse_error2", since = "1.8.0")] -impl Error for string::ParseError { - fn description(&self) -> &str { - match *self {} - } -} - #[stable(feature = "decode_utf16", since = "1.9.0")] impl Error for char::DecodeUtf16Error { fn description(&self) -> &str { diff --git a/src/libstd/path.rs b/src/libstd/path.rs index ec96157547383..1a59fc93c3ff4 100644 --- a/src/libstd/path.rs +++ b/src/libstd/path.rs @@ -1442,26 +1442,10 @@ impl From for PathBuf { } } -/// Error returned from [`PathBuf::from_str`][`from_str`]. -/// -/// Note that parsing a path will never fail. This error is just a placeholder -/// for implementing `FromStr` for `PathBuf`. -/// -/// [`from_str`]: struct.PathBuf.html#method.from_str -#[derive(Debug, Clone, PartialEq, Eq)] -#[stable(feature = "path_from_str", since = "1.26.0")] -pub enum ParsePathError {} - -#[stable(feature = "path_from_str", since = "1.26.0")] -impl fmt::Display for ParsePathError { - fn fmt(&self, _: &mut fmt::Formatter) -> fmt::Result { - match *self {} - } -} - +/// Note that parsing a path will never fail. #[stable(feature = "path_from_str", since = "1.26.0")] impl FromStr for PathBuf { - type Err = ParsePathError; + type Err = !; fn from_str(s: &str) -> Result { Ok(PathBuf::from(s))