From 79d8d087a3d911ddcd881e452a7e72a8a7121435 Mon Sep 17 00:00:00 2001 From: Michael Woerister Date: Mon, 2 Jul 2018 16:21:34 +0200 Subject: [PATCH] incr.comp.: Take names of children into account when computing the ICH of a module's HIR. --- src/librustc/ich/impls_hir.rs | 29 +++++++++++++++++++------- src/librustc_codegen_llvm/mono_item.rs | 5 ++--- 2 files changed, 24 insertions(+), 10 deletions(-) diff --git a/src/librustc/ich/impls_hir.rs b/src/librustc/ich/impls_hir.rs index 0c7baea85ad8f..8917051bfd8ae 100644 --- a/src/librustc/ich/impls_hir.rs +++ b/src/librustc/ich/impls_hir.rs @@ -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> for hir::Mod { + fn hash_stable(&self, + hcx: &mut StableHashingContext<'a>, + hasher: &mut StableHasher) { + let hir::Mod { + inner: ref inner_span, + ref item_ids, + } = *self; + + inner_span.hash_stable(hcx, hasher); + + let mut item_ids: Vec = 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, diff --git a/src/librustc_codegen_llvm/mono_item.rs b/src/librustc_codegen_llvm/mono_item.rs index 6ba3582f0143b..c4a23ac653ca0 100644 --- a/src/librustc_codegen_llvm/mono_item.rs +++ b/src/librustc_codegen_llvm/mono_item.rs @@ -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; @@ -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); }