about summary refs log tree commit diff
path: root/src/libcore/num
diff options
context:
space:
mode:
authorSimon Sapin <simon.sapin@exyr.org>2019-02-08 14:55:44 +0100
committerSimon Sapin <simon.sapin@exyr.org>2019-02-13 18:00:18 +0100
commit2f7120397f5178fd3b389c2551a03991f3f4ee31 (patch)
treeedb763aa8743f70ce3a870b453b8bddd073dfcec /src/libcore/num
parent85f13f0d42fe7ee0a5850a271e8a1c975ad5b85f (diff)
downloadrust-2f7120397f5178fd3b389c2551a03991f3f4ee31.tar.gz
rust-2f7120397f5178fd3b389c2551a03991f3f4ee31.zip
Use convert::Infallible instead of never in the blanket TryFrom impl
Diffstat (limited to 'src/libcore/num')
-rw-r--r--src/libcore/num/mod.rs14
1 files changed, 12 insertions, 2 deletions
diff --git a/src/libcore/num/mod.rs b/src/libcore/num/mod.rs
index 6fb67ea9c9a..ae7f1fe98c9 100644
--- a/src/libcore/num/mod.rs
+++ b/src/libcore/num/mod.rs
@@ -2,7 +2,7 @@
 
 #![stable(feature = "rust1", since = "1.0.0")]
 
-use convert::TryFrom;
+use convert::{TryFrom, Infallible};
 use fmt;
 use intrinsics;
 use mem;
@@ -4531,9 +4531,19 @@ impl fmt::Display for TryFromIntError {
 }
 
 #[unstable(feature = "try_from", issue = "33417")]
+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 {
-        never
+        // 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 {}
     }
 }