diff options
| author | Aaron Turon <aturon@mozilla.com> | 2014-12-30 10:51:18 -0800 |
|---|---|---|
| committer | Aaron Turon <aturon@mozilla.com> | 2014-12-30 17:06:08 -0800 |
| commit | 6abfac083feafc73e5d736177755cce3bfb7153f (patch) | |
| tree | d5502fab0dd68ea96057616eb20d90a2c9050218 /src/libsyntax | |
| parent | 6e1879eaf1cb5e727eb134a3e27018f7535852eb (diff) | |
| download | rust-6abfac083feafc73e5d736177755cce3bfb7153f.tar.gz rust-6abfac083feafc73e5d736177755cce3bfb7153f.zip | |
Fallout from stabilization
Diffstat (limited to 'src/libsyntax')
| -rw-r--r-- | src/libsyntax/ast_map/mod.rs | 4 | ||||
| -rw-r--r-- | src/libsyntax/ext/expand.rs | 2 | ||||
| -rw-r--r-- | src/libsyntax/ext/format.rs | 16 | ||||
| -rw-r--r-- | src/libsyntax/ext/tt/macro_parser.rs | 5 | ||||
| -rw-r--r-- | src/libsyntax/print/pp.rs | 7 | ||||
| -rw-r--r-- | src/libsyntax/std_inject.rs | 2 |
6 files changed, 18 insertions, 18 deletions
diff --git a/src/libsyntax/ast_map/mod.rs b/src/libsyntax/ast_map/mod.rs index 5a4f5731be5..b5395d09ca7 100644 --- a/src/libsyntax/ast_map/mod.rs +++ b/src/libsyntax/ast_map/mod.rs @@ -26,7 +26,7 @@ use arena::TypedArena; use std::cell::RefCell; use std::fmt; use std::io::IoResult; -use std::iter; +use std::iter::{mod, repeat}; use std::mem; use std::slice; @@ -726,7 +726,7 @@ impl<'ast> NodeCollector<'ast> { debug!("ast_map: {} => {}", id, entry); let len = self.map.len(); if id as uint >= len { - self.map.grow(id as uint - len + 1, NotPresent); + self.map.extend(repeat(NotPresent).take(id as uint - len + 1)); } self.map[id as uint] = entry; } diff --git a/src/libsyntax/ext/expand.rs b/src/libsyntax/ext/expand.rs index d2d624fa05e..9fcaf2210c1 100644 --- a/src/libsyntax/ext/expand.rs +++ b/src/libsyntax/ext/expand.rs @@ -470,7 +470,7 @@ pub fn expand_item(it: P<ast::Item>, fld: &mut MacroExpander) fn expand_item_modifiers(mut it: P<ast::Item>, fld: &mut MacroExpander) -> P<ast::Item> { // partition the attributes into ItemModifiers and others - let (modifiers, other_attrs) = it.attrs.partitioned(|attr| { + let (modifiers, other_attrs): (Vec<_>, _) = it.attrs.iter().cloned().partition(|attr| { match fld.cx.syntax_env.find(&intern(attr.name().get())) { Some(rc) => match *rc { Modifier(_) => true, _ => false }, _ => false diff --git a/src/libsyntax/ext/format.rs b/src/libsyntax/ext/format.rs index 6474d92953f..500070a14d2 100644 --- a/src/libsyntax/ext/format.rs +++ b/src/libsyntax/ext/format.rs @@ -22,6 +22,7 @@ use parse::token; use ptr::P; use std::collections::HashMap; +use std::iter::repeat; #[deriving(PartialEq)] enum ArgumentType { @@ -477,7 +478,7 @@ impl<'a, 'b> Context<'a, 'b> { /// to fn into_expr(mut self) -> P<ast::Expr> { let mut locals = Vec::new(); - let mut names = Vec::from_fn(self.name_positions.len(), |_| None); + let mut names: Vec<_> = repeat(None).take(self.name_positions.len()).collect(); let mut pats = Vec::new(); let mut heads = Vec::new(); @@ -664,7 +665,7 @@ pub fn expand_preparsed_format_args(ecx: &mut ExtCtxt, sp: Span, name_ordering: Vec<String>, names: HashMap<String, P<ast::Expr>>) -> P<ast::Expr> { - let arg_types = Vec::from_fn(args.len(), |_| None); + let arg_types: Vec<_> = range(0, args.len()).map(|_| None).collect(); let mut cx = Context { ecx: ecx, args: args, @@ -707,13 +708,10 @@ pub fn expand_preparsed_format_args(ecx: &mut ExtCtxt, sp: Span, None => break } } - match parser.errors.remove(0) { - Some(error) => { - cx.ecx.span_err(cx.fmtsp, - format!("invalid format string: {}", error)[]); - return DummyResult::raw_expr(sp); - } - None => {} + if !parser.errors.is_empty() { + cx.ecx.span_err(cx.fmtsp, format!("invalid format string: {}", + parser.errors.remove(0))[]); + return DummyResult::raw_expr(sp); } if !cx.literal.is_empty() { let s = cx.trans_literal_string(); diff --git a/src/libsyntax/ext/tt/macro_parser.rs b/src/libsyntax/ext/tt/macro_parser.rs index 73ef18b8449..65ecf701e8d 100644 --- a/src/libsyntax/ext/tt/macro_parser.rs +++ b/src/libsyntax/ext/tt/macro_parser.rs @@ -166,7 +166,7 @@ pub fn count_names(ms: &[TokenTree]) -> uint { pub fn initial_matcher_pos(ms: Rc<Vec<TokenTree>>, sep: Option<Token>, lo: BytePos) -> Box<MatcherPos> { let match_idx_hi = count_names(ms[]); - let matches = Vec::from_fn(match_idx_hi, |_i| Vec::new()); + let matches: Vec<_> = range(0, match_idx_hi).map(|_| Vec::new()).collect(); box MatcherPos { stack: vec![], top_elts: TtSeq(ms), @@ -392,7 +392,8 @@ pub fn parse(sess: &ParseSess, cur_eis.push(new_ei); } - let matches = Vec::from_elem(ei.matches.len(), Vec::new()); + let matches: Vec<_> = range(0, ei.matches.len()) + .map(|_| Vec::new()).collect(); let ei_t = ei; cur_eis.push(box MatcherPos { stack: vec![], diff --git a/src/libsyntax/print/pp.rs b/src/libsyntax/print/pp.rs index ab0e0f9585c..a15f1ca354b 100644 --- a/src/libsyntax/print/pp.rs +++ b/src/libsyntax/print/pp.rs @@ -65,6 +65,7 @@ pub use self::Token::*; use std::io; use std::string; +use std::iter::repeat; #[deriving(Clone, Copy, PartialEq)] pub enum Breaks { @@ -166,9 +167,9 @@ pub fn mk_printer(out: Box<io::Writer+'static>, linewidth: uint) -> Printer { // fall behind. let n: uint = 3 * linewidth; debug!("mk_printer {}", linewidth); - let token: Vec<Token> = Vec::from_elem(n, Eof); - let size: Vec<int> = Vec::from_elem(n, 0i); - let scan_stack: Vec<uint> = Vec::from_elem(n, 0u); + let token: Vec<Token> = repeat(Eof).take(n).collect(); + let size: Vec<int> = repeat(0i).take(n).collect(); + let scan_stack: Vec<uint> = repeat(0u).take(n).collect(); Printer { out: out, buf_len: n, diff --git a/src/libsyntax/std_inject.rs b/src/libsyntax/std_inject.rs index e1c8ff5011b..c1823231e24 100644 --- a/src/libsyntax/std_inject.rs +++ b/src/libsyntax/std_inject.rs @@ -163,7 +163,7 @@ impl<'a> fold::Folder for PreludeInjector<'a> { }), }; - let (crates, uses) = view_items.partitioned(|x| { + let (crates, uses): (Vec<_>, _) = view_items.iter().cloned().partition(|x| { match x.node { ast::ViewItemExternCrate(..) => true, _ => false, |
