diff options
| author | Sean McArthur <sean.monstar@gmail.com> | 2015-03-30 17:56:48 -0700 |
|---|---|---|
| committer | Sean McArthur <sean.monstar@gmail.com> | 2015-03-30 18:08:58 -0700 |
| commit | e17f4fc1d4545f5c17b21805c5145b05495484ee (patch) | |
| tree | 73738e0f820177de7d6052ad15e01c868d7a24ae /src/libstd | |
| parent | 9de34a84bb300bab1bf0227f577331620cd60511 (diff) | |
| download | rust-e17f4fc1d4545f5c17b21805c5145b05495484ee.tar.gz rust-e17f4fc1d4545f5c17b21805c5145b05495484ee.zip | |
convert: remove FromError, use From<E> instead
This removes the FromError trait, since it can now be expressed using the new convert::Into trait. All implementations of FromError<E> where changed to From<E>, and `try!` was changed to use From::from instead. Because this removes FromError, it is a breaking change, but fixing it simply requires changing the words `FromError` to `From`, and `from_error` to `from`. [breaking-change]
Diffstat (limited to 'src/libstd')
| -rw-r--r-- | src/libstd/ffi/c_str.rs | 10 | ||||
| -rw-r--r-- | src/libstd/io/buffered.rs | 6 | ||||
| -rw-r--r-- | src/libstd/macros.rs | 2 | ||||
| -rw-r--r-- | src/libstd/os.rs | 2 | ||||
| -rw-r--r-- | src/libstd/sync/poison.rs | 6 |
5 files changed, 13 insertions, 13 deletions
diff --git a/src/libstd/ffi/c_str.rs b/src/libstd/ffi/c_str.rs index a00f7708025..f5c7d1d18d5 100644 --- a/src/libstd/ffi/c_str.rs +++ b/src/libstd/ffi/c_str.rs @@ -12,7 +12,7 @@ use convert::Into; use cmp::{PartialEq, Eq, PartialOrd, Ord, Ordering}; -use error::{Error, FromError}; +use error::Error; use fmt; use io; use iter::Iterator; @@ -298,8 +298,8 @@ impl fmt::Display for NulError { } #[stable(feature = "rust1", since = "1.0.0")] -impl FromError<NulError> for io::Error { - fn from_error(_: NulError) -> io::Error { +impl From<NulError> for io::Error { + fn from(_: NulError) -> io::Error { io::Error::new(io::ErrorKind::InvalidInput, "data provided contains a nul byte", None) } @@ -307,8 +307,8 @@ impl FromError<NulError> for io::Error { #[stable(feature = "rust1", since = "1.0.0")] #[allow(deprecated)] -impl FromError<NulError> for old_io::IoError { - fn from_error(_: NulError) -> old_io::IoError { +impl From<NulError> for old_io::IoError { + fn from(_: NulError) -> old_io::IoError { old_io::IoError { kind: old_io::IoErrorKind::InvalidInput, desc: "data provided contains a nul byte", diff --git a/src/libstd/io/buffered.rs b/src/libstd/io/buffered.rs index 98581fc43f8..f03ed7a3dde 100644 --- a/src/libstd/io/buffered.rs +++ b/src/libstd/io/buffered.rs @@ -16,7 +16,7 @@ use prelude::v1::*; use io::prelude::*; use cmp; -use error::{self, FromError}; +use error; use fmt; use io::{self, DEFAULT_BUF_SIZE, Error, ErrorKind}; use ptr; @@ -264,8 +264,8 @@ impl<W> IntoInnerError<W> { } #[stable(feature = "rust1", since = "1.0.0")] -impl<W> FromError<IntoInnerError<W>> for Error { - fn from_error(iie: IntoInnerError<W>) -> Error { iie.1 } +impl<W> From<IntoInnerError<W>> for Error { + fn from(iie: IntoInnerError<W>) -> Error { iie.1 } } #[stable(feature = "rust1", since = "1.0.0")] diff --git a/src/libstd/macros.rs b/src/libstd/macros.rs index 52492a019a2..88106811093 100644 --- a/src/libstd/macros.rs +++ b/src/libstd/macros.rs @@ -97,7 +97,7 @@ macro_rules! try { ($expr:expr) => (match $expr { $crate::result::Result::Ok(val) => val, $crate::result::Result::Err(err) => { - return $crate::result::Result::Err($crate::error::FromError::from_error(err)) + return $crate::result::Result::Err($crate::convert::From::from(err)) } }) } diff --git a/src/libstd/os.rs b/src/libstd/os.rs index e19c734b8a3..9aebdbe9eec 100644 --- a/src/libstd/os.rs +++ b/src/libstd/os.rs @@ -40,7 +40,7 @@ use boxed::Box; use clone::Clone; use convert::From; use env; -use error::{FromError, Error}; +use error::Error; use ffi::{OsString, OsStr}; use fmt; use iter::Iterator; diff --git a/src/libstd/sync/poison.rs b/src/libstd/sync/poison.rs index c07c83d37f4..cea2def30f1 100644 --- a/src/libstd/sync/poison.rs +++ b/src/libstd/sync/poison.rs @@ -11,7 +11,7 @@ use prelude::v1::*; use cell::UnsafeCell; -use error::{Error, FromError}; +use error::{Error}; use fmt; use thread; @@ -144,8 +144,8 @@ impl<T> PoisonError<T> { pub fn get_mut(&mut self) -> &mut T { &mut self.guard } } -impl<T> FromError<PoisonError<T>> for TryLockError<T> { - fn from_error(err: PoisonError<T>) -> TryLockError<T> { +impl<T> From<PoisonError<T>> for TryLockError<T> { + fn from(err: PoisonError<T>) -> TryLockError<T> { TryLockError::Poisoned(err) } } |
