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/rustc/metadata | |
| parent | d3a9bb1bd4a1d510bbaca2ab1121e4c85a239247 (diff) | |
| download | rust-ecaf9e39c9435fa2de4fe393c4b263be36eb2d99.tar.gz rust-ecaf9e39c9435fa2de4fe393c4b263be36eb2d99.zip | |
Convert alt to match. Stop parsing alt
Diffstat (limited to 'src/rustc/metadata')
| -rw-r--r-- | src/rustc/metadata/creader.rs | 16 | ||||
| -rw-r--r-- | src/rustc/metadata/csearch.rs | 2 | ||||
| -rw-r--r-- | src/rustc/metadata/cstore.rs | 2 | ||||
| -rw-r--r-- | src/rustc/metadata/decoder.rs | 54 | ||||
| -rw-r--r-- | src/rustc/metadata/encoder.rs | 60 | ||||
| -rw-r--r-- | src/rustc/metadata/filesearch.rs | 12 | ||||
| -rw-r--r-- | src/rustc/metadata/loader.rs | 16 | ||||
| -rw-r--r-- | src/rustc/metadata/tydecode.rs | 34 | ||||
| -rw-r--r-- | src/rustc/metadata/tyencode.rs | 38 |
9 files changed, 117 insertions, 117 deletions
diff --git a/src/rustc/metadata/creader.rs b/src/rustc/metadata/creader.rs index 03dd9c389dd..5b72a6caa6c 100644 --- a/src/rustc/metadata/creader.rs +++ b/src/rustc/metadata/creader.rs @@ -100,7 +100,7 @@ type env = @{diag: span_handler, mut next_crate_num: ast::crate_num}; fn visit_view_item(e: env, i: @ast::view_item) { - alt i.node { + match i.node { ast::view_item_use(ident, meta_items, id) => { debug!{"resolving use stmt. ident: %?, meta: %?", ident, meta_items}; let cnum = resolve_crate(e, ident, meta_items, ~"", i.span); @@ -111,9 +111,9 @@ fn visit_view_item(e: env, i: @ast::view_item) { } fn visit_item(e: env, i: @ast::item) { - alt i.node { + match i.node { ast::item_foreign_mod(m) => { - alt attr::foreign_abi(i.attrs) { + match attr::foreign_abi(i.attrs) { either::right(abi) => { if abi != ast::foreign_abi_cdecl && abi != ast::foreign_abi_stdcall { return; } @@ -123,7 +123,7 @@ fn visit_item(e: env, i: @ast::item) { let cstore = e.cstore; let foreign_name = - alt attr::first_attr_value_str_by_name(i.attrs, ~"link_name") { + match attr::first_attr_value_str_by_name(i.attrs, ~"link_name") { some(nn) => { if *nn == ~"" { e.diag.span_fatal( @@ -144,7 +144,7 @@ fn visit_item(e: env, i: @ast::item) { ~"' already added: can't specify link_args."); } for link_args.each |a| { - alt attr::get_meta_item_value_str(attr::attr_meta(a)) { + match attr::get_meta_item_value_str(attr::attr_meta(a)) { some(linkarg) => { cstore::add_used_link_args(cstore, *linkarg); } @@ -187,7 +187,7 @@ fn resolve_crate(e: env, ident: ast::ident, metas: ~[@ast::meta_item], hash: ~str, span: span) -> ast::crate_num { let metas = metas_with_ident(ident, metas); - alt existing_match(e, metas, hash) { + match existing_match(e, metas, hash) { none => { let load_ctxt: loader::ctxt = { diag: e.diag, @@ -218,7 +218,7 @@ fn resolve_crate(e: env, ident: ast::ident, metas: ~[@ast::meta_item], let cnum_map = resolve_crate_deps(e, cdata); let cname = - alt attr::last_meta_item_value_str_by_name(metas, ~"name") { + match attr::last_meta_item_value_str_by_name(metas, ~"name") { option::some(v) => v, option::none => ident }; @@ -248,7 +248,7 @@ fn resolve_crate_deps(e: env, cdata: @~[u8]) -> cstore::cnum_map { let cmetas = metas_with(dep.vers, @~"vers", ~[]); debug!{"resolving dep crate %s ver: %s hash: %s", *dep.name, *dep.vers, *dep.hash}; - alt existing_match(e, metas_with_ident(cname, cmetas), *dep.hash) { + match existing_match(e, metas_with_ident(cname, cmetas), *dep.hash) { some(local_cnum) => { debug!{"already have it"}; // We've already seen this crate diff --git a/src/rustc/metadata/csearch.rs b/src/rustc/metadata/csearch.rs index 1a536ca1bdd..627d7a326d0 100644 --- a/src/rustc/metadata/csearch.rs +++ b/src/rustc/metadata/csearch.rs @@ -57,7 +57,7 @@ fn lookup_defs(cstore: cstore::cstore, cnum: ast::crate_num, fn lookup_method_purity(cstore: cstore::cstore, did: ast::def_id) -> ast::purity { let cdata = cstore::get_crate_data(cstore, did.crate).data; - alt check decoder::lookup_def(did.crate, cdata, did) { + match check decoder::lookup_def(did.crate, cdata, did) { ast::def_fn(_, p) => p } } diff --git a/src/rustc/metadata/cstore.rs b/src/rustc/metadata/cstore.rs index a177b264e5b..75c7c8dd9fe 100644 --- a/src/rustc/metadata/cstore.rs +++ b/src/rustc/metadata/cstore.rs @@ -64,7 +64,7 @@ type use_crate_map = map::hashmap<ast::node_id, ast::crate_num>; // Internal method to retrieve the data from the cstore pure fn p(cstore: cstore) -> cstore_private { - alt cstore { private(p) => p } + match cstore { private(p) => p } } fn mk_cstore() -> cstore { diff --git a/src/rustc/metadata/decoder.rs b/src/rustc/metadata/decoder.rs index 2e4a670c841..2fae50785af 100644 --- a/src/rustc/metadata/decoder.rs +++ b/src/rustc/metadata/decoder.rs @@ -99,7 +99,7 @@ fn find_item(item_id: int, items: ebml::doc) -> ebml::doc { // to the item data. fn lookup_item(item_id: int, data: @~[u8]) -> ebml::doc { let items = ebml::get_doc(ebml::doc(data), tag_items); - alt maybe_find_item(item_id, items) { + match maybe_find_item(item_id, items) { none => fail(fmt!{"lookup_item: id not found: %d", item_id}), some(d) => d } @@ -135,7 +135,7 @@ fn field_mutability(d: ebml::doc) -> ast::class_mutability { ebml::maybe_get_doc(d, tag_class_mut), ast::class_immutable, |d| { - alt ebml::doc_as_u8(d) as char { + match ebml::doc_as_u8(d) as char { 'm' => ast::class_mutable, _ => ast::class_immutable } @@ -184,7 +184,7 @@ fn item_ty_param_bounds(item: ebml::doc, tcx: ty::ctxt, cdata: cmd) } fn item_ty_region_param(item: ebml::doc) -> bool { - alt ebml::maybe_get_doc(item, tag_region_param) { + match ebml::maybe_get_doc(item, tag_region_param) { some(_) => true, none => false } @@ -275,7 +275,7 @@ fn lookup_item_name(data: @~[u8], id: ast::node_id) -> ast::ident { fn item_to_def_like(item: ebml::doc, did: ast::def_id, cnum: ast::crate_num) -> def_like { let fam_ch = item_family(item); - alt fam_ch { + match fam_ch { 'c' => dl_def(ast::def_const(did)), 'C' => dl_def(ast::def_class(did, true)), 'S' => dl_def(ast::def_class(did, false)), @@ -349,7 +349,7 @@ fn get_class_method(cdata: cmd, id: ast::node_id, name: ast::ident) -> ast::def_id { let items = ebml::get_doc(ebml::doc(cdata.data), tag_items); let mut found = none; - let cls_items = alt maybe_find_item(id, items) { + let cls_items = match maybe_find_item(id, items) { some(it) => it, none => fail (fmt!{"get_class_method: class id not found \ when looking up method %s", *name}) @@ -360,7 +360,7 @@ fn get_class_method(cdata: cmd, id: ast::node_id, found = some(m_did); } } - alt found { + match found { some(found) => found, none => fail (fmt!{"get_class_method: no method named %s", *name}) } @@ -369,7 +369,7 @@ fn get_class_method(cdata: cmd, id: ast::node_id, fn class_dtor(cdata: cmd, id: ast::node_id) -> option<ast::def_id> { let items = ebml::get_doc(ebml::doc(cdata.data), tag_items); let mut found = none; - let cls_items = alt maybe_find_item(id, items) { + let cls_items = match maybe_find_item(id, items) { some(it) => it, none => fail (fmt!{"class_dtor: class id not found \ when looking up dtor for %d", id}) @@ -394,7 +394,7 @@ enum def_like { } fn def_like_to_def(def_like: def_like) -> ast::def { - alt def_like { + match def_like { dl_def(def) => return def, dl_impl(*) => fail ~"found impl in def_like_to_def", dl_field => fail ~"found field in def_like_to_def" @@ -467,7 +467,7 @@ fn each_path(cdata: cmd, f: fn(path_entry) -> bool) { let def_id = class_member_id(path_doc, cdata); // Get the item. - alt maybe_find_item(def_id.node, items) { + match maybe_find_item(def_id.node, items) { none => { debug!{"(each_path) ignoring implicit item: %s", *path}; @@ -515,14 +515,14 @@ fn maybe_get_item_ast(cdata: cmd, tcx: ty::ctxt, debug!{"Looking up item: %d", id}; let item_doc = lookup_item(id, cdata.data); let path = vec::init(item_path(item_doc)); - alt decode_inlined_item(cdata, tcx, path, item_doc) { + match decode_inlined_item(cdata, tcx, path, item_doc) { some(ii) => csearch::found(ii), none => { - alt item_parent_item(item_doc) { + match item_parent_item(item_doc) { some(did) => { let did = translate_def_id(cdata, did); let parent_item = lookup_item(did.node, cdata.data); - alt decode_inlined_item(cdata, tcx, path, + match decode_inlined_item(cdata, tcx, path, parent_item) { some(ii) => csearch::found_parent(did, ii), none => csearch::not_found @@ -548,13 +548,13 @@ fn get_enum_variants(cdata: cmd, id: ast::node_id, tcx: ty::ctxt) tcx, cdata); let name = item_name(item); let mut arg_tys: ~[ty::t] = ~[]; - alt ty::get(ctor_ty).struct { + match ty::get(ctor_ty).struct { ty::ty_fn(f) => { for f.inputs.each |a| { vec::push(arg_tys, a.ty); } } _ => { /* Nullary enum variant. */ } } - alt variant_disr_val(item) { + match variant_disr_val(item) { some(val) => { disr_val = val; } _ => { /* empty */ } } @@ -577,7 +577,7 @@ type _impl = {did: ast::def_id, ident: ast::ident, methods: ~[@method_info]}; fn get_self_ty(item: ebml::doc) -> ast::self_ty_ { fn get_mutability(ch: u8) -> ast::mutability { - alt ch as char { + match ch as char { 'i' => { ast::m_imm } 'm' => { ast::m_mutbl } 'c' => { ast::m_const } @@ -591,7 +591,7 @@ fn get_self_ty(item: ebml::doc) -> ast::self_ty_ { let string = ebml::doc_as_str(self_type_doc); let self_ty_kind = string[0]; - alt self_ty_kind as char { + match self_ty_kind as char { 'r' => { return ast::sty_by_ref; } 'v' => { return ast::sty_value; } '@' => { return ast::sty_box(get_mutability(string[1])); } @@ -654,7 +654,7 @@ fn get_impls_for_mod(cdata: cmd, let impl_data = impl_cdata.data; let item = lookup_item(local_did.node, impl_data); let nm = item_name(item); - if alt name { some(n) => { n == nm } none => { true } } { + if match name { some(n) => { n == nm } none => { true } } { let base_tps = item_ty_param_count(item); vec::push(result, @{ did: local_did, ident: nm, @@ -675,7 +675,7 @@ fn get_trait_methods(cdata: cmd, id: ast::node_id, tcx: ty::ctxt) let bounds = item_ty_param_bounds(mth, tcx, cdata); let name = item_name(mth); let ty = doc_type(mth, tcx, cdata); - let fty = alt ty::get(ty).struct { + let fty = match ty::get(ty).struct { ty::ty_fn(f) => f, _ => { tcx.diag.handler().bug( @@ -684,7 +684,7 @@ fn get_trait_methods(cdata: cmd, id: ast::node_id, tcx: ty::ctxt) let self_ty = get_self_ty(mth); vec::push(result, {ident: name, tps: bounds, fty: fty, self_ty: self_ty, - purity: alt check item_family(mth) { + purity: match check item_family(mth) { 'u' => ast::unsafe_fn, 'f' => ast::impure_fn, 'p' => ast::pure_fn @@ -742,7 +742,7 @@ fn get_class_members(cdata: cmd, id: ast::node_id, } pure fn family_to_visibility(family: char) -> ast::visibility { - alt family { + match family { 'g' => ast::public, 'j' => ast::private, 'N' => ast::inherited, @@ -756,7 +756,7 @@ fn get_class_fields(cdata: cmd, id: ast::node_id) -> ~[ty::field_ty] { } fn family_has_type_params(fam_ch: char) -> bool { - alt check fam_ch { + match check fam_ch { 'c' | 'T' | 'm' | 'n' | 'g' | 'h' | 'j' => false, 'f' | 'u' | 'p' | 'F' | 'U' | 'P' | 'y' | 't' | 'v' | 'i' | 'I' | 'C' | 'a' | 'S' @@ -765,7 +765,7 @@ fn family_has_type_params(fam_ch: char) -> bool { } fn family_names_type(fam_ch: char) -> bool { - alt fam_ch { 'y' | 't' | 'I' => true, _ => false } + match fam_ch { 'y' | 't' | 'I' => true, _ => false } } fn read_path(d: ebml::doc) -> {path: ~str, pos: uint} { @@ -778,7 +778,7 @@ fn read_path(d: ebml::doc) -> {path: ~str, pos: uint} { fn describe_def(items: ebml::doc, id: ast::def_id) -> ~str { if id.crate != ast::local_crate { return ~"external"; } - let it = alt maybe_find_item(id.node, items) { + let it = match maybe_find_item(id.node, items) { some(it) => it, none => fail (fmt!{"describe_def: item not found %?", id}) }; @@ -786,7 +786,7 @@ fn describe_def(items: ebml::doc, id: ast::def_id) -> ~str { } fn item_family_to_str(fam: char) -> ~str { - alt check fam { + match check fam { 'c' => return ~"const", 'f' => return ~"fn", 'u' => return ~"unsafe fn", @@ -837,7 +837,7 @@ fn get_meta_items(md: ebml::doc) -> ~[@ast::meta_item] { fn get_attributes(md: ebml::doc) -> ~[ast::attribute] { let mut attrs: ~[ast::attribute] = ~[]; - alt ebml::maybe_get_doc(md, tag_attributes) { + match ebml::maybe_get_doc(md, tag_attributes) { option::some(attrs_d) => { for ebml::tagged_docs(attrs_d, tag_attribute) |attr_doc| { let meta_items = get_meta_items(attr_doc); @@ -916,7 +916,7 @@ fn get_crate_hash(data: @~[u8]) -> @~str { fn get_crate_vers(data: @~[u8]) -> @~str { let attrs = decoder::get_crate_attributes(data); - return alt attr::last_meta_item_value_str_by_name( + return match attr::last_meta_item_value_str_by_name( attr::find_linkage_metas(attrs), ~"vers") { some(ver) => ver, none => @~"0.0" @@ -997,7 +997,7 @@ fn translate_def_id(cdata: cmd, did: ast::def_id) -> ast::def_id { return {crate: cdata.cnum, node: did.node}; } - alt cdata.cnum_map.find(did.crate) { + match cdata.cnum_map.find(did.crate) { option::some(n) => return {crate: n, node: did.node}, option::none => fail ~"didn't find a crate in the cnum_map" } diff --git a/src/rustc/metadata/encoder.rs b/src/rustc/metadata/encoder.rs index fc23c8b351c..39057647b7f 100644 --- a/src/rustc/metadata/encoder.rs +++ b/src/rustc/metadata/encoder.rs @@ -101,7 +101,7 @@ fn encode_named_def_id(ebml_w: ebml::writer, name: ident, id: def_id) { fn encode_mutability(ebml_w: ebml::writer, mt: class_mutability) { do ebml_w.wr_tag(tag_class_mut) { - let val = alt mt { + let val = match mt { class_immutable => 'i', class_mutable => 'm' }; @@ -145,10 +145,10 @@ fn encode_foreign_module_item_paths(ebml_w: ebml::writer, nmod: foreign_mod, fn encode_class_item_paths(ebml_w: ebml::writer, items: ~[@class_member], path: ~[ident], &index: ~[entry<~str>]) { for items.each |it| { - alt ast_util::class_member_visibility(it) { + match ast_util::class_member_visibility(it) { private => again, public | inherited => { - let (id, ident) = alt it.node { + let (id, ident) = match it.node { instance_var(v, _, _, vid, _) => (vid, v), class_method(it) => (it.id, it.ident) }; @@ -168,7 +168,7 @@ fn encode_module_item_paths(ebml_w: ebml::writer, ecx: @encode_ctxt, if !ast_util::is_item_impl(it) { add_to_index(ebml_w, path, index, it.ident); } - alt it.node { + match it.node { item_const(_, _) => { encode_named_def_id(ebml_w, it.ident, local_def(it.id)); } @@ -205,7 +205,7 @@ fn encode_module_item_paths(ebml_w: ebml::writer, ecx: @encode_ctxt, // class and for its ctor add_to_index(ebml_w, path, index, it.ident); - alt m_ctor { + match m_ctor { none => { // Nothing to do. } @@ -317,7 +317,7 @@ fn encode_type(ecx: @encode_ctxt, ebml_w: ebml::writer, typ: ty::t) { fn encode_symbol(ecx: @encode_ctxt, ebml_w: ebml::writer, id: node_id) { ebml_w.start_tag(tag_items_data_item_symbol); - let sym = alt ecx.item_symbols.find(id) { + let sym = match ecx.item_symbols.find(id) { some(x) => x, none => { ecx.diag.handler().bug( @@ -382,7 +382,7 @@ fn encode_path(ebml_w: ebml::writer, path: ast_map::path, name: ast_map::path_elt) { fn encode_path_elt(ebml_w: ebml::writer, elt: ast_map::path_elt) { - let (tag, name) = alt elt { + let (tag, name) = match elt { ast_map::path_mod(name) => (tag_path_elt_mod, name), ast_map::path_name(name) => (tag_path_elt_name, name) }; @@ -416,7 +416,7 @@ fn encode_info_for_mod(ecx: @encode_ctxt, ebml_w: ebml::writer, md: _mod, ast_util::is_exported(ident, md)}; ebml_w.start_tag(tag_mod_impl); - alt ecx.tcx.items.find(did.node) { + match ecx.tcx.items.find(did.node) { some(ast_map::node_item(it@@{node: cl@item_class(*),_},_)) => { /* If did stands for a trait ref, we need to map it to its parent class */ @@ -436,7 +436,7 @@ fn encode_info_for_mod(ecx: @encode_ctxt, ebml_w: ebml::writer, md: _mod, } fn encode_visibility(ebml_w: ebml::writer, visibility: visibility) { - encode_family(ebml_w, alt visibility { + encode_family(ebml_w, match visibility { public => 'g', private => 'j', inherited => 'N' @@ -444,7 +444,7 @@ fn encode_visibility(ebml_w: ebml::writer, visibility: visibility) { } fn encode_region(ebml_w: ebml::writer, region: region) { - alt region.node { + match region.node { re_anon => { ebml_w.wr_tagged_str(tag_item_trait_method_self_ty, ~""); } @@ -459,7 +459,7 @@ fn encode_self_type(ebml_w: ebml::writer, self_type: ast::self_ty_) { // Encode the base self type. let ch; - alt self_type { + match self_type { sty_by_ref => { ch = 'r' as u8; } sty_value => { ch = 'v' as u8; } sty_region(_, _) => { ch = '&' as u8; } @@ -469,7 +469,7 @@ fn encode_self_type(ebml_w: ebml::writer, self_type: ast::self_ty_) { ebml_w.writer.write(&[ ch ]); // Encode mutability. - alt self_type { + match self_type { sty_by_ref | sty_value => { /* No-op. */ } sty_region(_, m_imm) | sty_box(m_imm) | sty_uniq(m_imm) => { ebml_w.writer.write(&[ 'i' as u8 ]); @@ -483,7 +483,7 @@ fn encode_self_type(ebml_w: ebml::writer, self_type: ast::self_ty_) { } // Encode the region. - alt self_type { + match self_type { sty_region(region, _) => { encode_region(ebml_w, *region); } @@ -508,7 +508,7 @@ fn encode_info_for_class(ecx: @encode_ctxt, ebml_w: ebml::writer, for items.each |ci| { /* We encode both private and public fields -- need to include private fields to get the offsets right */ - alt ci.node { + match ci.node { instance_var(nm, _, mt, id, vis) => { vec::push(*index, {val: id, pos: ebml_w.writer.tell()}); vec::push(*global_index, {val: id, pos: ebml_w.writer.tell()}); @@ -523,7 +523,7 @@ fn encode_info_for_class(ecx: @encode_ctxt, ebml_w: ebml::writer, ebml_w.end_tag(); } class_method(m) => { - alt m.vis { + match m.vis { public | inherited => { vec::push(*index, {val: m.id, pos: ebml_w.writer.tell()}); vec::push(*global_index, @@ -557,7 +557,7 @@ fn encode_info_for_fn(ecx: @encode_ctxt, ebml_w: ebml::writer, util::ppaux::ty_to_str(ecx.tcx, its_ty), id}; encode_type(ecx, ebml_w, its_ty); encode_path(ebml_w, path, ast_map::path_name(ident)); - alt item { + match item { some(it) => { ecx.encode_inlined_item(ecx, ebml_w, path, it); } @@ -592,7 +592,7 @@ fn encode_info_for_method(ecx: @encode_ctxt, ebml_w: ebml::writer, } fn purity_fn_family(p: purity) -> char { - alt p { + match p { unsafe_fn => 'u', pure_fn => 'p', impure_fn => 'f', @@ -602,7 +602,7 @@ fn purity_fn_family(p: purity) -> char { fn should_inline(attrs: ~[attribute]) -> bool { - alt attr::find_inline_attr(attrs) { + match attr::find_inline_attr(attrs) { attr::ia_none | attr::ia_never => false, attr::ia_hint | attr::ia_always => true } @@ -614,7 +614,7 @@ fn encode_info_for_item(ecx: @encode_ctxt, ebml_w: ebml::writer, item: @item, let tcx = ecx.tcx; let must_write = - alt item.node { + match item.node { item_enum(_, _) | item_impl(*) | item_trait(*) | item_class(*) => true, _ => false @@ -627,7 +627,7 @@ fn encode_info_for_item(ecx: @encode_ctxt, ebml_w: ebml::writer, item: @item, } let add_to_index = |copy ebml_w| add_to_index_(item, ebml_w, index); - alt item.node { + match item.node { item_const(_, _) => { add_to_index(); ebml_w.start_tag(tag_items_data_item); @@ -719,7 +719,7 @@ fn encode_info_for_item(ecx: @encode_ctxt, ebml_w: ebml::writer, item: @item, ebml_w.start_tag(tag_items_data_item); encode_def_id(ebml_w, local_def(item.id)); - alt ctor { + match ctor { none => encode_family(ebml_w, 'S'), some(_) => encode_family(ebml_w, 'C') } @@ -752,7 +752,7 @@ fn encode_info_for_item(ecx: @encode_ctxt, ebml_w: ebml::writer, item: @item, ebml_w.end_tag(); } for ms.each |m| { - alt m.vis { + match m.vis { private => { /* do nothing */ } public | inherited => { /* Write the info that's needed when viewing this class @@ -823,7 +823,7 @@ fn encode_info_for_item(ecx: @encode_ctxt, ebml_w: ebml::writer, item: @item, encode_attributes(ebml_w, item.attrs); let mut i = 0u; for vec::each(*ty::trait_methods(tcx, local_def(item.id))) |mty| { - alt ms[i] { + match ms[i] { required(ty_m) => { ebml_w.start_tag(tag_item_trait_method); encode_name(ebml_w, mty.ident); @@ -859,7 +859,7 @@ fn encode_info_for_foreign_item(ecx: @encode_ctxt, ebml_w: ebml::writer, vec::push(*index, {val: nitem.id, pos: ebml_w.writer.tell()}); ebml_w.start_tag(tag_items_data_item); - alt nitem.node { + match nitem.node { foreign_item_fn(fn_decl, tps) => { encode_def_id(ebml_w, local_def(nitem.id)); encode_family(ebml_w, purity_fn_family(fn_decl.purity)); @@ -888,11 +888,11 @@ fn encode_info_for_items(ecx: @encode_ctxt, ebml_w: ebml::writer, visit_expr: |_e, _cx, _v| { }, visit_item: |i, cx, v, copy ebml_w| { visit::visit_item(i, cx, v); - alt check ecx.tcx.items.get(i.id) { + match check ecx.tcx.items.get(i.id) { ast_map::node_item(_, pt) => { encode_info_for_item(ecx, ebml_w, i, index, *pt); /* encode ctor, then encode items */ - alt i.node { + match i.node { item_class(tps, _, _, some(ctor), m_dtor) => { debug!{"encoding info for ctor %s %d", *i.ident, ctor.node.id}; @@ -913,7 +913,7 @@ fn encode_info_for_items(ecx: @encode_ctxt, ebml_w: ebml::writer, }, visit_foreign_item: |ni, cx, v, copy ebml_w| { visit::visit_foreign_item(ni, cx, v); - alt check ecx.tcx.items.get(ni.id) { + match check ecx.tcx.items.get(ni.id) { ast_map::node_foreign_item(_, abi, pt) => { encode_info_for_foreign_item(ecx, ebml_w, ni, index, *pt, abi); @@ -981,7 +981,7 @@ fn write_int(writer: io::writer, &&n: int) { } fn encode_meta_item(ebml_w: ebml::writer, mi: meta_item) { - alt mi.node { + match mi.node { meta_word(name) => { ebml_w.start_tag(tag_meta_item_word); ebml_w.start_tag(tag_meta_item_name); @@ -990,7 +990,7 @@ fn encode_meta_item(ebml_w: ebml::writer, mi: meta_item) { ebml_w.end_tag(); } meta_name_value(name, value) => { - alt value.node { + match value.node { lit_str(value) => { ebml_w.start_tag(tag_meta_item_name_value); ebml_w.start_tag(tag_meta_item_name); @@ -1064,7 +1064,7 @@ fn synthesize_crate_attrs(ecx: @encode_ctxt, crate: @crate) -> ~[attribute] { if *attr::get_attr_name(attr) != ~"link" { attr } else { - alt attr.node.value.node { + match attr.node.value.node { meta_list(n, l) => { found_link_attr = true;; synthesize_link_attr(ecx, l) diff --git a/src/rustc/metadata/filesearch.rs b/src/rustc/metadata/filesearch.rs index 656aa4a0ae2..54aef6e858f 100644 --- a/src/rustc/metadata/filesearch.rs +++ b/src/rustc/metadata/filesearch.rs @@ -43,11 +43,11 @@ fn mk_filesearch(maybe_sysroot: option<path>, vec::push(paths, make_target_lib_path(self.sysroot, self.target_triple)); - alt get_cargo_lib_path_nearest() { + match get_cargo_lib_path_nearest() { result::ok(p) => vec::push(paths, p), result::err(p) => () } - alt get_cargo_lib_path() { + match get_cargo_lib_path() { result::ok(p) => vec::push(paths, p), result::err(p) => () } @@ -101,14 +101,14 @@ fn make_target_lib_path(sysroot: path, } fn get_default_sysroot() -> path { - alt os::self_exe_path() { + match os::self_exe_path() { option::some(p) => path::normalize(path::connect(p, ~"..")), option::none => fail ~"can't determine value for sysroot" } } fn get_sysroot(maybe_sysroot: option<path>) -> path { - alt maybe_sysroot { + match maybe_sysroot { option::some(sr) => sr, option::none => get_default_sysroot() } @@ -120,9 +120,9 @@ fn get_cargo_sysroot() -> result<path, ~str> { } fn get_cargo_root() -> result<path, ~str> { - alt os::getenv(~"CARGO_ROOT") { + match os::getenv(~"CARGO_ROOT") { some(_p) => result::ok(_p), - none => alt os::homedir() { + none => match os::homedir() { some(_q) => result::ok(path::connect(_q, ~".cargo")), none => result::err(~"no CARGO_ROOT or home directory") } diff --git a/src/rustc/metadata/loader.rs b/src/rustc/metadata/loader.rs index e45fdeb06b8..e5a2e0848e9 100644 --- a/src/rustc/metadata/loader.rs +++ b/src/rustc/metadata/loader.rs @@ -37,7 +37,7 @@ type ctxt = { }; fn load_library_crate(cx: ctxt) -> {ident: ~str, data: @~[u8]} { - alt find_library_crate(cx) { + match find_library_crate(cx) { some(t) => return t, none => { cx.diag.span_fatal( @@ -53,7 +53,7 @@ fn find_library_crate(cx: ctxt) -> option<{ident: ~str, data: @~[u8]}> { fn libname(cx: ctxt) -> {prefix: ~str, suffix: ~str} { if cx.static { return {prefix: ~"lib", suffix: ~".rlib"}; } - alt cx.os { + match cx.os { os_win32 => return {prefix: ~"", suffix: ~".dll"}, os_macos => return {prefix: ~"lib", suffix: ~".dylib"}, os_linux => return {prefix: ~"lib", suffix: ~".so"}, @@ -79,7 +79,7 @@ fn find_library_crate_aux(cx: ctxt, option::none::<()> } else { debug!{"%s is a candidate", path}; - alt get_metadata_section(cx.os, path) { + match get_metadata_section(cx.os, path) { option::some(cvec) => { if !crate_matches(cvec, cx.metas, cx.hash) { debug!{"skipping %s, metadata doesn't match", path}; @@ -118,9 +118,9 @@ fn find_library_crate_aux(cx: ctxt, fn crate_name_from_metas(metas: ~[@ast::meta_item]) -> @~str { let name_items = attr::find_meta_items_by_name(metas, ~"name"); - alt vec::last_opt(name_items) { + match vec::last_opt(name_items) { some(i) => { - alt attr::get_meta_item_value_str(i) { + match attr::get_meta_item_value_str(i) { some(n) => n, // FIXME (#2406): Probably want a warning here since the user // is using the wrong type of meta item. @@ -175,7 +175,7 @@ fn get_metadata_section(os: os, llvm::LLVMRustCreateMemoryBufferWithContentsOfFile(buf) }); if mb as int == 0 { return option::none::<@~[u8]>; } - let of = alt mk_object_file(mb) { + let of = match mk_object_file(mb) { option::some(of) => of, _ => return option::none::<@~[u8]> }; @@ -197,7 +197,7 @@ fn get_metadata_section(os: os, } fn meta_section_name(os: os) -> ~str { - alt os { + match os { os_macos => ~"__DATA,__note.rustc", os_win32 => ~".note.rustc", os_linux => ~".note.rustc", @@ -207,7 +207,7 @@ fn meta_section_name(os: os) -> ~str { // A diagnostic function for dumping crate metadata to an output stream fn list_file_metadata(os: os, path: ~str, out: io::writer) { - alt get_metadata_section(os, path) { + match get_metadata_section(os, path) { option::some(bytes) => decoder::list_crate_metadata(bytes, out), option::none => { out.write_str(~"could not find metadata in " + path + ~".\n"); diff --git a/src/rustc/metadata/tydecode.rs b/src/rustc/metadata/tydecode.rs index fee68f5592d..a834147af96 100644 --- a/src/rustc/metadata/tydecode.rs +++ b/src/rustc/metadata/tydecode.rs @@ -57,7 +57,7 @@ fn parse_ty_data(data: @~[u8], crate_num: int, pos: uint, tcx: ty::ctxt, } fn parse_ret_ty(st: @pstate, conv: conv_did) -> (ast::ret_style, ty::t) { - alt peek(st) { + match peek(st) { '!' => { next(st); (ast::noreturn, ty::mk_bot(st.tcx)) } _ => (ast::return_val, parse_ty(st, conv)) } @@ -68,7 +68,7 @@ fn parse_path(st: @pstate) -> @ast::path { fn is_last(c: char) -> bool { return c == '(' || c == ':'; } vec::push(idents, parse_ident_(st, is_last)); loop { - alt peek(st) { + match peek(st) { ':' => { next(st); next(st); } c => { if c == '(' { @@ -86,7 +86,7 @@ fn parse_ty_rust_fn(st: @pstate, conv: conv_did) -> ty::t { } fn parse_proto(c: char) -> ast::proto { - alt c { + match c { '~' => ast::proto_uniq, '@' => ast::proto_box, '&' => ast::proto_block, @@ -105,7 +105,7 @@ fn parse_vstore(st: @pstate) -> ty::vstore { return ty::vstore_fixed(n); } - alt check next(st) { + match check next(st) { '~' => ty::vstore_uniq, '@' => ty::vstore_box, '&' => ty::vstore_slice(parse_region(st)) @@ -128,7 +128,7 @@ fn parse_substs(st: @pstate, conv: conv_did) -> ty::substs { } fn parse_bound_region(st: @pstate) -> ty::bound_region { - alt check next(st) { + match check next(st) { 's' => ty::br_self, 'a' => ty::br_anon, '[' => ty::br_named(@parse_str(st, ']')), @@ -141,7 +141,7 @@ fn parse_bound_region(st: @pstate) -> ty::bound_region { } fn parse_region(st: @pstate) -> ty::region { - alt check next(st) { + match check next(st) { 'b' => { ty::re_bound(parse_bound_region(st)) } @@ -165,7 +165,7 @@ fn parse_region(st: @pstate) -> ty::region { } fn parse_opt<T>(st: @pstate, f: fn() -> T) -> option<T> { - alt check next(st) { + match check next(st) { 'n' => none, 's' => some(f()) } @@ -181,7 +181,7 @@ fn parse_str(st: @pstate, term: char) -> ~str { } fn parse_ty(st: @pstate, conv: conv_did) -> ty::t { - alt check next(st) { + match check next(st) { 'n' => return ty::mk_nil(st.tcx), 'z' => return ty::mk_bot(st.tcx), 'b' => return ty::mk_bool(st.tcx), @@ -189,7 +189,7 @@ fn parse_ty(st: @pstate, conv: conv_did) -> ty::t { 'u' => return ty::mk_uint(st.tcx), 'l' => return ty::mk_float(st.tcx), 'M' => { - alt check next(st) { + match check next(st) { 'b' => return ty::mk_mach_uint(st.tcx, ast::ty_u8), 'w' => return ty::mk_mach_uint(st.tcx, ast::ty_u16), 'l' => return ty::mk_mach_uint(st.tcx, ast::ty_u32), @@ -267,7 +267,7 @@ fn parse_ty(st: @pstate, conv: conv_did) -> ty::t { } 'Y' => return ty::mk_type(st.tcx), 'C' => { - let ck = alt check next(st) { + let ck = match check next(st) { '&' => ty::ck_block, '@' => ty::ck_box, '~' => ty::ck_uniq @@ -279,7 +279,7 @@ fn parse_ty(st: @pstate, conv: conv_did) -> ty::t { assert (next(st) == ':'); let len = parse_hex(st); assert (next(st) == '#'); - alt st.tcx.rcache.find({cnum: st.crate, pos: pos, len: len}) { + match st.tcx.rcache.find({cnum: st.crate, pos: pos, len: len}) { some(tt) => return tt, none => { let ps = @{pos: pos with *st}; @@ -311,7 +311,7 @@ fn parse_ty(st: @pstate, conv: conv_did) -> ty::t { fn parse_mt(st: @pstate, conv: conv_did) -> ty::mt { let mut m; - alt peek(st) { + match peek(st) { 'm' => { next(st); m = ast::m_mutbl; } '?' => { next(st); m = ast::m_const; } _ => { m = ast::m_imm; } @@ -351,7 +351,7 @@ fn parse_hex(st: @pstate) -> uint { } fn parse_purity(c: char) -> purity { - alt check c { + match check c { 'u' => unsafe_fn, 'p' => pure_fn, 'i' => impure_fn, @@ -365,7 +365,7 @@ fn parse_ty_fn(st: @pstate, conv: conv_did) -> ty::fn_ty { assert (next(st) == '['); let mut inputs: ~[ty::arg] = ~[]; while peek(st) != ']' { - let mode = alt check peek(st) { + let mode = match check peek(st) { '&' => ast::by_mutbl_ref, '-' => ast::by_move, '+' => ast::by_copy, @@ -394,12 +394,12 @@ fn parse_def_id(buf: &[u8]) -> ast::def_id { let crate_part = vec::slice(buf, 0u, colon_idx); let def_part = vec::slice(buf, colon_idx + 1u, len); - let crate_num = alt uint::parse_buf(crate_part, 10u) { + let crate_num = match uint::parse_buf(crate_part, 10u) { some(cn) => cn as int, none => fail (fmt!{"internal error: parse_def_id: crate number \ expected, but found %?", crate_part}) }; - let def_num = alt uint::parse_buf(def_part, 10u) { + let def_num = match uint::parse_buf(def_part, 10u) { some(dn) => dn as int, none => fail (fmt!{"internal error: parse_def_id: id expected, but \ found %?", def_part}) @@ -417,7 +417,7 @@ fn parse_bounds_data(data: @~[u8], start: uint, fn parse_bounds(st: @pstate, conv: conv_did) -> @~[ty::param_bound] { let mut bounds = ~[]; loop { - vec::push(bounds, alt check next(st) { + vec::push(bounds, match check next(st) { 'S' => ty::bound_send, 'C' => ty::bound_copy, 'K' => ty::bound_const, diff --git a/src/rustc/metadata/tyencode.rs b/src/rustc/metadata/tyencode.rs index a9685dabba7..458dc149802 100644 --- a/src/rustc/metadata/tyencode.rs +++ b/src/rustc/metadata/tyencode.rs @@ -34,16 +34,16 @@ type ty_abbrev = {pos: uint, len: uint, s: @~str}; enum abbrev_ctxt { ac_no_abbrevs, ac_use_abbrevs(hashmap<ty::t, ty_abbrev>), } fn cx_uses_abbrevs(cx: @ctxt) -> bool { - alt cx.abbrevs { + match cx.abbrevs { ac_no_abbrevs => return false, ac_use_abbrevs(_) => return true } } fn enc_ty(w: io::writer, cx: @ctxt, t: ty::t) { - alt cx.abbrevs { + match cx.abbrevs { ac_no_abbrevs => { - let result_str = alt cx.tcx.short_names_cache.find(t) { + let result_str = match cx.tcx.short_names_cache.find(t) { some(s) => *s, none => { let buf = io::mem_buffer(); @@ -55,11 +55,11 @@ fn enc_ty(w: io::writer, cx: @ctxt, t: ty::t) { w.write_str(result_str); } ac_use_abbrevs(abbrevs) => { - alt abbrevs.find(t) { + match abbrevs.find(t) { some(a) => { w.write_str(*a.s); return; } none => { let pos = w.tell(); - alt ty::type_def_id(t) { + match ty::type_def_id(t) { some(def_id) => { // Do not emit node ids that map to unexported names. Those // are not helpful. @@ -96,7 +96,7 @@ fn enc_ty(w: io::writer, cx: @ctxt, t: ty::t) { } } fn enc_mt(w: io::writer, cx: @ctxt, mt: ty::mt) { - alt mt.mutbl { + match mt.mutbl { m_imm => (), m_mutbl => w.write_char('m'), m_const => w.write_char('?') @@ -105,7 +105,7 @@ fn enc_mt(w: io::writer, cx: @ctxt, mt: ty::mt) { } fn enc_opt<T>(w: io::writer, t: option<T>, enc_f: fn(T)) { - alt t { + match t { none => w.write_char('n'), some(v) => { w.write_char('s'); @@ -123,7 +123,7 @@ fn enc_substs(w: io::writer, cx: @ctxt, substs: ty::substs) { } fn enc_region(w: io::writer, cx: @ctxt, r: ty::region) { - alt r { + match r { ty::re_bound(br) => { w.write_char('b'); enc_bound_region(w, br); @@ -152,7 +152,7 @@ fn enc_region(w: io::writer, cx: @ctxt, r: ty::region) { } fn enc_bound_region(w: io::writer, br: ty::bound_region) { - alt br { + match br { ty::br_self => w.write_char('s'), ty::br_anon => w.write_char('a'), ty::br_named(s) => { @@ -171,7 +171,7 @@ fn enc_bound_region(w: io::writer, br: ty::bound_region) { fn enc_vstore(w: io::writer, cx: @ctxt, v: ty::vstore) { w.write_char('/'); - alt v { + match v { ty::vstore_fixed(u) => { w.write_uint(u); w.write_char('|'); @@ -190,12 +190,12 @@ fn enc_vstore(w: io::writer, cx: @ctxt, v: ty::vstore) { } fn enc_sty(w: io::writer, cx: @ctxt, st: ty::sty) { - alt st { + match st { ty::ty_nil => w.write_char('n'), ty::ty_bot => w.write_char('z'), ty::ty_bool => w.write_char('b'), ty::ty_int(t) => { - alt t { + match t { ty_i => w.write_char('i'), ty_char => w.write_char('c'), ty_i8 => w.write_str(&"MB"), @@ -205,7 +205,7 @@ fn enc_sty(w: io::writer, cx: @ctxt, st: ty::sty) { } } ty::ty_uint(t) => { - alt t { + match t { ty_u => w.write_char('u'), ty_u8 => w.write_str(&"Mb"), ty_u16 => w.write_str(&"Mw"), @@ -214,7 +214,7 @@ fn enc_sty(w: io::writer, cx: @ctxt, st: ty::sty) { } } ty::ty_float(t) => { - alt t { + match t { ty_f => w.write_char('l'), ty_f32 => w.write_str(&"Mf"), ty_f64 => w.write_str(&"MF"), @@ -307,7 +307,7 @@ fn enc_sty(w: io::writer, cx: @ctxt, st: ty::sty) { } } fn enc_proto(w: io::writer, proto: proto) { - alt proto { + match proto { proto_uniq => w.write_str(&"f~"), proto_box => w.write_str(&"f@"), proto_block => w.write_str(~"f&"), @@ -316,7 +316,7 @@ fn enc_proto(w: io::writer, proto: proto) { } fn enc_mode(w: io::writer, cx: @ctxt, m: mode) { - alt ty::resolved_mode(cx.tcx, m) { + match ty::resolved_mode(cx.tcx, m) { by_mutbl_ref => w.write_char('&'), by_move => w.write_char('-'), by_copy => w.write_char('+'), @@ -326,7 +326,7 @@ fn enc_mode(w: io::writer, cx: @ctxt, m: mode) { } fn enc_purity(w: io::writer, p: purity) { - alt p { + match p { pure_fn => w.write_char('p'), impure_fn => w.write_char('i'), unsafe_fn => w.write_char('u'), @@ -343,7 +343,7 @@ fn enc_ty_fn(w: io::writer, cx: @ctxt, ft: ty::fn_ty) { enc_ty(w, cx, arg.ty); } w.write_char(']'); - alt ft.ret_style { + match ft.ret_style { noreturn => w.write_char('!'), _ => enc_ty(w, cx, ft.output) } @@ -351,7 +351,7 @@ fn enc_ty_fn(w: io::writer, cx: @ctxt, ft: ty::fn_ty) { fn enc_bounds(w: io::writer, cx: @ctxt, bs: @~[ty::param_bound]) { for vec::each(*bs) |bound| { - alt bound { + match bound { ty::bound_send => w.write_char('S'), ty::bound_copy => w.write_char('C'), ty::bound_const => w.write_char('K'), |
