about summary refs log tree commit diff
path: root/src/libcore/num
diff options
context:
space:
mode:
authorNiko Matsakis <niko@alum.mit.edu>2019-12-11 09:49:29 -0500
committerNiko Matsakis <niko@alum.mit.edu>2019-12-14 09:00:49 -0500
commitca8154861e0b8412c74bdbf05691af1d9e48a966 (patch)
treeb5f6ac70ba32b5e14ce48ec6f641a3b93b1a530f /src/libcore/num
parent12307b3b08edee543a78fb9d4a837fbd6d6ac0fa (diff)
downloadrust-ca8154861e0b8412c74bdbf05691af1d9e48a966.tar.gz
rust-ca8154861e0b8412c74bdbf05691af1d9e48a966.zip
Revert "Redefine `core::convert::Infallible` as `!`."
This reverts commit 089229a1935fa9795cfdefa518c8f8c3beb66db8.
Diffstat (limited to 'src/libcore/num')
-rw-r--r--src/libcore/num/mod.rs11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/libcore/num/mod.rs b/src/libcore/num/mod.rs
index d1f518d52dd..c2e6ae64a51 100644
--- a/src/libcore/num/mod.rs
+++ b/src/libcore/num/mod.rs
@@ -4,6 +4,7 @@
 
 #![stable(feature = "rust1", since = "1.0.0")]
 
+use crate::convert::Infallible;
 use crate::fmt;
 use crate::intrinsics;
 use crate::mem;
@@ -4724,8 +4725,18 @@ 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.41.0")]
 impl From<!> for TryFromIntError {
     fn from(never: !) -> TryFromIntError {
+        // Match rather than coerce to make sure that code like
+        // `From<Infallible> for TryFromIntError` above will keep working
+        // when `Infallible` becomes an alias to `!`.
         match never {}
     }
 }