versions: ~[(~str, ~str)]
};
+#[cfg(stage0)]
impl package : cmp::Ord {
pure fn lt(&&other: package) -> bool {
if self.name.lt(other.name) { return true; }
pure fn ge(&&other: package) -> bool { !self.lt(other) }
pure fn gt(&&other: package) -> bool { other.lt(self) }
}
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl package : cmp::Ord {
+ pure fn lt(other: &package) -> bool {
+ if self.name.lt(&(*other).name) { return true; }
+ if (*other).name.lt(&self.name) { return false; }
+ if self.uuid.lt(&(*other).uuid) { return true; }
+ if (*other).uuid.lt(&self.uuid) { return false; }
+ if self.url.lt(&(*other).url) { return true; }
+ if (*other).url.lt(&self.url) { return false; }
+ if self.method.lt(&(*other).method) { return true; }
+ if (*other).method.lt(&self.method) { return false; }
+ if self.description.lt(&(*other).description) { return true; }
+ if (*other).description.lt(&self.description) { return false; }
+ if self.tags.lt(&(*other).tags) { return true; }
+ if (*other).tags.lt(&self.tags) { return false; }
+ if self.versions.lt(&(*other).versions) { return true; }
+ return false;
+ }
+ pure fn le(other: &package) -> bool { !(*other).lt(&self) }
+ pure fn ge(other: &package) -> bool { !self.lt(other) }
+ pure fn gt(other: &package) -> bool { (*other).lt(&self) }
+}
type local_package = {
name: ~str,
enum mode { system_mode, user_mode, local_mode }
+#[cfg(stage0)]
impl mode : cmp::Eq {
pure fn eq(&&other: mode) -> bool {
(self as uint) == (other as uint)
}
pure fn ne(&&other: mode) -> bool { !self.eq(other) }
}
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl mode : cmp::Eq {
+ pure fn eq(other: &mode) -> bool {
+ (self as uint) == ((*other) as uint)
+ }
+ pure fn ne(other: &mode) -> bool { !self.eq(other) }
+}
fn opts() -> ~[getopts::Opt] {
~[optflag(~"g"), optflag(~"G"), optflag(~"test"),
enum mode { mode_compile_fail, mode_run_fail, mode_run_pass, mode_pretty, }
+#[cfg(stage0)]
impl mode : cmp::Eq {
pure fn eq(&&other: mode) -> bool {
other as int == self as int
}
pure fn ne(&&other: mode) -> bool { !self.eq(other) }
}
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl mode : cmp::Eq {
+ pure fn eq(other: &mode) -> bool {
+ (*other) as int == self as int
+ }
+ pure fn ne(other: &mode) -> bool { !self.eq(other) }
+}
type config = {
// The library paths required for running the compiler
enum test_mode { tm_converge, tm_run, }
type context = { mode: test_mode }; // + rng
+#[cfg(stage0)]
impl test_mode : cmp::Eq {
pure fn eq(&&other: test_mode) -> bool {
(self as uint) == (other as uint)
}
pure fn ne(&&other: test_mode) -> bool { !self.eq(other) }
}
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl test_mode : cmp::Eq {
+ pure fn eq(other: &test_mode) -> bool {
+ (self as uint) == ((*other) as uint)
+ }
+ pure fn ne(other: &test_mode) -> bool { !self.eq(other) }
+}
fn write_file(filename: &Path, content: ~str) {
result::get(
export map;
export from_fn, from_elem;
export raw;
+export traits;
/// Code for dealing with @-vectors. This is pretty incomplete, and
/// contains a bunch of duplication from the code for ~-vectors.
}
#[cfg(notest)]
-impl<T: Copy> @[T]: Add<&[const T],@[T]> {
- #[inline(always)]
- pure fn add(rhs: &[const T]) -> @[T] {
- append(self, rhs)
+mod traits {
+ #[cfg(stage0)]
+ impl<T: Copy> @[T]: Add<&[const T],@[T]> {
+ #[inline(always)]
+ pure fn add(rhs: &[const T]) -> @[T] {
+ append(self, rhs)
+ }
+ }
+ #[cfg(stage1)]
+ #[cfg(stage2)]
+ impl<T: Copy> @[T] : Add<&[const T],@[T]> {
+ #[inline(always)]
+ pure fn add(rhs: & &[const T]) -> @[T] {
+ append(self, (*rhs))
+ }
}
}
+#[cfg(test)]
+mod traits {}
mod raw {
type VecRepr = vec::raw::VecRepr;
/// converts truth value to an 8 bit byte
pure fn to_bit(v: bool) -> u8 { if v { 1u8 } else { 0u8 } }
+#[cfg(stage0)]
impl bool : cmp::Eq {
pure fn eq(&&other: bool) -> bool { self == other }
pure fn ne(&&other: bool) -> bool { self != other }
}
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl bool : cmp::Eq {
+ pure fn eq(other: &bool) -> bool { self == (*other) }
+ pure fn ne(other: &bool) -> bool { self != (*other) }
+}
#[test]
fn test_bool_from_str() {
unsafe { ptr::addr_of(*a) == ptr::addr_of(*b) }
}
+#[cfg(stage0)]
impl<T:Eq> @const T : Eq {
pure fn eq(&&other: @const T) -> bool { *self == *other }
pure fn ne(&&other: @const T) -> bool { *self != *other }
}
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl<T:Eq> @const T : Eq {
+ pure fn eq(other: &@const T) -> bool { *self == *(*other) }
+ pure fn ne(other: &@const T) -> bool { *self != *(*other) }
+}
+#[cfg(stage0)]
impl<T:Ord> @const T : Ord {
pure fn lt(&&other: @const T) -> bool { *self < *other }
pure fn le(&&other: @const T) -> bool { *self <= *other }
pure fn ge(&&other: @const T) -> bool { *self >= *other }
pure fn gt(&&other: @const T) -> bool { *self > *other }
}
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl<T:Ord> @const T : Ord {
+ pure fn lt(other: &@const T) -> bool { *self < *(*other) }
+ pure fn le(other: &@const T) -> bool { *self <= *(*other) }
+ pure fn ge(other: &@const T) -> bool { *self >= *(*other) }
+ pure fn gt(other: &@const T) -> bool { *self > *(*other) }
+}
#[test]
fn test() {
else { 0 }
}
+#[cfg(stage0)]
impl char: Eq {
pure fn eq(&&other: char) -> bool { self == other }
pure fn ne(&&other: char) -> bool { self != other }
}
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl char : Eq {
+ pure fn eq(other: &char) -> bool { self == (*other) }
+ pure fn ne(other: &char) -> bool { self != (*other) }
+}
#[test]
fn test_is_lowercase() {
#[forbid(deprecated_mode)];
#[forbid(deprecated_pattern)];
+use nounittest::*;
+use unittest::*;
+export Ord;
+export Eq;
+
/// Interfaces used for comparison.
// Awful hack to work around duplicate lang items in core test.
-
-/**
- * Trait for values that can be compared for a sort-order.
- *
- * Eventually this may be simplified to only require
- * an `le` method, with the others generated from
- * default implementations.
- */
#[cfg(notest)]
-#[lang="ord"]
-trait Ord {
- pure fn lt(&&other: self) -> bool;
- pure fn le(&&other: self) -> bool;
- pure fn ge(&&other: self) -> bool;
- pure fn gt(&&other: self) -> bool;
+mod nounittest {
+ /**
+ * Trait for values that can be compared for a sort-order.
+ *
+ * Eventually this may be simplified to only require
+ * an `le` method, with the others generated from
+ * default implementations.
+ */
+ #[cfg(stage0)]
+ #[lang="ord"]
+ trait Ord {
+ pure fn lt(&&other: self) -> bool;
+ pure fn le(&&other: self) -> bool;
+ pure fn ge(&&other: self) -> bool;
+ pure fn gt(&&other: self) -> bool;
+ }
+
+ #[cfg(stage1)]
+ #[cfg(stage2)]
+ #[lang="ord"]
+ trait Ord {
+ pure fn lt(other: &self) -> bool;
+ pure fn le(other: &self) -> bool;
+ pure fn ge(other: &self) -> bool;
+ pure fn gt(other: &self) -> bool;
+ }
+
+ #[cfg(stage0)]
+ #[lang="eq"]
+ /**
+ * Trait for values that can be compared for equality
+ * and inequality.
+ *
+ * Eventually this may be simplified to only require
+ * an `eq` method, with the other generated from
+ * a default implementation.
+ */
+ trait Eq {
+ pure fn eq(&&other: self) -> bool;
+ pure fn ne(&&other: self) -> bool;
+ }
+
+ #[cfg(stage1)]
+ #[cfg(stage2)]
+ #[lang="eq"]
+ trait Eq {
+ pure fn eq(other: &self) -> bool;
+ pure fn ne(other: &self) -> bool;
+ }
}
#[cfg(test)]
-trait Ord {
- pure fn lt(&&other: self) -> bool;
- pure fn le(&&other: self) -> bool;
- pure fn ge(&&other: self) -> bool;
- pure fn gt(&&other: self) -> bool;
-}
-
-/**
- * Trait for values that can be compared for equality
- * and inequality.
- *
- * Eventually this may be simplified to only require
- * an `eq` method, with the other generated from
- * a default implementation.
- */
-#[cfg(notest)]
-#[lang="eq"]
-trait Eq {
- pure fn eq(&&other: self) -> bool;
- pure fn ne(&&other: self) -> bool;
-}
+mod nounittest {}
#[cfg(test)]
-trait Eq {
- pure fn eq(&&other: self) -> bool;
- pure fn ne(&&other: self) -> bool;
+mod unittest {
+ #[cfg(stage0)]
+ trait Ord {
+ pure fn lt(&&other: self) -> bool;
+ pure fn le(&&other: self) -> bool;
+ pure fn ge(&&other: self) -> bool;
+ pure fn gt(&&other: self) -> bool;
+ }
+
+ #[cfg(stage1)]
+ #[cfg(stage2)]
+ trait Ord {
+ pure fn lt(other: &self) -> bool;
+ pure fn le(other: &self) -> bool;
+ pure fn ge(other: &self) -> bool;
+ pure fn gt(other: &self) -> bool;
+ }
+
+ #[cfg(stage0)]
+ trait Eq {
+ pure fn eq(&&other: self) -> bool;
+ pure fn ne(&&other: self) -> bool;
+ }
+
+ #[cfg(stage1)]
+ #[cfg(stage2)]
+ trait Eq {
+ pure fn eq(other: &self) -> bool;
+ pure fn ne(other: &self) -> bool;
+ }
}
+#[cfg(notest)]
+mod unittest {}
+
+#[cfg(stage0)]
pure fn lt<T: Ord>(v1: &T, v2: &T) -> bool {
v1.lt(v2)
}
+#[cfg(stage0)]
pure fn le<T: Ord Eq>(v1: &T, v2: &T) -> bool {
v1.lt(v2) || v1.eq(v2)
}
+#[cfg(stage0)]
pure fn eq<T: Eq>(v1: &T, v2: &T) -> bool {
v1.eq(v2)
}
+#[cfg(stage0)]
pure fn ne<T: Eq>(v1: &T, v2: &T) -> bool {
v1.ne(v2)
}
+#[cfg(stage0)]
pure fn ge<T: Ord>(v1: &T, v2: &T) -> bool {
v1.ge(v2)
}
+#[cfg(stage0)]
pure fn gt<T: Ord>(v1: &T, v2: &T) -> bool {
v1.gt(v2)
}
+#[cfg(stage1)]
+#[cfg(stage2)]
+pure fn lt<T: Ord>(v1: &T, v2: &T) -> bool {
+ (*v1).lt(v2)
+}
+
+#[cfg(stage1)]
+#[cfg(stage2)]
+pure fn le<T: Ord Eq>(v1: &T, v2: &T) -> bool {
+ (*v1).lt(v2) || (*v1).eq(v2)
+}
+
+#[cfg(stage1)]
+#[cfg(stage2)]
+pure fn eq<T: Eq>(v1: &T, v2: &T) -> bool {
+ (*v1).eq(v2)
+}
+
+#[cfg(stage1)]
+#[cfg(stage2)]
+pure fn ne<T: Eq>(v1: &T, v2: &T) -> bool {
+ (*v1).ne(v2)
+}
+
+#[cfg(stage1)]
+#[cfg(stage2)]
+pure fn ge<T: Ord>(v1: &T, v2: &T) -> bool {
+ (*v1).ge(v2)
+}
+
+#[cfg(stage1)]
+#[cfg(stage2)]
+pure fn gt<T: Ord>(v1: &T, v2: &T) -> bool {
+ (*v1).gt(v2)
+}
+
}
}
+#[cfg(stage0)]
impl<T:Eq,U:Eq> Either<T,U> : Eq {
pure fn eq(&&other: Either<T,U>) -> bool {
match self {
}
pure fn ne(&&other: Either<T,U>) -> bool { !self.eq(other) }
}
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl<T:Eq,U:Eq> Either<T,U> : Eq {
+ pure fn eq(other: &Either<T,U>) -> bool {
+ match self {
+ Left(a) => {
+ match (*other) {
+ Left(ref b) => a.eq(b),
+ Right(_) => false
+ }
+ }
+ Right(a) => {
+ match (*other) {
+ Left(_) => false,
+ Right(ref b) => a.eq(b)
+ }
+ }
+ }
+ }
+ pure fn ne(other: &Either<T,U>) -> bool { !self.eq(other) }
+}
#[test]
fn test_either_left() {
enum PadMode { PadSigned, PadUnsigned, PadNozero, PadFloat }
+#[cfg(stage0)]
impl PadMode: Eq {
pure fn eq(&&other: PadMode) -> bool {
match (self, other) {
}
pure fn ne(&&other: PadMode) -> bool { !self.eq(other) }
}
+ #[cfg(stage1)]
+ #[cfg(stage2)]
+ impl PadMode : Eq {
+ pure fn eq(other: &PadMode) -> bool {
+ match (self, (*other)) {
+ (PadSigned, PadSigned) => true,
+ (PadUnsigned, PadUnsigned) => true,
+ (PadNozero, PadNozero) => true,
+ (PadFloat, PadFloat) => true,
+ (PadSigned, _) => false,
+ (PadUnsigned, _) => false,
+ (PadNozero, _) => false,
+ (PadFloat, _) => false
+ }
+ }
+ pure fn ne(other: &PadMode) -> bool { !self.eq(other) }
+ }
fn pad(cv: Conv, &s: ~str, mode: PadMode) -> ~str {
let uwidth : uint = match cv.width {
enum PadMode { PadSigned, PadUnsigned, PadNozero, PadFloat }
+#[cfg(stage0)]
impl PadMode: Eq {
pure fn eq(&&other: PadMode) -> bool {
match (self, other) {
}
pure fn ne(&&other: PadMode) -> bool { !self.eq(other) }
}
+ #[cfg(stage1)]
+ #[cfg(stage2)]
+ impl PadMode : Eq {
+ pure fn eq(other: &PadMode) -> bool {
+ match (self, (*other)) {
+ (PadSigned, PadSigned) => true,
+ (PadUnsigned, PadUnsigned) => true,
+ (PadNozero, PadNozero) => true,
+ (PadFloat, PadFloat) => true,
+ (PadSigned, _) => false,
+ (PadUnsigned, _) => false,
+ (PadNozero, _) => false,
+ (PadFloat, _) => false
+ }
+ }
+ pure fn ne(other: &PadMode) -> bool { !self.eq(other) }
+ }
fn pad(cv: Conv, &s: ~str, mode: PadMode) -> ~str {
let uwidth : uint = match cv.width {
pure fn cos(x: float) -> float { f64::cos(x as f64) as float }
pure fn tan(x: float) -> float { f64::tan(x as f64) as float }
+#[cfg(stage0)]
impl float: Eq {
pure fn eq(&&other: float) -> bool { self == other }
pure fn ne(&&other: float) -> bool { self != other }
}
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl float : Eq {
+ pure fn eq(other: &float) -> bool { self == (*other) }
+ pure fn ne(other: &float) -> bool { self != (*other) }
+}
+#[cfg(stage0)]
impl float: Ord {
pure fn lt(&&other: float) -> bool { self < other }
pure fn le(&&other: float) -> bool { self <= other }
pure fn ge(&&other: float) -> bool { self >= other }
pure fn gt(&&other: float) -> bool { self > other }
}
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl float : Ord {
+ pure fn lt(other: &float) -> bool { self < (*other) }
+ pure fn le(other: &float) -> bool { self <= (*other) }
+ pure fn ge(other: &float) -> bool { self >= (*other) }
+ pure fn gt(other: &float) -> bool { self > (*other) }
+}
impl float: num::Num {
pure fn add(&&other: float) -> float { return self + other; }
if is_negative(i) { -i } else { i }
}
+#[cfg(stage0)]
impl T: Ord {
pure fn lt(&&other: T) -> bool { return self < other; }
pure fn le(&&other: T) -> bool { return self <= other; }
pure fn ge(&&other: T) -> bool { return self >= other; }
pure fn gt(&&other: T) -> bool { return self > other; }
}
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl T : Ord {
+ pure fn lt(other: &T) -> bool { return self < (*other); }
+ pure fn le(other: &T) -> bool { return self <= (*other); }
+ pure fn ge(other: &T) -> bool { return self >= (*other); }
+ pure fn gt(other: &T) -> bool { return self > (*other); }
+}
+#[cfg(stage0)]
impl T: Eq {
pure fn eq(&&other: T) -> bool { return self == other; }
pure fn ne(&&other: T) -> bool { return self != other; }
}
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl T : Eq {
+ pure fn eq(other: &T) -> bool { return self == (*other); }
+ pure fn ne(other: &T) -> bool { return self != (*other); }
+}
impl T: num::Num {
pure fn add(&&other: T) -> T { return self + other; }
// What type of writer are we?
enum WriterType { Screen, File }
+#[cfg(stage0)]
impl WriterType: Eq {
pure fn eq(&&other: WriterType) -> bool {
match (self, other) {
}
pure fn ne(&&other: WriterType) -> bool { !self.eq(other) }
}
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl WriterType : Eq {
+ pure fn eq(other: &WriterType) -> bool {
+ match (self, (*other)) {
+ (Screen, Screen) | (File, File) => true,
+ (Screen, _) | (File, _) => false
+ }
+ }
+ pure fn ne(other: &WriterType) -> bool { !self.eq(other) }
+}
// FIXME (#2004): Seekable really should be orthogonal.
// FIXME (#2004): eventually u64
// Core operators and kinds.
-#[cfg(notest)]
#[lang="const"]
trait Const {
// Empty.
}
-#[cfg(notest)]
#[lang="copy"]
trait Copy {
// Empty.
}
-#[cfg(notest)]
#[lang="send"]
trait Send {
// Empty.
}
-#[cfg(notest)]
#[lang="owned"]
trait Owned {
// Empty.
}
-#[cfg(notest)]
+#[cfg(stage0)]
#[lang="add"]
trait Add<RHS,Result> {
pure fn add(rhs: RHS) -> Result;
}
-#[cfg(notest)]
+#[cfg(stage1)]
+#[cfg(stage2)]
+#[lang="add"]
+trait Add<RHS,Result> {
+ pure fn add(rhs: &RHS) -> Result;
+}
+
+#[cfg(stage0)]
#[lang="sub"]
trait Sub<RHS,Result> {
pure fn sub(rhs: RHS) -> Result;
}
-#[cfg(notest)]
+#[cfg(stage1)]
+#[cfg(stage2)]
+#[lang="sub"]
+trait Sub<RHS,Result> {
+ pure fn sub(rhs: &RHS) -> Result;
+}
+
+#[cfg(stage0)]
#[lang="mul"]
trait Mul<RHS,Result> {
pure fn mul(rhs: RHS) -> Result;
}
-#[cfg(notest)]
+#[cfg(stage1)]
+#[cfg(stage2)]
+#[lang="mul"]
+trait Mul<RHS,Result> {
+ pure fn mul(rhs: &RHS) -> Result;
+}
+
+#[cfg(stage0)]
#[lang="div"]
trait Div<RHS,Result> {
pure fn div(rhs: RHS) -> Result;
}
-#[cfg(notest)]
+#[cfg(stage1)]
+#[cfg(stage2)]
+#[lang="div"]
+trait Div<RHS,Result> {
+ pure fn div(rhs: &RHS) -> Result;
+}
+
+#[cfg(stage0)]
#[lang="modulo"]
trait Modulo<RHS,Result> {
pure fn modulo(rhs: RHS) -> Result;
}
-#[cfg(notest)]
+#[cfg(stage1)]
+#[cfg(stage2)]
+#[lang="modulo"]
+trait Modulo<RHS,Result> {
+ pure fn modulo(rhs: &RHS) -> Result;
+}
+
#[lang="neg"]
trait Neg<Result> {
pure fn neg() -> Result;
}
-#[cfg(notest)]
+#[cfg(stage0)]
#[lang="bitand"]
trait BitAnd<RHS,Result> {
pure fn bitand(rhs: RHS) -> Result;
}
-#[cfg(notest)]
+#[cfg(stage1)]
+#[cfg(stage2)]
+#[lang="bitand"]
+trait BitAnd<RHS,Result> {
+ pure fn bitand(rhs: &RHS) -> Result;
+}
+
+#[cfg(stage0)]
#[lang="bitor"]
trait BitOr<RHS,Result> {
pure fn bitor(rhs: RHS) -> Result;
}
-#[cfg(notest)]
+#[cfg(stage1)]
+#[cfg(stage2)]
+#[lang="bitor"]
+trait BitOr<RHS,Result> {
+ pure fn bitor(rhs: &RHS) -> Result;
+}
+
+#[cfg(stage0)]
#[lang="bitxor"]
trait BitXor<RHS,Result> {
pure fn bitxor(rhs: RHS) -> Result;
}
-#[cfg(notest)]
+#[cfg(stage1)]
+#[cfg(stage2)]
+#[lang="bitxor"]
+trait BitXor<RHS,Result> {
+ pure fn bitxor(rhs: &RHS) -> Result;
+}
+
+#[cfg(stage0)]
#[lang="shl"]
trait Shl<RHS,Result> {
pure fn shl(rhs: RHS) -> Result;
}
-#[cfg(notest)]
+#[cfg(stage1)]
+#[cfg(stage2)]
+#[lang="shl"]
+trait Shl<RHS,Result> {
+ pure fn shl(rhs: &RHS) -> Result;
+}
+
+#[cfg(stage0)]
#[lang="shr"]
trait Shr<RHS,Result> {
pure fn shr(rhs: RHS) -> Result;
}
-#[cfg(notest)]
+#[cfg(stage1)]
+#[cfg(stage2)]
+#[lang="shr"]
+trait Shr<RHS,Result> {
+ pure fn shr(rhs: &RHS) -> Result;
+}
+
#[lang="index"]
trait Index<Index,Result> {
pure fn index(index: Index) -> Result;
pure fn while_some(blk: fn(+T) -> Option<T>) { while_some(self, blk) }
}
+#[cfg(stage0)]
impl<T: Eq> Option<T> : Eq {
pure fn eq(&&other: Option<T>) -> bool {
match self {
}
pure fn ne(&&other: Option<T>) -> bool { !self.eq(other) }
}
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl<T: Eq> Option<T> : Eq {
+ pure fn eq(other: &Option<T>) -> bool {
+ match self {
+ None => {
+ match (*other) {
+ None => true,
+ Some(_) => false
+ }
+ }
+ Some(self_contents) => {
+ match (*other) {
+ None => false,
+ Some(ref other_contents) =>
+ self_contents.eq(other_contents)
+ }
+ }
+ }
+ }
+ pure fn ne(other: &Option<T>) -> bool { !self.eq(other) }
+}
#[test]
fn test_unwrap_ptr() {
}
}
+#[cfg(stage0)]
impl PosixPath : Eq {
pure fn eq(&&other: PosixPath) -> bool {
return self.is_absolute == other.is_absolute &&
}
pure fn ne(&&other: PosixPath) -> bool { !self.eq(other) }
}
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl PosixPath : Eq {
+ pure fn eq(other: &PosixPath) -> bool {
+ return self.is_absolute == (*other).is_absolute &&
+ self.components == (*other).components;
+ }
+ pure fn ne(other: &PosixPath) -> bool { !self.eq(other) }
+}
+#[cfg(stage0)]
impl WindowsPath : Eq {
pure fn eq(&&other: WindowsPath) -> bool {
return self.host == other.host &&
}
pure fn ne(&&other: WindowsPath) -> bool { !self.eq(other) }
}
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl WindowsPath : Eq {
+ pure fn eq(other: &WindowsPath) -> bool {
+ return self.host == (*other).host &&
+ self.device == (*other).device &&
+ self.is_absolute == (*other).is_absolute &&
+ self.components == (*other).components;
+ }
+ pure fn ne(other: &WindowsPath) -> bool { !self.eq(other) }
+}
// FIXME (#3227): when default methods in traits are working, de-duplicate
// PosixPath and WindowsPath, most of their methods are common.
Terminated
}
+#[cfg(stage0)]
impl State: Eq {
pure fn eq(&&other: State) -> bool {
(self as uint) == (other as uint)
}
pure fn ne(&&other: State) -> bool { !self.eq(other) }
}
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl State : Eq {
+ pure fn eq(other: &State) -> bool {
+ (self as uint) == ((*other) as uint)
+ }
+ pure fn ne(other: &State) -> bool { !self.eq(other) }
+}
struct BufferHeader {
// Tracks whether this buffer needs to be freed. We can probably
}
// Equality for pointers
+#[cfg(stage0)]
impl<T> *const T : Eq {
pure fn eq(&&other: *const T) -> bool unsafe {
let a: uint = cast::reinterpret_cast(&self);
}
pure fn ne(&&other: *const T) -> bool { !self.eq(other) }
}
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl<T> *const T : Eq {
+ pure fn eq(other: &*const T) -> bool unsafe {
+ let a: uint = cast::reinterpret_cast(&self);
+ let b: uint = cast::reinterpret_cast(&(*other));
+ return a == b;
+ }
+ pure fn ne(other: &*const T) -> bool { !self.eq(other) }
+}
// Comparison for pointers
+#[cfg(stage0)]
impl<T> *const T : Ord {
pure fn lt(&&other: *const T) -> bool unsafe {
let a: uint = cast::reinterpret_cast(&self);
return a > b;
}
}
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl<T> *const T : Ord {
+ pure fn lt(other: &*const T) -> bool unsafe {
+ let a: uint = cast::reinterpret_cast(&self);
+ let b: uint = cast::reinterpret_cast(&(*other));
+ return a < b;
+ }
+ pure fn le(other: &*const T) -> bool unsafe {
+ let a: uint = cast::reinterpret_cast(&self);
+ let b: uint = cast::reinterpret_cast(&(*other));
+ return a <= b;
+ }
+ pure fn ge(other: &*const T) -> bool unsafe {
+ let a: uint = cast::reinterpret_cast(&self);
+ let b: uint = cast::reinterpret_cast(&(*other));
+ return a >= b;
+ }
+ pure fn gt(other: &*const T) -> bool unsafe {
+ let a: uint = cast::reinterpret_cast(&self);
+ let b: uint = cast::reinterpret_cast(&(*other));
+ return a > b;
+ }
+}
// Equality for region pointers
+#[cfg(stage0)]
impl<T:Eq> &const T : Eq {
pure fn eq(&&other: &const T) -> bool { return *self == *other; }
pure fn ne(&&other: &const T) -> bool { return *self != *other; }
}
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl<T:Eq> &const T : Eq {
+ pure fn eq(other: & &const T) -> bool { return *self == *(*other); }
+ pure fn ne(other: & &const T) -> bool { return *self != *(*other); }
+}
// Comparison for region pointers
+#[cfg(stage0)]
impl<T:Ord> &const T : Ord {
pure fn lt(&&other: &const T) -> bool { *self < *other }
pure fn le(&&other: &const T) -> bool { *self <= *other }
pure fn ge(&&other: &const T) -> bool { *self >= *other }
pure fn gt(&&other: &const T) -> bool { *self > *other }
}
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl<T:Ord> &const T : Ord {
+ pure fn lt(other: & &const T) -> bool { *self < *(*other) }
+ pure fn le(other: & &const T) -> bool { *self <= *(*other) }
+ pure fn ge(other: & &const T) -> bool { *self >= *(*other) }
+ pure fn gt(other: & &const T) -> bool { *self > *(*other) }
+}
#[test]
fn test() {
Degenerate // This is a degenerate enum (exactly 1 variant)
}
+#[cfg(stage0)]
impl EnumVisitState : cmp::Eq {
pure fn eq(&&other: EnumVisitState) -> bool {
(self as uint) == (other as uint)
}
pure fn ne(&&other: EnumVisitState) -> bool { !self.eq(other) }
}
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl EnumVisitState : cmp::Eq {
+ pure fn eq(other: &EnumVisitState) -> bool {
+ (self as uint) == ((*other) as uint)
+ }
+ pure fn ne(other: &EnumVisitState) -> bool { !self.eq(other) }
+}
struct EnumState {
end_ptr: *c_void,
}
}
+#[cfg(stage0)]
impl<T:Eq,U:Eq> Result<T,U> : Eq {
pure fn eq(&&other: Result<T,U>) -> bool {
match self {
}
pure fn ne(&&other: Result<T,U>) -> bool { !self.eq(other) }
}
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl<T:Eq,U:Eq> Result<T,U> : Eq {
+ pure fn eq(other: &Result<T,U>) -> bool {
+ match self {
+ Ok(e0a) => {
+ match (*other) {
+ Ok(e0b) => e0a == e0b,
+ _ => false
+ }
+ }
+ Err(e0a) => {
+ match (*other) {
+ Err(e0b) => e0a == e0b,
+ _ => false
+ }
+ }
+ }
+ }
+ pure fn ne(other: &Result<T,U>) -> bool { !self.eq(other) }
+}
#[cfg(test)]
#[allow(non_implicitly_copyable_typarams)]
raw,
extensions,
StrSlice,
- UniqueStr;
+ UniqueStr,
+ traits;
/*
Section: Creating a string
!le(a, b)
}
+#[cfg(stage0)]
impl &str: Eq {
#[inline(always)]
pure fn eq(&&other: &str) -> bool {
#[inline(always)]
pure fn ne(&&other: &str) -> bool { !self.eq(other) }
}
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl &str : Eq {
+ #[inline(always)]
+ pure fn eq(other: & &str) -> bool {
+ eq_slice(self, (*other))
+ }
+ #[inline(always)]
+ pure fn ne(other: & &str) -> bool { !self.eq(other) }
+}
+#[cfg(stage0)]
impl ~str: Eq {
#[inline(always)]
pure fn eq(&&other: ~str) -> bool {
#[inline(always)]
pure fn ne(&&other: ~str) -> bool { !self.eq(other) }
}
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl ~str : Eq {
+ #[inline(always)]
+ pure fn eq(other: &~str) -> bool {
+ eq_slice(self, (*other))
+ }
+ #[inline(always)]
+ pure fn ne(other: &~str) -> bool { !self.eq(other) }
+}
+#[cfg(stage0)]
impl @str: Eq {
#[inline(always)]
pure fn eq(&&other: @str) -> bool {
#[inline(always)]
pure fn ne(&&other: @str) -> bool { !self.eq(other) }
}
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl @str : Eq {
+ #[inline(always)]
+ pure fn eq(other: &@str) -> bool {
+ eq_slice(self, (*other))
+ }
+ #[inline(always)]
+ pure fn ne(other: &@str) -> bool { !self.eq(other) }
+}
+#[cfg(stage0)]
impl ~str : Ord {
#[inline(always)]
pure fn lt(&&other: ~str) -> bool { lt(self, other) }
#[inline(always)]
pure fn gt(&&other: ~str) -> bool { gt(self, other) }
}
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl ~str : Ord {
+ #[inline(always)]
+ pure fn lt(other: &~str) -> bool { lt(self, (*other)) }
+ #[inline(always)]
+ pure fn le(other: &~str) -> bool { le(self, (*other)) }
+ #[inline(always)]
+ pure fn ge(other: &~str) -> bool { ge(self, (*other)) }
+ #[inline(always)]
+ pure fn gt(other: &~str) -> bool { gt(self, (*other)) }
+}
+#[cfg(stage0)]
impl &str : Ord {
#[inline(always)]
pure fn lt(&&other: &str) -> bool { lt(self, other) }
#[inline(always)]
pure fn gt(&&other: &str) -> bool { gt(self, other) }
}
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl &str : Ord {
+ #[inline(always)]
+ pure fn lt(other: & &str) -> bool { lt(self, (*other)) }
+ #[inline(always)]
+ pure fn le(other: & &str) -> bool { le(self, (*other)) }
+ #[inline(always)]
+ pure fn ge(other: & &str) -> bool { ge(self, (*other)) }
+ #[inline(always)]
+ pure fn gt(other: & &str) -> bool { gt(self, (*other)) }
+}
+#[cfg(stage0)]
impl @str : Ord {
#[inline(always)]
pure fn lt(&&other: @str) -> bool { lt(self, other) }
#[inline(always)]
pure fn gt(&&other: @str) -> bool { gt(self, other) }
}
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl @str : Ord {
+ #[inline(always)]
+ pure fn lt(other: &@str) -> bool { lt(self, (*other)) }
+ #[inline(always)]
+ pure fn le(other: &@str) -> bool { le(self, (*other)) }
+ #[inline(always)]
+ pure fn ge(other: &@str) -> bool { ge(self, (*other)) }
+ #[inline(always)]
+ pure fn gt(other: &@str) -> bool { gt(self, (*other)) }
+}
/*
Section: Iterating through strings
}
#[cfg(notest)]
-impl ~str: Add<&str,~str> {
- #[inline(always)]
- pure fn add(rhs: &str) -> ~str {
- append(copy self, rhs)
+mod traits {
+ #[cfg(stage0)]
+ impl ~str: Add<&str,~str> {
+ #[inline(always)]
+ pure fn add(rhs: &str) -> ~str {
+ append(copy self, rhs)
+ }
+ }
+ #[cfg(stage1)]
+ #[cfg(stage2)]
+ impl ~str : Add<&str,~str> {
+ #[inline(always)]
+ pure fn add(rhs: & &str) -> ~str {
+ append(copy self, (*rhs))
+ }
}
}
+#[cfg(test)]
+mod traits {}
+
trait StrSlice {
fn all(it: fn(char) -> bool) -> bool;
fn any(it: fn(char) -> bool) -> bool;
TaskHandle(task_id)
}
+#[cfg(stage0)]
impl Task : cmp::Eq {
pure fn eq(&&other: Task) -> bool { *self == *other }
pure fn ne(&&other: Task) -> bool { !self.eq(other) }
}
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl Task : cmp::Eq {
+ pure fn eq(other: &Task) -> bool { *self == *(*other) }
+ pure fn ne(other: &Task) -> bool { !self.eq(other) }
+}
/**
* Indicates the manner in which a task exited.
Failure,
}
+#[cfg(stage0)]
impl TaskResult: Eq {
pure fn eq(&&other: TaskResult) -> bool {
match (self, other) {
}
pure fn ne(&&other: TaskResult) -> bool { !self.eq(other) }
}
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl TaskResult : Eq {
+ pure fn eq(other: &TaskResult) -> bool {
+ match (self, (*other)) {
+ (Success, Success) | (Failure, Failure) => true,
+ (Success, _) | (Failure, _) => false
+ }
+ }
+ pure fn ne(other: &TaskResult) -> bool { !self.eq(other) }
+}
/// A message type for notifying of task lifecycle events
enum Notification {
Exit(Task, TaskResult)
}
+#[cfg(stage0)]
impl Notification : cmp::Eq {
pure fn eq(&&other: Notification) -> bool {
match self {
}
pure fn ne(&&other: Notification) -> bool { !self.eq(other) }
}
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl Notification : cmp::Eq {
+ pure fn eq(other: &Notification) -> bool {
+ match self {
+ Exit(e0a, e1a) => {
+ match (*other) {
+ Exit(e0b, e1b) => e0a == e0b && e1a == e1b
+ }
+ }
+ }
+ }
+ pure fn ne(other: &Notification) -> bool { !self.eq(other) }
+}
/// Scheduler modes
enum SchedMode {
PlatformThread
}
+#[cfg(stage0)]
impl SchedMode : cmp::Eq {
pure fn eq(&&other: SchedMode) -> bool {
match self {
!self.eq(other)
}
}
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl SchedMode : cmp::Eq {
+ pure fn eq(other: &SchedMode) -> bool {
+ match self {
+ SingleThreaded => {
+ match (*other) {
+ SingleThreaded => true,
+ _ => false
+ }
+ }
+ ThreadPerCore => {
+ match (*other) {
+ ThreadPerCore => true,
+ _ => false
+ }
+ }
+ ThreadPerTask => {
+ match (*other) {
+ ThreadPerTask => true,
+ _ => false
+ }
+ }
+ ManualThreads(e0a) => {
+ match (*other) {
+ ManualThreads(e0b) => e0a == e0b,
+ _ => false
+ }
+ }
+ PlatformThread => {
+ match (*other) {
+ PlatformThread => true,
+ _ => false
+ }
+ }
+ }
+ }
+ pure fn ne(other: &SchedMode) -> bool {
+ !self.eq(other)
+ }
+}
/**
* Scheduler configuration options
trait LocalData { }
impl<T: Owned> @T: LocalData { }
+#[cfg(stage0)]
impl LocalData: Eq {
pure fn eq(&&other: LocalData) -> bool unsafe {
let ptr_a: (uint, uint) = cast::reinterpret_cast(&self);
}
pure fn ne(&&other: LocalData) -> bool { !self.eq(other) }
}
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl LocalData: Eq {
+ pure fn eq(other: &@LocalData) -> bool unsafe {
+ let ptr_a: (uint, uint) = cast::reinterpret_cast(&self);
+ let ptr_b: (uint, uint) = cast::reinterpret_cast(other);
+ return ptr_a == ptr_b;
+ }
+ pure fn ne(other: &@LocalData) -> bool { !self.eq(other) }
+}
// We use dvec because it's the best data structure in core. If TLS is used
// heavily in future, this could be made more efficient with a proper map.
}
}
+#[cfg(stage0)]
impl<A: Eq, B: Eq> (A, B): Eq {
pure fn eq(&&other: (A, B)) -> bool {
// XXX: This would be a lot less wordy with ref bindings, but I don't
}
pure fn ne(&&other: (A, B)) -> bool { !self.eq(other) }
}
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl<A: Eq, B: Eq> (A, B) : Eq {
+ pure fn eq(other: &(A, B)) -> bool {
+ // XXX: This would be a lot less wordy with ref bindings, but I don't
+ // trust that they work yet.
+ match self {
+ (self_a, self_b) => {
+ match (*other) {
+ (ref other_a, ref other_b) => {
+ self_a.eq(other_a) && self_b.eq(other_b)
+ }
+ }
+ }
+ }
+ }
+ pure fn ne(other: &(A, B)) -> bool { !self.eq(other) }
+}
+#[cfg(stage0)]
impl<A: Ord, B: Ord> (A, B): Ord {
pure fn lt(&&other: (A, B)) -> bool {
match self {
pure fn ge(&&other: (A, B)) -> bool { !self.lt(other) }
pure fn gt(&&other: (A, B)) -> bool { other.lt(self) }
}
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl<A: Ord, B: Ord> (A, B) : Ord {
+ pure fn lt(other: &(A, B)) -> bool {
+ match self {
+ (ref self_a, ref self_b) => {
+ match (*other) {
+ (ref other_a, ref other_b) => {
+ if (*self_a).lt(other_a) { return true; }
+ if (*other_a).lt(self_a) { return false; }
+ if (*self_b).lt(other_b) { return true; }
+ return false;
+ }
+ }
+ }
+ }
+ }
+ pure fn le(other: &(A, B)) -> bool { !(*other).lt(&self) }
+ pure fn ge(other: &(A, B)) -> bool { !self.lt(other) }
+ pure fn gt(other: &(A, B)) -> bool { (*other).lt(&self) }
+}
+#[cfg(stage0)]
impl<A: Eq, B: Eq, C: Eq> (A, B, C): Eq {
pure fn eq(&&other: (A, B, C)) -> bool {
// XXX: This would be a lot less wordy with ref bindings, but I don't
}
pure fn ne(&&other: (A, B, C)) -> bool { !self.eq(other) }
}
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl<A: Eq, B: Eq, C: Eq> (A, B, C) : Eq {
+ pure fn eq(other: &(A, B, C)) -> bool {
+ // XXX: This would be a lot less wordy with ref bindings, but I don't
+ // trust that they work yet.
+ match self {
+ (self_a, self_b, self_c) => {
+ match (*other) {
+ (ref other_a, ref other_b, ref other_c) => {
+ self_a.eq(other_a) &&
+ self_b.eq(other_b) &&
+ self_c.eq(other_c)
+ }
+ }
+ }
+ }
+ }
+ pure fn ne(other: &(A, B, C)) -> bool { !self.eq(other) }
+}
+#[cfg(stage0)]
impl<A: Ord, B: Ord, C: Ord> (A, B, C): Ord {
pure fn lt(&&other: (A, B, C)) -> bool {
match self {
pure fn ge(&&other: (A, B, C)) -> bool { !self.lt(other) }
pure fn gt(&&other: (A, B, C)) -> bool { other.lt(self) }
}
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl<A: Ord, B: Ord, C: Ord> (A, B, C) : Ord {
+ pure fn lt(other: &(A, B, C)) -> bool {
+ match self {
+ (ref self_a, ref self_b, ref self_c) => {
+ match (*other) {
+ (ref other_a, ref other_b, ref other_c) => {
+ if (*self_a).lt(other_a) { return true; }
+ if (*other_a).lt(self_a) { return false; }
+ if (*self_b).lt(other_b) { return true; }
+ if (*other_b).lt(self_b) { return false; }
+ if (*self_c).lt(other_c) { return true; }
+ return false;
+ }
+ }
+ }
+ }
+ }
+ pure fn le(other: &(A, B, C)) -> bool { !(*other).lt(&self) }
+ pure fn ge(other: &(A, B, C)) -> bool { !self.lt(other) }
+ pure fn gt(other: &(A, B, C)) -> bool { (*other).lt(&self) }
+}
#[test]
#[allow(non_implicitly_copyable_typarams)]
max_value ^ i
}
+#[cfg(stage0)]
impl T: Ord {
pure fn lt(&&other: T) -> bool { self < other }
pure fn le(&&other: T) -> bool { self <= other }
pure fn ge(&&other: T) -> bool { self >= other }
pure fn gt(&&other: T) -> bool { self > other }
}
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl T : Ord {
+ pure fn lt(other: &T) -> bool { self < (*other) }
+ pure fn le(other: &T) -> bool { self <= (*other) }
+ pure fn ge(other: &T) -> bool { self >= (*other) }
+ pure fn gt(other: &T) -> bool { self > (*other) }
+}
+#[cfg(stage0)]
impl T: Eq {
pure fn eq(&&other: T) -> bool { return self == other; }
pure fn ne(&&other: T) -> bool { return self != other; }
}
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl T : Eq {
+ pure fn eq(other: &T) -> bool { return self == (*other); }
+ pure fn ne(other: &T) -> bool { return self != (*other); }
+}
impl T: num::Num {
pure fn add(&&other: T) -> T { return self + other; }
use cmp::{Eq, Ord};
+#[cfg(stage0)]
impl<T:Eq> ~const T : Eq {
pure fn eq(&&other: ~const T) -> bool { *self == *other }
pure fn ne(&&other: ~const T) -> bool { *self != *other }
}
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl<T:Eq> ~const T : Eq {
+ pure fn eq(other: &~const T) -> bool { *self == *(*other) }
+ pure fn ne(other: &~const T) -> bool { *self != *(*other) }
+}
+#[cfg(stage0)]
impl<T:Ord> ~const T : Ord {
pure fn lt(&&other: ~const T) -> bool { *self < *other }
pure fn le(&&other: ~const T) -> bool { *self <= *other }
pure fn ge(&&other: ~const T) -> bool { *self >= *other }
pure fn gt(&&other: ~const T) -> bool { *self > *other }
}
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl<T:Ord> ~const T : Ord {
+ pure fn lt(other: &~const T) -> bool { *self < *(*other) }
+ pure fn le(other: &~const T) -> bool { *self <= *(*other) }
+ pure fn ge(other: &~const T) -> bool { *self >= *(*other) }
+ pure fn gt(other: &~const T) -> bool { *self > *(*other) }
+}
use cmp::{Eq, Ord};
+#[cfg(stage0)]
impl () : Eq {
pure fn eq(&&_other: ()) -> bool { true }
pure fn ne(&&_other: ()) -> bool { false }
}
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl () : Eq {
+ pure fn eq(_other: &()) -> bool { true }
+ pure fn ne(_other: &()) -> bool { false }
+}
+#[cfg(stage0)]
impl () : Ord {
pure fn lt(&&_other: ()) -> bool { false }
pure fn le(&&_other: ()) -> bool { true }
pure fn ge(&&_other: ()) -> bool { true }
pure fn gt(&&_other: ()) -> bool { false }
}
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl () : Ord {
+ pure fn lt(_other: &()) -> bool { false }
+ pure fn le(_other: &()) -> bool { true }
+ pure fn ge(_other: &()) -> bool { true }
+ pure fn gt(_other: &()) -> bool { false }
+}
let x = ~[(5, false)];
//FIXME #3387 assert x.eq(id(copy x));
let y = copy x;
- assert x.eq(id(y));
+ assert x.eq(&id(y));
}
#[test]
fn test_swap() {
export ImmutableCopyableVector;
export IterTraitExtensions;
export vec_concat;
+export traits;
#[abi = "cdecl"]
extern mod rustrt {
return true;
}
+#[cfg(stage0)]
impl<T: Eq> &[T]: Eq {
#[inline(always)]
pure fn eq(&&other: &[T]) -> bool { eq(self, other) }
#[inline(always)]
pure fn ne(&&other: &[T]) -> bool { !self.eq(other) }
}
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl<T: Eq> &[T] : Eq {
+ #[inline(always)]
+ pure fn eq(other: & &[T]) -> bool { eq(self, (*other)) }
+ #[inline(always)]
+ pure fn ne(other: & &[T]) -> bool { !self.eq(other) }
+}
+#[cfg(stage0)]
impl<T: Eq> ~[T]: Eq {
#[inline(always)]
pure fn eq(&&other: ~[T]) -> bool { eq(self, other) }
#[inline(always)]
pure fn ne(&&other: ~[T]) -> bool { !self.eq(other) }
}
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl<T: Eq> ~[T] : Eq {
+ #[inline(always)]
+ pure fn eq(other: &~[T]) -> bool { eq(self, (*other)) }
+ #[inline(always)]
+ pure fn ne(other: &~[T]) -> bool { !self.eq(other) }
+}
+#[cfg(stage0)]
impl<T: Eq> @[T]: Eq {
#[inline(always)]
pure fn eq(&&other: @[T]) -> bool { eq(self, other) }
#[inline(always)]
pure fn ne(&&other: @[T]) -> bool { !self.eq(other) }
}
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl<T: Eq> @[T] : Eq {
+ #[inline(always)]
+ pure fn eq(other: &@[T]) -> bool { eq(self, (*other)) }
+ #[inline(always)]
+ pure fn ne(other: &@[T]) -> bool { !self.eq(other) }
+}
// Lexicographical comparison
pure fn ge<T: Ord>(a: &[T], b: &[T]) -> bool { !lt(a, b) }
pure fn gt<T: Ord>(a: &[T], b: &[T]) -> bool { lt(b, a) }
+#[cfg(stage0)]
impl<T: Ord> &[T]: Ord {
#[inline(always)]
pure fn lt(&&other: &[T]) -> bool { lt(self, other) }
#[inline(always)]
pure fn gt(&&other: &[T]) -> bool { gt(self, other) }
}
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl<T: Ord> &[T] : Ord {
+ #[inline(always)]
+ pure fn lt(other: & &[T]) -> bool { lt(self, (*other)) }
+ #[inline(always)]
+ pure fn le(other: & &[T]) -> bool { le(self, (*other)) }
+ #[inline(always)]
+ pure fn ge(other: & &[T]) -> bool { ge(self, (*other)) }
+ #[inline(always)]
+ pure fn gt(other: & &[T]) -> bool { gt(self, (*other)) }
+}
+#[cfg(stage0)]
impl<T: Ord> ~[T]: Ord {
#[inline(always)]
pure fn lt(&&other: ~[T]) -> bool { lt(self, other) }
#[inline(always)]
pure fn gt(&&other: ~[T]) -> bool { gt(self, other) }
}
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl<T: Ord> ~[T] : Ord {
+ #[inline(always)]
+ pure fn lt(other: &~[T]) -> bool { lt(self, (*other)) }
+ #[inline(always)]
+ pure fn le(other: &~[T]) -> bool { le(self, (*other)) }
+ #[inline(always)]
+ pure fn ge(other: &~[T]) -> bool { ge(self, (*other)) }
+ #[inline(always)]
+ pure fn gt(other: &~[T]) -> bool { gt(self, (*other)) }
+}
+#[cfg(stage0)]
impl<T: Ord> @[T]: Ord {
#[inline(always)]
pure fn lt(&&other: @[T]) -> bool { lt(self, other) }
#[inline(always)]
pure fn gt(&&other: @[T]) -> bool { gt(self, other) }
}
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl<T: Ord> @[T] : Ord {
+ #[inline(always)]
+ pure fn lt(other: &@[T]) -> bool { lt(self, (*other)) }
+ #[inline(always)]
+ pure fn le(other: &@[T]) -> bool { le(self, (*other)) }
+ #[inline(always)]
+ pure fn ge(other: &@[T]) -> bool { ge(self, (*other)) }
+ #[inline(always)]
+ pure fn gt(other: &@[T]) -> bool { gt(self, (*other)) }
+}
#[cfg(notest)]
-impl<T: Copy> ~[T]: Add<&[const T],~[T]> {
- #[inline(always)]
- pure fn add(rhs: &[const T]) -> ~[T] {
- append(copy self, rhs)
+mod traits {
+ #[cfg(stage0)]
+ impl<T: Copy> ~[T]: Add<&[const T],~[T]> {
+ #[inline(always)]
+ pure fn add(rhs: &[const T]) -> ~[T] {
+ append(copy self, rhs)
+ }
}
-}
-impl<T: Copy> ~[mut T]: Add<&[const T],~[mut T]> {
- #[inline(always)]
- pure fn add(rhs: &[const T]) -> ~[mut T] {
- append_mut(self, rhs)
+ #[cfg(stage1)]
+ #[cfg(stage2)]
+ impl<T: Copy> ~[T] : Add<&[const T],~[T]> {
+ #[inline(always)]
+ pure fn add(rhs: & &[const T]) -> ~[T] {
+ append(copy self, (*rhs))
+ }
+ }
+
+ #[cfg(stage0)]
+ impl<T: Copy> ~[mut T]: Add<&[const T],~[mut T]> {
+ #[inline(always)]
+ pure fn add(rhs: &[const T]) -> ~[mut T] {
+ append_mut(self, rhs)
+ }
+ }
+ #[cfg(stage1)]
+ #[cfg(stage2)]
+ impl<T: Copy> ~[mut T] : Add<&[const T],~[mut T]> {
+ #[inline(always)]
+ pure fn add(rhs: & &[const T]) -> ~[mut T] {
+ append_mut(self, (*rhs))
+ }
}
}
+#[cfg(test)]
+mod traits {}
+
trait ConstVector {
pure fn is_empty() -> bool;
pure fn is_not_empty() -> bool;
type RecCy = {x: int, y: int, t: Taggy};
+#[cfg(stage0)]
impl Taggy : Eq {
pure fn eq(other: Taggy) -> bool {
match self {
}
pure fn ne(other: Taggy) -> bool { !self.eq(other) }
}
+ #[cfg(stage1)]
+ #[cfg(stage2)]
+ impl Taggy : Eq {
+ pure fn eq(other: &Taggy) -> bool {
+ match self {
+ One(a1) => match (*other) {
+ One(b1) => return a1 == b1,
+ _ => return false
+ },
+ Two(a1, a2) => match (*other) {
+ Two(b1, b2) => return a1 == b1 && a2 == b2,
+ _ => return false
+ },
+ Three(a1, a2, a3) => match (*other) {
+ Three(b1, b2, b3) => return a1 == b1 && a2 == b2 && a3 == b3,
+ _ => return false
+ }
+ }
+ }
+ pure fn ne(other: &Taggy) -> bool { !self.eq(other) }
+ }
+#[cfg(stage0)]
impl Taggypar<int> : Eq {
//let eq4: EqFn<Taggypar<int>> = |x,y| taggypareq::<int>(x, y);
pure fn eq(other: Taggypar<int>) -> bool {
}
pure fn ne(other: Taggypar<int>) -> bool { !self.eq(other) }
}
+ #[cfg(stage1)]
+ #[cfg(stage2)]
+ impl Taggypar<int> : Eq {
+ //let eq4: EqFn<Taggypar<int>> = |x,y| taggypareq::<int>(x, y);
+ pure fn eq(other: &Taggypar<int>) -> bool {
+ match self {
+ Onepar::<int>(a1) => match (*other) {
+ Onepar::<int>(b1) => return a1 == b1,
+ _ => return false
+ },
+ Twopar::<int>(a1, a2) => match (*other) {
+ Twopar::<int>(b1, b2) => return a1 == b1 && a2 == b2,
+ _ => return false
+ },
+ Threepar::<int>(a1, a2, a3) => match (*other) {
+ Threepar::<int>(b1, b2, b3) => {
+ return a1 == b1 && a2 == b2 && a3 == b3
+ }
+ _ => return false
+ }
+ }
+ }
+ pure fn ne(other: &Taggypar<int>) -> bool { !self.eq(other) }
+ }
+#[cfg(stage0)]
impl RecCy : Eq {
pure fn eq(other: RecCy) -> bool {
return self.x == other.x && self.y == other.y && self.t == other.t;
}
pure fn ne(other: RecCy) -> bool { !self.eq(other) }
}
+ #[cfg(stage1)]
+ #[cfg(stage2)]
+ impl RecCy : Eq {
+ pure fn eq(other: &RecCy) -> bool {
+ return self.x == (*other).x && self.y == (*other).y &&
+ self.t == (*other).t;
+ }
+ pure fn ne(other: &RecCy) -> bool { !self.eq(other) }
+ }
#[test]
fn test_param_int() {
} else { Long(unm) };
}
+#[cfg(stage0)]
impl Name : Eq {
pure fn eq(&&other: Name) -> bool {
match self {
}
pure fn ne(&&other: Name) -> bool { !self.eq(other) }
}
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl Name : Eq {
+ pure fn eq(other: &Name) -> bool {
+ match self {
+ Long(e0a) => {
+ match (*other) {
+ Long(e0b) => e0a == e0b,
+ _ => false
+ }
+ }
+ Short(e0a) => {
+ match (*other) {
+ Short(e0b) => e0a == e0b,
+ _ => false
+ }
+ }
+ }
+ }
+ pure fn ne(other: &Name) -> bool { !self.eq(other) }
+}
+#[cfg(stage0)]
impl Occur : Eq {
pure fn eq(&&other: Occur) -> bool {
(self as uint) == (other as uint)
}
pure fn ne(&&other: Occur) -> bool { !self.eq(other) }
}
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl Occur : Eq {
+ pure fn eq(other: &Occur) -> bool {
+ (self as uint) == ((*other) as uint)
+ }
+ pure fn ne(other: &Occur) -> bool { !self.eq(other) }
+}
/// Create an option that is required and takes an argument
fn reqopt(name: &str) -> Opt {
UnexpectedArgument_,
}
+#[cfg(stage0)]
impl FailType : Eq {
pure fn eq(&&other: FailType) -> bool {
(self as uint) == (other as uint)
}
pure fn ne(&&other: FailType) -> bool { !self.eq(other) }
}
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl FailType : Eq {
+ pure fn eq(other: &FailType) -> bool {
+ (self as uint) == ((*other) as uint)
+ }
+ pure fn ne(other: &FailType) -> bool { !self.eq(other) }
+}
#[cfg(test)]
mod tests {
}
}
+#[cfg(stage0)]
impl Error : Eq {
pure fn eq(&&other: Error) -> bool {
self.line == other.line &&
}
pure fn ne(&&other: Error) -> bool { !self.eq(other) }
}
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl Error : Eq {
+ pure fn eq(other: &Error) -> bool {
+ self.line == (*other).line &&
+ self.col == (*other).col &&
+ self.msg == (*other).msg
+ }
+ pure fn ne(other: &Error) -> bool { !self.eq(other) }
+}
+#[cfg(stage0)]
impl Json : Eq {
pure fn eq(&&other: Json) -> bool { eq(self, other) }
pure fn ne(&&other: Json) -> bool { !self.eq(other) }
}
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl Json : Eq {
+ pure fn eq(other: &Json) -> bool { eq(self, (*other)) }
+ pure fn ne(other: &Json) -> bool { !self.eq(other) }
+}
+#[cfg(stage0)]
impl Json : Ord {
pure fn lt(&&other: Json) -> bool { lt(self, other) }
pure fn le(&&other: Json) -> bool { !other.lt(self) }
pure fn ge(&&other: Json) -> bool { !self.lt(other) }
pure fn gt(&&other: Json) -> bool { other.lt(self) }
}
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl Json : Ord {
+ pure fn lt(other: &Json) -> bool { lt(self, (*other)) }
+ pure fn le(other: &Json) -> bool { !(*other).lt(&self) }
+ pure fn ge(other: &Json) -> bool { !self.lt(other) }
+ pure fn gt(other: &Json) -> bool { (*other).lt(&self) }
+}
trait ToJson { fn to_json() -> Json; }
}
}
+#[cfg(stage0)]
impl<T:Eq> List<T> : Eq {
pure fn eq(&&other: List<T>) -> bool {
match self {
}
pure fn ne(&&other: List<T>) -> bool { !self.eq(other) }
}
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl<T:Eq> List<T> : Eq {
+ pure fn eq(other: &List<T>) -> bool {
+ match self {
+ Cons(e0a, e1a) => {
+ match (*other) {
+ Cons(e0b, e1b) => e0a == e0b && e1a == e1b,
+ _ => false
+ }
+ }
+ Nil => {
+ match (*other) {
+ Nil => true,
+ _ => false
+ }
+ }
+ }
+ }
+ pure fn ne(other: &List<T>) -> bool { !self.eq(other) }
+}
#[cfg(test)]
mod tests {
}
}
+#[cfg(stage0)]
impl UserInfo : Eq {
pure fn eq(&&other: UserInfo) -> bool {
self.user == other.user && self.pass == other.pass
}
pure fn ne(&&other: UserInfo) -> bool { !self.eq(other) }
}
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl UserInfo : Eq {
+ pure fn eq(other: &UserInfo) -> bool {
+ self.user == (*other).user && self.pass == (*other).pass
+ }
+ pure fn ne(other: &UserInfo) -> bool { !self.eq(other) }
+}
fn query_from_str(rawquery: &str) -> Query {
let mut query: Query = ~[];
Unreserved // all other legal characters
}
+#[cfg(stage0)]
impl Input: Eq {
pure fn eq(&&other: Input) -> bool {
match (self, other) {
}
pure fn ne(&&other: Input) -> bool { !self.eq(other) }
}
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl Input : Eq {
+ pure fn eq(other: &Input) -> bool {
+ match (self, (*other)) {
+ (Digit, Digit) => true,
+ (Hex, Hex) => true,
+ (Unreserved, Unreserved) => true,
+ (Digit, _) => false,
+ (Hex, _) => false,
+ (Unreserved, _) => false
+ }
+ }
+ pure fn ne(other: &Input) -> bool { !self.eq(other) }
+}
// returns userinfo, host, port, and unparsed part, or an error
fn get_authority(rawurl: &str) ->
}
}
+#[cfg(stage0)]
impl Url: Eq {
pure fn eq(&&other: Url) -> bool {
self.scheme == other.scheme
!self.eq(other)
}
}
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl Url : Eq {
+ pure fn eq(other: &Url) -> bool {
+ self.scheme == (*other).scheme
+ && self.user == (*other).user
+ && self.host == (*other).host
+ && self.port == (*other).port
+ && self.path == (*other).path
+ && self.query == (*other).query
+ && self.fragment == (*other).fragment
+ }
+
+ pure fn ne(other: &Url) -> bool {
+ !self.eq(other)
+ }
+}
impl Url: IterBytes {
pure fn iter_bytes(lsb0: bool, f: to_bytes::Cb) {
enum TestResult { TrOk, TrFailed, TrIgnored, }
+#[cfg(stage0)]
impl TestResult : Eq {
pure fn eq(&&other: TestResult) -> bool {
(self as uint) == (other as uint)
}
pure fn ne(&&other: TestResult) -> bool { !self.eq(other) }
}
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl TestResult : Eq {
+ pure fn eq(other: &TestResult) -> bool {
+ (self as uint) == ((*other) as uint)
+ }
+ pure fn ne(other: &TestResult) -> bool { !self.eq(other) }
+}
type ConsoleTestState =
@{out: io::Writer,
/// A record specifying a time value in seconds and nanoseconds.
type Timespec = {sec: i64, nsec: i32};
+#[cfg(stage0)]
impl Timespec : Eq {
pure fn eq(&&other: Timespec) -> bool {
self.sec == other.sec && self.nsec == other.nsec
}
pure fn ne(&&other: Timespec) -> bool { !self.eq(other) }
}
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl Timespec : Eq {
+ pure fn eq(other: &Timespec) -> bool {
+ self.sec == (*other).sec && self.nsec == (*other).nsec
+ }
+ pure fn ne(other: &Timespec) -> bool { !self.eq(other) }
+}
/**
* Returns the current time as a `timespec` containing the seconds and
tm_nsec: i32, // nanoseconds
};
+#[cfg(stage0)]
impl Tm_ : Eq {
pure fn eq(&&other: Tm_) -> bool {
self.tm_sec == other.tm_sec &&
}
pure fn ne(&&other: Tm_) -> bool { !self.eq(other) }
}
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl Tm_ : Eq {
+ pure fn eq(other: &Tm_) -> bool {
+ self.tm_sec == (*other).tm_sec &&
+ self.tm_min == (*other).tm_min &&
+ self.tm_hour == (*other).tm_hour &&
+ self.tm_mday == (*other).tm_mday &&
+ self.tm_mon == (*other).tm_mon &&
+ self.tm_year == (*other).tm_year &&
+ self.tm_wday == (*other).tm_wday &&
+ self.tm_yday == (*other).tm_yday &&
+ self.tm_isdst == (*other).tm_isdst &&
+ self.tm_gmtoff == (*other).tm_gmtoff &&
+ self.tm_zone == (*other).tm_zone &&
+ self.tm_nsec == (*other).tm_nsec
+ }
+ pure fn ne(other: &Tm_) -> bool { !self.eq(other) }
+}
enum Tm {
Tm_(Tm_)
}
+#[cfg(stage0)]
impl Tm : Eq {
pure fn eq(&&other: Tm) -> bool { *self == *other }
pure fn ne(&&other: Tm) -> bool { *self != *other }
}
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl Tm : Eq {
+ pure fn eq(other: &Tm) -> bool { *self == *(*other) }
+ pure fn ne(other: &Tm) -> bool { *self != *(*other) }
+}
fn empty_tm() -> Tm {
Tm_({
#[auto_serialize]
type def_id = {crate: crate_num, node: node_id};
+#[cfg(stage0)]
impl def_id: cmp::Eq {
pure fn eq(&&other: def_id) -> bool {
self.crate == other.crate && self.node == other.node
}
pure fn ne(&&other: def_id) -> bool { !self.eq(other) }
}
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl def_id : cmp::Eq {
+ pure fn eq(other: &def_id) -> bool {
+ self.crate == (*other).crate && self.node == (*other).node
+ }
+ pure fn ne(other: &def_id) -> bool { !self.eq(other) }
+}
const local_crate: crate_num = 0;
const crate_node_id: node_id = 0;
def_label(node_id)
}
+#[cfg(stage0)]
impl def : cmp::Eq {
pure fn eq(&&other: def) -> bool {
match self {
}
pure fn ne(&&other: def) -> bool { !self.eq(other) }
}
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl def : cmp::Eq {
+ pure fn eq(other: &def) -> bool {
+ match self {
+ def_fn(e0a, e1a) => {
+ match (*other) {
+ def_fn(e0b, e1b) => e0a == e0b && e1a == e1b,
+ _ => false
+ }
+ }
+ def_static_method(e0a, e1a) => {
+ match (*other) {
+ def_static_method(e0b, e1b) => e0a == e0b && e1a == e1b,
+ _ => false
+ }
+ }
+ def_self(e0a) => {
+ match (*other) {
+ def_self(e0b) => e0a == e0b,
+ _ => false
+ }
+ }
+ def_mod(e0a) => {
+ match (*other) {
+ def_mod(e0b) => e0a == e0b,
+ _ => false
+ }
+ }
+ def_foreign_mod(e0a) => {
+ match (*other) {
+ def_foreign_mod(e0b) => e0a == e0b,
+ _ => false
+ }
+ }
+ def_const(e0a) => {
+ match (*other) {
+ def_const(e0b) => e0a == e0b,
+ _ => false
+ }
+ }
+ def_arg(e0a, e1a) => {
+ match (*other) {
+ def_arg(e0b, e1b) => e0a == e0b && e1a == e1b,
+ _ => false
+ }
+ }
+ def_local(e0a, e1a) => {
+ match (*other) {
+ def_local(e0b, e1b) => e0a == e0b && e1a == e1b,
+ _ => false
+ }
+ }
+ def_variant(e0a, e1a) => {
+ match (*other) {
+ def_variant(e0b, e1b) => e0a == e0b && e1a == e1b,
+ _ => false
+ }
+ }
+ def_ty(e0a) => {
+ match (*other) {
+ def_ty(e0b) => e0a == e0b,
+ _ => false
+ }
+ }
+ def_prim_ty(e0a) => {
+ match (*other) {
+ def_prim_ty(e0b) => e0a == e0b,
+ _ => false
+ }
+ }
+ def_ty_param(e0a, e1a) => {
+ match (*other) {
+ def_ty_param(e0b, e1b) => e0a == e0b && e1a == e1b,
+ _ => false
+ }
+ }
+ def_binding(e0a, e1a) => {
+ match (*other) {
+ def_binding(e0b, e1b) => e0a == e0b && e1a == e1b,
+ _ => false
+ }
+ }
+ def_use(e0a) => {
+ match (*other) {
+ def_use(e0b) => e0a == e0b,
+ _ => false
+ }
+ }
+ def_upvar(e0a, e1a, e2a, e3a) => {
+ match (*other) {
+ def_upvar(e0b, e1b, e2b, e3b) =>
+ e0a == e0b && e1a == e1b && e2a == e2b && e3a == e3b,
+ _ => false
+ }
+ }
+ def_class(e0a, e1a) => {
+ match (*other) {
+ def_class(e0b, e1b) => e0a == e0b && e1a == e1b,
+ _ => false
+ }
+ }
+ def_typaram_binder(e0a) => {
+ match (*other) {
+ def_typaram_binder(e1a) => e0a == e1a,
+ _ => false
+ }
+ }
+ def_region(e0a) => {
+ match (*other) {
+ def_region(e0b) => e0a == e0b,
+ _ => false
+ }
+ }
+ def_label(e0a) => {
+ match (*other) {
+ def_label(e0b) => e0a == e0b,
+ _ => false
+ }
+ }
+ }
+ }
+ pure fn ne(other: &def) -> bool { !self.eq(other) }
+}
// The set of meta_items that define the compilation environment of the crate,
// used to drive conditional compilation
}
}
+#[cfg(stage0)]
impl binding_mode : cmp::Eq {
pure fn eq(&&other: binding_mode) -> bool {
match self {
}
pure fn ne(&&other: binding_mode) -> bool { !self.eq(other) }
}
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl binding_mode : cmp::Eq {
+ pure fn eq(other: &binding_mode) -> bool {
+ match self {
+ bind_by_value => {
+ match (*other) {
+ bind_by_value => true,
+ _ => false
+ }
+ }
+ bind_by_move => {
+ match (*other) {
+ bind_by_move => true,
+ _ => false
+ }
+ }
+ bind_by_ref(e0a) => {
+ match (*other) {
+ bind_by_ref(e0b) => e0a == e0b,
+ _ => false
+ }
+ }
+ bind_by_implicit_ref => {
+ match (*other) {
+ bind_by_implicit_ref => true,
+ _ => false
+ }
+ }
+ }
+ }
+ pure fn ne(other: &binding_mode) -> bool { !self.eq(other) }
+}
#[auto_serialize]
enum pat_ {
}
}
+#[cfg(stage0)]
impl mutability: cmp::Eq {
pure fn eq(&&other: mutability) -> bool {
(self as uint) == (other as uint)
}
pure fn ne(&&other: mutability) -> bool { !self.eq(other) }
}
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl mutability : cmp::Eq {
+ pure fn eq(other: &mutability) -> bool {
+ (self as uint) == ((*other) as uint)
+ }
+ pure fn ne(other: &mutability) -> bool { !self.eq(other) }
+}
#[auto_serialize]
enum proto {
proto_block, // fn&
}
+#[cfg(stage0)]
impl proto : cmp::Eq {
pure fn eq(&&other: proto) -> bool {
(self as uint) == (other as uint)
}
pure fn ne(&&other: proto) -> bool { !self.eq(other) }
}
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl proto : cmp::Eq {
+ pure fn eq(other: &proto) -> bool {
+ (self as uint) == ((*other) as uint)
+ }
+ pure fn ne(other: &proto) -> bool { !self.eq(other) }
+}
#[auto_serialize]
enum vstore {
gt,
}
+#[cfg(stage0)]
impl binop : cmp::Eq {
pure fn eq(&&other: binop) -> bool {
(self as uint) == (other as uint)
}
pure fn ne(&&other: binop) -> bool { !self.eq(other) }
}
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl binop : cmp::Eq {
+ pure fn eq(other: &binop) -> bool {
+ (self as uint) == ((*other) as uint)
+ }
+ pure fn ne(other: &binop) -> bool { !self.eq(other) }
+}
#[auto_serialize]
enum unop {
neg
}
+#[cfg(stage0)]
impl unop : cmp::Eq {
pure fn eq(&&other: unop) -> bool {
match self {
!self.eq(other)
}
}
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl unop : cmp::Eq {
+ pure fn eq(other: &unop) -> bool {
+ match self {
+ box(e0a) => {
+ match (*other) {
+ box(e0b) => e0a == e0b,
+ _ => false
+ }
+ }
+ uniq(e0a) => {
+ match (*other) {
+ uniq(e0b) => e0a == e0b,
+ _ => false
+ }
+ }
+ deref => {
+ match (*other) {
+ deref => true,
+ _ => false
+ }
+ }
+ not => {
+ match (*other) {
+ not => true,
+ _ => false
+ }
+ }
+ neg => {
+ match (*other) {
+ neg => true,
+ _ => false
+ }
+ }
+ }
+ }
+ pure fn ne(other: &unop) -> bool {
+ !self.eq(other)
+ }
+}
// Generally, after typeck you can get the inferred value
// using ty::resolved_T(...).
}
}
+#[cfg(stage0)]
impl<T:cmp::Eq> inferable<T> : cmp::Eq {
pure fn eq(&&other: inferable<T>) -> bool {
match self {
}
pure fn ne(&&other: inferable<T>) -> bool { !self.eq(other) }
}
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl<T:cmp::Eq> inferable<T> : cmp::Eq {
+ pure fn eq(other: &inferable<T>) -> bool {
+ match self {
+ expl(e0a) => {
+ match (*other) {
+ expl(e0b) => e0a == e0b,
+ _ => false
+ }
+ }
+ infer(e0a) => {
+ match (*other) {
+ infer(e0b) => e0a == e0b,
+ _ => false
+ }
+ }
+ }
+ }
+ pure fn ne(other: &inferable<T>) -> bool { !self.eq(other) }
+}
// "resolved" mode: the real modes.
#[auto_serialize]
}
+#[cfg(stage0)]
impl rmode : cmp::Eq {
pure fn eq(&&other: rmode) -> bool {
(self as uint) == (other as uint)
}
pure fn ne(&&other: rmode) -> bool { !self.eq(other) }
}
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl rmode : cmp::Eq {
+ pure fn eq(other: &rmode) -> bool {
+ (self as uint) == ((*other) as uint)
+ }
+ pure fn ne(other: &rmode) -> bool { !self.eq(other) }
+}
// inferable mode.
#[auto_serialize]
#[auto_serialize]
enum init_op { init_assign, init_move, }
+#[cfg(stage0)]
impl init_op : cmp::Eq {
pure fn eq(&&other: init_op) -> bool {
match self {
}
pure fn ne(&&other: init_op) -> bool { !self.eq(other) }
}
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl init_op : cmp::Eq {
+ pure fn eq(other: &init_op) -> bool {
+ match self {
+ init_assign => {
+ match (*other) {
+ init_assign => true,
+ _ => false
+ }
+ }
+ init_move => {
+ match (*other) {
+ init_move => true,
+ _ => false
+ }
+ }
+ }
+ }
+ pure fn ne(other: &init_op) -> bool { !self.eq(other) }
+}
#[auto_serialize]
type initializer = {op: init_op, expr: @expr};
#[auto_serialize]
enum blk_check_mode { default_blk, unsafe_blk, }
+#[cfg(stage0)]
impl blk_check_mode : cmp::Eq {
pure fn eq(&&other: blk_check_mode) -> bool {
match (self, other) {
}
pure fn ne(&&other: blk_check_mode) -> bool { !self.eq(other) }
}
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl blk_check_mode : cmp::Eq {
+ pure fn eq(other: &blk_check_mode) -> bool {
+ match (self, (*other)) {
+ (default_blk, default_blk) => true,
+ (unsafe_blk, unsafe_blk) => true,
+ (default_blk, _) => false,
+ (unsafe_blk, _) => false,
+ }
+ }
+ pure fn ne(other: &blk_check_mode) -> bool { !self.eq(other) }
+}
#[auto_serialize]
type expr = {id: node_id, callee_id: node_id, node: expr_, span: span};
lit_bool(bool),
}
+#[cfg(stage0)]
impl ast::lit_: cmp::Eq {
pure fn eq(&&other: ast::lit_) -> bool {
match (self, other) {
}
pure fn ne(&&other: ast::lit_) -> bool { !self.eq(other) }
}
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl ast::lit_: cmp::Eq {
+ pure fn eq(other: &ast::lit_) -> bool {
+ match (self, *other) {
+ (lit_str(a), lit_str(b)) => a == b,
+ (lit_int(val_a, ty_a), lit_int(val_b, ty_b)) => {
+ val_a == val_b && ty_a == ty_b
+ }
+ (lit_uint(val_a, ty_a), lit_uint(val_b, ty_b)) => {
+ val_a == val_b && ty_a == ty_b
+ }
+ (lit_int_unsuffixed(a), lit_int_unsuffixed(b)) => a == b,
+ (lit_float(val_a, ty_a), lit_float(val_b, ty_b)) => {
+ val_a == val_b && ty_a == ty_b
+ }
+ (lit_nil, lit_nil) => true,
+ (lit_bool(a), lit_bool(b)) => a == b,
+ (lit_str(_), _) => false,
+ (lit_int(*), _) => false,
+ (lit_uint(*), _) => false,
+ (lit_int_unsuffixed(*), _) => false,
+ (lit_float(*), _) => false,
+ (lit_nil, _) => false,
+ (lit_bool(_), _) => false
+ }
+ }
+ pure fn ne(other: &ast::lit_) -> bool { !self.eq(other) }
+}
// NB: If you change this, you'll probably want to change the corresponding
// type structure in middle/ty.rs as well.
}
}
+#[cfg(stage0)]
impl int_ty: cmp::Eq {
pure fn eq(&&other: int_ty) -> bool {
match (self, other) {
}
pure fn ne(&&other: int_ty) -> bool { !self.eq(other) }
}
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl int_ty : cmp::Eq {
+ pure fn eq(other: &int_ty) -> bool {
+ match (self, (*other)) {
+ (ty_i, ty_i) => true,
+ (ty_char, ty_char) => true,
+ (ty_i8, ty_i8) => true,
+ (ty_i16, ty_i16) => true,
+ (ty_i32, ty_i32) => true,
+ (ty_i64, ty_i64) => true,
+ (ty_i, _) => false,
+ (ty_char, _) => false,
+ (ty_i8, _) => false,
+ (ty_i16, _) => false,
+ (ty_i32, _) => false,
+ (ty_i64, _) => false,
+ }
+ }
+ pure fn ne(other: &int_ty) -> bool { !self.eq(other) }
+}
#[auto_serialize]
enum uint_ty { ty_u, ty_u8, ty_u16, ty_u32, ty_u64, }
}
}
+#[cfg(stage0)]
impl uint_ty: cmp::Eq {
pure fn eq(&&other: uint_ty) -> bool {
match (self, other) {
}
pure fn ne(&&other: uint_ty) -> bool { !self.eq(other) }
}
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl uint_ty : cmp::Eq {
+ pure fn eq(other: &uint_ty) -> bool {
+ match (self, (*other)) {
+ (ty_u, ty_u) => true,
+ (ty_u8, ty_u8) => true,
+ (ty_u16, ty_u16) => true,
+ (ty_u32, ty_u32) => true,
+ (ty_u64, ty_u64) => true,
+ (ty_u, _) => false,
+ (ty_u8, _) => false,
+ (ty_u16, _) => false,
+ (ty_u32, _) => false,
+ (ty_u64, _) => false
+ }
+ }
+ pure fn ne(other: &uint_ty) -> bool { !self.eq(other) }
+}
#[auto_serialize]
enum float_ty { ty_f, ty_f32, ty_f64, }
(self as u8).iter_bytes(lsb0, f)
}
}
+#[cfg(stage0)]
impl float_ty: cmp::Eq {
pure fn eq(&&other: float_ty) -> bool {
match (self, other) {
}
pure fn ne(&&other: float_ty) -> bool { !self.eq(other) }
}
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl float_ty : cmp::Eq {
+ pure fn eq(other: &float_ty) -> bool {
+ match (self, (*other)) {
+ (ty_f, ty_f) | (ty_f32, ty_f32) | (ty_f64, ty_f64) => true,
+ (ty_f, _) | (ty_f32, _) | (ty_f64, _) => false
+ }
+ }
+ pure fn ne(other: &float_ty) -> bool { !self.eq(other) }
+}
#[auto_serialize]
type ty = {id: node_id, node: ty_, span: span};
ty_bool,
}
+#[cfg(stage0)]
impl prim_ty : cmp::Eq {
pure fn eq(&&other: prim_ty) -> bool {
match self {
}
pure fn ne(&&other: prim_ty) -> bool { !self.eq(other) }
}
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl prim_ty : cmp::Eq {
+ pure fn eq(other: &prim_ty) -> bool {
+ match self {
+ ty_int(e0a) => {
+ match (*other) {
+ ty_int(e0b) => e0a == e0b,
+ _ => false
+ }
+ }
+ ty_uint(e0a) => {
+ match (*other) {
+ ty_uint(e0b) => e0a == e0b,
+ _ => false
+ }
+ }
+ ty_float(e0a) => {
+ match (*other) {
+ ty_float(e0b) => e0a == e0b,
+ _ => false
+ }
+ }
+ ty_str => {
+ match (*other) {
+ ty_str => true,
+ _ => false
+ }
+ }
+ ty_bool => {
+ match (*other) {
+ ty_bool => true,
+ _ => false
+ }
+ }
+ }
+ }
+ pure fn ne(other: &prim_ty) -> bool { !self.eq(other) }
+}
#[auto_serialize]
type region = {id: node_id, node: region_};
// Equality and byte-iter (hashing) can be quite approximate for AST types.
// since we only care about this for normalizing them to "real" types.
+#[cfg(stage0)]
impl ty : cmp::Eq {
pure fn eq(&&other: ty) -> bool {
ptr::addr_of(self) == ptr::addr_of(other)
ptr::addr_of(self) != ptr::addr_of(other)
}
}
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl ty : cmp::Eq {
+ pure fn eq(other: &ty) -> bool {
+ ptr::addr_of(self) == ptr::addr_of((*other))
+ }
+ pure fn ne(other: &ty) -> bool {
+ ptr::addr_of(self) != ptr::addr_of((*other))
+ }
+}
impl ty : to_bytes::IterBytes {
pure fn iter_bytes(lsb0: bool, f: to_bytes::Cb) {
}
}
+#[cfg(stage0)]
impl purity : cmp::Eq {
pure fn eq(&&other: purity) -> bool {
(self as uint) == (other as uint)
}
pure fn ne(&&other: purity) -> bool { !self.eq(other) }
}
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl purity : cmp::Eq {
+ pure fn eq(other: &purity) -> bool {
+ (self as uint) == ((*other) as uint)
+ }
+ pure fn ne(other: &purity) -> bool { !self.eq(other) }
+}
#[auto_serialize]
enum ret_style {
}
}
+#[cfg(stage0)]
impl ret_style : cmp::Eq {
pure fn eq(&&other: ret_style) -> bool {
match (self, other) {
}
pure fn ne(&&other: ret_style) -> bool { !self.eq(other) }
}
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl ret_style : cmp::Eq {
+ pure fn eq(other: &ret_style) -> bool {
+ match (self, (*other)) {
+ (noreturn, noreturn) => true,
+ (return_val, return_val) => true,
+ (noreturn, _) => false,
+ (return_val, _) => false,
+ }
+ }
+ pure fn ne(other: &ret_style) -> bool { !self.eq(other) }
+}
#[auto_serialize]
enum self_ty_ {
sty_uniq(mutability) // by-unique-pointer self: `~self`
}
+#[cfg(stage0)]
impl self_ty_ : cmp::Eq {
pure fn eq(&&other: self_ty_) -> bool {
match self {
}
pure fn ne(&&other: self_ty_) -> bool { !self.eq(other) }
}
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl self_ty_ : cmp::Eq {
+ pure fn eq(other: &self_ty_) -> bool {
+ match self {
+ sty_static => {
+ match (*other) {
+ sty_static => true,
+ _ => false
+ }
+ }
+ sty_by_ref => {
+ match (*other) {
+ sty_by_ref => true,
+ _ => false
+ }
+ }
+ sty_value => {
+ match (*other) {
+ sty_value => true,
+ _ => false
+ }
+ }
+ sty_region(e0a) => {
+ match (*other) {
+ sty_region(e0b) => e0a == e0b,
+ _ => false
+ }
+ }
+ sty_box(e0a) => {
+ match (*other) {
+ sty_box(e0b) => e0a == e0b,
+ _ => false
+ }
+ }
+ sty_uniq(e0a) => {
+ match (*other) {
+ sty_uniq(e0b) => e0a == e0b,
+ _ => false
+ }
+ }
+ }
+ }
+ pure fn ne(other: &self_ty_) -> bool { !self.eq(other) }
+}
#[auto_serialize]
type self_ty = spanned<self_ty_>;
#[auto_serialize]
enum foreign_mod_sort { named, anonymous }
+#[cfg(stage0)]
impl foreign_mod_sort : cmp::Eq {
pure fn eq(&&other: foreign_mod_sort) -> bool {
(self as uint) == (other as uint)
}
pure fn ne(&&other: foreign_mod_sort) -> bool { !self.eq(other) }
}
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl foreign_mod_sort : cmp::Eq {
+ pure fn eq(other: &foreign_mod_sort) -> bool {
+ (self as uint) == ((*other) as uint)
+ }
+ pure fn ne(other: &foreign_mod_sort) -> bool { !self.eq(other) }
+}
+#[cfg(stage0)]
impl foreign_abi : cmp::Eq {
pure fn eq(&&other: foreign_abi) -> bool {
match (self, other) {
}
pure fn ne(&&other: foreign_abi) -> bool { !self.eq(other) }
}
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl foreign_abi : cmp::Eq {
+ pure fn eq(other: &foreign_abi) -> bool {
+ match (self, (*other)) {
+ (foreign_abi_rust_intrinsic, foreign_abi_rust_intrinsic) => true,
+ (foreign_abi_cdecl, foreign_abi_cdecl) => true,
+ (foreign_abi_stdcall, foreign_abi_stdcall) => true,
+ (foreign_abi_rust_intrinsic, _) => false,
+ (foreign_abi_cdecl, _) => false,
+ (foreign_abi_stdcall, _) => false,
+ }
+ }
+ pure fn ne(other: &foreign_abi) -> bool { !self.eq(other) }
+}
#[auto_serialize]
type foreign_mod =
#[auto_serialize]
enum namespace { module_ns, type_value_ns }
+#[cfg(stage0)]
impl namespace : cmp::Eq {
pure fn eq(&&other: namespace) -> bool {
(self as uint) == (other as uint)
}
pure fn ne(&&other: namespace) -> bool { !self.eq(other) }
}
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl namespace : cmp::Eq {
+ pure fn eq(other: &namespace) -> bool {
+ (self as uint) == ((*other) as uint)
+ }
+ pure fn ne(other: &namespace) -> bool { !self.eq(other) }
+}
#[auto_serialize]
type view_path = spanned<view_path_>;
#[auto_serialize]
enum attr_style { attr_outer, attr_inner, }
+#[cfg(stage0)]
impl attr_style : cmp::Eq {
pure fn eq(&&other: attr_style) -> bool {
(self as uint) == (other as uint)
}
pure fn ne(&&other: attr_style) -> bool { !self.eq(other) }
}
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl attr_style : cmp::Eq {
+ pure fn eq(other: &attr_style) -> bool {
+ (self as uint) == ((*other) as uint)
+ }
+ pure fn ne(other: &attr_style) -> bool { !self.eq(other) }
+}
// doc-comments are promoted to attributes that have is_sugared_doc = true
#[auto_serialize]
#[auto_serialize]
enum visibility { public, private, inherited }
+#[cfg(stage0)]
impl visibility : cmp::Eq {
pure fn eq(&&other: visibility) -> bool {
match (self, other) {
}
pure fn ne(&&other: visibility) -> bool { !self.eq(other) }
}
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl visibility : cmp::Eq {
+ pure fn eq(other: &visibility) -> bool {
+ match (self, (*other)) {
+ (public, public) => true,
+ (private, private) => true,
+ (inherited, inherited) => true,
+ (public, _) => false,
+ (private, _) => false,
+ (inherited, _) => false,
+ }
+ }
+ pure fn ne(other: &visibility) -> bool { !self.eq(other) }
+}
#[auto_serialize]
type struct_field_ = {
}
}
+#[cfg(stage0)]
impl class_mutability : cmp::Eq {
pure fn eq(&&other: class_mutability) -> bool {
match (self, other) {
}
pure fn ne(&&other: class_mutability) -> bool { !self.eq(other) }
}
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl class_mutability : cmp::Eq {
+ pure fn eq(other: &class_mutability) -> bool {
+ match (self, (*other)) {
+ (class_mutable, class_mutable) => true,
+ (class_immutable, class_immutable) => true,
+ (class_mutable, _) => false,
+ (class_immutable, _) => false,
+ }
+ }
+ pure fn ne(other: &class_mutability) -> bool { !self.eq(other) }
+}
#[auto_serialize]
type class_ctor = spanned<class_ctor_>;
path_name(ident)
}
+#[cfg(stage0)]
impl path_elt : cmp::Eq {
pure fn eq(&&other: path_elt) -> bool {
match self {
}
pure fn ne(&&other: path_elt) -> bool { !self.eq(other) }
}
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl path_elt : cmp::Eq {
+ pure fn eq(other: &path_elt) -> bool {
+ match self {
+ path_mod(e0a) => {
+ match (*other) {
+ path_mod(e0b) => e0a == e0b,
+ _ => false
+ }
+ }
+ path_name(e0a) => {
+ match (*other) {
+ path_name(e0b) => e0a == e0b,
+ _ => false
+ }
+ }
+ }
+ }
+ pure fn ne(other: &path_elt) -> bool { !self.eq(other) }
+}
type path = ~[path_elt];
ia_never,
}
+#[cfg(stage0)]
impl inline_attr : cmp::Eq {
pure fn eq(&&other: inline_attr) -> bool {
(self as uint) == (other as uint)
}
pure fn ne(&&other: inline_attr) -> bool { !self.eq(other) }
}
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl inline_attr : cmp::Eq {
+ pure fn eq(other: &inline_attr) -> bool {
+ (self as uint) == ((*other) as uint)
+ }
+ pure fn ne(other: &inline_attr) -> bool { !self.eq(other) }
+}
/// True if something like #[inline] is found in the list of attrs.
fn find_inline_attr(attrs: ~[ast::attribute]) -> inline_attr {
type file_pos = {ch: uint, byte: uint};
+#[cfg(stage0)]
impl file_pos: cmp::Eq {
pure fn eq(&&other: file_pos) -> bool {
self.ch == other.ch && self.byte == other.byte
}
pure fn ne(&&other: file_pos) -> bool { !self.eq(other) }
}
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl file_pos : cmp::Eq {
+ pure fn eq(other: &file_pos) -> bool {
+ self.ch == (*other).ch && self.byte == (*other).byte
+ }
+ pure fn ne(other: &file_pos) -> bool { !self.eq(other) }
+}
/* A codemap is a thing that maps uints to file/line/column positions
* in a crate. This to make it possible to represent the positions
type span = {lo: uint, hi: uint, expn_info: expn_info};
+#[cfg(stage0)]
impl span : cmp::Eq {
pure fn eq(&&other: span) -> bool {
return self.lo == other.lo && self.hi == other.hi;
}
pure fn ne(&&other: span) -> bool { !self.eq(other) }
}
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl span : cmp::Eq {
+ pure fn eq(other: &span) -> bool {
+ return self.lo == (*other).lo && self.hi == (*other).hi;
+ }
+ pure fn ne(other: &span) -> bool { !self.eq(other) }
+}
fn span_to_str_no_adj(sp: span, cm: codemap) -> ~str {
let lo = lookup_char_pos(cm, sp.lo);
note,
}
+#[cfg(stage0)]
impl level : cmp::Eq {
pure fn eq(&&other: level) -> bool {
(self as uint) == (other as uint)
}
pure fn ne(&&other: level) -> bool { !self.eq(other) }
}
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl level : cmp::Eq {
+ pure fn eq(other: &level) -> bool {
+ (self as uint) == ((*other) as uint)
+ }
+ pure fn ne(other: &level) -> bool { !self.eq(other) }
+}
fn diagnosticstr(lvl: level) -> ~str {
match lvl {
enum direction { send, recv }
+#[cfg(stage0)]
impl direction : cmp::Eq {
pure fn eq(&&other: direction) -> bool {
match (self, other) {
}
pure fn ne(&&other: direction) -> bool { !self.eq(other) }
}
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl direction : cmp::Eq {
+ pure fn eq(other: &direction) -> bool {
+ match (self, (*other)) {
+ (send, send) => true,
+ (recv, recv) => true,
+ (send, _) => false,
+ (recv, _) => false,
+ }
+ }
+ pure fn ne(other: &direction) -> bool { !self.eq(other) }
+}
impl direction: ToStr {
fn to_str() -> ~str {
blank_line, // Just a manual blank line "\n\n", for layout
}
+#[cfg(stage0)]
impl cmnt_style : cmp::Eq {
pure fn eq(&&other: cmnt_style) -> bool {
(self as uint) == (other as uint)
(self as uint) != (other as uint)
}
}
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl cmnt_style : cmp::Eq {
+ pure fn eq(other: &cmnt_style) -> bool {
+ (self as uint) == ((*other) as uint)
+ }
+ pure fn ne(other: &cmnt_style) -> bool {
+ (self as uint) != ((*other) as uint)
+ }
+}
type cmnt = {style: cmnt_style, lines: ~[~str], pos: uint};
ObsoletePrivSection
}
+#[cfg(stage0)]
impl ObsoleteSyntax : cmp::Eq {
pure fn eq(&&other: ObsoleteSyntax) -> bool {
self as uint == other as uint
!self.eq(other)
}
}
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl ObsoleteSyntax : cmp::Eq {
+ pure fn eq(other: &ObsoleteSyntax) -> bool {
+ self as uint == (*other) as uint
+ }
+ pure fn ne(other: &ObsoleteSyntax) -> bool {
+ !self.eq(other)
+ }
+}
impl ObsoleteSyntax: to_bytes::IterBytes {
#[inline(always)]
}
}
+#[cfg(stage0)]
impl restriction : cmp::Eq {
pure fn eq(&&other: restriction) -> bool {
(self as uint) == (other as uint)
}
pure fn ne(&&other: restriction) -> bool { !self.eq(other) }
}
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl restriction : cmp::Eq {
+ pure fn eq(other: &restriction) -> bool {
+ (self as uint) == ((*other) as uint)
+ }
+ pure fn ne(other: &restriction) -> bool { !self.eq(other) }
+}
//
// Local Variables:
words
}
+#[cfg(stage0)]
impl binop : cmp::Eq {
pure fn eq(&&other: binop) -> bool {
(self as uint) == (other as uint)
}
pure fn ne(&&other: binop) -> bool { !self.eq(other) }
}
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl binop : cmp::Eq {
+ pure fn eq(other: &binop) -> bool {
+ (self as uint) == ((*other) as uint)
+ }
+ pure fn ne(other: &binop) -> bool { !self.eq(other) }
+}
+#[cfg(stage0)]
impl token : cmp::Eq {
pure fn eq(&&other: token) -> bool {
match self {
}
pure fn ne(&&other: token) -> bool { !self.eq(other) }
}
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl token : cmp::Eq {
+ pure fn eq(other: &token) -> bool {
+ match self {
+ EQ => {
+ match (*other) {
+ EQ => true,
+ _ => false
+ }
+ }
+ LT => {
+ match (*other) {
+ LT => true,
+ _ => false
+ }
+ }
+ LE => {
+ match (*other) {
+ LE => true,
+ _ => false
+ }
+ }
+ EQEQ => {
+ match (*other) {
+ EQEQ => true,
+ _ => false
+ }
+ }
+ NE => {
+ match (*other) {
+ NE => true,
+ _ => false
+ }
+ }
+ GE => {
+ match (*other) {
+ GE => true,
+ _ => false
+ }
+ }
+ GT => {
+ match (*other) {
+ GT => true,
+ _ => false
+ }
+ }
+ ANDAND => {
+ match (*other) {
+ ANDAND => true,
+ _ => false
+ }
+ }
+ OROR => {
+ match (*other) {
+ OROR => true,
+ _ => false
+ }
+ }
+ NOT => {
+ match (*other) {
+ NOT => true,
+ _ => false
+ }
+ }
+ TILDE => {
+ match (*other) {
+ TILDE => true,
+ _ => false
+ }
+ }
+ BINOP(e0a) => {
+ match (*other) {
+ BINOP(e0b) => e0a == e0b,
+ _ => false
+ }
+ }
+ BINOPEQ(e0a) => {
+ match (*other) {
+ BINOPEQ(e0b) => e0a == e0b,
+ _ => false
+ }
+ }
+ AT => {
+ match (*other) {
+ AT => true,
+ _ => false
+ }
+ }
+ DOT => {
+ match (*other) {
+ DOT => true,
+ _ => false
+ }
+ }
+ DOTDOT => {
+ match (*other) {
+ DOTDOT => true,
+ _ => false
+ }
+ }
+ ELLIPSIS => {
+ match (*other) {
+ ELLIPSIS => true,
+ _ => false
+ }
+ }
+ COMMA => {
+ match (*other) {
+ COMMA => true,
+ _ => false
+ }
+ }
+ SEMI => {
+ match (*other) {
+ SEMI => true,
+ _ => false
+ }
+ }
+ COLON => {
+ match (*other) {
+ COLON => true,
+ _ => false
+ }
+ }
+ MOD_SEP => {
+ match (*other) {
+ MOD_SEP => true,
+ _ => false
+ }
+ }
+ RARROW => {
+ match (*other) {
+ RARROW => true,
+ _ => false
+ }
+ }
+ LARROW => {
+ match (*other) {
+ LARROW => true,
+ _ => false
+ }
+ }
+ DARROW => {
+ match (*other) {
+ DARROW => true,
+ _ => false
+ }
+ }
+ FAT_ARROW => {
+ match (*other) {
+ FAT_ARROW => true,
+ _ => false
+ }
+ }
+ LPAREN => {
+ match (*other) {
+ LPAREN => true,
+ _ => false
+ }
+ }
+ RPAREN => {
+ match (*other) {
+ RPAREN => true,
+ _ => false
+ }
+ }
+ LBRACKET => {
+ match (*other) {
+ LBRACKET => true,
+ _ => false
+ }
+ }
+ RBRACKET => {
+ match (*other) {
+ RBRACKET => true,
+ _ => false
+ }
+ }
+ LBRACE => {
+ match (*other) {
+ LBRACE => true,
+ _ => false
+ }
+ }
+ RBRACE => {
+ match (*other) {
+ RBRACE => true,
+ _ => false
+ }
+ }
+ POUND => {
+ match (*other) {
+ POUND => true,
+ _ => false
+ }
+ }
+ DOLLAR => {
+ match (*other) {
+ DOLLAR => true,
+ _ => false
+ }
+ }
+ LIT_INT(e0a, e1a) => {
+ match (*other) {
+ LIT_INT(e0b, e1b) => e0a == e0b && e1a == e1b,
+ _ => false
+ }
+ }
+ LIT_UINT(e0a, e1a) => {
+ match (*other) {
+ LIT_UINT(e0b, e1b) => e0a == e0b && e1a == e1b,
+ _ => false
+ }
+ }
+ LIT_INT_UNSUFFIXED(e0a) => {
+ match (*other) {
+ LIT_INT_UNSUFFIXED(e0b) => e0a == e0b,
+ _ => false
+ }
+ }
+ LIT_FLOAT(e0a, e1a) => {
+ match (*other) {
+ LIT_FLOAT(e0b, e1b) => e0a == e0b && e1a == e1b,
+ _ => false
+ }
+ }
+ LIT_STR(e0a) => {
+ match (*other) {
+ LIT_STR(e0b) => e0a == e0b,
+ _ => false
+ }
+ }
+ IDENT(e0a, e1a) => {
+ match (*other) {
+ IDENT(e0b, e1b) => e0a == e0b && e1a == e1b,
+ _ => false
+ }
+ }
+ UNDERSCORE => {
+ match (*other) {
+ UNDERSCORE => true,
+ _ => false
+ }
+ }
+ INTERPOLATED(_) => {
+ match (*other) {
+ INTERPOLATED(_) => true,
+ _ => false
+ }
+ }
+ DOC_COMMENT(e0a) => {
+ match (*other) {
+ DOC_COMMENT(e0b) => e0a == e0b,
+ _ => false
+ }
+ }
+ EOF => {
+ match (*other) {
+ EOF => true,
+ _ => false
+ }
+ }
+ }
+ }
+ pure fn ne(other: &token) -> bool { !self.eq(other) }
+}
// Local Variables:
// fill-column: 78;
*/
enum breaks { consistent, inconsistent, }
+#[cfg(stage0)]
impl breaks : cmp::Eq {
pure fn eq(&&other: breaks) -> bool {
match (self, other) {
}
pure fn ne(&&other: breaks) -> bool { !self.eq(other) }
}
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl breaks : cmp::Eq {
+ pure fn eq(other: &breaks) -> bool {
+ match (self, (*other)) {
+ (consistent, consistent) => true,
+ (inconsistent, inconsistent) => true,
+ (consistent, _) => false,
+ (inconsistent, _) => false,
+ }
+ }
+ pure fn ne(other: &breaks) -> bool { !self.eq(other) }
+}
type break_t = {offset: int, blank_space: int};
output_type_exe,
}
+#[cfg(stage0)]
impl output_type : cmp::Eq {
pure fn eq(&&other: output_type) -> bool {
(self as uint) == (other as uint)
}
pure fn ne(&&other: output_type) -> bool { !self.eq(other) }
}
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl output_type : cmp::Eq {
+ pure fn eq(other: &output_type) -> bool {
+ (self as uint) == ((*other) as uint)
+ }
+ pure fn ne(other: &output_type) -> bool { !self.eq(other) }
+}
fn llvm_err(sess: session, msg: ~str) -> ! unsafe {
let cstr = llvm::LLVMRustGetLastError();
cu_everything,
}
+#[cfg(stage0)]
impl compile_upto : cmp::Eq {
pure fn eq(&&other: compile_upto) -> bool {
(self as uint) == (other as uint)
}
pure fn ne(&&other: compile_upto) -> bool { !self.eq(other) }
}
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl compile_upto : cmp::Eq {
+ pure fn eq(other: &compile_upto) -> bool {
+ (self as uint) == ((*other) as uint)
+ }
+ pure fn ne(other: &compile_upto) -> bool { !self.eq(other) }
+}
fn compile_upto(sess: session, cfg: ast::crate_cfg,
input: input, upto: compile_upto,
done,
}
+#[cfg(stage0)]
impl monitor_msg : cmp::Eq {
pure fn eq(&&other: monitor_msg) -> bool {
(self as uint) == (other as uint)
}
pure fn ne(&&other: monitor_msg) -> bool { !self.eq(other) }
}
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl monitor_msg : cmp::Eq {
+ pure fn eq(other: &monitor_msg) -> bool {
+ (self as uint) == ((*other) as uint)
+ }
+ pure fn ne(other: &monitor_msg) -> bool { !self.eq(other) }
+}
/*
This is a sanity check that any failure of the compiler is performed
enum os { os_win32, os_macos, os_linux, os_freebsd, }
+#[cfg(stage0)]
impl os : cmp::Eq {
pure fn eq(&&other: os) -> bool {
(self as uint) == (other as uint)
}
pure fn ne(&&other: os) -> bool { !self.eq(other) }
}
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl os : cmp::Eq {
+ pure fn eq(other: &os) -> bool {
+ (self as uint) == ((*other) as uint)
+ }
+ pure fn ne(other: &os) -> bool { !self.eq(other) }
+}
enum arch { arch_x86, arch_x86_64, arch_arm, }
+#[cfg(stage0)]
impl arch: cmp::Eq {
pure fn eq(&&other: arch) -> bool {
(self as uint) == (other as uint)
}
pure fn ne(&&other: arch) -> bool { !self.eq(other) }
}
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl arch : cmp::Eq {
+ pure fn eq(other: &arch) -> bool {
+ (self as uint) == ((*other) as uint)
+ }
+ pure fn ne(other: &arch) -> bool { !self.eq(other) }
+}
enum crate_type { bin_crate, lib_crate, unknown_crate, }
Aggressive // -O3
}
+#[cfg(stage0)]
impl OptLevel : cmp::Eq {
pure fn eq(&&other: OptLevel) -> bool {
(self as uint) == (other as uint)
}
pure fn ne(&&other: OptLevel) -> bool { !self.eq(other) }
}
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl OptLevel : cmp::Eq {
+ pure fn eq(other: &OptLevel) -> bool {
+ (self as uint) == ((*other) as uint)
+ }
+ pure fn ne(other: &OptLevel) -> bool { !self.eq(other) }
+}
type options =
// The crate config requested for the session, which may be combined
X86_MMX = 15
}
+#[cfg(stage0)]
impl TypeKind : cmp::Eq {
pure fn eq(&&other: TypeKind) -> bool {
match (self, other) {
}
pure fn ne(&&other: TypeKind) -> bool { !self.eq(other) }
}
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl TypeKind : cmp::Eq {
+ pure fn eq(other: &TypeKind) -> bool {
+ match (self, (*other)) {
+ (Void, Void) => true,
+ (Half, Half) => true,
+ (Float, Float) => true,
+ (Double, Double) => true,
+ (X86_FP80, X86_FP80) => true,
+ (FP128, FP128) => true,
+ (PPC_FP128, PPC_FP128) => true,
+ (Label, Label) => true,
+ (Integer, Integer) => true,
+ (Function, Function) => true,
+ (Struct, Struct) => true,
+ (Array, Array) => true,
+ (Pointer, Pointer) => true,
+ (Vector, Vector) => true,
+ (Metadata, Metadata) => true,
+ (X86_MMX, X86_MMX) => true,
+ (Void, _) => false,
+ (Half, _) => false,
+ (Float, _) => false,
+ (Double, _) => false,
+ (X86_FP80, _) => false,
+ (FP128, _) => false,
+ (PPC_FP128, _) => false,
+ (Label, _) => false,
+ (Integer, _) => false,
+ (Function, _) => false,
+ (Struct, _) => false,
+ (Array, _) => false,
+ (Pointer, _) => false,
+ (Vector, _) => false,
+ (Metadata, _) => false,
+ (X86_MMX, _) => false,
+ }
+ }
+ pure fn ne(other: &TypeKind) -> bool { !self.eq(other) }
+}
enum AtomicBinOp {
Xchg = 0,
InheritedField // N
}
+#[cfg(stage0)]
impl Family : cmp::Eq {
pure fn eq(&&other: Family) -> bool {
(self as uint) == (other as uint)
}
pure fn ne(&&other: Family) -> bool { !self.eq(other) }
}
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl Family : cmp::Eq {
+ pure fn eq(other: &Family) -> bool {
+ (self as uint) == ((*other) as uint)
+ }
+ pure fn ne(other: &Family) -> bool { !self.eq(other) }
+}
fn item_family(item: ebml::Doc) -> Family {
let fam = ebml::get_doc(item, tag_items_data_item_family);
err_out_of_scope(ty::region, ty::region) // superscope, subscope
}
+#[cfg(stage0)]
impl bckerr_code : cmp::Eq {
pure fn eq(&&other: bckerr_code) -> bool {
match self {
}
pure fn ne(&&other: bckerr_code) -> bool { !self.eq(other) }
}
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl bckerr_code : cmp::Eq {
+ pure fn eq(other: &bckerr_code) -> bool {
+ match self {
+ err_mut_uniq => {
+ match (*other) {
+ err_mut_uniq => true,
+ _ => false
+ }
+ }
+ err_mut_variant => {
+ match (*other) {
+ err_mut_variant => true,
+ _ => false
+ }
+ }
+ err_root_not_permitted => {
+ match (*other) {
+ err_root_not_permitted => true,
+ _ => false
+ }
+ }
+ err_mutbl(e0a) => {
+ match (*other) {
+ err_mutbl(e0b) => e0a == e0b,
+ _ => false
+ }
+ }
+ err_out_of_root_scope(e0a, e1a) => {
+ match (*other) {
+ err_out_of_root_scope(e0b, e1b) =>
+ e0a == e0b && e1a == e1b,
+ _ => false
+ }
+ }
+ err_out_of_scope(e0a, e1a) => {
+ match (*other) {
+ err_out_of_scope(e0b, e1b) => e0a == e0b && e1a == e1b,
+ _ => false
+ }
+ }
+ }
+ }
+ pure fn ne(other: &bckerr_code) -> bool { !self.eq(other) }
+}
// Combination of an error code and the categorization of the expression
// that caused it
type bckerr = {cmt: cmt, code: bckerr_code};
+#[cfg(stage0)]
impl bckerr : cmp::Eq {
pure fn eq(&&other: bckerr) -> bool {
self.cmt == other.cmt && self.code == other.code
}
pure fn ne(&&other: bckerr) -> bool { !self.eq(other) }
}
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl bckerr : cmp::Eq {
+ pure fn eq(other: &bckerr) -> bool {
+ self.cmt == (*other).cmt && self.code == (*other).code
+ }
+ pure fn ne(other: &bckerr) -> bool { !self.eq(other) }
+}
// shorthand for something that fails with `bckerr` or succeeds with `T`
type bckres<T> = Result<T, bckerr>;
/// Creates and returns a new root_map
+#[cfg(stage0)]
impl root_map_key : cmp::Eq {
pure fn eq(&&other: root_map_key) -> bool {
self.id == other.id && self.derefs == other.derefs
! (self == other)
}
}
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl root_map_key : cmp::Eq {
+ pure fn eq(other: &root_map_key) -> bool {
+ self.id == (*other).id && self.derefs == (*other).derefs
+ }
+ pure fn ne(other: &root_map_key) -> bool {
+ ! (self == (*other))
+ }
+}
impl root_map_key : to_bytes::IterBytes {
pure fn iter_bytes(lsb0: bool, f: to_bytes::Cb) {
pc_cmt(bckerr)
}
+#[cfg(stage0)]
impl purity_cause : cmp::Eq {
pure fn eq(&&other: purity_cause) -> bool {
match self {
}
pure fn ne(&&other: purity_cause) -> bool { !self.eq(other) }
}
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl purity_cause : cmp::Eq {
+ pure fn eq(other: &purity_cause) -> bool {
+ match self {
+ pc_pure_fn => {
+ match (*other) {
+ pc_pure_fn => true,
+ _ => false
+ }
+ }
+ pc_cmt(e0a) => {
+ match (*other) {
+ pc_cmt(e0b) => e0a == e0b,
+ _ => false
+ }
+ }
+ }
+ }
+ pure fn ne(other: &purity_cause) -> bool { !self.eq(other) }
+}
fn check_loans(bccx: borrowck_ctxt,
req_maps: req_maps,
at_swap
}
+#[cfg(stage0)]
impl assignment_type : cmp::Eq {
pure fn eq(&&other: assignment_type) -> bool {
(self as uint) == (other as uint)
}
pure fn ne(&&other: assignment_type) -> bool { !self.eq(other) }
}
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl assignment_type : cmp::Eq {
+ pure fn eq(other: &assignment_type) -> bool {
+ (self as uint) == ((*other) as uint)
+ }
+ pure fn ne(other: &assignment_type) -> bool { !self.eq(other) }
+}
impl assignment_type {
fn checked_by_liveness() -> bool {
range(const_val, const_val),
}
+#[cfg(stage0)]
impl ctor: cmp::Eq {
pure fn eq(&&other: ctor) -> bool {
match (self, other) {
}
pure fn ne(&&other: ctor) -> bool { !self.eq(other) }
}
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl ctor : cmp::Eq {
+ pure fn eq(other: &ctor) -> bool {
+ match (self, (*other)) {
+ (single, single) => true,
+ (variant(did_self), variant(did_other)) => did_self == did_other,
+ (val(cv_self), val(cv_other)) => cv_self == cv_other,
+ (range(cv0_self, cv1_self), range(cv0_other, cv1_other)) => {
+ cv0_self == cv0_other && cv1_self == cv1_other
+ }
+ (single, _) | (variant(_), _) | (val(_), _) | (range(*), _) => {
+ false
+ }
+ }
+ }
+ pure fn ne(other: &ctor) -> bool { !self.eq(other) }
+}
// Algorithm from http://moscova.inria.fr/~maranget/papers/warn/index.html
//
const_bool(bool)
}
+#[cfg(stage0)]
impl const_val: cmp::Eq {
pure fn eq(&&other: const_val) -> bool {
match (self, other) {
}
pure fn ne(&&other: const_val) -> bool { !self.eq(other) }
}
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl const_val : cmp::Eq {
+ pure fn eq(other: &const_val) -> bool {
+ match (self, (*other)) {
+ (const_float(a), const_float(b)) => a == b,
+ (const_int(a), const_int(b)) => a == b,
+ (const_uint(a), const_uint(b)) => a == b,
+ (const_str(a), const_str(b)) => a == b,
+ (const_bool(a), const_bool(b)) => a == b,
+ (const_float(_), _) | (const_int(_), _) | (const_uint(_), _) |
+ (const_str(_), _) | (const_bool(_), _) => false
+ }
+ }
+ pure fn ne(other: &const_val) -> bool { !self.eq(other) }
+}
// FIXME: issue #1417
fn eval_const_expr(tcx: middle::ty::ctxt, e: @expr) -> const_val {
// dead_assignment
}
+#[cfg(stage0)]
impl lint : cmp::Eq {
pure fn eq(&&other: lint) -> bool {
(self as uint) == (other as uint)
}
pure fn ne(&&other: lint) -> bool { !self.eq(other) }
}
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl lint : cmp::Eq {
+ pure fn eq(other: &lint) -> bool {
+ (self as uint) == ((*other) as uint)
+ }
+ pure fn ne(other: &lint) -> bool { !self.eq(other) }
+}
fn level_to_str(lv: level) -> ~str {
match lv {
allow, warn, deny, forbid
}
+#[cfg(stage0)]
impl level : cmp::Eq {
pure fn eq(&&other: level) -> bool {
(self as uint) == (other as uint)
}
pure fn ne(&&other: level) -> bool { !self.eq(other) }
}
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl level : cmp::Eq {
+ pure fn eq(other: &level) -> bool {
+ (self as uint) == ((*other) as uint)
+ }
+ pure fn ne(other: &level) -> bool { !self.eq(other) }
+}
type lint_spec = @{lint: lint,
desc: ~str,
enum Variable = uint;
enum LiveNode = uint;
+#[cfg(stage0)]
impl Variable : cmp::Eq {
pure fn eq(&&other: Variable) -> bool { *self == *other }
pure fn ne(&&other: Variable) -> bool { *self != *other }
}
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl Variable : cmp::Eq {
+ pure fn eq(other: &Variable) -> bool { *self == *(*other) }
+ pure fn ne(other: &Variable) -> bool { *self != *(*other) }
+}
+#[cfg(stage0)]
impl LiveNode : cmp::Eq {
pure fn eq(&&other: LiveNode) -> bool { *self == *other }
pure fn ne(&&other: LiveNode) -> bool { *self != *other }
}
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl LiveNode : cmp::Eq {
+ pure fn eq(other: &LiveNode) -> bool { *self == *(*other) }
+ pure fn ne(other: &LiveNode) -> bool { *self != *(*other) }
+}
enum LiveNodeKind {
FreeVarNode(span),
ExitNode
}
+#[cfg(stage0)]
impl LiveNodeKind : cmp::Eq {
pure fn eq(&&other: LiveNodeKind) -> bool {
match self {
}
pure fn ne(&&other: LiveNodeKind) -> bool { !self.eq(other) }
}
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl LiveNodeKind : cmp::Eq {
+ pure fn eq(other: &LiveNodeKind) -> bool {
+ match self {
+ FreeVarNode(e0a) => {
+ match (*other) {
+ FreeVarNode(e0b) => e0a == e0b,
+ _ => false
+ }
+ }
+ ExprNode(e0a) => {
+ match (*other) {
+ ExprNode(e0b) => e0a == e0b,
+ _ => false
+ }
+ }
+ VarDefNode(e0a) => {
+ match (*other) {
+ VarDefNode(e0b) => e0a == e0b,
+ _ => false
+ }
+ }
+ ExitNode => {
+ match (*other) {
+ ExitNode => true,
+ _ => false
+ }
+ }
+ }
+ }
+ pure fn ne(other: &LiveNodeKind) -> bool { !self.eq(other) }
+}
fn check_crate(tcx: ty::ctxt,
method_map: typeck::method_map,
cat_discr(cmt, ast::node_id), // match discriminant (see preserve())
}
+#[cfg(stage0)]
impl categorization : cmp::Eq {
pure fn eq(&&other: categorization) -> bool {
match self {
}
pure fn ne(&&other: categorization) -> bool { !self.eq(other) }
}
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl categorization : cmp::Eq {
+ pure fn eq(other: &categorization) -> bool {
+ match self {
+ cat_rvalue => {
+ match (*other) {
+ cat_rvalue => true,
+ _ => false
+ }
+ }
+ cat_special(e0a) => {
+ match (*other) {
+ cat_special(e0b) => e0a == e0b,
+ _ => false
+ }
+ }
+ cat_local(e0a) => {
+ match (*other) {
+ cat_local(e0b) => e0a == e0b,
+ _ => false
+ }
+ }
+ cat_binding(e0a) => {
+ match (*other) {
+ cat_binding(e0b) => e0a == e0b,
+ _ => false
+ }
+ }
+ cat_arg(e0a) => {
+ match (*other) {
+ cat_arg(e0b) => e0a == e0b,
+ _ => false
+ }
+ }
+ cat_stack_upvar(e0a) => {
+ match (*other) {
+ cat_stack_upvar(e0b) => e0a == e0b,
+ _ => false
+ }
+ }
+ cat_deref(e0a, e1a, e2a) => {
+ match (*other) {
+ cat_deref(e0b, e1b, e2b) =>
+ e0a == e0b && e1a == e1b && e2a == e2b,
+ _ => false
+ }
+ }
+ cat_comp(e0a, e1a) => {
+ match (*other) {
+ cat_comp(e0b, e1b) => e0a == e0b && e1a == e1b,
+ _ => false
+ }
+ }
+ cat_discr(e0a, e1a) => {
+ match (*other) {
+ cat_discr(e0b, e1b) => e0a == e0b && e1a == e1b,
+ _ => false
+ }
+ }
+ }
+ }
+ pure fn ne(other: &categorization) -> bool { !self.eq(other) }
+}
// different kinds of pointers:
enum ptr_kind {
unsafe_ptr
}
+#[cfg(stage0)]
impl ptr_kind : cmp::Eq {
pure fn eq(&&other: ptr_kind) -> bool {
match self {
}
pure fn ne(&&other: ptr_kind) -> bool { !self.eq(other) }
}
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl ptr_kind : cmp::Eq {
+ pure fn eq(other: &ptr_kind) -> bool {
+ match self {
+ uniq_ptr => {
+ match (*other) {
+ uniq_ptr => true,
+ _ => false
+ }
+ }
+ gc_ptr => {
+ match (*other) {
+ gc_ptr => true,
+ _ => false
+ }
+ }
+ region_ptr(e0a) => {
+ match (*other) {
+ region_ptr(e0b) => e0a == e0b,
+ _ => false
+ }
+ }
+ unsafe_ptr => {
+ match (*other) {
+ unsafe_ptr => true,
+ _ => false
+ }
+ }
+ }
+ }
+ pure fn ne(other: &ptr_kind) -> bool { !self.eq(other) }
+}
// I am coining the term "components" to mean "pieces of a data
// structure accessible without a dereference":
ast::mutability) // mutability of vec content
}
+#[cfg(stage0)]
impl comp_kind : cmp::Eq {
pure fn eq(&&other: comp_kind) -> bool {
match self {
}
pure fn ne(&&other: comp_kind) -> bool { !self.eq(other) }
}
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl comp_kind : cmp::Eq {
+ pure fn eq(other: &comp_kind) -> bool {
+ match self {
+ comp_tuple => {
+ match (*other) {
+ comp_tuple => true,
+ _ => false
+ }
+ }
+ comp_variant(e0a) => {
+ match (*other) {
+ comp_variant(e0b) => e0a == e0b,
+ _ => false
+ }
+ }
+ comp_field(e0a, e1a) => {
+ match (*other) {
+ comp_field(e0b, e1b) => e0a == e0b && e1a == e1b,
+ _ => false
+ }
+ }
+ comp_index(e0a, e1a) => {
+ match (*other) {
+ comp_index(e0b, e1b) => e0a == e0b && e1a == e1b,
+ _ => false
+ }
+ }
+ }
+ }
+ pure fn ne(other: &comp_kind) -> bool { !self.eq(other) }
+}
// different kinds of expressions we might evaluate
enum special_kind {
sk_heap_upvar
}
+#[cfg(stage0)]
impl special_kind : cmp::Eq {
pure fn eq(&&other: special_kind) -> bool {
(self as uint) == (other as uint)
}
pure fn ne(&&other: special_kind) -> bool { !self.eq(other) }
}
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl special_kind : cmp::Eq {
+ pure fn eq(other: &special_kind) -> bool {
+ (self as uint) == ((*other) as uint)
+ }
+ pure fn ne(other: &special_kind) -> bool { !self.eq(other) }
+}
// a complete categorization of a value indicating where it originated
// and how it is located, as well as the mutability of the memory in
type cmt = @cmt_;
+#[cfg(stage0)]
impl cmt_ : cmp::Eq {
pure fn eq(&&other: cmt_) -> bool {
self.id == other.id &&
}
pure fn ne(&&other: cmt_) -> bool { !self.eq(other) }
}
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl cmt_ : cmp::Eq {
+ pure fn eq(other: &cmt_) -> bool {
+ self.id == (*other).id &&
+ self.span == (*other).span &&
+ self.cat == (*other).cat &&
+ self.lp == (*other).lp &&
+ self.mutbl == (*other).mutbl &&
+ self.ty == (*other).ty
+ }
+ pure fn ne(other: &cmt_) -> bool { !self.eq(other) }
+}
// a loan path is like a category, but it exists only when the data is
// interior to the stack frame. loan paths are used as the key to a
lp_comp(@loan_path, comp_kind)
}
+#[cfg(stage0)]
impl loan_path : cmp::Eq {
pure fn eq(&&other: loan_path) -> bool {
match self {
}
pure fn ne(&&other: loan_path) -> bool { !self.eq(other) }
}
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl loan_path : cmp::Eq {
+ pure fn eq(other: &loan_path) -> bool {
+ match self {
+ lp_local(e0a) => {
+ match (*other) {
+ lp_local(e0b) => e0a == e0b,
+ _ => false
+ }
+ }
+ lp_arg(e0a) => {
+ match (*other) {
+ lp_arg(e0b) => e0a == e0b,
+ _ => false
+ }
+ }
+ lp_deref(e0a, e1a) => {
+ match (*other) {
+ lp_deref(e0b, e1b) => e0a == e0b && e1a == e1b,
+ _ => false
+ }
+ }
+ lp_comp(e0a, e1a) => {
+ match (*other) {
+ lp_comp(e0b, e1b) => e0a == e0b && e1a == e1b,
+ _ => false
+ }
+ }
+ }
+ }
+ pure fn ne(other: &loan_path) -> bool { !self.eq(other) }
+}
// We pun on *T to mean both actual deref of a ptr as well
// as accessing of components:
type region_dep = {ambient_variance: region_variance, id: ast::node_id};
type dep_map = HashMap<ast::node_id, @DVec<region_dep>>;
+#[cfg(stage0)]
impl region_dep: cmp::Eq {
pure fn eq(&&other: region_dep) -> bool {
self.ambient_variance == other.ambient_variance && self.id == other.id
}
pure fn ne(&&other: region_dep) -> bool { !self.eq(other) }
}
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl region_dep : cmp::Eq {
+ pure fn eq(other: ®ion_dep) -> bool {
+ self.ambient_variance == (*other).ambient_variance &&
+ self.id == (*other).id
+ }
+ pure fn ne(other: ®ion_dep) -> bool { !self.eq(other) }
+}
type determine_rp_ctxt_ = {
sess: session,
IrrefutableMode
}
+#[cfg(stage0)]
impl PatternBindingMode : cmp::Eq {
pure fn eq(&&other: PatternBindingMode) -> bool {
(self as uint) == (other as uint)
}
pure fn ne(&&other: PatternBindingMode) -> bool { !self.eq(other) }
}
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl PatternBindingMode : cmp::Eq {
+ pure fn eq(other: &PatternBindingMode) -> bool {
+ (self as uint) == ((*other) as uint)
+ }
+ pure fn ne(other: &PatternBindingMode) -> bool { !self.eq(other) }
+}
enum Namespace {
Immutable
}
+#[cfg(stage0)]
impl Mutability : cmp::Eq {
pure fn eq(&&other: Mutability) -> bool {
(self as uint) == (other as uint)
}
pure fn ne(&&other: Mutability) -> bool { !self.eq(other) }
}
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl Mutability : cmp::Eq {
+ pure fn eq(other: &Mutability) -> bool {
+ (self as uint) == ((*other) as uint)
+ }
+ pure fn ne(other: &Mutability) -> bool { !self.eq(other) }
+}
enum SelfBinding {
NoSelfBinding,
AnyNS
}
+#[cfg(stage0)]
impl ImportDirectiveNS : cmp::Eq {
pure fn eq(&&other: ImportDirectiveNS) -> bool {
(self as uint) == (other as uint)
}
pure fn ne(&&other: ImportDirectiveNS) -> bool { !self.eq(other) }
}
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl ImportDirectiveNS : cmp::Eq {
+ pure fn eq(other: &ImportDirectiveNS) -> bool {
+ (self as uint) == ((*other) as uint)
+ }
+ pure fn ne(other: &ImportDirectiveNS) -> bool { !self.eq(other) }
+}
/// Contains data for specific types of import directives.
enum ImportDirectiveSubclass {
Xray //< Private items can be accessed.
}
+#[cfg(stage0)]
impl XrayFlag : cmp::Eq {
pure fn eq(&&other: XrayFlag) -> bool {
(self as uint) == (other as uint)
}
pure fn ne(&&other: XrayFlag) -> bool { !self.eq(other) }
}
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl XrayFlag : cmp::Eq {
+ pure fn eq(other: &XrayFlag) -> bool {
+ (self as uint) == ((*other) as uint)
+ }
+ pure fn ne(other: &XrayFlag) -> bool { !self.eq(other) }
+}
enum AllowCapturingSelfFlag {
AllowCapturingSelf, //< The "self" definition can be captured.
DontAllowCapturingSelf, //< The "self" definition cannot be captured.
}
+#[cfg(stage0)]
impl AllowCapturingSelfFlag : cmp::Eq {
pure fn eq(&&other: AllowCapturingSelfFlag) -> bool {
(self as uint) == (other as uint)
}
pure fn ne(&&other: AllowCapturingSelfFlag) -> bool { !self.eq(other) }
}
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl AllowCapturingSelfFlag : cmp::Eq {
+ pure fn eq(other: &AllowCapturingSelfFlag) -> bool {
+ (self as uint) == ((*other) as uint)
+ }
+ pure fn ne(other: &AllowCapturingSelfFlag) -> bool { !self.eq(other) }
+}
enum EnumVariantOrConstResolution {
FoundEnumVariant(def),
Public
}
+#[cfg(stage0)]
impl Privacy : cmp::Eq {
pure fn eq(&&other: Privacy) -> bool {
(self as uint) == (other as uint)
}
pure fn ne(&&other: Privacy) -> bool { !self.eq(other) }
}
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl Privacy : cmp::Eq {
+ pure fn eq(other: &Privacy) -> bool {
+ (self as uint) == ((*other) as uint)
+ }
+ pure fn ne(other: &Privacy) -> bool { !self.eq(other) }
+}
// Records a possibly-private definition.
struct Definition {
enum branch_kind { no_branch, single, switch, compare, }
+#[cfg(stage0)]
impl branch_kind : cmp::Eq {
pure fn eq(&&other: branch_kind) -> bool {
(self as uint) == (other as uint)
}
pure fn ne(&&other: branch_kind) -> bool { !self.eq(other) }
}
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl branch_kind : cmp::Eq {
+ pure fn eq(other: &branch_kind) -> bool {
+ (self as uint) == ((*other) as uint)
+ }
+ pure fn ne(other: &branch_kind) -> bool { !self.eq(other) }
+}
// Compiles a comparison between two things.
fn compare_values(cx: block, lhs: ValueRef, rhs: ValueRef, rhs_t: ty::t) ->
let _icx = in_cx.insn_ctxt("trans_call");
trans_call_inner(
in_cx, call_ex.info(), expr_ty(in_cx, f), node_id_type(in_cx, id),
- |cx| trans(cx, f), args, dest)
+ |cx| trans(cx, f), args, dest, DontAutorefArg)
}
fn trans_rtcall(bcx: block, name: ~str, args: ~[ValueRef], dest: expr::Dest)
return callee::trans_call_inner(
bcx, None, fty, rty,
|bcx| trans_fn_ref_with_vtables_to_callee(bcx, did, 0, ~[], None),
- ArgVals(args), dest);
+ ArgVals(args), dest, DontAutorefArg);
}
fn body_contains_ret(body: ast::blk) -> bool {
ret_ty: ty::t,
get_callee: fn(block) -> Callee,
args: CallArgs,
- dest: expr::Dest) -> block
+ dest: expr::Dest,
+ autoref_arg: AutorefArg) -> block
{
do base::with_scope(in_cx, call_info, ~"call") |cx| {
let ret_in_loop = match args {
};
let args_res = trans_args(bcx, llenv, args, fn_expr_ty,
- dest, ret_flag);
+ dest, ret_flag, autoref_arg);
bcx = args_res.bcx;
let mut llargs = args_res.args;
}
fn trans_args(cx: block, llenv: ValueRef, args: CallArgs, fn_ty: ty::t,
- dest: expr::Dest, ret_flag: Option<ValueRef>)
+ dest: expr::Dest, ret_flag: Option<ValueRef>,
+ +autoref_arg: AutorefArg)
-> {bcx: block, args: ~[ValueRef], retslot: ValueRef}
{
let _icx = cx.insn_ctxt("trans_args");
for vec::eachi(arg_exprs) |i, arg_expr| {
let arg_val = unpack_result!(bcx, {
trans_arg_expr(bcx, arg_tys[i], arg_expr, &mut temp_cleanups,
- if i == last { ret_flag } else { None })
+ if i == last { ret_flag } else { None },
+ autoref_arg)
});
vec::push(llargs, arg_val);
}
return {bcx: bcx, args: llargs, retslot: llretslot};
}
+enum AutorefArg {
+ DontAutorefArg,
+ DoAutorefArg
+}
+
// temp_cleanups: cleanups that should run only if failure occurs before the
// call takes place:
fn trans_arg_expr(bcx: block,
formal_ty: ty::arg,
arg_expr: @ast::expr,
temp_cleanups: &mut ~[ValueRef],
- ret_flag: Option<ValueRef>)
+ ret_flag: Option<ValueRef>,
+ +autoref_arg: AutorefArg)
-> Result
{
let _icx = bcx.insn_ctxt("trans_arg_expr");
let llformal_ty = type_of::type_of(ccx, formal_ty.ty);
val = llvm::LLVMGetUndef(llformal_ty);
} else {
- match arg_mode {
- ast::by_ref | ast::by_mutbl_ref => {
- val = arg_datum.to_ref_llval(bcx);
- }
-
- ast::by_val => {
- // NB: avoid running the take glue.
- val = arg_datum.to_value_llval(bcx);
- }
-
- ast::by_copy | ast::by_move => {
- let scratch = scratch_datum(bcx, arg_datum.ty, false);
-
- if arg_mode == ast::by_move {
- // NDM---Doesn't seem like this should be necessary
- if !arg_datum.store_will_move() {
- bcx.sess().span_bug(
- arg_expr.span,
- fmt!("move mode but datum will not store: %s",
- arg_datum.to_str(bcx.ccx())));
+ match autoref_arg {
+ DoAutorefArg => { val = arg_datum.to_ref_llval(bcx); }
+ DontAutorefArg => {
+ match arg_mode {
+ ast::by_ref | ast::by_mutbl_ref => {
+ val = arg_datum.to_ref_llval(bcx);
}
- }
- arg_datum.store_to_datum(bcx, INIT, scratch);
+ ast::by_val => {
+ // NB: avoid running the take glue.
+ val = arg_datum.to_value_llval(bcx);
+ }
- // Technically, ownership of val passes to the callee.
- // However, we must cleanup should we fail before the
- // callee is actually invoked.
- scratch.add_clean(bcx);
- vec::push(*temp_cleanups, scratch.val);
- val = scratch.val;
- }
+ ast::by_copy | ast::by_move => {
+ let scratch = scratch_datum(bcx, arg_datum.ty, false);
+
+ if arg_mode == ast::by_move {
+ // NDM---Doesn't seem like this should be
+ // necessary
+ if !arg_datum.store_will_move() {
+ bcx.sess().span_bug(
+ arg_expr.span,
+ fmt!("move mode but datum will not \
+ store: %s",
+ arg_datum.to_str(bcx.ccx())));
+ }
+ }
+
+ arg_datum.store_to_datum(bcx, INIT, scratch);
+
+ // Technically, ownership of val passes to the callee.
+ // However, we must cleanup should we fail before the
+ // callee is actually invoked.
+ scratch.add_clean(bcx);
+ vec::push(*temp_cleanups, scratch.val);
+ val = scratch.val;
+ }
+ }
+ }
}
if formal_ty.ty != arg_datum.ty {
clean_temp(ValueRef, fn@(block) -> block, cleantype),
}
+#[cfg(stage0)]
impl cleantype : cmp::Eq {
pure fn eq(&&other: cleantype) -> bool {
match self {
}
pure fn ne(&&other: cleantype) -> bool { !self.eq(other) }
}
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl cleantype : cmp::Eq {
+ pure fn eq(other: &cleantype) -> bool {
+ match self {
+ normal_exit_only => {
+ match (*other) {
+ normal_exit_only => true,
+ _ => false
+ }
+ }
+ normal_exit_and_unwind => {
+ match (*other) {
+ normal_exit_and_unwind => true,
+ _ => false
+ }
+ }
+ }
+ }
+ pure fn ne(other: &cleantype) -> bool { !self.eq(other) }
+}
// Used to remember and reuse existing cleanup paths
// target: none means the path ends in an resume instruction
type mono_id = @mono_id_;
+#[cfg(stage0)]
impl mono_param_id: cmp::Eq {
pure fn eq(&&other: mono_param_id) -> bool {
match (self, other) {
}
pure fn ne(&&other: mono_param_id) -> bool { !self.eq(other) }
}
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl mono_param_id : cmp::Eq {
+ pure fn eq(other: &mono_param_id) -> bool {
+ match (self, (*other)) {
+ (mono_precise(ty_a, ids_a), mono_precise(ty_b, ids_b)) => {
+ ty_a == ty_b && ids_a == ids_b
+ }
+ (mono_any, mono_any) => true,
+ (mono_repr(size_a, align_a), mono_repr(size_b, align_b)) => {
+ size_a == size_b && align_a == align_b
+ }
+ (mono_precise(*), _) => false,
+ (mono_any, _) => false,
+ (mono_repr(*), _) => false
+ }
+ }
+ pure fn ne(other: &mono_param_id) -> bool { !self.eq(other) }
+}
+#[cfg(stage0)]
impl mono_id_: cmp::Eq {
pure fn eq(&&other: mono_id_) -> bool {
return self.def == other.def && self.params == other.params;
}
pure fn ne(&&other: mono_id_) -> bool { !self.eq(other) }
}
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl mono_id_ : cmp::Eq {
+ pure fn eq(other: &mono_id_) -> bool {
+ return self.def == (*other).def && self.params == (*other).params;
+ }
+ pure fn ne(other: &mono_id_) -> bool { !self.eq(other) }
+}
impl mono_param_id : to_bytes::IterBytes {
pure fn iter_bytes(lsb0: bool, f: to_bytes::Cb) {
}
}
+#[cfg(stage0)]
impl CopyAction : cmp::Eq {
pure fn eq(&&other: CopyAction) -> bool {
match (self, other) {
}
pure fn ne(&&other: CopyAction) -> bool { !self.eq(other) }
}
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl CopyAction : cmp::Eq {
+ pure fn eq(other: &CopyAction) -> bool {
+ match (self, (*other)) {
+ (INIT, INIT) => true,
+ (DROP_EXISTING, DROP_EXISTING) => true,
+ (INIT, _) => false,
+ (DROP_EXISTING, _) => false,
+ }
+ }
+ pure fn ne(other: &CopyAction) -> bool { !self.eq(other) }
+}
use util::ppaux::ty_to_str;
use util::common::indenter;
use ty::{AutoPtr, AutoSlice};
+use callee::{AutorefArg, DoAutorefArg, DontAutorefArg};
// The primary two functions for translating expressions:
export trans_to_datum, trans_into;
}
}
+#[cfg(stage0)]
impl Dest : cmp::Eq {
pure fn eq(&&other: Dest) -> bool {
match (self, other) {
}
pure fn ne(&&other: Dest) -> bool { !self.eq(other) }
}
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl Dest : cmp::Eq {
+ pure fn eq(other: &Dest) -> bool {
+ match (self, (*other)) {
+ (SaveIn(e0a), SaveIn(e0b)) => e0a == e0b,
+ (Ignore, Ignore) => true,
+ (SaveIn(*), _) => false,
+ (Ignore, _) => false,
+ }
+ }
+ pure fn ne(other: &Dest) -> bool { !self.eq(other) }
+}
fn trans_to_datum(bcx: block, expr: @ast::expr) -> DatumBlock {
debug!("trans_to_datum(expr=%s)", bcx.expr_to_str(expr));
}
ast::expr_binary(_, lhs, rhs) => {
// if not overloaded, would be RvalueDatumExpr
- return trans_overloaded_op(bcx, expr, lhs, ~[rhs], dest);
+ return trans_overloaded_op(bcx, expr, lhs, ~[rhs], dest,
+ DoAutorefArg);
}
ast::expr_unary(_, subexpr) => {
// if not overloaded, would be RvalueDatumExpr
- return trans_overloaded_op(bcx, expr, subexpr, ~[], dest);
+ return trans_overloaded_op(bcx, expr, subexpr, ~[], dest,
+ DontAutorefArg);
}
ast::expr_index(base, idx) => {
// if not overloaded, would be RvalueDatumExpr
- return trans_overloaded_op(bcx, expr, base, ~[idx], dest);
+ return trans_overloaded_op(bcx, expr, base, ~[idx], dest,
+ DontAutorefArg);
}
ast::expr_cast(val, _) => {
return meth::trans_trait_cast(bcx, val, expr.id, dest);
expr: @ast::expr,
rcvr: @ast::expr,
+args: ~[@ast::expr],
- dest: Dest) -> block
+ dest: Dest,
+ +autoref_arg: AutorefArg) -> block
{
let origin = bcx.ccx().maps.method_map.get(expr.id);
let fty = node_id_type(bcx, expr.callee_id);
bcx, expr.info(), fty,
expr_ty(bcx, expr),
|bcx| meth::trans_method_callee(bcx, expr.callee_id, rcvr, origin),
- callee::ArgExprs(args), dest);
+ callee::ArgExprs(args), dest, autoref_arg);
}
fn int_cast(bcx: block, lldsttype: TypeRef, llsrctype: TypeRef,
cast_other,
}
+#[cfg(stage0)]
impl cast_kind : cmp::Eq {
pure fn eq(&&other: cast_kind) -> bool {
match (self, other) {
}
pure fn ne(&&other: cast_kind) -> bool { !self.eq(other) }
}
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl cast_kind : cmp::Eq {
+ pure fn eq(other: &cast_kind) -> bool {
+ match (self, (*other)) {
+ (cast_pointer, cast_pointer) => true,
+ (cast_integral, cast_integral) => true,
+ (cast_float, cast_float) => true,
+ (cast_enum, cast_enum) => true,
+ (cast_other, cast_other) => true,
+ (cast_pointer, _) => false,
+ (cast_integral, _) => false,
+ (cast_float, _) => false,
+ (cast_enum, _) => false,
+ (cast_other, _) => false,
+ }
+ }
+ pure fn ne(other: &cast_kind) -> bool { !self.eq(other) }
+}
fn cast_type_kind(t: ty::t) -> cast_kind {
match ty::get(t).sty {
// FIXME(#2582) evaluates the receiver twice!!
let scratch = scratch_datum(bcx, dst_datum.ty, false);
let bcx = trans_overloaded_op(bcx, expr, dst, ~[src],
- SaveIn(scratch.val));
+ SaveIn(scratch.val), DoAutorefArg);
return scratch.move_to_datum(bcx, DROP_EXISTING, dst_datum);
}
memory_class
}
+#[cfg(stage0)]
impl x86_64_reg_class: cmp::Eq {
pure fn eq(&&other: x86_64_reg_class) -> bool {
(self as uint) == (other as uint)
}
pure fn ne(&&other: x86_64_reg_class) -> bool { !self.eq(other) }
}
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl x86_64_reg_class : cmp::Eq {
+ pure fn eq(other: &x86_64_reg_class) -> bool {
+ (self as uint) == ((*other) as uint)
+ }
+ pure fn ne(other: &x86_64_reg_class) -> bool { !self.eq(other) }
+}
fn is_sse(++c: x86_64_reg_class) -> bool {
return match c {
bcx = trans_call_inner(
bcx, None, fty, ty::mk_nil(bcx.tcx()),
|bcx| Callee {bcx: bcx, data: Closure(datum)},
- ArgVals(~[frameaddress_val]), Ignore);
+ ArgVals(~[frameaddress_val]), Ignore, DontAutorefArg);
}
~"morestack_addr" => {
// XXX This is a hack to grab the address of this particular
let self_arg = {mode: mentry.self_arg.mode,
ty: monomorphize_type(bcx, mentry.self_arg.ty)};
let result = trans_arg_expr(bcx, self_arg, base,
- &mut temp_cleanups, None);
+ &mut temp_cleanups, None, DontAutorefArg);
// FIXME(#3446)---this is wrong, actually. The temp_cleanups
// should be revoked only after all arguments have been passed.
use ast::def_id;
use util::ppaux::ty_to_str;
use datum::*;
-use callee::ArgVals;
+use callee::{ArgVals, DontAutorefArg};
use expr::SaveIn;
enum reflector = {
self.bcx, None, mth_ty, bool_ty,
|bcx| meth::trans_trait_callee_from_llval(bcx, mth_ty,
mth_idx, v),
- ArgVals(args), SaveIn(scratch.val));
+ ArgVals(args), SaveIn(scratch.val), DontAutorefArg);
let result = scratch.to_value_llval(bcx);
let next_bcx = sub_block(bcx, ~"next");
CondBr(bcx, result, next_bcx.llbb, self.final_bcx.llbb);
tps: ~[ty::t]};
type nominal_id = @nominal_id_;
+#[cfg(stage0)]
impl nominal_id_ : core::cmp::Eq {
pure fn eq(&&other: nominal_id_) -> bool {
if self.did != other.did ||
! (self == other)
}
}
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl nominal_id_ : core::cmp::Eq {
+ pure fn eq(other: &nominal_id_) -> bool {
+ if self.did != other.did ||
+ self.parent_id != other.parent_id {
+ false
+ } else {
+ do vec::all2(self.tps, other.tps) |m_tp, n_tp| {
+ ty::type_id(m_tp) == ty::type_id(n_tp)
+ }
+ }
+ }
+ pure fn ne(other: &nominal_id_) -> bool {
+ ! (self == *other)
+ }
+}
impl nominal_id_ : to_bytes::IterBytes {
pure fn iter_bytes(lsb0: bool, f: to_bytes::Cb) {
type creader_cache_key = {cnum: int, pos: uint, len: uint};
type creader_cache = HashMap<creader_cache_key, t>;
+#[cfg(stage0)]
impl creader_cache_key : cmp::Eq {
pure fn eq(&&other: creader_cache_key) -> bool {
self.cnum == other.cnum &&
!(self == other)
}
}
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl creader_cache_key : cmp::Eq {
+ pure fn eq(other: &creader_cache_key) -> bool {
+ self.cnum == (*other).cnum &&
+ self.pos == (*other).pos &&
+ self.len == (*other).len
+ }
+ pure fn ne(other: &creader_cache_key) -> bool {
+ !(self == (*other))
+ }
+}
impl creader_cache_key : to_bytes::IterBytes {
pure fn iter_bytes(lsb0: bool, f: to_bytes::Cb) {
type intern_key = {sty: sty, o_def_id: Option<ast::def_id>};
+#[cfg(stage0)]
impl intern_key: cmp::Eq {
pure fn eq(&&other: intern_key) -> bool {
self.sty == other.sty && self.o_def_id == other.o_def_id
}
pure fn ne(&&other: intern_key) -> bool { !self.eq(other) }
}
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl intern_key : cmp::Eq {
+ pure fn eq(other: &intern_key) -> bool {
+ self.sty == (*other).sty && self.o_def_id == (*other).o_def_id
+ }
+ pure fn ne(other: &intern_key) -> bool { !self.eq(other) }
+}
impl intern_key : to_bytes::IterBytes {
pure fn iter_bytes(lsb0: bool, f: to_bytes::Cb) {
#[auto_serialize]
enum region_variance { rv_covariant, rv_invariant, rv_contravariant }
+#[cfg(stage0)]
impl region_variance: cmp::Eq {
pure fn eq(&&other: region_variance) -> bool {
match (self, other) {
}
pure fn ne(&&other: region_variance) -> bool { !self.eq(other) }
}
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl region_variance : cmp::Eq {
+ pure fn eq(other: ®ion_variance) -> bool {
+ match (self, (*other)) {
+ (rv_covariant, rv_covariant) => true,
+ (rv_invariant, rv_invariant) => true,
+ (rv_contravariant, rv_contravariant) => true,
+ (rv_covariant, _) => false,
+ (rv_invariant, _) => false,
+ (rv_contravariant, _) => false
+ }
+ }
+ pure fn ne(other: ®ion_variance) -> bool { !self.eq(other) }
+}
#[auto_serialize]
type AutoAdjustment = {
}
}
+#[cfg(stage0)]
impl closure_kind : cmp::Eq {
pure fn eq(&&other: closure_kind) -> bool {
(self as uint) == (other as uint)
}
pure fn ne(&&other: closure_kind) -> bool { !self.eq(other) }
}
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl closure_kind : cmp::Eq {
+ pure fn eq(other: &closure_kind) -> bool {
+ (self as uint) == ((*other) as uint)
+ }
+ pure fn ne(other: &closure_kind) -> bool { !self.eq(other) }
+}
enum fn_proto {
proto_bare, // supertype of all other protocols
}
}
+#[cfg(stage0)]
impl fn_proto : cmp::Eq {
pure fn eq(&&other: fn_proto) -> bool {
match self {
}
pure fn ne(&&other: fn_proto) -> bool { !self.eq(other) }
}
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl fn_proto : cmp::Eq {
+ pure fn eq(other: &fn_proto) -> bool {
+ match self {
+ proto_bare => {
+ match (*other) {
+ proto_bare => true,
+ _ => false
+ }
+ }
+ proto_vstore(e0a) => {
+ match (*other) {
+ proto_vstore(e0b) => e0a == e0b,
+ _ => false
+ }
+ }
+ }
+ }
+ pure fn ne(other: &fn_proto) -> bool { !self.eq(other) }
+}
/**
* Meta information about a closure.
type param_ty = {idx: uint, def_id: def_id};
+#[cfg(stage0)]
impl param_ty: cmp::Eq {
pure fn eq(&&other: param_ty) -> bool {
self.idx == other.idx && self.def_id == other.def_id
}
pure fn ne(&&other: param_ty) -> bool { !self.eq(other) }
}
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl param_ty : cmp::Eq {
+ pure fn eq(other: ¶m_ty) -> bool {
+ self.idx == (*other).idx && self.def_id == (*other).def_id
+ }
+ pure fn ne(other: ¶m_ty) -> bool { !self.eq(other) }
+}
impl param_ty : to_bytes::IterBytes {
pure fn iter_bytes(lsb0: bool, f: to_bytes::Cb) {
k - kind_(KIND_MASK_COPY | KIND_MASK_DEFAULT_MODE)
}
+#[cfg(stage0)]
impl kind: ops::BitAnd<kind,kind> {
pure fn bitand(other: kind) -> kind {
unsafe {
}
}
}
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl kind : ops::BitAnd<kind,kind> {
+ pure fn bitand(other: &kind) -> kind {
+ unsafe {
+ lower_kind(self, (*other))
+ }
+ }
+}
+#[cfg(stage0)]
impl kind: ops::BitOr<kind,kind> {
pure fn bitor(other: kind) -> kind {
unsafe {
}
}
}
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl kind : ops::BitOr<kind,kind> {
+ pure fn bitor(other: &kind) -> kind {
+ unsafe {
+ raise_kind(self, (*other))
+ }
+ }
+}
+#[cfg(stage0)]
impl kind: ops::Sub<kind,kind> {
pure fn sub(other: kind) -> kind {
unsafe {
}
}
}
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl kind : ops::Sub<kind,kind> {
+ pure fn sub(other: &kind) -> kind {
+ unsafe {
+ kind_(*self & !*(*other))
+ }
+ }
+}
// Using these query functions is preferable to direct comparison or matching
// against the kind constants, as we may modify the kind hierarchy in the
} else { child_purity }
}
+#[cfg(stage0)]
impl mt : cmp::Eq {
pure fn eq(&&other: mt) -> bool {
self.ty == other.ty && self.mutbl == other.mutbl
}
pure fn ne(&&other: mt) -> bool { !self.eq(other) }
}
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl mt : cmp::Eq {
+ pure fn eq(other: &mt) -> bool {
+ self.ty == (*other).ty && self.mutbl == (*other).mutbl
+ }
+ pure fn ne(other: &mt) -> bool { !self.eq(other) }
+}
+#[cfg(stage0)]
impl arg : cmp::Eq {
pure fn eq(&&other: arg) -> bool {
self.mode == other.mode && self.ty == other.ty
}
pure fn ne(&&other: arg) -> bool { !self.eq(other) }
}
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl arg : cmp::Eq {
+ pure fn eq(other: &arg) -> bool {
+ self.mode == (*other).mode && self.ty == (*other).ty
+ }
+ pure fn ne(other: &arg) -> bool { !self.eq(other) }
+}
+#[cfg(stage0)]
impl field : cmp::Eq {
pure fn eq(&&other: field) -> bool {
self.ident == other.ident && self.mt == other.mt
}
pure fn ne(&&other: field) -> bool { !self.eq(other) }
}
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl field : cmp::Eq {
+ pure fn eq(other: &field) -> bool {
+ self.ident == (*other).ident && self.mt == (*other).mt
+ }
+ pure fn ne(other: &field) -> bool { !self.eq(other) }
+}
+#[cfg(stage0)]
impl vstore : cmp::Eq {
pure fn eq(&&other: vstore) -> bool {
match self {
}
pure fn ne(&&other: vstore) -> bool { !self.eq(other) }
}
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl vstore : cmp::Eq {
+ pure fn eq(other: &vstore) -> bool {
+ match self {
+ vstore_fixed(e0a) => {
+ match (*other) {
+ vstore_fixed(e0b) => e0a == e0b,
+ _ => false
+ }
+ }
+ vstore_uniq => {
+ match (*other) {
+ vstore_uniq => true,
+ _ => false
+ }
+ }
+ vstore_box => {
+ match (*other) {
+ vstore_box => true,
+ _ => false
+ }
+ }
+ vstore_slice(e0a) => {
+ match (*other) {
+ vstore_slice(e0b) => e0a == e0b,
+ _ => false
+ }
+ }
+ }
+ }
+ pure fn ne(other: &vstore) -> bool { !self.eq(other) }
+}
+#[cfg(stage0)]
impl FnMeta : cmp::Eq {
pure fn eq(&&other: FnMeta) -> bool {
self.purity == other.purity &&
}
pure fn ne(&&other: FnMeta) -> bool { !self.eq(other) }
}
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl FnMeta : cmp::Eq {
+ pure fn eq(other: &FnMeta) -> bool {
+ self.purity == (*other).purity &&
+ self.proto == (*other).proto &&
+ self.bounds == (*other).bounds &&
+ self.ret_style == (*other).ret_style
+ }
+ pure fn ne(other: &FnMeta) -> bool { !self.eq(other) }
+}
+#[cfg(stage0)]
impl FnSig : cmp::Eq {
pure fn eq(&&other: FnSig) -> bool {
self.inputs == other.inputs &&
}
pure fn ne(&&other: FnSig) -> bool { !self.eq(other) }
}
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl FnSig : cmp::Eq {
+ pure fn eq(other: &FnSig) -> bool {
+ self.inputs == (*other).inputs &&
+ self.output == (*other).output
+ }
+ pure fn ne(other: &FnSig) -> bool { !self.eq(other) }
+}
+#[cfg(stage0)]
impl<M: cmp::Eq> FnTyBase<M> : cmp::Eq {
pure fn eq(&&other: FnTyBase<M>) -> bool {
self.meta == other.meta && self.sig == other.sig
}
pure fn ne(&&other: FnTyBase<M>) -> bool { !self.eq(other) }
}
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl<M: cmp::Eq> FnTyBase<M> : cmp::Eq {
+ pure fn eq(other: &FnTyBase<M>) -> bool {
+ self.meta == (*other).meta && self.sig == (*other).sig
+ }
+ pure fn ne(other: &FnTyBase<M>) -> bool { !self.eq(other) }
+}
+#[cfg(stage0)]
impl TyVid: cmp::Eq {
pure fn eq(&&other: TyVid) -> bool { *self == *other }
pure fn ne(&&other: TyVid) -> bool { *self != *other }
}
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl TyVid : cmp::Eq {
+ pure fn eq(other: &TyVid) -> bool { *self == *(*other) }
+ pure fn ne(other: &TyVid) -> bool { *self != *(*other) }
+}
+#[cfg(stage0)]
impl IntVid: cmp::Eq {
pure fn eq(&&other: IntVid) -> bool { *self == *other }
pure fn ne(&&other: IntVid) -> bool { *self != *other }
}
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl IntVid : cmp::Eq {
+ pure fn eq(other: &IntVid) -> bool { *self == *(*other) }
+ pure fn ne(other: &IntVid) -> bool { *self != *(*other) }
+}
+#[cfg(stage0)]
impl FnVid: cmp::Eq {
pure fn eq(&&other: FnVid) -> bool { *self == *other }
pure fn ne(&&other: FnVid) -> bool { *self != *other }
}
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl FnVid : cmp::Eq {
+ pure fn eq(other: &FnVid) -> bool { *self == *(*other) }
+ pure fn ne(other: &FnVid) -> bool { *self != *(*other) }
+}
+#[cfg(stage0)]
impl RegionVid: cmp::Eq {
pure fn eq(&&other: RegionVid) -> bool { *self == *other }
pure fn ne(&&other: RegionVid) -> bool { *self != *other }
}
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl RegionVid : cmp::Eq {
+ pure fn eq(other: &RegionVid) -> bool { *self == *(*other) }
+ pure fn ne(other: &RegionVid) -> bool { *self != *(*other) }
+}
+#[cfg(stage0)]
impl region : cmp::Eq {
pure fn eq(&&other: region) -> bool {
match self {
}
pure fn ne(&&other: region) -> bool { !self.eq(other) }
}
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl region : cmp::Eq {
+ pure fn eq(other: ®ion) -> bool {
+ match self {
+ re_bound(e0a) => {
+ match (*other) {
+ re_bound(e0b) => e0a == e0b,
+ _ => false
+ }
+ }
+ re_free(e0a, e1a) => {
+ match (*other) {
+ re_free(e0b, e1b) => e0a == e0b && e1a == e1b,
+ _ => false
+ }
+ }
+ re_scope(e0a) => {
+ match (*other) {
+ re_scope(e0b) => e0a == e0b,
+ _ => false
+ }
+ }
+ re_static => {
+ match (*other) {
+ re_static => true,
+ _ => false
+ }
+ }
+ re_var(e0a) => {
+ match (*other) {
+ re_var(e0b) => e0a == e0b,
+ _ => false
+ }
+ }
+ }
+ }
+ pure fn ne(other: ®ion) -> bool { !self.eq(other) }
+}
+#[cfg(stage0)]
impl bound_region : cmp::Eq {
pure fn eq(&&other: bound_region) -> bool {
match self {
}
pure fn ne(&&other: bound_region) -> bool { !self.eq(other) }
}
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl bound_region : cmp::Eq {
+ pure fn eq(other: &bound_region) -> bool {
+ match self {
+ br_self => {
+ match (*other) {
+ br_self => true,
+ _ => false
+ }
+ }
+ br_anon(e0a) => {
+ match (*other) {
+ br_anon(e0b) => e0a == e0b,
+ _ => false
+ }
+ }
+ br_named(e0a) => {
+ match (*other) {
+ br_named(e0b) => e0a == e0b,
+ _ => false
+ }
+ }
+ br_cap_avoid(e0a, e1a) => {
+ match (*other) {
+ br_cap_avoid(e0b, e1b) => e0a == e0b && e1a == e1b,
+ _ => false
+ }
+ }
+ }
+ }
+ pure fn ne(other: &bound_region) -> bool { !self.eq(other) }
+}
+#[cfg(stage0)]
impl substs : cmp::Eq {
pure fn eq(&&other: substs) -> bool {
self.self_r == other.self_r &&
}
pure fn ne(&&other: substs) -> bool { !self.eq(other) }
}
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl substs : cmp::Eq {
+ pure fn eq(other: &substs) -> bool {
+ self.self_r == (*other).self_r &&
+ self.self_ty == (*other).self_ty &&
+ self.tps == (*other).tps
+ }
+ pure fn ne(other: &substs) -> bool { !self.eq(other) }
+}
+#[cfg(stage0)]
impl InferTy : cmp::Eq {
pure fn eq(&&other: InferTy) -> bool {
self.to_hash() == other.to_hash()
}
pure fn ne(&&other: InferTy) -> bool { !self.eq(other) }
}
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl InferTy : cmp::Eq {
+ pure fn eq(other: &InferTy) -> bool {
+ self.to_hash() == (*other).to_hash()
+ }
+ pure fn ne(other: &InferTy) -> bool { !self.eq(other) }
+}
+#[cfg(stage0)]
impl sty : cmp::Eq {
pure fn eq(&&other: sty) -> bool {
match self {
}
pure fn ne(&&other: sty) -> bool { !self.eq(other) }
}
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl sty : cmp::Eq {
+ pure fn eq(other: &sty) -> bool {
+ match self {
+ ty_nil => {
+ match (*other) {
+ ty_nil => true,
+ _ => false
+ }
+ }
+ ty_bot => {
+ match (*other) {
+ ty_bot => true,
+ _ => false
+ }
+ }
+ ty_bool => {
+ match (*other) {
+ ty_bool => true,
+ _ => false
+ }
+ }
+ ty_int(e0a) => {
+ match (*other) {
+ ty_int(e0b) => e0a == e0b,
+ _ => false
+ }
+ }
+ ty_uint(e0a) => {
+ match (*other) {
+ ty_uint(e0b) => e0a == e0b,
+ _ => false
+ }
+ }
+ ty_float(e0a) => {
+ match (*other) {
+ ty_float(e0b) => e0a == e0b,
+ _ => false
+ }
+ }
+ ty_estr(e0a) => {
+ match (*other) {
+ ty_estr(e0b) => e0a == e0b,
+ _ => false
+ }
+ }
+ ty_enum(e0a, e1a) => {
+ match (*other) {
+ ty_enum(e0b, e1b) => e0a == e0b && e1a == e1b,
+ _ => false
+ }
+ }
+ ty_box(e0a) => {
+ match (*other) {
+ ty_box(e0b) => e0a == e0b,
+ _ => false
+ }
+ }
+ ty_uniq(e0a) => {
+ match (*other) {
+ ty_uniq(e0b) => e0a == e0b,
+ _ => false
+ }
+ }
+ ty_evec(e0a, e1a) => {
+ match (*other) {
+ ty_evec(e0b, e1b) => e0a == e0b && e1a == e1b,
+ _ => false
+ }
+ }
+ ty_ptr(e0a) => {
+ match (*other) {
+ ty_ptr(e0b) => e0a == e0b,
+ _ => false
+ }
+ }
+ ty_rptr(e0a, e1a) => {
+ match (*other) {
+ ty_rptr(e0b, e1b) => e0a == e0b && e1a == e1b,
+ _ => false
+ }
+ }
+ ty_rec(e0a) => {
+ match (*other) {
+ ty_rec(e0b) => e0a == e0b,
+ _ => false
+ }
+ }
+ ty_fn(e0a) => {
+ match (*other) {
+ ty_fn(e0b) => e0a == e0b,
+ _ => false
+ }
+ }
+ ty_trait(e0a, e1a, e2a) => {
+ match (*other) {
+ ty_trait(e0b, e1b, e2b) =>
+ e0a == e0b && e1a == e1b && e2a == e2b,
+ _ => false
+ }
+ }
+ ty_class(e0a, e1a) => {
+ match (*other) {
+ ty_class(e0b, e1b) => e0a == e0b && e1a == e1b,
+ _ => false
+ }
+ }
+ ty_tup(e0a) => {
+ match (*other) {
+ ty_tup(e0b) => e0a == e0b,
+ _ => false
+ }
+ }
+ ty_infer(e0a) => {
+ match (*other) {
+ ty_infer(e0b) => e0a == e0b,
+ _ => false
+ }
+ }
+ ty_param(e0a) => {
+ match (*other) {
+ ty_param(e0b) => e0a == e0b,
+ _ => false
+ }
+ }
+ ty_self => {
+ match (*other) {
+ ty_self => true,
+ _ => false
+ }
+ }
+ ty_type => {
+ match (*other) {
+ ty_type => true,
+ _ => false
+ }
+ }
+ ty_opaque_box => {
+ match (*other) {
+ ty_opaque_box => true,
+ _ => false
+ }
+ }
+ ty_opaque_closure_ptr(e0a) => {
+ match (*other) {
+ ty_opaque_closure_ptr(e0b) => e0a == e0b,
+ _ => false
+ }
+ }
+ ty_unboxed_vec(e0a) => {
+ match (*other) {
+ ty_unboxed_vec(e0b) => e0a == e0b,
+ _ => false
+ }
+ }
+ }
+ }
+ pure fn ne(other: &sty) -> bool { !self.eq(other) }
+}
+#[cfg(stage0)]
impl param_bound : cmp::Eq {
pure fn eq(&&other: param_bound) -> bool {
match self {
}
pure fn ne(&&other: param_bound) -> bool { !self.eq(other) }
}
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl param_bound : cmp::Eq {
+ pure fn eq(other: ¶m_bound) -> bool {
+ match self {
+ bound_copy => {
+ match (*other) {
+ bound_copy => true,
+ _ => false
+ }
+ }
+ bound_owned => {
+ match (*other) {
+ bound_owned => true,
+ _ => false
+ }
+ }
+ bound_send => {
+ match (*other) {
+ bound_send => true,
+ _ => false
+ }
+ }
+ bound_const => {
+ match (*other) {
+ bound_const => true,
+ _ => false
+ }
+ }
+ bound_trait(e0a) => {
+ match (*other) {
+ bound_trait(e0b) => e0a == e0b,
+ _ => false
+ }
+ }
+ }
+ }
+ pure fn ne(other: ¶m_bound) -> bool { !self.eq(other) }
+}
+#[cfg(stage0)]
impl kind : cmp::Eq {
pure fn eq(&&other: kind) -> bool { *self == *other }
pure fn ne(&&other: kind) -> bool { *self != *other }
}
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl kind : cmp::Eq {
+ pure fn eq(other: &kind) -> bool { *self == *(*other) }
+ pure fn ne(other: &kind) -> bool { *self != *(*other) }
+}
// Local Variables:
}
}
+// Controls whether the arguments are automatically referenced. This is useful
+// for overloaded binary and unary operators.
+enum DerefArgs {
+ DontDerefArgs,
+ DoDerefArgs
+}
+
fn check_expr_with_unifier(fcx: @fn_ctxt,
expr: @ast::expr,
expected: Option<ty::t>,
call_expr_id: ast::node_id,
in_fty: ty::t,
callee_expr: @ast::expr,
- args: ~[@ast::expr]) -> {fty: ty::t, bot: bool} {
+ args: ~[@ast::expr],
+ deref_args: DerefArgs) -> {fty: ty::t, bot: bool} {
let mut bot = false;
if is_block == check_blocks {
debug!("checking the argument");
- let formal_ty = formal_tys[i];
+ let mut formal_ty = formal_tys[i];
+
+ match deref_args {
+ DoDerefArgs => {
+ match ty::get(formal_ty).sty {
+ ty::ty_rptr(_, mt) => formal_ty = mt.ty,
+ _ => {
+ fcx.ccx.tcx.sess.span_bug(arg.span,
+ ~"no ref");
+ }
+ }
+ }
+ DontDerefArgs => {}
+ }
bot |= check_expr_with_unifier(
fcx, arg, Some(formal_ty),
// Call the generic checker.
let fty = {
let r = check_call_inner(fcx, sp, call_expr_id,
- fn_ty, f, args);
+ fn_ty, f, args, DontDerefArgs);
bot |= r.bot;
r.fty
};
fn lookup_op_method(fcx: @fn_ctxt, op_ex: @ast::expr,
self_ex: @ast::expr, self_t: ty::t,
- opname: ast::ident, args: ~[@ast::expr])
+ opname: ast::ident, args: ~[@ast::expr],
+ +deref_args: DerefArgs)
-> Option<(ty::t, bool)>
{
match method::lookup(fcx, op_ex, self_ex,
let {fty: method_ty, bot: bot} = {
let method_ty = fcx.node_ty(op_ex.callee_id);
check_call_inner(fcx, op_ex.span, op_ex.id,
- method_ty, op_ex, args)
+ method_ty, op_ex, args, deref_args)
};
fcx.ccx.method_map.insert(op_ex.id, origin);
Some((ty::ty_fn_ret(method_ty), bot))
let rhs_bot = check_expr_with(fcx, rhs, tvar);
let result_t = match op {
- ast::eq | ast::ne | ast::lt | ast::le | ast::ge | ast::gt => {
+ ast::eq | ast::ne | ast::lt | ast::le | ast::ge |
+ ast::gt => {
ty::mk_bool(tcx)
}
_ => {
Some(name) => {
match lookup_op_method(fcx, ex, lhs_expr, lhs_resolved_t,
fcx.tcx().sess.ident_of(name),
- ~[rhs]) {
+ ~[rhs], DoDerefArgs) {
Some(pair) => return pair,
_ => ()
}
ex: @ast::expr,
rhs_expr: @ast::expr, rhs_t: ty::t) -> ty::t {
match lookup_op_method(fcx, ex, rhs_expr, rhs_t,
- fcx.tcx().sess.ident_of(mname), ~[]) {
+ fcx.tcx().sess.ident_of(mname), ~[],
+ DontDerefArgs) {
Some((ret_ty, _)) => ret_ty,
_ => {
fcx.ccx.tcx.sess.span_err(
raw_base_t);
match lookup_op_method(fcx, expr, base, resolved,
tcx.sess.ident_of(~"index"),
- ~[idx]) {
+ ~[idx], DontDerefArgs) {
Some((ret_ty, _)) => fcx.write_ty(id, ret_ty),
_ => {
tcx.sess.span_fatal(
ConstrainVarSubReg(RegionVid, region)
}
+#[cfg(stage0)]
impl Constraint: cmp::Eq {
pure fn eq(&&other: Constraint) -> bool {
match (self, other) {
}
pure fn ne(&&other: Constraint) -> bool { !self.eq(other) }
}
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl Constraint : cmp::Eq {
+ pure fn eq(other: &Constraint) -> bool {
+ match (self, (*other)) {
+ (ConstrainVarSubVar(v0a, v1a), ConstrainVarSubVar(v0b, v1b)) => {
+ v0a == v0b && v1a == v1b
+ }
+ (ConstrainRegSubVar(ra, va), ConstrainRegSubVar(rb, vb)) => {
+ ra == rb && va == vb
+ }
+ (ConstrainVarSubReg(va, ra), ConstrainVarSubReg(vb, rb)) => {
+ va == vb && ra == rb
+ }
+ (ConstrainVarSubVar(*), _) => false,
+ (ConstrainRegSubVar(*), _) => false,
+ (ConstrainVarSubReg(*), _) => false
+ }
+ }
+ pure fn ne(other: &Constraint) -> bool { !self.eq(other) }
+}
impl Constraint : to_bytes::IterBytes {
pure fn iter_bytes(lsb0: bool, f: to_bytes::Cb) {
b: region,
}
+#[cfg(stage0)]
impl TwoRegions: cmp::Eq {
pure fn eq(&&other: TwoRegions) -> bool {
self.a == other.a && self.b == other.b
}
pure fn ne(&&other: TwoRegions) -> bool { !self.eq(other) }
}
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl TwoRegions : cmp::Eq {
+ pure fn eq(other: &TwoRegions) -> bool {
+ self.a == (*other).a && self.b == (*other).b
+ }
+ pure fn ne(other: &TwoRegions) -> bool { !self.eq(other) }
+}
impl TwoRegions : to_bytes::IterBytes {
pure fn iter_bytes(lsb0: bool, f: to_bytes::Cb) {
enum Direction { Incoming = 0, Outgoing = 1 }
+#[cfg(stage0)]
impl Direction : cmp::Eq {
pure fn eq(&&other: Direction) -> bool {
(self as uint) == (other as uint)
}
pure fn ne(&&other: Direction) -> bool { !self.eq(other) }
}
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl Direction : cmp::Eq {
+ pure fn eq(other: &Direction) -> bool {
+ (self as uint) == ((*other) as uint)
+ }
+ pure fn ne(other: &Direction) -> bool { !self.eq(other) }
+}
enum Classification { Expanding, Contracting }
+#[cfg(stage0)]
impl Classification : cmp::Eq {
pure fn eq(&&other: Classification) -> bool {
(self as uint) == (other as uint)
}
pure fn ne(&&other: Classification) -> bool { !self.eq(other) }
}
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl Classification : cmp::Eq {
+ pure fn eq(other: &Classification) -> bool {
+ (self as uint) == ((*other) as uint)
+ }
+ pure fn ne(other: &Classification) -> bool { !self.eq(other) }
+}
enum GraphNodeValue { NoValue, Value(region), ErrorValue }
PandocHtml
}
+#[cfg(stage0)]
impl OutputFormat : cmp::Eq {
pure fn eq(&&other: OutputFormat) -> bool {
(self as uint) == (other as uint)
}
pure fn ne(&&other: OutputFormat) -> bool { !self.eq(other) }
}
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl OutputFormat : cmp::Eq {
+ pure fn eq(other: &OutputFormat) -> bool {
+ (self as uint) == ((*other) as uint)
+ }
+ pure fn ne(other: &OutputFormat) -> bool { !self.eq(other) }
+}
/// How to organize the output
enum OutputStyle {
DocPerMod
}
+#[cfg(stage0)]
impl OutputStyle : cmp::Eq {
pure fn eq(&&other: OutputStyle) -> bool {
(self as uint) == (other as uint)
}
pure fn ne(&&other: OutputStyle) -> bool { !self.eq(other) }
}
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl OutputStyle : cmp::Eq {
+ pure fn eq(other: &OutputStyle) -> bool {
+ (self as uint) == ((*other) as uint)
+ }
+ pure fn ne(other: &OutputStyle) -> bool { !self.eq(other) }
+}
/// The configuration for a rustdoc session
type Config = {
pages: ~[Page]
};
+#[cfg(stage0)]
impl Doc_ : cmp::Eq {
pure fn eq(&&other: Doc_) -> bool {
self.pages == other.pages
}
pure fn ne(&&other: Doc_) -> bool { !self.eq(other) }
}
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl Doc_ : cmp::Eq {
+ pure fn eq(other: &Doc_) -> bool {
+ self.pages == (*other).pages
+ }
+ pure fn ne(other: &Doc_) -> bool { !self.eq(other) }
+}
enum Doc {
Doc_(Doc_)
}
+#[cfg(stage0)]
impl Doc : cmp::Eq {
pure fn eq(&&other: Doc) -> bool { *self == *other }
pure fn ne(&&other: Doc) -> bool { *self != *other }
}
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl Doc : cmp::Eq {
+ pure fn eq(other: &Doc) -> bool { *self == *(*other) }
+ pure fn ne(other: &Doc) -> bool { *self != *(*other) }
+}
enum Page {
CratePage(CrateDoc),
ItemPage(ItemTag)
}
+#[cfg(stage0)]
impl Page : cmp::Eq {
pure fn eq(&&other: Page) -> bool {
match self {
}
pure fn ne(&&other: Page) -> bool { !self.eq(other) }
}
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl Page : cmp::Eq {
+ pure fn eq(other: &Page) -> bool {
+ match self {
+ CratePage(e0a) => {
+ match (*other) {
+ CratePage(e0b) => e0a == e0b,
+ _ => false
+ }
+ }
+ ItemPage(e0a) => {
+ match (*other) {
+ ItemPage(e0b) => e0a == e0b,
+ _ => false
+ }
+ }
+ }
+ }
+ pure fn ne(other: &Page) -> bool { !self.eq(other) }
+}
enum Implementation {
Required,
Provided,
}
+#[cfg(stage0)]
impl Implementation : cmp::Eq {
pure fn eq(&&other: Implementation) -> bool {
(self as uint) == (other as uint)
}
pure fn ne(&&other: Implementation) -> bool { !self.eq(other) }
}
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl Implementation : cmp::Eq {
+ pure fn eq(other: &Implementation) -> bool {
+ (self as uint) == ((*other) as uint)
+ }
+ pure fn ne(other: &Implementation) -> bool { !self.eq(other) }
+}
/**
body: ~str
};
+#[cfg(stage0)]
impl Section : cmp::Eq {
pure fn eq(&&other: Section) -> bool {
self.header == other.header && self.body == other.body
}
pure fn ne(&&other: Section) -> bool { !self.eq(other) }
}
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl Section : cmp::Eq {
+ pure fn eq(other: &Section) -> bool {
+ self.header == (*other).header && self.body == (*other).body
+ }
+ pure fn ne(other: &Section) -> bool { !self.eq(other) }
+}
// FIXME (#2596): We currently give topmod the name of the crate. There
// would probably be fewer special cases if the crate had its own name
topmod: ModDoc,
};
+#[cfg(stage0)]
impl CrateDoc : cmp::Eq {
pure fn eq(&&other: CrateDoc) -> bool {
self.topmod == other.topmod
}
pure fn ne(&&other: CrateDoc) -> bool { !self.eq(other) }
}
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl CrateDoc : cmp::Eq {
+ pure fn eq(other: &CrateDoc) -> bool {
+ self.topmod == (*other).topmod
+ }
+ pure fn ne(other: &CrateDoc) -> bool { !self.eq(other) }
+}
enum ItemTag {
ModTag(ModDoc),
StructTag(StructDoc)
}
+#[cfg(stage0)]
impl ItemTag : cmp::Eq {
pure fn eq(&&other: ItemTag) -> bool {
match self {
}
pure fn ne(&&other: ItemTag) -> bool { !self.eq(other) }
}
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl ItemTag : cmp::Eq {
+ pure fn eq(other: &ItemTag) -> bool {
+ match self {
+ ModTag(e0a) => {
+ match (*other) {
+ ModTag(e0b) => e0a == e0b,
+ _ => false
+ }
+ }
+ NmodTag(e0a) => {
+ match (*other) {
+ NmodTag(e0b) => e0a == e0b,
+ _ => false
+ }
+ }
+ ConstTag(e0a) => {
+ match (*other) {
+ ConstTag(e0b) => e0a == e0b,
+ _ => false
+ }
+ }
+ FnTag(e0a) => {
+ match (*other) {
+ FnTag(e0b) => e0a == e0b,
+ _ => false
+ }
+ }
+ EnumTag(e0a) => {
+ match (*other) {
+ EnumTag(e0b) => e0a == e0b,
+ _ => false
+ }
+ }
+ TraitTag(e0a) => {
+ match (*other) {
+ TraitTag(e0b) => e0a == e0b,
+ _ => false
+ }
+ }
+ ImplTag(e0a) => {
+ match (*other) {
+ ImplTag(e0b) => e0a == e0b,
+ _ => false
+ }
+ }
+ TyTag(e0a) => {
+ match (*other) {
+ TyTag(e0b) => e0a == e0b,
+ _ => false
+ }
+ }
+ StructTag(e0a) => {
+ match (*other) {
+ StructTag(e0b) => e0a == e0b,
+ _ => false
+ }
+ }
+ }
+ }
+ pure fn ne(other: &ItemTag) -> bool { !self.eq(other) }
+}
type ItemDoc = {
id: AstId,
reexport: bool
};
+#[cfg(stage0)]
impl ItemDoc : cmp::Eq {
pure fn eq(&&other: ItemDoc) -> bool {
self.id == other.id &&
}
pure fn ne(&&other: ItemDoc) -> bool { !self.eq(other) }
}
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl ItemDoc : cmp::Eq {
+ pure fn eq(other: &ItemDoc) -> bool {
+ self.id == (*other).id &&
+ self.name == (*other).name &&
+ self.path == (*other).path &&
+ self.brief == (*other).brief &&
+ self.desc == (*other).desc &&
+ self.sections == (*other).sections &&
+ self.reexport == (*other).reexport
+ }
+ pure fn ne(other: &ItemDoc) -> bool { !self.eq(other) }
+}
type SimpleItemDoc = {
item: ItemDoc,
sig: Option<~str>
};
+#[cfg(stage0)]
impl SimpleItemDoc : cmp::Eq {
pure fn eq(&&other: SimpleItemDoc) -> bool {
self.item == other.item && self.sig == other.sig
}
pure fn ne(&&other: SimpleItemDoc) -> bool { !self.eq(other) }
}
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl SimpleItemDoc : cmp::Eq {
+ pure fn eq(other: &SimpleItemDoc) -> bool {
+ self.item == (*other).item && self.sig == (*other).sig
+ }
+ pure fn ne(other: &SimpleItemDoc) -> bool { !self.eq(other) }
+}
type ModDoc_ = {
item: ItemDoc,
index: Option<Index>
};
+#[cfg(stage0)]
impl ModDoc_ : cmp::Eq {
pure fn eq(&&other: ModDoc_) -> bool {
self.item == other.item &&
}
pure fn ne(&&other: ModDoc_) -> bool { !self.eq(other) }
}
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl ModDoc_ : cmp::Eq {
+ pure fn eq(other: &ModDoc_) -> bool {
+ self.item == (*other).item &&
+ self.items == (*other).items &&
+ self.index == (*other).index
+ }
+ pure fn ne(other: &ModDoc_) -> bool { !self.eq(other) }
+}
enum ModDoc {
ModDoc_(ModDoc_)
}
+#[cfg(stage0)]
impl ModDoc : cmp::Eq {
pure fn eq(&&other: ModDoc) -> bool { *self == *other }
pure fn ne(&&other: ModDoc) -> bool { *self != *other }
}
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl ModDoc : cmp::Eq {
+ pure fn eq(other: &ModDoc) -> bool { *self == *(*other) }
+ pure fn ne(other: &ModDoc) -> bool { *self != *(*other) }
+}
type NmodDoc = {
item: ItemDoc,
index: Option<Index>
};
+#[cfg(stage0)]
impl NmodDoc : cmp::Eq {
pure fn eq(&&other: NmodDoc) -> bool {
self.item == other.item &&
}
pure fn ne(&&other: NmodDoc) -> bool { !self.eq(other) }
}
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl NmodDoc : cmp::Eq {
+ pure fn eq(other: &NmodDoc) -> bool {
+ self.item == (*other).item &&
+ self.fns == (*other).fns &&
+ self.index == (*other).index
+ }
+ pure fn ne(other: &NmodDoc) -> bool { !self.eq(other) }
+}
type ConstDoc = SimpleItemDoc;
variants: ~[VariantDoc]
};
+#[cfg(stage0)]
impl EnumDoc : cmp::Eq {
pure fn eq(&&other: EnumDoc) -> bool {
self.item == other.item && self.variants == other.variants
}
pure fn ne(&&other: EnumDoc) -> bool { !self.eq(other) }
}
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl EnumDoc : cmp::Eq {
+ pure fn eq(other: &EnumDoc) -> bool {
+ self.item == (*other).item && self.variants == (*other).variants
+ }
+ pure fn ne(other: &EnumDoc) -> bool { !self.eq(other) }
+}
type VariantDoc = {
name: ~str,
sig: Option<~str>
};
+#[cfg(stage0)]
impl VariantDoc : cmp::Eq {
pure fn eq(&&other: VariantDoc) -> bool {
self.name == other.name &&
}
pure fn ne(&&other: VariantDoc) -> bool { !self.eq(other) }
}
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl VariantDoc : cmp::Eq {
+ pure fn eq(other: &VariantDoc) -> bool {
+ self.name == (*other).name &&
+ self.desc == (*other).desc &&
+ self.sig == (*other).sig
+ }
+ pure fn ne(other: &VariantDoc) -> bool { !self.eq(other) }
+}
type TraitDoc = {
item: ItemDoc,
methods: ~[MethodDoc]
};
+#[cfg(stage0)]
impl TraitDoc : cmp::Eq {
pure fn eq(&&other: TraitDoc) -> bool {
self.item == other.item && self.methods == other.methods
}
pure fn ne(&&other: TraitDoc) -> bool { !self.eq(other) }
}
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl TraitDoc : cmp::Eq {
+ pure fn eq(other: &TraitDoc) -> bool {
+ self.item == (*other).item && self.methods == (*other).methods
+ }
+ pure fn ne(other: &TraitDoc) -> bool { !self.eq(other) }
+}
type MethodDoc = {
name: ~str,
implementation: Implementation,
};
+#[cfg(stage0)]
impl MethodDoc : cmp::Eq {
pure fn eq(&&other: MethodDoc) -> bool {
self.name == other.name &&
}
pure fn ne(&&other: MethodDoc) -> bool { !self.eq(other) }
}
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl MethodDoc : cmp::Eq {
+ pure fn eq(other: &MethodDoc) -> bool {
+ self.name == (*other).name &&
+ self.brief == (*other).brief &&
+ self.desc == (*other).desc &&
+ self.sections == (*other).sections &&
+ self.sig == (*other).sig &&
+ self.implementation == (*other).implementation
+ }
+ pure fn ne(other: &MethodDoc) -> bool { !self.eq(other) }
+}
type ImplDoc = {
item: ItemDoc,
methods: ~[MethodDoc]
};
+#[cfg(stage0)]
impl ImplDoc : cmp::Eq {
pure fn eq(&&other: ImplDoc) -> bool {
self.item == other.item &&
}
pure fn ne(&&other: ImplDoc) -> bool { !self.eq(other) }
}
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl ImplDoc : cmp::Eq {
+ pure fn eq(other: &ImplDoc) -> bool {
+ self.item == (*other).item &&
+ self.trait_types == (*other).trait_types &&
+ self.self_ty == (*other).self_ty &&
+ self.methods == (*other).methods
+ }
+ pure fn ne(other: &ImplDoc) -> bool { !self.eq(other) }
+}
type TyDoc = SimpleItemDoc;
};
impl StructDoc : cmp::Eq {
- pure fn eq(&&other: StructDoc) -> bool {
+ pure fn eq(other: &StructDoc) -> bool {
return self.item == other.item
&& self.fields == other.fields
&& self.sig == other.sig;
}
- pure fn ne(&&other: StructDoc) -> bool { !self.eq(other) }
+ pure fn ne(other: &StructDoc) -> bool { !self.eq(other) }
}
type Index = {
entries: ~[IndexEntry]
};
+#[cfg(stage0)]
impl Index : cmp::Eq {
pure fn eq(&&other: Index) -> bool {
self.entries == other.entries
}
pure fn ne(&&other: Index) -> bool { !self.eq(other) }
}
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl Index : cmp::Eq {
+ pure fn eq(other: &Index) -> bool {
+ self.entries == (*other).entries
+ }
+ pure fn ne(other: &Index) -> bool { !self.eq(other) }
+}
/**
* A single entry in an index
link: ~str
};
+#[cfg(stage0)]
impl IndexEntry : cmp::Eq {
pure fn eq(&&other: IndexEntry) -> bool {
self.kind == other.kind &&
}
pure fn ne(&&other: IndexEntry) -> bool { !self.eq(other) }
}
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl IndexEntry : cmp::Eq {
+ pure fn eq(other: &IndexEntry) -> bool {
+ self.kind == (*other).kind &&
+ self.name == (*other).name &&
+ self.brief == (*other).brief &&
+ self.link == (*other).link
+ }
+ pure fn ne(other: &IndexEntry) -> bool { !self.eq(other) }
+}
impl Doc {
fn CrateDoc() -> CrateDoc {
im: f64
}
+#[cfg(stage0)]
impl cmplx : ops::Mul<cmplx,cmplx> {
pure fn mul(x: cmplx) -> cmplx {
cmplx {
}
}
}
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl cmplx : ops::Mul<cmplx,cmplx> {
+ pure fn mul(x: &cmplx) -> cmplx {
+ cmplx {
+ re: self.re*(*x).re - self.im*(*x).im,
+ im: self.re*(*x).im + self.im*(*x).re
+ }
+ }
+}
+#[cfg(stage0)]
impl cmplx : ops::Add<cmplx,cmplx> {
pure fn add(x: cmplx) -> cmplx {
cmplx {
}
}
}
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl cmplx : ops::Add<cmplx,cmplx> {
+ pure fn add(x: &cmplx) -> cmplx {
+ cmplx {
+ re: self.re + (*x).re,
+ im: self.im + (*x).im
+ }
+ }
+}
type line = {i: uint, b: ~[u8]};
enum foo = ~uint;
+#[cfg(stage0)]
impl foo: Add<foo, foo> {
pure fn add(f: foo) -> foo {
foo(~(**self + **f))
}
}
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl foo : Add<foo, foo> {
+ pure fn add(f: &foo) -> foo {
+ foo(~(**self + **(*f)))
+ }
+}
fn main() {
let x = foo(~3);
+// xfail-test
+// xfail-fast
+
+// XFAIL'd because of error message problems with demoded Add.
+
struct Point {
x: int,
y: int,
}
+#[cfg(stage0)]
impl Point : ops::Add<int,int> {
pure fn add(&&z: int) -> int {
self.x + self.y + z
}
}
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl Point : ops::Add<int,int> {
+ pure fn add(z: &int) -> int {
+ self.x + self.y + (*z)
+ }
+}
impl Point {
fn times(z: int) -> int {
+// xfail-fast
+// xfail-test
+
+// XFAIL'd due to problems with error messages on demoded Add.
+
#[legacy_modes];
fn foo<T: Copy>(+_t: T) { fail; }
fn S(x: int) -> S { S { x: x } }
+#[cfg(stage0)]
impl S: Add<S, S> {
pure fn add(rhs: S) -> S {
S { x: self.x + rhs.x }
}
}
+#[cfg(stage1)]
+#[cfg(stage2)]
+impl S : Add<S, S> {
+ pure fn add(rhs: &S) -> S {
+ S { x: self.x + (*rhs).x }
+ }
+}
fn main() {
let v = S(5);
enum thing = uint;
impl thing : cmp::Ord { //~ ERROR missing method `gt`
- pure fn lt(&&other: thing) -> bool { *self < *other }
- pure fn le(&&other: thing) -> bool { *self < *other }
- pure fn ge(&&other: thing) -> bool { *self < *other }
+ pure fn lt(other: &thing) -> bool { *self < *other }
+ pure fn le(other: &thing) -> bool { *self < *other }
+ pure fn ge(other: &thing) -> bool { *self < *other }
}
fn main() {}
}
impl an_enum : cmp::Eq {
- pure fn eq(&&other: an_enum) -> bool {
- self.v == other.v
+ pure fn eq(other: &an_enum) -> bool {
+ self.v == (*other).v
}
- pure fn ne(&&other: an_enum) -> bool { !self.eq(other) }
+ pure fn ne(other: &an_enum) -> bool { !self.eq(other) }
}
impl point : cmp::Eq {
- pure fn eq(&&other: point) -> bool {
- self.x == other.x && self.y == other.y
+ pure fn eq(other: &point) -> bool {
+ self.x == (*other).x && self.y == (*other).y
}
- pure fn ne(&&other: point) -> bool { !self.eq(other) }
+ pure fn ne(other: &point) -> bool { !self.eq(other) }
}
impl<T:cmp::Eq> quark<T> : cmp::Eq {
- pure fn eq(&&other: quark<T>) -> bool {
+ pure fn eq(other: &quark<T>) -> bool {
match self {
- top(ref q) => match other {
+ top(ref q) => match (*other) {
top(ref r) => q == r,
bottom(_) => false
},
- bottom(ref q) => match other {
+ bottom(ref q) => match (*other) {
top(_) => false,
bottom(ref r) => q == r
}
}
}
- pure fn ne(&&other: quark<T>) -> bool { !self.eq(other) }
+ pure fn ne(other: &quark<T>) -> bool { !self.eq(other) }
}
impl c_like : cmp::Eq {
- pure fn eq(&&other: c_like) -> bool {
- self as int == other as int
+ pure fn eq(other: &c_like) -> bool {
+ self as int == (*other) as int
}
- pure fn ne(&&other: c_like) -> bool { !self.eq(other) }
+ pure fn ne(other: &c_like) -> bool { !self.eq(other) }
}
impl expr : cmp::Eq {
- pure fn eq(&&other: expr) -> bool {
+ pure fn eq(other: &expr) -> bool {
match self {
val(e0a) => {
- match other {
+ match (*other) {
val(e0b) => e0a == e0b,
_ => false
}
}
plus(e0a, e1a) => {
- match other {
+ match (*other) {
plus(e0b, e1b) => e0a == e0b && e1a == e1b,
_ => false
}
}
minus(e0a, e1a) => {
- match other {
+ match (*other) {
minus(e0b, e1b) => e0a == e0b && e1a == e1b,
_ => false
}
}
}
}
- pure fn ne(&&other: expr) -> bool { !self.eq(other) }
+ pure fn ne(other: &expr) -> bool { !self.eq(other) }
}
#[auto_serialize]
type spanned<T> = {lo: uint, hi: uint, node: T};
impl<T:cmp::Eq> spanned<T> : cmp::Eq {
- pure fn eq(&&other: spanned<T>) -> bool {
- self.lo == other.lo && self.hi == other.hi && self.node.eq(other.node)
+ pure fn eq(other: &spanned<T>) -> bool {
+ self.lo == (*other).lo && self.hi == (*other).hi &&
+ self.node.eq(&(*other).node)
}
- pure fn ne(&&other: spanned<T>) -> bool { !self.eq(other) }
+ pure fn ne(other: &spanned<T>) -> bool { !self.eq(other) }
}
#[auto_serialize]
}
impl p : cmp::Eq {
- pure fn eq(&&other: p) -> bool {
- self.x == other.x && self.y == other.y
+ pure fn eq(other: &p) -> bool {
+ self.x == (*other).x && self.y == (*other).y
}
- pure fn ne(&&other: p) -> bool { !self.eq(other) }
+ pure fn ne(other: &p) -> bool { !self.eq(other) }
}
fn test_class() {
enum cat_type { tuxedo, tabby, tortoiseshell }
impl cat_type : cmp::Eq {
- pure fn eq(&&other: cat_type) -> bool {
- (self as uint) == (other as uint)
+ pure fn eq(other: &cat_type) -> bool {
+ (self as uint) == ((*other) as uint)
}
- pure fn ne(&&other: cat_type) -> bool { !self.eq(other) }
+ pure fn ne(other: &cat_type) -> bool { !self.eq(other) }
}
// Very silly -- this just returns the value of the name field
fn main() {
enum x { foo }
impl x : core::cmp::Eq {
- pure fn eq(&&other: x) -> bool { self as int == other as int }
- pure fn ne(&&other: x) -> bool { !self.eq(other) }
+ pure fn eq(other: &x) -> bool { self as int == (*other) as int }
+ pure fn ne(other: &x) -> bool { !self.eq(other) }
}
}
struct foo { a: int, b: int, c: int }
impl foo : cmp::Eq {
- pure fn eq(&&other: foo) -> bool {
- self.a == other.a && self.b == other.b && self.c == other.c
+ pure fn eq(other: &foo) -> bool {
+ self.a == (*other).a && self.b == (*other).b && self.c == (*other).c
}
- pure fn ne(&&other: foo) -> bool { !self.eq(other) }
+ pure fn ne(other: &foo) -> bool { !self.eq(other) }
}
const x : foo = foo { a:1, b:2, c: 3 };
enum chan { chan_t, }
impl chan : cmp::Eq {
- pure fn eq(&&other: chan) -> bool {
- (self as uint) == (other as uint)
+ pure fn eq(other: &chan) -> bool {
+ (self as uint) == ((*other) as uint)
}
- pure fn ne(&&other: chan) -> bool { !self.eq(other) }
+ pure fn ne(other: &chan) -> bool { !self.eq(other) }
}
fn wrapper3(i: chan) {
+++ /dev/null
-fn main() {
- let x : str/5 = "hello"/5;
- let _y : str/5 = "there"/_;
- let mut z = "thing"/_;
- z = x;
- assert z[0] == ('h' as u8);
- assert z[4] == ('o' as u8);
-
- let a = "aaaa"/_;
- let b = "bbbb"/_;
- let c = "cccc"/_;
-
- log(debug, a);
-
- assert a < b;
- assert a <= b;
- assert a != b;
- assert b >= a;
- assert b > a;
-
- log(debug, b);
-
- assert b < c;
- assert b <= c;
- assert b != c;
- assert c >= b;
- assert c > b;
-
- assert a < c;
- assert a <= c;
- assert a != c;
- assert c >= a;
- assert c > a;
-
- log(debug, c);
-}
+// xfail-test
+// xfail-fast
+
+// Doesn't work; needs a design decision.
+
fn main() {
let x : [int]/5 = [1,2,3,4,5]/5;
let _y : [int]/5 = [1,2,3,4,5]/_;
enum t { t1, t2, }
impl t : cmp::Eq {
- pure fn eq(&&other: t) -> bool {
- (self as uint) == (other as uint)
+ pure fn eq(other: &t) -> bool {
+ (self as uint) == ((*other) as uint)
}
- pure fn ne(&&other: t) -> bool { !self.eq(other) }
+ pure fn ne(other: &t) -> bool { !self.eq(other) }
}
fn f() -> t { return t1; }
}
enum mood { happy, sad, }
+
impl mood : cmp::Eq {
- pure fn eq(&&other: mood) -> bool {
- (self as uint) == (other as uint)
+ pure fn eq(other: &mood) -> bool {
+ (self as uint) == ((*other) as uint)
}
- pure fn ne(&&other: mood) -> bool { !self.eq(other) }
+ pure fn ne(other: &mood) -> bool { !self.eq(other) }
}
fn test_tag() {
}
enum mood { happy, sad, }
+
impl mood : cmp::Eq {
- pure fn eq(&&other: mood) -> bool {
- (self as uint) == (other as uint)
+ pure fn eq(other: &mood) -> bool {
+ (self as uint) == ((*other) as uint)
}
- pure fn ne(&&other: mood) -> bool { !self.eq(other) }
+ pure fn ne(other: &mood) -> bool { !self.eq(other) }
}
fn test_tag() {
}
impl state : cmp::Eq {
- pure fn eq(&&other: state) -> bool {
- (self as uint) == (other as uint)
+ pure fn eq(other: &state) -> bool {
+ (self as uint) == ((*other) as uint)
}
- pure fn ne(&&other: state) -> bool { !self.eq(other) }
+ pure fn ne(other: &state) -> bool { !self.eq(other) }
}
type packet<T: Send> = {
}
impl Point : ops::Add<Point,Point> {
- pure fn add(other: Point) -> Point {
- Point {x: self.x + other.x, y: self.y + other.y}
+ pure fn add(other: &Point) -> Point {
+ Point {x: self.x + (*other).x, y: self.y + (*other).y}
}
}
impl Point : ops::Sub<Point,Point> {
- pure fn sub(other: Point) -> Point {
- Point {x: self.x - other.x, y: self.y - other.y}
+ pure fn sub(other: &Point) -> Point {
+ Point {x: self.x - (*other).x, y: self.y - (*other).y}
}
}
}
impl Point : cmp::Eq {
- pure fn eq(&&other: Point) -> bool {
- self.x == other.x && self.y == other.y
+ pure fn eq(other: &Point) -> bool {
+ self.x == (*other).x && self.y == (*other).y
}
- pure fn ne(&&other: Point) -> bool { !self.eq(other) }
+ pure fn ne(other: &Point) -> bool { !self.eq(other) }
}
fn main() {
enum foo { large, small, }
impl foo : cmp::Eq {
- pure fn eq(&&other: foo) -> bool {
- (self as uint) == (other as uint)
+ pure fn eq(other: &foo) -> bool {
+ (self as uint) == ((*other) as uint)
}
- pure fn ne(&&other: foo) -> bool { !self.eq(other) }
+ pure fn ne(other: &foo) -> bool { !self.eq(other) }
}
fn main() {
}
impl color : cmp::Eq {
- pure fn eq(&&other: color) -> bool {
- (self as uint) == (other as uint)
+ pure fn eq(other: &color) -> bool {
+ (self as uint) == ((*other) as uint)
}
- pure fn ne(&&other: color) -> bool { !self.eq(other) }
+ pure fn ne(other: &color) -> bool { !self.eq(other) }
}
fn main() {
enum colour { red(int, int), green, }
impl colour : cmp::Eq {
- pure fn eq(&&other: colour) -> bool {
+ pure fn eq(other: &colour) -> bool {
match self {
red(a0, b0) => {
- match other {
+ match (*other) {
red(a1, b1) => a0 == a1 && b0 == b1,
green => false,
}
}
green => {
- match other {
+ match (*other) {
red(*) => false,
green => true
}
}
}
}
- pure fn ne(&&other: colour) -> bool { !self.eq(other) }
+ pure fn ne(other: &colour) -> bool { !self.eq(other) }
}
fn f() { let x = red(1, 2); let y = green; assert (x != y); }
}
impl t : cmp::Eq {
- pure fn eq(&&other: t) -> bool {
+ pure fn eq(other: &t) -> bool {
match self {
tag1 => {
- match other {
+ match (*other) {
tag1 => true,
_ => false
}
}
tag2(e0a) => {
- match other {
+ match (*other) {
tag2(e0b) => e0a == e0b,
_ => false
}
}
tag3(e0a, e1a, e2a) => {
- match other {
+ match (*other) {
tag3(e0b, e1b, e2b) =>
e0a == e0b && e1a == e1b && e2a == e2b,
_ => false
}
}
}
- pure fn ne(&&other: t) -> bool { !self.eq(other) }
+ pure fn ne(other: &t) -> bool { !self.eq(other) }
}
fn test_tag() {
}
// pronounced "impl of Ord for int" -- not sold on this yet
-impl int: Ord {
- fn lt(a: int) -> bool {
- self < a
+impl int : Ord {
+ fn lt(a: &int) -> bool {
+ self < (*a)
}
// is this the place to put this?
- fn eq(a: int) -> bool {
- self == a
+ fn eq(a: &int) -> bool {
+ self == (*a)
}
}
enum t { a, b(~str), }
impl t : cmp::Eq {
- pure fn eq(&&other: t) -> bool {
+ pure fn eq(other: &t) -> bool {
match self {
a => {
- match other {
+ match (*other) {
a => true,
b(_) => false
}
}
b(s0) => {
- match other {
+ match (*other) {
a => false,
b(s1) => s0 == s1
}
}
}
}
- pure fn ne(&&other: t) -> bool { !self.eq(other) }
+ pure fn ne(other: &t) -> bool { !self.eq(other) }
}
fn make(i: int) -> t {