From 51c6ae25e286152f44adfdc3d2f88b597fa5fc7a Mon Sep 17 00:00:00 2001 From: Andrew Cann Date: Mon, 1 Aug 2016 12:56:43 +0800 Subject: [PATCH] implement std::cmp::* traits for `!` --- src/libcore/cmp.rs | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/src/libcore/cmp.rs b/src/libcore/cmp.rs index 8764766b2ef8..1d2ed735e813 100644 --- a/src/libcore/cmp.rs +++ b/src/libcore/cmp.rs @@ -699,6 +699,39 @@ mod impls { ord_impl! { char usize u8 u16 u32 u64 isize i8 i16 i32 i64 } + // 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 PartialEq for ! { + fn eq(&self, _: &!) -> bool { + *self + } + } + + #[unstable(feature = "bang_type", issue = "35121")] + impl Eq for ! {} + + #[unstable(feature = "bang_type", issue = "35121")] + impl PartialOrd for ! { + fn partial_cmp(&self, _: &!) -> Option { + *self + } + } + + #[unstable(feature = "bang_type", issue = "35121")] + impl Ord for ! { + fn cmp(&self, _: &!) -> Ordering { + *self + } + } + } + } + + #[cfg(not(stage0))] + argh!(); + // & pointers #[stable(feature = "rust1", since = "1.0.0")]