diff options
| author | Brian Anderson <banderson@mozilla.com> | 2012-06-30 16:19:07 -0700 |
|---|---|---|
| committer | Brian Anderson <banderson@mozilla.com> | 2012-07-01 19:19:32 -0700 |
| commit | d1fc2b5995fdef69fe1dbdbba3703398c0aa547b (patch) | |
| tree | b6d14fd0e920512a29c64a671cc2a5bb90132abb /src/libsyntax | |
| parent | 13a8f545388929a07af110a950441e6a1b88473a (diff) | |
| download | rust-d1fc2b5995fdef69fe1dbdbba3703398c0aa547b.tar.gz rust-d1fc2b5995fdef69fe1dbdbba3703398c0aa547b.zip | |
Convert to new closure syntax
Diffstat (limited to 'src/libsyntax')
| -rw-r--r-- | src/libsyntax/ast_map.rs | 18 | ||||
| -rw-r--r-- | src/libsyntax/ast_util.rs | 50 | ||||
| -rw-r--r-- | src/libsyntax/attr.rs | 15 | ||||
| -rw-r--r-- | src/libsyntax/codemap.rs | 4 | ||||
| -rw-r--r-- | src/libsyntax/diagnostic.rs | 10 | ||||
| -rw-r--r-- | src/libsyntax/ext/auto_serialize.rs | 82 | ||||
| -rw-r--r-- | src/libsyntax/ext/build.rs | 2 | ||||
| -rw-r--r-- | src/libsyntax/ext/concat_idents.rs | 2 | ||||
| -rw-r--r-- | src/libsyntax/ext/earley_parser.rs | 12 | ||||
| -rw-r--r-- | src/libsyntax/ext/expand.rs | 12 | ||||
| -rw-r--r-- | src/libsyntax/ext/fmt.rs | 8 | ||||
| -rw-r--r-- | src/libsyntax/ext/log_syntax.rs | 2 | ||||
| -rw-r--r-- | src/libsyntax/ext/qquote.rs | 37 | ||||
| -rw-r--r-- | src/libsyntax/ext/simplext.rs | 64 | ||||
| -rw-r--r-- | src/libsyntax/ext/source_util.rs | 4 | ||||
| -rw-r--r-- | src/libsyntax/fold.rs | 50 | ||||
| -rw-r--r-- | src/libsyntax/parse.rs | 8 | ||||
| -rw-r--r-- | src/libsyntax/parse/attr.rs | 2 | ||||
| -rw-r--r-- | src/libsyntax/parse/comments.rs | 4 | ||||
| -rw-r--r-- | src/libsyntax/parse/eval.rs | 2 | ||||
| -rw-r--r-- | src/libsyntax/parse/parser.rs | 78 | ||||
| -rw-r--r-- | src/libsyntax/parse/token.rs | 8 | ||||
| -rw-r--r-- | src/libsyntax/print/pprust.rs | 68 | ||||
| -rw-r--r-- | src/libsyntax/visit.rs | 157 |
24 files changed, 345 insertions, 354 deletions
diff --git a/src/libsyntax/ast_map.rs b/src/libsyntax/ast_map.rs index f393f37dfb9..3b4fe5f91ee 100644 --- a/src/libsyntax/ast_map.rs +++ b/src/libsyntax/ast_map.rs @@ -11,7 +11,7 @@ type path = ~[path_elt]; /* FIXMEs that say "bad" are as per #2543 */ fn path_to_str_with_sep(p: path, sep: str) -> str { - let strs = do vec::map(p) {|e| + let strs = do vec::map(p) |e| { alt e { path_mod(s) { /* FIXME (#2543) */ copy *s } path_name(s) { /* FIXME (#2543) */ copy *s } @@ -119,7 +119,7 @@ fn map_decoded_item(diag: span_handler, fn map_fn(fk: visit::fn_kind, decl: fn_decl, body: blk, sp: codemap::span, id: node_id, cx: ctx, v: vt) { - for decl.inputs.each {|a| + for decl.inputs.each |a| { cx.map.insert(a.id, node_arg(/* FIXME (#2543) */ copy a, cx.local_id)); @@ -156,7 +156,7 @@ fn map_block(b: blk, cx: ctx, v: vt) { } fn number_pat(cx: ctx, pat: @pat) { - do ast_util::walk_pat(pat) {|p| + do ast_util::walk_pat(pat) |p| { alt p.node { pat_ident(_, _) { cx.map.insert(p.id, node_local(cx.local_id)); @@ -190,13 +190,13 @@ fn map_item(i: @item, cx: ctx, v: vt) { alt i.node { item_impl(_, _, _, _, ms) { let impl_did = ast_util::local_def(i.id); - for ms.each {|m| + for ms.each |m| { map_method(impl_did, extend(cx, i.ident), m, cx); } } item_enum(vs, _, _) { - for vs.each {|v| + for vs.each |v| { cx.map.insert(v.node.id, node_variant( /* FIXME (#2543) */ copy v, i, extend(cx, i.ident))); @@ -207,7 +207,7 @@ fn map_item(i: @item, cx: ctx, v: vt) { either::left(msg) { cx.diag.span_fatal(i.span, msg); } either::right(abi) { abi } }; - for nm.items.each {|nitem| + for nm.items.each |nitem| { cx.map.insert(nitem.id, node_foreign_item(nitem, abi, /* FIXME (#2543) */ @@ -218,12 +218,12 @@ fn map_item(i: @item, cx: ctx, v: vt) { let (_, ms) = ast_util::split_class_items(items); // Map iface refs to their parent classes. This is // so we can find the self_ty - do vec::iter(ifces) {|p| cx.map.insert(p.id, + do vec::iter(ifces) |p| { cx.map.insert(p.id, node_item(i, item_path)); }; let d_id = ast_util::local_def(i.id); let p = extend(cx, i.ident); // only need to handle methods - do vec::iter(ms) {|m| map_method(d_id, p, m, cx); } + do vec::iter(ms) |m| { map_method(d_id, p, m, cx); } } _ { } } @@ -240,7 +240,7 @@ fn map_item(i: @item, cx: ctx, v: vt) { fn map_view_item(vi: @view_item, cx: ctx, _v: vt) { alt vi.node { view_item_export(vps) { - for vps.each {|vp| + for vps.each |vp| { let (id, name) = alt vp.node { view_path_simple(nm, _, id) { (id, /* FIXME (#2543) */ copy nm) diff --git a/src/libsyntax/ast_util.rs b/src/libsyntax/ast_util.rs index fdb6d4dc7d9..0115ffb0331 100644 --- a/src/libsyntax/ast_util.rs +++ b/src/libsyntax/ast_util.rs @@ -25,7 +25,7 @@ pure fn path_name(p: @path) -> str { path_name_i(p.idents) } pure fn path_name_i(idents: ~[ident]) -> str { // FIXME: Bad copies (#2543 -- same for everything else that says "bad") - str::connect(idents.map({|i|*i}), "::") + str::connect(idents.map(|i|*i), "::") } pure fn path_to_ident(p: @path) -> ident { vec::last(p.idents) } @@ -152,11 +152,11 @@ pure fn float_ty_to_str(t: float_ty) -> str { fn is_exported(i: ident, m: _mod) -> bool { let mut local = false; let mut parent_enum : option<ident> = none; - for m.items.each {|it| + for m.items.each |it| { if it.ident == i { local = true; } alt it.node { item_enum(variants, _, _) { - for variants.each {|v| + for variants.each |v| { if v.node.name == i { local = true; parent_enum = some(/* FIXME (#2543) */ copy it.ident); @@ -168,11 +168,11 @@ fn is_exported(i: ident, m: _mod) -> bool { if local { break; } } let mut has_explicit_exports = false; - for m.view_items.each {|vi| + for m.view_items.each |vi| { alt vi.node { view_item_export(vps) { has_explicit_exports = true; - for vps.each {|vp| + for vps.each |vp| { alt vp.node { ast::view_path_simple(id, _, _) { if id == i { ret true; } @@ -187,7 +187,7 @@ fn is_exported(i: ident, m: _mod) -> bool { ast::view_path_list(path, ids, _) { if vec::len(path.idents) == 1u { if i == path.idents[0] { ret true; } - for ids.each {|id| + for ids.each |id| { if id.node.name == i { ret true; } } } else { @@ -288,14 +288,16 @@ type ivar = {ident: ident, ty: @ty, cm: class_mutability, id: node_id, vis: visibility}; fn public_methods(ms: ~[@method]) -> ~[@method] { - vec::filter(ms, {|m| alt m.vis { + vec::filter(ms, + |m| alt m.vis { public { true } - _ { false }}}) + _ { false } + }) } fn split_class_items(cs: ~[@class_member]) -> (~[ivar], ~[@method]) { let mut vs = ~[], ms = ~[]; - for cs.each {|c| + for cs.each |c| { alt c.node { instance_var(i, t, cm, id, vis) { vec::push(vs, {ident: /* FIXME (#2543) */ copy i, @@ -408,7 +410,7 @@ fn id_visitor(vfn: fn@(node_id)) -> visit::vt<()> { alt vi.node { view_item_use(_, _, id) { vfn(id) } view_item_import(vps) | view_item_export(vps) { - do vec::iter(vps) {|vp| + do vec::iter(vps) |vp| { alt vp.node { view_path_simple(_, _, id) { vfn(id) } view_path_glob(_, id) { vfn(id) } @@ -426,7 +428,7 @@ fn id_visitor(vfn: fn@(node_id)) -> visit::vt<()> { visit_item: fn@(i: @item) { vfn(i.id); alt i.node { - item_enum(vs, _, _) { for vs.each {|v| vfn(v.node.id); } } + item_enum(vs, _, _) { for vs.each |v| { vfn(v.node.id); } } _ {} } }, @@ -473,7 +475,7 @@ fn id_visitor(vfn: fn@(node_id)) -> visit::vt<()> { }, visit_ty_params: fn@(ps: ~[ty_param]) { - vec::iter(ps, {|p| vfn(p.id) }) + vec::iter(ps, |p| vfn(p.id)) }, visit_constr: fn@(_p: @path, _sp: span, id: node_id) { @@ -486,33 +488,33 @@ fn id_visitor(vfn: fn@(node_id)) -> visit::vt<()> { alt fk { visit::fk_ctor(nm, tps, self_id, parent_id) { - vec::iter(tps, {|tp| vfn(tp.id)}); + vec::iter(tps, |tp| vfn(tp.id)); vfn(id); vfn(self_id); vfn(parent_id.node); } visit::fk_dtor(tps, self_id, parent_id) { - vec::iter(tps, {|tp| vfn(tp.id)}); + vec::iter(tps, |tp| vfn(tp.id)); vfn(id); vfn(self_id); vfn(parent_id.node); } visit::fk_item_fn(_, tps) { - vec::iter(tps, {|tp| vfn(tp.id)}); + vec::iter(tps, |tp| vfn(tp.id)); } visit::fk_method(_, tps, m) { vfn(m.self_id); - vec::iter(tps, {|tp| vfn(tp.id)}); + vec::iter(tps, |tp| vfn(tp.id)); } visit::fk_anon(_, capture_clause) | visit::fk_fn_block(capture_clause) { - for vec::each(*capture_clause) {|clause| + for vec::each(*capture_clause) |clause| { vfn(clause.id); } } } - do vec::iter(d.inputs) {|arg| + do vec::iter(d.inputs) |arg| { vfn(arg.id) } }, @@ -536,7 +538,7 @@ fn visit_ids_for_inlined_item(item: inlined_item, vfn: fn@(node_id)) { fn compute_id_range(visit_ids_fn: fn(fn@(node_id))) -> id_range { let min = @mut int::max_value; let max = @mut int::min_value; - do visit_ids_fn { |id| + do visit_ids_fn |id| { *min = int::min(*min, id); *max = int::max(*max, id + 1); } @@ -544,7 +546,7 @@ fn compute_id_range(visit_ids_fn: fn(fn@(node_id))) -> id_range { } fn compute_id_range_for_inlined_item(item: inlined_item) -> id_range { - compute_id_range({ |f| visit_ids_for_inlined_item(item, f) }) + compute_id_range(|f| visit_ids_for_inlined_item(item, f)) } pure fn is_item_impl(item: @ast::item) -> bool { @@ -558,8 +560,12 @@ fn walk_pat(pat: @pat, it: fn(@pat)) { it(pat); alt pat.node { pat_ident(pth, some(p)) { walk_pat(p, it); } - pat_rec(fields, _) { for fields.each {|f| walk_pat(f.pat, it); } } - pat_enum(_, some(s)) | pat_tup(s) { for s.each {|p| walk_pat(p, it); } } + pat_rec(fields, _) { + for fields.each |f| { walk_pat(f.pat, it); } + } + pat_enum(_, some(s)) | pat_tup(s) { + for s.each |p| { walk_pat(p, it); } + } pat_box(s) | pat_uniq(s) { walk_pat(s, it); } pat_wild | pat_lit(_) | pat_range(_, _) | pat_ident(_, _) | pat_enum(_, _) {} diff --git a/src/libsyntax/attr.rs b/src/libsyntax/attr.rs index 08e2fd6c9b8..13aa281ffb0 100644 --- a/src/libsyntax/attr.rs +++ b/src/libsyntax/attr.rs @@ -77,7 +77,7 @@ fn attr_meta(attr: ast::attribute) -> @ast::meta_item { @attr.node.value } // Get the meta_items from inside a vector of attributes fn attr_metas(attrs: ~[ast::attribute]) -> ~[@ast::meta_item] { let mut mitems = ~[]; - for attrs.each {|a| vec::push(mitems, attr_meta(a)); } + for attrs.each |a| { vec::push(mitems, attr_meta(a)); } ret mitems; } @@ -179,7 +179,7 @@ comparison is performed structurally. fn contains(haystack: ~[@ast::meta_item], needle: @ast::meta_item) -> bool { #debug("looking for %s", print::pprust::meta_item_to_str(*needle)); - for haystack.each {|item| + for haystack.each |item| { #debug("looking in %s", print::pprust::meta_item_to_str(*item)); if eq(item, needle) { #debug("found it!"); ret true; } @@ -289,8 +289,7 @@ fn sort_meta_items(+items: ~[@ast::meta_item]) -> ~[@ast::meta_item] { fn remove_meta_items_by_name(items: ~[@ast::meta_item], name: ast::ident) -> ~[@ast::meta_item] { - ret vec::filter_map(items, { - |item| + ret vec::filter_map(items, |item| { if get_meta_item_name(item) != name { option::some(/* FIXME (#2543) */ copy item) } else { @@ -301,7 +300,7 @@ fn remove_meta_items_by_name(items: ~[@ast::meta_item], name: ast::ident) -> fn find_linkage_attrs(attrs: ~[ast::attribute]) -> ~[ast::attribute] { let mut found = ~[]; - for find_attrs_by_name(attrs, "link").each {|attr| + for find_attrs_by_name(attrs, "link").each |attr| { alt attr.node.value.node { ast::meta_list(_, _) { vec::push(found, attr) } _ { #debug("ignoring link attribute that has incorrect type"); } @@ -315,7 +314,7 @@ From a list of crate attributes get only the meta_items that impact crate linkage "] fn find_linkage_metas(attrs: ~[ast::attribute]) -> ~[@ast::meta_item] { - do find_linkage_attrs(attrs).flat_map {|attr| + do find_linkage_attrs(attrs).flat_map |attr| { alt check attr.node.value.node { ast::meta_list(_, items) { /* FIXME (#2543) */ copy items } } @@ -351,7 +350,7 @@ enum inline_attr { #[doc = "True if something like #[inline] is found in the list of attrs."] fn find_inline_attr(attrs: ~[ast::attribute]) -> inline_attr { // TODO---validate the usage of #[inline] and #[inline(always)] - do vec::foldl(ia_none, attrs) {|ia,attr| + do vec::foldl(ia_none, attrs) |ia,attr| { alt attr.node.value.node { ast::meta_word(@"inline") { ia_hint } ast::meta_list(@"inline", items) { @@ -370,7 +369,7 @@ fn find_inline_attr(attrs: ~[ast::attribute]) -> inline_attr { fn require_unique_names(diagnostic: span_handler, metas: ~[@ast::meta_item]) { let map = map::str_hash(); - for metas.each {|meta| + for metas.each |meta| { let name = get_meta_item_name(meta); // FIXME: How do I silence the warnings? --pcw (#2619) diff --git a/src/libsyntax/codemap.rs b/src/libsyntax/codemap.rs index 7bbf8f1ed07..4c30016fdc8 100644 --- a/src/libsyntax/codemap.rs +++ b/src/libsyntax/codemap.rs @@ -185,7 +185,7 @@ fn span_to_lines(sp: span, cm: codemap::codemap) -> @file_lines { let lo = lookup_char_pos(cm, sp.lo); let hi = lookup_char_pos(cm, sp.hi); let mut lines = ~[]; - for uint::range(lo.line - 1u, hi.line as uint) {|i| + for uint::range(lo.line - 1u, hi.line as uint) |i| { vec::push(lines, i); }; ret @{file: lo.file, lines: lines}; @@ -224,7 +224,7 @@ fn get_snippet(cm: codemap::codemap, fidx: uint, lo: uint, hi: uint) -> str } fn get_filemap(cm: codemap, filename: str) -> filemap { - for cm.files.each {|fm| if fm.name == filename { ret fm; } } + for cm.files.each |fm| { if fm.name == filename { ret fm; } } //XXjdm the following triggers a mismatched type bug // (or expected function, found _|_) fail; // ("asking for " + filename + " which we don't know about"); diff --git a/src/libsyntax/diagnostic.rs b/src/libsyntax/diagnostic.rs index 56017cd1f27..4e1d8f824e1 100644 --- a/src/libsyntax/diagnostic.rs +++ b/src/libsyntax/diagnostic.rs @@ -207,7 +207,7 @@ fn highlight_lines(cm: codemap::codemap, sp: span, elided = true; } // Print the offending lines - for display_lines.each {|line| + for display_lines.each |line| { io::stderr().write_str(#fmt["%s:%u ", fm.name, line + 1u]); let s = codemap::get_line(fm, line as int) + "\n"; io::stderr().write_str(s); @@ -249,11 +249,9 @@ fn highlight_lines(cm: codemap::codemap, sp: span, } fn print_macro_backtrace(cm: codemap::codemap, sp: span) { - do option::iter (sp.expn_info) {|ei| - let ss = option::map_default(ei.callie.span, @"", { - |span| - @codemap::span_to_str(span, cm) - }); + do option::iter (sp.expn_info) |ei| { + let ss = option::map_default(ei.callie.span, @"", + |span| @codemap::span_to_str(span, cm)); print_diagnostic(*ss, note, #fmt("in expansion of #%s", ei.callie.name)); let ss = codemap::span_to_str(ei.call_site, cm); diff --git a/src/libsyntax/ext/auto_serialize.rs b/src/libsyntax/ext/auto_serialize.rs index 487a435df46..d2d685f8f7d 100644 --- a/src/libsyntax/ext/auto_serialize.rs +++ b/src/libsyntax/ext/auto_serialize.rs @@ -100,7 +100,7 @@ fn expand(cx: ext_ctxt, with *item} } - do vec::flat_map(in_items) {|in_item| + do vec::flat_map(in_items) |in_item| { alt in_item.node { ast::item_ty(ty, tps, _) { vec::append(~[filter_attrs(in_item)], @@ -151,7 +151,7 @@ impl helpers for ext_ctxt { fn ty_fn(span: span, -input_tys: ~[@ast::ty], -output: @ast::ty) -> @ast::ty { - let args = do vec::map(input_tys) {|ty| + let args = do vec::map(input_tys) |ty| { {mode: ast::expl(ast::by_ref), ty: ty, ident: @"", @@ -237,12 +237,12 @@ impl helpers for ext_ctxt { fn lambda(blk: ast::blk) -> @ast::expr { let ext_cx = self; let blk_e = self.expr(blk.span, ast::expr_block(blk)); - #ast{ {|| $(blk_e) } } + #ast{ || $(blk_e) } } fn clone_folder() -> fold::ast_fold { fold::make_fold(@{ - new_id: {|_id| self.next_id()} + new_id: |_id| self.next_id() with *fold::default_ast_fold() }) } @@ -272,7 +272,7 @@ impl helpers for ext_ctxt { } let fld = fold::make_fold(@{ - new_span: {|a|repl_sp(a, ast_util::dummy_sp(), span)} + new_span: |a| repl_sp(a, ast_util::dummy_sp(), span) with *fold::default_ast_fold() }); @@ -294,11 +294,11 @@ fn ser_path(cx: ext_ctxt, tps: ser_tps_map, path: @ast::path, ast::expr_path( cx.helper_path(path, "serialize"))); - let ty_args = do vec::map(path.types) {|ty| + let ty_args = do vec::map(path.types) |ty| { let sv_stmts = ser_ty(cx, tps, ty, cx.clone(s), #ast{ __v }); let sv = cx.expr(path.span, ast::expr_block(cx.blk(path.span, sv_stmts))); - cx.at(ty.span, #ast{ {|__v| $(sv)} }) + cx.at(ty.span, #ast{ |__v| $(sv) }) }; ~[cx.stmt( @@ -316,14 +316,14 @@ fn ser_variant(cx: ext_ctxt, bodyfn: fn(-@ast::expr, ast::blk) -> @ast::expr, argfn: fn(-@ast::expr, uint, ast::blk) -> @ast::expr) -> ast::arm { - let vnames = do vec::from_fn(vec::len(tys)) {|i| + let vnames = do vec::from_fn(vec::len(tys)) |i| { @#fmt["__v%u", i] }; - let pats = do vec::from_fn(vec::len(tys)) {|i| + let pats = do vec::from_fn(vec::len(tys)) |i| { cx.binder_pat(tys[i].span, vnames[i]) }; let pat: @ast::pat = @{id: cx.next_id(), node: pfn(pats), span: span}; - let stmts = do vec::from_fn(vec::len(tys)) {|i| + let stmts = do vec::from_fn(vec::len(tys)) |i| { let v = cx.var_ref(span, vnames[i]); let arg_blk = cx.blk( @@ -376,7 +376,7 @@ fn ser_ty(cx: ext_ctxt, tps: ser_tps_map, } ast::ty_rec(flds) { - let fld_stmts = do vec::from_fn(vec::len(flds)) {|fidx| + let fld_stmts = do vec::from_fn(vec::len(flds)) |fidx| { let fld = flds[fidx]; let vf = cx.expr(fld.span, ast::expr_field(cx.clone(v), @@ -412,17 +412,17 @@ fn ser_ty(cx: ext_ctxt, tps: ser_tps_map, cx, tps, tys, ty.span, s, // Generate pattern (v1, v2, v3) - {|pats| ast::pat_tup(pats)}, + |pats| ast::pat_tup(pats), // Generate body s.emit_tup(3, {|| blk }) - {|-s, blk| + |-s, blk| { let sz = cx.lit_uint(ty.span, vec::len(tys)); let body = cx.lambda(blk); #ast{ $(s).emit_tup($(sz), $(body)) } }, // Generate s.emit_tup_elt(i, {|| blk }) - {|-s, i, blk| + |-s, i, blk| { let idx = cx.lit_uint(ty.span, i); let body = cx.lambda(blk); #ast{ $(s).emit_tup_elt($(idx), $(body)) } @@ -473,7 +473,7 @@ fn ser_ty(cx: ext_ctxt, tps: ser_tps_map, cx.at(ty.span, #ast{ __e }))))); ~[#ast(stmt){ - std::serialization::emit_from_vec($(s), $(v), {|__e| $(ser_e) }) + std::serialization::emit_from_vec($(s), $(v), |__e| $(ser_e)) }] } @@ -491,17 +491,17 @@ fn mk_ser_fn(cx: ext_ctxt, span: span, name: ast::ident, -> @ast::item { let ext_cx = cx; // required for #ast - let tp_types = vec::map(tps, {|tp| cx.ty_path(span, ~[tp.ident], ~[])}); + let tp_types = vec::map(tps, |tp| cx.ty_path(span, ~[tp.ident], ~[])); let v_ty = cx.ty_path(span, ~[name], tp_types); let tp_inputs = - vec::map(tps, {|tp| + vec::map(tps, |tp| {mode: ast::expl(ast::by_ref), ty: cx.ty_fn(span, ~[cx.ty_path(span, ~[tp.ident], ~[])], cx.ty_nil(span)), ident: @("__s" + *tp.ident), - id: cx.next_id()}}); + id: cx.next_id()}); #debug["tp_inputs = %?", tp_inputs]; @@ -518,7 +518,7 @@ fn mk_ser_fn(cx: ext_ctxt, span: span, name: ast::ident, tp_inputs); let tps_map = map::str_hash(); - do vec::iter2(tps, tp_inputs) {|tp, arg| + do vec::iter2(tps, tp_inputs) |tp, arg| { let arg_ident = arg.ident; tps_map.insert( *tp.ident, @@ -539,7 +539,7 @@ fn mk_ser_fn(cx: ext_ctxt, span: span, name: ast::ident, vec::append(~[{ident: @"__S", id: cx.next_id(), bounds: ser_bnds}], - vec::map(tps, {|tp| cx.clone_ty_param(tp) })); + vec::map(tps, |tp| cx.clone_ty_param(tp))); let ser_output: @ast::ty = @{id: cx.next_id(), node: ast::ty_nil, @@ -575,7 +575,7 @@ fn deser_path(cx: ext_ctxt, tps: deser_tps_map, path: @ast::path, ast::expr_path( cx.helper_path(path, "deserialize"))); - let ty_args = do vec::map(path.types) {|ty| + let ty_args = do vec::map(path.types) |ty| { let dv_expr = deser_ty(cx, tps, ty, cx.clone(d)); cx.lambda(cx.expr_blk(dv_expr)) }; @@ -618,7 +618,7 @@ fn deser_ty(cx: ext_ctxt, tps: deser_tps_map, } ast::ty_rec(flds) { - let fields = do vec::from_fn(vec::len(flds)) {|fidx| + let fields = do vec::from_fn(vec::len(flds)) |fidx| { let fld = flds[fidx]; let d = cx.clone(d); let f = cx.lit_str(fld.span, fld.node.ident); @@ -647,7 +647,7 @@ fn deser_ty(cx: ext_ctxt, tps: deser_tps_map, // d.read_tup_elt(2u, {||...})) // } - let arg_exprs = do vec::from_fn(vec::len(tys)) {|i| + let arg_exprs = do vec::from_fn(vec::len(tys)) |i| { let idx = cx.lit_uint(ty.span, i); let body = deser_lambda(cx, tps, tys[i], cx.clone(d)); #ast{ $(d).read_tup_elt($(idx), $(body)) } @@ -703,17 +703,17 @@ fn mk_deser_fn(cx: ext_ctxt, span: span, -> @ast::item { let ext_cx = cx; // required for #ast - let tp_types = vec::map(tps, {|tp| cx.ty_path(span, ~[tp.ident], ~[])}); + let tp_types = vec::map(tps, |tp| cx.ty_path(span, ~[tp.ident], ~[])); let v_ty = cx.ty_path(span, ~[name], tp_types); let tp_inputs = - vec::map(tps, {|tp| + vec::map(tps, |tp| {mode: ast::expl(ast::by_ref), ty: cx.ty_fn(span, ~[], cx.ty_path(span, ~[tp.ident], ~[])), ident: @("__d" + *tp.ident), - id: cx.next_id()}}); + id: cx.next_id()}); #debug["tp_inputs = %?", tp_inputs]; @@ -725,7 +725,7 @@ fn mk_deser_fn(cx: ext_ctxt, span: span, tp_inputs); let tps_map = map::str_hash(); - do vec::iter2(tps, tp_inputs) {|tp, arg| + do vec::iter2(tps, tp_inputs) |tp, arg| { let arg_ident = arg.ident; tps_map.insert( *tp.ident, @@ -745,7 +745,7 @@ fn mk_deser_fn(cx: ext_ctxt, span: span, vec::append(~[{ident: @"__D", id: cx.next_id(), bounds: deser_bnds}], - vec::map(tps, {|tp| + vec::map(tps, |tp| { let cloned = cx.clone_ty_param(tp); {bounds: @(vec::append(*cloned.bounds, ~[ast::bound_copy])) @@ -774,8 +774,8 @@ fn ty_fns(cx: ext_ctxt, name: ast::ident, let span = ty.span; ~[ - mk_ser_fn(cx, span, name, tps, {|a,b,c,d|ser_ty(a, b, ty, c, d)}), - mk_deser_fn(cx, span, name, tps, {|a,b,c|deser_ty(a, b, ty, c)}) + mk_ser_fn(cx, span, name, tps, |a,b,c,d| ser_ty(a, b, ty, c, d)), + mk_deser_fn(cx, span, name, tps, |a,b,c| deser_ty(a, b, ty, c)) ] } @@ -783,17 +783,17 @@ fn ser_enum(cx: ext_ctxt, tps: ser_tps_map, e_name: ast::ident, e_span: span, variants: ~[ast::variant], -s: @ast::expr, -v: @ast::expr) -> ~[@ast::stmt] { let ext_cx = cx; - let arms = do vec::from_fn(vec::len(variants)) {|vidx| + let arms = do vec::from_fn(vec::len(variants)) |vidx| { let variant = variants[vidx]; let v_span = variant.span; let v_name = variant.node.name; - let variant_tys = vec::map(variant.node.args, {|a| a.ty }); + let variant_tys = vec::map(variant.node.args, |a| a.ty); ser_variant( cx, tps, variant_tys, v_span, cx.clone(s), // Generate pattern var(v1, v2, v3) - {|pats| + |pats| { if vec::is_empty(pats) { ast::pat_ident(cx.path(v_span, ~[v_name]), none) } else { @@ -803,7 +803,7 @@ fn ser_enum(cx: ext_ctxt, tps: ser_tps_map, e_name: ast::ident, // Generate body s.emit_enum_variant("foo", 0u, // 3u, {|| blk }) - {|-s, blk| + |-s, blk| { let v_name = cx.lit_str(v_span, v_name); let v_id = cx.lit_uint(v_span, vidx); let sz = cx.lit_uint(v_span, vec::len(variant_tys)); @@ -815,7 +815,7 @@ fn ser_enum(cx: ext_ctxt, tps: ser_tps_map, e_name: ast::ident, }, // Generate s.emit_enum_variant_arg(i, {|| blk }) - {|-s, i, blk| + |-s, i, blk| { let idx = cx.lit_uint(v_span, i); let body = cx.lambda(blk); #ast[expr]{ @@ -832,13 +832,13 @@ fn deser_enum(cx: ext_ctxt, tps: deser_tps_map, e_name: ast::ident, e_span: span, variants: ~[ast::variant], -d: @ast::expr) -> @ast::expr { let ext_cx = cx; - let arms: ~[ast::arm] = do vec::from_fn(vec::len(variants)) {|vidx| + let arms: ~[ast::arm] = do vec::from_fn(vec::len(variants)) |vidx| { let variant = variants[vidx]; let v_span = variant.span; let v_name = variant.node.name; - let tys = vec::map(variant.node.args, {|a| a.ty }); + let tys = vec::map(variant.node.args, |a| a.ty); - let arg_exprs = do vec::from_fn(vec::len(tys)) {|i| + let arg_exprs = do vec::from_fn(vec::len(tys)) |i| { let idx = cx.lit_uint(v_span, i); let body = deser_lambda(cx, tps, tys[i], cx.clone(d)); #ast{ $(d).read_enum_variant_arg($(idx), $(body)) } @@ -866,7 +866,7 @@ fn deser_enum(cx: ext_ctxt, tps: deser_tps_map, e_name: ast::ident, let e_name = cx.lit_str(e_span, e_name); let alt_expr = cx.expr(e_span, ast::expr_alt(#ast{__i}, arms, ast::alt_check)); - let var_lambda = #ast{ {|__i| $(alt_expr)} }; + let var_lambda = #ast{ |__i| $(alt_expr) }; let read_var = #ast{ $(cx.clone(d)).read_enum_variant($(var_lambda)) }; let read_lambda = cx.lambda(cx.expr_blk(read_var)); #ast{ $(d).read_enum($(e_name), $(read_lambda)) } @@ -877,8 +877,8 @@ fn enum_fns(cx: ext_ctxt, e_name: ast::ident, e_span: span, -> ~[@ast::item] { ~[ mk_ser_fn(cx, e_span, e_name, tps, - {|a,b,c,d|ser_enum(a, b, e_name, e_span, variants, c, d)}), + |a,b,c,d| ser_enum(a, b, e_name, e_span, variants, c, d)), mk_deser_fn(cx, e_span, e_name, tps, - {|a,b,c|deser_enum(a, b, e_name, e_span, variants, c)}) + |a,b,c| deser_enum(a, b, e_name, e_span, variants, c)) ] } diff --git a/src/libsyntax/ext/build.rs b/src/libsyntax/ext/build.rs index 1621cf7db7c..872d1f5eff6 100644 --- a/src/libsyntax/ext/build.rs +++ b/src/libsyntax/ext/build.rs @@ -81,7 +81,7 @@ fn mk_rec_e(cx: ext_ctxt, sp: span, fields: ~[{ident: ast::ident, ex: @ast::expr}]) -> @ast::expr { let mut astfields: ~[ast::field] = ~[]; - for fields.each {|field| + for fields.each |field| { let ident = field.ident; let val = field.ex; let astfield = diff --git a/src/libsyntax/ext/concat_idents.rs b/src/libsyntax/ext/concat_idents.rs index e324994eeb4..a678304725d 100644 --- a/src/libsyntax/ext/concat_idents.rs +++ b/src/libsyntax/ext/concat_idents.rs @@ -4,7 +4,7 @@ fn expand_syntax_ext(cx: ext_ctxt, sp: codemap::span, arg: ast::mac_arg, _body: ast::mac_body) -> @ast::expr { let args = get_mac_args_no_max(cx,sp,arg,1u,"concat_idents"); let mut res = ""; - for args.each {|e| + for args.each |e| { res += *expr_to_ident(cx, e, "expected an ident"); } diff --git a/src/libsyntax/ext/earley_parser.rs b/src/libsyntax/ext/earley_parser.rs index 8f76e8308b9..a6e47e0941c 100644 --- a/src/libsyntax/ext/earley_parser.rs +++ b/src/libsyntax/ext/earley_parser.rs @@ -47,7 +47,7 @@ fn copy_up(&& mpu: matcher_pos_up) -> matcher_pos { } fn count_names(ms: &[matcher]) -> uint { - vec::foldl(0u, ms, {|ct, m| + vec::foldl(0u, ms, |ct, m| { ct + alt m.node { mtc_tok(_) { 0u } mtc_rep(more_ms, _, _) { count_names(more_ms) } @@ -57,7 +57,7 @@ fn count_names(ms: &[matcher]) -> uint { fn new_matcher_pos(ms: ~[matcher], sep: option<token>) -> matcher_pos { ~{elts: ms, sep: sep, mut idx: 0u, mut up: matcher_pos_up(none), - matches: copy vec::from_fn(count_names(ms), {|_i| dvec::dvec()}) } + matches: copy vec::from_fn(count_names(ms), |_i| dvec::dvec()) } } /* logically, an arb_depth should contain only one kind of nonterminal */ @@ -106,7 +106,7 @@ fn parse(sess: parse_sess, cfg: ast::crate_cfg, rdr: reader, ms: ~[matcher]) // I bet this is a perf problem: we're preemptively // doing a lot of array work that will get thrown away // most of the time. - for ei.matches.eachi() { |idx, elt| + for ei.matches.eachi() |idx, elt| { new_pos.matches[idx].push(@seq(elt.get())); } @@ -145,7 +145,7 @@ fn parse(sess: parse_sess, cfg: ast::crate_cfg, rdr: reader, ms: ~[matcher]) } let matches = vec::map(ei.matches, // fresh, same size: - {|_m| dvec::<@arb_depth>()}); + |_m| dvec::<@arb_depth>()); let ei_t <- ei; vec::push(cur_eis, ~{ elts: matchers, sep: sep, mut idx: 0u, @@ -165,7 +165,7 @@ fn parse(sess: parse_sess, cfg: ast::crate_cfg, rdr: reader, ms: ~[matcher]) /* error messages here could be improved with links to orig. rules */ if tok == EOF { if eof_eis.len() == 1u { - let ret_val = vec::map(eof_eis[0u].matches, {|dv| dv.pop()}); + let ret_val = vec::map(eof_eis[0u].matches, |dv| dv.pop()); ret ret_val; /* success */ } else if eof_eis.len() > 1u { rdr.fatal("Ambiguity: multiple successful parses"); @@ -175,7 +175,7 @@ fn parse(sess: parse_sess, cfg: ast::crate_cfg, rdr: reader, ms: ~[matcher]) } else { if (bb_eis.len() > 0u && next_eis.len() > 0u) || bb_eis.len() > 1u { - let nts = str::connect(vec::map(bb_eis, {|ei| + let nts = str::connect(vec::map(bb_eis, |ei| { alt ei.elts[ei.idx].node { mtc_bb(_,name,_) { *name } _ { fail; } } }), " or "); diff --git a/src/libsyntax/ext/expand.rs b/src/libsyntax/ext/expand.rs index 1b7abc21394..a037d87166a 100644 --- a/src/libsyntax/ext/expand.rs +++ b/src/libsyntax/ext/expand.rs @@ -100,8 +100,8 @@ fn expand_mod_items(exts: hashmap<str, syntax_extension>, cx: ext_ctxt, // For each item, look through the attributes. If any of them are // decorated with "item decorators", then use that function to transform // the item into a new set of items. - let new_items = do vec::flat_map(module.items) {|item| - do vec::foldr(item.attrs, ~[item]) {|attr, items| + let new_items = do vec::flat_map(module.items) |item| { + do vec::foldr(item.attrs, ~[item]) |attr, items| { let mname = alt attr.node.value.node { ast::meta_word(n) { n } ast::meta_name_value(n, _) { n } @@ -164,10 +164,10 @@ fn expand_crate(parse_sess: parse::parse_sess, let afp = default_ast_fold(); let cx: ext_ctxt = mk_ctxt(parse_sess, cfg); let f_pre = - @{fold_expr: {|a,b,c|expand_expr(exts, cx, a, b, c, afp.fold_expr)}, - fold_mod: {|a,b|expand_mod_items(exts, cx, a, b, afp.fold_mod)}, - fold_item: {|a,b|expand_item(cx, a, b, afp.fold_item)}, - new_span: {|a|new_span(cx, a)} + @{fold_expr: |a,b,c| expand_expr(exts, cx, a, b, c, afp.fold_expr), + fold_mod: |a,b| expand_mod_items(exts, cx, a, b, afp.fold_mod), + fold_item: |a,b| expand_item(cx, a, b, afp.fold_item), + new_span: |a|new_span(cx, a) with *afp}; let f = make_fold(f_pre); let cm = parse_expr_from_source_str("<core-macros>", diff --git a/src/libsyntax/ext/fmt.rs b/src/libsyntax/ext/fmt.rs index 197de757d3d..acf055ccabd 100644 --- a/src/libsyntax/ext/fmt.rs +++ b/src/libsyntax/ext/fmt.rs @@ -51,7 +51,7 @@ fn pieces_to_expr(cx: ext_ctxt, sp: span, fn make_rt_conv_expr(cx: ext_ctxt, sp: span, cnv: conv) -> @ast::expr { fn make_flags(cx: ext_ctxt, sp: span, flags: ~[flag]) -> @ast::expr { let mut tmp_expr = make_rt_path_expr(cx, sp, @"flag_none"); - for flags.each {|f| + for flags.each |f| { let fstr = alt f { flag_left_justify { "flag_left_justify" } flag_left_zero_pad { "flag_left_zero_pad" } @@ -136,7 +136,7 @@ fn pieces_to_expr(cx: ext_ctxt, sp: span, option::none { } _ { cx.span_unimpl(sp, unsupported); } } - for cnv.flags.each {|f| + for cnv.flags.each |f| { alt f { flag_left_justify { } flag_sign_always { @@ -191,7 +191,7 @@ fn pieces_to_expr(cx: ext_ctxt, sp: span, some(p) { log(debug, "param: " + int::to_str(p, 10u)); } _ { #debug("param: none"); } } - for c.flags.each {|f| + for c.flags.each |f| { alt f { flag_left_justify { #debug("flag: left justify"); } flag_left_zero_pad { #debug("flag: left zero pad"); } @@ -246,7 +246,7 @@ fn pieces_to_expr(cx: ext_ctxt, sp: span, let mut n = 0u; let mut piece_exprs = ~[]; let nargs = args.len(); - for pieces.each {|pc| + for pieces.each |pc| { alt pc { piece_string(s) { vec::push(piece_exprs, mk_str(cx, fmt_sp, s)); diff --git a/src/libsyntax/ext/log_syntax.rs b/src/libsyntax/ext/log_syntax.rs index cf80f7d11bd..d237cd33839 100644 --- a/src/libsyntax/ext/log_syntax.rs +++ b/src/libsyntax/ext/log_syntax.rs @@ -7,7 +7,7 @@ fn expand_syntax_ext(cx: ext_ctxt, sp: codemap::span, arg: ast::mac_arg, cx.print_backtrace(); io::stdout().write_line( str::connect(vec::map(args, - {|&&ex| print::pprust::expr_to_str(ex)}), ", ") + |&&ex| print::pprust::expr_to_str(ex)), ", ") ); //trivial expression diff --git a/src/libsyntax/ext/qquote.rs b/src/libsyntax/ext/qquote.rs index 367a0dcea50..2bb8c27828c 100644 --- a/src/libsyntax/ext/qquote.rs +++ b/src/libsyntax/ext/qquote.rs @@ -97,17 +97,15 @@ impl of qq_helper for @ast::pat { fn gather_anti_quotes<N: qq_helper>(lo: uint, node: N) -> aq_ctxt { - let v = @{visit_expr: {|node, &&cx, v| - visit_aq(node, "from_expr", cx, v)}, - visit_ty: {|node, &&cx, v| - visit_aq(node, "from_ty", cx, v)} + let v = @{visit_expr: |node, &&cx, v| visit_aq(node, "from_expr", cx, v), + visit_ty: |node, &&cx, v| visit_aq(node, "from_ty", cx, v) with *default_visitor()}; let cx = @{lo:lo, gather: dvec()}; node.visit(cx, mk_vt(v)); // FIXME (#2250): Maybe this is an overkill (merge_sort), it might // be better to just keep the gather array in sorted order. - do cx.gather.swap { |v| - vec::to_mut(std::sort::merge_sort({|a,b| a.lo < b.lo}, v)) + do cx.gather.swap |v| { + vec::to_mut(std::sort::merge_sort(|a,b| a.lo < b.lo, v)) }; ret cx; } @@ -132,7 +130,7 @@ fn expand_ast(ecx: ext_ctxt, _sp: span, -> @ast::expr { let mut what = "expr"; - do option::iter(arg) {|arg| + do option::iter(arg) |arg| { let args: ~[@ast::expr] = alt arg.node { ast::expr_vec(elts, _) { elts } @@ -193,7 +191,7 @@ fn finish<T: qq_helper> let qcx = gather_anti_quotes(sp.lo, node); let cx = qcx; - for uint::range(1u, cx.gather.len()) {|i| + for uint::range(1u, cx.gather.len()) |i| { assert cx.gather[i-1u].lo < cx.gather[i].lo; // ^^ check that the vector is sorted assert cx.gather[i-1u].hi <= cx.gather[i].lo; @@ -205,7 +203,7 @@ fn finish<T: qq_helper> let mut state = active; let mut i = 0u, j = 0u; let g_len = cx.gather.len(); - do str::chars_iter(*str) {|ch| + do str::chars_iter(*str) |ch| { if (j < g_len && i == cx.gather[j].lo) { assert ch == '$'; let repl = #fmt("$%u ", j); @@ -229,14 +227,11 @@ fn finish<T: qq_helper> let cx = ecx; - let cfg_call = {|| - mk_call_(cx, sp, mk_access(cx, sp, ~[@"ext_cx"], @"cfg"), ~[]) - }; + let cfg_call = || mk_call_( + cx, sp, mk_access(cx, sp, ~[@"ext_cx"], @"cfg"), ~[]); - let parse_sess_call = {|| - mk_call_(cx, sp, - mk_access(cx, sp, ~[@"ext_cx"], @"parse_sess"), ~[]) - }; + let parse_sess_call = || mk_call_( + cx, sp, mk_access(cx, sp, ~[@"ext_cx"], @"parse_sess"), ~[]); let pcall = mk_call(cx,sp, ~[@"syntax", @"parse", @"parser", @@ -259,7 +254,7 @@ fn finish<T: qq_helper> rcall = mk_call(cx,sp, ~[@"syntax", @"ext", @"qquote", @"replace"], ~[pcall, - mk_uniq_vec_e(cx,sp, qcx.gather.map_to_vec({|g| + mk_uniq_vec_e(cx,sp, qcx.gather.map_to_vec(|g| { mk_call(cx,sp, ~[@"syntax", @"ext", @"qquote", @g.constr], @@ -275,10 +270,10 @@ fn replace<T>(node: T, repls: ~[fragment], ff: fn (ast_fold, T) -> T) -> T { let aft = default_ast_fold(); - let f_pre = @{fold_expr: {|a,b,c|replace_expr(repls, a, b, c, - aft.fold_expr)}, - fold_ty: {|a,b,c|replace_ty(repls, a, b, c, - aft.fold_ty)} + let f_pre = @{fold_expr: |a,b,c|replace_expr(repls, a, b, c, + aft.fold_expr), + fold_ty: |a,b,c|replace_ty(repls, a, b, c, + aft.fold_ty) with *aft}; ret ff(make_fold(f_pre), node); } diff --git a/src/libsyntax/ext/simplext.rs b/src/libsyntax/ext/simplext.rs index cc3a4d04d06..2f811891711 100644 --- a/src/libsyntax/ext/simplext.rs +++ b/src/libsyntax/ext/simplext.rs @@ -74,7 +74,7 @@ fn elts_to_ell(cx: ext_ctxt, elts: ~[@expr]) -> {pre: ~[@expr], rep: option<@expr>, post: ~[@expr]} { let mut idx: uint = 0u; let mut res = none; - for elts.each {|elt| + for elts.each |elt| { alt elt.node { expr_mac(m) { alt m.node { @@ -103,7 +103,7 @@ fn elts_to_ell(cx: ext_ctxt, elts: ~[@expr]) -> fn option_flatten_map<T: copy, U: copy>(f: fn@(T) -> option<U>, v: ~[T]) -> option<~[U]> { let mut res = ~[]; - for v.each {|elem| + for v.each |elem| { alt f(elem) { none { ret none; } some(fv) { vec::push(res, fv); } } } ret some(res); @@ -113,7 +113,7 @@ fn a_d_map(ad: arb_depth<matchable>, f: selector) -> match_result { alt ad { leaf(x) { ret f(x); } seq(ads, span) { - alt option_flatten_map({|x| a_d_map(x, f)}, *ads) { + alt option_flatten_map(|x| a_d_map(x, f), *ads) { none { ret none; } some(ts) { ret some(seq(@ts, span)); } } @@ -128,7 +128,7 @@ fn compose_sels(s1: selector, s2: selector) -> selector { some(matches) { a_d_map(matches, s2) } } } - ret {|x|scomp(s1, s2, x)}; + ret { |x| scomp(s1, s2, x) }; } @@ -164,11 +164,11 @@ selectors. */ fn use_selectors_to_bind(b: binders, e: @expr) -> option<bindings> { let res = box_str_hash::<arb_depth<matchable>>(); //need to do this first, to check vec lengths. - for b.literal_ast_matchers.each {|sel| + for b.literal_ast_matchers.each |sel| { alt sel(match_expr(e)) { none { ret none; } _ { } } } let mut never_mind: bool = false; - for b.real_binders.each {|key, val| + for b.real_binders.each |key, val| { alt val(match_expr(e)) { none { never_mind = true; } some(mtc) { res.insert(key, mtc); } @@ -190,22 +190,22 @@ fn transcribe(cx: ext_ctxt, b: bindings, body: @expr) -> @expr { } let afp = default_ast_fold(); let f_pre = - @{fold_ident: {|x,y|transcribe_ident(cx, b, idx_path, x, y)}, - fold_path: {|x,y|transcribe_path(cx, b, idx_path, x, y)}, - fold_expr: {|x,y,z| + @{fold_ident: |x,y|transcribe_ident(cx, b, idx_path, x, y), + fold_path: |x,y|transcribe_path(cx, b, idx_path, x, y), + fold_expr: |x,y,z| transcribe_expr(cx, b, idx_path, x, y, z, afp.fold_expr) - }, - fold_ty: {|x,y,z| + , + fold_ty: |x,y,z| transcribe_type(cx, b, idx_path, x, y, z, afp.fold_ty) - }, - fold_block: {|x,y,z| + , + fold_block: |x,y,z| transcribe_block(cx, b, idx_path, x, y, z, afp.fold_block) - }, - map_exprs: {|x,y| + , + map_exprs: |x,y| transcribe_exprs(cx, b, idx_path, x, y) - }, - new_id: {|x|new_id(x, cx)} + , + new_id: |x|new_id(x, cx) with *afp}; let f = make_fold(f_pre); let result = f.fold_expr(body); @@ -217,7 +217,7 @@ fn transcribe(cx: ext_ctxt, b: bindings, body: @expr) -> @expr { fn follow(m: arb_depth<matchable>, idx_path: @mut ~[uint]) -> arb_depth<matchable> { let mut res: arb_depth<matchable> = m; - for vec::each(*idx_path) {|idx| + for vec::each(*idx_path) |idx| { res = alt res { leaf(_) { ret res;/* end of the line */ } seq(new_ms, _) { new_ms[idx] } @@ -255,11 +255,11 @@ fn free_vars(b: bindings, e: @expr, it: fn(ident)) { // using fold is a hack: we want visit, but it doesn't hit idents ) : // solve this with macros let f_pre = - @{fold_ident: {|x,y|mark_ident(x, y, b, idents)} + @{fold_ident: |x,y|mark_ident(x, y, b, idents) with *default_ast_fold()}; let f = make_fold(f_pre); f.fold_expr(e); // ignore result - for idents.each_key {|x| it(x); }; + for idents.each_key |x| { it(x); }; } @@ -276,7 +276,7 @@ fn transcribe_exprs(cx: ext_ctxt, b: bindings, idx_path: @mut ~[uint], let mut repeat: option<{rep_count: uint, name: ident}> = none; /* we need to walk over all the free vars in lockstep, except for the leaves, which are just duplicated */ - do free_vars(b, repeat_me) {|fv| + do free_vars(b, repeat_me) |fv| { let cur_pos = follow(b.get(fv), idx_path); alt cur_pos { leaf(_) { } @@ -481,7 +481,7 @@ fn p_t_s_rec(cx: ext_ctxt, m: matchable, s: selector, b: binders) { _ { cx.bug("broken traversal in p_t_s_r") } } } - b.literal_ast_matchers.push({|x|select(cx, x, e)}); + b.literal_ast_matchers.push(|x| select(cx, x, e)); } } } @@ -523,7 +523,7 @@ fn p_t_s_r_path(cx: ext_ctxt, p: @path, s: selector, b: binders) { if b.real_binders.contains_key(p_id) { cx.span_fatal(p.span, "duplicate binding identifier"); } - b.real_binders.insert(p_id, compose_sels(s, {|x|select(cx, x)})); + b.real_binders.insert(p_id, compose_sels(s, |x| select(cx, x))); } none { } } @@ -568,7 +568,7 @@ fn p_t_s_r_mac(cx: ext_ctxt, mac: ast::mac, s: selector, b: binders) { _ { none } } } - let final_step = {|x|select_pt_1(cx, x, select_pt_2)}; + let final_step = |x| select_pt_1(cx, x, select_pt_2); b.real_binders.insert(id, compose_sels(s, final_step)); } none { no_des(cx, pth.span, "under `#<>`"); } @@ -588,7 +588,7 @@ fn p_t_s_r_mac(cx: ext_ctxt, mac: ast::mac, s: selector, b: binders) { _ { none } } } - let final_step = {|x|select_pt_1(cx, x, select_pt_2)}; + let final_step = |x| select_pt_1(cx, x, select_pt_2); b.real_binders.insert(id, compose_sels(s, final_step)); } none { no_des(cx, blk.span, "under `#{}`"); } @@ -625,7 +625,7 @@ fn p_t_s_r_ellipses(cx: ext_ctxt, repeat_me: @expr, offset: uint, s: selector, } } p_t_s_rec(cx, match_expr(repeat_me), - compose_sels(s, {|x|select(cx, repeat_me, offset, x)}), b); + compose_sels(s, |x| select(cx, repeat_me, offset, x)), b); } @@ -649,7 +649,7 @@ fn p_t_s_r_length(cx: ext_ctxt, len: uint, at_least: bool, s: selector, } } b.literal_ast_matchers.push( - compose_sels(s, {|x|len_select(cx, x, at_least, len)})); + compose_sels(s, |x| len_select(cx, x, at_least, len))); } fn p_t_s_r_actual_vector(cx: ext_ctxt, elts: ~[@expr], _repeat_after: bool, @@ -670,7 +670,7 @@ fn p_t_s_r_actual_vector(cx: ext_ctxt, elts: ~[@expr], _repeat_after: bool, } } p_t_s_rec(cx, match_expr(elts[idx]), - compose_sels(s, {|x, copy idx|select(cx, x, idx)}), b); + compose_sels(s, |x, copy idx| select(cx, x, idx)), b); idx += 1u; } } @@ -681,7 +681,7 @@ fn add_new_extension(cx: ext_ctxt, sp: span, arg: ast::mac_arg, let mut macro_name: option<@str> = none; let mut clauses: ~[@clause] = ~[]; - for args.each {|arg| + for args.each |arg| { alt arg.node { expr_vec(elts, mutbl) { if vec::len(elts) != 2u { @@ -745,9 +745,7 @@ fn add_new_extension(cx: ext_ctxt, sp: span, arg: ast::mac_arg, } } - let ext = {|a,b,c,d, move clauses| - generic_extension(a,b,c,d,clauses) - }; + let ext = |a,b,c,d, move clauses| generic_extension(a,b,c,d,clauses); ret {ident: alt macro_name { @@ -766,7 +764,7 @@ fn add_new_extension(cx: ext_ctxt, sp: span, arg: ast::mac_arg, some(arg) { arg } none { cx.span_fatal(sp, "macro must have arguments")} }; - for clauses.each {|c| + for clauses.each |c| { alt use_selectors_to_bind(c.params, arg) { some(bindings) { ret transcribe(cx, bindings, c.body); } none { cont; } diff --git a/src/libsyntax/ext/source_util.rs b/src/libsyntax/ext/source_util.rs index 51feb53b2b3..ee5e96cc0e4 100644 --- a/src/libsyntax/ext/source_util.rs +++ b/src/libsyntax/ext/source_util.rs @@ -50,7 +50,7 @@ fn expand_mod(cx: ext_ctxt, sp: span, arg: ast::mac_arg, _body: ast::mac_body) -> @ast::expr { get_mac_args(cx, sp, arg, 0u, option::some(0u), "file"); ret mk_lit(cx, sp, ast::lit_str( - @str::connect(cx.mod_path().map({|x|*x}), "::"))); + @str::connect(cx.mod_path().map(|x|*x), "::"))); } fn expand_include(cx: ext_ctxt, sp: span, arg: ast::mac_arg, @@ -88,7 +88,7 @@ fn expand_include_bin(cx: ext_ctxt, sp: codemap::span, arg: ast::mac_arg, alt io::read_whole_file(res_rel_file(cx, sp, file)) { result::ok(src) { - let u8_exprs = vec::map(src, { |char: u8| + let u8_exprs = vec::map(src, |char: u8| { mk_lit(cx, sp, ast::lit_uint(char as u64, ast::ty_u8)) }); ret mk_uniq_vec_e(cx, sp, u8_exprs); diff --git a/src/libsyntax/fold.rs b/src/libsyntax/fold.rs index dbe09a31dd2..cbe8edb2b51 100644 --- a/src/libsyntax/fold.rs +++ b/src/libsyntax/fold.rs @@ -87,7 +87,7 @@ fn fold_meta_item_(&&mi: @meta_item, fld: ast_fold) -> @meta_item { alt mi.node { meta_word(id) { meta_word(fld.fold_ident(id)) } meta_list(id, mis) { - let fold_meta_item = {|x|fold_meta_item_(x, fld)}; + let fold_meta_item = |x|fold_meta_item_(x, fld); meta_list(/* FIXME: (#2543) */ copy id, vec::map(mis, fold_meta_item)) } @@ -131,7 +131,7 @@ fn fold_mac_(m: mac, fld: ast_fold) -> mac { } fn fold_fn_decl(decl: ast::fn_decl, fld: ast_fold) -> ast::fn_decl { - ret {inputs: vec::map(decl.inputs, {|x| fold_arg_(x, fld)}), + ret {inputs: vec::map(decl.inputs, |x| fold_arg_(x, fld) ), output: fld.fold_ty(decl.output), purity: decl.purity, cf: decl.cf, @@ -148,16 +148,16 @@ fn fold_ty_param_bound(tpb: ty_param_bound, fld: ast_fold) -> ty_param_bound { fn fold_ty_param(tp: ty_param, fld: ast_fold) -> ty_param { {ident: /* FIXME (#2543) */ copy tp.ident, id: fld.new_id(tp.id), - bounds: @vec::map(*tp.bounds, {|x|fold_ty_param_bound(x, fld)})} + bounds: @vec::map(*tp.bounds, |x| fold_ty_param_bound(x, fld) )} } fn fold_ty_params(tps: ~[ty_param], fld: ast_fold) -> ~[ty_param] { - vec::map(tps, {|x|fold_ty_param(x, fld)}) + vec::map(tps, |x| fold_ty_param(x, fld) ) } fn noop_fold_crate(c: crate_, fld: ast_fold) -> crate_ { - let fold_meta_item = {|x|fold_meta_item_(x, fld)}; - let fold_attribute = {|x|fold_attribute_(x, fld)}; + let fold_meta_item = |x| fold_meta_item_(x, fld); + let fold_attribute = |x| fold_attribute_(x, fld); ret {directives: vec::map(c.directives, fld.fold_crate_directive), module: fld.fold_mod(c.module), @@ -188,8 +188,8 @@ fn noop_fold_view_item(vi: view_item_, _fld: ast_fold) -> view_item_ { fn noop_fold_foreign_item(&&ni: @foreign_item, fld: ast_fold) -> @foreign_item { - let fold_arg = {|x|fold_arg_(x, fld)}; - let fold_attribute = {|x|fold_attribute_(x, fld)}; + let fold_arg = |x| fold_arg_(x, fld); + let fold_attribute = |x| fold_attribute_(x, fld); ret @{ident: fld.fold_ident(ni.ident), attrs: vec::map(ni.attrs, fold_attribute), @@ -211,7 +211,7 @@ fn noop_fold_foreign_item(&&ni: @foreign_item, fld: ast_fold) } fn noop_fold_item(&&i: @item, fld: ast_fold) -> @item { - let fold_attribute = {|x|fold_attribute_(x, fld)}; + let fold_attribute = |x| fold_attribute_(x, fld); ret @{ident: fld.fold_ident(i.ident), attrs: vec::map(i.attrs, fold_attribute), @@ -255,7 +255,7 @@ fn noop_fold_item_underscore(i: item_, fld: ast_fold) -> item_ { let ctor_body = fld.fold_block(ctor.node.body); let ctor_decl = fold_fn_decl(ctor.node.dec, fld); let ctor_id = fld.new_id(ctor.node.id); - let dtor = do option::map(m_dtor) {|dtor| + let dtor = do option::map(m_dtor) |dtor| { let dtor_body = fld.fold_block(dtor.node.body); let dtor_id = fld.new_id(dtor.node.id); {node: {body: dtor_body, @@ -263,7 +263,7 @@ fn noop_fold_item_underscore(i: item_, fld: ast_fold) -> item_ { with dtor}}; item_class( /* FIXME (#2543) */ copy typms, - vec::map(ifaces, {|p| fold_iface_ref(p, fld) }), + vec::map(ifaces, |p| fold_iface_ref(p, fld)), vec::map(items, fld.fold_class_item), {node: {body: ctor_body, dec: ctor_decl, @@ -273,7 +273,7 @@ fn noop_fold_item_underscore(i: item_, fld: ast_fold) -> item_ { item_impl(tps, rp, ifce, ty, methods) { item_impl(fold_ty_params(tps, fld), rp, - ifce.map({ |p| fold_iface_ref(p, fld) }), + ifce.map(|p| fold_iface_ref(p, fld)), fld.fold_ty(ty), vec::map(methods, fld.fold_method)) } @@ -333,11 +333,11 @@ fn noop_fold_pat(p: pat_, fld: ast_fold) -> pat_ { pat_lit(e) { pat_lit(fld.fold_expr(e)) } pat_enum(pth, pats) { pat_enum(fld.fold_path(pth), option::map(pats, - {|pats| vec::map(pats, fld.fold_pat)})) + |pats| vec::map(pats, fld.fold_pat))) } pat_rec(fields, etc) { let mut fs = ~[]; - for fields.each {|f| + for fields.each |f| { vec::push(fs, {ident: /* FIXME (#2543) */ copy f.ident, pat: fld.fold_pat(f.pat)}); @@ -376,9 +376,9 @@ fn noop_fold_expr(e: expr_, fld: ast_fold) -> expr_ { expr: fld.fold_expr(field.node.expr)}, span: fld.new_span(field.span)}; } - let fold_field = {|x|fold_field_(x, fld)}; + let fold_field = |x| fold_field_(x, fld); - let fold_mac = {|x|fold_mac_(x, fld)}; + let fold_mac = |x| fold_mac_(x, fld); ret alt e { expr_new(p, i, v) { @@ -426,13 +426,13 @@ fn noop_fold_expr(e: expr_, fld: ast_fold) -> expr_ { expr_fn(proto, decl, body, captures) { expr_fn(proto, fold_fn_decl(decl, fld), fld.fold_block(body), - @((*captures).map({|cap_item| + @((*captures).map(|cap_item| { @({id: fld.new_id((*cap_item).id) with *cap_item})}))) } expr_fn_block(decl, body, captures) { expr_fn_block(fold_fn_decl(decl, fld), fld.fold_block(body), - @((*captures).map({|cap_item| + @((*captures).map(|cap_item| { @({id: fld.new_id((*cap_item).id) with *cap_item})}))) } @@ -474,7 +474,7 @@ fn noop_fold_expr(e: expr_, fld: ast_fold) -> expr_ { } fn noop_fold_ty(t: ty_, fld: ast_fold) -> ty_ { - let fold_mac = {|x|fold_mac_(x, fld)}; + let fold_mac = |x| fold_mac_(x, fld); fn fold_mt(mt: mt, fld: ast_fold) -> mt { {ty: fld.fold_ty(mt.ty), mutbl: mt.mutbl} } @@ -490,9 +490,9 @@ fn noop_fold_ty(t: ty_, fld: ast_fold) -> ty_ { ty_vec(mt) {ty_vec(fold_mt(mt, fld))} ty_ptr(mt) {ty_ptr(fold_mt(mt, fld))} ty_rptr(region, mt) {ty_rptr(region, fold_mt(mt, fld))} - ty_rec(fields) {ty_rec(vec::map(fields, {|f| fold_field(f, fld)}))} + ty_rec(fields) {ty_rec(vec::map(fields, |f| fold_field(f, fld)))} ty_fn(proto, decl) {ty_fn(proto, fold_fn_decl(decl, fld))} - ty_tup(tys) {ty_tup(vec::map(tys, {|ty| fld.fold_ty(ty)}))} + ty_tup(tys) {ty_tup(vec::map(tys, |ty| fld.fold_ty(ty)))} ty_path(path, id) {ty_path(fld.fold_path(path), fld.new_id(id))} ty_constr(ty, constrs) {ty_constr(fld.fold_ty(ty), vec::map(constrs, fld.fold_ty_constr))} @@ -527,10 +527,10 @@ fn noop_fold_variant(v: variant_, fld: ast_fold) -> variant_ { fn fold_variant_arg_(va: variant_arg, fld: ast_fold) -> variant_arg { ret {ty: fld.fold_ty(va.ty), id: fld.new_id(va.id)}; } - let fold_variant_arg = {|x|fold_variant_arg_(x, fld)}; + let fold_variant_arg = |x| fold_variant_arg_(x, fld); let args = vec::map(v.args, fold_variant_arg); - let fold_attribute = {|x|fold_attribute_(x, fld)}; + let fold_attribute = |x| fold_attribute_(x, fld); let attrs = vec::map(v.attrs, fold_attribute); let de = alt v.disr_expr { @@ -624,8 +624,8 @@ impl of ast_fold for ast_fold_precursor { fn fold_view_item(&&x: @view_item) -> @view_item { ret @{node: self.fold_view_item(x.node, self as ast_fold), - attrs: vec::map(x.attrs, {|a| - fold_attribute_(a, self as ast_fold)}), + attrs: vec::map(x.attrs, |a| + fold_attribute_(a, self as ast_fold)), vis: x.vis, span: self.new_span(x.span)}; } diff --git a/src/libsyntax/parse.rs b/src/libsyntax/parse.rs index a64a373eba7..bf9a7dd2ace 100644 --- a/src/libsyntax/parse.rs +++ b/src/libsyntax/parse.rs @@ -37,8 +37,8 @@ fn new_parse_sess(demitter: option<emitter>) -> parse_sess { ret @{cm: cm, mut next_id: 1, span_diagnostic: mk_span_handler(mk_handler(demitter), cm), - interner: @interner::mk::<@str>({|x|str::hash(*x)}, - {|x,y|str::eq(*x, *y)}), + interner: @interner::mk::<@str>(|x| str::hash(*x), + |x,y| str::eq(*x, *y)), mut chpos: 0u, mut byte_pos: 0u}; } @@ -47,8 +47,8 @@ fn new_parse_sess_special_handler(sh: span_handler, cm: codemap::codemap) ret @{cm: cm, mut next_id: 1, span_diagnostic: sh, - interner: @interner::mk::<@str>({|x|str::hash(*x)}, - {|x,y|str::eq(*x, *y)}), + interner: @interner::mk::<@str>(|x| str::hash(*x), + |x,y| str::eq(*x, *y)), mut chpos: 0u, mut byte_pos: 0u}; } diff --git a/src/libsyntax/parse/attr.rs b/src/libsyntax/parse/attr.rs index e38fc8a0e54..13c72d1e315 100644 --- a/src/libsyntax/parse/attr.rs +++ b/src/libsyntax/parse/attr.rs @@ -114,7 +114,7 @@ impl parser_attr for parser { fn parse_meta_seq() -> ~[@ast::meta_item] { ret self.parse_seq(token::LPAREN, token::RPAREN, seq_sep_trailing_disallowed(token::COMMA), - {|p| p.parse_meta_item()}).node; + |p| p.parse_meta_item()).node; } fn parse_optional_meta() -> ~[@ast::meta_item] { diff --git a/src/libsyntax/parse/comments.rs b/src/libsyntax/parse/comments.rs index 638e66995ba..3fbb16b5574 100644 --- a/src/libsyntax/parse/comments.rs +++ b/src/libsyntax/parse/comments.rs @@ -173,8 +173,8 @@ fn gather_comments_and_literals(span_diagnostic: diagnostic::span_handler, {cmnts: ~[cmnt], lits: ~[lit]} { let src = @str::from_bytes(srdr.read_whole_stream()); let itr = @interner::mk::<@str>( - {|x|str::hash(*x)}, - {|x,y|str::eq(*x, *y)} + |x| str::hash(*x), + |x,y| str::eq(*x, *y) ); let rdr = lexer::new_low_level_string_reader (span_diagnostic, codemap::new_filemap(path, src, 0u, 0u), itr); diff --git a/src/libsyntax/parse/eval.rs b/src/libsyntax/parse/eval.rs index 66cfa7b1855..883aedb75a6 100644 --- a/src/libsyntax/parse/eval.rs +++ b/src/libsyntax/parse/eval.rs @@ -12,7 +12,7 @@ fn eval_crate_directives(cx: ctx, prefix: str, &view_items: ~[@ast::view_item], &items: ~[@ast::item]) { - for cdirs.each {|sub_cdir| + for cdirs.each |sub_cdir| { eval_crate_directive(cx, sub_cdir, prefix, view_items, items); } } diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index 55058d337e9..e42ba7fe187 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -162,7 +162,7 @@ class parser { fn parse_ty_fn_decl(purity: ast::purity) -> fn_decl { let inputs = do self.parse_unspanned_seq( token::LPAREN, token::RPAREN, - seq_sep_trailing_disallowed(token::COMMA)) { |p| + seq_sep_trailing_disallowed(token::COMMA)) |p| { let mode = p.parse_arg_mode(); let name = if is_plain_ident(p.token) && p.look_ahead(1u) == token::COLON { @@ -188,7 +188,7 @@ class parser { fn parse_ty_methods() -> ~[ty_method] { do self.parse_unspanned_seq(token::LBRACE, token::RBRACE, - seq_sep_none()) { |p| + seq_sep_none()) |p| { let attrs = p.parse_outer_attributes(); let flo = p.span.lo; let pur = p.parse_fn_purity(); @@ -220,7 +220,7 @@ class parser { // otherwise, fail fn ident_index(args: ~[arg], i: ident) -> uint { let mut j = 0u; - for args.each {|a| if a.ident == i { ret j; } j += 1u; } + for args.each |a| { if a.ident == i { ret j; } j += 1u; } self.fatal("unbound variable `" + *i + "` in constraint arg"); } @@ -256,7 +256,7 @@ class parser { let args = self.parse_unspanned_seq( token::LPAREN, token::RPAREN, seq_sep_trailing_disallowed(token::COMMA), - {|p| p.parse_constr_arg(fn_args)}); + |p| p.parse_constr_arg(fn_args)); ret @spanned(lo, self.span.hi, {path: path, args: args, id: self.get_id()}); } @@ -267,7 +267,7 @@ class parser { let args: ~[@ty_constr_arg] = self.parse_unspanned_seq( token::LPAREN, token::RPAREN, seq_sep_trailing_disallowed(token::COMMA), - {|p| p.parse_type_constr_arg()}); + |p| p.parse_type_constr_arg()); let hi = self.span.lo; let tc: ty_constr_ = {path: path, args: args, id: self.get_id()}; ret @spanned(lo, hi, tc); @@ -286,7 +286,7 @@ class parser { } fn parse_type_constraints() -> ~[@ty_constr] { - ret self.parse_constrs({|p| p.parse_constr_in_type()}); + ret self.parse_constrs(|p| p.parse_constr_in_type()); } fn parse_ret_ty() -> (ret_style, @ty) { @@ -397,7 +397,7 @@ class parser { let elems = self.parse_unspanned_seq( token::LBRACE, token::RBRACE, seq_sep_trailing_allowed(token::COMMA), - {|p| p.parse_ty_field()}); + |p| p.parse_ty_field()); if vec::len(elems) == 0u { self.unexpected_last(token::RBRACE); } @@ -495,11 +495,11 @@ class parser { } fn parse_arg_or_capture_item() -> arg_or_capture_item { - self.parse_capture_item_or({|p| p.parse_arg() }) + self.parse_capture_item_or(|p| p.parse_arg()) } fn parse_fn_block_arg() -> arg_or_capture_item { - do self.parse_capture_item_or {|p| + do self.parse_capture_item_or |p| { let m = p.parse_arg_mode(); let i = p.parse_value_ident(); let t = if p.eat(token::COLON) { @@ -594,8 +594,8 @@ class parser { } fn parse_path_without_tps() -> @path { - self.parse_path_without_tps_({|p| p.parse_ident()}, - {|p| p.parse_ident()}) + self.parse_path_without_tps_(|p| p.parse_ident(), + |p| p.parse_ident()) } fn parse_path_without_tps_( @@ -623,8 +623,8 @@ class parser { } fn parse_value_path() -> @path { - self.parse_path_without_tps_({|p| p.parse_ident()}, - {|p| p.parse_value_ident()}) + self.parse_path_without_tps_(|p| p.parse_ident(), + |p| p.parse_value_ident()) } fn parse_path_with_tps(colons: bool) -> @path { @@ -658,7 +658,7 @@ class parser { let tps = { if self.token == token::LT { self.parse_seq_lt_gt(some(token::COMMA), - {|p| p.parse_ty(false)}) + |p| p.parse_ty(false)) } else { {node: ~[], span: path.span} } @@ -820,7 +820,7 @@ class parser { let mutbl = self.parse_mutability(); let es = self.parse_seq_to_end( token::RBRACKET, seq_sep_trailing_allowed(token::COMMA), - {|p| p.parse_expr()}); + |p| p.parse_expr()); hi = self.span.hi; ex = expr_vec(es, mutbl); } else if self.token == token::POUND @@ -968,10 +968,10 @@ class parser { let es = if self.token == token::LPAREN { self.parse_unspanned_seq(token::LPAREN, token::RPAREN, - sep, {|p| p.parse_expr()}) + sep, |p| p.parse_expr()) } else { self.parse_unspanned_seq(token::LBRACKET, token::RBRACKET, - sep, {|p| p.parse_expr()}) + sep, |p| p.parse_expr()) }; let hi = self.span.hi; e = some(self.mk_expr(lo, hi, expr_vec(es, m_imm))); @@ -1019,7 +1019,7 @@ class parser { let tys = if self.eat(token::MOD_SEP) { self.expect(token::LT); self.parse_seq_to_gt(some(token::COMMA), - {|p| p.parse_ty(false)}) + |p| p.parse_ty(false)) } else { ~[] }; e = self.mk_pexpr(lo, hi, expr_field(self.to_expr(e), self.get_str(i), @@ -1036,7 +1036,7 @@ class parser { let es = self.parse_unspanned_seq( token::LPAREN, token::RPAREN, seq_sep_trailing_disallowed(token::COMMA), - {|p| p.parse_expr()}); + |p| p.parse_expr()); hi = self.span.hi; let nd = expr_call(self.to_expr(e), es, false); @@ -1095,7 +1095,7 @@ class parser { vec::append( self.parse_seq_to_before_end( ket, seq_sep_none(), - {|p| p.parse_token_tree()}), + |p| p.parse_token_tree()), ~[parse_tt_flat(self, true)]))) } _ { parse_tt_flat(self, false) } @@ -1106,7 +1106,7 @@ class parser { fn parse_tt_mac_demo() -> @expr { let ms = self.parse_seq(token::LBRACE, token::RBRACE, common::seq_sep_none(), - {|p| p.parse_matcher(@mut 0u)}).node; + |p| p.parse_matcher(@mut 0u)).node; let tt = self.parse_token_tree(); alt tt { tt_delim(tts) { @@ -1131,7 +1131,7 @@ class parser { self.bump(); let ms = (self.parse_seq(token::LPAREN, token::RPAREN, common::seq_sep_none(), - {|p| p.parse_matcher(name_idx)}).node); + |p| p.parse_matcher(name_idx)).node); if ms.len() == 0u { self.fatal("repetition body must be nonempty"); } @@ -1350,7 +1350,7 @@ class parser { // the future, just have to change parse_arg to parse_fn_block_arg. let (decl, capture_clause) = self.parse_fn_decl(impure_fn, - {|p| p.parse_arg_or_capture_item()}); + |p| p.parse_arg_or_capture_item()); let body = self.parse_block(); ret self.mk_expr(lo, body.span.hi, @@ -1367,7 +1367,7 @@ class parser { // `|args| { ... }` like in `do` expressions fn parse_lambda_block_expr() -> @expr { - self.parse_lambda_expr_({|| + self.parse_lambda_expr_(|| { let blk = self.parse_block(); self.mk_expr(blk.span.lo, blk.span.hi, expr_block(blk)) }) @@ -1375,7 +1375,7 @@ class parser { // `|args| expr` fn parse_lambda_expr() -> @expr { - self.parse_lambda_expr_({|| self.parse_expr()}) + self.parse_lambda_expr_(|| self.parse_expr()) } fn parse_lambda_expr_(parse_body: fn&() -> @expr) -> @expr { @@ -1645,7 +1645,7 @@ class parser { args = self.parse_unspanned_seq( token::LPAREN, token::RPAREN, seq_sep_trailing_disallowed(token::COMMA), - {|p| p.parse_pat()}); + |p| p.parse_pat()); hi = self.span.hi; } } @@ -1891,7 +1891,7 @@ class parser { fn parse_ty_params() -> ~[ty_param] { if self.eat(token::LT) { - self.parse_seq_to_gt(some(token::COMMA), {|p| p.parse_ty_param()}) + self.parse_seq_to_gt(some(token::COMMA), |p| p.parse_ty_param()) } else { ~[] } } @@ -1913,7 +1913,7 @@ class parser { let mut constrs = ~[]; if self.token == token::COLON { self.bump(); - constrs = self.parse_constrs({|p| p.parse_ty_constr(inputs) }); + constrs = self.parse_constrs(|p| p.parse_ty_constr(inputs)); } let (ret_style, ret_ty) = self.parse_ret_ty(); ret ({inputs: inputs, @@ -1931,7 +1931,7 @@ class parser { self.parse_unspanned_seq( token::BINOP(token::OR), token::BINOP(token::OR), seq_sep_trailing_disallowed(token::COMMA), - {|p| p.parse_fn_block_arg()}) + |p| p.parse_fn_block_arg()) } }; let output = if self.eat(token::RARROW) { @@ -1966,7 +1966,7 @@ class parser { fn parse_item_fn(purity: purity) -> item_info { let t = self.parse_fn_header(); - let (decl, _) = self.parse_fn_decl(purity, {|p| p.parse_arg()}); + let (decl, _) = self.parse_fn_decl(purity, |p| p.parse_arg()); let (inner_attrs, body) = self.parse_inner_attrs_and_block(true); (t.ident, item_fn(decl, t.tps, body), some(inner_attrs)) } @@ -1991,7 +1991,7 @@ class parser { let lo = self.span.lo, pur = self.parse_fn_purity(); let ident = self.parse_method_name(); let tps = self.parse_ty_params(); - let (decl, _) = self.parse_fn_decl(pur, {|p| p.parse_arg()}); + let (decl, _) = self.parse_fn_decl(pur, |p| p.parse_arg()); let (inner_attrs, body) = self.parse_inner_attrs_and_block(true); let attrs = vec::append(attrs, inner_attrs); @{ident: ident, attrs: attrs, tps: tps, decl: decl, body: body, @@ -2066,7 +2066,7 @@ class parser { @{span: s, global: false, idents: ~[i], rp: a_r, - types: vec::map(typarams, {|tp| + types: vec::map(typarams, |tp| { @{id: self.get_id(), node: ty_path(ident_to_path(s, tp.ident), self.get_id()), span: s}}) @@ -2081,7 +2081,7 @@ class parser { fn parse_iface_ref_list() -> ~[@iface_ref] { self.parse_seq_to_before_end( token::LBRACE, seq_sep_trailing_disallowed(token::COMMA), - {|p| p.parse_iface_ref()}) + |p| p.parse_iface_ref()) } fn parse_item_class() -> item_info { @@ -2108,7 +2108,7 @@ class parser { members(mms) { ms = vec::append(ms, mms); } } } - let actual_dtor = do option::map(the_dtor) {|dtor| + let actual_dtor = do option::map(the_dtor) |dtor| { let (d_body, d_s) = dtor; {node: {id: self.get_id(), self_id: self.get_id(), @@ -2151,7 +2151,7 @@ class parser { fn parse_ctor(result_ty: ast::ty_) -> class_contents { // FIXME (#2660): Can ctors/dtors have attrs? let lo = self.last_span.lo; - let (decl_, _) = self.parse_fn_decl(impure_fn, {|p| p.parse_arg()}); + let (decl_, _) = self.parse_fn_decl(impure_fn, |p| p.parse_arg()); let decl = {output: @{id: self.get_id(), node: result_ty, span: decl_.output.span} with decl_}; @@ -2253,7 +2253,7 @@ class parser { purity: purity) -> @foreign_item { let lo = self.last_span.lo; let t = self.parse_fn_header(); - let (decl, _) = self.parse_fn_decl(purity, {|p| p.parse_arg()}); + let (decl, _) = self.parse_fn_decl(purity, |p| p.parse_arg()); let mut hi = self.span.hi; self.expect(token::SEMI); ret @{ident: t.ident, @@ -2368,8 +2368,8 @@ class parser { let arg_tys = self.parse_unspanned_seq( token::LPAREN, token::RPAREN, seq_sep_trailing_disallowed(token::COMMA), - {|p| p.parse_ty(false)}); - for arg_tys.each {|ty| + |p| p.parse_ty(false)); + for arg_tys.each |ty| { vec::push(args, {ty: ty, id: self.get_id()}); } } else if self.eat(token::EQ) { @@ -2515,7 +2515,7 @@ class parser { let idents = self.parse_unspanned_seq( token::LBRACE, token::RBRACE, seq_sep_trailing_allowed(token::COMMA), - {|p| p.parse_path_list_ident()}); + |p| p.parse_path_list_ident()); let path = @{span: mk_sp(lo, self.span.hi), global: false, idents: path, rp: none, types: ~[]}; diff --git a/src/libsyntax/parse/token.rs b/src/libsyntax/parse/token.rs index 9ab2fc5014c..a5d119d8986 100644 --- a/src/libsyntax/parse/token.rs +++ b/src/libsyntax/parse/token.rs @@ -238,10 +238,10 @@ in positions that might otherwise contain _value identifiers_. "] fn keyword_table() -> hashmap<str, ()> { let keywords = str_hash(); - for contextual_keyword_table().each_key {|word| + for contextual_keyword_table().each_key |word| { keywords.insert(word, ()); } - for restricted_keyword_table().each_key {|word| + for restricted_keyword_table().each_key |word| { keywords.insert(word, ()); } keywords @@ -263,7 +263,7 @@ fn contextual_keyword_table() -> hashmap<str, ()> { /* temp */ "sep", "many", "at_least_one", "parse" ]; - for keys.each {|word| + for keys.each |word| { words.insert(word, ()); } words @@ -301,7 +301,7 @@ fn restricted_keyword_table() -> hashmap<str, ()> { "unchecked", "unsafe", "while" ]; - for keys.each {|word| + for keys.each |word| { words.insert(word, ()); } words diff --git a/src/libsyntax/print/pprust.rs b/src/libsyntax/print/pprust.rs index d085546f621..05e959c3321 100644 --- a/src/libsyntax/print/pprust.rs +++ b/src/libsyntax/print/pprust.rs @@ -105,7 +105,7 @@ fn typarams_to_str(tps: ~[ast::ty_param]) -> str { } fn path_to_str(&&p: @ast::path) -> str { - ret to_str(p, {|a,b|print_path(a, b, false)}); + ret to_str(p, |a,b| print_path(a, b, false)); } fn fun_to_str(decl: ast::fn_decl, name: ast::ident, @@ -260,7 +260,7 @@ fn synth_comment(s: ps, text: str) { fn commasep<IN>(s: ps, b: breaks, elts: ~[IN], op: fn(ps, IN)) { box(s, 0u, b); let mut first = true; - for elts.each {|elt| + for elts.each |elt| { if first { first = false; } else { word_space(s, ","); } op(s, elt); } @@ -273,7 +273,7 @@ fn commasep_cmnt<IN>(s: ps, b: breaks, elts: ~[IN], op: fn(ps, IN), box(s, 0u, b); let len = vec::len::<IN>(elts); let mut i = 0u; - for elts.each {|elt| + for elts.each |elt| { maybe_print_comment(s, get_span(elt).hi); op(s, elt); i += 1u; @@ -294,19 +294,19 @@ fn commasep_exprs(s: ps, b: breaks, exprs: ~[@ast::expr]) { fn print_mod(s: ps, _mod: ast::_mod, attrs: ~[ast::attribute]) { print_inner_attributes(s, attrs); - for _mod.view_items.each {|vitem| + for _mod.view_items.each |vitem| { print_view_item(s, vitem); } - for _mod.items.each {|item| print_item(s, item); } + for _mod.items.each |item| { print_item(s, item); } } fn print_foreign_mod(s: ps, nmod: ast::foreign_mod, attrs: ~[ast::attribute]) { print_inner_attributes(s, attrs); - for nmod.view_items.each {|vitem| + for nmod.view_items.each |vitem| { print_view_item(s, vitem); } - for nmod.items.each {|item| print_foreign_item(s, item); } + for nmod.items.each |item| { print_foreign_item(s, item); } } fn print_region(s: ps, region: @ast::region) { @@ -481,7 +481,7 @@ fn print_item(s: ps, &&item: @ast::item) { end(s); } else { bopen(s); - for variants.each {|v| + for variants.each |v| { space_if_not_bol(s); maybe_print_comment(s, v.span.lo); print_outer_attributes(s, v.node.attrs); @@ -501,8 +501,8 @@ fn print_item(s: ps, &&item: @ast::item) { print_type_params(s, tps); if vec::len(ifaces) != 0u { word_space(s, ":"); - commasep(s, inconsistent, ifaces, {|s, p| - print_path(s, p.path, false)}); + commasep(s, inconsistent, ifaces, |s, p| + print_path(s, p.path, false)); } bopen(s); hardbreak_if_not_bol(s); @@ -511,13 +511,13 @@ fn print_item(s: ps, &&item: @ast::item) { print_fn_args_and_ret(s, ctor.node.dec, ~[]); space(s.s); print_block(s, ctor.node.body); - do option::iter(m_dtor) {|dtor| + do option::iter(m_dtor) |dtor| { hardbreak_if_not_bol(s); maybe_print_comment(s, dtor.span.lo); head(s, "drop"); print_block(s, dtor.node.body); } - for items.each {|ci| + for items.each |ci| { /* FIXME (#1893): collect all private items and print them in a single "priv" section @@ -565,7 +565,7 @@ fn print_item(s: ps, &&item: @ast::item) { print_region_param(s, rp); print_type_params(s, tps); space(s.s); - option::iter(ifce, {|p| + option::iter(ifce, |p| { word_nbsp(s, "of"); print_path(s, p.path, false); space(s.s); @@ -574,7 +574,7 @@ fn print_item(s: ps, &&item: @ast::item) { print_type(s, ty); space(s.s); bopen(s); - for methods.each {|meth| + for methods.each |meth| { print_method(s, meth); } bclose(s, item.span); @@ -586,7 +586,7 @@ fn print_item(s: ps, &&item: @ast::item) { print_type_params(s, tps); word(s.s, " "); bopen(s); - for methods.each {|meth| print_ty_method(s, meth); } + for methods.each |meth| { print_ty_method(s, meth); } bclose(s, item.span); } } @@ -632,7 +632,7 @@ fn print_method(s: ps, meth: @ast::method) { fn print_outer_attributes(s: ps, attrs: ~[ast::attribute]) { let mut count = 0; - for attrs.each {|attr| + for attrs.each |attr| { alt attr.node.style { ast::attr_outer { print_attribute(s, attr); count += 1; } _ {/* fallthrough */ } @@ -643,7 +643,7 @@ fn print_outer_attributes(s: ps, attrs: ~[ast::attribute]) { fn print_inner_attributes(s: ps, attrs: ~[ast::attribute]) { let mut count = 0; - for attrs.each {|attr| + for attrs.each |attr| { alt attr.node.style { ast::attr_inner { print_attribute(s, attr); @@ -719,8 +719,8 @@ fn print_possibly_embedded_block_(s: ps, blk: ast::blk, embedded: embed_type, print_inner_attributes(s, attrs); - for blk.node.view_items.each {|vi| print_view_item(s, vi); } - for blk.node.stmts.each {|st| + for blk.node.view_items.each |vi| { print_view_item(s, vi); } + for blk.node.stmts.each |st| { print_stmt(s, *st); } alt blk.node.expr { @@ -796,7 +796,7 @@ fn print_mac(s: ps, m: ast::mac) { some(@{node: ast::expr_vec(_, _), _}) { } _ { word(s.s, " "); } } - option::iter(arg, {|a|print_expr(s, a)}); + option::iter(arg, |a| print_expr(s, a)); // FIXME: extension 'body' (#2339) } ast::mac_embed_type(ty) { @@ -943,12 +943,12 @@ fn print_expr(s: ps, &&expr: @ast::expr) { print_maybe_parens_discrim(s, expr); space(s.s); bopen(s); - for arms.each {|arm| + for arms.each |arm| { space(s.s); cbox(s, alt_indent_unit); ibox(s, 0u); let mut first = true; - for arm.pats.each {|p| + for arm.pats.each |p| { if first { first = false; } else { space(s.s); word_space(s, "|"); } @@ -1135,8 +1135,8 @@ fn print_decl(s: ps, decl: @ast::decl) { word_nbsp(s, "let"); // if any are mut, all are mut - if vec::any(locs, {|l| l.node.is_mutbl }) { - assert vec::all(locs, {|l| l.node.is_mutbl }); + if vec::any(locs, |l| l.node.is_mutbl) { + assert vec::all(locs, |l| l.node.is_mutbl); word_nbsp(s, "mut"); } @@ -1176,7 +1176,7 @@ fn print_path(s: ps, &&path: @ast::path, colons_before_params: bool) { maybe_print_comment(s, path.span.lo); if path.global { word(s.s, "::"); } let mut first = true; - for path.idents.each {|id| + for path.idents.each |id| { if first { first = false; } else { word(s.s, "::"); } word(s.s, *id); } @@ -1278,7 +1278,7 @@ fn print_fn_args(s: ps, decl: ast::fn_decl, commasep(s, inconsistent, decl.inputs, print_arg); if cap_items.is_not_empty() { let mut first = decl.inputs.is_empty(); - for cap_items.each { |cap_item| + for cap_items.each |cap_item| { if first { first = false; } else { word_space(s, ","); } if cap_item.is_move { word_nbsp(s, "move") } else { word_nbsp(s, "copy") } @@ -1292,7 +1292,7 @@ fn print_fn_args_and_ret(s: ps, decl: ast::fn_decl, popen(s); print_fn_args(s, decl, cap_items); pclose(s); - word(s.s, constrs_str(decl.constraints, {|c| + word(s.s, constrs_str(decl.constraints, |c| { ast_fn_constr_to_str(decl, c) })); @@ -1336,7 +1336,7 @@ fn print_arg_mode(s: ps, m: ast::mode) { fn print_bounds(s: ps, bounds: @~[ast::ty_param_bound]) { if vec::len(*bounds) > 0u { word(s.s, ":"); - for vec::each(*bounds) {|bound| + for vec::each(*bounds) |bound| { nbsp(s); alt bound { ast::bound_copy { word(s.s, "copy"); } @@ -1404,7 +1404,7 @@ fn print_view_path(s: ps, &&vp: @ast::view_path) { ast::view_path_list(path, idents, _) { print_path(s, path, false); word(s.s, "::{"); - do commasep(s, inconsistent, idents) {|s, w| + do commasep(s, inconsistent, idents) |s, w| { word(s.s, *w.node.name) } word(s.s, "}"); @@ -1627,7 +1627,7 @@ fn print_comment(s: ps, cmnt: comments::cmnt) { } comments::isolated { pprust::hardbreak_if_not_bol(s); - for cmnt.lines.each {|line| + for cmnt.lines.each |line| { // Don't print empty lines because they will end up as trailing // whitespace if str::is_not_empty(line) { word(s.s, line); } @@ -1641,7 +1641,7 @@ fn print_comment(s: ps, cmnt: comments::cmnt) { hardbreak(s.s); } else { ibox(s, 0u); - for cmnt.lines.each {|line| + for cmnt.lines.each |line| { if str::is_not_empty(line) { word(s.s, line); } hardbreak(s.s); } @@ -1691,7 +1691,7 @@ fn constr_args_to_str<T>(f: fn@(T) -> str, str { let mut comma = false; let mut s = "("; - for args.each {|a| + for args.each |a| { if comma { s += ", "; } else { comma = true; } s += constr_arg_to_str::<T>(f, a.node); } @@ -1719,7 +1719,7 @@ fn ast_ty_fn_constr_to_str(&&c: @ast::constr) -> str { } fn ast_fn_constr_to_str(decl: ast::fn_decl, &&c: @ast::constr) -> str { - let arg_to_str = {|a|fn_arg_idx_to_str(decl, a)}; + let arg_to_str = |a| fn_arg_idx_to_str(decl, a); ret path_to_str(c.node.path) + constr_args_to_str(arg_to_str, c.node.args); } @@ -1734,7 +1734,7 @@ fn ty_constr_to_str(&&c: @ast::ty_constr) -> str { fn constrs_str<T>(constrs: ~[T], elt: fn(T) -> str) -> str { let mut s = "", colon = true; - for constrs.each {|c| + for constrs.each |c| { if colon { s += " : "; colon = false; } else { s += ", "; } s += elt(c); } diff --git a/src/libsyntax/visit.rs b/src/libsyntax/visit.rs index 4e8f1028bcd..48f2e57de1c 100644 --- a/src/libsyntax/visit.rs +++ b/src/libsyntax/visit.rs @@ -64,22 +64,22 @@ type visitor<E> = visit_class_item: fn@(@class_member, E, vt<E>)}; fn default_visitor<E>() -> visitor<E> { - ret @{visit_mod: {|a,b,c,d,e|visit_mod::<E>(a, b, c, d, e)}, - visit_view_item: {|a,b,c|visit_view_item::<E>(a, b, c)}, - visit_foreign_item: {|a,b,c|visit_foreign_item::<E>(a, b, c)}, - visit_item: {|a,b,c|visit_item::<E>(a, b, c)}, - visit_local: {|a,b,c|visit_local::<E>(a, b, c)}, - visit_block: {|a,b,c|visit_block::<E>(a, b, c)}, - visit_stmt: {|a,b,c|visit_stmt::<E>(a, b, c)}, - visit_arm: {|a,b,c|visit_arm::<E>(a, b, c)}, - visit_pat: {|a,b,c|visit_pat::<E>(a, b, c)}, - visit_decl: {|a,b,c|visit_decl::<E>(a, b, c)}, - visit_expr: {|a,b,c|visit_expr::<E>(a, b, c)}, - visit_ty: {|a,b,c|skip_ty::<E>(a, b, c)}, - visit_ty_params: {|a,b,c|visit_ty_params::<E>(a, b, c)}, - visit_constr: {|a,b,c,d,e|visit_constr::<E>(a, b, c, d, e)}, - visit_fn: {|a,b,c,d,e,f,g|visit_fn::<E>(a, b, c, d, e, f, g)}, - visit_class_item: {|a,b,c|visit_class_item::<E>(a, b, c)}}; + ret @{visit_mod: |a,b,c,d,e|visit_mod::<E>(a, b, c, d, e), + visit_view_item: |a,b,c|visit_view_item::<E>(a, b, c), + visit_foreign_item: |a,b,c|visit_foreign_item::<E>(a, b, c), + visit_item: |a,b,c|visit_item::<E>(a, b, c), + visit_local: |a,b,c|visit_local::<E>(a, b, c), + visit_block: |a,b,c|visit_block::<E>(a, b, c), + visit_stmt: |a,b,c|visit_stmt::<E>(a, b, c), + visit_arm: |a,b,c|visit_arm::<E>(a, b, c), + visit_pat: |a,b,c|visit_pat::<E>(a, b, c), + visit_decl: |a,b,c|visit_decl::<E>(a, b, c), + visit_expr: |a,b,c|visit_expr::<E>(a, b, c), + visit_ty: |a,b,c|skip_ty::<E>(a, b, c), + visit_ty_params: |a,b,c|visit_ty_params::<E>(a, b, c), + visit_constr: |a,b,c,d,e|visit_constr::<E>(a, b, c, d, e), + visit_fn: |a,b,c,d,e,f,g|visit_fn::<E>(a, b, c, d, e, f, g), + visit_class_item: |a,b,c|visit_class_item::<E>(a, b, c)}; } fn visit_crate<E>(c: crate, e: E, v: vt<E>) { @@ -90,7 +90,7 @@ fn visit_crate_directive<E>(cd: @crate_directive, e: E, v: vt<E>) { alt cd.node { cdir_src_mod(_, _) { } cdir_dir_mod(_, cdirs, _) { - for cdirs.each {|cdir| + for cdirs.each |cdir| { visit_crate_directive(cdir, e, v); } } @@ -100,8 +100,8 @@ fn visit_crate_directive<E>(cd: @crate_directive, e: E, v: vt<E>) { } fn visit_mod<E>(m: _mod, _sp: span, _id: node_id, e: E, v: vt<E>) { - for m.view_items.each {|vi| v.visit_view_item(vi, e, v); } - for m.items.each {|i| v.visit_item(i, e, v); } + for m.view_items.each |vi| { v.visit_view_item(vi, e, v); } + for m.items.each |i| { v.visit_item(i, e, v); } } fn visit_view_item<E>(_vi: @view_item, _e: E, _v: vt<E>) { } @@ -122,8 +122,8 @@ fn visit_item<E>(i: @item, e: E, v: vt<E>) { } item_mod(m) { v.visit_mod(m, i.span, i.id, e, v); } item_foreign_mod(nm) { - for nm.view_items.each {|vi| v.visit_view_item(vi, e, v); } - for nm.items.each {|ni| v.visit_foreign_item(ni, e, v); } + for nm.view_items.each |vi| { v.visit_view_item(vi, e, v); } + for nm.items.each |ni| { v.visit_foreign_item(ni, e, v); } } item_ty(t, tps, rp) { v.visit_ty(t, e, v); @@ -131,34 +131,34 @@ fn visit_item<E>(i: @item, e: E, v: vt<E>) { } item_enum(variants, tps, _) { v.visit_ty_params(tps, e, v); - for variants.each {|vr| - for vr.node.args.each {|va| v.visit_ty(va.ty, e, v); } + for variants.each |vr| { + for vr.node.args.each |va| { v.visit_ty(va.ty, e, v); } } } item_impl(tps, _rp, ifce, ty, methods) { v.visit_ty_params(tps, e, v); - option::iter(ifce, {|p| visit_path(p.path, e, v)}); + option::iter(ifce, |p| visit_path(p.path, e, v)); v.visit_ty(ty, e, v); - for methods.each {|m| + for methods.each |m| { visit_method_helper(m, e, v) } } item_class(tps, ifaces, members, ctor, m_dtor, _) { v.visit_ty_params(tps, e, v); - for members.each {|m| + for members.each |m| { v.visit_class_item(m, e, v); } - for ifaces.each {|p| visit_path(p.path, e, v); } + for ifaces.each |p| { visit_path(p.path, e, v); } visit_class_ctor_helper(ctor, i.ident, tps, ast_util::local_def(i.id), e, v); - do option::iter(m_dtor) {|dtor| + do option::iter(m_dtor) |dtor| { visit_class_dtor_helper(dtor, tps, ast_util::local_def(i.id), e, v)}; } item_iface(tps, _rp, methods) { v.visit_ty_params(tps, e, v); - for methods.each {|m| - for m.decl.inputs.each {|a| v.visit_ty(a.ty, e, v); } + for methods.each |m| { + for m.decl.inputs.each |a| { v.visit_ty(a.ty, e, v); } v.visit_ty_params(m.tps, e, v); v.visit_ty(m.decl.output, e, v); } @@ -186,12 +186,12 @@ fn visit_ty<E>(t: @ty, e: E, v: vt<E>) { v.visit_ty(mt.ty, e, v); } ty_rec(flds) { - for flds.each {|f| v.visit_ty(f.node.mt.ty, e, v); } + for flds.each |f| { v.visit_ty(f.node.mt.ty, e, v); } } - ty_tup(ts) { for ts.each {|tt| v.visit_ty(tt, e, v); } } + ty_tup(ts) { for ts.each |tt| { v.visit_ty(tt, e, v); } } ty_fn(_, decl) { - for decl.inputs.each {|a| v.visit_ty(a.ty, e, v); } - for decl.constraints.each {|c| + for decl.inputs.each |a| { v.visit_ty(a.ty, e, v); } + for decl.constraints.each |c| { v.visit_constr(c.node.path, c.span, c.node.id, e, v); } v.visit_ty(decl.output, e, v); @@ -202,7 +202,7 @@ fn visit_ty<E>(t: @ty, e: E, v: vt<E>) { } ty_constr(t, cs) { v.visit_ty(t, e, v); - for cs.each {|tc| + for cs.each |tc| { v.visit_constr(tc.node.path, tc.span, tc.node.id, e, v); } } @@ -220,26 +220,26 @@ fn visit_constr<E>(_operator: @path, _sp: span, _id: node_id, _e: E, } fn visit_path<E>(p: @path, e: E, v: vt<E>) { - for p.types.each {|tp| v.visit_ty(tp, e, v); } + for p.types.each |tp| { v.visit_ty(tp, e, v); } } fn visit_pat<E>(p: @pat, e: E, v: vt<E>) { alt p.node { pat_enum(path, children) { visit_path(path, e, v); - do option::iter(children) {|children| - for children.each {|child| v.visit_pat(child, e, v); }} + do option::iter(children) |children| { + for children.each |child| { v.visit_pat(child, e, v); }} } pat_rec(fields, _) { - for fields.each {|f| v.visit_pat(f.pat, e, v); } + for fields.each |f| { v.visit_pat(f.pat, e, v); } } - pat_tup(elts) { for elts.each {|elt| v.visit_pat(elt, e, v); } } + pat_tup(elts) { for elts.each |elt| { v.visit_pat(elt, e, v); } } pat_box(inner) | pat_uniq(inner) { v.visit_pat(inner, e, v); } pat_ident(path, inner) { visit_path(path, e, v); - do option::iter(inner) {|subpat| v.visit_pat(subpat, e, v)}; + do option::iter(inner) |subpat| { v.visit_pat(subpat, e, v)}; } pat_lit(ex) { v.visit_expr(ex, e, v); } pat_range(e1, e2) { v.visit_expr(e1, e, v); v.visit_expr(e2, e, v); } @@ -257,8 +257,8 @@ fn visit_foreign_item<E>(ni: @foreign_item, e: E, v: vt<E>) { } fn visit_ty_params<E>(tps: ~[ty_param], e: E, v: vt<E>) { - for tps.each {|tp| - for vec::each(*tp.bounds) {|bound| + for tps.each |tp| { + for vec::each(*tp.bounds) |bound| { alt bound { bound_iface(t) { v.visit_ty(t, e, v); } bound_copy | bound_send | bound_const { } @@ -268,8 +268,8 @@ fn visit_ty_params<E>(tps: ~[ty_param], e: E, v: vt<E>) { } fn visit_fn_decl<E>(fd: fn_decl, e: E, v: vt<E>) { - for fd.inputs.each {|a| v.visit_ty(a.ty, e, v); } - for fd.constraints.each {|c| + for fd.inputs.each |a| { v.visit_ty(a.ty, e, v); } + for fd.constraints.each |c| { v.visit_constr(c.node.path, c.span, c.node.id, e, v); } v.visit_ty(fd.output, e, v); @@ -311,8 +311,8 @@ fn visit_fn<E>(fk: fn_kind, decl: fn_decl, body: blk, _sp: span, } fn visit_block<E>(b: ast::blk, e: E, v: vt<E>) { - for b.node.view_items.each {|vi| v.visit_view_item(vi, e, v); } - for b.node.stmts.each {|s| v.visit_stmt(s, e, v); } + for b.node.view_items.each |vi| { v.visit_view_item(vi, e, v); } + for b.node.stmts.each |s| { v.visit_stmt(s, e, v); } visit_expr_opt(b.node.expr, e, v); } @@ -327,7 +327,7 @@ fn visit_stmt<E>(s: @stmt, e: E, v: vt<E>) { fn visit_decl<E>(d: @decl, e: E, v: vt<E>) { alt d.node { decl_local(locs) { - for locs.each {|loc| v.visit_local(loc, e, v); } + for locs.each |loc| { v.visit_local(loc, e, v); } } decl_item(it) { v.visit_item(it, e, v); } } @@ -338,13 +338,13 @@ fn visit_expr_opt<E>(eo: option<@expr>, e: E, v: vt<E>) { } fn visit_exprs<E>(exprs: ~[@expr], e: E, v: vt<E>) { - for exprs.each {|ex| v.visit_expr(ex, e, v); } + for exprs.each |ex| { v.visit_expr(ex, e, v); } } fn visit_mac<E>(m: mac, e: E, v: vt<E>) { alt m.node { ast::mac_invoc(pth, arg, body) { - option::map(arg, {|arg| v.visit_expr(arg, e, v)}); } + option::map(arg, |arg| v.visit_expr(arg, e, v)); } ast::mac_invoc_tt(pth, tt) { /* no user-serviceable parts inside */ } ast::mac_embed_type(ty) { v.visit_ty(ty, e, v); } ast::mac_embed_block(blk) { v.visit_block(blk, e, v); } @@ -363,10 +363,10 @@ fn visit_expr<E>(ex: @expr, e: E, v: vt<E>) { expr_vstore(x, _) { v.visit_expr(x, e, v); } expr_vec(es, _) { visit_exprs(es, e, v); } expr_rec(flds, base) { - for flds.each {|f| v.visit_expr(f.node.expr, e, v); } + for flds.each |f| { v.visit_expr(f.node.expr, e, v); } visit_expr_opt(base, e, v); } - expr_tup(elts) { for elts.each {|el| v.visit_expr(el, e, v); } } + expr_tup(elts) { for elts.each |el| { v.visit_expr(el, e, v); } } expr_call(callee, args, _) { visit_exprs(args, e, v); v.visit_expr(callee, e, v); @@ -393,7 +393,7 @@ fn visit_expr<E>(ex: @expr, e: E, v: vt<E>) { expr_loop(b) { v.visit_block(b, e, v); } expr_alt(x, arms, _) { v.visit_expr(x, e, v); - for arms.each {|a| v.visit_arm(a, e, v); } + for arms.each |a| { v.visit_arm(a, e, v); } } expr_fn(proto, decl, body, cap_clause) { v.visit_fn(fk_anon(proto, cap_clause), decl, body, @@ -414,7 +414,7 @@ fn visit_expr<E>(ex: @expr, e: E, v: vt<E>) { } expr_field(x, _, tys) { v.visit_expr(x, e, v); - for tys.each {|tp| v.visit_ty(tp, e, v); } + for tys.each |tp| { v.visit_ty(tp, e, v); } } expr_index(a, b) { v.visit_expr(a, e, v); v.visit_expr(b, e, v); } expr_path(p) { visit_path(p, e, v); } @@ -431,7 +431,7 @@ fn visit_expr<E>(ex: @expr, e: E, v: vt<E>) { } fn visit_arm<E>(a: arm, e: E, v: vt<E>) { - for a.pats.each {|p| v.visit_pat(p, e, v); } + for a.pats.each |p| { v.visit_pat(p, e, v); } visit_expr_opt(a.guard, e, v); v.visit_block(a.body, e, v); } @@ -551,9 +551,9 @@ fn mk_simple_visitor(v: simple_visitor) -> vt<()> { visit_fn(fk, decl, body, sp, id, e, v); } let visit_ty = if v.visit_ty == simple_ignore_ty { - {|a,b,c| skip_ty(a, b, c)} + |a,b,c| skip_ty(a, b, c) } else { - {|a,b,c| v_ty(v.visit_ty, a, b, c)} + |a,b,c| v_ty(v.visit_ty, a, b, c) }; fn v_class_item(f: fn@(@class_member), cm: @class_member, &&e: (), @@ -561,33 +561,28 @@ fn mk_simple_visitor(v: simple_visitor) -> vt<()> { f(cm); visit_class_item(cm, e, v); } - ret mk_vt(@{visit_mod: {|a,b,c,d,e|v_mod(v.visit_mod, a, b, c, d, e)}, - visit_view_item: {|a,b,c| - v_view_item(v.visit_view_item, a, b, c) - }, + ret mk_vt(@{visit_mod: |a,b,c,d,e|v_mod(v.visit_mod, a, b, c, d, e), + visit_view_item: |a,b,c| + v_view_item(v.visit_view_item, a, b, c), visit_foreign_item: - {|a,b,c|v_foreign_item(v.visit_foreign_item, a, b, c)}, - visit_item: {|a,b,c|v_item(v.visit_item, a, b, c)}, - visit_local: {|a,b,c|v_local(v.visit_local, a, b, c)}, - visit_block: {|a,b,c|v_block(v.visit_block, a, b, c)}, - visit_stmt: {|a,b,c|v_stmt(v.visit_stmt, a, b, c)}, - visit_arm: {|a,b,c|v_arm(v.visit_arm, a, b, c)}, - visit_pat: {|a,b,c|v_pat(v.visit_pat, a, b, c)}, - visit_decl: {|a,b,c|v_decl(v.visit_decl, a, b, c)}, - visit_expr: {|a,b,c|v_expr(v.visit_expr, a, b, c)}, + |a,b,c|v_foreign_item(v.visit_foreign_item, a, b, c), + visit_item: |a,b,c|v_item(v.visit_item, a, b, c), + visit_local: |a,b,c|v_local(v.visit_local, a, b, c), + visit_block: |a,b,c|v_block(v.visit_block, a, b, c), + visit_stmt: |a,b,c|v_stmt(v.visit_stmt, a, b, c), + visit_arm: |a,b,c|v_arm(v.visit_arm, a, b, c), + visit_pat: |a,b,c|v_pat(v.visit_pat, a, b, c), + visit_decl: |a,b,c|v_decl(v.visit_decl, a, b, c), + visit_expr: |a,b,c|v_expr(v.visit_expr, a, b, c), visit_ty: visit_ty, - visit_ty_params: {|a,b,c| - v_ty_params(v.visit_ty_params, a, b, c) - }, - visit_constr: {|a,b,c,d,e| - v_constr(v.visit_constr, a, b, c, d, e) - }, - visit_fn: {|a,b,c,d,e,f,g| - v_fn(v.visit_fn, a, b, c, d, e, f, g) - }, - visit_class_item: {|a,b,c| + visit_ty_params: |a,b,c| + v_ty_params(v.visit_ty_params, a, b, c), + visit_constr: |a,b,c,d,e| + v_constr(v.visit_constr, a, b, c, d, e), + visit_fn: |a,b,c,d,e,f,g| + v_fn(v.visit_fn, a, b, c, d, e, f, g), + visit_class_item: |a,b,c| v_class_item(v.visit_class_item, a, b, c) - } }); } |
