diff --git a/compiler/rustc_abi/src/callconv/reg.rs b/compiler/rustc_abi/src/callconv/reg.rs index 66d4dca00726f..d857c6796e524 100644 --- a/compiler/rustc_abi/src/callconv/reg.rs +++ b/compiler/rustc_abi/src/callconv/reg.rs @@ -1,9 +1,9 @@ #[cfg(feature = "nightly")] -use rustc_macros::HashStable_Generic; +use rustc_macros::HashStable; use crate::{Align, HasDataLayout, Size}; -#[cfg_attr(feature = "nightly", derive(HashStable_Generic))] +#[cfg_attr(feature = "nightly", derive(HashStable))] #[derive(Copy, Clone, PartialEq, Eq, Hash, Debug)] pub enum RegKind { Integer, @@ -11,7 +11,7 @@ pub enum RegKind { Vector, } -#[cfg_attr(feature = "nightly", derive(HashStable_Generic))] +#[cfg_attr(feature = "nightly", derive(HashStable))] #[derive(Copy, Clone, PartialEq, Eq, Hash, Debug)] pub struct Reg { pub kind: RegKind, diff --git a/compiler/rustc_abi/src/canon_abi.rs b/compiler/rustc_abi/src/canon_abi.rs index fd45f0ea0e9ec..fc81a5911edd4 100644 --- a/compiler/rustc_abi/src/canon_abi.rs +++ b/compiler/rustc_abi/src/canon_abi.rs @@ -1,7 +1,7 @@ use std::fmt; #[cfg(feature = "nightly")] -use rustc_macros::HashStable_Generic; +use rustc_macros::HashStable; use crate::ExternAbi; @@ -18,7 +18,7 @@ use crate::ExternAbi; /// rather than picking the "actual" ABI. #[derive(Copy, Clone, Debug)] #[derive(PartialOrd, Ord, PartialEq, Eq, Hash)] -#[cfg_attr(feature = "nightly", derive(HashStable_Generic))] +#[cfg_attr(feature = "nightly", derive(HashStable))] pub enum CanonAbi { // NOTE: the use of nested variants for some ABIs is for many targets they don't matter, // and this pushes the complexity of their reasoning to target-specific code, @@ -111,7 +111,7 @@ impl fmt::Display for CanonAbi { /// These only affect callee codegen. making their categorization as distinct ABIs a bit peculiar. #[derive(Copy, Clone, Debug)] #[derive(PartialOrd, Ord, PartialEq, Eq, Hash)] -#[cfg_attr(feature = "nightly", derive(HashStable_Generic))] +#[cfg_attr(feature = "nightly", derive(HashStable))] pub enum InterruptKind { Avr, AvrNonBlocking, @@ -126,7 +126,7 @@ pub enum InterruptKind { /// One of SysV64 or Win64 may alias the C ABI, and arguably Win64 is cross-platform now? #[derive(Clone, Copy, Debug)] #[derive(PartialOrd, Ord, PartialEq, Eq, Hash)] -#[cfg_attr(feature = "nightly", derive(HashStable_Generic))] +#[cfg_attr(feature = "nightly", derive(HashStable))] pub enum X86Call { /// "fastcall" has both GNU and Windows variants Fastcall, @@ -141,7 +141,7 @@ pub enum X86Call { /// ABIs defined for 32-bit Arm #[derive(Copy, Clone, Debug)] #[derive(PartialOrd, Ord, PartialEq, Eq, Hash)] -#[cfg_attr(feature = "nightly", derive(HashStable_Generic))] +#[cfg_attr(feature = "nightly", derive(HashStable))] pub enum ArmCall { Aapcs, CCmseNonSecureCall, diff --git a/compiler/rustc_abi/src/extern_abi.rs b/compiler/rustc_abi/src/extern_abi.rs index 9173245d8aa4e..2b03589d7314d 100644 --- a/compiler/rustc_abi/src/extern_abi.rs +++ b/compiler/rustc_abi/src/extern_abi.rs @@ -3,7 +3,9 @@ use std::fmt; use std::hash::{Hash, Hasher}; #[cfg(feature = "nightly")] -use rustc_data_structures::stable_hasher::{HashStable, StableHasher, StableOrd}; +use rustc_data_structures::stable_hasher::{ + HashStable, HashStableContext, StableHasher, StableOrd, +}; #[cfg(feature = "nightly")] use rustc_macros::{Decodable, Encodable}; #[cfg(feature = "nightly")] @@ -217,9 +219,9 @@ impl Hash for ExternAbi { } #[cfg(feature = "nightly")] -impl HashStable for ExternAbi { +impl HashStable for ExternAbi { #[inline] - fn hash_stable(&self, _: &mut C, hasher: &mut StableHasher) { + fn hash_stable(&self, _: &mut Hcx, hasher: &mut StableHasher) { Hash::hash(self, hasher); } } diff --git a/compiler/rustc_abi/src/layout.rs b/compiler/rustc_abi/src/layout.rs index cca1d499088f4..3aa00d14d39b1 100644 --- a/compiler/rustc_abi/src/layout.rs +++ b/compiler/rustc_abi/src/layout.rs @@ -45,7 +45,7 @@ rustc_index::newtype_index! { /// `b` is `FieldIdx(1)` in `VariantIdx(0)`, /// `d` is `FieldIdx(1)` in `VariantIdx(1)`, and /// `f` is `FieldIdx(1)` in `VariantIdx(0)`. - #[stable_hash_generic] + #[stable_hash] #[encodable] #[orderable] #[gate_rustc_only] @@ -70,7 +70,7 @@ rustc_index::newtype_index! { /// /// `struct`s, `tuples`, and `unions`s are considered to have a single variant /// with variant index zero, aka [`FIRST_VARIANT`]. - #[stable_hash_generic] + #[stable_hash] #[encodable] #[orderable] #[gate_rustc_only] diff --git a/compiler/rustc_abi/src/layout/ty.rs b/compiler/rustc_abi/src/layout/ty.rs index 7698a40629daf..b394f9f4f86dc 100644 --- a/compiler/rustc_abi/src/layout/ty.rs +++ b/compiler/rustc_abi/src/layout/ty.rs @@ -2,7 +2,7 @@ use std::fmt; use std::ops::Deref; use rustc_data_structures::intern::Interned; -use rustc_macros::HashStable_Generic; +use rustc_macros::HashStable; use crate::layout::{FieldIdx, VariantIdx}; use crate::{ @@ -12,7 +12,7 @@ use crate::{ // Explicitly import `Float` to avoid ambiguity with `Primitive::Float`. -#[derive(Copy, Clone, PartialEq, Eq, Hash, HashStable_Generic)] +#[derive(Copy, Clone, PartialEq, Eq, Hash, HashStable)] #[rustc_pass_by_value] pub struct Layout<'a>(pub Interned<'a, LayoutData>); @@ -71,7 +71,7 @@ impl<'a> Layout<'a> { /// to that obtained from `layout_of(ty)`, as we need to produce /// layouts for which Rust types do not exist, such as enum variants /// or synthetic fields of enums (i.e., discriminants) and wide pointers. -#[derive(Copy, Clone, PartialEq, Eq, Hash, HashStable_Generic)] +#[derive(Copy, Clone, PartialEq, Eq, Hash, HashStable)] pub struct TyAndLayout<'a, Ty> { pub ty: Ty, pub layout: Layout<'a>, diff --git a/compiler/rustc_abi/src/lib.rs b/compiler/rustc_abi/src/lib.rs index f148b776852aa..e10de04394865 100644 --- a/compiler/rustc_abi/src/lib.rs +++ b/compiler/rustc_abi/src/lib.rs @@ -49,7 +49,7 @@ use rustc_data_structures::stable_hasher::StableOrd; use rustc_hashes::Hash64; use rustc_index::{Idx, IndexSlice, IndexVec}; #[cfg(feature = "nightly")] -use rustc_macros::{Decodable_NoContext, Encodable_NoContext, HashStable_Generic}; +use rustc_macros::{Decodable_NoContext, Encodable_NoContext, HashStable}; mod callconv; mod canon_abi; @@ -68,10 +68,7 @@ pub use layout::{FIRST_VARIANT, FieldIdx, LayoutCalculator, LayoutCalculatorErro pub use layout::{Layout, TyAbiInterface, TyAndLayout}; #[derive(Clone, Copy, PartialEq, Eq, Default)] -#[cfg_attr( - feature = "nightly", - derive(Encodable_NoContext, Decodable_NoContext, HashStable_Generic) -)] +#[cfg_attr(feature = "nightly", derive(Encodable_NoContext, Decodable_NoContext, HashStable))] pub struct ReprFlags(u8); bitflags! { @@ -108,10 +105,7 @@ impl std::fmt::Debug for ReprFlags { } #[derive(Copy, Clone, Debug, Eq, PartialEq)] -#[cfg_attr( - feature = "nightly", - derive(Encodable_NoContext, Decodable_NoContext, HashStable_Generic) -)] +#[cfg_attr(feature = "nightly", derive(Encodable_NoContext, Decodable_NoContext, HashStable))] pub enum IntegerType { /// Pointer-sized integer type, i.e. `isize` and `usize`. The field shows signedness, e.g. /// `Pointer(true)` means `isize`. @@ -131,10 +125,7 @@ impl IntegerType { } #[derive(Copy, Clone, Debug, Eq, PartialEq)] -#[cfg_attr( - feature = "nightly", - derive(Encodable_NoContext, Decodable_NoContext, HashStable_Generic) -)] +#[cfg_attr(feature = "nightly", derive(Encodable_NoContext, Decodable_NoContext, HashStable))] pub enum ScalableElt { /// `N` in `rustc_scalable_vector(N)` - the element count of the scalable vector ElementCount(u16), @@ -145,10 +136,7 @@ pub enum ScalableElt { /// Represents the repr options provided by the user. #[derive(Copy, Clone, Debug, Eq, PartialEq, Default)] -#[cfg_attr( - feature = "nightly", - derive(Encodable_NoContext, Decodable_NoContext, HashStable_Generic) -)] +#[cfg_attr(feature = "nightly", derive(Encodable_NoContext, Decodable_NoContext, HashStable))] pub struct ReprOptions { pub int: Option, pub align: Option, @@ -745,10 +733,7 @@ impl FromStr for Endian { /// Size of a type in bytes. #[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)] -#[cfg_attr( - feature = "nightly", - derive(Encodable_NoContext, Decodable_NoContext, HashStable_Generic) -)] +#[cfg_attr(feature = "nightly", derive(Encodable_NoContext, Decodable_NoContext, HashStable))] pub struct Size { raw: u64, } @@ -973,10 +958,7 @@ impl Step for Size { /// Alignment of a type in bytes (always a power of two). #[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)] -#[cfg_attr( - feature = "nightly", - derive(Encodable_NoContext, Decodable_NoContext, HashStable_Generic) -)] +#[cfg_attr(feature = "nightly", derive(Encodable_NoContext, Decodable_NoContext, HashStable))] pub struct Align { pow2: u8, } @@ -1109,7 +1091,7 @@ impl Align { /// An example of a rare thing actually affected by preferred alignment is aligning of statics. /// It is of effectively no consequence for layout in structs and on the stack. #[derive(Copy, Clone, PartialEq, Eq, Hash, Debug)] -#[cfg_attr(feature = "nightly", derive(HashStable_Generic))] +#[cfg_attr(feature = "nightly", derive(HashStable))] pub struct AbiAlign { pub abi: Align, } @@ -1141,10 +1123,7 @@ impl Deref for AbiAlign { /// Integers, also used for enum discriminants. #[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Debug)] -#[cfg_attr( - feature = "nightly", - derive(Encodable_NoContext, Decodable_NoContext, HashStable_Generic) -)] +#[cfg_attr(feature = "nightly", derive(Encodable_NoContext, Decodable_NoContext, HashStable))] pub enum Integer { I8, I16, @@ -1304,7 +1283,7 @@ impl Integer { /// Floating-point types. #[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Debug)] -#[cfg_attr(feature = "nightly", derive(HashStable_Generic))] +#[cfg_attr(feature = "nightly", derive(HashStable))] pub enum Float { F16, F32, @@ -1339,7 +1318,7 @@ impl Float { /// Fundamental unit of memory access and layout. #[derive(Copy, Clone, PartialEq, Eq, Hash, Debug)] -#[cfg_attr(feature = "nightly", derive(HashStable_Generic))] +#[cfg_attr(feature = "nightly", derive(HashStable))] pub enum Primitive { /// The `bool` is the signedness of the `Integer` type. /// @@ -1387,7 +1366,7 @@ impl Primitive { /// /// This is intended specifically to mirror LLVM’s `!range` metadata semantics. #[derive(Clone, Copy, PartialEq, Eq, Hash)] -#[cfg_attr(feature = "nightly", derive(HashStable_Generic))] +#[cfg_attr(feature = "nightly", derive(HashStable))] pub struct WrappingRange { pub start: u128, pub end: u128, @@ -1499,7 +1478,7 @@ impl fmt::Debug for WrappingRange { /// Information about one scalar component of a Rust type. #[derive(Clone, Copy, PartialEq, Eq, Hash, Debug)] -#[cfg_attr(feature = "nightly", derive(HashStable_Generic))] +#[cfg_attr(feature = "nightly", derive(HashStable))] pub enum Scalar { Initialized { value: Primitive, @@ -1603,7 +1582,7 @@ impl Scalar { // NOTE: This struct is generic over the FieldIdx for rust-analyzer usage. /// Describes how the fields of a type are located in memory. #[derive(PartialEq, Eq, Hash, Clone, Debug)] -#[cfg_attr(feature = "nightly", derive(HashStable_Generic))] +#[cfg_attr(feature = "nightly", derive(HashStable))] pub enum FieldsShape { /// Scalar primitives and `!`, which never have fields. Primitive, @@ -1688,7 +1667,7 @@ impl FieldsShape { /// should operate on. Special address spaces have an effect on code generation, /// depending on the target and the address spaces it implements. #[derive(Copy, Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)] -#[cfg_attr(feature = "nightly", derive(HashStable_Generic))] +#[cfg_attr(feature = "nightly", derive(HashStable))] pub struct AddressSpace(pub u32); impl AddressSpace { @@ -1698,7 +1677,7 @@ impl AddressSpace { /// How many scalable vectors are in a `BackendRepr::ScalableVector`? #[derive(Clone, Copy, PartialEq, Eq, Hash, Debug)] -#[cfg_attr(feature = "nightly", derive(HashStable_Generic))] +#[cfg_attr(feature = "nightly", derive(HashStable))] pub struct NumScalableVectors(pub u8); impl NumScalableVectors { @@ -1729,7 +1708,7 @@ impl NumScalableVectors { /// Generally, a codegen backend will prefer to handle smaller values as a scalar or short vector, /// and larger values will usually prefer to be represented as memory. #[derive(Clone, Copy, PartialEq, Eq, Hash, Debug)] -#[cfg_attr(feature = "nightly", derive(HashStable_Generic))] +#[cfg_attr(feature = "nightly", derive(HashStable))] pub enum BackendRepr { Scalar(Scalar), ScalarPair(Scalar, Scalar), @@ -1873,7 +1852,7 @@ impl BackendRepr { // NOTE: This struct is generic over the FieldIdx and VariantIdx for rust-analyzer usage. #[derive(PartialEq, Eq, Hash, Clone, Debug)] -#[cfg_attr(feature = "nightly", derive(HashStable_Generic))] +#[cfg_attr(feature = "nightly", derive(HashStable))] pub enum Variants { /// A type with no valid variants. Must be uninhabited. Empty, @@ -1900,7 +1879,7 @@ pub enum Variants { // NOTE: This struct is generic over the VariantIdx for rust-analyzer usage. #[derive(PartialEq, Eq, Hash, Clone, Debug)] -#[cfg_attr(feature = "nightly", derive(HashStable_Generic))] +#[cfg_attr(feature = "nightly", derive(HashStable))] pub enum TagEncoding { /// The tag directly stores the discriminant, but possibly with a smaller layout /// (so converting the tag to the discriminant can require sign extension). @@ -1941,7 +1920,7 @@ pub enum TagEncoding { } #[derive(Clone, Copy, PartialEq, Eq, Hash, Debug)] -#[cfg_attr(feature = "nightly", derive(HashStable_Generic))] +#[cfg_attr(feature = "nightly", derive(HashStable))] pub struct Niche { pub offset: Size, pub value: Primitive, @@ -2028,7 +2007,7 @@ impl Niche { // NOTE: This struct is generic over the FieldIdx and VariantIdx for rust-analyzer usage. #[derive(PartialEq, Eq, Hash, Clone)] -#[cfg_attr(feature = "nightly", derive(HashStable_Generic))] +#[cfg_attr(feature = "nightly", derive(HashStable))] pub struct LayoutData { /// Says where the fields are located within the layout. pub fields: FieldsShape, diff --git a/compiler/rustc_ast/src/ast.rs b/compiler/rustc_ast/src/ast.rs index ae4989fcbc6c9..a61ed89bd0de6 100644 --- a/compiler/rustc_ast/src/ast.rs +++ b/compiler/rustc_ast/src/ast.rs @@ -25,14 +25,13 @@ pub use GenericArgs::*; pub use UnsafeSource::*; pub use rustc_ast_ir::{FloatTy, IntTy, Movability, Mutability, Pinnedness, UintTy}; use rustc_data_structures::packed::Pu128; -use rustc_data_structures::stable_hasher::{HashStable, StableHasher}; +use rustc_data_structures::stable_hasher::{HashStable, HashStableContext, StableHasher}; use rustc_data_structures::stack::ensure_sufficient_stack; use rustc_data_structures::tagged_ptr::Tag; -use rustc_macros::{Decodable, Encodable, HashStable_Generic, Walkable}; +use rustc_macros::{Decodable, Encodable, HashStable, Walkable}; pub use rustc_span::AttrId; use rustc_span::{ - ByteSymbol, DUMMY_SP, ErrorGuaranteed, HashStableContext, Ident, Span, Spanned, Symbol, kw, - respan, sym, + ByteSymbol, DUMMY_SP, ErrorGuaranteed, Ident, Span, Spanned, Symbol, kw, respan, sym, }; use thin_vec::{ThinVec, thin_vec}; @@ -53,7 +52,7 @@ use crate::visit::{AssocCtxt, BoundKind, LifetimeCtxt}; /// ``` /// /// `'outer` is a label. -#[derive(Clone, Encodable, Decodable, Copy, HashStable_Generic, Eq, PartialEq, Walkable)] +#[derive(Clone, Encodable, Decodable, Copy, HashStable, Eq, PartialEq, Walkable)] pub struct Label { pub ident: Ident, } @@ -121,8 +120,8 @@ impl PartialEq<&[Symbol]> for Path { } } -impl HashStable for Path { - fn hash_stable(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { +impl HashStable for Path { + fn hash_stable(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { self.segments.len().hash_stable(hcx, hasher); for segment in &self.segments { segment.ident.hash_stable(hcx, hasher); @@ -565,7 +564,7 @@ pub struct Crate { /// for most built-in attributes. /// /// E.g., `#[test]`, `#[derive(..)]`, `#[rustfmt::skip]` or `#[feature = "foo"]`. -#[derive(Clone, Encodable, Decodable, Debug, HashStable_Generic)] +#[derive(Clone, Encodable, Decodable, Debug, HashStable)] pub struct MetaItem { pub unsafety: Safety, pub path: Path, @@ -574,7 +573,7 @@ pub struct MetaItem { } /// The meta item kind, containing the data after the initial path. -#[derive(Clone, Encodable, Decodable, Debug, HashStable_Generic)] +#[derive(Clone, Encodable, Decodable, Debug, HashStable)] pub enum MetaItemKind { /// Word meta item. /// @@ -595,7 +594,7 @@ pub enum MetaItemKind { /// Values inside meta item lists. /// /// E.g., each of `Clone`, `Copy` in `#[derive(Clone, Copy)]`. -#[derive(Clone, Encodable, Decodable, Debug, HashStable_Generic)] +#[derive(Clone, Encodable, Decodable, Debug, HashStable)] pub enum MetaItemInner { /// A full MetaItem, for recursive meta items. MetaItem(MetaItem), @@ -793,7 +792,7 @@ pub struct PatField { } #[derive(Clone, Copy, Debug, Eq, PartialEq)] -#[derive(Encodable, Decodable, HashStable_Generic, Walkable)] +#[derive(Encodable, Decodable, HashStable, Walkable)] pub enum ByRef { Yes(Pinnedness, Mutability), No, @@ -815,7 +814,7 @@ impl ByRef { /// `.0` is the by-reference mode (`ref`, `ref mut`, or by value), /// `.1` is the mutability of the binding. #[derive(Clone, Copy, Debug, Eq, PartialEq)] -#[derive(Encodable, Decodable, HashStable_Generic, Walkable)] +#[derive(Encodable, Decodable, HashStable, Walkable)] pub struct BindingMode(pub ByRef, pub Mutability); impl BindingMode { @@ -965,7 +964,7 @@ pub enum PatFieldsRest { /// The kind of borrow in an `AddrOf` expression, /// e.g., `&place` or `&raw const place`. #[derive(Clone, Copy, PartialEq, Eq, Debug)] -#[derive(Encodable, Decodable, HashStable_Generic, Walkable)] +#[derive(Encodable, Decodable, HashStable, Walkable)] pub enum BorrowKind { /// A normal borrow, `&$expr` or `&mut $expr`. /// The resulting type is either `&'a T` or `&'a mut T` @@ -981,7 +980,7 @@ pub enum BorrowKind { Pin, } -#[derive(Clone, Copy, Debug, PartialEq, Encodable, Decodable, HashStable_Generic, Walkable)] +#[derive(Clone, Copy, Debug, PartialEq, Encodable, Decodable, HashStable, Walkable)] pub enum BinOpKind { /// The `+` operator (addition) Add, @@ -1111,7 +1110,7 @@ impl From for BinOpKind { } } -#[derive(Clone, Copy, Debug, PartialEq, Encodable, Decodable, HashStable_Generic, Walkable)] +#[derive(Clone, Copy, Debug, PartialEq, Encodable, Decodable, HashStable, Walkable)] pub enum AssignOpKind { /// The `+=` operator (addition) AddAssign, @@ -1163,7 +1162,7 @@ pub type AssignOp = Spanned; /// Unary operator. /// /// Note that `&data` is not an operator, it's an `AddrOf` expression. -#[derive(Clone, Copy, Debug, PartialEq, Encodable, Decodable, HashStable_Generic, Walkable)] +#[derive(Clone, Copy, Debug, PartialEq, Encodable, Decodable, HashStable, Walkable)] pub enum UnOp { /// The `*` operator for dereferencing Deref, @@ -1962,7 +1961,7 @@ impl GenBlockKind { /// Whether we're unwrapping or wrapping an unsafe binder #[derive(Copy, Clone, Debug, PartialEq, Eq, Hash)] -#[derive(Encodable, Decodable, HashStable_Generic, Walkable)] +#[derive(Encodable, Decodable, HashStable, Walkable)] pub enum UnsafeBinderCastKind { // e.g. `&i32` -> `unsafe<'a> &'a i32` Wrap, @@ -1996,7 +1995,7 @@ pub struct QSelf { } /// A capture clause used in closures and `async` blocks. -#[derive(Clone, Copy, PartialEq, Encodable, Decodable, Debug, HashStable_Generic, Walkable)] +#[derive(Clone, Copy, PartialEq, Encodable, Decodable, Debug, HashStable, Walkable)] pub enum CaptureBy { /// `move |x| y + x`. Value { @@ -2091,7 +2090,7 @@ impl AttrArgs { } /// Delimited arguments, as used in `#[attr()/[]/{}]` or `mac!()/[]/{}`. -#[derive(Clone, Encodable, Decodable, Debug, HashStable_Generic, Walkable)] +#[derive(Clone, Encodable, Decodable, Debug, HashStable, Walkable)] pub struct DelimArgs { pub dspan: DelimSpan, pub delim: Delimiter, // Note: `Delimiter::Invisible` never occurs @@ -2107,7 +2106,7 @@ impl DelimArgs { } /// Represents a macro definition. -#[derive(Clone, Encodable, Decodable, Debug, HashStable_Generic, Walkable)] +#[derive(Clone, Encodable, Decodable, Debug, HashStable, Walkable)] pub struct MacroDef { pub body: Box, /// `true` if macro was defined with `macro_rules`. @@ -2121,7 +2120,7 @@ pub struct MacroDef { pub eii_declaration: Option, } -#[derive(Clone, Encodable, Decodable, Debug, HashStable_Generic, Walkable)] +#[derive(Clone, Encodable, Decodable, Debug, HashStable, Walkable)] pub struct EiiDecl { /// path to the extern item we're targeting pub foreign_item: Path, @@ -2129,7 +2128,7 @@ pub struct EiiDecl { } #[derive(Clone, Encodable, Decodable, Debug, Copy, Hash, Eq, PartialEq)] -#[derive(HashStable_Generic, Walkable)] +#[derive(HashStable, Walkable)] pub enum StrStyle { /// A regular string, like `"foo"`. Cooked, @@ -2187,7 +2186,7 @@ impl YieldKind { } /// A literal in a meta item. -#[derive(Clone, Copy, Encodable, Decodable, Debug, HashStable_Generic)] +#[derive(Clone, Copy, Encodable, Decodable, Debug, HashStable)] pub struct MetaItemLit { /// The original literal as written in the source code. pub symbol: Symbol, @@ -2224,7 +2223,7 @@ impl StrLit { /// Type of the integer literal based on provided suffix. #[derive(Clone, Copy, Encodable, Decodable, Debug, Hash, Eq, PartialEq)] -#[derive(HashStable_Generic)] +#[derive(HashStable)] pub enum LitIntType { /// e.g. `42_i32`. Signed(IntTy), @@ -2236,7 +2235,7 @@ pub enum LitIntType { /// Type of the float literal based on provided suffix. #[derive(Clone, Copy, Encodable, Decodable, Debug, Hash, Eq, PartialEq)] -#[derive(HashStable_Generic)] +#[derive(HashStable)] pub enum LitFloatType { /// A float literal with a suffix (`1f32` or `1E10f32`). Suffixed(FloatTy), @@ -2250,7 +2249,7 @@ pub enum LitFloatType { /// deciding the `LitKind`. This means that float literals like `1f32` are /// classified by this type as `Float`. This is different to `token::LitKind` /// which does *not* consider the suffix. -#[derive(Clone, Copy, Encodable, Decodable, Debug, Hash, Eq, PartialEq, HashStable_Generic)] +#[derive(Clone, Copy, Encodable, Decodable, Debug, Hash, Eq, PartialEq, HashStable)] pub enum LitKind { /// A string literal (`"foo"`). The symbol is unescaped, and so may differ /// from the original token's symbol. @@ -2653,7 +2652,7 @@ pub enum TyPatKind { } /// Syntax used to declare a trait object. -#[derive(Clone, Copy, PartialEq, Encodable, Decodable, Debug, HashStable_Generic, Walkable)] +#[derive(Clone, Copy, PartialEq, Encodable, Decodable, Debug, HashStable, Walkable)] #[repr(u8)] pub enum TraitObjectSyntax { // SAFETY: When adding new variants make sure to update the `Tag` impl. @@ -2697,7 +2696,7 @@ pub enum InlineAsmRegOrRegClass { RegClass(Symbol), } -#[derive(Clone, Copy, PartialEq, Eq, Hash, Encodable, Decodable, HashStable_Generic)] +#[derive(Clone, Copy, PartialEq, Eq, Hash, Encodable, Decodable, HashStable)] pub struct InlineAsmOptions(u16); bitflags::bitflags! { impl InlineAsmOptions: u16 { @@ -2760,7 +2759,7 @@ impl std::fmt::Debug for InlineAsmOptions { } } -#[derive(Clone, PartialEq, Encodable, Decodable, Debug, Hash, HashStable_Generic, Walkable)] +#[derive(Clone, PartialEq, Encodable, Decodable, Debug, Hash, HashStable, Walkable)] pub enum InlineAsmTemplatePiece { String(Cow<'static, str>), Placeholder { operand_idx: usize, modifier: Option, span: Span }, @@ -2863,7 +2862,7 @@ impl InlineAsmOperand { } } -#[derive(Clone, Copy, Encodable, Decodable, Debug, HashStable_Generic, Walkable, PartialEq, Eq)] +#[derive(Clone, Copy, Encodable, Decodable, Debug, HashStable, Walkable, PartialEq, Eq)] pub enum AsmMacro { /// The `asm!` macro Asm, @@ -3061,7 +3060,7 @@ impl FnDecl { } /// Is the trait definition an auto trait? -#[derive(Copy, Clone, PartialEq, Encodable, Decodable, Debug, HashStable_Generic, Walkable)] +#[derive(Copy, Clone, PartialEq, Encodable, Decodable, Debug, HashStable, Walkable)] pub enum IsAuto { Yes, No, @@ -3069,7 +3068,7 @@ pub enum IsAuto { /// Safety of items. #[derive(Copy, Clone, PartialEq, Eq, Hash, Encodable, Decodable, Debug)] -#[derive(HashStable_Generic, Walkable)] +#[derive(HashStable, Walkable)] pub enum Safety { /// `unsafe` an item is explicitly marked as `unsafe`. Unsafe(Span), @@ -3134,7 +3133,7 @@ impl CoroutineKind { } #[derive(Copy, Clone, PartialEq, Eq, Hash, Encodable, Decodable, Debug)] -#[derive(HashStable_Generic, Walkable)] +#[derive(HashStable, Walkable)] pub enum Const { Yes(Span), No, @@ -3142,7 +3141,7 @@ pub enum Const { /// Item defaultness. /// For details see the [RFC #2532](https://github.com/rust-lang/rfcs/pull/2532). -#[derive(Copy, Clone, PartialEq, Encodable, Decodable, Debug, HashStable_Generic, Walkable)] +#[derive(Copy, Clone, PartialEq, Encodable, Decodable, Debug, HashStable, Walkable)] pub enum Defaultness { /// Item is unmarked. Implicitly determined based off of position. /// For impls, this is `final`; for traits, this is `default`. @@ -3156,7 +3155,7 @@ pub enum Defaultness { Final(Span), } -#[derive(Copy, Clone, PartialEq, Encodable, Decodable, HashStable_Generic, Walkable)] +#[derive(Copy, Clone, PartialEq, Encodable, Decodable, HashStable, Walkable)] pub enum ImplPolarity { /// `impl Trait for Type` Positive, @@ -3175,7 +3174,7 @@ impl fmt::Debug for ImplPolarity { /// The polarity of a trait bound. #[derive(Copy, Clone, PartialEq, Eq, Encodable, Decodable, Debug, Hash)] -#[derive(HashStable_Generic, Walkable)] +#[derive(HashStable, Walkable)] pub enum BoundPolarity { /// `Type: Trait` Positive, @@ -3197,7 +3196,7 @@ impl BoundPolarity { /// The constness of a trait bound. #[derive(Copy, Clone, PartialEq, Eq, Encodable, Decodable, Debug, Hash)] -#[derive(HashStable_Generic, Walkable)] +#[derive(HashStable, Walkable)] pub enum BoundConstness { /// `Type: Trait` Never, @@ -3219,7 +3218,7 @@ impl BoundConstness { /// The asyncness of a trait bound. #[derive(Copy, Clone, PartialEq, Eq, Encodable, Decodable, Debug)] -#[derive(HashStable_Generic, Walkable)] +#[derive(HashStable, Walkable)] pub enum BoundAsyncness { /// `Type: Trait` Normal, @@ -3388,7 +3387,7 @@ impl UseTree { /// are contained as statements within items. These two cases need to be /// distinguished for pretty-printing. #[derive(Clone, PartialEq, Eq, Hash, Debug, Copy)] -#[derive(Encodable, Decodable, HashStable_Generic, Walkable)] +#[derive(Encodable, Decodable, HashStable, Walkable)] pub enum AttrStyle { Outer, Inner, @@ -3485,7 +3484,7 @@ impl AttrItemKind { /// /// Currently all early parsed attributes are excluded from pretty printing at rustc_ast_pretty::pprust::state::print_attribute_inline. /// When adding new early parsed attributes, consider whether they should be pretty printed. -#[derive(Clone, Encodable, Decodable, Debug, HashStable_Generic)] +#[derive(Clone, Encodable, Decodable, Debug, HashStable)] pub enum EarlyParsedAttribute { CfgTrace(CfgEntry), CfgAttrTrace, @@ -3608,7 +3607,7 @@ pub struct FieldDef { } /// Was parsing recovery performed? -#[derive(Copy, Clone, Debug, Encodable, Decodable, HashStable_Generic, Walkable)] +#[derive(Copy, Clone, Debug, Encodable, Decodable, HashStable, Walkable)] pub enum Recovered { No, Yes(ErrorGuaranteed), diff --git a/compiler/rustc_ast/src/attr/data_structures.rs b/compiler/rustc_ast/src/attr/data_structures.rs index 2eab91801cd6d..36d0352b7f8a0 100644 --- a/compiler/rustc_ast/src/attr/data_structures.rs +++ b/compiler/rustc_ast/src/attr/data_structures.rs @@ -1,12 +1,12 @@ use std::fmt; -use rustc_macros::{Decodable, Encodable, HashStable_Generic}; +use rustc_macros::{Decodable, Encodable, HashStable}; use rustc_span::{Span, Symbol}; use thin_vec::ThinVec; use crate::attr::version::RustcVersion; -#[derive(Encodable, Decodable, Clone, Debug, PartialEq, Eq, Hash, HashStable_Generic)] +#[derive(Encodable, Decodable, Clone, Debug, PartialEq, Eq, Hash, HashStable)] pub enum CfgEntry { All(ThinVec, Span), Any(ThinVec, Span), diff --git a/compiler/rustc_ast/src/attr/version.rs b/compiler/rustc_ast/src/attr/version.rs index 59deee40ae28d..c695ba5b8a057 100644 --- a/compiler/rustc_ast/src/attr/version.rs +++ b/compiler/rustc_ast/src/attr/version.rs @@ -1,10 +1,10 @@ use std::fmt::{self, Display}; use std::sync::OnceLock; -use rustc_macros::{BlobDecodable, Encodable, HashStable_Generic, current_rustc_version}; +use rustc_macros::{BlobDecodable, Encodable, HashStable, current_rustc_version}; #[derive(Encodable, BlobDecodable, Copy, Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)] -#[derive(HashStable_Generic)] +#[derive(HashStable)] pub struct RustcVersion { pub major: u16, pub minor: u16, diff --git a/compiler/rustc_ast/src/expand/allocator.rs b/compiler/rustc_ast/src/expand/allocator.rs index 332ad50d927fa..874534b876521 100644 --- a/compiler/rustc_ast/src/expand/allocator.rs +++ b/compiler/rustc_ast/src/expand/allocator.rs @@ -1,7 +1,7 @@ -use rustc_macros::HashStable_Generic; +use rustc_macros::HashStable; use rustc_span::{Symbol, sym}; -#[derive(Clone, Debug, Copy, Eq, PartialEq, HashStable_Generic)] +#[derive(Clone, Debug, Copy, Eq, PartialEq, HashStable)] pub enum AllocatorKind { /// Use `#[global_allocator]` as global allocator. Global, diff --git a/compiler/rustc_ast/src/expand/autodiff_attrs.rs b/compiler/rustc_ast/src/expand/autodiff_attrs.rs index a3c913436ac76..a1967ba8db322 100644 --- a/compiler/rustc_ast/src/expand/autodiff_attrs.rs +++ b/compiler/rustc_ast/src/expand/autodiff_attrs.rs @@ -8,7 +8,7 @@ use std::str::FromStr; use rustc_span::{Symbol, sym}; -use crate::expand::{Decodable, Encodable, HashStable_Generic}; +use crate::expand::{Decodable, Encodable, HashStable}; use crate::{Ty, TyKind}; /// Forward and Reverse Mode are well known names for automatic differentiation implementations. @@ -20,7 +20,7 @@ use crate::{Ty, TyKind}; /// /// Documentation for using [reverse](https://enzyme.mit.edu/rust/rev.html) and /// [forward](https://enzyme.mit.edu/rust/fwd.html) mode is available online. -#[derive(Clone, Copy, Eq, PartialEq, Encodable, Decodable, Debug, HashStable_Generic)] +#[derive(Clone, Copy, Eq, PartialEq, Encodable, Decodable, Debug, HashStable)] pub enum DiffMode { /// No autodiff is applied (used during error handling). Error, @@ -42,7 +42,7 @@ impl DiffMode { /// However, under forward mode we overwrite the previous shadow value, while for reverse mode /// we add to the previous shadow value. To not surprise users, we picked different names. /// Dual numbers is also a quite well known name for forward mode AD types. -#[derive(Clone, Copy, Eq, PartialEq, Encodable, Decodable, Debug, HashStable_Generic)] +#[derive(Clone, Copy, Eq, PartialEq, Encodable, Decodable, Debug, HashStable)] pub enum DiffActivity { /// Implicit or Explicit () return type, so a special case of Const. None, diff --git a/compiler/rustc_ast/src/expand/mod.rs b/compiler/rustc_ast/src/expand/mod.rs index 069bff67b97ac..e5abb651c0800 100644 --- a/compiler/rustc_ast/src/expand/mod.rs +++ b/compiler/rustc_ast/src/expand/mod.rs @@ -1,6 +1,6 @@ //! Definitions shared by macros / syntax extensions and e.g. `rustc_middle`. -use rustc_macros::{Decodable, Encodable, HashStable_Generic}; +use rustc_macros::{Decodable, Encodable, HashStable}; pub mod allocator; pub mod autodiff_attrs; diff --git a/compiler/rustc_ast/src/expand/typetree.rs b/compiler/rustc_ast/src/expand/typetree.rs index e7b4f3aff413a..3c1dd69f6c559 100644 --- a/compiler/rustc_ast/src/expand/typetree.rs +++ b/compiler/rustc_ast/src/expand/typetree.rs @@ -21,9 +21,9 @@ use std::fmt; -use crate::expand::{Decodable, Encodable, HashStable_Generic}; +use crate::expand::{Decodable, Encodable, HashStable}; -#[derive(Clone, Copy, Eq, PartialEq, Encodable, Decodable, Debug, HashStable_Generic)] +#[derive(Clone, Copy, Eq, PartialEq, Encodable, Decodable, Debug, HashStable)] pub enum Kind { Anything, Integer, @@ -35,7 +35,7 @@ pub enum Kind { Unknown, } -#[derive(Clone, Eq, PartialEq, Encodable, Decodable, Debug, HashStable_Generic)] +#[derive(Clone, Eq, PartialEq, Encodable, Decodable, Debug, HashStable)] pub struct TypeTree(pub Vec); impl TypeTree { @@ -59,13 +59,13 @@ impl TypeTree { } } -#[derive(Clone, Eq, PartialEq, Encodable, Decodable, Debug, HashStable_Generic)] +#[derive(Clone, Eq, PartialEq, Encodable, Decodable, Debug, HashStable)] pub struct FncTree { pub args: Vec, pub ret: TypeTree, } -#[derive(Clone, Eq, PartialEq, Encodable, Decodable, Debug, HashStable_Generic)] +#[derive(Clone, Eq, PartialEq, Encodable, Decodable, Debug, HashStable)] pub struct Type { pub offset: isize, pub size: usize, diff --git a/compiler/rustc_ast/src/node_id.rs b/compiler/rustc_ast/src/node_id.rs index adca1844b61f8..848fbc1848c0b 100644 --- a/compiler/rustc_ast/src/node_id.rs +++ b/compiler/rustc_ast/src/node_id.rs @@ -1,5 +1,6 @@ use std::fmt; +use rustc_data_structures::stable_hasher::{HashStable, HashStableContext, StableHasher}; use rustc_span::LocalExpnId; rustc_index::newtype_index! { @@ -18,6 +19,13 @@ rustc_index::newtype_index! { } } +impl HashStable for NodeId { + #[inline] + fn hash_stable(&self, _: &mut Hcx, _: &mut StableHasher) { + panic!("Node IDs should not appear in incremental state"); + } +} + rustc_data_structures::define_id_collections!(NodeMap, NodeSet, NodeMapEntry, NodeId); /// When parsing and at the beginning of doing expansions, we initially give all AST nodes diff --git a/compiler/rustc_ast/src/token.rs b/compiler/rustc_ast/src/token.rs index 62ec063585171..9f148f87dfba8 100644 --- a/compiler/rustc_ast/src/token.rs +++ b/compiler/rustc_ast/src/token.rs @@ -5,7 +5,7 @@ pub use LitKind::*; pub use NtExprKind::*; pub use NtPatKind::*; pub use TokenKind::*; -use rustc_macros::{Decodable, Encodable, HashStable_Generic}; +use rustc_macros::{Decodable, Encodable, HashStable}; use rustc_span::edition::Edition; use rustc_span::symbol::IdentPrintMode; use rustc_span::{DUMMY_SP, ErrorGuaranteed, Span, kw, sym}; @@ -17,7 +17,7 @@ use crate::ast; use crate::util::case::Case; /// Represents the kind of doc comment it is, ie `///` or `#[doc = ""]`. -#[derive(Clone, Copy, PartialEq, Eq, Encodable, Decodable, Debug, HashStable_Generic)] +#[derive(Clone, Copy, PartialEq, Eq, Encodable, Decodable, Debug, HashStable)] pub enum DocFragmentKind { /// A sugared doc comment: `///` or `//!` or `/**` or `/*!`. Sugared(CommentKind), @@ -40,13 +40,13 @@ impl DocFragmentKind { } } -#[derive(Clone, Copy, PartialEq, Eq, Hash, Encodable, Decodable, Debug, HashStable_Generic)] +#[derive(Clone, Copy, PartialEq, Eq, Hash, Encodable, Decodable, Debug, HashStable)] pub enum CommentKind { Line, Block, } -#[derive(Copy, Clone, PartialEq, Eq, Hash, Debug, Encodable, Decodable, HashStable_Generic)] +#[derive(Copy, Clone, PartialEq, Eq, Hash, Debug, Encodable, Decodable, HashStable)] pub enum InvisibleOrigin { // From the expansion of a metavariable in a declarative macro. MetaVar(MetaVarKind), @@ -69,7 +69,7 @@ impl InvisibleOrigin { } /// Annoyingly similar to `NonterminalKind`, but the slight differences are important. -#[derive(Debug, Copy, Clone, PartialEq, Eq, Encodable, Decodable, Hash, HashStable_Generic)] +#[derive(Debug, Copy, Clone, PartialEq, Eq, Encodable, Decodable, Hash, HashStable)] pub enum MetaVarKind { Item, Block, @@ -125,7 +125,7 @@ impl fmt::Display for MetaVarKind { /// Describes how a sequence of token trees is delimited. /// Cannot use `proc_macro::Delimiter` directly because this /// structure should implement some additional traits. -#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash, Encodable, Decodable, HashStable_Generic)] +#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash, Encodable, Decodable, HashStable)] pub enum Delimiter { /// `( ... )` Parenthesis, @@ -188,7 +188,7 @@ impl Delimiter { // type. This means that float literals like `1f32` are classified by this type // as `Int`. Only upon conversion to `ast::LitKind` will such a literal be // given the `Float` kind. -#[derive(Clone, Copy, PartialEq, Eq, Hash, Encodable, Decodable, Debug, HashStable_Generic)] +#[derive(Clone, Copy, PartialEq, Eq, Hash, Encodable, Decodable, Debug, HashStable)] pub enum LitKind { Bool, // AST only, must never appear in a `Token` Byte, @@ -205,7 +205,7 @@ pub enum LitKind { } /// A literal token. -#[derive(Clone, Copy, PartialEq, Eq, Hash, Encodable, Decodable, Debug, HashStable_Generic)] +#[derive(Clone, Copy, PartialEq, Eq, Hash, Encodable, Decodable, Debug, HashStable)] pub struct Lit { pub kind: LitKind, pub symbol: Symbol, @@ -351,7 +351,7 @@ fn ident_can_begin_type(name: Symbol, span: Span, is_raw: IdentIsRaw) -> bool { .contains(&name) } -#[derive(PartialEq, Eq, Encodable, Decodable, Hash, Debug, Copy, Clone, HashStable_Generic)] +#[derive(PartialEq, Eq, Encodable, Decodable, Hash, Debug, Copy, Clone, HashStable)] pub enum IdentIsRaw { No, Yes, @@ -378,7 +378,7 @@ impl From for IdentIsRaw { } } -#[derive(Clone, Copy, PartialEq, Eq, Hash, Encodable, Decodable, Debug, HashStable_Generic)] +#[derive(Clone, Copy, PartialEq, Eq, Hash, Encodable, Decodable, Debug, HashStable)] pub enum TokenKind { /* Expression-operator symbols. */ /// `=` @@ -528,7 +528,7 @@ pub enum TokenKind { Eof, } -#[derive(Clone, Copy, PartialEq, Eq, Hash, Encodable, Decodable, Debug, HashStable_Generic)] +#[derive(Clone, Copy, PartialEq, Eq, Hash, Encodable, Decodable, Debug, HashStable)] pub struct Token { pub kind: TokenKind, pub span: Span, @@ -1090,7 +1090,7 @@ impl PartialEq for Token { } } -#[derive(Debug, Copy, Clone, PartialEq, Eq, Encodable, Decodable, Hash, HashStable_Generic)] +#[derive(Debug, Copy, Clone, PartialEq, Eq, Encodable, Decodable, Hash, HashStable)] pub enum NtPatKind { // Matches or-patterns. Was written using `pat` in edition 2021 or later. PatWithOr, @@ -1100,7 +1100,7 @@ pub enum NtPatKind { PatParam { inferred: bool }, } -#[derive(Debug, Copy, Clone, PartialEq, Eq, Encodable, Decodable, Hash, HashStable_Generic)] +#[derive(Debug, Copy, Clone, PartialEq, Eq, Encodable, Decodable, Hash, HashStable)] pub enum NtExprKind { // Matches expressions using the post-edition 2024. Was written using // `expr` in edition 2024 or later. @@ -1112,7 +1112,7 @@ pub enum NtExprKind { } /// A macro nonterminal, known in documentation as a fragment specifier. -#[derive(Debug, Copy, Clone, PartialEq, Eq, Encodable, Decodable, Hash, HashStable_Generic)] +#[derive(Debug, Copy, Clone, PartialEq, Eq, Encodable, Decodable, Hash, HashStable)] pub enum NonterminalKind { Item, Block, diff --git a/compiler/rustc_ast/src/tokenstream.rs b/compiler/rustc_ast/src/tokenstream.rs index 06bd6f03e9350..86a6d93dac359 100644 --- a/compiler/rustc_ast/src/tokenstream.rs +++ b/compiler/rustc_ast/src/tokenstream.rs @@ -10,11 +10,11 @@ use std::ops::Range; use std::sync::Arc; use std::{cmp, fmt, iter, mem}; -use rustc_data_structures::stable_hasher::{HashStable, StableHasher}; +use rustc_data_structures::stable_hasher::{HashStable, HashStableContext, StableHasher}; use rustc_data_structures::sync; -use rustc_macros::{Decodable, Encodable, HashStable_Generic, Walkable}; +use rustc_macros::{Decodable, Encodable, HashStable, Walkable}; use rustc_serialize::{Decodable, Encodable}; -use rustc_span::{DUMMY_SP, HashStableContext, Span, SpanDecoder, SpanEncoder, Symbol, sym}; +use rustc_span::{DUMMY_SP, Span, SpanDecoder, SpanEncoder, Symbol, sym}; use thin_vec::ThinVec; use crate::ast::AttrStyle; @@ -23,7 +23,7 @@ use crate::token::{self, Delimiter, Token, TokenKind}; use crate::{AttrVec, Attribute}; /// Part of a `TokenStream`. -#[derive(Debug, Clone, PartialEq, Eq, Hash, Encodable, Decodable, HashStable_Generic)] +#[derive(Debug, Clone, PartialEq, Eq, Hash, Encodable, Decodable, HashStable)] pub enum TokenTree { /// A single token. Should never be `OpenDelim` or `CloseDelim`, because /// delimiters are implicitly represented by `Delimited`. @@ -138,8 +138,8 @@ impl Decodable for LazyAttrTokenStream { } } -impl HashStable for LazyAttrTokenStream { - fn hash_stable(&self, _hcx: &mut Hcx, _hasher: &mut StableHasher) { +impl HashStable for LazyAttrTokenStream { + fn hash_stable(&self, _hcx: &mut Hcx, _hasher: &mut StableHasher) { panic!("Attempted to compute stable hash for LazyAttrTokenStream"); } } @@ -545,7 +545,7 @@ pub struct AttrsTarget { /// compound token. Used for conversions to `proc_macro::Spacing`. Also used to /// guide pretty-printing, which is where the `JointHidden` value (which isn't /// part of `proc_macro::Spacing`) comes in useful. -#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, Encodable, Decodable, HashStable_Generic)] +#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, Encodable, Decodable, HashStable)] pub enum Spacing { /// The token cannot join with the following token to form a compound /// token. @@ -824,11 +824,8 @@ impl FromIterator for TokenStream { } } -impl HashStable for TokenStream -where - Hcx: HashStableContext, -{ - fn hash_stable(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { +impl HashStable for TokenStream { + fn hash_stable(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { for sub_tt in self.iter() { sub_tt.hash_stable(hcx, hasher); } @@ -970,7 +967,7 @@ impl TokenCursor { } #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] -#[derive(Encodable, Decodable, HashStable_Generic, Walkable)] +#[derive(Encodable, Decodable, HashStable, Walkable)] pub struct DelimSpan { pub open: Span, pub close: Span, @@ -994,7 +991,7 @@ impl DelimSpan { } } -#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash, Encodable, Decodable, HashStable_Generic)] +#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash, Encodable, Decodable, HashStable)] pub struct DelimSpacing { pub open: Spacing, pub close: Spacing, diff --git a/compiler/rustc_ast_ir/src/lib.rs b/compiler/rustc_ast_ir/src/lib.rs index fb00f5d9b6236..f0ba622308670 100644 --- a/compiler/rustc_ast_ir/src/lib.rs +++ b/compiler/rustc_ast_ir/src/lib.rs @@ -14,17 +14,14 @@ use std::fmt; #[cfg(feature = "nightly")] -use rustc_macros::{Decodable_NoContext, Encodable_NoContext, HashStable_NoContext}; +use rustc_macros::{Decodable_NoContext, Encodable_NoContext, HashStable}; #[cfg(feature = "nightly")] use rustc_span::{Symbol, sym}; pub mod visit; #[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)] -#[cfg_attr( - feature = "nightly", - derive(Encodable_NoContext, Decodable_NoContext, HashStable_NoContext) -)] +#[cfg_attr(feature = "nightly", derive(Encodable_NoContext, Decodable_NoContext, HashStable))] pub enum IntTy { Isize, I8, @@ -100,10 +97,7 @@ impl fmt::Debug for IntTy { } #[derive(Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Copy)] -#[cfg_attr( - feature = "nightly", - derive(Encodable_NoContext, Decodable_NoContext, HashStable_NoContext) -)] +#[cfg_attr(feature = "nightly", derive(Encodable_NoContext, Decodable_NoContext, HashStable))] pub enum UintTy { Usize, U8, @@ -179,10 +173,7 @@ impl fmt::Debug for UintTy { } #[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)] -#[cfg_attr( - feature = "nightly", - derive(Encodable_NoContext, Decodable_NoContext, HashStable_NoContext) -)] +#[cfg_attr(feature = "nightly", derive(Encodable_NoContext, Decodable_NoContext, HashStable))] pub enum FloatTy { F16, F32, @@ -229,10 +220,7 @@ impl fmt::Debug for FloatTy { /// The movability of a coroutine / closure literal: /// whether a coroutine contains self-references, causing it to be `!Unpin`. #[derive(Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Debug, Copy)] -#[cfg_attr( - feature = "nightly", - derive(Encodable_NoContext, Decodable_NoContext, HashStable_NoContext) -)] +#[cfg_attr(feature = "nightly", derive(Encodable_NoContext, Decodable_NoContext, HashStable))] pub enum Movability { /// May contain self-references, `!Unpin`. Static, @@ -241,10 +229,7 @@ pub enum Movability { } #[derive(Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Debug, Copy)] -#[cfg_attr( - feature = "nightly", - derive(Encodable_NoContext, Decodable_NoContext, HashStable_NoContext) -)] +#[cfg_attr(feature = "nightly", derive(Encodable_NoContext, Decodable_NoContext, HashStable))] pub enum Mutability { // N.B. Order is deliberate, so that Not < Mut Not, @@ -303,10 +288,7 @@ impl Mutability { } #[derive(Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Debug, Copy)] -#[cfg_attr( - feature = "nightly", - derive(Encodable_NoContext, Decodable_NoContext, HashStable_NoContext) -)] +#[cfg_attr(feature = "nightly", derive(Encodable_NoContext, Decodable_NoContext, HashStable))] pub enum Pinnedness { Not, Pinned, diff --git a/compiler/rustc_codegen_cranelift/src/driver/aot.rs b/compiler/rustc_codegen_cranelift/src/driver/aot.rs index c74e0b9b1a669..cb65067c7a69a 100644 --- a/compiler/rustc_codegen_cranelift/src/driver/aot.rs +++ b/compiler/rustc_codegen_cranelift/src/driver/aot.rs @@ -14,7 +14,7 @@ use rustc_codegen_ssa::back::write::produce_final_output_artifacts; use rustc_codegen_ssa::base::determine_cgu_reuse; use rustc_codegen_ssa::{CompiledModule, CompiledModules, ModuleKind}; use rustc_data_structures::profiling::SelfProfilerRef; -use rustc_data_structures::stable_hasher::{HashStable, StableHasher}; +use rustc_data_structures::stable_hasher::{HashStable, HashStableContext, StableHasher}; use rustc_data_structures::sync::{IntoDynSyncSend, par_map}; use rustc_hir::attrs::Linkage as RLinkage; use rustc_middle::dep_graph::{WorkProduct, WorkProductId}; @@ -45,8 +45,8 @@ enum OngoingModuleCodegen { Async(JoinHandle>), } -impl HashStable for OngoingModuleCodegen { - fn hash_stable(&self, _: &mut Hcx, _: &mut StableHasher) { +impl HashStable for OngoingModuleCodegen { + fn hash_stable(&self, _: &mut Hcx, _: &mut StableHasher) { // do nothing } } diff --git a/compiler/rustc_codegen_ssa/src/common.rs b/compiler/rustc_codegen_ssa/src/common.rs index de79acd165f0f..c963bb9de4b42 100644 --- a/compiler/rustc_codegen_ssa/src/common.rs +++ b/compiler/rustc_codegen_ssa/src/common.rs @@ -98,12 +98,12 @@ pub enum TypeKind { // for now we content ourselves with providing a no-op HashStable // implementation for CGUs. mod temp_stable_hash_impls { - use rustc_data_structures::stable_hasher::{HashStable, StableHasher}; + use rustc_data_structures::stable_hasher::{HashStable, HashStableContext, StableHasher}; use crate::ModuleCodegen; - impl HashStable for ModuleCodegen { - fn hash_stable(&self, _: &mut Hcx, _: &mut StableHasher) { + impl HashStable for ModuleCodegen { + fn hash_stable(&self, _: &mut Hcx, _: &mut StableHasher) { // do nothing } } diff --git a/compiler/rustc_data_structures/src/intern.rs b/compiler/rustc_data_structures/src/intern.rs index e196ff0941594..419cdc115518c 100644 --- a/compiler/rustc_data_structures/src/intern.rs +++ b/compiler/rustc_data_structures/src/intern.rs @@ -4,7 +4,7 @@ use std::hash::{Hash, Hasher}; use std::ops::Deref; use std::ptr; -use crate::stable_hasher::{HashStable, StableHasher}; +use crate::stable_hasher::{HashStable, HashStableContext, StableHasher}; mod private { #[derive(Clone, Copy, Debug)] @@ -103,11 +103,11 @@ where } } -impl HashStable for Interned<'_, T> +impl HashStable for Interned<'_, T> where - T: HashStable, + T: HashStable, { - fn hash_stable(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { + fn hash_stable(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { self.0.hash_stable(hcx, hasher); } } diff --git a/compiler/rustc_data_structures/src/packed.rs b/compiler/rustc_data_structures/src/packed.rs index eef25331987da..30f76cb4476c5 100644 --- a/compiler/rustc_data_structures/src/packed.rs +++ b/compiler/rustc_data_structures/src/packed.rs @@ -3,7 +3,7 @@ use std::fmt; use rustc_serialize::{Decodable, Decoder, Encodable, Encoder}; -use crate::stable_hasher::{HashStable, StableHasher}; +use crate::stable_hasher::{HashStable, HashStableContext, StableHasher}; /// A packed 128-bit integer. Useful for reducing the size of structures in /// some cases. @@ -60,9 +60,9 @@ impl fmt::UpperHex for Pu128 { } } -impl HashStable for Pu128 { +impl HashStable for Pu128 { #[inline] - fn hash_stable(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { + fn hash_stable(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { { self.0 }.hash_stable(hcx, hasher) } } diff --git a/compiler/rustc_data_structures/src/sorted_map.rs b/compiler/rustc_data_structures/src/sorted_map.rs index 49c5272bd8568..ca813a36059ba 100644 --- a/compiler/rustc_data_structures/src/sorted_map.rs +++ b/compiler/rustc_data_structures/src/sorted_map.rs @@ -7,7 +7,7 @@ use std::ops::{Bound, Index, IndexMut, RangeBounds}; use rustc_macros::{Decodable_NoContext, Encodable_NoContext}; -use crate::stable_hasher::{HashStable, StableHasher, StableOrd}; +use crate::stable_hasher::{HashStable, HashStableContext, StableHasher, StableOrd}; mod index_map; @@ -347,9 +347,9 @@ impl FromIterator<(K, V)> for SortedMap { } } -impl + StableOrd, V: HashStable, Hcx> HashStable for SortedMap { +impl HashStable for SortedMap { #[inline] - fn hash_stable(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { + fn hash_stable(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { self.data.hash_stable(hcx, hasher); } } diff --git a/compiler/rustc_data_structures/src/sorted_map/index_map.rs b/compiler/rustc_data_structures/src/sorted_map/index_map.rs index 30485a289b6b7..b688601fd5d25 100644 --- a/compiler/rustc_data_structures/src/sorted_map/index_map.rs +++ b/compiler/rustc_data_structures/src/sorted_map/index_map.rs @@ -3,7 +3,7 @@ use std::hash::{Hash, Hasher}; use rustc_index::{Idx, IndexVec}; -use rustc_macros::HashStable_NoContext; +use rustc_macros::HashStable; /// An indexed multi-map that preserves insertion order while permitting both *O*(log *n*) lookup of /// an item by key and *O*(1) lookup by index. @@ -23,7 +23,7 @@ use rustc_macros::HashStable_NoContext; /// in-place. /// /// [`SortedMap`]: super::SortedMap -#[derive(Clone, Debug, HashStable_NoContext)] +#[derive(Clone, Debug, HashStable)] pub struct SortedIndexMultiMap { /// The elements of the map in insertion order. items: IndexVec, diff --git a/compiler/rustc_data_structures/src/stable_hasher.rs b/compiler/rustc_data_structures/src/stable_hasher.rs index ce3d781712515..6054f96e28b00 100644 --- a/compiler/rustc_data_structures/src/stable_hasher.rs +++ b/compiler/rustc_data_structures/src/stable_hasher.rs @@ -15,7 +15,42 @@ pub use rustc_stable_hash::{ FromStableHash, SipHasher128Hash as StableHasherHash, StableSipHasher128 as StableHasher, }; -/// Something that implements `HashStable` can be hashed in a way that is +/// This trait lets `HashStable` and `derive(HashStable)` be used in +/// this crate (and other crates upstream of `rustc_middle`), while leaving +/// certain operations to be defined in `rustc_middle` where more things are +/// visible. +pub trait HashStableContext { + /// The main event: stable hashing of a span. + fn span_hash_stable(&mut self, span: RawSpan, hasher: &mut StableHasher); + + /// Compute a `DefPathHash`. + fn def_path_hash(&self, def_id: RawDefId) -> RawDefPathHash; + + /// Get the hashing controls. + fn hashing_controls(&self) -> HashingControls; + + /// Assert that the provided `HashStableContext` is configured with the default + /// `HashingControls`. We should always have bailed out before getting to here with a + fn assert_default_hashing_controls(&self, msg: &str); +} + +// A type used to work around `Span` not being visible in this crate. It is the same layout as +// `Span`. +pub struct RawSpan(pub u32, pub u16, pub u16); + +// A type used to work around `DefId` not being visible in this crate. It is the same size as +// `DefId`. +pub struct RawDefId { + _data: u64, +} + +// A type used to work around `DefPathHash` not being visible in this crate. It is the same size as +// `DefPathHash`. +pub struct RawDefPathHash { + _data: u128, +} + +/// Something that implements `HashStable` can be hashed in a way that is /// stable across multiple compilation sessions. /// /// Note that `HashStable` imposes rather more strict requirements than usual @@ -41,16 +76,16 @@ pub use rustc_stable_hash::{ /// - `hash_stable()` must be independent of the host architecture. The /// `StableHasher` takes care of endianness and `isize`/`usize` platform /// differences. -pub trait HashStable { - fn hash_stable(&self, hcx: &mut Hcx, hasher: &mut StableHasher); +pub trait HashStable { + fn hash_stable(&self, hcx: &mut Hcx, hasher: &mut StableHasher); } /// Implement this for types that can be turned into stable keys like, for /// example, for DefId that can be converted to a DefPathHash. This is used for /// bringing maps into a predictable order before hashing them. -pub trait ToStableHashKey { - type KeyType: Ord + Sized + HashStable; - fn to_stable_hash_key(&self, hcx: &mut Hcx) -> Self::KeyType; +pub trait ToStableHashKey { + type KeyType: Ord + Sized + HashStable; + fn to_stable_hash_key(&self, hcx: &mut Hcx) -> Self::KeyType; } /// Trait for marking a type as having a sort order that is @@ -133,12 +168,16 @@ impl StableCompare for T { /// for examples). Therefore this macro is not exported and should only be used in the limited cases /// here in this module. /// -/// Use `#[derive(HashStable_Generic)]` instead. +/// Use `#[derive(HashStable)]` instead. macro_rules! impl_stable_traits_for_trivial_type { ($t:ty) => { - impl $crate::stable_hasher::HashStable for $t { + impl $crate::stable_hasher::HashStable for $t { #[inline] - fn hash_stable(&self, _: &mut Hcx, hasher: &mut $crate::stable_hasher::StableHasher) { + fn hash_stable( + &self, + _: &mut Hcx, + hasher: &mut $crate::stable_hasher::StableHasher, + ) { ::std::hash::Hash::hash(self, hasher); } } @@ -177,9 +216,9 @@ impl_stable_traits_for_trivial_type!(Hash64); // We need a custom impl as the default hash function will only hash half the bits. For stable // hashing we want to hash the full 128-bit hash. -impl HashStable for Hash128 { +impl HashStable for Hash128 { #[inline] - fn hash_stable(&self, _: &mut Hcx, hasher: &mut StableHasher) { + fn hash_stable(&self, _: &mut Hcx, hasher: &mut StableHasher) { self.as_u128().hash(hasher); } } @@ -192,61 +231,61 @@ impl StableOrd for Hash128 { const THIS_IMPLEMENTATION_HAS_BEEN_TRIPLE_CHECKED: () = (); } -impl HashStable for ! { - fn hash_stable(&self, _hcx: &mut Hcx, _hasher: &mut StableHasher) { +impl HashStable for ! { + fn hash_stable(&self, _hcx: &mut Hcx, _hasher: &mut StableHasher) { unreachable!() } } -impl HashStable for PhantomData { - fn hash_stable(&self, _hcx: &mut Hcx, _hasher: &mut StableHasher) {} +impl HashStable for PhantomData { + fn hash_stable(&self, _hcx: &mut Hcx, _hasher: &mut StableHasher) {} } -impl HashStable for NonZero { +impl HashStable for NonZero { #[inline] - fn hash_stable(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { + fn hash_stable(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { self.get().hash_stable(hcx, hasher) } } -impl HashStable for NonZero { +impl HashStable for NonZero { #[inline] - fn hash_stable(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { + fn hash_stable(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { self.get().hash_stable(hcx, hasher) } } -impl HashStable for f32 { - fn hash_stable(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { +impl HashStable for f32 { + fn hash_stable(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { let val: u32 = self.to_bits(); val.hash_stable(hcx, hasher); } } -impl HashStable for f64 { - fn hash_stable(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { +impl HashStable for f64 { + fn hash_stable(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { let val: u64 = self.to_bits(); val.hash_stable(hcx, hasher); } } -impl HashStable for ::std::cmp::Ordering { +impl HashStable for ::std::cmp::Ordering { #[inline] - fn hash_stable(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { + fn hash_stable(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { (*self as i8).hash_stable(hcx, hasher); } } -impl, Hcx> HashStable for (T1,) { +impl HashStable for (T1,) { #[inline] - fn hash_stable(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { + fn hash_stable(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { let (ref _0,) = *self; _0.hash_stable(hcx, hasher); } } -impl, T2: HashStable, Hcx> HashStable for (T1, T2) { - fn hash_stable(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { +impl HashStable for (T1, T2) { + fn hash_stable(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { let (ref _0, ref _1) = *self; _0.hash_stable(hcx, hasher); _1.hash_stable(hcx, hasher); @@ -261,13 +300,13 @@ impl StableOrd for (T1, T2) { const THIS_IMPLEMENTATION_HAS_BEEN_TRIPLE_CHECKED: () = (); } -impl HashStable for (T1, T2, T3) +impl HashStable for (T1, T2, T3) where - T1: HashStable, - T2: HashStable, - T3: HashStable, + T1: HashStable, + T2: HashStable, + T3: HashStable, { - fn hash_stable(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { + fn hash_stable(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { let (ref _0, ref _1, ref _2) = *self; _0.hash_stable(hcx, hasher); _1.hash_stable(hcx, hasher); @@ -284,14 +323,14 @@ impl StableOrd for (T1, T2, T3) { const THIS_IMPLEMENTATION_HAS_BEEN_TRIPLE_CHECKED: () = (); } -impl HashStable for (T1, T2, T3, T4) +impl HashStable for (T1, T2, T3, T4) where - T1: HashStable, - T2: HashStable, - T3: HashStable, - T4: HashStable, + T1: HashStable, + T2: HashStable, + T3: HashStable, + T4: HashStable, { - fn hash_stable(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { + fn hash_stable(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { let (ref _0, ref _1, ref _2, ref _3) = *self; _0.hash_stable(hcx, hasher); _1.hash_stable(hcx, hasher); @@ -311,8 +350,12 @@ impl StableOrd for ( const THIS_IMPLEMENTATION_HAS_BEEN_TRIPLE_CHECKED: () = (); } -impl, Hcx> HashStable for [T] { - default fn hash_stable(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { +impl HashStable for [T] { + default fn hash_stable( + &self, + hcx: &mut Hcx, + hasher: &mut StableHasher, + ) { self.len().hash_stable(hcx, hasher); for item in self { item.hash_stable(hcx, hasher); @@ -320,28 +363,28 @@ impl, Hcx> HashStable for [T] { } } -impl HashStable for [u8] { - fn hash_stable(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { +impl HashStable for [u8] { + fn hash_stable(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { self.len().hash_stable(hcx, hasher); hasher.write(self); } } -impl, Hcx> HashStable for Vec { +impl HashStable for Vec { #[inline] - fn hash_stable(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { + fn hash_stable(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { self[..].hash_stable(hcx, hasher); } } -impl HashStable for indexmap::IndexMap +impl HashStable for indexmap::IndexMap where - K: HashStable + Eq + Hash, - V: HashStable, + K: HashStable + Eq + Hash, + V: HashStable, R: BuildHasher, { #[inline] - fn hash_stable(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { + fn hash_stable(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { self.len().hash_stable(hcx, hasher); for kv in self { kv.hash_stable(hcx, hasher); @@ -349,13 +392,13 @@ where } } -impl HashStable for indexmap::IndexSet +impl HashStable for indexmap::IndexSet where - K: HashStable + Eq + Hash, + K: HashStable + Eq + Hash, R: BuildHasher, { #[inline] - fn hash_stable(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { + fn hash_stable(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { self.len().hash_stable(hcx, hasher); for key in self { key.hash_stable(hcx, hasher); @@ -363,40 +406,40 @@ where } } -impl HashStable for SmallVec<[A; N]> +impl HashStable for SmallVec<[A; N]> where - A: HashStable, + A: HashStable, { #[inline] - fn hash_stable(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { + fn hash_stable(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { self[..].hash_stable(hcx, hasher); } } -impl, Hcx> HashStable for Box { +impl HashStable for Box { #[inline] - fn hash_stable(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { + fn hash_stable(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { (**self).hash_stable(hcx, hasher); } } -impl, Hcx> HashStable for ::std::rc::Rc { +impl HashStable for ::std::rc::Rc { #[inline] - fn hash_stable(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { + fn hash_stable(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { (**self).hash_stable(hcx, hasher); } } -impl, Hcx> HashStable for ::std::sync::Arc { +impl HashStable for ::std::sync::Arc { #[inline] - fn hash_stable(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { + fn hash_stable(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { (**self).hash_stable(hcx, hasher); } } -impl HashStable for str { +impl HashStable for str { #[inline] - fn hash_stable(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { + fn hash_stable(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { self.as_bytes().hash_stable(hcx, hasher); } } @@ -409,9 +452,9 @@ impl StableOrd for &str { const THIS_IMPLEMENTATION_HAS_BEEN_TRIPLE_CHECKED: () = (); } -impl HashStable for String { +impl HashStable for String { #[inline] - fn hash_stable(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { + fn hash_stable(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { self[..].hash_stable(hcx, hasher); } } @@ -424,25 +467,25 @@ impl StableOrd for String { const THIS_IMPLEMENTATION_HAS_BEEN_TRIPLE_CHECKED: () = (); } -impl ToStableHashKey for String { +impl ToStableHashKey for String { type KeyType = String; #[inline] - fn to_stable_hash_key(&self, _: &mut Hcx) -> Self::KeyType { + fn to_stable_hash_key(&self, _: &mut Hcx) -> Self::KeyType { self.clone() } } -impl, T2: ToStableHashKey> ToStableHashKey for (T1, T2) { +impl ToStableHashKey for (T1, T2) { type KeyType = (T1::KeyType, T2::KeyType); #[inline] - fn to_stable_hash_key(&self, hcx: &mut Hcx) -> Self::KeyType { + fn to_stable_hash_key(&self, hcx: &mut Hcx) -> Self::KeyType { (self.0.to_stable_hash_key(hcx), self.1.to_stable_hash_key(hcx)) } } -impl HashStable for bool { +impl HashStable for bool { #[inline] - fn hash_stable(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { + fn hash_stable(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { (if *self { 1u8 } else { 0u8 }).hash_stable(hcx, hasher); } } @@ -454,12 +497,12 @@ impl StableOrd for bool { const THIS_IMPLEMENTATION_HAS_BEEN_TRIPLE_CHECKED: () = (); } -impl HashStable for Option +impl HashStable for Option where - T: HashStable, + T: HashStable, { #[inline] - fn hash_stable(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { + fn hash_stable(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { if let Some(ref value) = *self { 1u8.hash_stable(hcx, hasher); value.hash_stable(hcx, hasher); @@ -476,13 +519,13 @@ impl StableOrd for Option { const THIS_IMPLEMENTATION_HAS_BEEN_TRIPLE_CHECKED: () = (); } -impl HashStable for Result +impl HashStable for Result where - T1: HashStable, - T2: HashStable, + T1: HashStable, + T2: HashStable, { #[inline] - fn hash_stable(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { + fn hash_stable(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { mem::discriminant(self).hash_stable(hcx, hasher); match *self { Ok(ref x) => x.hash_stable(hcx, hasher), @@ -491,39 +534,39 @@ where } } -impl<'a, T, Hcx> HashStable for &'a T +impl<'a, T> HashStable for &'a T where - T: HashStable + ?Sized, + T: HashStable + ?Sized, { #[inline] - fn hash_stable(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { + fn hash_stable(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { (**self).hash_stable(hcx, hasher); } } -impl HashStable for ::std::mem::Discriminant { +impl HashStable for ::std::mem::Discriminant { #[inline] - fn hash_stable(&self, _: &mut Hcx, hasher: &mut StableHasher) { + fn hash_stable(&self, _: &mut Hcx, hasher: &mut StableHasher) { ::std::hash::Hash::hash(self, hasher); } } -impl HashStable for ::std::ops::RangeInclusive +impl HashStable for ::std::ops::RangeInclusive where - T: HashStable, + T: HashStable, { #[inline] - fn hash_stable(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { + fn hash_stable(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { self.start().hash_stable(hcx, hasher); self.end().hash_stable(hcx, hasher); } } -impl HashStable for IndexSlice +impl HashStable for IndexSlice where - T: HashStable, + T: HashStable, { - fn hash_stable(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { + fn hash_stable(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { self.len().hash_stable(hcx, hasher); for v in &self.raw { v.hash_stable(hcx, hasher); @@ -531,11 +574,11 @@ where } } -impl HashStable for IndexVec +impl HashStable for IndexVec where - T: HashStable, + T: HashStable, { - fn hash_stable(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { + fn hash_stable(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { self.len().hash_stable(hcx, hasher); for v in &self.raw { v.hash_stable(hcx, hasher); @@ -543,14 +586,14 @@ where } } -impl HashStable for DenseBitSet { - fn hash_stable(&self, _hcx: &mut Hcx, hasher: &mut StableHasher) { +impl HashStable for DenseBitSet { + fn hash_stable(&self, _hcx: &mut Hcx, hasher: &mut StableHasher) { ::std::hash::Hash::hash(self, hasher); } } -impl HashStable for bit_set::BitMatrix { - fn hash_stable(&self, _hcx: &mut Hcx, hasher: &mut StableHasher) { +impl HashStable for bit_set::BitMatrix { + fn hash_stable(&self, _hcx: &mut Hcx, hasher: &mut StableHasher) { ::std::hash::Hash::hash(self, hasher); } } @@ -563,15 +606,15 @@ impl_stable_traits_for_trivial_type!(::std::path::PathBuf); // It is not safe to implement HashStable for HashSet, HashMap or any other collection type // with unstable but observable iteration order. // See https://github.com/rust-lang/compiler-team/issues/533 for further information. -impl !HashStable for std::collections::HashSet {} -impl !HashStable for std::collections::HashMap {} +impl !HashStable for std::collections::HashSet {} +impl !HashStable for std::collections::HashMap {} -impl HashStable for ::std::collections::BTreeMap +impl HashStable for ::std::collections::BTreeMap where - K: HashStable + StableOrd, - V: HashStable, + K: HashStable + StableOrd, + V: HashStable, { - fn hash_stable(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { + fn hash_stable(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { self.len().hash_stable(hcx, hasher); for entry in self.iter() { entry.hash_stable(hcx, hasher); @@ -579,11 +622,11 @@ where } } -impl HashStable for ::std::collections::BTreeSet +impl HashStable for ::std::collections::BTreeSet where - K: HashStable + StableOrd, + K: HashStable + StableOrd, { - fn hash_stable(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { + fn hash_stable(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { self.len().hash_stable(hcx, hasher); for entry in self.iter() { entry.hash_stable(hcx, hasher); diff --git a/compiler/rustc_data_structures/src/stable_hasher/tests.rs b/compiler/rustc_data_structures/src/stable_hasher/tests.rs index 55a666d2d0fc2..da12d7ed7876b 100644 --- a/compiler/rustc_data_structures/src/stable_hasher/tests.rs +++ b/compiler/rustc_data_structures/src/stable_hasher/tests.rs @@ -7,10 +7,25 @@ use super::*; // ways). The expected values depend on the hashing algorithm used, so they // need to be updated whenever StableHasher changes its hashing algorithm. -fn hash>(t: &T) -> Hash128 { +impl HashStableContext for () { + fn span_hash_stable(&mut self, _: RawSpan, _: &mut StableHasher) { + panic!(); + } + fn def_path_hash(&self, _: RawDefId) -> RawDefPathHash { + panic!(); + } + fn hashing_controls(&self) -> HashingControls { + panic!(); + } + fn assert_default_hashing_controls(&self, _: &str) { + panic!(); + } +} + +fn hash(t: &T) -> Hash128 { let mut h = StableHasher::new(); - let ctx = &mut (); - t.hash_stable(ctx, &mut h); + let hcx = &mut (); + t.hash_stable(hcx, &mut h); h.finish() } @@ -44,8 +59,12 @@ fn test_attribute_permutation() { b: $ty, } - impl HashStable for Foo { - fn hash_stable(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { + impl HashStable for Foo { + fn hash_stable( + &self, + hcx: &mut Hcx, + hasher: &mut StableHasher, + ) { self.a.hash_stable(hcx, hasher); self.b.hash_stable(hcx, hasher); } diff --git a/compiler/rustc_data_structures/src/steal.rs b/compiler/rustc_data_structures/src/steal.rs index 184acfe8ca1a6..8e55323873951 100644 --- a/compiler/rustc_data_structures/src/steal.rs +++ b/compiler/rustc_data_structures/src/steal.rs @@ -1,4 +1,4 @@ -use crate::stable_hasher::{HashStable, StableHasher}; +use crate::stable_hasher::{HashStable, HashStableContext, StableHasher}; use crate::sync::{MappedReadGuard, MappedWriteGuard, ReadGuard, RwLock, WriteGuard}; /// The `Steal` struct is intended to used as the value for a query. @@ -71,8 +71,8 @@ impl Steal { } } -impl> HashStable for Steal { - fn hash_stable(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { +impl HashStable for Steal { + fn hash_stable(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { self.borrow().hash_stable(hcx, hasher); } } diff --git a/compiler/rustc_data_structures/src/svh.rs b/compiler/rustc_data_structures/src/svh.rs index 68b224676aec7..e64793f0778f7 100644 --- a/compiler/rustc_data_structures/src/svh.rs +++ b/compiler/rustc_data_structures/src/svh.rs @@ -7,7 +7,7 @@ use std::fmt; -use rustc_macros::{Decodable_NoContext, Encodable_NoContext, HashStable_NoContext}; +use rustc_macros::{Decodable_NoContext, Encodable_NoContext, HashStable}; use crate::fingerprint::Fingerprint; @@ -20,7 +20,7 @@ use crate::fingerprint::Fingerprint; Encodable_NoContext, Decodable_NoContext, Hash, - HashStable_NoContext + HashStable )] pub struct Svh { hash: Fingerprint, diff --git a/compiler/rustc_data_structures/src/tagged_ptr.rs b/compiler/rustc_data_structures/src/tagged_ptr.rs index 32f8138110895..d5cc78dd9221d 100644 --- a/compiler/rustc_data_structures/src/tagged_ptr.rs +++ b/compiler/rustc_data_structures/src/tagged_ptr.rs @@ -12,7 +12,7 @@ use std::ops::Deref; use std::ptr::NonNull; use crate::aligned::Aligned; -use crate::stable_hasher::{HashStable, StableHasher}; +use crate::stable_hasher::{HashStable, HashStableContext, StableHasher}; /// This describes tags that the [`TaggedRef`] struct can hold. /// @@ -262,12 +262,12 @@ impl Hash for TaggedRef<'_, P, T> { } } -impl<'a, P, T, Hcx> HashStable for TaggedRef<'a, P, T> +impl<'a, P, T> HashStable for TaggedRef<'a, P, T> where - P: HashStable + Aligned + ?Sized, - T: Tag + HashStable, + P: HashStable + Aligned + ?Sized, + T: Tag + HashStable, { - fn hash_stable(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { + fn hash_stable(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { self.pointer().hash_stable(hcx, hasher); self.tag().hash_stable(hcx, hasher); } diff --git a/compiler/rustc_data_structures/src/tagged_ptr/tests.rs b/compiler/rustc_data_structures/src/tagged_ptr/tests.rs index e663df5105f95..a1c53ef854326 100644 --- a/compiler/rustc_data_structures/src/tagged_ptr/tests.rs +++ b/compiler/rustc_data_structures/src/tagged_ptr/tests.rs @@ -32,8 +32,12 @@ unsafe impl Tag for Tag2 { } } -impl crate::stable_hasher::HashStable for Tag2 { - fn hash_stable(&self, hcx: &mut Hcx, hasher: &mut crate::stable_hasher::StableHasher) { +impl HashStable for Tag2 { + fn hash_stable( + &self, + hcx: &mut Hcx, + hasher: &mut crate::stable_hasher::StableHasher, + ) { (*self as u8).hash_stable(hcx, hasher); } } diff --git a/compiler/rustc_data_structures/src/unord.rs b/compiler/rustc_data_structures/src/unord.rs index b0550f0a4f698..4c033065abe3d 100644 --- a/compiler/rustc_data_structures/src/unord.rs +++ b/compiler/rustc_data_structures/src/unord.rs @@ -12,7 +12,9 @@ use rustc_macros::{Decodable_NoContext, Encodable_NoContext}; use crate::fingerprint::Fingerprint; use crate::fx::{FxBuildHasher, FxHashMap, FxHashSet}; -use crate::stable_hasher::{HashStable, StableCompare, StableHasher, ToStableHashKey}; +use crate::stable_hasher::{ + HashStable, HashStableContext, StableCompare, StableHasher, ToStableHashKey, +}; /// `UnordItems` is the order-less version of `Iterator`. It only contains methods /// that don't (easily) expose an ordering of the underlying items. @@ -143,9 +145,9 @@ impl<'a, T: Copy + 'a, I: Iterator> UnordItems<&'a T, I> { impl> UnordItems { #[inline] - pub fn into_sorted(self, hcx: &mut Hcx) -> Vec + pub fn into_sorted(self, hcx: &mut Hcx) -> Vec where - T: ToStableHashKey, + T: ToStableHashKey, { self.collect_sorted(hcx, true) } @@ -170,7 +172,8 @@ impl> UnordItems { #[inline] pub fn collect_sorted(self, hcx: &mut Hcx, cache_sort_key: bool) -> C where - T: ToStableHashKey, + Hcx: HashStableContext, + T: ToStableHashKey, C: FromIterator + BorrowMut<[T]>, { let mut items: C = self.0.collect(); @@ -317,7 +320,8 @@ impl UnordSet { #[inline] pub fn to_sorted(&self, hcx: &mut Hcx, cache_sort_key: bool) -> Vec<&V> where - V: ToStableHashKey, + Hcx: HashStableContext, + V: ToStableHashKey, { to_sorted_vec(hcx, self.inner.iter(), cache_sort_key, |&x| x) } @@ -359,7 +363,8 @@ impl UnordSet { #[inline] pub fn into_sorted(self, hcx: &mut Hcx, cache_sort_key: bool) -> Vec where - V: ToStableHashKey, + Hcx: HashStableContext, + V: ToStableHashKey, { to_sorted_vec(hcx, self.inner.into_iter(), cache_sort_key, |x| x) } @@ -415,9 +420,9 @@ impl> From> for UnordSet } } -impl> HashStable for UnordSet { +impl HashStable for UnordSet { #[inline] - fn hash_stable(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { + fn hash_stable(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { hash_iter_order_independent(self.inner.iter(), hcx, hasher); } } @@ -557,7 +562,8 @@ impl UnordMap { #[inline] pub fn to_sorted(&self, hcx: &mut Hcx, cache_sort_key: bool) -> Vec<(&K, &V)> where - K: ToStableHashKey, + Hcx: HashStableContext, + K: ToStableHashKey, { to_sorted_vec(hcx, self.inner.iter(), cache_sort_key, |&(k, _)| k) } @@ -584,7 +590,8 @@ impl UnordMap { #[inline] pub fn into_sorted(self, hcx: &mut Hcx, cache_sort_key: bool) -> Vec<(K, V)> where - K: ToStableHashKey, + Hcx: HashStableContext, + K: ToStableHashKey, { to_sorted_vec(hcx, self.inner.into_iter(), cache_sort_key, |(k, _)| k) } @@ -616,7 +623,8 @@ impl UnordMap { cache_sort_key: bool, ) -> impl Iterator where - K: ToStableHashKey, + Hcx: HashStableContext, + K: ToStableHashKey, { to_sorted_vec(hcx, self.inner.iter(), cache_sort_key, |&(k, _)| k) .into_iter() @@ -642,9 +650,9 @@ where } } -impl, V: HashStable> HashStable for UnordMap { +impl HashStable for UnordMap { #[inline] - fn hash_stable(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { + fn hash_stable(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { hash_iter_order_independent(self.inner.iter(), hcx, hasher); } } @@ -705,9 +713,9 @@ impl> From> for UnordBag { } } -impl> HashStable for UnordBag { +impl HashStable for UnordBag { #[inline] - fn hash_stable(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { + fn hash_stable(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { hash_iter_order_independent(self.inner.iter(), hcx, hasher); } } @@ -720,8 +728,9 @@ fn to_sorted_vec( extract_key: fn(&T) -> &K, ) -> Vec where + Hcx: HashStableContext, I: Iterator, - K: ToStableHashKey, + K: ToStableHashKey, { let mut items: Vec = iter.collect(); if cache_sort_key { @@ -734,8 +743,8 @@ where } fn hash_iter_order_independent< - Hcx, - T: HashStable, + Hcx: HashStableContext, + T: HashStable, I: Iterator + ExactSizeIterator, >( mut it: I, diff --git a/compiler/rustc_feature/src/unstable.rs b/compiler/rustc_feature/src/unstable.rs index 859a1ad391cb9..3aa494a752b8a 100644 --- a/compiler/rustc_feature/src/unstable.rs +++ b/compiler/rustc_feature/src/unstable.rs @@ -5,6 +5,7 @@ use std::time::{SystemTime, UNIX_EPOCH}; use rustc_data_structures::AtomicRef; use rustc_data_structures::fx::FxHashSet; +use rustc_data_structures::stable_hasher::{HashStable, HashStableContext, StableHasher}; use rustc_span::{Span, Symbol, sym}; use super::{Feature, to_nonzero}; @@ -119,6 +120,32 @@ impl Features { } } +impl HashStable for Features { + fn hash_stable(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { + // Unfortunately we cannot exhaustively list fields here, since the + // struct has private fields (to ensure its invariant is maintained) + self.enabled_lang_features().hash_stable(hcx, hasher); + self.enabled_lib_features().hash_stable(hcx, hasher); + } +} + +impl HashStable for EnabledLangFeature { + fn hash_stable(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { + let EnabledLangFeature { gate_name, attr_sp, stable_since } = self; + gate_name.hash_stable(hcx, hasher); + attr_sp.hash_stable(hcx, hasher); + stable_since.hash_stable(hcx, hasher); + } +} + +impl HashStable for EnabledLibFeature { + fn hash_stable(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { + let EnabledLibFeature { gate_name, attr_sp } = self; + gate_name.hash_stable(hcx, hasher); + attr_sp.hash_stable(hcx, hasher); + } +} + macro_rules! declare_features { ($( $(#[doc = $doc:tt])* ($status:ident, $feature:ident, $ver:expr, $issue:expr), diff --git a/compiler/rustc_hir/src/attrs/data_structures.rs b/compiler/rustc_hir/src/attrs/data_structures.rs index f18d5a1f190a2..f82c17b4948c1 100644 --- a/compiler/rustc_hir/src/attrs/data_structures.rs +++ b/compiler/rustc_hir/src/attrs/data_structures.rs @@ -12,7 +12,7 @@ use rustc_ast::{AttrStyle, Path, ast}; use rustc_data_structures::fx::FxIndexMap; use rustc_error_messages::{DiagArgValue, IntoDiagArg}; use rustc_hir::LangItem; -use rustc_macros::{Decodable, Encodable, HashStable_Generic, PrintAttribute}; +use rustc_macros::{Decodable, Encodable, HashStable, PrintAttribute}; use rustc_span::def_id::DefId; use rustc_span::hygiene::Transparency; use rustc_span::{ErrorGuaranteed, Ident, Span, Symbol, sym}; @@ -26,7 +26,7 @@ use crate::{ DefaultBodyStability, HashIgnoredAttrId, PartialConstStability, RustcVersion, Stability, }; -#[derive(Copy, Clone, Debug, HashStable_Generic, Encodable, Decodable, PrintAttribute)] +#[derive(Copy, Clone, Debug, HashStable, Encodable, Decodable, PrintAttribute)] pub enum EiiImplResolution { /// Usually, finding the extern item that an EII implementation implements means finding /// the defid of the associated attribute macro, and looking at *its* attributes to find @@ -39,7 +39,7 @@ pub enum EiiImplResolution { Error(ErrorGuaranteed), } -#[derive(Copy, Clone, Debug, HashStable_Generic, Encodable, Decodable, PrintAttribute)] +#[derive(Copy, Clone, Debug, HashStable, Encodable, Decodable, PrintAttribute)] pub struct EiiImpl { pub resolution: EiiImplResolution, pub impl_marked_unsafe: bool, @@ -48,7 +48,7 @@ pub struct EiiImpl { pub is_default: bool, } -#[derive(Copy, Clone, Debug, HashStable_Generic, Encodable, Decodable, PrintAttribute)] +#[derive(Copy, Clone, Debug, HashStable, Encodable, Decodable, PrintAttribute)] pub struct EiiDecl { pub foreign_item: DefId, /// whether or not it is unsafe to implement this EII @@ -56,7 +56,7 @@ pub struct EiiDecl { pub name: Ident, } -#[derive(Copy, Clone, PartialEq, Encodable, Decodable, Debug, HashStable_Generic, PrintAttribute)] +#[derive(Copy, Clone, PartialEq, Encodable, Decodable, Debug, HashStable, PrintAttribute)] pub enum CguKind { No, PreDashLto, @@ -64,7 +64,7 @@ pub enum CguKind { Any, } -#[derive(Copy, Clone, PartialEq, Encodable, Decodable, Debug, HashStable_Generic, PrintAttribute)] +#[derive(Copy, Clone, PartialEq, Encodable, Decodable, Debug, HashStable, PrintAttribute)] pub enum CguFields { PartitionReused { cfg: Symbol, module: Symbol }, PartitionCodegened { cfg: Symbol, module: Symbol }, @@ -72,7 +72,7 @@ pub enum CguFields { } #[derive(Copy, Clone, PartialEq, Debug, PrintAttribute)] -#[derive(HashStable_Generic, Encodable, Decodable)] +#[derive(HashStable, Encodable, Decodable)] pub enum DivergingFallbackBehavior { /// Always fallback to `()` (aka "always spontaneous decay") ToUnit, @@ -84,7 +84,7 @@ pub enum DivergingFallbackBehavior { } #[derive(Copy, Clone, PartialEq, Debug, PrintAttribute, Default)] -#[derive(HashStable_Generic, Encodable, Decodable)] +#[derive(HashStable, Encodable, Decodable)] pub enum DivergingBlockBehavior { /// This is the current stable behavior: /// @@ -107,7 +107,7 @@ pub enum DivergingBlockBehavior { Unit, } -#[derive(Copy, Clone, PartialEq, Encodable, Decodable, Debug, HashStable_Generic, PrintAttribute)] +#[derive(Copy, Clone, PartialEq, Encodable, Decodable, Debug, HashStable, PrintAttribute)] pub enum InlineAttr { None, Hint, @@ -131,24 +131,14 @@ impl InlineAttr { } } -#[derive( - Copy, - Clone, - Encodable, - Decodable, - Debug, - PartialEq, - Eq, - HashStable_Generic, - PrintAttribute -)] +#[derive(Copy, Clone, Encodable, Decodable, Debug, PartialEq, Eq, HashStable, PrintAttribute)] pub enum InstructionSetAttr { ArmA32, ArmT32, } #[derive(Copy, Clone, Debug, PartialEq, Eq, Default, PrintAttribute)] -#[derive(Encodable, Decodable, HashStable_Generic)] +#[derive(Encodable, Decodable, HashStable)] pub enum OptimizeAttr { /// No `#[optimize(..)]` attribute #[default] @@ -167,7 +157,7 @@ impl OptimizeAttr { } } -#[derive(PartialEq, Debug, Encodable, Decodable, Copy, Clone, HashStable_Generic, PrintAttribute)] +#[derive(PartialEq, Debug, Encodable, Decodable, Copy, Clone, HashStable, PrintAttribute)] pub enum ReprAttr { ReprInt(IntType), ReprRust, @@ -184,13 +174,13 @@ pub enum TransparencyError { } #[derive(Eq, PartialEq, Debug, Copy, Clone)] -#[derive(Encodable, Decodable, HashStable_Generic, PrintAttribute)] +#[derive(Encodable, Decodable, HashStable, PrintAttribute)] pub enum IntType { SignedInt(ast::IntTy), UnsignedInt(ast::UintTy), } -#[derive(Copy, Debug, Encodable, Decodable, Clone, HashStable_Generic, PrintAttribute)] +#[derive(Copy, Debug, Encodable, Decodable, Clone, HashStable, PrintAttribute)] pub struct Deprecation { pub since: DeprecatedSince, /// The note to issue a reason. @@ -202,7 +192,7 @@ pub struct Deprecation { } /// Release in which an API is deprecated. -#[derive(Copy, Debug, Encodable, Decodable, Clone, HashStable_Generic, PrintAttribute)] +#[derive(Copy, Debug, Encodable, Decodable, Clone, HashStable, PrintAttribute)] pub enum DeprecatedSince { RustcVersion(RustcVersion), /// Deprecated in the future ("to be determined"). @@ -219,7 +209,7 @@ pub enum DeprecatedSince { /// Successfully-parsed value of a `#[coverage(..)]` attribute. #[derive(Copy, Debug, Eq, PartialEq, Encodable, Decodable, Clone)] -#[derive(HashStable_Generic, PrintAttribute)] +#[derive(HashStable, PrintAttribute)] pub enum CoverageAttrKind { On, Off, @@ -227,7 +217,7 @@ pub enum CoverageAttrKind { /// Successfully-parsed value of a `#[rustc_abi(..)]` attribute. #[derive(Copy, Debug, Eq, PartialEq, Encodable, Decodable, Clone)] -#[derive(HashStable_Generic, PrintAttribute)] +#[derive(HashStable, PrintAttribute)] pub enum RustcAbiAttrKind { Debug, AssertEq, @@ -258,7 +248,7 @@ impl Deprecation { /// `#[used(compiler)]` /// `#[used(linker)]` #[derive(Encodable, Decodable, Copy, Clone, Debug, PartialEq, Eq, Hash)] -#[derive(HashStable_Generic, PrintAttribute)] +#[derive(HashStable, PrintAttribute)] pub enum UsedBy { Default, Compiler, @@ -266,7 +256,7 @@ pub enum UsedBy { } #[derive(Encodable, Decodable, Clone, Debug, PartialEq, Eq, Hash)] -#[derive(HashStable_Generic, PrintAttribute)] +#[derive(HashStable, PrintAttribute)] pub enum MacroUseArgs { UseAll, UseSpecific(ThinVec), @@ -278,7 +268,7 @@ impl Default for MacroUseArgs { } } -#[derive(Debug, Clone, Encodable, Decodable, HashStable_Generic)] +#[derive(Debug, Clone, Encodable, Decodable, HashStable)] pub struct StrippedCfgItem { pub parent_scope: ScopeId, pub ident: Ident, @@ -296,7 +286,7 @@ impl StrippedCfgItem { /// /// See for more details about these variants. #[derive(Encodable, Decodable, Clone, Copy, Debug, PartialEq, Eq, Hash)] -#[derive(HashStable_Generic, PrintAttribute)] +#[derive(HashStable, PrintAttribute)] pub enum Linkage { AvailableExternally, Common, @@ -310,7 +300,7 @@ pub enum Linkage { } #[derive(Clone, Copy, Decodable, Debug, Encodable, PartialEq)] -#[derive(HashStable_Generic, PrintAttribute)] +#[derive(HashStable, PrintAttribute)] pub enum MirDialect { Analysis, Built, @@ -329,7 +319,7 @@ impl IntoDiagArg for MirDialect { } #[derive(Clone, Copy, Decodable, Debug, Encodable, PartialEq)] -#[derive(HashStable_Generic, PrintAttribute)] +#[derive(HashStable, PrintAttribute)] pub enum MirPhase { Initial, PostCleanup, @@ -349,17 +339,7 @@ impl IntoDiagArg for MirPhase { /// Different ways that the PE Format can decorate a symbol name. /// From -#[derive( - Copy, - Clone, - Debug, - Encodable, - Decodable, - HashStable_Generic, - PartialEq, - Eq, - PrintAttribute -)] +#[derive(Copy, Clone, Debug, Encodable, Decodable, HashStable, PartialEq, Eq, PrintAttribute)] pub enum PeImportNameType { /// IMPORT_ORDINAL /// Uses the ordinal (i.e., a number) rather than the name. @@ -389,7 +369,7 @@ pub enum PeImportNameType { Decodable, PrintAttribute )] -#[derive(HashStable_Generic)] +#[derive(HashStable)] pub enum NativeLibKind { /// Static library (e.g. `libfoo.a` on Linux or `foo.lib` on Windows/MSVC) Static { @@ -457,7 +437,7 @@ impl NativeLibKind { } } -#[derive(Debug, Encodable, Decodable, Clone, HashStable_Generic, PrintAttribute)] +#[derive(Debug, Encodable, Decodable, Clone, HashStable, PrintAttribute)] pub struct LinkEntry { pub span: Span, pub kind: NativeLibKind, @@ -467,14 +447,14 @@ pub struct LinkEntry { pub import_name_type: Option<(PeImportNameType, Span)>, } -#[derive(HashStable_Generic, PrintAttribute)] +#[derive(HashStable, PrintAttribute)] #[derive(Copy, PartialEq, PartialOrd, Clone, Ord, Eq, Hash, Debug, Encodable, Decodable)] pub enum DebuggerVisualizerType { Natvis, GdbPrettyPrinter, } -#[derive(Debug, Encodable, Decodable, Clone, HashStable_Generic, PrintAttribute)] +#[derive(Debug, Encodable, Decodable, Clone, HashStable, PrintAttribute)] pub struct DebugVisualizer { pub span: Span, pub visualizer_type: DebuggerVisualizerType, @@ -482,7 +462,7 @@ pub struct DebugVisualizer { } #[derive(Clone, Copy, Debug, Decodable, Encodable, Eq, PartialEq)] -#[derive(HashStable_Generic, PrintAttribute)] +#[derive(HashStable, PrintAttribute)] #[derive_const(Default)] pub enum RtsanSetting { Nonblocking, @@ -492,7 +472,7 @@ pub enum RtsanSetting { } #[derive(Eq, PartialEq, Debug, Copy, Clone)] -#[derive(Encodable, Decodable, HashStable_Generic, PrintAttribute)] +#[derive(Encodable, Decodable, HashStable, PrintAttribute)] pub enum WindowsSubsystemKind { Console, Windows, @@ -508,20 +488,20 @@ impl WindowsSubsystemKind { } #[derive(Copy, Clone, Debug, PartialEq)] -#[derive(HashStable_Generic, Encodable, Decodable, PrintAttribute)] +#[derive(HashStable, Encodable, Decodable, PrintAttribute)] pub enum DocInline { Inline, NoInline, } #[derive(Copy, Clone, Debug, PartialEq)] -#[derive(HashStable_Generic, Encodable, Decodable, PrintAttribute)] +#[derive(HashStable, Encodable, Decodable, PrintAttribute)] pub enum HideOrShow { Hide, Show, } -#[derive(Clone, Debug, HashStable_Generic, Encodable, Decodable, PrintAttribute)] +#[derive(Clone, Debug, HashStable, Encodable, Decodable, PrintAttribute)] pub struct CfgInfo { pub name: Symbol, pub name_span: Span, @@ -538,13 +518,13 @@ impl CfgInfo { } } -#[derive(Clone, Debug, HashStable_Generic, Encodable, Decodable, PrintAttribute)] +#[derive(Clone, Debug, HashStable, Encodable, Decodable, PrintAttribute)] pub struct CfgHideShow { pub kind: HideOrShow, pub values: ThinVec, } -#[derive(Clone, Debug, Default, HashStable_Generic, Decodable, PrintAttribute)] +#[derive(Clone, Debug, Default, HashStable, Decodable, PrintAttribute)] pub struct DocAttribute { pub aliases: FxIndexMap, pub hidden: Option, @@ -644,7 +624,7 @@ impl rustc_serialize::Encodable for DocAttribute /// | external | no | if-ext | if-ext | yes | /// | yes | yes | yes | yes | yes | #[derive(Copy, Clone, Debug, Hash, PartialEq)] -#[derive(HashStable_Generic, Encodable, Decodable, PrintAttribute)] +#[derive(HashStable, Encodable, Decodable, PrintAttribute)] pub enum CollapseMacroDebuginfo { /// Don't collapse debuginfo for the macro No = 0, @@ -658,7 +638,7 @@ pub enum CollapseMacroDebuginfo { /// Crate type, as specified by `#![crate_type]` #[derive(Copy, Clone, Debug, Hash, PartialEq, Default, PartialOrd, Eq, Ord)] -#[derive(HashStable_Generic, Encodable, Decodable, PrintAttribute)] +#[derive(HashStable, Encodable, Decodable, PrintAttribute)] pub enum CrateType { /// `#![crate_type = "bin"]` Executable, @@ -758,7 +738,7 @@ impl IntoDiagArg for CrateType { } } -#[derive(Clone, Debug, HashStable_Generic, Encodable, Decodable, PrintAttribute)] +#[derive(Clone, Debug, HashStable, Encodable, Decodable, PrintAttribute)] pub enum RustcLayoutType { Abi, Align, @@ -767,7 +747,7 @@ pub enum RustcLayoutType { Debug, } -#[derive(Clone, Debug, HashStable_Generic, Encodable, Decodable, PrintAttribute, PartialEq, Eq)] +#[derive(Clone, Debug, HashStable, Encodable, Decodable, PrintAttribute, PartialEq, Eq)] pub enum RustcMirKind { PeekMaybeInit, PeekMaybeUninit, @@ -777,13 +757,13 @@ pub enum RustcMirKind { BorrowckGraphvizFormat { format: BorrowckGraphvizFormatKind }, } -#[derive(Clone, Debug, HashStable_Generic, Encodable, Decodable, PrintAttribute, PartialEq, Eq)] +#[derive(Clone, Debug, HashStable, Encodable, Decodable, PrintAttribute, PartialEq, Eq)] pub enum BorrowckGraphvizFormatKind { TwoPhase, } #[derive(Clone, Debug, PartialEq, Eq)] -#[derive(HashStable_Generic, Encodable, Decodable, PrintAttribute)] +#[derive(HashStable, Encodable, Decodable, PrintAttribute)] pub struct RustcCleanAttribute { pub span: Span, pub cfg: Symbol, @@ -793,14 +773,14 @@ pub struct RustcCleanAttribute { /// Represents the `except=` or `loaded_from_disk=` argument of `#[rustc_clean]` #[derive(Clone, Debug, PartialEq, Eq)] -#[derive(HashStable_Generic, Encodable, Decodable, PrintAttribute)] +#[derive(HashStable, Encodable, Decodable, PrintAttribute)] pub struct RustcCleanQueries { pub entries: ThinVec, pub span: Span, } #[derive(Clone, Debug, PartialEq, Eq)] -#[derive(HashStable_Generic, Encodable, Decodable, PrintAttribute)] +#[derive(HashStable, Encodable, Decodable, PrintAttribute)] pub struct RustcAutodiff { /// Conceptually either forward or reverse mode AD, as described in various autodiff papers and /// e.g. in the [JAX @@ -876,7 +856,7 @@ impl RustcAutodiff { } /// We generate one of these structs for each `#[autodiff(...)]` attribute. -#[derive(Clone, Eq, PartialEq, Encodable, Decodable, Debug, HashStable_Generic)] +#[derive(Clone, Eq, PartialEq, Encodable, Decodable, Debug, HashStable)] pub struct AutoDiffItem { /// The name of the function getting differentiated pub source: String, @@ -896,7 +876,7 @@ impl fmt::Display for AutoDiffItem { } } -#[derive(Clone, Debug, HashStable_Generic, Encodable, Decodable, PrintAttribute)] +#[derive(Clone, Debug, HashStable, Encodable, Decodable, PrintAttribute)] pub struct LintAttribute { /// See RFC #2383 pub reason: Option, @@ -908,7 +888,7 @@ pub struct LintAttribute { pub lint_instances: ThinVec, } -#[derive(Debug, Clone, Encodable, Decodable, HashStable_Generic)] +#[derive(Debug, Clone, Encodable, Decodable, HashStable)] pub struct LintInstance { /// The span of the `MetaItem` that produced this `LintInstance` span: Span, @@ -1006,13 +986,13 @@ impl LintInstance { } } -#[derive(Debug, Clone, PrintAttribute, Encodable, Decodable, HashStable_Generic)] +#[derive(Debug, Clone, PrintAttribute, Encodable, Decodable, HashStable)] enum LintAttrTool { Present { tool_name: Symbol, full_lint: Symbol }, NoTool, } -#[derive(Clone, Copy, Debug, HashStable_Generic, Encodable, Decodable, PrintAttribute, PartialEq)] +#[derive(Clone, Copy, Debug, HashStable, Encodable, Decodable, PrintAttribute, PartialEq)] pub enum LintAttributeKind { Allow, Deny, @@ -1082,7 +1062,7 @@ impl LintAttributeKind { /// [`rustc_parse`]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_parse/index.html /// [`rustc_codegen_ssa`]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_codegen_ssa/index.html /// [`rustc_attr_parsing`]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_attr_parsing/index.html -#[derive(Clone, Debug, HashStable_Generic, Encodable, Decodable, PrintAttribute)] +#[derive(Clone, Debug, HashStable, Encodable, Decodable, PrintAttribute)] pub enum AttributeKind { // tidy-alphabetical-start /// Represents `#[allow_internal_unsafe]`. diff --git a/compiler/rustc_hir/src/attrs/diagnostic.rs b/compiler/rustc_hir/src/attrs/diagnostic.rs index 66cdf2be8fc4d..5cea004b01185 100644 --- a/compiler/rustc_hir/src/attrs/diagnostic.rs +++ b/compiler/rustc_hir/src/attrs/diagnostic.rs @@ -3,14 +3,14 @@ use std::fmt; use std::fmt::Debug; pub use rustc_ast::attr::data_structures::*; -use rustc_macros::{Decodable, Encodable, HashStable_Generic, PrintAttribute}; +use rustc_macros::{Decodable, Encodable, HashStable, PrintAttribute}; use rustc_span::{DesugaringKind, Span, Symbol, kw}; use thin_vec::ThinVec; use tracing::debug; use crate::attrs::PrintAttribute; -#[derive(Clone, Default, Debug, HashStable_Generic, Encodable, Decodable, PrintAttribute)] +#[derive(Clone, Default, Debug, HashStable, Encodable, Decodable, PrintAttribute)] pub struct Directive { pub is_rustc_attr: bool, pub condition: Option, @@ -123,7 +123,7 @@ pub struct CustomDiagnostic { /// Like [std::fmt::Arguments] this is a string that has been parsed into "pieces", /// either as string pieces or dynamic arguments. -#[derive(Clone, Debug, HashStable_Generic, Encodable, Decodable, PrintAttribute)] +#[derive(Clone, Debug, HashStable, Encodable, Decodable, PrintAttribute)] pub struct FormatString { pub input: Symbol, pub span: Span, @@ -224,13 +224,13 @@ pub struct FormatArgs { pub generic_args: Vec<(Symbol, String)>, } -#[derive(Clone, Debug, HashStable_Generic, Encodable, Decodable, PrintAttribute)] +#[derive(Clone, Debug, HashStable, Encodable, Decodable, PrintAttribute)] pub enum Piece { Lit(Symbol), Arg(FormatArg), } -#[derive(Clone, Debug, HashStable_Generic, Encodable, Decodable, PrintAttribute)] +#[derive(Clone, Debug, HashStable, Encodable, Decodable, PrintAttribute)] pub enum FormatArg { // A generic parameter, like `{T}` if we're on the `From` trait. GenericParam { @@ -250,7 +250,7 @@ pub enum FormatArg { } /// Represents the `on` filter in `#[rustc_on_unimplemented]`. -#[derive(Clone, Debug, HashStable_Generic, Encodable, Decodable, PrintAttribute)] +#[derive(Clone, Debug, HashStable, Encodable, Decodable, PrintAttribute)] pub struct OnUnimplementedCondition { pub span: Span, pub pred: Predicate, @@ -275,7 +275,7 @@ impl OnUnimplementedCondition { /// /// It is similar to the predicate in the `cfg` attribute, /// and may contain nested predicates. -#[derive(Clone, Debug, HashStable_Generic, Encodable, Decodable, PrintAttribute)] +#[derive(Clone, Debug, HashStable, Encodable, Decodable, PrintAttribute)] pub enum Predicate { /// A condition like `on(crate_local)`. Flag(Flag), @@ -313,7 +313,7 @@ impl Predicate { } /// Represents a `MetaWord` in an `on`-filter. -#[derive(Clone, Copy, Debug, HashStable_Generic, Encodable, Decodable, PrintAttribute)] +#[derive(Clone, Copy, Debug, HashStable, Encodable, Decodable, PrintAttribute)] pub enum Flag { /// Whether the code causing the trait bound to not be fulfilled /// is part of the user's crate. @@ -328,7 +328,7 @@ pub enum Flag { /// A `MetaNameValueStr` in an `on`-filter. /// /// For example, `#[rustc_on_unimplemented(on(name = "value", message = "hello"))]`. -#[derive(Clone, Debug, HashStable_Generic, Encodable, Decodable, PrintAttribute)] +#[derive(Clone, Debug, HashStable, Encodable, Decodable, PrintAttribute)] pub struct NameValue { pub name: Name, /// Something like `"&str"` or `"alloc::string::String"`, @@ -347,7 +347,7 @@ impl NameValue { } /// The valid names of the `on` filter. -#[derive(Clone, Copy, Debug, HashStable_Generic, Encodable, Decodable, PrintAttribute)] +#[derive(Clone, Copy, Debug, HashStable, Encodable, Decodable, PrintAttribute)] pub enum Name { Cause, FromDesugaring, @@ -367,7 +367,7 @@ pub enum FlagOrNv<'p> { /// If it is a simple literal like this then `pieces` will be `[LitOrArg::Lit("value")]`. /// The `Arg` variant is used when it contains formatting like /// `#[rustc_on_unimplemented(on(Self = "&[{A}]", message = "hello"))]`. -#[derive(Clone, Debug, HashStable_Generic, Encodable, Decodable, PrintAttribute)] +#[derive(Clone, Debug, HashStable, Encodable, Decodable, PrintAttribute)] pub struct FilterFormatString { pub pieces: ThinVec, } @@ -399,7 +399,7 @@ impl FilterFormatString { } } -#[derive(Clone, Debug, HashStable_Generic, Encodable, Decodable, PrintAttribute)] +#[derive(Clone, Debug, HashStable, Encodable, Decodable, PrintAttribute)] pub enum LitOrArg { Lit(Symbol), Arg(Symbol), diff --git a/compiler/rustc_hir/src/def.rs b/compiler/rustc_hir/src/def.rs index ec701cbe9a469..863e066f845f0 100644 --- a/compiler/rustc_hir/src/def.rs +++ b/compiler/rustc_hir/src/def.rs @@ -7,16 +7,16 @@ use rustc_ast::NodeId; use rustc_data_structures::stable_hasher::ToStableHashKey; use rustc_data_structures::unord::UnordMap; use rustc_error_messages::{DiagArgValue, IntoDiagArg}; -use rustc_macros::{Decodable, Encodable, HashStable_Generic}; +use rustc_macros::{Decodable, Encodable, HashStable}; +use rustc_span::Symbol; use rustc_span::def_id::{DefId, LocalDefId}; use rustc_span::hygiene::MacroKind; -use rustc_span::{HashStableContext, Symbol}; use crate::definitions::DefPathData; use crate::hir; /// Encodes if a `DefKind::Ctor` is the constructor of an enum variant or a struct. -#[derive(Clone, Copy, PartialEq, Eq, Encodable, Decodable, Hash, Debug, HashStable_Generic)] +#[derive(Clone, Copy, PartialEq, Eq, Encodable, Decodable, Hash, Debug, HashStable)] pub enum CtorOf { /// This `DefKind::Ctor` is a synthesized constructor of a tuple or unit struct. Struct, @@ -25,7 +25,7 @@ pub enum CtorOf { } /// What kind of constructor something is. -#[derive(Clone, Copy, PartialEq, Eq, Encodable, Decodable, Hash, Debug, HashStable_Generic)] +#[derive(Clone, Copy, PartialEq, Eq, Encodable, Decodable, Hash, Debug, HashStable)] pub enum CtorKind { /// Constructor function automatically created by a tuple struct/variant. Fn, @@ -35,7 +35,7 @@ pub enum CtorKind { /// A set of macro kinds, for macros that can have more than one kind #[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Encodable, Decodable, Hash, Debug)] -#[derive(HashStable_Generic)] +#[derive(HashStable)] pub struct MacroKinds(u8); bitflags::bitflags! { impl MacroKinds: u8 { @@ -81,7 +81,7 @@ impl MacroKinds { } /// An attribute that is not a macro; e.g., `#[inline]` or `#[rustfmt::skip]`. -#[derive(Clone, Copy, PartialEq, Eq, Encodable, Decodable, Hash, Debug, HashStable_Generic)] +#[derive(Clone, Copy, PartialEq, Eq, Encodable, Decodable, Hash, Debug, HashStable)] pub enum NonMacroAttrKind { /// Single-segment attribute defined by the language (`#[inline]`) Builtin(Symbol), @@ -96,7 +96,7 @@ pub enum NonMacroAttrKind { /// What kind of definition something is; e.g., `mod` vs `struct`. /// `enum DefPathData` may need to be updated if a new variant is added here. -#[derive(Clone, Copy, PartialEq, Eq, Encodable, Decodable, Hash, Debug, HashStable_Generic)] +#[derive(Clone, Copy, PartialEq, Eq, Encodable, Decodable, Hash, Debug, HashStable)] pub enum DefKind { // Type namespace Mod, @@ -511,7 +511,7 @@ impl DefKind { /// - 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. // -#[derive(Clone, Copy, PartialEq, Eq, Encodable, Decodable, Hash, Debug, HashStable_Generic)] +#[derive(Clone, Copy, PartialEq, Eq, Encodable, Decodable, Hash, Debug, HashStable)] pub enum Res { /// Definition having a unique ID (`DefId`), corresponds to something defined in user code. /// @@ -679,7 +679,7 @@ impl PartialRes { /// Different kinds of symbols can coexist even if they share the same textual name. /// Therefore, they each have a separate universe (known as a "namespace"). #[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Debug, Encodable, Decodable)] -#[derive(HashStable_Generic)] +#[derive(HashStable)] pub enum Namespace { /// The type namespace includes `struct`s, `enum`s, `union`s, `trait`s, and `mod`s /// (and, by extension, crates). @@ -712,17 +712,17 @@ impl IntoDiagArg for Namespace { } } -impl ToStableHashKey for Namespace { +impl ToStableHashKey for Namespace { type KeyType = Namespace; #[inline] - fn to_stable_hash_key(&self, _: &mut Hcx) -> Namespace { + fn to_stable_hash_key(&self, _: &mut Hcx) -> Namespace { *self } } /// Just a helper ‒ separate structure for each namespace. -#[derive(Copy, Clone, Default, Debug, HashStable_Generic)] +#[derive(Copy, Clone, Default, Debug, HashStable)] pub struct PerNS { pub value_ns: T, pub type_ns: T, diff --git a/compiler/rustc_hir/src/diagnostic_items.rs b/compiler/rustc_hir/src/diagnostic_items.rs index 5e0915de9d388..c19aeec659795 100644 --- a/compiler/rustc_hir/src/diagnostic_items.rs +++ b/compiler/rustc_hir/src/diagnostic_items.rs @@ -1,11 +1,11 @@ use rustc_data_structures::fx::FxIndexMap; -use rustc_macros::HashStable_Generic; +use rustc_macros::HashStable; use rustc_span::Symbol; use rustc_span::def_id::DefIdMap; use crate::def_id::DefId; -#[derive(Debug, Default, HashStable_Generic)] +#[derive(Debug, Default, HashStable)] pub struct DiagnosticItems { #[stable_hasher(ignore)] pub id_to_name: DefIdMap, diff --git a/compiler/rustc_hir/src/hir.rs b/compiler/rustc_hir/src/hir.rs index 71ef6c9a9c03c..37db24a955d8d 100644 --- a/compiler/rustc_hir/src/hir.rs +++ b/compiler/rustc_hir/src/hir.rs @@ -21,7 +21,7 @@ use rustc_data_structures::sorted_map::SortedMap; use rustc_data_structures::tagged_ptr::TaggedRef; use rustc_error_messages::{DiagArgValue, IntoDiagArg}; use rustc_index::IndexVec; -use rustc_macros::{Decodable, Encodable, HashStable_Generic}; +use rustc_macros::{Decodable, Encodable, HashStable}; use rustc_span::def_id::LocalDefId; use rustc_span::{ BytePos, DUMMY_SP, DesugaringKind, ErrorGuaranteed, Ident, Span, Spanned, Symbol, kw, sym, @@ -38,7 +38,7 @@ pub(crate) use crate::hir_id::{HirId, ItemLocalId, ItemLocalMap, OwnerId}; use crate::intravisit::{FnKind, VisitorExt}; use crate::lints::DelayedLints; -#[derive(Debug, Copy, Clone, PartialEq, Eq, HashStable_Generic)] +#[derive(Debug, Copy, Clone, PartialEq, Eq, HashStable)] pub enum AngleBrackets { /// E.g. `Path`. Missing, @@ -48,7 +48,7 @@ pub enum AngleBrackets { Full, } -#[derive(Debug, Copy, Clone, PartialEq, Eq, HashStable_Generic)] +#[derive(Debug, Copy, Clone, PartialEq, Eq, HashStable)] pub enum LifetimeSource { /// E.g. `&Type`, `&'_ Type`, `&'a Type`, `&mut Type`, `&'_ mut Type`, `&'a mut Type` Reference, @@ -72,7 +72,7 @@ pub enum LifetimeSource { Other, } -#[derive(Debug, Copy, Clone, PartialEq, Eq, HashStable_Generic)] +#[derive(Debug, Copy, Clone, PartialEq, Eq, HashStable)] pub enum LifetimeSyntax { /// E.g. `&Type`, `ContainsLifetime` Implicit, @@ -149,7 +149,7 @@ impl From for LifetimeSyntax { /// Some combinations that cannot occur are `LifetimeSyntax::Implicit` with /// `LifetimeSource::OutlivesBound` or `LifetimeSource::PreciseCapturing` /// — there's no way to "elide" these lifetimes. -#[derive(Debug, Copy, Clone, HashStable_Generic)] +#[derive(Debug, Copy, Clone, HashStable)] // Raise the alignment to at least 4 bytes. // This is relied on in other parts of the compiler (for pointer tagging): // @@ -179,7 +179,7 @@ pub struct Lifetime { pub syntax: LifetimeSyntax, } -#[derive(Debug, Copy, Clone, HashStable_Generic)] +#[derive(Debug, Copy, Clone, HashStable)] pub enum ParamName { /// Some user-given name like `T` or `'x`. Plain(Ident), @@ -217,7 +217,7 @@ impl ParamName { } } -#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash, HashStable_Generic)] +#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash, HashStable)] pub enum LifetimeKind { /// User-given names or fresh (synthetic) names. Param(LocalDefId), @@ -344,7 +344,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(Debug, Clone, Copy, HashStable_Generic)] +#[derive(Debug, Clone, Copy, HashStable)] pub struct Path<'hir, R = Res> { pub span: Span, /// The resolution for the path. @@ -364,7 +364,7 @@ impl Path<'_> { /// A segment of a path: an identifier, an optional lifetime, and a set of /// types. -#[derive(Debug, Clone, Copy, HashStable_Generic)] +#[derive(Debug, Clone, Copy, HashStable)] pub struct PathSegment<'hir> { /// The identifier portion of this path segment. pub ident: Ident, @@ -401,7 +401,7 @@ impl<'hir> PathSegment<'hir> { } } -#[derive(Clone, Copy, Debug, HashStable_Generic)] +#[derive(Clone, Copy, Debug, HashStable)] pub enum ConstItemRhs<'hir> { Body(BodyId), TypeConst(&'hir ConstArg<'hir>), @@ -436,7 +436,7 @@ impl<'hir> ConstItemRhs<'hir> { /// /// For an explanation of the `Unambig` generic parameter see the dev-guide: /// -#[derive(Clone, Copy, Debug, HashStable_Generic)] +#[derive(Clone, Copy, Debug, HashStable)] #[repr(C)] pub struct ConstArg<'hir, Unambig = ()> { #[stable_hasher(ignore)] @@ -493,7 +493,7 @@ impl<'hir, Unambig> ConstArg<'hir, Unambig> { } /// See [`ConstArg`]. -#[derive(Clone, Copy, Debug, HashStable_Generic)] +#[derive(Clone, Copy, Debug, HashStable)] #[repr(u8, C)] pub enum ConstArgKind<'hir, Unambig = ()> { Tup(&'hir [&'hir ConstArg<'hir, Unambig>]), @@ -521,7 +521,7 @@ pub enum ConstArgKind<'hir, Unambig = ()> { }, } -#[derive(Clone, Copy, Debug, HashStable_Generic)] +#[derive(Clone, Copy, Debug, HashStable)] pub struct ConstArgExprField<'hir> { pub hir_id: HirId, pub span: Span, @@ -529,13 +529,13 @@ pub struct ConstArgExprField<'hir> { pub expr: &'hir ConstArg<'hir>, } -#[derive(Clone, Copy, Debug, HashStable_Generic)] +#[derive(Clone, Copy, Debug, HashStable)] pub struct ConstArgArrayExpr<'hir> { pub span: Span, pub elems: &'hir [&'hir ConstArg<'hir>], } -#[derive(Clone, Copy, Debug, HashStable_Generic)] +#[derive(Clone, Copy, Debug, HashStable)] pub struct InferArg { #[stable_hasher(ignore)] pub hir_id: HirId, @@ -548,7 +548,7 @@ impl InferArg { } } -#[derive(Debug, Clone, Copy, HashStable_Generic)] +#[derive(Debug, Clone, Copy, HashStable)] pub enum GenericArg<'hir> { Lifetime(&'hir Lifetime), Type(&'hir Ty<'hir, AmbigArg>), @@ -611,7 +611,7 @@ impl GenericArg<'_> { } /// The generic arguments and associated item constraints of a path segment. -#[derive(Debug, Clone, Copy, HashStable_Generic)] +#[derive(Debug, Clone, Copy, HashStable)] pub struct GenericArgs<'hir> { /// The generic arguments for this path segment. pub args: &'hir [GenericArg<'hir>], @@ -735,7 +735,7 @@ impl<'hir> GenericArgs<'hir> { } } -#[derive(Copy, Clone, PartialEq, Eq, Debug, HashStable_Generic)] +#[derive(Copy, Clone, PartialEq, Eq, Debug, HashStable)] pub enum GenericArgsParentheses { No, /// Bounds for `feature(return_type_notation)`, like `T: Trait`, @@ -746,7 +746,7 @@ pub enum GenericArgsParentheses { } /// The modifiers on a trait bound. -#[derive(Copy, Clone, PartialEq, Eq, Hash, Debug, HashStable_Generic)] +#[derive(Copy, Clone, PartialEq, Eq, Hash, Debug, HashStable)] pub struct TraitBoundModifiers { pub constness: BoundConstness, pub polarity: BoundPolarity, @@ -757,7 +757,7 @@ impl TraitBoundModifiers { TraitBoundModifiers { constness: BoundConstness::Never, polarity: BoundPolarity::Positive }; } -#[derive(Clone, Copy, Debug, HashStable_Generic)] +#[derive(Clone, Copy, Debug, HashStable)] pub enum GenericBound<'hir> { Trait(PolyTraitRef<'hir>), Outlives(&'hir Lifetime), @@ -783,7 +783,7 @@ impl GenericBound<'_> { pub type GenericBounds<'hir> = &'hir [GenericBound<'hir>]; -#[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash, HashStable_Generic, Debug)] +#[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash, HashStable, Debug)] pub enum MissingLifetimeKind { /// An explicit `'_`. Underscore, @@ -795,7 +795,7 @@ pub enum MissingLifetimeKind { Brackets, } -#[derive(Copy, Clone, Debug, HashStable_Generic)] +#[derive(Copy, Clone, Debug, HashStable)] pub enum LifetimeParamKind { // Indicates that the lifetime definition was explicitly declared (e.g., in // `fn foo<'a>(x: &'a u8) -> &'a u8 { x }`). @@ -809,7 +809,7 @@ pub enum LifetimeParamKind { Error, } -#[derive(Debug, Clone, Copy, HashStable_Generic)] +#[derive(Debug, Clone, Copy, HashStable)] pub enum GenericParamKind<'hir> { /// A lifetime definition (e.g., `'a: 'b + 'c + 'd`). Lifetime { @@ -826,7 +826,7 @@ pub enum GenericParamKind<'hir> { }, } -#[derive(Debug, Clone, Copy, HashStable_Generic)] +#[derive(Debug, Clone, Copy, HashStable)] pub struct GenericParam<'hir> { #[stable_hasher(ignore)] pub hir_id: HirId, @@ -865,7 +865,7 @@ impl<'hir> GenericParam<'hir> { /// early-bound (but can be a late-bound lifetime in functions, for example), /// or from a `for<...>` binder, in which case it's late-bound (and notably, /// does not show up in the parent item's generics). -#[derive(Debug, Clone, Copy, HashStable_Generic)] +#[derive(Debug, Clone, Copy, HashStable)] pub enum GenericParamSource { // Early or late-bound parameters defined on an item Generics, @@ -883,7 +883,7 @@ pub struct GenericParamCount { /// Represents lifetimes and type parameters attached to a declaration /// of a function, enum, trait, etc. -#[derive(Debug, Clone, Copy, HashStable_Generic)] +#[derive(Debug, Clone, Copy, HashStable)] pub struct Generics<'hir> { pub params: &'hir [GenericParam<'hir>], pub predicates: &'hir [WherePredicate<'hir>], @@ -1090,7 +1090,7 @@ impl<'hir> Generics<'hir> { } /// A single predicate in a where-clause. -#[derive(Debug, Clone, Copy, HashStable_Generic)] +#[derive(Debug, Clone, Copy, HashStable)] pub struct WherePredicate<'hir> { #[stable_hasher(ignore)] pub hir_id: HirId, @@ -1099,7 +1099,7 @@ pub struct WherePredicate<'hir> { } /// The kind of a single predicate in a where-clause. -#[derive(Debug, Clone, Copy, HashStable_Generic)] +#[derive(Debug, Clone, Copy, HashStable)] pub enum WherePredicateKind<'hir> { /// A type bound (e.g., `for<'c> Foo: Send + Clone + 'c`). BoundPredicate(WhereBoundPredicate<'hir>), @@ -1127,7 +1127,7 @@ impl<'hir> WherePredicateKind<'hir> { } } -#[derive(Copy, Clone, Debug, HashStable_Generic, PartialEq, Eq)] +#[derive(Copy, Clone, Debug, HashStable, PartialEq, Eq)] pub enum PredicateOrigin { WhereClause, GenericParam, @@ -1135,7 +1135,7 @@ pub enum PredicateOrigin { } /// A type bound (e.g., `for<'c> Foo: Send + Clone + 'c`). -#[derive(Debug, Clone, Copy, HashStable_Generic)] +#[derive(Debug, Clone, Copy, HashStable)] pub struct WhereBoundPredicate<'hir> { /// Origin of the predicate. pub origin: PredicateOrigin, @@ -1155,7 +1155,7 @@ impl<'hir> WhereBoundPredicate<'hir> { } /// A lifetime predicate (e.g., `'a: 'b + 'c`). -#[derive(Debug, Clone, Copy, HashStable_Generic)] +#[derive(Debug, Clone, Copy, HashStable)] pub struct WhereRegionPredicate<'hir> { pub in_where_clause: bool, pub lifetime: &'hir Lifetime, @@ -1170,7 +1170,7 @@ impl<'hir> WhereRegionPredicate<'hir> { } /// An equality predicate (e.g., `T = int`); currently unsupported. -#[derive(Debug, Clone, Copy, HashStable_Generic)] +#[derive(Debug, Clone, Copy, HashStable)] pub struct WhereEqPredicate<'hir> { pub lhs_ty: &'hir Ty<'hir>, pub rhs_ty: &'hir Ty<'hir>, @@ -1186,7 +1186,7 @@ pub struct ParentedNode<'tcx> { } /// Arguments passed to an attribute macro. -#[derive(Clone, Debug, HashStable_Generic, Encodable, Decodable)] +#[derive(Clone, Debug, HashStable, Encodable, Decodable)] pub enum AttrArgs { /// No arguments: `#[attr]`. Empty, @@ -1201,7 +1201,7 @@ pub enum AttrArgs { }, } -#[derive(Clone, Debug, HashStable_Generic, Encodable, Decodable)] +#[derive(Clone, Debug, HashStable, Encodable, Decodable)] pub struct AttrPath { pub segments: Box<[Symbol]>, pub span: Span, @@ -1237,7 +1237,7 @@ impl fmt::Display for AttrPath { } } -#[derive(Clone, Debug, HashStable_Generic, Encodable, Decodable)] +#[derive(Clone, Debug, HashStable, Encodable, Decodable)] pub struct AttrItem { // Not lowered to hir::Path because we have no NodeId to resolve to. pub path: AttrPath, @@ -1250,7 +1250,7 @@ pub struct AttrItem { pub span: Span, } -/// The derived implementation of [`HashStable_Generic`] on [`Attribute`]s shouldn't hash +/// The derived implementation of [`HashStable`] on [`Attribute`]s shouldn't hash /// [`AttrId`]s. By wrapping them in this, we make sure we never do. #[derive(Copy, Debug, Encodable, Decodable, Clone)] pub struct HashIgnoredAttrId { @@ -1259,7 +1259,7 @@ pub struct HashIgnoredAttrId { /// Many functions on this type have their documentation in the [`AttributeExt`] trait, /// since they defer their implementation directly to that trait. -#[derive(Clone, Debug, Encodable, Decodable, HashStable_Generic)] +#[derive(Clone, Debug, Encodable, Decodable, HashStable)] pub enum Attribute { /// A parsed built-in attribute. /// @@ -1631,7 +1631,7 @@ impl fmt::Debug for OwnerNodes<'_> { } /// Full information resulting from lowering an AST node. -#[derive(Debug, HashStable_Generic)] +#[derive(Debug, HashStable)] pub struct OwnerInfo<'hir> { /// Contents of the HIR. pub nodes: OwnerNodes<'hir>, @@ -1655,7 +1655,7 @@ impl<'tcx> OwnerInfo<'tcx> { } } -#[derive(Copy, Clone, Debug, HashStable_Generic)] +#[derive(Copy, Clone, Debug, HashStable)] pub enum MaybeOwner<'tcx> { Owner(&'tcx OwnerInfo<'tcx>), NonOwner(HirId), @@ -1676,7 +1676,7 @@ impl<'tcx> MaybeOwner<'tcx> { } } -#[derive(Debug, Clone, Copy, HashStable_Generic)] +#[derive(Debug, Clone, Copy, HashStable)] pub struct Closure<'hir> { pub def_id: LocalDefId, pub binder: ClosureBinder, @@ -1692,7 +1692,7 @@ pub struct Closure<'hir> { pub kind: ClosureKind, } -#[derive(Clone, PartialEq, Eq, Debug, Copy, Hash, HashStable_Generic, Encodable, Decodable)] +#[derive(Clone, PartialEq, Eq, Debug, Copy, Hash, HashStable, Encodable, Decodable)] pub enum ClosureKind { /// This is a plain closure expression. Closure, @@ -1711,7 +1711,7 @@ pub enum ClosureKind { /// A block of statements `{ .. }`, which may have a label (in this case the /// `targeted_by_break` field will be `true`) and may be `unsafe` by means of /// the `rules` being anything but `DefaultBlock`. -#[derive(Debug, Clone, Copy, HashStable_Generic)] +#[derive(Debug, Clone, Copy, HashStable)] pub struct Block<'hir> { /// Statements in a block. pub stmts: &'hir [Stmt<'hir>], @@ -1740,13 +1740,13 @@ impl<'hir> Block<'hir> { } } -#[derive(Debug, Clone, Copy, HashStable_Generic)] +#[derive(Debug, Clone, Copy, HashStable)] pub struct TyFieldPath { pub variant: Option, pub field: Ident, } -#[derive(Debug, Clone, Copy, HashStable_Generic)] +#[derive(Debug, Clone, Copy, HashStable)] pub struct TyPat<'hir> { #[stable_hasher(ignore)] pub hir_id: HirId, @@ -1754,7 +1754,7 @@ pub struct TyPat<'hir> { pub span: Span, } -#[derive(Debug, Clone, Copy, HashStable_Generic)] +#[derive(Debug, Clone, Copy, HashStable)] pub struct Pat<'hir> { #[stable_hasher(ignore)] pub hir_id: HirId, @@ -1902,7 +1902,7 @@ impl<'hir> Pat<'hir> { /// 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(Debug, Clone, Copy, HashStable_Generic)] +#[derive(Debug, Clone, Copy, HashStable)] pub struct PatField<'hir> { #[stable_hasher(ignore)] pub hir_id: HirId, @@ -1914,7 +1914,7 @@ pub struct PatField<'hir> { pub span: Span, } -#[derive(Copy, Clone, PartialEq, Debug, HashStable_Generic, Hash, Eq, Encodable, Decodable)] +#[derive(Copy, Clone, PartialEq, Debug, HashStable, Hash, Eq, Encodable, Decodable)] pub enum RangeEnd { Included, Excluded, @@ -1932,7 +1932,7 @@ impl fmt::Display for RangeEnd { // Equivalent to `Option`. That type takes up 16 bytes on 64-bit, but // this type only takes up 4 bytes, at the cost of being restricted to a // maximum value of `u32::MAX - 1`. In practice, this is more than enough. -#[derive(Clone, Copy, PartialEq, Eq, Hash, HashStable_Generic)] +#[derive(Clone, Copy, PartialEq, Eq, Hash, HashStable)] pub struct DotDotPos(u32); impl DotDotPos { @@ -1958,7 +1958,7 @@ impl fmt::Debug for DotDotPos { } } -#[derive(Debug, Clone, Copy, HashStable_Generic)] +#[derive(Debug, Clone, Copy, HashStable)] pub struct PatExpr<'hir> { #[stable_hasher(ignore)] pub hir_id: HirId, @@ -1966,7 +1966,7 @@ pub struct PatExpr<'hir> { pub kind: PatExprKind<'hir>, } -#[derive(Debug, Clone, Copy, HashStable_Generic)] +#[derive(Debug, Clone, Copy, HashStable)] pub enum PatExprKind<'hir> { Lit { lit: Lit, @@ -1976,7 +1976,7 @@ pub enum PatExprKind<'hir> { Path(QPath<'hir>), } -#[derive(Debug, Clone, Copy, HashStable_Generic)] +#[derive(Debug, Clone, Copy, HashStable)] pub enum TyPatKind<'hir> { /// A range pattern (e.g., `1..=2` or `1..2`). Range(&'hir ConstArg<'hir>, &'hir ConstArg<'hir>), @@ -1991,7 +1991,7 @@ pub enum TyPatKind<'hir> { Err(ErrorGuaranteed), } -#[derive(Debug, Clone, Copy, HashStable_Generic)] +#[derive(Debug, Clone, Copy, HashStable)] pub enum PatKind<'hir> { /// A missing pattern, e.g. for an anonymous param in a bare fn like `fn f(u32)`. Missing, @@ -2066,7 +2066,7 @@ pub enum PatKind<'hir> { } /// A statement. -#[derive(Debug, Clone, Copy, HashStable_Generic)] +#[derive(Debug, Clone, Copy, HashStable)] pub struct Stmt<'hir> { #[stable_hasher(ignore)] pub hir_id: HirId, @@ -2075,7 +2075,7 @@ pub struct Stmt<'hir> { } /// The contents of a statement. -#[derive(Debug, Clone, Copy, HashStable_Generic)] +#[derive(Debug, Clone, Copy, HashStable)] pub enum StmtKind<'hir> { /// A local (`let`) binding. Let(&'hir LetStmt<'hir>), @@ -2091,7 +2091,7 @@ pub enum StmtKind<'hir> { } /// Represents a `let` statement (i.e., `let : = ;`). -#[derive(Debug, Clone, Copy, HashStable_Generic)] +#[derive(Debug, Clone, Copy, HashStable)] pub struct LetStmt<'hir> { /// Span of `super` in `super let`. pub super_: Option, @@ -2113,7 +2113,7 @@ pub struct LetStmt<'hir> { /// Represents a single arm of a `match` expression, e.g. /// ` (if ) => `. -#[derive(Debug, Clone, Copy, HashStable_Generic)] +#[derive(Debug, Clone, Copy, HashStable)] pub struct Arm<'hir> { #[stable_hasher(ignore)] pub hir_id: HirId, @@ -2131,7 +2131,7 @@ pub struct Arm<'hir> { /// /// In an `if let`, imagine it as `if (let = ) { ... }`; in a let-else, it is part of /// the desugaring to if-let. Only let-else supports the type annotation at present. -#[derive(Debug, Clone, Copy, HashStable_Generic)] +#[derive(Debug, Clone, Copy, HashStable)] pub struct LetExpr<'hir> { pub span: Span, pub pat: &'hir Pat<'hir>, @@ -2142,7 +2142,7 @@ pub struct LetExpr<'hir> { pub recovered: ast::Recovered, } -#[derive(Debug, Clone, Copy, HashStable_Generic)] +#[derive(Debug, Clone, Copy, HashStable)] pub struct ExprField<'hir> { #[stable_hasher(ignore)] pub hir_id: HirId, @@ -2152,19 +2152,19 @@ pub struct ExprField<'hir> { pub is_shorthand: bool, } -#[derive(Copy, Clone, PartialEq, Debug, HashStable_Generic)] +#[derive(Copy, Clone, PartialEq, Debug, HashStable)] pub enum BlockCheckMode { DefaultBlock, UnsafeBlock(UnsafeSource), } -#[derive(Copy, Clone, PartialEq, Debug, HashStable_Generic)] +#[derive(Copy, Clone, PartialEq, Debug, HashStable)] pub enum UnsafeSource { CompilerGenerated, UserProvided, } -#[derive(Copy, Clone, PartialEq, Eq, Hash, Debug, HashStable_Generic)] +#[derive(Copy, Clone, PartialEq, Eq, Hash, Debug, HashStable)] pub struct BodyId { pub hir_id: HirId, } @@ -2190,7 +2190,7 @@ pub struct BodyId { /// /// All bodies have an **owner**, which can be accessed via the HIR /// map using `body_owner_def_id()`. -#[derive(Debug, Clone, Copy, HashStable_Generic)] +#[derive(Debug, Clone, Copy, HashStable)] pub struct Body<'hir> { pub params: &'hir [Param<'hir>], pub value: &'hir Expr<'hir>, @@ -2203,7 +2203,7 @@ impl<'hir> Body<'hir> { } /// The type of source expression that caused this coroutine to be created. -#[derive(Clone, PartialEq, Eq, Debug, Copy, Hash, HashStable_Generic, Encodable, Decodable)] +#[derive(Clone, PartialEq, Eq, Debug, Copy, Hash, HashStable, Encodable, Decodable)] pub enum CoroutineKind { /// A coroutine that comes from a desugaring. Desugared(CoroutineDesugaring, CoroutineSource), @@ -2253,7 +2253,7 @@ impl fmt::Display for CoroutineKind { /// /// This helps error messages but is also used to drive coercions in /// type-checking (see #60424). -#[derive(Clone, PartialEq, Eq, Hash, Debug, Copy, HashStable_Generic, Encodable, Decodable)] +#[derive(Clone, PartialEq, Eq, Hash, Debug, Copy, HashStable, Encodable, Decodable)] pub enum CoroutineSource { /// An explicit `async`/`gen` block written by the user. Block, @@ -2276,7 +2276,7 @@ impl fmt::Display for CoroutineSource { } } -#[derive(Clone, PartialEq, Eq, Debug, Copy, Hash, HashStable_Generic, Encodable, Decodable)] +#[derive(Clone, PartialEq, Eq, Debug, Copy, Hash, HashStable, Encodable, Decodable)] pub enum CoroutineDesugaring { /// An explicit `async` block or the body of an `async` function. Async, @@ -2416,7 +2416,7 @@ pub type Lit = Spanned; /// /// You can check if this anon const is a default in a const param /// `const N: usize = { ... }` with `tcx.hir_opt_const_param_default_param_def_id(..)` -#[derive(Copy, Clone, Debug, HashStable_Generic)] +#[derive(Copy, Clone, Debug, HashStable)] pub struct AnonConst { #[stable_hasher(ignore)] pub hir_id: HirId, @@ -2426,7 +2426,7 @@ pub struct AnonConst { } /// An inline constant expression `const { something }`. -#[derive(Copy, Clone, Debug, HashStable_Generic)] +#[derive(Copy, Clone, Debug, HashStable)] pub struct ConstBlock { #[stable_hasher(ignore)] pub hir_id: HirId, @@ -2442,7 +2442,7 @@ pub struct ConstBlock { /// the compiler and the reference. /// /// [rust lang reference]: https://doc.rust-lang.org/reference/expressions.html -#[derive(Debug, Clone, Copy, HashStable_Generic)] +#[derive(Debug, Clone, Copy, HashStable)] pub struct Expr<'hir> { #[stable_hasher(ignore)] pub hir_id: HirId, @@ -2801,7 +2801,7 @@ pub fn expr_needs_parens(expr: &Expr<'_>) -> bool { } } -#[derive(Debug, Clone, Copy, HashStable_Generic)] +#[derive(Debug, Clone, Copy, HashStable)] pub enum ExprKind<'hir> { /// Allow anonymous constants from an inline `const` block ConstBlock(ConstBlock), @@ -2940,7 +2940,7 @@ pub enum ExprKind<'hir> { Err(rustc_span::ErrorGuaranteed), } -#[derive(Debug, Clone, Copy, HashStable_Generic)] +#[derive(Debug, Clone, Copy, HashStable)] pub enum StructTailExpr<'hir> { /// A struct expression where all the fields are explicitly enumerated: `Foo { a, b }`. None, @@ -2964,7 +2964,7 @@ pub enum StructTailExpr<'hir> { /// To resolve the path to a `DefId`, call [`qpath_res`]. /// /// [`qpath_res`]: ../../rustc_middle/ty/struct.TypeckResults.html#method.qpath_res -#[derive(Debug, Clone, Copy, HashStable_Generic)] +#[derive(Debug, Clone, Copy, HashStable)] pub enum QPath<'hir> { /// Path to a definition, optionally "fully-qualified" with a `Self` /// type, if the path points to an associated item in a trait. @@ -3003,7 +3003,7 @@ impl<'hir> QPath<'hir> { } /// Hints at the original code for a let statement. -#[derive(Copy, Clone, Debug, HashStable_Generic)] +#[derive(Copy, Clone, Debug, HashStable)] pub enum LocalSource { /// A `match _ { .. }`. Normal, @@ -3027,7 +3027,7 @@ pub enum LocalSource { } /// Hints at the original code for a `match _ { .. }`. -#[derive(Copy, Clone, PartialEq, Eq, Hash, Debug, HashStable_Generic, Encodable, Decodable)] +#[derive(Copy, Clone, PartialEq, Eq, Hash, Debug, HashStable, Encodable, Decodable)] pub enum MatchSource { /// A `match _ { .. }`. Normal, @@ -3059,7 +3059,7 @@ impl MatchSource { } /// The loop type that yielded an `ExprKind::Loop`. -#[derive(Copy, Clone, PartialEq, Debug, HashStable_Generic)] +#[derive(Copy, Clone, PartialEq, Debug, HashStable)] pub enum LoopSource { /// A `loop { .. }` loop. Loop, @@ -3079,7 +3079,7 @@ impl LoopSource { } } -#[derive(Copy, Clone, Debug, PartialEq, HashStable_Generic)] +#[derive(Copy, Clone, Debug, PartialEq, HashStable)] pub enum LoopIdError { OutsideLoopScope, UnlabeledCfInWhileCondition, @@ -3098,7 +3098,7 @@ impl fmt::Display for LoopIdError { } } -#[derive(Copy, Clone, Debug, PartialEq, HashStable_Generic)] +#[derive(Copy, Clone, Debug, PartialEq, HashStable)] pub struct Destination { /// This is `Some(_)` iff there is an explicit user-specified 'label pub label: Option