diff --git a/compiler/rustc_ast_lowering/src/lib.rs b/compiler/rustc_ast_lowering/src/lib.rs index 3c8abf3ee2bbb..278c82c5eeb6d 100644 --- a/compiler/rustc_ast_lowering/src/lib.rs +++ b/compiler/rustc_ast_lowering/src/lib.rs @@ -563,7 +563,7 @@ pub fn lower_to_hir(tcx: TyCtxt<'_>, (): ()) -> mid_hir::Crate<'_> { // Don't hash unless necessary, because it's expensive. let opt_hir_hash = - if tcx.needs_crate_hash() { Some(compute_hir_hash(tcx, &owners)) } else { None }; + if tcx.needs_hir_hash() { Some(compute_hir_hash(tcx, &owners)) } else { None }; let delayed_resolver = Steal::new((resolver, krate)); mid_hir::Crate::new(owners, delayed_ids, delayed_resolver, opt_hir_hash) diff --git a/compiler/rustc_interface/src/queries.rs b/compiler/rustc_interface/src/queries.rs index 170393f3b8179..63c7332893b81 100644 --- a/compiler/rustc_interface/src/queries.rs +++ b/compiler/rustc_interface/src/queries.rs @@ -36,7 +36,7 @@ impl Linker { Linker { dep_graph: tcx.dep_graph.clone(), output_filenames: Arc::clone(tcx.output_filenames(())), - crate_hash: if tcx.needs_crate_hash() { + crate_hash: if tcx.sess.opts.incremental.is_some() { Some(tcx.crate_hash(LOCAL_CRATE)) } else { None diff --git a/compiler/rustc_middle/src/hir/mod.rs b/compiler/rustc_middle/src/hir/mod.rs index 492d21b3169a8..2d55078bc4d3e 100644 --- a/compiler/rustc_middle/src/hir/mod.rs +++ b/compiler/rustc_middle/src/hir/mod.rs @@ -237,7 +237,7 @@ impl<'tcx> TyCtxt<'tcx> { attrs: &SortedMap, define_opaque: Option<&[(Span, LocalDefId)]>, ) -> Hashes { - if !self.needs_crate_hash() { + if !self.needs_hir_hash() { return Hashes { opt_hash_including_bodies: None, attrs_hash: None }; } diff --git a/compiler/rustc_middle/src/ty/context.rs b/compiler/rustc_middle/src/ty/context.rs index bbe241c574d41..2a80ea670353a 100644 --- a/compiler/rustc_middle/src/ty/context.rs +++ b/compiler/rustc_middle/src/ty/context.rs @@ -1136,12 +1136,12 @@ impl<'tcx> TyCtxt<'tcx> { }) } - pub fn needs_crate_hash(self) -> bool { - // Why is the crate hash needed for these configurations? + pub fn needs_hir_hash(self) -> bool { + // Why is the hir hash needed for these configurations? // - debug_assertions: for the "fingerprint the result" check in // `rustc_query_impl::execution::execute_job`. // - incremental: for query lookups. - // - needs_metadata: for putting into crate metadata. + // - needs_metadata: it is included in the crate metadata through the crate_hash query // - instrument_coverage: for putting into coverage data (see // `hash_mir_source`). // - metrics_dir: metrics use the strict version hash in the filenames