diff --git a/.mailmap b/.mailmap index c29f6a66f5d7d..fa30f07ad7310 100644 --- a/.mailmap +++ b/.mailmap @@ -260,6 +260,7 @@ Grzegorz Bartoszek Guanqun Lu Guillaume Gomez Guillaume Gomez Guillaume Gomez +Guillaume Gomez ggomez Guillaume Gomez ggomez Guillaume Gomez Guillaume Gomez Guillaume Gomez Guillaume Gomez diff --git a/compiler/rustc_abi/src/callconv/reg.rs b/compiler/rustc_abi/src/callconv/reg.rs index 397fa7d653655..198b62d5fb475 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; +use rustc_macros::StableHash; use crate::{Align, HasDataLayout, Integer, Primitive, Size}; -#[cfg_attr(feature = "nightly", derive(HashStable))] +#[cfg_attr(feature = "nightly", derive(StableHash))] #[derive(Copy, Clone, PartialEq, Eq, Hash, Debug)] pub enum RegKind { Integer, @@ -16,7 +16,7 @@ pub enum RegKind { }, } -#[cfg_attr(feature = "nightly", derive(HashStable))] +#[cfg_attr(feature = "nightly", derive(StableHash))] #[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 fc81a5911edd4..3ef3fa365298c 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; +use rustc_macros::StableHash; 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))] +#[cfg_attr(feature = "nightly", derive(StableHash))] 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))] +#[cfg_attr(feature = "nightly", derive(StableHash))] 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))] +#[cfg_attr(feature = "nightly", derive(StableHash))] 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))] +#[cfg_attr(feature = "nightly", derive(StableHash))] pub enum ArmCall { Aapcs, CCmseNonSecureCall, diff --git a/compiler/rustc_abi/src/extern_abi.rs b/compiler/rustc_abi/src/extern_abi.rs index 9de25c4cec405..fbc009c4d57e4 100644 --- a/compiler/rustc_abi/src/extern_abi.rs +++ b/compiler/rustc_abi/src/extern_abi.rs @@ -3,9 +3,7 @@ use std::fmt; use std::hash::{Hash, Hasher}; #[cfg(feature = "nightly")] -use rustc_data_structures::stable_hasher::{ - HashStable, HashStableContext, StableHasher, StableOrd, -}; +use rustc_data_structures::stable_hasher::{StableHash, StableHashCtxt, StableHasher, StableOrd}; #[cfg(feature = "nightly")] use rustc_macros::{Decodable, Encodable}; #[cfg(feature = "nightly")] @@ -242,9 +240,9 @@ impl Hash for ExternAbi { } #[cfg(feature = "nightly")] -impl HashStable for ExternAbi { +impl StableHash for ExternAbi { #[inline] - fn hash_stable(&self, _: &mut Hcx, hasher: &mut StableHasher) { + fn stable_hash(&self, _: &mut Hcx, hasher: &mut StableHasher) { Hash::hash(self, hasher); } } diff --git a/compiler/rustc_abi/src/layout/ty.rs b/compiler/rustc_abi/src/layout/ty.rs index b394f9f4f86dc..b09afc9ec8af6 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; +use rustc_macros::StableHash; 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)] +#[derive(Copy, Clone, PartialEq, Eq, Hash, StableHash)] #[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)] +#[derive(Copy, Clone, PartialEq, Eq, Hash, StableHash)] 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 2e6141722cd8c..3cc98bdd7e70e 100644 --- a/compiler/rustc_abi/src/lib.rs +++ b/compiler/rustc_abi/src/lib.rs @@ -53,7 +53,7 @@ use rustc_errors::{Diag, DiagCtxtHandle, Diagnostic, EmissionGuarantee, Level, m use rustc_hashes::Hash64; use rustc_index::{Idx, IndexSlice, IndexVec}; #[cfg(feature = "nightly")] -use rustc_macros::{Decodable_NoContext, Encodable_NoContext, HashStable}; +use rustc_macros::{Decodable_NoContext, Encodable_NoContext, StableHash}; #[cfg(feature = "nightly")] use rustc_span::{Symbol, sym}; @@ -74,7 +74,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))] +#[cfg_attr(feature = "nightly", derive(Encodable_NoContext, Decodable_NoContext, StableHash))] pub struct ReprFlags(u8); bitflags! { @@ -111,7 +111,7 @@ impl std::fmt::Debug for ReprFlags { } #[derive(Copy, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "nightly", derive(Encodable_NoContext, Decodable_NoContext, HashStable))] +#[cfg_attr(feature = "nightly", derive(Encodable_NoContext, Decodable_NoContext, StableHash))] pub enum IntegerType { /// Pointer-sized integer type, i.e. `isize` and `usize`. The field shows signedness, e.g. /// `Pointer(true)` means `isize`. @@ -131,7 +131,7 @@ impl IntegerType { } #[derive(Copy, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "nightly", derive(Encodable_NoContext, Decodable_NoContext, HashStable))] +#[cfg_attr(feature = "nightly", derive(Encodable_NoContext, Decodable_NoContext, StableHash))] pub enum ScalableElt { /// `N` in `rustc_scalable_vector(N)` - the element count of the scalable vector ElementCount(u16), @@ -142,7 +142,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))] +#[cfg_attr(feature = "nightly", derive(Encodable_NoContext, Decodable_NoContext, StableHash))] pub struct ReprOptions { pub int: Option, pub align: Option, @@ -792,7 +792,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))] +#[cfg_attr(feature = "nightly", derive(Encodable_NoContext, Decodable_NoContext, StableHash))] pub struct Size { raw: u64, } @@ -1017,7 +1017,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))] +#[cfg_attr(feature = "nightly", derive(Encodable_NoContext, Decodable_NoContext, StableHash))] pub struct Align { pow2: u8, } @@ -1150,7 +1150,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))] +#[cfg_attr(feature = "nightly", derive(StableHash))] pub struct AbiAlign { pub abi: Align, } @@ -1182,7 +1182,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))] +#[cfg_attr(feature = "nightly", derive(Encodable_NoContext, Decodable_NoContext, StableHash))] pub enum Integer { I8, I16, @@ -1342,7 +1342,7 @@ impl Integer { /// Floating-point types. #[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Debug)] -#[cfg_attr(feature = "nightly", derive(HashStable))] +#[cfg_attr(feature = "nightly", derive(StableHash))] pub enum Float { F16, F32, @@ -1377,7 +1377,7 @@ impl Float { /// Fundamental unit of memory access and layout. #[derive(Copy, Clone, PartialEq, Eq, Hash, Debug)] -#[cfg_attr(feature = "nightly", derive(HashStable))] +#[cfg_attr(feature = "nightly", derive(StableHash))] pub enum Primitive { /// The `bool` is the signedness of the `Integer` type. /// @@ -1425,7 +1425,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))] +#[cfg_attr(feature = "nightly", derive(StableHash))] pub struct WrappingRange { pub start: u128, pub end: u128, @@ -1537,7 +1537,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))] +#[cfg_attr(feature = "nightly", derive(StableHash))] pub enum Scalar { Initialized { value: Primitive, @@ -1641,7 +1641,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))] +#[cfg_attr(feature = "nightly", derive(StableHash))] pub enum FieldsShape { /// Scalar primitives and `!`, which never have fields. Primitive, @@ -1726,7 +1726,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))] +#[cfg_attr(feature = "nightly", derive(StableHash))] pub struct AddressSpace(pub u32); impl AddressSpace { @@ -1739,7 +1739,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))] +#[cfg_attr(feature = "nightly", derive(StableHash))] pub struct NumScalableVectors(pub u8); impl NumScalableVectors { @@ -1788,7 +1788,7 @@ impl IntoDiagArg for 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))] +#[cfg_attr(feature = "nightly", derive(StableHash))] pub enum BackendRepr { Scalar(Scalar), ScalarPair(Scalar, Scalar), @@ -1932,7 +1932,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))] +#[cfg_attr(feature = "nightly", derive(StableHash))] pub enum Variants { /// A type with no valid variants. Must be uninhabited. Empty, @@ -1959,7 +1959,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))] +#[cfg_attr(feature = "nightly", derive(StableHash))] 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). @@ -2000,7 +2000,7 @@ pub enum TagEncoding { } #[derive(Clone, Copy, PartialEq, Eq, Hash, Debug)] -#[cfg_attr(feature = "nightly", derive(HashStable))] +#[cfg_attr(feature = "nightly", derive(StableHash))] pub struct Niche { pub offset: Size, pub value: Primitive, @@ -2097,7 +2097,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))] +#[cfg_attr(feature = "nightly", derive(StableHash))] 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 a768beedba31c..b105a97cdf98d 100644 --- a/compiler/rustc_ast/src/ast.rs +++ b/compiler/rustc_ast/src/ast.rs @@ -25,10 +25,10 @@ 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, HashStableContext, StableHasher}; +use rustc_data_structures::stable_hasher::{StableHash, StableHashCtxt, StableHasher}; use rustc_data_structures::stack::ensure_sufficient_stack; use rustc_data_structures::tagged_ptr::Tag; -use rustc_macros::{Decodable, Encodable, HashStable, Walkable}; +use rustc_macros::{Decodable, Encodable, StableHash, Walkable}; pub use rustc_span::AttrId; use rustc_span::{ ByteSymbol, DUMMY_SP, ErrorGuaranteed, Ident, Span, Spanned, Symbol, kw, respan, sym, @@ -52,7 +52,7 @@ use crate::visit::{AssocCtxt, BoundKind, LifetimeCtxt}; /// ``` /// /// `'outer` is a label. -#[derive(Clone, Encodable, Decodable, Copy, HashStable, Eq, PartialEq, Walkable)] +#[derive(Clone, Encodable, Decodable, Copy, StableHash, Eq, PartialEq, Walkable)] pub struct Label { pub ident: Ident, } @@ -120,11 +120,11 @@ impl PartialEq<&[Symbol]> for Path { } } -impl HashStable for Path { - fn hash_stable(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { - self.segments.len().hash_stable(hcx, hasher); +impl StableHash for Path { + fn stable_hash(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { + self.segments.len().stable_hash(hcx, hasher); for segment in &self.segments { - segment.ident.hash_stable(hcx, hasher); + segment.ident.stable_hash(hcx, hasher); } } } @@ -564,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)] +#[derive(Clone, Encodable, Decodable, Debug, StableHash)] pub struct MetaItem { pub unsafety: Safety, pub path: Path, @@ -573,7 +573,7 @@ pub struct MetaItem { } /// The meta item kind, containing the data after the initial path. -#[derive(Clone, Encodable, Decodable, Debug, HashStable)] +#[derive(Clone, Encodable, Decodable, Debug, StableHash)] pub enum MetaItemKind { /// Word meta item. /// @@ -594,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)] +#[derive(Clone, Encodable, Decodable, Debug, StableHash)] pub enum MetaItemInner { /// A full MetaItem, for recursive meta items. MetaItem(MetaItem), @@ -792,7 +792,7 @@ pub struct PatField { } #[derive(Clone, Copy, Debug, Eq, PartialEq)] -#[derive(Encodable, Decodable, HashStable, Walkable)] +#[derive(Encodable, Decodable, StableHash, Walkable)] pub enum ByRef { Yes(Pinnedness, Mutability), No, @@ -814,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, Walkable)] +#[derive(Encodable, Decodable, StableHash, Walkable)] pub struct BindingMode(pub ByRef, pub Mutability); impl BindingMode { @@ -964,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, Walkable)] +#[derive(Encodable, Decodable, StableHash, Walkable)] pub enum BorrowKind { /// A normal borrow, `&$expr` or `&mut $expr`. /// The resulting type is either `&'a T` or `&'a mut T` @@ -980,7 +980,7 @@ pub enum BorrowKind { Pin, } -#[derive(Clone, Copy, Debug, PartialEq, Encodable, Decodable, HashStable, Walkable)] +#[derive(Clone, Copy, Debug, PartialEq, Encodable, Decodable, StableHash, Walkable)] pub enum BinOpKind { /// The `+` operator (addition) Add, @@ -1110,7 +1110,7 @@ impl From for BinOpKind { } } -#[derive(Clone, Copy, Debug, PartialEq, Encodable, Decodable, HashStable, Walkable)] +#[derive(Clone, Copy, Debug, PartialEq, Encodable, Decodable, StableHash, Walkable)] pub enum AssignOpKind { /// The `+=` operator (addition) AddAssign, @@ -1162,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, Walkable)] +#[derive(Clone, Copy, Debug, PartialEq, Encodable, Decodable, StableHash, Walkable)] pub enum UnOp { /// The `*` operator for dereferencing Deref, @@ -1961,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, Walkable)] +#[derive(Encodable, Decodable, StableHash, Walkable)] pub enum UnsafeBinderCastKind { // e.g. `&i32` -> `unsafe<'a> &'a i32` Wrap, @@ -1995,7 +1995,7 @@ pub struct QSelf { } /// A capture clause used in closures and `async` blocks. -#[derive(Clone, Copy, PartialEq, Encodable, Decodable, Debug, HashStable, Walkable)] +#[derive(Clone, Copy, PartialEq, Encodable, Decodable, Debug, StableHash, Walkable)] pub enum CaptureBy { /// `move |x| y + x`. Value { @@ -2090,7 +2090,7 @@ impl AttrArgs { } /// Delimited arguments, as used in `#[attr()/[]/{}]` or `mac!()/[]/{}`. -#[derive(Clone, Encodable, Decodable, Debug, HashStable, Walkable)] +#[derive(Clone, Encodable, Decodable, Debug, StableHash, Walkable)] pub struct DelimArgs { pub dspan: DelimSpan, pub delim: Delimiter, // Note: `Delimiter::Invisible` never occurs @@ -2106,7 +2106,7 @@ impl DelimArgs { } /// Represents a macro definition. -#[derive(Clone, Encodable, Decodable, Debug, HashStable, Walkable)] +#[derive(Clone, Encodable, Decodable, Debug, StableHash, Walkable)] pub struct MacroDef { pub body: Box, /// `true` if macro was defined with `macro_rules`. @@ -2120,7 +2120,7 @@ pub struct MacroDef { pub eii_declaration: Option, } -#[derive(Clone, Encodable, Decodable, Debug, HashStable, Walkable)] +#[derive(Clone, Encodable, Decodable, Debug, StableHash, Walkable)] pub struct EiiDecl { /// path to the extern item we're targeting pub foreign_item: Path, @@ -2128,7 +2128,7 @@ pub struct EiiDecl { } #[derive(Clone, Encodable, Decodable, Debug, Copy, Hash, Eq, PartialEq)] -#[derive(HashStable, Walkable)] +#[derive(StableHash, Walkable)] pub enum StrStyle { /// A regular string, like `"foo"`. Cooked, @@ -2186,7 +2186,7 @@ impl YieldKind { } /// A literal in a meta item. -#[derive(Clone, Copy, Encodable, Decodable, Debug, HashStable)] +#[derive(Clone, Copy, Encodable, Decodable, Debug, StableHash)] pub struct MetaItemLit { /// The original literal as written in the source code. pub symbol: Symbol, @@ -2223,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)] +#[derive(StableHash)] pub enum LitIntType { /// e.g. `42_i32`. Signed(IntTy), @@ -2235,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)] +#[derive(StableHash)] pub enum LitFloatType { /// A float literal with a suffix (`1f32` or `1E10f32`). Suffixed(FloatTy), @@ -2249,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)] +#[derive(Clone, Copy, Encodable, Decodable, Debug, Hash, Eq, PartialEq, StableHash)] pub enum LitKind { /// A string literal (`"foo"`). The symbol is unescaped, and so may differ /// from the original token's symbol. @@ -2652,7 +2652,7 @@ pub enum TyPatKind { } /// Syntax used to declare a trait object. -#[derive(Clone, Copy, PartialEq, Encodable, Decodable, Debug, HashStable, Walkable)] +#[derive(Clone, Copy, PartialEq, Encodable, Decodable, Debug, StableHash, Walkable)] #[repr(u8)] pub enum TraitObjectSyntax { // SAFETY: When adding new variants make sure to update the `Tag` impl. @@ -2696,7 +2696,7 @@ pub enum InlineAsmRegOrRegClass { RegClass(Symbol), } -#[derive(Clone, Copy, PartialEq, Eq, Hash, Encodable, Decodable, HashStable)] +#[derive(Clone, Copy, PartialEq, Eq, Hash, Encodable, Decodable, StableHash)] pub struct InlineAsmOptions(u16); bitflags::bitflags! { impl InlineAsmOptions: u16 { @@ -2759,7 +2759,7 @@ impl std::fmt::Debug for InlineAsmOptions { } } -#[derive(Clone, PartialEq, Encodable, Decodable, Debug, Hash, HashStable, Walkable)] +#[derive(Clone, PartialEq, Encodable, Decodable, Debug, Hash, StableHash, Walkable)] pub enum InlineAsmTemplatePiece { String(Cow<'static, str>), Placeholder { operand_idx: usize, modifier: Option, span: Span }, @@ -2862,7 +2862,7 @@ impl InlineAsmOperand { } } -#[derive(Clone, Copy, Encodable, Decodable, Debug, HashStable, Walkable, PartialEq, Eq)] +#[derive(Clone, Copy, Encodable, Decodable, Debug, StableHash, Walkable, PartialEq, Eq)] pub enum AsmMacro { /// The `asm!` macro Asm, @@ -3060,7 +3060,7 @@ impl FnDecl { } /// Is the trait definition an auto trait? -#[derive(Copy, Clone, PartialEq, Encodable, Decodable, Debug, HashStable, Walkable)] +#[derive(Copy, Clone, PartialEq, Encodable, Decodable, Debug, StableHash, Walkable)] pub enum IsAuto { Yes, No, @@ -3068,7 +3068,7 @@ pub enum IsAuto { /// Safety of items. #[derive(Copy, Clone, PartialEq, Eq, Hash, Encodable, Decodable, Debug)] -#[derive(HashStable, Walkable)] +#[derive(StableHash, Walkable)] pub enum Safety { /// `unsafe` an item is explicitly marked as `unsafe`. Unsafe(Span), @@ -3133,7 +3133,7 @@ impl CoroutineKind { } #[derive(Copy, Clone, PartialEq, Eq, Hash, Encodable, Decodable, Debug)] -#[derive(HashStable, Walkable)] +#[derive(StableHash, Walkable)] pub enum Const { Yes(Span), No, @@ -3141,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, Walkable)] +#[derive(Copy, Clone, PartialEq, Encodable, Decodable, Debug, StableHash, Walkable)] pub enum Defaultness { /// Item is unmarked. Implicitly determined based off of position. /// For impls, this is `final`; for traits, this is `default`. @@ -3155,7 +3155,7 @@ pub enum Defaultness { Final(Span), } -#[derive(Copy, Clone, PartialEq, Encodable, Decodable, HashStable, Walkable)] +#[derive(Copy, Clone, PartialEq, Encodable, Decodable, StableHash, Walkable)] pub enum ImplPolarity { /// `impl Trait for Type` Positive, @@ -3174,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, Walkable)] +#[derive(StableHash, Walkable)] pub enum BoundPolarity { /// `Type: Trait` Positive, @@ -3196,7 +3196,7 @@ impl BoundPolarity { /// The constness of a trait bound. #[derive(Copy, Clone, PartialEq, Eq, Encodable, Decodable, Debug, Hash)] -#[derive(HashStable, Walkable)] +#[derive(StableHash, Walkable)] pub enum BoundConstness { /// `Type: Trait` Never, @@ -3218,7 +3218,7 @@ impl BoundConstness { /// The asyncness of a trait bound. #[derive(Copy, Clone, PartialEq, Eq, Encodable, Decodable, Debug)] -#[derive(HashStable, Walkable)] +#[derive(StableHash, Walkable)] pub enum BoundAsyncness { /// `Type: Trait` Normal, @@ -3387,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, Walkable)] +#[derive(Encodable, Decodable, StableHash, Walkable)] pub enum AttrStyle { Outer, Inner, @@ -3484,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)] +#[derive(Clone, Encodable, Decodable, Debug, StableHash)] pub enum EarlyParsedAttribute { CfgTrace(CfgEntry), CfgAttrTrace, @@ -3607,7 +3607,7 @@ pub struct FieldDef { } /// Was parsing recovery performed? -#[derive(Copy, Clone, Debug, Encodable, Decodable, HashStable, Walkable)] +#[derive(Copy, Clone, Debug, Encodable, Decodable, StableHash, 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 36d0352b7f8a0..bc960deda1b89 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}; +use rustc_macros::{Decodable, Encodable, StableHash}; use rustc_span::{Span, Symbol}; use thin_vec::ThinVec; use crate::attr::version::RustcVersion; -#[derive(Encodable, Decodable, Clone, Debug, PartialEq, Eq, Hash, HashStable)] +#[derive(Encodable, Decodable, Clone, Debug, PartialEq, Eq, Hash, StableHash)] 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 c695ba5b8a057..506a7a291813c 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, current_rustc_version}; +use rustc_macros::{BlobDecodable, Encodable, StableHash, current_rustc_version}; #[derive(Encodable, BlobDecodable, Copy, Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)] -#[derive(HashStable)] +#[derive(StableHash)] 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 874534b876521..9a79fa1fbe55e 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; +use rustc_macros::StableHash; use rustc_span::{Symbol, sym}; -#[derive(Clone, Debug, Copy, Eq, PartialEq, HashStable)] +#[derive(Clone, Debug, Copy, Eq, PartialEq, StableHash)] 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 a1967ba8db322..c9a3275c4c97f 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}; +use crate::expand::{Decodable, Encodable, StableHash}; 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)] +#[derive(Clone, Copy, Eq, PartialEq, Encodable, Decodable, Debug, StableHash)] 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)] +#[derive(Clone, Copy, Eq, PartialEq, Encodable, Decodable, Debug, StableHash)] 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 e5abb651c0800..1eeb4a8ec848e 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}; +use rustc_macros::{Decodable, Encodable, StableHash}; 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 3c1dd69f6c559..9619c80904426 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}; +use crate::expand::{Decodable, Encodable, StableHash}; -#[derive(Clone, Copy, Eq, PartialEq, Encodable, Decodable, Debug, HashStable)] +#[derive(Clone, Copy, Eq, PartialEq, Encodable, Decodable, Debug, StableHash)] pub enum Kind { Anything, Integer, @@ -35,7 +35,7 @@ pub enum Kind { Unknown, } -#[derive(Clone, Eq, PartialEq, Encodable, Decodable, Debug, HashStable)] +#[derive(Clone, Eq, PartialEq, Encodable, Decodable, Debug, StableHash)] pub struct TypeTree(pub Vec); impl TypeTree { @@ -59,13 +59,13 @@ impl TypeTree { } } -#[derive(Clone, Eq, PartialEq, Encodable, Decodable, Debug, HashStable)] +#[derive(Clone, Eq, PartialEq, Encodable, Decodable, Debug, StableHash)] pub struct FncTree { pub args: Vec, pub ret: TypeTree, } -#[derive(Clone, Eq, PartialEq, Encodable, Decodable, Debug, HashStable)] +#[derive(Clone, Eq, PartialEq, Encodable, Decodable, Debug, StableHash)] 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 8ba2d5eaa8ba7..13783350ea29f 100644 --- a/compiler/rustc_ast/src/node_id.rs +++ b/compiler/rustc_ast/src/node_id.rs @@ -1,6 +1,6 @@ use std::fmt; -use rustc_data_structures::stable_hasher::{HashStable, HashStableContext, StableHasher}; +use rustc_data_structures::stable_hasher::{StableHash, StableHashCtxt, StableHasher}; use rustc_span::LocalExpnId; rustc_index::newtype_index! { @@ -19,10 +19,10 @@ rustc_index::newtype_index! { } } -impl HashStable for NodeId { +impl StableHash for NodeId { #[inline] - fn hash_stable(&self, _: &mut Hcx, _: &mut StableHasher) { - // This impl is never called but is necessary for types implementing `HashStable` such as + fn stable_hash(&self, _: &mut Hcx, _: &mut StableHasher) { + // This impl is never called but is necessary for types implementing `StableHash` such as // `MainDefinition` and `DocLinkResMap` (both of which occur in `ResolverGlobalCtxt`). panic!("Node IDs should not appear in incremental state"); } diff --git a/compiler/rustc_ast/src/token.rs b/compiler/rustc_ast/src/token.rs index 9f148f87dfba8..743e60d2f3bb2 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}; +use rustc_macros::{Decodable, Encodable, StableHash}; 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)] +#[derive(Clone, Copy, PartialEq, Eq, Encodable, Decodable, Debug, StableHash)] 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)] +#[derive(Clone, Copy, PartialEq, Eq, Hash, Encodable, Decodable, Debug, StableHash)] pub enum CommentKind { Line, Block, } -#[derive(Copy, Clone, PartialEq, Eq, Hash, Debug, Encodable, Decodable, HashStable)] +#[derive(Copy, Clone, PartialEq, Eq, Hash, Debug, Encodable, Decodable, StableHash)] 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)] +#[derive(Debug, Copy, Clone, PartialEq, Eq, Encodable, Decodable, Hash, StableHash)] 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)] +#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash, Encodable, Decodable, StableHash)] 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)] +#[derive(Clone, Copy, PartialEq, Eq, Hash, Encodable, Decodable, Debug, StableHash)] 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)] +#[derive(Clone, Copy, PartialEq, Eq, Hash, Encodable, Decodable, Debug, StableHash)] 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)] +#[derive(PartialEq, Eq, Encodable, Decodable, Hash, Debug, Copy, Clone, StableHash)] pub enum IdentIsRaw { No, Yes, @@ -378,7 +378,7 @@ impl From for IdentIsRaw { } } -#[derive(Clone, Copy, PartialEq, Eq, Hash, Encodable, Decodable, Debug, HashStable)] +#[derive(Clone, Copy, PartialEq, Eq, Hash, Encodable, Decodable, Debug, StableHash)] pub enum TokenKind { /* Expression-operator symbols. */ /// `=` @@ -528,7 +528,7 @@ pub enum TokenKind { Eof, } -#[derive(Clone, Copy, PartialEq, Eq, Hash, Encodable, Decodable, Debug, HashStable)] +#[derive(Clone, Copy, PartialEq, Eq, Hash, Encodable, Decodable, Debug, StableHash)] 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)] +#[derive(Debug, Copy, Clone, PartialEq, Eq, Encodable, Decodable, Hash, StableHash)] 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)] +#[derive(Debug, Copy, Clone, PartialEq, Eq, Encodable, Decodable, Hash, StableHash)] 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)] +#[derive(Debug, Copy, Clone, PartialEq, Eq, Encodable, Decodable, Hash, StableHash)] pub enum NonterminalKind { Item, Block, diff --git a/compiler/rustc_ast/src/tokenstream.rs b/compiler/rustc_ast/src/tokenstream.rs index 86a6d93dac359..af5bf14aecce6 100644 --- a/compiler/rustc_ast/src/tokenstream.rs +++ b/compiler/rustc_ast/src/tokenstream.rs @@ -10,9 +10,9 @@ use std::ops::Range; use std::sync::Arc; use std::{cmp, fmt, iter, mem}; -use rustc_data_structures::stable_hasher::{HashStable, HashStableContext, StableHasher}; +use rustc_data_structures::stable_hasher::{StableHash, StableHashCtxt, StableHasher}; use rustc_data_structures::sync; -use rustc_macros::{Decodable, Encodable, HashStable, Walkable}; +use rustc_macros::{Decodable, Encodable, StableHash, Walkable}; use rustc_serialize::{Decodable, Encodable}; use rustc_span::{DUMMY_SP, Span, SpanDecoder, SpanEncoder, Symbol, sym}; use thin_vec::ThinVec; @@ -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)] +#[derive(Debug, Clone, PartialEq, Eq, Hash, Encodable, Decodable, StableHash)] 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 StableHash for LazyAttrTokenStream { + fn stable_hash(&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)] +#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, Encodable, Decodable, StableHash)] pub enum Spacing { /// The token cannot join with the following token to form a compound /// token. @@ -824,10 +824,10 @@ impl FromIterator for TokenStream { } } -impl HashStable for TokenStream { - fn hash_stable(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { +impl StableHash for TokenStream { + fn stable_hash(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { for sub_tt in self.iter() { - sub_tt.hash_stable(hcx, hasher); + sub_tt.stable_hash(hcx, hasher); } } } @@ -967,7 +967,7 @@ impl TokenCursor { } #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] -#[derive(Encodable, Decodable, HashStable, Walkable)] +#[derive(Encodable, Decodable, StableHash, Walkable)] pub struct DelimSpan { pub open: Span, pub close: Span, @@ -991,7 +991,7 @@ impl DelimSpan { } } -#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash, Encodable, Decodable, HashStable)] +#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash, Encodable, Decodable, StableHash)] 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 f0ba622308670..f90359c515264 100644 --- a/compiler/rustc_ast_ir/src/lib.rs +++ b/compiler/rustc_ast_ir/src/lib.rs @@ -14,14 +14,14 @@ use std::fmt; #[cfg(feature = "nightly")] -use rustc_macros::{Decodable_NoContext, Encodable_NoContext, HashStable}; +use rustc_macros::{Decodable_NoContext, Encodable_NoContext, StableHash}; #[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))] +#[cfg_attr(feature = "nightly", derive(Encodable_NoContext, Decodable_NoContext, StableHash))] pub enum IntTy { Isize, I8, @@ -97,7 +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))] +#[cfg_attr(feature = "nightly", derive(Encodable_NoContext, Decodable_NoContext, StableHash))] pub enum UintTy { Usize, U8, @@ -173,7 +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))] +#[cfg_attr(feature = "nightly", derive(Encodable_NoContext, Decodable_NoContext, StableHash))] pub enum FloatTy { F16, F32, @@ -220,7 +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))] +#[cfg_attr(feature = "nightly", derive(Encodable_NoContext, Decodable_NoContext, StableHash))] pub enum Movability { /// May contain self-references, `!Unpin`. Static, @@ -229,7 +229,7 @@ pub enum Movability { } #[derive(Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Debug, Copy)] -#[cfg_attr(feature = "nightly", derive(Encodable_NoContext, Decodable_NoContext, HashStable))] +#[cfg_attr(feature = "nightly", derive(Encodable_NoContext, Decodable_NoContext, StableHash))] pub enum Mutability { // N.B. Order is deliberate, so that Not < Mut Not, @@ -288,7 +288,7 @@ impl Mutability { } #[derive(Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Debug, Copy)] -#[cfg_attr(feature = "nightly", derive(Encodable_NoContext, Decodable_NoContext, HashStable))] +#[cfg_attr(feature = "nightly", derive(Encodable_NoContext, Decodable_NoContext, StableHash))] pub enum Pinnedness { Not, Pinned, diff --git a/compiler/rustc_ast_lowering/src/lib.rs b/compiler/rustc_ast_lowering/src/lib.rs index 49790c2da6de4..3c8abf3ee2bbb 100644 --- a/compiler/rustc_ast_lowering/src/lib.rs +++ b/compiler/rustc_ast_lowering/src/lib.rs @@ -45,7 +45,7 @@ use rustc_attr_parsing::{AttributeParser, OmitDoc, Recovery, ShouldEmit}; use rustc_data_structures::fingerprint::Fingerprint; use rustc_data_structures::fx::FxIndexSet; use rustc_data_structures::sorted_map::SortedMap; -use rustc_data_structures::stable_hasher::{HashStable, StableHasher}; +use rustc_data_structures::stable_hasher::{StableHash, StableHasher}; use rustc_data_structures::steal::Steal; use rustc_data_structures::tagged_ptr::TaggedRef; use rustc_errors::{DiagArgFromDisplay, DiagCtxtHandle}; @@ -523,7 +523,7 @@ fn compute_hir_hash( tcx.with_stable_hashing_context(|mut hcx| { let mut stable_hasher = StableHasher::new(); - hir_body_nodes.hash_stable(&mut hcx, &mut stable_hasher); + hir_body_nodes.stable_hash(&mut hcx, &mut stable_hasher); stable_hasher.finish() }) } diff --git a/compiler/rustc_attr_parsing/src/attributes/autodiff.rs b/compiler/rustc_attr_parsing/src/attributes/autodiff.rs index 34fd7c8e7f046..dc63767462201 100644 --- a/compiler/rustc_attr_parsing/src/attributes/autodiff.rs +++ b/compiler/rustc_attr_parsing/src/attributes/autodiff.rs @@ -52,10 +52,7 @@ impl SingleAttributeParser for RustcAutodiffParser { cx.adcx().expected_identifier(mode.span()); return None; }; - let Ok(()) = mode.args().no_args() else { - cx.adcx().expected_identifier(mode.span()); - return None; - }; + cx.expect_no_args(mode.args())?; let Some(mode) = mode.path().word() else { cx.adcx().expected_identifier(mode.span()); return None; @@ -85,11 +82,7 @@ impl SingleAttributeParser for RustcAutodiffParser { .expected_specific_argument(activity.span(), DiffActivity::all_activities()); return None; }; - let Ok(()) = activity.args().no_args() else { - cx.adcx() - .expected_specific_argument(activity.span(), DiffActivity::all_activities()); - return None; - }; + cx.expect_no_args(activity.args())?; let Some(activity) = activity.path().word() else { cx.adcx() .expected_specific_argument(activity.span(), DiffActivity::all_activities()); diff --git a/compiler/rustc_attr_parsing/src/attributes/codegen_attrs.rs b/compiler/rustc_attr_parsing/src/attributes/codegen_attrs.rs index a6cf25330b557..2651d97cf63e0 100644 --- a/compiler/rustc_attr_parsing/src/attributes/codegen_attrs.rs +++ b/compiler/rustc_attr_parsing/src/attributes/codegen_attrs.rs @@ -195,10 +195,9 @@ pub(crate) struct NakedParser { impl AttributeParser for NakedParser { const ATTRIBUTES: AcceptMapping = &[(&[sym::naked], template!(Word), |this, cx, args| { - if let Err(span) = args.no_args() { - cx.adcx().expected_no_args(span); + let Some(()) = cx.expect_no_args(args) else { return; - } + }; if let Some(earlier) = this.span { let span = cx.attr_span; diff --git a/compiler/rustc_attr_parsing/src/attributes/crate_level.rs b/compiler/rustc_attr_parsing/src/attributes/crate_level.rs index 070b0e385b024..75c777f1a9c4e 100644 --- a/compiler/rustc_attr_parsing/src/attributes/crate_level.rs +++ b/compiler/rustc_attr_parsing/src/attributes/crate_level.rs @@ -294,11 +294,9 @@ impl CombineAttributeParser for FeatureParser { cx.adcx().expected_identifier(elem.span()); continue; }; - if let Err(arg_span) = elem.args().no_args() { - cx.adcx().expected_no_args(arg_span); + let Some(()) = cx.expect_no_args(elem.args()) else { continue; - } - + }; let path = elem.path(); let Some(ident) = path.word() else { cx.adcx().expected_identifier(path.span()); @@ -340,10 +338,9 @@ impl CombineAttributeParser for RegisterToolParser { cx.adcx().expected_identifier(elem.span()); continue; }; - if let Err(arg_span) = elem.args().no_args() { - cx.adcx().expected_no_args(arg_span); + let Some(()) = cx.expect_no_args(elem.args()) else { continue; - } + }; let path = elem.path(); let Some(ident) = path.word() else { diff --git a/compiler/rustc_attr_parsing/src/attributes/doc.rs b/compiler/rustc_attr_parsing/src/attributes/doc.rs index 63c86f3ee9ef6..10232a7c55a5f 100644 --- a/compiler/rustc_attr_parsing/src/attributes/doc.rs +++ b/compiler/rustc_attr_parsing/src/attributes/doc.rs @@ -150,7 +150,7 @@ impl DocParser { match path.word_sym() { Some(sym::no_crate_inject) => { - if let Err(span) = args.no_args() { + if let Err(span) = args.as_no_args() { expected_no_args(cx, span); return; } @@ -280,7 +280,7 @@ impl DocParser { args: &ArgParser, inline: DocInline, ) { - if let Err(span) = args.no_args() { + if let Err(span) = args.as_no_args() { expected_no_args(cx, span); return; } @@ -426,7 +426,7 @@ impl DocParser { macro_rules! no_args { ($ident: ident) => {{ - if let Err(span) = args.no_args() { + if let Err(span) = args.as_no_args() { expected_no_args(cx, span); return; } @@ -445,7 +445,7 @@ impl DocParser { } macro_rules! no_args_and_not_crate_level { ($ident: ident) => {{ - if let Err(span) = args.no_args() { + if let Err(span) = args.as_no_args() { expected_no_args(cx, span); return; } @@ -461,7 +461,7 @@ impl DocParser { no_args_and_crate_level!($ident, |span| {}); }}; ($ident: ident, |$span:ident| $extra_validation:block) => {{ - if let Err(span) = args.no_args() { + if let Err(span) = args.as_no_args() { expected_no_args(cx, span); return; } diff --git a/compiler/rustc_attr_parsing/src/attributes/macro_attrs.rs b/compiler/rustc_attr_parsing/src/attributes/macro_attrs.rs index 36ee18d5bbe8d..80555053174f7 100644 --- a/compiler/rustc_attr_parsing/src/attributes/macro_attrs.rs +++ b/compiler/rustc_attr_parsing/src/attributes/macro_attrs.rs @@ -86,10 +86,9 @@ impl AttributeParser for MacroUseParser { cx.adcx().expected_identifier(item.span()); continue; }; - if let Err(err_span) = item.args().no_args() { - cx.adcx().expected_no_args(err_span); + let Some(()) = cx.expect_no_args(item.args()) else { continue; - } + }; let Some(item) = item.path().word() else { cx.adcx().expected_identifier(item.span()); continue; @@ -179,9 +178,7 @@ impl SingleAttributeParser for CollapseDebugInfoParser { cx.adcx().expected_not_literal(single.span()); return None; }; - if let Err(err) = mi.args().no_args() { - cx.adcx().expected_no_args(err); - } + let _ = cx.expect_no_args(mi.args()); let path = mi.path().word_sym(); let info = match path { Some(sym::yes) => CollapseMacroDebuginfo::Yes, diff --git a/compiler/rustc_attr_parsing/src/attributes/mod.rs b/compiler/rustc_attr_parsing/src/attributes/mod.rs index af90bd0fe58cc..42c6828ef57b7 100644 --- a/compiler/rustc_attr_parsing/src/attributes/mod.rs +++ b/compiler/rustc_attr_parsing/src/attributes/mod.rs @@ -258,9 +258,7 @@ impl SingleAttributeParser for WithoutArgs { const TEMPLATE: AttributeTemplate = template!(Word); fn convert(cx: &mut AcceptContext<'_, '_>, args: &ArgParser) -> Option { - if let Err(span) = args.no_args() { - cx.adcx().expected_no_args(span); - } + let _ = cx.expect_no_args(args); Some(T::CREATE(cx.attr_span)) } } diff --git a/compiler/rustc_attr_parsing/src/attributes/proc_macro_attrs.rs b/compiler/rustc_attr_parsing/src/attributes/proc_macro_attrs.rs index 88253041ed6e0..d7bc60153f269 100644 --- a/compiler/rustc_attr_parsing/src/attributes/proc_macro_attrs.rs +++ b/compiler/rustc_attr_parsing/src/attributes/proc_macro_attrs.rs @@ -58,7 +58,7 @@ fn parse_derive_like( ) -> Option<(Option, ThinVec)> { let Some(list) = args.as_list() else { // For #[rustc_builtin_macro], it is permitted to leave out the trait name - if args.no_args().is_ok() && !trait_name_mandatory { + if args.as_no_args().is_ok() && !trait_name_mandatory { return Some((None, ThinVec::new())); } let attr_span = cx.attr_span; @@ -84,10 +84,7 @@ fn parse_derive_like( cx.adcx().expected_identifier(trait_ident.span); return None; } - if let Err(e) = trait_attr.args().no_args() { - cx.adcx().expected_no_args(e); - return None; - }; + cx.expect_no_args(trait_attr.args())?; // Parse optional attributes let mut attributes = ThinVec::new(); @@ -108,10 +105,7 @@ fn parse_derive_like( cx.adcx().expected_identifier(attr.span()); return None; }; - if let Err(e) = attr.args().no_args() { - cx.adcx().expected_no_args(e); - return None; - }; + cx.expect_no_args(attr.args())?; let Some(ident) = attr.path().word() else { cx.adcx().expected_identifier(attr.path().span()); return None; diff --git a/compiler/rustc_attr_parsing/src/attributes/rustc_dump.rs b/compiler/rustc_attr_parsing/src/attributes/rustc_dump.rs index 1158f1c5acf4c..8d507065dbdb6 100644 --- a/compiler/rustc_attr_parsing/src/attributes/rustc_dump.rs +++ b/compiler/rustc_attr_parsing/src/attributes/rustc_dump.rs @@ -36,10 +36,7 @@ impl SingleAttributeParser for RustcDumpDefPathParser { ]); const TEMPLATE: AttributeTemplate = template!(Word); fn convert(cx: &mut AcceptContext<'_, '_>, args: &ArgParser) -> Option { - if let Err(span) = args.no_args() { - cx.adcx().expected_no_args(span); - return None; - } + cx.expect_no_args(args)?; Some(AttributeKind::RustcDumpDefPath(cx.attr_span)) } } @@ -203,10 +200,7 @@ impl SingleAttributeParser for RustcDumpSymbolNameParser { ]); const TEMPLATE: AttributeTemplate = template!(Word); fn convert(cx: &mut AcceptContext<'_, '_>, args: &ArgParser) -> Option { - if let Err(span) = args.no_args() { - cx.adcx().expected_no_args(span); - return None; - } + cx.expect_no_args(args)?; Some(AttributeKind::RustcDumpSymbolName(cx.attr_span)) } } diff --git a/compiler/rustc_attr_parsing/src/attributes/rustc_internal.rs b/compiler/rustc_attr_parsing/src/attributes/rustc_internal.rs index 835af97358ac4..697d3f8cc2a23 100644 --- a/compiler/rustc_attr_parsing/src/attributes/rustc_internal.rs +++ b/compiler/rustc_attr_parsing/src/attributes/rustc_internal.rs @@ -555,7 +555,7 @@ impl SingleAttributeParser for RustcScalableVectorParser { const TEMPLATE: AttributeTemplate = template!(Word, List: &["count"]); fn convert(cx: &mut AcceptContext<'_, '_>, args: &ArgParser) -> Option { - if args.no_args().is_ok() { + if args.as_no_args().is_ok() { return Some(AttributeKind::RustcScalableVector { element_count: None, span: cx.attr_span, diff --git a/compiler/rustc_attr_parsing/src/attributes/test_attrs.rs b/compiler/rustc_attr_parsing/src/attributes/test_attrs.rs index 4ed10b0ff1ac3..89f5e3747c1d6 100644 --- a/compiler/rustc_attr_parsing/src/attributes/test_attrs.rs +++ b/compiler/rustc_attr_parsing/src/attributes/test_attrs.rs @@ -30,7 +30,7 @@ impl SingleAttributeParser for IgnoreParser { ArgParser::List(list) => { let help = list.as_single().and_then(|item| item.meta_item()).and_then(|item| { - item.args().no_args().ok()?; + item.args().as_no_args().ok()?; Some(item.path().to_string()) }); cx.adcx().warn_ill_formed_attribute_input_with_help( diff --git a/compiler/rustc_attr_parsing/src/attributes/traits.rs b/compiler/rustc_attr_parsing/src/attributes/traits.rs index 546bb0364bddc..fe5af66f2a9cb 100644 --- a/compiler/rustc_attr_parsing/src/attributes/traits.rs +++ b/compiler/rustc_attr_parsing/src/attributes/traits.rs @@ -27,9 +27,7 @@ impl SingleAttributeParser for RustcSkipDuringMethodDispatchParser { cx.adcx().expected_not_literal(arg.span()); continue; }; - if let Err(span) = arg.args().no_args() { - cx.adcx().expected_no_args(span); - } + let _ = cx.expect_no_args(arg.args()); let path = arg.path(); let (key, skip): (Symbol, &mut bool) = match path.word_sym() { Some(key @ sym::array) => (key, &mut array), diff --git a/compiler/rustc_attr_parsing/src/context.rs b/compiler/rustc_attr_parsing/src/context.rs index 9c82e6208c24c..9fc7c3c8f1320 100644 --- a/compiler/rustc_attr_parsing/src/context.rs +++ b/compiler/rustc_attr_parsing/src/context.rs @@ -562,6 +562,16 @@ impl<'f, 'sess: 'f> AcceptContext<'f, 'sess> { { arg.expect_name_value(self, span, name) } + + /// Assert that an [`ArgParser`] has no args, or emits an error and return `None`. + pub(crate) fn expect_no_args<'arg>(&mut self, arg: &'arg ArgParser) -> Option<()> { + if let Err(span) = arg.as_no_args() { + self.adcx().expected_no_args(span); + return None; + } + + Some(()) + } } pub(crate) trait ExpectNameValue { diff --git a/compiler/rustc_attr_parsing/src/parser.rs b/compiler/rustc_attr_parsing/src/parser.rs index de505cc8c7ac8..845f1394cc3de 100644 --- a/compiler/rustc_attr_parsing/src/parser.rs +++ b/compiler/rustc_attr_parsing/src/parser.rs @@ -202,7 +202,7 @@ impl ArgParser { /// Assert that there were no args. /// If there were, get a span to the arguments /// (to pass to [`AttributeDiagnosticContext::expected_no_args`](crate::context::AttributeDiagnosticContext::expected_no_args)). - pub fn no_args(&self) -> Result<(), Span> { + pub fn as_no_args(&self) -> Result<(), Span> { match self { Self::NoArgs => Ok(()), Self::List(args) => Err(args.span), diff --git a/compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs b/compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs index f7d35f3ff3b4b..86184e913262e 100644 --- a/compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs +++ b/compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs @@ -47,7 +47,6 @@ use super::{DescribePlaceOpt, RegionName, RegionNameSource, UseSpans}; use crate::borrow_set::{BorrowData, TwoPhaseActivation}; use crate::diagnostics::conflict_errors::StorageDeadOrDrop::LocalStorageDead; use crate::diagnostics::{CapturedMessageOpt, call_kind, find_all_local_uses}; -use crate::prefixes::IsPrefixOf; use crate::{InitializationRequiringAction, MirBorrowckCtxt, WriteKind, borrowck_errors}; #[derive(Debug)] diff --git a/compiler/rustc_borrowck/src/prefixes.rs b/compiler/rustc_borrowck/src/prefixes.rs index 9e51264d8edcb..7ac63e02e318d 100644 --- a/compiler/rustc_borrowck/src/prefixes.rs +++ b/compiler/rustc_borrowck/src/prefixes.rs @@ -8,18 +8,6 @@ use rustc_middle::mir::{PlaceRef, ProjectionElem}; use super::MirBorrowckCtxt; -pub(crate) trait IsPrefixOf<'tcx> { - fn is_prefix_of(&self, other: PlaceRef<'tcx>) -> bool; -} - -impl<'tcx> IsPrefixOf<'tcx> for PlaceRef<'tcx> { - fn is_prefix_of(&self, other: PlaceRef<'tcx>) -> bool { - self.local == other.local - && self.projection.len() <= other.projection.len() - && self.projection == &other.projection[..self.projection.len()] - } -} - pub(super) struct Prefixes<'tcx> { kind: PrefixSet, next: Option>, diff --git a/compiler/rustc_borrowck/src/region_infer/values.rs b/compiler/rustc_borrowck/src/region_infer/values.rs index c1fed1260340f..6a0d70790cfef 100644 --- a/compiler/rustc_borrowck/src/region_infer/values.rs +++ b/compiler/rustc_borrowck/src/region_infer/values.rs @@ -426,19 +426,13 @@ impl ToElementIndex<'_> for RegionVid { } impl<'tcx> ToElementIndex<'tcx> for ty::PlaceholderRegion<'tcx> { - fn add_to_row(self, values: &mut RegionValues<'tcx, N>, row: N) -> bool - where - Self: Into>, - { + fn add_to_row(self, values: &mut RegionValues<'tcx, N>, row: N) -> bool { let placeholder: ty::PlaceholderRegion<'tcx> = self.into(); let index = values.placeholder_indices.lookup_index(placeholder); values.placeholders.insert(row, index) } - fn contained_in_row(self, values: &RegionValues<'tcx, N>, row: N) -> bool - where - Self: Into>, - { + fn contained_in_row(self, values: &RegionValues<'tcx, N>, row: N) -> bool { let placeholder: ty::PlaceholderRegion<'tcx> = self.into(); let index = values.placeholder_indices.lookup_index(placeholder); values.placeholders.contains(row, index) diff --git a/compiler/rustc_borrowck/src/type_check/input_output.rs b/compiler/rustc_borrowck/src/type_check/input_output.rs index 2e6a2962b8760..64c5f5f0c560b 100644 --- a/compiler/rustc_borrowck/src/type_check/input_output.rs +++ b/compiler/rustc_borrowck/src/type_check/input_output.rs @@ -176,7 +176,7 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> { } // In MIR, argument N is stored in local N+1. - let local = Local::from_usize(argument_index + 1); + let local = Local::arg(argument_index); let mir_input_ty = self.body.local_decls[local].ty; diff --git a/compiler/rustc_codegen_cranelift/src/driver/aot.rs b/compiler/rustc_codegen_cranelift/src/driver/aot.rs index 26e518ccc94de..bea254b7b3a6f 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, HashStableContext, StableHasher}; +use rustc_data_structures::stable_hasher::{StableHash, StableHashCtxt, 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 StableHash for OngoingModuleCodegen { + fn stable_hash(&self, _: &mut Hcx, _: &mut StableHasher) { // do nothing } } diff --git a/compiler/rustc_codegen_llvm/src/common.rs b/compiler/rustc_codegen_llvm/src/common.rs index dadf8e9e7d5fa..988e0c4b0513b 100644 --- a/compiler/rustc_codegen_llvm/src/common.rs +++ b/compiler/rustc_codegen_llvm/src/common.rs @@ -8,7 +8,7 @@ use rustc_abi::{self as abi, HasDataLayout as _}; use rustc_ast::Mutability; use rustc_codegen_ssa::common::TypeKind; use rustc_codegen_ssa::traits::*; -use rustc_data_structures::stable_hasher::{HashStable, StableHasher}; +use rustc_data_structures::stable_hasher::{StableHash, StableHasher}; use rustc_hashes::Hash128; use rustc_hir::def_id::DefId; use rustc_middle::bug; @@ -308,7 +308,7 @@ impl<'ll, 'tcx> ConstCodegenMethods for CodegenCx<'ll, 'tcx> { { let hash = self.tcx.with_stable_hashing_context(|mut hcx| { let mut hasher = StableHasher::new(); - alloc.hash_stable(&mut hcx, &mut hasher); + alloc.stable_hash(&mut hcx, &mut hasher); hasher.finish::() }); llvm::set_value_name( diff --git a/compiler/rustc_codegen_llvm/src/debuginfo/metadata/type_map.rs b/compiler/rustc_codegen_llvm/src/debuginfo/metadata/type_map.rs index 9a5c3289cabd8..984b6b009f038 100644 --- a/compiler/rustc_codegen_llvm/src/debuginfo/metadata/type_map.rs +++ b/compiler/rustc_codegen_llvm/src/debuginfo/metadata/type_map.rs @@ -4,8 +4,8 @@ use libc::c_uint; use rustc_abi::{Align, Size, VariantIdx}; use rustc_data_structures::fingerprint::Fingerprint; use rustc_data_structures::fx::FxHashMap; -use rustc_data_structures::stable_hasher::{HashStable, StableHasher}; -use rustc_macros::HashStable; +use rustc_data_structures::stable_hasher::{StableHash, StableHasher}; +use rustc_macros::StableHash; use rustc_middle::bug; use rustc_middle::ty::{self, ExistentialTraitRef, Ty, TyCtxt, Unnormalized}; @@ -16,13 +16,13 @@ use crate::llvm; use crate::llvm::debuginfo::{DIFlags, DIScope, DIType}; mod private { - use rustc_macros::HashStable; + use rustc_macros::StableHash; // This type cannot be constructed outside of this module because // it has a private field. We make use of this in order to prevent // `UniqueTypeId` from being constructed directly, without asserting // the preconditions. - #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, HashStable)] + #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, StableHash)] pub(crate) struct HiddenZst; } @@ -33,7 +33,7 @@ mod private { /// Note that there are some things that only show up in debuginfo, like /// the separate type descriptions for each enum variant. These get an ID /// too because they have their own debuginfo node in LLVM IR. -#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, HashStable)] +#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, StableHash)] pub(super) enum UniqueTypeId<'tcx> { /// The ID of a regular type as it shows up at the language level. Ty(Ty<'tcx>, private::HiddenZst), @@ -130,7 +130,7 @@ impl<'tcx> UniqueTypeId<'tcx> { fn generate_unique_id_string(self, tcx: TyCtxt<'tcx>) -> String { let mut hasher = StableHasher::new(); tcx.with_stable_hashing_context(|mut hcx| { - hcx.while_hashing_spans(false, |hcx| self.hash_stable(hcx, &mut hasher)) + hcx.while_hashing_spans(false, |hcx| self.stable_hash(hcx, &mut hasher)) }); hasher.finish::().to_hex() } diff --git a/compiler/rustc_codegen_ssa/src/common.rs b/compiler/rustc_codegen_ssa/src/common.rs index c963bb9de4b42..8c962fe4ea6e0 100644 --- a/compiler/rustc_codegen_ssa/src/common.rs +++ b/compiler/rustc_codegen_ssa/src/common.rs @@ -90,20 +90,20 @@ pub enum TypeKind { } // FIXME(mw): Anything that is produced via DepGraph::with_task() must implement -// the HashStable trait. Normally DepGraph::with_task() calls are +// the StableHash trait. Normally DepGraph::with_task() calls are // hidden behind queries, but CGU creation is a special case in two // ways: (1) it's not a query and (2) CGU are output nodes, so their // Fingerprints are not actually needed. It remains to be clarified // how exactly this case will be handled in the red/green system but -// for now we content ourselves with providing a no-op HashStable +// for now we content ourselves with providing a no-op StableHash // implementation for CGUs. mod temp_stable_hash_impls { - use rustc_data_structures::stable_hasher::{HashStable, HashStableContext, StableHasher}; + use rustc_data_structures::stable_hasher::{StableHash, StableHashCtxt, StableHasher}; use crate::ModuleCodegen; - impl HashStable for ModuleCodegen { - fn hash_stable(&self, _: &mut Hcx, _: &mut StableHasher) { + impl StableHash for ModuleCodegen { + fn stable_hash(&self, _: &mut Hcx, _: &mut StableHasher) { // do nothing } } diff --git a/compiler/rustc_codegen_ssa/src/debuginfo/type_names.rs b/compiler/rustc_codegen_ssa/src/debuginfo/type_names.rs index b4c6ecd069f82..730272d2be94d 100644 --- a/compiler/rustc_codegen_ssa/src/debuginfo/type_names.rs +++ b/compiler/rustc_codegen_ssa/src/debuginfo/type_names.rs @@ -15,7 +15,7 @@ use std::fmt::Write; use rustc_abi::Integer; use rustc_data_structures::fx::FxHashSet; -use rustc_data_structures::stable_hasher::{HashStable, StableHasher}; +use rustc_data_structures::stable_hasher::{StableHash, StableHasher}; use rustc_hashes::Hash64; use rustc_hir::def_id::DefId; use rustc_hir::definitions::{DefPathData, DefPathDataName, DisambiguatedDefPathData}; @@ -734,7 +734,7 @@ fn push_debuginfo_const_name<'tcx>(tcx: TyCtxt<'tcx>, ct: ty::Const<'tcx>, outpu // avoiding collisions and will make the emitted type names shorter. let hash_short = tcx.with_stable_hashing_context(|mut hcx| { let mut hasher = StableHasher::new(); - hcx.while_hashing_spans(false, |hcx| cv.hash_stable(hcx, &mut hasher)); + hcx.while_hashing_spans(false, |hcx| cv.stable_hash(hcx, &mut hasher)); hasher.finish::() }); diff --git a/compiler/rustc_codegen_ssa/src/mir/block.rs b/compiler/rustc_codegen_ssa/src/mir/block.rs index 2967db9df787c..55001d85211a4 100644 --- a/compiler/rustc_codegen_ssa/src/mir/block.rs +++ b/compiler/rustc_codegen_ssa/src/mir/block.rs @@ -522,7 +522,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> { if self.fn_abi.c_variadic { // The `VaList` "spoofed" argument is just after all the real arguments. let va_list_arg_idx = self.fn_abi.args.len(); - match self.locals[mir::Local::from_usize(1 + va_list_arg_idx)] { + match self.locals[mir::Local::arg(va_list_arg_idx)] { LocalRef::Place(va_list) => { bx.va_end(va_list.val.llval); diff --git a/compiler/rustc_data_structures/src/intern.rs b/compiler/rustc_data_structures/src/intern.rs index 419cdc115518c..268ee62da1461 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, HashStableContext, StableHasher}; +use crate::stable_hasher::{StableHash, StableHashCtxt, StableHasher}; mod private { #[derive(Clone, Copy, Debug)] @@ -103,12 +103,12 @@ where } } -impl HashStable for Interned<'_, T> +impl StableHash for Interned<'_, T> where - T: HashStable, + T: StableHash, { - fn hash_stable(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { - self.0.hash_stable(hcx, hasher); + fn stable_hash(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { + self.0.stable_hash(hcx, hasher); } } diff --git a/compiler/rustc_data_structures/src/packed.rs b/compiler/rustc_data_structures/src/packed.rs index 30f76cb4476c5..0ac2008ee6673 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, HashStableContext, StableHasher}; +use crate::stable_hasher::{StableHash, StableHashCtxt, StableHasher}; /// A packed 128-bit integer. Useful for reducing the size of structures in /// some cases. @@ -60,10 +60,10 @@ impl fmt::UpperHex for Pu128 { } } -impl HashStable for Pu128 { +impl StableHash for Pu128 { #[inline] - fn hash_stable(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { - { self.0 }.hash_stable(hcx, hasher) + fn stable_hash(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { + { self.0 }.stable_hash(hcx, hasher) } } diff --git a/compiler/rustc_data_structures/src/sorted_map.rs b/compiler/rustc_data_structures/src/sorted_map.rs index ca813a36059ba..8c6aa939b4654 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, HashStableContext, StableHasher, StableOrd}; +use crate::stable_hasher::{StableHash, StableHashCtxt, StableHasher, StableOrd}; mod index_map; @@ -347,10 +347,10 @@ impl FromIterator<(K, V)> for SortedMap { } } -impl HashStable for SortedMap { +impl StableHash for SortedMap { #[inline] - fn hash_stable(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { - self.data.hash_stable(hcx, hasher); + fn stable_hash(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { + self.data.stable_hash(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 b688601fd5d25..8c439437b8bec 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; +use rustc_macros::StableHash; /// 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; /// in-place. /// /// [`SortedMap`]: super::SortedMap -#[derive(Clone, Debug, HashStable)] +#[derive(Clone, Debug, StableHash)] 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 9d4b03f63c098..17effa07e3bcb 100644 --- a/compiler/rustc_data_structures/src/stable_hasher.rs +++ b/compiler/rustc_data_structures/src/stable_hasher.rs @@ -15,11 +15,11 @@ pub use rustc_stable_hash::{ FromStableHash, SipHasher128Hash as StableHasherHash, StableSipHasher128 as StableHasher, }; -/// This trait lets `HashStable` and `derive(HashStable)` be used in +/// This trait lets `StableHash` and `derive(StableHash)` 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 { +pub trait StableHashCtxt { /// The main event: stable hashing of a span. fn span_hash_stable(&mut self, span: RawSpan, hasher: &mut StableHasher); @@ -29,7 +29,7 @@ pub trait HashStableContext { /// Get the hashing controls. fn hashing_controls(&self) -> HashingControls; - /// Assert that the provided `HashStableContext` is configured with the default + /// Assert that the provided `StableHashCtxt` 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); } @@ -46,42 +46,42 @@ pub struct RawDefId(pub u32, pub u32); // `DefPathHash`. pub struct RawDefPathHash(pub [u8; 16]); -/// Something that implements `HashStable` can be hashed in a way that is +/// Something that implements `StableHash` can be hashed in a way that is /// stable across multiple compilation sessions. /// -/// Note that `HashStable` imposes rather more strict requirements than usual +/// Note that `StableHash` imposes rather more strict requirements than usual /// hash functions: /// /// - Stable hashes are sometimes used as identifiers. Therefore they must /// conform to the corresponding `PartialEq` implementations: /// -/// - `x == y` implies `hash_stable(x) == hash_stable(y)`, and -/// - `x != y` implies `hash_stable(x) != hash_stable(y)`. +/// - `x == y` implies `stable_hash(x) == stable_hash(y)`, and +/// - `x != y` implies `stable_hash(x) != stable_hash(y)`. /// /// That second condition is usually not required for hash functions -/// (e.g. `Hash`). In practice this means that `hash_stable` must feed any +/// (e.g. `Hash`). In practice this means that `stable_hash` must feed any /// information into the hasher that a `PartialEq` comparison takes into /// account. See [#49300](https://github.com/rust-lang/rust/issues/49300) /// for an example where violating this invariant has caused trouble in the /// past. /// -/// - `hash_stable()` must be independent of the current +/// - `stable_hash()` must be independent of the current /// compilation session. E.g. they must not hash memory addresses or other /// things that are "randomly" assigned per compilation session. /// -/// - `hash_stable()` must be independent of the host architecture. The +/// - `stable_hash()` 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 StableHash { + fn stable_hash(&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; + type KeyType: Ord + Sized + StableHash; + fn to_stable_hash_key(&self, hcx: &mut Hcx) -> Self::KeyType; } /// Trait for marking a type as having a sort order that is @@ -156,20 +156,20 @@ impl StableCompare for T { } } -/// Implement HashStable by just calling `Hash::hash()`. Also implement `StableOrd` for the type since -/// that has the same requirements. +/// Implement StableHash by just calling `Hash::hash()`. Also implement `StableOrd` for the type +/// since that has the same requirements. /// /// **WARNING** This is only valid for types that *really* don't need any context for fingerprinting. /// But it is easy to misuse this macro (see [#96013](https://github.com/rust-lang/rust/issues/96013) /// for examples). Therefore this macro is not exported and should only be used in the limited cases /// here in this module. /// -/// Use `#[derive(HashStable)]` instead. +/// Use `#[derive(StableHash)]` instead. macro_rules! impl_stable_traits_for_trivial_type { ($t:ty) => { - impl $crate::stable_hasher::HashStable for $t { + impl $crate::stable_hasher::StableHash for $t { #[inline] - fn hash_stable( + fn stable_hash( &self, _: &mut Hcx, hasher: &mut $crate::stable_hasher::StableHasher, @@ -212,9 +212,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 StableHash for Hash128 { #[inline] - fn hash_stable(&self, _: &mut Hcx, hasher: &mut StableHasher) { + fn stable_hash(&self, _: &mut Hcx, hasher: &mut StableHasher) { self.as_u128().hash(hasher); } } @@ -227,64 +227,64 @@ 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 StableHash for ! { + fn stable_hash(&self, _hcx: &mut Hcx, _hasher: &mut StableHasher) { unreachable!() } } -impl HashStable for PhantomData { - fn hash_stable(&self, _hcx: &mut Hcx, _hasher: &mut StableHasher) {} +impl StableHash for PhantomData { + fn stable_hash(&self, _hcx: &mut Hcx, _hasher: &mut StableHasher) {} } -impl HashStable for NonZero { +impl StableHash for NonZero { #[inline] - fn hash_stable(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { - self.get().hash_stable(hcx, hasher) + fn stable_hash(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { + self.get().stable_hash(hcx, hasher) } } -impl HashStable for NonZero { +impl StableHash for NonZero { #[inline] - fn hash_stable(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { - self.get().hash_stable(hcx, hasher) + fn stable_hash(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { + self.get().stable_hash(hcx, hasher) } } -impl HashStable for f32 { - fn hash_stable(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { +impl StableHash for f32 { + fn stable_hash(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { let val: u32 = self.to_bits(); - val.hash_stable(hcx, hasher); + val.stable_hash(hcx, hasher); } } -impl HashStable for f64 { - fn hash_stable(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { +impl StableHash for f64 { + fn stable_hash(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { let val: u64 = self.to_bits(); - val.hash_stable(hcx, hasher); + val.stable_hash(hcx, hasher); } } -impl HashStable for ::std::cmp::Ordering { +impl StableHash for ::std::cmp::Ordering { #[inline] - fn hash_stable(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { - (*self as i8).hash_stable(hcx, hasher); + fn stable_hash(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { + (*self as i8).stable_hash(hcx, hasher); } } -impl HashStable for (T1,) { +impl StableHash for (T1,) { #[inline] - fn hash_stable(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { + fn stable_hash(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { let (ref _0,) = *self; - _0.hash_stable(hcx, hasher); + _0.stable_hash(hcx, hasher); } } -impl HashStable for (T1, T2) { - fn hash_stable(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { +impl StableHash for (T1, T2) { + fn stable_hash(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { let (ref _0, ref _1) = *self; - _0.hash_stable(hcx, hasher); - _1.hash_stable(hcx, hasher); + _0.stable_hash(hcx, hasher); + _1.stable_hash(hcx, hasher); } } @@ -296,17 +296,17 @@ impl StableOrd for (T1, T2) { const THIS_IMPLEMENTATION_HAS_BEEN_TRIPLE_CHECKED: () = (); } -impl HashStable for (T1, T2, T3) +impl StableHash for (T1, T2, T3) where - T1: HashStable, - T2: HashStable, - T3: HashStable, + T1: StableHash, + T2: StableHash, + T3: StableHash, { - fn hash_stable(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { + fn stable_hash(&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); - _2.hash_stable(hcx, hasher); + _0.stable_hash(hcx, hasher); + _1.stable_hash(hcx, hasher); + _2.stable_hash(hcx, hasher); } } @@ -319,19 +319,19 @@ impl StableOrd for (T1, T2, T3) { const THIS_IMPLEMENTATION_HAS_BEEN_TRIPLE_CHECKED: () = (); } -impl HashStable for (T1, T2, T3, T4) +impl StableHash for (T1, T2, T3, T4) where - T1: HashStable, - T2: HashStable, - T3: HashStable, - T4: HashStable, + T1: StableHash, + T2: StableHash, + T3: StableHash, + T4: StableHash, { - fn hash_stable(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { + fn stable_hash(&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); - _2.hash_stable(hcx, hasher); - _3.hash_stable(hcx, hasher); + _0.stable_hash(hcx, hasher); + _1.stable_hash(hcx, hasher); + _2.stable_hash(hcx, hasher); + _3.stable_hash(hcx, hasher); } } @@ -346,97 +346,93 @@ impl StableOrd for ( const THIS_IMPLEMENTATION_HAS_BEEN_TRIPLE_CHECKED: () = (); } -impl HashStable for [T] { - default fn hash_stable( - &self, - hcx: &mut Hcx, - hasher: &mut StableHasher, - ) { - self.len().hash_stable(hcx, hasher); +impl StableHash for [T] { + default fn stable_hash(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { + self.len().stable_hash(hcx, hasher); for item in self { - item.hash_stable(hcx, hasher); + item.stable_hash(hcx, hasher); } } } -impl HashStable for [u8] { - fn hash_stable(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { - self.len().hash_stable(hcx, hasher); +impl StableHash for [u8] { + fn stable_hash(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { + self.len().stable_hash(hcx, hasher); hasher.write(self); } } -impl HashStable for Vec { +impl StableHash for Vec { #[inline] - fn hash_stable(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { - self[..].hash_stable(hcx, hasher); + fn stable_hash(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { + self[..].stable_hash(hcx, hasher); } } -impl HashStable for indexmap::IndexMap +impl StableHash for indexmap::IndexMap where - K: HashStable + Eq + Hash, - V: HashStable, + K: StableHash + Eq + Hash, + V: StableHash, R: BuildHasher, { #[inline] - fn hash_stable(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { - self.len().hash_stable(hcx, hasher); + fn stable_hash(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { + self.len().stable_hash(hcx, hasher); for kv in self { - kv.hash_stable(hcx, hasher); + kv.stable_hash(hcx, hasher); } } } -impl HashStable for indexmap::IndexSet +impl StableHash for indexmap::IndexSet where - K: HashStable + Eq + Hash, + K: StableHash + Eq + Hash, R: BuildHasher, { #[inline] - fn hash_stable(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { - self.len().hash_stable(hcx, hasher); + fn stable_hash(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { + self.len().stable_hash(hcx, hasher); for key in self { - key.hash_stable(hcx, hasher); + key.stable_hash(hcx, hasher); } } } -impl HashStable for SmallVec<[A; N]> +impl StableHash for SmallVec<[A; N]> where - A: HashStable, + A: StableHash, { #[inline] - fn hash_stable(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { - self[..].hash_stable(hcx, hasher); + fn stable_hash(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { + self[..].stable_hash(hcx, hasher); } } -impl HashStable for Box { +impl StableHash for Box { #[inline] - fn hash_stable(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { - (**self).hash_stable(hcx, hasher); + fn stable_hash(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { + (**self).stable_hash(hcx, hasher); } } -impl HashStable for ::std::rc::Rc { +impl StableHash for ::std::rc::Rc { #[inline] - fn hash_stable(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { - (**self).hash_stable(hcx, hasher); + fn stable_hash(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { + (**self).stable_hash(hcx, hasher); } } -impl HashStable for ::std::sync::Arc { +impl StableHash for ::std::sync::Arc { #[inline] - fn hash_stable(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { - (**self).hash_stable(hcx, hasher); + fn stable_hash(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { + (**self).stable_hash(hcx, hasher); } } -impl HashStable for str { +impl StableHash for str { #[inline] - fn hash_stable(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { - self.as_bytes().hash_stable(hcx, hasher); + fn stable_hash(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { + self.as_bytes().stable_hash(hcx, hasher); } } @@ -448,10 +444,10 @@ impl StableOrd for &str { const THIS_IMPLEMENTATION_HAS_BEEN_TRIPLE_CHECKED: () = (); } -impl HashStable for String { +impl StableHash for String { #[inline] - fn hash_stable(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { - self[..].hash_stable(hcx, hasher); + fn stable_hash(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { + self[..].stable_hash(hcx, hasher); } } @@ -474,15 +470,15 @@ impl ToStableHashKey for String { 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 StableHash for bool { #[inline] - fn hash_stable(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { - (if *self { 1u8 } else { 0u8 }).hash_stable(hcx, hasher); + fn stable_hash(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { + (if *self { 1u8 } else { 0u8 }).stable_hash(hcx, hasher); } } @@ -493,17 +489,17 @@ impl StableOrd for bool { const THIS_IMPLEMENTATION_HAS_BEEN_TRIPLE_CHECKED: () = (); } -impl HashStable for Option +impl StableHash for Option where - T: HashStable, + T: StableHash, { #[inline] - fn hash_stable(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { + fn stable_hash(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { if let Some(ref value) = *self { - 1u8.hash_stable(hcx, hasher); - value.hash_stable(hcx, hasher); + 1u8.stable_hash(hcx, hasher); + value.stable_hash(hcx, hasher); } else { - 0u8.hash_stable(hcx, hasher); + 0u8.stable_hash(hcx, hasher); } } } @@ -515,81 +511,81 @@ impl StableOrd for Option { const THIS_IMPLEMENTATION_HAS_BEEN_TRIPLE_CHECKED: () = (); } -impl HashStable for Result +impl StableHash for Result where - T1: HashStable, - T2: HashStable, + T1: StableHash, + T2: StableHash, { #[inline] - fn hash_stable(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { - mem::discriminant(self).hash_stable(hcx, hasher); + fn stable_hash(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { + mem::discriminant(self).stable_hash(hcx, hasher); match *self { - Ok(ref x) => x.hash_stable(hcx, hasher), - Err(ref x) => x.hash_stable(hcx, hasher), + Ok(ref x) => x.stable_hash(hcx, hasher), + Err(ref x) => x.stable_hash(hcx, hasher), } } } -impl<'a, T> HashStable for &'a T +impl<'a, T> StableHash for &'a T where - T: HashStable + ?Sized, + T: StableHash + ?Sized, { #[inline] - fn hash_stable(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { - (**self).hash_stable(hcx, hasher); + fn stable_hash(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { + (**self).stable_hash(hcx, hasher); } } -impl HashStable for ::std::mem::Discriminant { +impl StableHash for ::std::mem::Discriminant { #[inline] - fn hash_stable(&self, _: &mut Hcx, hasher: &mut StableHasher) { + fn stable_hash(&self, _: &mut Hcx, hasher: &mut StableHasher) { ::std::hash::Hash::hash(self, hasher); } } -impl HashStable for ::std::ops::RangeInclusive +impl StableHash for ::std::ops::RangeInclusive where - T: HashStable, + T: StableHash, { #[inline] - fn hash_stable(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { - self.start().hash_stable(hcx, hasher); - self.end().hash_stable(hcx, hasher); + fn stable_hash(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { + self.start().stable_hash(hcx, hasher); + self.end().stable_hash(hcx, hasher); } } -impl HashStable for IndexSlice +impl StableHash for IndexSlice where - T: HashStable, + T: StableHash, { - fn hash_stable(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { - self.len().hash_stable(hcx, hasher); + fn stable_hash(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { + self.len().stable_hash(hcx, hasher); for v in &self.raw { - v.hash_stable(hcx, hasher); + v.stable_hash(hcx, hasher); } } } -impl HashStable for IndexVec +impl StableHash for IndexVec where - T: HashStable, + T: StableHash, { - fn hash_stable(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { - self.len().hash_stable(hcx, hasher); + fn stable_hash(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { + self.len().stable_hash(hcx, hasher); for v in &self.raw { - v.hash_stable(hcx, hasher); + v.stable_hash(hcx, hasher); } } } -impl HashStable for DenseBitSet { - fn hash_stable(&self, _hcx: &mut Hcx, hasher: &mut StableHasher) { +impl StableHash for DenseBitSet { + fn stable_hash(&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 StableHash for bit_set::BitMatrix { + fn stable_hash(&self, _hcx: &mut Hcx, hasher: &mut StableHasher) { ::std::hash::Hash::hash(self, hasher); } } @@ -599,39 +595,39 @@ impl_stable_traits_for_trivial_type!(::std::ffi::OsStr); impl_stable_traits_for_trivial_type!(::std::path::Path); impl_stable_traits_for_trivial_type!(::std::path::PathBuf); -// It is not safe to implement HashStable for HashSet, HashMap or any other collection type +// It is not safe to implement StableHash 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 !StableHash for std::collections::HashSet {} +impl !StableHash for std::collections::HashMap {} -impl HashStable for ::std::collections::BTreeMap +impl StableHash for ::std::collections::BTreeMap where - K: HashStable + StableOrd, - V: HashStable, + K: StableHash + StableOrd, + V: StableHash, { - fn hash_stable(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { - self.len().hash_stable(hcx, hasher); + fn stable_hash(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { + self.len().stable_hash(hcx, hasher); for entry in self.iter() { - entry.hash_stable(hcx, hasher); + entry.stable_hash(hcx, hasher); } } } -impl HashStable for ::std::collections::BTreeSet +impl StableHash for ::std::collections::BTreeSet where - K: HashStable + StableOrd, + K: StableHash + StableOrd, { - fn hash_stable(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { - self.len().hash_stable(hcx, hasher); + fn stable_hash(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { + self.len().stable_hash(hcx, hasher); for entry in self.iter() { - entry.hash_stable(hcx, hasher); + entry.stable_hash(hcx, hasher); } } } /// Controls what data we do or do not hash. -/// Whenever a `HashStable` implementation caches its +/// Whenever a `StableHash` implementation caches its /// result, it needs to include `HashingControls` as part /// of the key, to ensure that it does not produce an incorrect /// result (for example, using a `Fingerprint` produced while diff --git a/compiler/rustc_data_structures/src/stable_hasher/tests.rs b/compiler/rustc_data_structures/src/stable_hasher/tests.rs index da12d7ed7876b..37c73cee9f30b 100644 --- a/compiler/rustc_data_structures/src/stable_hasher/tests.rs +++ b/compiler/rustc_data_structures/src/stable_hasher/tests.rs @@ -7,7 +7,7 @@ use super::*; // ways). The expected values depend on the hashing algorithm used, so they // need to be updated whenever StableHasher changes its hashing algorithm. -impl HashStableContext for () { +impl StableHashCtxt for () { fn span_hash_stable(&mut self, _: RawSpan, _: &mut StableHasher) { panic!(); } @@ -22,10 +22,10 @@ impl HashStableContext for () { } } -fn hash(t: &T) -> Hash128 { +fn hash(t: &T) -> Hash128 { let mut h = StableHasher::new(); let hcx = &mut (); - t.hash_stable(hcx, &mut h); + t.stable_hash(hcx, &mut h); h.finish() } @@ -59,14 +59,14 @@ fn test_attribute_permutation() { b: $ty, } - impl HashStable for Foo { - fn hash_stable( + impl StableHash for Foo { + fn stable_hash( &self, hcx: &mut Hcx, hasher: &mut StableHasher, ) { - self.a.hash_stable(hcx, hasher); - self.b.hash_stable(hcx, hasher); + self.a.stable_hash(hcx, hasher); + self.b.stable_hash(hcx, hasher); } } diff --git a/compiler/rustc_data_structures/src/steal.rs b/compiler/rustc_data_structures/src/steal.rs index 8e55323873951..b9adc372861a6 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, HashStableContext, StableHasher}; +use crate::stable_hasher::{StableHash, StableHashCtxt, 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) { - self.borrow().hash_stable(hcx, hasher); +impl StableHash for Steal { + fn stable_hash(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { + self.borrow().stable_hash(hcx, hasher); } } diff --git a/compiler/rustc_data_structures/src/svh.rs b/compiler/rustc_data_structures/src/svh.rs index e64793f0778f7..2c4e00c824d80 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}; +use rustc_macros::{Decodable_NoContext, Encodable_NoContext, StableHash}; use crate::fingerprint::Fingerprint; @@ -20,7 +20,7 @@ use crate::fingerprint::Fingerprint; Encodable_NoContext, Decodable_NoContext, Hash, - HashStable + StableHash )] 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 59baa441d2a4a..867a702093e7b 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, HashStableContext, StableHasher}; +use crate::stable_hasher::{StableHash, StableHashCtxt, StableHasher}; /// This describes tags that the [`TaggedRef`] struct can hold. /// @@ -259,14 +259,14 @@ impl Hash for TaggedRef<'_, P, T> { } } -impl<'a, P, T> HashStable for TaggedRef<'a, P, T> +impl<'a, P, T> StableHash for TaggedRef<'a, P, T> where - P: HashStable + Aligned + ?Sized, - T: Tag + HashStable, + P: StableHash + Aligned + ?Sized, + T: Tag + StableHash, { - fn hash_stable(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { - self.pointer().hash_stable(hcx, hasher); - self.tag().hash_stable(hcx, hasher); + fn stable_hash(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { + self.pointer().stable_hash(hcx, hasher); + self.tag().stable_hash(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 a1c53ef854326..78f24412dbb4c 100644 --- a/compiler/rustc_data_structures/src/tagged_ptr/tests.rs +++ b/compiler/rustc_data_structures/src/tagged_ptr/tests.rs @@ -3,7 +3,7 @@ use std::ptr; use rustc_hashes::Hash128; use super::*; -use crate::stable_hasher::{HashStable, StableHasher}; +use crate::stable_hasher::{StableHash, StableHasher}; /// A tag type used in [`TaggedRef`] tests. #[derive(Copy, Clone, Debug, PartialEq, Eq)] @@ -32,13 +32,13 @@ unsafe impl Tag for Tag2 { } } -impl HashStable for Tag2 { - fn hash_stable( +impl StableHash for Tag2 { + fn stable_hash( &self, hcx: &mut Hcx, hasher: &mut crate::stable_hasher::StableHasher, ) { - (*self as u8).hash_stable(hcx, hasher); + (*self as u8).stable_hash(hcx, hasher); } } @@ -69,13 +69,13 @@ fn smoke() { fn stable_hash_hashes_as_tuple() { let hash_packed = { let mut hasher = StableHasher::new(); - TaggedRef::new(&12, Tag2::B11).hash_stable(&mut (), &mut hasher); + TaggedRef::new(&12, Tag2::B11).stable_hash(&mut (), &mut hasher); hasher.finish::() }; let hash_tupled = { let mut hasher = StableHasher::new(); - (&12, Tag2::B11).hash_stable(&mut (), &mut hasher); + (&12, Tag2::B11).stable_hash(&mut (), &mut hasher); hasher.finish::() }; diff --git a/compiler/rustc_data_structures/src/unord.rs b/compiler/rustc_data_structures/src/unord.rs index 4c033065abe3d..779615f73039f 100644 --- a/compiler/rustc_data_structures/src/unord.rs +++ b/compiler/rustc_data_structures/src/unord.rs @@ -13,7 +13,7 @@ use rustc_macros::{Decodable_NoContext, Encodable_NoContext}; use crate::fingerprint::Fingerprint; use crate::fx::{FxBuildHasher, FxHashMap, FxHashSet}; use crate::stable_hasher::{ - HashStable, HashStableContext, StableCompare, StableHasher, ToStableHashKey, + StableCompare, StableHash, StableHashCtxt, StableHasher, ToStableHashKey, }; /// `UnordItems` is the order-less version of `Iterator`. It only contains methods @@ -145,7 +145,7 @@ 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, { @@ -172,7 +172,7 @@ impl> UnordItems { #[inline] pub fn collect_sorted(self, hcx: &mut Hcx, cache_sort_key: bool) -> C where - Hcx: HashStableContext, + Hcx: StableHashCtxt, T: ToStableHashKey, C: FromIterator + BorrowMut<[T]>, { @@ -320,7 +320,7 @@ impl UnordSet { #[inline] pub fn to_sorted(&self, hcx: &mut Hcx, cache_sort_key: bool) -> Vec<&V> where - Hcx: HashStableContext, + Hcx: StableHashCtxt, V: ToStableHashKey, { to_sorted_vec(hcx, self.inner.iter(), cache_sort_key, |&x| x) @@ -363,7 +363,7 @@ impl UnordSet { #[inline] pub fn into_sorted(self, hcx: &mut Hcx, cache_sort_key: bool) -> Vec where - Hcx: HashStableContext, + Hcx: StableHashCtxt, V: ToStableHashKey, { to_sorted_vec(hcx, self.inner.into_iter(), cache_sort_key, |x| x) @@ -420,9 +420,9 @@ impl> From> for UnordSet } } -impl HashStable for UnordSet { +impl StableHash for UnordSet { #[inline] - fn hash_stable(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { + fn stable_hash(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { hash_iter_order_independent(self.inner.iter(), hcx, hasher); } } @@ -562,7 +562,7 @@ impl UnordMap { #[inline] pub fn to_sorted(&self, hcx: &mut Hcx, cache_sort_key: bool) -> Vec<(&K, &V)> where - Hcx: HashStableContext, + Hcx: StableHashCtxt, K: ToStableHashKey, { to_sorted_vec(hcx, self.inner.iter(), cache_sort_key, |&(k, _)| k) @@ -590,7 +590,7 @@ impl UnordMap { #[inline] pub fn into_sorted(self, hcx: &mut Hcx, cache_sort_key: bool) -> Vec<(K, V)> where - Hcx: HashStableContext, + Hcx: StableHashCtxt, K: ToStableHashKey, { to_sorted_vec(hcx, self.inner.into_iter(), cache_sort_key, |(k, _)| k) @@ -623,7 +623,7 @@ impl UnordMap { cache_sort_key: bool, ) -> impl Iterator where - Hcx: HashStableContext, + Hcx: StableHashCtxt, K: ToStableHashKey, { to_sorted_vec(hcx, self.inner.iter(), cache_sort_key, |&(k, _)| k) @@ -650,9 +650,9 @@ where } } -impl HashStable for UnordMap { +impl StableHash for UnordMap { #[inline] - fn hash_stable(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { + fn stable_hash(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { hash_iter_order_independent(self.inner.iter(), hcx, hasher); } } @@ -713,9 +713,9 @@ impl> From> for UnordBag { } } -impl HashStable for UnordBag { +impl StableHash for UnordBag { #[inline] - fn hash_stable(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { + fn stable_hash(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { hash_iter_order_independent(self.inner.iter(), hcx, hasher); } } @@ -728,7 +728,7 @@ fn to_sorted_vec( extract_key: fn(&T) -> &K, ) -> Vec where - Hcx: HashStableContext, + Hcx: StableHashCtxt, I: Iterator, K: ToStableHashKey, { @@ -743,8 +743,8 @@ where } fn hash_iter_order_independent< - Hcx: HashStableContext, - T: HashStable, + Hcx: StableHashCtxt, + T: StableHash, I: Iterator + ExactSizeIterator, >( mut it: I, @@ -752,7 +752,7 @@ fn hash_iter_order_independent< hasher: &mut StableHasher, ) { let len = it.len(); - len.hash_stable(hcx, hasher); + len.stable_hash(hcx, hasher); match len { 0 => { @@ -760,17 +760,17 @@ fn hash_iter_order_independent< } 1 => { // No need to instantiate a hasher - it.next().unwrap().hash_stable(hcx, hasher); + it.next().unwrap().stable_hash(hcx, hasher); } _ => { let mut accumulator = Fingerprint::ZERO; for item in it { let mut item_hasher = StableHasher::new(); - item.hash_stable(hcx, &mut item_hasher); + item.stable_hash(hcx, &mut item_hasher); let item_fingerprint: Fingerprint = item_hasher.finish(); accumulator = accumulator.combine_commutative(item_fingerprint); } - accumulator.hash_stable(hcx, hasher); + accumulator.stable_hash(hcx, hasher); } } } diff --git a/compiler/rustc_error_messages/src/lib.rs b/compiler/rustc_error_messages/src/lib.rs index bbcda7bce2177..2722db0600758 100644 --- a/compiler/rustc_error_messages/src/lib.rs +++ b/compiler/rustc_error_messages/src/lib.rs @@ -7,7 +7,7 @@ use std::borrow::Cow; pub use fluent_bundle::types::FluentType; pub use fluent_bundle::{self, FluentArgs, FluentError, FluentValue}; -use rustc_macros::{Decodable, Encodable, HashStable}; +use rustc_macros::{Decodable, Encodable, StableHash}; use rustc_span::Span; pub use unic_langid::{LanguageIdentifier, langid}; @@ -28,7 +28,7 @@ pub fn register_functions(bundle: &mut fluent_bundle::bundle::FluentBundle /// diagnostic messages. /// /// Intended to be removed once diagnostics are entirely translatable. -#[derive(Clone, Debug, PartialEq, Eq, Hash, Encodable, Decodable, HashStable)] +#[derive(Clone, Debug, PartialEq, Eq, Hash, Encodable, Decodable, StableHash)] #[rustc_diagnostic_item = "DiagMessage"] pub enum DiagMessage { /// Non-translatable diagnostic message or a message that has been translated eagerly. @@ -89,7 +89,7 @@ pub struct SpanLabel { /// the error, and would be rendered with `^^^`. /// - They can have a *label*. In this case, the label is written next /// to the mark in the snippet when we render. -#[derive(Clone, Debug, Hash, PartialEq, Eq, Encodable, Decodable, HashStable)] +#[derive(Clone, Debug, Hash, PartialEq, Eq, Encodable, Decodable, StableHash)] pub struct MultiSpan { primary_spans: Vec, span_labels: Vec<(Span, DiagMessage)>, @@ -268,10 +268,7 @@ pub fn fluent_value_from_str_list_sep_by_and(l: Vec>) -> FluentValu type Args = (); type Error = (); - fn construct(lang: LanguageIdentifier, _args: Self::Args) -> Result - where - Self: Sized, - { + fn construct(lang: LanguageIdentifier, _args: Self::Args) -> Result { let locale = icu_locale_from_unic_langid(lang) .unwrap_or_else(|| rustc_baked_icu_data::supported_locales::EN); let list_formatter = icu_list::ListFormatter::try_new_and_unstable( diff --git a/compiler/rustc_errors/src/diagnostic.rs b/compiler/rustc_errors/src/diagnostic.rs index 377d96b73e9b8..2fbb90b770261 100644 --- a/compiler/rustc_errors/src/diagnostic.rs +++ b/compiler/rustc_errors/src/diagnostic.rs @@ -143,10 +143,7 @@ impl<'a, F: FnOnce(&mut Diag<'_, ()>)> Diagnostic<'a, ()> for DiagDecorator { /// Trait implemented by error types. This should not be implemented manually. Instead, use /// `#[derive(Subdiagnostic)]` -- see [rustc_macros::Subdiagnostic]. #[rustc_diagnostic_item = "Subdiagnostic"] -pub trait Subdiagnostic -where - Self: Sized, -{ +pub trait Subdiagnostic { /// Add a subdiagnostic to an existing diagnostic. fn add_to_diag(self, diag: &mut Diag<'_, G>); } diff --git a/compiler/rustc_feature/src/unstable.rs b/compiler/rustc_feature/src/unstable.rs index d77031564db5d..1e58e6159ccb2 100644 --- a/compiler/rustc_feature/src/unstable.rs +++ b/compiler/rustc_feature/src/unstable.rs @@ -5,7 +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_data_structures::stable_hasher::{StableHash, StableHashCtxt, StableHasher}; use rustc_span::{Span, Symbol, sym}; use super::{Feature, to_nonzero}; @@ -120,29 +120,29 @@ impl Features { } } -impl HashStable for Features { - fn hash_stable(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { +impl StableHash for Features { + fn stable_hash(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { // `enabled_features` is skipped because it's the sum of the lang and lib features. let Features { enabled_lang_features, enabled_lib_features, enabled_features: _ } = self; - enabled_lang_features.hash_stable(hcx, hasher); - enabled_lib_features.hash_stable(hcx, hasher); + enabled_lang_features.stable_hash(hcx, hasher); + enabled_lib_features.stable_hash(hcx, hasher); } } -impl HashStable for EnabledLangFeature { - fn hash_stable(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { +impl StableHash for EnabledLangFeature { + fn stable_hash(&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); + gate_name.stable_hash(hcx, hasher); + attr_sp.stable_hash(hcx, hasher); + stable_since.stable_hash(hcx, hasher); } } -impl HashStable for EnabledLibFeature { - fn hash_stable(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { +impl StableHash for EnabledLibFeature { + fn stable_hash(&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); + gate_name.stable_hash(hcx, hasher); + attr_sp.stable_hash(hcx, hasher); } } diff --git a/compiler/rustc_hir/src/attrs/data_structures.rs b/compiler/rustc_hir/src/attrs/data_structures.rs index 556eb428a1b87..4691116442864 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, PrintAttribute}; +use rustc_macros::{Decodable, Encodable, PrintAttribute, StableHash}; use rustc_span::def_id::DefId; use rustc_span::hygiene::Transparency; use rustc_span::{ErrorGuaranteed, Ident, Span, Symbol}; @@ -24,7 +24,7 @@ use crate::attrs::pretty_printing::PrintAttribute; use crate::limit::Limit; use crate::{DefaultBodyStability, PartialConstStability, RustcVersion, Stability}; -#[derive(Copy, Clone, Debug, HashStable, Encodable, Decodable, PrintAttribute)] +#[derive(Copy, Clone, Debug, StableHash, 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 @@ -37,7 +37,7 @@ pub enum EiiImplResolution { Error(ErrorGuaranteed), } -#[derive(Copy, Clone, Debug, HashStable, Encodable, Decodable, PrintAttribute)] +#[derive(Copy, Clone, Debug, StableHash, Encodable, Decodable, PrintAttribute)] pub struct EiiImpl { pub resolution: EiiImplResolution, pub impl_marked_unsafe: bool, @@ -46,7 +46,7 @@ pub struct EiiImpl { pub is_default: bool, } -#[derive(Copy, Clone, Debug, HashStable, Encodable, Decodable, PrintAttribute)] +#[derive(Copy, Clone, Debug, StableHash, Encodable, Decodable, PrintAttribute)] pub struct EiiDecl { pub foreign_item: DefId, /// whether or not it is unsafe to implement this EII @@ -54,7 +54,7 @@ pub struct EiiDecl { pub name: Ident, } -#[derive(Copy, Clone, PartialEq, Encodable, Decodable, Debug, HashStable, PrintAttribute)] +#[derive(Copy, Clone, PartialEq, Encodable, Decodable, Debug, StableHash, PrintAttribute)] pub enum CguKind { No, PreDashLto, @@ -62,7 +62,7 @@ pub enum CguKind { Any, } -#[derive(Copy, Clone, PartialEq, Encodable, Decodable, Debug, HashStable, PrintAttribute)] +#[derive(Copy, Clone, PartialEq, Encodable, Decodable, Debug, StableHash, PrintAttribute)] pub enum CguFields { PartitionReused { cfg: Symbol, module: Symbol }, PartitionCodegened { cfg: Symbol, module: Symbol }, @@ -70,7 +70,7 @@ pub enum CguFields { } #[derive(Copy, Clone, PartialEq, Debug, PrintAttribute)] -#[derive(HashStable, Encodable, Decodable)] +#[derive(StableHash, Encodable, Decodable)] pub enum DivergingFallbackBehavior { /// Always fallback to `()` (aka "always spontaneous decay") ToUnit, @@ -82,7 +82,7 @@ pub enum DivergingFallbackBehavior { } #[derive(Copy, Clone, PartialEq, Debug, PrintAttribute, Default)] -#[derive(HashStable, Encodable, Decodable)] +#[derive(StableHash, Encodable, Decodable)] pub enum DivergingBlockBehavior { /// This is the current stable behavior: /// @@ -105,7 +105,7 @@ pub enum DivergingBlockBehavior { Unit, } -#[derive(Copy, Clone, PartialEq, Encodable, Decodable, Debug, HashStable, PrintAttribute)] +#[derive(Copy, Clone, PartialEq, Encodable, Decodable, Debug, StableHash, PrintAttribute)] pub enum InlineAttr { None, Hint, @@ -129,14 +129,14 @@ impl InlineAttr { } } -#[derive(Copy, Clone, Encodable, Decodable, Debug, PartialEq, Eq, HashStable, PrintAttribute)] +#[derive(Copy, Clone, Encodable, Decodable, Debug, PartialEq, Eq, StableHash, PrintAttribute)] pub enum InstructionSetAttr { ArmA32, ArmT32, } #[derive(Copy, Clone, Debug, PartialEq, Eq, Default, PrintAttribute)] -#[derive(Encodable, Decodable, HashStable)] +#[derive(Encodable, Decodable, StableHash)] pub enum OptimizeAttr { /// No `#[optimize(..)]` attribute #[default] @@ -155,7 +155,7 @@ impl OptimizeAttr { } } -#[derive(PartialEq, Debug, Encodable, Decodable, Copy, Clone, HashStable, PrintAttribute)] +#[derive(PartialEq, Debug, Encodable, Decodable, Copy, Clone, StableHash, PrintAttribute)] pub enum ReprAttr { ReprInt(IntType), ReprRust, @@ -172,13 +172,13 @@ pub enum TransparencyError { } #[derive(Eq, PartialEq, Debug, Copy, Clone)] -#[derive(Encodable, Decodable, HashStable, PrintAttribute)] +#[derive(Encodable, Decodable, StableHash, PrintAttribute)] pub enum IntType { SignedInt(ast::IntTy), UnsignedInt(ast::UintTy), } -#[derive(Copy, Debug, Encodable, Decodable, Clone, HashStable, PrintAttribute)] +#[derive(Copy, Debug, Encodable, Decodable, Clone, StableHash, PrintAttribute)] pub struct Deprecation { pub since: DeprecatedSince, /// The note to issue a reason. @@ -190,7 +190,7 @@ pub struct Deprecation { } /// Release in which an API is deprecated. -#[derive(Copy, Debug, Encodable, Decodable, Clone, HashStable, PrintAttribute)] +#[derive(Copy, Debug, Encodable, Decodable, Clone, StableHash, PrintAttribute)] pub enum DeprecatedSince { RustcVersion(RustcVersion), /// Deprecated in the future ("to be determined"). @@ -207,7 +207,7 @@ pub enum DeprecatedSince { /// Successfully-parsed value of a `#[coverage(..)]` attribute. #[derive(Copy, Debug, Eq, PartialEq, Encodable, Decodable, Clone)] -#[derive(HashStable, PrintAttribute)] +#[derive(StableHash, PrintAttribute)] pub enum CoverageAttrKind { On, Off, @@ -215,7 +215,7 @@ pub enum CoverageAttrKind { /// Successfully-parsed value of a `#[rustc_abi(..)]` attribute. #[derive(Copy, Debug, Eq, PartialEq, Encodable, Decodable, Clone)] -#[derive(HashStable, PrintAttribute)] +#[derive(StableHash, PrintAttribute)] pub enum RustcAbiAttrKind { Debug, AssertEq, @@ -246,7 +246,7 @@ impl Deprecation { /// `#[used(compiler)]` /// `#[used(linker)]` #[derive(Encodable, Decodable, Copy, Clone, Debug, PartialEq, Eq, Hash)] -#[derive(HashStable, PrintAttribute)] +#[derive(StableHash, PrintAttribute)] pub enum UsedBy { Default, Compiler, @@ -254,7 +254,7 @@ pub enum UsedBy { } #[derive(Encodable, Decodable, Clone, Debug, PartialEq, Eq, Hash)] -#[derive(HashStable, PrintAttribute)] +#[derive(StableHash, PrintAttribute)] pub enum MacroUseArgs { UseAll, UseSpecific(ThinVec), @@ -266,7 +266,7 @@ impl Default for MacroUseArgs { } } -#[derive(Debug, Clone, Encodable, Decodable, HashStable)] +#[derive(Debug, Clone, Encodable, Decodable, StableHash)] pub struct StrippedCfgItem { pub parent_scope: ScopeId, pub ident: Ident, @@ -284,7 +284,7 @@ impl StrippedCfgItem { /// /// See for more details about these variants. #[derive(Encodable, Decodable, Clone, Copy, Debug, PartialEq, Eq, Hash)] -#[derive(HashStable, PrintAttribute)] +#[derive(StableHash, PrintAttribute)] pub enum Linkage { AvailableExternally, Common, @@ -298,7 +298,7 @@ pub enum Linkage { } #[derive(Clone, Copy, Decodable, Debug, Encodable, PartialEq)] -#[derive(HashStable, PrintAttribute)] +#[derive(StableHash, PrintAttribute)] pub enum MirDialect { Analysis, Built, @@ -317,7 +317,7 @@ impl IntoDiagArg for MirDialect { } #[derive(Clone, Copy, Decodable, Debug, Encodable, PartialEq)] -#[derive(HashStable, PrintAttribute)] +#[derive(StableHash, PrintAttribute)] pub enum MirPhase { Initial, PostCleanup, @@ -337,7 +337,7 @@ impl IntoDiagArg for MirPhase { /// Different ways that the PE Format can decorate a symbol name. /// From -#[derive(Copy, Clone, Debug, Encodable, Decodable, HashStable, PartialEq, Eq, PrintAttribute)] +#[derive(Copy, Clone, Debug, Encodable, Decodable, StableHash, PartialEq, Eq, PrintAttribute)] pub enum PeImportNameType { /// IMPORT_ORDINAL /// Uses the ordinal (i.e., a number) rather than the name. @@ -367,7 +367,7 @@ pub enum PeImportNameType { Decodable, PrintAttribute )] -#[derive(HashStable)] +#[derive(StableHash)] pub enum NativeLibKind { /// Static library (e.g. `libfoo.a` on Linux or `foo.lib` on Windows/MSVC) Static { @@ -435,7 +435,7 @@ impl NativeLibKind { } } -#[derive(Debug, Encodable, Decodable, Clone, HashStable, PrintAttribute)] +#[derive(Debug, Encodable, Decodable, Clone, StableHash, PrintAttribute)] pub struct LinkEntry { pub span: Span, pub kind: NativeLibKind, @@ -445,14 +445,14 @@ pub struct LinkEntry { pub import_name_type: Option<(PeImportNameType, Span)>, } -#[derive(HashStable, PrintAttribute)] +#[derive(StableHash, PrintAttribute)] #[derive(Copy, PartialEq, PartialOrd, Clone, Ord, Eq, Hash, Debug, Encodable, Decodable)] pub enum DebuggerVisualizerType { Natvis, GdbPrettyPrinter, } -#[derive(Debug, Encodable, Decodable, Clone, HashStable, PrintAttribute)] +#[derive(Debug, Encodable, Decodable, Clone, StableHash, PrintAttribute)] pub struct DebugVisualizer { pub span: Span, pub visualizer_type: DebuggerVisualizerType, @@ -460,7 +460,7 @@ pub struct DebugVisualizer { } #[derive(Clone, Copy, Debug, Decodable, Encodable, Eq, PartialEq)] -#[derive(HashStable, PrintAttribute)] +#[derive(StableHash, PrintAttribute)] #[derive_const(Default)] pub enum RtsanSetting { Nonblocking, @@ -470,7 +470,7 @@ pub enum RtsanSetting { } #[derive(Eq, PartialEq, Debug, Copy, Clone)] -#[derive(Encodable, Decodable, HashStable, PrintAttribute)] +#[derive(Encodable, Decodable, StableHash, PrintAttribute)] pub enum WindowsSubsystemKind { Console, Windows, @@ -486,20 +486,20 @@ impl WindowsSubsystemKind { } #[derive(Copy, Clone, Debug, PartialEq)] -#[derive(HashStable, Encodable, Decodable, PrintAttribute)] +#[derive(StableHash, Encodable, Decodable, PrintAttribute)] pub enum DocInline { Inline, NoInline, } #[derive(Copy, Clone, Debug, PartialEq)] -#[derive(HashStable, Encodable, Decodable, PrintAttribute)] +#[derive(StableHash, Encodable, Decodable, PrintAttribute)] pub enum HideOrShow { Hide, Show, } -#[derive(Clone, Debug, HashStable, Encodable, Decodable, PrintAttribute)] +#[derive(Clone, Debug, StableHash, Encodable, Decodable, PrintAttribute)] pub struct CfgInfo { pub name: Symbol, pub name_span: Span, @@ -516,13 +516,13 @@ impl CfgInfo { } } -#[derive(Clone, Debug, HashStable, Encodable, Decodable, PrintAttribute)] +#[derive(Clone, Debug, StableHash, Encodable, Decodable, PrintAttribute)] pub struct CfgHideShow { pub kind: HideOrShow, pub values: ThinVec, } -#[derive(Clone, Debug, Default, HashStable, Decodable, PrintAttribute)] +#[derive(Clone, Debug, Default, StableHash, Decodable, PrintAttribute)] pub struct DocAttribute { pub first_span: Span, @@ -626,7 +626,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, Encodable, Decodable, PrintAttribute)] +#[derive(StableHash, Encodable, Decodable, PrintAttribute)] pub enum CollapseMacroDebuginfo { /// Don't collapse debuginfo for the macro No = 0, @@ -640,7 +640,7 @@ pub enum CollapseMacroDebuginfo { /// Crate type, as specified by `#![crate_type]` #[derive(Copy, Clone, Debug, Hash, PartialEq, Default, PartialOrd, Eq, Ord)] -#[derive(HashStable, Encodable, Decodable, PrintAttribute)] +#[derive(StableHash, Encodable, Decodable, PrintAttribute)] pub enum CrateType { /// `#![crate_type = "bin"]` Executable, @@ -740,7 +740,7 @@ impl IntoDiagArg for CrateType { } } -#[derive(Clone, Debug, HashStable, Encodable, Decodable, PrintAttribute)] +#[derive(Clone, Debug, StableHash, Encodable, Decodable, PrintAttribute)] pub enum RustcDumpLayoutKind { Align, BackendRepr, @@ -749,7 +749,7 @@ pub enum RustcDumpLayoutKind { Size, } -#[derive(Clone, Debug, HashStable, Encodable, Decodable, PrintAttribute, PartialEq, Eq)] +#[derive(Clone, Debug, StableHash, Encodable, Decodable, PrintAttribute, PartialEq, Eq)] pub enum RustcMirKind { PeekMaybeInit, PeekMaybeUninit, @@ -759,13 +759,13 @@ pub enum RustcMirKind { BorrowckGraphvizFormat { format: BorrowckGraphvizFormatKind }, } -#[derive(Clone, Debug, HashStable, Encodable, Decodable, PrintAttribute, PartialEq, Eq)] +#[derive(Clone, Debug, StableHash, Encodable, Decodable, PrintAttribute, PartialEq, Eq)] pub enum BorrowckGraphvizFormatKind { TwoPhase, } #[derive(Clone, Debug, PartialEq, Eq)] -#[derive(HashStable, Encodable, Decodable, PrintAttribute)] +#[derive(StableHash, Encodable, Decodable, PrintAttribute)] pub struct RustcCleanAttribute { pub span: Span, pub cfg: Symbol, @@ -775,14 +775,14 @@ pub struct RustcCleanAttribute { /// Represents the `except=` or `loaded_from_disk=` argument of `#[rustc_clean]` #[derive(Clone, Debug, PartialEq, Eq)] -#[derive(HashStable, Encodable, Decodable, PrintAttribute)] +#[derive(StableHash, Encodable, Decodable, PrintAttribute)] pub struct RustcCleanQueries { pub entries: ThinVec, pub span: Span, } #[derive(Clone, Debug, PartialEq, Eq)] -#[derive(HashStable, Encodable, Decodable, PrintAttribute)] +#[derive(StableHash, 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 @@ -858,7 +858,7 @@ impl RustcAutodiff { } /// We generate one of these structs for each `#[autodiff(...)]` attribute. -#[derive(Clone, Eq, PartialEq, Encodable, Decodable, Debug, HashStable)] +#[derive(Clone, Eq, PartialEq, Encodable, Decodable, Debug, StableHash)] pub struct AutoDiffItem { /// The name of the function getting differentiated pub source: String, @@ -878,7 +878,7 @@ impl fmt::Display for AutoDiffItem { } } -#[derive(Clone, Debug, HashStable, Encodable, Decodable, PrintAttribute)] +#[derive(Clone, Debug, StableHash, Encodable, Decodable, PrintAttribute)] pub struct UnstableRemovedFeature { pub feature: Symbol, pub reason: Symbol, @@ -935,7 +935,7 @@ pub struct UnstableRemovedFeature { /// [`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, Encodable, Decodable, PrintAttribute)] +#[derive(Clone, Debug, StableHash, 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 9d38125c678b9..26be6e2224615 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, PrintAttribute}; +use rustc_macros::{Decodable, Encodable, PrintAttribute, StableHash}; use rustc_span::{DesugaringKind, Span, Symbol, kw}; use thin_vec::ThinVec; use tracing::debug; use crate::attrs::PrintAttribute; -#[derive(Clone, Default, Debug, HashStable, Encodable, Decodable, PrintAttribute)] +#[derive(Clone, Default, Debug, StableHash, 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, Encodable, Decodable, PrintAttribute)] +#[derive(Clone, Debug, StableHash, Encodable, Decodable, PrintAttribute)] pub struct FormatString { pub input: Symbol, pub span: Span, @@ -225,13 +225,13 @@ pub struct FormatArgs { pub generic_args: Vec<(Symbol, String)> = Vec::new(), } -#[derive(Clone, Debug, HashStable, Encodable, Decodable, PrintAttribute)] +#[derive(Clone, Debug, StableHash, Encodable, Decodable, PrintAttribute)] pub enum Piece { Lit(Symbol), Arg(FormatArg), } -#[derive(Clone, Debug, HashStable, Encodable, Decodable, PrintAttribute)] +#[derive(Clone, Debug, StableHash, Encodable, Decodable, PrintAttribute)] pub enum FormatArg { // A generic parameter, like `{T}` if we're on the `From` trait. GenericParam { @@ -251,7 +251,7 @@ pub enum FormatArg { } /// Represents the `on` filter in `#[rustc_on_unimplemented]`. -#[derive(Clone, Debug, HashStable, Encodable, Decodable, PrintAttribute)] +#[derive(Clone, Debug, StableHash, Encodable, Decodable, PrintAttribute)] pub struct OnUnimplementedCondition { pub span: Span, pub pred: Predicate, @@ -276,7 +276,7 @@ impl OnUnimplementedCondition { /// /// It is similar to the predicate in the `cfg` attribute, /// and may contain nested predicates. -#[derive(Clone, Debug, HashStable, Encodable, Decodable, PrintAttribute)] +#[derive(Clone, Debug, StableHash, Encodable, Decodable, PrintAttribute)] pub enum Predicate { /// A condition like `on(crate_local)`. Flag(Flag), @@ -314,7 +314,7 @@ impl Predicate { } /// Represents a `MetaWord` in an `on`-filter. -#[derive(Clone, Copy, Debug, HashStable, Encodable, Decodable, PrintAttribute)] +#[derive(Clone, Copy, Debug, StableHash, Encodable, Decodable, PrintAttribute)] pub enum Flag { /// Whether the code causing the trait bound to not be fulfilled /// is part of the user's crate. @@ -329,7 +329,7 @@ pub enum Flag { /// A `MetaNameValueStr` in an `on`-filter. /// /// For example, `#[rustc_on_unimplemented(on(name = "value", message = "hello"))]`. -#[derive(Clone, Debug, HashStable, Encodable, Decodable, PrintAttribute)] +#[derive(Clone, Debug, StableHash, Encodable, Decodable, PrintAttribute)] pub struct NameValue { pub name: Name, /// Something like `"&str"` or `"alloc::string::String"`, @@ -348,7 +348,7 @@ impl NameValue { } /// The valid names of the `on` filter. -#[derive(Clone, Copy, Debug, HashStable, Encodable, Decodable, PrintAttribute)] +#[derive(Clone, Copy, Debug, StableHash, Encodable, Decodable, PrintAttribute)] pub enum Name { Cause, FromDesugaring, @@ -368,7 +368,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, Encodable, Decodable, PrintAttribute)] +#[derive(Clone, Debug, StableHash, Encodable, Decodable, PrintAttribute)] pub struct FilterFormatString { pub pieces: ThinVec, } @@ -400,7 +400,7 @@ impl FilterFormatString { } } -#[derive(Clone, Debug, HashStable, Encodable, Decodable, PrintAttribute)] +#[derive(Clone, Debug, StableHash, 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 863e066f845f0..f268192233c0d 100644 --- a/compiler/rustc_hir/src/def.rs +++ b/compiler/rustc_hir/src/def.rs @@ -7,7 +7,7 @@ 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}; +use rustc_macros::{Decodable, Encodable, StableHash}; use rustc_span::Symbol; use rustc_span::def_id::{DefId, LocalDefId}; use rustc_span::hygiene::MacroKind; @@ -16,7 +16,7 @@ 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)] +#[derive(Clone, Copy, PartialEq, Eq, Encodable, Decodable, Hash, Debug, StableHash)] 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)] +#[derive(Clone, Copy, PartialEq, Eq, Encodable, Decodable, Hash, Debug, StableHash)] 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)] +#[derive(StableHash)] 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)] +#[derive(Clone, Copy, PartialEq, Eq, Encodable, Decodable, Hash, Debug, StableHash)] 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)] +#[derive(Clone, Copy, PartialEq, Eq, Encodable, Decodable, Hash, Debug, StableHash)] 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)] +#[derive(Clone, Copy, PartialEq, Eq, Encodable, Decodable, Hash, Debug, StableHash)] 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)] +#[derive(StableHash)] pub enum Namespace { /// The type namespace includes `struct`s, `enum`s, `union`s, `trait`s, and `mod`s /// (and, by extension, crates). @@ -722,7 +722,7 @@ impl ToStableHashKey for Namespace { } /// Just a helper ‒ separate structure for each namespace. -#[derive(Copy, Clone, Default, Debug, HashStable)] +#[derive(Copy, Clone, Default, Debug, StableHash)] 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 c19aeec659795..128b6f5e39983 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; +use rustc_macros::StableHash; use rustc_span::Symbol; use rustc_span::def_id::DefIdMap; use crate::def_id::DefId; -#[derive(Debug, Default, HashStable)] +#[derive(Debug, Default, StableHash)] 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 c44ed05d6947a..0d06672f1266d 100644 --- a/compiler/rustc_hir/src/hir.rs +++ b/compiler/rustc_hir/src/hir.rs @@ -22,7 +22,7 @@ use rustc_data_structures::steal::Steal; use rustc_data_structures::tagged_ptr::TaggedRef; use rustc_error_messages::{DiagArgValue, IntoDiagArg}; use rustc_index::IndexVec; -use rustc_macros::{Decodable, Encodable, HashStable}; +use rustc_macros::{Decodable, Encodable, StableHash}; use rustc_span::def_id::LocalDefId; use rustc_span::{ BytePos, DUMMY_SP, DesugaringKind, ErrorGuaranteed, Ident, Span, Spanned, Symbol, kw, sym, @@ -39,7 +39,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)] +#[derive(Debug, Copy, Clone, PartialEq, Eq, StableHash)] pub enum AngleBrackets { /// E.g. `Path`. Missing, @@ -49,7 +49,7 @@ pub enum AngleBrackets { Full, } -#[derive(Debug, Copy, Clone, PartialEq, Eq, HashStable)] +#[derive(Debug, Copy, Clone, PartialEq, Eq, StableHash)] pub enum LifetimeSource { /// E.g. `&Type`, `&'_ Type`, `&'a Type`, `&mut Type`, `&'_ mut Type`, `&'a mut Type` Reference, @@ -73,7 +73,7 @@ pub enum LifetimeSource { Other, } -#[derive(Debug, Copy, Clone, PartialEq, Eq, HashStable)] +#[derive(Debug, Copy, Clone, PartialEq, Eq, StableHash)] pub enum LifetimeSyntax { /// E.g. `&Type`, `ContainsLifetime` Implicit, @@ -150,7 +150,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)] +#[derive(Debug, Copy, Clone, StableHash)] // Raise the alignment to at least 4 bytes. // This is relied on in other parts of the compiler (for pointer tagging): // @@ -180,7 +180,7 @@ pub struct Lifetime { pub syntax: LifetimeSyntax, } -#[derive(Debug, Copy, Clone, HashStable)] +#[derive(Debug, Copy, Clone, StableHash)] pub enum ParamName { /// Some user-given name like `T` or `'x`. Plain(Ident), @@ -218,7 +218,7 @@ impl ParamName { } } -#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash, HashStable)] +#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash, StableHash)] pub enum LifetimeKind { /// User-given names or fresh (synthetic) names. Param(LocalDefId), @@ -345,7 +345,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)] +#[derive(Debug, Clone, Copy, StableHash)] pub struct Path<'hir, R = Res> { pub span: Span, /// The resolution for the path. @@ -365,7 +365,7 @@ impl Path<'_> { /// A segment of a path: an identifier, an optional lifetime, and a set of /// types. -#[derive(Debug, Clone, Copy, HashStable)] +#[derive(Debug, Clone, Copy, StableHash)] pub struct PathSegment<'hir> { /// The identifier portion of this path segment. pub ident: Ident, @@ -402,7 +402,7 @@ impl<'hir> PathSegment<'hir> { } } -#[derive(Clone, Copy, Debug, HashStable)] +#[derive(Clone, Copy, Debug, StableHash)] pub enum ConstItemRhs<'hir> { Body(BodyId), TypeConst(&'hir ConstArg<'hir>), @@ -437,7 +437,7 @@ impl<'hir> ConstItemRhs<'hir> { /// /// For an explanation of the `Unambig` generic parameter see the dev-guide: /// -#[derive(Clone, Copy, Debug, HashStable)] +#[derive(Clone, Copy, Debug, StableHash)] #[repr(C)] pub struct ConstArg<'hir, Unambig = ()> { #[stable_hasher(ignore)] @@ -494,7 +494,7 @@ impl<'hir, Unambig> ConstArg<'hir, Unambig> { } /// See [`ConstArg`]. -#[derive(Clone, Copy, Debug, HashStable)] +#[derive(Clone, Copy, Debug, StableHash)] #[repr(u8, C)] pub enum ConstArgKind<'hir, Unambig = ()> { Tup(&'hir [&'hir ConstArg<'hir, Unambig>]), @@ -522,7 +522,7 @@ pub enum ConstArgKind<'hir, Unambig = ()> { }, } -#[derive(Clone, Copy, Debug, HashStable)] +#[derive(Clone, Copy, Debug, StableHash)] pub struct ConstArgExprField<'hir> { pub hir_id: HirId, pub span: Span, @@ -530,13 +530,13 @@ pub struct ConstArgExprField<'hir> { pub expr: &'hir ConstArg<'hir>, } -#[derive(Clone, Copy, Debug, HashStable)] +#[derive(Clone, Copy, Debug, StableHash)] pub struct ConstArgArrayExpr<'hir> { pub span: Span, pub elems: &'hir [&'hir ConstArg<'hir>], } -#[derive(Clone, Copy, Debug, HashStable)] +#[derive(Clone, Copy, Debug, StableHash)] pub struct InferArg { #[stable_hasher(ignore)] pub hir_id: HirId, @@ -549,7 +549,7 @@ impl InferArg { } } -#[derive(Debug, Clone, Copy, HashStable)] +#[derive(Debug, Clone, Copy, StableHash)] pub enum GenericArg<'hir> { Lifetime(&'hir Lifetime), Type(&'hir Ty<'hir, AmbigArg>), @@ -612,7 +612,7 @@ impl GenericArg<'_> { } /// The generic arguments and associated item constraints of a path segment. -#[derive(Debug, Clone, Copy, HashStable)] +#[derive(Debug, Clone, Copy, StableHash)] pub struct GenericArgs<'hir> { /// The generic arguments for this path segment. pub args: &'hir [GenericArg<'hir>], @@ -736,7 +736,7 @@ impl<'hir> GenericArgs<'hir> { } } -#[derive(Copy, Clone, PartialEq, Eq, Debug, HashStable)] +#[derive(Copy, Clone, PartialEq, Eq, Debug, StableHash)] pub enum GenericArgsParentheses { No, /// Bounds for `feature(return_type_notation)`, like `T: Trait`, @@ -747,7 +747,7 @@ pub enum GenericArgsParentheses { } /// The modifiers on a trait bound. -#[derive(Copy, Clone, PartialEq, Eq, Hash, Debug, HashStable)] +#[derive(Copy, Clone, PartialEq, Eq, Hash, Debug, StableHash)] pub struct TraitBoundModifiers { pub constness: BoundConstness, pub polarity: BoundPolarity, @@ -758,7 +758,7 @@ impl TraitBoundModifiers { TraitBoundModifiers { constness: BoundConstness::Never, polarity: BoundPolarity::Positive }; } -#[derive(Clone, Copy, Debug, HashStable)] +#[derive(Clone, Copy, Debug, StableHash)] pub enum GenericBound<'hir> { Trait(PolyTraitRef<'hir>), Outlives(&'hir Lifetime), @@ -784,7 +784,7 @@ impl GenericBound<'_> { pub type GenericBounds<'hir> = &'hir [GenericBound<'hir>]; -#[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash, HashStable, Debug)] +#[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash, StableHash, Debug)] pub enum MissingLifetimeKind { /// An explicit `'_`. Underscore, @@ -796,7 +796,7 @@ pub enum MissingLifetimeKind { Brackets, } -#[derive(Copy, Clone, Debug, HashStable)] +#[derive(Copy, Clone, Debug, StableHash)] pub enum LifetimeParamKind { // Indicates that the lifetime definition was explicitly declared (e.g., in // `fn foo<'a>(x: &'a u8) -> &'a u8 { x }`). @@ -810,7 +810,7 @@ pub enum LifetimeParamKind { Error, } -#[derive(Debug, Clone, Copy, HashStable)] +#[derive(Debug, Clone, Copy, StableHash)] pub enum GenericParamKind<'hir> { /// A lifetime definition (e.g., `'a: 'b + 'c + 'd`). Lifetime { @@ -827,7 +827,7 @@ pub enum GenericParamKind<'hir> { }, } -#[derive(Debug, Clone, Copy, HashStable)] +#[derive(Debug, Clone, Copy, StableHash)] pub struct GenericParam<'hir> { #[stable_hasher(ignore)] pub hir_id: HirId, @@ -866,7 +866,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)] +#[derive(Debug, Clone, Copy, StableHash)] pub enum GenericParamSource { // Early or late-bound parameters defined on an item Generics, @@ -884,7 +884,7 @@ pub struct GenericParamCount { /// Represents lifetimes and type parameters attached to a declaration /// of a function, enum, trait, etc. -#[derive(Debug, Clone, Copy, HashStable)] +#[derive(Debug, Clone, Copy, StableHash)] pub struct Generics<'hir> { pub params: &'hir [GenericParam<'hir>], pub predicates: &'hir [WherePredicate<'hir>], @@ -1091,7 +1091,7 @@ impl<'hir> Generics<'hir> { } /// A single predicate in a where-clause. -#[derive(Debug, Clone, Copy, HashStable)] +#[derive(Debug, Clone, Copy, StableHash)] pub struct WherePredicate<'hir> { #[stable_hasher(ignore)] pub hir_id: HirId, @@ -1100,7 +1100,7 @@ pub struct WherePredicate<'hir> { } /// The kind of a single predicate in a where-clause. -#[derive(Debug, Clone, Copy, HashStable)] +#[derive(Debug, Clone, Copy, StableHash)] pub enum WherePredicateKind<'hir> { /// A type bound (e.g., `for<'c> Foo: Send + Clone + 'c`). BoundPredicate(WhereBoundPredicate<'hir>), @@ -1128,7 +1128,7 @@ impl<'hir> WherePredicateKind<'hir> { } } -#[derive(Copy, Clone, Debug, HashStable, PartialEq, Eq)] +#[derive(Copy, Clone, Debug, StableHash, PartialEq, Eq)] pub enum PredicateOrigin { WhereClause, GenericParam, @@ -1136,7 +1136,7 @@ pub enum PredicateOrigin { } /// A type bound (e.g., `for<'c> Foo: Send + Clone + 'c`). -#[derive(Debug, Clone, Copy, HashStable)] +#[derive(Debug, Clone, Copy, StableHash)] pub struct WhereBoundPredicate<'hir> { /// Origin of the predicate. pub origin: PredicateOrigin, @@ -1156,7 +1156,7 @@ impl<'hir> WhereBoundPredicate<'hir> { } /// A lifetime predicate (e.g., `'a: 'b + 'c`). -#[derive(Debug, Clone, Copy, HashStable)] +#[derive(Debug, Clone, Copy, StableHash)] pub struct WhereRegionPredicate<'hir> { pub in_where_clause: bool, pub lifetime: &'hir Lifetime, @@ -1171,7 +1171,7 @@ impl<'hir> WhereRegionPredicate<'hir> { } /// An equality predicate (e.g., `T = int`); currently unsupported. -#[derive(Debug, Clone, Copy, HashStable)] +#[derive(Debug, Clone, Copy, StableHash)] pub struct WhereEqPredicate<'hir> { pub lhs_ty: &'hir Ty<'hir>, pub rhs_ty: &'hir Ty<'hir>, @@ -1187,7 +1187,7 @@ pub struct ParentedNode<'tcx> { } /// Arguments passed to an attribute macro. -#[derive(Clone, Debug, HashStable, Encodable, Decodable)] +#[derive(Clone, Debug, StableHash, Encodable, Decodable)] pub enum AttrArgs { /// No arguments: `#[attr]`. Empty, @@ -1202,7 +1202,7 @@ pub enum AttrArgs { }, } -#[derive(Clone, Debug, HashStable, Encodable, Decodable)] +#[derive(Clone, Debug, StableHash, Encodable, Decodable)] pub struct AttrPath { pub segments: Box<[Symbol]>, pub span: Span, @@ -1238,7 +1238,7 @@ impl fmt::Display for AttrPath { } } -#[derive(Clone, Debug, HashStable, Encodable, Decodable)] +#[derive(Clone, Debug, StableHash, Encodable, Decodable)] pub struct AttrItem { // Not lowered to hir::Path because we have no NodeId to resolve to. pub path: AttrPath, @@ -1251,7 +1251,7 @@ pub struct AttrItem { pub span: Span, } -/// The derived implementation of [`HashStable`] on [`Attribute`]s shouldn't hash +/// The derived implementation of [`StableHash`] 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 { @@ -1260,7 +1260,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)] +#[derive(Clone, Debug, Encodable, Decodable, StableHash)] pub enum Attribute { /// A parsed built-in attribute. /// @@ -1619,7 +1619,7 @@ impl fmt::Debug for OwnerNodes<'_> { } /// Full information resulting from lowering an AST node. -#[derive(Debug, HashStable)] +#[derive(Debug, StableHash)] pub struct OwnerInfo<'hir> { /// Contents of the HIR. pub nodes: OwnerNodes<'hir>, @@ -1647,7 +1647,7 @@ impl<'tcx> OwnerInfo<'tcx> { } } -#[derive(Copy, Clone, Debug, HashStable)] +#[derive(Copy, Clone, Debug, StableHash)] pub enum MaybeOwner<'tcx> { Owner(&'tcx OwnerInfo<'tcx>), NonOwner(HirId), @@ -1668,7 +1668,7 @@ impl<'tcx> MaybeOwner<'tcx> { } } -#[derive(Debug, Clone, Copy, HashStable)] +#[derive(Debug, Clone, Copy, StableHash)] pub struct Closure<'hir> { pub def_id: LocalDefId, pub binder: ClosureBinder, @@ -1684,7 +1684,7 @@ pub struct Closure<'hir> { pub kind: ClosureKind, } -#[derive(Clone, PartialEq, Eq, Debug, Copy, Hash, HashStable, Encodable, Decodable)] +#[derive(Clone, PartialEq, Eq, Debug, Copy, Hash, StableHash, Encodable, Decodable)] pub enum ClosureKind { /// This is a plain closure expression. Closure, @@ -1703,7 +1703,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)] +#[derive(Debug, Clone, Copy, StableHash)] pub struct Block<'hir> { /// Statements in a block. pub stmts: &'hir [Stmt<'hir>], @@ -1732,13 +1732,13 @@ impl<'hir> Block<'hir> { } } -#[derive(Debug, Clone, Copy, HashStable)] +#[derive(Debug, Clone, Copy, StableHash)] pub struct TyFieldPath { pub variant: Option, pub field: Ident, } -#[derive(Debug, Clone, Copy, HashStable)] +#[derive(Debug, Clone, Copy, StableHash)] pub struct TyPat<'hir> { #[stable_hasher(ignore)] pub hir_id: HirId, @@ -1746,7 +1746,7 @@ pub struct TyPat<'hir> { pub span: Span, } -#[derive(Debug, Clone, Copy, HashStable)] +#[derive(Debug, Clone, Copy, StableHash)] pub struct Pat<'hir> { #[stable_hasher(ignore)] pub hir_id: HirId, @@ -1894,7 +1894,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)] +#[derive(Debug, Clone, Copy, StableHash)] pub struct PatField<'hir> { #[stable_hasher(ignore)] pub hir_id: HirId, @@ -1906,7 +1906,7 @@ pub struct PatField<'hir> { pub span: Span, } -#[derive(Copy, Clone, PartialEq, Debug, HashStable, Hash, Eq, Encodable, Decodable)] +#[derive(Copy, Clone, PartialEq, Debug, StableHash, Hash, Eq, Encodable, Decodable)] pub enum RangeEnd { Included, Excluded, @@ -1924,7 +1924,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)] +#[derive(Clone, Copy, PartialEq, Eq, Hash, StableHash)] pub struct DotDotPos(u32); impl DotDotPos { @@ -1950,7 +1950,7 @@ impl fmt::Debug for DotDotPos { } } -#[derive(Debug, Clone, Copy, HashStable)] +#[derive(Debug, Clone, Copy, StableHash)] pub struct PatExpr<'hir> { #[stable_hasher(ignore)] pub hir_id: HirId, @@ -1958,7 +1958,7 @@ pub struct PatExpr<'hir> { pub kind: PatExprKind<'hir>, } -#[derive(Debug, Clone, Copy, HashStable)] +#[derive(Debug, Clone, Copy, StableHash)] pub enum PatExprKind<'hir> { Lit { lit: Lit, @@ -1968,7 +1968,7 @@ pub enum PatExprKind<'hir> { Path(QPath<'hir>), } -#[derive(Debug, Clone, Copy, HashStable)] +#[derive(Debug, Clone, Copy, StableHash)] pub enum TyPatKind<'hir> { /// A range pattern (e.g., `1..=2` or `1..2`). Range(&'hir ConstArg<'hir>, &'hir ConstArg<'hir>), @@ -1983,7 +1983,7 @@ pub enum TyPatKind<'hir> { Err(ErrorGuaranteed), } -#[derive(Debug, Clone, Copy, HashStable)] +#[derive(Debug, Clone, Copy, StableHash)] pub enum PatKind<'hir> { /// A missing pattern, e.g. for an anonymous param in a bare fn like `fn f(u32)`. Missing, @@ -2058,7 +2058,7 @@ pub enum PatKind<'hir> { } /// A statement. -#[derive(Debug, Clone, Copy, HashStable)] +#[derive(Debug, Clone, Copy, StableHash)] pub struct Stmt<'hir> { #[stable_hasher(ignore)] pub hir_id: HirId, @@ -2067,7 +2067,7 @@ pub struct Stmt<'hir> { } /// The contents of a statement. -#[derive(Debug, Clone, Copy, HashStable)] +#[derive(Debug, Clone, Copy, StableHash)] pub enum StmtKind<'hir> { /// A local (`let`) binding. Let(&'hir LetStmt<'hir>), @@ -2083,7 +2083,7 @@ pub enum StmtKind<'hir> { } /// Represents a `let` statement (i.e., `let : = ;`). -#[derive(Debug, Clone, Copy, HashStable)] +#[derive(Debug, Clone, Copy, StableHash)] pub struct LetStmt<'hir> { /// Span of `super` in `super let`. pub super_: Option, @@ -2105,7 +2105,7 @@ pub struct LetStmt<'hir> { /// Represents a single arm of a `match` expression, e.g. /// ` (if ) => `. -#[derive(Debug, Clone, Copy, HashStable)] +#[derive(Debug, Clone, Copy, StableHash)] pub struct Arm<'hir> { #[stable_hasher(ignore)] pub hir_id: HirId, @@ -2123,7 +2123,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)] +#[derive(Debug, Clone, Copy, StableHash)] pub struct LetExpr<'hir> { pub span: Span, pub pat: &'hir Pat<'hir>, @@ -2134,7 +2134,7 @@ pub struct LetExpr<'hir> { pub recovered: ast::Recovered, } -#[derive(Debug, Clone, Copy, HashStable)] +#[derive(Debug, Clone, Copy, StableHash)] pub struct ExprField<'hir> { #[stable_hasher(ignore)] pub hir_id: HirId, @@ -2144,19 +2144,19 @@ pub struct ExprField<'hir> { pub is_shorthand: bool, } -#[derive(Copy, Clone, PartialEq, Debug, HashStable)] +#[derive(Copy, Clone, PartialEq, Debug, StableHash)] pub enum BlockCheckMode { DefaultBlock, UnsafeBlock(UnsafeSource), } -#[derive(Copy, Clone, PartialEq, Debug, HashStable)] +#[derive(Copy, Clone, PartialEq, Debug, StableHash)] pub enum UnsafeSource { CompilerGenerated, UserProvided, } -#[derive(Copy, Clone, PartialEq, Eq, Hash, Debug, HashStable)] +#[derive(Copy, Clone, PartialEq, Eq, Hash, Debug, StableHash)] pub struct BodyId { pub hir_id: HirId, } @@ -2182,7 +2182,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)] +#[derive(Debug, Clone, Copy, StableHash)] pub struct Body<'hir> { pub params: &'hir [Param<'hir>], pub value: &'hir Expr<'hir>, @@ -2195,7 +2195,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, Encodable, Decodable)] +#[derive(Clone, PartialEq, Eq, Debug, Copy, Hash, StableHash, Encodable, Decodable)] pub enum CoroutineKind { /// A coroutine that comes from a desugaring. Desugared(CoroutineDesugaring, CoroutineSource), @@ -2245,7 +2245,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, Encodable, Decodable)] +#[derive(Clone, PartialEq, Eq, Hash, Debug, Copy, StableHash, Encodable, Decodable)] pub enum CoroutineSource { /// An explicit `async`/`gen` block written by the user. Block, @@ -2268,7 +2268,7 @@ impl fmt::Display for CoroutineSource { } } -#[derive(Clone, PartialEq, Eq, Debug, Copy, Hash, HashStable, Encodable, Decodable)] +#[derive(Clone, PartialEq, Eq, Debug, Copy, Hash, StableHash, Encodable, Decodable)] pub enum CoroutineDesugaring { /// An explicit `async` block or the body of an `async` function. Async, @@ -2408,7 +2408,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)] +#[derive(Copy, Clone, Debug, StableHash)] pub struct AnonConst { #[stable_hasher(ignore)] pub hir_id: HirId, @@ -2418,7 +2418,7 @@ pub struct AnonConst { } /// An inline constant expression `const { something }`. -#[derive(Copy, Clone, Debug, HashStable)] +#[derive(Copy, Clone, Debug, StableHash)] pub struct ConstBlock { #[stable_hasher(ignore)] pub hir_id: HirId, @@ -2434,7 +2434,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)] +#[derive(Debug, Clone, Copy, StableHash)] pub struct Expr<'hir> { #[stable_hasher(ignore)] pub hir_id: HirId, @@ -2793,7 +2793,7 @@ pub fn expr_needs_parens(expr: &Expr<'_>) -> bool { } } -#[derive(Debug, Clone, Copy, HashStable)] +#[derive(Debug, Clone, Copy, StableHash)] pub enum ExprKind<'hir> { /// Allow anonymous constants from an inline `const` block ConstBlock(ConstBlock), @@ -2932,7 +2932,7 @@ pub enum ExprKind<'hir> { Err(rustc_span::ErrorGuaranteed), } -#[derive(Debug, Clone, Copy, HashStable)] +#[derive(Debug, Clone, Copy, StableHash)] pub enum StructTailExpr<'hir> { /// A struct expression where all the fields are explicitly enumerated: `Foo { a, b }`. None, @@ -2956,7 +2956,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)] +#[derive(Debug, Clone, Copy, StableHash)] 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. @@ -2995,7 +2995,7 @@ impl<'hir> QPath<'hir> { } /// Hints at the original code for a let statement. -#[derive(Copy, Clone, Debug, HashStable)] +#[derive(Copy, Clone, Debug, StableHash)] pub enum LocalSource { /// A `match _ { .. }`. Normal, @@ -3019,7 +3019,7 @@ pub enum LocalSource { } /// Hints at the original code for a `match _ { .. }`. -#[derive(Copy, Clone, PartialEq, Eq, Hash, Debug, HashStable, Encodable, Decodable)] +#[derive(Copy, Clone, PartialEq, Eq, Hash, Debug, StableHash, Encodable, Decodable)] pub enum MatchSource { /// A `match _ { .. }`. Normal, @@ -3051,7 +3051,7 @@ impl MatchSource { } /// The loop type that yielded an `ExprKind::Loop`. -#[derive(Copy, Clone, PartialEq, Debug, HashStable)] +#[derive(Copy, Clone, PartialEq, Debug, StableHash)] pub enum LoopSource { /// A `loop { .. }` loop. Loop, @@ -3071,7 +3071,7 @@ impl LoopSource { } } -#[derive(Copy, Clone, Debug, PartialEq, HashStable)] +#[derive(Copy, Clone, Debug, PartialEq, StableHash)] pub enum LoopIdError { OutsideLoopScope, UnlabeledCfInWhileCondition, @@ -3090,7 +3090,7 @@ impl fmt::Display for LoopIdError { } } -#[derive(Copy, Clone, Debug, PartialEq, HashStable)] +#[derive(Copy, Clone, Debug, PartialEq, StableHash)] pub struct Destination { /// This is `Some(_)` iff there is an explicit user-specified 'label pub label: Option