Skip to content

Commit 4647156

Browse files
committed
replace convert::Infallible with !
1 parent a8a0c69 commit 4647156

File tree

3 files changed

+6
-42
lines changed

3 files changed

+6
-42
lines changed

src/libcore/convert.rs

+1-20
Original file line numberDiff line numberDiff line change
@@ -48,25 +48,6 @@
4848
4949
#![stable(feature = "rust1", since = "1.0.0")]
5050

51-
use fmt;
52-
53-
/// A type used as the error type for implementations of fallible conversion
54-
/// traits in cases where conversions cannot actually fail.
55-
///
56-
/// Because `Infallible` has no variants, a value of this type can never exist.
57-
/// It is used only to satisfy trait signatures that expect an error type, and
58-
/// signals to both the compiler and the user that the error case is impossible.
59-
#[unstable(feature = "try_from", issue = "33417")]
60-
#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
61-
pub enum Infallible {}
62-
63-
#[unstable(feature = "try_from", issue = "33417")]
64-
impl fmt::Display for Infallible {
65-
fn fmt(&self, _: &mut fmt::Formatter) -> fmt::Result {
66-
match *self {
67-
}
68-
}
69-
}
7051
/// A cheap reference-to-reference conversion. Used to convert a value to a
7152
/// reference value within generic code.
7253
///
@@ -438,7 +419,7 @@ impl<T, U> TryInto<U> for T where U: TryFrom<T>
438419
// with an uninhabited error type.
439420
#[unstable(feature = "try_from", issue = "33417")]
440421
impl<T, U> TryFrom<U> for T where T: From<U> {
441-
type Error = Infallible;
422+
type Error = !;
442423

443424
fn try_from(value: U) -> Result<Self, Self::Error> {
444425
Ok(T::from(value))

src/libcore/num/mod.rs

+5-13
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
1313
#![stable(feature = "rust1", since = "1.0.0")]
1414

15-
use convert::{Infallible, TryFrom};
15+
use convert::TryFrom;
1616
use fmt;
1717
use intrinsics;
1818
use ops;
@@ -3595,20 +3595,12 @@ impl fmt::Display for TryFromIntError {
35953595
}
35963596
}
35973597

3598-
#[unstable(feature = "try_from", issue = "33417")]
3599-
impl From<Infallible> for TryFromIntError {
3600-
fn from(infallible: Infallible) -> TryFromIntError {
3601-
match infallible {
3602-
}
3603-
}
3604-
}
3605-
36063598
// no possible bounds violation
36073599
macro_rules! try_from_unbounded {
36083600
($source:ty, $($target:ty),*) => {$(
36093601
#[unstable(feature = "try_from", issue = "33417")]
36103602
impl TryFrom<$source> for $target {
3611-
type Error = Infallible;
3603+
type Error = !;
36123604

36133605
#[inline]
36143606
fn try_from(value: $source) -> Result<Self, Self::Error> {
@@ -3719,7 +3711,7 @@ try_from_lower_bounded!(isize, usize);
37193711
#[cfg(target_pointer_width = "16")]
37203712
mod ptr_try_from_impls {
37213713
use super::TryFromIntError;
3722-
use convert::{Infallible, TryFrom};
3714+
use convert::TryFrom;
37233715

37243716
try_from_upper_bounded!(usize, u8);
37253717
try_from_unbounded!(usize, u16, u32, u64, u128);
@@ -3745,7 +3737,7 @@ mod ptr_try_from_impls {
37453737
#[cfg(target_pointer_width = "32")]
37463738
mod ptr_try_from_impls {
37473739
use super::TryFromIntError;
3748-
use convert::{Infallible, TryFrom};
3740+
use convert::TryFrom;
37493741

37503742
try_from_upper_bounded!(usize, u8, u16);
37513743
try_from_unbounded!(usize, u32, u64, u128);
@@ -3771,7 +3763,7 @@ mod ptr_try_from_impls {
37713763
#[cfg(target_pointer_width = "64")]
37723764
mod ptr_try_from_impls {
37733765
use super::TryFromIntError;
3774-
use convert::{Infallible, TryFrom};
3766+
use convert::TryFrom;
37753767

37763768
try_from_upper_bounded!(usize, u8, u16, u32);
37773769
try_from_unbounded!(usize, u64, u128);

src/libstd/error.rs

-9
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,6 @@ use any::TypeId;
5656
use borrow::Cow;
5757
use cell;
5858
use char;
59-
use convert;
6059
use core::array;
6160
use fmt::{self, Debug, Display};
6261
use mem::transmute;
@@ -371,14 +370,6 @@ impl Error for char::ParseCharError {
371370
}
372371
}
373372

374-
#[unstable(feature = "try_from", issue = "33417")]
375-
impl Error for convert::Infallible {
376-
fn description(&self) -> &str {
377-
match *self {
378-
}
379-
}
380-
}
381-
382373
// copied from any.rs
383374
impl Error + 'static {
384375
/// Returns true if the boxed type is the same as `T`

0 commit comments

Comments
 (0)