summary refs log tree commit diff
path: root/src/libsyntax
diff options
context:
space:
mode:
authorManish Goregaokar <manishsmail@gmail.com>2015-01-29 03:04:09 +0530
committerManish Goregaokar <manishsmail@gmail.com>2015-01-29 03:04:09 +0530
commitbe13211b0aa7a869e649c952df21d595e35bc6a3 (patch)
tree0385e2ca8cf5036ce994e2ba3b33319b784097b2 /src/libsyntax
parentee0be3b3e76773618bf230b7188ac633ac0e76aa (diff)
parent7aa27353931c3cad8d43ee7ba82f622a68faac18 (diff)
downloadrust-be13211b0aa7a869e649c952df21d595e35bc6a3.tar.gz
rust-be13211b0aa7a869e649c952df21d595e35bc6a3.zip
Rollup merge of #21626 - Ms2ger:various-cleanup, r=eddyb
Diffstat (limited to 'src/libsyntax')
-rw-r--r--src/libsyntax/ast_map/mod.rs21
-rw-r--r--src/libsyntax/ast_util.rs21
2 files changed, 11 insertions, 31 deletions
diff --git a/src/libsyntax/ast_map/mod.rs b/src/libsyntax/ast_map/mod.rs
index 96476cabac5..002e003afcb 100644
--- a/src/libsyntax/ast_map/mod.rs
+++ b/src/libsyntax/ast_map/mod.rs
@@ -75,21 +75,8 @@ impl<'a> Iterator for LinkedPath<'a> {
     }
 }
 
-// HACK(eddyb) move this into libstd (value wrapper for slice::Iter).
-#[derive(Clone)]
-pub struct Values<'a, T:'a>(pub slice::Iter<'a, T>);
-
-impl<'a, T: Copy> Iterator for Values<'a, T> {
-    type Item = T;
-
-    fn next(&mut self) -> Option<T> {
-        let &mut Values(ref mut items) = self;
-        items.next().map(|&x| x)
-    }
-}
-
 /// The type of the iterator used by with_path.
-pub type PathElems<'a, 'b> = iter::Chain<Values<'a, PathElem>, LinkedPath<'b>>;
+pub type PathElems<'a, 'b> = iter::Chain<iter::Cloned<slice::Iter<'a, PathElem>>, LinkedPath<'b>>;
 
 pub fn path_to_string<PI: Iterator<Item=PathElem>>(path: PI) -> String {
     let itr = token::get_ident_interner();
@@ -101,7 +88,7 @@ pub fn path_to_string<PI: Iterator<Item=PathElem>>(path: PI) -> String {
         }
         s.push_str(&e[]);
         s
-    }).to_string()
+    })
 }
 
 #[derive(Copy, Show)]
@@ -458,9 +445,9 @@ impl<'ast> Map<'ast> {
         if parent == id {
             match self.find_entry(id) {
                 Some(RootInlinedParent(data)) => {
-                    f(Values(data.path.iter()).chain(next))
+                    f(data.path.iter().cloned().chain(next))
                 }
-                _ => f(Values([].iter()).chain(next))
+                _ => f([].iter().cloned().chain(next))
             }
         } else {
             self.with_path_next(parent, Some(&LinkedPathNode {
diff --git a/src/libsyntax/ast_util.rs b/src/libsyntax/ast_util.rs
index 5aeea47ac60..07d3290d410 100644
--- a/src/libsyntax/ast_util.rs
+++ b/src/libsyntax/ast_util.rs
@@ -670,20 +670,13 @@ pub fn path_name_eq(a : &ast::Path, b : &ast::Path) -> bool {
 
 // are two arrays of segments equal when compared unhygienically?
 pub fn segments_name_eq(a : &[ast::PathSegment], b : &[ast::PathSegment]) -> bool {
-    if a.len() != b.len() {
-        false
-    } else {
-        for (idx,seg) in a.iter().enumerate() {
-            if seg.identifier.name != b[idx].identifier.name
-                // FIXME #7743: ident -> name problems in lifetime comparison?
-                // can types contain idents?
-                || seg.parameters != b[idx].parameters
-            {
-                return false;
-            }
-        }
-        true
-    }
+    a.len() == b.len() &&
+    a.iter().zip(b.iter()).all(|(s, t)| {
+        s.identifier.name == t.identifier.name &&
+        // FIXME #7743: ident -> name problems in lifetime comparison?
+        // can types contain idents?
+        s.parameters == t.parameters
+    })
 }
 
 /// Returns true if this literal is a string and false otherwise.