about summary refs log tree commit diff
path: root/src/libsyntax/ast_map
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2015-01-07 05:31:23 +0000
committerbors <bors@rust-lang.org>2015-01-07 05:31:23 +0000
commit9e4e524e0eb17c8f463e731f23b544003e8709c6 (patch)
tree916024d35e08f0826c20654f629ec596b5cb1f14 /src/libsyntax/ast_map
parentea6f65c5f1a3f84e010d2cef02a0160804e9567a (diff)
parenta64000820f0fc32be4d7535a9a92418a434fa4ba (diff)
auto merge of #20677 : alexcrichton/rust/rollup, r=alexcrichton
Diffstat (limited to 'src/libsyntax/ast_map')
-rw-r--r--src/libsyntax/ast_map/mod.rs43
1 files changed, 25 insertions, 18 deletions
diff --git a/src/libsyntax/ast_map/mod.rs b/src/libsyntax/ast_map/mod.rs
index cf09e2777f7..7496a0f9f26 100644
--- a/src/libsyntax/ast_map/mod.rs
+++ b/src/libsyntax/ast_map/mod.rs
@@ -46,8 +46,15 @@ impl PathElem {
     }
 }
 
+//NOTE(stage0): replace with deriving(Show) after snapshot
 impl fmt::Show for PathElem {
     fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
+        fmt::String::fmt(self, f)
+    }
+}
+
+impl fmt::String for PathElem {
+    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
         let slot = token::get_name(self.name());
         write!(f, "{}", slot)
     }
@@ -99,7 +106,7 @@ pub fn path_to_string<PI: Iterator<Item=PathElem>>(path: PI) -> String {
         if !s.is_empty() {
             s.push_str("::");
         }
-        s.push_str(e[]);
+        s.push_str(e.index(&FullRange));
         s
     }).to_string()
 }
@@ -396,7 +403,7 @@ impl<'ast> Map<'ast> {
                                 PathName(ident.name)
                             }
                             MethMac(_) => {
-                                panic!("no path elem for {}", node)
+                                panic!("no path elem for {:?}", node)
                             }
                         }
                     }
@@ -410,7 +417,7 @@ impl<'ast> Map<'ast> {
                         MethDecl(ident, _, _, _, _, _, _, _) => {
                             PathName(ident.name)
                         }
-                        MethMac(_) => panic!("no path elem for {}", node),
+                        MethMac(_) => panic!("no path elem for {:?}", node),
                     }
                 }
                 TypeTraitItem(ref m) => {
@@ -418,7 +425,7 @@ impl<'ast> Map<'ast> {
                 }
             },
             NodeVariant(v) => PathName(v.node.name.name),
-            _ => panic!("no path elem for {}", node)
+            _ => panic!("no path elem for {:?}", node)
         }
     }
 
@@ -476,20 +483,20 @@ impl<'ast> Map<'ast> {
         F: FnOnce(Option<&[Attribute]>) -> T,
     {
         let attrs = match self.get(id) {
-            NodeItem(i) => Some(i.attrs[]),
-            NodeForeignItem(fi) => Some(fi.attrs[]),
+            NodeItem(i) => Some(i.attrs.index(&FullRange)),
+            NodeForeignItem(fi) => Some(fi.attrs.index(&FullRange)),
             NodeTraitItem(ref tm) => match **tm {
-                RequiredMethod(ref type_m) => Some(type_m.attrs[]),
-                ProvidedMethod(ref m) => Some(m.attrs[]),
-                TypeTraitItem(ref typ) => Some(typ.attrs[]),
+                RequiredMethod(ref type_m) => Some(type_m.attrs.index(&FullRange)),
+                ProvidedMethod(ref m) => Some(m.attrs.index(&FullRange)),
+                TypeTraitItem(ref typ) => Some(typ.attrs.index(&FullRange)),
             },
             NodeImplItem(ref ii) => {
                 match **ii {
-                    MethodImplItem(ref m) => Some(m.attrs[]),
-                    TypeImplItem(ref t) => Some(t.attrs[]),
+                    MethodImplItem(ref m) => Some(m.attrs.index(&FullRange)),
+                    TypeImplItem(ref t) => Some(t.attrs.index(&FullRange)),
                 }
             }
-            NodeVariant(ref v) => Some(v.node.attrs[]),
+            NodeVariant(ref v) => Some(v.node.attrs.index(&FullRange)),
             // unit/tuple structs take the attributes straight from
             // the struct definition.
             // FIXME(eddyb) make this work again (requires access to the map).
@@ -513,7 +520,7 @@ impl<'ast> Map<'ast> {
         NodesMatchingSuffix {
             map: self,
             item_name: parts.last().unwrap(),
-            in_which: parts[..parts.len() - 1],
+            in_which: parts.index(&(0..(parts.len() - 1))),
             idx: 0,
         }
     }
@@ -549,7 +556,7 @@ impl<'ast> Map<'ast> {
 
     pub fn span(&self, id: NodeId) -> Span {
         self.opt_span(id)
-            .unwrap_or_else(|| panic!("AstMap.span: could not find span for id {}", id))
+            .unwrap_or_else(|| panic!("AstMap.span: could not find span for id {:?}", id))
     }
 
     pub fn def_id_span(&self, def_id: DefId, fallback: Span) -> Span {
@@ -590,7 +597,7 @@ impl<'a, 'ast> NodesMatchingSuffix<'a, 'ast> {
                 None => return false,
                 Some((node_id, name)) => (node_id, name),
             };
-            if part[] != mod_name.as_str() {
+            if part.index(&FullRange) != mod_name.as_str() {
                 return false;
             }
             cursor = self.map.get_parent(mod_id);
@@ -628,7 +635,7 @@ impl<'a, 'ast> NodesMatchingSuffix<'a, 'ast> {
     // We are looking at some node `n` with a given name and parent
     // id; do their names match what I am seeking?
     fn matches_names(&self, parent_of_n: NodeId, name: Name) -> bool {
-        name.as_str() == self.item_name[] &&
+        name.as_str() == self.item_name.index(&FullRange) &&
             self.suffix_matches(parent_of_n)
     }
 }
@@ -729,7 +736,7 @@ struct NodeCollector<'ast> {
 
 impl<'ast> NodeCollector<'ast> {
     fn insert_entry(&mut self, id: NodeId, entry: MapEntry<'ast>) {
-        debug!("ast_map: {} => {}", id, entry);
+        debug!("ast_map: {:?} => {:?}", id, entry);
         let len = self.map.len();
         if id as uint >= len {
             self.map.extend(repeat(NotPresent).take(id as uint - len + 1));
@@ -1040,7 +1047,7 @@ impl<'a> NodePrinter for pprust::State<'a> {
 
 fn node_id_to_string(map: &Map, id: NodeId, include_id: bool) -> String {
     let id_str = format!(" (id={})", id);
-    let id_str = if include_id { id_str[] } else { "" };
+    let id_str = if include_id { id_str.index(&FullRange) } else { "" };
 
     match map.find(id) {
         Some(NodeItem(item)) => {