diff options
| author | Brian Anderson <banderson@mozilla.com> | 2012-08-20 12:23:37 -0700 |
|---|---|---|
| committer | Brian Anderson <banderson@mozilla.com> | 2012-08-26 15:56:16 -0700 |
| commit | 8337fa1a545e7958389c6025661990eedd9c1b91 (patch) | |
| tree | c8156400e412fe7e4441a42592f2687915d8f2fa /src/libsyntax/ext | |
| parent | d9a6a6365327ac156ef3102e2b7efae1b2be5934 (diff) | |
| download | rust-8337fa1a545e7958389c6025661990eedd9c1b91.tar.gz rust-8337fa1a545e7958389c6025661990eedd9c1b91.zip | |
Camel case the option type
Diffstat (limited to 'src/libsyntax/ext')
23 files changed, 263 insertions, 263 deletions
diff --git a/src/libsyntax/ext/auto_serialize.rs b/src/libsyntax/ext/auto_serialize.rs index f95a689f9c2..bcbe5c88110 100644 --- a/src/libsyntax/ext/auto_serialize.rs +++ b/src/libsyntax/ext/auto_serialize.rs @@ -164,12 +164,12 @@ impl ext_ctxt: ext_ctxt_helpers { } fn path(span: span, strs: ~[ast::ident]) -> @ast::path { - @{span: span, global: false, idents: strs, rp: none, types: ~[]} + @{span: span, global: false, idents: strs, rp: None, types: ~[]} } fn path_tps(span: span, strs: ~[ast::ident], tps: ~[@ast::ty]) -> @ast::path { - @{span: span, global: false, idents: strs, rp: none, types: tps} + @{span: span, global: false, idents: strs, rp: None, types: tps} } fn ty_path(span: span, strs: ~[ast::ident], @@ -215,7 +215,7 @@ impl ext_ctxt: ext_ctxt_helpers { fn blk(span: span, stmts: ~[@ast::stmt]) -> ast::blk { {node: {view_items: ~[], stmts: stmts, - expr: none, + expr: None, id: self.next_id(), rules: ast::default_blk}, span: span} @@ -224,7 +224,7 @@ impl ext_ctxt: ext_ctxt_helpers { fn expr_blk(expr: @ast::expr) -> ast::blk { {node: {view_items: ~[], stmts: ~[], - expr: some(expr), + expr: Some(expr), id: self.next_id(), rules: ast::default_blk}, span: expr.span} @@ -232,11 +232,11 @@ impl ext_ctxt: ext_ctxt_helpers { fn binder_pat(span: span, nm: ast::ident) -> @ast::pat { let path = @{span: span, global: false, idents: ~[nm], - rp: none, types: ~[]}; + rp: None, types: ~[]}; @{id: self.next_id(), node: ast::pat_ident(ast::bind_by_implicit_ref, path, - none), + None), span: span} } @@ -374,7 +374,7 @@ fn ser_variant(cx: ext_ctxt, let body_blk = cx.blk(span, stmts); let body = cx.blk(span, ~[cx.stmt(bodyfn(s, body_blk))]); - {pats: ~[pat], guard: none, body: body} + {pats: ~[pat], guard: None, body: body} } fn ser_lambda(cx: ext_ctxt, tps: ser_tps_map, ty: @ast::ty, @@ -387,7 +387,7 @@ fn is_vec_or_str(ty: @ast::ty) -> bool { ast::ty_vec(_) => true, // This may be wrong if the user has shadowed (!) str ast::ty_path(@{span: _, global: _, idents: ids, - rp: none, types: _}, _) + rp: None, types: _}, _) if ids == ~[parse::token::special_idents::str] => true, _ => false } @@ -493,8 +493,8 @@ fn ser_ty(cx: ext_ctxt, tps: ser_tps_map, let ident = path.idents[0]; match tps.find(ident) { - some(f) => f(v), - none => ser_path(cx, tps, path, s, v) + Some(f) => f(v), + None => ser_path(cx, tps, path, s, v) } } else { ser_path(cx, tps, path, s, v) @@ -684,7 +684,7 @@ fn deser_ty(cx: ext_ctxt, tps: deser_tps_map, expr: #ast{ $(d).read_rec_field($(f), $(i), $(l))} }, span: fld.span} }; - let fld_expr = cx.expr(ty.span, ast::expr_rec(fields, none)); + let fld_expr = cx.expr(ty.span, ast::expr_rec(fields, None)); let fld_lambda = cx.lambda(cx.expr_blk(fld_expr)); #ast{ $(d).read_rec($(fld_lambda)) } } @@ -720,8 +720,8 @@ fn deser_ty(cx: ext_ctxt, tps: deser_tps_map, let ident = path.idents[0]; match tps.find(ident) { - some(f) => f(), - none => deser_path(cx, tps, path, d) + Some(f) => f(), + None => deser_path(cx, tps, path, d) } } else { deser_path(cx, tps, path, d) @@ -850,10 +850,10 @@ fn ser_enum(cx: ext_ctxt, tps: ser_tps_map, e_name: ast::ident, if vec::is_empty(pats) { ast::pat_ident(ast::bind_by_implicit_ref, cx.path(v_span, ~[v_name]), - none) + None) } else { ast::pat_enum(cx.path(v_span, ~[v_name]), - some(pats)) + Some(pats)) } }, @@ -928,17 +928,17 @@ fn deser_enum(cx: ext_ctxt, tps: deser_tps_map, e_name: ast::ident, {pats: ~[@{id: cx.next_id(), node: ast::pat_lit(cx.lit_uint(v_span, vidx)), span: v_span}], - guard: none, + guard: None, body: cx.expr_blk(body)} }; let impossible_case = {pats: ~[@{id: cx.next_id(), node: ast::pat_wild, span: e_span}], - guard: none, + guard: None, // FIXME #3198: proper error message body: cx.expr_blk(cx.expr(e_span, - ast::expr_fail(none)))}; + ast::expr_fail(None)))}; arms += ~[impossible_case]; // Generate code like: diff --git a/src/libsyntax/ext/base.rs b/src/libsyntax/ext/base.rs index 796f0400190..7a3eb4b67e9 100644 --- a/src/libsyntax/ext/base.rs +++ b/src/libsyntax/ext/base.rs @@ -21,7 +21,7 @@ import std::map::str_hash; type syntax_expander_ = fn@(ext_ctxt, span, ast::mac_arg, ast::mac_body) -> @ast::expr; // second argument is the origin of the macro, if user-defined -type syntax_expander = {expander: syntax_expander_, span: option<span>}; +type syntax_expander = {expander: syntax_expander_, span: Option<span>}; type macro_def = {name: ~str, ext: syntax_extension}; @@ -32,12 +32,12 @@ type macro_definer = type item_decorator = fn@(ext_ctxt, span, ast::meta_item, ~[@ast::item]) -> ~[@ast::item]; -type syntax_expander_tt = {expander: syntax_expander_tt_, span: option<span>}; +type syntax_expander_tt = {expander: syntax_expander_tt_, span: Option<span>}; type syntax_expander_tt_ = fn@(ext_ctxt, span, ~[ast::token_tree]) -> mac_result; type syntax_expander_tt_item - = {expander: syntax_expander_tt_item_, span: option<span>}; + = {expander: syntax_expander_tt_item_, span: Option<span>}; type syntax_expander_tt_item_ = fn@(ext_ctxt, span, ast::ident, ~[ast::token_tree]) -> mac_result; @@ -67,12 +67,12 @@ enum syntax_extension { // AST nodes into full ASTs fn syntax_expander_table() -> hashmap<~str, syntax_extension> { fn builtin(f: syntax_expander_) -> syntax_extension - {normal({expander: f, span: none})} + {normal({expander: f, span: None})} fn builtin_expr_tt(f: syntax_expander_tt_) -> syntax_extension { - expr_tt({expander: f, span: none}) + expr_tt({expander: f, span: None}) } fn builtin_item_tt(f: syntax_expander_tt_item_) -> syntax_extension { - item_tt({expander: f, span: none}) + item_tt({expander: f, span: None}) } let syntax_expanders = str_hash::<syntax_extension>(); syntax_expanders.insert(~"macro", @@ -166,7 +166,7 @@ fn mk_ctxt(parse_sess: parse::parse_sess, match ei { expanded_from({call_site: cs, callie: callie}) => { self.backtrace = - some(@expanded_from({ + Some(@expanded_from({ call_site: {lo: cs.lo, hi: cs.hi, expn_info: self.backtrace}, callie: callie})); @@ -175,7 +175,7 @@ fn mk_ctxt(parse_sess: parse::parse_sess, } fn bt_pop() { match self.backtrace { - some(@expanded_from({call_site: {expn_info: prev, _}, _})) => { + Some(@expanded_from({call_site: {expn_info: prev, _}, _})) => { self.backtrace = prev } _ => self.bug(~"tried to pop without a push") @@ -225,7 +225,7 @@ fn mk_ctxt(parse_sess: parse::parse_sess, let imp : ctxt_repr = { parse_sess: parse_sess, cfg: cfg, - mut backtrace: none, + mut backtrace: None, mut mod_path: ~[], mut trace_mac: false }; @@ -255,22 +255,22 @@ fn expr_to_ident(cx: ext_ctxt, expr: @ast::expr, error: ~str) -> ast::ident { fn get_mac_args_no_max(cx: ext_ctxt, sp: span, arg: ast::mac_arg, min: uint, name: ~str) -> ~[@ast::expr] { - return get_mac_args(cx, sp, arg, min, none, name); + return get_mac_args(cx, sp, arg, min, None, name); } fn get_mac_args(cx: ext_ctxt, sp: span, arg: ast::mac_arg, - min: uint, max: option<uint>, name: ~str) -> ~[@ast::expr] { + min: uint, max: Option<uint>, name: ~str) -> ~[@ast::expr] { match arg { - some(expr) => match expr.node { + Some(expr) => match expr.node { ast::expr_vec(elts, _) => { let elts_len = vec::len(elts); match max { - some(max) if ! (min <= elts_len && elts_len <= max) => { + Some(max) if ! (min <= elts_len && elts_len <= max) => { cx.span_fatal(sp, fmt!("#%s takes between %u and %u arguments.", name, min, max)); } - none if ! (min <= elts_len) => { + None if ! (min <= elts_len) => { cx.span_fatal(sp, fmt!("#%s needs at least %u arguments.", name, min)); } @@ -281,7 +281,7 @@ fn get_mac_args(cx: ext_ctxt, sp: span, arg: ast::mac_arg, cx.span_fatal(sp, fmt!("#%s: malformed invocation", name)) } }, - none => cx.span_fatal(sp, fmt!("#%s: missing arguments", name)) + None => cx.span_fatal(sp, fmt!("#%s: missing arguments", name)) } } @@ -289,8 +289,8 @@ fn get_mac_body(cx: ext_ctxt, sp: span, args: ast::mac_body) -> ast::mac_body_ { match (args) { - some(body) => body, - none => cx.span_fatal(sp, ~"missing macro body") + Some(body) => body, + None => cx.span_fatal(sp, ~"missing macro body") } } @@ -306,16 +306,16 @@ fn tt_args_to_original_flavor(cx: ext_ctxt, sp: span, arg: ~[ast::token_tree]) // these spans won't matter, anyways fn ms(m: matcher_) -> matcher { - {node: m, span: {lo: 0u, hi: 0u, expn_info: none}} + {node: m, span: {lo: 0u, hi: 0u, expn_info: None}} } let arg_nm = cx.parse_sess().interner.gensym(@~"arg"); let argument_gram = ~[ms(match_seq(~[ ms(match_nonterminal(arg_nm, parse::token::special_idents::expr, 0u)) - ], some(parse::token::COMMA), true, 0u, 1u))]; + ], Some(parse::token::COMMA), true, 0u, 1u))]; let arg_reader = new_tt_reader(cx.parse_sess().span_diagnostic, - cx.parse_sess().interner, none, arg); + cx.parse_sess().interner, None, arg); let args = match parse_or_else(cx.parse_sess(), cx.cfg(), arg_reader as reader, argument_gram).get(arg_nm) { @@ -331,7 +331,7 @@ fn tt_args_to_original_flavor(cx: ext_ctxt, sp: span, arg: ~[ast::token_tree]) _ => fail ~"badly-structured parse result" }; - return some(@{id: parse::next_node_id(cx.parse_sess()), + return Some(@{id: parse::next_node_id(cx.parse_sess()), callee_id: parse::next_node_id(cx.parse_sess()), node: ast::expr_vec(args, ast::m_imm), span: sp}); } diff --git a/src/libsyntax/ext/build.rs b/src/libsyntax/ext/build.rs index ab2d93faabe..2207dee09c6 100644 --- a/src/libsyntax/ext/build.rs +++ b/src/libsyntax/ext/build.rs @@ -37,7 +37,7 @@ fn mk_unary(cx: ext_ctxt, sp: span, op: ast::unop, e: @ast::expr) fn mk_path(cx: ext_ctxt, sp: span, idents: ~[ast::ident]) -> @ast::expr { let path = @{span: sp, global: false, idents: idents, - rp: none, types: ~[]}; + rp: None, types: ~[]}; let pathexpr = ast::expr_path(path); mk_expr(cx, sp, pathexpr) } @@ -75,7 +75,7 @@ fn mk_uniq_vec_e(cx: ext_ctxt, sp: span, exprs: ~[@ast::expr]) -> } fn mk_fixed_vec_e(cx: ext_ctxt, sp: span, exprs: ~[@ast::expr]) -> @ast::expr { - mk_vstore_e(cx, sp, mk_base_vec_e(cx, sp, exprs), ast::vstore_fixed(none)) + mk_vstore_e(cx, sp, mk_base_vec_e(cx, sp, exprs), ast::vstore_fixed(None)) } fn mk_base_str(cx: ext_ctxt, sp: span, s: ~str) -> @ast::expr { let lit = ast::lit_str(@s); @@ -96,7 +96,7 @@ fn mk_rec_e(cx: ext_ctxt, sp: span, {node: {mutbl: ast::m_imm, ident: ident, expr: val}, span: sp}; vec::push(astfields, astfield); } - let recexpr = ast::expr_rec(astfields, option::none::<@ast::expr>); + let recexpr = ast::expr_rec(astfields, option::None::<@ast::expr>); mk_expr(cx, sp, recexpr) } diff --git a/src/libsyntax/ext/concat_idents.rs b/src/libsyntax/ext/concat_idents.rs index b53a0439e59..4e344d62626 100644 --- a/src/libsyntax/ext/concat_idents.rs +++ b/src/libsyntax/ext/concat_idents.rs @@ -13,6 +13,6 @@ fn expand_syntax_ext(cx: ext_ctxt, sp: codemap::span, arg: ast::mac_arg, return @{id: cx.next_id(), callee_id: cx.next_id(), node: ast::expr_path(@{span: sp, global: false, idents: ~[res], - rp: none, types: ~[]}), + rp: None, types: ~[]}), span: sp}; } diff --git a/src/libsyntax/ext/env.rs b/src/libsyntax/ext/env.rs index 01030591da9..9720eb7d4ce 100644 --- a/src/libsyntax/ext/env.rs +++ b/src/libsyntax/ext/env.rs @@ -10,15 +10,15 @@ export expand_syntax_ext; fn expand_syntax_ext(cx: ext_ctxt, sp: codemap::span, arg: ast::mac_arg, _body: ast::mac_body) -> @ast::expr { - let args = get_mac_args(cx, sp, arg, 1u, option::some(1u), ~"env"); + let args = get_mac_args(cx, sp, arg, 1u, option::Some(1u), ~"env"); // FIXME (#2248): if this was more thorough it would manufacture an - // option<str> rather than just an maybe-empty string. + // Option<str> rather than just an maybe-empty string. let var = expr_to_str(cx, args[0], ~"#env requires a string"); match os::getenv(var) { - option::none => return mk_uniq_str(cx, sp, ~""), - option::some(s) => return mk_uniq_str(cx, sp, s) + option::None => return mk_uniq_str(cx, sp, ~""), + option::Some(s) => return mk_uniq_str(cx, sp, s) } } diff --git a/src/libsyntax/ext/expand.rs b/src/libsyntax/ext/expand.rs index a66b37b49bd..366207ee427 100644 --- a/src/libsyntax/ext/expand.rs +++ b/src/libsyntax/ext/expand.rs @@ -29,16 +29,16 @@ fn expand_expr(exts: hashmap<~str, syntax_extension>, cx: ext_ctxt, the macro names be hygienic */ let extname = cx.parse_sess().interner.get(pth.idents[0]); match exts.find(*extname) { - none => { + None => { cx.span_fatal(pth.span, fmt!("macro undefined: '%s'", *extname)) } - some(item_decorator(_)) => { + Some(item_decorator(_)) => { cx.span_fatal( pth.span, fmt!("%s can only be used as a decorator", *extname)); } - some(normal({expander: exp, span: exp_sp})) => { + Some(normal({expander: exp, span: exp_sp})) => { let expanded = exp(cx, mac.span, args, body); cx.bt_push(expanded_from({call_site: s, @@ -49,17 +49,17 @@ fn expand_expr(exts: hashmap<~str, syntax_extension>, cx: ext_ctxt, (fully_expanded, s) } - some(macro_defining(ext)) => { + Some(macro_defining(ext)) => { let named_extension = ext(cx, mac.span, args, body); exts.insert(named_extension.name, named_extension.ext); - (ast::expr_rec(~[], none), s) + (ast::expr_rec(~[], None), s) } - some(expr_tt(_)) => { + Some(expr_tt(_)) => { cx.span_fatal(pth.span, fmt!("this tt-style macro should be \ invoked '%s!(...)'", *extname)) } - some(item_tt(*)) => { + Some(item_tt(*)) => { cx.span_fatal(pth.span, ~"cannot use item macros in this context"); } @@ -74,11 +74,11 @@ fn expand_expr(exts: hashmap<~str, syntax_extension>, cx: ext_ctxt, the macro names be hygienic */ let extname = cx.parse_sess().interner.get(pth.idents[0]); match exts.find(*extname) { - none => { + None => { cx.span_fatal(pth.span, fmt!("macro undefined: '%s'", *extname)) } - some(expr_tt({expander: exp, span: exp_sp})) => { + Some(expr_tt({expander: exp, span: exp_sp})) => { let expanded = match exp(cx, mac.span, tts) { mr_expr(e) => e, _ => cx.span_fatal( @@ -94,11 +94,11 @@ fn expand_expr(exts: hashmap<~str, syntax_extension>, cx: ext_ctxt, (fully_expanded, s) } - some(normal({expander: exp, span: exp_sp})) => { + Some(normal({expander: exp, span: exp_sp})) => { //convert the new-style invoc for the old-style macro let arg = base::tt_args_to_original_flavor(cx, pth.span, tts); - let expanded = exp(cx, mac.span, arg, none); + let expanded = exp(cx, mac.span, arg, None); cx.bt_push(expanded_from({call_site: s, callie: {name: *extname, span: exp_sp}})); @@ -151,9 +151,9 @@ fn expand_mod_items(exts: hashmap<~str, syntax_extension>, cx: ext_ctxt, ast::meta_list(n, _) => n }; match exts.find(mname) { - none | some(normal(_)) | some(macro_defining(_)) - | some(expr_tt(_)) | some(item_tt(*)) => items, - some(item_decorator(dec_fn)) => { + None | Some(normal(_)) | Some(macro_defining(_)) + | Some(expr_tt(_)) | Some(item_tt(*)) => items, + Some(item_decorator(dec_fn)) => { dec_fn(cx, attr.span, attr.node.value, items) } } @@ -167,8 +167,8 @@ fn expand_mod_items(exts: hashmap<~str, syntax_extension>, cx: ext_ctxt, // When we enter a module, record it, for the sake of `module!` fn expand_item(exts: hashmap<~str, syntax_extension>, cx: ext_ctxt, &&it: @ast::item, fld: ast_fold, - orig: fn@(&&@ast::item, ast_fold) -> option<@ast::item>) - -> option<@ast::item> + orig: fn@(&&@ast::item, ast_fold) -> Option<@ast::item>) + -> Option<@ast::item> { let is_mod = match it.node { ast::item_mod(_) | ast::item_foreign_mod(_) => true, @@ -176,17 +176,17 @@ fn expand_item(exts: hashmap<~str, syntax_extension>, }; let maybe_it = match it.node { ast::item_mac(*) => expand_item_mac(exts, cx, it, fld), - _ => some(it) + _ => Some(it) }; match maybe_it { - some(it) => { + Some(it) => { if is_mod { cx.mod_push(it.ident); } let ret_val = orig(it, fld); if is_mod { cx.mod_pop(); } return ret_val; } - none => return none + None => return None } } @@ -195,16 +195,16 @@ fn expand_item(exts: hashmap<~str, syntax_extension>, // logic as for expression-position macro invocations. fn expand_item_mac(exts: hashmap<~str, syntax_extension>, cx: ext_ctxt, &&it: @ast::item, - fld: ast_fold) -> option<@ast::item> { + fld: ast_fold) -> Option<@ast::item> { match it.node { item_mac({node: mac_invoc_tt(pth, tts), span}) => { let extname = cx.parse_sess().interner.get(pth.idents[0]); match exts.find(*extname) { - none => { + None => { cx.span_fatal(pth.span, fmt!("macro undefined: '%s'", *extname)) } - some(item_tt(expand)) => { + Some(item_tt(expand)) => { let expanded = expand.expander(cx, it.span, it.ident, tts); cx.bt_push(expanded_from({call_site: it.span, callie: {name: *extname, @@ -216,7 +216,7 @@ fn expand_item_mac(exts: hashmap<~str, syntax_extension>, *extname), mr_def(mdef) => { exts.insert(mdef.name, mdef.ext); - none + None } }; cx.bt_pop(); diff --git a/src/libsyntax/ext/fmt.rs b/src/libsyntax/ext/fmt.rs index 6e459a551fe..829e16e3992 100644 --- a/src/libsyntax/ext/fmt.rs +++ b/src/libsyntax/ext/fmt.rs @@ -135,7 +135,7 @@ fn pieces_to_expr(cx: ext_ctxt, sp: span, } let unsupported = ~"conversion not supported in #fmt string"; match cnv.param { - option::none => (), + option::None => (), _ => cx.span_unimpl(sp, unsupported) } for cnv.flags.each |f| { @@ -192,7 +192,7 @@ fn pieces_to_expr(cx: ext_ctxt, sp: span, } fn log_conv(c: conv) { match c.param { - some(p) => { log(debug, ~"param: " + int::to_str(p, 10u)); } + Some(p) => { log(debug, ~"param: " + int::to_str(p, 10u)); } _ => debug!("param: none") } for c.flags.each |f| { diff --git a/src/libsyntax/ext/ident_to_str.rs b/src/libsyntax/ext/ident_to_str.rs index 9daaf164562..cc083643fc9 100644 --- a/src/libsyntax/ext/ident_to_str.rs +++ b/src/libsyntax/ext/ident_to_str.rs @@ -4,7 +4,7 @@ import option; fn expand_syntax_ext(cx: ext_ctxt, sp: codemap::span, arg: ast::mac_arg, _body: ast::mac_body) -> @ast::expr { - let args = get_mac_args(cx,sp,arg,1u,option::some(1u),~"ident_to_str"); + let args = get_mac_args(cx,sp,arg,1u,option::Some(1u),~"ident_to_str"); return mk_uniq_str(cx, sp, *cx.parse_sess().interner.get( expr_to_ident(cx, args[0u], ~"expected an ident"))); diff --git a/src/libsyntax/ext/log_syntax.rs b/src/libsyntax/ext/log_syntax.rs index 61bb00fd6de..88e11f37513 100644 --- a/src/libsyntax/ext/log_syntax.rs +++ b/src/libsyntax/ext/log_syntax.rs @@ -10,5 +10,5 @@ fn expand_syntax_ext(cx: ext_ctxt, sp: codemap::span, tt: ~[ast::token_tree]) //trivial expression return mr_expr(@{id: cx.next_id(), callee_id: cx.next_id(), - node: ast::expr_rec(~[], option::none), span: sp}); + node: ast::expr_rec(~[], option::None), span: sp}); } diff --git a/src/libsyntax/ext/pipes.rs b/src/libsyntax/ext/pipes.rs index 479e3afe51b..2e9125d6c22 100644 --- a/src/libsyntax/ext/pipes.rs +++ b/src/libsyntax/ext/pipes.rs @@ -50,7 +50,7 @@ fn expand_proto(cx: ext_ctxt, _sp: span, id: ast::ident, let sess = cx.parse_sess(); let cfg = cx.cfg(); let tt_rdr = new_tt_reader(cx.parse_sess().span_diagnostic, - cx.parse_sess().interner, none, tt); + cx.parse_sess().interner, None, tt); let rdr = tt_rdr as reader; let rust_parser = parser(sess, cfg, rdr.dup(), SOURCE_FILE); diff --git a/src/libsyntax/ext/pipes/ast_builder.rs b/src/libsyntax/ext/pipes/ast_builder.rs index 8b134239fc1..d0a5757ed1f 100644 --- a/src/libsyntax/ext/pipes/ast_builder.rs +++ b/src/libsyntax/ext/pipes/ast_builder.rs @@ -19,12 +19,12 @@ fn path(ids: ~[ident], span: span) -> @ast::path { @{span: span, global: false, idents: ids, - rp: none, + rp: None, types: ~[]} } fn empty_span() -> span { - {lo: 0, hi: 0, expn_info: none} + {lo: 0, hi: 0, expn_info: None} } trait append_types { @@ -90,7 +90,7 @@ trait ext_ctxt_ast_builder { impl ext_ctxt: ext_ctxt_ast_builder { fn ty_option(ty: @ast::ty) -> @ast::ty { - self.ty_path_ast_builder(path(~[self.ident_of(~"option")], + self.ty_path_ast_builder(path(~[self.ident_of(~"Option")], self.empty_span()) .add_ty(ty)) } @@ -125,9 +125,9 @@ impl ext_ctxt: ext_ctxt_ast_builder { node: ast::pat_ident(ast::bind_by_implicit_ref, path(~[ident], self.empty_span()), - none), + None), span: self.empty_span()}, - init: some({op: ast::init_move, + init: Some({op: ast::init_move, expr: e}), id: self.next_id()}, span: self.empty_span()}]), @@ -143,7 +143,7 @@ impl ext_ctxt: ext_ctxt_ast_builder { fn rec(+fields: ~[ast::field]) -> @ast::expr { @{id: self.next_id(), callee_id: self.next_id(), - node: ast::expr_rec(fields, none), + node: ast::expr_rec(fields, None), span: self.empty_span()} } @@ -187,7 +187,7 @@ impl ext_ctxt: ext_ctxt_ast_builder { fn block(+stmts: ~[@ast::stmt], e: @ast::expr) -> ast::blk { let blk = {view_items: ~[], stmts: stmts, - expr: some(e), + expr: Some(e), id: self.next_id(), rules: ast::default_blk}; @@ -258,7 +258,7 @@ impl ext_ctxt: ext_ctxt_ast_builder { attrs: ~[], kind: ast::tuple_variant_kind(args), id: self.next_id(), - disr_expr: none, + disr_expr: None, vis: ast::public}, span: span} } diff --git a/src/libsyntax/ext/pipes/check.rs b/src/libsyntax/ext/pipes/check.rs index 60d1d666a7f..3468754b6f8 100644 --- a/src/libsyntax/ext/pipes/check.rs +++ b/src/libsyntax/ext/pipes/check.rs @@ -41,7 +41,7 @@ impl ext_ctxt: proto::visitor<(), (), ()> { fn visit_message(name: ~str, _span: span, _tys: &[@ast::ty], this: state, next: next_state) { match next { - some({state: next, tys: next_tys}) => { + Some({state: next, tys: next_tys}) => { let proto = this.proto; if !proto.has_state(next) { // This should be a span fatal, but then we need to @@ -65,7 +65,7 @@ impl ext_ctxt: proto::visitor<(), (), ()> { } } } - none => () + None => () } } } \ No newline at end of file diff --git a/src/libsyntax/ext/pipes/liveness.rs b/src/libsyntax/ext/pipes/liveness.rs index a3dfdb6a769..70a2af46625 100644 --- a/src/libsyntax/ext/pipes/liveness.rs +++ b/src/libsyntax/ext/pipes/liveness.rs @@ -82,10 +82,10 @@ fn analyze(proto: protocol, _cx: ext_ctxt) { // *proto.name, // states)); - proto.bounded = some(false); + proto.bounded = Some(false); } else { debug!("protocol %s is bounded. yay!", proto.name); - proto.bounded = some(true); + proto.bounded = Some(true); } } \ No newline at end of file diff --git a/src/libsyntax/ext/pipes/parse_proto.rs b/src/libsyntax/ext/pipes/parse_proto.rs index 4dc61e54aa4..c6562b068f3 100644 --- a/src/libsyntax/ext/pipes/parse_proto.rs +++ b/src/libsyntax/ext/pipes/parse_proto.rs @@ -15,7 +15,7 @@ impl parser: proto_parser { let proto = protocol(id, self.span); self.parse_seq_to_before_end(token::EOF, - {sep: none, trailing_sep_allowed: false}, + {sep: None, trailing_sep_allowed: false}, |self| self.parse_state(proto)); return proto; @@ -47,7 +47,7 @@ impl parser: proto_parser { // parse the messages self.parse_unspanned_seq( token::LBRACE, token::RBRACE, - {sep: some(token::COMMA), trailing_sep_allowed: true}, + {sep: Some(token::COMMA), trailing_sep_allowed: true}, |self| self.parse_message(state)); } @@ -57,7 +57,7 @@ impl parser: proto_parser { let args = if self.token == token::LPAREN { self.parse_unspanned_seq(token::LPAREN, token::RPAREN, - {sep: some(token::COMMA), + {sep: Some(token::COMMA), trailing_sep_allowed: true}, |p| p.parse_ty(false)) } @@ -71,17 +71,17 @@ impl parser: proto_parser { let ntys = if self.token == token::LT { self.parse_unspanned_seq(token::LT, token::GT, - {sep: some(token::COMMA), + {sep: Some(token::COMMA), trailing_sep_allowed: true}, |p| p.parse_ty(false)) } else { ~[] }; - some({state: name, tys: ntys}) + Some({state: name, tys: ntys}) } token::NOT => { // -> ! self.bump(); - none + None } _ => self.fatal(~"invalid next state") }; diff --git a/src/libsyntax/ext/pipes/pipec.rs b/src/libsyntax/ext/pipes/pipec.rs index 1c501120c06..f527d9f79f3 100644 --- a/src/libsyntax/ext/pipes/pipec.rs +++ b/src/libsyntax/ext/pipes/pipec.rs @@ -42,7 +42,7 @@ impl message: gen_send { debug!("pipec: gen_send"); match self { message(_id, span, tys, this, - some({state: next, tys: next_tys})) => { + Some({state: next, tys: next_tys})) => { debug!("pipec: next state exists"); let next = this.proto.get_state(next); assert next_tys.len() == next.ty_params.len(); @@ -126,7 +126,7 @@ impl message: gen_send { cx.expr_block(body)) } - message(_id, span, tys, this, none) => { + message(_id, span, tys, this, None) => { debug!("pipec: no next state"); let arg_names = tys.mapi(|i, _ty| (~"x_" + i.to_str())); @@ -207,7 +207,7 @@ impl state: to_type_decls { let message(name, span, tys, this, next) = m; let tys = match next { - some({state: next, tys: next_tys}) => { + Some({state: next, tys: next_tys}) => { let next = this.proto.get_state(next); let next_name = cx.str_of(next.data_name()); @@ -222,7 +222,7 @@ impl state: to_type_decls { cx.ident_of(next_name)], span) .add_tys(next_tys))) } - none => tys + None => tys }; let v = cx.variant(cx.ident_of(name), span, tys); @@ -233,7 +233,7 @@ impl state: to_type_decls { ~[cx.item_enum_poly(name, self.span, ast::enum_def({ variants: items_msg, - common: none }), + common: None }), self.ty_params)] } @@ -368,7 +368,7 @@ impl protocol: gen_init { for (copy self.states).each |s| { for s.ty_params.each |tp| { match params.find(|tpp| tp.ident == tpp.ident) { - none => vec::push(params, tp), + None => vec::push(params, tp), _ => () } } @@ -384,7 +384,7 @@ impl protocol: gen_init { let fields = do (copy self.states).map_to_vec |s| { for s.ty_params.each |tp| { match params.find(|tpp| tp.ident == tpp.ident) { - none => vec::push(params, tp), + None => vec::push(params, tp), _ => () } } @@ -488,8 +488,8 @@ impl ext_ctxt: ext_ctxt_parse_utils { ~[], self.parse_sess()); match res { - some(ast) => ast, - none => { + Some(ast) => ast, + None => { error!("Parse error with ```\n%s\n```", s); fail } diff --git a/src/libsyntax/ext/pipes/proto.rs b/src/libsyntax/ext/pipes/proto.rs index eea4e434956..7f9b9acd8e2 100644 --- a/src/libsyntax/ext/pipes/proto.rs +++ b/src/libsyntax/ext/pipes/proto.rs @@ -25,7 +25,7 @@ impl direction { } } -type next_state = option<{state: ~str, tys: ~[@ast::ty]}>; +type next_state = Option<{state: ~str, tys: ~[@ast::ty]}>; enum message { // name, span, data, current state, next state @@ -93,7 +93,7 @@ impl state { fn reachable(f: fn(state) -> bool) { for self.messages.each |m| { match m { - message(_, _, _, _, some({state: id, _})) => { + message(_, _, _, _, Some({state: id, _})) => { let state = self.proto.get_state(id); if !f(state) { break } } @@ -114,13 +114,13 @@ struct protocol_ { let span: span; let states: DVec<state>; - let mut bounded: option<bool>; + let mut bounded: Option<bool>; new(name: ~str, span: span) { self.name = name; self.span = span; self.states = dvec(); - self.bounded = none; + self.bounded = None; } /// Get a state. @@ -131,7 +131,7 @@ struct protocol_ { fn get_state_by_id(id: uint) -> state { self.states[id] } fn has_state(name: ~str) -> bool { - self.states.find(|i| i.name == name) != none + self.states.find(|i| i.name == name) != None } fn filename() -> ~str { diff --git a/src/libsyntax/ext/qquote.rs b/src/libsyntax/ext/qquote.rs index de4d1975e24..38108861b47 100644 --- a/src/libsyntax/ext/qquote.rs +++ b/src/libsyntax/ext/qquote.rs @@ -38,7 +38,7 @@ fn id_ext(cx: ext_ctxt, str: ~str) -> ast::ident { trait qq_helper { fn span() -> span; fn visit(aq_ctxt, vt<aq_ctxt>); - fn extract_mac() -> option<ast::mac_>; + fn extract_mac() -> Option<ast::mac_>; fn mk_parse_fn(ext_ctxt,span) -> @ast::expr; fn get_fold_fn() -> ~str; } @@ -46,7 +46,7 @@ trait qq_helper { impl @ast::crate: qq_helper { fn span() -> span {self.span} fn visit(cx: aq_ctxt, v: vt<aq_ctxt>) {visit_crate(*self, cx, v);} - fn extract_mac() -> option<ast::mac_> {fail} + fn extract_mac() -> Option<ast::mac_> {fail} fn mk_parse_fn(cx: ext_ctxt, sp: span) -> @ast::expr { mk_path(cx, sp, ids_ext(cx, ~[~"syntax", ~"ext", ~"qquote", ~"parse_crate"])) @@ -56,10 +56,10 @@ impl @ast::crate: qq_helper { impl @ast::expr: qq_helper { fn span() -> span {self.span} fn visit(cx: aq_ctxt, v: vt<aq_ctxt>) {visit_expr(self, cx, v);} - fn extract_mac() -> option<ast::mac_> { + fn extract_mac() -> Option<ast::mac_> { match (self.node) { - ast::expr_mac({node: mac, _}) => some(mac), - _ => none + ast::expr_mac({node: mac, _}) => Some(mac), + _ => None } } fn mk_parse_fn(cx: ext_ctxt, sp: span) -> @ast::expr { @@ -71,10 +71,10 @@ impl @ast::expr: qq_helper { impl @ast::ty: qq_helper { fn span() -> span {self.span} fn visit(cx: aq_ctxt, v: vt<aq_ctxt>) {visit_ty(self, cx, v);} - fn extract_mac() -> option<ast::mac_> { + fn extract_mac() -> Option<ast::mac_> { match (self.node) { - ast::ty_mac({node: mac, _}) => some(mac), - _ => none + ast::ty_mac({node: mac, _}) => Some(mac), + _ => None } } fn mk_parse_fn(cx: ext_ctxt, sp: span) -> @ast::expr { @@ -86,7 +86,7 @@ impl @ast::ty: qq_helper { impl @ast::item: qq_helper { fn span() -> span {self.span} fn visit(cx: aq_ctxt, v: vt<aq_ctxt>) {visit_item(self, cx, v);} - fn extract_mac() -> option<ast::mac_> {fail} + fn extract_mac() -> Option<ast::mac_> {fail} fn mk_parse_fn(cx: ext_ctxt, sp: span) -> @ast::expr { mk_path(cx, sp, ids_ext(cx, ~[~"syntax", ~"ext", ~"qquote", ~"parse_item"])) @@ -96,7 +96,7 @@ impl @ast::item: qq_helper { impl @ast::stmt: qq_helper { fn span() -> span {self.span} fn visit(cx: aq_ctxt, v: vt<aq_ctxt>) {visit_stmt(self, cx, v);} - fn extract_mac() -> option<ast::mac_> {fail} + fn extract_mac() -> Option<ast::mac_> {fail} fn mk_parse_fn(cx: ext_ctxt, sp: span) -> @ast::expr { mk_path(cx, sp, ids_ext(cx, ~[~"syntax", ~"ext", ~"qquote", ~"parse_stmt"])) @@ -106,7 +106,7 @@ impl @ast::stmt: qq_helper { impl @ast::pat: qq_helper { fn span() -> span {self.span} fn visit(cx: aq_ctxt, v: vt<aq_ctxt>) {visit_pat(self, cx, v);} - fn extract_mac() -> option<ast::mac_> {fail} + fn extract_mac() -> Option<ast::mac_> {fail} fn mk_parse_fn(cx: ext_ctxt, sp: span) -> @ast::expr { mk_path(cx, sp, ids_ext(cx, ~[~"syntax", ~"ext", ~"qquote", ~"parse_pat"])) @@ -135,7 +135,7 @@ fn gather_anti_quotes<N: qq_helper>(lo: uint, node: N) -> aq_ctxt fn visit_aq<T:qq_helper>(node: T, constr: ~str, &&cx: aq_ctxt, v: vt<aq_ctxt>) { match (node.extract_mac()) { - some(mac_aq(sp, e)) => { + Some(mac_aq(sp, e)) => { cx.gather.push(gather_item { lo: sp.lo - cx.lo, hi: sp.hi - cx.lo, @@ -194,8 +194,8 @@ fn parse_pat(p: parser) -> @ast::pat { p.parse_pat(true) } fn parse_item(p: parser) -> @ast::item { match p.parse_item(~[]) { - some(item) => item, - none => fail ~"parse_item: parsing an item failed" + Some(item) => item, + None => fail ~"parse_item: parsing an item failed" } } diff --git a/src/libsyntax/ext/simplext.rs b/src/libsyntax/ext/simplext.rs index 6a9507f5ce3..ee65d81974e 100644 --- a/src/libsyntax/ext/simplext.rs +++ b/src/libsyntax/ext/simplext.rs @@ -11,11 +11,11 @@ import ast::{ident, path, ty, blk_, expr, expr_path, export add_new_extension; -fn path_to_ident(pth: @path) -> option<ident> { +fn path_to_ident(pth: @path) -> Option<ident> { if vec::len(pth.idents) == 1u && vec::len(pth.types) == 0u { - return some(pth.idents[0u]); + return Some(pth.idents[0u]); } - return none; + return None; } //a vec of binders might be a little big. @@ -57,23 +57,23 @@ fn match_error(cx: ext_ctxt, m: matchable, expected: ~str) -> ! { // If we want better match failure error messages (like in Fortifying Syntax), // we'll want to return something indicating amount of progress and location // of failure instead of `none`. -type match_result = option<arb_depth<matchable>>; +type match_result = Option<arb_depth<matchable>>; type selector = fn@(matchable) -> match_result; fn elts_to_ell(cx: ext_ctxt, elts: ~[@expr]) -> - {pre: ~[@expr], rep: option<@expr>, post: ~[@expr]} { + {pre: ~[@expr], rep: Option<@expr>, post: ~[@expr]} { let mut idx: uint = 0u; - let mut res = none; + let mut res = None; for elts.each |elt| { match elt.node { expr_mac(m) => match m.node { ast::mac_ellipsis => { - if res != none { + if res != None { cx.span_fatal(m.span, ~"only one ellipsis allowed"); } res = - some({pre: vec::slice(elts, 0u, idx - 1u), - rep: some(elts[idx - 1u]), + Some({pre: vec::slice(elts, 0u, idx - 1u), + rep: Some(elts[idx - 1u]), post: vec::slice(elts, idx + 1u, vec::len(elts))}); } _ => () @@ -83,29 +83,29 @@ fn elts_to_ell(cx: ext_ctxt, elts: ~[@expr]) -> idx += 1u; } return match res { - some(val) => val, - none => {pre: elts, rep: none, post: ~[]} + Some(val) => val, + None => {pre: elts, rep: None, post: ~[]} } } -fn option_flatten_map<T: copy, U: copy>(f: fn@(T) -> option<U>, v: ~[T]) -> - option<~[U]> { +fn option_flatten_map<T: copy, U: copy>(f: fn@(T) -> Option<U>, v: ~[T]) -> + Option<~[U]> { let mut res = ~[]; for v.each |elem| { match f(elem) { - none => return none, - some(fv) => vec::push(res, fv) + None => return None, + Some(fv) => vec::push(res, fv) } } - return some(res); + return Some(res); } fn a_d_map(ad: arb_depth<matchable>, f: selector) -> match_result { match ad { leaf(x) => return f(x), seq(ads, span) => match option_flatten_map(|x| a_d_map(x, f), *ads) { - none => return none, - some(ts) => return some(seq(@ts, span)) + None => return None, + Some(ts) => return Some(seq(@ts, span)) } } } @@ -113,8 +113,8 @@ fn a_d_map(ad: arb_depth<matchable>, f: selector) -> match_result { fn compose_sels(s1: selector, s2: selector) -> selector { fn scomp(s1: selector, s2: selector, m: matchable) -> match_result { return match s1(m) { - none => none, - some(matches) => a_d_map(matches, s2) + None => None, + Some(matches) => a_d_map(matches, s2) } } return { |x| scomp(s1, s2, x) }; @@ -140,7 +140,7 @@ fn pattern_to_selectors(cx: ext_ctxt, e: @expr) -> binders { //this oughta return binders instead, but macro args are a sequence of //expressions, rather than a single expression fn trivial_selector(m: matchable) -> match_result { - return some(leaf(m)); + return Some(leaf(m)); } p_t_s_rec(cx, match_expr(e), trivial_selector, res); return res; @@ -152,22 +152,22 @@ fn pattern_to_selectors(cx: ext_ctxt, e: @expr) -> binders { bindings. Most of the work is done in p_t_s, which generates the selectors. */ -fn use_selectors_to_bind(b: binders, e: @expr) -> option<bindings> { +fn use_selectors_to_bind(b: binders, e: @expr) -> Option<bindings> { let res = uint_hash::<arb_depth<matchable>>(); //need to do this first, to check vec lengths. for b.literal_ast_matchers.each |sel| { - match sel(match_expr(e)) { none => return none, _ => () } + match sel(match_expr(e)) { None => return None, _ => () } } let mut never_mind: bool = false; for b.real_binders.each |key, val| { match val(match_expr(e)) { - none => never_mind = true, - some(mtc) => { res.insert(key, mtc); } + None => never_mind = true, + Some(mtc) => { res.insert(key, mtc); } } }; //HACK: `ret` doesn't work in `for each` - if never_mind { return none; } - return some(res); + if never_mind { return None; } + return Some(res); } /* use the bindings on the body to generate the expanded code */ @@ -217,18 +217,18 @@ pure fn follow(m: arb_depth<matchable>, idx_path: &[uint]) -> return res; } -fn follow_for_trans(cx: ext_ctxt, mmaybe: option<arb_depth<matchable>>, - idx_path: @mut ~[uint]) -> option<matchable> { +fn follow_for_trans(cx: ext_ctxt, mmaybe: Option<arb_depth<matchable>>, + idx_path: @mut ~[uint]) -> Option<matchable> { match mmaybe { - none => return none, - some(m) => { + None => return None, + Some(m) => { return match follow(m, *idx_path) { seq(_, sp) => { cx.span_fatal(sp, ~"syntax matched under ... but not " + ~"used that way.") } - leaf(m) => return some(m) + leaf(m) => return Some(m) } } } @@ -268,9 +268,9 @@ fn transcribe_exprs(cx: ext_ctxt, b: bindings, idx_path: @mut ~[uint], {pre: pre, rep: repeat_me_maybe, post: post} => { let mut res = vec::map(pre, recur); match repeat_me_maybe { - none => (), - some(repeat_me) => { - let mut repeat: option<{rep_count: uint, name: ident}> = none; + None => (), + Some(repeat_me) => { + let mut repeat: Option<{rep_count: uint, name: ident}> = None; /* we need to walk over all the free vars in lockstep, except for the leaves, which are just duplicated */ do free_vars(b, repeat_me) |fv| { @@ -280,10 +280,10 @@ fn transcribe_exprs(cx: ext_ctxt, b: bindings, idx_path: @mut ~[uint], leaf(_) => (), seq(ms, _) => { match repeat { - none => { - repeat = some({rep_count: vec::len(*ms), name: fv}); + None => { + repeat = Some({rep_count: vec::len(*ms), name: fv}); } - some({rep_count: old_len, name: old_name}) => { + Some({rep_count: old_len, name: old_name}) => { let len = vec::len(*ms); if old_len != len { let msg = wrong_occurs(cx, fv, len, @@ -296,12 +296,12 @@ fn transcribe_exprs(cx: ext_ctxt, b: bindings, idx_path: @mut ~[uint], } }; match repeat { - none => { + None => { cx.span_fatal(repeat_me.span, ~"'...' surrounds an expression without any" + ~" repeating syntax variables"); } - some({rep_count: rc, _}) => { + Some({rep_count: rc, _}) => { /* Whew, we now know how how many times to repeat */ let mut idx: uint = 0u; while idx < rc { @@ -326,9 +326,9 @@ fn transcribe_exprs(cx: ext_ctxt, b: bindings, idx_path: @mut ~[uint], fn transcribe_ident(cx: ext_ctxt, b: bindings, idx_path: @mut ~[uint], &&i: ident, _fld: ast_fold) -> ident { return match follow_for_trans(cx, b.find(i), idx_path) { - some(match_ident(a_id)) => a_id.node, - some(m) => match_error(cx, m, ~"an identifier"), - none => i + Some(match_ident(a_id)) => a_id.node, + Some(m) => match_error(cx, m, ~"an identifier"), + None => i } } @@ -338,13 +338,13 @@ fn transcribe_path(cx: ext_ctxt, b: bindings, idx_path: @mut ~[uint], // Don't substitute into qualified names. if vec::len(p.types) > 0u || vec::len(p.idents) != 1u { return p; } match follow_for_trans(cx, b.find(p.idents[0]), idx_path) { - some(match_ident(id)) => { + Some(match_ident(id)) => { {span: id.span, global: false, idents: ~[id.node], - rp: none, types: ~[]} + rp: None, types: ~[]} } - some(match_path(a_pth)) => *a_pth, - some(m) => match_error(cx, m, ~"a path"), - none => p + Some(match_path(a_pth)) => *a_pth, + Some(m) => match_error(cx, m, ~"a path"), + None => p } } @@ -361,17 +361,17 @@ fn transcribe_expr(cx: ext_ctxt, b: bindings, idx_path: @mut ~[uint], (e, s); } match follow_for_trans(cx, b.find(p.idents[0]), idx_path) { - some(match_ident(id)) => { + Some(match_ident(id)) => { (expr_path(@{span: id.span, global: false, idents: ~[id.node], - rp: none, + rp: None, types: ~[]}), id.span) } - some(match_path(a_pth)) => (expr_path(a_pth), s), - some(match_expr(a_exp)) => (a_exp.node, a_exp.span), - some(m) => match_error(cx, m, ~"an expression"), - none => orig(e, s, fld) + Some(match_path(a_pth)) => (expr_path(a_pth), s), + Some(match_expr(a_exp)) => (a_exp.node, a_exp.span), + Some(m) => match_error(cx, m, ~"an expression"), + None => orig(e, s, fld) } } _ => orig(e, s, fld) @@ -386,14 +386,14 @@ fn transcribe_type(cx: ext_ctxt, b: bindings, idx_path: @mut ~[uint], return match t { ast::ty_path(pth, _) => { match path_to_ident(pth) { - some(id) => { + Some(id) => { match follow_for_trans(cx, b.find(id), idx_path) { - some(match_ty(ty)) => (ty.node, ty.span), - some(m) => match_error(cx, m, ~"a type"), - none => orig(t, s, fld) + Some(match_ty(ty)) => (ty.node, ty.span), + Some(m) => match_error(cx, m, ~"a type"), + None => orig(t, s, fld) } } - none => orig(t, s, fld) + None => orig(t, s, fld) } } _ => orig(t, s, fld) @@ -410,16 +410,16 @@ fn transcribe_block(cx: ext_ctxt, b: bindings, idx_path: @mut ~[uint], -> (blk_, span) { return match block_to_ident(blk) { - some(id) => { + Some(id) => { match follow_for_trans(cx, b.find(id), idx_path) { - some(match_block(new_blk)) => (new_blk.node, new_blk.span), + Some(match_block(new_blk)) => (new_blk.node, new_blk.span), // possibly allow promotion of ident/path/expr to blocks? - some(m) => match_error(cx, m, ~"a block"), - none => orig(blk, s, fld) + Some(m) => match_error(cx, m, ~"a block"), + None => orig(blk, s, fld) } } - none => orig(blk, s, fld) + None => orig(blk, s, fld) } } @@ -435,7 +435,7 @@ fn p_t_s_rec(cx: ext_ctxt, m: matchable, s: selector, b: binders) { expr_path(p_pth) => p_t_s_r_path(cx, p_pth, s, b), expr_vec(p_elts, _) => { match elts_to_ell(cx, p_elts) { - {pre: pre, rep: some(repeat_me), post: post} => { + {pre: pre, rep: Some(repeat_me), post: post} => { p_t_s_r_length(cx, vec::len(pre) + vec::len(post), true, s, b); if vec::len(pre) > 0u { @@ -448,7 +448,7 @@ fn p_t_s_rec(cx: ext_ctxt, m: matchable, s: selector, b: binders) { ~"matching after `...` not yet supported"); } } - {pre: pre, rep: none, post: post} => { + {pre: pre, rep: None, post: post} => { if post != ~[] { cx.bug(~"elts_to_ell provided an invalid result"); } @@ -466,7 +466,7 @@ fn p_t_s_rec(cx: ext_ctxt, m: matchable, s: selector, b: binders) { match_result { return match m { match_expr(e) => { - if e == pat { some(leaf(match_exact)) } else { none } + if e == pat { Some(leaf(match_exact)) } else { None } } _ => cx.bug(~"broken traversal in p_t_s_r") } @@ -487,8 +487,8 @@ fn specialize_match(m: matchable) -> matchable { match e.node { expr_path(pth) => { match path_to_ident(pth) { - some(id) => match_ident(respan(pth.span, id)), - none => match_path(pth) + Some(id) => match_ident(respan(pth.span, id)), + None => match_path(pth) } } _ => m @@ -501,10 +501,10 @@ fn specialize_match(m: matchable) -> matchable { /* pattern_to_selectors helper functions */ fn p_t_s_r_path(cx: ext_ctxt, p: @path, s: selector, b: binders) { match path_to_ident(p) { - some(p_id) => { + Some(p_id) => { fn select(cx: ext_ctxt, m: matchable) -> match_result { return match m { - match_expr(e) => some(leaf(specialize_match(m))), + match_expr(e) => Some(leaf(specialize_match(m))), _ => cx.bug(~"broken traversal in p_t_s_r") } } @@ -513,18 +513,18 @@ fn p_t_s_r_path(cx: ext_ctxt, p: @path, s: selector, b: binders) { } b.real_binders.insert(p_id, compose_sels(s, |x| select(cx, x))); } - none => () + None => () } } -fn block_to_ident(blk: blk_) -> option<ident> { - if vec::len(blk.stmts) != 0u { return none; } +fn block_to_ident(blk: blk_) -> Option<ident> { + if vec::len(blk.stmts) != 0u { return None; } return match blk.expr { - some(expr) => match expr.node { + Some(expr) => match expr.node { expr_path(pth) => path_to_ident(pth), - _ => none + _ => None }, - none => none + None => None } } @@ -534,7 +534,7 @@ fn p_t_s_r_mac(cx: ext_ctxt, mac: ast::mac, _s: selector, _b: binders) { return match m { match_expr(e) => match e.node { expr_mac(mac) => fn_m(mac), - _ => none + _ => None }, _ => cx.bug(~"broken traversal in p_t_s_r") } @@ -568,9 +568,9 @@ fn p_t_s_r_ellipses(cx: ext_ctxt, repeat_me: @expr, offset: uint, s: selector, // using repeat_me.span is a little wacky, but the // error we want to report is one in the macro def - some(seq(@elts, repeat_me.span)) + Some(seq(@elts, repeat_me.span)) } - _ => none + _ => None } } _ => cx.bug(~"broken traversal in p_t_s_r") @@ -591,13 +591,13 @@ fn p_t_s_r_length(cx: ext_ctxt, len: uint, at_least: bool, s: selector, expr_vec(arg_elts, _) => { let actual_len = vec::len(arg_elts); if at_least && actual_len >= len || actual_len == len { - some(leaf(match_exact)) - } else { none } + Some(leaf(match_exact)) + } else { None } } - _ => none + _ => None } } - _ => none + _ => None } } b.literal_ast_matchers.push( @@ -613,9 +613,9 @@ fn p_t_s_r_actual_vector(cx: ext_ctxt, elts: ~[@expr], _repeat_after: bool, match_expr(e) => { match e.node { expr_vec(arg_elts, _) => { - some(leaf(match_expr(arg_elts[idx]))) + Some(leaf(match_expr(arg_elts[idx]))) } - _ => none + _ => None } } _ => cx.bug(~"broken traversal in p_t_s_r") @@ -631,7 +631,7 @@ fn add_new_extension(cx: ext_ctxt, sp: span, arg: ast::mac_arg, _body: ast::mac_body) -> base::macro_def { let args = get_mac_args_no_max(cx, sp, arg, 0u, ~"macro"); - let mut macro_name: option<~str> = none; + let mut macro_name: Option<~str> = None; let mut clauses: ~[@clause] = ~[]; for args.each |arg| { match arg.node { @@ -648,23 +648,23 @@ fn add_new_extension(cx: ext_ctxt, sp: span, arg: ast::mac_arg, match mac.node { mac_invoc(pth, invoc_arg, body) => { match path_to_ident(pth) { - some(id) => { + Some(id) => { let id_str = cx.str_of(id); match macro_name { - none => macro_name = some(id_str), - some(other_id) => if id_str != other_id { + None => macro_name = Some(id_str), + Some(other_id) => if id_str != other_id { cx.span_fatal(pth.span, ~"macro name must be " + ~"consistent"); } } }, - none => cx.span_fatal(pth.span, + None => cx.span_fatal(pth.span, ~"macro name must not be a path") } let arg = match invoc_arg { - some(arg) => arg, - none => cx.span_fatal(mac.span, + Some(arg) => arg, + None => cx.span_fatal(mac.span, ~"macro must have arguments") }; vec::push(clauses, @@ -698,23 +698,23 @@ fn add_new_extension(cx: ext_ctxt, sp: span, arg: ast::mac_arg, return {name: match macro_name { - some(id) => id, - none => cx.span_fatal(sp, ~"macro definition must have " + + Some(id) => id, + None => cx.span_fatal(sp, ~"macro definition must have " + ~"at least one clause") }, - ext: normal({expander: ext, span: some(option::get(arg).span)})}; + ext: normal({expander: ext, span: Some(option::get(arg).span)})}; fn generic_extension(cx: ext_ctxt, sp: span, arg: ast::mac_arg, _body: ast::mac_body, clauses: ~[@clause]) -> @expr { let arg = match arg { - some(arg) => arg, - none => cx.span_fatal(sp, ~"macro must have arguments") + Some(arg) => arg, + None => cx.span_fatal(sp, ~"macro must have arguments") }; for clauses.each |c| { match use_selectors_to_bind(c.params, arg) { - some(bindings) => return transcribe(cx, bindings, c.body), - none => again + Some(bindings) => return transcribe(cx, bindings, c.body), + None => again } } cx.span_fatal(sp, ~"no clauses match macro invocation"); diff --git a/src/libsyntax/ext/source_util.rs b/src/libsyntax/ext/source_util.rs index 881691b5f5c..09dc48e0929 100644 --- a/src/libsyntax/ext/source_util.rs +++ b/src/libsyntax/ext/source_util.rs @@ -16,7 +16,7 @@ export expand_include_bin; /* line!(): expands to the current line number */ fn expand_line(cx: ext_ctxt, sp: span, arg: ast::mac_arg, _body: ast::mac_body) -> @ast::expr { - get_mac_args(cx, sp, arg, 0u, option::some(0u), ~"line"); + get_mac_args(cx, sp, arg, 0u, option::Some(0u), ~"line"); let loc = codemap::lookup_char_pos(cx.codemap(), sp.lo); return mk_uint(cx, sp, loc.line); } @@ -24,7 +24,7 @@ fn expand_line(cx: ext_ctxt, sp: span, arg: ast::mac_arg, /* col!(): expands to the current column number */ fn expand_col(cx: ext_ctxt, sp: span, arg: ast::mac_arg, _body: ast::mac_body) -> @ast::expr { - get_mac_args(cx, sp, arg, 0u, option::some(0u), ~"col"); + get_mac_args(cx, sp, arg, 0u, option::Some(0u), ~"col"); let loc = codemap::lookup_char_pos(cx.codemap(), sp.lo); return mk_uint(cx, sp, loc.col); } @@ -34,7 +34,7 @@ fn expand_col(cx: ext_ctxt, sp: span, arg: ast::mac_arg, * out if we wanted. */ fn expand_file(cx: ext_ctxt, sp: span, arg: ast::mac_arg, _body: ast::mac_body) -> @ast::expr { - get_mac_args(cx, sp, arg, 0u, option::some(0u), ~"file"); + get_mac_args(cx, sp, arg, 0u, option::Some(0u), ~"file"); let { file: @{ name: filename, _ }, _ } = codemap::lookup_char_pos(cx.codemap(), sp.lo); return mk_uniq_str(cx, sp, filename); @@ -42,21 +42,21 @@ fn expand_file(cx: ext_ctxt, sp: span, arg: ast::mac_arg, fn expand_stringify(cx: ext_ctxt, sp: span, arg: ast::mac_arg, _body: ast::mac_body) -> @ast::expr { - let args = get_mac_args(cx, sp, arg, 1u, option::some(1u), ~"stringify"); + let args = get_mac_args(cx, sp, arg, 1u, option::Some(1u), ~"stringify"); let s = pprust::expr_to_str(args[0], cx.parse_sess().interner); return mk_uniq_str(cx, sp, s); } fn expand_mod(cx: ext_ctxt, sp: span, arg: ast::mac_arg, _body: ast::mac_body) -> @ast::expr { - get_mac_args(cx, sp, arg, 0u, option::some(0u), ~"file"); + get_mac_args(cx, sp, arg, 0u, option::Some(0u), ~"file"); return mk_uniq_str(cx, sp, str::connect(cx.mod_path().map(|x| cx.str_of(x)), ~"::")); } fn expand_include(cx: ext_ctxt, sp: span, arg: ast::mac_arg, _body: ast::mac_body) -> @ast::expr { - let args = get_mac_args(cx, sp, arg, 1u, option::some(1u), ~"include"); + let args = get_mac_args(cx, sp, arg, 1u, option::Some(1u), ~"include"); let file = expr_to_str(cx, args[0], ~"#include_str requires a string"); let p = parse::new_parser_from_file(cx.parse_sess(), cx.cfg(), &res_rel_file(cx, sp, &Path(file)), @@ -66,7 +66,7 @@ fn expand_include(cx: ext_ctxt, sp: span, arg: ast::mac_arg, fn expand_include_str(cx: ext_ctxt, sp: codemap::span, arg: ast::mac_arg, _body: ast::mac_body) -> @ast::expr { - let args = get_mac_args(cx,sp,arg,1u,option::some(1u),~"include_str"); + let args = get_mac_args(cx,sp,arg,1u,option::Some(1u),~"include_str"); let file = expr_to_str(cx, args[0], ~"#include_str requires a string"); @@ -83,7 +83,7 @@ fn expand_include_str(cx: ext_ctxt, sp: codemap::span, arg: ast::mac_arg, fn expand_include_bin(cx: ext_ctxt, sp: codemap::span, arg: ast::mac_arg, _body: ast::mac_body) -> @ast::expr { - let args = get_mac_args(cx,sp,arg,1u,option::some(1u),~"include_bin"); + let args = get_mac_args(cx,sp,arg,1u,option::Some(1u),~"include_bin"); let file = expr_to_str(cx, args[0], ~"#include_bin requires a string"); diff --git a/src/libsyntax/ext/trace_macros.rs b/src/libsyntax/ext/trace_macros.rs index 22f0aeaa2c0..b647e868da5 100644 --- a/src/libsyntax/ext/trace_macros.rs +++ b/src/libsyntax/ext/trace_macros.rs @@ -11,7 +11,7 @@ fn expand_trace_macros(cx: ext_ctxt, sp: span, let sess = cx.parse_sess(); let cfg = cx.cfg(); let tt_rdr = new_tt_reader(cx.parse_sess().span_diagnostic, - cx.parse_sess().interner, none, tt); + cx.parse_sess().interner, None, tt); let rdr = tt_rdr as reader; let rust_parser = parser(sess, cfg, rdr.dup(), SOURCE_FILE); diff --git a/src/libsyntax/ext/tt/macro_parser.rs b/src/libsyntax/ext/tt/macro_parser.rs index 04f0e5f0a83..3b04fd502f4 100644 --- a/src/libsyntax/ext/tt/macro_parser.rs +++ b/src/libsyntax/ext/tt/macro_parser.rs @@ -85,19 +85,19 @@ eof: [a $( a )* a b ยท] nonempty body. */ enum matcher_pos_up { /* to break a circularity */ - matcher_pos_up(option<matcher_pos>) + matcher_pos_up(Option<matcher_pos>) } fn is_some(&&mpu: matcher_pos_up) -> bool { match mpu { - matcher_pos_up(none) => false, + matcher_pos_up(None) => false, _ => true } } type matcher_pos = ~{ elts: ~[ast::matcher], // maybe should be /&? Need to understand regions. - sep: option<token>, + sep: Option<token>, mut idx: uint, mut up: matcher_pos_up, // mutable for swapping only matches: ~[DVec<@named_match>], @@ -107,7 +107,7 @@ type matcher_pos = ~{ fn copy_up(&& mpu: matcher_pos_up) -> matcher_pos { match mpu { - matcher_pos_up(some(mp)) => copy mp, + matcher_pos_up(Some(mp)) => copy mp, _ => fail } } @@ -122,7 +122,7 @@ fn count_names(ms: &[matcher]) -> uint { } #[allow(non_implicitly_copyable_typarams)] -fn initial_matcher_pos(ms: ~[matcher], sep: option<token>, lo: uint) +fn initial_matcher_pos(ms: ~[matcher], sep: Option<token>, lo: uint) -> matcher_pos { let mut match_idx_hi = 0u; for ms.each() |elt| { @@ -136,7 +136,7 @@ fn initial_matcher_pos(ms: ~[matcher], sep: option<token>, lo: uint) } } } - ~{elts: ms, sep: sep, mut idx: 0u, mut up: matcher_pos_up(none), + ~{elts: ms, sep: sep, mut idx: 0u, mut up: matcher_pos_up(None), matches: copy vec::from_fn(count_names(ms), |_i| dvec::dvec()), match_lo: 0u, match_hi: match_idx_hi, sp_lo: lo} } @@ -208,7 +208,7 @@ fn parse_or_else(sess: parse_sess, cfg: ast::crate_cfg, rdr: reader, fn parse(sess: parse_sess, cfg: ast::crate_cfg, rdr: reader, ms: ~[matcher]) -> parse_result { let mut cur_eis = ~[]; - vec::push(cur_eis, initial_matcher_pos(ms, none, rdr.peek().sp.lo)); + vec::push(cur_eis, initial_matcher_pos(ms, None, rdr.peek().sp.lo)); loop { let mut bb_eis = ~[]; // black-box parsed by parser.rs @@ -263,7 +263,7 @@ fn parse(sess: parse_sess, cfg: ast::crate_cfg, rdr: reader, ms: ~[matcher]) // the *_t vars are workarounds for the lack of unary move match copy ei.sep { - some(t) if idx == len => { // we need a separator + Some(t) if idx == len => { // we need a separator if tok == t { //pass the separator let ei_t <- ei; ei_t.idx += 1u; @@ -300,7 +300,7 @@ fn parse(sess: parse_sess, cfg: ast::crate_cfg, rdr: reader, ms: ~[matcher]) let ei_t <- ei; vec::push(cur_eis, ~{ elts: matchers, sep: sep, mut idx: 0u, - mut up: matcher_pos_up(some(ei_t)), + mut up: matcher_pos_up(Some(ei_t)), matches: matches, match_lo: match_idx_lo, match_hi: match_idx_hi, sp_lo: sp.lo @@ -381,8 +381,8 @@ fn parse(sess: parse_sess, cfg: ast::crate_cfg, rdr: reader, ms: ~[matcher]) fn parse_nt(p: parser, name: ~str) -> nonterminal { match name { ~"item" => match p.parse_item(~[]) { - some(i) => token::nt_item(i), - none => p.fatal(~"expected an item keyword") + Some(i) => token::nt_item(i), + None => p.fatal(~"expected an item keyword") }, ~"block" => token::nt_block(p.parse_block()), ~"stmt" => token::nt_stmt(p.parse_stmt(~[])), diff --git a/src/libsyntax/ext/tt/macro_rules.rs b/src/libsyntax/ext/tt/macro_rules.rs index 5b5a631f248..1fd2f880595 100644 --- a/src/libsyntax/ext/tt/macro_rules.rs +++ b/src/libsyntax/ext/tt/macro_rules.rs @@ -14,7 +14,7 @@ fn add_new_extension(cx: ext_ctxt, sp: span, name: ident, arg: ~[ast::token_tree]) -> base::mac_result { // these spans won't matter, anyways fn ms(m: matcher_) -> matcher { - {node: m, span: {lo: 0u, hi: 0u, expn_info: none}} + {node: m, span: {lo: 0u, hi: 0u, expn_info: None}} } let lhs_nm = cx.parse_sess().interner.gensym(@~"lhs"); @@ -28,15 +28,15 @@ fn add_new_extension(cx: ext_ctxt, sp: span, name: ident, ms(match_nonterminal(lhs_nm, special_idents::matchers, 0u)), ms(match_tok(FAT_ARROW)), ms(match_nonterminal(rhs_nm, special_idents::tt, 1u)), - ], some(SEMI), false, 0u, 2u)), + ], Some(SEMI), false, 0u, 2u)), //to phase into semicolon-termination instead of //semicolon-separation - ms(match_seq(~[ms(match_tok(SEMI))], none, true, 2u, 2u))]; + ms(match_seq(~[ms(match_tok(SEMI))], None, true, 2u, 2u))]; // Parse the macro_rules! invocation (`none` is for no interpolations): let arg_reader = new_tt_reader(cx.parse_sess().span_diagnostic, - cx.parse_sess().interner, none, arg); + cx.parse_sess().interner, None, arg); let argument_map = parse_or_else(cx.parse_sess(), cx.cfg(), arg_reader as reader, argument_gram); @@ -65,7 +65,7 @@ fn add_new_extension(cx: ext_ctxt, sp: span, name: ident, } // Which arm's failure should we report? (the one furthest along) - let mut best_fail_spot = {lo: 0u, hi: 0u, expn_info: none}; + let mut best_fail_spot = {lo: 0u, hi: 0u, expn_info: None}; let mut best_fail_msg = ~"internal error: ran no matchers"; let s_d = cx.parse_sess().span_diagnostic; @@ -75,7 +75,7 @@ fn add_new_extension(cx: ext_ctxt, sp: span, name: ident, match lhs { @matched_nonterminal(nt_matchers(mtcs)) => { // `none` is because we're not interpolating - let arg_rdr = new_tt_reader(s_d, itr, none, arg) as reader; + let arg_rdr = new_tt_reader(s_d, itr, None, arg) as reader; match parse(cx.parse_sess(), cx.cfg(), arg_rdr, mtcs) { success(named_matches) => { let rhs = match rhses[i] { @@ -84,7 +84,7 @@ fn add_new_extension(cx: ext_ctxt, sp: span, name: ident, _ => cx.span_bug(sp, ~"bad thing in rhs") }; // rhs has holes ( `$id` and `$(...)` that need filled) - let trncbr = new_tt_reader(s_d, itr, some(named_matches), + let trncbr = new_tt_reader(s_d, itr, Some(named_matches), ~[rhs]); let p = parser(cx.parse_sess(), cx.cfg(), trncbr as reader, SOURCE_FILE); @@ -109,6 +109,6 @@ fn add_new_extension(cx: ext_ctxt, sp: span, name: ident, return mr_def({ name: *cx.parse_sess().interner.get(name), - ext: expr_tt({expander: exp, span: some(sp)}) + ext: expr_tt({expander: exp, span: Some(sp)}) }); } \ No newline at end of file diff --git a/src/libsyntax/ext/tt/transcribe.rs b/src/libsyntax/ext/tt/transcribe.rs index 8755e0d7d59..f353eecb926 100644 --- a/src/libsyntax/ext/tt/transcribe.rs +++ b/src/libsyntax/ext/tt/transcribe.rs @@ -9,7 +9,7 @@ import std::map::{hashmap, box_str_hash}; export tt_reader, new_tt_reader, dup_tt_reader, tt_next_token; enum tt_frame_up { /* to break a circularity */ - tt_frame_up(option<tt_frame>) + tt_frame_up(Option<tt_frame>) } /* FIXME #2811: figure out how to have a uniquely linked stack, and change to @@ -19,7 +19,7 @@ type tt_frame = @{ readme: ~[ast::token_tree], mut idx: uint, dotdotdoted: bool, - sep: option<token>, + sep: Option<token>, up: tt_frame_up, }; @@ -40,15 +40,15 @@ type tt_reader = @{ * `src` contains no `tt_seq`s and `tt_nonterminal`s, `interp` can (and * should) be none. */ fn new_tt_reader(sp_diag: span_handler, itr: ident_interner, - interp: option<std::map::hashmap<ident,@named_match>>, + interp: Option<std::map::hashmap<ident,@named_match>>, src: ~[ast::token_tree]) -> tt_reader { let r = @{sp_diag: sp_diag, interner: itr, mut cur: @{readme: src, mut idx: 0u, dotdotdoted: false, - sep: none, up: tt_frame_up(option::none)}, + sep: None, up: tt_frame_up(option::None)}, interpolations: match interp { /* just a convienience */ - none => std::map::uint_hash::<@named_match>(), - some(x) => x + None => std::map::uint_hash::<@named_match>(), + Some(x) => x }, mut repeat_idx: ~[mut], mut repeat_len: ~[], /* dummy values, never read: */ @@ -62,8 +62,8 @@ fn new_tt_reader(sp_diag: span_handler, itr: ident_interner, pure fn dup_tt_frame(&&f: tt_frame) -> tt_frame { @{readme: f.readme, mut idx: f.idx, dotdotdoted: f.dotdotdoted, sep: f.sep, up: match f.up { - tt_frame_up(some(up_frame)) => { - tt_frame_up(some(dup_tt_frame(up_frame))) + tt_frame_up(Some(up_frame)) => { + tt_frame_up(Some(dup_tt_frame(up_frame))) } tt_frame_up(none) => tt_frame_up(none) } @@ -141,11 +141,11 @@ fn tt_next_token(&&r: tt_reader) -> {tok: token, sp: span} { || r.repeat_idx.last() == r.repeat_len.last() - 1 { match r.cur.up { - tt_frame_up(none) => { + tt_frame_up(None) => { r.cur_tok = EOF; return ret_val; } - tt_frame_up(some(tt_f)) => { + tt_frame_up(Some(tt_f)) => { if r.cur.dotdotdoted { vec::pop(r.repeat_idx); vec::pop(r.repeat_len); } @@ -159,11 +159,11 @@ fn tt_next_token(&&r: tt_reader) -> {tok: token, sp: span} { r.cur.idx = 0u; r.repeat_idx[r.repeat_idx.len() - 1u] += 1u; match r.cur.sep { - some(tk) => { + Some(tk) => { r.cur_tok = tk; /* repeat same span, I guess */ return ret_val; } - none => () + None => () } } } @@ -172,7 +172,7 @@ fn tt_next_token(&&r: tt_reader) -> {tok: token, sp: span} { match r.cur.readme[r.cur.idx] { tt_delim(tts) => { r.cur = @{readme: tts, mut idx: 0u, dotdotdoted: false, - sep: none, up: tt_frame_up(option::some(r.cur)) }; + sep: None, up: tt_frame_up(option::Some(r.cur)) }; // if this could be 0-length, we'd need to potentially recur here } tt_tok(sp, tok) => { @@ -207,7 +207,7 @@ fn tt_next_token(&&r: tt_reader) -> {tok: token, sp: span} { vec::push(r.repeat_len, len); vec::push(r.repeat_idx, 0u); r.cur = @{readme: tts, mut idx: 0u, dotdotdoted: true, - sep: sep, up: tt_frame_up(option::some(r.cur))}; + sep: sep, up: tt_frame_up(option::Some(r.cur))}; } } } |
