diff options
| author | Zalathar <Zalathar@users.noreply.github.com> | 2025-08-02 23:06:48 +1000 |
|---|---|---|
| committer | Zalathar <Zalathar@users.noreply.github.com> | 2025-08-02 23:11:53 +1000 |
| commit | d3e597a1322575dd15ede6a032402488fdc6161d (patch) | |
| tree | 2572134be7165934e4c94cbf1dc81b9a7883e0a8 | |
| parent | 40f587aa0d0a792b3f4e558e739c591534778eb3 (diff) | |
| download | rust-d3e597a1322575dd15ede6a032402488fdc6161d.tar.gz rust-d3e597a1322575dd15ede6a032402488fdc6161d.zip | |
Return a struct with named fields from `hash_owner_nodes`
| -rw-r--r-- | compiler/rustc_ast_lowering/src/lib.rs | 2 | ||||
| -rw-r--r-- | compiler/rustc_middle/src/hir/mod.rs | 22 | ||||
| -rw-r--r-- | compiler/rustc_middle/src/ty/context.rs | 2 |
3 files changed, 21 insertions, 5 deletions
diff --git a/compiler/rustc_ast_lowering/src/lib.rs b/compiler/rustc_ast_lowering/src/lib.rs index 189c82b614c..d097e3cbaa8 100644 --- a/compiler/rustc_ast_lowering/src/lib.rs +++ b/compiler/rustc_ast_lowering/src/lib.rs @@ -675,7 +675,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> { let bodies = SortedMap::from_presorted_elements(bodies); // Don't hash unless necessary, because it's expensive. - let (opt_hash_including_bodies, attrs_hash, delayed_lints_hash) = + let rustc_middle::hir::Hashes { opt_hash_including_bodies, attrs_hash, delayed_lints_hash } = self.tcx.hash_owner_nodes(node, &bodies, &attrs, &delayed_lints, define_opaque); let num_nodes = self.item_local_id_counter.as_usize(); let (nodes, parenting) = index::index_hir(self.tcx, node, &bodies, num_nodes); diff --git a/compiler/rustc_middle/src/hir/mod.rs b/compiler/rustc_middle/src/hir/mod.rs index a928703542f..67bc89692ff 100644 --- a/compiler/rustc_middle/src/hir/mod.rs +++ b/compiler/rustc_middle/src/hir/mod.rs @@ -174,9 +174,13 @@ impl<'tcx> TyCtxt<'tcx> { attrs: &SortedMap<ItemLocalId, &[Attribute]>, delayed_lints: &[DelayedLint], define_opaque: Option<&[(Span, LocalDefId)]>, - ) -> (Option<Fingerprint>, Option<Fingerprint>, Option<Fingerprint>) { + ) -> Hashes { if !self.needs_crate_hash() { - return (None, None, None); + return Hashes { + opt_hash_including_bodies: None, + attrs_hash: None, + delayed_lints_hash: None, + }; } self.with_stable_hashing_context(|mut hcx| { @@ -199,11 +203,23 @@ impl<'tcx> TyCtxt<'tcx> { delayed_lints.hash_stable(&mut hcx, &mut stable_hasher); let h3 = stable_hasher.finish(); - (Some(h1), Some(h2), Some(h3)) + Hashes { + opt_hash_including_bodies: Some(h1), + attrs_hash: Some(h2), + delayed_lints_hash: Some(h3), + } }) } } +/// Hashes computed by [`TyCtxt::hash_owner_nodes`] if necessary. +#[derive(Clone, Copy, Debug)] +pub struct Hashes { + pub opt_hash_including_bodies: Option<Fingerprint>, + pub attrs_hash: Option<Fingerprint>, + pub delayed_lints_hash: Option<Fingerprint>, +} + pub fn provide(providers: &mut Providers) { providers.hir_crate_items = map::hir_crate_items; providers.crate_hash = map::crate_hash; diff --git a/compiler/rustc_middle/src/ty/context.rs b/compiler/rustc_middle/src/ty/context.rs index f4ee3d7971c..d583c5d496e 100644 --- a/compiler/rustc_middle/src/ty/context.rs +++ b/compiler/rustc_middle/src/ty/context.rs @@ -1381,7 +1381,7 @@ impl<'tcx> TyCtxtFeed<'tcx, LocalDefId> { let bodies = Default::default(); let attrs = hir::AttributeMap::EMPTY; - let (opt_hash_including_bodies, _, _) = + let rustc_middle::hir::Hashes { opt_hash_including_bodies, .. } = self.tcx.hash_owner_nodes(node, &bodies, &attrs.map, &[], attrs.define_opaque); let node = node.into(); self.opt_hir_owner_nodes(Some(self.tcx.arena.alloc(hir::OwnerNodes { |
