Skip to content

Commit 2275f81

Browse files
committed
Use Fingerprint instead of full path
1 parent 8317aa1 commit 2275f81

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

compiler/rustc_middle/src/middle/cstore.rs

+8-2
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ use crate::ty::TyCtxt;
66

77
use rustc_ast as ast;
88
use rustc_ast::expand::allocator::AllocatorKind;
9+
use rustc_data_structures::fingerprint::Fingerprint;
10+
use rustc_data_structures::stable_hasher::{HashStable, StableHasher};
911
use rustc_data_structures::svh::Svh;
1012
use rustc_data_structures::sync::{self, MetadataRef};
1113
use rustc_hir::def::DefKind;
@@ -272,12 +274,16 @@ pub struct HashAndState<T> {
272274
/// This field is private, and never needs to be accessed by callers of `crate_hash`
273275
/// or `host_crate_hash`. Its sole purpose is to be hashed as part of the
274276
/// `HashStable` impl, so that its value influences the hash used by incremental compilation.
275-
real_rust_source_base_dir: Option<PathBuf>,
277+
real_rust_source_base_dir: Fingerprint,
276278
}
277279

278280
impl<T> HashAndState<T> {
279281
pub fn new(tcx: TyCtxt<'tcx>, svh: T) -> HashAndState<T> {
280-
HashAndState { svh, real_rust_source_base_dir: tcx.sess.real_rust_source_base_dir.clone() }
282+
let mut hasher = StableHasher::new();
283+
let mut hcx = tcx.create_stable_hashing_context();
284+
tcx.sess.real_rust_source_base_dir.hash_stable(&mut hcx, &mut hasher);
285+
let real_rust_source_base_dir = hasher.finish();
286+
HashAndState { svh, real_rust_source_base_dir }
281287
}
282288
}
283289

0 commit comments

Comments
 (0)