diff --git a/src/librustc_incremental/calculate_svh/caching_codemap_view.rs b/src/librustc/ich/caching_codemap_view.rs similarity index 99% rename from src/librustc_incremental/calculate_svh/caching_codemap_view.rs rename to src/librustc/ich/caching_codemap_view.rs index ad9c48420e2..a71251eedf5 100644 --- a/src/librustc_incremental/calculate_svh/caching_codemap_view.rs +++ b/src/librustc/ich/caching_codemap_view.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -use rustc::ty::TyCtxt; +use ty::TyCtxt; use std::rc::Rc; use syntax::codemap::CodeMap; use syntax_pos::{BytePos, FileMap}; diff --git a/src/librustc_incremental/calculate_svh/def_path_hash.rs b/src/librustc/ich/def_path_hash.rs similarity index 92% rename from src/librustc_incremental/calculate_svh/def_path_hash.rs rename to src/librustc/ich/def_path_hash.rs index 8aa134ba3bf..03051dc0034 100644 --- a/src/librustc_incremental/calculate_svh/def_path_hash.rs +++ b/src/librustc/ich/def_path_hash.rs @@ -8,9 +8,9 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -use rustc::hir::def_id::DefId; -use rustc::ty::TyCtxt; -use rustc::util::nodemap::DefIdMap; +use hir::def_id::DefId; +use ty::TyCtxt; +use util::nodemap::DefIdMap; pub struct DefPathHashes<'a, 'tcx: 'a> { tcx: TyCtxt<'a, 'tcx, 'tcx>, diff --git a/src/librustc_incremental/ich/fingerprint.rs b/src/librustc/ich/fingerprint.rs similarity index 100% rename from src/librustc_incremental/ich/fingerprint.rs rename to src/librustc/ich/fingerprint.rs diff --git a/src/librustc/ich/mod.rs b/src/librustc/ich/mod.rs new file mode 100644 index 00000000000..209953f3c68 --- /dev/null +++ b/src/librustc/ich/mod.rs @@ -0,0 +1,34 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +pub use self::fingerprint::Fingerprint; +pub use self::def_path_hash::DefPathHashes; +pub use self::caching_codemap_view::CachingCodemapView; + +mod fingerprint; +mod def_path_hash; +mod caching_codemap_view; + +pub const ATTR_DIRTY: &'static str = "rustc_dirty"; +pub const ATTR_CLEAN: &'static str = "rustc_clean"; +pub const ATTR_DIRTY_METADATA: &'static str = "rustc_metadata_dirty"; +pub const ATTR_CLEAN_METADATA: &'static str = "rustc_metadata_clean"; +pub const ATTR_IF_THIS_CHANGED: &'static str = "rustc_if_this_changed"; +pub const ATTR_THEN_THIS_WOULD_NEED: &'static str = "rustc_then_this_would_need"; + +pub const IGNORED_ATTRIBUTES: &'static [&'static str] = &[ + "cfg", + ATTR_IF_THIS_CHANGED, + ATTR_THEN_THIS_WOULD_NEED, + ATTR_DIRTY, + ATTR_CLEAN, + ATTR_DIRTY_METADATA, + ATTR_CLEAN_METADATA +]; diff --git a/src/librustc/lib.rs b/src/librustc/lib.rs index a007c9d2c43..c1c945d4e60 100644 --- a/src/librustc/lib.rs +++ b/src/librustc/lib.rs @@ -72,6 +72,7 @@ pub mod diagnostics; pub mod cfg; pub mod dep_graph; pub mod hir; +pub mod ich; pub mod infer; pub mod lint; diff --git a/src/librustc/ty/util.rs b/src/librustc/ty/util.rs index 1d816d342c4..1c1e0d91cb4 100644 --- a/src/librustc/ty/util.rs +++ b/src/librustc/ty/util.rs @@ -509,18 +509,21 @@ impl<'a, 'gcx, 'tcx, W> TypeVisitor<'tcx> for TypeIdHasher<'a, 'gcx, 'tcx, W> } fn visit_region(&mut self, r: &'tcx ty::Region) -> bool { + self.hash_discriminant_u8(r); match *r { - ty::ReErased => { - self.hash::(0); + ty::ReErased | + ty::ReStatic | + ty::ReEmpty => { + // No variant fields to hash for these ... } ty::ReLateBound(db, ty::BrAnon(i)) => { - assert!(db.depth > 0); - self.hash::(db.depth); + self.hash(db.depth); self.hash(i); } - ty::ReStatic | - ty::ReEmpty | - ty::ReEarlyBound(..) | + ty::ReEarlyBound(ty::EarlyBoundRegion { index, name }) => { + self.hash(index); + self.hash(name.as_str()); + } ty::ReLateBound(..) | ty::ReFree(..) | ty::ReScope(..) | diff --git a/src/librustc_driver/driver.rs b/src/librustc_driver/driver.rs index c1ea2b9ce41..5d600270626 100644 --- a/src/librustc_driver/driver.rs +++ b/src/librustc_driver/driver.rs @@ -10,6 +10,7 @@ use rustc::hir::{self, map as hir_map}; use rustc::hir::lowering::lower_crate; +use rustc::ich::Fingerprint; use rustc_data_structures::stable_hasher::StableHasher; use rustc_mir as mir; use rustc::session::{Session, CompileResult, compile_result_from_err_count}; @@ -25,7 +26,6 @@ use rustc::util::nodemap::NodeSet; use rustc::util::fs::rename_or_copy_remove; use rustc_borrowck as borrowck; use rustc_incremental::{self, IncrementalHashesMap}; -use rustc_incremental::ich::Fingerprint; use rustc_resolve::{MakeGlobMap, Resolver}; use rustc_metadata::creader::CrateLoader; use rustc_metadata::cstore::{self, CStore}; diff --git a/src/librustc_incremental/assert_dep_graph.rs b/src/librustc_incremental/assert_dep_graph.rs index 287ee7dd13e..897ca0f2957 100644 --- a/src/librustc_incremental/assert_dep_graph.rs +++ b/src/librustc_incremental/assert_dep_graph.rs @@ -52,13 +52,13 @@ use rustc_data_structures::fx::FxHashSet; use rustc_data_structures::graph::{Direction, INCOMING, OUTGOING, NodeIndex}; use rustc::hir; use rustc::hir::itemlikevisit::ItemLikeVisitor; +use rustc::ich::{ATTR_IF_THIS_CHANGED, ATTR_THEN_THIS_WOULD_NEED}; use graphviz::IntoCow; use std::env; use std::fs::File; use std::io::Write; use syntax::ast; use syntax_pos::Span; -use {ATTR_IF_THIS_CHANGED, ATTR_THEN_THIS_WOULD_NEED}; pub fn assert_dep_graph<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>) { let _ignore = tcx.dep_graph.in_ignore(); diff --git a/src/librustc_incremental/calculate_svh/mod.rs b/src/librustc_incremental/calculate_svh/mod.rs index b9e6426dc01..c9496a4deb8 100644 --- a/src/librustc_incremental/calculate_svh/mod.rs +++ b/src/librustc_incremental/calculate_svh/mod.rs @@ -35,20 +35,16 @@ use rustc::hir; use rustc::hir::def_id::{CRATE_DEF_INDEX, DefId}; use rustc::hir::intravisit as visit; use rustc::hir::intravisit::{Visitor, NestedVisitorMap}; +use rustc::ich::{Fingerprint, DefPathHashes, CachingCodemapView}; use rustc::ty::TyCtxt; use rustc_data_structures::stable_hasher::StableHasher; -use ich::Fingerprint; use rustc_data_structures::fx::FxHashMap; use rustc::util::common::record_time; use rustc::session::config::DebugInfoLevel::NoDebugInfo; -use self::def_path_hash::DefPathHashes; use self::svh_visitor::StrictVersionHashVisitor; -use self::caching_codemap_view::CachingCodemapView; -mod def_path_hash; mod svh_visitor; -mod caching_codemap_view; pub type IchHasher = StableHasher; diff --git a/src/librustc_incremental/calculate_svh/svh_visitor.rs b/src/librustc_incremental/calculate_svh/svh_visitor.rs index fac49b29598..210803c3f32 100644 --- a/src/librustc_incremental/calculate_svh/svh_visitor.rs +++ b/src/librustc_incremental/calculate_svh/svh_visitor.rs @@ -26,23 +26,12 @@ use rustc::hir::*; use rustc::hir::def::Def; use rustc::hir::def_id::DefId; use rustc::hir::intravisit::{self as visit, Visitor}; +use rustc::ich::{DefPathHashes, CachingCodemapView, IGNORED_ATTRIBUTES}; use rustc::ty::TyCtxt; use std::hash::{Hash, Hasher}; -use super::def_path_hash::DefPathHashes; -use super::caching_codemap_view::CachingCodemapView; use super::IchHasher; -const IGNORED_ATTRIBUTES: &'static [&'static str] = &[ - "cfg", - ::ATTR_IF_THIS_CHANGED, - ::ATTR_THEN_THIS_WOULD_NEED, - ::ATTR_DIRTY, - ::ATTR_CLEAN, - ::ATTR_DIRTY_METADATA, - ::ATTR_CLEAN_METADATA -]; - pub struct StrictVersionHashVisitor<'a, 'hash: 'a, 'tcx: 'hash> { pub tcx: TyCtxt<'hash, 'tcx, 'tcx>, pub st: &'a mut IchHasher, diff --git a/src/librustc_incremental/ich/mod.rs b/src/librustc_incremental/ich/mod.rs deleted file mode 100644 index 8edd04322d7..00000000000 --- a/src/librustc_incremental/ich/mod.rs +++ /dev/null @@ -1,13 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -pub use self::fingerprint::Fingerprint; - -mod fingerprint; diff --git a/src/librustc_incremental/lib.rs b/src/librustc_incremental/lib.rs index 0a8719c1253..3b61cc1464a 100644 --- a/src/librustc_incremental/lib.rs +++ b/src/librustc_incremental/lib.rs @@ -36,17 +36,9 @@ extern crate serialize as rustc_serialize; extern crate syntax; extern crate syntax_pos; -const ATTR_DIRTY: &'static str = "rustc_dirty"; -const ATTR_CLEAN: &'static str = "rustc_clean"; -const ATTR_DIRTY_METADATA: &'static str = "rustc_metadata_dirty"; -const ATTR_CLEAN_METADATA: &'static str = "rustc_metadata_clean"; -const ATTR_IF_THIS_CHANGED: &'static str = "rustc_if_this_changed"; -const ATTR_THEN_THIS_WOULD_NEED: &'static str = "rustc_then_this_would_need"; - mod assert_dep_graph; mod calculate_svh; mod persist; -pub mod ich; pub use assert_dep_graph::assert_dep_graph; pub use calculate_svh::compute_incremental_hashes_map; diff --git a/src/librustc_incremental/persist/data.rs b/src/librustc_incremental/persist/data.rs index 673f1ae1084..d9009073956 100644 --- a/src/librustc_incremental/persist/data.rs +++ b/src/librustc_incremental/persist/data.rs @@ -12,9 +12,9 @@ use rustc::dep_graph::{DepNode, WorkProduct, WorkProductId}; use rustc::hir::def_id::DefIndex; +use rustc::ich::Fingerprint; use std::sync::Arc; use rustc_data_structures::fx::FxHashMap; -use ich::Fingerprint; use super::directory::DefPathIndex; diff --git a/src/librustc_incremental/persist/dirty_clean.rs b/src/librustc_incremental/persist/dirty_clean.rs index 929249df0b1..d931f64d579 100644 --- a/src/librustc_incremental/persist/dirty_clean.rs +++ b/src/librustc_incremental/persist/dirty_clean.rs @@ -47,13 +47,12 @@ use rustc::hir; use rustc::hir::def_id::DefId; use rustc::hir::itemlikevisit::ItemLikeVisitor; use rustc::hir::intravisit; +use rustc::ich::{Fingerprint, ATTR_DIRTY, ATTR_CLEAN, ATTR_DIRTY_METADATA, + ATTR_CLEAN_METADATA}; use syntax::ast::{self, Attribute, NestedMetaItem}; use rustc_data_structures::fx::{FxHashSet, FxHashMap}; use syntax_pos::Span; use rustc::ty::TyCtxt; -use ich::Fingerprint; - -use {ATTR_DIRTY, ATTR_CLEAN, ATTR_DIRTY_METADATA, ATTR_CLEAN_METADATA}; const LABEL: &'static str = "label"; const CFG: &'static str = "cfg"; diff --git a/src/librustc_incremental/persist/hash.rs b/src/librustc_incremental/persist/hash.rs index 799cb6c5e3d..9d8ff57e03b 100644 --- a/src/librustc_incremental/persist/hash.rs +++ b/src/librustc_incremental/persist/hash.rs @@ -11,6 +11,7 @@ use rustc::dep_graph::DepNode; use rustc::hir::def_id::{CrateNum, DefId}; use rustc::hir::svh::Svh; +use rustc::ich::Fingerprint; use rustc::ty::TyCtxt; use rustc_data_structures::fx::FxHashMap; use rustc_data_structures::flock; @@ -18,7 +19,6 @@ use rustc_serialize::Decodable; use rustc_serialize::opaque::Decoder; use IncrementalHashesMap; -use ich::Fingerprint; use super::data::*; use super::fs::*; use super::file_format; diff --git a/src/librustc_incremental/persist/load.rs b/src/librustc_incremental/persist/load.rs index 27892506496..ed2e2e72ee7 100644 --- a/src/librustc_incremental/persist/load.rs +++ b/src/librustc_incremental/persist/load.rs @@ -13,6 +13,7 @@ use rustc::dep_graph::{DepNode, WorkProductId}; use rustc::hir::def_id::DefId; use rustc::hir::svh::Svh; +use rustc::ich::Fingerprint; use rustc::session::Session; use rustc::ty::TyCtxt; use rustc_data_structures::fx::{FxHashSet, FxHashMap}; @@ -22,7 +23,6 @@ use std::path::{Path}; use std::sync::Arc; use IncrementalHashesMap; -use ich::Fingerprint; use super::data::*; use super::directory::*; use super::dirty_clean; diff --git a/src/librustc_incremental/persist/preds/mod.rs b/src/librustc_incremental/persist/preds/mod.rs index f6a37c7a122..fe8cf72996e 100644 --- a/src/librustc_incremental/persist/preds/mod.rs +++ b/src/librustc_incremental/persist/preds/mod.rs @@ -10,11 +10,11 @@ use rustc::dep_graph::{DepGraphQuery, DepNode}; use rustc::hir::def_id::DefId; +use rustc::ich::Fingerprint; use rustc_data_structures::fx::FxHashMap; use rustc_data_structures::graph::{Graph, NodeIndex}; use super::hash::*; -use ich::Fingerprint; mod compress; diff --git a/src/librustc_incremental/persist/save.rs b/src/librustc_incremental/persist/save.rs index dfa6bf6bbb5..2e518649337 100644 --- a/src/librustc_incremental/persist/save.rs +++ b/src/librustc_incremental/persist/save.rs @@ -11,6 +11,7 @@ use rustc::dep_graph::DepNode; use rustc::hir::def_id::DefId; use rustc::hir::svh::Svh; +use rustc::ich::Fingerprint; use rustc::session::Session; use rustc::ty::TyCtxt; use rustc_data_structures::fx::FxHashMap; @@ -23,7 +24,6 @@ use std::fs::{self, File}; use std::path::PathBuf; use IncrementalHashesMap; -use ich::Fingerprint; use super::data::*; use super::directory::*; use super::hash::*; diff --git a/src/librustc_mir/transform/erase_regions.rs b/src/librustc_mir/transform/erase_regions.rs index cebd9dd9668..0f869e7ed02 100644 --- a/src/librustc_mir/transform/erase_regions.rs +++ b/src/librustc_mir/transform/erase_regions.rs @@ -13,7 +13,7 @@ //! care erasing regions all over the place. use rustc::ty::subst::Substs; -use rustc::ty::{Ty, TyCtxt}; +use rustc::ty::{Ty, TyCtxt, ReErased, ClosureSubsts}; use rustc::mir::*; use rustc::mir::visit::MutVisitor; use rustc::mir::transform::{MirPass, MirSource, Pass}; @@ -39,6 +39,32 @@ impl<'a, 'tcx> MutVisitor<'tcx> for EraseRegionsVisitor<'a, 'tcx> { fn visit_substs(&mut self, substs: &mut &'tcx Substs<'tcx>) { *substs = self.tcx.erase_regions(&{*substs}); } + + fn visit_rvalue(&mut self, rvalue: &mut Rvalue<'tcx>, location: Location) { + match *rvalue { + Rvalue::Ref(ref mut r, _, _) => { + *r = self.tcx.mk_region(ReErased); + } + Rvalue::Use(..) | + Rvalue::Repeat(..) | + Rvalue::Len(..) | + Rvalue::Cast(..) | + Rvalue::BinaryOp(..) | + Rvalue::CheckedBinaryOp(..) | + Rvalue::UnaryOp(..) | + Rvalue::Discriminant(..) | + Rvalue::Box(..) | + Rvalue::Aggregate(..) => { + // These variants don't contain regions. + } + } + self.super_rvalue(rvalue, location); + } + + fn visit_closure_substs(&mut self, + substs: &mut ClosureSubsts<'tcx>) { + *substs = self.tcx.erase_regions(substs); + } } pub struct EraseRegions;