]> git.lizzy.rs Git - rust.git/commitdiff
impl Debug + Display for !
authorAndrew Cann <shum@canndrew.org>
Sat, 30 Jul 2016 05:24:53 +0000 (13:24 +0800)
committerAndrew Cann <shum@canndrew.org>
Sat, 13 Aug 2016 13:37:09 +0000 (21:37 +0800)
src/libcore/fmt/mod.rs

index 173c55e35d51e5a680cd62c84929e22caa798193..60862334846cf64327dba2449588521fed5f8c24 100644 (file)
@@ -1363,6 +1363,29 @@ fn fmt(&self, f: &mut Formatter) -> Result { $tr::fmt(&**self, f) }
 
 fmt_refs! { Debug, Display, Octal, Binary, LowerHex, UpperHex, LowerExp, UpperExp }
 
+// Note: This macro is a temporary hack that can be remove once we are building with a compiler
+// that supports `!`
+macro_rules! argh {
+    () => {
+        #[unstable(feature = "bang_type", issue = "35121")]
+        impl Debug for ! {
+            fn fmt(&self, _: &mut Formatter) -> Result {
+                *self
+            }
+        }
+
+        #[unstable(feature = "bang_type", issue = "35121")]
+        impl Display for ! {
+            fn fmt(&self, _: &mut Formatter) -> Result {
+                *self
+            }
+        }
+    }
+}
+
+#[cfg(not(stage0))]
+argh!();
+
 #[stable(feature = "rust1", since = "1.0.0")]
 impl Debug for bool {
     fn fmt(&self, f: &mut Formatter) -> Result {