about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2018-08-10 00:14:52 +0000
committerbors <bors@rust-lang.org>2018-08-10 00:14:52 +0000
commitdb1acaac7f8c84d8fb46211f5e96f678c28628a8 (patch)
tree972e8bbf160423e6ad3cf8a4797ff1a9de33bf3c /src
parentfb65d7563c93509c343a98e5cccf8e5ab4506924 (diff)
parenta8e19bec373a0a6e673969fed2ded5ec4e53761d (diff)
downloadrust-db1acaac7f8c84d8fb46211f5e96f678c28628a8.tar.gz
rust-db1acaac7f8c84d8fb46211f5e96f678c28628a8.zip
Auto merge of #53073 - Mark-Simulacrum:data-structures, r=pnkfelix
Cleanup to librustc::session and related code

No functional changes, just some cleanup.

This also creates the `rustc_fs_util` crate, but I can remove that change if desired. It felt a little odd to force crates to depend on librustc for some fs utilities; and also seemed good to generally keep the size of librustc lower (for compile times); fs_util will compile in parallel with essentially the first crate since it has no dependencies beyond std.
Diffstat (limited to 'src')
-rw-r--r--src/Cargo.lock6
-rw-r--r--src/librustc/Cargo.toml1
-rw-r--r--src/librustc/hir/map/collector.rs2
-rw-r--r--src/librustc/hir/map/mod.rs2
-rw-r--r--src/librustc/hir/mod.rs1
-rw-r--r--src/librustc/ich/hcx.rs7
-rw-r--r--src/librustc/ich/mod.rs5
-rw-r--r--src/librustc/lib.rs4
-rw-r--r--src/librustc/macros.rs4
-rw-r--r--src/librustc/middle/cstore.rs2
-rw-r--r--src/librustc/session/code_stats.rs15
-rw-r--r--src/librustc/session/config.rs36
-rw-r--r--src/librustc/session/filesearch.rs4
-rw-r--r--src/librustc/session/mod.rs48
-rw-r--r--src/librustc/ty/mod.rs13
-rw-r--r--src/librustc/ty/query/mod.rs2
-rw-r--r--src/librustc/util/bug.rs51
-rw-r--r--src/librustc/util/common.rs15
-rw-r--r--src/librustc_codegen_llvm/back/link.rs2
-rw-r--r--src/librustc_codegen_llvm/back/symbol_export.rs2
-rw-r--r--src/librustc_codegen_llvm/back/write.rs3
-rw-r--r--src/librustc_codegen_llvm/debuginfo/metadata.rs5
-rw-r--r--src/librustc_codegen_llvm/lib.rs1
-rw-r--r--src/librustc_codegen_llvm/metadata.rs4
-rw-r--r--src/librustc_codegen_utils/link.rs2
-rw-r--r--src/librustc_data_structures/fingerprint.rs (renamed from src/librustc/ich/fingerprint.rs)11
-rw-r--r--src/librustc_data_structures/lib.rs5
-rw-r--r--src/librustc_data_structures/stable_hasher.rs11
-rw-r--r--src/librustc_data_structures/svh.rs (renamed from src/librustc/hir/svh.rs)18
-rw-r--r--src/librustc_driver/driver.rs2
-rw-r--r--src/librustc_fs_util/Cargo.toml11
-rw-r--r--src/librustc_fs_util/lib.rs (renamed from src/librustc/util/fs.rs)29
-rw-r--r--src/librustc_incremental/Cargo.toml1
-rw-r--r--src/librustc_incremental/lib.rs1
-rw-r--r--src/librustc_incremental/persist/fs.rs10
-rw-r--r--src/librustc_incremental/persist/work_product.rs2
-rw-r--r--src/librustc_metadata/creader.rs2
-rw-r--r--src/librustc_metadata/cstore_impl.rs3
-rw-r--r--src/librustc_metadata/decoder.rs2
-rw-r--r--src/librustc_metadata/encoder.rs2
-rw-r--r--src/librustc_metadata/locator.rs2
-rw-r--r--src/librustc_metadata/schema.rs5
42 files changed, 185 insertions, 169 deletions
diff --git a/src/Cargo.lock b/src/Cargo.lock
index 2a7dbce2ddc..1ef6b2a571e 100644
--- a/src/Cargo.lock
+++ b/src/Cargo.lock
@@ -1887,6 +1887,7 @@ dependencies = [
  "rustc_apfloat 0.0.0",
  "rustc_data_structures 0.0.0",
  "rustc_errors 0.0.0",
+ "rustc_fs_util 0.0.0",
  "rustc_target 0.0.0",
  "scoped-tls 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
  "serialize 0.0.0",
@@ -2186,6 +2187,10 @@ dependencies = [
 ]
 
 [[package]]
+name = "rustc_fs_util"
+version = "0.0.0"
+
+[[package]]
 name = "rustc_incremental"
 version = "0.0.0"
 dependencies = [
@@ -2194,6 +2199,7 @@ dependencies = [
  "rand 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)",
  "rustc 0.0.0",
  "rustc_data_structures 0.0.0",
+ "rustc_fs_util 0.0.0",
  "serialize 0.0.0",
  "syntax 0.0.0",
  "syntax_pos 0.0.0",
diff --git a/src/librustc/Cargo.toml b/src/librustc/Cargo.toml
index 457a9f2f625..088b9436d0f 100644
--- a/src/librustc/Cargo.toml
+++ b/src/librustc/Cargo.toml
@@ -32,6 +32,7 @@ backtrace = "0.3.3"
 parking_lot = "0.5.5"
 byteorder = { version = "1.1", features = ["i128"]}
 chalk-engine = { version = "0.6.0", default-features=false }
+rustc_fs_util = { path = "../librustc_fs_util" }
 
 # Note that these dependencies are a lie, they're just here to get linkage to
 # work.
diff --git a/src/librustc/hir/map/collector.rs b/src/librustc/hir/map/collector.rs
index 0150ba659c9..3934475bea9 100644
--- a/src/librustc/hir/map/collector.rs
+++ b/src/librustc/hir/map/collector.rs
@@ -12,7 +12,7 @@ use super::*;
 use dep_graph::{DepGraph, DepKind, DepNodeIndex};
 use hir::def_id::{LOCAL_CRATE, CrateNum};
 use hir::intravisit::{Visitor, NestedVisitorMap};
-use hir::svh::Svh;
+use rustc_data_structures::svh::Svh;
 use ich::Fingerprint;
 use middle::cstore::CrateStore;
 use session::CrateDisambiguator;
diff --git a/src/librustc/hir/map/mod.rs b/src/librustc/hir/map/mod.rs
index b05bcadf826..81897322b6f 100644
--- a/src/librustc/hir/map/mod.rs
+++ b/src/librustc/hir/map/mod.rs
@@ -22,6 +22,7 @@ use hir::def_id::{CRATE_DEF_INDEX, DefId, LocalDefId, DefIndexAddressSpace};
 use middle::cstore::CrateStore;
 
 use rustc_target::spec::abi::Abi;
+use rustc_data_structures::svh::Svh;
 use syntax::ast::{self, Name, NodeId, CRATE_NODE_ID};
 use syntax::codemap::Spanned;
 use syntax::ext::base::MacroKind;
@@ -29,7 +30,6 @@ use syntax_pos::{Span, DUMMY_SP};
 
 use hir::*;
 use hir::print::Nested;
-use hir::svh::Svh;
 use util::nodemap::FxHashMap;
 
 use std::io;
diff --git a/src/librustc/hir/mod.rs b/src/librustc/hir/mod.rs
index 0003790e6d5..521499e4766 100644
--- a/src/librustc/hir/mod.rs
+++ b/src/librustc/hir/mod.rs
@@ -70,7 +70,6 @@ pub mod lowering;
 pub mod map;
 pub mod pat_util;
 pub mod print;
-pub mod svh;
 
 /// A HirId uniquely identifies a node in the HIR of the current crate. It is
 /// composed of the `owner`, which is the DefIndex of the directly enclosing
diff --git a/src/librustc/ich/hcx.rs b/src/librustc/ich/hcx.rs
index 05361b65641..329cc2216a4 100644
--- a/src/librustc/ich/hcx.rs
+++ b/src/librustc/ich/hcx.rs
@@ -37,7 +37,7 @@ use rustc_data_structures::stable_hasher::{HashStable,
 use rustc_data_structures::accumulate_vec::AccumulateVec;
 use rustc_data_structures::fx::{FxHashSet, FxHashMap};
 
-pub fn compute_ignored_attr_names() -> FxHashSet<Symbol> {
+fn compute_ignored_attr_names() -> FxHashSet<Symbol> {
     debug_assert!(ich::IGNORED_ATTRIBUTES.len() > 0);
     ich::IGNORED_ATTRIBUTES.iter().map(|&s| Symbol::intern(s)).collect()
 }
@@ -183,7 +183,10 @@ impl<'a> StableHashingContext<'a> {
 
     #[inline]
     pub fn is_ignored_attr(&self, name: Symbol) -> bool {
-        self.sess.ignored_attr_names.contains(&name)
+        thread_local! {
+            static IGNORED_ATTRIBUTES: FxHashSet<Symbol> = compute_ignored_attr_names();
+        }
+        IGNORED_ATTRIBUTES.with(|attrs| attrs.contains(&name))
     }
 
     pub fn hash_hir_item_like<F: FnOnce(&mut Self)>(&mut self, f: F) {
diff --git a/src/librustc/ich/mod.rs b/src/librustc/ich/mod.rs
index d58eb64c366..b00d8c56569 100644
--- a/src/librustc/ich/mod.rs
+++ b/src/librustc/ich/mod.rs
@@ -10,11 +10,10 @@
 
 //! ICH - Incremental Compilation Hash
 
-pub use self::fingerprint::Fingerprint;
+crate use rustc_data_structures::fingerprint::Fingerprint;
 pub use self::caching_codemap_view::CachingCodemapView;
 pub use self::hcx::{StableHashingContextProvider, StableHashingContext, NodeIdHashingMode,
-                    hash_stable_trait_impls, compute_ignored_attr_names};
-mod fingerprint;
+                    hash_stable_trait_impls};
 mod caching_codemap_view;
 mod hcx;
 
diff --git a/src/librustc/lib.rs b/src/librustc/lib.rs
index 804481846af..55a5e342947 100644
--- a/src/librustc/lib.rs
+++ b/src/librustc/lib.rs
@@ -72,6 +72,7 @@
 #![feature(in_band_lifetimes)]
 #![feature(macro_at_most_once_rep)]
 #![feature(crate_in_paths)]
+#![feature(crate_visibility_modifier)]
 
 #![recursion_limit="512"]
 
@@ -99,6 +100,7 @@ extern crate syntax_pos;
 extern crate jobserver;
 extern crate proc_macro;
 extern crate chalk_engine;
+extern crate rustc_fs_util;
 
 extern crate serialize as rustc_serialize; // used by deriving
 
@@ -162,9 +164,9 @@ pub mod util {
     pub mod common;
     pub mod ppaux;
     pub mod nodemap;
-    pub mod fs;
     pub mod time_graph;
     pub mod profiling;
+    pub mod bug;
 }
 
 // A private module so that macro-expanded idents like
diff --git a/src/librustc/macros.rs b/src/librustc/macros.rs
index 0bf1f4decc4..e599b0704f9 100644
--- a/src/librustc/macros.rs
+++ b/src/librustc/macros.rs
@@ -51,14 +51,14 @@ macro_rules! enum_from_u32 {
 macro_rules! bug {
     () => ( bug!("impossible case reached") );
     ($($message:tt)*) => ({
-        $crate::session::bug_fmt(file!(), line!(), format_args!($($message)*))
+        $crate::util::bug::bug_fmt(file!(), line!(), format_args!($($message)*))
     })
 }
 
 #[macro_export]
 macro_rules! span_bug {
     ($span:expr, $($message:tt)*) => ({
-        $crate::session::span_bug_fmt(file!(), line!(), $span, format_args!($($message)*))
+        $crate::util::bug::span_bug_fmt(file!(), line!(), $span, format_args!($($message)*))
     })
 }
 
diff --git a/src/librustc/middle/cstore.rs b/src/librustc/middle/cstore.rs
index 0e84104245d..b91a9644b21 100644
--- a/src/librustc/middle/cstore.rs
+++ b/src/librustc/middle/cstore.rs
@@ -25,7 +25,7 @@
 use hir::def_id::{CrateNum, DefId, LOCAL_CRATE};
 use hir::map as hir_map;
 use hir::map::definitions::{DefKey, DefPathTable};
-use hir::svh::Svh;
+use rustc_data_structures::svh::Svh;
 use ty::{self, TyCtxt};
 use session::{Session, CrateDisambiguator};
 use session::search_paths::PathKind;
diff --git a/src/librustc/session/code_stats.rs b/src/librustc/session/code_stats.rs
index 1eee6508c59..32865acb298 100644
--- a/src/librustc/session/code_stats.rs
+++ b/src/librustc/session/code_stats.rs
@@ -8,11 +8,8 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-use ty::AdtKind;
-use ty::layout::{Align, Size};
-
+use rustc_target::abi::{Align, Size};
 use rustc_data_structures::fx::{FxHashSet};
-
 use std::cmp::{self, Ordering};
 
 #[derive(Clone, PartialEq, Eq, Hash, Debug)]
@@ -38,16 +35,6 @@ pub struct FieldInfo {
     pub align: u64,
 }
 
-impl From<AdtKind> for DataTypeKind {
-    fn from(kind: AdtKind) -> Self {
-        match kind {
-            AdtKind::Struct => DataTypeKind::Struct,
-            AdtKind::Enum => DataTypeKind::Enum,
-            AdtKind::Union => DataTypeKind::Union,
-        }
-    }
-}
-
 #[derive(Copy, Clone, PartialEq, Eq, Hash, Debug)]
 pub enum DataTypeKind {
     Struct,
diff --git a/src/librustc/session/config.rs b/src/librustc/session/config.rs
index dddf921aec6..ef1052d562e 100644
--- a/src/librustc/session/config.rs
+++ b/src/librustc/session/config.rs
@@ -16,10 +16,8 @@ use std::str::FromStr;
 use session::{early_error, early_warn, Session};
 use session::search_paths::SearchPaths;
 
-use ich::StableHashingContext;
 use rustc_target::spec::{LinkerFlavor, PanicStrategy, RelroLevel};
 use rustc_target::spec::{Target, TargetTriple};
-use rustc_data_structures::stable_hasher::ToStableHashKey;
 use lint;
 use middle::cstore;
 
@@ -126,25 +124,7 @@ pub enum OutputType {
     DepInfo,
 }
 
-
-impl_stable_hash_for!(enum self::OutputType {
-    Bitcode,
-    Assembly,
-    LlvmAssembly,
-    Mir,
-    Metadata,
-    Object,
-    Exe,
-    DepInfo
-});
-
-impl<'a, 'tcx> ToStableHashKey<StableHashingContext<'a>> for OutputType {
-    type KeyType = OutputType;
-    #[inline]
-    fn to_stable_hash_key(&self, _: &StableHashingContext<'a>) -> Self::KeyType {
-        *self
-    }
-}
+impl_stable_hash_via_hash!(OutputType);
 
 impl OutputType {
     fn is_compatible_with_codegen_units_and_single_output_file(&self) -> bool {
@@ -233,9 +213,7 @@ impl Default for ErrorOutputType {
 #[derive(Clone, Hash)]
 pub struct OutputTypes(BTreeMap<OutputType, Option<PathBuf>>);
 
-impl_stable_hash_for!(tuple_struct self::OutputTypes {
-    map
-});
+impl_stable_hash_via_hash!(OutputTypes);
 
 impl OutputTypes {
     pub fn new(entries: &[(OutputType, Option<PathBuf>)]) -> OutputTypes {
@@ -512,7 +490,7 @@ impl Input {
     }
 }
 
-#[derive(Clone)]
+#[derive(Clone, Hash)]
 pub struct OutputFilenames {
     pub out_directory: PathBuf,
     pub out_filestem: String,
@@ -521,13 +499,7 @@ pub struct OutputFilenames {
     pub outputs: OutputTypes,
 }
 
-impl_stable_hash_for!(struct self::OutputFilenames {
-    out_directory,
-    out_filestem,
-    single_output_file,
-    extra,
-    outputs
-});
+impl_stable_hash_via_hash!(OutputFilenames);
 
 pub const RUST_CGU_EXT: &str = "rcgu";
 
diff --git a/src/librustc/session/filesearch.rs b/src/librustc/session/filesearch.rs
index b636fc6c995..32044fdf2a8 100644
--- a/src/librustc/session/filesearch.rs
+++ b/src/librustc/session/filesearch.rs
@@ -19,7 +19,7 @@ use std::fs;
 use std::path::{Path, PathBuf};
 
 use session::search_paths::{SearchPaths, PathKind};
-use util::fs as rustcfs;
+use rustc_fs_util::fix_windows_verbatim_for_gcc;
 
 #[derive(Copy, Clone)]
 pub enum FileMatch {
@@ -151,7 +151,7 @@ pub fn get_or_default_sysroot() -> PathBuf {
                 // See comments on this target function, but the gist is that
                 // gcc chokes on verbatim paths which fs::canonicalize generates
                 // so we try to avoid those kinds of paths.
-                Ok(canon) => Some(rustcfs::fix_windows_verbatim_for_gcc(&canon)),
+                Ok(canon) => Some(fix_windows_verbatim_for_gcc(&canon)),
                 Err(e) => bug!("failed to get realpath: {}", e),
             }
         })
diff --git a/src/librustc/session/mod.rs b/src/librustc/session/mod.rs
index 9a3ce50fcbd..f474f214305 100644
--- a/src/librustc/session/mod.rs
+++ b/src/librustc/session/mod.rs
@@ -12,16 +12,14 @@ pub use self::code_stats::{DataTypeKind, SizeKind, FieldInfo, VariantInfo};
 use self::code_stats::CodeStats;
 
 use hir::def_id::CrateNum;
-use ich::Fingerprint;
+use rustc_data_structures::fingerprint::Fingerprint;
 
-use ich;
 use lint;
 use lint::builtin::BuiltinLintDiagnostics;
 use middle::allocator::AllocatorKind;
 use middle::dependency_format;
 use session::search_paths::PathKind;
 use session::config::{OutputType, Lto};
-use ty::tls;
 use util::nodemap::{FxHashMap, FxHashSet};
 use util::common::{duration_to_secs_str, ErrorReported};
 use util::common::ProfileQueriesMsg;
@@ -34,7 +32,6 @@ use errors::emitter::{Emitter, EmitterWriter};
 use syntax::edition::Edition;
 use syntax::json::JsonEmitter;
 use syntax::feature_gate;
-use syntax::symbol::Symbol;
 use syntax::parse;
 use syntax::parse::ParseSess;
 use syntax::{ast, codemap};
@@ -51,7 +48,6 @@ use std;
 use std::cell::{self, Cell, RefCell};
 use std::collections::HashMap;
 use std::env;
-use std::fmt;
 use std::io::Write;
 use std::path::{Path, PathBuf};
 use std::time::Duration;
@@ -128,9 +124,6 @@ pub struct Session {
 
     incr_comp_session: OneThread<RefCell<IncrCompSession>>,
 
-    /// A cache of attributes ignored by StableHashingContext
-    pub ignored_attr_names: FxHashSet<Symbol>,
-
     /// Used by -Z profile-queries in util::common
     pub profile_channel: Lock<Option<mpsc::Sender<ProfileQueriesMsg>>>,
 
@@ -1143,7 +1136,6 @@ pub fn build_session_(
         injected_panic_runtime: Once::new(),
         imported_macro_spans: OneThread::new(RefCell::new(HashMap::new())),
         incr_comp_session: OneThread::new(RefCell::new(IncrCompSession::NotInitialized)),
-        ignored_attr_names: ich::compute_ignored_attr_names(),
         self_profiling: Lock::new(SelfProfiler::new()),
         profile_channel: Lock::new(None),
         perf_stats: PerfStats {
@@ -1235,7 +1227,7 @@ impl From<Fingerprint> for CrateDisambiguator {
     }
 }
 
-impl_stable_hash_for!(tuple_struct CrateDisambiguator { fingerprint });
+impl_stable_hash_via_hash!(CrateDisambiguator);
 
 /// Holds data on the current incremental compilation session, if there is one.
 #[derive(Debug)]
@@ -1307,39 +1299,3 @@ pub fn compile_result_from_err_count(err_count: usize) -> CompileResult {
         Err(CompileIncomplete::Errored(ErrorReported))
     }
 }
-
-#[cold]
-#[inline(never)]
-pub fn bug_fmt(file: &'static str, line: u32, args: fmt::Arguments) -> ! {
-    // this wrapper mostly exists so I don't have to write a fully
-    // qualified path of None::<Span> inside the bug!() macro definition
-    opt_span_bug_fmt(file, line, None::<Span>, args);
-}
-
-#[cold]
-#[inline(never)]
-pub fn span_bug_fmt<S: Into<MultiSpan>>(
-    file: &'static str,
-    line: u32,
-    span: S,
-    args: fmt::Arguments,
-) -> ! {
-    opt_span_bug_fmt(file, line, Some(span), args);
-}
-
-fn opt_span_bug_fmt<S: Into<MultiSpan>>(
-    file: &'static str,
-    line: u32,
-    span: Option<S>,
-    args: fmt::Arguments,
-) -> ! {
-    tls::with_opt(move |tcx| {
-        let msg = format!("{}:{}: {}", file, line, args);
-        match (tcx, span) {
-            (Some(tcx), Some(span)) => tcx.sess.diagnostic().span_bug(span, &msg),
-            (Some(tcx), None) => tcx.sess.diagnostic().bug(&msg),
-            (None, _) => panic!(msg),
-        }
-    });
-    unreachable!();
-}
diff --git a/src/librustc/ty/mod.rs b/src/librustc/ty/mod.rs
index 4fda3bdca3d..0c962fff272 100644
--- a/src/librustc/ty/mod.rs
+++ b/src/librustc/ty/mod.rs
@@ -18,7 +18,7 @@ use hir::{map as hir_map, FreevarMap, TraitMap};
 use hir::def::{Def, CtorKind, ExportMap};
 use hir::def_id::{CrateNum, DefId, LocalDefId, CRATE_DEF_INDEX, LOCAL_CRATE};
 use hir::map::DefPathData;
-use hir::svh::Svh;
+use rustc_data_structures::svh::Svh;
 use ich::Fingerprint;
 use ich::StableHashingContext;
 use infer::canonical::Canonical;
@@ -37,6 +37,7 @@ use ty::walk::TypeWalker;
 use util::captures::Captures;
 use util::nodemap::{NodeSet, DefIdMap, FxHashMap};
 use arena::SyncDroplessArena;
+use session::DataTypeKind;
 
 use serialize::{self, Encodable, Encoder};
 use std::cell::RefCell;
@@ -1810,6 +1811,16 @@ impl<'a> HashStable<StableHashingContext<'a>> for AdtDef {
 #[derive(Copy, Clone, Debug, Eq, PartialEq, Hash)]
 pub enum AdtKind { Struct, Union, Enum }
 
+impl Into<DataTypeKind> for AdtKind {
+    fn into(self) -> DataTypeKind {
+        match self {
+            AdtKind::Struct => DataTypeKind::Struct,
+            AdtKind::Union => DataTypeKind::Union,
+            AdtKind::Enum => DataTypeKind::Enum,
+        }
+    }
+}
+
 bitflags! {
     #[derive(RustcEncodable, RustcDecodable, Default)]
     pub struct ReprFlags: u8 {
diff --git a/src/librustc/ty/query/mod.rs b/src/librustc/ty/query/mod.rs
index 35080123d3e..ef22ebef9d7 100644
--- a/src/librustc/ty/query/mod.rs
+++ b/src/librustc/ty/query/mod.rs
@@ -13,7 +13,7 @@ use errors::DiagnosticBuilder;
 use hir::def_id::{CrateNum, DefId, DefIndex};
 use hir::def::{Def, Export};
 use hir::{self, TraitCandidate, ItemLocalId, CodegenFnAttrs};
-use hir::svh::Svh;
+use rustc_data_structures::svh::Svh;
 use infer::canonical::{self, Canonical};
 use lint;
 use middle::borrowck::BorrowCheckResult;
diff --git a/src/librustc/util/bug.rs b/src/librustc/util/bug.rs
new file mode 100644
index 00000000000..f2593e4d4b5
--- /dev/null
+++ b/src/librustc/util/bug.rs
@@ -0,0 +1,51 @@
+// Copyright 2018 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 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+// These functions are used by macro expansion for bug! and span_bug!
+
+use ty::tls;
+use std::fmt;
+use syntax_pos::{Span, MultiSpan};
+
+#[cold]
+#[inline(never)]
+pub fn bug_fmt(file: &'static str, line: u32, args: fmt::Arguments) -> ! {
+    // this wrapper mostly exists so I don't have to write a fully
+    // qualified path of None::<Span> inside the bug!() macro definition
+    opt_span_bug_fmt(file, line, None::<Span>, args);
+}
+
+#[cold]
+#[inline(never)]
+pub fn span_bug_fmt<S: Into<MultiSpan>>(
+    file: &'static str,
+    line: u32,
+    span: S,
+    args: fmt::Arguments,
+) -> ! {
+    opt_span_bug_fmt(file, line, Some(span), args);
+}
+
+fn opt_span_bug_fmt<S: Into<MultiSpan>>(
+    file: &'static str,
+    line: u32,
+    span: Option<S>,
+    args: fmt::Arguments,
+) -> ! {
+    tls::with_opt(move |tcx| {
+        let msg = format!("{}:{}: {}", file, line, args);
+        match (tcx, span) {
+            (Some(tcx), Some(span)) => tcx.sess.diagnostic().span_bug(span, &msg),
+            (Some(tcx), None) => tcx.sess.diagnostic().bug(&msg),
+            (None, _) => panic!(msg),
+        }
+    });
+    unreachable!();
+}
diff --git a/src/librustc/util/common.rs b/src/librustc/util/common.rs
index 990fbc4bc91..1ec025f78c9 100644
--- a/src/librustc/util/common.rs
+++ b/src/librustc/util/common.rs
@@ -14,12 +14,10 @@ use rustc_data_structures::sync::Lock;
 
 use std::cell::{RefCell, Cell};
 use std::collections::HashMap;
-use std::ffi::CString;
 use std::fmt::Debug;
 use std::hash::{Hash, BuildHasher};
 use std::panic;
 use std::env;
-use std::path::Path;
 use std::time::{Duration, Instant};
 
 use std::sync::mpsc::{Sender};
@@ -376,19 +374,6 @@ impl<K, V, S> MemoizationMap for RefCell<HashMap<K,V,S>>
     }
 }
 
-#[cfg(unix)]
-pub fn path2cstr(p: &Path) -> CString {
-    use std::os::unix::prelude::*;
-    use std::ffi::OsStr;
-    let p: &OsStr = p.as_ref();
-    CString::new(p.as_bytes()).unwrap()
-}
-#[cfg(windows)]
-pub fn path2cstr(p: &Path) -> CString {
-    CString::new(p.to_str().unwrap()).unwrap()
-}
-
-
 #[test]
 fn test_to_readable_str() {
     assert_eq!("0", to_readable_str(0));
diff --git a/src/librustc_codegen_llvm/back/link.rs b/src/librustc_codegen_llvm/back/link.rs
index 50d41d76986..bbe1ccf3696 100644
--- a/src/librustc_codegen_llvm/back/link.rs
+++ b/src/librustc_codegen_llvm/back/link.rs
@@ -26,7 +26,7 @@ use rustc::middle::cstore::{NativeLibrary, LibSource, NativeLibraryKind};
 use rustc::middle::dependency_format::Linkage;
 use {CodegenResults, CrateInfo};
 use rustc::util::common::time;
-use rustc::util::fs::fix_windows_verbatim_for_gcc;
+use rustc_fs_util::fix_windows_verbatim_for_gcc;
 use rustc::hir::def_id::CrateNum;
 use tempfile::{Builder as TempFileBuilder, TempDir};
 use rustc_target::spec::{PanicStrategy, RelroLevel, LinkerFlavor};
diff --git a/src/librustc_codegen_llvm/back/symbol_export.rs b/src/librustc_codegen_llvm/back/symbol_export.rs
index 02434b7be0b..c78d061a39b 100644
--- a/src/librustc_codegen_llvm/back/symbol_export.rs
+++ b/src/librustc_codegen_llvm/back/symbol_export.rs
@@ -15,7 +15,7 @@ use monomorphize::Instance;
 use rustc::hir;
 use rustc::hir::CodegenFnAttrFlags;
 use rustc::hir::def_id::{CrateNum, DefId, LOCAL_CRATE, CRATE_DEF_INDEX};
-use rustc::ich::Fingerprint;
+use rustc_data_structures::fingerprint::Fingerprint;
 use rustc::middle::exported_symbols::{SymbolExportLevel, ExportedSymbol, metadata_symbol_name};
 use rustc::session::config;
 use rustc::ty::{TyCtxt, SymbolName};
diff --git a/src/librustc_codegen_llvm/back/write.rs b/src/librustc_codegen_llvm/back/write.rs
index 640e1c1f3d4..cdfa874b177 100644
--- a/src/librustc_codegen_llvm/back/write.rs
+++ b/src/librustc_codegen_llvm/back/write.rs
@@ -30,8 +30,7 @@ use CrateInfo;
 use rustc::hir::def_id::{CrateNum, LOCAL_CRATE};
 use rustc::ty::TyCtxt;
 use rustc::util::common::{time_ext, time_depth, set_time_depth, print_time_passes_entry};
-use rustc::util::common::path2cstr;
-use rustc::util::fs::{link_or_copy};
+use rustc_fs_util::{path2cstr, link_or_copy};
 use errors::{self, Handler, Level, DiagnosticBuilder, FatalError, DiagnosticId};
 use errors::emitter::{Emitter};
 use syntax::attr;
diff --git a/src/librustc_codegen_llvm/debuginfo/metadata.rs b/src/librustc_codegen_llvm/debuginfo/metadata.rs
index 69ef92ed98e..8ee2404e10c 100644
--- a/src/librustc_codegen_llvm/debuginfo/metadata.rs
+++ b/src/librustc_codegen_llvm/debuginfo/metadata.rs
@@ -28,14 +28,15 @@ use rustc_data_structures::stable_hasher::{HashStable, StableHasher};
 use rustc::hir::CodegenFnAttrFlags;
 use rustc::hir::def::CtorKind;
 use rustc::hir::def_id::{DefId, CrateNum, LOCAL_CRATE};
-use rustc::ich::{Fingerprint, NodeIdHashingMode};
+use rustc::ich::NodeIdHashingMode;
+use rustc_data_structures::fingerprint::Fingerprint;
 use rustc::ty::Instance;
 use common::CodegenCx;
 use rustc::ty::{self, AdtKind, ParamEnv, Ty, TyCtxt};
 use rustc::ty::layout::{self, Align, LayoutOf, PrimitiveExt, Size, TyLayout};
 use rustc::session::config;
 use rustc::util::nodemap::FxHashMap;
-use rustc::util::common::path2cstr;
+use rustc_fs_util::path2cstr;
 
 use libc::{c_uint, c_longlong};
 use std::ffi::CString;
diff --git a/src/librustc_codegen_llvm/lib.rs b/src/librustc_codegen_llvm/lib.rs
index 9599ccfe979..4572f5891a4 100644
--- a/src/librustc_codegen_llvm/lib.rs
+++ b/src/librustc_codegen_llvm/lib.rs
@@ -55,6 +55,7 @@ extern crate rustc_incremental;
 extern crate rustc_llvm;
 extern crate rustc_platform_intrinsics as intrinsics;
 extern crate rustc_codegen_utils;
+extern crate rustc_fs_util;
 
 #[macro_use] extern crate log;
 #[macro_use] extern crate syntax;
diff --git a/src/librustc_codegen_llvm/metadata.rs b/src/librustc_codegen_llvm/metadata.rs
index fcb704413ef..a4526a53769 100644
--- a/src/librustc_codegen_llvm/metadata.rs
+++ b/src/librustc_codegen_llvm/metadata.rs
@@ -8,7 +8,6 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-use rustc::util::common;
 use rustc::middle::cstore::MetadataLoader;
 use rustc_target::spec::Target;
 use llvm;
@@ -19,6 +18,7 @@ use rustc_data_structures::owning_ref::OwningRef;
 use std::path::Path;
 use std::ptr;
 use std::slice;
+use rustc_fs_util::path2cstr;
 
 pub use rustc_data_structures::sync::MetadataRef;
 
@@ -57,7 +57,7 @@ impl MetadataLoader for LlvmMetadataLoader {
                           filename: &Path)
                           -> Result<MetadataRef, String> {
         unsafe {
-            let buf = common::path2cstr(filename);
+            let buf = path2cstr(filename);
             let mb = llvm::LLVMRustCreateMemoryBufferWithContentsOfFile(buf.as_ptr())
                 .ok_or_else(|| format!("error reading library: '{}'", filename.display()))?;
             let of = ObjectFile::new(mb)
diff --git a/src/librustc_codegen_utils/link.rs b/src/librustc_codegen_utils/link.rs
index 73cffdf7d49..a0d88ccae0f 100644
--- a/src/librustc_codegen_utils/link.rs
+++ b/src/librustc_codegen_utils/link.rs
@@ -11,7 +11,7 @@
 use rustc::session::config::{self, OutputFilenames, Input, OutputType};
 use rustc::session::Session;
 use rustc::middle::cstore::LinkMeta;
-use rustc::hir::svh::Svh;
+use rustc_data_structures::svh::Svh;
 use std::path::{Path, PathBuf};
 use syntax::{ast, attr};
 use syntax_pos::Span;
diff --git a/src/librustc/ich/fingerprint.rs b/src/librustc_data_structures/fingerprint.rs
index a6e35d78dcb..aa9ddda2b93 100644
--- a/src/librustc/ich/fingerprint.rs
+++ b/src/librustc_data_structures/fingerprint.rs
@@ -9,7 +9,7 @@
 // except according to those terms.
 
 use std::mem;
-use rustc_data_structures::stable_hasher;
+use stable_hasher;
 use serialize;
 use serialize::opaque::{EncodeResult, Encoder, Decoder};
 
@@ -92,14 +92,7 @@ impl stable_hasher::StableHasherResult for Fingerprint {
     }
 }
 
-impl<CTX> stable_hasher::HashStable<CTX> for Fingerprint {
-    #[inline]
-    fn hash_stable<W: stable_hasher::StableHasherResult>(&self,
-                                          _: &mut CTX,
-                                          hasher: &mut stable_hasher::StableHasher<W>) {
-        ::std::hash::Hash::hash(self, hasher);
-    }
-}
+impl_stable_hash_via_hash!(Fingerprint);
 
 impl serialize::UseSpecializedEncodable for Fingerprint { }
 
diff --git a/src/librustc_data_structures/lib.rs b/src/librustc_data_structures/lib.rs
index dd90cf7ae19..3aa15f472a2 100644
--- a/src/librustc_data_structures/lib.rs
+++ b/src/librustc_data_structures/lib.rs
@@ -46,6 +46,7 @@ extern crate stable_deref_trait;
 extern crate rustc_rayon as rayon;
 extern crate rustc_rayon_core as rayon_core;
 extern crate rustc_hash;
+extern crate serialize;
 
 // See librustc_cratesio_shim/Cargo.toml for a comment explaining this.
 #[allow(unused_extern_crates)]
@@ -53,6 +54,7 @@ extern crate rustc_cratesio_shim;
 
 pub use rustc_serialize::hex::ToHex;
 
+pub mod svh;
 pub mod accumulate_vec;
 pub mod array_vec;
 pub mod base_n;
@@ -71,13 +73,14 @@ pub mod small_vec;
 pub mod snapshot_map;
 pub use ena::snapshot_vec;
 pub mod sorted_map;
-pub mod stable_hasher;
+#[macro_use] pub mod stable_hasher;
 pub mod sync;
 pub mod tiny_list;
 pub mod transitive_relation;
 pub mod tuple_slice;
 pub use ena::unify;
 pub mod work_queue;
+pub mod fingerprint;
 
 pub struct OnDrop<F: Fn()>(pub F);
 
diff --git a/src/librustc_data_structures/stable_hasher.rs b/src/librustc_data_structures/stable_hasher.rs
index a8f689e5c81..9f1c7dac119 100644
--- a/src/librustc_data_structures/stable_hasher.rs
+++ b/src/librustc_data_structures/stable_hasher.rs
@@ -183,13 +183,16 @@ pub trait ToStableHashKey<HCX> {
 
 // Implement HashStable by just calling `Hash::hash()`. This works fine for
 // self-contained values that don't depend on the hashing context `CTX`.
+#[macro_export]
 macro_rules! impl_stable_hash_via_hash {
     ($t:ty) => (
-        impl<CTX> HashStable<CTX> for $t {
+        impl<CTX> $crate::stable_hasher::HashStable<CTX> for $t {
             #[inline]
-            fn hash_stable<W: StableHasherResult>(&self,
-                                                  _: &mut CTX,
-                                                  hasher: &mut StableHasher<W>) {
+            fn hash_stable<W: $crate::stable_hasher::StableHasherResult>(
+                &self,
+                _: &mut CTX,
+                hasher: &mut $crate::stable_hasher::StableHasher<W>
+            ) {
                 ::std::hash::Hash::hash(self, hasher);
             }
         }
diff --git a/src/librustc/hir/svh.rs b/src/librustc_data_structures/svh.rs
index a6cfcb710ed..94f132562b5 100644
--- a/src/librustc/hir/svh.rs
+++ b/src/librustc_data_structures/svh.rs
@@ -19,6 +19,8 @@ use std::fmt;
 use std::hash::{Hash, Hasher};
 use serialize::{Encodable, Decodable, Encoder, Decoder};
 
+use stable_hasher;
+
 #[derive(Copy, Clone, PartialEq, Eq, Debug)]
 pub struct Svh {
     hash: u64,
@@ -67,6 +69,16 @@ impl Decodable for Svh {
     }
 }
 
-impl_stable_hash_for!(struct Svh {
-    hash
-});
+impl<T> stable_hasher::HashStable<T> for Svh {
+    #[inline]
+    fn hash_stable<W: stable_hasher::StableHasherResult>(
+        &self,
+        ctx: &mut T,
+        hasher: &mut stable_hasher::StableHasher<W>
+    ) {
+        let Svh {
+            hash
+        } = *self;
+        hash.hash_stable(ctx, hasher);
+    }
+}
diff --git a/src/librustc_driver/driver.rs b/src/librustc_driver/driver.rs
index 805a5ecd991..b6e03b66510 100644
--- a/src/librustc_driver/driver.rs
+++ b/src/librustc_driver/driver.rs
@@ -11,7 +11,7 @@
 use rustc::dep_graph::DepGraph;
 use rustc::hir::{self, map as hir_map};
 use rustc::hir::lowering::lower_crate;
-use rustc::ich::Fingerprint;
+use rustc_data_structures::fingerprint::Fingerprint;
 use rustc_data_structures::stable_hasher::StableHasher;
 use rustc_mir as mir;
 use rustc::session::{CompileResult, CrateDisambiguator, Session};
diff --git a/src/librustc_fs_util/Cargo.toml b/src/librustc_fs_util/Cargo.toml
new file mode 100644
index 00000000000..e40b44204b3
--- /dev/null
+++ b/src/librustc_fs_util/Cargo.toml
@@ -0,0 +1,11 @@
+[package]
+authors = ["The Rust Project Developers"]
+name = "rustc_fs_util"
+version = "0.0.0"
+
+[lib]
+name = "rustc_fs_util"
+path = "lib.rs"
+crate-type = ["dylib"]
+
+[dependencies]
diff --git a/src/librustc/util/fs.rs b/src/librustc_fs_util/lib.rs
index 090753b18c0..ffe420b109d 100644
--- a/src/librustc/util/fs.rs
+++ b/src/librustc_fs_util/lib.rs
@@ -1,4 +1,4 @@
-// Copyright 2015 The Rust Project Developers. See the COPYRIGHT
+// Copyright 2018 The Rust Project Developers. See the COPYRIGHT
 // file at the top-level directory of this distribution and at
 // http://rust-lang.org/COPYRIGHT.
 //
@@ -8,8 +8,8 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-use std::path::{self, Path, PathBuf};
-use std::ffi::OsString;
+use std::path::{Path, PathBuf};
+use std::ffi::CString;
 use std::fs;
 use std::io;
 
@@ -29,10 +29,10 @@ use std::io;
 //
 // For some more information, see this comment:
 //   https://github.com/rust-lang/rust/issues/25505#issuecomment-102876737
+#[cfg(windows)]
 pub fn fix_windows_verbatim_for_gcc(p: &Path) -> PathBuf {
-    if !cfg!(windows) {
-        return p.to_path_buf();
-    }
+    use std::path;
+    use std::ffi::OsString;
     let mut components = p.components();
     let prefix = match components.next() {
         Some(path::Component::Prefix(p)) => p,
@@ -56,6 +56,11 @@ pub fn fix_windows_verbatim_for_gcc(p: &Path) -> PathBuf {
     }
 }
 
+#[cfg(not(windows))]
+pub fn fix_windows_verbatim_for_gcc(p: &Path) -> PathBuf {
+    p.to_path_buf()
+}
+
 pub enum LinkOrCopy {
     Link,
     Copy,
@@ -109,3 +114,15 @@ pub fn rename_or_copy_remove<P: AsRef<Path>, Q: AsRef<Path>>(p: P,
         }
     }
 }
+
+#[cfg(unix)]
+pub fn path2cstr(p: &Path) -> CString {
+    use std::os::unix::prelude::*;
+    use std::ffi::OsStr;
+    let p: &OsStr = p.as_ref();
+    CString::new(p.as_bytes()).unwrap()
+}
+#[cfg(windows)]
+pub fn path2cstr(p: &Path) -> CString {
+    CString::new(p.to_str().unwrap()).unwrap()
+}
diff --git a/src/librustc_incremental/Cargo.toml b/src/librustc_incremental/Cargo.toml
index dd05679589e..c3f6062e799 100644
--- a/src/librustc_incremental/Cargo.toml
+++ b/src/librustc_incremental/Cargo.toml
@@ -17,3 +17,4 @@ rustc_data_structures = { path = "../librustc_data_structures" }
 serialize = { path = "../libserialize" }
 syntax = { path = "../libsyntax" }
 syntax_pos = { path = "../libsyntax_pos" }
+rustc_fs_util = { path = "../librustc_fs_util" }
diff --git a/src/librustc_incremental/lib.rs b/src/librustc_incremental/lib.rs
index 22b260642e4..ad8714fa4d5 100644
--- a/src/librustc_incremental/lib.rs
+++ b/src/librustc_incremental/lib.rs
@@ -24,6 +24,7 @@ extern crate graphviz;
 extern crate rustc_data_structures;
 extern crate serialize as rustc_serialize;
 extern crate rand;
+extern crate rustc_fs_util;
 
 #[macro_use] extern crate log;
 extern crate syntax;
diff --git a/src/librustc_incremental/persist/fs.rs b/src/librustc_incremental/persist/fs.rs
index 795825f180c..28d53dc7fb3 100644
--- a/src/librustc_incremental/persist/fs.rs
+++ b/src/librustc_incremental/persist/fs.rs
@@ -114,11 +114,11 @@
 //! unsupported file system and emit a warning in that case. This is not yet
 //! implemented.
 
-use rustc::hir::svh::Svh;
 use rustc::session::{Session, CrateDisambiguator};
-use rustc::util::fs as fs_util;
+use rustc_fs_util::{link_or_copy, LinkOrCopy};
 use rustc_data_structures::{flock, base_n};
 use rustc_data_structures::fx::{FxHashSet, FxHashMap};
+use rustc_data_structures::svh::Svh;
 
 use std::fs as std_fs;
 use std::io;
@@ -429,11 +429,11 @@ fn copy_files(sess: &Session,
                 let source_path = entry.path();
 
                 debug!("copying into session dir: {}", source_path.display());
-                match fs_util::link_or_copy(source_path, target_file_path) {
-                    Ok(fs_util::LinkOrCopy::Link) => {
+                match link_or_copy(source_path, target_file_path) {
+                    Ok(LinkOrCopy::Link) => {
                         files_linked += 1
                     }
-                    Ok(fs_util::LinkOrCopy::Copy) => {
+                    Ok(LinkOrCopy::Copy) => {
                         files_copied += 1
                     }
                     Err(_) => return Err(())
diff --git a/src/librustc_incremental/persist/work_product.rs b/src/librustc_incremental/persist/work_product.rs
index c0ccbd67a31..cfe59b1f672 100644
--- a/src/librustc_incremental/persist/work_product.rs
+++ b/src/librustc_incremental/persist/work_product.rs
@@ -13,7 +13,7 @@
 use persist::fs::*;
 use rustc::dep_graph::{WorkProduct, WorkProductId, WorkProductFileKind};
 use rustc::session::Session;
-use rustc::util::fs::link_or_copy;
+use rustc_fs_util::link_or_copy;
 use std::path::PathBuf;
 use std::fs as std_fs;
 
diff --git a/src/librustc_metadata/creader.rs b/src/librustc_metadata/creader.rs
index 62c06aac1df..d3b70933e2c 100644
--- a/src/librustc_metadata/creader.rs
+++ b/src/librustc_metadata/creader.rs
@@ -16,7 +16,7 @@ use schema::CrateRoot;
 use rustc_data_structures::sync::{Lrc, RwLock, Lock};
 
 use rustc::hir::def_id::{CrateNum, CRATE_DEF_INDEX};
-use rustc::hir::svh::Svh;
+use rustc_data_structures::svh::Svh;
 use rustc::middle::allocator::AllocatorKind;
 use rustc::middle::cstore::DepKind;
 use rustc::mir::interpret::AllocDecodingState;
diff --git a/src/librustc_metadata/cstore_impl.rs b/src/librustc_metadata/cstore_impl.rs
index 060dddd5343..4926da3b880 100644
--- a/src/librustc_metadata/cstore_impl.rs
+++ b/src/librustc_metadata/cstore_impl.rs
@@ -30,6 +30,7 @@ use rustc::hir::map::{DefKey, DefPath, DefPathHash};
 use rustc::hir::map::blocks::FnLikeNode;
 use rustc::hir::map::definitions::DefPathTable;
 use rustc::util::nodemap::DefIdMap;
+use rustc_data_structures::svh::Svh;
 
 use std::any::Any;
 use rustc_data_structures::sync::Lrc;
@@ -515,7 +516,7 @@ impl CrateStore for cstore::CStore {
         self.get_crate_data(cnum).root.disambiguator
     }
 
-    fn crate_hash_untracked(&self, cnum: CrateNum) -> hir::svh::Svh
+    fn crate_hash_untracked(&self, cnum: CrateNum) -> Svh
     {
         self.get_crate_data(cnum).root.hash
     }
diff --git a/src/librustc_metadata/decoder.rs b/src/librustc_metadata/decoder.rs
index 5121b682d36..33d4cf26c03 100644
--- a/src/librustc_metadata/decoder.rs
+++ b/src/librustc_metadata/decoder.rs
@@ -22,7 +22,7 @@ use rustc::middle::exported_symbols::{ExportedSymbol, SymbolExportLevel};
 use rustc::hir::def::{self, Def, CtorKind};
 use rustc::hir::def_id::{CrateNum, DefId, DefIndex,
                          CRATE_DEF_INDEX, LOCAL_CRATE, LocalDefId};
-use rustc::ich::Fingerprint;
+use rustc_data_structures::fingerprint::Fingerprint;
 use rustc::middle::lang_items;
 use rustc::mir::{self, interpret};
 use rustc::mir::interpret::AllocDecodingSession;
diff --git a/src/librustc_metadata/encoder.rs b/src/librustc_metadata/encoder.rs
index 96d6c5b75f4..7c445cb715e 100644
--- a/src/librustc_metadata/encoder.rs
+++ b/src/librustc_metadata/encoder.rs
@@ -18,7 +18,7 @@ use rustc::middle::cstore::{LinkMeta, LinkagePreference, NativeLibrary,
 use rustc::hir::def::CtorKind;
 use rustc::hir::def_id::{CrateNum, CRATE_DEF_INDEX, DefIndex, DefId, LocalDefId, LOCAL_CRATE};
 use rustc::hir::map::definitions::DefPathTable;
-use rustc::ich::Fingerprint;
+use rustc_data_structures::fingerprint::Fingerprint;
 use rustc::middle::dependency_format::Linkage;
 use rustc::middle::exported_symbols::{ExportedSymbol, SymbolExportLevel,
                                       metadata_symbol_name};
diff --git a/src/librustc_metadata/locator.rs b/src/librustc_metadata/locator.rs
index f68bcdd62c6..52777e5f6b9 100644
--- a/src/librustc_metadata/locator.rs
+++ b/src/librustc_metadata/locator.rs
@@ -226,7 +226,7 @@ use cstore::{MetadataRef, MetadataBlob};
 use creader::Library;
 use schema::{METADATA_HEADER, rustc_version};
 
-use rustc::hir::svh::Svh;
+use rustc_data_structures::svh::Svh;
 use rustc::middle::cstore::MetadataLoader;
 use rustc::session::{config, Session};
 use rustc::session::filesearch::{FileSearch, FileMatches, FileDoesntMatch};
diff --git a/src/librustc_metadata/schema.rs b/src/librustc_metadata/schema.rs
index 894c7cbf683..781652e1985 100644
--- a/src/librustc_metadata/schema.rs
+++ b/src/librustc_metadata/schema.rs
@@ -20,6 +20,7 @@ use rustc::mir;
 use rustc::session::CrateDisambiguator;
 use rustc::ty::{self, Ty, ReprOptions};
 use rustc_target::spec::{PanicStrategy, TargetTriple};
+use rustc_data_structures::svh::Svh;
 
 use rustc_serialize as serialize;
 use syntax::{ast, attr};
@@ -187,7 +188,7 @@ pub struct CrateRoot {
     pub name: Symbol,
     pub triple: TargetTriple,
     pub extra_filename: String,
-    pub hash: hir::svh::Svh,
+    pub hash: Svh,
     pub disambiguator: CrateDisambiguator,
     pub panic_strategy: PanicStrategy,
     pub edition: Edition,
@@ -223,7 +224,7 @@ pub struct CrateRoot {
 #[derive(RustcEncodable, RustcDecodable)]
 pub struct CrateDep {
     pub name: ast::Name,
-    pub hash: hir::svh::Svh,
+    pub hash: Svh,
     pub kind: DepKind,
     pub extra_filename: String,
 }