replace convert::Infallible with !

This commit is contained in:
Andrew Cann
2018-03-15 12:35:56 +08:00
parent a8a0c69191
commit 4647156985
3 changed files with 6 additions and 42 deletions

View File

@@ -12,7 +12,7 @@
#![stable(feature = "rust1", since = "1.0.0")]
use convert::{Infallible, TryFrom};
use convert::TryFrom;
use fmt;
use intrinsics;
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
macro_rules! try_from_unbounded {
($source:ty, $($target:ty),*) => {$(
#[unstable(feature = "try_from", issue = "33417")]
impl TryFrom<$source> for $target {
type Error = Infallible;
type Error = !;
#[inline]
fn try_from(value: $source) -> Result<Self, Self::Error> {
@@ -3719,7 +3711,7 @@ try_from_lower_bounded!(isize, usize);
#[cfg(target_pointer_width = "16")]
mod ptr_try_from_impls {
use super::TryFromIntError;
use convert::{Infallible, TryFrom};
use convert::TryFrom;
try_from_upper_bounded!(usize, u8);
try_from_unbounded!(usize, u16, u32, u64, u128);
@@ -3745,7 +3737,7 @@ mod ptr_try_from_impls {
#[cfg(target_pointer_width = "32")]
mod ptr_try_from_impls {
use super::TryFromIntError;
use convert::{Infallible, TryFrom};
use convert::TryFrom;
try_from_upper_bounded!(usize, u8, u16);
try_from_unbounded!(usize, u32, u64, u128);
@@ -3771,7 +3763,7 @@ mod ptr_try_from_impls {
#[cfg(target_pointer_width = "64")]
mod ptr_try_from_impls {
use super::TryFromIntError;
use convert::{Infallible, TryFrom};
use convert::TryFrom;
try_from_upper_bounded!(usize, u8, u16, u32);
try_from_unbounded!(usize, u64, u128);