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/ext | |
| parent | 6e1879eaf1cb5e727eb134a3e27018f7535852eb (diff) | |
| download | rust-6abfac083feafc73e5d736177755cce3bfb7153f.tar.gz rust-6abfac083feafc73e5d736177755cce3bfb7153f.zip | |
Fallout from stabilization
Diffstat (limited to 'src/libsyntax/ext')
| -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 |
3 files changed, 11 insertions, 12 deletions
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![], |
