Permalink
Browse files

core: Demode option

  • Loading branch information...
1 parent 92752a4 commit 4a78f9b16620489855da93c19be56f59431416f6 @brson brson committed Sep 22, 2012
Showing with 325 additions and 313 deletions.
  1. +4 −4 src/cargo/cargo.rs
  2. +2 −2 src/compiletest/compiletest.rs
  3. +4 −4 src/compiletest/header.rs
  4. +2 −2 src/compiletest/procsrv.rs
  5. +3 −3 src/compiletest/runtest.rs
  6. +1 −1 src/fuzzer/fuzzer.rs
  7. +26 −18 src/libcore/dlist.rs
  8. +1 −1 src/libcore/gc.rs
  9. +2 −2 src/libcore/iter-trait/dlist.rs
  10. +31 −27 src/libcore/option.rs
  11. +8 −8 src/libcore/os.rs
  12. +2 −2 src/libcore/str.rs
  13. +2 −2 src/libcore/vec.rs
  14. +7 −7 src/libstd/getopts.rs
  15. +2 −2 src/libstd/map.rs
  16. +7 −7 src/libstd/net_url.rs
  17. +1 −1 src/libstd/smallintmap.rs
  18. +4 −4 src/libstd/test.rs
  19. +2 −2 src/libsyntax/diagnostic.rs
  20. +2 −2 src/libsyntax/ext/qquote.rs
  21. +1 −1 src/libsyntax/ext/simplext.rs
  22. +17 −17 src/libsyntax/fold.rs
  23. +1 −1 src/libsyntax/parse.rs
  24. +2 −2 src/libsyntax/parse/lexer.rs
  25. +2 −2 src/libsyntax/parse/parser.rs
  26. +7 −7 src/libsyntax/print/pprust.rs
  27. +5 −5 src/libsyntax/visit.rs
  28. +2 −2 src/rustc/back/link.rs
  29. +4 −4 src/rustc/driver/driver.rs
  30. +3 −3 src/rustc/driver/rustc.rs
  31. +1 −1 src/rustc/front/config.rs
  32. +1 −1 src/rustc/metadata/cstore.rs
  33. +4 −4 src/rustc/metadata/decoder.rs
  34. +2 −2 src/rustc/metadata/encoder.rs
  35. +2 −2 src/rustc/metadata/filesearch.rs
  36. +1 −1 src/rustc/metadata/loader.rs
  37. +11 −11 src/rustc/middle/astencode.rs
  38. +3 −3 src/rustc/middle/check_alt.rs
  39. +1 −1 src/rustc/middle/check_const.rs
  40. +1 −1 src/rustc/middle/const_eval.rs
  41. +2 −2 src/rustc/middle/kind.rs
  42. +2 −2 src/rustc/middle/resolve.rs
  43. +4 −4 src/rustc/middle/trans/alt.rs
  44. +12 −12 src/rustc/middle/trans/base.rs
  45. +2 −2 src/rustc/middle/trans/callee.rs
  46. +3 −3 src/rustc/middle/trans/closure.rs
  47. +1 −1 src/rustc/middle/trans/common.rs
  48. +11 −11 src/rustc/middle/trans/debuginfo.rs
  49. +4 −4 src/rustc/middle/trans/foreign.rs
  50. +2 −2 src/rustc/middle/trans/glue.rs
  51. +1 −1 src/rustc/middle/trans/meth.rs
  52. +4 −4 src/rustc/middle/trans/monomorphize.rs
  53. +2 −2 src/rustc/middle/trans/reachable.rs
  54. +1 −1 src/rustc/middle/trans/reflect.rs
  55. +5 −5 src/rustc/middle/trans/shape.rs
  56. +4 −4 src/rustc/middle/trans/type_use.rs
  57. +3 −3 src/rustc/middle/ty.rs
  58. +9 −9 src/rustc/middle/typeck/check.rs
  59. +1 −1 src/rustc/middle/typeck/check/alt.rs
  60. +2 −2 src/rustc/middle/typeck/collect.rs
  61. +2 −2 src/rustdoc/attr_pass.rs
  62. +5 −5 src/rustdoc/config.rs
  63. +2 −2 src/rustdoc/desc_to_brief_pass.rs
  64. +1 −1 src/rustdoc/doc.rs
  65. +7 −7 src/rustdoc/markdown_index_pass.rs
  66. +14 −14 src/rustdoc/markdown_pass.rs
  67. +2 −2 src/rustdoc/markdown_writer.rs
  68. +1 −1 src/rustdoc/page_pass.rs
  69. +8 −8 src/rustdoc/sectionalize_pass.rs
  70. +1 −1 src/rustdoc/text_pass.rs
  71. +2 −2 src/rustdoc/tystr_pass.rs
  72. +2 −2 src/test/bench/msgsend-pipes-shared.rs
  73. +2 −2 src/test/bench/msgsend-pipes.rs
  74. +2 −2 src/test/bench/msgsend-ring-mutex-arcs.rs
  75. +2 −2 src/test/bench/msgsend-ring-pipes.rs
  76. +2 −2 src/test/bench/msgsend-ring-rw-arcs.rs
  77. +2 −2 src/test/bench/msgsend-ring.rs
  78. +2 −2 src/test/bench/msgsend.rs
  79. +2 −2 src/test/bench/shootout-pfib.rs
  80. +3 −3 src/test/bench/sudoku.rs
  81. +2 −2 src/test/run-pass/test-ignore-cfg.rs
View
8 src/cargo/cargo.rs
@@ -805,7 +805,7 @@ fn install_one_crate(c: &cargo, path: &Path, cf: &Path) {
if (exec_suffix != ~"" && str::ends_with(ct.to_str(),
exec_suffix)) ||
(exec_suffix == ~"" &&
- !str::starts_with(option::get(ct.filename()),
+ !str::starts_with(ct.filename().get(),
~"lib")) {
debug!(" bin: %s", ct.to_str());
install_to_dir(*ct, &c.bindir);
@@ -874,8 +874,8 @@ fn install_source(c: &cargo, path: &Path) {
fn install_git(c: &cargo, wd: &Path, url: ~str, reference: Option<~str>) {
run::program_output(~"git", ~[~"clone", url, wd.to_str()]);
- if option::is_some(reference) {
- let r = option::get(reference);
+ if reference.is_some() {
+ let r = reference.get();
os::change_dir(wd);
run::run_program(~"git", ~[~"checkout", r]);
}
@@ -1597,7 +1597,7 @@ fn cmd_search(c: &cargo) {
}
fn install_to_dir(srcfile: &Path, destdir: &Path) {
- let newfile = destdir.push(option::get(srcfile.filename()));
+ let newfile = destdir.push(srcfile.filename().get());
let status = run::run_program(~"cp", ~[~"-r", srcfile.to_str(),
newfile.to_str()]);
View
4 src/compiletest/compiletest.rs
@@ -56,7 +56,7 @@ fn parse_config(args: ~[~str]) -> config {
if vec::len(matches.free) > 0u {
option::Some(matches.free[0])
} else { option::None },
- logfile: option::map(getopts::opt_maybe_str(matches,
+ logfile: option::map(&getopts::opt_maybe_str(matches,
~"logfile"),
|s| Path(s)),
runtool: getopts::opt_maybe_str(matches, ~"runtool"),
@@ -155,7 +155,7 @@ fn is_test(config: config, testfile: &Path) -> bool {
_ => ~[~".rc", ~".rs"]
};
let invalid_prefixes = ~[~".", ~"#", ~"~"];
- let name = option::get(testfile.filename());
+ let name = testfile.filename().get();
let mut valid = false;
View
8 src/compiletest/header.rs
@@ -32,19 +32,19 @@ fn load_props(testfile: &Path) -> test_props {
option::None => ()
};
- if option::is_none(compile_flags) {
+ if compile_flags.is_none() {
compile_flags = parse_compile_flags(ln);
}
- if option::is_none(pp_exact) {
+ if pp_exact.is_none() {
pp_exact = parse_pp_exact(ln, testfile);
}
- do option::iter(parse_aux_build(ln)) |ab| {
+ do parse_aux_build(ln).iter |ab| {
vec::push(aux_builds, ab);
}
- do option::iter(parse_exec_env(ln)) |ee| {
+ do parse_exec_env(ln).iter |ee| {
vec::push(exec_env, ee);
}
};
View
4 src/compiletest/procsrv.rs
@@ -89,9 +89,9 @@ fn run(lib_path: ~str,
}
fn writeclose(fd: c_int, s: Option<~str>) {
- if option::is_some(s) {
+ if s.is_some() {
let writer = io::fd_writer(fd, false);
- writer.write_str(option::get(s));
+ writer.write_str(s.get());
}
os::close(fd);
View
6 src/compiletest/runtest.rs
@@ -102,7 +102,7 @@ fn run_rpass_test(config: config, props: test_props, testfile: &Path) {
}
fn run_pretty_test(config: config, props: test_props, testfile: &Path) {
- if option::is_some(props.pp_exact) {
+ if props.pp_exact.is_some() {
logv(config, ~"testing for exact pretty-printing");
} else { logv(config, ~"testing for converging pretty-printing"); }
@@ -135,7 +135,7 @@ fn run_pretty_test(config: config, props: test_props, testfile: &Path) {
};
let mut actual = srcs[vec::len(srcs) - 1u];
- if option::is_some(props.pp_exact) {
+ if props.pp_exact.is_some() {
// Now we have to care about line endings
let cr = ~"\r";
actual = str::replace(actual, cr, ~"");
@@ -575,7 +575,7 @@ fn aux_output_dir_name(config: config, testfile: &Path) -> Path {
}
fn output_testname(testfile: &Path) -> Path {
- Path(option::get(testfile.filestem()))
+ Path(testfile.filestem().get())
}
fn output_base_name(config: config, testfile: &Path) -> Path {
View
2 src/fuzzer/fuzzer.rs
@@ -305,7 +305,7 @@ fn check_variants_T<T: Copy>(
}
fn last_part(filename: ~str) -> ~str {
- let ix = option::get(str::rfind_char(filename, '/'));
+ let ix = option::get(&str::rfind_char(filename, '/'));
str::slice(filename, ix + 1u, str::len(filename) - 3u)
}
View
44 src/libcore/dlist.rs
@@ -211,7 +211,7 @@ impl<T> DList<T> {
fn push_head_n(+data: T) -> DListNode<T> {
let mut nobe = self.new_link(move data);
self.add_head(nobe);
- option::get(nobe)
+ option::get(&nobe)
}
/// Add data to the tail of the list. O(1).
fn push(+data: T) {
@@ -224,7 +224,7 @@ impl<T> DList<T> {
fn push_n(+data: T) -> DListNode<T> {
let mut nobe = self.new_link(move data);
self.add_tail(nobe);
- option::get(nobe)
+ option::get(&nobe)
}
/**
* Insert data into the middle of the list, left of the given node.
@@ -248,7 +248,7 @@ impl<T> DList<T> {
fn insert_before_n(+data: T, neighbour: DListNode<T>) -> DListNode<T> {
let mut nobe = self.new_link(move data);
self.insert_left(nobe, neighbour);
- option::get(nobe)
+ option::get(&nobe)
}
/**
* Insert data into the middle of the list, right of the given node.
@@ -272,7 +272,7 @@ impl<T> DList<T> {
fn insert_after_n(+data: T, neighbour: DListNode<T>) -> DListNode<T> {
let mut nobe = self.new_link(move data);
self.insert_right(neighbour, nobe);
- option::get(nobe)
+ option::get(&nobe)
}
/// Remove a node from the head of the list. O(1).
@@ -380,21 +380,25 @@ impl<T> DList<T> {
/// Check data structure integrity. O(n).
fn assert_consistent() {
- if option::is_none(self.hd) || option::is_none(self.tl) {
- assert option::is_none(self.hd) && option::is_none(self.tl);
+ if option::is_none(&self.hd) || option::is_none(&self.tl) {
+ assert option::is_none(&self.hd) && option::is_none(&self.tl);
}
// iterate forwards
let mut count = 0;
let mut link = self.peek_n();
let mut rabbit = link;
- while option::is_some(link) {
- let nobe = option::get(link);
+ while option::is_some(&link) {
+ let nobe = option::get(&link);
assert nobe.linked;
// check cycle
- if option::is_some(rabbit) { rabbit = option::get(rabbit).next; }
- if option::is_some(rabbit) { rabbit = option::get(rabbit).next; }
- if option::is_some(rabbit) {
- assert !box::ptr_eq(*option::get(rabbit), *nobe);
+ if option::is_some(&rabbit) {
+ rabbit = option::get(&rabbit).next;
+ }
+ if option::is_some(&rabbit) {
+ rabbit = option::get(&rabbit).next;
+ }
+ if option::is_some(&rabbit) {
+ assert !box::ptr_eq(*option::get(&rabbit), *nobe);
}
// advance
link = nobe.next_link();
@@ -404,14 +408,18 @@ impl<T> DList<T> {
// iterate backwards - some of this is probably redundant.
link = self.peek_tail_n();
rabbit = link;
- while option::is_some(link) {
- let nobe = option::get(link);
+ while option::is_some(&link) {
+ let nobe = option::get(&link);
assert nobe.linked;
// check cycle
- if option::is_some(rabbit) { rabbit = option::get(rabbit).prev; }
- if option::is_some(rabbit) { rabbit = option::get(rabbit).prev; }
- if option::is_some(rabbit) {
- assert !box::ptr_eq(*option::get(rabbit), *nobe);
+ if option::is_some(&rabbit) {
+ rabbit = option::get(&rabbit).prev;
+ }
+ if option::is_some(&rabbit) {
+ rabbit = option::get(&rabbit).prev;
+ }
+ if option::is_some(&rabbit) {
+ assert !box::ptr_eq(*option::get(&rabbit), *nobe);
}
// advance
link = nobe.prev_link();
View
2 src/libcore/gc.rs
@@ -328,7 +328,7 @@ fn cleanup_stack_for_failure() {
let mut roots = ~RootSet();
for walk_gc_roots(need_cleanup, sentinel) |root, tydesc| {
// Track roots to avoid double frees.
- if option::is_some(roots.find(&*root)) {
+ if roots.find(&*root).is_some() {
loop;
}
roots.insert(*root, ());
View
4 src/libcore/iter-trait/dlist.rs
@@ -10,8 +10,8 @@ type IMPL_T<A> = dlist::DList<A>;
*/
pure fn EACH<A>(self: IMPL_T<A>, f: fn(v: &A) -> bool) {
let mut link = self.peek_n();
- while option::is_some(link) {
- let nobe = option::get(link);
+ while option::is_some(&link) {
+ let nobe = option::get(&link);
assert nobe.linked;
if !f(&nobe.data) { break; }
// Check (weakly) that the user didn't do a remove.
View
58 src/libcore/option.rs
@@ -8,6 +8,10 @@
* type.
*/
+// NB: transitionary, de-mode-ing.
+#[forbid(deprecated_mode)];
+#[forbid(deprecated_pattern)];
+
use cmp::Eq;
/// The option type
@@ -16,7 +20,7 @@ enum Option<T> {
Some(T),
}
-pure fn get<T: Copy>(opt: Option<T>) -> T {
+pure fn get<T: Copy>(opt: &Option<T>) -> T {
/*!
* Gets the value out of an option
*
@@ -25,7 +29,7 @@ pure fn get<T: Copy>(opt: Option<T>) -> T {
* Fails if the value equals `none`
*/
- match opt {
+ match *opt {
Some(x) => return x,
None => fail ~"option::get none"
}
@@ -45,7 +49,7 @@ pure fn get_ref<T>(opt: &r/Option<T>) -> &r/T {
}
}
-pure fn expect<T: Copy>(opt: Option<T>, reason: ~str) -> T {
+pure fn expect<T: Copy>(opt: &Option<T>, +reason: ~str) -> T {
/*!
* Gets the value out of an option, printing a specified message on
* failure
@@ -54,13 +58,13 @@ pure fn expect<T: Copy>(opt: Option<T>, reason: ~str) -> T {
*
* Fails if the value equals `none`
*/
- match opt { Some(x) => x, None => fail reason }
+ match *opt { Some(x) => x, None => fail reason }
}
-pure fn map<T, U>(opt: Option<T>, f: fn(T) -> U) -> Option<U> {
+pure fn map<T, U>(opt: &Option<T>, f: fn(T) -> U) -> Option<U> {
//! Maps a `some` value from one type to another
- match opt { Some(x) => Some(f(x)), None => None }
+ match *opt { Some(x) => Some(f(x)), None => None }
}
pure fn map_ref<T, U>(opt: &Option<T>, f: fn(x: &T) -> U) -> Option<U> {
@@ -77,13 +81,13 @@ pure fn map_consume<T, U>(+opt: Option<T>, f: fn(+v: T) -> U) -> Option<U> {
if opt.is_some() { Some(f(option::unwrap(move opt))) } else { None }
}
-pure fn chain<T, U>(opt: Option<T>, f: fn(T) -> Option<U>) -> Option<U> {
+pure fn chain<T, U>(opt: &Option<T>, f: fn(T) -> Option<U>) -> Option<U> {
/*!
* Update an optional value by optionally running its content through a
* function that returns an option.
*/
- match opt { Some(x) => f(x), None => None }
+ match *opt { Some(x) => f(x), None => None }
}
pure fn chain_ref<T, U>(opt: &Option<T>,
@@ -116,28 +120,28 @@ pure fn while_some<T>(+x: Option<T>, blk: fn(+v: T) -> Option<T>) {
}
}
-pure fn is_none<T>(opt: Option<T>) -> bool {
+pure fn is_none<T>(opt: &Option<T>) -> bool {
//! Returns true if the option equals `none`
- match opt { None => true, Some(_) => false }
+ match *opt { None => true, Some(_) => false }
}
-pure fn is_some<T>(opt: Option<T>) -> bool {
+pure fn is_some<T>(opt: &Option<T>) -> bool {
//! Returns true if the option contains some value
!is_none(opt)
}
-pure fn get_default<T: Copy>(opt: Option<T>, def: T) -> T {
+pure fn get_default<T: Copy>(opt: &Option<T>, +def: T) -> T {
//! Returns the contained value or a default
- match opt { Some(x) => x, None => def }
+ match *opt { Some(x) => x, None => def }
}
-pure fn map_default<T, U>(opt: Option<T>, +def: U, f: fn(T) -> U) -> U {
+pure fn map_default<T, U>(opt: &Option<T>, +def: U, f: fn(T) -> U) -> U {
//! Applies a function to the contained value or returns a default
- match opt { None => move def, Some(t) => f(t) }
+ match *opt { None => move def, Some(t) => f(t) }
}
// This should replace map_default.
@@ -149,10 +153,10 @@ pure fn map_default_ref<T, U>(opt: &Option<T>, +def: U,
}
// This should change to by-copy mode; use iter_ref below for by reference
-pure fn iter<T>(opt: Option<T>, f: fn(T)) {
+pure fn iter<T>(opt: &Option<T>, f: fn(T)) {
//! Performs an operation on the contained value or does nothing
- match opt { None => (), Some(t) => f(t) }
+ match *opt { None => (), Some(t) => f(t) }
}
pure fn iter_ref<T>(opt: &Option<T>, f: fn(x: &T)) {
@@ -163,7 +167,7 @@ pure fn iter_ref<T>(opt: &Option<T>, f: fn(x: &T)) {
// tjc: shouldn't this be - instead of +?
// then could get rid of some superfluous moves
#[inline(always)]
-pure fn unwrap<T>(-opt: Option<T>) -> T {
+pure fn unwrap<T>(+opt: Option<T>) -> T {
/*!
* Moves a value out of an option type and returns it.
*
@@ -195,18 +199,18 @@ impl<T> Option<T> {
* Update an optional value by optionally running its content through a
* function that returns an option.
*/
- pure fn chain<U>(f: fn(T) -> Option<U>) -> Option<U> { chain(self, f) }
+ pure fn chain<U>(f: fn(T) -> Option<U>) -> Option<U> { chain(&self, f) }
/// Applies a function to the contained value or returns a default
pure fn map_default<U>(+def: U, f: fn(T) -> U) -> U
- { map_default(self, move def, f) }
+ { map_default(&self, move def, f) }
/// Performs an operation on the contained value or does nothing
- pure fn iter(f: fn(T)) { iter(self, f) }
+ pure fn iter(f: fn(T)) { iter(&self, f) }
/// Returns true if the option equals `none`
- pure fn is_none() -> bool { is_none(self) }
+ pure fn is_none() -> bool { is_none(&self) }
/// Returns true if the option contains some value
- pure fn is_some() -> bool { is_some(self) }
+ pure fn is_some() -> bool { is_some(&self) }
/// Maps a `some` value from one type to another
- pure fn map<U>(f: fn(T) -> U) -> Option<U> { map(self, f) }
+ pure fn map<U>(f: fn(T) -> U) -> Option<U> { map(&self, f) }
}
impl<T> &Option<T> {
@@ -236,8 +240,8 @@ impl<T: Copy> Option<T> {
*
* Fails if the value equals `none`
*/
- pure fn get() -> T { get(self) }
- pure fn get_default(def: T) -> T { get_default(self, def) }
+ pure fn get() -> T { get(&self) }
+ pure fn get_default(+def: T) -> T { get_default(&self, def) }
/**
* Gets the value out of an option, printing a specified message on
* failure
@@ -246,7 +250,7 @@ impl<T: Copy> Option<T> {
*
* Fails if the value equals `none`
*/
- pure fn expect(reason: ~str) -> T { expect(self, reason) }
+ pure fn expect(+reason: ~str) -> T { expect(&self, reason) }
/// Applies a function zero or more times until the result is none.
pure fn while_some(blk: fn(+v: T) -> Option<T>) { while_some(self, blk) }
}
View
16 src/libcore/os.rs
@@ -438,7 +438,7 @@ fn self_exe_path() -> Option<Path> {
}
}
- do option::map(load_self()) |pth| {
+ do load_self().map |pth| {
Path(pth).dir_path()
}
}
@@ -512,15 +512,15 @@ fn tmpdir() -> Path {
#[cfg(unix)]
#[allow(non_implicitly_copyable_typarams)]
fn lookup() -> Path {
- option::get_default(getenv_nonempty("TMPDIR"),
+ option::get_default(&getenv_nonempty("TMPDIR"),
Path("/tmp"))
}
#[cfg(windows)]
#[allow(non_implicitly_copyable_typarams)]
fn lookup() -> Path {
option::get_default(
- option::or(getenv_nonempty("TMP"),
+ &option::or(getenv_nonempty("TMP"),
option::or(getenv_nonempty("TEMP"),
option::or(getenv_nonempty("USERPROFILE"),
getenv_nonempty("WINDIR")))),
@@ -848,7 +848,7 @@ mod tests {
fn make_rand_name() -> ~str {
let rng: rand::Rng = rand::Rng();
let n = ~"TEST" + rng.gen_str(10u);
- assert option::is_none(getenv(n));
+ assert getenv(n).is_none();
n
}
@@ -889,8 +889,8 @@ mod tests {
#[test]
fn test_self_exe_path() {
let path = os::self_exe_path();
- assert option::is_some(path);
- let path = option::get(path);
+ assert path.is_some();
+ let path = path.get();
log(debug, path);
// Hard to test this function
@@ -909,7 +909,7 @@ mod tests {
// MingW seems to set some funky environment variables like
// "=C:=C:\MinGW\msys\1.0\bin" and "!::=::\" that are returned
// from env() but not visible from getenv().
- assert option::is_none(v2) || v2 == option::Some(v);
+ assert v2.is_none() || v2 == option::Some(v);
}
}
@@ -946,7 +946,7 @@ mod tests {
setenv(~"HOME", ~"");
assert os::homedir().is_none();
- option::iter(oldhome, |s| setenv(~"HOME", s));
+ oldhome.iter(|s| setenv(~"HOME", s));
}
#[test]
View
4 src/libcore/str.rs
@@ -1466,7 +1466,7 @@ pure fn find_str_between(haystack: &a/str, needle: &b/str, start: uint,
* * needle - The string to look for
*/
pure fn contains(haystack: &a/str, needle: &b/str) -> bool {
- option::is_some(find_str(haystack, needle))
+ find_str(haystack, needle).is_some()
}
/**
@@ -1478,7 +1478,7 @@ pure fn contains(haystack: &a/str, needle: &b/str) -> bool {
* * needle - The char to look for
*/
pure fn contains_char(haystack: &str, needle: char) -> bool {
- option::is_some(find_char(haystack, needle))
+ find_char(haystack, needle).is_some()
}
/**
View
4 src/libcore/vec.rs
@@ -957,7 +957,7 @@ pure fn find<T: Copy>(v: &[T], f: fn(T) -> bool) -> Option<T> {
*/
pure fn find_between<T: Copy>(v: &[T], start: uint, end: uint,
f: fn(T) -> bool) -> Option<T> {
- option::map(position_between(v, start, end, f), |i| v[i])
+ position_between(v, start, end, f).map(|i| v[i])
}
/**
@@ -980,7 +980,7 @@ pure fn rfind<T: Copy>(v: &[T], f: fn(T) -> bool) -> Option<T> {
*/
pure fn rfind_between<T: Copy>(v: &[T], start: uint, end: uint,
f: fn(T) -> bool) -> Option<T> {
- option::map(rposition_between(v, start, end, f), |i| v[i])
+ rposition_between(v, start, end, f).map(|i| v[i])
}
/// Find the first index containing a matching value
View
14 src/libstd/getopts.rs
@@ -303,8 +303,8 @@ fn getopts(args: &[~str], opts: &[Opt]) -> Result unsafe {
Some(id) => last_valid_opt_id = option::Some(id),
None => {
let arg_follows =
- option::is_some(last_valid_opt_id) &&
- match opts[option::get(last_valid_opt_id)]
+ last_valid_opt_id.is_some() &&
+ match opts[last_valid_opt_id.get()]
.hasarg {
Yes | Maybe => true,
@@ -331,23 +331,23 @@ fn getopts(args: &[~str], opts: &[Opt]) -> Result unsafe {
};
match opts[optid].hasarg {
No => {
- if !option::is_none::<~str>(i_arg) {
+ if !i_arg.is_none() {
return Err(UnexpectedArgument(name_str(nm)));
}
vec::push(vals[optid], Given);
}
Maybe => {
- if !option::is_none::<~str>(i_arg) {
- vec::push(vals[optid], Val(option::get(i_arg)));
+ if !i_arg.is_none() {
+ vec::push(vals[optid], Val(i_arg.get()));
} else if name_pos < vec::len::<Name>(names) ||
i + 1u == l || is_arg(args[i + 1u]) {
vec::push(vals[optid], Given);
} else { i += 1u; vec::push(vals[optid], Val(args[i])); }
}
Yes => {
- if !option::is_none::<~str>(i_arg) {
+ if !i_arg.is_none() {
vec::push(vals[optid],
- Val(option::get::<~str>(i_arg)));
+ Val(i_arg.get()));
} else if i + 1u == l {
return Err(ArgumentMissing(name_str(nm)));
} else { i += 1u; vec::push(vals[optid], Val(args[i])); }
View
4 src/libstd/map.rs
@@ -730,9 +730,9 @@ mod tests {
fn test_find() {
let key = ~"k";
let map = map::HashMap::<~str, ~str>();
- assert (option::is_none(map.find(key)));
+ assert (option::is_none(&map.find(key)));
map.insert(key, ~"val");
- assert (option::get(map.find(key)) == ~"val");
+ assert (option::get(&map.find(key)) == ~"val");
}
#[test]
View
14 src/libstd/net_url.rs
@@ -308,7 +308,7 @@ fn userinfo_from_str(uinfo: &str) -> UserInfo {
}
fn userinfo_to_str(+userinfo: UserInfo) -> ~str {
- if option::is_some(userinfo.pass) {
+ if option::is_some(&userinfo.pass) {
return str::concat(~[copy userinfo.user, ~":",
option::unwrap(copy userinfo.pass),
~"@"]);
@@ -708,7 +708,7 @@ impl Url : FromStr {
*
*/
fn to_str(+url: Url) -> ~str {
- let user = if option::is_some(url.user) {
+ let user = if url.user.is_some() {
userinfo_to_str(option::unwrap(copy url.user))
} else {
~""
@@ -723,7 +723,7 @@ fn to_str(+url: Url) -> ~str {
} else {
str::concat(~[~"?", query_to_str(url.query)])
};
- let fragment = if option::is_some(url.fragment) {
+ let fragment = if url.fragment.is_some() {
str::concat(~[~"#", encode_component(
option::unwrap(copy url.fragment))])
} else {
@@ -805,21 +805,21 @@ mod tests {
assert u == option::Some({user: ~"user",
pass: option::Some(~"pass")});
assert h == ~"rust-lang.org";
- assert option::is_none(p);
+ assert p.is_none();
assert r == ~"/something";
let (u, h, p, r) = result::unwrap(get_authority(
~"//rust-lang.org:8000?something"));
- assert option::is_none(u);
+ assert u.is_none();
assert h == ~"rust-lang.org";
assert p == option::Some(~"8000");
assert r == ~"?something";
let (u, h, p, r) = result::unwrap(get_authority(
~"//rust-lang.org#blah"));
- assert option::is_none(u);
+ assert u.is_none();
assert h == ~"rust-lang.org";
- assert option::is_none(p);
+ assert p.is_none();
assert r == ~"#blah";
// ipv6 tests
View
2 src/libstd/smallintmap.rs
@@ -62,7 +62,7 @@ pure fn get<T: Copy>(self: SmallIntMap<T>, key: uint) -> T {
/// Returns true if the map contains a value for the specified key
fn contains_key<T: Copy>(self: SmallIntMap<T>, key: uint) -> bool {
- return !option::is_none(find(self, key));
+ return !find(self, key).is_none();
}
/// Implements the map::map interface for smallintmap
View
8 src/libstd/test.rs
@@ -274,8 +274,8 @@ fn should_sort_failures_before_printing_them() {
print_failures(st);
};
- let apos = option::get(str::find_str(s, ~"a"));
- let bpos = option::get(str::find_str(s, ~"b"));
+ let apos = str::find_str(s, ~"a").get();
+ let bpos = str::find_str(s, ~"b").get();
assert apos < bpos;
}
@@ -351,7 +351,7 @@ fn filter_tests(opts: &TestOpts,
let mut filtered = vec::slice(tests, 0, tests.len());
// Remove tests that don't match the test filter
- filtered = if option::is_none(opts.filter) {
+ filtered = if opts.filter.is_none() {
move filtered
} else {
let filter_str =
@@ -503,7 +503,7 @@ mod tests {
either::Left(o) => o,
_ => fail ~"Malformed arg in first_free_arg_should_be_a_filter"
};
- assert ~"filter" == option::get(opts.filter);
+ assert ~"filter" == opts.filter.get();
}
#[test]
View
4 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));
View
4 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)}
View
2 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,
View
34 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,20 +501,20 @@ 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)),
expr_mac(mac) => expr_mac(fold_mac(mac)),
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 }));
View
2 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;
View
4 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);
View
4 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,
View
14 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; }
View
10 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) */ }
View
4 src/rustc/back/link.rs
@@ -688,7 +688,7 @@ fn link_binary(sess: session,
}
let dir = cratepath.dirname();
if dir != ~"" { vec::push(cc_args, ~"-L" + dir); }
- let libarg = unlib(sess.targ_cfg, option::get(cratepath.filestem()));
+ let libarg = unlib(sess.targ_cfg, cratepath.filestem().get());
vec::push(cc_args, ~"-l" + libarg);
}
@@ -717,7 +717,7 @@ fn link_binary(sess: session,
// be rpathed
if sess.targ_cfg.os == session::os_macos {
vec::push(cc_args, ~"-Wl,-install_name,@rpath/"
- + option::get(output.filename()));
+ + output.filename().get());
}
}
View
8 src/rustc/driver/driver.rs
@@ -254,7 +254,7 @@ fn compile_upto(sess: session, cfg: ast::crate_cfg,
time(time_passes, ~"lint checking", || lint::check_crate(ty_cx, crate));
if upto == cu_no_trans { return {crate: crate, tcx: Some(ty_cx)}; }
- let outputs = option::get(outputs);
+ let outputs = outputs.get();
let maps = {mutbl_map: mutbl_map,
root_map: root_map,
@@ -353,7 +353,7 @@ fn pretty_print_input(sess: session, cfg: ast::crate_cfg, input: input,
let ann = match ppm {
ppm_typed => {
{pre: ann_paren_for_expr,
- post: |a| ann_typed_post(option::get(tcx), a) }
+ post: |a| ann_typed_post(tcx.get(), a) }
}
ppm_identified | ppm_expanded_identified => {
{pre: ann_paren_for_expr, post: ann_identified_post}
@@ -516,7 +516,7 @@ fn build_session_options(binary: ~str,
let extra_debuginfo = opt_present(matches, ~"xg");
let debuginfo = opt_present(matches, ~"g") || extra_debuginfo;
let sysroot_opt = getopts::opt_maybe_str(matches, ~"sysroot");
- let sysroot_opt = option::map(sysroot_opt, |m| Path(m));
+ let sysroot_opt = sysroot_opt.map(|m| Path(m));
let target_opt = getopts::opt_maybe_str(matches, ~"target");
let save_temps = getopts::opt_present(matches, ~"save-temps");
match output_type {
@@ -695,7 +695,7 @@ fn build_output_filenames(input: input,
};
let stem = match input {
- file_input(ifile) => option::get(ifile.filestem()),
+ file_input(ifile) => ifile.filestem().get(),
str_input(_) => ~"rust_out"
};
View
6 src/rustc/driver/rustc.rs
@@ -171,12 +171,12 @@ fn run_compiler(args: ~[~str], demitter: diagnostic::emitter) {
let sopts = build_session_options(binary, matches, demitter);
let sess = build_session(sopts, demitter);
let odir = getopts::opt_maybe_str(matches, ~"out-dir");
- let odir = option::map(odir, |o| Path(o));
+ let odir = odir.map(|o| Path(o));
let ofile = getopts::opt_maybe_str(matches, ~"o");
- let ofile = option::map(ofile, |o| Path(o));
+ let ofile = ofile.map(|o| Path(o));
let cfg = build_configuration(sess, binary, input);
let pretty =
- option::map(getopts::opt_default(matches, ~"pretty",
+ option::map(&getopts::opt_default(matches, ~"pretty",
~"normal"),
|a| parse_pretty(sess, a) );
match pretty {
View
2 src/rustc/front/config.rs
@@ -104,7 +104,7 @@ fn fold_block(cx: ctxt, b: ast::blk_, fld: fold::ast_fold) ->
let filtered_stmts = vec::filter_map(b.stmts, filter);
return {view_items: b.view_items,
stmts: vec::map(filtered_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: b.id,
rules: b.rules};
}
View
2 src/rustc/metadata/cstore.rs
@@ -176,7 +176,7 @@ fn get_dep_hashes(cstore: cstore) -> ~[~str] {
}
fn get_path(cstore: cstore, d: ast::def_id) -> ~[~str] {
- option::map_default(p(cstore).mod_path_map.find(d), ~[],
+ option::map_default(&p(cstore).mod_path_map.find(d), ~[],
|ds| str::split_str(*ds, ~"::"))
}
// Local Variables:
View
8 src/rustc/metadata/decoder.rs
@@ -92,7 +92,7 @@ fn maybe_find_item(item_id: int, items: ebml::Doc) -> Option<ebml::Doc> {
}
fn find_item(item_id: int, items: ebml::Doc) -> ebml::Doc {
- return option::get(maybe_find_item(item_id, items));
+ return maybe_find_item(item_id, items).get();
}
// Looks up an item in the given metadata and returns an ebml doc pointing
@@ -202,7 +202,7 @@ fn each_reexport(d: ebml::Doc, f: fn(ebml::Doc) -> bool) {
fn field_mutability(d: ebml::Doc) -> ast::class_mutability {
// Use maybe_get_doc in case it's a method
option::map_default(
- ebml::maybe_get_doc(d, tag_class_mut),
+ &ebml::maybe_get_doc(d, tag_class_mut),
ast::class_immutable,
|d| {
match ebml::doc_as_u8(d) as char {
@@ -213,7 +213,7 @@ fn field_mutability(d: ebml::Doc) -> ast::class_mutability {
}
fn variant_disr_val(d: ebml::Doc) -> Option<int> {
- do option::chain(ebml::maybe_get_doc(d, tag_disr_val)) |val_doc| {
+ do option::chain(&ebml::maybe_get_doc(d, tag_disr_val)) |val_doc| {
int::parse_bytes(ebml::doc_data(val_doc), 10u)
}
}
@@ -384,7 +384,7 @@ fn get_impl_method(intr: ident_interner, cdata: cmd, id: ast::node_id,
found = Some(translate_def_id(cdata, m_did));
}
}
- option::get(found)
+ found.get()
}
fn get_class_method(intr: ident_interner, cdata: cmd, id: ast::node_id,
View
4 src/rustc/metadata/encoder.rs
@@ -602,7 +602,7 @@ fn encode_info_for_item(ecx: @encode_ctxt, ebml_w: ebml::Writer, item: @item,
struct_def.fields, struct_def.methods,
index);
/* Encode the dtor */
- do option::iter(struct_def.dtor) |dtor| {
+ do struct_def.dtor.iter |dtor| {
vec::push(*index, {val: dtor.node.id, pos: ebml_w.writer.tell()});
encode_info_for_ctor(ecx, ebml_w, dtor.node.id,
ecx.tcx.sess.ident_of(
@@ -635,7 +635,7 @@ fn encode_info_for_item(ecx: @encode_ctxt, ebml_w: ebml::Writer, item: @item,
}
/* Encode the dtor */
/* Encode id for dtor */
- do option::iter(struct_def.dtor) |dtor| {
+ do struct_def.dtor.iter |dtor| {
do ebml_w.wr_tag(tag_item_dtor) {
encode_def_id(ebml_w, local_def(dtor.node.id));
}
View
4 src/rustc/metadata/filesearch.rs
@@ -74,15 +74,15 @@ fn search<T: Copy>(filesearch: filesearch, pick: pick<T>) -> Option<T> {
for os::list_dir_path(lib_search_path).each |path| {
debug!("testing %s", path.to_str());
let maybe_picked = pick(*path);
- if option::is_some(maybe_picked) {
+ if maybe_picked.is_some() {
debug!("picked %s", path.to_str());
rslt = maybe_picked;
break;
} else {
debug!("rejected %s", path.to_str());
}
}
- if option::is_some(rslt) { break; }
+ if rslt.is_some() { break; }
}
return rslt;
}
View
2 src/rustc/metadata/loader.rs
@@ -75,7 +75,7 @@ fn find_library_crate_aux(cx: ctxt,
let mut matches = ~[];
filesearch::search(filesearch, |path| {
debug!("inspecting file %s", path.to_str());
- let f: ~str = option::get(path.filename());
+ let f: ~str = path.filename().get();
if !(str::starts_with(f, prefix) && str::ends_with(f, suffix)) {
debug!("skipping %s, doesn't look like %s*%s", path.to_str(),
prefix, suffix);
View
22 src/rustc/middle/astencode.rs
@@ -719,15 +719,15 @@ fn encode_side_tables_for_id(ecx: @e::encode_ctxt,
debug!("Encoding side tables for id %d", id);
- do option::iter(tcx.def_map.find(id)) |def| {
+ do option::iter(&tcx.def_map.find(id)) |def| {
do ebml_w.tag(c::tag_table_def) {
ebml_w.id(id);
do ebml_w.tag(c::tag_table_val) {
ast::serialize_def(ebml_w, def)
}
}
}
- do option::iter((*tcx.node_types).find(id as uint)) |ty| {
+ do option::iter(&(*tcx.node_types).find(id as uint)) |ty| {
do ebml_w.tag(c::tag_table_node_type) {
ebml_w.id(id);
do ebml_w.tag(c::tag_table_val) {
@@ -736,7 +736,7 @@ fn encode_side_tables_for_id(ecx: @e::encode_ctxt,
}
}
- do option::iter(tcx.node_type_substs.find(id)) |tys| {
+ do option::iter(&tcx.node_type_substs.find(id)) |tys| {
do ebml_w.tag(c::tag_table_node_type_subst) {
ebml_w.id(id);
do ebml_w.tag(c::tag_table_val) {
@@ -745,7 +745,7 @@ fn encode_side_tables_for_id(ecx: @e::encode_ctxt,
}
}
- do option::iter(tcx.freevars.find(id)) |fv| {
+ do option::iter(&tcx.freevars.find(id)) |fv| {
do ebml_w.tag(c::tag_table_freevars) {
ebml_w.id(id);
do ebml_w.tag(c::tag_table_val) {
@@ -757,7 +757,7 @@ fn encode_side_tables_for_id(ecx: @e::encode_ctxt,
}
let lid = {crate: ast::local_crate, node: id};
- do option::iter(tcx.tcache.find(lid)) |tpbt| {
+ do option::iter(&tcx.tcache.find(lid)) |tpbt| {
do ebml_w.tag(c::tag_table_tcache) {
ebml_w.id(id);
do ebml_w.tag(c::tag_table_val) {
@@ -766,7 +766,7 @@ fn encode_side_tables_for_id(ecx: @e::encode_ctxt,
}
}
- do option::iter(tcx.ty_param_bounds.find(id)) |pbs| {
+ do option::iter(&tcx.ty_param_bounds.find(id)) |pbs| {
do ebml_w.tag(c::tag_table_param_bounds) {
ebml_w.id(id);
do ebml_w.tag(c::tag_table_val) {
@@ -789,13 +789,13 @@ fn encode_side_tables_for_id(ecx: @e::encode_ctxt,
// }
//}
- do option::iter(maps.mutbl_map.find(id)) |_m| {
+ do option::iter(&maps.mutbl_map.find(id)) |_m| {
do ebml_w.tag(c::tag_table_mutbl) {
ebml_w.id(id);
}
}
- do option::iter(maps.last_use_map.find(id)) |m| {
+ do option::iter(&maps.last_use_map.find(id)) |m| {
do ebml_w.tag(c::tag_table_last_use) {
ebml_w.id(id);
do ebml_w.tag(c::tag_table_val) {
@@ -806,7 +806,7 @@ fn encode_side_tables_for_id(ecx: @e::encode_ctxt,
}
}
- do option::iter(maps.method_map.find(id)) |mme| {
+ do option::iter(&maps.method_map.find(id)) |mme| {
do ebml_w.tag(c::tag_table_method_map) {
ebml_w.id(id);
do ebml_w.tag(c::tag_table_val) {
@@ -815,7 +815,7 @@ fn encode_side_tables_for_id(ecx: @e::encode_ctxt,
}
}
- do option::iter(maps.vtable_map.find(id)) |dr| {
+ do option::iter(&maps.vtable_map.find(id)) |dr| {
do ebml_w.tag(c::tag_table_vtable_map) {
ebml_w.id(id);
do ebml_w.tag(c::tag_table_val) {
@@ -824,7 +824,7 @@ fn encode_side_tables_for_id(ecx: @e::encode_ctxt,
}
}
- do option::iter(tcx.adjustments.find(id)) |adj| {
+ do option::iter(&tcx.adjustments.find(id)) |adj| {
do ebml_w.tag(c::tag_table_adjustments) {
ebml_w.id(id);
do ebml_w.tag(c::tag_table_val) {
View
6 src/rustc/middle/check_alt.rs
@@ -67,7 +67,7 @@ fn check_arms(tcx: ty::ctxt, arms: ~[arm]) {
}
_ => ()
}
- if option::is_none(arm.guard) { vec::push(seen, v); }
+ if arm.guard.is_none() { vec::push(seen, v); }
}
}
}
@@ -233,7 +233,7 @@ fn is_useful_specialized(tcx: ty::ctxt, m: matrix, v: ~[@pat], ctor: ctor,
arity: uint, lty: ty::t) -> useful {
let ms = vec::filter_map(m, |r| specialize(tcx, r, ctor, arity, lty) );
let could_be_useful = is_useful(
- tcx, ms, option::get(specialize(tcx, v, ctor, arity, lty)));
+ tcx, ms, specialize(tcx, v, ctor, arity, lty).get());
match could_be_useful {
useful_ => useful(lty, ctor),
u => u
@@ -287,7 +287,7 @@ fn missing_ctor(tcx: ty::ctxt, m: matrix, left_ty: ty::t) -> Option<ctor> {
ty::ty_enum(eid, _) => {
let mut found = ~[];
for m.each |r| {
- do option::iter(pat_ctor_id(tcx, r[0])) |id| {
+ do option::iter(&pat_ctor_id(tcx, r[0])) |id| {
if !vec::contains(found, id) { vec::push(found, id); }
}
}
View
2 src/rustc/middle/check_const.rs
@@ -27,7 +27,7 @@ fn check_item(sess: session, ast_map: ast_map::map,
}
item_enum(enum_definition, _) => {
for enum_definition.variants.each |var| {
- do option::iter(var.node.disr_expr) |ex| {
+ do option::iter(&var.node.disr_expr) |ex| {
v.visit_expr(ex, true, v);
}
}
View
2 src/rustc/middle/const_eval.rs
@@ -375,7 +375,7 @@ fn lit_to_const(lit: @lit) -> const_val {
lit_int(n, _) => const_int(n),
lit_uint(n, _) => const_uint(n),
lit_int_unsuffixed(n) => const_int(n),
- lit_float(n, _) => const_float(option::get(float::from_str(*n)) as f64),
+ lit_float(n, _) => const_float(float::from_str(*n).get() as f64),
lit_nil => const_int(0i64),
lit_bool(b) => const_bool(b)
}
View
4 src/rustc/middle/kind.rs
@@ -248,7 +248,7 @@ fn check_expr(e: @expr, cx: ctx, v: visit::vt<ctx>) {
};
// Handle any kind bounds on type parameters
- do option::iter(cx.tcx.node_type_substs.find(id_to_use)) |ts| {
+ do option::iter(&cx.tcx.node_type_substs.find(id_to_use)) |ts| {
let bounds = match e.node {
expr_path(_) => {
let did = ast_util::def_id_of_def(cx.tcx.def_map.get(e.id));
@@ -373,7 +373,7 @@ fn check_stmt(stmt: @stmt, cx: ctx, v: visit::vt<ctx>) {
fn check_ty(aty: @ty, cx: ctx, v: visit::vt<ctx>) {
match aty.node {
ty_path(_, id) => {
- do option::iter(cx.tcx.node_type_substs.find(id)) |ts| {
+ do option::iter(&cx.tcx.node_type_substs.find(id)) |ts| {
let did = ast_util::def_id_of_def(cx.tcx.def_map.get(id));
let bounds = ty::lookup_item_type(cx.tcx, did).bounds;
do vec::iter2(ts, *bounds) |ty, bound| {
View
4 src/rustc/middle/resolve.rs
@@ -1168,7 +1168,7 @@ impl Resolver {
// Record the def ID of this struct.
self.structs.insert(local_def(item.id),
- is_some(struct_definition.ctor));
+ struct_definition.ctor.is_some());
visit_item(item, new_parent, visitor);
}
@@ -1607,7 +1607,7 @@ impl Resolver {
let modules = HashMap();
// Create all the items reachable by paths.
- for each_path(self.session.cstore, get(root.def_id).crate)
+ for each_path(self.session.cstore, root.def_id.get().crate)
|path_entry| {
debug!("(building reduced graph for external crate) found path \
View
8 src/rustc/middle/trans/alt.rs
@@ -354,7 +354,7 @@ fn enter_opt(bcx: block, m: &[@Match/&r], opt: &Opt, col: uint,
match p.node {
ast::pat_enum(_, subpats) => {
if opt_eq(tcx, &variant_opt(tcx, p.id), opt) {
- Some(option::get_default(subpats,
+ Some(option::get_default(&subpats,
vec::from_elem(variant_size,
dummy)))
} else {
@@ -872,12 +872,12 @@ fn compile_submatch(bcx: block,
/*
For an empty match, a fall-through case must exist
*/
- assert(m.len() > 0u || is_some(chk));
+ assert(m.len() > 0u || chk.is_some());
let _icx = bcx.insn_ctxt("alt::compile_submatch");
let mut bcx = bcx;
let tcx = bcx.tcx(), dm = tcx.def_map;
if m.len() == 0u {
- Br(bcx, option::get(chk)());
+ Br(bcx, chk.get()());
return;
}
if m[0].pats.len() == 0u {
@@ -1019,7 +1019,7 @@ fn compile_submatch(bcx: block,
};
let defaults = enter_default(else_cx, dm, m, col, val);
- let exhaustive = option::is_none(chk) && defaults.len() == 0u;
+ let exhaustive = chk.is_none() && defaults.len() == 0u;
let len = opts.len();
let mut i = 0u;
View
24 src/rustc/middle/trans/base.rs
@@ -777,7 +777,7 @@ fn in_lpad_scope_cx(bcx: block, f: fn(scope_info)) {
loop {
match bcx.kind {
block_scope(inf) => {
- if inf.cleanups.len() > 0u || is_none(bcx.parent) {
+ if inf.cleanups.len() > 0u || bcx.parent.is_none() {
f(inf); return;
}
}
@@ -1042,7 +1042,7 @@ fn new_block(cx: fn_ctxt, parent: Option<block>, +kind: block_kind,
llvm::LLVMAppendBasicBlock(cx.llfn, buf)
});
let bcx = mk_block(llbb, parent, move kind, is_lpad, opt_node_info, cx);
- do option::iter(parent) |cx| {
+ do option::iter(&parent) |cx| {
if cx.unreachable { Unreachable(bcx); }
};
return bcx;
@@ -1164,12 +1164,12 @@ fn cleanup_and_leave(bcx: block, upto: Option<BasicBlockRef>,
}
cur = match cur.parent {
Some(next) => next,
- None => { assert is_none(upto); break; }
+ None => { assert upto.is_none(); break; }
};
}
match leave {
Some(target) => Br(bcx, target),
- None => { Resume(bcx, Load(bcx, option::get(bcx.fcx.personality))); }
+ None => { Resume(bcx, Load(bcx, bcx.fcx.personality.get())); }
}
}
@@ -1251,7 +1251,7 @@ fn alloc_local(cx: block, local: @ast::local) -> block {
};
let val = alloc_ty(cx, t);
if cx.sess().opts.debuginfo {
- do option::iter(simple_name) |name| {
+ do option::iter(&simple_name) |name| {
str::as_c_str(cx.ccx().sess.str_of(name), |buf| {
llvm::LLVMSetValueName(val, buf)
});
@@ -1601,7 +1601,7 @@ fn trans_closure(ccx: @crate_ctxt, path: path, decl: ast::fn_decl,
/* avoids the need for special cases to assign a type to
the constructor body (since it has no explicit return) */
&&