diff options
| author | bors <bors@rust-lang.org> | 2014-02-25 06:41:36 -0800 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2014-02-25 06:41:36 -0800 |
| commit | 25d68366b73c24bd9b7d277b38da087420d63f9b (patch) | |
| tree | 20978b14ec9da96f64fbd7659d090c04e99d300d /src/libsyntax | |
| parent | d222f03f42fe855d2fadc87010453bcfc2a669e1 (diff) | |
| parent | 6335a76b6eb473ea399b16fe9309db142d6b68ce (diff) | |
| download | rust-25d68366b73c24bd9b7d277b38da087420d63f9b.tar.gz rust-25d68366b73c24bd9b7d277b38da087420d63f9b.zip | |
auto merge of #12522 : erickt/rust/hash, r=alexcrichton
This patch series does a couple things: * replaces manual `Hash` implementations with `#[deriving(Hash)]` * adds `Hash` back to `std::prelude` * minor cleanup of whitespace and variable names.
Diffstat (limited to 'src/libsyntax')
| -rw-r--r-- | src/libsyntax/abi.rs | 9 | ||||
| -rw-r--r-- | src/libsyntax/ast.rs | 38 | ||||
| -rw-r--r-- | src/libsyntax/codemap.rs | 2 | ||||
| -rw-r--r-- | src/libsyntax/util/interner.rs | 6 |
4 files changed, 23 insertions, 32 deletions
diff --git a/src/libsyntax/abi.rs b/src/libsyntax/abi.rs index 9349e5c8e98..c01f3721fad 100644 --- a/src/libsyntax/abi.rs +++ b/src/libsyntax/abi.rs @@ -8,14 +8,13 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -use std::hash::{Hash, sip}; use std::fmt; use std::fmt::Show; #[deriving(Eq)] pub enum Os { OsWin32, OsMacos, OsLinux, OsAndroid, OsFreebsd, } -#[deriving(Eq)] +#[deriving(Eq, Hash)] pub enum Abi { // NB: This ordering MUST match the AbiDatas array below. // (This is ensured by the test indices_are_correct().) @@ -267,12 +266,6 @@ impl AbiSet { } } -impl Hash for Abi { - fn hash(&self, s: &mut sip::SipState) { - self.index().hash(s) - } -} - impl fmt::Show for Abi { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { self.data().name.fmt(f) diff --git a/src/libsyntax/ast.rs b/src/libsyntax/ast.rs index 0415748097c..c095cec1e7d 100644 --- a/src/libsyntax/ast.rs +++ b/src/libsyntax/ast.rs @@ -107,7 +107,7 @@ pub struct SCTable { pub static EMPTY_CTXT : SyntaxContext = 0; pub static ILLEGAL_CTXT : SyntaxContext = 1; -#[deriving(Eq, Encodable, Decodable,Hash)] +#[deriving(Eq, Encodable, Decodable, Hash)] pub enum SyntaxContext_ { EmptyCtxt, Mark (Mrk,SyntaxContext), @@ -332,7 +332,7 @@ impl Eq for MetaItem_ { } } -#[deriving(Clone, Eq, Encodable, Decodable,Hash)] +#[deriving(Clone, Eq, Encodable, Decodable, Hash)] pub struct Block { view_items: ~[ViewItem], stmts: ~[@Stmt], @@ -467,7 +467,7 @@ pub enum Stmt_ { // 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, Encodable, Decodable, Hash)] pub struct Local { ty: P<Ty>, pat: @Pat, @@ -478,7 +478,7 @@ pub struct Local { pub type Decl = Spanned<Decl_>; -#[deriving(Eq, Encodable, Decodable,Hash)] +#[deriving(Eq, Encodable, Decodable, Hash)] pub enum Decl_ { // a local (let) binding: DeclLocal(@Local), @@ -514,7 +514,7 @@ pub enum UnsafeSource { UserProvided, } -#[deriving(Clone, Eq, Encodable, Decodable,Hash)] +#[deriving(Clone, Eq, Encodable, Decodable, Hash)] pub struct Expr { id: NodeId, node: Expr_, @@ -732,7 +732,7 @@ pub struct MutTy { mutbl: Mutability, } -#[deriving(Eq, Encodable, Decodable,Hash)] +#[deriving(Eq, Encodable, Decodable, Hash)] pub struct TypeField { ident: Ident, mt: MutTy, @@ -836,7 +836,7 @@ impl fmt::Show for Onceness { } } -#[deriving(Eq, Encodable, Decodable,Hash)] +#[deriving(Eq, Encodable, Decodable, Hash)] pub struct ClosureTy { sigil: Sigil, region: Option<Lifetime>, @@ -967,7 +967,7 @@ pub enum ExplicitSelf_ { pub type ExplicitSelf = Spanned<ExplicitSelf_>; -#[deriving(Eq, Encodable, Decodable,Hash)] +#[deriving(Eq, Encodable, Decodable, Hash)] pub struct Method { ident: Ident, attrs: ~[Attribute], @@ -987,7 +987,7 @@ pub struct Mod { items: ~[@Item], } -#[deriving(Clone, Eq, Encodable, Decodable,Hash)] +#[deriving(Clone, Eq, Encodable, Decodable, Hash)] pub struct ForeignMod { abis: AbiSet, view_items: ~[ViewItem], @@ -1074,14 +1074,14 @@ pub type Attribute = Spanned<Attribute_>; // 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, 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, Encodable, Decodable, Hash)] pub struct Attribute_ { style: AttrStyle, value: @MetaItem, @@ -1095,13 +1095,13 @@ pub struct Attribute_ { 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, Encodable, Decodable, Hash)] pub struct TraitRef { path: Path, ref_id: NodeId, } -#[deriving(Clone, Eq, Encodable, Decodable,Hash)] +#[deriving(Clone, Eq, Encodable, Decodable, Hash)] pub enum Visibility { Public, Private, @@ -1117,7 +1117,7 @@ impl Visibility { } } -#[deriving(Clone, Eq, Encodable, Decodable,Hash)] +#[deriving(Clone, Eq, Encodable, Decodable, Hash)] pub struct StructField_ { kind: StructFieldKind, id: NodeId, @@ -1127,13 +1127,13 @@ pub struct StructField_ { pub type StructField = Spanned<StructField_>; -#[deriving(Clone, Eq, Encodable, Decodable,Hash)] +#[deriving(Clone, Eq, Encodable, Decodable, Hash)] pub enum StructFieldKind { NamedField(Ident, Visibility), UnnamedField // element of a tuple-like struct } -#[deriving(Eq, Encodable, Decodable,Hash)] +#[deriving(Eq, Encodable, Decodable, Hash)] pub struct StructDef { fields: ~[StructField], /* fields, not including ctor */ /* ID of the constructor. This is only used for tuple- or enum-like @@ -1173,7 +1173,7 @@ pub enum Item_ { ItemMac(Mac), } -#[deriving(Eq, Encodable, Decodable,Hash)] +#[deriving(Eq, Encodable, Decodable, Hash)] pub struct ForeignItem { ident: Ident, attrs: ~[Attribute], @@ -1183,7 +1183,7 @@ pub struct ForeignItem { vis: Visibility, } -#[deriving(Eq, Encodable, Decodable,Hash)] +#[deriving(Eq, Encodable, Decodable, Hash)] pub enum ForeignItem_ { ForeignItemFn(P<FnDecl>, Generics), ForeignItemStatic(P<Ty>, /* is_mutbl */ bool), @@ -1192,7 +1192,7 @@ pub enum ForeignItem_ { // 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, Encodable, Decodable, Hash)] pub enum InlinedItem { IIItem(@Item), IIMethod(DefId /* impl id */, bool /* is provided */, @Method), diff --git a/src/libsyntax/codemap.rs b/src/libsyntax/codemap.rs index a67d1b933a8..79ccc8df0f3 100644 --- a/src/libsyntax/codemap.rs +++ b/src/libsyntax/codemap.rs @@ -38,7 +38,7 @@ pub struct BytePos(u32); /// A character offset. Because of multibyte utf8 characters, a byte offset /// is not equivalent to a character offset. The CodeMap will convert BytePos /// values to CharPos values as necessary. -#[deriving(Eq,Hash, Ord)] +#[deriving(Eq, Hash, Ord)] pub struct CharPos(uint); // FIXME: Lots of boilerplate in these impls, but so far my attempts to fix diff --git a/src/libsyntax/util/interner.rs b/src/libsyntax/util/interner.rs index fa21924bbb9..4b5a05f4cb8 100644 --- a/src/libsyntax/util/interner.rs +++ b/src/libsyntax/util/interner.rs @@ -75,8 +75,7 @@ impl<T:Eq + Hash + Freeze + Clone + 'static> Interner<T> { vect.get().len() } - pub fn find_equiv<Q:Hash + Equiv<T>>(&self, val: &Q) - -> Option<Name> { + pub fn find_equiv<Q:Hash + Equiv<T>>(&self, val: &Q) -> Option<Name> { let map = self.map.borrow(); match map.get().find_equiv(val) { Some(v) => Some(*v), @@ -207,8 +206,7 @@ impl StrInterner { vect.get().len() } - pub fn find_equiv<Q:Hash + Equiv<RcStr>>(&self, val: &Q) - -> Option<Name> { + pub fn find_equiv<Q:Hash + Equiv<RcStr>>(&self, val: &Q) -> Option<Name> { let map = self.map.borrow(); match map.get().find_equiv(val) { Some(v) => Some(*v), |
