diff --git a/src/libcore/cmp.rs b/src/libcore/cmp.rs index 0f27f4ddfb14..318ef6e630e3 100644 --- a/src/libcore/cmp.rs +++ b/src/libcore/cmp.rs @@ -4,29 +4,37 @@ /// Interfaces used for comparison. +// Awful hack to work around duplicate lang items in core test. #[cfg(notest)] #[lang="ord"] trait Ord { pure fn lt(&&other: self) -> bool; } +#[cfg(test)] +trait Ord { + pure fn lt(&&other: self) -> bool; +} + #[cfg(notest)] #[lang="eq"] trait Eq { pure fn eq(&&other: self) -> bool; } -#[cfg(notest)] +#[cfg(test)] +trait Eq { + pure fn eq(&&other: self) -> bool; +} + pure fn lt(v1: &T, v2: &T) -> bool { v1.lt(*v2) } -#[cfg(notest)] pure fn le(v1: &T, v2: &T) -> bool { v1.lt(*v2) || v1.eq(*v2) } -#[cfg(notest)] pure fn eq(v1: &T, v2: &T) -> bool { v1.eq(*v2) } diff --git a/src/libcore/int-template.rs b/src/libcore/int-template.rs index 953a7a9494d3..b8d1b76908c2 100644 --- a/src/libcore/int-template.rs +++ b/src/libcore/int-template.rs @@ -1,4 +1,5 @@ import T = inst::T; +import cmp::{Eq, Ord}; import num::from_int; export min_value, max_value; @@ -62,20 +63,15 @@ pure fn abs(i: T) -> T { if is_negative(i) { -i } else { i } } -#[cfg(notest)] -mod impls { - import cmp::{Eq, Ord}; - - impl T: Ord { - pure fn lt(&&other: T) -> bool { - return self < other; - } +impl T: Ord { + pure fn lt(&&other: T) -> bool { + return self < other; } +} - impl T: Eq { - pure fn eq(&&other: T) -> bool { - return self == other; - } +impl T: Eq { + pure fn eq(&&other: T) -> bool { + return self == other; } } diff --git a/src/libcore/uint-template.rs b/src/libcore/uint-template.rs index 48681661ee71..1aa46e628252 100644 --- a/src/libcore/uint-template.rs +++ b/src/libcore/uint-template.rs @@ -1,4 +1,5 @@ import T = inst::T; +import cmp::{Eq, Ord}; export min_value, max_value; export min, max; @@ -55,20 +56,15 @@ pure fn compl(i: T) -> T { max_value ^ i } -#[cfg(notest)] -mod impls { - import cmp::{Eq, Ord}; - - impl T: Ord { - pure fn lt(&&other: T) -> bool { - return self < other; - } +impl T: Ord { + pure fn lt(&&other: T) -> bool { + return self < other; } +} - impl T: Eq { - pure fn eq(&&other: T) -> bool { - return self == other; - } +impl T: Eq { + pure fn eq(&&other: T) -> bool { + return self == other; } }