diff options
| author | Brian Anderson <banderson@mozilla.com> | 2012-08-06 12:34:08 -0700 |
|---|---|---|
| committer | Brian Anderson <banderson@mozilla.com> | 2012-08-06 15:36:30 -0700 |
| commit | ecaf9e39c9435fa2de4fe393c4b263be36eb2d99 (patch) | |
| tree | 775f69be65adff65551d96173dd797e32e2c3157 /src/libsyntax | |
| parent | d3a9bb1bd4a1d510bbaca2ab1121e4c85a239247 (diff) | |
| download | rust-ecaf9e39c9435fa2de4fe393c4b263be36eb2d99.tar.gz rust-ecaf9e39c9435fa2de4fe393c4b263be36eb2d99.zip | |
Convert alt to match. Stop parsing alt
Diffstat (limited to 'src/libsyntax')
35 files changed, 484 insertions, 483 deletions
diff --git a/src/libsyntax/ast.rs b/src/libsyntax/ast.rs index daf3e20f469..f10ec142328 100644 --- a/src/libsyntax/ast.rs +++ b/src/libsyntax/ast.rs @@ -193,7 +193,7 @@ enum vstore { } pure fn is_blockish(p: ast::proto) -> bool { - alt p { + match p { proto_block => true, proto_bare | proto_uniq | proto_box => false } diff --git a/src/libsyntax/ast_map.rs b/src/libsyntax/ast_map.rs index f23385f2e17..2c774abff57 100644 --- a/src/libsyntax/ast_map.rs +++ b/src/libsyntax/ast_map.rs @@ -12,7 +12,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| { - alt e { + match e { path_mod(s) => /* FIXME (#2543) */ copy *s, path_name(s) => /* FIXME (#2543) */ copy *s } @@ -104,7 +104,7 @@ fn map_decoded_item(diag: span_handler, // methods get added to the AST map when their impl is visited. Since we // don't decode and instantiate the impl, but just the method, we have to // add it to the table now: - alt ii { + match ii { ii_item(*) | ii_ctor(*) | ii_dtor(*) => { /* fallthrough */ } ii_foreign(i) => { cx.map.insert(i.id, node_foreign_item(i, foreign_abi_rust_intrinsic, @@ -127,7 +127,7 @@ fn map_fn(fk: visit::fn_kind, decl: fn_decl, body: blk, copy a, cx.local_id)); cx.local_id += 1u; } - alt fk { + match fk { visit::fk_ctor(nm, attrs, tps, self_id, parent_id) => { let ct = @{node: {id: id, attrs: attrs, @@ -159,7 +159,7 @@ fn map_block(b: blk, cx: ctx, v: vt) { fn number_pat(cx: ctx, pat: @pat) { do ast_util::walk_pat(pat) |p| { - alt p.node { + match p.node { pat_ident(*) => { cx.map.insert(p.id, node_local(cx.local_id)); cx.local_id += 1u; @@ -189,7 +189,7 @@ fn map_method(impl_did: def_id, impl_path: @path, fn map_item(i: @item, cx: ctx, v: vt) { let item_path = @/* FIXME (#2543) */ copy cx.path; cx.map.insert(i.id, node_item(i, item_path)); - alt i.node { + match i.node { item_impl(_, opt_ir, _, ms) => { let impl_did = ast_util::local_def(i.id); for ms.each |m| { @@ -205,7 +205,7 @@ fn map_item(i: @item, cx: ctx, v: vt) { } } item_foreign_mod(nm) => { - let abi = alt attr::foreign_abi(i.attrs) { + let abi = match attr::foreign_abi(i.attrs) { either::left(msg) => cx.diag.span_fatal(i.span, msg), either::right(abi) => abi }; @@ -248,7 +248,7 @@ fn map_item(i: @item, cx: ctx, v: vt) { } _ => () } - alt i.node { + match i.node { item_mod(_) | item_foreign_mod(_) => { vec::push(cx.path, path_mod(i.ident)); } @@ -259,9 +259,9 @@ fn map_item(i: @item, cx: ctx, v: vt) { } fn map_view_item(vi: @view_item, cx: ctx, _v: vt) { - alt vi.node { + match vi.node { view_item_export(vps) => for vps.each |vp| { - let (id, name) = alt vp.node { + let (id, name) = match vp.node { view_path_simple(nm, _, id) => { (id, /* FIXME (#2543) */ copy nm) } @@ -281,7 +281,7 @@ fn map_expr(ex: @expr, cx: ctx, v: vt) { } fn node_id_to_str(map: map, id: node_id) -> ~str { - alt map.find(id) { + match map.find(id) { none => { fmt!{"unknown node (id=%d)", id} } diff --git a/src/libsyntax/ast_util.rs b/src/libsyntax/ast_util.rs index cf5168fc6da..4f261afa3de 100644 --- a/src/libsyntax/ast_util.rs +++ b/src/libsyntax/ast_util.rs @@ -35,7 +35,7 @@ pure fn local_def(id: node_id) -> def_id { {crate: local_crate, node: id} } pure fn is_local(did: ast::def_id) -> bool { did.crate == local_crate } pure fn stmt_id(s: stmt) -> node_id { - alt s.node { + match s.node { stmt_decl(_, id) => id, stmt_expr(_, id) => id, stmt_semi(_, id) => id @@ -43,7 +43,7 @@ pure fn stmt_id(s: stmt) -> node_id { } fn variant_def_ids(d: def) -> {enm: def_id, var: def_id} { - alt d { + match d { def_variant(enum_id, var_id) => { return {enm: enum_id, var: var_id} } @@ -52,7 +52,7 @@ fn variant_def_ids(d: def) -> {enm: def_id, var: def_id} { } pure fn def_id_of_def(d: def) -> def_id { - alt d { + match d { def_fn(id, _) | def_mod(id) | def_foreign_mod(id) | def_const(id) | def_variant(_, id) | def_ty(id) | def_ty_param(id, _) | @@ -70,7 +70,7 @@ pure fn def_id_of_def(d: def) -> def_id { } pure fn binop_to_str(op: binop) -> ~str { - alt op { + match op { add => return ~"+", subtract => return ~"-", mul => return ~"*", @@ -93,7 +93,7 @@ pure fn binop_to_str(op: binop) -> ~str { } pure fn binop_to_method_name(op: binop) -> option<~str> { - alt op { + match op { add => return some(~"add"), subtract => return some(~"sub"), mul => return some(~"mul"), @@ -109,7 +109,7 @@ pure fn binop_to_method_name(op: binop) -> option<~str> { } pure fn lazy_binop(b: binop) -> bool { - alt b { + match b { and => true, or => true, _ => false @@ -117,7 +117,7 @@ pure fn lazy_binop(b: binop) -> bool { } pure fn is_shift_binop(b: binop) -> bool { - alt b { + match b { shl => true, shr => true, _ => false @@ -125,7 +125,7 @@ pure fn is_shift_binop(b: binop) -> bool { } pure fn unop_to_str(op: unop) -> ~str { - alt op { + match op { box(mt) => if mt == m_mutbl { ~"@mut " } else { ~"@" }, uniq(mt) => if mt == m_mutbl { ~"~mut " } else { ~"~" }, deref => ~"*", @@ -135,11 +135,11 @@ pure fn unop_to_str(op: unop) -> ~str { } pure fn is_path(e: @expr) -> bool { - return alt e.node { expr_path(_) => true, _ => false }; + return match e.node { expr_path(_) => true, _ => false }; } pure fn int_ty_to_str(t: int_ty) -> ~str { - alt t { + match t { ty_char => ~"u8", // ??? ty_i => ~"", ty_i8 => ~"i8", @@ -150,7 +150,7 @@ pure fn int_ty_to_str(t: int_ty) -> ~str { } pure fn int_ty_max(t: int_ty) -> u64 { - alt t { + match t { ty_i8 => 0x80u64, ty_i16 => 0x8000u64, ty_i | ty_char | ty_i32 => 0x80000000u64, // actually ni about ty_i @@ -159,7 +159,7 @@ pure fn int_ty_max(t: int_ty) -> u64 { } pure fn uint_ty_to_str(t: uint_ty) -> ~str { - alt t { + match t { ty_u => ~"u", ty_u8 => ~"u8", ty_u16 => ~"u16", @@ -169,7 +169,7 @@ pure fn uint_ty_to_str(t: uint_ty) -> ~str { } pure fn uint_ty_max(t: uint_ty) -> u64 { - alt t { + match t { ty_u8 => 0xffu64, ty_u16 => 0xffffu64, ty_u | ty_u32 => 0xffffffffu64, // actually ni about ty_u @@ -178,7 +178,7 @@ pure fn uint_ty_max(t: uint_ty) -> u64 { } pure fn float_ty_to_str(t: float_ty) -> ~str { - alt t { ty_f => ~"f", ty_f32 => ~"f32", ty_f64 => ~"f64" } + match t { ty_f => ~"f", ty_f32 => ~"f32", ty_f64 => ~"f64" } } fn is_exported(i: ident, m: _mod) -> bool { @@ -186,7 +186,7 @@ fn is_exported(i: ident, m: _mod) -> bool { let mut parent_enum : option<ident> = none; for m.items.each |it| { if it.ident == i { local = true; } - alt it.node { + match it.node { item_enum(variants, _) => for variants.each |v| { if v.node.name == i { local = true; @@ -199,14 +199,14 @@ fn is_exported(i: ident, m: _mod) -> bool { } let mut has_explicit_exports = false; for m.view_items.each |vi| { - alt vi.node { + match vi.node { view_item_export(vps) => { has_explicit_exports = true; for vps.each |vp| { - alt vp.node { + match vp.node { ast::view_path_simple(id, _, _) => { if id == i { return true; } - alt parent_enum { + match parent_enum { some(parent_enum_id) => { if id == parent_enum_id { return true; } } @@ -240,7 +240,7 @@ fn is_exported(i: ident, m: _mod) -> bool { } pure fn is_call_expr(e: @expr) -> bool { - alt e.node { expr_call(_, _, _) => true, _ => false } + match e.node { expr_call(_, _, _) => true, _ => false } } pure fn eq_ty(a: &@ty, b: &@ty) -> bool { box::ptr_eq(*a, *b) } @@ -284,7 +284,7 @@ fn ident_to_path(s: span, +i: ident) -> @path { } pure fn is_unguarded(&&a: arm) -> bool { - alt a.guard { + match a.guard { none => true, _ => false } @@ -295,7 +295,7 @@ pure fn unguarded_pat(a: arm) -> option<~[@pat]> { } pure fn class_item_ident(ci: @class_member) -> ident { - alt ci.node { + match ci.node { instance_var(i,_,_,_,_) => /* FIXME (#2543) */ copy i, class_method(it) => /* FIXME (#2543) */ copy it.ident } @@ -306,7 +306,7 @@ type ivar = {ident: ident, ty: @ty, cm: class_mutability, fn public_methods(ms: ~[@method]) -> ~[@method] { vec::filter(ms, - |m| alt m.vis { + |m| match m.vis { public => true, _ => false }) @@ -315,7 +315,7 @@ fn public_methods(ms: ~[@method]) -> ~[@method] { fn split_class_items(cs: ~[@class_member]) -> (~[ivar], ~[@method]) { let mut vs = ~[], ms = ~[]; for cs.each |c| { - alt c.node { + match c.node { instance_var(i, t, cm, id, vis) => { vec::push(vs, {ident: /* FIXME (#2543) */ copy i, ty: t, @@ -332,7 +332,7 @@ fn split_class_items(cs: ~[@class_member]) -> (~[ivar], ~[@method]) { // extract a ty_method from a trait_method. if the trait_method is // a default, pull out the useful fields to make a ty_method fn trait_method_to_ty_method(method: trait_method) -> ty_method { - alt method { + match method { required(m) => m, provided(m) => { {ident: m.ident, attrs: m.attrs, @@ -346,7 +346,7 @@ fn split_trait_methods(trait_methods: ~[trait_method]) -> (~[ty_method], ~[@method]) { let mut reqd = ~[], provd = ~[]; for trait_methods.each |trt_method| { - alt trt_method { + match trt_method { required(tm) => vec::push(reqd, tm), provided(m) => vec::push(provd, m) } @@ -355,7 +355,7 @@ fn split_trait_methods(trait_methods: ~[trait_method]) } pure fn class_member_visibility(ci: @class_member) -> visibility { - alt ci.node { + match ci.node { instance_var(_, _, _, _, vis) => vis, class_method(m) => m.vis } @@ -369,7 +369,7 @@ trait inlined_item_utils { impl inlined_item_methods of inlined_item_utils for inlined_item { fn ident() -> ident { - alt self { + match self { ii_item(i) => /* FIXME (#2543) */ copy i.ident, ii_foreign(i) => /* FIXME (#2543) */ copy i.ident, ii_method(_, m) => /* FIXME (#2543) */ copy m.ident, @@ -379,7 +379,7 @@ impl inlined_item_methods of inlined_item_utils for inlined_item { } fn id() -> ast::node_id { - alt self { + match self { ii_item(i) => i.id, ii_foreign(i) => i.id, ii_method(_, m) => m.id, @@ -389,7 +389,7 @@ impl inlined_item_methods of inlined_item_utils for inlined_item { } fn accept<E>(e: E, v: visit::vt<E>) { - alt self { + match self { ii_item(i) => v.visit_item(i, e, v), ii_foreign(i) => v.visit_foreign_item(i, e, v), ii_method(_, m) => visit::visit_method_helper(m, e, v), @@ -406,7 +406,7 @@ impl inlined_item_methods of inlined_item_utils for inlined_item { /* True if d is either a def_self, or a chain of def_upvars referring to a def_self */ fn is_self(d: ast::def) -> bool { - alt d { + match d { def_self(_) => true, def_upvar(_, d, _) => is_self(*d), _ => false @@ -415,7 +415,7 @@ fn is_self(d: ast::def) -> bool { /// Maps a binary operator to its precedence fn operator_prec(op: ast::binop) -> uint { - alt op { + match op { mul | div | rem => 12u, // 'as' sits between here with 11 add | subtract => 10u, @@ -455,11 +455,11 @@ fn id_visitor(vfn: fn@(node_id)) -> visit::vt<()> { }, visit_view_item: fn@(vi: @view_item) { - alt vi.node { + match vi.node { view_item_use(_, _, id) => vfn(id), view_item_import(vps) | view_item_export(vps) => { do vec::iter(vps) |vp| { - alt vp.node { + match vp.node { view_path_simple(_, _, id) => vfn(id), view_path_glob(_, id) => vfn(id), view_path_list(_, _, id) => vfn(id) @@ -475,7 +475,7 @@ fn id_visitor(vfn: fn@(node_id)) -> visit::vt<()> { visit_item: fn@(i: @item) { vfn(i.id); - alt i.node { + match i.node { item_enum(vs, _) => for vs.each |v| { vfn(v.node.id); } _ => () } @@ -511,7 +511,7 @@ fn id_visitor(vfn: fn@(node_id)) -> visit::vt<()> { }, visit_ty: fn@(t: @ty) { - alt t.node { + match t.node { ty_path(_, id) => vfn(id), _ => { /* fall through */ } } @@ -525,7 +525,7 @@ fn id_visitor(vfn: fn@(node_id)) -> visit::vt<()> { _b: ast::blk, _sp: span, id: ast::node_id) { vfn(id); - alt fk { + match fk { visit::fk_ctor(nm, _, tps, self_id, parent_id) => { vec::iter(tps, |tp| vfn(tp.id)); vfn(id); @@ -565,7 +565,7 @@ fn id_visitor(vfn: fn@(node_id)) -> visit::vt<()> { }, visit_class_item: fn@(c: @class_member) { - alt c.node { + match c.node { instance_var(_, _, _, id,_) => vfn(id), class_method(_) => () } @@ -592,7 +592,7 @@ fn compute_id_range_for_inlined_item(item: inlined_item) -> id_range { } pure fn is_item_impl(item: @ast::item) -> bool { - alt item.node { + match item.node { item_impl(*) => true, _ => false } @@ -600,7 +600,7 @@ pure fn is_item_impl(item: @ast::item) -> bool { fn walk_pat(pat: @pat, it: fn(@pat)) { it(pat); - alt pat.node { + match 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| { @@ -613,7 +613,7 @@ fn walk_pat(pat: @pat, it: fn(@pat)) { } fn view_path_id(p: @view_path) -> node_id { - alt p.node { + match p.node { view_path_simple(_, _, id) | view_path_glob(_, id) | view_path_list(_, _, id) => id } diff --git a/src/libsyntax/attr.rs b/src/libsyntax/attr.rs index f04a8e42ab7..0838a1a70d9 100644 --- a/src/libsyntax/attr.rs +++ b/src/libsyntax/attr.rs @@ -114,7 +114,7 @@ fn get_attr_name(attr: ast::attribute) -> ast::ident { // All "bad" FIXME copies are as per #2543 fn get_meta_item_name(meta: @ast::meta_item) -> ast::ident { - alt meta.node { + match meta.node { ast::meta_word(n) => /* FIXME (#2543) */ copy n, ast::meta_name_value(n, _) => /* FIXME (#2543) */ copy n, ast::meta_list(n, _) => /* FIXME (#2543) */ copy n @@ -126,8 +126,8 @@ fn get_meta_item_name(meta: @ast::meta_item) -> ast::ident { * containing a string, otherwise none */ fn get_meta_item_value_str(meta: @ast::meta_item) -> option<@~str> { - alt meta.node { - ast::meta_name_value(_, v) => alt v.node { + match meta.node { + ast::meta_name_value(_, v) => match v.node { ast::lit_str(s) => option::some(s), _ => option::none } @@ -137,7 +137,7 @@ fn get_meta_item_value_str(meta: @ast::meta_item) -> option<@~str> { /// Gets a list of inner meta items from a list meta_item type fn get_meta_item_list(meta: @ast::meta_item) -> option<~[@ast::meta_item]> { - alt meta.node { + match meta.node { ast::meta_list(_, l) => option::some(/* FIXME (#2543) */ copy l), _ => option::none } @@ -150,7 +150,7 @@ fn get_meta_item_list(meta: @ast::meta_item) -> option<~[@ast::meta_item]> { fn get_name_value_str_pair( item: @ast::meta_item ) -> option<(ast::ident, @~str)> { - alt attr::get_meta_item_value_str(item) { + match attr::get_meta_item_value_str(item) { some(value) => { let name = attr::get_meta_item_name(item); some((name, value)) @@ -203,12 +203,12 @@ fn contains(haystack: ~[@ast::meta_item], needle: @ast::meta_item) -> bool { } fn eq(a: @ast::meta_item, b: @ast::meta_item) -> bool { - return alt a.node { - ast::meta_word(na) => alt b.node { + return match a.node { + ast::meta_word(na) => match b.node { ast::meta_word(nb) => na == nb, _ => false } - ast::meta_name_value(na, va) => alt b.node { + ast::meta_name_value(na, va) => match b.node { ast::meta_name_value(nb, vb) => na == nb && va.node == vb.node, _ => false } @@ -253,8 +253,8 @@ fn last_meta_item_value_str_by_name( items: ~[@ast::meta_item], +name: ~str ) -> option<@~str> { - alt last_meta_item_by_name(items, name) { - some(item) => alt attr::get_meta_item_value_str(item) { + match last_meta_item_by_name(items, name) { + some(item) => match attr::get_meta_item_value_str(item) { some(value) => some(value), none => none } @@ -266,7 +266,7 @@ fn last_meta_item_list_by_name( items: ~[@ast::meta_item], +name: ~str ) -> option<~[@ast::meta_item]> { - alt last_meta_item_by_name(items, name) { + match last_meta_item_by_name(items, name) { some(item) => attr::get_meta_item_list(item), none => none } @@ -280,7 +280,7 @@ fn last_meta_item_list_by_name( fn sort_meta_items(+items: ~[@ast::meta_item]) -> ~[@ast::meta_item] { pure fn lteq(ma: &@ast::meta_item, mb: &@ast::meta_item) -> bool { pure fn key(m: &ast::meta_item) -> ast::ident { - alt m.node { + match m.node { ast::meta_word(name) => /* FIXME (#2543) */ copy name, ast::meta_name_value(name, _) => /* FIXME (#2543) */ copy name, ast::meta_list(name, _) => /* FIXME (#2543) */ copy name @@ -310,7 +310,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| { - alt attr.node.value.node { + match attr.node.value.node { ast::meta_list(_, _) => vec::push(found, attr), _ => debug!{"ignoring link attribute that has incorrect type"} } @@ -324,14 +324,14 @@ fn find_linkage_attrs(attrs: ~[ast::attribute]) -> ~[ast::attribute] { */ fn find_linkage_metas(attrs: ~[ast::attribute]) -> ~[@ast::meta_item] { do find_linkage_attrs(attrs).flat_map |attr| { - alt check attr.node.value.node { + match check attr.node.value.node { ast::meta_list(_, items) => /* FIXME (#2543) */ copy items } } } fn foreign_abi(attrs: ~[ast::attribute]) -> either<~str, ast::foreign_abi> { - return alt attr::first_attr_value_str_by_name(attrs, ~"abi") { + return match attr::first_attr_value_str_by_name(attrs, ~"abi") { option::none => { either::right(ast::foreign_abi_cdecl) } @@ -361,7 +361,7 @@ enum inline_attr { fn find_inline_attr(attrs: ~[ast::attribute]) -> inline_attr { // FIXME (#2809)---validate the usage of #[inline] and #[inline(always)] do vec::foldl(ia_none, attrs) |ia,attr| { - alt attr.node.value.node { + match attr.node.value.node { ast::meta_word(@~"inline") => ia_hint, ast::meta_list(@~"inline", items) => { if !vec::is_empty(find_meta_items_by_name(items, ~"always")) { diff --git a/src/libsyntax/codemap.rs b/src/libsyntax/codemap.rs index 575edaa771c..e725eaaa724 100644 --- a/src/libsyntax/codemap.rs +++ b/src/libsyntax/codemap.rs @@ -124,7 +124,7 @@ fn lookup_char_pos_adj(map: codemap, pos: uint) -> {filename: ~str, line: uint, col: uint, file: option<filemap>} { let loc = lookup_char_pos(map, pos); - alt (loc.file.substr) { + match (loc.file.substr) { fss_none => { {filename: /* FIXME (#2543) */ copy loc.file.name, line: loc.line, @@ -146,7 +146,7 @@ fn lookup_char_pos_adj(map: codemap, pos: uint) fn adjust_span(map: codemap, sp: span) -> span { pure fn lookup(pos: file_pos) -> uint { return pos.ch; } let line = lookup_line(map, sp.lo, lookup); - alt (line.fm.substr) { + match (line.fm.substr) { fss_none => sp, fss_internal(s) => { adjust_span(map, {lo: s.lo + (sp.lo - line.fm.start_pos.ch), @@ -196,7 +196,7 @@ fn span_to_lines(sp: span, cm: codemap::codemap) -> @file_lines { fn get_line(fm: filemap, line: int) -> ~str unsafe { let begin: uint = fm.lines[line].byte - fm.start_pos.byte; - let end = alt str::find_char_from(*fm.src, '\n', begin) { + let end = match str::find_char_from(*fm.src, '\n', begin) { some(e) => e, none => str::len(*fm.src) }; diff --git a/src/libsyntax/diagnostic.rs b/src/libsyntax/diagnostic.rs index 6195849f340..bd5b37ab698 100644 --- a/src/libsyntax/diagnostic.rs +++ b/src/libsyntax/diagnostic.rs @@ -87,7 +87,7 @@ impl codemap_handler of handler for handler_t { fn has_errors() -> bool { self.err_count > 0u } fn abort_if_errors() { let s; - alt self.err_count { + match self.err_count { 0u => return, 1u => s = ~"aborting due to previous error", _ => { @@ -122,7 +122,7 @@ fn mk_span_handler(handler: handler, cm: codemap::codemap) -> span_handler { fn mk_handler(emitter: option<emitter>) -> handler { - let emit = alt emitter { + let emit = match emitter { some(e) => e, none => { let f = fn@(cmsp: option<(codemap::codemap, span)>, @@ -147,7 +147,7 @@ enum level { } fn diagnosticstr(lvl: level) -> ~str { - alt lvl { + match lvl { fatal => ~"error", error => ~"error", warning => ~"warning", @@ -156,7 +156,7 @@ fn diagnosticstr(lvl: level) -> ~str { } fn diagnosticcolor(lvl: level) -> u8 { - alt lvl { + match lvl { fatal => term::color_bright_red, error => term::color_bright_red, warning => term::color_bright_yellow, @@ -182,7 +182,7 @@ fn print_diagnostic(topic: ~str, lvl: level, msg: ~str) { fn emit(cmsp: option<(codemap::codemap, span)>, msg: ~str, lvl: level) { - alt cmsp { + match cmsp { some((cm, sp)) => { let sp = codemap::adjust_span(cm,sp); let ss = codemap::span_to_str(sp, cm); @@ -266,7 +266,7 @@ fn print_macro_backtrace(cm: codemap::codemap, sp: span) { fn expect<T: copy>(diag: span_handler, opt: option<T>, msg: fn() -> ~str) -> T { - alt opt { + match opt { some(t) => t, none => diag.handler().bug(msg()) } diff --git a/src/libsyntax/ext/auto_serialize.rs b/src/libsyntax/ext/auto_serialize.rs index 6e9673f4bc2..c87ea71fc47 100644 --- a/src/libsyntax/ext/auto_serialize.rs +++ b/src/libsyntax/ext/auto_serialize.rs @@ -101,7 +101,7 @@ fn expand(cx: ext_ctxt, } do vec::flat_map(in_items) |in_item| { - alt in_item.node { + match in_item.node { ast::item_ty(ty, tps) => { vec::append(~[filter_attrs(in_item)], ty_fns(cx, in_item.ident, ty, tps)) @@ -375,7 +375,7 @@ fn ser_lambda(cx: ext_ctxt, tps: ser_tps_map, ty: @ast::ty, } fn is_vec_or_str(ty: @ast::ty) -> bool { - alt ty.node { + match ty.node { ast::ty_vec(_) => true, // This may be wrong if the user has shadowed (!) str ast::ty_path(@{span: _, global: _, idents: ids, @@ -391,7 +391,7 @@ fn ser_ty(cx: ext_ctxt, tps: ser_tps_map, let ext_cx = cx; // required for #ast{} - alt ty.node { + match ty.node { ast::ty_nil => { ~[#ast[stmt]{$(s).emit_nil()}] } @@ -447,7 +447,7 @@ fn ser_ty(cx: ext_ctxt, tps: ser_tps_map, ast::ty_tup(tys) => { // Generate code like // - // alt v { + // match v { // (v1, v2, v3) { // .. serialize v1, v2, v3 .. // } @@ -483,7 +483,7 @@ fn ser_ty(cx: ext_ctxt, tps: ser_tps_map, vec::is_empty(path.types) { let ident = path.idents[0]; - alt tps.find(*ident) { + match tps.find(*ident) { some(f) => f(v), none => ser_path(cx, tps, path, s, v) } @@ -634,7 +634,7 @@ fn deser_ty(cx: ext_ctxt, tps: deser_tps_map, let ext_cx = cx; // required for #ast{} - alt ty.node { + match ty.node { ast::ty_nil => { #ast{ $(d).read_nil() } } @@ -709,7 +709,7 @@ fn deser_ty(cx: ext_ctxt, tps: deser_tps_map, vec::is_empty(path.types) { let ident = path.idents[0]; - alt tps.find(*ident) { + match tps.find(*ident) { some(f) => f(), none => deser_path(cx, tps, path, d) } diff --git a/src/libsyntax/ext/base.rs b/src/libsyntax/ext/base.rs index b8cce21190c..f2e1855c0f5 100644 --- a/src/libsyntax/ext/base.rs +++ b/src/libsyntax/ext/base.rs @@ -150,7 +150,7 @@ fn mk_ctxt(parse_sess: parse::parse_sess, fn mod_pop() { vec::pop(self.mod_path); } fn mod_path() -> ~[ast::ident] { return self.mod_path; } fn bt_push(ei: codemap::expn_info_) { - alt ei { + match ei { expanded_from({call_site: cs, callie: callie}) => { self.backtrace = some(@expanded_from({ @@ -161,7 +161,7 @@ fn mk_ctxt(parse_sess: parse::parse_sess, } } fn bt_pop() { - alt self.backtrace { + match self.backtrace { some(@expanded_from({call_site: {expn_info: prev, _}, _})) => { self.backtrace = prev } @@ -206,8 +206,8 @@ fn mk_ctxt(parse_sess: parse::parse_sess, } fn expr_to_str(cx: ext_ctxt, expr: @ast::expr, error: ~str) -> ~str { - alt expr.node { - ast::expr_lit(l) => alt l.node { + match expr.node { + ast::expr_lit(l) => match l.node { ast::lit_str(s) => return *s, _ => cx.span_fatal(l.span, error) } @@ -216,7 +216,7 @@ fn expr_to_str(cx: ext_ctxt, expr: @ast::expr, error: ~str) -> ~str { } fn expr_to_ident(cx: ext_ctxt, expr: @ast::expr, error: ~str) -> ast::ident { - alt expr.node { + match expr.node { ast::expr_path(p) => { if vec::len(p.types) > 0u || vec::len(p.idents) != 1u { cx.span_fatal(expr.span, error); @@ -233,11 +233,11 @@ fn get_mac_args_no_max(cx: ext_ctxt, sp: span, arg: ast::mac_arg, fn get_mac_args(cx: ext_ctxt, sp: span, arg: ast::mac_arg, min: uint, max: option<uint>, name: ~str) -> ~[@ast::expr] { - alt arg { - some(expr) => alt expr.node { + match arg { + some(expr) => match expr.node { ast::expr_vec(elts, _) => { let elts_len = vec::len(elts); - alt max { + match max { some(max) if ! (min <= elts_len && elts_len <= max) => { cx.span_fatal(sp, fmt!{"#%s takes between %u and %u arguments.", @@ -261,7 +261,7 @@ fn get_mac_args(cx: ext_ctxt, sp: span, arg: ast::mac_arg, fn get_mac_body(cx: ext_ctxt, sp: span, args: ast::mac_body) -> ast::mac_body_ { - alt (args) { + match (args) { some(body) => body, none => cx.span_fatal(sp, ~"missing macro body") } @@ -289,10 +289,10 @@ fn tt_args_to_original_flavor(cx: ext_ctxt, sp: span, arg: ~[ast::token_tree]) let arg_reader = new_tt_reader(cx.parse_sess().span_diagnostic, cx.parse_sess().interner, none, arg); let args = - alt parse_or_else(cx.parse_sess(), cx.cfg(), arg_reader as reader, + match parse_or_else(cx.parse_sess(), cx.cfg(), arg_reader as reader, argument_gram).get(@~"arg") { @matched_seq(s, _) => do s.map() |lf| { - alt lf { + match lf { @matched_nonterminal(parse::token::nt_expr(arg)) => { arg /* whew! list of exprs, here we come! */ } diff --git a/src/libsyntax/ext/env.rs b/src/libsyntax/ext/env.rs index 143a675fa63..01030591da9 100644 --- a/src/libsyntax/ext/env.rs +++ b/src/libsyntax/ext/env.rs @@ -16,7 +16,7 @@ fn expand_syntax_ext(cx: ext_ctxt, sp: codemap::span, arg: ast::mac_arg, // option<str> rather than just an maybe-empty string. let var = expr_to_str(cx, args[0], ~"#env requires a string"); - alt os::getenv(var) { + match os::getenv(var) { option::none => return mk_uniq_str(cx, sp, ~""), option::some(s) => return mk_uniq_str(cx, sp, s) } diff --git a/src/libsyntax/ext/expand.rs b/src/libsyntax/ext/expand.rs index ee1ec62e4e2..9b50101683a 100644 --- a/src/libsyntax/ext/expand.rs +++ b/src/libsyntax/ext/expand.rs @@ -15,18 +15,18 @@ fn expand_expr(exts: hashmap<~str, syntax_extension>, cx: ext_ctxt, orig: fn@(expr_, span, ast_fold) -> (expr_, span)) -> (expr_, span) { - return alt e { + return match e { // expr_mac should really be expr_ext or something; it's the // entry-point for all syntax extensions. expr_mac(mac) => { // Old-style macros, for compatibility, will erase this whole // block once we've transitioned. - alt mac.node { + match mac.node { mac_invoc(pth, args, body) => { assert (vec::len(pth.idents) > 0u); let extname = pth.idents[0]; - alt exts.find(*extname) { + match exts.find(*extname) { none => { cx.span_fatal(pth.span, fmt!{"macro undefined: '%s'", *extname}) @@ -69,13 +69,13 @@ fn expand_expr(exts: hashmap<~str, syntax_extension>, cx: ext_ctxt, mac_invoc_tt(pth, tts) => { assert (vec::len(pth.idents) == 1u); let extname = pth.idents[0]; - alt exts.find(*extname) { + match exts.find(*extname) { none => { cx.span_fatal(pth.span, fmt!{"macro undefined: '%s'", *extname}) } some(expr_tt({expander: exp, span: exp_sp})) => { - let expanded = alt exp(cx, mac.span, tts) { + let expanded = match exp(cx, mac.span, tts) { mr_expr(e) => e, _ => cx.span_fatal( pth.span, fmt!{"non-expr macro in expr pos: %s", @@ -141,12 +141,12 @@ fn expand_mod_items(exts: hashmap<~str, syntax_extension>, cx: ext_ctxt, // 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 mname = alt attr.node.value.node { + let mname = match attr.node.value.node { ast::meta_word(n) => n, ast::meta_name_value(n, _) => n, ast::meta_list(n, _) => n }; - alt exts.find(*mname) { + match exts.find(*mname) { none | some(normal(_)) | some(macro_defining(_)) | some(expr_tt(_)) | some(item_tt(*)) => items, some(item_decorator(dec_fn)) => { @@ -166,16 +166,16 @@ fn expand_item(exts: hashmap<~str, syntax_extension>, orig: fn@(&&@ast::item, ast_fold) -> option<@ast::item>) -> option<@ast::item> { - let is_mod = alt it.node { + let is_mod = match it.node { ast::item_mod(_) | ast::item_foreign_mod(_) => true, _ => false }; - let maybe_it = alt it.node { + let maybe_it = match it.node { ast::item_mac(*) => expand_item_mac(exts, cx, it, fld), _ => some(it) }; - alt maybe_it { + match maybe_it { some(it) => { if is_mod { cx.mod_push(it.ident); } let ret_val = orig(it, fld); @@ -192,10 +192,10 @@ fn expand_item(exts: hashmap<~str, syntax_extension>, fn expand_item_mac(exts: hashmap<~str, syntax_extension>, cx: ext_ctxt, &&it: @ast::item, fld: ast_fold) -> option<@ast::item> { - alt it.node { + match it.node { item_mac({node: mac_invoc_tt(pth, tts), span}) => { let extname = pth.idents[0]; - alt exts.find(*extname) { + match exts.find(*extname) { none => { cx.span_fatal(pth.span, fmt!{"macro undefined: '%s'", *extname}) @@ -205,7 +205,7 @@ fn expand_item_mac(exts: hashmap<~str, syntax_extension>, cx.bt_push(expanded_from({call_site: it.span, callie: {name: *extname, span: expand.span}})); - let maybe_it = alt expanded { + let maybe_it = match expanded { mr_item(it) => fld.fold_item(it), mr_expr(e) => cx.span_fatal(pth.span, ~"expr macro in item position: " + diff --git a/src/libsyntax/ext/fmt.rs b/src/libsyntax/ext/fmt.rs index d1acf622c1f..19b5fefc1cf 100644 --- a/src/libsyntax/ext/fmt.rs +++ b/src/libsyntax/ext/fmt.rs @@ -52,7 +52,7 @@ fn pieces_to_expr(cx: ext_ctxt, sp: span, 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| { - let fstr = alt f { + let fstr = match f { flag_left_justify => ~"flag_left_justify", flag_left_zero_pad => ~"flag_left_zero_pad", flag_space_for_sign => ~"flag_space_for_sign", @@ -65,7 +65,7 @@ fn pieces_to_expr(cx: ext_ctxt, sp: span, return tmp_expr; } fn make_count(cx: ext_ctxt, sp: span, cnt: count) -> @ast::expr { - alt cnt { + match cnt { count_implied => { return make_rt_path_expr(cx, sp, @~"count_implied"); } @@ -80,8 +80,8 @@ fn pieces_to_expr(cx: ext_ctxt, sp: span, } fn make_ty(cx: ext_ctxt, sp: span, t: ty) -> @ast::expr { let mut rt_type; - alt t { - ty_hex(c) => alt c { + match t { + ty_hex(c) => match c { case_upper => rt_type = ~"ty_hex_upper", case_lower => rt_type = ~"ty_hex_lower" } @@ -121,8 +121,8 @@ fn pieces_to_expr(cx: ext_ctxt, sp: span, // FIXME: Move validation code into core::extfmt (Issue #2249) fn is_signed_type(cnv: conv) -> bool { - alt cnv.ty { - ty_int(s) => alt s { + match cnv.ty { + ty_int(s) => match s { signed => return true, unsigned => return false } @@ -131,12 +131,12 @@ fn pieces_to_expr(cx: ext_ctxt, sp: span, } } let unsupported = ~"conversion not supported in #fmt string"; - alt cnv.param { + match cnv.param { option::none => (), _ => cx.span_unimpl(sp, unsupported) } for cnv.flags.each |f| { - alt f { + match f { flag_left_justify => (), flag_sign_always => { if !is_signed_type(cnv) { @@ -156,19 +156,19 @@ fn pieces_to_expr(cx: ext_ctxt, sp: span, _ => cx.span_unimpl(sp, unsupported) } } - alt cnv.width { + match cnv.width { count_implied => (), count_is(_) => (), _ => cx.span_unimpl(sp, unsupported) } - alt cnv.precision { + match cnv.precision { count_implied => (), count_is(_) => (), _ => cx.span_unimpl(sp, unsupported) } - alt cnv.ty { + match cnv.ty { ty_str => return make_conv_call(cx, arg.span, ~"str", cnv, arg), - ty_int(sign) => alt sign { + ty_int(sign) => match sign { signed => return make_conv_call(cx, arg.span, ~"int", cnv, arg), unsigned => { return make_conv_call(cx, arg.span, ~"uint", cnv, arg) @@ -188,12 +188,12 @@ fn pieces_to_expr(cx: ext_ctxt, sp: span, } } fn log_conv(c: conv) { - alt c.param { + match c.param { some(p) => { log(debug, ~"param: " + int::to_str(p, 10u)); } _ => debug!{"param: none"} } for c.flags.each |f| { - alt f { + match f { flag_left_justify => debug!{"flag: left justify"}, flag_left_zero_pad => debug!{"flag: left zero pad"}, flag_space_for_sign => debug!{"flag: left space pad"}, @@ -201,7 +201,7 @@ fn pieces_to_expr(cx: ext_ctxt, sp: span, flag_alternate => debug!{"flag: alternate"} } } - alt c.width { + match c.width { count_is(i) => log( debug, ~"width: count is " + int::to_str(i, 10u)), count_is_param(i) => log( @@ -209,7 +209,7 @@ fn pieces_to_expr(cx: ext_ctxt, sp: span, count_is_next_param => debug!{"width: count is next param"}, count_implied => debug!{"width: count is implied"} } - alt c.precision { + match c.precision { count_is(i) => log( debug, ~"prec: count is " + int::to_str(i, 10u)), count_is_param(i) => log( @@ -217,16 +217,16 @@ fn pieces_to_expr(cx: ext_ctxt, sp: span, count_is_next_param => debug!{"prec: count is next param"}, count_implied => debug!{"prec: count is implied"} } - alt c.ty { + match c.ty { ty_bool => debug!{"type: bool"}, ty_str => debug!{"type: str"}, ty_char => debug!{"type: char"}, - ty_int(s) => alt s { + ty_int(s) => match s { signed => debug!{"type: signed"}, unsigned => debug!{"type: unsigned"} } ty_bits => debug!{"type: bits"}, - ty_hex(cs) => alt cs { + ty_hex(cs) => match cs { case_upper => debug!{"type: uhex"}, case_lower => debug!{"type: lhex"}, } @@ -240,7 +240,7 @@ fn pieces_to_expr(cx: ext_ctxt, sp: span, let mut piece_exprs = ~[]; let nargs = args.len(); for pieces.each |pc| { - alt pc { + match pc { piece_string(s) => { vec::push(piece_exprs, mk_uniq_str(cx, fmt_sp, s)) } diff --git a/src/libsyntax/ext/pipes/check.rs b/src/libsyntax/ext/pipes/check.rs index 59687eda96d..8595a991e24 100644 --- a/src/libsyntax/ext/pipes/check.rs +++ b/src/libsyntax/ext/pipes/check.rs @@ -44,7 +44,7 @@ impl proto_check of proto::visitor<(), (), ()> for ext_ctxt { fn visit_message(name: ident, _span: span, _tys: &[@ast::ty], this: state, next: next_state) { - alt next { + match next { some({state: next, tys: next_tys}) => { let proto = this.proto; if !proto.has_state(next) { diff --git a/src/libsyntax/ext/pipes/parse_proto.rs b/src/libsyntax/ext/pipes/parse_proto.rs index 678f5b36c45..aa553d8ae53 100644 --- a/src/libsyntax/ext/pipes/parse_proto.rs +++ b/src/libsyntax/ext/pipes/parse_proto.rs @@ -25,12 +25,12 @@ impl proto_parser of proto_parser for parser { fn parse_state(proto: protocol) { let id = self.parse_ident(); self.expect(token::COLON); - let dir = alt copy self.token { + let dir = match copy self.token { token::IDENT(n, _) => self.get_str(n), _ => fail }; self.bump(); - let dir = alt dir { + let dir = match dir { @~"send" => send, @~"recv" => recv, _ => fail @@ -64,7 +64,7 @@ impl proto_parser of proto_parser for parser { self.expect(token::RARROW); - let next = alt copy self.token { + let next = match copy self.token { token::IDENT(_, _) => { let name = self.parse_ident(); let ntys = if self.token == token::LT { diff --git a/src/libsyntax/ext/pipes/pipec.rs b/src/libsyntax/ext/pipes/pipec.rs index f61601a2aa0..16ba6d3a063 100644 --- a/src/libsyntax/ext/pipes/pipec.rs +++ b/src/libsyntax/ext/pipes/pipec.rs @@ -47,7 +47,7 @@ trait gen_init { impl compile of gen_send for message { fn gen_send(cx: ext_ctxt) -> @ast::item { debug!{"pipec: gen_send"}; - alt self { + match self { message(id, span, tys, this, some({state: next, tys: next_tys})) => { debug!{"pipec: next state exists"}; @@ -71,7 +71,7 @@ impl compile of gen_send for message { let mut body = ~"{\n"; if this.proto.is_bounded() { - let (sp, rp) = alt (this.dir, next.dir) { + let (sp, rp) = match (this.dir, next.dir) { (send, send) => (~"c", ~"s"), (send, recv) => (~"s", ~"c"), (recv, send) => (~"s", ~"c"), @@ -87,7 +87,7 @@ impl compile of gen_send for message { rp, *next.name}; } else { - let pat = alt (this.dir, next.dir) { + let pat = match (this.dir, next.dir) { (send, send) => ~"(c, s)", (send, recv) => ~"(s, c)", (recv, send) => ~"(s, c)", @@ -181,12 +181,12 @@ impl compile of to_type_decls for state { for self.messages.each |m| { let message(name, _span, tys, this, next) = m; - let tys = alt next { + let tys = match next { some({state: next, tys: next_tys}) => { let next = this.proto.get_state(next); let next_name = next.data_name(); - let dir = alt this.dir { + let dir = match this.dir { send => @~"server", recv => @~"client" }; @@ -208,7 +208,7 @@ impl compile of to_type_decls for state { fn to_endpoint_decls(cx: ext_ctxt, dir: direction) -> ~[@ast::item] { debug!{"pipec: to_endpoint_decls"}; - let dir = alt dir { + let dir = match dir { send => (*self).dir, recv => (*self).dir.reverse() }; @@ -255,7 +255,7 @@ impl compile of gen_init for protocol { let start_state = self.states[0]; let body = if !self.is_bounded() { - alt start_state.dir { + match start_state.dir { send => #ast { pipes::entangle() }, recv => { #ast {{ @@ -267,7 +267,7 @@ impl compile of gen_init for protocol { } else { let body = self.gen_init_bounded(ext_cx); - alt start_state.dir { + match start_state.dir { send => body, recv => { #ast {{ @@ -322,7 +322,7 @@ impl compile of gen_init for protocol { let mut params: ~[ast::ty_param] = ~[]; for (copy self.states).each |s| { for s.ty_params.each |tp| { - alt params.find(|tpp| *tp.ident == *tpp.ident) { + match params.find(|tpp| *tp.ident == *tpp.ident) { none => vec::push(params, tp), _ => () } @@ -338,7 +338,7 @@ impl compile of gen_init for protocol { let mut params: ~[ast::ty_param] = ~[]; let fields = do (copy self.states).map_to_vec |s| { for s.ty_params.each |tp| { - alt params.find(|tpp| *tp.ident == *tpp.ident) { + match params.find(|tpp| *tp.ident == *tpp.ident) { none => vec::push(params, tp), _ => () } @@ -439,7 +439,7 @@ impl parse_utils of ext_ctxt_parse_utils for ext_ctxt { self.cfg(), ~[], self.parse_sess()); - alt res { + match res { some(ast) => ast, none => { error!{"Parse error with ```\n%s\n```", s}; diff --git a/src/libsyntax/ext/pipes/proto.rs b/src/libsyntax/ext/pipes/proto.rs index bd9ea96ee33..5769125225e 100644 --- a/src/libsyntax/ext/pipes/proto.rs +++ b/src/libsyntax/ext/pipes/proto.rs @@ -11,7 +11,7 @@ enum direction { impl of to_str for direction { fn to_str() -> ~str { - alt self { + match self { send => ~"send", recv => ~"recv" } @@ -20,7 +20,7 @@ impl of to_str for direction { impl methods for direction { fn reverse() -> direction { - alt self { + match self { send => recv, recv => send } @@ -36,20 +36,20 @@ enum message { impl methods for message { fn name() -> ident { - alt self { + match self { message(id, _, _, _, _) => id } } fn span() -> span { - alt self { + match self { message(_, span, _, _, _) => span } } /// Return the type parameters actually used by this message fn get_params() -> ~[ast::ty_param] { - alt self { + match self { message(_, _, _, this, _) => this.ty_params } } @@ -92,7 +92,7 @@ impl methods for state { /// from this state. fn reachable(f: fn(state) -> bool) { for self.messages.each |m| { - alt m { + match m { message(_, _, _, _, some({state: id, _})) => { let state = self.proto.get_state(id); if !f(state) { break } diff --git a/src/libsyntax/ext/qquote.rs b/src/libsyntax/ext/qquote.rs index 21ba9599240..491d6104c7b 100644 --- a/src/libsyntax/ext/qquote.rs +++ b/src/libsyntax/ext/qquote.rs @@ -48,7 +48,7 @@ impl of qq_helper for @ast::expr { fn span() -> span {self.span} fn visit(cx: aq_ctxt, v: vt<aq_ctxt>) {visit_expr(self, cx, v);} fn extract_mac() -> option<ast::mac_> { - alt (self.node) { + match (self.node) { ast::expr_mac({node: mac, _}) => some(mac), _ => none } @@ -63,7 +63,7 @@ impl of qq_helper for @ast::ty { fn span() -> span {self.span} fn visit(cx: aq_ctxt, v: vt<aq_ctxt>) {visit_ty(self, cx, v);} fn extract_mac() -> option<ast::mac_> { - alt (self.node) { + match (self.node) { ast::ty_mac({node: mac, _}) => some(mac), _ => none } @@ -124,7 +124,7 @@ fn gather_anti_quotes<N: qq_helper>(lo: uint, node: N) -> aq_ctxt fn visit_aq<T:qq_helper>(node: T, constr: ~str, &&cx: aq_ctxt, v: vt<aq_ctxt>) { - alt (node.extract_mac()) { + match (node.extract_mac()) { some(mac_aq(sp, e)) => { cx.gather.push(gather_item { lo: sp.lo - cx.lo, @@ -147,7 +147,7 @@ fn expand_ast(ecx: ext_ctxt, _sp: span, let mut what = ~"expr"; do option::iter(arg) |arg| { let args: ~[@ast::expr] = - alt arg.node { + match arg.node { ast::expr_vec(elts, _) => elts, _ => { ecx.span_fatal @@ -157,7 +157,7 @@ fn expand_ast(ecx: ext_ctxt, _sp: span, if vec::len::<@ast::expr>(args) != 1u { ecx.span_fatal(_sp, ~"#ast requires exactly one arg"); } - alt (args[0].node) { + match (args[0].node) { ast::expr_path(@{idents: id, _}) if vec::len(id) == 1u => what = *id[0], _ => ecx.span_fatal(args[0].span, ~"expected an identifier") @@ -165,7 +165,7 @@ fn expand_ast(ecx: ext_ctxt, _sp: span, } let body = get_mac_body(ecx,_sp,body); - return alt what { + return match what { ~"crate" => finish(ecx, body, parse_crate), ~"expr" => finish(ecx, body, parse_expr), ~"ty" => finish(ecx, body, parse_ty), @@ -183,7 +183,7 @@ fn parse_expr(p: parser) -> @ast::expr { p.parse_expr() } fn parse_pat(p: parser) -> @ast::pat { p.parse_pat(true) } fn parse_item(p: parser) -> @ast::item { - alt p.parse_item(~[]) { + match p.parse_item(~[]) { some(item) => item, none => fail ~"parse_item: parsing an item failed" } @@ -225,7 +225,7 @@ fn finish<T: qq_helper> state = skip(str::char_len(repl)); str2 += repl; } - alt copy state { + match copy state { active => str::push_char(str2, ch), skip(1u) => state = blank, skip(sk) => state = skip (sk-1u), @@ -308,8 +308,8 @@ fn replace_expr(repls: ~[fragment], orig: fn@(ast::expr_, span, ast_fold)->(ast::expr_, span)) -> (ast::expr_, span) { - alt e { - ast::expr_mac({node: mac_var(i), _}) => alt (repls[i]) { + match e { + ast::expr_mac({node: mac_var(i), _}) => match (repls[i]) { from_expr(r) => (r.node, r.span), _ => fail /* fixme error message */ } @@ -322,8 +322,8 @@ fn replace_ty(repls: ~[fragment], orig: fn@(ast::ty_, span, ast_fold)->(ast::ty_, span)) -> (ast::ty_, span) { - alt e { - ast::ty_mac({node: mac_var(i), _}) => alt (repls[i]) { + match e { + ast::ty_mac({node: mac_var(i), _}) => match (repls[i]) { from_ty(r) => (r.node, r.span), _ => fail /* fixme error message */ } diff --git a/src/libsyntax/ext/simplext.rs b/src/libsyntax/ext/simplext.rs index 79b609113ab..bdb0c663fc7 100644 --- a/src/libsyntax/ext/simplext.rs +++ b/src/libsyntax/ext/simplext.rs @@ -36,7 +36,7 @@ enum matchable { /* for when given an incompatible bit of AST */ fn match_error(cx: ext_ctxt, m: matchable, expected: ~str) -> ! { - alt m { + match m { match_expr(x) => cx.span_fatal( x.span, ~"this argument is an expr, expected " + expected), match_path(x) => cx.span_fatal( @@ -65,8 +65,8 @@ fn elts_to_ell(cx: ext_ctxt, elts: ~[@expr]) -> let mut idx: uint = 0u; let mut res = none; for elts.each |elt| { - alt elt.node { - expr_mac(m) => alt m.node { + match elt.node { + expr_mac(m) => match m.node { ast::mac_ellipsis => { if res != none { cx.span_fatal(m.span, ~"only one ellipsis allowed"); @@ -82,7 +82,7 @@ fn elts_to_ell(cx: ext_ctxt, elts: ~[@expr]) -> } idx += 1u; } - return alt res { + return match res { some(val) => val, none => {pre: elts, rep: none, post: ~[]} } @@ -92,7 +92,7 @@ fn option_flatten_map<T: copy, U: copy>(f: fn@(T) -> option<U>, v: ~[T]) -> option<~[U]> { let mut res = ~[]; for v.each |elem| { - alt f(elem) { + match f(elem) { none => return none, some(fv) => vec::push(res, fv) } @@ -101,9 +101,9 @@ fn option_flatten_map<T: copy, U: copy>(f: fn@(T) -> option<U>, v: ~[T]) -> } fn a_d_map(ad: arb_depth<matchable>, f: selector) -> match_result { - alt ad { + match ad { leaf(x) => return f(x), - seq(ads, span) => alt option_flatten_map(|x| a_d_map(x, f), *ads) { + seq(ads, span) => match option_flatten_map(|x| a_d_map(x, f), *ads) { none => return none, some(ts) => return some(seq(@ts, span)) } @@ -112,7 +112,7 @@ fn a_d_map(ad: arb_depth<matchable>, f: selector) -> match_result { fn compose_sels(s1: selector, s2: selector) -> selector { fn scomp(s1: selector, s2: selector, m: matchable) -> match_result { - return alt s1(m) { + return match s1(m) { none => none, some(matches) => a_d_map(matches, s2) } @@ -156,11 +156,11 @@ 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| { - alt sel(match_expr(e)) { none => return none, _ => () } + match sel(match_expr(e)) { none => return none, _ => () } } let mut never_mind: bool = false; for b.real_binders.each |key, val| { - alt val(match_expr(e)) { + match val(match_expr(e)) { none => never_mind = true, some(mtc) => { res.insert(key, mtc); } } @@ -209,7 +209,7 @@ 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| { - res = alt res { + res = match res { leaf(_) => return res,/* end of the line */ seq(new_ms, _) => new_ms[idx] } @@ -219,10 +219,10 @@ fn follow(m: arb_depth<matchable>, idx_path: @mut ~[uint]) -> fn follow_for_trans(cx: ext_ctxt, mmaybe: option<arb_depth<matchable>>, idx_path: @mut ~[uint]) -> option<matchable> { - alt mmaybe { + match mmaybe { none => return none, some(m) => { - return alt follow(m, idx_path) { + return match follow(m, idx_path) { seq(_, sp) => { cx.span_fatal(sp, ~"syntax matched under ... but not " + @@ -258,10 +258,10 @@ fn free_vars(b: bindings, e: @expr, it: fn(ident)) { fn transcribe_exprs(cx: ext_ctxt, b: bindings, idx_path: @mut ~[uint], recur: fn@(&&@expr) -> @expr, exprs: ~[@expr]) -> ~[@expr] { - alt elts_to_ell(cx, exprs) { + match elts_to_ell(cx, exprs) { {pre: pre, rep: repeat_me_maybe, post: post} => { let mut res = vec::map(pre, recur); - alt repeat_me_maybe { + match repeat_me_maybe { none => (), some(repeat_me) => { let mut repeat: option<{rep_count: uint, name: ident}> = none; @@ -269,10 +269,10 @@ fn transcribe_exprs(cx: ext_ctxt, b: bindings, idx_path: @mut ~[uint], the leaves, which are just duplicated */ do free_vars(b, repeat_me) |fv| { let cur_pos = follow(b.get(fv), idx_path); - alt cur_pos { + match cur_pos { leaf(_) => (), seq(ms, _) => { - alt repeat { + match repeat { none => { repeat = some({rep_count: vec::len(*ms), name: fv}); } @@ -290,7 +290,7 @@ fn transcribe_exprs(cx: ext_ctxt, b: bindings, idx_path: @mut ~[uint], } } }; - alt repeat { + match repeat { none => { cx.span_fatal(repeat_me.span, ~"'...' surrounds an expression without any" + @@ -320,7 +320,7 @@ fn transcribe_exprs(cx: ext_ctxt, b: bindings, idx_path: @mut ~[uint], // substitute, in a position that's required to be an ident fn transcribe_ident(cx: ext_ctxt, b: bindings, idx_path: @mut ~[uint], &&i: ident, _fld: ast_fold) -> ident { - return alt follow_for_trans(cx, b.find(i), idx_path) { + return match follow_for_trans(cx, b.find(i), idx_path) { some(match_ident(a_id)) => a_id.node, some(m) => match_error(cx, m, ~"an identifier"), none => i @@ -332,7 +332,7 @@ fn transcribe_path(cx: ext_ctxt, b: bindings, idx_path: @mut ~[uint], p: path, _fld: ast_fold) -> path { // Don't substitute into qualified names. if vec::len(p.types) > 0u || vec::len(p.idents) != 1u { return p; } - alt follow_for_trans(cx, b.find(p.idents[0]), idx_path) { + match follow_for_trans(cx, b.find(p.idents[0]), idx_path) { some(match_ident(id)) => { {span: id.span, global: false, idents: ~[id.node], rp: none, types: ~[]} @@ -349,13 +349,13 @@ fn transcribe_expr(cx: ext_ctxt, b: bindings, idx_path: @mut ~[uint], orig: fn@(ast::expr_, span, ast_fold)->(ast::expr_, span)) -> (ast::expr_, span) { - return alt e { + return match e { expr_path(p) => { // Don't substitute into qualified names. if vec::len(p.types) > 0u || vec::len(p.idents) != 1u { (e, s); } - alt follow_for_trans(cx, b.find(p.idents[0]), idx_path) { + match follow_for_trans(cx, b.find(p.idents[0]), idx_path) { some(match_ident(id)) => { (expr_path(@{span: id.span, global: false, @@ -378,11 +378,11 @@ fn transcribe_type(cx: ext_ctxt, b: bindings, idx_path: @mut ~[uint], orig: fn@(ast::ty_, span, ast_fold) -> (ast::ty_, span)) -> (ast::ty_, span) { - return alt t { + return match t { ast::ty_path(pth, _) => { - alt path_to_ident(pth) { + match path_to_ident(pth) { some(id) => { - alt follow_for_trans(cx, b.find(id), idx_path) { + match follow_for_trans(cx, b.find(id), idx_path) { some(match_ty(ty)) => (ty.node, ty.span), some(m) => match_error(cx, m, ~"a type"), none => orig(t, s, fld) @@ -404,9 +404,9 @@ fn transcribe_block(cx: ext_ctxt, b: bindings, idx_path: @mut ~[uint], orig: fn@(blk_, span, ast_fold) -> (blk_, span)) -> (blk_, span) { - return alt block_to_ident(blk) { + return match block_to_ident(blk) { some(id) => { - alt follow_for_trans(cx, b.find(id), idx_path) { + match follow_for_trans(cx, b.find(id), idx_path) { some(match_block(new_blk)) => (new_blk.node, new_blk.span), // possibly allow promotion of ident/path/expr to blocks? @@ -424,12 +424,12 @@ argument. ps accumulates instructions on navigating the tree.*/ fn p_t_s_rec(cx: ext_ctxt, m: matchable, s: selector, b: binders) { //it might be possible to traverse only exprs, not matchables - alt m { + match m { match_expr(e) => { - alt e.node { + match e.node { expr_path(p_pth) => p_t_s_r_path(cx, p_pth, s, b), expr_vec(p_elts, _) => { - alt elts_to_ell(cx, p_elts) { + match elts_to_ell(cx, p_elts) { {pre: pre, rep: some(repeat_me), post: post} => { p_t_s_r_length(cx, vec::len(pre) + vec::len(post), true, s, b); @@ -459,7 +459,7 @@ fn p_t_s_rec(cx: ext_ctxt, m: matchable, s: selector, b: binders) { _ => { fn select(cx: ext_ctxt, m: matchable, pat: @expr) -> match_result { - return alt m { + return match m { match_expr(e) => { if e == pat { some(leaf(match_exact)) } else { none } } @@ -477,11 +477,11 @@ fn p_t_s_rec(cx: ext_ctxt, m: matchable, s: selector, b: binders) { /* make a match more precise */ fn specialize_match(m: matchable) -> matchable { - return alt m { + return match m { match_expr(e) => { - alt e.node { + match e.node { expr_path(pth) => { - alt path_to_ident(pth) { + match path_to_ident(pth) { some(id) => match_ident(respan(pth.span, id)), none => match_path(pth) } @@ -495,10 +495,10 @@ fn specialize_match(m: matchable) -> matchable { /* pattern_to_selectors helper functions */ fn p_t_s_r_path(cx: ext_ctxt, p: @path, s: selector, b: binders) { - alt path_to_ident(p) { + match path_to_ident(p) { some(p_id) => { fn select(cx: ext_ctxt, m: matchable) -> match_result { - return alt m { + return match m { match_expr(e) => some(leaf(specialize_match(m))), _ => cx.bug(~"broken traversal in p_t_s_r") } @@ -514,8 +514,8 @@ fn p_t_s_r_path(cx: ext_ctxt, p: @path, s: selector, b: binders) { fn block_to_ident(blk: blk_) -> option<ident> { if vec::len(blk.stmts) != 0u { return none; } - return alt blk.expr { - some(expr) => alt expr.node { + return match blk.expr { + some(expr) => match expr.node { expr_path(pth) => path_to_ident(pth), _ => none } @@ -526,8 +526,8 @@ fn block_to_ident(blk: blk_) -> option<ident> { fn p_t_s_r_mac(cx: ext_ctxt, mac: ast::mac, _s: selector, _b: binders) { fn select_pt_1(cx: ext_ctxt, m: matchable, fn_m: fn(ast::mac) -> match_result) -> match_result { - return alt m { - match_expr(e) => alt e.node { + return match m { + match_expr(e) => match e.node { expr_mac(mac) => fn_m(mac), _ => none } @@ -537,7 +537,7 @@ fn p_t_s_r_mac(cx: ext_ctxt, mac: ast::mac, _s: selector, _b: binders) { fn no_des(cx: ext_ctxt, sp: span, syn: ~str) -> ! { cx.span_fatal(sp, ~"destructuring " + syn + ~" is not yet supported"); } - alt mac.node { + match mac.node { ast::mac_ellipsis => cx.span_fatal(mac.span, ~"misused `...`"), ast::mac_invoc(_, _, _) => no_des(cx, mac.span, ~"macro calls"), ast::mac_invoc_tt(_, _) => no_des(cx, mac.span, ~"macro calls"), @@ -550,9 +550,9 @@ fn p_t_s_r_ellipses(cx: ext_ctxt, repeat_me: @expr, offset: uint, s: selector, b: binders) { fn select(cx: ext_ctxt, repeat_me: @expr, offset: uint, m: matchable) -> match_result { - return alt m { + return match m { match_expr(e) => { - alt e.node { + match e.node { expr_vec(arg_elts, _) => { let mut elts = ~[]; let mut idx = offset; @@ -580,9 +580,9 @@ fn p_t_s_r_length(cx: ext_ctxt, len: uint, at_least: bool, s: selector, b: binders) { fn len_select(_cx: ext_ctxt, m: matchable, at_least: bool, len: uint) -> match_result { - return alt m { + return match m { match_expr(e) => { - alt e.node { + match e.node { expr_vec(arg_elts, _) => { let actual_len = vec::len(arg_elts); if at_least && actual_len >= len || actual_len == len { @@ -604,9 +604,9 @@ fn p_t_s_r_actual_vector(cx: ext_ctxt, elts: ~[@expr], _repeat_after: bool, let mut idx: uint = 0u; while idx < vec::len(elts) { fn select(cx: ext_ctxt, m: matchable, idx: uint) -> match_result { - return alt m { + return match m { match_expr(e) => { - alt e.node { + match e.node { expr_vec(arg_elts, _) => { some(leaf(match_expr(arg_elts[idx]))) } @@ -629,7 +629,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| { - alt arg.node { + match arg.node { expr_vec(elts, mutbl) => { if vec::len(elts) != 2u { cx.span_fatal((*arg).span, @@ -638,12 +638,12 @@ fn add_new_extension(cx: ext_ctxt, sp: span, arg: ast::mac_arg, } - alt elts[0u].node { + match elts[0u].node { expr_mac(mac) => { - alt mac.node { + match mac.node { mac_invoc(pth, invoc_arg, body) => { - alt path_to_ident(pth) { - some(id) => alt macro_name { + match path_to_ident(pth) { + some(id) => match macro_name { none => macro_name = some(id), some(other_id) => if id != other_id { cx.span_fatal(pth.span, @@ -654,7 +654,7 @@ fn add_new_extension(cx: ext_ctxt, sp: span, arg: ast::mac_arg, none => cx.span_fatal(pth.span, ~"macro name must not be a path") } - let arg = alt invoc_arg { + let arg = match invoc_arg { some(arg) => arg, none => cx.span_fatal(mac.span, ~"macro must have arguments") @@ -689,7 +689,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); return {ident: - alt macro_name { + match macro_name { some(id) => id, none => cx.span_fatal(sp, ~"macro definition must have " + ~"at least one clause") @@ -699,12 +699,12 @@ fn add_new_extension(cx: ext_ctxt, sp: span, arg: ast::mac_arg, fn generic_extension(cx: ext_ctxt, sp: span, arg: ast::mac_arg, _body: ast::mac_body, clauses: ~[@clause]) -> @expr { - let arg = alt arg { + let arg = match arg { some(arg) => arg, none => cx.span_fatal(sp, ~"macro must have arguments") }; for clauses.each |c| { - alt use_selectors_to_bind(c.params, arg) { + match use_selectors_to_bind(c.params, arg) { some(bindings) => return transcribe(cx, bindings, c.body), none => again } diff --git a/src/libsyntax/ext/source_util.rs b/src/libsyntax/ext/source_util.rs index c55f1e67be2..3fdd5239e65 100644 --- a/src/libsyntax/ext/source_util.rs +++ b/src/libsyntax/ext/source_util.rs @@ -70,7 +70,7 @@ fn expand_include_str(cx: ext_ctxt, sp: codemap::span, arg: ast::mac_arg, let file = expr_to_str(cx, args[0], ~"#include_str requires a string"); let res = io::read_whole_file_str(res_rel_file(cx, sp, file)); - alt res { + match res { result::ok(_) => { /* Continue. */ } result::err(e) => { cx.parse_sess().span_diagnostic.handler().fatal(e); @@ -86,7 +86,7 @@ fn expand_include_bin(cx: ext_ctxt, sp: codemap::span, arg: ast::mac_arg, let file = expr_to_str(cx, args[0], ~"#include_bin requires a string"); - alt io::read_whole_file(res_rel_file(cx, sp, file)) { + match io::read_whole_file(res_rel_file(cx, sp, file)) { result::ok(src) => { let u8_exprs = vec::map(src, |char: u8| { mk_u8(cx, sp, char) diff --git a/src/libsyntax/ext/tt/earley_parser.rs b/src/libsyntax/ext/tt/earley_parser.rs index 6a801f33aa6..f1c7ebb7dad 100644 --- a/src/libsyntax/ext/tt/earley_parser.rs +++ b/src/libsyntax/ext/tt/earley_parser.rs @@ -31,7 +31,7 @@ enum matcher_pos_up { /* to break a circularity */ } fn is_some(&&mpu: matcher_pos_up) -> bool { - alt mpu { + match mpu { matcher_pos_up(none) => false, _ => true } @@ -48,7 +48,7 @@ type matcher_pos = ~{ }; fn copy_up(&& mpu: matcher_pos_up) -> matcher_pos { - alt mpu { + match mpu { matcher_pos_up(some(mp)) => copy mp, _ => fail } @@ -56,7 +56,7 @@ fn copy_up(&& mpu: matcher_pos_up) -> matcher_pos { fn count_names(ms: &[matcher]) -> uint { vec::foldl(0u, ms, |ct, m| { - ct + alt m.node { + ct + match m.node { match_tok(_) => 0u, match_seq(more_ms, _, _, _, _) => count_names(more_ms), match_nonterminal(_,_,_) => 1u @@ -68,7 +68,7 @@ fn initial_matcher_pos(ms: ~[matcher], sep: option<token>, lo: uint) -> matcher_pos { let mut match_idx_hi = 0u; for ms.each() |elt| { - alt elt.node { + match elt.node { match_tok(_) => (), match_seq(_,_,_,_,hi) => { match_idx_hi = hi; // it is monotonic... @@ -113,7 +113,7 @@ fn nameize(p_s: parse_sess, ms: ~[matcher], res: ~[@named_match]) -> hashmap<ident,@named_match> { fn n_rec(p_s: parse_sess, m: matcher, res: ~[@named_match], ret_val: hashmap<ident, @named_match>) { - alt m { + match m { {node: match_tok(_), span: _} => (), {node: match_seq(more_ms, _, _, _, _), span: _} => { for more_ms.each() |next_m| { n_rec(p_s, next_m, res, ret_val) }; @@ -139,7 +139,7 @@ enum parse_result { fn parse_or_else(sess: parse_sess, cfg: ast::crate_cfg, rdr: reader, ms: ~[matcher]) -> hashmap<ident, @named_match> { - alt parse(sess, cfg, rdr, ms) { + match parse(sess, cfg, rdr, ms) { success(m) => m, failure(sp, str) => sess.span_diagnostic.span_fatal(sp, str) } @@ -202,7 +202,7 @@ fn parse(sess: parse_sess, cfg: ast::crate_cfg, rdr: reader, ms: ~[matcher]) // can we go around again? // the *_t vars are workarounds for the lack of unary move - alt copy ei.sep { + match copy ei.sep { some(t) if idx == len => { // we need a separator if tok == t { //pass the separator let ei_t <- ei; @@ -220,7 +220,7 @@ fn parse(sess: parse_sess, cfg: ast::crate_cfg, rdr: reader, ms: ~[matcher]) vec::push(eof_eis, ei); } } else { - alt copy ei.elts[idx].node { + match copy ei.elts[idx].node { /* need to descend into sequence */ match_seq(matchers, sep, zero_ok, match_idx_lo, match_idx_hi) => { @@ -270,7 +270,7 @@ fn parse(sess: parse_sess, cfg: ast::crate_cfg, rdr: reader, ms: ~[matcher]) if (bb_eis.len() > 0u && next_eis.len() > 0u) || bb_eis.len() > 1u { let nts = str::connect(vec::map(bb_eis, |ei| { - alt ei.elts[ei.idx].node { + match ei.elts[ei.idx].node { match_nonterminal(bind,name,_) => { fmt!{"%s ('%s')", *name, *bind} } @@ -293,7 +293,7 @@ fn parse(sess: parse_sess, cfg: ast::crate_cfg, rdr: reader, ms: ~[matcher]) let rust_parser = parser(sess, cfg, rdr.dup(), SOURCE_FILE); let ei = vec::pop(bb_eis); - alt ei.elts[ei.idx].node { + match ei.elts[ei.idx].node { match_nonterminal(_, name, idx) => { ei.matches[idx].push(@matched_nonterminal( parse_nt(rust_parser, *name))); @@ -318,8 +318,8 @@ fn parse(sess: parse_sess, cfg: ast::crate_cfg, rdr: reader, ms: ~[matcher]) } fn parse_nt(p: parser, name: ~str) -> nonterminal { - alt name { - ~"item" => alt p.parse_item(~[]) { + match name { + ~"item" => match p.parse_item(~[]) { some(i) => token::nt_item(i), none => p.fatal(~"expected an item keyword") } @@ -329,7 +329,7 @@ fn parse_nt(p: parser, name: ~str) -> nonterminal { ~"expr" => token::nt_expr(p.parse_expr()), ~"ty" => token::nt_ty(p.parse_ty(false /* no need to disambiguate*/)), // this could be handled like a token, since it is one - ~"ident" => alt copy p.token { + ~"ident" => match copy p.token { token::IDENT(sn,b) => { p.bump(); token::nt_ident(sn,b) } _ => p.fatal(~"expected ident, found " + token::to_str(*p.reader.interner(), copy p.token)) diff --git a/src/libsyntax/ext/tt/macro_rules.rs b/src/libsyntax/ext/tt/macro_rules.rs index b4fc1f5c484..a870928d50b 100644 --- a/src/libsyntax/ext/tt/macro_rules.rs +++ b/src/libsyntax/ext/tt/macro_rules.rs @@ -37,11 +37,11 @@ fn add_new_extension(cx: ext_ctxt, sp: span, name: ident, arg_reader as reader, argument_gram); // Extract the arguments: - let lhses:~[@named_match] = alt argument_map.get(@~"lhs") { + let lhses:~[@named_match] = match argument_map.get(@~"lhs") { @matched_seq(s, sp) => s, _ => cx.span_bug(sp, ~"wrong-structured lhs") }; - let rhses:~[@named_match] = alt argument_map.get(@~"rhs") { + let rhses:~[@named_match] = match argument_map.get(@~"rhs") { @matched_seq(s, sp) => s, _ => cx.span_bug(sp, ~"wrong-structured rhs") }; @@ -58,13 +58,14 @@ fn add_new_extension(cx: ext_ctxt, sp: span, name: ident, let itr = cx.parse_sess().interner; for lhses.eachi() |i, lhs| { // try each arm's matchers - alt lhs { + match lhs { @matched_nonterminal(nt_matchers(mtcs)) => { // `none` is because we're not interpolating let arg_rdr = new_tt_reader(s_d, itr, none, arg) as reader; - alt parse(cx.parse_sess(), cx.cfg(), arg_rdr, mtcs) { + match parse(cx.parse_sess(), cx.cfg(), arg_rdr, mtcs) { success(named_matches) => { - let rhs = alt rhses[i] { // okay, what's your transcriber? + let rhs = match rhses[i] { + // okay, what's your transcriber? @matched_nonterminal(nt_tt(@tt)) => tt, _ => cx.span_bug(sp, ~"bad thing in rhs") }; diff --git a/src/libsyntax/ext/tt/transcribe.rs b/src/libsyntax/ext/tt/transcribe.rs index c704fd351ec..693b538ec6d 100644 --- a/src/libsyntax/ext/tt/transcribe.rs +++ b/src/libsyntax/ext/tt/transcribe.rs @@ -46,7 +46,7 @@ fn new_tt_reader(sp_diag: span_handler, itr: @interner<@~str>, let r = @{sp_diag: sp_diag, interner: itr, mut cur: @{readme: src, mut idx: 0u, dotdotdoted: false, sep: none, up: tt_frame_up(option::none)}, - interpolations: alt interp { /* just a convienience */ + interpolations: match interp { /* just a convienience */ none => std::map::box_str_hash::<@named_match>(), some(x) => x }, @@ -61,7 +61,7 @@ fn new_tt_reader(sp_diag: span_handler, itr: @interner<@~str>, pure fn dup_tt_frame(&&f: tt_frame) -> tt_frame { @{readme: f.readme, mut idx: f.idx, dotdotdoted: f.dotdotdoted, - sep: f.sep, up: alt f.up { + sep: f.sep, up: match f.up { tt_frame_up(some(up_frame)) => { tt_frame_up(some(dup_tt_frame(up_frame))) } @@ -82,7 +82,7 @@ pure fn dup_tt_reader(&&r: tt_reader) -> tt_reader { pure fn lookup_cur_matched_by_matched(r: tt_reader, start: @named_match) -> @named_match { pure fn red(&&ad: @named_match, &&idx: uint) -> @named_match { - alt *ad { + match *ad { matched_nonterminal(_) => { // end of the line; duplicate henceforth ad @@ -102,10 +102,10 @@ enum lis { fn lockstep_iter_size(&&t: token_tree, &&r: tt_reader) -> lis { fn lis_merge(lhs: lis, rhs: lis) -> lis { - alt lhs { + match lhs { lis_unconstrained => rhs, lis_contradiction(_) => lhs, - lis_constraint(l_len, l_id) => alt rhs { + lis_constraint(l_len, l_id) => match rhs { lis_unconstrained => lhs, lis_contradiction(_) => rhs, lis_constraint(r_len, _) if l_len == r_len => lhs, @@ -117,13 +117,13 @@ fn lockstep_iter_size(&&t: token_tree, &&r: tt_reader) -> lis { } } } - alt t { + match t { tt_delim(tts) | tt_seq(_, tts, _, _) => { vec::foldl(lis_unconstrained, tts, {|lis, tt| lis_merge(lis, lockstep_iter_size(tt, r)) }) } tt_tok(*) => lis_unconstrained, - tt_nonterminal(_, name) => alt *lookup_cur_matched(r, name) { + tt_nonterminal(_, name) => match *lookup_cur_matched(r, name) { matched_nonterminal(_) => lis_unconstrained, matched_seq(ads, _) => lis_constraint(ads.len(), name) } @@ -138,7 +138,7 @@ fn tt_next_token(&&r: tt_reader) -> {tok: token, sp: span} { if ! r.cur.dotdotdoted || r.repeat_idx.last() == r.repeat_len.last() - 1 { - alt r.cur.up { + match r.cur.up { tt_frame_up(none) => { r.cur_tok = EOF; return ret_val; @@ -156,7 +156,7 @@ fn tt_next_token(&&r: tt_reader) -> {tok: token, sp: span} { } else { /* repeat */ r.cur.idx = 0u; r.repeat_idx[r.repeat_idx.len() - 1u] += 1u; - alt r.cur.sep { + match r.cur.sep { some(tk) => { r.cur_tok = tk; /* repeat same span, I guess */ return ret_val; @@ -167,7 +167,7 @@ fn tt_next_token(&&r: tt_reader) -> {tok: token, sp: span} { } loop { /* because it's easiest, this handles `tt_delim` not starting with a `tt_tok`, even though it won't happen */ - alt r.cur.readme[r.cur.idx] { + match r.cur.readme[r.cur.idx] { tt_delim(tts) => { r.cur = @{readme: tts, mut idx: 0u, dotdotdoted: false, sep: none, up: tt_frame_up(option::some(r.cur)) }; @@ -179,7 +179,7 @@ fn tt_next_token(&&r: tt_reader) -> {tok: token, sp: span} { return ret_val; } tt_seq(sp, tts, sep, zerok) => { - alt lockstep_iter_size(tt_seq(sp, tts, sep, zerok), r) { + match lockstep_iter_size(tt_seq(sp, tts, sep, zerok), r) { lis_unconstrained => { r.sp_diag.span_fatal( sp, /* blame macro writer */ @@ -212,7 +212,7 @@ fn tt_next_token(&&r: tt_reader) -> {tok: token, sp: span} { } // FIXME #2887: think about span stuff here tt_nonterminal(sp, ident) => { - alt *lookup_cur_matched(r, ident) { + match *lookup_cur_matched(r, ident) { /* sidestep the interpolation tricks for ident because (a) idents can be in lots of places, so it'd be a pain (b) we actually can, since it's a token. */ diff --git a/src/libsyntax/fold.rs b/src/libsyntax/fold.rs index 71c23ff4fa6..40c676f8b80 100644 --- a/src/libsyntax/fold.rs +++ b/src/libsyntax/fold.rs @@ -80,7 +80,7 @@ type ast_fold_precursor = @{ //used in noop_fold_item and noop_fold_crate and noop_fold_crate_directive fn fold_meta_item_(&&mi: @meta_item, fld: ast_fold) -> @meta_item { return @{node: - alt mi.node { + match 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); @@ -112,7 +112,7 @@ fn fold_arg_(a: arg, fld: ast_fold) -> arg { //used in noop_fold_expr, and possibly elsewhere in the future fn fold_mac_(m: mac, fld: ast_fold) -> mac { return {node: - alt m.node { + match m.node { mac_invoc(pth, arg, body) => { mac_invoc(fld.fold_path(pth), option::map(arg, |x| fld.fold_expr(x)), body) @@ -133,7 +133,7 @@ fn fold_fn_decl(decl: ast::fn_decl, fld: ast_fold) -> ast::fn_decl { } fn fold_ty_param_bound(tpb: ty_param_bound, fld: ast_fold) -> ty_param_bound { - alt tpb { + match tpb { bound_copy | bound_send | bound_const | bound_owned => tpb, bound_trait(ty) => bound_trait(fld.fold_ty(ty)) } @@ -163,7 +163,7 @@ fn noop_fold_crate(c: crate_, fld: ast_fold) -> crate_ { fn noop_fold_crate_directive(cd: crate_directive_, fld: ast_fold) -> crate_directive_ { - return alt cd { + return match cd { cdir_src_mod(id, attrs) => { cdir_src_mod(fld.fold_ident(id), /* FIXME (#2543) */ copy attrs) } @@ -190,7 +190,7 @@ fn noop_fold_foreign_item(&&ni: @foreign_item, fld: ast_fold) return @{ident: fld.fold_ident(ni.ident), attrs: vec::map(ni.attrs, fold_attribute), node: - alt ni.node { + match ni.node { foreign_item_fn(fdec, typms) => { foreign_item_fn({inputs: vec::map(fdec.inputs, fold_arg), output: fld.fold_ty(fdec.output), @@ -216,7 +216,7 @@ fn noop_fold_item(&&i: @item, fld: ast_fold) -> option<@item> { fn noop_fold_class_item(&&ci: @class_member, fld: ast_fold) -> @class_member { - @{node: alt ci.node { + @{node: match ci.node { instance_var(ident, t, cm, id, p) => { instance_var(/* FIXME (#2543) */ copy ident, fld.fold_ty(t), cm, id, p) @@ -227,7 +227,7 @@ fn noop_fold_class_item(&&ci: @class_member, fld: ast_fold) } fn noop_fold_item_underscore(i: item_, fld: ast_fold) -> item_ { - return alt i { + return match i { item_const(t, e) => item_const(fld.fold_ty(t), fld.fold_expr(e)), item_fn(decl, typms, body) => { item_fn(fold_fn_decl(decl, fld), @@ -244,7 +244,7 @@ fn noop_fold_item_underscore(i: item_, fld: ast_fold) -> item_ { } item_class(typms, traits, items, m_ctor, m_dtor) => { let resulting_optional_constructor; - alt m_ctor { + match m_ctor { none => { resulting_optional_constructor = none; } @@ -319,7 +319,7 @@ fn noop_fold_block(b: blk_, fld: ast_fold) -> blk_ { } fn noop_fold_stmt(s: stmt_, fld: ast_fold) -> stmt_ { - return alt s { + return match s { stmt_decl(d, nid) => stmt_decl(fld.fold_decl(d), fld.new_id(nid)), stmt_expr(e, nid) => stmt_expr(fld.fold_expr(e), fld.new_id(nid)), stmt_semi(e, nid) => stmt_semi(fld.fold_expr(e), fld.new_id(nid)) @@ -333,7 +333,7 @@ fn noop_fold_arm(a: arm, fld: ast_fold) -> arm { } fn noop_fold_pat(p: pat_, fld: ast_fold) -> pat_ { - return alt p { + return match p { pat_wild => pat_wild, pat_ident(binding_mode, pth, sub) => { pat_ident(binding_mode, @@ -364,9 +364,9 @@ fn noop_fold_pat(p: pat_, fld: ast_fold) -> pat_ { } fn noop_fold_decl(d: decl_, fld: ast_fold) -> decl_ { - alt d { + match d { decl_local(ls) => decl_local(vec::map(ls, |x| fld.fold_local(x))), - decl_item(it) => alt fld.fold_item(it) { + decl_item(it) => match fld.fold_item(it) { some(it_folded) => decl_item(it_folded), none => decl_local(~[]) } @@ -393,7 +393,7 @@ fn noop_fold_expr(e: expr_, fld: ast_fold) -> expr_ { let fold_mac = |x| fold_mac_(x, fld); - return alt e { + return match e { expr_vstore(e, v) => { expr_vstore(fld.fold_expr(e), v) } @@ -496,7 +496,7 @@ fn noop_fold_ty(t: ty_, fld: ast_fold) -> ty_ { mt: fold_mt(f.node.mt, fld)}, span: fld.new_span(f.span)} } - alt t { + match t { ty_nil | ty_bot | ty_infer => copy t, ty_box(mt) => ty_box(fold_mt(mt, fld)), ty_uniq(mt) => ty_uniq(fold_mt(mt, fld)), @@ -533,7 +533,7 @@ fn noop_fold_variant(v: variant_, fld: ast_fold) -> variant_ { let fold_attribute = |x| fold_attribute_(x, fld); let attrs = vec::map(v.attrs, fold_attribute); - let de = alt v.disr_expr { + let de = match v.disr_expr { some(e) => some(fld.fold_expr(e)), none => none }; @@ -560,7 +560,7 @@ fn noop_fold_local(l: local_, fld: ast_fold) -> local_ { ty: fld.fold_ty(l.ty), pat: fld.fold_pat(l.pat), init: - alt l.init { + match l.init { option::none::<initializer> => l.init, option::some::<initializer>(init) => { option::some::<initializer>({op: init.op, @@ -635,7 +635,7 @@ impl of ast_fold for ast_fold_precursor { return self.fold_item(i, self as ast_fold); } fn fold_class_item(&&ci: @class_member) -> @class_member { - @{node: alt ci.node { + @{node: match ci.node { instance_var(nm, t, mt, id, p) => { instance_var(/* FIXME (#2543) */ copy nm, (self as ast_fold).fold_ty(t), mt, id, p) diff --git a/src/libsyntax/parse.rs b/src/libsyntax/parse.rs index 71e7c4a04e5..0a6df808530 100644 --- a/src/libsyntax/parse.rs +++ b/src/libsyntax/parse.rs @@ -189,7 +189,7 @@ fn new_parser_etc_from_file(sess: parse_sess, cfg: ast::crate_cfg, +path: ~str, ftype: parser::file_type) -> (parser, string_reader) { let res = io::read_whole_file_str(path); - alt res { + match res { result::ok(_) => { /* Continue. */ } result::err(e) => sess.span_diagnostic.handler().fatal(e) } diff --git a/src/libsyntax/parse/attr.rs b/src/libsyntax/parse/attr.rs index 006bd3909d8..aefa7264bf6 100644 --- a/src/libsyntax/parse/attr.rs +++ b/src/libsyntax/parse/attr.rs @@ -29,7 +29,7 @@ impl parser_attr of parser_attr for parser { -> attr_or_ext { let expect_item_next = vec::is_not_empty(first_item_attrs); - alt self.token { + match self.token { token::POUND => { let lo = self.span.lo; if self.look_ahead(1u) == token::LBRACKET { @@ -57,7 +57,7 @@ impl parser_attr of parser_attr for parser { fn parse_outer_attributes() -> ~[ast::attribute] { let mut attrs: ~[ast::attribute] = ~[]; loop { - alt copy self.token { + match copy self.token { token::POUND => { if self.look_ahead(1u) != token::LBRACKET { break; @@ -106,7 +106,7 @@ impl parser_attr of parser_attr for parser { let mut inner_attrs: ~[ast::attribute] = ~[]; let mut next_outer_attrs: ~[ast::attribute] = ~[]; loop { - alt copy self.token { + match copy self.token { token::POUND => { if self.look_ahead(1u) != token::LBRACKET { // This is an extension @@ -146,7 +146,7 @@ impl parser_attr of parser_attr for parser { fn parse_meta_item() -> @ast::meta_item { let lo = self.span.lo; let ident = self.parse_ident(); - alt self.token { + match self.token { token::EQ => { self.bump(); let lit = self.parse_lit(); @@ -172,7 +172,7 @@ impl parser_attr of parser_attr for parser { } fn parse_optional_meta() -> ~[@ast::meta_item] { - alt self.token { + match self.token { token::LPAREN => return self.parse_meta_seq(), _ => return ~[] } diff --git a/src/libsyntax/parse/classify.rs b/src/libsyntax/parse/classify.rs index 8450ce0038d..38599907e6f 100644 --- a/src/libsyntax/parse/classify.rs +++ b/src/libsyntax/parse/classify.rs @@ -5,7 +5,7 @@ import ast_util::operator_prec; fn expr_requires_semi_to_be_stmt(e: @ast::expr) -> bool { - alt e.node { + match e.node { ast::expr_if(_, _, _) | ast::expr_alt(_, _, _) | ast::expr_block(_) | ast::expr_while(_, _) | ast::expr_loop(_) | ast::expr_call(_, _, true) => false, @@ -14,9 +14,9 @@ fn expr_requires_semi_to_be_stmt(e: @ast::expr) -> bool { } fn stmt_ends_with_semi(stmt: ast::stmt) -> bool { - alt stmt.node { + match stmt.node { ast::stmt_decl(d, _) => { - return alt d.node { + return match d.node { ast::decl_local(_) => true, ast::decl_item(_) => false } @@ -31,7 +31,7 @@ fn stmt_ends_with_semi(stmt: ast::stmt) -> bool { } fn need_parens(expr: @ast::expr, outer_prec: uint) -> bool { - alt expr.node { + match expr.node { ast::expr_binary(op, _, _) => operator_prec(op) < outer_prec, ast::expr_cast(_, _) => parse::prec::as_prec < outer_prec, // This may be too conservative in some cases @@ -47,8 +47,8 @@ fn need_parens(expr: @ast::expr, outer_prec: uint) -> bool { } fn ends_in_lit_int(ex: @ast::expr) -> bool { - alt ex.node { - ast::expr_lit(node) => alt node { + match ex.node { + ast::expr_lit(node) => match node { @{node: ast::lit_int(_, ast::ty_i), _} | @{node: ast::lit_int_unsuffixed(_), _} => true, _ => false @@ -60,7 +60,7 @@ fn ends_in_lit_int(ex: @ast::expr) -> bool { ast::expr_log(_, _, sub) | ast::expr_assert(sub) => { ends_in_lit_int(sub) } - ast::expr_fail(osub) | ast::expr_ret(osub) => alt osub { + ast::expr_fail(osub) | ast::expr_ret(osub) => match osub { some(ex) => ends_in_lit_int(ex), _ => false } diff --git a/src/libsyntax/parse/common.rs b/src/libsyntax/parse/common.rs index 6b31b53eaa5..445e4c20eed 100644 --- a/src/libsyntax/parse/common.rs +++ b/src/libsyntax/parse/common.rs @@ -84,7 +84,7 @@ impl parser_common of parser_common for parser { } fn parse_ident() -> ast::ident { - alt copy self.token { + match copy self.token { token::IDENT(i, _) => { self.bump(); return self.get_str(i); } token::INTERPOLATED(token::nt_ident(*)) => { self.bug( ~"ident interpolation not converted to real token"); } @@ -118,7 +118,7 @@ impl parser_common of parser_common for parser { } fn token_is_word(word: ~str, ++tok: token::token) -> bool { - alt tok { + match tok { token::IDENT(sid, false) => { word == *self.get_str(sid) } _ => { false } } @@ -134,7 +134,7 @@ impl parser_common of parser_common for parser { } fn is_any_keyword(tok: token::token) -> bool { - alt tok { + match tok { token::IDENT(sid, false) => { self.keywords.contains_key_ref(self.get_str(sid)) } @@ -146,7 +146,7 @@ impl parser_common of parser_common for parser { self.require_keyword(word); let mut bump = false; - let val = alt self.token { + let val = match self.token { token::IDENT(sid, false) => { if word == *self.get_str(sid) { bump = true; @@ -173,7 +173,7 @@ impl parser_common of parser_common for parser { } fn check_restricted_keywords() { - alt self.token { + match self.token { token::IDENT(_, false) => { let w = token_to_str(self.reader, self.token); self.check_restricted_keywords_(w); @@ -209,7 +209,7 @@ impl parser_common of parser_common for parser { let mut v = ~[]; while self.token != token::GT && self.token != token::BINOP(token::SHR) { - alt sep { + match sep { some(t) => { if first { first = false; } else { self.expect(t); } @@ -253,7 +253,7 @@ impl parser_common of parser_common for parser { let mut first: bool = true; let mut v: ~[T] = ~[]; while self.token != ket { - alt sep.sep { + match sep.sep { some(t) => { if first { first = false; } else { self.expect(t); } diff --git a/src/libsyntax/parse/eval.rs b/src/libsyntax/parse/eval.rs index 154e653e890..6b0112922a5 100644 --- a/src/libsyntax/parse/eval.rs +++ b/src/libsyntax/parse/eval.rs @@ -47,7 +47,7 @@ fn parse_companion_mod(cx: ctx, prefix: ~str, suffix: option<~str>) -> (~[@ast::view_item], ~[@ast::item], ~[ast::attribute]) { fn companion_file(+prefix: ~str, suffix: option<~str>) -> ~str { - return alt suffix { + return match suffix { option::some(s) => path::connect(prefix, s), option::none => prefix } + ~".rs"; @@ -56,7 +56,7 @@ fn parse_companion_mod(cx: ctx, prefix: ~str, suffix: option<~str>) fn file_exists(path: ~str) -> bool { // Crude, but there's no lib function for this and I'm not // up to writing it just now - alt io::file_reader(path) { + match io::file_reader(path) { result::ok(_) => true, result::err(_) => false } @@ -79,7 +79,7 @@ fn parse_companion_mod(cx: ctx, prefix: ~str, suffix: option<~str>) } fn cdir_path_opt(id: ast::ident, attrs: ~[ast::attribute]) -> @~str { - alt ::attr::first_attr_value_str_by_name(attrs, ~"path") { + match ::attr::first_attr_value_str_by_name(attrs, ~"path") { some(d) => return d, none => return id } @@ -88,7 +88,7 @@ fn cdir_path_opt(id: ast::ident, attrs: ~[ast::attribute]) -> @~str { fn eval_crate_directive(cx: ctx, cdir: @ast::crate_directive, prefix: ~str, &view_items: ~[@ast::view_item], &items: ~[@ast::item]) { - alt cdir.node { + match cdir.node { ast::cdir_src_mod(id, attrs) => { let file_path = cdir_path_opt(@(*id + ~".rs"), attrs); let full_path = diff --git a/src/libsyntax/parse/lexer.rs b/src/libsyntax/parse/lexer.rs index bc5aba5283c..e9bfbc753f7 100644 --- a/src/libsyntax/parse/lexer.rs +++ b/src/libsyntax/parse/lexer.rs @@ -206,7 +206,7 @@ fn consume_whitespace_and_comments(rdr: string_reader) fn consume_any_line_comment(rdr: string_reader) -> option<{tok: token::token, sp: span}> { if rdr.curr == '/' { - alt nextch(rdr) { + match nextch(rdr) { '/' => { bump(rdr); bump(rdr); @@ -313,7 +313,7 @@ fn scan_digits(rdr: string_reader, radix: uint) -> ~str { loop { let c = rdr.curr; if c == '_' { bump(rdr); again; } - alt char::to_digit(c, radix) { + match char::to_digit(c, radix) { some(d) => { str::push_char(rslt, c); bump(rdr); @@ -371,7 +371,7 @@ fn scan_number(c: char, rdr: string_reader) -> token::token { rdr.fatal(~"no valid digits found for number"); } let parsed = option::get(u64::from_str_radix(num_str, base as u64)); - alt tp { + match tp { either::left(t) => return token::LIT_INT(parsed as i64, t), either::right(t) => return token::LIT_UINT(parsed, t) } @@ -383,7 +383,7 @@ fn scan_number(c: char, rdr: string_reader) -> token::token { let dec_part = scan_digits(rdr, 10u); num_str += ~"." + dec_part; } - alt scan_exponent(rdr) { + match scan_exponent(rdr) { some(s) => { is_float = true; num_str += s; @@ -472,7 +472,7 @@ fn next_token_inner(rdr: string_reader) -> token::token { return token::BINOPEQ(op); } else { return token::BINOP(op); } } - alt c { + match c { @@ -539,12 +539,12 @@ fn next_token_inner(rdr: string_reader) -> token::token { } '<' => { bump(rdr); - alt rdr.curr { + match rdr.curr { '=' => { bump(rdr); return token::LE; } '<' => { return binop(rdr, token::SHL); } '-' => { bump(rdr); - alt rdr.curr { + match rdr.curr { '>' => { bump(rdr); return token::DARROW; } _ => { return token::LARROW; } } @@ -554,7 +554,7 @@ fn next_token_inner(rdr: string_reader) -> token::token { } '>' => { bump(rdr); - alt rdr.curr { + match rdr.curr { '=' => { bump(rdr); return token::GE; } '>' => { return binop(rdr, token::SHR); } _ => { return token::GT; } @@ -567,7 +567,7 @@ fn next_token_inner(rdr: string_reader) -> token::token { if c2 == '\\' { let escaped = rdr.curr; bump(rdr); - alt escaped { + match escaped { 'n' => { c2 = '\n'; } 'r' => { c2 = '\r'; } 't' => { c2 = '\t'; } @@ -599,11 +599,11 @@ fn next_token_inner(rdr: string_reader) -> token::token { let ch = rdr.curr; bump(rdr); - alt ch { + match ch { '\\' => { let escaped = rdr.curr; bump(rdr); - alt escaped { + match escaped { 'n' => str::push_char(accum_str, '\n'), 'r' => str::push_char(accum_str, '\r'), 't' => str::push_char(accum_str, '\t'), @@ -646,7 +646,7 @@ fn next_token_inner(rdr: string_reader) -> token::token { } else { return binop(rdr, token::AND); } } '|' => { - alt nextch(rdr) { + match nextch(rdr) { '|' => { bump(rdr); bump(rdr); return token::OROR; } _ => { return binop(rdr, token::OR); } } diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index 4a34b667937..7684c66c364 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -107,7 +107,7 @@ type item_info = (ident, item_, option<~[attribute]>); The important thing is to make sure that lookahead doesn't balk at INTERPOLATED tokens */ macro_rules! maybe_whole_expr { - {$p:expr} => { alt copy $p.token { + {$p:expr} => { match copy $p.token { INTERPOLATED(token::nt_expr(e)) => { $p.bump(); return pexpr(e); @@ -122,19 +122,19 @@ macro_rules! maybe_whole_expr { } macro_rules! maybe_whole { - {$p:expr, $constructor:ident} => { alt copy $p.token { + {$p:expr, $constructor:ident} => { match copy $p.token { INTERPOLATED(token::$constructor(x)) => { $p.bump(); return x; } _ => () }} ; - {deref $p:expr, $constructor:ident} => { alt copy $p.token { + {deref $p:expr, $constructor:ident} => { match copy $p.token { INTERPOLATED(token::$constructor(x)) => { $p.bump(); return *x; } _ => () }} ; - {some $p:expr, $constructor:ident} => { alt copy $p.token { + {some $p:expr, $constructor:ident} => { match copy $p.token { INTERPOLATED(token::$constructor(x)) => { $p.bump(); return some(x); } _ => () }} ; - {pair_empty $p:expr, $constructor:ident} => { alt copy $p.token { + {pair_empty $p:expr, $constructor:ident} => { match copy $p.token { INTERPOLATED(token::$constructor(x)) => { $p.bump(); return (~[], x); } _ => () }} @@ -284,7 +284,7 @@ class parser { debug!{"parse_trait_methods(): trait method signature ends in \ `%s`", token_to_str(p.reader, p.token)}; - alt p.token { + match p.token { token::SEMI => { p.bump(); debug!{"parse_trait_methods(): parsing required method"}; @@ -356,7 +356,7 @@ class parser { } fn region_from_name(s: option<@~str>) -> @region { - let r = alt s { + let r = match s { some (string) => re_named(string), none => re_anon }; @@ -368,7 +368,7 @@ class parser { fn parse_region() -> @region { self.expect(token::BINOP(token::AND)); - alt copy self.token { + match copy self.token { token::IDENT(sid, _) => { self.bump(); let n = self.get_str(sid); @@ -383,7 +383,7 @@ class parser { // Parses something like "&x/" (note the trailing slash) fn parse_region_with_sep() -> @region { let name = - alt copy self.token { + match copy self.token { token::IDENT(sid, _) => { if self.look_ahead(1u) == token::BINOP(token::SLASH) { self.bump(); self.bump(); @@ -402,7 +402,7 @@ class parser { let lo = self.span.lo; - alt self.maybe_parse_dollar_mac() { + match self.maybe_parse_dollar_mac() { some(e) => { return @{id: self.get_id(), node: ty_mac(spanned(lo, self.span.hi, e)), @@ -471,7 +471,7 @@ class parser { let sp = mk_sp(lo, self.last_span.hi); return @{id: self.get_id(), - node: alt self.maybe_parse_fixed_vstore() { + node: match self.maybe_parse_fixed_vstore() { // Consider a fixed vstore suffix (/N or /_) none => t, some(v) => { @@ -542,11 +542,11 @@ class parser { } fn maybe_parse_dollar_mac() -> option<mac_> { - alt copy self.token { + match copy self.token { token::DOLLAR => { let lo = self.span.lo; self.bump(); - alt copy self.token { + match copy self.token { token::LIT_INT_UNSUFFIXED(num) => { self.bump(); some(mac_var(num as uint)) @@ -570,7 +570,7 @@ class parser { fn maybe_parse_fixed_vstore() -> option<option<uint>> { if self.token == token::BINOP(token::SLASH) { self.bump(); - alt copy self.token { + match copy self.token { token::UNDERSCORE => { self.bump(); some(none) } @@ -585,7 +585,7 @@ class parser { } fn lit_from_token(tok: token::token) -> lit_ { - alt tok { + match tok { token::LIT_INT(i, it) => lit_int(i, it), token::LIT_UINT(u, ut) => lit_uint(u, ut), token::LIT_INT_UNSUFFIXED(i) => lit_int_unsuffixed(i), @@ -733,7 +733,7 @@ class parser { } fn to_expr(e: pexpr) -> @expr { - alt e.node { + match e.node { expr_tup(es) if vec::len(es) == 1u => es[0u], _ => *e } @@ -746,7 +746,7 @@ class parser { let mut ex: expr_; - alt self.maybe_parse_dollar_mac() { + match self.maybe_parse_dollar_mac() { some(x) => return pexpr(self.mk_mac_expr(lo, self.span.hi, x)), _ => () } @@ -794,11 +794,11 @@ class parser { return pexpr(self.parse_while_expr()); } else if self.eat_keyword(~"loop") { return pexpr(self.parse_loop_expr()); - } else if self.eat_keyword(~"alt") || self.eat_keyword(~"match") { + } else if self.eat_keyword(~"match") { return pexpr(self.parse_alt_expr()); } else if self.eat_keyword(~"fn") { let proto = self.parse_fn_ty_proto(); - alt proto { + match proto { proto_bare => self.fatal(~"fn expr are deprecated, use fn@"), _ => { /* fallthrough */ } } @@ -893,7 +893,7 @@ class parser { /* `!`, as an operator, is prefix, so we know this isn't that */ if self.token == token::NOT { self.bump(); - let tts = alt self.token { + let tts = match self.token { token::LPAREN | token::LBRACE | token::LBRACKET => { let ket = token::flip_delimiter(self.token); self.parse_unspanned_seq(copy self.token, ket, @@ -948,9 +948,9 @@ class parser { // Vstore is legal following expr_lit(lit_str(...)) and expr_vec(...) // only. - alt ex { + match ex { expr_lit(@{node: lit_str(_), span: _}) | - expr_vec(_, _) => alt self.maybe_parse_fixed_vstore() { + expr_vec(_, _) => match self.maybe_parse_fixed_vstore() { none => (), some(v) => { hi = self.span.hi; @@ -976,7 +976,7 @@ class parser { } fn parse_syntax_ext_naked(lo: uint) -> @expr { - alt self.token { + match self.token { token::IDENT(_, _) => (), _ => self.fatal(~"expected a syntax expander name") } @@ -1003,7 +1003,7 @@ class parser { let lo = self.span.lo; let mut depth = 1u; while (depth > 0u) { - alt (self.token) { + match (self.token) { token::LBRACE => depth += 1u, token::RBRACE => depth -= 1u, token::EOF => self.fatal(~"unexpected EOF in macro body"), @@ -1033,7 +1033,7 @@ class parser { loop { // expr.f if self.eat(token::DOT) { - alt copy self.token { + match copy self.token { token::IDENT(i, _) => { hi = self.span.hi; self.bump(); @@ -1051,7 +1051,7 @@ class parser { again; } if self.expr_is_complete(e) { break; } - alt copy self.token { + match copy self.token { // expr(...) token::LPAREN if self.permits_call() => { let es = self.parse_unspanned_seq( @@ -1103,7 +1103,7 @@ class parser { maybe_whole!{deref self, nt_tt}; fn parse_tt_tok(p: parser, delim_ok: bool) -> token_tree { - alt p.token { + match p.token { token::RPAREN | token::RBRACE | token::RBRACKET if !delim_ok => { p.fatal(~"incorrect close delimiter: `" @@ -1134,7 +1134,7 @@ class parser { return res; } - return alt self.token { + return match self.token { token::LPAREN | token::LBRACE | token::LBRACKET => { let ket = token::flip_delimiter(self.token); tt_delim(vec::append( @@ -1154,7 +1154,7 @@ class parser { // the interpolation of matchers maybe_whole!{self, nt_matchers}; let name_idx = @mut 0u; - return alt self.token { + return match self.token { token::LBRACE | token::LPAREN | token::LBRACKET => { self.parse_matcher_subseq(name_idx, copy self.token, token::flip_delimiter(self.token)) @@ -1222,7 +1222,7 @@ class parser { let mut hi; let mut ex; - alt copy self.token { + match copy self.token { token::NOT => { self.bump(); let e = self.to_expr(self.parse_prefix_expr()); @@ -1231,7 +1231,7 @@ class parser { ex = expr_unary(not, e); } token::BINOP(b) => { - alt b { + match b { token::MINUS => { self.bump(); let e = self.to_expr(self.parse_prefix_expr()); @@ -1251,7 +1251,7 @@ class parser { let e = self.to_expr(self.parse_prefix_expr()); hi = e.span.hi; // HACK: turn &[...] into a &-evec - ex = alt e.node { + ex = match e.node { expr_vec(*) | expr_lit(@{node: lit_str(_), span: _}) if m == m_imm => { expr_vstore(e, vstore_slice(self.region_from_name(none))) @@ -1268,7 +1268,7 @@ class parser { let e = self.to_expr(self.parse_prefix_expr()); hi = e.span.hi; // HACK: turn @[...] into a @-evec - ex = alt e.node { + ex = match e.node { expr_vec(*) | expr_lit(@{node: lit_str(_), span: _}) if m == m_imm => expr_vstore(e, vstore_box), _ => expr_unary(box(m), e) @@ -1280,7 +1280,7 @@ class parser { let e = self.to_expr(self.parse_prefix_expr()); hi = e.span.hi; // HACK: turn ~[...] into a ~-evec - ex = alt e.node { + ex = match e.node { expr_vec(*) | expr_lit(@{node: lit_str(_), span: _}) if m == m_imm => expr_vstore(e, vstore_uniq), _ => expr_unary(uniq(m), e) @@ -1311,7 +1311,7 @@ class parser { return lhs; } let cur_opt = token_to_binop(peeked); - alt cur_opt { + match cur_opt { some(cur_op) => { let cur_prec = operator_prec(cur_op); if cur_prec > min_prec { @@ -1338,7 +1338,7 @@ class parser { fn parse_assign_expr() -> @expr { let lo = self.span.lo; let lhs = self.parse_binops(); - alt copy self.token { + match copy self.token { token::EQ => { self.bump(); let rhs = self.parse_expr(); @@ -1348,7 +1348,7 @@ class parser { self.bump(); let rhs = self.parse_expr(); let mut aop; - alt op { + match op { token::PLUS => aop = add, token::MINUS => aop = subtract, token::STAR => aop = mul, @@ -1412,7 +1412,7 @@ class parser { fn parse_lambda_block_expr() -> @expr { self.parse_lambda_expr_( || { - alt self.token { + match self.token { token::BINOP(token::OR) | token::OROR => { self.parse_fn_block_decl() } @@ -1481,7 +1481,7 @@ class parser { // Turn on the restriction to stop at | or || so we can parse // them as the lambda arguments let e = self.parse_expr_res(RESTRICT_NO_BAR_OR_DOUBLEBAR_OP); - alt e.node { + match e.node { expr_call(f, args, false) => { let block = self.parse_lambda_block_expr(); let last_arg = self.mk_expr(block.span.lo, block.span.hi, @@ -1608,7 +1608,7 @@ class parser { } fn parse_initializer() -> option<initializer> { - alt self.token { + match self.token { token::EQ => { self.bump(); return some({op: init_assign, expr: self.parse_expr()}); @@ -1645,14 +1645,14 @@ class parser { let lo = self.span.lo; let mut hi = self.span.hi; let mut pat; - alt self.token { + match self.token { token::UNDERSCORE => { self.bump(); pat = pat_wild; } token::AT => { self.bump(); let sub = self.parse_pat(refutable); hi = sub.span.hi; // HACK: parse @"..." as a literal of a vstore @str - pat = alt sub.node { + pat = match sub.node { pat_lit(e@@{ node: expr_lit(@{node: lit_str(_), span: _}), _ }) => { @@ -1669,7 +1669,7 @@ class parser { let sub = self.parse_pat(refutable); hi = sub.span.hi; // HACK: parse ~"..." as a literal of a vstore ~str - pat = alt sub.node { + pat = match sub.node { pat_lit(e@@{ node: expr_lit(@{node: lit_str(_), span: _}), _ }) => { @@ -1775,7 +1775,7 @@ class parser { } if is_plain_ident(self.token) && - alt self.look_ahead(1) { + match self.look_ahead(1) { token::LPAREN | token::LBRACKET | token::LT => { false } @@ -1794,8 +1794,8 @@ class parser { hi = enum_path.span.hi; let mut args: ~[@pat] = ~[]; let mut star_pat = false; - alt self.token { - token::LPAREN => alt self.look_ahead(1u) { + match self.token { + token::LPAREN => match self.look_ahead(1u) { token::BINOP(token::STAR) => { // This is a "top constructor only" pat self.bump(); self.bump(); @@ -1890,7 +1890,7 @@ class parser { return @spanned(lo, decl.span.hi, stmt_decl(decl, self.get_id())); } else { let mut item_attrs; - alt self.parse_outer_attrs_or_ext(first_item_attrs) { + match self.parse_outer_attrs_or_ext(first_item_attrs) { none => item_attrs = ~[], some(left(attrs)) => item_attrs = attrs, some(right(ext)) => { @@ -1901,7 +1901,7 @@ class parser { let item_attrs = vec::append(first_item_attrs, item_attrs); - alt self.parse_item(item_attrs) { + match self.parse_item(item_attrs) { some(i) => { let mut hi = i.span.hi; let decl = @spanned(lo, hi, decl_item(i)); @@ -1993,16 +1993,16 @@ class parser { } while self.token != token::RBRACE { - alt self.token { + match self.token { token::SEMI => { self.bump(); // empty } _ => { let stmt = self.parse_stmt(initial_attrs); initial_attrs = ~[]; - alt stmt.node { + match stmt.node { stmt_expr(e, stmt_id) => { // Expression without semicolon: - alt self.token { + match self.token { token::SEMI => { self.bump(); push(stmts, @@ -2086,7 +2086,7 @@ class parser { } fn is_self_ident() -> bool { - alt self.token { + match self.token { token::IDENT(sid, false) if ~"self" == *self.get_str(sid) => true, _ => false } @@ -2111,7 +2111,7 @@ class parser { // backwards compatible. let lo = self.span.lo; let self_ty; - alt copy self.token { + match copy self.token { token::BINOP(token::AND) => { // We need to make sure it isn't a mode. self.bump(); @@ -2126,10 +2126,10 @@ class parser { // Parse an explicit region, if possible. let region_name; - alt copy self.token { + match copy self.token { token::BINOP(token::SLASH) => { self.bump(); - alt copy self.token { + match copy self.token { token::IDENT(sid, false) => { self.bump(); region_name = some(self.get_str(sid)); @@ -2174,7 +2174,7 @@ class parser { // If we parsed a self type, expect a comma before the argument list. let args_or_capture_items; if self_ty != sty_by_ref { - alt copy self.token { + match copy self.token { token::COMMA => { self.bump(); let sep = seq_sep_trailing_disallowed(token::COMMA); @@ -2265,7 +2265,7 @@ class parser { } fn parse_method_name() -> ident { - alt copy self.token { + match copy self.token { token::BINOP(op) => { self.bump(); @token::binop_to_str(op) } token::NOT => { self.bump(); @~"!" } token::LBRACKET => { @@ -2387,7 +2387,7 @@ class parser { } else { traits = ~[]; }; - ident = alt ident_old { + ident = match ident_old { some(name) => name, none => { self.expect_keyword(~"of"); fail; } }; @@ -2445,7 +2445,7 @@ class parser { codemap::span)> = none; let mut the_dtor : option<(blk, ~[attribute], codemap::span)> = none; while self.token != token::RBRACE { - alt self.parse_class_item(class_path) { + match self.parse_class_item(class_path) { ctor_decl(a_fn_decl, attrs, blk, s) => { the_ctor = some((a_fn_decl, attrs, blk, s)); } @@ -2463,7 +2463,7 @@ class parser { body: d_body}, span: d_s}}; self.bump(); - alt the_ctor { + match the_ctor { some((ct_d, ct_attrs, ct_b, ct_s)) => { (class_name, item_class(ty_params, traits, ms, some({ @@ -2487,7 +2487,7 @@ class parser { } fn token_is_pound_or_doc_comment(++tok: token::token) -> bool { - alt tok { + match tok { token::POUND | token::DOC_COMMENT(_) => true, _ => false } @@ -2582,7 +2582,7 @@ class parser { first = false; } debug!{"parse_mod_items: parse_item(attrs=%?)", attrs}; - alt self.parse_item(attrs) { + match self.parse_item(attrs) { some(i) => vec::push(items, i), _ => { self.fatal(~"expected item but found `" + @@ -2764,7 +2764,7 @@ class parser { } fn parse_fn_ty_proto() -> proto { - alt self.token { + match self.token { token::AT => { self.bump(); proto_box @@ -2784,7 +2784,7 @@ class parser { } fn fn_expr_lookahead(tok: token::token) -> bool { - alt tok { + match tok { token::LPAREN | token::AT | token::TILDE | token::BINOP(_) => true, _ => false } @@ -2846,7 +2846,7 @@ class parser { let pth = self.parse_path_without_tps(); self.expect(token::NOT); let id = self.parse_ident(); - let tts = alt self.token { + let tts = match self.token { token::LPAREN | token::LBRACE | token::LBRACKET => { let ket = token::flip_delimiter(self.token); self.parse_unspanned_seq(copy self.token, ket, @@ -2863,7 +2863,7 @@ class parser { (id, item_mac(m), none) } else { return none; }; some(self.mk_item(lo, self.last_span.hi, ident, item_, visibility, - alt extra_attrs { + match extra_attrs { some(as) => vec::append(attrs, as), none => attrs })) @@ -2880,7 +2880,7 @@ class parser { let first_ident = self.parse_ident(); let mut path = ~[first_ident]; debug!{"parsed view_path: %s", *first_ident}; - alt self.token { + match self.token { token::EQ => { // x = foo::bar self.bump(); @@ -2901,7 +2901,7 @@ class parser { while self.token == token::MOD_SEP { self.bump(); - alt copy self.token { + match copy self.token { token::IDENT(i, _) => { self.bump(); @@ -3004,7 +3004,7 @@ class parser { } fn parse_str() -> @~str { - alt copy self.token { + match copy self.token { token::LIT_STR(s) => { self.bump(); self.get_str(s) } _ => self.fatal(~"expected string literal") } @@ -3035,7 +3035,7 @@ class parser { self.expect_keyword(~"module"); } let id = self.parse_ident(); - alt self.token { + match self.token { // mod x = "foo.rs"; token::SEMI => { let mut hi = self.span.hi; diff --git a/src/libsyntax/parse/prec.rs b/src/libsyntax/parse/prec.rs index 45bbe3b8e3b..bd9ada9a338 100644 --- a/src/libsyntax/parse/prec.rs +++ b/src/libsyntax/parse/prec.rs @@ -20,7 +20,7 @@ const as_prec: uint = 11u; * operator and its precedence */ fn token_to_binop(tok: token) -> option<ast::binop> { - alt tok { + match tok { BINOP(STAR) => some(mul), BINOP(SLASH) => some(div), BINOP(PERCENT) => some(rem), diff --git a/src/libsyntax/parse/token.rs b/src/libsyntax/parse/token.rs index 9e9a3bbca56..a99d071b6ef 100644 --- a/src/libsyntax/parse/token.rs +++ b/src/libsyntax/parse/token.rs @@ -102,7 +102,7 @@ enum nonterminal { } fn binop_to_str(o: binop) -> ~str { - alt o { + match o { PLUS => ~"+", MINUS => ~"-", STAR => ~"*", @@ -117,7 +117,7 @@ fn binop_to_str(o: binop) -> ~str { } fn to_str(in: interner<@~str>, t: token) -> ~str { - alt t { + match t { EQ => ~"=", LT => ~"<", LE => ~"<=", @@ -186,7 +186,7 @@ fn to_str(in: interner<@~str>, t: token) -> ~str { EOF => ~"<eof>", INTERPOLATED(nt) => { ~"an interpolated " + - alt nt { + match nt { nt_item(*) => ~"item", nt_block(*) => ~"block", nt_stmt(*) => ~"statement", @@ -203,7 +203,7 @@ fn to_str(in: interner<@~str>, t: token) -> ~str { } pure fn can_begin_expr(t: token) -> bool { - alt t { + match t { LPAREN => true, LBRACE => true, LBRACKET => true, @@ -234,7 +234,7 @@ pure fn can_begin_expr(t: token) -> bool { /// what's the opposite delimiter? fn flip_delimiter(&t: token::token) -> token::token { - alt t { + match t { token::LPAREN => token::RPAREN, token::LBRACE => token::RBRACE, token::LBRACKET => token::RBRACKET, @@ -248,7 +248,7 @@ fn flip_delimiter(&t: token::token) -> token::token { fn is_lit(t: token) -> bool { - alt t { + match t { LIT_INT(_, _) => true, LIT_UINT(_, _) => true, LIT_INT_UNSUFFIXED(_) => true, @@ -259,22 +259,22 @@ fn is_lit(t: token) -> bool { } pure fn is_ident(t: token) -> bool { - alt t { IDENT(_, _) => true, _ => false } + match t { IDENT(_, _) => true, _ => false } } pure fn is_ident_or_path(t: token) -> bool { - alt t { + match t { IDENT(_, _) | INTERPOLATED(nt_path(*)) => true, _ => false } } pure fn is_plain_ident(t: token) -> bool { - alt t { IDENT(_, false) => true, _ => false } + match t { IDENT(_, false) => true, _ => false } } pure fn is_bar(t: token) -> bool { - alt t { BINOP(OR) | OROR => true, _ => false } + match t { BINOP(OR) | OROR => true, _ => false } } /** @@ -333,7 +333,7 @@ fn contextual_keyword_table() -> hashmap<~str, ()> { fn restricted_keyword_table() -> hashmap<~str, ()> { let words = str_hash(); let keys = ~[ - ~"alt", ~"again", ~"assert", + ~"again", ~"assert", ~"break", ~"check", ~"class", ~"const", ~"copy", ~"do", ~"drop", diff --git a/src/libsyntax/print/pp.rs b/src/libsyntax/print/pp.rs index 12ef7149f6b..a8f9cf756a8 100644 --- a/src/libsyntax/print/pp.rs +++ b/src/libsyntax/print/pp.rs @@ -62,7 +62,7 @@ type begin_t = {offset: int, breaks: breaks}; enum token { STRING(@~str, int), BREAK(break_t), BEGIN(begin_t), END, EOF, } fn tok_str(++t: token) -> ~str { - alt t { + match t { STRING(s, len) => return fmt!{"STR(%s,%d)", *s, len}, BREAK(_) => return ~"BREAK", BEGIN(_) => return ~"BEGIN", @@ -238,7 +238,7 @@ impl printer for printer { fn replace_last_token(t: token) { self.token[self.right] = t; } fn pretty_print(t: token) { debug!{"pp ~[%u,%u]", self.left, self.right}; - alt t { + match t { EOF => { if !self.scan_stack_empty { self.check_stack(0); @@ -357,7 +357,7 @@ impl printer for printer { self.left, L}; if L >= 0 { self.print(x, L); - alt x { + match x { BREAK(b) => self.left_total += b.blank_space, STRING(_, len) => { assert (len == L); self.left_total += len; } _ => () @@ -373,7 +373,7 @@ impl printer for printer { fn check_stack(k: int) { if !self.scan_stack_empty { let x = self.scan_top(); - alt copy self.token[x] { + match copy self.token[x] { BEGIN(b) => { if k > 0 { self.size[self.scan_pop()] = self.size[x] + @@ -422,7 +422,7 @@ impl printer for printer { debug!{"print %s %d (remaining line space=%d)", tok_str(x), L, self.space}; log(debug, buf_str(self.token, self.size, self.left, self.right, 6u)); - alt x { + match x { BEGIN(b) => { if L > self.space { let col = self.margin - self.space + b.offset; @@ -442,7 +442,7 @@ impl printer for printer { } BREAK(b) => { let top = self.get_top(); - alt top.pbreak { + match top.pbreak { fits => { debug!{"print BREAK in fitting block"}; self.space -= b.blank_space; diff --git a/src/libsyntax/print/pprust.rs b/src/libsyntax/print/pprust.rs index eca571b9ccd..e968fb92ad6 100644 --- a/src/libsyntax/print/pprust.rs +++ b/src/libsyntax/print/pprust.rs @@ -222,11 +222,11 @@ fn bclose_(s: ps, span: codemap::span, indented: uint) { fn bclose(s: ps, span: codemap::span) { bclose_(s, span, indent_unit); } fn is_begin(s: ps) -> bool { - alt s.s.last_token() { pp::BEGIN(_) => true, _ => false } + match s.s.last_token() { pp::BEGIN(_) => true, _ => false } } fn is_end(s: ps) -> bool { - alt s.s.last_token() { pp::END => true, _ => false } + match s.s.last_token() { pp::END => true, _ => false } } fn is_bol(s: ps) -> bool { @@ -318,7 +318,7 @@ fn print_foreign_mod(s: ps, nmod: ast::foreign_mod, } fn print_region(s: ps, region: @ast::region) { - alt region.node { + match region.node { ast::re_anon => word_space(s, ~"&"), ast::re_named(name) => { word(s.s, ~"&"); @@ -334,14 +334,14 @@ fn print_type(s: ps, &&ty: @ast::ty) { fn print_type_ex(s: ps, &&ty: @ast::ty, print_colons: bool) { maybe_print_comment(s, ty.span.lo); ibox(s, 0u); - alt ty.node { + match ty.node { ast::ty_nil => word(s.s, ~"()"), ast::ty_bot => word(s.s, ~"!"), ast::ty_box(mt) => { word(s.s, ~"@"); print_mt(s, mt); } ast::ty_uniq(mt) => { word(s.s, ~"~"); print_mt(s, mt); } ast::ty_vec(mt) => { word(s.s, ~"["); - alt mt.mutbl { + match mt.mutbl { ast::m_mutbl => word_space(s, ~"mut"), ast::m_const => word_space(s, ~"const"), ast::m_imm => () @@ -351,7 +351,7 @@ fn print_type_ex(s: ps, &&ty: @ast::ty, print_colons: bool) { } ast::ty_ptr(mt) => { word(s.s, ~"*"); print_mt(s, mt); } ast::ty_rptr(region, mt) => { - alt region.node { + match region.node { ast::re_anon => word(s.s, ~"&"), _ => { print_region(s, region); word(s.s, ~"/"); } } @@ -400,7 +400,7 @@ fn print_foreign_item(s: ps, item: @ast::foreign_item) { hardbreak_if_not_bol(s); maybe_print_comment(s, item.span.lo); print_outer_attributes(s, item.attrs); - alt item.node { + match item.node { ast::foreign_item_fn(decl, typarams) => { print_fn(s, decl, item.ident, typarams); end(s); // end head-ibox @@ -416,7 +416,7 @@ fn print_item(s: ps, &&item: @ast::item) { print_outer_attributes(s, item.attrs); let ann_node = node_item(s, item); s.ann.pre(ann_node); - alt item.node { + match item.node { ast::item_const(ty, expr) => { head(s, ~"const"); word_space(s, *item.ident + ~":"); @@ -538,7 +538,7 @@ fn print_item(s: ps, &&item: @ast::item) { hardbreak_if_not_bol(s); maybe_print_comment(s, ci.span.lo); let pr = ast_util::class_member_visibility(ci); - alt pr { + match pr { ast::private => { head(s, ~"priv"); bopen(s); @@ -546,10 +546,10 @@ fn print_item(s: ps, &&item: @ast::item) { } _ => () } - alt ci.node { + match ci.node { ast::instance_var(nm, t, mt, _,_) => { word_nbsp(s, ~"let"); - alt mt { + match mt { ast::class_mutable => word_nbsp(s, ~"mut"), _ => () } @@ -562,7 +562,7 @@ fn print_item(s: ps, &&item: @ast::item) { print_method(s, m); } } - alt pr { + match pr { ast::private => bclose(s, ci.span), _ => () } @@ -625,10 +625,10 @@ fn print_item(s: ps, &&item: @ast::item) { /// and then pretty-print the resulting AST nodes (so, e.g., we print /// expression arguments as expressions). It can be done! I think. fn print_tt(s: ps, tt: ast::token_tree) { - alt tt { + match tt { ast::tt_delim(tts) => for tts.each() |tt_elt| { print_tt(s, tt_elt); } ast::tt_tok(_, tk) => { - alt tk { + match tk { parse::token::IDENT(*) => { // don't let idents run together if s.s.token_tree_last_was_ident { word(s.s, ~" ") } s.s.token_tree_last_was_ident = true; @@ -641,7 +641,7 @@ fn print_tt(s: ps, tt: ast::token_tree) { word(s.s, ~"$("); for tts.each() |tt_elt| { print_tt(s, tt_elt); } word(s.s, ~")"); - alt sep { + match sep { some(tk) => word(s.s, parse::token::to_str(*s.intr, tk)), none => () } @@ -665,7 +665,7 @@ fn print_variant(s: ps, v: ast::variant) { commasep(s, consistent, v.node.args, print_variant_arg); pclose(s); } - alt v.node.disr_expr { + match v.node.disr_expr { some(d) => { space(s.s); word_space(s, ~"="); @@ -684,7 +684,7 @@ fn print_ty_method(s: ps, m: ast::ty_method) { } fn print_trait_method(s: ps, m: ast::trait_method) { - alt m { + match m { required(ty_m) => print_ty_method(s, ty_m), provided(m) => print_method(s, m) } @@ -702,7 +702,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| { - alt attr.node.style { + match attr.node.style { ast::attr_outer => { print_attribute(s, attr); count += 1; } _ => {/* fallthrough */ } } @@ -713,7 +713,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| { - alt attr.node.style { + match attr.node.style { ast::attr_inner => { print_attribute(s, attr); if !attr.node.is_sugared_doc { @@ -744,7 +744,7 @@ fn print_attribute(s: ps, attr: ast::attribute) { fn print_stmt(s: ps, st: ast::stmt) { maybe_print_comment(s, st.span.lo); - alt st.node { + match st.node { ast::stmt_decl(decl, _) => { print_decl(s, decl); } @@ -780,7 +780,7 @@ fn print_possibly_embedded_block(s: ps, blk: ast::blk, embedded: embed_type, fn print_possibly_embedded_block_(s: ps, blk: ast::blk, embedded: embed_type, indented: uint, attrs: ~[ast::attribute]) { - alt blk.node.rules { + match blk.node.rules { ast::unchecked_blk => word(s.s, ~"unchecked"), ast::unsafe_blk => word(s.s, ~"unsafe"), ast::default_blk => () @@ -788,7 +788,7 @@ fn print_possibly_embedded_block_(s: ps, blk: ast::blk, embedded: embed_type, maybe_print_comment(s, blk.span.lo); let ann_node = node_block(s, blk); s.ann.pre(ann_node); - alt embedded { + match embedded { block_block_fn => end(s), block_normal => bopen(s) } @@ -799,7 +799,7 @@ fn print_possibly_embedded_block_(s: ps, blk: ast::blk, embedded: embed_type, for blk.node.stmts.each |st| { print_stmt(s, *st); } - alt blk.node.expr { + match blk.node.expr { some(expr) => { space_if_not_bol(s); print_expr(s, expr); @@ -814,7 +814,7 @@ fn print_possibly_embedded_block_(s: ps, blk: ast::blk, embedded: embed_type, // return and fail, without arguments cannot appear is the discriminant of if, // alt, do, & while unambiguously without being parenthesized fn print_maybe_parens_discrim(s: ps, e: @ast::expr) { - let disambig = alt e.node { + let disambig = match e.node { ast::expr_ret(none) | ast::expr_fail(none) => true, _ => false }; @@ -831,9 +831,9 @@ fn print_if(s: ps, test: @ast::expr, blk: ast::blk, space(s.s); print_block(s, blk); fn do_else(s: ps, els: option<@ast::expr>) { - alt els { + match els { some(_else) => { - alt _else.node { + match _else.node { // "another else-if" ast::expr_if(i, t, e) => { cbox(s, indent_unit - 1u); @@ -864,11 +864,11 @@ fn print_if(s: ps, test: @ast::expr, blk: ast::blk, } fn print_mac(s: ps, m: ast::mac) { - alt m.node { + match m.node { ast::mac_invoc(path, arg, body) => { word(s.s, ~"#"); print_path(s, path, false); - alt arg { + match arg { some(@{node: ast::expr_vec(_, _), _}) => (), _ => word(s.s, ~" ") } @@ -888,12 +888,12 @@ fn print_mac(s: ps, m: ast::mac) { } fn print_vstore(s: ps, t: ast::vstore) { - alt t { + match t { ast::vstore_fixed(some(i)) => word(s.s, fmt!{"%u", i}), ast::vstore_fixed(none) => word(s.s, ~"_"), ast::vstore_uniq => word(s.s, ~"~"), ast::vstore_box => word(s.s, ~"@"), - ast::vstore_slice(r) => alt r.node { + ast::vstore_slice(r) => match r.node { ast::re_anon => word(s.s, ~"&"), ast::re_named(name) => { word(s.s, ~"&"); @@ -919,8 +919,8 @@ fn print_expr(s: ps, &&expr: @ast::expr) { ibox(s, indent_unit); let ann_node = node_expr(s, expr); s.ann.pre(ann_node); - alt expr.node { - ast::expr_vstore(e, v) => alt v { + match expr.node { + ast::expr_vstore(e, v) => match v { ast::vstore_fixed(_) => { print_expr(s, e); word(s.s, ~"/"); @@ -961,7 +961,7 @@ fn print_expr(s: ps, &&expr: @ast::expr) { ast::expr_rec(fields, wth) => { word(s.s, ~"{"); commasep_cmnt(s, consistent, fields, print_field, get_span); - alt wth { + match wth { some(expr) => { if vec::len(fields) > 0u { space(s.s); } ibox(s, indent_unit); @@ -977,7 +977,7 @@ fn print_expr(s: ps, &&expr: @ast::expr) { print_path(s, path, true); word(s.s, ~"{"); commasep_cmnt(s, consistent, fields, print_field, get_span); - alt wth { + match wth { some(expr) => { if vec::len(fields) > 0u { space(s.s); } ibox(s, indent_unit); @@ -998,7 +998,7 @@ fn print_expr(s: ps, &&expr: @ast::expr) { let mut base_args = args; let blk = if has_block { let blk_arg = vec::pop(base_args); - alt blk_arg.node { + match blk_arg.node { ast::expr_loop_body(_) => word_nbsp(s, ~"for"), ast::expr_do_body(_) => word_nbsp(s, ~"do"), _ => () @@ -1056,7 +1056,7 @@ fn print_expr(s: ps, &&expr: @ast::expr) { ast::expr_alt(expr, arms, mode) => { cbox(s, alt_indent_unit); ibox(s, 4u); - word_nbsp(s, ~"alt"); + word_nbsp(s, ~"match"); if mode == ast::alt_check { word_nbsp(s, ~"check"); } print_maybe_parens_discrim(s, expr); space(s.s); @@ -1074,7 +1074,7 @@ fn print_expr(s: ps, &&expr: @ast::expr) { print_pat(s, p); } space(s.s); - alt arm.guard { + match arm.guard { some(e) => { word_space(s, ~"if"); print_expr(s, e); @@ -1087,7 +1087,7 @@ fn print_expr(s: ps, &&expr: @ast::expr) { assert arm.body.node.view_items.is_empty(); assert arm.body.node.stmts.is_empty(); assert arm.body.node.rules == ast::default_blk; - alt arm.body.node.expr { + match arm.body.node.expr { some(expr) => { end(s); // close the ibox for the pattern print_expr(s, expr); @@ -1185,7 +1185,7 @@ fn print_expr(s: ps, &&expr: @ast::expr) { ast::expr_path(path) => print_path(s, path, true), ast::expr_fail(maybe_fail_val) => { word(s.s, ~"fail"); - alt maybe_fail_val { + match maybe_fail_val { some(expr) => { word(s.s, ~" "); print_expr(s, expr); } _ => () } @@ -1194,13 +1194,13 @@ fn print_expr(s: ps, &&expr: @ast::expr) { ast::expr_again => word(s.s, ~"again"), ast::expr_ret(result) => { word(s.s, ~"return"); - alt result { + match result { some(expr) => { word(s.s, ~" "); print_expr(s, expr); } _ => () } } ast::expr_log(lvl, lexp, expr) => { - alt check lvl { + match check lvl { 1 => { word_nbsp(s, ~"log"); print_expr(s, expr); } 0 => { word_nbsp(s, ~"log_err"); print_expr(s, expr); } 2 => { @@ -1225,7 +1225,7 @@ fn print_expr(s: ps, &&expr: @ast::expr) { } fn print_expr_parens_if_not_bot(s: ps, ex: @ast::expr) { - let parens = alt ex.node { + let parens = match ex.node { ast::expr_fail(_) | ast::expr_ret(_) | ast::expr_binary(_, _, _) | ast::expr_unary(_, _) | ast::expr_move(_, _) | ast::expr_copy(_) | @@ -1243,7 +1243,7 @@ fn print_expr_parens_if_not_bot(s: ps, ex: @ast::expr) { fn print_local_decl(s: ps, loc: @ast::local) { print_pat(s, loc.node.pat); - alt loc.node.ty.node { + match loc.node.ty.node { ast::ty_infer => (), _ => { word_space(s, ~":"); print_type(s, loc.node.ty); } } @@ -1251,7 +1251,7 @@ fn print_local_decl(s: ps, loc: @ast::local) { fn print_decl(s: ps, decl: @ast::decl) { maybe_print_comment(s, decl.span.lo); - alt decl.node { + match decl.node { ast::decl_local(locs) => { space_if_not_bol(s); ibox(s, indent_unit); @@ -1267,10 +1267,10 @@ fn print_decl(s: ps, decl: @ast::decl) { ibox(s, indent_unit); print_local_decl(s, loc); end(s); - alt loc.node.init { + match loc.node.init { some(init) => { nbsp(s); - alt init.op { + match init.op { ast::init_assign => word_space(s, ~"="), ast::init_move => word_space(s, ~"<-") } @@ -1306,7 +1306,7 @@ fn print_path(s: ps, &&path: @ast::path, colons_before_params: bool) { if path.rp.is_some() || !path.types.is_empty() { if colons_before_params { word(s.s, ~"::"); } - alt path.rp { + match path.rp { none => { /* ok */ } some(r) => { word(s.s, ~"/"); @@ -1328,22 +1328,22 @@ fn print_pat(s: ps, &&pat: @ast::pat) { s.ann.pre(ann_node); /* Pat isn't normalized, but the beauty of it is that it doesn't matter */ - alt pat.node { + match pat.node { ast::pat_wild => word(s.s, ~"_"), ast::pat_ident(binding_mode, path, sub) => { - alt binding_mode { + match binding_mode { ast::bind_by_ref => word_space(s, ~"ref"), ast::bind_by_value => () } print_path(s, path, true); - alt sub { + match sub { some(p) => { word(s.s, ~"@"); print_pat(s, p); } none => () } } ast::pat_enum(path, args_) => { print_path(s, path, true); - alt args_ { + match args_ { none => word(s.s, ~"(*)"), some(args) => { if vec::len(args) > 0u { @@ -1391,7 +1391,7 @@ fn print_pat(s: ps, &&pat: @ast::pat) { fn print_fn(s: ps, decl: ast::fn_decl, name: ast::ident, typarams: ~[ast::ty_param]) { - alt decl.purity { + match decl.purity { ast::impure_fn => head(s, ~"fn"), _ => head(s, purity_to_str(decl.purity) + ~" fn") } @@ -1442,7 +1442,7 @@ fn print_fn_block_args(s: ps, decl: ast::fn_decl, } fn mode_to_str(m: ast::mode) -> ~str { - alt m { + match m { ast::expl(ast::by_mutbl_ref) => ~"&", ast::expl(ast::by_move) => ~"-", ast::expl(ast::by_ref) => ~"&&", @@ -1462,7 +1462,7 @@ fn print_bounds(s: ps, bounds: @~[ast::ty_param_bound]) { word(s.s, ~":"); for vec::each(*bounds) |bound| { nbsp(s); - alt bound { + match bound { ast::bound_copy => word(s.s, ~"copy"), ast::bound_send => word(s.s, ~"send"), ast::bound_const => word(s.s, ~"const"), @@ -1487,7 +1487,7 @@ fn print_type_params(s: ps, &¶ms: ~[ast::ty_param]) { fn print_meta_item(s: ps, &&item: @ast::meta_item) { ibox(s, indent_unit); - alt item.node { + match item.node { ast::meta_word(name) => word(s.s, *name), ast::meta_name_value(name, value) => { word_space(s, *name); @@ -1505,7 +1505,7 @@ fn print_meta_item(s: ps, &&item: @ast::meta_item) { } fn print_view_path(s: ps, &&vp: @ast::view_path) { - alt vp.node { + match vp.node { ast::view_path_simple(ident, path, _) => { if path.idents[vec::len(path.idents)-1u] != ident { word_space(s, *ident); @@ -1538,7 +1538,7 @@ fn print_view_item(s: ps, item: @ast::view_item) { hardbreak_if_not_bol(s); maybe_print_comment(s, item.span.lo); print_outer_attributes(s, item.attrs); - alt item.node { + match item.node { ast::view_item_use(id, mta, _) => { head(s, ~"use"); word(s.s, *id); @@ -1572,7 +1572,7 @@ fn print_op_maybe_parens(s: ps, expr: @ast::expr, outer_prec: uint) { } fn print_mutability(s: ps, mutbl: ast::mutability) { - alt mutbl { + match mutbl { ast::m_mutbl => word_nbsp(s, ~"mut"), ast::m_const => word_nbsp(s, ~"const"), ast::m_imm => {/* nothing */ } @@ -1587,7 +1587,7 @@ fn print_mt(s: ps, mt: ast::mt) { fn print_arg(s: ps, input: ast::arg) { ibox(s, indent_unit); print_arg_mode(s, input.mode); - alt input.ty.node { + match input.ty.node { ast::ty_infer => word(s.s, *input.ident), _ => { if str::len(*input.ident) > 0u { @@ -1604,8 +1604,8 @@ fn print_ty_fn(s: ps, opt_proto: option<ast::proto>, tps: option<~[ast::ty_param]>) { ibox(s, indent_unit); word(s.s, opt_proto_to_str(opt_proto)); - alt id { some(id) => { word(s.s, ~" "); word(s.s, *id); } _ => () } - alt tps { some(tps) => print_type_params(s, tps), _ => () } + match id { some(id) => { word(s.s, ~" "); word(s.s, *id); } _ => () } + match tps { some(tps) => print_type_params(s, tps), _ => () } zerobreak(s.s); popen(s); commasep(s, inconsistent, decl.inputs, print_arg); @@ -1625,14 +1625,14 @@ fn print_ty_fn(s: ps, opt_proto: option<ast::proto>, fn maybe_print_trailing_comment(s: ps, span: codemap::span, next_pos: option<uint>) { let mut cm; - alt s.cm { some(ccm) => cm = ccm, _ => return } - alt next_comment(s) { + match s.cm { some(ccm) => cm = ccm, _ => return } + match next_comment(s) { some(cmnt) => { if cmnt.style != comments::trailing { return; } let span_line = codemap::lookup_char_pos(cm, span.hi); let comment_line = codemap::lookup_char_pos(cm, cmnt.pos); let mut next = cmnt.pos + 1u; - alt next_pos { none => (), some(p) => next = p } + match next_pos { none => (), some(p) => next = p } if span.hi < cmnt.pos && cmnt.pos < next && span_line.line == comment_line.line { print_comment(s, cmnt); @@ -1648,7 +1648,7 @@ fn print_remaining_comments(s: ps) { // make sure there is a line break at the end. if option::is_none(next_comment(s)) { hardbreak(s.s); } loop { - alt next_comment(s) { + match next_comment(s) { some(cmnt) => { print_comment(s, cmnt); s.cur_cmnt += 1u; } _ => break } @@ -1657,14 +1657,14 @@ fn print_remaining_comments(s: ps) { fn print_literal(s: ps, &&lit: @ast::lit) { maybe_print_comment(s, lit.span.lo); - alt next_lit(s, lit.span.lo) { + match next_lit(s, lit.span.lo) { some(ltrl) => { word(s.s, ltrl.lit); return; } _ => () } - alt lit.node { + match lit.node { ast::lit_str(st) => print_string(s, *st), ast::lit_int(ch, ast::ty_char) => { word(s.s, ~"'" + char::escape_default(ch as char) + ~"'"); @@ -1705,7 +1705,7 @@ fn print_literal(s: ps, &&lit: @ast::lit) { fn lit_to_str(l: @ast::lit) -> ~str { return to_str(l, print_literal); } fn next_lit(s: ps, pos: uint) -> option<comments::lit> { - alt s.literals { + match s.literals { some(lits) => { while s.cur_lit < vec::len(lits) { let ltrl = lits[s.cur_lit]; @@ -1721,7 +1721,7 @@ fn next_lit(s: ps, pos: uint) -> option<comments::lit> { fn maybe_print_comment(s: ps, pos: uint) { loop { - alt next_comment(s) { + match next_comment(s) { some(cmnt) => { if cmnt.pos < pos { print_comment(s, cmnt); @@ -1734,7 +1734,7 @@ fn maybe_print_comment(s: ps, pos: uint) { } fn print_comment(s: ps, cmnt: comments::cmnt) { - alt cmnt.style { + match cmnt.style { comments::mixed => { assert (vec::len(cmnt.lines) == 1u); zerobreak(s.s); @@ -1767,7 +1767,7 @@ fn print_comment(s: ps, cmnt: comments::cmnt) { comments::blank_line => { // We need to do at least one, possibly two hardbreaks. let is_semi = - alt s.s.last_token() { + match s.s.last_token() { pp::STRING(s, _) => *s == ~";", _ => false }; @@ -1792,7 +1792,7 @@ fn to_str<T>(t: T, f: fn@(ps, T)) -> ~str { } fn next_comment(s: ps) -> option<comments::cmnt> { - alt s.comments { + match s.comments { some(cmnts) => { if s.cur_cmnt < vec::len(cmnts) { return some(cmnts[s.cur_cmnt]); @@ -1803,14 +1803,14 @@ fn next_comment(s: ps) -> option<comments::cmnt> { } fn opt_proto_to_str(opt_p: option<ast::proto>) -> ~str { - alt opt_p { + match opt_p { none => ~"fn", some(p) => proto_to_str(p) } } pure fn purity_to_str(p: ast::purity) -> ~str { - alt p { + match p { ast::impure_fn => ~"impure", ast::unsafe_fn => ~"unsafe", ast::pure_fn => ~"pure", @@ -1819,14 +1819,14 @@ pure fn purity_to_str(p: ast::purity) -> ~str { } fn print_purity(s: ps, p: ast::purity) { - alt p { + match p { ast::impure_fn => (), _ => word_nbsp(s, purity_to_str(p)) } } fn proto_to_str(p: ast::proto) -> ~str { - return alt p { + return match p { ast::proto_bare => ~"extern fn", ast::proto_block => ~"fn&", ast::proto_uniq => ~"fn~", diff --git a/src/libsyntax/util/interner.rs b/src/libsyntax/util/interner.rs index 80bd9e3a6d1..ccc53020155 100644 --- a/src/libsyntax/util/interner.rs +++ b/src/libsyntax/util/interner.rs @@ -27,7 +27,7 @@ trait interner<T: const copy> { impl <T: const copy> of interner<T> for hash_interner<T> { fn intern(val: T) -> uint { - alt self.map.find(val) { + match self.map.find(val) { some(idx) => return idx, none => { let new_idx = self.vect.len(); diff --git a/src/libsyntax/visit.rs b/src/libsyntax/visit.rs index 1c92f26cabe..7df0fc739ad 100644 --- a/src/libsyntax/visit.rs +++ b/src/libsyntax/visit.rs @@ -25,7 +25,7 @@ enum fn_kind { } fn name_of_fn(fk: fn_kind) -> ident { - alt fk { + match fk { fk_item_fn(name, _) | fk_method(name, _, _) | fk_ctor(name, _, _, _, _) => /* FIXME (#2543) */ copy name, fk_anon(*) | fk_fn_block(*) => @~"anon", @@ -34,7 +34,7 @@ fn name_of_fn(fk: fn_kind) -> ident { } fn tps_of_fn(fk: fn_kind) -> ~[ty_param] { - alt fk { + match fk { fk_item_fn(_, tps) | fk_method(_, tps, _) | fk_ctor(_, _, tps, _, _) | fk_dtor(tps, _, _, _) => { /* FIXME (#2543) */ copy tps @@ -89,7 +89,7 @@ fn visit_crate<E>(c: crate, e: E, v: vt<E>) { } fn visit_crate_directive<E>(cd: @crate_directive, e: E, v: vt<E>) { - alt cd.node { + match cd.node { cdir_src_mod(_, _) => (), cdir_dir_mod(_, cdirs, _) => for cdirs.each |cdir| { visit_crate_directive(cdir, e, v); @@ -109,14 +109,14 @@ fn visit_view_item<E>(_vi: @view_item, _e: E, _v: vt<E>) { } fn visit_local<E>(loc: @local, e: E, v: vt<E>) { v.visit_pat(loc.node.pat, e, v); v.visit_ty(loc.node.ty, e, v); - alt loc.node.init { + match loc.node.init { none => (), some(i) => v.visit_expr(i.expr, e, v) } } fn visit_item<E>(i: @item, e: E, v: vt<E>) { - alt i.node { + match i.node { item_const(t, ex) => { v.visit_ty(t, e, v); v.visit_expr(ex, e, v); } item_fn(decl, tp, body) => { v.visit_fn(fk_item_fn(/* FIXME (#2543) */ copy i.ident, @@ -175,7 +175,7 @@ fn visit_item<E>(i: @item, e: E, v: vt<E>) { } fn visit_class_item<E>(cm: @class_member, e:E, v:vt<E>) { - alt cm.node { + match cm.node { instance_var(_, t, _, _, _) => v.visit_ty(t, e, v), class_method(m) => visit_method_helper(m, e, v) } @@ -184,7 +184,7 @@ fn visit_class_item<E>(cm: @class_member, e:E, v:vt<E>) { fn skip_ty<E>(_t: @ty, _e: E, _v: vt<E>) {} fn visit_ty<E>(t: @ty, e: E, v: vt<E>) { - alt t.node { + match t.node { ty_box(mt) | ty_uniq(mt) | ty_vec(mt) | ty_ptr(mt) | ty_rptr(_, mt) => { v.visit_ty(mt.ty, e, v); @@ -213,7 +213,7 @@ fn visit_path<E>(p: @path, e: E, v: vt<E>) { } fn visit_pat<E>(p: @pat, e: E, v: vt<E>) { - alt p.node { + match p.node { pat_enum(path, children) => { visit_path(path, e, v); do option::iter(children) |children| { @@ -237,7 +237,7 @@ fn visit_pat<E>(p: @pat, e: E, v: vt<E>) { } fn visit_foreign_item<E>(ni: @foreign_item, e: E, v: vt<E>) { - alt ni.node { + match ni.node { foreign_item_fn(fd, tps) => { v.visit_ty_params(tps, e, v); visit_fn_decl(fd, e, v); @@ -248,7 +248,7 @@ 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| { - alt bound { + match bound { bound_trait(t) => v.visit_ty(t, e, v), bound_copy | bound_send | bound_const | bound_owned => () } @@ -304,7 +304,7 @@ fn visit_ty_method<E>(m: ty_method, e: E, v: vt<E>) { } fn visit_trait_method<E>(m: trait_method, e: E, v: vt<E>) { - alt m { + match m { required(ty_m) => v.visit_ty_method(ty_m, e, v), provided(m) => visit_method_helper(m, e, v) } @@ -317,7 +317,7 @@ fn visit_block<E>(b: ast::blk, e: E, v: vt<E>) { } fn visit_stmt<E>(s: @stmt, e: E, v: vt<E>) { - alt s.node { + match s.node { stmt_decl(d, _) => v.visit_decl(d, e, v), stmt_expr(ex, _) => v.visit_expr(ex, e, v), stmt_semi(ex, _) => v.visit_expr(ex, e, v) @@ -325,7 +325,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 { + match d.node { decl_local(locs) => for locs.each |loc| { v.visit_local(loc, e, v) } @@ -334,7 +334,7 @@ fn visit_decl<E>(d: @decl, e: E, v: vt<E>) { } fn visit_expr_opt<E>(eo: option<@expr>, e: E, v: vt<E>) { - alt eo { none => (), some(ex) => v.visit_expr(ex, e, v) } + match eo { none => (), some(ex) => v.visit_expr(ex, e, v) } } fn visit_exprs<E>(exprs: ~[@expr], e: E, v: vt<E>) { @@ -342,7 +342,7 @@ fn visit_exprs<E>(exprs: ~[@expr], e: E, v: vt<E>) { } fn visit_mac<E>(m: mac, e: E, v: vt<E>) { - alt m.node { + match m.node { ast::mac_invoc(pth, arg, body) => { option::map(arg, |arg| v.visit_expr(arg, e, v)); } ast::mac_invoc_tt(pth, tt) => { /* no user-serviceable parts inside */ } @@ -353,7 +353,7 @@ fn visit_mac<E>(m: mac, e: E, v: vt<E>) { } fn visit_expr<E>(ex: @expr, e: E, v: vt<E>) { - alt ex.node { + match ex.node { expr_vstore(x, _) => v.visit_expr(x, e, v), expr_vec(es, _) => visit_exprs(es, e, v), expr_repeat(element, count, _) => { |
