Skip to content

Commit ac6daed

Browse files
committed
Remove many unnecessary trait derivations.
1 parent c3b3a86 commit ac6daed

File tree

49 files changed

+89
-103
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+89
-103
lines changed

Diff for: src/librustc/dep_graph/graph.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ impl DepNodeIndex {
3535
pub const INVALID: DepNodeIndex = DepNodeIndex::MAX;
3636
}
3737

38-
#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash)]
38+
#[derive(PartialEq)]
3939
pub enum DepNodeColor {
4040
Red,
4141
Green(DepNodeIndex)

Diff for: src/librustc/hir/map/definitions.rs

-1
Original file line numberDiff line numberDiff line change
@@ -599,7 +599,6 @@ macro_rules! define_global_metadata_kind {
599599
(pub enum GlobalMetaDataKind {
600600
$($variant:ident),*
601601
}) => (
602-
#[derive(Clone, Copy, Debug, Hash, RustcEncodable, RustcDecodable)]
603602
pub enum GlobalMetaDataKind {
604603
$($variant),*
605604
}

Diff for: src/librustc/hir/mod.rs

+4-6
Original file line numberDiff line numberDiff line change
@@ -1077,7 +1077,7 @@ impl Mutability {
10771077
}
10781078
}
10791079

1080-
#[derive(Copy, Clone, PartialEq, RustcEncodable, RustcDecodable, Debug, Hash, HashStable)]
1080+
#[derive(Copy, Clone, PartialEq, RustcEncodable, RustcDecodable, Debug, HashStable)]
10811081
pub enum BinOpKind {
10821082
/// The `+` operator (addition).
10831083
Add,
@@ -1211,7 +1211,7 @@ impl Into<ast::BinOpKind> for BinOpKind {
12111211

12121212
pub type BinOp = Spanned<BinOpKind>;
12131213

1214-
#[derive(Copy, Clone, PartialEq, RustcEncodable, RustcDecodable, Debug, Hash, HashStable)]
1214+
#[derive(Copy, Clone, PartialEq, RustcEncodable, RustcDecodable, Debug, HashStable)]
12151215
pub enum UnOp {
12161216
/// The `*` operator (deferencing).
12171217
UnDeref,
@@ -1388,8 +1388,7 @@ impl Body {
13881388
}
13891389

13901390
/// The type of source expression that caused this generator to be created.
1391-
#[derive(Clone, PartialEq, Eq, PartialOrd, Ord, HashStable,
1392-
RustcEncodable, RustcDecodable, Hash, Debug, Copy)]
1391+
#[derive(Clone, PartialEq, Eq, HashStable, RustcEncodable, RustcDecodable, Debug, Copy)]
13931392
pub enum GeneratorKind {
13941393
/// An explicit `async` block or the body of an async function.
13951394
Async(AsyncGeneratorKind),
@@ -1412,8 +1411,7 @@ impl fmt::Display for GeneratorKind {
14121411
///
14131412
/// This helps error messages but is also used to drive coercions in
14141413
/// type-checking (see #60424).
1415-
#[derive(Clone, PartialEq, Eq, PartialOrd, Ord, HashStable,
1416-
RustcEncodable, RustcDecodable, Hash, Debug, Copy)]
1414+
#[derive(Clone, PartialEq, Eq, HashStable, RustcEncodable, RustcDecodable, Debug, Copy)]
14171415
pub enum AsyncGeneratorKind {
14181416
/// An explicit `async` block written by the user.
14191417
Block,

Diff for: src/librustc/hir/ptr.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ use rustc_serialize::{Encodable, Decodable, Encoder, Decoder};
1111

1212
use rustc_data_structures::stable_hasher::{StableHasher, HashStable};
1313
/// An owned smart pointer.
14-
#[derive(Hash, PartialEq, Eq)]
14+
#[derive(PartialEq, Eq)]
1515
pub struct P<T: ?Sized> {
1616
ptr: Box<T>
1717
}

Diff for: src/librustc/infer/canonical/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ pub struct CanonicalVarValues<'tcx> {
7373
/// various parts of it with canonical variables. This struct stores
7474
/// those replaced bits to remember for when we process the query
7575
/// result.
76-
#[derive(Clone, Debug, PartialEq, Eq, Hash, RustcDecodable, RustcEncodable)]
76+
#[derive(Clone, Debug)]
7777
pub struct OriginalQueryValues<'tcx> {
7878
/// Map from the universes that appear in the query to the
7979
/// universes in the caller context. For the time being, we only

Diff for: src/librustc/infer/combine.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ pub struct CombineFields<'infcx, 'tcx> {
5353
pub obligations: PredicateObligations<'tcx>,
5454
}
5555

56-
#[derive(Copy, Clone, Eq, PartialEq, Hash, Debug)]
56+
#[derive(Copy, Clone, Debug)]
5757
pub enum RelationDir {
5858
SubtypeOf, SupertypeOf, EqTo
5959
}

Diff for: src/librustc/infer/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -407,7 +407,7 @@ pub enum RegionVariableOrigin {
407407
NLL(NLLRegionVariableOrigin),
408408
}
409409

410-
#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash)]
410+
#[derive(Copy, Clone, Debug)]
411411
pub enum NLLRegionVariableOrigin {
412412
/// During NLL region processing, we create variables for free
413413
/// regions that we encounter in the function signature and

Diff for: src/librustc/infer/nll_relate/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ use crate::mir::interpret::ConstValue;
3232
use rustc_data_structures::fx::FxHashMap;
3333
use std::fmt::Debug;
3434

35-
#[derive(Copy, Clone, PartialEq, Eq, Hash, Debug)]
35+
#[derive(PartialEq)]
3636
pub enum NormalizationStrategy {
3737
Lazy,
3838
Eager,

Diff for: src/librustc/infer/region_constraints/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ pub struct RegionConstraintData<'tcx> {
116116
}
117117

118118
/// Represents a constraint that influences the inference process.
119-
#[derive(Clone, Copy, PartialEq, Eq, Hash, Debug, PartialOrd, Ord)]
119+
#[derive(Clone, Copy, PartialEq, Eq, Debug, PartialOrd, Ord)]
120120
pub enum Constraint<'tcx> {
121121
/// A region variable is a subregion of another.
122122
VarSubVar(RegionVid, RegionVid),

Diff for: src/librustc/middle/cstore.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ pub struct NativeLibrary {
117117
pub wasm_import_module: Option<Symbol>,
118118
}
119119

120-
#[derive(Clone, Hash, RustcEncodable, RustcDecodable, HashStable)]
120+
#[derive(Clone, RustcEncodable, RustcDecodable, HashStable)]
121121
pub struct ForeignModule {
122122
pub foreign_items: Vec<DefId>,
123123
pub def_id: DefId,

Diff for: src/librustc/middle/mem_categorization.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ pub struct Upvar {
102102
}
103103

104104
// different kinds of pointers:
105-
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
105+
#[derive(Clone, Copy, Debug, PartialEq)]
106106
pub enum PointerKind<'tcx> {
107107
/// `Box<T>`
108108
Unique,
@@ -116,7 +116,7 @@ pub enum PointerKind<'tcx> {
116116

117117
// We use the term "interior" to mean "something reachable from the
118118
// base without a pointer dereference", e.g., a field
119-
#[derive(Clone, Copy, PartialEq, Eq, Hash)]
119+
#[derive(Clone, PartialEq)]
120120
pub enum InteriorKind {
121121
InteriorField(FieldIndex),
122122
InteriorElement(InteriorOffsetKind),
@@ -139,13 +139,13 @@ impl Hash for FieldIndex {
139139
}
140140
}
141141

142-
#[derive(Clone, Copy, PartialEq, Eq, Hash, Debug)]
142+
#[derive(Clone, PartialEq)]
143143
pub enum InteriorOffsetKind {
144144
Index, // e.g., `array_expr[index_expr]`
145145
Pattern, // e.g., `fn foo([_, a, _, _]: [A; 4]) { ... }`
146146
}
147147

148-
#[derive(Clone, Copy, PartialEq, Eq, Hash, Debug)]
148+
#[derive(Clone, Copy, PartialEq, Debug)]
149149
pub enum MutabilityCategory {
150150
McImmutable, // Immutable.
151151
McDeclared, // Directly declared as mutable.

Diff for: src/librustc/middle/stability.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ use crate::util::nodemap::{FxHashSet, FxHashMap};
2525
use std::mem::replace;
2626
use std::cmp::Ordering;
2727

28-
#[derive(RustcEncodable, RustcDecodable, PartialEq, PartialOrd, Clone, Copy, Debug, Eq, Hash)]
28+
#[derive(PartialEq, Clone, Copy, Debug)]
2929
pub enum StabilityLevel {
3030
Unstable,
3131
Stable,

Diff for: src/librustc/mir/interpret/value.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use crate::hir::def_id::DefId;
99
use super::{InterpResult, Pointer, PointerArithmetic, Allocation, AllocId, sign_extend, truncate};
1010

1111
/// Represents the result of a raw const operation, pre-validation.
12-
#[derive(Copy, Clone, Debug, Eq, PartialEq, RustcEncodable, RustcDecodable, Hash, HashStable)]
12+
#[derive(Clone, HashStable)]
1313
pub struct RawConst<'tcx> {
1414
// the value lives here, at offset 0, and that allocation definitely is a `AllocKind::Memory`
1515
// (so you can use `AllocMap::unwrap_memory`).
@@ -487,7 +487,7 @@ impl<Tag> From<Pointer<Tag>> for Scalar<Tag> {
487487
}
488488
}
489489

490-
#[derive(Clone, Copy, Eq, PartialEq, Ord, PartialOrd, Hash, RustcEncodable, RustcDecodable)]
490+
#[derive(Clone, Copy, Eq, PartialEq, RustcEncodable, RustcDecodable)]
491491
pub enum ScalarMaybeUndef<Tag = (), Id = AllocId> {
492492
Scalar(Scalar<Tag, Id>),
493493
Undef,

Diff for: src/librustc/mir/mod.rs

+10-10
Original file line numberDiff line numberDiff line change
@@ -468,7 +468,7 @@ impl<T: Decodable> rustc_serialize::UseSpecializedDecodable for ClearCrossCrate<
468468
/// Grouped information about the source code origin of a MIR entity.
469469
/// Intended to be inspected by diagnostics and debuginfo.
470470
/// Most passes can work with it as a whole, within a single function.
471-
#[derive(Copy, Clone, Debug, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, HashStable)]
471+
#[derive(Copy, Clone, Debug, PartialEq, RustcEncodable, RustcDecodable, HashStable)]
472472
pub struct SourceInfo {
473473
/// The source span for the AST pertaining to this MIR entity.
474474
pub span: Span,
@@ -608,7 +608,7 @@ pub enum LocalKind {
608608
ReturnPointer,
609609
}
610610

611-
#[derive(Clone, PartialEq, Eq, Hash, Debug, RustcEncodable, RustcDecodable)]
611+
#[derive(Clone, Debug, RustcEncodable, RustcDecodable)]
612612
pub struct VarBindingForm<'tcx> {
613613
/// Is variable bound via `x`, `mut x`, `ref x`, or `ref mut x`?
614614
pub binding_mode: ty::BindingMode,
@@ -630,7 +630,7 @@ pub struct VarBindingForm<'tcx> {
630630
pub pat_span: Span,
631631
}
632632

633-
#[derive(Clone, PartialEq, Eq, Hash, Debug, RustcEncodable, RustcDecodable)]
633+
#[derive(Clone, Debug, RustcEncodable, RustcDecodable)]
634634
pub enum BindingForm<'tcx> {
635635
/// This is a binding for a non-`self` binding, or a `self` that has an explicit type.
636636
Var(VarBindingForm<'tcx>),
@@ -641,7 +641,7 @@ pub enum BindingForm<'tcx> {
641641
}
642642

643643
/// Represents what type of implicit self a function has, if any.
644-
#[derive(Clone, Copy, PartialEq, Eq, Hash, Debug, RustcEncodable, RustcDecodable)]
644+
#[derive(Clone, Copy, PartialEq, Debug, RustcEncodable, RustcDecodable)]
645645
pub enum ImplicitSelfKind {
646646
/// Represents a `fn x(self);`.
647647
Imm,
@@ -2392,7 +2392,7 @@ impl<'tcx> Debug for Rvalue<'tcx> {
23922392
/// this does not necessarily mean that they are "==" in Rust -- in
23932393
/// particular one must be wary of `NaN`!
23942394
2395-
#[derive(Copy, Clone, PartialEq, Eq, Hash, RustcEncodable, RustcDecodable, HashStable)]
2395+
#[derive(Clone, PartialEq, RustcEncodable, RustcDecodable, HashStable)]
23962396
pub struct Constant<'tcx> {
23972397
pub span: Span,
23982398

@@ -2438,7 +2438,7 @@ pub struct Constant<'tcx> {
24382438
/// The first will lead to the constraint `w: &'1 str` (for some
24392439
/// inferred region `'1`). The second will lead to the constraint `w:
24402440
/// &'static str`.
2441-
#[derive(Clone, Debug, PartialEq, Eq, Hash, RustcEncodable, RustcDecodable, HashStable)]
2441+
#[derive(Clone, Debug, RustcEncodable, RustcDecodable, HashStable)]
24422442
pub struct UserTypeProjections {
24432443
pub(crate) contents: Vec<(UserTypeProjection, Span)>,
24442444
}
@@ -2515,7 +2515,7 @@ impl<'tcx> UserTypeProjections {
25152515
/// * `let (x, _): T = ...` -- here, the `projs` vector would contain
25162516
/// `field[0]` (aka `.0`), indicating that the type of `s` is
25172517
/// determined by finding the type of the `.0` field from `T`.
2518-
#[derive(Clone, Debug, PartialEq, Eq, Hash, RustcEncodable, RustcDecodable, HashStable)]
2518+
#[derive(Clone, Debug, RustcEncodable, RustcDecodable, HashStable)]
25192519
pub struct UserTypeProjection {
25202520
pub base: UserTypeAnnotationIndex,
25212521
pub projs: Vec<ProjectionKind>,
@@ -2724,7 +2724,7 @@ impl Location {
27242724
}
27252725
}
27262726

2727-
#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash, RustcEncodable, RustcDecodable, HashStable)]
2727+
#[derive(Copy, Clone, PartialEq, RustcEncodable, RustcDecodable, HashStable)]
27282728
pub enum UnsafetyViolationKind {
27292729
General,
27302730
/// Permitted both in `const fn`s and regular `fn`s.
@@ -2733,15 +2733,15 @@ pub enum UnsafetyViolationKind {
27332733
BorrowPacked(hir::HirId),
27342734
}
27352735

2736-
#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash, RustcEncodable, RustcDecodable, HashStable)]
2736+
#[derive(Copy, Clone, PartialEq, RustcEncodable, RustcDecodable, HashStable)]
27372737
pub struct UnsafetyViolation {
27382738
pub source_info: SourceInfo,
27392739
pub description: InternedString,
27402740
pub details: InternedString,
27412741
pub kind: UnsafetyViolationKind,
27422742
}
27432743

2744-
#[derive(Clone, Debug, PartialEq, Eq, Hash, RustcEncodable, RustcDecodable, HashStable)]
2744+
#[derive(Clone, RustcEncodable, RustcDecodable, HashStable)]
27452745
pub struct UnsafetyCheckResult {
27462746
/// Violations that are propagated *upwards* from this function.
27472747
pub violations: Lrc<[UnsafetyViolation]>,

Diff for: src/librustc/mir/mono.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ use std::fmt;
1515
use std::hash::Hash;
1616

1717
/// Describes how a monomorphization will be instantiated in object files.
18-
#[derive(PartialEq, Eq, Clone, Copy, Debug, Hash)]
18+
#[derive(PartialEq)]
1919
pub enum InstantiationMode {
2020
/// There will be exactly one instance of the given MonoItem. It will have
2121
/// external linkage so that it can be linked to from other codegen units.
@@ -251,7 +251,7 @@ pub struct CodegenUnit<'tcx> {
251251
size_estimate: Option<usize>,
252252
}
253253

254-
#[derive(Copy, Clone, PartialEq, Eq, Hash, Debug, RustcEncodable, RustcDecodable)]
254+
#[derive(Copy, Clone, PartialEq, Debug, RustcEncodable, RustcDecodable)]
255255
pub enum Linkage {
256256
External,
257257
AvailableExternally,
@@ -280,7 +280,7 @@ impl_stable_hash_for!(enum self::Linkage {
280280
Common
281281
});
282282

283-
#[derive(Copy, Clone, PartialEq, Eq, Hash, Debug)]
283+
#[derive(Copy, Clone, PartialEq, Debug)]
284284
pub enum Visibility {
285285
Default,
286286
Hidden,

Diff for: src/librustc/mir/visit.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -947,7 +947,7 @@ impl<'tcx> MirVisitable<'tcx> for Option<Terminator<'tcx>> {
947947

948948
/// Extra information passed to `visit_ty` and friends to give context
949949
/// about where the type etc appears.
950-
#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash)]
950+
#[derive(Debug)]
951951
pub enum TyContext {
952952
LocalDecl {
953953
/// The index of the local variable we are visiting.

Diff for: src/librustc/session/config.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ impl_stable_hash_via_hash!(OptLevel);
6767

6868
/// This is what the `LtoCli` values get mapped to after resolving defaults and
6969
/// and taking other command line options into account.
70-
#[derive(Clone, Copy, PartialEq, Hash, Debug)]
70+
#[derive(Clone, PartialEq)]
7171
pub enum Lto {
7272
/// Don't do any LTO whatsoever
7373
No,
@@ -301,10 +301,10 @@ impl OutputTypes {
301301
/// Use tree-based collections to cheaply get a deterministic `Hash` implementation.
302302
/// *Do not* switch `BTreeMap` or `BTreeSet` out for an unsorted container type! That
303303
/// would break dependency tracking for command-line arguments.
304-
#[derive(Clone, Hash)]
304+
#[derive(Clone)]
305305
pub struct Externs(BTreeMap<String, ExternEntry>);
306306

307-
#[derive(Clone, Hash, Eq, PartialEq, Ord, PartialOrd, Debug, Default)]
307+
#[derive(Clone, Debug, Default)]
308308
pub struct ExternEntry {
309309
pub locations: BTreeSet<Option<String>>,
310310
pub is_private_dep: bool
@@ -464,7 +464,7 @@ pub enum PrintRequest {
464464
NativeStaticLibs,
465465
}
466466

467-
#[derive(Copy, Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
467+
#[derive(Copy, Clone)]
468468
pub enum BorrowckMode {
469469
Mir,
470470
Migrate,

Diff for: src/librustc/session/search_paths.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
use std::path::{Path, PathBuf};
2-
use rustc_macros::HashStable;
32
use crate::session::{early_error, config};
43
use crate::session::filesearch::make_target_lib_path;
54

@@ -10,7 +9,7 @@ pub struct SearchPath {
109
pub files: Vec<PathBuf>,
1110
}
1211

13-
#[derive(Eq, PartialEq, Clone, Copy, Debug, PartialOrd, Ord, Hash, HashStable)]
12+
#[derive(PartialEq, Clone, Copy, Debug, HashStable)]
1413
pub enum PathKind {
1514
Native,
1615
Crate,

Diff for: src/librustc/traits/query/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ pub type CanonicalTypeOpProvePredicateGoal<'tcx> =
4040
pub type CanonicalTypeOpNormalizeGoal<'tcx, T> =
4141
Canonical<'tcx, ty::ParamEnvAnd<'tcx, type_op::normalize::Normalize<T>>>;
4242

43-
#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash)]
43+
#[derive(Clone, Debug)]
4444
pub struct NoSolution;
4545

4646
pub type Fallible<T> = Result<T, NoSolution>;

Diff for: src/librustc/traits/query/type_op/implied_outlives_bounds.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use crate::traits::query::outlives_bounds::OutlivesBound;
33
use crate::traits::query::Fallible;
44
use crate::ty::{ParamEnvAnd, Ty, TyCtxt};
55

6-
#[derive(Copy, Clone, Debug, Hash, PartialEq, Eq)]
6+
#[derive(Clone, Debug)]
77
pub struct ImpliedOutlivesBounds<'tcx> {
88
pub ty: Ty<'tcx>,
99
}

Diff for: src/librustc/ty/binding.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use crate::hir::BindingAnnotation::*;
22
use crate::hir::BindingAnnotation;
33
use crate::hir::Mutability;
44

5-
#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug, Copy)]
5+
#[derive(Clone, PartialEq, RustcEncodable, RustcDecodable, Debug, Copy)]
66
pub enum BindingMode {
77
BindByReference(Mutability),
88
BindByValue(Mutability),

Diff for: src/librustc/ty/context.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -827,7 +827,7 @@ rustc_index::newtype_index! {
827827
pub type CanonicalUserTypeAnnotations<'tcx> =
828828
IndexVec<UserTypeAnnotationIndex, CanonicalUserTypeAnnotation<'tcx>>;
829829

830-
#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash, RustcEncodable, RustcDecodable, HashStable)]
830+
#[derive(Clone, Debug, RustcEncodable, RustcDecodable, HashStable)]
831831
pub struct CanonicalUserTypeAnnotation<'tcx> {
832832
pub user_ty: CanonicalUserType<'tcx>,
833833
pub span: Span,
@@ -899,7 +899,7 @@ impl CanonicalUserType<'tcx> {
899899
/// A user-given type annotation attached to a constant. These arise
900900
/// from constants that are named via paths, like `Foo::<A>::new` and
901901
/// so forth.
902-
#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash, RustcEncodable, RustcDecodable, HashStable)]
902+
#[derive(Copy, Clone, Debug, PartialEq, RustcEncodable, RustcDecodable, HashStable)]
903903
pub enum UserType<'tcx> {
904904
Ty(Ty<'tcx>),
905905

0 commit comments

Comments
 (0)