From 5987fe8f75c443d4f73603fa5a3af8ab41ee1b01 Mon Sep 17 00:00:00 2001 From: Vadim Petrochenkov Date: Wed, 27 Jun 2018 00:57:27 +0300 Subject: [PATCH] Remove most of `Hash` impls from AST and HIR structures --- src/librustc/hir/mod.rs | 171 ++++++++++++++-------------- src/librustc/middle/cstore.rs | 2 +- src/librustdoc/clean/mod.rs | 17 ++- src/libsyntax/ast.rs | 198 ++++++++++++++++----------------- src/libsyntax/ext/tt/quoted.rs | 6 +- src/libsyntax/parse/token.rs | 4 +- src/libsyntax/tokenstream.rs | 20 +--- 7 files changed, 208 insertions(+), 210 deletions(-) diff --git a/src/librustc/hir/mod.rs b/src/librustc/hir/mod.rs index e98e9b1760351..09fc824750d72 100644 --- a/src/librustc/hir/mod.rs +++ b/src/librustc/hir/mod.rs @@ -172,7 +172,7 @@ pub const DUMMY_HIR_ID: HirId = HirId { pub const DUMMY_ITEM_LOCAL_ID: ItemLocalId = ItemLocalId(!0); -#[derive(Clone, RustcEncodable, RustcDecodable, Hash, Copy)] +#[derive(Clone, RustcEncodable, RustcDecodable, Copy)] pub struct Label { pub ident: Ident, } @@ -183,7 +183,7 @@ impl fmt::Debug for Label { } } -#[derive(Clone, RustcEncodable, RustcDecodable, Hash, Copy)] +#[derive(Clone, RustcEncodable, RustcDecodable, Copy)] pub struct Lifetime { pub id: NodeId, pub span: Span, @@ -312,7 +312,7 @@ impl Lifetime { /// A "Path" is essentially Rust's notion of a name; for instance: /// `std::cmp::PartialEq`. It's represented as a sequence of identifiers, /// along with a bunch of supporting information. -#[derive(Clone, RustcEncodable, RustcDecodable, Hash)] +#[derive(Clone, RustcEncodable, RustcDecodable)] pub struct Path { pub span: Span, /// The definition that the path resolved to. @@ -341,7 +341,7 @@ impl fmt::Display for Path { /// A segment of a path: an identifier, an optional lifetime, and a set of /// types. -#[derive(Clone, RustcEncodable, RustcDecodable, Hash, Debug)] +#[derive(Clone, RustcEncodable, RustcDecodable, Debug)] pub struct PathSegment { /// The identifier portion of this path segment. pub ident: Ident, @@ -396,7 +396,7 @@ impl PathSegment { } } -#[derive(Clone, RustcEncodable, RustcDecodable, Hash, Debug)] +#[derive(Clone, RustcEncodable, RustcDecodable, Debug)] pub enum GenericArg { Lifetime(Lifetime), Type(Ty), @@ -411,7 +411,7 @@ impl GenericArg { } } -#[derive(Clone, RustcEncodable, RustcDecodable, Hash, Debug)] +#[derive(Clone, RustcEncodable, RustcDecodable, Debug)] pub struct GenericArgs { /// The generic arguments for this path segment. pub args: HirVec, @@ -467,7 +467,7 @@ pub enum TraitBoundModifier { /// typeck::collect::compute_bounds matches these against /// the "special" built-in traits (see middle::lang_items) and /// detects Copy, Send and Sync. -#[derive(Clone, RustcEncodable, RustcDecodable, Hash, Debug)] +#[derive(Clone, RustcEncodable, RustcDecodable, Debug)] pub enum GenericBound { Trait(PolyTraitRef, TraitBoundModifier), Outlives(Lifetime), @@ -484,7 +484,7 @@ impl GenericBound { pub type GenericBounds = HirVec; -#[derive(Clone, RustcEncodable, RustcDecodable, Hash, Debug)] +#[derive(Clone, RustcEncodable, RustcDecodable, Debug)] pub enum GenericParamKind { /// A lifetime definition, eg `'a: 'b + 'c + 'd`. Lifetime { @@ -499,7 +499,7 @@ pub enum GenericParamKind { } } -#[derive(Clone, RustcEncodable, RustcDecodable, Hash, Debug)] +#[derive(Clone, RustcEncodable, RustcDecodable, Debug)] pub struct GenericParam { pub id: NodeId, pub name: ParamName, @@ -518,7 +518,7 @@ pub struct GenericParamCount { /// Represents lifetimes and type parameters attached to a declaration /// of a function, enum, trait, etc. -#[derive(Clone, RustcEncodable, RustcDecodable, Hash, Debug)] +#[derive(Clone, RustcEncodable, RustcDecodable, Debug)] pub struct Generics { pub params: HirVec, pub where_clause: WhereClause, @@ -574,7 +574,7 @@ pub enum SyntheticTyParamKind { } /// A `where` clause in a definition -#[derive(Clone, RustcEncodable, RustcDecodable, Hash, Debug)] +#[derive(Clone, RustcEncodable, RustcDecodable, Debug)] pub struct WhereClause { pub id: NodeId, pub predicates: HirVec, @@ -593,7 +593,7 @@ impl WhereClause { } /// A single predicate in a `where` clause -#[derive(Clone, RustcEncodable, RustcDecodable, Hash, Debug)] +#[derive(Clone, RustcEncodable, RustcDecodable, Debug)] pub enum WherePredicate { /// A type binding, eg `for<'c> Foo: Send+Clone+'c` BoundPredicate(WhereBoundPredicate), @@ -614,7 +614,7 @@ impl WherePredicate { } /// A type bound, eg `for<'c> Foo: Send+Clone+'c` -#[derive(Clone, RustcEncodable, RustcDecodable, Hash, Debug)] +#[derive(Clone, RustcEncodable, RustcDecodable, Debug)] pub struct WhereBoundPredicate { pub span: Span, /// Any generics from a `for` binding @@ -626,7 +626,7 @@ pub struct WhereBoundPredicate { } /// A lifetime predicate, e.g. `'a: 'b+'c` -#[derive(Clone, RustcEncodable, RustcDecodable, Hash, Debug)] +#[derive(Clone, RustcEncodable, RustcDecodable, Debug)] pub struct WhereRegionPredicate { pub span: Span, pub lifetime: Lifetime, @@ -634,7 +634,7 @@ pub struct WhereRegionPredicate { } /// An equality predicate (unsupported), e.g. `T=int` -#[derive(Clone, RustcEncodable, RustcDecodable, Hash, Debug)] +#[derive(Clone, RustcEncodable, RustcDecodable, Debug)] pub struct WhereEqPredicate { pub id: NodeId, pub span: Span, @@ -748,7 +748,7 @@ impl Crate { /// A macro definition, in this crate or imported from another. /// /// Not parsed directly, but created on macro import or `macro_rules!` expansion. -#[derive(Clone, RustcEncodable, RustcDecodable, Hash, Debug)] +#[derive(Clone, RustcEncodable, RustcDecodable, Debug)] pub struct MacroDef { pub name: Name, pub vis: Visibility, @@ -759,7 +759,7 @@ pub struct MacroDef { pub legacy: bool, } -#[derive(Clone, RustcEncodable, RustcDecodable, Hash, Debug)] +#[derive(Clone, RustcEncodable, RustcDecodable, Debug)] pub struct Block { /// Statements in a block pub stmts: HirVec, @@ -782,7 +782,7 @@ pub struct Block { pub recovered: bool, } -#[derive(Clone, RustcEncodable, RustcDecodable, Hash)] +#[derive(Clone, RustcEncodable, RustcDecodable)] pub struct Pat { pub id: NodeId, pub hir_id: HirId, @@ -844,7 +844,7 @@ impl Pat { /// Patterns like the fields of Foo `{ x, ref y, ref mut z }` /// are treated the same as` x: x, y: ref y, z: ref mut z`, /// except is_shorthand is true -#[derive(Clone, RustcEncodable, RustcDecodable, Hash, Debug)] +#[derive(Clone, RustcEncodable, RustcDecodable, Debug)] pub struct FieldPat { pub id: NodeId, /// The identifier for the field @@ -857,7 +857,7 @@ pub struct FieldPat { /// Explicit binding annotations given in the HIR for a binding. Note /// that this is not the final binding *mode* that we infer after type /// inference. -#[derive(Clone, PartialEq, RustcEncodable, RustcDecodable, Hash, Debug, Copy)] +#[derive(Clone, PartialEq, RustcEncodable, RustcDecodable, Debug, Copy)] pub enum BindingAnnotation { /// No binding annotation given: this means that the final binding mode /// will depend on whether we have skipped through a `&` reference @@ -878,13 +878,13 @@ pub enum BindingAnnotation { RefMut, } -#[derive(Copy, Clone, PartialEq, RustcEncodable, RustcDecodable, Hash, Debug)] +#[derive(Copy, Clone, PartialEq, RustcEncodable, RustcDecodable, Debug)] pub enum RangeEnd { Included, Excluded, } -#[derive(Clone, RustcEncodable, RustcDecodable, Hash, Debug)] +#[derive(Clone, RustcEncodable, RustcDecodable, Debug)] pub enum PatKind { /// Represents a wildcard pattern (`_`) Wild, @@ -940,7 +940,7 @@ impl Mutability { } } -#[derive(Clone, PartialEq, RustcEncodable, RustcDecodable, Hash, Debug, Copy)] +#[derive(Clone, PartialEq, RustcEncodable, RustcDecodable, Debug, Copy)] pub enum BinOp_ { /// The `+` operator (addition) BiAdd, @@ -1069,7 +1069,7 @@ impl Into for BinOp_ { pub type BinOp = Spanned; -#[derive(Clone, PartialEq, RustcEncodable, RustcDecodable, Hash, Debug, Copy)] +#[derive(Clone, PartialEq, RustcEncodable, RustcDecodable, Debug, Copy)] pub enum UnOp { /// The `*` operator for dereferencing UnDeref, @@ -1111,7 +1111,7 @@ impl fmt::Debug for Stmt_ { } } -#[derive(Clone, RustcEncodable, RustcDecodable, Hash)] +#[derive(Clone, RustcEncodable, RustcDecodable)] pub enum Stmt_ { /// Could be an item or a local (let) binding: StmtDecl(P, NodeId), @@ -1142,7 +1142,7 @@ impl Stmt_ { } /// Local represents a `let` statement, e.g., `let : = ;` -#[derive(Clone, RustcEncodable, RustcDecodable, Hash, Debug)] +#[derive(Clone, RustcEncodable, RustcDecodable, Debug)] pub struct Local { pub pat: P, pub ty: Option>, @@ -1157,7 +1157,7 @@ pub struct Local { pub type Decl = Spanned; -#[derive(Clone, RustcEncodable, RustcDecodable, Hash, Debug)] +#[derive(Clone, RustcEncodable, RustcDecodable, Debug)] pub enum Decl_ { /// A local (let) binding: DeclLocal(P), @@ -1182,7 +1182,7 @@ impl Decl_ { } /// represents one arm of a 'match' -#[derive(Clone, RustcEncodable, RustcDecodable, Hash, Debug)] +#[derive(Clone, RustcEncodable, RustcDecodable, Debug)] pub struct Arm { pub attrs: HirVec, pub pats: HirVec>, @@ -1190,7 +1190,7 @@ pub struct Arm { pub body: P, } -#[derive(Clone, RustcEncodable, RustcDecodable, Hash, Debug)] +#[derive(Clone, RustcEncodable, RustcDecodable, Debug)] pub struct Field { pub id: NodeId, pub ident: Ident, @@ -1199,7 +1199,7 @@ pub struct Field { pub is_shorthand: bool, } -#[derive(Clone, PartialEq, RustcEncodable, RustcDecodable, Hash, Debug, Copy)] +#[derive(Clone, PartialEq, RustcEncodable, RustcDecodable, Debug, Copy)] pub enum BlockCheckMode { DefaultBlock, UnsafeBlock(UnsafeSource), @@ -1207,7 +1207,7 @@ pub enum BlockCheckMode { PopUnsafeBlock(UnsafeSource), } -#[derive(Clone, PartialEq, RustcEncodable, RustcDecodable, Hash, Debug, Copy)] +#[derive(Clone, PartialEq, RustcEncodable, RustcDecodable, Debug, Copy)] pub enum UnsafeSource { CompilerGenerated, UserProvided, @@ -1239,7 +1239,7 @@ pub struct BodyId { /// /// All bodies have an **owner**, which can be accessed via the HIR /// map using `body_owner_def_id()`. -#[derive(Clone, RustcEncodable, RustcDecodable, Hash, Debug)] +#[derive(Clone, RustcEncodable, RustcDecodable, Debug)] pub struct Body { pub arguments: HirVec, pub value: Expr, @@ -1271,7 +1271,7 @@ pub enum BodyOwnerKind { /// These are usually found nested inside types (e.g. array lengths) /// or expressions (e.g. repeat counts), and also used to define /// explicit discriminant values for enum variants. -#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)] +#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Debug)] pub struct AnonConst { pub id: NodeId, pub hir_id: HirId, @@ -1279,7 +1279,7 @@ pub struct AnonConst { } /// An expression -#[derive(Clone, RustcEncodable, RustcDecodable, Hash)] +#[derive(Clone, RustcEncodable, RustcDecodable)] pub struct Expr { pub id: NodeId, pub span: Span, @@ -1330,7 +1330,7 @@ impl fmt::Debug for Expr { } } -#[derive(Clone, RustcEncodable, RustcDecodable, Hash, Debug)] +#[derive(Clone, RustcEncodable, RustcDecodable, Debug)] pub enum Expr_ { /// A `box x` expression. ExprBox(P), @@ -1432,7 +1432,7 @@ pub enum Expr_ { } /// Optionally `Self`-qualified value/type path or associated extension. -#[derive(Clone, RustcEncodable, RustcDecodable, Hash, Debug)] +#[derive(Clone, RustcEncodable, RustcDecodable, Debug)] pub enum QPath { /// Path to a definition, optionally "fully-qualified" with a `Self` /// type, if the path points to an associated item in a trait. @@ -1452,7 +1452,7 @@ pub enum QPath { } /// Hints at the original code for a let statement -#[derive(Clone, RustcEncodable, RustcDecodable, Hash, Debug, Copy)] +#[derive(Clone, RustcEncodable, RustcDecodable, Debug, Copy)] pub enum LocalSource { /// A `match _ { .. }` Normal, @@ -1479,7 +1479,7 @@ pub enum MatchSource { } /// The loop type that yielded an ExprLoop -#[derive(Clone, PartialEq, RustcEncodable, RustcDecodable, Hash, Debug, Copy)] +#[derive(Clone, PartialEq, RustcEncodable, RustcDecodable, Debug, Copy)] pub enum LoopSource { /// A `loop { .. }` loop Loop, @@ -1489,7 +1489,7 @@ pub enum LoopSource { ForLoop, } -#[derive(Clone, RustcEncodable, RustcDecodable, Hash, Debug, Copy)] +#[derive(Clone, RustcEncodable, RustcDecodable, Debug, Copy)] pub enum LoopIdError { OutsideLoopScope, UnlabeledCfInWhileCondition, @@ -1507,6 +1507,7 @@ impl fmt::Display for LoopIdError { } } +#[derive(Clone, RustcEncodable, RustcDecodable, Debug, Copy)] pub struct Destination { // This is `Some(_)` iff there is an explicit user-specified `label pub label: Option