Skip to content

Commit

Permalink
Auto merge of #51982 - michaelwoerister:hash-modules-properly, r=<try>
Browse files Browse the repository at this point in the history
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
  • Loading branch information
bors committed Jul 2, 2018
2 parents e75e782 + 79d8d08 commit 71ab10d
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 10 deletions.
29 changes: 22 additions & 7 deletions src/librustc/ich/impls_hir.rs
Original file line number Diff line number Diff line change
Expand Up @@ -756,13 +756,28 @@ impl_stable_hash_for!(enum hir::ImplPolarity {
Negative
});

impl_stable_hash_for!(struct hir::Mod {
inner,
// We are not hashing the IDs of the items contained in the module.
// This is harmless and matches the current behavior but it's not
// actually correct. See issue #40876.
item_ids -> _,
});
impl<'a> HashStable<StableHashingContext<'a>> for hir::Mod {
fn hash_stable<W: StableHasherResult>(&self,
hcx: &mut StableHashingContext<'a>,
hasher: &mut StableHasher<W>) {
let hir::Mod {
inner: ref inner_span,
ref item_ids,
} = *self;

inner_span.hash_stable(hcx, hasher);

let mut item_ids: Vec<DefPathHash> = item_ids.iter().map(|id| {
let (def_path_hash, local_id) = id.id.to_stable_hash_key(hcx);
debug_assert_eq!(local_id, hir::ItemLocalId(0));
def_path_hash
}).collect();

item_ids.sort_unstable();

item_ids.hash_stable(hcx, hasher);
}
}

impl_stable_hash_for!(struct hir::ForeignMod {
abi,
Expand Down
5 changes: 2 additions & 3 deletions src/librustc_codegen_llvm/mono_item.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,10 @@ use monomorphize::Instance;
use type_of::LayoutLlvmExt;
use rustc::hir;
use rustc::hir::def::Def;
use rustc::hir::def_id::DefId;
use rustc::hir::def_id::{DefId, LOCAL_CRATE};
use rustc::mir::mono::{Linkage, Visibility};
use rustc::ty::TypeFoldable;
use rustc::ty::layout::LayoutOf;
use syntax::attr;
use std::fmt;

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

0 comments on commit 71ab10d

Please sign in to comment.