]> git.lizzy.rs Git - rust.git/commitdiff
fix tidy
authorAriel Ben-Yehuda <arielb1@mail.tau.ac.il>
Wed, 25 Nov 2015 15:02:59 +0000 (17:02 +0200)
committerAriel Ben-Yehuda <arielb1@mail.tau.ac.il>
Thu, 26 Nov 2015 16:22:40 +0000 (18:22 +0200)
src/librustc/middle/cstore.rs
src/librustc_driver/lib.rs
src/librustc_metadata/creader.rs
src/librustc_metadata/csearch.rs
src/librustc_metadata/cstore.rs
src/librustdoc/clean/inline.rs
src/test/compile-fail/use-from-trait-xc.rs

index ee337f02ffc968a9a7b4173f26324b91092b32c0..2db43a9497612b5b5276cd1f4e1e36754ca9907f 100644 (file)
@@ -42,7 +42,7 @@
 use syntax::ptr::P;
 use rustc_back::target::Target;
 use rustc_front::hir;
-use rustc_front::visit::Visitor;
+use rustc_front::intravisit::Visitor;
 use rustc_front::util::IdVisitor;
 
 pub use self::DefLike::{DlDef, DlField, DlImpl};
@@ -123,6 +123,13 @@ pub enum FoundAst<'ast> {
     NotFound,
 }
 
+/// A store of Rust crates, through with their metadata
+/// can be accessed.
+///
+/// The `: Any` bound is a temporary measure that allows access
+/// to the backing `rustc_metadata::cstore::CStore` object. It
+/// will be removed in the near future - if you need to access
+/// internal APIs, please tell us.
 pub trait CrateStore<'tcx> : Any {
     // item info
     fn stability(&self, def: DefId) -> Option<attr::Stability>;
@@ -244,11 +251,7 @@ pub fn visit<'ast,V>(&'ast self, visitor: &mut V)
     }
 
     pub fn visit_ids<O: IdVisitingOperation>(&self, operation: &mut O) {
-        let mut id_visitor = IdVisitor {
-            operation: operation,
-            pass_through_items: true,
-            visited_outermost: false,
-        };
+        let mut id_visitor = IdVisitor::new(operation);
         self.visit(&mut id_visitor);
     }
 }
index b77425e18092927c7f65de28b8867087e7fef03c..3a91b573fd4aa8db3abb4bf82611d0926ea6f060 100644 (file)
 const BUG_REPORT_URL: &'static str = "https://github.com/rust-lang/rust/blob/master/CONTRIBUTING.\
                                       md#bug-reports";
 
-// [stage0]: kill this
+// SNAP 1af31d4
+// This is a terrible hack. Our stage0 is older than 1.4 and does not
+// support DST coercions, so this function performs the corecion
+// manually. This should go away.
 pub fn cstore_to_cratestore(a: Rc<CStore>) -> Rc<for<'s> CrateStore<'s>>
 {
     use std::mem;
index 89aa3bf86611a3a983a2b6eaf16837266e3133cd..4420da5f9b87dfd3f7d77fcb18f73d24381e1b27 100644 (file)
@@ -20,7 +20,7 @@
 use rustc::back::svh::Svh;
 use rustc::session::{config, Session};
 use rustc::session::search_paths::PathKind;
-use rustc::middle::cstore::validate_crate_name;
+use rustc::middle::cstore::{CrateStore, validate_crate_name};
 use rustc::util::nodemap::FnvHashMap;
 use rustc::front::map as hir_map;
 
@@ -223,7 +223,7 @@ fn existing_match(&self, name: &str, hash: Option<&Svh>, kind: PathKind)
             // We're also sure to compare *paths*, not actual byte slices. The
             // `source` stores paths which are normalized which may be different
             // from the strings on the command line.
-            let source = self.cstore.do_get_used_crate_source(cnum).unwrap();
+            let source = self.cstore.used_crate_source(cnum);
             if let Some(locs) = self.sess.opts.externs.get(name) {
                 let found = locs.iter().any(|l| {
                     let l = fs::canonicalize(l).ok();
@@ -395,7 +395,7 @@ enum LookupResult {
                 if explicitly_linked && !data.explicitly_linked.get() {
                     data.explicitly_linked.set(explicitly_linked);
                 }
-                (cnum, data, self.cstore.do_get_used_crate_source(cnum).unwrap())
+                (cnum, data, self.cstore.used_crate_source(cnum))
             }
             LookupResult::Loaded(library) => {
                 self.register_crate(root, ident, name, span, library,
@@ -707,7 +707,8 @@ fn validate(me: &CrateReader, krate: ast::CrateNum,
 }
 
 impl<'a, 'b> LocalCrateReader<'a, 'b> {
-    pub fn new(sess: &'a Session, cstore: &'a CStore, map: &'a hir_map::Map<'b>) -> LocalCrateReader<'a, 'b> {
+    pub fn new(sess: &'a Session, cstore: &'a CStore,
+               map: &'a hir_map::Map<'b>) -> LocalCrateReader<'a, 'b> {
         LocalCrateReader {
             sess: sess,
             cstore: cstore,
index 99fa18837ebe6bd9b8468f8766f303b9036b07bb..3c97692ee56eb5a4d205cc9ddc5d9c848464ee3d 100644 (file)
@@ -447,12 +447,12 @@ fn used_crates(&self, prefer: LinkagePreference) -> Vec<(ast::CrateNum, Option<P
 
     fn used_crate_source(&self, cnum: ast::CrateNum) -> CrateSource
     {
-        self.do_get_used_crate_source(cnum).unwrap()
+        self.opt_used_crate_source(cnum).unwrap()
     }
 
     fn extern_mod_stmt_cnum(&self, emod_id: ast::NodeId) -> Option<ast::CrateNum>
     {
-        self.find_extern_mod_stmt_cnum(emod_id)
+        self.do_extern_mod_stmt_cnum(emod_id)
     }
 
     fn encode_metadata(&self,
index 6a1f9d16fe7a403d065e4675a495f2a32522f03e..b0eef29467ba21b4db5faade747da69189d898bd 100644 (file)
@@ -136,7 +136,7 @@ pub fn iter_crate_data_origins<I>(&self, mut i: I) where
         I: FnMut(ast::CrateNum, &crate_metadata, Option<CrateSource>),
     {
         for (&k, v) in self.metas.borrow().iter() {
-            let origin = self.do_get_used_crate_source(k);
+            let origin = self.opt_used_crate_source(k);
             origin.as_ref().map(|cs| { assert!(k == cs.cnum); });
             i(k, &**v, origin);
         }
@@ -149,9 +149,8 @@ pub fn add_used_crate_source(&self, src: CrateSource) {
         }
     }
 
-    // TODO: killdo
-    pub fn do_get_used_crate_source(&self, cnum: ast::CrateNum)
-                                    -> Option<CrateSource> {
+    pub fn opt_used_crate_source(&self, cnum: ast::CrateNum)
+                                 -> Option<CrateSource> {
         self.used_crate_sources.borrow_mut()
             .iter().find(|source| source.cnum == cnum).cloned()
     }
@@ -174,7 +173,6 @@ pub fn reset(&self) {
     // In order to get this left-to-right dependency ordering, we perform a
     // topological sort of all crates putting the leaves at the right-most
     // positions.
-    // TODO: killdo
     pub fn do_get_used_crates(&self, prefer: LinkagePreference)
                               -> Vec<(ast::CrateNum, Option<PathBuf>)> {
         let mut ordering = Vec::new();
@@ -234,11 +232,6 @@ pub fn add_extern_mod_stmt_cnum(&self,
         self.extern_mod_crate_map.borrow_mut().insert(emod_id, cnum);
     }
 
-    pub fn find_extern_mod_stmt_cnum(&self, emod_id: ast::NodeId)
-                                     -> Option<ast::CrateNum> {
-        self.extern_mod_crate_map.borrow().get(&emod_id).cloned()
-    }
-
     pub fn add_statically_included_foreign_item(&self, id: ast::NodeId) {
         self.statically_included_foreign_items.borrow_mut().insert(id);
     }
@@ -246,6 +239,11 @@ pub fn add_statically_included_foreign_item(&self, id: ast::NodeId) {
     pub fn do_is_statically_included_foreign_item(&self, id: ast::NodeId) -> bool {
         self.statically_included_foreign_items.borrow().contains(&id)
     }
+
+    pub fn do_extern_mod_stmt_cnum(&self, emod_id: ast::NodeId) -> Option<ast::CrateNum>
+    {
+        self.extern_mod_crate_map.borrow().get(&emod_id).cloned()
+    }
 }
 
 impl crate_metadata {
index 8b687a250dc2e78f214646fa8f533d14c4ea0c83..40cd5e5bf278715ce39ea3b7f23c8ddf0c2fb105 100644 (file)
@@ -169,7 +169,7 @@ fn build_external_function(cx: &DocContext, tcx: &ty::ctxt, did: DefId) -> clean
         _ => panic!("bad function"),
     };
 
-    let constness = if csearch::is_const_fn(&tcx.sess.cstore, did) {
+    let constness = if tcx.sess.cstore.is_const_fn(did) {
         hir::Constness::Const
     } else {
         hir::Constness::NotConst
@@ -346,7 +346,7 @@ pub fn build_impl(cx: &DocContext,
                     clean::TyMethodItem(clean::TyMethod {
                         unsafety, decl, self_, generics, abi
                     }) => {
-                        let constness = if csearch::is_const_fn(&tcx.sess.cstore, did) {
+                        let constness = if tcx.sess.cstore.is_const_fn(did) {
                             hir::Constness::Const
                         } else {
                             hir::Constness::NotConst
index 4f7e38bd26b0a6e877e4e36e1a824741807e3961..e6c9b1b41c0486bebef3aa6c1e04b86309658a8a 100644 (file)
 //~^ ERROR `CONST` is not directly importable
 
 use use_from_trait_xc::Foo::new;
-//~^ ERROR `new` is not directly importable
+//~^ ERROR unresolved import `use_from_trait_xc::Foo::new`
 
 use use_from_trait_xc::Foo::C;
 //~^ ERROR unresolved import `use_from_trait_xc::Foo::C`
 
 use use_from_trait_xc::Bar::new as bnew;
-//~^ ERROR `bnew` is not directly importable
+//~^ ERROR unresolved import `use_from_trait_xc::Bar::new`
 
 use use_from_trait_xc::Baz::new as baznew;
 //~^ ERROR `baznew` is not directly importable