Put derives on a single line where possible.

This commit is contained in:
Nicholas Nethercote 2023-11-20 16:17:02 +11:00
parent b142ed296c
commit 5bec5ae545
3 changed files with 13 additions and 26 deletions

View File

@ -13,8 +13,7 @@ use std::array::IntoIter;
use std::fmt::Debug; use std::fmt::Debug;
/// Encodes if a `DefKind::Ctor` is the constructor of an enum variant or a struct. /// Encodes if a `DefKind::Ctor` is the constructor of an enum variant or a struct.
#[derive(Clone, Copy, PartialEq, Eq, Encodable, Decodable, Hash, Debug)] #[derive(Clone, Copy, PartialEq, Eq, Encodable, Decodable, Hash, Debug, HashStable_Generic)]
#[derive(HashStable_Generic)]
pub enum CtorOf { pub enum CtorOf {
/// This `DefKind::Ctor` is a synthesized constructor of a tuple or unit struct. /// This `DefKind::Ctor` is a synthesized constructor of a tuple or unit struct.
Struct, Struct,
@ -23,8 +22,7 @@ pub enum CtorOf {
} }
/// What kind of constructor something is. /// What kind of constructor something is.
#[derive(Clone, Copy, PartialEq, Eq, Encodable, Decodable, Hash, Debug)] #[derive(Clone, Copy, PartialEq, Eq, Encodable, Decodable, Hash, Debug, HashStable_Generic)]
#[derive(HashStable_Generic)]
pub enum CtorKind { pub enum CtorKind {
/// Constructor function automatically created by a tuple struct/variant. /// Constructor function automatically created by a tuple struct/variant.
Fn, Fn,
@ -33,8 +31,7 @@ pub enum CtorKind {
} }
/// An attribute that is not a macro; e.g., `#[inline]` or `#[rustfmt::skip]`. /// An attribute that is not a macro; e.g., `#[inline]` or `#[rustfmt::skip]`.
#[derive(Clone, Copy, PartialEq, Eq, Encodable, Decodable, Hash, Debug)] #[derive(Clone, Copy, PartialEq, Eq, Encodable, Decodable, Hash, Debug, HashStable_Generic)]
#[derive(HashStable_Generic)]
pub enum NonMacroAttrKind { pub enum NonMacroAttrKind {
/// Single-segment attribute defined by the language (`#[inline]`) /// Single-segment attribute defined by the language (`#[inline]`)
Builtin(Symbol), Builtin(Symbol),
@ -48,8 +45,7 @@ pub enum NonMacroAttrKind {
} }
/// What kind of definition something is; e.g., `mod` vs `struct`. /// What kind of definition something is; e.g., `mod` vs `struct`.
#[derive(Clone, Copy, PartialEq, Eq, Encodable, Decodable, Hash, Debug)] #[derive(Clone, Copy, PartialEq, Eq, Encodable, Decodable, Hash, Debug, HashStable_Generic)]
#[derive(HashStable_Generic)]
pub enum DefKind { pub enum DefKind {
// Type namespace // Type namespace
Mod, Mod,
@ -299,8 +295,7 @@ impl DefKind {
/// - the call to `str_to_string` will resolve to [`Res::Def`], with the [`DefId`] /// - the call to `str_to_string` will resolve to [`Res::Def`], with the [`DefId`]
/// pointing to the definition of `str_to_string` in the current crate. /// pointing to the definition of `str_to_string` in the current crate.
// //
#[derive(Clone, Copy, PartialEq, Eq, Encodable, Decodable, Hash, Debug)] #[derive(Clone, Copy, PartialEq, Eq, Encodable, Decodable, Hash, Debug, HashStable_Generic)]
#[derive(HashStable_Generic)]
pub enum Res<Id = hir::HirId> { pub enum Res<Id = hir::HirId> {
/// Definition having a unique ID (`DefId`), corresponds to something defined in user code. /// Definition having a unique ID (`DefId`), corresponds to something defined in user code.
/// ///

View File

@ -1516,8 +1516,7 @@ impl<'hir> Body<'hir> {
} }
/// The type of source expression that caused this coroutine to be created. /// The type of source expression that caused this coroutine to be created.
#[derive(Clone, PartialEq, Eq, Debug, Copy, Hash)] #[derive(Clone, PartialEq, Eq, Debug, Copy, Hash, HashStable_Generic, Encodable, Decodable)]
#[derive(HashStable_Generic, Encodable, Decodable)]
pub enum CoroutineKind { pub enum CoroutineKind {
/// An explicit `async` block or the body of an async function. /// An explicit `async` block or the body of an async function.
Async(CoroutineSource), Async(CoroutineSource),
@ -1558,8 +1557,7 @@ impl fmt::Display for CoroutineKind {
/// ///
/// This helps error messages but is also used to drive coercions in /// This helps error messages but is also used to drive coercions in
/// type-checking (see #60424). /// type-checking (see #60424).
#[derive(Clone, PartialEq, Eq, Hash, Debug, Copy)] #[derive(Clone, PartialEq, Eq, Hash, Debug, Copy, HashStable_Generic, Encodable, Decodable)]
#[derive(HashStable_Generic, Encodable, Decodable)]
pub enum CoroutineSource { pub enum CoroutineSource {
/// An explicit `async`/`gen` block written by the user. /// An explicit `async`/`gen` block written by the user.
Block, Block,
@ -2153,8 +2151,7 @@ pub enum LocalSource {
} }
/// Hints at the original code for a `match _ { .. }`. /// Hints at the original code for a `match _ { .. }`.
#[derive(Copy, Clone, PartialEq, Eq, Hash, Debug)] #[derive(Copy, Clone, PartialEq, Eq, Hash, Debug, HashStable_Generic, Encodable, Decodable)]
#[derive(HashStable_Generic, Encodable, Decodable)]
pub enum MatchSource { pub enum MatchSource {
/// A `match _ { .. }`. /// A `match _ { .. }`.
Normal, Normal,
@ -2579,8 +2576,7 @@ impl<'hir> Ty<'hir> {
} }
/// Not represented directly in the AST; referred to by name through a `ty_path`. /// Not represented directly in the AST; referred to by name through a `ty_path`.
#[derive(Copy, Clone, PartialEq, Eq, Encodable, Decodable, Hash, Debug)] #[derive(Copy, Clone, PartialEq, Eq, Encodable, Decodable, Hash, Debug, HashStable_Generic)]
#[derive(HashStable_Generic)]
pub enum PrimTy { pub enum PrimTy {
Int(IntTy), Int(IntTy),
Uint(UintTy), Uint(UintTy),
@ -2860,8 +2856,7 @@ impl ImplicitSelfKind {
} }
} }
#[derive(Copy, Clone, PartialEq, Eq, Encodable, Decodable, Debug)] #[derive(Copy, Clone, PartialEq, Eq, Encodable, Decodable, Debug, HashStable_Generic)]
#[derive(HashStable_Generic)]
pub enum IsAsync { pub enum IsAsync {
Async(Span), Async(Span),
NotAsync, NotAsync,
@ -3280,8 +3275,7 @@ impl fmt::Display for Unsafety {
} }
} }
#[derive(Copy, Clone, PartialEq, Eq, Debug)] #[derive(Copy, Clone, PartialEq, Eq, Debug, Encodable, Decodable, HashStable_Generic)]
#[derive(Encodable, Decodable, HashStable_Generic)]
pub enum Constness { pub enum Constness {
Const, Const,
NotConst, NotConst,

View File

@ -3,8 +3,7 @@ use rustc_data_structures::stable_hasher::{HashStable, StableHasher, StableOrd,
use rustc_span::{def_id::DefPathHash, HashStableContext}; use rustc_span::{def_id::DefPathHash, HashStableContext};
use std::fmt::{self, Debug}; use std::fmt::{self, Debug};
#[derive(Copy, Clone, PartialEq, Eq, Hash)] #[derive(Copy, Clone, PartialEq, Eq, Hash, Encodable, Decodable)]
#[derive(Encodable, Decodable)]
pub struct OwnerId { pub struct OwnerId {
pub def_id: LocalDefId, pub def_id: LocalDefId,
} }
@ -73,8 +72,7 @@ impl<CTX: HashStableContext> ToStableHashKey<CTX> for OwnerId {
/// the `local_id` part of the `HirId` changing, which is a very useful property in /// the `local_id` part of the `HirId` changing, which is a very useful property in
/// incremental compilation where we have to persist things through changes to /// incremental compilation where we have to persist things through changes to
/// the code base. /// the code base.
#[derive(Copy, Clone, PartialEq, Eq, Hash)] #[derive(Copy, Clone, PartialEq, Eq, Hash, Encodable, Decodable, HashStable_Generic)]
#[derive(Encodable, Decodable, HashStable_Generic)]
#[rustc_pass_by_value] #[rustc_pass_by_value]
pub struct HirId { pub struct HirId {
pub owner: OwnerId, pub owner: OwnerId,