Skip to content

Commit 394f719

Browse files
committed
Allow to hash HIR for coverage.
1 parent 7a209bb commit 394f719

File tree

1 file changed

+6
-10
lines changed
  • compiler/rustc_mir_transform/src/coverage

1 file changed

+6
-10
lines changed

compiler/rustc_mir_transform/src/coverage/mod.rs

+6-10
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ use spans::{CoverageSpan, CoverageSpans};
1414

1515
use crate::MirPass;
1616

17-
use rustc_data_structures::fingerprint::Fingerprint;
1817
use rustc_data_structures::graph::WithNumNodes;
1918
use rustc_data_structures::stable_hasher::{HashStable, StableHasher};
2019
use rustc_data_structures::sync::Lrc;
@@ -29,7 +28,6 @@ use rustc_middle::mir::{
2928
TerminatorKind,
3029
};
3130
use rustc_middle::ty::TyCtxt;
32-
use rustc_query_system::ich::StableHashingContext;
3331
use rustc_span::def_id::DefId;
3432
use rustc_span::source_map::SourceMap;
3533
use rustc_span::{CharPos, ExpnKind, Pos, SourceFile, Span, Symbol};
@@ -574,15 +572,13 @@ fn get_body_span<'tcx>(
574572
}
575573

576574
fn hash_mir_source<'tcx>(tcx: TyCtxt<'tcx>, hir_body: &'tcx rustc_hir::Body<'tcx>) -> u64 {
575+
// FIXME(cjgillot) Stop hashing HIR manually here.
577576
let mut hcx = tcx.create_no_span_stable_hashing_context();
578-
hash(&mut hcx, &hir_body.value).to_smaller_hash()
579-
}
580-
581-
fn hash(
582-
hcx: &mut StableHashingContext<'tcx>,
583-
node: &impl HashStable<StableHashingContext<'tcx>>,
584-
) -> Fingerprint {
585577
let mut stable_hasher = StableHasher::new();
586-
node.hash_stable(hcx, &mut stable_hasher);
578+
let owner = hir_body.id().hir_id.owner;
579+
let bodies = &tcx.hir_owner_nodes(owner).as_ref().unwrap().bodies;
580+
hcx.with_hir_bodies(false, owner, bodies, |hcx| {
581+
hir_body.value.hash_stable(hcx, &mut stable_hasher)
582+
});
587583
stable_hasher.finish()
588584
}

0 commit comments

Comments
 (0)