about summary refs log tree commit diff
path: root/src/libsyntax
diff options
context:
space:
mode:
authorBrian Anderson <banderson@mozilla.com>2012-09-21 19:37:57 -0700
committerBrian Anderson <banderson@mozilla.com>2012-09-23 17:15:00 -0700
commit4a78f9b16620489855da93c19be56f59431416f6 (patch)
tree4b164738698203f474003682d5f0a5e23aa13377 /src/libsyntax
parent92752a462a055d6478bd96dab37a740514992106 (diff)
downloadrust-4a78f9b16620489855da93c19be56f59431416f6.tar.gz
rust-4a78f9b16620489855da93c19be56f59431416f6.zip
core: Demode option
Diffstat (limited to 'src/libsyntax')
-rw-r--r--src/libsyntax/diagnostic.rs4
-rw-r--r--src/libsyntax/ext/qquote.rs4
-rw-r--r--src/libsyntax/ext/simplext.rs2
-rw-r--r--src/libsyntax/fold.rs34
-rw-r--r--src/libsyntax/parse.rs2
-rw-r--r--src/libsyntax/parse/lexer.rs4
-rw-r--r--src/libsyntax/parse/parser.rs4
-rw-r--r--src/libsyntax/print/pprust.rs14
-rw-r--r--src/libsyntax/visit.rs10
9 files changed, 39 insertions, 39 deletions
diff --git a/src/libsyntax/diagnostic.rs b/src/libsyntax/diagnostic.rs
index 5b72bf61fde..abeddbdd69a 100644
--- a/src/libsyntax/diagnostic.rs
+++ b/src/libsyntax/diagnostic.rs
@@ -269,8 +269,8 @@ fn highlight_lines(cm: codemap::codemap, sp: span,
 }
 
 fn print_macro_backtrace(cm: codemap::codemap, sp: span) {
-    do option::iter (sp.expn_info) |ei| {
-        let ss = option::map_default(ei.callie.span, @~"",
+    do option::iter(&sp.expn_info) |ei| {
+        let ss = option::map_default(&ei.callie.span, @~"",
                                      |span| @codemap::span_to_str(span, cm));
         print_diagnostic(*ss, note,
                          fmt!("in expansion of #%s", ei.callie.name));
diff --git a/src/libsyntax/ext/qquote.rs b/src/libsyntax/ext/qquote.rs
index 115a640bda8..ee9602598d1 100644
--- a/src/libsyntax/ext/qquote.rs
+++ b/src/libsyntax/ext/qquote.rs
@@ -155,7 +155,7 @@ fn expand_ast(ecx: ext_ctxt, _sp: span,
     -> @ast::expr
 {
     let mut what = ~"expr";
-    do option::iter(arg) |arg| {
+    do arg.iter |arg| {
         let args: ~[@ast::expr] =
             match arg.node {
               ast::expr_vec(elts, _) => elts,
@@ -311,7 +311,7 @@ fn fold_crate(f: ast_fold, &&n: @ast::crate) -> @ast::crate {
 fn fold_expr(f: ast_fold, &&n: @ast::expr) -> @ast::expr {f.fold_expr(n)}
 fn fold_ty(f: ast_fold, &&n: @ast::ty) -> @ast::ty {f.fold_ty(n)}
 fn fold_item(f: ast_fold, &&n: @ast::item) -> @ast::item {
-    option::get(f.fold_item(n)) //HACK: we know we don't drop items
+    f.fold_item(n).get() //HACK: we know we don't drop items
 }
 fn fold_stmt(f: ast_fold, &&n: @ast::stmt) -> @ast::stmt {f.fold_stmt(n)}
 fn fold_pat(f: ast_fold, &&n: @ast::pat) -> @ast::pat {f.fold_pat(n)}
diff --git a/src/libsyntax/ext/simplext.rs b/src/libsyntax/ext/simplext.rs
index 8df57144c07..3af9cfe852d 100644
--- a/src/libsyntax/ext/simplext.rs
+++ b/src/libsyntax/ext/simplext.rs
@@ -707,7 +707,7 @@ fn add_new_extension(cx: ext_ctxt, sp: span, arg: ast::mac_arg,
                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(arg.get().span)})};
 
     fn generic_extension(cx: ext_ctxt, sp: span, arg: ast::mac_arg,
                          _body: ast::mac_body,
diff --git a/src/libsyntax/fold.rs b/src/libsyntax/fold.rs
index 07362e1b31e..918b6b28459 100644
--- a/src/libsyntax/fold.rs
+++ b/src/libsyntax/fold.rs
@@ -114,7 +114,7 @@ fn fold_mac_(m: mac, fld: ast_fold) -> mac {
              match m.node {
                mac_invoc(pth, arg, body) => {
                  mac_invoc(fld.fold_path(pth),
-                           option::map(arg, |x| fld.fold_expr(x)), body)
+                           option::map(&arg, |x| fld.fold_expr(x)), body)
                }
                mac_invoc_tt(*) => m.node,
                mac_ellipsis => mac_ellipsis,
@@ -241,7 +241,7 @@ fn noop_fold_item_underscore(i: item_, fld: ast_fold) -> item_ {
             item_enum(ast::enum_def({
                 variants: vec::map(enum_definition.variants,
                                    |x| fld.fold_variant(*x)),
-                common: option::map(enum_definition.common,
+                common: option::map(&enum_definition.common,
                                     |x| fold_struct_def(x, fld))
             }), fold_ty_params(typms, fld))
           }
@@ -286,7 +286,7 @@ fn fold_struct_def(struct_def: @ast::struct_def, fld: ast_fold)
             });
         }
     }
-    let dtor = do option::map(struct_def.dtor) |dtor| {
+    let dtor = do option::map(&struct_def.dtor) |dtor| {
         let dtor_body = fld.fold_block(dtor.node.body);
         let dtor_id   = fld.new_id(dtor.node.id);
         {node: {body: dtor_body,
@@ -331,7 +331,7 @@ fn noop_fold_method(&&m: @method, fld: ast_fold) -> @method {
 fn noop_fold_block(b: blk_, fld: ast_fold) -> blk_ {
     return {view_items: vec::map(b.view_items, |x| fld.fold_view_item(*x)),
          stmts: vec::map(b.stmts, |x| fld.fold_stmt(*x)),
-         expr: option::map(b.expr, |x| fld.fold_expr(x)),
+         expr: option::map(&b.expr, |x| fld.fold_expr(x)),
          id: fld.new_id(b.id),
          rules: b.rules};
 }
@@ -346,7 +346,7 @@ fn noop_fold_stmt(s: stmt_, fld: ast_fold) -> stmt_ {
 
 fn noop_fold_arm(a: arm, fld: ast_fold) -> arm {
     return {pats: vec::map(a.pats, |x| fld.fold_pat(*x)),
-         guard: option::map(a.guard, |x| fld.fold_expr(x)),
+         guard: option::map(&a.guard, |x| fld.fold_expr(x)),
          body: fld.fold_block(a.body)};
 }
 
@@ -356,11 +356,11 @@ fn noop_fold_pat(p: pat_, fld: ast_fold) -> pat_ {
           pat_ident(binding_mode, pth, sub) => {
             pat_ident(binding_mode,
                       fld.fold_path(pth),
-                      option::map(sub, |x| fld.fold_pat(x)))
+                      option::map(&sub, |x| fld.fold_pat(x)))
           }
           pat_lit(e) => pat_lit(fld.fold_expr(e)),
           pat_enum(pth, pats) => {
-              pat_enum(fld.fold_path(pth), option::map(pats,
+              pat_enum(fld.fold_path(pth), option::map(&pats,
                        |pats| vec::map(pats, |x| fld.fold_pat(*x))))
           }
           pat_rec(fields, etc) => {
@@ -433,7 +433,7 @@ fn noop_fold_expr(e: expr_, fld: ast_fold) -> expr_ {
             expr_repeat(fld.fold_expr(expr), fld.fold_expr(count), mutt),
           expr_rec(fields, maybe_expr) => {
             expr_rec(vec::map(fields, |x| fold_field(*x)),
-                     option::map(maybe_expr, |x| fld.fold_expr(x)))
+                     option::map(&maybe_expr, |x| fld.fold_expr(x)))
           }
           expr_tup(elts) => expr_tup(vec::map(elts, |x| fld.fold_expr(*x))),
           expr_call(f, args, blk) => {
@@ -452,14 +452,14 @@ fn noop_fold_expr(e: expr_, fld: ast_fold) -> expr_ {
           expr_addr_of(m, ohs) => expr_addr_of(m, fld.fold_expr(ohs)),
           expr_if(cond, tr, fl) => {
             expr_if(fld.fold_expr(cond), fld.fold_block(tr),
-                    option::map(fl, |x| fld.fold_expr(x)))
+                    option::map(&fl, |x| fld.fold_expr(x)))
           }
           expr_while(cond, body) => {
             expr_while(fld.fold_expr(cond), fld.fold_block(body))
           }
           expr_loop(body, opt_ident) => {
               expr_loop(fld.fold_block(body),
-                        option::map(opt_ident, |x| fld.fold_ident(x)))
+                        option::map(&opt_ident, |x| fld.fold_ident(x)))
           }
           expr_match(expr, arms) => {
             expr_match(fld.fold_expr(expr),
@@ -501,12 +501,12 @@ fn noop_fold_expr(e: expr_, fld: ast_fold) -> expr_ {
             expr_index(fld.fold_expr(el), fld.fold_expr(er))
           }
           expr_path(pth) => expr_path(fld.fold_path(pth)),
-          expr_fail(e) => expr_fail(option::map(e, |x| fld.fold_expr(x))),
+          expr_fail(e) => expr_fail(option::map(&e, |x| fld.fold_expr(x))),
           expr_break(opt_ident) =>
-            expr_break(option::map(opt_ident, |x| fld.fold_ident(x))),
+            expr_break(option::map(&opt_ident, |x| fld.fold_ident(x))),
           expr_again(opt_ident) =>
-            expr_again(option::map(opt_ident, |x| fld.fold_ident(x))),
-          expr_ret(e) => expr_ret(option::map(e, |x| fld.fold_expr(x))),
+            expr_again(option::map(&opt_ident, |x| fld.fold_ident(x))),
+          expr_ret(e) => expr_ret(option::map(&e, |x| fld.fold_expr(x))),
           expr_log(i, lv, e) => expr_log(i, fld.fold_expr(lv),
                                          fld.fold_expr(e)),
           expr_assert(e) => expr_assert(fld.fold_expr(e)),
@@ -514,7 +514,7 @@ fn noop_fold_expr(e: expr_, fld: ast_fold) -> expr_ {
           expr_struct(path, fields, maybe_expr) => {
             expr_struct(fld.fold_path(path),
                         vec::map(fields, |x| fold_field(*x)),
-                        option::map(maybe_expr, |x| fld.fold_expr(x)))
+                        option::map(&maybe_expr, |x| fld.fold_expr(x)))
           }
         }
 }
@@ -573,7 +573,7 @@ fn noop_fold_variant(v: variant_, fld: ast_fold) -> variant_ {
             kind = tuple_variant_kind(vec::map(variant_args,
                                                |x| fold_variant_arg(*x))),
         struct_variant_kind(struct_def) => {
-            let dtor = do option::map(struct_def.dtor) |dtor| {
+            let dtor = do option::map(&struct_def.dtor) |dtor| {
                 let dtor_body = fld.fold_block(dtor.node.body);
                 let dtor_id   = fld.new_id(dtor.node.id);
                 {node: {body: dtor_body,
@@ -593,7 +593,7 @@ fn noop_fold_variant(v: variant_, fld: ast_fold) -> variant_ {
         enum_variant_kind(enum_definition) => {
             let variants = vec::map(enum_definition.variants,
                                     |x| fld.fold_variant(*x));
-            let common = option::map(enum_definition.common,
+            let common = option::map(&enum_definition.common,
                                      |x| fold_struct_def(x, fld));
             kind = enum_variant_kind(ast::enum_def({ variants: variants,
                                                      common: common }));
diff --git a/src/libsyntax/parse.rs b/src/libsyntax/parse.rs
index 9b9d7addee2..312c78085ac 100644
--- a/src/libsyntax/parse.rs
+++ b/src/libsyntax/parse.rs
@@ -73,7 +73,7 @@ fn parse_crate_from_crate_file(input: &Path, cfg: ast::crate_cfg,
     sess.chpos = rdr.chpos;
     sess.byte_pos = sess.byte_pos + rdr.pos;
     let cx = @{sess: sess, cfg: /* FIXME (#2543) */ copy p.cfg};
-    let companionmod = option::map(input.filestem(), |s| Path(s));
+    let companionmod = input.filestem().map(|s| Path(s));
     let (m, attrs) = eval::eval_crate_directives_to_mod(
         cx, cdirs, &prefix, &companionmod);
     let mut hi = p.span.hi;
diff --git a/src/libsyntax/parse/lexer.rs b/src/libsyntax/parse/lexer.rs
index c32aaa3d474..c9b10c7b754 100644
--- a/src/libsyntax/parse/lexer.rs
+++ b/src/libsyntax/parse/lexer.rs
@@ -364,7 +364,7 @@ fn scan_number(c: char, rdr: string_reader) -> token::token {
         if str::len(num_str) == 0u {
             rdr.fatal(~"no valid digits found for number");
         }
-        let parsed = option::get(u64::from_str_radix(num_str, base as u64));
+        let parsed = u64::from_str_radix(num_str, base as u64).get();
         match tp {
           either::Left(t) => return token::LIT_INT(parsed as i64, t),
           either::Right(t) => return token::LIT_UINT(parsed, t)
@@ -412,7 +412,7 @@ fn scan_number(c: char, rdr: string_reader) -> token::token {
         if str::len(num_str) == 0u {
             rdr.fatal(~"no valid digits found for number");
         }
-        let parsed = option::get(u64::from_str_radix(num_str, base as u64));
+        let parsed = u64::from_str_radix(num_str, base as u64).get();
 
         debug!("lexing %s as an unsuffixed integer literal",
                num_str);
diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs
index f2e7245a1d4..490808edaad 100644
--- a/src/libsyntax/parse/parser.rs
+++ b/src/libsyntax/parse/parser.rs
@@ -2743,7 +2743,7 @@ impl parser {
                             token_to_str(self.reader, self.token)));
         }
 
-        let actual_dtor = do option::map(the_dtor) |dtor| {
+        let actual_dtor = do the_dtor.map |dtor| {
             let (d_body, d_attrs, d_s) = dtor;
             {node: {id: self.get_id(),
                     attrs: d_attrs,
@@ -3111,7 +3111,7 @@ impl parser {
             }
         }
         self.bump();
-        let mut actual_dtor = do option::map(the_dtor) |dtor| {
+        let mut actual_dtor = do the_dtor.map |dtor| {
             let (d_body, d_attrs, d_s) = dtor;
             {node: {id: self.get_id(),
                     attrs: d_attrs,
diff --git a/src/libsyntax/print/pprust.rs b/src/libsyntax/print/pprust.rs
index 7ec3cb23b7b..3630ba8c5c6 100644
--- a/src/libsyntax/print/pprust.rs
+++ b/src/libsyntax/print/pprust.rs
@@ -652,7 +652,7 @@ fn print_struct(s: ps, struct_def: @ast::struct_def, tps: ~[ast::ty_param],
     }
     bopen(s);
     hardbreak_if_not_bol(s);
-    do option::iter(struct_def.ctor) |ctor| {
+    do struct_def.ctor.iter |ctor| {
       maybe_print_comment(s, ctor.span.lo);
       print_outer_attributes(s, ctor.node.attrs);
       // Doesn't call head because there shouldn't be a space after new.
@@ -664,7 +664,7 @@ fn print_struct(s: ps, struct_def: @ast::struct_def, tps: ~[ast::ty_param],
       space(s.s);
       print_block(s, ctor.node.body);
     }
-    do option::iter(struct_def.dtor) |dtor| {
+    do struct_def.dtor.iter |dtor| {
       hardbreak_if_not_bol(s);
       maybe_print_comment(s, dtor.span.lo);
       print_outer_attributes(s, dtor.node.attrs);
@@ -979,7 +979,7 @@ fn print_mac(s: ps, m: ast::mac) {
           Some(@{node: ast::expr_vec(_, _), _}) => (),
           _ => word(s.s, ~" ")
         }
-        option::iter(arg, |a| print_expr(s, a));
+        arg.iter(|a| print_expr(s, a));
         // FIXME: extension 'body' (#2339)
       }
       ast::mac_invoc_tt(pth, tts) => {
@@ -1177,7 +1177,7 @@ fn print_expr(s: ps, &&expr: @ast::expr) {
       ast::expr_loop(blk, opt_ident) => {
         head(s, ~"loop");
         space(s.s);
-        option::iter(opt_ident, |ident| {print_ident(s, ident); space(s.s)});
+        opt_ident.iter(|ident| {print_ident(s, ident); space(s.s)});
         print_block(s, blk);
       }
       ast::expr_match(expr, arms) => {
@@ -1360,12 +1360,12 @@ fn print_expr(s: ps, &&expr: @ast::expr) {
       ast::expr_break(opt_ident) => {
         word(s.s, ~"break");
         space(s.s);
-        option::iter(opt_ident, |ident| {print_ident(s, ident); space(s.s)});
+        opt_ident.iter(|ident| {print_ident(s, ident); space(s.s)});
       }
       ast::expr_again(opt_ident) => {
         word(s.s, ~"loop");
         space(s.s);
-        option::iter(opt_ident, |ident| {print_ident(s, ident); space(s.s)});
+        opt_ident.iter(|ident| {print_ident(s, ident); space(s.s)});
       }
       ast::expr_ret(result) => {
         word(s.s, ~"return");
@@ -1920,7 +1920,7 @@ fn maybe_print_trailing_comment(s: ps, span: codemap::span,
 fn print_remaining_comments(s: ps) {
     // If there aren't any remaining comments, then we need to manually
     // make sure there is a line break at the end.
-    if option::is_none(next_comment(s)) { hardbreak(s.s); }
+    if next_comment(s).is_none() { hardbreak(s.s); }
     loop {
         match next_comment(s) {
           Some(cmnt) => { print_comment(s, cmnt); s.cur_cmnt += 1u; }
diff --git a/src/libsyntax/visit.rs b/src/libsyntax/visit.rs
index 4392ed55219..efcb5b2bda0 100644
--- a/src/libsyntax/visit.rs
+++ b/src/libsyntax/visit.rs
@@ -222,7 +222,7 @@ fn visit_pat<E>(p: @pat, e: E, v: vt<E>) {
     match p.node {
       pat_enum(path, children) => {
         visit_path(path, e, v);
-        do option::iter(children) |children| {
+        do option::iter(&children) |children| {
             for children.each |child| { v.visit_pat(*child, e, v); }}
       }
       pat_rec(fields, _) => for fields.each |f| {
@@ -241,7 +241,7 @@ fn visit_pat<E>(p: @pat, e: E, v: vt<E>) {
           v.visit_pat(inner, e, v),
       pat_ident(_, path, inner) => {
           visit_path(path, e, v);
-          do option::iter(inner) |subpat| { v.visit_pat(subpat, e, v)};
+          do option::iter(&inner) |subpat| { v.visit_pat(subpat, e, v)};
       }
       pat_lit(ex) => v.visit_expr(ex, e, v),
       pat_range(e1, e2) => { v.visit_expr(e1, e, v); v.visit_expr(e2, e, v); }
@@ -341,10 +341,10 @@ fn visit_struct_def<E>(sd: @struct_def, nm: ast::ident, tps: ~[ty_param],
     for sd.traits.each |p| {
         visit_path(p.path, e, v);
     }
-    do option::iter(sd.ctor) |ctor| {
+    do option::iter(&sd.ctor) |ctor| {
       visit_class_ctor_helper(ctor, nm, tps, ast_util::local_def(id), e, v);
     };
-    do option::iter(sd.dtor) |dtor| {
+    do option::iter(&sd.dtor) |dtor| {
       visit_class_dtor_helper(dtor, tps, ast_util::local_def(id), e, v)
     };
 }
@@ -395,7 +395,7 @@ fn visit_exprs<E>(exprs: ~[@expr], e: E, v: vt<E>) {
 fn visit_mac<E>(m: mac, e: E, v: vt<E>) {
     match m.node {
       ast::mac_invoc(_, arg, _) => {
-        option::map(arg, |arg| v.visit_expr(arg, e, v)); }
+        option::map(&arg, |arg| v.visit_expr(arg, e, v)); }
       ast::mac_invoc_tt(*) => { /* no user-serviceable parts inside */ }
       ast::mac_ellipsis => (),
       ast::mac_aq(*) => { /* FIXME: maybe visit (Issue #2340) */ }