use std::num::Bitwise;
-#[deriving(Clone, Eq, Hash, Show)]
+#[deriving(Clone, Eq, TotalEq, Hash, Show)]
/// A specialized Set implementation to use enum types.
pub struct EnumSet<E> {
// We must maintain the invariant that no bits are set
use std::container::{Container, Mutable, Map, MutableMap, Set, MutableSet};
use std::clone::Clone;
-use std::cmp::{Eq, Equiv, max};
+use std::cmp::{Eq, TotalEq, Equiv, max};
use std::default::Default;
use std::fmt;
use std::fmt::Show;
}
/// A hash that is not zero, since we use that to represent empty buckets.
+ #[deriving(Eq)]
pub struct SafeHash {
priv hash: u64,
}
pub fn inspect(&self) -> u64 { self.hash }
}
- impl Eq for SafeHash {
- fn eq(&self, other: &SafeHash) -> bool { self.hash == other.hash }
- }
-
/// We need to remove hashes of 0. That's reserved for empty buckets.
/// This function wraps up `hash_keyed` to be the only way outside this
/// module to generate a SafeHash.
fraction_mul(capacity, load_factor)
}
-impl<K: Eq + Hash<S>, V, S, H: Hasher<S>> HashMap<K, V, H> {
+impl<K: TotalEq + Hash<S>, V, S, H: Hasher<S>> HashMap<K, V, H> {
/// Get the number of elements which will force the capacity to shrink.
/// When size == self.shrink_at(), we halve the capacity.
fn shrink_at(&self) -> uint {
}
}
-impl<K: Eq + Hash<S>, V, S, H: Hasher<S>> Container for HashMap<K, V, H> {
+impl<K: TotalEq + Hash<S>, V, S, H: Hasher<S>> Container for HashMap<K, V, H> {
/// Return the number of elements in the map
fn len(&self) -> uint { self.table.size() }
}
-impl<K: Eq + Hash<S>, V, S, H: Hasher<S>> Mutable for HashMap<K, V, H> {
+impl<K: TotalEq + Hash<S>, V, S, H: Hasher<S>> Mutable for HashMap<K, V, H> {
/// Clear the map, removing all key-value pairs.
fn clear(&mut self) {
self.minimum_capacity = self.table.size();
}
-impl<K: Eq + Hash<S>, V, S, H: Hasher<S>> Map<K, V> for HashMap<K, V, H> {
+impl<K: TotalEq + Hash<S>, V, S, H: Hasher<S>> Map<K, V> for HashMap<K, V, H> {
fn find<'a>(&'a self, k: &K) -> Option<&'a V> {
self.search(k).map(|idx| {
let (_, v) = self.table.read(&idx);
}
}
-impl<K: Eq + Hash<S>, V, S, H: Hasher<S>> MutableMap<K, V> for HashMap<K, V, H> {
+impl<K: TotalEq + Hash<S>, V, S, H: Hasher<S>> MutableMap<K, V> for HashMap<K, V, H> {
fn find_mut<'a>(&'a mut self, k: &K) -> Option<&'a mut V> {
match self.search(k) {
None => None,
}
}
-impl<K: Hash + Eq, V> HashMap<K, V, sip::SipHasher> {
+impl<K: Hash + TotalEq, V> HashMap<K, V, sip::SipHasher> {
/// Create an empty HashMap.
pub fn new() -> HashMap<K, V, sip::SipHasher> {
HashMap::with_capacity(INITIAL_CAPACITY)
}
}
-impl<K: Eq + Hash<S>, V, S, H: Hasher<S>> HashMap<K, V, H> {
+impl<K: TotalEq + Hash<S>, V, S, H: Hasher<S>> HashMap<K, V, H> {
pub fn with_hasher(hasher: H) -> HashMap<K, V, H> {
HashMap::with_capacity_and_hasher(INITIAL_CAPACITY, hasher)
}
}
}
-impl<K: Eq + Hash<S>, V: Clone, S, H: Hasher<S>> HashMap<K, V, H> {
+impl<K: TotalEq + Hash<S>, V: Clone, S, H: Hasher<S>> HashMap<K, V, H> {
/// Like `find`, but returns a copy of the value.
pub fn find_copy(&self, k: &K) -> Option<V> {
self.find(k).map(|v| (*v).clone())
}
}
-impl<K: Eq + Hash<S>, V: Eq, S, H: Hasher<S>> Eq for HashMap<K, V, H> {
+impl<K: TotalEq + Hash<S>, V: Eq, S, H: Hasher<S>> Eq for HashMap<K, V, H> {
fn eq(&self, other: &HashMap<K, V, H>) -> bool {
if self.len() != other.len() { return false; }
}
}
-impl<K: Eq + Hash<S> + Show, V: Show, S, H: Hasher<S>> Show for HashMap<K, V, H> {
+impl<K: TotalEq + Hash<S> + Show, V: Show, S, H: Hasher<S>> Show for HashMap<K, V, H> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
try!(write!(f.buf, r"\{"));
}
}
-impl<K: Eq + Hash<S>, V, S, H: Hasher<S> + Default> Default for HashMap<K, V, H> {
+impl<K: TotalEq + Hash<S>, V, S, H: Hasher<S> + Default> Default for HashMap<K, V, H> {
fn default() -> HashMap<K, V, H> {
HashMap::with_capacity_and_hasher(INITIAL_CAPACITY, Default::default())
}
pub type Values<'a, K, V> =
iter::Map<'static, (&'a K, &'a V), &'a V, Entries<'a, K, V>>;
-impl<K: Eq + Hash<S>, V, S, H: Hasher<S> + Default> FromIterator<(K, V)> for HashMap<K, V, H> {
+impl<K: TotalEq + Hash<S>, V, S, H: Hasher<S> + Default> FromIterator<(K, V)> for HashMap<K, V, H> {
fn from_iterator<T: Iterator<(K, V)>>(iter: &mut T) -> HashMap<K, V, H> {
let (lower, _) = iter.size_hint();
let mut map = HashMap::with_capacity_and_hasher(lower, Default::default());
}
}
-impl<K: Eq + Hash<S>, V, S, H: Hasher<S> + Default> Extendable<(K, V)> for HashMap<K, V, H> {
+impl<K: TotalEq + Hash<S>, V, S, H: Hasher<S> + Default> Extendable<(K, V)> for HashMap<K, V, H> {
fn extend<T: Iterator<(K, V)>>(&mut self, iter: &mut T) {
for (k, v) in *iter {
self.insert(k, v);
priv map: HashMap<T, (), H>
}
-impl<T: Eq + Hash<S>, S, H: Hasher<S>> Eq for HashSet<T, H> {
+impl<T: TotalEq + Hash<S>, S, H: Hasher<S>> Eq for HashSet<T, H> {
// FIXME #11998: Since the value is a (), and `find` returns a Some(&()),
// we trigger #11998 when matching on it. I've fallen back to manual
// iteration until this is fixed.
}
}
-impl<T: Eq + Hash<S>, S, H: Hasher<S>> Container for HashSet<T, H> {
+impl<T: TotalEq + Hash<S>, S, H: Hasher<S>> Container for HashSet<T, H> {
/// Return the number of elements in the set
fn len(&self) -> uint { self.map.len() }
}
-impl<T: Eq + Hash<S>, S, H: Hasher<S>> Mutable for HashSet<T, H> {
+impl<T: TotalEq + Hash<S>, S, H: Hasher<S>> Mutable for HashSet<T, H> {
/// Clear the set, removing all values.
fn clear(&mut self) { self.map.clear() }
}
-impl<T: Eq + Hash<S>, S, H: Hasher<S>> Set<T> for HashSet<T, H> {
+impl<T: TotalEq + Hash<S>, S, H: Hasher<S>> Set<T> for HashSet<T, H> {
/// Return true if the set contains a value
fn contains(&self, value: &T) -> bool { self.map.search(value).is_some() }
}
}
-impl<T: Eq + Hash<S>, S, H: Hasher<S>> MutableSet<T> for HashSet<T, H> {
+impl<T: TotalEq + Hash<S>, S, H: Hasher<S>> MutableSet<T> for HashSet<T, H> {
/// Add a value to the set. Return true if the value was not already
/// present in the set.
fn insert(&mut self, value: T) -> bool { self.map.insert(value, ()) }
fn remove(&mut self, value: &T) -> bool { self.map.remove(value) }
}
-impl<T: Hash + Eq> HashSet<T, sip::SipHasher> {
+impl<T: Hash + TotalEq> HashSet<T, sip::SipHasher> {
/// Create an empty HashSet
pub fn new() -> HashSet<T, sip::SipHasher> {
HashSet::with_capacity(INITIAL_CAPACITY)
}
}
-impl<T: Eq + Hash<S>, S, H: Hasher<S>> HashSet<T, H> {
+impl<T: TotalEq + Hash<S>, S, H: Hasher<S>> HashSet<T, H> {
pub fn with_hasher(hasher: H) -> HashSet<T, H> {
HashSet::with_capacity_and_hasher(INITIAL_CAPACITY, hasher)
}
}
-impl<T: Eq + Hash<S> + fmt::Show, S, H: Hasher<S>> fmt::Show for HashSet<T, H> {
+impl<T: TotalEq + Hash<S> + fmt::Show, S, H: Hasher<S>> fmt::Show for HashSet<T, H> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
try!(write!(f.buf, r"\{"));
}
}
-impl<T: Eq + Hash<S>, S, H: Hasher<S> + Default> FromIterator<T> for HashSet<T, H> {
+impl<T: TotalEq + Hash<S>, S, H: Hasher<S> + Default> FromIterator<T> for HashSet<T, H> {
fn from_iterator<I: Iterator<T>>(iter: &mut I) -> HashSet<T, H> {
let (lower, _) = iter.size_hint();
let mut set = HashSet::with_capacity_and_hasher(lower, Default::default());
}
}
-impl<T: Eq + Hash<S>, S, H: Hasher<S> + Default> Extendable<T> for HashSet<T, H> {
+impl<T: TotalEq + Hash<S>, S, H: Hasher<S> + Default> Extendable<T> for HashSet<T, H> {
fn extend<I: Iterator<T>>(&mut self, iter: &mut I) {
for k in *iter {
self.insert(k);
}
}
-impl<T: Eq + Hash> Default for HashSet<T, sip::SipHasher> {
+impl<T: TotalEq + Hash> Default for HashSet<T, sip::SipHasher> {
fn default() -> HashSet<T> { HashSet::new() }
}
local_data_key!(drop_vector: vec::Vec<int>)
- #[deriving(Hash, Eq)]
+ #[deriving(Hash, Eq, TotalEq)]
struct Dropable {
k: int
}
}
}
+impl<K: TotalEq> TotalEq for KeyRef<K> {}
+
impl<K, V> LruEntry<K, V> {
fn new() -> LruEntry<K, V> {
LruEntry {
}
}
-impl<K: Hash + Eq, V> LruCache<K, V> {
+impl<K: Hash + TotalEq, V> LruCache<K, V> {
/// Create an LRU Cache that holds at most `capacity` items.
pub fn new(capacity: uint) -> LruCache<K, V> {
let cache = LruCache {
}
}
-impl<A: fmt::Show + Hash + Eq, B: fmt::Show> fmt::Show for LruCache<A, B> {
+impl<A: fmt::Show + Hash + TotalEq, B: fmt::Show> fmt::Show for LruCache<A, B> {
/// Return a string that lists the key-value pairs from most-recently
/// used to least-recently used.
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
}
}
-impl<K: Hash + Eq, V> Container for LruCache<K, V> {
+impl<K: Hash + TotalEq, V> Container for LruCache<K, V> {
/// Return the number of key-value pairs in the cache.
fn len(&self) -> uint {
self.map.len()
}
}
-impl<K: Hash + Eq, V> Mutable for LruCache<K, V> {
+impl<K: Hash + TotalEq, V> Mutable for LruCache<K, V> {
/// Clear the cache of all key-value pairs.
fn clear(&mut self) {
self.map.clear();
//
// Note that there is no entry with derefs:3---the type of that expression
// is T, which is not a box.
-#[deriving(Eq, Hash)]
+#[deriving(Eq, TotalEq, Hash)]
pub struct root_map_key {
id: ast::NodeId,
derefs: uint
RefBinding,
}
-#[deriving(Eq, Hash)]
+#[deriving(Eq, TotalEq, Hash)]
pub enum LoanPath {
LpVar(ast::NodeId), // `x` in doc.rs
LpExtend(@LoanPath, mc::MutabilityCategory, LoanPathElem)
}
-#[deriving(Eq, Hash)]
+#[deriving(Eq, TotalEq, Hash)]
pub enum LoanPathElem {
LpDeref(mc::PointerKind), // `*LV` in doc.rs
LpInterior(mc::InteriorKind) // `LV.f` in doc.rs
}
// different kinds of pointers:
-#[deriving(Eq, Hash)]
+#[deriving(Eq, TotalEq, Hash)]
pub enum PointerKind {
OwnedPtr,
GcPtr,
// We use the term "interior" to mean "something reachable from the
// base without a pointer dereference", e.g. a field
-#[deriving(Eq, Hash)]
+#[deriving(Eq, TotalEq, Hash)]
pub enum InteriorKind {
InteriorField(FieldName),
InteriorElement(ElementKind),
}
-#[deriving(Eq, Hash)]
+#[deriving(Eq, TotalEq, Hash)]
pub enum FieldName {
NamedField(ast::Name),
PositionalField(uint)
}
-#[deriving(Eq, Hash)]
+#[deriving(Eq, TotalEq, Hash)]
pub enum ElementKind {
VecElement,
StrElement,
OtherElement,
}
-#[deriving(Eq, Hash, Show)]
+#[deriving(Eq, TotalEq, Hash, Show)]
pub enum MutabilityCategory {
McImmutable, // Immutable.
McDeclared, // Directly declared as mutable.
ArgumentIrrefutableMode,
}
-#[deriving(Eq, Hash)]
+#[deriving(Eq, TotalEq, Hash)]
enum Namespace {
TypeNS,
ValueNS
}
// Used to identify cached monomorphized functions and vtables
-#[deriving(Eq, Hash)]
+#[deriving(Eq, TotalEq, Hash)]
pub enum mono_param_id {
mono_precise(ty::t, Option<@Vec<mono_id> >),
mono_any,
datum::RvalueMode),
}
-#[deriving(Eq, Hash)]
+#[deriving(Eq, TotalEq, Hash)]
pub enum MonoDataClass {
MonoBits, // Anything not treated differently from arbitrary integer data
MonoNonNull, // Non-null pointers (used for optional-pointer optimization)
}
}
-#[deriving(Eq, Hash)]
+#[deriving(Eq, TotalEq, Hash)]
pub struct mono_id_ {
def: ast::DefId,
params: Vec<mono_param_id> }
fn drop(&mut self) { }
}
-#[deriving(Eq, Hash)]
+#[deriving(Eq, TotalEq, Hash)]
pub enum RvalueMode {
/// `val` is a pointer to the actual value (and thus has type *T)
ByRef,
// Data types
-#[deriving(Eq, Hash)]
+#[deriving(Eq, TotalEq, Hash)]
pub struct field {
ident: ast::Ident,
mt: mt
ident: Ident,
methods: Vec<@Method> }
-#[deriving(Clone, Eq, Hash)]
+#[deriving(Clone, Eq, TotalEq, Hash)]
pub struct mt {
ty: t,
mutbl: ast::Mutability,
}
-#[deriving(Clone, Eq, Encodable, Decodable, Hash, Show)]
+#[deriving(Clone, Eq, TotalEq, Encodable, Decodable, Hash, Show)]
pub enum vstore {
vstore_fixed(uint),
vstore_uniq,
vstore_slice(Region)
}
-#[deriving(Clone, Eq, Hash, Encodable, Decodable, Show)]
+#[deriving(Clone, Eq, TotalEq, Hash, Encodable, Decodable, Show)]
pub enum TraitStore {
UniqTraitStore, // ~Trait
RegionTraitStore(Region), // &Trait
// Contains information needed to resolve types and (in the future) look up
// the types of AST nodes.
-#[deriving(Eq, Hash)]
+#[deriving(Eq, TotalEq, Hash)]
pub struct creader_cache_key {
cnum: CrateNum,
pos: uint,
}
}
+impl TotalEq for intern_key {}
+
impl<W:Writer> Hash<W> for intern_key {
fn hash(&self, s: &mut W) {
unsafe { (*self.sty).hash(s) }
// alive, and using ty::get is unsafe when the ctxt is no longer alive.
enum t_opaque {}
-#[deriving(Clone, Eq, Hash)]
+#[deriving(Clone, Eq, TotalEq, Hash)]
pub struct t { priv inner: *t_opaque }
impl fmt::Show for t {
}
pub fn type_id(t: t) -> uint { get(t).id }
-#[deriving(Clone, Eq, Hash)]
+#[deriving(Clone, Eq, TotalEq, Hash)]
pub struct BareFnTy {
purity: ast::Purity,
abis: AbiSet,
sig: FnSig
}
-#[deriving(Clone, Eq, Hash)]
+#[deriving(Clone, Eq, TotalEq, Hash)]
pub struct ClosureTy {
purity: ast::Purity,
sigil: ast::Sigil,
* - `output` is the return type.
* - `variadic` indicates whether this is a varidic function. (only true for foreign fns)
*/
-#[deriving(Clone, Eq, Hash)]
+#[deriving(Clone, Eq, TotalEq, Hash)]
pub struct FnSig {
binder_id: ast::NodeId,
inputs: Vec<t>,
variadic: bool
}
-#[deriving(Clone, Eq, Hash)]
+#[deriving(Clone, Eq, TotalEq, Hash)]
pub struct param_ty {
idx: uint,
def_id: DefId
}
/// Representation of regions:
-#[deriving(Clone, Eq, Hash, Encodable, Decodable, Show)]
+#[deriving(Clone, Eq, TotalEq, Hash, Encodable, Decodable, Show)]
pub enum Region {
// Region bound in a type or fn declaration which will be
// substituted 'early' -- that is, at the same time when type
* the original var id (that is, the root variable that is referenced
* by the upvar) and the id of the closure expression.
*/
-#[deriving(Clone, Eq, Hash)]
+#[deriving(Clone, Eq, TotalEq, Hash)]
pub struct UpvarId {
var_id: ast::NodeId,
closure_expr_id: ast::NodeId,
}
-#[deriving(Clone, Eq, Hash)]
+#[deriving(Clone, Eq, TotalEq, Hash)]
pub enum BorrowKind {
/// Data must be immutable and is aliasable.
ImmBorrow,
* Represents the values to use when substituting lifetime parameters.
* If the value is `ErasedRegions`, then this subst is occurring during
* trans, and all region parameters will be replaced with `ty::ReStatic`. */
-#[deriving(Clone, Eq, Hash)]
+#[deriving(Clone, Eq, TotalEq, Hash)]
pub enum RegionSubsts {
ErasedRegions,
NonerasedRegions(OwnedSlice<ty::Region>)
* - `self_ty` is the type to which `self` should be remapped, if any. The
* `self` type is rather funny in that it can only appear on traits and is
* always substituted away to the implementing type for a trait. */
-#[deriving(Clone, Eq, Hash)]
+#[deriving(Clone, Eq, TotalEq, Hash)]
pub struct substs {
self_ty: Option<ty::t>,
tps: Vec<t>,
// NB: If you change this, you'll probably want to change the corresponding
// AST structure in libsyntax/ast.rs as well.
-#[deriving(Clone, Eq, Hash)]
+#[deriving(Clone, Eq, TotalEq, Hash)]
pub enum sty {
ty_nil,
ty_bot,
ty_unboxed_vec(mt),
}
-#[deriving(Clone, Eq, Hash)]
+#[deriving(Clone, Eq, TotalEq, Hash)]
pub struct TyTrait {
def_id: DefId,
substs: substs,
bounds: BuiltinBounds
}
-#[deriving(Eq, Hash)]
+#[deriving(Eq, TotalEq, Hash)]
pub struct TraitRef {
def_id: DefId,
substs: substs
terr_variadic_mismatch(expected_found<bool>)
}
-#[deriving(Eq, Hash)]
+#[deriving(Eq, TotalEq, Hash)]
pub struct ParamBounds {
builtin_bounds: BuiltinBounds,
trait_bounds: Vec<@TraitRef> }
pub type BuiltinBounds = EnumSet<BuiltinBound>;
-#[deriving(Clone, Encodable, Eq, Decodable, Hash, Show)]
+#[deriving(Clone, Encodable, Eq, TotalEq, Decodable, Hash, Show)]
#[repr(uint)]
pub enum BuiltinBound {
BoundStatic,
}
}
-#[deriving(Clone, Eq, Hash)]
+#[deriving(Clone, Eq, TotalEq, Hash)]
pub struct TyVid(uint);
-#[deriving(Clone, Eq, Hash)]
+#[deriving(Clone, Eq, TotalEq, Hash)]
pub struct IntVid(uint);
-#[deriving(Clone, Eq, Hash)]
+#[deriving(Clone, Eq, TotalEq, Hash)]
pub struct FloatVid(uint);
-#[deriving(Clone, Eq, Encodable, Decodable, Hash)]
+#[deriving(Clone, Eq, TotalEq, Encodable, Decodable, Hash)]
pub struct RegionVid {
id: uint
}
-#[deriving(Clone, Eq, Hash)]
+#[deriving(Clone, Eq, TotalEq, Hash)]
pub enum InferTy {
TyVar(TyVid),
IntVar(IntVid),
FloatVar(FloatVid)
}
-#[deriving(Clone, Encodable, Decodable, Hash, Show)]
+#[deriving(Clone, Encodable, Decodable, TotalEq, Hash, Show)]
pub enum InferRegion {
ReVar(RegionVid),
ReSkolemized(uint, BoundRegion)
mod doc;
-#[deriving(Eq, Hash)]
+#[deriving(Eq, TotalEq, Hash)]
pub enum Constraint {
ConstrainVarSubVar(RegionVid, RegionVid),
ConstrainRegSubVar(Region, RegionVid),
ConstrainRegSubReg(Region, Region),
}
-#[deriving(Eq, Hash)]
+#[deriving(Eq, TotalEq, Hash)]
pub struct TwoRegions {
a: Region,
b: Region,
substs: ty::substs
}
-#[deriving(Clone, Eq, Hash, Show)]
+#[deriving(Clone, Eq, TotalEq, Hash, Show)]
pub struct MethodCall {
expr_id: ast::NodeId,
autoderef: u32
pub mod FnvHashMap {
use std::hash::Hash;
use collections::HashMap;
- pub fn new<K: Hash<super::FnvState> + Eq, V>() -> super::FnvHashMap<K, V> {
+ pub fn new<K: Hash<super::FnvState> + TotalEq, V>() -> super::FnvHashMap<K, V> {
HashMap::with_hasher(super::FnvHasher)
}
}
impl<
E: Encoder,
- K: Encodable<E> + Hash<S> + Eq,
+ K: Encodable<E> + Hash<S> + TotalEq,
V: Encodable<E>,
S,
H: Hasher<S>
impl<
D: Decoder,
- K: Decodable<D> + Hash<S> + Eq,
+ K: Decodable<D> + Hash<S> + TotalEq,
V: Decodable<D>,
S,
H: Hasher<S> + Default
impl<
E: Encoder,
- T: Encodable<E> + Hash<S> + Eq,
+ T: Encodable<E> + Hash<S> + TotalEq,
S,
H: Hasher<S>
> Encodable<E> for HashSet<T, H> {
impl<
D: Decoder,
- T: Decodable<D> + Hash<S> + Eq,
+ T: Decodable<D> + Hash<S> + TotalEq,
S,
H: Hasher<S> + Default
> Decodable<D> for HashSet<T, H> {
}
/// A selector for what pluralization a plural method should take
-#[deriving(Eq, Hash)]
+#[deriving(Eq, TotalEq, Hash)]
pub enum PluralSelector {
/// One of the plural keywords should be used
Keyword(PluralKeyword),
/// specially placed in the `Plural` variant of `Method`
///
/// http://www.icu-project.org/apiref/icu4c/classicu_1_1PluralRules.html
-#[deriving(Eq, Hash)]
+#[deriving(Eq, TotalEq, Hash)]
#[allow(missing_doc)]
pub enum PluralKeyword {
Zero, One, Two, Few, Many
use container::Container;
use c_str::{CString, ToCStr};
use clone::Clone;
-use cmp::Eq;
+use cmp::{Eq, TotalEq};
use from_str::FromStr;
use io::Writer;
use iter::{AdditiveIterator, Extendable, Iterator, Map};
}
}
+impl TotalEq for Path {}
+
impl FromStr for Path {
fn from_str(s: &str) -> Option<Path> {
Path::new_opt(s)
use cast;
use clone::Clone;
use container::Container;
-use cmp::Eq;
+use cmp::{Eq, TotalEq};
use from_str::FromStr;
use io::Writer;
use iter::{AdditiveIterator, DoubleEndedIterator, Extendable, Rev, Iterator, Map};
}
}
+impl TotalEq for Path {}
+
impl FromStr for Path {
fn from_str(s: &str) -> Option<Path> {
Path::new_opt(s)
use option::{Option, Some, None};
use intrinsics;
-#[cfg(not(test))] use cmp::{Eq, Ord};
+#[cfg(not(test))] use cmp::{Eq, TotalEq, Ord};
/// Return the offset of the first null pointer in `buf`.
#[inline]
fn ne(&self, other: &*T) -> bool { !self.eq(other) }
}
+#[cfg(not(test))]
+impl<T> TotalEq for *T {}
+
#[cfg(not(test))]
impl<T> Eq for *mut T {
#[inline]
fn ne(&self, other: &*mut T) -> bool { !self.eq(other) }
}
+#[cfg(not(test))]
+impl<T> TotalEq for *mut T {}
+
// Equivalence for pointers
#[cfg(not(test))]
impl<T> Equiv<*mut T> for *T {
use cast::transmute;
use cell::Cell;
use clone::Clone;
-use cmp::{Eq, Ord};
+use cmp::{Eq, Ord, TotalEq, TotalOrd, Ordering};
use kinds::marker;
use ops::{Deref, Drop};
use option::{Option, Some, None};
fn ne(&self, other: &Rc<T>) -> bool { **self != **other }
}
+impl<T: TotalEq> TotalEq for Rc<T> {}
+
impl<T: Ord> Ord for Rc<T> {
#[inline(always)]
fn lt(&self, other: &Rc<T>) -> bool { **self < **other }
fn ge(&self, other: &Rc<T>) -> bool { **self >= **other }
}
+impl<T: TotalOrd> TotalOrd for Rc<T> {
+ #[inline]
+ fn cmp(&self, other: &Rc<T>) -> Ordering { (**self).cmp(&**other) }
+}
+
/// Weak reference to a reference-counted box
#[unsafe_no_drop_flag]
pub struct Weak<T> {
#[deriving(Eq)]
pub enum Os { OsWin32, OsMacos, OsLinux, OsAndroid, OsFreebsd, }
-#[deriving(Eq, Hash)]
+#[deriving(Eq, TotalEq, Hash)]
pub enum Abi {
// NB: This ordering MUST match the AbiDatas array below.
// (This is ensured by the test indices_are_correct().)
Archs(u32) // Multiple architectures (bitset)
}
-#[deriving(Clone, Eq, Encodable, Decodable, Hash)]
+#[deriving(Clone, Eq, TotalEq, Encodable, Decodable, Hash)]
pub struct AbiSet {
priv bits: u32 // each bit represents one of the abis below
}
/// Function name (not all functions have names)
pub type FnIdent = Option<Ident>;
-#[deriving(Clone, Eq, Encodable, Decodable, Hash)]
+#[deriving(Clone, Eq, TotalEq, Encodable, Decodable, Hash)]
pub struct Lifetime {
id: NodeId,
span: Span,
// for instance: std::cmp::Eq . It's represented
// as a sequence of identifiers, along with a bunch
// of supporting information.
-#[deriving(Clone, Eq, Encodable, Decodable, Hash)]
+#[deriving(Clone, Eq, TotalEq, Encodable, Decodable, Hash)]
pub struct Path {
span: Span,
/// A `::foo` path, is relative to the crate root rather than current
/// A segment of a path: an identifier, an optional lifetime, and a set of
/// types.
-#[deriving(Clone, Eq, Encodable, Decodable, Hash)]
+#[deriving(Clone, Eq, TotalEq, Encodable, Decodable, Hash)]
pub struct PathSegment {
/// The identifier portion of this path segment.
identifier: Ident,
// typeck::collect::compute_bounds matches these against
// the "special" built-in traits (see middle::lang_items) and
// detects Copy, Send and Share.
-#[deriving(Clone, Eq, Encodable, Decodable, Hash)]
+#[deriving(Clone, Eq, TotalEq, Encodable, Decodable, Hash)]
pub enum TyParamBound {
TraitTyParamBound(TraitRef),
RegionTyParamBound
}
-#[deriving(Clone, Eq, Encodable, Decodable, Hash)]
+#[deriving(Clone, Eq, TotalEq, Encodable, Decodable, Hash)]
pub struct TyParam {
ident: Ident,
id: NodeId,
default: Option<P<Ty>>
}
-#[deriving(Clone, Eq, Encodable, Decodable, Hash)]
+#[deriving(Clone, Eq, TotalEq, Encodable, Decodable, Hash)]
pub struct Generics {
lifetimes: Vec<Lifetime>,
ty_params: OwnedSlice<TyParam>,
}
}
-#[deriving(Clone, Eq, Encodable, Decodable, Hash)]
+#[deriving(Clone, Eq, TotalEq, Encodable, Decodable, Hash)]
pub enum MethodProvenance {
FromTrait(DefId),
FromImpl(DefId),
}
-#[deriving(Clone, Eq, Encodable, Decodable, Hash)]
+#[deriving(Clone, Eq, TotalEq, Encodable, Decodable, Hash)]
pub enum Def {
DefFn(DefId, Purity),
DefStaticMethod(/* method */ DefId, MethodProvenance, Purity),
DefMethod(DefId /* method */, Option<DefId> /* trait */),
}
-#[deriving(Clone, Eq, Hash, Encodable, Decodable, Show)]
+#[deriving(Clone, Eq, TotalEq, Hash, Encodable, Decodable, Show)]
pub enum DefRegion {
DefStaticRegion,
DefEarlyBoundRegion(/* index */ uint, /* lifetime decl */ NodeId),
// used to drive conditional compilation
pub type CrateConfig = Vec<@MetaItem> ;
-#[deriving(Clone, Eq, Encodable, Decodable, Hash)]
+#[deriving(Clone, Eq, TotalEq, Encodable, Decodable, Hash)]
pub struct Crate {
module: Mod,
attrs: Vec<Attribute> ,
pub type MetaItem = Spanned<MetaItem_>;
-#[deriving(Clone, Encodable, Decodable, Hash)]
+#[deriving(Clone, Encodable, Decodable, TotalEq, Hash)]
pub enum MetaItem_ {
MetaWord(InternedString),
MetaList(InternedString, Vec<@MetaItem> ),
}
}
-#[deriving(Clone, Eq, Encodable, Decodable, Hash)]
+#[deriving(Clone, Eq, TotalEq, Encodable, Decodable, Hash)]
pub struct Block {
view_items: Vec<ViewItem> ,
stmts: Vec<@Stmt> ,
span: Span,
}
-#[deriving(Clone, Eq, Encodable, Decodable, Hash)]
+#[deriving(Clone, Eq, TotalEq, Encodable, Decodable, Hash)]
pub struct Pat {
id: NodeId,
node: Pat_,
span: Span,
}
-#[deriving(Clone, Eq, Encodable, Decodable, Hash)]
+#[deriving(Clone, Eq, TotalEq, Encodable, Decodable, Hash)]
pub struct FieldPat {
ident: Ident,
pat: @Pat,
}
-#[deriving(Clone, Eq, Encodable, Decodable, Hash)]
+#[deriving(Clone, Eq, TotalEq, Encodable, Decodable, Hash)]
pub enum BindingMode {
BindByRef(Mutability),
BindByValue(Mutability),
}
-#[deriving(Clone, Eq, Encodable, Decodable, Hash)]
+#[deriving(Clone, Eq, TotalEq, Encodable, Decodable, Hash)]
pub enum Pat_ {
PatWild,
PatWildMulti,
PatVec(Vec<@Pat> , Option<@Pat>, Vec<@Pat> )
}
-#[deriving(Clone, Eq, Encodable, Decodable, Hash, Show)]
+#[deriving(Clone, Eq, TotalEq, Encodable, Decodable, Hash, Show)]
pub enum Mutability {
MutMutable,
MutImmutable,
}
-#[deriving(Clone, Eq, Encodable, Decodable, Hash)]
+#[deriving(Clone, Eq, TotalEq, Encodable, Decodable, Hash)]
pub enum Sigil {
BorrowedSigil,
OwnedSigil,
}
}
-#[deriving(Clone, Eq, Encodable, Decodable, Hash)]
+#[deriving(Clone, Eq, TotalEq, Encodable, Decodable, Hash)]
pub enum ExprVstore {
ExprVstoreUniq, // ~[1,2,3,4]
ExprVstoreSlice, // &[1,2,3,4]
ExprVstoreMutSlice, // &mut [1,2,3,4]
}
-#[deriving(Clone, Eq, Encodable, Decodable, Hash)]
+#[deriving(Clone, Eq, TotalEq, Encodable, Decodable, Hash)]
pub enum BinOp {
BiAdd,
BiSub,
BiGt,
}
-#[deriving(Clone, Eq, Encodable, Decodable, Hash)]
+#[deriving(Clone, Eq, TotalEq, Encodable, Decodable, Hash)]
pub enum UnOp {
UnBox,
UnUniq,
pub type Stmt = Spanned<Stmt_>;
-#[deriving(Clone, Eq, Encodable, Decodable, Hash)]
+#[deriving(Clone, Eq, TotalEq, Encodable, Decodable, Hash)]
pub enum Stmt_ {
// could be an item or a local (let) binding:
StmtDecl(@Decl, NodeId),
// FIXME (pending discussion of #1697, #2178...): local should really be
// a refinement on pat.
/// Local represents a `let` statement, e.g., `let <pat>:<ty> = <expr>;`
-#[deriving(Eq, Encodable, Decodable, Hash)]
+#[deriving(Eq, TotalEq, Encodable, Decodable, Hash)]
pub struct Local {
ty: P<Ty>,
pat: @Pat,
pub type Decl = Spanned<Decl_>;
-#[deriving(Eq, Encodable, Decodable, Hash)]
+#[deriving(Eq, TotalEq, Encodable, Decodable, Hash)]
pub enum Decl_ {
// a local (let) binding:
DeclLocal(@Local),
DeclItem(@Item),
}
-#[deriving(Clone, Eq, Encodable, Decodable, Hash)]
+#[deriving(Clone, Eq, TotalEq, Encodable, Decodable, Hash)]
pub struct Arm {
pats: Vec<@Pat> ,
guard: Option<@Expr>,
body: @Expr,
}
-#[deriving(Clone, Eq, Encodable, Decodable, Hash)]
+#[deriving(Clone, Eq, TotalEq, Encodable, Decodable, Hash)]
pub struct Field {
ident: SpannedIdent,
expr: @Expr,
pub type SpannedIdent = Spanned<Ident>;
-#[deriving(Clone, Eq, Encodable, Decodable, Hash)]
+#[deriving(Clone, Eq, TotalEq, Encodable, Decodable, Hash)]
pub enum BlockCheckMode {
DefaultBlock,
UnsafeBlock(UnsafeSource),
}
-#[deriving(Clone, Eq, Encodable, Decodable, Hash)]
+#[deriving(Clone, Eq, TotalEq, Encodable, Decodable, Hash)]
pub enum UnsafeSource {
CompilerGenerated,
UserProvided,
}
-#[deriving(Clone, Eq, Encodable, Decodable, Hash)]
+#[deriving(Clone, Eq, TotalEq, Encodable, Decodable, Hash)]
pub struct Expr {
id: NodeId,
node: Expr_,
span: Span,
}
-#[deriving(Clone, Eq, Encodable, Decodable, Hash)]
+#[deriving(Clone, Eq, TotalEq, Encodable, Decodable, Hash)]
pub enum Expr_ {
ExprVstore(@Expr, ExprVstore),
// First expr is the place; second expr is the value.
// else knows what to do with them, so you'll probably get a syntax
// error.
//
-#[deriving(Clone, Eq, Encodable, Decodable, Hash)]
+#[deriving(Clone, Eq, TotalEq, Encodable, Decodable, Hash)]
#[doc="For macro invocations; parsing is delegated to the macro"]
pub enum TokenTree {
// a single token
//
pub type Matcher = Spanned<Matcher_>;
-#[deriving(Clone, Eq, Encodable, Decodable, Hash)]
+#[deriving(Clone, Eq, TotalEq, Encodable, Decodable, Hash)]
pub enum Matcher_ {
// match one token
MatchTok(::parse::token::Token),
// is being invoked, and the vector of token-trees contains the source
// of the macro invocation.
// There's only one flavor, now, so this could presumably be simplified.
-#[deriving(Clone, Eq, Encodable, Decodable, Hash)]
+#[deriving(Clone, Eq, TotalEq, Encodable, Decodable, Hash)]
pub enum Mac_ {
MacInvocTT(Path, Vec<TokenTree> , SyntaxContext), // new macro-invocation
}
-#[deriving(Clone, Eq, Encodable, Decodable, Hash)]
+#[deriving(Clone, Eq, TotalEq, Encodable, Decodable, Hash)]
pub enum StrStyle {
CookedStr,
RawStr(uint)
pub type Lit = Spanned<Lit_>;
-#[deriving(Clone, Eq, Encodable, Decodable, Hash)]
+#[deriving(Clone, Eq, TotalEq, Encodable, Decodable, Hash)]
pub enum Lit_ {
LitStr(InternedString, StrStyle),
LitBinary(Rc<Vec<u8> >),
// NB: If you change this, you'll probably want to change the corresponding
// type structure in middle/ty.rs as well.
-#[deriving(Clone, Eq, Encodable, Decodable, Hash)]
+#[deriving(Clone, Eq, TotalEq, Encodable, Decodable, Hash)]
pub struct MutTy {
ty: P<Ty>,
mutbl: Mutability,
}
-#[deriving(Eq, Encodable, Decodable, Hash)]
+#[deriving(Eq, TotalEq, Encodable, Decodable, Hash)]
pub struct TypeField {
ident: Ident,
mt: MutTy,
span: Span,
}
-#[deriving(Clone, Eq, Encodable, Decodable, Hash)]
+#[deriving(Clone, Eq, TotalEq, Encodable, Decodable, Hash)]
pub struct TypeMethod {
ident: Ident,
attrs: Vec<Attribute> ,
// A trait method is either required (meaning it doesn't have an
// implementation, just a signature) or provided (meaning it has a default
// implementation).
-#[deriving(Clone, Eq, Encodable, Decodable, Hash)]
+#[deriving(Clone, Eq, TotalEq, Encodable, Decodable, Hash)]
pub enum TraitMethod {
Required(TypeMethod),
Provided(@Method),
}
-#[deriving(Clone, Eq, Encodable, Decodable, Hash)]
+#[deriving(Clone, Eq, TotalEq, Encodable, Decodable, Hash)]
pub enum IntTy {
TyI,
TyI8,
}
}
-#[deriving(Clone, Eq, Encodable, Decodable, Hash)]
+#[deriving(Clone, Eq, TotalEq, Encodable, Decodable, Hash)]
pub enum UintTy {
TyU,
TyU8,
}
}
-#[deriving(Clone, Eq, Encodable, Decodable, Hash)]
+#[deriving(Clone, Eq, TotalEq, Encodable, Decodable, Hash)]
pub enum FloatTy {
TyF32,
TyF64,
}
// NB Eq method appears below.
-#[deriving(Clone, Eq, Encodable, Decodable, Hash)]
+#[deriving(Clone, Eq, TotalEq, Encodable, Decodable, Hash)]
pub struct Ty {
id: NodeId,
node: Ty_,
}
// Not represented directly in the AST, referred to by name through a ty_path.
-#[deriving(Clone, Eq, Encodable, Decodable, Hash)]
+#[deriving(Clone, Eq, TotalEq, Encodable, Decodable, Hash)]
pub enum PrimTy {
TyInt(IntTy),
TyUint(UintTy),
TyChar
}
-#[deriving(Clone, Eq, Encodable, Decodable, Hash)]
+#[deriving(Clone, Eq, TotalEq, Encodable, Decodable, Hash)]
pub enum Onceness {
Once,
Many
}
}
-#[deriving(Eq, Encodable, Decodable, Hash)]
+#[deriving(Eq, TotalEq, Encodable, Decodable, Hash)]
pub struct ClosureTy {
sigil: Sigil,
region: Option<Lifetime>,
bounds: Option<OwnedSlice<TyParamBound>>,
}
-#[deriving(Eq, Encodable, Decodable, Hash)]
+#[deriving(Eq, TotalEq, Encodable, Decodable, Hash)]
pub struct BareFnTy {
purity: Purity,
abis: AbiSet,
decl: P<FnDecl>
}
-#[deriving(Clone, Eq, Encodable, Decodable, Hash)]
+#[deriving(Clone, Eq, TotalEq, Encodable, Decodable, Hash)]
pub enum Ty_ {
TyNil,
TyBot, /* bottom type */
TyInfer,
}
-#[deriving(Clone, Eq, Encodable, Decodable, Hash)]
+#[deriving(Clone, Eq, TotalEq, Encodable, Decodable, Hash)]
pub enum AsmDialect {
AsmAtt,
AsmIntel
}
-#[deriving(Clone, Eq, Encodable, Decodable, Hash)]
+#[deriving(Clone, Eq, TotalEq, Encodable, Decodable, Hash)]
pub struct InlineAsm {
asm: InternedString,
asm_str_style: StrStyle,
dialect: AsmDialect
}
-#[deriving(Clone, Eq, Encodable, Decodable, Hash)]
+#[deriving(Clone, Eq, TotalEq, Encodable, Decodable, Hash)]
pub struct Arg {
ty: P<Ty>,
pat: @Pat,
}
}
-#[deriving(Clone, Eq, Encodable, Decodable, Hash)]
+#[deriving(Clone, Eq, TotalEq, Encodable, Decodable, Hash)]
pub struct FnDecl {
inputs: Vec<Arg> ,
output: P<Ty>,
variadic: bool
}
-#[deriving(Clone, Eq, Encodable, Decodable, Hash)]
+#[deriving(Clone, Eq, TotalEq, Encodable, Decodable, Hash)]
pub enum Purity {
UnsafeFn, // declared with "unsafe fn"
ImpureFn, // declared with "fn"
}
}
-#[deriving(Clone, Eq, Encodable, Decodable, Hash)]
+#[deriving(Clone, Eq, TotalEq, Encodable, Decodable, Hash)]
pub enum RetStyle {
NoReturn, // functions with return type _|_ that always
// raise an error or exit (i.e. never return to the caller)
Return, // everything else
}
-#[deriving(Clone, Eq, Encodable, Decodable, Hash)]
+#[deriving(Clone, Eq, TotalEq, Encodable, Decodable, Hash)]
pub enum ExplicitSelf_ {
SelfStatic, // no self
SelfValue, // `self`
pub type ExplicitSelf = Spanned<ExplicitSelf_>;
-#[deriving(Eq, Encodable, Decodable, Hash)]
+#[deriving(Eq, TotalEq, Encodable, Decodable, Hash)]
pub struct Method {
ident: Ident,
attrs: Vec<Attribute> ,
vis: Visibility,
}
-#[deriving(Clone, Eq, Encodable, Decodable, Hash)]
+#[deriving(Clone, Eq, TotalEq, Encodable, Decodable, Hash)]
pub struct Mod {
view_items: Vec<ViewItem> ,
items: Vec<@Item> ,
}
-#[deriving(Clone, Eq, Encodable, Decodable, Hash)]
+#[deriving(Clone, Eq, TotalEq, Encodable, Decodable, Hash)]
pub struct ForeignMod {
abis: AbiSet,
view_items: Vec<ViewItem> ,
items: Vec<@ForeignItem> ,
}
-#[deriving(Clone, Eq, Encodable, Decodable, Hash)]
+#[deriving(Clone, Eq, TotalEq, Encodable, Decodable, Hash)]
pub struct VariantArg {
ty: P<Ty>,
id: NodeId,
}
-#[deriving(Clone, Eq, Encodable, Decodable, Hash)]
+#[deriving(Clone, Eq, TotalEq, Encodable, Decodable, Hash)]
pub enum VariantKind {
TupleVariantKind(Vec<VariantArg> ),
StructVariantKind(@StructDef),
}
-#[deriving(Clone, Eq, Encodable, Decodable, Hash)]
+#[deriving(Clone, Eq, TotalEq, Encodable, Decodable, Hash)]
pub struct EnumDef {
variants: Vec<P<Variant>> ,
}
-#[deriving(Clone, Eq, Encodable, Decodable, Hash)]
+#[deriving(Clone, Eq, TotalEq, Encodable, Decodable, Hash)]
pub struct Variant_ {
name: Ident,
attrs: Vec<Attribute> ,
pub type Variant = Spanned<Variant_>;
-#[deriving(Clone, Eq, Encodable, Decodable, Hash)]
+#[deriving(Clone, Eq, TotalEq, Encodable, Decodable, Hash)]
pub struct PathListIdent_ {
name: Ident,
id: NodeId,
pub type ViewPath = Spanned<ViewPath_>;
-#[deriving(Eq, Encodable, Decodable, Hash)]
+#[deriving(Eq, TotalEq, Encodable, Decodable, Hash)]
pub enum ViewPath_ {
// quux = foo::bar::baz
ViewPathList(Path, Vec<PathListIdent> , NodeId)
}
-#[deriving(Clone, Eq, Encodable, Decodable, Hash)]
+#[deriving(Clone, Eq, TotalEq, Encodable, Decodable, Hash)]
pub struct ViewItem {
node: ViewItem_,
attrs: Vec<Attribute> ,
span: Span,
}
-#[deriving(Clone, Eq, Encodable, Decodable, Hash)]
+#[deriving(Clone, Eq, TotalEq, Encodable, Decodable, Hash)]
pub enum ViewItem_ {
// ident: name used to refer to this crate in the code
// optional (InternedString,StrStyle): if present, this is a location
// Distinguishes between Attributes that decorate items and Attributes that
// are contained as statements within items. These two cases need to be
// distinguished for pretty-printing.
-#[deriving(Clone, Eq, Encodable, Decodable, Hash)]
+#[deriving(Clone, Eq, TotalEq, Encodable, Decodable, Hash)]
pub enum AttrStyle {
AttrOuter,
AttrInner,
}
// doc-comments are promoted to attributes that have is_sugared_doc = true
-#[deriving(Clone, Eq, Encodable, Decodable, Hash)]
+#[deriving(Clone, Eq, TotalEq, Encodable, Decodable, Hash)]
pub struct Attribute_ {
style: AttrStyle,
value: @MetaItem,
If this impl is an ItemImpl, the impl_id is redundant (it could be the
same as the impl's node id).
*/
-#[deriving(Clone, Eq, Encodable, Decodable, Hash)]
+#[deriving(Clone, Eq, TotalEq, Encodable, Decodable, Hash)]
pub struct TraitRef {
path: Path,
ref_id: NodeId,
}
-#[deriving(Clone, Eq, Encodable, Decodable, Hash)]
+#[deriving(Clone, Eq, TotalEq, Encodable, Decodable, Hash)]
pub enum Visibility {
Public,
Private,
}
}
-#[deriving(Clone, Eq, Encodable, Decodable, Hash)]
+#[deriving(Clone, Eq, TotalEq, Encodable, Decodable, Hash)]
pub struct StructField_ {
kind: StructFieldKind,
id: NodeId,
pub type StructField = Spanned<StructField_>;
-#[deriving(Clone, Eq, Encodable, Decodable, Hash)]
+#[deriving(Clone, Eq, TotalEq, Encodable, Decodable, Hash)]
pub enum StructFieldKind {
NamedField(Ident, Visibility),
UnnamedField // element of a tuple-like struct
}
-#[deriving(Eq, Encodable, Decodable, Hash)]
+#[deriving(Eq, TotalEq, Encodable, Decodable, Hash)]
pub struct StructDef {
fields: Vec<StructField> , /* fields, not including ctor */
/* ID of the constructor. This is only used for tuple- or enum-like
FIXME (#3300): Should allow items to be anonymous. Right now
we just use dummy names for anon items.
*/
-#[deriving(Clone, Eq, Encodable, Decodable, Hash)]
+#[deriving(Clone, Eq, TotalEq, Encodable, Decodable, Hash)]
pub struct Item {
ident: Ident,
attrs: Vec<Attribute> ,
span: Span,
}
-#[deriving(Clone, Eq, Encodable, Decodable, Hash)]
+#[deriving(Clone, Eq, TotalEq, Encodable, Decodable, Hash)]
pub enum Item_ {
ItemStatic(P<Ty>, Mutability, @Expr),
ItemFn(P<FnDecl>, Purity, AbiSet, Generics, P<Block>),
ItemMac(Mac),
}
-#[deriving(Eq, Encodable, Decodable, Hash)]
+#[deriving(Eq, TotalEq, Encodable, Decodable, Hash)]
pub struct ForeignItem {
ident: Ident,
attrs: Vec<Attribute> ,
vis: Visibility,
}
-#[deriving(Eq, Encodable, Decodable, Hash)]
+#[deriving(Eq, TotalEq, Encodable, Decodable, Hash)]
pub enum ForeignItem_ {
ForeignItemFn(P<FnDecl>, Generics),
ForeignItemStatic(P<Ty>, /* is_mutbl */ bool),
// The data we save and restore about an inlined item or method. This is not
// part of the AST that we parse from a file, but it becomes part of the tree
// that we trans.
-#[deriving(Eq, Encodable, Decodable, Hash)]
+#[deriving(Eq, TotalEq, Encodable, Decodable, Hash)]
pub enum InlinedItem {
IIItem(@Item),
IIMethod(DefId /* impl id */, bool /* is provided */, @Method),
*/
use std::cell::RefCell;
-use std::cmp;
use std::rc::Rc;
use serialize::{Encodable, Decodable, Encoder, Decoder};
/// A byte offset. Keep this small (currently 32-bits), as AST contains
/// a lot of them.
-#[deriving(Clone, Eq, Hash, Ord, Show)]
+#[deriving(Clone, Eq, TotalEq, Hash, Ord, Show)]
pub struct BytePos(u32);
/// A character offset. Because of multibyte utf8 characters, a byte offset
pub static DUMMY_SP: Span = Span { lo: BytePos(0), hi: BytePos(0), expn_info: None };
-#[deriving(Clone, Eq, Encodable, Decodable, Hash)]
+#[deriving(Clone, Eq, TotalEq, Encodable, Decodable, Hash)]
pub struct Spanned<T> {
node: T,
span: Span,
}
-impl cmp::Eq for Span {
+impl Eq for Span {
fn eq(&self, other: &Span) -> bool {
return (*self).lo == (*other).lo && (*self).hi == (*other).hi;
}
fn ne(&self, other: &Span) -> bool { !(*self).eq(other) }
}
+impl TotalEq for Span {}
+
impl<S:Encoder> Encodable<S> for Span {
/* Note #1972 -- spans are encoded but not decoded */
fn encode(&self, s: &mut S) {
}
}
+impl<T: TotalEq> TotalEq for OwnedSlice<T> {}
+
impl<T> Container for OwnedSlice<T> {
fn len(&self) -> uint { self.len }
}
use parse::token;
/// The specific types of unsupported syntax
-#[deriving(Eq, Hash)]
+#[deriving(Eq, TotalEq, Hash)]
pub enum ObsoleteSyntax {
ObsoleteSwap,
ObsoleteUnsafeBlock,
use std::path::BytesContainer;
#[allow(non_camel_case_types)]
-#[deriving(Clone, Encodable, Decodable, Eq, Hash, Show)]
+#[deriving(Clone, Encodable, Decodable, Eq, TotalEq, Hash, Show)]
pub enum BinOp {
PLUS,
MINUS,
}
#[allow(non_camel_case_types)]
-#[deriving(Clone, Encodable, Decodable, Eq, Hash, Show)]
+#[deriving(Clone, Encodable, Decodable, Eq, TotalEq, Hash, Show)]
pub enum Token {
/* Expression-operator symbols. */
EQ,
EOF,
}
-#[deriving(Clone, Encodable, Decodable, Eq, Hash)]
+#[deriving(Clone, Encodable, Decodable, Eq, TotalEq, Hash)]
/// For interpolation during macro expansion.
pub enum Nonterminal {
NtItem(@ast::Item),
}
// when traits can extend traits, we should extend index<Name,T> to get []
-impl<T: Eq + Hash + Clone + 'static> Interner<T> {
+impl<T: TotalEq + Hash + Clone + 'static> Interner<T> {
pub fn new() -> Interner<T> {
Interner {
map: RefCell::new(HashMap::new()),
/// Returns a HashMap with the number of occurrences of every element in the
/// sequence that the iterator exposes.
-pub fn freq_count<T: Iterator<U>, U: Eq+Hash>(mut iter: T) -> hashmap::HashMap<U, uint> {
+pub fn freq_count<T: Iterator<U>, U: TotalEq+Hash>(mut iter: T) -> hashmap::HashMap<U, uint> {
let mut map: hashmap::HashMap<U,uint> = hashmap::HashMap::new();
for elem in iter {
map.insert_or_update_with(elem, 1, |_, count| *count += 1);
use collections::HashSet;
-#[deriving(Eq, Hash)]
+#[deriving(Eq, TotalEq, Hash)]
struct XYZ {
x: int,
y: int,
}
}
+impl<'tcx> TotalEq for TypeStructure<'tcx> {}
+
struct TypeContext<'tcx, 'ast> {
ty_arena: &'tcx Arena,
types: Vec<Type<'tcx>> ,
}
}
-#[deriving(Eq, Hash)]
+#[deriving(Eq, TotalEq, Hash)]
struct NodeId {
id: uint
}