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 | |
| parent | d9a6a6365327ac156ef3102e2b7efae1b2be5934 (diff) | |
| download | rust-8337fa1a545e7958389c6025661990eedd9c1b91.tar.gz rust-8337fa1a545e7958389c6025661990eedd9c1b91.zip | |
Camel case the option type
Diffstat (limited to 'src/libsyntax')
43 files changed, 723 insertions, 723 deletions
diff --git a/src/libsyntax/ast.rs b/src/libsyntax/ast.rs index fbd155e0729..a9df28abeba 100644 --- a/src/libsyntax/ast.rs +++ b/src/libsyntax/ast.rs @@ -3,8 +3,8 @@ import codemap::{span, filename}; import std::serialization::{serializer, deserializer, - serialize_option, - deserialize_option, + serialize_Option, + deserialize_Option, serialize_uint, deserialize_uint, serialize_int, @@ -40,16 +40,16 @@ macro_rules! interner_key ( fn serialize_ident<S: serializer>(s: S, i: ident) { let intr = match unsafe{task::local_data_get(interner_key!())}{ - none => fail ~"serialization: TLS interner not set up", - some(intr) => intr + None => fail ~"serialization: TLS interner not set up", + Some(intr) => intr }; s.emit_str(*(*intr).get(i)); } fn deserialize_ident<D: deserializer>(d: D) -> ident { let intr = match unsafe{task::local_data_get(interner_key!())}{ - none => fail ~"deserialization: TLS interner not set up", - some(intr) => intr + None => fail ~"deserialization: TLS interner not set up", + Some(intr) => intr }; (*intr).intern(@d.read_str()) @@ -59,13 +59,13 @@ type ident = token::str_num; // Functions may or may not have names. #[auto_serialize] -type fn_ident = option<ident>; +type fn_ident = Option<ident>; #[auto_serialize] type path = {span: span, global: bool, idents: ~[ident], - rp: option<@region>, + rp: Option<@region>, types: ~[@ty]}; #[auto_serialize] @@ -162,7 +162,7 @@ type blk = spanned<blk_>; #[auto_serialize] type blk_ = {view_items: ~[@view_item], stmts: ~[@stmt], - expr: option<@expr>, + expr: Option<@expr>, id: node_id, rules: blk_check_mode}; @@ -185,13 +185,13 @@ enum pat_ { pat_wild, // A pat_ident may either be a new bound variable, // or a nullary enum (in which case the second field - // is none). + // is None). // In the nullary enum case, the parser can't determine // which it is. The resolver determines this, and // records this pattern's node_id in an auxiliary // set (of "pat_idents that refer to nullary enums") - pat_ident(binding_mode, @path, option<@pat>), - pat_enum(@path, option<~[@pat]>), // "none" means a * pattern where + pat_ident(binding_mode, @path, Option<@pat>), + pat_enum(@path, Option<~[@pat]>), // "none" means a * pattern where // we don't bind the fields to names pat_rec(~[field_pat], bool), pat_struct(@path, ~[field_pat], bool), @@ -216,7 +216,7 @@ enum proto { #[auto_serialize] enum vstore { // FIXME (#2112): Change uint to @expr (actually only constant exprs) - vstore_fixed(option<uint>), // [1,2,3,4]/_ or 4 + vstore_fixed(Option<uint>), // [1,2,3,4]/_ or 4 vstore_uniq, // ~[1,2,3,4] vstore_box, // @[1,2,3,4] vstore_slice(@region) // &[1,2,3,4](foo)? @@ -297,7 +297,7 @@ type initializer = {op: init_op, expr: @expr}; // a refinement on pat. #[auto_serialize] type local_ = {is_mutbl: bool, ty: @ty, pat: @pat, - init: option<initializer>, id: node_id}; + init: Option<initializer>, id: node_id}; #[auto_serialize] type local = spanned<local_>; @@ -309,7 +309,7 @@ type decl = spanned<decl_>; enum decl_ { decl_local(~[@local]), decl_item(@item), } #[auto_serialize] -type arm = {pats: ~[@pat], guard: option<@expr>, body: blk}; +type arm = {pats: ~[@pat], guard: Option<@expr>, body: blk}; #[auto_serialize] type field_ = {mutbl: mutability, ident: ident, expr: @expr}; @@ -335,19 +335,19 @@ enum alt_mode { alt_check, alt_exhaustive, } enum expr_ { expr_vstore(@expr, vstore), expr_vec(~[@expr], mutability), - expr_rec(~[field], option<@expr>), + expr_rec(~[field], Option<@expr>), expr_call(@expr, ~[@expr], bool), // True iff last argument is a block expr_tup(~[@expr]), expr_binary(binop, @expr, @expr), expr_unary(unop, @expr), expr_lit(@lit), expr_cast(@expr, @ty), - expr_if(@expr, blk, option<@expr>), + expr_if(@expr, blk, Option<@expr>), expr_while(@expr, blk), /* Conditionless loop (can be exited with break, cont, ret, or fail) Same semantics as while(true) { body }, but typestate knows that the (implicit) condition is always true. */ - expr_loop(blk, option<ident>), + expr_loop(blk, Option<ident>), expr_match(@expr, ~[arm]), expr_fn(proto, fn_decl, blk, capture_clause), expr_fn_block(fn_decl, blk, capture_clause), @@ -369,10 +369,10 @@ enum expr_ { expr_index(@expr, @expr), expr_path(@path), expr_addr_of(mutability, @expr), - expr_fail(option<@expr>), - expr_break(option<ident>), - expr_again(option<ident>), - expr_ret(option<@expr>), + expr_fail(Option<@expr>), + expr_break(Option<ident>), + expr_again(Option<ident>), + expr_ret(Option<@expr>), expr_log(log_level, @expr, @expr), /* just an assert */ @@ -381,7 +381,7 @@ enum expr_ { expr_mac(mac), // A struct literal expression. - expr_struct(@path, ~[field], option<@expr>), + expr_struct(@path, ~[field], Option<@expr>), // A vector literal constructed from one repeated element. expr_repeat(@expr /* element */, @expr /* count */, mutability) @@ -420,7 +420,7 @@ enum token_tree { tt_tok(span, token::token), tt_delim(~[token_tree]), // These only make sense for right-hand-sides of MBE macros - tt_seq(span, ~[token_tree], option<token::token>, bool), + tt_seq(span, ~[token_tree], Option<token::token>, bool), tt_nonterminal(span, ident) } @@ -485,7 +485,7 @@ enum matcher_ { match_tok(token::token), // match repetitions of a sequence: body, separator, zero ok?, // lo, hi position-in-match-array used: - match_seq(~[matcher], option<token::token>, bool, uint, uint), + match_seq(~[matcher], Option<token::token>, bool, uint, uint), // parse a Rust NT: name to bind, name of NT, position in match array: match_nonterminal(ident, ident, uint) } @@ -494,13 +494,13 @@ enum matcher_ { type mac = spanned<mac_>; #[auto_serialize] -type mac_arg = option<@expr>; +type mac_arg = Option<@expr>; #[auto_serialize] type mac_body_ = {span: span}; #[auto_serialize] -type mac_body = option<mac_body_>; +type mac_body = Option<mac_body_>; #[auto_serialize] enum mac_ { @@ -593,7 +593,7 @@ enum ty_ { ty_fn(proto, purity, @~[ty_param_bound], fn_decl), ty_tup(~[@ty]), ty_path(@path, node_id), - ty_fixed_length(@ty, option<uint>), + ty_fixed_length(@ty, Option<uint>), ty_mac(mac), // ty_infer means the type should be inferred instead of it having been // specified. This should only appear at the "top level" of a type and not @@ -672,11 +672,11 @@ enum variant_kind { } #[auto_serialize] -enum enum_def = { variants: ~[variant], common: option<@struct_def> }; +enum enum_def = { variants: ~[variant], common: Option<@struct_def> }; #[auto_serialize] type variant_ = {name: ident, attrs: ~[attribute], kind: variant_kind, - id: node_id, disr_expr: option<@expr>, vis: visibility}; + id: node_id, disr_expr: Option<@expr>, vis: visibility}; #[auto_serialize] type variant = spanned<variant_>; @@ -770,9 +770,9 @@ type struct_def = { methods: ~[@method], /* methods */ /* (not including ctor or dtor) */ /* ctor is optional, and will soon go away */ - ctor: option<class_ctor>, + ctor: Option<class_ctor>, /* dtor is optional */ - dtor: option<class_dtor> + dtor: Option<class_dtor> }; #[auto_serialize] diff --git a/src/libsyntax/ast_map.rs b/src/libsyntax/ast_map.rs index 68dd986025b..d0c67f85bb0 100644 --- a/src/libsyntax/ast_map.rs +++ b/src/libsyntax/ast_map.rs @@ -295,10 +295,10 @@ fn map_stmt(stmt: @stmt, cx: ctx, v: vt) { fn node_id_to_str(map: map, id: node_id, itr: ident_interner) -> ~str { match map.find(id) { - none => { + None => { fmt!("unknown node (id=%d)", id) } - some(node_item(item, path)) => { + Some(node_item(item, path)) => { let path_str = path_ident_to_str(*path, item.ident, itr); let item_str = match item.node { item_const(*) => ~"const", @@ -314,48 +314,48 @@ fn node_id_to_str(map: map, id: node_id, itr: ident_interner) -> ~str { }; fmt!("%s %s (id=%?)", item_str, path_str, id) } - some(node_foreign_item(item, abi, path)) => { + Some(node_foreign_item(item, abi, path)) => { fmt!("foreign item %s with abi %? (id=%?)", path_ident_to_str(*path, item.ident, itr), abi, id) } - some(node_method(m, impl_did, path)) => { + Some(node_method(m, impl_did, path)) => { fmt!("method %s in %s (id=%?)", *itr.get(m.ident), path_to_str(*path, itr), id) } - some(node_trait_method(tm, impl_did, path)) => { + Some(node_trait_method(tm, impl_did, path)) => { let m = ast_util::trait_method_to_ty_method(*tm); fmt!("method %s in %s (id=%?)", *itr.get(m.ident), path_to_str(*path, itr), id) } - some(node_variant(variant, def_id, path)) => { + Some(node_variant(variant, def_id, path)) => { fmt!("variant %s in %s (id=%?)", *itr.get(variant.node.name), path_to_str(*path, itr), id) } - some(node_expr(expr)) => { + Some(node_expr(expr)) => { fmt!("expr %s (id=%?)", pprust::expr_to_str(expr, itr), id) } - some(node_stmt(stmt)) => { + Some(node_stmt(stmt)) => { fmt!("stmt %s (id=%?)", pprust::stmt_to_str(*stmt, itr), id) } // FIXMEs are as per #2410 - some(node_export(_, path)) => { + Some(node_export(_, path)) => { fmt!("export %s (id=%?)", // add more info here path_to_str(*path, itr), id) } - some(node_arg(_, _)) => { // add more info here + Some(node_arg(_, _)) => { // add more info here fmt!("arg (id=%?)", id) } - some(node_local(_)) => { // add more info here + Some(node_local(_)) => { // add more info here fmt!("local (id=%?)", id) } - some(node_ctor(*)) => { // add more info here + Some(node_ctor(*)) => { // add more info here fmt!("node_ctor (id=%?)", id) } - some(node_dtor(*)) => { // add more info here + Some(node_dtor(*)) => { // add more info here fmt!("node_dtor (id=%?)", id) } - some(node_block(_)) => { + Some(node_block(_)) => { fmt!("block") } } diff --git a/src/libsyntax/ast_util.rs b/src/libsyntax/ast_util.rs index 17a9942c489..79df0767ca5 100644 --- a/src/libsyntax/ast_util.rs +++ b/src/libsyntax/ast_util.rs @@ -15,7 +15,7 @@ pure fn dummy_spanned<T>(+t: T) -> spanned<T> { /* assuming that we're not in macro expansion */ pure fn mk_sp(lo: uint, hi: uint) -> span { - {lo: lo, hi: hi, expn_info: none} + {lo: lo, hi: hi, expn_info: None} } // make this a const, once the compiler supports it @@ -93,19 +93,19 @@ pure fn binop_to_str(op: binop) -> ~str { } } -pure fn binop_to_method_name(op: binop) -> option<~str> { +pure fn binop_to_method_name(op: binop) -> Option<~str> { match op { - add => return some(~"add"), - subtract => return some(~"sub"), - mul => return some(~"mul"), - div => return some(~"div"), - rem => return some(~"modulo"), - bitxor => return some(~"bitxor"), - bitand => return some(~"bitand"), - bitor => return some(~"bitor"), - shl => return some(~"shl"), - shr => return some(~"shr"), - and | or | eq | lt | le | ne | ge | gt => return none + add => return Some(~"add"), + subtract => return Some(~"sub"), + mul => return Some(~"mul"), + div => return Some(~"div"), + rem => return Some(~"modulo"), + bitxor => return Some(~"bitxor"), + bitand => return Some(~"bitand"), + bitor => return Some(~"bitor"), + shl => return Some(~"shl"), + shr => return Some(~"shr"), + and | or | eq | lt | le | ne | ge | gt => return None } } @@ -184,7 +184,7 @@ pure fn float_ty_to_str(t: float_ty) -> ~str { fn is_exported(i: ident, m: _mod) -> bool { let mut local = false; - let mut parent_enum : option<ident> = none; + let mut parent_enum : Option<ident> = None; for m.items.each |it| { if it.ident == i { local = true; } match it.node { @@ -192,7 +192,7 @@ fn is_exported(i: ident, m: _mod) -> bool { for enum_definition.variants.each |v| { if v.node.name == i { local = true; - parent_enum = some(/* FIXME (#2543) */ copy it.ident); + parent_enum = Some(/* FIXME (#2543) */ copy it.ident); } }, _ => () @@ -209,7 +209,7 @@ fn is_exported(i: ident, m: _mod) -> bool { ast::view_path_simple(id, _, _) => { if id == i { return true; } match parent_enum { - some(parent_enum_id) => { + Some(parent_enum_id) => { if id == parent_enum_id { return true; } } _ => () @@ -270,11 +270,11 @@ fn new_def_hash<V: copy>() -> std::map::hashmap<ast::def_id, V> { } fn block_from_expr(e: @expr) -> blk { - let blk_ = default_block(~[], option::some::<@expr>(e), e.id); + let blk_ = default_block(~[], option::Some::<@expr>(e), e.id); return {node: blk_, span: e.span}; } -fn default_block(+stmts1: ~[@stmt], expr1: option<@expr>, id1: node_id) -> +fn default_block(+stmts1: ~[@stmt], expr1: Option<@expr>, id1: node_id) -> blk_ { {view_items: ~[], stmts: stmts1, expr: expr1, id: id1, rules: default_blk} @@ -282,18 +282,18 @@ fn default_block(+stmts1: ~[@stmt], expr1: option<@expr>, id1: node_id) -> fn ident_to_path(s: span, +i: ident) -> @path { @{span: s, global: false, idents: ~[i], - rp: none, types: ~[]} + rp: None, types: ~[]} } pure fn is_unguarded(&&a: arm) -> bool { match a.guard { - none => true, + None => true, _ => false } } -pure fn unguarded_pat(a: arm) -> option<~[@pat]> { - if is_unguarded(a) { some(/* FIXME (#2543) */ copy a.pats) } else { none } +pure fn unguarded_pat(a: arm) -> Option<~[@pat]> { + if is_unguarded(a) { Some(/* FIXME (#2543) */ copy a.pats) } else { None } } fn public_methods(ms: ~[@method]) -> ~[@method] { @@ -583,10 +583,10 @@ pure fn is_item_impl(item: @ast::item) -> bool { fn walk_pat(pat: @pat, it: fn(@pat)) { it(pat); match pat.node { - pat_ident(_, _, some(p)) => walk_pat(p, it), + pat_ident(_, _, Some(p)) => walk_pat(p, it), pat_rec(fields, _) | pat_struct(_, fields, _) => for fields.each |f| { walk_pat(f.pat, it) }, - pat_enum(_, some(s)) | pat_tup(s) => for s.each |p| { + pat_enum(_, Some(s)) | pat_tup(s) => for s.each |p| { walk_pat(p, it) }, pat_box(s) | pat_uniq(s) => walk_pat(s, it), diff --git a/src/libsyntax/attr.rs b/src/libsyntax/attr.rs index 132e8f6b8dd..70ca59bc1fc 100644 --- a/src/libsyntax/attr.rs +++ b/src/libsyntax/attr.rs @@ -124,21 +124,21 @@ fn get_meta_item_name(meta: @ast::meta_item) -> ~str { * Gets the string value if the meta_item is a meta_name_value variant * containing a string, otherwise none */ -fn get_meta_item_value_str(meta: @ast::meta_item) -> option<~str> { +fn get_meta_item_value_str(meta: @ast::meta_item) -> Option<~str> { match meta.node { ast::meta_name_value(_, v) => match v.node { - ast::lit_str(s) => option::some(*s), - _ => option::none + ast::lit_str(s) => option::Some(*s), + _ => option::None }, - _ => option::none + _ => option::None } } /// Gets a list of inner meta items from a list meta_item type -fn get_meta_item_list(meta: @ast::meta_item) -> option<~[@ast::meta_item]> { +fn get_meta_item_list(meta: @ast::meta_item) -> Option<~[@ast::meta_item]> { match meta.node { - ast::meta_list(_, l) => option::some(/* FIXME (#2543) */ copy l), - _ => option::none + ast::meta_list(_, l) => option::Some(/* FIXME (#2543) */ copy l), + _ => option::None } } @@ -146,13 +146,13 @@ fn get_meta_item_list(meta: @ast::meta_item) -> option<~[@ast::meta_item]> { * If the meta item is a nam-value type with a string value then returns * a tuple containing the name and string value, otherwise `none` */ -fn get_name_value_str_pair(item: @ast::meta_item) -> option<(~str, ~str)> { +fn get_name_value_str_pair(item: @ast::meta_item) -> Option<(~str, ~str)> { match attr::get_meta_item_value_str(item) { - some(value) => { + Some(value) => { let name = attr::get_meta_item_name(item); - some((name, value)) + Some((name, value)) } - none => none + None => None } } @@ -163,10 +163,10 @@ fn get_name_value_str_pair(item: @ast::meta_item) -> option<(~str, ~str)> { fn find_attrs_by_name(attrs: ~[ast::attribute], name: ~str) -> ~[ast::attribute] { let filter = ( - fn@(a: ast::attribute) -> option<ast::attribute> { + fn@(a: ast::attribute) -> Option<ast::attribute> { if get_attr_name(a) == name { - option::some(a) - } else { option::none } + option::Some(a) + } else { option::None } } ); return vec::filter_map(attrs, filter); @@ -175,10 +175,10 @@ fn find_attrs_by_name(attrs: ~[ast::attribute], name: ~str) -> /// Searcha list of meta items and return only those with a specific name fn find_meta_items_by_name(metas: ~[@ast::meta_item], name: ~str) -> ~[@ast::meta_item] { - let filter = fn@(&&m: @ast::meta_item) -> option<@ast::meta_item> { + let filter = fn@(&&m: @ast::meta_item) -> Option<@ast::meta_item> { if get_meta_item_name(m) == name { - option::some(m) - } else { option::none } + option::Some(m) + } else { option::None } }; return vec::filter_map(metas, filter); } @@ -225,40 +225,40 @@ fn attrs_contains_name(attrs: ~[ast::attribute], name: ~str) -> bool { } fn first_attr_value_str_by_name(attrs: ~[ast::attribute], name: ~str) - -> option<~str> { + -> Option<~str> { let mattrs = find_attrs_by_name(attrs, name); if vec::len(mattrs) > 0u { return get_meta_item_value_str(attr_meta(mattrs[0])); } - return option::none; + return option::None; } fn last_meta_item_by_name(items: ~[@ast::meta_item], name: ~str) - -> option<@ast::meta_item> { + -> Option<@ast::meta_item> { let items = attr::find_meta_items_by_name(items, name); vec::last_opt(items) } fn last_meta_item_value_str_by_name(items: ~[@ast::meta_item], name: ~str) - -> option<~str> { + -> Option<~str> { match last_meta_item_by_name(items, name) { - some(item) => match attr::get_meta_item_value_str(item) { - some(value) => some(value), - none => none + Some(item) => match attr::get_meta_item_value_str(item) { + Some(value) => Some(value), + None => None }, - none => none + None => None } } fn last_meta_item_list_by_name(items: ~[@ast::meta_item], name: ~str) - -> option<~[@ast::meta_item]> { + -> Option<~[@ast::meta_item]> { match last_meta_item_by_name(items, name) { - some(item) => attr::get_meta_item_list(item), - none => none + Some(item) => attr::get_meta_item_list(item), + None => None } } @@ -290,9 +290,9 @@ fn remove_meta_items_by_name(items: ~[@ast::meta_item], name: ~str) -> return vec::filter_map(items, |item| { if get_meta_item_name(item) != name { - option::some(/* FIXME (#2543) */ copy item) + option::Some(/* FIXME (#2543) */ copy item) } else { - option::none + option::None } }); } @@ -312,19 +312,19 @@ fn find_linkage_metas(attrs: ~[ast::attribute]) -> ~[@ast::meta_item] { fn foreign_abi(attrs: ~[ast::attribute]) -> Either<~str, ast::foreign_abi> { return match attr::first_attr_value_str_by_name(attrs, ~"abi") { - option::none => { + option::None => { either::Right(ast::foreign_abi_cdecl) } - option::some(~"rust-intrinsic") => { + option::Some(~"rust-intrinsic") => { either::Right(ast::foreign_abi_rust_intrinsic) } - option::some(~"cdecl") => { + option::Some(~"cdecl") => { either::Right(ast::foreign_abi_cdecl) } - option::some(~"stdcall") => { + option::Some(~"stdcall") => { either::Right(ast::foreign_abi_stdcall) } - option::some(t) => { + option::Some(t) => { either::Left(~"unsupported abi: " + t) } }; diff --git a/src/libsyntax/codemap.rs b/src/libsyntax/codemap.rs index bbaaf2deb35..ed2e2589ab1 100644 --- a/src/libsyntax/codemap.rs +++ b/src/libsyntax/codemap.rs @@ -121,7 +121,7 @@ fn lookup_byte_pos(map: codemap, pos: uint) -> loc { } fn lookup_char_pos_adj(map: codemap, pos: uint) - -> {filename: ~str, line: uint, col: uint, file: option<filemap>} + -> {filename: ~str, line: uint, col: uint, file: Option<filemap>} { let loc = lookup_char_pos(map, pos); match (loc.file.substr) { @@ -129,7 +129,7 @@ fn lookup_char_pos_adj(map: codemap, pos: uint) {filename: /* FIXME (#2543) */ copy loc.file.name, line: loc.line, col: loc.col, - file: some(loc.file)} + file: Some(loc.file)} } fss_internal(sp) => { lookup_char_pos_adj(map, sp.lo + (pos - loc.file.start_pos.ch)) @@ -138,7 +138,7 @@ fn lookup_char_pos_adj(map: codemap, pos: uint) {filename: /* FIXME (#2543) */ copy eloc.filename, line: eloc.line + loc.line - 1u, col: if loc.line == 1u {eloc.col + loc.col} else {loc.col}, - file: none} + file: None} } } } @@ -158,9 +158,9 @@ fn adjust_span(map: codemap, sp: span) -> span { enum expn_info_ { expanded_from({call_site: span, - callie: {name: ~str, span: option<span>}}) + callie: {name: ~str, span: Option<span>}}) } -type expn_info = option<@expn_info_>; +type expn_info = Option<@expn_info_>; type span = {lo: uint, hi: uint, expn_info: expn_info}; fn span_to_str_no_adj(sp: span, cm: codemap) -> ~str { @@ -197,8 +197,8 @@ fn span_to_lines(sp: span, cm: codemap::codemap) -> @file_lines { fn get_line(fm: filemap, line: int) -> ~str unsafe { let begin: uint = fm.lines[line].byte - fm.start_pos.byte; let end = match str::find_char_from(*fm.src, '\n', begin) { - some(e) => e, - none => str::len(*fm.src) + Some(e) => e, + None => str::len(*fm.src) }; str::slice(*fm.src, begin, end) } diff --git a/src/libsyntax/diagnostic.rs b/src/libsyntax/diagnostic.rs index 0c622cf7a7c..11384078b43 100644 --- a/src/libsyntax/diagnostic.rs +++ b/src/libsyntax/diagnostic.rs @@ -9,7 +9,7 @@ export codemap_span_handler, codemap_handler; export ice_msg; export expect; -type emitter = fn@(cmsp: option<(codemap::codemap, span)>, +type emitter = fn@(cmsp: Option<(codemap::codemap, span)>, msg: ~str, lvl: level); @@ -33,7 +33,7 @@ trait handler { fn note(msg: ~str); fn bug(msg: ~str) -> !; fn unimpl(msg: ~str) -> !; - fn emit(cmsp: option<(codemap::codemap, span)>, msg: ~str, lvl: level); + fn emit(cmsp: Option<(codemap::codemap, span)>, msg: ~str, lvl: level); } type handler_t = @{ @@ -48,18 +48,18 @@ type codemap_t = @{ impl codemap_t: span_handler { fn span_fatal(sp: span, msg: ~str) -> ! { - self.handler.emit(some((self.cm, sp)), msg, fatal); + self.handler.emit(Some((self.cm, sp)), msg, fatal); fail; } fn span_err(sp: span, msg: ~str) { - self.handler.emit(some((self.cm, sp)), msg, error); + self.handler.emit(Some((self.cm, sp)), msg, error); self.handler.bump_err_count(); } fn span_warn(sp: span, msg: ~str) { - self.handler.emit(some((self.cm, sp)), msg, warning); + self.handler.emit(Some((self.cm, sp)), msg, warning); } fn span_note(sp: span, msg: ~str) { - self.handler.emit(some((self.cm, sp)), msg, note); + self.handler.emit(Some((self.cm, sp)), msg, note); } fn span_bug(sp: span, msg: ~str) -> ! { self.span_fatal(sp, ice_msg(msg)); @@ -74,11 +74,11 @@ impl codemap_t: span_handler { impl handler_t: handler { fn fatal(msg: ~str) -> ! { - self.emit(none, msg, fatal); + self.emit(None, msg, fatal); fail; } fn err(msg: ~str) { - self.emit(none, msg, error); + self.emit(None, msg, error); self.bump_err_count(); } fn bump_err_count() { @@ -98,16 +98,16 @@ impl handler_t: handler { self.fatal(s); } fn warn(msg: ~str) { - self.emit(none, msg, warning); + self.emit(None, msg, warning); } fn note(msg: ~str) { - self.emit(none, msg, note); + self.emit(None, msg, note); } fn bug(msg: ~str) -> ! { self.fatal(ice_msg(msg)); } fn unimpl(msg: ~str) -> ! { self.bug(~"unimplemented " + msg); } - fn emit(cmsp: option<(codemap::codemap, span)>, msg: ~str, lvl: level) { + fn emit(cmsp: Option<(codemap::codemap, span)>, msg: ~str, lvl: level) { self.emit(cmsp, msg, lvl); } } @@ -120,12 +120,12 @@ fn mk_span_handler(handler: handler, cm: codemap::codemap) -> span_handler { @{ handler: handler, cm: cm } as span_handler } -fn mk_handler(emitter: option<emitter>) -> handler { +fn mk_handler(emitter: Option<emitter>) -> handler { let emit = match emitter { - some(e) => e, - none => { - let f = fn@(cmsp: option<(codemap::codemap, span)>, + Some(e) => e, + None => { + let f = fn@(cmsp: Option<(codemap::codemap, span)>, msg: ~str, t: level) { emit(cmsp, msg, t); }; @@ -180,10 +180,10 @@ fn print_diagnostic(topic: ~str, lvl: level, msg: ~str) { io::stderr().write_str(fmt!(" %s\n", msg)); } -fn emit(cmsp: option<(codemap::codemap, span)>, +fn emit(cmsp: Option<(codemap::codemap, span)>, msg: ~str, lvl: level) { match cmsp { - some((cm, sp)) => { + Some((cm, sp)) => { let sp = codemap::adjust_span(cm,sp); let ss = codemap::span_to_str(sp, cm); let lines = codemap::span_to_lines(sp, cm); @@ -191,7 +191,7 @@ fn emit(cmsp: option<(codemap::codemap, span)>, highlight_lines(cm, sp, lines); print_macro_backtrace(cm, sp); } - none => { + None => { print_diagnostic(~"", lvl, msg); } } @@ -265,9 +265,9 @@ fn print_macro_backtrace(cm: codemap::codemap, sp: span) { } fn expect<T: copy>(diag: span_handler, - opt: option<T>, msg: fn() -> ~str) -> T { + opt: Option<T>, msg: fn() -> ~str) -> T { match opt { - some(t) => t, - none => diag.handler().bug(msg()) + Some(t) => t, + None => diag.handler().bug(msg()) } } diff --git a/src/libsyntax/ext/auto_serialize.rs b/src/libsyntax/ext/auto_serialize.rs index 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))}; } } } diff --git a/src/libsyntax/fold.rs b/src/libsyntax/fold.rs index 8bfbb14fc53..2006ccf639c 100644 --- a/src/libsyntax/fold.rs +++ b/src/libsyntax/fold.rs @@ -23,7 +23,7 @@ trait ast_fold { fn fold_crate_directive(&&@crate_directive) -> @crate_directive; fn fold_view_item(&&@view_item) -> @view_item; fn fold_foreign_item(&&@foreign_item) -> @foreign_item; - fn fold_item(&&@item) -> option<@item>; + fn fold_item(&&@item) -> Option<@item>; fn fold_struct_field(&&@struct_field) -> @struct_field; fn fold_item_underscore(item_) -> item_; fn fold_method(&&@method) -> @method; @@ -54,7 +54,7 @@ type ast_fold_precursor = @{ ast_fold) -> (crate_directive_, span), fold_view_item: fn@(view_item_, ast_fold) -> view_item_, fold_foreign_item: fn@(&&@foreign_item, ast_fold) -> @foreign_item, - fold_item: fn@(&&@item, ast_fold) -> option<@item>, + fold_item: fn@(&&@item, ast_fold) -> Option<@item>, fold_struct_field: fn@(&&@struct_field, ast_fold) -> @struct_field, fold_item_underscore: fn@(item_, ast_fold) -> item_, fold_method: fn@(&&@method, ast_fold) -> @method, @@ -204,10 +204,10 @@ fn noop_fold_foreign_item(&&ni: @foreign_item, fld: ast_fold) span: fld.new_span(ni.span)}; } -fn noop_fold_item(&&i: @item, fld: ast_fold) -> option<@item> { +fn noop_fold_item(&&i: @item, fld: ast_fold) -> Option<@item> { let fold_attribute = |x| fold_attribute_(x, fld); - return some(@{ident: fld.fold_ident(i.ident), + return Some(@{ident: fld.fold_ident(i.ident), attrs: vec::map(i.attrs, fold_attribute), id: fld.new_id(i.id), node: fld.fold_item_underscore(i.node), @@ -270,11 +270,11 @@ fn fold_struct_def(struct_def: @ast::struct_def, fld: ast_fold) -> @ast::struct_def { let resulting_optional_constructor; match struct_def.ctor { - none => { - resulting_optional_constructor = none; + None => { + resulting_optional_constructor = None; } - some(constructor) => { - resulting_optional_constructor = some({ + Some(constructor) => { + resulting_optional_constructor = Some({ node: { body: fld.fold_block(constructor.node.body), dec: fold_fn_decl(constructor.node.dec, fld), @@ -394,8 +394,8 @@ fn noop_fold_decl(d: decl_, fld: ast_fold) -> decl_ { match d { decl_local(ls) => decl_local(vec::map(ls, |x| fld.fold_local(x))), decl_item(it) => match fld.fold_item(it) { - some(it_folded) => decl_item(it_folded), - none => decl_local(~[]) + Some(it_folded) => decl_item(it_folded), + None => decl_local(~[]) } } } @@ -581,7 +581,7 @@ fn noop_fold_variant(v: variant_, fld: ast_fold) -> variant_ { fields: vec::map(struct_def.fields, |f| fld.fold_struct_field(f)), methods: vec::map(struct_def.methods, |m| fld.fold_method(m)), - ctor: none, + ctor: None, dtor: dtor }) } @@ -600,8 +600,8 @@ fn noop_fold_variant(v: variant_, fld: ast_fold) -> variant_ { let attrs = vec::map(v.attrs, fold_attribute); let de = match v.disr_expr { - some(e) => some(fld.fold_expr(e)), - none => none + Some(e) => Some(fld.fold_expr(e)), + None => None }; return {name: /* FIXME (#2543) */ copy v.name, attrs: attrs, @@ -628,9 +628,9 @@ fn noop_fold_local(l: local_, fld: ast_fold) -> local_ { pat: fld.fold_pat(l.pat), init: match l.init { - option::none::<initializer> => l.init, - option::some::<initializer>(init) => { - option::some::<initializer>({op: init.op, + option::None::<initializer> => l.init, + option::Some::<initializer>(init) => { + option::Some::<initializer>({op: init.op, expr: fld.fold_expr(init.expr)}) } }, @@ -698,7 +698,7 @@ impl ast_fold_precursor: ast_fold { -> @foreign_item { return self.fold_foreign_item(x, self as ast_fold); } - fn fold_item(&&i: @item) -> option<@item> { + fn fold_item(&&i: @item) -> Option<@item> { return self.fold_item(i, self as ast_fold); } fn fold_struct_field(&&sf: @struct_field) -> @struct_field { diff --git a/src/libsyntax/parse.rs b/src/libsyntax/parse.rs index b83c687b94b..41cb285f7db 100644 --- a/src/libsyntax/parse.rs +++ b/src/libsyntax/parse.rs @@ -31,7 +31,7 @@ type parse_sess = @{ mut byte_pos: uint }; -fn new_parse_sess(demitter: option<emitter>) -> parse_sess { +fn new_parse_sess(demitter: Option<emitter>) -> parse_sess { let cm = codemap::new_codemap(); return @{cm: cm, mut next_id: 1, @@ -51,9 +51,9 @@ fn new_parse_sess_special_handler(sh: span_handler, cm: codemap::codemap) fn parse_crate_from_file(input: &Path, cfg: ast::crate_cfg, sess: parse_sess) -> @ast::crate { - if input.filetype() == some(~"rc") { + if input.filetype() == Some(~"rc") { parse_crate_from_crate_file(input, cfg, sess) - } else if input.filetype() == some(~"rs") { + } else if input.filetype() == Some(~"rs") { parse_crate_from_source_file(input, cfg, sess) } else { sess.span_diagnostic.handler().fatal(~"unknown input file type: " + @@ -117,7 +117,7 @@ fn parse_expr_from_source_str(name: ~str, source: @~str, cfg: ast::crate_cfg, fn parse_item_from_source_str(name: ~str, source: @~str, cfg: ast::crate_cfg, +attrs: ~[ast::attribute], - sess: parse_sess) -> option<@ast::item> { + sess: parse_sess) -> Option<@ast::item> { let (p, rdr) = new_parser_etc_from_source_str(sess, cfg, name, codemap::fss_none, source); let r = p.parse_item(attrs); @@ -208,6 +208,6 @@ fn new_parser_from_file(sess: parse_sess, cfg: ast::crate_cfg, path: &Path, fn new_parser_from_tt(sess: parse_sess, cfg: ast::crate_cfg, tt: ~[ast::token_tree]) -> parser { let trdr = lexer::new_tt_reader(sess.span_diagnostic, sess.interner, - none, tt); + None, tt); return parser(sess, cfg, trdr as reader, parser::SOURCE_FILE) } diff --git a/src/libsyntax/parse/attr.rs b/src/libsyntax/parse/attr.rs index 54b0e3388f7..074b7c5829d 100644 --- a/src/libsyntax/parse/attr.rs +++ b/src/libsyntax/parse/attr.rs @@ -7,7 +7,7 @@ export parser_attr; // A type to distingush between the parsing of item attributes or syntax // extensions, which both begin with token.POUND -type attr_or_ext = option<Either<~[ast::attribute], @ast::expr>>; +type attr_or_ext = Option<Either<~[ast::attribute], @ast::expr>>; trait parser_attr { fn parse_outer_attrs_or_ext(first_item_attrs: ~[ast::attribute]) @@ -36,20 +36,20 @@ impl parser: parser_attr { self.bump(); let first_attr = self.parse_attribute_naked(ast::attr_outer, lo); - return some(Left(vec::append(~[first_attr], + return Some(Left(vec::append(~[first_attr], self.parse_outer_attributes()))); } else if !(self.look_ahead(1u) == token::LT || self.look_ahead(1u) == token::LBRACKET || self.look_ahead(1u) == token::POUND || expect_item_next) { self.bump(); - return some(Right(self.parse_syntax_ext_naked(lo))); - } else { return none; } + return Some(Right(self.parse_syntax_ext_naked(lo))); + } else { return None; } } token::DOC_COMMENT(_) => { - return some(Left(self.parse_outer_attributes())); + return Some(Left(self.parse_outer_attributes())); } - _ => return none + _ => return None } } diff --git a/src/libsyntax/parse/classify.rs b/src/libsyntax/parse/classify.rs index 8f44a165ea4..3ad33b8f218 100644 --- a/src/libsyntax/parse/classify.rs +++ b/src/libsyntax/parse/classify.rs @@ -68,7 +68,7 @@ fn ends_in_lit_int(ex: @ast::expr) -> bool { ends_in_lit_int(sub) } ast::expr_fail(osub) | ast::expr_ret(osub) => match osub { - some(ex) => ends_in_lit_int(ex), + Some(ex) => ends_in_lit_int(ex), _ => false }, _ => false diff --git a/src/libsyntax/parse/comments.rs b/src/libsyntax/parse/comments.rs index b80e472c047..7b18ca532e0 100644 --- a/src/libsyntax/parse/comments.rs +++ b/src/libsyntax/parse/comments.rs @@ -50,7 +50,7 @@ fn strip_doc_comment_decoration(comment: ~str) -> ~str { } // drop leftmost columns that contain only values in chars - fn block_trim(lines: ~[~str], chars: ~str, max: option<uint>) -> ~[~str] { + fn block_trim(lines: ~[~str], chars: ~str, max: Option<uint>) -> ~[~str] { let mut i = max.get_default(uint::max_value); for lines.each |line| { @@ -85,9 +85,9 @@ fn strip_doc_comment_decoration(comment: ~str) -> ~str { if comment.starts_with(~"/*") { let lines = str::lines_any(comment.slice(3u, comment.len() - 2u)); let lines = vertical_trim(lines); - let lines = block_trim(lines, ~"\t ", none); - let lines = block_trim(lines, ~"*", some(1u)); - let lines = block_trim(lines, ~"\t ", none); + let lines = block_trim(lines, ~"\t ", None); + let lines = block_trim(lines, ~"*", Some(1u)); + let lines = block_trim(lines, ~"\t ", None); return str::connect(lines, ~"\n"); } diff --git a/src/libsyntax/parse/common.rs b/src/libsyntax/parse/common.rs index e68a8120992..9cca463c7c3 100644 --- a/src/libsyntax/parse/common.rs +++ b/src/libsyntax/parse/common.rs @@ -4,18 +4,18 @@ import parser::parser; import lexer::reader; type seq_sep = { - sep: option<token::token>, + sep: Option<token::token>, trailing_sep_allowed: bool }; fn seq_sep_trailing_disallowed(t: token::token) -> seq_sep { - return {sep: option::some(t), trailing_sep_allowed: false}; + return {sep: option::Some(t), trailing_sep_allowed: false}; } fn seq_sep_trailing_allowed(t: token::token) -> seq_sep { - return {sep: option::some(t), trailing_sep_allowed: true}; + return {sep: option::Some(t), trailing_sep_allowed: true}; } fn seq_sep_none() -> seq_sep { - return {sep: option::none, trailing_sep_allowed: false}; + return {sep: option::None, trailing_sep_allowed: false}; } fn token_to_str(reader: reader, ++token: token::token) -> ~str { @@ -41,11 +41,11 @@ trait parser_common { fn check_restricted_keywords(); fn check_restricted_keywords_(w: ~str); fn expect_gt(); - fn parse_seq_to_before_gt<T: copy>(sep: option<token::token>, + fn parse_seq_to_before_gt<T: copy>(sep: Option<token::token>, f: fn(parser) -> T) -> ~[T]; - fn parse_seq_to_gt<T: copy>(sep: option<token::token>, + fn parse_seq_to_gt<T: copy>(sep: Option<token::token>, f: fn(parser) -> T) -> ~[T]; - fn parse_seq_lt_gt<T: copy>(sep: option<token::token>, + fn parse_seq_lt_gt<T: copy>(sep: Option<token::token>, f: fn(parser) -> T) -> spanned<~[T]>; fn parse_seq_to_end<T: copy>(ket: token::token, sep: seq_sep, f: fn(parser) -> T) -> ~[T]; @@ -198,14 +198,14 @@ impl parser: parser_common { } } - fn parse_seq_to_before_gt<T: copy>(sep: option<token::token>, + fn parse_seq_to_before_gt<T: copy>(sep: Option<token::token>, f: fn(parser) -> T) -> ~[T] { let mut first = true; let mut v = ~[]; while self.token != token::GT && self.token != token::BINOP(token::SHR) { match sep { - some(t) => { + Some(t) => { if first { first = false; } else { self.expect(t); } } @@ -217,7 +217,7 @@ impl parser: parser_common { return v; } - fn parse_seq_to_gt<T: copy>(sep: option<token::token>, + fn parse_seq_to_gt<T: copy>(sep: Option<token::token>, f: fn(parser) -> T) -> ~[T] { let v = self.parse_seq_to_before_gt(sep, f); self.expect_gt(); @@ -225,7 +225,7 @@ impl parser: parser_common { return v; } - fn parse_seq_lt_gt<T: copy>(sep: option<token::token>, + fn parse_seq_lt_gt<T: copy>(sep: Option<token::token>, f: fn(parser) -> T) -> spanned<~[T]> { let lo = self.span.lo; self.expect(token::LT); @@ -249,7 +249,7 @@ impl parser: parser_common { let mut v: ~[T] = ~[]; while self.token != ket { match sep.sep { - some(t) => { + Some(t) => { if first { first = false; } else { self.expect(t); } } diff --git a/src/libsyntax/parse/eval.rs b/src/libsyntax/parse/eval.rs index 54ec79de4c1..2a4516f80aa 100644 --- a/src/libsyntax/parse/eval.rs +++ b/src/libsyntax/parse/eval.rs @@ -18,7 +18,7 @@ fn eval_crate_directives(cx: ctx, } fn eval_crate_directives_to_mod(cx: ctx, cdirs: ~[@ast::crate_directive], - prefix: &Path, suffix: &option<Path>) + prefix: &Path, suffix: &Option<Path>) -> (ast::_mod, ~[ast::attribute]) { let (cview_items, citems, cattrs) = parse_companion_mod(cx, prefix, suffix); @@ -40,13 +40,13 @@ companion mod is a .rs file with the same name as the directory. We build the path to the companion mod by combining the prefix and the optional suffix then adding the .rs extension. */ -fn parse_companion_mod(cx: ctx, prefix: &Path, suffix: &option<Path>) +fn parse_companion_mod(cx: ctx, prefix: &Path, suffix: &Option<Path>) -> (~[@ast::view_item], ~[@ast::item], ~[ast::attribute]) { - fn companion_file(prefix: &Path, suffix: &option<Path>) -> Path { + fn companion_file(prefix: &Path, suffix: &Option<Path>) -> Path { return match *suffix { - option::some(s) => prefix.push_many(s.components), - option::none => copy *prefix + option::Some(s) => prefix.push_many(s.components), + option::None => copy *prefix }.with_filetype("rs"); } @@ -76,8 +76,8 @@ fn parse_companion_mod(cx: ctx, prefix: &Path, suffix: &option<Path>) fn cdir_path_opt(default: ~str, attrs: ~[ast::attribute]) -> ~str { match ::attr::first_attr_value_str_by_name(attrs, ~"path") { - some(d) => d, - none => default + Some(d) => d, + None => default } } @@ -117,7 +117,7 @@ fn eval_crate_directive(cx: ctx, cdir: @ast::crate_directive, prefix: &Path, prefix.push_many(path.components) }; let (m0, a0) = eval_crate_directives_to_mod( - cx, cdirs, &full_path, &none); + cx, cdirs, &full_path, &None); let i = @{ident: /* FIXME (#2543) */ copy id, attrs: vec::append(attrs, a0), diff --git a/src/libsyntax/parse/lexer.rs b/src/libsyntax/parse/lexer.rs index bef69be4e8a..e51064d6ffe 100644 --- a/src/libsyntax/parse/lexer.rs +++ b/src/libsyntax/parse/lexer.rs @@ -196,14 +196,14 @@ fn is_bin_digit(c: char) -> bool { return c == '0' || c == '1'; } // might return a sugared-doc-attr fn consume_whitespace_and_comments(rdr: string_reader) - -> option<{tok: token::token, sp: span}> { + -> Option<{tok: token::token, sp: span}> { while is_whitespace(rdr.curr) { bump(rdr); } return consume_any_line_comment(rdr); } // might return a sugared-doc-attr fn consume_any_line_comment(rdr: string_reader) - -> option<{tok: token::token, sp: span}> { + -> Option<{tok: token::token, sp: span}> { if rdr.curr == '/' { match nextch(rdr) { '/' => { @@ -217,7 +217,7 @@ fn consume_any_line_comment(rdr: string_reader) str::push_char(acc, rdr.curr); bump(rdr); } - return some({ + return Some({ tok: token::DOC_COMMENT(rdr.interner.intern(@acc)), sp: ast_util::mk_sp(start_chpos, rdr.chpos) }); @@ -241,12 +241,12 @@ fn consume_any_line_comment(rdr: string_reader) } } } - return none; + return None; } // might return a sugared-doc-attr fn consume_block_comment(rdr: string_reader) - -> option<{tok: token::token, sp: span}> { + -> Option<{tok: token::token, sp: span}> { // block comments starting with "/**" or "/*!" are doc-comments if rdr.curr == '*' || rdr.curr == '!' { @@ -262,7 +262,7 @@ fn consume_block_comment(rdr: string_reader) acc += ~"*/"; bump(rdr); bump(rdr); - return some({ + return Some({ tok: token::DOC_COMMENT(rdr.interner.intern(@acc)), sp: ast_util::mk_sp(start_chpos, rdr.chpos) }); @@ -289,7 +289,7 @@ fn consume_block_comment(rdr: string_reader) return consume_whitespace_and_comments(rdr); } -fn scan_exponent(rdr: string_reader) -> option<~str> { +fn scan_exponent(rdr: string_reader) -> Option<~str> { let mut c = rdr.curr; let mut rslt = ~""; if c == 'e' || c == 'E' { @@ -302,9 +302,9 @@ fn scan_exponent(rdr: string_reader) -> option<~str> { } let exponent = scan_digits(rdr, 10u); if str::len(exponent) > 0u { - return some(rslt + exponent); + return Some(rslt + exponent); } else { rdr.fatal(~"scan_exponent: bad fp literal"); } - } else { return none::<~str>; } + } else { return None::<~str>; } } fn scan_digits(rdr: string_reader, radix: uint) -> ~str { @@ -313,7 +313,7 @@ fn scan_digits(rdr: string_reader, radix: uint) -> ~str { let c = rdr.curr; if c == '_' { bump(rdr); again; } match char::to_digit(c, radix) { - some(_) => { + Some(_) => { str::push_char(rslt, c); bump(rdr); } @@ -384,11 +384,11 @@ fn scan_number(c: char, rdr: string_reader) -> token::token { num_str += ~"." + dec_part; } match scan_exponent(rdr) { - some(s) => { + Some(s) => { is_float = true; num_str += s; } - none => () + None => () } if rdr.curr == 'f' { bump(rdr); diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index 840791d840b..a98be8ec1d0 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -109,7 +109,7 @@ enum class_contents { ctor_decl(fn_decl, ~[attribute], blk, codemap::span), members(~[@class_member]) } type arg_or_capture_item = Either<arg, capture_item>; -type item_info = (ident, item_, option<~[attribute]>); +type item_info = (ident, item_, Option<~[attribute]>); enum item_or_view_item { iovi_none, @@ -150,8 +150,8 @@ macro_rules! maybe_whole ( INTERPOLATED(token::$constructor(x)) => { $p.bump(); return *x; } _ => () }} ; - (some $p:expr, $constructor:ident) => { match copy $p.token { - INTERPOLATED(token::$constructor(x)) => { $p.bump(); return some(x); } + (Some $p:expr, $constructor:ident) => { match copy $p.token { + INTERPOLATED(token::$constructor(x)) => { $p.bump(); return Some(x); } _ => () }} ; (iovi $p:expr, $constructor:ident) => { match copy $p.token { @@ -169,11 +169,11 @@ macro_rules! maybe_whole ( ) -pure fn maybe_append(+lhs: ~[attribute], rhs: option<~[attribute]>) +pure fn maybe_append(+lhs: ~[attribute], rhs: Option<~[attribute]>) -> ~[attribute] { match rhs { - none => lhs, - some(attrs) => vec::append(lhs, attrs) + None => lhs, + Some(attrs) => vec::append(lhs, attrs) } } @@ -400,10 +400,10 @@ struct parser { } } - fn region_from_name(s: option<ident>) -> @region { + fn region_from_name(s: Option<ident>) -> @region { let r = match s { - some (id) => re_named(id), - none => re_anon + Some (id) => re_named(id), + None => re_anon }; @{id: self.get_id(), node: r} @@ -416,10 +416,10 @@ struct parser { match copy self.token { token::IDENT(sid, _) => { self.bump(); - self.region_from_name(some(sid)) + self.region_from_name(Some(sid)) } _ => { - self.region_from_name(none) + self.region_from_name(None) } } } @@ -431,12 +431,12 @@ struct parser { token::IDENT(sid, _) => { if self.look_ahead(1u) == token::BINOP(token::SLASH) { self.bump(); self.bump(); - some(sid) + Some(sid) } else { - none + None } } - _ => { none } + _ => { None } }; self.region_from_name(name) } @@ -447,12 +447,12 @@ struct parser { let lo = self.span.lo; match self.maybe_parse_dollar_mac() { - some(e) => { + Some(e) => { return @{id: self.get_id(), node: ty_mac(spanned(lo, self.span.hi, e)), span: mk_sp(lo, self.span.hi)}; } - none => () + None => () } let t = if self.token == token::LPAREN { @@ -495,8 +495,8 @@ struct parser { // Parse the `* 3` in `[ int * 3 ]` match self.maybe_parse_fixed_vstore_with_star() { - none => {} - some(suffix) => { + None => {} + Some(suffix) => { t = ty_fixed_length(@{ id: self.get_id(), node: t, @@ -529,8 +529,8 @@ struct parser { return @{id: self.get_id(), node: match self.maybe_parse_fixed_vstore() { // Consider a fixed vstore suffix (/N or /_) - none => t, - some(v) => { + None => t, + Some(v) => { ty_fixed_length(@{id: self.get_id(), node:t, span: sp}, v) } }, span: sp} @@ -615,7 +615,7 @@ struct parser { } } - fn maybe_parse_dollar_mac() -> option<mac_> { + fn maybe_parse_dollar_mac() -> Option<mac_> { match copy self.token { token::DOLLAR => { let lo = self.span.lo; @@ -623,54 +623,54 @@ struct parser { match copy self.token { token::LIT_INT_UNSUFFIXED(num) => { self.bump(); - some(mac_var(num as uint)) + Some(mac_var(num as uint)) } token::LPAREN => { self.bump(); let e = self.parse_expr(); self.expect(token::RPAREN); let hi = self.last_span.hi; - some(mac_aq(mk_sp(lo,hi), e)) + Some(mac_aq(mk_sp(lo,hi), e)) } _ => { self.fatal(~"expected `(` or unsuffixed integer literal"); } } } - _ => none + _ => None } } - fn maybe_parse_fixed_vstore() -> option<option<uint>> { + fn maybe_parse_fixed_vstore() -> Option<Option<uint>> { if self.token == token::BINOP(token::SLASH) { self.bump(); match copy self.token { token::UNDERSCORE => { - self.bump(); some(none) + self.bump(); Some(None) } token::LIT_INT_UNSUFFIXED(i) if i >= 0i64 => { - self.bump(); some(some(i as uint)) + self.bump(); Some(Some(i as uint)) } - _ => none + _ => None } } else { - none + None } } - fn maybe_parse_fixed_vstore_with_star() -> option<option<uint>> { + fn maybe_parse_fixed_vstore_with_star() -> Option<Option<uint>> { if self.eat(token::BINOP(token::STAR)) { match copy self.token { token::UNDERSCORE => { - self.bump(); some(none) + self.bump(); Some(None) } token::LIT_INT_UNSUFFIXED(i) if i >= 0i64 => { - self.bump(); some(some(i as uint)) + self.bump(); Some(Some(i as uint)) } - _ => none + _ => None } } else { - none + None } } @@ -727,7 +727,7 @@ struct parser { } } @{span: mk_sp(lo, self.last_span.hi), global: global, - idents: ids, rp: none, types: ~[]} + idents: ids, rp: None, types: ~[]} } fn parse_value_path() -> @path { @@ -757,16 +757,16 @@ struct parser { && self.look_ahead(1u) == token::BINOP(token::AND) { self.expect(token::BINOP(token::SLASH)); - some(self.parse_region()) + Some(self.parse_region()) } else { - none + None } }; // Parse any type parameters which may appear: let tps = { if self.token == token::LT { - self.parse_seq_lt_gt(some(token::COMMA), + self.parse_seq_lt_gt(Some(token::COMMA), |p| p.parse_ty(false)) } else { {node: ~[], span: path.span} @@ -837,7 +837,7 @@ struct parser { let mut ex: expr_; match self.maybe_parse_dollar_mac() { - some(x) => return pexpr(self.mk_mac_expr(lo, self.span.hi, x)), + Some(x) => return pexpr(self.mk_mac_expr(lo, self.span.hi, x)), _ => () } @@ -941,8 +941,8 @@ struct parser { if can_begin_expr(self.token) { let e = self.parse_expr(); hi = e.span.hi; - ex = expr_fail(some(e)); - } else { ex = expr_fail(none); } + ex = expr_fail(Some(e)); + } else { ex = expr_fail(None); } } else if self.eat_keyword(~"log") { self.expect(token::LPAREN); let lvl = self.parse_expr(); @@ -959,20 +959,20 @@ struct parser { if can_begin_expr(self.token) { let e = self.parse_expr(); hi = e.span.hi; - ex = expr_ret(some(e)); - } else { ex = expr_ret(none); } + ex = expr_ret(Some(e)); + } else { ex = expr_ret(None); } } else if self.eat_keyword(~"break") { if is_ident(self.token) { - ex = expr_break(some(self.parse_ident())); + ex = expr_break(Some(self.parse_ident())); } else { - ex = expr_break(none); + ex = expr_break(None); } hi = self.span.hi; } else if self.eat_keyword(~"again") { if is_ident(self.token) { - ex = expr_again(some(self.parse_ident())); + ex = expr_again(Some(self.parse_ident())); } else { - ex = expr_again(none); + ex = expr_again(None); } hi = self.span.hi; } else if self.eat_keyword(~"copy") { @@ -1020,9 +1020,9 @@ struct parser { let base; if self.eat_keyword(~"with") || self.eat(token::DOTDOT) { - base = some(self.parse_expr()); + base = Some(self.parse_expr()); } else { - base = none; + base = None; } hi = pth.span.hi; @@ -1045,8 +1045,8 @@ struct parser { match ex { expr_lit(@{node: lit_str(_), span: _}) | expr_vec(_, _) => match self.maybe_parse_fixed_vstore() { - none => (), - some(v) => { + None => (), + Some(v) => { hi = self.span.hi; ex = expr_vstore(self.mk_expr(lo, hi, ex), vstore_fixed(v)); } @@ -1077,7 +1077,7 @@ struct parser { let pth = self.parse_path_without_tps(); //temporary for a backwards-compatible cycle: let sep = seq_sep_trailing_disallowed(token::COMMA); - let mut e = none; + let mut e = None; if (self.token == token::LPAREN || self.token == token::LBRACKET) { let lo = self.span.lo; let es = @@ -1089,9 +1089,9 @@ struct parser { sep, |p| p.parse_expr()) }; let hi = self.span.hi; - e = some(self.mk_expr(lo, hi, expr_vec(es, m_imm))); + e = Some(self.mk_expr(lo, hi, expr_vec(es, m_imm))); } - let mut b = none; + let mut b = None; if self.token == token::LBRACE { self.bump(); let lo = self.span.lo; @@ -1106,7 +1106,7 @@ struct parser { self.bump(); } let hi = self.last_span.lo; - b = some({span: mk_sp(lo,hi)}); + b = Some({span: mk_sp(lo,hi)}); } return self.mk_mac_expr(lo, self.span.hi, mac_invoc(pth, e, b)); } @@ -1133,7 +1133,7 @@ struct parser { self.bump(); let tys = if self.eat(token::MOD_SEP) { self.expect(token::LT); - self.parse_seq_to_gt(some(token::COMMA), + self.parse_seq_to_gt(Some(token::COMMA), |p| p.parse_ty(false)) } else { ~[] }; e = self.mk_pexpr(lo, hi, expr_field(self.to_expr(e), i, @@ -1172,12 +1172,12 @@ struct parser { return e; } - fn parse_sep_and_zerok() -> (option<token::token>, bool) { + fn parse_sep_and_zerok() -> (Option<token::token>, bool) { if self.token == token::BINOP(token::STAR) || self.token == token::BINOP(token::PLUS) { let zerok = self.token == token::BINOP(token::STAR); self.bump(); - return (none, zerok); + return (None, zerok); } else { let sep = self.token; self.bump(); @@ -1185,7 +1185,7 @@ struct parser { || self.token == token::BINOP(token::PLUS) { let zerok = self.token == token::BINOP(token::STAR); self.bump(); - return (some(sep), zerok); + return (Some(sep), zerok); } else { self.fatal(~"expected `*` or `+`"); } @@ -1347,7 +1347,7 @@ struct parser { ex = match e.node { expr_vec(*) | expr_lit(@{node: lit_str(_), span: _}) if m == m_imm => { - expr_vstore(e, vstore_slice(self.region_from_name(none))) + expr_vstore(e, vstore_slice(self.region_from_name(None))) } _ => expr_addr_of(m, e) }; @@ -1405,7 +1405,7 @@ struct parser { } let cur_opt = token_to_binop(peeked); match cur_opt { - some(cur_op) => { + Some(cur_op) => { let cur_prec = operator_prec(cur_op); if cur_prec > min_prec { self.bump(); @@ -1476,11 +1476,11 @@ struct parser { let lo = self.last_span.lo; let cond = self.parse_expr(); let thn = self.parse_block(); - let mut els: option<@expr> = none; + let mut els: Option<@expr> = None; let mut hi = thn.span.hi; if self.eat_keyword(~"else") { let elexpr = self.parse_else_expr(); - els = some(elexpr); + els = Some(elexpr); hi = elexpr.span.hi; } let q = {cond: cond, then: thn, els: els, lo: lo, hi: hi}; @@ -1542,7 +1542,7 @@ struct parser { let lo = self.last_span.lo; let (decl, captures) = parse_decl(); let body = parse_body(); - let fakeblock = {view_items: ~[], stmts: ~[], expr: some(body), + let fakeblock = {view_items: ~[], stmts: ~[], expr: Some(body), id: self.get_id(), rules: default_blk}; let fakeblock = spanned(body.span.lo, body.span.hi, fakeblock); @@ -1610,10 +1610,10 @@ struct parser { fn parse_loop_expr() -> @expr { let opt_ident; if is_ident(self.token) && !self.is_any_keyword(copy self.token) { - opt_ident = some(self.parse_ident()); + opt_ident = Some(self.parse_ident()); self.expect(token::COLON); } else { - opt_ident = none; + opt_ident = None; } let lo = self.last_span.lo; @@ -1634,13 +1634,13 @@ struct parser { fn parse_record_literal() -> expr_ { self.expect(token::LBRACE); let mut fields = ~[self.parse_field(token::COLON)]; - let mut base = none; + let mut base = None; while self.token != token::RBRACE { if self.token == token::COMMA && self.look_ahead(1) == token::DOTDOT { self.bump(); self.bump(); - base = some(self.parse_expr()); break; + base = Some(self.parse_expr()); break; } // XXX: Remove "with" after all code is converted over and there's @@ -1653,7 +1653,7 @@ struct parser { self.bump(); } if self.eat_keyword(~"with") { - base = some(self.parse_expr()); break; + base = Some(self.parse_expr()); break; } self.expect(token::COMMA); if self.token == token::RBRACE { @@ -1673,8 +1673,8 @@ struct parser { let mut arms: ~[arm] = ~[]; while self.token != token::RBRACE { let pats = self.parse_pats(); - let mut guard = none; - if self.eat_keyword(~"if") { guard = some(self.parse_expr()); } + let mut guard = None; + if self.eat_keyword(~"if") { guard = Some(self.parse_expr()); } self.expect(token::FAT_ARROW); let expr = self.parse_expr_res(RESTRICT_STMT_EXPR); @@ -1690,7 +1690,7 @@ struct parser { let blk = {node: {view_items: ~[], stmts: ~[], - expr: some(expr), + expr: Some(expr), id: self.get_id(), rules: default_blk}, span: expr.span}; @@ -1714,25 +1714,25 @@ struct parser { return e; } - fn parse_initializer() -> option<initializer> { + fn parse_initializer() -> Option<initializer> { match self.token { token::EQ => { self.bump(); - return some({op: init_assign, expr: self.parse_expr()}); + return Some({op: init_assign, expr: self.parse_expr()}); } token::LARROW => { self.bump(); - return some({op: init_move, expr: self.parse_expr()}); + return Some({op: init_move, expr: self.parse_expr()}); } // Now that the the channel is the first argument to receive, // combining it with an initializer doesn't really make sense. // case (token::RECV) { // self.bump(); - // return some(rec(op = init_recv, + // return Some(rec(op = init_recv, // expr = self.parse_expr())); // } _ => { - return none; + return None; } } } @@ -1783,7 +1783,7 @@ struct parser { id: self.get_id(), node: pat_ident(bind_by_implicit_ref, fieldpath, - none), + None), span: self.last_span }; } @@ -1911,9 +1911,9 @@ struct parser { let name = self.parse_value_path(); let sub; if self.eat(token::AT) { - sub = some(self.parse_pat(refutable)); + sub = Some(self.parse_pat(refutable)); } else { - sub = none; + sub = None; }; pat = pat_ident(binding_mode, name, sub); } else { @@ -1950,16 +1950,16 @@ struct parser { // at this point, we're not sure whether it's a // enum or a bind if star_pat { - pat = pat_enum(enum_path, none); + pat = pat_enum(enum_path, None); } else if vec::is_empty(args) && vec::len(enum_path.idents) == 1u { pat = pat_ident(binding_mode, enum_path, - none); + None); } else { - pat = pat_enum(enum_path, some(args)); + pat = pat_enum(enum_path, Some(args)); } } } @@ -1980,11 +1980,11 @@ struct parser { } let name = self.parse_value_path(); let sub = if self.eat(token::AT) { - some(self.parse_pat(refutable)) - } else { none }; + Some(self.parse_pat(refutable)) + } else { None }; // just to be friendly, if they write something like - // ref some(i) + // ref Some(i) // we end up here with ( as the current token. This shortly // leads to a parse error. Note that if there is no explicit // binding mode then we do not end up here, because the lookahead @@ -2007,19 +2007,19 @@ struct parser { self.expect(token::LPAREN); self.expect(token::BINOP(token::STAR)); self.expect(token::RPAREN); - pat_enum(enum_path, none) + pat_enum(enum_path, None) } _ => { // foo(a, ..., z) let args = self.parse_unspanned_seq( token::LPAREN, token::RPAREN, seq_sep_trailing_disallowed(token::COMMA), |p| p.parse_pat(refutable)); - pat_enum(enum_path, some(args)) + pat_enum(enum_path, Some(args)) } } } - _ => { // option::none - pat_enum(enum_path, some(~[])) + _ => { // option::None + pat_enum(enum_path, Some(~[])) } } } @@ -2032,7 +2032,7 @@ struct parser { node: ty_infer, span: mk_sp(lo, lo)}; if self.eat(token::COLON) { ty = self.parse_ty(false); } - let init = if allow_init { self.parse_initializer() } else { none }; + let init = if allow_init { self.parse_initializer() } else { None }; return @spanned(lo, self.last_span.hi, {is_mutbl: is_mutbl, ty: ty, pat: pat, init: init, id: self.get_id()}); @@ -2087,9 +2087,9 @@ struct parser { } else { let mut item_attrs; match self.parse_outer_attrs_or_ext(first_item_attrs) { - none => item_attrs = ~[], - some(Left(attrs)) => item_attrs = attrs, - some(Right(ext)) => { + None => item_attrs = ~[], + Some(Left(attrs)) => item_attrs = attrs, + Some(Right(ext)) => { return @spanned(lo, ext.span.hi, stmt_expr(ext, self.get_id())); } @@ -2180,7 +2180,7 @@ struct parser { fn parse_block_tail_(lo: uint, s: blk_check_mode, +first_item_attrs: ~[attribute]) -> blk { let mut stmts = ~[]; - let mut expr = none; + let mut expr = None; let {attrs_remaining, view_items, items: items} = self.parse_items_and_view_items(first_item_attrs, @@ -2215,7 +2215,7 @@ struct parser { @{node: stmt_semi(e, stmt_id) with *stmt}); } token::RBRACE => { - expr = some(e); + expr = Some(e); } t => { if classify::stmt_ends_with_semi(*stmt) { @@ -2274,7 +2274,7 @@ struct parser { fn parse_ty_params() -> ~[ty_param] { if self.eat(token::LT) { - self.parse_seq_to_gt(some(token::COMMA), |p| p.parse_ty_param()) + self.parse_seq_to_gt(Some(token::COMMA), |p| p.parse_ty_param()) } else { ~[] } } @@ -2444,7 +2444,7 @@ struct parser { let t = self.parse_fn_header(); let (decl, _) = self.parse_fn_decl(|p| p.parse_arg()); let (inner_attrs, body) = self.parse_inner_attrs_and_block(true); - (t.ident, item_fn(decl, purity, t.tps, body), some(inner_attrs)) + (t.ident, item_fn(decl, purity, t.tps, body), Some(inner_attrs)) } fn parse_method_name() -> ident { @@ -2490,7 +2490,7 @@ struct parser { } let meths = self.parse_trait_methods(); - (ident, item_trait(tps, traits, meths), none) + (ident, item_trait(tps, traits, meths), None) } // Parses four variants (with the region/type params always optional): @@ -2531,7 +2531,7 @@ struct parser { while !self.eat(token::RBRACE) { vec::push(meths, self.parse_method(public)); } - (ident, item_impl(tps, traits, ty, meths), none) + (ident, item_impl(tps, traits, ty, meths), None) } // Instantiates ident <i> with references to <typarams> as arguments. @@ -2542,7 +2542,7 @@ struct parser { let s = self.last_span; @{span: s, global: false, idents: ~[i], - rp: none, + rp: None, types: vec::map(typarams, |tp| { @{id: self.get_id(), node: ty_path(ident_to_path(s, tp.ident), self.get_id()), @@ -2572,9 +2572,9 @@ struct parser { let mut fields: ~[@struct_field]; let mut methods: ~[@method] = ~[]; - let mut the_ctor: option<(fn_decl, ~[attribute], blk, codemap::span)> - = none; - let mut the_dtor: option<(blk, ~[attribute], codemap::span)> = none; + let mut the_ctor: Option<(fn_decl, ~[attribute], blk, codemap::span)> + = None; + let mut the_dtor: Option<(blk, ~[attribute], codemap::span)> = None; let ctor_id = self.get_id(); if self.eat(token::LBRACE) { @@ -2584,29 +2584,29 @@ struct parser { match self.parse_class_item(class_path) { ctor_decl(a_fn_decl, attrs, blk, s) => { match the_ctor { - some((_, _, _, s_first)) => { + Some((_, _, _, s_first)) => { self.span_note(s, #fmt("Duplicate constructor \ declaration for class %s", *self.interner.get(class_name))); self.span_fatal(copy s_first, ~"First constructor \ declared here"); } - none => { - the_ctor = some((a_fn_decl, attrs, blk, s)); + None => { + the_ctor = Some((a_fn_decl, attrs, blk, s)); } } } dtor_decl(blk, attrs, s) => { match the_dtor { - some((_, _, s_first)) => { + Some((_, _, s_first)) => { self.span_note(s, #fmt("Duplicate destructor \ declaration for class %s", *self.interner.get(class_name))); self.span_fatal(copy s_first, ~"First destructor \ declared here"); } - none => { - the_dtor = some((blk, attrs, s)); + None => { + the_dtor = Some((blk, attrs, s)); } } } @@ -2654,13 +2654,13 @@ struct parser { body: d_body}, span: d_s}}; match the_ctor { - some((ct_d, ct_attrs, ct_b, ct_s)) => { + Some((ct_d, ct_attrs, ct_b, ct_s)) => { (class_name, item_class(@{ traits: traits, fields: move fields, methods: move methods, - ctor: some({ + ctor: Some({ node: {id: ctor_id, attrs: ct_attrs, self_id: self.get_id(), @@ -2669,18 +2669,18 @@ struct parser { span: ct_s}), dtor: actual_dtor }, ty_params), - none) + None) } - none => { + None => { (class_name, item_class(@{ traits: traits, fields: move fields, methods: move methods, - ctor: none, + ctor: None, dtor: actual_dtor }, ty_params), - none) + None) } } } @@ -2829,7 +2829,7 @@ struct parser { self.expect(token::EQ); let e = self.parse_expr(); self.expect(token::SEMI); - (id, item_const(ty, e), none) + (id, item_const(ty, e), None) } fn parse_item_mod() -> item_info { @@ -2838,7 +2838,7 @@ struct parser { let inner_attrs = self.parse_inner_attrs_and_next(); let m = self.parse_mod_items(token::RBRACE, inner_attrs.next); self.expect(token::RBRACE); - (id, item_mod(m), some(inner_attrs.inner)) + (id, item_mod(m), Some(inner_attrs.inner)) } fn parse_item_foreign_fn(+attrs: ~[attribute]) -> @foreign_item { @@ -2929,7 +2929,7 @@ struct parser { return iovi_item(self.mk_item(lo, self.last_span.hi, ident, item_foreign_mod(m), visibility, maybe_append(attrs, - some(extra_attrs. + Some(extra_attrs. inner)))); } @@ -2957,7 +2957,7 @@ struct parser { self.expect(token::EQ); let ty = self.parse_ty(false); self.expect(token::SEMI); - (t.ident, item_ty(ty, tps), none) + (t.ident, item_ty(ty, tps), None) } fn parse_region_param() { @@ -2967,7 +2967,7 @@ struct parser { } fn parse_struct_def(path: @path) -> @struct_def { - let mut the_dtor: option<(blk, ~[attribute], codemap::span)> = none; + let mut the_dtor: Option<(blk, ~[attribute], codemap::span)> = None; let mut fields: ~[@struct_field] = ~[]; let mut methods: ~[@method] = ~[]; while self.token != token::RBRACE { @@ -2980,15 +2980,15 @@ struct parser { } dtor_decl(blk, attrs, s) => { match the_dtor { - some((_, _, s_first)) => { + Some((_, _, s_first)) => { self.span_note(s, ~"duplicate destructor \ declaration"); self.span_fatal(copy s_first, ~"first destructor \ declared here"); } - none => { - the_dtor = some((blk, attrs, s)); + None => { + the_dtor = Some((blk, attrs, s)); } } } @@ -3018,7 +3018,7 @@ struct parser { traits: ~[], fields: move fields, methods: move methods, - ctor: none, + ctor: None, dtor: actual_dtor }; } @@ -3027,7 +3027,7 @@ struct parser { -> enum_def { let mut variants: ~[variant] = ~[]; let mut all_nullary = true, have_disr = false; - let mut common_fields = none; + let mut common_fields = None; while self.token != token::RBRACE { let variant_attrs = self.parse_outer_attributes(); @@ -3040,7 +3040,7 @@ struct parser { } self.expect(token::LBRACE); let path = self.ident_to_path_tys(ident, ty_params); - common_fields = some(self.parse_struct_def(path)); + common_fields = Some(self.parse_struct_def(path)); again; } @@ -3048,7 +3048,7 @@ struct parser { // Is this a nested enum declaration? let ident, needs_comma, kind; - let mut args = ~[], disr_expr = none; + let mut args = ~[], disr_expr = None; if self.eat_keyword(~"enum") { ident = self.parse_ident(); self.expect(token::LBRACE); @@ -3074,7 +3074,7 @@ struct parser { kind = tuple_variant_kind(args); } else if self.eat(token::EQ) { have_disr = true; - disr_expr = some(self.parse_expr()); + disr_expr = Some(self.parse_expr()); kind = tuple_variant_kind(args); } else { kind = tuple_variant_kind(~[]); @@ -3115,16 +3115,16 @@ struct parser { kind: tuple_variant_kind (~[{ty: ty, id: self.get_id()}]), id: self.get_id(), - disr_expr: none, + disr_expr: None, vis: public}); return (id, item_enum(enum_def({ variants: ~[variant], - common: none }), - ty_params), none); + common: None }), + ty_params), None); } self.expect(token::LBRACE); let enum_definition = self.parse_enum_def(id, ty_params); - (id, item_enum(enum_definition, ty_params), none) + (id, item_enum(enum_definition, ty_params), None) } fn parse_fn_ty_proto() -> proto { @@ -3278,7 +3278,7 @@ struct parser { let m: ast::mac = {node: m, span: {lo: self.span.lo, hi: self.span.hi, - expn_info: none}}; + expn_info: None}}; let item_ = item_mac(m); return iovi_item(self.mk_item(lo, self.last_span.hi, id, item_, visibility, attrs)); @@ -3287,14 +3287,14 @@ struct parser { }; } - fn parse_item(+attrs: ~[attribute]) -> option<@ast::item> { + fn parse_item(+attrs: ~[attribute]) -> Option<@ast::item> { match self.parse_item_or_view_item(attrs, true) { iovi_none => - none, + None, iovi_view_item(_) => self.fatal(~"view items are not allowed here"), iovi_item(item) => - some(item) + Some(item) } } @@ -3326,7 +3326,7 @@ struct parser { vec::push(path, id); } let path = @{span: mk_sp(lo, self.span.hi), global: false, - idents: path, rp: none, types: ~[]}; + idents: path, rp: None, types: ~[]}; return @spanned(lo, self.span.hi, view_path_simple(first_ident, path, self.get_id())); } @@ -3351,7 +3351,7 @@ struct parser { |p| p.parse_path_list_ident()); let path = @{span: mk_sp(lo, self.span.hi), global: false, idents: path, - rp: none, types: ~[]}; + rp: None, types: ~[]}; return @spanned(lo, self.span.hi, view_path_list(path, idents, self.get_id())); } @@ -3361,7 +3361,7 @@ struct parser { self.bump(); let path = @{span: mk_sp(lo, self.span.hi), global: false, idents: path, - rp: none, types: ~[]}; + rp: None, types: ~[]}; return @spanned(lo, self.span.hi, view_path_glob(path, self.get_id())); } @@ -3374,7 +3374,7 @@ struct parser { } let last = path[vec::len(path) - 1u]; let path = @{span: mk_sp(lo, self.span.hi), global: false, - idents: path, rp: none, types: ~[]}; + idents: path, rp: None, types: ~[]}; return @spanned(lo, self.span.hi, view_path_simple(last, path, self.get_id())); } diff --git a/src/libsyntax/parse/prec.rs b/src/libsyntax/parse/prec.rs index bd9ada9a338..872ffeb84a5 100644 --- a/src/libsyntax/parse/prec.rs +++ b/src/libsyntax/parse/prec.rs @@ -19,27 +19,27 @@ const as_prec: uint = 11u; * Maps a token to a record specifying the corresponding binary * operator and its precedence */ -fn token_to_binop(tok: token) -> option<ast::binop> { +fn token_to_binop(tok: token) -> Option<ast::binop> { match tok { - BINOP(STAR) => some(mul), - BINOP(SLASH) => some(div), - BINOP(PERCENT) => some(rem), + BINOP(STAR) => Some(mul), + BINOP(SLASH) => Some(div), + BINOP(PERCENT) => Some(rem), // 'as' sits between here with 11 - BINOP(PLUS) => some(add), - BINOP(MINUS) => some(subtract), - BINOP(SHL) => some(shl), - BINOP(SHR) => some(shr), - BINOP(AND) => some(bitand), - BINOP(CARET) => some(bitxor), - BINOP(OR) => some(bitor), - LT => some(lt), - LE => some(le), - GE => some(ge), - GT => some(gt), - EQEQ => some(eq), - NE => some(ne), - ANDAND => some(and), - OROR => some(or), - _ => none + BINOP(PLUS) => Some(add), + BINOP(MINUS) => Some(subtract), + BINOP(SHL) => Some(shl), + BINOP(SHR) => Some(shr), + BINOP(AND) => Some(bitand), + BINOP(CARET) => Some(bitxor), + BINOP(OR) => Some(bitor), + LT => Some(lt), + LE => Some(le), + GE => Some(ge), + GT => Some(gt), + EQEQ => Some(eq), + NE => Some(ne), + ANDAND => Some(and), + OROR => Some(or), + _ => None } } diff --git a/src/libsyntax/parse/token.rs b/src/libsyntax/parse/token.rs index 759d99511fe..846a7e7c88e 100644 --- a/src/libsyntax/parse/token.rs +++ b/src/libsyntax/parse/token.rs @@ -349,7 +349,7 @@ fn mk_ident_interner() -> ident_interner { |x,y| str::eq(*x, *y), init_vec); /* having multiple interners will just confuse the serializer */ - unsafe{ assert task::local_data_get(interner_key!()) == none }; + unsafe{ assert task::local_data_get(interner_key!()) == None }; unsafe{ task::local_data_set(interner_key!(), @rv) }; rv } diff --git a/src/libsyntax/print/pprust.rs b/src/libsyntax/print/pprust.rs index f4d7817f564..4ebdcd03040 100644 --- a/src/libsyntax/print/pprust.rs +++ b/src/libsyntax/print/pprust.rs @@ -26,10 +26,10 @@ fn no_ann() -> pp_ann { type ps = @{s: pp::printer, - cm: option<codemap>, + cm: Option<codemap>, intr: token::ident_interner, - comments: option<~[comments::cmnt]>, - literals: option<~[comments::lit]>, + comments: Option<~[comments::cmnt]>, + literals: Option<~[comments::lit]>, mut cur_cmnt: uint, mut cur_lit: uint, boxes: DVec<pp::breaks>, @@ -47,10 +47,10 @@ fn end(s: ps) { fn rust_printer(writer: io::Writer, intr: ident_interner) -> ps { return @{s: pp::mk_printer(writer, default_columns), - cm: none::<codemap>, + cm: None::<codemap>, intr: intr, - comments: none::<~[comments::cmnt]>, - literals: none::<~[comments::lit]>, + comments: None::<~[comments::cmnt]>, + literals: None::<~[comments::lit]>, mut cur_cmnt: 0u, mut cur_lit: 0u, boxes: dvec(), @@ -73,13 +73,13 @@ fn print_crate(cm: codemap, intr: ident_interner, filename, in); let s = @{s: pp::mk_printer(out, default_columns), - cm: some(cm), + cm: Some(cm), intr: intr, - comments: some(r.cmnts), + comments: Some(r.cmnts), // If the code is post expansion, don't use the table of // literals, since it doesn't correspond with the literals // in the AST anymore. - literals: if is_expanded { none } else { some(r.lits) }, + literals: if is_expanded { None } else { Some(r.lits) }, mut cur_cmnt: 0u, mut cur_lit: 0u, boxes: dvec(), @@ -129,7 +129,7 @@ fn fun_to_str(decl: ast::fn_decl, name: ast::ident, params: ~[ast::ty_param], intr: ident_interner) -> ~str { let buffer = io::mem_buffer(); let s = rust_printer(io::mem_buffer_writer(buffer), intr); - print_fn(s, decl, none, name, params, none); + print_fn(s, decl, None, name, params, None); end(s); // Close the head box end(s); // Close the outer box eof(s.s); @@ -302,7 +302,7 @@ fn commasep_cmnt<IN>(s: ps, b: breaks, elts: ~[IN], op: fn(ps, IN), if i < len { word(s.s, ~","); maybe_print_trailing_comment(s, get_span(elt), - some(get_span(elts[i]).hi)); + Some(get_span(elts[i]).hi)); space_if_not_bol(s); } } @@ -391,7 +391,7 @@ fn print_type_ex(s: ps, &&ty: @ast::ty, print_colons: bool) { pclose(s); } ast::ty_fn(proto, purity, bounds, d) => { - print_ty_fn(s, some(proto), purity, bounds, d, none, none, none); + print_ty_fn(s, Some(proto), purity, bounds, d, None, None, None); } ast::ty_path(path, _) => print_path(s, path, print_colons), ast::ty_fixed_length(t, v) => { @@ -416,7 +416,7 @@ fn print_foreign_item(s: ps, item: @ast::foreign_item) { print_outer_attributes(s, item.attrs); match item.node { ast::foreign_item_fn(decl, purity, typarams) => { - print_fn(s, decl, some(purity), item.ident, typarams, none); + print_fn(s, decl, Some(purity), item.ident, typarams, None); end(s); // end head-ibox word(s.s, ~";"); end(s); // end the outer fn box @@ -454,7 +454,7 @@ fn print_item(s: ps, &&item: @ast::item) { } ast::item_fn(decl, purity, typarams, body) => { - print_fn(s, decl, some(purity), item.ident, typarams, none); + print_fn(s, decl, Some(purity), item.ident, typarams, None); word(s.s, ~" "); print_block_with_attrs(s, body, item.attrs); } @@ -595,7 +595,7 @@ fn print_variants(s: ps, variants: ~[ast::variant], span: ast::span) { print_variant(s, v); word(s.s, ~","); end(s); - maybe_print_trailing_comment(s, v.span, none::<uint>); + maybe_print_trailing_comment(s, v.span, None::<uint>); } bclose(s, span); } @@ -619,7 +619,7 @@ fn print_struct(s: ps, struct_def: @ast::struct_def, tps: ~[ast::ty_param], cbox(s, indent_unit); ibox(s, 4); word(s.s, ~"new("); - print_fn_args(s, ctor.node.dec, ~[], none); + print_fn_args(s, ctor.node.dec, ~[], None); word(s.s, ~")"); space(s.s); print_block(s, ctor.node.body); @@ -681,8 +681,8 @@ fn print_tt(s: ps, tt: ast::token_tree) { for tts.each() |tt_elt| { print_tt(s, tt_elt); } word(s.s, ~")"); match sep { - some(tk) => word(s.s, parse::token::to_str(s.intr, tk)), - none => () + Some(tk) => word(s.s, parse::token::to_str(s.intr, tk)), + None => () } word(s.s, if zerok { ~"*" } else { ~"+" }); s.s.token_tree_last_was_ident = false; @@ -717,7 +717,7 @@ fn print_variant(s: ps, v: ast::variant) { } } match v.node.disr_expr { - some(d) => { + Some(d) => { space(s.s); word_space(s, ~"="); print_expr(s, d); @@ -730,9 +730,9 @@ fn print_ty_method(s: ps, m: ast::ty_method) { hardbreak_if_not_bol(s); maybe_print_comment(s, m.span.lo); print_outer_attributes(s, m.attrs); - print_ty_fn(s, none, m.purity, - @~[], m.decl, some(m.ident), some(m.tps), - some(m.self_ty.node)); + print_ty_fn(s, None, m.purity, + @~[], m.decl, Some(m.ident), Some(m.tps), + Some(m.self_ty.node)); word(s.s, ~";"); } @@ -747,8 +747,8 @@ fn print_method(s: ps, meth: @ast::method) { hardbreak_if_not_bol(s); maybe_print_comment(s, meth.span.lo); print_outer_attributes(s, meth.attrs); - print_fn(s, meth.decl, some(meth.purity), - meth.ident, meth.tps, some(meth.self_ty.node)); + print_fn(s, meth.decl, Some(meth.purity), + meth.ident, meth.tps, Some(meth.self_ty.node)); word(s.s, ~" "); print_block_with_attrs(s, meth.body, meth.attrs); } @@ -813,7 +813,7 @@ fn print_stmt(s: ps, st: ast::stmt) { } } if parse::classify::stmt_ends_with_semi(st) { word(s.s, ~";"); } - maybe_print_trailing_comment(s, st.span, none::<uint>); + maybe_print_trailing_comment(s, st.span, None::<uint>); } fn print_block(s: ps, blk: ast::blk) { @@ -866,10 +866,10 @@ fn print_possibly_embedded_block_(s: ps, blk: ast::blk, embedded: embed_type, print_stmt(s, *st); } match blk.node.expr { - some(expr) => { + Some(expr) => { space_if_not_bol(s); print_expr(s, expr); - maybe_print_trailing_comment(s, expr.span, some(blk.span.hi)); + maybe_print_trailing_comment(s, expr.span, Some(blk.span.hi)); } _ => () } @@ -881,7 +881,7 @@ fn print_possibly_embedded_block_(s: ps, blk: ast::blk, embedded: embed_type, // alt, do, & while unambiguously without being parenthesized fn print_maybe_parens_discrim(s: ps, e: @ast::expr) { let disambig = match e.node { - ast::expr_ret(none) | ast::expr_fail(none) => true, + ast::expr_ret(None) | ast::expr_fail(None) => true, _ => false }; if disambig { popen(s); } @@ -890,15 +890,15 @@ fn print_maybe_parens_discrim(s: ps, e: @ast::expr) { } fn print_if(s: ps, test: @ast::expr, blk: ast::blk, - elseopt: option<@ast::expr>, chk: bool) { + elseopt: Option<@ast::expr>, chk: bool) { head(s, ~"if"); if chk { word_nbsp(s, ~"check"); } print_maybe_parens_discrim(s, test); space(s.s); print_block(s, blk); - fn do_else(s: ps, els: option<@ast::expr>) { + fn do_else(s: ps, els: Option<@ast::expr>) { match els { - some(_else) => { + Some(_else) => { match _else.node { // "another else-if" ast::expr_if(i, t, e) => { @@ -935,7 +935,7 @@ fn print_mac(s: ps, m: ast::mac) { word(s.s, ~"#"); print_path(s, path, false); match arg { - some(@{node: ast::expr_vec(_, _), _}) => (), + Some(@{node: ast::expr_vec(_, _), _}) => (), _ => word(s.s, ~" ") } option::iter(arg, |a| print_expr(s, a)); @@ -956,8 +956,8 @@ fn print_mac(s: ps, m: ast::mac) { fn print_vstore(s: ps, t: ast::vstore) { match t { - ast::vstore_fixed(some(i)) => word(s.s, fmt!("%u", i)), - ast::vstore_fixed(none) => word(s.s, ~"_"), + ast::vstore_fixed(Some(i)) => word(s.s, fmt!("%u", i)), + ast::vstore_fixed(None) => word(s.s, ~"_"), ast::vstore_uniq => word(s.s, ~"~"), ast::vstore_box => word(s.s, ~"@"), ast::vstore_slice(r) => match r.node { @@ -1029,7 +1029,7 @@ fn print_expr(s: ps, &&expr: @ast::expr) { word(s.s, ~"{"); commasep_cmnt(s, consistent, fields, print_field, get_span); match wth { - some(expr) => { + Some(expr) => { ibox(s, indent_unit); word(s.s, ~","); space(s.s); @@ -1046,7 +1046,7 @@ fn print_expr(s: ps, &&expr: @ast::expr) { word(s.s, ~"{"); commasep_cmnt(s, consistent, fields, print_field, get_span); match wth { - some(expr) => { + Some(expr) => { if vec::len(fields) > 0u { space(s.s); } ibox(s, indent_unit); word(s.s, ~","); @@ -1073,8 +1073,8 @@ fn print_expr(s: ps, &&expr: @ast::expr) { ast::expr_do_body(_) => { head(s, ~"do"); } _ => {} } - some(blk_arg) - } else { none }; + Some(blk_arg) + } else { None }; print_expr_parens_if_not_bot(s, func); if !has_block || vec::len(base_args) > 0u { popen(s); @@ -1157,12 +1157,12 @@ fn print_expr(s: ps, &&expr: @ast::expr) { } space(s.s); match arm.guard { - some(e) => { + Some(e) => { word_space(s, ~"if"); print_expr(s, e); space(s.s); } - none => () + None => () } word_space(s, ~"=>"); // Extract the expression from the extra block the parser adds @@ -1170,7 +1170,7 @@ fn print_expr(s: ps, &&expr: @ast::expr) { assert arm.body.node.stmts.is_empty(); assert arm.body.node.rules == ast::default_blk; match arm.body.node.expr { - some(expr) => { + Some(expr) => { match expr.node { ast::expr_block(blk) => { // the block will close the pattern's ibox @@ -1187,7 +1187,7 @@ fn print_expr(s: ps, &&expr: @ast::expr) { } end(s); // close enclosing cbox } - none => fail + None => fail } } bclose_(s, expr.span, alt_indent_unit); @@ -1197,8 +1197,8 @@ fn print_expr(s: ps, &&expr: @ast::expr) { cbox(s, indent_unit); // head-box, will be closed by print-block at start ibox(s, 0u); - word(s.s, fn_header_info_to_str(none, none, some(proto))); - print_fn_args_and_ret(s, decl, *cap_clause, none); + word(s.s, fn_header_info_to_str(None, None, Some(proto))); + print_fn_args_and_ret(s, decl, *cap_clause, None); space(s.s); print_block(s, body); } @@ -1299,7 +1299,7 @@ fn print_expr(s: ps, &&expr: @ast::expr) { ast::expr_fail(maybe_fail_val) => { word(s.s, ~"fail"); match maybe_fail_val { - some(expr) => { word(s.s, ~" "); print_expr(s, expr); } + Some(expr) => { word(s.s, ~" "); print_expr(s, expr); } _ => () } } @@ -1316,7 +1316,7 @@ fn print_expr(s: ps, &&expr: @ast::expr) { ast::expr_ret(result) => { word(s.s, ~"return"); match result { - some(expr) => { word(s.s, ~" "); print_expr(s, expr); } + Some(expr) => { word(s.s, ~" "); print_expr(s, expr); } _ => () } } @@ -1389,7 +1389,7 @@ fn print_decl(s: ps, decl: @ast::decl) { print_local_decl(s, loc); end(s); match loc.node.init { - some(init) => { + Some(init) => { nbsp(s); match init.op { ast::init_assign => word_space(s, ~"="), @@ -1428,8 +1428,8 @@ fn print_path(s: ps, &&path: @ast::path, colons_before_params: bool) { if colons_before_params { word(s.s, ~"::"); } match path.rp { - none => { /* ok */ } - some(r) => { + None => { /* ok */ } + Some(r) => { word(s.s, ~"/"); print_region(s, r); } @@ -1465,15 +1465,15 @@ fn print_pat(s: ps, &&pat: @ast::pat) { } print_path(s, path, true); match sub { - some(p) => { word(s.s, ~"@"); print_pat(s, p); } - none => () + Some(p) => { word(s.s, ~"@"); print_pat(s, p); } + None => () } } ast::pat_enum(path, args_) => { print_path(s, path, true); match args_ { - none => word(s.s, ~"(*)"), - some(args) => { + None => word(s.s, ~"(*)"), + Some(args) => { if vec::len(args) > 0u { popen(s); commasep(s, inconsistent, args, print_pat); @@ -1553,11 +1553,11 @@ fn print_self_ty(s: ps, self_ty: ast::self_ty_) -> bool { return true; } -fn print_fn(s: ps, decl: ast::fn_decl, purity: option<ast::purity>, +fn print_fn(s: ps, decl: ast::fn_decl, purity: Option<ast::purity>, name: ast::ident, typarams: ~[ast::ty_param], - opt_self_ty: option<ast::self_ty_>) { - head(s, fn_header_info_to_str(opt_self_ty, purity, none)); + opt_self_ty: Option<ast::self_ty_>) { + head(s, fn_header_info_to_str(opt_self_ty, purity, None)); print_ident(s, name); print_type_params(s, typarams); print_fn_args_and_ret(s, decl, ~[], opt_self_ty); @@ -1565,7 +1565,7 @@ fn print_fn(s: ps, decl: ast::fn_decl, purity: option<ast::purity>, fn print_fn_args(s: ps, decl: ast::fn_decl, cap_items: ~[ast::capture_item], - opt_self_ty: option<ast::self_ty_>) { + opt_self_ty: Option<ast::self_ty_>) { // It is unfortunate to duplicate the commasep logic, but we // we want the self type, the args, and the capture clauses all // in the same box. @@ -1592,7 +1592,7 @@ fn print_fn_args(s: ps, decl: ast::fn_decl, fn print_fn_args_and_ret(s: ps, decl: ast::fn_decl, cap_items: ~[ast::capture_item], - opt_self_ty: option<ast::self_ty_>) { + opt_self_ty: Option<ast::self_ty_>) { popen(s); print_fn_args(s, decl, cap_items, opt_self_ty); pclose(s); @@ -1608,7 +1608,7 @@ fn print_fn_args_and_ret(s: ps, decl: ast::fn_decl, fn print_fn_block_args(s: ps, decl: ast::fn_decl, cap_items: ~[ast::capture_item]) { word(s.s, ~"|"); - print_fn_args(s, decl, cap_items, none); + print_fn_args(s, decl, cap_items, None); word(s.s, ~"|"); if decl.output.node != ast::ty_infer { space_if_not_bol(s); @@ -1779,16 +1779,16 @@ fn print_arg(s: ps, input: ast::arg) { end(s); } -fn print_ty_fn(s: ps, opt_proto: option<ast::proto>, purity: ast::purity, +fn print_ty_fn(s: ps, opt_proto: Option<ast::proto>, purity: ast::purity, bounds: @~[ast::ty_param_bound], - decl: ast::fn_decl, id: option<ast::ident>, - tps: option<~[ast::ty_param]>, - opt_self_ty: option<ast::self_ty_>) { + decl: ast::fn_decl, id: Option<ast::ident>, + tps: Option<~[ast::ty_param]>, + opt_self_ty: Option<ast::self_ty_>) { ibox(s, indent_unit); - word(s.s, fn_header_info_to_str(opt_self_ty, some(purity), opt_proto)); + word(s.s, fn_header_info_to_str(opt_self_ty, Some(purity), opt_proto)); print_bounds(s, bounds); - match id { some(id) => { word(s.s, ~" "); print_ident(s, id); } _ => () } - match tps { some(tps) => print_type_params(s, tps), _ => () } + match id { Some(id) => { word(s.s, ~" "); print_ident(s, id); } _ => () } + match tps { Some(tps) => print_type_params(s, tps), _ => () } zerobreak(s.s); popen(s); @@ -1820,16 +1820,16 @@ fn print_ty_fn(s: ps, opt_proto: option<ast::proto>, purity: ast::purity, } fn maybe_print_trailing_comment(s: ps, span: codemap::span, - next_pos: option<uint>) { + next_pos: Option<uint>) { let mut cm; - match s.cm { some(ccm) => cm = ccm, _ => return } + match s.cm { Some(ccm) => cm = ccm, _ => return } match next_comment(s) { - some(cmnt) => { + Some(cmnt) => { if cmnt.style != comments::trailing { return; } let span_line = codemap::lookup_char_pos(cm, span.hi); let comment_line = codemap::lookup_char_pos(cm, cmnt.pos); let mut next = cmnt.pos + 1u; - match next_pos { none => (), some(p) => next = p } + match next_pos { None => (), Some(p) => next = p } if span.hi < cmnt.pos && cmnt.pos < next && span_line.line == comment_line.line { print_comment(s, cmnt); @@ -1846,7 +1846,7 @@ fn print_remaining_comments(s: ps) { if option::is_none(next_comment(s)) { hardbreak(s.s); } loop { match next_comment(s) { - some(cmnt) => { print_comment(s, cmnt); s.cur_cmnt += 1u; } + Some(cmnt) => { print_comment(s, cmnt); s.cur_cmnt += 1u; } _ => break } } @@ -1855,7 +1855,7 @@ fn print_remaining_comments(s: ps) { fn print_literal(s: ps, &&lit: @ast::lit) { maybe_print_comment(s, lit.span.lo); match next_lit(s, lit.span.lo) { - some(ltrl) => { + Some(ltrl) => { word(s.s, ltrl.lit); return; } @@ -1903,25 +1903,25 @@ fn lit_to_str(l: @ast::lit) -> ~str { return to_str(l, print_literal, parse::token::mk_fake_ident_interner()); } -fn next_lit(s: ps, pos: uint) -> option<comments::lit> { +fn next_lit(s: ps, pos: uint) -> Option<comments::lit> { match s.literals { - some(lits) => { + Some(lits) => { while s.cur_lit < vec::len(lits) { let ltrl = lits[s.cur_lit]; - if ltrl.pos > pos { return none; } + if ltrl.pos > pos { return None; } s.cur_lit += 1u; - if ltrl.pos == pos { return some(ltrl); } + if ltrl.pos == pos { return Some(ltrl); } } - return none; + return None; } - _ => return none + _ => return None } } fn maybe_print_comment(s: ps, pos: uint) { loop { match next_comment(s) { - some(cmnt) => { + Some(cmnt) => { if cmnt.pos < pos { print_comment(s, cmnt); s.cur_cmnt += 1u; @@ -1990,32 +1990,32 @@ fn to_str<T>(t: T, f: fn@(ps, T), intr: ident_interner) -> ~str { io::mem_buffer_str(buffer) } -fn next_comment(s: ps) -> option<comments::cmnt> { +fn next_comment(s: ps) -> Option<comments::cmnt> { match s.comments { - some(cmnts) => { + Some(cmnts) => { if s.cur_cmnt < vec::len(cmnts) { - return some(cmnts[s.cur_cmnt]); - } else { return none::<comments::cmnt>; } + return Some(cmnts[s.cur_cmnt]); + } else { return None::<comments::cmnt>; } } - _ => return none::<comments::cmnt> + _ => return None::<comments::cmnt> } } -fn fn_header_info_to_str(opt_sty: option<ast::self_ty_>, - opt_purity: option<ast::purity>, - opt_p: option<ast::proto>) -> ~str { +fn fn_header_info_to_str(opt_sty: Option<ast::self_ty_>, + opt_purity: Option<ast::purity>, + opt_p: Option<ast::proto>) -> ~str { let mut s = match opt_sty { - some(ast::sty_static) => ~"static ", + Some(ast::sty_static) => ~"static ", _ => ~ "" }; match opt_purity { - some(ast::impure_fn) => { } - some(purity) => { + Some(ast::impure_fn) => { } + Some(purity) => { str::push_str(s, purity_to_str(purity)); str::push_char(s, ' '); } - none => {} + None => {} } str::push_str(s, opt_proto_to_str(opt_p)); @@ -2023,10 +2023,10 @@ fn fn_header_info_to_str(opt_sty: option<ast::self_ty_>, return s; } -fn opt_proto_to_str(opt_p: option<ast::proto>) -> ~str { +fn opt_proto_to_str(opt_p: Option<ast::proto>) -> ~str { match opt_p { - none => ~"fn", - some(p) => proto_to_str(p) + None => ~"fn", + Some(p) => proto_to_str(p) } } diff --git a/src/libsyntax/util/interner.rs b/src/libsyntax/util/interner.rs index 5cecd315ac4..9f738fdc6a2 100644 --- a/src/libsyntax/util/interner.rs +++ b/src/libsyntax/util/interner.rs @@ -38,8 +38,8 @@ trait interner<T: const copy> { impl <T: const copy> hash_interner<T>: interner<T> { fn intern(val: T) -> uint { match self.map.find(val) { - some(idx) => return idx, - none => { + Some(idx) => return idx, + None => { let new_idx = self.vect.len(); self.map.insert(val, new_idx); self.vect.push(val); diff --git a/src/libsyntax/visit.rs b/src/libsyntax/visit.rs index 4195ecf32ce..d1886908173 100644 --- a/src/libsyntax/visit.rs +++ b/src/libsyntax/visit.rs @@ -116,8 +116,8 @@ fn visit_local<E>(loc: @local, e: E, v: vt<E>) { v.visit_pat(loc.node.pat, e, v); v.visit_ty(loc.node.ty, e, v); match loc.node.init { - none => (), - some(i) => v.visit_expr(i.expr, e, v) + None => (), + Some(i) => v.visit_expr(i.expr, e, v) } } @@ -377,8 +377,8 @@ fn visit_decl<E>(d: @decl, e: E, v: vt<E>) { } } -fn visit_expr_opt<E>(eo: option<@expr>, e: E, v: vt<E>) { - match eo { none => (), some(ex) => v.visit_expr(ex, e, v) } +fn visit_expr_opt<E>(eo: Option<@expr>, e: E, v: vt<E>) { + match eo { None => (), Some(ex) => v.visit_expr(ex, e, v) } } fn visit_exprs<E>(exprs: ~[@expr], e: E, v: vt<E>) { |
