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 | |
| parent | d3a9bb1bd4a1d510bbaca2ab1121e4c85a239247 (diff) | |
| download | rust-ecaf9e39c9435fa2de4fe393c4b263be36eb2d99.tar.gz rust-ecaf9e39c9435fa2de4fe393c4b263be36eb2d99.zip | |
Convert alt to match. Stop parsing alt
Diffstat (limited to 'src/rustc')
80 files changed, 1511 insertions, 1496 deletions
diff --git a/src/rustc/back/link.rs b/src/rustc/back/link.rs index c4dc6efe7b2..e7fe5fa3e3d 100644 --- a/src/rustc/back/link.rs +++ b/src/rustc/back/link.rs @@ -61,7 +61,7 @@ mod write { // and the extension to use. fn mk_intermediate_name(output_path: ~str, extension: ~str) -> ~str unsafe { - let stem = alt str::find_char(output_path, '.') { + let stem = match str::find_char(output_path, '.') { some(dot_pos) => str::slice(output_path, 0u, dot_pos), none => output_path }; @@ -82,7 +82,7 @@ mod write { // specified. if opts.save_temps { - alt opts.output_type { + match opts.output_type { output_type_bitcode => { if opts.optimize != 0u { let filename = mk_intermediate_name(output, ~"no-opt.bc"); @@ -146,7 +146,7 @@ mod write { let LLVMOptDefault = 2 as c_int; // -O2, -Os let LLVMOptAggressive = 3 as c_int; // -O3 - let mut CodeGenOptLevel = alt check opts.optimize { + let mut CodeGenOptLevel = match check opts.optimize { 0u => LLVMOptNone, 1u => LLVMOptLess, 2u => LLVMOptDefault, @@ -323,12 +323,12 @@ fn build_link_meta(sess: session, c: ast::crate, output: ~str, attr::require_unique_names(sess.diagnostic(), linkage_metas); for linkage_metas.each |meta| { if *attr::get_meta_item_name(meta) == ~"name" { - alt attr::get_meta_item_value_str(meta) { + match attr::get_meta_item_value_str(meta) { some(v) => { name = some(v); } none => vec::push(cmh_items, meta) } } else if *attr::get_meta_item_name(meta) == ~"vers" { - alt attr::get_meta_item_value_str(meta) { + match attr::get_meta_item_value_str(meta) { some(v) => { vers = some(v); } none => vec::push(cmh_items, meta) } @@ -355,7 +355,7 @@ fn build_link_meta(sess: session, c: ast::crate, output: ~str, symbol_hasher.reset(); for cmh_items.each |m_| { let m = m_; - alt m.node { + match m.node { ast::meta_name_value(key, value) => { symbol_hasher.write_str(len_and_str(*key)); symbol_hasher.write_str(len_and_str_lit(value)); @@ -385,7 +385,7 @@ fn build_link_meta(sess: session, c: ast::crate, output: ~str, fn crate_meta_name(sess: session, _crate: ast::crate, output: ~str, metas: provided_metas) -> @~str { - return alt metas.name { + return match metas.name { some(v) => v, none => { let name = @@ -407,7 +407,7 @@ fn build_link_meta(sess: session, c: ast::crate, output: ~str, fn crate_meta_vers(sess: session, _crate: ast::crate, metas: provided_metas) -> @~str { - return alt metas.vers { + return match metas.vers { some(v) => v, none => { let vers = ~"0.0"; @@ -451,7 +451,7 @@ fn symbol_hash(tcx: ty::ctxt, symbol_hasher: &hash::State, t: ty::t, } fn get_symbol_hash(ccx: @crate_ctxt, t: ty::t) -> ~str { - alt ccx.type_hashcodes.find(t) { + match ccx.type_hashcodes.find(t) { some(h) => return h, none => { let hash = symbol_hash(ccx.tcx, ccx.symbol_hasher, t, ccx.link_meta); @@ -467,7 +467,7 @@ fn get_symbol_hash(ccx: @crate_ctxt, t: ty::t) -> ~str { fn sanitize(s: ~str) -> ~str { let mut result = ~""; do str::chars_iter(s) |c| { - alt c { + match c { '@' => result += ~"_sbox_", '~' => result += ~"_ubox_", '*' => result += ~"_ptr_", @@ -503,7 +503,7 @@ fn mangle(ss: path) -> ~str { let mut n = ~"_ZN"; // Begin name-sequence. for ss.each |s| { - alt s { path_name(s) | path_mod(s) => { + match s { path_name(s) | path_mod(s) => { let sani = sanitize(*s); n += fmt!{"%u%s", str::len(sani), sani}; } } @@ -566,7 +566,7 @@ fn link_binary(sess: session, vec::pop(parts); return str::connect(parts, ~"."); } - return alt config.os { + return match config.os { session::os_macos => rmext(rmlib(filename)), session::os_linux => rmext(rmlib(filename)), session::os_freebsd => rmext(rmlib(filename)), diff --git a/src/rustc/back/rpath.rs b/src/rustc/back/rpath.rs index f74ffe8f067..e06b0a2fe72 100644 --- a/src/rustc/back/rpath.rs +++ b/src/rustc/back/rpath.rs @@ -7,7 +7,7 @@ import metadata::filesearch; export get_rpath_flags; pure fn not_win32(os: session::os) -> bool { - alt os { + match os { session::os_win32 => false, _ => true } @@ -108,7 +108,7 @@ fn get_rpath_relative_to_output(os: session::os, assert not_win32(os); // Mac doesn't appear to support $ORIGIN - let prefix = alt os { + let prefix = match os { session::os_linux => ~"$ORIGIN" + path::path_sep(), session::os_freebsd => ~"$ORIGIN" + path::path_sep(), session::os_macos => ~"@executable_path" + path::path_sep(), diff --git a/src/rustc/back/x86.rs b/src/rustc/back/x86.rs index 045a90de495..78270f31e37 100644 --- a/src/rustc/back/x86.rs +++ b/src/rustc/back/x86.rs @@ -8,7 +8,7 @@ fn get_target_strs(target_os: session::os) -> target_strs::t { meta_sect_name: meta_section_name(sess_os_to_meta_os(target_os)), - data_layout: alt target_os { + data_layout: match target_os { session::os_macos => { ~"e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16" + ~"-i32:32:32-i64:32:64" + @@ -29,7 +29,7 @@ fn get_target_strs(target_os: session::os) -> target_strs::t { } }, - target_triple: alt target_os { + target_triple: match target_os { session::os_macos => ~"i686-apple-darwin", session::os_win32 => ~"i686-pc-mingw32", session::os_linux => ~"i686-unknown-linux-gnu", diff --git a/src/rustc/back/x86_64.rs b/src/rustc/back/x86_64.rs index 70a35eb3289..18c2232c0fc 100644 --- a/src/rustc/back/x86_64.rs +++ b/src/rustc/back/x86_64.rs @@ -8,7 +8,7 @@ fn get_target_strs(target_os: session::os) -> target_strs::t { meta_sect_name: meta_section_name(sess_os_to_meta_os(target_os)), - data_layout: alt target_os { + data_layout: match target_os { session::os_macos => { ~"e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-"+ ~"f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-"+ @@ -35,7 +35,7 @@ fn get_target_strs(target_os: session::os) -> target_strs::t { } }, - target_triple: alt target_os { + target_triple: match target_os { session::os_macos => ~"x86_64-apple-darwin", session::os_win32 => ~"x86_64-pc-mingw32", session::os_linux => ~"x86_64-unknown-linux-gnu", diff --git a/src/rustc/driver/driver.rs b/src/rustc/driver/driver.rs index 5a07c8f411c..2f6bd86592f 100644 --- a/src/rustc/driver/driver.rs +++ b/src/rustc/driver/driver.rs @@ -26,7 +26,7 @@ enum pp_mode {ppm_normal, ppm_expanded, ppm_typed, ppm_identified, fn anon_src() -> ~str { ~"<anon>" } fn source_name(input: input) -> ~str { - alt input { + match input { file_input(ifile) => ifile, str_input(_) => anon_src() } @@ -34,7 +34,7 @@ fn source_name(input: input) -> ~str { fn default_configuration(sess: session, argv0: ~str, input: input) -> ast::crate_cfg { - let libc = alt sess.targ_cfg.os { + let libc = match sess.targ_cfg.os { session::os_win32 => ~"msvcrt.dll", session::os_macos => ~"libc.dylib", session::os_linux => ~"libc.so.6", @@ -44,7 +44,7 @@ fn default_configuration(sess: session, argv0: ~str, input: input) -> let mk = attr::mk_name_value_item_str; - let (arch,wordsz) = alt sess.targ_cfg.arch { + let (arch,wordsz) = match sess.targ_cfg.arch { session::arch_x86 => (~"x86",~"32"), session::arch_x86_64 => (~"x86_64",~"64"), session::arch_arm => (~"arm",~"32") @@ -99,7 +99,7 @@ enum input { fn parse_input(sess: session, cfg: ast::crate_cfg, input: input) -> @ast::crate { - alt input { + match input { file_input(file) => { parse::parse_crate_from_file(file, cfg, sess.parse_sess) } @@ -270,13 +270,13 @@ fn compile_input(sess: session, cfg: ast::crate_cfg, input: input, fn pretty_print_input(sess: session, cfg: ast::crate_cfg, input: input, ppm: pp_mode) { fn ann_paren_for_expr(node: pprust::ann_node) { - alt node { + match node { pprust::node_expr(s, expr) => pprust::popen(s), _ => () } } fn ann_typed_post(tcx: ty::ctxt, node: pprust::ann_node) { - alt node { + match node { pprust::node_expr(s, expr) => { pp::space(s.s); pp::word(s.s, ~"as"); @@ -288,7 +288,7 @@ fn pretty_print_input(sess: session, cfg: ast::crate_cfg, input: input, } } fn ann_identified_post(node: pprust::ann_node) { - alt node { + match node { pprust::node_item(s, item) => { pp::space(s.s); pprust::synth_comment(s, int::to_str(item.id, 10u)); @@ -314,14 +314,14 @@ fn pretty_print_input(sess: session, cfg: ast::crate_cfg, input: input, // to collect comments and literals, and we need to support reading // from stdin, we're going to just suck the source into a string // so both the parser and pretty-printer can use it. - let upto = alt ppm { + let upto = match ppm { ppm_expanded | ppm_expanded_identified => cu_expand, ppm_typed => cu_typeck, _ => cu_parse }; let {crate, tcx} = compile_upto(sess, cfg, input, upto, none); - let ann = alt ppm { + let ann = match ppm { ppm_typed => { {pre: ann_paren_for_expr, post: |a| ann_typed_post(option::get(tcx), a) } @@ -371,21 +371,21 @@ fn get_arch(triple: ~str) -> option<session::arch> { fn build_target_config(sopts: @session::options, demitter: diagnostic::emitter) -> @session::config { - let os = alt get_os(sopts.target_triple) { + let os = match get_os(sopts.target_triple) { some(os) => os, none => early_error(demitter, ~"unknown operating system") }; - let arch = alt get_arch(sopts.target_triple) { + let arch = match get_arch(sopts.target_triple) { some(arch) => arch, none => early_error(demitter, ~"unknown architecture: " + sopts.target_triple) }; - let (int_type, uint_type, float_type) = alt arch { + let (int_type, uint_type, float_type) = match arch { session::arch_x86 => (ast::ty_i32, ast::ty_u32, ast::ty_f64), session::arch_x86_64 => (ast::ty_i64, ast::ty_u64, ast::ty_f64), session::arch_arm => (ast::ty_i32, ast::ty_u32, ast::ty_f64) }; - let target_strs = alt arch { + let target_strs = match arch { session::arch_x86 => x86::get_target_strs(os), session::arch_x86_64 => x86_64::get_target_strs(os), session::arch_arm => x86::get_target_strs(os) @@ -438,7 +438,7 @@ fn build_session_options(matches: getopts::matches, getopts::opt_strs(matches, level_name)); for flags.each |lint_name| { let lint_name = str::replace(lint_name, ~"-", ~"_"); - alt lint_dict.find(lint_name) { + match lint_dict.find(lint_name) { none => { early_error(demitter, fmt!{"unknown %s flag: %s", level_name, lint_name}); @@ -486,7 +486,7 @@ fn build_session_options(matches: getopts::matches, let sysroot_opt = getopts::opt_maybe_str(matches, ~"sysroot"); let target_opt = getopts::opt_maybe_str(matches, ~"target"); let save_temps = getopts::opt_present(matches, ~"save-temps"); - alt output_type { + match output_type { // unless we're emitting huamn-readable assembly, omit comments. link::output_type_llvm_assembly | link::output_type_assembly => (), _ => debugging_opts |= session::no_asm_comments @@ -498,7 +498,7 @@ fn build_session_options(matches: getopts::matches, } 2u } else if opt_present(matches, ~"opt-level") { - alt getopts::opt_str(matches, ~"opt-level") { + match getopts::opt_str(matches, ~"opt-level") { ~"0" => 0u, ~"1" => 1u, ~"2" => 2u, @@ -510,7 +510,7 @@ fn build_session_options(matches: getopts::matches, } } else { 0u }; let target = - alt target_opt { + match target_opt { none => host_triple(), some(s) => s }; @@ -577,7 +577,7 @@ fn build_session_(sopts: @session::options, } fn parse_pretty(sess: session, &&name: ~str) -> pp_mode { - alt name { + match name { ~"normal" => ppm_normal, ~"expanded" => ppm_expanded, ~"typed" => ppm_typed, @@ -628,7 +628,7 @@ fn build_output_filenames(input: input, let obj_suffix = - alt sopts.output_type { + match sopts.output_type { link::output_type_none => ~"none", link::output_type_bitcode => ~"bc", link::output_type_assembly => ~"s", @@ -637,20 +637,20 @@ fn build_output_filenames(input: input, link::output_type_object | link::output_type_exe => ~"o" }; - alt ofile { + match ofile { none => { // "-" as input file will cause the parser to read from stdin so we // have to make up a name // We want to toss everything after the final '.' - let dirname = alt odir { + let dirname = match odir { some(d) => d, - none => alt input { + none => match input { str_input(_) => os::getcwd(), file_input(ifile) => path::dirname(ifile) } }; - let base_filename = alt input { + let base_filename = match input { file_input(ifile) => { let (path, _) = path::splitext(ifile); path::basename(path) @@ -714,7 +714,7 @@ mod test { #[test] fn test_switch_implies_cfg_test() { let matches = - alt getopts::getopts(~[~"--test"], opts()) { + match getopts::getopts(~[~"--test"], opts()) { ok(m) => m, err(f) => fail ~"test_switch_implies_cfg_test: " + getopts::fail_str(f) @@ -730,7 +730,7 @@ mod test { #[test] fn test_switch_implies_cfg_test_unless_cfg_test() { let matches = - alt getopts::getopts(~[~"--test", ~"--cfg=test"], opts()) { + match getopts::getopts(~[~"--test", ~"--cfg=test"], opts()) { ok(m) => m, err(f) => { fail ~"test_switch_implies_cfg_test_unless_cfg_test: " + diff --git a/src/rustc/driver/rustc.rs b/src/rustc/driver/rustc.rs index 483e1ca5808..dbbe48f84b2 100644 --- a/src/rustc/driver/rustc.rs +++ b/src/rustc/driver/rustc.rs @@ -95,7 +95,7 @@ fn describe_warnings() { let k = str::replace(k, ~"_", ~"-"); io::println(fmt!{" %s %7.7s %s", padded(max_key, k), - alt v.default { + match v.default { lint::allow => ~"allow", lint::warn => ~"warn", lint::deny => ~"deny", @@ -124,7 +124,7 @@ fn run_compiler(args: ~[~str], demitter: diagnostic::emitter) { if vec::len(args) == 0u { usage(binary); return; } let matches = - alt getopts::getopts(args, opts()) { + match getopts::getopts(args, opts()) { ok(m) => m, err(f) => { early_error(demitter, getopts::fail_str(f)) @@ -152,7 +152,7 @@ fn run_compiler(args: ~[~str], demitter: diagnostic::emitter) { version(binary); return; } - let input = alt vec::len(matches.free) { + let input = match vec::len(matches.free) { 0u => early_error(demitter, ~"no input filename given"), 1u => { let ifile = matches.free[0]; @@ -175,7 +175,7 @@ fn run_compiler(args: ~[~str], demitter: diagnostic::emitter) { option::map(getopts::opt_default(matches, ~"pretty", ~"normal"), |a| parse_pretty(sess, a) ); - alt pretty { + match pretty { some::<pp_mode>(ppm) => { pretty_print_input(sess, cfg, input, ppm); return; @@ -184,7 +184,7 @@ fn run_compiler(args: ~[~str], demitter: diagnostic::emitter) { } let ls = opt_present(matches, ~"ls"); if ls { - alt input { + match input { file_input(ifile) => { list_metadata(sess, ifile, io::stdout()); } @@ -219,7 +219,7 @@ fn monitor(+f: fn~(diagnostic::emitter)) { let p = comm::port(); let ch = comm::chan(p); - alt do task::try { + match do task::try { // The 'diagnostics emitter'. Every error, warning, etc. should // go through this function. diff --git a/src/rustc/driver/session.rs b/src/rustc/driver/session.rs index 200dd1b00d7..df9370afaea 100644 --- a/src/rustc/driver/session.rs +++ b/src/rustc/driver/session.rs @@ -152,7 +152,7 @@ impl session for session { } fn span_lint_level(level: lint::level, sp: span, msg: ~str) { - alt level { + match level { lint::allow => { }, lint::warn => self.span_warn(sp, msg), lint::deny | lint::forbid => { @@ -219,14 +219,14 @@ fn expect<T: copy>(sess: session, opt: option<T>, msg: fn() -> ~str) -> T { fn building_library(req_crate_type: crate_type, crate: @ast::crate, testing: bool) -> bool { - alt req_crate_type { + match req_crate_type { bin_crate => false, lib_crate => true, unknown_crate => { if testing { false } else { - alt syntax::attr::first_attr_value_str_by_name( + match syntax::attr::first_attr_value_str_by_name( crate.node.attrs, ~"crate_type") { option::some(@~"lib") => true, @@ -240,7 +240,7 @@ fn building_library(req_crate_type: crate_type, crate: @ast::crate, fn sess_os_to_meta_os(os: os) -> metadata::loader::os { import metadata::loader; - alt os { + match os { os_win32 => loader::os_win32, os_linux => loader::os_linux, os_macos => loader::os_macos, diff --git a/src/rustc/front/config.rs b/src/rustc/front/config.rs index 92035856ddf..ee9000b80e0 100644 --- a/src/rustc/front/config.rs +++ b/src/rustc/front/config.rs @@ -82,9 +82,9 @@ fn fold_foreign_mod(cx: ctxt, nm: ast::foreign_mod, fn filter_stmt(cx: ctxt, &&stmt: @ast::stmt) -> option<@ast::stmt> { - alt stmt.node { + match stmt.node { ast::stmt_decl(decl, _) => { - alt decl.node { + match decl.node { ast::decl_item(item) => { if item_in_cfg(cx, item) { option::some(stmt) diff --git a/src/rustc/front/intrinsic_inject.rs b/src/rustc/front/intrinsic_inject.rs index cc80a524f31..85770b7b6dd 100644 --- a/src/rustc/front/intrinsic_inject.rs +++ b/src/rustc/front/intrinsic_inject.rs @@ -15,7 +15,7 @@ fn inject_intrinsic(sess: session, ~[], sess.parse_sess); let item = - alt item { + match item { some(i) => i, none => { sess.fatal(~"no item found in intrinsic module"); diff --git a/src/rustc/front/test.rs b/src/rustc/front/test.rs index 66e430f27cd..9c54f6fa981 100644 --- a/src/rustc/front/test.rs +++ b/src/rustc/front/test.rs @@ -70,7 +70,7 @@ fn fold_mod(_cx: test_ctxt, m: ast::_mod, fld: fold::ast_fold) -> ast::_mod { // FIXME (#2403): This is sloppy. Instead we should have some mechanism to // indicate to the translation pass which function we want to be main. fn nomain(&&item: @ast::item) -> option<@ast::item> { - alt item.node { + match item.node { ast::item_fn(_, _, _) => { if *item.ident == ~"main" { option::none @@ -102,7 +102,7 @@ fn fold_item(cx: test_ctxt, &&i: @ast::item, fld: fold::ast_fold) -> debug!{"current path: %s", ast_util::path_name_i(cx.path)}; if is_test_fn(i) { - alt i.node { + match i.node { ast::item_fn(decl, _, _) if decl.purity == ast::unsafe_fn => { cx.sess.span_fatal( i.span, @@ -129,7 +129,7 @@ fn is_test_fn(i: @ast::item) -> bool { vec::len(attr::find_attrs_by_name(i.attrs, ~"test")) > 0u; fn has_test_signature(i: @ast::item) -> bool { - alt i.node { + match i.node { ast::item_fn(decl, tps, _) => { let input_cnt = vec::len(decl.inputs); let no_output = decl.output.node == ast::ty_nil; @@ -246,7 +246,7 @@ fn mk_path(cx: test_ctxt, path: ~[ast::ident]) -> ~[ast::ident] { // the paths with std:: let is_std = { let items = attr::find_linkage_metas(cx.crate.node.attrs); - alt attr::last_meta_item_value_str_by_name(items, ~"name") { + match attr::last_meta_item_value_str_by_name(items, ~"name") { some(@~"std") => true, _ => false } diff --git a/src/rustc/lib/llvm.rs b/src/rustc/lib/llvm.rs index 1effed07f13..2250d3d3086 100644 --- a/src/rustc/lib/llvm.rs +++ b/src/rustc/lib/llvm.rs @@ -1015,7 +1015,7 @@ fn type_to_str(names: type_names, ty: TypeRef) -> ~str { fn type_to_str_inner(names: type_names, outer0: ~[TypeRef], ty: TypeRef) -> ~str { - alt type_has_name(names, ty) { + match type_has_name(names, ty) { option::some(n) => return n, _ => {} } @@ -1035,7 +1035,7 @@ fn type_to_str_inner(names: type_names, outer0: ~[TypeRef], ty: TypeRef) -> return s; } - alt kind { + match kind { Void => return ~"Void", Half => return ~"Half", Float => return ~"Float", @@ -1103,7 +1103,7 @@ fn type_to_str_inner(names: type_names, outer0: ~[TypeRef], ty: TypeRef) -> } fn float_width(llt: TypeRef) -> uint { - return alt llvm::LLVMGetTypeKind(llt) as int { + return match llvm::LLVMGetTypeKind(llt) as int { 1 => 32u, 2 => 64u, 3 => 80u, 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'), diff --git a/src/rustc/middle/astencode.rs b/src/rustc/middle/astencode.rs index 054c51bfe36..b1b54816998 100644 --- a/src/rustc/middle/astencode.rs +++ b/src/rustc/middle/astencode.rs @@ -111,7 +111,7 @@ fn decode_inlined_item(cdata: cstore::crate_metadata, path: ast_map::path, par_doc: ebml::doc) -> option<ast::inlined_item> { let dcx = @{cdata: cdata, tcx: tcx, maps: maps}; - alt par_doc.opt_child(c::tag_ast) { + match par_doc.opt_child(c::tag_ast) { none => none, some(ast_doc) => { debug!{"> Decoding inlined fn: %s::?", ast_map::path_to_str(path)}; @@ -129,7 +129,7 @@ fn decode_inlined_item(cdata: cstore::crate_metadata, decode_side_tables(xcx, ast_doc); debug!{"< Decoded inlined fn: %s::%s", ast_map::path_to_str(path), *ii.ident()}; - alt ii { + match ii { ast::ii_item(i) => { debug!{">>> DECODED ITEM >>>\n%s\n<<< DECODED ITEM <<<", syntax::print::pprust::item_to_str(i)}; @@ -245,7 +245,7 @@ fn encode_ast(ebml_w: ebml::writer, item: ast::inlined_item) { fn simplify_ast(ii: ast::inlined_item) -> ast::inlined_item { fn drop_nested_items(blk: ast::blk_, fld: fold::ast_fold) -> ast::blk_ { let stmts_sans_items = do vec::filter(blk.stmts) |stmt| { - alt stmt.node { + match stmt.node { ast::stmt_expr(_, _) | ast::stmt_semi(_, _) | ast::stmt_decl(@{node: ast::decl_local(_), span: _}, _) => true, ast::stmt_decl(@{node: ast::decl_item(_), span: _}, _) => false @@ -260,7 +260,7 @@ fn simplify_ast(ii: ast::inlined_item) -> ast::inlined_item { with *fold::default_ast_fold() }); - alt ii { + match ii { ast::ii_item(i) => { ast::ii_item(fld.fold_item(i).get()) //hack: we're not dropping items } @@ -300,7 +300,7 @@ fn renumber_ast(xcx: extended_decode_ctxt, ii: ast::inlined_item) with *fold::default_ast_fold() }); - alt ii { + match ii { ast::ii_item(i) => { ast::ii_item(fld.fold_item(i).get()) } @@ -352,7 +352,7 @@ fn decode_def(xcx: extended_decode_ctxt, doc: ebml::doc) -> ast::def { impl of tr for ast::def { fn tr(xcx: extended_decode_ctxt) -> ast::def { - alt self { + match self { ast::def_fn(did, p) => ast::def_fn(did.tr(xcx), p), ast::def_self(nid) => ast::def_self(xcx.tr_id(nid)), ast::def_mod(did) => ast::def_mod(did.tr(xcx)), @@ -422,7 +422,7 @@ impl helper of read_method_map_entry_helper for ebml::ebml_deserializer { impl of tr for method_origin { fn tr(xcx: extended_decode_ctxt) -> method_origin { - alt self { + match self { typeck::method_static(did) => { typeck::method_static(did.tr(xcx)) } @@ -455,7 +455,7 @@ fn encode_vtable_origin(ecx: @e::encode_ctxt, ebml_w: ebml::writer, vtable_origin: typeck::vtable_origin) { do ebml_w.emit_enum(~"vtable_origin") { - alt vtable_origin { + match vtable_origin { typeck::vtable_static(def_id, tys, vtable_res) => { do ebml_w.emit_enum_variant(~"vtable_static", 0u, 3u) { do ebml_w.emit_enum_variant_arg(0u) { @@ -508,7 +508,7 @@ impl helpers of vtable_deserialization_helpers for ebml::ebml_deserializer { -> typeck::vtable_origin { do self.read_enum(~"vtable_origin") { do self.read_enum_variant |i| { - alt check i { + match check i { 0u => { typeck::vtable_static( do self.read_enum_variant_arg(0u) { @@ -992,7 +992,7 @@ fn test_simplification() { return {eq_fn: eq_int, mut data: ~[]}; } }); - alt (item_out, item_exp) { + match (item_out, item_exp) { (ast::ii_item(item_out), ast::ii_item(item_exp)) => { assert pprust::item_to_str(item_out) == pprust::item_to_str(item_exp); } diff --git a/src/rustc/middle/block_use.rs b/src/rustc/middle/block_use.rs index 3f7ddd94eed..2896ad32d6a 100644 --- a/src/rustc/middle/block_use.rs +++ b/src/rustc/middle/block_use.rs @@ -13,7 +13,7 @@ fn check_crate(tcx: ty::ctxt, crate: @crate) { fn visit_expr(ex: @expr, cx: ctx, v: visit::vt<ctx>) { if !cx.allow_block { - alt ty::get(ty::expr_ty(cx.tcx, ex)).struct { + match ty::get(ty::expr_ty(cx.tcx, ex)).struct { ty::ty_fn({proto: p, _}) if is_blockish(p) => { cx.tcx.sess.span_err(ex.span, ~"expressions with stack closure type \ @@ -23,7 +23,7 @@ fn visit_expr(ex: @expr, cx: ctx, v: visit::vt<ctx>) { } } let outer = cx.allow_block; - alt ex.node { + match ex.node { expr_call(f, args, _) => { cx.allow_block = true; v.visit_expr(f, cx, v); diff --git a/src/rustc/middle/borrowck.rs b/src/rustc/middle/borrowck.rs index 4e9f770232f..3df0cb3b25e 100644 --- a/src/rustc/middle/borrowck.rs +++ b/src/rustc/middle/borrowck.rs @@ -91,7 +91,7 @@ In other cases, like an enum on the stack, the memory cannot be freed but its type can change: let mut x = some(5); - alt x { + match x { some(ref y) => { ... } none => { ... } } @@ -105,7 +105,7 @@ Finally, in some cases, both dangers can arise. For example, something like the following: let mut x = ~some(5); - alt x { + match x { ~some(ref y) => { ... } ~none => { ... } } @@ -343,7 +343,7 @@ enum categorization { cat_stack_upvar(cmt), // upvar in stack closure cat_deref(cmt, uint, ptr_kind), // deref of a ptr cat_comp(cmt, comp_kind), // adjust to locate an internal component - cat_discr(cmt, ast::node_id), // alt discriminant (see preserve()) + cat_discr(cmt, ast::node_id), // match discriminant (see preserve()) } // different kinds of pointers: @@ -456,7 +456,7 @@ impl methods of get_type_for_node for ty::ctxt { impl error_methods for borrowck_ctxt { fn report_if_err(bres: bckres<()>) { - alt bres { + match bres { ok(()) => (), err(e) => self.report(e) } @@ -478,7 +478,7 @@ impl error_methods for borrowck_ctxt { } fn add_to_mutbl_map(cmt: cmt) { - alt cmt.cat { + match cmt.cat { cat_local(id) | cat_arg(id) => { self.mutbl_map.insert(id, ()); } @@ -492,7 +492,7 @@ impl error_methods for borrowck_ctxt { impl to_str_methods for borrowck_ctxt { fn cat_to_repr(cat: categorization) -> ~str { - alt cat { + match cat { cat_special(sk_method) => ~"method", cat_special(sk_static_item) => ~"static_item", cat_special(sk_self) => ~"self", @@ -514,7 +514,7 @@ impl to_str_methods for borrowck_ctxt { } fn mut_to_str(mutbl: ast::mutability) -> ~str { - alt mutbl { + match mutbl { m_mutbl => ~"mutable", m_const => ~"const", m_imm => ~"immutable" @@ -522,7 +522,7 @@ impl to_str_methods for borrowck_ctxt { } fn ptr_sigil(ptr: ptr_kind) -> ~str { - alt ptr { + match ptr { uniq_ptr => ~"~", gc_ptr => ~"@", region_ptr(_) => ~"&", @@ -531,7 +531,7 @@ impl to_str_methods for borrowck_ctxt { } fn comp_to_repr(comp: comp_kind) -> ~str { - alt comp { + match comp { comp_field(fld, _) => *fld, comp_index(*) => ~"[]", comp_tuple => ~"()", @@ -540,7 +540,7 @@ impl to_str_methods for borrowck_ctxt { } fn lp_to_str(lp: @loan_path) -> ~str { - alt *lp { + match *lp { lp_local(node_id) => { fmt!{"local(%d)", node_id} } @@ -569,7 +569,7 @@ impl to_str_methods for borrowck_ctxt { fn cmt_to_str(cmt: cmt) -> ~str { let mut_str = self.mut_to_str(cmt.mutbl); - alt cmt.cat { + match cmt.cat { cat_special(sk_method) => ~"method", cat_special(sk_static_item) => ~"static item", cat_special(sk_self) => ~"self reference", @@ -589,7 +589,7 @@ impl to_str_methods for borrowck_ctxt { cat_comp(_, comp_tuple) => ~"tuple content", cat_comp(_, comp_variant(_)) => ~"enum content", cat_comp(_, comp_index(t, _)) => { - alt ty::get(t).struct { + match ty::get(t).struct { ty::ty_evec(*) => mut_str + ~" vec content", ty::ty_estr(*) => mut_str + ~" str content", _ => mut_str + ~" indexed content" @@ -602,7 +602,7 @@ impl to_str_methods for borrowck_ctxt { } fn bckerr_code_to_str(code: bckerr_code) -> ~str { - alt code { + match code { err_mutbl(req, act) => { fmt!{"creating %s alias to aliasable, %s memory", self.mut_to_str(req), self.mut_to_str(act)} @@ -644,7 +644,7 @@ impl to_str_methods for borrowck_ctxt { // mutability can be "overridden" if the component is embedded in a // mutable structure. fn inherent_mutability(ck: comp_kind) -> mutability { - alt ck { + match ck { comp_tuple | comp_variant(_) => m_imm, comp_field(_, m) | comp_index(_, m) => m } diff --git a/src/rustc/middle/borrowck/categorization.rs b/src/rustc/middle/borrowck/categorization.rs index f3d39aa91ef..e113c957c15 100644 --- a/src/rustc/middle/borrowck/categorization.rs +++ b/src/rustc/middle/borrowck/categorization.rs @@ -43,7 +43,7 @@ export opt_deref_kind; // derefable (we model an index as the combination of a deref and then a // pointer adjustment). fn opt_deref_kind(t: ty::t) -> option<deref_kind> { - alt ty::get(t).struct { + match ty::get(t).struct { ty::ty_uniq(*) | ty::ty_evec(_, ty::vstore_uniq) | ty::ty_estr(ty::vstore_uniq) => { @@ -83,7 +83,7 @@ fn opt_deref_kind(t: ty::t) -> option<deref_kind> { } fn deref_kind(tcx: ty::ctxt, t: ty::t) -> deref_kind { - alt opt_deref_kind(t) { + match opt_deref_kind(t) { some(k) => k, none => { tcx.sess.bug( @@ -97,7 +97,7 @@ impl public_methods for borrowck_ctxt { fn cat_borrow_of_expr(expr: @ast::expr) -> cmt { // a borrowed expression must be either an @, ~, or a @vec, ~vec let expr_ty = ty::expr_ty(self.tcx, expr); - alt ty::get(expr_ty).struct { + match ty::get(expr_ty).struct { ty::ty_evec(*) | ty::ty_estr(*) => { self.cat_index(expr, expr) } @@ -128,14 +128,14 @@ impl public_methods for borrowck_ctxt { let tcx = self.tcx; let expr_ty = tcx.ty(expr); - alt expr.node { + match expr.node { ast::expr_unary(ast::deref, e_base) => { if self.method_map.contains_key(expr.id) { return self.cat_rvalue(expr, expr_ty); } let base_cmt = self.cat_expr(e_base); - alt self.cat_deref(expr, base_cmt, 0u, true) { + match self.cat_deref(expr, base_cmt, 0u, true) { some(cmt) => return cmt, none => { tcx.sess.span_bug( @@ -190,7 +190,7 @@ impl public_methods for borrowck_ctxt { span: span, expr_ty: ty::t, def: ast::def) -> cmt { - alt def { + match def { ast::def_fn(*) | ast::def_mod(_) | ast::def_foreign_mod(_) | ast::def_const(_) | ast::def_use(_) | ast::def_variant(*) | @@ -208,7 +208,7 @@ impl public_methods for borrowck_ctxt { // m: mutability of the argument // lp: loan path, must be none for aliasable things - let {m,lp} = alt ty::resolved_mode(self.tcx, mode) { + let {m,lp} = match ty::resolved_mode(self.tcx, mode) { ast::by_mutbl_ref => { {m: m_mutbl, lp: none} } @@ -241,7 +241,7 @@ impl public_methods for borrowck_ctxt { ast::def_upvar(upvid, inner, fn_node_id) => { let ty = ty::node_id_to_type(self.tcx, fn_node_id); let proto = ty::ty_fn_proto(ty); - alt proto { + match proto { ast::proto_block => { let upcmt = self.cat_def(id, span, expr_ty, *inner); @{id:id, span:span, @@ -311,7 +311,7 @@ impl public_methods for borrowck_ctxt { /// or if the container is mutable. fn inherited_mutability(base_m: ast::mutability, comp_m: ast::mutability) -> ast::mutability { - alt comp_m { + match comp_m { m_imm => {base_m} // imm: as mutable as the container m_mutbl | m_const => {comp_m} } @@ -319,7 +319,7 @@ impl public_methods for borrowck_ctxt { fn cat_field<N:ast_node>(node: N, base_cmt: cmt, f_name: ast::ident) -> cmt { - let f_mutbl = alt field_mutbl(self.tcx, base_cmt.ty, f_name) { + let f_mutbl = match field_mutbl(self.tcx, base_cmt.ty, f_name) { some(f_mutbl) => f_mutbl, none => { self.tcx.sess.span_bug( @@ -339,7 +339,7 @@ impl public_methods for borrowck_ctxt { fn cat_deref<N:ast_node>(node: N, base_cmt: cmt, derefs: uint, expl: bool) -> option<cmt> { do ty::deref(self.tcx, base_cmt.ty, expl).map |mt| { - alt deref_kind(self.tcx, base_cmt.ty) { + match deref_kind(self.tcx, base_cmt.ty) { deref_ptr(ptr) => { let lp = do base_cmt.lp.chain |l| { // Given that the ptr itself is loanable, we can @@ -347,7 +347,7 @@ impl public_methods for borrowck_ctxt { // the only way to reach the data they point at. // Other ptr types admit aliases and are therefore // not loanable. - alt ptr { + match ptr { uniq_ptr => {some(@lp_deref(l, ptr))} gc_ptr | region_ptr(_) | unsafe_ptr => {none} } @@ -355,7 +355,7 @@ impl public_methods for borrowck_ctxt { // for unique ptrs, we inherit mutability from the // owning reference. - let m = alt ptr { + let m = match ptr { uniq_ptr => { self.inherited_mutability(base_cmt.mutbl, mt.mutbl) } @@ -383,7 +383,7 @@ impl public_methods for borrowck_ctxt { fn cat_index(expr: @ast::expr, base: @ast::expr) -> cmt { let base_cmt = self.cat_autoderef(base); - let mt = alt ty::index(self.tcx, base_cmt.ty) { + let mt = match ty::index(self.tcx, base_cmt.ty) { some(mt) => mt, none => { self.tcx.sess.span_bug( @@ -393,18 +393,18 @@ impl public_methods for borrowck_ctxt { } }; - return alt deref_kind(self.tcx, base_cmt.ty) { + return match deref_kind(self.tcx, base_cmt.ty) { deref_ptr(ptr) => { // (a) the contents are loanable if the base is loanable // and this is a *unique* vector - let deref_lp = alt ptr { + let deref_lp = match ptr { uniq_ptr => {base_cmt.lp.map(|lp| @lp_deref(lp, uniq_ptr))} _ => {none} }; // (b) for unique ptrs, we inherit mutability from the // owning reference. - let m = alt ptr { + let m = match ptr { uniq_ptr => { self.inherited_mutability(base_cmt.mutbl, mt.mutbl) } @@ -465,7 +465,7 @@ impl private_methods for borrowck_ctxt { let mut ctr = 0u; loop { ctr += 1u; - alt self.cat_deref(base, cmt, ctr, false) { + match self.cat_deref(base, cmt, ctr, false) { none => return cmt, some(cmt1) => cmt = cmt1 } @@ -477,7 +477,7 @@ fn field_mutbl(tcx: ty::ctxt, base_ty: ty::t, f_name: ast::ident) -> option<ast::mutability> { // Need to refactor so that records/class fields can be treated uniformly. - alt ty::get(base_ty).struct { + match ty::get(base_ty).struct { ty::ty_rec(fields) => { for fields.each |f| { if f.ident == f_name { @@ -488,7 +488,7 @@ fn field_mutbl(tcx: ty::ctxt, ty::ty_class(did, substs) => { for ty::lookup_class_fields(tcx, did).each |fld| { if fld.ident == f_name { - let m = alt fld.mutability { + let m = match fld.mutability { ast::class_mutable => ast::m_mutbl, ast::class_immutable => ast::m_imm }; diff --git a/src/rustc/middle/borrowck/check_loans.rs b/src/rustc/middle/borrowck/check_loans.rs index f84fca5c197..9b7d0e037c1 100644 --- a/src/rustc/middle/borrowck/check_loans.rs +++ b/src/rustc/middle/borrowck/check_loans.rs @@ -64,14 +64,14 @@ impl methods for assignment_type { fn checked_by_liveness() -> bool { // the liveness pass guarantees that immutable local variables // are only assigned once; but it doesn't consider &mut - alt self { + match self { at_straight_up => true, at_swap => true, at_mutbl_ref => false } } fn ing_form(desc: ~str) -> ~str { - alt self { + match self { at_straight_up => ~"assigning to " + desc, at_swap => ~"swapping to and from " + desc, at_mutbl_ref => ~"taking mut reference to " + desc @@ -83,7 +83,7 @@ impl methods for check_loan_ctxt { fn tcx() -> ty::ctxt { self.bccx.tcx } fn purity(scope_id: ast::node_id) -> option<purity_cause> { - let default_purity = alt self.declared_purity { + let default_purity = match self.declared_purity { // an unsafe declaration overrides all ast::unsafe_fn => return none, @@ -101,12 +101,12 @@ impl methods for check_loan_ctxt { let region_map = self.tcx().region_map; let pure_map = self.req_maps.pure_map; loop { - alt pure_map.find(scope_id) { + match pure_map.find(scope_id) { none => (), some(e) => return some(pc_cmt(e)) } - alt region_map.find(scope_id) { + match region_map.find(scope_id) { none => return default_purity, some(next_scope_id) => scope_id = next_scope_id } @@ -128,7 +128,7 @@ impl methods for check_loan_ctxt { } } - alt region_map.find(scope_id) { + match region_map.find(scope_id) { none => return, some(next_scope_id) => scope_id = next_scope_id, } @@ -173,9 +173,9 @@ impl methods for check_loan_ctxt { // (c) B is a pure fn; // (d) B is not a fn. - alt opt_expr { + match opt_expr { some(expr) => { - alt expr.node { + match expr.node { ast::expr_path(_) if pc == pc_pure_fn => { let def = self.tcx().def_map.get(expr.id); let did = ast_util::def_id_of_def(def); @@ -198,9 +198,9 @@ impl methods for check_loan_ctxt { } let callee_ty = ty::node_id_to_type(tcx, callee_id); - alt ty::get(callee_ty).struct { + match ty::get(callee_ty).struct { ty::ty_fn(fn_ty) => { - alt fn_ty.purity { + match fn_ty.purity { ast::pure_fn => return, // case (c) above ast::impure_fn | ast::unsafe_fn | ast::extern_fn => { self.report_purity_error( @@ -219,14 +219,14 @@ impl methods for check_loan_ctxt { fn is_stack_closure(id: ast::node_id) -> bool { let fn_ty = ty::node_id_to_type(self.tcx(), id); let proto = ty::ty_fn_proto(fn_ty); - alt proto { + match proto { ast::proto_block => true, ast::proto_bare | ast::proto_uniq | ast::proto_box => false } } fn is_allowed_pure_arg(expr: @ast::expr) -> bool { - return alt expr.node { + return match expr.node { ast::expr_path(_) => { let def = self.tcx().def_map.get(expr.id); let did = ast_util::def_id_of_def(def); @@ -241,7 +241,7 @@ impl methods for check_loan_ctxt { } fn check_for_conflicting_loans(scope_id: ast::node_id) { - let new_loanss = alt self.req_maps.req_loan_map.find(scope_id) { + let new_loanss = match self.req_maps.req_loan_map.find(scope_id) { none => return, some(loanss) => loanss }; @@ -251,7 +251,7 @@ impl methods for check_loan_ctxt { for (*new_loanss).each |new_loans| { for (*new_loans).each |new_loan| { if old_loan.lp != new_loan.lp { again; } - alt (old_loan.mutbl, new_loan.mutbl) { + match (old_loan.mutbl, new_loan.mutbl) { (m_const, _) | (_, m_const) | (m_mutbl, m_mutbl) | (m_imm, m_imm) => { /*ok*/ @@ -276,16 +276,16 @@ impl methods for check_loan_ctxt { } fn is_local_variable(cmt: cmt) -> bool { - alt cmt.cat { + match cmt.cat { cat_local(_) => true, _ => false } } fn is_self_field(cmt: cmt) -> bool { - alt cmt.cat { + match cmt.cat { cat_comp(cmt_base, comp_field(*)) => { - alt cmt_base.cat { + match cmt_base.cat { cat_special(sk_self) => true, _ => false } @@ -307,7 +307,7 @@ impl methods for check_loan_ctxt { // liveness guarantees that immutable local variables // are only assigned once } else { - alt cmt.mutbl { + match cmt.mutbl { m_mutbl => { /*ok*/ } m_const | m_imm => { self.bccx.span_err( @@ -321,7 +321,7 @@ impl methods for check_loan_ctxt { // if this is a pure function, only loan-able state can be // assigned, because it is uniquely tied to this function and // is not visible from the outside - alt self.purity(ex.id) { + match self.purity(ex.id) { none => (), some(pc) => { if cmt.lp.is_none() { @@ -352,7 +352,7 @@ impl methods for check_loan_ctxt { lp: @loan_path) { for self.walk_loans_of(ex.id, lp) |loan| { - alt loan.mutbl { + match loan.mutbl { m_mutbl | m_const => { /*ok*/ } m_imm => { self.bccx.span_err( @@ -375,7 +375,7 @@ impl methods for check_loan_ctxt { // let mut x = {f: some(3)}; // let y = &x; // x loaned out as immutable // x.f = none; // changes type of y.f, which appears to be imm - alt *lp { + match *lp { lp_comp(lp_base, ck) if inherent_mutability(ck) != m_mutbl => { self.check_for_loan_conflicting_with_assignment( at, ex, cmt, lp_base); @@ -385,7 +385,7 @@ impl methods for check_loan_ctxt { } fn report_purity_error(pc: purity_cause, sp: span, msg: ~str) { - alt pc { + match pc { pc_pure_fn => { self.tcx().sess.span_err( sp, @@ -414,7 +414,7 @@ impl methods for check_loan_ctxt { debug!{"check_move_out_from_cmt(cmt=%s)", self.bccx.cmt_to_repr(cmt)}; - alt cmt.cat { + match cmt.cat { // Rvalues, locals, and arguments can be moved: cat_rvalue | cat_local(_) | cat_arg(_) => {} @@ -437,7 +437,7 @@ impl methods for check_loan_ctxt { self.bccx.add_to_mutbl_map(cmt); // check for a conflicting loan: - let lp = alt cmt.lp { + let lp = match cmt.lp { none => return, some(lp) => lp }; @@ -459,7 +459,7 @@ impl methods for check_loan_ctxt { // safe to consider the use a last_use. fn check_last_use(expr: @ast::expr) { let cmt = self.bccx.cat_expr(expr); - let lp = alt cmt.lp { + let lp = match cmt.lp { none => return, some(lp) => lp }; @@ -476,7 +476,7 @@ impl methods for check_loan_ctxt { callee_id: ast::node_id, callee_span: span, args: ~[@ast::expr]) { - alt self.purity(expr.id) { + match self.purity(expr.id) { none => {} some(pc) => { self.check_pure_callee_or_arg( @@ -491,7 +491,7 @@ impl methods for check_loan_ctxt { ty::ty_fn_args( ty::node_id_to_type(self.tcx(), callee_id)); do vec::iter2(args, arg_tys) |arg, arg_ty| { - alt ty::resolved_mode(self.tcx(), arg_ty.mode) { + match ty::resolved_mode(self.tcx(), arg_ty.mode) { ast::by_move => { self.check_move_out(arg); } @@ -521,7 +521,7 @@ fn check_loans_in_fn(fk: visit::fn_kind, decl: ast::fn_decl, body: ast::blk, // of otherwise immutable fields and typestate wouldn't be // able to "see" into those functions anyway, so it // wouldn't be very helpful. - alt fk { + match fk { visit::fk_ctor(*) => { self.in_ctor = true; self.declared_purity = decl.purity; @@ -551,7 +551,7 @@ fn check_loans_in_fn(fk: visit::fn_kind, decl: ast::fn_decl, body: ast::blk, fn check_loans_in_local(local: @ast::local, &&self: check_loan_ctxt, vt: visit::vt<check_loan_ctxt>) { - alt local.node.init { + match local.node.init { some({op: ast::init_move, expr: expr}) => { self.check_move_out(expr); } @@ -565,7 +565,7 @@ fn check_loans_in_expr(expr: @ast::expr, vt: visit::vt<check_loan_ctxt>) { self.check_for_conflicting_loans(expr.id); - alt expr.node { + match expr.node { ast::expr_path(*) if self.bccx.last_use_map.contains_key(expr.id) => { self.check_last_use(expr); } @@ -601,7 +601,7 @@ fn check_loans_in_expr(expr: @ast::expr, } } ast::expr_addr_of(mutbl, base) => { - alt mutbl { + match mutbl { m_const => { /*all memory is const*/ } m_mutbl => { // If we are taking an &mut ptr, make sure the memory @@ -645,7 +645,7 @@ fn check_loans_in_block(blk: ast::blk, do save_and_restore(self.declared_purity) { self.check_for_conflicting_loans(blk.node.id); - alt blk.node.rules { + match blk.node.rules { ast::default_blk => { } ast::unchecked_blk => { diff --git a/src/rustc/middle/borrowck/gather_loans.rs b/src/rustc/middle/borrowck/gather_loans.rs index 88e329f63c0..86455652faa 100644 --- a/src/rustc/middle/borrowck/gather_loans.rs +++ b/src/rustc/middle/borrowck/gather_loans.rs @@ -70,7 +70,7 @@ fn req_loans_in_fn(fk: visit::fn_kind, let old_root_ub = self.root_ub; self.root_ub = body.node.id; - alt fk { + match fk { visit::fk_anon(*) | visit::fk_fn_block(*) => {} visit::fk_item_fn(*) | visit::fk_method(*) | visit::fk_ctor(*) | visit::fk_dtor(*) => { @@ -99,14 +99,14 @@ fn req_loans_in_expr(ex: @ast::expr, } // Special checks for various kinds of expressions: - alt ex.node { + match ex.node { ast::expr_addr_of(mutbl, base) => { let base_cmt = self.bccx.cat_expr(base); // make sure that the thing we are pointing out stays valid // for the lifetime `scope_r` of the resulting ptr: let scope_r = - alt check ty::get(tcx.ty(ex)).struct { + match check ty::get(tcx.ty(ex)).struct { ty::ty_rptr(r, _) => r }; self.guarantee_valid(base_cmt, mutbl, scope_r); @@ -117,7 +117,7 @@ fn req_loans_in_expr(ex: @ast::expr, let arg_tys = ty::ty_fn_args(ty::expr_ty(self.tcx(), f)); let scope_r = ty::re_scope(ex.id); do vec::iter2(args, arg_tys) |arg, arg_ty| { - alt ty::resolved_mode(self.tcx(), arg_ty.mode) { + match ty::resolved_mode(self.tcx(), arg_ty.mode) { ast::by_mutbl_ref => { let arg_cmt = self.bccx.cat_expr(arg); self.guarantee_valid(arg_cmt, m_mutbl, scope_r); @@ -151,7 +151,7 @@ fn req_loans_in_expr(ex: @ast::expr, // immutable (whereas something like {f:int} would be // fine). // - alt opt_deref_kind(arg_ty.ty) { + match opt_deref_kind(arg_ty.ty) { some(deref_ptr(region_ptr(_))) | some(deref_ptr(unsafe_ptr)) => { /* region pointers are (by induction) guaranteed */ @@ -265,7 +265,7 @@ impl methods for gather_loan_ctxt { region_to_str(self.tcx(), scope_r)}; let _i = indenter(); - alt cmt.lp { + match cmt.lp { // If this expression is a loanable path, we MUST take out a // loan. This is somewhat non-obvious. You might think, // for example, that if we have an immutable local variable @@ -277,11 +277,11 @@ impl methods for gather_loan_ctxt { // it within that scope, the loan will be detected and an // error will be reported. some(_) => { - alt self.bccx.loan(cmt, scope_r, req_mutbl) { + match self.bccx.loan(cmt, scope_r, req_mutbl) { err(e) => { self.bccx.report(e); } ok(loans) if loans.len() == 0 => {} ok(loans) => { - alt scope_r { + match scope_r { ty::re_scope(scope_id) => { self.add_loans(scope_id, loans); @@ -325,7 +325,7 @@ impl methods for gather_loan_ctxt { } }; - alt result { + match result { ok(pc_ok) => { // we were able guarantee the validity of the ptr, // perhaps by rooting or because it is immutably @@ -335,7 +335,7 @@ impl methods for gather_loan_ctxt { ok(pc_if_pure(e)) => { // we are only able to guarantee the validity if // the scope is pure - alt scope_r { + match scope_r { ty::re_scope(pure_id) => { // if the scope is some block/expr in the fn, // then just require that this scope be pure @@ -374,7 +374,7 @@ impl methods for gather_loan_ctxt { // mutable memory. fn check_mutbl(req_mutbl: ast::mutability, cmt: cmt) -> bckres<preserve_condition> { - alt (req_mutbl, cmt.mutbl) { + match (req_mutbl, cmt.mutbl) { (m_const, _) | (m_imm, m_imm) | (m_mutbl, m_mutbl) => { @@ -397,7 +397,7 @@ impl methods for gather_loan_ctxt { } fn add_loans(scope_id: ast::node_id, loans: @dvec<loan>) { - alt self.req_maps.req_loan_map.find(scope_id) { + match self.req_maps.req_loan_map.find(scope_id) { some(l) => { (*l).push(loans); } @@ -432,7 +432,7 @@ impl methods for gather_loan_ctxt { // To see what I mean about ids etc, consider: // // let x = @@3; - // alt x { + // match x { // @@y { ... } // } // @@ -450,7 +450,7 @@ impl methods for gather_loan_ctxt { let _i = indenter(); let tcx = self.tcx(); - alt pat.node { + match pat.node { ast::pat_wild => { // _ } @@ -460,7 +460,7 @@ impl methods for gather_loan_ctxt { } ast::pat_enum(_, some(subpats)) => { // variant(x, y, z) - let enum_did = alt self.bccx.tcx.def_map + let enum_did = match self.bccx.tcx.def_map .find(pat.id) { some(ast::def_variant(enum_did, _)) => enum_did, e => tcx.sess.span_bug(pat.span, @@ -523,7 +523,7 @@ impl methods for gather_loan_ctxt { ast::pat_box(subpat) | ast::pat_uniq(subpat) => { // @p1, ~p1 - alt self.bccx.cat_deref(subpat, cmt, 0u, true) { + match self.bccx.cat_deref(subpat, cmt, 0u, true) { some(subcmt) => { self.gather_pat(subcmt, subpat, arm_id, alt_id); } diff --git a/src/rustc/middle/borrowck/loan.rs b/src/rustc/middle/borrowck/loan.rs index 5479afd10b7..59e3cd183fc 100644 --- a/src/rustc/middle/borrowck/loan.rs +++ b/src/rustc/middle/borrowck/loan.rs @@ -12,7 +12,7 @@ impl public_methods for borrowck_ctxt { let lc = loan_ctxt_(@{bccx: self, scope_region: scope_region, loans: @dvec()}); - alt lc.loan(cmt, mutbl) { + match lc.loan(cmt, mutbl) { ok(()) => {ok(lc.loans)} err(e) => {err(e)} } @@ -70,7 +70,7 @@ impl loan_methods for loan_ctxt { ~"loan() called with non-lendable value"); } - alt cmt.cat { + match cmt.cat { cat_binding(_) | cat_rvalue | cat_special(_) => { // should never be loanable self.bccx.tcx.sess.span_bug( @@ -131,7 +131,7 @@ impl loan_methods for loan_ctxt { fn loan_stable_comp(cmt: cmt, cmt_base: cmt, req_mutbl: ast::mutability) -> bckres<()> { - let base_mutbl = alt req_mutbl { + let base_mutbl = match req_mutbl { m_imm => m_imm, m_const | m_mutbl => m_const }; diff --git a/src/rustc/middle/borrowck/preserve.rs b/src/rustc/middle/borrowck/preserve.rs index 568030c85b5..a586aca24f3 100644 --- a/src/rustc/middle/borrowck/preserve.rs +++ b/src/rustc/middle/borrowck/preserve.rs @@ -14,7 +14,7 @@ impl public_methods for preserve_condition { // combines two preservation conditions such that if either of // them requires purity, the result requires purity fn combine(pc: preserve_condition) -> preserve_condition { - alt self { + match self { pc_ok => {pc} pc_if_pure(e) => {self} } @@ -63,7 +63,7 @@ impl private_methods for &preserve_ctxt { self.root_managed_data}; let _i = indenter(); - alt cmt.cat { + match cmt.cat { cat_special(sk_self) | cat_special(sk_heap_upvar) => { self.compare_scope(cmt, ty::re_scope(self.item_ub)) } @@ -160,7 +160,7 @@ impl private_methods for &preserve_ctxt { if base.mutbl == m_imm { let non_rooting_ctxt = preserve_ctxt({root_managed_data: false with **self}); - alt (&non_rooting_ctxt).preserve(base) { + match (&non_rooting_ctxt).preserve(base) { ok(pc_ok) => { ok(pc_ok) } @@ -191,7 +191,7 @@ impl private_methods for &preserve_ctxt { // As an example, consider this scenario: // // let mut x = @some(3); - // alt *x { some(y) {...} none {...} } + // match *x { some(y) {...} none {...} } // // Technically, the value `x` need only be rooted // in the `some` arm. However, we evaluate `x` in trans @@ -201,7 +201,7 @@ impl private_methods for &preserve_ctxt { // As a second example, consider *this* scenario: // // let x = @mut @some(3); - // alt x { @@some(y) {...} @@none {...} } + // match x { @@some(y) {...} @@none {...} } // // Here again, `x` need only be rooted in the `some` arm. // In this case, the value which needs to be rooted is @@ -220,7 +220,7 @@ impl private_methods for &preserve_ctxt { // also yielded suboptimal results for patterns like: // // let x = @mut @...; - // alt x { @@some_variant(y) | @@some_other_variant(y) {...} } + // match x { @@some_variant(y) | @@some_other_variant(y) => // // The reason is that we would root the value once for // each pattern and not once per arm. This is also easily @@ -234,7 +234,7 @@ impl private_methods for &preserve_ctxt { // current scope must be the arm, which is always a child of alt: assert { - alt check self.scope_region { + match check self.scope_region { ty::re_scope(arm_id) => { self.tcx().region_map.get(arm_id) == alt_id } @@ -259,11 +259,11 @@ impl private_methods for &preserve_ctxt { code: bckerr_code) -> bckres<preserve_condition> { // Variant contents and unique pointers: must be immutably // rooted to a preserved address. - alt self.preserve(cmt_base) { + match self.preserve(cmt_base) { // the base is preserved, but if we are not mutable then // purity is required ok(pc_ok) => { - alt cmt_base.mutbl { + match cmt_base.mutbl { m_mutbl | m_const => { ok(pc_if_pure({cmt:cmt, code:code})) } @@ -322,7 +322,7 @@ impl private_methods for &preserve_ctxt { } let root_region = ty::re_scope(self.root_ub); - alt self.scope_region { + match self.scope_region { // we can only root values if the desired region is some concrete // scope within the fn body ty::re_scope(scope_id) => { diff --git a/src/rustc/middle/capture.rs b/src/rustc/middle/capture.rs index 1af377e1ba2..266c31b2805 100644 --- a/src/rustc/middle/capture.rs +++ b/src/rustc/middle/capture.rs @@ -101,14 +101,14 @@ fn compute_capture_vars(tcx: ty::ctxt, // now go through anything that is referenced but was not explicitly // named and add that - let implicit_mode = alt fn_proto { + let implicit_mode = match fn_proto { ast::proto_block => cap_ref, ast::proto_bare | ast::proto_box | ast::proto_uniq => cap_copy }; do vec::iter(*freevars) |fvar| { let fvar_def_id = ast_util::def_id_of_def(fvar.def).node; - alt cap_map.find(fvar_def_id) { + match cap_map.find(fvar_def_id) { option::some(_) => { /* was explicitly named, do nothing */ } option::none => { cap_map.insert(fvar_def_id, {def:fvar.def, diff --git a/src/rustc/middle/check_alt.rs b/src/rustc/middle/check_alt.rs index 28fbfacb78c..7ccccbbcc07 100644 --- a/src/rustc/middle/check_alt.rs +++ b/src/rustc/middle/check_alt.rs @@ -22,7 +22,7 @@ fn check_crate(tcx: ty::ctxt, crate: @crate) { fn check_expr(tcx: ty::ctxt, ex: @expr, &&s: (), v: visit::vt<()>) { visit::visit_expr(ex, s, v); - alt ex.node { + match ex.node { expr_alt(scrut, arms, mode) => { check_arms(tcx, arms); /* Check for exhaustiveness */ @@ -33,7 +33,7 @@ fn check_expr(tcx: ty::ctxt, ex: @expr, &&s: (), v: visit::vt<()>) { // Vacuously exhaustive return; } - alt ty::get(pat_ty).struct { + match ty::get(pat_ty).struct { ty_enum(did, _) => { if (*enum_variants(tcx, did)).is_empty() && arms.is_empty() { @@ -58,7 +58,7 @@ fn check_arms(tcx: ty::ctxt, arms: ~[arm]) { for arms.each |arm| { for arm.pats.each |pat| { let v = ~[pat]; - alt is_useful(tcx, seen, v) { + match is_useful(tcx, seen, v) { not_useful => { tcx.sess.span_err(pat.span, ~"unreachable pattern"); } @@ -70,7 +70,7 @@ fn check_arms(tcx: ty::ctxt, arms: ~[arm]) { } fn raw_pat(p: @pat) -> @pat { - alt p.node { + match p.node { pat_ident(_, _, some(s)) => { raw_pat(s) } _ => { p } } @@ -78,20 +78,20 @@ fn raw_pat(p: @pat) -> @pat { fn check_exhaustive(tcx: ty::ctxt, sp: span, pats: ~[@pat]) { assert(pats.is_not_empty()); - let ext = alt is_useful(tcx, vec::map(pats, |p| ~[p]), ~[wild()]) { + let ext = match is_useful(tcx, vec::map(pats, |p| ~[p]), ~[wild()]) { not_useful => return, // This is good, wildcard pattern isn't reachable useful_ => none, useful(ty, ctor) => { - alt ty::get(ty).struct { + match ty::get(ty).struct { ty::ty_bool => { - alt check ctor { + match check ctor { val(const_int(1i64)) => some(@~"true"), val(const_int(0i64)) => some(@~"false") } } ty::ty_enum(id, _) => { - let vid = alt check ctor { variant(id) => id }; - alt check vec::find(*ty::enum_variants(tcx, id), + let vid = match check ctor { variant(id) => id }; + match check vec::find(*ty::enum_variants(tcx, id), |v| v.id == vid) { some(v) => some(v.name) } @@ -100,7 +100,7 @@ fn check_exhaustive(tcx: ty::ctxt, sp: span, pats: ~[@pat]) { } } }; - let msg = ~"non-exhaustive patterns" + alt ext { + let msg = ~"non-exhaustive patterns" + match ext { some(s) => ~": " + *s + ~" not covered", none => ~"" }; @@ -134,19 +134,19 @@ enum ctor { fn is_useful(tcx: ty::ctxt, m: matrix, v: ~[@pat]) -> useful { if m.len() == 0u { return useful_; } if m[0].len() == 0u { return not_useful; } - let real_pat = alt vec::find(m, |r| r[0].id != 0) { + let real_pat = match vec::find(m, |r| r[0].id != 0) { some(r) => r[0], none => v[0] }; let left_ty = if real_pat.id == 0 { ty::mk_nil(tcx) } else { ty::node_id_to_type(tcx, real_pat.id) }; - alt pat_ctor_id(tcx, v[0]) { + match pat_ctor_id(tcx, v[0]) { none => { - alt missing_ctor(tcx, m, left_ty) { + match missing_ctor(tcx, m, left_ty) { none => { - alt ty::get(left_ty).struct { + match ty::get(left_ty).struct { ty::ty_bool => { - alt is_useful_specialized(tcx, m, v, val(const_int(1i64)), + match is_useful_specialized(tcx, m, v, val(const_int(1i64)), 0u, left_ty){ not_useful => { is_useful_specialized(tcx, m, v, val(const_int(0i64)), @@ -157,7 +157,7 @@ fn is_useful(tcx: ty::ctxt, m: matrix, v: ~[@pat]) -> useful { } ty::ty_enum(eid, _) => { for (*ty::enum_variants(tcx, eid)).each |va| { - alt is_useful_specialized(tcx, m, v, variant(va.id), + match is_useful_specialized(tcx, m, v, variant(va.id), va.args.len(), left_ty) { not_useful => (), u => return u @@ -172,7 +172,7 @@ fn is_useful(tcx: ty::ctxt, m: matrix, v: ~[@pat]) -> useful { } } some(ctor) => { - alt is_useful(tcx, vec::filter_map(m, |r| default(tcx, r) ), + match is_useful(tcx, vec::filter_map(m, |r| default(tcx, r) ), vec::tail(v)) { useful_ => useful(left_ty, ctor), u => u @@ -190,7 +190,9 @@ fn is_useful(tcx: ty::ctxt, m: matrix, v: ~[@pat]) -> useful { fn is_useful_specialized(tcx: ty::ctxt, m: matrix, v: ~[@pat], ctor: ctor, arity: uint, lty: ty::t) -> useful { let ms = vec::filter_map(m, |r| specialize(tcx, r, ctor, arity, lty) ); - alt is_useful(tcx, ms, option::get(specialize(tcx, v, ctor, arity, lty))){ + let could_be_useful = is_useful( + tcx, ms, option::get(specialize(tcx, v, ctor, arity, lty))); + match could_be_useful { useful_ => useful(lty, ctor), u => u } @@ -198,10 +200,10 @@ fn is_useful_specialized(tcx: ty::ctxt, m: matrix, v: ~[@pat], ctor: ctor, fn pat_ctor_id(tcx: ty::ctxt, p: @pat) -> option<ctor> { let pat = raw_pat(p); - alt pat.node { + match pat.node { pat_wild => { none } pat_ident(_, _, _) | pat_enum(_, _) => { - alt tcx.def_map.find(pat.id) { + match tcx.def_map.find(pat.id) { some(def_variant(_, id)) => some(variant(id)), _ => none } @@ -218,10 +220,10 @@ fn pat_ctor_id(tcx: ty::ctxt, p: @pat) -> option<ctor> { fn is_wild(tcx: ty::ctxt, p: @pat) -> bool { let pat = raw_pat(p); - alt pat.node { + match pat.node { pat_wild => { true } pat_ident(_, _, _) => { - alt tcx.def_map.find(pat.id) { + match tcx.def_map.find(pat.id) { some(def_variant(_, _)) => { false } _ => { true } } @@ -231,7 +233,7 @@ fn is_wild(tcx: ty::ctxt, p: @pat) -> bool { } fn missing_ctor(tcx: ty::ctxt, m: matrix, left_ty: ty::t) -> option<ctor> { - alt ty::get(left_ty).struct { + match ty::get(left_ty).struct { ty::ty_box(_) | ty::ty_uniq(_) | ty::ty_tup(_) | ty::ty_rec(_) => { for m.each |r| { if !is_wild(tcx, r[0]) { return none; } @@ -259,7 +261,7 @@ fn missing_ctor(tcx: ty::ctxt, m: matrix, left_ty: ty::t) -> option<ctor> { ty::ty_bool => { let mut true_found = false, false_found = false; for m.each |r| { - alt check pat_ctor_id(tcx, r[0]) { + match check pat_ctor_id(tcx, r[0]) { none => (), some(val(const_int(1i64))) => true_found = true, some(val(const_int(0i64))) => false_found = true @@ -274,13 +276,13 @@ fn missing_ctor(tcx: ty::ctxt, m: matrix, left_ty: ty::t) -> option<ctor> { } fn ctor_arity(tcx: ty::ctxt, ctor: ctor, ty: ty::t) -> uint { - alt ty::get(ty).struct { + match ty::get(ty).struct { ty::ty_tup(fs) => fs.len(), ty::ty_rec(fs) => fs.len(), ty::ty_box(_) | ty::ty_uniq(_) => 1u, ty::ty_enum(eid, _) => { - let id = alt check ctor { variant(id) => id }; - alt check vec::find(*ty::enum_variants(tcx, eid), |v| v.id == id ) { + let id = match check ctor { variant(id) => id }; + match check vec::find(*ty::enum_variants(tcx, eid), |v| v.id == id ) { some(v) => v.args.len() } } @@ -295,11 +297,11 @@ fn wild() -> @pat { fn specialize(tcx: ty::ctxt, r: ~[@pat], ctor_id: ctor, arity: uint, left_ty: ty::t) -> option<~[@pat]> { let r0 = raw_pat(r[0]); - alt r0.node { + match r0.node { pat_wild => some(vec::append(vec::from_elem(arity, wild()), vec::tail(r))), pat_ident(_, _, _) => { - alt tcx.def_map.find(r0.id) { + match tcx.def_map.find(r0.id) { some(def_variant(_, id)) => { if variant(id) == ctor_id { some(vec::tail(r)) } else { none } @@ -308,9 +310,9 @@ fn specialize(tcx: ty::ctxt, r: ~[@pat], ctor_id: ctor, arity: uint, } } pat_enum(_, args) => { - alt check tcx.def_map.get(r0.id) { + match check tcx.def_map.get(r0.id) { def_variant(_, id) if variant(id) == ctor_id => { - let args = alt args { + let args = match args { some(args) => args, none => vec::from_elem(arity, wild()) }; @@ -320,11 +322,11 @@ fn specialize(tcx: ty::ctxt, r: ~[@pat], ctor_id: ctor, arity: uint, } } pat_rec(flds, _) => { - let ty_flds = alt check ty::get(left_ty).struct { + let ty_flds = match check ty::get(left_ty).struct { ty::ty_rec(flds) => flds }; let args = vec::map(ty_flds, |ty_f| { - alt vec::find(flds, |f| f.ident == ty_f.ident ) { + match vec::find(flds, |f| f.ident == ty_f.ident ) { some(f) => f.pat, _ => wild() } }); @@ -334,7 +336,7 @@ fn specialize(tcx: ty::ctxt, r: ~[@pat], ctor_id: ctor, arity: uint, pat_box(a) | pat_uniq(a) => some(vec::append(~[a], vec::tail(r))), pat_lit(expr) => { let e_v = eval_const_expr(tcx, expr); - let match_ = alt check ctor_id { + let match_ = match check ctor_id { val(v) => compare_const_vals(e_v, v) == 0, range(c_lo, c_hi) => { compare_const_vals(c_lo, e_v) >= 0 && @@ -345,7 +347,7 @@ fn specialize(tcx: ty::ctxt, r: ~[@pat], ctor_id: ctor, arity: uint, if match_ { some(vec::tail(r)) } else { none } } pat_range(lo, hi) => { - let (c_lo, c_hi) = alt check ctor_id { + let (c_lo, c_hi) = match check ctor_id { val(v) => (v, v), range(lo, hi) => (lo, hi), single => return some(vec::tail(r)), @@ -373,14 +375,14 @@ fn check_local(tcx: ty::ctxt, loc: @local, &&s: (), v: visit::vt<()>) { } fn is_refutable(tcx: ty::ctxt, pat: @pat) -> bool { - alt tcx.def_map.find(pat.id) { + match tcx.def_map.find(pat.id) { some(def_variant(enum_id, var_id)) => { if vec::len(*ty::enum_variants(tcx, enum_id)) != 1u { return true; } } _ => () } - alt pat.node { + match pat.node { pat_box(sub) | pat_uniq(sub) | pat_ident(_, _, some(sub)) => { is_refutable(tcx, sub) } diff --git a/src/rustc/middle/check_const.rs b/src/rustc/middle/check_const.rs index 4d2ffa4b3e9..36b0908f435 100644 --- a/src/rustc/middle/check_const.rs +++ b/src/rustc/middle/check_const.rs @@ -20,7 +20,7 @@ fn check_crate(sess: session, crate: @crate, ast_map: ast_map::map, fn check_item(sess: session, ast_map: ast_map::map, def_map: resolve3::DefMap, it: @item, &&_is_const: bool, v: visit::vt<bool>) { - alt it.node { + match it.node { item_const(_, ex) => { v.visit_expr(ex, true, v); check_item_recursion(sess, ast_map, def_map, it); @@ -38,13 +38,13 @@ fn check_item(sess: session, ast_map: ast_map::map, fn check_pat(p: @pat, &&_is_const: bool, v: visit::vt<bool>) { fn is_str(e: @expr) -> bool { - alt e.node { + match e.node { expr_vstore(@{node: expr_lit(@{node: lit_str(_), _}), _}, vstore_uniq) => true, _ => false } } - alt p.node { + match p.node { // Let through plain ~-string literals here pat_lit(a) => if !is_str(a) { v.visit_expr(a, true, v); } pat_range(a, b) => { @@ -59,7 +59,7 @@ fn check_expr(sess: session, def_map: resolve3::DefMap, method_map: typeck::method_map, tcx: ty::ctxt, e: @expr, &&is_const: bool, v: visit::vt<bool>) { if is_const { - alt e.node { + match e.node { expr_unary(box(_), _) | expr_unary(uniq(_), _) | expr_unary(deref, _) => { sess.span_err(e.span, @@ -83,7 +83,7 @@ fn check_expr(sess: session, def_map: resolve3::DefMap, } } expr_path(_) => { - alt def_map.find(e.id) { + match def_map.find(e.id) { some(def_const(def_id)) => { if !ast_util::is_local(def_id) { sess.span_err( @@ -117,7 +117,7 @@ fn check_expr(sess: session, def_map: resolve3::DefMap, } } } - alt e.node { + match e.node { expr_lit(@{node: lit_int(v, t), _}) => { if t != ty_char { if (v as u64) > ast_util::int_ty_max( @@ -175,11 +175,11 @@ fn check_item_recursion(sess: session, ast_map: ast_map::map, } fn visit_expr(e: @expr, &&env: env, v: visit::vt<env>) { - alt e.node { + match e.node { expr_path(path) => { - alt env.def_map.find(e.id) { + match env.def_map.find(e.id) { some(def_const(def_id)) => { - alt check env.ast_map.get(def_id.node) { + match check env.ast_map.get(def_id.node) { ast_map::node_item(it, _) => { v.visit_item(it, env, v); } diff --git a/src/rustc/middle/check_loop.rs b/src/rustc/middle/check_loop.rs index 0ac3caa633b..8f3de8c8aa2 100644 --- a/src/rustc/middle/check_loop.rs +++ b/src/rustc/middle/check_loop.rs @@ -10,7 +10,7 @@ fn check_crate(tcx: ty::ctxt, crate: @crate) { visit::visit_item(i, {in_loop: false, can_ret: true}, v); }, visit_expr: |e: @expr, cx: ctx, v: visit::vt<ctx>| { - alt e.node { + match e.node { expr_while(e, b) => { v.visit_expr(e, cx, v); v.visit_block(b, {in_loop: true with cx}, v); diff --git a/src/rustc/middle/const_eval.rs b/src/rustc/middle/const_eval.rs index 66c19a14e6f..e15ef586042 100644 --- a/src/rustc/middle/const_eval.rs +++ b/src/rustc/middle/const_eval.rs @@ -41,7 +41,7 @@ enum constness { } fn join(a: constness, b: constness) -> constness { - alt (a,b) { + match (a,b) { (integral_const, integral_const) => integral_const, (integral_const, general_const) | (general_const, integral_const) @@ -58,13 +58,13 @@ fn classify(e: @expr, def_map: resolve3::DefMap, tcx: ty::ctxt) -> constness { let did = ast_util::local_def(e.id); - alt tcx.ccache.find(did) { + match tcx.ccache.find(did) { some(x) => x, none => { let cn = - alt e.node { + match e.node { ast::expr_lit(lit) => { - alt lit.node { + match lit.node { ast::lit_str(*) | ast::lit_float(*) => general_const, _ => integral_const @@ -87,7 +87,7 @@ fn classify(e: @expr, } ast::expr_vstore(e, vstore) => { - alt vstore { + match vstore { ast::vstore_fixed(_) | ast::vstore_slice(_) => classify(e, def_map, tcx), ast::vstore_uniq | @@ -134,7 +134,7 @@ fn classify(e: @expr, // FIXME: #1272, we can probably do something CCI-ish // surrounding nonlocal constants. But we don't yet. ast::expr_path(_) => { - alt def_map.find(e.id) { + match def_map.find(e.id) { some(ast::def_const(def_id)) => { if ast_util::is_local(def_id) { let ty = ty::expr_ty(tcx, e); @@ -191,24 +191,24 @@ enum const_val { fn eval_const_expr(tcx: middle::ty::ctxt, e: @expr) -> const_val { import middle::ty; fn fromb(b: bool) -> const_val { const_int(b as i64) } - alt check e.node { + match check e.node { expr_unary(neg, inner) => { - alt check eval_const_expr(tcx, inner) { + match check eval_const_expr(tcx, inner) { const_float(f) => const_float(-f), const_int(i) => const_int(-i), const_uint(i) => const_uint(-i) } } expr_unary(not, inner) => { - alt check eval_const_expr(tcx, inner) { + match check eval_const_expr(tcx, inner) { const_int(i) => const_int(!i), const_uint(i) => const_uint(!i) } } expr_binary(op, a, b) => { - alt check (eval_const_expr(tcx, a), eval_const_expr(tcx, b)) { + match check (eval_const_expr(tcx, a), eval_const_expr(tcx, b)) { (const_float(a), const_float(b)) => { - alt check op { + match check op { add => const_float(a + b), subtract => const_float(a - b), mul => const_float(a * b), @@ -223,7 +223,7 @@ fn eval_const_expr(tcx: middle::ty::ctxt, e: @expr) -> const_val { } } (const_int(a), const_int(b)) => { - alt check op { + match check op { add => const_int(a + b), subtract => const_int(a - b), mul => const_int(a * b), @@ -243,7 +243,7 @@ fn eval_const_expr(tcx: middle::ty::ctxt, e: @expr) -> const_val { } } (const_uint(a), const_uint(b)) => { - alt check op { + match check op { add => const_uint(a + b), subtract => const_uint(a - b), mul => const_uint(a * b), @@ -264,13 +264,13 @@ fn eval_const_expr(tcx: middle::ty::ctxt, e: @expr) -> const_val { } // shifts can have any integral type as their rhs (const_int(a), const_uint(b)) => { - alt check op { + match check op { shl => const_int(a << b), shr => const_int(a >> b) } } (const_uint(a), const_int(b)) => { - alt check op { + match check op { shl => const_uint(a << b), shr => const_uint(a >> b) } @@ -280,23 +280,23 @@ fn eval_const_expr(tcx: middle::ty::ctxt, e: @expr) -> const_val { expr_cast(base, _) => { let ety = ty::expr_ty(tcx, e); let base = eval_const_expr(tcx, base); - alt check ty::get(ety).struct { + match check ty::get(ety).struct { ty::ty_float(_) => { - alt check base { + match check base { const_uint(u) => const_float(u as f64), const_int(i) => const_float(i as f64), const_float(_) => base } } ty::ty_uint(_) => { - alt check base { + match check base { const_uint(_) => base, const_int(i) => const_uint(i as u64), const_float(f) => const_uint(f as u64) } } ty::ty_int(_) | ty::ty_bool => { - alt check base { + match check base { const_uint(u) => const_int(u as i64), const_int(_) => base, const_float(f) => const_int(f as i64) @@ -311,7 +311,7 @@ fn eval_const_expr(tcx: middle::ty::ctxt, e: @expr) -> const_val { } fn lit_to_const(lit: @lit) -> const_val { - alt lit.node { + match lit.node { lit_str(s) => const_str(*s), lit_int(n, _) => const_int(n), lit_uint(n, _) => const_uint(n), @@ -323,7 +323,7 @@ fn lit_to_const(lit: @lit) -> const_val { } fn compare_const_vals(a: const_val, b: const_val) -> int { - alt (a, b) { + match (a, b) { (const_int(a), const_int(b)) => { if a == b { 0 diff --git a/src/rustc/middle/freevars.rs b/src/rustc/middle/freevars.rs index 7c8e807a085..4c81ec30392 100644 --- a/src/rustc/middle/freevars.rs +++ b/src/rustc/middle/freevars.rs @@ -38,7 +38,7 @@ fn collect_freevars(def_map: resolve3::DefMap, blk: ast::blk) fn ignore_item(_i: @ast::item, &&_depth: int, _v: visit::vt<int>) { } let walk_expr = fn@(expr: @ast::expr, &&depth: int, v: visit::vt<int>) { - alt expr.node { + match expr.node { ast::expr_fn(proto, decl, _, _) => { if proto != ast::proto_bare { visit::visit_expr(expr, depth + 1, v); @@ -49,12 +49,12 @@ fn collect_freevars(def_map: resolve3::DefMap, blk: ast::blk) } ast::expr_path(path) => { let mut i = 0; - alt def_map.find(expr.id) { + match def_map.find(expr.id) { none => fail (~"Not found: " + path_to_str(path)), some(df) => { let mut def = df; while i < depth { - alt copy def { + match copy def { ast::def_upvar(_, inner, _) => { def = *inner; } _ => break } @@ -104,7 +104,7 @@ fn annotate_freevars(def_map: resolve3::DefMap, crate: @ast::crate) -> } fn get_freevars(tcx: ty::ctxt, fid: ast::node_id) -> freevar_info { - alt tcx.freevars.find(fid) { + match tcx.freevars.find(fid) { none => fail ~"get_freevars: " + int::str(fid) + ~" has no freevars", some(d) => return d } diff --git a/src/rustc/middle/kind.rs b/src/rustc/middle/kind.rs index e855e23b12b..408b0ef6916 100644 --- a/src/rustc/middle/kind.rs +++ b/src/rustc/middle/kind.rs @@ -144,7 +144,7 @@ fn with_appropriate_checker(cx: ctx, id: node_id, b: fn(check_fn)) { } let fty = ty::node_id_to_type(cx.tcx, id); - alt ty::ty_fn_proto(fty) { + match ty::ty_fn_proto(fty) { proto_uniq => b(check_for_uniq), proto_box => b(check_for_box), proto_bare => b(check_for_bare), @@ -166,7 +166,7 @@ fn check_fn(fk: visit::fn_kind, decl: fn_decl, body: blk, sp: span, // errors and produce a list of the def id's for all capture // variables. This list is used below to avoid checking and reporting // on a given variable twice. - let cap_clause = alt fk { + let cap_clause = match fk { visit::fk_anon(_, cc) | visit::fk_fn_block(cc) => cc, visit::fk_item_fn(*) | visit::fk_method(*) | visit::fk_ctor(*) | visit::fk_dtor(*) => @~[] @@ -190,7 +190,7 @@ fn check_fn(fk: visit::fn_kind, decl: fn_decl, body: blk, sp: span, // if this is the last use of the variable, then it will be // a move and not a copy let is_move = { - alt check cx.last_use_map.find(fn_id) { + match check cx.last_use_map.find(fn_id) { some(vars) => (*vars).contains(id), none => false } @@ -205,7 +205,7 @@ fn check_fn(fk: visit::fn_kind, decl: fn_decl, body: blk, sp: span, } fn check_block(b: blk, cx: ctx, v: visit::vt<ctx>) { - alt b.node.expr { + match b.node.expr { some(ex) => maybe_copy(cx, ex), _ => () } @@ -214,7 +214,7 @@ fn check_block(b: blk, cx: ctx, v: visit::vt<ctx>) { fn check_expr(e: @expr, cx: ctx, v: visit::vt<ctx>) { debug!{"kind::check_expr(%s)", expr_to_str(e)}; - alt e.node { + match e.node { expr_assign(_, ex) | expr_unary(box(_), ex) | expr_unary(uniq(_), ex) | expr_ret(some(ex)) => { @@ -233,11 +233,11 @@ fn check_expr(e: @expr, cx: ctx, v: visit::vt<ctx>) { } expr_rec(fields, def) => { for fields.each |field| { maybe_copy(cx, field.node.expr); } - alt def { + match def { some(ex) => { // All noncopyable fields must be overridden let t = ty::expr_ty(cx.tcx, ex); - let ty_fields = alt ty::get(t).struct { + let ty_fields = match ty::get(t).struct { ty::ty_rec(f) => f, _ => cx.tcx.sess.span_bug(ex.span, ~"bad expr type in record") }; @@ -258,7 +258,7 @@ fn check_expr(e: @expr, cx: ctx, v: visit::vt<ctx>) { expr_call(f, args, _) => { let mut i = 0u; for ty::ty_fn_args(ty::expr_ty(cx.tcx, f)).each |arg_t| { - alt ty::arg_mode(cx.tcx, arg_t) { + match ty::arg_mode(cx.tcx, arg_t) { by_copy => maybe_copy(cx, args[i]), by_ref | by_val | by_mutbl_ref | by_move => () } @@ -267,13 +267,13 @@ fn check_expr(e: @expr, cx: ctx, v: visit::vt<ctx>) { } expr_path(_) | expr_field(_, _, _) => { do option::iter(cx.tcx.node_type_substs.find(e.id)) |ts| { - let bounds = alt check e.node { + let bounds = match check e.node { expr_path(_) => { let did = ast_util::def_id_of_def(cx.tcx.def_map.get(e.id)); ty::lookup_item_type(cx.tcx, did).bounds } expr_field(base, _, _) => { - alt cx.method_map.get(e.id).origin { + match cx.method_map.get(e.id).origin { typeck::method_static(did) => { // n.b.: When we encode class/impl methods, the bounds // that we encode include both the class/impl bounds @@ -312,10 +312,10 @@ fn check_expr(e: @expr, cx: ctx, v: visit::vt<ctx>) { } fn check_stmt(stmt: @stmt, cx: ctx, v: visit::vt<ctx>) { - alt stmt.node { + match stmt.node { stmt_decl(@{node: decl_local(locals), _}, _) => { for locals.each |local| { - alt local.node.init { + match local.node.init { some({op: init_assign, expr}) => maybe_copy(cx, expr), _ => {} } @@ -327,7 +327,7 @@ fn check_stmt(stmt: @stmt, cx: ctx, v: visit::vt<ctx>) { } fn check_ty(aty: @ty, cx: ctx, v: visit::vt<ctx>) { - alt aty.node { + match aty.node { ty_path(_, id) => { do option::iter(cx.tcx.node_type_substs.find(id)) |ts| { let did = ast_util::def_id_of_def(cx.tcx.def_map.get(id)); @@ -373,9 +373,9 @@ fn maybe_copy(cx: ctx, ex: @expr) { } fn is_nullary_variant(cx: ctx, ex: @expr) -> bool { - alt ex.node { + match ex.node { expr_path(_) => { - alt cx.tcx.def_map.get(ex.id) { + match cx.tcx.def_map.get(ex.id) { def_variant(edid, vdid) => { vec::len(ty::enum_variant_with_id(cx.tcx, edid, vdid).args) == 0u } @@ -398,14 +398,14 @@ fn check_copy_ex(cx: ctx, ex: @expr, implicit_copy: bool) { fn check_imm_free_var(cx: ctx, def: def, sp: span) { let msg = ~"mutable variables cannot be implicitly captured; \ use a capture clause"; - alt def { + match def { def_local(_, is_mutbl) => { if is_mutbl { cx.tcx.sess.span_err(sp, msg); } } def_arg(_, mode) => { - alt ty::resolved_mode(cx.tcx, mode) { + match ty::resolved_mode(cx.tcx, mode) { by_ref | by_val | by_move | by_copy => { /* ok */ } by_mutbl_ref => { cx.tcx.sess.span_err(sp, msg); @@ -449,7 +449,7 @@ fn check_send(cx: ctx, ty: ty::t, sp: span) -> bool { // note: also used from middle::typeck::regionck! fn check_owned(tcx: ty::ctxt, ty: ty::t, sp: span) -> bool { if !ty::kind_is_owned(ty::type_kind(tcx, ty)) { - alt ty::get(ty).struct { + match ty::get(ty).struct { ty::ty_param(*) => { tcx.sess.span_err(sp, ~"value may contain borrowed \ pointers; use `owned` bound"); @@ -496,7 +496,7 @@ fn check_cast_for_escaping_regions( // Determine what type we are casting to; if it is not an trait, then no // worries. let target_ty = ty::expr_ty(cx.tcx, target); - let target_substs = alt ty::get(target_ty).struct { + let target_substs = match ty::get(target_ty).struct { ty::ty_trait(_, substs) => {substs} _ => { return; /* not a cast to a trait */ } }; @@ -504,7 +504,7 @@ fn check_cast_for_escaping_regions( // Check, based on the region associated with the trait, whether it can // possibly escape the enclosing fn item (note that all type parameters // must have been declared on the enclosing fn item): - alt target_substs.self_r { + match target_substs.self_r { some(ty::re_scope(*)) => { return; /* case (1) */ } none | some(ty::re_static) | some(ty::re_free(*)) => {} some(ty::re_bound(*)) | some(ty::re_var(*)) => { @@ -519,7 +519,7 @@ fn check_cast_for_escaping_regions( let target_params = ty::param_tys_in_type(target_ty); let source_ty = ty::expr_ty(cx.tcx, source); do ty::walk_ty(source_ty) |ty| { - alt ty::get(ty).struct { + match ty::get(ty).struct { ty::ty_param(source_param) => { if target_params.contains(source_param) { /* case (2) */ diff --git a/src/rustc/middle/lang_items.rs b/src/rustc/middle/lang_items.rs index 5abc64a3b0d..877dfd5f90c 100644 --- a/src/rustc/middle/lang_items.rs +++ b/src/rustc/middle/lang_items.rs @@ -98,9 +98,9 @@ class LanguageItemCollector { fn match_and_collect_meta_item(item_def_id: def_id, meta_item: meta_item) { - alt meta_item.node { + match meta_item.node { meta_name_value(key, literal) => { - alt literal.node { + match literal.node { lit_str(value) => { self.match_and_collect_item(item_def_id, *key, @@ -122,13 +122,13 @@ class LanguageItemCollector { return; // Didn't match. } - alt self.item_refs.find(value) { + match self.item_refs.find(value) { none => { // Didn't match. } some(item_ref) => { // Check for duplicates. - alt copy *item_ref { + match copy *item_ref { some(original_def_id) if original_def_id != item_def_id => { @@ -168,7 +168,7 @@ class LanguageItemCollector { do iter_crate_data(crate_store) |crate_number, _crate_metadata| { for each_path(crate_store, crate_number) |path_entry| { let def_id; - alt path_entry.def_like { + match path_entry.def_like { dl_def(def_ty(did)) => { def_id = did; } @@ -189,7 +189,7 @@ class LanguageItemCollector { fn check_completeness() { for self.item_refs.each |key, item_ref| { - alt copy *item_ref { + match copy *item_ref { none => { self.session.err(fmt!{"no item found for `%s`", key}); } diff --git a/src/rustc/middle/lint.rs b/src/rustc/middle/lint.rs index 61299171eae..4de9bf8e17d 100644 --- a/src/rustc/middle/lint.rs +++ b/src/rustc/middle/lint.rs @@ -55,7 +55,7 @@ enum lint { // This is pretty unfortunate. We really want some sort of "deriving Enum" // type of thing. fn int_to_lint(i: int) -> lint { - alt check i { + match check i { 0 => ctypes, 1 => unused_imports, 2 => while_true, @@ -70,7 +70,7 @@ fn int_to_lint(i: int) -> lint { } fn level_to_str(lv: level) -> ~str { - alt lv { + match lv { allow => ~"allow", warn => ~"warn", deny => ~"deny", @@ -166,7 +166,7 @@ fn mk_lint_settings() -> lint_settings { } fn get_lint_level(modes: lint_modes, lint: lint) -> level { - alt modes.find(lint as uint) { + match modes.find(lint as uint) { some(c) => c, none => allow } @@ -176,7 +176,7 @@ fn get_lint_settings_level(settings: lint_settings, lint_mode: lint, _expr_id: ast::node_id, item_id: ast::node_id) -> level { - alt settings.settings_map.find(item_id) { + match settings.settings_map.find(item_id) { some(modes) => get_lint_level(modes, lint_mode), none => get_lint_level(settings.default_settings, lint_mode) } @@ -230,10 +230,10 @@ impl methods for ctxt { attr::attr_metas(attr::find_attrs_by_name(attrs, level_name)); for metas.each |meta| { - alt meta.node { + match meta.node { ast::meta_list(_, metas) => { for metas.each |meta| { - alt meta.node { + match meta.node { ast::meta_word(lintname) => { vec::push(triples, (meta, level, lintname)); } @@ -255,7 +255,7 @@ impl methods for ctxt { for triples.each |pair| { let (meta, level, lintname) = pair; - alt self.dict.find(*lintname) { + match self.dict.find(*lintname) { none => { self.span_lint( new_ctxt.get_level(unrecognized_lint), @@ -354,9 +354,9 @@ fn item_stopping_visitor<E>(v: visit::vt<E>) -> visit::vt<E> { fn check_item_while_true(cx: ty::ctxt, it: @ast::item) { let visit = item_stopping_visitor(visit::mk_simple_visitor(@{ visit_expr: fn@(e: @ast::expr) { - alt e.node { + match e.node { ast::expr_while(cond, _) => { - alt cond.node { + match cond.node { ast::expr_lit(@{node: ast::lit_bool(true),_}) => { cx.sess.span_lint( while_true, e.id, it.id, @@ -380,9 +380,9 @@ fn check_item_ctypes(cx: ty::ctxt, it: @ast::item) { decl: ast::fn_decl) { let tys = vec::map(decl.inputs, |a| a.ty ); for vec::each(vec::append_one(tys, decl.output)) |ty| { - alt ty.node { + match ty.node { ast::ty_path(_, id) => { - alt cx.def_map.get(id) { + match cx.def_map.get(id) { ast::def_prim_ty(ast::ty_int(ast::ty_i)) => { cx.sess.span_lint( ctypes, id, fn_id, @@ -405,11 +405,11 @@ fn check_item_ctypes(cx: ty::ctxt, it: @ast::item) { } } - alt it.node { + match it.node { ast::item_foreign_mod(nmod) if attr::foreign_abi(it.attrs) != either::right(ast::foreign_abi_rust_intrinsic) => { for nmod.items.each |ni| { - alt ni.node { + match ni.node { ast::foreign_item_fn(decl, tps) => { check_foreign_fn(cx, it.id, decl); } @@ -423,7 +423,7 @@ fn check_item_ctypes(cx: ty::ctxt, it: @ast::item) { fn check_item_path_statement(cx: ty::ctxt, it: @ast::item) { let visit = item_stopping_visitor(visit::mk_simple_visitor(@{ visit_stmt: fn@(s: @ast::stmt) { - alt s.node { + match s.node { ast::stmt_semi(@{id: id, callee_id: _, node: ast::expr_path(@path), @@ -458,7 +458,7 @@ fn check_item_non_camel_case_types(cx: ty::ctxt, it: @ast::item) { } } - alt it.node { + match it.node { ast::item_ty(*) | ast::item_class(*) | ast::item_trait(*) | ast::item_impl(*) => { check_case(cx, it.ident, it.id, it.id, it.span) @@ -480,13 +480,13 @@ fn check_fn(tcx: ty::ctxt, fk: visit::fn_kind, decl: ast::fn_decl, // don't complain about blocks, since they tend to get their modes // specified from the outside - alt fk { + match fk { visit::fk_fn_block(*) => { return; } _ => {} } let fn_ty = ty::node_id_to_type(tcx, id); - alt check ty::get(fn_ty).struct { + match check ty::get(fn_ty).struct { ty::ty_fn(fn_ty) => { let mut counter = 0; do vec::iter2(fn_ty.inputs, decl.inputs) |arg_ty, arg_ast| { @@ -495,7 +495,7 @@ fn check_fn(tcx: ty::ctxt, fk: visit::fn_kind, decl: ast::fn_decl, counter, ty_to_str(tcx, arg_ty.ty), mode_to_str(arg_ast.mode)}; - alt arg_ast.mode { + match arg_ast.mode { ast::expl(ast::by_copy) => { /* always allow by-copy */ } diff --git a/src/rustc/middle/liveness.rs b/src/rustc/middle/liveness.rs index 38942b40750..6cad5e19e96 100644 --- a/src/rustc/middle/liveness.rs +++ b/src/rustc/middle/liveness.rs @@ -201,7 +201,7 @@ enum var_kind { } fn relevant_def(def: def) -> option<relevant_def> { - alt def { + match def { def_self(_) => some(rdef_self), def_arg(nid, _) | def_local(nid, _) => some(rdef_var(nid)), _ => none @@ -260,7 +260,7 @@ class ir_maps { vec::push(self.var_kinds, vk); self.num_vars += 1u; - alt vk { + match vk { vk_local(node_id, _) | vk_arg(node_id, _, _) => { self.variable_map.insert(node_id, v); } @@ -277,7 +277,7 @@ class ir_maps { } fn variable(node_id: node_id, span: span) -> variable { - alt self.variable_map.find(node_id) { + match self.variable_map.find(node_id) { some(var) => var, none => { self.tcx.sess.span_bug( @@ -287,7 +287,7 @@ class ir_maps { } fn variable_name(var: variable) -> ident { - alt self.var_kinds[*var] { + match self.var_kinds[*var] { vk_local(_, name) | vk_arg(_, name, _) => name, vk_field(name) => @(~"self." + *name), vk_self => @~"self", @@ -300,7 +300,7 @@ class ir_maps { } fn captures(expr: @expr) -> @~[capture_info] { - alt self.capture_map.find(expr.id) { + match self.capture_map.find(expr.id) { some(caps) => caps, none => { self.tcx.sess.span_bug(expr.span, ~"no registered caps"); @@ -315,11 +315,11 @@ class ir_maps { fn add_last_use(expr_id: node_id, var: variable) { let vk = self.var_kinds[*var]; debug!{"Node %d is a last use of variable %?", expr_id, vk}; - alt vk { + match vk { vk_arg(id, name, by_move) | vk_arg(id, name, by_copy) | vk_local(id, name) => { - let v = alt self.last_use_map.find(expr_id) { + let v = match self.last_use_map.find(expr_id) { some(v) => v, none => { let v = @dvec(); @@ -359,7 +359,7 @@ fn visit_fn(fk: visit::fn_kind, decl: fn_decl, body: blk, // and so forth: visit::visit_fn(fk, decl, body, sp, id, fn_maps, v); - alt fk { + match fk { visit::fk_ctor(_, _, _, _, class_did) => { add_class_fields(fn_maps, class_did); } @@ -414,7 +414,7 @@ fn visit_local(local: @local, &&self: @ir_maps, vt: vt<@ir_maps>) { } fn visit_expr(expr: @expr, &&self: @ir_maps, vt: vt<@ir_maps>) { - alt expr.node { + match expr.node { // live nodes required for uses or definitions of variables: expr_path(_) => { let def = self.tcx.def_map.get(expr.id); @@ -435,10 +435,10 @@ fn visit_expr(expr: @expr, &&self: @ir_maps, vt: vt<@ir_maps>) { proto, cap_clause); let mut call_caps = ~[]; for cvs.each |cv| { - alt relevant_def(cv.def) { + match relevant_def(cv.def) { some(rv) => { let cv_ln = (*self).add_live_node(lnk_freevar(cv.span)); - let is_move = alt cv.mode { + let is_move = match cv.mode { cap_move | cap_drop => true, // var must be dead afterwards cap_copy | cap_ref => false // var can still be used }; @@ -533,7 +533,7 @@ class liveness { // _______________________________________________________________________ fn live_node(node_id: node_id, span: span) -> live_node { - alt self.ir.live_node_map.find(node_id) { + match self.ir.live_node_map.find(node_id) { some(ln) => ln, none => { // This must be a mismatch between the ir_map construction @@ -548,14 +548,14 @@ class liveness { } fn variable_from_rdef(rv: relevant_def, span: span) -> variable { - alt rv { + match rv { rdef_self => self.s.self_var, rdef_var(nid) => self.variable(nid, span) } } fn variable_from_path(expr: @expr) -> option<variable> { - alt expr.node { + match expr.node { expr_path(_) => { let def = self.tcx.def_map.get(expr.id); relevant_def(def).map( @@ -572,7 +572,7 @@ class liveness { fn variable_from_def_map(node_id: node_id, span: span) -> option<variable> { - alt self.tcx.def_map.find(node_id) { + match self.tcx.def_map.find(node_id) { some(def) => { relevant_def(def).map( |rdef| self.variable_from_rdef(rdef, span) @@ -794,7 +794,7 @@ class liveness { fn propagate_through_fn_block(decl: fn_decl, blk: blk) -> live_node { // inputs passed by & mode should be considered live on exit: for decl.inputs.each |arg| { - alt ty::resolved_mode(self.tcx, arg.mode) { + match ty::resolved_mode(self.tcx, arg.mode) { by_mutbl_ref | by_ref | by_val => { // These are "non-owned" modes, so register a read at // the end. This will prevent us from moving out of @@ -836,7 +836,7 @@ class liveness { } fn propagate_through_stmt(stmt: @stmt, succ: live_node) -> live_node { - alt stmt.node { + match stmt.node { stmt_decl(decl, _) => { return self.propagate_through_decl(decl, succ); } @@ -848,7 +848,7 @@ class liveness { } fn propagate_through_decl(decl: @decl, succ: live_node) -> live_node { - alt decl.node { + match decl.node { decl_local(locals) => { do locals.foldr(succ) |local, succ| { self.propagate_through_local(local, succ) @@ -900,7 +900,7 @@ class liveness { } fn propagate_through_expr(expr: @expr, succ: live_node) -> live_node { - alt expr.node { + match expr.node { // Interesting cases with control flow or which gen/kill expr_path(_) => { @@ -912,7 +912,7 @@ class liveness { // then we treat it as a read of that variable. // Otherwise, we ignore it and just propagate down to // process `e`. - alt self.as_self_field(e, nm) { + match self.as_self_field(e, nm) { some((ln, var)) => { self.init_from_succ(ln, succ); self.acc(ln, var, ACC_READ | ACC_USE); @@ -1185,9 +1185,9 @@ class liveness { // these errors are detected in the later pass borrowck. We // just ignore such cases and treat them as reads. - alt expr.node { + match expr.node { expr_path(_) => succ, - expr_field(e, nm, _) => alt self.as_self_field(e, nm) { + expr_field(e, nm, _) => match self.as_self_field(e, nm) { some(_) => succ, none => self.propagate_through_expr(e, succ) } @@ -1199,9 +1199,9 @@ class liveness { fn write_lvalue(expr: @expr, succ: live_node, acc: uint) -> live_node { - alt expr.node { + match expr.node { expr_path(_) => self.access_path(expr, succ, acc), - expr_field(e, nm, _) => alt self.as_self_field(e, nm) { + expr_field(e, nm, _) => match self.as_self_field(e, nm) { some((ln, var)) => { self.init_from_succ(ln, succ); self.acc(ln, var, acc); @@ -1220,7 +1220,7 @@ class liveness { fn access_path(expr: @expr, succ: live_node, acc: uint) -> live_node { let def = self.tcx.def_map.get(expr.id); - alt relevant_def(def) { + match relevant_def(def) { some(rdef_self) => { // Accessing `self` is like accessing every field of // the current object. This allows something like @@ -1259,10 +1259,10 @@ class liveness { // If we checking a constructor, then we treat self.f as a // variable. we use the live_node id that will be assigned to // the reference to self but the variable id for `f`. - alt expr.node { + match expr.node { expr_path(_) => { let def = self.tcx.def_map.get(expr.id); - alt def { + match def { def_self(_) => { // Note: the field_map is empty unless we are in a ctor return self.ir.field_map.find(fld).map(|var| { @@ -1345,12 +1345,12 @@ class liveness { // Checking for error conditions fn check_local(local: @local, &&self: @liveness, vt: vt<@liveness>) { - alt local.node.init { + match local.node.init { some({op: op, expr: expr}) => { // Initializer: - alt op { + match op { init_move => self.check_move_from_expr(expr, vt), init_assign => () } @@ -1367,7 +1367,7 @@ fn check_local(local: @local, &&self: @liveness, vt: vt<@liveness>) { debug!{"check_local() with no initializer"}; do (*self).pat_bindings(local.node.pat) |ln, var, sp| { if !self.warn_about_unused(sp, ln, var) { - alt (*self).live_on_exit(ln, var) { + match (*self).live_on_exit(ln, var) { none => { /* not live: good */ } some(lnk) => { self.report_illegal_read( @@ -1384,7 +1384,7 @@ fn check_local(local: @local, &&self: @liveness, vt: vt<@liveness>) { } fn check_expr(expr: @expr, &&self: @liveness, vt: vt<@liveness>) { - alt expr.node { + match expr.node { expr_path(_) => { for (*self).variable_from_def_map(expr.id, expr.span).each |var| { let ln = (*self).live_node(expr.id, expr.span); @@ -1437,7 +1437,7 @@ fn check_expr(expr: @expr, &&self: @liveness, vt: vt<@liveness>) { let targs = ty::ty_fn_args(ty::expr_ty(self.tcx, f)); vt.visit_expr(f, self, vt); do vec::iter2(args, targs) |arg_expr, arg_ty| { - alt ty::resolved_mode(self.tcx, arg_ty.mode) { + match ty::resolved_mode(self.tcx, arg_ty.mode) { by_val | by_copy | by_ref | by_mutbl_ref => { vt.visit_expr(arg_expr, self, vt); } @@ -1480,7 +1480,7 @@ enum read_kind { impl check_methods for @liveness { fn check_fields(sp: span, entry_ln: live_node) { for self.ir.field_map.each |nm, var| { - alt (*self).live_on_entry(entry_ln, var) { + match (*self).live_on_entry(entry_ln, var) { none => { /* ok */ } some(lnk_exit) => { self.tcx.sess.span_err( @@ -1508,7 +1508,7 @@ impl check_methods for @liveness { self.tcx.sess.span_err( sp, ~"some control paths may return"); } else { - alt fk { + match fk { visit::fk_ctor(*) => { // ctors are written as though they are unit. } @@ -1525,14 +1525,14 @@ impl check_methods for @liveness { debug!{"check_move_from_var(%s, %s)", ln.to_str(), var.to_str()}; - alt (*self).live_on_exit(ln, var) { + match (*self).live_on_exit(ln, var) { none => {} some(lnk) => self.report_illegal_move(span, lnk, var) } } fn consider_last_use(expr: @expr, ln: live_node, var: variable) { - alt (*self).live_on_exit(ln, var) { + match (*self).live_on_exit(ln, var) { some(_) => {} none => (*self.ir).add_last_use(expr.id, var) } @@ -1547,9 +1547,9 @@ impl check_methods for @liveness { return vt.visit_expr(expr, self, vt); } - alt expr.node { + match expr.node { expr_path(_) => { - alt (*self).variable_from_path(expr) { + match (*self).variable_from_path(expr) { some(var) => { let ln = (*self).live_node(expr.id, expr.span); self.check_move_from_var(expr.span, ln, var); @@ -1582,9 +1582,9 @@ impl check_methods for @liveness { } fn check_lvalue(expr: @expr, vt: vt<@liveness>) { - alt expr.node { + match expr.node { expr_path(_) => { - alt self.tcx.def_map.get(expr.id) { + match self.tcx.def_map.get(expr.id) { def_local(nid, false) => { // Assignment to an immutable variable or argument: // only legal if there is no later assignment. @@ -1594,7 +1594,7 @@ impl check_methods for @liveness { self.warn_about_dead_assign(expr.span, ln, var); } def => { - alt relevant_def(def) { + match relevant_def(def) { some(rdef_var(nid)) => { let ln = (*self).live_node(expr.id, expr.span); let var = (*self).variable(nid, expr.span); @@ -1623,7 +1623,7 @@ impl check_methods for @liveness { fn check_for_reassignment(ln: live_node, var: variable, orig_span: span) { - alt (*self).assigned_on_exit(ln, var) { + match (*self).assigned_on_exit(ln, var) { some(lnk_expr(span)) => { self.tcx.sess.span_err( span, @@ -1651,7 +1651,7 @@ impl check_methods for @liveness { // we give a slightly different error message in those cases. if lnk == lnk_exit { let vk = self.ir.var_kinds[*var]; - alt vk { + match vk { vk_arg(_, name, _) => { self.tcx.sess.span_err( move_span, @@ -1691,7 +1691,7 @@ impl check_methods for @liveness { lnk: live_node_kind, var: variable, rk: read_kind) { - let msg = alt rk { + let msg = match rk { possibly_uninitialized_variable => { ~"possibly uninitialized variable" } @@ -1699,7 +1699,7 @@ impl check_methods for @liveness { moved_variable => ~"moved variable" }; let name = (*self.ir).variable_name(var); - alt lnk { + match lnk { lnk_freevar(span) => { self.tcx.sess.span_err( span, @@ -1727,13 +1727,13 @@ impl check_methods for @liveness { fn warn_about_unused_args(sp: span, decl: fn_decl, entry_ln: live_node) { for decl.inputs.each |arg| { let var = (*self).variable(arg.id, arg.ty.span); - alt ty::resolved_mode(self.tcx, arg.mode) { + match ty::resolved_mode(self.tcx, arg.mode) { by_mutbl_ref => { // for mutable reference arguments, something like // x = 1; // is not worth warning about, as it has visible // side effects outside the fn. - alt (*self).assigned_on_entry(entry_ln, var) { + match (*self).assigned_on_entry(entry_ln, var) { some(_) => { /*ok*/ } none => { // but if it is not written, it ought to be used diff --git a/src/rustc/middle/pat_util.rs b/src/rustc/middle/pat_util.rs index 405afe20a1c..f1f33e74e53 100644 --- a/src/rustc/middle/pat_util.rs +++ b/src/rustc/middle/pat_util.rs @@ -22,9 +22,9 @@ fn pat_id_map(dm: resolve3::DefMap, pat: @pat) -> pat_id_map { } fn pat_is_variant(dm: resolve3::DefMap, pat: @pat) -> bool { - alt pat.node { + match pat.node { pat_enum(_, _) => true, - pat_ident(_, _, none) => alt dm.find(pat.id) { + pat_ident(_, _, none) => match dm.find(pat.id) { some(def_variant(_, _)) => true, _ => false } @@ -35,7 +35,7 @@ fn pat_is_variant(dm: resolve3::DefMap, pat: @pat) -> bool { fn pat_bindings(dm: resolve3::DefMap, pat: @pat, it: fn(node_id, span, @path)) { do walk_pat(pat) |p| { - alt p.node { + match p.node { pat_ident(_, pth, _) if !pat_is_variant(dm, p) => { it(p.id, p.span, pth); } diff --git a/src/rustc/middle/region.rs b/src/rustc/middle/region.rs index 9cece96b892..362c4be7abe 100644 --- a/src/rustc/middle/region.rs +++ b/src/rustc/middle/region.rs @@ -88,7 +88,7 @@ fn scope_contains(region_map: region_map, superscope: ast::node_id, subscope: ast::node_id) -> bool { let mut subscope = subscope; while superscope != subscope { - alt region_map.find(subscope) { + match region_map.find(subscope) { none => return false, some(scope) => subscope = scope } @@ -103,7 +103,7 @@ fn subregion(region_map: region_map, super_region: ty::region, sub_region: ty::region) -> bool { super_region == sub_region || - alt (super_region, sub_region) { + match (super_region, sub_region) { (ty::re_static, _) => {true} (ty::re_scope(super_scope), ty::re_scope(sub_scope)) | @@ -128,7 +128,7 @@ fn nearest_common_ancestor(region_map: region_map, scope_a: ast::node_id, let mut result = ~[scope]; let mut scope = scope; loop { - alt region_map.find(scope) { + match region_map.find(scope) { none => return result, some(superscope) => { vec::push(result, superscope); @@ -172,7 +172,7 @@ fn nearest_common_ancestor(region_map: region_map, scope_a: ast::node_id, /// Extracts that current parent from cx, failing if there is none. fn parent_id(cx: ctxt, span: span) -> ast::node_id { - alt cx.parent { + match cx.parent { none => { cx.sess.span_bug(span, ~"crate should not be parent here"); } @@ -184,7 +184,7 @@ fn parent_id(cx: ctxt, span: span) -> ast::node_id { /// Records the current parent (if any) as the parent of `child_id`. fn record_parent(cx: ctxt, child_id: ast::node_id) { - alt cx.parent { + match cx.parent { none => { /* no-op */ } some(parent_id) => { debug!{"parent of node %d is node %d", child_id, parent_id}; @@ -207,10 +207,10 @@ fn resolve_arm(arm: ast::arm, cx: ctxt, visitor: visit::vt<ctxt>) { } fn resolve_pat(pat: @ast::pat, cx: ctxt, visitor: visit::vt<ctxt>) { - alt pat.node { + match pat.node { ast::pat_ident(_, path, _) => { let defn_opt = cx.def_map.find(pat.id); - alt defn_opt { + match defn_opt { some(ast::def_variant(_,_)) => { /* Nothing to do; this names a variant. */ } @@ -230,7 +230,7 @@ fn resolve_expr(expr: @ast::expr, cx: ctxt, visitor: visit::vt<ctxt>) { record_parent(cx, expr.id); let mut new_cx = cx; - alt expr.node { + match expr.node { ast::expr_call(*) => { debug!{"node %d: %s", expr.id, pprust::expr_to_str(expr)}; new_cx.parent = some(expr.id); @@ -276,7 +276,7 @@ fn resolve_fn(fk: visit::fn_kind, decl: ast::fn_decl, body: ast::blk, sp: span, id: ast::node_id, cx: ctxt, visitor: visit::vt<ctxt>) { - let fn_cx = alt fk { + let fn_cx = match fk { visit::fk_item_fn(*) | visit::fk_method(*) | visit::fk_ctor(*) | visit::fk_dtor(*) => { // Top-level functions are a root scope. @@ -380,7 +380,7 @@ impl methods for determine_rp_ctxt { from, to, ast_map::node_id_to_str(self.ast_map, from), ast_map::node_id_to_str(self.ast_map, to)}; - let vec = alt self.dep_map.find(from) { + let vec = match self.dep_map.find(from) { some(vec) => {vec} none => { let vec = @dvec(); @@ -424,7 +424,7 @@ impl methods for determine_rp_ctxt { // (anon_implies_rp) to true when we enter an item and setting // that flag to false when we enter a method. fn region_is_relevant(r: @ast::region) -> bool { - alt r.node { + match r.node { ast::re_anon => self.anon_implies_rp, ast::re_named(@~"self") => true, ast::re_named(_) => false @@ -485,7 +485,7 @@ fn determine_rp_in_ty(ty: @ast::ty, // if this type directly references a region, either via a // region pointer like &r.ty or a region-parameterized path // like path/r, add to the worklist/set - alt ty.node { + match ty.node { ast::ty_rptr(r, _) | ast::ty_path(@{rp: some(r), _}, _) => { debug!{"referenced type with regions %s", pprust::ty_to_str(ty)}; @@ -501,9 +501,9 @@ fn determine_rp_in_ty(ty: @ast::ty, // to the dep_map. If the type is not defined in this crate, // then check whether it is region-parameterized and consider // that as a direct dependency. - alt ty.node { + match ty.node { ast::ty_path(_, id) => { - alt cx.def_map.get(id) { + match cx.def_map.get(id) { ast::def_ty(did) | ast::def_class(did, _) => { if did.crate == ast::local_crate { cx.add_dep(did.node, cx.item_id); @@ -522,7 +522,7 @@ fn determine_rp_in_ty(ty: @ast::ty, _ => {} } - alt ty.node { + match ty.node { ast::ty_fn(*) => { do cx.with(cx.item_id, false) { visit::visit_ty(ty, cx, visitor); @@ -561,7 +561,7 @@ fn determine_rp_in_crate(sess: session, while cx.worklist.len() != 0 { let id = cx.worklist.pop(); debug!{"popped %d from worklist", id}; - alt cx.dep_map.find(id) { + match cx.dep_map.find(id) { none => {} some(vec) => { for vec.each |to_id| { diff --git a/src/rustc/middle/resolve3.rs b/src/rustc/middle/resolve3.rs index 9f17e38ba54..11f329669c0 100644 --- a/src/rustc/middle/resolve3.rs +++ b/src/rustc/middle/resolve3.rs @@ -247,7 +247,7 @@ class AtomTable { } fn intern(string: @~str) -> Atom { - alt self.atoms.find(string) { + match self.atoms.find(string) { none => { /* fall through */ } some(atom) => return atom } @@ -367,7 +367,7 @@ class ImportResolution { } fn target_for_namespace(namespace: Namespace) -> option<Target> { - alt namespace { + match namespace { ModuleNS => return copy self.module_target, TypeNS => return copy self.type_target, ValueNS => return copy self.value_target, @@ -461,7 +461,7 @@ class Module { // requiring a T:copy. pure fn is_none<T>(x: option<T>) -> bool { - alt x { + match x { none => return true, some(_) => return false } @@ -517,7 +517,7 @@ class NameBindings { /// Returns the module node if applicable. fn get_module_if_available() -> option<@Module> { - alt self.module_def { + match self.module_def { NoModuleDef => return none, ModuleDef(module_) => return some(module_) } @@ -528,7 +528,7 @@ class NameBindings { * definition. */ fn get_module() -> @Module { - alt self.module_def { + match self.module_def { NoModuleDef => { fail ~"get_module called on a node with no module definition!"; @@ -540,7 +540,7 @@ class NameBindings { } fn defined_in_namespace(namespace: Namespace) -> bool { - alt namespace { + match namespace { ModuleNS => return self.module_def != NoModuleDef, TypeNS => return self.type_def != none, ValueNS => return self.value_def != none, @@ -549,12 +549,12 @@ class NameBindings { } fn def_for_namespace(namespace: Namespace) -> option<def> { - alt namespace { + match namespace { TypeNS => return self.type_def, ValueNS => return self.value_def, - ModuleNS => alt self.module_def { + ModuleNS => match self.module_def { NoModuleDef => return none, - ModuleDef(module_) => alt module_.def_id { + ModuleDef(module_) => match module_.def_id { none => return none, some(def_id) => return some(def_mod(def_id)) } @@ -750,7 +750,7 @@ class Resolver { /// Returns the current module tracked by the reduced graph parent. fn get_module_from_parent(reduced_graph_parent: ReducedGraphParent) -> @Module { - alt reduced_graph_parent { + match reduced_graph_parent { ModuleReducedGraphParent(module_) => { return module_; } @@ -776,7 +776,7 @@ class Resolver { // module and add the child to that. let mut module_; - alt reduced_graph_parent { + match reduced_graph_parent { ModuleReducedGraphParent(parent_module) => { module_ = parent_module; } @@ -784,7 +784,7 @@ class Resolver { // Add or reuse the child. let new_parent = ModuleReducedGraphParent(module_); - alt module_.children.find(name) { + match module_.children.find(name) { none => { let child = @NameBindings(); module_.children.insert(name, child); @@ -804,9 +804,9 @@ class Resolver { // Check each statement. for block.node.stmts.each |statement| { - alt statement.node { + match statement.node { stmt_decl(declaration, _) => { - alt declaration.node { + match declaration.node { decl_item(_) => { return true; } @@ -828,7 +828,7 @@ class Resolver { } fn get_parent_link(parent: ReducedGraphParent, name: Atom) -> ParentLink { - alt parent { + match parent { ModuleReducedGraphParent(module_) => { return ModuleParentLink(module_, name); } @@ -843,7 +843,7 @@ class Resolver { let atom = (*self.atom_table).intern(item.ident); let (name_bindings, new_parent) = self.add_child(atom, parent); - alt item.node { + match item.node { item_mod(module_) => { let parent_link = self.get_parent_link(new_parent, atom); let def_id = { crate: 0, node: item.id }; @@ -894,7 +894,7 @@ class Resolver { item_class(_, _, class_members, optional_ctor, _) => { (*name_bindings).define_type(def_ty(local_def(item.id))); - alt optional_ctor { + match optional_ctor { none => { // Nothing to do. } @@ -913,7 +913,7 @@ class Resolver { let mut method_infos = ~[]; for class_members.each |class_member| { - alt class_member.node { + match class_member.node { class_method(method) => { // XXX: Combine with impl method code below. method_infos += ~[ @@ -979,7 +979,7 @@ class Resolver { let method_names = @atom_hashmap(); for methods.each |method| { let atom; - alt method { + match method { required(required_method) => { atom = (*self.atom_table).intern (required_method.ident); @@ -1028,7 +1028,7 @@ class Resolver { fn build_reduced_graph_for_view_item(view_item: @view_item, parent: ReducedGraphParent, &&_visitor: vt<ReducedGraphParent>) { - alt view_item.node { + match view_item.node { view_item_import(view_paths) => { for view_paths.each |view_path| { // Extract and intern the module part of the path. For @@ -1036,7 +1036,7 @@ class Resolver { // for simple paths we have to munge the path a little. let module_path = @dvec(); - alt view_path.node { + match view_path.node { view_path_simple(_, full_path, _) => { let path_len = full_path.idents.len(); assert path_len != 0u; @@ -1061,7 +1061,7 @@ class Resolver { // Build up the import directives. let module_ = self.get_module_from_parent(parent); - alt view_path.node { + match view_path.node { view_path_simple(binding, full_path, _) => { let target_atom = (*self.atom_table).intern(binding); @@ -1099,7 +1099,7 @@ class Resolver { view_item_export(view_paths) => { let module_ = self.get_module_from_parent(parent); for view_paths.each |view_path| { - alt view_path.node { + match view_path.node { view_path_simple(ident, full_path, ident_id) => { let last_ident = full_path.idents.last(); if last_ident != ident { @@ -1157,7 +1157,7 @@ class Resolver { } view_item_use(name, _, node_id) => { - alt find_use_stmt_cnum(self.session.cstore, node_id) { + match find_use_stmt_cnum(self.session.cstore, node_id) { some(crate_id) => { let atom = (*self.atom_table).intern(name); let (child_name_bindings, new_parent) = @@ -1189,7 +1189,7 @@ class Resolver { let name = (*self.atom_table).intern(foreign_item.ident); let (name_bindings, new_parent) = self.add_child(name, parent); - alt foreign_item.node { + match foreign_item.node { foreign_item_fn(fn_decl, type_parameters) => { let def = def_fn(local_def(foreign_item.id), fn_decl.purity); (*name_bindings).define_value(def); @@ -1262,7 +1262,7 @@ class Resolver { ModuleReducedGraphParent(current_module)); // Define or reuse the module node. - alt child_name_bindings.module_def { + match child_name_bindings.module_def { NoModuleDef => { debug!{"(building reduced graph for external crate) \ autovivifying %s", ident}; @@ -1283,11 +1283,11 @@ class Resolver { self.add_child(atom, ModuleReducedGraphParent(current_module)); - alt path_entry.def_like { + match path_entry.def_like { dl_def(def) => { - alt def { + match def { def_mod(def_id) | def_foreign_mod(def_id) => { - alt copy child_name_bindings.module_def { + match copy child_name_bindings.module_def { NoModuleDef => { debug!{"(building reduced graph for \ external crate) building module \ @@ -1296,7 +1296,7 @@ class Resolver { self.get_parent_link(new_parent, atom); - alt modules.find(def_id) { + match modules.find(def_id) { none => { (*child_name_bindings). define_module(parent_link, @@ -1315,7 +1315,9 @@ class Resolver { resolution. outstanding_references = 0; - alt existing_module.parent_link { + match existing_module + .parent_link { + NoParentLink | BlockParentLink(*) => { fail ~"can't happen"; @@ -1368,8 +1370,9 @@ class Resolver { // If this is a trait, add all the method names // to the trait info. - alt get_method_names_if_trait(self.session.cstore, - def_id) { + match get_method_names_if_trait( + self.session.cstore, def_id) { + none => { // Nothing to do. } @@ -1437,7 +1440,7 @@ class Resolver { self.build_reduced_graph_for_impls_in_external_module(module_); for module_.children.each |_name, child_node| { - alt (*child_node).get_module_if_available() { + match (*child_node).get_module_if_available() { none => { // Nothing to do. } @@ -1464,7 +1467,7 @@ class Resolver { self.module_to_str(module_), copy module_.def_id}; - alt module_.def_id { + match module_.def_id { none => { debug!{"(building reduced graph for impls in external \ module) no def ID for `%s`, skipping", @@ -1516,9 +1519,9 @@ class Resolver { // Bump the reference count on the name. Or, if this is a glob, set // the appropriate flag. - alt *subclass { + match *subclass { SingleImport(target, _) => { - alt module_.import_resolutions.find(target) { + match module_.import_resolutions.find(target) { some(resolution) => { resolution.outstanding_references += 1u; } @@ -1588,7 +1591,7 @@ class Resolver { self.resolve_imports_for_module(module_); for module_.children.each |_name, child_node| { - alt (*child_node).get_module_if_available() { + match (*child_node).get_module_if_available() { none => { // Nothing to do. } @@ -1616,7 +1619,7 @@ class Resolver { while module_.resolved_import_count < import_count { let import_index = module_.resolved_import_count; let import_directive = module_.imports.get_elt(import_index); - alt self.resolve_import_for_module(module_, import_directive) { + match self.resolve_import_for_module(module_, import_directive) { Failed => { // We presumably emitted an error. Continue. self.session.span_err(import_directive.span, @@ -1663,7 +1666,7 @@ class Resolver { import_directive); } else { // First, resolve the module path for the directive, if necessary. - alt self.resolve_module_path_for_import(module_, + match self.resolve_module_path_for_import(module_, module_path, NoXray, import_directive.span) { @@ -1678,7 +1681,7 @@ class Resolver { // We found the module that the target is contained // within. Attempt to resolve the import within it. - alt *import_directive.subclass { + match *import_directive.subclass { SingleImport(target, source) => { resolution_result = self.resolve_single_import(module_, @@ -1699,7 +1702,7 @@ class Resolver { } // Decrement the count of unresolved imports. - alt resolution_result { + match resolution_result { Success(()) => { assert self.unresolved_imports >= 1u; self.unresolved_imports -= 1u; @@ -1715,7 +1718,7 @@ class Resolver { // resolve_imports_for_module.) if resolution_result != Indeterminate { - alt *import_directive.subclass { + match *import_directive.subclass { GlobImport => { assert module_.glob_count >= 1u; module_.glob_count -= 1u; @@ -1757,7 +1760,7 @@ class Resolver { let mut impl_result = UnknownImplResult; // Search for direct children of the containing module. - alt containing_module.children.find(source) { + match containing_module.children.find(source) { none => { // Continue. } @@ -1786,7 +1789,7 @@ class Resolver { // Unless we managed to find a result in all four namespaces // (exceedingly unlikely), search imports as well. - alt (module_result, value_result, type_result, impl_result) { + match (module_result, value_result, type_result, impl_result) { (BoundResult(*), BoundResult(*), BoundResult(*), BoundImplResult(*)) => { // Continue. @@ -1805,7 +1808,7 @@ class Resolver { // Now search the exported imports within the containing // module. - alt containing_module.import_resolutions.find(source) { + match containing_module.import_resolutions.find(source) { none => { // The containing module definitely doesn't have an // exported import with the name in question. We can @@ -1833,7 +1836,7 @@ class Resolver { namespace: Namespace) -> NamespaceResult { - alt (*import_resolution). + match (*import_resolution). target_for_namespace(namespace) { none => { return UnboundResult; @@ -1892,7 +1895,7 @@ class Resolver { assert module_.import_resolutions.contains_key(target); let import_resolution = module_.import_resolutions.get(target); - alt module_result { + match module_result { BoundResult(target_module, name_bindings) => { debug!{"(resolving single import) found module binding"}; import_resolution.module_target = @@ -1906,7 +1909,7 @@ class Resolver { fail ~"module result should be known at this point"; } } - alt value_result { + match value_result { BoundResult(target_module, name_bindings) => { import_resolution.value_target = some(Target(target_module, name_bindings)); @@ -1916,7 +1919,7 @@ class Resolver { fail ~"value result should be known at this point"; } } - alt type_result { + match type_result { BoundResult(target_module, name_bindings) => { import_resolution.type_target = some(Target(target_module, name_bindings)); @@ -1926,7 +1929,7 @@ class Resolver { fail ~"type result should be known at this point"; } } - alt impl_result { + match impl_result { BoundImplResult(targets) => { for (*targets).each |target| { (*import_resolution.impl_target).push(target); @@ -1939,7 +1942,8 @@ class Resolver { } let i = import_resolution; - alt (i.module_target, i.value_target, i.type_target, i.impl_target) { + match (i.module_target, i.value_target, + i.type_target, i.impl_target) { /* If this name wasn't found in any of the four namespaces, it's definitely unresolved @@ -1996,7 +2000,7 @@ class Resolver { self.module_to_str(module_)}; // Here we merge two import resolutions. - alt module_.import_resolutions.find(atom) { + match module_.import_resolutions.find(atom) { none => { // Simple: just copy the old import resolution. let new_import_resolution = @@ -2017,7 +2021,7 @@ class Resolver { // Merge the two import resolutions at a finer-grained // level. - alt copy target_import_resolution.module_target { + match copy target_import_resolution.module_target { none => { // Continue. } @@ -2026,7 +2030,7 @@ class Resolver { some(copy module_target); } } - alt copy target_import_resolution.value_target { + match copy target_import_resolution.value_target { none => { // Continue. } @@ -2035,7 +2039,7 @@ class Resolver { some(copy value_target); } } - alt copy target_import_resolution.type_target { + match copy target_import_resolution.type_target { none => { // Continue. } @@ -2068,7 +2072,7 @@ class Resolver { } let mut dest_import_resolution; - alt module_.import_resolutions.find(atom) { + match module_.import_resolutions.find(atom) { none => { // Create a new import resolution from this child. dest_import_resolution = @ImportResolution(span); @@ -2131,7 +2135,7 @@ class Resolver { while index < module_path_len { let name = (*module_path).get_elt(index); - alt self.resolve_name_in_module(search_module, name, ModuleNS, + match self.resolve_name_in_module(search_module, name, ModuleNS, xray) { Failed => { @@ -2145,7 +2149,7 @@ class Resolver { return Indeterminate; } Success(target) => { - alt target.bindings.module_def { + match target.bindings.module_def { NoModuleDef => { // Not a module. self.session.span_err(span, @@ -2190,7 +2194,7 @@ class Resolver { let first_element = (*module_path).get_elt(0u); let mut search_module; - alt self.resolve_module_in_lexical_scope(module_, first_element) { + match self.resolve_module_in_lexical_scope(module_, first_element) { Failed => { self.session.span_err(span, ~"unresolved name"); return Failed; @@ -2226,7 +2230,7 @@ class Resolver { // The current module node is handled specially. First, check for // its immediate children. - alt module_.children.find(name) { + match module_.children.find(name) { some(name_bindings) if (*name_bindings).defined_in_namespace(namespace) => { @@ -2240,12 +2244,12 @@ class Resolver { // adjacent import statements are processed as though they mutated the // current scope. - alt module_.import_resolutions.find(name) { + match module_.import_resolutions.find(name) { none => { // Not found; continue. } some(import_resolution) => { - alt (*import_resolution).target_for_namespace(namespace) { + match (*import_resolution).target_for_namespace(namespace) { none => { // Not found; continue. debug!{"(resolving item in lexical scope) found \ @@ -2264,7 +2268,7 @@ class Resolver { let mut search_module = module_; loop { // Go to the next parent. - alt search_module.parent_link { + match search_module.parent_link { NoParentLink => { // No more parents. This module was unresolved. debug!{"(resolving item in lexical scope) unresolved \ @@ -2278,7 +2282,7 @@ class Resolver { } // Resolve the name in the parent module. - alt self.resolve_name_in_module(search_module, name, namespace, + match self.resolve_name_in_module(search_module, name, namespace, Xray) { Failed => { // Continue up the search chain. @@ -2302,9 +2306,9 @@ class Resolver { fn resolve_module_in_lexical_scope(module_: @Module, name: Atom) -> ResolveResult<@Module> { - alt self.resolve_item_in_lexical_scope(module_, name, ModuleNS) { + match self.resolve_item_in_lexical_scope(module_, name, ModuleNS) { Success(target) => { - alt target.bindings.module_def { + match target.bindings.module_def { NoModuleDef => { error!{"!!! (resolving module in lexical scope) module wasn't actually a module!"}; @@ -2355,7 +2359,7 @@ class Resolver { } // First, check the direct children of the module. - alt module_.children.find(name) { + match module_.children.find(name) { some(name_bindings) if (*name_bindings).defined_in_namespace(namespace) => { @@ -2376,7 +2380,7 @@ class Resolver { } // Otherwise, we check the list of resolved imports. - alt module_.import_resolutions.find(name) { + match module_.import_resolutions.find(name) { some(import_resolution) => { if import_resolution.outstanding_references != 0u { debug!{"(resolving name in module) import unresolved; \ @@ -2384,7 +2388,7 @@ class Resolver { return Indeterminate; } - alt (*import_resolution).target_for_namespace(namespace) { + match (*import_resolution).target_for_namespace(namespace) { none => { debug!{"(resolving name in module) name found, but \ not in namespace %?", @@ -2420,7 +2424,7 @@ class Resolver { let mut target_name; let mut source_name; - alt *import_directive.subclass { + match *import_directive.subclass { SingleImport(target, source) => { target_name = target; source_name = source; @@ -2442,7 +2446,7 @@ class Resolver { let mut module_result; debug!{"(resolving one-level naming result) searching for module"}; - alt self.resolve_item_in_lexical_scope(module_, + match self.resolve_item_in_lexical_scope(module_, source_name, ModuleNS) { @@ -2465,7 +2469,7 @@ class Resolver { let mut value_result; debug!{"(resolving one-level naming result) searching for value"}; - alt self.resolve_item_in_lexical_scope(module_, + match self.resolve_item_in_lexical_scope(module_, source_name, ValueNS) { @@ -2488,7 +2492,7 @@ class Resolver { let mut type_result; debug!{"(resolving one-level naming result) searching for type"}; - alt self.resolve_item_in_lexical_scope(module_, + match self.resolve_item_in_lexical_scope(module_, source_name, TypeNS) { @@ -2528,7 +2532,7 @@ class Resolver { let mut impl_result; debug!{"(resolving one-level naming result) searching for impl"}; - alt self.resolve_item_in_lexical_scope(module_, + match self.resolve_item_in_lexical_scope(module_, source_name, ImplNS) { @@ -2559,7 +2563,7 @@ class Resolver { } // Otherwise, proceed and write in the bindings. - alt module_.import_resolutions.find(target_name) { + match module_.import_resolutions.find(target_name) { none => { fail ~"(resolving one-level renaming import) reduced graph \ construction or glob importing should have created the \ @@ -2576,7 +2580,7 @@ class Resolver { import_resolution.value_target = value_result; import_resolution.type_target = type_result; - alt impl_result { + match impl_result { none => { // Nothing to do. } @@ -2604,7 +2608,7 @@ class Resolver { // Descend into children and anonymous children. for module_.children.each |_name, child_node| { - alt (*child_node).get_module_if_available() { + match (*child_node).get_module_if_available() { none => { // Continue. } @@ -2637,7 +2641,7 @@ class Resolver { // If this isn't a local crate, then bail out. We don't need to record // exports for local crates. - alt module_.def_id { + match module_.def_id { some(def_id) if def_id.crate == local_crate => { // OK. Continue. } @@ -2656,7 +2660,7 @@ class Resolver { self.record_exports_for_module(module_); for module_.children.each |_atom, child_name_bindings| { - alt (*child_name_bindings).get_module_if_available() { + match (*child_name_bindings).get_module_if_available() { none => { // Nothing to do. } @@ -2682,7 +2686,7 @@ class Resolver { again; } - alt self.resolve_definition_of_name_in_module(module_, + match self.resolve_definition_of_name_in_module(module_, name, namespace, Xray) { @@ -2723,7 +2727,7 @@ class Resolver { // If this isn't a local crate, then bail out. We don't need to // resolve implementations for external crates. - alt module_.def_id { + match module_.def_id { some(def_id) if def_id.crate == local_crate => { // OK. Continue. } @@ -2742,7 +2746,7 @@ class Resolver { self.build_impl_scope_for_module(module_); for module_.children.each |_atom, child_name_bindings| { - alt (*child_name_bindings).get_module_if_available() { + match (*child_name_bindings).get_module_if_available() { none => { // Nothing to do. } @@ -2788,7 +2792,7 @@ class Resolver { // Determine the parent's implementation scope. let mut parent_impl_scopes; - alt module_.parent_link { + match module_.parent_link { NoParentLink => { parent_impl_scopes = @nil; } @@ -2830,19 +2834,19 @@ class Resolver { let orig_module = self.current_module; // Move down in the graph. - alt name { + match name { none => { // Nothing to do. } some(name) => { - alt orig_module.children.find(name) { + match orig_module.children.find(name) { none => { debug!{"!!! (with scope) didn't find `%s` in `%s`", *(*self.atom_table).atom_to_str(name), self.module_to_str(orig_module)}; } some(name_bindings) => { - alt (*name_bindings).get_module_if_available() { + match (*name_bindings).get_module_if_available() { none => { debug!{"!!! (with scope) didn't find module \ for `%s` in `%s`", @@ -2873,7 +2877,7 @@ class Resolver { let mut def; let mut is_ty_param; - alt def_like { + match def_like { dl_def(d @ def_local(*)) | dl_def(d @ def_upvar(*)) | dl_def(d @ def_arg(*)) | dl_def(d @ def_binding(*)) => { def = d; @@ -2896,7 +2900,7 @@ class Resolver { let mut rib_index = rib_index + 1u; while rib_index < (*ribs).len() { let rib = (*ribs).get_elt(rib_index); - alt rib.kind { + match rib.kind { NormalRibKind => { // Nothing to do. Continue. } @@ -2910,7 +2914,7 @@ class Resolver { MethodRibKind(item_id, method_id) => { // If the def is a ty param, and came from the parent // item, it's ok - alt def { + match def { def_ty_param(did, _) if self.def_map.find(copy(did.node)) == some(def_typaram_binder(item_id)) => { // ok @@ -2976,7 +2980,7 @@ class Resolver { while i != 0u { i -= 1u; let rib = (*ribs).get_elt(i); - alt rib.bindings.find(name) { + match rib.bindings.find(name) { some(def_like) => { return self.upvarify(ribs, i, def_like, span, allow_capturing_self); @@ -3028,7 +3032,7 @@ class Resolver { self.xray_context = Xray; } - alt item.node { + match item.node { item_enum(_, type_parameters) | item_ty(_, type_parameters) => { do self.with_type_parameter_rib @@ -3090,7 +3094,7 @@ class Resolver { // // XXX: Do we need a node ID here? - alt method { + match method { required(ty_m) => { do self.with_type_parameter_rib (HasTypeParameters(&ty_m.tps, @@ -3148,7 +3152,7 @@ class Resolver { let atom = (*self.atom_table).intern(item.ident); do self.with_scope(some(atom)) { for foreign_module.items.each |foreign_item| { - alt foreign_item.node { + match foreign_item.node { foreign_item_fn(_, type_parameters) => { do self.with_type_parameter_rib (HasTypeParameters(&type_parameters, @@ -3206,7 +3210,7 @@ class Resolver { } fn with_type_parameter_rib(type_parameters: TypeParameters, f: fn()) { - alt type_parameters { + match type_parameters { HasTypeParameters(type_parameters, node_id, initial_index, rib_kind) => { @@ -3236,7 +3240,7 @@ class Resolver { f(); - alt type_parameters { + match type_parameters { HasTypeParameters(type_parameters, _, _, _) => { (*self.type_ribs).pop(); } @@ -3256,14 +3260,14 @@ class Resolver { visitor: ResolveVisitor) { // Check each element of the capture clause. - alt capture_clause { + match capture_clause { NoCaptureClause => { // Nothing to do. } HasCaptureClause(capture_clause) => { // Resolve each captured item. for (*capture_clause).each |capture_item| { - alt self.resolve_identifier(capture_item.name, + match self.resolve_identifier(capture_item.name, ValueNS, true, capture_item.span) { @@ -3287,7 +3291,7 @@ class Resolver { // If this function has type parameters, add them now. do self.with_type_parameter_rib(type_parameters) { // Resolve the type parameters. - alt type_parameters { + match type_parameters { NoTypeParameters => { // Continue. } @@ -3297,7 +3301,7 @@ class Resolver { } // Add self to the rib, if necessary. - alt self_binding { + match self_binding { NoSelfBinding => { // Nothing to do. } @@ -3309,7 +3313,7 @@ class Resolver { } // Add each argument to the rib. - alt optional_declaration { + match optional_declaration { none => { // Nothing to do. } @@ -3344,7 +3348,7 @@ class Resolver { for type_parameters.each |type_parameter| { for (*type_parameter.bounds).each |bound| { - alt bound { + match bound { bound_copy | bound_send | bound_const | bound_owned => { // Nothing to do. } @@ -3379,7 +3383,7 @@ class Resolver { // Resolve implemented traits. for traits.each |trt| { - alt self.resolve_path(trt.path, TypeNS, true, visitor) { + match self.resolve_path(trt.path, TypeNS, true, visitor) { none => { self.session.span_err(trt.path.span, ~"attempt to implement a \ @@ -3404,7 +3408,7 @@ class Resolver { // Resolve methods. for class_members.each |class_member| { - alt class_member.node { + match class_member.node { class_method(method) => { self.resolve_method(MethodRibKind(id, Provided(method.id)), @@ -3419,7 +3423,7 @@ class Resolver { } // Resolve the constructor, if applicable. - alt optional_constructor { + match optional_constructor { none => { // Nothing to do. } @@ -3436,7 +3440,7 @@ class Resolver { } // Resolve the destructor, if applicable. - alt optional_destructor { + match optional_destructor { none => { // Nothing to do. } @@ -3498,8 +3502,8 @@ class Resolver { if trait_references.len() >= 1 { let mut new_trait_refs = @dvec(); for trait_references.each |trait_reference| { - alt self.resolve_path(trait_reference.path, TypeNS, true, - visitor) { + match self.resolve_path( + trait_reference.path, TypeNS, true, visitor) { none => { self.session.span_err(span, ~"attempt to implement an \ @@ -3566,7 +3570,7 @@ class Resolver { self.resolve_type(local.node.ty, visitor); // Resolve the initializer, if necessary. - alt local.node.init { + match local.node.init { none => { // Nothing to do. } @@ -3639,7 +3643,7 @@ class Resolver { // Move down in the graph, if there's an anonymous module rooted here. let orig_module = self.current_module; - alt self.current_module.anonymous_children.find(block.node.id) { + match self.current_module.anonymous_children.find(block.node.id) { none => { /* Nothing to do. */ } some(anonymous_module) => { debug!{"(resolving block) found anonymous module, moving \ @@ -3659,7 +3663,7 @@ class Resolver { } fn resolve_type(ty: @ty, visitor: ResolveVisitor) { - alt ty.node { + match ty.node { // Like path expressions, the interpretation of path types depends // on whether the path has multiple elements in it or not. @@ -3668,7 +3672,7 @@ class Resolver { // scopes looking for it. let mut result_def; - alt self.resolve_path(path, TypeNS, true, visitor) { + match self.resolve_path(path, TypeNS, true, visitor) { some(def) => { debug!{"(resolving type) resolved `%s` to type", *path.idents.last()}; @@ -3679,7 +3683,7 @@ class Resolver { } } - alt result_def { + match result_def { some(_) => { // Continue. } @@ -3689,7 +3693,7 @@ class Resolver { let name = (*self.atom_table).intern(path.idents.last()); - alt self.primitive_type_table + match self.primitive_type_table .primitive_types .find(name) { @@ -3705,7 +3709,7 @@ class Resolver { } } - alt copy result_def { + match copy result_def { some(def) => { // Write the result into the def map. debug!{"(resolving type) writing resolution for `%s` \ @@ -3740,7 +3744,7 @@ class Resolver { let pat_id = pattern.id; do walk_pat(pattern) |pattern| { - alt pattern.node { + match pattern.node { pat_ident(binding_mode, path, _) if !path.global && path.idents.len() == 1u => { @@ -3754,7 +3758,7 @@ class Resolver { let atom = (*self.atom_table).intern(path.idents[0]); - alt self.resolve_enum_variant_or_const(atom) { + match self.resolve_enum_variant_or_const(atom) { FoundEnumVariant(def) if mode == RefutableMode => { debug!{"(resolving pattern) resolving `%s` to \ enum variant", @@ -3783,7 +3787,7 @@ class Resolver { let is_mutable = mutability == Mutable; - let def = alt mode { + let def = match mode { RefutableMode => { // For pattern arms, we must use // `def_binding` definitions. @@ -3808,7 +3812,7 @@ class Resolver { // because that breaks the assumptions later // passes make about or-patterns.) - alt bindings_list { + match bindings_list { some(bindings_list) if !bindings_list.contains_key(atom) => { let last_rib = (*self.value_ribs).last(); @@ -3845,7 +3849,7 @@ class Resolver { pat_ident(_, path, _) | pat_enum(path, _) => { // These two must be enum variants. - alt self.resolve_path(path, ValueNS, false, visitor) { + match self.resolve_path(path, ValueNS, false, visitor) { some(def @ def_variant(*)) => { self.record_def(pattern.id, def); } @@ -3886,12 +3890,12 @@ class Resolver { fn resolve_enum_variant_or_const(name: Atom) -> EnumVariantOrConstResolution { - alt self.resolve_item_in_lexical_scope(self.current_module, + match self.resolve_item_in_lexical_scope(self.current_module, name, ValueNS) { Success(target) => { - alt target.bindings.value_def { + match target.bindings.value_def { none => { fail ~"resolved name in the value namespace to a set \ of name bindings with no def?!"; @@ -3956,7 +3960,7 @@ class Resolver { -> option<def> { if check_ribs { - alt self.resolve_identifier_in_local_ribs(identifier, + match self.resolve_identifier_in_local_ribs(identifier, namespace, span) { some(def) => { @@ -3987,9 +3991,9 @@ class Resolver { } // First, search children. - alt containing_module.children.find(name) { + match containing_module.children.find(name) { some(child_name_bindings) => { - alt (*child_name_bindings).def_for_namespace(namespace) { + match (*child_name_bindings).def_for_namespace(namespace) { some(def) => { // Found it. Stop the search here. return ChildNameDefinition(def); @@ -4005,11 +4009,12 @@ class Resolver { } // Next, search import resolutions. - alt containing_module.import_resolutions.find(name) { + match containing_module.import_resolutions.find(name) { some(import_resolution) => { - alt (*import_resolution).target_for_namespace(namespace) { + match (*import_resolution).target_for_namespace(namespace) { some(target) => { - alt (*target.bindings).def_for_namespace(namespace) { + match (*target.bindings) + .def_for_namespace(namespace) { some(def) => { // Found it. import_resolution.used = true; @@ -4055,7 +4060,7 @@ class Resolver { let module_path_atoms = self.intern_module_part_of_path(path); let mut containing_module; - alt self.resolve_module_path_for_import(self.current_module, + match self.resolve_module_path_for_import(self.current_module, module_path_atoms, xray, path.span) { @@ -4078,7 +4083,7 @@ class Resolver { } let name = (*self.atom_table).intern(path.idents.last()); - alt self.resolve_definition_of_name_in_module(containing_module, + match self.resolve_definition_of_name_in_module(containing_module, name, namespace, xray) { @@ -4108,7 +4113,7 @@ class Resolver { let root_module = (*self.graph_root).get_module(); let mut containing_module; - alt self.resolve_module_path_from_root(root_module, + match self.resolve_module_path_from_root(root_module, module_path_atoms, 0u, xray, @@ -4132,7 +4137,7 @@ class Resolver { } let name = (*self.atom_table).intern(path.idents.last()); - alt self.resolve_definition_of_name_in_module(containing_module, + match self.resolve_definition_of_name_in_module(containing_module, name, namespace, xray) { @@ -4161,7 +4166,7 @@ class Resolver { // Check the local set of ribs. let mut search_result; - alt namespace { + match namespace { ValueNS => { search_result = self.search_ribs(self.value_ribs, name, span, DontAllowCapturingSelf); @@ -4175,7 +4180,7 @@ class Resolver { } } - alt copy search_result { + match copy search_result { some(dl_def(def)) => { debug!{"(resolving path in local ribs) resolved `%s` to \ local: %?", @@ -4196,12 +4201,12 @@ class Resolver { let name = (*self.atom_table).intern(ident); // Check the items. - alt self.resolve_item_in_lexical_scope(self.current_module, + match self.resolve_item_in_lexical_scope(self.current_module, name, namespace) { Success(target) => { - alt (*target.bindings).def_for_namespace(namespace) { + match (*target.bindings).def_for_namespace(namespace) { none => { fail ~"resolved name in a namespace to a set of name \ bindings with no def for that namespace?!"; @@ -4235,7 +4240,7 @@ class Resolver { self.record_candidate_traits_for_expr_if_necessary(expr); // Next, resolve the node. - alt expr.node { + match expr.node { // The interpretation of paths depends on whether the path has // multiple elements in it or not. @@ -4243,7 +4248,7 @@ class Resolver { // This is a local path in the value namespace. Walk through // scopes looking for it. - alt self.resolve_path(path, ValueNS, true, visitor) { + match self.resolve_path(path, ValueNS, true, visitor) { some(def) => { // Write the result into the def map. debug!{"(resolving expr) resolved `%s`", @@ -4288,7 +4293,7 @@ class Resolver { // type Bar<A> = Foo<A>; // let bar = Bar { ... } // no type parameters - alt self.resolve_path(path, TypeNS, false, visitor) { + match self.resolve_path(path, TypeNS, false, visitor) { some(definition @ def_ty(class_id)) if self.structs.contains_key(class_id) => { @@ -4316,7 +4321,7 @@ class Resolver { } fn record_impls_for_expr_if_necessary(expr: @expr) { - alt expr.node { + match expr.node { expr_field(*) | expr_path(*) | expr_cast(*) | expr_binary(*) | expr_unary(*) | expr_assign_op(*) | expr_index(*) => { self.impl_map.insert(expr.id, @@ -4329,7 +4334,7 @@ class Resolver { } fn record_candidate_traits_for_expr_if_necessary(expr: @expr) { - alt expr.node { + match expr.node { expr_field(_, ident, _) => { let atom = (*self.atom_table).intern(ident); let traits = self.search_for_traits_containing_method(atom); @@ -4394,7 +4399,7 @@ class Resolver { let mut search_module = self.current_module; loop { // Look for the current trait. - alt copy self.current_trait_refs { + match copy self.current_trait_refs { some(trait_def_ids) => { for trait_def_ids.each |trait_def_id| { self.add_trait_info_if_containing_method @@ -4408,7 +4413,7 @@ class Resolver { // Look for trait children. for search_module.children.each |_name, child_name_bindings| { - alt child_name_bindings.def_for_namespace(TypeNS) { + match child_name_bindings.def_for_namespace(TypeNS) { some(def_ty(trait_def_id)) => { self.add_trait_info_if_containing_method(found_traits, trait_def_id, @@ -4424,12 +4429,12 @@ class Resolver { for search_module.import_resolutions.each |_atom, import_resolution| { - alt import_resolution.target_for_namespace(TypeNS) { + match import_resolution.target_for_namespace(TypeNS) { none => { // Continue. } some(target) => { - alt target.bindings.def_for_namespace(TypeNS) { + match target.bindings.def_for_namespace(TypeNS) { some(def_ty(trait_def_id)) => { self.add_trait_info_if_containing_method (found_traits, trait_def_id, name); @@ -4443,7 +4448,7 @@ class Resolver { } // Move to the next parent. - alt search_module.parent_link { + match search_module.parent_link { NoParentLink => { // Done. break; @@ -4462,7 +4467,7 @@ class Resolver { trait_def_id: def_id, name: Atom) { - alt self.trait_info.find(trait_def_id) { + match self.trait_info.find(trait_def_id) { some(trait_info) if trait_info.contains_key(name) => { debug!{"(adding trait info if containing method) found trait \ %d:%d for method '%s'", @@ -4508,7 +4513,7 @@ class Resolver { // If this isn't a local crate, then bail out. We don't need to check // for unused imports in external crates. - alt module_.def_id { + match module_.def_id { some(def_id) if def_id.crate == local_crate => { // OK. Continue. } @@ -4527,7 +4532,7 @@ class Resolver { self.check_for_unused_imports_in_module(module_); for module_.children.each |_atom, child_name_bindings| { - alt (*child_name_bindings).get_module_if_available() { + match (*child_name_bindings).get_module_if_available() { none => { // Nothing to do. } @@ -4546,7 +4551,7 @@ class Resolver { fn check_for_unused_imports_in_module(module_: @Module) { for module_.import_resolutions.each |_impl_name, import_resolution| { if !import_resolution.used { - alt self.unused_import_lint_level { + match self.unused_import_lint_level { warn => { self.session.span_warn(import_resolution.span, ~"unused import"); @@ -4577,7 +4582,7 @@ class Resolver { let atoms = dvec(); let mut current_module = module_; loop { - alt current_module.parent_link { + match current_module.parent_link { NoParentLink => { break; } @@ -4624,7 +4629,7 @@ class Resolver { debug!{"Import resolutions:"}; for module_.import_resolutions.each |name, import_resolution| { let mut module_repr; - alt (*import_resolution).target_for_namespace(ModuleNS) { + match (*import_resolution).target_for_namespace(ModuleNS) { none => { module_repr = ~""; } some(target) => { module_repr = ~" module:?"; @@ -4633,7 +4638,7 @@ class Resolver { } let mut value_repr; - alt (*import_resolution).target_for_namespace(ValueNS) { + match (*import_resolution).target_for_namespace(ValueNS) { none => { value_repr = ~""; } some(target) => { value_repr = ~" value:?"; @@ -4642,7 +4647,7 @@ class Resolver { } let mut type_repr; - alt (*import_resolution).target_for_namespace(TypeNS) { + match (*import_resolution).target_for_namespace(TypeNS) { none => { type_repr = ~""; } some(target) => { type_repr = ~" type:?"; @@ -4651,7 +4656,7 @@ class Resolver { } let mut impl_repr; - alt (*import_resolution).target_for_namespace(ImplNS) { + match (*import_resolution).target_for_namespace(ImplNS) { none => { impl_repr = ~""; } some(target) => { impl_repr = ~" impl:?"; @@ -4671,7 +4676,7 @@ class Resolver { let mut i = 0u; let mut impl_scopes = impl_scopes; loop { - alt *impl_scopes { + match *impl_scopes { cons(impl_scope, rest_impl_scopes) => { debug!{"Impl scope %u:", i}; diff --git a/src/rustc/middle/trans/alt.rs b/src/rustc/middle/trans/alt.rs index e3103cfefc6..783a856fd9d 100644 --- a/src/rustc/middle/trans/alt.rs +++ b/src/rustc/middle/trans/alt.rs @@ -25,7 +25,7 @@ enum opt { range(@ast::expr, @ast::expr) } fn opt_eq(tcx: ty::ctxt, a: opt, b: opt) -> bool { - alt (a, b) { + match (a, b) { (lit(a), lit(b)) => const_eval::compare_lit_exprs(tcx, a, b) == 0, (range(a1, a2), range(b1, b2)) => { const_eval::compare_lit_exprs(tcx, a1, b1) == 0 && @@ -44,9 +44,9 @@ fn trans_opt(bcx: block, o: opt) -> opt_result { let _icx = bcx.insn_ctxt(~"alt::trans_opt"); let ccx = bcx.ccx(); let mut bcx = bcx; - alt o { + match o { lit(l) => { - alt l.node { + match l.node { ast::expr_vstore(@{node: ast::expr_lit( @{node: ast::lit_str(s), _}), _}, ast::vstore_uniq) => { @@ -112,7 +112,7 @@ type match_ = ~[match_branch]; fn has_nested_bindings(m: match_, col: uint) -> bool { for vec::each(m) |br| { - alt br.pats[col].node { + match br.pats[col].node { ast::pat_ident(_, _, some(_)) => return true, _ => () } @@ -125,7 +125,7 @@ fn expand_nested_bindings(bcx: block, m: match_, col: uint, val: ValueRef) let mut result = ~[]; for vec::each(m) |br| { - alt br.pats[col].node { + match br.pats[col].node { ast::pat_ident(mode, name, some(inner)) => { let pats = vec::append( vec::slice(br.pats, 0u, col), @@ -155,13 +155,13 @@ fn enter_match(bcx: block, dm: DefMap, m: match_, col: uint, val: ValueRef, e: enter_pat) -> match_ { let mut result = ~[]; for vec::each(m) |br| { - alt e(br.pats[col]) { + match e(br.pats[col]) { some(sub) => { let pats = vec::append( vec::append(sub, vec::view(br.pats, 0u, col)), vec::view(br.pats, col + 1u, br.pats.len())); let self = br.pats[col]; - let bound = alt self.node { + let bound = match self.node { ast::pat_ident(mode, name, none) if !pat_is_variant(dm, self) => { vec::append(br.bound, @@ -186,7 +186,7 @@ fn enter_default(bcx: block, dm: DefMap, m: match_, col: uint, val: ValueRef) -> match_ { do enter_match(bcx, dm, m, col, val) |p| { - alt p.node { + match p.node { ast::pat_wild | ast::pat_rec(_, _) | ast::pat_tup(_) => some(~[]), ast::pat_ident(_, _, none) if !pat_is_variant(dm, p) => some(~[]), _ => none @@ -199,7 +199,7 @@ fn enter_opt(bcx: block, m: match_, opt: opt, col: uint, let tcx = bcx.tcx(); let dummy = @{id: 0, node: ast::pat_wild, span: dummy_sp()}; do enter_match(bcx, tcx.def_map, m, col, val) |p| { - alt p.node { + match p.node { ast::pat_enum(_, subpats) => { if opt_eq(tcx, variant_opt(tcx, p.id), opt) { some(option::get_default(subpats, @@ -225,7 +225,7 @@ fn enter_rec(bcx: block, dm: DefMap, m: match_, col: uint, fields: ~[ast::ident], val: ValueRef) -> match_ { let dummy = @{id: 0, node: ast::pat_wild, span: dummy_sp()}; do enter_match(bcx, dm, m, col, val) |p| { - alt p.node { + match p.node { ast::pat_rec(fpats, _) => { let mut pats = ~[]; for vec::each(fields) |fname| { @@ -246,7 +246,7 @@ fn enter_tup(bcx: block, dm: DefMap, m: match_, col: uint, val: ValueRef, n_elts: uint) -> match_ { let dummy = @{id: 0, node: ast::pat_wild, span: dummy_sp()}; do enter_match(bcx, dm, m, col, val) |p| { - alt p.node { + match p.node { ast::pat_tup(elts) => some(elts), _ => some(vec::from_elem(n_elts, dummy)) } @@ -257,7 +257,7 @@ fn enter_box(bcx: block, dm: DefMap, m: match_, col: uint, val: ValueRef) -> match_ { let dummy = @{id: 0, node: ast::pat_wild, span: dummy_sp()}; do enter_match(bcx, dm, m, col, val) |p| { - alt p.node { + match p.node { ast::pat_box(sub) => some(~[sub]), _ => some(~[dummy]) } @@ -268,7 +268,7 @@ fn enter_uniq(bcx: block, dm: DefMap, m: match_, col: uint, val: ValueRef) -> match_ { let dummy = @{id: 0, node: ast::pat_wild, span: dummy_sp()}; do enter_match(bcx, dm, m, col, val) |p| { - alt p.node { + match p.node { ast::pat_uniq(sub) => some(~[sub]), _ => some(~[dummy]) } @@ -287,7 +287,7 @@ fn get_options(ccx: @crate_ctxt, m: match_, col: uint) -> ~[opt] { if pat_is_variant(ccx.tcx.def_map, cur) { add_to_set(ccx.tcx, found, variant_opt(ccx.tcx, br.pats[col].id)); } else { - alt cur.node { + match cur.node { ast::pat_lit(l) => add_to_set(ccx.tcx, found, lit(l)), ast::pat_range(l1, l2) => { add_to_set(ccx.tcx, found, range(l1, l2)); @@ -304,7 +304,9 @@ fn extract_variant_args(bcx: block, pat_id: ast::node_id, {vals: ~[ValueRef], bcx: block} { let _icx = bcx.insn_ctxt(~"alt::extract_variant_args"); let ccx = bcx.fcx.ccx; - let enum_ty_substs = alt check ty::get(node_id_type(bcx, pat_id)).struct { + let enum_ty_substs = match check ty::get(node_id_type(bcx, pat_id)) + .struct { + ty::ty_enum(id, substs) => { assert id == vdefs.enm; substs.tps } }; let mut blobptr = val; @@ -328,7 +330,7 @@ fn extract_variant_args(bcx: block, pat_id: ast::node_id, fn collect_record_fields(m: match_, col: uint) -> ~[ast::ident] { let mut fields: ~[ast::ident] = ~[]; for vec::each(m) |br| { - alt br.pats[col].node { + match br.pats[col].node { ast::pat_rec(fs, _) => { for vec::each(fs) |f| { if !vec::any(fields, |x| str::eq(f.ident, x)) { @@ -346,7 +348,7 @@ fn root_pats_as_necessary(bcx: block, m: match_, col: uint, val: ValueRef) { for vec::each(m) |br| { let pat_id = br.pats[col].id; - alt bcx.ccx().maps.root_map.find({id:pat_id, derefs:0u}) { + match bcx.ccx().maps.root_map.find({id:pat_id, derefs:0u}) { none => (), some(scope_id) => { // Note: the scope_id will always be the id of the alt. See the @@ -364,7 +366,7 @@ fn root_pats_as_necessary(bcx: block, m: match_, col: uint, val: ValueRef) { fn any_box_pat(m: match_, col: uint) -> bool { for vec::each(m) |br| { - alt br.pats[col].node { + match br.pats[col].node { ast::pat_box(_) => return true, _ => () } @@ -374,7 +376,7 @@ fn any_box_pat(m: match_, col: uint) -> bool { fn any_uniq_pat(m: match_, col: uint) -> bool { for vec::each(m) |br| { - alt br.pats[col].node { + match br.pats[col].node { ast::pat_uniq(_) => return true, _ => () } @@ -384,7 +386,7 @@ fn any_uniq_pat(m: match_, col: uint) -> bool { fn any_tup_pat(m: match_, col: uint) -> bool { for vec::each(m) |br| { - alt br.pats[col].node { + match br.pats[col].node { ast::pat_tup(_) => return true, _ => () } @@ -397,7 +399,7 @@ type mk_fail = fn@() -> BasicBlockRef; fn pick_col(m: match_) -> uint { fn score(p: @ast::pat) -> uint { - alt p.node { + match p.node { ast::pat_lit(_) | ast::pat_enum(_, _) | ast::pat_range(_, _) => 1u, ast::pat_ident(_, _, some(p)) => score(p), _ => 0u @@ -435,7 +437,7 @@ fn compile_submatch(bcx: block, m: match_, vals: ~[ValueRef], if m.len() == 0u { Br(bcx, option::get(chk)()); return; } if m[0].pats.len() == 0u { let data = m[0].data; - alt data.guard { + match data.guard { some(e) => { // Temporarily set bindings. They'll be rewritten to PHI nodes // for the actual arm block. @@ -512,7 +514,7 @@ fn compile_submatch(bcx: block, m: match_, vals: ~[ValueRef], if any_tup_pat(m, col) { let tup_ty = node_id_type(bcx, pat_id); - let n_tup_elts = alt ty::get(tup_ty).struct { + let n_tup_elts = match ty::get(tup_ty).struct { ty::ty_tup(elts) => elts.len(), _ => ccx.sess.bug(~"non-tuple type in tuple pattern") }; @@ -553,7 +555,7 @@ fn compile_submatch(bcx: block, m: match_, vals: ~[ValueRef], let mut kind = no_branch; let mut test_val = val; if opts.len() > 0u { - alt opts[0] { + match opts[0] { var(_, vdef) => { if (*ty::enum_variants(tcx, vdef.enm)).len() == 1u { kind = single; @@ -578,12 +580,12 @@ fn compile_submatch(bcx: block, m: match_, vals: ~[ValueRef], } } for vec::each(opts) |o| { - alt o { + match o { range(_, _) => { kind = compare; break } _ => () } } - let else_cx = alt kind { + let else_cx = match kind { no_branch | single => bcx, _ => sub_block(bcx, ~"match_else") }; @@ -601,10 +603,10 @@ fn compile_submatch(bcx: block, m: match_, vals: ~[ValueRef], let mut opt_cx = else_cx; if !exhaustive || i < len { opt_cx = sub_block(bcx, ~"match_case"); - alt kind { + match kind { single => Br(bcx, opt_cx.llbb), switch => { - alt check trans_opt(bcx, opt) { + match check trans_opt(bcx, opt) { single_result(r) => { llvm::LLVMAddCase(sw, r.val, opt_cx.llbb); bcx = r.bcx; @@ -615,7 +617,7 @@ fn compile_submatch(bcx: block, m: match_, vals: ~[ValueRef], let t = node_id_type(bcx, pat_id); let {bcx: after_cx, val: matches} = { do with_scope_result(bcx, none, ~"compare_scope") |bcx| { - alt trans_opt(bcx, opt) { + match trans_opt(bcx, opt) { single_result({bcx, val}) => { trans_compare(bcx, ast::eq, test_val, t, val, t) } @@ -638,7 +640,7 @@ fn compile_submatch(bcx: block, m: match_, vals: ~[ValueRef], } else if kind == compare { Br(bcx, else_cx.llbb); } let mut size = 0u; let mut unpacked = ~[]; - alt opt { + match opt { var(_, vdef) => { let args = extract_variant_args(opt_cx, pat_id, vdef, val); size = args.vals.len(); @@ -671,7 +673,7 @@ fn make_phi_bindings(bcx: block, map: ~[exit_node], let mut vals = ~[]; for vec::each(map) |ex| { if ex.to as uint == our_block { - alt assoc(name, ex.bound) { + match assoc(name, ex.bound) { some(binding) => { vec::push(llbbs, ex.from); vec::push(vals, binding.val); @@ -774,14 +776,14 @@ fn trans_alt_inner(scope_cx: block, expr: @ast::expr, arms: ~[ast::arm], fn mk_fail(bcx: block, sp: span, msg: ~str, done: @mut option<BasicBlockRef>) -> BasicBlockRef { - alt *done { some(bb) => return bb, _ => () } + match *done { some(bb) => return bb, _ => () } let fail_cx = sub_block(bcx, ~"case_fallthrough"); trans_fail(fail_cx, some(sp), msg); *done = some(fail_cx.llbb); return fail_cx.llbb; } let t = node_id_type(bcx, expr.id); - let mk_fail = alt mode { + let mk_fail = match mode { ast::alt_check => { let fail_cx = @mut none; // Cached fail-on-fallthrough block @@ -829,7 +831,7 @@ fn bind_irrefutable_pat(bcx: block, pat: @ast::pat, val: ValueRef, let mut bcx = bcx; // Necessary since bind_irrefutable_pat is called outside trans_alt - alt pat.node { + match pat.node { ast::pat_ident(_, _,inner) => { if pat_is_variant(bcx.tcx().def_map, pat) { return bcx; } if make_copy { @@ -841,7 +843,7 @@ fn bind_irrefutable_pat(bcx: block, pat: @ast::pat, val: ValueRef, bcx.fcx.lllocals.insert(pat.id, local_mem(alloc)); add_clean(bcx, alloc, ty); } else { bcx.fcx.lllocals.insert(pat.id, local_mem(val)); } - alt inner { + match inner { some(pat) => { bcx = bind_irrefutable_pat(bcx, pat, val, true); } _ => () } diff --git a/src/rustc/middle/trans/base.rs b/src/rustc/middle/trans/base.rs index 6fecdead048..6e882d71c00 100644 --- a/src/rustc/middle/trans/base.rs +++ b/src/rustc/middle/trans/base.rs @@ -66,7 +66,7 @@ enum dest { } fn dest_str(ccx: @crate_ctxt, d: dest) -> ~str { - alt d { + match d { by_val(v) => fmt!{"by_val(%s)", val_str(ccx.tn, *v)}, save_in(v) => fmt!{"save_in(%s)", val_str(ccx.tn, v)}, ignore => ~"ignore" @@ -78,7 +78,7 @@ fn empty_dest_cell() -> @mut ValueRef { } fn dup_for_join(dest: dest) -> dest { - alt dest { + match dest { by_val(_) => by_val(empty_dest_cell()), _ => dest } @@ -128,7 +128,7 @@ fn join_returns(parent_cx: block, in_cxs: ~[block], if !cx.unreachable { Br(cx, out.llbb); reachable = true; - alt in_ds[i] { + match in_ds[i] { by_val(cell) => { if option::is_none(phi) { phi = some(EmptyPhi(out, val_ty(*cell))); @@ -143,7 +143,7 @@ fn join_returns(parent_cx: block, in_cxs: ~[block], if !reachable { Unreachable(out); } else { - alt out_dest { + match out_dest { by_val(cell) => *cell = option::get(phi), _ => () } @@ -153,7 +153,7 @@ fn join_returns(parent_cx: block, in_cxs: ~[block], // Used to put an immediate value in a dest. fn store_in_dest(bcx: block, val: ValueRef, dest: dest) -> block { - alt dest { + match dest { ignore => (), by_val(cell) => *cell = val, save_in(addr) => Store(bcx, val, addr) @@ -162,7 +162,7 @@ fn store_in_dest(bcx: block, val: ValueRef, dest: dest) -> block { } fn get_dest_addr(dest: dest) -> ValueRef { - alt dest { + match dest { save_in(a) => a, _ => fail ~"get_dest_addr: not a save_in" } @@ -359,7 +359,7 @@ fn malloc_raw_dyn(bcx: block, t: ty::t, heap: heap, let _icx = bcx.insn_ctxt(~"malloc_raw"); let ccx = bcx.ccx(); - let (mk_fn, rtcall) = alt heap { + let (mk_fn, rtcall) = match heap { heap_shared => (ty::mk_imm_box, ~"malloc"), heap_exchange => (ty::mk_imm_uniq, ~"exchange_malloc") }; @@ -419,7 +419,7 @@ fn get_tydesc_simple(ccx: @crate_ctxt, t: ty::t) -> ValueRef { } fn get_tydesc(ccx: @crate_ctxt, t: ty::t) -> @tydesc_info { - alt ccx.tydescs.find(t) { + match ccx.tydescs.find(t) { some(inf) => inf, _ => { ccx.stats.n_static_tydescs += 1u; @@ -454,7 +454,7 @@ fn set_inline_hint(f: ValueRef) { fn set_inline_hint_if_appr(attrs: ~[ast::attribute], llfn: ValueRef) { - alt attr::find_inline_attr(attrs) { + match attr::find_inline_attr(attrs) { attr::ia_hint => set_inline_hint(llfn), attr::ia_always => set_always_inline(llfn), attr::ia_never => set_no_inline(llfn), @@ -577,22 +577,22 @@ fn emit_tydescs(ccx: @crate_ctxt) { let glue_fn_ty = T_ptr(T_glue_fn(ccx)); let ti = val; let take_glue = - alt copy ti.take_glue { + match copy ti.take_glue { none => { ccx.stats.n_null_glues += 1u; C_null(glue_fn_ty) } some(v) => { ccx.stats.n_real_glues += 1u; v } }; let drop_glue = - alt copy ti.drop_glue { + match copy ti.drop_glue { none => { ccx.stats.n_null_glues += 1u; C_null(glue_fn_ty) } some(v) => { ccx.stats.n_real_glues += 1u; v } }; let free_glue = - alt copy ti.free_glue { + match copy ti.free_glue { none => { ccx.stats.n_null_glues += 1u; C_null(glue_fn_ty) } some(v) => { ccx.stats.n_real_glues += 1u; v } }; let visit_glue = - alt copy ti.visit_glue { + match copy ti.visit_glue { none => { ccx.stats.n_null_glues += 1u; C_null(glue_fn_ty) } some(v) => { ccx.stats.n_real_glues += 1u; v } }; @@ -623,7 +623,7 @@ fn emit_tydescs(ccx: @crate_ctxt) { fn make_take_glue(bcx: block, v: ValueRef, t: ty::t) { let _icx = bcx.insn_ctxt(~"make_take_glue"); // NB: v is a *pointer* to type t here, not a direct value. - let bcx = alt ty::get(t).struct { + let bcx = match ty::get(t).struct { ty::ty_box(_) | ty::ty_opaque_box | ty::ty_evec(_, ty::vstore_box) | ty::ty_estr(ty::vstore_box) => { incr_refcnt_of_boxed(bcx, Load(bcx, v)); bcx @@ -689,7 +689,7 @@ fn make_free_glue(bcx: block, v: ValueRef, t: ty::t) { // everything to a pointer to the type that the glue acts on). let _icx = bcx.insn_ctxt(~"make_free_glue"); let ccx = bcx.ccx(); - let bcx = alt ty::get(t).struct { + let bcx = match ty::get(t).struct { ty::ty_box(body_mt) => { let v = PointerCast(bcx, v, type_of(ccx, t)); let body = GEPi(bcx, v, ~[0u, abi::box_field_body]); @@ -770,7 +770,7 @@ fn make_drop_glue(bcx: block, v0: ValueRef, t: ty::t) { // NB: v0 is an *alias* of type t here, not a direct value. let _icx = bcx.insn_ctxt(~"make_drop_glue"); let ccx = bcx.ccx(); - let bcx = alt ty::get(t).struct { + let bcx = match ty::get(t).struct { ty::ty_box(_) | ty::ty_opaque_box | ty::ty_estr(ty::vstore_box) | ty::ty_evec(_, ty::vstore_box) => { decr_refcnt_maybe_free(bcx, Load(bcx, v0), t) @@ -784,7 +784,7 @@ fn make_drop_glue(bcx: block, v0: ValueRef, t: ty::t) { } ty::ty_class(did, substs) => { let tcx = bcx.tcx(); - alt ty::ty_dtor(tcx, did) { + match ty::ty_dtor(tcx, did) { some(dtor) => { trans_class_drop(bcx, v0, dtor, did, substs) } @@ -880,7 +880,7 @@ fn compare_scalar_types(cx: block, lhs: ValueRef, rhs: ValueRef, t: ty::t, op: ast::binop) -> result { let f = |a| compare_scalar_values(cx, lhs, rhs, a, op); - alt ty::get(t).struct { + match ty::get(t).struct { ty::ty_nil => return rslt(cx, f(nil_type)), ty::ty_bool | ty::ty_ptr(_) => return rslt(cx, f(unsigned_int)), ty::ty_int(_) => return rslt(cx, f(signed_int)), @@ -909,11 +909,11 @@ fn compare_scalar_values(cx: block, lhs: ValueRef, rhs: ValueRef, comparison operator"); } let die = fn@() -> ! { die_(cx) }; - alt nt { + match nt { nil_type => { // We don't need to do actual comparisons for nil. // () == () holds but () < () does not. - alt op { + match op { ast::eq | ast::le | ast::ge => return C_bool(true), ast::ne | ast::lt | ast::gt => return C_bool(false), // refinements would be nice @@ -921,7 +921,7 @@ fn compare_scalar_values(cx: block, lhs: ValueRef, rhs: ValueRef, } } floating_point => { - let cmp = alt op { + let cmp = match op { ast::eq => lib::llvm::RealOEQ, ast::ne => lib::llvm::RealUNE, ast::lt => lib::llvm::RealOLT, @@ -933,7 +933,7 @@ fn compare_scalar_values(cx: block, lhs: ValueRef, rhs: ValueRef, return FCmp(cx, cmp, lhs, rhs); } signed_int => { - let cmp = alt op { + let cmp = match op { ast::eq => lib::llvm::IntEQ, ast::ne => lib::llvm::IntNE, ast::lt => lib::llvm::IntSLT, @@ -945,7 +945,7 @@ fn compare_scalar_values(cx: block, lhs: ValueRef, rhs: ValueRef, return ICmp(cx, cmp, lhs, rhs); } unsigned_int => { - let cmp = alt op { + let cmp = match op { ast::eq => lib::llvm::IntEQ, ast::ne => lib::llvm::IntNE, ast::lt => lib::llvm::IntULT, @@ -985,7 +985,7 @@ fn iter_structural_ty(cx: block, av: ValueRef, t: ty::t, let fn_ty = variant.ctor_ty; let ccx = cx.ccx(); let mut cx = cx; - alt ty::get(fn_ty).struct { + match ty::get(fn_ty).struct { ty::ty_fn({inputs: args, _}) => { let mut j = 0u; let v_id = variant.id; @@ -1005,7 +1005,7 @@ fn iter_structural_ty(cx: block, av: ValueRef, t: ty::t, Typestate constraint that shows the unimpl case doesn't happen? */ let mut cx = cx; - alt ty::get(t).struct { + match ty::get(t).struct { ty::ty_rec(fields) => { for vec::eachi(fields) |i, fld| { let llfld_a = GEPi(cx, av, ~[0u, i]); @@ -1090,7 +1090,7 @@ fn lazily_emit_tydesc_glue(ccx: @crate_ctxt, field: uint, ti: @tydesc_info) { let _icx = ccx.insn_ctxt(~"lazily_emit_tydesc_glue"); if field == abi::tydesc_field_take_glue { - alt ti.take_glue { + match ti.take_glue { some(_) => (), none => { debug!{"+++ lazily_emit_tydesc_glue TAKE %s", @@ -1105,7 +1105,7 @@ fn lazily_emit_tydesc_glue(ccx: @crate_ctxt, field: uint, } } } else if field == abi::tydesc_field_drop_glue { - alt ti.drop_glue { + match ti.drop_glue { some(_) => (), none => { debug!{"+++ lazily_emit_tydesc_glue DROP %s", @@ -1120,7 +1120,7 @@ fn lazily_emit_tydesc_glue(ccx: @crate_ctxt, field: uint, } } } else if field == abi::tydesc_field_free_glue { - alt ti.free_glue { + match ti.free_glue { some(_) => (), none => { debug!{"+++ lazily_emit_tydesc_glue FREE %s", @@ -1135,7 +1135,7 @@ fn lazily_emit_tydesc_glue(ccx: @crate_ctxt, field: uint, } } } else if field == abi::tydesc_field_visit_glue { - alt ti.visit_glue { + match ti.visit_glue { some(_) => (), none => { debug!{"+++ lazily_emit_tydesc_glue VISIT %s", @@ -1159,7 +1159,7 @@ fn call_tydesc_glue_full(++cx: block, v: ValueRef, tydesc: ValueRef, if cx.unreachable { return; } let mut static_glue_fn = none; - alt static_ti { + match static_ti { none => {/* no-op */ } some(sti) => { lazily_emit_tydesc_glue(cx.ccx(), field, sti); @@ -1178,7 +1178,7 @@ fn call_tydesc_glue_full(++cx: block, v: ValueRef, tydesc: ValueRef, let llrawptr = PointerCast(cx, v, T_ptr(T_i8())); let llfn = { - alt static_glue_fn { + match static_glue_fn { none => { // Select out the glue function to call from the tydesc let llfnptr = GEPi(cx, tydesc, ~[0u, field]); @@ -1240,7 +1240,7 @@ fn drop_ty(cx: block, v: ValueRef, t: ty::t) -> block { fn drop_ty_immediate(bcx: block, v: ValueRef, t: ty::t) -> block { let _icx = bcx.insn_ctxt(~"drop_ty_immediate"); - alt ty::get(t).struct { + match ty::get(t).struct { ty::ty_uniq(_) | ty::ty_evec(_, ty::vstore_uniq) | ty::ty_estr(ty::vstore_uniq) => { @@ -1257,7 +1257,7 @@ fn drop_ty_immediate(bcx: block, v: ValueRef, t: ty::t) -> block { fn take_ty_immediate(bcx: block, v: ValueRef, t: ty::t) -> result { let _icx = bcx.insn_ctxt(~"take_ty_immediate"); - alt ty::get(t).struct { + match ty::get(t).struct { ty::ty_box(_) | ty::ty_opaque_box | ty::ty_evec(_, ty::vstore_box) | ty::ty_estr(ty::vstore_box) => { @@ -1291,7 +1291,7 @@ fn call_memmove(cx: block, dst: ValueRef, src: ValueRef, // constant element of a tydesc works). let _icx = cx.insn_ctxt(~"call_memmove"); let ccx = cx.ccx(); - let key = alt ccx.sess.targ_cfg.arch { + let key = match ccx.sess.targ_cfg.arch { session::arch_x86 | session::arch_arm => ~"llvm.memmove.p0i8.p0i8.i32", session::arch_x86_64 => ~"llvm.memmove.p0i8.p0i8.i64" }; @@ -1320,7 +1320,7 @@ enum copy_action { INIT, DROP_EXISTING, } // These are the types that are passed by pointer. fn type_is_structural_or_param(t: ty::t) -> bool { if ty::type_is_structural(t) { return true; } - alt ty::get(t).struct { + match ty::get(t).struct { ty::ty_param(*) => return true, _ => return false } @@ -1446,7 +1446,7 @@ fn trans_unary(bcx: block, op: ast::unop, e: @ast::expr, un_expr: @ast::expr, dest: dest) -> block { let _icx = bcx.insn_ctxt(~"trans_unary"); // Check for user-defined method call - alt bcx.ccx().maps.method_map.find(un_expr.id) { + match bcx.ccx().maps.method_map.find(un_expr.id) { some(mentry) => { let fty = node_id_type(bcx, un_expr.callee_id); return trans_call_inner( @@ -1461,7 +1461,7 @@ fn trans_unary(bcx: block, op: ast::unop, e: @ast::expr, if dest == ignore { return trans_expr(bcx, e, ignore); } let e_ty = expr_ty(bcx, e); - alt op { + match op { ast::not => { let {bcx, val} = trans_temp_expr(bcx, e); store_in_dest(bcx, Not(bcx, val), dest) @@ -1508,7 +1508,7 @@ fn trans_compare(cx: block, op: ast::binop, lhs: ValueRef, // Determine the operation we need. let llop = { - alt op { + match op { ast::eq | ast::ne => C_u8(abi::cmp_glue_op_eq), ast::lt | ast::ge => C_u8(abi::cmp_glue_op_lt), ast::le | ast::gt => C_u8(abi::cmp_glue_op_le), @@ -1519,7 +1519,7 @@ fn trans_compare(cx: block, op: ast::binop, lhs: ValueRef, let cmpval = call_cmp_glue(cx, lhs, rhs, rhs_t, llop); // Invert the result if necessary. - alt op { + match op { ast::eq | ast::lt | ast::le => rslt(cx, cmpval), ast::ne | ast::ge | ast::gt => rslt(cx, Not(cx, cmpval)), _ => cx.tcx().sess.bug(~"trans_compare got non-comparison-op") @@ -1571,7 +1571,7 @@ fn fail_if_zero(cx: block, span: span, divmod: ast::binop, } else { ~"modulo zero" }; - let is_zero = alt ty::get(rhs_t).struct { + let is_zero = match ty::get(rhs_t).struct { ty::ty_int(t) => { let zero = C_integral(T_int_ty(cx.ccx(), t), 0u64, False); ICmp(cx, lib::llvm::IntEQ, rhs, zero) @@ -1607,7 +1607,7 @@ fn trans_eager_binop(cx: block, span: span, op: ast::binop, lhs: ValueRef, let rhs = cast_shift_expr_rhs(cx, op, lhs, rhs); let mut cx = cx; - let val = alt op { + let val = match op { ast::add => { if is_float { FAdd(cx, lhs, rhs) } else { Add(cx, lhs, rhs) } @@ -1673,7 +1673,7 @@ fn trans_assign_op(bcx: block, ex: @ast::expr, op: ast::binop, assert (lhs_res.kind == lv_owned); // A user-defined operator method - alt bcx.ccx().maps.method_map.find(ex.id) { + match bcx.ccx().maps.method_map.find(ex.id) { some(origin) => { let bcx = lhs_res.bcx; debug!{"user-defined method callee_id: %s", @@ -1738,14 +1738,14 @@ fn autoderef(cx: block, e_id: ast::node_id, // root the autoderef'd value, if necessary: derefs += 1u; - alt ccx.maps.root_map.find({id:e_id, derefs:derefs}) { + match ccx.maps.root_map.find({id:e_id, derefs:derefs}) { none => (), some(scope_id) => { root_value(cx, v1, t1, scope_id); } } - alt ty::get(t1).struct { + match ty::get(t1).struct { ty::ty_box(mt) => { let body = GEPi(cx, v1, ~[0u, abi::box_field_body]); t1 = mt.ty; @@ -1800,7 +1800,7 @@ fn trans_lazy_binop(bcx: block, op: lazy_binop_ty, a: @ast::expr, if past_lhs.unreachable { return past_lhs; } let join = sub_block(bcx, ~"join"), before_rhs = sub_block(bcx, ~"rhs"); - alt op { + match op { lazy_and => CondBr(past_lhs, lhs, before_rhs.llbb, join.llbb), lazy_or => CondBr(past_lhs, lhs, join.llbb, before_rhs.llbb) } @@ -1821,7 +1821,7 @@ fn trans_binary(bcx: block, op: ast::binop, lhs: @ast::expr, rhs: @ast::expr, dest: dest, ex: @ast::expr) -> block { let _icx = bcx.insn_ctxt(~"trans_binary"); // User-defined operators - alt bcx.ccx().maps.method_map.find(ex.id) { + match bcx.ccx().maps.method_map.find(ex.id) { some(origin) => { let fty = node_id_type(bcx, ex.callee_id); return trans_call_inner( @@ -1836,7 +1836,7 @@ fn trans_binary(bcx: block, op: ast::binop, lhs: @ast::expr, } // First couple cases are lazy: - alt op { + match op { ast::and => { return trans_lazy_binop(bcx, lazy_and, lhs, rhs, dest); } @@ -1872,9 +1872,9 @@ fn trans_if(cx: block, cond: @ast::expr, thn: ast::blk, // because trans_expr will create another scope block // context for the block, but we've already got the // 'else' context - let else_bcx = alt els { + let else_bcx = match els { some(elexpr) => { - alt elexpr.node { + match elexpr.node { ast::expr_if(_, _, _) => { let elseif_blk = ast_util::block_from_expr(elexpr); trans_block(else_cx, elseif_blk, else_dest) @@ -1960,7 +1960,7 @@ fn lval_no_env(bcx: block, val: ValueRef, kind: lval_kind) fn trans_external_path(ccx: @crate_ctxt, did: ast::def_id, t: ty::t) -> ValueRef { let name = csearch::get_symbol(ccx.sess.cstore, did); - alt ty::get(t).struct { + match ty::get(t).struct { ty::ty_fn(_) => { let llty = type_of_fn_from_ty(ccx, t); return get_extern_fn(ccx.externs, ccx.llmod, name, @@ -1975,7 +1975,7 @@ fn trans_external_path(ccx: @crate_ctxt, did: ast::def_id, t: ty::t) fn normalize_for_monomorphization(tcx: ty::ctxt, ty: ty::t) -> option<ty::t> { // FIXME[mono] could do this recursively. is that worthwhile? (#2529) - alt ty::get(ty).struct { + match ty::get(ty).struct { ty::ty_box(mt) => { some(ty::mk_opaque_box(tcx)) } @@ -2001,14 +2001,14 @@ fn normalize_for_monomorphization(tcx: ty::ctxt, ty: ty::t) -> option<ty::t> { fn make_mono_id(ccx: @crate_ctxt, item: ast::def_id, substs: ~[ty::t], vtables: option<typeck::vtable_res>, param_uses: option<~[type_use::type_uses]>) -> mono_id { - let precise_param_ids = alt vtables { + let precise_param_ids = match vtables { some(vts) => { let bounds = ty::lookup_item_type(ccx.tcx, item).bounds; let mut i = 0u; vec::map2(*bounds, substs, |bounds, subst| { let mut v = ~[]; for vec::each(*bounds) |bound| { - alt bound { + match bound { ty::bound_trait(_) => { vec::push(v, impl::vtable_id(ccx, vts[i])); i += 1u; @@ -2023,10 +2023,10 @@ fn make_mono_id(ccx: @crate_ctxt, item: ast::def_id, substs: ~[ty::t], vec::map(substs, |subst| mono_precise(subst, none)) } }; - let param_ids = alt param_uses { + let param_ids = match param_uses { some(uses) => { vec::map2(precise_param_ids, uses, |id, uses| { - alt check id { + match check id { mono_precise(_, some(_)) => id, mono_precise(subst, none) => { if uses == 0u { mono_any } @@ -2058,7 +2058,7 @@ fn monomorphic_fn(ccx: @crate_ctxt, fn_id: ast::def_id, let _icx = ccx.insn_ctxt(~"monomorphic_fn"); let mut must_cast = false; let substs = vec::map(real_substs, |t| { - alt normalize_for_monomorphization(ccx.tcx, t) { + match normalize_for_monomorphization(ccx.tcx, t) { some(t) => { must_cast = true; t } none => t } @@ -2069,7 +2069,7 @@ fn monomorphic_fn(ccx: @crate_ctxt, fn_id: ast::def_id, let param_uses = type_use::type_uses_for(ccx, fn_id, substs.len()); let hash_id = make_mono_id(ccx, fn_id, substs, vtables, some(param_uses)); if vec::any(hash_id.params, - |p| alt p { mono_precise(_, _) => false, _ => true }) { + |p| match p { mono_precise(_, _) => false, _ => true }) { must_cast = true; } @@ -2079,7 +2079,7 @@ fn monomorphic_fn(ccx: @crate_ctxt, fn_id: ast::def_id, real_substs.map(|s| ty_to_str(ccx.tcx, s)), substs.map(|s| ty_to_str(ccx.tcx, s)), hash_id]; - alt ccx.monomorphized.find(hash_id) { + match ccx.monomorphized.find(hash_id) { some(val) => { debug!{"leaving monomorphic fn %s", ty::item_path_str(ccx.tcx, fn_id)}; @@ -2096,7 +2096,7 @@ fn monomorphic_fn(ccx: @crate_ctxt, fn_id: ast::def_id, (may have attempted to monomorphize an item defined in a different \ crate?)", fn_id}); // Get the path so that we can create a symbol - let (pt, name, span) = alt map_node { + let (pt, name, span) = match map_node { ast_map::node_item(i, pt) => (pt, i.ident, i.span), ast_map::node_variant(v, enm, pt) => (pt, v.node.name, enm.span), ast_map::node_method(m, _, pt) => (pt, m.ident, m.span), @@ -2149,7 +2149,7 @@ fn monomorphic_fn(ccx: @crate_ctxt, fn_id: ast::def_id, }; let psubsts = some({tys: substs, vtables: vtables, bounds: tpt.bounds}); - let lldecl = alt map_node { + let lldecl = match map_node { ast_map::node_item(i@@{node: ast::item_fn(decl, _, body), _}, _) => { let d = mk_lldecl(); set_inline_hint_if_appr(i.attrs, d); @@ -2195,7 +2195,7 @@ fn monomorphic_fn(ccx: @crate_ctxt, fn_id: ast::def_id, d } ast_map::node_dtor(_, dtor, _, pt) => { - let parent_id = alt ty::ty_to_def_id(ty::node_id_to_type(ccx.tcx, + let parent_id = match ty::ty_to_def_id(ty::node_id_to_type(ccx.tcx, dtor.node.self_id)) { some(did) => did, none => ccx.sess.span_bug(dtor.span, ~"Bad self ty in \ @@ -2231,7 +2231,7 @@ fn monomorphic_fn(ccx: @crate_ctxt, fn_id: ast::def_id, fn maybe_instantiate_inline(ccx: @crate_ctxt, fn_id: ast::def_id) -> ast::def_id { let _icx = ccx.insn_ctxt(~"maybe_instantiate_inline"); - alt ccx.external.find(fn_id) { + match ccx.external.find(fn_id) { some(some(node_id)) => { // Already inline debug!{"maybe_instantiate_inline(%s): already inline as node id %d", @@ -2240,7 +2240,7 @@ fn maybe_instantiate_inline(ccx: @crate_ctxt, fn_id: ast::def_id) } some(none) => fn_id, // Not inlinable none => { // Not seen yet - alt csearch::maybe_get_item_ast( + match csearch::maybe_get_item_ast( ccx.tcx, fn_id, |a,b,c,d| { astencode::decode_inlined_item(a, b, ccx.maps, c, d) @@ -2266,7 +2266,7 @@ fn maybe_instantiate_inline(ccx: @crate_ctxt, fn_id: ast::def_id) csearch::found_parent(parent_id, ast::ii_item(item)) => { ccx.external.insert(parent_id, some(item.id)); let mut my_id = 0; - alt check item.node { + match check item.node { ast::item_enum(_, _) => { let vs_here = ty::enum_variants(ccx.tcx, local_def(item.id)); let vs_there = ty::enum_variants(ccx.tcx, parent_id); @@ -2350,9 +2350,9 @@ fn lval_static_fn_inner(bcx: block, fn_id: ast::def_id, id: ast::node_id, ccx, node_id_type(bcx, id)))); } - alt ty::get(tpt.ty).struct { + match ty::get(tpt.ty).struct { ty::ty_fn(fn_ty) => { - alt fn_ty.purity { + match fn_ty.purity { ast::extern_fn => { // Extern functions are just opaque pointers let val = PointerCast(bcx, val, T_ptr(T_i8())); @@ -2369,7 +2369,7 @@ fn lval_static_fn_inner(bcx: block, fn_id: ast::def_id, id: ast::node_id, fn lookup_discriminant(ccx: @crate_ctxt, vid: ast::def_id) -> ValueRef { let _icx = ccx.insn_ctxt(~"lookup_discriminant"); - alt ccx.discrims.find(vid) { + match ccx.discrims.find(vid) { none => { // It's an external discriminant that we haven't seen yet. assert (vid.crate != ast::local_crate); @@ -2394,13 +2394,13 @@ fn trans_local_var(cx: block, def: ast::def) -> local_var_result { let _icx = cx.insn_ctxt(~"trans_local_var"); fn take_local(table: hashmap<ast::node_id, local_val>, id: ast::node_id) -> local_var_result { - alt table.find(id) { + match table.find(id) { some(local_mem(v)) => {val: v, kind: lv_owned}, some(local_imm(v)) => {val: v, kind: lv_owned_imm}, r => fail(~"take_local: internal error") } } - alt def { + match def { ast::def_upvar(nid, _, _) => { assert (cx.fcx.llupvars.contains_key(nid)); return { val: cx.fcx.llupvars.get(nid), kind: lv_owned }; @@ -2414,7 +2414,7 @@ fn trans_local_var(cx: block, def: ast::def) -> local_var_result { return take_local(cx.fcx.lllocals, nid); } ast::def_self(sid) => { - let slf = alt copy cx.fcx.llself { + let slf = match copy cx.fcx.llself { some(s) => cast_self(cx, s), none => cx.sess().bug(~"trans_local_var: reference to self \ out of context") @@ -2431,7 +2431,7 @@ fn trans_local_var(cx: block, def: ast::def) -> local_var_result { fn trans_path(cx: block, id: ast::node_id) -> lval_maybe_callee { let _icx = cx.insn_ctxt(~"trans_path"); - alt cx.tcx().def_map.find(id) { + match cx.tcx().def_map.find(id) { none => cx.sess().bug(~"trans_path: unbound node ID"), some(df) => { return trans_var(cx, df, id); @@ -2442,7 +2442,7 @@ fn trans_path(cx: block, id: ast::node_id) fn trans_var(cx: block, def: ast::def, id: ast::node_id)-> lval_maybe_callee { let _icx = cx.insn_ctxt(~"trans_var"); let ccx = cx.ccx(); - alt def { + match def { ast::def_fn(did, _) => { return lval_static_fn(cx, did, id); } @@ -2491,7 +2491,7 @@ fn trans_rec_field(bcx: block, base: @ast::expr, fn trans_rec_field_inner(bcx: block, val: ValueRef, ty: ty::t, field: ast::ident, sp: span) -> lval_result { let mut llderef = false; - let fields = alt ty::get(ty).struct { + let fields = match ty::get(ty).struct { ty::ty_rec(fs) => fs, ty::ty_class(did, substs) => { if option::is_some(ty::ty_dtor(bcx.tcx(), did)) { @@ -2583,12 +2583,12 @@ fn expr_is_lval(bcx: block, e: @ast::expr) -> bool { fn trans_callee(bcx: block, e: @ast::expr) -> lval_maybe_callee { let _icx = bcx.insn_ctxt(~"trans_callee"); - alt e.node { + match e.node { ast::expr_path(path) => return trans_path(bcx, e.id), ast::expr_field(base, _, _) => { // Lval means this is a record field, so not a method if !expr_is_lval(bcx, e) { - alt bcx.ccx().maps.method_map.find(e.id) { + match bcx.ccx().maps.method_map.find(e.id) { some(origin) => { // An impl method return impl::trans_method_callee(bcx, e.id, base, origin); } @@ -2609,7 +2609,7 @@ fn trans_callee(bcx: block, e: @ast::expr) -> lval_maybe_callee { // represented as an alloca or heap, hence needs a 'load' to be used as an // immediate). fn trans_lval(cx: block, e: @ast::expr) -> lval_result { - return alt cx.ccx().maps.root_map.find({id:e.id, derefs:0u}) { + return match cx.ccx().maps.root_map.find({id:e.id, derefs:0u}) { // No need to root this lvalue. none => unrooted(cx, e), @@ -2634,7 +2634,7 @@ fn trans_lval(cx: block, e: @ast::expr) -> lval_result { fn unrooted(cx: block, e: @ast::expr) -> lval_result { let _icx = cx.insn_ctxt(~"trans_lval"); - alt e.node { + match e.node { ast::expr_path(_) => { let v = trans_path(cx, e.id); return lval_maybe_callee_to_lval(v, e.span); @@ -2649,7 +2649,7 @@ fn trans_lval(cx: block, e: @ast::expr) -> lval_result { let ccx = cx.ccx(); let sub = trans_temp_expr(cx, base); let t = expr_ty(cx, base); - let val = alt check ty::get(t).struct { + let val = match check ty::get(t).struct { ty::ty_box(_) => { let non_gc_val = non_gc_box_cast(sub.bcx, sub.val); GEPi(sub.bcx, non_gc_val, ~[0u, abi::box_field_body]) @@ -2689,7 +2689,7 @@ fn non_gc_box_cast(cx: block, val: ValueRef) -> ValueRef { } fn lval_maybe_callee_to_lval(c: lval_maybe_callee, sp: span) -> lval_result { - alt c.env { + match c.env { self_env(*) => { c.bcx.sess().span_bug(sp, ~"implicitly binding method call"); } @@ -2732,7 +2732,7 @@ fn float_cast(bcx: block, lldsttype: TypeRef, llsrctype: TypeRef, enum cast_kind { cast_pointer, cast_integral, cast_float, cast_enum, cast_other, } fn cast_type_kind(t: ty::t) -> cast_kind { - alt ty::get(t).struct { + match ty::get(t).struct { ty::ty_float(*) => cast_float, ty::ty_ptr(*) => cast_pointer, ty::ty_rptr(*) => cast_pointer, @@ -2750,7 +2750,7 @@ fn trans_cast(cx: block, e: @ast::expr, id: ast::node_id, let _icx = cx.insn_ctxt(~"trans_cast"); let ccx = cx.ccx(); let t_out = node_id_type(cx, id); - alt ty::get(t_out).struct { + match ty::get(t_out).struct { ty::ty_trait(_, _) => return impl::trans_cast(cx, e, id, dest), _ => () } @@ -2764,7 +2764,7 @@ fn trans_cast(cx: block, e: @ast::expr, id: ast::node_id, let s_in = k_in == cast_integral && ty::type_is_signed(t_in); let newval = - alt {in: k_in, out: k_out} { + match {in: k_in, out: k_out} { {in: cast_integral, out: cast_integral} => { int_cast(e_res.bcx, ll_t_out, ll_t_in, e_res.val, s_in) } @@ -2797,7 +2797,7 @@ fn trans_cast(cx: block, e: @ast::expr, id: ast::node_id, let av_enum = PointerCast(cx, e_res.val, llenumty); let lldiscrim_a_ptr = GEPi(cx, av_enum, ~[0u, 0u]); let lldiscrim_a = Load(cx, lldiscrim_a_ptr); - alt k_out { + match k_out { cast_integral => int_cast(e_res.bcx, ll_t_out, val_ty(lldiscrim_a), lldiscrim_a, true), @@ -2812,12 +2812,12 @@ fn trans_cast(cx: block, e: @ast::expr, id: ast::node_id, fn trans_loop_body(bcx: block, e: @ast::expr, ret_flag: option<ValueRef>, dest: dest) -> block { - alt check e.node { + match check e.node { ast::expr_loop_body(b@@{ node: ast::expr_fn_block(decl, body, cap), _ }) => { - alt check ty::get(expr_ty(bcx, e)).struct { + match check ty::get(expr_ty(bcx, e)).struct { ty::ty_fn({proto, _}) => { closure::trans_expr_fn(bcx, proto, decl, body, b.id, cap, some(ret_flag), @@ -2841,9 +2841,9 @@ fn trans_arg_expr(cx: block, arg: ty::arg, lldestty: TypeRef, e: @ast::expr, let is_bot = ty::type_is_bot(e_ty); // translate the arg expr as an lvalue - let lv = alt ret_flag { + let lv = match ret_flag { // If there is a ret_flag, this *must* be a loop body - some(ptr) => alt check e.node { + some(ptr) => match check e.node { ast::expr_loop_body(blk) => { let scratch = alloc_ty(cx, expr_ty(cx, blk)); let bcx = trans_loop_body(cx, e, ret_flag, save_in(scratch)); @@ -2884,7 +2884,7 @@ fn trans_arg_expr(cx: block, arg: ty::arg, lldestty: TypeRef, e: @ast::expr, // to have type lldestty (the callee's expected type). val = llvm::LLVMGetUndef(lldestty); } else { - alt arg_mode { + match arg_mode { ast::by_ref | ast::by_mutbl_ref => { // Ensure that the value is spilled into memory: if lv.kind != lv_owned && ty::type_is_immediate(e_ty) { @@ -2949,7 +2949,7 @@ fn adapt_borrowed_value(lv: lval_result, return {lv:lv, ty:e_ty}; } - alt ty::get(e_ty).struct { + match ty::get(e_ty).struct { ty::ty_uniq(mt) | ty::ty_box(mt) => { let box_ptr = load_value_from_lval_result(lv, e_ty); let body_ptr = GEPi(bcx, box_ptr, ~[0u, abi::box_field_body]); @@ -2959,7 +2959,7 @@ fn adapt_borrowed_value(lv: lval_result, ty::ty_estr(_) | ty::ty_evec(_, _) => { let ccx = bcx.ccx(); - let val = alt lv.kind { + let val = match lv.kind { lv_temporary => lv.val, lv_owned => load_if_immediate(bcx, lv.val, e_ty), lv_owned_imm => lv.val @@ -3019,7 +3019,7 @@ fn trans_args(cx: block, llenv: ValueRef, args: call_args, fn_ty: ty::t, let retty = ty::ty_fn_ret(fn_ty); // Arg 0: Output pointer. - let llretslot = alt dest { + let llretslot = match dest { ignore => { if ty::type_is_nil(retty) { llvm::LLVMGetUndef(T_ptr(T_nil())) @@ -3039,7 +3039,7 @@ fn trans_args(cx: block, llenv: ValueRef, args: call_args, fn_ty: ty::t, // First we figure out the caller's view of the types of the arguments. // This will be needed if this is a generic call, because the callee has // to cast her view of the arguments to the caller's view. - alt args { + match args { arg_exprs(es) => { let llarg_tys = type_of_explicit_args(ccx, arg_tys); let last = es.len() - 1u; @@ -3083,7 +3083,7 @@ fn body_contains_ret(body: ast::blk) -> bool { visit_item: |_i, _cx, _v| { }, visit_expr: |e: @ast::expr, cx: {mut found: bool}, v| { if !cx.found { - alt e.node { + match e.node { ast::expr_ret(_) => cx.found = true, _ => visit::visit_expr(e, cx, v), } @@ -3104,9 +3104,9 @@ fn trans_call_inner( dest: dest) -> block { do with_scope(in_cx, call_info, ~"call") |cx| { - let ret_in_loop = alt args { + let ret_in_loop = match args { arg_exprs(args) => { - args.len() > 0u && alt vec::last(args).node { + args.len() > 0u && match vec::last(args).node { ast::expr_loop_body(@{ node: ast::expr_fn_block(_, body, _), _ @@ -3127,7 +3127,7 @@ fn trans_call_inner( } else { none }; let mut faddr = f_res.val; - let llenv = alt f_res.env { + let llenv = match f_res.env { null_env => { llvm::LLVMGetUndef(T_opaque_box_ptr(ccx)) } @@ -3160,7 +3160,7 @@ fn trans_call_inner( type _|_. Since that means it diverges, the code for the call itself is unreachable. */ bcx = invoke(bcx, faddr, llargs); - alt dest { + match dest { ignore => { if llvm::LLVMIsUndef(llretslot) != lib::llvm::True { bcx = drop_ty(bcx, llretslot, ret_ty); @@ -3220,10 +3220,10 @@ fn need_invoke(bcx: block) -> bool { // Walk the scopes to look for cleanups let mut cur = bcx; loop { - alt cur.kind { + match cur.kind { block_scope(inf) => { for vec::each(inf.cleanups) |cleanup| { - alt cleanup { + match cleanup { clean(_, cleanup_type) | clean_temp(_, _, cleanup_type) => { if cleanup_type == normal_exit_and_unwind { return true; @@ -3234,7 +3234,7 @@ fn need_invoke(bcx: block) -> bool { } _ => () } - cur = alt cur.parent { + cur = match cur.parent { some(next) => next, none => return false } @@ -3244,7 +3244,7 @@ fn need_invoke(bcx: block) -> bool { fn have_cached_lpad(bcx: block) -> bool { let mut res = false; do in_lpad_scope_cx(bcx) |inf| { - alt inf.landing_pad { + match inf.landing_pad { some(_) => res = true, none => res = false } @@ -3255,7 +3255,7 @@ fn have_cached_lpad(bcx: block) -> bool { fn in_lpad_scope_cx(bcx: block, f: fn(scope_info)) { let mut bcx = bcx; loop { - alt bcx.kind { + match bcx.kind { block_scope(inf) => { if inf.cleanups.len() > 0u || is_none(bcx.parent) { f(inf); return; @@ -3273,7 +3273,7 @@ fn get_landing_pad(bcx: block) -> BasicBlockRef { let mut cached = none, pad_bcx = bcx; // Guaranteed to be set below do in_lpad_scope_cx(bcx) |inf| { // If there is a valid landing pad still around, use it - alt copy inf.landing_pad { + match copy inf.landing_pad { some(target) => cached = some(target), none => { pad_bcx = lpad_block(bcx, ~"unwind"); @@ -3282,7 +3282,7 @@ fn get_landing_pad(bcx: block) -> BasicBlockRef { } } // Can't return from block above - alt cached { some(b) => return b, none => () } + match cached { some(b) => return b, none => () } // The landing pad return type (the type being propagated). Not sure what // this represents but it's determined by the personality function and // this is what the EH proposal example uses. @@ -3303,7 +3303,7 @@ fn get_landing_pad(bcx: block) -> BasicBlockRef { // We store the retval in a function-central alloca, so that calls to // Resume can find it. - alt copy bcx.fcx.personality { + match copy bcx.fcx.personality { some(addr) => Store(pad_bcx, llretval, addr), none => { let addr = alloca(pad_bcx, val_ty(llretval)); @@ -3320,7 +3320,7 @@ fn get_landing_pad(bcx: block) -> BasicBlockRef { fn trans_tup(bcx: block, elts: ~[@ast::expr], dest: dest) -> block { let _icx = bcx.insn_ctxt(~"trans_tup"); let mut bcx = bcx; - let addr = alt dest { + let addr = match dest { ignore => { for vec::each(elts) |ex| { bcx = trans_expr(bcx, ex, ignore); } return bcx; @@ -3346,7 +3346,7 @@ fn trans_rec(bcx: block, fields: ~[ast::field], let _icx = bcx.insn_ctxt(~"trans_rec"); let t = node_id_type(bcx, id); let mut bcx = bcx; - let addr = alt check dest { + let addr = match check dest { ignore => { for vec::each(fields) |fld| { bcx = trans_expr(bcx, fld.node.expr, ignore); @@ -3356,7 +3356,7 @@ fn trans_rec(bcx: block, fields: ~[ast::field], save_in(pos) => pos }; - let ty_fields = alt check ty::get(t).struct { ty::ty_rec(f) => f }; + let ty_fields = match check ty::get(t).struct { ty::ty_rec(f) => f }; let mut temp_cleanups = ~[]; for fields.each |fld| { @@ -3368,7 +3368,7 @@ fn trans_rec(bcx: block, fields: ~[ast::field], add_clean_temp_mem(bcx, dst, ty_fields[ix].mt.ty); vec::push(temp_cleanups, dst); } - alt base { + match base { some(bexp) => { let {bcx: cx, val: base_val} = trans_temp_expr(bcx, bexp); bcx = cx; @@ -3404,7 +3404,7 @@ fn trans_struct(block_context: block, span: span, fields: ~[ast::field], // Get the address to store the structure into. If there is no address, // just translate each field and be done with it. let dest_address; - alt dest { + match dest { ignore => { for fields.each |field| { block_context = trans_expr(block_context, @@ -3423,7 +3423,7 @@ fn trans_struct(block_context: block, span: span, fields: ~[ast::field], // Get the class ID and its fields. let class_fields, class_id, substitutions; - alt ty::get(struct_type).struct { + match ty::get(struct_type).struct { ty::ty_class(existing_class_id, existing_substitutions) => { class_id = existing_class_id; substitutions = existing_substitutions; @@ -3458,7 +3458,7 @@ fn trans_struct(block_context: block, span: span, fields: ~[ast::field], } let index, field_id; - alt found { + match found { some((found_index, found_field_id)) => { index = found_index; field_id = found_field_id; @@ -3571,7 +3571,7 @@ fn trans_temp_expr(bcx: block, e: @ast::expr) -> result { } fn load_value_from_lval_result(lv: lval_result, ty: ty::t) -> ValueRef { - alt lv.kind { + match lv.kind { lv_temporary => lv.val, lv_owned => load_if_immediate(lv.bcx, lv.val, ty), lv_owned_imm => lv.val @@ -3606,12 +3606,12 @@ fn add_root_cleanup(bcx: block, scope_id: ast::node_id, fn find_bcx_for_scope(bcx: block, scope_id: ast::node_id) -> block { let mut bcx_sid = bcx; loop { - bcx_sid = alt bcx_sid.node_info { + bcx_sid = match bcx_sid.node_info { some({id, _}) if id == scope_id => { return bcx_sid } _ => { - alt bcx_sid.parent { + match bcx_sid.parent { none => bcx.tcx().sess.bug( fmt!{"no enclosing scope with id %d", scope_id}), some(bcx_par) => bcx_par @@ -3634,7 +3634,7 @@ fn trans_expr(bcx: block, e: @ast::expr, dest: dest) -> block { return lval_to_dps(bcx, e, dest); } - return alt bcx.ccx().maps.root_map.find({id:e.id, derefs:0u}) { + return match bcx.ccx().maps.root_map.find({id:e.id, derefs:0u}) { none => unrooted(bcx, e, dest), some(scope_id) => { debug!{"expression %d found in root map with scope %d", @@ -3658,7 +3658,7 @@ fn trans_expr(bcx: block, e: @ast::expr, dest: dest) -> block { fn unrooted(bcx: block, e: @ast::expr, dest: dest) -> block { let tcx = bcx.tcx(); - alt e.node { + match e.node { ast::expr_if(cond, thn, els) => { return trans_if(bcx, cond, thn, els, dest); } @@ -3703,7 +3703,7 @@ fn trans_expr(bcx: block, e: @ast::expr, dest: dest) -> block { cap_clause, none, dest); } ast::expr_fn_block(decl, body, cap_clause) => { - alt check ty::get(expr_ty(bcx, e)).struct { + match check ty::get(expr_ty(bcx, e)).struct { ty::ty_fn({proto, _}) => { debug!{"translating fn_block %s with type %s", expr_to_str(e), @@ -3841,7 +3841,7 @@ fn lval_result_to_dps(lv: lval_result, ty: ty::t, last_use: bool, dest: dest) -> block { let mut {bcx, val, kind} = lv; let ccx = bcx.ccx(); - alt dest { + match dest { by_val(cell) => { if kind == lv_temporary { revoke_clean(bcx, val); @@ -3909,7 +3909,7 @@ fn trans_log(log_ex: @ast::expr, lvl: @ast::expr, let modpath = vec::append( ~[path_mod(ccx.link_meta.name)], vec::filter(bcx.fcx.path, |e| - alt e { path_mod(_) => true, _ => false } + match e { path_mod(_) => true, _ => false } )); let modname = path_str(modpath); @@ -3967,7 +3967,7 @@ fn trans_fail_expr(bcx: block, sp_opt: option<span>, fail_expr: option<@ast::expr>) -> block { let _icx = bcx.insn_ctxt(~"trans_fail_expr"); let mut bcx = bcx; - alt fail_expr { + match fail_expr { some(expr) => { let ccx = bcx.ccx(), tcx = ccx.tcx; let expr_res = trans_temp_expr(bcx, expr); @@ -3995,7 +3995,7 @@ fn trans_trace(bcx: block, sp_opt: option<span>, trace_str: ~str) { let _icx = bcx.insn_ctxt(~"trans_trace"); add_comment(bcx, trace_str); let V_trace_str = C_cstr(bcx.ccx(), trace_str); - let {V_filename, V_line} = alt sp_opt { + let {V_filename, V_line} = match sp_opt { some(sp) => { let sess = bcx.sess(); let loc = codemap::lookup_char_pos(sess.parse_sess.cm, sp.lo); @@ -4025,7 +4025,7 @@ fn trans_fail_value(bcx: block, sp_opt: option<span>, V_fail_str: ValueRef) -> block { let _icx = bcx.insn_ctxt(~"trans_fail_value"); let ccx = bcx.ccx(); - let {V_filename, V_line} = alt sp_opt { + let {V_filename, V_line} = match sp_opt { some(sp) => { let sess = bcx.sess(); let loc = codemap::lookup_char_pos(sess.parse_sess.cm, sp.lo); @@ -4067,7 +4067,7 @@ fn trans_break_cont(bcx: block, to_end: bool) let mut unwind = bcx; let mut target; loop { - alt unwind.kind { + match unwind.kind { block_scope({loop_break: some(brk), _}) => { target = if to_end { brk @@ -4078,7 +4078,7 @@ fn trans_break_cont(bcx: block, to_end: bool) } _ => () } - unwind = alt unwind.parent { + unwind = match unwind.parent { some(cx) => cx, // This is a return from a loop body block none => { @@ -4105,14 +4105,14 @@ fn trans_cont(cx: block) -> block { fn trans_ret(bcx: block, e: option<@ast::expr>) -> block { let _icx = bcx.insn_ctxt(~"trans_ret"); let mut bcx = bcx; - let retptr = alt copy bcx.fcx.loop_ret { + let retptr = match copy bcx.fcx.loop_ret { some({flagptr, retptr}) => { // This is a loop body return. Must set continue flag (our retptr) // to false, return flag to true, and then store the value in the // parent's retptr. Store(bcx, C_bool(true), flagptr); Store(bcx, C_bool(false), bcx.fcx.llretptr); - alt e { + match e { some(x) => PointerCast(bcx, retptr, T_ptr(type_of(bcx.ccx(), expr_ty(bcx, x)))), none => retptr @@ -4120,7 +4120,7 @@ fn trans_ret(bcx: block, e: option<@ast::expr>) -> block { } none => bcx.fcx.llretptr }; - alt e { + match e { some(x) => { bcx = trans_expr_save_in(bcx, x, retptr); } @@ -4139,7 +4139,7 @@ fn build_return(bcx: block) { fn init_local(bcx: block, local: @ast::local) -> block { let _icx = bcx.insn_ctxt(~"init_local"); let ty = node_id_type(bcx, local.node.id); - let llptr = alt bcx.fcx.lllocals.find(local.node.id) { + let llptr = match bcx.fcx.lllocals.find(local.node.id) { some(local_mem(v)) => v, _ => { bcx.tcx().sess.span_bug(local.span, ~"init_local: Someone forgot to document why it's\ @@ -4148,7 +4148,7 @@ fn init_local(bcx: block, local: @ast::local) -> block { }; let mut bcx = bcx; - alt local.node.init { + match local.node.init { some(init) => { if init.op == ast::init_assign || !expr_is_lval(bcx, init.expr) { bcx = trans_expr_save_in(bcx, init.expr, llptr); @@ -4175,12 +4175,12 @@ fn trans_stmt(cx: block, s: ast::stmt) -> block { let mut bcx = cx; debuginfo::update_source_pos(cx, s.span); - alt s.node { + match s.node { ast::stmt_expr(e, _) | ast::stmt_semi(e, _) => { bcx = trans_expr(cx, e, ignore); } ast::stmt_decl(d, _) => { - alt d.node { + match d.node { ast::decl_local(locals) => { for vec::each(locals) |local| { bcx = init_local(bcx, local); @@ -4275,11 +4275,11 @@ fn trans_block_cleanups_(bcx: block, cleanup_cx: block, is_lpad: bool) -> let _icx = bcx.insn_ctxt(~"trans_block_cleanups"); if bcx.unreachable { return bcx; } let mut bcx = bcx; - alt check cleanup_cx.kind { + match check cleanup_cx.kind { block_scope({cleanups, _}) => { let cleanups = copy cleanups; do vec::riter(cleanups) |cu| { - alt cu { + match cu { clean(cfn, cleanup_type) | clean_temp(_, cfn, cleanup_type) => { // Some types don't need to be cleaned up during // landing pads because they can be freed en mass later @@ -4311,7 +4311,7 @@ fn cleanup_and_leave(bcx: block, upto: option<BasicBlockRef>, fmt!{"cleanup_and_leave(%s)", cur.to_str()}); } - alt cur.kind { + match cur.kind { block_scope(inf) if inf.cleanups.len() > 0u => { for vec::find(inf.cleanup_paths, |cp| cp.target == leave).each |cp| { @@ -4325,16 +4325,16 @@ fn cleanup_and_leave(bcx: block, upto: option<BasicBlockRef>, } _ => () } - alt upto { + match upto { some(bb) => { if cur.llbb == bb { break; } } _ => () } - cur = alt cur.parent { + cur = match cur.parent { some(next) => next, none => { assert is_none(upto); break; } }; } - alt leave { + match leave { some(target) => Br(bcx, target), none => { Resume(bcx, Load(bcx, option::get(bcx.fcx.personality))); } } @@ -4383,9 +4383,9 @@ fn with_cond(bcx: block, val: ValueRef, f: fn(block) -> block) -> block { fn block_locals(b: ast::blk, it: fn(@ast::local)) { for vec::each(b.node.stmts) |s| { - alt s.node { + match s.node { ast::stmt_decl(d, _) => { - alt d.node { + match d.node { ast::decl_local(locals) => { for vec::each(locals) |local| { it(local); } } @@ -4410,7 +4410,7 @@ fn alloc_ty(bcx: block, t: ty::t) -> ValueRef { fn alloc_local(cx: block, local: @ast::local) -> block { let _icx = cx.insn_ctxt(~"alloc_local"); let t = node_id_type(cx, local.node.id); - let simple_name = alt local.node.pat.node { + let simple_name = match local.node.pat.node { ast::pat_ident(_, pth, none) => some(path_to_ident(pth)), _ => none }; @@ -4435,7 +4435,7 @@ fn trans_block(bcx: block, b: ast::blk, dest: dest) debuginfo::update_source_pos(bcx, b.span); bcx = trans_stmt(bcx, *s); } - alt b.node.expr { + match b.node.expr { some(e) => { let bt = ty::type_is_bot(expr_ty(bcx, e)); debuginfo::update_source_pos(bcx, e.span); @@ -4513,7 +4513,7 @@ fn create_llargs_for_fn_args(cx: fn_ctxt, let _icx = cx.insn_ctxt(~"create_llargs_for_fn_args"); // Skip the implicit arguments 0, and 1. let mut arg_n = first_real_arg; - alt ty_self { + match ty_self { impl_self(tt) => { cx.llself = some({v: cx.llenv, t: tt}); } @@ -4544,11 +4544,11 @@ fn copy_args_to_allocas(fcx: fn_ctxt, bcx: block, args: ~[ast::arg], }; for vec::each(arg_tys) |arg| { let id = args[arg_n].id; - let argval = alt fcx.llargs.get(id) { + let argval = match fcx.llargs.get(id) { local_mem(v) => v, _ => epic_fail() }; - alt ty::resolved_mode(tcx, arg.mode) { + match ty::resolved_mode(tcx, arg.mode) { ast::by_mutbl_ref => (), ast::by_move | ast::by_copy => add_clean(bcx, argval, arg.ty), ast::by_val => { @@ -4682,7 +4682,7 @@ fn trans_enum_variant(ccx: @crate_ctxt, enum_id: ast::node_id, let fcx = new_fn_ctxt_w_id(ccx, ~[], llfndecl, variant.node.id, param_substs, none); create_llargs_for_fn_args(fcx, no_self, fn_args); - let ty_param_substs = alt param_substs { + let ty_param_substs = match param_substs { some(substs) => substs.tys, none => ~[] }; @@ -4708,7 +4708,7 @@ fn trans_enum_variant(ccx: @crate_ctxt, enum_id: ast::node_id, // If this argument to this function is a enum, it'll have come in to // this function as an opaque blob due to the way that type_of() // works. So we have to cast to the destination's view of the type. - let llarg = alt check fcx.llargs.find(va.id) { + let llarg = match check fcx.llargs.find(va.id) { some(local_mem(x)) => x }; let arg_ty = arg_tys[i].ty; @@ -4824,10 +4824,10 @@ fn trans_class_dtor(ccx: @crate_ctxt, path: path, fn trans_item(ccx: @crate_ctxt, item: ast::item) { let _icx = ccx.insn_ctxt(~"trans_item"); - let path = alt check ccx.tcx.items.get(item.id) { + let path = match check ccx.tcx.items.get(item.id) { ast_map::node_item(_, p) => p }; - alt item.node { + match item.node { ast::item_fn(decl, tps, body) => { if decl.purity == ast::extern_fn { let llfndecl = get_item_val(ccx, item.id); @@ -4843,7 +4843,7 @@ fn trans_item(ccx: @crate_ctxt, item: ast::item) { decl, body, llfndecl, no_self, none, item.id); } else { for vec::each(body.node.stmts) |stmt| { - alt stmt.node { + match stmt.node { ast::stmt_decl(@{node: ast::decl_item(i), _}, _) => { trans_item(ccx, *i); } @@ -4876,7 +4876,7 @@ fn trans_item(ccx: @crate_ctxt, item: ast::item) { } ast::item_const(_, expr) => consts::trans_const(ccx, expr, item.id), ast::item_foreign_mod(foreign_mod) => { - let abi = alt attr::foreign_abi(item.attrs) { + let abi = match attr::foreign_abi(item.attrs) { either::right(abi_) => abi_, either::left(msg) => ccx.sess.span_fatal(item.span, msg) }; @@ -4961,7 +4961,7 @@ fn create_main_wrapper(ccx: @crate_ctxt, sp: span, main_llfn: ValueRef, let main_takes_argv = // invariant! - alt ty::get(main_node_type).struct { + match ty::get(main_node_type).struct { ty::ty_fn({inputs, _}) => inputs.len() != 0u, _ => ccx.sess.span_fatal(sp, ~"main has a non-function type") }; @@ -5050,7 +5050,7 @@ fn fill_fn_pair(bcx: block, pair: ValueRef, llfn: ValueRef, fn item_path(ccx: @crate_ctxt, i: @ast::item) -> path { vec::append( - *alt check ccx.tcx.items.get(i.id) { + *match check ccx.tcx.items.get(i.id) { ast_map::node_item(_, p) => p }, ~[path_name(i.ident)]) @@ -5061,7 +5061,7 @@ fn item_path(ccx: @crate_ctxt, i: @ast::item) -> path { fn get_dtor_symbol(ccx: @crate_ctxt, path: path, id: ast::node_id, substs: option<param_substs>) -> ~str { let t = ty::node_id_to_type(ccx.tcx, id); - alt ccx.item_symbols.find(id) { + match ccx.item_symbols.find(id) { some(s) => s, none if is_none(substs) => { let s = mangle_exported_name( @@ -5074,7 +5074,7 @@ fn get_dtor_symbol(ccx: @crate_ctxt, path: path, id: ast::node_id, none => { // Monomorphizing, so just make a symbol, don't add // this to item_symbols - alt substs { + match substs { some(ss) => { let mono_ty = ty::subst_tps(ccx.tcx, ss.tys, t); mangle_exported_name( @@ -5094,14 +5094,14 @@ fn get_dtor_symbol(ccx: @crate_ctxt, path: path, id: ast::node_id, fn get_item_val(ccx: @crate_ctxt, id: ast::node_id) -> ValueRef { let tcx = ccx.tcx; - alt ccx.item_vals.find(id) { + match ccx.item_vals.find(id) { some(v) => v, none => { let mut exprt = false; - let val = alt check ccx.tcx.items.get(id) { + let val = match check ccx.tcx.items.get(id) { ast_map::node_item(i, pth) => { let my_path = vec::append(*pth, ~[path_name(i.ident)]); - alt check i.node { + match check i.node { ast::item_const(_, _) => { let typ = ty::node_id_to_type(ccx.tcx, i.id); let s = mangle_exported_name(ccx, my_path, typ); @@ -5167,7 +5167,7 @@ fn get_item_val(ccx: @crate_ctxt, id: ast::node_id) -> ValueRef { let pth = vec::append(*pth, ~[path_name(enm.ident), path_name(v.node.name)]); - let llfn = alt check enm.node { + let llfn = match check enm.node { ast::item_enum(_, _) => { register_fn(ccx, v.span, pth, id) } @@ -5188,7 +5188,7 @@ fn get_item_val(ccx: @crate_ctxt, id: ast::node_id) -> ValueRef { // The constant translation pass. fn trans_constant(ccx: @crate_ctxt, it: @ast::item) { let _icx = ccx.insn_ctxt(~"trans_constant"); - alt it.node { + match it.node { ast::item_enum(variants, _) => { let vi = ty::enum_variants(ccx.tcx, {crate: ast::local_crate, node: it.id}); @@ -5294,7 +5294,7 @@ fn declare_dbg_intrinsics(llmod: ModuleRef, fn trap(bcx: block) { let v: ~[ValueRef] = ~[]; - alt bcx.ccx().intrinsics.find(~"llvm.trap") { + match bcx.ccx().intrinsics.find(~"llvm.trap") { some(x) => { Call(bcx, x, v); }, _ => bcx.sess().bug(~"unbound llvm.trap in trap") } @@ -5309,12 +5309,12 @@ fn push_rtcall(ccx: @crate_ctxt, name: ~str, did: ast::def_id) { fn gather_local_rtcalls(ccx: @crate_ctxt, crate: @ast::crate) { visit::visit_crate(*crate, (), visit::mk_simple_visitor(@{ - visit_item: |item| alt item.node { + visit_item: |item| match item.node { ast::item_fn(decl, _, _) => { let attr_metas = attr::attr_metas( attr::find_attrs_by_name(item.attrs, ~"rt")); do vec::iter(attr_metas) |attr_meta| { - alt attr::get_meta_item_list(attr_meta) { + match attr::get_meta_item_list(attr_meta) { some(list) => { let name = *attr::get_meta_item_name(vec::head(list)); push_rtcall(ccx, name, {crate: ast::local_crate, @@ -5334,9 +5334,9 @@ fn gather_external_rtcalls(ccx: @crate_ctxt) { do cstore::iter_crate_data(ccx.sess.cstore) |_cnum, cmeta| { do decoder::each_path(cmeta) |path| { let pathname = path.path_string; - alt path.def_like { + match path.def_like { decoder::dl_def(d) => { - alt d { + match d { ast::def_fn(did, _) => { // FIXME (#2861): This should really iterate attributes // like gather_local_rtcalls, but we'll need to @@ -5462,7 +5462,7 @@ fn crate_ctxt_to_encode_parms(cx: @crate_ctxt) for cx.exp_map.each |exp_id, defs| { for defs.each |def| { if !def.reexp { again; } - let path = alt check cx.tcx.items.get(exp_id) { + let path = match check cx.tcx.items.get(exp_id) { ast_map::node_export(_, path) => { ast_map::path_to_str(*path) } diff --git a/src/rustc/middle/trans/build.rs b/src/rustc/middle/trans/build.rs index 6e7c41e0fa9..d6083a3c564 100644 --- a/src/rustc/middle/trans/build.rs +++ b/src/rustc/middle/trans/build.rs @@ -49,7 +49,7 @@ fn count_insn(cx: block, category: ~str) { s += ~"/"; s += category; - let n = alt h.find(s) { + let n = match h.find(s) { some(n) => n, _ => 0u }; diff --git a/src/rustc/middle/trans/closure.rs b/src/rustc/middle/trans/closure.rs index 1912c509693..752ce97427c 100644 --- a/src/rustc/middle/trans/closure.rs +++ b/src/rustc/middle/trans/closure.rs @@ -101,7 +101,7 @@ enum environment_value { } fn ev_to_str(ccx: @crate_ctxt, ev: environment_value) -> ~str { - alt ev { + match ev { env_copy(v, t, lk) => fmt!{"copy(%s,%s)", val_str(ccx.tn, v), ty_to_str(ccx.tcx, t)}, env_move(v, t, lk) => fmt!{"move(%s,%s)", val_str(ccx.tn, v), @@ -124,7 +124,7 @@ fn mk_closure_tys(tcx: ty::ctxt, // Compute the closed over data for vec::each(bound_values) |bv| { - vec::push(bound_tys, alt bv { + vec::push(bound_tys, match bv { env_copy(_, t, _) => t, env_move(_, t, _) => t, env_ref(_, t, _) => t @@ -153,7 +153,7 @@ fn allocate_cbox(bcx: block, } // Allocate and initialize the box: - let {bcx, val} = alt ck { + let {bcx, val} = match ck { ty::ck_box => malloc_raw(bcx, cdata_ty, heap_shared), ty::ck_uniq => malloc_raw(bcx, cdata_ty, heap_exchange), ty::ck_block => { @@ -211,7 +211,7 @@ fn store_environment(bcx: block, let bound_data = GEPi(bcx, llbox, ~[0u, abi::box_field_body, i]); - alt bv { + match bv { env_copy(val, ty, lv_owned) => { let val1 = load_if_immediate(bcx, val, ty); bcx = base::copy_val(bcx, INIT, bound_data, val1, ty); @@ -267,14 +267,14 @@ fn build_closure(bcx0: block, debug!{"Node id is %s", syntax::ast_map::node_id_to_str(bcx.ccx().tcx.items, nid)}; let mut ty = node_id_type(bcx, nid); - alt cap_var.mode { + match cap_var.mode { capture::cap_ref => { assert ck == ty::ck_block; ty = ty::mk_mut_ptr(tcx, ty); vec::push(env_vals, env_ref(lv.val, ty, lv.kind)); } capture::cap_copy => { - let mv = alt check ccx.maps.last_use_map.find(id) { + let mv = match check ccx.maps.last_use_map.find(id) { none => false, some(vars) => (*vars).contains(nid) }; @@ -292,7 +292,7 @@ fn build_closure(bcx0: block, } } do option::iter(include_ret_handle) |flagptr| { - let our_ret = alt bcx.fcx.loop_ret { + let our_ret = match bcx.fcx.loop_ret { some({retptr, _}) => retptr, none => bcx.fcx.llretptr }; @@ -323,12 +323,12 @@ fn load_environment(fcx: fn_ctxt, // Populate the upvars from the environment. let mut i = 0u; do vec::iter(cap_vars) |cap_var| { - alt cap_var.mode { + match cap_var.mode { capture::cap_drop => { /* ignore */ } _ => { let mut upvarptr = GEPi(bcx, llcdata, ~[0u, i]); - alt ck { + match ck { ty::ck_block => { upvarptr = Load(bcx, upvarptr); } ty::ck_uniq | ty::ck_box => () } @@ -368,7 +368,7 @@ fn trans_expr_fn(bcx: block, let trans_closure_env = fn@(ck: ty::closure_kind) -> result { let cap_vars = capture::compute_capture_vars( ccx.tcx, id, proto, cap_clause); - let ret_handle = alt is_loop_body { some(x) => x, none => none }; + let ret_handle = match is_loop_body { some(x) => x, none => none }; let {llbox, cdata_ty, bcx} = build_closure(bcx, cap_vars, ck, id, ret_handle); trans_closure(ccx, sub_path, decl, body, llfn, no_self, @@ -383,7 +383,7 @@ fn trans_expr_fn(bcx: block, {bcx: bcx, val: llbox} }; - let {bcx: bcx, val: closure} = alt proto { + let {bcx: bcx, val: closure} = match proto { ast::proto_block => trans_closure_env(ty::ck_block), ast::proto_box => trans_closure_env(ty::ck_box), ast::proto_uniq => trans_closure_env(ty::ck_uniq), @@ -417,7 +417,7 @@ fn make_fn_glue( } }; - return alt ty::get(t).struct { + return match ty::get(t).struct { ty::ty_fn({proto: ast::proto_bare, _}) | ty::ty_fn({proto: ast::proto_block, _}) => bcx, ty::ty_fn({proto: ast::proto_uniq, _}) => fn_env(ty::ck_uniq), @@ -433,7 +433,7 @@ fn make_opaque_cbox_take_glue( -> block { // Easy cases: let _icx = bcx.insn_ctxt(~"closure::make_opaque_cbox_take_glue"); - alt ck { + match ck { ty::ck_block => return bcx, ty::ck_box => { incr_refcnt_of_boxed(bcx, Load(bcx, cboxptr)); @@ -485,7 +485,7 @@ fn make_opaque_cbox_drop_glue( cboxptr: ValueRef) // ptr to the opaque closure -> block { let _icx = bcx.insn_ctxt(~"closure::make_opaque_cbox_drop_glue"); - alt ck { + match ck { ty::ck_block => bcx, ty::ck_box => { decr_refcnt_maybe_free(bcx, Load(bcx, cboxptr), @@ -504,7 +504,7 @@ fn make_opaque_cbox_free_glue( cbox: ValueRef) // ptr to the opaque closure -> block { let _icx = bcx.insn_ctxt(~"closure::make_opaque_cbox_free_glue"); - alt ck { + match ck { ty::ck_block => return bcx, ty::ck_box | ty::ck_uniq => { /* hard cases: */ } } @@ -524,7 +524,7 @@ fn make_opaque_cbox_free_glue( abi::tydesc_field_drop_glue, none); // Free the ty descr (if necc) and the box itself - alt ck { + match ck { ty::ck_block => fail ~"Impossible", ty::ck_box => trans_free(bcx, cbox), ty::ck_uniq => trans_unique_free(bcx, cbox) diff --git a/src/rustc/middle/trans/common.rs b/src/rustc/middle/trans/common.rs index 99fd0c8b7bc..7e48297f12e 100644 --- a/src/rustc/middle/trans/common.rs +++ b/src/rustc/middle/trans/common.rs @@ -292,7 +292,7 @@ fn add_clean_temp_mem(cx: block, val: ValueRef, ty: ty::t) { } } fn add_clean_free(cx: block, ptr: ValueRef, heap: heap) { - let free_fn = alt heap { + let free_fn = match heap { heap_shared => |a| base::trans_free(a, ptr), heap_exchange => |a| base::trans_unique_free(a, ptr) }; @@ -310,7 +310,7 @@ fn add_clean_free(cx: block, ptr: ValueRef, heap: heap) { fn revoke_clean(cx: block, val: ValueRef) { do in_scope_cx(cx) |info| { do option::iter(vec::position(info.cleanups, |cu| { - alt cu { + match cu { clean_temp(v, _, _) if v == val => true, _ => false } @@ -453,7 +453,7 @@ fn struct_elt(llstructty: TypeRef, n: uint) -> TypeRef unsafe { fn in_scope_cx(cx: block, f: fn(scope_info)) { let mut cur = cx; loop { - alt cur.kind { + match cur.kind { block_scope(inf) => { f(inf); return; } _ => () } @@ -462,7 +462,7 @@ fn in_scope_cx(cx: block, f: fn(scope_info)) { } fn block_parent(cx: block) -> block { - alt cx.parent { + match cx.parent { some(b) => b, none => cx.sess().bug(fmt!{"block_parent called on root block %?", cx}) @@ -483,7 +483,7 @@ impl bcx_cxs for block { ty_to_str(self.tcx(), t) } fn to_str() -> ~str { - alt self.node_info { + match self.node_info { some(node_info) => { fmt!{"[block %d]", node_info.id} } @@ -535,7 +535,7 @@ fn T_f64() -> TypeRef { return llvm::LLVMDoubleType(); } fn T_bool() -> TypeRef { return T_i1(); } fn T_int(targ_cfg: @session::config) -> TypeRef { - return alt targ_cfg.arch { + return match targ_cfg.arch { session::arch_x86 => T_i32(), session::arch_x86_64 => T_i64(), session::arch_arm => T_i32() @@ -543,7 +543,7 @@ fn T_int(targ_cfg: @session::config) -> TypeRef { } fn T_int_ty(cx: @crate_ctxt, t: ast::int_ty) -> TypeRef { - alt t { + match t { ast::ty_i => cx.int_type, ast::ty_char => T_char(), ast::ty_i8 => T_i8(), @@ -554,7 +554,7 @@ fn T_int_ty(cx: @crate_ctxt, t: ast::int_ty) -> TypeRef { } fn T_uint_ty(cx: @crate_ctxt, t: ast::uint_ty) -> TypeRef { - alt t { + match t { ast::ty_u => cx.int_type, ast::ty_u8 => T_i8(), ast::ty_u16 => T_i16(), @@ -564,7 +564,7 @@ fn T_uint_ty(cx: @crate_ctxt, t: ast::uint_ty) -> TypeRef { } fn T_float_ty(cx: @crate_ctxt, t: ast::float_ty) -> TypeRef { - alt t { + match t { ast::ty_f => cx.float_type, ast::ty_f32 => T_f32(), ast::ty_f64 => T_f64() @@ -572,7 +572,7 @@ fn T_float_ty(cx: @crate_ctxt, t: ast::float_ty) -> TypeRef { } fn T_float(targ_cfg: @session::config) -> TypeRef { - return alt targ_cfg.arch { + return match targ_cfg.arch { session::arch_x86 => T_f64(), session::arch_x86_64 => T_f64(), session::arch_arm => T_f64() @@ -657,7 +657,7 @@ fn T_tydesc_field(cx: @crate_ctxt, field: uint) -> TypeRef unsafe { fn T_glue_fn(cx: @crate_ctxt) -> TypeRef { let s = ~"glue_fn"; - alt name_has_type(cx.tn, s) { + match name_has_type(cx.tn, s) { some(t) => return t, _ => () } @@ -764,7 +764,7 @@ fn T_taskptr(cx: @crate_ctxt) -> TypeRef { return T_ptr(cx.task_type); } // This type must never be used directly; it must always be cast away. fn T_typaram(tn: type_names) -> TypeRef { let s = ~"typaram"; - alt name_has_type(tn, s) { + match name_has_type(tn, s) { some(t) => return t, _ => () } @@ -787,7 +787,7 @@ fn T_enum_discrim(cx: @crate_ctxt) -> TypeRef { fn T_opaque_enum(cx: @crate_ctxt) -> TypeRef { let s = ~"opaque_enum"; - alt name_has_type(cx.tn, s) { + match name_has_type(cx.tn, s) { some(t) => return t, _ => () } @@ -856,7 +856,7 @@ fn C_u8(i: uint) -> ValueRef { return C_integral(T_i8(), i as u64, False); } // This is a 'c-like' raw string, which differs from // our boxed-and-length-annotated strings. fn C_cstr(cx: @crate_ctxt, s: ~str) -> ValueRef { - alt cx.const_cstr_cache.find(s) { + match cx.const_cstr_cache.find(s) { some(llval) => return llval, none => () } @@ -942,7 +942,7 @@ type mono_id = @{def: ast::def_id, params: ~[mono_param_id]}; pure fn hash_mono_id(mi: &mono_id) -> uint { let mut h = syntax::ast_util::hash_def(&mi.def); for vec::each(mi.params) |param| { - h = h * alt param { + h = h * match param { mono_precise(ty, vts) => { let mut h = ty::type_id(ty); do option::iter(vts) |vts| { @@ -978,7 +978,7 @@ fn align_to(cx: block, off: ValueRef, align: ValueRef) -> ValueRef { fn path_str(p: path) -> ~str { let mut r = ~"", first = true; for vec::each(p) |e| { - alt e { ast_map::path_name(s) | ast_map::path_mod(s) => { + match e { ast_map::path_name(s) | ast_map::path_mod(s) => { if first { first = false; } else { r += ~"::"; } r += *s; @@ -990,7 +990,7 @@ fn path_str(p: path) -> ~str { fn node_id_type(bcx: block, id: ast::node_id) -> ty::t { let tcx = bcx.tcx(); let t = ty::node_id_to_type(tcx, id); - alt bcx.fcx.param_substs { + match bcx.fcx.param_substs { some(substs) => ty::subst_tps(tcx, substs.tys, t), _ => { assert !ty::type_has_params(t); t } } @@ -1001,7 +1001,7 @@ fn expr_ty(bcx: block, ex: @ast::expr) -> ty::t { fn node_id_type_params(bcx: block, id: ast::node_id) -> ~[ty::t] { let tcx = bcx.tcx(); let params = ty::node_id_to_type_params(tcx, id); - alt bcx.fcx.param_substs { + match bcx.fcx.param_substs { some(substs) => { vec::map(params, |t| ty::subst_tps(tcx, substs.tys, t)) } @@ -1012,7 +1012,7 @@ fn node_id_type_params(bcx: block, id: ast::node_id) -> ~[ty::t] { fn field_idx_strict(cx: ty::ctxt, sp: span, ident: ast::ident, fields: ~[ty::field]) -> uint { - alt ty::field_idx(ident, fields) { + match ty::field_idx(ident, fields) { none => cx.sess.span_bug( sp, fmt!{"base expr doesn't appear to \ have a field named %s", *ident}), diff --git a/src/rustc/middle/trans/consts.rs b/src/rustc/middle/trans/consts.rs index d0a448da5b2..49ea20c6e85 100644 --- a/src/rustc/middle/trans/consts.rs +++ b/src/rustc/middle/trans/consts.rs @@ -5,12 +5,12 @@ import base::get_insn_ctxt; fn const_lit(cx: @crate_ctxt, e: @ast::expr, lit: ast::lit) -> ValueRef { let _icx = cx.insn_ctxt(~"trans_lit"); - alt lit.node { + match lit.node { ast::lit_int(i, t) => C_integral(T_int_ty(cx, t), i as u64, True), ast::lit_uint(u, t) => C_integral(T_uint_ty(cx, t), u, False), ast::lit_int_unsuffixed(i) => { let lit_int_ty = ty::node_id_to_type(cx.tcx, e.id); - alt ty::get(lit_int_ty).struct { + match ty::get(lit_int_ty).struct { ty::ty_int(t) => { C_integral(T_int_ty(cx, t), i as u64, True) } @@ -45,7 +45,7 @@ fn const_vec_and_sz(cx: @crate_ctxt, e: @ast::expr, es: &[@ast::expr]) fn const_expr(cx: @crate_ctxt, e: @ast::expr) -> ValueRef { let _icx = cx.insn_ctxt(~"const_expr"); - alt e.node { + match e.node { ast::expr_lit(lit) => consts::const_lit(cx, e, *lit), ast::expr_binary(b, e1, e2) => { let te1 = const_expr(cx, e1); @@ -58,7 +58,7 @@ fn const_expr(cx: @crate_ctxt, e: @ast::expr) -> ValueRef { let ty = ty::expr_ty(cx.tcx, e1); let is_float = ty::type_is_fp(ty); let signed = ty::type_is_signed(ty); - return alt b { + return match b { ast::add => { if is_float { llvm::LLVMConstFAdd(te1, te2) } else { llvm::LLVMConstAdd(te1, te2) } @@ -103,7 +103,7 @@ fn const_expr(cx: @crate_ctxt, e: @ast::expr) -> ValueRef { let te = const_expr(cx, e); let ty = ty::expr_ty(cx.tcx, e); let is_float = ty::type_is_fp(ty); - return alt u { + return match u { ast::box(_) | ast::uniq(_) | ast::deref => cx.sess.span_bug(e.span, @@ -119,7 +119,9 @@ fn const_expr(cx: @crate_ctxt, e: @ast::expr) -> ValueRef { let ety = ty::expr_ty(cx.tcx, e), llty = type_of::type_of(cx, ety); let basety = ty::expr_ty(cx.tcx, base); let v = const_expr(cx, base); - alt check (base::cast_type_kind(basety), base::cast_type_kind(ety)) { + match check (base::cast_type_kind(basety), + base::cast_type_kind(ety)) { + (base::cast_integral, base::cast_integral) => { let s = if ty::type_is_signed(basety) { True } else { False }; llvm::LLVMConstIntCast(v, llty, s) @@ -162,9 +164,9 @@ fn const_expr(cx: @crate_ctxt, e: @ast::expr) -> ValueRef { const_expr(cx, e) } ast::expr_vstore(sub, ast::vstore_slice(_)) => { - alt sub.node { + match sub.node { ast::expr_lit(lit) => { - alt lit.node { + match lit.node { ast::lit_str(*) => { const_expr(cx, sub) } _ => { cx.sess.span_bug(e.span, ~"bad const-slice lit") } @@ -186,11 +188,11 @@ fn const_expr(cx: @crate_ctxt, e: @ast::expr) -> ValueRef { } } ast::expr_path(path) => { - alt cx.tcx.def_map.find(e.id) { + match cx.tcx.def_map.find(e.id) { some(ast::def_const(def_id)) => { // Don't know how to handle external consts assert ast_util::is_local(def_id); - alt cx.tcx.items.get(def_id.node) { + match cx.tcx.items.get(def_id.node) { ast_map::node_item(@{ node: ast::item_const(_, subexpr), _ }, _) => { diff --git a/src/rustc/middle/trans/debuginfo.rs b/src/rustc/middle/trans/debuginfo.rs index 30300550c31..1a207a5313c 100644 --- a/src/rustc/middle/trans/debuginfo.rs +++ b/src/rustc/middle/trans/debuginfo.rs @@ -134,7 +134,7 @@ fn cast_safely<T: copy, U>(val: T) -> U unsafe { } fn md_from_metadata<T>(val: debug_metadata) -> T unsafe { - alt val { + match val { file_metadata(md) => cast_safely(md), compile_unit_metadata(md) => cast_safely(md), subprogram_metadata(md) => cast_safely(md), @@ -165,7 +165,7 @@ fn create_compile_unit(cx: @crate_ctxt) let cache = get_cache(cx); let crate_name = option::get(cx.dbg_cx).crate_file; let tg = CompileUnitTag; - alt cached_metadata::<@metadata<compile_unit_md>>(cache, tg, + match cached_metadata::<@metadata<compile_unit_md>>(cache, tg, |md| md.data.name == crate_name) { option::some(md) => return md, option::none => () @@ -208,7 +208,7 @@ fn get_file_path_and_dir(work_dir: ~str, full_path: ~str) -> (~str, ~str) { fn create_file(cx: @crate_ctxt, full_path: ~str) -> @metadata<file_md> { let cache = get_cache(cx);; let tg = FileDescriptorTag; - alt cached_metadata::<@metadata<file_md>>( + match cached_metadata::<@metadata<file_md>>( cache, tg, |md| md.data.path == full_path) { option::some(md) => return md, option::none => () @@ -235,7 +235,7 @@ fn create_block(cx: block) -> @metadata<block_md> { let cache = get_cache(cx.ccx()); let mut cx = cx; while option::is_none(cx.node_info) { - alt cx.parent { + match cx.parent { some(b) => cx = b, none => fail } @@ -253,12 +253,12 @@ fn create_block(cx: block) -> @metadata<block_md> { option::none {} }*/ - let parent = alt cx.parent { + let parent = match cx.parent { none => create_function(cx.fcx).node, some(bcx) => create_block(bcx).node }; let file_node = create_file(cx.ccx(), fname); - let unique_id = alt cache.find(LexicalBlockTag) { + let unique_id = match cache.find(LexicalBlockTag) { option::some(v) => vec::len(v) as int, option::none => 0 }; @@ -285,15 +285,15 @@ fn create_basic_type(cx: @crate_ctxt, t: ty::t, ty: ast::prim_ty, span: span) -> @metadata<tydesc_md> { let cache = get_cache(cx); let tg = BasicTypeDescriptorTag; - alt cached_metadata::<@metadata<tydesc_md>>( + match cached_metadata::<@metadata<tydesc_md>>( cache, tg, |md| ty::type_id(t) == md.data.hash) { option::some(md) => return md, option::none => () } - let (name, encoding) = alt check ty { + let (name, encoding) = match check ty { ast::ty_bool => (~"bool", DW_ATE_boolean), - ast::ty_int(m) => alt m { + ast::ty_int(m) => match m { ast::ty_char => (~"char", DW_ATE_unsigned), ast::ty_i => (~"int", DW_ATE_signed), ast::ty_i8 => (~"i8", DW_ATE_signed_char), @@ -301,14 +301,14 @@ fn create_basic_type(cx: @crate_ctxt, t: ty::t, ty: ast::prim_ty, span: span) ast::ty_i32 => (~"i32", DW_ATE_signed), ast::ty_i64 => (~"i64", DW_ATE_signed) } - ast::ty_uint(m) => alt m { + ast::ty_uint(m) => match m { ast::ty_u => (~"uint", DW_ATE_unsigned), ast::ty_u8 => (~"u8", DW_ATE_unsigned_char), ast::ty_u16 => (~"u16", DW_ATE_unsigned), ast::ty_u32 => (~"u32", DW_ATE_unsigned), ast::ty_u64 => (~"u64", DW_ATE_unsigned) } - ast::ty_float(m) => alt m { + ast::ty_float(m) => match m { ast::ty_f => (~"float", DW_ATE_float), ast::ty_f32 => (~"f32", DW_ATE_float), ast::ty_f64 => (~"f64", DW_ATE_float) @@ -341,7 +341,7 @@ fn create_pointer_type(cx: @crate_ctxt, t: ty::t, span: span, -> @metadata<tydesc_md> { let tg = PointerTypeTag; /*let cache = cx.llmetadata; - alt cached_metadata::<@metadata<tydesc_md>>( + match cached_metadata::<@metadata<tydesc_md>>( cache, tg, {|md| ty::hash_ty(t) == ty::hash_ty(md.data.hash)}) { option::some(md) { return md; } option::none {} @@ -434,7 +434,7 @@ fn create_boxed_type(cx: @crate_ctxt, outer: ty::t, _inner: ty::t, -> @metadata<tydesc_md> { //let tg = StructureTypeTag; /*let cache = cx.llmetadata; - alt cached_metadata::<@metadata<tydesc_md>>( + match cached_metadata::<@metadata<tydesc_md>>( cache, tg, {|md| ty::hash_ty(outer) == ty::hash_ty(md.data.hash)}) { option::some(md) { return md; } option::none {} @@ -516,7 +516,7 @@ fn create_vec(cx: @crate_ctxt, vec_t: ty::t, elem_t: ty::t, fn create_ty(_cx: @crate_ctxt, _t: ty::t, _ty: @ast::ty) -> @metadata<tydesc_md> { /*let cache = get_cache(cx); - alt cached_metadata::<@metadata<tydesc_md>>( + match cached_metadata::<@metadata<tydesc_md>>( cache, tg, {|md| t == md.data.hash}) { option::some(md) { return md; } option::none {} @@ -536,7 +536,7 @@ fn create_ty(_cx: @crate_ctxt, _t: ty::t, _ty: @ast::ty) fail; /* fn t_to_ty(cx: crate_ctxt, t: ty::t, span: span) -> @ast::ty { - let ty = alt ty::get(t).struct { + let ty = match ty::get(t).struct { ty::ty_nil { ast::ty_nil } ty::ty_bot { ast::ty_bot } ty::ty_bool { ast::ty_bool } @@ -566,9 +566,9 @@ fn create_ty(_cx: @crate_ctxt, _t: ty::t, _ty: @ast::ty) return @{node: ty, span: span}; } - alt ty.node { + match ty.node { ast::ty_box(mt) { - let inner_t = alt ty::get(t).struct { + let inner_t = match ty::get(t).struct { ty::ty_box(boxed) { boxed.ty } _ { cx.sess.span_bug(ty.span, "t_to_ty was incoherent"); } }; @@ -578,7 +578,7 @@ fn create_ty(_cx: @crate_ctxt, _t: ty::t, _ty: @ast::ty) } ast::ty_uniq(mt) { - let inner_t = alt ty::get(t).struct { + let inner_t = match ty::get(t).struct { ty::ty_uniq(boxed) { boxed.ty } // Hoping we'll have a way to eliminate this check soon. _ { cx.sess.span_bug(ty.span, "t_to_ty was incoherent"); } @@ -604,7 +604,7 @@ fn create_ty(_cx: @crate_ctxt, _t: ty::t, _ty: @ast::ty) } ast::ty_path(_, id) { - alt cx.tcx.def_map.get(id) { + match cx.tcx.def_map.get(id) { ast::def_prim_ty(pty) { return create_basic_type(cx, t, pty, ty.span); } @@ -639,13 +639,13 @@ fn create_local_var(bcx: block, local: @ast::local) let cx = bcx.ccx(); let cache = get_cache(cx); let tg = AutoVariableTag; - alt cached_metadata::<@metadata<local_var_md>>( + match cached_metadata::<@metadata<local_var_md>>( cache, tg, |md| md.data.id == local.node.id) { option::some(md) => return md, option::none => () } - let name = alt local.node.pat.node { + let name = match local.node.pat.node { ast::pat_ident(_, pth, _) => ast_util::path_to_ident(pth), // FIXME this should be handled (#2533) _ => fail ~"no single variable name for local" @@ -655,7 +655,7 @@ fn create_local_var(bcx: block, local: @ast::local) let ty = node_id_type(bcx, local.node.id); let tymd = create_ty(cx, ty, local.node.ty); let filemd = create_file(cx, loc.file.name); - let context = alt bcx.parent { + let context = match bcx.parent { none => create_function(bcx.fcx).node, some(_) => create_block(bcx).node }; @@ -664,14 +664,14 @@ fn create_local_var(bcx: block, local: @ast::local) let mdval = @{node: mdnode, data: {id: local.node.id}}; update_cache(cache, AutoVariableTag, local_var_metadata(mdval)); - let llptr = alt bcx.fcx.lllocals.find(local.node.id) { + let llptr = match bcx.fcx.lllocals.find(local.node.id) { option::some(local_mem(v)) => v, option::some(_) => { bcx.tcx().sess.span_bug(local.span, ~"local is bound to \ something weird"); } option::none => { - alt bcx.fcx.lllocals.get(local.node.pat.id) { + match bcx.fcx.lllocals.get(local.node.pat.id) { local_imm(v) => v, _ => bcx.tcx().sess.span_bug(local.span, ~"local is bound to \ something weird") @@ -689,7 +689,7 @@ fn create_arg(bcx: block, arg: ast::arg, sp: span) let fcx = bcx.fcx, cx = fcx.ccx; let cache = get_cache(cx); let tg = ArgVariableTag; - alt cached_metadata::<@metadata<argument_md>>( + match cached_metadata::<@metadata<argument_md>>( cache, ArgVariableTag, |md| md.data.id == arg.id) { option::some(md) => return md, option::none => () @@ -706,7 +706,7 @@ fn create_arg(bcx: block, arg: ast::arg, sp: span) let mdval = @{node: mdnode, data: {id: arg.id}}; update_cache(cache, tg, argument_metadata(mdval)); - let llptr = alt fcx.llargs.get(arg.id) { + let llptr = match fcx.llargs.get(arg.id) { local_mem(v) | local_imm(v) => v, }; let declargs = ~[llmdnode(~[llptr]), mdnode]; @@ -740,9 +740,9 @@ fn create_function(fcx: fn_ctxt) -> @metadata<subprogram_md> { let sp = option::get(fcx.span); log(debug, codemap::span_to_str(sp, cx.sess.codemap)); - let (ident, ret_ty, id) = alt cx.tcx.items.get(fcx.id) { + let (ident, ret_ty, id) = match cx.tcx.items.get(fcx.id) { ast_map::node_item(item, _) => { - alt item.node { + match item.node { ast::item_fn(decl, _, _) => { (item.ident, decl.output, item.id) } @@ -758,7 +758,7 @@ fn create_function(fcx: fn_ctxt) -> @metadata<subprogram_md> { (nm, ctor.node.dec.output, ctor.node.id) } ast_map::node_expr(expr) => { - alt expr.node { + match expr.node { ast::expr_fn(_, decl, _, _) => { (@dbg_cx.names(~"fn"), decl.output, expr.id) } @@ -778,7 +778,7 @@ fn create_function(fcx: fn_ctxt) -> @metadata<subprogram_md> { log(debug, id); let cache = get_cache(cx); - alt cached_metadata::<@metadata<subprogram_md>>( + match cached_metadata::<@metadata<subprogram_md>>( cache, SubprogramTag, |md| md.data.id == id) { option::some(md) => return md, option::none => () @@ -788,7 +788,7 @@ fn create_function(fcx: fn_ctxt) -> @metadata<subprogram_md> { sp.lo); let file_node = create_file(cx, loc.file.name).node; let ty_node = if cx.sess.opts.extra_debuginfo { - alt ret_ty.node { + match ret_ty.node { ast::ty_nil => llnull(), _ => create_ty(cx, ty::node_id_to_type(cx.tcx, id), ret_ty).node } diff --git a/src/rustc/middle/trans/foreign.rs b/src/rustc/middle/trans/foreign.rs index 56f8892ff37..1555f2df89a 100644 --- a/src/rustc/middle/trans/foreign.rs +++ b/src/rustc/middle/trans/foreign.rs @@ -38,7 +38,7 @@ enum x86_64_reg_class { } fn is_sse(++c: x86_64_reg_class) -> bool { - return alt c { + return match c { sse_fs_class | sse_fv_class | sse_ds_class | sse_dv_class => true, _ => false @@ -73,7 +73,7 @@ fn classify_ty(ty: TypeRef) -> ~[x86_64_reg_class] { } fn ty_align(ty: TypeRef) -> uint { - return alt llvm::LLVMGetTypeKind(ty) as int { + return match llvm::LLVMGetTypeKind(ty) as int { 8 /* integer */ => { ((llvm::LLVMGetIntTypeWidth(ty) as uint) + 7u) / 8u } @@ -94,7 +94,7 @@ fn classify_ty(ty: TypeRef) -> ~[x86_64_reg_class] { } fn ty_size(ty: TypeRef) -> uint { - return alt llvm::LLVMGetTypeKind(ty) as int { + return match llvm::LLVMGetTypeKind(ty) as int { 8 /* integer */ => { ((llvm::LLVMGetIntTypeWidth(ty) as uint) + 7u) / 8u } @@ -179,7 +179,7 @@ fn classify_ty(ty: TypeRef) -> ~[x86_64_reg_class] { return; } - alt llvm::LLVMGetTypeKind(ty) as int { + match llvm::LLVMGetTypeKind(ty) as int { 8 /* integer */ | 12 /* pointer */ => { unify(cls, ix + off / 8u, integer_class); @@ -285,7 +285,7 @@ fn llreg_ty(cls: ~[x86_64_reg_class]) -> TypeRef { let mut i = 0u; let e = vec::len(cls); while i < e { - alt cls[i] { + match cls[i] { integer_class => { vec::push(tys, T_i64()); } @@ -326,7 +326,7 @@ fn x86_64_tys(atys: ~[TypeRef], rty: TypeRef, ret_def: bool) -> x86_64_tys { fn is_reg_ty(ty: TypeRef) -> bool { - return alt llvm::LLVMGetTypeKind(ty) as int { + return match llvm::LLVMGetTypeKind(ty) as int { 8 /* integer */ | 12 /* pointer */ | 2 /* float */ | @@ -401,7 +401,7 @@ fn decl_x86_64_fn(tys: x86_64_tys, let llfn = decl(fnty); do vec::iteri(tys.attrs) |i, a| { - alt a { + match a { option::some(attr) => { let llarg = get_param(llfn, i); llvm::LLVMAddAttribute(llarg, attr as c_uint); @@ -413,7 +413,7 @@ fn decl_x86_64_fn(tys: x86_64_tys, } fn link_name(i: @ast::foreign_item) -> ~str { - alt attr::first_attr_value_str_by_name(i.attrs, ~"link_name") { + match attr::first_attr_value_str_by_name(i.attrs, ~"link_name") { none => return *i.ident, option::some(ln) => return *ln } @@ -430,7 +430,7 @@ type c_stack_tys = { fn c_arg_and_ret_lltys(ccx: @crate_ctxt, id: ast::node_id) -> (~[TypeRef], TypeRef, ty::t) { - alt ty::get(ty::node_id_to_type(ccx.tcx, id)).struct { + match ty::get(ty::node_id_to_type(ccx.tcx, id)).struct { ty::ty_fn({inputs: arg_tys, output: ret_ty, _}) => { let llargtys = type_of_explicit_args(ccx, arg_tys); let llretty = type_of::type_of(ccx, ret_ty); @@ -587,7 +587,7 @@ fn trans_foreign_mod(ccx: @crate_ctxt, let mut i = 0u; let n = vec::len(tys.arg_tys); - alt tys.x86_64_tys { + match tys.x86_64_tys { some(x86_64) => { let mut atys = x86_64.arg_tys; let mut attrs = x86_64.attrs; @@ -629,10 +629,10 @@ fn trans_foreign_mod(ccx: @crate_ctxt, fn build_ret(bcx: block, tys: @c_stack_tys, llargbundle: ValueRef, llretval: ValueRef) { let _icx = bcx.insn_ctxt(~"foreign::shim::build_ret"); - alt tys.x86_64_tys { + match tys.x86_64_tys { some(x86_64) => { do vec::iteri(x86_64.attrs) |i, a| { - alt a { + match a { some(attr) => { llvm::LLVMAddInstrAttribute( llretval, (i + 1u) as c_uint, @@ -680,7 +680,7 @@ fn trans_foreign_mod(ccx: @crate_ctxt, fn base_fn(ccx: @crate_ctxt, lname: ~str, tys: @c_stack_tys, cc: lib::llvm::CallConv) -> ValueRef { // Declare the "prototype" for the base function F: - alt tys.x86_64_tys { + match tys.x86_64_tys { some(x86_64) => { do decl_x86_64_fn(x86_64) |fnty| { decl_fn(ccx.llmod, lname, cc, fnty) @@ -747,14 +747,14 @@ fn trans_foreign_mod(ccx: @crate_ctxt, build_args, build_ret); } - let mut cc = alt abi { + let mut cc = match abi { ast::foreign_abi_rust_intrinsic | ast::foreign_abi_cdecl => lib::llvm::CCallConv, ast::foreign_abi_stdcall => lib::llvm::X86StdcallCallConv }; for vec::each(foreign_mod.items) |foreign_item| { - alt foreign_item.node { + match foreign_item.node { ast::foreign_item_fn(fn_decl, typarams) => { let id = foreign_item.id; if abi != ast::foreign_abi_rust_intrinsic { @@ -772,7 +772,7 @@ fn trans_foreign_mod(ccx: @crate_ctxt, // monomorphic_fn, but ones without are emitted here if typarams.is_empty() { let llwrapfn = get_item_val(ccx, id); - let path = alt ccx.tcx.items.find(id) { + let path = match ccx.tcx.items.find(id) { some(ast_map::node_foreign_item(_, _, pt)) => pt, _ => { ccx.sess.span_bug(foreign_item.span, @@ -799,7 +799,7 @@ fn trans_intrinsic(ccx: @crate_ctxt, decl: ValueRef, item: @ast::foreign_item, let fcx = new_fn_ctxt_w_id(ccx, path, decl, item.id, some(substs), some(item.span)); let mut bcx = top_scope_block(fcx, none), lltop = bcx.llbb; - alt check *item.ident { + match check *item.ident { ~"atomic_xchng" => { let old = AtomicRMW(bcx, Xchg, get_param(decl, first_real_arg), @@ -925,7 +925,7 @@ fn trans_intrinsic(ccx: @crate_ctxt, decl: ValueRef, item: @ast::foreign_item, let tp_sz = shape::llsize_of_real(ccx, lltp_ty), out_sz = shape::llsize_of_real(ccx, llout_ty); if tp_sz != out_sz { - let sp = alt check ccx.tcx.items.get(option::get(ref_id)) { + let sp = match check ccx.tcx.items.get(option::get(ref_id)) { ast_map::node_expr(e) => e.span }; ccx.sess.span_fatal( @@ -1045,7 +1045,7 @@ fn trans_foreign_fn(ccx: @crate_ctxt, path: ast_map::path, decl: ast::fn_decl, fn build_args(bcx: block, tys: @c_stack_tys, llwrapfn: ValueRef, llargbundle: ValueRef) { let _icx = bcx.insn_ctxt(~"foreign::foreign::wrap::build_args"); - alt tys.x86_64_tys { + match tys.x86_64_tys { option::some(x86_64) => { let mut atys = x86_64.arg_tys; let mut attrs = x86_64.attrs; @@ -1099,7 +1099,7 @@ fn trans_foreign_fn(ccx: @crate_ctxt, path: ast_map::path, decl: ast::fn_decl, fn build_ret(bcx: block, tys: @c_stack_tys, llargbundle: ValueRef) { let _icx = bcx.insn_ctxt(~"foreign::foreign::wrap::build_ret"); - alt tys.x86_64_tys { + match tys.x86_64_tys { option::some(x86_64) => { if x86_64.sret || !tys.ret_def { RetVoid(bcx); @@ -1161,11 +1161,11 @@ fn register_foreign_fn(ccx: @crate_ctxt, sp: span, fn abi_of_foreign_fn(ccx: @crate_ctxt, i: @ast::foreign_item) -> ast::foreign_abi { - alt attr::first_attr_value_str_by_name(i.attrs, ~"abi") { - none => alt check ccx.tcx.items.get(i.id) { + match attr::first_attr_value_str_by_name(i.attrs, ~"abi") { + none => match check ccx.tcx.items.get(i.id) { ast_map::node_foreign_item(_, abi, _) => abi } - some(_) => alt attr::foreign_abi(i.attrs) { + some(_) => match attr::foreign_abi(i.attrs) { either::right(abi) => abi, either::left(msg) => ccx.sess.span_fatal(i.span, msg) } diff --git a/src/rustc/middle/trans/impl.rs b/src/rustc/middle/trans/impl.rs index 434707f3fa8..979bb6e847a 100644 --- a/src/rustc/middle/trans/impl.rs +++ b/src/rustc/middle/trans/impl.rs @@ -52,7 +52,7 @@ fn trans_method_callee(bcx: block, callee_id: ast::node_id, self: @ast::expr, mentry: typeck::method_map_entry) -> lval_maybe_callee { let _icx = bcx.insn_ctxt(~"impl::trans_method_callee"); - alt mentry.origin { + match mentry.origin { typeck::method_static(did) => { let {bcx, val} = trans_self_arg(bcx, self, mentry.derefs); {env: self_env(val, node_id_type(bcx, self.id), none) @@ -60,7 +60,7 @@ fn trans_method_callee(bcx: block, callee_id: ast::node_id, } typeck::method_param({trait_id:iid, method_num:off, param_num:p, bound_num:b}) => { - alt check bcx.fcx.param_substs { + match check bcx.fcx.param_substs { some(substs) => { trans_monomorphized_callee(bcx, callee_id, self, mentry.derefs, iid, off, p, b, substs) @@ -83,7 +83,7 @@ fn method_from_methods(ms: ~[@ast::method], name: ast::ident) fn method_with_name(ccx: @crate_ctxt, impl_id: ast::def_id, name: ast::ident) -> ast::def_id { if impl_id.crate == ast::local_crate { - alt check ccx.tcx.items.get(impl_id.node) { + match check ccx.tcx.items.get(impl_id.node) { ast_map::node_item(@{node: ast::item_impl(_, _, _, ms), _}, _) => { method_from_methods(ms, name) } @@ -101,7 +101,7 @@ fn method_with_name(ccx: @crate_ctxt, impl_id: ast::def_id, fn method_ty_param_count(ccx: @crate_ctxt, m_id: ast::def_id, i_id: ast::def_id) -> uint { if m_id.crate == ast::local_crate { - alt check ccx.tcx.items.get(m_id.node) { + match check ccx.tcx.items.get(m_id.node) { ast_map::node_method(m, _, _) => vec::len(m.tps), } } else { @@ -116,7 +116,7 @@ fn trans_monomorphized_callee(bcx: block, callee_id: ast::node_id, n_param: uint, n_bound: uint, substs: param_substs) -> lval_maybe_callee { let _icx = bcx.insn_ctxt(~"impl::trans_monomorphized_callee"); - alt find_vtable_in_fn_ctxt(substs, n_param, n_bound) { + match find_vtable_in_fn_ctxt(substs, n_param, n_bound) { typeck::vtable_static(impl_did, impl_substs, sub_origins) => { let ccx = bcx.ccx(); let mname = ty::trait_methods(ccx.tcx, trait_id)[n_method].ident; @@ -173,7 +173,7 @@ fn find_vtable_in_fn_ctxt(ps: param_substs, n_param: uint, n_bound: uint) for vec::each(*ps.bounds) |bounds| { if i >= n_param { break; } for vec::each(*bounds) |bound| { - alt bound { ty::bound_trait(_) => vtable_off += 1u, _ => () } + match bound { ty::bound_trait(_) => vtable_off += 1u, _ => () } } i += 1u; } @@ -189,9 +189,9 @@ fn resolve_vtables_in_fn_ctxt(fcx: fn_ctxt, vts: typeck::vtable_res) // eliminate any vtable_params. fn resolve_vtable_in_fn_ctxt(fcx: fn_ctxt, vt: typeck::vtable_origin) -> typeck::vtable_origin { - alt vt { + match vt { typeck::vtable_static(iid, tys, sub) => { - let tys = alt fcx.param_substs { + let tys = match fcx.param_substs { some(substs) => { vec::map(tys, |t| ty::subst_tps(fcx.ccx.tcx, substs.tys, t)) } @@ -200,7 +200,7 @@ fn resolve_vtable_in_fn_ctxt(fcx: fn_ctxt, vt: typeck::vtable_origin) typeck::vtable_static(iid, tys, resolve_vtables_in_fn_ctxt(fcx, sub)) } typeck::vtable_param(n_param, n_bound) => { - alt check fcx.param_substs { + match check fcx.param_substs { some(substs) => { find_vtable_in_fn_ctxt(substs, n_param, n_bound) } @@ -211,7 +211,7 @@ fn resolve_vtable_in_fn_ctxt(fcx: fn_ctxt, vt: typeck::vtable_origin) } fn vtable_id(ccx: @crate_ctxt, origin: typeck::vtable_origin) -> mono_id { - alt check origin { + match check origin { typeck::vtable_static(impl_id, substs, sub_vtables) => { make_mono_id(ccx, impl_id, substs, if (*sub_vtables).len() == 0u { none } @@ -227,9 +227,9 @@ fn vtable_id(ccx: @crate_ctxt, origin: typeck::vtable_origin) -> mono_id { fn get_vtable(ccx: @crate_ctxt, origin: typeck::vtable_origin) -> ValueRef { let hash_id = vtable_id(ccx, origin); - alt ccx.vtables.find(hash_id) { + match ccx.vtables.find(hash_id) { some(val) => val, - none => alt check origin { + none => match check origin { typeck::vtable_static(id, substs, sub_vtables) => { make_impl_vtable(ccx, id, substs, sub_vtables) } diff --git a/src/rustc/middle/trans/reachable.rs b/src/rustc/middle/trans/reachable.rs index b149857ffaa..9637b5b7ce5 100644 --- a/src/rustc/middle/trans/reachable.rs +++ b/src/rustc/middle/trans/reachable.rs @@ -34,11 +34,11 @@ fn find_reachable(crate_mod: _mod, exp_map: resolve3::ExportMap, fn traverse_exports(cx: ctx, vis: ~[@view_item]) -> bool { let mut found_export = false; for vec::each(vis) |vi| { - alt vi.node { + match vi.node { view_item_export(vps) => { found_export = true; for vec::each(vps) |vp| { - alt vp.node { + match vp.node { view_path_simple(_, _, id) | view_path_glob(_, id) | view_path_list(_, _, id) => { traverse_export(cx, id); @@ -60,11 +60,11 @@ fn traverse_export(cx: ctx, exp_id: node_id) { fn traverse_def_id(cx: ctx, did: def_id) { if did.crate != local_crate { return; } - let n = alt cx.tcx.items.find(did.node) { + let n = match cx.tcx.items.find(did.node) { none => return, // This can happen for self, for example some(n) => n }; - alt n { + match n { ast_map::node_item(item, _) => traverse_public_item(cx, item), ast_map::node_method(_, impl_id, _) => traverse_def_id(cx, impl_id), ast_map::node_foreign_item(item, _, _) => { @@ -89,7 +89,7 @@ fn traverse_public_mod(cx: ctx, m: _mod) { fn traverse_public_item(cx: ctx, item: @item) { if cx.rmap.contains_key(item.id) { return; } cx.rmap.insert(item.id, ()); - alt item.node { + match item.node { item_mod(m) => traverse_public_mod(cx, m), item_foreign_mod(nm) => { if !traverse_exports(cx, nm.view_items) { @@ -127,7 +127,7 @@ fn traverse_public_item(cx: ctx, item: @item) { } } for vec::each(items) |item| { - alt item.node { + match item.node { class_method(m) => { cx.rmap.insert(m.id, ()); if tps.len() > 0u || @@ -156,9 +156,9 @@ fn traverse_ty(ty: @ty, cx: ctx, v: visit::vt<ctx>) { if cx.rmap.contains_key(ty.id) { return; } cx.rmap.insert(ty.id, ()); - alt ty.node { + match ty.node { ty_path(p, p_id) => { - alt cx.tcx.def_map.find(p_id) { + match cx.tcx.def_map.find(p_id) { // Kind of a hack to check this here, but I'm not sure what else // to do some(def_prim_ty(_)) => { /* do nothing */ } @@ -173,9 +173,9 @@ fn traverse_ty(ty: @ty, cx: ctx, v: visit::vt<ctx>) { fn traverse_inline_body(cx: ctx, body: blk) { fn traverse_expr(e: @expr, cx: ctx, v: visit::vt<ctx>) { - alt e.node { + match e.node { expr_path(_) => { - alt cx.tcx.def_map.find(e.id) { + match cx.tcx.def_map.find(e.id) { some(d) => { traverse_def_id(cx, def_id_of_def(d)); } @@ -184,7 +184,7 @@ fn traverse_inline_body(cx: ctx, body: blk) { } } expr_field(_, _, _) => { - alt cx.method_map.find(e.id) { + match cx.method_map.find(e.id) { some({origin: typeck::method_static(did), _}) => { traverse_def_id(cx, did); } @@ -213,7 +213,7 @@ fn traverse_all_resources_and_impls(cx: ctx, crate_mod: _mod) { visit_expr: |_e, _cx, _v| { }, visit_item: |i, cx, v| { visit::visit_item(i, cx, v); - alt i.node { + match i.node { item_class(_, _, _, _, some(_)) => { traverse_public_item(cx, i); } diff --git a/src/rustc/middle/trans/reflect.rs b/src/rustc/middle/trans/reflect.rs index c4d4cd6f9b3..fbcb01ff68e 100644 --- a/src/rustc/middle/trans/reflect.rs +++ b/src/rustc/middle/trans/reflect.rs @@ -91,7 +91,7 @@ impl methods for reflector { fn vstore_name_and_extra(t: ty::t, vstore: ty::vstore, f: fn(~str,~[ValueRef])) { - alt vstore { + match vstore { ty::vstore_fixed(n) => { let extra = vec::append(~[self.c_uint(n)], self.c_size_and_align(t)); @@ -114,7 +114,7 @@ impl methods for reflector { debug!{"reflect::visit_ty %s", ty_to_str(bcx.ccx().tcx, t)}; - alt ty::get(t).struct { + match ty::get(t).struct { ty::ty_bot => self.leaf(~"bot"), ty::ty_nil => self.leaf(~"nil"), ty::ty_bool => self.leaf(~"bool"), @@ -178,19 +178,19 @@ impl methods for reflector { // FIXME (#2594): fetch constants out of intrinsic:: for the // numbers. ty::ty_fn(fty) => { - let pureval = alt fty.purity { + let pureval = match fty.purity { ast::pure_fn => 0u, ast::unsafe_fn => 1u, ast::impure_fn => 2u, ast::extern_fn => 3u }; - let protoval = alt fty.proto { + let protoval = match fty.proto { ast::proto_bare => 0u, ast::proto_uniq => 2u, ast::proto_box => 3u, ast::proto_block => 4u }; - let retval = alt fty.ret_style { + let retval = match fty.ret_style { ast::noreturn => 0u, ast::return_val => 1u }; @@ -200,9 +200,9 @@ impl methods for reflector { self.c_uint(retval)]; self.visit(~"enter_fn", extra); for fty.inputs.eachi |i, arg| { - let modeval = alt arg.mode { + let modeval = match arg.mode { ast::infer(_) => 0u, - ast::expl(e) => alt e { + ast::expl(e) => match e { ast::by_ref => 1u, ast::by_val => 2u, ast::by_mutbl_ref => 3u, @@ -274,7 +274,7 @@ impl methods for reflector { ty::ty_type => self.leaf(~"type"), ty::ty_opaque_box => self.leaf(~"opaque_box"), ty::ty_opaque_closure_ptr(ck) => { - let ckval = alt ck { + let ckval = match ck { ty::ck_block => 0u, ty::ck_box => 1u, ty::ck_uniq => 2u diff --git a/src/rustc/middle/trans/shape.rs b/src/rustc/middle/trans/shape.rs index d6d5d96e4dc..2d57b71e683 100644 --- a/src/rustc/middle/trans/shape.rs +++ b/src/rustc/middle/trans/shape.rs @@ -149,7 +149,7 @@ fn enum_kind(ccx: @crate_ctxt, did: ast::def_id) -> enum_kind { // Returns the code corresponding to the pointer size on this architecture. fn s_int(tcx: ty_ctxt) -> u8 { - return alt tcx.sess.targ_cfg.arch { + return match tcx.sess.targ_cfg.arch { session::arch_x86 => shape_i32, session::arch_x86_64 => shape_i64, session::arch_arm => shape_i32 @@ -157,7 +157,7 @@ fn s_int(tcx: ty_ctxt) -> u8 { } fn s_uint(tcx: ty_ctxt) -> u8 { - return alt tcx.sess.targ_cfg.arch { + return match tcx.sess.targ_cfg.arch { session::arch_x86 => shape_u32, session::arch_x86_64 => shape_u64, session::arch_arm => shape_u32 @@ -165,7 +165,7 @@ fn s_uint(tcx: ty_ctxt) -> u8 { } fn s_float(tcx: ty_ctxt) -> u8 { - return alt tcx.sess.targ_cfg.arch { + return match tcx.sess.targ_cfg.arch { session::arch_x86 => shape_f64, session::arch_x86_64 => shape_f64, session::arch_arm => shape_f64 @@ -213,7 +213,7 @@ fn add_substr(&dest: ~[u8], src: ~[u8]) { } fn shape_of(ccx: @crate_ctxt, t: ty::t) -> ~[u8] { - alt ty::get(t).struct { + match ty::get(t).struct { ty::ty_nil | ty::ty_bool | ty::ty_uint(ast::ty_u8) | ty::ty_bot => ~[shape_u8], ty::ty_int(ast::ty_i) => ~[s_int(ccx.tcx)], @@ -233,13 +233,13 @@ fn shape_of(ccx: @crate_ctxt, t: ty::t) -> ~[u8] { shape_of(ccx, tvec::expand_boxed_vec_ty(ccx.tcx, t)) } ty::ty_enum(did, substs) => { - alt enum_kind(ccx, did) { + match enum_kind(ccx, did) { tk_unit => ~[s_variant_enum_t(ccx.tcx)], tk_enum => ~[s_variant_enum_t(ccx.tcx)], tk_newtype | tk_complex => { let mut s = ~[shape_enum], id; let nom_id = mk_nominal_id(ccx.tcx, did, none, substs.tps); - alt ccx.shape_cx.tag_id_to_index.find(nom_id) { + match ccx.shape_cx.tag_id_to_index.find(nom_id) { none => { id = ccx.shape_cx.next_tag_id; ccx.shape_cx.tag_id_to_index.insert(nom_id, id); @@ -678,7 +678,7 @@ fn llalign_of(cx: @crate_ctxt, t: TypeRef) -> ValueRef { // Computes the size of the data part of an enum. fn static_size_of_enum(cx: @crate_ctxt, t: ty::t) -> uint { if cx.enum_sizes.contains_key(t) { return cx.enum_sizes.get(t); } - alt ty::get(t).struct { + match ty::get(t).struct { ty::ty_enum(tid, substs) => { // Compute max(variant sizes). let mut max_size = 0u; @@ -712,7 +712,7 @@ fn simplify_type(tcx: ty::ctxt, typ: ty::t) -> ty::t { ty::mk_ptr(tcx, {ty: ty::mk_nil(tcx), mutbl: ast::m_imm}) } fn simplifier(tcx: ty::ctxt, typ: ty::t) -> ty::t { - alt ty::get(typ).struct { + match ty::get(typ).struct { ty::ty_box(_) | ty::ty_opaque_box | ty::ty_uniq(_) | ty::ty_evec(_, ty::vstore_uniq) | ty::ty_evec(_, ty::vstore_box) | ty::ty_estr(ty::vstore_uniq) | ty::ty_estr(ty::vstore_box) | diff --git a/src/rustc/middle/trans/tvec.rs b/src/rustc/middle/trans/tvec.rs index 84d7ca370f9..aa92c96a686 100644 --- a/src/rustc/middle/trans/tvec.rs +++ b/src/rustc/middle/trans/tvec.rs @@ -19,7 +19,7 @@ import util::ppaux::ty_to_str; fn expand_boxed_vec_ty(tcx: ty::ctxt, t: ty::t) -> ty::t { let unit_ty = ty::sequence_element_type(tcx, t); let unboxed_vec_ty = ty::mk_mut_unboxed_vec(tcx, unit_ty); - alt ty::get(t).struct { + match ty::get(t).struct { ty::ty_estr(ty::vstore_uniq) | ty::ty_evec(_, ty::vstore_uniq) => { ty::mk_imm_uniq(tcx, unboxed_vec_ty) } @@ -156,10 +156,10 @@ fn trans_evec(bcx: block, elements: evec_elements, let unit_sz = llsize_of(ccx, llunitty); let mut {bcx, val, dataptr} = - alt vst { + match vst { ast::vstore_fixed(_) => { // Destination should be pre-allocated for us. - let v = alt dest { + let v = match dest { base::save_in(v) => { PointerCast(bcx, v, T_ptr(llunitty)) } @@ -245,7 +245,7 @@ fn trans_evec(bcx: block, elements: evec_elements, for vec::each(temp_cleanups) |cln| { revoke_clean(bcx, cln); } - alt vst { + match vst { ast::vstore_fixed(_) => { // We wrote into the destination in the fixed case. return bcx; @@ -261,7 +261,7 @@ fn trans_evec(bcx: block, elements: evec_elements, fn trans_vstore(bcx: block, e: @ast::expr, v: ast::vstore, dest: dest) -> block { - alt e.node { + match e.node { ast::expr_lit(@{node: ast::lit_str(s), span: _}) => { return trans_estr(bcx, s, some(v), dest); } @@ -288,12 +288,12 @@ fn get_base_and_len(cx: block, v: ValueRef, e_ty: ty::t) let llunitty = type_of::type_of(ccx, unit_ty); let unit_sz = llsize_of(ccx, llunitty); - let vstore = alt ty::get(vec_ty).struct { + let vstore = match ty::get(vec_ty).struct { ty::ty_estr(vst) | ty::ty_evec(_, vst) => vst, _ => ty::vstore_uniq }; - alt vstore { + match vstore { ty::vstore_fixed(n) => { let base = GEPi(cx, v, ~[0u, 0u]); let n = if ty::type_is_str(e_ty) { n + 1u } else { n }; @@ -319,7 +319,7 @@ fn trans_estr(bcx: block, s: @~str, vstore: option<ast::vstore>, if dest == base::ignore { return bcx; } let ccx = bcx.ccx(); - let c = alt vstore { + let c = match vstore { some(ast::vstore_fixed(_)) => { // "hello"/_ => "hello"/5 => ~[i8 x 6] in llvm debug!{"trans_estr: fixed: %s", *s}; diff --git a/src/rustc/middle/trans/type_of.rs b/src/rustc/middle/trans/type_of.rs index 03f7d2b5482..73daa654d28 100644 --- a/src/rustc/middle/trans/type_of.rs +++ b/src/rustc/middle/trans/type_of.rs @@ -17,7 +17,7 @@ fn type_of_explicit_args(cx: @crate_ctxt, do vec::map(inputs) |arg| { let arg_ty = arg.ty; let llty = type_of(cx, arg_ty); - alt ty::resolved_mode(cx.tcx, arg.mode) { + match ty::resolved_mode(cx.tcx, arg.mode) { ast::by_val => llty, _ => T_ptr(llty) } @@ -51,7 +51,7 @@ fn type_of_non_gc_box(cx: @crate_ctxt, t: ty::t) -> TypeRef { if t != t_norm { type_of_non_gc_box(cx, t_norm) } else { - alt ty::get(t).struct { + match ty::get(t).struct { ty::ty_box(mt) => { T_ptr(T_box(cx, type_of(cx, mt.ty))) } @@ -83,7 +83,7 @@ fn type_of(cx: @crate_ctxt, t: ty::t) -> TypeRef { llty = type_of(cx, t_norm); cx.lltypes.insert(t, llty); } else { - llty = alt ty::get(t).struct { + llty = match ty::get(t).struct { ty::ty_nil | ty::ty_bot => T_nil(), ty::ty_bool => T_bool(), ty::ty_int(t) => T_int_ty(cx, t), @@ -166,7 +166,7 @@ fn type_of(cx: @crate_ctxt, t: ty::t) -> TypeRef { cx.lltypes.insert(t, llty); // If this was a class, fill in the type now. - alt ty::get(t).struct { + match ty::get(t).struct { ty::ty_class(did, ts) => { // Only instance vars are record fields at runtime. let fields = ty::lookup_class_fields(cx.tcx, did); @@ -225,7 +225,7 @@ fn type_of_enum(cx: @crate_ctxt, did: ast::def_id, t: ty::t) } fn llvm_type_name(cx: @crate_ctxt, t: ty::t) -> ~str { - let (name, did, tps) = alt check ty::get(t).struct { + let (name, did, tps) = match check ty::get(t).struct { ty::ty_enum(did, substs) => (~"enum", did, substs.tps), ty::ty_class(did, substs) => (~"class", did, substs.tps) }; diff --git a/src/rustc/middle/trans/type_use.rs b/src/rustc/middle/trans/type_use.rs index 4026d2b0a24..b7f9fdc459d 100644 --- a/src/rustc/middle/trans/type_use.rs +++ b/src/rustc/middle/trans/type_use.rs @@ -35,7 +35,7 @@ type ctx = {ccx: @crate_ctxt, fn type_uses_for(ccx: @crate_ctxt, fn_id: def_id, n_tps: uint) -> ~[type_uses] { - alt ccx.type_use_cache.find(fn_id) { + match ccx.type_use_cache.find(fn_id) { some(uses) => return uses, none => () } @@ -45,7 +45,7 @@ fn type_uses_for(ccx: @crate_ctxt, fn_id: def_id, n_tps: uint) ccx.type_use_cache.insert(fn_id, vec::from_elem(n_tps, 3u)); let cx = {ccx: ccx, uses: vec::to_mut(vec::from_elem(n_tps, 0u))}; - alt ty::get(ty::lookup_item_type(cx.ccx.tcx, fn_id).ty).struct { + match ty::get(ty::lookup_item_type(cx.ccx.tcx, fn_id).ty).struct { ty::ty_fn({inputs, _}) => { for vec::each(inputs) |arg| { if arg.mode == expl(by_val) { type_needs(cx, use_repr, arg.ty); } @@ -59,12 +59,12 @@ fn type_uses_for(ccx: @crate_ctxt, fn_id: def_id, n_tps: uint) ccx.type_use_cache.insert(fn_id, uses); return uses; } - let map_node = alt ccx.tcx.items.find(fn_id_loc.node) { + let map_node = match ccx.tcx.items.find(fn_id_loc.node) { some(x) => x, none => ccx.sess.bug(fmt!{"type_uses_for: unbound item ID %?", fn_id_loc}) }; - alt check map_node { + match check map_node { ast_map::node_item(@{node: item_fn(_, _, body), _}, _) | ast_map::node_method(@{body, _}, _, _) => { handle_body(cx, body); @@ -75,7 +75,7 @@ fn type_uses_for(ccx: @crate_ctxt, fn_id: def_id, n_tps: uint) ast_map::node_foreign_item(i@@{node: foreign_item_fn(_, _), _}, abi, _) => { if abi == foreign_abi_rust_intrinsic { - let flags = alt check *i.ident { + let flags = match check *i.ident { ~"size_of" | ~"pref_align_of" | ~"min_align_of" | ~"init" | ~"reinterpret_cast" | ~"move_val" | ~"move_val_init" => { @@ -120,7 +120,7 @@ fn type_needs_inner(cx: ctx, use: uint, ty: ty::t, enums_seen: @list<def_id>) { do ty::maybe_walk_ty(ty) |ty| { if ty::type_has_params(ty) { - alt ty::get(ty).struct { + match ty::get(ty).struct { /* This previously included ty_box -- that was wrong because if we cast an @T to an trait (for example) and return @@ -156,7 +156,7 @@ fn node_type_needs(cx: ctx, use: uint, id: node_id) { } fn mark_for_expr(cx: ctx, e: @expr) { - alt e.node { + match e.node { expr_vstore(_, _) | expr_vec(_, _) | expr_rec(_, _) | expr_struct(*) | expr_tup(_) | @@ -168,7 +168,7 @@ fn mark_for_expr(cx: ctx, e: @expr) { } expr_cast(base, _) => { let result_t = ty::node_id_to_type(cx.ccx.tcx, e.id); - alt ty::get(result_t).struct { + match ty::get(result_t).struct { ty::ty_trait(*) => { // When we're casting to an trait, we need the // tydesc for the expr that's being cast. @@ -178,7 +178,7 @@ fn mark_for_expr(cx: ctx, e: @expr) { } } expr_binary(op, lhs, _) => { - alt op { + match op { eq | lt | le | ne | ge | gt => { node_type_needs(cx, use_tydesc, lhs.id) } @@ -195,7 +195,7 @@ fn mark_for_expr(cx: ctx, e: @expr) { } } expr_fn(*) | expr_fn_block(*) => { - alt ty::ty_fn_proto(ty::expr_ty(cx.ccx.tcx, e)) { + match ty::ty_fn_proto(ty::expr_ty(cx.ccx.tcx, e)) { proto_bare | proto_uniq => {} proto_box | proto_block => { for vec::each(*freevars::get_freevars(cx.ccx.tcx, e.id)) |fv| { @@ -216,7 +216,7 @@ fn mark_for_expr(cx: ctx, e: @expr) { type_needs(cx, use_repr, ty::type_autoderef(cx.ccx.tcx, base_ty)); do option::iter(cx.ccx.maps.method_map.find(e.id)) |mth| { - alt mth.origin { + match mth.origin { typeck::method_static(did) => { do option::iter(cx.ccx.tcx.node_type_substs.find(e.id)) |ts| { do vec::iter2(type_uses_for(cx.ccx, did, ts.len()), ts) @@ -235,7 +235,7 @@ fn mark_for_expr(cx: ctx, e: @expr) { } expr_call(f, _, _) => { vec::iter(ty::ty_fn_args(ty::node_id_to_type(cx.ccx.tcx, f.id)), |a| { - alt a.mode { + match a.mode { expl(by_move) | expl(by_copy) | expl(by_val) => { type_needs(cx, use_repr, a.ty); } diff --git a/src/rustc/middle/trans/uniq.rs b/src/rustc/middle/trans/uniq.rs index c2bdf280100..e66ae41e5c6 100644 --- a/src/rustc/middle/trans/uniq.rs +++ b/src/rustc/middle/trans/uniq.rs @@ -19,7 +19,7 @@ fn make_free_glue(bcx: block, vptr: ValueRef, t: ty::t) } fn content_ty(t: ty::t) -> ty::t { - alt ty::get(t).struct { + match ty::get(t).struct { ty::ty_uniq({ty: ct, _}) => ct, _ => core::unreachable() } diff --git a/src/rustc/middle/tstate/ann.rs b/src/rustc/middle/tstate/ann.rs index cbd255341f5..19a2ca15723 100644 --- a/src/rustc/middle/tstate/ann.rs +++ b/src/rustc/middle/tstate/ann.rs @@ -240,7 +240,7 @@ fn implies(a: t, b: t) -> bool { } fn trit_str(t: trit) -> ~str { - alt t { dont_care { ~"?" } ttrue { ~"1" } tfalse { ~"0" } } + match t { dont_care { ~"?" } ttrue { ~"1" } tfalse { ~"0" } } } // FIXME (#2538): Would be nice to have unit tests for some of these diff --git a/src/rustc/middle/tstate/annotate.rs b/src/rustc/middle/tstate/annotate.rs index f4b2e5e6442..379546015cc 100644 --- a/src/rustc/middle/tstate/annotate.rs +++ b/src/rustc/middle/tstate/annotate.rs @@ -14,7 +14,7 @@ fn collect_ids_block(b: blk, rs: @mut ~[node_id]) { } fn collect_ids_stmt(s: @stmt, rs: @mut ~[node_id]) { - alt s.node { + match s.node { stmt_decl(_, id) | stmt_expr(_, id) | stmt_semi(_, id) { debug!{"node_id %s", int::str(id)}; debug!{"%s", stmt_to_str(*s)}; diff --git a/src/rustc/middle/tstate/auxiliary.rs b/src/rustc/middle/tstate/auxiliary.rs index eb39d4ec561..ce3b65db6ff 100644 --- a/src/rustc/middle/tstate/auxiliary.rs +++ b/src/rustc/middle/tstate/auxiliary.rs @@ -39,7 +39,7 @@ fn comma_str(args: ~[@constr_arg_use]) -> ~str { let mut comma = false; for args.each |a| { if comma { rslt += ~", "; } else { comma = true; } - alt a.node { + match a.node { carg_base { rslt += ~"*"; } carg_ident(i) { rslt += *i.ident; } carg_lit(l) { rslt += lit_to_str(l); } @@ -59,7 +59,7 @@ fn tritv_to_str(fcx: fn_ctxt, v: tritv::t) -> ~str { let mut s = ~""; let mut comma = false; for constraints(fcx).each |p| { - alt v.get(p.bit_num) { + match v.get(p.bit_num) { dont_care { } tt { s += @@ -261,7 +261,7 @@ fn get_ts_ann(ccx: crate_ctxt, i: node_id) -> option<ts_ann> { /********* utils ********/ fn node_id_to_ts_ann(ccx: crate_ctxt, id: node_id) -> ts_ann { - alt get_ts_ann(ccx, id) { + match get_ts_ann(ccx, id) { none { error!{"node_id_to_ts_ann: no ts_ann for node_id %d", id}; fail; @@ -277,7 +277,7 @@ fn node_id_to_poststate(ccx: crate_ctxt, id: node_id) -> poststate { fn stmt_to_ann(ccx: crate_ctxt, s: stmt) -> ts_ann { debug!{"stmt_to_ann"}; - alt s.node { + match s.node { stmt_decl(_, id) | stmt_expr(_, id) | stmt_semi(_, id) { return node_id_to_ts_ann(ccx, id); } @@ -445,21 +445,21 @@ fn new_crate_ctxt(cx: ty::ctxt) -> crate_ctxt { If it has a function type with a ! annotation, the answer is noreturn. */ fn controlflow_expr(ccx: crate_ctxt, e: @expr) -> ret_style { - alt ty::get(ty::node_id_to_type(ccx.tcx, e.id)).struct { + match ty::get(ty::node_id_to_type(ccx.tcx, e.id)).struct { ty::ty_fn(f) { return f.ret_style; } _ { return return_val; } } } fn constraints_expr(cx: ty::ctxt, e: @expr) -> ~[@ty::constr] { - alt ty::get(ty::node_id_to_type(cx, e.id)).struct { + match ty::get(ty::node_id_to_type(cx, e.id)).struct { ty::ty_fn(f) { return f.constraints; } _ { return ~[]; } } } fn node_id_to_def_strict(cx: ty::ctxt, id: node_id) -> def { - alt cx.def_map.find(id) { + match cx.def_map.find(id) { none { error!{"node_id_to_def: node_id %d has no def", id}; fail; @@ -511,7 +511,7 @@ fn match_args(fcx: fn_ctxt, occs: @dvec<pred_args>, } fn def_id_for_constr(tcx: ty::ctxt, t: node_id) -> def_id { - alt tcx.def_map.find(t) { + match tcx.def_map.find(t) { none { tcx.sess.bug(~"node_id_for_constr: bad node_id " + int::str(t)); } @@ -521,9 +521,9 @@ fn def_id_for_constr(tcx: ty::ctxt, t: node_id) -> def_id { } fn expr_to_constr_arg(tcx: ty::ctxt, e: @expr) -> @constr_arg_use { - alt e.node { + match e.node { expr_path(p) { - alt tcx.def_map.find(e.id) { + match tcx.def_map.find(e.id) { some(def_local(nid, _)) | some(def_arg(nid, _)) | some(def_binding(nid, _)) | some(def_upvar(nid, _, _)) { return @respan(p.span, @@ -559,9 +559,9 @@ fn exprs_to_constr_args(tcx: ty::ctxt, } fn expr_to_constr(tcx: ty::ctxt, e: @expr) -> sp_constr { - alt e.node { + match e.node { expr_call(operator, args, _) { - alt operator.node { + match operator.node { expr_path(p) { return respan(e.span, {path: p, @@ -601,7 +601,7 @@ fn substitute_constr_args(cx: ty::ctxt, actuals: ~[@expr], c: @ty::constr) -> fn substitute_arg(cx: ty::ctxt, actuals: ~[@expr], a: @constr_arg) -> @constr_arg_use { let num_actuals = vec::len(actuals); - alt a.node { + match a.node { carg_ident(i) { if i < num_actuals { return expr_to_constr_arg(cx, actuals[i]); @@ -620,16 +620,16 @@ fn pred_args_matches(pattern: ~[constr_arg_general_<inst>], let mut i = 0u; for desc.node.args.each |c| { let n = pattern[i]; - alt c.node { + match c.node { carg_ident(p) { - alt n { + match n { carg_ident(q) { if p.node != q.node { return false; } } _ { return false; } } } carg_base { if n != carg_base { return false; } } carg_lit(l) { - alt n { + match n { carg_lit(m) { if !const_eval::lit_eq(l, m) { return false; } } _ { return false; } } @@ -669,7 +669,7 @@ fn find_instances(_fcx: fn_ctxt, subst: subst, if args_mention(d.node.args, find_in_subst_bool, subst) { let old_bit_num = d.node.bit_num; let newv = replace(subst, d); - alt find_instance_(newv, v) { + match find_instance_(newv, v) { some(d1) {vec::push(res, {from: old_bit_num, to: d1})} _ {} } @@ -696,7 +696,7 @@ fn insts_to_str(stuff: ~[constr_arg_general_<inst>]) -> ~str { for stuff.each |i| { rslt += ~" " + - alt i { + match i { carg_ident(p) { *p.ident } carg_base { ~"*" } carg_lit(_) { ~"~[lit]" } @@ -709,9 +709,9 @@ fn insts_to_str(stuff: ~[constr_arg_general_<inst>]) -> ~str { fn replace(subst: subst, d: pred_args) -> ~[constr_arg_general_<inst>] { let mut rslt: ~[constr_arg_general_<inst>] = ~[]; for d.node.args.each |c| { - alt c.node { + match c.node { carg_ident(p) { - alt find_in_subst(p.node, subst) { + match find_in_subst(p.node, subst) { some(newv) { vec::push(rslt, carg_ident(newv)); } _ { vec::push(rslt, c.node); } } @@ -736,7 +736,7 @@ fn for_constraints_mentioning(fcx: fn_ctxt, id: node_id, fn local_node_id_to_def_id_strict(fcx: fn_ctxt, sp: span, i: node_id) -> def_id { - alt local_node_id_to_def(fcx, i) { + match local_node_id_to_def(fcx, i) { some(def_local(nid, _)) | some(def_arg(nid, _)) | some(def_upvar(nid, _, _)) { return local_def(nid); @@ -760,7 +760,7 @@ fn local_node_id_to_def(fcx: fn_ctxt, i: node_id) -> option<def> { } fn local_node_id_to_def_id(fcx: fn_ctxt, i: node_id) -> option<def_id> { - alt local_node_id_to_def(fcx, i) { + match local_node_id_to_def(fcx, i) { some(def_local(nid, _)) | some(def_arg(nid, _)) | some(def_binding(nid, _)) | some(def_upvar(nid, _, _)) { some(local_def(nid)) @@ -771,7 +771,7 @@ fn local_node_id_to_def_id(fcx: fn_ctxt, i: node_id) -> option<def_id> { fn local_node_id_to_local_def_id(fcx: fn_ctxt, i: node_id) -> option<node_id> { - alt local_node_id_to_def_id(fcx, i) { + match local_node_id_to_def_id(fcx, i) { some(did) { some(did.node) } _ { none } } @@ -798,7 +798,7 @@ fn copy_in_poststate_two(fcx: fn_ctxt, src_post: poststate, target_post: poststate, dest: inst, src: inst, ty: oper_type) { let mut subst; - alt ty { + match ty { oper_swap { subst = ~[{from: dest, to: src}, {from: src, to: dest}]; } oper_assign_op { return; // Don't do any propagation @@ -863,7 +863,7 @@ fn args_mention<T>(args: ~[@constr_arg_use], s: ~[T]) -> bool { for args.each |a| { - alt a.node { + match a.node { carg_ident(p1) { if q(s, p1.node) { return true; } } _ { } } } @@ -875,7 +875,7 @@ fn use_var(fcx: fn_ctxt, v: node_id) { } fn op_to_oper_ty(io: init_op) -> oper_type { - alt io { init_move { oper_move } _ { oper_assign } } + match io { init_move { oper_move } _ { oper_assign } } } // default function visitor @@ -894,7 +894,7 @@ fn args_to_constr_args(tcx: ty::ctxt, args: ~[arg], vec::push( actuals, @respan(a.span, - alt a.node { + match a.node { carg_base { carg_base } carg_ident(i) { if i < num_args { @@ -945,7 +945,7 @@ fn locals_to_bindings(tcx: ty::ctxt, locals: ~[@local]) -> ~[binding] { fn callee_modes(fcx: fn_ctxt, callee: node_id) -> ~[mode] { let ty = ty::type_autoderef(fcx.ccx.tcx, ty::node_id_to_type(fcx.ccx.tcx, callee)); - alt ty::get(ty).struct { + match ty::get(ty).struct { ty::ty_fn({inputs: args, _}) { let mut modes = ~[]; for args.each |arg| { vec::push(modes, arg.mode); } @@ -961,7 +961,7 @@ fn callee_modes(fcx: fn_ctxt, callee: node_id) -> ~[mode] { fn callee_arg_init_ops(fcx: fn_ctxt, callee: node_id) -> ~[init_op] { do vec::map(callee_modes(fcx, callee)) |m| { - alt ty::resolved_mode(fcx.ccx.tcx, m) { + match ty::resolved_mode(fcx.ccx.tcx, m) { by_move { init_move } by_copy | by_ref | by_val | by_mutbl_ref { init_assign } } diff --git a/src/rustc/middle/tstate/collect_locals.rs b/src/rustc/middle/tstate/collect_locals.rs index c6f46ba3888..6379e8898f7 100644 --- a/src/rustc/middle/tstate/collect_locals.rs +++ b/src/rustc/middle/tstate/collect_locals.rs @@ -13,7 +13,7 @@ import dvec::{dvec, extensions}; type ctxt = {cs: @mut ~[sp_constr], tcx: ty::ctxt}; fn collect_pred(e: @expr, cx: ctxt, v: visit::vt<ctxt>) { - alt e.node { + match e.node { expr_check(_, ch) { vec::push(*cx.cs, expr_to_constr(cx.tcx, ch)); } expr_if_check(ex, _, _) { vec::push(*cx.cs, expr_to_constr(cx.tcx, ex)); @@ -58,7 +58,7 @@ fn add_constraint(tcx: ty::ctxt, c: sp_constr, next: uint, tbl: constr_map) -> constraint_to_str(tcx, c) + ~" |-> " + uint::str(next)); let {path: p, def_id: d_id, args: args} = c.node; - alt tbl.find(d_id) { + match tbl.find(d_id) { some(ct) { (*ct.descs).push(respan(c.span, {args: args, bit_num: next})); } diff --git a/src/rustc/middle/tstate/pre_post_conditions.rs b/src/rustc/middle/tstate/pre_post_conditions.rs index 9315e69d289..6036db54432 100644 --- a/src/rustc/middle/tstate/pre_post_conditions.rs +++ b/src/rustc/middle/tstate/pre_post_conditions.rs @@ -36,7 +36,7 @@ fn find_pre_post_method(ccx: crate_ctxt, m: @method) { } fn find_pre_post_item(ccx: crate_ctxt, i: item) { - alt i.node { + match i.node { item_const(_, e) { // do nothing -- item_consts don't refer to local vars } @@ -100,9 +100,9 @@ fn join_then_else(fcx: fn_ctxt, antec: @expr, conseq: blk, maybe_alt: option<@expr>, id: node_id, chck: if_ty) { find_pre_post_expr(fcx, antec); find_pre_post_block(fcx, conseq); - alt maybe_alt { + match maybe_alt { none { - alt chck { + match chck { if_check { let c: sp_constr = expr_to_constr(fcx.ccx.tcx, antec); gen(fcx, antec.id, c.node); @@ -135,7 +135,7 @@ fn join_then_else(fcx: fn_ctxt, antec: @expr, conseq: blk, /* Be sure to set the bit for the check condition here, so that it's *not* set in the alternative. */ - alt chck { + match chck { if_check { let c: sp_constr = expr_to_constr(fcx.ccx.tcx, antec); gen(fcx, antec.id, c.node); @@ -162,9 +162,9 @@ fn join_then_else(fcx: fn_ctxt, antec: @expr, conseq: blk, fn gen_if_local(fcx: fn_ctxt, lhs: @expr, rhs: @expr, larger_id: node_id, new_var: node_id) { - alt node_id_to_def(fcx.ccx, new_var) { + match node_id_to_def(fcx.ccx, new_var) { some(d) { - alt d { + match d { def_local(nid, _) { find_pre_post_expr(fcx, rhs); let p = expr_pp(fcx.ccx, rhs); @@ -181,12 +181,12 @@ fn gen_if_local(fcx: fn_ctxt, lhs: @expr, rhs: @expr, larger_id: node_id, fn handle_update(fcx: fn_ctxt, parent: @expr, lhs: @expr, rhs: @expr, ty: oper_type) { find_pre_post_expr(fcx, rhs); - alt lhs.node { + match lhs.node { expr_path(p) { let post = expr_postcond(fcx.ccx, parent); let tmp = post.clone(); - alt ty { + match ty { oper_move { if is_path(rhs) { forget_in_postcond(fcx, parent.id, rhs.id); } } @@ -201,13 +201,13 @@ fn handle_update(fcx: fn_ctxt, parent: @expr, lhs: @expr, rhs: @expr, } gen_if_local(fcx, lhs, rhs, parent.id, lhs.id); - alt rhs.node { + match rhs.node { expr_path(p1) { let d = local_node_id_to_local_def_id(fcx, lhs.id); let d1 = local_node_id_to_local_def_id(fcx, rhs.id); - alt d { + match d { some(id) { - alt d1 { + match d1 { some(id1) { let instlhs = {ident: path_to_ident(p), node: id}; @@ -232,7 +232,7 @@ fn handle_update(fcx: fn_ctxt, parent: @expr, lhs: @expr, rhs: @expr, fn forget_args_moved_in(fcx: fn_ctxt, parent: @expr, modes: ~[mode], operands: ~[@expr]) { do vec::iteri(modes) |i,mode| { - alt ty::resolved_mode(fcx.ccx.tcx, mode) { + match ty::resolved_mode(fcx.ccx.tcx, mode) { by_move { forget_in_postcond(fcx, parent.id, operands[i].id); } by_ref | by_val | by_mutbl_ref | by_copy { } } @@ -251,7 +251,7 @@ fn find_pre_post_expr(fcx: fn_ctxt, e: @expr) { fn do_rand_(fcx: fn_ctxt, e: @expr) { find_pre_post_expr(fcx, e); } - alt e.node { + match e.node { expr_call(operator, operands, _) { /* copy */ @@ -270,7 +270,7 @@ fn find_pre_post_expr(fcx: fn_ctxt, e: @expr) { operands); /* if this is a failing call, its postcondition sets everything */ - alt controlflow_expr(fcx.ccx, operator) { + match controlflow_expr(fcx.ccx, operator) { noreturn { set_postcond_false(fcx.ccx, e.id); } _ { } } @@ -315,7 +315,7 @@ fn find_pre_post_expr(fcx: fn_ctxt, e: @expr) { } expr_rec(fields, maybe_base) { let mut es = field_exprs(fields); - alt maybe_base { none {/* no-op */ } some(b) { vec::push(es, b); } } + match maybe_base { none {/* no-op */ } some(b) { vec::push(es, b); } } find_pre_post_exprs(fcx, es, e.id); } expr_tup(elts) { find_pre_post_exprs(fcx, elts, e.id); } @@ -331,7 +331,7 @@ fn find_pre_post_expr(fcx: fn_ctxt, e: @expr) { } expr_lit(_) { clear_pp(expr_pp(fcx.ccx, e)); } expr_ret(maybe_val) { - alt maybe_val { + match maybe_val { none { clear_precond(fcx.ccx, e.id); set_postcond_false(fcx.ccx, e.id); @@ -391,7 +391,7 @@ fn find_pre_post_expr(fcx: fn_ctxt, e: @expr) { expr_alt(ex, alts, _) { find_pre_post_expr(fcx, ex); fn do_an_alt(fcx: fn_ctxt, an_alt: arm) -> pre_and_post { - alt an_alt.guard { + match an_alt.guard { some(e) { find_pre_post_expr(fcx, e); } _ {} } @@ -422,7 +422,7 @@ fn find_pre_post_expr(fcx: fn_ctxt, e: @expr) { } expr_fail(maybe_val) { let mut prestate; - alt maybe_val { + match maybe_val { none { prestate = empty_prestate(num_local_vars); } some(fail_val) { find_pre_post_expr(fcx, fail_val); @@ -453,13 +453,13 @@ fn find_pre_post_expr(fcx: fn_ctxt, e: @expr) { fn find_pre_post_stmt(fcx: fn_ctxt, s: stmt) { debug!{"stmt = %s", stmt_to_str(s)}; - alt s.node { + match s.node { stmt_decl(adecl, id) { - alt adecl.node { + match adecl.node { decl_local(alocals) { let prev_pp = empty_pre_post(num_constraints(fcx.enclosing)); for alocals.each |alocal| { - alt alocal.node.init { + match alocal.node.init { some(an_init) { /* LHS always becomes initialized, whether or not this is a move */ @@ -473,7 +473,7 @@ fn find_pre_post_stmt(fcx: fn_ctxt, s: stmt) { copy_pre_post(fcx.ccx, id, an_init.expr); let mut p = none; - alt an_init.expr.node { + match an_init.expr.node { expr_path(_p) { p = some(_p); } _ { } } @@ -481,7 +481,7 @@ fn find_pre_post_stmt(fcx: fn_ctxt, s: stmt) { do pat_bindings(fcx.ccx.tcx.def_map, alocal.node.pat) |p_id, _s, n| { let ident = path_to_ident(n); - alt p { + match p { some(p) { copy_in_postcond(fcx, id, {ident: ident, node: p_id}, @@ -557,7 +557,7 @@ fn find_pre_post_block(fcx: fn_ctxt, b: blk) { let mut pps: ~[pre_and_post] = ~[]; for b.node.stmts.each |s| { vec::push(pps, stmt_pp(fcx.ccx, *s)); } - alt b.node.expr { + match b.node.expr { none {/* no-op */ } some(e) { vec::push(pps, expr_pp(fcx.ccx, e)); } } @@ -584,7 +584,7 @@ fn find_pre_post_fn(fcx: fn_ctxt, body: blk) { find_pre_post_block(fcx, body); // Treat the tail expression as a return statement - alt body.node.expr { + match body.node.expr { some(tailexpr) { set_postcond_false(fcx.ccx, tailexpr.id); } none {/* fallthrough */ } } diff --git a/src/rustc/middle/tstate/states.rs b/src/rustc/middle/tstate/states.rs index b134f3b71af..9c4191fc20a 100644 --- a/src/rustc/middle/tstate/states.rs +++ b/src/rustc/middle/tstate/states.rs @@ -15,9 +15,9 @@ import driver::session::session; import std::map::hashmap; fn forbid_upvar(fcx: fn_ctxt, rhs_id: node_id, sp: span, t: oper_type) { - alt t { + match t { oper_move { - alt local_node_id_to_def(fcx, rhs_id) { + match local_node_id_to_def(fcx, rhs_id) { some(def_upvar(_, _, _)) { fcx.ccx.tcx.sess.span_err(sp, ~"tried to deinitialize a variable \ @@ -35,12 +35,12 @@ fn handle_move_or_copy(fcx: fn_ctxt, post: poststate, rhs_path: @path, forbid_upvar(fcx, rhs_id, rhs_path.span, op_to_oper_ty(init_op)); let rhs_d_id = local_node_id_to_def_id(fcx, rhs_id); - alt rhs_d_id { + match rhs_d_id { some(rhsid) { // RHS is a local var let instrhs = {ident: path_to_ident(rhs_path), node: rhsid.node}; - alt destlhs { + match destlhs { local_dest(instlhs) { copy_in_poststate(fcx, post, instlhs, instrhs, op_to_oper_ty(init_op)); @@ -59,14 +59,14 @@ fn seq_states(fcx: fn_ctxt, pres: prestate, bindings: ~[binding]) -> let mut changed = false; let mut post = pres.clone(); for bindings.each |b| { - alt b.rhs { + match b.rhs { some(an_init) { // an expression, with or without a destination changed |= find_pre_post_state_expr(fcx, post, an_init.expr) || changed; post = expr_poststate(fcx.ccx, an_init.expr).clone(); for b.lhs.each |d| { - alt an_init.expr.node { + match an_init.expr.node { expr_path(p) { handle_move_or_copy(fcx, post, p, an_init.expr.id, d, an_init.op); @@ -94,7 +94,7 @@ fn find_pre_post_state_sub(fcx: fn_ctxt, pres: prestate, e: @expr, changed = set_prestate_ann(fcx.ccx, parent, pres) || changed; let post = expr_poststate(fcx.ccx, e).clone(); - alt c { + match c { none { } some(c1) { set_in_poststate_(bit_num(fcx, c1), post); } } @@ -115,7 +115,7 @@ fn find_pre_post_state_two(fcx: fn_ctxt, pres: prestate, lhs: @expr, let post = expr_poststate(fcx.ccx, rhs).clone(); - alt lhs.node { + match lhs.node { expr_path(p) { // for termination, need to make sure intermediate changes don't set // changed flag @@ -123,7 +123,7 @@ fn find_pre_post_state_two(fcx: fn_ctxt, pres: prestate, lhs: @expr, // for substitution purposes let tmp = post.clone(); - alt ty { + match ty { oper_move { if is_path(rhs) { forget_in_poststate(fcx, post, rhs.id); } forget_in_poststate(fcx, post, lhs.id); @@ -135,13 +135,13 @@ fn find_pre_post_state_two(fcx: fn_ctxt, pres: prestate, lhs: @expr, _ { forget_in_poststate(fcx, post, lhs.id); } } - alt rhs.node { + match rhs.node { expr_path(p1) { let d = local_node_id_to_local_def_id(fcx, lhs.id); let d1 = local_node_id_to_local_def_id(fcx, rhs.id); - alt d { + match d { some(id) { - alt d1 { + match d1 { some(id1) { let instlhs = {ident: path_to_ident(p), node: id}; @@ -188,7 +188,7 @@ fn find_pre_post_state_exprs(fcx: fn_ctxt, pres: prestate, id: node_id, let rs = seq_states(fcx, pres, arg_bindings(ops, es)); let mut changed = rs.changed | set_prestate_ann(fcx.ccx, id, pres); /* if this is a failing call, it sets everything as initialized */ - alt cf { + match cf { noreturn { let post = false_postcond(num_constraints(fcx.enclosing)); changed |= set_poststate_ann(fcx.ccx, id, post); @@ -205,9 +205,9 @@ fn join_then_else(fcx: fn_ctxt, antec: @expr, conseq: blk, set_prestate_ann(fcx.ccx, id, pres) | find_pre_post_state_expr(fcx, pres, antec); - alt maybe_alt { + match maybe_alt { none { - alt chk { + match chk { if_check { let c: sp_constr = expr_to_constr(fcx.ccx.tcx, antec); let conseq_prestate = expr_poststate(fcx.ccx, antec).clone(); @@ -232,7 +232,7 @@ fn join_then_else(fcx: fn_ctxt, antec: @expr, conseq: blk, altern); let mut conseq_prestate = expr_poststate(fcx.ccx, antec); - alt chk { + match chk { if_check { let c: sp_constr = expr_to_constr(fcx.ccx.tcx, antec); conseq_prestate = conseq_prestate.clone(); @@ -282,7 +282,7 @@ fn find_pre_post_state_cap_clause(fcx: fn_ctxt, e_id: node_id, fn find_pre_post_state_expr(fcx: fn_ctxt, pres: prestate, e: @expr) -> bool { let num_constrs = num_constraints(fcx.enclosing); - alt e.node { + match e.node { expr_new(p, _, v) { return find_pre_post_state_two(fcx, pres, p, v, e.id, oper_pure); } @@ -330,7 +330,7 @@ fn find_pre_post_state_expr(fcx: fn_ctxt, pres: prestate, e: @expr) -> bool { init_assign), exs, return_val); - let base_pres = alt vec::last_opt(exs) { none { pres } + let base_pres = match vec::last_opt(exs) { none { pres } some(f) { expr_poststate(fcx.ccx, f) }}; option::iter(maybe_base, |base| { changed |= find_pre_post_state_expr(fcx, base_pres, base) | @@ -366,7 +366,7 @@ fn find_pre_post_state_expr(fcx: fn_ctxt, pres: prestate, e: @expr) -> bool { set_poststate_ann(fcx.ccx, e.id, post); - alt maybe_ret_val { + match maybe_ret_val { none {/* do nothing */ } some(ret_val) { changed |= find_pre_post_state_expr(fcx, pres, ret_val); @@ -452,7 +452,7 @@ fn find_pre_post_state_expr(fcx: fn_ctxt, pres: prestate, e: @expr) -> bool { if vec::len(alts) > 0u { a_post = false_postcond(num_constrs); for alts.each |an_alt| { - alt an_alt.guard { + match an_alt.guard { some(e) { changed |= find_pre_post_state_expr(fcx, e_post, e); } @@ -512,9 +512,9 @@ fn find_pre_post_state_stmt(fcx: fn_ctxt, pres: prestate, s: @stmt) -> bool { debug!{"*prestate = %s", stmt_ann.states.prestate.to_str()}; debug!{"*poststate = %s", stmt_ann.states.prestate.to_str()}; - alt s.node { + match s.node { stmt_decl(adecl, id) { - alt adecl.node { + match adecl.node { decl_local(alocals) { set_prestate(stmt_ann, pres); let c_and_p = seq_states(fcx, pres, @@ -574,7 +574,7 @@ fn find_pre_post_state_block(fcx: fn_ctxt, pres0: prestate, b: blk) -> bool { pres = stmt_poststate(fcx.ccx, *s); } let mut post = pres; - alt b.node.expr { + match b.node.expr { none { } some(e) { changed |= find_pre_post_state_expr(fcx, pres, e); diff --git a/src/rustc/middle/tstate/tritv.rs b/src/rustc/middle/tstate/tritv.rs index ee2cf2d7a14..b6110121171 100644 --- a/src/rustc/middle/tstate/tritv.rs +++ b/src/rustc/middle/tstate/tritv.rs @@ -57,7 +57,7 @@ class t { } pure fn set(i: uint, t: trit) -> bool { let old = self.get(i); - alt t { + match t { dont_care { self.uncertain.set(i, true); self.val.set(i, false); @@ -103,7 +103,7 @@ class t { let mut rslt: ~[uint] = ~[]; for uint::range(0, self.nbits) |i| { vec::push(rslt, - alt self.get(i) { + match self.get(i) { dont_care { 2 } ttrue { 1 } tfalse { 0 } @@ -116,7 +116,7 @@ class t { let mut rs: str = ""; for uint::range(0, self.nbits) |i| { rs += - alt self.get(i) { + match self.get(i) { dont_care { "?" } ttrue { "1" } tfalse { "0" } @@ -177,10 +177,10 @@ fn minus(a: trit, b: trit) -> trit { 0 - 1 is an error 0 - anything else - 0 */ - alt a { + match a { dont_care { dont_care } ttrue { - alt b { + match b { ttrue { dont_care } tfalse { ttrue } /* internally contradictory, but @@ -191,7 +191,7 @@ fn minus(a: trit, b: trit) -> trit { } } tfalse { - alt b { + match b { ttrue { tfalse } /* see above comment */ _ { @@ -203,11 +203,11 @@ fn minus(a: trit, b: trit) -> trit { } fn trit_or(a: trit, b: trit) -> trit { - alt a { + match a { dont_care { b } ttrue { ttrue } tfalse { - alt b { + match b { ttrue { dont_care } /* FIXME (#2538): ?????? Again, unit tests would help here @@ -226,11 +226,11 @@ fn trit_or(a: trit, b: trit) -> trit { // to make it so that all constraints start out in a 0 state // (we consider a constraint false until proven true), too. fn trit_and(a: trit, b: trit) -> trit { - alt a { + match a { dont_care { b } // also seems wrong for case b = ttrue ttrue { - alt b { + match b { dont_care { ttrue } // ??? Seems wrong ttrue { diff --git a/src/rustc/middle/ty.rs b/src/rustc/middle/ty.rs index 210c4c9af86..814e0cc2f15 100644 --- a/src/rustc/middle/ty.rs +++ b/src/rustc/middle/ty.rs @@ -510,7 +510,7 @@ impl of purity_to_str for purity { fn param_bounds_to_kind(bounds: param_bounds) -> kind { let mut kind = kind_noncopyable(); for vec::each(*bounds) |bound| { - alt bound { + match bound { bound_copy => { kind = raise_kind(kind, kind_implicitly_copyable()); } @@ -608,14 +608,14 @@ fn mk_t(cx: ctxt, st: sty) -> t { mk_t_with_id(cx, st, none) } // and returns the box as cast to an unsafe ptr (see comments for t above). fn mk_t_with_id(cx: ctxt, st: sty, o_def_id: option<ast::def_id>) -> t { let key = {struct: st, o_def_id: o_def_id}; - alt cx.interner.find(key) { + match cx.interner.find(key) { some(t) => unsafe { return unsafe::reinterpret_cast(t); } _ => () } let mut flags = 0u; fn rflags(r: region) -> uint { (has_regions as uint) | { - alt r { + match r { ty::re_var(_) => needs_infer as uint, _ => 0u } @@ -627,7 +627,7 @@ fn mk_t_with_id(cx: ctxt, st: sty, o_def_id: option<ast::def_id>) -> t { substs.self_r.iter(|r| f |= rflags(r)); return f; } - alt st { + match st { ty_estr(vstore_slice(r)) => { flags |= rflags(r); } @@ -786,7 +786,7 @@ fn mk_with_id(cx: ctxt, base: t, def_id: ast::def_id) -> t { // Converts s to its machine type equivalent pure fn mach_sty(cfg: @session::config, t: t) -> sty { - alt get(t).struct { + match get(t).struct { ty_int(ast::ty_i) => ty_int(cfg.int_type), ty_uint(ast::ty_u) => ty_uint(cfg.uint_type), ty_float(ast::ty_f) => ty_float(cfg.float_type), @@ -802,7 +802,7 @@ fn default_arg_mode_for_ty(ty: ty::t) -> ast::rmode { // Returns the narrowest lifetime enclosing the evaluation of the expression // with id `id`. fn encl_region(cx: ctxt, id: ast::node_id) -> ty::region { - alt cx.region_map.find(id) { + match cx.region_map.find(id) { some(encl_scope) => ty::re_scope(encl_scope), none => ty::re_static } @@ -814,7 +814,7 @@ fn walk_ty(ty: t, f: fn(t)) { fn maybe_walk_ty(ty: t, f: fn(t) -> bool) { if !f(ty) { return; } - alt get(ty).struct { + match get(ty).struct { ty_nil | ty_bot | ty_bool | ty_int(_) | ty_uint(_) | ty_float(_) | ty_estr(_) | ty_type | ty_opaque_box | ty_self | ty_opaque_closure_ptr(_) | ty_var(_) | ty_var_integral(_) | @@ -851,7 +851,7 @@ fn fold_sty(sty: sty, fldop: fn(t) -> t) -> sty { tps: substs.tps.map(|t| fldop(t))} } - alt sty { + match sty { ty_box(tm) => { ty_box({ty: fldop(tm.ty), mutbl: tm.mutbl}) } @@ -947,7 +947,7 @@ fn fold_regions_and_ty( } let tb = ty::get(ty); - alt tb.struct { + match tb.struct { ty::ty_rptr(r, mt) => { let m_r = fldr(r); let m_t = fldt(mt.ty); @@ -1004,7 +1004,7 @@ fn fold_region(cx: ctxt, t0: t, fldop: fn(region, bool) -> region) -> t { fldop: fn(region, bool) -> region) -> t { let tb = get(t0); if !tbox_has_flag(tb, has_regions) { return t0; } - alt tb.struct { + match tb.struct { ty_rptr(r, {ty: t1, mutbl: m}) => { let m_r = fldop(r, under_r); let m_t1 = do_fold(cx, t1, true, fldop); @@ -1039,7 +1039,7 @@ fn subst_tps(cx: ctxt, tps: ~[t], typ: t) -> t { if tps.len() == 0u { return typ; } let tb = ty::get(typ); if !tbox_has_flag(tb, has_params) { return typ; } - alt tb.struct { + match tb.struct { ty_param(p) => tps[p.idx], sty => fold_sty_to_ty(cx, sty, |t| subst_tps(cx, tps, t)) } @@ -1076,13 +1076,13 @@ fn subst(cx: ctxt, typ: t) -> t { let tb = get(typ); if !tbox_has_flag(tb, needs_subst) { return typ; } - alt tb.struct { + match tb.struct { ty_param(p) => substs.tps[p.idx], ty_self => substs.self_ty.get(), _ => { fold_regions_and_ty( cx, typ, - |r| alt r { + |r| match r { re_bound(br_self) => substs.self_r.get(), _ => r }, @@ -1100,14 +1100,14 @@ fn type_is_nil(ty: t) -> bool { get(ty).struct == ty_nil } fn type_is_bot(ty: t) -> bool { get(ty).struct == ty_bot } fn type_is_var(ty: t) -> bool { - alt get(ty).struct { + match get(ty).struct { ty_var(_) => true, _ => false } } fn type_is_var_integral(ty: t) -> bool { - alt get(ty).struct { + match get(ty).struct { ty_var_integral(_) => true, _ => false } @@ -1116,7 +1116,7 @@ fn type_is_var_integral(ty: t) -> bool { fn type_is_bool(ty: t) -> bool { get(ty).struct == ty_bool } fn type_is_structural(ty: t) -> bool { - alt get(ty).struct { + match get(ty).struct { ty_rec(_) | ty_class(*) | ty_tup(_) | ty_enum(*) | ty_fn(_) | ty_trait(*) | ty_evec(_, vstore_fixed(_)) | ty_estr(vstore_fixed(_)) | @@ -1131,21 +1131,21 @@ fn type_is_copyable(cx: ctxt, ty: t) -> bool { } fn type_is_sequence(ty: t) -> bool { - alt get(ty).struct { + match get(ty).struct { ty_estr(_) | ty_evec(_, _) => true, _ => false } } fn type_is_str(ty: t) -> bool { - alt get(ty).struct { + match get(ty).struct { ty_estr(_) => true, _ => false } } fn sequence_element_type(cx: ctxt, ty: t) -> t { - alt get(ty).struct { + match get(ty).struct { ty_estr(_) => return mk_mach_uint(cx, ast::ty_u8), ty_evec(mt, _) | ty_unboxed_vec(mt) => return mt.ty, _ => cx.sess.bug( @@ -1154,7 +1154,7 @@ fn sequence_element_type(cx: ctxt, ty: t) -> t { } fn get_element_type(ty: t, i: uint) -> t { - alt get(ty).struct { + match get(ty).struct { ty_rec(flds) => return flds[i].mt.ty, ty_tup(ts) => return ts[i], _ => fail ~"get_element_type called on invalid type" @@ -1162,14 +1162,14 @@ fn get_element_type(ty: t, i: uint) -> t { } pure fn type_is_box(ty: t) -> bool { - alt get(ty).struct { + match get(ty).struct { ty_box(_) => return true, _ => return false } } pure fn type_is_boxed(ty: t) -> bool { - alt get(ty).struct { + match get(ty).struct { ty_box(_) | ty_opaque_box | ty_evec(_, vstore_box) | ty_estr(vstore_box) => true, _ => false @@ -1177,35 +1177,35 @@ pure fn type_is_boxed(ty: t) -> bool { } pure fn type_is_region_ptr(ty: t) -> bool { - alt get(ty).struct { + match get(ty).struct { ty_rptr(_, _) => true, _ => false } } pure fn type_is_slice(ty: t) -> bool { - alt get(ty).struct { + match get(ty).struct { ty_evec(_, vstore_slice(_)) | ty_estr(vstore_slice(_)) => true, _ => return false } } pure fn type_is_unique_box(ty: t) -> bool { - alt get(ty).struct { + match get(ty).struct { ty_uniq(_) => return true, _ => return false } } pure fn type_is_unsafe_ptr(ty: t) -> bool { - alt get(ty).struct { + match get(ty).struct { ty_ptr(_) => return true, _ => return false } } pure fn type_is_vec(ty: t) -> bool { - return alt get(ty).struct { + return match get(ty).struct { ty_evec(_, _) | ty_unboxed_vec(_) => true, ty_estr(_) => true, _ => false @@ -1213,7 +1213,7 @@ pure fn type_is_vec(ty: t) -> bool { } pure fn type_is_unique(ty: t) -> bool { - alt get(ty).struct { + match get(ty).struct { ty_uniq(_) => return true, ty_evec(_, vstore_uniq) => true, ty_estr(vstore_uniq) => true, @@ -1227,7 +1227,7 @@ pure fn type_is_unique(ty: t) -> bool { contents are abstract to rustc.) */ pure fn type_is_scalar(ty: t) -> bool { - alt get(ty).struct { + match get(ty).struct { ty_nil | ty_bool | ty_int(_) | ty_float(_) | ty_uint(_) | ty_var_integral(_) | ty_type | ty_ptr(_) => true, _ => false @@ -1240,13 +1240,13 @@ fn type_is_immediate(ty: t) -> bool { } fn type_needs_drop(cx: ctxt, ty: t) -> bool { - alt cx.needs_drop_cache.find(ty) { + match cx.needs_drop_cache.find(ty) { some(result) => return result, none => {/* fall through */ } } let mut accum = false; - let result = alt get(ty).struct { + let result = match get(ty).struct { // scalar types ty_nil | ty_bot | ty_bool | ty_int(_) | ty_float(_) | ty_uint(_) | ty_type | ty_ptr(_) | ty_rptr(_, _) | @@ -1286,7 +1286,7 @@ fn type_needs_drop(cx: ctxt, ty: t) -> bool { accum } ty_fn(fty) => { - alt fty.proto { + match fty.proto { proto_bare | proto_block => false, _ => true } @@ -1303,7 +1303,7 @@ fn type_needs_drop(cx: ctxt, ty: t) -> bool { // that only contain scalars and shared boxes can avoid unwind // cleanups. fn type_needs_unwind_cleanup(cx: ctxt, ty: t) -> bool { - alt cx.needs_unwind_cleanup_cache.find(ty) { + match cx.needs_unwind_cleanup_cache.find(ty) { some(result) => return result, none => () } @@ -1320,7 +1320,7 @@ fn type_needs_unwind_cleanup_(cx: ctxt, ty: t, encountered_box: bool) -> bool { // Prevent infinite recursion - alt tycache.find(ty) { + match tycache.find(ty) { some(_) => return false, none => { tycache.insert(ty, ()); } } @@ -1329,7 +1329,7 @@ fn type_needs_unwind_cleanup_(cx: ctxt, ty: t, let mut needs_unwind_cleanup = false; do maybe_walk_ty(ty) |ty| { let old_encountered_box = encountered_box; - let result = alt get(ty).struct { + let result = match get(ty).struct { ty_box(_) | ty_opaque_box => { encountered_box = true; true @@ -1528,7 +1528,7 @@ pure fn kind_is_owned(k: kind) -> bool { } fn proto_kind(p: proto) -> kind { - alt p { + match p { ast::proto_block => kind_noncopyable(), ast::proto_box => kind_safe_for_default_mode() | kind_owned(), ast::proto_uniq => kind_send_copy() | kind_owned(), @@ -1571,7 +1571,7 @@ fn test_kinds() { // This is used to prevent objects containing mutable state from being // implicitly copied and to compute whether things have const kind. fn mutability_kind(m: mutability) -> kind { - alt (m) { + match (m) { m_mutbl => remove_const(remove_implicit(kind_top())), m_const => remove_implicit(kind_top()), m_imm => kind_top() @@ -1583,7 +1583,7 @@ fn mutable_type_kind(cx: ctxt, ty: mt) -> kind { } fn type_kind(cx: ctxt, ty: t) -> kind { - alt cx.kind_cache.find(ty) { + match cx.kind_cache.find(ty) { some(result) => return result, none => {/* fall through */ } } @@ -1591,7 +1591,7 @@ fn type_kind(cx: ctxt, ty: t) -> kind { // Insert a default in case we loop back on self recursively. cx.kind_cache.insert(ty, kind_top()); - let mut result = alt get(ty).struct { + let mut result = match get(ty).struct { // Scalar and unique types are sendable, constant, and owned ty_nil | ty_bot | ty_bool | ty_int(_) | ty_uint(_) | ty_float(_) | ty_ptr(_) => { @@ -1743,7 +1743,7 @@ fn type_kind(cx: ctxt, ty: t) -> kind { /// gives a rough estimate of how much space it takes to represent /// an instance of `ty`. Used for the mode transition. fn type_size(cx: ctxt, ty: t) -> uint { - alt get(ty).struct { + match get(ty).struct { ty_nil | ty_bot | ty_bool | ty_int(_) | ty_uint(_) | ty_float(_) | ty_ptr(_) | ty_box(_) | ty_uniq(_) | ty_estr(vstore_uniq) | ty_trait(*) | ty_rptr(*) | ty_evec(_, vstore_uniq) | @@ -1828,7 +1828,7 @@ fn is_instantiable(cx: ctxt, r_ty: t) -> bool { ty_to_str(cx, r_ty), ty_to_str(cx, ty)}; - let r = alt get(ty).struct { + let r = match get(ty).struct { ty_nil | ty_bot | ty_bool | @@ -1919,7 +1919,7 @@ fn type_structurally_contains(cx: ctxt, ty: t, test: fn(sty) -> bool) -> let sty = get(ty).struct; debug!{"type_structurally_contains: %s", ty_to_str(cx, ty)}; if test(sty) { return true; } - alt sty { + match sty { ty_enum(did, substs) => { for vec::each(*enum_variants(cx, did)) |variant| { for variant.args.each |aty| { @@ -1960,7 +1960,7 @@ fn type_structurally_contains(cx: ctxt, ty: t, test: fn(sty) -> bool) -> fn type_structurally_contains_uniques(cx: ctxt, ty: t) -> bool { return type_structurally_contains(cx, ty, |sty| { - alt sty { + match sty { ty_uniq(_) | ty_evec(_, vstore_uniq) | ty_estr(vstore_uniq) => true, @@ -1970,14 +1970,14 @@ fn type_structurally_contains_uniques(cx: ctxt, ty: t) -> bool { } fn type_is_integral(ty: t) -> bool { - alt get(ty).struct { + match get(ty).struct { ty_var_integral(_) | ty_int(_) | ty_uint(_) | ty_bool => true, _ => false } } fn type_is_fp(ty: t) -> bool { - alt get(ty).struct { + match get(ty).struct { ty_float(_) => true, _ => false } @@ -1988,7 +1988,7 @@ fn type_is_numeric(ty: t) -> bool { } fn type_is_signed(ty: t) -> bool { - alt get(ty).struct { + match get(ty).struct { ty_int(_) => true, _ => false } @@ -1998,7 +1998,7 @@ fn type_is_signed(ty: t) -> bool { // that the cycle collector might care about. fn type_is_pod(cx: ctxt, ty: t) -> bool { let mut result = true; - alt get(ty).struct { + match get(ty).struct { // Scalar types ty_nil | ty_bot | ty_bool | ty_int(_) | ty_float(_) | ty_uint(_) | ty_type | ty_ptr(_) => result = true, @@ -2053,7 +2053,7 @@ fn type_is_pod(cx: ctxt, ty: t) -> bool { } fn type_is_enum(ty: t) -> bool { - alt get(ty).struct { + match get(ty).struct { ty_enum(_, _) => return true, _ => return false } @@ -2062,7 +2062,7 @@ fn type_is_enum(ty: t) -> bool { // Whether a type is enum like, that is a enum type with only nullary // constructors fn type_is_c_like_enum(cx: ctxt, ty: t) -> bool { - alt get(ty).struct { + match get(ty).struct { ty_enum(did, substs) => { let variants = enum_variants(cx, did); let some_n_ary = vec::any(*variants, |v| vec::len(v.args) > 0u); @@ -2073,7 +2073,7 @@ fn type_is_c_like_enum(cx: ctxt, ty: t) -> bool { } fn type_param(ty: t) -> option<uint> { - alt get(ty).struct { + match get(ty).struct { ty_param(p) => return some(p.idx), _ => {/* fall through */ } } @@ -2088,7 +2088,7 @@ fn deref(cx: ctxt, t: t, expl: bool) -> option<mt> { deref_sty(cx, get(t).struct, expl) } fn deref_sty(cx: ctxt, sty: sty, expl: bool) -> option<mt> { - alt sty { + match sty { ty_rptr(_, mt) | ty_box(mt) | ty_uniq(mt) => { some(mt) } @@ -2114,7 +2114,7 @@ fn deref_sty(cx: ctxt, sty: sty, expl: bool) -> option<mt> { fn type_autoderef(cx: ctxt, t: t) -> t { let mut t = t; loop { - alt deref(cx, t, false) { + match deref(cx, t, false) { none => return t, some(mt) => t = mt.ty } @@ -2127,7 +2127,7 @@ fn index(cx: ctxt, t: t) -> option<mt> { } fn index_sty(cx: ctxt, sty: sty) -> option<mt> { - alt sty { + match sty { ty_evec(mt, _) => some(mt), ty_estr(_) => some({ty: mk_u8(cx), mutbl: ast::m_imm}), _ => none @@ -2135,7 +2135,7 @@ fn index_sty(cx: ctxt, sty: sty) -> option<mt> { } pure fn hash_bound_region(br: &bound_region) -> uint { - alt *br { // no idea if this is any good + match *br { // no idea if this is any good ty::br_self => 0u, ty::br_anon => 1u, ty::br_named(str) => str::hash(str), @@ -2163,7 +2163,7 @@ pure fn hash_type_structure(st: sty) -> uint { h } pure fn hash_region(r: ®ion) -> uint { - alt *r { // no idea if this is any good + match *r { // no idea if this is any good re_bound(br) => (hash_bound_region(&br)) << 2u | 0u, re_free(id, br) => ((id as uint) << 4u) | (hash_bound_region(&br)) << 2u | 1u, @@ -2176,10 +2176,10 @@ pure fn hash_type_structure(st: sty) -> uint { let h = hash_subtys(h, substs.tps); h + substs.self_r.map_default(0u, |r| hash_region(&r)) } - alt st { + match st { ty_nil => 0u, ty_bool => 1u, - ty_int(t) => alt t { + ty_int(t) => match t { ast::ty_i => 2u, ast::ty_char => 3u, ast::ty_i8 => 4u, @@ -2187,14 +2187,14 @@ pure fn hash_type_structure(st: sty) -> uint { ast::ty_i32 => 6u, ast::ty_i64 => 7u } - ty_uint(t) => alt t { + ty_uint(t) => match t { ast::ty_u => 8u, ast::ty_u8 => 9u, ast::ty_u16 => 10u, ast::ty_u32 => 11u, ast::ty_u64 => 12u } - ty_float(t) => alt t { + ty_float(t) => match t { ast::ty_f => 13u, ast::ty_f32 => 14u, ast::ty_f64 => 15u @@ -2246,7 +2246,7 @@ pure fn hash_type_structure(st: sty) -> uint { } fn node_id_to_type(cx: ctxt, id: ast::node_id) -> t { - alt smallintmap::find(*cx.node_types, id as uint) { + match smallintmap::find(*cx.node_types, id as uint) { some(t) => t, none => cx.sess.bug(fmt!{"node_id_to_type: unbound node ID %s", ast_map::node_id_to_str(cx.items, id)}) @@ -2254,7 +2254,7 @@ fn node_id_to_type(cx: ctxt, id: ast::node_id) -> t { } fn node_id_to_type_params(cx: ctxt, id: ast::node_id) -> ~[t] { - alt cx.node_type_substs.find(id) { + match cx.node_type_substs.find(id) { none => return ~[], some(ts) => return ts } @@ -2266,35 +2266,35 @@ fn node_id_has_type_params(cx: ctxt, id: ast::node_id) -> bool { // Type accessors for substructures of types fn ty_fn_args(fty: t) -> ~[arg] { - alt get(fty).struct { + match get(fty).struct { ty_fn(f) => f.inputs, _ => fail ~"ty_fn_args() called on non-fn type" } } fn ty_fn_proto(fty: t) -> ast::proto { - alt get(fty).struct { + match get(fty).struct { ty_fn(f) => f.proto, _ => fail ~"ty_fn_proto() called on non-fn type" } } pure fn ty_fn_ret(fty: t) -> t { - alt get(fty).struct { + match get(fty).struct { ty_fn(f) => f.output, _ => fail ~"ty_fn_ret() called on non-fn type" } } fn ty_fn_ret_style(fty: t) -> ast::ret_style { - alt get(fty).struct { + match get(fty).struct { ty_fn(f) => f.ret_style, _ => fail ~"ty_fn_ret_style() called on non-fn type" } } fn is_fn_ty(fty: t) -> bool { - alt get(fty).struct { + match get(fty).struct { ty_fn(_) => return true, _ => return false } @@ -2312,14 +2312,14 @@ fn is_pred_ty(fty: t) -> bool { } fn ty_var_id(typ: t) -> tv_vid { - alt get(typ).struct { + match get(typ).struct { ty_var(vid) => return vid, _ => { error!{"ty_var_id called on non-var ty"}; fail; } } } fn ty_var_integral_id(typ: t) -> tvi_vid { - alt get(typ).struct { + match get(typ).struct { ty_var_integral(vid) => return vid, _ => { error!{"ty_var_integral_id called on ty other than \ ty_var_integral"}; @@ -2361,7 +2361,7 @@ fn expr_has_ty_params(cx: ctxt, expr: @ast::expr) -> bool { } fn expr_is_lval(method_map: typeck::method_map, e: @ast::expr) -> bool { - alt e.node { + match e.node { ast::expr_path(_) | ast::expr_unary(ast::deref, _) => true, ast::expr_field(_, _, _) | ast::expr_index(_, _) => { !method_map.contains_key(e.id) @@ -2371,7 +2371,7 @@ fn expr_is_lval(method_map: typeck::method_map, e: @ast::expr) -> bool { } fn stmt_node_id(s: @ast::stmt) -> ast::node_id { - alt s.node { + match s.node { ast::stmt_decl(_, id) | stmt_expr(_, id) | stmt_semi(_, id) => { return id; } @@ -2385,13 +2385,13 @@ fn field_idx(id: ast::ident, fields: ~[field]) -> option<uint> { } fn get_field(rec_ty: t, id: ast::ident) -> field { - alt check vec::find(get_fields(rec_ty), |f| str::eq(f.ident, id)) { + match check vec::find(get_fields(rec_ty), |f| str::eq(f.ident, id)) { some(f) => f } } fn get_fields(rec_ty:t) -> ~[field] { - alt check get(rec_ty).struct { + match check get(rec_ty).struct { ty_rec(fields) => fields } } @@ -2408,7 +2408,7 @@ fn method_idx(id: ast::ident, meths: ~[method]) -> option<uint> { fn param_tys_in_type(ty: t) -> ~[param_ty] { let mut rslt = ~[]; do walk_ty(ty) |ty| { - alt get(ty).struct { + match get(ty).struct { ty_param(p) => { vec::push(rslt, p); } @@ -2425,7 +2425,7 @@ fn occurs_check(tcx: ctxt, sp: span, vid: tv_vid, rt: t) { fn vars_in_type(ty: t) -> ~[tv_vid] { let mut rslt = ~[]; do walk_ty(ty) |ty| { - alt get(ty).struct { + match get(ty).struct { ty_var(v) => vec::push(rslt, v), _ => () } @@ -2454,8 +2454,8 @@ fn occurs_check(tcx: ctxt, sp: span, vid: tv_vid, rt: t) { // the current head value for `m0`. fn canon<T:copy>(tbl: hashmap<ast::node_id, ast::inferable<T>>, m0: ast::inferable<T>) -> ast::inferable<T> { - alt m0 { - ast::infer(id) => alt tbl.find(id) { + match m0 { + ast::infer(id) => match tbl.find(id) { none => m0, some(m1) => { let cm1 = canon(tbl, m1); @@ -2477,7 +2477,7 @@ fn canon_mode(cx: ctxt, m0: ast::mode) -> ast::mode { // Returns the head value for mode, failing if `m` was a infer(_) that // was never inferred. This should be safe for use after typeck. fn resolved_mode(cx: ctxt, m: ast::mode) -> ast::rmode { - alt canon_mode(cx, m) { + match canon_mode(cx, m) { ast::infer(_) => { cx.sess.bug(fmt!{"mode %? was never resolved", m}); } @@ -2490,7 +2490,7 @@ fn arg_mode(cx: ctxt, a: arg) -> ast::rmode { resolved_mode(cx, a.mode) } // Unifies `m1` and `m2`. Returns unified value or failure code. fn unify_mode(cx: ctxt, m1: ast::mode, m2: ast::mode) -> result<ast::mode, type_err> { - alt (canon_mode(cx, m1), canon_mode(cx, m2)) { + match (canon_mode(cx, m1), canon_mode(cx, m2)) { (m1, m2) if (m1 == m2) => { result::ok(m1) } @@ -2511,7 +2511,7 @@ fn unify_mode(cx: ctxt, m1: ast::mode, m2: ast::mode) // If `m` was never unified, unifies it with `m_def`. Returns the final value // for `m`. fn set_default_mode(cx: ctxt, m: ast::mode, m_def: ast::rmode) { - alt canon_mode(cx, m) { + match canon_mode(cx, m) { ast::infer(id) => { cx.inferred_modes.insert(id, ast::expl(m_def)); } @@ -2520,7 +2520,7 @@ fn set_default_mode(cx: ctxt, m: ast::mode, m_def: ast::rmode) { } fn ty_sort_str(cx: ctxt, t: t) -> ~str { - alt get(t).struct { + match get(t).struct { ty_nil | ty_bot | ty_bool | ty_int(_) | ty_uint(_) | ty_float(_) | ty_estr(_) | ty_type | ty_opaque_box | ty_opaque_closure_ptr(_) => { @@ -2548,14 +2548,14 @@ fn ty_sort_str(cx: ctxt, t: t) -> ~str { fn type_err_to_str(cx: ctxt, err: type_err) -> ~str { fn terr_vstore_kind_to_str(k: terr_vstore_kind) -> ~str { - alt k { terr_vec => ~"[]", terr_str => ~"str" } + match k { terr_vec => ~"[]", terr_str => ~"str" } } - alt err { + match err { terr_mismatch => return ~"types differ", terr_ret_style_mismatch(expect, actual) => { fn to_str(s: ast::ret_style) -> ~str { - alt s { + match s { ast::noreturn => ~"non-returning", ast::return_val => ~"return-by-value" } @@ -2631,7 +2631,7 @@ fn type_err_to_str(cx: ctxt, err: type_err) -> ~str { } fn def_has_ty_params(def: ast::def) -> bool { - alt def { + match def { ast::def_fn(_, _) | ast::def_variant(_, _) | ast::def_class(_, _) => true, _ => false @@ -2643,7 +2643,7 @@ fn store_trait_methods(cx: ctxt, id: ast::node_id, ms: @~[method]) { } fn trait_methods(cx: ctxt, id: ast::def_id) -> @~[method] { - alt cx.trait_method_cache.find(id) { + match cx.trait_method_cache.find(id) { some(ms) => return ms, _ => () } @@ -2657,7 +2657,7 @@ fn trait_methods(cx: ctxt, id: ast::def_id) -> @~[method] { fn impl_traits(cx: ctxt, id: ast::def_id) -> ~[t] { if id.crate == ast::local_crate { debug!{"(impl_traits) searching for trait impl %?", id}; - alt cx.items.find(id.node) { + match cx.items.find(id.node) { some(ast_map::node_item(@{ node: ast::item_impl(_, trait_refs, _, _), _}, @@ -2669,7 +2669,7 @@ fn impl_traits(cx: ctxt, id: ast::def_id) -> ~[t] { } some(ast_map::node_item(@{node: ast::item_class(*), _},_)) => { - alt cx.def_map.find(id.node) { + match cx.def_map.find(id.node) { some(def_ty(trait_id)) => { // XXX: Doesn't work cross-crate. debug!{"(impl_traits) found trait id %?", trait_id}; @@ -2692,7 +2692,7 @@ fn impl_traits(cx: ctxt, id: ast::def_id) -> ~[t] { } fn ty_to_def_id(ty: t) -> option<ast::def_id> { - alt get(ty).struct { + match get(ty).struct { ty_trait(id, _) | ty_class(id, _) | ty_enum(id, _) => some(id), _ => none } @@ -2723,7 +2723,7 @@ fn item_path_str(cx: ctxt, id: ast::def_id) -> ~str { Otherwise return none. */ fn ty_dtor(cx: ctxt, class_id: def_id) -> option<def_id> { if is_local(class_id) { - alt cx.items.find(class_id.node) { + match cx.items.find(class_id.node) { some(ast_map::node_item(@{node: ast::item_class(_, _, _, _, some(dtor)), _}, _)) => some(local_def(dtor.node.id)), @@ -2744,9 +2744,9 @@ fn item_path(cx: ctxt, id: ast::def_id) -> ast_map::path { csearch::get_item_path(cx, id) } else { let node = cx.items.get(id.node); - alt node { + match node { ast_map::node_item(item, path) => { - let item_elt = alt item.node { + let item_elt = match item.node { item_mod(_) | item_foreign_mod(_) => { ast_map::path_mod(item.ident) } @@ -2796,14 +2796,14 @@ fn enum_is_univariant(cx: ctxt, id: ast::def_id) -> bool { } fn type_is_empty(cx: ctxt, t: t) -> bool { - alt ty::get(t).struct { + match ty::get(t).struct { ty_enum(did, _) => (*enum_variants(cx, did)).is_empty(), _ => false } } fn enum_variants(cx: ctxt, id: ast::def_id) -> @~[variant_info] { - alt cx.enum_var_cache.find(id) { + match cx.enum_var_cache.find(id) { some(variants) => return variants, _ => { /* fallthrough */ } } @@ -2816,7 +2816,7 @@ fn enum_variants(cx: ctxt, id: ast::def_id) -> @~[variant_info] { call eval_const_expr, it should never get called twice for the same expr, since check_enum_variants also updates the enum_var_cache */ - alt cx.items.get(id.node) { + match cx.items.get(id.node) { ast_map::node_item(@{node: ast::item_enum(variants, _), _}, _) => { let mut disr_val = -1; @vec::map(variants, |variant| { @@ -2826,10 +2826,10 @@ fn enum_variants(cx: ctxt, id: ast::def_id) -> @~[variant_info] { ty_fn_args(ctor_ty).map(|a| a.ty) } else { ~[] } }; - alt variant.node.disr_expr { + match variant.node.disr_expr { some (ex) => { // FIXME: issue #1417 - disr_val = alt const_eval::eval_const_expr(cx, ex) { + disr_val = match const_eval::eval_const_expr(cx, ex) { const_eval::const_int(val) =>val as int, _ => cx.sess.bug(~"tag_variants: bad disr expr") } @@ -2869,7 +2869,7 @@ fn enum_variant_with_id(cx: ctxt, enum_id: ast::def_id, // If the given item is in an external crate, looks up its type and adds it to // the type cache. Returns the type parameters and type. fn lookup_item_type(cx: ctxt, did: ast::def_id) -> ty_param_bounds_and_ty { - alt cx.tcache.find(did) { + match cx.tcache.find(did) { some(tpt) => return tpt, none => { // The item is in this crate. The caller should have added it to the @@ -2891,7 +2891,7 @@ fn lookup_field_type(tcx: ctxt, class_id: def_id, id: def_id, node_id_to_type(tcx, id.node) } else { - alt tcx.tcache.find(id) { + match tcx.tcache.find(id) { some(tpt) => tpt.ty, none => { let tpt = csearch::get_field_type(tcx, class_id, id); @@ -2907,9 +2907,9 @@ fn lookup_field_type(tcx: ctxt, class_id: def_id, id: def_id, // Fails if the id is not bound to a class. fn lookup_class_fields(cx: ctxt, did: ast::def_id) -> ~[field_ty] { if did.crate == ast::local_crate { - alt cx.items.find(did.node) { + match cx.items.find(did.node) { some(ast_map::node_item(i,_)) => { - alt i.node { + match i.node { ast::item_class(_, _, items, _, _) => { class_field_tys(items) } @@ -2929,7 +2929,7 @@ fn lookup_class_fields(cx: ctxt, did: ast::def_id) -> ~[field_ty] { fn lookup_class_field(cx: ctxt, parent: ast::def_id, field_id: ast::def_id) -> field_ty { - alt vec::find(lookup_class_fields(cx, parent), + match vec::find(lookup_class_fields(cx, parent), |f| f.id.node == field_id.node) { some(t) => t, none => cx.sess.bug(~"class ID not found in parent's fields") @@ -2962,7 +2962,7 @@ fn lookup_class_method_by_name(cx:ctxt, did: ast::def_id, name: ident, -> ~[{name: ident, id: node_id, vis: visibility}] { assert is_local(did); - alt cx.items.find(did.node) { + match cx.items.find(did.node) { some(ast_map::node_item(@{ node: item_class(_,_,items,_,_), _ }, _)) => { @@ -2994,7 +2994,7 @@ fn lookup_class_method_by_name(cx:ctxt, did: ast::def_id, name: ident, fn class_field_tys(items: ~[@class_member]) -> ~[field_ty] { let mut rslt = ~[]; for items.each |it| { - alt it.node { + match it.node { instance_var(nm, _, cm, id, vis) => { vec::push(rslt, {ident: nm, id: ast_util::local_def(id), vis: vis, mutability: cm}); @@ -3020,7 +3020,7 @@ fn class_items_as_mutable_fields(cx:ctxt, did: ast::def_id, // mutability. fn class_items_as_fields(cx:ctxt, did: ast::def_id, substs: substs) -> ~[field] { - class_item_fields(cx, did, substs, |mt| alt mt { + class_item_fields(cx, did, substs, |mt| match mt { class_mutable => m_mutbl, class_immutable => m_imm }) } @@ -3058,7 +3058,7 @@ fn is_binopable(_cx: ctxt, ty: t, op: ast::binop) -> bool { const opcat_logic: int = 7; fn opcat(op: ast::binop) -> int { - alt op { + match op { ast::add => opcat_add, ast::subtract => opcat_sub, ast::mul => opcat_mult, @@ -3081,7 +3081,7 @@ fn is_binopable(_cx: ctxt, ty: t, op: ast::binop) -> bool { } fn tycat(ty: t) -> int { - alt get(ty).struct { + match get(ty).struct { ty_bool => tycat_bool, ty_int(_) | ty_uint(_) | ty_var_integral(_) => tycat_int, ty_float(_) => tycat_float, @@ -3126,7 +3126,7 @@ fn normalize_ty(cx: ctxt, t: t) -> t { } } - alt cx.normalized_cache.find(t) { + match cx.normalized_cache.find(t) { some(t) => return t, none => () } diff --git a/src/rustc/middle/typeck.rs b/src/rustc/middle/typeck.rs index a0c1d1da02f..e96fe4e8679 100644 --- a/src/rustc/middle/typeck.rs +++ b/src/rustc/middle/typeck.rs @@ -180,7 +180,7 @@ fn write_substs_to_tcx(tcx: ty::ctxt, } fn lookup_def_tcx(tcx: ty::ctxt, sp: span, id: ast::node_id) -> ast::def { - alt tcx.def_map.find(id) { + match tcx.def_map.find(id) { some(x) => x, _ => { tcx.sess.span_fatal(sp, ~"internal error looking up a definition") @@ -205,7 +205,7 @@ fn require_same_types( msg: fn() -> ~str) -> bool { let l_tcx, l_infcx; - alt maybe_infcx { + match maybe_infcx { none => { l_tcx = tcx; l_infcx = infer::new_infer_ctxt(tcx); @@ -216,7 +216,7 @@ fn require_same_types( } } - alt infer::mk_eqty(l_infcx, t1, t2) { + match infer::mk_eqty(l_infcx, t1, t2) { result::ok(()) => true, result::err(terr) => { l_tcx.sess.span_err(span, msg() + ~": " + @@ -227,10 +227,10 @@ fn require_same_types( } fn arg_is_argv_ty(_tcx: ty::ctxt, a: ty::arg) -> bool { - alt ty::get(a.ty).struct { + match ty::get(a.ty).struct { ty::ty_evec(mt, vstore_uniq) => { if mt.mutbl != ast::m_imm { return false; } - alt ty::get(mt.ty).struct { + match ty::get(mt.ty).struct { ty::ty_estr(vstore_uniq) => return true, _ => return false } @@ -245,12 +245,12 @@ fn check_main_fn_ty(ccx: @crate_ctxt, let tcx = ccx.tcx; let main_t = ty::node_id_to_type(tcx, main_id); - alt ty::get(main_t).struct { + match ty::get(main_t).struct { ty::ty_fn({purity: ast::impure_fn, proto: ast::proto_bare, inputs, output, ret_style: ast::return_val}) => { - alt tcx.items.find(main_id) { + match tcx.items.find(main_id) { some(ast_map::node_item(it,_)) => { - alt it.node { + match it.node { ast::item_fn(_,ps,_) if vec::is_not_empty(ps) => { tcx.sess.span_err(main_span, ~"main function is not allowed to have type parameters"); @@ -284,7 +284,7 @@ fn check_main_fn_ty(ccx: @crate_ctxt, fn check_for_main_fn(ccx: @crate_ctxt) { let tcx = ccx.tcx; if !tcx.sess.building_library { - alt copy tcx.sess.main_fn { + match copy tcx.sess.main_fn { some((id, sp)) => check_main_fn_ty(ccx, id, sp), none => tcx.sess.err(~"main function not found") } diff --git a/src/rustc/middle/typeck/astconv.rs b/src/rustc/middle/typeck/astconv.rs index 1211c5aa8d6..fffc70e9525 100644 --- a/src/rustc/middle/typeck/astconv.rs +++ b/src/rustc/middle/typeck/astconv.rs @@ -59,7 +59,7 @@ fn get_region_reporting_err(tcx: ty::ctxt, span: span, res: result<ty::region, ~str>) -> ty::region { - alt res { + match res { result::ok(r) => r, result::err(e) => { tcx.sess.span_err(span, e); @@ -71,7 +71,7 @@ fn get_region_reporting_err(tcx: ty::ctxt, fn ast_region_to_region<AC: ast_conv, RS: region_scope copy owned>( self: AC, rscope: RS, span: span, a_r: @ast::region) -> ty::region { - let res = alt a_r.node { + let res = match a_r.node { ast::re_anon => rscope.anon_region(), ast::re_named(id) => rscope.named_region(id) }; @@ -93,7 +93,7 @@ fn ast_path_to_substs_and_ty<AC: ast_conv, RS: region_scope copy owned>( // If the type is parameterized by the self region, then replace self // region with the current anon region binding (in other words, // whatever & would get replaced with). - let self_r = alt (decl_rp, path.rp) { + let self_r = match (decl_rp, path.rp) { (false, none) => { none } @@ -168,14 +168,14 @@ fn ast_ty_to_ty<AC: ast_conv, RS: region_scope copy owned>( let tcx = self.tcx(); - alt a_seq_ty.ty.node { + match a_seq_ty.ty.node { // to convert to an e{vec,str}, there can't be a mutability argument _ if a_seq_ty.mutbl != ast::m_imm => (), ast::ty_vec(mt) => { return ty::mk_evec(tcx, ast_mt_to_mt(self, rscope, mt), vst); } ast::ty_path(path, id) => { - alt tcx.def_map.find(id) { + match tcx.def_map.find(id) { some(ast::def_prim_ty(ast::ty_str)) => { check_path_args(tcx, path, NO_TPS | NO_REGIONS); return ty::mk_estr(tcx, vst); @@ -212,7 +212,7 @@ fn ast_ty_to_ty<AC: ast_conv, RS: region_scope copy owned>( let tcx = self.tcx(); - alt tcx.ast_ty_to_ty_cache.find(ast_ty) { + match tcx.ast_ty_to_ty_cache.find(ast_ty) { some(ty::atttce_resolved(ty)) => return ty, some(ty::atttce_unresolved) => { tcx.sess.span_fatal(ast_ty.span, ~"illegal recursive type; \ @@ -223,7 +223,7 @@ fn ast_ty_to_ty<AC: ast_conv, RS: region_scope copy owned>( } tcx.ast_ty_to_ty_cache.insert(ast_ty, ty::atttce_unresolved); - let typ = alt ast_ty.node { + let typ = match ast_ty.node { ast::ty_nil => ty::mk_nil(tcx), ast::ty_bot => ty::mk_bot(tcx), ast::ty_box(mt) => { @@ -265,17 +265,17 @@ fn ast_ty_to_ty<AC: ast_conv, RS: region_scope copy owned>( ty::mk_fn(tcx, ty_of_fn_decl(self, rscope, proto, decl, none)) } ast::ty_path(path, id) => { - let a_def = alt tcx.def_map.find(id) { + let a_def = match tcx.def_map.find(id) { none => tcx.sess.span_fatal(ast_ty.span, fmt!{"unbound path %s", path_to_str(path)}), some(d) => d }; - alt a_def { + match a_def { ast::def_ty(did) | ast::def_class(did, _) => { ast_path_to_ty(self, rscope, did, path, id).ty } ast::def_prim_ty(nty) => { - alt nty { + match nty { ast::ty_bool => { check_path_args(tcx, path, NO_TPS | NO_REGIONS); ty::mk_bool(tcx) @@ -356,20 +356,20 @@ fn ty_of_arg<AC: ast_conv, RS: region_scope copy owned>( self: AC, rscope: RS, a: ast::arg, expected_ty: option<ty::arg>) -> ty::arg { - let ty = alt a.ty.node { + let ty = match a.ty.node { ast::ty_infer if expected_ty.is_some() => expected_ty.get().ty, ast::ty_infer => self.ty_infer(a.ty.span), _ => ast_ty_to_ty(self, rscope, a.ty) }; let mode = { - alt a.mode { + match a.mode { ast::infer(_) if expected_ty.is_some() => { result::get(ty::unify_mode(self.tcx(), a.mode, expected_ty.get().mode)) } ast::infer(_) => { - alt ty::get(ty).struct { + match ty::get(ty).struct { // If the type is not specified, then this must be a fn expr. // Leave the mode as infer(_), it will get inferred based // on constraints elsewhere. @@ -417,7 +417,7 @@ fn ty_of_fn_decl<AC: ast_conv, RS: region_scope copy owned>( }; let expected_ret_ty = expected_tys.map(|e| e.output); - let output_ty = alt decl.output.node { + let output_ty = match decl.output.node { ast::ty_infer if expected_ret_ty.is_some() => expected_ret_ty.get(), ast::ty_infer => self.ty_infer(decl.output.span), _ => ast_ty_to_ty(self, rb, decl.output) diff --git a/src/rustc/middle/typeck/check.rs b/src/rustc/middle/typeck/check.rs index c875ac8c386..efe728f9e12 100644 --- a/src/rustc/middle/typeck/check.rs +++ b/src/rustc/middle/typeck/check.rs @@ -177,7 +177,7 @@ fn check_bare_fn(ccx: @crate_ctxt, id: ast::node_id, self_info: option<self_info>) { let fty = ty::node_id_to_type(ccx.tcx, id); - let fn_ty = alt check ty::get(fty).struct { ty::ty_fn(f) => f }; + let fn_ty = match check ty::get(fty).struct { ty::ty_fn(f) => f }; check_fn(ccx, self_info, fn_ty, decl, body, false, none); } @@ -216,7 +216,7 @@ fn check_fn(ccx: @crate_ctxt, // in the case of function expressions, based on the outer context. let fcx: @fn_ctxt = { let {infcx, locals, purity, node_types, node_type_substs} = - alt old_fcx { + match old_fcx { none => { {infcx: infer::new_infer_ctxt(tcx), locals: int_hash(), @@ -236,7 +236,7 @@ fn check_fn(ccx: @crate_ctxt, let indirect_ret_ty = if indirect_ret { let ofcx = option::get(old_fcx); - alt ofcx.indirect_ret_ty { + match ofcx.indirect_ret_ty { some(t) => some(t), none => some(ofcx.ret_ty) } @@ -260,7 +260,7 @@ fn check_fn(ccx: @crate_ctxt, // We unify the tail expr's type with the // function result type, if there is a tail expr. - alt body.node.expr { + match body.node.expr { some(tail_expr) => { let tail_expr_ty = fcx.expr_ty(tail_expr); demand::suptype(fcx, tail_expr.span, fcx.ret_ty, tail_expr_ty); @@ -293,7 +293,7 @@ fn check_fn(ccx: @crate_ctxt, let assign = fn@(nid: ast::node_id, ty_opt: option<ty::t>) { let var_id = fcx.infcx.next_ty_var_id(); fcx.locals.insert(nid, var_id); - alt ty_opt { + match ty_opt { none => {/* nothing to do */ } some(typ) => { infer::mk_eqty(fcx.infcx, ty::mk_var(tcx, var_id), typ); @@ -311,7 +311,7 @@ fn check_fn(ccx: @crate_ctxt, // Add explicitly-declared locals. let visit_local = fn@(local: @ast::local, &&e: (), v: visit::vt<()>) { - let o_ty = alt local.node.ty.node { + let o_ty = match local.node.ty.node { ast::ty_infer => none, _ => some(fcx.to_ty(local.node.ty)) }; @@ -324,7 +324,7 @@ fn check_fn(ccx: @crate_ctxt, // Add pattern bindings. let visit_pat = fn@(p: @ast::pat, &&e: (), v: visit::vt<()>) { - alt p.node { + match p.node { ast::pat_ident(_, path, _) if !pat_util::pat_is_variant(fcx.ccx.tcx.def_map, p) => { assign(p.id, none); @@ -371,7 +371,7 @@ fn check_method(ccx: @crate_ctxt, method: @ast::method, fn check_class_member(ccx: @crate_ctxt, class_t: self_info, cm: @ast::class_member) { - alt cm.node { + match cm.node { ast::instance_var(_,t,_,_,_) => (), ast::class_method(m) => check_method(ccx, m, class_t) } @@ -383,7 +383,7 @@ fn check_no_duplicate_fields(tcx: ty::ctxt, fields: |x,y| str::eq(*x, *y)); for fields.each |p| { let (id, sp) = p; - alt field_names.find(id) { + match field_names.find(id) { some(orig_sp) => { tcx.sess.span_err(sp, fmt!{"Duplicate field \ name %s in record type declaration", @@ -401,7 +401,7 @@ fn check_no_duplicate_fields(tcx: ty::ctxt, fields: } fn check_item(ccx: @crate_ctxt, it: @ast::item) { - alt it.node { + match it.node { ast::item_const(_, e) => check_const(ccx, it.span, e, it.id), ast::item_enum(vs, _) => { check_enum_variants(ccx, it.span, vs, it.id); @@ -419,7 +419,7 @@ fn check_item(ccx: @crate_ctxt, it: @ast::item) { } ast::item_trait(_, _, trait_methods) => { for trait_methods.each |trait_method| { - alt trait_method { + match trait_method { required(ty_m) => { // Nothing to do, since required methods don't have // bodies to check. @@ -471,7 +471,7 @@ fn check_item(ccx: @crate_ctxt, it: @ast::item) { let tpt_ty = ty::node_id_to_type(ccx.tcx, it.id); check_bounds_are_used(ccx, t.span, tps, tpt_ty); // If this is a record ty, check for duplicate fields - alt t.node { + match t.node { ast::ty_rec(fields) => { check_no_duplicate_fields(ccx.tcx, fields.map(|f| (f.node.ident, f.span))); @@ -519,7 +519,7 @@ impl of region_scope for @fn_ctxt { } fn named_region(id: ast::ident) -> result<ty::region, ~str> { do empty_rscope.named_region(id).chain_err |_e| { - alt self.in_scope_regions.find(ty::br_named(id)) { + match self.in_scope_regions.find(ty::br_named(id)) { some(r) => result::ok(r), none if *id == ~"blk" => self.block_region(), none => { @@ -564,7 +564,7 @@ impl methods for @fn_ctxt { } fn expr_ty(ex: @ast::expr) -> ty::t { - alt self.node_types.find(ex.id) { + match self.node_types.find(ex.id) { some(t) => t, none => { self.tcx().sess.bug(fmt!{"no type for expr %d (%s) in fcx %s", @@ -573,7 +573,7 @@ impl methods for @fn_ctxt { } } fn node_ty(id: ast::node_id) -> ty::t { - alt self.node_types.find(id) { + match self.node_types.find(id) { some(t) => t, none => { self.tcx().sess.bug( @@ -584,7 +584,7 @@ impl methods for @fn_ctxt { } } fn node_ty_substs(id: ast::node_id) -> ty::substs { - alt self.node_type_substs.find(id) { + match self.node_type_substs.find(id) { some(ts) => ts, none => { self.tcx().sess.bug( @@ -637,7 +637,7 @@ impl methods for @fn_ctxt { } fn require_unsafe(sp: span, op: ~str) { - alt self.purity { + match self.purity { ast::unsafe_fn => {/*ok*/} _ => { self.ccx.tcx.sess.span_err( @@ -662,9 +662,9 @@ fn do_autoderef(fcx: @fn_ctxt, sp: span, t: ty::t) -> ty::t { let sty = structure_of(fcx, sp, t1); // Some extra checks to detect weird cycles and so forth: - alt sty { + match sty { ty::ty_box(inner) | ty::ty_uniq(inner) | ty::ty_rptr(_, inner) => { - alt ty::get(t1).struct { + match ty::get(t1).struct { ty::ty_var(v1) => { ty::occurs_check(fcx.ccx.tcx, sp, v1, ty::mk_box(fcx.ccx.tcx, inner)); @@ -687,7 +687,7 @@ fn do_autoderef(fcx: @fn_ctxt, sp: span, t: ty::t) -> ty::t { } // Otherwise, deref if type is derefable: - alt ty::deref_sty(fcx.ccx.tcx, sty, false) { + match ty::deref_sty(fcx.ccx.tcx, sty, false) { none => return t1, some(mt) => t1 = mt.ty } @@ -698,7 +698,7 @@ fn do_autoderef(fcx: @fn_ctxt, sp: span, t: ty::t) -> ty::t { fn check_lit(fcx: @fn_ctxt, lit: @ast::lit) -> ty::t { let tcx = fcx.ccx.tcx; - alt lit.node { + match lit.node { ast::lit_str(s) => ty::mk_estr(tcx, ty::vstore_slice(ty::re_static)), ast::lit_int(_, t) => ty::mk_mach_int(tcx, t), ast::lit_uint(_, t) => ty::mk_mach_uint(tcx, t), @@ -740,7 +740,7 @@ fn impl_self_ty(fcx: @fn_ctxt, did: ast::def_id) -> ty_param_substs_and_ty { let {n_tps, rp, raw_ty} = if did.crate == ast::local_crate { let rp = fcx.tcx().region_paramd_items.contains_key(did.node); - alt check tcx.items.find(did.node) { + match check tcx.items.find(did.node) { some(ast_map::node_item(@{node: ast::item_impl(ts, _, st, _), _}, _)) => { {n_tps: ts.len(), @@ -818,7 +818,7 @@ fn check_expr_with_unifier(fcx: @fn_ctxt, // process the types bound by the function but not by any nested // functions. Therefore, we match one level of structure. let fn_ty = - alt structure_of(fcx, sp, in_fty) { + match structure_of(fcx, sp, in_fty) { sty @ ty::ty_fn(fn_ty) => { replace_bound_regions_in_fn_ty( fcx.ccx.tcx, @nil, none, fn_ty, @@ -872,7 +872,7 @@ fn check_expr_with_unifier(fcx: @fn_ctxt, // right way to do this. for [false, true]/_.each |check_blocks| { for args.eachi |i, a| { - let is_block = alt a.node { + let is_block = match a.node { ast::expr_fn_block(*) => true, _ => false }; @@ -905,7 +905,7 @@ fn check_expr_with_unifier(fcx: @fn_ctxt, // Index expressions need to be handled seperately, to inform // them that they appear in call position. - let mut bot = alt f.node { + let mut bot = match f.node { ast::expr_field(base, field, tys) => { check_field(fcx, f, true, base, field, tys) } @@ -922,7 +922,7 @@ fn check_expr_with_unifier(fcx: @fn_ctxt, }; // Pull the return type out of the type of the function. - alt structure_of(fcx, sp, fty) { + match structure_of(fcx, sp, fty) { ty::ty_fn(f) => { bot |= (f.ret_style == ast::noreturn); fcx.write_ty(call_expr_id, f.output); @@ -952,7 +952,7 @@ fn check_expr_with_unifier(fcx: @fn_ctxt, elsopt: option<@ast::expr>, id: ast::node_id, _sp: span) -> bool { let (if_t, if_bot) = - alt elsopt { + match elsopt { some(els) => { let if_t = fcx.infcx.next_ty_var(); let thn_bot = check_block(fcx, thn); @@ -976,7 +976,7 @@ fn check_expr_with_unifier(fcx: @fn_ctxt, -> option<(ty::t, bool)> { let lkup = method::lookup(fcx, op_ex, self_ex, op_ex.id, op_ex.callee_id, @opname, self_t, ~[], false); - alt lkup.method() { + match lkup.method() { some(origin) => { let {fty: method_ty, bot: bot} = { let method_ty = fcx.node_ty(op_ex.callee_id); @@ -998,7 +998,7 @@ fn check_expr_with_unifier(fcx: @fn_ctxt, let lhs_bot = check_expr(fcx, lhs, none); let lhs_t = fcx.expr_ty(lhs); let lhs_t = structurally_resolved_type(fcx, lhs.span, lhs_t); - return alt (op, ty::get(lhs_t).struct) { + return match (op, ty::get(lhs_t).struct) { (_, _) if ty::type_is_integral(lhs_t) && ast_util::is_shift_binop(op) => { // Shift is a special case: rhs can be any integral type @@ -1013,7 +1013,7 @@ fn check_expr_with_unifier(fcx: @fn_ctxt, let tvar = fcx.infcx.next_ty_var(); demand::suptype(fcx, expr.span, tvar, lhs_t); let rhs_bot = check_expr_with(fcx, rhs, tvar); - let rhs_t = alt op { + let rhs_t = match op { ast::eq | ast::lt | ast::le | ast::ne | ast::ge | ast::gt => { // these comparison operators are handled in a @@ -1042,9 +1042,9 @@ fn check_expr_with_unifier(fcx: @fn_ctxt, lhs_expr: @ast::expr, lhs_resolved_t: ty::t, op: ast::binop, rhs: @ast::expr) -> (ty::t, bool) { let tcx = fcx.ccx.tcx; - alt ast_util::binop_to_method_name(op) { + match ast_util::binop_to_method_name(op) { some(name) => { - alt lookup_op_method(fcx, ex, + match lookup_op_method(fcx, ex, lhs_expr, lhs_resolved_t, name, ~[rhs]) { some(pair) => return pair, @@ -1064,7 +1064,7 @@ fn check_expr_with_unifier(fcx: @fn_ctxt, // If the or operator is used it might be that the user forgot to // supply the do keyword. Let's be more helpful in that situation. if op == ast::or { - alt ty::get(lhs_resolved_t).struct { + match ty::get(lhs_resolved_t).struct { ty::ty_fn(f) => { tcx.sess.span_note( ex.span, ~"did you forget the 'do' keyword for the call?"); @@ -1078,7 +1078,7 @@ fn check_expr_with_unifier(fcx: @fn_ctxt, fn check_user_unop(fcx: @fn_ctxt, op_str: ~str, mname: ~str, ex: @ast::expr, rhs_expr: @ast::expr, rhs_t: ty::t) -> ty::t { - alt lookup_op_method(fcx, ex, rhs_expr, rhs_t, mname, ~[]) { + match lookup_op_method(fcx, ex, rhs_expr, rhs_t, mname, ~[]) { some((ret_ty, _)) => ret_ty, _ => { fcx.ccx.tcx.sess.span_err( @@ -1096,9 +1096,9 @@ fn check_expr_with_unifier(fcx: @fn_ctxt, fn unpack_expected<O: copy>(fcx: @fn_ctxt, expected: option<ty::t>, unpack: fn(ty::sty) -> option<O>) -> option<O> { - alt expected { + match expected { some(t) => { - alt resolve_type(fcx.infcx, t, force_tvar) { + match resolve_type(fcx.infcx, t, force_tvar) { result::ok(t) => unpack(ty::get(t).struct), _ => none } @@ -1121,7 +1121,7 @@ fn check_expr_with_unifier(fcx: @fn_ctxt, // def'n of br_cap_avoid() for a more lengthy explanation of // what's going on here. let expected_tys = do unpack_expected(fcx, expected) |sty| { - alt sty { + match sty { ty::ty_fn(fn_ty) => { let {fn_ty, _} = replace_bound_regions_in_fn_ty( @@ -1160,9 +1160,9 @@ fn check_expr_with_unifier(fcx: @fn_ctxt, let base_t = do_autoderef(fcx, expr.span, expr_t); let mut handled = false; let n_tys = vec::len(tys); - alt structure_of(fcx, expr.span, base_t) { + match structure_of(fcx, expr.span, base_t) { ty::ty_rec(fields) => { - alt ty::field_idx(field, fields) { + match ty::field_idx(field, fields) { some(ix) => { if n_tys > 0u { tcx.sess.span_err(expr.span, @@ -1194,7 +1194,7 @@ fn check_expr_with_unifier(fcx: @fn_ctxt, else { lookup_public_fields(tcx, base_id) }; - alt lookup_field_ty(tcx, base_id, cls_items, field, substs) { + match lookup_field_ty(tcx, base_id, cls_items, field, substs) { some(field_ty) => { // (2) look up what field's type is, and return it fcx.write_ty(expr.id, field_ty); @@ -1216,7 +1216,7 @@ fn check_expr_with_unifier(fcx: @fn_ctxt, let lkup = method::lookup(fcx, expr, base, borrow_lb, expr.id, field, expr_t, tps, is_self_ref); - alt lkup.method() { + match lkup.method() { some(entry) => { fcx.ccx.method_map.insert(expr.id, entry); @@ -1248,9 +1248,9 @@ fn check_expr_with_unifier(fcx: @fn_ctxt, let tcx = fcx.ccx.tcx; let id = expr.id; let mut bot = false; - alt expr.node { + match expr.node { ast::expr_vstore(ev, vst) => { - let typ = alt ev.node { + let typ = match ev.node { ast::expr_lit(@{node: ast::lit_str(s), span:_}) => { let tt = ast_expr_vstore_to_vstore(fcx, ev, str::len(*s), vst); ty::mk_estr(tcx, tt) @@ -1315,8 +1315,8 @@ fn check_expr_with_unifier(fcx: @fn_ctxt, } ast::expr_unary(unop, oprnd) => { let exp_inner = do unpack_expected(fcx, expected) |sty| { - alt unop { - ast::box(_) | ast::uniq(_) => alt sty { + match unop { + ast::box(_) | ast::uniq(_) => match sty { ty::ty_box(mt) | ty::ty_uniq(mt) => some(mt.ty), _ => none } @@ -1326,7 +1326,7 @@ fn check_expr_with_unifier(fcx: @fn_ctxt, }; bot = check_expr(fcx, oprnd, exp_inner); let mut oprnd_t = fcx.expr_ty(oprnd); - alt unop { + match unop { ast::box(mutbl) => { oprnd_t = ty::mk_box(tcx, {ty: oprnd_t, mutbl: mutbl}); } @@ -1338,7 +1338,7 @@ fn check_expr_with_unifier(fcx: @fn_ctxt, // deref'ing an unsafe pointer requires that we be in an unsafe // context - alt sty { + match sty { ty::ty_ptr(*) => { fcx.require_unsafe( expr.span, @@ -1347,10 +1347,10 @@ fn check_expr_with_unifier(fcx: @fn_ctxt, _ => { /*ok*/ } } - alt ty::deref_sty(tcx, sty, true) { + match ty::deref_sty(tcx, sty, true) { some(mt) => { oprnd_t = mt.ty } none => { - alt sty { + match sty { ty::ty_enum(*) => { tcx.sess.span_err( expr.span, @@ -1389,7 +1389,7 @@ fn check_expr_with_unifier(fcx: @fn_ctxt, } ast::expr_addr_of(mutbl, oprnd) => { bot = check_expr(fcx, oprnd, unpack_expected(fcx, expected, |ty| - alt ty { ty::ty_rptr(_, mt) => some(mt.ty), _ => none } + match ty { ty::ty_rptr(_, mt) => some(mt.ty), _ => none } )); //let region = region_of(fcx, oprnd); let region = fcx.infcx.next_region_var_with_scope_lb(expr.id); @@ -1406,7 +1406,7 @@ fn check_expr_with_unifier(fcx: @fn_ctxt, ast::expr_mac(_) => tcx.sess.bug(~"unexpanded macro"), ast::expr_fail(expr_opt) => { bot = true; - alt expr_opt { + match expr_opt { none => {/* do nothing */ } some(e) => { check_expr_with(fcx, e, @@ -1419,11 +1419,11 @@ fn check_expr_with_unifier(fcx: @fn_ctxt, ast::expr_again => { fcx.write_bot(id); bot = true; } ast::expr_ret(expr_opt) => { bot = true; - let ret_ty = alt fcx.indirect_ret_ty { + let ret_ty = match fcx.indirect_ret_ty { some(t) => t, none => fcx.ret_ty }; - alt expr_opt { - none => alt fcx.mk_eqty(ret_ty, ty::mk_nil(tcx)) { + match expr_opt { + none => match fcx.mk_eqty(ret_ty, ty::mk_nil(tcx)) { result::ok(_) => { /* fall through */ } result::err(_) => { tcx.sess.span_err( @@ -1482,7 +1482,7 @@ fn check_expr_with_unifier(fcx: @fn_ctxt, ast::expr_fn_block(decl, body, cap_clause) => { // Take the prototype from the expected type, but default to block: let proto = unpack_expected(fcx, expected, |sty| - alt sty { ty::ty_fn({proto, _}) => some(proto), _ => none } + match sty { ty::ty_fn({proto, _}) => some(proto), _ => none } ).get_default(ast::proto_box); check_expr_fn(fcx, expr, proto, decl, body, false, expected); capture::check_capture_clause(tcx, expr.id, cap_clause); @@ -1495,9 +1495,9 @@ fn check_expr_with_unifier(fcx: @fn_ctxt, // 1. a closure that returns a bool is expected // 2. the cloure that was given returns unit let expected_sty = unpack_expected(fcx, expected, |x| some(x)); - let (inner_ty, proto) = alt expected_sty { + let (inner_ty, proto) = match expected_sty { some(ty::ty_fn(fty)) => { - alt infer::mk_subty(fcx.infcx, fty.output, ty::mk_bool(tcx)) { + match infer::mk_subty(fcx.infcx, fty.output, ty::mk_bool(tcx)) { result::ok(_) => (), result::err(err) => { tcx.sess.span_fatal( @@ -1514,7 +1514,7 @@ fn check_expr_with_unifier(fcx: @fn_ctxt, type"); } }; - alt check b.node { + match check b.node { ast::expr_fn_block(decl, body, cap_clause) => { check_expr_fn(fcx, b, proto, decl, body, true, some(inner_ty)); demand::suptype(fcx, b.span, inner_ty, fcx.expr_ty(b)); @@ -1523,7 +1523,7 @@ fn check_expr_with_unifier(fcx: @fn_ctxt, } let block_ty = structurally_resolved_type( fcx, expr.span, fcx.node_ty(b.id)); - alt check ty::get(block_ty).struct { + match check ty::get(block_ty).struct { ty::ty_fn(fty) => { fcx.write_ty(expr.id, ty::mk_fn(tcx, {output: ty::mk_bool(tcx) with fty})); @@ -1532,7 +1532,7 @@ fn check_expr_with_unifier(fcx: @fn_ctxt, } ast::expr_do_body(b) => { let expected_sty = unpack_expected(fcx, expected, |x| some(x)); - let (inner_ty, proto) = alt expected_sty { + let (inner_ty, proto) = match expected_sty { some(ty::ty_fn(fty)) => { (ty::mk_fn(tcx, fty), fty.proto) } @@ -1542,7 +1542,7 @@ fn check_expr_with_unifier(fcx: @fn_ctxt, passed to a `do` function"); } }; - alt check b.node { + match check b.node { ast::expr_fn_block(decl, body, cap_clause) => { check_expr_fn(fcx, b, proto, decl, body, true, some(inner_ty)); demand::suptype(fcx, b.span, inner_ty, fcx.expr_ty(b)); @@ -1551,7 +1551,7 @@ fn check_expr_with_unifier(fcx: @fn_ctxt, } let block_ty = structurally_resolved_type( fcx, expr.span, fcx.node_ty(b.id)); - alt check ty::get(block_ty).struct { + match check ty::get(block_ty).struct { ty::ty_fn(fty) => { fcx.write_ty(expr.id, ty::mk_fn(tcx, fty)); } @@ -1561,7 +1561,7 @@ fn check_expr_with_unifier(fcx: @fn_ctxt, // If this is an unchecked block, turn off purity-checking bot = check_block(fcx, b); let typ = - alt b.node.expr { + match b.node.expr { some(expr) => fcx.expr_ty(expr), none => ty::mk_nil(tcx) }; @@ -1578,7 +1578,7 @@ fn check_expr_with_unifier(fcx: @fn_ctxt, debug!{"t_1=%s", fcx.infcx.ty_to_str(t_1)}; debug!{"t_e=%s", fcx.infcx.ty_to_str(t_e)}; - alt ty::get(t_1).struct { + match ty::get(t_1).struct { // This will be looked up later on ty::ty_trait(*) => (), @@ -1631,7 +1631,7 @@ fn check_expr_with_unifier(fcx: @fn_ctxt, let mut elt_ts = ~[]; vec::reserve(elt_ts, vec::len(elts)); let flds = unpack_expected(fcx, expected, |sty| { - alt sty { ty::ty_tup(flds) => some(flds), _ => none } + match sty { ty::ty_tup(flds) => some(flds), _ => none } }); for elts.eachi |i, e| { check_expr(fcx, e, flds.map(|fs| fs[i])); @@ -1647,7 +1647,7 @@ fn check_expr_with_unifier(fcx: @fn_ctxt, some(fcx.expr_ty(base.get())) } else { expected }; let flds = unpack_expected(fcx, expected, |sty| - alt sty { ty::ty_rec(flds) => some(flds), _ => none } + match sty { ty::ty_rec(flds) => some(flds), _ => none } ); let fields_t = vec::map(fields, |f| { bot |= check_expr(fcx, f.node.expr, flds.chain(|flds| @@ -1659,7 +1659,7 @@ fn check_expr_with_unifier(fcx: @fn_ctxt, // should be f.node.expr.span, not f.span respan(f.node.expr.span, {ident: f.node.ident, mt: expr_mt}) }); - alt base { + match base { none => { fn get_node(f: spanned<field>) -> field { f.node } let typ = ty::mk_rec(tcx, vec::map(fields_t, get_node)); @@ -1674,7 +1674,7 @@ fn check_expr_with_unifier(fcx: @fn_ctxt, } some(bexpr) => { let bexpr_t = fcx.expr_ty(bexpr); - let base_fields = alt structure_of(fcx, expr.span, bexpr_t) { + let base_fields = match structure_of(fcx, expr.span, bexpr_t) { ty::ty_rec(flds) => flds, _ => { tcx.sess.span_fatal(expr.span, @@ -1702,7 +1702,7 @@ fn check_expr_with_unifier(fcx: @fn_ctxt, ast::expr_struct(path, fields, base_expr) => { // Resolve the path. let class_id; - alt tcx.def_map.find(id) { + match tcx.def_map.find(id) { some(ast::def_class(type_def_id, _)) => { class_id = type_def_id; } @@ -1718,7 +1718,7 @@ fn check_expr_with_unifier(fcx: @fn_ctxt, if class_id.crate == ast::local_crate { region_parameterized = tcx.region_paramd_items.contains_key(class_id.node); - alt tcx.items.find(class_id.node) { + match tcx.items.find(class_id.node) { some(ast_map::node_item(@{ node: ast::item_class(type_parameters, _, _, _, _), _ @@ -1779,7 +1779,7 @@ fn check_expr_with_unifier(fcx: @fn_ctxt, // Typecheck each field. for fields.each |field| { - alt class_field_map.find(*field.node.ident) { + match class_field_map.find(*field.node.ident) { none => { tcx.sess.span_err(field.span, fmt!{"structure has no field named \ @@ -1848,7 +1848,7 @@ fn check_expr_with_unifier(fcx: @fn_ctxt, let base_t = do_autoderef(fcx, expr.span, raw_base_t); bot |= check_expr(fcx, idx, none); let idx_t = fcx.expr_ty(idx); - alt ty::index_sty(tcx, structure_of(fcx, expr.span, base_t)) { + match ty::index_sty(tcx, structure_of(fcx, expr.span, base_t)) { some(mt) => { require_integral(fcx, idx.span, idx_t); fcx.write_ty(id, mt.ty); @@ -1856,7 +1856,7 @@ fn check_expr_with_unifier(fcx: @fn_ctxt, none => { let resolved = structurally_resolved_type(fcx, expr.span, raw_base_t); - alt lookup_op_method(fcx, expr, base, resolved, ~"index", + match lookup_op_method(fcx, expr, base, resolved, ~"index", ~[idx]) { some((ret_ty, _)) => fcx.write_ty(id, ret_ty), _ => { @@ -1874,7 +1874,7 @@ fn check_expr_with_unifier(fcx: @fn_ctxt, debug!{"type of expr %s is %s, expected is %s", syntax::print::pprust::expr_to_str(expr), ty_to_str(tcx, fcx.expr_ty(expr)), - alt expected { + match expected { some(t) => ty_to_str(tcx, t), _ => ~"empty" }}; @@ -1904,7 +1904,7 @@ fn check_decl_local(fcx: @fn_ctxt, local: @ast::local) -> bool { let t = ty::mk_var(fcx.ccx.tcx, fcx.locals.get(local.node.id)); fcx.write_ty(local.node.id, t); - alt local.node.init { + match local.node.init { some(init) => { bot = check_decl_initializer(fcx, local.node.id, init); } @@ -1927,10 +1927,10 @@ fn check_decl_local(fcx: @fn_ctxt, local: @ast::local) -> bool { fn check_stmt(fcx: @fn_ctxt, stmt: @ast::stmt) -> bool { let mut node_id; let mut bot = false; - alt stmt.node { + match stmt.node { ast::stmt_decl(decl, id) => { node_id = id; - alt decl.node { + match decl.node { ast::decl_local(ls) => for ls.each |l| { bot |= check_decl_local(fcx, l); } @@ -1961,7 +1961,7 @@ fn check_block_no_value(fcx: @fn_ctxt, blk: ast::blk) -> bool { } fn check_block(fcx0: @fn_ctxt, blk: ast::blk) -> bool { - let fcx = alt blk.node.rules { + let fcx = match blk.node.rules { ast::unchecked_blk => @fn_ctxt_({purity: ast::impure_fn with **fcx0}), ast::unsafe_blk => @fn_ctxt_({purity: ast::unsafe_fn with **fcx0}), ast::default_blk => fcx0 @@ -1971,7 +1971,7 @@ fn check_block(fcx0: @fn_ctxt, blk: ast::blk) -> bool { let mut warned = false; for blk.node.stmts.each |s| { if bot && !warned && - alt s.node { + match s.node { ast::stmt_decl(@{node: ast::decl_local(_), _}, _) | ast::stmt_expr(_, _) | ast::stmt_semi(_, _) => { true @@ -1983,7 +1983,7 @@ fn check_block(fcx0: @fn_ctxt, blk: ast::blk) -> bool { } bot |= check_stmt(fcx, s); } - alt blk.node.expr { + match blk.node.expr { none => fcx.write_nil(blk.node.id), some(e) => { if bot && !warned { @@ -2044,7 +2044,7 @@ fn check_enum_variants(ccx: @crate_ctxt, let mut disr_val = 0; let mut variants = ~[]; for vs.each |v| { - alt v.node.disr_expr { + match v.node.disr_expr { some(e) => { let fcx = blank_fn_ctxt(ccx, rty, e.id); check_expr(fcx, e, none); @@ -2055,7 +2055,7 @@ fn check_enum_variants(ccx: @crate_ctxt, // Also, check_expr (from check_const pass) doesn't guarantee that // the expression in an form that eval_const_expr can handle, so // we may still get an internal compiler error - alt const_eval::eval_const_expr(ccx.tcx, e) { + match const_eval::eval_const_expr(ccx.tcx, e) { const_eval::const_int(val) => { disr_val = val as int; } @@ -2088,7 +2088,7 @@ fn check_enum_variants(ccx: @crate_ctxt, // Check that it is possible to represent this enum: let mut outer = true, did = local_def(id); if ty::type_structurally_contains(ccx.tcx, rty, |sty| { - alt sty { + match sty { ty::ty_enum(id, _) if id == did => { if outer { outer = false; false } else { true } @@ -2119,7 +2119,7 @@ fn self_ref(fcx: @fn_ctxt, id: ast::node_id) -> bool { } fn lookup_local(fcx: @fn_ctxt, sp: span, id: ast::node_id) -> tv_vid { - alt fcx.locals.find(id) { + match fcx.locals.find(id) { some(x) => x, _ => { fcx.ccx.tcx.sess.span_fatal(sp, @@ -2136,7 +2136,7 @@ fn lookup_def(fcx: @fn_ctxt, sp: span, id: ast::node_id) -> ast::def { fn ty_param_bounds_and_ty_for_def(fcx: @fn_ctxt, sp: span, defn: ast::def) -> ty_param_bounds_and_ty { - alt defn { + match defn { ast::def_arg(nid, _) => { assert (fcx.locals.contains_key(nid)); let typ = ty::mk_var(fcx.ccx.tcx, lookup_local(fcx, sp, nid)); @@ -2148,7 +2148,7 @@ fn ty_param_bounds_and_ty_for_def(fcx: @fn_ctxt, sp: span, defn: ast::def) -> return no_params(typ); } ast::def_self(_) => { - alt fcx.self_info { + match fcx.self_info { some(self_info) => { return no_params(self_info.self_ty); } @@ -2223,7 +2223,7 @@ fn instantiate_path(fcx: @fn_ctxt, // determine the region bound, using the value given by the user // (if any) and otherwise using a fresh region variable - let self_r = alt pth.rp { + let self_r = match pth.rp { some(r) if !tpt.rp => { fcx.ccx.tcx.sess.span_err (sp, ~"this item is not region-parameterized"); @@ -2267,7 +2267,7 @@ fn instantiate_path(fcx: @fn_ctxt, // Resolves `typ` by a single level if `typ` is a type variable. If no // resolution is possible, then an error is reported. fn structurally_resolved_type(fcx: @fn_ctxt, sp: span, tp: ty::t) -> ty::t { - alt infer::resolve_type(fcx.infcx, tp, force_tvar) { + match infer::resolve_type(fcx.infcx, tp, force_tvar) { result::ok(t_s) if !ty::type_is_var(t_s) => return t_s, _ => { fcx.ccx.tcx.sess.span_fatal @@ -2298,7 +2298,7 @@ fn type_is_c_like_enum(fcx: @fn_ctxt, sp: span, typ: ty::t) -> bool { fn ast_expr_vstore_to_vstore(fcx: @fn_ctxt, e: @ast::expr, n: uint, v: ast::vstore) -> ty::vstore { - alt v { + match v { ast::vstore_fixed(none) => ty::vstore_fixed(n), ast::vstore_fixed(some(u)) => { if n != u { @@ -2309,7 +2309,7 @@ fn ast_expr_vstore_to_vstore(fcx: @fn_ctxt, e: @ast::expr, n: uint, } ast::vstore_uniq => ty::vstore_uniq, ast::vstore_box => ty::vstore_box, - ast::vstore_slice(a_r) => alt fcx.block_region() { + ast::vstore_slice(a_r) => match fcx.block_region() { result::ok(b_r) => { let rscope = in_anon_rscope(fcx, b_r); let r = astconv::ast_region_to_region(fcx, rscope, e.span, a_r); @@ -2335,7 +2335,7 @@ fn check_bounds_are_used(ccx: @crate_ctxt, ccx.tcx, ty, |_r| {}, |t| { - alt ty::get(t).struct { + match ty::get(t).struct { ty::ty_param({idx, _}) => { tps_used[idx] = true; } _ => () } @@ -2358,7 +2358,7 @@ fn check_intrinsic_type(ccx: @crate_ctxt, it: @ast::foreign_item) { {mode: ast::expl(m), ty: ty} } let tcx = ccx.tcx; - let (n_tps, inputs, output) = alt *it.ident { + let (n_tps, inputs, output) = match *it.ident { ~"size_of" | ~"pref_align_of" | ~"min_align_of" => (1u, ~[], ty::mk_uint(ccx.tcx)), ~"init" => (1u, ~[], param(ccx, 0u)), diff --git a/src/rustc/middle/typeck/check/alt.rs b/src/rustc/middle/typeck/check/alt.rs index 316ef5a8927..2de26873316 100644 --- a/src/rustc/middle/typeck/check/alt.rs +++ b/src/rustc/middle/typeck/check/alt.rs @@ -29,7 +29,7 @@ fn check_alt(fcx: @fn_ctxt, let mut result_ty = fcx.infcx.next_ty_var(); let mut arm_non_bot = false; for arms.each |arm| { - alt arm.guard { + match arm.guard { some(e) => { check_expr_with(fcx, e, ty::mk_bool(tcx)); }, none => () } @@ -68,7 +68,7 @@ fn check_pat_variant(pcx: pat_ctxt, pat: @ast::pat, path: @ast::path, instantiate_path(pcx.fcx, path, enum_tpt, pat.span, pat.id); // Take the enum type params out of `expected`. - alt structure_of(pcx.fcx, pat.span, expected) { + match structure_of(pcx.fcx, pat.span, expected) { ty::ty_enum(_, expected_substs) => { // check that the type of the value being matched is a subtype // of the type of the pattern: @@ -82,7 +82,7 @@ fn check_pat_variant(pcx: pat_ctxt, pat: @ast::pat, path: @ast::path, tcx, v_def_ids.enm, v_def_ids.var); vinfo.args.map(|t| { ty::subst(tcx, expected_substs, t) }) }; - let arg_len = arg_types.len(), subpats_len = alt subpats { + let arg_len = arg_types.len(), subpats_len = match subpats { none => arg_len, some(ps) => ps.len() }; @@ -127,7 +127,7 @@ fn check_pat(pcx: pat_ctxt, pat: @ast::pat, expected: ty::t) { let fcx = pcx.fcx; let tcx = pcx.fcx.ccx.tcx; - alt pat.node { + match pat.node { ast::pat_wild => { fcx.write_ty(pat.id, expected); } @@ -167,7 +167,7 @@ fn check_pat(pcx: pat_ctxt, pat: @ast::pat, expected: ty::t) { demand::suptype(fcx, pat.span, ct, typ); } fcx.write_ty(pat.id, typ); - alt sub { + match sub { some(p) => check_pat(pcx, p, expected), _ => () } @@ -179,7 +179,7 @@ fn check_pat(pcx: pat_ctxt, pat: @ast::pat, expected: ty::t) { check_pat_variant(pcx, pat, path, subpats, expected); } ast::pat_rec(fields, etc) => { - let ex_fields = alt structure_of(fcx, pat.span, expected) { + let ex_fields = match structure_of(fcx, pat.span, expected) { ty::ty_rec(fields) => fields, _ => { tcx.sess.span_fatal @@ -201,7 +201,7 @@ fn check_pat(pcx: pat_ctxt, pat: @ast::pat, expected: ty::t) { str::eq(name, f.ident) } for fields.each |f| { - alt vec::find(ex_fields, |a| matches(f.ident, a)) { + match vec::find(ex_fields, |a| matches(f.ident, a)) { some(field) => { check_pat(pcx, f.pat, field.mt.ty); } @@ -216,7 +216,7 @@ fn check_pat(pcx: pat_ctxt, pat: @ast::pat, expected: ty::t) { fcx.write_ty(pat.id, expected); } ast::pat_tup(elts) => { - let ex_elts = alt structure_of(fcx, pat.span, expected) { + let ex_elts = match structure_of(fcx, pat.span, expected) { ty::ty_tup(elts) => elts, _ => { tcx.sess.span_fatal @@ -241,7 +241,7 @@ fn check_pat(pcx: pat_ctxt, pat: @ast::pat, expected: ty::t) { fcx.write_ty(pat.id, expected); } ast::pat_box(inner) => { - alt structure_of(fcx, pat.span, expected) { + match structure_of(fcx, pat.span, expected) { ty::ty_box(e_inner) => { check_pat(pcx, inner, e_inner.ty); fcx.write_ty(pat.id, expected); @@ -256,7 +256,7 @@ fn check_pat(pcx: pat_ctxt, pat: @ast::pat, expected: ty::t) { } } ast::pat_uniq(inner) => { - alt structure_of(fcx, pat.span, expected) { + match structure_of(fcx, pat.span, expected) { ty::ty_uniq(e_inner) => { check_pat(pcx, inner, e_inner.ty); fcx.write_ty(pat.id, expected); diff --git a/src/rustc/middle/typeck/check/demand.rs b/src/rustc/middle/typeck/check/demand.rs index e1cf67e94e6..17f171bdf90 100644 --- a/src/rustc/middle/typeck/check/demand.rs +++ b/src/rustc/middle/typeck/check/demand.rs @@ -6,7 +6,7 @@ fn suptype(fcx: @fn_ctxt, sp: span, expected: ty::t, actual: ty::t) { // n.b.: order of actual, expected is reversed - alt infer::mk_subty(fcx.infcx, actual, expected) { + match infer::mk_subty(fcx.infcx, actual, expected) { result::ok(()) => { /* ok */ } result::err(err) => { fcx.report_mismatched_types(sp, expected, actual, err); @@ -17,7 +17,7 @@ fn suptype(fcx: @fn_ctxt, sp: span, fn eqtype(fcx: @fn_ctxt, sp: span, expected: ty::t, actual: ty::t) { - alt infer::mk_eqty(fcx.infcx, actual, expected) { + match infer::mk_eqty(fcx.infcx, actual, expected) { result::ok(()) => { /* ok */ } result::err(err) => { fcx.report_mismatched_types(sp, expected, actual, err); @@ -29,7 +29,7 @@ fn eqtype(fcx: @fn_ctxt, sp: span, fn assign(fcx: @fn_ctxt, sp: span, borrow_lb: ast::node_id, expected: ty::t, expr: @ast::expr) { let expr_ty = fcx.expr_ty(expr); - alt fcx.mk_assignty(expr, borrow_lb, expr_ty, expected) { + match fcx.mk_assignty(expr, borrow_lb, expr_ty, expected) { result::ok(()) => { /* ok */ } result::err(err) => { fcx.report_mismatched_types(sp, expected, expr_ty, err); diff --git a/src/rustc/middle/typeck/check/method.rs b/src/rustc/middle/typeck/check/method.rs index f86d5bf3a7a..442920a0681 100644 --- a/src/rustc/middle/typeck/check/method.rs +++ b/src/rustc/middle/typeck/check/method.rs @@ -24,7 +24,7 @@ fn transform_self_type_for_method(fcx: @fn_ctxt, impl_ty: ty::t, method_info: MethodInfo) -> ty::t { - alt method_info.self_type { + match method_info.self_type { sty_by_ref | sty_value => { impl_ty } @@ -88,7 +88,7 @@ class lookup { // Determine if there are any inherent methods we can call. let optional_inherent_methods; - alt get_base_type_def_id(self.fcx.infcx, + match get_base_type_def_id(self.fcx.infcx, self.self_expr.span, self.self_ty) { none => { @@ -110,7 +110,7 @@ class lookup { loop { // First, see whether this is a bounded parameter. - alt ty::get(self.self_ty).struct { + match ty::get(self.self_ty).struct { ty::ty_param(p) => { self.add_candidates_from_param(p.idx, p.def_id); } @@ -151,7 +151,7 @@ class lookup { if self.candidates.len() > 0u { break; } // check whether we can autoderef and if so loop around again. - alt ty::deref(self.tcx(), self.self_ty, false) { + match ty::deref(self.tcx(), self.self_ty, false) { none => break, some(mt) => { self.self_ty = mt.ty; @@ -168,7 +168,7 @@ class lookup { ~"multiple applicable methods in scope"); for self.candidates.eachi |i, candidate| { - alt candidate.entry.origin { + match candidate.entry.origin { method_static(did) => { self.report_static_candidate(i, did); } @@ -189,7 +189,7 @@ class lookup { fn report_static_candidate(idx: uint, did: ast::def_id) { let span = if did.crate == ast::local_crate { - alt check self.tcx().items.get(did.node) { + match check self.tcx().items.get(did.node) { ast_map::node_method(m, _, _) => m.span, } } else { @@ -226,20 +226,20 @@ class lookup { let mut trait_bnd_idx = 0u; // count only trait bounds let bounds = tcx.ty_param_bounds.get(did.node); for vec::each(*bounds) |bound| { - let (iid, bound_substs) = alt bound { + let (iid, bound_substs) = match bound { ty::bound_copy | ty::bound_send | ty::bound_const | ty::bound_owned => { again; /* ok */ } ty::bound_trait(bound_t) => { - alt check ty::get(bound_t).struct { + match check ty::get(bound_t).struct { ty::ty_trait(i, substs) => (i, substs) } } }; let trt_methods = ty::trait_methods(tcx, iid); - alt vec::position(*trt_methods, |m| m.ident == self.m_name) { + match vec::position(*trt_methods, |m| m.ident == self.m_name) { none => { /* check next bound */ trait_bnd_idx += 1u; @@ -329,14 +329,14 @@ class lookup { } fn ty_from_did(did: ast::def_id) -> ty::t { - alt check ty::get(ty::lookup_item_type(self.tcx(), did).ty).struct { + match check ty::get(ty::lookup_item_type(self.tcx(), did).ty).struct { ty::ty_fn(fty) => { ty::mk_fn(self.tcx(), {proto: ast::proto_box with fty}) } } /* if did.crate == ast::local_crate { - alt check self.tcx().items.get(did.node) { + match check self.tcx().items.get(did.node) { ast_map::node_method(m, _, _) { // NDM trait/impl regions let mt = ty_of_method(self.fcx.ccx, m, ast::rp_none); @@ -344,7 +344,9 @@ class lookup { } } } else { - alt check ty::get(csearch::get_type(self.tcx(), did).ty).struct { + match check ty::get(csearch::get_type(self.tcx(), did).ty) + .struct { + ty::ty_fn(fty) { ty::mk_fn(self.tcx(), {proto: ast::proto_box with fty}) } @@ -408,7 +410,7 @@ class lookup { self.fcx.can_mk_subty(self.self_ty, impl_ty) }; debug!{"matches = %?", matches}; - alt matches { + match matches { result::err(_) => { /* keep looking */ } result::ok(_) => { if !self.candidate_impls.contains_key(im.did) { @@ -454,7 +456,7 @@ class lookup { use_assignability: bool) { // Add inherent methods. - alt optional_inherent_methods { + match optional_inherent_methods { none => { // Continue. } @@ -473,7 +475,7 @@ class lookup { } // Add trait methods. - alt self.fcx.ccx.trait_map.find(self.expr.id) { + match self.fcx.ccx.trait_map.find(self.expr.id) { none => { // Should only happen for placement new right now. } @@ -484,7 +486,7 @@ class lookup { self.def_id_to_str(trait_id)}; let coherence_info = self.fcx.ccx.coherence_info; - alt coherence_info.extension_methods.find(trait_id) { + match coherence_info.extension_methods.find(trait_id) { none => { // Do nothing. } @@ -523,7 +525,7 @@ class lookup { // Make the actual receiver type (cand.self_ty) assignable to the // required receiver type (cand.rcvr_ty). If this method is not // from an impl, this'll basically be a no-nop. - alt self.fcx.mk_assignty(self.self_expr, self.borrow_lb, + match self.fcx.mk_assignty(self.self_expr, self.borrow_lb, cand.self_ty, cand.rcvr_ty) { result::ok(_) => (), result::err(_) => { diff --git a/src/rustc/middle/typeck/check/regionck.rs b/src/rustc/middle/typeck/check/regionck.rs index 7871e1802ea..03a27e88c97 100644 --- a/src/rustc/middle/typeck/check/regionck.rs +++ b/src/rustc/middle/typeck/check/regionck.rs @@ -104,7 +104,7 @@ fn visit_local(l: @ast::local, &&rcx: @rcx, v: rvt) { fn visit_pat(p: @ast::pat, &&rcx: @rcx, v: rvt) { let fcx = rcx.fcx; - alt p.node { + match p.node { ast::pat_ident(_, path, _) if !pat_util::pat_is_variant(fcx.ccx.tcx.def_map, p) => { debug!{"visit_pat binding=%s", *path.idents[0]}; @@ -123,14 +123,14 @@ fn visit_block(b: ast::blk, &&rcx: @rcx, v: rvt) { fn visit_expr(e: @ast::expr, &&rcx: @rcx, v: rvt) { debug!{"visit_expr(e=%s)", pprust::expr_to_str(e)}; - alt e.node { + match e.node { ast::expr_path(*) => { // Avoid checking the use of local variables, as we already // check their definitions. The def'n always encloses the // use. So if the def'n is enclosed by the region, then the // uses will also be enclosed (and otherwise, an error will // have been reported at the def'n site). - alt lookup_def(rcx.fcx, e.span, e.id) { + match lookup_def(rcx.fcx, e.span, e.id) { ast::def_local(*) | ast::def_arg(*) | ast::def_upvar(*) => return, _ => () } @@ -150,12 +150,12 @@ fn visit_expr(e: @ast::expr, &&rcx: @rcx, v: rvt) { // is an extensive comment on the function // check_cast_for_escaping_regions() in kind.rs explaining how // it goes about doing that. - alt rcx.resolve_node_type(e.id) { + match rcx.resolve_node_type(e.id) { result::err(_) => { return; /* typeck will fail anyhow */ } result::ok(target_ty) => { - alt ty::get(target_ty).struct { + match ty::get(target_ty).struct { ty::ty_trait(_, substs) => { - let trait_region = alt substs.self_r { + let trait_region = match substs.self_r { some(r) => {r} none => {ty::re_static} }; @@ -191,7 +191,7 @@ fn visit_node(id: ast::node_id, span: span, rcx: @rcx) -> bool { // Try to resolve the type. If we encounter an error, then typeck // is going to fail anyway, so just stop here and let typeck // report errors later on in the writeback phase. - let ty = alt rcx.resolve_node_type(id) { + let ty = match rcx.resolve_node_type(id) { result::err(_) => return true, result::ok(ty) => ty }; @@ -232,7 +232,7 @@ fn constrain_regions_in_type( ppaux::region_to_str(tcx, encl_region), ppaux::region_to_str(tcx, region)}; - alt region { + match region { ty::re_bound(_) => { // a bound region is one which appears inside an fn type. // (e.g., the `&` in `fn(&T)`). Such regions need not be @@ -243,7 +243,7 @@ fn constrain_regions_in_type( _ => () } - alt rcx.fcx.mk_subr(encl_region, region) { + match rcx.fcx.mk_subr(encl_region, region) { result::err(_) => { let region1 = rcx.fcx.infcx.resolve_region_if_possible(region); tcx.sess.span_err( diff --git a/src/rustc/middle/typeck/check/regionmanip.rs b/src/rustc/middle/typeck/check/regionmanip.rs index aee2a62d947..b9073f97399 100644 --- a/src/rustc/middle/typeck/check/regionmanip.rs +++ b/src/rustc/middle/typeck/check/regionmanip.rs @@ -12,7 +12,7 @@ fn replace_bound_regions_in_fn_ty( // Take self_info apart; the self_ty part is the only one we want // to update here. - let self_ty = alt self_info { + let self_ty = match self_info { some(s) => some(s.self_ty), none => none }; @@ -44,8 +44,8 @@ fn replace_bound_regions_in_fn_ty( // Glue updated self_ty back together with its original node_id. - let new_self_info = alt self_info { - some(s) => alt check t_self { + let new_self_info = match self_info { + some(s) => match check t_self { some(t) => some({self_ty: t, node_id: s.node_id}) // this 'none' case shouldn't happen } @@ -54,7 +54,7 @@ fn replace_bound_regions_in_fn_ty( return {isr: isr, self_info: new_self_info, - fn_ty: alt check ty::get(t_fn).struct { ty::ty_fn(o) => o }}; + fn_ty: match check ty::get(t_fn).struct { ty::ty_fn(o) => o }}; // Takes `isr`, a (possibly empty) mapping from in-scope region @@ -82,13 +82,13 @@ fn replace_bound_regions_in_fn_ty( fn append_isr(isr: isr_alist, to_r: fn(ty::bound_region) -> ty::region, r: ty::region) -> isr_alist { - alt r { + match r { ty::re_free(_, _) | ty::re_static | ty::re_scope(_) | ty::re_var(_) => { isr } ty::re_bound(br) => { - alt isr.find(br) { + match isr.find(br) { some(_) => isr, none => @cons((br, to_r(br)), isr) } @@ -124,14 +124,14 @@ fn replace_bound_regions_in_fn_ty( ty: ty::t) -> ty::t { do ty::fold_regions(tcx, ty) |r, in_fn| { - alt r { + match r { // As long as we are not within a fn() type, `&T` is // mapped to the free region anon_r. But within a fn // type, it remains bound. ty::re_bound(ty::br_anon) if in_fn => r, ty::re_bound(br) => { - alt isr.find(br) { + match isr.find(br) { // In most cases, all named, bound regions will be // mapped to some free region. some(fr) => fr, diff --git a/src/rustc/middle/typeck/check/vtable.rs b/src/rustc/middle/typeck/check/vtable.rs index e1d85828c13..ec8e89ef2ad 100644 --- a/src/rustc/middle/typeck/check/vtable.rs +++ b/src/rustc/middle/typeck/check/vtable.rs @@ -6,7 +6,7 @@ import dvec::extensions; fn has_trait_bounds(tps: ~[ty::param_bounds]) -> bool { vec::any(tps, |bs| { vec::any(*bs, |b| { - alt b { ty::bound_trait(_) => true, _ => false } + match b { ty::bound_trait(_) => true, _ => false } }) }) } @@ -18,7 +18,7 @@ fn lookup_vtables(fcx: @fn_ctxt, sp: span, let mut result = ~[], i = 0u; for substs.tps.each |ty| { for vec::each(*bounds[i]) |bound| { - alt bound { + match bound { ty::bound_trait(i_ty) => { let i_ty = ty::subst(tcx, substs, i_ty); vec::push(result, lookup_vtable(fcx, sp, ty, i_ty, @@ -38,7 +38,7 @@ fn fixup_substs(fcx: @fn_ctxt, sp: span, // use a dummy type just to package up the substs that need fixing up let t = ty::mk_trait(tcx, id, substs); let t_f = fixup_ty(fcx, sp, t); - alt check ty::get(t_f).struct { + match check ty::get(t_f).struct { ty::ty_trait(_, substs_f) => substs_f, } } @@ -61,21 +61,21 @@ fn lookup_vtable(fcx: @fn_ctxt, sp: span, ty: ty::t, trait_ty: ty::t, let _i = indenter(); let tcx = fcx.ccx.tcx; - let (trait_id, trait_substs) = alt check ty::get(trait_ty).struct { + let (trait_id, trait_substs) = match check ty::get(trait_ty).struct { ty::ty_trait(did, substs) => (did, substs) }; let ty = fixup_ty(fcx, sp, ty); - alt ty::get(ty).struct { + match ty::get(ty).struct { ty::ty_param({idx: n, def_id: did}) => { let mut n_bound = 0u; for vec::each(*tcx.ty_param_bounds.get(did.node)) |bound| { - alt bound { + match bound { ty::bound_send | ty::bound_copy | ty::bound_const | ty::bound_owned => { /* ignore */ } ty::bound_trait(ity) => { - alt check ty::get(ity).struct { + match check ty::get(ity).struct { ty::ty_trait(idid, substs) => { if trait_id == idid { debug!{"(checking vtable) @0 relating ty to trait ty @@ -118,7 +118,7 @@ fn lookup_vtable(fcx: @fn_ctxt, sp: span, ty: ty::t, trait_ty: ty::t, let mut impls_seen = new_def_hash(); - alt fcx.ccx.coherence_info.extension_methods.find(trait_id) { + match fcx.ccx.coherence_info.extension_methods.find(trait_id) { none => { // Nothing found. Continue. } @@ -137,7 +137,7 @@ fn lookup_vtable(fcx: @fn_ctxt, sp: span, ty: ty::t, trait_ty: ty::t, // find the trait that im implements (if any) for vec::each(ty::impl_traits(tcx, im.did)) |of_ty| { // it must have the same id as the expected one - alt ty::get(of_ty).struct { + match ty::get(of_ty).struct { ty::ty_trait(id, _) if id != trait_id => again, _ => { /* ok */ } } @@ -147,7 +147,7 @@ fn lookup_vtable(fcx: @fn_ctxt, sp: span, ty: ty::t, trait_ty: ty::t, let {substs: substs, ty: for_ty} = impl_self_ty(fcx, im.did); let im_bs = ty::lookup_item_type(tcx, im.did).bounds; - alt fcx.mk_subty(ty, for_ty) { + match fcx.mk_subty(ty, for_ty) { result::err(_) => again, result::ok(()) => () } @@ -176,7 +176,7 @@ fn lookup_vtable(fcx: @fn_ctxt, sp: span, ty: ty::t, trait_ty: ty::t, } } - alt found.len() { + match found.len() { 0u => { /* fallthrough */ } 1u => { return found[0]; } _ => { @@ -196,7 +196,7 @@ fn lookup_vtable(fcx: @fn_ctxt, sp: span, ty: ty::t, trait_ty: ty::t, fn fixup_ty(fcx: @fn_ctxt, sp: span, ty: ty::t) -> ty::t { let tcx = fcx.ccx.tcx; - alt resolve_type(fcx.infcx, ty, resolve_all | force_all) { + match resolve_type(fcx.infcx, ty, resolve_all | force_all) { result::ok(new_type) => new_type, result::err(e) => { tcx.sess.span_fatal( @@ -217,7 +217,7 @@ fn connect_trait_tps(fcx: @fn_ctxt, sp: span, impl_tys: ~[ty::t], let trait_ty = ty::subst_tps(tcx, impl_tys, ity); debug!{"(connect trait tps) trait type is %?, impl did is %?", ty::get(trait_ty).struct, impl_did}; - alt check ty::get(trait_ty).struct { + match check ty::get(trait_ty).struct { ty::ty_trait(_, substs) => { vec::iter2(substs.tps, trait_tys, |a, b| demand::suptype(fcx, sp, a, b)); @@ -227,9 +227,9 @@ fn connect_trait_tps(fcx: @fn_ctxt, sp: span, impl_tys: ~[ty::t], fn resolve_expr(ex: @ast::expr, &&fcx: @fn_ctxt, v: visit::vt<@fn_ctxt>) { let cx = fcx.ccx; - alt ex.node { + match ex.node { ast::expr_path(*) => { - alt fcx.opt_node_ty_substs(ex.id) { + match fcx.opt_node_ty_substs(ex.id) { some(substs) => { let did = ast_util::def_id_of_def(cx.tcx.def_map.get(ex.id)); let item_ty = ty::lookup_item_type(cx.tcx, did); @@ -248,11 +248,11 @@ fn resolve_expr(ex: @ast::expr, &&fcx: @fn_ctxt, v: visit::vt<@fn_ctxt>) { ast::expr_field(*) | ast::expr_binary(*) | ast::expr_unary(*) | ast::expr_assign_op(*) | ast::expr_index(*) => { - alt cx.method_map.find(ex.id) { + match cx.method_map.find(ex.id) { some({origin: method_static(did), _}) => { let bounds = ty::lookup_item_type(cx.tcx, did).bounds; if has_trait_bounds(*bounds) { - let callee_id = alt ex.node { + let callee_id = match ex.node { ast::expr_field(_, _, _) => ex.id, _ => ex.callee_id }; @@ -269,7 +269,7 @@ fn resolve_expr(ex: @ast::expr, &&fcx: @fn_ctxt, v: visit::vt<@fn_ctxt>) { } ast::expr_cast(src, _) => { let target_ty = fcx.expr_ty(ex); - alt ty::get(target_ty).struct { + match ty::get(target_ty).struct { ty::ty_trait(*) => { /* Look up vtables for the type we're casting to, diff --git a/src/rustc/middle/typeck/check/writeback.rs b/src/rustc/middle/typeck/check/writeback.rs index bafcfc4855d..fc5a3763615 100644 --- a/src/rustc/middle/typeck/check/writeback.rs +++ b/src/rustc/middle/typeck/check/writeback.rs @@ -10,7 +10,7 @@ export resolve_type_vars_in_expr; fn resolve_type_vars_in_type(fcx: @fn_ctxt, sp: span, typ: ty::t) -> option<ty::t> { if !ty::type_needs_infer(typ) { return some(typ); } - alt resolve_type(fcx.infcx, typ, resolve_all | force_all) { + match resolve_type(fcx.infcx, typ, resolve_all | force_all) { result::ok(new_type) => return some(new_type), result::err(e) => { if !fcx.ccx.tcx.sess.has_errors() { @@ -28,7 +28,7 @@ fn resolve_type_vars_for_node(wbcx: wb_ctxt, sp: span, id: ast::node_id) -> option<ty::t> { let fcx = wbcx.fcx, tcx = fcx.ccx.tcx; let n_ty = fcx.node_ty(id); - alt resolve_type_vars_in_type(fcx, sp, n_ty) { + match resolve_type_vars_in_type(fcx, sp, n_ty) { none => { wbcx.success = false; return none; @@ -38,11 +38,11 @@ fn resolve_type_vars_for_node(wbcx: wb_ctxt, sp: span, id: ast::node_id) debug!{"resolve_type_vars_for_node(id=%d, n_ty=%s, t=%s)", id, ty_to_str(tcx, n_ty), ty_to_str(tcx, t)}; write_ty_to_tcx(tcx, id, t); - alt fcx.opt_node_ty_substs(id) { + match fcx.opt_node_ty_substs(id) { some(substs) => { let mut new_tps = ~[]; for substs.tps.each |subst| { - alt resolve_type_vars_in_type(fcx, sp, subst) { + match resolve_type_vars_in_type(fcx, sp, subst) { some(t) => vec::push(new_tps, t), none => { wbcx.success = false; return none; } } @@ -80,7 +80,7 @@ fn visit_stmt(s: @ast::stmt, wbcx: wb_ctxt, v: wb_vt) { fn visit_expr(e: @ast::expr, wbcx: wb_ctxt, v: wb_vt) { if !wbcx.success { return; } resolve_type_vars_for_node(wbcx, e.span, e.id); - alt e.node { + match e.node { ast::expr_fn(_, decl, _, _) | ast::expr_fn_block(decl, _, _) => { do vec::iter(decl.inputs) |input| { @@ -88,7 +88,7 @@ fn visit_expr(e: @ast::expr, wbcx: wb_ctxt, v: wb_vt) { // Just in case we never constrained the mode to anything, // constrain it to the default for the type in question. - alt (r_ty, input.mode) { + match (r_ty, input.mode) { (some(t), ast::infer(_)) => { let tcx = wbcx.fcx.ccx.tcx; let m_def = ty::default_arg_mode_for_ty(t); @@ -127,7 +127,7 @@ fn visit_local(l: @ast::local, wbcx: wb_ctxt, v: wb_vt) { if !wbcx.success { return; } let var_id = lookup_local(wbcx.fcx, l.span, l.node.id); let var_ty = ty::mk_var(wbcx.fcx.tcx(), var_id); - alt resolve_type(wbcx.fcx.infcx, var_ty, resolve_all | force_all) { + match resolve_type(wbcx.fcx.infcx, var_ty, resolve_all | force_all) { result::ok(lty) => { debug!{"Type for local %s (id %d) resolved to %s", pat_to_str(l.node.pat), l.node.id, diff --git a/src/rustc/middle/typeck/coherence.rs b/src/rustc/middle/typeck/coherence.rs index 74f9b6c3061..c6633efe43f 100644 --- a/src/rustc/middle/typeck/coherence.rs +++ b/src/rustc/middle/typeck/coherence.rs @@ -40,7 +40,7 @@ fn get_base_type(inference_context: infer_ctxt, span: span, original_type: t) -> option<t> { let resolved_type; - alt resolve_type(inference_context, + match resolve_type(inference_context, original_type, resolve_ivar) { ok(resulting_type) if !type_is_var(resulting_type) => { @@ -55,7 +55,7 @@ fn get_base_type(inference_context: infer_ctxt, span: span, original_type: t) } } - alt get(resolved_type).struct { + match get(resolved_type).struct { ty_box(base_mutability_and_type) | ty_uniq(base_mutability_and_type) | ty_ptr(base_mutability_and_type) | @@ -88,12 +88,12 @@ fn get_base_type_def_id(inference_context: infer_ctxt, original_type: t) -> option<def_id> { - alt get_base_type(inference_context, span, original_type) { + match get_base_type(inference_context, span, original_type) { none => { return none; } some(base_type) => { - alt get(base_type).struct { + match get(base_type).struct { ty_enum(def_id, _) | ty_class(def_id, _) | ty_trait(def_id, _) => { @@ -160,7 +160,7 @@ class CoherenceChecker { visit_item: |item| { debug!{"(checking coherence) item '%s'", *item.ident}; - alt item.node { + match item.node { item_impl(_, associated_traits, _, _) => { self.check_implementation(item, associated_traits); } @@ -203,7 +203,7 @@ class CoherenceChecker { '%s'", *item.ident}; - alt get_base_type_def_id(self.inference_context, + match get_base_type_def_id(self.inference_context, item.span, self_type.ty) { none => { @@ -235,7 +235,7 @@ class CoherenceChecker { // Add the implementation to the mapping from implementation to base // type def ID, if there is a base type for this implementation. - alt get_base_type_def_id(self.inference_context, + match get_base_type_def_id(self.inference_context, item.span, self_type.ty) { none => { @@ -253,7 +253,7 @@ class CoherenceChecker { fn add_inherent_method(base_def_id: def_id, implementation: @Impl) { let implementation_list; - alt self.crate_context.coherence_info.inherent_methods + match self.crate_context.coherence_info.inherent_methods .find(base_def_id) { none => { @@ -271,7 +271,7 @@ class CoherenceChecker { fn add_trait_method(trait_id: def_id, implementation: @Impl) { let implementation_list; - alt self.crate_context.coherence_info.extension_methods + match self.crate_context.coherence_info.extension_methods .find(trait_id) { none => { @@ -363,7 +363,7 @@ class CoherenceChecker { visit_crate(*crate, (), mk_vt(@{ visit_item: |item, _context, visitor| { - alt item.node { + match item.node { item_mod(module_) => { // First, gather up all privileged types. let privileged_types = @@ -386,7 +386,9 @@ class CoherenceChecker { } } item_impl(_, associated_traits, _, _) => { - alt self.base_type_def_ids.find(local_def(item.id)) { + match self.base_type_def_ids.find( + local_def(item.id)) { + none => { // Nothing to do. } @@ -468,7 +470,7 @@ class CoherenceChecker { fn gather_privileged_types(items: ~[@item]) -> @dvec<def_id> { let results = @dvec(); for items.each |item| { - alt item.node { + match item.node { item_class(*) | item_enum(*) | item_trait(*) => { results.push(local_def(item.id)); } @@ -486,7 +488,7 @@ class CoherenceChecker { // Converts an implementation in the AST to an Impl structure. fn create_impl_from_item(item: @item) -> @Impl { - alt item.node { + match item.node { item_impl(ty_params, _, _, ast_methods) => { let mut methods = ~[]; for ast_methods.each |ast_method| { @@ -507,7 +509,7 @@ class CoherenceChecker { item_class(ty_params, _, class_members, _, _) => { let mut methods = ~[]; for class_members.each |class_member| { - alt class_member.node { + match class_member.node { instance_var(*) => { // Nothing to do. } @@ -538,7 +540,7 @@ class CoherenceChecker { fn span_of_impl(implementation: @Impl) -> span { assert implementation.did.crate == local_crate; - alt self.crate_context.tcx.items.find(implementation.did.node) { + match self.crate_context.tcx.items.find(implementation.did.node) { some(node_item(item, _)) => { return item.span; } @@ -562,7 +564,7 @@ class CoherenceChecker { for (*implementations).each |implementation| { // Make sure we don't visit the same implementation // multiple times. - alt impls_seen.find(implementation.did) { + match impls_seen.find(implementation.did) { none => { // Good. Continue. impls_seen.insert(implementation.did, ()); @@ -582,7 +584,7 @@ class CoherenceChecker { // types. if associated_traits.len() == 0 { - alt get_base_type_def_id(self.inference_context, + match get_base_type_def_id(self.inference_context, dummy_sp(), self_type.ty) { none => { @@ -601,7 +603,7 @@ class CoherenceChecker { // Record all the trait methods. for associated_traits.each |trait_type| { - alt get(trait_type).struct { + match get(trait_type).struct { ty_trait(trait_id, _) => { self.add_trait_method(trait_id, implementation); } @@ -617,7 +619,7 @@ class CoherenceChecker { // implementation to base type def ID, if there is a base // type for this implementation. - alt get_base_type_def_id(self.inference_context, + match get_base_type_def_id(self.inference_context, dummy_sp(), self_type.ty) { none => { @@ -645,7 +647,7 @@ class CoherenceChecker { for each_path(crate_store, crate_number) |path_entry| { let module_def_id; - alt path_entry.def_like { + match path_entry.def_like { dl_def(def_mod(def_id)) => { module_def_id = def_id; } diff --git a/src/rustc/middle/typeck/collect.rs b/src/rustc/middle/typeck/collect.rs index 5a13d1d8efc..c1211d79a7e 100644 --- a/src/rustc/middle/typeck/collect.rs +++ b/src/rustc/middle/typeck/collect.rs @@ -30,14 +30,14 @@ fn collect_item_types(ccx: @crate_ctxt, crate: @ast::crate) { for crate.node.module.items.each |crate_item| { if *crate_item.ident == ~"intrinsic" { - alt crate_item.node { + match crate_item.node { ast::item_mod(m) => { for m.items.each |intrinsic_item| { let def_id = { crate: ast::local_crate, node: intrinsic_item.id }; let substs = {self_r: none, self_ty: none, tps: ~[]}; - alt intrinsic_item.node { + match intrinsic_item.node { ast::item_trait(*) => { let ty = ty::mk_trait(ccx.tcx, def_id, substs); ccx.tcx.intrinsic_defs.insert @@ -83,7 +83,7 @@ impl of ast_conv for @crate_ctxt { if id.crate != ast::local_crate { csearch::get_type(self.tcx, id) } else { - alt self.tcx.items.find(id.node) { + match self.tcx.items.find(id.node) { some(ast_map::node_item(item, _)) => { ty_of_item(self, item) } @@ -145,10 +145,10 @@ fn ensure_trait_methods(ccx: @crate_ctxt, id: ast::node_id) { let tcx = ccx.tcx; let rp = tcx.region_paramd_items.contains_key(id); - alt check tcx.items.get(id) { + match check tcx.items.get(id) { ast_map::node_item(@{node: ast::item_trait(_, _, ms), _}, _) => { store_methods::<ast::trait_method>(ccx, id, ms, |m| { - alt m { + match m { required(ty_m) => { ty_of_ty_method(ccx, ty_m, rp) } @@ -253,7 +253,7 @@ fn check_methods_against_trait(ccx: @crate_ctxt, ensure_trait_methods(ccx, did.node); } for vec::each(*ty::trait_methods(tcx, did)) |trait_m| { - alt vec::find(impl_ms, |impl_m| trait_m.ident == impl_m.mty.ident) { + match vec::find(impl_ms, |impl_m| trait_m.ident == impl_m.mty.ident) { some({mty: impl_m, id, span}) => { if impl_m.purity != trait_m.purity { ccx.tcx.sess.span_err( @@ -271,13 +271,13 @@ fn check_methods_against_trait(ccx: @crate_ctxt, // implementation in the trait itself. If not, raise a // "missing method" error. - alt tcx.items.get(did.node) { + match tcx.items.get(did.node) { ast_map::node_item( @{node: ast::item_trait(_, _, trait_methods), _}, _) => { let (_, provided_methods) = split_trait_methods(trait_methods); - alt vec::find(provided_methods, |provided_method| + match vec::find(provided_methods, |provided_method| provided_method.ident == trait_m.ident) { some(m) => { // If there's a provided method with the name we @@ -339,7 +339,7 @@ fn convert(ccx: @crate_ctxt, it: @ast::item) { let tcx = ccx.tcx; let rp = tcx.region_paramd_items.contains_key(it.id); debug!{"convert: item %s with id %d rp %b", *it.ident, it.id, rp}; - alt it.node { + match it.node { // These don't define types. ast::item_foreign_mod(_) | ast::item_mod(_) => {} ast::item_enum(variants, ty_params) => { @@ -449,7 +449,7 @@ fn convert_foreign(ccx: @crate_ctxt, i: @ast::foreign_item) { // type of the foreign item. We simply write it into the node type // table. let tpt = ty_of_foreign_item(ccx, i); - alt i.node { + match i.node { ast::foreign_item_fn(_, _) => { write_ty_to_tcx(ccx.tcx, i.id, tpt.ty); ccx.tcx.tcache.insert(local_def(i.id), tpt); @@ -494,11 +494,11 @@ fn instantiate_trait_ref(ccx: @crate_ctxt, t: @ast::trait_ref, rp: bool) let rscope = type_rscope(rp); - alt lookup_def_tcx(ccx.tcx, t.path.span, t.ref_id) { + match lookup_def_tcx(ccx.tcx, t.path.span, t.ref_id) { ast::def_ty(t_id) => { let tpt = astconv::ast_path_to_ty(ccx, rscope, t_id, t.path, t.ref_id); - alt ty::get(tpt.ty).struct { + match ty::get(tpt.ty).struct { ty::ty_trait(*) => { (t_id, tpt) } @@ -514,12 +514,12 @@ fn ty_of_item(ccx: @crate_ctxt, it: @ast::item) let def_id = local_def(it.id); let tcx = ccx.tcx; - alt tcx.tcache.find(def_id) { + match tcx.tcache.find(def_id) { some(tpt) => return tpt, _ => {} } let rp = tcx.region_paramd_items.contains_key(it.id); - alt it.node { + match it.node { ast::item_const(t, _) => { let typ = ccx.to_ty(empty_rscope, t); let tpt = no_params(typ); @@ -539,7 +539,7 @@ fn ty_of_item(ccx: @crate_ctxt, it: @ast::item) return tpt; } ast::item_ty(t, tps) => { - alt tcx.tcache.find(local_def(it.id)) { + match tcx.tcache.find(local_def(it.id)) { some(tpt) => return tpt, none => { } } @@ -592,7 +592,7 @@ fn ty_of_item(ccx: @crate_ctxt, it: @ast::item) fn ty_of_foreign_item(ccx: @crate_ctxt, it: @ast::foreign_item) -> ty::ty_param_bounds_and_ty { - alt it.node { + match it.node { ast::foreign_item_fn(fn_decl, params) => { return ty_of_foreign_fn_decl(ccx, fn_decl, params, local_def(it.id)); @@ -605,14 +605,14 @@ fn ty_param_bounds(ccx: @crate_ctxt, fn compute_bounds(ccx: @crate_ctxt, param: ast::ty_param) -> ty::param_bounds { @do vec::flat_map(*param.bounds) |b| { - alt b { + match b { ast::bound_send => ~[ty::bound_send], ast::bound_copy => ~[ty::bound_copy], ast::bound_const => ~[ty::bound_const], ast::bound_owned => ~[ty::bound_owned], ast::bound_trait(t) => { let ity = ast_ty_to_ty(ccx, empty_rscope, t); - alt ty::get(ity).struct { + match ty::get(ity).struct { ty::ty_trait(*) => { ~[ty::bound_trait(ity)] } @@ -629,7 +629,7 @@ fn ty_param_bounds(ccx: @crate_ctxt, } @do params.map |param| { - alt ccx.tcx.ty_param_bounds.find(param.id) { + match ccx.tcx.ty_param_bounds.find(param.id) { some(bs) => bs, none => { let bounds = compute_bounds(ccx, param); diff --git a/src/rustc/middle/typeck/infer.rs b/src/rustc/middle/typeck/infer.rs index d13a18dfcc6..8c9cbc07598 100644 --- a/src/rustc/middle/typeck/infer.rs +++ b/src/rustc/middle/typeck/infer.rs @@ -249,8 +249,8 @@ fn single_type_contained_in(tcx: ty::ctxt, a: int_ty_set) -> fn convert_integral_ty_to_int_ty_set(tcx: ty::ctxt, t: ty::t) -> int_ty_set { - alt get(t).struct { - ty_int(int_ty) => alt int_ty { + match get(t).struct { + ty_int(int_ty) => match int_ty { ast::ty_i8 => int_ty_set(INT_TY_SET_i8), ast::ty_i16 => int_ty_set(INT_TY_SET_i16), ast::ty_i32 => int_ty_set(INT_TY_SET_i32), @@ -259,7 +259,7 @@ fn convert_integral_ty_to_int_ty_set(tcx: ty::ctxt, t: ty::t) ast::ty_char => tcx.sess.bug( ~"char type passed to convert_integral_ty_to_int_ty_set()") } - ty_uint(uint_ty) => alt uint_ty { + ty_uint(uint_ty) => match uint_ty { ast::ty_u8 => int_ty_set(INT_TY_SET_u8), ast::ty_u16 => int_ty_set(INT_TY_SET_u16), ast::ty_u32 => int_ty_set(INT_TY_SET_u32), @@ -335,7 +335,7 @@ enum fixup_err { } fn fixup_err_to_str(f: fixup_err) -> ~str { - alt f { + match f { unresolved_int_ty(_) => ~"unconstrained integral type", unresolved_ty(_) => ~"unconstrained type", cyclic_ty(_) => ~"cyclic type of infinite size", @@ -418,7 +418,7 @@ fn resolve_region(cx: infer_ctxt, r: ty::region, modes: uint) fn resolve_borrowings(cx: infer_ctxt) { for cx.borrowings.each |item| { - alt resolve_region(cx, item.scope, resolve_all|force_all) { + match resolve_region(cx, item.scope, resolve_all|force_all) { ok(region) => { debug!{"borrowing for expr %d resolved to region %?, mutbl %?", item.expr_id, region, item.mutbl}; @@ -455,7 +455,7 @@ trait cres_helpers<T> { impl methods<T:copy> of cres_helpers<T> for cres<T> { fn to_ures() -> ures { - alt self { + match self { ok(_v) => ok(()), err(e) => err(e) } @@ -496,7 +496,7 @@ impl of to_str for ty::region { impl<V:copy to_str> of to_str for bound<V> { fn to_str(cx: infer_ctxt) -> ~str { - alt self { + match self { some(v) => v.to_str(cx), none => ~"none" } @@ -513,7 +513,7 @@ impl<T:copy to_str> of to_str for bounds<T> { impl of to_str for int_ty_set { fn to_str(_cx: infer_ctxt) -> ~str { - alt self { + match self { int_ty_set(v) => uint::to_str(v, 10u) } } @@ -521,7 +521,7 @@ impl of to_str for int_ty_set { impl<V:copy vid, T:copy to_str> of to_str for var_value<V,T> { fn to_str(cx: infer_ctxt) -> ~str { - alt self { + match self { redirect(vid) => fmt!{"redirect(%s)", vid.to_str()}, root(pt, rk) => fmt!{"root(%s, %s)", pt.to_str(cx), uint::to_str(rk, 10u)} @@ -602,7 +602,7 @@ impl transaction_methods for infer_ctxt { debug!{"try(tvbl=%u, rbl=%u)", tvbl, rbl}; let r <- f(); - alt r { + match r { result::ok(_) => debug!{"try--ok"}, result::err(_) => { debug!{"try--rollback"}; @@ -681,14 +681,14 @@ impl methods for infer_ctxt { } fn resolve_type_vars_if_possible(typ: ty::t) -> ty::t { - alt resolve_type(self, typ, resolve_all) { + match resolve_type(self, typ, resolve_all) { result::ok(new_type) => return new_type, result::err(_) => return typ } } fn resolve_region_if_possible(oldr: ty::region) -> ty::region { - alt resolve_region(self, oldr, resolve_all) { + match resolve_region(self, oldr, resolve_all) { result::ok(newr) => return newr, result::err(_) => return oldr } @@ -714,12 +714,12 @@ impl unify_methods for infer_ctxt { -> node<V, T> { let vid_u = vid.to_uint(); - alt vb.vals.find(vid_u) { + match vb.vals.find(vid_u) { none => { self.tcx.sess.bug(fmt!{"failed lookup of vid `%u`", vid_u}); } some(var_val) => { - alt var_val { + match var_val { redirect(vid) => { let nde = self.get(vb, vid); if nde.root != vid { @@ -744,7 +744,7 @@ impl unify_methods for infer_ctxt { debug!{"merge_bnd(%s,%s)", a.to_str(self), b.to_str(self)}; let _r = indenter(); - alt (a, b) { + match (a, b) { (none, none) => ok(none), (some(_), none) => ok(a), (none, some(_)) => ok(b), @@ -853,10 +853,10 @@ impl unify_methods for infer_ctxt { // If both A's UB and B's LB have already been bound to types, // see if we can make those types subtypes. - alt (a_bounds.ub, b_bounds.lb) { + match (a_bounds.ub, b_bounds.lb) { (some(a_ub), some(b_lb)) => { let r = self.try(|| a_ub.sub(self, b_lb)); - alt r { + match r { ok(()) => return result::ok(()), err(_) => { /*fallthrough */ } } @@ -1022,7 +1022,7 @@ impl unify_methods for infer_ctxt { debug!{"bnds(%s <: %s)", a.to_str(self), b.to_str(self)}; do indent { - alt (a, b) { + match (a, b) { (none, none) | (some(_), none) | (none, some(_)) => { @@ -1141,7 +1141,7 @@ impl methods for resolve_state { assert vec::is_empty(self.v_seen); let rty = indent(|| self.resolve_type(typ) ); assert vec::is_empty(self.v_seen); - alt self.err { + match self.err { none => { debug!{"Resolved to %s (modes=%x)", ty_to_str(self.infcx.tcx, rty), @@ -1155,7 +1155,7 @@ impl methods for resolve_state { fn resolve_region_chk(orig: ty::region) -> fres<ty::region> { self.err = none; let resolved = indent(|| self.resolve_region(orig) ); - alt self.err { + match self.err { none => ok(resolved), some(e) => err(e) } @@ -1166,7 +1166,7 @@ impl methods for resolve_state { indent(fn&() -> ty::t { if !ty::type_needs_infer(typ) { return typ; } - alt ty::get(typ).struct { + match ty::get(typ).struct { ty::ty_var(vid) => { self.resolve_ty_var(vid) } @@ -1201,7 +1201,7 @@ impl methods for resolve_state { fn resolve_region(orig: ty::region) -> ty::region { debug!{"Resolve_region(%s)", orig.to_str(self.infcx)}; - alt orig { + match orig { ty::re_var(rid) => self.resolve_region_var(rid), _ => orig } @@ -1213,7 +1213,7 @@ impl methods for resolve_state { } let nde = self.infcx.get(self.infcx.rb, rid); let bounds = nde.possible_types; - alt bounds { + match bounds { { ub:_, lb:some(r) } => { self.assert_not_rvar(rid, r); r } { ub:some(r), lb:_ } => { self.assert_not_rvar(rid, r); r } { ub:none, lb:none } => { @@ -1226,7 +1226,7 @@ impl methods for resolve_state { } fn assert_not_rvar(rid: region_vid, r: ty::region) { - alt r { + match r { ty::re_var(rid2) => { self.err = some(region_var_bound_by_region_var(rid, rid2)); } @@ -1251,7 +1251,7 @@ impl methods for resolve_state { let nde = self.infcx.get(self.infcx.tvb, vid); let bounds = nde.possible_types; - let t1 = alt bounds { + let t1 = match bounds { { ub:_, lb:some(t) } if !type_is_bot(t) => self.resolve_type(t), { ub:some(t), lb:_ } => self.resolve_type(t), { ub:_, lb:some(t) } => self.resolve_type(t), @@ -1277,7 +1277,7 @@ impl methods for resolve_state { // If there's only one type in the set of possible types, then // that's the answer. - alt single_type_contained_in(self.infcx.tcx, pt) { + match single_type_contained_in(self.infcx.tcx, pt) { some(t) => t, none => { if self.should(force_ivar) { @@ -1351,9 +1351,9 @@ impl assignment for infer_ctxt { fn assign_tys(anmnt: assignment, a: ty::t, b: ty::t) -> ures { fn select(fst: option<ty::t>, snd: option<ty::t>) -> option<ty::t> { - alt fst { + match fst { some(t) => some(t), - none => alt snd { + none => match snd { some(t) => some(t), none => none } @@ -1364,7 +1364,7 @@ impl assignment for infer_ctxt { anmnt, a.to_str(self), b.to_str(self)}; let _r = indenter(); - alt (ty::get(a).struct, ty::get(b).struct) { + match (ty::get(a).struct, ty::get(b).struct) { (ty::ty_bot, _) => { uok() } @@ -1413,15 +1413,15 @@ impl assignment for infer_ctxt { let _r = indenter(); fn is_borrowable(v: ty::vstore) -> bool { - alt v { + match v { ty::vstore_fixed(_) | ty::vstore_uniq | ty::vstore_box => true, ty::vstore_slice(_) => false } } - alt (a_bnd, b_bnd) { + match (a_bnd, b_bnd) { (some(a_bnd), some(b_bnd)) => { - alt (ty::get(a_bnd).struct, ty::get(b_bnd).struct) { + match (ty::get(a_bnd).struct, ty::get(b_bnd).struct) { (ty::ty_box(mt_a), ty::ty_rptr(r_b, mt_b)) => { let nr_b = ty::mk_box(self.tcx, {ty: mt_b.ty, mutbl: m_const}); @@ -1569,7 +1569,7 @@ fn super_substs<C:combine>( fn eq_opt_regions(infcx: infer_ctxt, a: option<ty::region>, b: option<ty::region>) -> cres<option<ty::region>> { - alt (a, b) { + match (a, b) { (none, none) => { ok(none) } @@ -1625,7 +1625,7 @@ fn super_self_tys<C:combine>( // Note: the self type parameter is (currently) always treated as // *invariant* (otherwise the type system would be unsound). - alt (a, b) { + match (a, b) { (none, none) => { ok(none) } @@ -1677,7 +1677,7 @@ fn super_vstores<C:combine>( self: C, vk: ty::terr_vstore_kind, a: ty::vstore, b: ty::vstore) -> cres<ty::vstore> { - alt (a, b) { + match (a, b) { (ty::vstore_slice(a_r), ty::vstore_slice(b_r)) => { do self.contraregions(a_r, b_r).chain |r| { ok(ty::vstore_slice(r)) @@ -1732,7 +1732,7 @@ fn super_tys<C:combine>( self: C, a: ty::t, b: ty::t) -> cres<ty::t> { let tcx = self.infcx().tcx; - alt (ty::get(a).struct, ty::get(b).struct) { + match (ty::get(a).struct, ty::get(b).struct) { // The "subtype" ought to be handling cases involving bot or var: (ty::ty_bot, _) | (_, ty::ty_bot) | @@ -1897,7 +1897,7 @@ impl of combine for sub { a.to_str(self.infcx()), b.to_str(self.infcx())}; do indent { - alt (a, b) { + match (a, b) { (ty::re_var(a_id), ty::re_var(b_id)) => { do self.infcx().vars(self.rb, a_id, b_id).then { ok(a) @@ -1929,7 +1929,7 @@ impl of combine for sub { return err(ty::terr_mutability); } - alt b.mutbl { + match b.mutbl { m_mutbl => { // If supertype is mut, subtype must match exactly // (i.e., invariant if mut): @@ -1965,7 +1965,7 @@ impl of combine for sub { a.to_str(*self), b.to_str(*self)}; if a == b { return ok(a); } do indent { - alt (ty::get(a).struct, ty::get(b).struct) { + match (ty::get(a).struct, ty::get(b).struct) { (ty::ty_bot, _) => { ok(a) } @@ -2077,7 +2077,7 @@ impl of combine for lub { m_const }; - alt m { + match m { m_imm | m_const => { self.tys(a.ty, b.ty).chain(|t| ok({ty: t, mutbl: m}) ) } @@ -2113,7 +2113,7 @@ impl of combine for lub { } fn purities(f1: purity, f2: purity) -> cres<purity> { - alt (f1, f2) { + match (f1, f2) { (unsafe_fn, _) | (_, unsafe_fn) => ok(unsafe_fn), (impure_fn, _) | (_, impure_fn) => ok(impure_fn), (extern_fn, _) | (_, extern_fn) => ok(extern_fn), @@ -2122,7 +2122,7 @@ impl of combine for lub { } fn ret_styles(r1: ret_style, r2: ret_style) -> cres<ret_style> { - alt (r1, r2) { + match (r1, r2) { (ast::return_val, _) | (_, ast::return_val) => ok(ast::return_val), (ast::noreturn, ast::noreturn) => ok(ast::noreturn) @@ -2140,7 +2140,7 @@ impl of combine for lub { b.to_str(self.infcx())}; do indent { - alt (a, b) { + match (a, b) { (ty::re_static, _) | (_, ty::re_static) => { ok(ty::re_static) // nothing lives longer than static } @@ -2155,7 +2155,7 @@ impl of combine for lub { // at least as big as the block f_id". So, we can // reasonably compare free regions and scopes: let rm = self.infcx().tcx.region_map; - alt region::nearest_common_ancestor(rm, f_id, s_id) { + match region::nearest_common_ancestor(rm, f_id, s_id) { // if the free region's scope `f_id` is bigger than // the scope region `s_id`, then the LUB is the free // region itself: @@ -2172,7 +2172,7 @@ impl of combine for lub { // subtype of the region corresponding to an inner // block. let rm = self.infcx().tcx.region_map; - alt region::nearest_common_ancestor(rm, a_id, b_id) { + match region::nearest_common_ancestor(rm, a_id, b_id) { some(r_id) => ok(ty::re_scope(r_id)), _ => ok(ty::re_static) } @@ -2248,7 +2248,7 @@ impl of combine for glb { mt_to_str(tcx, a), mt_to_str(tcx, b)}; - alt (a.mutbl, b.mutbl) { + match (a.mutbl, b.mutbl) { // If one side or both is mut, then the GLB must use // the precise type from the mut side. (m_mutbl, m_const) => { @@ -2310,7 +2310,7 @@ impl of combine for glb { } fn purities(f1: purity, f2: purity) -> cres<purity> { - alt (f1, f2) { + match (f1, f2) { (pure_fn, _) | (_, pure_fn) => ok(pure_fn), (extern_fn, _) | (_, extern_fn) => ok(extern_fn), (impure_fn, _) | (_, impure_fn) => ok(impure_fn), @@ -2319,7 +2319,7 @@ impl of combine for glb { } fn ret_styles(r1: ret_style, r2: ret_style) -> cres<ret_style> { - alt (r1, r2) { + match (r1, r2) { (ast::return_val, ast::return_val) => { ok(ast::return_val) } @@ -2337,7 +2337,7 @@ impl of combine for glb { b.to_str(self.infcx())}; do indent { - alt (a, b) { + match (a, b) { (ty::re_static, r) | (r, ty::re_static) => { // static lives longer than everything else ok(r) @@ -2355,7 +2355,7 @@ impl of combine for glb { // is the scope `s_id`. Otherwise, as we do not know // big the free region is precisely, the GLB is undefined. let rm = self.infcx().tcx.region_map; - alt region::nearest_common_ancestor(rm, f_id, s_id) { + match region::nearest_common_ancestor(rm, f_id, s_id) { some(r_id) if r_id == f_id => ok(s), _ => err(ty::terr_regions_differ(b, a)) } @@ -2367,7 +2367,7 @@ impl of combine for glb { // these: so, if one of these scopes is a subscope of the // other, return it. Otherwise fail. let rm = self.infcx().tcx.region_map; - alt region::nearest_common_ancestor(rm, a_id, b_id) { + match region::nearest_common_ancestor(rm, a_id, b_id) { some(r_id) if a_id == r_id => ok(b), some(r_id) if b_id == r_id => ok(a), _ => err(ty::terr_regions_differ(b, a)) @@ -2475,7 +2475,7 @@ fn lattice_tys<L:lattice_ops combine>( b.to_str(self.infcx())}; if a == b { return ok(a); } do indent { - alt (ty::get(a).struct, ty::get(b).struct) { + match (ty::get(a).struct, ty::get(b).struct) { (ty::ty_bot, _) => self.ty_bot(b), (_, ty::ty_bot) => self.ty_bot(a), @@ -2505,7 +2505,7 @@ fn lattice_tys<L:lattice_ops combine>( fn lattice_rvars<L:lattice_ops combine>( self: L, a: ty::region, b: ty::region) -> cres<ty::region> { - alt (a, b) { + match (a, b) { (ty::re_var(a_id), ty::re_var(b_id)) => { lattice_vars(self, self.infcx().rb, a, a_id, b_id, @@ -2558,9 +2558,9 @@ fn lattice_vars<V:copy vid, T:copy to_str st, L:lattice_ops combine>( // If both A and B have an UB type, then we can just compute the // LUB of those types: let a_bnd = self.bnd(a_bounds), b_bnd = self.bnd(b_bounds); - alt (a_bnd, b_bnd) { + match (a_bnd, b_bnd) { (some(a_ty), some(b_ty)) => { - alt self.infcx().try(|| c_ts(a_ty, b_ty) ) { + match self.infcx().try(|| c_ts(a_ty, b_ty) ) { ok(t) => return ok(t), err(_) => { /*fallthrough */ } } @@ -2590,7 +2590,7 @@ fn lattice_var_t<V:copy vid, T:copy to_str st, L:lattice_ops combine>( a_id.to_str(), a_bounds.to_str(self.infcx()), b.to_str(self.infcx())}; - alt self.bnd(a_bounds) { + match self.bnd(a_bounds) { some(a_bnd) => { // If a has an upper bound, return the LUB(a.ub, b) debug!{"bnd=some(%s)", a_bnd.to_str(self.infcx())}; diff --git a/src/rustc/util/common.rs b/src/rustc/util/common.rs index d471ba677b5..906f3b7bdb3 100644 --- a/src/rustc/util/common.rs +++ b/src/rustc/util/common.rs @@ -42,7 +42,7 @@ fn loop_query(b: ast::blk, p: fn@(ast::expr_) -> bool) -> bool { let visit_expr = |e: @ast::expr, &&flag: @mut bool, v: visit::vt<@mut bool>| { *flag |= p(e.node); - alt e.node { + match e.node { // Skip inner loops, since a break in the inner loop isn't a // break inside the outer loop ast::expr_loop(*) | ast::expr_while(*) @@ -58,7 +58,7 @@ fn loop_query(b: ast::blk, p: fn@(ast::expr_) -> bool) -> bool { fn has_nonlocal_exits(b: ast::blk) -> bool { do loop_query(b) |e| { - alt e { + match e { ast::expr_break | ast::expr_again => true, _ => false } @@ -67,7 +67,7 @@ fn has_nonlocal_exits(b: ast::blk) -> bool { fn may_break(b: ast::blk) -> bool { do loop_query(b) |e| { - alt e { + match e { ast::expr_break => true, _ => false } @@ -75,7 +75,7 @@ fn may_break(b: ast::blk) -> bool { } fn local_rhs_span(l: @ast::local, def: span) -> span { - alt l.node.init { + match l.node.init { some(i) => return i.expr.span, _ => return def } diff --git a/src/rustc/util/ppaux.rs b/src/rustc/util/ppaux.rs index 571da9db069..1f180bfb764 100644 --- a/src/rustc/util/ppaux.rs +++ b/src/rustc/util/ppaux.rs @@ -25,14 +25,14 @@ import driver::session::session; /// that attempts to explain a lifetime in a way it might plausibly be /// understood. fn explain_region(cx: ctxt, region: ty::region) -> ~str { - return alt region { + return match region { re_scope(node_id) => { - let scope_str = alt cx.items.find(node_id) { + let scope_str = match cx.items.find(node_id) { some(ast_map::node_block(blk)) => { explain_span(cx, ~"block", blk.span) } some(ast_map::node_expr(expr)) => { - alt expr.node { + match expr.node { ast::expr_call(*) => { explain_span(cx, ~"call", expr.span) } ast::expr_alt(*) => { explain_span(cx, ~"alt", expr.span) } _ => { explain_span(cx, ~"expression", expr.span) } @@ -47,7 +47,7 @@ fn explain_region(cx: ctxt, region: ty::region) -> ~str { } re_free(id, br) => { - alt cx.items.find(id) { + match cx.items.find(id) { some(ast_map::node_block(blk)) => { fmt!{"reference with lifetime %s as defined on %s", bound_region_to_str(cx, br), @@ -76,7 +76,7 @@ fn explain_region(cx: ctxt, region: ty::region) -> ~str { } fn bound_region_to_str(cx: ctxt, br: bound_region) -> ~str { - alt br { + match br { br_anon => { ~"&" } br_named(str) => { fmt!{"&%s", *str} } br_self if cx.sess.ppregions() => { ~"&<self>" } @@ -95,13 +95,13 @@ fn bound_region_to_str(cx: ctxt, br: bound_region) -> ~str { } fn re_scope_id_to_str(cx: ctxt, node_id: ast::node_id) -> ~str { - alt cx.items.find(node_id) { + match cx.items.find(node_id) { some(ast_map::node_block(blk)) => { fmt!{"<block at %s>", codemap::span_to_str(blk.span, cx.sess.codemap)} } some(ast_map::node_expr(expr)) => { - alt expr.node { + match expr.node { ast::expr_call(*) => { fmt!{"<call at %s>", codemap::span_to_str(expr.span, cx.sess.codemap)} @@ -134,7 +134,7 @@ fn re_scope_id_to_str(cx: ctxt, node_id: ast::node_id) -> ~str { } fn region_to_str(cx: ctxt, region: region) -> ~str { - alt region { + match region { re_scope(node_id) => { if cx.sess.ppregions() { fmt!{"&%s", re_scope_id_to_str(cx, node_id)} @@ -162,7 +162,7 @@ fn region_to_str(cx: ctxt, region: region) -> ~str { } fn mt_to_str(cx: ctxt, m: mt) -> ~str { - let mstr = alt m.mutbl { + let mstr = match m.mutbl { ast::m_mutbl => ~"mut ", ast::m_imm => ~"", ast::m_const => ~"const " @@ -171,7 +171,7 @@ fn mt_to_str(cx: ctxt, m: mt) -> ~str { } fn vstore_to_str(cx: ctxt, vs: ty::vstore) -> ~str { - alt vs { + match vs { ty::vstore_fixed(n) => fmt!{"%u", n}, ty::vstore_uniq => ~"~", ty::vstore_box => ~"@", @@ -180,7 +180,7 @@ fn vstore_to_str(cx: ctxt, vs: ty::vstore) -> ~str { } fn vstore_ty_to_str(cx: ctxt, ty: ~str, vs: ty::vstore) -> ~str { - alt vs { + match vs { ty::vstore_fixed(_) => { fmt!{"%s/%s", ty, vstore_to_str(cx, vs)} } @@ -198,7 +198,7 @@ fn ty_to_str(cx: ctxt, typ: t) -> ~str { fn fn_input_to_str(cx: ctxt, input: {mode: ast::mode, ty: t}) -> ~str { let {mode, ty} = input; - let modestr = alt canon_mode(cx, mode) { + let modestr = match canon_mode(cx, mode) { ast::infer(_) => ~"", ast::expl(m) => { if !ty::type_needs_infer(ty) && @@ -216,12 +216,12 @@ fn ty_to_str(cx: ctxt, typ: t) -> ~str { inputs: ~[arg], output: t, cf: ast::ret_style) -> ~str { let mut s; - s = alt purity { + s = match purity { ast::impure_fn => ~"", _ => purity_to_str(purity) + ~" " }; s += proto_to_str(proto); - alt ident { + match ident { some(i) => { s += ~" "; s += *i; } _ => { } } @@ -232,7 +232,7 @@ fn ty_to_str(cx: ctxt, typ: t) -> ~str { s += ~")"; if ty::get(output).struct != ty_nil { s += ~" -> "; - alt cf { + match cf { ast::noreturn => { s += ~"!"; } ast::return_val => { s += ty_to_str(cx, output); } } @@ -255,7 +255,7 @@ fn ty_to_str(cx: ctxt, typ: t) -> ~str { } // pretty print the structural type representation: - return alt ty::get(typ).struct { + return match ty::get(typ).struct { ty_nil => ~"()", ty_bot => ~"_|_", ty_bool => ~"bool", @@ -325,7 +325,7 @@ fn parameterized(cx: ctxt, self_r: option<ty::region>, tps: ~[ty::t]) -> ~str { - let r_str = alt self_r { + let r_str = match self_r { none => ~"", some(r) => { fmt!{"/%s", region_to_str(cx, r)} |
