Skip to content

Commit 71ab10d

Browse files
committed
Auto merge of #51982 - michaelwoerister:hash-modules-properly, r=<try>
incr.comp.: Take names of children into account when computing the ICH of a module's HIR. Fixes #40876. Red-green tracking does not make this a problem anymore. We should verify this via a perf-run though. r? @nikomatsakis
2 parents e75e782 + 79d8d08 commit 71ab10d

File tree

2 files changed

+24
-10
lines changed

2 files changed

+24
-10
lines changed

src/librustc/ich/impls_hir.rs

+22-7
Original file line numberDiff line numberDiff line change
@@ -756,13 +756,28 @@ impl_stable_hash_for!(enum hir::ImplPolarity {
756756
Negative
757757
});
758758

759-
impl_stable_hash_for!(struct hir::Mod {
760-
inner,
761-
// We are not hashing the IDs of the items contained in the module.
762-
// This is harmless and matches the current behavior but it's not
763-
// actually correct. See issue #40876.
764-
item_ids -> _,
765-
});
759+
impl<'a> HashStable<StableHashingContext<'a>> for hir::Mod {
760+
fn hash_stable<W: StableHasherResult>(&self,
761+
hcx: &mut StableHashingContext<'a>,
762+
hasher: &mut StableHasher<W>) {
763+
let hir::Mod {
764+
inner: ref inner_span,
765+
ref item_ids,
766+
} = *self;
767+
768+
inner_span.hash_stable(hcx, hasher);
769+
770+
let mut item_ids: Vec<DefPathHash> = item_ids.iter().map(|id| {
771+
let (def_path_hash, local_id) = id.id.to_stable_hash_key(hcx);
772+
debug_assert_eq!(local_id, hir::ItemLocalId(0));
773+
def_path_hash
774+
}).collect();
775+
776+
item_ids.sort_unstable();
777+
778+
item_ids.hash_stable(hcx, hasher);
779+
}
780+
}
766781

767782
impl_stable_hash_for!(struct hir::ForeignMod {
768783
abi,

src/librustc_codegen_llvm/mono_item.rs

+2-3
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,10 @@ use monomorphize::Instance;
2525
use type_of::LayoutLlvmExt;
2626
use rustc::hir;
2727
use rustc::hir::def::Def;
28-
use rustc::hir::def_id::DefId;
28+
use rustc::hir::def_id::{DefId, LOCAL_CRATE};
2929
use rustc::mir::mono::{Linkage, Visibility};
3030
use rustc::ty::TypeFoldable;
3131
use rustc::ty::layout::LayoutOf;
32-
use syntax::attr;
3332
use std::fmt;
3433

3534
pub use rustc::mir::mono::MonoItem;
@@ -173,7 +172,7 @@ fn predefine_fn<'a, 'tcx>(cx: &CodegenCx<'a, 'tcx>,
173172
// visibility as we're going to link this object all over the place but
174173
// don't want the symbols to get exported.
175174
if linkage != Linkage::Internal && linkage != Linkage::Private &&
176-
attr::contains_name(cx.tcx.hir.krate_attrs(), "compiler_builtins") {
175+
cx.tcx.is_compiler_builtins(LOCAL_CRATE) {
177176
unsafe {
178177
llvm::LLVMRustSetVisibility(lldecl, llvm::Visibility::Hidden);
179178
}

0 commit comments

Comments
 (0)