From 7313fc67dbb9654910fd77c0e087a1d6ccdc40c6 Mon Sep 17 00:00:00 2001 From: Nicholas Nethercote Date: Fri, 1 May 2026 06:33:37 +1000 Subject: [PATCH 01/17] Remove unused `IntoVisitor` trait. --- compiler/rustc_hir/src/intravisit.rs | 5 ----- 1 file changed, 5 deletions(-) diff --git a/compiler/rustc_hir/src/intravisit.rs b/compiler/rustc_hir/src/intravisit.rs index e93059f752223..68d8c12ec099c 100644 --- a/compiler/rustc_hir/src/intravisit.rs +++ b/compiler/rustc_hir/src/intravisit.rs @@ -71,11 +71,6 @@ use rustc_span::{Ident, Span, Symbol}; use crate::hir::*; -pub trait IntoVisitor<'hir> { - type Visitor: Visitor<'hir>; - fn into_visitor(&self) -> Self::Visitor; -} - #[derive(Copy, Clone, Debug)] pub enum FnKind<'a> { /// `#[xxx] pub async/const/extern "Abi" fn foo()` From e92ca90902b02c0ab7b16d64474bf8d0c80801be Mon Sep 17 00:00:00 2001 From: Nicholas Nethercote Date: Fri, 1 May 2026 06:40:51 +1000 Subject: [PATCH 02/17] Remove unused `Captures` trait. --- compiler/rustc_pattern_analysis/src/lib.rs | 3 --- 1 file changed, 3 deletions(-) diff --git a/compiler/rustc_pattern_analysis/src/lib.rs b/compiler/rustc_pattern_analysis/src/lib.rs index 059bf47c579c8..e1883e7df815e 100644 --- a/compiler/rustc_pattern_analysis/src/lib.rs +++ b/compiler/rustc_pattern_analysis/src/lib.rs @@ -25,9 +25,6 @@ pub use rustc_index::{Idx, IndexVec}; // re-exported to avoid rustc_index versio use crate::constructor::{Constructor, ConstructorSet, IntRange}; use crate::pat::DeconstructedPat; -pub trait Captures<'a> {} -impl<'a, T: ?Sized> Captures<'a> for T {} - /// `bool` newtype that indicates whether this is a privately uninhabited field that we should skip /// during analysis. #[derive(Copy, Clone, Debug, PartialEq, Eq)] From bc0e581abf4221be953172279ee2c06f812b9365 Mon Sep 17 00:00:00 2001 From: Nicholas Nethercote Date: Fri, 1 May 2026 06:44:55 +1000 Subject: [PATCH 03/17] Eliminate `IsPrefixOf` trait. It has a single method and a single impl and the trait isn't directly used. It can just become an inherent method. --- .../src/diagnostics/conflict_errors.rs | 1 - compiler/rustc_borrowck/src/prefixes.rs | 12 ------------ compiler/rustc_middle/src/mir/statement.rs | 6 ++++++ 3 files changed, 6 insertions(+), 13 deletions(-) diff --git a/compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs b/compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs index f7d35f3ff3b4b..86184e913262e 100644 --- a/compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs +++ b/compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs @@ -47,7 +47,6 @@ use super::{DescribePlaceOpt, RegionName, RegionNameSource, UseSpans}; use crate::borrow_set::{BorrowData, TwoPhaseActivation}; use crate::diagnostics::conflict_errors::StorageDeadOrDrop::LocalStorageDead; use crate::diagnostics::{CapturedMessageOpt, call_kind, find_all_local_uses}; -use crate::prefixes::IsPrefixOf; use crate::{InitializationRequiringAction, MirBorrowckCtxt, WriteKind, borrowck_errors}; #[derive(Debug)] diff --git a/compiler/rustc_borrowck/src/prefixes.rs b/compiler/rustc_borrowck/src/prefixes.rs index 9e51264d8edcb..7ac63e02e318d 100644 --- a/compiler/rustc_borrowck/src/prefixes.rs +++ b/compiler/rustc_borrowck/src/prefixes.rs @@ -8,18 +8,6 @@ use rustc_middle::mir::{PlaceRef, ProjectionElem}; use super::MirBorrowckCtxt; -pub(crate) trait IsPrefixOf<'tcx> { - fn is_prefix_of(&self, other: PlaceRef<'tcx>) -> bool; -} - -impl<'tcx> IsPrefixOf<'tcx> for PlaceRef<'tcx> { - fn is_prefix_of(&self, other: PlaceRef<'tcx>) -> bool { - self.local == other.local - && self.projection.len() <= other.projection.len() - && self.projection == &other.projection[..self.projection.len()] - } -} - pub(super) struct Prefixes<'tcx> { kind: PrefixSet, next: Option>, diff --git a/compiler/rustc_middle/src/mir/statement.rs b/compiler/rustc_middle/src/mir/statement.rs index c55d49c12b4b8..02bbcf1c9e6cb 100644 --- a/compiler/rustc_middle/src/mir/statement.rs +++ b/compiler/rustc_middle/src/mir/statement.rs @@ -478,6 +478,12 @@ impl From for Place<'_> { } impl<'tcx> PlaceRef<'tcx> { + pub fn is_prefix_of(&self, other: PlaceRef<'tcx>) -> bool { + self.local == other.local + && self.projection.len() <= other.projection.len() + && self.projection == &other.projection[..self.projection.len()] + } + /// Finds the innermost `Local` from this `Place`, *if* it is either a local itself or /// a single deref of a local. pub fn local_or_deref_local(&self) -> Option { From 82cfcaf7ec49ae6643f584a2fee15f06457836ec Mon Sep 17 00:00:00 2001 From: Nicholas Nethercote Date: Fri, 1 May 2026 08:59:18 +1000 Subject: [PATCH 04/17] Remove useless bounds on `Self` for impls of concrete types. When you have `impl Foo for Bar` and `Bar` has no generics it's useless (and odd) to have `where Self: Baz` bounds on methods when the trait itself doesn't have those bounds. This commit removes a few. --- compiler/rustc_borrowck/src/region_infer/values.rs | 10 ++-------- compiler/rustc_error_messages/src/lib.rs | 5 +---- compiler/rustc_infer/src/infer/snapshot/undo_log.rs | 1 - 3 files changed, 3 insertions(+), 13 deletions(-) diff --git a/compiler/rustc_borrowck/src/region_infer/values.rs b/compiler/rustc_borrowck/src/region_infer/values.rs index c1fed1260340f..6a0d70790cfef 100644 --- a/compiler/rustc_borrowck/src/region_infer/values.rs +++ b/compiler/rustc_borrowck/src/region_infer/values.rs @@ -426,19 +426,13 @@ impl ToElementIndex<'_> for RegionVid { } impl<'tcx> ToElementIndex<'tcx> for ty::PlaceholderRegion<'tcx> { - fn add_to_row(self, values: &mut RegionValues<'tcx, N>, row: N) -> bool - where - Self: Into>, - { + fn add_to_row(self, values: &mut RegionValues<'tcx, N>, row: N) -> bool { let placeholder: ty::PlaceholderRegion<'tcx> = self.into(); let index = values.placeholder_indices.lookup_index(placeholder); values.placeholders.insert(row, index) } - fn contained_in_row(self, values: &RegionValues<'tcx, N>, row: N) -> bool - where - Self: Into>, - { + fn contained_in_row(self, values: &RegionValues<'tcx, N>, row: N) -> bool { let placeholder: ty::PlaceholderRegion<'tcx> = self.into(); let index = values.placeholder_indices.lookup_index(placeholder); values.placeholders.contains(row, index) diff --git a/compiler/rustc_error_messages/src/lib.rs b/compiler/rustc_error_messages/src/lib.rs index bbcda7bce2177..0111080bc2ee4 100644 --- a/compiler/rustc_error_messages/src/lib.rs +++ b/compiler/rustc_error_messages/src/lib.rs @@ -268,10 +268,7 @@ pub fn fluent_value_from_str_list_sep_by_and(l: Vec>) -> FluentValu type Args = (); type Error = (); - fn construct(lang: LanguageIdentifier, _args: Self::Args) -> Result - where - Self: Sized, - { + fn construct(lang: LanguageIdentifier, _args: Self::Args) -> Result { let locale = icu_locale_from_unic_langid(lang) .unwrap_or_else(|| rustc_baked_icu_data::supported_locales::EN); let list_formatter = icu_list::ListFormatter::try_new_and_unstable( diff --git a/compiler/rustc_infer/src/infer/snapshot/undo_log.rs b/compiler/rustc_infer/src/infer/snapshot/undo_log.rs index 19212c99ae43b..a10026f2f77c7 100644 --- a/compiler/rustc_infer/src/infer/snapshot/undo_log.rs +++ b/compiler/rustc_infer/src/infer/snapshot/undo_log.rs @@ -126,7 +126,6 @@ where fn extend(&mut self, undos: J) where - Self: Sized, J: IntoIterator, { if self.in_snapshot() { From 9119225b7f1bcecbec04ddff25adc6255811abdc Mon Sep 17 00:00:00 2001 From: Nicholas Nethercote Date: Fri, 1 May 2026 09:01:48 +1000 Subject: [PATCH 05/17] Remove unnecessary trait bound on `Subdiagnostic`. FWIW, note that `Diagnostic` doesn't have this bound. --- compiler/rustc_errors/src/diagnostic.rs | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/compiler/rustc_errors/src/diagnostic.rs b/compiler/rustc_errors/src/diagnostic.rs index 377d96b73e9b8..2fbb90b770261 100644 --- a/compiler/rustc_errors/src/diagnostic.rs +++ b/compiler/rustc_errors/src/diagnostic.rs @@ -143,10 +143,7 @@ impl<'a, F: FnOnce(&mut Diag<'_, ()>)> Diagnostic<'a, ()> for DiagDecorator { /// Trait implemented by error types. This should not be implemented manually. Instead, use /// `#[derive(Subdiagnostic)]` -- see [rustc_macros::Subdiagnostic]. #[rustc_diagnostic_item = "Subdiagnostic"] -pub trait Subdiagnostic -where - Self: Sized, -{ +pub trait Subdiagnostic { /// Add a subdiagnostic to an existing diagnostic. fn add_to_diag(self, diag: &mut Diag<'_, G>); } From 548cdc1412a08910994ad8e06c412e3a195f7ef1 Mon Sep 17 00:00:00 2001 From: Scott McMurray Date: Thu, 30 Apr 2026 20:52:02 -0700 Subject: [PATCH 06/17] Add a `Local::arg(i)` helper constructor While reading through stuff I was noticing just how many `+1` fixes there were in various places (and comments explaining that fixup), so this adds a new inherent helper on `Local` for making an argument to help make this clearer. --- .../src/type_check/input_output.rs | 2 +- compiler/rustc_codegen_ssa/src/mir/block.rs | 2 +- compiler/rustc_middle/src/mir/mod.rs | 10 +++++++++ compiler/rustc_middle/src/ty/closure.rs | 2 +- compiler/rustc_mir_build/src/builder/mod.rs | 2 +- compiler/rustc_mir_transform/src/coroutine.rs | 4 ++-- compiler/rustc_mir_transform/src/shim.rs | 22 +++++++++---------- .../src/shim/async_destructor_ctor.rs | 4 ++-- .../src/single_use_consts.rs | 2 +- compiler/rustc_mir_transform/src/sroa.rs | 2 +- 10 files changed, 31 insertions(+), 21 deletions(-) diff --git a/compiler/rustc_borrowck/src/type_check/input_output.rs b/compiler/rustc_borrowck/src/type_check/input_output.rs index 2e6a2962b8760..64c5f5f0c560b 100644 --- a/compiler/rustc_borrowck/src/type_check/input_output.rs +++ b/compiler/rustc_borrowck/src/type_check/input_output.rs @@ -176,7 +176,7 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> { } // In MIR, argument N is stored in local N+1. - let local = Local::from_usize(argument_index + 1); + let local = Local::arg(argument_index); let mir_input_ty = self.body.local_decls[local].ty; diff --git a/compiler/rustc_codegen_ssa/src/mir/block.rs b/compiler/rustc_codegen_ssa/src/mir/block.rs index 06c81662d6018..61f0f6b1b7690 100644 --- a/compiler/rustc_codegen_ssa/src/mir/block.rs +++ b/compiler/rustc_codegen_ssa/src/mir/block.rs @@ -523,7 +523,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> { if self.fn_abi.c_variadic { // The `VaList` "spoofed" argument is just after all the real arguments. let va_list_arg_idx = self.fn_abi.args.len(); - match self.locals[mir::Local::from_usize(1 + va_list_arg_idx)] { + match self.locals[mir::Local::arg(va_list_arg_idx)] { LocalRef::Place(va_list) => { bx.va_end(va_list.val.llval); diff --git a/compiler/rustc_middle/src/mir/mod.rs b/compiler/rustc_middle/src/mir/mod.rs index 36752bba9f722..e46a895aadd16 100644 --- a/compiler/rustc_middle/src/mir/mod.rs +++ b/compiler/rustc_middle/src/mir/mod.rs @@ -845,6 +845,16 @@ rustc_index::newtype_index! { } } +impl Local { + /// Makes a `Local` for the `i`-th argument to a function. + /// + /// `Local(0)` is the [`RETURN_PLACE`], with the arguments after that, + /// so `arg(i)` will give `Local(i + 1)`. + pub const fn arg(i: usize) -> Local { + Local::from_usize(i + 1) + } +} + impl Atom for Local { fn index(self) -> usize { Idx::index(self) diff --git a/compiler/rustc_middle/src/ty/closure.rs b/compiler/rustc_middle/src/ty/closure.rs index ce6f87668beff..e8d5f1a912d21 100644 --- a/compiler/rustc_middle/src/ty/closure.rs +++ b/compiler/rustc_middle/src/ty/closure.rs @@ -17,7 +17,7 @@ use crate::{mir, ty}; /// Captures are represented using fields inside a structure. /// This represents accessing self in the closure structure -pub const CAPTURE_STRUCT_LOCAL: mir::Local = mir::Local::from_u32(1); +pub const CAPTURE_STRUCT_LOCAL: mir::Local = mir::Local::arg(0); #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, TyEncodable, TyDecodable, HashStable)] #[derive(TypeFoldable, TypeVisitable)] diff --git a/compiler/rustc_mir_build/src/builder/mod.rs b/compiler/rustc_mir_build/src/builder/mod.rs index 8e51ab7d4edb1..5a33963b2b654 100644 --- a/compiler/rustc_mir_build/src/builder/mod.rs +++ b/compiler/rustc_mir_build/src/builder/mod.rs @@ -1068,7 +1068,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { // Bind the argument patterns for (index, param) in arguments.iter().enumerate() { // Function arguments always get the first Local indices after the return place - let local = Local::new(index + 1); + let local = Local::arg(index); let place = Place::from(local); // Make sure we drop (parts of) the argument even when not matched on. diff --git a/compiler/rustc_mir_transform/src/coroutine.rs b/compiler/rustc_mir_transform/src/coroutine.rs index 652fd00d54d02..807fe771d0ea2 100644 --- a/compiler/rustc_mir_transform/src/coroutine.rs +++ b/compiler/rustc_mir_transform/src/coroutine.rs @@ -168,8 +168,8 @@ fn replace_base<'tcx>(place: &mut Place<'tcx>, new_base: Place<'tcx>, tcx: TyCtx tracing::trace!(?place); } -const SELF_ARG: Local = Local::from_u32(1); -const CTX_ARG: Local = Local::from_u32(2); +const SELF_ARG: Local = Local::arg(0); +const CTX_ARG: Local = Local::arg(1); /// A `yield` point in the coroutine. struct SuspensionPoint<'tcx> { diff --git a/compiler/rustc_mir_transform/src/shim.rs b/compiler/rustc_mir_transform/src/shim.rs index 89423bf885c84..39d5eef844559 100644 --- a/compiler/rustc_mir_transform/src/shim.rs +++ b/compiler/rustc_mir_transform/src/shim.rs @@ -358,8 +358,8 @@ fn build_drop_shim<'tcx>(tcx: TyCtxt<'tcx>, def_id: DefId, ty: Option>) let mut body = new_body(source, blocks, local_decls_for_sig(&sig, span), sig.inputs().len(), span); - // The first argument (index 0), but add 1 for the return value. - let dropee_ptr = Place::from(Local::new(1 + 0)); + // The first argument (index 0), but local 1 (after the return place). + let dropee_ptr = Place::from(Local::arg(0)); let dropee_ptr = dropee_emit_retag(tcx, &mut body, dropee_ptr, span); if ty.is_some() { @@ -538,7 +538,7 @@ fn build_clone_shim<'tcx>(tcx: TyCtxt<'tcx>, def_id: DefId, self_ty: Ty<'tcx>) - let mut builder = CloneShimBuilder::new(tcx, def_id, self_ty); let dest = Place::return_place(); - let src = tcx.mk_place_deref(Place::from(Local::new(1 + 0))); + let src = tcx.mk_place_deref(Place::from(Local::arg(0))); match self_ty.kind() { ty::FnDef(..) | ty::FnPtr(..) => builder.copy_shim(), @@ -624,7 +624,7 @@ impl<'tcx> CloneShimBuilder<'tcx> { } fn copy_shim(&mut self) { - let rcvr = self.tcx.mk_place_deref(Place::from(Local::new(1 + 0))); + let rcvr = self.tcx.mk_place_deref(Place::from(Local::arg(0))); let ret_statement = self.make_statement(StatementKind::Assign(Box::new(( Place::return_place(), Rvalue::Use(Operand::Copy(rcvr)), @@ -879,7 +879,7 @@ fn build_call_shim<'tcx>( let rcvr_place = || { assert!(rcvr_adjustment.is_some()); - Place::from(Local::new(1)) + Place::from(Local::arg(0)) }; let mut statements = vec![]; @@ -938,11 +938,11 @@ fn build_call_shim<'tcx>( } // Pass all of the non-special arguments directly. - args.extend(arg_range.map(|i| Operand::Move(Place::from(Local::new(1 + i))))); + args.extend(arg_range.map(|i| Operand::Move(Place::from(Local::arg(i))))); // Untuple the last argument, if we have to. if let Some(untuple_args) = untuple_args { - let tuple_arg = Local::new(1 + (sig.inputs().len() - 1)); + let tuple_arg = Local::arg(sig.inputs().len() - 1); args.extend(untuple_args.iter().enumerate().map(|(i, ity)| { Operand::Move(tcx.mk_place_field(Place::from(tuple_arg), FieldIdx::new(i), *ity)) })); @@ -1074,7 +1074,7 @@ pub(super) fn build_adt_ctor(tcx: TyCtxt<'_>, ctor_id: DefId) -> Body<'_> { Rvalue::Aggregate( Box::new(kind), (0..variant.fields.len()) - .map(|idx| Operand::Move(Place::from(Local::new(idx + 1)))) + .map(|idx| Operand::Move(Place::from(Local::arg(idx)))) .collect(), ), ))), @@ -1125,7 +1125,7 @@ fn build_fn_ptr_addr_shim<'tcx>(tcx: TyCtxt<'tcx>, def_id: DefId, self_ty: Ty<'t // provenance. let rvalue = Rvalue::Cast( CastKind::FnPtrToPtr, - Operand::Move(Place::from(Local::new(1))), + Operand::Move(Place::from(Local::arg(0))), Ty::new_imm_ptr(tcx, tcx.types.unit), ); let stmt = Statement::new( @@ -1148,7 +1148,7 @@ fn build_construct_coroutine_by_move_shim<'tcx>( receiver_by_ref: bool, ) -> Body<'tcx> { let mut self_ty = tcx.type_of(coroutine_closure_def_id).instantiate_identity().skip_norm_wip(); - let mut self_local: Place<'tcx> = Local::from_usize(1).into(); + let mut self_local: Place<'tcx> = Local::arg(0).into(); let ty::CoroutineClosure(_, args) = *self_ty.kind() else { bug!(); }; @@ -1190,7 +1190,7 @@ fn build_construct_coroutine_by_move_shim<'tcx>( // Move all of the closure args. for idx in 1..sig.inputs().len() { - fields.push(Operand::Move(Local::from_usize(idx + 1).into())); + fields.push(Operand::Move(Local::arg(idx).into())); } for (idx, ty) in args.as_coroutine_closure().upvar_tys().iter().enumerate() { diff --git a/compiler/rustc_mir_transform/src/shim/async_destructor_ctor.rs b/compiler/rustc_mir_transform/src/shim/async_destructor_ctor.rs index 5038afffcd8d2..0897aecb17e0a 100644 --- a/compiler/rustc_mir_transform/src/shim/async_destructor_ctor.rs +++ b/compiler/rustc_mir_transform/src/shim/async_destructor_ctor.rs @@ -74,8 +74,8 @@ pub(super) fn build_async_drop_shim<'tcx>( let span = tcx.def_span(def_id); let source_info = SourceInfo::outermost(span); - // The first argument (index 0), but add 1 for the return value. - let coroutine_layout = Place::from(Local::new(1 + 0)); + // The first argument (index 0) which will be local 1 (after the return value). + let coroutine_layout = Place::from(Local::arg(0)); let coroutine_layout_dropee = tcx.mk_place_field(coroutine_layout, FieldIdx::new(0), drop_ptr_ty); diff --git a/compiler/rustc_mir_transform/src/single_use_consts.rs b/compiler/rustc_mir_transform/src/single_use_consts.rs index 91e040d5cbc89..5d0008f9e7472 100644 --- a/compiler/rustc_mir_transform/src/single_use_consts.rs +++ b/compiler/rustc_mir_transform/src/single_use_consts.rs @@ -35,7 +35,7 @@ impl<'tcx> crate::MirPass<'tcx> for SingleUseConsts { locals_in_debug_info: DenseBitSet::new_empty(body.local_decls.len()), }; - finder.ineligible_locals.insert_range(..=Local::from_usize(body.arg_count)); + finder.ineligible_locals.insert_range(..Local::arg(body.arg_count)); finder.visit_body(body); diff --git a/compiler/rustc_mir_transform/src/sroa.rs b/compiler/rustc_mir_transform/src/sroa.rs index f9ab5f3551221..0fe20e6a46acc 100644 --- a/compiler/rustc_mir_transform/src/sroa.rs +++ b/compiler/rustc_mir_transform/src/sroa.rs @@ -87,7 +87,7 @@ fn escaping_locals<'tcx>( }; let mut set = DenseBitSet::new_empty(body.local_decls.len()); - set.insert_range(RETURN_PLACE..=Local::from_usize(body.arg_count)); + set.insert_range(RETURN_PLACE..Local::arg(body.arg_count)); for (local, decl) in body.local_decls().iter_enumerated() { if excluded.contains(local) || is_excluded_ty(decl.ty) { set.insert(local); From f77fc05d25f901796341a6ab2803ff3b4120c09e Mon Sep 17 00:00:00 2001 From: Sasha Pourcelot Date: Tue, 28 Apr 2026 14:01:03 +0000 Subject: [PATCH 07/17] Add AcceptContext::expect_no_args --- .../rustc_attr_parsing/src/attributes/autodiff.rs | 11 ++--------- .../src/attributes/codegen_attrs.rs | 5 ++--- .../rustc_attr_parsing/src/attributes/crate_level.rs | 11 ++++------- compiler/rustc_attr_parsing/src/attributes/doc.rs | 10 +++++----- .../rustc_attr_parsing/src/attributes/macro_attrs.rs | 9 +++------ compiler/rustc_attr_parsing/src/attributes/mod.rs | 4 +--- .../src/attributes/proc_macro_attrs.rs | 12 +++--------- .../rustc_attr_parsing/src/attributes/rustc_dump.rs | 10 ++-------- .../src/attributes/rustc_internal.rs | 2 +- .../rustc_attr_parsing/src/attributes/test_attrs.rs | 2 +- compiler/rustc_attr_parsing/src/attributes/traits.rs | 4 +--- compiler/rustc_attr_parsing/src/context.rs | 10 ++++++++++ compiler/rustc_attr_parsing/src/parser.rs | 2 +- 13 files changed, 36 insertions(+), 56 deletions(-) diff --git a/compiler/rustc_attr_parsing/src/attributes/autodiff.rs b/compiler/rustc_attr_parsing/src/attributes/autodiff.rs index 34fd7c8e7f046..dc63767462201 100644 --- a/compiler/rustc_attr_parsing/src/attributes/autodiff.rs +++ b/compiler/rustc_attr_parsing/src/attributes/autodiff.rs @@ -52,10 +52,7 @@ impl SingleAttributeParser for RustcAutodiffParser { cx.adcx().expected_identifier(mode.span()); return None; }; - let Ok(()) = mode.args().no_args() else { - cx.adcx().expected_identifier(mode.span()); - return None; - }; + cx.expect_no_args(mode.args())?; let Some(mode) = mode.path().word() else { cx.adcx().expected_identifier(mode.span()); return None; @@ -85,11 +82,7 @@ impl SingleAttributeParser for RustcAutodiffParser { .expected_specific_argument(activity.span(), DiffActivity::all_activities()); return None; }; - let Ok(()) = activity.args().no_args() else { - cx.adcx() - .expected_specific_argument(activity.span(), DiffActivity::all_activities()); - return None; - }; + cx.expect_no_args(activity.args())?; let Some(activity) = activity.path().word() else { cx.adcx() .expected_specific_argument(activity.span(), DiffActivity::all_activities()); diff --git a/compiler/rustc_attr_parsing/src/attributes/codegen_attrs.rs b/compiler/rustc_attr_parsing/src/attributes/codegen_attrs.rs index a20813406b024..1230b2187458e 100644 --- a/compiler/rustc_attr_parsing/src/attributes/codegen_attrs.rs +++ b/compiler/rustc_attr_parsing/src/attributes/codegen_attrs.rs @@ -195,10 +195,9 @@ pub(crate) struct NakedParser { impl AttributeParser for NakedParser { const ATTRIBUTES: AcceptMapping = &[(&[sym::naked], template!(Word), |this, cx, args| { - if let Err(span) = args.no_args() { - cx.adcx().expected_no_args(span); + let Some(()) = cx.expect_no_args(args) else { return; - } + }; if let Some(earlier) = this.span { let span = cx.attr_span; diff --git a/compiler/rustc_attr_parsing/src/attributes/crate_level.rs b/compiler/rustc_attr_parsing/src/attributes/crate_level.rs index 76fa2aed5c79c..cc88fa0aea741 100644 --- a/compiler/rustc_attr_parsing/src/attributes/crate_level.rs +++ b/compiler/rustc_attr_parsing/src/attributes/crate_level.rs @@ -299,11 +299,9 @@ impl CombineAttributeParser for FeatureParser { cx.adcx().expected_identifier(elem.span()); continue; }; - if let Err(arg_span) = elem.args().no_args() { - cx.adcx().expected_no_args(arg_span); + let Some(()) = cx.expect_no_args(elem.args()) else { continue; - } - + }; let path = elem.path(); let Some(ident) = path.word() else { cx.adcx().expected_identifier(path.span()); @@ -345,10 +343,9 @@ impl CombineAttributeParser for RegisterToolParser { cx.adcx().expected_identifier(elem.span()); continue; }; - if let Err(arg_span) = elem.args().no_args() { - cx.adcx().expected_no_args(arg_span); + let Some(()) = cx.expect_no_args(elem.args()) else { continue; - } + }; let path = elem.path(); let Some(ident) = path.word() else { diff --git a/compiler/rustc_attr_parsing/src/attributes/doc.rs b/compiler/rustc_attr_parsing/src/attributes/doc.rs index c0b90c2c6d97f..2fdf3a7b8a55e 100644 --- a/compiler/rustc_attr_parsing/src/attributes/doc.rs +++ b/compiler/rustc_attr_parsing/src/attributes/doc.rs @@ -162,7 +162,7 @@ impl DocParser { match path.word_sym() { Some(sym::no_crate_inject) => { - if let Err(span) = args.no_args() { + if let Err(span) = args.as_no_args() { expected_no_args(cx, span); return; } @@ -295,7 +295,7 @@ impl DocParser { args: &ArgParser, inline: DocInline, ) { - if let Err(span) = args.no_args() { + if let Err(span) = args.as_no_args() { expected_no_args(cx, span); return; } @@ -449,7 +449,7 @@ impl DocParser { macro_rules! no_args { ($ident: ident) => {{ - if let Err(span) = args.no_args() { + if let Err(span) = args.as_no_args() { expected_no_args(cx, span); return; } @@ -468,7 +468,7 @@ impl DocParser { } macro_rules! no_args_and_not_crate_level { ($ident: ident) => {{ - if let Err(span) = args.no_args() { + if let Err(span) = args.as_no_args() { expected_no_args(cx, span); return; } @@ -484,7 +484,7 @@ impl DocParser { no_args_and_crate_level!($ident, |span| {}); }}; ($ident: ident, |$span:ident| $extra_validation:block) => {{ - if let Err(span) = args.no_args() { + if let Err(span) = args.as_no_args() { expected_no_args(cx, span); return; } diff --git a/compiler/rustc_attr_parsing/src/attributes/macro_attrs.rs b/compiler/rustc_attr_parsing/src/attributes/macro_attrs.rs index 36ee18d5bbe8d..80555053174f7 100644 --- a/compiler/rustc_attr_parsing/src/attributes/macro_attrs.rs +++ b/compiler/rustc_attr_parsing/src/attributes/macro_attrs.rs @@ -86,10 +86,9 @@ impl AttributeParser for MacroUseParser { cx.adcx().expected_identifier(item.span()); continue; }; - if let Err(err_span) = item.args().no_args() { - cx.adcx().expected_no_args(err_span); + let Some(()) = cx.expect_no_args(item.args()) else { continue; - } + }; let Some(item) = item.path().word() else { cx.adcx().expected_identifier(item.span()); continue; @@ -179,9 +178,7 @@ impl SingleAttributeParser for CollapseDebugInfoParser { cx.adcx().expected_not_literal(single.span()); return None; }; - if let Err(err) = mi.args().no_args() { - cx.adcx().expected_no_args(err); - } + let _ = cx.expect_no_args(mi.args()); let path = mi.path().word_sym(); let info = match path { Some(sym::yes) => CollapseMacroDebuginfo::Yes, diff --git a/compiler/rustc_attr_parsing/src/attributes/mod.rs b/compiler/rustc_attr_parsing/src/attributes/mod.rs index af90bd0fe58cc..42c6828ef57b7 100644 --- a/compiler/rustc_attr_parsing/src/attributes/mod.rs +++ b/compiler/rustc_attr_parsing/src/attributes/mod.rs @@ -258,9 +258,7 @@ impl SingleAttributeParser for WithoutArgs { const TEMPLATE: AttributeTemplate = template!(Word); fn convert(cx: &mut AcceptContext<'_, '_>, args: &ArgParser) -> Option { - if let Err(span) = args.no_args() { - cx.adcx().expected_no_args(span); - } + let _ = cx.expect_no_args(args); Some(T::CREATE(cx.attr_span)) } } diff --git a/compiler/rustc_attr_parsing/src/attributes/proc_macro_attrs.rs b/compiler/rustc_attr_parsing/src/attributes/proc_macro_attrs.rs index 00af9bd38e60c..67f0f15135588 100644 --- a/compiler/rustc_attr_parsing/src/attributes/proc_macro_attrs.rs +++ b/compiler/rustc_attr_parsing/src/attributes/proc_macro_attrs.rs @@ -59,7 +59,7 @@ fn parse_derive_like( ) -> Option<(Option, ThinVec)> { let Some(list) = args.as_list() else { // For #[rustc_builtin_macro], it is permitted to leave out the trait name - if args.no_args().is_ok() && !trait_name_mandatory { + if args.as_no_args().is_ok() && !trait_name_mandatory { return Some((None, ThinVec::new())); } let attr_span = cx.attr_span; @@ -85,10 +85,7 @@ fn parse_derive_like( cx.adcx().expected_identifier(trait_ident.span); return None; } - if let Err(e) = trait_attr.args().no_args() { - cx.adcx().expected_no_args(e); - return None; - }; + cx.expect_no_args(trait_attr.args())?; // Parse optional attributes let mut attributes = ThinVec::new(); @@ -109,10 +106,7 @@ fn parse_derive_like( cx.adcx().expected_identifier(attr.span()); return None; }; - if let Err(e) = attr.args().no_args() { - cx.adcx().expected_no_args(e); - return None; - }; + cx.expect_no_args(attr.args())?; let Some(ident) = attr.path().word() else { cx.adcx().expected_identifier(attr.path().span()); return None; diff --git a/compiler/rustc_attr_parsing/src/attributes/rustc_dump.rs b/compiler/rustc_attr_parsing/src/attributes/rustc_dump.rs index 1158f1c5acf4c..8d507065dbdb6 100644 --- a/compiler/rustc_attr_parsing/src/attributes/rustc_dump.rs +++ b/compiler/rustc_attr_parsing/src/attributes/rustc_dump.rs @@ -36,10 +36,7 @@ impl SingleAttributeParser for RustcDumpDefPathParser { ]); const TEMPLATE: AttributeTemplate = template!(Word); fn convert(cx: &mut AcceptContext<'_, '_>, args: &ArgParser) -> Option { - if let Err(span) = args.no_args() { - cx.adcx().expected_no_args(span); - return None; - } + cx.expect_no_args(args)?; Some(AttributeKind::RustcDumpDefPath(cx.attr_span)) } } @@ -203,10 +200,7 @@ impl SingleAttributeParser for RustcDumpSymbolNameParser { ]); const TEMPLATE: AttributeTemplate = template!(Word); fn convert(cx: &mut AcceptContext<'_, '_>, args: &ArgParser) -> Option { - if let Err(span) = args.no_args() { - cx.adcx().expected_no_args(span); - return None; - } + cx.expect_no_args(args)?; Some(AttributeKind::RustcDumpSymbolName(cx.attr_span)) } } diff --git a/compiler/rustc_attr_parsing/src/attributes/rustc_internal.rs b/compiler/rustc_attr_parsing/src/attributes/rustc_internal.rs index 835af97358ac4..697d3f8cc2a23 100644 --- a/compiler/rustc_attr_parsing/src/attributes/rustc_internal.rs +++ b/compiler/rustc_attr_parsing/src/attributes/rustc_internal.rs @@ -555,7 +555,7 @@ impl SingleAttributeParser for RustcScalableVectorParser { const TEMPLATE: AttributeTemplate = template!(Word, List: &["count"]); fn convert(cx: &mut AcceptContext<'_, '_>, args: &ArgParser) -> Option { - if args.no_args().is_ok() { + if args.as_no_args().is_ok() { return Some(AttributeKind::RustcScalableVector { element_count: None, span: cx.attr_span, diff --git a/compiler/rustc_attr_parsing/src/attributes/test_attrs.rs b/compiler/rustc_attr_parsing/src/attributes/test_attrs.rs index 4ed10b0ff1ac3..89f5e3747c1d6 100644 --- a/compiler/rustc_attr_parsing/src/attributes/test_attrs.rs +++ b/compiler/rustc_attr_parsing/src/attributes/test_attrs.rs @@ -30,7 +30,7 @@ impl SingleAttributeParser for IgnoreParser { ArgParser::List(list) => { let help = list.as_single().and_then(|item| item.meta_item()).and_then(|item| { - item.args().no_args().ok()?; + item.args().as_no_args().ok()?; Some(item.path().to_string()) }); cx.adcx().warn_ill_formed_attribute_input_with_help( diff --git a/compiler/rustc_attr_parsing/src/attributes/traits.rs b/compiler/rustc_attr_parsing/src/attributes/traits.rs index 546bb0364bddc..fe5af66f2a9cb 100644 --- a/compiler/rustc_attr_parsing/src/attributes/traits.rs +++ b/compiler/rustc_attr_parsing/src/attributes/traits.rs @@ -27,9 +27,7 @@ impl SingleAttributeParser for RustcSkipDuringMethodDispatchParser { cx.adcx().expected_not_literal(arg.span()); continue; }; - if let Err(span) = arg.args().no_args() { - cx.adcx().expected_no_args(span); - } + let _ = cx.expect_no_args(arg.args()); let path = arg.path(); let (key, skip): (Symbol, &mut bool) = match path.word_sym() { Some(key @ sym::array) => (key, &mut array), diff --git a/compiler/rustc_attr_parsing/src/context.rs b/compiler/rustc_attr_parsing/src/context.rs index 02a7aac9659f2..ccca7665bb593 100644 --- a/compiler/rustc_attr_parsing/src/context.rs +++ b/compiler/rustc_attr_parsing/src/context.rs @@ -570,6 +570,16 @@ impl<'f, 'sess: 'f> AcceptContext<'f, 'sess> { { arg.expect_name_value(self, span, name) } + + /// Assert that an [`ArgParser`] has no args, or emits an error and return `None`. + pub(crate) fn expect_no_args<'arg>(&mut self, arg: &'arg ArgParser) -> Option<()> { + if let Err(span) = arg.as_no_args() { + self.adcx().expected_no_args(span); + return None; + } + + Some(()) + } } pub(crate) trait ExpectNameValue { diff --git a/compiler/rustc_attr_parsing/src/parser.rs b/compiler/rustc_attr_parsing/src/parser.rs index de505cc8c7ac8..845f1394cc3de 100644 --- a/compiler/rustc_attr_parsing/src/parser.rs +++ b/compiler/rustc_attr_parsing/src/parser.rs @@ -202,7 +202,7 @@ impl ArgParser { /// Assert that there were no args. /// If there were, get a span to the arguments /// (to pass to [`AttributeDiagnosticContext::expected_no_args`](crate::context::AttributeDiagnosticContext::expected_no_args)). - pub fn no_args(&self) -> Result<(), Span> { + pub fn as_no_args(&self) -> Result<(), Span> { match self { Self::NoArgs => Ok(()), Self::List(args) => Err(args.span), From a9da61237948d682439a9d5b87827e3118aa53c7 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Fri, 1 May 2026 12:49:37 +0200 Subject: [PATCH 08/17] Add missing alias to mailmap --- .mailmap | 1 + 1 file changed, 1 insertion(+) diff --git a/.mailmap b/.mailmap index c29f6a66f5d7d..fa30f07ad7310 100644 --- a/.mailmap +++ b/.mailmap @@ -260,6 +260,7 @@ Grzegorz Bartoszek Guanqun Lu Guillaume Gomez Guillaume Gomez Guillaume Gomez +Guillaume Gomez ggomez Guillaume Gomez ggomez Guillaume Gomez Guillaume Gomez Guillaume Gomez Guillaume Gomez From f19e850f592889c49010b008b8c12e501eb2936e Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Fri, 1 May 2026 01:24:03 +0200 Subject: [PATCH 09/17] Improve source code for `librustdoc/visit_ast.rs` --- src/librustdoc/clean/mod.rs | 101 +++++++++++++++++++----------------- src/librustdoc/visit_ast.rs | 26 +++++++--- 2 files changed, 73 insertions(+), 54 deletions(-) diff --git a/src/librustdoc/clean/mod.rs b/src/librustdoc/clean/mod.rs index b42f2f92c52bd..3afe367a45ed3 100644 --- a/src/librustdoc/clean/mod.rs +++ b/src/librustdoc/clean/mod.rs @@ -62,12 +62,15 @@ pub(crate) use self::types::*; pub(crate) use self::utils::{krate, register_res, synthesize_auto_trait_and_blanket_impls}; use crate::core::DocContext; use crate::formats::item_type::ItemType; -use crate::visit_ast::Module as DocModule; +use crate::visit_ast; -pub(crate) fn clean_doc_module<'tcx>(doc: &DocModule<'tcx>, cx: &mut DocContext<'tcx>) -> Item { +pub(crate) fn clean_doc_module<'tcx>( + doc: &visit_ast::Module<'tcx>, + cx: &mut DocContext<'tcx>, +) -> Item { let mut items: Vec = vec![]; let mut inserted = FxHashSet::default(); - items.extend(doc.foreigns.iter().map(|(item, renamed, import_id)| { + items.extend(doc.foreigns.iter().map(|visit_ast::Foreign { item, renamed, import_id }| { let item = clean_maybe_renamed_foreign_item(cx, item, *renamed, *import_id); if let Some(name) = item.name && (cx.document_hidden() || !item.is_doc_hidden()) @@ -95,52 +98,56 @@ pub(crate) fn clean_doc_module<'tcx>(doc: &DocModule<'tcx>, cx: &mut DocContext< // This covers the case where somebody does an import which should pull in an item, // but there's already an item with the same namespace and same name. Rust gives // priority to the not-imported one, so we should, too. - items.extend(doc.items.values().flat_map(|entry| { - // First, lower everything other than glob imports. - let item = entry.item; - if matches!(item.kind, hir::ItemKind::Use(_, hir::UseKind::Glob)) { - return Vec::new(); - } - let v = clean_maybe_renamed_item(cx, item, entry.renamed, &entry.import_ids); - for item in &v { - if let Some(name) = item.name - && (cx.document_hidden() || !item.is_doc_hidden()) - { - inserted.insert((item.type_(), name)); + items.extend(doc.items.values().flat_map( + |visit_ast::ItemEntry { item, renamed, import_ids }| { + // First, lower everything other than glob imports. + if matches!(item.kind, hir::ItemKind::Use(_, hir::UseKind::Glob)) { + return Vec::new(); } - } - v - })); - items.extend(doc.inlined_foreigns.iter().flat_map(|((_, renamed), (res, local_import_id))| { - let Some(def_id) = res.opt_def_id() else { return Vec::new() }; - let name = renamed.unwrap_or_else(|| cx.tcx.item_name(def_id)); - let import = cx.tcx.hir_expect_item(*local_import_id); - match import.kind { - hir::ItemKind::Use(path, kind) => { - let hir::UsePath { segments, span, .. } = *path; - let path = hir::Path { segments, res: *res, span }; - clean_use_statement_inner( - import, - Some(name), - &path, - kind, - cx, - &mut Default::default(), - ) + let v = clean_maybe_renamed_item(cx, item, *renamed, import_ids); + for item in &v { + if let Some(name) = item.name + && (cx.document_hidden() || !item.is_doc_hidden()) + { + inserted.insert((item.type_(), name)); + } } - _ => unreachable!(), - } - })); - items.extend(doc.items.values().flat_map(|entry| { - // Now we actually lower the imports, skipping everything else. - let item = entry.item; - if let hir::ItemKind::Use(path, hir::UseKind::Glob) = item.kind { - clean_use_statement(item, entry.renamed, path, hir::UseKind::Glob, cx, &mut inserted) - } else { - // skip everything else - Vec::new() - } - })); + v + }, + )); + items.extend(doc.inlined_foreigns.iter().flat_map( + |((_, renamed), visit_ast::InlinedForeign { res, import_id })| { + let Some(def_id) = res.opt_def_id() else { return Vec::new() }; + let name = renamed.unwrap_or_else(|| cx.tcx.item_name(def_id)); + let import = cx.tcx.hir_expect_item(*import_id); + match import.kind { + hir::ItemKind::Use(path, kind) => { + let hir::UsePath { segments, span, .. } = *path; + let path = hir::Path { segments, res: *res, span }; + clean_use_statement_inner( + import, + Some(name), + &path, + kind, + cx, + &mut Default::default(), + ) + } + _ => unreachable!(), + } + }, + )); + items.extend(doc.items.values().flat_map( + |visit_ast::ItemEntry { item, renamed, import_ids: _ }| { + // Now we actually lower the imports, skipping everything else. + if let hir::ItemKind::Use(path, hir::UseKind::Glob) = item.kind { + clean_use_statement(item, *renamed, path, hir::UseKind::Glob, cx, &mut inserted) + } else { + // skip everything else + Vec::new() + } + }, + )); // determine if we should display the inner contents or // the outer `mod` item for the source code. diff --git a/src/librustdoc/visit_ast.rs b/src/librustdoc/visit_ast.rs index 5f119c23841e3..9e989bbd5fd9e 100644 --- a/src/librustdoc/visit_ast.rs +++ b/src/librustdoc/visit_ast.rs @@ -32,8 +32,7 @@ pub(crate) struct Module<'hir> { pub(crate) def_id: LocalDefId, pub(crate) renamed: Option, pub(crate) import_id: Option, - /// The key is the item `ItemId`. - /// We use `FxIndexMap` to keep the insert order. + /// The key is the item `ItemId`. We use `FxIndexMap` to keep the insert order. /// /// `import_id` needs to be a `Vec` because we live in a dark world where you can have code /// like: @@ -54,7 +53,7 @@ pub(crate) struct Module<'hir> { /// shadowed or not. pub(crate) items: FxIndexMap<(LocalDefId, Option), ItemEntry<'hir>>, - /// (def_id, renamed) -> (res, local_import_id) + /// The key is `(def_id, renamed)`. /// /// `inlined_foreigns` only contains `extern` items /// that are cross-crate inlined. @@ -62,9 +61,9 @@ pub(crate) struct Module<'hir> { /// Locally inlined `extern` items are /// stored in `foreigns` with the `import_id` set, /// analogous to how `items` is. - pub(crate) inlined_foreigns: FxIndexMap<(DefId, Option), (Res, LocalDefId)>, + pub(crate) inlined_foreigns: FxIndexMap<(DefId, Option), InlinedForeign>, /// (item, renamed, import_id) - pub(crate) foreigns: Vec<(&'hir hir::ForeignItem<'hir>, Option, Option)>, + pub(crate) foreigns: Vec>, } #[derive(Debug)] @@ -74,6 +73,19 @@ pub(crate) struct ItemEntry<'hir> { pub(crate) import_ids: Vec, } +#[derive(Debug)] +pub(crate) struct InlinedForeign { + pub(crate) res: Res, + pub(crate) import_id: LocalDefId, +} + +#[derive(Debug)] +pub(crate) struct Foreign<'hir> { + pub(crate) item: &'hir hir::ForeignItem<'hir>, + pub(crate) renamed: Option, + pub(crate) import_id: Option, +} + impl Module<'_> { pub(crate) fn new( name: Symbol, @@ -283,7 +295,7 @@ impl<'a, 'tcx> RustdocVisitor<'a, 'tcx> { .last_mut() .unwrap() .inlined_foreigns - .insert((ori_res_did, renamed), (res, def_id)); + .insert((ori_res_did, renamed), InlinedForeign { res, import_id: def_id }); return true; }; @@ -575,7 +587,7 @@ impl<'a, 'tcx> RustdocVisitor<'a, 'tcx> { ) { // If inlining we only want to include public functions. if !self.inlining || self.cx.tcx.visibility(item.owner_id).is_public() { - self.modules.last_mut().unwrap().foreigns.push((item, renamed, import_id)); + self.modules.last_mut().unwrap().foreigns.push(Foreign { item, renamed, import_id }); } } From f14ce9dab4dc3344111e235583b3ac9c313b9973 Mon Sep 17 00:00:00 2001 From: Jonathan Brouwer Date: Fri, 1 May 2026 16:39:12 +0200 Subject: [PATCH 10/17] Make `diverging_type_vars` a set of `TyVid` --- compiler/rustc_hir_typeck/src/fallback.rs | 2 +- compiler/rustc_hir_typeck/src/fn_ctxt/_impl.rs | 4 ++-- compiler/rustc_hir_typeck/src/typeck_root_ctxt.rs | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/compiler/rustc_hir_typeck/src/fallback.rs b/compiler/rustc_hir_typeck/src/fallback.rs index 3ce363e1e9c7e..c8b3c4dda10f8 100644 --- a/compiler/rustc_hir_typeck/src/fallback.rs +++ b/compiler/rustc_hir_typeck/src/fallback.rs @@ -212,7 +212,7 @@ impl<'tcx> FnCtxt<'_, 'tcx> { .diverging_type_vars .borrow() .items() - .map(|&ty| self.shallow_resolve(ty)) + .map(|&ty_id| self.shallow_resolve(Ty::new_var(self.tcx, ty_id))) .filter_map(|ty| ty.ty_vid()) .map(|vid| self.root_var(vid)) .collect(); diff --git a/compiler/rustc_hir_typeck/src/fn_ctxt/_impl.rs b/compiler/rustc_hir_typeck/src/fn_ctxt/_impl.rs index 9a54d651fe73a..84b95121ced50 100644 --- a/compiler/rustc_hir_typeck/src/fn_ctxt/_impl.rs +++ b/compiler/rustc_hir_typeck/src/fn_ctxt/_impl.rs @@ -321,8 +321,8 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { for a in &adj { match a.kind { Adjust::NeverToAny => { - if a.target.is_ty_var() { - self.diverging_type_vars.borrow_mut().insert(a.target); + if let ty::Infer(ty::TyVar(a_id)) = a.target.kind() { + self.diverging_type_vars.borrow_mut().insert(*a_id); debug!("apply_adjustments: adding `{:?}` as diverging type var", a.target); } } diff --git a/compiler/rustc_hir_typeck/src/typeck_root_ctxt.rs b/compiler/rustc_hir_typeck/src/typeck_root_ctxt.rs index ff2fc66e1d477..46a037afa49c4 100644 --- a/compiler/rustc_hir_typeck/src/typeck_root_ctxt.rs +++ b/compiler/rustc_hir_typeck/src/typeck_root_ctxt.rs @@ -6,7 +6,7 @@ use rustc_hir::def_id::LocalDefId; use rustc_hir::{self as hir, HirId, HirIdMap}; use rustc_infer::infer::{InferCtxt, InferOk, OpaqueTypeStorageEntries, TyCtxtInferExt}; use rustc_middle::span_bug; -use rustc_middle::ty::{self, Ty, TyCtxt, TypeVisitableExt, TypingMode}; +use rustc_middle::ty::{self, Ty, TyCtxt, TyVid, TypeVisitableExt, TypingMode}; use rustc_span::Span; use rustc_span::def_id::LocalDefIdMap; use rustc_trait_selection::traits::{self, FulfillmentError, TraitEngine, TraitEngineExt as _}; @@ -66,7 +66,7 @@ pub(crate) struct TypeckRootCtxt<'tcx> { /// Whenever we introduce an adjustment from `!` into a type variable, /// we record that type variable here. This is later used to inform /// fallback. See the `fallback` module for details. - pub(super) diverging_type_vars: RefCell>>, + pub(super) diverging_type_vars: RefCell>, } impl<'tcx> Deref for TypeckRootCtxt<'tcx> { From c17d24e1f7ca638c318e3ee910974cdb5efa29a7 Mon Sep 17 00:00:00 2001 From: Jonathan Brouwer Date: Fri, 1 May 2026 16:51:07 +0200 Subject: [PATCH 11/17] Make `diverging_type_vars` a `Vec` It being a `Set` does not really make sense. You never really should do a `contains` on it, since you should normalize the tyvid to its root var first. --- compiler/rustc_hir_typeck/src/fallback.rs | 2 +- compiler/rustc_hir_typeck/src/fn_ctxt/_impl.rs | 2 +- compiler/rustc_hir_typeck/src/typeck_root_ctxt.rs | 3 +-- 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/compiler/rustc_hir_typeck/src/fallback.rs b/compiler/rustc_hir_typeck/src/fallback.rs index c8b3c4dda10f8..4dfbbc6c6350c 100644 --- a/compiler/rustc_hir_typeck/src/fallback.rs +++ b/compiler/rustc_hir_typeck/src/fallback.rs @@ -211,7 +211,7 @@ impl<'tcx> FnCtxt<'_, 'tcx> { let diverging_roots: UnordSet = self .diverging_type_vars .borrow() - .items() + .iter() .map(|&ty_id| self.shallow_resolve(Ty::new_var(self.tcx, ty_id))) .filter_map(|ty| ty.ty_vid()) .map(|vid| self.root_var(vid)) diff --git a/compiler/rustc_hir_typeck/src/fn_ctxt/_impl.rs b/compiler/rustc_hir_typeck/src/fn_ctxt/_impl.rs index 84b95121ced50..360236f048dec 100644 --- a/compiler/rustc_hir_typeck/src/fn_ctxt/_impl.rs +++ b/compiler/rustc_hir_typeck/src/fn_ctxt/_impl.rs @@ -322,7 +322,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { match a.kind { Adjust::NeverToAny => { if let ty::Infer(ty::TyVar(a_id)) = a.target.kind() { - self.diverging_type_vars.borrow_mut().insert(*a_id); + self.diverging_type_vars.borrow_mut().push(*a_id); debug!("apply_adjustments: adding `{:?}` as diverging type var", a.target); } } diff --git a/compiler/rustc_hir_typeck/src/typeck_root_ctxt.rs b/compiler/rustc_hir_typeck/src/typeck_root_ctxt.rs index 46a037afa49c4..e4dcead1f7954 100644 --- a/compiler/rustc_hir_typeck/src/typeck_root_ctxt.rs +++ b/compiler/rustc_hir_typeck/src/typeck_root_ctxt.rs @@ -1,7 +1,6 @@ use std::cell::{Cell, RefCell}; use std::ops::Deref; -use rustc_data_structures::unord::UnordSet; use rustc_hir::def_id::LocalDefId; use rustc_hir::{self as hir, HirId, HirIdMap}; use rustc_infer::infer::{InferCtxt, InferOk, OpaqueTypeStorageEntries, TyCtxtInferExt}; @@ -66,7 +65,7 @@ pub(crate) struct TypeckRootCtxt<'tcx> { /// Whenever we introduce an adjustment from `!` into a type variable, /// we record that type variable here. This is later used to inform /// fallback. See the `fallback` module for details. - pub(super) diverging_type_vars: RefCell>, + pub(super) diverging_type_vars: RefCell>, } impl<'tcx> Deref for TypeckRootCtxt<'tcx> { From b14a811b4b21d58964a6b50674e20c5233b28be7 Mon Sep 17 00:00:00 2001 From: Camille Gillot Date: Fri, 1 May 2026 15:41:27 +0000 Subject: [PATCH 12/17] Reuse CTFE MIR for constructors. --- compiler/rustc_mir_transform/src/lib.rs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/compiler/rustc_mir_transform/src/lib.rs b/compiler/rustc_mir_transform/src/lib.rs index 9273c2103d442..21a55654cd844 100644 --- a/compiler/rustc_mir_transform/src/lib.rs +++ b/compiler/rustc_mir_transform/src/lib.rs @@ -430,6 +430,7 @@ fn mir_promoted( def: LocalDefId, ) -> (&Steal>, &Steal>>) { debug_assert!(!tcx.is_trivial_const(def), "Tried to get mir_promoted of a trivial const"); + debug_assert!(!tcx.is_constructor(def.to_def_id())); // Ensure that we compute the `mir_const_qualif` for constants at // this point, before we steal the mir-const result. @@ -492,7 +493,6 @@ fn mir_for_ctfe(tcx: TyCtxt<'_>, def_id: LocalDefId) -> &Body<'_> { } fn inner_mir_for_ctfe(tcx: TyCtxt<'_>, def: LocalDefId) -> Body<'_> { - // FIXME: don't duplicate this between the optimized_mir/mir_for_ctfe queries if tcx.is_constructor(def.to_def_id()) { // There's no reason to run all of the MIR passes on constructors when // we can just output the MIR we want directly. This also saves const @@ -785,18 +785,18 @@ pub(crate) fn run_optimization_passes<'tcx>(tcx: TyCtxt<'tcx>, body: &mut Body<' /// Optimize the MIR and prepare it for codegen. fn optimized_mir(tcx: TyCtxt<'_>, did: LocalDefId) -> &Body<'_> { - tcx.arena.alloc(inner_optimized_mir(tcx, did)) -} - -fn inner_optimized_mir(tcx: TyCtxt<'_>, did: LocalDefId) -> Body<'_> { if tcx.is_constructor(did.to_def_id()) { // There's no reason to run all of the MIR passes on constructors when // we can just output the MIR we want directly. This also saves const // qualification and borrow checking the trouble of special casing // constructors. - return shim::build_adt_ctor(tcx, did.to_def_id()); + return tcx.mir_for_ctfe(did); } + tcx.arena.alloc(inner_optimized_mir(tcx, did)) +} + +fn inner_optimized_mir(tcx: TyCtxt<'_>, did: LocalDefId) -> Body<'_> { match tcx.hir_body_const_context(did) { // Run the `mir_for_ctfe` query, which depends on `mir_drops_elaborated_and_const_checked` // which we are going to steal below. Thus we need to run `mir_for_ctfe` first, so it From e906d1f9eb8b9812a576e43311d513ff5a6dad90 Mon Sep 17 00:00:00 2001 From: Martin Nordholts Date: Fri, 1 May 2026 19:08:02 +0200 Subject: [PATCH 13/17] compiler: Print valid `-Zmir-enable-passes` names if invalid name is used If a user passes an invalid name to `-Zmir-enable-passes`, print the valid names as a note. The diagnostic is duplicated, but that is not introduced by this commit. In other words, we don't make matters worse. The existing "is unknown and will be ignored" diagnostic is already duplicated. To avoid the annoyance of having to keep blessing test output, completely normalize away the list of names in the test. --- compiler/rustc_mir_transform/src/errors.rs | 9 ++++++++- compiler/rustc_mir_transform/src/pass_manager.rs | 8 ++++++++ tests/ui/mir/enable_passes_validation.all_unknown.stderr | 6 ++++++ ...nable_passes_validation.enum_not_in_pass_names.stderr | 6 ++++++ tests/ui/mir/enable_passes_validation.mixed.stderr | 6 ++++++ tests/ui/mir/enable_passes_validation.rs | 1 + 6 files changed, 35 insertions(+), 1 deletion(-) diff --git a/compiler/rustc_mir_transform/src/errors.rs b/compiler/rustc_mir_transform/src/errors.rs index 77dea3ae1003b..39c85489f939a 100644 --- a/compiler/rustc_mir_transform/src/errors.rs +++ b/compiler/rustc_mir_transform/src/errors.rs @@ -1,6 +1,7 @@ use rustc_errors::codes::*; use rustc_errors::{ - Applicability, Diag, DiagCtxtHandle, Diagnostic, EmissionGuarantee, Level, Subdiagnostic, msg, + Applicability, Diag, DiagCtxtHandle, DiagSymbolList, Diagnostic, EmissionGuarantee, Level, + Subdiagnostic, msg, }; use rustc_macros::{Diagnostic, Subdiagnostic}; use rustc_middle::mir::AssertKind; @@ -120,6 +121,12 @@ pub(crate) struct UnknownPassName<'a> { pub(crate) name: &'a str, } +#[derive(Diagnostic)] +#[diag("valid MIR pass names are: {$valid_passes}")] +pub(crate) struct ValidPassNames<'a> { + pub(crate) valid_passes: DiagSymbolList<&'a str>, +} + pub(crate) struct AssertLint

{ pub span: Span, pub assert_kind: AssertKind

, diff --git a/compiler/rustc_mir_transform/src/pass_manager.rs b/compiler/rustc_mir_transform/src/pass_manager.rs index a081364165438..ef4cf82cf1b5d 100644 --- a/compiler/rustc_mir_transform/src/pass_manager.rs +++ b/compiler/rustc_mir_transform/src/pass_manager.rs @@ -253,8 +253,16 @@ fn run_passes_inner<'tcx>( let named_passes: FxIndexSet<_> = overridden_passes.iter().map(|(name, _)| name.as_str()).collect(); + let mut unknown_found = false; for &name in named_passes.difference(&*crate::PASS_NAMES) { tcx.dcx().emit_warn(errors::UnknownPassName { name }); + unknown_found = true; + } + + if unknown_found { + let mut valid_pass_names = crate::PASS_NAMES.iter().copied().collect::>(); + valid_pass_names.sort(); + tcx.dcx().emit_note(errors::ValidPassNames { valid_passes: valid_pass_names.into() }); } // Verify that no passes are missing from the `declare_passes` invocation diff --git a/tests/ui/mir/enable_passes_validation.all_unknown.stderr b/tests/ui/mir/enable_passes_validation.all_unknown.stderr index 85a942c00ede7..937988726e78f 100644 --- a/tests/ui/mir/enable_passes_validation.all_unknown.stderr +++ b/tests/ui/mir/enable_passes_validation.all_unknown.stderr @@ -2,6 +2,8 @@ warning: MIR pass `ThisPass` is unknown and will be ignored warning: MIR pass `DoesNotExist` is unknown and will be ignored +note: valid MIR pass names are: $PASS_NAMES + warning: MIR pass `ThisPass` is unknown and will be ignored | = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` @@ -10,5 +12,9 @@ warning: MIR pass `DoesNotExist` is unknown and will be ignored | = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` +note: valid MIR pass names are: $PASS_NAMES + | + = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` + warning: 4 warnings emitted diff --git a/tests/ui/mir/enable_passes_validation.enum_not_in_pass_names.stderr b/tests/ui/mir/enable_passes_validation.enum_not_in_pass_names.stderr index 89229ebabe84c..23ccdf7d205a4 100644 --- a/tests/ui/mir/enable_passes_validation.enum_not_in_pass_names.stderr +++ b/tests/ui/mir/enable_passes_validation.enum_not_in_pass_names.stderr @@ -1,8 +1,14 @@ warning: MIR pass `SimplifyCfg` is unknown and will be ignored +note: valid MIR pass names are: $PASS_NAMES + warning: MIR pass `SimplifyCfg` is unknown and will be ignored | = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` +note: valid MIR pass names are: $PASS_NAMES + | + = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` + warning: 2 warnings emitted diff --git a/tests/ui/mir/enable_passes_validation.mixed.stderr b/tests/ui/mir/enable_passes_validation.mixed.stderr index 5aace86abc020..4ddada9d17c9b 100644 --- a/tests/ui/mir/enable_passes_validation.mixed.stderr +++ b/tests/ui/mir/enable_passes_validation.mixed.stderr @@ -1,8 +1,14 @@ warning: MIR pass `ThisPassDoesNotExist` is unknown and will be ignored +note: valid MIR pass names are: $PASS_NAMES + warning: MIR pass `ThisPassDoesNotExist` is unknown and will be ignored | = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` +note: valid MIR pass names are: $PASS_NAMES + | + = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` + warning: 2 warnings emitted diff --git a/tests/ui/mir/enable_passes_validation.rs b/tests/ui/mir/enable_passes_validation.rs index d3d22b49ac7f8..7dae3a99e3886 100644 --- a/tests/ui/mir/enable_passes_validation.rs +++ b/tests/ui/mir/enable_passes_validation.rs @@ -1,5 +1,6 @@ //@ revisions: empty unprefixed all_unknown all_known mixed //@ revisions: enum_not_in_pass_names enum_in_pass_names +//@ normalize-stderr: "note: valid MIR pass names are: .*" -> "note: valid MIR pass names are: $$PASS_NAMES" //@[empty] compile-flags: -Zmir-enable-passes= From ab9c9bf850f7cc542b67a9c8d6b60644160d9416 Mon Sep 17 00:00:00 2001 From: Nicholas Nethercote Date: Fri, 1 May 2026 09:58:03 +1000 Subject: [PATCH 14/17] Fix a comment. --- compiler/rustc_index_macros/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/compiler/rustc_index_macros/src/lib.rs b/compiler/rustc_index_macros/src/lib.rs index e4790e5ebadc5..aab0de83be09c 100644 --- a/compiler/rustc_index_macros/src/lib.rs +++ b/compiler/rustc_index_macros/src/lib.rs @@ -25,7 +25,7 @@ mod newtype; /// The impls provided by default are Clone, Copy, PartialEq, Eq, and Hash. /// /// Accepted attributes for customization: -/// - `#[derive(HashStable)]`: derives `HashStable`, as normal. +/// - `#[stable_hash]`: derives `HashStable`. /// - `#[encodable]`: derives `Encodable`/`Decodable`. /// - `#[orderable]`: derives `PartialOrd`/`Ord`, plus step-related methods. /// - `#[debug_format = "Foo({})"]`: derives `Debug` with particular output. From 851049cf581ab3ba12cc511620849be2a9039ff0 Mon Sep 17 00:00:00 2001 From: Nicholas Nethercote Date: Fri, 1 May 2026 09:16:23 +1000 Subject: [PATCH 15/17] Rename the `hash_stable` method as `stable_hash`. Part of MCP 983. --- compiler/rustc_abi/src/extern_abi.rs | 2 +- compiler/rustc_ast/src/ast.rs | 6 +- compiler/rustc_ast/src/node_id.rs | 2 +- compiler/rustc_ast/src/tokenstream.rs | 6 +- compiler/rustc_ast_lowering/src/lib.rs | 2 +- .../rustc_codegen_cranelift/src/driver/aot.rs | 2 +- compiler/rustc_codegen_llvm/src/common.rs | 2 +- .../src/debuginfo/metadata/type_map.rs | 2 +- compiler/rustc_codegen_ssa/src/common.rs | 2 +- .../src/debuginfo/type_names.rs | 2 +- compiler/rustc_data_structures/src/intern.rs | 4 +- compiler/rustc_data_structures/src/packed.rs | 4 +- .../rustc_data_structures/src/sorted_map.rs | 4 +- .../src/stable_hasher.rs | 178 +++++++++--------- .../src/stable_hasher/tests.rs | 8 +- compiler/rustc_data_structures/src/steal.rs | 4 +- .../rustc_data_structures/src/tagged_ptr.rs | 6 +- .../src/tagged_ptr/tests.rs | 8 +- compiler/rustc_data_structures/src/unord.rs | 14 +- compiler/rustc_feature/src/unstable.rs | 20 +- compiler/rustc_hir/src/lang_items.rs | 2 +- compiler/rustc_hir/src/stable_hash_impls.rs | 12 +- compiler/rustc_hir_id/src/lib.rs | 4 +- compiler/rustc_index_macros/src/newtype.rs | 8 +- compiler/rustc_lint_defs/src/lib.rs | 12 +- compiler/rustc_macros/src/hash_stable.rs | 8 +- .../src/dep_graph/dep_node_key.rs | 2 +- compiler/rustc_middle/src/dep_graph/graph.rs | 2 +- compiler/rustc_middle/src/hir/map.rs | 18 +- compiler/rustc_middle/src/hir/mod.rs | 12 +- compiler/rustc_middle/src/ich.rs | 8 +- compiler/rustc_middle/src/middle/privacy.rs | 4 +- compiler/rustc_middle/src/mir/basic_blocks.rs | 2 +- compiler/rustc_middle/src/mono.rs | 2 +- .../rustc_middle/src/query/on_disk_cache.rs | 2 +- compiler/rustc_middle/src/ty/adt.rs | 12 +- compiler/rustc_middle/src/ty/consts/int.rs | 8 +- compiler/rustc_middle/src/ty/impls_ty.rs | 20 +- compiler/rustc_middle/src/ty/mod.rs | 4 +- compiler/rustc_middle/src/ty/util.rs | 2 +- compiler/rustc_span/src/def_id.rs | 12 +- compiler/rustc_span/src/hygiene.rs | 20 +- compiler/rustc_span/src/lib.rs | 2 +- compiler/rustc_span/src/symbol.rs | 8 +- compiler/rustc_symbol_mangling/src/hashed.rs | 2 +- compiler/rustc_symbol_mangling/src/legacy.rs | 12 +- compiler/rustc_type_ir/src/const_kind.rs | 4 +- compiler/rustc_type_ir/src/fast_reject.rs | 2 +- compiler/rustc_type_ir/src/region_kind.rs | 14 +- compiler/rustc_type_ir/src/ty_info.rs | 4 +- compiler/rustc_type_ir/src/ty_kind.rs | 6 +- 51 files changed, 254 insertions(+), 254 deletions(-) diff --git a/compiler/rustc_abi/src/extern_abi.rs b/compiler/rustc_abi/src/extern_abi.rs index 9de25c4cec405..12940d8cfe078 100644 --- a/compiler/rustc_abi/src/extern_abi.rs +++ b/compiler/rustc_abi/src/extern_abi.rs @@ -244,7 +244,7 @@ impl Hash for ExternAbi { #[cfg(feature = "nightly")] impl HashStable for ExternAbi { #[inline] - fn hash_stable(&self, _: &mut Hcx, hasher: &mut StableHasher) { + fn stable_hash(&self, _: &mut Hcx, hasher: &mut StableHasher) { Hash::hash(self, hasher); } } diff --git a/compiler/rustc_ast/src/ast.rs b/compiler/rustc_ast/src/ast.rs index a768beedba31c..d650ec49b8124 100644 --- a/compiler/rustc_ast/src/ast.rs +++ b/compiler/rustc_ast/src/ast.rs @@ -121,10 +121,10 @@ impl PartialEq<&[Symbol]> for Path { } impl HashStable for Path { - fn hash_stable(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { - self.segments.len().hash_stable(hcx, hasher); + fn stable_hash(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { + self.segments.len().stable_hash(hcx, hasher); for segment in &self.segments { - segment.ident.hash_stable(hcx, hasher); + segment.ident.stable_hash(hcx, hasher); } } } diff --git a/compiler/rustc_ast/src/node_id.rs b/compiler/rustc_ast/src/node_id.rs index 8ba2d5eaa8ba7..170897ebe1f4d 100644 --- a/compiler/rustc_ast/src/node_id.rs +++ b/compiler/rustc_ast/src/node_id.rs @@ -21,7 +21,7 @@ rustc_index::newtype_index! { impl HashStable for NodeId { #[inline] - fn hash_stable(&self, _: &mut Hcx, _: &mut StableHasher) { + fn stable_hash(&self, _: &mut Hcx, _: &mut StableHasher) { // This impl is never called but is necessary for types implementing `HashStable` such as // `MainDefinition` and `DocLinkResMap` (both of which occur in `ResolverGlobalCtxt`). panic!("Node IDs should not appear in incremental state"); diff --git a/compiler/rustc_ast/src/tokenstream.rs b/compiler/rustc_ast/src/tokenstream.rs index 86a6d93dac359..6d22bcbe6fc4b 100644 --- a/compiler/rustc_ast/src/tokenstream.rs +++ b/compiler/rustc_ast/src/tokenstream.rs @@ -139,7 +139,7 @@ impl Decodable for LazyAttrTokenStream { } impl HashStable for LazyAttrTokenStream { - fn hash_stable(&self, _hcx: &mut Hcx, _hasher: &mut StableHasher) { + fn stable_hash(&self, _hcx: &mut Hcx, _hasher: &mut StableHasher) { panic!("Attempted to compute stable hash for LazyAttrTokenStream"); } } @@ -825,9 +825,9 @@ impl FromIterator for TokenStream { } impl HashStable for TokenStream { - fn hash_stable(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { + fn stable_hash(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { for sub_tt in self.iter() { - sub_tt.hash_stable(hcx, hasher); + sub_tt.stable_hash(hcx, hasher); } } } diff --git a/compiler/rustc_ast_lowering/src/lib.rs b/compiler/rustc_ast_lowering/src/lib.rs index 49790c2da6de4..d11d5e6ddcd2b 100644 --- a/compiler/rustc_ast_lowering/src/lib.rs +++ b/compiler/rustc_ast_lowering/src/lib.rs @@ -523,7 +523,7 @@ fn compute_hir_hash( tcx.with_stable_hashing_context(|mut hcx| { let mut stable_hasher = StableHasher::new(); - hir_body_nodes.hash_stable(&mut hcx, &mut stable_hasher); + hir_body_nodes.stable_hash(&mut hcx, &mut stable_hasher); stable_hasher.finish() }) } diff --git a/compiler/rustc_codegen_cranelift/src/driver/aot.rs b/compiler/rustc_codegen_cranelift/src/driver/aot.rs index 26e518ccc94de..a8059187a1d2e 100644 --- a/compiler/rustc_codegen_cranelift/src/driver/aot.rs +++ b/compiler/rustc_codegen_cranelift/src/driver/aot.rs @@ -46,7 +46,7 @@ enum OngoingModuleCodegen { } impl HashStable for OngoingModuleCodegen { - fn hash_stable(&self, _: &mut Hcx, _: &mut StableHasher) { + fn stable_hash(&self, _: &mut Hcx, _: &mut StableHasher) { // do nothing } } diff --git a/compiler/rustc_codegen_llvm/src/common.rs b/compiler/rustc_codegen_llvm/src/common.rs index dadf8e9e7d5fa..b532eb238ac94 100644 --- a/compiler/rustc_codegen_llvm/src/common.rs +++ b/compiler/rustc_codegen_llvm/src/common.rs @@ -308,7 +308,7 @@ impl<'ll, 'tcx> ConstCodegenMethods for CodegenCx<'ll, 'tcx> { { let hash = self.tcx.with_stable_hashing_context(|mut hcx| { let mut hasher = StableHasher::new(); - alloc.hash_stable(&mut hcx, &mut hasher); + alloc.stable_hash(&mut hcx, &mut hasher); hasher.finish::() }); llvm::set_value_name( diff --git a/compiler/rustc_codegen_llvm/src/debuginfo/metadata/type_map.rs b/compiler/rustc_codegen_llvm/src/debuginfo/metadata/type_map.rs index 9a5c3289cabd8..b75fe4264239e 100644 --- a/compiler/rustc_codegen_llvm/src/debuginfo/metadata/type_map.rs +++ b/compiler/rustc_codegen_llvm/src/debuginfo/metadata/type_map.rs @@ -130,7 +130,7 @@ impl<'tcx> UniqueTypeId<'tcx> { fn generate_unique_id_string(self, tcx: TyCtxt<'tcx>) -> String { let mut hasher = StableHasher::new(); tcx.with_stable_hashing_context(|mut hcx| { - hcx.while_hashing_spans(false, |hcx| self.hash_stable(hcx, &mut hasher)) + hcx.while_hashing_spans(false, |hcx| self.stable_hash(hcx, &mut hasher)) }); hasher.finish::().to_hex() } diff --git a/compiler/rustc_codegen_ssa/src/common.rs b/compiler/rustc_codegen_ssa/src/common.rs index c963bb9de4b42..81c095cbf4af8 100644 --- a/compiler/rustc_codegen_ssa/src/common.rs +++ b/compiler/rustc_codegen_ssa/src/common.rs @@ -103,7 +103,7 @@ mod temp_stable_hash_impls { use crate::ModuleCodegen; impl HashStable for ModuleCodegen { - fn hash_stable(&self, _: &mut Hcx, _: &mut StableHasher) { + fn stable_hash(&self, _: &mut Hcx, _: &mut StableHasher) { // do nothing } } diff --git a/compiler/rustc_codegen_ssa/src/debuginfo/type_names.rs b/compiler/rustc_codegen_ssa/src/debuginfo/type_names.rs index b4c6ecd069f82..20d556028389d 100644 --- a/compiler/rustc_codegen_ssa/src/debuginfo/type_names.rs +++ b/compiler/rustc_codegen_ssa/src/debuginfo/type_names.rs @@ -734,7 +734,7 @@ fn push_debuginfo_const_name<'tcx>(tcx: TyCtxt<'tcx>, ct: ty::Const<'tcx>, outpu // avoiding collisions and will make the emitted type names shorter. let hash_short = tcx.with_stable_hashing_context(|mut hcx| { let mut hasher = StableHasher::new(); - hcx.while_hashing_spans(false, |hcx| cv.hash_stable(hcx, &mut hasher)); + hcx.while_hashing_spans(false, |hcx| cv.stable_hash(hcx, &mut hasher)); hasher.finish::() }); diff --git a/compiler/rustc_data_structures/src/intern.rs b/compiler/rustc_data_structures/src/intern.rs index 419cdc115518c..21706a11fbe02 100644 --- a/compiler/rustc_data_structures/src/intern.rs +++ b/compiler/rustc_data_structures/src/intern.rs @@ -107,8 +107,8 @@ impl HashStable for Interned<'_, T> where T: HashStable, { - fn hash_stable(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { - self.0.hash_stable(hcx, hasher); + fn stable_hash(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { + self.0.stable_hash(hcx, hasher); } } diff --git a/compiler/rustc_data_structures/src/packed.rs b/compiler/rustc_data_structures/src/packed.rs index 30f76cb4476c5..9220b87ffe8cc 100644 --- a/compiler/rustc_data_structures/src/packed.rs +++ b/compiler/rustc_data_structures/src/packed.rs @@ -62,8 +62,8 @@ impl fmt::UpperHex for Pu128 { impl HashStable for Pu128 { #[inline] - fn hash_stable(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { - { self.0 }.hash_stable(hcx, hasher) + fn stable_hash(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { + { self.0 }.stable_hash(hcx, hasher) } } diff --git a/compiler/rustc_data_structures/src/sorted_map.rs b/compiler/rustc_data_structures/src/sorted_map.rs index ca813a36059ba..1b0f9380b347e 100644 --- a/compiler/rustc_data_structures/src/sorted_map.rs +++ b/compiler/rustc_data_structures/src/sorted_map.rs @@ -349,8 +349,8 @@ impl FromIterator<(K, V)> for SortedMap { impl HashStable for SortedMap { #[inline] - fn hash_stable(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { - self.data.hash_stable(hcx, hasher); + fn stable_hash(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { + self.data.stable_hash(hcx, hasher); } } diff --git a/compiler/rustc_data_structures/src/stable_hasher.rs b/compiler/rustc_data_structures/src/stable_hasher.rs index 9d4b03f63c098..671cddde185b9 100644 --- a/compiler/rustc_data_structures/src/stable_hasher.rs +++ b/compiler/rustc_data_structures/src/stable_hasher.rs @@ -55,25 +55,25 @@ pub struct RawDefPathHash(pub [u8; 16]); /// - Stable hashes are sometimes used as identifiers. Therefore they must /// conform to the corresponding `PartialEq` implementations: /// -/// - `x == y` implies `hash_stable(x) == hash_stable(y)`, and -/// - `x != y` implies `hash_stable(x) != hash_stable(y)`. +/// - `x == y` implies `stable_hash(x) == stable_hash(y)`, and +/// - `x != y` implies `stable_hash(x) != stable_hash(y)`. /// /// That second condition is usually not required for hash functions -/// (e.g. `Hash`). In practice this means that `hash_stable` must feed any +/// (e.g. `Hash`). In practice this means that `stable_hash` must feed any /// information into the hasher that a `PartialEq` comparison takes into /// account. See [#49300](https://github.com/rust-lang/rust/issues/49300) /// for an example where violating this invariant has caused trouble in the /// past. /// -/// - `hash_stable()` must be independent of the current +/// - `stable_hash()` must be independent of the current /// compilation session. E.g. they must not hash memory addresses or other /// things that are "randomly" assigned per compilation session. /// -/// - `hash_stable()` must be independent of the host architecture. The +/// - `stable_hash()` must be independent of the host architecture. The /// `StableHasher` takes care of endianness and `isize`/`usize` platform /// differences. pub trait HashStable { - fn hash_stable(&self, hcx: &mut Hcx, hasher: &mut StableHasher); + fn stable_hash(&self, hcx: &mut Hcx, hasher: &mut StableHasher); } /// Implement this for types that can be turned into stable keys like, for @@ -169,7 +169,7 @@ macro_rules! impl_stable_traits_for_trivial_type { ($t:ty) => { impl $crate::stable_hasher::HashStable for $t { #[inline] - fn hash_stable( + fn stable_hash( &self, _: &mut Hcx, hasher: &mut $crate::stable_hasher::StableHasher, @@ -214,7 +214,7 @@ impl_stable_traits_for_trivial_type!(Hash64); // hashing we want to hash the full 128-bit hash. impl HashStable for Hash128 { #[inline] - fn hash_stable(&self, _: &mut Hcx, hasher: &mut StableHasher) { + fn stable_hash(&self, _: &mut Hcx, hasher: &mut StableHasher) { self.as_u128().hash(hasher); } } @@ -228,63 +228,63 @@ impl StableOrd for Hash128 { } impl HashStable for ! { - fn hash_stable(&self, _hcx: &mut Hcx, _hasher: &mut StableHasher) { + fn stable_hash(&self, _hcx: &mut Hcx, _hasher: &mut StableHasher) { unreachable!() } } impl HashStable for PhantomData { - fn hash_stable(&self, _hcx: &mut Hcx, _hasher: &mut StableHasher) {} + fn stable_hash(&self, _hcx: &mut Hcx, _hasher: &mut StableHasher) {} } impl HashStable for NonZero { #[inline] - fn hash_stable(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { - self.get().hash_stable(hcx, hasher) + fn stable_hash(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { + self.get().stable_hash(hcx, hasher) } } impl HashStable for NonZero { #[inline] - fn hash_stable(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { - self.get().hash_stable(hcx, hasher) + fn stable_hash(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { + self.get().stable_hash(hcx, hasher) } } impl HashStable for f32 { - fn hash_stable(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { + fn stable_hash(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { let val: u32 = self.to_bits(); - val.hash_stable(hcx, hasher); + val.stable_hash(hcx, hasher); } } impl HashStable for f64 { - fn hash_stable(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { + fn stable_hash(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { let val: u64 = self.to_bits(); - val.hash_stable(hcx, hasher); + val.stable_hash(hcx, hasher); } } impl HashStable for ::std::cmp::Ordering { #[inline] - fn hash_stable(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { - (*self as i8).hash_stable(hcx, hasher); + fn stable_hash(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { + (*self as i8).stable_hash(hcx, hasher); } } impl HashStable for (T1,) { #[inline] - fn hash_stable(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { + fn stable_hash(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { let (ref _0,) = *self; - _0.hash_stable(hcx, hasher); + _0.stable_hash(hcx, hasher); } } impl HashStable for (T1, T2) { - fn hash_stable(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { + fn stable_hash(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { let (ref _0, ref _1) = *self; - _0.hash_stable(hcx, hasher); - _1.hash_stable(hcx, hasher); + _0.stable_hash(hcx, hasher); + _1.stable_hash(hcx, hasher); } } @@ -302,11 +302,11 @@ where T2: HashStable, T3: HashStable, { - fn hash_stable(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { + fn stable_hash(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { let (ref _0, ref _1, ref _2) = *self; - _0.hash_stable(hcx, hasher); - _1.hash_stable(hcx, hasher); - _2.hash_stable(hcx, hasher); + _0.stable_hash(hcx, hasher); + _1.stable_hash(hcx, hasher); + _2.stable_hash(hcx, hasher); } } @@ -326,12 +326,12 @@ where T3: HashStable, T4: HashStable, { - fn hash_stable(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { + fn stable_hash(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { let (ref _0, ref _1, ref _2, ref _3) = *self; - _0.hash_stable(hcx, hasher); - _1.hash_stable(hcx, hasher); - _2.hash_stable(hcx, hasher); - _3.hash_stable(hcx, hasher); + _0.stable_hash(hcx, hasher); + _1.stable_hash(hcx, hasher); + _2.stable_hash(hcx, hasher); + _3.stable_hash(hcx, hasher); } } @@ -347,29 +347,29 @@ impl StableOrd for ( } impl HashStable for [T] { - default fn hash_stable( + default fn stable_hash( &self, hcx: &mut Hcx, hasher: &mut StableHasher, ) { - self.len().hash_stable(hcx, hasher); + self.len().stable_hash(hcx, hasher); for item in self { - item.hash_stable(hcx, hasher); + item.stable_hash(hcx, hasher); } } } impl HashStable for [u8] { - fn hash_stable(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { - self.len().hash_stable(hcx, hasher); + fn stable_hash(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { + self.len().stable_hash(hcx, hasher); hasher.write(self); } } impl HashStable for Vec { #[inline] - fn hash_stable(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { - self[..].hash_stable(hcx, hasher); + fn stable_hash(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { + self[..].stable_hash(hcx, hasher); } } @@ -380,10 +380,10 @@ where R: BuildHasher, { #[inline] - fn hash_stable(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { - self.len().hash_stable(hcx, hasher); + fn stable_hash(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { + self.len().stable_hash(hcx, hasher); for kv in self { - kv.hash_stable(hcx, hasher); + kv.stable_hash(hcx, hasher); } } } @@ -394,10 +394,10 @@ where R: BuildHasher, { #[inline] - fn hash_stable(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { - self.len().hash_stable(hcx, hasher); + fn stable_hash(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { + self.len().stable_hash(hcx, hasher); for key in self { - key.hash_stable(hcx, hasher); + key.stable_hash(hcx, hasher); } } } @@ -407,36 +407,36 @@ where A: HashStable, { #[inline] - fn hash_stable(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { - self[..].hash_stable(hcx, hasher); + fn stable_hash(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { + self[..].stable_hash(hcx, hasher); } } impl HashStable for Box { #[inline] - fn hash_stable(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { - (**self).hash_stable(hcx, hasher); + fn stable_hash(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { + (**self).stable_hash(hcx, hasher); } } impl HashStable for ::std::rc::Rc { #[inline] - fn hash_stable(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { - (**self).hash_stable(hcx, hasher); + fn stable_hash(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { + (**self).stable_hash(hcx, hasher); } } impl HashStable for ::std::sync::Arc { #[inline] - fn hash_stable(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { - (**self).hash_stable(hcx, hasher); + fn stable_hash(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { + (**self).stable_hash(hcx, hasher); } } impl HashStable for str { #[inline] - fn hash_stable(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { - self.as_bytes().hash_stable(hcx, hasher); + fn stable_hash(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { + self.as_bytes().stable_hash(hcx, hasher); } } @@ -450,8 +450,8 @@ impl StableOrd for &str { impl HashStable for String { #[inline] - fn hash_stable(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { - self[..].hash_stable(hcx, hasher); + fn stable_hash(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { + self[..].stable_hash(hcx, hasher); } } @@ -481,8 +481,8 @@ impl ToStableHashKey for (T1, T2) { impl HashStable for bool { #[inline] - fn hash_stable(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { - (if *self { 1u8 } else { 0u8 }).hash_stable(hcx, hasher); + fn stable_hash(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { + (if *self { 1u8 } else { 0u8 }).stable_hash(hcx, hasher); } } @@ -498,12 +498,12 @@ where T: HashStable, { #[inline] - fn hash_stable(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { + fn stable_hash(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { if let Some(ref value) = *self { - 1u8.hash_stable(hcx, hasher); - value.hash_stable(hcx, hasher); + 1u8.stable_hash(hcx, hasher); + value.stable_hash(hcx, hasher); } else { - 0u8.hash_stable(hcx, hasher); + 0u8.stable_hash(hcx, hasher); } } } @@ -521,11 +521,11 @@ where T2: HashStable, { #[inline] - fn hash_stable(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { - mem::discriminant(self).hash_stable(hcx, hasher); + fn stable_hash(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { + mem::discriminant(self).stable_hash(hcx, hasher); match *self { - Ok(ref x) => x.hash_stable(hcx, hasher), - Err(ref x) => x.hash_stable(hcx, hasher), + Ok(ref x) => x.stable_hash(hcx, hasher), + Err(ref x) => x.stable_hash(hcx, hasher), } } } @@ -535,14 +535,14 @@ where T: HashStable + ?Sized, { #[inline] - fn hash_stable(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { - (**self).hash_stable(hcx, hasher); + fn stable_hash(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { + (**self).stable_hash(hcx, hasher); } } impl HashStable for ::std::mem::Discriminant { #[inline] - fn hash_stable(&self, _: &mut Hcx, hasher: &mut StableHasher) { + fn stable_hash(&self, _: &mut Hcx, hasher: &mut StableHasher) { ::std::hash::Hash::hash(self, hasher); } } @@ -552,9 +552,9 @@ where T: HashStable, { #[inline] - fn hash_stable(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { - self.start().hash_stable(hcx, hasher); - self.end().hash_stable(hcx, hasher); + fn stable_hash(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { + self.start().stable_hash(hcx, hasher); + self.end().stable_hash(hcx, hasher); } } @@ -562,10 +562,10 @@ impl HashStable for IndexSlice where T: HashStable, { - fn hash_stable(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { - self.len().hash_stable(hcx, hasher); + fn stable_hash(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { + self.len().stable_hash(hcx, hasher); for v in &self.raw { - v.hash_stable(hcx, hasher); + v.stable_hash(hcx, hasher); } } } @@ -574,22 +574,22 @@ impl HashStable for IndexVec where T: HashStable, { - fn hash_stable(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { - self.len().hash_stable(hcx, hasher); + fn stable_hash(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { + self.len().stable_hash(hcx, hasher); for v in &self.raw { - v.hash_stable(hcx, hasher); + v.stable_hash(hcx, hasher); } } } impl HashStable for DenseBitSet { - fn hash_stable(&self, _hcx: &mut Hcx, hasher: &mut StableHasher) { + fn stable_hash(&self, _hcx: &mut Hcx, hasher: &mut StableHasher) { ::std::hash::Hash::hash(self, hasher); } } impl HashStable for bit_set::BitMatrix { - fn hash_stable(&self, _hcx: &mut Hcx, hasher: &mut StableHasher) { + fn stable_hash(&self, _hcx: &mut Hcx, hasher: &mut StableHasher) { ::std::hash::Hash::hash(self, hasher); } } @@ -610,10 +610,10 @@ where K: HashStable + StableOrd, V: HashStable, { - fn hash_stable(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { - self.len().hash_stable(hcx, hasher); + fn stable_hash(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { + self.len().stable_hash(hcx, hasher); for entry in self.iter() { - entry.hash_stable(hcx, hasher); + entry.stable_hash(hcx, hasher); } } } @@ -622,10 +622,10 @@ impl HashStable for ::std::collections::BTreeSet where K: HashStable + StableOrd, { - fn hash_stable(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { - self.len().hash_stable(hcx, hasher); + fn stable_hash(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { + self.len().stable_hash(hcx, hasher); for entry in self.iter() { - entry.hash_stable(hcx, hasher); + entry.stable_hash(hcx, hasher); } } } diff --git a/compiler/rustc_data_structures/src/stable_hasher/tests.rs b/compiler/rustc_data_structures/src/stable_hasher/tests.rs index da12d7ed7876b..246d9a1169f4c 100644 --- a/compiler/rustc_data_structures/src/stable_hasher/tests.rs +++ b/compiler/rustc_data_structures/src/stable_hasher/tests.rs @@ -25,7 +25,7 @@ impl HashStableContext for () { fn hash(t: &T) -> Hash128 { let mut h = StableHasher::new(); let hcx = &mut (); - t.hash_stable(hcx, &mut h); + t.stable_hash(hcx, &mut h); h.finish() } @@ -60,13 +60,13 @@ fn test_attribute_permutation() { } impl HashStable for Foo { - fn hash_stable( + fn stable_hash( &self, hcx: &mut Hcx, hasher: &mut StableHasher, ) { - self.a.hash_stable(hcx, hasher); - self.b.hash_stable(hcx, hasher); + self.a.stable_hash(hcx, hasher); + self.b.stable_hash(hcx, hasher); } } diff --git a/compiler/rustc_data_structures/src/steal.rs b/compiler/rustc_data_structures/src/steal.rs index 8e55323873951..757d8bf281c50 100644 --- a/compiler/rustc_data_structures/src/steal.rs +++ b/compiler/rustc_data_structures/src/steal.rs @@ -72,7 +72,7 @@ impl Steal { } impl HashStable for Steal { - fn hash_stable(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { - self.borrow().hash_stable(hcx, hasher); + fn stable_hash(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { + self.borrow().stable_hash(hcx, hasher); } } diff --git a/compiler/rustc_data_structures/src/tagged_ptr.rs b/compiler/rustc_data_structures/src/tagged_ptr.rs index 59baa441d2a4a..abe01b08e0f0d 100644 --- a/compiler/rustc_data_structures/src/tagged_ptr.rs +++ b/compiler/rustc_data_structures/src/tagged_ptr.rs @@ -264,9 +264,9 @@ where P: HashStable + Aligned + ?Sized, T: Tag + HashStable, { - fn hash_stable(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { - self.pointer().hash_stable(hcx, hasher); - self.tag().hash_stable(hcx, hasher); + fn stable_hash(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { + self.pointer().stable_hash(hcx, hasher); + self.tag().stable_hash(hcx, hasher); } } diff --git a/compiler/rustc_data_structures/src/tagged_ptr/tests.rs b/compiler/rustc_data_structures/src/tagged_ptr/tests.rs index a1c53ef854326..af41970886913 100644 --- a/compiler/rustc_data_structures/src/tagged_ptr/tests.rs +++ b/compiler/rustc_data_structures/src/tagged_ptr/tests.rs @@ -33,12 +33,12 @@ unsafe impl Tag for Tag2 { } impl HashStable for Tag2 { - fn hash_stable( + fn stable_hash( &self, hcx: &mut Hcx, hasher: &mut crate::stable_hasher::StableHasher, ) { - (*self as u8).hash_stable(hcx, hasher); + (*self as u8).stable_hash(hcx, hasher); } } @@ -69,13 +69,13 @@ fn smoke() { fn stable_hash_hashes_as_tuple() { let hash_packed = { let mut hasher = StableHasher::new(); - TaggedRef::new(&12, Tag2::B11).hash_stable(&mut (), &mut hasher); + TaggedRef::new(&12, Tag2::B11).stable_hash(&mut (), &mut hasher); hasher.finish::() }; let hash_tupled = { let mut hasher = StableHasher::new(); - (&12, Tag2::B11).hash_stable(&mut (), &mut hasher); + (&12, Tag2::B11).stable_hash(&mut (), &mut hasher); hasher.finish::() }; diff --git a/compiler/rustc_data_structures/src/unord.rs b/compiler/rustc_data_structures/src/unord.rs index 4c033065abe3d..9249a742ae2f5 100644 --- a/compiler/rustc_data_structures/src/unord.rs +++ b/compiler/rustc_data_structures/src/unord.rs @@ -422,7 +422,7 @@ impl> From> for UnordSet impl HashStable for UnordSet { #[inline] - fn hash_stable(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { + fn stable_hash(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { hash_iter_order_independent(self.inner.iter(), hcx, hasher); } } @@ -652,7 +652,7 @@ where impl HashStable for UnordMap { #[inline] - fn hash_stable(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { + fn stable_hash(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { hash_iter_order_independent(self.inner.iter(), hcx, hasher); } } @@ -715,7 +715,7 @@ impl> From> for UnordBag { impl HashStable for UnordBag { #[inline] - fn hash_stable(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { + fn stable_hash(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { hash_iter_order_independent(self.inner.iter(), hcx, hasher); } } @@ -752,7 +752,7 @@ fn hash_iter_order_independent< hasher: &mut StableHasher, ) { let len = it.len(); - len.hash_stable(hcx, hasher); + len.stable_hash(hcx, hasher); match len { 0 => { @@ -760,17 +760,17 @@ fn hash_iter_order_independent< } 1 => { // No need to instantiate a hasher - it.next().unwrap().hash_stable(hcx, hasher); + it.next().unwrap().stable_hash(hcx, hasher); } _ => { let mut accumulator = Fingerprint::ZERO; for item in it { let mut item_hasher = StableHasher::new(); - item.hash_stable(hcx, &mut item_hasher); + item.stable_hash(hcx, &mut item_hasher); let item_fingerprint: Fingerprint = item_hasher.finish(); accumulator = accumulator.combine_commutative(item_fingerprint); } - accumulator.hash_stable(hcx, hasher); + accumulator.stable_hash(hcx, hasher); } } } diff --git a/compiler/rustc_feature/src/unstable.rs b/compiler/rustc_feature/src/unstable.rs index d77031564db5d..373a6437e5fcf 100644 --- a/compiler/rustc_feature/src/unstable.rs +++ b/compiler/rustc_feature/src/unstable.rs @@ -121,28 +121,28 @@ impl Features { } impl HashStable for Features { - fn hash_stable(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { + fn stable_hash(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { // `enabled_features` is skipped because it's the sum of the lang and lib features. let Features { enabled_lang_features, enabled_lib_features, enabled_features: _ } = self; - enabled_lang_features.hash_stable(hcx, hasher); - enabled_lib_features.hash_stable(hcx, hasher); + enabled_lang_features.stable_hash(hcx, hasher); + enabled_lib_features.stable_hash(hcx, hasher); } } impl HashStable for EnabledLangFeature { - fn hash_stable(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { + fn stable_hash(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { let EnabledLangFeature { gate_name, attr_sp, stable_since } = self; - gate_name.hash_stable(hcx, hasher); - attr_sp.hash_stable(hcx, hasher); - stable_since.hash_stable(hcx, hasher); + gate_name.stable_hash(hcx, hasher); + attr_sp.stable_hash(hcx, hasher); + stable_since.stable_hash(hcx, hasher); } } impl HashStable for EnabledLibFeature { - fn hash_stable(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { + fn stable_hash(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { let EnabledLibFeature { gate_name, attr_sp } = self; - gate_name.hash_stable(hcx, hasher); - attr_sp.hash_stable(hcx, hasher); + gate_name.stable_hash(hcx, hasher); + attr_sp.stable_hash(hcx, hasher); } } diff --git a/compiler/rustc_hir/src/lang_items.rs b/compiler/rustc_hir/src/lang_items.rs index 6a8e5d25e54cc..f35973d16271b 100644 --- a/compiler/rustc_hir/src/lang_items.rs +++ b/compiler/rustc_hir/src/lang_items.rs @@ -145,7 +145,7 @@ macro_rules! language_item_table { } impl HashStable for LangItem { - fn hash_stable(&self, _: &mut Hcx, hasher: &mut StableHasher) { + fn stable_hash(&self, _: &mut Hcx, hasher: &mut StableHasher) { ::std::hash::Hash::hash(self, hasher); } } diff --git a/compiler/rustc_hir/src/stable_hash_impls.rs b/compiler/rustc_hir/src/stable_hash_impls.rs index 420ee271d86ba..15b45bf921c77 100644 --- a/compiler/rustc_hir/src/stable_hash_impls.rs +++ b/compiler/rustc_hir/src/stable_hash_impls.rs @@ -66,28 +66,28 @@ impl ToStableHashKey for ForeignItemId { // in "DefPath Mode". impl<'tcx> HashStable for OwnerNodes<'tcx> { - fn hash_stable(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { + fn stable_hash(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { // We ignore the `nodes` and `bodies` fields since these refer to information included in // `hash` which is hashed in the collector and used for the crate hash. // `local_id_to_def_id` is also ignored because is dependent on the body, then just hashing // the body satisfies the condition of two nodes being different have different - // `hash_stable` results. + // `stable_hash` results. let OwnerNodes { opt_hash_including_bodies, nodes: _, bodies: _ } = *self; - opt_hash_including_bodies.unwrap().hash_stable(hcx, hasher); + opt_hash_including_bodies.unwrap().stable_hash(hcx, hasher); } } impl<'tcx> HashStable for AttributeMap<'tcx> { - fn hash_stable(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { + fn stable_hash(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { // We ignore the `map` since it refers to information included in `opt_hash` which is // hashed in the collector and used for the crate hash. let AttributeMap { opt_hash, define_opaque: _, map: _ } = *self; - opt_hash.unwrap().hash_stable(hcx, hasher); + opt_hash.unwrap().stable_hash(hcx, hasher); } } impl HashStable for HashIgnoredAttrId { - fn hash_stable(&self, _hcx: &mut Hcx, _hasher: &mut StableHasher) { + fn stable_hash(&self, _hcx: &mut Hcx, _hasher: &mut StableHasher) { /* we don't hash HashIgnoredAttrId, we ignore them */ } } diff --git a/compiler/rustc_hir_id/src/lib.rs b/compiler/rustc_hir_id/src/lib.rs index 6077f28ddbb54..7590423f60444 100644 --- a/compiler/rustc_hir_id/src/lib.rs +++ b/compiler/rustc_hir_id/src/lib.rs @@ -57,8 +57,8 @@ impl rustc_index::Idx for OwnerId { impl HashStable for OwnerId { #[inline] - fn hash_stable(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { - self.to_stable_hash_key(hcx).hash_stable(hcx, hasher); + fn stable_hash(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { + self.to_stable_hash_key(hcx).stable_hash(hcx, hasher); } } diff --git a/compiler/rustc_index_macros/src/newtype.rs b/compiler/rustc_index_macros/src/newtype.rs index 2d77df9948ce5..4504a3db9c503 100644 --- a/compiler/rustc_index_macros/src/newtype.rs +++ b/compiler/rustc_index_macros/src/newtype.rs @@ -152,18 +152,18 @@ impl Parse for Newtype { quote! {} }; - let hash_stable = if stable_hash { + let hash_stable_impl = if stable_hash { quote! { #gate_rustc_only impl ::rustc_data_structures::stable_hasher::HashStable for #name { - fn hash_stable< + fn stable_hash< __Hcx: ::rustc_data_structures::stable_hasher::HashStableContext >( &self, hcx: &mut __Hcx, hasher: &mut ::rustc_data_structures::stable_hasher::StableHasher ) { - self.as_u32().hash_stable(hcx, hasher) + self.as_u32().stable_hash(hcx, hasher) } } } @@ -307,7 +307,7 @@ impl Parse for Newtype { #step - #hash_stable + #hash_stable_impl impl From<#name> for u32 { #[inline] diff --git a/compiler/rustc_lint_defs/src/lib.rs b/compiler/rustc_lint_defs/src/lib.rs index a0aa78d013ad4..dea655e279831 100644 --- a/compiler/rustc_lint_defs/src/lib.rs +++ b/compiler/rustc_lint_defs/src/lib.rs @@ -138,12 +138,12 @@ impl LintExpectationId { impl HashStable for LintExpectationId { #[inline] - fn hash_stable(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { + fn stable_hash(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { match self { LintExpectationId::Stable { hir_id, attr_index, lint_index: Some(lint_index) } => { - hir_id.hash_stable(hcx, hasher); - attr_index.hash_stable(hcx, hasher); - lint_index.hash_stable(hcx, hasher); + hir_id.stable_hash(hcx, hasher); + attr_index.stable_hash(hcx, hasher); + lint_index.stable_hash(hcx, hasher); } _ => { unreachable!( @@ -618,8 +618,8 @@ impl LintId { impl HashStable for LintId { #[inline] - fn hash_stable(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { - self.lint_name_raw().hash_stable(hcx, hasher); + fn stable_hash(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { + self.lint_name_raw().stable_hash(hcx, hasher); } } diff --git a/compiler/rustc_macros/src/hash_stable.rs b/compiler/rustc_macros/src/hash_stable.rs index 4fd5c00c411e3..3dd2e0b153a76 100644 --- a/compiler/rustc_macros/src/hash_stable.rs +++ b/compiler/rustc_macros/src/hash_stable.rs @@ -82,7 +82,7 @@ fn hash_stable_derive_with_mode( quote!(::rustc_data_structures::stable_hasher::HashStable), quote! { #[inline] - fn hash_stable<__Hcx: ::rustc_data_structures::stable_hasher::HashStableContext>( + fn stable_hash<__Hcx: ::rustc_data_structures::stable_hasher::HashStableContext>( &self, __hcx: &mut __Hcx, __hasher: &mut ::rustc_data_structures::stable_hasher::StableHasher @@ -97,7 +97,7 @@ fn hash_stable_derive_with_mode( fn hash_stable_discriminant(s: &mut synstructure::Structure<'_>) -> proc_macro2::TokenStream { match s.ast().data { syn::Data::Enum(_) => quote! { - ::std::mem::discriminant(self).hash_stable(__hcx, __hasher); + ::std::mem::discriminant(self).stable_hash(__hcx, __hasher); }, syn::Data::Struct(_) => quote! {}, syn::Data::Union(_) => panic!("cannot derive on union"), @@ -111,11 +111,11 @@ fn hash_stable_body(s: &mut synstructure::Structure<'_>) -> proc_macro2::TokenSt quote! {} } else if let Some(project) = attrs.project { quote! { - (&#bi.#project).hash_stable(__hcx, __hasher); + (&#bi.#project).stable_hash(__hcx, __hasher); } } else { quote! { - #bi.hash_stable(__hcx, __hasher); + #bi.stable_hash(__hcx, __hasher); } } }) diff --git a/compiler/rustc_middle/src/dep_graph/dep_node_key.rs b/compiler/rustc_middle/src/dep_graph/dep_node_key.rs index f81888a816e79..76a83209dc95b 100644 --- a/compiler/rustc_middle/src/dep_graph/dep_node_key.rs +++ b/compiler/rustc_middle/src/dep_graph/dep_node_key.rs @@ -40,7 +40,7 @@ where default fn to_fingerprint(&self, tcx: TyCtxt<'tcx>) -> Fingerprint { tcx.with_stable_hashing_context(|mut hcx| { let mut hasher = StableHasher::new(); - self.hash_stable(&mut hcx, &mut hasher); + self.stable_hash(&mut hcx, &mut hasher); hasher.finish() }) } diff --git a/compiler/rustc_middle/src/dep_graph/graph.rs b/compiler/rustc_middle/src/dep_graph/graph.rs index a4ec9a17f913c..70a16276e449c 100644 --- a/compiler/rustc_middle/src/dep_graph/graph.rs +++ b/compiler/rustc_middle/src/dep_graph/graph.rs @@ -126,7 +126,7 @@ where R: HashStable, { let mut stable_hasher = StableHasher::new(); - result.hash_stable(hcx, &mut stable_hasher); + result.stable_hash(hcx, &mut stable_hasher); stable_hasher.finish() } diff --git a/compiler/rustc_middle/src/hir/map.rs b/compiler/rustc_middle/src/hir/map.rs index 5a28dde4c9ba0..2ad2dfacf8b1a 100644 --- a/compiler/rustc_middle/src/hir/map.rs +++ b/compiler/rustc_middle/src/hir/map.rs @@ -1163,10 +1163,10 @@ pub(super) fn crate_hash(tcx: TyCtxt<'_>, _: LocalCrate) -> Svh { let crate_hash: Fingerprint = tcx.with_stable_hashing_context(|mut hcx| { let mut stable_hasher = StableHasher::new(); - hir_body_hash.hash_stable(&mut hcx, &mut stable_hasher); - upstream_crates.hash_stable(&mut hcx, &mut stable_hasher); - source_file_names.hash_stable(&mut hcx, &mut stable_hasher); - debugger_visualizers.hash_stable(&mut hcx, &mut stable_hasher); + hir_body_hash.stable_hash(&mut hcx, &mut stable_hasher); + upstream_crates.stable_hash(&mut hcx, &mut stable_hasher); + source_file_names.stable_hash(&mut hcx, &mut stable_hasher); + debugger_visualizers.stable_hash(&mut hcx, &mut stable_hasher); if tcx.sess.opts.incremental.is_some() { let definitions = tcx.untracked().definitions.freeze(); let mut owner_spans: Vec<_> = tcx @@ -1180,17 +1180,17 @@ pub(super) fn crate_hash(tcx: TyCtxt<'_>, _: LocalCrate) -> Svh { }) .collect(); owner_spans.sort_unstable_by_key(|bn| bn.0); - owner_spans.hash_stable(&mut hcx, &mut stable_hasher); + owner_spans.stable_hash(&mut hcx, &mut stable_hasher); } - tcx.sess.opts.dep_tracking_hash(true).hash_stable(&mut hcx, &mut stable_hasher); - tcx.stable_crate_id(LOCAL_CRATE).hash_stable(&mut hcx, &mut stable_hasher); + tcx.sess.opts.dep_tracking_hash(true).stable_hash(&mut hcx, &mut stable_hasher); + tcx.stable_crate_id(LOCAL_CRATE).stable_hash(&mut hcx, &mut stable_hasher); // Hash visibility information since it does not appear in HIR. // FIXME: Figure out how to remove `visibilities_for_hashing` by hashing visibilities on // the fly in the resolver, storing only their accumulated hash in `ResolverGlobalCtxt`, // and combining it with other hashes here. - resolutions.visibilities_for_hashing.hash_stable(&mut hcx, &mut stable_hasher); + resolutions.visibilities_for_hashing.stable_hash(&mut hcx, &mut stable_hasher); with_metavar_spans(|mspans| { - mspans.freeze_and_get_read_spans().hash_stable(&mut hcx, &mut stable_hasher); + mspans.freeze_and_get_read_spans().stable_hash(&mut hcx, &mut stable_hasher); }); stable_hasher.finish() }); diff --git a/compiler/rustc_middle/src/hir/mod.rs b/compiler/rustc_middle/src/hir/mod.rs index 64e09a9dbcf38..e9308d860fcb9 100644 --- a/compiler/rustc_middle/src/hir/mod.rs +++ b/compiler/rustc_middle/src/hir/mod.rs @@ -77,9 +77,9 @@ impl<'hir> Crate<'hir> { } impl HashStable for Crate<'_> { - fn hash_stable(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { + fn stable_hash(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { let Crate { opt_hir_hash, .. } = self; - opt_hir_hash.unwrap().hash_stable(hcx, hasher) + opt_hir_hash.unwrap().stable_hash(hcx, hasher) } } @@ -243,16 +243,16 @@ impl<'tcx> TyCtxt<'tcx> { self.with_stable_hashing_context(|mut hcx| { let mut stable_hasher = StableHasher::new(); - node.hash_stable(&mut hcx, &mut stable_hasher); + node.stable_hash(&mut hcx, &mut stable_hasher); // Bodies are stored out of line, so we need to pull them explicitly in the hash. - bodies.hash_stable(&mut hcx, &mut stable_hasher); + bodies.stable_hash(&mut hcx, &mut stable_hasher); let h1 = stable_hasher.finish(); let mut stable_hasher = StableHasher::new(); - attrs.hash_stable(&mut hcx, &mut stable_hasher); + attrs.stable_hash(&mut hcx, &mut stable_hasher); // Hash the defined opaque types, which are not present in the attrs. - define_opaque.hash_stable(&mut hcx, &mut stable_hasher); + define_opaque.stable_hash(&mut hcx, &mut stable_hasher); let h2 = stable_hasher.finish(); diff --git a/compiler/rustc_middle/src/ich.rs b/compiler/rustc_middle/src/ich.rs index f9527fa6e79de..e34c8f9e490db 100644 --- a/compiler/rustc_middle/src/ich.rs +++ b/compiler/rustc_middle/src/ich.rs @@ -96,8 +96,8 @@ impl<'a> HashStableContext for StableHashingContext<'a> { let span = Span::from_raw_span(raw_span); let span = span.data_untracked(); - span.ctxt.hash_stable(self, hasher); - span.parent.hash_stable(self, hasher); + span.ctxt.stable_hash(self, hasher); + span.parent.stable_hash(self, hasher); if span.is_dummy() { Hash::hash(&TAG_INVALID_SPAN, hasher); @@ -112,8 +112,8 @@ impl<'a> HashStableContext for StableHashingContext<'a> { // a subset of the cases from the `file.contains(parent.lo)`. But we can do this check // cheaply without the expensive `span_data_to_lines_and_cols` query. Hash::hash(&TAG_RELATIVE_SPAN, hasher); - (span.lo - parent.lo).to_u32().hash_stable(self, hasher); - (span.hi - parent.lo).to_u32().hash_stable(self, hasher); + (span.lo - parent.lo).to_u32().stable_hash(self, hasher); + (span.hi - parent.lo).to_u32().stable_hash(self, hasher); return; } diff --git a/compiler/rustc_middle/src/middle/privacy.rs b/compiler/rustc_middle/src/middle/privacy.rs index 6c6781a0bbae4..1a5f37be7292c 100644 --- a/compiler/rustc_middle/src/middle/privacy.rs +++ b/compiler/rustc_middle/src/middle/privacy.rs @@ -281,8 +281,8 @@ impl Default for EffectiveVisibilities { } impl HashStable for EffectiveVisibilities { - fn hash_stable(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { + fn stable_hash(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { let EffectiveVisibilities { ref map } = *self; - map.hash_stable(hcx, hasher); + map.stable_hash(hcx, hasher); } } diff --git a/compiler/rustc_middle/src/mir/basic_blocks.rs b/compiler/rustc_middle/src/mir/basic_blocks.rs index 96d4f3140da8c..f96bf99b8cb26 100644 --- a/compiler/rustc_middle/src/mir/basic_blocks.rs +++ b/compiler/rustc_middle/src/mir/basic_blocks.rs @@ -173,5 +173,5 @@ impl Decodable for Cache { impl HashStable for Cache { #[inline] - fn hash_stable(&self, _: &mut Hcx, _: &mut StableHasher) {} + fn stable_hash(&self, _: &mut Hcx, _: &mut StableHasher) {} } diff --git a/compiler/rustc_middle/src/mono.rs b/compiler/rustc_middle/src/mono.rs index 90ddc1cba6555..5cafa6d716825 100644 --- a/compiler/rustc_middle/src/mono.rs +++ b/compiler/rustc_middle/src/mono.rs @@ -331,7 +331,7 @@ impl ToStableHashKey for MonoItem<'_> { fn to_stable_hash_key(&self, hcx: &mut Hcx) -> Self::KeyType { let mut hasher = StableHasher::new(); - self.hash_stable(hcx, &mut hasher); + self.stable_hash(hcx, &mut hasher); hasher.finish() } } diff --git a/compiler/rustc_middle/src/query/on_disk_cache.rs b/compiler/rustc_middle/src/query/on_disk_cache.rs index df2c8d8b98f97..a9a81e653a09e 100644 --- a/compiler/rustc_middle/src/query/on_disk_cache.rs +++ b/compiler/rustc_middle/src/query/on_disk_cache.rs @@ -584,7 +584,7 @@ impl<'a, 'tcx> SpanDecoder for CacheDecoder<'a, 'tcx> { use rustc_data_structures::stable_hasher::{HashStable, StableHasher}; let local_hash = self.tcx.with_stable_hashing_context(|mut hcx| { let mut hasher = StableHasher::new(); - expn_id.expn_data().hash_stable(&mut hcx, &mut hasher); + expn_id.expn_data().stable_hash(&mut hcx, &mut hasher); hasher.finish() }); debug_assert_eq!(hash.local_hash(), local_hash); diff --git a/compiler/rustc_middle/src/ty/adt.rs b/compiler/rustc_middle/src/ty/adt.rs index 0e46a0007ecf7..dddd312b7b150 100644 --- a/compiler/rustc_middle/src/ty/adt.rs +++ b/compiler/rustc_middle/src/ty/adt.rs @@ -153,7 +153,7 @@ impl Hash for AdtDefData { } impl HashStable for AdtDefData { - fn hash_stable(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { + fn stable_hash(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { thread_local! { static CACHE: RefCell> = Default::default(); } @@ -165,16 +165,16 @@ impl HashStable for AdtDefData { let ty::AdtDefData { did, ref variants, ref flags, ref repr } = *self; let mut hasher = StableHasher::new(); - did.hash_stable(hcx, &mut hasher); - variants.hash_stable(hcx, &mut hasher); - flags.hash_stable(hcx, &mut hasher); - repr.hash_stable(hcx, &mut hasher); + did.stable_hash(hcx, &mut hasher); + variants.stable_hash(hcx, &mut hasher); + flags.stable_hash(hcx, &mut hasher); + repr.stable_hash(hcx, &mut hasher); hasher.finish() }) }); - hash.hash_stable(hcx, hasher); + hash.stable_hash(hcx, hasher); } } diff --git a/compiler/rustc_middle/src/ty/consts/int.rs b/compiler/rustc_middle/src/ty/consts/int.rs index 61c0575755bec..fe08df7c4b13e 100644 --- a/compiler/rustc_middle/src/ty/consts/int.rs +++ b/compiler/rustc_middle/src/ty/consts/int.rs @@ -153,17 +153,17 @@ pub struct ScalarInt { // Cannot derive these, as the derives take references to the fields, and we // can't take references to fields of packed structs. impl HashStable for ScalarInt { - fn hash_stable( + fn stable_hash( &self, hcx: &mut Hcx, hasher: &mut crate::ty::StableHasher, ) { // Using a block `{self.data}` here to force a copy instead of using `self.data` - // directly, because `hash_stable` takes `&self` and would thus borrow `self.data`. + // directly, because `stable_hash` takes `&self` and would thus borrow `self.data`. // Since `Self` is a packed struct, that would create a possibly unaligned reference, // which is UB. - { self.data }.hash_stable(hcx, hasher); - self.size.get().hash_stable(hcx, hasher); + { self.data }.stable_hash(hcx, hasher); + self.size.get().stable_hash(hcx, hasher); } } diff --git a/compiler/rustc_middle/src/ty/impls_ty.rs b/compiler/rustc_middle/src/ty/impls_ty.rs index c3777cf592cac..9fb3845782b11 100644 --- a/compiler/rustc_middle/src/ty/impls_ty.rs +++ b/compiler/rustc_middle/src/ty/impls_ty.rs @@ -18,7 +18,7 @@ impl<'tcx, H, T> HashStable for &'tcx ty::list::RawList where T: HashStable, { - fn hash_stable(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { + fn stable_hash(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { // Note: this cache makes an *enormous* performance difference on certain benchmarks. E.g. // without it, compiling `diesel-2.2.10` can be 74% slower, and compiling // `deeply-nested-multi` can be ~4,000x slower(!) @@ -34,14 +34,14 @@ where } let mut hasher = StableHasher::new(); - self[..].hash_stable(hcx, &mut hasher); + self[..].stable_hash(hcx, &mut hasher); let hash: Fingerprint = hasher.finish(); cache.borrow_mut().insert(key, hash); hash }); - hash.hash_stable(hcx, hasher); + hash.stable_hash(hcx, hasher); } } @@ -54,31 +54,31 @@ where #[inline] fn to_stable_hash_key(&self, hcx: &mut Hcx) -> Fingerprint { let mut hasher = StableHasher::new(); - self.hash_stable(hcx, &mut hasher); + self.stable_hash(hcx, &mut hasher); hasher.finish() } } impl<'tcx> HashStable for ty::GenericArg<'tcx> { - fn hash_stable(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { - self.kind().hash_stable(hcx, hasher); + fn stable_hash(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { + self.kind().stable_hash(hcx, hasher); } } // AllocIds get resolved to whatever they point to (to be stable) impl HashStable for mir::interpret::AllocId { - fn hash_stable(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { + fn stable_hash(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { ty::tls::with_opt(|tcx| { trace!("hashing {:?}", *self); let tcx = tcx.expect("can't hash AllocIds during hir lowering"); - tcx.try_get_global_alloc(*self).hash_stable(hcx, hasher); + tcx.try_get_global_alloc(*self).stable_hash(hcx, hasher); }); } } impl HashStable for mir::interpret::CtfeProvenance { - fn hash_stable(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { - self.into_parts().hash_stable(hcx, hasher); + fn stable_hash(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { + self.into_parts().stable_hash(hcx, hasher); } } diff --git a/compiler/rustc_middle/src/ty/mod.rs b/compiler/rustc_middle/src/ty/mod.rs index 9802d678dbf3c..b63d27cc9475d 100644 --- a/compiler/rustc_middle/src/ty/mod.rs +++ b/compiler/rustc_middle/src/ty/mod.rs @@ -558,8 +558,8 @@ impl<'tcx> From> for Term<'tcx> { } impl<'tcx> HashStable for Term<'tcx> { - fn hash_stable(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { - self.kind().hash_stable(hcx, hasher); + fn stable_hash(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { + self.kind().stable_hash(hcx, hasher); } } diff --git a/compiler/rustc_middle/src/ty/util.rs b/compiler/rustc_middle/src/ty/util.rs index 321a486249620..59fa0ddbb991e 100644 --- a/compiler/rustc_middle/src/ty/util.rs +++ b/compiler/rustc_middle/src/ty/util.rs @@ -138,7 +138,7 @@ impl<'tcx> TyCtxt<'tcx> { self.with_stable_hashing_context(|mut hcx| { let mut hasher = StableHasher::new(); - hcx.while_hashing_spans(false, |hcx| ty.hash_stable(hcx, &mut hasher)); + hcx.while_hashing_spans(false, |hcx| ty.stable_hash(hcx, &mut hasher)); hasher.finish() }) } diff --git a/compiler/rustc_span/src/def_id.rs b/compiler/rustc_span/src/def_id.rs index 0743dc221d610..8087ef122f6c9 100644 --- a/compiler/rustc_span/src/def_id.rs +++ b/compiler/rustc_span/src/def_id.rs @@ -429,22 +429,22 @@ rustc_data_structures::define_id_collections!( impl HashStable for DefId { #[inline] - fn hash_stable(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { - self.to_stable_hash_key(hcx).hash_stable(hcx, hasher); + fn stable_hash(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { + self.to_stable_hash_key(hcx).stable_hash(hcx, hasher); } } impl HashStable for LocalDefId { #[inline] - fn hash_stable(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { - self.to_stable_hash_key(hcx).local_hash().hash_stable(hcx, hasher); + fn stable_hash(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { + self.to_stable_hash_key(hcx).local_hash().stable_hash(hcx, hasher); } } impl HashStable for CrateNum { #[inline] - fn hash_stable(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { - self.as_def_id().to_stable_hash_key(hcx).stable_crate_id().hash_stable(hcx, hasher); + fn stable_hash(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { + self.as_def_id().to_stable_hash_key(hcx).stable_crate_id().stable_hash(hcx, hasher); } } diff --git a/compiler/rustc_span/src/hygiene.rs b/compiler/rustc_span/src/hygiene.rs index 5a0a003fd138e..5face6b38da0f 100644 --- a/compiler/rustc_span/src/hygiene.rs +++ b/compiler/rustc_span/src/hygiene.rs @@ -1106,7 +1106,7 @@ impl ExpnData { #[inline] fn hash_expn(&self, hcx: &mut impl HashStableContext) -> Hash64 { let mut hasher = StableHasher::new(); - self.hash_stable(hcx, &mut hasher); + self.stable_hash(hcx, &mut hasher); hasher.finish() } } @@ -1520,23 +1520,23 @@ fn update_disambiguator(expn_data: &mut ExpnData, mut hcx: impl HashStableContex } impl HashStable for SyntaxContext { - fn hash_stable(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { + fn stable_hash(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { const TAG_EXPANSION: u8 = 0; const TAG_NO_EXPANSION: u8 = 1; if self.is_root() { - TAG_NO_EXPANSION.hash_stable(hcx, hasher); + TAG_NO_EXPANSION.stable_hash(hcx, hasher); } else { - TAG_EXPANSION.hash_stable(hcx, hasher); + TAG_EXPANSION.stable_hash(hcx, hasher); let (expn_id, transparency) = self.outer_mark(); - expn_id.hash_stable(hcx, hasher); - transparency.hash_stable(hcx, hasher); + expn_id.stable_hash(hcx, hasher); + transparency.stable_hash(hcx, hasher); } } } impl HashStable for ExpnId { - fn hash_stable(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { + fn stable_hash(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { hcx.assert_default_hashing_controls("ExpnId"); let hash = if *self == ExpnId::root() { // Avoid fetching TLS storage for a trivial often-used value. @@ -1545,12 +1545,12 @@ impl HashStable for ExpnId { self.expn_hash().0 }; - hash.hash_stable(hcx, hasher); + hash.stable_hash(hcx, hasher); } } impl HashStable for LocalExpnId { - fn hash_stable(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { - self.to_expn_id().hash_stable(hcx, hasher); + fn stable_hash(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { + self.to_expn_id().stable_hash(hcx, hasher); } } diff --git a/compiler/rustc_span/src/lib.rs b/compiler/rustc_span/src/lib.rs index 931e9d4fb1f45..d637feff3fce6 100644 --- a/compiler/rustc_span/src/lib.rs +++ b/compiler/rustc_span/src/lib.rs @@ -2788,7 +2788,7 @@ impl InnerSpan { } impl HashStable for Span { - fn hash_stable(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { + fn stable_hash(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { // `span_hash_stable` does all the work. hcx.span_hash_stable(self.to_raw_span(), hasher) } diff --git a/compiler/rustc_span/src/symbol.rs b/compiler/rustc_span/src/symbol.rs index 702c3c54101c3..56ada83943f2b 100644 --- a/compiler/rustc_span/src/symbol.rs +++ b/compiler/rustc_span/src/symbol.rs @@ -2635,8 +2635,8 @@ impl fmt::Display for Symbol { impl HashStable for Symbol { #[inline] - fn hash_stable(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { - self.as_str().hash_stable(hcx, hasher); + fn stable_hash(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { + self.as_str().stable_hash(hcx, hasher); } } @@ -2695,8 +2695,8 @@ impl fmt::Debug for ByteSymbol { impl HashStable for ByteSymbol { #[inline] - fn hash_stable(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { - self.as_byte_str().hash_stable(hcx, hasher); + fn stable_hash(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { + self.as_byte_str().stable_hash(hcx, hasher); } } diff --git a/compiler/rustc_symbol_mangling/src/hashed.rs b/compiler/rustc_symbol_mangling/src/hashed.rs index e965e6a7d53aa..709bbf4cbe8b3 100644 --- a/compiler/rustc_symbol_mangling/src/hashed.rs +++ b/compiler/rustc_symbol_mangling/src/hashed.rs @@ -27,7 +27,7 @@ pub(super) fn mangle<'tcx>( let hash = tcx.with_stable_hashing_context(|mut hcx| { let mut hasher = StableHasher::new(); - full_mangling_name().hash_stable(&mut hcx, &mut hasher); + full_mangling_name().stable_hash(&mut hcx, &mut hasher); hasher.finish::().as_u64() }); diff --git a/compiler/rustc_symbol_mangling/src/legacy.rs b/compiler/rustc_symbol_mangling/src/legacy.rs index b574ca2186a9f..2c5c8a4d237b9 100644 --- a/compiler/rustc_symbol_mangling/src/legacy.rs +++ b/compiler/rustc_symbol_mangling/src/legacy.rs @@ -136,33 +136,33 @@ fn get_symbol_hash<'tcx>( // the main symbol name is not necessarily unique; hash in the // compiler's internal def-path, guaranteeing each symbol has a // truly unique path - tcx.def_path_hash(def_id).hash_stable(&mut hcx, &mut hasher); + tcx.def_path_hash(def_id).stable_hash(&mut hcx, &mut hasher); // Include the main item-type. Note that, in this case, the // assertions about `has_param` may not hold, but this item-type // ought to be the same for every reference anyway. assert!(!item_type.has_erasable_regions()); hcx.while_hashing_spans(false, |hcx| { - item_type.hash_stable(hcx, &mut hasher); + item_type.stable_hash(hcx, &mut hasher); // If this is a function, we hash the signature as well. // This is not *strictly* needed, but it may help in some // situations, see the `run-make/a-b-a-linker-guard` test. if let ty::FnDef(..) = item_type.kind() { - item_type.fn_sig(tcx).hash_stable(hcx, &mut hasher); + item_type.fn_sig(tcx).stable_hash(hcx, &mut hasher); } // also include any type parameters (for generic items) - args.hash_stable(hcx, &mut hasher); + args.stable_hash(hcx, &mut hasher); if let Some(instantiating_crate) = instantiating_crate { - tcx.stable_crate_id(instantiating_crate).hash_stable(hcx, &mut hasher); + tcx.stable_crate_id(instantiating_crate).stable_hash(hcx, &mut hasher); } // We want to avoid accidental collision between different types of instances. // Especially, `VTableShim`s and `ReifyShim`s may overlap with their original // instances without this. - discriminant(&instance.def).hash_stable(hcx, &mut hasher); + discriminant(&instance.def).stable_hash(hcx, &mut hasher); }); // 64 bits should be enough to avoid collisions. diff --git a/compiler/rustc_type_ir/src/const_kind.rs b/compiler/rustc_type_ir/src/const_kind.rs index 302f9df4066b4..1261362c4d278 100644 --- a/compiler/rustc_type_ir/src/const_kind.rs +++ b/compiler/rustc_type_ir/src/const_kind.rs @@ -118,12 +118,12 @@ impl fmt::Debug for InferConst { #[cfg(feature = "nightly")] impl HashStable for InferConst { - fn hash_stable(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { + fn stable_hash(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { match self { InferConst::Var(_) => { panic!("const variables should not be hashed: {self:?}") } - InferConst::Fresh(i) => i.hash_stable(hcx, hasher), + InferConst::Fresh(i) => i.stable_hash(hcx, hasher), } } } diff --git a/compiler/rustc_type_ir/src/fast_reject.rs b/compiler/rustc_type_ir/src/fast_reject.rs index 453b51e2b7a21..f6a5e98d1c529 100644 --- a/compiler/rustc_type_ir/src/fast_reject.rs +++ b/compiler/rustc_type_ir/src/fast_reject.rs @@ -55,7 +55,7 @@ impl ToStableHashKey for SimplifiedType { #[inline] fn to_stable_hash_key(&self, hcx: &mut Hcx) -> Fingerprint { let mut hasher = StableHasher::new(); - self.hash_stable(hcx, &mut hasher); + self.stable_hash(hcx, &mut hasher); hasher.finish() } } diff --git a/compiler/rustc_type_ir/src/region_kind.rs b/compiler/rustc_type_ir/src/region_kind.rs index b930fede993a7..fbe58d2839ada 100644 --- a/compiler/rustc_type_ir/src/region_kind.rs +++ b/compiler/rustc_type_ir/src/region_kind.rs @@ -225,24 +225,24 @@ where I::Symbol: HashStable, { #[inline] - fn hash_stable(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { - std::mem::discriminant(self).hash_stable(hcx, hasher); + fn stable_hash(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { + std::mem::discriminant(self).stable_hash(hcx, hasher); match self { ReErased | ReStatic | ReError(_) => { // No variant fields to hash for these ... } ReBound(d, r) => { - d.hash_stable(hcx, hasher); - r.hash_stable(hcx, hasher); + d.stable_hash(hcx, hasher); + r.stable_hash(hcx, hasher); } ReEarlyParam(r) => { - r.hash_stable(hcx, hasher); + r.stable_hash(hcx, hasher); } ReLateParam(r) => { - r.hash_stable(hcx, hasher); + r.stable_hash(hcx, hasher); } RePlaceholder(r) => { - r.hash_stable(hcx, hasher); + r.stable_hash(hcx, hasher); } ReVar(_) => { panic!("region variables should not be hashed: {self:?}") diff --git a/compiler/rustc_type_ir/src/ty_info.rs b/compiler/rustc_type_ir/src/ty_info.rs index 55eac7ddc83dd..7a596538a6d64 100644 --- a/compiler/rustc_type_ir/src/ty_info.rs +++ b/compiler/rustc_type_ir/src/ty_info.rs @@ -84,7 +84,7 @@ impl Hash for WithCachedTypeInfo { #[cfg(feature = "nightly")] impl HashStable for WithCachedTypeInfo { - fn hash_stable(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { - self.internee.hash_stable(hcx, hasher); + fn stable_hash(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { + self.internee.stable_hash(hcx, hasher); } } diff --git a/compiler/rustc_type_ir/src/ty_kind.rs b/compiler/rustc_type_ir/src/ty_kind.rs index c5078115870c4..688aa5f540193 100644 --- a/compiler/rustc_type_ir/src/ty_kind.rs +++ b/compiler/rustc_type_ir/src/ty_kind.rs @@ -708,14 +708,14 @@ impl UnifyKey for FloatVid { #[cfg(feature = "nightly")] impl HashStable for InferTy { - fn hash_stable(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { + fn stable_hash(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { use InferTy::*; - std::mem::discriminant(self).hash_stable(hcx, hasher); + std::mem::discriminant(self).stable_hash(hcx, hasher); match self { TyVar(_) | IntVar(_) | FloatVar(_) => { panic!("type variables should not be hashed: {self:?}") } - FreshTy(v) | FreshIntTy(v) | FreshFloatTy(v) => v.hash_stable(hcx, hasher), + FreshTy(v) | FreshIntTy(v) | FreshFloatTy(v) => v.stable_hash(hcx, hasher), } } } From 846267e725e35c058437d4ab4324cab2063ece9e Mon Sep 17 00:00:00 2001 From: Nicholas Nethercote Date: Fri, 1 May 2026 09:39:23 +1000 Subject: [PATCH 16/17] Rename the `HashStableContext` trait as `StableHashCtxt`. Part of MCP 983. --- compiler/rustc_abi/src/extern_abi.rs | 6 +- compiler/rustc_ast/src/ast.rs | 4 +- compiler/rustc_ast/src/node_id.rs | 4 +- compiler/rustc_ast/src/tokenstream.rs | 6 +- .../rustc_codegen_cranelift/src/driver/aot.rs | 4 +- compiler/rustc_codegen_ssa/src/common.rs | 4 +- compiler/rustc_data_structures/src/intern.rs | 4 +- compiler/rustc_data_structures/src/packed.rs | 4 +- .../rustc_data_structures/src/sorted_map.rs | 4 +- .../src/stable_hasher.rs | 78 +++++++++---------- .../src/stable_hasher/tests.rs | 4 +- compiler/rustc_data_structures/src/steal.rs | 4 +- .../rustc_data_structures/src/tagged_ptr.rs | 4 +- .../src/tagged_ptr/tests.rs | 2 +- compiler/rustc_data_structures/src/unord.rs | 26 +++---- compiler/rustc_feature/src/unstable.rs | 8 +- compiler/rustc_hir/src/lang_items.rs | 4 +- compiler/rustc_hir/src/stable_hash_impls.rs | 21 +++-- compiler/rustc_hir_id/src/lib.rs | 11 +-- compiler/rustc_index_macros/src/newtype.rs | 2 +- compiler/rustc_lint_defs/src/lib.rs | 8 +- compiler/rustc_macros/src/hash_stable.rs | 2 +- compiler/rustc_middle/src/hir/mod.rs | 4 +- compiler/rustc_middle/src/ich.rs | 6 +- compiler/rustc_middle/src/middle/privacy.rs | 4 +- compiler/rustc_middle/src/mir/basic_blocks.rs | 4 +- compiler/rustc_middle/src/mono.rs | 4 +- compiler/rustc_middle/src/ty/adt.rs | 4 +- compiler/rustc_middle/src/ty/consts/int.rs | 4 +- compiler/rustc_middle/src/ty/impls_ty.rs | 12 +-- compiler/rustc_middle/src/ty/mod.rs | 4 +- compiler/rustc_span/src/def_id.rs | 15 ++-- compiler/rustc_span/src/hygiene.rs | 18 ++--- compiler/rustc_span/src/lib.rs | 4 +- compiler/rustc_span/src/symbol.rs | 6 +- compiler/rustc_type_ir/src/const_kind.rs | 4 +- compiler/rustc_type_ir/src/fast_reject.rs | 4 +- compiler/rustc_type_ir/src/region_kind.rs | 4 +- compiler/rustc_type_ir/src/solve/mod.rs | 2 +- compiler/rustc_type_ir/src/ty_info.rs | 4 +- compiler/rustc_type_ir/src/ty_kind.rs | 4 +- 41 files changed, 156 insertions(+), 169 deletions(-) diff --git a/compiler/rustc_abi/src/extern_abi.rs b/compiler/rustc_abi/src/extern_abi.rs index 12940d8cfe078..28066d11b226f 100644 --- a/compiler/rustc_abi/src/extern_abi.rs +++ b/compiler/rustc_abi/src/extern_abi.rs @@ -3,9 +3,7 @@ use std::fmt; use std::hash::{Hash, Hasher}; #[cfg(feature = "nightly")] -use rustc_data_structures::stable_hasher::{ - HashStable, HashStableContext, StableHasher, StableOrd, -}; +use rustc_data_structures::stable_hasher::{HashStable, StableHashCtxt, StableHasher, StableOrd}; #[cfg(feature = "nightly")] use rustc_macros::{Decodable, Encodable}; #[cfg(feature = "nightly")] @@ -244,7 +242,7 @@ impl Hash for ExternAbi { #[cfg(feature = "nightly")] impl HashStable for ExternAbi { #[inline] - fn stable_hash(&self, _: &mut Hcx, hasher: &mut StableHasher) { + fn stable_hash(&self, _: &mut Hcx, hasher: &mut StableHasher) { Hash::hash(self, hasher); } } diff --git a/compiler/rustc_ast/src/ast.rs b/compiler/rustc_ast/src/ast.rs index d650ec49b8124..490e38ca729e9 100644 --- a/compiler/rustc_ast/src/ast.rs +++ b/compiler/rustc_ast/src/ast.rs @@ -25,7 +25,7 @@ pub use GenericArgs::*; pub use UnsafeSource::*; pub use rustc_ast_ir::{FloatTy, IntTy, Movability, Mutability, Pinnedness, UintTy}; use rustc_data_structures::packed::Pu128; -use rustc_data_structures::stable_hasher::{HashStable, HashStableContext, StableHasher}; +use rustc_data_structures::stable_hasher::{HashStable, StableHashCtxt, StableHasher}; use rustc_data_structures::stack::ensure_sufficient_stack; use rustc_data_structures::tagged_ptr::Tag; use rustc_macros::{Decodable, Encodable, HashStable, Walkable}; @@ -121,7 +121,7 @@ impl PartialEq<&[Symbol]> for Path { } impl HashStable for Path { - fn stable_hash(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { + fn stable_hash(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { self.segments.len().stable_hash(hcx, hasher); for segment in &self.segments { segment.ident.stable_hash(hcx, hasher); diff --git a/compiler/rustc_ast/src/node_id.rs b/compiler/rustc_ast/src/node_id.rs index 170897ebe1f4d..a23bf268852ee 100644 --- a/compiler/rustc_ast/src/node_id.rs +++ b/compiler/rustc_ast/src/node_id.rs @@ -1,6 +1,6 @@ use std::fmt; -use rustc_data_structures::stable_hasher::{HashStable, HashStableContext, StableHasher}; +use rustc_data_structures::stable_hasher::{HashStable, StableHashCtxt, StableHasher}; use rustc_span::LocalExpnId; rustc_index::newtype_index! { @@ -21,7 +21,7 @@ rustc_index::newtype_index! { impl HashStable for NodeId { #[inline] - fn stable_hash(&self, _: &mut Hcx, _: &mut StableHasher) { + fn stable_hash(&self, _: &mut Hcx, _: &mut StableHasher) { // This impl is never called but is necessary for types implementing `HashStable` such as // `MainDefinition` and `DocLinkResMap` (both of which occur in `ResolverGlobalCtxt`). panic!("Node IDs should not appear in incremental state"); diff --git a/compiler/rustc_ast/src/tokenstream.rs b/compiler/rustc_ast/src/tokenstream.rs index 6d22bcbe6fc4b..c534b2b1c590f 100644 --- a/compiler/rustc_ast/src/tokenstream.rs +++ b/compiler/rustc_ast/src/tokenstream.rs @@ -10,7 +10,7 @@ use std::ops::Range; use std::sync::Arc; use std::{cmp, fmt, iter, mem}; -use rustc_data_structures::stable_hasher::{HashStable, HashStableContext, StableHasher}; +use rustc_data_structures::stable_hasher::{HashStable, StableHashCtxt, StableHasher}; use rustc_data_structures::sync; use rustc_macros::{Decodable, Encodable, HashStable, Walkable}; use rustc_serialize::{Decodable, Encodable}; @@ -139,7 +139,7 @@ impl Decodable for LazyAttrTokenStream { } impl HashStable for LazyAttrTokenStream { - fn stable_hash(&self, _hcx: &mut Hcx, _hasher: &mut StableHasher) { + fn stable_hash(&self, _hcx: &mut Hcx, _hasher: &mut StableHasher) { panic!("Attempted to compute stable hash for LazyAttrTokenStream"); } } @@ -825,7 +825,7 @@ impl FromIterator for TokenStream { } impl HashStable for TokenStream { - fn stable_hash(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { + fn stable_hash(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { for sub_tt in self.iter() { sub_tt.stable_hash(hcx, hasher); } diff --git a/compiler/rustc_codegen_cranelift/src/driver/aot.rs b/compiler/rustc_codegen_cranelift/src/driver/aot.rs index a8059187a1d2e..60ad076672713 100644 --- a/compiler/rustc_codegen_cranelift/src/driver/aot.rs +++ b/compiler/rustc_codegen_cranelift/src/driver/aot.rs @@ -14,7 +14,7 @@ use rustc_codegen_ssa::back::write::produce_final_output_artifacts; use rustc_codegen_ssa::base::determine_cgu_reuse; use rustc_codegen_ssa::{CompiledModule, CompiledModules, ModuleKind}; use rustc_data_structures::profiling::SelfProfilerRef; -use rustc_data_structures::stable_hasher::{HashStable, HashStableContext, StableHasher}; +use rustc_data_structures::stable_hasher::{HashStable, StableHashCtxt, StableHasher}; use rustc_data_structures::sync::{IntoDynSyncSend, par_map}; use rustc_hir::attrs::Linkage as RLinkage; use rustc_middle::dep_graph::{WorkProduct, WorkProductId}; @@ -46,7 +46,7 @@ enum OngoingModuleCodegen { } impl HashStable for OngoingModuleCodegen { - fn stable_hash(&self, _: &mut Hcx, _: &mut StableHasher) { + fn stable_hash(&self, _: &mut Hcx, _: &mut StableHasher) { // do nothing } } diff --git a/compiler/rustc_codegen_ssa/src/common.rs b/compiler/rustc_codegen_ssa/src/common.rs index 81c095cbf4af8..a900e92a82930 100644 --- a/compiler/rustc_codegen_ssa/src/common.rs +++ b/compiler/rustc_codegen_ssa/src/common.rs @@ -98,12 +98,12 @@ pub enum TypeKind { // for now we content ourselves with providing a no-op HashStable // implementation for CGUs. mod temp_stable_hash_impls { - use rustc_data_structures::stable_hasher::{HashStable, HashStableContext, StableHasher}; + use rustc_data_structures::stable_hasher::{HashStable, StableHashCtxt, StableHasher}; use crate::ModuleCodegen; impl HashStable for ModuleCodegen { - fn stable_hash(&self, _: &mut Hcx, _: &mut StableHasher) { + fn stable_hash(&self, _: &mut Hcx, _: &mut StableHasher) { // do nothing } } diff --git a/compiler/rustc_data_structures/src/intern.rs b/compiler/rustc_data_structures/src/intern.rs index 21706a11fbe02..2d9ab50094752 100644 --- a/compiler/rustc_data_structures/src/intern.rs +++ b/compiler/rustc_data_structures/src/intern.rs @@ -4,7 +4,7 @@ use std::hash::{Hash, Hasher}; use std::ops::Deref; use std::ptr; -use crate::stable_hasher::{HashStable, HashStableContext, StableHasher}; +use crate::stable_hasher::{HashStable, StableHashCtxt, StableHasher}; mod private { #[derive(Clone, Copy, Debug)] @@ -107,7 +107,7 @@ impl HashStable for Interned<'_, T> where T: HashStable, { - fn stable_hash(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { + fn stable_hash(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { self.0.stable_hash(hcx, hasher); } } diff --git a/compiler/rustc_data_structures/src/packed.rs b/compiler/rustc_data_structures/src/packed.rs index 9220b87ffe8cc..1e15eb13c74f6 100644 --- a/compiler/rustc_data_structures/src/packed.rs +++ b/compiler/rustc_data_structures/src/packed.rs @@ -3,7 +3,7 @@ use std::fmt; use rustc_serialize::{Decodable, Decoder, Encodable, Encoder}; -use crate::stable_hasher::{HashStable, HashStableContext, StableHasher}; +use crate::stable_hasher::{HashStable, StableHashCtxt, StableHasher}; /// A packed 128-bit integer. Useful for reducing the size of structures in /// some cases. @@ -62,7 +62,7 @@ impl fmt::UpperHex for Pu128 { impl HashStable for Pu128 { #[inline] - fn stable_hash(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { + fn stable_hash(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { { self.0 }.stable_hash(hcx, hasher) } } diff --git a/compiler/rustc_data_structures/src/sorted_map.rs b/compiler/rustc_data_structures/src/sorted_map.rs index 1b0f9380b347e..53ff5877627a4 100644 --- a/compiler/rustc_data_structures/src/sorted_map.rs +++ b/compiler/rustc_data_structures/src/sorted_map.rs @@ -7,7 +7,7 @@ use std::ops::{Bound, Index, IndexMut, RangeBounds}; use rustc_macros::{Decodable_NoContext, Encodable_NoContext}; -use crate::stable_hasher::{HashStable, HashStableContext, StableHasher, StableOrd}; +use crate::stable_hasher::{HashStable, StableHashCtxt, StableHasher, StableOrd}; mod index_map; @@ -349,7 +349,7 @@ impl FromIterator<(K, V)> for SortedMap { impl HashStable for SortedMap { #[inline] - fn stable_hash(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { + fn stable_hash(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { self.data.stable_hash(hcx, hasher); } } diff --git a/compiler/rustc_data_structures/src/stable_hasher.rs b/compiler/rustc_data_structures/src/stable_hasher.rs index 671cddde185b9..c62553a40a3c9 100644 --- a/compiler/rustc_data_structures/src/stable_hasher.rs +++ b/compiler/rustc_data_structures/src/stable_hasher.rs @@ -19,7 +19,7 @@ pub use rustc_stable_hash::{ /// this crate (and other crates upstream of `rustc_middle`), while leaving /// certain operations to be defined in `rustc_middle` where more things are /// visible. -pub trait HashStableContext { +pub trait StableHashCtxt { /// The main event: stable hashing of a span. fn span_hash_stable(&mut self, span: RawSpan, hasher: &mut StableHasher); @@ -29,7 +29,7 @@ pub trait HashStableContext { /// Get the hashing controls. fn hashing_controls(&self) -> HashingControls; - /// Assert that the provided `HashStableContext` is configured with the default + /// Assert that the provided `StableHashCtxt` is configured with the default /// `HashingControls`. We should always have bailed out before getting to here with a fn assert_default_hashing_controls(&self, msg: &str); } @@ -73,7 +73,7 @@ pub struct RawDefPathHash(pub [u8; 16]); /// `StableHasher` takes care of endianness and `isize`/`usize` platform /// differences. pub trait HashStable { - fn stable_hash(&self, hcx: &mut Hcx, hasher: &mut StableHasher); + fn stable_hash(&self, hcx: &mut Hcx, hasher: &mut StableHasher); } /// Implement this for types that can be turned into stable keys like, for @@ -81,7 +81,7 @@ pub trait HashStable { /// bringing maps into a predictable order before hashing them. pub trait ToStableHashKey { type KeyType: Ord + Sized + HashStable; - fn to_stable_hash_key(&self, hcx: &mut Hcx) -> Self::KeyType; + fn to_stable_hash_key(&self, hcx: &mut Hcx) -> Self::KeyType; } /// Trait for marking a type as having a sort order that is @@ -239,27 +239,27 @@ impl HashStable for PhantomData { impl HashStable for NonZero { #[inline] - fn stable_hash(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { + fn stable_hash(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { self.get().stable_hash(hcx, hasher) } } impl HashStable for NonZero { #[inline] - fn stable_hash(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { + fn stable_hash(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { self.get().stable_hash(hcx, hasher) } } impl HashStable for f32 { - fn stable_hash(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { + fn stable_hash(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { let val: u32 = self.to_bits(); val.stable_hash(hcx, hasher); } } impl HashStable for f64 { - fn stable_hash(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { + fn stable_hash(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { let val: u64 = self.to_bits(); val.stable_hash(hcx, hasher); } @@ -267,21 +267,21 @@ impl HashStable for f64 { impl HashStable for ::std::cmp::Ordering { #[inline] - fn stable_hash(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { + fn stable_hash(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { (*self as i8).stable_hash(hcx, hasher); } } impl HashStable for (T1,) { #[inline] - fn stable_hash(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { + fn stable_hash(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { let (ref _0,) = *self; _0.stable_hash(hcx, hasher); } } impl HashStable for (T1, T2) { - fn stable_hash(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { + fn stable_hash(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { let (ref _0, ref _1) = *self; _0.stable_hash(hcx, hasher); _1.stable_hash(hcx, hasher); @@ -302,7 +302,7 @@ where T2: HashStable, T3: HashStable, { - fn stable_hash(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { + fn stable_hash(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { let (ref _0, ref _1, ref _2) = *self; _0.stable_hash(hcx, hasher); _1.stable_hash(hcx, hasher); @@ -326,7 +326,7 @@ where T3: HashStable, T4: HashStable, { - fn stable_hash(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { + fn stable_hash(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { let (ref _0, ref _1, ref _2, ref _3) = *self; _0.stable_hash(hcx, hasher); _1.stable_hash(hcx, hasher); @@ -347,11 +347,7 @@ impl StableOrd for ( } impl HashStable for [T] { - default fn stable_hash( - &self, - hcx: &mut Hcx, - hasher: &mut StableHasher, - ) { + default fn stable_hash(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { self.len().stable_hash(hcx, hasher); for item in self { item.stable_hash(hcx, hasher); @@ -360,7 +356,7 @@ impl HashStable for [T] { } impl HashStable for [u8] { - fn stable_hash(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { + fn stable_hash(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { self.len().stable_hash(hcx, hasher); hasher.write(self); } @@ -368,7 +364,7 @@ impl HashStable for [u8] { impl HashStable for Vec { #[inline] - fn stable_hash(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { + fn stable_hash(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { self[..].stable_hash(hcx, hasher); } } @@ -380,7 +376,7 @@ where R: BuildHasher, { #[inline] - fn stable_hash(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { + fn stable_hash(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { self.len().stable_hash(hcx, hasher); for kv in self { kv.stable_hash(hcx, hasher); @@ -394,7 +390,7 @@ where R: BuildHasher, { #[inline] - fn stable_hash(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { + fn stable_hash(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { self.len().stable_hash(hcx, hasher); for key in self { key.stable_hash(hcx, hasher); @@ -407,35 +403,35 @@ where A: HashStable, { #[inline] - fn stable_hash(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { + fn stable_hash(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { self[..].stable_hash(hcx, hasher); } } impl HashStable for Box { #[inline] - fn stable_hash(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { + fn stable_hash(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { (**self).stable_hash(hcx, hasher); } } impl HashStable for ::std::rc::Rc { #[inline] - fn stable_hash(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { + fn stable_hash(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { (**self).stable_hash(hcx, hasher); } } impl HashStable for ::std::sync::Arc { #[inline] - fn stable_hash(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { + fn stable_hash(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { (**self).stable_hash(hcx, hasher); } } impl HashStable for str { #[inline] - fn stable_hash(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { + fn stable_hash(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { self.as_bytes().stable_hash(hcx, hasher); } } @@ -450,7 +446,7 @@ impl StableOrd for &str { impl HashStable for String { #[inline] - fn stable_hash(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { + fn stable_hash(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { self[..].stable_hash(hcx, hasher); } } @@ -474,14 +470,14 @@ impl ToStableHashKey for String { impl ToStableHashKey for (T1, T2) { type KeyType = (T1::KeyType, T2::KeyType); #[inline] - fn to_stable_hash_key(&self, hcx: &mut Hcx) -> Self::KeyType { + fn to_stable_hash_key(&self, hcx: &mut Hcx) -> Self::KeyType { (self.0.to_stable_hash_key(hcx), self.1.to_stable_hash_key(hcx)) } } impl HashStable for bool { #[inline] - fn stable_hash(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { + fn stable_hash(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { (if *self { 1u8 } else { 0u8 }).stable_hash(hcx, hasher); } } @@ -498,7 +494,7 @@ where T: HashStable, { #[inline] - fn stable_hash(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { + fn stable_hash(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { if let Some(ref value) = *self { 1u8.stable_hash(hcx, hasher); value.stable_hash(hcx, hasher); @@ -521,7 +517,7 @@ where T2: HashStable, { #[inline] - fn stable_hash(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { + fn stable_hash(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { mem::discriminant(self).stable_hash(hcx, hasher); match *self { Ok(ref x) => x.stable_hash(hcx, hasher), @@ -535,14 +531,14 @@ where T: HashStable + ?Sized, { #[inline] - fn stable_hash(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { + fn stable_hash(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { (**self).stable_hash(hcx, hasher); } } impl HashStable for ::std::mem::Discriminant { #[inline] - fn stable_hash(&self, _: &mut Hcx, hasher: &mut StableHasher) { + fn stable_hash(&self, _: &mut Hcx, hasher: &mut StableHasher) { ::std::hash::Hash::hash(self, hasher); } } @@ -552,7 +548,7 @@ where T: HashStable, { #[inline] - fn stable_hash(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { + fn stable_hash(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { self.start().stable_hash(hcx, hasher); self.end().stable_hash(hcx, hasher); } @@ -562,7 +558,7 @@ impl HashStable for IndexSlice where T: HashStable, { - fn stable_hash(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { + fn stable_hash(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { self.len().stable_hash(hcx, hasher); for v in &self.raw { v.stable_hash(hcx, hasher); @@ -574,7 +570,7 @@ impl HashStable for IndexVec where T: HashStable, { - fn stable_hash(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { + fn stable_hash(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { self.len().stable_hash(hcx, hasher); for v in &self.raw { v.stable_hash(hcx, hasher); @@ -583,13 +579,13 @@ where } impl HashStable for DenseBitSet { - fn stable_hash(&self, _hcx: &mut Hcx, hasher: &mut StableHasher) { + fn stable_hash(&self, _hcx: &mut Hcx, hasher: &mut StableHasher) { ::std::hash::Hash::hash(self, hasher); } } impl HashStable for bit_set::BitMatrix { - fn stable_hash(&self, _hcx: &mut Hcx, hasher: &mut StableHasher) { + fn stable_hash(&self, _hcx: &mut Hcx, hasher: &mut StableHasher) { ::std::hash::Hash::hash(self, hasher); } } @@ -610,7 +606,7 @@ where K: HashStable + StableOrd, V: HashStable, { - fn stable_hash(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { + fn stable_hash(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { self.len().stable_hash(hcx, hasher); for entry in self.iter() { entry.stable_hash(hcx, hasher); @@ -622,7 +618,7 @@ impl HashStable for ::std::collections::BTreeSet where K: HashStable + StableOrd, { - fn stable_hash(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { + fn stable_hash(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { self.len().stable_hash(hcx, hasher); for entry in self.iter() { entry.stable_hash(hcx, hasher); diff --git a/compiler/rustc_data_structures/src/stable_hasher/tests.rs b/compiler/rustc_data_structures/src/stable_hasher/tests.rs index 246d9a1169f4c..aa76b3a7c57b7 100644 --- a/compiler/rustc_data_structures/src/stable_hasher/tests.rs +++ b/compiler/rustc_data_structures/src/stable_hasher/tests.rs @@ -7,7 +7,7 @@ use super::*; // ways). The expected values depend on the hashing algorithm used, so they // need to be updated whenever StableHasher changes its hashing algorithm. -impl HashStableContext for () { +impl StableHashCtxt for () { fn span_hash_stable(&mut self, _: RawSpan, _: &mut StableHasher) { panic!(); } @@ -60,7 +60,7 @@ fn test_attribute_permutation() { } impl HashStable for Foo { - fn stable_hash( + fn stable_hash( &self, hcx: &mut Hcx, hasher: &mut StableHasher, diff --git a/compiler/rustc_data_structures/src/steal.rs b/compiler/rustc_data_structures/src/steal.rs index 757d8bf281c50..eeb5f677a29f5 100644 --- a/compiler/rustc_data_structures/src/steal.rs +++ b/compiler/rustc_data_structures/src/steal.rs @@ -1,4 +1,4 @@ -use crate::stable_hasher::{HashStable, HashStableContext, StableHasher}; +use crate::stable_hasher::{HashStable, StableHashCtxt, StableHasher}; use crate::sync::{MappedReadGuard, MappedWriteGuard, ReadGuard, RwLock, WriteGuard}; /// The `Steal` struct is intended to used as the value for a query. @@ -72,7 +72,7 @@ impl Steal { } impl HashStable for Steal { - fn stable_hash(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { + fn stable_hash(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { self.borrow().stable_hash(hcx, hasher); } } diff --git a/compiler/rustc_data_structures/src/tagged_ptr.rs b/compiler/rustc_data_structures/src/tagged_ptr.rs index abe01b08e0f0d..f45a048f2babd 100644 --- a/compiler/rustc_data_structures/src/tagged_ptr.rs +++ b/compiler/rustc_data_structures/src/tagged_ptr.rs @@ -12,7 +12,7 @@ use std::ops::Deref; use std::ptr::NonNull; use crate::aligned::Aligned; -use crate::stable_hasher::{HashStable, HashStableContext, StableHasher}; +use crate::stable_hasher::{HashStable, StableHashCtxt, StableHasher}; /// This describes tags that the [`TaggedRef`] struct can hold. /// @@ -264,7 +264,7 @@ where P: HashStable + Aligned + ?Sized, T: Tag + HashStable, { - fn stable_hash(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { + fn stable_hash(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { self.pointer().stable_hash(hcx, hasher); self.tag().stable_hash(hcx, hasher); } diff --git a/compiler/rustc_data_structures/src/tagged_ptr/tests.rs b/compiler/rustc_data_structures/src/tagged_ptr/tests.rs index af41970886913..8c1dccc538e3c 100644 --- a/compiler/rustc_data_structures/src/tagged_ptr/tests.rs +++ b/compiler/rustc_data_structures/src/tagged_ptr/tests.rs @@ -33,7 +33,7 @@ unsafe impl Tag for Tag2 { } impl HashStable for Tag2 { - fn stable_hash( + fn stable_hash( &self, hcx: &mut Hcx, hasher: &mut crate::stable_hasher::StableHasher, diff --git a/compiler/rustc_data_structures/src/unord.rs b/compiler/rustc_data_structures/src/unord.rs index 9249a742ae2f5..1a312d2591477 100644 --- a/compiler/rustc_data_structures/src/unord.rs +++ b/compiler/rustc_data_structures/src/unord.rs @@ -13,7 +13,7 @@ use rustc_macros::{Decodable_NoContext, Encodable_NoContext}; use crate::fingerprint::Fingerprint; use crate::fx::{FxBuildHasher, FxHashMap, FxHashSet}; use crate::stable_hasher::{ - HashStable, HashStableContext, StableCompare, StableHasher, ToStableHashKey, + HashStable, StableCompare, StableHashCtxt, StableHasher, ToStableHashKey, }; /// `UnordItems` is the order-less version of `Iterator`. It only contains methods @@ -145,7 +145,7 @@ impl<'a, T: Copy + 'a, I: Iterator> UnordItems<&'a T, I> { impl> UnordItems { #[inline] - pub fn into_sorted(self, hcx: &mut Hcx) -> Vec + pub fn into_sorted(self, hcx: &mut Hcx) -> Vec where T: ToStableHashKey, { @@ -172,7 +172,7 @@ impl> UnordItems { #[inline] pub fn collect_sorted(self, hcx: &mut Hcx, cache_sort_key: bool) -> C where - Hcx: HashStableContext, + Hcx: StableHashCtxt, T: ToStableHashKey, C: FromIterator + BorrowMut<[T]>, { @@ -320,7 +320,7 @@ impl UnordSet { #[inline] pub fn to_sorted(&self, hcx: &mut Hcx, cache_sort_key: bool) -> Vec<&V> where - Hcx: HashStableContext, + Hcx: StableHashCtxt, V: ToStableHashKey, { to_sorted_vec(hcx, self.inner.iter(), cache_sort_key, |&x| x) @@ -363,7 +363,7 @@ impl UnordSet { #[inline] pub fn into_sorted(self, hcx: &mut Hcx, cache_sort_key: bool) -> Vec where - Hcx: HashStableContext, + Hcx: StableHashCtxt, V: ToStableHashKey, { to_sorted_vec(hcx, self.inner.into_iter(), cache_sort_key, |x| x) @@ -422,7 +422,7 @@ impl> From> for UnordSet impl HashStable for UnordSet { #[inline] - fn stable_hash(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { + fn stable_hash(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { hash_iter_order_independent(self.inner.iter(), hcx, hasher); } } @@ -562,7 +562,7 @@ impl UnordMap { #[inline] pub fn to_sorted(&self, hcx: &mut Hcx, cache_sort_key: bool) -> Vec<(&K, &V)> where - Hcx: HashStableContext, + Hcx: StableHashCtxt, K: ToStableHashKey, { to_sorted_vec(hcx, self.inner.iter(), cache_sort_key, |&(k, _)| k) @@ -590,7 +590,7 @@ impl UnordMap { #[inline] pub fn into_sorted(self, hcx: &mut Hcx, cache_sort_key: bool) -> Vec<(K, V)> where - Hcx: HashStableContext, + Hcx: StableHashCtxt, K: ToStableHashKey, { to_sorted_vec(hcx, self.inner.into_iter(), cache_sort_key, |(k, _)| k) @@ -623,7 +623,7 @@ impl UnordMap { cache_sort_key: bool, ) -> impl Iterator where - Hcx: HashStableContext, + Hcx: StableHashCtxt, K: ToStableHashKey, { to_sorted_vec(hcx, self.inner.iter(), cache_sort_key, |&(k, _)| k) @@ -652,7 +652,7 @@ where impl HashStable for UnordMap { #[inline] - fn stable_hash(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { + fn stable_hash(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { hash_iter_order_independent(self.inner.iter(), hcx, hasher); } } @@ -715,7 +715,7 @@ impl> From> for UnordBag { impl HashStable for UnordBag { #[inline] - fn stable_hash(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { + fn stable_hash(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { hash_iter_order_independent(self.inner.iter(), hcx, hasher); } } @@ -728,7 +728,7 @@ fn to_sorted_vec( extract_key: fn(&T) -> &K, ) -> Vec where - Hcx: HashStableContext, + Hcx: StableHashCtxt, I: Iterator, K: ToStableHashKey, { @@ -743,7 +743,7 @@ where } fn hash_iter_order_independent< - Hcx: HashStableContext, + Hcx: StableHashCtxt, T: HashStable, I: Iterator + ExactSizeIterator, >( diff --git a/compiler/rustc_feature/src/unstable.rs b/compiler/rustc_feature/src/unstable.rs index 373a6437e5fcf..dacefe4c5d3f1 100644 --- a/compiler/rustc_feature/src/unstable.rs +++ b/compiler/rustc_feature/src/unstable.rs @@ -5,7 +5,7 @@ use std::time::{SystemTime, UNIX_EPOCH}; use rustc_data_structures::AtomicRef; use rustc_data_structures::fx::FxHashSet; -use rustc_data_structures::stable_hasher::{HashStable, HashStableContext, StableHasher}; +use rustc_data_structures::stable_hasher::{HashStable, StableHashCtxt, StableHasher}; use rustc_span::{Span, Symbol, sym}; use super::{Feature, to_nonzero}; @@ -121,7 +121,7 @@ impl Features { } impl HashStable for Features { - fn stable_hash(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { + fn stable_hash(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { // `enabled_features` is skipped because it's the sum of the lang and lib features. let Features { enabled_lang_features, enabled_lib_features, enabled_features: _ } = self; enabled_lang_features.stable_hash(hcx, hasher); @@ -130,7 +130,7 @@ impl HashStable for Features { } impl HashStable for EnabledLangFeature { - fn stable_hash(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { + fn stable_hash(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { let EnabledLangFeature { gate_name, attr_sp, stable_since } = self; gate_name.stable_hash(hcx, hasher); attr_sp.stable_hash(hcx, hasher); @@ -139,7 +139,7 @@ impl HashStable for EnabledLangFeature { } impl HashStable for EnabledLibFeature { - fn stable_hash(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { + fn stable_hash(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { let EnabledLibFeature { gate_name, attr_sp } = self; gate_name.stable_hash(hcx, hasher); attr_sp.stable_hash(hcx, hasher); diff --git a/compiler/rustc_hir/src/lang_items.rs b/compiler/rustc_hir/src/lang_items.rs index f35973d16271b..2eadd64cc6a67 100644 --- a/compiler/rustc_hir/src/lang_items.rs +++ b/compiler/rustc_hir/src/lang_items.rs @@ -8,7 +8,7 @@ //! * Functions called by the compiler itself. use rustc_data_structures::fx::FxIndexMap; -use rustc_data_structures::stable_hasher::{HashStable, HashStableContext, StableHasher}; +use rustc_data_structures::stable_hasher::{HashStable, StableHashCtxt, StableHasher}; use rustc_macros::{BlobDecodable, Encodable, HashStable, PrintAttribute}; use rustc_span::{Symbol, kw, sym}; @@ -145,7 +145,7 @@ macro_rules! language_item_table { } impl HashStable for LangItem { - fn stable_hash(&self, _: &mut Hcx, hasher: &mut StableHasher) { + fn stable_hash(&self, _: &mut Hcx, hasher: &mut StableHasher) { ::std::hash::Hash::hash(self, hasher); } } diff --git a/compiler/rustc_hir/src/stable_hash_impls.rs b/compiler/rustc_hir/src/stable_hash_impls.rs index 15b45bf921c77..31684e6d31613 100644 --- a/compiler/rustc_hir/src/stable_hash_impls.rs +++ b/compiler/rustc_hir/src/stable_hash_impls.rs @@ -1,5 +1,5 @@ use rustc_data_structures::stable_hasher::{ - HashStable, HashStableContext, StableHasher, ToStableHashKey, + HashStable, StableHashCtxt, StableHasher, ToStableHashKey, }; use rustc_span::def_id::DefPathHash; @@ -13,10 +13,7 @@ impl ToStableHashKey for BodyId { type KeyType = (DefPathHash, ItemLocalId); #[inline] - fn to_stable_hash_key( - &self, - hcx: &mut Hcx, - ) -> (DefPathHash, ItemLocalId) { + fn to_stable_hash_key(&self, hcx: &mut Hcx) -> (DefPathHash, ItemLocalId) { let BodyId { hir_id } = *self; hir_id.to_stable_hash_key(hcx) } @@ -26,7 +23,7 @@ impl ToStableHashKey for ItemId { type KeyType = DefPathHash; #[inline] - fn to_stable_hash_key(&self, hcx: &mut Hcx) -> DefPathHash { + fn to_stable_hash_key(&self, hcx: &mut Hcx) -> DefPathHash { self.owner_id.def_id.to_stable_hash_key(hcx) } } @@ -35,7 +32,7 @@ impl ToStableHashKey for TraitItemId { type KeyType = DefPathHash; #[inline] - fn to_stable_hash_key(&self, hcx: &mut Hcx) -> DefPathHash { + fn to_stable_hash_key(&self, hcx: &mut Hcx) -> DefPathHash { self.owner_id.def_id.to_stable_hash_key(hcx) } } @@ -44,7 +41,7 @@ impl ToStableHashKey for ImplItemId { type KeyType = DefPathHash; #[inline] - fn to_stable_hash_key(&self, hcx: &mut Hcx) -> DefPathHash { + fn to_stable_hash_key(&self, hcx: &mut Hcx) -> DefPathHash { self.owner_id.def_id.to_stable_hash_key(hcx) } } @@ -53,7 +50,7 @@ impl ToStableHashKey for ForeignItemId { type KeyType = DefPathHash; #[inline] - fn to_stable_hash_key(&self, hcx: &mut Hcx) -> DefPathHash { + fn to_stable_hash_key(&self, hcx: &mut Hcx) -> DefPathHash { self.owner_id.def_id.to_stable_hash_key(hcx) } } @@ -66,7 +63,7 @@ impl ToStableHashKey for ForeignItemId { // in "DefPath Mode". impl<'tcx> HashStable for OwnerNodes<'tcx> { - fn stable_hash(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { + fn stable_hash(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { // We ignore the `nodes` and `bodies` fields since these refer to information included in // `hash` which is hashed in the collector and used for the crate hash. // `local_id_to_def_id` is also ignored because is dependent on the body, then just hashing @@ -78,7 +75,7 @@ impl<'tcx> HashStable for OwnerNodes<'tcx> { } impl<'tcx> HashStable for AttributeMap<'tcx> { - fn stable_hash(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { + fn stable_hash(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { // We ignore the `map` since it refers to information included in `opt_hash` which is // hashed in the collector and used for the crate hash. let AttributeMap { opt_hash, define_opaque: _, map: _ } = *self; @@ -87,7 +84,7 @@ impl<'tcx> HashStable for AttributeMap<'tcx> { } impl HashStable for HashIgnoredAttrId { - fn stable_hash(&self, _hcx: &mut Hcx, _hasher: &mut StableHasher) { + fn stable_hash(&self, _hcx: &mut Hcx, _hasher: &mut StableHasher) { /* we don't hash HashIgnoredAttrId, we ignore them */ } } diff --git a/compiler/rustc_hir_id/src/lib.rs b/compiler/rustc_hir_id/src/lib.rs index 7590423f60444..e7a231263e218 100644 --- a/compiler/rustc_hir_id/src/lib.rs +++ b/compiler/rustc_hir_id/src/lib.rs @@ -7,7 +7,7 @@ use std::fmt::{self, Debug}; use rustc_data_structures::stable_hasher::{ - HashStable, HashStableContext, StableHasher, StableOrd, ToStableHashKey, + HashStable, StableHashCtxt, StableHasher, StableOrd, ToStableHashKey, }; use rustc_macros::{Decodable, Encodable, HashStable}; use rustc_span::def_id::{CRATE_DEF_ID, DefId, DefIndex, DefPathHash, LocalDefId}; @@ -57,7 +57,7 @@ impl rustc_index::Idx for OwnerId { impl HashStable for OwnerId { #[inline] - fn stable_hash(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { + fn stable_hash(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { self.to_stable_hash_key(hcx).stable_hash(hcx, hasher); } } @@ -66,7 +66,7 @@ impl ToStableHashKey for OwnerId { type KeyType = DefPathHash; #[inline] - fn to_stable_hash_key(&self, hcx: &mut Hcx) -> DefPathHash { + fn to_stable_hash_key(&self, hcx: &mut Hcx) -> DefPathHash { self.to_def_id().to_stable_hash_key(hcx) } } @@ -181,10 +181,7 @@ impl ToStableHashKey for HirId { type KeyType = (DefPathHash, ItemLocalId); #[inline] - fn to_stable_hash_key( - &self, - hcx: &mut Hcx, - ) -> (DefPathHash, ItemLocalId) { + fn to_stable_hash_key(&self, hcx: &mut Hcx) -> (DefPathHash, ItemLocalId) { let def_path_hash = self.owner.def_id.to_stable_hash_key(hcx); (def_path_hash, self.local_id) } diff --git a/compiler/rustc_index_macros/src/newtype.rs b/compiler/rustc_index_macros/src/newtype.rs index 4504a3db9c503..0e8b95fbb9dd7 100644 --- a/compiler/rustc_index_macros/src/newtype.rs +++ b/compiler/rustc_index_macros/src/newtype.rs @@ -157,7 +157,7 @@ impl Parse for Newtype { #gate_rustc_only impl ::rustc_data_structures::stable_hasher::HashStable for #name { fn stable_hash< - __Hcx: ::rustc_data_structures::stable_hasher::HashStableContext + __Hcx: ::rustc_data_structures::stable_hasher::StableHashCtxt >( &self, hcx: &mut __Hcx, diff --git a/compiler/rustc_lint_defs/src/lib.rs b/compiler/rustc_lint_defs/src/lib.rs index dea655e279831..8d472d1d922ca 100644 --- a/compiler/rustc_lint_defs/src/lib.rs +++ b/compiler/rustc_lint_defs/src/lib.rs @@ -3,7 +3,7 @@ use std::fmt::Display; use rustc_data_structures::fx::FxIndexSet; use rustc_data_structures::stable_hasher::{ - HashStable, HashStableContext, StableCompare, StableHasher, ToStableHashKey, + HashStable, StableCompare, StableHashCtxt, StableHasher, ToStableHashKey, }; use rustc_error_messages::{DiagArgValue, IntoDiagArg}; use rustc_hir_id::{HirId, ItemLocalId}; @@ -138,7 +138,7 @@ impl LintExpectationId { impl HashStable for LintExpectationId { #[inline] - fn stable_hash(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { + fn stable_hash(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { match self { LintExpectationId::Stable { hir_id, attr_index, lint_index: Some(lint_index) } => { hir_id.stable_hash(hcx, hasher); @@ -158,7 +158,7 @@ impl ToStableHashKey for LintExpectationId { type KeyType = (DefPathHash, ItemLocalId, u16, u16); #[inline] - fn to_stable_hash_key(&self, hcx: &mut Hcx) -> Self::KeyType { + fn to_stable_hash_key(&self, hcx: &mut Hcx) -> Self::KeyType { match self { LintExpectationId::Stable { hir_id, attr_index, lint_index: Some(lint_index) } => { let (def_path_hash, lint_idx) = hir_id.to_stable_hash_key(hcx); @@ -618,7 +618,7 @@ impl LintId { impl HashStable for LintId { #[inline] - fn stable_hash(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { + fn stable_hash(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { self.lint_name_raw().stable_hash(hcx, hasher); } } diff --git a/compiler/rustc_macros/src/hash_stable.rs b/compiler/rustc_macros/src/hash_stable.rs index 3dd2e0b153a76..09e72451838c0 100644 --- a/compiler/rustc_macros/src/hash_stable.rs +++ b/compiler/rustc_macros/src/hash_stable.rs @@ -82,7 +82,7 @@ fn hash_stable_derive_with_mode( quote!(::rustc_data_structures::stable_hasher::HashStable), quote! { #[inline] - fn stable_hash<__Hcx: ::rustc_data_structures::stable_hasher::HashStableContext>( + fn stable_hash<__Hcx: ::rustc_data_structures::stable_hasher::StableHashCtxt>( &self, __hcx: &mut __Hcx, __hasher: &mut ::rustc_data_structures::stable_hasher::StableHasher diff --git a/compiler/rustc_middle/src/hir/mod.rs b/compiler/rustc_middle/src/hir/mod.rs index e9308d860fcb9..10fdf3676b26a 100644 --- a/compiler/rustc_middle/src/hir/mod.rs +++ b/compiler/rustc_middle/src/hir/mod.rs @@ -12,7 +12,7 @@ use rustc_ast::{self as ast}; use rustc_data_structures::fingerprint::Fingerprint; use rustc_data_structures::fx::FxIndexSet; use rustc_data_structures::sorted_map::SortedMap; -use rustc_data_structures::stable_hasher::{HashStable, HashStableContext, StableHasher}; +use rustc_data_structures::stable_hasher::{HashStable, StableHashCtxt, StableHasher}; use rustc_data_structures::steal::Steal; use rustc_data_structures::sync::{DynSend, DynSync, try_par_for_each_in}; use rustc_hir::def::{DefKind, Res}; @@ -77,7 +77,7 @@ impl<'hir> Crate<'hir> { } impl HashStable for Crate<'_> { - fn stable_hash(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { + fn stable_hash(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { let Crate { opt_hir_hash, .. } = self; opt_hir_hash.unwrap().stable_hash(hcx, hasher) } diff --git a/compiler/rustc_middle/src/ich.rs b/compiler/rustc_middle/src/ich.rs index e34c8f9e490db..e0a869d4b4575 100644 --- a/compiler/rustc_middle/src/ich.rs +++ b/compiler/rustc_middle/src/ich.rs @@ -1,7 +1,7 @@ use std::hash::Hash; use rustc_data_structures::stable_hasher::{ - HashStable, HashStableContext, HashingControls, RawDefId, RawDefPathHash, RawSpan, StableHasher, + HashStable, HashingControls, RawDefId, RawDefPathHash, RawSpan, StableHashCtxt, StableHasher, }; use rustc_hir::def_id::{DefId, LocalDefId}; use rustc_session::Session; @@ -72,7 +72,7 @@ impl<'a> StableHashingContext<'a> { } } -impl<'a> HashStableContext for StableHashingContext<'a> { +impl<'a> StableHashCtxt for StableHashingContext<'a> { /// Hashes a span in a stable way. We can't directly hash the span's `BytePos` fields (that /// would be similar to hashing pointers, since those are just offsets into the `SourceMap`). /// Instead, we hash the (file name, line, column) triple, which stays the same even if the @@ -169,7 +169,7 @@ impl<'a> HashStableContext for StableHashingContext<'a> { .to_raw_def_path_hash() } - /// Assert that the provided `HashStableContext` is configured with the default + /// Assert that the provided `StableHashCtxt` is configured with the default /// `HashingControls`. We should always have bailed out before getting to here with a /// non-default mode. With this check in place, we can avoid the need to maintain separate /// versions of `ExpnData` hashes for each permutation of `HashingControls` settings. diff --git a/compiler/rustc_middle/src/middle/privacy.rs b/compiler/rustc_middle/src/middle/privacy.rs index 1a5f37be7292c..237cd3eceb964 100644 --- a/compiler/rustc_middle/src/middle/privacy.rs +++ b/compiler/rustc_middle/src/middle/privacy.rs @@ -6,7 +6,7 @@ use std::cmp::Ordering; use std::hash::Hash; use rustc_data_structures::fx::{FxIndexMap, IndexEntry}; -use rustc_data_structures::stable_hasher::{HashStable, HashStableContext, StableHasher}; +use rustc_data_structures::stable_hasher::{HashStable, StableHashCtxt, StableHasher}; use rustc_hir::def::DefKind; use rustc_hir::{ItemKind, Node, UseKind}; use rustc_macros::HashStable; @@ -281,7 +281,7 @@ impl Default for EffectiveVisibilities { } impl HashStable for EffectiveVisibilities { - fn stable_hash(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { + fn stable_hash(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { let EffectiveVisibilities { ref map } = *self; map.stable_hash(hcx, hasher); } diff --git a/compiler/rustc_middle/src/mir/basic_blocks.rs b/compiler/rustc_middle/src/mir/basic_blocks.rs index f96bf99b8cb26..bf1c084b90589 100644 --- a/compiler/rustc_middle/src/mir/basic_blocks.rs +++ b/compiler/rustc_middle/src/mir/basic_blocks.rs @@ -2,7 +2,7 @@ use std::sync::{Arc, OnceLock}; use rustc_data_structures::graph; use rustc_data_structures::graph::dominators::{Dominators, dominators}; -use rustc_data_structures::stable_hasher::{HashStable, HashStableContext, StableHasher}; +use rustc_data_structures::stable_hasher::{HashStable, StableHashCtxt, StableHasher}; use rustc_index::{IndexSlice, IndexVec}; use rustc_macros::{HashStable, TyDecodable, TyEncodable, TypeFoldable, TypeVisitable}; use rustc_serialize::{Decodable, Decoder, Encodable, Encoder}; @@ -173,5 +173,5 @@ impl Decodable for Cache { impl HashStable for Cache { #[inline] - fn stable_hash(&self, _: &mut Hcx, _: &mut StableHasher) {} + fn stable_hash(&self, _: &mut Hcx, _: &mut StableHasher) {} } diff --git a/compiler/rustc_middle/src/mono.rs b/compiler/rustc_middle/src/mono.rs index 5cafa6d716825..132f086de6f39 100644 --- a/compiler/rustc_middle/src/mono.rs +++ b/compiler/rustc_middle/src/mono.rs @@ -6,7 +6,7 @@ use rustc_data_structures::base_n::{BaseNString, CASE_INSENSITIVE, ToBaseN}; use rustc_data_structures::fingerprint::Fingerprint; use rustc_data_structures::fx::FxIndexMap; use rustc_data_structures::stable_hasher::{ - HashStable, HashStableContext, StableHasher, ToStableHashKey, + HashStable, StableHashCtxt, StableHasher, ToStableHashKey, }; use rustc_data_structures::unord::UnordMap; use rustc_hashes::Hash128; @@ -329,7 +329,7 @@ impl<'tcx> fmt::Display for MonoItem<'tcx> { impl ToStableHashKey for MonoItem<'_> { type KeyType = Fingerprint; - fn to_stable_hash_key(&self, hcx: &mut Hcx) -> Self::KeyType { + fn to_stable_hash_key(&self, hcx: &mut Hcx) -> Self::KeyType { let mut hasher = StableHasher::new(); self.stable_hash(hcx, &mut hasher); hasher.finish() diff --git a/compiler/rustc_middle/src/ty/adt.rs b/compiler/rustc_middle/src/ty/adt.rs index dddd312b7b150..82eaed172ac46 100644 --- a/compiler/rustc_middle/src/ty/adt.rs +++ b/compiler/rustc_middle/src/ty/adt.rs @@ -8,7 +8,7 @@ use rustc_data_structures::fingerprint::Fingerprint; use rustc_data_structures::fx::FxHashMap; use rustc_data_structures::intern::Interned; use rustc_data_structures::stable_hasher::{ - HashStable, HashStableContext, HashingControls, StableHasher, + HashStable, HashingControls, StableHashCtxt, StableHasher, }; use rustc_errors::ErrorGuaranteed; use rustc_hir::def::{CtorKind, DefKind, Res}; @@ -153,7 +153,7 @@ impl Hash for AdtDefData { } impl HashStable for AdtDefData { - fn stable_hash(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { + fn stable_hash(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { thread_local! { static CACHE: RefCell> = Default::default(); } diff --git a/compiler/rustc_middle/src/ty/consts/int.rs b/compiler/rustc_middle/src/ty/consts/int.rs index fe08df7c4b13e..4e83f2d4baa92 100644 --- a/compiler/rustc_middle/src/ty/consts/int.rs +++ b/compiler/rustc_middle/src/ty/consts/int.rs @@ -4,7 +4,7 @@ use std::num::NonZero; use rustc_abi::Size; use rustc_apfloat::Float; use rustc_apfloat::ieee::{Double, Half, Quad, Single}; -use rustc_data_structures::stable_hasher::{HashStable, HashStableContext}; +use rustc_data_structures::stable_hasher::{HashStable, StableHashCtxt}; use rustc_serialize::{Decodable, Decoder, Encodable, Encoder}; use crate::ty::TyCtxt; @@ -153,7 +153,7 @@ pub struct ScalarInt { // Cannot derive these, as the derives take references to the fields, and we // can't take references to fields of packed structs. impl HashStable for ScalarInt { - fn stable_hash( + fn stable_hash( &self, hcx: &mut Hcx, hasher: &mut crate::ty::StableHasher, diff --git a/compiler/rustc_middle/src/ty/impls_ty.rs b/compiler/rustc_middle/src/ty/impls_ty.rs index 9fb3845782b11..1f7f494ed89e2 100644 --- a/compiler/rustc_middle/src/ty/impls_ty.rs +++ b/compiler/rustc_middle/src/ty/impls_ty.rs @@ -7,7 +7,7 @@ use std::ptr; use rustc_data_structures::fingerprint::Fingerprint; use rustc_data_structures::fx::FxHashMap; use rustc_data_structures::stable_hasher::{ - HashStable, HashStableContext, HashingControls, StableHasher, ToStableHashKey, + HashStable, HashingControls, StableHashCtxt, StableHasher, ToStableHashKey, }; use tracing::trace; @@ -18,7 +18,7 @@ impl<'tcx, H, T> HashStable for &'tcx ty::list::RawList where T: HashStable, { - fn stable_hash(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { + fn stable_hash(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { // Note: this cache makes an *enormous* performance difference on certain benchmarks. E.g. // without it, compiling `diesel-2.2.10` can be 74% slower, and compiling // `deeply-nested-multi` can be ~4,000x slower(!) @@ -52,7 +52,7 @@ where type KeyType = Fingerprint; #[inline] - fn to_stable_hash_key(&self, hcx: &mut Hcx) -> Fingerprint { + fn to_stable_hash_key(&self, hcx: &mut Hcx) -> Fingerprint { let mut hasher = StableHasher::new(); self.stable_hash(hcx, &mut hasher); hasher.finish() @@ -60,14 +60,14 @@ where } impl<'tcx> HashStable for ty::GenericArg<'tcx> { - fn stable_hash(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { + fn stable_hash(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { self.kind().stable_hash(hcx, hasher); } } // AllocIds get resolved to whatever they point to (to be stable) impl HashStable for mir::interpret::AllocId { - fn stable_hash(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { + fn stable_hash(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { ty::tls::with_opt(|tcx| { trace!("hashing {:?}", *self); let tcx = tcx.expect("can't hash AllocIds during hir lowering"); @@ -77,7 +77,7 @@ impl HashStable for mir::interpret::AllocId { } impl HashStable for mir::interpret::CtfeProvenance { - fn stable_hash(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { + fn stable_hash(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { self.into_parts().stable_hash(hcx, hasher); } } diff --git a/compiler/rustc_middle/src/ty/mod.rs b/compiler/rustc_middle/src/ty/mod.rs index b63d27cc9475d..d730a19b04090 100644 --- a/compiler/rustc_middle/src/ty/mod.rs +++ b/compiler/rustc_middle/src/ty/mod.rs @@ -33,7 +33,7 @@ use rustc_ast::node_id::NodeMap; pub use rustc_ast_ir::{Movability, Mutability, try_visit}; use rustc_data_structures::fx::{FxHashSet, FxIndexMap, FxIndexSet}; use rustc_data_structures::intern::Interned; -use rustc_data_structures::stable_hasher::{HashStable, HashStableContext, StableHasher}; +use rustc_data_structures::stable_hasher::{HashStable, StableHashCtxt, StableHasher}; use rustc_data_structures::steal::Steal; use rustc_data_structures::unord::{UnordMap, UnordSet}; use rustc_errors::{Diag, ErrorGuaranteed, LintBuffer}; @@ -558,7 +558,7 @@ impl<'tcx> From> for Term<'tcx> { } impl<'tcx> HashStable for Term<'tcx> { - fn stable_hash(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { + fn stable_hash(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { self.kind().stable_hash(hcx, hasher); } } diff --git a/compiler/rustc_span/src/def_id.rs b/compiler/rustc_span/src/def_id.rs index 8087ef122f6c9..6902b7f282ae3 100644 --- a/compiler/rustc_span/src/def_id.rs +++ b/compiler/rustc_span/src/def_id.rs @@ -4,8 +4,7 @@ use std::hash::{BuildHasherDefault, Hash, Hasher}; use rustc_data_structures::AtomicRef; use rustc_data_structures::fingerprint::Fingerprint; use rustc_data_structures::stable_hasher::{ - HashStable, HashStableContext, RawDefId, RawDefPathHash, StableHasher, StableOrd, - ToStableHashKey, + HashStable, RawDefId, RawDefPathHash, StableHashCtxt, StableHasher, StableOrd, ToStableHashKey, }; use rustc_data_structures::unhash::Unhasher; use rustc_hashes::Hash64; @@ -429,21 +428,21 @@ rustc_data_structures::define_id_collections!( impl HashStable for DefId { #[inline] - fn stable_hash(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { + fn stable_hash(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { self.to_stable_hash_key(hcx).stable_hash(hcx, hasher); } } impl HashStable for LocalDefId { #[inline] - fn stable_hash(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { + fn stable_hash(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { self.to_stable_hash_key(hcx).local_hash().stable_hash(hcx, hasher); } } impl HashStable for CrateNum { #[inline] - fn stable_hash(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { + fn stable_hash(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { self.as_def_id().to_stable_hash_key(hcx).stable_crate_id().stable_hash(hcx, hasher); } } @@ -452,7 +451,7 @@ impl ToStableHashKey for DefId { type KeyType = DefPathHash; #[inline] - fn to_stable_hash_key(&self, hcx: &mut Hcx) -> DefPathHash { + fn to_stable_hash_key(&self, hcx: &mut Hcx) -> DefPathHash { DefPathHash::from_raw_def_path_hash(hcx.def_path_hash(self.to_raw_def_id())) } } @@ -461,7 +460,7 @@ impl ToStableHashKey for LocalDefId { type KeyType = DefPathHash; #[inline] - fn to_stable_hash_key(&self, hcx: &mut Hcx) -> DefPathHash { + fn to_stable_hash_key(&self, hcx: &mut Hcx) -> DefPathHash { self.to_def_id().to_stable_hash_key(hcx) } } @@ -470,7 +469,7 @@ impl ToStableHashKey for CrateNum { type KeyType = DefPathHash; #[inline] - fn to_stable_hash_key(&self, hcx: &mut Hcx) -> DefPathHash { + fn to_stable_hash_key(&self, hcx: &mut Hcx) -> DefPathHash { self.as_def_id().to_stable_hash_key(hcx) } } diff --git a/compiler/rustc_span/src/hygiene.rs b/compiler/rustc_span/src/hygiene.rs index 5face6b38da0f..bf89b3fb78a63 100644 --- a/compiler/rustc_span/src/hygiene.rs +++ b/compiler/rustc_span/src/hygiene.rs @@ -31,7 +31,7 @@ use std::{fmt, iter, mem}; use rustc_data_structures::fingerprint::Fingerprint; use rustc_data_structures::fx::{FxHashMap, FxHashSet}; use rustc_data_structures::stable_hasher::{ - HashStable, HashStableContext, StableHasher, ToStableHashKey, + HashStable, StableHashCtxt, StableHasher, ToStableHashKey, }; use rustc_data_structures::sync::Lock; use rustc_data_structures::unhash::UnhashMap; @@ -209,7 +209,7 @@ impl LocalExpnId { }) } - pub fn fresh(mut expn_data: ExpnData, hcx: impl HashStableContext) -> LocalExpnId { + pub fn fresh(mut expn_data: ExpnData, hcx: impl StableHashCtxt) -> LocalExpnId { debug_assert_eq!(expn_data.parent.krate, LOCAL_CRATE); let expn_hash = update_disambiguator(&mut expn_data, hcx); HygieneData::with(|data| { @@ -233,7 +233,7 @@ impl LocalExpnId { } #[inline] - pub fn set_expn_data(self, mut expn_data: ExpnData, hcx: impl HashStableContext) { + pub fn set_expn_data(self, mut expn_data: ExpnData, hcx: impl StableHashCtxt) { debug_assert_eq!(expn_data.parent.krate, LOCAL_CRATE); let expn_hash = update_disambiguator(&mut expn_data, hcx); HygieneData::with(|data| { @@ -952,7 +952,7 @@ impl Span { allow_internal_unstable: Option>, reason: DesugaringKind, edition: Edition, - hcx: impl HashStableContext, + hcx: impl StableHashCtxt, ) -> Span { let expn_data = ExpnData { allow_internal_unstable, @@ -1104,7 +1104,7 @@ impl ExpnData { } #[inline] - fn hash_expn(&self, hcx: &mut impl HashStableContext) -> Hash64 { + fn hash_expn(&self, hcx: &mut impl StableHashCtxt) -> Hash64 { let mut hasher = StableHasher::new(); self.stable_hash(hcx, &mut hasher); hasher.finish() @@ -1484,7 +1484,7 @@ pub fn raw_encode_syntax_context( /// `set_expn_data`). It is *not* called for foreign `ExpnId`s deserialized /// from another crate's metadata - since `ExpnHash` includes the stable crate id, /// collisions are only possible between `ExpnId`s within the same crate. -fn update_disambiguator(expn_data: &mut ExpnData, mut hcx: impl HashStableContext) -> ExpnHash { +fn update_disambiguator(expn_data: &mut ExpnData, mut hcx: impl StableHashCtxt) -> ExpnHash { // This disambiguator should not have been set yet. assert_eq!(expn_data.disambiguator, 0, "Already set disambiguator for ExpnData: {expn_data:?}"); hcx.assert_default_hashing_controls("ExpnData (disambiguator)"); @@ -1520,7 +1520,7 @@ fn update_disambiguator(expn_data: &mut ExpnData, mut hcx: impl HashStableContex } impl HashStable for SyntaxContext { - fn stable_hash(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { + fn stable_hash(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { const TAG_EXPANSION: u8 = 0; const TAG_NO_EXPANSION: u8 = 1; @@ -1536,7 +1536,7 @@ impl HashStable for SyntaxContext { } impl HashStable for ExpnId { - fn stable_hash(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { + fn stable_hash(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { hcx.assert_default_hashing_controls("ExpnId"); let hash = if *self == ExpnId::root() { // Avoid fetching TLS storage for a trivial often-used value. @@ -1550,7 +1550,7 @@ impl HashStable for ExpnId { } impl HashStable for LocalExpnId { - fn stable_hash(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { + fn stable_hash(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { self.to_expn_id().stable_hash(hcx, hasher); } } diff --git a/compiler/rustc_span/src/lib.rs b/compiler/rustc_span/src/lib.rs index d637feff3fce6..12d20ebe5bc2c 100644 --- a/compiler/rustc_span/src/lib.rs +++ b/compiler/rustc_span/src/lib.rs @@ -31,7 +31,7 @@ extern crate self as rustc_span; use derive_where::derive_where; -use rustc_data_structures::stable_hasher::HashStableContext; +use rustc_data_structures::stable_hasher::StableHashCtxt; use rustc_data_structures::{AtomicRef, outline}; use rustc_macros::{Decodable, Encodable, HashStable}; use rustc_serialize::opaque::{FileEncoder, MemDecoder}; @@ -2788,7 +2788,7 @@ impl InnerSpan { } impl HashStable for Span { - fn stable_hash(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { + fn stable_hash(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { // `span_hash_stable` does all the work. hcx.span_hash_stable(self.to_raw_span(), hasher) } diff --git a/compiler/rustc_span/src/symbol.rs b/compiler/rustc_span/src/symbol.rs index 56ada83943f2b..9b987ca46d6b9 100644 --- a/compiler/rustc_span/src/symbol.rs +++ b/compiler/rustc_span/src/symbol.rs @@ -8,7 +8,7 @@ use std::{fmt, str}; use rustc_arena::DroplessArena; use rustc_data_structures::fx::{FxHashSet, FxIndexSet}; use rustc_data_structures::stable_hasher::{ - HashStable, HashStableContext, StableCompare, StableHasher, ToStableHashKey, + HashStable, StableCompare, StableHashCtxt, StableHasher, ToStableHashKey, }; use rustc_data_structures::sync::Lock; use rustc_macros::{Decodable, Encodable, HashStable, symbols}; @@ -2635,7 +2635,7 @@ impl fmt::Display for Symbol { impl HashStable for Symbol { #[inline] - fn stable_hash(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { + fn stable_hash(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { self.as_str().stable_hash(hcx, hasher); } } @@ -2695,7 +2695,7 @@ impl fmt::Debug for ByteSymbol { impl HashStable for ByteSymbol { #[inline] - fn stable_hash(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { + fn stable_hash(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { self.as_byte_str().stable_hash(hcx, hasher); } } diff --git a/compiler/rustc_type_ir/src/const_kind.rs b/compiler/rustc_type_ir/src/const_kind.rs index 1261362c4d278..632fc28f9bde3 100644 --- a/compiler/rustc_type_ir/src/const_kind.rs +++ b/compiler/rustc_type_ir/src/const_kind.rs @@ -2,7 +2,7 @@ use std::fmt; use derive_where::derive_where; #[cfg(feature = "nightly")] -use rustc_data_structures::stable_hasher::{HashStable, HashStableContext, StableHasher}; +use rustc_data_structures::stable_hasher::{HashStable, StableHashCtxt, StableHasher}; #[cfg(feature = "nightly")] use rustc_macros::{Decodable_NoContext, Encodable_NoContext, HashStable, HashStable_NoContext}; use rustc_type_ir_macros::{ @@ -118,7 +118,7 @@ impl fmt::Debug for InferConst { #[cfg(feature = "nightly")] impl HashStable for InferConst { - fn stable_hash(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { + fn stable_hash(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { match self { InferConst::Var(_) => { panic!("const variables should not be hashed: {self:?}") diff --git a/compiler/rustc_type_ir/src/fast_reject.rs b/compiler/rustc_type_ir/src/fast_reject.rs index f6a5e98d1c529..11fb0ba8249c4 100644 --- a/compiler/rustc_type_ir/src/fast_reject.rs +++ b/compiler/rustc_type_ir/src/fast_reject.rs @@ -8,7 +8,7 @@ use rustc_ast_ir::Mutability; use rustc_data_structures::fingerprint::Fingerprint; #[cfg(feature = "nightly")] use rustc_data_structures::stable_hasher::{ - HashStable, HashStableContext, StableHasher, ToStableHashKey, + HashStable, StableHashCtxt, StableHasher, ToStableHashKey, }; #[cfg(feature = "nightly")] use rustc_macros::{Decodable_NoContext, Encodable_NoContext, HashStable}; @@ -53,7 +53,7 @@ impl ToStableHashKey for SimplifiedType { type KeyType = Fingerprint; #[inline] - fn to_stable_hash_key(&self, hcx: &mut Hcx) -> Fingerprint { + fn to_stable_hash_key(&self, hcx: &mut Hcx) -> Fingerprint { let mut hasher = StableHasher::new(); self.stable_hash(hcx, &mut hasher); hasher.finish() diff --git a/compiler/rustc_type_ir/src/region_kind.rs b/compiler/rustc_type_ir/src/region_kind.rs index fbe58d2839ada..a3f8e2cb79cf0 100644 --- a/compiler/rustc_type_ir/src/region_kind.rs +++ b/compiler/rustc_type_ir/src/region_kind.rs @@ -2,7 +2,7 @@ use std::fmt; use derive_where::derive_where; #[cfg(feature = "nightly")] -use rustc_data_structures::stable_hasher::{HashStable, HashStableContext, StableHasher}; +use rustc_data_structures::stable_hasher::{HashStable, StableHashCtxt, StableHasher}; #[cfg(feature = "nightly")] use rustc_macros::{Decodable_NoContext, Encodable_NoContext}; use rustc_type_ir_macros::GenericTypeVisitable; @@ -225,7 +225,7 @@ where I::Symbol: HashStable, { #[inline] - fn stable_hash(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { + fn stable_hash(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { std::mem::discriminant(self).stable_hash(hcx, hasher); match self { ReErased | ReStatic | ReError(_) => { diff --git a/compiler/rustc_type_ir/src/solve/mod.rs b/compiler/rustc_type_ir/src/solve/mod.rs index b32bbefb01a91..3aaaaa0b7dd43 100644 --- a/compiler/rustc_type_ir/src/solve/mod.rs +++ b/compiler/rustc_type_ir/src/solve/mod.rs @@ -271,7 +271,7 @@ impl ExternalConstraintsData { /// `Unreachable` is used in places in which leak check isn't done, e.g. /// borrowck. #[derive(Clone, Copy, Hash, PartialEq, Eq, Debug)] -#[cfg_attr(feature = "nightly", derive(HashStable_NoContext))] +#[cfg_attr(feature = "nightly", derive(StableHash_NoContext))] pub enum VisibleForLeakCheck { Yes, No, diff --git a/compiler/rustc_type_ir/src/ty_info.rs b/compiler/rustc_type_ir/src/ty_info.rs index 7a596538a6d64..26aad55076064 100644 --- a/compiler/rustc_type_ir/src/ty_info.rs +++ b/compiler/rustc_type_ir/src/ty_info.rs @@ -3,7 +3,7 @@ use std::hash::{Hash, Hasher}; use std::ops::Deref; #[cfg(feature = "nightly")] -use rustc_data_structures::stable_hasher::{HashStable, HashStableContext, StableHasher}; +use rustc_data_structures::stable_hasher::{HashStable, StableHashCtxt, StableHasher}; use rustc_type_ir_macros::GenericTypeVisitable; use crate::{DebruijnIndex, TypeFlags}; @@ -84,7 +84,7 @@ impl Hash for WithCachedTypeInfo { #[cfg(feature = "nightly")] impl HashStable for WithCachedTypeInfo { - fn stable_hash(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { + fn stable_hash(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { self.internee.stable_hash(hcx, hasher); } } diff --git a/compiler/rustc_type_ir/src/ty_kind.rs b/compiler/rustc_type_ir/src/ty_kind.rs index 688aa5f540193..a07afa5766d6f 100644 --- a/compiler/rustc_type_ir/src/ty_kind.rs +++ b/compiler/rustc_type_ir/src/ty_kind.rs @@ -6,7 +6,7 @@ use derive_where::derive_where; use rustc_abi::ExternAbi; use rustc_ast_ir::Mutability; #[cfg(feature = "nightly")] -use rustc_data_structures::stable_hasher::{HashStable, HashStableContext, StableHasher}; +use rustc_data_structures::stable_hasher::{HashStable, StableHashCtxt, StableHasher}; #[cfg(feature = "nightly")] use rustc_macros::{Decodable_NoContext, Encodable_NoContext, HashStable_NoContext}; use rustc_type_ir::data_structures::{NoError, UnifyKey, UnifyValue}; @@ -708,7 +708,7 @@ impl UnifyKey for FloatVid { #[cfg(feature = "nightly")] impl HashStable for InferTy { - fn stable_hash(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { + fn stable_hash(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { use InferTy::*; std::mem::discriminant(self).stable_hash(hcx, hasher); match self { From e7d28d3e9b6daaec005e0a56ca8998af10fe6fc3 Mon Sep 17 00:00:00 2001 From: Nicholas Nethercote Date: Fri, 1 May 2026 09:44:46 +1000 Subject: [PATCH 17/17] Rename the `HashStable*` trait/derives as `StableHash*`. Specifically: - `HashStable` -> `StableHash` (trait) - `HashStable` -> `StableHash` (derive) - `HashStable_NoContext` -> `StableHash_NoContext` (derive) Note: there are some names in `compiler/rustc_macros/src/hash_stable.rs` that are still to be renamed, e.g. `HashStableMode`. Part of MCP 983. --- compiler/rustc_abi/src/callconv/reg.rs | 6 +- compiler/rustc_abi/src/canon_abi.rs | 10 +- compiler/rustc_abi/src/extern_abi.rs | 4 +- compiler/rustc_abi/src/layout/ty.rs | 6 +- compiler/rustc_abi/src/lib.rs | 42 +-- compiler/rustc_ast/src/ast.rs | 76 ++--- .../rustc_ast/src/attr/data_structures.rs | 4 +- compiler/rustc_ast/src/attr/version.rs | 4 +- compiler/rustc_ast/src/expand/allocator.rs | 4 +- .../rustc_ast/src/expand/autodiff_attrs.rs | 6 +- compiler/rustc_ast/src/expand/mod.rs | 2 +- compiler/rustc_ast/src/expand/typetree.rs | 10 +- compiler/rustc_ast/src/node_id.rs | 6 +- compiler/rustc_ast/src/token.rs | 28 +- compiler/rustc_ast/src/tokenstream.rs | 16 +- compiler/rustc_ast_ir/src/lib.rs | 14 +- compiler/rustc_ast_lowering/src/lib.rs | 2 +- .../rustc_codegen_cranelift/src/driver/aot.rs | 4 +- compiler/rustc_codegen_llvm/src/common.rs | 2 +- .../src/debuginfo/metadata/type_map.rs | 10 +- compiler/rustc_codegen_ssa/src/common.rs | 8 +- .../src/debuginfo/type_names.rs | 2 +- compiler/rustc_data_structures/src/intern.rs | 6 +- compiler/rustc_data_structures/src/packed.rs | 4 +- .../rustc_data_structures/src/sorted_map.rs | 4 +- .../src/sorted_map/index_map.rs | 4 +- .../src/stable_hasher.rs | 138 ++++----- .../src/stable_hasher/tests.rs | 4 +- compiler/rustc_data_structures/src/steal.rs | 4 +- compiler/rustc_data_structures/src/svh.rs | 4 +- .../rustc_data_structures/src/tagged_ptr.rs | 8 +- .../src/tagged_ptr/tests.rs | 4 +- compiler/rustc_data_structures/src/unord.rs | 10 +- compiler/rustc_error_messages/src/lib.rs | 6 +- compiler/rustc_feature/src/unstable.rs | 8 +- .../rustc_hir/src/attrs/data_structures.rs | 92 +++--- compiler/rustc_hir/src/attrs/diagnostic.rs | 24 +- compiler/rustc_hir/src/def.rs | 18 +- compiler/rustc_hir/src/diagnostic_items.rs | 4 +- compiler/rustc_hir/src/hir.rs | 284 +++++++++--------- compiler/rustc_hir/src/lang_items.rs | 8 +- compiler/rustc_hir/src/limit.rs | 4 +- compiler/rustc_hir/src/stability.rs | 16 +- compiler/rustc_hir/src/stable_hash_impls.rs | 10 +- compiler/rustc_hir/src/target.rs | 8 +- compiler/rustc_hir_id/src/lib.rs | 8 +- compiler/rustc_index_macros/src/lib.rs | 2 +- compiler/rustc_index_macros/src/newtype.rs | 6 +- compiler/rustc_lint_defs/src/lib.rs | 14 +- compiler/rustc_macros/src/hash_stable.rs | 14 +- compiler/rustc_macros/src/lib.rs | 4 +- .../rustc_middle/src/dep_graph/dep_node.rs | 4 +- .../src/dep_graph/dep_node_key.rs | 4 +- compiler/rustc_middle/src/dep_graph/graph.rs | 4 +- compiler/rustc_middle/src/hir/map.rs | 2 +- compiler/rustc_middle/src/hir/mod.rs | 8 +- compiler/rustc_middle/src/hir/place.rs | 12 +- compiler/rustc_middle/src/ich.rs | 2 +- compiler/rustc_middle/src/infer/canonical.rs | 8 +- compiler/rustc_middle/src/lint.rs | 10 +- compiler/rustc_middle/src/metadata.rs | 8 +- .../src/middle/codegen_fn_attrs.rs | 14 +- .../src/middle/debugger_visualizer.rs | 4 +- .../src/middle/deduced_param_attrs.rs | 6 +- .../src/middle/dependency_format.rs | 4 +- .../src/middle/exported_symbols.rs | 10 +- compiler/rustc_middle/src/middle/mod.rs | 6 +- compiler/rustc_middle/src/middle/privacy.rs | 10 +- compiler/rustc_middle/src/middle/region.rs | 10 +- .../src/middle/resolve_bound_vars.rs | 10 +- compiler/rustc_middle/src/middle/stability.rs | 4 +- compiler/rustc_middle/src/mir/basic_blocks.rs | 8 +- compiler/rustc_middle/src/mir/consts.rs | 10 +- compiler/rustc_middle/src/mir/coverage.rs | 24 +- .../src/mir/interpret/allocation.rs | 6 +- .../src/mir/interpret/allocation/init_mask.rs | 8 +- .../interpret/allocation/provenance_map.rs | 6 +- .../rustc_middle/src/mir/interpret/error.rs | 8 +- .../rustc_middle/src/mir/interpret/mod.rs | 6 +- .../rustc_middle/src/mir/interpret/pointer.rs | 4 +- .../rustc_middle/src/mir/interpret/value.rs | 4 +- compiler/rustc_middle/src/mir/mod.rs | 46 +-- compiler/rustc_middle/src/mir/query.rs | 16 +- compiler/rustc_middle/src/mir/statement.rs | 6 +- compiler/rustc_middle/src/mir/syntax.rs | 68 ++--- compiler/rustc_middle/src/mir/terminator.rs | 4 +- compiler/rustc_middle/src/mono.rs | 18 +- compiler/rustc_middle/src/query/keys.rs | 4 +- .../rustc_middle/src/query/on_disk_cache.rs | 2 +- compiler/rustc_middle/src/thir.rs | 58 ++-- compiler/rustc_middle/src/traits/mod.rs | 36 +-- compiler/rustc_middle/src/traits/query.rs | 36 +-- compiler/rustc_middle/src/traits/select.rs | 6 +- compiler/rustc_middle/src/traits/solve.rs | 4 +- .../src/traits/specialization_graph.rs | 8 +- .../rustc_middle/src/ty/abstract_const.rs | 6 +- compiler/rustc_middle/src/ty/adjustment.rs | 26 +- compiler/rustc_middle/src/ty/adt.rs | 12 +- compiler/rustc_middle/src/ty/assoc.rs | 12 +- compiler/rustc_middle/src/ty/cast.rs | 4 +- compiler/rustc_middle/src/ty/closure.rs | 16 +- compiler/rustc_middle/src/ty/consts.rs | 4 +- compiler/rustc_middle/src/ty/consts/int.rs | 4 +- compiler/rustc_middle/src/ty/consts/kind.rs | 6 +- compiler/rustc_middle/src/ty/consts/lit.rs | 4 +- .../rustc_middle/src/ty/consts/valtree.rs | 6 +- compiler/rustc_middle/src/ty/context.rs | 4 +- compiler/rustc_middle/src/ty/generic_args.rs | 6 +- compiler/rustc_middle/src/ty/generics.rs | 12 +- compiler/rustc_middle/src/ty/impls_ty.rs | 16 +- .../ty/inhabitedness/inhabited_predicate.rs | 4 +- compiler/rustc_middle/src/ty/instance.rs | 8 +- compiler/rustc_middle/src/ty/intrinsic.rs | 4 +- compiler/rustc_middle/src/ty/layout.rs | 10 +- compiler/rustc_middle/src/ty/mod.rs | 56 ++-- .../src/ty/normalize_erasing_regions.rs | 4 +- compiler/rustc_middle/src/ty/pattern.rs | 4 +- compiler/rustc_middle/src/ty/predicate.rs | 6 +- compiler/rustc_middle/src/ty/region.rs | 10 +- compiler/rustc_middle/src/ty/sty.rs | 8 +- compiler/rustc_middle/src/ty/trait_def.rs | 10 +- .../rustc_middle/src/ty/typeck_results.rs | 12 +- compiler/rustc_middle/src/ty/util.rs | 6 +- compiler/rustc_middle/src/ty/vtable.rs | 4 +- .../src/solve/eval_ctxt/mod.rs | 4 +- compiler/rustc_session/src/config.rs | 16 +- compiler/rustc_session/src/cstore.rs | 22 +- compiler/rustc_session/src/search_paths.rs | 4 +- compiler/rustc_session/src/session.rs | 4 +- compiler/rustc_session/src/utils.rs | 4 +- compiler/rustc_span/src/def_id.rs | 18 +- compiler/rustc_span/src/edition.rs | 4 +- compiler/rustc_span/src/hygiene.rs | 28 +- compiler/rustc_span/src/lib.rs | 22 +- compiler/rustc_span/src/symbol.rs | 10 +- compiler/rustc_symbol_mangling/src/hashed.rs | 2 +- compiler/rustc_symbol_mangling/src/legacy.rs | 2 +- compiler/rustc_target/src/asm/mod.rs | 14 +- compiler/rustc_target/src/callconv/mod.rs | 22 +- compiler/rustc_target/src/spec/mod.rs | 10 +- compiler/rustc_target/src/target_features.rs | 4 +- compiler/rustc_type_ir/src/binder.rs | 22 +- compiler/rustc_type_ir/src/canonical.rs | 10 +- compiler/rustc_type_ir/src/const_kind.rs | 14 +- compiler/rustc_type_ir/src/fast_reject.rs | 8 +- compiler/rustc_type_ir/src/generic_arg.rs | 6 +- compiler/rustc_type_ir/src/infer_ctxt.rs | 6 +- compiler/rustc_type_ir/src/lib.rs | 6 +- compiler/rustc_type_ir/src/opaque_ty.rs | 4 +- compiler/rustc_type_ir/src/pattern.rs | 4 +- compiler/rustc_type_ir/src/predicate.rs | 38 +-- compiler/rustc_type_ir/src/predicate_kind.rs | 8 +- compiler/rustc_type_ir/src/region_kind.rs | 14 +- .../rustc_type_ir/src/search_graph/mod.rs | 4 +- compiler/rustc_type_ir/src/solve/mod.rs | 30 +- compiler/rustc_type_ir/src/ty_info.rs | 4 +- compiler/rustc_type_ir/src/ty_kind.rs | 26 +- .../incremental-compilation-in-detail.md | 4 +- .../crates/hir-ty/src/next_solver/interner.rs | 2 +- tests/ui-fulldeps/hash-stable-is-unstable.rs | 12 +- .../hash-stable-is-unstable.stderr | 6 +- 161 files changed, 1112 insertions(+), 1112 deletions(-) diff --git a/compiler/rustc_abi/src/callconv/reg.rs b/compiler/rustc_abi/src/callconv/reg.rs index 397fa7d653655..198b62d5fb475 100644 --- a/compiler/rustc_abi/src/callconv/reg.rs +++ b/compiler/rustc_abi/src/callconv/reg.rs @@ -1,9 +1,9 @@ #[cfg(feature = "nightly")] -use rustc_macros::HashStable; +use rustc_macros::StableHash; use crate::{Align, HasDataLayout, Integer, Primitive, Size}; -#[cfg_attr(feature = "nightly", derive(HashStable))] +#[cfg_attr(feature = "nightly", derive(StableHash))] #[derive(Copy, Clone, PartialEq, Eq, Hash, Debug)] pub enum RegKind { Integer, @@ -16,7 +16,7 @@ pub enum RegKind { }, } -#[cfg_attr(feature = "nightly", derive(HashStable))] +#[cfg_attr(feature = "nightly", derive(StableHash))] #[derive(Copy, Clone, PartialEq, Eq, Hash, Debug)] pub struct Reg { pub kind: RegKind, diff --git a/compiler/rustc_abi/src/canon_abi.rs b/compiler/rustc_abi/src/canon_abi.rs index fc81a5911edd4..3ef3fa365298c 100644 --- a/compiler/rustc_abi/src/canon_abi.rs +++ b/compiler/rustc_abi/src/canon_abi.rs @@ -1,7 +1,7 @@ use std::fmt; #[cfg(feature = "nightly")] -use rustc_macros::HashStable; +use rustc_macros::StableHash; use crate::ExternAbi; @@ -18,7 +18,7 @@ use crate::ExternAbi; /// rather than picking the "actual" ABI. #[derive(Copy, Clone, Debug)] #[derive(PartialOrd, Ord, PartialEq, Eq, Hash)] -#[cfg_attr(feature = "nightly", derive(HashStable))] +#[cfg_attr(feature = "nightly", derive(StableHash))] pub enum CanonAbi { // NOTE: the use of nested variants for some ABIs is for many targets they don't matter, // and this pushes the complexity of their reasoning to target-specific code, @@ -111,7 +111,7 @@ impl fmt::Display for CanonAbi { /// These only affect callee codegen. making their categorization as distinct ABIs a bit peculiar. #[derive(Copy, Clone, Debug)] #[derive(PartialOrd, Ord, PartialEq, Eq, Hash)] -#[cfg_attr(feature = "nightly", derive(HashStable))] +#[cfg_attr(feature = "nightly", derive(StableHash))] pub enum InterruptKind { Avr, AvrNonBlocking, @@ -126,7 +126,7 @@ pub enum InterruptKind { /// One of SysV64 or Win64 may alias the C ABI, and arguably Win64 is cross-platform now? #[derive(Clone, Copy, Debug)] #[derive(PartialOrd, Ord, PartialEq, Eq, Hash)] -#[cfg_attr(feature = "nightly", derive(HashStable))] +#[cfg_attr(feature = "nightly", derive(StableHash))] pub enum X86Call { /// "fastcall" has both GNU and Windows variants Fastcall, @@ -141,7 +141,7 @@ pub enum X86Call { /// ABIs defined for 32-bit Arm #[derive(Copy, Clone, Debug)] #[derive(PartialOrd, Ord, PartialEq, Eq, Hash)] -#[cfg_attr(feature = "nightly", derive(HashStable))] +#[cfg_attr(feature = "nightly", derive(StableHash))] pub enum ArmCall { Aapcs, CCmseNonSecureCall, diff --git a/compiler/rustc_abi/src/extern_abi.rs b/compiler/rustc_abi/src/extern_abi.rs index 28066d11b226f..fbc009c4d57e4 100644 --- a/compiler/rustc_abi/src/extern_abi.rs +++ b/compiler/rustc_abi/src/extern_abi.rs @@ -3,7 +3,7 @@ use std::fmt; use std::hash::{Hash, Hasher}; #[cfg(feature = "nightly")] -use rustc_data_structures::stable_hasher::{HashStable, StableHashCtxt, StableHasher, StableOrd}; +use rustc_data_structures::stable_hasher::{StableHash, StableHashCtxt, StableHasher, StableOrd}; #[cfg(feature = "nightly")] use rustc_macros::{Decodable, Encodable}; #[cfg(feature = "nightly")] @@ -240,7 +240,7 @@ impl Hash for ExternAbi { } #[cfg(feature = "nightly")] -impl HashStable for ExternAbi { +impl StableHash for ExternAbi { #[inline] fn stable_hash(&self, _: &mut Hcx, hasher: &mut StableHasher) { Hash::hash(self, hasher); diff --git a/compiler/rustc_abi/src/layout/ty.rs b/compiler/rustc_abi/src/layout/ty.rs index b394f9f4f86dc..b09afc9ec8af6 100644 --- a/compiler/rustc_abi/src/layout/ty.rs +++ b/compiler/rustc_abi/src/layout/ty.rs @@ -2,7 +2,7 @@ use std::fmt; use std::ops::Deref; use rustc_data_structures::intern::Interned; -use rustc_macros::HashStable; +use rustc_macros::StableHash; use crate::layout::{FieldIdx, VariantIdx}; use crate::{ @@ -12,7 +12,7 @@ use crate::{ // Explicitly import `Float` to avoid ambiguity with `Primitive::Float`. -#[derive(Copy, Clone, PartialEq, Eq, Hash, HashStable)] +#[derive(Copy, Clone, PartialEq, Eq, Hash, StableHash)] #[rustc_pass_by_value] pub struct Layout<'a>(pub Interned<'a, LayoutData>); @@ -71,7 +71,7 @@ impl<'a> Layout<'a> { /// to that obtained from `layout_of(ty)`, as we need to produce /// layouts for which Rust types do not exist, such as enum variants /// or synthetic fields of enums (i.e., discriminants) and wide pointers. -#[derive(Copy, Clone, PartialEq, Eq, Hash, HashStable)] +#[derive(Copy, Clone, PartialEq, Eq, Hash, StableHash)] pub struct TyAndLayout<'a, Ty> { pub ty: Ty, pub layout: Layout<'a>, diff --git a/compiler/rustc_abi/src/lib.rs b/compiler/rustc_abi/src/lib.rs index 2e6141722cd8c..3cc98bdd7e70e 100644 --- a/compiler/rustc_abi/src/lib.rs +++ b/compiler/rustc_abi/src/lib.rs @@ -53,7 +53,7 @@ use rustc_errors::{Diag, DiagCtxtHandle, Diagnostic, EmissionGuarantee, Level, m use rustc_hashes::Hash64; use rustc_index::{Idx, IndexSlice, IndexVec}; #[cfg(feature = "nightly")] -use rustc_macros::{Decodable_NoContext, Encodable_NoContext, HashStable}; +use rustc_macros::{Decodable_NoContext, Encodable_NoContext, StableHash}; #[cfg(feature = "nightly")] use rustc_span::{Symbol, sym}; @@ -74,7 +74,7 @@ pub use layout::{FIRST_VARIANT, FieldIdx, LayoutCalculator, LayoutCalculatorErro pub use layout::{Layout, TyAbiInterface, TyAndLayout}; #[derive(Clone, Copy, PartialEq, Eq, Default)] -#[cfg_attr(feature = "nightly", derive(Encodable_NoContext, Decodable_NoContext, HashStable))] +#[cfg_attr(feature = "nightly", derive(Encodable_NoContext, Decodable_NoContext, StableHash))] pub struct ReprFlags(u8); bitflags! { @@ -111,7 +111,7 @@ impl std::fmt::Debug for ReprFlags { } #[derive(Copy, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "nightly", derive(Encodable_NoContext, Decodable_NoContext, HashStable))] +#[cfg_attr(feature = "nightly", derive(Encodable_NoContext, Decodable_NoContext, StableHash))] pub enum IntegerType { /// Pointer-sized integer type, i.e. `isize` and `usize`. The field shows signedness, e.g. /// `Pointer(true)` means `isize`. @@ -131,7 +131,7 @@ impl IntegerType { } #[derive(Copy, Clone, Debug, Eq, PartialEq)] -#[cfg_attr(feature = "nightly", derive(Encodable_NoContext, Decodable_NoContext, HashStable))] +#[cfg_attr(feature = "nightly", derive(Encodable_NoContext, Decodable_NoContext, StableHash))] pub enum ScalableElt { /// `N` in `rustc_scalable_vector(N)` - the element count of the scalable vector ElementCount(u16), @@ -142,7 +142,7 @@ pub enum ScalableElt { /// Represents the repr options provided by the user. #[derive(Copy, Clone, Debug, Eq, PartialEq, Default)] -#[cfg_attr(feature = "nightly", derive(Encodable_NoContext, Decodable_NoContext, HashStable))] +#[cfg_attr(feature = "nightly", derive(Encodable_NoContext, Decodable_NoContext, StableHash))] pub struct ReprOptions { pub int: Option, pub align: Option, @@ -792,7 +792,7 @@ impl FromStr for Endian { /// Size of a type in bytes. #[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)] -#[cfg_attr(feature = "nightly", derive(Encodable_NoContext, Decodable_NoContext, HashStable))] +#[cfg_attr(feature = "nightly", derive(Encodable_NoContext, Decodable_NoContext, StableHash))] pub struct Size { raw: u64, } @@ -1017,7 +1017,7 @@ impl Step for Size { /// Alignment of a type in bytes (always a power of two). #[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)] -#[cfg_attr(feature = "nightly", derive(Encodable_NoContext, Decodable_NoContext, HashStable))] +#[cfg_attr(feature = "nightly", derive(Encodable_NoContext, Decodable_NoContext, StableHash))] pub struct Align { pow2: u8, } @@ -1150,7 +1150,7 @@ impl Align { /// An example of a rare thing actually affected by preferred alignment is aligning of statics. /// It is of effectively no consequence for layout in structs and on the stack. #[derive(Copy, Clone, PartialEq, Eq, Hash, Debug)] -#[cfg_attr(feature = "nightly", derive(HashStable))] +#[cfg_attr(feature = "nightly", derive(StableHash))] pub struct AbiAlign { pub abi: Align, } @@ -1182,7 +1182,7 @@ impl Deref for AbiAlign { /// Integers, also used for enum discriminants. #[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Debug)] -#[cfg_attr(feature = "nightly", derive(Encodable_NoContext, Decodable_NoContext, HashStable))] +#[cfg_attr(feature = "nightly", derive(Encodable_NoContext, Decodable_NoContext, StableHash))] pub enum Integer { I8, I16, @@ -1342,7 +1342,7 @@ impl Integer { /// Floating-point types. #[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Debug)] -#[cfg_attr(feature = "nightly", derive(HashStable))] +#[cfg_attr(feature = "nightly", derive(StableHash))] pub enum Float { F16, F32, @@ -1377,7 +1377,7 @@ impl Float { /// Fundamental unit of memory access and layout. #[derive(Copy, Clone, PartialEq, Eq, Hash, Debug)] -#[cfg_attr(feature = "nightly", derive(HashStable))] +#[cfg_attr(feature = "nightly", derive(StableHash))] pub enum Primitive { /// The `bool` is the signedness of the `Integer` type. /// @@ -1425,7 +1425,7 @@ impl Primitive { /// /// This is intended specifically to mirror LLVM’s `!range` metadata semantics. #[derive(Clone, Copy, PartialEq, Eq, Hash)] -#[cfg_attr(feature = "nightly", derive(HashStable))] +#[cfg_attr(feature = "nightly", derive(StableHash))] pub struct WrappingRange { pub start: u128, pub end: u128, @@ -1537,7 +1537,7 @@ impl fmt::Debug for WrappingRange { /// Information about one scalar component of a Rust type. #[derive(Clone, Copy, PartialEq, Eq, Hash, Debug)] -#[cfg_attr(feature = "nightly", derive(HashStable))] +#[cfg_attr(feature = "nightly", derive(StableHash))] pub enum Scalar { Initialized { value: Primitive, @@ -1641,7 +1641,7 @@ impl Scalar { // NOTE: This struct is generic over the FieldIdx for rust-analyzer usage. /// Describes how the fields of a type are located in memory. #[derive(PartialEq, Eq, Hash, Clone, Debug)] -#[cfg_attr(feature = "nightly", derive(HashStable))] +#[cfg_attr(feature = "nightly", derive(StableHash))] pub enum FieldsShape { /// Scalar primitives and `!`, which never have fields. Primitive, @@ -1726,7 +1726,7 @@ impl FieldsShape { /// should operate on. Special address spaces have an effect on code generation, /// depending on the target and the address spaces it implements. #[derive(Copy, Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)] -#[cfg_attr(feature = "nightly", derive(HashStable))] +#[cfg_attr(feature = "nightly", derive(StableHash))] pub struct AddressSpace(pub u32); impl AddressSpace { @@ -1739,7 +1739,7 @@ impl AddressSpace { /// How many scalable vectors are in a `BackendRepr::ScalableVector`? #[derive(Clone, Copy, PartialEq, Eq, Hash, Debug)] -#[cfg_attr(feature = "nightly", derive(HashStable))] +#[cfg_attr(feature = "nightly", derive(StableHash))] pub struct NumScalableVectors(pub u8); impl NumScalableVectors { @@ -1788,7 +1788,7 @@ impl IntoDiagArg for NumScalableVectors { /// Generally, a codegen backend will prefer to handle smaller values as a scalar or short vector, /// and larger values will usually prefer to be represented as memory. #[derive(Clone, Copy, PartialEq, Eq, Hash, Debug)] -#[cfg_attr(feature = "nightly", derive(HashStable))] +#[cfg_attr(feature = "nightly", derive(StableHash))] pub enum BackendRepr { Scalar(Scalar), ScalarPair(Scalar, Scalar), @@ -1932,7 +1932,7 @@ impl BackendRepr { // NOTE: This struct is generic over the FieldIdx and VariantIdx for rust-analyzer usage. #[derive(PartialEq, Eq, Hash, Clone, Debug)] -#[cfg_attr(feature = "nightly", derive(HashStable))] +#[cfg_attr(feature = "nightly", derive(StableHash))] pub enum Variants { /// A type with no valid variants. Must be uninhabited. Empty, @@ -1959,7 +1959,7 @@ pub enum Variants { // NOTE: This struct is generic over the VariantIdx for rust-analyzer usage. #[derive(PartialEq, Eq, Hash, Clone, Debug)] -#[cfg_attr(feature = "nightly", derive(HashStable))] +#[cfg_attr(feature = "nightly", derive(StableHash))] pub enum TagEncoding { /// The tag directly stores the discriminant, but possibly with a smaller layout /// (so converting the tag to the discriminant can require sign extension). @@ -2000,7 +2000,7 @@ pub enum TagEncoding { } #[derive(Clone, Copy, PartialEq, Eq, Hash, Debug)] -#[cfg_attr(feature = "nightly", derive(HashStable))] +#[cfg_attr(feature = "nightly", derive(StableHash))] pub struct Niche { pub offset: Size, pub value: Primitive, @@ -2097,7 +2097,7 @@ impl Niche { // NOTE: This struct is generic over the FieldIdx and VariantIdx for rust-analyzer usage. #[derive(PartialEq, Eq, Hash, Clone)] -#[cfg_attr(feature = "nightly", derive(HashStable))] +#[cfg_attr(feature = "nightly", derive(StableHash))] pub struct LayoutData { /// Says where the fields are located within the layout. pub fields: FieldsShape, diff --git a/compiler/rustc_ast/src/ast.rs b/compiler/rustc_ast/src/ast.rs index 490e38ca729e9..b105a97cdf98d 100644 --- a/compiler/rustc_ast/src/ast.rs +++ b/compiler/rustc_ast/src/ast.rs @@ -25,10 +25,10 @@ pub use GenericArgs::*; pub use UnsafeSource::*; pub use rustc_ast_ir::{FloatTy, IntTy, Movability, Mutability, Pinnedness, UintTy}; use rustc_data_structures::packed::Pu128; -use rustc_data_structures::stable_hasher::{HashStable, StableHashCtxt, StableHasher}; +use rustc_data_structures::stable_hasher::{StableHash, StableHashCtxt, StableHasher}; use rustc_data_structures::stack::ensure_sufficient_stack; use rustc_data_structures::tagged_ptr::Tag; -use rustc_macros::{Decodable, Encodable, HashStable, Walkable}; +use rustc_macros::{Decodable, Encodable, StableHash, Walkable}; pub use rustc_span::AttrId; use rustc_span::{ ByteSymbol, DUMMY_SP, ErrorGuaranteed, Ident, Span, Spanned, Symbol, kw, respan, sym, @@ -52,7 +52,7 @@ use crate::visit::{AssocCtxt, BoundKind, LifetimeCtxt}; /// ``` /// /// `'outer` is a label. -#[derive(Clone, Encodable, Decodable, Copy, HashStable, Eq, PartialEq, Walkable)] +#[derive(Clone, Encodable, Decodable, Copy, StableHash, Eq, PartialEq, Walkable)] pub struct Label { pub ident: Ident, } @@ -120,7 +120,7 @@ impl PartialEq<&[Symbol]> for Path { } } -impl HashStable for Path { +impl StableHash for Path { fn stable_hash(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { self.segments.len().stable_hash(hcx, hasher); for segment in &self.segments { @@ -564,7 +564,7 @@ pub struct Crate { /// for most built-in attributes. /// /// E.g., `#[test]`, `#[derive(..)]`, `#[rustfmt::skip]` or `#[feature = "foo"]`. -#[derive(Clone, Encodable, Decodable, Debug, HashStable)] +#[derive(Clone, Encodable, Decodable, Debug, StableHash)] pub struct MetaItem { pub unsafety: Safety, pub path: Path, @@ -573,7 +573,7 @@ pub struct MetaItem { } /// The meta item kind, containing the data after the initial path. -#[derive(Clone, Encodable, Decodable, Debug, HashStable)] +#[derive(Clone, Encodable, Decodable, Debug, StableHash)] pub enum MetaItemKind { /// Word meta item. /// @@ -594,7 +594,7 @@ pub enum MetaItemKind { /// Values inside meta item lists. /// /// E.g., each of `Clone`, `Copy` in `#[derive(Clone, Copy)]`. -#[derive(Clone, Encodable, Decodable, Debug, HashStable)] +#[derive(Clone, Encodable, Decodable, Debug, StableHash)] pub enum MetaItemInner { /// A full MetaItem, for recursive meta items. MetaItem(MetaItem), @@ -792,7 +792,7 @@ pub struct PatField { } #[derive(Clone, Copy, Debug, Eq, PartialEq)] -#[derive(Encodable, Decodable, HashStable, Walkable)] +#[derive(Encodable, Decodable, StableHash, Walkable)] pub enum ByRef { Yes(Pinnedness, Mutability), No, @@ -814,7 +814,7 @@ impl ByRef { /// `.0` is the by-reference mode (`ref`, `ref mut`, or by value), /// `.1` is the mutability of the binding. #[derive(Clone, Copy, Debug, Eq, PartialEq)] -#[derive(Encodable, Decodable, HashStable, Walkable)] +#[derive(Encodable, Decodable, StableHash, Walkable)] pub struct BindingMode(pub ByRef, pub Mutability); impl BindingMode { @@ -964,7 +964,7 @@ pub enum PatFieldsRest { /// The kind of borrow in an `AddrOf` expression, /// e.g., `&place` or `&raw const place`. #[derive(Clone, Copy, PartialEq, Eq, Debug)] -#[derive(Encodable, Decodable, HashStable, Walkable)] +#[derive(Encodable, Decodable, StableHash, Walkable)] pub enum BorrowKind { /// A normal borrow, `&$expr` or `&mut $expr`. /// The resulting type is either `&'a T` or `&'a mut T` @@ -980,7 +980,7 @@ pub enum BorrowKind { Pin, } -#[derive(Clone, Copy, Debug, PartialEq, Encodable, Decodable, HashStable, Walkable)] +#[derive(Clone, Copy, Debug, PartialEq, Encodable, Decodable, StableHash, Walkable)] pub enum BinOpKind { /// The `+` operator (addition) Add, @@ -1110,7 +1110,7 @@ impl From for BinOpKind { } } -#[derive(Clone, Copy, Debug, PartialEq, Encodable, Decodable, HashStable, Walkable)] +#[derive(Clone, Copy, Debug, PartialEq, Encodable, Decodable, StableHash, Walkable)] pub enum AssignOpKind { /// The `+=` operator (addition) AddAssign, @@ -1162,7 +1162,7 @@ pub type AssignOp = Spanned; /// Unary operator. /// /// Note that `&data` is not an operator, it's an `AddrOf` expression. -#[derive(Clone, Copy, Debug, PartialEq, Encodable, Decodable, HashStable, Walkable)] +#[derive(Clone, Copy, Debug, PartialEq, Encodable, Decodable, StableHash, Walkable)] pub enum UnOp { /// The `*` operator for dereferencing Deref, @@ -1961,7 +1961,7 @@ impl GenBlockKind { /// Whether we're unwrapping or wrapping an unsafe binder #[derive(Copy, Clone, Debug, PartialEq, Eq, Hash)] -#[derive(Encodable, Decodable, HashStable, Walkable)] +#[derive(Encodable, Decodable, StableHash, Walkable)] pub enum UnsafeBinderCastKind { // e.g. `&i32` -> `unsafe<'a> &'a i32` Wrap, @@ -1995,7 +1995,7 @@ pub struct QSelf { } /// A capture clause used in closures and `async` blocks. -#[derive(Clone, Copy, PartialEq, Encodable, Decodable, Debug, HashStable, Walkable)] +#[derive(Clone, Copy, PartialEq, Encodable, Decodable, Debug, StableHash, Walkable)] pub enum CaptureBy { /// `move |x| y + x`. Value { @@ -2090,7 +2090,7 @@ impl AttrArgs { } /// Delimited arguments, as used in `#[attr()/[]/{}]` or `mac!()/[]/{}`. -#[derive(Clone, Encodable, Decodable, Debug, HashStable, Walkable)] +#[derive(Clone, Encodable, Decodable, Debug, StableHash, Walkable)] pub struct DelimArgs { pub dspan: DelimSpan, pub delim: Delimiter, // Note: `Delimiter::Invisible` never occurs @@ -2106,7 +2106,7 @@ impl DelimArgs { } /// Represents a macro definition. -#[derive(Clone, Encodable, Decodable, Debug, HashStable, Walkable)] +#[derive(Clone, Encodable, Decodable, Debug, StableHash, Walkable)] pub struct MacroDef { pub body: Box, /// `true` if macro was defined with `macro_rules`. @@ -2120,7 +2120,7 @@ pub struct MacroDef { pub eii_declaration: Option, } -#[derive(Clone, Encodable, Decodable, Debug, HashStable, Walkable)] +#[derive(Clone, Encodable, Decodable, Debug, StableHash, Walkable)] pub struct EiiDecl { /// path to the extern item we're targeting pub foreign_item: Path, @@ -2128,7 +2128,7 @@ pub struct EiiDecl { } #[derive(Clone, Encodable, Decodable, Debug, Copy, Hash, Eq, PartialEq)] -#[derive(HashStable, Walkable)] +#[derive(StableHash, Walkable)] pub enum StrStyle { /// A regular string, like `"foo"`. Cooked, @@ -2186,7 +2186,7 @@ impl YieldKind { } /// A literal in a meta item. -#[derive(Clone, Copy, Encodable, Decodable, Debug, HashStable)] +#[derive(Clone, Copy, Encodable, Decodable, Debug, StableHash)] pub struct MetaItemLit { /// The original literal as written in the source code. pub symbol: Symbol, @@ -2223,7 +2223,7 @@ impl StrLit { /// Type of the integer literal based on provided suffix. #[derive(Clone, Copy, Encodable, Decodable, Debug, Hash, Eq, PartialEq)] -#[derive(HashStable)] +#[derive(StableHash)] pub enum LitIntType { /// e.g. `42_i32`. Signed(IntTy), @@ -2235,7 +2235,7 @@ pub enum LitIntType { /// Type of the float literal based on provided suffix. #[derive(Clone, Copy, Encodable, Decodable, Debug, Hash, Eq, PartialEq)] -#[derive(HashStable)] +#[derive(StableHash)] pub enum LitFloatType { /// A float literal with a suffix (`1f32` or `1E10f32`). Suffixed(FloatTy), @@ -2249,7 +2249,7 @@ pub enum LitFloatType { /// deciding the `LitKind`. This means that float literals like `1f32` are /// classified by this type as `Float`. This is different to `token::LitKind` /// which does *not* consider the suffix. -#[derive(Clone, Copy, Encodable, Decodable, Debug, Hash, Eq, PartialEq, HashStable)] +#[derive(Clone, Copy, Encodable, Decodable, Debug, Hash, Eq, PartialEq, StableHash)] pub enum LitKind { /// A string literal (`"foo"`). The symbol is unescaped, and so may differ /// from the original token's symbol. @@ -2652,7 +2652,7 @@ pub enum TyPatKind { } /// Syntax used to declare a trait object. -#[derive(Clone, Copy, PartialEq, Encodable, Decodable, Debug, HashStable, Walkable)] +#[derive(Clone, Copy, PartialEq, Encodable, Decodable, Debug, StableHash, Walkable)] #[repr(u8)] pub enum TraitObjectSyntax { // SAFETY: When adding new variants make sure to update the `Tag` impl. @@ -2696,7 +2696,7 @@ pub enum InlineAsmRegOrRegClass { RegClass(Symbol), } -#[derive(Clone, Copy, PartialEq, Eq, Hash, Encodable, Decodable, HashStable)] +#[derive(Clone, Copy, PartialEq, Eq, Hash, Encodable, Decodable, StableHash)] pub struct InlineAsmOptions(u16); bitflags::bitflags! { impl InlineAsmOptions: u16 { @@ -2759,7 +2759,7 @@ impl std::fmt::Debug for InlineAsmOptions { } } -#[derive(Clone, PartialEq, Encodable, Decodable, Debug, Hash, HashStable, Walkable)] +#[derive(Clone, PartialEq, Encodable, Decodable, Debug, Hash, StableHash, Walkable)] pub enum InlineAsmTemplatePiece { String(Cow<'static, str>), Placeholder { operand_idx: usize, modifier: Option, span: Span }, @@ -2862,7 +2862,7 @@ impl InlineAsmOperand { } } -#[derive(Clone, Copy, Encodable, Decodable, Debug, HashStable, Walkable, PartialEq, Eq)] +#[derive(Clone, Copy, Encodable, Decodable, Debug, StableHash, Walkable, PartialEq, Eq)] pub enum AsmMacro { /// The `asm!` macro Asm, @@ -3060,7 +3060,7 @@ impl FnDecl { } /// Is the trait definition an auto trait? -#[derive(Copy, Clone, PartialEq, Encodable, Decodable, Debug, HashStable, Walkable)] +#[derive(Copy, Clone, PartialEq, Encodable, Decodable, Debug, StableHash, Walkable)] pub enum IsAuto { Yes, No, @@ -3068,7 +3068,7 @@ pub enum IsAuto { /// Safety of items. #[derive(Copy, Clone, PartialEq, Eq, Hash, Encodable, Decodable, Debug)] -#[derive(HashStable, Walkable)] +#[derive(StableHash, Walkable)] pub enum Safety { /// `unsafe` an item is explicitly marked as `unsafe`. Unsafe(Span), @@ -3133,7 +3133,7 @@ impl CoroutineKind { } #[derive(Copy, Clone, PartialEq, Eq, Hash, Encodable, Decodable, Debug)] -#[derive(HashStable, Walkable)] +#[derive(StableHash, Walkable)] pub enum Const { Yes(Span), No, @@ -3141,7 +3141,7 @@ pub enum Const { /// Item defaultness. /// For details see the [RFC #2532](https://github.com/rust-lang/rfcs/pull/2532). -#[derive(Copy, Clone, PartialEq, Encodable, Decodable, Debug, HashStable, Walkable)] +#[derive(Copy, Clone, PartialEq, Encodable, Decodable, Debug, StableHash, Walkable)] pub enum Defaultness { /// Item is unmarked. Implicitly determined based off of position. /// For impls, this is `final`; for traits, this is `default`. @@ -3155,7 +3155,7 @@ pub enum Defaultness { Final(Span), } -#[derive(Copy, Clone, PartialEq, Encodable, Decodable, HashStable, Walkable)] +#[derive(Copy, Clone, PartialEq, Encodable, Decodable, StableHash, Walkable)] pub enum ImplPolarity { /// `impl Trait for Type` Positive, @@ -3174,7 +3174,7 @@ impl fmt::Debug for ImplPolarity { /// The polarity of a trait bound. #[derive(Copy, Clone, PartialEq, Eq, Encodable, Decodable, Debug, Hash)] -#[derive(HashStable, Walkable)] +#[derive(StableHash, Walkable)] pub enum BoundPolarity { /// `Type: Trait` Positive, @@ -3196,7 +3196,7 @@ impl BoundPolarity { /// The constness of a trait bound. #[derive(Copy, Clone, PartialEq, Eq, Encodable, Decodable, Debug, Hash)] -#[derive(HashStable, Walkable)] +#[derive(StableHash, Walkable)] pub enum BoundConstness { /// `Type: Trait` Never, @@ -3218,7 +3218,7 @@ impl BoundConstness { /// The asyncness of a trait bound. #[derive(Copy, Clone, PartialEq, Eq, Encodable, Decodable, Debug)] -#[derive(HashStable, Walkable)] +#[derive(StableHash, Walkable)] pub enum BoundAsyncness { /// `Type: Trait` Normal, @@ -3387,7 +3387,7 @@ impl UseTree { /// are contained as statements within items. These two cases need to be /// distinguished for pretty-printing. #[derive(Clone, PartialEq, Eq, Hash, Debug, Copy)] -#[derive(Encodable, Decodable, HashStable, Walkable)] +#[derive(Encodable, Decodable, StableHash, Walkable)] pub enum AttrStyle { Outer, Inner, @@ -3484,7 +3484,7 @@ impl AttrItemKind { /// /// Currently all early parsed attributes are excluded from pretty printing at rustc_ast_pretty::pprust::state::print_attribute_inline. /// When adding new early parsed attributes, consider whether they should be pretty printed. -#[derive(Clone, Encodable, Decodable, Debug, HashStable)] +#[derive(Clone, Encodable, Decodable, Debug, StableHash)] pub enum EarlyParsedAttribute { CfgTrace(CfgEntry), CfgAttrTrace, @@ -3607,7 +3607,7 @@ pub struct FieldDef { } /// Was parsing recovery performed? -#[derive(Copy, Clone, Debug, Encodable, Decodable, HashStable, Walkable)] +#[derive(Copy, Clone, Debug, Encodable, Decodable, StableHash, Walkable)] pub enum Recovered { No, Yes(ErrorGuaranteed), diff --git a/compiler/rustc_ast/src/attr/data_structures.rs b/compiler/rustc_ast/src/attr/data_structures.rs index 36d0352b7f8a0..bc960deda1b89 100644 --- a/compiler/rustc_ast/src/attr/data_structures.rs +++ b/compiler/rustc_ast/src/attr/data_structures.rs @@ -1,12 +1,12 @@ use std::fmt; -use rustc_macros::{Decodable, Encodable, HashStable}; +use rustc_macros::{Decodable, Encodable, StableHash}; use rustc_span::{Span, Symbol}; use thin_vec::ThinVec; use crate::attr::version::RustcVersion; -#[derive(Encodable, Decodable, Clone, Debug, PartialEq, Eq, Hash, HashStable)] +#[derive(Encodable, Decodable, Clone, Debug, PartialEq, Eq, Hash, StableHash)] pub enum CfgEntry { All(ThinVec, Span), Any(ThinVec, Span), diff --git a/compiler/rustc_ast/src/attr/version.rs b/compiler/rustc_ast/src/attr/version.rs index c695ba5b8a057..506a7a291813c 100644 --- a/compiler/rustc_ast/src/attr/version.rs +++ b/compiler/rustc_ast/src/attr/version.rs @@ -1,10 +1,10 @@ use std::fmt::{self, Display}; use std::sync::OnceLock; -use rustc_macros::{BlobDecodable, Encodable, HashStable, current_rustc_version}; +use rustc_macros::{BlobDecodable, Encodable, StableHash, current_rustc_version}; #[derive(Encodable, BlobDecodable, Copy, Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)] -#[derive(HashStable)] +#[derive(StableHash)] pub struct RustcVersion { pub major: u16, pub minor: u16, diff --git a/compiler/rustc_ast/src/expand/allocator.rs b/compiler/rustc_ast/src/expand/allocator.rs index 874534b876521..9a79fa1fbe55e 100644 --- a/compiler/rustc_ast/src/expand/allocator.rs +++ b/compiler/rustc_ast/src/expand/allocator.rs @@ -1,7 +1,7 @@ -use rustc_macros::HashStable; +use rustc_macros::StableHash; use rustc_span::{Symbol, sym}; -#[derive(Clone, Debug, Copy, Eq, PartialEq, HashStable)] +#[derive(Clone, Debug, Copy, Eq, PartialEq, StableHash)] pub enum AllocatorKind { /// Use `#[global_allocator]` as global allocator. Global, diff --git a/compiler/rustc_ast/src/expand/autodiff_attrs.rs b/compiler/rustc_ast/src/expand/autodiff_attrs.rs index a1967ba8db322..c9a3275c4c97f 100644 --- a/compiler/rustc_ast/src/expand/autodiff_attrs.rs +++ b/compiler/rustc_ast/src/expand/autodiff_attrs.rs @@ -8,7 +8,7 @@ use std::str::FromStr; use rustc_span::{Symbol, sym}; -use crate::expand::{Decodable, Encodable, HashStable}; +use crate::expand::{Decodable, Encodable, StableHash}; use crate::{Ty, TyKind}; /// Forward and Reverse Mode are well known names for automatic differentiation implementations. @@ -20,7 +20,7 @@ use crate::{Ty, TyKind}; /// /// Documentation for using [reverse](https://enzyme.mit.edu/rust/rev.html) and /// [forward](https://enzyme.mit.edu/rust/fwd.html) mode is available online. -#[derive(Clone, Copy, Eq, PartialEq, Encodable, Decodable, Debug, HashStable)] +#[derive(Clone, Copy, Eq, PartialEq, Encodable, Decodable, Debug, StableHash)] pub enum DiffMode { /// No autodiff is applied (used during error handling). Error, @@ -42,7 +42,7 @@ impl DiffMode { /// However, under forward mode we overwrite the previous shadow value, while for reverse mode /// we add to the previous shadow value. To not surprise users, we picked different names. /// Dual numbers is also a quite well known name for forward mode AD types. -#[derive(Clone, Copy, Eq, PartialEq, Encodable, Decodable, Debug, HashStable)] +#[derive(Clone, Copy, Eq, PartialEq, Encodable, Decodable, Debug, StableHash)] pub enum DiffActivity { /// Implicit or Explicit () return type, so a special case of Const. None, diff --git a/compiler/rustc_ast/src/expand/mod.rs b/compiler/rustc_ast/src/expand/mod.rs index e5abb651c0800..1eeb4a8ec848e 100644 --- a/compiler/rustc_ast/src/expand/mod.rs +++ b/compiler/rustc_ast/src/expand/mod.rs @@ -1,6 +1,6 @@ //! Definitions shared by macros / syntax extensions and e.g. `rustc_middle`. -use rustc_macros::{Decodable, Encodable, HashStable}; +use rustc_macros::{Decodable, Encodable, StableHash}; pub mod allocator; pub mod autodiff_attrs; diff --git a/compiler/rustc_ast/src/expand/typetree.rs b/compiler/rustc_ast/src/expand/typetree.rs index 3c1dd69f6c559..9619c80904426 100644 --- a/compiler/rustc_ast/src/expand/typetree.rs +++ b/compiler/rustc_ast/src/expand/typetree.rs @@ -21,9 +21,9 @@ use std::fmt; -use crate::expand::{Decodable, Encodable, HashStable}; +use crate::expand::{Decodable, Encodable, StableHash}; -#[derive(Clone, Copy, Eq, PartialEq, Encodable, Decodable, Debug, HashStable)] +#[derive(Clone, Copy, Eq, PartialEq, Encodable, Decodable, Debug, StableHash)] pub enum Kind { Anything, Integer, @@ -35,7 +35,7 @@ pub enum Kind { Unknown, } -#[derive(Clone, Eq, PartialEq, Encodable, Decodable, Debug, HashStable)] +#[derive(Clone, Eq, PartialEq, Encodable, Decodable, Debug, StableHash)] pub struct TypeTree(pub Vec); impl TypeTree { @@ -59,13 +59,13 @@ impl TypeTree { } } -#[derive(Clone, Eq, PartialEq, Encodable, Decodable, Debug, HashStable)] +#[derive(Clone, Eq, PartialEq, Encodable, Decodable, Debug, StableHash)] pub struct FncTree { pub args: Vec, pub ret: TypeTree, } -#[derive(Clone, Eq, PartialEq, Encodable, Decodable, Debug, HashStable)] +#[derive(Clone, Eq, PartialEq, Encodable, Decodable, Debug, StableHash)] pub struct Type { pub offset: isize, pub size: usize, diff --git a/compiler/rustc_ast/src/node_id.rs b/compiler/rustc_ast/src/node_id.rs index a23bf268852ee..13783350ea29f 100644 --- a/compiler/rustc_ast/src/node_id.rs +++ b/compiler/rustc_ast/src/node_id.rs @@ -1,6 +1,6 @@ use std::fmt; -use rustc_data_structures::stable_hasher::{HashStable, StableHashCtxt, StableHasher}; +use rustc_data_structures::stable_hasher::{StableHash, StableHashCtxt, StableHasher}; use rustc_span::LocalExpnId; rustc_index::newtype_index! { @@ -19,10 +19,10 @@ rustc_index::newtype_index! { } } -impl HashStable for NodeId { +impl StableHash for NodeId { #[inline] fn stable_hash(&self, _: &mut Hcx, _: &mut StableHasher) { - // This impl is never called but is necessary for types implementing `HashStable` such as + // This impl is never called but is necessary for types implementing `StableHash` such as // `MainDefinition` and `DocLinkResMap` (both of which occur in `ResolverGlobalCtxt`). panic!("Node IDs should not appear in incremental state"); } diff --git a/compiler/rustc_ast/src/token.rs b/compiler/rustc_ast/src/token.rs index 9f148f87dfba8..743e60d2f3bb2 100644 --- a/compiler/rustc_ast/src/token.rs +++ b/compiler/rustc_ast/src/token.rs @@ -5,7 +5,7 @@ pub use LitKind::*; pub use NtExprKind::*; pub use NtPatKind::*; pub use TokenKind::*; -use rustc_macros::{Decodable, Encodable, HashStable}; +use rustc_macros::{Decodable, Encodable, StableHash}; use rustc_span::edition::Edition; use rustc_span::symbol::IdentPrintMode; use rustc_span::{DUMMY_SP, ErrorGuaranteed, Span, kw, sym}; @@ -17,7 +17,7 @@ use crate::ast; use crate::util::case::Case; /// Represents the kind of doc comment it is, ie `///` or `#[doc = ""]`. -#[derive(Clone, Copy, PartialEq, Eq, Encodable, Decodable, Debug, HashStable)] +#[derive(Clone, Copy, PartialEq, Eq, Encodable, Decodable, Debug, StableHash)] pub enum DocFragmentKind { /// A sugared doc comment: `///` or `//!` or `/**` or `/*!`. Sugared(CommentKind), @@ -40,13 +40,13 @@ impl DocFragmentKind { } } -#[derive(Clone, Copy, PartialEq, Eq, Hash, Encodable, Decodable, Debug, HashStable)] +#[derive(Clone, Copy, PartialEq, Eq, Hash, Encodable, Decodable, Debug, StableHash)] pub enum CommentKind { Line, Block, } -#[derive(Copy, Clone, PartialEq, Eq, Hash, Debug, Encodable, Decodable, HashStable)] +#[derive(Copy, Clone, PartialEq, Eq, Hash, Debug, Encodable, Decodable, StableHash)] pub enum InvisibleOrigin { // From the expansion of a metavariable in a declarative macro. MetaVar(MetaVarKind), @@ -69,7 +69,7 @@ impl InvisibleOrigin { } /// Annoyingly similar to `NonterminalKind`, but the slight differences are important. -#[derive(Debug, Copy, Clone, PartialEq, Eq, Encodable, Decodable, Hash, HashStable)] +#[derive(Debug, Copy, Clone, PartialEq, Eq, Encodable, Decodable, Hash, StableHash)] pub enum MetaVarKind { Item, Block, @@ -125,7 +125,7 @@ impl fmt::Display for MetaVarKind { /// Describes how a sequence of token trees is delimited. /// Cannot use `proc_macro::Delimiter` directly because this /// structure should implement some additional traits. -#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash, Encodable, Decodable, HashStable)] +#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash, Encodable, Decodable, StableHash)] pub enum Delimiter { /// `( ... )` Parenthesis, @@ -188,7 +188,7 @@ impl Delimiter { // type. This means that float literals like `1f32` are classified by this type // as `Int`. Only upon conversion to `ast::LitKind` will such a literal be // given the `Float` kind. -#[derive(Clone, Copy, PartialEq, Eq, Hash, Encodable, Decodable, Debug, HashStable)] +#[derive(Clone, Copy, PartialEq, Eq, Hash, Encodable, Decodable, Debug, StableHash)] pub enum LitKind { Bool, // AST only, must never appear in a `Token` Byte, @@ -205,7 +205,7 @@ pub enum LitKind { } /// A literal token. -#[derive(Clone, Copy, PartialEq, Eq, Hash, Encodable, Decodable, Debug, HashStable)] +#[derive(Clone, Copy, PartialEq, Eq, Hash, Encodable, Decodable, Debug, StableHash)] pub struct Lit { pub kind: LitKind, pub symbol: Symbol, @@ -351,7 +351,7 @@ fn ident_can_begin_type(name: Symbol, span: Span, is_raw: IdentIsRaw) -> bool { .contains(&name) } -#[derive(PartialEq, Eq, Encodable, Decodable, Hash, Debug, Copy, Clone, HashStable)] +#[derive(PartialEq, Eq, Encodable, Decodable, Hash, Debug, Copy, Clone, StableHash)] pub enum IdentIsRaw { No, Yes, @@ -378,7 +378,7 @@ impl From for IdentIsRaw { } } -#[derive(Clone, Copy, PartialEq, Eq, Hash, Encodable, Decodable, Debug, HashStable)] +#[derive(Clone, Copy, PartialEq, Eq, Hash, Encodable, Decodable, Debug, StableHash)] pub enum TokenKind { /* Expression-operator symbols. */ /// `=` @@ -528,7 +528,7 @@ pub enum TokenKind { Eof, } -#[derive(Clone, Copy, PartialEq, Eq, Hash, Encodable, Decodable, Debug, HashStable)] +#[derive(Clone, Copy, PartialEq, Eq, Hash, Encodable, Decodable, Debug, StableHash)] pub struct Token { pub kind: TokenKind, pub span: Span, @@ -1090,7 +1090,7 @@ impl PartialEq for Token { } } -#[derive(Debug, Copy, Clone, PartialEq, Eq, Encodable, Decodable, Hash, HashStable)] +#[derive(Debug, Copy, Clone, PartialEq, Eq, Encodable, Decodable, Hash, StableHash)] pub enum NtPatKind { // Matches or-patterns. Was written using `pat` in edition 2021 or later. PatWithOr, @@ -1100,7 +1100,7 @@ pub enum NtPatKind { PatParam { inferred: bool }, } -#[derive(Debug, Copy, Clone, PartialEq, Eq, Encodable, Decodable, Hash, HashStable)] +#[derive(Debug, Copy, Clone, PartialEq, Eq, Encodable, Decodable, Hash, StableHash)] pub enum NtExprKind { // Matches expressions using the post-edition 2024. Was written using // `expr` in edition 2024 or later. @@ -1112,7 +1112,7 @@ pub enum NtExprKind { } /// A macro nonterminal, known in documentation as a fragment specifier. -#[derive(Debug, Copy, Clone, PartialEq, Eq, Encodable, Decodable, Hash, HashStable)] +#[derive(Debug, Copy, Clone, PartialEq, Eq, Encodable, Decodable, Hash, StableHash)] pub enum NonterminalKind { Item, Block, diff --git a/compiler/rustc_ast/src/tokenstream.rs b/compiler/rustc_ast/src/tokenstream.rs index c534b2b1c590f..af5bf14aecce6 100644 --- a/compiler/rustc_ast/src/tokenstream.rs +++ b/compiler/rustc_ast/src/tokenstream.rs @@ -10,9 +10,9 @@ use std::ops::Range; use std::sync::Arc; use std::{cmp, fmt, iter, mem}; -use rustc_data_structures::stable_hasher::{HashStable, StableHashCtxt, StableHasher}; +use rustc_data_structures::stable_hasher::{StableHash, StableHashCtxt, StableHasher}; use rustc_data_structures::sync; -use rustc_macros::{Decodable, Encodable, HashStable, Walkable}; +use rustc_macros::{Decodable, Encodable, StableHash, Walkable}; use rustc_serialize::{Decodable, Encodable}; use rustc_span::{DUMMY_SP, Span, SpanDecoder, SpanEncoder, Symbol, sym}; use thin_vec::ThinVec; @@ -23,7 +23,7 @@ use crate::token::{self, Delimiter, Token, TokenKind}; use crate::{AttrVec, Attribute}; /// Part of a `TokenStream`. -#[derive(Debug, Clone, PartialEq, Eq, Hash, Encodable, Decodable, HashStable)] +#[derive(Debug, Clone, PartialEq, Eq, Hash, Encodable, Decodable, StableHash)] pub enum TokenTree { /// A single token. Should never be `OpenDelim` or `CloseDelim`, because /// delimiters are implicitly represented by `Delimited`. @@ -138,7 +138,7 @@ impl Decodable for LazyAttrTokenStream { } } -impl HashStable for LazyAttrTokenStream { +impl StableHash for LazyAttrTokenStream { fn stable_hash(&self, _hcx: &mut Hcx, _hasher: &mut StableHasher) { panic!("Attempted to compute stable hash for LazyAttrTokenStream"); } @@ -545,7 +545,7 @@ pub struct AttrsTarget { /// compound token. Used for conversions to `proc_macro::Spacing`. Also used to /// guide pretty-printing, which is where the `JointHidden` value (which isn't /// part of `proc_macro::Spacing`) comes in useful. -#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, Encodable, Decodable, HashStable)] +#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, Encodable, Decodable, StableHash)] pub enum Spacing { /// The token cannot join with the following token to form a compound /// token. @@ -824,7 +824,7 @@ impl FromIterator for TokenStream { } } -impl HashStable for TokenStream { +impl StableHash for TokenStream { fn stable_hash(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { for sub_tt in self.iter() { sub_tt.stable_hash(hcx, hasher); @@ -967,7 +967,7 @@ impl TokenCursor { } #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] -#[derive(Encodable, Decodable, HashStable, Walkable)] +#[derive(Encodable, Decodable, StableHash, Walkable)] pub struct DelimSpan { pub open: Span, pub close: Span, @@ -991,7 +991,7 @@ impl DelimSpan { } } -#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash, Encodable, Decodable, HashStable)] +#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash, Encodable, Decodable, StableHash)] pub struct DelimSpacing { pub open: Spacing, pub close: Spacing, diff --git a/compiler/rustc_ast_ir/src/lib.rs b/compiler/rustc_ast_ir/src/lib.rs index f0ba622308670..f90359c515264 100644 --- a/compiler/rustc_ast_ir/src/lib.rs +++ b/compiler/rustc_ast_ir/src/lib.rs @@ -14,14 +14,14 @@ use std::fmt; #[cfg(feature = "nightly")] -use rustc_macros::{Decodable_NoContext, Encodable_NoContext, HashStable}; +use rustc_macros::{Decodable_NoContext, Encodable_NoContext, StableHash}; #[cfg(feature = "nightly")] use rustc_span::{Symbol, sym}; pub mod visit; #[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)] -#[cfg_attr(feature = "nightly", derive(Encodable_NoContext, Decodable_NoContext, HashStable))] +#[cfg_attr(feature = "nightly", derive(Encodable_NoContext, Decodable_NoContext, StableHash))] pub enum IntTy { Isize, I8, @@ -97,7 +97,7 @@ impl fmt::Debug for IntTy { } #[derive(Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Copy)] -#[cfg_attr(feature = "nightly", derive(Encodable_NoContext, Decodable_NoContext, HashStable))] +#[cfg_attr(feature = "nightly", derive(Encodable_NoContext, Decodable_NoContext, StableHash))] pub enum UintTy { Usize, U8, @@ -173,7 +173,7 @@ impl fmt::Debug for UintTy { } #[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)] -#[cfg_attr(feature = "nightly", derive(Encodable_NoContext, Decodable_NoContext, HashStable))] +#[cfg_attr(feature = "nightly", derive(Encodable_NoContext, Decodable_NoContext, StableHash))] pub enum FloatTy { F16, F32, @@ -220,7 +220,7 @@ impl fmt::Debug for FloatTy { /// The movability of a coroutine / closure literal: /// whether a coroutine contains self-references, causing it to be `!Unpin`. #[derive(Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Debug, Copy)] -#[cfg_attr(feature = "nightly", derive(Encodable_NoContext, Decodable_NoContext, HashStable))] +#[cfg_attr(feature = "nightly", derive(Encodable_NoContext, Decodable_NoContext, StableHash))] pub enum Movability { /// May contain self-references, `!Unpin`. Static, @@ -229,7 +229,7 @@ pub enum Movability { } #[derive(Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Debug, Copy)] -#[cfg_attr(feature = "nightly", derive(Encodable_NoContext, Decodable_NoContext, HashStable))] +#[cfg_attr(feature = "nightly", derive(Encodable_NoContext, Decodable_NoContext, StableHash))] pub enum Mutability { // N.B. Order is deliberate, so that Not < Mut Not, @@ -288,7 +288,7 @@ impl Mutability { } #[derive(Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Debug, Copy)] -#[cfg_attr(feature = "nightly", derive(Encodable_NoContext, Decodable_NoContext, HashStable))] +#[cfg_attr(feature = "nightly", derive(Encodable_NoContext, Decodable_NoContext, StableHash))] pub enum Pinnedness { Not, Pinned, diff --git a/compiler/rustc_ast_lowering/src/lib.rs b/compiler/rustc_ast_lowering/src/lib.rs index d11d5e6ddcd2b..3c8abf3ee2bbb 100644 --- a/compiler/rustc_ast_lowering/src/lib.rs +++ b/compiler/rustc_ast_lowering/src/lib.rs @@ -45,7 +45,7 @@ use rustc_attr_parsing::{AttributeParser, OmitDoc, Recovery, ShouldEmit}; use rustc_data_structures::fingerprint::Fingerprint; use rustc_data_structures::fx::FxIndexSet; use rustc_data_structures::sorted_map::SortedMap; -use rustc_data_structures::stable_hasher::{HashStable, StableHasher}; +use rustc_data_structures::stable_hasher::{StableHash, StableHasher}; use rustc_data_structures::steal::Steal; use rustc_data_structures::tagged_ptr::TaggedRef; use rustc_errors::{DiagArgFromDisplay, DiagCtxtHandle}; diff --git a/compiler/rustc_codegen_cranelift/src/driver/aot.rs b/compiler/rustc_codegen_cranelift/src/driver/aot.rs index 60ad076672713..bea254b7b3a6f 100644 --- a/compiler/rustc_codegen_cranelift/src/driver/aot.rs +++ b/compiler/rustc_codegen_cranelift/src/driver/aot.rs @@ -14,7 +14,7 @@ use rustc_codegen_ssa::back::write::produce_final_output_artifacts; use rustc_codegen_ssa::base::determine_cgu_reuse; use rustc_codegen_ssa::{CompiledModule, CompiledModules, ModuleKind}; use rustc_data_structures::profiling::SelfProfilerRef; -use rustc_data_structures::stable_hasher::{HashStable, StableHashCtxt, StableHasher}; +use rustc_data_structures::stable_hasher::{StableHash, StableHashCtxt, StableHasher}; use rustc_data_structures::sync::{IntoDynSyncSend, par_map}; use rustc_hir::attrs::Linkage as RLinkage; use rustc_middle::dep_graph::{WorkProduct, WorkProductId}; @@ -45,7 +45,7 @@ enum OngoingModuleCodegen { Async(JoinHandle>), } -impl HashStable for OngoingModuleCodegen { +impl StableHash for OngoingModuleCodegen { fn stable_hash(&self, _: &mut Hcx, _: &mut StableHasher) { // do nothing } diff --git a/compiler/rustc_codegen_llvm/src/common.rs b/compiler/rustc_codegen_llvm/src/common.rs index b532eb238ac94..988e0c4b0513b 100644 --- a/compiler/rustc_codegen_llvm/src/common.rs +++ b/compiler/rustc_codegen_llvm/src/common.rs @@ -8,7 +8,7 @@ use rustc_abi::{self as abi, HasDataLayout as _}; use rustc_ast::Mutability; use rustc_codegen_ssa::common::TypeKind; use rustc_codegen_ssa::traits::*; -use rustc_data_structures::stable_hasher::{HashStable, StableHasher}; +use rustc_data_structures::stable_hasher::{StableHash, StableHasher}; use rustc_hashes::Hash128; use rustc_hir::def_id::DefId; use rustc_middle::bug; diff --git a/compiler/rustc_codegen_llvm/src/debuginfo/metadata/type_map.rs b/compiler/rustc_codegen_llvm/src/debuginfo/metadata/type_map.rs index b75fe4264239e..984b6b009f038 100644 --- a/compiler/rustc_codegen_llvm/src/debuginfo/metadata/type_map.rs +++ b/compiler/rustc_codegen_llvm/src/debuginfo/metadata/type_map.rs @@ -4,8 +4,8 @@ use libc::c_uint; use rustc_abi::{Align, Size, VariantIdx}; use rustc_data_structures::fingerprint::Fingerprint; use rustc_data_structures::fx::FxHashMap; -use rustc_data_structures::stable_hasher::{HashStable, StableHasher}; -use rustc_macros::HashStable; +use rustc_data_structures::stable_hasher::{StableHash, StableHasher}; +use rustc_macros::StableHash; use rustc_middle::bug; use rustc_middle::ty::{self, ExistentialTraitRef, Ty, TyCtxt, Unnormalized}; @@ -16,13 +16,13 @@ use crate::llvm; use crate::llvm::debuginfo::{DIFlags, DIScope, DIType}; mod private { - use rustc_macros::HashStable; + use rustc_macros::StableHash; // This type cannot be constructed outside of this module because // it has a private field. We make use of this in order to prevent // `UniqueTypeId` from being constructed directly, without asserting // the preconditions. - #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, HashStable)] + #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, StableHash)] pub(crate) struct HiddenZst; } @@ -33,7 +33,7 @@ mod private { /// Note that there are some things that only show up in debuginfo, like /// the separate type descriptions for each enum variant. These get an ID /// too because they have their own debuginfo node in LLVM IR. -#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, HashStable)] +#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, StableHash)] pub(super) enum UniqueTypeId<'tcx> { /// The ID of a regular type as it shows up at the language level. Ty(Ty<'tcx>, private::HiddenZst), diff --git a/compiler/rustc_codegen_ssa/src/common.rs b/compiler/rustc_codegen_ssa/src/common.rs index a900e92a82930..8c962fe4ea6e0 100644 --- a/compiler/rustc_codegen_ssa/src/common.rs +++ b/compiler/rustc_codegen_ssa/src/common.rs @@ -90,19 +90,19 @@ pub enum TypeKind { } // FIXME(mw): Anything that is produced via DepGraph::with_task() must implement -// the HashStable trait. Normally DepGraph::with_task() calls are +// the StableHash trait. Normally DepGraph::with_task() calls are // hidden behind queries, but CGU creation is a special case in two // ways: (1) it's not a query and (2) CGU are output nodes, so their // Fingerprints are not actually needed. It remains to be clarified // how exactly this case will be handled in the red/green system but -// for now we content ourselves with providing a no-op HashStable +// for now we content ourselves with providing a no-op StableHash // implementation for CGUs. mod temp_stable_hash_impls { - use rustc_data_structures::stable_hasher::{HashStable, StableHashCtxt, StableHasher}; + use rustc_data_structures::stable_hasher::{StableHash, StableHashCtxt, StableHasher}; use crate::ModuleCodegen; - impl HashStable for ModuleCodegen { + impl StableHash for ModuleCodegen { fn stable_hash(&self, _: &mut Hcx, _: &mut StableHasher) { // do nothing } diff --git a/compiler/rustc_codegen_ssa/src/debuginfo/type_names.rs b/compiler/rustc_codegen_ssa/src/debuginfo/type_names.rs index 20d556028389d..730272d2be94d 100644 --- a/compiler/rustc_codegen_ssa/src/debuginfo/type_names.rs +++ b/compiler/rustc_codegen_ssa/src/debuginfo/type_names.rs @@ -15,7 +15,7 @@ use std::fmt::Write; use rustc_abi::Integer; use rustc_data_structures::fx::FxHashSet; -use rustc_data_structures::stable_hasher::{HashStable, StableHasher}; +use rustc_data_structures::stable_hasher::{StableHash, StableHasher}; use rustc_hashes::Hash64; use rustc_hir::def_id::DefId; use rustc_hir::definitions::{DefPathData, DefPathDataName, DisambiguatedDefPathData}; diff --git a/compiler/rustc_data_structures/src/intern.rs b/compiler/rustc_data_structures/src/intern.rs index 2d9ab50094752..268ee62da1461 100644 --- a/compiler/rustc_data_structures/src/intern.rs +++ b/compiler/rustc_data_structures/src/intern.rs @@ -4,7 +4,7 @@ use std::hash::{Hash, Hasher}; use std::ops::Deref; use std::ptr; -use crate::stable_hasher::{HashStable, StableHashCtxt, StableHasher}; +use crate::stable_hasher::{StableHash, StableHashCtxt, StableHasher}; mod private { #[derive(Clone, Copy, Debug)] @@ -103,9 +103,9 @@ where } } -impl HashStable for Interned<'_, T> +impl StableHash for Interned<'_, T> where - T: HashStable, + T: StableHash, { fn stable_hash(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { self.0.stable_hash(hcx, hasher); diff --git a/compiler/rustc_data_structures/src/packed.rs b/compiler/rustc_data_structures/src/packed.rs index 1e15eb13c74f6..0ac2008ee6673 100644 --- a/compiler/rustc_data_structures/src/packed.rs +++ b/compiler/rustc_data_structures/src/packed.rs @@ -3,7 +3,7 @@ use std::fmt; use rustc_serialize::{Decodable, Decoder, Encodable, Encoder}; -use crate::stable_hasher::{HashStable, StableHashCtxt, StableHasher}; +use crate::stable_hasher::{StableHash, StableHashCtxt, StableHasher}; /// A packed 128-bit integer. Useful for reducing the size of structures in /// some cases. @@ -60,7 +60,7 @@ impl fmt::UpperHex for Pu128 { } } -impl HashStable for Pu128 { +impl StableHash for Pu128 { #[inline] fn stable_hash(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { { self.0 }.stable_hash(hcx, hasher) diff --git a/compiler/rustc_data_structures/src/sorted_map.rs b/compiler/rustc_data_structures/src/sorted_map.rs index 53ff5877627a4..8c6aa939b4654 100644 --- a/compiler/rustc_data_structures/src/sorted_map.rs +++ b/compiler/rustc_data_structures/src/sorted_map.rs @@ -7,7 +7,7 @@ use std::ops::{Bound, Index, IndexMut, RangeBounds}; use rustc_macros::{Decodable_NoContext, Encodable_NoContext}; -use crate::stable_hasher::{HashStable, StableHashCtxt, StableHasher, StableOrd}; +use crate::stable_hasher::{StableHash, StableHashCtxt, StableHasher, StableOrd}; mod index_map; @@ -347,7 +347,7 @@ impl FromIterator<(K, V)> for SortedMap { } } -impl HashStable for SortedMap { +impl StableHash for SortedMap { #[inline] fn stable_hash(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { self.data.stable_hash(hcx, hasher); diff --git a/compiler/rustc_data_structures/src/sorted_map/index_map.rs b/compiler/rustc_data_structures/src/sorted_map/index_map.rs index b688601fd5d25..8c439437b8bec 100644 --- a/compiler/rustc_data_structures/src/sorted_map/index_map.rs +++ b/compiler/rustc_data_structures/src/sorted_map/index_map.rs @@ -3,7 +3,7 @@ use std::hash::{Hash, Hasher}; use rustc_index::{Idx, IndexVec}; -use rustc_macros::HashStable; +use rustc_macros::StableHash; /// An indexed multi-map that preserves insertion order while permitting both *O*(log *n*) lookup of /// an item by key and *O*(1) lookup by index. @@ -23,7 +23,7 @@ use rustc_macros::HashStable; /// in-place. /// /// [`SortedMap`]: super::SortedMap -#[derive(Clone, Debug, HashStable)] +#[derive(Clone, Debug, StableHash)] pub struct SortedIndexMultiMap { /// The elements of the map in insertion order. items: IndexVec, diff --git a/compiler/rustc_data_structures/src/stable_hasher.rs b/compiler/rustc_data_structures/src/stable_hasher.rs index c62553a40a3c9..17effa07e3bcb 100644 --- a/compiler/rustc_data_structures/src/stable_hasher.rs +++ b/compiler/rustc_data_structures/src/stable_hasher.rs @@ -15,7 +15,7 @@ pub use rustc_stable_hash::{ FromStableHash, SipHasher128Hash as StableHasherHash, StableSipHasher128 as StableHasher, }; -/// This trait lets `HashStable` and `derive(HashStable)` be used in +/// This trait lets `StableHash` and `derive(StableHash)` be used in /// this crate (and other crates upstream of `rustc_middle`), while leaving /// certain operations to be defined in `rustc_middle` where more things are /// visible. @@ -46,10 +46,10 @@ pub struct RawDefId(pub u32, pub u32); // `DefPathHash`. pub struct RawDefPathHash(pub [u8; 16]); -/// Something that implements `HashStable` can be hashed in a way that is +/// Something that implements `StableHash` can be hashed in a way that is /// stable across multiple compilation sessions. /// -/// Note that `HashStable` imposes rather more strict requirements than usual +/// Note that `StableHash` imposes rather more strict requirements than usual /// hash functions: /// /// - Stable hashes are sometimes used as identifiers. Therefore they must @@ -72,7 +72,7 @@ pub struct RawDefPathHash(pub [u8; 16]); /// - `stable_hash()` must be independent of the host architecture. The /// `StableHasher` takes care of endianness and `isize`/`usize` platform /// differences. -pub trait HashStable { +pub trait StableHash { fn stable_hash(&self, hcx: &mut Hcx, hasher: &mut StableHasher); } @@ -80,7 +80,7 @@ pub trait HashStable { /// example, for DefId that can be converted to a DefPathHash. This is used for /// bringing maps into a predictable order before hashing them. pub trait ToStableHashKey { - type KeyType: Ord + Sized + HashStable; + type KeyType: Ord + Sized + StableHash; fn to_stable_hash_key(&self, hcx: &mut Hcx) -> Self::KeyType; } @@ -156,18 +156,18 @@ impl StableCompare for T { } } -/// Implement HashStable by just calling `Hash::hash()`. Also implement `StableOrd` for the type since -/// that has the same requirements. +/// Implement StableHash by just calling `Hash::hash()`. Also implement `StableOrd` for the type +/// since that has the same requirements. /// /// **WARNING** This is only valid for types that *really* don't need any context for fingerprinting. /// But it is easy to misuse this macro (see [#96013](https://github.com/rust-lang/rust/issues/96013) /// for examples). Therefore this macro is not exported and should only be used in the limited cases /// here in this module. /// -/// Use `#[derive(HashStable)]` instead. +/// Use `#[derive(StableHash)]` instead. macro_rules! impl_stable_traits_for_trivial_type { ($t:ty) => { - impl $crate::stable_hasher::HashStable for $t { + impl $crate::stable_hasher::StableHash for $t { #[inline] fn stable_hash( &self, @@ -212,7 +212,7 @@ impl_stable_traits_for_trivial_type!(Hash64); // We need a custom impl as the default hash function will only hash half the bits. For stable // hashing we want to hash the full 128-bit hash. -impl HashStable for Hash128 { +impl StableHash for Hash128 { #[inline] fn stable_hash(&self, _: &mut Hcx, hasher: &mut StableHasher) { self.as_u128().hash(hasher); @@ -227,52 +227,52 @@ impl StableOrd for Hash128 { const THIS_IMPLEMENTATION_HAS_BEEN_TRIPLE_CHECKED: () = (); } -impl HashStable for ! { +impl StableHash for ! { fn stable_hash(&self, _hcx: &mut Hcx, _hasher: &mut StableHasher) { unreachable!() } } -impl HashStable for PhantomData { +impl StableHash for PhantomData { fn stable_hash(&self, _hcx: &mut Hcx, _hasher: &mut StableHasher) {} } -impl HashStable for NonZero { +impl StableHash for NonZero { #[inline] fn stable_hash(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { self.get().stable_hash(hcx, hasher) } } -impl HashStable for NonZero { +impl StableHash for NonZero { #[inline] fn stable_hash(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { self.get().stable_hash(hcx, hasher) } } -impl HashStable for f32 { +impl StableHash for f32 { fn stable_hash(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { let val: u32 = self.to_bits(); val.stable_hash(hcx, hasher); } } -impl HashStable for f64 { +impl StableHash for f64 { fn stable_hash(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { let val: u64 = self.to_bits(); val.stable_hash(hcx, hasher); } } -impl HashStable for ::std::cmp::Ordering { +impl StableHash for ::std::cmp::Ordering { #[inline] fn stable_hash(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { (*self as i8).stable_hash(hcx, hasher); } } -impl HashStable for (T1,) { +impl StableHash for (T1,) { #[inline] fn stable_hash(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { let (ref _0,) = *self; @@ -280,7 +280,7 @@ impl HashStable for (T1,) { } } -impl HashStable for (T1, T2) { +impl StableHash for (T1, T2) { fn stable_hash(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { let (ref _0, ref _1) = *self; _0.stable_hash(hcx, hasher); @@ -296,11 +296,11 @@ impl StableOrd for (T1, T2) { const THIS_IMPLEMENTATION_HAS_BEEN_TRIPLE_CHECKED: () = (); } -impl HashStable for (T1, T2, T3) +impl StableHash for (T1, T2, T3) where - T1: HashStable, - T2: HashStable, - T3: HashStable, + T1: StableHash, + T2: StableHash, + T3: StableHash, { fn stable_hash(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { let (ref _0, ref _1, ref _2) = *self; @@ -319,12 +319,12 @@ impl StableOrd for (T1, T2, T3) { const THIS_IMPLEMENTATION_HAS_BEEN_TRIPLE_CHECKED: () = (); } -impl HashStable for (T1, T2, T3, T4) +impl StableHash for (T1, T2, T3, T4) where - T1: HashStable, - T2: HashStable, - T3: HashStable, - T4: HashStable, + T1: StableHash, + T2: StableHash, + T3: StableHash, + T4: StableHash, { fn stable_hash(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { let (ref _0, ref _1, ref _2, ref _3) = *self; @@ -346,7 +346,7 @@ impl StableOrd for ( const THIS_IMPLEMENTATION_HAS_BEEN_TRIPLE_CHECKED: () = (); } -impl HashStable for [T] { +impl StableHash for [T] { default fn stable_hash(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { self.len().stable_hash(hcx, hasher); for item in self { @@ -355,24 +355,24 @@ impl HashStable for [T] { } } -impl HashStable for [u8] { +impl StableHash for [u8] { fn stable_hash(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { self.len().stable_hash(hcx, hasher); hasher.write(self); } } -impl HashStable for Vec { +impl StableHash for Vec { #[inline] fn stable_hash(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { self[..].stable_hash(hcx, hasher); } } -impl HashStable for indexmap::IndexMap +impl StableHash for indexmap::IndexMap where - K: HashStable + Eq + Hash, - V: HashStable, + K: StableHash + Eq + Hash, + V: StableHash, R: BuildHasher, { #[inline] @@ -384,9 +384,9 @@ where } } -impl HashStable for indexmap::IndexSet +impl StableHash for indexmap::IndexSet where - K: HashStable + Eq + Hash, + K: StableHash + Eq + Hash, R: BuildHasher, { #[inline] @@ -398,9 +398,9 @@ where } } -impl HashStable for SmallVec<[A; N]> +impl StableHash for SmallVec<[A; N]> where - A: HashStable, + A: StableHash, { #[inline] fn stable_hash(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { @@ -408,28 +408,28 @@ where } } -impl HashStable for Box { +impl StableHash for Box { #[inline] fn stable_hash(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { (**self).stable_hash(hcx, hasher); } } -impl HashStable for ::std::rc::Rc { +impl StableHash for ::std::rc::Rc { #[inline] fn stable_hash(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { (**self).stable_hash(hcx, hasher); } } -impl HashStable for ::std::sync::Arc { +impl StableHash for ::std::sync::Arc { #[inline] fn stable_hash(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { (**self).stable_hash(hcx, hasher); } } -impl HashStable for str { +impl StableHash for str { #[inline] fn stable_hash(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { self.as_bytes().stable_hash(hcx, hasher); @@ -444,7 +444,7 @@ impl StableOrd for &str { const THIS_IMPLEMENTATION_HAS_BEEN_TRIPLE_CHECKED: () = (); } -impl HashStable for String { +impl StableHash for String { #[inline] fn stable_hash(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { self[..].stable_hash(hcx, hasher); @@ -475,7 +475,7 @@ impl ToStableHashKey for (T1, T2) { } } -impl HashStable for bool { +impl StableHash for bool { #[inline] fn stable_hash(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { (if *self { 1u8 } else { 0u8 }).stable_hash(hcx, hasher); @@ -489,9 +489,9 @@ impl StableOrd for bool { const THIS_IMPLEMENTATION_HAS_BEEN_TRIPLE_CHECKED: () = (); } -impl HashStable for Option +impl StableHash for Option where - T: HashStable, + T: StableHash, { #[inline] fn stable_hash(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { @@ -511,10 +511,10 @@ impl StableOrd for Option { const THIS_IMPLEMENTATION_HAS_BEEN_TRIPLE_CHECKED: () = (); } -impl HashStable for Result +impl StableHash for Result where - T1: HashStable, - T2: HashStable, + T1: StableHash, + T2: StableHash, { #[inline] fn stable_hash(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { @@ -526,9 +526,9 @@ where } } -impl<'a, T> HashStable for &'a T +impl<'a, T> StableHash for &'a T where - T: HashStable + ?Sized, + T: StableHash + ?Sized, { #[inline] fn stable_hash(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { @@ -536,16 +536,16 @@ where } } -impl HashStable for ::std::mem::Discriminant { +impl StableHash for ::std::mem::Discriminant { #[inline] fn stable_hash(&self, _: &mut Hcx, hasher: &mut StableHasher) { ::std::hash::Hash::hash(self, hasher); } } -impl HashStable for ::std::ops::RangeInclusive +impl StableHash for ::std::ops::RangeInclusive where - T: HashStable, + T: StableHash, { #[inline] fn stable_hash(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { @@ -554,9 +554,9 @@ where } } -impl HashStable for IndexSlice +impl StableHash for IndexSlice where - T: HashStable, + T: StableHash, { fn stable_hash(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { self.len().stable_hash(hcx, hasher); @@ -566,9 +566,9 @@ where } } -impl HashStable for IndexVec +impl StableHash for IndexVec where - T: HashStable, + T: StableHash, { fn stable_hash(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { self.len().stable_hash(hcx, hasher); @@ -578,13 +578,13 @@ where } } -impl HashStable for DenseBitSet { +impl StableHash for DenseBitSet { fn stable_hash(&self, _hcx: &mut Hcx, hasher: &mut StableHasher) { ::std::hash::Hash::hash(self, hasher); } } -impl HashStable for bit_set::BitMatrix { +impl StableHash for bit_set::BitMatrix { fn stable_hash(&self, _hcx: &mut Hcx, hasher: &mut StableHasher) { ::std::hash::Hash::hash(self, hasher); } @@ -595,16 +595,16 @@ impl_stable_traits_for_trivial_type!(::std::ffi::OsStr); impl_stable_traits_for_trivial_type!(::std::path::Path); impl_stable_traits_for_trivial_type!(::std::path::PathBuf); -// It is not safe to implement HashStable for HashSet, HashMap or any other collection type +// It is not safe to implement StableHash for HashSet, HashMap or any other collection type // with unstable but observable iteration order. // See https://github.com/rust-lang/compiler-team/issues/533 for further information. -impl !HashStable for std::collections::HashSet {} -impl !HashStable for std::collections::HashMap {} +impl !StableHash for std::collections::HashSet {} +impl !StableHash for std::collections::HashMap {} -impl HashStable for ::std::collections::BTreeMap +impl StableHash for ::std::collections::BTreeMap where - K: HashStable + StableOrd, - V: HashStable, + K: StableHash + StableOrd, + V: StableHash, { fn stable_hash(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { self.len().stable_hash(hcx, hasher); @@ -614,9 +614,9 @@ where } } -impl HashStable for ::std::collections::BTreeSet +impl StableHash for ::std::collections::BTreeSet where - K: HashStable + StableOrd, + K: StableHash + StableOrd, { fn stable_hash(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { self.len().stable_hash(hcx, hasher); @@ -627,7 +627,7 @@ where } /// Controls what data we do or do not hash. -/// Whenever a `HashStable` implementation caches its +/// Whenever a `StableHash` implementation caches its /// result, it needs to include `HashingControls` as part /// of the key, to ensure that it does not produce an incorrect /// result (for example, using a `Fingerprint` produced while diff --git a/compiler/rustc_data_structures/src/stable_hasher/tests.rs b/compiler/rustc_data_structures/src/stable_hasher/tests.rs index aa76b3a7c57b7..37c73cee9f30b 100644 --- a/compiler/rustc_data_structures/src/stable_hasher/tests.rs +++ b/compiler/rustc_data_structures/src/stable_hasher/tests.rs @@ -22,7 +22,7 @@ impl StableHashCtxt for () { } } -fn hash(t: &T) -> Hash128 { +fn hash(t: &T) -> Hash128 { let mut h = StableHasher::new(); let hcx = &mut (); t.stable_hash(hcx, &mut h); @@ -59,7 +59,7 @@ fn test_attribute_permutation() { b: $ty, } - impl HashStable for Foo { + impl StableHash for Foo { fn stable_hash( &self, hcx: &mut Hcx, diff --git a/compiler/rustc_data_structures/src/steal.rs b/compiler/rustc_data_structures/src/steal.rs index eeb5f677a29f5..b9adc372861a6 100644 --- a/compiler/rustc_data_structures/src/steal.rs +++ b/compiler/rustc_data_structures/src/steal.rs @@ -1,4 +1,4 @@ -use crate::stable_hasher::{HashStable, StableHashCtxt, StableHasher}; +use crate::stable_hasher::{StableHash, StableHashCtxt, StableHasher}; use crate::sync::{MappedReadGuard, MappedWriteGuard, ReadGuard, RwLock, WriteGuard}; /// The `Steal` struct is intended to used as the value for a query. @@ -71,7 +71,7 @@ impl Steal { } } -impl HashStable for Steal { +impl StableHash for Steal { fn stable_hash(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { self.borrow().stable_hash(hcx, hasher); } diff --git a/compiler/rustc_data_structures/src/svh.rs b/compiler/rustc_data_structures/src/svh.rs index e64793f0778f7..2c4e00c824d80 100644 --- a/compiler/rustc_data_structures/src/svh.rs +++ b/compiler/rustc_data_structures/src/svh.rs @@ -7,7 +7,7 @@ use std::fmt; -use rustc_macros::{Decodable_NoContext, Encodable_NoContext, HashStable}; +use rustc_macros::{Decodable_NoContext, Encodable_NoContext, StableHash}; use crate::fingerprint::Fingerprint; @@ -20,7 +20,7 @@ use crate::fingerprint::Fingerprint; Encodable_NoContext, Decodable_NoContext, Hash, - HashStable + StableHash )] pub struct Svh { hash: Fingerprint, diff --git a/compiler/rustc_data_structures/src/tagged_ptr.rs b/compiler/rustc_data_structures/src/tagged_ptr.rs index f45a048f2babd..867a702093e7b 100644 --- a/compiler/rustc_data_structures/src/tagged_ptr.rs +++ b/compiler/rustc_data_structures/src/tagged_ptr.rs @@ -12,7 +12,7 @@ use std::ops::Deref; use std::ptr::NonNull; use crate::aligned::Aligned; -use crate::stable_hasher::{HashStable, StableHashCtxt, StableHasher}; +use crate::stable_hasher::{StableHash, StableHashCtxt, StableHasher}; /// This describes tags that the [`TaggedRef`] struct can hold. /// @@ -259,10 +259,10 @@ impl Hash for TaggedRef<'_, P, T> { } } -impl<'a, P, T> HashStable for TaggedRef<'a, P, T> +impl<'a, P, T> StableHash for TaggedRef<'a, P, T> where - P: HashStable + Aligned + ?Sized, - T: Tag + HashStable, + P: StableHash + Aligned + ?Sized, + T: Tag + StableHash, { fn stable_hash(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { self.pointer().stable_hash(hcx, hasher); diff --git a/compiler/rustc_data_structures/src/tagged_ptr/tests.rs b/compiler/rustc_data_structures/src/tagged_ptr/tests.rs index 8c1dccc538e3c..78f24412dbb4c 100644 --- a/compiler/rustc_data_structures/src/tagged_ptr/tests.rs +++ b/compiler/rustc_data_structures/src/tagged_ptr/tests.rs @@ -3,7 +3,7 @@ use std::ptr; use rustc_hashes::Hash128; use super::*; -use crate::stable_hasher::{HashStable, StableHasher}; +use crate::stable_hasher::{StableHash, StableHasher}; /// A tag type used in [`TaggedRef`] tests. #[derive(Copy, Clone, Debug, PartialEq, Eq)] @@ -32,7 +32,7 @@ unsafe impl Tag for Tag2 { } } -impl HashStable for Tag2 { +impl StableHash for Tag2 { fn stable_hash( &self, hcx: &mut Hcx, diff --git a/compiler/rustc_data_structures/src/unord.rs b/compiler/rustc_data_structures/src/unord.rs index 1a312d2591477..779615f73039f 100644 --- a/compiler/rustc_data_structures/src/unord.rs +++ b/compiler/rustc_data_structures/src/unord.rs @@ -13,7 +13,7 @@ use rustc_macros::{Decodable_NoContext, Encodable_NoContext}; use crate::fingerprint::Fingerprint; use crate::fx::{FxBuildHasher, FxHashMap, FxHashSet}; use crate::stable_hasher::{ - HashStable, StableCompare, StableHashCtxt, StableHasher, ToStableHashKey, + StableCompare, StableHash, StableHashCtxt, StableHasher, ToStableHashKey, }; /// `UnordItems` is the order-less version of `Iterator`. It only contains methods @@ -420,7 +420,7 @@ impl> From> for UnordSet } } -impl HashStable for UnordSet { +impl StableHash for UnordSet { #[inline] fn stable_hash(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { hash_iter_order_independent(self.inner.iter(), hcx, hasher); @@ -650,7 +650,7 @@ where } } -impl HashStable for UnordMap { +impl StableHash for UnordMap { #[inline] fn stable_hash(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { hash_iter_order_independent(self.inner.iter(), hcx, hasher); @@ -713,7 +713,7 @@ impl> From> for UnordBag { } } -impl HashStable for UnordBag { +impl StableHash for UnordBag { #[inline] fn stable_hash(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { hash_iter_order_independent(self.inner.iter(), hcx, hasher); @@ -744,7 +744,7 @@ where fn hash_iter_order_independent< Hcx: StableHashCtxt, - T: HashStable, + T: StableHash, I: Iterator + ExactSizeIterator, >( mut it: I, diff --git a/compiler/rustc_error_messages/src/lib.rs b/compiler/rustc_error_messages/src/lib.rs index bbcda7bce2177..a33532abc5e44 100644 --- a/compiler/rustc_error_messages/src/lib.rs +++ b/compiler/rustc_error_messages/src/lib.rs @@ -7,7 +7,7 @@ use std::borrow::Cow; pub use fluent_bundle::types::FluentType; pub use fluent_bundle::{self, FluentArgs, FluentError, FluentValue}; -use rustc_macros::{Decodable, Encodable, HashStable}; +use rustc_macros::{Decodable, Encodable, StableHash}; use rustc_span::Span; pub use unic_langid::{LanguageIdentifier, langid}; @@ -28,7 +28,7 @@ pub fn register_functions(bundle: &mut fluent_bundle::bundle::FluentBundle /// diagnostic messages. /// /// Intended to be removed once diagnostics are entirely translatable. -#[derive(Clone, Debug, PartialEq, Eq, Hash, Encodable, Decodable, HashStable)] +#[derive(Clone, Debug, PartialEq, Eq, Hash, Encodable, Decodable, StableHash)] #[rustc_diagnostic_item = "DiagMessage"] pub enum DiagMessage { /// Non-translatable diagnostic message or a message that has been translated eagerly. @@ -89,7 +89,7 @@ pub struct SpanLabel { /// the error, and would be rendered with `^^^`. /// - They can have a *label*. In this case, the label is written next /// to the mark in the snippet when we render. -#[derive(Clone, Debug, Hash, PartialEq, Eq, Encodable, Decodable, HashStable)] +#[derive(Clone, Debug, Hash, PartialEq, Eq, Encodable, Decodable, StableHash)] pub struct MultiSpan { primary_spans: Vec, span_labels: Vec<(Span, DiagMessage)>, diff --git a/compiler/rustc_feature/src/unstable.rs b/compiler/rustc_feature/src/unstable.rs index dacefe4c5d3f1..1e58e6159ccb2 100644 --- a/compiler/rustc_feature/src/unstable.rs +++ b/compiler/rustc_feature/src/unstable.rs @@ -5,7 +5,7 @@ use std::time::{SystemTime, UNIX_EPOCH}; use rustc_data_structures::AtomicRef; use rustc_data_structures::fx::FxHashSet; -use rustc_data_structures::stable_hasher::{HashStable, StableHashCtxt, StableHasher}; +use rustc_data_structures::stable_hasher::{StableHash, StableHashCtxt, StableHasher}; use rustc_span::{Span, Symbol, sym}; use super::{Feature, to_nonzero}; @@ -120,7 +120,7 @@ impl Features { } } -impl HashStable for Features { +impl StableHash for Features { fn stable_hash(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { // `enabled_features` is skipped because it's the sum of the lang and lib features. let Features { enabled_lang_features, enabled_lib_features, enabled_features: _ } = self; @@ -129,7 +129,7 @@ impl HashStable for Features { } } -impl HashStable for EnabledLangFeature { +impl StableHash for EnabledLangFeature { fn stable_hash(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { let EnabledLangFeature { gate_name, attr_sp, stable_since } = self; gate_name.stable_hash(hcx, hasher); @@ -138,7 +138,7 @@ impl HashStable for EnabledLangFeature { } } -impl HashStable for EnabledLibFeature { +impl StableHash for EnabledLibFeature { fn stable_hash(&self, hcx: &mut Hcx, hasher: &mut StableHasher) { let EnabledLibFeature { gate_name, attr_sp } = self; gate_name.stable_hash(hcx, hasher); diff --git a/compiler/rustc_hir/src/attrs/data_structures.rs b/compiler/rustc_hir/src/attrs/data_structures.rs index 556eb428a1b87..4691116442864 100644 --- a/compiler/rustc_hir/src/attrs/data_structures.rs +++ b/compiler/rustc_hir/src/attrs/data_structures.rs @@ -12,7 +12,7 @@ use rustc_ast::{AttrStyle, Path, ast}; use rustc_data_structures::fx::FxIndexMap; use rustc_error_messages::{DiagArgValue, IntoDiagArg}; use rustc_hir::LangItem; -use rustc_macros::{Decodable, Encodable, HashStable, PrintAttribute}; +use rustc_macros::{Decodable, Encodable, PrintAttribute, StableHash}; use rustc_span::def_id::DefId; use rustc_span::hygiene::Transparency; use rustc_span::{ErrorGuaranteed, Ident, Span, Symbol}; @@ -24,7 +24,7 @@ use crate::attrs::pretty_printing::PrintAttribute; use crate::limit::Limit; use crate::{DefaultBodyStability, PartialConstStability, RustcVersion, Stability}; -#[derive(Copy, Clone, Debug, HashStable, Encodable, Decodable, PrintAttribute)] +#[derive(Copy, Clone, Debug, StableHash, Encodable, Decodable, PrintAttribute)] pub enum EiiImplResolution { /// Usually, finding the extern item that an EII implementation implements means finding /// the defid of the associated attribute macro, and looking at *its* attributes to find @@ -37,7 +37,7 @@ pub enum EiiImplResolution { Error(ErrorGuaranteed), } -#[derive(Copy, Clone, Debug, HashStable, Encodable, Decodable, PrintAttribute)] +#[derive(Copy, Clone, Debug, StableHash, Encodable, Decodable, PrintAttribute)] pub struct EiiImpl { pub resolution: EiiImplResolution, pub impl_marked_unsafe: bool, @@ -46,7 +46,7 @@ pub struct EiiImpl { pub is_default: bool, } -#[derive(Copy, Clone, Debug, HashStable, Encodable, Decodable, PrintAttribute)] +#[derive(Copy, Clone, Debug, StableHash, Encodable, Decodable, PrintAttribute)] pub struct EiiDecl { pub foreign_item: DefId, /// whether or not it is unsafe to implement this EII @@ -54,7 +54,7 @@ pub struct EiiDecl { pub name: Ident, } -#[derive(Copy, Clone, PartialEq, Encodable, Decodable, Debug, HashStable, PrintAttribute)] +#[derive(Copy, Clone, PartialEq, Encodable, Decodable, Debug, StableHash, PrintAttribute)] pub enum CguKind { No, PreDashLto, @@ -62,7 +62,7 @@ pub enum CguKind { Any, } -#[derive(Copy, Clone, PartialEq, Encodable, Decodable, Debug, HashStable, PrintAttribute)] +#[derive(Copy, Clone, PartialEq, Encodable, Decodable, Debug, StableHash, PrintAttribute)] pub enum CguFields { PartitionReused { cfg: Symbol, module: Symbol }, PartitionCodegened { cfg: Symbol, module: Symbol }, @@ -70,7 +70,7 @@ pub enum CguFields { } #[derive(Copy, Clone, PartialEq, Debug, PrintAttribute)] -#[derive(HashStable, Encodable, Decodable)] +#[derive(StableHash, Encodable, Decodable)] pub enum DivergingFallbackBehavior { /// Always fallback to `()` (aka "always spontaneous decay") ToUnit, @@ -82,7 +82,7 @@ pub enum DivergingFallbackBehavior { } #[derive(Copy, Clone, PartialEq, Debug, PrintAttribute, Default)] -#[derive(HashStable, Encodable, Decodable)] +#[derive(StableHash, Encodable, Decodable)] pub enum DivergingBlockBehavior { /// This is the current stable behavior: /// @@ -105,7 +105,7 @@ pub enum DivergingBlockBehavior { Unit, } -#[derive(Copy, Clone, PartialEq, Encodable, Decodable, Debug, HashStable, PrintAttribute)] +#[derive(Copy, Clone, PartialEq, Encodable, Decodable, Debug, StableHash, PrintAttribute)] pub enum InlineAttr { None, Hint, @@ -129,14 +129,14 @@ impl InlineAttr { } } -#[derive(Copy, Clone, Encodable, Decodable, Debug, PartialEq, Eq, HashStable, PrintAttribute)] +#[derive(Copy, Clone, Encodable, Decodable, Debug, PartialEq, Eq, StableHash, PrintAttribute)] pub enum InstructionSetAttr { ArmA32, ArmT32, } #[derive(Copy, Clone, Debug, PartialEq, Eq, Default, PrintAttribute)] -#[derive(Encodable, Decodable, HashStable)] +#[derive(Encodable, Decodable, StableHash)] pub enum OptimizeAttr { /// No `#[optimize(..)]` attribute #[default] @@ -155,7 +155,7 @@ impl OptimizeAttr { } } -#[derive(PartialEq, Debug, Encodable, Decodable, Copy, Clone, HashStable, PrintAttribute)] +#[derive(PartialEq, Debug, Encodable, Decodable, Copy, Clone, StableHash, PrintAttribute)] pub enum ReprAttr { ReprInt(IntType), ReprRust, @@ -172,13 +172,13 @@ pub enum TransparencyError { } #[derive(Eq, PartialEq, Debug, Copy, Clone)] -#[derive(Encodable, Decodable, HashStable, PrintAttribute)] +#[derive(Encodable, Decodable, StableHash, PrintAttribute)] pub enum IntType { SignedInt(ast::IntTy), UnsignedInt(ast::UintTy), } -#[derive(Copy, Debug, Encodable, Decodable, Clone, HashStable, PrintAttribute)] +#[derive(Copy, Debug, Encodable, Decodable, Clone, StableHash, PrintAttribute)] pub struct Deprecation { pub since: DeprecatedSince, /// The note to issue a reason. @@ -190,7 +190,7 @@ pub struct Deprecation { } /// Release in which an API is deprecated. -#[derive(Copy, Debug, Encodable, Decodable, Clone, HashStable, PrintAttribute)] +#[derive(Copy, Debug, Encodable, Decodable, Clone, StableHash, PrintAttribute)] pub enum DeprecatedSince { RustcVersion(RustcVersion), /// Deprecated in the future ("to be determined"). @@ -207,7 +207,7 @@ pub enum DeprecatedSince { /// Successfully-parsed value of a `#[coverage(..)]` attribute. #[derive(Copy, Debug, Eq, PartialEq, Encodable, Decodable, Clone)] -#[derive(HashStable, PrintAttribute)] +#[derive(StableHash, PrintAttribute)] pub enum CoverageAttrKind { On, Off, @@ -215,7 +215,7 @@ pub enum CoverageAttrKind { /// Successfully-parsed value of a `#[rustc_abi(..)]` attribute. #[derive(Copy, Debug, Eq, PartialEq, Encodable, Decodable, Clone)] -#[derive(HashStable, PrintAttribute)] +#[derive(StableHash, PrintAttribute)] pub enum RustcAbiAttrKind { Debug, AssertEq, @@ -246,7 +246,7 @@ impl Deprecation { /// `#[used(compiler)]` /// `#[used(linker)]` #[derive(Encodable, Decodable, Copy, Clone, Debug, PartialEq, Eq, Hash)] -#[derive(HashStable, PrintAttribute)] +#[derive(StableHash, PrintAttribute)] pub enum UsedBy { Default, Compiler, @@ -254,7 +254,7 @@ pub enum UsedBy { } #[derive(Encodable, Decodable, Clone, Debug, PartialEq, Eq, Hash)] -#[derive(HashStable, PrintAttribute)] +#[derive(StableHash, PrintAttribute)] pub enum MacroUseArgs { UseAll, UseSpecific(ThinVec), @@ -266,7 +266,7 @@ impl Default for MacroUseArgs { } } -#[derive(Debug, Clone, Encodable, Decodable, HashStable)] +#[derive(Debug, Clone, Encodable, Decodable, StableHash)] pub struct StrippedCfgItem { pub parent_scope: ScopeId, pub ident: Ident, @@ -284,7 +284,7 @@ impl StrippedCfgItem { /// /// See for more details about these variants. #[derive(Encodable, Decodable, Clone, Copy, Debug, PartialEq, Eq, Hash)] -#[derive(HashStable, PrintAttribute)] +#[derive(StableHash, PrintAttribute)] pub enum Linkage { AvailableExternally, Common, @@ -298,7 +298,7 @@ pub enum Linkage { } #[derive(Clone, Copy, Decodable, Debug, Encodable, PartialEq)] -#[derive(HashStable, PrintAttribute)] +#[derive(StableHash, PrintAttribute)] pub enum MirDialect { Analysis, Built, @@ -317,7 +317,7 @@ impl IntoDiagArg for MirDialect { } #[derive(Clone, Copy, Decodable, Debug, Encodable, PartialEq)] -#[derive(HashStable, PrintAttribute)] +#[derive(StableHash, PrintAttribute)] pub enum MirPhase { Initial, PostCleanup, @@ -337,7 +337,7 @@ impl IntoDiagArg for MirPhase { /// Different ways that the PE Format can decorate a symbol name. /// From -#[derive(Copy, Clone, Debug, Encodable, Decodable, HashStable, PartialEq, Eq, PrintAttribute)] +#[derive(Copy, Clone, Debug, Encodable, Decodable, StableHash, PartialEq, Eq, PrintAttribute)] pub enum PeImportNameType { /// IMPORT_ORDINAL /// Uses the ordinal (i.e., a number) rather than the name. @@ -367,7 +367,7 @@ pub enum PeImportNameType { Decodable, PrintAttribute )] -#[derive(HashStable)] +#[derive(StableHash)] pub enum NativeLibKind { /// Static library (e.g. `libfoo.a` on Linux or `foo.lib` on Windows/MSVC) Static { @@ -435,7 +435,7 @@ impl NativeLibKind { } } -#[derive(Debug, Encodable, Decodable, Clone, HashStable, PrintAttribute)] +#[derive(Debug, Encodable, Decodable, Clone, StableHash, PrintAttribute)] pub struct LinkEntry { pub span: Span, pub kind: NativeLibKind, @@ -445,14 +445,14 @@ pub struct LinkEntry { pub import_name_type: Option<(PeImportNameType, Span)>, } -#[derive(HashStable, PrintAttribute)] +#[derive(StableHash, PrintAttribute)] #[derive(Copy, PartialEq, PartialOrd, Clone, Ord, Eq, Hash, Debug, Encodable, Decodable)] pub enum DebuggerVisualizerType { Natvis, GdbPrettyPrinter, } -#[derive(Debug, Encodable, Decodable, Clone, HashStable, PrintAttribute)] +#[derive(Debug, Encodable, Decodable, Clone, StableHash, PrintAttribute)] pub struct DebugVisualizer { pub span: Span, pub visualizer_type: DebuggerVisualizerType, @@ -460,7 +460,7 @@ pub struct DebugVisualizer { } #[derive(Clone, Copy, Debug, Decodable, Encodable, Eq, PartialEq)] -#[derive(HashStable, PrintAttribute)] +#[derive(StableHash, PrintAttribute)] #[derive_const(Default)] pub enum RtsanSetting { Nonblocking, @@ -470,7 +470,7 @@ pub enum RtsanSetting { } #[derive(Eq, PartialEq, Debug, Copy, Clone)] -#[derive(Encodable, Decodable, HashStable, PrintAttribute)] +#[derive(Encodable, Decodable, StableHash, PrintAttribute)] pub enum WindowsSubsystemKind { Console, Windows, @@ -486,20 +486,20 @@ impl WindowsSubsystemKind { } #[derive(Copy, Clone, Debug, PartialEq)] -#[derive(HashStable, Encodable, Decodable, PrintAttribute)] +#[derive(StableHash, Encodable, Decodable, PrintAttribute)] pub enum DocInline { Inline, NoInline, } #[derive(Copy, Clone, Debug, PartialEq)] -#[derive(HashStable, Encodable, Decodable, PrintAttribute)] +#[derive(StableHash, Encodable, Decodable, PrintAttribute)] pub enum HideOrShow { Hide, Show, } -#[derive(Clone, Debug, HashStable, Encodable, Decodable, PrintAttribute)] +#[derive(Clone, Debug, StableHash, Encodable, Decodable, PrintAttribute)] pub struct CfgInfo { pub name: Symbol, pub name_span: Span, @@ -516,13 +516,13 @@ impl CfgInfo { } } -#[derive(Clone, Debug, HashStable, Encodable, Decodable, PrintAttribute)] +#[derive(Clone, Debug, StableHash, Encodable, Decodable, PrintAttribute)] pub struct CfgHideShow { pub kind: HideOrShow, pub values: ThinVec, } -#[derive(Clone, Debug, Default, HashStable, Decodable, PrintAttribute)] +#[derive(Clone, Debug, Default, StableHash, Decodable, PrintAttribute)] pub struct DocAttribute { pub first_span: Span, @@ -626,7 +626,7 @@ impl rustc_serialize::Encodable for DocAttribute /// | external | no | if-ext | if-ext | yes | /// | yes | yes | yes | yes | yes | #[derive(Copy, Clone, Debug, Hash, PartialEq)] -#[derive(HashStable, Encodable, Decodable, PrintAttribute)] +#[derive(StableHash, Encodable, Decodable, PrintAttribute)] pub enum CollapseMacroDebuginfo { /// Don't collapse debuginfo for the macro No = 0, @@ -640,7 +640,7 @@ pub enum CollapseMacroDebuginfo { /// Crate type, as specified by `#![crate_type]` #[derive(Copy, Clone, Debug, Hash, PartialEq, Default, PartialOrd, Eq, Ord)] -#[derive(HashStable, Encodable, Decodable, PrintAttribute)] +#[derive(StableHash, Encodable, Decodable, PrintAttribute)] pub enum CrateType { /// `#![crate_type = "bin"]` Executable, @@ -740,7 +740,7 @@ impl IntoDiagArg for CrateType { } } -#[derive(Clone, Debug, HashStable, Encodable, Decodable, PrintAttribute)] +#[derive(Clone, Debug, StableHash, Encodable, Decodable, PrintAttribute)] pub enum RustcDumpLayoutKind { Align, BackendRepr, @@ -749,7 +749,7 @@ pub enum RustcDumpLayoutKind { Size, } -#[derive(Clone, Debug, HashStable, Encodable, Decodable, PrintAttribute, PartialEq, Eq)] +#[derive(Clone, Debug, StableHash, Encodable, Decodable, PrintAttribute, PartialEq, Eq)] pub enum RustcMirKind { PeekMaybeInit, PeekMaybeUninit, @@ -759,13 +759,13 @@ pub enum RustcMirKind { BorrowckGraphvizFormat { format: BorrowckGraphvizFormatKind }, } -#[derive(Clone, Debug, HashStable, Encodable, Decodable, PrintAttribute, PartialEq, Eq)] +#[derive(Clone, Debug, StableHash, Encodable, Decodable, PrintAttribute, PartialEq, Eq)] pub enum BorrowckGraphvizFormatKind { TwoPhase, } #[derive(Clone, Debug, PartialEq, Eq)] -#[derive(HashStable, Encodable, Decodable, PrintAttribute)] +#[derive(StableHash, Encodable, Decodable, PrintAttribute)] pub struct RustcCleanAttribute { pub span: Span, pub cfg: Symbol, @@ -775,14 +775,14 @@ pub struct RustcCleanAttribute { /// Represents the `except=` or `loaded_from_disk=` argument of `#[rustc_clean]` #[derive(Clone, Debug, PartialEq, Eq)] -#[derive(HashStable, Encodable, Decodable, PrintAttribute)] +#[derive(StableHash, Encodable, Decodable, PrintAttribute)] pub struct RustcCleanQueries { pub entries: ThinVec, pub span: Span, } #[derive(Clone, Debug, PartialEq, Eq)] -#[derive(HashStable, Encodable, Decodable, PrintAttribute)] +#[derive(StableHash, Encodable, Decodable, PrintAttribute)] pub struct RustcAutodiff { /// Conceptually either forward or reverse mode AD, as described in various autodiff papers and /// e.g. in the [JAX @@ -858,7 +858,7 @@ impl RustcAutodiff { } /// We generate one of these structs for each `#[autodiff(...)]` attribute. -#[derive(Clone, Eq, PartialEq, Encodable, Decodable, Debug, HashStable)] +#[derive(Clone, Eq, PartialEq, Encodable, Decodable, Debug, StableHash)] pub struct AutoDiffItem { /// The name of the function getting differentiated pub source: String, @@ -878,7 +878,7 @@ impl fmt::Display for AutoDiffItem { } } -#[derive(Clone, Debug, HashStable, Encodable, Decodable, PrintAttribute)] +#[derive(Clone, Debug, StableHash, Encodable, Decodable, PrintAttribute)] pub struct UnstableRemovedFeature { pub feature: Symbol, pub reason: Symbol, @@ -935,7 +935,7 @@ pub struct UnstableRemovedFeature { /// [`rustc_parse`]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_parse/index.html /// [`rustc_codegen_ssa`]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_codegen_ssa/index.html /// [`rustc_attr_parsing`]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_attr_parsing/index.html -#[derive(Clone, Debug, HashStable, Encodable, Decodable, PrintAttribute)] +#[derive(Clone, Debug, StableHash, Encodable, Decodable, PrintAttribute)] pub enum AttributeKind { // tidy-alphabetical-start /// Represents `#[allow_internal_unsafe]`. diff --git a/compiler/rustc_hir/src/attrs/diagnostic.rs b/compiler/rustc_hir/src/attrs/diagnostic.rs index 9d38125c678b9..26be6e2224615 100644 --- a/compiler/rustc_hir/src/attrs/diagnostic.rs +++ b/compiler/rustc_hir/src/attrs/diagnostic.rs @@ -3,14 +3,14 @@ use std::fmt; use std::fmt::Debug; pub use rustc_ast::attr::data_structures::*; -use rustc_macros::{Decodable, Encodable, HashStable, PrintAttribute}; +use rustc_macros::{Decodable, Encodable, PrintAttribute, StableHash}; use rustc_span::{DesugaringKind, Span, Symbol, kw}; use thin_vec::ThinVec; use tracing::debug; use crate::attrs::PrintAttribute; -#[derive(Clone, Default, Debug, HashStable, Encodable, Decodable, PrintAttribute)] +#[derive(Clone, Default, Debug, StableHash, Encodable, Decodable, PrintAttribute)] pub struct Directive { pub is_rustc_attr: bool, pub condition: Option, @@ -123,7 +123,7 @@ pub struct CustomDiagnostic { /// Like [std::fmt::Arguments] this is a string that has been parsed into "pieces", /// either as string pieces or dynamic arguments. -#[derive(Clone, Debug, HashStable, Encodable, Decodable, PrintAttribute)] +#[derive(Clone, Debug, StableHash, Encodable, Decodable, PrintAttribute)] pub struct FormatString { pub input: Symbol, pub span: Span, @@ -225,13 +225,13 @@ pub struct FormatArgs { pub generic_args: Vec<(Symbol, String)> = Vec::new(), } -#[derive(Clone, Debug, HashStable, Encodable, Decodable, PrintAttribute)] +#[derive(Clone, Debug, StableHash, Encodable, Decodable, PrintAttribute)] pub enum Piece { Lit(Symbol), Arg(FormatArg), } -#[derive(Clone, Debug, HashStable, Encodable, Decodable, PrintAttribute)] +#[derive(Clone, Debug, StableHash, Encodable, Decodable, PrintAttribute)] pub enum FormatArg { // A generic parameter, like `{T}` if we're on the `From` trait. GenericParam { @@ -251,7 +251,7 @@ pub enum FormatArg { } /// Represents the `on` filter in `#[rustc_on_unimplemented]`. -#[derive(Clone, Debug, HashStable, Encodable, Decodable, PrintAttribute)] +#[derive(Clone, Debug, StableHash, Encodable, Decodable, PrintAttribute)] pub struct OnUnimplementedCondition { pub span: Span, pub pred: Predicate, @@ -276,7 +276,7 @@ impl OnUnimplementedCondition { /// /// It is similar to the predicate in the `cfg` attribute, /// and may contain nested predicates. -#[derive(Clone, Debug, HashStable, Encodable, Decodable, PrintAttribute)] +#[derive(Clone, Debug, StableHash, Encodable, Decodable, PrintAttribute)] pub enum Predicate { /// A condition like `on(crate_local)`. Flag(Flag), @@ -314,7 +314,7 @@ impl Predicate { } /// Represents a `MetaWord` in an `on`-filter. -#[derive(Clone, Copy, Debug, HashStable, Encodable, Decodable, PrintAttribute)] +#[derive(Clone, Copy, Debug, StableHash, Encodable, Decodable, PrintAttribute)] pub enum Flag { /// Whether the code causing the trait bound to not be fulfilled /// is part of the user's crate. @@ -329,7 +329,7 @@ pub enum Flag { /// A `MetaNameValueStr` in an `on`-filter. /// /// For example, `#[rustc_on_unimplemented(on(name = "value", message = "hello"))]`. -#[derive(Clone, Debug, HashStable, Encodable, Decodable, PrintAttribute)] +#[derive(Clone, Debug, StableHash, Encodable, Decodable, PrintAttribute)] pub struct NameValue { pub name: Name, /// Something like `"&str"` or `"alloc::string::String"`, @@ -348,7 +348,7 @@ impl NameValue { } /// The valid names of the `on` filter. -#[derive(Clone, Copy, Debug, HashStable, Encodable, Decodable, PrintAttribute)] +#[derive(Clone, Copy, Debug, StableHash, Encodable, Decodable, PrintAttribute)] pub enum Name { Cause, FromDesugaring, @@ -368,7 +368,7 @@ pub enum FlagOrNv<'p> { /// If it is a simple literal like this then `pieces` will be `[LitOrArg::Lit("value")]`. /// The `Arg` variant is used when it contains formatting like /// `#[rustc_on_unimplemented(on(Self = "&[{A}]", message = "hello"))]`. -#[derive(Clone, Debug, HashStable, Encodable, Decodable, PrintAttribute)] +#[derive(Clone, Debug, StableHash, Encodable, Decodable, PrintAttribute)] pub struct FilterFormatString { pub pieces: ThinVec, } @@ -400,7 +400,7 @@ impl FilterFormatString { } } -#[derive(Clone, Debug, HashStable, Encodable, Decodable, PrintAttribute)] +#[derive(Clone, Debug, StableHash, Encodable, Decodable, PrintAttribute)] pub enum LitOrArg { Lit(Symbol), Arg(Symbol), diff --git a/compiler/rustc_hir/src/def.rs b/compiler/rustc_hir/src/def.rs index 863e066f845f0..f268192233c0d 100644 --- a/compiler/rustc_hir/src/def.rs +++ b/compiler/rustc_hir/src/def.rs @@ -7,7 +7,7 @@ use rustc_ast::NodeId; use rustc_data_structures::stable_hasher::ToStableHashKey; use rustc_data_structures::unord::UnordMap; use rustc_error_messages::{DiagArgValue, IntoDiagArg}; -use rustc_macros::{Decodable, Encodable, HashStable}; +use rustc_macros::{Decodable, Encodable, StableHash}; use rustc_span::Symbol; use rustc_span::def_id::{DefId, LocalDefId}; use rustc_span::hygiene::MacroKind; @@ -16,7 +16,7 @@ use crate::definitions::DefPathData; use crate::hir; /// Encodes if a `DefKind::Ctor` is the constructor of an enum variant or a struct. -#[derive(Clone, Copy, PartialEq, Eq, Encodable, Decodable, Hash, Debug, HashStable)] +#[derive(Clone, Copy, PartialEq, Eq, Encodable, Decodable, Hash, Debug, StableHash)] pub enum CtorOf { /// This `DefKind::Ctor` is a synthesized constructor of a tuple or unit struct. Struct, @@ -25,7 +25,7 @@ pub enum CtorOf { } /// What kind of constructor something is. -#[derive(Clone, Copy, PartialEq, Eq, Encodable, Decodable, Hash, Debug, HashStable)] +#[derive(Clone, Copy, PartialEq, Eq, Encodable, Decodable, Hash, Debug, StableHash)] pub enum CtorKind { /// Constructor function automatically created by a tuple struct/variant. Fn, @@ -35,7 +35,7 @@ pub enum CtorKind { /// A set of macro kinds, for macros that can have more than one kind #[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Encodable, Decodable, Hash, Debug)] -#[derive(HashStable)] +#[derive(StableHash)] pub struct MacroKinds(u8); bitflags::bitflags! { impl MacroKinds: u8 { @@ -81,7 +81,7 @@ impl MacroKinds { } /// An attribute that is not a macro; e.g., `#[inline]` or `#[rustfmt::skip]`. -#[derive(Clone, Copy, PartialEq, Eq, Encodable, Decodable, Hash, Debug, HashStable)] +#[derive(Clone, Copy, PartialEq, Eq, Encodable, Decodable, Hash, Debug, StableHash)] pub enum NonMacroAttrKind { /// Single-segment attribute defined by the language (`#[inline]`) Builtin(Symbol), @@ -96,7 +96,7 @@ pub enum NonMacroAttrKind { /// What kind of definition something is; e.g., `mod` vs `struct`. /// `enum DefPathData` may need to be updated if a new variant is added here. -#[derive(Clone, Copy, PartialEq, Eq, Encodable, Decodable, Hash, Debug, HashStable)] +#[derive(Clone, Copy, PartialEq, Eq, Encodable, Decodable, Hash, Debug, StableHash)] pub enum DefKind { // Type namespace Mod, @@ -511,7 +511,7 @@ impl DefKind { /// - the call to `str_to_string` will resolve to [`Res::Def`], with the [`DefId`] /// pointing to the definition of `str_to_string` in the current crate. // -#[derive(Clone, Copy, PartialEq, Eq, Encodable, Decodable, Hash, Debug, HashStable)] +#[derive(Clone, Copy, PartialEq, Eq, Encodable, Decodable, Hash, Debug, StableHash)] pub enum Res { /// Definition having a unique ID (`DefId`), corresponds to something defined in user code. /// @@ -679,7 +679,7 @@ impl PartialRes { /// Different kinds of symbols can coexist even if they share the same textual name. /// Therefore, they each have a separate universe (known as a "namespace"). #[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Debug, Encodable, Decodable)] -#[derive(HashStable)] +#[derive(StableHash)] pub enum Namespace { /// The type namespace includes `struct`s, `enum`s, `union`s, `trait`s, and `mod`s /// (and, by extension, crates). @@ -722,7 +722,7 @@ impl ToStableHashKey for Namespace { } /// Just a helper ‒ separate structure for each namespace. -#[derive(Copy, Clone, Default, Debug, HashStable)] +#[derive(Copy, Clone, Default, Debug, StableHash)] pub struct PerNS { pub value_ns: T, pub type_ns: T, diff --git a/compiler/rustc_hir/src/diagnostic_items.rs b/compiler/rustc_hir/src/diagnostic_items.rs index c19aeec659795..128b6f5e39983 100644 --- a/compiler/rustc_hir/src/diagnostic_items.rs +++ b/compiler/rustc_hir/src/diagnostic_items.rs @@ -1,11 +1,11 @@ use rustc_data_structures::fx::FxIndexMap; -use rustc_macros::HashStable; +use rustc_macros::StableHash; use rustc_span::Symbol; use rustc_span::def_id::DefIdMap; use crate::def_id::DefId; -#[derive(Debug, Default, HashStable)] +#[derive(Debug, Default, StableHash)] pub struct DiagnosticItems { #[stable_hasher(ignore)] pub id_to_name: DefIdMap, diff --git a/compiler/rustc_hir/src/hir.rs b/compiler/rustc_hir/src/hir.rs index c44ed05d6947a..0d06672f1266d 100644 --- a/compiler/rustc_hir/src/hir.rs +++ b/compiler/rustc_hir/src/hir.rs @@ -22,7 +22,7 @@ use rustc_data_structures::steal::Steal; use rustc_data_structures::tagged_ptr::TaggedRef; use rustc_error_messages::{DiagArgValue, IntoDiagArg}; use rustc_index::IndexVec; -use rustc_macros::{Decodable, Encodable, HashStable}; +use rustc_macros::{Decodable, Encodable, StableHash}; use rustc_span::def_id::LocalDefId; use rustc_span::{ BytePos, DUMMY_SP, DesugaringKind, ErrorGuaranteed, Ident, Span, Spanned, Symbol, kw, sym, @@ -39,7 +39,7 @@ pub(crate) use crate::hir_id::{HirId, ItemLocalId, ItemLocalMap, OwnerId}; use crate::intravisit::{FnKind, VisitorExt}; use crate::lints::DelayedLints; -#[derive(Debug, Copy, Clone, PartialEq, Eq, HashStable)] +#[derive(Debug, Copy, Clone, PartialEq, Eq, StableHash)] pub enum AngleBrackets { /// E.g. `Path`. Missing, @@ -49,7 +49,7 @@ pub enum AngleBrackets { Full, } -#[derive(Debug, Copy, Clone, PartialEq, Eq, HashStable)] +#[derive(Debug, Copy, Clone, PartialEq, Eq, StableHash)] pub enum LifetimeSource { /// E.g. `&Type`, `&'_ Type`, `&'a Type`, `&mut Type`, `&'_ mut Type`, `&'a mut Type` Reference, @@ -73,7 +73,7 @@ pub enum LifetimeSource { Other, } -#[derive(Debug, Copy, Clone, PartialEq, Eq, HashStable)] +#[derive(Debug, Copy, Clone, PartialEq, Eq, StableHash)] pub enum LifetimeSyntax { /// E.g. `&Type`, `ContainsLifetime` Implicit, @@ -150,7 +150,7 @@ impl From for LifetimeSyntax { /// Some combinations that cannot occur are `LifetimeSyntax::Implicit` with /// `LifetimeSource::OutlivesBound` or `LifetimeSource::PreciseCapturing` /// — there's no way to "elide" these lifetimes. -#[derive(Debug, Copy, Clone, HashStable)] +#[derive(Debug, Copy, Clone, StableHash)] // Raise the alignment to at least 4 bytes. // This is relied on in other parts of the compiler (for pointer tagging): // @@ -180,7 +180,7 @@ pub struct Lifetime { pub syntax: LifetimeSyntax, } -#[derive(Debug, Copy, Clone, HashStable)] +#[derive(Debug, Copy, Clone, StableHash)] pub enum ParamName { /// Some user-given name like `T` or `'x`. Plain(Ident), @@ -218,7 +218,7 @@ impl ParamName { } } -#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash, HashStable)] +#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash, StableHash)] pub enum LifetimeKind { /// User-given names or fresh (synthetic) names. Param(LocalDefId), @@ -345,7 +345,7 @@ impl Lifetime { /// A `Path` is essentially Rust's notion of a name; for instance, /// `std::cmp::PartialEq`. It's represented as a sequence of identifiers, /// along with a bunch of supporting information. -#[derive(Debug, Clone, Copy, HashStable)] +#[derive(Debug, Clone, Copy, StableHash)] pub struct Path<'hir, R = Res> { pub span: Span, /// The resolution for the path. @@ -365,7 +365,7 @@ impl Path<'_> { /// A segment of a path: an identifier, an optional lifetime, and a set of /// types. -#[derive(Debug, Clone, Copy, HashStable)] +#[derive(Debug, Clone, Copy, StableHash)] pub struct PathSegment<'hir> { /// The identifier portion of this path segment. pub ident: Ident, @@ -402,7 +402,7 @@ impl<'hir> PathSegment<'hir> { } } -#[derive(Clone, Copy, Debug, HashStable)] +#[derive(Clone, Copy, Debug, StableHash)] pub enum ConstItemRhs<'hir> { Body(BodyId), TypeConst(&'hir ConstArg<'hir>), @@ -437,7 +437,7 @@ impl<'hir> ConstItemRhs<'hir> { /// /// For an explanation of the `Unambig` generic parameter see the dev-guide: /// -#[derive(Clone, Copy, Debug, HashStable)] +#[derive(Clone, Copy, Debug, StableHash)] #[repr(C)] pub struct ConstArg<'hir, Unambig = ()> { #[stable_hasher(ignore)] @@ -494,7 +494,7 @@ impl<'hir, Unambig> ConstArg<'hir, Unambig> { } /// See [`ConstArg`]. -#[derive(Clone, Copy, Debug, HashStable)] +#[derive(Clone, Copy, Debug, StableHash)] #[repr(u8, C)] pub enum ConstArgKind<'hir, Unambig = ()> { Tup(&'hir [&'hir ConstArg<'hir, Unambig>]), @@ -522,7 +522,7 @@ pub enum ConstArgKind<'hir, Unambig = ()> { }, } -#[derive(Clone, Copy, Debug, HashStable)] +#[derive(Clone, Copy, Debug, StableHash)] pub struct ConstArgExprField<'hir> { pub hir_id: HirId, pub span: Span, @@ -530,13 +530,13 @@ pub struct ConstArgExprField<'hir> { pub expr: &'hir ConstArg<'hir>, } -#[derive(Clone, Copy, Debug, HashStable)] +#[derive(Clone, Copy, Debug, StableHash)] pub struct ConstArgArrayExpr<'hir> { pub span: Span, pub elems: &'hir [&'hir ConstArg<'hir>], } -#[derive(Clone, Copy, Debug, HashStable)] +#[derive(Clone, Copy, Debug, StableHash)] pub struct InferArg { #[stable_hasher(ignore)] pub hir_id: HirId, @@ -549,7 +549,7 @@ impl InferArg { } } -#[derive(Debug, Clone, Copy, HashStable)] +#[derive(Debug, Clone, Copy, StableHash)] pub enum GenericArg<'hir> { Lifetime(&'hir Lifetime), Type(&'hir Ty<'hir, AmbigArg>), @@ -612,7 +612,7 @@ impl GenericArg<'_> { } /// The generic arguments and associated item constraints of a path segment. -#[derive(Debug, Clone, Copy, HashStable)] +#[derive(Debug, Clone, Copy, StableHash)] pub struct GenericArgs<'hir> { /// The generic arguments for this path segment. pub args: &'hir [GenericArg<'hir>], @@ -736,7 +736,7 @@ impl<'hir> GenericArgs<'hir> { } } -#[derive(Copy, Clone, PartialEq, Eq, Debug, HashStable)] +#[derive(Copy, Clone, PartialEq, Eq, Debug, StableHash)] pub enum GenericArgsParentheses { No, /// Bounds for `feature(return_type_notation)`, like `T: Trait`, @@ -747,7 +747,7 @@ pub enum GenericArgsParentheses { } /// The modifiers on a trait bound. -#[derive(Copy, Clone, PartialEq, Eq, Hash, Debug, HashStable)] +#[derive(Copy, Clone, PartialEq, Eq, Hash, Debug, StableHash)] pub struct TraitBoundModifiers { pub constness: BoundConstness, pub polarity: BoundPolarity, @@ -758,7 +758,7 @@ impl TraitBoundModifiers { TraitBoundModifiers { constness: BoundConstness::Never, polarity: BoundPolarity::Positive }; } -#[derive(Clone, Copy, Debug, HashStable)] +#[derive(Clone, Copy, Debug, StableHash)] pub enum GenericBound<'hir> { Trait(PolyTraitRef<'hir>), Outlives(&'hir Lifetime), @@ -784,7 +784,7 @@ impl GenericBound<'_> { pub type GenericBounds<'hir> = &'hir [GenericBound<'hir>]; -#[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash, HashStable, Debug)] +#[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash, StableHash, Debug)] pub enum MissingLifetimeKind { /// An explicit `'_`. Underscore, @@ -796,7 +796,7 @@ pub enum MissingLifetimeKind { Brackets, } -#[derive(Copy, Clone, Debug, HashStable)] +#[derive(Copy, Clone, Debug, StableHash)] pub enum LifetimeParamKind { // Indicates that the lifetime definition was explicitly declared (e.g., in // `fn foo<'a>(x: &'a u8) -> &'a u8 { x }`). @@ -810,7 +810,7 @@ pub enum LifetimeParamKind { Error, } -#[derive(Debug, Clone, Copy, HashStable)] +#[derive(Debug, Clone, Copy, StableHash)] pub enum GenericParamKind<'hir> { /// A lifetime definition (e.g., `'a: 'b + 'c + 'd`). Lifetime { @@ -827,7 +827,7 @@ pub enum GenericParamKind<'hir> { }, } -#[derive(Debug, Clone, Copy, HashStable)] +#[derive(Debug, Clone, Copy, StableHash)] pub struct GenericParam<'hir> { #[stable_hasher(ignore)] pub hir_id: HirId, @@ -866,7 +866,7 @@ impl<'hir> GenericParam<'hir> { /// early-bound (but can be a late-bound lifetime in functions, for example), /// or from a `for<...>` binder, in which case it's late-bound (and notably, /// does not show up in the parent item's generics). -#[derive(Debug, Clone, Copy, HashStable)] +#[derive(Debug, Clone, Copy, StableHash)] pub enum GenericParamSource { // Early or late-bound parameters defined on an item Generics, @@ -884,7 +884,7 @@ pub struct GenericParamCount { /// Represents lifetimes and type parameters attached to a declaration /// of a function, enum, trait, etc. -#[derive(Debug, Clone, Copy, HashStable)] +#[derive(Debug, Clone, Copy, StableHash)] pub struct Generics<'hir> { pub params: &'hir [GenericParam<'hir>], pub predicates: &'hir [WherePredicate<'hir>], @@ -1091,7 +1091,7 @@ impl<'hir> Generics<'hir> { } /// A single predicate in a where-clause. -#[derive(Debug, Clone, Copy, HashStable)] +#[derive(Debug, Clone, Copy, StableHash)] pub struct WherePredicate<'hir> { #[stable_hasher(ignore)] pub hir_id: HirId, @@ -1100,7 +1100,7 @@ pub struct WherePredicate<'hir> { } /// The kind of a single predicate in a where-clause. -#[derive(Debug, Clone, Copy, HashStable)] +#[derive(Debug, Clone, Copy, StableHash)] pub enum WherePredicateKind<'hir> { /// A type bound (e.g., `for<'c> Foo: Send + Clone + 'c`). BoundPredicate(WhereBoundPredicate<'hir>), @@ -1128,7 +1128,7 @@ impl<'hir> WherePredicateKind<'hir> { } } -#[derive(Copy, Clone, Debug, HashStable, PartialEq, Eq)] +#[derive(Copy, Clone, Debug, StableHash, PartialEq, Eq)] pub enum PredicateOrigin { WhereClause, GenericParam, @@ -1136,7 +1136,7 @@ pub enum PredicateOrigin { } /// A type bound (e.g., `for<'c> Foo: Send + Clone + 'c`). -#[derive(Debug, Clone, Copy, HashStable)] +#[derive(Debug, Clone, Copy, StableHash)] pub struct WhereBoundPredicate<'hir> { /// Origin of the predicate. pub origin: PredicateOrigin, @@ -1156,7 +1156,7 @@ impl<'hir> WhereBoundPredicate<'hir> { } /// A lifetime predicate (e.g., `'a: 'b + 'c`). -#[derive(Debug, Clone, Copy, HashStable)] +#[derive(Debug, Clone, Copy, StableHash)] pub struct WhereRegionPredicate<'hir> { pub in_where_clause: bool, pub lifetime: &'hir Lifetime, @@ -1171,7 +1171,7 @@ impl<'hir> WhereRegionPredicate<'hir> { } /// An equality predicate (e.g., `T = int`); currently unsupported. -#[derive(Debug, Clone, Copy, HashStable)] +#[derive(Debug, Clone, Copy, StableHash)] pub struct WhereEqPredicate<'hir> { pub lhs_ty: &'hir Ty<'hir>, pub rhs_ty: &'hir Ty<'hir>, @@ -1187,7 +1187,7 @@ pub struct ParentedNode<'tcx> { } /// Arguments passed to an attribute macro. -#[derive(Clone, Debug, HashStable, Encodable, Decodable)] +#[derive(Clone, Debug, StableHash, Encodable, Decodable)] pub enum AttrArgs { /// No arguments: `#[attr]`. Empty, @@ -1202,7 +1202,7 @@ pub enum AttrArgs { }, } -#[derive(Clone, Debug, HashStable, Encodable, Decodable)] +#[derive(Clone, Debug, StableHash, Encodable, Decodable)] pub struct AttrPath { pub segments: Box<[Symbol]>, pub span: Span, @@ -1238,7 +1238,7 @@ impl fmt::Display for AttrPath { } } -#[derive(Clone, Debug, HashStable, Encodable, Decodable)] +#[derive(Clone, Debug, StableHash, Encodable, Decodable)] pub struct AttrItem { // Not lowered to hir::Path because we have no NodeId to resolve to. pub path: AttrPath, @@ -1251,7 +1251,7 @@ pub struct AttrItem { pub span: Span, } -/// The derived implementation of [`HashStable`] on [`Attribute`]s shouldn't hash +/// The derived implementation of [`StableHash`] on [`Attribute`]s shouldn't hash /// [`AttrId`]s. By wrapping them in this, we make sure we never do. #[derive(Copy, Debug, Encodable, Decodable, Clone)] pub struct HashIgnoredAttrId { @@ -1260,7 +1260,7 @@ pub struct HashIgnoredAttrId { /// Many functions on this type have their documentation in the [`AttributeExt`] trait, /// since they defer their implementation directly to that trait. -#[derive(Clone, Debug, Encodable, Decodable, HashStable)] +#[derive(Clone, Debug, Encodable, Decodable, StableHash)] pub enum Attribute { /// A parsed built-in attribute. /// @@ -1619,7 +1619,7 @@ impl fmt::Debug for OwnerNodes<'_> { } /// Full information resulting from lowering an AST node. -#[derive(Debug, HashStable)] +#[derive(Debug, StableHash)] pub struct OwnerInfo<'hir> { /// Contents of the HIR. pub nodes: OwnerNodes<'hir>, @@ -1647,7 +1647,7 @@ impl<'tcx> OwnerInfo<'tcx> { } } -#[derive(Copy, Clone, Debug, HashStable)] +#[derive(Copy, Clone, Debug, StableHash)] pub enum MaybeOwner<'tcx> { Owner(&'tcx OwnerInfo<'tcx>), NonOwner(HirId), @@ -1668,7 +1668,7 @@ impl<'tcx> MaybeOwner<'tcx> { } } -#[derive(Debug, Clone, Copy, HashStable)] +#[derive(Debug, Clone, Copy, StableHash)] pub struct Closure<'hir> { pub def_id: LocalDefId, pub binder: ClosureBinder, @@ -1684,7 +1684,7 @@ pub struct Closure<'hir> { pub kind: ClosureKind, } -#[derive(Clone, PartialEq, Eq, Debug, Copy, Hash, HashStable, Encodable, Decodable)] +#[derive(Clone, PartialEq, Eq, Debug, Copy, Hash, StableHash, Encodable, Decodable)] pub enum ClosureKind { /// This is a plain closure expression. Closure, @@ -1703,7 +1703,7 @@ pub enum ClosureKind { /// A block of statements `{ .. }`, which may have a label (in this case the /// `targeted_by_break` field will be `true`) and may be `unsafe` by means of /// the `rules` being anything but `DefaultBlock`. -#[derive(Debug, Clone, Copy, HashStable)] +#[derive(Debug, Clone, Copy, StableHash)] pub struct Block<'hir> { /// Statements in a block. pub stmts: &'hir [Stmt<'hir>], @@ -1732,13 +1732,13 @@ impl<'hir> Block<'hir> { } } -#[derive(Debug, Clone, Copy, HashStable)] +#[derive(Debug, Clone, Copy, StableHash)] pub struct TyFieldPath { pub variant: Option, pub field: Ident, } -#[derive(Debug, Clone, Copy, HashStable)] +#[derive(Debug, Clone, Copy, StableHash)] pub struct TyPat<'hir> { #[stable_hasher(ignore)] pub hir_id: HirId, @@ -1746,7 +1746,7 @@ pub struct TyPat<'hir> { pub span: Span, } -#[derive(Debug, Clone, Copy, HashStable)] +#[derive(Debug, Clone, Copy, StableHash)] pub struct Pat<'hir> { #[stable_hasher(ignore)] pub hir_id: HirId, @@ -1894,7 +1894,7 @@ impl<'hir> Pat<'hir> { /// Patterns like the fields of Foo `{ x, ref y, ref mut z }` /// are treated the same as` x: x, y: ref y, z: ref mut z`, /// except `is_shorthand` is true. -#[derive(Debug, Clone, Copy, HashStable)] +#[derive(Debug, Clone, Copy, StableHash)] pub struct PatField<'hir> { #[stable_hasher(ignore)] pub hir_id: HirId, @@ -1906,7 +1906,7 @@ pub struct PatField<'hir> { pub span: Span, } -#[derive(Copy, Clone, PartialEq, Debug, HashStable, Hash, Eq, Encodable, Decodable)] +#[derive(Copy, Clone, PartialEq, Debug, StableHash, Hash, Eq, Encodable, Decodable)] pub enum RangeEnd { Included, Excluded, @@ -1924,7 +1924,7 @@ impl fmt::Display for RangeEnd { // Equivalent to `Option`. That type takes up 16 bytes on 64-bit, but // this type only takes up 4 bytes, at the cost of being restricted to a // maximum value of `u32::MAX - 1`. In practice, this is more than enough. -#[derive(Clone, Copy, PartialEq, Eq, Hash, HashStable)] +#[derive(Clone, Copy, PartialEq, Eq, Hash, StableHash)] pub struct DotDotPos(u32); impl DotDotPos { @@ -1950,7 +1950,7 @@ impl fmt::Debug for DotDotPos { } } -#[derive(Debug, Clone, Copy, HashStable)] +#[derive(Debug, Clone, Copy, StableHash)] pub struct PatExpr<'hir> { #[stable_hasher(ignore)] pub hir_id: HirId, @@ -1958,7 +1958,7 @@ pub struct PatExpr<'hir> { pub kind: PatExprKind<'hir>, } -#[derive(Debug, Clone, Copy, HashStable)] +#[derive(Debug, Clone, Copy, StableHash)] pub enum PatExprKind<'hir> { Lit { lit: Lit, @@ -1968,7 +1968,7 @@ pub enum PatExprKind<'hir> { Path(QPath<'hir>), } -#[derive(Debug, Clone, Copy, HashStable)] +#[derive(Debug, Clone, Copy, StableHash)] pub enum TyPatKind<'hir> { /// A range pattern (e.g., `1..=2` or `1..2`). Range(&'hir ConstArg<'hir>, &'hir ConstArg<'hir>), @@ -1983,7 +1983,7 @@ pub enum TyPatKind<'hir> { Err(ErrorGuaranteed), } -#[derive(Debug, Clone, Copy, HashStable)] +#[derive(Debug, Clone, Copy, StableHash)] pub enum PatKind<'hir> { /// A missing pattern, e.g. for an anonymous param in a bare fn like `fn f(u32)`. Missing, @@ -2058,7 +2058,7 @@ pub enum PatKind<'hir> { } /// A statement. -#[derive(Debug, Clone, Copy, HashStable)] +#[derive(Debug, Clone, Copy, StableHash)] pub struct Stmt<'hir> { #[stable_hasher(ignore)] pub hir_id: HirId, @@ -2067,7 +2067,7 @@ pub struct Stmt<'hir> { } /// The contents of a statement. -#[derive(Debug, Clone, Copy, HashStable)] +#[derive(Debug, Clone, Copy, StableHash)] pub enum StmtKind<'hir> { /// A local (`let`) binding. Let(&'hir LetStmt<'hir>), @@ -2083,7 +2083,7 @@ pub enum StmtKind<'hir> { } /// Represents a `let` statement (i.e., `let : = ;`). -#[derive(Debug, Clone, Copy, HashStable)] +#[derive(Debug, Clone, Copy, StableHash)] pub struct LetStmt<'hir> { /// Span of `super` in `super let`. pub super_: Option, @@ -2105,7 +2105,7 @@ pub struct LetStmt<'hir> { /// Represents a single arm of a `match` expression, e.g. /// ` (if ) => `. -#[derive(Debug, Clone, Copy, HashStable)] +#[derive(Debug, Clone, Copy, StableHash)] pub struct Arm<'hir> { #[stable_hasher(ignore)] pub hir_id: HirId, @@ -2123,7 +2123,7 @@ pub struct Arm<'hir> { /// /// In an `if let`, imagine it as `if (let = ) { ... }`; in a let-else, it is part of /// the desugaring to if-let. Only let-else supports the type annotation at present. -#[derive(Debug, Clone, Copy, HashStable)] +#[derive(Debug, Clone, Copy, StableHash)] pub struct LetExpr<'hir> { pub span: Span, pub pat: &'hir Pat<'hir>, @@ -2134,7 +2134,7 @@ pub struct LetExpr<'hir> { pub recovered: ast::Recovered, } -#[derive(Debug, Clone, Copy, HashStable)] +#[derive(Debug, Clone, Copy, StableHash)] pub struct ExprField<'hir> { #[stable_hasher(ignore)] pub hir_id: HirId, @@ -2144,19 +2144,19 @@ pub struct ExprField<'hir> { pub is_shorthand: bool, } -#[derive(Copy, Clone, PartialEq, Debug, HashStable)] +#[derive(Copy, Clone, PartialEq, Debug, StableHash)] pub enum BlockCheckMode { DefaultBlock, UnsafeBlock(UnsafeSource), } -#[derive(Copy, Clone, PartialEq, Debug, HashStable)] +#[derive(Copy, Clone, PartialEq, Debug, StableHash)] pub enum UnsafeSource { CompilerGenerated, UserProvided, } -#[derive(Copy, Clone, PartialEq, Eq, Hash, Debug, HashStable)] +#[derive(Copy, Clone, PartialEq, Eq, Hash, Debug, StableHash)] pub struct BodyId { pub hir_id: HirId, } @@ -2182,7 +2182,7 @@ pub struct BodyId { /// /// All bodies have an **owner**, which can be accessed via the HIR /// map using `body_owner_def_id()`. -#[derive(Debug, Clone, Copy, HashStable)] +#[derive(Debug, Clone, Copy, StableHash)] pub struct Body<'hir> { pub params: &'hir [Param<'hir>], pub value: &'hir Expr<'hir>, @@ -2195,7 +2195,7 @@ impl<'hir> Body<'hir> { } /// The type of source expression that caused this coroutine to be created. -#[derive(Clone, PartialEq, Eq, Debug, Copy, Hash, HashStable, Encodable, Decodable)] +#[derive(Clone, PartialEq, Eq, Debug, Copy, Hash, StableHash, Encodable, Decodable)] pub enum CoroutineKind { /// A coroutine that comes from a desugaring. Desugared(CoroutineDesugaring, CoroutineSource), @@ -2245,7 +2245,7 @@ impl fmt::Display for CoroutineKind { /// /// This helps error messages but is also used to drive coercions in /// type-checking (see #60424). -#[derive(Clone, PartialEq, Eq, Hash, Debug, Copy, HashStable, Encodable, Decodable)] +#[derive(Clone, PartialEq, Eq, Hash, Debug, Copy, StableHash, Encodable, Decodable)] pub enum CoroutineSource { /// An explicit `async`/`gen` block written by the user. Block, @@ -2268,7 +2268,7 @@ impl fmt::Display for CoroutineSource { } } -#[derive(Clone, PartialEq, Eq, Debug, Copy, Hash, HashStable, Encodable, Decodable)] +#[derive(Clone, PartialEq, Eq, Debug, Copy, Hash, StableHash, Encodable, Decodable)] pub enum CoroutineDesugaring { /// An explicit `async` block or the body of an `async` function. Async, @@ -2408,7 +2408,7 @@ pub type Lit = Spanned; /// /// You can check if this anon const is a default in a const param /// `const N: usize = { ... }` with `tcx.hir_opt_const_param_default_param_def_id(..)` -#[derive(Copy, Clone, Debug, HashStable)] +#[derive(Copy, Clone, Debug, StableHash)] pub struct AnonConst { #[stable_hasher(ignore)] pub hir_id: HirId, @@ -2418,7 +2418,7 @@ pub struct AnonConst { } /// An inline constant expression `const { something }`. -#[derive(Copy, Clone, Debug, HashStable)] +#[derive(Copy, Clone, Debug, StableHash)] pub struct ConstBlock { #[stable_hasher(ignore)] pub hir_id: HirId, @@ -2434,7 +2434,7 @@ pub struct ConstBlock { /// the compiler and the reference. /// /// [rust lang reference]: https://doc.rust-lang.org/reference/expressions.html -#[derive(Debug, Clone, Copy, HashStable)] +#[derive(Debug, Clone, Copy, StableHash)] pub struct Expr<'hir> { #[stable_hasher(ignore)] pub hir_id: HirId, @@ -2793,7 +2793,7 @@ pub fn expr_needs_parens(expr: &Expr<'_>) -> bool { } } -#[derive(Debug, Clone, Copy, HashStable)] +#[derive(Debug, Clone, Copy, StableHash)] pub enum ExprKind<'hir> { /// Allow anonymous constants from an inline `const` block ConstBlock(ConstBlock), @@ -2932,7 +2932,7 @@ pub enum ExprKind<'hir> { Err(rustc_span::ErrorGuaranteed), } -#[derive(Debug, Clone, Copy, HashStable)] +#[derive(Debug, Clone, Copy, StableHash)] pub enum StructTailExpr<'hir> { /// A struct expression where all the fields are explicitly enumerated: `Foo { a, b }`. None, @@ -2956,7 +2956,7 @@ pub enum StructTailExpr<'hir> { /// To resolve the path to a `DefId`, call [`qpath_res`]. /// /// [`qpath_res`]: ../../rustc_middle/ty/struct.TypeckResults.html#method.qpath_res -#[derive(Debug, Clone, Copy, HashStable)] +#[derive(Debug, Clone, Copy, StableHash)] pub enum QPath<'hir> { /// Path to a definition, optionally "fully-qualified" with a `Self` /// type, if the path points to an associated item in a trait. @@ -2995,7 +2995,7 @@ impl<'hir> QPath<'hir> { } /// Hints at the original code for a let statement. -#[derive(Copy, Clone, Debug, HashStable)] +#[derive(Copy, Clone, Debug, StableHash)] pub enum LocalSource { /// A `match _ { .. }`. Normal, @@ -3019,7 +3019,7 @@ pub enum LocalSource { } /// Hints at the original code for a `match _ { .. }`. -#[derive(Copy, Clone, PartialEq, Eq, Hash, Debug, HashStable, Encodable, Decodable)] +#[derive(Copy, Clone, PartialEq, Eq, Hash, Debug, StableHash, Encodable, Decodable)] pub enum MatchSource { /// A `match _ { .. }`. Normal, @@ -3051,7 +3051,7 @@ impl MatchSource { } /// The loop type that yielded an `ExprKind::Loop`. -#[derive(Copy, Clone, PartialEq, Debug, HashStable)] +#[derive(Copy, Clone, PartialEq, Debug, StableHash)] pub enum LoopSource { /// A `loop { .. }` loop. Loop, @@ -3071,7 +3071,7 @@ impl LoopSource { } } -#[derive(Copy, Clone, Debug, PartialEq, HashStable)] +#[derive(Copy, Clone, Debug, PartialEq, StableHash)] pub enum LoopIdError { OutsideLoopScope, UnlabeledCfInWhileCondition, @@ -3090,7 +3090,7 @@ impl fmt::Display for LoopIdError { } } -#[derive(Copy, Clone, Debug, PartialEq, HashStable)] +#[derive(Copy, Clone, Debug, PartialEq, StableHash)] pub struct Destination { /// This is `Some(_)` iff there is an explicit user-specified 'label pub label: Option