diff options
Diffstat (limited to 'src/libsyntax/ext')
| -rw-r--r-- | src/libsyntax/ext/base.rs | 6 | ||||
| -rw-r--r-- | src/libsyntax/ext/build.rs | 5 | ||||
| -rw-r--r-- | src/libsyntax/ext/deriving/decodable.rs | 4 | ||||
| -rw-r--r-- | src/libsyntax/ext/deriving/default.rs | 2 | ||||
| -rw-r--r-- | src/libsyntax/ext/deriving/encodable.rs | 4 | ||||
| -rw-r--r-- | src/libsyntax/ext/deriving/generic/mod.rs | 3 | ||||
| -rw-r--r-- | src/libsyntax/ext/deriving/generic/ty.rs | 17 | ||||
| -rw-r--r-- | src/libsyntax/ext/deriving/hash.rs | 4 | ||||
| -rw-r--r-- | src/libsyntax/ext/deriving/mod.rs | 4 | ||||
| -rw-r--r-- | src/libsyntax/ext/deriving/rand.rs | 1 | ||||
| -rw-r--r-- | src/libsyntax/ext/deriving/zero.rs | 2 | ||||
| -rw-r--r-- | src/libsyntax/ext/expand.rs | 6 | ||||
| -rw-r--r-- | src/libsyntax/ext/format.rs | 16 | ||||
| -rw-r--r-- | src/libsyntax/ext/quote.rs | 4 | ||||
| -rw-r--r-- | src/libsyntax/ext/tt/macro_parser.rs | 5 |
15 files changed, 40 insertions, 43 deletions
diff --git a/src/libsyntax/ext/base.rs b/src/libsyntax/ext/base.rs index 8e69076a2c5..5134897893f 100644 --- a/src/libsyntax/ext/base.rs +++ b/src/libsyntax/ext/base.rs @@ -47,18 +47,18 @@ pub trait ItemDecorator { sp: Span, meta_item: &ast::MetaItem, item: &ast::Item, - push: |P<ast::Item>|); + push: Box<FnMut(P<ast::Item>)>); } impl<F> ItemDecorator for F - where F : Fn(&mut ExtCtxt, Span, &ast::MetaItem, &ast::Item, |P<ast::Item>|) + where F : Fn(&mut ExtCtxt, Span, &ast::MetaItem, &ast::Item, Box<FnMut(P<ast::Item>)>) { fn expand(&self, ecx: &mut ExtCtxt, sp: Span, meta_item: &ast::MetaItem, item: &ast::Item, - push: |P<ast::Item>|) { + push: Box<FnMut(P<ast::Item>)>) { (*self)(ecx, sp, meta_item, item, push) } } diff --git a/src/libsyntax/ext/build.rs b/src/libsyntax/ext/build.rs index 77165168746..239af188909 100644 --- a/src/libsyntax/ext/build.rs +++ b/src/libsyntax/ext/build.rs @@ -68,7 +68,6 @@ pub trait AstBuilder { span: Span, id: ast::Ident, bounds: OwnedSlice<ast::TyParamBound>, - unbound: Option<ast::TraitRef>, default: Option<P<ast::Ty>>) -> ast::TyParam; fn trait_ref(&self, path: ast::Path) -> ast::TraitRef; @@ -414,13 +413,11 @@ impl<'a> AstBuilder for ExtCtxt<'a> { span: Span, id: ast::Ident, bounds: OwnedSlice<ast::TyParamBound>, - unbound: Option<ast::TraitRef>, default: Option<P<ast::Ty>>) -> ast::TyParam { ast::TyParam { ident: id, id: ast::DUMMY_NODE_ID, bounds: bounds, - unbound: unbound, default: default, span: span } @@ -455,7 +452,7 @@ impl<'a> AstBuilder for ExtCtxt<'a> { } fn typarambound(&self, path: ast::Path) -> ast::TyParamBound { - ast::TraitTyParamBound(self.poly_trait_ref(path)) + ast::TraitTyParamBound(self.poly_trait_ref(path), ast::TraitBoundModifier::None) } fn lifetime(&self, span: Span, name: ast::Name) -> ast::Lifetime { diff --git a/src/libsyntax/ext/deriving/decodable.rs b/src/libsyntax/ext/deriving/decodable.rs index 57dfbc0c6e8..3c8d74c14ee 100644 --- a/src/libsyntax/ext/deriving/decodable.rs +++ b/src/libsyntax/ext/deriving/decodable.rs @@ -58,10 +58,10 @@ fn expand_deriving_decodable_imp<F>(cx: &mut ExtCtxt, additional_bounds: Vec::new(), generics: LifetimeBounds { lifetimes: Vec::new(), - bounds: vec!(("__D", None, vec!(Path::new_( + bounds: vec!(("__D", vec!(Path::new_( vec!(krate, "Decoder"), None, vec!(box Literal(Path::new_local("__E"))), true))), - ("__E", None, vec!())) + ("__E", vec!())) }, methods: vec!( MethodDef { diff --git a/src/libsyntax/ext/deriving/default.rs b/src/libsyntax/ext/deriving/default.rs index b3621490ce3..49bcb26a4c2 100644 --- a/src/libsyntax/ext/deriving/default.rs +++ b/src/libsyntax/ext/deriving/default.rs @@ -55,7 +55,7 @@ fn default_substructure(cx: &mut ExtCtxt, trait_span: Span, substr: &Substructur cx.ident_of("Default"), cx.ident_of("default") ); - let default_call = |span| cx.expr_call_global(span, default_ident.clone(), Vec::new()); + let default_call = |&: span| cx.expr_call_global(span, default_ident.clone(), Vec::new()); return match *substr.fields { StaticStruct(_, ref summary) => { diff --git a/src/libsyntax/ext/deriving/encodable.rs b/src/libsyntax/ext/deriving/encodable.rs index 8bd3df6232c..5829f34bccc 100644 --- a/src/libsyntax/ext/deriving/encodable.rs +++ b/src/libsyntax/ext/deriving/encodable.rs @@ -134,10 +134,10 @@ fn expand_deriving_encodable_imp<F>(cx: &mut ExtCtxt, additional_bounds: Vec::new(), generics: LifetimeBounds { lifetimes: Vec::new(), - bounds: vec!(("__S", None, vec!(Path::new_( + bounds: vec!(("__S", vec!(Path::new_( vec!(krate, "Encoder"), None, vec!(box Literal(Path::new_local("__E"))), true))), - ("__E", None, vec!())) + ("__E", vec!())) }, methods: vec!( MethodDef { diff --git a/src/libsyntax/ext/deriving/generic/mod.rs b/src/libsyntax/ext/deriving/generic/mod.rs index cf0201294ae..9149c20ce1b 100644 --- a/src/libsyntax/ext/deriving/generic/mod.rs +++ b/src/libsyntax/ext/deriving/generic/mod.rs @@ -417,7 +417,6 @@ impl<'a> TraitDef<'a> { cx.typaram(self.span, ty_param.ident, OwnedSlice::from_vec(bounds), - ty_param.unbound.clone(), None) })); @@ -936,7 +935,7 @@ impl<'a> MethodDef<'a> { // where each tuple has length = self_args.len() let mut match_arms: Vec<ast::Arm> = variants.iter().enumerate() .map(|(index, variant)| { - let mk_self_pat = |cx: &mut ExtCtxt, self_arg_name: &str| { + let mk_self_pat = |&: cx: &mut ExtCtxt, self_arg_name: &str| { let (p, idents) = trait_.create_enum_variant_pattern(cx, type_ident, &**variant, self_arg_name, diff --git a/src/libsyntax/ext/deriving/generic/ty.rs b/src/libsyntax/ext/deriving/generic/ty.rs index 56d11c2377f..95bdd8b9ffd 100644 --- a/src/libsyntax/ext/deriving/generic/ty.rs +++ b/src/libsyntax/ext/deriving/generic/ty.rs @@ -189,15 +189,19 @@ impl<'a> Ty<'a> { } -fn mk_ty_param(cx: &ExtCtxt, span: Span, name: &str, - bounds: &[Path], unbound: Option<ast::TraitRef>, - self_ident: Ident, self_generics: &Generics) -> ast::TyParam { +fn mk_ty_param(cx: &ExtCtxt, + span: Span, + name: &str, + bounds: &[Path], + self_ident: Ident, + self_generics: &Generics) + -> ast::TyParam { let bounds = bounds.iter().map(|b| { let path = b.to_path(cx, span, self_ident, self_generics); cx.typarambound(path) }).collect(); - cx.typaram(span, cx.ident_of(name), bounds, unbound, None) + cx.typaram(span, cx.ident_of(name), bounds, None) } fn mk_generics(lifetimes: Vec<ast::LifetimeDef>, ty_params: Vec<ast::TyParam>) @@ -216,7 +220,7 @@ fn mk_generics(lifetimes: Vec<ast::LifetimeDef>, ty_params: Vec<ast::TyParam>) #[deriving(Clone)] pub struct LifetimeBounds<'a> { pub lifetimes: Vec<(&'a str, Vec<&'a str>)>, - pub bounds: Vec<(&'a str, Option<ast::TraitRef>, Vec<Path<'a>>)>, + pub bounds: Vec<(&'a str, Vec<Path<'a>>)>, } impl<'a> LifetimeBounds<'a> { @@ -239,12 +243,11 @@ impl<'a> LifetimeBounds<'a> { }).collect(); let ty_params = self.bounds.iter().map(|t| { match t { - &(ref name, ref unbound, ref bounds) => { + &(ref name, ref bounds) => { mk_ty_param(cx, span, *name, bounds.as_slice(), - unbound.clone(), self_ty, self_generics) } diff --git a/src/libsyntax/ext/deriving/hash.rs b/src/libsyntax/ext/deriving/hash.rs index 4e59124a129..9ad0ad16217 100644 --- a/src/libsyntax/ext/deriving/hash.rs +++ b/src/libsyntax/ext/deriving/hash.rs @@ -30,7 +30,7 @@ pub fn expand_deriving_hash<F>(cx: &mut ExtCtxt, vec!(box Literal(Path::new_local("__S"))), true), LifetimeBounds { lifetimes: Vec::new(), - bounds: vec!(("__S", None, + bounds: vec!(("__S", vec!(Path::new(vec!("std", "hash", "Writer"))))), }, Path::new_local("__S")) @@ -71,7 +71,7 @@ fn hash_substructure(cx: &mut ExtCtxt, trait_span: Span, substr: &Substructure) _ => cx.span_bug(trait_span, "incorrect number of arguments in `deriving(Hash)`") }; let hash_ident = substr.method_ident; - let call_hash = |span, thing_expr| { + let call_hash = |&: span, thing_expr| { let expr = cx.expr_method_call(span, thing_expr, hash_ident, vec!(state_expr.clone())); cx.stmt_expr(expr) }; diff --git a/src/libsyntax/ext/deriving/mod.rs b/src/libsyntax/ext/deriving/mod.rs index edf29e670eb..75f763b5c38 100644 --- a/src/libsyntax/ext/deriving/mod.rs +++ b/src/libsyntax/ext/deriving/mod.rs @@ -45,7 +45,7 @@ pub fn expand_meta_deriving(cx: &mut ExtCtxt, _span: Span, mitem: &MetaItem, item: &Item, - push: |P<Item>|) { + mut push: Box<FnMut(P<Item>)>) { match mitem.node { MetaNameValue(_, ref l) => { cx.span_err(l.span, "unexpected value in `deriving`"); @@ -64,7 +64,7 @@ pub fn expand_meta_deriving(cx: &mut ExtCtxt, MetaWord(ref tname) => { macro_rules! expand(($func:path) => ($func(cx, titem.span, &**titem, item, - |i| push(i)))); + |i| push.call_mut((i,))))); match tname.get() { "Clone" => expand!(clone::expand_deriving_clone), diff --git a/src/libsyntax/ext/deriving/rand.rs b/src/libsyntax/ext/deriving/rand.rs index 4f6e4d1fb3c..1ddf5b2a5c3 100644 --- a/src/libsyntax/ext/deriving/rand.rs +++ b/src/libsyntax/ext/deriving/rand.rs @@ -36,7 +36,6 @@ pub fn expand_deriving_rand<F>(cx: &mut ExtCtxt, generics: LifetimeBounds { lifetimes: Vec::new(), bounds: vec!(("R", - None, vec!( Path::new(vec!("std", "rand", "Rng")) ))) }, explicit_self: None, diff --git a/src/libsyntax/ext/deriving/zero.rs b/src/libsyntax/ext/deriving/zero.rs index ea32549cad2..73331f06aa4 100644 --- a/src/libsyntax/ext/deriving/zero.rs +++ b/src/libsyntax/ext/deriving/zero.rs @@ -71,7 +71,7 @@ fn zero_substructure(cx: &mut ExtCtxt, trait_span: Span, substr: &Substructure) cx.ident_of("Zero"), cx.ident_of("zero") ); - let zero_call = |span| cx.expr_call_global(span, zero_ident.clone(), Vec::new()); + let zero_call = |&: span| cx.expr_call_global(span, zero_ident.clone(), Vec::new()); return match *substr.fields { StaticStruct(_, ref summary) => { diff --git a/src/libsyntax/ext/expand.rs b/src/libsyntax/ext/expand.rs index d2d624fa05e..5de7068563d 100644 --- a/src/libsyntax/ext/expand.rs +++ b/src/libsyntax/ext/expand.rs @@ -424,7 +424,7 @@ pub fn expand_item(it: P<ast::Item>, fld: &mut MacroExpander) // but that double-mut-borrows fld let mut items: SmallVector<P<ast::Item>> = SmallVector::zero(); dec.expand(fld.cx, attr.span, &*attr.node.value, &*it, - |item| items.push(item)); + box |&mut : item| items.push(item)); decorator_items.extend(items.into_iter() .flat_map(|item| expand_item(item, fld).into_iter())); @@ -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 @@ -1660,7 +1660,7 @@ mod test { assert!((shouldmatch.len() == 0) || (varrefs.len() > *shouldmatch.iter().max().unwrap())); for (idx,varref) in varrefs.iter().enumerate() { - let print_hygiene_debug_info = || { + let print_hygiene_debug_info = |&:| { // good lord, you can't make a path with 0 segments, can you? let final_varref_ident = match varref.segments.last() { Some(pathsegment) => pathsegment.identifier, 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/quote.rs b/src/libsyntax/ext/quote.rs index 4aadc78babd..e46bd7ac4bc 100644 --- a/src/libsyntax/ext/quote.rs +++ b/src/libsyntax/ext/quote.rs @@ -799,11 +799,11 @@ fn expand_parse_call(cx: &ExtCtxt, tts: &[ast::TokenTree]) -> P<ast::Expr> { let (cx_expr, tts_expr) = expand_tts(cx, sp, tts); - let cfg_call = || cx.expr_method_call( + let cfg_call = |&:| cx.expr_method_call( sp, cx.expr_ident(sp, id_ext("ext_cx")), id_ext("cfg"), Vec::new()); - let parse_sess_call = || cx.expr_method_call( + let parse_sess_call = |&:| cx.expr_method_call( sp, cx.expr_ident(sp, id_ext("ext_cx")), id_ext("parse_sess"), Vec::new()); 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![], |
