about summary refs log tree commit diff
path: root/src/libcore/num
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2019-12-14 22:02:59 +0000
committerbors <bors@rust-lang.org>2019-12-14 22:02:59 +0000
commit6f829840f7e5897745bc7b5ff951b006a2c4e0e3 (patch)
tree0c73bcad1ba6245af90566e58a69def359b598cd /src/libcore/num
parentc8ea4ace9213ae045123fdfeb59d1ac887656d31 (diff)
parent775076ff4dc9ce4986a1286669cfa268b01ac592 (diff)
downloadrust-6f829840f7e5897745bc7b5ff951b006a2c4e0e3.tar.gz
rust-6f829840f7e5897745bc7b5ff951b006a2c4e0e3.zip
Auto merge of #67224 - nikomatsakis:revert-stabilization-of-never-type, r=centril
Revert stabilization of never type

Fixes https://github.com/rust-lang/rust/issues/66757

I decided to keep the separate `never-type-fallback` feature gate, but tried to otherwise revert https://github.com/rust-lang/rust/pull/65355. Seemed pretty clean.

( cc @Centril, author of #65355, you may want to check this over briefly )
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 5a97aa4acfa..88c14dfe7d1 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;
@@ -5032,8 +5033,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 {}
+    }
+}
+
+#[unstable(feature = "never_type", issue = "35121")]
 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 {}
     }
 }