Skip to content

Commit 5bec5ae

Browse files
committed
Put derives on a single line where possible.
1 parent b142ed2 commit 5bec5ae

File tree

3 files changed

+13
-26
lines changed

3 files changed

+13
-26
lines changed

compiler/rustc_hir/src/def.rs

+5-10
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,7 @@ use std::array::IntoIter;
1313
use std::fmt::Debug;
1414

1515
/// Encodes if a `DefKind::Ctor` is the constructor of an enum variant or a struct.
16-
#[derive(Clone, Copy, PartialEq, Eq, Encodable, Decodable, Hash, Debug)]
17-
#[derive(HashStable_Generic)]
16+
#[derive(Clone, Copy, PartialEq, Eq, Encodable, Decodable, Hash, Debug, HashStable_Generic)]
1817
pub enum CtorOf {
1918
/// This `DefKind::Ctor` is a synthesized constructor of a tuple or unit struct.
2019
Struct,
@@ -23,8 +22,7 @@ pub enum CtorOf {
2322
}
2423

2524
/// What kind of constructor something is.
26-
#[derive(Clone, Copy, PartialEq, Eq, Encodable, Decodable, Hash, Debug)]
27-
#[derive(HashStable_Generic)]
25+
#[derive(Clone, Copy, PartialEq, Eq, Encodable, Decodable, Hash, Debug, HashStable_Generic)]
2826
pub enum CtorKind {
2927
/// Constructor function automatically created by a tuple struct/variant.
3028
Fn,
@@ -33,8 +31,7 @@ pub enum CtorKind {
3331
}
3432

3533
/// An attribute that is not a macro; e.g., `#[inline]` or `#[rustfmt::skip]`.
36-
#[derive(Clone, Copy, PartialEq, Eq, Encodable, Decodable, Hash, Debug)]
37-
#[derive(HashStable_Generic)]
34+
#[derive(Clone, Copy, PartialEq, Eq, Encodable, Decodable, Hash, Debug, HashStable_Generic)]
3835
pub enum NonMacroAttrKind {
3936
/// Single-segment attribute defined by the language (`#[inline]`)
4037
Builtin(Symbol),
@@ -48,8 +45,7 @@ pub enum NonMacroAttrKind {
4845
}
4946

5047
/// What kind of definition something is; e.g., `mod` vs `struct`.
51-
#[derive(Clone, Copy, PartialEq, Eq, Encodable, Decodable, Hash, Debug)]
52-
#[derive(HashStable_Generic)]
48+
#[derive(Clone, Copy, PartialEq, Eq, Encodable, Decodable, Hash, Debug, HashStable_Generic)]
5349
pub enum DefKind {
5450
// Type namespace
5551
Mod,
@@ -299,8 +295,7 @@ impl DefKind {
299295
/// - the call to `str_to_string` will resolve to [`Res::Def`], with the [`DefId`]
300296
/// pointing to the definition of `str_to_string` in the current crate.
301297
//
302-
#[derive(Clone, Copy, PartialEq, Eq, Encodable, Decodable, Hash, Debug)]
303-
#[derive(HashStable_Generic)]
298+
#[derive(Clone, Copy, PartialEq, Eq, Encodable, Decodable, Hash, Debug, HashStable_Generic)]
304299
pub enum Res<Id = hir::HirId> {
305300
/// Definition having a unique ID (`DefId`), corresponds to something defined in user code.
306301
///

compiler/rustc_hir/src/hir.rs

+6-12
Original file line numberDiff line numberDiff line change
@@ -1516,8 +1516,7 @@ impl<'hir> Body<'hir> {
15161516
}
15171517

15181518
/// The type of source expression that caused this coroutine to be created.
1519-
#[derive(Clone, PartialEq, Eq, Debug, Copy, Hash)]
1520-
#[derive(HashStable_Generic, Encodable, Decodable)]
1519+
#[derive(Clone, PartialEq, Eq, Debug, Copy, Hash, HashStable_Generic, Encodable, Decodable)]
15211520
pub enum CoroutineKind {
15221521
/// An explicit `async` block or the body of an async function.
15231522
Async(CoroutineSource),
@@ -1558,8 +1557,7 @@ impl fmt::Display for CoroutineKind {
15581557
///
15591558
/// This helps error messages but is also used to drive coercions in
15601559
/// type-checking (see #60424).
1561-
#[derive(Clone, PartialEq, Eq, Hash, Debug, Copy)]
1562-
#[derive(HashStable_Generic, Encodable, Decodable)]
1560+
#[derive(Clone, PartialEq, Eq, Hash, Debug, Copy, HashStable_Generic, Encodable, Decodable)]
15631561
pub enum CoroutineSource {
15641562
/// An explicit `async`/`gen` block written by the user.
15651563
Block,
@@ -2153,8 +2151,7 @@ pub enum LocalSource {
21532151
}
21542152

21552153
/// Hints at the original code for a `match _ { .. }`.
2156-
#[derive(Copy, Clone, PartialEq, Eq, Hash, Debug)]
2157-
#[derive(HashStable_Generic, Encodable, Decodable)]
2154+
#[derive(Copy, Clone, PartialEq, Eq, Hash, Debug, HashStable_Generic, Encodable, Decodable)]
21582155
pub enum MatchSource {
21592156
/// A `match _ { .. }`.
21602157
Normal,
@@ -2579,8 +2576,7 @@ impl<'hir> Ty<'hir> {
25792576
}
25802577

25812578
/// Not represented directly in the AST; referred to by name through a `ty_path`.
2582-
#[derive(Copy, Clone, PartialEq, Eq, Encodable, Decodable, Hash, Debug)]
2583-
#[derive(HashStable_Generic)]
2579+
#[derive(Copy, Clone, PartialEq, Eq, Encodable, Decodable, Hash, Debug, HashStable_Generic)]
25842580
pub enum PrimTy {
25852581
Int(IntTy),
25862582
Uint(UintTy),
@@ -2860,8 +2856,7 @@ impl ImplicitSelfKind {
28602856
}
28612857
}
28622858

2863-
#[derive(Copy, Clone, PartialEq, Eq, Encodable, Decodable, Debug)]
2864-
#[derive(HashStable_Generic)]
2859+
#[derive(Copy, Clone, PartialEq, Eq, Encodable, Decodable, Debug, HashStable_Generic)]
28652860
pub enum IsAsync {
28662861
Async(Span),
28672862
NotAsync,
@@ -3280,8 +3275,7 @@ impl fmt::Display for Unsafety {
32803275
}
32813276
}
32823277

3283-
#[derive(Copy, Clone, PartialEq, Eq, Debug)]
3284-
#[derive(Encodable, Decodable, HashStable_Generic)]
3278+
#[derive(Copy, Clone, PartialEq, Eq, Debug, Encodable, Decodable, HashStable_Generic)]
32853279
pub enum Constness {
32863280
Const,
32873281
NotConst,

compiler/rustc_hir/src/hir_id.rs

+2-4
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,7 @@ use rustc_data_structures::stable_hasher::{HashStable, StableHasher, StableOrd,
33
use rustc_span::{def_id::DefPathHash, HashStableContext};
44
use std::fmt::{self, Debug};
55

6-
#[derive(Copy, Clone, PartialEq, Eq, Hash)]
7-
#[derive(Encodable, Decodable)]
6+
#[derive(Copy, Clone, PartialEq, Eq, Hash, Encodable, Decodable)]
87
pub struct OwnerId {
98
pub def_id: LocalDefId,
109
}
@@ -73,8 +72,7 @@ impl<CTX: HashStableContext> ToStableHashKey<CTX> for OwnerId {
7372
/// the `local_id` part of the `HirId` changing, which is a very useful property in
7473
/// incremental compilation where we have to persist things through changes to
7574
/// the code base.
76-
#[derive(Copy, Clone, PartialEq, Eq, Hash)]
77-
#[derive(Encodable, Decodable, HashStable_Generic)]
75+
#[derive(Copy, Clone, PartialEq, Eq, Hash, Encodable, Decodable, HashStable_Generic)]
7876
#[rustc_pass_by_value]
7977
pub struct HirId {
8078
pub owner: OwnerId,

0 commit comments

Comments
 (0)