Skip to content

Commit

Permalink
WIP: make Infallible an alias for !
Browse files Browse the repository at this point in the history
  • Loading branch information
nikomatsakis committed Nov 29, 2020
1 parent 5ef3eb6 commit 3ad1e4d
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 80 deletions.
65 changes: 1 addition & 64 deletions library/core/src/convert/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,6 @@
#![stable(feature = "rust1", since = "1.0.0")]

use crate::fmt;
use crate::hash::{Hash, Hasher};

mod num;

#[unstable(feature = "convert_float_to_int", issue = "67057")]
Expand Down Expand Up @@ -675,64 +672,4 @@ impl AsRef<str> for str {
///
/// [never]: ../../std/primitive.never.html
#[stable(feature = "convert_infallible", since = "1.34.0")]
#[derive(Copy)]
pub enum Infallible {}

#[stable(feature = "convert_infallible", since = "1.34.0")]
impl Clone for Infallible {
fn clone(&self) -> Infallible {
match *self {}
}
}

#[stable(feature = "convert_infallible", since = "1.34.0")]
impl fmt::Debug for Infallible {
fn fmt(&self, _: &mut fmt::Formatter<'_>) -> fmt::Result {
match *self {}
}
}

#[stable(feature = "convert_infallible", since = "1.34.0")]
impl fmt::Display for Infallible {
fn fmt(&self, _: &mut fmt::Formatter<'_>) -> fmt::Result {
match *self {}
}
}

#[stable(feature = "convert_infallible", since = "1.34.0")]
impl PartialEq for Infallible {
fn eq(&self, _: &Infallible) -> bool {
match *self {}
}
}

#[stable(feature = "convert_infallible", since = "1.34.0")]
impl Eq for Infallible {}

#[stable(feature = "convert_infallible", since = "1.34.0")]
impl PartialOrd for Infallible {
fn partial_cmp(&self, _other: &Self) -> Option<crate::cmp::Ordering> {
match *self {}
}
}

#[stable(feature = "convert_infallible", since = "1.34.0")]
impl Ord for Infallible {
fn cmp(&self, _other: &Self) -> crate::cmp::Ordering {
match *self {}
}
}

#[stable(feature = "convert_infallible", since = "1.34.0")]
impl From<!> for Infallible {
fn from(x: !) -> Self {
x
}
}

#[stable(feature = "convert_infallible_hash", since = "1.44.0")]
impl Hash for Infallible {
fn hash<H: Hasher>(&self, _: &mut H) {
match *self {}
}
}
pub type Infallible = !;
8 changes: 0 additions & 8 deletions library/core/src/num/error.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
//! Error types for conversion to integral types.
use crate::convert::Infallible;
use crate::fmt;

/// The error type returned when a checked integral type conversion fails.
Expand Down Expand Up @@ -28,13 +27,6 @@ impl fmt::Display for TryFromIntError {
}
}

#[stable(feature = "try_from", since = "1.34.0")]
impl From<Infallible> for TryFromIntError {
fn from(x: Infallible) -> TryFromIntError {
match x {}
}
}

#[stable(feature = "never_type", since = "1.49.0")]
impl From<!> for TryFromIntError {
fn from(never: !) -> TryFromIntError {
Expand Down
8 changes: 0 additions & 8 deletions library/std/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
mod tests;

use core::array;
use core::convert::Infallible;

use crate::alloc::{AllocError, LayoutError};
use crate::any::TypeId;
Expand Down Expand Up @@ -456,13 +455,6 @@ impl Error for string::FromUtf16Error {
}
}

#[stable(feature = "str_parse_error2", since = "1.8.0")]
impl Error for Infallible {
fn description(&self) -> &str {
match *self {}
}
}

#[stable(feature = "decode_utf16", since = "1.9.0")]
impl Error for char::DecodeUtf16Error {
#[allow(deprecated)]
Expand Down

0 comments on commit 3ad1e4d

Please sign in to comment.