Revert "Stabilize the TryFrom and TryInto traits"
This reverts commit e53a2a7274
.
This commit is contained in:
parent
aaefa947ac
commit
d141fdc3bf
11 changed files with 28 additions and 27 deletions
|
@ -59,7 +59,7 @@ unsafe impl<T, A: Unsize<[T]>> FixedSizeArray<T> for A {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// The error type returned when a conversion from a slice to an array fails.
|
/// The error type returned when a conversion from a slice to an array fails.
|
||||||
#[stable(feature = "try_from", since = "1.26.0")]
|
#[unstable(feature = "try_from", issue = "33417")]
|
||||||
#[derive(Debug, Copy, Clone)]
|
#[derive(Debug, Copy, Clone)]
|
||||||
pub struct TryFromSliceError(());
|
pub struct TryFromSliceError(());
|
||||||
|
|
||||||
|
@ -148,7 +148,7 @@ macro_rules! array_impls {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[stable(feature = "try_from", since = "1.26.0")]
|
#[unstable(feature = "try_from", issue = "33417")]
|
||||||
impl<'a, T> TryFrom<&'a [T]> for &'a [T; $N] {
|
impl<'a, T> TryFrom<&'a [T]> for &'a [T; $N] {
|
||||||
type Error = TryFromSliceError;
|
type Error = TryFromSliceError;
|
||||||
|
|
||||||
|
@ -162,7 +162,7 @@ macro_rules! array_impls {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[stable(feature = "try_from", since = "1.26.0")]
|
#[unstable(feature = "try_from", issue = "33417")]
|
||||||
impl<'a, T> TryFrom<&'a mut [T]> for &'a mut [T; $N] {
|
impl<'a, T> TryFrom<&'a mut [T]> for &'a mut [T; $N] {
|
||||||
type Error = TryFromSliceError;
|
type Error = TryFromSliceError;
|
||||||
|
|
||||||
|
|
|
@ -204,7 +204,7 @@ impl FromStr for char {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#[stable(feature = "try_from", since = "1.26.0")]
|
#[unstable(feature = "try_from", issue = "33417")]
|
||||||
impl TryFrom<u32> for char {
|
impl TryFrom<u32> for char {
|
||||||
type Error = CharTryFromError;
|
type Error = CharTryFromError;
|
||||||
|
|
||||||
|
@ -219,11 +219,11 @@ impl TryFrom<u32> for char {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// The error type returned when a conversion from u32 to char fails.
|
/// The error type returned when a conversion from u32 to char fails.
|
||||||
#[stable(feature = "try_from", since = "1.26.0")]
|
#[unstable(feature = "try_from", issue = "33417")]
|
||||||
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
|
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
|
||||||
pub struct CharTryFromError(());
|
pub struct CharTryFromError(());
|
||||||
|
|
||||||
#[stable(feature = "try_from", since = "1.26.0")]
|
#[unstable(feature = "try_from", issue = "33417")]
|
||||||
impl fmt::Display for CharTryFromError {
|
impl fmt::Display for CharTryFromError {
|
||||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||||
"converted integer out of range for `char`".fmt(f)
|
"converted integer out of range for `char`".fmt(f)
|
||||||
|
|
|
@ -40,7 +40,7 @@ pub use self::convert::{from_u32, from_digit};
|
||||||
pub use self::convert::from_u32_unchecked;
|
pub use self::convert::from_u32_unchecked;
|
||||||
#[stable(feature = "char_from_str", since = "1.20.0")]
|
#[stable(feature = "char_from_str", since = "1.20.0")]
|
||||||
pub use self::convert::ParseCharError;
|
pub use self::convert::ParseCharError;
|
||||||
#[stable(feature = "try_from", since = "1.26.0")]
|
#[unstable(feature = "try_from", issue = "33417")]
|
||||||
pub use self::convert::CharTryFromError;
|
pub use self::convert::CharTryFromError;
|
||||||
#[stable(feature = "decode_utf16", since = "1.9.0")]
|
#[stable(feature = "decode_utf16", since = "1.9.0")]
|
||||||
pub use self::decode::{decode_utf16, DecodeUtf16, DecodeUtf16Error};
|
pub use self::decode::{decode_utf16, DecodeUtf16, DecodeUtf16Error};
|
||||||
|
|
|
@ -322,26 +322,22 @@ pub trait From<T>: Sized {
|
||||||
///
|
///
|
||||||
/// [`TryFrom`]: trait.TryFrom.html
|
/// [`TryFrom`]: trait.TryFrom.html
|
||||||
/// [`Into`]: trait.Into.html
|
/// [`Into`]: trait.Into.html
|
||||||
#[stable(feature = "try_from", since = "1.26.0")]
|
#[unstable(feature = "try_from", issue = "33417")]
|
||||||
pub trait TryInto<T>: Sized {
|
pub trait TryInto<T>: Sized {
|
||||||
/// The type returned in the event of a conversion error.
|
/// The type returned in the event of a conversion error.
|
||||||
#[stable(feature = "try_from", since = "1.26.0")]
|
|
||||||
type Error;
|
type Error;
|
||||||
|
|
||||||
/// Performs the conversion.
|
/// Performs the conversion.
|
||||||
#[stable(feature = "try_from", since = "1.26.0")]
|
|
||||||
fn try_into(self) -> Result<T, Self::Error>;
|
fn try_into(self) -> Result<T, Self::Error>;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Attempt to construct `Self` via a conversion.
|
/// Attempt to construct `Self` via a conversion.
|
||||||
#[stable(feature = "try_from", since = "1.26.0")]
|
#[unstable(feature = "try_from", issue = "33417")]
|
||||||
pub trait TryFrom<T>: Sized {
|
pub trait TryFrom<T>: Sized {
|
||||||
/// The type returned in the event of a conversion error.
|
/// The type returned in the event of a conversion error.
|
||||||
#[stable(feature = "try_from", since = "1.26.0")]
|
|
||||||
type Error;
|
type Error;
|
||||||
|
|
||||||
/// Performs the conversion.
|
/// Performs the conversion.
|
||||||
#[stable(feature = "try_from", since = "1.26.0")]
|
|
||||||
fn try_from(value: T) -> Result<Self, Self::Error>;
|
fn try_from(value: T) -> Result<Self, Self::Error>;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -409,7 +405,7 @@ impl<T> From<T> for T {
|
||||||
|
|
||||||
|
|
||||||
// TryFrom implies TryInto
|
// TryFrom implies TryInto
|
||||||
#[stable(feature = "try_from", since = "1.26.0")]
|
#[unstable(feature = "try_from", issue = "33417")]
|
||||||
impl<T, U> TryInto<U> for T where U: TryFrom<T>
|
impl<T, U> TryInto<U> for T where U: TryFrom<T>
|
||||||
{
|
{
|
||||||
type Error = U::Error;
|
type Error = U::Error;
|
||||||
|
@ -421,7 +417,7 @@ impl<T, U> TryInto<U> for T where U: TryFrom<T>
|
||||||
|
|
||||||
// Infallible conversions are semantically equivalent to fallible conversions
|
// Infallible conversions are semantically equivalent to fallible conversions
|
||||||
// with an uninhabited error type.
|
// with an uninhabited error type.
|
||||||
#[stable(feature = "try_from", since = "1.26.0")]
|
#[unstable(feature = "try_from", issue = "33417")]
|
||||||
impl<T, U> TryFrom<U> for T where T: From<U> {
|
impl<T, U> TryFrom<U> for T where T: From<U> {
|
||||||
type Error = !;
|
type Error = !;
|
||||||
|
|
||||||
|
|
|
@ -4192,7 +4192,7 @@ macro_rules! from_str_radix_int_impl {
|
||||||
from_str_radix_int_impl! { isize i8 i16 i32 i64 i128 usize u8 u16 u32 u64 u128 }
|
from_str_radix_int_impl! { isize i8 i16 i32 i64 i128 usize u8 u16 u32 u64 u128 }
|
||||||
|
|
||||||
/// The error type returned when a checked integral type conversion fails.
|
/// The error type returned when a checked integral type conversion fails.
|
||||||
#[stable(feature = "try_from", since = "1.26.0")]
|
#[unstable(feature = "try_from", issue = "33417")]
|
||||||
#[derive(Debug, Copy, Clone)]
|
#[derive(Debug, Copy, Clone)]
|
||||||
pub struct TryFromIntError(());
|
pub struct TryFromIntError(());
|
||||||
|
|
||||||
|
@ -4207,14 +4207,14 @@ impl TryFromIntError {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[stable(feature = "try_from", since = "1.26.0")]
|
#[unstable(feature = "try_from", issue = "33417")]
|
||||||
impl fmt::Display for TryFromIntError {
|
impl fmt::Display for TryFromIntError {
|
||||||
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
|
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
|
||||||
self.__description().fmt(fmt)
|
self.__description().fmt(fmt)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[stable(feature = "try_from", since = "1.26.0")]
|
#[unstable(feature = "try_from", issue = "33417")]
|
||||||
impl From<!> for TryFromIntError {
|
impl From<!> for TryFromIntError {
|
||||||
fn from(never: !) -> TryFromIntError {
|
fn from(never: !) -> TryFromIntError {
|
||||||
never
|
never
|
||||||
|
@ -4224,7 +4224,7 @@ impl From<!> for TryFromIntError {
|
||||||
// only negative bounds
|
// only negative bounds
|
||||||
macro_rules! try_from_lower_bounded {
|
macro_rules! try_from_lower_bounded {
|
||||||
($source:ty, $($target:ty),*) => {$(
|
($source:ty, $($target:ty),*) => {$(
|
||||||
#[stable(feature = "try_from", since = "1.26.0")]
|
#[unstable(feature = "try_from", issue = "33417")]
|
||||||
impl TryFrom<$source> for $target {
|
impl TryFrom<$source> for $target {
|
||||||
type Error = TryFromIntError;
|
type Error = TryFromIntError;
|
||||||
|
|
||||||
|
@ -4243,7 +4243,7 @@ macro_rules! try_from_lower_bounded {
|
||||||
// unsigned to signed (only positive bound)
|
// unsigned to signed (only positive bound)
|
||||||
macro_rules! try_from_upper_bounded {
|
macro_rules! try_from_upper_bounded {
|
||||||
($source:ty, $($target:ty),*) => {$(
|
($source:ty, $($target:ty),*) => {$(
|
||||||
#[stable(feature = "try_from", since = "1.26.0")]
|
#[unstable(feature = "try_from", issue = "33417")]
|
||||||
impl TryFrom<$source> for $target {
|
impl TryFrom<$source> for $target {
|
||||||
type Error = TryFromIntError;
|
type Error = TryFromIntError;
|
||||||
|
|
||||||
|
@ -4262,7 +4262,7 @@ macro_rules! try_from_upper_bounded {
|
||||||
// all other cases
|
// all other cases
|
||||||
macro_rules! try_from_both_bounded {
|
macro_rules! try_from_both_bounded {
|
||||||
($source:ty, $($target:ty),*) => {$(
|
($source:ty, $($target:ty),*) => {$(
|
||||||
#[stable(feature = "try_from", since = "1.26.0")]
|
#[unstable(feature = "try_from", issue = "33417")]
|
||||||
impl TryFrom<$source> for $target {
|
impl TryFrom<$source> for $target {
|
||||||
type Error = TryFromIntError;
|
type Error = TryFromIntError;
|
||||||
|
|
||||||
|
|
|
@ -36,6 +36,7 @@
|
||||||
#![feature(str_internals)]
|
#![feature(str_internals)]
|
||||||
#![feature(test)]
|
#![feature(test)]
|
||||||
#![feature(trusted_len)]
|
#![feature(trusted_len)]
|
||||||
|
#![feature(try_from)]
|
||||||
#![feature(try_trait)]
|
#![feature(try_trait)]
|
||||||
#![feature(exact_chunks)]
|
#![feature(exact_chunks)]
|
||||||
#![cfg_attr(stage0, feature(atomic_nand))]
|
#![cfg_attr(stage0, feature(atomic_nand))]
|
||||||
|
|
|
@ -45,6 +45,7 @@
|
||||||
html_root_url = "https://doc.rust-lang.org/nightly/")]
|
html_root_url = "https://doc.rust-lang.org/nightly/")]
|
||||||
#![forbid(unsafe_code)]
|
#![forbid(unsafe_code)]
|
||||||
|
|
||||||
|
#![feature(try_from)]
|
||||||
// See librustc_cratesio_shim/Cargo.toml for a comment explaining this.
|
// See librustc_cratesio_shim/Cargo.toml for a comment explaining this.
|
||||||
#[allow(unused_extern_crates)]
|
#[allow(unused_extern_crates)]
|
||||||
extern crate rustc_cratesio_shim;
|
extern crate rustc_cratesio_shim;
|
||||||
|
|
|
@ -284,14 +284,14 @@ impl Error for num::ParseIntError {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[stable(feature = "try_from", since = "1.26.0")]
|
#[unstable(feature = "try_from", issue = "33417")]
|
||||||
impl Error for num::TryFromIntError {
|
impl Error for num::TryFromIntError {
|
||||||
fn description(&self) -> &str {
|
fn description(&self) -> &str {
|
||||||
self.__description()
|
self.__description()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[stable(feature = "try_from", since = "1.26.0")]
|
#[unstable(feature = "try_from", issue = "33417")]
|
||||||
impl Error for array::TryFromSliceError {
|
impl Error for array::TryFromSliceError {
|
||||||
fn description(&self) -> &str {
|
fn description(&self) -> &str {
|
||||||
self.__description()
|
self.__description()
|
||||||
|
@ -365,7 +365,7 @@ impl Error for cell::BorrowMutError {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[stable(feature = "try_from", since = "1.26.0")]
|
#[unstable(feature = "try_from", issue = "33417")]
|
||||||
impl Error for char::CharTryFromError {
|
impl Error for char::CharTryFromError {
|
||||||
fn description(&self) -> &str {
|
fn description(&self) -> &str {
|
||||||
"converted integer out of range for `char`"
|
"converted integer out of range for `char`"
|
||||||
|
|
|
@ -307,6 +307,7 @@
|
||||||
#![feature(test, rustc_private)]
|
#![feature(test, rustc_private)]
|
||||||
#![feature(thread_local)]
|
#![feature(thread_local)]
|
||||||
#![feature(toowned_clone_into)]
|
#![feature(toowned_clone_into)]
|
||||||
|
#![feature(try_from)]
|
||||||
#![feature(try_reserve)]
|
#![feature(try_reserve)]
|
||||||
#![feature(unboxed_closures)]
|
#![feature(unboxed_closures)]
|
||||||
#![feature(untagged_unions)]
|
#![feature(untagged_unions)]
|
||||||
|
|
|
@ -8,6 +8,8 @@
|
||||||
// option. This file may not be copied, modified, or distributed
|
// option. This file may not be copied, modified, or distributed
|
||||||
// except according to those terms.
|
// except according to those terms.
|
||||||
|
|
||||||
|
#![feature(try_from)]
|
||||||
|
|
||||||
use std::marker::PhantomData;
|
use std::marker::PhantomData;
|
||||||
use std::convert::{TryFrom, AsRef};
|
use std::convert::{TryFrom, AsRef};
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
error[E0119]: conflicting implementations of trait `std::convert::AsRef<Q>` for type `std::boxed::Box<Q>`:
|
error[E0119]: conflicting implementations of trait `std::convert::AsRef<Q>` for type `std::boxed::Box<Q>`:
|
||||||
--> $DIR/conflict-with-std.rs:15:1
|
--> $DIR/conflict-with-std.rs:17:1
|
||||||
|
|
|
|
||||||
LL | impl AsRef<Q> for Box<Q> { //~ ERROR conflicting implementations
|
LL | impl AsRef<Q> for Box<Q> { //~ ERROR conflicting implementations
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^
|
| ^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
@ -9,7 +9,7 @@ LL | impl AsRef<Q> for Box<Q> { //~ ERROR conflicting implementations
|
||||||
where T: ?Sized;
|
where T: ?Sized;
|
||||||
|
|
||||||
error[E0119]: conflicting implementations of trait `std::convert::From<S>` for type `S`:
|
error[E0119]: conflicting implementations of trait `std::convert::From<S>` for type `S`:
|
||||||
--> $DIR/conflict-with-std.rs:22:1
|
--> $DIR/conflict-with-std.rs:24:1
|
||||||
|
|
|
|
||||||
LL | impl From<S> for S { //~ ERROR conflicting implementations
|
LL | impl From<S> for S { //~ ERROR conflicting implementations
|
||||||
| ^^^^^^^^^^^^^^^^^^
|
| ^^^^^^^^^^^^^^^^^^
|
||||||
|
@ -18,7 +18,7 @@ LL | impl From<S> for S { //~ ERROR conflicting implementations
|
||||||
- impl<T> std::convert::From<T> for T;
|
- impl<T> std::convert::From<T> for T;
|
||||||
|
|
||||||
error[E0119]: conflicting implementations of trait `std::convert::TryFrom<X>` for type `X`:
|
error[E0119]: conflicting implementations of trait `std::convert::TryFrom<X>` for type `X`:
|
||||||
--> $DIR/conflict-with-std.rs:29:1
|
--> $DIR/conflict-with-std.rs:31:1
|
||||||
|
|
|
|
||||||
LL | impl TryFrom<X> for X { //~ ERROR conflicting implementations
|
LL | impl TryFrom<X> for X { //~ ERROR conflicting implementations
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^
|
| ^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue