Skip to content

Commit d3e597a

Browse files
committed
Return a struct with named fields from hash_owner_nodes
1 parent 40f587a commit d3e597a

File tree

3 files changed

+21
-5
lines changed

3 files changed

+21
-5
lines changed

compiler/rustc_ast_lowering/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -675,7 +675,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
675675
let bodies = SortedMap::from_presorted_elements(bodies);
676676

677677
// Don't hash unless necessary, because it's expensive.
678-
let (opt_hash_including_bodies, attrs_hash, delayed_lints_hash) =
678+
let rustc_middle::hir::Hashes { opt_hash_including_bodies, attrs_hash, delayed_lints_hash } =
679679
self.tcx.hash_owner_nodes(node, &bodies, &attrs, &delayed_lints, define_opaque);
680680
let num_nodes = self.item_local_id_counter.as_usize();
681681
let (nodes, parenting) = index::index_hir(self.tcx, node, &bodies, num_nodes);

compiler/rustc_middle/src/hir/mod.rs

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -174,9 +174,13 @@ impl<'tcx> TyCtxt<'tcx> {
174174
attrs: &SortedMap<ItemLocalId, &[Attribute]>,
175175
delayed_lints: &[DelayedLint],
176176
define_opaque: Option<&[(Span, LocalDefId)]>,
177-
) -> (Option<Fingerprint>, Option<Fingerprint>, Option<Fingerprint>) {
177+
) -> Hashes {
178178
if !self.needs_crate_hash() {
179-
return (None, None, None);
179+
return Hashes {
180+
opt_hash_including_bodies: None,
181+
attrs_hash: None,
182+
delayed_lints_hash: None,
183+
};
180184
}
181185

182186
self.with_stable_hashing_context(|mut hcx| {
@@ -199,11 +203,23 @@ impl<'tcx> TyCtxt<'tcx> {
199203
delayed_lints.hash_stable(&mut hcx, &mut stable_hasher);
200204
let h3 = stable_hasher.finish();
201205

202-
(Some(h1), Some(h2), Some(h3))
206+
Hashes {
207+
opt_hash_including_bodies: Some(h1),
208+
attrs_hash: Some(h2),
209+
delayed_lints_hash: Some(h3),
210+
}
203211
})
204212
}
205213
}
206214

215+
/// Hashes computed by [`TyCtxt::hash_owner_nodes`] if necessary.
216+
#[derive(Clone, Copy, Debug)]
217+
pub struct Hashes {
218+
pub opt_hash_including_bodies: Option<Fingerprint>,
219+
pub attrs_hash: Option<Fingerprint>,
220+
pub delayed_lints_hash: Option<Fingerprint>,
221+
}
222+
207223
pub fn provide(providers: &mut Providers) {
208224
providers.hir_crate_items = map::hir_crate_items;
209225
providers.crate_hash = map::crate_hash;

compiler/rustc_middle/src/ty/context.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1381,7 +1381,7 @@ impl<'tcx> TyCtxtFeed<'tcx, LocalDefId> {
13811381
let bodies = Default::default();
13821382
let attrs = hir::AttributeMap::EMPTY;
13831383

1384-
let (opt_hash_including_bodies, _, _) =
1384+
let rustc_middle::hir::Hashes { opt_hash_including_bodies, .. } =
13851385
self.tcx.hash_owner_nodes(node, &bodies, &attrs.map, &[], attrs.define_opaque);
13861386
let node = node.into();
13871387
self.opt_hir_owner_nodes(Some(self.tcx.arena.alloc(hir::OwnerNodes {

0 commit comments

Comments
 (0)