about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--src/Cargo.lock6
-rw-r--r--src/librustc/ty/context.rs71
-rw-r--r--src/librustc/ty/item_path.rs2
-rw-r--r--src/librustc/ty/mod.rs32
-rw-r--r--src/librustc_driver/driver.rs4
-rw-r--r--src/librustc_metadata/cstore_impl.rs16
-rw-r--r--src/librustc_trans/base.rs7
-rw-r--r--src/librustdoc/build.rs1
-rw-r--r--src/librustdoc/core.rs2
-rw-r--r--src/librustdoc/visit_ast.rs10
m---------src/tools/rls0
11 files changed, 80 insertions, 71 deletions
diff --git a/src/Cargo.lock b/src/Cargo.lock
index 47ef0a7d8ca..1bbe8ca7575 100644
--- a/src/Cargo.lock
+++ b/src/Cargo.lock
@@ -1336,7 +1336,7 @@ dependencies = [
  "racer 2.0.10 (registry+https://github.com/rust-lang/crates.io-index)",
  "rls-analysis 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)",
  "rls-data 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)",
- "rls-rustc 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
+ "rls-rustc 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
  "rls-span 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
  "rls-vfs 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)",
  "rustfmt-nightly 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -1371,7 +1371,7 @@ dependencies = [
 
 [[package]]
 name = "rls-rustc"
-version = "0.1.0"
+version = "0.1.1"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 
 [[package]]
@@ -2544,7 +2544,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
 "checksum regex-syntax 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)" = "ad890a5eef7953f55427c50575c680c42841653abd2b028b68cd223d157f62db"
 "checksum rls-analysis 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)" = "d2cb40c0371765897ae428b5706bb17135705ad4f6d1b8b6afbaabcf8c9b5cff"
 "checksum rls-data 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)" = "11d339f1888e33e74d8032de0f83c40b2bdaaaf04a8cfc03b32186c3481fb534"
-"checksum rls-rustc 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "5fa757c9d547d460427ceff01875f9cac5f5acd8fc6543946e9b0335ba29d537"
+"checksum rls-rustc 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "b21ea952e9bf1569929abf1bb920262cde04b7b1b26d8e0260286302807299d2"
 "checksum rls-span 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "5d7c7046dc6a92f2ae02ed302746db4382e75131b9ce20ce967259f6b5867a6a"
 "checksum rls-vfs 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)" = "ffd34691a510938bb67fe0444fb363103c73ffb31c121d1e16bc92d8945ea8ff"
 "checksum rustc-demangle 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "aee45432acc62f7b9a108cc054142dac51f979e69e71ddce7d6fc7adf29e817e"
diff --git a/src/librustc/ty/context.rs b/src/librustc/ty/context.rs
index 88fcbc1707e..fb0cdab0b6a 100644
--- a/src/librustc/ty/context.rs
+++ b/src/librustc/ty/context.rs
@@ -21,11 +21,9 @@ use hir::map as hir_map;
 use hir::map::DefPathHash;
 use lint::{self, Lint};
 use ich::{self, StableHashingContext, NodeIdHashingMode};
-<<<<<<< 817e1b81e230d599585f860cdcad96c5ed83b93e
 use middle::const_val::ConstVal;
-=======
-use middle::cstore::CrateStore;
->>>>>>> Remove the `cstore` reference from Session in order to prepare encapsulating CrateStore access in tcx.
+use middle::cstore::{CrateStore, LinkMeta, EncodedMetadataHashes};
+use middle::cstore::EncodedMetadata;
 use middle::free_region::FreeRegionMap;
 use middle::lang_items;
 use middle::resolve_lifetime::{self, ObjectLifetimeDefault};
@@ -56,6 +54,7 @@ use rustc_data_structures::stable_hasher::{HashStable, StableHasher,
 use arena::{TypedArena, DroplessArena};
 use rustc_const_math::{ConstInt, ConstUsize};
 use rustc_data_structures::indexed_vec::IndexVec;
+use std::any::Any;
 use std::borrow::Borrow;
 use std::cell::{Cell, RefCell};
 use std::cmp::Ordering;
@@ -915,10 +914,6 @@ impl<'tcx> GlobalCtxt<'tcx> {
 }
 
 impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
-    pub fn cstore_untracked(&self) -> &CrateStore {
-        &*self.cstore
-    }
-
     pub fn alloc_generics(self, generics: ty::Generics) -> &'gcx ty::Generics {
         self.global_arenas.generics.alloc(generics)
     }
@@ -1183,6 +1178,54 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
     pub fn crates(self) -> Rc<Vec<CrateNum>> {
         self.all_crate_nums(LOCAL_CRATE)
     }
+
+    pub fn def_key(self, id: DefId) -> hir_map::DefKey {
+        if id.is_local() {
+            self.hir.def_key(id)
+        } else {
+            self.cstore.def_key(id)
+        }
+    }
+
+    /// Convert a `DefId` into its fully expanded `DefPath` (every
+    /// `DefId` is really just an interned def-path).
+    ///
+    /// Note that if `id` is not local to this crate, the result will
+    ///  be a non-local `DefPath`.
+    pub fn def_path(self, id: DefId) -> hir_map::DefPath {
+        if id.is_local() {
+            self.hir.def_path(id)
+        } else {
+            self.cstore.def_path(id)
+        }
+    }
+
+    #[inline]
+    pub fn def_path_hash(self, def_id: DefId) -> hir_map::DefPathHash {
+        if def_id.is_local() {
+            self.hir.definitions().def_path_hash(def_id.index)
+        } else {
+            self.cstore.def_path_hash(def_id)
+        }
+    }
+
+    pub fn metadata_encoding_version(self) -> Vec<u8> {
+        self.cstore.metadata_encoding_version().to_vec()
+    }
+
+    // Note that this is *untracked* and should only be used within the query
+    // system if the result is otherwise tracked through queries
+    pub fn crate_data_as_rc_any(self, cnum: CrateNum) -> Rc<Any> {
+        self.cstore.crate_data_as_rc_any(cnum)
+    }
+}
+
+impl<'a, 'tcx> TyCtxt<'a, 'tcx, 'tcx> {
+    pub fn encode_metadata(self, link_meta: &LinkMeta, reachable: &NodeSet)
+        -> (EncodedMetadata, EncodedMetadataHashes)
+    {
+        self.cstore.encode_metadata(self, link_meta, reachable)
+    }
 }
 
 impl<'gcx: 'tcx, 'tcx> GlobalCtxt<'gcx> {
@@ -2163,4 +2206,16 @@ pub fn provide(providers: &mut ty::maps::Providers) {
         let id = tcx.hir.definitions().def_index_to_hir_id(id.index);
         tcx.stability().local_deprecation_entry(id)
     };
+    providers.extern_mod_stmt_cnum = |tcx, id| {
+        let id = tcx.hir.as_local_node_id(id).unwrap();
+        tcx.cstore.extern_mod_stmt_cnum_untracked(id)
+    };
+    providers.all_crate_nums = |tcx, cnum| {
+        assert_eq!(cnum, LOCAL_CRATE);
+        Rc::new(tcx.cstore.crates_untracked())
+    };
+    providers.postorder_cnums = |tcx, cnum| {
+        assert_eq!(cnum, LOCAL_CRATE);
+        Rc::new(tcx.cstore.postorder_cnums_untracked())
+    };
 }
diff --git a/src/librustc/ty/item_path.rs b/src/librustc/ty/item_path.rs
index 64b231b11fc..a8ccb3e269f 100644
--- a/src/librustc/ty/item_path.rs
+++ b/src/librustc/ty/item_path.rs
@@ -151,7 +151,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
                 }
             }
 
-            cur_path.push(self.cstore_untracked().def_key(cur_def)
+            cur_path.push(self.def_key(cur_def)
                               .disambiguated_data.data.get_opt_name().unwrap_or_else(||
                 Symbol::intern("<unnamed>").as_str()));
             match visible_parent_map.get(&cur_def) {
diff --git a/src/librustc/ty/mod.rs b/src/librustc/ty/mod.rs
index 59c42c70129..2d5b0ce0954 100644
--- a/src/librustc/ty/mod.rs
+++ b/src/librustc/ty/mod.rs
@@ -2170,43 +2170,13 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
         }
     }
 
-    pub fn def_key(self, id: DefId) -> hir_map::DefKey {
-        if id.is_local() {
-            self.hir.def_key(id)
-        } else {
-            self.cstore_untracked().def_key(id)
-        }
-    }
-
-    /// Convert a `DefId` into its fully expanded `DefPath` (every
-    /// `DefId` is really just an interned def-path).
-    ///
-    /// Note that if `id` is not local to this crate, the result will
-    ///  be a non-local `DefPath`.
-    pub fn def_path(self, id: DefId) -> hir_map::DefPath {
-        if id.is_local() {
-            self.hir.def_path(id)
-        } else {
-            self.cstore_untracked().def_path(id)
-        }
-    }
-
-    #[inline]
-    pub fn def_path_hash(self, def_id: DefId) -> hir_map::DefPathHash {
-        if def_id.is_local() {
-            self.hir.definitions().def_path_hash(def_id.index)
-        } else {
-            self.cstore_untracked().def_path_hash(def_id)
-        }
-    }
-
     pub fn item_name(self, id: DefId) -> InternedString {
         if let Some(id) = self.hir.as_local_node_id(id) {
             self.hir.name(id).as_str()
         } else if id.index == CRATE_DEF_INDEX {
             self.original_crate_name(id.krate).as_str()
         } else {
-            let def_key = self.cstore_untracked().def_key(id);
+            let def_key = self.def_key(id);
             // The name of a StructCtor is that of its struct parent.
             if let hir_map::DefPathData::StructCtor = def_key.disambiguated_data.data {
                 self.item_name(DefId {
diff --git a/src/librustc_driver/driver.rs b/src/librustc_driver/driver.rs
index 5a35de7b6aa..c41d5beec68 100644
--- a/src/librustc_driver/driver.rs
+++ b/src/librustc_driver/driver.rs
@@ -274,7 +274,7 @@ pub fn compile_input(sess: &Session,
                                 phase5_result);
         phase5_result?;
 
-        phase_6_link_output(sess, cstore, &trans, &outputs);
+        phase_6_link_output(sess, &trans, &outputs);
 
         // Now that we won't touch anything in the incremental compilation directory
         // any more, we can finalize it (which involves renaming it)
@@ -1153,12 +1153,10 @@ pub fn phase_5_run_llvm_passes(sess: &Session,
 /// This should produce either a finished executable or library.
 #[cfg(feature="llvm")]
 pub fn phase_6_link_output(sess: &Session,
-                           cstore: &CrateStore,
                            trans: &trans::CrateTranslation,
                            outputs: &OutputFilenames) {
     time(sess.time_passes(), "linking", || {
         ::rustc_trans::back::link::link_binary(sess,
-                                               cstore,
                                                trans,
                                                outputs,
                                                &trans.crate_name.as_str())
diff --git a/src/librustc_metadata/cstore_impl.rs b/src/librustc_metadata/cstore_impl.rs
index 3a47ee1a36b..74e4ffcdfff 100644
--- a/src/librustc_metadata/cstore_impl.rs
+++ b/src/librustc_metadata/cstore_impl.rs
@@ -60,7 +60,7 @@ macro_rules! provide {
 
                 $tcx.dep_graph.read(dep_node);
 
-                let $cdata = $tcx.cstore_untracked().crate_data_as_rc_any($def_id.krate);
+                let $cdata = $tcx.crate_data_as_rc_any($def_id.krate);
                 let $cdata = $cdata.downcast_ref::<cstore::CrateMetadata>()
                     .expect("CrateStore crated ata is not a CrateMetadata");
                 $compute
@@ -275,15 +275,6 @@ pub fn provide_local<'tcx>(providers: &mut Providers<'tcx>) {
             assert_eq!(cnum, LOCAL_CRATE);
             Rc::new(link_args::collect(tcx))
         },
-        extern_mod_stmt_cnum: |tcx, id| {
-            let id = tcx.hir.as_local_node_id(id).unwrap();
-            tcx.cstore_untracked().extern_mod_stmt_cnum_untracked(id)
-        },
-
-        all_crate_nums: |tcx, cnum| {
-            assert_eq!(cnum, LOCAL_CRATE);
-            Rc::new(tcx.cstore_untracked().crates_untracked())
-        },
 
         // Returns a map from a sufficiently visible external item (i.e. an
         // external item that is visible from at least one local module) to a
@@ -342,11 +333,6 @@ pub fn provide_local<'tcx>(providers: &mut Providers<'tcx>) {
             Rc::new(visible_parent_map)
         },
 
-        postorder_cnums: |tcx, cnum| {
-            assert_eq!(cnum, LOCAL_CRATE);
-            Rc::new(tcx.cstore_untracked().postorder_cnums_untracked())
-        },
-
         ..*providers
     };
 }
diff --git a/src/librustc_trans/base.rs b/src/librustc_trans/base.rs
index ade05003ef8..026417682cc 100644
--- a/src/librustc_trans/base.rs
+++ b/src/librustc_trans/base.rs
@@ -777,16 +777,13 @@ fn write_metadata<'a, 'gcx>(tcx: TyCtxt<'a, 'gcx, 'gcx>,
                 EncodedMetadataHashes::new());
     }
 
-    let cstore = tcx.cstore_untracked();
-    let (metadata, hashes) = cstore.encode_metadata(tcx,
-                                                    &link_meta,
-                                                    exported_symbols);
+    let (metadata, hashes) = tcx.encode_metadata(link_meta, exported_symbols);
     if kind == MetadataKind::Uncompressed {
         return (metadata_llcx, metadata_llmod, metadata, hashes);
     }
 
     assert!(kind == MetadataKind::Compressed);
-    let mut compressed = cstore.metadata_encoding_version().to_vec();
+    let mut compressed = tcx.metadata_encoding_version();
     DeflateEncoder::new(&mut compressed, Compression::Fast)
         .write_all(&metadata.raw_data).unwrap();
 
diff --git a/src/librustdoc/build.rs b/src/librustdoc/build.rs
index 507393bed8a..830492dec94 100644
--- a/src/librustdoc/build.rs
+++ b/src/librustdoc/build.rs
@@ -26,6 +26,7 @@ fn main() {
        .file("../rt/hoedown/src/version.c")
        .warnings(false)
        .include(src_dir)
+       .warnings(false)
        .compile("libhoedown.a");
 }
 
diff --git a/src/librustdoc/core.rs b/src/librustdoc/core.rs
index 81396d41606..d7ce5e262ce 100644
--- a/src/librustdoc/core.rs
+++ b/src/librustdoc/core.rs
@@ -215,7 +215,7 @@ pub fn run_core(search_paths: SearchPaths,
         debug!("crate: {:?}", tcx.hir.krate());
 
         let krate = {
-            let mut v = RustdocVisitor::new(&ctxt);
+            let mut v = RustdocVisitor::new(&*cstore, &ctxt);
             v.visit(tcx.hir.krate());
             v.clean(&ctxt)
         };
diff --git a/src/librustdoc/visit_ast.rs b/src/librustdoc/visit_ast.rs
index b74bac7a85b..327a330c2a2 100644
--- a/src/librustdoc/visit_ast.rs
+++ b/src/librustdoc/visit_ast.rs
@@ -21,7 +21,7 @@ use syntax_pos::Span;
 use rustc::hir::map as hir_map;
 use rustc::hir::def::Def;
 use rustc::hir::def_id::{DefId, LOCAL_CRATE};
-use rustc::middle::cstore::LoadedMacro;
+use rustc::middle::cstore::{LoadedMacro, CrateStore};
 use rustc::middle::privacy::AccessLevel;
 use rustc::util::nodemap::FxHashSet;
 
@@ -40,6 +40,7 @@ use doctree::*;
 // framework from syntax?
 
 pub struct RustdocVisitor<'a, 'tcx: 'a> {
+    cstore: &'tcx CrateStore,
     pub module: Module,
     pub attrs: hir::HirVec<ast::Attribute>,
     pub cx: &'a core::DocContext<'a, 'tcx>,
@@ -51,7 +52,8 @@ pub struct RustdocVisitor<'a, 'tcx: 'a> {
 }
 
 impl<'a, 'tcx> RustdocVisitor<'a, 'tcx> {
-    pub fn new(cx: &'a core::DocContext<'a, 'tcx>) -> RustdocVisitor<'a, 'tcx> {
+    pub fn new(cstore: &'tcx CrateStore,
+               cx: &'a core::DocContext<'a, 'tcx>) -> RustdocVisitor<'a, 'tcx> {
         // If the root is reexported, terminate all recursion.
         let mut stack = FxHashSet();
         stack.insert(ast::CRATE_NODE_ID);
@@ -63,6 +65,7 @@ impl<'a, 'tcx> RustdocVisitor<'a, 'tcx> {
             inlining: false,
             inside_public_path: true,
             reexported_macros: FxHashSet(),
+            cstore,
         }
     }
 
@@ -208,8 +211,7 @@ impl<'a, 'tcx> RustdocVisitor<'a, 'tcx> {
                     }
 
                     let imported_from = self.cx.tcx.original_crate_name(def_id.krate);
-                    let cstore = &self.cx.sess().cstore;
-                    let def = match cstore.load_macro_untracked(def_id, self.cx.sess()) {
+                    let def = match self.cstore.load_macro_untracked(def_id, self.cx.sess()) {
                         LoadedMacro::MacroDef(macro_def) => macro_def,
                         // FIXME(jseyfried): document proc macro reexports
                         LoadedMacro::ProcMacro(..) => continue,
diff --git a/src/tools/rls b/src/tools/rls
-Subproject 303671ea8103cbc39575a1f47a204159546a04d
+Subproject 8dd70945fb049df3f9dc7685cdc58d94e05e8ff