]> git.lizzy.rs Git - rust.git/blobdiff - src/librustc_trans/symbol_names_test.rs
move Instance to rustc and use it in the collector
[rust.git] / src / librustc_trans / symbol_names_test.rs
index aa23a1817227657f8e71aad3d0051ca8ae4c8082..fe551b06b3d95cff1b7e774139d7fbd99f5a19d9 100644 (file)
@@ -14,8 +14,9 @@
 //! item-path. This is used for unit testing the code that generates
 //! paths etc in all kinds of annoying scenarios.
 
+use back::symbol_names;
 use rustc::hir;
-use rustc::hir::intravisit::{self, Visitor};
+use rustc::hir::intravisit::{self, Visitor, NestedVisitorMap};
 use syntax::ast;
 
 use common::SharedCrateContext;
@@ -36,7 +37,7 @@ pub fn report_symbol_names(scx: &SharedCrateContext) {
     let _ignore = tcx.dep_graph.in_ignore();
     let mut visitor = SymbolNamesTest { scx: scx };
     // FIXME(#37712) could use ItemLikeVisitor if trait items were item-like
-    tcx.map.krate().visit_all_item_likes(&mut visitor.as_deep_visitor());
+    tcx.hir.krate().visit_all_item_likes(&mut visitor.as_deep_visitor());
 }
 
 struct SymbolNamesTest<'a, 'tcx:'a> {
@@ -47,12 +48,12 @@ impl<'a, 'tcx> SymbolNamesTest<'a, 'tcx> {
     fn process_attrs(&mut self,
                      node_id: ast::NodeId) {
         let tcx = self.scx.tcx();
-        let def_id = tcx.map.local_def_id(node_id);
+        let def_id = tcx.hir.local_def_id(node_id);
         for attr in tcx.get_attrs(def_id).iter() {
             if attr.check_name(SYMBOL_NAME) {
                 // for now, can only use on monomorphic names
-                let instance = Instance::mono(self.scx, def_id);
-                let name = instance.symbol_name(self.scx);
+                let instance = Instance::mono(tcx, def_id);
+                let name = symbol_names::symbol_name(instance, self.scx);
                 tcx.sess.span_err(attr.span, &format!("symbol-name({})", name));
             } else if attr.check_name(ITEM_PATH) {
                 let path = tcx.item_path_str(def_id);
@@ -67,6 +68,10 @@ fn process_attrs(&mut self,
 }
 
 impl<'a, 'tcx> Visitor<'tcx> for SymbolNamesTest<'a, 'tcx> {
+    fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'tcx> {
+        NestedVisitorMap::None
+    }
+
     fn visit_item(&mut self, item: &'tcx hir::Item) {
         self.process_attrs(item.id);
         intravisit::walk_item(self, item);
@@ -82,4 +87,3 @@ fn visit_impl_item(&mut self, ii: &'tcx hir::ImplItem) {
         intravisit::walk_impl_item(self, ii)
     }
 }
-