about summary refs log tree commit diff
diff options
context:
space:
mode:
authorMichael Woerister <michaelwoerister@posteo>2017-09-18 12:14:52 +0200
committerMichael Woerister <michaelwoerister@posteo>2017-09-18 12:14:52 +0200
commit74d6b850fd731597fe2f03408a0397a972c13641 (patch)
tree8bad0564fefd57cc91f7efa63cb7a6801fa5cc61
parentd5b1fee6fd658bf464902d46f9a6c9c2f8ab87d7 (diff)
downloadrust-74d6b850fd731597fe2f03408a0397a972c13641.tar.gz
rust-74d6b850fd731597fe2f03408a0397a972c13641.zip
incr.comp.: Fix rebase fallout.
-rw-r--r--src/librustc/ich/hcx.rs4
-rw-r--r--src/librustc/infer/error_reporting/different_lifetimes.rs12
-rw-r--r--src/librustc/middle/exported_symbols.rs5
-rw-r--r--src/librustc/middle/trans.rs79
-rw-r--r--src/librustc/session/config.rs33
-rw-r--r--src/librustc_data_structures/stable_hasher.rs8
-rw-r--r--src/librustc_trans/base.rs25
-rw-r--r--src/librustc_trans/context.rs3
8 files changed, 138 insertions, 31 deletions
diff --git a/src/librustc/ich/hcx.rs b/src/librustc/ich/hcx.rs
index 0a2566f0692..64fc63002da 100644
--- a/src/librustc/ich/hcx.rs
+++ b/src/librustc/ich/hcx.rs
@@ -15,7 +15,7 @@ use hir::map::definitions::Definitions;
 use ich::{self, CachingCodemapView};
 use middle::cstore::CrateStore;
 use session::config::DebugInfoLevel::NoDebugInfo;
-use ty::{self, TyCtxt, fast_reject};
+use ty::{TyCtxt, fast_reject};
 use session::Session;
 
 use std::cmp::Ord;
@@ -252,7 +252,7 @@ impl<'gcx> StableHashingContext<'gcx> {
     }
 }
 
-impl<'a, 'gcx, 'lcx> StableHashingContextProvider for ty::TyCtxt<'a, 'gcx, 'lcx> {
+impl<'a, 'gcx, 'lcx> StableHashingContextProvider for TyCtxt<'a, 'gcx, 'lcx> {
     type ContextType = StableHashingContext<'gcx>;
     fn create_stable_hashing_context(&self) -> Self::ContextType {
         (*self).create_stable_hashing_context()
diff --git a/src/librustc/infer/error_reporting/different_lifetimes.rs b/src/librustc/infer/error_reporting/different_lifetimes.rs
index ef28b5b42b0..6c57130a995 100644
--- a/src/librustc/infer/error_reporting/different_lifetimes.rs
+++ b/src/librustc/infer/error_reporting/different_lifetimes.rs
@@ -332,10 +332,8 @@ impl<'a, 'gcx, 'tcx> Visitor<'gcx> for TyPathVisitor<'a, 'gcx, 'tcx> {
 
             (Some(rl::Region::EarlyBound(_, id)), ty::BrNamed(def_id, _)) => {
                 debug!("EarlyBound self.infcx.tcx.hir.local_def_id(id)={:?} \
-                                        def_id={:?}",
-                       self.infcx.tcx.hir.local_def_id(id),
-                       def_id);
-                if self.infcx.tcx.hir.local_def_id(id) == def_id {
+                                        def_id={:?}", id, def_id);
+                if id == def_id {
                     self.found_it = true;
                     return; // we can stop visiting now
                 }
@@ -344,11 +342,9 @@ impl<'a, 'gcx, 'tcx> Visitor<'gcx> for TyPathVisitor<'a, 'gcx, 'tcx> {
             (Some(rl::Region::LateBound(debruijn_index, id)), ty::BrNamed(def_id, _)) => {
                 debug!("FindNestedTypeVisitor::visit_ty: LateBound depth = {:?}",
                        debruijn_index.depth);
-                debug!("self.infcx.tcx.hir.local_def_id(id)={:?}",
-                       self.infcx.tcx.hir.local_def_id(id));
+                debug!("id={:?}", id);
                 debug!("def_id={:?}", def_id);
-                if debruijn_index.depth == self.depth &&
-                   self.infcx.tcx.hir.local_def_id(id) == def_id {
+                if debruijn_index.depth == self.depth && id == def_id {
                     self.found_it = true;
                     return; // we can stop visiting now
                 }
diff --git a/src/librustc/middle/exported_symbols.rs b/src/librustc/middle/exported_symbols.rs
index 230878f8545..d650dbe88b5 100644
--- a/src/librustc/middle/exported_symbols.rs
+++ b/src/librustc/middle/exported_symbols.rs
@@ -19,6 +19,11 @@ pub enum SymbolExportLevel {
     Rust,
 }
 
+impl_stable_hash_for!(enum self::SymbolExportLevel {
+    C,
+    Rust
+});
+
 impl SymbolExportLevel {
     pub fn is_below_threshold(self, threshold: SymbolExportLevel) -> bool {
         if threshold == SymbolExportLevel::Rust {
diff --git a/src/librustc/middle/trans.rs b/src/librustc/middle/trans.rs
index 9a501257548..7744c9c3d12 100644
--- a/src/librustc/middle/trans.rs
+++ b/src/librustc/middle/trans.rs
@@ -12,6 +12,9 @@ use syntax::ast::NodeId;
 use syntax::symbol::InternedString;
 use ty::Instance;
 use util::nodemap::FxHashMap;
+use rustc_data_structures::stable_hasher::{HashStable, StableHasherResult,
+                                           StableHasher};
+use ich::{Fingerprint, StableHashingContext, NodeIdHashingMode};
 
 #[derive(PartialEq, Eq, Clone, Copy, Debug, Hash)]
 pub enum TransItem<'tcx> {
@@ -20,6 +23,26 @@ pub enum TransItem<'tcx> {
     GlobalAsm(NodeId),
 }
 
+impl<'tcx> HashStable<StableHashingContext<'tcx>> for TransItem<'tcx> {
+    fn hash_stable<W: StableHasherResult>(&self,
+                                           hcx: &mut StableHashingContext<'tcx>,
+                                           hasher: &mut StableHasher<W>) {
+        ::std::mem::discriminant(self).hash_stable(hcx, hasher);
+
+        match *self {
+            TransItem::Fn(ref instance) => {
+                instance.hash_stable(hcx, hasher);
+            }
+            TransItem::Static(node_id)    |
+            TransItem::GlobalAsm(node_id) => {
+                hcx.with_node_id_hashing_mode(NodeIdHashingMode::HashDefPath, |hcx| {
+                    node_id.hash_stable(hcx, hasher);
+                })
+            }
+        }
+    }
+}
+
 pub struct CodegenUnit<'tcx> {
     /// A name for this CGU. Incremental compilation requires that
     /// name be unique amongst **all** crates.  Therefore, it should
@@ -44,6 +67,20 @@ pub enum Linkage {
     Common,
 }
 
+impl_stable_hash_for!(enum self::Linkage {
+    External,
+    AvailableExternally,
+    LinkOnceAny,
+    LinkOnceODR,
+    WeakAny,
+    WeakODR,
+    Appending,
+    Internal,
+    Private,
+    ExternalWeak,
+    Common
+});
+
 #[derive(Copy, Clone, PartialEq, Eq, Hash, Debug)]
 pub enum Visibility {
     Default,
@@ -51,6 +88,12 @@ pub enum Visibility {
     Protected,
 }
 
+impl_stable_hash_for!(enum self::Visibility {
+    Default,
+    Hidden,
+    Protected
+});
+
 impl<'tcx> CodegenUnit<'tcx> {
     pub fn new(name: InternedString) -> CodegenUnit<'tcx> {
         CodegenUnit {
@@ -78,6 +121,29 @@ impl<'tcx> CodegenUnit<'tcx> {
     }
 }
 
+impl<'tcx> HashStable<StableHashingContext<'tcx>> for CodegenUnit<'tcx> {
+    fn hash_stable<W: StableHasherResult>(&self,
+                                           hcx: &mut StableHashingContext<'tcx>,
+                                           hasher: &mut StableHasher<W>) {
+        let CodegenUnit {
+            ref items,
+            name,
+        } = *self;
+
+        name.hash_stable(hcx, hasher);
+
+        let mut items: Vec<(Fingerprint, _)> = items.iter().map(|(trans_item, &attrs)| {
+            let mut hasher = StableHasher::new();
+            trans_item.hash_stable(hcx, &mut hasher);
+            let trans_item_fingerprint = hasher.finish();
+            (trans_item_fingerprint, attrs)
+        }).collect();
+
+        items.sort_unstable_by_key(|i| i.0);
+        items.hash_stable(hcx, hasher);
+    }
+}
+
 #[derive(Clone, Default)]
 pub struct Stats {
     pub n_glues_created: usize,
@@ -92,6 +158,18 @@ pub struct Stats {
     pub fn_stats: Vec<(String, usize)>,
 }
 
+impl_stable_hash_for!(struct self::Stats {
+    n_glues_created,
+    n_null_glues,
+    n_real_glues,
+    n_fns,
+    n_inlines,
+    n_closures,
+    n_llvm_insns,
+    llvm_insns,
+    fn_stats
+});
+
 impl Stats {
     pub fn extend(&mut self, stats: Stats) {
         self.n_glues_created += stats.n_glues_created;
@@ -108,3 +186,4 @@ impl Stats {
         self.fn_stats.extend(stats.fn_stats);
     }
 }
+
diff --git a/src/librustc/session/config.rs b/src/librustc/session/config.rs
index df2de17f1e4..f079d7d4338 100644
--- a/src/librustc/session/config.rs
+++ b/src/librustc/session/config.rs
@@ -19,8 +19,10 @@ pub use self::DebugInfoLevel::*;
 use session::{early_error, early_warn, Session};
 use session::search_paths::SearchPaths;
 
+use ich::StableHashingContext;
 use rustc_back::{LinkerFlavor, PanicStrategy, RelroLevel};
 use rustc_back::target::Target;
+use rustc_data_structures::stable_hasher::ToStableHashKey;
 use lint;
 use middle::cstore;
 
@@ -90,6 +92,25 @@ pub enum OutputType {
     DepInfo,
 }
 
+impl_stable_hash_for!(enum self::OutputType {
+    Bitcode,
+    Assembly,
+    LlvmAssembly,
+    Mir,
+    Metadata,
+    Object,
+    Exe,
+    DepInfo
+});
+
+impl<'tcx> ToStableHashKey<StableHashingContext<'tcx>> for OutputType {
+    type KeyType = OutputType;
+    #[inline]
+    fn to_stable_hash_key(&self, _: &StableHashingContext<'tcx>) -> Self::KeyType {
+        *self
+    }
+}
+
 impl OutputType {
     fn is_compatible_with_codegen_units_and_single_output_file(&self) -> bool {
         match *self {
@@ -149,6 +170,10 @@ impl Default for ErrorOutputType {
 #[derive(Clone, Hash)]
 pub struct OutputTypes(BTreeMap<OutputType, Option<PathBuf>>);
 
+impl_stable_hash_for!(tuple_struct self::OutputTypes {
+    map
+});
+
 impl OutputTypes {
     pub fn new(entries: &[(OutputType, Option<PathBuf>)]) -> OutputTypes {
         OutputTypes(BTreeMap::from_iter(entries.iter()
@@ -373,6 +398,14 @@ pub struct OutputFilenames {
     pub outputs: OutputTypes,
 }
 
+impl_stable_hash_for!(struct self::OutputFilenames {
+    out_directory,
+    out_filestem,
+    single_output_file,
+    extra,
+    outputs
+});
+
 /// Codegen unit names generated by the numbered naming scheme will contain this
 /// marker right before the index of the codegen unit.
 pub const NUMBERED_CODEGEN_UNIT_MARKER: &'static str = ".cgu-";
diff --git a/src/librustc_data_structures/stable_hasher.rs b/src/librustc_data_structures/stable_hasher.rs
index e18c1969a91..f6b23af2f73 100644
--- a/src/librustc_data_structures/stable_hasher.rs
+++ b/src/librustc_data_structures/stable_hasher.rs
@@ -386,6 +386,14 @@ impl<CTX> HashStable<CTX> for String {
     }
 }
 
+impl<HCX> ToStableHashKey<HCX> for String {
+    type KeyType = String;
+    #[inline]
+    fn to_stable_hash_key(&self, _: &HCX) -> Self::KeyType {
+        self.clone()
+    }
+}
+
 impl<CTX> HashStable<CTX> for bool {
     #[inline]
     fn hash_stable<W: StableHasherResult>(&self,
diff --git a/src/librustc_trans/base.rs b/src/librustc_trans/base.rs
index 1e1b9929f0e..ba15f3522ac 100644
--- a/src/librustc_trans/base.rs
+++ b/src/librustc_trans/base.rs
@@ -41,7 +41,6 @@ use rustc::middle::trans::{Linkage, Visibility, Stats};
 use rustc::middle::cstore::{EncodedMetadata, EncodedMetadataHashes};
 use rustc::ty::{self, Ty, TyCtxt};
 use rustc::ty::maps::Providers;
-use rustc::dep_graph::AssertDepGraphSafe;
 use rustc::middle::cstore::{self, LinkMeta, LinkagePreference};
 use rustc::hir::map as hir_map;
 use rustc::util::common::{time, print_time_passes_entry};
@@ -894,7 +893,7 @@ fn iter_globals(llmod: llvm::ModuleRef) -> ValueIter {
 /// This list is later used by linkers to determine the set of symbols needed to
 /// be exposed from a dynamic library and it's also encoded into the metadata.
 pub fn find_exported_symbols(tcx: TyCtxt) -> NodeSet {
-    tcx.reachable_set(LOCAL_CRATE).iter().cloned().filter(|&id| {
+    tcx.reachable_set(LOCAL_CRATE).0.iter().cloned().filter(|&id| {
         // Next, we want to ignore some FFI functions that are not exposed from
         // this crate. Reachable FFI functions can be lumped into two
         // categories:
@@ -1370,8 +1369,8 @@ fn compile_codegen_unit<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
     let dep_node = cgu.work_product_dep_node();
     let ((stats, module), _) =
         tcx.dep_graph.with_task(dep_node,
-                                AssertDepGraphSafe(tcx),
-                                AssertDepGraphSafe(cgu),
+                                tcx,
+                                cgu,
                                 module_translation);
     let time_to_translate = start_time.elapsed();
 
@@ -1392,14 +1391,10 @@ fn compile_codegen_unit<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
     return stats;
 
     fn module_translation<'a, 'tcx>(
-        tcx: AssertDepGraphSafe<TyCtxt<'a, 'tcx, 'tcx>>,
-        args: AssertDepGraphSafe<Arc<CodegenUnit<'tcx>>>)
+        tcx: TyCtxt<'a, 'tcx, 'tcx>,
+        cgu: Arc<CodegenUnit<'tcx>>)
         -> (Stats, ModuleTranslation)
     {
-        // FIXME(#40304): We ought to be using the id as a key and some queries, I think.
-        let AssertDepGraphSafe(tcx) = tcx;
-        let AssertDepGraphSafe(cgu) = args;
-
         let cgu_name = cgu.name().to_string();
         let cgu_id = cgu.work_product_id();
         let symbol_name_hash = cgu.compute_symbol_name_hash(tcx);
@@ -1564,6 +1559,7 @@ pub fn visibility_to_llvm(linkage: Visibility) -> llvm::Visibility {
         Visibility::Default => llvm::Visibility::Default,
         Visibility::Hidden => llvm::Visibility::Hidden,
         Visibility::Protected => llvm::Visibility::Protected,
+    }
 }
 
 // FIXME(mw): Anything that is produced via DepGraph::with_task() must implement
@@ -1577,17 +1573,8 @@ pub fn visibility_to_llvm(linkage: Visibility) -> llvm::Visibility {
 mod temp_stable_hash_impls {
     use rustc_data_structures::stable_hasher::{StableHasherResult, StableHasher,
                                                HashStable};
-    use context::Stats;
     use ModuleTranslation;
 
-    impl<HCX> HashStable<HCX> for Stats {
-        fn hash_stable<W: StableHasherResult>(&self,
-                                              _: &mut HCX,
-                                              _: &mut StableHasher<W>) {
-            // do nothing
-        }
-    }
-
     impl<HCX> HashStable<HCX> for ModuleTranslation {
         fn hash_stable<W: StableHasherResult>(&self,
                                               _: &mut HCX,
diff --git a/src/librustc_trans/context.rs b/src/librustc_trans/context.rs
index 7e75eb9c78b..b394911c923 100644
--- a/src/librustc_trans/context.rs
+++ b/src/librustc_trans/context.rs
@@ -27,9 +27,8 @@ use type_::Type;
 use rustc_data_structures::base_n;
 use rustc::middle::trans::Stats;
 use rustc_data_structures::stable_hasher::StableHashingContextProvider;
-use rustc::session::config::{self, NoDebugInfo, OutputFilenames};
-use rustc::session::Session;
 use rustc::session::config::{self, NoDebugInfo};
+use rustc::session::Session;
 use rustc::ty::layout::{LayoutCx, LayoutError, LayoutTyper, TyLayout};
 use rustc::ty::{self, Ty, TyCtxt};
 use rustc::util::nodemap::FxHashMap;