authorbors <bors@rust-lang.org> 2026-04-30 07:30:46 UTC
committerbors <bors@rust-lang.org> 2026-04-30 07:30:46 UTC
logf53b654a8882fd5fc036c4ca7a4ff41ce32497a6
treefb2f8ce531662fba48c10256b90ec7276c6fc4db
parent57f772f25c5ce2bd870d6f8c3ab318eaee5a3326
parent20060c60f320e806fa070a78abe268c15484487d

Auto merge of #155018 - nnethercote:simplify-HashStable, r=fee1-dead

Simplify `HashStable` This PR: - Simplifies the `HashStable` trait, by moving its generic parameter from the trait to its single method. - Eliminates the need for the non-obvious `derive(HashStable)`/`derive(HashStable_Generic)` distinction. - Reduces the need for, and clarifies, the non-obvious `derive(HashStable)`/`derive(HashStable_NoContext)` distinction. r? @fee1-dead

93 files changed, 1178 insertions(+), 1229 deletions(-)

compiler/rustc_abi/src/callconv/reg.rs+3-3
......@@ -1,9 +1,9 @@
11#[cfg(feature = "nightly")]
2use rustc_macros::HashStable_Generic;
2use rustc_macros::HashStable;
33
44use crate::{Align, HasDataLayout, Integer, Primitive, Size};
55
6#[cfg_attr(feature = "nightly", derive(HashStable_Generic))]
6#[cfg_attr(feature = "nightly", derive(HashStable))]
77#[derive(Copy, Clone, PartialEq, Eq, Hash, Debug)]
88pub enum RegKind {
99 Integer,
......@@ -16,7 +16,7 @@ pub enum RegKind {
1616 },
1717}
1818
19#[cfg_attr(feature = "nightly", derive(HashStable_Generic))]
19#[cfg_attr(feature = "nightly", derive(HashStable))]
2020#[derive(Copy, Clone, PartialEq, Eq, Hash, Debug)]
2121pub struct Reg {
2222 pub kind: RegKind,
compiler/rustc_abi/src/canon_abi.rs+5-5
......@@ -1,7 +1,7 @@
11use std::fmt;
22
33#[cfg(feature = "nightly")]
4use rustc_macros::HashStable_Generic;
4use rustc_macros::HashStable;
55
66use crate::ExternAbi;
77
......@@ -18,7 +18,7 @@ use crate::ExternAbi;
1818/// rather than picking the "actual" ABI.
1919#[derive(Copy, Clone, Debug)]
2020#[derive(PartialOrd, Ord, PartialEq, Eq, Hash)]
21#[cfg_attr(feature = "nightly", derive(HashStable_Generic))]
21#[cfg_attr(feature = "nightly", derive(HashStable))]
2222pub enum CanonAbi {
2323 // NOTE: the use of nested variants for some ABIs is for many targets they don't matter,
2424 // and this pushes the complexity of their reasoning to target-specific code,
......@@ -111,7 +111,7 @@ impl fmt::Display for CanonAbi {
111111/// These only affect callee codegen. making their categorization as distinct ABIs a bit peculiar.
112112#[derive(Copy, Clone, Debug)]
113113#[derive(PartialOrd, Ord, PartialEq, Eq, Hash)]
114#[cfg_attr(feature = "nightly", derive(HashStable_Generic))]
114#[cfg_attr(feature = "nightly", derive(HashStable))]
115115pub enum InterruptKind {
116116 Avr,
117117 AvrNonBlocking,
......@@ -126,7 +126,7 @@ pub enum InterruptKind {
126126/// One of SysV64 or Win64 may alias the C ABI, and arguably Win64 is cross-platform now?
127127#[derive(Clone, Copy, Debug)]
128128#[derive(PartialOrd, Ord, PartialEq, Eq, Hash)]
129#[cfg_attr(feature = "nightly", derive(HashStable_Generic))]
129#[cfg_attr(feature = "nightly", derive(HashStable))]
130130pub enum X86Call {
131131 /// "fastcall" has both GNU and Windows variants
132132 Fastcall,
......@@ -141,7 +141,7 @@ pub enum X86Call {
141141/// ABIs defined for 32-bit Arm
142142#[derive(Copy, Clone, Debug)]
143143#[derive(PartialOrd, Ord, PartialEq, Eq, Hash)]
144#[cfg_attr(feature = "nightly", derive(HashStable_Generic))]
144#[cfg_attr(feature = "nightly", derive(HashStable))]
145145pub enum ArmCall {
146146 Aapcs,
147147 CCmseNonSecureCall,
compiler/rustc_abi/src/extern_abi.rs+5-3
......@@ -3,7 +3,9 @@ use std::fmt;
33use std::hash::{Hash, Hasher};
44
55#[cfg(feature = "nightly")]
6use rustc_data_structures::stable_hasher::{HashStable, StableHasher, StableOrd};
6use rustc_data_structures::stable_hasher::{
7 HashStable, HashStableContext, StableHasher, StableOrd,
8};
79#[cfg(feature = "nightly")]
810use rustc_macros::{Decodable, Encodable};
911#[cfg(feature = "nightly")]
......@@ -240,9 +242,9 @@ impl Hash for ExternAbi {
240242}
241243
242244#[cfg(feature = "nightly")]
243impl<C> HashStable<C> for ExternAbi {
245impl HashStable for ExternAbi {
244246 #[inline]
245 fn hash_stable(&self, _: &mut C, hasher: &mut StableHasher) {
247 fn hash_stable<Hcx: HashStableContext>(&self, _: &mut Hcx, hasher: &mut StableHasher) {
246248 Hash::hash(self, hasher);
247249 }
248250}
compiler/rustc_abi/src/layout.rs+2-2
......@@ -45,7 +45,7 @@ rustc_index::newtype_index! {
4545 /// `b` is `FieldIdx(1)` in `VariantIdx(0)`,
4646 /// `d` is `FieldIdx(1)` in `VariantIdx(1)`, and
4747 /// `f` is `FieldIdx(1)` in `VariantIdx(0)`.
48 #[stable_hash_generic]
48 #[stable_hash]
4949 #[encodable]
5050 #[orderable]
5151 #[gate_rustc_only]
......@@ -70,7 +70,7 @@ rustc_index::newtype_index! {
7070 ///
7171 /// `struct`s, `tuples`, and `unions`s are considered to have a single variant
7272 /// with variant index zero, aka [`FIRST_VARIANT`].
73 #[stable_hash_generic]
73 #[stable_hash]
7474 #[encodable]
7575 #[orderable]
7676 #[gate_rustc_only]
compiler/rustc_abi/src/layout/ty.rs+3-3
......@@ -2,7 +2,7 @@ use std::fmt;
22use std::ops::Deref;
33
44use rustc_data_structures::intern::Interned;
5use rustc_macros::HashStable_Generic;
5use rustc_macros::HashStable;
66
77use crate::layout::{FieldIdx, VariantIdx};
88use crate::{
......@@ -12,7 +12,7 @@ use crate::{
1212
1313// Explicitly import `Float` to avoid ambiguity with `Primitive::Float`.
1414
15#[derive(Copy, Clone, PartialEq, Eq, Hash, HashStable_Generic)]
15#[derive(Copy, Clone, PartialEq, Eq, Hash, HashStable)]
1616#[rustc_pass_by_value]
1717pub struct Layout<'a>(pub Interned<'a, LayoutData<FieldIdx, VariantIdx>>);
1818
......@@ -71,7 +71,7 @@ impl<'a> Layout<'a> {
7171/// to that obtained from `layout_of(ty)`, as we need to produce
7272/// layouts for which Rust types do not exist, such as enum variants
7373/// or synthetic fields of enums (i.e., discriminants) and wide pointers.
74#[derive(Copy, Clone, PartialEq, Eq, Hash, HashStable_Generic)]
74#[derive(Copy, Clone, PartialEq, Eq, Hash, HashStable)]
7575pub struct TyAndLayout<'a, Ty> {
7676 pub ty: Ty,
7777 pub layout: Layout<'a>,
compiler/rustc_abi/src/lib.rs+21-42
......@@ -53,7 +53,7 @@ use rustc_errors::{Diag, DiagCtxtHandle, Diagnostic, EmissionGuarantee, Level, m
5353use rustc_hashes::Hash64;
5454use rustc_index::{Idx, IndexSlice, IndexVec};
5555#[cfg(feature = "nightly")]
56use rustc_macros::{Decodable_NoContext, Encodable_NoContext, HashStable_Generic};
56use rustc_macros::{Decodable_NoContext, Encodable_NoContext, HashStable};
5757#[cfg(feature = "nightly")]
5858use rustc_span::{Symbol, sym};
5959
......@@ -74,10 +74,7 @@ pub use layout::{FIRST_VARIANT, FieldIdx, LayoutCalculator, LayoutCalculatorErro
7474pub use layout::{Layout, TyAbiInterface, TyAndLayout};
7575
7676#[derive(Clone, Copy, PartialEq, Eq, Default)]
77#[cfg_attr(
78 feature = "nightly",
79 derive(Encodable_NoContext, Decodable_NoContext, HashStable_Generic)
80)]
77#[cfg_attr(feature = "nightly", derive(Encodable_NoContext, Decodable_NoContext, HashStable))]
8178pub struct ReprFlags(u8);
8279
8380bitflags! {
......@@ -114,10 +111,7 @@ impl std::fmt::Debug for ReprFlags {
114111}
115112
116113#[derive(Copy, Clone, Debug, Eq, PartialEq)]
117#[cfg_attr(
118 feature = "nightly",
119 derive(Encodable_NoContext, Decodable_NoContext, HashStable_Generic)
120)]
114#[cfg_attr(feature = "nightly", derive(Encodable_NoContext, Decodable_NoContext, HashStable))]
121115pub enum IntegerType {
122116 /// Pointer-sized integer type, i.e. `isize` and `usize`. The field shows signedness, e.g.
123117 /// `Pointer(true)` means `isize`.
......@@ -137,10 +131,7 @@ impl IntegerType {
137131}
138132
139133#[derive(Copy, Clone, Debug, Eq, PartialEq)]
140#[cfg_attr(
141 feature = "nightly",
142 derive(Encodable_NoContext, Decodable_NoContext, HashStable_Generic)
143)]
134#[cfg_attr(feature = "nightly", derive(Encodable_NoContext, Decodable_NoContext, HashStable))]
144135pub enum ScalableElt {
145136 /// `N` in `rustc_scalable_vector(N)` - the element count of the scalable vector
146137 ElementCount(u16),
......@@ -151,10 +142,7 @@ pub enum ScalableElt {
151142
152143/// Represents the repr options provided by the user.
153144#[derive(Copy, Clone, Debug, Eq, PartialEq, Default)]
154#[cfg_attr(
155 feature = "nightly",
156 derive(Encodable_NoContext, Decodable_NoContext, HashStable_Generic)
157)]
145#[cfg_attr(feature = "nightly", derive(Encodable_NoContext, Decodable_NoContext, HashStable))]
158146pub struct ReprOptions {
159147 pub int: Option<IntegerType>,
160148 pub align: Option<Align>,
......@@ -804,10 +792,7 @@ impl FromStr for Endian {
804792
805793/// Size of a type in bytes.
806794#[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
807#[cfg_attr(
808 feature = "nightly",
809 derive(Encodable_NoContext, Decodable_NoContext, HashStable_Generic)
810)]
795#[cfg_attr(feature = "nightly", derive(Encodable_NoContext, Decodable_NoContext, HashStable))]
811796pub struct Size {
812797 raw: u64,
813798}
......@@ -1032,10 +1017,7 @@ impl Step for Size {
10321017
10331018/// Alignment of a type in bytes (always a power of two).
10341019#[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
1035#[cfg_attr(
1036 feature = "nightly",
1037 derive(Encodable_NoContext, Decodable_NoContext, HashStable_Generic)
1038)]
1020#[cfg_attr(feature = "nightly", derive(Encodable_NoContext, Decodable_NoContext, HashStable))]
10391021pub struct Align {
10401022 pow2: u8,
10411023}
......@@ -1168,7 +1150,7 @@ impl Align {
11681150/// An example of a rare thing actually affected by preferred alignment is aligning of statics.
11691151/// It is of effectively no consequence for layout in structs and on the stack.
11701152#[derive(Copy, Clone, PartialEq, Eq, Hash, Debug)]
1171#[cfg_attr(feature = "nightly", derive(HashStable_Generic))]
1153#[cfg_attr(feature = "nightly", derive(HashStable))]
11721154pub struct AbiAlign {
11731155 pub abi: Align,
11741156}
......@@ -1200,10 +1182,7 @@ impl Deref for AbiAlign {
12001182
12011183/// Integers, also used for enum discriminants.
12021184#[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Debug)]
1203#[cfg_attr(
1204 feature = "nightly",
1205 derive(Encodable_NoContext, Decodable_NoContext, HashStable_Generic)
1206)]
1185#[cfg_attr(feature = "nightly", derive(Encodable_NoContext, Decodable_NoContext, HashStable))]
12071186pub enum Integer {
12081187 I8,
12091188 I16,
......@@ -1363,7 +1342,7 @@ impl Integer {
13631342
13641343/// Floating-point types.
13651344#[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Debug)]
1366#[cfg_attr(feature = "nightly", derive(HashStable_Generic))]
1345#[cfg_attr(feature = "nightly", derive(HashStable))]
13671346pub enum Float {
13681347 F16,
13691348 F32,
......@@ -1398,7 +1377,7 @@ impl Float {
13981377
13991378/// Fundamental unit of memory access and layout.
14001379#[derive(Copy, Clone, PartialEq, Eq, Hash, Debug)]
1401#[cfg_attr(feature = "nightly", derive(HashStable_Generic))]
1380#[cfg_attr(feature = "nightly", derive(HashStable))]
14021381pub enum Primitive {
14031382 /// The `bool` is the signedness of the `Integer` type.
14041383 ///
......@@ -1446,7 +1425,7 @@ impl Primitive {
14461425///
14471426/// This is intended specifically to mirror LLVM’s `!range` metadata semantics.
14481427#[derive(Clone, Copy, PartialEq, Eq, Hash)]
1449#[cfg_attr(feature = "nightly", derive(HashStable_Generic))]
1428#[cfg_attr(feature = "nightly", derive(HashStable))]
14501429pub struct WrappingRange {
14511430 pub start: u128,
14521431 pub end: u128,
......@@ -1558,7 +1537,7 @@ impl fmt::Debug for WrappingRange {
15581537
15591538/// Information about one scalar component of a Rust type.
15601539#[derive(Clone, Copy, PartialEq, Eq, Hash, Debug)]
1561#[cfg_attr(feature = "nightly", derive(HashStable_Generic))]
1540#[cfg_attr(feature = "nightly", derive(HashStable))]
15621541pub enum Scalar {
15631542 Initialized {
15641543 value: Primitive,
......@@ -1662,7 +1641,7 @@ impl Scalar {
16621641// NOTE: This struct is generic over the FieldIdx for rust-analyzer usage.
16631642/// Describes how the fields of a type are located in memory.
16641643#[derive(PartialEq, Eq, Hash, Clone, Debug)]
1665#[cfg_attr(feature = "nightly", derive(HashStable_Generic))]
1644#[cfg_attr(feature = "nightly", derive(HashStable))]
16661645pub enum FieldsShape<FieldIdx: Idx> {
16671646 /// Scalar primitives and `!`, which never have fields.
16681647 Primitive,
......@@ -1747,7 +1726,7 @@ impl<FieldIdx: Idx> FieldsShape<FieldIdx> {
17471726/// should operate on. Special address spaces have an effect on code generation,
17481727/// depending on the target and the address spaces it implements.
17491728#[derive(Copy, Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
1750#[cfg_attr(feature = "nightly", derive(HashStable_Generic))]
1729#[cfg_attr(feature = "nightly", derive(HashStable))]
17511730pub struct AddressSpace(pub u32);
17521731
17531732impl AddressSpace {
......@@ -1760,7 +1739,7 @@ impl AddressSpace {
17601739
17611740/// How many scalable vectors are in a `BackendRepr::ScalableVector`?
17621741#[derive(Clone, Copy, PartialEq, Eq, Hash, Debug)]
1763#[cfg_attr(feature = "nightly", derive(HashStable_Generic))]
1742#[cfg_attr(feature = "nightly", derive(HashStable))]
17641743pub struct NumScalableVectors(pub u8);
17651744
17661745impl NumScalableVectors {
......@@ -1809,7 +1788,7 @@ impl IntoDiagArg for NumScalableVectors {
18091788/// Generally, a codegen backend will prefer to handle smaller values as a scalar or short vector,
18101789/// and larger values will usually prefer to be represented as memory.
18111790#[derive(Clone, Copy, PartialEq, Eq, Hash, Debug)]
1812#[cfg_attr(feature = "nightly", derive(HashStable_Generic))]
1791#[cfg_attr(feature = "nightly", derive(HashStable))]
18131792pub enum BackendRepr {
18141793 Scalar(Scalar),
18151794 ScalarPair(Scalar, Scalar),
......@@ -1953,7 +1932,7 @@ impl BackendRepr {
19531932
19541933// NOTE: This struct is generic over the FieldIdx and VariantIdx for rust-analyzer usage.
19551934#[derive(PartialEq, Eq, Hash, Clone, Debug)]
1956#[cfg_attr(feature = "nightly", derive(HashStable_Generic))]
1935#[cfg_attr(feature = "nightly", derive(HashStable))]
19571936pub enum Variants<FieldIdx: Idx, VariantIdx: Idx> {
19581937 /// A type with no valid variants. Must be uninhabited.
19591938 Empty,
......@@ -1980,7 +1959,7 @@ pub enum Variants<FieldIdx: Idx, VariantIdx: Idx> {
19801959
19811960// NOTE: This struct is generic over the VariantIdx for rust-analyzer usage.
19821961#[derive(PartialEq, Eq, Hash, Clone, Debug)]
1983#[cfg_attr(feature = "nightly", derive(HashStable_Generic))]
1962#[cfg_attr(feature = "nightly", derive(HashStable))]
19841963pub enum TagEncoding<VariantIdx: Idx> {
19851964 /// The tag directly stores the discriminant, but possibly with a smaller layout
19861965 /// (so converting the tag to the discriminant can require sign extension).
......@@ -2021,7 +2000,7 @@ pub enum TagEncoding<VariantIdx: Idx> {
20212000}
20222001
20232002#[derive(Clone, Copy, PartialEq, Eq, Hash, Debug)]
2024#[cfg_attr(feature = "nightly", derive(HashStable_Generic))]
2003#[cfg_attr(feature = "nightly", derive(HashStable))]
20252004pub struct Niche {
20262005 pub offset: Size,
20272006 pub value: Primitive,
......@@ -2118,7 +2097,7 @@ impl Niche {
21182097
21192098// NOTE: This struct is generic over the FieldIdx and VariantIdx for rust-analyzer usage.
21202099#[derive(PartialEq, Eq, Hash, Clone)]
2121#[cfg_attr(feature = "nightly", derive(HashStable_Generic))]
2100#[cfg_attr(feature = "nightly", derive(HashStable))]
21222101pub struct LayoutData<FieldIdx: Idx, VariantIdx: Idx> {
21232102 /// Says where the fields are located within the layout.
21242103 pub fields: FieldsShape<FieldIdx>,
compiler/rustc_ast/src/ast.rs+40-41
......@@ -25,14 +25,13 @@ pub use GenericArgs::*;
2525pub use UnsafeSource::*;
2626pub use rustc_ast_ir::{FloatTy, IntTy, Movability, Mutability, Pinnedness, UintTy};
2727use rustc_data_structures::packed::Pu128;
28use rustc_data_structures::stable_hasher::{HashStable, StableHasher};
28use rustc_data_structures::stable_hasher::{HashStable, HashStableContext, StableHasher};
2929use rustc_data_structures::stack::ensure_sufficient_stack;
3030use rustc_data_structures::tagged_ptr::Tag;
31use rustc_macros::{Decodable, Encodable, HashStable_Generic, Walkable};
31use rustc_macros::{Decodable, Encodable, HashStable, Walkable};
3232pub use rustc_span::AttrId;
3333use rustc_span::{
34 ByteSymbol, DUMMY_SP, ErrorGuaranteed, HashStableContext, Ident, Span, Spanned, Symbol, kw,
35 respan, sym,
34 ByteSymbol, DUMMY_SP, ErrorGuaranteed, Ident, Span, Spanned, Symbol, kw, respan, sym,
3635};
3736use thin_vec::{ThinVec, thin_vec};
3837
......@@ -53,7 +52,7 @@ use crate::visit::{AssocCtxt, BoundKind, LifetimeCtxt};
5352/// ```
5453///
5554/// `'outer` is a label.
56#[derive(Clone, Encodable, Decodable, Copy, HashStable_Generic, Eq, PartialEq, Walkable)]
55#[derive(Clone, Encodable, Decodable, Copy, HashStable, Eq, PartialEq, Walkable)]
5756pub struct Label {
5857 pub ident: Ident,
5958}
......@@ -121,8 +120,8 @@ impl PartialEq<&[Symbol]> for Path {
121120 }
122121}
123122
124impl<Hcx: HashStableContext> HashStable<Hcx> for Path {
125 fn hash_stable(&self, hcx: &mut Hcx, hasher: &mut StableHasher) {
123impl HashStable for Path {
124 fn hash_stable<Hcx: HashStableContext>(&self, hcx: &mut Hcx, hasher: &mut StableHasher) {
126125 self.segments.len().hash_stable(hcx, hasher);
127126 for segment in &self.segments {
128127 segment.ident.hash_stable(hcx, hasher);
......@@ -565,7 +564,7 @@ pub struct Crate {
565564/// for most built-in attributes.
566565///
567566/// E.g., `#[test]`, `#[derive(..)]`, `#[rustfmt::skip]` or `#[feature = "foo"]`.
568#[derive(Clone, Encodable, Decodable, Debug, HashStable_Generic)]
567#[derive(Clone, Encodable, Decodable, Debug, HashStable)]
569568pub struct MetaItem {
570569 pub unsafety: Safety,
571570 pub path: Path,
......@@ -574,7 +573,7 @@ pub struct MetaItem {
574573}
575574
576575/// The meta item kind, containing the data after the initial path.
577#[derive(Clone, Encodable, Decodable, Debug, HashStable_Generic)]
576#[derive(Clone, Encodable, Decodable, Debug, HashStable)]
578577pub enum MetaItemKind {
579578 /// Word meta item.
580579 ///
......@@ -595,7 +594,7 @@ pub enum MetaItemKind {
595594/// Values inside meta item lists.
596595///
597596/// E.g., each of `Clone`, `Copy` in `#[derive(Clone, Copy)]`.
598#[derive(Clone, Encodable, Decodable, Debug, HashStable_Generic)]
597#[derive(Clone, Encodable, Decodable, Debug, HashStable)]
599598pub enum MetaItemInner {
600599 /// A full MetaItem, for recursive meta items.
601600 MetaItem(MetaItem),
......@@ -793,7 +792,7 @@ pub struct PatField {
793792}
794793
795794#[derive(Clone, Copy, Debug, Eq, PartialEq)]
796#[derive(Encodable, Decodable, HashStable_Generic, Walkable)]
795#[derive(Encodable, Decodable, HashStable, Walkable)]
797796pub enum ByRef {
798797 Yes(Pinnedness, Mutability),
799798 No,
......@@ -815,7 +814,7 @@ impl ByRef {
815814/// `.0` is the by-reference mode (`ref`, `ref mut`, or by value),
816815/// `.1` is the mutability of the binding.
817816#[derive(Clone, Copy, Debug, Eq, PartialEq)]
818#[derive(Encodable, Decodable, HashStable_Generic, Walkable)]
817#[derive(Encodable, Decodable, HashStable, Walkable)]
819818pub struct BindingMode(pub ByRef, pub Mutability);
820819
821820impl BindingMode {
......@@ -965,7 +964,7 @@ pub enum PatFieldsRest {
965964/// The kind of borrow in an `AddrOf` expression,
966965/// e.g., `&place` or `&raw const place`.
967966#[derive(Clone, Copy, PartialEq, Eq, Debug)]
968#[derive(Encodable, Decodable, HashStable_Generic, Walkable)]
967#[derive(Encodable, Decodable, HashStable, Walkable)]
969968pub enum BorrowKind {
970969 /// A normal borrow, `&$expr` or `&mut $expr`.
971970 /// The resulting type is either `&'a T` or `&'a mut T`
......@@ -981,7 +980,7 @@ pub enum BorrowKind {
981980 Pin,
982981}
983982
984#[derive(Clone, Copy, Debug, PartialEq, Encodable, Decodable, HashStable_Generic, Walkable)]
983#[derive(Clone, Copy, Debug, PartialEq, Encodable, Decodable, HashStable, Walkable)]
985984pub enum BinOpKind {
986985 /// The `+` operator (addition)
987986 Add,
......@@ -1111,7 +1110,7 @@ impl From<AssignOpKind> for BinOpKind {
11111110 }
11121111}
11131112
1114#[derive(Clone, Copy, Debug, PartialEq, Encodable, Decodable, HashStable_Generic, Walkable)]
1113#[derive(Clone, Copy, Debug, PartialEq, Encodable, Decodable, HashStable, Walkable)]
11151114pub enum AssignOpKind {
11161115 /// The `+=` operator (addition)
11171116 AddAssign,
......@@ -1163,7 +1162,7 @@ pub type AssignOp = Spanned<AssignOpKind>;
11631162/// Unary operator.
11641163///
11651164/// Note that `&data` is not an operator, it's an `AddrOf` expression.
1166#[derive(Clone, Copy, Debug, PartialEq, Encodable, Decodable, HashStable_Generic, Walkable)]
1165#[derive(Clone, Copy, Debug, PartialEq, Encodable, Decodable, HashStable, Walkable)]
11671166pub enum UnOp {
11681167 /// The `*` operator for dereferencing
11691168 Deref,
......@@ -1962,7 +1961,7 @@ impl GenBlockKind {
19621961
19631962/// Whether we're unwrapping or wrapping an unsafe binder
19641963#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash)]
1965#[derive(Encodable, Decodable, HashStable_Generic, Walkable)]
1964#[derive(Encodable, Decodable, HashStable, Walkable)]
19661965pub enum UnsafeBinderCastKind {
19671966 // e.g. `&i32` -> `unsafe<'a> &'a i32`
19681967 Wrap,
......@@ -1996,7 +1995,7 @@ pub struct QSelf {
19961995}
19971996
19981997/// A capture clause used in closures and `async` blocks.
1999#[derive(Clone, Copy, PartialEq, Encodable, Decodable, Debug, HashStable_Generic, Walkable)]
1998#[derive(Clone, Copy, PartialEq, Encodable, Decodable, Debug, HashStable, Walkable)]
20001999pub enum CaptureBy {
20012000 /// `move |x| y + x`.
20022001 Value {
......@@ -2091,7 +2090,7 @@ impl AttrArgs {
20912090}
20922091
20932092/// Delimited arguments, as used in `#[attr()/[]/{}]` or `mac!()/[]/{}`.
2094#[derive(Clone, Encodable, Decodable, Debug, HashStable_Generic, Walkable)]
2093#[derive(Clone, Encodable, Decodable, Debug, HashStable, Walkable)]
20952094pub struct DelimArgs {
20962095 pub dspan: DelimSpan,
20972096 pub delim: Delimiter, // Note: `Delimiter::Invisible` never occurs
......@@ -2107,7 +2106,7 @@ impl DelimArgs {
21072106}
21082107
21092108/// Represents a macro definition.
2110#[derive(Clone, Encodable, Decodable, Debug, HashStable_Generic, Walkable)]
2109#[derive(Clone, Encodable, Decodable, Debug, HashStable, Walkable)]
21112110pub struct MacroDef {
21122111 pub body: Box<DelimArgs>,
21132112 /// `true` if macro was defined with `macro_rules`.
......@@ -2121,7 +2120,7 @@ pub struct MacroDef {
21212120 pub eii_declaration: Option<EiiDecl>,
21222121}
21232122
2124#[derive(Clone, Encodable, Decodable, Debug, HashStable_Generic, Walkable)]
2123#[derive(Clone, Encodable, Decodable, Debug, HashStable, Walkable)]
21252124pub struct EiiDecl {
21262125 /// path to the extern item we're targeting
21272126 pub foreign_item: Path,
......@@ -2129,7 +2128,7 @@ pub struct EiiDecl {
21292128}
21302129
21312130#[derive(Clone, Encodable, Decodable, Debug, Copy, Hash, Eq, PartialEq)]
2132#[derive(HashStable_Generic, Walkable)]
2131#[derive(HashStable, Walkable)]
21332132pub enum StrStyle {
21342133 /// A regular string, like `"foo"`.
21352134 Cooked,
......@@ -2187,7 +2186,7 @@ impl YieldKind {
21872186}
21882187
21892188/// A literal in a meta item.
2190#[derive(Clone, Copy, Encodable, Decodable, Debug, HashStable_Generic)]
2189#[derive(Clone, Copy, Encodable, Decodable, Debug, HashStable)]
21912190pub struct MetaItemLit {
21922191 /// The original literal as written in the source code.
21932192 pub symbol: Symbol,
......@@ -2224,7 +2223,7 @@ impl StrLit {
22242223
22252224/// Type of the integer literal based on provided suffix.
22262225#[derive(Clone, Copy, Encodable, Decodable, Debug, Hash, Eq, PartialEq)]
2227#[derive(HashStable_Generic)]
2226#[derive(HashStable)]
22282227pub enum LitIntType {
22292228 /// e.g. `42_i32`.
22302229 Signed(IntTy),
......@@ -2236,7 +2235,7 @@ pub enum LitIntType {
22362235
22372236/// Type of the float literal based on provided suffix.
22382237#[derive(Clone, Copy, Encodable, Decodable, Debug, Hash, Eq, PartialEq)]
2239#[derive(HashStable_Generic)]
2238#[derive(HashStable)]
22402239pub enum LitFloatType {
22412240 /// A float literal with a suffix (`1f32` or `1E10f32`).
22422241 Suffixed(FloatTy),
......@@ -2250,7 +2249,7 @@ pub enum LitFloatType {
22502249/// deciding the `LitKind`. This means that float literals like `1f32` are
22512250/// classified by this type as `Float`. This is different to `token::LitKind`
22522251/// which does *not* consider the suffix.
2253#[derive(Clone, Copy, Encodable, Decodable, Debug, Hash, Eq, PartialEq, HashStable_Generic)]
2252#[derive(Clone, Copy, Encodable, Decodable, Debug, Hash, Eq, PartialEq, HashStable)]
22542253pub enum LitKind {
22552254 /// A string literal (`"foo"`). The symbol is unescaped, and so may differ
22562255 /// from the original token's symbol.
......@@ -2653,7 +2652,7 @@ pub enum TyPatKind {
26532652}
26542653
26552654/// Syntax used to declare a trait object.
2656#[derive(Clone, Copy, PartialEq, Encodable, Decodable, Debug, HashStable_Generic, Walkable)]
2655#[derive(Clone, Copy, PartialEq, Encodable, Decodable, Debug, HashStable, Walkable)]
26572656#[repr(u8)]
26582657pub enum TraitObjectSyntax {
26592658 // SAFETY: When adding new variants make sure to update the `Tag` impl.
......@@ -2697,7 +2696,7 @@ pub enum InlineAsmRegOrRegClass {
26972696 RegClass(Symbol),
26982697}
26992698
2700#[derive(Clone, Copy, PartialEq, Eq, Hash, Encodable, Decodable, HashStable_Generic)]
2699#[derive(Clone, Copy, PartialEq, Eq, Hash, Encodable, Decodable, HashStable)]
27012700pub struct InlineAsmOptions(u16);
27022701bitflags::bitflags! {
27032702 impl InlineAsmOptions: u16 {
......@@ -2760,7 +2759,7 @@ impl std::fmt::Debug for InlineAsmOptions {
27602759 }
27612760}
27622761
2763#[derive(Clone, PartialEq, Encodable, Decodable, Debug, Hash, HashStable_Generic, Walkable)]
2762#[derive(Clone, PartialEq, Encodable, Decodable, Debug, Hash, HashStable, Walkable)]
27642763pub enum InlineAsmTemplatePiece {
27652764 String(Cow<'static, str>),
27662765 Placeholder { operand_idx: usize, modifier: Option<char>, span: Span },
......@@ -2863,7 +2862,7 @@ impl InlineAsmOperand {
28632862 }
28642863}
28652864
2866#[derive(Clone, Copy, Encodable, Decodable, Debug, HashStable_Generic, Walkable, PartialEq, Eq)]
2865#[derive(Clone, Copy, Encodable, Decodable, Debug, HashStable, Walkable, PartialEq, Eq)]
28672866pub enum AsmMacro {
28682867 /// The `asm!` macro
28692868 Asm,
......@@ -3061,7 +3060,7 @@ impl FnDecl {
30613060}
30623061
30633062/// Is the trait definition an auto trait?
3064#[derive(Copy, Clone, PartialEq, Encodable, Decodable, Debug, HashStable_Generic, Walkable)]
3063#[derive(Copy, Clone, PartialEq, Encodable, Decodable, Debug, HashStable, Walkable)]
30653064pub enum IsAuto {
30663065 Yes,
30673066 No,
......@@ -3069,7 +3068,7 @@ pub enum IsAuto {
30693068
30703069/// Safety of items.
30713070#[derive(Copy, Clone, PartialEq, Eq, Hash, Encodable, Decodable, Debug)]
3072#[derive(HashStable_Generic, Walkable)]
3071#[derive(HashStable, Walkable)]
30733072pub enum Safety {
30743073 /// `unsafe` an item is explicitly marked as `unsafe`.
30753074 Unsafe(Span),
......@@ -3134,7 +3133,7 @@ impl CoroutineKind {
31343133}
31353134
31363135#[derive(Copy, Clone, PartialEq, Eq, Hash, Encodable, Decodable, Debug)]
3137#[derive(HashStable_Generic, Walkable)]
3136#[derive(HashStable, Walkable)]
31383137pub enum Const {
31393138 Yes(Span),
31403139 No,
......@@ -3142,7 +3141,7 @@ pub enum Const {
31423141
31433142/// Item defaultness.
31443143/// For details see the [RFC #2532](https://github.com/rust-lang/rfcs/pull/2532).
3145#[derive(Copy, Clone, PartialEq, Encodable, Decodable, Debug, HashStable_Generic, Walkable)]
3144#[derive(Copy, Clone, PartialEq, Encodable, Decodable, Debug, HashStable, Walkable)]
31463145pub enum Defaultness {
31473146 /// Item is unmarked. Implicitly determined based off of position.
31483147 /// For impls, this is `final`; for traits, this is `default`.
......@@ -3156,7 +3155,7 @@ pub enum Defaultness {
31563155 Final(Span),
31573156}
31583157
3159#[derive(Copy, Clone, PartialEq, Encodable, Decodable, HashStable_Generic, Walkable)]
3158#[derive(Copy, Clone, PartialEq, Encodable, Decodable, HashStable, Walkable)]
31603159pub enum ImplPolarity {
31613160 /// `impl Trait for Type`
31623161 Positive,
......@@ -3175,7 +3174,7 @@ impl fmt::Debug for ImplPolarity {
31753174
31763175/// The polarity of a trait bound.
31773176#[derive(Copy, Clone, PartialEq, Eq, Encodable, Decodable, Debug, Hash)]
3178#[derive(HashStable_Generic, Walkable)]
3177#[derive(HashStable, Walkable)]
31793178pub enum BoundPolarity {
31803179 /// `Type: Trait`
31813180 Positive,
......@@ -3197,7 +3196,7 @@ impl BoundPolarity {
31973196
31983197/// The constness of a trait bound.
31993198#[derive(Copy, Clone, PartialEq, Eq, Encodable, Decodable, Debug, Hash)]
3200#[derive(HashStable_Generic, Walkable)]
3199#[derive(HashStable, Walkable)]
32013200pub enum BoundConstness {
32023201 /// `Type: Trait`
32033202 Never,
......@@ -3219,7 +3218,7 @@ impl BoundConstness {
32193218
32203219/// The asyncness of a trait bound.
32213220#[derive(Copy, Clone, PartialEq, Eq, Encodable, Decodable, Debug)]
3222#[derive(HashStable_Generic, Walkable)]
3221#[derive(HashStable, Walkable)]
32233222pub enum BoundAsyncness {
32243223 /// `Type: Trait`
32253224 Normal,
......@@ -3388,7 +3387,7 @@ impl UseTree {
33883387/// are contained as statements within items. These two cases need to be
33893388/// distinguished for pretty-printing.
33903389#[derive(Clone, PartialEq, Eq, Hash, Debug, Copy)]
3391#[derive(Encodable, Decodable, HashStable_Generic, Walkable)]
3390#[derive(Encodable, Decodable, HashStable, Walkable)]
33923391pub enum AttrStyle {
33933392 Outer,
33943393 Inner,
......@@ -3485,7 +3484,7 @@ impl AttrItemKind {
34853484///
34863485/// Currently all early parsed attributes are excluded from pretty printing at rustc_ast_pretty::pprust::state::print_attribute_inline.
34873486/// When adding new early parsed attributes, consider whether they should be pretty printed.
3488#[derive(Clone, Encodable, Decodable, Debug, HashStable_Generic)]
3487#[derive(Clone, Encodable, Decodable, Debug, HashStable)]
34893488pub enum EarlyParsedAttribute {
34903489 CfgTrace(CfgEntry),
34913490 CfgAttrTrace,
......@@ -3608,7 +3607,7 @@ pub struct FieldDef {
36083607}
36093608
36103609/// Was parsing recovery performed?
3611#[derive(Copy, Clone, Debug, Encodable, Decodable, HashStable_Generic, Walkable)]
3610#[derive(Copy, Clone, Debug, Encodable, Decodable, HashStable, Walkable)]
36123611pub enum Recovered {
36133612 No,
36143613 Yes(ErrorGuaranteed),
compiler/rustc_ast/src/attr/data_structures.rs+2-2
......@@ -1,12 +1,12 @@
11use std::fmt;
22
3use rustc_macros::{Decodable, Encodable, HashStable_Generic};
3use rustc_macros::{Decodable, Encodable, HashStable};
44use rustc_span::{Span, Symbol};
55use thin_vec::ThinVec;
66
77use crate::attr::version::RustcVersion;
88
9#[derive(Encodable, Decodable, Clone, Debug, PartialEq, Eq, Hash, HashStable_Generic)]
9#[derive(Encodable, Decodable, Clone, Debug, PartialEq, Eq, Hash, HashStable)]
1010pub enum CfgEntry {
1111 All(ThinVec<CfgEntry>, Span),
1212 Any(ThinVec<CfgEntry>, Span),
compiler/rustc_ast/src/attr/version.rs+2-2
......@@ -1,10 +1,10 @@
11use std::fmt::{self, Display};
22use std::sync::OnceLock;
33
4use rustc_macros::{BlobDecodable, Encodable, HashStable_Generic, current_rustc_version};
4use rustc_macros::{BlobDecodable, Encodable, HashStable, current_rustc_version};
55
66#[derive(Encodable, BlobDecodable, Copy, Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
7#[derive(HashStable_Generic)]
7#[derive(HashStable)]
88pub struct RustcVersion {
99 pub major: u16,
1010 pub minor: u16,
compiler/rustc_ast/src/expand/allocator.rs+2-2
......@@ -1,7 +1,7 @@
1use rustc_macros::HashStable_Generic;
1use rustc_macros::HashStable;
22use rustc_span::{Symbol, sym};
33
4#[derive(Clone, Debug, Copy, Eq, PartialEq, HashStable_Generic)]
4#[derive(Clone, Debug, Copy, Eq, PartialEq, HashStable)]
55pub enum AllocatorKind {
66 /// Use `#[global_allocator]` as global allocator.
77 Global,
compiler/rustc_ast/src/expand/autodiff_attrs.rs+3-3
......@@ -8,7 +8,7 @@ use std::str::FromStr;
88
99use rustc_span::{Symbol, sym};
1010
11use crate::expand::{Decodable, Encodable, HashStable_Generic};
11use crate::expand::{Decodable, Encodable, HashStable};
1212use crate::{Ty, TyKind};
1313
1414/// Forward and Reverse Mode are well known names for automatic differentiation implementations.
......@@ -20,7 +20,7 @@ use crate::{Ty, TyKind};
2020///
2121/// Documentation for using [reverse](https://enzyme.mit.edu/rust/rev.html) and
2222/// [forward](https://enzyme.mit.edu/rust/fwd.html) mode is available online.
23#[derive(Clone, Copy, Eq, PartialEq, Encodable, Decodable, Debug, HashStable_Generic)]
23#[derive(Clone, Copy, Eq, PartialEq, Encodable, Decodable, Debug, HashStable)]
2424pub enum DiffMode {
2525 /// No autodiff is applied (used during error handling).
2626 Error,
......@@ -42,7 +42,7 @@ impl DiffMode {
4242/// However, under forward mode we overwrite the previous shadow value, while for reverse mode
4343/// we add to the previous shadow value. To not surprise users, we picked different names.
4444/// Dual numbers is also a quite well known name for forward mode AD types.
45#[derive(Clone, Copy, Eq, PartialEq, Encodable, Decodable, Debug, HashStable_Generic)]
45#[derive(Clone, Copy, Eq, PartialEq, Encodable, Decodable, Debug, HashStable)]
4646pub enum DiffActivity {
4747 /// Implicit or Explicit () return type, so a special case of Const.
4848 None,
compiler/rustc_ast/src/expand/mod.rs+1-1
......@@ -1,6 +1,6 @@
11//! Definitions shared by macros / syntax extensions and e.g. `rustc_middle`.
22
3use rustc_macros::{Decodable, Encodable, HashStable_Generic};
3use rustc_macros::{Decodable, Encodable, HashStable};
44
55pub mod allocator;
66pub mod autodiff_attrs;
compiler/rustc_ast/src/expand/typetree.rs+5-5
......@@ -21,9 +21,9 @@
2121
2222use std::fmt;
2323
24use crate::expand::{Decodable, Encodable, HashStable_Generic};
24use crate::expand::{Decodable, Encodable, HashStable};
2525
26#[derive(Clone, Copy, Eq, PartialEq, Encodable, Decodable, Debug, HashStable_Generic)]
26#[derive(Clone, Copy, Eq, PartialEq, Encodable, Decodable, Debug, HashStable)]
2727pub enum Kind {
2828 Anything,
2929 Integer,
......@@ -35,7 +35,7 @@ pub enum Kind {
3535 Unknown,
3636}
3737
38#[derive(Clone, Eq, PartialEq, Encodable, Decodable, Debug, HashStable_Generic)]
38#[derive(Clone, Eq, PartialEq, Encodable, Decodable, Debug, HashStable)]
3939pub struct TypeTree(pub Vec<Type>);
4040
4141impl TypeTree {
......@@ -59,13 +59,13 @@ impl TypeTree {
5959 }
6060}
6161
62#[derive(Clone, Eq, PartialEq, Encodable, Decodable, Debug, HashStable_Generic)]
62#[derive(Clone, Eq, PartialEq, Encodable, Decodable, Debug, HashStable)]
6363pub struct FncTree {
6464 pub args: Vec<TypeTree>,
6565 pub ret: TypeTree,
6666}
6767
68#[derive(Clone, Eq, PartialEq, Encodable, Decodable, Debug, HashStable_Generic)]
68#[derive(Clone, Eq, PartialEq, Encodable, Decodable, Debug, HashStable)]
6969pub struct Type {
7070 pub offset: isize,
7171 pub size: usize,
compiler/rustc_ast/src/node_id.rs+10
......@@ -1,5 +1,6 @@
11use std::fmt;
22
3use rustc_data_structures::stable_hasher::{HashStable, HashStableContext, StableHasher};
34use rustc_span::LocalExpnId;
45
56rustc_index::newtype_index! {
......@@ -18,6 +19,15 @@ rustc_index::newtype_index! {
1819 }
1920}
2021
22impl HashStable for NodeId {
23 #[inline]
24 fn hash_stable<Hcx: HashStableContext>(&self, _: &mut Hcx, _: &mut StableHasher) {
25 // This impl is never called but is necessary for types implementing `HashStable` such as
26 // `MainDefinition` and `DocLinkResMap` (both of which occur in `ResolverGlobalCtxt`).
27 panic!("Node IDs should not appear in incremental state");
28 }
29}
30
2131rustc_data_structures::define_id_collections!(NodeMap, NodeSet, NodeMapEntry, NodeId);
2232
2333/// When parsing and at the beginning of doing expansions, we initially give all AST nodes
compiler/rustc_ast/src/token.rs+14-14
......@@ -5,7 +5,7 @@ pub use LitKind::*;
55pub use NtExprKind::*;
66pub use NtPatKind::*;
77pub use TokenKind::*;
8use rustc_macros::{Decodable, Encodable, HashStable_Generic};
8use rustc_macros::{Decodable, Encodable, HashStable};
99use rustc_span::edition::Edition;
1010use rustc_span::symbol::IdentPrintMode;
1111use rustc_span::{DUMMY_SP, ErrorGuaranteed, Span, kw, sym};
......@@ -17,7 +17,7 @@ use crate::ast;
1717use crate::util::case::Case;
1818
1919/// Represents the kind of doc comment it is, ie `///` or `#[doc = ""]`.
20#[derive(Clone, Copy, PartialEq, Eq, Encodable, Decodable, Debug, HashStable_Generic)]
20#[derive(Clone, Copy, PartialEq, Eq, Encodable, Decodable, Debug, HashStable)]
2121pub enum DocFragmentKind {
2222 /// A sugared doc comment: `///` or `//!` or `/**` or `/*!`.
2323 Sugared(CommentKind),
......@@ -40,13 +40,13 @@ impl DocFragmentKind {
4040 }
4141}
4242
43#[derive(Clone, Copy, PartialEq, Eq, Hash, Encodable, Decodable, Debug, HashStable_Generic)]
43#[derive(Clone, Copy, PartialEq, Eq, Hash, Encodable, Decodable, Debug, HashStable)]
4444pub enum CommentKind {
4545 Line,
4646 Block,
4747}
4848
49#[derive(Copy, Clone, PartialEq, Eq, Hash, Debug, Encodable, Decodable, HashStable_Generic)]
49#[derive(Copy, Clone, PartialEq, Eq, Hash, Debug, Encodable, Decodable, HashStable)]
5050pub enum InvisibleOrigin {
5151 // From the expansion of a metavariable in a declarative macro.
5252 MetaVar(MetaVarKind),
......@@ -69,7 +69,7 @@ impl InvisibleOrigin {
6969}
7070
7171/// Annoyingly similar to `NonterminalKind`, but the slight differences are important.
72#[derive(Debug, Copy, Clone, PartialEq, Eq, Encodable, Decodable, Hash, HashStable_Generic)]
72#[derive(Debug, Copy, Clone, PartialEq, Eq, Encodable, Decodable, Hash, HashStable)]
7373pub enum MetaVarKind {
7474 Item,
7575 Block,
......@@ -125,7 +125,7 @@ impl fmt::Display for MetaVarKind {
125125/// Describes how a sequence of token trees is delimited.
126126/// Cannot use `proc_macro::Delimiter` directly because this
127127/// structure should implement some additional traits.
128#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash, Encodable, Decodable, HashStable_Generic)]
128#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash, Encodable, Decodable, HashStable)]
129129pub enum Delimiter {
130130 /// `( ... )`
131131 Parenthesis,
......@@ -188,7 +188,7 @@ impl Delimiter {
188188// type. This means that float literals like `1f32` are classified by this type
189189// as `Int`. Only upon conversion to `ast::LitKind` will such a literal be
190190// given the `Float` kind.
191#[derive(Clone, Copy, PartialEq, Eq, Hash, Encodable, Decodable, Debug, HashStable_Generic)]
191#[derive(Clone, Copy, PartialEq, Eq, Hash, Encodable, Decodable, Debug, HashStable)]
192192pub enum LitKind {
193193 Bool, // AST only, must never appear in a `Token`
194194 Byte,
......@@ -205,7 +205,7 @@ pub enum LitKind {
205205}
206206
207207/// A literal token.
208#[derive(Clone, Copy, PartialEq, Eq, Hash, Encodable, Decodable, Debug, HashStable_Generic)]
208#[derive(Clone, Copy, PartialEq, Eq, Hash, Encodable, Decodable, Debug, HashStable)]
209209pub struct Lit {
210210 pub kind: LitKind,
211211 pub symbol: Symbol,
......@@ -351,7 +351,7 @@ fn ident_can_begin_type(name: Symbol, span: Span, is_raw: IdentIsRaw) -> bool {
351351 .contains(&name)
352352}
353353
354#[derive(PartialEq, Eq, Encodable, Decodable, Hash, Debug, Copy, Clone, HashStable_Generic)]
354#[derive(PartialEq, Eq, Encodable, Decodable, Hash, Debug, Copy, Clone, HashStable)]
355355pub enum IdentIsRaw {
356356 No,
357357 Yes,
......@@ -378,7 +378,7 @@ impl From<bool> for IdentIsRaw {
378378 }
379379}
380380
381#[derive(Clone, Copy, PartialEq, Eq, Hash, Encodable, Decodable, Debug, HashStable_Generic)]
381#[derive(Clone, Copy, PartialEq, Eq, Hash, Encodable, Decodable, Debug, HashStable)]
382382pub enum TokenKind {
383383 /* Expression-operator symbols. */
384384 /// `=`
......@@ -528,7 +528,7 @@ pub enum TokenKind {
528528 Eof,
529529}
530530
531#[derive(Clone, Copy, PartialEq, Eq, Hash, Encodable, Decodable, Debug, HashStable_Generic)]
531#[derive(Clone, Copy, PartialEq, Eq, Hash, Encodable, Decodable, Debug, HashStable)]
532532pub struct Token {
533533 pub kind: TokenKind,
534534 pub span: Span,
......@@ -1090,7 +1090,7 @@ impl PartialEq<TokenKind> for Token {
10901090 }
10911091}
10921092
1093#[derive(Debug, Copy, Clone, PartialEq, Eq, Encodable, Decodable, Hash, HashStable_Generic)]
1093#[derive(Debug, Copy, Clone, PartialEq, Eq, Encodable, Decodable, Hash, HashStable)]
10941094pub enum NtPatKind {
10951095 // Matches or-patterns. Was written using `pat` in edition 2021 or later.
10961096 PatWithOr,
......@@ -1100,7 +1100,7 @@ pub enum NtPatKind {
11001100 PatParam { inferred: bool },
11011101}
11021102
1103#[derive(Debug, Copy, Clone, PartialEq, Eq, Encodable, Decodable, Hash, HashStable_Generic)]
1103#[derive(Debug, Copy, Clone, PartialEq, Eq, Encodable, Decodable, Hash, HashStable)]
11041104pub enum NtExprKind {
11051105 // Matches expressions using the post-edition 2024. Was written using
11061106 // `expr` in edition 2024 or later.
......@@ -1112,7 +1112,7 @@ pub enum NtExprKind {
11121112}
11131113
11141114/// A macro nonterminal, known in documentation as a fragment specifier.
1115#[derive(Debug, Copy, Clone, PartialEq, Eq, Encodable, Decodable, Hash, HashStable_Generic)]
1115#[derive(Debug, Copy, Clone, PartialEq, Eq, Encodable, Decodable, Hash, HashStable)]
11161116pub enum NonterminalKind {
11171117 Item,
11181118 Block,
compiler/rustc_ast/src/tokenstream.rs+11-14
......@@ -10,11 +10,11 @@ use std::ops::Range;
1010use std::sync::Arc;
1111use std::{cmp, fmt, iter, mem};
1212
13use rustc_data_structures::stable_hasher::{HashStable, StableHasher};
13use rustc_data_structures::stable_hasher::{HashStable, HashStableContext, StableHasher};
1414use rustc_data_structures::sync;
15use rustc_macros::{Decodable, Encodable, HashStable_Generic, Walkable};
15use rustc_macros::{Decodable, Encodable, HashStable, Walkable};
1616use rustc_serialize::{Decodable, Encodable};
17use rustc_span::{DUMMY_SP, HashStableContext, Span, SpanDecoder, SpanEncoder, Symbol, sym};
17use rustc_span::{DUMMY_SP, Span, SpanDecoder, SpanEncoder, Symbol, sym};
1818use thin_vec::ThinVec;
1919
2020use crate::ast::AttrStyle;
......@@ -23,7 +23,7 @@ use crate::token::{self, Delimiter, Token, TokenKind};
2323use crate::{AttrVec, Attribute};
2424
2525/// Part of a `TokenStream`.
26#[derive(Debug, Clone, PartialEq, Eq, Hash, Encodable, Decodable, HashStable_Generic)]
26#[derive(Debug, Clone, PartialEq, Eq, Hash, Encodable, Decodable, HashStable)]
2727pub enum TokenTree {
2828 /// A single token. Should never be `OpenDelim` or `CloseDelim`, because
2929 /// delimiters are implicitly represented by `Delimited`.
......@@ -138,8 +138,8 @@ impl<D: SpanDecoder> Decodable<D> for LazyAttrTokenStream {
138138 }
139139}
140140
141impl<Hcx> HashStable<Hcx> for LazyAttrTokenStream {
142 fn hash_stable(&self, _hcx: &mut Hcx, _hasher: &mut StableHasher) {
141impl HashStable for LazyAttrTokenStream {
142 fn hash_stable<Hcx: HashStableContext>(&self, _hcx: &mut Hcx, _hasher: &mut StableHasher) {
143143 panic!("Attempted to compute stable hash for LazyAttrTokenStream");
144144 }
145145}
......@@ -545,7 +545,7 @@ pub struct AttrsTarget {
545545/// compound token. Used for conversions to `proc_macro::Spacing`. Also used to
546546/// guide pretty-printing, which is where the `JointHidden` value (which isn't
547547/// part of `proc_macro::Spacing`) comes in useful.
548#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, Encodable, Decodable, HashStable_Generic)]
548#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, Encodable, Decodable, HashStable)]
549549pub enum Spacing {
550550 /// The token cannot join with the following token to form a compound
551551 /// token.
......@@ -824,11 +824,8 @@ impl FromIterator<TokenTree> for TokenStream {
824824 }
825825}
826826
827impl<Hcx> HashStable<Hcx> for TokenStream
828where
829 Hcx: HashStableContext,
830{
831 fn hash_stable(&self, hcx: &mut Hcx, hasher: &mut StableHasher) {
827impl HashStable for TokenStream {
828 fn hash_stable<Hcx: HashStableContext>(&self, hcx: &mut Hcx, hasher: &mut StableHasher) {
832829 for sub_tt in self.iter() {
833830 sub_tt.hash_stable(hcx, hasher);
834831 }
......@@ -970,7 +967,7 @@ impl TokenCursor {
970967}
971968
972969#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
973#[derive(Encodable, Decodable, HashStable_Generic, Walkable)]
970#[derive(Encodable, Decodable, HashStable, Walkable)]
974971pub struct DelimSpan {
975972 pub open: Span,
976973 pub close: Span,
......@@ -994,7 +991,7 @@ impl DelimSpan {
994991 }
995992}
996993
997#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash, Encodable, Decodable, HashStable_Generic)]
994#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash, Encodable, Decodable, HashStable)]
998995pub struct DelimSpacing {
999996 pub open: Spacing,
1000997 pub close: Spacing,
compiler/rustc_ast_ir/src/lib.rs+7-25
......@@ -14,17 +14,14 @@
1414use std::fmt;
1515
1616#[cfg(feature = "nightly")]
17use rustc_macros::{Decodable_NoContext, Encodable_NoContext, HashStable_NoContext};
17use rustc_macros::{Decodable_NoContext, Encodable_NoContext, HashStable};
1818#[cfg(feature = "nightly")]
1919use rustc_span::{Symbol, sym};
2020
2121pub mod visit;
2222
2323#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
24#[cfg_attr(
25 feature = "nightly",
26 derive(Encodable_NoContext, Decodable_NoContext, HashStable_NoContext)
27)]
24#[cfg_attr(feature = "nightly", derive(Encodable_NoContext, Decodable_NoContext, HashStable))]
2825pub enum IntTy {
2926 Isize,
3027 I8,
......@@ -100,10 +97,7 @@ impl fmt::Debug for IntTy {
10097}
10198
10299#[derive(Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Copy)]
103#[cfg_attr(
104 feature = "nightly",
105 derive(Encodable_NoContext, Decodable_NoContext, HashStable_NoContext)
106)]
100#[cfg_attr(feature = "nightly", derive(Encodable_NoContext, Decodable_NoContext, HashStable))]
107101pub enum UintTy {
108102 Usize,
109103 U8,
......@@ -179,10 +173,7 @@ impl fmt::Debug for UintTy {
179173}
180174
181175#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
182#[cfg_attr(
183 feature = "nightly",
184 derive(Encodable_NoContext, Decodable_NoContext, HashStable_NoContext)
185)]
176#[cfg_attr(feature = "nightly", derive(Encodable_NoContext, Decodable_NoContext, HashStable))]
186177pub enum FloatTy {
187178 F16,
188179 F32,
......@@ -229,10 +220,7 @@ impl fmt::Debug for FloatTy {
229220/// The movability of a coroutine / closure literal:
230221/// whether a coroutine contains self-references, causing it to be `!Unpin`.
231222#[derive(Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Debug, Copy)]
232#[cfg_attr(
233 feature = "nightly",
234 derive(Encodable_NoContext, Decodable_NoContext, HashStable_NoContext)
235)]
223#[cfg_attr(feature = "nightly", derive(Encodable_NoContext, Decodable_NoContext, HashStable))]
236224pub enum Movability {
237225 /// May contain self-references, `!Unpin`.
238226 Static,
......@@ -241,10 +229,7 @@ pub enum Movability {
241229}
242230
243231#[derive(Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Debug, Copy)]
244#[cfg_attr(
245 feature = "nightly",
246 derive(Encodable_NoContext, Decodable_NoContext, HashStable_NoContext)
247)]
232#[cfg_attr(feature = "nightly", derive(Encodable_NoContext, Decodable_NoContext, HashStable))]
248233pub enum Mutability {
249234 // N.B. Order is deliberate, so that Not < Mut
250235 Not,
......@@ -303,10 +288,7 @@ impl Mutability {
303288}
304289
305290#[derive(Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Debug, Copy)]
306#[cfg_attr(
307 feature = "nightly",
308 derive(Encodable_NoContext, Decodable_NoContext, HashStable_NoContext)
309)]
291#[cfg_attr(feature = "nightly", derive(Encodable_NoContext, Decodable_NoContext, HashStable))]
310292pub enum Pinnedness {
311293 Not,
312294 Pinned,
compiler/rustc_codegen_cranelift/src/driver/aot.rs+3-3
......@@ -14,7 +14,7 @@ use rustc_codegen_ssa::back::write::produce_final_output_artifacts;
1414use rustc_codegen_ssa::base::determine_cgu_reuse;
1515use rustc_codegen_ssa::{CompiledModule, CompiledModules, ModuleKind};
1616use rustc_data_structures::profiling::SelfProfilerRef;
17use rustc_data_structures::stable_hasher::{HashStable, StableHasher};
17use rustc_data_structures::stable_hasher::{HashStable, HashStableContext, StableHasher};
1818use rustc_data_structures::sync::{IntoDynSyncSend, par_map};
1919use rustc_hir::attrs::Linkage as RLinkage;
2020use rustc_middle::dep_graph::{WorkProduct, WorkProductId};
......@@ -45,8 +45,8 @@ enum OngoingModuleCodegen {
4545 Async(JoinHandle<Result<ModuleCodegenResult, String>>),
4646}
4747
48impl<Hcx> HashStable<Hcx> for OngoingModuleCodegen {
49 fn hash_stable(&self, _: &mut Hcx, _: &mut StableHasher) {
48impl HashStable for OngoingModuleCodegen {
49 fn hash_stable<Hcx: HashStableContext>(&self, _: &mut Hcx, _: &mut StableHasher) {
5050 // do nothing
5151 }
5252}
compiler/rustc_codegen_ssa/src/common.rs+3-3
......@@ -98,12 +98,12 @@ pub enum TypeKind {
9898// for now we content ourselves with providing a no-op HashStable
9999// implementation for CGUs.
100100mod temp_stable_hash_impls {
101 use rustc_data_structures::stable_hasher::{HashStable, StableHasher};
101 use rustc_data_structures::stable_hasher::{HashStable, HashStableContext, StableHasher};
102102
103103 use crate::ModuleCodegen;
104104
105 impl<Hcx, M> HashStable<Hcx> for ModuleCodegen<M> {
106 fn hash_stable(&self, _: &mut Hcx, _: &mut StableHasher) {
105 impl<M> HashStable for ModuleCodegen<M> {
106 fn hash_stable<Hcx: HashStableContext>(&self, _: &mut Hcx, _: &mut StableHasher) {
107107 // do nothing
108108 }
109109 }
compiler/rustc_data_structures/src/intern.rs+4-4
......@@ -4,7 +4,7 @@ use std::hash::{Hash, Hasher};
44use std::ops::Deref;
55use std::ptr;
66
7use crate::stable_hasher::{HashStable, StableHasher};
7use crate::stable_hasher::{HashStable, HashStableContext, StableHasher};
88
99mod private {
1010 #[derive(Clone, Copy, Debug)]
......@@ -103,11 +103,11 @@ where
103103 }
104104}
105105
106impl<T, Hcx> HashStable<Hcx> for Interned<'_, T>
106impl<T> HashStable for Interned<'_, T>
107107where
108 T: HashStable<Hcx>,
108 T: HashStable,
109109{
110 fn hash_stable(&self, hcx: &mut Hcx, hasher: &mut StableHasher) {
110 fn hash_stable<Hcx: HashStableContext>(&self, hcx: &mut Hcx, hasher: &mut StableHasher) {
111111 self.0.hash_stable(hcx, hasher);
112112 }
113113}
compiler/rustc_data_structures/src/packed.rs+3-3
......@@ -3,7 +3,7 @@ use std::fmt;
33
44use rustc_serialize::{Decodable, Decoder, Encodable, Encoder};
55
6use crate::stable_hasher::{HashStable, StableHasher};
6use crate::stable_hasher::{HashStable, HashStableContext, StableHasher};
77
88/// A packed 128-bit integer. Useful for reducing the size of structures in
99/// some cases.
......@@ -60,9 +60,9 @@ impl fmt::UpperHex for Pu128 {
6060 }
6161}
6262
63impl<Hcx> HashStable<Hcx> for Pu128 {
63impl HashStable for Pu128 {
6464 #[inline]
65 fn hash_stable(&self, hcx: &mut Hcx, hasher: &mut StableHasher) {
65 fn hash_stable<Hcx: HashStableContext>(&self, hcx: &mut Hcx, hasher: &mut StableHasher) {
6666 { self.0 }.hash_stable(hcx, hasher)
6767 }
6868}
compiler/rustc_data_structures/src/sorted_map.rs+3-3
......@@ -7,7 +7,7 @@ use std::ops::{Bound, Index, IndexMut, RangeBounds};
77
88use rustc_macros::{Decodable_NoContext, Encodable_NoContext};
99
10use crate::stable_hasher::{HashStable, StableHasher, StableOrd};
10use crate::stable_hasher::{HashStable, HashStableContext, StableHasher, StableOrd};
1111
1212mod index_map;
1313
......@@ -347,9 +347,9 @@ impl<K: Ord, V> FromIterator<(K, V)> for SortedMap<K, V> {
347347 }
348348}
349349
350impl<K: HashStable<Hcx> + StableOrd, V: HashStable<Hcx>, Hcx> HashStable<Hcx> for SortedMap<K, V> {
350impl<K: HashStable + StableOrd, V: HashStable> HashStable for SortedMap<K, V> {
351351 #[inline]
352 fn hash_stable(&self, hcx: &mut Hcx, hasher: &mut StableHasher) {
352 fn hash_stable<Hcx: HashStableContext>(&self, hcx: &mut Hcx, hasher: &mut StableHasher) {
353353 self.data.hash_stable(hcx, hasher);
354354 }
355355}
compiler/rustc_data_structures/src/sorted_map/index_map.rs+2-2
......@@ -3,7 +3,7 @@
33use std::hash::{Hash, Hasher};
44
55use rustc_index::{Idx, IndexVec};
6use rustc_macros::HashStable_NoContext;
6use rustc_macros::HashStable;
77
88/// An indexed multi-map that preserves insertion order while permitting both *O*(log *n*) lookup of
99/// an item by key and *O*(1) lookup by index.
......@@ -23,7 +23,7 @@ use rustc_macros::HashStable_NoContext;
2323/// in-place.
2424///
2525/// [`SortedMap`]: super::SortedMap
26#[derive(Clone, Debug, HashStable_NoContext)]
26#[derive(Clone, Debug, HashStable)]
2727pub struct SortedIndexMultiMap<I: Idx, K, V> {
2828 /// The elements of the map in insertion order.
2929 items: IndexVec<I, (K, V)>,
compiler/rustc_data_structures/src/stable_hasher.rs+145-106
......@@ -15,7 +15,38 @@ pub use rustc_stable_hash::{
1515 FromStableHash, SipHasher128Hash as StableHasherHash, StableSipHasher128 as StableHasher,
1616};
1717
18/// Something that implements `HashStable<Hcx>` can be hashed in a way that is
18/// This trait lets `HashStable` and `derive(HashStable)` be used in
19/// this crate (and other crates upstream of `rustc_middle`), while leaving
20/// certain operations to be defined in `rustc_middle` where more things are
21/// visible.
22pub trait HashStableContext {
23 /// The main event: stable hashing of a span.
24 fn span_hash_stable(&mut self, span: RawSpan, hasher: &mut StableHasher);
25
26 /// Compute a `DefPathHash`.
27 fn def_path_hash(&self, def_id: RawDefId) -> RawDefPathHash;
28
29 /// Get the hashing controls.
30 fn hashing_controls(&self) -> HashingControls;
31
32 /// Assert that the provided `HashStableContext` is configured with the default
33 /// `HashingControls`. We should always have bailed out before getting to here with a
34 fn assert_default_hashing_controls(&self, msg: &str);
35}
36
37// A type used to work around `Span` not being visible in this crate. It is the same layout as
38// `Span`.
39pub struct RawSpan(pub u32, pub u16, pub u16);
40
41// A type used to work around `DefId` not being visible in this crate. It is the same size as
42// `DefId`.
43pub struct RawDefId(pub u32, pub u32);
44
45// A type used to work around `DefPathHash` not being visible in this crate. It is the same size as
46// `DefPathHash`.
47pub struct RawDefPathHash(pub [u8; 16]);
48
49/// Something that implements `HashStable` can be hashed in a way that is
1950/// stable across multiple compilation sessions.
2051///
2152/// Note that `HashStable` imposes rather more strict requirements than usual
......@@ -41,16 +72,16 @@ pub use rustc_stable_hash::{
4172/// - `hash_stable()` must be independent of the host architecture. The
4273/// `StableHasher` takes care of endianness and `isize`/`usize` platform
4374/// differences.
44pub trait HashStable<Hcx> {
45 fn hash_stable(&self, hcx: &mut Hcx, hasher: &mut StableHasher);
75pub trait HashStable {
76 fn hash_stable<Hcx: HashStableContext>(&self, hcx: &mut Hcx, hasher: &mut StableHasher);
4677}
4778
4879/// Implement this for types that can be turned into stable keys like, for
4980/// example, for DefId that can be converted to a DefPathHash. This is used for
5081/// bringing maps into a predictable order before hashing them.
51pub trait ToStableHashKey<Hcx> {
52 type KeyType: Ord + Sized + HashStable<Hcx>;
53 fn to_stable_hash_key(&self, hcx: &mut Hcx) -> Self::KeyType;
82pub trait ToStableHashKey {
83 type KeyType: Ord + Sized + HashStable;
84 fn to_stable_hash_key<Hcx: HashStableContext>(&self, hcx: &mut Hcx) -> Self::KeyType;
5485}
5586
5687/// Trait for marking a type as having a sort order that is
......@@ -133,12 +164,16 @@ impl<T: StableOrd> StableCompare for T {
133164/// for examples). Therefore this macro is not exported and should only be used in the limited cases
134165/// here in this module.
135166///
136/// Use `#[derive(HashStable_Generic)]` instead.
167/// Use `#[derive(HashStable)]` instead.
137168macro_rules! impl_stable_traits_for_trivial_type {
138169 ($t:ty) => {
139 impl<Hcx> $crate::stable_hasher::HashStable<Hcx> for $t {
170 impl $crate::stable_hasher::HashStable for $t {
140171 #[inline]
141 fn hash_stable(&self, _: &mut Hcx, hasher: &mut $crate::stable_hasher::StableHasher) {
172 fn hash_stable<Hcx>(
173 &self,
174 _: &mut Hcx,
175 hasher: &mut $crate::stable_hasher::StableHasher,
176 ) {
142177 ::std::hash::Hash::hash(self, hasher);
143178 }
144179 }
......@@ -177,9 +212,9 @@ impl_stable_traits_for_trivial_type!(Hash64);
177212
178213// We need a custom impl as the default hash function will only hash half the bits. For stable
179214// hashing we want to hash the full 128-bit hash.
180impl<Hcx> HashStable<Hcx> for Hash128 {
215impl HashStable for Hash128 {
181216 #[inline]
182 fn hash_stable(&self, _: &mut Hcx, hasher: &mut StableHasher) {
217 fn hash_stable<Hcx>(&self, _: &mut Hcx, hasher: &mut StableHasher) {
183218 self.as_u128().hash(hasher);
184219 }
185220}
......@@ -192,61 +227,61 @@ impl StableOrd for Hash128 {
192227 const THIS_IMPLEMENTATION_HAS_BEEN_TRIPLE_CHECKED: () = ();
193228}
194229
195impl<Hcx> HashStable<Hcx> for ! {
196 fn hash_stable(&self, _hcx: &mut Hcx, _hasher: &mut StableHasher) {
230impl HashStable for ! {
231 fn hash_stable<Hcx>(&self, _hcx: &mut Hcx, _hasher: &mut StableHasher) {
197232 unreachable!()
198233 }
199234}
200235
201impl<Hcx, T> HashStable<Hcx> for PhantomData<T> {
202 fn hash_stable(&self, _hcx: &mut Hcx, _hasher: &mut StableHasher) {}
236impl<T> HashStable for PhantomData<T> {
237 fn hash_stable<Hcx>(&self, _hcx: &mut Hcx, _hasher: &mut StableHasher) {}
203238}
204239
205impl<Hcx> HashStable<Hcx> for NonZero<u32> {
240impl HashStable for NonZero<u32> {
206241 #[inline]
207 fn hash_stable(&self, hcx: &mut Hcx, hasher: &mut StableHasher) {
242 fn hash_stable<Hcx: HashStableContext>(&self, hcx: &mut Hcx, hasher: &mut StableHasher) {
208243 self.get().hash_stable(hcx, hasher)
209244 }
210245}
211246
212impl<Hcx> HashStable<Hcx> for NonZero<usize> {
247impl HashStable for NonZero<usize> {
213248 #[inline]
214 fn hash_stable(&self, hcx: &mut Hcx, hasher: &mut StableHasher) {
249 fn hash_stable<Hcx: HashStableContext>(&self, hcx: &mut Hcx, hasher: &mut StableHasher) {
215250 self.get().hash_stable(hcx, hasher)
216251 }
217252}
218253
219impl<Hcx> HashStable<Hcx> for f32 {
220 fn hash_stable(&self, hcx: &mut Hcx, hasher: &mut StableHasher) {
254impl HashStable for f32 {
255 fn hash_stable<Hcx: HashStableContext>(&self, hcx: &mut Hcx, hasher: &mut StableHasher) {
221256 let val: u32 = self.to_bits();
222257 val.hash_stable(hcx, hasher);
223258 }
224259}
225260
226impl<Hcx> HashStable<Hcx> for f64 {
227 fn hash_stable(&self, hcx: &mut Hcx, hasher: &mut StableHasher) {
261impl HashStable for f64 {
262 fn hash_stable<Hcx: HashStableContext>(&self, hcx: &mut Hcx, hasher: &mut StableHasher) {
228263 let val: u64 = self.to_bits();
229264 val.hash_stable(hcx, hasher);
230265 }
231266}
232267
233impl<Hcx> HashStable<Hcx> for ::std::cmp::Ordering {
268impl HashStable for ::std::cmp::Ordering {
234269 #[inline]
235 fn hash_stable(&self, hcx: &mut Hcx, hasher: &mut StableHasher) {
270 fn hash_stable<Hcx: HashStableContext>(&self, hcx: &mut Hcx, hasher: &mut StableHasher) {
236271 (*self as i8).hash_stable(hcx, hasher);
237272 }
238273}
239274
240impl<T1: HashStable<Hcx>, Hcx> HashStable<Hcx> for (T1,) {
275impl<T1: HashStable> HashStable for (T1,) {
241276 #[inline]
242 fn hash_stable(&self, hcx: &mut Hcx, hasher: &mut StableHasher) {
277 fn hash_stable<Hcx: HashStableContext>(&self, hcx: &mut Hcx, hasher: &mut StableHasher) {
243278 let (ref _0,) = *self;
244279 _0.hash_stable(hcx, hasher);
245280 }
246281}
247282
248impl<T1: HashStable<Hcx>, T2: HashStable<Hcx>, Hcx> HashStable<Hcx> for (T1, T2) {
249 fn hash_stable(&self, hcx: &mut Hcx, hasher: &mut StableHasher) {
283impl<T1: HashStable, T2: HashStable> HashStable for (T1, T2) {
284 fn hash_stable<Hcx: HashStableContext>(&self, hcx: &mut Hcx, hasher: &mut StableHasher) {
250285 let (ref _0, ref _1) = *self;
251286 _0.hash_stable(hcx, hasher);
252287 _1.hash_stable(hcx, hasher);
......@@ -261,13 +296,13 @@ impl<T1: StableOrd, T2: StableOrd> StableOrd for (T1, T2) {
261296 const THIS_IMPLEMENTATION_HAS_BEEN_TRIPLE_CHECKED: () = ();
262297}
263298
264impl<T1, T2, T3, Hcx> HashStable<Hcx> for (T1, T2, T3)
299impl<T1, T2, T3> HashStable for (T1, T2, T3)
265300where
266 T1: HashStable<Hcx>,
267 T2: HashStable<Hcx>,
268 T3: HashStable<Hcx>,
301 T1: HashStable,
302 T2: HashStable,
303 T3: HashStable,
269304{
270 fn hash_stable(&self, hcx: &mut Hcx, hasher: &mut StableHasher) {
305 fn hash_stable<Hcx: HashStableContext>(&self, hcx: &mut Hcx, hasher: &mut StableHasher) {
271306 let (ref _0, ref _1, ref _2) = *self;
272307 _0.hash_stable(hcx, hasher);
273308 _1.hash_stable(hcx, hasher);
......@@ -284,14 +319,14 @@ impl<T1: StableOrd, T2: StableOrd, T3: StableOrd> StableOrd for (T1, T2, T3) {
284319 const THIS_IMPLEMENTATION_HAS_BEEN_TRIPLE_CHECKED: () = ();
285320}
286321
287impl<T1, T2, T3, T4, Hcx> HashStable<Hcx> for (T1, T2, T3, T4)
322impl<T1, T2, T3, T4> HashStable for (T1, T2, T3, T4)
288323where
289 T1: HashStable<Hcx>,
290 T2: HashStable<Hcx>,
291 T3: HashStable<Hcx>,
292 T4: HashStable<Hcx>,
324 T1: HashStable,
325 T2: HashStable,
326 T3: HashStable,
327 T4: HashStable,
293328{
294 fn hash_stable(&self, hcx: &mut Hcx, hasher: &mut StableHasher) {
329 fn hash_stable<Hcx: HashStableContext>(&self, hcx: &mut Hcx, hasher: &mut StableHasher) {
295330 let (ref _0, ref _1, ref _2, ref _3) = *self;
296331 _0.hash_stable(hcx, hasher);
297332 _1.hash_stable(hcx, hasher);
......@@ -311,8 +346,12 @@ impl<T1: StableOrd, T2: StableOrd, T3: StableOrd, T4: StableOrd> StableOrd for (
311346 const THIS_IMPLEMENTATION_HAS_BEEN_TRIPLE_CHECKED: () = ();
312347}
313348
314impl<T: HashStable<Hcx>, Hcx> HashStable<Hcx> for [T] {
315 default fn hash_stable(&self, hcx: &mut Hcx, hasher: &mut StableHasher) {
349impl<T: HashStable> HashStable for [T] {
350 default fn hash_stable<Hcx: HashStableContext>(
351 &self,
352 hcx: &mut Hcx,
353 hasher: &mut StableHasher,
354 ) {
316355 self.len().hash_stable(hcx, hasher);
317356 for item in self {
318357 item.hash_stable(hcx, hasher);
......@@ -320,28 +359,28 @@ impl<T: HashStable<Hcx>, Hcx> HashStable<Hcx> for [T] {
320359 }
321360}
322361
323impl<Hcx> HashStable<Hcx> for [u8] {
324 fn hash_stable(&self, hcx: &mut Hcx, hasher: &mut StableHasher) {
362impl HashStable for [u8] {
363 fn hash_stable<Hcx: HashStableContext>(&self, hcx: &mut Hcx, hasher: &mut StableHasher) {
325364 self.len().hash_stable(hcx, hasher);
326365 hasher.write(self);
327366 }
328367}
329368
330impl<T: HashStable<Hcx>, Hcx> HashStable<Hcx> for Vec<T> {
369impl<T: HashStable> HashStable for Vec<T> {
331370 #[inline]
332 fn hash_stable(&self, hcx: &mut Hcx, hasher: &mut StableHasher) {
371 fn hash_stable<Hcx: HashStableContext>(&self, hcx: &mut Hcx, hasher: &mut StableHasher) {
333372 self[..].hash_stable(hcx, hasher);
334373 }
335374}
336375
337impl<K, V, R, Hcx> HashStable<Hcx> for indexmap::IndexMap<K, V, R>
376impl<K, V, R> HashStable for indexmap::IndexMap<K, V, R>
338377where
339 K: HashStable<Hcx> + Eq + Hash,
340 V: HashStable<Hcx>,
378 K: HashStable + Eq + Hash,
379 V: HashStable,
341380 R: BuildHasher,
342381{
343382 #[inline]
344 fn hash_stable(&self, hcx: &mut Hcx, hasher: &mut StableHasher) {
383 fn hash_stable<Hcx: HashStableContext>(&self, hcx: &mut Hcx, hasher: &mut StableHasher) {
345384 self.len().hash_stable(hcx, hasher);
346385 for kv in self {
347386 kv.hash_stable(hcx, hasher);
......@@ -349,13 +388,13 @@ where
349388 }
350389}
351390
352impl<K, R, Hcx> HashStable<Hcx> for indexmap::IndexSet<K, R>
391impl<K, R> HashStable for indexmap::IndexSet<K, R>
353392where
354 K: HashStable<Hcx> + Eq + Hash,
393 K: HashStable + Eq + Hash,
355394 R: BuildHasher,
356395{
357396 #[inline]
358 fn hash_stable(&self, hcx: &mut Hcx, hasher: &mut StableHasher) {
397 fn hash_stable<Hcx: HashStableContext>(&self, hcx: &mut Hcx, hasher: &mut StableHasher) {
359398 self.len().hash_stable(hcx, hasher);
360399 for key in self {
361400 key.hash_stable(hcx, hasher);
......@@ -363,40 +402,40 @@ where
363402 }
364403}
365404
366impl<A, const N: usize, Hcx> HashStable<Hcx> for SmallVec<[A; N]>
405impl<A, const N: usize> HashStable for SmallVec<[A; N]>
367406where
368 A: HashStable<Hcx>,
407 A: HashStable,
369408{
370409 #[inline]
371 fn hash_stable(&self, hcx: &mut Hcx, hasher: &mut StableHasher) {
410 fn hash_stable<Hcx: HashStableContext>(&self, hcx: &mut Hcx, hasher: &mut StableHasher) {
372411 self[..].hash_stable(hcx, hasher);
373412 }
374413}
375414
376impl<T: ?Sized + HashStable<Hcx>, Hcx> HashStable<Hcx> for Box<T> {
415impl<T: ?Sized + HashStable> HashStable for Box<T> {
377416 #[inline]
378 fn hash_stable(&self, hcx: &mut Hcx, hasher: &mut StableHasher) {
417 fn hash_stable<Hcx: HashStableContext>(&self, hcx: &mut Hcx, hasher: &mut StableHasher) {
379418 (**self).hash_stable(hcx, hasher);
380419 }
381420}
382421
383impl<T: ?Sized + HashStable<Hcx>, Hcx> HashStable<Hcx> for ::std::rc::Rc<T> {
422impl<T: ?Sized + HashStable> HashStable for ::std::rc::Rc<T> {
384423 #[inline]
385 fn hash_stable(&self, hcx: &mut Hcx, hasher: &mut StableHasher) {
424 fn hash_stable<Hcx: HashStableContext>(&self, hcx: &mut Hcx, hasher: &mut StableHasher) {
386425 (**self).hash_stable(hcx, hasher);
387426 }
388427}
389428
390impl<T: ?Sized + HashStable<Hcx>, Hcx> HashStable<Hcx> for ::std::sync::Arc<T> {
429impl<T: ?Sized + HashStable> HashStable for ::std::sync::Arc<T> {
391430 #[inline]
392 fn hash_stable(&self, hcx: &mut Hcx, hasher: &mut StableHasher) {
431 fn hash_stable<Hcx: HashStableContext>(&self, hcx: &mut Hcx, hasher: &mut StableHasher) {
393432 (**self).hash_stable(hcx, hasher);
394433 }
395434}
396435
397impl<Hcx> HashStable<Hcx> for str {
436impl HashStable for str {
398437 #[inline]
399 fn hash_stable(&self, hcx: &mut Hcx, hasher: &mut StableHasher) {
438 fn hash_stable<Hcx: HashStableContext>(&self, hcx: &mut Hcx, hasher: &mut StableHasher) {
400439 self.as_bytes().hash_stable(hcx, hasher);
401440 }
402441}
......@@ -409,9 +448,9 @@ impl StableOrd for &str {
409448 const THIS_IMPLEMENTATION_HAS_BEEN_TRIPLE_CHECKED: () = ();
410449}
411450
412impl<Hcx> HashStable<Hcx> for String {
451impl HashStable for String {
413452 #[inline]
414 fn hash_stable(&self, hcx: &mut Hcx, hasher: &mut StableHasher) {
453 fn hash_stable<Hcx: HashStableContext>(&self, hcx: &mut Hcx, hasher: &mut StableHasher) {
415454 self[..].hash_stable(hcx, hasher);
416455 }
417456}
......@@ -424,25 +463,25 @@ impl StableOrd for String {
424463 const THIS_IMPLEMENTATION_HAS_BEEN_TRIPLE_CHECKED: () = ();
425464}
426465
427impl<Hcx> ToStableHashKey<Hcx> for String {
466impl ToStableHashKey for String {
428467 type KeyType = String;
429468 #[inline]
430 fn to_stable_hash_key(&self, _: &mut Hcx) -> Self::KeyType {
469 fn to_stable_hash_key<Hcx>(&self, _: &mut Hcx) -> Self::KeyType {
431470 self.clone()
432471 }
433472}
434473
435impl<Hcx, T1: ToStableHashKey<Hcx>, T2: ToStableHashKey<Hcx>> ToStableHashKey<Hcx> for (T1, T2) {
474impl<T1: ToStableHashKey, T2: ToStableHashKey> ToStableHashKey for (T1, T2) {
436475 type KeyType = (T1::KeyType, T2::KeyType);
437476 #[inline]
438 fn to_stable_hash_key(&self, hcx: &mut Hcx) -> Self::KeyType {
477 fn to_stable_hash_key<Hcx: HashStableContext>(&self, hcx: &mut Hcx) -> Self::KeyType {
439478 (self.0.to_stable_hash_key(hcx), self.1.to_stable_hash_key(hcx))
440479 }
441480}
442481
443impl<Hcx> HashStable<Hcx> for bool {
482impl HashStable for bool {
444483 #[inline]
445 fn hash_stable(&self, hcx: &mut Hcx, hasher: &mut StableHasher) {
484 fn hash_stable<Hcx: HashStableContext>(&self, hcx: &mut Hcx, hasher: &mut StableHasher) {
446485 (if *self { 1u8 } else { 0u8 }).hash_stable(hcx, hasher);
447486 }
448487}
......@@ -454,12 +493,12 @@ impl StableOrd for bool {
454493 const THIS_IMPLEMENTATION_HAS_BEEN_TRIPLE_CHECKED: () = ();
455494}
456495
457impl<T, Hcx> HashStable<Hcx> for Option<T>
496impl<T> HashStable for Option<T>
458497where
459 T: HashStable<Hcx>,
498 T: HashStable,
460499{
461500 #[inline]
462 fn hash_stable(&self, hcx: &mut Hcx, hasher: &mut StableHasher) {
501 fn hash_stable<Hcx: HashStableContext>(&self, hcx: &mut Hcx, hasher: &mut StableHasher) {
463502 if let Some(ref value) = *self {
464503 1u8.hash_stable(hcx, hasher);
465504 value.hash_stable(hcx, hasher);
......@@ -476,13 +515,13 @@ impl<T: StableOrd> StableOrd for Option<T> {
476515 const THIS_IMPLEMENTATION_HAS_BEEN_TRIPLE_CHECKED: () = ();
477516}
478517
479impl<T1, T2, Hcx> HashStable<Hcx> for Result<T1, T2>
518impl<T1, T2> HashStable for Result<T1, T2>
480519where
481 T1: HashStable<Hcx>,
482 T2: HashStable<Hcx>,
520 T1: HashStable,
521 T2: HashStable,
483522{
484523 #[inline]
485 fn hash_stable(&self, hcx: &mut Hcx, hasher: &mut StableHasher) {
524 fn hash_stable<Hcx: HashStableContext>(&self, hcx: &mut Hcx, hasher: &mut StableHasher) {
486525 mem::discriminant(self).hash_stable(hcx, hasher);
487526 match *self {
488527 Ok(ref x) => x.hash_stable(hcx, hasher),
......@@ -491,39 +530,39 @@ where
491530 }
492531}
493532
494impl<'a, T, Hcx> HashStable<Hcx> for &'a T
533impl<'a, T> HashStable for &'a T
495534where
496 T: HashStable<Hcx> + ?Sized,
535 T: HashStable + ?Sized,
497536{
498537 #[inline]
499 fn hash_stable(&self, hcx: &mut Hcx, hasher: &mut StableHasher) {
538 fn hash_stable<Hcx: HashStableContext>(&self, hcx: &mut Hcx, hasher: &mut StableHasher) {
500539 (**self).hash_stable(hcx, hasher);
501540 }
502541}
503542
504impl<T, Hcx> HashStable<Hcx> for ::std::mem::Discriminant<T> {
543impl<T> HashStable for ::std::mem::Discriminant<T> {
505544 #[inline]
506 fn hash_stable(&self, _: &mut Hcx, hasher: &mut StableHasher) {
545 fn hash_stable<Hcx: HashStableContext>(&self, _: &mut Hcx, hasher: &mut StableHasher) {
507546 ::std::hash::Hash::hash(self, hasher);
508547 }
509548}
510549
511impl<T, Hcx> HashStable<Hcx> for ::std::ops::RangeInclusive<T>
550impl<T> HashStable for ::std::ops::RangeInclusive<T>
512551where
513 T: HashStable<Hcx>,
552 T: HashStable,
514553{
515554 #[inline]
516 fn hash_stable(&self, hcx: &mut Hcx, hasher: &mut StableHasher) {
555 fn hash_stable<Hcx: HashStableContext>(&self, hcx: &mut Hcx, hasher: &mut StableHasher) {
517556 self.start().hash_stable(hcx, hasher);
518557 self.end().hash_stable(hcx, hasher);
519558 }
520559}
521560
522impl<I: Idx, T, Hcx> HashStable<Hcx> for IndexSlice<I, T>
561impl<I: Idx, T> HashStable for IndexSlice<I, T>
523562where
524 T: HashStable<Hcx>,
563 T: HashStable,
525564{
526 fn hash_stable(&self, hcx: &mut Hcx, hasher: &mut StableHasher) {
565 fn hash_stable<Hcx: HashStableContext>(&self, hcx: &mut Hcx, hasher: &mut StableHasher) {
527566 self.len().hash_stable(hcx, hasher);
528567 for v in &self.raw {
529568 v.hash_stable(hcx, hasher);
......@@ -531,11 +570,11 @@ where
531570 }
532571}
533572
534impl<I: Idx, T, Hcx> HashStable<Hcx> for IndexVec<I, T>
573impl<I: Idx, T> HashStable for IndexVec<I, T>
535574where
536 T: HashStable<Hcx>,
575 T: HashStable,
537576{
538 fn hash_stable(&self, hcx: &mut Hcx, hasher: &mut StableHasher) {
577 fn hash_stable<Hcx: HashStableContext>(&self, hcx: &mut Hcx, hasher: &mut StableHasher) {
539578 self.len().hash_stable(hcx, hasher);
540579 for v in &self.raw {
541580 v.hash_stable(hcx, hasher);
......@@ -543,14 +582,14 @@ where
543582 }
544583}
545584
546impl<I: Idx, Hcx> HashStable<Hcx> for DenseBitSet<I> {
547 fn hash_stable(&self, _hcx: &mut Hcx, hasher: &mut StableHasher) {
585impl<I: Idx> HashStable for DenseBitSet<I> {
586 fn hash_stable<Hcx: HashStableContext>(&self, _hcx: &mut Hcx, hasher: &mut StableHasher) {
548587 ::std::hash::Hash::hash(self, hasher);
549588 }
550589}
551590
552impl<R: Idx, C: Idx, Hcx> HashStable<Hcx> for bit_set::BitMatrix<R, C> {
553 fn hash_stable(&self, _hcx: &mut Hcx, hasher: &mut StableHasher) {
591impl<R: Idx, C: Idx> HashStable for bit_set::BitMatrix<R, C> {
592 fn hash_stable<Hcx: HashStableContext>(&self, _hcx: &mut Hcx, hasher: &mut StableHasher) {
554593 ::std::hash::Hash::hash(self, hasher);
555594 }
556595}
......@@ -563,15 +602,15 @@ impl_stable_traits_for_trivial_type!(::std::path::PathBuf);
563602// It is not safe to implement HashStable for HashSet, HashMap or any other collection type
564603// with unstable but observable iteration order.
565604// See https://github.com/rust-lang/compiler-team/issues/533 for further information.
566impl<V, Hcx> !HashStable<Hcx> for std::collections::HashSet<V> {}
567impl<K, V, Hcx> !HashStable<Hcx> for std::collections::HashMap<K, V> {}
605impl<V> !HashStable for std::collections::HashSet<V> {}
606impl<K, V> !HashStable for std::collections::HashMap<K, V> {}
568607
569impl<K, V, Hcx> HashStable<Hcx> for ::std::collections::BTreeMap<K, V>
608impl<K, V> HashStable for ::std::collections::BTreeMap<K, V>
570609where
571 K: HashStable<Hcx> + StableOrd,
572 V: HashStable<Hcx>,
610 K: HashStable + StableOrd,
611 V: HashStable,
573612{
574 fn hash_stable(&self, hcx: &mut Hcx, hasher: &mut StableHasher) {
613 fn hash_stable<Hcx: HashStableContext>(&self, hcx: &mut Hcx, hasher: &mut StableHasher) {
575614 self.len().hash_stable(hcx, hasher);
576615 for entry in self.iter() {
577616 entry.hash_stable(hcx, hasher);
......@@ -579,11 +618,11 @@ where
579618 }
580619}
581620
582impl<K, Hcx> HashStable<Hcx> for ::std::collections::BTreeSet<K>
621impl<K> HashStable for ::std::collections::BTreeSet<K>
583622where
584 K: HashStable<Hcx> + StableOrd,
623 K: HashStable + StableOrd,
585624{
586 fn hash_stable(&self, hcx: &mut Hcx, hasher: &mut StableHasher) {
625 fn hash_stable<Hcx: HashStableContext>(&self, hcx: &mut Hcx, hasher: &mut StableHasher) {
587626 self.len().hash_stable(hcx, hasher);
588627 for entry in self.iter() {
589628 entry.hash_stable(hcx, hasher);
compiler/rustc_data_structures/src/stable_hasher/tests.rs+24-5
......@@ -7,10 +7,25 @@ use super::*;
77// ways). The expected values depend on the hashing algorithm used, so they
88// need to be updated whenever StableHasher changes its hashing algorithm.
99
10fn hash<T: HashStable<()>>(t: &T) -> Hash128 {
10impl HashStableContext for () {
11 fn span_hash_stable(&mut self, _: RawSpan, _: &mut StableHasher) {
12 panic!();
13 }
14 fn def_path_hash(&self, _: RawDefId) -> RawDefPathHash {
15 panic!();
16 }
17 fn hashing_controls(&self) -> HashingControls {
18 panic!();
19 }
20 fn assert_default_hashing_controls(&self, _: &str) {
21 panic!();
22 }
23}
24
25fn hash<T: HashStable>(t: &T) -> Hash128 {
1126 let mut h = StableHasher::new();
12 let ctx = &mut ();
13 t.hash_stable(ctx, &mut h);
27 let hcx = &mut ();
28 t.hash_stable(hcx, &mut h);
1429 h.finish()
1530}
1631
......@@ -44,8 +59,12 @@ fn test_attribute_permutation() {
4459 b: $ty,
4560 }
4661
47 impl<Hcx> HashStable<Hcx> for Foo {
48 fn hash_stable(&self, hcx: &mut Hcx, hasher: &mut StableHasher) {
62 impl HashStable for Foo {
63 fn hash_stable<Hcx: HashStableContext>(
64 &self,
65 hcx: &mut Hcx,
66 hasher: &mut StableHasher,
67 ) {
4968 self.a.hash_stable(hcx, hasher);
5069 self.b.hash_stable(hcx, hasher);
5170 }
compiler/rustc_data_structures/src/steal.rs+3-3
......@@ -1,4 +1,4 @@
1use crate::stable_hasher::{HashStable, StableHasher};
1use crate::stable_hasher::{HashStable, HashStableContext, StableHasher};
22use crate::sync::{MappedReadGuard, MappedWriteGuard, ReadGuard, RwLock, WriteGuard};
33
44/// The `Steal` struct is intended to used as the value for a query.
......@@ -71,8 +71,8 @@ impl<T> Steal<T> {
7171 }
7272}
7373
74impl<Hcx, T: HashStable<Hcx>> HashStable<Hcx> for Steal<T> {
75 fn hash_stable(&self, hcx: &mut Hcx, hasher: &mut StableHasher) {
74impl<T: HashStable> HashStable for Steal<T> {
75 fn hash_stable<Hcx: HashStableContext>(&self, hcx: &mut Hcx, hasher: &mut StableHasher) {
7676 self.borrow().hash_stable(hcx, hasher);
7777 }
7878}
compiler/rustc_data_structures/src/svh.rs+2-2
......@@ -7,7 +7,7 @@
77
88use std::fmt;
99
10use rustc_macros::{Decodable_NoContext, Encodable_NoContext, HashStable_NoContext};
10use rustc_macros::{Decodable_NoContext, Encodable_NoContext, HashStable};
1111
1212use crate::fingerprint::Fingerprint;
1313
......@@ -20,7 +20,7 @@ use crate::fingerprint::Fingerprint;
2020 Encodable_NoContext,
2121 Decodable_NoContext,
2222 Hash,
23 HashStable_NoContext
23 HashStable
2424)]
2525pub struct Svh {
2626 hash: Fingerprint,
compiler/rustc_data_structures/src/tagged_ptr.rs+5-5
......@@ -12,7 +12,7 @@ use std::ops::Deref;
1212use std::ptr::NonNull;
1313
1414use crate::aligned::Aligned;
15use crate::stable_hasher::{HashStable, StableHasher};
15use crate::stable_hasher::{HashStable, HashStableContext, StableHasher};
1616
1717/// This describes tags that the [`TaggedRef`] struct can hold.
1818///
......@@ -259,12 +259,12 @@ impl<P, T: Tag> Hash for TaggedRef<'_, P, T> {
259259 }
260260}
261261
262impl<'a, P, T, Hcx> HashStable<Hcx> for TaggedRef<'a, P, T>
262impl<'a, P, T> HashStable for TaggedRef<'a, P, T>
263263where
264 P: HashStable<Hcx> + Aligned + ?Sized,
265 T: Tag + HashStable<Hcx>,
264 P: HashStable + Aligned + ?Sized,
265 T: Tag + HashStable,
266266{
267 fn hash_stable(&self, hcx: &mut Hcx, hasher: &mut StableHasher) {
267 fn hash_stable<Hcx: HashStableContext>(&self, hcx: &mut Hcx, hasher: &mut StableHasher) {
268268 self.pointer().hash_stable(hcx, hasher);
269269 self.tag().hash_stable(hcx, hasher);
270270 }
compiler/rustc_data_structures/src/tagged_ptr/tests.rs+6-2
......@@ -32,8 +32,12 @@ unsafe impl Tag for Tag2 {
3232 }
3333}
3434
35impl<Hcx> crate::stable_hasher::HashStable<Hcx> for Tag2 {
36 fn hash_stable(&self, hcx: &mut Hcx, hasher: &mut crate::stable_hasher::StableHasher) {
35impl HashStable for Tag2 {
36 fn hash_stable<Hcx: HashStableContext>(
37 &self,
38 hcx: &mut Hcx,
39 hasher: &mut crate::stable_hasher::StableHasher,
40 ) {
3741 (*self as u8).hash_stable(hcx, hasher);
3842 }
3943}
compiler/rustc_data_structures/src/unord.rs+27-18
......@@ -12,7 +12,9 @@ use rustc_macros::{Decodable_NoContext, Encodable_NoContext};
1212
1313use crate::fingerprint::Fingerprint;
1414use crate::fx::{FxBuildHasher, FxHashMap, FxHashSet};
15use crate::stable_hasher::{HashStable, StableCompare, StableHasher, ToStableHashKey};
15use crate::stable_hasher::{
16 HashStable, HashStableContext, StableCompare, StableHasher, ToStableHashKey,
17};
1618
1719/// `UnordItems` is the order-less version of `Iterator`. It only contains methods
1820/// that don't (easily) expose an ordering of the underlying items.
......@@ -143,9 +145,9 @@ impl<'a, T: Copy + 'a, I: Iterator<Item = &'a T>> UnordItems<&'a T, I> {
143145
144146impl<T, I: Iterator<Item = T>> UnordItems<T, I> {
145147 #[inline]
146 pub fn into_sorted<Hcx>(self, hcx: &mut Hcx) -> Vec<T>
148 pub fn into_sorted<Hcx: HashStableContext>(self, hcx: &mut Hcx) -> Vec<T>
147149 where
148 T: ToStableHashKey<Hcx>,
150 T: ToStableHashKey,
149151 {
150152 self.collect_sorted(hcx, true)
151153 }
......@@ -170,7 +172,8 @@ impl<T, I: Iterator<Item = T>> UnordItems<T, I> {
170172 #[inline]
171173 pub fn collect_sorted<Hcx, C>(self, hcx: &mut Hcx, cache_sort_key: bool) -> C
172174 where
173 T: ToStableHashKey<Hcx>,
175 Hcx: HashStableContext,
176 T: ToStableHashKey,
174177 C: FromIterator<T> + BorrowMut<[T]>,
175178 {
176179 let mut items: C = self.0.collect();
......@@ -317,7 +320,8 @@ impl<V: Eq + Hash> UnordSet<V> {
317320 #[inline]
318321 pub fn to_sorted<Hcx>(&self, hcx: &mut Hcx, cache_sort_key: bool) -> Vec<&V>
319322 where
320 V: ToStableHashKey<Hcx>,
323 Hcx: HashStableContext,
324 V: ToStableHashKey,
321325 {
322326 to_sorted_vec(hcx, self.inner.iter(), cache_sort_key, |&x| x)
323327 }
......@@ -359,7 +363,8 @@ impl<V: Eq + Hash> UnordSet<V> {
359363 #[inline]
360364 pub fn into_sorted<Hcx>(self, hcx: &mut Hcx, cache_sort_key: bool) -> Vec<V>
361365 where
362 V: ToStableHashKey<Hcx>,
366 Hcx: HashStableContext,
367 V: ToStableHashKey,
363368 {
364369 to_sorted_vec(hcx, self.inner.into_iter(), cache_sort_key, |x| x)
365370 }
......@@ -415,9 +420,9 @@ impl<V: Hash + Eq, I: Iterator<Item = V>> From<UnordItems<V, I>> for UnordSet<V>
415420 }
416421}
417422
418impl<Hcx, V: Hash + Eq + HashStable<Hcx>> HashStable<Hcx> for UnordSet<V> {
423impl<V: Hash + Eq + HashStable> HashStable for UnordSet<V> {
419424 #[inline]
420 fn hash_stable(&self, hcx: &mut Hcx, hasher: &mut StableHasher) {
425 fn hash_stable<Hcx: HashStableContext>(&self, hcx: &mut Hcx, hasher: &mut StableHasher) {
421426 hash_iter_order_independent(self.inner.iter(), hcx, hasher);
422427 }
423428}
......@@ -557,7 +562,8 @@ impl<K: Eq + Hash, V> UnordMap<K, V> {
557562 #[inline]
558563 pub fn to_sorted<Hcx>(&self, hcx: &mut Hcx, cache_sort_key: bool) -> Vec<(&K, &V)>
559564 where
560 K: ToStableHashKey<Hcx>,
565 Hcx: HashStableContext,
566 K: ToStableHashKey,
561567 {
562568 to_sorted_vec(hcx, self.inner.iter(), cache_sort_key, |&(k, _)| k)
563569 }
......@@ -584,7 +590,8 @@ impl<K: Eq + Hash, V> UnordMap<K, V> {
584590 #[inline]
585591 pub fn into_sorted<Hcx>(self, hcx: &mut Hcx, cache_sort_key: bool) -> Vec<(K, V)>
586592 where
587 K: ToStableHashKey<Hcx>,
593 Hcx: HashStableContext,
594 K: ToStableHashKey,
588595 {
589596 to_sorted_vec(hcx, self.inner.into_iter(), cache_sort_key, |(k, _)| k)
590597 }
......@@ -616,7 +623,8 @@ impl<K: Eq + Hash, V> UnordMap<K, V> {
616623 cache_sort_key: bool,
617624 ) -> impl Iterator<Item = &V>
618625 where
619 K: ToStableHashKey<Hcx>,
626 Hcx: HashStableContext,
627 K: ToStableHashKey,
620628 {
621629 to_sorted_vec(hcx, self.inner.iter(), cache_sort_key, |&(k, _)| k)
622630 .into_iter()
......@@ -642,9 +650,9 @@ where
642650 }
643651}
644652
645impl<Hcx, K: Hash + Eq + HashStable<Hcx>, V: HashStable<Hcx>> HashStable<Hcx> for UnordMap<K, V> {
653impl<K: Hash + Eq + HashStable, V: HashStable> HashStable for UnordMap<K, V> {
646654 #[inline]
647 fn hash_stable(&self, hcx: &mut Hcx, hasher: &mut StableHasher) {
655 fn hash_stable<Hcx: HashStableContext>(&self, hcx: &mut Hcx, hasher: &mut StableHasher) {
648656 hash_iter_order_independent(self.inner.iter(), hcx, hasher);
649657 }
650658}
......@@ -705,9 +713,9 @@ impl<T, I: Iterator<Item = T>> From<UnordItems<T, I>> for UnordBag<T> {
705713 }
706714}
707715
708impl<Hcx, V: Hash + Eq + HashStable<Hcx>> HashStable<Hcx> for UnordBag<V> {
716impl<V: Hash + Eq + HashStable> HashStable for UnordBag<V> {
709717 #[inline]
710 fn hash_stable(&self, hcx: &mut Hcx, hasher: &mut StableHasher) {
718 fn hash_stable<Hcx: HashStableContext>(&self, hcx: &mut Hcx, hasher: &mut StableHasher) {
711719 hash_iter_order_independent(self.inner.iter(), hcx, hasher);
712720 }
713721}
......@@ -720,8 +728,9 @@ fn to_sorted_vec<Hcx, T, K, I>(
720728 extract_key: fn(&T) -> &K,
721729) -> Vec<T>
722730where
731 Hcx: HashStableContext,
723732 I: Iterator<Item = T>,
724 K: ToStableHashKey<Hcx>,
733 K: ToStableHashKey,
725734{
726735 let mut items: Vec<T> = iter.collect();
727736 if cache_sort_key {
......@@ -734,8 +743,8 @@ where
734743}
735744
736745fn hash_iter_order_independent<
737 Hcx,
738 T: HashStable<Hcx>,
746 Hcx: HashStableContext,
747 T: HashStable,
739748 I: Iterator<Item = T> + ExactSizeIterator,
740749>(
741750 mut it: I,
compiler/rustc_error_messages/src/lib.rs+3-3
......@@ -7,7 +7,7 @@ use std::borrow::Cow;
77
88pub use fluent_bundle::types::FluentType;
99pub use fluent_bundle::{self, FluentArgs, FluentError, FluentValue};
10use rustc_macros::{Decodable, Encodable, HashStable_Generic};
10use rustc_macros::{Decodable, Encodable, HashStable};
1111use rustc_span::Span;
1212pub use unic_langid::{LanguageIdentifier, langid};
1313
......@@ -28,7 +28,7 @@ pub fn register_functions<R, M>(bundle: &mut fluent_bundle::bundle::FluentBundle
2828/// diagnostic messages.
2929///
3030/// Intended to be removed once diagnostics are entirely translatable.
31#[derive(Clone, Debug, PartialEq, Eq, Hash, Encodable, Decodable, HashStable_Generic)]
31#[derive(Clone, Debug, PartialEq, Eq, Hash, Encodable, Decodable, HashStable)]
3232#[rustc_diagnostic_item = "DiagMessage"]
3333pub enum DiagMessage {
3434 /// Non-translatable diagnostic message or a message that has been translated eagerly.
......@@ -89,7 +89,7 @@ pub struct SpanLabel {
8989/// the error, and would be rendered with `^^^`.
9090/// - They can have a *label*. In this case, the label is written next
9191/// to the mark in the snippet when we render.
92#[derive(Clone, Debug, Hash, PartialEq, Eq, Encodable, Decodable, HashStable_Generic)]
92#[derive(Clone, Debug, Hash, PartialEq, Eq, Encodable, Decodable, HashStable)]
9393pub struct MultiSpan {
9494 primary_spans: Vec<Span>,
9595 span_labels: Vec<(Span, DiagMessage)>,
compiler/rustc_feature/src/unstable.rs+27
......@@ -5,6 +5,7 @@ use std::time::{SystemTime, UNIX_EPOCH};
55
66use rustc_data_structures::AtomicRef;
77use rustc_data_structures::fx::FxHashSet;
8use rustc_data_structures::stable_hasher::{HashStable, HashStableContext, StableHasher};
89use rustc_span::{Span, Symbol, sym};
910
1011use super::{Feature, to_nonzero};
......@@ -119,6 +120,32 @@ impl Features {
119120 }
120121}
121122
123impl HashStable for Features {
124 fn hash_stable<Hcx: HashStableContext>(&self, hcx: &mut Hcx, hasher: &mut StableHasher) {
125 // `enabled_features` is skipped because it's the sum of the lang and lib features.
126 let Features { enabled_lang_features, enabled_lib_features, enabled_features: _ } = self;
127 enabled_lang_features.hash_stable(hcx, hasher);
128 enabled_lib_features.hash_stable(hcx, hasher);
129 }
130}
131
132impl HashStable for EnabledLangFeature {
133 fn hash_stable<Hcx: HashStableContext>(&self, hcx: &mut Hcx, hasher: &mut StableHasher) {
134 let EnabledLangFeature { gate_name, attr_sp, stable_since } = self;
135 gate_name.hash_stable(hcx, hasher);
136 attr_sp.hash_stable(hcx, hasher);
137 stable_since.hash_stable(hcx, hasher);
138 }
139}
140
141impl HashStable for EnabledLibFeature {
142 fn hash_stable<Hcx: HashStableContext>(&self, hcx: &mut Hcx, hasher: &mut StableHasher) {
143 let EnabledLibFeature { gate_name, attr_sp } = self;
144 gate_name.hash_stable(hcx, hasher);
145 attr_sp.hash_stable(hcx, hasher);
146 }
147}
148
122149macro_rules! declare_features {
123150 ($(
124151 $(#[doc = $doc:tt])* ($status:ident, $feature:ident, $ver:expr, $issue:expr),
compiler/rustc_hir/src/attrs/data_structures.rs+46-66
......@@ -12,7 +12,7 @@ use rustc_ast::{AttrStyle, Path, ast};
1212use rustc_data_structures::fx::FxIndexMap;
1313use rustc_error_messages::{DiagArgValue, IntoDiagArg};
1414use rustc_hir::LangItem;
15use rustc_macros::{Decodable, Encodable, HashStable_Generic, PrintAttribute};
15use rustc_macros::{Decodable, Encodable, HashStable, PrintAttribute};
1616use rustc_span::def_id::DefId;
1717use rustc_span::hygiene::Transparency;
1818use rustc_span::{ErrorGuaranteed, Ident, Span, Symbol};
......@@ -24,7 +24,7 @@ use crate::attrs::pretty_printing::PrintAttribute;
2424use crate::limit::Limit;
2525use crate::{DefaultBodyStability, PartialConstStability, RustcVersion, Stability};
2626
27#[derive(Copy, Clone, Debug, HashStable_Generic, Encodable, Decodable, PrintAttribute)]
27#[derive(Copy, Clone, Debug, HashStable, Encodable, Decodable, PrintAttribute)]
2828pub enum EiiImplResolution {
2929 /// Usually, finding the extern item that an EII implementation implements means finding
3030 /// the defid of the associated attribute macro, and looking at *its* attributes to find
......@@ -37,7 +37,7 @@ pub enum EiiImplResolution {
3737 Error(ErrorGuaranteed),
3838}
3939
40#[derive(Copy, Clone, Debug, HashStable_Generic, Encodable, Decodable, PrintAttribute)]
40#[derive(Copy, Clone, Debug, HashStable, Encodable, Decodable, PrintAttribute)]
4141pub struct EiiImpl {
4242 pub resolution: EiiImplResolution,
4343 pub impl_marked_unsafe: bool,
......@@ -46,7 +46,7 @@ pub struct EiiImpl {
4646 pub is_default: bool,
4747}
4848
49#[derive(Copy, Clone, Debug, HashStable_Generic, Encodable, Decodable, PrintAttribute)]
49#[derive(Copy, Clone, Debug, HashStable, Encodable, Decodable, PrintAttribute)]
5050pub struct EiiDecl {
5151 pub foreign_item: DefId,
5252 /// whether or not it is unsafe to implement this EII
......@@ -54,7 +54,7 @@ pub struct EiiDecl {
5454 pub name: Ident,
5555}
5656
57#[derive(Copy, Clone, PartialEq, Encodable, Decodable, Debug, HashStable_Generic, PrintAttribute)]
57#[derive(Copy, Clone, PartialEq, Encodable, Decodable, Debug, HashStable, PrintAttribute)]
5858pub enum CguKind {
5959 No,
6060 PreDashLto,
......@@ -62,7 +62,7 @@ pub enum CguKind {
6262 Any,
6363}
6464
65#[derive(Copy, Clone, PartialEq, Encodable, Decodable, Debug, HashStable_Generic, PrintAttribute)]
65#[derive(Copy, Clone, PartialEq, Encodable, Decodable, Debug, HashStable, PrintAttribute)]
6666pub enum CguFields {
6767 PartitionReused { cfg: Symbol, module: Symbol },
6868 PartitionCodegened { cfg: Symbol, module: Symbol },
......@@ -70,7 +70,7 @@ pub enum CguFields {
7070}
7171
7272#[derive(Copy, Clone, PartialEq, Debug, PrintAttribute)]
73#[derive(HashStable_Generic, Encodable, Decodable)]
73#[derive(HashStable, Encodable, Decodable)]
7474pub enum DivergingFallbackBehavior {
7575 /// Always fallback to `()` (aka "always spontaneous decay")
7676 ToUnit,
......@@ -82,7 +82,7 @@ pub enum DivergingFallbackBehavior {
8282}
8383
8484#[derive(Copy, Clone, PartialEq, Debug, PrintAttribute, Default)]
85#[derive(HashStable_Generic, Encodable, Decodable)]
85#[derive(HashStable, Encodable, Decodable)]
8686pub enum DivergingBlockBehavior {
8787 /// This is the current stable behavior:
8888 ///
......@@ -105,7 +105,7 @@ pub enum DivergingBlockBehavior {
105105 Unit,
106106}
107107
108#[derive(Copy, Clone, PartialEq, Encodable, Decodable, Debug, HashStable_Generic, PrintAttribute)]
108#[derive(Copy, Clone, PartialEq, Encodable, Decodable, Debug, HashStable, PrintAttribute)]
109109pub enum InlineAttr {
110110 None,
111111 Hint,
......@@ -129,24 +129,14 @@ impl InlineAttr {
129129 }
130130}
131131
132#[derive(
133 Copy,
134 Clone,
135 Encodable,
136 Decodable,
137 Debug,
138 PartialEq,
139 Eq,
140 HashStable_Generic,
141 PrintAttribute
142)]
132#[derive(Copy, Clone, Encodable, Decodable, Debug, PartialEq, Eq, HashStable, PrintAttribute)]
143133pub enum InstructionSetAttr {
144134 ArmA32,
145135 ArmT32,
146136}
147137
148138#[derive(Copy, Clone, Debug, PartialEq, Eq, Default, PrintAttribute)]
149#[derive(Encodable, Decodable, HashStable_Generic)]
139#[derive(Encodable, Decodable, HashStable)]
150140pub enum OptimizeAttr {
151141 /// No `#[optimize(..)]` attribute
152142 #[default]
......@@ -165,7 +155,7 @@ impl OptimizeAttr {
165155 }
166156}
167157
168#[derive(PartialEq, Debug, Encodable, Decodable, Copy, Clone, HashStable_Generic, PrintAttribute)]
158#[derive(PartialEq, Debug, Encodable, Decodable, Copy, Clone, HashStable, PrintAttribute)]
169159pub enum ReprAttr {
170160 ReprInt(IntType),
171161 ReprRust,
......@@ -182,13 +172,13 @@ pub enum TransparencyError {
182172}
183173
184174#[derive(Eq, PartialEq, Debug, Copy, Clone)]
185#[derive(Encodable, Decodable, HashStable_Generic, PrintAttribute)]
175#[derive(Encodable, Decodable, HashStable, PrintAttribute)]
186176pub enum IntType {
187177 SignedInt(ast::IntTy),
188178 UnsignedInt(ast::UintTy),
189179}
190180
191#[derive(Copy, Debug, Encodable, Decodable, Clone, HashStable_Generic, PrintAttribute)]
181#[derive(Copy, Debug, Encodable, Decodable, Clone, HashStable, PrintAttribute)]
192182pub struct Deprecation {
193183 pub since: DeprecatedSince,
194184 /// The note to issue a reason.
......@@ -200,7 +190,7 @@ pub struct Deprecation {
200190}
201191
202192/// Release in which an API is deprecated.
203#[derive(Copy, Debug, Encodable, Decodable, Clone, HashStable_Generic, PrintAttribute)]
193#[derive(Copy, Debug, Encodable, Decodable, Clone, HashStable, PrintAttribute)]
204194pub enum DeprecatedSince {
205195 RustcVersion(RustcVersion),
206196 /// Deprecated in the future ("to be determined").
......@@ -217,7 +207,7 @@ pub enum DeprecatedSince {
217207
218208/// Successfully-parsed value of a `#[coverage(..)]` attribute.
219209#[derive(Copy, Debug, Eq, PartialEq, Encodable, Decodable, Clone)]
220#[derive(HashStable_Generic, PrintAttribute)]
210#[derive(HashStable, PrintAttribute)]
221211pub enum CoverageAttrKind {
222212 On,
223213 Off,
......@@ -225,7 +215,7 @@ pub enum CoverageAttrKind {
225215
226216/// Successfully-parsed value of a `#[rustc_abi(..)]` attribute.
227217#[derive(Copy, Debug, Eq, PartialEq, Encodable, Decodable, Clone)]
228#[derive(HashStable_Generic, PrintAttribute)]
218#[derive(HashStable, PrintAttribute)]
229219pub enum RustcAbiAttrKind {
230220 Debug,
231221 AssertEq,
......@@ -256,7 +246,7 @@ impl Deprecation {
256246/// `#[used(compiler)]`
257247/// `#[used(linker)]`
258248#[derive(Encodable, Decodable, Copy, Clone, Debug, PartialEq, Eq, Hash)]
259#[derive(HashStable_Generic, PrintAttribute)]
249#[derive(HashStable, PrintAttribute)]
260250pub enum UsedBy {
261251 Default,
262252 Compiler,
......@@ -264,7 +254,7 @@ pub enum UsedBy {
264254}
265255
266256#[derive(Encodable, Decodable, Clone, Debug, PartialEq, Eq, Hash)]
267#[derive(HashStable_Generic, PrintAttribute)]
257#[derive(HashStable, PrintAttribute)]
268258pub enum MacroUseArgs {
269259 UseAll,
270260 UseSpecific(ThinVec<Ident>),
......@@ -276,7 +266,7 @@ impl Default for MacroUseArgs {
276266 }
277267}
278268
279#[derive(Debug, Clone, Encodable, Decodable, HashStable_Generic)]
269#[derive(Debug, Clone, Encodable, Decodable, HashStable)]
280270pub struct StrippedCfgItem<ScopeId = DefId> {
281271 pub parent_scope: ScopeId,
282272 pub ident: Ident,
......@@ -294,7 +284,7 @@ impl<ScopeId> StrippedCfgItem<ScopeId> {
294284///
295285/// See <https://llvm.org/docs/LangRef.html#linkage-types> for more details about these variants.
296286#[derive(Encodable, Decodable, Clone, Copy, Debug, PartialEq, Eq, Hash)]
297#[derive(HashStable_Generic, PrintAttribute)]
287#[derive(HashStable, PrintAttribute)]
298288pub enum Linkage {
299289 AvailableExternally,
300290 Common,
......@@ -308,7 +298,7 @@ pub enum Linkage {
308298}
309299
310300#[derive(Clone, Copy, Decodable, Debug, Encodable, PartialEq)]
311#[derive(HashStable_Generic, PrintAttribute)]
301#[derive(HashStable, PrintAttribute)]
312302pub enum MirDialect {
313303 Analysis,
314304 Built,
......@@ -327,7 +317,7 @@ impl IntoDiagArg for MirDialect {
327317}
328318
329319#[derive(Clone, Copy, Decodable, Debug, Encodable, PartialEq)]
330#[derive(HashStable_Generic, PrintAttribute)]
320#[derive(HashStable, PrintAttribute)]
331321pub enum MirPhase {
332322 Initial,
333323 PostCleanup,
......@@ -347,17 +337,7 @@ impl IntoDiagArg for MirPhase {
347337
348338/// Different ways that the PE Format can decorate a symbol name.
349339/// From <https://docs.microsoft.com/en-us/windows/win32/debug/pe-format#import-name-type>
350#[derive(
351 Copy,
352 Clone,
353 Debug,
354 Encodable,
355 Decodable,
356 HashStable_Generic,
357 PartialEq,
358 Eq,
359 PrintAttribute
360)]
340#[derive(Copy, Clone, Debug, Encodable, Decodable, HashStable, PartialEq, Eq, PrintAttribute)]
361341pub enum PeImportNameType {
362342 /// IMPORT_ORDINAL
363343 /// Uses the ordinal (i.e., a number) rather than the name.
......@@ -387,7 +367,7 @@ pub enum PeImportNameType {
387367 Decodable,
388368 PrintAttribute
389369)]
390#[derive(HashStable_Generic)]
370#[derive(HashStable)]
391371pub enum NativeLibKind {
392372 /// Static library (e.g. `libfoo.a` on Linux or `foo.lib` on Windows/MSVC)
393373 Static {
......@@ -455,7 +435,7 @@ impl NativeLibKind {
455435 }
456436}
457437
458#[derive(Debug, Encodable, Decodable, Clone, HashStable_Generic, PrintAttribute)]
438#[derive(Debug, Encodable, Decodable, Clone, HashStable, PrintAttribute)]
459439pub struct LinkEntry {
460440 pub span: Span,
461441 pub kind: NativeLibKind,
......@@ -465,14 +445,14 @@ pub struct LinkEntry {
465445 pub import_name_type: Option<(PeImportNameType, Span)>,
466446}
467447
468#[derive(HashStable_Generic, PrintAttribute)]
448#[derive(HashStable, PrintAttribute)]
469449#[derive(Copy, PartialEq, PartialOrd, Clone, Ord, Eq, Hash, Debug, Encodable, Decodable)]
470450pub enum DebuggerVisualizerType {
471451 Natvis,
472452 GdbPrettyPrinter,
473453}
474454
475#[derive(Debug, Encodable, Decodable, Clone, HashStable_Generic, PrintAttribute)]
455#[derive(Debug, Encodable, Decodable, Clone, HashStable, PrintAttribute)]
476456pub struct DebugVisualizer {
477457 pub span: Span,
478458 pub visualizer_type: DebuggerVisualizerType,
......@@ -480,7 +460,7 @@ pub struct DebugVisualizer {
480460}
481461
482462#[derive(Clone, Copy, Debug, Decodable, Encodable, Eq, PartialEq)]
483#[derive(HashStable_Generic, PrintAttribute)]
463#[derive(HashStable, PrintAttribute)]
484464#[derive_const(Default)]
485465pub enum RtsanSetting {
486466 Nonblocking,
......@@ -490,7 +470,7 @@ pub enum RtsanSetting {
490470}
491471
492472#[derive(Eq, PartialEq, Debug, Copy, Clone)]
493#[derive(Encodable, Decodable, HashStable_Generic, PrintAttribute)]
473#[derive(Encodable, Decodable, HashStable, PrintAttribute)]
494474pub enum WindowsSubsystemKind {
495475 Console,
496476 Windows,
......@@ -506,20 +486,20 @@ impl WindowsSubsystemKind {
506486}
507487
508488#[derive(Copy, Clone, Debug, PartialEq)]
509#[derive(HashStable_Generic, Encodable, Decodable, PrintAttribute)]
489#[derive(HashStable, Encodable, Decodable, PrintAttribute)]
510490pub enum DocInline {
511491 Inline,
512492 NoInline,
513493}
514494
515495#[derive(Copy, Clone, Debug, PartialEq)]
516#[derive(HashStable_Generic, Encodable, Decodable, PrintAttribute)]
496#[derive(HashStable, Encodable, Decodable, PrintAttribute)]
517497pub enum HideOrShow {
518498 Hide,
519499 Show,
520500}
521501
522#[derive(Clone, Debug, HashStable_Generic, Encodable, Decodable, PrintAttribute)]
502#[derive(Clone, Debug, HashStable, Encodable, Decodable, PrintAttribute)]
523503pub struct CfgInfo {
524504 pub name: Symbol,
525505 pub name_span: Span,
......@@ -536,13 +516,13 @@ impl CfgInfo {
536516 }
537517}
538518
539#[derive(Clone, Debug, HashStable_Generic, Encodable, Decodable, PrintAttribute)]
519#[derive(Clone, Debug, HashStable, Encodable, Decodable, PrintAttribute)]
540520pub struct CfgHideShow {
541521 pub kind: HideOrShow,
542522 pub values: ThinVec<CfgInfo>,
543523}
544524
545#[derive(Clone, Debug, Default, HashStable_Generic, Decodable, PrintAttribute)]
525#[derive(Clone, Debug, Default, HashStable, Decodable, PrintAttribute)]
546526pub struct DocAttribute {
547527 pub first_span: Span,
548528
......@@ -646,7 +626,7 @@ impl<E: rustc_span::SpanEncoder> rustc_serialize::Encodable<E> for DocAttribute
646626/// | external | no | if-ext | if-ext | yes |
647627/// | yes | yes | yes | yes | yes |
648628#[derive(Copy, Clone, Debug, Hash, PartialEq)]
649#[derive(HashStable_Generic, Encodable, Decodable, PrintAttribute)]
629#[derive(HashStable, Encodable, Decodable, PrintAttribute)]
650630pub enum CollapseMacroDebuginfo {
651631 /// Don't collapse debuginfo for the macro
652632 No = 0,
......@@ -660,7 +640,7 @@ pub enum CollapseMacroDebuginfo {
660640
661641/// Crate type, as specified by `#![crate_type]`
662642#[derive(Copy, Clone, Debug, Hash, PartialEq, Default, PartialOrd, Eq, Ord)]
663#[derive(HashStable_Generic, Encodable, Decodable, PrintAttribute)]
643#[derive(HashStable, Encodable, Decodable, PrintAttribute)]
664644pub enum CrateType {
665645 /// `#![crate_type = "bin"]`
666646 Executable,
......@@ -760,7 +740,7 @@ impl IntoDiagArg for CrateType {
760740 }
761741}
762742
763#[derive(Clone, Debug, HashStable_Generic, Encodable, Decodable, PrintAttribute)]
743#[derive(Clone, Debug, HashStable, Encodable, Decodable, PrintAttribute)]
764744pub enum RustcDumpLayoutKind {
765745 Align,
766746 BackendRepr,
......@@ -769,7 +749,7 @@ pub enum RustcDumpLayoutKind {
769749 Size,
770750}
771751
772#[derive(Clone, Debug, HashStable_Generic, Encodable, Decodable, PrintAttribute, PartialEq, Eq)]
752#[derive(Clone, Debug, HashStable, Encodable, Decodable, PrintAttribute, PartialEq, Eq)]
773753pub enum RustcMirKind {
774754 PeekMaybeInit,
775755 PeekMaybeUninit,
......@@ -779,13 +759,13 @@ pub enum RustcMirKind {
779759 BorrowckGraphvizFormat { format: BorrowckGraphvizFormatKind },
780760}
781761
782#[derive(Clone, Debug, HashStable_Generic, Encodable, Decodable, PrintAttribute, PartialEq, Eq)]
762#[derive(Clone, Debug, HashStable, Encodable, Decodable, PrintAttribute, PartialEq, Eq)]
783763pub enum BorrowckGraphvizFormatKind {
784764 TwoPhase,
785765}
786766
787767#[derive(Clone, Debug, PartialEq, Eq)]
788#[derive(HashStable_Generic, Encodable, Decodable, PrintAttribute)]
768#[derive(HashStable, Encodable, Decodable, PrintAttribute)]
789769pub struct RustcCleanAttribute {
790770 pub span: Span,
791771 pub cfg: Symbol,
......@@ -795,14 +775,14 @@ pub struct RustcCleanAttribute {
795775
796776/// Represents the `except=` or `loaded_from_disk=` argument of `#[rustc_clean]`
797777#[derive(Clone, Debug, PartialEq, Eq)]
798#[derive(HashStable_Generic, Encodable, Decodable, PrintAttribute)]
778#[derive(HashStable, Encodable, Decodable, PrintAttribute)]
799779pub struct RustcCleanQueries {
800780 pub entries: ThinVec<Symbol>,
801781 pub span: Span,
802782}
803783
804784#[derive(Clone, Debug, PartialEq, Eq)]
805#[derive(HashStable_Generic, Encodable, Decodable, PrintAttribute)]
785#[derive(HashStable, Encodable, Decodable, PrintAttribute)]
806786pub struct RustcAutodiff {
807787 /// Conceptually either forward or reverse mode AD, as described in various autodiff papers and
808788 /// e.g. in the [JAX
......@@ -878,7 +858,7 @@ impl RustcAutodiff {
878858}
879859
880860/// We generate one of these structs for each `#[autodiff(...)]` attribute.
881#[derive(Clone, Eq, PartialEq, Encodable, Decodable, Debug, HashStable_Generic)]
861#[derive(Clone, Eq, PartialEq, Encodable, Decodable, Debug, HashStable)]
882862pub struct AutoDiffItem {
883863 /// The name of the function getting differentiated
884864 pub source: String,
......@@ -898,7 +878,7 @@ impl fmt::Display for AutoDiffItem {
898878 }
899879}
900880
901#[derive(Clone, Debug, HashStable_Generic, Encodable, Decodable, PrintAttribute)]
881#[derive(Clone, Debug, HashStable, Encodable, Decodable, PrintAttribute)]
902882pub struct UnstableRemovedFeature {
903883 pub feature: Symbol,
904884 pub reason: Symbol,
......@@ -955,7 +935,7 @@ pub struct UnstableRemovedFeature {
955935/// [`rustc_parse`]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_parse/index.html
956936/// [`rustc_codegen_ssa`]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_codegen_ssa/index.html
957937/// [`rustc_attr_parsing`]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_attr_parsing/index.html
958#[derive(Clone, Debug, HashStable_Generic, Encodable, Decodable, PrintAttribute)]
938#[derive(Clone, Debug, HashStable, Encodable, Decodable, PrintAttribute)]
959939pub enum AttributeKind {
960940 // tidy-alphabetical-start
961941 /// Represents `#[allow_internal_unsafe]`.
compiler/rustc_hir/src/attrs/diagnostic.rs+12-12
......@@ -3,14 +3,14 @@ use std::fmt;
33use std::fmt::Debug;
44
55pub use rustc_ast::attr::data_structures::*;
6use rustc_macros::{Decodable, Encodable, HashStable_Generic, PrintAttribute};
6use rustc_macros::{Decodable, Encodable, HashStable, PrintAttribute};
77use rustc_span::{DesugaringKind, Span, Symbol, kw};
88use thin_vec::ThinVec;
99use tracing::debug;
1010
1111use crate::attrs::PrintAttribute;
1212
13#[derive(Clone, Default, Debug, HashStable_Generic, Encodable, Decodable, PrintAttribute)]
13#[derive(Clone, Default, Debug, HashStable, Encodable, Decodable, PrintAttribute)]
1414pub struct Directive {
1515 pub is_rustc_attr: bool,
1616 pub condition: Option<OnUnimplementedCondition>,
......@@ -123,7 +123,7 @@ pub struct CustomDiagnostic {
123123
124124/// Like [std::fmt::Arguments] this is a string that has been parsed into "pieces",
125125/// either as string pieces or dynamic arguments.
126#[derive(Clone, Debug, HashStable_Generic, Encodable, Decodable, PrintAttribute)]
126#[derive(Clone, Debug, HashStable, Encodable, Decodable, PrintAttribute)]
127127pub struct FormatString {
128128 pub input: Symbol,
129129 pub span: Span,
......@@ -225,13 +225,13 @@ pub struct FormatArgs {
225225 pub generic_args: Vec<(Symbol, String)> = Vec::new(),
226226}
227227
228#[derive(Clone, Debug, HashStable_Generic, Encodable, Decodable, PrintAttribute)]
228#[derive(Clone, Debug, HashStable, Encodable, Decodable, PrintAttribute)]
229229pub enum Piece {
230230 Lit(Symbol),
231231 Arg(FormatArg),
232232}
233233
234#[derive(Clone, Debug, HashStable_Generic, Encodable, Decodable, PrintAttribute)]
234#[derive(Clone, Debug, HashStable, Encodable, Decodable, PrintAttribute)]
235235pub enum FormatArg {
236236 // A generic parameter, like `{T}` if we're on the `From<T>` trait.
237237 GenericParam {
......@@ -251,7 +251,7 @@ pub enum FormatArg {
251251}
252252
253253/// Represents the `on` filter in `#[rustc_on_unimplemented]`.
254#[derive(Clone, Debug, HashStable_Generic, Encodable, Decodable, PrintAttribute)]
254#[derive(Clone, Debug, HashStable, Encodable, Decodable, PrintAttribute)]
255255pub struct OnUnimplementedCondition {
256256 pub span: Span,
257257 pub pred: Predicate,
......@@ -276,7 +276,7 @@ impl OnUnimplementedCondition {
276276///
277277/// It is similar to the predicate in the `cfg` attribute,
278278/// and may contain nested predicates.
279#[derive(Clone, Debug, HashStable_Generic, Encodable, Decodable, PrintAttribute)]
279#[derive(Clone, Debug, HashStable, Encodable, Decodable, PrintAttribute)]
280280pub enum Predicate {
281281 /// A condition like `on(crate_local)`.
282282 Flag(Flag),
......@@ -314,7 +314,7 @@ impl Predicate {
314314}
315315
316316/// Represents a `MetaWord` in an `on`-filter.
317#[derive(Clone, Copy, Debug, HashStable_Generic, Encodable, Decodable, PrintAttribute)]
317#[derive(Clone, Copy, Debug, HashStable, Encodable, Decodable, PrintAttribute)]
318318pub enum Flag {
319319 /// Whether the code causing the trait bound to not be fulfilled
320320 /// is part of the user's crate.
......@@ -329,7 +329,7 @@ pub enum Flag {
329329/// A `MetaNameValueStr` in an `on`-filter.
330330///
331331/// For example, `#[rustc_on_unimplemented(on(name = "value", message = "hello"))]`.
332#[derive(Clone, Debug, HashStable_Generic, Encodable, Decodable, PrintAttribute)]
332#[derive(Clone, Debug, HashStable, Encodable, Decodable, PrintAttribute)]
333333pub struct NameValue {
334334 pub name: Name,
335335 /// Something like `"&str"` or `"alloc::string::String"`,
......@@ -348,7 +348,7 @@ impl NameValue {
348348}
349349
350350/// The valid names of the `on` filter.
351#[derive(Clone, Copy, Debug, HashStable_Generic, Encodable, Decodable, PrintAttribute)]
351#[derive(Clone, Copy, Debug, HashStable, Encodable, Decodable, PrintAttribute)]
352352pub enum Name {
353353 Cause,
354354 FromDesugaring,
......@@ -368,7 +368,7 @@ pub enum FlagOrNv<'p> {
368368/// If it is a simple literal like this then `pieces` will be `[LitOrArg::Lit("value")]`.
369369/// The `Arg` variant is used when it contains formatting like
370370/// `#[rustc_on_unimplemented(on(Self = "&[{A}]", message = "hello"))]`.
371#[derive(Clone, Debug, HashStable_Generic, Encodable, Decodable, PrintAttribute)]
371#[derive(Clone, Debug, HashStable, Encodable, Decodable, PrintAttribute)]
372372pub struct FilterFormatString {
373373 pub pieces: ThinVec<LitOrArg>,
374374}
......@@ -400,7 +400,7 @@ impl FilterFormatString {
400400 }
401401}
402402
403#[derive(Clone, Debug, HashStable_Generic, Encodable, Decodable, PrintAttribute)]
403#[derive(Clone, Debug, HashStable, Encodable, Decodable, PrintAttribute)]
404404pub enum LitOrArg {
405405 Lit(Symbol),
406406 Arg(Symbol),
compiler/rustc_hir/src/def.rs+12-12
......@@ -7,16 +7,16 @@ use rustc_ast::NodeId;
77use rustc_data_structures::stable_hasher::ToStableHashKey;
88use rustc_data_structures::unord::UnordMap;
99use rustc_error_messages::{DiagArgValue, IntoDiagArg};
10use rustc_macros::{Decodable, Encodable, HashStable_Generic};
10use rustc_macros::{Decodable, Encodable, HashStable};
11use rustc_span::Symbol;
1112use rustc_span::def_id::{DefId, LocalDefId};
1213use rustc_span::hygiene::MacroKind;
13use rustc_span::{HashStableContext, Symbol};
1414
1515use crate::definitions::DefPathData;
1616use crate::hir;
1717
1818/// Encodes if a `DefKind::Ctor` is the constructor of an enum variant or a struct.
19#[derive(Clone, Copy, PartialEq, Eq, Encodable, Decodable, Hash, Debug, HashStable_Generic)]
19#[derive(Clone, Copy, PartialEq, Eq, Encodable, Decodable, Hash, Debug, HashStable)]
2020pub enum CtorOf {
2121 /// This `DefKind::Ctor` is a synthesized constructor of a tuple or unit struct.
2222 Struct,
......@@ -25,7 +25,7 @@ pub enum CtorOf {
2525}
2626
2727/// What kind of constructor something is.
28#[derive(Clone, Copy, PartialEq, Eq, Encodable, Decodable, Hash, Debug, HashStable_Generic)]
28#[derive(Clone, Copy, PartialEq, Eq, Encodable, Decodable, Hash, Debug, HashStable)]
2929pub enum CtorKind {
3030 /// Constructor function automatically created by a tuple struct/variant.
3131 Fn,
......@@ -35,7 +35,7 @@ pub enum CtorKind {
3535
3636/// A set of macro kinds, for macros that can have more than one kind
3737#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Encodable, Decodable, Hash, Debug)]
38#[derive(HashStable_Generic)]
38#[derive(HashStable)]
3939pub struct MacroKinds(u8);
4040bitflags::bitflags! {
4141 impl MacroKinds: u8 {
......@@ -81,7 +81,7 @@ impl MacroKinds {
8181}
8282
8383/// An attribute that is not a macro; e.g., `#[inline]` or `#[rustfmt::skip]`.
84#[derive(Clone, Copy, PartialEq, Eq, Encodable, Decodable, Hash, Debug, HashStable_Generic)]
84#[derive(Clone, Copy, PartialEq, Eq, Encodable, Decodable, Hash, Debug, HashStable)]
8585pub enum NonMacroAttrKind {
8686 /// Single-segment attribute defined by the language (`#[inline]`)
8787 Builtin(Symbol),
......@@ -96,7 +96,7 @@ pub enum NonMacroAttrKind {
9696
9797/// What kind of definition something is; e.g., `mod` vs `struct`.
9898/// `enum DefPathData` may need to be updated if a new variant is added here.
99#[derive(Clone, Copy, PartialEq, Eq, Encodable, Decodable, Hash, Debug, HashStable_Generic)]
99#[derive(Clone, Copy, PartialEq, Eq, Encodable, Decodable, Hash, Debug, HashStable)]
100100pub enum DefKind {
101101 // Type namespace
102102 Mod,
......@@ -511,7 +511,7 @@ impl DefKind {
511511/// - the call to `str_to_string` will resolve to [`Res::Def`], with the [`DefId`]
512512/// pointing to the definition of `str_to_string` in the current crate.
513513//
514#[derive(Clone, Copy, PartialEq, Eq, Encodable, Decodable, Hash, Debug, HashStable_Generic)]
514#[derive(Clone, Copy, PartialEq, Eq, Encodable, Decodable, Hash, Debug, HashStable)]
515515pub enum Res<Id = hir::HirId> {
516516 /// Definition having a unique ID (`DefId`), corresponds to something defined in user code.
517517 ///
......@@ -679,7 +679,7 @@ impl PartialRes {
679679/// Different kinds of symbols can coexist even if they share the same textual name.
680680/// Therefore, they each have a separate universe (known as a "namespace").
681681#[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Debug, Encodable, Decodable)]
682#[derive(HashStable_Generic)]
682#[derive(HashStable)]
683683pub enum Namespace {
684684 /// The type namespace includes `struct`s, `enum`s, `union`s, `trait`s, and `mod`s
685685 /// (and, by extension, crates).
......@@ -712,17 +712,17 @@ impl IntoDiagArg for Namespace {
712712 }
713713}
714714
715impl<Hcx: HashStableContext> ToStableHashKey<Hcx> for Namespace {
715impl ToStableHashKey for Namespace {
716716 type KeyType = Namespace;
717717
718718 #[inline]
719 fn to_stable_hash_key(&self, _: &mut Hcx) -> Namespace {
719 fn to_stable_hash_key<Hcx>(&self, _: &mut Hcx) -> Namespace {
720720 *self
721721 }
722722}
723723
724724/// Just a helper ‒ separate structure for each namespace.
725#[derive(Copy, Clone, Default, Debug, HashStable_Generic)]
725#[derive(Copy, Clone, Default, Debug, HashStable)]
726726pub struct PerNS<T> {
727727 pub value_ns: T,
728728 pub type_ns: T,
compiler/rustc_hir/src/diagnostic_items.rs+2-2
......@@ -1,11 +1,11 @@
11use rustc_data_structures::fx::FxIndexMap;
2use rustc_macros::HashStable_Generic;
2use rustc_macros::HashStable;
33use rustc_span::Symbol;
44use rustc_span::def_id::DefIdMap;
55
66use crate::def_id::DefId;
77
8#[derive(Debug, Default, HashStable_Generic)]
8#[derive(Debug, Default, HashStable)]
99pub struct DiagnosticItems {
1010 #[stable_hasher(ignore)]
1111 pub id_to_name: DefIdMap<Symbol>,
compiler/rustc_hir/src/hir.rs+142-142
......@@ -22,7 +22,7 @@ use rustc_data_structures::steal::Steal;
2222use rustc_data_structures::tagged_ptr::TaggedRef;
2323use rustc_error_messages::{DiagArgValue, IntoDiagArg};
2424use rustc_index::IndexVec;
25use rustc_macros::{Decodable, Encodable, HashStable_Generic};
25use rustc_macros::{Decodable, Encodable, HashStable};
2626use rustc_span::def_id::LocalDefId;
2727use rustc_span::{
2828 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};
3939use crate::intravisit::{FnKind, VisitorExt};
4040use crate::lints::DelayedLints;
4141
42#[derive(Debug, Copy, Clone, PartialEq, Eq, HashStable_Generic)]
42#[derive(Debug, Copy, Clone, PartialEq, Eq, HashStable)]
4343pub enum AngleBrackets {
4444 /// E.g. `Path`.
4545 Missing,
......@@ -49,7 +49,7 @@ pub enum AngleBrackets {
4949 Full,
5050}
5151
52#[derive(Debug, Copy, Clone, PartialEq, Eq, HashStable_Generic)]
52#[derive(Debug, Copy, Clone, PartialEq, Eq, HashStable)]
5353pub enum LifetimeSource {
5454 /// E.g. `&Type`, `&'_ Type`, `&'a Type`, `&mut Type`, `&'_ mut Type`, `&'a mut Type`
5555 Reference,
......@@ -73,7 +73,7 @@ pub enum LifetimeSource {
7373 Other,
7474}
7575
76#[derive(Debug, Copy, Clone, PartialEq, Eq, HashStable_Generic)]
76#[derive(Debug, Copy, Clone, PartialEq, Eq, HashStable)]
7777pub enum LifetimeSyntax {
7878 /// E.g. `&Type`, `ContainsLifetime`
7979 Implicit,
......@@ -150,7 +150,7 @@ impl From<Ident> for LifetimeSyntax {
150150/// Some combinations that cannot occur are `LifetimeSyntax::Implicit` with
151151/// `LifetimeSource::OutlivesBound` or `LifetimeSource::PreciseCapturing`
152152/// — there's no way to "elide" these lifetimes.
153#[derive(Debug, Copy, Clone, HashStable_Generic)]
153#[derive(Debug, Copy, Clone, HashStable)]
154154// Raise the alignment to at least 4 bytes.
155155// This is relied on in other parts of the compiler (for pointer tagging):
156156// <https://github.com/rust-lang/rust/blob/ce5fdd7d42aba9a2925692e11af2bd39cf37798a/compiler/rustc_data_structures/src/tagged_ptr.rs#L163>
......@@ -180,7 +180,7 @@ pub struct Lifetime {
180180 pub syntax: LifetimeSyntax,
181181}
182182
183#[derive(Debug, Copy, Clone, HashStable_Generic)]
183#[derive(Debug, Copy, Clone, HashStable)]
184184pub enum ParamName {
185185 /// Some user-given name like `T` or `'x`.
186186 Plain(Ident),
......@@ -218,7 +218,7 @@ impl ParamName {
218218 }
219219}
220220
221#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash, HashStable_Generic)]
221#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash, HashStable)]
222222pub enum LifetimeKind {
223223 /// User-given names or fresh (synthetic) names.
224224 Param(LocalDefId),
......@@ -345,7 +345,7 @@ impl Lifetime {
345345/// A `Path` is essentially Rust's notion of a name; for instance,
346346/// `std::cmp::PartialEq`. It's represented as a sequence of identifiers,
347347/// along with a bunch of supporting information.
348#[derive(Debug, Clone, Copy, HashStable_Generic)]
348#[derive(Debug, Clone, Copy, HashStable)]
349349pub struct Path<'hir, R = Res> {
350350 pub span: Span,
351351 /// The resolution for the path.
......@@ -365,7 +365,7 @@ impl Path<'_> {
365365
366366/// A segment of a path: an identifier, an optional lifetime, and a set of
367367/// types.
368#[derive(Debug, Clone, Copy, HashStable_Generic)]
368#[derive(Debug, Clone, Copy, HashStable)]
369369pub struct PathSegment<'hir> {
370370 /// The identifier portion of this path segment.
371371 pub ident: Ident,
......@@ -402,7 +402,7 @@ impl<'hir> PathSegment<'hir> {
402402 }
403403}
404404
405#[derive(Clone, Copy, Debug, HashStable_Generic)]
405#[derive(Clone, Copy, Debug, HashStable)]
406406pub enum ConstItemRhs<'hir> {
407407 Body(BodyId),
408408 TypeConst(&'hir ConstArg<'hir>),
......@@ -437,7 +437,7 @@ impl<'hir> ConstItemRhs<'hir> {
437437///
438438/// For an explanation of the `Unambig` generic parameter see the dev-guide:
439439/// <https://rustc-dev-guide.rust-lang.org/ambig-unambig-ty-and-consts.html>
440#[derive(Clone, Copy, Debug, HashStable_Generic)]
440#[derive(Clone, Copy, Debug, HashStable)]
441441#[repr(C)]
442442pub struct ConstArg<'hir, Unambig = ()> {
443443 #[stable_hasher(ignore)]
......@@ -494,7 +494,7 @@ impl<'hir, Unambig> ConstArg<'hir, Unambig> {
494494}
495495
496496/// See [`ConstArg`].
497#[derive(Clone, Copy, Debug, HashStable_Generic)]
497#[derive(Clone, Copy, Debug, HashStable)]
498498#[repr(u8, C)]
499499pub enum ConstArgKind<'hir, Unambig = ()> {
500500 Tup(&'hir [&'hir ConstArg<'hir, Unambig>]),
......@@ -522,7 +522,7 @@ pub enum ConstArgKind<'hir, Unambig = ()> {
522522 },
523523}
524524
525#[derive(Clone, Copy, Debug, HashStable_Generic)]
525#[derive(Clone, Copy, Debug, HashStable)]
526526pub struct ConstArgExprField<'hir> {
527527 pub hir_id: HirId,
528528 pub span: Span,
......@@ -530,13 +530,13 @@ pub struct ConstArgExprField<'hir> {
530530 pub expr: &'hir ConstArg<'hir>,
531531}
532532
533#[derive(Clone, Copy, Debug, HashStable_Generic)]
533#[derive(Clone, Copy, Debug, HashStable)]
534534pub struct ConstArgArrayExpr<'hir> {
535535 pub span: Span,
536536 pub elems: &'hir [&'hir ConstArg<'hir>],
537537}
538538
539#[derive(Clone, Copy, Debug, HashStable_Generic)]
539#[derive(Clone, Copy, Debug, HashStable)]
540540pub struct InferArg {
541541 #[stable_hasher(ignore)]
542542 pub hir_id: HirId,
......@@ -549,7 +549,7 @@ impl InferArg {
549549 }
550550}
551551
552#[derive(Debug, Clone, Copy, HashStable_Generic)]
552#[derive(Debug, Clone, Copy, HashStable)]
553553pub enum GenericArg<'hir> {
554554 Lifetime(&'hir Lifetime),
555555 Type(&'hir Ty<'hir, AmbigArg>),
......@@ -612,7 +612,7 @@ impl GenericArg<'_> {
612612}
613613
614614/// The generic arguments and associated item constraints of a path segment.
615#[derive(Debug, Clone, Copy, HashStable_Generic)]
615#[derive(Debug, Clone, Copy, HashStable)]
616616pub struct GenericArgs<'hir> {
617617 /// The generic arguments for this path segment.
618618 pub args: &'hir [GenericArg<'hir>],
......@@ -736,7 +736,7 @@ impl<'hir> GenericArgs<'hir> {
736736 }
737737}
738738
739#[derive(Copy, Clone, PartialEq, Eq, Debug, HashStable_Generic)]
739#[derive(Copy, Clone, PartialEq, Eq, Debug, HashStable)]
740740pub enum GenericArgsParentheses {
741741 No,
742742 /// Bounds for `feature(return_type_notation)`, like `T: Trait<method(..): Send>`,
......@@ -747,7 +747,7 @@ pub enum GenericArgsParentheses {
747747}
748748
749749/// The modifiers on a trait bound.
750#[derive(Copy, Clone, PartialEq, Eq, Hash, Debug, HashStable_Generic)]
750#[derive(Copy, Clone, PartialEq, Eq, Hash, Debug, HashStable)]
751751pub struct TraitBoundModifiers {
752752 pub constness: BoundConstness,
753753 pub polarity: BoundPolarity,
......@@ -758,7 +758,7 @@ impl TraitBoundModifiers {
758758 TraitBoundModifiers { constness: BoundConstness::Never, polarity: BoundPolarity::Positive };
759759}
760760
761#[derive(Clone, Copy, Debug, HashStable_Generic)]
761#[derive(Clone, Copy, Debug, HashStable)]
762762pub enum GenericBound<'hir> {
763763 Trait(PolyTraitRef<'hir>),
764764 Outlives(&'hir Lifetime),
......@@ -784,7 +784,7 @@ impl GenericBound<'_> {
784784
785785pub type GenericBounds<'hir> = &'hir [GenericBound<'hir>];
786786
787#[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash, HashStable_Generic, Debug)]
787#[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash, HashStable, Debug)]
788788pub enum MissingLifetimeKind {
789789 /// An explicit `'_`.
790790 Underscore,
......@@ -796,7 +796,7 @@ pub enum MissingLifetimeKind {
796796 Brackets,
797797}
798798
799#[derive(Copy, Clone, Debug, HashStable_Generic)]
799#[derive(Copy, Clone, Debug, HashStable)]
800800pub enum LifetimeParamKind {
801801 // Indicates that the lifetime definition was explicitly declared (e.g., in
802802 // `fn foo<'a>(x: &'a u8) -> &'a u8 { x }`).
......@@ -810,7 +810,7 @@ pub enum LifetimeParamKind {
810810 Error,
811811}
812812
813#[derive(Debug, Clone, Copy, HashStable_Generic)]
813#[derive(Debug, Clone, Copy, HashStable)]
814814pub enum GenericParamKind<'hir> {
815815 /// A lifetime definition (e.g., `'a: 'b + 'c + 'd`).
816816 Lifetime {
......@@ -827,7 +827,7 @@ pub enum GenericParamKind<'hir> {
827827 },
828828}
829829
830#[derive(Debug, Clone, Copy, HashStable_Generic)]
830#[derive(Debug, Clone, Copy, HashStable)]
831831pub struct GenericParam<'hir> {
832832 #[stable_hasher(ignore)]
833833 pub hir_id: HirId,
......@@ -866,7 +866,7 @@ impl<'hir> GenericParam<'hir> {
866866/// early-bound (but can be a late-bound lifetime in functions, for example),
867867/// or from a `for<...>` binder, in which case it's late-bound (and notably,
868868/// does not show up in the parent item's generics).
869#[derive(Debug, Clone, Copy, HashStable_Generic)]
869#[derive(Debug, Clone, Copy, HashStable)]
870870pub enum GenericParamSource {
871871 // Early or late-bound parameters defined on an item
872872 Generics,
......@@ -884,7 +884,7 @@ pub struct GenericParamCount {
884884
885885/// Represents lifetimes and type parameters attached to a declaration
886886/// of a function, enum, trait, etc.
887#[derive(Debug, Clone, Copy, HashStable_Generic)]
887#[derive(Debug, Clone, Copy, HashStable)]
888888pub struct Generics<'hir> {
889889 pub params: &'hir [GenericParam<'hir>],
890890 pub predicates: &'hir [WherePredicate<'hir>],
......@@ -1091,7 +1091,7 @@ impl<'hir> Generics<'hir> {
10911091}
10921092
10931093/// A single predicate in a where-clause.
1094#[derive(Debug, Clone, Copy, HashStable_Generic)]
1094#[derive(Debug, Clone, Copy, HashStable)]
10951095pub struct WherePredicate<'hir> {
10961096 #[stable_hasher(ignore)]
10971097 pub hir_id: HirId,
......@@ -1100,7 +1100,7 @@ pub struct WherePredicate<'hir> {
11001100}
11011101
11021102/// The kind of a single predicate in a where-clause.
1103#[derive(Debug, Clone, Copy, HashStable_Generic)]
1103#[derive(Debug, Clone, Copy, HashStable)]
11041104pub enum WherePredicateKind<'hir> {
11051105 /// A type bound (e.g., `for<'c> Foo: Send + Clone + 'c`).
11061106 BoundPredicate(WhereBoundPredicate<'hir>),
......@@ -1128,7 +1128,7 @@ impl<'hir> WherePredicateKind<'hir> {
11281128 }
11291129}
11301130
1131#[derive(Copy, Clone, Debug, HashStable_Generic, PartialEq, Eq)]
1131#[derive(Copy, Clone, Debug, HashStable, PartialEq, Eq)]
11321132pub enum PredicateOrigin {
11331133 WhereClause,
11341134 GenericParam,
......@@ -1136,7 +1136,7 @@ pub enum PredicateOrigin {
11361136}
11371137
11381138/// A type bound (e.g., `for<'c> Foo: Send + Clone + 'c`).
1139#[derive(Debug, Clone, Copy, HashStable_Generic)]
1139#[derive(Debug, Clone, Copy, HashStable)]
11401140pub struct WhereBoundPredicate<'hir> {
11411141 /// Origin of the predicate.
11421142 pub origin: PredicateOrigin,
......@@ -1156,7 +1156,7 @@ impl<'hir> WhereBoundPredicate<'hir> {
11561156}
11571157
11581158/// A lifetime predicate (e.g., `'a: 'b + 'c`).
1159#[derive(Debug, Clone, Copy, HashStable_Generic)]
1159#[derive(Debug, Clone, Copy, HashStable)]
11601160pub struct WhereRegionPredicate<'hir> {
11611161 pub in_where_clause: bool,
11621162 pub lifetime: &'hir Lifetime,
......@@ -1171,7 +1171,7 @@ impl<'hir> WhereRegionPredicate<'hir> {
11711171}
11721172
11731173/// An equality predicate (e.g., `T = int`); currently unsupported.
1174#[derive(Debug, Clone, Copy, HashStable_Generic)]
1174#[derive(Debug, Clone, Copy, HashStable)]
11751175pub struct WhereEqPredicate<'hir> {
11761176 pub lhs_ty: &'hir Ty<'hir>,
11771177 pub rhs_ty: &'hir Ty<'hir>,
......@@ -1187,7 +1187,7 @@ pub struct ParentedNode<'tcx> {
11871187}
11881188
11891189/// Arguments passed to an attribute macro.
1190#[derive(Clone, Debug, HashStable_Generic, Encodable, Decodable)]
1190#[derive(Clone, Debug, HashStable, Encodable, Decodable)]
11911191pub enum AttrArgs {
11921192 /// No arguments: `#[attr]`.
11931193 Empty,
......@@ -1202,7 +1202,7 @@ pub enum AttrArgs {
12021202 },
12031203}
12041204
1205#[derive(Clone, Debug, HashStable_Generic, Encodable, Decodable)]
1205#[derive(Clone, Debug, HashStable, Encodable, Decodable)]
12061206pub struct AttrPath {
12071207 pub segments: Box<[Symbol]>,
12081208 pub span: Span,
......@@ -1238,7 +1238,7 @@ impl fmt::Display for AttrPath {
12381238 }
12391239}
12401240
1241#[derive(Clone, Debug, HashStable_Generic, Encodable, Decodable)]
1241#[derive(Clone, Debug, HashStable, Encodable, Decodable)]
12421242pub struct AttrItem {
12431243 // Not lowered to hir::Path because we have no NodeId to resolve to.
12441244 pub path: AttrPath,
......@@ -1251,7 +1251,7 @@ pub struct AttrItem {
12511251 pub span: Span,
12521252}
12531253
1254/// The derived implementation of [`HashStable_Generic`] on [`Attribute`]s shouldn't hash
1254/// The derived implementation of [`HashStable`] on [`Attribute`]s shouldn't hash
12551255/// [`AttrId`]s. By wrapping them in this, we make sure we never do.
12561256#[derive(Copy, Debug, Encodable, Decodable, Clone)]
12571257pub struct HashIgnoredAttrId {
......@@ -1260,7 +1260,7 @@ pub struct HashIgnoredAttrId {
12601260
12611261/// Many functions on this type have their documentation in the [`AttributeExt`] trait,
12621262/// since they defer their implementation directly to that trait.
1263#[derive(Clone, Debug, Encodable, Decodable, HashStable_Generic)]
1263#[derive(Clone, Debug, Encodable, Decodable, HashStable)]
12641264pub enum Attribute {
12651265 /// A parsed built-in attribute.
12661266 ///
......@@ -1619,7 +1619,7 @@ impl fmt::Debug for OwnerNodes<'_> {
16191619}
16201620
16211621/// Full information resulting from lowering an AST node.
1622#[derive(Debug, HashStable_Generic)]
1622#[derive(Debug, HashStable)]
16231623pub struct OwnerInfo<'hir> {
16241624 /// Contents of the HIR.
16251625 pub nodes: OwnerNodes<'hir>,
......@@ -1647,7 +1647,7 @@ impl<'tcx> OwnerInfo<'tcx> {
16471647 }
16481648}
16491649
1650#[derive(Copy, Clone, Debug, HashStable_Generic)]
1650#[derive(Copy, Clone, Debug, HashStable)]
16511651pub enum MaybeOwner<'tcx> {
16521652 Owner(&'tcx OwnerInfo<'tcx>),
16531653 NonOwner(HirId),
......@@ -1668,7 +1668,7 @@ impl<'tcx> MaybeOwner<'tcx> {
16681668 }
16691669}
16701670
1671#[derive(Debug, Clone, Copy, HashStable_Generic)]
1671#[derive(Debug, Clone, Copy, HashStable)]
16721672pub struct Closure<'hir> {
16731673 pub def_id: LocalDefId,
16741674 pub binder: ClosureBinder,
......@@ -1684,7 +1684,7 @@ pub struct Closure<'hir> {
16841684 pub kind: ClosureKind,
16851685}
16861686
1687#[derive(Clone, PartialEq, Eq, Debug, Copy, Hash, HashStable_Generic, Encodable, Decodable)]
1687#[derive(Clone, PartialEq, Eq, Debug, Copy, Hash, HashStable, Encodable, Decodable)]
16881688pub enum ClosureKind {
16891689 /// This is a plain closure expression.
16901690 Closure,
......@@ -1703,7 +1703,7 @@ pub enum ClosureKind {
17031703/// A block of statements `{ .. }`, which may have a label (in this case the
17041704/// `targeted_by_break` field will be `true`) and may be `unsafe` by means of
17051705/// the `rules` being anything but `DefaultBlock`.
1706#[derive(Debug, Clone, Copy, HashStable_Generic)]
1706#[derive(Debug, Clone, Copy, HashStable)]
17071707pub struct Block<'hir> {
17081708 /// Statements in a block.
17091709 pub stmts: &'hir [Stmt<'hir>],
......@@ -1732,13 +1732,13 @@ impl<'hir> Block<'hir> {
17321732 }
17331733}
17341734
1735#[derive(Debug, Clone, Copy, HashStable_Generic)]
1735#[derive(Debug, Clone, Copy, HashStable)]
17361736pub struct TyFieldPath {
17371737 pub variant: Option<Ident>,
17381738 pub field: Ident,
17391739}
17401740
1741#[derive(Debug, Clone, Copy, HashStable_Generic)]
1741#[derive(Debug, Clone, Copy, HashStable)]
17421742pub struct TyPat<'hir> {
17431743 #[stable_hasher(ignore)]
17441744 pub hir_id: HirId,
......@@ -1746,7 +1746,7 @@ pub struct TyPat<'hir> {
17461746 pub span: Span,
17471747}
17481748
1749#[derive(Debug, Clone, Copy, HashStable_Generic)]
1749#[derive(Debug, Clone, Copy, HashStable)]
17501750pub struct Pat<'hir> {
17511751 #[stable_hasher(ignore)]
17521752 pub hir_id: HirId,
......@@ -1894,7 +1894,7 @@ impl<'hir> Pat<'hir> {
18941894/// Patterns like the fields of Foo `{ x, ref y, ref mut z }`
18951895/// are treated the same as` x: x, y: ref y, z: ref mut z`,
18961896/// except `is_shorthand` is true.
1897#[derive(Debug, Clone, Copy, HashStable_Generic)]
1897#[derive(Debug, Clone, Copy, HashStable)]
18981898pub struct PatField<'hir> {
18991899 #[stable_hasher(ignore)]
19001900 pub hir_id: HirId,
......@@ -1906,7 +1906,7 @@ pub struct PatField<'hir> {
19061906 pub span: Span,
19071907}
19081908
1909#[derive(Copy, Clone, PartialEq, Debug, HashStable_Generic, Hash, Eq, Encodable, Decodable)]
1909#[derive(Copy, Clone, PartialEq, Debug, HashStable, Hash, Eq, Encodable, Decodable)]
19101910pub enum RangeEnd {
19111911 Included,
19121912 Excluded,
......@@ -1924,7 +1924,7 @@ impl fmt::Display for RangeEnd {
19241924// Equivalent to `Option<usize>`. That type takes up 16 bytes on 64-bit, but
19251925// this type only takes up 4 bytes, at the cost of being restricted to a
19261926// maximum value of `u32::MAX - 1`. In practice, this is more than enough.
1927#[derive(Clone, Copy, PartialEq, Eq, Hash, HashStable_Generic)]
1927#[derive(Clone, Copy, PartialEq, Eq, Hash, HashStable)]
19281928pub struct DotDotPos(u32);
19291929
19301930impl DotDotPos {
......@@ -1950,7 +1950,7 @@ impl fmt::Debug for DotDotPos {
19501950 }
19511951}
19521952
1953#[derive(Debug, Clone, Copy, HashStable_Generic)]
1953#[derive(Debug, Clone, Copy, HashStable)]
19541954pub struct PatExpr<'hir> {
19551955 #[stable_hasher(ignore)]
19561956 pub hir_id: HirId,
......@@ -1958,7 +1958,7 @@ pub struct PatExpr<'hir> {
19581958 pub kind: PatExprKind<'hir>,
19591959}
19601960
1961#[derive(Debug, Clone, Copy, HashStable_Generic)]
1961#[derive(Debug, Clone, Copy, HashStable)]
19621962pub enum PatExprKind<'hir> {
19631963 Lit {
19641964 lit: Lit,
......@@ -1968,7 +1968,7 @@ pub enum PatExprKind<'hir> {
19681968 Path(QPath<'hir>),
19691969}
19701970
1971#[derive(Debug, Clone, Copy, HashStable_Generic)]
1971#[derive(Debug, Clone, Copy, HashStable)]
19721972pub enum TyPatKind<'hir> {
19731973 /// A range pattern (e.g., `1..=2` or `1..2`).
19741974 Range(&'hir ConstArg<'hir>, &'hir ConstArg<'hir>),
......@@ -1983,7 +1983,7 @@ pub enum TyPatKind<'hir> {
19831983 Err(ErrorGuaranteed),
19841984}
19851985
1986#[derive(Debug, Clone, Copy, HashStable_Generic)]
1986#[derive(Debug, Clone, Copy, HashStable)]
19871987pub enum PatKind<'hir> {
19881988 /// A missing pattern, e.g. for an anonymous param in a bare fn like `fn f(u32)`.
19891989 Missing,
......@@ -2058,7 +2058,7 @@ pub enum PatKind<'hir> {
20582058}
20592059
20602060/// A statement.
2061#[derive(Debug, Clone, Copy, HashStable_Generic)]
2061#[derive(Debug, Clone, Copy, HashStable)]
20622062pub struct Stmt<'hir> {
20632063 #[stable_hasher(ignore)]
20642064 pub hir_id: HirId,
......@@ -2067,7 +2067,7 @@ pub struct Stmt<'hir> {
20672067}
20682068
20692069/// The contents of a statement.
2070#[derive(Debug, Clone, Copy, HashStable_Generic)]
2070#[derive(Debug, Clone, Copy, HashStable)]
20712071pub enum StmtKind<'hir> {
20722072 /// A local (`let`) binding.
20732073 Let(&'hir LetStmt<'hir>),
......@@ -2083,7 +2083,7 @@ pub enum StmtKind<'hir> {
20832083}
20842084
20852085/// Represents a `let` statement (i.e., `let <pat>:<ty> = <init>;`).
2086#[derive(Debug, Clone, Copy, HashStable_Generic)]
2086#[derive(Debug, Clone, Copy, HashStable)]
20872087pub struct LetStmt<'hir> {
20882088 /// Span of `super` in `super let`.
20892089 pub super_: Option<Span>,
......@@ -2105,7 +2105,7 @@ pub struct LetStmt<'hir> {
21052105
21062106/// Represents a single arm of a `match` expression, e.g.
21072107/// `<pat> (if <guard>) => <body>`.
2108#[derive(Debug, Clone, Copy, HashStable_Generic)]
2108#[derive(Debug, Clone, Copy, HashStable)]
21092109pub struct Arm<'hir> {
21102110 #[stable_hasher(ignore)]
21112111 pub hir_id: HirId,
......@@ -2123,7 +2123,7 @@ pub struct Arm<'hir> {
21232123///
21242124/// In an `if let`, imagine it as `if (let <pat> = <expr>) { ... }`; in a let-else, it is part of
21252125/// the desugaring to if-let. Only let-else supports the type annotation at present.
2126#[derive(Debug, Clone, Copy, HashStable_Generic)]
2126#[derive(Debug, Clone, Copy, HashStable)]
21272127pub struct LetExpr<'hir> {
21282128 pub span: Span,
21292129 pub pat: &'hir Pat<'hir>,
......@@ -2134,7 +2134,7 @@ pub struct LetExpr<'hir> {
21342134 pub recovered: ast::Recovered,
21352135}
21362136
2137#[derive(Debug, Clone, Copy, HashStable_Generic)]
2137#[derive(Debug, Clone, Copy, HashStable)]
21382138pub struct ExprField<'hir> {
21392139 #[stable_hasher(ignore)]
21402140 pub hir_id: HirId,
......@@ -2144,19 +2144,19 @@ pub struct ExprField<'hir> {
21442144 pub is_shorthand: bool,
21452145}
21462146
2147#[derive(Copy, Clone, PartialEq, Debug, HashStable_Generic)]
2147#[derive(Copy, Clone, PartialEq, Debug, HashStable)]
21482148pub enum BlockCheckMode {
21492149 DefaultBlock,
21502150 UnsafeBlock(UnsafeSource),
21512151}
21522152
2153#[derive(Copy, Clone, PartialEq, Debug, HashStable_Generic)]
2153#[derive(Copy, Clone, PartialEq, Debug, HashStable)]
21542154pub enum UnsafeSource {
21552155 CompilerGenerated,
21562156 UserProvided,
21572157}
21582158
2159#[derive(Copy, Clone, PartialEq, Eq, Hash, Debug, HashStable_Generic)]
2159#[derive(Copy, Clone, PartialEq, Eq, Hash, Debug, HashStable)]
21602160pub struct BodyId {
21612161 pub hir_id: HirId,
21622162}
......@@ -2182,7 +2182,7 @@ pub struct BodyId {
21822182///
21832183/// All bodies have an **owner**, which can be accessed via the HIR
21842184/// map using `body_owner_def_id()`.
2185#[derive(Debug, Clone, Copy, HashStable_Generic)]
2185#[derive(Debug, Clone, Copy, HashStable)]
21862186pub struct Body<'hir> {
21872187 pub params: &'hir [Param<'hir>],
21882188 pub value: &'hir Expr<'hir>,
......@@ -2195,7 +2195,7 @@ impl<'hir> Body<'hir> {
21952195}
21962196
21972197/// The type of source expression that caused this coroutine to be created.
2198#[derive(Clone, PartialEq, Eq, Debug, Copy, Hash, HashStable_Generic, Encodable, Decodable)]
2198#[derive(Clone, PartialEq, Eq, Debug, Copy, Hash, HashStable, Encodable, Decodable)]
21992199pub enum CoroutineKind {
22002200 /// A coroutine that comes from a desugaring.
22012201 Desugared(CoroutineDesugaring, CoroutineSource),
......@@ -2245,7 +2245,7 @@ impl fmt::Display for CoroutineKind {
22452245///
22462246/// This helps error messages but is also used to drive coercions in
22472247/// type-checking (see #60424).
2248#[derive(Clone, PartialEq, Eq, Hash, Debug, Copy, HashStable_Generic, Encodable, Decodable)]
2248#[derive(Clone, PartialEq, Eq, Hash, Debug, Copy, HashStable, Encodable, Decodable)]
22492249pub enum CoroutineSource {
22502250 /// An explicit `async`/`gen` block written by the user.
22512251 Block,
......@@ -2268,7 +2268,7 @@ impl fmt::Display for CoroutineSource {
22682268 }
22692269}
22702270
2271#[derive(Clone, PartialEq, Eq, Debug, Copy, Hash, HashStable_Generic, Encodable, Decodable)]
2271#[derive(Clone, PartialEq, Eq, Debug, Copy, Hash, HashStable, Encodable, Decodable)]
22722272pub enum CoroutineDesugaring {
22732273 /// An explicit `async` block or the body of an `async` function.
22742274 Async,
......@@ -2408,7 +2408,7 @@ pub type Lit = Spanned<LitKind>;
24082408///
24092409/// You can check if this anon const is a default in a const param
24102410/// `const N: usize = { ... }` with `tcx.hir_opt_const_param_default_param_def_id(..)`
2411#[derive(Copy, Clone, Debug, HashStable_Generic)]
2411#[derive(Copy, Clone, Debug, HashStable)]
24122412pub struct AnonConst {
24132413 #[stable_hasher(ignore)]
24142414 pub hir_id: HirId,
......@@ -2418,7 +2418,7 @@ pub struct AnonConst {
24182418}
24192419
24202420/// An inline constant expression `const { something }`.
2421#[derive(Copy, Clone, Debug, HashStable_Generic)]
2421#[derive(Copy, Clone, Debug, HashStable)]
24222422pub struct ConstBlock {
24232423 #[stable_hasher(ignore)]
24242424 pub hir_id: HirId,
......@@ -2434,7 +2434,7 @@ pub struct ConstBlock {
24342434/// the compiler and the reference.
24352435///
24362436/// [rust lang reference]: https://doc.rust-lang.org/reference/expressions.html
2437#[derive(Debug, Clone, Copy, HashStable_Generic)]
2437#[derive(Debug, Clone, Copy, HashStable)]
24382438pub struct Expr<'hir> {
24392439 #[stable_hasher(ignore)]
24402440 pub hir_id: HirId,
......@@ -2793,7 +2793,7 @@ pub fn expr_needs_parens(expr: &Expr<'_>) -> bool {
27932793 }
27942794}
27952795
2796#[derive(Debug, Clone, Copy, HashStable_Generic)]
2796#[derive(Debug, Clone, Copy, HashStable)]
27972797pub enum ExprKind<'hir> {
27982798 /// Allow anonymous constants from an inline `const` block
27992799 ConstBlock(ConstBlock),
......@@ -2932,7 +2932,7 @@ pub enum ExprKind<'hir> {
29322932 Err(rustc_span::ErrorGuaranteed),
29332933}
29342934
2935#[derive(Debug, Clone, Copy, HashStable_Generic)]
2935#[derive(Debug, Clone, Copy, HashStable)]
29362936pub enum StructTailExpr<'hir> {
29372937 /// A struct expression where all the fields are explicitly enumerated: `Foo { a, b }`.
29382938 None,
......@@ -2956,7 +2956,7 @@ pub enum StructTailExpr<'hir> {
29562956/// To resolve the path to a `DefId`, call [`qpath_res`].
29572957///
29582958/// [`qpath_res`]: ../../rustc_middle/ty/struct.TypeckResults.html#method.qpath_res
2959#[derive(Debug, Clone, Copy, HashStable_Generic)]
2959#[derive(Debug, Clone, Copy, HashStable)]
29602960pub enum QPath<'hir> {
29612961 /// Path to a definition, optionally "fully-qualified" with a `Self`
29622962 /// type, if the path points to an associated item in a trait.
......@@ -2995,7 +2995,7 @@ impl<'hir> QPath<'hir> {
29952995}
29962996
29972997/// Hints at the original code for a let statement.
2998#[derive(Copy, Clone, Debug, HashStable_Generic)]
2998#[derive(Copy, Clone, Debug, HashStable)]
29992999pub enum LocalSource {
30003000 /// A `match _ { .. }`.
30013001 Normal,
......@@ -3019,7 +3019,7 @@ pub enum LocalSource {
30193019}
30203020
30213021/// Hints at the original code for a `match _ { .. }`.
3022#[derive(Copy, Clone, PartialEq, Eq, Hash, Debug, HashStable_Generic, Encodable, Decodable)]
3022#[derive(Copy, Clone, PartialEq, Eq, Hash, Debug, HashStable, Encodable, Decodable)]
30233023pub enum MatchSource {
30243024 /// A `match _ { .. }`.
30253025 Normal,
......@@ -3051,7 +3051,7 @@ impl MatchSource {
30513051}
30523052
30533053/// The loop type that yielded an `ExprKind::Loop`.
3054#[derive(Copy, Clone, PartialEq, Debug, HashStable_Generic)]
3054#[derive(Copy, Clone, PartialEq, Debug, HashStable)]
30553055pub enum LoopSource {
30563056 /// A `loop { .. }` loop.
30573057 Loop,
......@@ -3071,7 +3071,7 @@ impl LoopSource {
30713071 }
30723072}
30733073
3074#[derive(Copy, Clone, Debug, PartialEq, HashStable_Generic)]
3074#[derive(Copy, Clone, Debug, PartialEq, HashStable)]
30753075pub enum LoopIdError {
30763076 OutsideLoopScope,
30773077 UnlabeledCfInWhileCondition,
......@@ -3090,7 +3090,7 @@ impl fmt::Display for LoopIdError {
30903090 }
30913091}
30923092
3093#[derive(Copy, Clone, Debug, PartialEq, HashStable_Generic)]
3093#[derive(Copy, Clone, Debug, PartialEq, HashStable)]
30943094pub struct Destination {
30953095 /// This is `Some(_)` iff there is an explicit user-specified 'label
30963096 pub label: Option<Label>,
......@@ -3101,7 +3101,7 @@ pub struct Destination {
31013101}
31023102
31033103/// The yield kind that caused an `ExprKind::Yield`.
3104#[derive(Copy, Clone, Debug, HashStable_Generic)]
3104#[derive(Copy, Clone, Debug, HashStable)]
31053105pub enum YieldSource {
31063106 /// An `<expr>.await`.
31073107 Await { expr: Option<HirId> },
......@@ -3120,7 +3120,7 @@ impl fmt::Display for YieldSource {
31203120
31213121// N.B., if you change this, you'll probably want to change the corresponding
31223122// type structure in middle/ty.rs as well.
3123#[derive(Debug, Clone, Copy, HashStable_Generic)]
3123#[derive(Debug, Clone, Copy, HashStable)]
31243124pub struct MutTy<'hir> {
31253125 pub ty: &'hir Ty<'hir>,
31263126 pub mutbl: Mutability,
......@@ -3128,7 +3128,7 @@ pub struct MutTy<'hir> {
31283128
31293129/// Represents a function's signature in a trait declaration,
31303130/// trait implementation, or a free function.
3131#[derive(Debug, Clone, Copy, HashStable_Generic)]
3131#[derive(Debug, Clone, Copy, HashStable)]
31323132pub struct FnSig<'hir> {
31333133 pub header: FnHeader,
31343134 pub decl: &'hir FnDecl<'hir>,
......@@ -3138,7 +3138,7 @@ pub struct FnSig<'hir> {
31383138// The bodies for items are stored "out of line", in a separate
31393139// hashmap in the `Crate`. Here we just record the hir-id of the item
31403140// so it can fetched later.
3141#[derive(Copy, Clone, PartialEq, Eq, Encodable, Decodable, Debug, HashStable_Generic)]
3141#[derive(Copy, Clone, PartialEq, Eq, Encodable, Decodable, Debug, HashStable)]
31423142pub struct TraitItemId {
31433143 pub owner_id: OwnerId,
31443144}
......@@ -3155,7 +3155,7 @@ impl TraitItemId {
31553155/// possibly including a default implementation. A trait item is
31563156/// either required (meaning it doesn't have an implementation, just a
31573157/// signature) or provided (meaning it has a default implementation).
3158#[derive(Debug, Clone, Copy, HashStable_Generic)]
3158#[derive(Debug, Clone, Copy, HashStable)]
31593159pub struct TraitItem<'hir> {
31603160 pub ident: Ident,
31613161 pub owner_id: OwnerId,
......@@ -3219,7 +3219,7 @@ impl<'hir> TraitItem<'hir> {
32193219}
32203220
32213221/// Represents a trait method's body (or just argument names).
3222#[derive(Debug, Clone, Copy, HashStable_Generic)]
3222#[derive(Debug, Clone, Copy, HashStable)]
32233223pub enum TraitFn<'hir> {
32243224 /// No default body in the trait, just a signature.
32253225 Required(&'hir [Option<Ident>]),
......@@ -3228,7 +3228,7 @@ pub enum TraitFn<'hir> {
32283228 Provided(BodyId),
32293229}
32303230
3231#[derive(Debug, Clone, Copy, PartialEq, Eq, HashStable_Generic)]
3231#[derive(Debug, Clone, Copy, PartialEq, Eq, HashStable)]
32323232pub enum IsTypeConst {
32333233 No,
32343234 Yes,
......@@ -3247,7 +3247,7 @@ impl From<IsTypeConst> for bool {
32473247}
32483248
32493249/// Represents a trait method or associated constant or type
3250#[derive(Debug, Clone, Copy, HashStable_Generic)]
3250#[derive(Debug, Clone, Copy, HashStable)]
32513251pub enum TraitItemKind<'hir> {
32523252 // FIXME(mgca) eventually want to move the option that is around `ConstItemRhs<'hir>`
32533253 // into `ConstItemRhs`, much like `ast::ConstItemRhsKind`, but for now mark whether
......@@ -3264,7 +3264,7 @@ pub enum TraitItemKind<'hir> {
32643264// The bodies for items are stored "out of line", in a separate
32653265// hashmap in the `Crate`. Here we just record the hir-id of the item
32663266// so it can fetched later.
3267#[derive(Copy, Clone, PartialEq, Eq, Encodable, Decodable, Debug, HashStable_Generic)]
3267#[derive(Copy, Clone, PartialEq, Eq, Encodable, Decodable, Debug, HashStable)]
32683268pub struct ImplItemId {
32693269 pub owner_id: OwnerId,
32703270}
......@@ -3280,7 +3280,7 @@ impl ImplItemId {
32803280/// Represents an associated item within an impl block.
32813281///
32823282/// Refer to [`Impl`] for an impl block declaration.
3283#[derive(Debug, Clone, Copy, HashStable_Generic)]
3283#[derive(Debug, Clone, Copy, HashStable)]
32843284pub struct ImplItem<'hir> {
32853285 pub ident: Ident,
32863286 pub owner_id: OwnerId,
......@@ -3291,7 +3291,7 @@ pub struct ImplItem<'hir> {
32913291 pub has_delayed_lints: bool,
32923292}
32933293
3294#[derive(Debug, Clone, Copy, HashStable_Generic)]
3294#[derive(Debug, Clone, Copy, HashStable)]
32953295pub enum ImplItemImplKind {
32963296 Inherent {
32973297 vis_span: Span,
......@@ -3329,7 +3329,7 @@ impl<'hir> ImplItem<'hir> {
33293329}
33303330
33313331/// Represents various kinds of content within an `impl`.
3332#[derive(Debug, Clone, Copy, HashStable_Generic)]
3332#[derive(Debug, Clone, Copy, HashStable)]
33333333pub enum ImplItemKind<'hir> {
33343334 /// An associated constant of the given type, set to the constant result
33353335 /// of the expression.
......@@ -3350,7 +3350,7 @@ pub enum ImplItemKind<'hir> {
33503350/// * the `RetTy` in `Trait(ArgTy, ArgTy) -> RetTy`
33513351/// * the `C = { Ct }` in `Trait<C = { Ct }>` (feature `min_generic_const_args`)
33523352/// * the `f(..): Bound` in `Trait<f(..): Bound>` (feature `return_type_notation`)
3353#[derive(Debug, Clone, Copy, HashStable_Generic)]
3353#[derive(Debug, Clone, Copy, HashStable)]
33543354pub struct AssocItemConstraint<'hir> {
33553355 #[stable_hasher(ignore)]
33563356 pub hir_id: HirId,
......@@ -3378,7 +3378,7 @@ impl<'hir> AssocItemConstraint<'hir> {
33783378 }
33793379}
33803380
3381#[derive(Debug, Clone, Copy, HashStable_Generic)]
3381#[derive(Debug, Clone, Copy, HashStable)]
33823382pub enum Term<'hir> {
33833383 Ty(&'hir Ty<'hir>),
33843384 Const(&'hir ConstArg<'hir>),
......@@ -3397,7 +3397,7 @@ impl<'hir> From<&'hir ConstArg<'hir>> for Term<'hir> {
33973397}
33983398
33993399/// The kind of [associated item constraint][AssocItemConstraint].
3400#[derive(Debug, Clone, Copy, HashStable_Generic)]
3400#[derive(Debug, Clone, Copy, HashStable)]
34013401pub enum AssocItemConstraintKind<'hir> {
34023402 /// An equality constraint for an associated item (e.g., `AssocTy = Ty` in `Trait<AssocTy = Ty>`).
34033403 ///
......@@ -3422,14 +3422,14 @@ impl<'hir> AssocItemConstraintKind<'hir> {
34223422/// An uninhabited enum used to make `Infer` variants on [`Ty`] and [`ConstArg`] be
34233423/// unreachable. Zero-Variant enums are guaranteed to have the same layout as the never
34243424/// type.
3425#[derive(Debug, Clone, Copy, HashStable_Generic)]
3425#[derive(Debug, Clone, Copy, HashStable)]
34263426pub enum AmbigArg {}
34273427
34283428/// Represents a type in the `HIR`.
34293429///
34303430/// For an explanation of the `Unambig` generic parameter see the dev-guide:
34313431/// <https://rustc-dev-guide.rust-lang.org/ambig-unambig-ty-and-consts.html>
3432#[derive(Debug, Clone, Copy, HashStable_Generic)]
3432#[derive(Debug, Clone, Copy, HashStable)]
34333433#[repr(C)]
34343434pub struct Ty<'hir, Unambig = ()> {
34353435 #[stable_hasher(ignore)]
......@@ -3569,7 +3569,7 @@ impl<'hir> Ty<'hir> {
35693569}
35703570
35713571/// Not represented directly in the AST; referred to by name through a `ty_path`.
3572#[derive(Copy, Clone, PartialEq, Eq, Encodable, Decodable, Hash, Debug, HashStable_Generic)]
3572#[derive(Copy, Clone, PartialEq, Eq, Encodable, Decodable, Hash, Debug, HashStable)]
35733573pub enum PrimTy {
35743574 Int(IntTy),
35753575 Uint(UintTy),
......@@ -3659,7 +3659,7 @@ impl PrimTy {
36593659 }
36603660}
36613661
3662#[derive(Debug, Clone, Copy, HashStable_Generic)]
3662#[derive(Debug, Clone, Copy, HashStable)]
36633663pub struct FnPtrTy<'hir> {
36643664 pub safety: Safety,
36653665 pub abi: ExternAbi,
......@@ -3670,13 +3670,13 @@ pub struct FnPtrTy<'hir> {
36703670 pub param_idents: &'hir [Option<Ident>],
36713671}
36723672
3673#[derive(Debug, Clone, Copy, HashStable_Generic)]
3673#[derive(Debug, Clone, Copy, HashStable)]
36743674pub struct UnsafeBinderTy<'hir> {
36753675 pub generic_params: &'hir [GenericParam<'hir>],
36763676 pub inner_ty: &'hir Ty<'hir>,
36773677}
36783678
3679#[derive(Debug, Clone, Copy, HashStable_Generic)]
3679#[derive(Debug, Clone, Copy, HashStable)]
36803680pub struct OpaqueTy<'hir> {
36813681 #[stable_hasher(ignore)]
36823682 pub hir_id: HirId,
......@@ -3686,7 +3686,7 @@ pub struct OpaqueTy<'hir> {
36863686 pub span: Span,
36873687}
36883688
3689#[derive(Debug, Clone, Copy, HashStable_Generic, Encodable, Decodable)]
3689#[derive(Debug, Clone, Copy, HashStable, Encodable, Decodable)]
36903690pub enum PreciseCapturingArgKind<T, U> {
36913691 Lifetime(T),
36923692 /// Non-lifetime argument (type or const)
......@@ -3716,7 +3716,7 @@ impl PreciseCapturingArg<'_> {
37163716/// resolution to. Lifetimes don't have this problem, and for them, it's actually
37173717/// kind of detrimental to use a custom node type versus just using [`Lifetime`],
37183718/// since resolve_bound_vars operates on `Lifetime`s.
3719#[derive(Debug, Clone, Copy, HashStable_Generic)]
3719#[derive(Debug, Clone, Copy, HashStable)]
37203720pub struct PreciseCapturingNonLifetimeArg {
37213721 #[stable_hasher(ignore)]
37223722 pub hir_id: HirId,
......@@ -3725,7 +3725,7 @@ pub struct PreciseCapturingNonLifetimeArg {
37253725}
37263726
37273727#[derive(Copy, Clone, PartialEq, Eq, Debug)]
3728#[derive(HashStable_Generic, Encodable, Decodable)]
3728#[derive(HashStable, Encodable, Decodable)]
37293729pub enum RpitContext {
37303730 Trait,
37313731 TraitImpl,
......@@ -3733,7 +3733,7 @@ pub enum RpitContext {
37333733
37343734/// From whence the opaque type came.
37353735#[derive(Copy, Clone, PartialEq, Eq, Debug)]
3736#[derive(HashStable_Generic, Encodable, Decodable)]
3736#[derive(HashStable, Encodable, Decodable)]
37373737pub enum OpaqueTyOrigin<D> {
37383738 /// `-> impl Trait`
37393739 FnReturn {
......@@ -3759,7 +3759,7 @@ pub enum OpaqueTyOrigin<D> {
37593759}
37603760
37613761// Ids of parent (or child) path segment that contains user-specified args
3762#[derive(Debug, Clone, Copy, PartialEq, Eq, HashStable_Generic)]
3762#[derive(Debug, Clone, Copy, PartialEq, Eq, HashStable)]
37633763pub struct DelegationGenerics {
37643764 pub parent_args_segment_id: Option<HirId>,
37653765 pub child_args_segment_id: Option<HirId>,
......@@ -3767,14 +3767,14 @@ pub struct DelegationGenerics {
37673767 pub propagate_self_ty: bool,
37683768}
37693769
3770#[derive(Debug, Clone, Copy, PartialEq, Eq, HashStable_Generic)]
3770#[derive(Debug, Clone, Copy, PartialEq, Eq, HashStable)]
37713771pub enum InferDelegationSig<'hir> {
37723772 Input(usize),
37733773 // Place generics info here, as we always specify output type for delegations.
37743774 Output(&'hir DelegationGenerics),
37753775}
37763776
3777#[derive(Debug, Clone, Copy, PartialEq, Eq, HashStable_Generic)]
3777#[derive(Debug, Clone, Copy, PartialEq, Eq, HashStable)]
37783778pub enum InferDelegation<'hir> {
37793779 /// Infer the type of this `DefId` through `tcx.type_of(def_id).instantiate_identity()`,
37803780 /// used for const types propagation.
......@@ -3789,7 +3789,7 @@ pub enum InferDelegation<'hir> {
37893789/// <https://rustc-dev-guide.rust-lang.org/ambig-unambig-ty-and-consts.html>
37903790// SAFETY: `repr(u8)` is required so that `TyKind<()>` and `TyKind<!>` are layout compatible
37913791#[repr(u8, C)]
3792#[derive(Debug, Clone, Copy, HashStable_Generic)]
3792#[derive(Debug, Clone, Copy, HashStable)]
37933793pub enum TyKind<'hir, Unambig = ()> {
37943794 /// Actual type should be inherited from `DefId` signature
37953795 InferDelegation(InferDelegation<'hir>),
......@@ -3840,7 +3840,7 @@ pub enum TyKind<'hir, Unambig = ()> {
38403840 Infer(Unambig),
38413841}
38423842
3843#[derive(Debug, Clone, Copy, HashStable_Generic)]
3843#[derive(Debug, Clone, Copy, HashStable)]
38443844pub enum InlineAsmOperand<'hir> {
38453845 In {
38463846 reg: InlineAsmRegOrRegClass,
......@@ -3899,7 +3899,7 @@ impl<'hir> InlineAsmOperand<'hir> {
38993899 }
39003900}
39013901
3902#[derive(Debug, Clone, Copy, HashStable_Generic)]
3902#[derive(Debug, Clone, Copy, HashStable)]
39033903pub struct InlineAsm<'hir> {
39043904 pub asm_macro: ast::AsmMacro,
39053905 pub template: &'hir [InlineAsmTemplatePiece],
......@@ -3916,7 +3916,7 @@ impl InlineAsm<'_> {
39163916}
39173917
39183918/// Represents a parameter in a function header.
3919#[derive(Debug, Clone, Copy, HashStable_Generic)]
3919#[derive(Debug, Clone, Copy, HashStable)]
39203920pub struct Param<'hir> {
39213921 #[stable_hasher(ignore)]
39223922 pub hir_id: HirId,
......@@ -3928,7 +3928,7 @@ pub struct Param<'hir> {
39283928/// Contains the packed non-type fields of a function declaration.
39293929// FIXME(splat): add the splatted argument index as a u16
39303930#[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
3931#[derive(Encodable, Decodable, HashStable_Generic)]
3931#[derive(Encodable, Decodable, HashStable)]
39323932pub struct FnDeclFlags {
39333933 /// Holds the c_variadic and lifetime_elision_allowed bitflags, and 3 bits for the `ImplicitSelfKind`.
39343934 flags: u8,
......@@ -4037,7 +4037,7 @@ impl FnDeclFlags {
40374037}
40384038
40394039/// Represents the header (not the body) of a function declaration.
4040#[derive(Debug, Clone, Copy, HashStable_Generic)]
4040#[derive(Debug, Clone, Copy, HashStable)]
40414041pub struct FnDecl<'hir> {
40424042 /// The types of the function's parameters.
40434043 ///
......@@ -4091,7 +4091,7 @@ impl<'hir> FnDecl<'hir> {
40914091}
40924092
40934093/// Represents what type of implicit self a function has, if any.
4094#[derive(Copy, Clone, PartialEq, Eq, Encodable, Decodable, Debug, HashStable_Generic)]
4094#[derive(Copy, Clone, PartialEq, Eq, Encodable, Decodable, Debug, HashStable)]
40954095pub enum ImplicitSelfKind {
40964096 /// Represents a `fn x(self);`.
40974097 Imm,
......@@ -4113,7 +4113,7 @@ impl ImplicitSelfKind {
41134113 }
41144114}
41154115
4116#[derive(Copy, Clone, PartialEq, Eq, Encodable, Decodable, Debug, HashStable_Generic)]
4116#[derive(Copy, Clone, PartialEq, Eq, Encodable, Decodable, Debug, HashStable)]
41174117pub enum IsAsync {
41184118 Async(Span),
41194119 NotAsync,
......@@ -4125,7 +4125,7 @@ impl IsAsync {
41254125 }
41264126}
41274127
4128#[derive(Copy, Clone, PartialEq, Eq, Debug, Encodable, Decodable, HashStable_Generic)]
4128#[derive(Copy, Clone, PartialEq, Eq, Debug, Encodable, Decodable, HashStable)]
41294129#[derive(Default)]
41304130pub enum Defaultness {
41314131 Default {
......@@ -4152,7 +4152,7 @@ impl Defaultness {
41524152 }
41534153}
41544154
4155#[derive(Debug, Clone, Copy, HashStable_Generic)]
4155#[derive(Debug, Clone, Copy, HashStable)]
41564156pub enum FnRetTy<'hir> {
41574157 /// Return type is not specified.
41584158 ///
......@@ -4184,7 +4184,7 @@ impl<'hir> FnRetTy<'hir> {
41844184}
41854185
41864186/// Represents `for<...>` binder before a closure
4187#[derive(Copy, Clone, Debug, HashStable_Generic)]
4187#[derive(Copy, Clone, Debug, HashStable)]
41884188pub enum ClosureBinder {
41894189 /// Binder is not specified.
41904190 Default,
......@@ -4194,13 +4194,13 @@ pub enum ClosureBinder {
41944194 For { span: Span },
41954195}
41964196
4197#[derive(Debug, Clone, Copy, HashStable_Generic)]
4197#[derive(Debug, Clone, Copy, HashStable)]
41984198pub struct Mod<'hir> {
41994199 pub spans: ModSpans,
42004200 pub item_ids: &'hir [ItemId],
42014201}
42024202
4203#[derive(Copy, Clone, Debug, HashStable_Generic)]
4203#[derive(Copy, Clone, Debug, HashStable)]
42044204pub struct ModSpans {
42054205 /// A span from the first token past `{` to the last token until `}`.
42064206 /// For `mod foo;`, the inner span ranges from the first token
......@@ -4209,12 +4209,12 @@ pub struct ModSpans {
42094209 pub inject_use_span: Span,
42104210}
42114211
4212#[derive(Debug, Clone, Copy, HashStable_Generic)]
4212#[derive(Debug, Clone, Copy, HashStable)]
42134213pub struct EnumDef<'hir> {
42144214 pub variants: &'hir [Variant<'hir>],
42154215}
42164216
4217#[derive(Debug, Clone, Copy, HashStable_Generic)]
4217#[derive(Debug, Clone, Copy, HashStable)]
42184218pub struct Variant<'hir> {
42194219 /// Name of the variant.
42204220 pub ident: Ident,
......@@ -4230,7 +4230,7 @@ pub struct Variant<'hir> {
42304230 pub span: Span,
42314231}
42324232
4233#[derive(Copy, Clone, PartialEq, Debug, HashStable_Generic)]
4233#[derive(Copy, Clone, PartialEq, Debug, HashStable)]
42344234pub enum UseKind {
42354235 /// One import, e.g., `use foo::bar` or `use foo::bar as baz`.
42364236 /// Also produced for each element of a list `use`, e.g.
......@@ -4255,7 +4255,7 @@ pub enum UseKind {
42554255/// that the `ref_id` is for. Note that `ref_id`'s value is not the `HirId` of the
42564256/// trait being referred to but just a unique `HirId` that serves as a key
42574257/// within the resolution map.
4258#[derive(Clone, Debug, Copy, HashStable_Generic)]
4258#[derive(Clone, Debug, Copy, HashStable)]
42594259pub struct TraitRef<'hir> {
42604260 pub path: &'hir Path<'hir>,
42614261 // Don't hash the `ref_id`. It is tracked via the thing it is used to access.
......@@ -4274,7 +4274,7 @@ impl TraitRef<'_> {
42744274 }
42754275}
42764276
4277#[derive(Clone, Debug, Copy, HashStable_Generic)]
4277#[derive(Clone, Debug, Copy, HashStable)]
42784278pub struct PolyTraitRef<'hir> {
42794279 /// The `'a` in `for<'a> Foo<&'a T>`.
42804280 pub bound_generic_params: &'hir [GenericParam<'hir>],
......@@ -4290,7 +4290,7 @@ pub struct PolyTraitRef<'hir> {
42904290 pub span: Span,
42914291}
42924292
4293#[derive(Debug, Clone, Copy, HashStable_Generic)]
4293#[derive(Debug, Clone, Copy, HashStable)]
42944294pub struct FieldDef<'hir> {
42954295 pub span: Span,
42964296 pub vis_span: Span,
......@@ -4311,7 +4311,7 @@ impl FieldDef<'_> {
43114311}
43124312
43134313/// Fields and constructor IDs of enum variants and structs.
4314#[derive(Debug, Clone, Copy, HashStable_Generic)]
4314#[derive(Debug, Clone, Copy, HashStable)]
43154315pub enum VariantData<'hir> {
43164316 /// A struct variant.
43174317 ///
......@@ -4365,7 +4365,7 @@ impl<'hir> VariantData<'hir> {
43654365// The bodies for items are stored "out of line", in a separate
43664366// hashmap in the `Crate`. Here we just record the hir-id of the item
43674367// so it can fetched later.
4368#[derive(Copy, Clone, PartialEq, Eq, Encodable, Decodable, Debug, Hash, HashStable_Generic)]
4368#[derive(Copy, Clone, PartialEq, Eq, Encodable, Decodable, Debug, Hash, HashStable)]
43694369pub struct ItemId {
43704370 pub owner_id: OwnerId,
43714371}
......@@ -4386,7 +4386,7 @@ impl ItemId {
43864386/// the compiler and the reference.
43874387///
43884388/// [rust lang reference]: https://doc.rust-lang.org/reference/items.html
4389#[derive(Debug, Clone, Copy, HashStable_Generic)]
4389#[derive(Debug, Clone, Copy, HashStable)]
43904390pub struct Item<'hir> {
43914391 pub owner_id: OwnerId,
43924392 pub kind: ItemKind<'hir>,
......@@ -4479,7 +4479,7 @@ impl<'hir> Item<'hir> {
44794479}
44804480
44814481#[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Debug)]
4482#[derive(Encodable, Decodable, HashStable_Generic, Default)]
4482#[derive(Encodable, Decodable, HashStable, Default)]
44834483pub enum Safety {
44844484 /// This is the default variant, because the compiler messing up
44854485 /// metadata encoding and failing to encode a `Safe` flag, means
......@@ -4521,7 +4521,7 @@ impl fmt::Display for Safety {
45214521 }
45224522}
45234523
4524#[derive(Copy, Clone, PartialEq, Eq, Debug, Encodable, Decodable, HashStable_Generic)]
4524#[derive(Copy, Clone, PartialEq, Eq, Debug, Encodable, Decodable, HashStable)]
45254525#[derive(Default)]
45264526pub enum Constness {
45274527 #[default]
......@@ -4538,13 +4538,13 @@ impl fmt::Display for Constness {
45384538 }
45394539}
45404540
4541#[derive(Debug, Clone, Copy, HashStable_Generic)]
4541#[derive(Debug, Clone, Copy, HashStable)]
45424542pub struct ImplRestriction<'hir> {
45434543 pub kind: RestrictionKind<'hir>,
45444544 pub span: Span,
45454545}
45464546
4547#[derive(Debug, Clone, Copy, HashStable_Generic)]
4547#[derive(Debug, Clone, Copy, HashStable)]
45484548pub enum RestrictionKind<'hir> {
45494549 /// The restriction does not affect the item.
45504550 Unrestricted,
......@@ -4556,7 +4556,7 @@ pub enum RestrictionKind<'hir> {
45564556/// its safety different within the type system to create a
45574557/// "sound by default" system that needs checking this enum
45584558/// explicitly to allow unsafe operations.
4559#[derive(Copy, Clone, Debug, HashStable_Generic, PartialEq, Eq)]
4559#[derive(Copy, Clone, Debug, HashStable, PartialEq, Eq)]
45604560pub enum HeaderSafety {
45614561 /// A safe function annotated with `#[target_features]`.
45624562 /// The type system treats this function as an unsafe function,
......@@ -4573,7 +4573,7 @@ impl From<Safety> for HeaderSafety {
45734573 }
45744574}
45754575
4576#[derive(Copy, Clone, Debug, HashStable_Generic)]
4576#[derive(Copy, Clone, Debug, HashStable)]
45774577pub struct FnHeader {
45784578 pub safety: HeaderSafety,
45794579 pub constness: Constness,
......@@ -4606,7 +4606,7 @@ impl FnHeader {
46064606 }
46074607}
46084608
4609#[derive(Debug, Clone, Copy, HashStable_Generic)]
4609#[derive(Debug, Clone, Copy, HashStable)]
46104610pub enum ItemKind<'hir> {
46114611 /// An `extern crate` item, with optional *original* crate name if the crate was renamed.
46124612 ///
......@@ -4681,7 +4681,7 @@ pub enum ItemKind<'hir> {
46814681///
46824682/// E.g., `impl $Type { .. }` or `impl $Trait for $Type { .. }`
46834683/// Refer to [`ImplItem`] for an associated item within an impl block.
4684#[derive(Debug, Clone, Copy, HashStable_Generic)]
4684#[derive(Debug, Clone, Copy, HashStable)]
46854685pub struct Impl<'hir> {
46864686 pub generics: &'hir Generics<'hir>,
46874687 pub of_trait: Option<&'hir TraitImplHeader<'hir>>,
......@@ -4690,7 +4690,7 @@ pub struct Impl<'hir> {
46904690 pub constness: Constness,
46914691}
46924692
4693#[derive(Debug, Clone, Copy, HashStable_Generic)]
4693#[derive(Debug, Clone, Copy, HashStable)]
46944694pub struct TraitImplHeader<'hir> {
46954695 pub safety: Safety,
46964696 pub polarity: ImplPolarity,
......@@ -4764,7 +4764,7 @@ impl ItemKind<'_> {
47644764// The bodies for items are stored "out of line", in a separate
47654765// hashmap in the `Crate`. Here we just record the hir-id of the item
47664766// so it can fetched later.
4767#[derive(Copy, Clone, PartialEq, Eq, Encodable, Decodable, Debug, HashStable_Generic)]
4767#[derive(Copy, Clone, PartialEq, Eq, Encodable, Decodable, Debug, HashStable)]
47684768pub struct ForeignItemId {
47694769 pub owner_id: OwnerId,
47704770}
......@@ -4777,7 +4777,7 @@ impl ForeignItemId {
47774777 }
47784778}
47794779
4780#[derive(Debug, Clone, Copy, HashStable_Generic)]
4780#[derive(Debug, Clone, Copy, HashStable)]
47814781pub struct ForeignItem<'hir> {
47824782 pub ident: Ident,
47834783 pub kind: ForeignItemKind<'hir>,
......@@ -4800,7 +4800,7 @@ impl ForeignItem<'_> {
48004800}
48014801
48024802/// An item within an `extern` block.
4803#[derive(Debug, Clone, Copy, HashStable_Generic)]
4803#[derive(Debug, Clone, Copy, HashStable)]
48044804pub enum ForeignItemKind<'hir> {
48054805 /// A foreign function.
48064806 ///
......@@ -4816,7 +4816,7 @@ pub enum ForeignItemKind<'hir> {
48164816}
48174817
48184818/// A variable captured by a closure.
4819#[derive(Debug, Copy, Clone, HashStable_Generic)]
4819#[derive(Debug, Copy, Clone, HashStable)]
48204820pub struct Upvar {
48214821 /// First span where it is accessed (there can be multiple).
48224822 pub span: Span,
......@@ -4825,7 +4825,7 @@ pub struct Upvar {
48254825// The TraitCandidate's import_ids is empty if the trait is defined in the same module, and
48264826// has length > 0 if the trait is found through an chain of imports, starting with the
48274827// import/use statement in the scope where the trait is used.
4828#[derive(Debug, Clone, Copy, HashStable_Generic)]
4828#[derive(Debug, Clone, Copy, HashStable)]
48294829pub struct TraitCandidate<'hir> {
48304830 pub def_id: DefId,
48314831 pub import_ids: &'hir [LocalDefId],
......@@ -4836,7 +4836,7 @@ pub struct TraitCandidate<'hir> {
48364836 pub lint_ambiguous: bool,
48374837}
48384838
4839#[derive(Copy, Clone, Debug, HashStable_Generic)]
4839#[derive(Copy, Clone, Debug, HashStable)]
48404840pub enum OwnerNode<'hir> {
48414841 Item(&'hir Item<'hir>),
48424842 ForeignItem(&'hir ForeignItem<'hir>),
......@@ -4970,7 +4970,7 @@ impl<'hir> From<OwnerNode<'hir>> for Node<'hir> {
49704970 }
49714971}
49724972
4973#[derive(Copy, Clone, Debug, HashStable_Generic)]
4973#[derive(Copy, Clone, Debug, HashStable)]
49744974pub enum Node<'hir> {
49754975 Param(&'hir Param<'hir>),
49764976 Item(&'hir Item<'hir>),
compiler/rustc_hir/src/lang_items.rs+5-5
......@@ -8,8 +8,8 @@
88//! * Functions called by the compiler itself.
99
1010use rustc_data_structures::fx::FxIndexMap;
11use rustc_data_structures::stable_hasher::{HashStable, StableHasher};
12use rustc_macros::{BlobDecodable, Encodable, HashStable_Generic, PrintAttribute};
11use rustc_data_structures::stable_hasher::{HashStable, HashStableContext, StableHasher};
12use rustc_macros::{BlobDecodable, Encodable, HashStable, PrintAttribute};
1313use rustc_span::{Symbol, kw, sym};
1414
1515use crate::attrs::PrintAttribute;
......@@ -18,7 +18,7 @@ use crate::{MethodKind, Target};
1818
1919/// All of the lang items, defined or not.
2020/// Defined lang items can come from the current crate or its dependencies.
21#[derive(HashStable_Generic, Debug)]
21#[derive(HashStable, Debug)]
2222pub struct LanguageItems {
2323 /// Mappings from lang items to their possibly found [`DefId`]s.
2424 /// The index corresponds to the order in [`LangItem`].
......@@ -144,8 +144,8 @@ macro_rules! language_item_table {
144144 }
145145}
146146
147impl<Hcx> HashStable<Hcx> for LangItem {
148 fn hash_stable(&self, _: &mut Hcx, hasher: &mut StableHasher) {
147impl HashStable for LangItem {
148 fn hash_stable<Hcx: HashStableContext>(&self, _: &mut Hcx, hasher: &mut StableHasher) {
149149 ::std::hash::Hash::hash(self, hasher);
150150 }
151151}
compiler/rustc_hir/src/limit.rs+2-2
......@@ -2,11 +2,11 @@ use std::fmt;
22use std::ops::{Div, Mul};
33
44use rustc_error_messages::{DiagArgValue, IntoDiagArg};
5use rustc_macros::{Decodable, Encodable, HashStable_Generic};
5use rustc_macros::{Decodable, Encodable, HashStable};
66
77/// New-type wrapper around `usize` for representing limits. Ensures that comparisons against
88/// limits are consistent throughout the compiler.
9#[derive(Clone, Copy, Debug, HashStable_Generic, Encodable, Decodable)]
9#[derive(Clone, Copy, Debug, HashStable, Encodable, Decodable)]
1010pub struct Limit(pub usize);
1111
1212impl Limit {
compiler/rustc_hir/src/stability.rs+8-8
......@@ -1,6 +1,6 @@
11use std::num::NonZero;
22
3use rustc_macros::{BlobDecodable, Decodable, Encodable, HashStable_Generic, PrintAttribute};
3use rustc_macros::{BlobDecodable, Decodable, Encodable, HashStable, PrintAttribute};
44use rustc_span::{ErrorGuaranteed, Symbol, sym};
55
66use crate::RustcVersion;
......@@ -22,7 +22,7 @@ pub const VERSION_PLACEHOLDER: &str = concat!("CURRENT_RUSTC_VERSIO", "N");
2222/// - `#[stable]`
2323/// - `#[unstable]`
2424#[derive(Encodable, BlobDecodable, Copy, Clone, Debug, PartialEq, Eq, Hash)]
25#[derive(HashStable_Generic, PrintAttribute)]
25#[derive(HashStable, PrintAttribute)]
2626pub struct Stability {
2727 pub level: StabilityLevel,
2828 pub feature: Symbol,
......@@ -44,7 +44,7 @@ impl Stability {
4444
4545/// Represents the `#[rustc_const_unstable]` and `#[rustc_const_stable]` attributes.
4646#[derive(Encodable, Decodable, Copy, Clone, Debug, PartialEq, Eq, Hash)]
47#[derive(HashStable_Generic, PrintAttribute)]
47#[derive(HashStable, PrintAttribute)]
4848pub struct ConstStability {
4949 pub level: StabilityLevel,
5050 pub feature: Symbol,
......@@ -84,7 +84,7 @@ impl ConstStability {
8484/// Excludes `const_stable_indirect`. This is necessary because when `-Zforce-unstable-if-unmarked`
8585/// is set, we need to encode standalone `#[rustc_const_stable_indirect]` attributes
8686#[derive(Encodable, Decodable, Copy, Clone, Debug, PartialEq, Eq, Hash)]
87#[derive(HashStable_Generic, PrintAttribute)]
87#[derive(HashStable, PrintAttribute)]
8888pub struct PartialConstStability {
8989 pub level: StabilityLevel,
9090 pub feature: Symbol,
......@@ -104,7 +104,7 @@ impl PartialConstStability {
104104
105105/// The available stability levels.
106106#[derive(Encodable, BlobDecodable, PartialEq, Copy, Clone, Debug, Eq, Hash)]
107#[derive(HashStable_Generic, PrintAttribute)]
107#[derive(HashStable, PrintAttribute)]
108108pub enum StabilityLevel {
109109 /// `#[unstable]`
110110 Unstable {
......@@ -146,7 +146,7 @@ pub enum StabilityLevel {
146146
147147/// Rust release in which a feature is stabilized.
148148#[derive(Encodable, BlobDecodable, PartialEq, Copy, Clone, Debug, Eq, PartialOrd, Ord, Hash)]
149#[derive(HashStable_Generic, PrintAttribute)]
149#[derive(HashStable, PrintAttribute)]
150150pub enum StableSince {
151151 /// also stores the original symbol for printing
152152 Version(RustcVersion),
......@@ -172,7 +172,7 @@ impl StabilityLevel {
172172}
173173
174174#[derive(Encodable, BlobDecodable, PartialEq, Copy, Clone, Debug, Eq, Hash)]
175#[derive(HashStable_Generic, PrintAttribute)]
175#[derive(HashStable, PrintAttribute)]
176176pub enum UnstableReason {
177177 None,
178178 Default,
......@@ -181,7 +181,7 @@ pub enum UnstableReason {
181181
182182/// Represents the `#[rustc_default_body_unstable]` attribute.
183183#[derive(Encodable, Decodable, Copy, Clone, Debug, PartialEq, Eq, Hash)]
184#[derive(HashStable_Generic, PrintAttribute)]
184#[derive(HashStable, PrintAttribute)]
185185pub struct DefaultBodyStability {
186186 pub level: StabilityLevel,
187187 pub feature: Symbol,
compiler/rustc_hir/src/stable_hash_impls.rs+22-18
......@@ -1,5 +1,6 @@
1use rustc_data_structures::stable_hasher::{HashStable, StableHasher, ToStableHashKey};
2use rustc_span::HashStableContext;
1use rustc_data_structures::stable_hasher::{
2 HashStable, HashStableContext, StableHasher, ToStableHashKey,
3};
34use rustc_span::def_id::DefPathHash;
45
56use crate::HashIgnoredAttrId;
......@@ -8,48 +9,51 @@ use crate::hir::{
89};
910use crate::hir_id::ItemLocalId;
1011
11impl<Hcx: HashStableContext> ToStableHashKey<Hcx> for BodyId {
12impl ToStableHashKey for BodyId {
1213 type KeyType = (DefPathHash, ItemLocalId);
1314
1415 #[inline]
15 fn to_stable_hash_key(&self, hcx: &mut Hcx) -> (DefPathHash, ItemLocalId) {
16 fn to_stable_hash_key<Hcx: HashStableContext>(
17 &self,
18 hcx: &mut Hcx,
19 ) -> (DefPathHash, ItemLocalId) {
1620 let BodyId { hir_id } = *self;
1721 hir_id.to_stable_hash_key(hcx)
1822 }
1923}
2024
21impl<Hcx: HashStableContext> ToStableHashKey<Hcx> for ItemId {
25impl ToStableHashKey for ItemId {
2226 type KeyType = DefPathHash;
2327
2428 #[inline]
25 fn to_stable_hash_key(&self, hcx: &mut Hcx) -> DefPathHash {
29 fn to_stable_hash_key<Hcx: HashStableContext>(&self, hcx: &mut Hcx) -> DefPathHash {
2630 self.owner_id.def_id.to_stable_hash_key(hcx)
2731 }
2832}
2933
30impl<Hcx: HashStableContext> ToStableHashKey<Hcx> for TraitItemId {
34impl ToStableHashKey for TraitItemId {
3135 type KeyType = DefPathHash;
3236
3337 #[inline]
34 fn to_stable_hash_key(&self, hcx: &mut Hcx) -> DefPathHash {
38 fn to_stable_hash_key<Hcx: HashStableContext>(&self, hcx: &mut Hcx) -> DefPathHash {
3539 self.owner_id.def_id.to_stable_hash_key(hcx)
3640 }
3741}
3842
39impl<Hcx: HashStableContext> ToStableHashKey<Hcx> for ImplItemId {
43impl ToStableHashKey for ImplItemId {
4044 type KeyType = DefPathHash;
4145
4246 #[inline]
43 fn to_stable_hash_key(&self, hcx: &mut Hcx) -> DefPathHash {
47 fn to_stable_hash_key<Hcx: HashStableContext>(&self, hcx: &mut Hcx) -> DefPathHash {
4448 self.owner_id.def_id.to_stable_hash_key(hcx)
4549 }
4650}
4751
48impl<Hcx: HashStableContext> ToStableHashKey<Hcx> for ForeignItemId {
52impl ToStableHashKey for ForeignItemId {
4953 type KeyType = DefPathHash;
5054
5155 #[inline]
52 fn to_stable_hash_key(&self, hcx: &mut Hcx) -> DefPathHash {
56 fn to_stable_hash_key<Hcx: HashStableContext>(&self, hcx: &mut Hcx) -> DefPathHash {
5357 self.owner_id.def_id.to_stable_hash_key(hcx)
5458 }
5559}
......@@ -61,8 +65,8 @@ impl<Hcx: HashStableContext> ToStableHashKey<Hcx> for ForeignItemId {
6165// want to pick up on a reference changing its target, so we hash the NodeIds
6266// in "DefPath Mode".
6367
64impl<'tcx, Hcx: HashStableContext> HashStable<Hcx> for OwnerNodes<'tcx> {
65 fn hash_stable(&self, hcx: &mut Hcx, hasher: &mut StableHasher) {
68impl<'tcx> HashStable for OwnerNodes<'tcx> {
69 fn hash_stable<Hcx: HashStableContext>(&self, hcx: &mut Hcx, hasher: &mut StableHasher) {
6670 // We ignore the `nodes` and `bodies` fields since these refer to information included in
6771 // `hash` which is hashed in the collector and used for the crate hash.
6872 // `local_id_to_def_id` is also ignored because is dependent on the body, then just hashing
......@@ -73,8 +77,8 @@ impl<'tcx, Hcx: HashStableContext> HashStable<Hcx> for OwnerNodes<'tcx> {
7377 }
7478}
7579
76impl<'tcx, Hcx: HashStableContext> HashStable<Hcx> for AttributeMap<'tcx> {
77 fn hash_stable(&self, hcx: &mut Hcx, hasher: &mut StableHasher) {
80impl<'tcx> HashStable for AttributeMap<'tcx> {
81 fn hash_stable<Hcx: HashStableContext>(&self, hcx: &mut Hcx, hasher: &mut StableHasher) {
7882 // We ignore the `map` since it refers to information included in `opt_hash` which is
7983 // hashed in the collector and used for the crate hash.
8084 let AttributeMap { opt_hash, define_opaque: _, map: _ } = *self;
......@@ -82,8 +86,8 @@ impl<'tcx, Hcx: HashStableContext> HashStable<Hcx> for AttributeMap<'tcx> {
8286 }
8387}
8488
85impl<Hcx: HashStableContext> HashStable<Hcx> for HashIgnoredAttrId {
86 fn hash_stable(&self, _hcx: &mut Hcx, _hasher: &mut StableHasher) {
89impl HashStable for HashIgnoredAttrId {
90 fn hash_stable<Hcx: HashStableContext>(&self, _hcx: &mut Hcx, _hasher: &mut StableHasher) {
8791 /* we don't hash HashIgnoredAttrId, we ignore them */
8892 }
8993}
compiler/rustc_hir/src/target.rs+4-4
......@@ -4,19 +4,19 @@ use std::fmt::{self, Display};
44
55use rustc_ast::visit::AssocCtxt;
66use rustc_ast::{AssocItemKind, ForeignItemKind, ast};
7use rustc_macros::HashStable_Generic;
7use rustc_macros::HashStable;
88
99use crate::def::DefKind;
1010use crate::{Item, ItemKind, TraitItem, TraitItemKind, hir};
1111
12#[derive(Copy, Clone, PartialEq, Debug, Eq, HashStable_Generic)]
12#[derive(Copy, Clone, PartialEq, Debug, Eq, HashStable)]
1313pub enum GenericParamKind {
1414 Type,
1515 Lifetime,
1616 Const,
1717}
1818
19#[derive(Copy, Clone, PartialEq, Debug, Eq, HashStable_Generic)]
19#[derive(Copy, Clone, PartialEq, Debug, Eq, HashStable)]
2020pub enum MethodKind {
2121 /// Method in a `trait Trait` block
2222 Trait {
......@@ -29,7 +29,7 @@ pub enum MethodKind {
2929 Inherent,
3030}
3131
32#[derive(Copy, Clone, PartialEq, Debug, Eq, HashStable_Generic)]
32#[derive(Copy, Clone, PartialEq, Debug, Eq, HashStable)]
3333pub enum Target {
3434 ExternCrate,
3535 Use,
compiler/rustc_hir_id/src/lib.rs+18-14
......@@ -6,9 +6,10 @@
66
77use std::fmt::{self, Debug};
88
9use rustc_data_structures::stable_hasher::{HashStable, StableHasher, StableOrd, ToStableHashKey};
10use rustc_macros::{Decodable, Encodable, HashStable_Generic};
11use rustc_span::HashStableContext;
9use rustc_data_structures::stable_hasher::{
10 HashStable, HashStableContext, StableHasher, StableOrd, ToStableHashKey,
11};
12use rustc_macros::{Decodable, Encodable, HashStable};
1213use rustc_span::def_id::{CRATE_DEF_ID, DefId, DefIndex, DefPathHash, LocalDefId};
1314
1415#[derive(Copy, Clone, PartialEq, Eq, Hash, Encodable, Decodable)]
......@@ -54,19 +55,19 @@ impl rustc_index::Idx for OwnerId {
5455 }
5556}
5657
57impl<Hcx: HashStableContext> HashStable<Hcx> for OwnerId {
58impl HashStable for OwnerId {
5859 #[inline]
59 fn hash_stable(&self, hcx: &mut Hcx, hasher: &mut StableHasher) {
60 fn hash_stable<Hcx: HashStableContext>(&self, hcx: &mut Hcx, hasher: &mut StableHasher) {
6061 self.to_stable_hash_key(hcx).hash_stable(hcx, hasher);
6162 }
6263}
6364
64impl<Hcx: HashStableContext> ToStableHashKey<Hcx> for OwnerId {
65impl ToStableHashKey for OwnerId {
6566 type KeyType = DefPathHash;
6667
6768 #[inline]
68 fn to_stable_hash_key(&self, hcx: &mut Hcx) -> DefPathHash {
69 hcx.def_path_hash(self.to_def_id())
69 fn to_stable_hash_key<Hcx: HashStableContext>(&self, hcx: &mut Hcx) -> DefPathHash {
70 self.to_def_id().to_stable_hash_key(hcx)
7071 }
7172}
7273
......@@ -80,7 +81,7 @@ impl<Hcx: HashStableContext> ToStableHashKey<Hcx> for OwnerId {
8081/// the `local_id` part of the `HirId` changing, which is a very useful property in
8182/// incremental compilation where we have to persist things through changes to
8283/// the code base.
83#[derive(Copy, Clone, PartialEq, Eq, Hash, Encodable, Decodable, HashStable_Generic)]
84#[derive(Copy, Clone, PartialEq, Eq, Hash, Encodable, Decodable, HashStable)]
8485#[rustc_pass_by_value]
8586pub struct HirId {
8687 pub owner: OwnerId,
......@@ -151,7 +152,7 @@ rustc_index::newtype_index! {
151152 /// integers starting at zero, so a mapping that maps all or most nodes within
152153 /// an "item-like" to something else can be implemented by a `Vec` instead of a
153154 /// tree or hash map.
154 #[stable_hash_generic]
155 #[stable_hash]
155156 #[encodable]
156157 #[orderable]
157158 pub struct ItemLocalId {}
......@@ -176,21 +177,24 @@ pub const CRATE_HIR_ID: HirId =
176177
177178pub const CRATE_OWNER_ID: OwnerId = OwnerId { def_id: CRATE_DEF_ID };
178179
179impl<Hcx: HashStableContext> ToStableHashKey<Hcx> for HirId {
180impl ToStableHashKey for HirId {
180181 type KeyType = (DefPathHash, ItemLocalId);
181182
182183 #[inline]
183 fn to_stable_hash_key(&self, hcx: &mut Hcx) -> (DefPathHash, ItemLocalId) {
184 fn to_stable_hash_key<Hcx: HashStableContext>(
185 &self,
186 hcx: &mut Hcx,
187 ) -> (DefPathHash, ItemLocalId) {
184188 let def_path_hash = self.owner.def_id.to_stable_hash_key(hcx);
185189 (def_path_hash, self.local_id)
186190 }
187191}
188192
189impl<Hcx: HashStableContext> ToStableHashKey<Hcx> for ItemLocalId {
193impl ToStableHashKey for ItemLocalId {
190194 type KeyType = ItemLocalId;
191195
192196 #[inline]
193 fn to_stable_hash_key(&self, _: &mut Hcx) -> ItemLocalId {
197 fn to_stable_hash_key<Hcx>(&self, _: &mut Hcx) -> ItemLocalId {
194198 *self
195199 }
196200}
compiler/rustc_index_macros/src/lib.rs+1-2
......@@ -25,8 +25,7 @@ mod newtype;
2525/// The impls provided by default are Clone, Copy, PartialEq, Eq, and Hash.
2626///
2727/// Accepted attributes for customization:
28/// - `#[derive(HashStable_Generic)]`/`#[derive(HashStable)]`: derives
29/// `HashStable`, as normal.
28/// - `#[derive(HashStable)]`: derives `HashStable`, as normal.
3029/// - `#[encodable]`: derives `Encodable`/`Decodable`.
3130/// - `#[orderable]`: derives `PartialOrd`/`Ord`, plus step-related methods.
3231/// - `#[debug_format = "Foo({})"]`: derives `Debug` with particular output.
compiler/rustc_index_macros/src/newtype.rs+8-21
......@@ -24,8 +24,6 @@ impl Parse for Newtype {
2424 let mut encodable = false;
2525 let mut ord = false;
2626 let mut stable_hash = false;
27 let mut stable_hash_generic = false;
28 let mut stable_hash_no_context = false;
2927 let mut gate_rustc_only = quote! {};
3028 let mut gate_rustc_only_cfg = quote! { all() };
3129
......@@ -48,14 +46,6 @@ impl Parse for Newtype {
4846 stable_hash = true;
4947 false
5048 }
51 "stable_hash_generic" => {
52 stable_hash_generic = true;
53 false
54 }
55 "stable_hash_no_context" => {
56 stable_hash_no_context = true;
57 false
58 }
5949 "max" => {
6050 let Meta::NameValue(MetaNameValue { value: Expr::Lit(lit), .. }) = &attr.meta
6151 else {
......@@ -165,17 +155,14 @@ impl Parse for Newtype {
165155 let hash_stable = if stable_hash {
166156 quote! {
167157 #gate_rustc_only
168 impl<'__ctx> ::rustc_data_structures::stable_hasher::HashStable<::rustc_middle::ich::StableHashingContext<'__ctx>> for #name {
169 fn hash_stable(&self, hcx: &mut ::rustc_middle::ich::StableHashingContext<'__ctx>, hasher: &mut ::rustc_data_structures::stable_hasher::StableHasher) {
170 self.as_u32().hash_stable(hcx, hasher)
171 }
172 }
173 }
174 } else if stable_hash_generic || stable_hash_no_context {
175 quote! {
176 #gate_rustc_only
177 impl<Hcx> ::rustc_data_structures::stable_hasher::HashStable<Hcx> for #name {
178 fn hash_stable(&self, hcx: &mut Hcx, hasher: &mut ::rustc_data_structures::stable_hasher::StableHasher) {
158 impl ::rustc_data_structures::stable_hasher::HashStable for #name {
159 fn hash_stable<
160 __Hcx: ::rustc_data_structures::stable_hasher::HashStableContext
161 >(
162 &self,
163 hcx: &mut __Hcx,
164 hasher: &mut ::rustc_data_structures::stable_hasher::StableHasher
165 ) {
179166 self.as_u32().hash_stable(hcx, hasher)
180167 }
181168 }
compiler/rustc_lint_defs/src/lib.rs+12-22
......@@ -5,14 +5,14 @@ use rustc_ast::AttrId;
55use rustc_ast::attr::AttributeExt;
66use rustc_data_structures::fx::FxIndexSet;
77use rustc_data_structures::stable_hasher::{
8 HashStable, StableCompare, StableHasher, ToStableHashKey,
8 HashStable, HashStableContext, StableCompare, StableHasher, ToStableHashKey,
99};
1010use rustc_error_messages::{DiagArgValue, IntoDiagArg};
1111use rustc_hir_id::{HirId, ItemLocalId};
12use rustc_macros::{Decodable, Encodable, HashStable_Generic};
12use rustc_macros::{Decodable, Encodable, HashStable};
1313use rustc_span::def_id::DefPathHash;
1414pub use rustc_span::edition::Edition;
15use rustc_span::{HashStableContext, Ident, Symbol, sym};
15use rustc_span::{Ident, Symbol, sym};
1616use serde::{Deserialize, Serialize};
1717
1818pub use self::Level::*;
......@@ -138,9 +138,9 @@ impl LintExpectationId {
138138 }
139139}
140140
141impl<Hcx: HashStableContext> HashStable<Hcx> for LintExpectationId {
141impl HashStable for LintExpectationId {
142142 #[inline]
143 fn hash_stable(&self, hcx: &mut Hcx, hasher: &mut StableHasher) {
143 fn hash_stable<Hcx: HashStableContext>(&self, hcx: &mut Hcx, hasher: &mut StableHasher) {
144144 match self {
145145 LintExpectationId::Stable { hir_id, attr_index, lint_index: Some(lint_index) } => {
146146 hir_id.hash_stable(hcx, hasher);
......@@ -156,11 +156,11 @@ impl<Hcx: HashStableContext> HashStable<Hcx> for LintExpectationId {
156156 }
157157}
158158
159impl<Hcx: HashStableContext> ToStableHashKey<Hcx> for LintExpectationId {
159impl ToStableHashKey for LintExpectationId {
160160 type KeyType = (DefPathHash, ItemLocalId, u16, u16);
161161
162162 #[inline]
163 fn to_stable_hash_key(&self, hcx: &mut Hcx) -> Self::KeyType {
163 fn to_stable_hash_key<Hcx: HashStableContext>(&self, hcx: &mut Hcx) -> Self::KeyType {
164164 match self {
165165 LintExpectationId::Stable { hir_id, attr_index, lint_index: Some(lint_index) } => {
166166 let (def_path_hash, lint_idx) = hir_id.to_stable_hash_key(hcx);
......@@ -177,17 +177,7 @@ impl<Hcx: HashStableContext> ToStableHashKey<Hcx> for LintExpectationId {
177177///
178178/// See: <https://doc.rust-lang.org/rustc/lints/levels.html>
179179#[derive(
180 Clone,
181 Copy,
182 PartialEq,
183 PartialOrd,
184 Eq,
185 Ord,
186 Debug,
187 Hash,
188 Encodable,
189 Decodable,
190 HashStable_Generic
180 Clone, Copy, PartialEq, PartialOrd, Eq, Ord, Debug, Hash, Encodable, Decodable, HashStable
191181)]
192182pub enum Level {
193183 /// The `allow` level will not issue any message.
......@@ -621,18 +611,18 @@ impl LintId {
621611 }
622612}
623613
624impl<Hcx> HashStable<Hcx> for LintId {
614impl HashStable for LintId {
625615 #[inline]
626 fn hash_stable(&self, hcx: &mut Hcx, hasher: &mut StableHasher) {
616 fn hash_stable<Hcx: HashStableContext>(&self, hcx: &mut Hcx, hasher: &mut StableHasher) {
627617 self.lint_name_raw().hash_stable(hcx, hasher);
628618 }
629619}
630620
631impl<Hcx> ToStableHashKey<Hcx> for LintId {
621impl ToStableHashKey for LintId {
632622 type KeyType = &'static str;
633623
634624 #[inline]
635 fn to_stable_hash_key(&self, _: &mut Hcx) -> &'static str {
625 fn to_stable_hash_key<Hcx>(&self, _: &mut Hcx) -> &'static str {
636626 self.lint_name_raw()
637627 }
638628}
compiler/rustc_macros/src/hash_stable.rs+21-47
......@@ -1,6 +1,5 @@
11use proc_macro2::Ident;
22use quote::quote;
3use syn::parse_quote;
43
54struct Attributes {
65 ignore: bool,
......@@ -42,12 +41,6 @@ pub(crate) fn hash_stable_derive(s: synstructure::Structure<'_>) -> proc_macro2:
4241 hash_stable_derive_with_mode(s, HashStableMode::Normal)
4342}
4443
45pub(crate) fn hash_stable_generic_derive(
46 s: synstructure::Structure<'_>,
47) -> proc_macro2::TokenStream {
48 hash_stable_derive_with_mode(s, HashStableMode::Generic)
49}
50
5144pub(crate) fn hash_stable_no_context_derive(
5245 s: synstructure::Structure<'_>,
5346) -> proc_macro2::TokenStream {
......@@ -55,13 +48,19 @@ pub(crate) fn hash_stable_no_context_derive(
5548}
5649
5750enum HashStableMode {
58 // Use the query-system aware stable hashing context.
51 // Do a normal derive, where any generic type parameter gets a `HashStable` bound.
52 // For example, in `struct Abc<T, U>(T, U)` the added bounds are `T: HashStable` and
53 // `U: HashStable`.
5954 Normal,
60 // Emit a generic implementation that uses a crate-local `StableHashingContext`
61 // trait, when the crate is upstream of `rustc_middle`.
62 Generic,
63 // Emit a hash-stable implementation that takes no context,
64 // and emits per-field where clauses for (almost-)perfect derives.
55
56 // Do an (almost-)perfect derive, where any field with a generic type parameter gets a
57 // `HashStable` bound. For example, in `struct Def<T, U>(T, U::Assoc)` the added bounds are
58 // `T::HashStable` and `U::Assoc: HashStable` (not `U: HashStable`).
59 //
60 // This is used most commonly in `rustc_type_ir` for types like `TyKind<I: Interner>`.
61 // `Interner` does not impl `HashStable`, but the fields of `TyKind` do not use `I` itself,
62 // instead only using associated types from `I` such as `I::Region`. On types like `TyKind` we
63 // typically also see the use of `derive_where` for built-in traits such as `Debug`.
6564 NoContext,
6665}
6766
......@@ -69,50 +68,25 @@ fn hash_stable_derive_with_mode(
6968 mut s: synstructure::Structure<'_>,
7069 mode: HashStableMode,
7170) -> proc_macro2::TokenStream {
72 let generic: syn::GenericParam = match mode {
73 HashStableMode::Normal => parse_quote!('__ctx),
74 HashStableMode::Generic | HashStableMode::NoContext => parse_quote!(__CTX),
75 };
76
77 // no_context impl is able to derive by-field, which is closer to a perfect derive.
78 s.add_bounds(match mode {
79 HashStableMode::Normal | HashStableMode::Generic => synstructure::AddBounds::Generics,
71 let add_bounds = match mode {
72 HashStableMode::Normal => synstructure::AddBounds::Generics,
8073 HashStableMode::NoContext => synstructure::AddBounds::Fields,
81 });
82
83 // For generic impl, add `where __CTX: HashStableContext`.
84 match mode {
85 HashStableMode::Normal => {}
86 HashStableMode::Generic => {
87 s.add_where_predicate(parse_quote! { __CTX: ::rustc_span::HashStableContext });
88 }
89 HashStableMode::NoContext => {}
90 }
74 };
9175
92 s.add_impl_generic(generic);
76 s.add_bounds(add_bounds);
9377
9478 let discriminant = hash_stable_discriminant(&mut s);
9579 let body = hash_stable_body(&mut s);
9680
97 let context: syn::Type = match mode {
98 HashStableMode::Normal => {
99 parse_quote!(::rustc_middle::ich::StableHashingContext<'__ctx>)
100 }
101 HashStableMode::Generic | HashStableMode::NoContext => parse_quote!(__CTX),
102 };
103
10481 s.bound_impl(
105 quote!(
106 ::rustc_data_structures::stable_hasher::HashStable<
107 #context
108 >
109 ),
82 quote!(::rustc_data_structures::stable_hasher::HashStable),
11083 quote! {
11184 #[inline]
112 fn hash_stable(
85 fn hash_stable<__Hcx: ::rustc_data_structures::stable_hasher::HashStableContext>(
11386 &self,
114 __hcx: &mut #context,
115 __hasher: &mut ::rustc_data_structures::stable_hasher::StableHasher) {
87 __hcx: &mut __Hcx,
88 __hasher: &mut ::rustc_data_structures::stable_hasher::StableHasher
89 ) {
11690 #discriminant
11791 match *self { #body }
11892 }
compiler/rustc_macros/src/lib.rs+2-8
......@@ -58,17 +58,11 @@ pub fn extension(attr: TokenStream, input: TokenStream) -> TokenStream {
5858 extension::extension(attr, input)
5959}
6060
61decl_derive!([HashStable, attributes(stable_hasher)] => hash_stable::hash_stable_derive);
6261decl_derive!(
63 [HashStable_Generic, attributes(stable_hasher)] =>
64 hash_stable::hash_stable_generic_derive
62 [HashStable, attributes(stable_hasher)] => hash_stable::hash_stable_derive
6563);
6664decl_derive!(
67 [HashStable_NoContext, attributes(stable_hasher)] =>
68 /// `HashStable` implementation that has no `HashStableContext` bound and
69 /// which adds `where` bounds for `HashStable` based off of fields and not
70 /// generics. This is suitable for use in crates like `rustc_type_ir`.
71 hash_stable::hash_stable_no_context_derive
65 [HashStable_NoContext, attributes(stable_hasher)] => hash_stable::hash_stable_no_context_derive
7266);
7367
7468// Encoding and Decoding derives
compiler/rustc_middle/src/dep_graph/dep_node.rs+2-2
......@@ -231,10 +231,10 @@ impl WorkProductId {
231231 WorkProductId { hash: hasher.finish() }
232232 }
233233}
234impl<Hcx> ToStableHashKey<Hcx> for WorkProductId {
234impl ToStableHashKey for WorkProductId {
235235 type KeyType = Fingerprint;
236236 #[inline]
237 fn to_stable_hash_key(&self, _: &mut Hcx) -> Self::KeyType {
237 fn to_stable_hash_key<Hcx>(&self, _: &mut Hcx) -> Self::KeyType {
238238 self.hash
239239 }
240240}
compiler/rustc_middle/src/dep_graph/dep_node_key.rs+1-2
......@@ -7,7 +7,6 @@ use rustc_hir::definitions::DefPathHash;
77use rustc_hir::{HirId, ItemLocalId, OwnerId};
88
99use crate::dep_graph::{DepNode, KeyFingerprintStyle};
10use crate::ich::StableHashingContext;
1110use crate::ty::TyCtxt;
1211
1312/// Trait for query keys as seen by dependency-node tracking.
......@@ -30,7 +29,7 @@ pub trait DepNodeKey<'tcx>: Debug + Sized {
3029// Blanket impl of `DepNodeKey`, which is specialized by other impls elsewhere.
3130impl<'tcx, T> DepNodeKey<'tcx> for T
3231where
33 T: for<'a> HashStable<StableHashingContext<'a>> + Debug,
32 T: HashStable + Debug,
3433{
3534 #[inline(always)]
3635 default fn key_fingerprint_style() -> KeyFingerprintStyle {
compiler/rustc_middle/src/dep_graph/graph.rs+1-1
......@@ -123,7 +123,7 @@ pub struct DepGraphData {
123123
124124pub fn hash_result<R>(hcx: &mut StableHashingContext<'_>, result: &R) -> Fingerprint
125125where
126 R: for<'a> HashStable<StableHashingContext<'a>>,
126 R: HashStable,
127127{
128128 let mut stable_hasher = StableHasher::new();
129129 result.hash_stable(hcx, &mut stable_hasher);
compiler/rustc_middle/src/hir/mod.rs+4-4
......@@ -12,7 +12,7 @@ use rustc_ast::{self as ast};
1212use rustc_data_structures::fingerprint::Fingerprint;
1313use rustc_data_structures::fx::FxIndexSet;
1414use rustc_data_structures::sorted_map::SortedMap;
15use rustc_data_structures::stable_hasher::{HashStable, StableHasher};
15use rustc_data_structures::stable_hasher::{HashStable, HashStableContext, StableHasher};
1616use rustc_data_structures::steal::Steal;
1717use rustc_data_structures::sync::{DynSend, DynSync, try_par_for_each_in};
1818use rustc_hir::def::{DefKind, Res};
......@@ -20,7 +20,7 @@ use rustc_hir::def_id::{DefId, LocalDefId, LocalModDefId};
2020use rustc_hir::*;
2121use rustc_index::IndexVec;
2222use rustc_macros::{Decodable, Encodable, HashStable};
23use rustc_span::{ErrorGuaranteed, ExpnId, HashStableContext, Span};
23use rustc_span::{ErrorGuaranteed, ExpnId, Span};
2424
2525use crate::query::Providers;
2626use crate::ty::{ResolverAstLowering, TyCtxt};
......@@ -76,8 +76,8 @@ impl<'hir> Crate<'hir> {
7676 }
7777}
7878
79impl<Hcx: HashStableContext> HashStable<Hcx> for Crate<'_> {
80 fn hash_stable(&self, hcx: &mut Hcx, hasher: &mut StableHasher) {
79impl HashStable for Crate<'_> {
80 fn hash_stable<Hcx: HashStableContext>(&self, hcx: &mut Hcx, hasher: &mut StableHasher) {
8181 let Crate { opt_hir_hash, .. } = self;
8282 opt_hir_hash.unwrap().hash_stable(hcx, hasher)
8383 }
compiler/rustc_middle/src/ich.rs created+198
......@@ -0,0 +1,198 @@
1use std::hash::Hash;
2
3use rustc_data_structures::stable_hasher::{
4 HashStable, HashStableContext, HashingControls, RawDefId, RawDefPathHash, RawSpan, StableHasher,
5};
6use rustc_hir::def_id::{DefId, LocalDefId};
7use rustc_session::Session;
8use rustc_session::cstore::Untracked;
9use rustc_span::source_map::SourceMap;
10use rustc_span::{CachingSourceMapView, DUMMY_SP, Pos, Span};
11
12// Very often, we are hashing something that does not need the `CachingSourceMapView`, so we
13// initialize it lazily.
14enum CachingSourceMap<'a> {
15 Unused(&'a SourceMap),
16 InUse(CachingSourceMapView<'a>),
17}
18
19/// This is the context state available during incr. comp. hashing. It contains
20/// enough information to transform `DefId`s and `HirId`s into stable `DefPath`s (i.e.,
21/// a reference to the `TyCtxt`) and it holds a few caches for speeding up various
22/// things (e.g., each `DefId`/`DefPath` is only hashed once).
23pub struct StableHashingContext<'a> {
24 untracked: &'a Untracked,
25 // The value of `-Z incremental-ignore-spans`.
26 // This field should only be used by `unstable_opts_incremental_ignore_span`
27 incremental_ignore_spans: bool,
28 caching_source_map: CachingSourceMap<'a>,
29 hashing_controls: HashingControls,
30}
31
32impl<'a> StableHashingContext<'a> {
33 #[inline]
34 pub fn new(sess: &'a Session, untracked: &'a Untracked) -> Self {
35 let hash_spans_initial = !sess.opts.unstable_opts.incremental_ignore_spans;
36
37 StableHashingContext {
38 untracked,
39 incremental_ignore_spans: sess.opts.unstable_opts.incremental_ignore_spans,
40 caching_source_map: CachingSourceMap::Unused(sess.source_map()),
41 hashing_controls: HashingControls { hash_spans: hash_spans_initial },
42 }
43 }
44
45 #[inline]
46 pub fn while_hashing_spans<F: FnOnce(&mut Self)>(&mut self, hash_spans: bool, f: F) {
47 let prev_hash_spans = self.hashing_controls.hash_spans;
48 self.hashing_controls.hash_spans = hash_spans;
49 f(self);
50 self.hashing_controls.hash_spans = prev_hash_spans;
51 }
52
53 #[inline]
54 fn source_map(&mut self) -> &mut CachingSourceMapView<'a> {
55 match self.caching_source_map {
56 CachingSourceMap::InUse(ref mut sm) => sm,
57 CachingSourceMap::Unused(sm) => {
58 self.caching_source_map = CachingSourceMap::InUse(CachingSourceMapView::new(sm));
59 self.source_map() // this recursive call will hit the `InUse` case
60 }
61 }
62 }
63
64 #[inline]
65 fn def_span(&self, def_id: LocalDefId) -> Span {
66 self.untracked.source_span.get(def_id).unwrap_or(DUMMY_SP)
67 }
68
69 #[inline]
70 pub fn hashing_controls(&self) -> HashingControls {
71 self.hashing_controls
72 }
73}
74
75impl<'a> HashStableContext for StableHashingContext<'a> {
76 /// Hashes a span in a stable way. We can't directly hash the span's `BytePos` fields (that
77 /// would be similar to hashing pointers, since those are just offsets into the `SourceMap`).
78 /// Instead, we hash the (file name, line, column) triple, which stays the same even if the
79 /// containing `SourceFile` has moved within the `SourceMap`.
80 ///
81 /// Also note that we are hashing byte offsets for the column, not unicode codepoint offsets.
82 /// For the purpose of the hash that's sufficient. Also, hashing filenames is expensive so we
83 /// avoid doing it twice when the span starts and ends in the same file, which is almost always
84 /// the case.
85 ///
86 /// IMPORTANT: changes to this method should be reflected in implementations of `SpanEncoder`.
87 #[inline]
88 fn span_hash_stable(&mut self, raw_span: RawSpan, hasher: &mut StableHasher) {
89 const TAG_VALID_SPAN: u8 = 0;
90 const TAG_INVALID_SPAN: u8 = 1;
91 const TAG_RELATIVE_SPAN: u8 = 2;
92
93 if !self.hashing_controls().hash_spans {
94 return;
95 }
96
97 let span = Span::from_raw_span(raw_span);
98 let span = span.data_untracked();
99 span.ctxt.hash_stable(self, hasher);
100 span.parent.hash_stable(self, hasher);
101
102 if span.is_dummy() {
103 Hash::hash(&TAG_INVALID_SPAN, hasher);
104 return;
105 }
106
107 let parent = span.parent.map(|parent| self.def_span(parent).data_untracked());
108 if let Some(parent) = parent
109 && parent.contains(span)
110 {
111 // This span is enclosed in a definition: only hash the relative position. This catches
112 // a subset of the cases from the `file.contains(parent.lo)`. But we can do this check
113 // cheaply without the expensive `span_data_to_lines_and_cols` query.
114 Hash::hash(&TAG_RELATIVE_SPAN, hasher);
115 (span.lo - parent.lo).to_u32().hash_stable(self, hasher);
116 (span.hi - parent.lo).to_u32().hash_stable(self, hasher);
117 return;
118 }
119
120 // If this is not an empty or invalid span, we want to hash the last position that belongs
121 // to it, as opposed to hashing the first position past it.
122 let Some((file, line_lo, col_lo, line_hi, col_hi)) =
123 self.source_map().span_data_to_lines_and_cols(&span)
124 else {
125 Hash::hash(&TAG_INVALID_SPAN, hasher);
126 return;
127 };
128
129 if let Some(parent) = parent
130 && file.contains(parent.lo)
131 {
132 // This span is relative to another span in the same file,
133 // only hash the relative position.
134 Hash::hash(&TAG_RELATIVE_SPAN, hasher);
135 Hash::hash(&(span.lo.0.wrapping_sub(parent.lo.0)), hasher);
136 Hash::hash(&(span.hi.0.wrapping_sub(parent.lo.0)), hasher);
137 return;
138 }
139
140 Hash::hash(&TAG_VALID_SPAN, hasher);
141 Hash::hash(&file.stable_id, hasher);
142
143 // Hash both the length and the end location (line/column) of a span. If we hash only the
144 // length, for example, then two otherwise equal spans with different end locations will
145 // have the same hash. This can cause a problem during incremental compilation wherein a
146 // previous result for a query that depends on the end location of a span will be
147 // incorrectly reused when the end location of the span it depends on has changed (see
148 // issue #74890). A similar analysis applies if some query depends specifically on the
149 // length of the span, but we only hash the end location. So hash both.
150
151 let col_lo_trunc = (col_lo.0 as u64) & 0xFF;
152 let line_lo_trunc = ((line_lo as u64) & 0xFF_FF_FF) << 8;
153 let col_hi_trunc = (col_hi.0 as u64) & 0xFF << 32;
154 let line_hi_trunc = ((line_hi as u64) & 0xFF_FF_FF) << 40;
155 let col_line = col_lo_trunc | line_lo_trunc | col_hi_trunc | line_hi_trunc;
156 let len = (span.hi - span.lo).0;
157 Hash::hash(&col_line, hasher);
158 Hash::hash(&len, hasher);
159 }
160
161 #[inline]
162 fn def_path_hash(&self, raw_def_id: RawDefId) -> RawDefPathHash {
163 let def_id = DefId::from_raw_def_id(raw_def_id);
164 if let Some(def_id) = def_id.as_local() {
165 self.untracked.definitions.read().def_path_hash(def_id)
166 } else {
167 self.untracked.cstore.read().def_path_hash(def_id)
168 }
169 .to_raw_def_path_hash()
170 }
171
172 /// Assert that the provided `HashStableContext` is configured with the default
173 /// `HashingControls`. We should always have bailed out before getting to here with a
174 /// non-default mode. With this check in place, we can avoid the need to maintain separate
175 /// versions of `ExpnData` hashes for each permutation of `HashingControls` settings.
176 #[inline]
177 fn assert_default_hashing_controls(&self, msg: &str) {
178 let hashing_controls = self.hashing_controls;
179 let HashingControls { hash_spans } = hashing_controls;
180
181 // Note that we require that `hash_spans` be the inverse of the global `-Z
182 // incremental-ignore-spans` option. Normally, this option is disabled, in which case
183 // `hash_spans` must be true.
184 //
185 // Span hashing can also be disabled without `-Z incremental-ignore-spans`. This is the
186 // case for instance when building a hash for name mangling. Such configuration must not be
187 // used for metadata.
188 assert_eq!(
189 hash_spans, !self.incremental_ignore_spans,
190 "Attempted hashing of {msg} with non-default HashingControls: {hashing_controls:?}"
191 );
192 }
193
194 #[inline]
195 fn hashing_controls(&self) -> HashingControls {
196 self.hashing_controls
197 }
198}
compiler/rustc_middle/src/ich/hcx.rs deleted-189
......@@ -1,189 +0,0 @@
1use std::hash::Hash;
2
3use rustc_data_structures::stable_hasher::{HashStable, HashingControls, StableHasher};
4use rustc_hir::def_id::{DefId, LocalDefId};
5use rustc_hir::definitions::DefPathHash;
6use rustc_session::Session;
7use rustc_session::cstore::Untracked;
8use rustc_span::source_map::SourceMap;
9use rustc_span::{CachingSourceMapView, DUMMY_SP, HashStableContext, Pos, Span};
10
11// Very often, we are hashing something that does not need the `CachingSourceMapView`, so we
12// initialize it lazily.
13enum CachingSourceMap<'a> {
14 Unused(&'a SourceMap),
15 InUse(CachingSourceMapView<'a>),
16}
17
18/// This is the context state available during incr. comp. hashing. It contains
19/// enough information to transform `DefId`s and `HirId`s into stable `DefPath`s (i.e.,
20/// a reference to the `TyCtxt`) and it holds a few caches for speeding up various
21/// things (e.g., each `DefId`/`DefPath` is only hashed once).
22pub struct StableHashingContext<'a> {
23 untracked: &'a Untracked,
24 // The value of `-Z incremental-ignore-spans`.
25 // This field should only be used by `unstable_opts_incremental_ignore_span`
26 incremental_ignore_spans: bool,
27 caching_source_map: CachingSourceMap<'a>,
28 hashing_controls: HashingControls,
29}
30
31impl<'a> StableHashingContext<'a> {
32 #[inline]
33 pub fn new(sess: &'a Session, untracked: &'a Untracked) -> Self {
34 let hash_spans_initial = !sess.opts.unstable_opts.incremental_ignore_spans;
35
36 StableHashingContext {
37 untracked,
38 incremental_ignore_spans: sess.opts.unstable_opts.incremental_ignore_spans,
39 caching_source_map: CachingSourceMap::Unused(sess.source_map()),
40 hashing_controls: HashingControls { hash_spans: hash_spans_initial },
41 }
42 }
43
44 #[inline]
45 pub fn while_hashing_spans<F: FnOnce(&mut Self)>(&mut self, hash_spans: bool, f: F) {
46 let prev_hash_spans = self.hashing_controls.hash_spans;
47 self.hashing_controls.hash_spans = hash_spans;
48 f(self);
49 self.hashing_controls.hash_spans = prev_hash_spans;
50 }
51
52 #[inline]
53 fn source_map(&mut self) -> &mut CachingSourceMapView<'a> {
54 match self.caching_source_map {
55 CachingSourceMap::InUse(ref mut sm) => sm,
56 CachingSourceMap::Unused(sm) => {
57 self.caching_source_map = CachingSourceMap::InUse(CachingSourceMapView::new(sm));
58 self.source_map() // this recursive call will hit the `InUse` case
59 }
60 }
61 }
62
63 #[inline]
64 fn def_span(&self, def_id: LocalDefId) -> Span {
65 self.untracked.source_span.get(def_id).unwrap_or(DUMMY_SP)
66 }
67
68 #[inline]
69 pub fn hashing_controls(&self) -> HashingControls {
70 self.hashing_controls
71 }
72}
73
74impl<'a> HashStableContext for StableHashingContext<'a> {
75 /// Hashes a span in a stable way. We can't directly hash the span's `BytePos` fields (that
76 /// would be similar to hashing pointers, since those are just offsets into the `SourceMap`).
77 /// Instead, we hash the (file name, line, column) triple, which stays the same even if the
78 /// containing `SourceFile` has moved within the `SourceMap`.
79 ///
80 /// Also note that we are hashing byte offsets for the column, not unicode codepoint offsets.
81 /// For the purpose of the hash that's sufficient. Also, hashing filenames is expensive so we
82 /// avoid doing it twice when the span starts and ends in the same file, which is almost always
83 /// the case.
84 ///
85 /// IMPORTANT: changes to this method should be reflected in implementations of `SpanEncoder`.
86 #[inline]
87 fn span_hash_stable(&mut self, span: Span, hasher: &mut StableHasher) {
88 const TAG_VALID_SPAN: u8 = 0;
89 const TAG_INVALID_SPAN: u8 = 1;
90 const TAG_RELATIVE_SPAN: u8 = 2;
91
92 if !self.hashing_controls().hash_spans {
93 return;
94 }
95
96 let span = span.data_untracked();
97 span.ctxt.hash_stable(self, hasher);
98 span.parent.hash_stable(self, hasher);
99
100 if span.is_dummy() {
101 Hash::hash(&TAG_INVALID_SPAN, hasher);
102 return;
103 }
104
105 let parent = span.parent.map(|parent| self.def_span(parent).data_untracked());
106 if let Some(parent) = parent
107 && parent.contains(span)
108 {
109 // This span is enclosed in a definition: only hash the relative position. This catches
110 // a subset of the cases from the `file.contains(parent.lo)`. But we can do this check
111 // cheaply without the expensive `span_data_to_lines_and_cols` query.
112 Hash::hash(&TAG_RELATIVE_SPAN, hasher);
113 (span.lo - parent.lo).to_u32().hash_stable(self, hasher);
114 (span.hi - parent.lo).to_u32().hash_stable(self, hasher);
115 return;
116 }
117
118 // If this is not an empty or invalid span, we want to hash the last position that belongs
119 // to it, as opposed to hashing the first position past it.
120 let Some((file, line_lo, col_lo, line_hi, col_hi)) =
121 self.source_map().span_data_to_lines_and_cols(&span)
122 else {
123 Hash::hash(&TAG_INVALID_SPAN, hasher);
124 return;
125 };
126
127 if let Some(parent) = parent
128 && file.contains(parent.lo)
129 {
130 // This span is relative to another span in the same file,
131 // only hash the relative position.
132 Hash::hash(&TAG_RELATIVE_SPAN, hasher);
133 Hash::hash(&(span.lo.0.wrapping_sub(parent.lo.0)), hasher);
134 Hash::hash(&(span.hi.0.wrapping_sub(parent.lo.0)), hasher);
135 return;
136 }
137
138 Hash::hash(&TAG_VALID_SPAN, hasher);
139 Hash::hash(&file.stable_id, hasher);
140
141 // Hash both the length and the end location (line/column) of a span. If we hash only the
142 // length, for example, then two otherwise equal spans with different end locations will
143 // have the same hash. This can cause a problem during incremental compilation wherein a
144 // previous result for a query that depends on the end location of a span will be
145 // incorrectly reused when the end location of the span it depends on has changed (see
146 // issue #74890). A similar analysis applies if some query depends specifically on the
147 // length of the span, but we only hash the end location. So hash both.
148
149 let col_lo_trunc = (col_lo.0 as u64) & 0xFF;
150 let line_lo_trunc = ((line_lo as u64) & 0xFF_FF_FF) << 8;
151 let col_hi_trunc = (col_hi.0 as u64) & 0xFF << 32;
152 let line_hi_trunc = ((line_hi as u64) & 0xFF_FF_FF) << 40;
153 let col_line = col_lo_trunc | line_lo_trunc | col_hi_trunc | line_hi_trunc;
154 let len = (span.hi - span.lo).0;
155 Hash::hash(&col_line, hasher);
156 Hash::hash(&len, hasher);
157 }
158
159 #[inline]
160 fn def_path_hash(&self, def_id: DefId) -> DefPathHash {
161 if let Some(def_id) = def_id.as_local() {
162 self.untracked.definitions.read().def_path_hash(def_id)
163 } else {
164 self.untracked.cstore.read().def_path_hash(def_id)
165 }
166 }
167
168 /// Assert that the provided `HashStableContext` is configured with the default
169 /// `HashingControls`. We should always have bailed out before getting to here with a
170 /// non-default mode. With this check in place, we can avoid the need to maintain separate
171 /// versions of `ExpnData` hashes for each permutation of `HashingControls` settings.
172 #[inline]
173 fn assert_default_hashing_controls(&self, msg: &str) {
174 let hashing_controls = self.hashing_controls;
175 let HashingControls { hash_spans } = hashing_controls;
176
177 // Note that we require that `hash_spans` be the inverse of the global `-Z
178 // incremental-ignore-spans` option. Normally, this option is disabled, in which case
179 // `hash_spans` must be true.
180 //
181 // Span hashing can also be disabled without `-Z incremental-ignore-spans`. This is the
182 // case for instance when building a hash for name mangling. Such configuration must not be
183 // used for metadata.
184 assert_eq!(
185 hash_spans, !self.incremental_ignore_spans,
186 "Attempted hashing of {msg} with non-default HashingControls: {hashing_controls:?}"
187 );
188 }
189}
compiler/rustc_middle/src/ich/impls_syntax.rs deleted-40
......@@ -1,40 +0,0 @@
1//! This module contains `HashStable` implementations for various data types
2//! from various crates in no particular order.
3
4use rustc_ast as ast;
5use rustc_data_structures::stable_hasher::{HashStable, StableHasher};
6
7use super::StableHashingContext;
8
9impl<'a> HashStable<StableHashingContext<'a>> for ast::NodeId {
10 #[inline]
11 fn hash_stable(&self, _: &mut StableHashingContext<'a>, _: &mut StableHasher) {
12 panic!("Node IDs should not appear in incremental state");
13 }
14}
15
16impl<'tcx> HashStable<StableHashingContext<'tcx>> for rustc_feature::Features {
17 fn hash_stable(&self, hcx: &mut StableHashingContext<'tcx>, hasher: &mut StableHasher) {
18 // Unfortunately we cannot exhaustively list fields here, since the
19 // struct has private fields (to ensure its invariant is maintained)
20 self.enabled_lang_features().hash_stable(hcx, hasher);
21 self.enabled_lib_features().hash_stable(hcx, hasher);
22 }
23}
24
25impl<'tcx> HashStable<StableHashingContext<'tcx>> for rustc_feature::EnabledLangFeature {
26 fn hash_stable(&self, hcx: &mut StableHashingContext<'tcx>, hasher: &mut StableHasher) {
27 let rustc_feature::EnabledLangFeature { gate_name, attr_sp, stable_since } = self;
28 gate_name.hash_stable(hcx, hasher);
29 attr_sp.hash_stable(hcx, hasher);
30 stable_since.hash_stable(hcx, hasher);
31 }
32}
33
34impl<'tcx> HashStable<StableHashingContext<'tcx>> for rustc_feature::EnabledLibFeature {
35 fn hash_stable(&self, hcx: &mut StableHashingContext<'tcx>, hasher: &mut StableHasher) {
36 let rustc_feature::EnabledLibFeature { gate_name, attr_sp } = self;
37 gate_name.hash_stable(hcx, hasher);
38 attr_sp.hash_stable(hcx, hasher);
39 }
40}
compiler/rustc_middle/src/ich/mod.rs deleted-6
......@@ -1,6 +0,0 @@
1//! ICH - Incremental Compilation Hash
2
3pub use self::hcx::StableHashingContext;
4
5mod hcx;
6mod impls_syntax;
compiler/rustc_middle/src/middle/privacy.rs+3-4
......@@ -6,13 +6,12 @@ use std::cmp::Ordering;
66use std::hash::Hash;
77
88use rustc_data_structures::fx::{FxIndexMap, IndexEntry};
9use rustc_data_structures::stable_hasher::{HashStable, StableHasher};
9use rustc_data_structures::stable_hasher::{HashStable, HashStableContext, StableHasher};
1010use rustc_hir::def::DefKind;
1111use rustc_hir::{ItemKind, Node, UseKind};
1212use rustc_macros::HashStable;
1313use rustc_span::def_id::{CRATE_DEF_ID, LocalDefId};
1414
15use crate::ich::StableHashingContext;
1615use crate::ty::{TyCtxt, Visibility};
1716
1817/// Represents the levels of effective visibility an item can have.
......@@ -281,8 +280,8 @@ impl<Id> Default for EffectiveVisibilities<Id> {
281280 }
282281}
283282
284impl<'a> HashStable<StableHashingContext<'a>> for EffectiveVisibilities {
285 fn hash_stable(&self, hcx: &mut StableHashingContext<'a>, hasher: &mut StableHasher) {
283impl HashStable for EffectiveVisibilities {
284 fn hash_stable<Hcx: HashStableContext>(&self, hcx: &mut Hcx, hasher: &mut StableHasher) {
286285 let EffectiveVisibilities { ref map } = *self;
287286 map.hash_stable(hcx, hasher);
288287 }
compiler/rustc_middle/src/mir/basic_blocks.rs+3-3
......@@ -2,7 +2,7 @@ use std::sync::{Arc, OnceLock};
22
33use rustc_data_structures::graph;
44use rustc_data_structures::graph::dominators::{Dominators, dominators};
5use rustc_data_structures::stable_hasher::{HashStable, StableHasher};
5use rustc_data_structures::stable_hasher::{HashStable, HashStableContext, StableHasher};
66use rustc_index::{IndexSlice, IndexVec};
77use rustc_macros::{HashStable, TyDecodable, TyEncodable, TypeFoldable, TypeVisitable};
88use rustc_serialize::{Decodable, Decoder, Encodable, Encoder};
......@@ -171,7 +171,7 @@ impl<D: Decoder> Decodable<D> for Cache {
171171 }
172172}
173173
174impl<Hcx> HashStable<Hcx> for Cache {
174impl HashStable for Cache {
175175 #[inline]
176 fn hash_stable(&self, _: &mut Hcx, _: &mut StableHasher) {}
176 fn hash_stable<Hcx: HashStableContext>(&self, _: &mut Hcx, _: &mut StableHasher) {}
177177}
compiler/rustc_middle/src/mono.rs+7-6
......@@ -5,7 +5,9 @@ use std::hash::Hash;
55use rustc_data_structures::base_n::{BaseNString, CASE_INSENSITIVE, ToBaseN};
66use rustc_data_structures::fingerprint::Fingerprint;
77use rustc_data_structures::fx::FxIndexMap;
8use rustc_data_structures::stable_hasher::{HashStable, StableHasher, ToStableHashKey};
8use rustc_data_structures::stable_hasher::{
9 HashStable, HashStableContext, StableHasher, ToStableHashKey,
10};
911use rustc_data_structures::unord::UnordMap;
1012use rustc_hashes::Hash128;
1113use rustc_hir::ItemId;
......@@ -19,7 +21,6 @@ use tracing::debug;
1921
2022use crate::dep_graph::dep_node::{make_compile_codegen_unit, make_compile_mono_item};
2123use crate::dep_graph::{DepNode, WorkProduct, WorkProductId};
22use crate::ich::StableHashingContext;
2324use crate::middle::codegen_fn_attrs::CodegenFnAttrFlags;
2425use crate::ty::{self, GenericArgs, Instance, InstanceKind, SymbolName, Ty, TyCtxt};
2526
......@@ -325,10 +326,10 @@ impl<'tcx> fmt::Display for MonoItem<'tcx> {
325326 }
326327}
327328
328impl ToStableHashKey<StableHashingContext<'_>> for MonoItem<'_> {
329impl ToStableHashKey for MonoItem<'_> {
329330 type KeyType = Fingerprint;
330331
331 fn to_stable_hash_key(&self, hcx: &mut StableHashingContext<'_>) -> Self::KeyType {
332 fn to_stable_hash_key<Hcx: HashStableContext>(&self, hcx: &mut Hcx) -> Self::KeyType {
332333 let mut hasher = StableHasher::new();
333334 self.hash_stable(hcx, &mut hasher);
334335 hasher.finish()
......@@ -581,10 +582,10 @@ impl<'tcx> CodegenUnit<'tcx> {
581582 }
582583}
583584
584impl ToStableHashKey<StableHashingContext<'_>> for CodegenUnit<'_> {
585impl ToStableHashKey for CodegenUnit<'_> {
585586 type KeyType = String;
586587
587 fn to_stable_hash_key(&self, _: &mut StableHashingContext<'_>) -> Self::KeyType {
588 fn to_stable_hash_key<Hcx>(&self, _: &mut Hcx) -> Self::KeyType {
588589 // Codegen unit names are conceptually required to be stable across
589590 // compilation session so that object file names match up.
590591 self.name.to_string()
compiler/rustc_middle/src/query/keys.rs+1-2
......@@ -11,7 +11,6 @@ use rustc_hir::hir_id::OwnerId;
1111use rustc_span::{DUMMY_SP, Ident, LocalExpnId, Span, Symbol};
1212
1313use crate::dep_graph::DepNodeIndex;
14use crate::ich::StableHashingContext;
1514use crate::infer::canonical::CanonicalQueryInput;
1615use crate::mono::CollectionMode;
1716use crate::query::{DefIdCache, DefaultCache, SingleCache, VecCache};
......@@ -24,7 +23,7 @@ use crate::{mir, traits};
2423#[derive(Copy, Clone, Debug)]
2524pub struct LocalCrate;
2625
27pub trait QueryKeyBounds = Copy + Debug + Eq + Hash + for<'a> HashStable<StableHashingContext<'a>>;
26pub trait QueryKeyBounds = Copy + Debug + Eq + Hash + HashStable;
2827
2928/// Controls what types can legally be used as the key for a query.
3029pub trait QueryKey: Sized + QueryKeyBounds {
compiler/rustc_middle/src/ty/adt.rs+5-4
......@@ -7,7 +7,9 @@ use rustc_abi::{FIRST_VARIANT, FieldIdx, ReprOptions, VariantIdx};
77use rustc_data_structures::fingerprint::Fingerprint;
88use rustc_data_structures::fx::FxHashMap;
99use rustc_data_structures::intern::Interned;
10use rustc_data_structures::stable_hasher::{HashStable, HashingControls, StableHasher};
10use rustc_data_structures::stable_hasher::{
11 HashStable, HashStableContext, HashingControls, StableHasher,
12};
1113use rustc_errors::ErrorGuaranteed;
1214use rustc_hir::def::{CtorKind, DefKind, Res};
1315use rustc_hir::def_id::DefId;
......@@ -23,7 +25,6 @@ use tracing::{debug, info, trace};
2325use super::{
2426 AsyncDestructor, Destructor, FieldDef, GenericPredicates, Ty, TyCtxt, VariantDef, VariantDiscr,
2527};
26use crate::ich::StableHashingContext;
2728use crate::mir::interpret::ErrorHandled;
2829use crate::ty::util::{Discr, IntTypeExt};
2930use crate::ty::{self, ConstKind};
......@@ -151,8 +152,8 @@ impl Hash for AdtDefData {
151152 }
152153}
153154
154impl<'a> HashStable<StableHashingContext<'a>> for AdtDefData {
155 fn hash_stable(&self, hcx: &mut StableHashingContext<'a>, hasher: &mut StableHasher) {
155impl HashStable for AdtDefData {
156 fn hash_stable<Hcx: HashStableContext>(&self, hcx: &mut Hcx, hasher: &mut StableHasher) {
156157 thread_local! {
157158 static CACHE: RefCell<FxHashMap<(usize, HashingControls), Fingerprint>> = Default::default();
158159 }
compiler/rustc_middle/src/ty/consts/int.rs+7-2
......@@ -4,6 +4,7 @@ use std::num::NonZero;
44use rustc_abi::Size;
55use rustc_apfloat::Float;
66use rustc_apfloat::ieee::{Double, Half, Quad, Single};
7use rustc_data_structures::stable_hasher::{HashStable, HashStableContext};
78use rustc_serialize::{Decodable, Decoder, Encodable, Encoder};
89
910use crate::ty::TyCtxt;
......@@ -151,8 +152,12 @@ pub struct ScalarInt {
151152
152153// Cannot derive these, as the derives take references to the fields, and we
153154// can't take references to fields of packed structs.
154impl<Hcx> crate::ty::HashStable<Hcx> for ScalarInt {
155 fn hash_stable(&self, hcx: &mut Hcx, hasher: &mut crate::ty::StableHasher) {
155impl HashStable for ScalarInt {
156 fn hash_stable<Hcx: HashStableContext>(
157 &self,
158 hcx: &mut Hcx,
159 hasher: &mut crate::ty::StableHasher,
160 ) {
156161 // Using a block `{self.data}` here to force a copy instead of using `self.data`
157162 // directly, because `hash_stable` takes `&self` and would thus borrow `self.data`.
158163 // Since `Self` is a packed struct, that would create a possibly unaligned reference,
compiler/rustc_middle/src/ty/context.rs+2-2
......@@ -547,7 +547,7 @@ pub struct TyCtxtFeed<'tcx, KEY: Copy> {
547547
548548/// Never return a `Feed` from a query. Only queries that create a `DefId` are
549549/// allowed to feed queries for that `DefId`.
550impl<KEY: Copy, Hcx> !HashStable<Hcx> for TyCtxtFeed<'_, KEY> {}
550impl<KEY: Copy> !HashStable for TyCtxtFeed<'_, KEY> {}
551551
552552/// The same as `TyCtxtFeed`, but does not contain a `TyCtxt`.
553553/// Use this to pass around when you have a `TyCtxt` elsewhere.
......@@ -562,7 +562,7 @@ pub struct Feed<'tcx, KEY: Copy> {
562562
563563/// Never return a `Feed` from a query. Only queries that create a `DefId` are
564564/// allowed to feed queries for that `DefId`.
565impl<KEY: Copy, Hcx> !HashStable<Hcx> for Feed<'_, KEY> {}
565impl<KEY: Copy> !HashStable for Feed<'_, KEY> {}
566566
567567impl<T: fmt::Debug + Copy> fmt::Debug for Feed<'_, T> {
568568 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
compiler/rustc_middle/src/ty/impls_ty.rs+15-16
......@@ -7,19 +7,18 @@ use std::ptr;
77use rustc_data_structures::fingerprint::Fingerprint;
88use rustc_data_structures::fx::FxHashMap;
99use rustc_data_structures::stable_hasher::{
10 HashStable, HashingControls, StableHasher, ToStableHashKey,
10 HashStable, HashStableContext, HashingControls, StableHasher, ToStableHashKey,
1111};
1212use tracing::trace;
1313
14use crate::ich::StableHashingContext;
1514use crate::middle::region;
1615use crate::{mir, ty};
1716
18impl<'a, 'tcx, H, T> HashStable<StableHashingContext<'a>> for &'tcx ty::list::RawList<H, T>
17impl<'tcx, H, T> HashStable for &'tcx ty::list::RawList<H, T>
1918where
20 T: HashStable<StableHashingContext<'a>>,
19 T: HashStable,
2120{
22 fn hash_stable(&self, hcx: &mut StableHashingContext<'a>, hasher: &mut StableHasher) {
21 fn hash_stable<Hcx: HashStableContext>(&self, hcx: &mut Hcx, hasher: &mut StableHasher) {
2322 // Note: this cache makes an *enormous* performance difference on certain benchmarks. E.g.
2423 // without it, compiling `diesel-2.2.10` can be 74% slower, and compiling
2524 // `deeply-nested-multi` can be ~4,000x slower(!)
......@@ -46,29 +45,29 @@ where
4645 }
4746}
4847
49impl<'a, 'tcx, H, T> ToStableHashKey<StableHashingContext<'a>> for &'tcx ty::list::RawList<H, T>
48impl<'tcx, H, T> ToStableHashKey for &'tcx ty::list::RawList<H, T>
5049where
51 T: HashStable<StableHashingContext<'a>>,
50 T: HashStable,
5251{
5352 type KeyType = Fingerprint;
5453
5554 #[inline]
56 fn to_stable_hash_key(&self, hcx: &mut StableHashingContext<'a>) -> Fingerprint {
55 fn to_stable_hash_key<Hcx: HashStableContext>(&self, hcx: &mut Hcx) -> Fingerprint {
5756 let mut hasher = StableHasher::new();
5857 self.hash_stable(hcx, &mut hasher);
5958 hasher.finish()
6059 }
6160}
6261
63impl<'a, 'tcx> HashStable<StableHashingContext<'a>> for ty::GenericArg<'tcx> {
64 fn hash_stable(&self, hcx: &mut StableHashingContext<'a>, hasher: &mut StableHasher) {
62impl<'tcx> HashStable for ty::GenericArg<'tcx> {
63 fn hash_stable<Hcx: HashStableContext>(&self, hcx: &mut Hcx, hasher: &mut StableHasher) {
6564 self.kind().hash_stable(hcx, hasher);
6665 }
6766}
6867
6968// AllocIds get resolved to whatever they point to (to be stable)
70impl<'a> HashStable<StableHashingContext<'a>> for mir::interpret::AllocId {
71 fn hash_stable(&self, hcx: &mut StableHashingContext<'a>, hasher: &mut StableHasher) {
69impl HashStable for mir::interpret::AllocId {
70 fn hash_stable<Hcx: HashStableContext>(&self, hcx: &mut Hcx, hasher: &mut StableHasher) {
7271 ty::tls::with_opt(|tcx| {
7372 trace!("hashing {:?}", *self);
7473 let tcx = tcx.expect("can't hash AllocIds during hir lowering");
......@@ -77,17 +76,17 @@ impl<'a> HashStable<StableHashingContext<'a>> for mir::interpret::AllocId {
7776 }
7877}
7978
80impl<'a> HashStable<StableHashingContext<'a>> for mir::interpret::CtfeProvenance {
81 fn hash_stable(&self, hcx: &mut StableHashingContext<'a>, hasher: &mut StableHasher) {
79impl HashStable for mir::interpret::CtfeProvenance {
80 fn hash_stable<Hcx: HashStableContext>(&self, hcx: &mut Hcx, hasher: &mut StableHasher) {
8281 self.into_parts().hash_stable(hcx, hasher);
8382 }
8483}
8584
86impl<'a> ToStableHashKey<StableHashingContext<'a>> for region::Scope {
85impl ToStableHashKey for region::Scope {
8786 type KeyType = region::Scope;
8887
8988 #[inline]
90 fn to_stable_hash_key(&self, _: &mut StableHashingContext<'a>) -> region::Scope {
89 fn to_stable_hash_key<Hcx>(&self, _: &mut Hcx) -> region::Scope {
9190 *self
9291 }
9392}
compiler/rustc_middle/src/ty/mod.rs+3-4
......@@ -33,7 +33,7 @@ use rustc_ast::node_id::NodeMap;
3333pub use rustc_ast_ir::{Movability, Mutability, try_visit};
3434use rustc_data_structures::fx::{FxHashSet, FxIndexMap, FxIndexSet};
3535use rustc_data_structures::intern::Interned;
36use rustc_data_structures::stable_hasher::{HashStable, StableHasher};
36use rustc_data_structures::stable_hasher::{HashStable, HashStableContext, StableHasher};
3737use rustc_data_structures::steal::Steal;
3838use rustc_data_structures::unord::{UnordMap, UnordSet};
3939use rustc_errors::{Diag, ErrorGuaranteed, LintBuffer};
......@@ -117,7 +117,6 @@ pub use self::typeck_results::{
117117 Rust2024IncompatiblePatInfo, TypeckResults, UserType, UserTypeAnnotationIndex, UserTypeKind,
118118};
119119use crate::error::{OpaqueHiddenTypeMismatch, TypeMismatchReason};
120use crate::ich::StableHashingContext;
121120use crate::metadata::{AmbigModChild, ModChild};
122121use crate::middle::privacy::EffectiveVisibilities;
123122use crate::mir::{Body, CoroutineLayout, CoroutineSavedLocal, SourceInfo};
......@@ -558,8 +557,8 @@ impl<'tcx> From<Const<'tcx>> for Term<'tcx> {
558557 }
559558}
560559
561impl<'a, 'tcx> HashStable<StableHashingContext<'a>> for Term<'tcx> {
562 fn hash_stable(&self, hcx: &mut StableHashingContext<'a>, hasher: &mut StableHasher) {
560impl<'tcx> HashStable for Term<'tcx> {
561 fn hash_stable<Hcx: HashStableContext>(&self, hcx: &mut Hcx, hasher: &mut StableHasher) {
563562 self.kind().hash_stable(hcx, hasher);
564563 }
565564}
compiler/rustc_next_trait_solver/src/solve/eval_ctxt/mod.rs+2-2
......@@ -2,7 +2,7 @@ use std::mem;
22use std::ops::ControlFlow;
33
44#[cfg(feature = "nightly")]
5use rustc_macros::HashStable_NoContext;
5use rustc_macros::HashStable;
66use rustc_type_ir::data_structures::{HashMap, HashSet};
77use rustc_type_ir::inherent::*;
88use rustc_type_ir::relate::Relate;
......@@ -137,7 +137,7 @@ where
137137}
138138
139139#[derive(PartialEq, Eq, Debug, Hash, Clone, Copy)]
140#[cfg_attr(feature = "nightly", derive(HashStable_NoContext))]
140#[cfg_attr(feature = "nightly", derive(HashStable))]
141141pub enum GenerateProofTree {
142142 Yes,
143143 No,
compiler/rustc_session/src/config.rs+11-12
......@@ -19,12 +19,11 @@ use rustc_errors::emitter::HumanReadableErrorType;
1919use rustc_errors::{ColorConfig, DiagCtxtFlags};
2020use rustc_feature::UnstableFeatures;
2121use rustc_hashes::Hash64;
22use rustc_macros::{BlobDecodable, Decodable, Encodable, HashStable_Generic};
22use rustc_macros::{BlobDecodable, Decodable, Encodable, HashStable};
2323use rustc_span::edition::{DEFAULT_EDITION, EDITION_NAME_LIST, Edition, LATEST_STABLE_EDITION};
2424use rustc_span::source_map::FilePathMapping;
2525use rustc_span::{
26 FileName, HashStableContext, RealFileName, RemapPathScopeComponents, SourceFileHashAlgorithm,
27 Symbol, sym,
26 FileName, RealFileName, RemapPathScopeComponents, SourceFileHashAlgorithm, Symbol, sym,
2827};
2928use rustc_target::spec::{
3029 FramePointer, LinkSelfContainedComponents, LinkerFeatures, PanicStrategy, SplitDebuginfo,
......@@ -89,7 +88,7 @@ pub enum CFProtection {
8988 Full,
9089}
9190
92#[derive(Clone, Copy, Debug, PartialEq, Hash, HashStable_Generic, Encodable, Decodable)]
91#[derive(Clone, Copy, Debug, PartialEq, Hash, HashStable, Encodable, Decodable)]
9392pub enum OptLevel {
9493 /// `-Copt-level=0`
9594 No,
......@@ -544,7 +543,7 @@ impl SwitchWithOptPath {
544543 }
545544}
546545
547#[derive(Copy, Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash, HashStable_Generic)]
546#[derive(Copy, Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash, HashStable)]
548547#[derive(Encodable, BlobDecodable)]
549548pub enum SymbolManglingVersion {
550549 Legacy,
......@@ -620,7 +619,7 @@ macro_rules! define_output_types {
620619 }
621620 ),* $(,)?
622621 ) => {
623 #[derive(Clone, Copy, PartialEq, Eq, Hash, Debug, PartialOrd, Ord, HashStable_Generic)]
622 #[derive(Clone, Copy, PartialEq, Eq, Hash, Debug, PartialOrd, Ord, HashStable)]
624623 #[derive(Encodable, Decodable)]
625624 pub enum OutputType {
626625 $(
......@@ -637,10 +636,10 @@ macro_rules! define_output_types {
637636 const THIS_IMPLEMENTATION_HAS_BEEN_TRIPLE_CHECKED: () = ();
638637 }
639638
640 impl<Hcx: HashStableContext> ToStableHashKey<Hcx> for OutputType {
639 impl ToStableHashKey for OutputType {
641640 type KeyType = Self;
642641
643 fn to_stable_hash_key(&self, _: &mut Hcx) -> Self::KeyType {
642 fn to_stable_hash_key<Hcx>(&self, _: &mut Hcx) -> Self::KeyType {
644643 *self
645644 }
646645 }
......@@ -841,7 +840,7 @@ pub enum ResolveDocLinks {
841840/// *Do not* switch `BTreeMap` out for an unsorted container type! That would break
842841/// dependency tracking for command-line arguments. Also only hash keys, since tracking
843842/// should only depend on the output types, not the paths they're written to.
844#[derive(Clone, Debug, Hash, HashStable_Generic, Encodable, Decodable)]
843#[derive(Clone, Debug, Hash, HashStable, Encodable, Decodable)]
845844pub struct OutputTypes(BTreeMap<OutputType, Option<OutFileName>>);
846845
847846impl OutputTypes {
......@@ -1055,7 +1054,7 @@ impl Input {
10551054 }
10561055}
10571056
1058#[derive(Clone, Hash, Debug, HashStable_Generic, PartialEq, Eq, Encodable, Decodable)]
1057#[derive(Clone, Hash, Debug, HashStable, PartialEq, Eq, Encodable, Decodable)]
10591058pub enum OutFileName {
10601059 Real(PathBuf),
10611060 Stdout,
......@@ -1130,7 +1129,7 @@ impl OutFileName {
11301129 }
11311130}
11321131
1133#[derive(Clone, Hash, Debug, HashStable_Generic, Encodable, Decodable)]
1132#[derive(Clone, Hash, Debug, HashStable, Encodable, Decodable)]
11341133pub struct OutputFilenames {
11351134 pub(crate) out_directory: PathBuf,
11361135 /// Crate name. Never contains '-'.
......@@ -1524,7 +1523,7 @@ impl UnstableOptions {
15241523}
15251524
15261525// The type of entry function, so users can have their own entry functions
1527#[derive(Copy, Clone, PartialEq, Hash, Debug, HashStable_Generic)]
1526#[derive(Copy, Clone, PartialEq, Hash, Debug, HashStable)]
15281527pub enum EntryFnType {
15291528 Main {
15301529 /// Specifies what to do with `SIGPIPE` before calling `fn main()`.
compiler/rustc_session/src/cstore.rs+11-11
......@@ -12,14 +12,14 @@ use rustc_hir::def_id::{
1212 CrateNum, DefId, LOCAL_CRATE, LocalDefId, StableCrateId, StableCrateIdMap,
1313};
1414use rustc_hir::definitions::{DefKey, DefPath, DefPathHash, Definitions};
15use rustc_macros::{BlobDecodable, Decodable, Encodable, HashStable_Generic};
15use rustc_macros::{BlobDecodable, Decodable, Encodable, HashStable};
1616use rustc_span::{Span, Symbol};
1717
1818// lonely orphan structs and enums looking for a better home
1919
2020/// Where a crate came from on the local filesystem. One of these three options
2121/// must be non-None.
22#[derive(PartialEq, Clone, Debug, HashStable_Generic, Encodable, Decodable)]
22#[derive(PartialEq, Clone, Debug, HashStable, Encodable, Decodable)]
2323pub struct CrateSource {
2424 pub dylib: Option<PathBuf>,
2525 pub rlib: Option<PathBuf>,
......@@ -35,7 +35,7 @@ impl CrateSource {
3535}
3636
3737#[derive(Encodable, BlobDecodable, Copy, Clone, Ord, PartialOrd, Eq, PartialEq, Debug)]
38#[derive(HashStable_Generic)]
38#[derive(HashStable)]
3939pub enum CrateDepKind {
4040 /// A dependency that is only used for its macros.
4141 MacrosOnly,
......@@ -58,13 +58,13 @@ impl CrateDepKind {
5858 }
5959}
6060
61#[derive(Copy, Debug, PartialEq, Clone, Encodable, BlobDecodable, HashStable_Generic)]
61#[derive(Copy, Debug, PartialEq, Clone, Encodable, BlobDecodable, HashStable)]
6262pub enum LinkagePreference {
6363 RequireDynamic,
6464 RequireStatic,
6565}
6666
67#[derive(Debug, Encodable, Decodable, HashStable_Generic)]
67#[derive(Debug, Encodable, Decodable, HashStable)]
6868pub struct NativeLib {
6969 pub kind: NativeLibKind,
7070 pub name: Symbol,
......@@ -86,7 +86,7 @@ impl NativeLib {
8686 }
8787}
8888
89#[derive(Clone, Debug, Encodable, Decodable, HashStable_Generic)]
89#[derive(Clone, Debug, Encodable, Decodable, HashStable)]
9090pub struct DllImport {
9191 pub name: Symbol,
9292 pub import_name_type: Option<PeImportNameType>,
......@@ -101,7 +101,7 @@ pub struct DllImport {
101101 pub size: rustc_abi::Size,
102102}
103103
104#[derive(Copy, Clone, Debug, Encodable, Decodable, HashStable_Generic, PartialEq)]
104#[derive(Copy, Clone, Debug, Encodable, Decodable, HashStable, PartialEq)]
105105pub enum DllImportSymbolType {
106106 Function,
107107 Static,
......@@ -127,7 +127,7 @@ impl DllImport {
127127///
128128/// The usize value, where present, indicates the size of the function's argument list
129129/// in bytes.
130#[derive(Clone, PartialEq, Debug, Encodable, Decodable, HashStable_Generic)]
130#[derive(Clone, PartialEq, Debug, Encodable, Decodable, HashStable)]
131131pub enum DllCallingConvention {
132132 C,
133133 Stdcall(usize),
......@@ -135,14 +135,14 @@ pub enum DllCallingConvention {
135135 Vectorcall(usize),
136136}
137137
138#[derive(Clone, Encodable, Decodable, HashStable_Generic, Debug)]
138#[derive(Clone, Encodable, Decodable, HashStable, Debug)]
139139pub struct ForeignModule {
140140 pub foreign_items: Vec<DefId>,
141141 pub def_id: DefId,
142142 pub abi: ExternAbi,
143143}
144144
145#[derive(Copy, Clone, Debug, HashStable_Generic)]
145#[derive(Copy, Clone, Debug, HashStable)]
146146pub struct ExternCrate {
147147 pub src: ExternCrateSource,
148148
......@@ -175,7 +175,7 @@ impl ExternCrate {
175175 }
176176}
177177
178#[derive(Copy, Clone, Debug, HashStable_Generic)]
178#[derive(Copy, Clone, Debug, HashStable)]
179179pub enum ExternCrateSource {
180180 /// Crate is loaded by `extern crate`.
181181 Extern(
compiler/rustc_session/src/search_paths.rs+2-2
......@@ -1,7 +1,7 @@
11use std::path::{Path, PathBuf};
22use std::sync::Arc;
33
4use rustc_macros::{Decodable, Encodable, HashStable_Generic};
4use rustc_macros::{Decodable, Encodable, HashStable};
55use rustc_target::spec::TargetTuple;
66
77use crate::EarlyDiagCtxt;
......@@ -71,7 +71,7 @@ impl SearchPathFile {
7171 }
7272}
7373
74#[derive(PartialEq, Clone, Copy, Debug, Hash, Eq, Encodable, Decodable, HashStable_Generic)]
74#[derive(PartialEq, Clone, Copy, Debug, Hash, Eq, Encodable, Decodable, HashStable)]
7575pub enum PathKind {
7676 Native,
7777 Crate,
compiler/rustc_session/src/session.rs+2-2
......@@ -24,7 +24,7 @@ use rustc_errors::{
2424};
2525use rustc_feature::UnstableFeatures;
2626use rustc_hir::limit::Limit;
27use rustc_macros::HashStable_Generic;
27use rustc_macros::HashStable;
2828pub use rustc_span::def_id::StableCrateId;
2929use rustc_span::edition::Edition;
3030use rustc_span::source_map::{FilePathMapping, SourceMap};
......@@ -61,7 +61,7 @@ pub enum CtfeBacktrace {
6161 Immediate,
6262}
6363
64#[derive(Clone, Copy, Debug, HashStable_Generic)]
64#[derive(Clone, Copy, Debug, HashStable)]
6565pub struct Limits {
6666 /// The maximum recursion limit for potentially infinitely recursive
6767 /// operations such as auto-dereference and monomorphization.
compiler/rustc_session/src/utils.rs+2-2
......@@ -4,7 +4,7 @@ use std::sync::OnceLock;
44use rustc_data_structures::profiling::VerboseTimingGuard;
55use rustc_fs_util::try_canonicalize;
66use rustc_hir::attrs::NativeLibKind;
7use rustc_macros::{Decodable, Encodable, HashStable_Generic};
7use rustc_macros::{Decodable, Encodable, HashStable};
88
99use crate::session::Session;
1010
......@@ -19,7 +19,7 @@ impl Session {
1919}
2020
2121#[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash, Encodable, Decodable)]
22#[derive(HashStable_Generic)]
22#[derive(HashStable)]
2323pub struct NativeLib {
2424 pub name: String,
2525 pub new_name: Option<String>,
compiler/rustc_span/src/def_id.rs+50-25
......@@ -3,14 +3,17 @@ use std::hash::{BuildHasherDefault, Hash, Hasher};
33
44use rustc_data_structures::AtomicRef;
55use rustc_data_structures::fingerprint::Fingerprint;
6use rustc_data_structures::stable_hasher::{HashStable, StableHasher, StableOrd, ToStableHashKey};
6use rustc_data_structures::stable_hasher::{
7 HashStable, HashStableContext, RawDefId, RawDefPathHash, StableHasher, StableOrd,
8 ToStableHashKey,
9};
710use rustc_data_structures::unhash::Unhasher;
811use rustc_hashes::Hash64;
912use rustc_index::Idx;
10use rustc_macros::{BlobDecodable, Decodable, Encodable, HashStable_Generic};
13use rustc_macros::{BlobDecodable, Decodable, Encodable, HashStable};
1114use rustc_serialize::{Decodable, Encodable};
1215
13use crate::{HashStableContext, SpanDecoder, SpanEncoder, Symbol};
16use crate::{SpanDecoder, SpanEncoder, Symbol};
1417
1518pub type StableCrateIdMap =
1619 indexmap::IndexMap<StableCrateId, CrateNum, BuildHasherDefault<Unhasher>>;
......@@ -91,7 +94,7 @@ impl fmt::Display for CrateNum {
9194/// collision occurring. For a big crate graph with 1000 crates in it, there is
9295/// a probability of 1 in 36,890,000,000,000 of a `StableCrateId` collision.
9396#[derive(Copy, Clone, Hash, PartialEq, Eq, PartialOrd, Ord, Debug)]
94#[derive(HashStable_Generic, Encodable, Decodable)]
97#[derive(HashStable, Encodable, Decodable)]
9598pub struct DefPathHash(pub Fingerprint);
9699
97100impl DefPathHash {
......@@ -114,6 +117,16 @@ impl DefPathHash {
114117 pub fn new(stable_crate_id: StableCrateId, local_hash: Hash64) -> DefPathHash {
115118 DefPathHash(Fingerprint::new(stable_crate_id.0, local_hash))
116119 }
120
121 #[inline]
122 pub fn to_raw_def_path_hash(self) -> RawDefPathHash {
123 RawDefPathHash(self.0.to_le_bytes())
124 }
125
126 #[inline]
127 pub fn from_raw_def_path_hash(RawDefPathHash(a): RawDefPathHash) -> DefPathHash {
128 DefPathHash(Fingerprint::from_le_bytes(a))
129 }
117130}
118131
119132impl Default for DefPathHash {
......@@ -141,7 +154,7 @@ impl StableOrd for DefPathHash {
141154/// For more information on the possibility of hash collisions in rustc,
142155/// see the discussion in [`DefId`].
143156#[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Debug)]
144#[derive(Hash, HashStable_Generic, Encodable, BlobDecodable)]
157#[derive(Hash, HashStable, Encodable, BlobDecodable)]
145158pub struct StableCrateId(pub(crate) Hash64);
146159
147160impl StableCrateId {
......@@ -312,6 +325,18 @@ impl DefId {
312325 pub fn is_top_level_module(self) -> bool {
313326 self.is_local() && self.is_crate_root()
314327 }
328
329 #[inline]
330 pub fn to_raw_def_id(self) -> RawDefId {
331 // Field order must match `from_raw_def_id`.
332 RawDefId(self.krate.as_u32(), self.index.as_u32())
333 }
334
335 #[inline]
336 pub fn from_raw_def_id(RawDefId(a, b): RawDefId) -> DefId {
337 // Field order must match `to_raw_def_id`.
338 DefId { krate: a.into(), index: b.into() }
339 }
315340}
316341
317342impl From<LocalDefId> for DefId {
......@@ -402,66 +427,66 @@ rustc_data_structures::define_id_collections!(
402427 LocalDefId
403428);
404429
405impl<Hcx: HashStableContext> HashStable<Hcx> for DefId {
430impl HashStable for DefId {
406431 #[inline]
407 fn hash_stable(&self, hcx: &mut Hcx, hasher: &mut StableHasher) {
408 hcx.def_path_hash(*self).hash_stable(hcx, hasher);
432 fn hash_stable<Hcx: HashStableContext>(&self, hcx: &mut Hcx, hasher: &mut StableHasher) {
433 self.to_stable_hash_key(hcx).hash_stable(hcx, hasher);
409434 }
410435}
411436
412impl<Hcx: HashStableContext> HashStable<Hcx> for LocalDefId {
437impl HashStable for LocalDefId {
413438 #[inline]
414 fn hash_stable(&self, hcx: &mut Hcx, hasher: &mut StableHasher) {
415 hcx.def_path_hash(self.to_def_id()).local_hash().hash_stable(hcx, hasher);
439 fn hash_stable<Hcx: HashStableContext>(&self, hcx: &mut Hcx, hasher: &mut StableHasher) {
440 self.to_stable_hash_key(hcx).local_hash().hash_stable(hcx, hasher);
416441 }
417442}
418443
419impl<Hcx: HashStableContext> HashStable<Hcx> for CrateNum {
444impl HashStable for CrateNum {
420445 #[inline]
421 fn hash_stable(&self, hcx: &mut Hcx, hasher: &mut StableHasher) {
446 fn hash_stable<Hcx: HashStableContext>(&self, hcx: &mut Hcx, hasher: &mut StableHasher) {
422447 self.as_def_id().to_stable_hash_key(hcx).stable_crate_id().hash_stable(hcx, hasher);
423448 }
424449}
425450
426impl<Hcx: HashStableContext> ToStableHashKey<Hcx> for DefId {
451impl ToStableHashKey for DefId {
427452 type KeyType = DefPathHash;
428453
429454 #[inline]
430 fn to_stable_hash_key(&self, hcx: &mut Hcx) -> DefPathHash {
431 hcx.def_path_hash(*self)
455 fn to_stable_hash_key<Hcx: HashStableContext>(&self, hcx: &mut Hcx) -> DefPathHash {
456 DefPathHash::from_raw_def_path_hash(hcx.def_path_hash(self.to_raw_def_id()))
432457 }
433458}
434459
435impl<Hcx: HashStableContext> ToStableHashKey<Hcx> for LocalDefId {
460impl ToStableHashKey for LocalDefId {
436461 type KeyType = DefPathHash;
437462
438463 #[inline]
439 fn to_stable_hash_key(&self, hcx: &mut Hcx) -> DefPathHash {
440 hcx.def_path_hash(self.to_def_id())
464 fn to_stable_hash_key<Hcx: HashStableContext>(&self, hcx: &mut Hcx) -> DefPathHash {
465 self.to_def_id().to_stable_hash_key(hcx)
441466 }
442467}
443468
444impl<Hcx: HashStableContext> ToStableHashKey<Hcx> for CrateNum {
469impl ToStableHashKey for CrateNum {
445470 type KeyType = DefPathHash;
446471
447472 #[inline]
448 fn to_stable_hash_key(&self, hcx: &mut Hcx) -> DefPathHash {
473 fn to_stable_hash_key<Hcx: HashStableContext>(&self, hcx: &mut Hcx) -> DefPathHash {
449474 self.as_def_id().to_stable_hash_key(hcx)
450475 }
451476}
452477
453impl<Hcx: HashStableContext> ToStableHashKey<Hcx> for DefPathHash {
478impl ToStableHashKey for DefPathHash {
454479 type KeyType = DefPathHash;
455480
456481 #[inline]
457 fn to_stable_hash_key(&self, _: &mut Hcx) -> DefPathHash {
482 fn to_stable_hash_key<Hcx>(&self, _: &mut Hcx) -> DefPathHash {
458483 *self
459484 }
460485}
461486
462487macro_rules! typed_def_id {
463488 ($Name:ident, $LocalName:ident) => {
464 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Encodable, Decodable, HashStable_Generic)]
489 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Encodable, Decodable, HashStable)]
465490 pub struct $Name(DefId);
466491
467492 impl $Name {
......@@ -500,7 +525,7 @@ macro_rules! typed_def_id {
500525 }
501526 }
502527
503 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Encodable, Decodable, HashStable_Generic)]
528 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Encodable, Decodable, HashStable)]
504529 pub struct $LocalName(LocalDefId);
505530
506531 impl !Ord for $LocalName {}
compiler/rustc_span/src/edition.rs+2-2
......@@ -1,11 +1,11 @@
11use std::fmt;
22use std::str::FromStr;
33
4use rustc_macros::{BlobDecodable, Encodable, HashStable_Generic};
4use rustc_macros::{BlobDecodable, Encodable, HashStable};
55
66/// The edition of the compiler. (See [RFC 2052](https://github.com/rust-lang/rfcs/blob/master/text/2052-epochs.md).)
77#[derive(Clone, Copy, Hash, PartialEq, PartialOrd, Debug, Encodable, BlobDecodable, Eq)]
8#[derive(HashStable_Generic)]
8#[derive(HashStable)]
99pub enum Edition {
1010 // When adding new editions, be sure to do the following:
1111 //
compiler/rustc_span/src/hygiene.rs+19-17
......@@ -30,12 +30,14 @@ use std::{fmt, iter, mem};
3030
3131use rustc_data_structures::fingerprint::Fingerprint;
3232use rustc_data_structures::fx::{FxHashMap, FxHashSet};
33use rustc_data_structures::stable_hasher::{HashStable, StableHasher};
33use rustc_data_structures::stable_hasher::{
34 HashStable, HashStableContext, StableHasher, ToStableHashKey,
35};
3436use rustc_data_structures::sync::Lock;
3537use rustc_data_structures::unhash::UnhashMap;
3638use rustc_hashes::Hash64;
3739use rustc_index::IndexVec;
38use rustc_macros::{Decodable, Encodable, HashStable_Generic};
40use rustc_macros::{Decodable, Encodable, HashStable};
3941use rustc_serialize::{Decodable, Decoder, Encodable, Encoder};
4042use tracing::{debug, trace};
4143
......@@ -43,7 +45,7 @@ use crate::def_id::{CRATE_DEF_ID, CrateNum, DefId, LOCAL_CRATE, StableCrateId};
4345use crate::edition::Edition;
4446use crate::source_map::SourceMap;
4547use crate::symbol::{Symbol, kw, sym};
46use crate::{DUMMY_SP, HashStableContext, Span, SpanDecoder, SpanEncoder, with_session_globals};
48use crate::{DUMMY_SP, Span, SpanDecoder, SpanEncoder, with_session_globals};
4749
4850/// A `SyntaxContext` represents a chain of pairs `(ExpnId, Transparency)` named "marks".
4951///
......@@ -127,7 +129,7 @@ impl !Ord for LocalExpnId {}
127129impl !PartialOrd for LocalExpnId {}
128130
129131/// A unique hash value associated to an expansion.
130#[derive(Clone, Copy, PartialEq, Eq, Hash, Debug, Encodable, Decodable, HashStable_Generic)]
132#[derive(Clone, Copy, PartialEq, Eq, Hash, Debug, Encodable, Decodable, HashStable)]
131133pub struct ExpnHash(Fingerprint);
132134
133135impl ExpnHash {
......@@ -161,7 +163,7 @@ impl ExpnHash {
161163/// A property of a macro expansion that determines how identifiers
162164/// produced by that expansion are resolved.
163165#[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Hash, Debug, Encodable, Decodable)]
164#[derive(HashStable_Generic)]
166#[derive(HashStable)]
165167pub enum Transparency {
166168 /// Identifier produced by a transparent expansion is always resolved at call-site.
167169 /// Call-site spans in procedural macros, hygiene opt-out in `macro` should use this.
......@@ -963,7 +965,7 @@ impl Span {
963965
964966/// A subset of properties from both macro definition and macro call available through global data.
965967/// Avoid using this if you have access to the original definition or call structures.
966#[derive(Clone, Debug, Encodable, Decodable, HashStable_Generic)]
968#[derive(Clone, Debug, Encodable, Decodable, HashStable)]
967969pub struct ExpnData {
968970 // --- The part unique to each expansion.
969971 pub kind: ExpnKind,
......@@ -1110,7 +1112,7 @@ impl ExpnData {
11101112}
11111113
11121114/// Expansion kind.
1113#[derive(Clone, Debug, PartialEq, Encodable, Decodable, HashStable_Generic)]
1115#[derive(Clone, Debug, PartialEq, Encodable, Decodable, HashStable)]
11141116pub enum ExpnKind {
11151117 /// No expansion, aka root expansion. Only `ExpnId::root()` has this kind.
11161118 Root,
......@@ -1139,7 +1141,7 @@ impl ExpnKind {
11391141
11401142/// The kind of macro invocation or definition.
11411143#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Encodable, Decodable, Hash, Debug)]
1142#[derive(HashStable_Generic)]
1144#[derive(HashStable)]
11431145pub enum MacroKind {
11441146 /// A bang macro `foo!()`.
11451147 Bang,
......@@ -1174,7 +1176,7 @@ impl MacroKind {
11741176}
11751177
11761178/// The kind of AST transform.
1177#[derive(Clone, Copy, Debug, PartialEq, Encodable, Decodable, HashStable_Generic)]
1179#[derive(Clone, Copy, Debug, PartialEq, Encodable, Decodable, HashStable)]
11781180pub enum AstPass {
11791181 StdImports,
11801182 TestHarness,
......@@ -1192,7 +1194,7 @@ impl AstPass {
11921194}
11931195
11941196/// The kind of compiler desugaring.
1195#[derive(Clone, Copy, PartialEq, Debug, Encodable, Decodable, HashStable_Generic)]
1197#[derive(Clone, Copy, PartialEq, Debug, Encodable, Decodable, HashStable)]
11961198pub enum DesugaringKind {
11971199 QuestionMark,
11981200 TryBlock,
......@@ -1514,11 +1516,11 @@ fn update_disambiguator(expn_data: &mut ExpnData, mut hcx: impl HashStableContex
15141516 });
15151517 }
15161518
1517 ExpnHash::new(hcx.def_path_hash(LOCAL_CRATE.as_def_id()).stable_crate_id(), expn_hash)
1519 ExpnHash::new(LOCAL_CRATE.as_def_id().to_stable_hash_key(&mut hcx).stable_crate_id(), expn_hash)
15181520}
15191521
1520impl<Hcx: HashStableContext> HashStable<Hcx> for SyntaxContext {
1521 fn hash_stable(&self, hcx: &mut Hcx, hasher: &mut StableHasher) {
1522impl HashStable for SyntaxContext {
1523 fn hash_stable<Hcx: HashStableContext>(&self, hcx: &mut Hcx, hasher: &mut StableHasher) {
15221524 const TAG_EXPANSION: u8 = 0;
15231525 const TAG_NO_EXPANSION: u8 = 1;
15241526
......@@ -1533,8 +1535,8 @@ impl<Hcx: HashStableContext> HashStable<Hcx> for SyntaxContext {
15331535 }
15341536}
15351537
1536impl<Hcx: HashStableContext> HashStable<Hcx> for ExpnId {
1537 fn hash_stable(&self, hcx: &mut Hcx, hasher: &mut StableHasher) {
1538impl HashStable for ExpnId {
1539 fn hash_stable<Hcx: HashStableContext>(&self, hcx: &mut Hcx, hasher: &mut StableHasher) {
15381540 hcx.assert_default_hashing_controls("ExpnId");
15391541 let hash = if *self == ExpnId::root() {
15401542 // Avoid fetching TLS storage for a trivial often-used value.
......@@ -1547,8 +1549,8 @@ impl<Hcx: HashStableContext> HashStable<Hcx> for ExpnId {
15471549 }
15481550}
15491551
1550impl<Hcx: HashStableContext> HashStable<Hcx> for LocalExpnId {
1551 fn hash_stable(&self, hcx: &mut Hcx, hasher: &mut StableHasher) {
1552impl HashStable for LocalExpnId {
1553 fn hash_stable<Hcx: HashStableContext>(&self, hcx: &mut Hcx, hasher: &mut StableHasher) {
15521554 self.to_expn_id().hash_stable(hcx, hasher);
15531555 }
15541556}
compiler/rustc_span/src/lib.rs+14-42
......@@ -31,8 +31,9 @@
3131extern crate self as rustc_span;
3232
3333use derive_where::derive_where;
34use rustc_data_structures::stable_hasher::HashStableContext;
3435use rustc_data_structures::{AtomicRef, outline};
35use rustc_macros::{Decodable, Encodable, HashStable_Generic};
36use rustc_macros::{Decodable, Encodable, HashStable};
3637use rustc_serialize::opaque::{FileEncoder, MemDecoder};
3738use rustc_serialize::{Decodable, Decoder, Encodable, Encoder};
3839use tracing::debug;
......@@ -53,7 +54,7 @@ pub use hygiene::{
5354 DesugaringKind, ExpnData, ExpnHash, ExpnId, ExpnKind, LocalExpnId, MacroKind, SyntaxContext,
5455};
5556pub mod def_id;
56use def_id::{CrateNum, DefId, DefIndex, DefPathHash, LOCAL_CRATE, LocalDefId, StableCrateId};
57use def_id::{CrateNum, DefId, DefIndex, LOCAL_CRATE, LocalDefId, StableCrateId};
5758pub mod edit_distance;
5859mod span_encoding;
5960pub use span_encoding::{DUMMY_SP, Span};
......@@ -90,7 +91,7 @@ use sha2::Sha256;
9091#[cfg(test)]
9192mod tests;
9293
93#[derive(Clone, Encodable, Decodable, Debug, Copy, PartialEq, Hash, HashStable_Generic)]
94#[derive(Clone, Encodable, Decodable, Debug, Copy, PartialEq, Hash, HashStable)]
9495pub struct Spanned<T> {
9596 pub node: T,
9697 pub span: Span,
......@@ -1613,7 +1614,7 @@ impl fmt::Debug for SpanData {
16131614}
16141615
16151616/// Identifies an offset of a multi-byte character in a `SourceFile`.
1616#[derive(Copy, Clone, Encodable, Decodable, Eq, PartialEq, Debug, HashStable_Generic)]
1617#[derive(Copy, Clone, Encodable, Decodable, Eq, PartialEq, Debug, HashStable)]
16171618pub struct MultiByteChar {
16181619 /// The relative offset of the character in the `SourceFile`.
16191620 pub pos: RelativeBytePos,
......@@ -1622,7 +1623,7 @@ pub struct MultiByteChar {
16221623}
16231624
16241625/// Identifies an offset of a character that was normalized away from `SourceFile`.
1625#[derive(Copy, Clone, Encodable, Decodable, Eq, PartialEq, Debug, HashStable_Generic)]
1626#[derive(Copy, Clone, Encodable, Decodable, Eq, PartialEq, Debug, HashStable)]
16261627pub struct NormalizedPos {
16271628 /// The relative offset of the character in the `SourceFile`.
16281629 pub pos: RelativeBytePos,
......@@ -1665,7 +1666,7 @@ impl ExternalSource {
16651666pub struct OffsetOverflowError;
16661667
16671668#[derive(Copy, Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash, Encodable, Decodable)]
1668#[derive(HashStable_Generic)]
1669#[derive(HashStable)]
16691670pub enum SourceFileHashAlgorithm {
16701671 Md5,
16711672 Sha1,
......@@ -1700,7 +1701,7 @@ impl FromStr for SourceFileHashAlgorithm {
17001701
17011702/// The hash of the on-disk source file used for debug info and cargo freshness checks.
17021703#[derive(Copy, Clone, PartialEq, Eq, Debug, Hash)]
1703#[derive(HashStable_Generic, Encodable, Decodable)]
1704#[derive(HashStable, Encodable, Decodable)]
17041705pub struct SourceFileHash {
17051706 pub kind: SourceFileHashAlgorithm,
17061707 value: [u8; 32],
......@@ -2083,17 +2084,7 @@ impl fmt::Debug for SourceFile {
20832084/// When `SourceFile`s are exported in crate metadata, the `StableSourceFileId`
20842085/// is updated to incorporate the `StableCrateId` of the exporting crate.
20852086#[derive(
2086 Debug,
2087 Clone,
2088 Copy,
2089 Hash,
2090 PartialEq,
2091 Eq,
2092 HashStable_Generic,
2093 Encodable,
2094 Decodable,
2095 Default,
2096 PartialOrd,
2087 Debug, Clone, Copy, Hash, PartialEq, Eq, HashStable, Encodable, Decodable, Default, PartialOrd,
20972088 Ord
20982089)]
20992090pub struct StableSourceFileId(Hash128);
......@@ -2665,7 +2656,7 @@ impl_pos! {
26652656 pub struct BytePos(pub u32);
26662657
26672658 /// A byte offset relative to file beginning.
2668 #[derive(Clone, Copy, PartialEq, Eq, Hash, PartialOrd, Ord, Debug, HashStable_Generic)]
2659 #[derive(Clone, Copy, PartialEq, Eq, Hash, PartialOrd, Ord, Debug, HashStable)]
26692660 pub struct RelativeBytePos(pub u32);
26702661
26712662 /// A character offset.
......@@ -2796,29 +2787,10 @@ impl InnerSpan {
27962787 }
27972788}
27982789
2799/// This trait lets `HashStable` and `derive(HashStable_Generic)` be used in
2800/// this crate (and other crates upstream of `rustc_middle`), while leaving
2801/// certain operations to be defined in `rustc_middle` where more things are
2802/// visible.
2803pub trait HashStableContext {
2804 /// The main event: stable hashing of a span.
2805 fn span_hash_stable(&mut self, span: Span, hasher: &mut StableHasher);
2806
2807 /// Compute a `DefPathHash`.
2808 fn def_path_hash(&self, def_id: DefId) -> DefPathHash;
2809
2810 /// Assert that the provided `HashStableContext` is configured with the default
2811 /// `HashingControls`. We should always have bailed out before getting to here with a
2812 fn assert_default_hashing_controls(&self, msg: &str);
2813}
2814
2815impl<Hcx> HashStable<Hcx> for Span
2816where
2817 Hcx: HashStableContext,
2818{
2819 fn hash_stable(&self, hcx: &mut Hcx, hasher: &mut StableHasher) {
2790impl HashStable for Span {
2791 fn hash_stable<Hcx: HashStableContext>(&self, hcx: &mut Hcx, hasher: &mut StableHasher) {
28202792 // `span_hash_stable` does all the work.
2821 hcx.span_hash_stable(*self, hasher)
2793 hcx.span_hash_stable(self.to_raw_span(), hasher)
28222794 }
28232795}
28242796
......@@ -2828,7 +2800,7 @@ where
28282800/// The `()` field is necessary: it is non-`pub`, which means values of this
28292801/// type cannot be constructed outside of this crate.
28302802#[derive(Clone, Copy, Debug, Hash, PartialEq, Eq, PartialOrd, Ord)]
2831#[derive(HashStable_Generic)]
2803#[derive(HashStable)]
28322804pub struct ErrorGuaranteed(());
28332805
28342806impl ErrorGuaranteed {
compiler/rustc_span/src/span_encoding.rs+13
......@@ -1,4 +1,5 @@
11use rustc_data_structures::fx::FxIndexSet;
2use rustc_data_structures::stable_hasher::RawSpan;
23// This code is very hot and uses lots of arithmetic, avoid overflow checks for performance.
34// See https://github.com/rust-lang/rust/pull/119440#issuecomment-1874255727
45use rustc_serialize::int_overflow::DebugStrictAdd;
......@@ -441,6 +442,18 @@ impl Span {
441442 Interned(span) => interned_parent(span.index),
442443 }
443444 }
445
446 #[inline]
447 pub(crate) fn to_raw_span(self) -> RawSpan {
448 // Field order must match `from_raw_span`.
449 RawSpan(self.lo_or_index, self.len_with_tag_or_marker, self.ctxt_or_parent_or_marker)
450 }
451
452 #[inline]
453 pub fn from_raw_span(RawSpan(a, b, c): RawSpan) -> Span {
454 // Field order must match `to_raw_span`.
455 Span { lo_or_index: a, len_with_tag_or_marker: b, ctxt_or_parent_or_marker: c }
456 }
444457}
445458
446459#[derive(Default)]
compiler/rustc_span/src/symbol.rs+9-9
......@@ -8,10 +8,10 @@ use std::{fmt, str};
88use rustc_arena::DroplessArena;
99use rustc_data_structures::fx::{FxHashSet, FxIndexSet};
1010use rustc_data_structures::stable_hasher::{
11 HashStable, StableCompare, StableHasher, ToStableHashKey,
11 HashStable, HashStableContext, StableCompare, StableHasher, ToStableHashKey,
1212};
1313use rustc_data_structures::sync::Lock;
14use rustc_macros::{Decodable, Encodable, HashStable_Generic, symbols};
14use rustc_macros::{Decodable, Encodable, HashStable, symbols};
1515
1616use crate::edit_distance::find_best_match_for_name;
1717use crate::{DUMMY_SP, Edition, Span, with_session_globals};
......@@ -2308,7 +2308,7 @@ symbols! {
23082308/// `proc_macro`.
23092309pub const STDLIB_STABLE_CRATES: &[Symbol] = &[sym::std, sym::core, sym::alloc, sym::proc_macro];
23102310
2311#[derive(Copy, Clone, Eq, HashStable_Generic, Encodable, Decodable)]
2311#[derive(Copy, Clone, Eq, HashStable, Encodable, Decodable)]
23122312pub struct Ident {
23132313 /// `name` should never be the empty symbol. If you are considering that,
23142314 /// you are probably conflating "empty identifier with "no identifier" and
......@@ -2631,17 +2631,17 @@ impl fmt::Display for Symbol {
26312631 }
26322632}
26332633
2634impl<Hcx> HashStable<Hcx> for Symbol {
2634impl HashStable for Symbol {
26352635 #[inline]
2636 fn hash_stable(&self, hcx: &mut Hcx, hasher: &mut StableHasher) {
2636 fn hash_stable<Hcx: HashStableContext>(&self, hcx: &mut Hcx, hasher: &mut StableHasher) {
26372637 self.as_str().hash_stable(hcx, hasher);
26382638 }
26392639}
26402640
2641impl<Hcx> ToStableHashKey<Hcx> for Symbol {
2641impl ToStableHashKey for Symbol {
26422642 type KeyType = String;
26432643 #[inline]
2644 fn to_stable_hash_key(&self, _: &mut Hcx) -> String {
2644 fn to_stable_hash_key<Hcx>(&self, _: &mut Hcx) -> String {
26452645 self.as_str().to_string()
26462646 }
26472647}
......@@ -2691,9 +2691,9 @@ impl fmt::Debug for ByteSymbol {
26912691 }
26922692}
26932693
2694impl<Hcx> HashStable<Hcx> for ByteSymbol {
2694impl HashStable for ByteSymbol {
26952695 #[inline]
2696 fn hash_stable(&self, hcx: &mut Hcx, hasher: &mut StableHasher) {
2696 fn hash_stable<Hcx: HashStableContext>(&self, hcx: &mut Hcx, hasher: &mut StableHasher) {
26972697 self.as_byte_str().hash_stable(hcx, hasher);
26982698 }
26992699}
compiler/rustc_target/src/asm/mod.rs+7-7
......@@ -2,7 +2,7 @@ use std::fmt;
22
33use rustc_abi::Size;
44use rustc_data_structures::fx::{FxHashMap, FxIndexSet};
5use rustc_macros::{Decodable, Encodable, HashStable_Generic};
5use rustc_macros::{Decodable, Encodable, HashStable};
66use rustc_span::Symbol;
77
88use crate::spec::{Arch, CfgAbi, RelocModel, Target};
......@@ -25,7 +25,7 @@ macro_rules! def_reg_class {
2525 $class:ident,
2626 )*
2727 }) => {
28 #[derive(Copy, Clone, rustc_macros::Encodable, rustc_macros::Decodable, Debug, Eq, PartialEq, PartialOrd, Hash, rustc_macros::HashStable_Generic)]
28 #[derive(Copy, Clone, rustc_macros::Encodable, rustc_macros::Decodable, Debug, Eq, PartialEq, PartialOrd, Hash, rustc_macros::HashStable)]
2929 #[allow(non_camel_case_types)]
3030 pub enum $arch_regclass {
3131 $($class,)*
......@@ -74,7 +74,7 @@ macro_rules! def_regs {
7474 )*
7575 }) => {
7676 #[allow(unreachable_code)]
77 #[derive(Copy, Clone, rustc_macros::Encodable, rustc_macros::Decodable, Debug, Eq, PartialEq, PartialOrd, Hash, rustc_macros::HashStable_Generic)]
77 #[derive(Copy, Clone, rustc_macros::Encodable, rustc_macros::Decodable, Debug, Eq, PartialEq, PartialOrd, Hash, rustc_macros::HashStable)]
7878 #[allow(non_camel_case_types)]
7979 pub enum $arch_reg {
8080 $($reg,)*
......@@ -279,7 +279,7 @@ impl InlineAsmArch {
279279}
280280
281281#[derive(Copy, Clone, Debug, Eq, PartialEq, PartialOrd, Hash)]
282#[derive(HashStable_Generic, Encodable, Decodable)]
282#[derive(HashStable, Encodable, Decodable)]
283283pub enum InlineAsmReg {
284284 X86(X86InlineAsmReg),
285285 Arm(ArmInlineAsmReg),
......@@ -467,7 +467,7 @@ impl InlineAsmReg {
467467}
468468
469469#[derive(Copy, Clone, Debug, Eq, PartialEq, PartialOrd, Hash)]
470#[derive(HashStable_Generic, Encodable, Decodable)]
470#[derive(HashStable, Encodable, Decodable)]
471471pub enum InlineAsmRegClass {
472472 X86(X86InlineAsmRegClass),
473473 Arm(ArmInlineAsmRegClass),
......@@ -712,7 +712,7 @@ impl InlineAsmRegClass {
712712}
713713
714714#[derive(Copy, Clone, Debug, Eq, PartialEq, PartialOrd, Hash)]
715#[derive(HashStable_Generic, Encodable, Decodable)]
715#[derive(HashStable, Encodable, Decodable)]
716716pub enum InlineAsmRegOrRegClass {
717717 Reg(InlineAsmReg),
718718 RegClass(InlineAsmRegClass),
......@@ -922,7 +922,7 @@ pub fn allocatable_registers(
922922}
923923
924924#[derive(Copy, Clone, Debug, Eq, PartialEq, PartialOrd, Hash)]
925#[derive(HashStable_Generic, Encodable, Decodable)]
925#[derive(HashStable, Encodable, Decodable)]
926926pub enum InlineAsmClobberAbi {
927927 X86,
928928 X86_64Win,
compiler/rustc_target/src/callconv/mod.rs+11-11
......@@ -4,7 +4,7 @@ use rustc_abi::{
44 AddressSpace, Align, BackendRepr, CanonAbi, ExternAbi, FieldsShape, HasDataLayout, Primitive,
55 Reg, RegKind, Scalar, Size, TyAbiInterface, TyAndLayout, Variants,
66};
7use rustc_macros::HashStable_Generic;
7use rustc_macros::HashStable;
88
99pub use crate::spec::AbiMap;
1010use crate::spec::{Arch, HasTargetSpec, HasX86AbiOpt};
......@@ -35,7 +35,7 @@ mod x86_win32;
3535mod x86_win64;
3636mod xtensa;
3737
38#[derive(Clone, PartialEq, Eq, Hash, Debug, HashStable_Generic)]
38#[derive(Clone, PartialEq, Eq, Hash, Debug, HashStable)]
3939pub enum PassMode {
4040 /// Ignore the argument.
4141 ///
......@@ -106,10 +106,10 @@ pub use attr_impl::ArgAttribute;
106106#[allow(non_upper_case_globals)]
107107#[allow(unused)]
108108mod attr_impl {
109 use rustc_macros::HashStable_Generic;
109 use rustc_macros::HashStable;
110110
111111 // The subset of llvm::Attribute needed for arguments, packed into a bitfield.
112 #[derive(Clone, Copy, Default, Hash, PartialEq, Eq, HashStable_Generic)]
112 #[derive(Clone, Copy, Default, Hash, PartialEq, Eq, HashStable)]
113113 pub struct ArgAttribute(u16);
114114 bitflags::bitflags! {
115115 impl ArgAttribute: u16 {
......@@ -130,7 +130,7 @@ mod attr_impl {
130130/// Sometimes an ABI requires small integers to be extended to a full or partial register. This enum
131131/// defines if this extension should be zero-extension or sign-extension when necessary. When it is
132132/// not necessary to extend the argument, this enum is ignored.
133#[derive(Copy, Clone, PartialEq, Eq, Hash, Debug, HashStable_Generic)]
133#[derive(Copy, Clone, PartialEq, Eq, Hash, Debug, HashStable)]
134134pub enum ArgExtension {
135135 None,
136136 Zext,
......@@ -139,7 +139,7 @@ pub enum ArgExtension {
139139
140140/// A compact representation of LLVM attributes (at least those relevant for this module)
141141/// that can be manipulated without interacting with LLVM's Attribute machinery.
142#[derive(Copy, Clone, PartialEq, Eq, Hash, Debug, HashStable_Generic)]
142#[derive(Copy, Clone, PartialEq, Eq, Hash, Debug, HashStable)]
143143pub struct ArgAttributes {
144144 pub regular: ArgAttribute,
145145 pub arg_ext: ArgExtension,
......@@ -213,7 +213,7 @@ impl From<ArgAttribute> for ArgAttributes {
213213
214214/// An argument passed entirely registers with the
215215/// same kind (e.g., HFA / HVA on PPC64 and AArch64).
216#[derive(Clone, Copy, PartialEq, Eq, Hash, Debug, HashStable_Generic)]
216#[derive(Clone, Copy, PartialEq, Eq, Hash, Debug, HashStable)]
217217pub struct Uniform {
218218 pub unit: Reg,
219219
......@@ -262,7 +262,7 @@ impl Uniform {
262262/// `rest.unit` register type gets repeated often enough to cover `rest.size`. This describes the
263263/// actual type used for the call; the Rust type of the argument is then transmuted to this ABI type
264264/// (and all data in the padding between the registers is dropped).
265#[derive(Clone, PartialEq, Eq, Hash, Debug, HashStable_Generic)]
265#[derive(Clone, PartialEq, Eq, Hash, Debug, HashStable)]
266266pub struct CastTarget {
267267 pub prefix: [Option<Reg>; 8],
268268 /// The offset of `rest` from the start of the value. Currently only implemented for a `Reg`
......@@ -363,7 +363,7 @@ impl CastTarget {
363363
364364/// Information about how to pass an argument to,
365365/// or return a value from, a function, under some ABI.
366#[derive(Clone, PartialEq, Eq, Hash, HashStable_Generic)]
366#[derive(Clone, PartialEq, Eq, Hash, HashStable)]
367367pub struct ArgAbi<'a, Ty> {
368368 pub layout: TyAndLayout<'a, Ty>,
369369 pub mode: PassMode,
......@@ -564,7 +564,7 @@ impl<'a, Ty> ArgAbi<'a, Ty> {
564564 }
565565}
566566
567#[derive(Copy, Clone, PartialEq, Eq, Hash, Debug, HashStable_Generic)]
567#[derive(Copy, Clone, PartialEq, Eq, Hash, Debug, HashStable)]
568568pub enum RiscvInterruptKind {
569569 Machine,
570570 Supervisor,
......@@ -589,7 +589,7 @@ impl RiscvInterruptKind {
589589///
590590/// I will do my best to describe this structure, but these
591591/// comments are reverse-engineered and may be inaccurate. -NDM
592#[derive(Clone, PartialEq, Eq, Hash, HashStable_Generic)]
592#[derive(Clone, PartialEq, Eq, Hash, HashStable)]
593593pub struct FnAbi<'a, Ty> {
594594 /// The type, layout, and information about how each argument is passed.
595595 pub args: Box<[ArgAbi<'a, Ty>]>,
compiler/rustc_target/src/spec/mod.rs+5-5
......@@ -52,7 +52,7 @@ use rustc_abi::{
5252use rustc_data_structures::fx::{FxHashSet, FxIndexSet};
5353use rustc_error_messages::{DiagArgValue, IntoDiagArg, into_diag_arg_using_display};
5454use rustc_fs_util::try_canonicalize;
55use rustc_macros::{BlobDecodable, Decodable, Encodable, HashStable_Generic};
55use rustc_macros::{BlobDecodable, Decodable, Encodable, HashStable};
5656use rustc_serialize::{Decodable, Decoder, Encodable, Encoder};
5757use rustc_span::{Symbol, kw, sym};
5858use serde_json::Value;
......@@ -830,7 +830,7 @@ impl LinkerFeatures {
830830}
831831
832832crate::target_spec_enum! {
833 #[derive(Encodable, BlobDecodable, HashStable_Generic)]
833 #[derive(Encodable, BlobDecodable, HashStable)]
834834 pub enum PanicStrategy {
835835 Unwind = "unwind",
836836 Abort = "abort",
......@@ -840,7 +840,7 @@ crate::target_spec_enum! {
840840 parse_error_type = "panic strategy";
841841}
842842
843#[derive(Clone, Copy, Debug, PartialEq, Hash, Encodable, BlobDecodable, HashStable_Generic)]
843#[derive(Clone, Copy, Debug, PartialEq, Hash, Encodable, BlobDecodable, HashStable)]
844844pub enum OnBrokenPipe {
845845 Default,
846846 Kill,
......@@ -1161,7 +1161,7 @@ impl ToJson for StackProbeType {
11611161 }
11621162}
11631163
1164#[derive(Default, Clone, Copy, PartialEq, Eq, Hash, Encodable, Decodable, HashStable_Generic)]
1164#[derive(Default, Clone, Copy, PartialEq, Eq, Hash, Encodable, Decodable, HashStable)]
11651165pub struct SanitizerSet(u16);
11661166bitflags::bitflags! {
11671167 impl SanitizerSet: u16 {
......@@ -1347,7 +1347,7 @@ impl FramePointer {
13471347
13481348crate::target_spec_enum! {
13491349 /// Controls use of stack canaries.
1350 #[derive(Encodable, BlobDecodable, HashStable_Generic)]
1350 #[derive(Encodable, BlobDecodable, HashStable)]
13511351 pub enum StackProtector {
13521352 /// Disable stack canary generation.
13531353 None = "none",
compiler/rustc_target/src/target_features.rs+2-2
......@@ -2,7 +2,7 @@
22//! Note that these are similar to but not always identical to LLVM's feature names,
33//! and Rust adds some features that do not correspond to LLVM features at all.
44use rustc_data_structures::fx::{FxHashMap, FxHashSet};
5use rustc_macros::HashStable_Generic;
5use rustc_macros::HashStable;
66use rustc_span::{Symbol, sym};
77
88use crate::spec::{Arch, FloatAbi, LlvmAbi, RustcAbi, Target};
......@@ -12,7 +12,7 @@ use crate::spec::{Arch, FloatAbi, LlvmAbi, RustcAbi, Target};
1212pub const RUSTC_SPECIFIC_FEATURES: &[&str] = &["crt-static"];
1313
1414/// Stability information for target features.
15#[derive(Debug, Copy, Clone, HashStable_Generic)]
15#[derive(Debug, Copy, Clone, HashStable)]
1616pub enum Stability {
1717 /// This target feature is stable, it can be used in `#[target_feature]` and
1818 /// `#[cfg(target_feature)]`.
compiler/rustc_type_ir/src/binder.rs+2-6
......@@ -5,7 +5,7 @@ use std::ops::{ControlFlow, Deref};
55
66use derive_where::derive_where;
77#[cfg(feature = "nightly")]
8use rustc_macros::{Decodable_NoContext, Encodable_NoContext, HashStable_NoContext};
8use rustc_macros::{Decodable_NoContext, Encodable_NoContext, HashStable, HashStable_NoContext};
99use rustc_type_ir_macros::{
1010 GenericTypeVisitable, Lift_Generic, TypeFoldable_Generic, TypeVisitable_Generic,
1111};
......@@ -951,10 +951,7 @@ impl<'a, I: Interner> ArgFolder<'a, I> {
951951/// solver, canonicalization is hot and there are some pathological cases where
952952/// this is needed (`post-mono-higher-ranked-hang`).
953953#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
954#[cfg_attr(
955 feature = "nightly",
956 derive(Encodable_NoContext, Decodable_NoContext, HashStable_NoContext)
957)]
954#[cfg_attr(feature = "nightly", derive(Encodable_NoContext, Decodable_NoContext, HashStable))]
958955#[derive(TypeVisitable_Generic, GenericTypeVisitable, TypeFoldable_Generic)]
959956pub enum BoundVarIndexKind {
960957 Bound(DebruijnIndex),
......@@ -1009,7 +1006,6 @@ where
10091006 feature = "nightly",
10101007 derive(Encodable_NoContext, Decodable_NoContext, HashStable_NoContext)
10111008)]
1012
10131009pub enum BoundRegionKind<I: Interner> {
10141010 /// An anonymous region parameter for a given fn (&T)
10151011 Anon,
compiler/rustc_type_ir/src/const_kind.rs+5-8
......@@ -2,9 +2,9 @@ use std::fmt;
22
33use derive_where::derive_where;
44#[cfg(feature = "nightly")]
5use rustc_data_structures::stable_hasher::{HashStable, StableHasher};
5use rustc_data_structures::stable_hasher::{HashStable, HashStableContext, StableHasher};
66#[cfg(feature = "nightly")]
7use rustc_macros::{Decodable_NoContext, Encodable_NoContext, HashStable_NoContext};
7use rustc_macros::{Decodable_NoContext, Encodable_NoContext, HashStable, HashStable_NoContext};
88use rustc_type_ir_macros::{
99 GenericTypeVisitable, Lift_Generic, TypeFoldable_Generic, TypeVisitable_Generic,
1010};
......@@ -117,8 +117,8 @@ impl fmt::Debug for InferConst {
117117}
118118
119119#[cfg(feature = "nightly")]
120impl<Hcx> HashStable<Hcx> for InferConst {
121 fn hash_stable(&self, hcx: &mut Hcx, hasher: &mut StableHasher) {
120impl HashStable for InferConst {
121 fn hash_stable<Hcx: HashStableContext>(&self, hcx: &mut Hcx, hasher: &mut StableHasher) {
122122 match self {
123123 InferConst::Var(_) => {
124124 panic!("const variables should not be hashed: {self:?}")
......@@ -201,10 +201,7 @@ impl<I: Interner> ValTreeKind<I> {
201201}
202202
203203#[derive(Copy, Clone, PartialEq, Eq, Hash, Debug)]
204#[cfg_attr(
205 feature = "nightly",
206 derive(Encodable_NoContext, Decodable_NoContext, HashStable_NoContext)
207)]
204#[cfg_attr(feature = "nightly", derive(Encodable_NoContext, Decodable_NoContext, HashStable))]
208205pub enum AnonConstKind {
209206 /// `feature(generic_const_exprs)` anon consts are allowed to use arbitrary generic parameters in scope
210207 GCE,
compiler/rustc_type_ir/src/fast_reject.rs+7-8
......@@ -7,9 +7,11 @@ use rustc_ast_ir::Mutability;
77#[cfg(feature = "nightly")]
88use rustc_data_structures::fingerprint::Fingerprint;
99#[cfg(feature = "nightly")]
10use rustc_data_structures::stable_hasher::{HashStable, StableHasher, ToStableHashKey};
10use rustc_data_structures::stable_hasher::{
11 HashStable, HashStableContext, StableHasher, ToStableHashKey,
12};
1113#[cfg(feature = "nightly")]
12use rustc_macros::{Decodable_NoContext, Encodable_NoContext, HashStable_NoContext};
14use rustc_macros::{Decodable_NoContext, Encodable_NoContext, HashStable};
1315
1416use crate::inherent::*;
1517use crate::visit::TypeVisitableExt as _;
......@@ -17,10 +19,7 @@ use crate::{self as ty, Interner};
1719
1820/// See `simplify_type`.
1921#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
20#[cfg_attr(
21 feature = "nightly",
22 derive(Encodable_NoContext, Decodable_NoContext, HashStable_NoContext)
23)]
22#[cfg_attr(feature = "nightly", derive(Encodable_NoContext, Decodable_NoContext, HashStable))]
2423pub enum SimplifiedType<DefId> {
2524 Bool,
2625 Char,
......@@ -50,11 +49,11 @@ pub enum SimplifiedType<DefId> {
5049}
5150
5251#[cfg(feature = "nightly")]
53impl<Hcx, DefId: HashStable<Hcx>> ToStableHashKey<Hcx> for SimplifiedType<DefId> {
52impl<DefId: HashStable> ToStableHashKey for SimplifiedType<DefId> {
5453 type KeyType = Fingerprint;
5554
5655 #[inline]
57 fn to_stable_hash_key(&self, hcx: &mut Hcx) -> Fingerprint {
56 fn to_stable_hash_key<Hcx: HashStableContext>(&self, hcx: &mut Hcx) -> Fingerprint {
5857 let mut hasher = StableHasher::new();
5958 self.hash_stable(hcx, &mut hasher);
6059 hasher.finish()
compiler/rustc_type_ir/src/lib.rs+6-6
......@@ -15,7 +15,7 @@ use std::hash::Hash;
1515
1616use rustc_abi::{FieldIdx, VariantIdx};
1717#[cfg(feature = "nightly")]
18use rustc_macros::{Decodable, Encodable, HashStable_NoContext};
18use rustc_macros::{Decodable, Encodable, HashStable};
1919
2020// These modules are `pub` since they are not glob-imported.
2121pub mod data_structures;
......@@ -125,7 +125,7 @@ rustc_index::newtype_index! {
125125 /// is the outer fn.
126126 ///
127127 /// [dbi]: https://en.wikipedia.org/wiki/De_Bruijn_index
128 #[stable_hash_no_context]
128 #[stable_hash]
129129 #[encodable]
130130 #[orderable]
131131 #[debug_format = "DebruijnIndex({})"]
......@@ -219,7 +219,7 @@ pub fn debug_bound_var<T: std::fmt::Write>(
219219}
220220
221221#[derive(Copy, Clone, PartialEq, Eq, Hash, GenericTypeVisitable)]
222#[cfg_attr(feature = "nightly", derive(Decodable, Encodable, HashStable_NoContext))]
222#[cfg_attr(feature = "nightly", derive(Decodable, Encodable, HashStable))]
223223#[cfg_attr(feature = "nightly", rustc_pass_by_value)]
224224pub enum Variance {
225225 Covariant, // T<A> <: T<B> iff A <: B -- e.g., function return type
......@@ -335,7 +335,7 @@ rustc_index::newtype_index! {
335335 /// declared, but a type name in a non-zero universe is a placeholder
336336 /// type -- an idealized representative of "types in general" that we
337337 /// use for checking generic functions.
338 #[stable_hash_no_context]
338 #[stable_hash]
339339 #[encodable]
340340 #[orderable]
341341 #[debug_format = "U{}"]
......@@ -390,7 +390,7 @@ impl Default for UniverseIndex {
390390}
391391
392392rustc_index::newtype_index! {
393 #[stable_hash_generic]
393 #[stable_hash]
394394 #[encodable]
395395 #[orderable]
396396 #[debug_format = "{}"]
......@@ -405,7 +405,7 @@ rustc_index::newtype_index! {
405405/// You can get the environment type of a closure using
406406/// `tcx.closure_env_ty()`.
407407#[derive(Clone, Copy, PartialEq, Eq, Hash, Debug)]
408#[cfg_attr(feature = "nightly", derive(Encodable, Decodable, HashStable_NoContext))]
408#[cfg_attr(feature = "nightly", derive(Encodable, Decodable, HashStable))]
409409pub enum ClosureKind {
410410 Fn,
411411 FnMut,
compiler/rustc_type_ir/src/predicate.rs+4-13
......@@ -3,7 +3,7 @@ use std::{fmt, iter};
33
44use derive_where::derive_where;
55#[cfg(feature = "nightly")]
6use rustc_macros::{Decodable_NoContext, Encodable_NoContext, HashStable_NoContext};
6use rustc_macros::{Decodable_NoContext, Encodable_NoContext, HashStable, HashStable_NoContext};
77use rustc_type_ir_macros::{
88 GenericTypeVisitable, Lift_Generic, TypeFoldable_Generic, TypeVisitable_Generic,
99};
......@@ -270,10 +270,7 @@ impl<I: Interner> fmt::Debug for TraitPredicate<I> {
270270}
271271
272272#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Debug)]
273#[cfg_attr(
274 feature = "nightly",
275 derive(Decodable_NoContext, Encodable_NoContext, HashStable_NoContext)
276)]
273#[cfg_attr(feature = "nightly", derive(Decodable_NoContext, Encodable_NoContext, HashStable))]
277274pub enum ImplPolarity {
278275 /// `impl Trait for Type`
279276 Positive,
......@@ -313,10 +310,7 @@ impl ImplPolarity {
313310/// Distinguished from [`ImplPolarity`] since we never compute goals with
314311/// "reservation" level.
315312#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Debug)]
316#[cfg_attr(
317 feature = "nightly",
318 derive(Decodable_NoContext, Encodable_NoContext, HashStable_NoContext)
319)]
313#[cfg_attr(feature = "nightly", derive(Decodable_NoContext, Encodable_NoContext, HashStable))]
320314pub enum PredicatePolarity {
321315 /// `Type: Trait`
322316 Positive,
......@@ -1054,10 +1048,7 @@ pub struct CoercePredicate<I: Interner> {
10541048impl<I: Interner> Eq for CoercePredicate<I> {}
10551049
10561050#[derive(Clone, Copy, Hash, PartialEq, Eq, Debug)]
1057#[cfg_attr(
1058 feature = "nightly",
1059 derive(Encodable_NoContext, Decodable_NoContext, HashStable_NoContext)
1060)]
1051#[cfg_attr(feature = "nightly", derive(Encodable_NoContext, Decodable_NoContext, HashStable))]
10611052pub enum BoundConstness {
10621053 /// `Type: const Trait`
10631054 ///
compiler/rustc_type_ir/src/predicate_kind.rs+2-5
......@@ -2,7 +2,7 @@ use std::fmt;
22
33use derive_where::derive_where;
44#[cfg(feature = "nightly")]
5use rustc_macros::{Decodable_NoContext, Encodable_NoContext, HashStable_NoContext};
5use rustc_macros::{Decodable_NoContext, Encodable_NoContext, HashStable, HashStable_NoContext};
66use rustc_type_ir_macros::{GenericTypeVisitable, TypeFoldable_Generic, TypeVisitable_Generic};
77
88use crate::{self as ty, Interner};
......@@ -114,10 +114,7 @@ pub enum PredicateKind<I: Interner> {
114114impl<I: Interner> Eq for PredicateKind<I> {}
115115
116116#[derive(Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Debug, Copy)]
117#[cfg_attr(
118 feature = "nightly",
119 derive(HashStable_NoContext, Encodable_NoContext, Decodable_NoContext)
120)]
117#[cfg_attr(feature = "nightly", derive(HashStable, Encodable_NoContext, Decodable_NoContext))]
121118pub enum AliasRelationDirection {
122119 Equate,
123120 Subtype,
compiler/rustc_type_ir/src/region_kind.rs+8-8
......@@ -2,7 +2,7 @@ use std::fmt;
22
33use derive_where::derive_where;
44#[cfg(feature = "nightly")]
5use rustc_data_structures::stable_hasher::{HashStable, StableHasher};
5use rustc_data_structures::stable_hasher::{HashStable, HashStableContext, StableHasher};
66#[cfg(feature = "nightly")]
77use rustc_macros::{Decodable_NoContext, Encodable_NoContext};
88use rustc_type_ir_macros::GenericTypeVisitable;
......@@ -16,7 +16,7 @@ rustc_index::newtype_index! {
1616 #[orderable]
1717 #[debug_format = "'?{}"]
1818 #[gate_rustc_only]
19 #[stable_hash_no_context]
19 #[stable_hash]
2020 pub struct RegionVid {}
2121}
2222
......@@ -217,15 +217,15 @@ impl<I: Interner> fmt::Debug for RegionKind<I> {
217217
218218#[cfg(feature = "nightly")]
219219// This is not a derived impl because a derive would require `I: HashStable`
220impl<Hcx, I: Interner> HashStable<Hcx> for RegionKind<I>
220impl<I: Interner> HashStable for RegionKind<I>
221221where
222 I::EarlyParamRegion: HashStable<Hcx>,
223 I::LateParamRegion: HashStable<Hcx>,
224 I::DefId: HashStable<Hcx>,
225 I::Symbol: HashStable<Hcx>,
222 I::EarlyParamRegion: HashStable,
223 I::LateParamRegion: HashStable,
224 I::DefId: HashStable,
225 I::Symbol: HashStable,
226226{
227227 #[inline]
228 fn hash_stable(&self, hcx: &mut Hcx, hasher: &mut StableHasher) {
228 fn hash_stable<Hcx: HashStableContext>(&self, hcx: &mut Hcx, hasher: &mut StableHasher) {
229229 std::mem::discriminant(self).hash_stable(hcx, hasher);
230230 match self {
231231 ReErased | ReStatic | ReError(_) => {
compiler/rustc_type_ir/src/search_graph/mod.rs+2-5
......@@ -21,7 +21,7 @@ use std::marker::PhantomData;
2121
2222use derive_where::derive_where;
2323#[cfg(feature = "nightly")]
24use rustc_macros::{Decodable_NoContext, Encodable_NoContext, HashStable_NoContext};
24use rustc_macros::{Decodable_NoContext, Encodable_NoContext, HashStable};
2525use rustc_type_ir::data_structures::HashMap;
2626use tracing::{debug, instrument, trace};
2727
......@@ -118,10 +118,7 @@ pub trait Delegate: Sized {
118118/// result. In the case we return an initial provisional result depending
119119/// on the kind of cycle.
120120#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
121#[cfg_attr(
122 feature = "nightly",
123 derive(Decodable_NoContext, Encodable_NoContext, HashStable_NoContext)
124)]
121#[cfg_attr(feature = "nightly", derive(Decodable_NoContext, Encodable_NoContext, HashStable))]
125122pub enum PathKind {
126123 /// A path consisting of only inductive/unproductive steps. Their initial
127124 /// provisional result is `Err(NoSolution)`. We currently treat them as
compiler/rustc_type_ir/src/solve/mod.rs+8-11
......@@ -4,7 +4,7 @@ use std::hash::Hash;
44
55use derive_where::derive_where;
66#[cfg(feature = "nightly")]
7use rustc_macros::{Decodable_NoContext, Encodable_NoContext, HashStable_NoContext};
7use rustc_macros::{Decodable_NoContext, Encodable_NoContext, HashStable, HashStable_NoContext};
88use rustc_type_ir_macros::{
99 GenericTypeVisitable, Lift_Generic, TypeFoldable_Generic, TypeVisitable_Generic,
1010};
......@@ -25,7 +25,7 @@ pub type CanonicalResponse<I> = Canonical<I, Response<I>>;
2525pub type QueryResult<I> = Result<CanonicalResponse<I>, NoSolution>;
2626
2727#[derive(Copy, Clone, Debug, Hash, PartialEq, Eq)]
28#[cfg_attr(feature = "nightly", derive(HashStable_NoContext))]
28#[cfg_attr(feature = "nightly", derive(HashStable))]
2929pub struct NoSolution;
3030
3131/// A goal is a statement, i.e. `predicate`, we want to prove
......@@ -67,7 +67,7 @@ impl<I: Interner, P> Goal<I, P> {
6767///
6868/// It is also used by proof tree visitors, e.g. for diagnostics purposes.
6969#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash)]
70#[cfg_attr(feature = "nightly", derive(HashStable_NoContext))]
70#[cfg_attr(feature = "nightly", derive(HashStable))]
7171pub enum GoalSource {
7272 Misc,
7373 /// A nested goal required to prove that types are equal/subtypes.
......@@ -217,10 +217,7 @@ pub enum AliasBoundKind {
217217}
218218
219219#[derive(Clone, Copy, Hash, PartialEq, Eq, Debug)]
220#[cfg_attr(
221 feature = "nightly",
222 derive(HashStable_NoContext, Encodable_NoContext, Decodable_NoContext)
223)]
220#[cfg_attr(feature = "nightly", derive(HashStable, Encodable_NoContext, Decodable_NoContext))]
224221pub enum BuiltinImplSource {
225222 /// A built-in impl that is considered trivial, without any nested requirements. They
226223 /// are preferred over where-clauses, and we want to track them explicitly.
......@@ -286,7 +283,7 @@ impl<I: Interner> NestedNormalizationGoals<I> {
286283}
287284
288285#[derive(Clone, Copy, Hash, PartialEq, Eq, Debug)]
289#[cfg_attr(feature = "nightly", derive(HashStable_NoContext))]
286#[cfg_attr(feature = "nightly", derive(HashStable))]
290287pub enum Certainty {
291288 Yes,
292289 Maybe(MaybeInfo),
......@@ -353,7 +350,7 @@ impl MaybeInfo {
353350/// a goal. It is good enough for now and only matters for very rare type inference
354351/// edge cases. We can improve this later on if necessary.
355352#[derive(Clone, Copy, Hash, PartialEq, Eq, Debug)]
356#[cfg_attr(feature = "nightly", derive(HashStable_NoContext))]
353#[cfg_attr(feature = "nightly", derive(HashStable))]
357354pub enum OpaqueTypesJank {
358355 AllGood,
359356 ErrorIfRigidSelfTy,
......@@ -442,7 +439,7 @@ impl Certainty {
442439
443440/// Why we failed to evaluate a goal.
444441#[derive(Clone, Copy, Hash, PartialEq, Eq, Debug)]
445#[cfg_attr(feature = "nightly", derive(HashStable_NoContext))]
442#[cfg_attr(feature = "nightly", derive(HashStable))]
446443pub enum MaybeCause {
447444 /// We failed due to ambiguity. This ambiguity can either
448445 /// be a true ambiguity, i.e. there are multiple different answers,
......@@ -515,7 +512,7 @@ pub enum AdtDestructorKind {
515512/// Which sizedness trait - `Sized`, `MetaSized`? `PointeeSized` is omitted as it is removed during
516513/// lowering.
517514#[derive(Copy, Clone, Debug, Eq, Hash, PartialEq)]
518#[cfg_attr(feature = "nightly", derive(HashStable_NoContext))]
515#[cfg_attr(feature = "nightly", derive(HashStable))]
519516pub enum SizedTraitKind {
520517 /// `Sized` trait
521518 Sized,
compiler/rustc_type_ir/src/ty_info.rs+3-3
......@@ -3,7 +3,7 @@ use std::hash::{Hash, Hasher};
33use std::ops::Deref;
44
55#[cfg(feature = "nightly")]
6use rustc_data_structures::stable_hasher::{HashStable, StableHasher};
6use rustc_data_structures::stable_hasher::{HashStable, HashStableContext, StableHasher};
77use rustc_type_ir_macros::GenericTypeVisitable;
88
99use crate::{DebruijnIndex, TypeFlags};
......@@ -83,8 +83,8 @@ impl<T: Hash> Hash for WithCachedTypeInfo<T> {
8383}
8484
8585#[cfg(feature = "nightly")]
86impl<T: HashStable<Hcx>, Hcx> HashStable<Hcx> for WithCachedTypeInfo<T> {
87 fn hash_stable(&self, hcx: &mut Hcx, hasher: &mut StableHasher) {
86impl<T: HashStable> HashStable for WithCachedTypeInfo<T> {
87 fn hash_stable<Hcx: HashStableContext>(&self, hcx: &mut Hcx, hasher: &mut StableHasher) {
8888 self.internee.hash_stable(hcx, hasher);
8989 }
9090}
compiler/rustc_type_ir/src/ty_kind.rs+3-3
......@@ -6,7 +6,7 @@ use derive_where::derive_where;
66use rustc_abi::ExternAbi;
77use rustc_ast_ir::Mutability;
88#[cfg(feature = "nightly")]
9use rustc_data_structures::stable_hasher::{HashStable, StableHasher};
9use rustc_data_structures::stable_hasher::{HashStable, HashStableContext, StableHasher};
1010#[cfg(feature = "nightly")]
1111use rustc_macros::{Decodable_NoContext, Encodable_NoContext, HashStable_NoContext};
1212use rustc_type_ir::data_structures::{NoError, UnifyKey, UnifyValue};
......@@ -707,8 +707,8 @@ impl UnifyKey for FloatVid {
707707}
708708
709709#[cfg(feature = "nightly")]
710impl<Hcx> HashStable<Hcx> for InferTy {
711 fn hash_stable(&self, hcx: &mut Hcx, hasher: &mut StableHasher) {
710impl HashStable for InferTy {
711 fn hash_stable<Hcx: HashStableContext>(&self, hcx: &mut Hcx, hasher: &mut StableHasher) {
712712 use InferTy::*;
713713 std::mem::discriminant(self).hash_stable(hcx, hasher);
714714 match self {
triagebot.toml+1-1
......@@ -1590,7 +1590,7 @@ dep-bumps = [
15901590"/compiler/rustc_codegen_llvm/src/debuginfo" = ["compiler", "debuginfo"]
15911591"/compiler/rustc_codegen_ssa" = ["compiler", "codegen"]
15921592"/compiler/rustc_middle/src/dep_graph" = ["compiler", "incremental", "query-system"]
1593"/compiler/rustc_middle/src/ich" = ["compiler", "incremental", "query-system"]
1593"/compiler/rustc_middle/src/ich.rs" = ["compiler", "incremental", "query-system"]
15941594"/compiler/rustc_middle/src/mir" = ["compiler", "mir"]
15951595"/compiler/rustc_middle/src/traits" = ["compiler", "types"]
15961596"/compiler/rustc_middle/src/query" = ["compiler", "query-system"]