replace convert::Infallible with !
This commit is contained in:
@@ -48,25 +48,6 @@
|
|||||||
|
|
||||||
#![stable(feature = "rust1", since = "1.0.0")]
|
#![stable(feature = "rust1", since = "1.0.0")]
|
||||||
|
|
||||||
use fmt;
|
|
||||||
|
|
||||||
/// A type used as the error type for implementations of fallible conversion
|
|
||||||
/// traits in cases where conversions cannot actually fail.
|
|
||||||
///
|
|
||||||
/// Because `Infallible` has no variants, a value of this type can never exist.
|
|
||||||
/// It is used only to satisfy trait signatures that expect an error type, and
|
|
||||||
/// signals to both the compiler and the user that the error case is impossible.
|
|
||||||
#[unstable(feature = "try_from", issue = "33417")]
|
|
||||||
#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
|
|
||||||
pub enum Infallible {}
|
|
||||||
|
|
||||||
#[unstable(feature = "try_from", issue = "33417")]
|
|
||||||
impl fmt::Display for Infallible {
|
|
||||||
fn fmt(&self, _: &mut fmt::Formatter) -> fmt::Result {
|
|
||||||
match *self {
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/// A cheap reference-to-reference conversion. Used to convert a value to a
|
/// A cheap reference-to-reference conversion. Used to convert a value to a
|
||||||
/// reference value within generic code.
|
/// reference value within generic code.
|
||||||
///
|
///
|
||||||
@@ -438,7 +419,7 @@ impl<T, U> TryInto<U> for T where U: TryFrom<T>
|
|||||||
// with an uninhabited error type.
|
// with an uninhabited error type.
|
||||||
#[unstable(feature = "try_from", issue = "33417")]
|
#[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 = Infallible;
|
type Error = !;
|
||||||
|
|
||||||
fn try_from(value: U) -> Result<Self, Self::Error> {
|
fn try_from(value: U) -> Result<Self, Self::Error> {
|
||||||
Ok(T::from(value))
|
Ok(T::from(value))
|
||||||
|
|||||||
@@ -12,7 +12,7 @@
|
|||||||
|
|
||||||
#![stable(feature = "rust1", since = "1.0.0")]
|
#![stable(feature = "rust1", since = "1.0.0")]
|
||||||
|
|
||||||
use convert::{Infallible, TryFrom};
|
use convert::TryFrom;
|
||||||
use fmt;
|
use fmt;
|
||||||
use intrinsics;
|
use intrinsics;
|
||||||
use ops;
|
use ops;
|
||||||
@@ -3595,20 +3595,12 @@ impl fmt::Display for TryFromIntError {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[unstable(feature = "try_from", issue = "33417")]
|
|
||||||
impl From<Infallible> for TryFromIntError {
|
|
||||||
fn from(infallible: Infallible) -> TryFromIntError {
|
|
||||||
match infallible {
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// no possible bounds violation
|
// no possible bounds violation
|
||||||
macro_rules! try_from_unbounded {
|
macro_rules! try_from_unbounded {
|
||||||
($source:ty, $($target:ty),*) => {$(
|
($source:ty, $($target:ty),*) => {$(
|
||||||
#[unstable(feature = "try_from", issue = "33417")]
|
#[unstable(feature = "try_from", issue = "33417")]
|
||||||
impl TryFrom<$source> for $target {
|
impl TryFrom<$source> for $target {
|
||||||
type Error = Infallible;
|
type Error = !;
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn try_from(value: $source) -> Result<Self, Self::Error> {
|
fn try_from(value: $source) -> Result<Self, Self::Error> {
|
||||||
@@ -3719,7 +3711,7 @@ try_from_lower_bounded!(isize, usize);
|
|||||||
#[cfg(target_pointer_width = "16")]
|
#[cfg(target_pointer_width = "16")]
|
||||||
mod ptr_try_from_impls {
|
mod ptr_try_from_impls {
|
||||||
use super::TryFromIntError;
|
use super::TryFromIntError;
|
||||||
use convert::{Infallible, TryFrom};
|
use convert::TryFrom;
|
||||||
|
|
||||||
try_from_upper_bounded!(usize, u8);
|
try_from_upper_bounded!(usize, u8);
|
||||||
try_from_unbounded!(usize, u16, u32, u64, u128);
|
try_from_unbounded!(usize, u16, u32, u64, u128);
|
||||||
@@ -3745,7 +3737,7 @@ mod ptr_try_from_impls {
|
|||||||
#[cfg(target_pointer_width = "32")]
|
#[cfg(target_pointer_width = "32")]
|
||||||
mod ptr_try_from_impls {
|
mod ptr_try_from_impls {
|
||||||
use super::TryFromIntError;
|
use super::TryFromIntError;
|
||||||
use convert::{Infallible, TryFrom};
|
use convert::TryFrom;
|
||||||
|
|
||||||
try_from_upper_bounded!(usize, u8, u16);
|
try_from_upper_bounded!(usize, u8, u16);
|
||||||
try_from_unbounded!(usize, u32, u64, u128);
|
try_from_unbounded!(usize, u32, u64, u128);
|
||||||
@@ -3771,7 +3763,7 @@ mod ptr_try_from_impls {
|
|||||||
#[cfg(target_pointer_width = "64")]
|
#[cfg(target_pointer_width = "64")]
|
||||||
mod ptr_try_from_impls {
|
mod ptr_try_from_impls {
|
||||||
use super::TryFromIntError;
|
use super::TryFromIntError;
|
||||||
use convert::{Infallible, TryFrom};
|
use convert::TryFrom;
|
||||||
|
|
||||||
try_from_upper_bounded!(usize, u8, u16, u32);
|
try_from_upper_bounded!(usize, u8, u16, u32);
|
||||||
try_from_unbounded!(usize, u64, u128);
|
try_from_unbounded!(usize, u64, u128);
|
||||||
|
|||||||
@@ -56,7 +56,6 @@ use any::TypeId;
|
|||||||
use borrow::Cow;
|
use borrow::Cow;
|
||||||
use cell;
|
use cell;
|
||||||
use char;
|
use char;
|
||||||
use convert;
|
|
||||||
use core::array;
|
use core::array;
|
||||||
use fmt::{self, Debug, Display};
|
use fmt::{self, Debug, Display};
|
||||||
use mem::transmute;
|
use mem::transmute;
|
||||||
@@ -371,14 +370,6 @@ impl Error for char::ParseCharError {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[unstable(feature = "try_from", issue = "33417")]
|
|
||||||
impl Error for convert::Infallible {
|
|
||||||
fn description(&self) -> &str {
|
|
||||||
match *self {
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// copied from any.rs
|
// copied from any.rs
|
||||||
impl Error + 'static {
|
impl Error + 'static {
|
||||||
/// Returns true if the boxed type is the same as `T`
|
/// Returns true if the boxed type is the same as `T`
|
||||||
|
|||||||
Reference in New Issue
Block a user