diff options
Diffstat (limited to 'src/libsyntax')
| -rw-r--r-- | src/libsyntax/ast_map/mod.rs | 21 | ||||
| -rw-r--r-- | src/libsyntax/ast_util.rs | 21 | ||||
| -rw-r--r-- | src/libsyntax/ext/expand.rs | 5 | ||||
| -rw-r--r-- | src/libsyntax/parse/mod.rs | 2 | ||||
| -rw-r--r-- | src/libsyntax/print/pprust.rs | 1 |
5 files changed, 13 insertions, 37 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. diff --git a/src/libsyntax/ext/expand.rs b/src/libsyntax/ext/expand.rs index 629991799e7..acf0fe7f6cd 100644 --- a/src/libsyntax/ext/expand.rs +++ b/src/libsyntax/ext/expand.rs @@ -1433,15 +1433,12 @@ mod test { use super::{pattern_bindings, expand_crate}; use super::{PatIdentFinder, IdentRenamer, PatIdentRenamer, ExpansionConfig}; use ast; - use ast::{Attribute_, AttrOuter, MetaWord, Name}; - use attr; + use ast::Name; use codemap; - use codemap::Spanned; use ext::mtwt; use fold::Folder; use parse; use parse::token; - use ptr::P; use util::parser_testing::{string_to_parser}; use util::parser_testing::{string_to_pat, string_to_crate, strs_to_idents}; use visit; diff --git a/src/libsyntax/parse/mod.rs b/src/libsyntax/parse/mod.rs index 4bd476885a0..0be7b605e57 100644 --- a/src/libsyntax/parse/mod.rs +++ b/src/libsyntax/parse/mod.rs @@ -854,7 +854,7 @@ mod test { #[test] fn string_to_tts_1 () { let tts = string_to_tts("fn a (b : i32) { b; }".to_string()); - assert_eq!(json::encode(&tts), + assert_eq!(json::encode(&tts).unwrap(), "[\ {\ \"variant\":\"TtToken\",\ diff --git a/src/libsyntax/print/pprust.rs b/src/libsyntax/print/pprust.rs index ae3c4addf38..f9a202523b5 100644 --- a/src/libsyntax/print/pprust.rs +++ b/src/libsyntax/print/pprust.rs @@ -2975,7 +2975,6 @@ mod test { use ast_util; use codemap; use parse::token; - use ptr::P; #[test] fn test_fun_to_string() { |
