diff options
| author | Tim Chevalier <chevalier@alum.wellesley.edu> | 2013-02-05 10:33:28 -0800 |
|---|---|---|
| committer | Tim Chevalier <chevalier@alum.wellesley.edu> | 2013-02-05 10:33:28 -0800 |
| commit | 2dcb3ed745d04048941a8130f3603c5759b2b142 (patch) | |
| tree | b02ae43f09244c7f4549a9c4171516d0cc257997 | |
| parent | 6f0bede97c3468eaba8cf59702d04c7ede8f4b0a (diff) | |
| parent | 2f46b763da2c098913884f101b6d71d69af41b49 (diff) | |
| download | rust-2dcb3ed745d04048941a8130f3603c5759b2b142.tar.gz rust-2dcb3ed745d04048941a8130f3603c5759b2b142.zip | |
Merge
1491 files changed, 5903 insertions, 5779 deletions
diff --git a/AUTHORS.txt b/AUTHORS.txt index af60f35fcac..a7b55520b8d 100644 --- a/AUTHORS.txt +++ b/AUTHORS.txt @@ -106,6 +106,7 @@ Margaret Meyerhofer <mmeyerho@andrew.cmu.edu> Marijn Haverbeke <marijnh@gmail.com> Mark Lacey <641@rudkx.com> Martin DeMello <martindemello@gmail.com> +Marvin Löbel <loebel.marvin@gmail.com> Matt Brubeck <mbrubeck@limpet.net> Matthew O'Connor <thegreendragon@gmail.com> Max Penet <max.penet@gmail.com> diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 39183eafe9e..c6e9478713d 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -1,15 +1,24 @@ ## Pull request procedure -Pull requests should be targeted at Rust's `incoming` branch (note that by default Github will aim them at the `master` branch) -- see "Changing The Commit Range and Destination Repository" in Github's documentation on [pull requests](https://help.github.com/articles/using-pull-requests). Before pushing to your Github repo and issuing the pull request, please do two things: +Pull requests should be targeted at Rust's `incoming` branch (note that by default Github will aim them at the `master` branch) -- +see "Changing The Commit Range and Destination Repository" in Github's documentation on [pull requests](https://help.github.com/articles/using-pull-requests). +Before pushing to your Github repo and issuing the pull request, please do two things: 1. [Rebase](http://git-scm.com/book/en/Git-Branching-Rebasing) your local changes against the `incoming` branch. Resolve any conflicts that arise. -2. Run the full Rust test suite with the `make check` command. You're not off the hook even if you just stick to documentation; code examples in the docs are tested as well! +2. Run the full Rust test suite with the `make check` command. +You're not off the hook even if you just stick to documentation; code examples in the docs are tested as well! -Pull requests will be treated as "review requests", and we will give feedback we expect to see corrected on [style](https://github.com/mozilla/rust/wiki/Note-style-guide) and substance before pulling. Changes contributed via pull request should focus on a single issue at a time, like any other. We will not look kindly on pull-requests that try to "sneak" unrelated changes in. +Pull requests will be treated as "review requests", +and we will give feedback we expect to see corrected on [style](https://github.com/mozilla/rust/wiki/Note-style-guide) and substance before pulling. +Changes contributed via pull request should focus on a single issue at a time, like any other. +We will not look accept pull-requests that try to "sneak" unrelated changes in. -Normally, all pull requests must include regression tests (see [Note-testsuite](https://github.com/mozilla/rust/wiki/Note-testsuite)) that test your change. Occasionally, a change will be very difficult to test for. In those cases, please include a note in your commit message explaining why. +Normally, all pull requests must include regression tests (see [Note-testsuite](https://github.com/mozilla/rust/wiki/Note-testsuite)) that test your change. +Occasionally, a change will be very difficult to test for. +In those cases, please include a note in your commit message explaining why. -In the licensing header at the beginning of any files you change, please make sure the listed date range includes the current year. For example, if it's 2013, and you change a Rust file that was created in 2010, it should begin: +In the licensing header at the beginning of any files you change, please make sure the listed date range includes the current year. +For example, if it's 2013, and you change a Rust file that was created in 2010, it should begin: ``` // Copyright 2010-2013 The Rust Project Developers. diff --git a/README.md b/README.md index 877e2b56987..27b63c1080b 100644 --- a/README.md +++ b/README.md @@ -42,7 +42,7 @@ packages: Assuming you're on a relatively modern *nix system and have met the prerequisites, something along these lines should work. - $ wget http://static.rust-lang.org/dist/rust-0.5.tar.gz + $ curl -O http://static.rust-lang.org/dist/rust-0.5.tar.gz $ tar -xzf rust-0.5.tar.gz $ cd rust-0.5 $ ./configure diff --git a/doc/lib/codemirror-rust.js b/doc/lib/codemirror-rust.js index 727882d3099..052669be6f5 100644 --- a/doc/lib/codemirror-rust.js +++ b/doc/lib/codemirror-rust.js @@ -2,7 +2,7 @@ CodeMirror.defineMode("rust", function() { var indentUnit = 4, altIndentUnit = 2; var valKeywords = { "if": "if-style", "while": "if-style", "loop": "if-style", "else": "else-style", - "do": "else-style", "return": "else-style", "fail": "else-style", + "do": "else-style", "return": "else-style", "break": "atom", "cont": "atom", "const": "let", "resource": "fn", "let": "let", "fn": "fn", "for": "for", "match": "match", "trait": "trait", "impl": "impl", "type": "type", "enum": "enum", "struct": "atom", "mod": "mod", diff --git a/doc/rust.md b/doc/rust.md index 7a5b8dfd004..fc8ce9f9c38 100644 --- a/doc/rust.md +++ b/doc/rust.md @@ -216,7 +216,7 @@ break const copy do drop else enum extern -fail false fn for +false fn for if impl let log loop match mod move mut @@ -448,10 +448,10 @@ expression context, the final namespace qualifier is omitted. Two examples of paths with type arguments: ~~~~ -# use std::map; +# use std::oldmap; # fn f() { # fn id<T:Copy>(t: T) -> T { t } -type t = map::HashMap<int,~str>; // Type arguments used in a type expression +type t = oldmap::HashMap<int,~str>; // Type arguments used in a type expression let x = id::<int>(10); // Type arguments used in a call expression # } ~~~~ @@ -692,15 +692,15 @@ mod math { type complex = (f64, f64); fn sin(f: f64) -> f64 { ... -# fail; +# die!(); } fn cos(f: f64) -> f64 { ... -# fail; +# die!(); } fn tan(f: f64) -> f64 { ... -# fail; +# die!(); } } ~~~~~~~~ @@ -844,13 +844,16 @@ mod quux { pub fn bar() { } pub fn baz() { } } - + pub use quux::foo::*; } ~~~~ In this example, the module `quux` re-exports all of the public names defined in `foo`. +Also note that the paths contained in `use` items are relative to the crate root; so, in the previous +example, the use refers to `quux::foo::*`, and not simply to `foo::*`. + ### Functions A _function item_ defines a sequence of [statements](#statements) and an optional final [expression](#expressions), along with a name and a set of parameters. @@ -989,13 +992,13 @@ output slot type would normally be. For example: ~~~~ fn my_err(s: &str) -> ! { log(info, s); - fail; + die!(); } ~~~~ We call such functions "diverging" because they never return a value to the caller. Every control path in a diverging function must end with a -[`fail`](#fail-expressions) or a call to another diverging function on every +`fail!()` or a call to another diverging function on every control path. The `!` annotation does *not* denote a type. Rather, the result type of a diverging function is a special type called $\bot$ ("bottom") that unifies with any type. Rust has no syntax for $\bot$. @@ -1007,7 +1010,7 @@ were declared without the `!` annotation, the following code would not typecheck: ~~~~ -# fn my_err(s: &str) -> ! { fail } +# fn my_err(s: &str) -> ! { die!() } fn f(i: int) -> int { if i == 42 { @@ -1239,7 +1242,7 @@ trait Num { impl float: Num { static pure fn from_int(n: int) -> float { n as float } } -let x: float = Num::from_int(42); +let x: float = Num::from_int(42); ~~~~ Traits may inherit from other traits. For example, in @@ -1612,7 +1615,7 @@ The following are examples of structure expressions: ~~~~ # struct Point { x: float, y: float } # struct TuplePoint(float, float); -# mod game { pub struct User { name: &str, age: uint, mut score: uint } } +# mod game { pub struct User { name: &str, age: uint, mut score: uint } } # use game; Point {x: 10f, y: 20f}; TuplePoint(10f, 20f); @@ -1716,15 +1719,12 @@ vec_elems : [expr [',' expr]*] | [expr ',' ".." expr] A [_vector_](#vector-types) _expression_ is written by enclosing zero or more comma-separated expressions of uniform type in square brackets. -The keyword `mut` can be written after the opening bracket to -indicate that the elements of the resulting vector may be mutated. -When no mutability is specified, the vector is immutable. ~~~~ [1, 2, 3, 4]; ["a", "b", "c", "d"]; [0, ..128]; // vector with 128 zeros -[mut 0u8, 0u8, 0u8, 0u8]; +[0u8, 0u8, 0u8, 0u8]; ~~~~ ### Index expressions @@ -1746,7 +1746,6 @@ task in a _failing state_. # do task::spawn_unlinked { ([1, 2, 3, 4])[0]; -([mut 'x', 'y'])[1] = 'z'; (["a", "b"])[10]; // fails # } @@ -1909,8 +1908,8 @@ No allocation or destruction is entailed. An example of three different swap expressions: ~~~~~~~~ -# let mut x = &[mut 0]; -# let mut a = &[mut 0]; +# let mut x = &mut [0]; +# let mut a = &mut [0]; # let i = 0; # let y = {mut z: 0}; # let b = {mut c: 0}; @@ -2005,11 +2004,11 @@ the unary copy operator is typically only used to cause an argument to a functio An example of a copy expression: ~~~~ -fn mutate(vec: ~[mut int]) { +fn mutate(mut vec: ~[int]) { vec[0] = 10; } -let v = ~[mut 1,2,3]; +let v = ~[1,2,3]; mutate(copy v); // Pass a copy @@ -2291,9 +2290,9 @@ enum List<X> { Nil, Cons(X, @List<X>) } let x: List<int> = Cons(10, @Cons(11, @Nil)); match x { - Cons(_, @Nil) => fail ~"singleton list", + Cons(_, @Nil) => die!(~"singleton list"), Cons(*) => return, - Nil => fail ~"empty list" + Nil => die!(~"empty list") } ~~~~ @@ -2330,7 +2329,7 @@ match x { return; } _ => { - fail; + die!(); } } ~~~~ @@ -2418,23 +2417,10 @@ guard may refer to the variables bound within the pattern they follow. let message = match maybe_digit { Some(x) if x < 10 => process_digit(x), Some(x) => process_other(x), - None => fail + None => die!() }; ~~~~ - -### Fail expressions - -~~~~~~~~{.ebnf .gram} -fail_expr : "fail" expr ? ; -~~~~~~~~ - -Evaluating a `fail` expression causes a task to enter the *failing* state. In -the *failing* state, a task unwinds its stack, destroying all frames and -running all destructors until it reaches its entry frame, at which point it -halts execution in the *dead* state. - - ### Return expressions ~~~~~~~~{.ebnf .gram} @@ -2822,7 +2808,7 @@ trait Printable { } impl int: Printable { - fn to_str() -> ~str { int::to_str(self, 10) } + fn to_str() -> ~str { int::to_str(self) } } fn print(a: @Printable) { @@ -3154,7 +3140,7 @@ unblock and transition back to *running*. A task may transition to the *failing* state at any time, due being killed by some external event or internally, from the evaluation of a -`fail` expression. Once *failing*, a task unwinds its stack and +`fail!()` macro. Once *failing*, a task unwinds its stack and transitions to the *dead* state. Unwinding the stack of a task is done by the task itself, on its own control stack. If a value with a destructor is freed during unwinding, the code for the destructor is run, also on the task's diff --git a/doc/tutorial-macros.md b/doc/tutorial-macros.md index d1dd14a6d0a..4db584f2065 100644 --- a/doc/tutorial-macros.md +++ b/doc/tutorial-macros.md @@ -218,7 +218,7 @@ match x { // complicated stuff goes here return result + val; }, - _ => fail ~"Didn't get good_2" + _ => die!(~"Didn't get good_2") } } _ => return 0 // default value @@ -260,7 +260,7 @@ macro_rules! biased_match ( biased_match!((x) ~ (good_1(g1, val)) else { return 0 }; binds g1, val ) biased_match!((g1.body) ~ (good_2(result) ) - else { fail ~"Didn't get good_2" }; + else { die!(~"Didn't get good_2") }; binds result ) // complicated stuff goes here return result + val; @@ -362,7 +362,7 @@ macro_rules! biased_match ( # fn f(x: t1) -> uint { biased_match!( (x) ~ (good_1(g1, val)) else { return 0 }; - (g1.body) ~ (good_2(result) ) else { fail ~"Didn't get good_2" }; + (g1.body) ~ (good_2(result) ) else { die!(~"Didn't get good_2") }; binds val, result ) // complicated stuff goes here return result + val; diff --git a/doc/tutorial-tasks.md b/doc/tutorial-tasks.md index 98ed6b86584..f814970375a 100644 --- a/doc/tutorial-tasks.md +++ b/doc/tutorial-tasks.md @@ -13,7 +13,7 @@ cheaper to create than traditional threads, Rust can create hundreds of thousands of concurrent tasks on a typical 32-bit system. Tasks provide failure isolation and recovery. When an exception occurs in Rust -code (as a result of an explicit call to `fail`, an assertion failure, or +code (as a result of an explicit call to `fail!()`, an assertion failure, or another invalid operation), the runtime system destroys the entire task. Unlike in languages such as Java and C++, there is no way to `catch` an exception. Instead, tasks may monitor each other for failure. @@ -296,9 +296,9 @@ let result = ports.foldl(0, |accum, port| *accum + port.recv() ); # Handling task failure -Rust has a built-in mechanism for raising exceptions. The `fail` construct -(which can also be written with an error string as an argument: `fail -~reason`) and the `assert` construct (which effectively calls `fail` if a +Rust has a built-in mechanism for raising exceptions. The `fail!()` macro +(which can also be written with an error string as an argument: `fail!( +~reason)`) and the `assert` construct (which effectively calls `fail!()` if a boolean expression is false) are both ways to raise exceptions. When a task raises an exception the task unwinds its stack---running destructors and freeing memory along the way---and then exits. Unlike exceptions in C++, @@ -313,7 +313,7 @@ of all tasks are intertwined: if one fails, so do all the others. # fn do_some_work() { loop { task::yield() } } # do task::try { // Create a child task that fails -do spawn { fail } +do spawn { die!() } // This will also fail because the task we spawned failed do_some_work(); @@ -337,7 +337,7 @@ let result: Result<int, ()> = do task::try { if some_condition() { calculate_result() } else { - fail ~"oops!"; + die!(~"oops!"); } }; assert result.is_err(); @@ -354,7 +354,7 @@ an `Error` result. > ***Note:*** A failed task does not currently produce a useful error > value (`try` always returns `Err(())`). In the > future, it may be possible for tasks to intercept the value passed to -> `fail`. +> `fail!()`. TODO: Need discussion of `future_result` in order to make failure modes useful. @@ -377,7 +377,7 @@ either task dies, it kills the other one. # do task::try { do task::spawn { do task::spawn { - fail; // All three tasks will die. + die!(); // All three tasks will die. } sleep_forever(); // Will get woken up by force, then fail } @@ -432,7 +432,7 @@ do task::spawn_supervised { // Intermediate task immediately exits } wait_for_a_while(); -fail; // Will kill grandchild even if child has already exited +die!(); // Will kill grandchild even if child has already exited # }; ~~~ @@ -446,10 +446,10 @@ other at all, using `task::spawn_unlinked` for _isolated failure_. let (time1, time2) = (random(), random()); do task::spawn_unlinked { sleep_for(time2); // Won't get forced awake - fail; + die!(); } sleep_for(time1); // Won't get forced awake -fail; +die!(); // It will take MAX(time1,time2) for the program to finish. # }; ~~~ @@ -473,7 +473,7 @@ fn stringifier(channel: &DuplexStream<~str, uint>) { let mut value: uint; loop { value = channel.recv(); - channel.send(uint::to_str(value, 10)); + channel.send(uint::to_str(value)); if value == 0 { break; } } } @@ -497,7 +497,7 @@ Here is the code for the parent task: # let mut value: uint; # loop { # value = channel.recv(); -# channel.send(uint::to_str(value, 10u)); +# channel.send(uint::to_str(value)); # if value == 0u { break; } # } # } diff --git a/doc/tutorial.md b/doc/tutorial.md index 6ccf13a8d4d..1087689b9be 100644 --- a/doc/tutorial.md +++ b/doc/tutorial.md @@ -1791,11 +1791,11 @@ illegal to copy and pass by value. Generic `type`, `struct`, and `enum` declarations follow the same pattern: ~~~~ -# use std::map::HashMap; +# use std::oldmap::HashMap; type Set<T> = HashMap<T, ()>; struct Stack<T> { - elements: ~[mut T] + elements: ~[T] } enum Option<T> { diff --git a/mk/rt.mk b/mk/rt.mk index efabfc39749..81ccbf4b7ad 100644 --- a/mk/rt.mk +++ b/mk/rt.mk @@ -57,15 +57,12 @@ RUNTIME_CXXS_$(1) := \ rt/rust_sched_reaper.cpp \ rt/rust_task.cpp \ rt/rust_stack.cpp \ - rt/rust_port.cpp \ rt/rust_upcall.cpp \ rt/rust_uv.cpp \ rt/rust_crate_map.cpp \ rt/rust_log.cpp \ rt/rust_gc_metadata.cpp \ - rt/rust_port_selector.cpp \ rt/rust_util.cpp \ - rt/circular_buffer.cpp \ rt/isaac/randport.cpp \ rt/miniz.cpp \ rt/rust_kernel.cpp \ diff --git a/mk/target.mk b/mk/target.mk index 5694c907950..67bb055dfc7 100644 --- a/mk/target.mk +++ b/mk/target.mk @@ -14,13 +14,6 @@ # $(2) is the target triple # $(3) is the host triple -# If you are making non-backwards compatible changes to the runtime -# (resp. corelib), set this flag to 1. It will cause stage1 to use -# the snapshot runtime (resp. corelib) rather than the runtime -# (resp. corelib) from the working directory. -USE_SNAPSHOT_RUNTIME=0 -USE_SNAPSHOT_CORELIB=0 -USE_SNAPSHOT_STDLIB=0 define TARGET_STAGE_N @@ -59,86 +52,17 @@ $$(TLIB$(1)_T_$(2)_H_$(3))/$$(CFG_LIBSYNTAX): \ @$$(call E, compile_and_link: $$@) $$(STAGE$(1)_T_$(2)_H_$(3)) $(BORROWCK) -o $$@ $$< && touch $$@ -endef - -# The stage0 (snapshot) compiler produces binaries that expect the -# snapshot runtime. Normally the working directory runtime and -# snapshot runtime are compatible, so this is no problem. But -# sometimes we want to make non-backwards-compatible changes. In -# those cases, the stage1 compiler and libraries (which are produced -# by stage0) should use the runtime from the snapshot. The stage2 -# compiler and libraries (which are produced by stage1) will be the -# first that are expecting to run against the runtime as defined in -# the working directory. -# -# The catch is that you may not add new functions to the runtime -# in this case! -# -# Arguments are the same as for TARGET_BASE_STAGE_N -define TARGET_RT_FROM_SNAPSHOT - -$$(TLIB$(1)_T_$(2)_H_$(3))/$$(CFG_RUNTIME): \ - $$(HLIB$(1)_H_$(3))/$$(CFG_RUNTIME) - @$$(call E, cp: $$@) - $$(Q)cp $$< $$@ - -endef - -# This rule copies from the runtime for the working directory. It -# applies to targets produced by stage1 or later. See comment on -# previous rule. -# -# Arguments are the same as for TARGET_BASE_STAGE_N -define TARGET_RT_FROM_WD - $$(TLIB$(1)_T_$(2)_H_$(3))/$$(CFG_RUNTIME): \ rt/$(2)/$$(CFG_RUNTIME) @$$(call E, cp: $$@) $$(Q)cp $$< $$@ -endef - -# As above, but builds the corelib either by taking it out of the -# snapshot or from the working directory. - -define TARGET_CORELIB_FROM_SNAPSHOT - -$$(TLIB$(1)_T_$(2)_H_$(3))/$$(CFG_CORELIB): \ - $$(HLIB$(1)_H_$(3))/$$(CFG_CORELIB) \ - $$(CORELIB_INPUTS) \ - $$(TSREQ$(1)_T_$(2)_H_$(3)) - @$$(call E, cp: $$@) - $$(Q)cp $$< $$@ - $$(Q)cp $$(HLIB$(1)_H_$(3))/$$(CORELIB_GLOB) \ - $$(TLIB$(1)_T_$(2)_H_$(3)) - -endef - -define TARGET_CORELIB_FROM_WD - $$(TLIB$(1)_T_$(2)_H_$(3))/$$(CFG_CORELIB): \ $$(CORELIB_CRATE) $$(CORELIB_INPUTS) \ $$(TSREQ$(1)_T_$(2)_H_$(3)) @$$(call E, compile_and_link: $$@) $$(STAGE$(1)_T_$(2)_H_$(3)) -o $$@ $$< && touch $$@ -endef - -define TARGET_STDLIB_FROM_SNAPSHOT - -$$(TLIB$(1)_T_$(2)_H_$(3))/$$(CFG_STDLIB): \ - $$(HLIB$(1)_H_$(3))/$$(CFG_STDLIB) \ - $$(STDLIB_INPUTS) \ - $$(TSREQ$(1)_T_$(2)_H_$(3)) - @$$(call E, cp: $$@) - $$(Q)cp $$< $$@ - $$(Q)cp $$(HLIB$(1)_H_$(3))/$$(STDLIB_GLOB) \ - $$(TLIB$(1)_T_$(2)_H_$(3)) - -endef - -define TARGET_STDLIB_FROM_WD - $$(TLIB$(1)_T_$(2)_H_$(3))/$$(CFG_STDLIB): \ $$(STDLIB_CRATE) $$(STDLIB_INPUTS) \ $$(TLIB$(1)_T_$(2)_H_$(3))/$$(CFG_CORELIB) \ @@ -155,52 +79,3 @@ $(foreach source,$(CFG_TARGET_TRIPLES), \ $(eval $(call TARGET_STAGE_N,1,$(target),$(source))) \ $(eval $(call TARGET_STAGE_N,2,$(target),$(source))) \ $(eval $(call TARGET_STAGE_N,3,$(target),$(source))))) - -# Host triple either uses the snapshot runtime or runtime from -# working directory, depending on the USE_SNAPSHOT_RUNTIME var. -ifeq ($(USE_SNAPSHOT_RUNTIME),1) - $(foreach src,$(CFG_HOST_TRIPLE),\ - $(eval $(call TARGET_RT_FROM_SNAPSHOT,0,$(src),$(src)))) -else - $(foreach src,$(CFG_HOST_TRIPLE),\ - $(eval $(call TARGET_RT_FROM_WD,0,$(src),$(src)))) -endif - -ifeq ($(USE_SNAPSHOT_CORELIB),1) - $(foreach src,$(CFG_HOST_TRIPLE),\ - $(eval $(call TARGET_CORELIB_FROM_SNAPSHOT,0,$(src),$(src)))) -else - $(foreach src,$(CFG_HOST_TRIPLE),\ - $(eval $(call TARGET_CORELIB_FROM_WD,0,$(src),$(src)))) -endif - -ifeq ($(USE_SNAPSHOT_STDLIB),1) - $(foreach src,$(CFG_HOST_TRIPLE),\ - $(eval $(call TARGET_STDLIB_FROM_SNAPSHOT,0,$(src),$(src)))) -else - $(foreach src,$(CFG_HOST_TRIPLE),\ - $(eval $(call TARGET_STDLIB_FROM_WD,0,$(src),$(src)))) -endif - -# Non-host triples build the stage0 runtime from the working directory -$(foreach source,$(CFG_TARGET_TRIPLES), \ - $(foreach target,$(NON_HOST_TRIPLES), \ - $(eval $(call TARGET_RT_FROM_WD,0,$(target),$(source))) \ - $(eval $(call TARGET_CORELIB_FROM_WD,0,$(target),$(source))) \ - $(eval $(call TARGET_STDLIB_FROM_WD,0,$(target),$(source))) \ -)) - -# After stage0, always build the stage0 runtime from the working directory -$(foreach source,$(CFG_TARGET_TRIPLES), \ - $(foreach target,$(CFG_TARGET_TRIPLES), \ - $(eval $(call TARGET_RT_FROM_WD,1,$(target),$(source))) \ - $(eval $(call TARGET_RT_FROM_WD,2,$(target),$(source))) \ - $(eval $(call TARGET_RT_FROM_WD,3,$(target),$(source))) \ - $(eval $(call TARGET_CORELIB_FROM_WD,1,$(target),$(source))) \ - $(eval $(call TARGET_CORELIB_FROM_WD,2,$(target),$(source))) \ - $(eval $(call TARGET_CORELIB_FROM_WD,3,$(target),$(source))) \ - $(eval $(call TARGET_STDLIB_FROM_WD,1,$(target),$(source))) \ - $(eval $(call TARGET_STDLIB_FROM_WD,2,$(target),$(source))) \ - $(eval $(call TARGET_STDLIB_FROM_WD,3,$(target),$(source))) \ -)) - diff --git a/src/README.txt b/src/README.txt index 92312c6a9fa..c8029098cfa 100644 --- a/src/README.txt +++ b/src/README.txt @@ -17,6 +17,7 @@ rt/sync - Concurrency utils rt/util - Small utility classes for the runtime. rt/vg - Valgrind headers rt/msvc - MSVC support +rt/linenoise - a readline-like line editing library test/ Testsuite test/compile-fail - Tests that should fail to compile diff --git a/src/compiletest/compiletest.rc b/src/compiletest/compiletest.rc index 4f9c86b70f0..8f5f9547c52 100644 --- a/src/compiletest/compiletest.rc +++ b/src/compiletest/compiletest.rc @@ -69,7 +69,7 @@ pub fn parse_config(args: ~[~str]) -> config { let matches = &match getopts::getopts(args_, opts) { Ok(m) => m, - Err(f) => fail getopts::fail_str(f) + Err(f) => die!(getopts::fail_str(f)) }; fn opt_path(m: &getopts::Matches, nm: ~str) -> Path { @@ -131,7 +131,7 @@ pub fn str_mode(s: ~str) -> mode { ~"run-fail" => mode_run_fail, ~"run-pass" => mode_run_pass, ~"pretty" => mode_pretty, - _ => fail ~"invalid mode" + _ => die!(~"invalid mode") } } @@ -148,7 +148,7 @@ pub fn run_tests(config: config) { let opts = test_opts(config); let tests = make_tests(config); let res = test::run_tests_console(&opts, tests); - if !res { fail ~"Some tests failed"; } + if !res { die!(~"Some tests failed"); } } pub fn test_opts(config: config) -> test::TestOpts { diff --git a/src/compiletest/header.rs b/src/compiletest/header.rs index 64192e523db..0b9d67426ae 100644 --- a/src/compiletest/header.rs +++ b/src/compiletest/header.rs @@ -119,7 +119,7 @@ fn parse_exec_env(line: ~str) -> Option<(~str, ~str)> { match strs.len() { 1u => (strs[0], ~""), 2u => (strs[0], strs[1]), - n => fail fmt!("Expected 1 or 2 strings, not %u", n) + n => die!(fmt!("Expected 1 or 2 strings, not %u", n)) } } } diff --git a/src/compiletest/procsrv.rs b/src/compiletest/procsrv.rs index 8e575ca36f6..a8e4d91d89a 100644 --- a/src/compiletest/procsrv.rs +++ b/src/compiletest/procsrv.rs @@ -71,7 +71,7 @@ pub fn run(lib_path: ~str, os::close(pipe_in.out); os::close(pipe_out.in); os::close(pipe_err.in); - fail; + die!(); } @@ -99,7 +99,7 @@ pub fn run(lib_path: ~str, (2, s) => { errs = s; } - _ => { fail } + _ => { die!() } }; count -= 1; }; diff --git a/src/compiletest/runtest.rs b/src/compiletest/runtest.rs index e9c37115c49..a71b8a360a2 100644 --- a/src/compiletest/runtest.rs +++ b/src/compiletest/runtest.rs @@ -200,7 +200,7 @@ actual:\n\ \n", expected, actual); io::stdout().write_str(msg); - fail; + die!(); } } @@ -467,7 +467,7 @@ fn compose_and_run_compiler( fn ensure_dir(path: &Path) { if os::path_is_dir(path) { return; } if !os::make_dir(path, 0x1c0i32) { - fail fmt!("can't make dir %s", path.to_str()); + die!(fmt!("can't make dir %s", path.to_str())); } } @@ -617,7 +617,7 @@ fn maybe_dump_to_stdout(config: config, out: ~str, err: ~str) { fn error(err: ~str) { io::stdout().write_line(fmt!("\nerror: %s", err)); } -fn fatal(err: ~str) -> ! { error(err); fail; } +fn fatal(err: ~str) -> ! { error(err); die!(); } fn fatal_ProcRes(err: ~str, ProcRes: ProcRes) -> ! { let msg = @@ -635,5 +635,5 @@ stderr:\n\ \n", err, ProcRes.cmdline, ProcRes.stdout, ProcRes.stderr); io::stdout().write_str(msg); - fail; + die!(); } diff --git a/src/etc/vim/syntax/rust.vim b/src/etc/vim/syntax/rust.vim index af308f23a31..4ff7783888f 100644 --- a/src/etc/vim/syntax/rust.vim +++ b/src/etc/vim/syntax/rust.vim @@ -12,25 +12,24 @@ endif syn match rustAssert "\<assert\(\w\)*" syn keyword rustKeyword as break -syn keyword rustKeyword const copy do drop else export extern fail +syn keyword rustKeyword copy do drop else extern syn keyword rustKeyword for if impl let log -syn keyword rustKeyword loop match mod move mut once priv pure -syn match rustKeyword "\<pub\>" +syn keyword rustKeyword loop match mod move once priv pub pure syn keyword rustKeyword ref return static -syn match rustKeyword "\<unsafe\>" " Allows also matching unsafe::foo() -syn keyword rustKeyword use while +syn keyword rustKeyword unsafe use while " FIXME: Scoped impl's name is also fallen in this category syn keyword rustKeyword mod trait struct enum type nextgroup=rustIdentifier skipwhite syn keyword rustKeyword fn nextgroup=rustFuncName skipwhite +syn keyword rustStorage const mut syn match rustIdentifier contains=rustIdentifierPrime "\%([^[:cntrl:][:space:][:punct:][:digit:]]\|_\)\%([^[:cntrl:][:punct:][:space:]]\|_\)*" display contained syn match rustFuncName "\%([^[:cntrl:][:space:][:punct:][:digit:]]\|_\)\%([^[:cntrl:][:punct:][:space:]]\|_\)*" display contained " Reserved words -syn keyword rustKeyword m32 m64 m128 f80 f16 f128 +syn keyword rustKeyword m32 m64 m128 f80 f16 f128 be syn keyword rustType int uint float char bool u8 u16 u32 u64 f32 -syn keyword rustType f64 i8 i16 i32 i64 str +syn keyword rustType f64 i8 i16 i32 i64 str Self syn keyword rustType Option Either " Types from libc @@ -134,6 +133,7 @@ hi def link rustMacro Macro hi def link rustType Type hi def link rustTodo Todo hi def link rustAttribute PreProc +hi def link rustStorage StorageClass " Other Suggestions: " hi rustAssert ctermfg=yellow diff --git a/src/libcargo/cargo.rc b/src/libcargo/cargo.rc index bb5e3f9f74d..960bcf88eb7 100644 --- a/src/libcargo/cargo.rc +++ b/src/libcargo/cargo.rc @@ -53,8 +53,8 @@ use core::io::WriterUtil; use core::result::{Ok, Err}; use core::hashmap::linear::LinearMap; use std::getopts::{optflag, optopt, opt_present}; -use std::map::HashMap; -use std::{map, json, tempfile, term, sort, getopts}; +use std::oldmap::HashMap; +use std::{oldmap, json, tempfile, term, sort, getopts}; use syntax::codemap::span; use syntax::diagnostic::span_handler; use syntax::diagnostic; @@ -110,9 +110,9 @@ pub struct Cargo { libdir: Path, workdir: Path, sourcedir: Path, - sources: map::HashMap<~str, @Source>, + sources: oldmap::HashMap<~str, @Source>, mut current_install: ~str, - dep_cache: map::HashMap<~str, bool>, + dep_cache: oldmap::HashMap<~str, bool>, opts: Options } @@ -286,7 +286,7 @@ pub fn load_link(mis: ~[@ast::meta_item]) -> (Option<~str>, let mut uuid = None; for mis.each |a| { match a.node { - ast::meta_name_value(v, ast::spanned { node: ast::lit_str(s), + ast::meta_name_value(v, codemap::spanned { node: ast::lit_str(s), _ }) => { match v { ~"name" => name = Some(*s), @@ -295,7 +295,7 @@ pub fn load_link(mis: ~[@ast::meta_item]) -> (Option<~str>, _ => { } } } - _ => fail ~"load_link: meta items must be name-values" + _ => die!(~"load_link: meta items must be name-values") } } (name, vers, uuid) @@ -314,7 +314,7 @@ pub fn load_crate(filename: &Path) -> Option<Crate> { for c.node.attrs.each |a| { match a.node.value.node { - ast::meta_name_value(v, ast::spanned { node: ast::lit_str(_), + ast::meta_name_value(v, codemap::spanned { node: ast::lit_str(_), _ }) => { match v { ~"desc" => desc = Some(v), @@ -332,8 +332,8 @@ pub fn load_crate(filename: &Path) -> Option<Crate> { } } _ => { - fail ~"crate attributes may not contain " + - ~"meta_words"; + die!(~"crate attributes may not contain " + + ~"meta_words"); } } } @@ -435,7 +435,7 @@ pub fn rest(s: ~str, start: uint) -> ~str { pub fn need_dir(s: &Path) { if os::path_is_dir(s) { return; } if !os::make_dir(s, 493_i32 /* oct: 755 */) { - fail fmt!("can't make_dir %s", s.to_str()); + die!(fmt!("can't make_dir %s", s.to_str())); } } @@ -453,14 +453,14 @@ pub fn valid_pkg_name(s: &str) -> bool { pub fn parse_source(name: ~str, j: &json::Json) -> @Source { if !valid_pkg_name(name) { - fail fmt!("'%s' is an invalid source name", name); + die!(fmt!("'%s' is an invalid source name", name)); } match *j { json::Object(j) => { let mut url = match j.find(&~"url") { Some(&json::String(u)) => copy u, - _ => fail ~"needed 'url' field in source" + _ => die!(~"needed 'url' field in source") }; let method = match j.find(&~"method") { Some(&json::String(u)) => copy u, @@ -485,12 +485,12 @@ pub fn parse_source(name: ~str, j: &json::Json) -> @Source { mut keyfp: keyfp, packages: DVec() }; } - _ => fail ~"needed dict value in source" + _ => die!(~"needed dict value in source") }; } pub fn try_parse_sources(filename: &Path, - sources: map::HashMap<~str, @Source>) { + sources: oldmap::HashMap<~str, @Source>) { if !os::path_exists(filename) { return; } let c = io::read_whole_file_str(filename); match json::from_str(c.get()) { @@ -500,8 +500,8 @@ pub fn try_parse_sources(filename: &Path, debug!("source: %s", *k); } } - Ok(_) => fail ~"malformed sources.json", - Err(e) => fail fmt!("%s:%s", filename.to_str(), e.to_str()) + Ok(_) => die!(~"malformed sources.json"), + Err(e) => die!(fmt!("%s:%s", filename.to_str(), e.to_str())) } } @@ -662,7 +662,7 @@ pub fn build_cargo_options(argv: ~[~str]) -> Options { let matches = &match getopts::getopts(argv, opts()) { result::Ok(m) => m, result::Err(f) => { - fail fmt!("%s", getopts::fail_str(f)); + die!(fmt!("%s", getopts::fail_str(f))); } }; @@ -675,10 +675,10 @@ pub fn build_cargo_options(argv: ~[~str]) -> Options { let is_install = len > 1u && matches.free[1] == ~"install"; let is_uninstall = len > 1u && matches.free[1] == ~"uninstall"; - if G && g { fail ~"-G and -g both provided"; } + if G && g { die!(~"-G and -g both provided"); } if !is_install && !is_uninstall && (g || G) { - fail ~"-g and -G are only valid for `install` and `uninstall|rm`"; + die!(~"-g and -G are only valid for `install` and `uninstall|rm`"); } let mode = @@ -730,7 +730,7 @@ pub fn configure(opts: Options) -> Cargo { need_dir(&c.libdir); need_dir(&c.bindir); - for sources.each_key |k| { + for sources.each_key_ref |&k| { let mut s = sources.get(k); load_source_packages(&c, s); sources.insert(k, s); @@ -748,7 +748,7 @@ pub fn configure(opts: Options) -> Cargo { } pub fn for_each_package(c: &Cargo, b: fn(s: @Source, p: &Package)) { - for c.sources.each_value |v| { + for c.sources.each_value_ref |&v| { for v.packages.each |p| { b(v, p); } @@ -833,7 +833,7 @@ pub fn rustc_sysroot() -> ~str { } } -pub fn install_source(c: &Cargo, path: &Path) { +pub fn install_source(c: &mut Cargo, path: &Path) { debug!("source: %s", path.to_str()); os::change_dir(path); @@ -845,7 +845,7 @@ pub fn install_source(c: &Cargo, path: &Path) { } if vec::is_empty(cratefiles) { - fail ~"this doesn't look like a rust package (no .rc files)"; + die!(~"this doesn't look like a rust package (no .rc files)"); } for cratefiles.each |cf| { @@ -872,7 +872,8 @@ pub fn install_source(c: &Cargo, path: &Path) { } } -pub fn install_git(c: &Cargo, wd: &Path, url: ~str, reference: Option<~str>) { +pub fn install_git(c: &mut Cargo, wd: &Path, url: ~str, + reference: Option<~str>) { run::program_output(~"git", ~[~"clone", url, wd.to_str()]); if reference.is_some() { let r = reference.get(); @@ -883,12 +884,12 @@ pub fn install_git(c: &Cargo, wd: &Path, url: ~str, reference: Option<~str>) { install_source(c, wd); } -pub fn install_curl(c: &Cargo, wd: &Path, url: ~str) { +pub fn install_curl(c: &mut Cargo, wd: &Path, url: ~str) { let tarpath = wd.push("pkg.tar"); let p = run::program_output(~"curl", ~[~"-f", ~"-s", ~"-o", tarpath.to_str(), url]); if p.status != 0 { - fail fmt!("fetch of %s failed: %s", url, p.err); + die!(fmt!("fetch of %s failed: %s", url, p.err)); } run::run_program(~"tar", ~[~"-x", ~"--strip-components=1", ~"-C", wd.to_str(), @@ -896,14 +897,14 @@ pub fn install_curl(c: &Cargo, wd: &Path, url: ~str) { install_source(c, wd); } -pub fn install_file(c: &Cargo, wd: &Path, path: &Path) { +pub fn install_file(c: &mut Cargo, wd: &Path, path: &Path) { run::program_output(~"tar", ~[~"-x", ~"--strip-components=1", ~"-C", wd.to_str(), ~"-f", path.to_str()]); install_source(c, wd); } -pub fn install_package(c: &Cargo, src: ~str, wd: &Path, pkg: Package) { +pub fn install_package(c: &mut Cargo, src: ~str, wd: &Path, pkg: Package) { let url = copy pkg.url; let method = match pkg.method { ~"git" => ~"git", @@ -922,7 +923,7 @@ pub fn install_package(c: &Cargo, src: ~str, wd: &Path, pkg: Package) { } pub fn cargo_suggestion(c: &Cargo, fallback: fn()) { - if c.sources.size() == 0u { + if c.sources.is_empty() { error(~"no sources defined - you may wish to run " + ~"`cargo init`"); return; @@ -930,7 +931,7 @@ pub fn cargo_suggestion(c: &Cargo, fallback: fn()) { fallback(); } -pub fn install_uuid(c: &Cargo, wd: &Path, uuid: ~str) { +pub fn install_uuid(c: &mut Cargo, wd: &Path, uuid: ~str) { let mut ps = ~[]; for_each_package(c, |s, p| { if p.uuid == uuid { @@ -954,7 +955,7 @@ pub fn install_uuid(c: &Cargo, wd: &Path, uuid: ~str) { } } -pub fn install_named(c: &Cargo, wd: &Path, name: ~str) { +pub fn install_named(c: &mut Cargo, wd: &Path, name: ~str) { let mut ps = ~[]; for_each_package(c, |s, p| { if p.name == name { @@ -978,7 +979,8 @@ pub fn install_named(c: &Cargo, wd: &Path, name: ~str) { } } -pub fn install_uuid_specific(c: &Cargo, wd: &Path, src: ~str, uuid: ~str) { +pub fn install_uuid_specific(c: &mut Cargo, wd: &Path, src: ~str, + uuid: ~str) { match c.sources.find(src) { Some(s) => { for s.packages.each |p| { @@ -993,7 +995,8 @@ pub fn install_uuid_specific(c: &Cargo, wd: &Path, src: ~str, uuid: ~str) { error(~"can't find package: " + src + ~"/" + uuid); } -pub fn install_named_specific(c: &Cargo, wd: &Path, src: ~str, name: ~str) { +pub fn install_named_specific(c: &mut Cargo, wd: &Path, src: ~str, + name: ~str) { match c.sources.find(src) { Some(s) => { for s.packages.each |p| { @@ -1060,7 +1063,7 @@ pub fn cmd_uninstall(c: &Cargo) { } } -pub fn install_query(c: &Cargo, wd: &Path, target: ~str) { +pub fn install_query(c: &mut Cargo, wd: &Path, target: ~str) { match c.dep_cache.find(target) { Some(inst) => { if inst { @@ -1112,10 +1115,7 @@ pub fn install_query(c: &Cargo, wd: &Path, target: ~str) { // a bit of a hack. It should be cleaned up in the future. if target == c.current_install { - for c.dep_cache.each |k, _v| { - c.dep_cache.remove(k); - } - + c.dep_cache.clear(); c.current_install = ~""; } } @@ -1123,12 +1123,12 @@ pub fn install_query(c: &Cargo, wd: &Path, target: ~str) { pub fn get_temp_workdir(c: &Cargo) -> Path { match tempfile::mkdtemp(&c.workdir, "cargo") { Some(wd) => wd, - None => fail fmt!("needed temp dir: %s", - c.workdir.to_str()) + None => die!(fmt!("needed temp dir: %s", + c.workdir.to_str())) } } -pub fn cmd_install(c: &Cargo) { +pub fn cmd_install(c: &mut Cargo) { unsafe { let wd = get_temp_workdir(c); @@ -1138,7 +1138,7 @@ pub fn cmd_install(c: &Cargo) { wd.to_str()]); if status != 0 { - fail fmt!("could not copy directory: %s", cwd.to_str()); + die!(fmt!("could not copy directory: %s", cwd.to_str())); } install_source(c, &wd); @@ -1155,7 +1155,7 @@ pub fn cmd_install(c: &Cargo) { } pub fn sync(c: &Cargo) { - for c.sources.each_key |k| { + for c.sources.each_key_ref |&k| { let mut s = c.sources.get(k); sync_one(c, s); c.sources.insert(k, s); @@ -1569,7 +1569,7 @@ pub fn cmd_list(c: &Cargo) { } } } else { - for c.sources.each_value |v| { + for c.sources.each_value_ref |&v| { print_source(v); } } @@ -1620,7 +1620,7 @@ pub fn dump_cache(c: &Cargo) { } pub fn dump_sources(c: &Cargo) { - if c.sources.size() < 1u { + if c.sources.is_empty() { return; } @@ -1636,7 +1636,7 @@ pub fn dump_sources(c: &Cargo) { result::Ok(writer) => { let mut hash = ~LinearMap::new(); - for c.sources.each |k, v| { + for c.sources.each_ref |&k, &v| { let mut chash = ~LinearMap::new(); chash.insert(~"url", json::String(v.url)); @@ -1675,7 +1675,7 @@ pub fn copy_warn(srcfile: &Path, destfile: &Path) { pub fn cmd_sources(c: &Cargo) { if vec::len(c.opts.free) < 3u { - for c.sources.each_value |v| { + for c.sources.each_value_ref |&v| { info(fmt!("%s (%s) via %s", v.name, v.url, v.method)); } @@ -1686,8 +1686,8 @@ pub fn cmd_sources(c: &Cargo) { match action { ~"clear" => { - for c.sources.each_key |k| { - c.sources.remove(k); + for c.sources.each_key_ref |&k| { + c.sources.remove(&k); } info(~"cleared sources"); @@ -1706,7 +1706,7 @@ pub fn cmd_sources(c: &Cargo) { return; } - if c.sources.contains_key(name) { + if c.sources.contains_key_ref(&name) { error(fmt!("source already exists: %s", name)); } else { c.sources.insert(name, @Source { @@ -1733,8 +1733,8 @@ pub fn cmd_sources(c: &Cargo) { return; } - if c.sources.contains_key(name) { - c.sources.remove(name); + if c.sources.contains_key_ref(&name) { + c.sources.remove(&name); info(fmt!("removed source: %s", name)); } else { error(fmt!("no such source: %s", name)); @@ -1825,7 +1825,7 @@ pub fn cmd_sources(c: &Cargo) { match c.sources.find(name) { Some(source) => { - c.sources.remove(name); + c.sources.remove(&name); c.sources.insert(newn, source); info(fmt!("renamed source: %s to %s", name, newn)); } @@ -1967,7 +1967,7 @@ pub fn main() { match o.free[1] { ~"init" => cmd_init(&c), - ~"install" => cmd_install(&c), + ~"install" => cmd_install(&mut c), ~"uninstall" => cmd_uninstall(&c), ~"list" => cmd_list(&c), ~"search" => cmd_search(&c), diff --git a/src/libcargo/pgp.rs b/src/libcargo/pgp.rs index 7eee0f9b96b..18b1c49efb1 100644 --- a/src/libcargo/pgp.rs +++ b/src/libcargo/pgp.rs @@ -87,7 +87,7 @@ pub fn init(root: &Path) { p.input().write_str(signing_key()); let s = p.finish(); if s != 0 { - fail ~"pgp init failed"; + die!(~"pgp init failed"); } } } @@ -98,7 +98,7 @@ pub fn add(root: &Path, key: &Path) { run::program_output(~"gpg", ~[~"--homedir", path.to_str(), ~"--import", key.to_str()]); if p.status != 0 { - fail ~"pgp add failed: " + p.out; + die!(~"pgp add failed: " + p.out); } } diff --git a/src/libcore/char.rs b/src/libcore/char.rs index b656879e7a4..deecdc98ffa 100644 --- a/src/libcore/char.rs +++ b/src/libcore/char.rs @@ -119,6 +119,26 @@ pub pure fn is_digit(c: char) -> bool { } /** + * Checks if a character parses as a numeric digit in the given radix. + * Compared to `is_digit()`, this function only recognizes the ascii + * characters `0-9`, `a-z` and `A-Z`. + * + * Returns `true` if `c` is a valid digit under `radix`, and `false` + * otherwise. + * + * Fails if given a `radix` > 36. + * + * Note: This just wraps `to_digit()`. + */ +#[inline(always)] +pub pure fn is_digit_radix(c: char, radix: uint) -> bool { + match to_digit(c, radix) { + Some(_) => true, + None => false + } +} + +/** * Convert a char to the corresponding digit. * * # Return value @@ -127,9 +147,15 @@ pub pure fn is_digit(c: char) -> bool { * between 0 and 9. If `c` is 'a' or 'A', 10. If `c` is * 'b' or 'B', 11, etc. Returns none if the char does not * refer to a digit in the given radix. + * + * # Failure + * Fails if given a `radix` outside the range `[0..36]`. */ #[inline] pub pure fn to_digit(c: char, radix: uint) -> Option<uint> { + if radix > 36 { + die!(fmt!("to_digit: radix %? is to high (maximum 36)", radix)); + } let val = match c { '0' .. '9' => c as uint - ('0' as uint), 'a' .. 'z' => c as uint + 10u - ('a' as uint), @@ -141,6 +167,30 @@ pub pure fn to_digit(c: char, radix: uint) -> Option<uint> { } /** + * Converts a number to the ascii character representing it. + * + * Returns `Some(char)` if `num` represents one digit under `radix`, + * using one character of `0-9` or `a-z`, or `None` if it doesn't. + * + * Fails if given an `radix` > 36. + */ +#[inline] +pub pure fn from_digit(num: uint, radix: uint) -> Option<char> { + if radix > 36 { + die!(fmt!("from_digit: radix %? is to high (maximum 36)", num)); + } + if num < radix { + if num < 10 { + Some(('0' as uint + num) as char) + } else { + Some(('a' as uint + num - 10u) as char) + } + } else { + None + } +} + +/** * Return the hexadecimal unicode escape of a char. * * The rules are as follows: @@ -150,7 +200,7 @@ pub pure fn to_digit(c: char, radix: uint) -> Option<uint> { * - chars above 0x10000 get 8-digit escapes: `\\UNNNNNNNN` */ pub pure fn escape_unicode(c: char) -> ~str { - let s = u32::to_str(c as u32, 16u); + let s = u32::to_str_radix(c as u32, 16u); let (c, pad) = (if c <= '\xff' { ('x', 2u) } else if c <= '\uffff' { ('u', 4u) } else { ('U', 8u) }); diff --git a/src/libcore/cleanup.rs b/src/libcore/cleanup.rs index 8428484f630..1967f1771be 100644 --- a/src/libcore/cleanup.rs +++ b/src/libcore/cleanup.rs @@ -88,7 +88,6 @@ struct Task { kernel: *Kernel, // 112 name: *c_char, // 116 list_index: i32, // 120 - rendezvous_ptr: *uintptr_t, // 124 boxed_region: BoxedRegion // 128 } @@ -107,7 +106,6 @@ struct Task { kernel: *Kernel, name: *c_char, list_index: i32, - rendezvous_ptr: *uintptr_t, boxed_region: BoxedRegion } diff --git a/src/libcore/condition.rs b/src/libcore/condition.rs index c4001717ca1..8ad4ad7cd8c 100644 --- a/src/libcore/condition.rs +++ b/src/libcore/condition.rs @@ -37,7 +37,7 @@ impl<T, U> Condition<T, U> { fn raise(t: T) -> U { let msg = fmt!("Unhandled condition: %s: %?", self.name, t); - self.raise_default(t, || fail copy msg) + self.raise_default(t, || die!(copy msg)) } fn raise_default(t: T, default: &fn() -> U) -> U { diff --git a/src/libcore/core.rc b/src/libcore/core.rc index 1ac0bf4c0c5..aece60652a2 100644 --- a/src/libcore/core.rc +++ b/src/libcore/core.rc @@ -60,30 +60,33 @@ pub mod prelude; /* Primitive types */ -#[path = "int-template.rs"] #[merge = "int-template/int.rs"] +#[path = "num/int-template.rs"] #[merge = "num/int-template/int.rs"] pub mod int; -#[path = "int-template.rs"] #[merge = "int-template/i8.rs"] +#[path = "num/int-template.rs"] #[merge = "num/int-template/i8.rs"] pub mod i8; -#[path = "int-template.rs"] #[merge = "int-template/i16.rs"] +#[path = "num/int-template.rs"] #[merge = "num/int-template/i16.rs"] pub mod i16; -#[path = "int-template.rs"] #[merge = "int-template/i32.rs"] +#[path = "num/int-template.rs"] #[merge = "num/int-template/i32.rs"] pub mod i32; -#[path = "int-template.rs"] #[merge = "int-template/i64.rs"] +#[path = "num/int-template.rs"] #[merge = "num/int-template/i64.rs"] pub mod i64; -#[path = "uint-template.rs"] #[merge = "uint-template/uint.rs"] +#[path = "num/uint-template.rs"] #[merge = "num/uint-template/uint.rs"] pub mod uint; -#[path = "uint-template.rs"] #[merge = "uint-template/u8.rs"] +#[path = "num/uint-template.rs"] #[merge = "num/uint-template/u8.rs"] pub mod u8; -#[path = "uint-template.rs"] #[merge = "uint-template/u16.rs"] +#[path = "num/uint-template.rs"] #[merge = "num/uint-template/u16.rs"] pub mod u16; -#[path = "uint-template.rs"] #[merge = "uint-template/u32.rs"] +#[path = "num/uint-template.rs"] #[merge = "num/uint-template/u32.rs"] pub mod u32; -#[path = "uint-template.rs"] #[merge = "uint-template/u64.rs"] +#[path = "num/uint-template.rs"] #[merge = "num/uint-template/u64.rs"] pub mod u64; +#[path = "num/float.rs"] pub mod float; +#[path = "num/f32.rs"] pub mod f32; +#[path = "num/f64.rs"] pub mod f64; pub mod nil; @@ -116,6 +119,7 @@ pub mod managed; /* Common traits */ pub mod from_str; +#[path = "num/num.rs"] pub mod num; pub mod iter; pub mod to_str; @@ -144,7 +148,6 @@ pub mod hashmap; /* Tasks and communication */ -pub mod oldcomm; #[path = "task/mod.rs"] pub mod task; pub mod pipes; @@ -233,6 +236,7 @@ pub mod private; /* For internal use, not exported */ mod unicode; +#[path = "num/cmath.rs"] mod cmath; mod stackwalk; @@ -251,6 +255,7 @@ pub mod core { pub use condition; pub use option; pub use kinds; + pub use sys; } diff --git a/src/libcore/dlist.rs b/src/libcore/dlist.rs index fe881f1830a..d4216b283a9 100644 --- a/src/libcore/dlist.rs +++ b/src/libcore/dlist.rs @@ -48,18 +48,18 @@ priv impl<T> DListNode<T> { match self.next { Some(neighbour) => match neighbour.prev { Some(me) => if !managed::ptr_eq(self, me) { - fail ~"Asymmetric next-link in dlist node." + die!(~"Asymmetric next-link in dlist node.") }, - None => fail ~"One-way next-link in dlist node." + None => die!(~"One-way next-link in dlist node.") }, None => () } match self.prev { Some(neighbour) => match neighbour.next { Some(me) => if !managed::ptr_eq(me, self) { - fail ~"Asymmetric prev-link in dlist node." + die!(~"Asymmetric prev-link in dlist node.") }, - None => fail ~"One-way prev-link in dlist node." + None => die!(~"One-way prev-link in dlist node.") }, None => () } @@ -76,7 +76,7 @@ impl<T> DListNode<T> { pure fn next_node(@self) -> @DListNode<T> { match self.next_link() { Some(nobe) => nobe, - None => fail ~"This dlist node has no next neighbour." + None => die!(~"This dlist node has no next neighbour.") } } /// Get the previous node in the list, if there is one. @@ -88,7 +88,7 @@ impl<T> DListNode<T> { pure fn prev_node(@self) -> @DListNode<T> { match self.prev_link() { Some(nobe) => nobe, - None => fail ~"This dlist node has no previous neighbour." + None => die!(~"This dlist node has no previous neighbour.") } } } @@ -135,21 +135,21 @@ priv impl<T> DList<T> { // These asserts could be stronger if we had node-root back-pointers, // but those wouldn't allow for O(1) append. if self.size == 0 { - fail ~"This dlist is empty; that node can't be on it." + die!(~"This dlist is empty; that node can't be on it.") } - if !nobe.linked { fail ~"That node isn't linked to any dlist." } + if !nobe.linked { die!(~"That node isn't linked to any dlist.") } if !((nobe.prev.is_some() || managed::ptr_eq(self.hd.expect(~"headless dlist?"), nobe)) && (nobe.next.is_some() || managed::ptr_eq(self.tl.expect(~"tailless dlist?"), nobe))) { - fail ~"That node isn't on this dlist." + die!(~"That node isn't on this dlist.") } } fn make_mine(nobe: @DListNode<T>) { if nobe.prev.is_some() || nobe.next.is_some() || nobe.linked { - fail ~"Cannot insert node that's already on a dlist!" + die!(~"Cannot insert node that's already on a dlist!") } nobe.linked = true; } @@ -313,14 +313,16 @@ impl<T> DList<T> { pure fn head_n(@self) -> @DListNode<T> { match self.hd { Some(nobe) => nobe, - None => fail ~"Attempted to get the head of an empty dlist." + None => die!( + ~"Attempted to get the head of an empty dlist.") } } /// Get the node at the list's tail, failing if empty. O(1). pure fn tail_n(@self) -> @DListNode<T> { match self.tl { Some(nobe) => nobe, - None => fail ~"Attempted to get the tail of an empty dlist." + None => die!( + ~"Attempted to get the tail of an empty dlist.") } } @@ -333,7 +335,7 @@ impl<T> DList<T> { */ fn append(@self, them: @DList<T>) { if managed::ptr_eq(self, them) { - fail ~"Cannot append a dlist to itself!" + die!(~"Cannot append a dlist to itself!") } if them.len() > 0 { self.link(self.tl, them.hd); @@ -350,7 +352,7 @@ impl<T> DList<T> { */ fn prepend(@self, them: @DList<T>) { if managed::ptr_eq(self, them) { - fail ~"Cannot prepend a dlist to itself!" + die!(~"Cannot prepend a dlist to itself!") } if them.len() > 0 { self.link(them.tl, self.hd); diff --git a/src/libcore/dvec.rs b/src/libcore/dvec.rs index 06431e6590d..2fd7d71a7fc 100644 --- a/src/libcore/dvec.rs +++ b/src/libcore/dvec.rs @@ -91,7 +91,7 @@ priv impl<A> DVec<A> { unsafe { let data: *() = cast::reinterpret_cast(&self.data); if data.is_null() { - fail ~"Recursive use of dvec"; + die!(~"Recursive use of dvec"); } } } @@ -102,7 +102,7 @@ priv impl<A> DVec<A> { let mut data = cast::reinterpret_cast(&null::<()>()); data <-> self.data; let data_ptr: *() = cast::reinterpret_cast(&data); - if data_ptr.is_null() { fail ~"Recursive use of dvec"; } + if data_ptr.is_null() { die!(~"Recursive use of dvec"); } return f(move data); } } @@ -179,7 +179,7 @@ impl<A> DVec<A> { let mut data = cast::reinterpret_cast(&null::<()>()); data <-> self.data; let data_ptr: *() = cast::reinterpret_cast(&data); - if data_ptr.is_null() { fail ~"Recursive use of dvec"; } + if data_ptr.is_null() { die!(~"Recursive use of dvec"); } self.data = move ~[move t]; self.data.push_all_move(move data); } @@ -329,7 +329,7 @@ impl<A: Copy> DVec<A> { let length = self.len(); if length == 0 { - fail ~"attempt to retrieve the last element of an empty vector"; + die!(~"attempt to retrieve the last element of an empty vector"); } return self.data[length - 1]; diff --git a/src/libcore/either.rs b/src/libcore/either.rs index c4f07db6621..6b327b919e5 100644 --- a/src/libcore/either.rs +++ b/src/libcore/either.rs @@ -136,7 +136,7 @@ pub pure fn unwrap_left<T,U>(eith: Either<T,U>) -> T { //! Retrieves the value in the left branch. Fails if the either is Right. match move eith { - Left(move x) => move x, Right(_) => fail ~"either::unwrap_left Right" + Left(move x) => move x, Right(_) => die!(~"either::unwrap_left Right") } } @@ -145,7 +145,7 @@ pub pure fn unwrap_right<T,U>(eith: Either<T,U>) -> U { //! Retrieves the value in the right branch. Fails if the either is Left. match move eith { - Right(move x) => move x, Left(_) => fail ~"either::unwrap_right Left" + Right(move x) => move x, Left(_) => die!(~"either::unwrap_right Left") } } diff --git a/src/libcore/extfmt.rs b/src/libcore/extfmt.rs index 0910975e481..259895da2a5 100644 --- a/src/libcore/extfmt.rs +++ b/src/libcore/extfmt.rs @@ -342,7 +342,7 @@ pub mod ct { } #[cfg(test)] - fn die(s: &str) -> ! { fail s.to_owned() } + fn die(s: &str) -> ! { die!(s.to_owned()) } #[test] fn test_parse_count() { @@ -557,7 +557,7 @@ pub mod rt { pub pure fn conv_float(cv: Conv, f: float) -> ~str { let (to_str, digits) = match cv.precision { CountIs(c) => (float::to_str_exact, c as uint), - CountImplied => (float::to_str, 6u) + CountImplied => (float::to_str_digits, 6u) }; let mut s = unsafe { to_str(f, digits) }; if 0.0 <= f { @@ -590,7 +590,7 @@ pub mod rt { return if prec == 0u && num == 0u { ~"" } else { - let s = uint::to_str(num, radix); + let s = uint::to_str_radix(num, radix); let len = str::char_len(s); if len < prec { let diff = prec - len; diff --git a/src/libcore/gc.rs b/src/libcore/gc.rs index b04d5be5965..8150bfbe0ee 100644 --- a/src/libcore/gc.rs +++ b/src/libcore/gc.rs @@ -312,7 +312,7 @@ fn expect_sentinel() -> bool { false } // heap and stack allocations requiring drop, and runs all // destructors. // -// This should only be called from fail, as it will drop the roots +// This should only be called from fail!, as it will drop the roots // which are *live* on the stack, rather than dropping those that are // dead. pub fn cleanup_stack_for_failure() { diff --git a/src/libcore/hash.rs b/src/libcore/hash.rs index d3d6c5ae242..d676570e1e6 100644 --- a/src/libcore/hash.rs +++ b/src/libcore/hash.rs @@ -286,7 +286,7 @@ impl SipState : io::Writer { } fn seek(&self, _x: int, _s: io::SeekStyle) { - fail; + die!(); } fn tell(&self) -> uint { self.length @@ -354,7 +354,7 @@ impl &SipState : Streaming { let r = self.result_bytes(); let mut s = ~""; for vec::each(r) |b| { - s += uint::to_str(*b as uint, 16u); + s += uint::to_str_radix(*b as uint, 16u); } move s } @@ -449,7 +449,7 @@ pub fn test_siphash() { fn to_hex_str(r: &[u8 * 8]) -> ~str { let mut s = ~""; for vec::each(*r) |b| { - s += uint::to_str(*b as uint, 16u); + s += uint::to_str_radix(*b as uint, 16u); } move s } diff --git a/src/libcore/hashmap.rs b/src/libcore/hashmap.rs index ad3dd290679..adb16a92905 100644 --- a/src/libcore/hashmap.rs +++ b/src/libcore/hashmap.rs @@ -167,7 +167,7 @@ pub mod linear { /// True if there was no previous entry with that key fn insert_internal(&mut self, hash: uint, k: K, v: V) -> bool { match self.bucket_for_key_with_hash(self.buckets, hash, &k) { - TableFull => { fail ~"Internal logic error"; } + TableFull => { die!(~"Internal logic error"); } FoundHole(idx) => { debug!("insert fresh (%?->%?) at idx %?, hash %?", k, v, idx, hash); @@ -301,7 +301,7 @@ pub mod linear { Some(&bkt.value) } None => { - fail ~"LinearMap::find: internal logic error" + die!(~"LinearMap::find: internal logic error") } } } @@ -386,7 +386,7 @@ pub mod linear { pure fn get(&self, k: &K) -> &self/V { match self.find(k) { Some(v) => v, - None => fail fmt!("No entry found for key: %?", k), + None => die!(fmt!("No entry found for key: %?", k)), } } } @@ -623,7 +623,7 @@ mod test_map { assert m.find(&1).is_none(); m.insert(1, 2); match m.find(&1) { - None => fail, + None => die!(), Some(v) => assert *v == 2 } } diff --git a/src/libcore/io.rs b/src/libcore/io.rs index 6d618627ece..b726cf62cfe 100644 --- a/src/libcore/io.rs +++ b/src/libcore/io.rs @@ -611,7 +611,7 @@ impl *libc::FILE: Writer { if nout != len as size_t { error!("error writing buffer"); log(error, os::last_os_error()); - fail; + die!(); } } } @@ -661,7 +661,7 @@ impl fd_t: Writer { if nout < 0 as ssize_t { error!("error writing buffer"); log(error, os::last_os_error()); - fail; + die!(); } count += nout as uint; } @@ -670,11 +670,11 @@ impl fd_t: Writer { } fn seek(&self, _offset: int, _whence: SeekStyle) { error!("need 64-bit foreign calls for seek, sorry"); - fail; + die!(); } fn tell(&self) -> uint { error!("need 64-bit foreign calls for tell, sorry"); - fail; + die!(); } fn flush(&self) -> int { 0 } fn get_type(&self) -> WriterType { @@ -910,7 +910,7 @@ impl<T: Writer> T : WriterUtil { int::to_str_bytes(n, 10u, |bytes| self.write(bytes)) } fn write_uint(&self, n: uint) { - uint::to_str_bytes(false, n, 10u, |bytes| self.write(bytes)) + uint::to_str_bytes(n, 10u, |bytes| self.write(bytes)) } fn write_le_uint(&self, n: uint) { u64_to_le_bytes(n as u64, uint::bytes, |v| self.write(v)) @@ -1279,7 +1279,7 @@ mod tests { result::Err(copy e) => { assert e == ~"error opening not a file"; } - result::Ok(_) => fail + result::Ok(_) => die!() } } @@ -1320,7 +1320,7 @@ mod tests { result::Err(copy e) => { assert str::starts_with(e, "error opening"); } - result::Ok(_) => fail + result::Ok(_) => die!() } } @@ -1330,7 +1330,7 @@ mod tests { result::Err(copy e) => { assert str::starts_with(e, "error opening"); } - result::Ok(_) => fail + result::Ok(_) => die!() } } diff --git a/src/libcore/iter-trait/dlist.rs b/src/libcore/iter-trait/dlist.rs index 5b5f786bac7..cf67d478983 100644 --- a/src/libcore/iter-trait/dlist.rs +++ b/src/libcore/iter-trait/dlist.rs @@ -33,7 +33,7 @@ mod inst { if !f(&nobe.data) { break; } // Check (weakly) that the user didn't do a remove. if self.size == 0 { - fail ~"The dlist became empty during iteration??" + die!(~"The dlist became empty during iteration??") } if !nobe.linked || (!((nobe.prev.is_some() @@ -42,7 +42,7 @@ mod inst { && (nobe.next.is_some() || managed::ptr_eq(self.tl.expect(~"tailless dlist?"), nobe)))) { - fail ~"Removing a dlist node during iteration is forbidden!" + die!(~"Removing a dlist node during iteration is forbidden!") } link = nobe.next_link(); } diff --git a/src/libcore/iter.rs b/src/libcore/iter.rs index 69f7bd3f478..2ffa8702261 100644 --- a/src/libcore/iter.rs +++ b/src/libcore/iter.rs @@ -220,7 +220,7 @@ pub pure fn min<A:Copy Ord,IA:BaseIter<A>>(self: &IA) -> A { } } { Some(move val) => val, - None => fail ~"min called on empty iterator" + None => die!(~"min called on empty iterator") } } @@ -235,7 +235,7 @@ pub pure fn max<A:Copy Ord,IA:BaseIter<A>>(self: &IA) -> A { } } { Some(move val) => val, - None => fail ~"max called on empty iterator" + None => die!(~"max called on empty iterator") } } diff --git a/src/libcore/mutable.rs b/src/libcore/mutable.rs index e5090f02b41..4623a3f4543 100644 --- a/src/libcore/mutable.rs +++ b/src/libcore/mutable.rs @@ -48,8 +48,8 @@ pub fn unwrap<T>(m: Mut<T>) -> T { impl<T> Data<T> { fn borrow_mut<R>(op: &fn(t: &mut T) -> R) -> R { match self.mode { - Immutable => fail fmt!("%? currently immutable", - self.value), + Immutable => die!(fmt!("%? currently immutable", + self.value)), ReadOnly | Mutable => {} } @@ -64,8 +64,8 @@ impl<T> Data<T> { fn borrow_imm<R>(op: &fn(t: &T) -> R) -> R { match self.mode { - Mutable => fail fmt!("%? currently mutable", - self.value), + Mutable => die!(fmt!("%? currently mutable", + self.value)), ReadOnly | Immutable => {} } diff --git a/src/libcore/num.rs b/src/libcore/num.rs deleted file mode 100644 index 5680e3116bf..00000000000 --- a/src/libcore/num.rs +++ /dev/null @@ -1,37 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or -// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license -// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -//! An interface for numeric types - -pub trait Num { - // FIXME: Trait composition. (#2616) - pure fn add(&self, other: &Self) -> Self; - pure fn sub(&self, other: &Self) -> Self; - pure fn mul(&self, other: &Self) -> Self; - pure fn div(&self, other: &Self) -> Self; - pure fn modulo(&self, other: &Self) -> Self; - pure fn neg(&self) -> Self; - - pure fn to_int(&self) -> int; - static pure fn from_int(n: int) -> Self; -} - -pub trait IntConvertible { - pure fn to_int(&self) -> int; - static pure fn from_int(n: int) -> Self; -} - -pub trait Zero { - static pure fn zero() -> Self; -} - -pub trait One { - static pure fn one() -> Self; -} diff --git a/src/libcore/cmath.rs b/src/libcore/num/cmath.rs index 6341481809e..6341481809e 100644 --- a/src/libcore/cmath.rs +++ b/src/libcore/num/cmath.rs diff --git a/src/libcore/f32.rs b/src/libcore/num/f32.rs index 795a9f9371c..24ad5c114af 100644 --- a/src/libcore/f32.rs +++ b/src/libcore/num/f32.rs @@ -18,6 +18,9 @@ use cmath; use cmp; use libc::{c_float, c_int}; use num; +use option::Option; +use from_str; +use to_str; pub use cmath::c_float_targ_consts::*; @@ -306,6 +309,246 @@ pub extern { fn floorf32(val: f32) -> f32; } +impl f32: num::Round { + #[inline(always)] + pure fn round(&self, mode: num::RoundMode) -> f32 { + match mode { + num::RoundDown => floor(*self), + num::RoundUp => ceil(*self), + num::RoundToZero if is_negative(*self) => ceil(*self), + num::RoundToZero => floor(*self), + num::RoundFromZero if is_negative(*self) => floor(*self), + num::RoundFromZero => ceil(*self) + } + } + + #[inline(always)] + pure fn floor(&self) -> f32 { floor(*self) } + #[inline(always)] + pure fn ceil(&self) -> f32 { ceil(*self) } + #[inline(always)] + pure fn fract(&self) -> f32 { + if is_negative(*self) { + (*self) - ceil(*self) + } else { + (*self) - floor(*self) + } + } +} + +/** + * Section: String Conversions + */ + +/** + * Converts a float to a string + * + * # Arguments + * + * * num - The float value + */ +#[inline(always)] +pub pure fn to_str(num: f32) -> ~str { + let (r, _) = num::to_str_common( + &num, 10u, true, true, num::SignNeg, num::DigAll); + r +} + +/** + * Converts a float to a string in hexadecimal format + * + * # Arguments + * + * * num - The float value + */ +#[inline(always)] +pub pure fn to_str_hex(num: f32) -> ~str { + let (r, _) = num::to_str_common( + &num, 16u, true, true, num::SignNeg, num::DigAll); + r +} + +/** + * Converts a float to a string in a given radix + * + * # Arguments + * + * * num - The float value + * * radix - The base to use + * + * # Failure + * + * Fails if called on a special value like `inf`, `-inf` or `NaN` due to + * possible misinterpretation of the result at higher bases. If those values + * are expected, use `to_str_radix_special()` instead. + */ +#[inline(always)] +pub pure fn to_str_radix(num: f32, rdx: uint) -> ~str { + let (r, special) = num::to_str_common( + &num, rdx, true, true, num::SignNeg, num::DigAll); + if special { die!(~"number has a special value, \ + try to_str_radix_special() if those are expected") } + r +} + +/** + * Converts a float to a string in a given radix, and a flag indicating + * whether it's a special value + * + * # Arguments + * + * * num - The float value + * * radix - The base to use + */ +#[inline(always)] +pub pure fn to_str_radix_special(num: f32, rdx: uint) -> (~str, bool) { + num::to_str_common(&num, rdx, true, true, num::SignNeg, num::DigAll) +} + +/** + * Converts a float to a string with exactly the number of + * provided significant digits + * + * # Arguments + * + * * num - The float value + * * digits - The number of significant digits + */ +#[inline(always)] +pub pure fn to_str_exact(num: f32, dig: uint) -> ~str { + let (r, _) = num::to_str_common( + &num, 10u, true, true, num::SignNeg, num::DigExact(dig)); + r +} + +/** + * Converts a float to a string with a maximum number of + * significant digits + * + * # Arguments + * + * * num - The float value + * * digits - The number of significant digits + */ +#[inline(always)] +pub pure fn to_str_digits(num: f32, dig: uint) -> ~str { + let (r, _) = num::to_str_common( + &num, 10u, true, true, num::SignNeg, num::DigMax(dig)); + r +} + +impl f32: to_str::ToStr { + #[inline(always)] + pure fn to_str(&self) -> ~str { to_str_digits(*self, 8) } +} + +impl f32: num::ToStrRadix { + #[inline(always)] + pure fn to_str_radix(&self, rdx: uint) -> ~str { + to_str_radix(*self, rdx) + } +} + +/** + * Convert a string in base 10 to a float. + * Accepts a optional decimal exponent. + * + * This function accepts strings such as + * + * * '3.14' + * * '+3.14', equivalent to '3.14' + * * '-3.14' + * * '2.5E10', or equivalently, '2.5e10' + * * '2.5E-10' + * * '.' (understood as 0) + * * '5.' + * * '.5', or, equivalently, '0.5' + * * '+inf', 'inf', '-inf', 'NaN' + * + * Leading and trailing whitespace represent an error. + * + * # Arguments + * + * * num - A string + * + * # Return value + * + * `none` if the string did not represent a valid number. Otherwise, + * `Some(n)` where `n` is the floating-point number represented by `num`. + */ +#[inline(always)] +pub pure fn from_str(num: &str) -> Option<f32> { + num::from_str_common(num, 10u, true, true, true, num::ExpDec, false) +} + +/** + * Convert a string in base 16 to a float. + * Accepts a optional binary exponent. + * + * This function accepts strings such as + * + * * 'a4.fe' + * * '+a4.fe', equivalent to 'a4.fe' + * * '-a4.fe' + * * '2b.aP128', or equivalently, '2b.ap128' + * * '2b.aP-128' + * * '.' (understood as 0) + * * 'c.' + * * '.c', or, equivalently, '0.c' + * * '+inf', 'inf', '-inf', 'NaN' + * + * Leading and trailing whitespace represent an error. + * + * # Arguments + * + * * num - A string + * + * # Return value + * + * `none` if the string did not represent a valid number. Otherwise, + * `Some(n)` where `n` is the floating-point number represented by `[num]`. + */ +#[inline(always)] +pub pure fn from_str_hex(num: &str) -> Option<f32> { + num::from_str_common(num, 16u, true, true, true, num::ExpBin, false) +} + +/** + * Convert a string in an given base to a float. + * + * Due to possible conflicts, this function does **not** accept + * the special values `inf`, `-inf`, `+inf` and `NaN`, **nor** + * does it recognize exponents of any kind. + * + * Leading and trailing whitespace represent an error. + * + * # Arguments + * + * * num - A string + * * radix - The base to use. Must lie in the range [2 .. 36] + * + * # Return value + * + * `none` if the string did not represent a valid number. Otherwise, + * `Some(n)` where `n` is the floating-point number represented by `num`. + */ +#[inline(always)] +pub pure fn from_str_radix(num: &str, rdx: uint) -> Option<f32> { + num::from_str_common(num, rdx, true, true, false, num::ExpNone, false) +} + +impl f32: from_str::FromStr { + #[inline(always)] + static pure fn from_str(val: &str) -> Option<f32> { from_str(val) } +} + +impl f32: num::FromStrRadix { + #[inline(always)] + static pure fn from_str_radix(val: &str, rdx: uint) -> Option<f32> { + from_str_radix(val, rdx) + } +} + // // Local Variables: // mode: rust diff --git a/src/libcore/f64.rs b/src/libcore/num/f64.rs index 8cd94c9357d..126a48cf280 100644 --- a/src/libcore/f64.rs +++ b/src/libcore/num/f64.rs @@ -19,6 +19,9 @@ use cmp; use libc::{c_double, c_int}; use libc; use num; +use option::Option; +use to_str; +use from_str; pub use cmath::c_double_targ_consts::*; @@ -330,6 +333,246 @@ pub extern { fn floorf64(val: f64) -> f64; } +impl f64: num::Round { + #[inline(always)] + pure fn round(&self, mode: num::RoundMode) -> f64 { + match mode { + num::RoundDown => floor(*self), + num::RoundUp => ceil(*self), + num::RoundToZero if is_negative(*self) => ceil(*self), + num::RoundToZero => floor(*self), + num::RoundFromZero if is_negative(*self) => floor(*self), + num::RoundFromZero => ceil(*self) + } + } + + #[inline(always)] + pure fn floor(&self) -> f64 { floor(*self) } + #[inline(always)] + pure fn ceil(&self) -> f64 { ceil(*self) } + #[inline(always)] + pure fn fract(&self) -> f64 { + if is_negative(*self) { + (*self) - ceil(*self) + } else { + (*self) - floor(*self) + } + } +} + +/** + * Section: String Conversions + */ + +/** + * Converts a float to a string + * + * # Arguments + * + * * num - The float value + */ +#[inline(always)] +pub pure fn to_str(num: f64) -> ~str { + let (r, _) = num::to_str_common( + &num, 10u, true, true, num::SignNeg, num::DigAll); + r +} + +/** + * Converts a float to a string in hexadecimal format + * + * # Arguments + * + * * num - The float value + */ +#[inline(always)] +pub pure fn to_str_hex(num: f64) -> ~str { + let (r, _) = num::to_str_common( + &num, 16u, true, true, num::SignNeg, num::DigAll); + r +} + +/** + * Converts a float to a string in a given radix + * + * # Arguments + * + * * num - The float value + * * radix - The base to use + * + * # Failure + * + * Fails if called on a special value like `inf`, `-inf` or `NaN` due to + * possible misinterpretation of the result at higher bases. If those values + * are expected, use `to_str_radix_special()` instead. + */ +#[inline(always)] +pub pure fn to_str_radix(num: f64, rdx: uint) -> ~str { + let (r, special) = num::to_str_common( + &num, rdx, true, true, num::SignNeg, num::DigAll); + if special { die!(~"number has a special value, \ + try to_str_radix_special() if those are expected") } + r +} + +/** + * Converts a float to a string in a given radix, and a flag indicating + * whether it's a special value + * + * # Arguments + * + * * num - The float value + * * radix - The base to use + */ +#[inline(always)] +pub pure fn to_str_radix_special(num: f64, rdx: uint) -> (~str, bool) { + num::to_str_common(&num, rdx, true, true, num::SignNeg, num::DigAll) +} + +/** + * Converts a float to a string with exactly the number of + * provided significant digits + * + * # Arguments + * + * * num - The float value + * * digits - The number of significant digits + */ +#[inline(always)] +pub pure fn to_str_exact(num: f64, dig: uint) -> ~str { + let (r, _) = num::to_str_common( + &num, 10u, true, true, num::SignNeg, num::DigExact(dig)); + r +} + +/** + * Converts a float to a string with a maximum number of + * significant digits + * + * # Arguments + * + * * num - The float value + * * digits - The number of significant digits + */ +#[inline(always)] +pub pure fn to_str_digits(num: f64, dig: uint) -> ~str { + let (r, _) = num::to_str_common( + &num, 10u, true, true, num::SignNeg, num::DigMax(dig)); + r +} + +impl f64: to_str::ToStr { + #[inline(always)] + pure fn to_str(&self) -> ~str { to_str_digits(*self, 8) } +} + +impl f64: num::ToStrRadix { + #[inline(always)] + pure fn to_str_radix(&self, rdx: uint) -> ~str { + to_str_radix(*self, rdx) + } +} + +/** + * Convert a string in base 10 to a float. + * Accepts a optional decimal exponent. + * + * This function accepts strings such as + * + * * '3.14' + * * '+3.14', equivalent to '3.14' + * * '-3.14' + * * '2.5E10', or equivalently, '2.5e10' + * * '2.5E-10' + * * '.' (understood as 0) + * * '5.' + * * '.5', or, equivalently, '0.5' + * * '+inf', 'inf', '-inf', 'NaN' + * + * Leading and trailing whitespace represent an error. + * + * # Arguments + * + * * num - A string + * + * # Return value + * + * `none` if the string did not represent a valid number. Otherwise, + * `Some(n)` where `n` is the floating-point number represented by `num`. + */ +#[inline(always)] +pub pure fn from_str(num: &str) -> Option<f64> { + num::from_str_common(num, 10u, true, true, true, num::ExpDec, false) +} + +/** + * Convert a string in base 16 to a float. + * Accepts a optional binary exponent. + * + * This function accepts strings such as + * + * * 'a4.fe' + * * '+a4.fe', equivalent to 'a4.fe' + * * '-a4.fe' + * * '2b.aP128', or equivalently, '2b.ap128' + * * '2b.aP-128' + * * '.' (understood as 0) + * * 'c.' + * * '.c', or, equivalently, '0.c' + * * '+inf', 'inf', '-inf', 'NaN' + * + * Leading and trailing whitespace represent an error. + * + * # Arguments + * + * * num - A string + * + * # Return value + * + * `none` if the string did not represent a valid number. Otherwise, + * `Some(n)` where `n` is the floating-point number represented by `[num]`. + */ +#[inline(always)] +pub pure fn from_str_hex(num: &str) -> Option<f64> { + num::from_str_common(num, 16u, true, true, true, num::ExpBin, false) +} + +/** + * Convert a string in an given base to a float. + * + * Due to possible conflicts, this function does **not** accept + * the special values `inf`, `-inf`, `+inf` and `NaN`, **nor** + * does it recognize exponents of any kind. + * + * Leading and trailing whitespace represent an error. + * + * # Arguments + * + * * num - A string + * * radix - The base to use. Must lie in the range [2 .. 36] + * + * # Return value + * + * `none` if the string did not represent a valid number. Otherwise, + * `Some(n)` where `n` is the floating-point number represented by `num`. + */ +#[inline(always)] +pub pure fn from_str_radix(num: &str, rdx: uint) -> Option<f64> { + num::from_str_common(num, rdx, true, true, false, num::ExpNone, false) +} + +impl f64: from_str::FromStr { + #[inline(always)] + static pure fn from_str(val: &str) -> Option<f64> { from_str(val) } +} + +impl f64: num::FromStrRadix { + #[inline(always)] + static pure fn from_str_radix(val: &str, rdx: uint) -> Option<f64> { + from_str_radix(val, rdx) + } +} + // // Local Variables: // mode: rust diff --git a/src/libcore/float.rs b/src/libcore/num/float.rs index 7ff8599679c..32cda029cd1 100644 --- a/src/libcore/float.rs +++ b/src/libcore/num/float.rs @@ -34,6 +34,8 @@ use num::Num::from_int; use option::{None, Option, Some}; use str; use uint; +use to_str; +use from_str; pub use f64::{add, sub, mul, div, rem, lt, le, eq, ne, ge, gt}; pub use f64::logarithm; @@ -95,7 +97,7 @@ pub mod consts { pub const ln_10: float = 2.30258509299404568401799145468436421; } -/** +/* * Section: String Conversions */ @@ -105,85 +107,63 @@ pub mod consts { * # Arguments * * * num - The float value - * * digits - The number of significant digits - * * exact - Whether to enforce the exact number of significant digits */ -pub pure fn to_str_common(num: float, digits: uint, exact: bool) -> ~str { - if is_NaN(num) { return ~"NaN"; } - if num == infinity { return ~"inf"; } - if num == neg_infinity { return ~"-inf"; } - - let mut (num, sign) = if num < 0.0 { (-num, ~"-") } else { (num, ~"") }; - - // truncated integer - let trunc = num as uint; - - // decimal remainder - let mut frac = num - (trunc as float); - - // stack of digits - let mut fractionalParts = ~[]; - - // FIXME: (#2608) - // This used to return right away without rounding, as "~[-]num", - // but given epsilon like in f64.rs, I don't see how the comparison - // to epsilon did much when only used there. - // if (frac < epsilon && !exact) || digits == 0u { return accum; } - // - // With something better, possibly weird results like this can be avoided: - // assert "3.14158999999999988262" == my_to_str_exact(3.14159, 20u); - - let mut ii = digits; - let mut epsilon_prime = 1.0 / pow_with_uint(10u, ii); - - // while we still need digits - // build stack of digits - while ii > 0 && (frac >= epsilon_prime || exact) { - // store the next digit - frac *= 10.0; - let digit = frac as uint; - // Bleh: not really unsafe. - unsafe { fractionalParts.push(digit); } - - // calculate the next frac - frac -= digit as float; - epsilon_prime *= 10.0; - ii -= 1u; - } - - let mut acc; - let mut racc = ~""; - let mut carry = if frac * 10.0 as uint >= 5 { 1 } else { 0 }; - - // turn digits into string - // using stack of digits - while !fractionalParts.is_empty() { - // Bleh; shouldn't need to be unsafe - let mut adjusted_digit = carry + unsafe { fractionalParts.pop() }; - - if adjusted_digit == 10 { - carry = 1; - adjusted_digit %= 10 - } else { - carry = 0; - }; +#[inline(always)] +pub pure fn to_str(num: float) -> ~str { + let (r, _) = num::to_str_common( + &num, 10u, true, true, num::SignNeg, num::DigAll); + r +} - racc = uint::str(adjusted_digit) + racc; - } +/** + * Converts a float to a string in hexadecimal format + * + * # Arguments + * + * * num - The float value + */ +#[inline(always)] +pub pure fn to_str_hex(num: float) -> ~str { + let (r, _) = num::to_str_common( + &num, 16u, true, true, num::SignNeg, num::DigAll); + r +} - // pad decimals with trailing zeroes - while racc.len() < digits && exact { - racc += ~"0" - } +/** + * Converts a float to a string in a given radix + * + * # Arguments + * + * * num - The float value + * * radix - The base to use + * + * # Failure + * + * Fails if called on a special value like `inf`, `-inf` or `NaN` due to + * possible misinterpretation of the result at higher bases. If those values + * are expected, use `to_str_radix_special()` instead. + */ +#[inline(always)] +pub pure fn to_str_radix(num: float, radix: uint) -> ~str { + let (r, special) = num::to_str_common( + &num, radix, true, true, num::SignNeg, num::DigAll); + if special { die!(~"number has a special value, \ + try to_str_radix_special() if those are expected") } + r +} - // combine ints and decimals - let mut ones = uint::str(trunc + carry); - if racc == ~"" { - acc = sign + ones; - } else { - acc = sign + ones + ~"." + racc; - } - move acc +/** + * Converts a float to a string in a given radix, and a flag indicating + * whether it's a special value + * + * # Arguments + * + * * num - The float value + * * radix - The base to use + */ +#[inline(always)] +pub pure fn to_str_radix_special(num: float, radix: uint) -> (~str, bool) { + num::to_str_common(&num, radix, true, true, num::SignNeg, num::DigAll) } /** @@ -197,7 +177,9 @@ pub pure fn to_str_common(num: float, digits: uint, exact: bool) -> ~str { */ #[inline(always)] pub pure fn to_str_exact(num: float, digits: uint) -> ~str { - to_str_common(num, digits, true) + let (r, _) = num::to_str_common( + &num, 10u, true, true, num::SignNeg, num::DigExact(digits)); + r } #[test] @@ -206,7 +188,6 @@ pub fn test_to_str_exact_do_decimal() { assert s == ~"5.0000"; } - /** * Converts a float to a string with a maximum number of * significant digits @@ -217,12 +198,27 @@ pub fn test_to_str_exact_do_decimal() { * * digits - The number of significant digits */ #[inline(always)] -pub pure fn to_str(num: float, digits: uint) -> ~str { - to_str_common(num, digits, false) +pub pure fn to_str_digits(num: float, digits: uint) -> ~str { + let (r, _) = num::to_str_common( + &num, 10u, true, true, num::SignNeg, num::DigMax(digits)); + r +} + +impl float: to_str::ToStr { + #[inline(always)] + pure fn to_str(&self) -> ~str { to_str_digits(*self, 8) } +} + +impl float: num::ToStrRadix { + #[inline(always)] + pure fn to_str_radix(&self, radix: uint) -> ~str { + to_str_radix(*self, radix) + } } /** - * Convert a string to a float + * Convert a string in base 10 to a float. + * Accepts a optional decimal exponent. * * This function accepts strings such as * @@ -231,12 +227,12 @@ pub pure fn to_str(num: float, digits: uint) -> ~str { * * '-3.14' * * '2.5E10', or equivalently, '2.5e10' * * '2.5E-10' - * * '', or, equivalently, '.' (understood as 0) + * * '.' (understood as 0) * * '5.' * * '.5', or, equivalently, '0.5' - * * 'inf', '-inf', 'NaN' + * * '+inf', 'inf', '-inf', 'NaN' * - * Leading and trailing whitespace are ignored. + * Leading and trailing whitespace represent an error. * * # Arguments * @@ -245,125 +241,79 @@ pub pure fn to_str(num: float, digits: uint) -> ~str { * # Return value * * `none` if the string did not represent a valid number. Otherwise, - * `Some(n)` where `n` is the floating-point number represented by `[num]`. + * `Some(n)` where `n` is the floating-point number represented by `num`. */ +#[inline(always)] pub pure fn from_str(num: &str) -> Option<float> { - if num == "inf" { - return Some(infinity as float); - } else if num == "-inf" { - return Some(neg_infinity as float); - } else if num == "NaN" { - return Some(NaN as float); - } - - let mut pos = 0u; //Current byte position in the string. - //Used to walk the string in O(n). - let len = str::len(num); //Length of the string, in bytes. - - if len == 0u { return None; } - let mut total = 0f; //Accumulated result - let mut c = 'z'; //Latest char. - - //The string must start with one of the following characters. - match str::char_at(num, 0u) { - '-' | '+' | '0' .. '9' | '.' => (), - _ => return None - } - - //Determine if first char is '-'/'+'. Set [pos] and [neg] accordingly. - let mut neg = false; //Sign of the result - match str::char_at(num, 0u) { - '-' => { - neg = true; - pos = 1u; - } - '+' => { - pos = 1u; - } - _ => () - } + num::from_str_common(num, 10u, true, true, true, num::ExpDec, false) +} - //Examine the following chars until '.', 'e', 'E' - while(pos < len) { - let char_range = str::char_range_at(num, pos); - c = char_range.ch; - pos = char_range.next; - match c { - '0' .. '9' => { - total = total * 10f; - total += ((c as int) - ('0' as int)) as float; - } - '.' | 'e' | 'E' => break, - _ => return None - } - } +/** + * Convert a string in base 16 to a float. + * Accepts a optional binary exponent. + * + * This function accepts strings such as + * + * * 'a4.fe' + * * '+a4.fe', equivalent to 'a4.fe' + * * '-a4.fe' + * * '2b.aP128', or equivalently, '2b.ap128' + * * '2b.aP-128' + * * '.' (understood as 0) + * * 'c.' + * * '.c', or, equivalently, '0.c' + * * '+inf', 'inf', '-inf', 'NaN' + * + * Leading and trailing whitespace represent an error. + * + * # Arguments + * + * * num - A string + * + * # Return value + * + * `none` if the string did not represent a valid number. Otherwise, + * `Some(n)` where `n` is the floating-point number represented by `[num]`. + */ +#[inline(always)] +pub pure fn from_str_hex(num: &str) -> Option<float> { + num::from_str_common(num, 16u, true, true, true, num::ExpBin, false) +} - if c == '.' {//Examine decimal part - let mut decimal = 1f; - while(pos < len) { - let char_range = str::char_range_at(num, pos); - c = char_range.ch; - pos = char_range.next; - match c { - '0' | '1' | '2' | '3' | '4' | '5' | '6'| '7' | '8' | '9' => { - decimal /= 10f; - total += (((c as int) - ('0' as int)) as float)*decimal; - } - 'e' | 'E' => break, - _ => return None - } - } - } +/** + * Convert a string in an given base to a float. + * + * Due to possible conflicts, this function does **not** accept + * the special values `inf`, `-inf`, `+inf` and `NaN`, **nor** + * does it recognize exponents of any kind. + * + * Leading and trailing whitespace represent an error. + * + * # Arguments + * + * * num - A string + * * radix - The base to use. Must lie in the range [2 .. 36] + * + * # Return value + * + * `none` if the string did not represent a valid number. Otherwise, + * `Some(n)` where `n` is the floating-point number represented by `num`. + */ +#[inline(always)] +pub pure fn from_str_radix(num: &str, radix: uint) -> Option<float> { + num::from_str_common(num, radix, true, true, false, num::ExpNone, false) +} - if (c == 'e') || (c == 'E') { //Examine exponent - let mut exponent = 0u; - let mut neg_exponent = false; - if(pos < len) { - let char_range = str::char_range_at(num, pos); - c = char_range.ch; - match c { - '+' => { - pos = char_range.next; - } - '-' => { - pos = char_range.next; - neg_exponent = true; - } - _ => () - } - while(pos < len) { - let char_range = str::char_range_at(num, pos); - c = char_range.ch; - match c { - '0' | '1' | '2' | '3' | '4' | '5' | '6'| '7' | '8' | '9' => { - exponent *= 10u; - exponent += ((c as uint) - ('0' as uint)); - } - _ => break - } - pos = char_range.next; - } - let multiplier = pow_with_uint(10u, exponent); - //Note: not ~[int::pow], otherwise, we'll quickly - //end up with a nice overflow - if neg_exponent { - total = total / multiplier; - } else { - total = total * multiplier; - } - } else { - return None; - } - } +impl float: from_str::FromStr { + #[inline(always)] + static pure fn from_str(val: &str) -> Option<float> { from_str(val) } +} - if(pos < len) { - return None; - } else { - if(neg) { - total *= -1f; - } - return Some(total); - } +impl float: num::FromStrRadix { + #[inline(always)] + static pure fn from_str_radix(val: &str, radix: uint) -> Option<float> { + from_str_radix(val, radix) + } } /** @@ -488,10 +438,42 @@ impl float: num::One { static pure fn one() -> float { 1.0 } } +impl float: num::Round { + #[inline(always)] + pure fn round(&self, mode: num::RoundMode) -> float { + match mode { + num::RoundDown + => f64::floor(*self as f64) as float, + num::RoundUp + => f64::ceil(*self as f64) as float, + num::RoundToZero if is_negative(*self) + => f64::ceil(*self as f64) as float, + num::RoundToZero + => f64::floor(*self as f64) as float, + num::RoundFromZero if is_negative(*self) + => f64::floor(*self as f64) as float, + num::RoundFromZero + => f64::ceil(*self as f64) as float + } + } + + #[inline(always)] + pure fn floor(&self) -> float { f64::floor(*self as f64) as float} + #[inline(always)] + pure fn ceil(&self) -> float { f64::ceil(*self as f64) as float} + #[inline(always)] + pure fn fract(&self) -> float { + if is_negative(*self) { + (*self) - (f64::ceil(*self as f64) as float) + } else { + (*self) - (f64::floor(*self as f64) as float) + } + } +} + #[test] pub fn test_from_str() { assert from_str(~"3") == Some(3.); - assert from_str(~"3") == Some(3.); assert from_str(~"3.14") == Some(3.14); assert from_str(~"+3.14") == Some(3.14); assert from_str(~"-3.14") == Some(-3.14); @@ -504,19 +486,24 @@ pub fn test_from_str() { assert from_str(~"5.") == Some(5.); assert from_str(~".5") == Some(0.5); assert from_str(~"0.5") == Some(0.5); - assert from_str(~"0.5") == Some(0.5); - assert from_str(~"0.5") == Some(0.5); - assert from_str(~"-.5") == Some(-0.5); assert from_str(~"-.5") == Some(-0.5); assert from_str(~"-5") == Some(-5.); - assert from_str(~"-0") == Some(-0.); - assert from_str(~"0") == Some(0.); assert from_str(~"inf") == Some(infinity); + assert from_str(~"+inf") == Some(infinity); assert from_str(~"-inf") == Some(neg_infinity); // note: NaN != NaN, hence this slightly complex test match from_str(~"NaN") { Some(f) => assert is_NaN(f), - None => fail + None => die!() + } + // note: -0 == 0, hence these slightly more complex tests + match from_str(~"-0") { + Some(v) if is_zero(v) => assert is_negative(v), + _ => die!() + } + match from_str(~"0") { + Some(v) if is_zero(v) => assert is_positive(v), + _ => die!() } assert from_str(~"").is_none(); @@ -532,6 +519,89 @@ pub fn test_from_str() { } #[test] +pub fn test_from_str_hex() { + assert from_str_hex(~"a4") == Some(164.); + assert from_str_hex(~"a4.fe") == Some(164.9921875); + assert from_str_hex(~"-a4.fe") == Some(-164.9921875); + assert from_str_hex(~"+a4.fe") == Some(164.9921875); + assert from_str_hex(~"ff0P4") == Some(0xff00 as float); + assert from_str_hex(~"ff0p4") == Some(0xff00 as float); + assert from_str_hex(~"ff0p-4") == Some(0xff as float); + assert from_str_hex(~".") == Some(0.); + assert from_str_hex(~".p1") == Some(0.); + assert from_str_hex(~".p-1") == Some(0.); + assert from_str_hex(~"f.") == Some(15.); + assert from_str_hex(~".f") == Some(0.9375); + assert from_str_hex(~"0.f") == Some(0.9375); + assert from_str_hex(~"-.f") == Some(-0.9375); + assert from_str_hex(~"-f") == Some(-15.); + assert from_str_hex(~"inf") == Some(infinity); + assert from_str_hex(~"+inf") == Some(infinity); + assert from_str_hex(~"-inf") == Some(neg_infinity); + // note: NaN != NaN, hence this slightly complex test + match from_str_hex(~"NaN") { + Some(f) => assert is_NaN(f), + None => die!() + } + // note: -0 == 0, hence these slightly more complex tests + match from_str_hex(~"-0") { + Some(v) if is_zero(v) => assert is_negative(v), + _ => die!() + } + match from_str_hex(~"0") { + Some(v) if is_zero(v) => assert is_positive(v), + _ => die!() + } + assert from_str_hex(~"e") == Some(14.); + assert from_str_hex(~"E") == Some(14.); + assert from_str_hex(~"E1") == Some(225.); + assert from_str_hex(~"1e1e1") == Some(123361.); + assert from_str_hex(~"1e1.1") == Some(481.0625); + + assert from_str_hex(~"").is_none(); + assert from_str_hex(~"x").is_none(); + assert from_str_hex(~" ").is_none(); + assert from_str_hex(~" ").is_none(); + assert from_str_hex(~"p").is_none(); + assert from_str_hex(~"P").is_none(); + assert from_str_hex(~"P1").is_none(); + assert from_str_hex(~"1p1p1").is_none(); + assert from_str_hex(~"1p1.1").is_none(); + assert from_str_hex(~"1p1-1").is_none(); +} + +#[test] +pub fn test_to_str_hex() { + assert to_str_hex(164.) == ~"a4"; + assert to_str_hex(164.9921875) == ~"a4.fe"; + assert to_str_hex(-164.9921875) == ~"-a4.fe"; + assert to_str_hex(0xff00 as float) == ~"ff00"; + assert to_str_hex(-(0xff00 as float)) == ~"-ff00"; + assert to_str_hex(0.) == ~"0"; + assert to_str_hex(15.) == ~"f"; + assert to_str_hex(-15.) == ~"-f"; + assert to_str_hex(0.9375) == ~"0.f"; + assert to_str_hex(-0.9375) == ~"-0.f"; + assert to_str_hex(infinity) == ~"inf"; + assert to_str_hex(neg_infinity) == ~"-inf"; + assert to_str_hex(NaN) == ~"NaN"; + assert to_str_hex(0.) == ~"0"; + assert to_str_hex(-0.) == ~"-0"; +} + +#[test] +pub fn test_to_str_radix() { + assert to_str_radix(36., 36u) == ~"10"; + assert to_str_radix(8.125, 2u) == ~"1000.001"; +} + +#[test] +pub fn test_from_str_radix() { + assert from_str_radix(~"10", 36u) == Some(36.); + assert from_str_radix(~"1000.001", 2u) == Some(8.125); +} + +#[test] pub fn test_positive() { assert(is_positive(infinity)); assert(is_positive(1.)); @@ -577,8 +647,8 @@ pub fn test_nonnegative() { #[test] pub fn test_to_str_inf() { - assert to_str(infinity, 10u) == ~"inf"; - assert to_str(-infinity, 10u) == ~"-inf"; + assert to_str_digits(infinity, 10u) == ~"inf"; + assert to_str_digits(-infinity, 10u) == ~"-inf"; } #[test] diff --git a/src/libcore/int-template.rs b/src/libcore/num/int-template.rs index 532dd0007d5..8b02f3a94c5 100644 --- a/src/libcore/int-template.rs +++ b/src/libcore/num/int-template.rs @@ -17,13 +17,18 @@ use T = self::inst::T; use char; use cmp::{Eq, Ord}; use cmp; +use to_str::ToStr; use from_str::FromStr; +use num::{ToStrRadix, FromStrRadix}; use num; use num::Num::from_int; use prelude::*; use str; use uint; use vec; +use i8; +use i16; +use i32; pub const bits : uint = inst::bits; pub const bytes : uint = (inst::bits / 8); @@ -112,7 +117,7 @@ pub pure fn is_nonnegative(x: T) -> bool { x >= 0 as T } pub pure fn range_step(start: T, stop: T, step: T, it: fn(T) -> bool) { let mut i = start; if step == 0 { - fail ~"range_step called with step == 0"; + die!(~"range_step called with step == 0"); } else if step > 0 { // ascending while i < stop { if !it(i) { break } @@ -200,83 +205,112 @@ impl T: num::One { static pure fn one() -> T { 1 } } -/** - * Parse a buffer of bytes - * - * # Arguments - * - * * buf - A byte buffer - * * radix - The base of the number - */ -pub pure fn parse_bytes(buf: &[u8], radix: uint) -> Option<T> { - if vec::len(buf) == 0u { return None; } - let mut i = vec::len(buf) - 1u; - let mut start = 0u; - let mut power = 1 as T; - - if buf[0] == ('-' as u8) { - power = -1 as T; - start = 1u; - } - let mut n = 0 as T; - loop { - match char::to_digit(buf[i] as char, radix) { - Some(d) => n += (d as T) * power, - None => return None - } - power *= radix as T; - if i <= start { return Some(n); } - i -= 1u; - }; +impl T: num::Round { + #[inline(always)] + pure fn round(&self, _: num::RoundMode) -> T { *self } + + #[inline(always)] + pure fn floor(&self) -> T { *self } + #[inline(always)] + pure fn ceil(&self) -> T { *self } + #[inline(always)] + pure fn fract(&self) -> T { 0 } +} + +// String conversion functions and impl str -> num + +/// Parse a string as a number in base 10. +#[inline(always)] +pub pure fn from_str(s: &str) -> Option<T> { + num::from_str_common(s, 10u, true, false, false, + num::ExpNone, false) } -/// Parse a string to an int +/// Parse a string as a number in the given base. #[inline(always)] -pub pure fn from_str(s: &str) -> Option<T> -{ - parse_bytes(str::to_bytes(s), 10u) +pub pure fn from_str_radix(s: &str, radix: uint) -> Option<T> { + num::from_str_common(s, radix, true, false, false, + num::ExpNone, false) +} + +/// Parse a byte slice as a number in the given base. +#[inline(always)] +pub pure fn parse_bytes(buf: &[u8], radix: uint) -> Option<T> { + num::from_str_bytes_common(buf, radix, true, false, false, + num::ExpNone, false) } impl T : FromStr { #[inline(always)] - static pure fn from_str(s: &str) -> Option<T> { from_str(s) } + static pure fn from_str(s: &str) -> Option<T> { + from_str(s) + } } -/// Convert to a string in a given base -#[inline(always)] -pub pure fn to_str(n: T, radix: uint) -> ~str { - do to_str_bytes(n, radix) |slice| { - do vec::as_imm_buf(slice) |p, len| { - unsafe { str::raw::from_buf_len(p, len) } - } +impl T : FromStrRadix { + #[inline(always)] + static pure fn from_str_radix(&self, s: &str, radix: uint) -> Option<T> { + from_str_radix(s, radix) } } +// String conversion functions and impl num -> str + +/// Convert to a string as a byte slice in a given base. #[inline(always)] pub pure fn to_str_bytes<U>(n: T, radix: uint, f: fn(v: &[u8]) -> U) -> U { - if n < 0 as T { - uint::to_str_bytes(true, -n as uint, radix, f) - } else { - uint::to_str_bytes(false, n as uint, radix, f) - } + let (buf, _) = num::to_str_bytes_common(&n, radix, false, false, + num::SignNeg, num::DigAll); + f(buf) } -/// Convert to a string +/// Convert to a string in base 10. #[inline(always)] -pub pure fn str(i: T) -> ~str { return to_str(i, 10u); } +pub pure fn to_str(num: T) -> ~str { + let (buf, _) = num::to_str_common(&num, 10u, false, false, + num::SignNeg, num::DigAll); + buf +} + +/// Convert to a string in a given base. +#[inline(always)] +pub pure fn to_str_radix(num: T, radix: uint) -> ~str { + let (buf, _) = num::to_str_common(&num, radix, false, false, + num::SignNeg, num::DigAll); + buf +} + +/// Convert to a string. +/// *Deprecated*, use to_str() instead. +#[inline(always)] +pub pure fn str(i: T) -> ~str { to_str(i) } + +impl T : ToStr { + #[inline(always)] + pure fn to_str(&self) -> ~str { + to_str(*self) + } +} + +impl T : ToStrRadix { + #[inline(always)] + pure fn to_str_radix(&self, radix: uint) -> ~str { + to_str_radix(*self, radix) + } +} #[test] fn test_from_str() { assert from_str(~"0") == Some(0 as T); assert from_str(~"3") == Some(3 as T); assert from_str(~"10") == Some(10 as T); - assert from_str(~"123456789") == Some(123456789 as T); + assert i32::from_str(~"123456789") == Some(123456789 as i32); assert from_str(~"00100") == Some(100 as T); assert from_str(~"-1") == Some(-1 as T); assert from_str(~"-3") == Some(-3 as T); assert from_str(~"-10") == Some(-10 as T); - assert from_str(~"-123456789") == Some(-123456789 as T); + assert i32::from_str(~"-123456789") == Some(-123456789 as i32); assert from_str(~"-00100") == Some(-100 as T); assert from_str(~" ").is_none(); @@ -289,18 +323,18 @@ fn test_parse_bytes() { assert parse_bytes(to_bytes(~"123"), 10u) == Some(123 as T); assert parse_bytes(to_bytes(~"1001"), 2u) == Some(9 as T); assert parse_bytes(to_bytes(~"123"), 8u) == Some(83 as T); - assert parse_bytes(to_bytes(~"123"), 16u) == Some(291 as T); - assert parse_bytes(to_bytes(~"ffff"), 16u) == Some(65535 as T); - assert parse_bytes(to_bytes(~"FFFF"), 16u) == Some(65535 as T); + assert i32::parse_bytes(to_bytes(~"123"), 16u) == Some(291 as i32); + assert i32::parse_bytes(to_bytes(~"ffff"), 16u) == Some(65535 as i32); + assert i32::parse_bytes(to_bytes(~"FFFF"), 16u) == Some(65535 as i32); assert parse_bytes(to_bytes(~"z"), 36u) == Some(35 as T); assert parse_bytes(to_bytes(~"Z"), 36u) == Some(35 as T); assert parse_bytes(to_bytes(~"-123"), 10u) == Some(-123 as T); assert parse_bytes(to_bytes(~"-1001"), 2u) == Some(-9 as T); assert parse_bytes(to_bytes(~"-123"), 8u) == Some(-83 as T); - assert parse_bytes(to_bytes(~"-123"), 16u) == Some(-291 as T); - assert parse_bytes(to_bytes(~"-ffff"), 16u) == Some(-65535 as T); - assert parse_bytes(to_bytes(~"-FFFF"), 16u) == Some(-65535 as T); + assert i32::parse_bytes(to_bytes(~"-123"), 16u) == Some(-291 as i32); + assert i32::parse_bytes(to_bytes(~"-ffff"), 16u) == Some(-65535 as i32); + assert i32::parse_bytes(to_bytes(~"-FFFF"), 16u) == Some(-65535 as i32); assert parse_bytes(to_bytes(~"-z"), 36u) == Some(-35 as T); assert parse_bytes(to_bytes(~"-Z"), 36u) == Some(-35 as T); @@ -310,11 +344,74 @@ fn test_parse_bytes() { #[test] fn test_to_str() { - assert (to_str(0 as T, 10u) == ~"0"); - assert (to_str(1 as T, 10u) == ~"1"); - assert (to_str(-1 as T, 10u) == ~"-1"); - assert (to_str(127 as T, 16u) == ~"7f"); - assert (to_str(100 as T, 10u) == ~"100"); + assert (to_str_radix(0 as T, 10u) == ~"0"); + assert (to_str_radix(1 as T, 10u) == ~"1"); + assert (to_str_radix(-1 as T, 10u) == ~"-1"); + assert (to_str_radix(127 as T, 16u) == ~"7f"); + assert (to_str_radix(100 as T, 10u) == ~"100"); + +} + +#[test] +fn test_int_to_str_overflow() { + let mut i8_val: i8 = 127_i8; + assert (i8::to_str(i8_val) == ~"127"); + + i8_val += 1 as i8; + assert (i8::to_str(i8_val) == ~"-128"); + + let mut i16_val: i16 = 32_767_i16; + assert (i16::to_str(i16_val) == ~"32767"); + + i16_val += 1 as i16; + assert (i16::to_str(i16_val) == ~"-32768"); + + let mut i32_val: i32 = 2_147_483_647_i32; + assert (i32::to_str(i32_val) == ~"2147483647"); + + i32_val += 1 as i32; + assert (i32::to_str(i32_val) == ~"-2147483648"); + + let mut i64_val: i64 = 9_223_372_036_854_775_807_i64; + assert (i64::to_str(i64_val) == ~"9223372036854775807"); + + i64_val += 1 as i64; + assert (i64::to_str(i64_val) == ~"-9223372036854775808"); +} + +#[test] +fn test_int_from_str_overflow() { + let mut i8_val: i8 = 127_i8; + assert (i8::from_str(~"127") == Some(i8_val)); + assert (i8::from_str(~"128").is_none()); + + i8_val += 1 as i8; + assert (i8::from_str(~"-128") == Some(i8_val)); + assert (i8::from_str(~"-129").is_none()); + + let mut i16_val: i16 = 32_767_i16; + assert (i16::from_str(~"32767") == Some(i16_val)); + assert (i16::from_str(~"32768").is_none()); + + i16_val += 1 as i16; + assert (i16::from_str(~"-32768") == Some(i16_val)); + assert (i16::from_str(~"-32769").is_none()); + + let mut i32_val: i32 = 2_147_483_647_i32; + assert (i32::from_str(~"2147483647") == Some(i32_val)); + assert (i32::from_str(~"2147483648").is_none()); + + i32_val += 1 as i32; + assert (i32::from_str(~"-2147483648") == Some(i32_val)); + assert (i32::from_str(~"-2147483649").is_none()); + + let mut i64_val: i64 = 9_223_372_036_854_775_807_i64; + assert (i64::from_str(~"9223372036854775807") == Some(i64_val)); + assert (i64::from_str(~"9223372036854775808").is_none()); + + i64_val += 1 as i64; + assert (i64::from_str(~"-9223372036854775808") == Some(i64_val)); + assert (i64::from_str(~"-9223372036854775809").is_none()); } #[test] @@ -359,16 +456,16 @@ pub fn test_ranges() { // None of the `fail`s should execute. for range(10,0) |_i| { - fail ~"unreachable"; + die!(~"unreachable"); } for range_rev(0,10) |_i| { - fail ~"unreachable"; + die!(~"unreachable"); } for range_step(10,0,1) |_i| { - fail ~"unreachable"; + die!(~"unreachable"); } for range_step(0,10,-1) |_i| { - fail ~"unreachable"; + die!(~"unreachable"); } } diff --git a/src/libcore/int-template/i16.rs b/src/libcore/num/int-template/i16.rs index da60b567f66..da60b567f66 100644 --- a/src/libcore/int-template/i16.rs +++ b/src/libcore/num/int-template/i16.rs diff --git a/src/libcore/int-template/i32.rs b/src/libcore/num/int-template/i32.rs index 1bc45bb71af..1bc45bb71af 100644 --- a/src/libcore/int-template/i32.rs +++ b/src/libcore/num/int-template/i32.rs diff --git a/src/libcore/int-template/i64.rs b/src/libcore/num/int-template/i64.rs index 83d15aa857d..83d15aa857d 100644 --- a/src/libcore/int-template/i64.rs +++ b/src/libcore/num/int-template/i64.rs diff --git a/src/libcore/int-template/i8.rs b/src/libcore/num/int-template/i8.rs index 740442ed725..740442ed725 100644 --- a/src/libcore/int-template/i8.rs +++ b/src/libcore/num/int-template/i8.rs diff --git a/src/libcore/int-template/int.rs b/src/libcore/num/int-template/int.rs index 224da0dc062..224da0dc062 100644 --- a/src/libcore/int-template/int.rs +++ b/src/libcore/num/int-template/int.rs diff --git a/src/libcore/num/num.rs b/src/libcore/num/num.rs new file mode 100644 index 00000000000..05b03a53dcd --- /dev/null +++ b/src/libcore/num/num.rs @@ -0,0 +1,688 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +//! An interface for numeric types +use core::cmp::{Ord, Eq}; +use option::{None, Option, Some}; +use char; +use str; +use kinds::Copy; +use vec; + +pub trait Num { + // FIXME: Trait composition. (#2616) + pure fn add(&self, other: &Self) -> Self; + pure fn sub(&self, other: &Self) -> Self; + pure fn mul(&self, other: &Self) -> Self; + pure fn div(&self, other: &Self) -> Self; + pure fn modulo(&self, other: &Self) -> Self; + pure fn neg(&self) -> Self; + + pure fn to_int(&self) -> int; + static pure fn from_int(n: int) -> Self; +} + +pub trait IntConvertible { + pure fn to_int(&self) -> int; + static pure fn from_int(n: int) -> Self; +} + +pub trait Zero { + static pure fn zero() -> Self; +} + +pub trait One { + static pure fn one() -> Self; +} + +pub trait Round { + pure fn round(&self, mode: RoundMode) -> Self; + + pure fn floor(&self) -> Self; + pure fn ceil(&self) -> Self; + pure fn fract(&self) -> Self; +} + +pub enum RoundMode { + RoundDown, + RoundUp, + RoundToZero, + RoundFromZero +} + +pub trait ToStrRadix { + pub pure fn to_str_radix(&self, radix: uint) -> ~str; +} + +pub trait FromStrRadix { + static pub pure fn from_str_radix(str: &str, radix: uint) -> Option<Self>; +} + +// Generic math functions: + +/// Dynamically calculates the value `inf` (`1/0`). +/// Can fail on integer types. +#[inline(always)] +pub pure fn infinity<T: Num One Zero>() -> T { + let _0: T = Zero::zero(); + let _1: T = One::one(); + _1 / _0 +} + +/// Dynamically calculates the value `-inf` (`-1/0`). +/// Can fail on integer types. +#[inline(always)] +pub pure fn neg_infinity<T: Num One Zero>() -> T { + let _0: T = Zero::zero(); + let _1: T = One::one(); + - _1 / _0 +} + +/// Dynamically calculates the value `NaN` (`0/0`). +/// Can fail on integer types. +#[inline(always)] +pub pure fn NaN<T: Num Zero>() -> T { + let _0: T = Zero::zero(); + _0 / _0 +} + +/// Returns `true` if `num` has the value `inf` (`1/0`). +/// Can fail on integer types. +#[inline(always)] +pub pure fn is_infinity<T: Num One Zero Eq>(num: &T) -> bool { + (*num) == (infinity::<T>()) +} + +/// Returns `true` if `num` has the value `-inf` (`-1/0`). +/// Can fail on integer types. +#[inline(always)] +pub pure fn is_neg_infinity<T: Num One Zero Eq>(num: &T) -> bool { + (*num) == (neg_infinity::<T>()) +} + +/// Returns `true` if `num` has the value `NaN` (is not equal to itself). +#[inline(always)] +pub pure fn is_NaN<T: Num Eq>(num: &T) -> bool { + (*num) != (*num) +} + +/// Returns `true` if `num` has the value `-0` (`1/num == -1/0`). +/// Can fail on integer types. +#[inline(always)] +pub pure fn is_neg_zero<T: Num One Zero Eq>(num: &T) -> bool { + let _1: T = One::one(); + let _0: T = Zero::zero(); + *num == _0 && is_neg_infinity(&(_1 / *num)) +} + +/** + * Calculates a power to a given radix, optimized for uint `pow` and `radix`. + * + * Returns `radix^pow` as `T`. + * + * Note: + * Also returns `1` for `0^0`, despite that technically being an + * undefined number. The reason for this is twofold: + * - If code written to use this function cares about that special case, it's + * probably going to catch it before making the call. + * - If code written to use this function doesn't care about it, it's + * probably assuming that `x^0` always equals `1`. + */ +pub pure fn pow_with_uint<T: Num One Zero Copy>(radix: uint, + pow: uint) -> T { + let _0: T = Zero::zero(); + let _1: T = One::one(); + + if pow == 0u { return _1; } + if radix == 0u { return _0; } + let mut my_pow = pow; + let mut total = _1; + let mut multiplier = Num::from_int(radix as int); + while (my_pow > 0u) { + if my_pow % 2u == 1u { + total *= multiplier; + } + my_pow /= 2u; + multiplier *= multiplier; + } + total +} + +pub enum ExponentFormat { + ExpNone, + ExpDec, + ExpBin +} + +pub enum SignificantDigits { + DigAll, + DigMax(uint), + DigExact(uint) +} + +pub enum SignFormat { + SignNone, + SignNeg, + SignAll +} + +/** + * Converts a number to its string representation as a byte vector. + * This is meant to be a common base implementation for all numeric string + * conversion functions like `to_str()` or `to_str_radix()`. + * + * # Arguments + * - `num` - The number to convert. Accepts any number that + * implements the numeric traits. + * - `radix` - Base to use. Accepts only the values 2-36. + * - `special` - Whether to attempt to compare to special values like + * `inf` or `NaN`. Also needed to detect negative 0. + * Can fail if it doesn't match `num`s type + * (see safety note). + * - `negative_zero` - Whether to treat the special value `-0` as + * `-0` or as `+0`. + * - `sign` - How to emit the sign. Options are: + * - `SignNone`: No sign at all. Basically emits `abs(num)`. + * - `SignNeg`: Only `-` on negative values. + * - `SignAll`: Both `+` on positive, and `-` on negative numbers. + * - `digits` - The amount of digits to use for emitting the + * fractional part, if any. Options are: + * - `DigAll`: All calculatable digits. Beware of bignums or + * fractions! + * - `DigMax(uint)`: Maximum N digits, truncating any trailing zeros. + * - `DigExact(uint)`: Exactly N digits. + * + * # Return value + * A tuple containing the byte vector, and a boolean flag indicating + * whether it represents a special value like `inf`, `-inf`, `NaN` or not. + * It returns a tuple because there can be ambiguity between a special value + * and a number representation at higher bases. + * + * # Failure + * - Fails if `radix` < 2 or `radix` > 36. + * - Fails on wrong value for `special` (see safety note). + * + * # Safety note + * The function detects the special values `inf`, `-inf` and `NaN` by + * dynamically comparing `num` to `1 / 0`, `-1 / 0` and `0 / 0` + * (each of type T) if `special` is `true`. This will fail on integer types + * with a 'divide by zero'. Likewise, it will fail if `num` **is** one of + * those special values, and `special` is `false`, because then the + * algorithm just does normal calculations on them. + */ +pub pure fn to_str_bytes_common<T: Num Zero One Eq Ord Round Copy>( + num: &T, radix: uint, special: bool, negative_zero: bool, + sign: SignFormat, digits: SignificantDigits) -> (~[u8], bool) { + if radix as int < 2 { + die!(fmt!("to_str_bytes_common: radix %? to low, \ + must lie in the range [2, 36]", radix)); + } else if radix as int > 36 { + die!(fmt!("to_str_bytes_common: radix %? to high, \ + must lie in the range [2, 36]", radix)); + } + + let _0: T = Zero::zero(); + let _1: T = One::one(); + + if special { + if is_NaN(num) { + return (str::to_bytes("NaN"), true); + } else if is_infinity(num){ + return match sign { + SignAll => (str::to_bytes("+inf"), true), + _ => (str::to_bytes("inf"), true) + } + } else if is_neg_infinity(num) { + return match sign { + SignNone => (str::to_bytes("inf"), true), + _ => (str::to_bytes("-inf"), true), + } + } + } + + let neg = *num < _0 || (negative_zero && *num == _0 + && special && is_neg_zero(num)); + let mut buf: ~[u8] = ~[]; + let radix_gen = Num::from_int::<T>(radix as int); + + let mut deccum; + + // First emit the non-fractional part, looping at least once to make + // sure at least a `0` gets emitted. + deccum = num.round(RoundToZero); + loop { + // Calculate the absolute value of each digit instead of only + // doing it once for the whole number because a + // representable negative number doesn't necessary have an + // representable additive inverse of the same type + // (See twos complement). But we assume that for the + // numbers [-35 .. 0] we always have [0 .. 35]. + let current_digit_signed = deccum % radix_gen; + let current_digit = if current_digit_signed < _0 { + -current_digit_signed + } else { + current_digit_signed + }; + + // Decrease the deccumulator one digit at a time + deccum /= radix_gen; + deccum = deccum.round(RoundToZero); + + unsafe { // FIXME: Pureness workaround (#4568) + buf.push(char::from_digit(current_digit.to_int() as uint, radix) + .unwrap() as u8); + } + + // No more digits to calculate for the non-fractional part -> break + if deccum == _0 { break; } + } + + // If limited digits, calculate one digit more for rounding. + let (limit_digits, digit_count, exact) = match digits { + DigAll => (false, 0u, false), + DigMax(count) => (true, count+1, false), + DigExact(count) => (true, count+1, true) + }; + + // Decide what sign to put in front + match sign { + SignNeg | SignAll if neg => { + unsafe { // FIXME: Pureness workaround (#4568) + buf.push('-' as u8); + } + } + SignAll => { + unsafe { // FIXME: Pureness workaround (#4568) + buf.push('+' as u8); + } + } + _ => () + } + + unsafe { // FIXME: Pureness workaround (#4568) + vec::reverse(buf); + } + + // Remember start of the fractional digits. + // Points one beyond end of buf if none get generated, + // or at the '.' otherwise. + let start_fractional_digits = buf.len(); + + // Now emit the fractional part, if any + deccum = num.fract(); + if deccum != _0 || (limit_digits && exact && digit_count > 0) { + unsafe { // FIXME: Pureness workaround (#4568) + buf.push('.' as u8); + } + let mut dig = 0u; + + // calculate new digits while + // - there is no limit and there are digits left + // - or there is a limit, it's not reached yet and + // - it's exact + // - or it's a maximum, and there are still digits left + while (!limit_digits && deccum != _0) + || (limit_digits && dig < digit_count && ( + exact + || (!exact && deccum != _0) + ) + ) { + // Shift first fractional digit into the integer part + deccum *= radix_gen; + + // Calculate the absolute value of each digit. + // See note in first loop. + let current_digit_signed = deccum.round(RoundToZero); + let current_digit = if current_digit_signed < _0 { + -current_digit_signed + } else { + current_digit_signed + }; + + unsafe { // FIXME: Pureness workaround (#4568) + buf.push(char::from_digit( + current_digit.to_int() as uint, radix).unwrap() as u8); + } + + // Decrease the deccumulator one fractional digit at a time + deccum = deccum.fract(); + dig += 1u; + } + + // If digits are limited, and that limit has been reached, + // cut off the one extra digit, and depending on its value + // round the remaining ones. + if limit_digits && dig == digit_count { + let ascii2value = |chr: u8| { + char::to_digit(chr as char, radix).unwrap() as uint + }; + let value2ascii = |val: uint| { + char::from_digit(val, radix).unwrap() as u8 + }; + + unsafe { // FIXME: Pureness workaround (#4568) + let extra_digit = ascii2value(buf.pop()); + if extra_digit >= radix / 2 { // -> need to round + let mut i: int = buf.len() as int - 1; + loop { + // If reached left end of number, have to + // insert additional digit: + if i < 0 + || buf[i] == '-' as u8 + || buf[i] == '+' as u8 { + buf.insert((i + 1) as uint, value2ascii(1)); + break; + } + + // Skip the '.' + if buf[i] == '.' as u8 { i -= 1; loop; } + + // Either increment the digit, + // or set to 0 if max and carry the 1. + let current_digit = ascii2value(buf[i]); + if current_digit < (radix - 1) { + buf[i] = value2ascii(current_digit+1); + break; + } else { + buf[i] = value2ascii(0); + i -= 1; + } + } + } + } + } + } + + // if number of digits is not exact, remove all trailing '0's up to + // and including the '.' + if !exact { + let buf_max_i = buf.len() - 1; + + // index to truncate from + let mut i = buf_max_i; + + // discover trailing zeros of fractional part + while i > start_fractional_digits && buf[i] == '0' as u8 { + i -= 1; + } + + // Only attempt to truncate digits if buf has fractional digits + if i >= start_fractional_digits { + // If buf ends with '.', cut that too. + if buf[i] == '.' as u8 { i -= 1 } + + // only resize buf if we actually remove digits + if i < buf_max_i { + buf = buf.slice(0, i + 1); + } + } + } // If exact and trailing '.', just cut that + else { + let max_i = buf.len() - 1; + if buf[max_i] == '.' as u8 { + buf = buf.slice(0, max_i); + } + } + + (buf, false) +} + +/** + * Converts a number to its string representation. This is a wrapper for + * `to_str_bytes_common()`, for details see there. + */ +#[inline(always)] +pub pure fn to_str_common<T: Num Zero One Eq Ord Round Copy>( + num: &T, radix: uint, special: bool, negative_zero: bool, + sign: SignFormat, digits: SignificantDigits) -> (~str, bool) { + let (bytes, special) = to_str_bytes_common(num, radix, special, + negative_zero, sign, digits); + (str::from_bytes(bytes), special) +} + +// Some constants for from_str_bytes_common's input validation, +// they define minimum radix values for which the character is a valid digit. +priv const DIGIT_P_RADIX: uint = ('p' as uint) - ('a' as uint) + 11u; +priv const DIGIT_I_RADIX: uint = ('i' as uint) - ('a' as uint) + 11u; +priv const DIGIT_E_RADIX: uint = ('e' as uint) - ('a' as uint) + 11u; + +/** + * Parses a byte slice as a number. This is meant to + * be a common base implementation for all numeric string conversion + * functions like `from_str()` or `from_str_radix()`. + * + * # Arguments + * - `buf` - The byte slice to parse. + * - `radix` - Which base to parse the number as. Accepts 2-36. + * - `negative` - Whether to accept negative numbers. + * - `fractional` - Whether to accept numbers with fractional parts. + * - `special` - Whether to accept special values like `inf` + * and `NaN`. Can conflict with `radix`, see Failure. + * - `exponent` - Which exponent format to accept. Options are: + * - `ExpNone`: No Exponent, accepts just plain numbers like `42` or + * `-8.2`. + * - `ExpDec`: Accepts numbers with a decimal exponent like `42e5` or + * `8.2E-2`. The exponent string itself is always base 10. + * Can conflict with `radix`, see Failure. + * - `ExpBin`: Accepts numbers with a binary exponent like `42P-8` or + * `FFp128`. The exponent string itself is always base 10. + * Can conflict with `radix`, see Failure. + * - `empty_zero` - Whether to accept a empty `buf` as a 0 or not. + * + * # Return value + * Returns `Some(n)` if `buf` parses to a number n without overflowing, and + * `None` otherwise, depending on the constraints set by the remaining + * arguments. + * + * # Failure + * - Fails if `radix` < 2 or `radix` > 36. + * - Fails if `radix` > 14 and `exponent` is `ExpDec` due to conflict + * between digit and exponent sign `'e'`. + * - Fails if `radix` > 25 and `exponent` is `ExpBin` due to conflict + * between digit and exponent sign `'p'`. + * - Fails if `radix` > 18 and `special == true` due to conflict + * between digit and lowest first character in `inf` and `NaN`, the `'i'`. + * + * # Possible improvements + * - Could accept option to allow ignoring underscores, allowing for numbers + * formated like `FF_AE_FF_FF`. + */ +pub pure fn from_str_bytes_common<T: Num Zero One Ord Copy>( + buf: &[u8], radix: uint, negative: bool, fractional: bool, + special: bool, exponent: ExponentFormat, empty_zero: bool + ) -> Option<T> { + match exponent { + ExpDec if radix >= DIGIT_E_RADIX // decimal exponent 'e' + => die!(fmt!("from_str_bytes_common: radix %? incompatible with \ + use of 'e' as decimal exponent", radix)), + ExpBin if radix >= DIGIT_P_RADIX // binary exponent 'p' + => die!(fmt!("from_str_bytes_common: radix %? incompatible with \ + use of 'p' as binary exponent", radix)), + _ if special && radix >= DIGIT_I_RADIX // first digit of 'inf' + => die!(fmt!("from_str_bytes_common: radix %? incompatible with \ + special values 'inf' and 'NaN'", radix)), + _ if radix as int < 2 + => die!(fmt!("from_str_bytes_common: radix %? to low, \ + must lie in the range [2, 36]", radix)), + _ if radix as int > 36 + => die!(fmt!("from_str_bytes_common: radix %? to high, \ + must lie in the range [2, 36]", radix)), + _ => () + } + + let _0: T = Zero::zero(); + let _1: T = One::one(); + let radix_gen: T = Num::from_int(radix as int); + + let len = buf.len(); + + if len == 0 { + if empty_zero { + return Some(_0); + } else { + return None; + } + } + + if special { + if buf == str::to_bytes("inf") || buf == str::to_bytes("+inf") { + return Some(infinity()); + } else if buf == str::to_bytes("-inf") { + if negative { + return Some(neg_infinity()); + } else { + return None; + } + } else if buf == str::to_bytes("NaN") { + return Some(NaN()); + } + } + + let (start, accum_positive) = match buf[0] { + '-' as u8 if !negative => return None, + '-' as u8 => (1u, false), + '+' as u8 => (1u, true), + _ => (0u, true) + }; + + // Initialize accumulator with signed zero for floating point parsing to + // work + let mut accum = if accum_positive { _0 } else { -_1 * _0}; + let mut last_accum = accum; // Necessary to detect overflow + let mut i = start; + let mut exp_found = false; + + // Parse integer part of number + while i < len { + let c = buf[i] as char; + + match char::to_digit(c, radix) { + Some(digit) => { + // shift accum one digit left + accum *= radix_gen; + + // add/subtract current digit depending on sign + if accum_positive { + accum += Num::from_int(digit as int); + } else { + accum -= Num::from_int(digit as int); + } + + // Detect overflow by comparing to last value + if accum_positive && accum < last_accum { return None; } + if !accum_positive && accum > last_accum { return None; } + last_accum = accum; + } + None => match c { + 'e' | 'E' | 'p' | 'P' => { + exp_found = true; + break; // start of exponent + } + '.' if fractional => { + i += 1u; // skip the '.' + break; // start of fractional part + } + _ => return None // invalid number + } + } + + i += 1u; + } + + // Parse fractional part of number + // Skip if already reached start of exponent + if !exp_found { + let mut power = _1; + + while i < len { + let c = buf[i] as char; + + match char::to_digit(c, radix) { + Some(digit) => { + // Decrease power one order of magnitude + power /= radix_gen; + + // add/subtract current digit depending on sign + if accum_positive { + accum += Num::from_int::<T>(digit as int) * power; + } else { + accum -= Num::from_int::<T>(digit as int) * power; + } + + // Detect overflow by comparing to last value + if accum_positive && accum < last_accum { return None; } + if !accum_positive && accum > last_accum { return None; } + last_accum = accum; + } + None => match c { + 'e' | 'E' | 'p' | 'P' => { + exp_found = true; + break; // start of exponent + } + _ => return None // invalid number + } + } + + i += 1u; + } + } + + // Special case: buf not empty, but does not contain any digit in front + // of the exponent sign -> number is empty string + if i == start { + if empty_zero { + return Some(_0); + } else { + return None; + } + } + + let mut multiplier = _1; + + if exp_found { + let c = buf[i] as char; + let base = match (c, exponent) { + ('e', ExpDec) | ('E', ExpDec) => 10u, + ('p', ExpBin) | ('P', ExpBin) => 2u, + _ => return None // char doesn't fit given exponent format + }; + + // parse remaining bytes as decimal integer, + // skipping the exponent char + let exp: Option<int> = from_str_bytes_common( + buf.view(i+1, len), 10, true, false, false, ExpNone, false); + + match exp { + Some(exp_pow) => { + multiplier = if exp_pow < 0 { + _1 / pow_with_uint::<T>(base, (-exp_pow.to_int()) as uint) + } else { + pow_with_uint::<T>(base, exp_pow.to_int() as uint) + } + } + None => return None // invalid exponent -> invalid number + } + } + + Some(accum * multiplier) +} + +/** + * Parses a string as a number. This is a wrapper for + * `from_str_bytes_common()`, for details see there. + */ +#[inline(always)] +pub pure fn from_str_common<T: Num Zero One Ord Copy>( + buf: &str, radix: uint, negative: bool, fractional: bool, + special: bool, exponent: ExponentFormat, empty_zero: bool + ) -> Option<T> { + from_str_bytes_common(str::to_bytes(buf), radix, negative, + fractional, special, exponent, empty_zero) +} diff --git a/src/libcore/uint-template.rs b/src/libcore/num/uint-template.rs index e4cc6651958..82c6e017014 100644 --- a/src/libcore/uint-template.rs +++ b/src/libcore/num/uint-template.rs @@ -17,12 +17,19 @@ use T_SIGNED = self::inst::T_SIGNED; use char; use cmp::{Eq, Ord}; +use cmp; +use to_str::ToStr; use from_str::FromStr; +use num::{ToStrRadix, FromStrRadix}; use num; use option::{None, Option, Some}; +use prelude::*; use str; use uint; use vec; +use u8; +use u16; +use u32; pub const bits : uint = inst::bits; pub const bytes : uint = (inst::bits / 8); @@ -76,7 +83,7 @@ pub pure fn is_nonnegative(x: T) -> bool { x >= 0 as T } pub pure fn range_step(start: T, stop: T, step: T_SIGNED, it: fn(T) -> bool) { let mut i = start; if step == 0 { - fail ~"range_step called with step == 0"; + die!(~"range_step called with step == 0"); } if step >= 0 { while i < stop { @@ -160,135 +167,109 @@ impl T: num::One { static pure fn one() -> T { 1 } } -/** - * Parse a buffer of bytes - * - * # Arguments - * - * * buf - A byte buffer - * * radix - The base of the number - * - * # Failure - * - * `buf` must not be empty - */ -pub pure fn parse_bytes(buf: &[const u8], radix: uint) -> Option<T> { - if vec::len(buf) == 0u { return None; } - let mut i = vec::len(buf) - 1u; - let mut power = 1u as T; - let mut n = 0u as T; - loop { - match char::to_digit(buf[i] as char, radix) { - Some(d) => n += d as T * power, - None => return None - } - power *= radix as T; - if i == 0u { return Some(n); } - i -= 1u; - }; +impl T: num::Round { + #[inline(always)] + pure fn round(&self, _: num::RoundMode) -> T { *self } + + #[inline(always)] + pure fn floor(&self) -> T { *self } + #[inline(always)] + pure fn ceil(&self) -> T { *self } + #[inline(always)] + pure fn fract(&self) -> T { 0 } } -/// Parse a string to an int +// String conversion functions and impl str -> num + +/// Parse a string as a number in base 10. #[inline(always)] -pub pure fn from_str(s: &str) -> Option<T> -{ - parse_bytes(str::to_bytes(s), 10u) +pub pure fn from_str(s: &str) -> Option<T> { + num::from_str_common(s, 10u, false, false, false, + num::ExpNone, false) } -impl T : FromStr { - #[inline(always)] - static pure fn from_str(s: &str) -> Option<T> { from_str(s) } +/// Parse a string as a number in the given base. +#[inline(always)] +pub pure fn from_str_radix(s: &str, radix: uint) -> Option<T> { + num::from_str_common(s, radix, false, false, false, + num::ExpNone, false) } -/// Parse a string as an unsigned integer. -pub fn from_str_radix(buf: &str, radix: u64) -> Option<u64> { - if str::len(buf) == 0u { return None; } - let mut i = str::len(buf) - 1u; - let mut power = 1u64, n = 0u64; - loop { - match char::to_digit(buf[i] as char, radix as uint) { - Some(d) => n += d as u64 * power, - None => return None - } - power *= radix; - if i == 0u { return Some(n); } - i -= 1u; - }; +/// Parse a byte slice as a number in the given base. +#[inline(always)] +pub pure fn parse_bytes(buf: &[u8], radix: uint) -> Option<T> { + num::from_str_bytes_common(buf, radix, false, false, false, + num::ExpNone, false) } -/** - * Convert to a string in a given base - * - * # Failure - * - * Fails if `radix` < 2 or `radix` > 16 - */ -#[inline(always)] -pub pure fn to_str(num: T, radix: uint) -> ~str { - do to_str_bytes(false, num, radix) |slice| { - do vec::as_imm_buf(slice) |p, len| { - unsafe { str::raw::from_buf_len(p, len) } - } +impl T : FromStr { + #[inline(always)] + static pure fn from_str(s: &str) -> Option<T> { + from_str(s) } } -/// Low-level helper routine for string conversion. -pub pure fn to_str_bytes<U>(neg: bool, num: T, radix: uint, - f: fn(v: &[u8]) -> U) -> U { - +impl T : FromStrRadix { #[inline(always)] - pure fn digit(n: T) -> u8 { - if n <= 9u as T { - n as u8 + '0' as u8 - } else if n <= 15u as T { - (n - 10 as T) as u8 + 'a' as u8 - } else { - fail; - } + static pure fn from_str_radix(&self, s: &str, radix: uint) -> Option<T> { + from_str_radix(s, radix) } +} - assert (1u < radix && radix <= 16u); - - // Enough room to hold any number in any radix. - // Worst case: 64-bit number, binary-radix, with - // a leading negative sign = 65 bytes. - let buf : [mut u8 * 65] = [mut 0u8, ..65]; - let len = buf.len(); - - let mut i = len; - let mut n = num; - let radix = radix as T; - loop { - i -= 1u; - assert 0u < i && i < len; - buf[i] = digit(n % radix); - n /= radix; - if n == 0 as T { break; } - } +// String conversion functions and impl num -> str - assert 0u < i && i < len; +/// Convert to a string as a byte slice in a given base. +#[inline(always)] +pub pure fn to_str_bytes<U>(n: T, radix: uint, f: fn(v: &[u8]) -> U) -> U { + let (buf, _) = num::to_str_bytes_common(&n, radix, false, false, + num::SignNeg, num::DigAll); + f(buf) +} - if neg { - i -= 1u; - buf[i] = '-' as u8; - } +/// Convert to a string in base 10. +#[inline(always)] +pub pure fn to_str(num: T) -> ~str { + let (buf, _) = num::to_str_common(&num, 10u, false, false, + num::SignNeg, num::DigAll); + buf +} - f(vec::view(buf, i, len)) +/// Convert to a string in a given base. +#[inline(always)] +pub pure fn to_str_radix(num: T, radix: uint) -> ~str { + let (buf, _) = num::to_str_common(&num, radix, false, false, + num::SignNeg, num::DigAll); + buf } -/// Convert to a string +/// Convert to a string. +/// *Deprecated*, use to_str() instead. #[inline(always)] -pub pure fn str(i: T) -> ~str { return to_str(i, 10u); } +pub pure fn str(i: T) -> ~str { to_str(i) } + +impl T : ToStr { + #[inline(always)] + pure fn to_str(&self) -> ~str { + to_str(*self) + } +} + +impl T : ToStrRadix { + #[inline(always)] + pure fn to_str_radix(&self, radix: uint) -> ~str { + to_str_radix(*self, radix) + } +} #[test] pub fn test_to_str() { - assert to_str(0 as T, 10u) == ~"0"; - assert to_str(1 as T, 10u) == ~"1"; - assert to_str(2 as T, 10u) == ~"2"; - assert to_str(11 as T, 10u) == ~"11"; - assert to_str(11 as T, 16u) == ~"b"; - assert to_str(255 as T, 16u) == ~"ff"; - assert to_str(0xff as T, 10u) == ~"255"; + assert to_str_radix(0 as T, 10u) == ~"0"; + assert to_str_radix(1 as T, 10u) == ~"1"; + assert to_str_radix(2 as T, 10u) == ~"2"; + assert to_str_radix(11 as T, 10u) == ~"11"; + assert to_str_radix(11 as T, 16u) == ~"b"; + assert to_str_radix(255 as T, 16u) == ~"ff"; + assert to_str_radix(0xff as T, 10u) == ~"255"; } #[test] @@ -296,7 +277,7 @@ pub fn test_from_str() { assert from_str(~"0") == Some(0u as T); assert from_str(~"3") == Some(3u as T); assert from_str(~"10") == Some(10u as T); - assert from_str(~"123456789") == Some(123456789u as T); + assert u32::from_str(~"123456789") == Some(123456789 as u32); assert from_str(~"00100") == Some(100u as T); assert from_str(~"").is_none(); @@ -310,8 +291,8 @@ pub fn test_parse_bytes() { assert parse_bytes(to_bytes(~"123"), 10u) == Some(123u as T); assert parse_bytes(to_bytes(~"1001"), 2u) == Some(9u as T); assert parse_bytes(to_bytes(~"123"), 8u) == Some(83u as T); - assert parse_bytes(to_bytes(~"123"), 16u) == Some(291u as T); - assert parse_bytes(to_bytes(~"ffff"), 16u) == Some(65535u as T); + assert u16::parse_bytes(to_bytes(~"123"), 16u) == Some(291u as u16); + assert u16::parse_bytes(to_bytes(~"ffff"), 16u) == Some(65535u as u16); assert parse_bytes(to_bytes(~"z"), 36u) == Some(35u as T); assert parse_bytes(to_bytes(~"Z"), 10u).is_none(); @@ -319,17 +300,79 @@ pub fn test_parse_bytes() { } #[test] +fn test_uint_to_str_overflow() { + let mut u8_val: u8 = 255_u8; + assert (u8::to_str(u8_val) == ~"255"); + + u8_val += 1 as u8; + assert (u8::to_str(u8_val) == ~"0"); + + let mut u16_val: u16 = 65_535_u16; + assert (u16::to_str(u16_val) == ~"65535"); + + u16_val += 1 as u16; + assert (u16::to_str(u16_val) == ~"0"); + + let mut u32_val: u32 = 4_294_967_295_u32; + assert (u32::to_str(u32_val) == ~"4294967295"); + + u32_val += 1 as u32; + assert (u32::to_str(u32_val) == ~"0"); + + let mut u64_val: u64 = 18_446_744_073_709_551_615_u64; + assert (u64::to_str(u64_val) == ~"18446744073709551615"); + + u64_val += 1 as u64; + assert (u64::to_str(u64_val) == ~"0"); +} + +#[test] +fn test_uint_from_str_overflow() { + let mut u8_val: u8 = 255_u8; + assert (u8::from_str(~"255") == Some(u8_val)); + assert (u8::from_str(~"256").is_none()); + + u8_val += 1 as u8; + assert (u8::from_str(~"0") == Some(u8_val)); + assert (u8::from_str(~"-1").is_none()); + + let mut u16_val: u16 = 65_535_u16; + assert (u16::from_str(~"65535") == Some(u16_val)); + assert (u16::from_str(~"65536").is_none()); + + u16_val += 1 as u16; + assert (u16::from_str(~"0") == Some(u16_val)); + assert (u16::from_str(~"-1").is_none()); + + let mut u32_val: u32 = 4_294_967_295_u32; + assert (u32::from_str(~"4294967295") == Some(u32_val)); + assert (u32::from_str(~"4294967296").is_none()); + + u32_val += 1 as u32; + assert (u32::from_str(~"0") == Some(u32_val)); + assert (u32::from_str(~"-1").is_none()); + + let mut u64_val: u64 = 18_446_744_073_709_551_615_u64; + assert (u64::from_str(~"18446744073709551615") == Some(u64_val)); + assert (u64::from_str(~"18446744073709551616").is_none()); + + u64_val += 1 as u64; + assert (u64::from_str(~"0") == Some(u64_val)); + assert (u64::from_str(~"-1").is_none()); +} + +#[test] #[should_fail] #[ignore(cfg(windows))] pub fn to_str_radix1() { - uint::to_str(100u, 1u); + uint::to_str_radix(100u, 1u); } #[test] #[should_fail] #[ignore(cfg(windows))] -pub fn to_str_radix17() { - uint::to_str(100u, 17u); +pub fn to_str_radix37() { + uint::to_str_radix(100u, 37u); } use io; @@ -357,16 +400,16 @@ pub fn test_ranges() { // None of the `fail`s should execute. for range(0,0) |_i| { - fail ~"unreachable"; + die!(~"unreachable"); } for range_rev(0,0) |_i| { - fail ~"unreachable"; + die!(~"unreachable"); } for range_step(10,0,1) |_i| { - fail ~"unreachable"; + die!(~"unreachable"); } for range_step(0,1,-10) |_i| { - fail ~"unreachable"; + die!(~"unreachable"); } } diff --git a/src/libcore/uint-template/u16.rs b/src/libcore/num/uint-template/u16.rs index b9a007af2f6..b9a007af2f6 100644 --- a/src/libcore/uint-template/u16.rs +++ b/src/libcore/num/uint-template/u16.rs diff --git a/src/libcore/uint-template/u32.rs b/src/libcore/num/uint-template/u32.rs index 141509c49e5..141509c49e5 100644 --- a/src/libcore/uint-template/u32.rs +++ b/src/libcore/num/uint-template/u32.rs diff --git a/src/libcore/uint-template/u64.rs b/src/libcore/num/uint-template/u64.rs index 35210eae9a7..35210eae9a7 100644 --- a/src/libcore/uint-template/u64.rs +++ b/src/libcore/num/uint-template/u64.rs diff --git a/src/libcore/uint-template/u8.rs b/src/libcore/num/uint-template/u8.rs index e273a203213..e273a203213 100644 --- a/src/libcore/uint-template/u8.rs +++ b/src/libcore/num/uint-template/u8.rs diff --git a/src/libcore/uint-template/uint.rs b/src/libcore/num/uint-template/uint.rs index 93f59cd2d9f..93f59cd2d9f 100644 --- a/src/libcore/uint-template/uint.rs +++ b/src/libcore/num/uint-template/uint.rs diff --git a/src/libcore/oldcomm.rs b/src/libcore/oldcomm.rs deleted file mode 100644 index dc245f5bffd..00000000000 --- a/src/libcore/oldcomm.rs +++ /dev/null @@ -1,547 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or -// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license -// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -/*! - -Deprecated communication between tasks - -Communication between tasks is facilitated by ports (in the receiving -task), and channels (in the sending task). Any number of channels may -feed into a single port. Ports and channels may only transmit values -of unique types; that is, values that are statically guaranteed to be -accessed by a single 'owner' at a time. Unique types include scalars, -vectors, strings, and records, tags, tuples and unique boxes (`~T`) -thereof. Most notably, shared boxes (`@T`) may not be transmitted -across channels. - -# Example - -~~~ -let po = oldcomm::Port(); -let ch = oldcomm::Chan(&po); - -do task::spawn { - oldcomm::send(ch, ~"Hello, World"); -} - -io::println(oldcomm::recv(po)); -~~~ - -# Note - -Use of this module is deprecated in favor of `core::pipes`. In the -`core::comm` will likely be rewritten with pipes, at which point it -will once again be the preferred module for intertask communication. - -*/ - -// NB: transitionary, de-mode-ing. -#[forbid(deprecated_mode)]; -#[forbid(deprecated_pattern)]; - -use cast; -use either; -use either::Either; -use iter; -use libc; -use libc::size_t; -use prelude::*; -use ptr; -use result; -use sys; -use task; -use vec; - -// After snapshot, change p2::addr_of => addr_of - -/** - * A communication endpoint that can receive messages - * - * Each port has a unique per-task identity and may not be replicated or - * transmitted. If a port value is copied, both copies refer to the same - * port. Ports may be associated with multiple `chan`s. - */ -pub enum Port<T> { - Port_(@PortPtr<T>) -} - -// It's critical that this only have one variant, so it has a record -// layout, and will work in the rust_task structure in task.rs. -/** - * A communication endpoint that can send messages - * - * Each channel is bound to a port when the channel is constructed, so - * the destination port for a channel must exist before the channel - * itself. Channels are weak: a channel does not keep the port it is - * bound to alive. If a channel attempts to send data to a dead port that - * data will be silently dropped. Channels may be duplicated and - * themselves transmitted over other channels. - */ -pub enum Chan<T> { - Chan_(port_id) -} - -/// Constructs a port -pub fn Port<T: Owned>() -> Port<T> { - unsafe { - Port_(@PortPtr(rustrt::new_port(sys::nonzero_size_of::<T>() - as size_t))) - } -} - -impl<T: Owned> Port<T> { - - fn chan() -> Chan<T> { Chan(&self) } - fn send(v: T) { self.chan().send(move v) } - fn recv() -> T { recv(self) } - fn peek() -> bool { peek(self) } - -} - -impl<T: Owned> Chan<T> { - - fn chan() -> Chan<T> { self } - fn send(v: T) { send(self, move v) } - fn recv() -> T { recv_chan(self) } - fn peek() -> bool { peek_chan(self) } - -} - -/// Open a new receiving channel for the duration of a function -pub fn listen<T: Owned, U>(f: fn(Chan<T>) -> U) -> U { - let po = Port(); - f(po.chan()) -} - -struct PortPtr<T> { - po: *rust_port, - drop { - unsafe { - do task::unkillable { - // Once the port is detached it's guaranteed not to receive further - // messages - let yield = 0; - let yieldp = ptr::addr_of(&yield); - rustrt::rust_port_begin_detach(self.po, yieldp); - if yield != 0 { - // Need to wait for the port to be detached - task::yield(); - } - rustrt::rust_port_end_detach(self.po); - - // Drain the port so that all the still-enqueued items get dropped - while rustrt::rust_port_size(self.po) > 0 as size_t { - recv_::<T>(self.po); - } - rustrt::del_port(self.po); - } - } - } -} - -fn PortPtr<T: Owned>(po: *rust_port) -> PortPtr<T> { - PortPtr { - po: po - } -} - -/** - * Internal function for converting from a channel to a port - * - * # Failure - * - * Fails if the port is detached or dead. Fails if the port - * is owned by a different task. - */ -fn as_raw_port<T: Owned, U>(ch: Chan<T>, f: fn(*rust_port) -> U) -> U { - - struct PortRef { - p: *rust_port, - drop { - unsafe { - if !ptr::is_null(self.p) { - rustrt::rust_port_drop(self.p); - } - } - } - } - - fn PortRef(p: *rust_port) -> PortRef { - PortRef { - p: p - } - } - - unsafe { - let p = PortRef(rustrt::rust_port_take(*ch)); - - if ptr::is_null(p.p) { - fail ~"unable to locate port for channel" - } else if rustrt::get_task_id() != rustrt::rust_port_task(p.p) { - fail ~"unable to access unowned port" - } - - f(p.p) - } -} - -/** - * Constructs a channel. The channel is bound to the port used to - * construct it. - */ -pub fn Chan<T: Owned>(p: &Port<T>) -> Chan<T> { - unsafe { - Chan_(rustrt::get_port_id((**p).po)) - } -} - -/** - * Sends data over a channel. The sent data is moved into the channel, - * whereupon the caller loses access to it. - */ -pub fn send<T: Owned>(ch: Chan<T>, data: T) { - unsafe { - let Chan_(p) = ch; - let data_ptr = ptr::addr_of(&data) as *(); - let res = rustrt::rust_port_id_send(p, data_ptr); - if res != 0 { - // Data sent successfully - cast::forget(move data); - } - task::yield(); - } -} - -/** - * Receive from a port. If no data is available on the port then the - * task will block until data becomes available. - */ -pub fn recv<T: Owned>(p: Port<T>) -> T { recv_((**p).po) } - -/// Returns true if there are messages available -pub fn peek<T: Owned>(p: Port<T>) -> bool { peek_((**p).po) } - -#[doc(hidden)] -pub fn recv_chan<T: Owned>(ch: Chan<T>) -> T { - as_raw_port(ch, |x|recv_(x)) -} - -fn peek_chan<T: Owned>(ch: Chan<T>) -> bool { - as_raw_port(ch, |x|peek_(x)) -} - -/// Receive on a raw port pointer -fn recv_<T>(p: *rust_port) -> T { - unsafe { - let yield = 0; - let yieldp = ptr::addr_of(&yield); - let mut res; - res = rusti::init::<T>(); - rustrt::port_recv(ptr::addr_of(&res) as *uint, p, yieldp); - - if yield != 0 { - // Data isn't available yet, so res has not been initialized. - task::yield(); - } else { - // In the absence of compiler-generated preemption points - // this is a good place to yield - task::yield(); - } - move res - } -} - -fn peek_(p: *rust_port) -> bool { - unsafe { - // Yield here before we check to see if someone sent us a message - // FIXME #524, if the compiler generates yields, we don't need this - task::yield(); - rustrt::rust_port_size(p) != 0 as libc::size_t - } -} - -/// Receive on one of two ports -pub fn select2<A: Owned, B: Owned>(p_a: Port<A>, p_b: Port<B>) - -> Either<A, B> { - unsafe { - let ports = ~[(**p_a).po, (**p_b).po]; - let yield = 0, yieldp = ptr::addr_of(&yield); - - let mut resport: *rust_port; - resport = rusti::init::<*rust_port>(); - do vec::as_imm_buf(ports) |ports, n_ports| { - rustrt::rust_port_select(ptr::addr_of(&resport), ports, - n_ports as size_t, yieldp); - } - - if yield != 0 { - // Wait for data - task::yield(); - } else { - // As in recv, this is a good place to yield anyway until - // the compiler generates yield calls - task::yield(); - } - - // Now we know the port we're supposed to receive from - assert resport != ptr::null(); - - if resport == (**p_a).po { - either::Left(recv(p_a)) - } else if resport == (**p_b).po { - either::Right(recv(p_b)) - } else { - fail ~"unexpected result from rust_port_select"; - } - } -} - - -/* Implementation details */ - -#[allow(non_camel_case_types)] // runtime type -enum rust_port {} - -#[allow(non_camel_case_types)] // runtime type -type port_id = int; - -#[abi = "cdecl"] -extern mod rustrt { - unsafe fn rust_port_id_send(target_port: port_id, data: *()) - -> libc::uintptr_t; - - unsafe fn new_port(unit_sz: libc::size_t) -> *rust_port; - unsafe fn del_port(po: *rust_port); - unsafe fn rust_port_begin_detach(po: *rust_port, - yield: *libc::uintptr_t); - unsafe fn rust_port_end_detach(po: *rust_port); - unsafe fn get_port_id(po: *rust_port) -> port_id; - unsafe fn rust_port_size(po: *rust_port) -> libc::size_t; - unsafe fn port_recv(dptr: *uint, po: *rust_port, - yield: *libc::uintptr_t); - unsafe fn rust_port_select(dptr: **rust_port, ports: **rust_port, - n_ports: libc::size_t, - yield: *libc::uintptr_t); - unsafe fn rust_port_take(port_id: port_id) -> *rust_port; - unsafe fn rust_port_drop(p: *rust_port); - unsafe fn rust_port_task(p: *rust_port) -> libc::uintptr_t; - unsafe fn get_task_id() -> libc::uintptr_t; -} - -#[abi = "rust-intrinsic"] -extern mod rusti { - fn init<T>() -> T; -} - - -/* Tests */ - - -#[test] -fn create_port_and_chan() { let p = Port::<int>(); Chan(&p); } - -#[test] -fn send_int() { - let p = Port::<int>(); - let c = Chan(&p); - send(c, 22); -} - -#[test] -fn send_recv_fn() { - let p = Port::<int>(); - let c = Chan::<int>(&p); - send(c, 42); - assert (recv(p) == 42); -} - -#[test] -fn send_recv_fn_infer() { - let p = Port(); - let c = Chan(&p); - send(c, 42); - assert (recv(p) == 42); -} - -#[test] -fn chan_chan_infer() { - let p = Port(), p2 = Port::<int>(); - let c = Chan(&p); - send(c, Chan(&p2)); - recv(p); -} - -#[test] -fn chan_chan() { - let p = Port::<Chan<int>>(), p2 = Port::<int>(); - let c = Chan(&p); - send(c, Chan(&p2)); - recv(p); -} - -#[test] -fn test_peek() { - let po = Port(); - let ch = Chan(&po); - assert !peek(po); - send(ch, ()); - assert peek(po); - recv(po); - assert !peek(po); -} - -#[test] -fn test_select2_available() { - let po_a = Port(); - let po_b = Port(); - let ch_a = Chan(&po_a); - let ch_b = Chan(&po_b); - - send(ch_a, ~"a"); - - assert select2(po_a, po_b) == either::Left(~"a"); - - send(ch_b, ~"b"); - - assert select2(po_a, po_b) == either::Right(~"b"); -} - -#[test] -fn test_select2_rendezvous() { - let po_a = Port(); - let po_b = Port(); - let ch_a = Chan(&po_a); - let ch_b = Chan(&po_b); - - for iter::repeat(10) { - do task::spawn { - for iter::repeat(10) { task::yield() } - send(ch_a, ~"a"); - }; - - assert select2(po_a, po_b) == either::Left(~"a"); - - do task::spawn { - for iter::repeat(10) { task::yield() } - send(ch_b, ~"b"); - }; - - assert select2(po_a, po_b) == either::Right(~"b"); - } -} - -#[test] -fn test_select2_stress() { - let po_a = Port(); - let po_b = Port(); - let ch_a = Chan(&po_a); - let ch_b = Chan(&po_b); - - let msgs = 100; - let times = 4u; - - for iter::repeat(times) { - do task::spawn { - for iter::repeat(msgs) { - send(ch_a, ~"a") - } - }; - do task::spawn { - for iter::repeat(msgs) { - send(ch_b, ~"b") - } - }; - } - - let mut as_ = 0; - let mut bs = 0; - for iter::repeat(msgs * times * 2u) { - match select2(po_a, po_b) { - either::Left(~"a") => as_ += 1, - either::Right(~"b") => bs += 1, - _ => fail ~"test_select_2_stress failed" - } - } - - assert as_ == 400; - assert bs == 400; -} - -#[test] -fn test_recv_chan() { - let po = Port(); - let ch = Chan(&po); - send(ch, ~"flower"); - assert recv_chan(ch) == ~"flower"; -} - -#[test] -#[should_fail] -#[ignore(cfg(windows))] -fn test_recv_chan_dead() { - let ch = Chan(&Port()); - send(ch, ~"flower"); - recv_chan(ch); -} - -#[test] -#[ignore(cfg(windows))] -fn test_recv_chan_wrong_task() { - let po = Port(); - let ch = Chan(&po); - send(ch, ~"flower"); - assert result::is_err(&task::try(|| - recv_chan(ch) - )) -} - -#[test] -fn test_port_send() { - let po = Port(); - po.send(()); - po.recv(); -} - -#[test] -fn test_chan_peek() { - let po = Port(); - let ch = po.chan(); - ch.send(()); - assert ch.peek(); -} - -#[test] -fn test_listen() { - do listen |parent| { - do task::spawn { - parent.send(~"oatmeal-salad"); - } - assert parent.recv() == ~"oatmeal-salad"; - } -} - -#[test] -#[ignore(cfg(windows))] -fn test_port_detach_fail() { - for iter::repeat(100) { - do task::spawn_unlinked { - let po = Port(); - let ch = po.chan(); - - do task::spawn { - fail; - } - - do task::spawn { - ch.send(()); - } - } - } -} diff --git a/src/libcore/option.rs b/src/libcore/option.rs index 05a2572fdef..9cb955ad352 100644 --- a/src/libcore/option.rs +++ b/src/libcore/option.rs @@ -78,7 +78,7 @@ pub pure fn get<T: Copy>(opt: Option<T>) -> T { match opt { Some(copy x) => return x, - None => fail ~"option::get none" + None => die!(~"option::get none") } } @@ -100,7 +100,7 @@ pub pure fn get_ref<T>(opt: &r/Option<T>) -> &r/T { */ match *opt { Some(ref x) => x, - None => fail ~"option::get_ref none" + None => die!(~"option::get_ref none") } } @@ -229,7 +229,7 @@ pub pure fn unwrap<T>(opt: Option<T>) -> T { */ match move opt { Some(move x) => move x, - None => fail ~"option::unwrap none" + None => die!(~"option::unwrap none") } } @@ -243,7 +243,7 @@ pub fn swap_unwrap<T>(opt: &mut Option<T>) -> T { Fails if the value equals `None`. */ - if opt.is_none() { fail ~"option::swap_unwrap none" } + if opt.is_none() { die!(~"option::swap_unwrap none") } unwrap(util::replace(opt, None)) } @@ -252,7 +252,7 @@ pub pure fn expect<T>(opt: Option<T>, reason: &str) -> T { //! As unwrap, but with a specified failure message. match move opt { Some(move val) => val, - None => fail reason.to_owned(), + None => die!(reason.to_owned()), } } diff --git a/src/libcore/os.rs b/src/libcore/os.rs index 760c08510e3..af484454ef4 100644 --- a/src/libcore/os.rs +++ b/src/libcore/os.rs @@ -1212,7 +1212,7 @@ mod tests { assert (libc::fclose(ostream) == (0u as c_int)); let rs = os::copy_file(&in, &out); if (!os::path_exists(&in)) { - fail (fmt!("%s doesn't exist", in.to_str())); + die!(fmt!("%s doesn't exist", in.to_str())); } assert(rs); let rslt = run::run_program(~"diff", ~[in.to_str(), out.to_str()]); diff --git a/src/libcore/path.rs b/src/libcore/path.rs index 2f9b2967775..0b64df8c112 100644 --- a/src/libcore/path.rs +++ b/src/libcore/path.rs @@ -368,7 +368,7 @@ impl Path { } impl PosixPath : ToStr { - pure fn to_str() -> ~str { + pure fn to_str(&self) -> ~str { let mut s = ~""; if self.is_absolute { s += "/"; @@ -531,7 +531,7 @@ impl PosixPath : GenericPath { impl WindowsPath : ToStr { - pure fn to_str() -> ~str { + pure fn to_str(&self) -> ~str { let mut s = ~""; match self.host { Some(ref h) => { s += "\\\\"; s += *h; } diff --git a/src/libcore/pipes.rs b/src/libcore/pipes.rs index 2dde9a9508b..5f9eed70868 100644 --- a/src/libcore/pipes.rs +++ b/src/libcore/pipes.rs @@ -332,7 +332,7 @@ fn wait_event(this: *rust_task) -> *libc::c_void { let killed = rustrt::task_wait_event(this, &mut event); if killed && !task::failing() { - fail ~"killed" + die!(~"killed") } event } @@ -408,7 +408,7 @@ pub fn send<T,Tbuffer>(p: SendPacketBuffered<T,Tbuffer>, payload: T) -> bool { //unsafe { forget(p); } return true; } - Full => fail ~"duplicate send", + Full => die!(~"duplicate send"), Blocked => { debug!("waking up task for %?", p_); let old_task = swap_task(&mut p.header.blocked_task, ptr::null()); @@ -526,7 +526,7 @@ pub fn try_recv<T: Owned, Tbuffer: Owned>(p: RecvPacketBuffered<T, Tbuffer>) debug!("woke up, p.state = %?", copy p.header.state); } Blocked => if first { - fail ~"blocking on already blocked packet" + die!(~"blocking on already blocked packet") }, Full => { let mut payload = None; @@ -562,7 +562,7 @@ pub fn try_recv<T: Owned, Tbuffer: Owned>(p: RecvPacketBuffered<T, Tbuffer>) pub pure fn peek<T: Owned, Tb: Owned>(p: &RecvPacketBuffered<T, Tb>) -> bool { match unsafe {(*p.header()).state} { Empty | Terminated => false, - Blocked => fail ~"peeking on blocked packet", + Blocked => die!(~"peeking on blocked packet"), Full => true } } @@ -595,7 +595,7 @@ fn sender_terminate<T: Owned>(p: *Packet<T>) { } Full => { // This is impossible - fail ~"you dun goofed" + die!(~"you dun goofed") } Terminated => { assert p.header.blocked_task.is_null(); @@ -658,7 +658,7 @@ fn wait_many<T: Selectable>(pkts: &[T]) -> uint { (*p).state = old; break; } - Blocked => fail ~"blocking on blocked packet", + Blocked => die!(~"blocking on blocked packet"), Empty => () } } @@ -731,7 +731,7 @@ pub fn select2<A: Owned, Ab: Owned, B: Owned, Bb: Owned>( match i { 0 => Left((try_recv(move a), move b)), 1 => Right((move a, try_recv(move b))), - _ => fail ~"select2 return an invalid packet" + _ => die!(~"select2 return an invalid packet") } } @@ -755,7 +755,7 @@ pub fn select2i<A: Selectable, B: Selectable>(a: &A, b: &B) -> match wait_many([a.header(), b.header()]) { 0 => Left(()), 1 => Right(()), - _ => fail ~"wait returned unexpected index" + _ => die!(~"wait returned unexpected index") } } @@ -833,7 +833,7 @@ impl<T,Tbuffer> SendPacketBuffered<T,Tbuffer> { //forget(packet); header }, - None => fail ~"packet already consumed" + None => die!(~"packet already consumed") } } @@ -899,7 +899,7 @@ impl<T: Owned, Tbuffer: Owned> RecvPacketBuffered<T, Tbuffer> : Selectable { //forget(packet); header }, - None => fail ~"packet already consumed" + None => die!(~"packet already consumed") } } } @@ -1095,7 +1095,7 @@ impl<T: Owned> Port<T>: Peekable<T> { endp <-> self.endp; let peek = match &endp { &Some(ref endp) => pipes::peek(endp), - &None => fail ~"peeking empty stream" + &None => die!(~"peeking empty stream") }; self.endp <-> endp; peek @@ -1108,7 +1108,7 @@ impl<T: Owned> Port<T>: Selectable { unsafe { match self.endp { Some(ref endp) => endp.header(), - None => fail ~"peeking empty stream" + None => die!(~"peeking empty stream") } } } @@ -1325,7 +1325,7 @@ pub mod test { c1.send(~"abc"); match (move p1, move p2).select() { - Right(_) => fail, + Right(_) => die!(), _ => () } diff --git a/src/libcore/prelude.rs b/src/libcore/prelude.rs index d3813d1ae85..6bd319a15d2 100644 --- a/src/libcore/prelude.rs +++ b/src/libcore/prelude.rs @@ -69,7 +69,6 @@ pub use io; pub use iter; pub use libc; pub use num; -pub use oldcomm; pub use ops; pub use option; pub use os; diff --git a/src/libcore/private.rs b/src/libcore/private.rs index 21a74ac08d0..1fb8166ed12 100644 --- a/src/libcore/private.rs +++ b/src/libcore/private.rs @@ -225,7 +225,7 @@ pub unsafe fn unwrap_shared_mutable_state<T: Owned>(rc: SharedMutableState<T>) cast::forget(move ptr); // Also we have to free the (rejected) server endpoints. let _server: UnwrapProto = cast::transmute(move serverp); - fail ~"Another task is already unwrapping this ARC!"; + die!(~"Another task is already unwrapping this ARC!"); } } } @@ -371,7 +371,7 @@ impl<T: Owned> Exclusive<T> { let rec = unsafe { get_shared_mutable_state(&self.x) }; do rec.lock.lock { if rec.failed { - fail ~"Poisoned exclusive - another task failed inside!"; + die!(~"Poisoned exclusive - another task failed inside!"); } rec.failed = true; let result = f(&mut rec.data); @@ -513,7 +513,7 @@ pub mod tests { let x2 = x.clone(); do task::spawn { for 10.times { task::yield(); } // try to let the unwrapper go - fail; // punt it awake from its deadlock + die!(); // punt it awake from its deadlock } let _z = unwrap_exclusive(move x); do x2.with |_hello| { } diff --git a/src/libcore/private/finally.rs b/src/libcore/private/finally.rs index 6fd173f84aa..2c27b8ab3a2 100644 --- a/src/libcore/private/finally.rs +++ b/src/libcore/private/finally.rs @@ -71,7 +71,7 @@ fn test_fail() { let mut i = 0; do (|| { i = 10; - fail; + die!(); }).finally { assert failing(); assert i == 10; @@ -95,4 +95,4 @@ fn test_compact() { fn but_always_run_this_function() { } do_some_fallible_work.finally( but_always_run_this_function); -} \ No newline at end of file +} diff --git a/src/libcore/private/global.rs b/src/libcore/private/global.rs index eab3f8ee537..cc46c19c3d2 100644 --- a/src/libcore/private/global.rs +++ b/src/libcore/private/global.rs @@ -269,7 +269,7 @@ fn test_modify() { Some(~shared_mutable_state(10)) } } - _ => fail + _ => die!() } } @@ -280,7 +280,7 @@ fn test_modify() { assert *v == 10; None }, - _ => fail + _ => die!() } } @@ -291,7 +291,7 @@ fn test_modify() { Some(~shared_mutable_state(10)) } } - _ => fail + _ => die!() } } } diff --git a/src/libcore/private/weak_task.rs b/src/libcore/private/weak_task.rs index 7a299d6f11b..9d57cd5a466 100644 --- a/src/libcore/private/weak_task.rs +++ b/src/libcore/private/weak_task.rs @@ -112,7 +112,7 @@ fn run_weak_task_service(port: Port<ServiceMsg>) { // nobody will receive this shutdown_chan.send(()); } - None => fail + None => die!() } } Shutdown => break @@ -195,7 +195,7 @@ fn test_select_stream_and_oneshot() { do weaken_task |signal| { match select2i(&port, &signal) { Left(*) => (), - Right(*) => fail + Right(*) => die!() } } } diff --git a/src/libcore/repr.rs b/src/libcore/repr.rs index cce5cac8683..1f04f9e77a9 100644 --- a/src/libcore/repr.rs +++ b/src/libcore/repr.rs @@ -297,7 +297,7 @@ impl ReprVisitor : TyVisitor { } // Type no longer exists, vestigial function. - fn visit_str(&self) -> bool { fail; } + fn visit_str(&self) -> bool { die!(); } fn visit_estr_box(&self) -> bool { do self.get::<@str> |s| { @@ -319,7 +319,7 @@ impl ReprVisitor : TyVisitor { // Type no longer exists, vestigial function. fn visit_estr_fixed(&self, _n: uint, _sz: uint, - _align: uint) -> bool { fail; } + _align: uint) -> bool { die!(); } fn visit_box(&self, mtbl: uint, inner: *TyDesc) -> bool { self.writer.write_char('@'); @@ -355,7 +355,7 @@ impl ReprVisitor : TyVisitor { } // Type no longer exists, vestigial function. - fn visit_vec(&self, _mtbl: uint, _inner: *TyDesc) -> bool { fail; } + fn visit_vec(&self, _mtbl: uint, _inner: *TyDesc) -> bool { die!(); } fn visit_unboxed_vec(&self, mtbl: uint, inner: *TyDesc) -> bool { @@ -562,7 +562,7 @@ impl ReprVisitor : TyVisitor { } // Type no longer exists, vestigial function. - fn visit_constr(&self, _inner: *TyDesc) -> bool { fail; } + fn visit_constr(&self, _inner: *TyDesc) -> bool { die!(); } fn visit_closure_ptr(&self, _ck: uint) -> bool { true } } @@ -596,7 +596,7 @@ fn test_repr() { exact_test(&10, "10"); exact_test(&true, "true"); exact_test(&false, "false"); - exact_test(&1.234, "1.2340"); + exact_test(&1.234, "1.234"); exact_test(&(&"hello"), "\"hello\""); exact_test(&(@"hello"), "@\"hello\""); exact_test(&(~"he\u10f3llo"), "~\"he\\u10f3llo\""); @@ -621,11 +621,11 @@ fn test_repr() { exact_test(&(&["hi", "there"]), "&[\"hi\", \"there\"]"); exact_test(&(P{a:10, b:1.234}), - "{a: 10, b: 1.2340}"); + "{a: 10, b: 1.234}"); exact_test(&(@P{a:10, b:1.234}), - "@{a: 10, b: 1.2340}"); + "@{a: 10, b: 1.234}"); exact_test(&(~P{a:10, b:1.234}), - "~{a: 10, b: 1.2340}"); + "~{a: 10, b: 1.234}"); exact_test(&(10_u8, ~"hello"), "(10, ~\"hello\")"); exact_test(&(10_u16, ~"hello"), diff --git a/src/libcore/result.rs b/src/libcore/result.rs index c8c76e86aa6..d04667698fd 100644 --- a/src/libcore/result.rs +++ b/src/libcore/result.rs @@ -44,7 +44,7 @@ pub pure fn get<T: Copy, U>(res: &Result<T, U>) -> T { match *res { Ok(copy t) => t, Err(ref the_err) => unsafe { - fail fmt!("get called on error result: %?", *the_err) + die!(fmt!("get called on error result: %?", *the_err)) } } } @@ -61,7 +61,7 @@ pub pure fn get_ref<T, U>(res: &a/Result<T, U>) -> &a/T { match *res { Ok(ref t) => t, Err(ref the_err) => unsafe { - fail fmt!("get_ref called on error result: %?", *the_err) + die!(fmt!("get_ref called on error result: %?", *the_err)) } } } @@ -77,7 +77,7 @@ pub pure fn get_ref<T, U>(res: &a/Result<T, U>) -> &a/T { pub pure fn get_err<T, U: Copy>(res: &Result<T, U>) -> U { match *res { Err(copy u) => u, - Ok(_) => fail ~"get_err called on ok result" + Ok(_) => die!(~"get_err called on ok result") } } @@ -382,7 +382,7 @@ pub fn iter_vec2<S,T,U:Copy>(ss: &[S], ts: &[T], pub pure fn unwrap<T, U>(res: Result<T, U>) -> T { match move res { Ok(move t) => move t, - Err(_) => fail ~"unwrap called on an err result" + Err(_) => die!(~"unwrap called on an err result") } } @@ -391,7 +391,7 @@ pub pure fn unwrap<T, U>(res: Result<T, U>) -> T { pub pure fn unwrap_err<T, U>(res: Result<T, U>) -> U { match move res { Err(move u) => move u, - Ok(_) => fail ~"unwrap called on an ok result" + Ok(_) => die!(~"unwrap called on an ok result") } } diff --git a/src/libcore/run.rs b/src/libcore/run.rs index 8aeae1adeec..c10eacc7a0a 100644 --- a/src/libcore/run.rs +++ b/src/libcore/run.rs @@ -184,7 +184,7 @@ fn with_dirp<T>(d: &Option<~str>, pub fn run_program(prog: &str, args: &[~str]) -> int { let pid = spawn_process(prog, args, &None, &None, 0i32, 0i32, 0i32); - if pid == -1 as pid_t { fail; } + if pid == -1 as pid_t { die!(); } return waitpid(pid); } @@ -214,7 +214,7 @@ pub fn start_program(prog: &str, args: &[~str]) -> Program { pipe_err.out); unsafe { - if pid == -1 as pid_t { fail; } + if pid == -1 as pid_t { die!(); } libc::close(pipe_input.in); libc::close(pipe_output.out); libc::close(pipe_err.out); @@ -328,7 +328,7 @@ pub fn program_output(prog: &str, args: &[~str]) -> os::close(pipe_in.out); os::close(pipe_out.in); os::close(pipe_err.in); - fail; + die!(); } os::close(pipe_in.out); @@ -362,7 +362,7 @@ pub fn program_output(prog: &str, args: &[~str]) -> errs = move s; } (n, _) => { - fail(fmt!("program_output received an unexpected file \ + die!(fmt!("program_output received an unexpected file \ number: %u", n)); } }; @@ -474,7 +474,7 @@ mod tests { os::close(pipe_out.out); os::close(pipe_err.out); - if pid == -1i32 { fail; } + if pid == -1i32 { die!(); } let expected = ~"test"; writeclose(pipe_in.out, copy expected); let actual = readclose(pipe_out.in); diff --git a/src/libcore/str.rs b/src/libcore/str.rs index d3759dca517..64695be21d5 100644 --- a/src/libcore/str.rs +++ b/src/libcore/str.rs @@ -2990,7 +2990,7 @@ mod tests { #[should_fail] fn test_as_bytes_fail() { // Don't double free - as_bytes::<()>(&~"", |_bytes| fail ); + as_bytes::<()>(&~"", |_bytes| die!() ); } #[test] @@ -3090,12 +3090,12 @@ mod tests { 0 => assert ch == 'x', 1 => assert ch == '\u03c0', 2 => assert ch == 'y', - _ => fail ~"test_chars_each failed" + _ => die!(~"test_chars_each failed") } i += 1; } - chars_each(~"", |_ch| fail ); // should not fail + chars_each(~"", |_ch| die!() ); // should not fail } #[test] @@ -3107,7 +3107,7 @@ mod tests { 0 => assert bb == 'x' as u8, 1 => assert bb == 'y' as u8, 2 => assert bb == 'z' as u8, - _ => fail ~"test_bytes_each failed" + _ => die!(~"test_bytes_each failed") } i += 1; } @@ -3169,7 +3169,7 @@ mod tests { ii += 1; } - words_each(~"", |_x| fail); // should not fail + words_each(~"", |_x| die!()); // should not fail } #[test] diff --git a/src/libcore/task/local_data.rs b/src/libcore/task/local_data.rs index 42765ef139f..5136af810e8 100644 --- a/src/libcore/task/local_data.rs +++ b/src/libcore/task/local_data.rs @@ -133,15 +133,15 @@ fn test_tls_modify() { fn my_key(_x: @~str) { } local_data_modify(my_key, |data| { match data { - Some(@ref val) => fail ~"unwelcome value: " + *val, + Some(@ref val) => die!(~"unwelcome value: " + *val), None => Some(@~"first data") } }); local_data_modify(my_key, |data| { match data { Some(@~"first data") => Some(@~"next data"), - Some(@ref val) => fail ~"wrong value: " + *val, - None => fail ~"missing value" + Some(@ref val) => die!(~"wrong value: " + *val), + None => die!(~"missing value") } }); assert *(local_data_pop(my_key).get()) == ~"next data"; @@ -212,11 +212,11 @@ fn test_tls_cleanup_on_failure() { local_data_set(str_key, @~"string data"); local_data_set(box_key, @@()); local_data_set(int_key, @42); - fail; + die!(); } } // Not quite nondeterministic. local_data_set(int_key, @31337); - fail; + die!(); } } diff --git a/src/libcore/task/mod.rs b/src/libcore/task/mod.rs index 62d317abb95..d276f0c6ea9 100644 --- a/src/libcore/task/mod.rs +++ b/src/libcore/task/mod.rs @@ -218,7 +218,7 @@ pub fn task() -> TaskBuilder { priv impl TaskBuilder { fn consume() -> TaskBuilder { if self.consumed { - fail ~"Cannot copy a task_builder"; // Fake move mode on self + die!(~"Cannot copy a task_builder"); // Fake move mode on self } self.consumed = true; let notify_chan = replace(&mut self.opts.notify_chan, None); @@ -314,7 +314,7 @@ impl TaskBuilder { // sending out messages. if self.opts.notify_chan.is_some() { - fail ~"Can't set multiple future_results for one task!"; + die!(~"Can't set multiple future_results for one task!"); } // Construct the future and give it to the caller. @@ -548,7 +548,7 @@ pub fn yield() { let task_ = rt::rust_get_task(); let killed = rt::rust_task_yield(task_); if killed && !failing() { - fail ~"killed"; + die!(~"killed"); } } } @@ -694,24 +694,24 @@ fn test_spawn_unlinked_unsup_no_fail_down() { // grandchild sends on a port for iter::repeat(16) { task::yield(); } ch.send(()); // If killed first, grandparent hangs. } - fail; // Shouldn't kill either (grand)parent or (grand)child. + die!(); // Shouldn't kill either (grand)parent or (grand)child. } po.recv(); } #[test] #[ignore(cfg(windows))] fn test_spawn_unlinked_unsup_no_fail_up() { // child unlinked fails - do spawn_unlinked { fail; } + do spawn_unlinked { die!(); } } #[test] #[ignore(cfg(windows))] fn test_spawn_unlinked_sup_no_fail_up() { // child unlinked fails - do spawn_supervised { fail; } + do spawn_supervised { die!(); } // Give child a chance to fail-but-not-kill-us. for iter::repeat(16) { task::yield(); } } #[test] #[should_fail] #[ignore(cfg(windows))] fn test_spawn_unlinked_sup_fail_down() { do spawn_supervised { loop { task::yield(); } } - fail; // Shouldn't leave a child hanging around. + die!(); // Shouldn't leave a child hanging around. } #[test] #[should_fail] #[ignore(cfg(windows))] @@ -733,7 +733,7 @@ fn test_spawn_linked_sup_fail_up() { // child fails; parent fails can_not_copy: None, .. b0 }; - do b1.spawn { fail; } + do b1.spawn { die!(); } po.recv(); // We should get punted awake } #[test] #[should_fail] #[ignore(cfg(windows))] @@ -754,26 +754,26 @@ fn test_spawn_linked_sup_fail_down() { // parent fails; child fails .. b0 }; do b1.spawn { loop { task::yield(); } } - fail; // *both* mechanisms would be wrong if this didn't kill the child... + die!(); // *both* mechanisms would be wrong if this didn't kill the child } #[test] #[should_fail] #[ignore(cfg(windows))] fn test_spawn_linked_unsup_fail_up() { // child fails; parent fails let (po, _ch) = stream::<()>(); // Default options are to spawn linked & unsupervised. - do spawn { fail; } + do spawn { die!(); } po.recv(); // We should get punted awake } #[test] #[should_fail] #[ignore(cfg(windows))] fn test_spawn_linked_unsup_fail_down() { // parent fails; child fails // Default options are to spawn linked & unsupervised. do spawn { loop { task::yield(); } } - fail; + die!(); } #[test] #[should_fail] #[ignore(cfg(windows))] fn test_spawn_linked_unsup_default_opts() { // parent fails; child fails // Make sure the above test is the same as this one. do task().linked().spawn { loop { task::yield(); } } - fail; + die!(); } // A couple bonus linked failure tests - testing for failure propagation even @@ -788,7 +788,7 @@ fn test_spawn_failure_propagate_grandchild() { } } for iter::repeat(16) { task::yield(); } - fail; + die!(); } #[test] #[should_fail] #[ignore(cfg(windows))] @@ -800,7 +800,7 @@ fn test_spawn_failure_propagate_secondborn() { } } for iter::repeat(16) { task::yield(); } - fail; + die!(); } #[test] #[should_fail] #[ignore(cfg(windows))] @@ -812,7 +812,7 @@ fn test_spawn_failure_propagate_nephew_or_niece() { } } for iter::repeat(16) { task::yield(); } - fail; + die!(); } #[test] #[should_fail] #[ignore(cfg(windows))] @@ -824,7 +824,7 @@ fn test_spawn_linked_sup_propagate_sibling() { } } for iter::repeat(16) { task::yield(); } - fail; + die!(); } #[test] @@ -868,7 +868,7 @@ fn test_future_result() { result = None; do task().future_result(|+r| { result = Some(move r); }).unlinked().spawn { - fail; + die!(); } assert option::unwrap(move result).recv() == Failure; } @@ -884,7 +884,7 @@ fn test_try_success() { ~"Success!" } { result::Ok(~"Success!") => (), - _ => fail + _ => die!() } } @@ -892,10 +892,10 @@ fn test_try_success() { #[ignore(cfg(windows))] fn test_try_fail() { match do try { - fail + die!() } { result::Err(()) => (), - result::Ok(()) => fail + result::Ok(()) => die!() } } @@ -1095,7 +1095,7 @@ fn test_unkillable() { yield(); // We want to fail after the unkillable task // blocks on recv - fail; + die!(); } unsafe { @@ -1130,7 +1130,7 @@ fn test_unkillable_nested() { yield(); // We want to fail after the unkillable task // blocks on recv - fail; + die!(); } unsafe { diff --git a/src/libcore/task/spawn.rs b/src/libcore/task/spawn.rs index 3db6fa00f16..c88587067c1 100644 --- a/src/libcore/task/spawn.rs +++ b/src/libcore/task/spawn.rs @@ -75,7 +75,6 @@ use cast; use container::Map; -use oldcomm; use option; use pipes::{Chan, GenericChan, GenericPort, Port, stream}; use pipes; @@ -646,25 +645,25 @@ pub fn spawn_raw(opts: TaskOpts, f: fn~()) { fn new_task_in_sched(opts: SchedOpts) -> *rust_task { if opts.foreign_stack_size != None { - fail ~"foreign_stack_size scheduler option unimplemented"; + die!(~"foreign_stack_size scheduler option unimplemented"); } let num_threads = match opts.mode { - DefaultScheduler - | CurrentScheduler - | ExistingScheduler(*) - | PlatformThread => 0u, /* Won't be used */ - SingleThreaded => 1u, - ThreadPerCore => unsafe { rt::rust_num_threads() }, - ThreadPerTask => { - fail ~"ThreadPerTask scheduling mode unimplemented" - } - ManualThreads(threads) => { - if threads == 0u { - fail ~"can not create a scheduler with no threads"; + DefaultScheduler + | CurrentScheduler + | ExistingScheduler(*) + | PlatformThread => 0u, /* Won't be used */ + SingleThreaded => 1u, + ThreadPerCore => unsafe { rt::rust_num_threads() }, + ThreadPerTask => { + die!(~"ThreadPerTask scheduling mode unimplemented") + } + ManualThreads(threads) => { + if threads == 0u { + die!(~"can not create a scheduler with no threads"); + } + threads } - threads - } }; unsafe { @@ -697,7 +696,7 @@ fn test_spawn_raw_unsupervise() { .. default_task_opts() }; do spawn_raw(move opts) { - fail; + die!(); } } @@ -727,7 +726,7 @@ fn test_spawn_raw_notify_failure() { .. default_task_opts() }; do spawn_raw(move opts) { - fail; + die!(); } assert notify_po.recv() == Failure; } diff --git a/src/libcore/to_str.rs b/src/libcore/to_str.rs index b1fb1fdd483..0e46b4fd004 100644 --- a/src/libcore/to_str.rs +++ b/src/libcore/to_str.rs @@ -22,104 +22,68 @@ use kinds::Copy; use str; use vec; -pub trait ToStr { pub pure fn to_str() -> ~str; } - -impl int: ToStr { - #[inline(always)] - pure fn to_str() -> ~str { ::int::str(self) } -} -impl i8: ToStr { - #[inline(always)] - pure fn to_str() -> ~str { ::i8::str(self) } -} -impl i16: ToStr { - #[inline(always)] - pure fn to_str() -> ~str { ::i16::str(self) } -} -impl i32: ToStr { - #[inline(always)] - pure fn to_str() -> ~str { ::i32::str(self) } -} -impl i64: ToStr { - #[inline(always)] - pure fn to_str() -> ~str { ::i64::str(self) } -} -impl uint: ToStr { - #[inline(always)] - pure fn to_str() -> ~str { ::uint::str(self) } -} -impl u8: ToStr { - #[inline(always)] - pure fn to_str() -> ~str { ::u8::str(self) } -} -impl u16: ToStr { - #[inline(always)] - pure fn to_str() -> ~str { ::u16::str(self) } -} -impl u32: ToStr { - #[inline(always)] - pure fn to_str() -> ~str { ::u32::str(self) } -} -impl u64: ToStr { - #[inline(always)] - pure fn to_str() -> ~str { ::u64::str(self) } -} -impl float: ToStr { - #[inline(always)] - pure fn to_str() -> ~str { ::float::to_str(self, 4u) } -} -impl f32: ToStr { - #[inline(always)] - pure fn to_str() -> ~str { ::float::to_str(self as float, 4u) } -} -impl f64: ToStr { - #[inline(always)] - pure fn to_str() -> ~str { ::float::to_str(self as float, 4u) } +pub trait ToStr { + pure fn to_str(&self) -> ~str; } + impl bool: ToStr { #[inline(always)] - pure fn to_str() -> ~str { ::bool::to_str(self) } + pure fn to_str(&self) -> ~str { ::bool::to_str(*self) } } impl (): ToStr { #[inline(always)] - pure fn to_str() -> ~str { ~"()" } + pure fn to_str(&self) -> ~str { ~"()" } } impl ~str: ToStr { #[inline(always)] - pure fn to_str() -> ~str { copy self } + pure fn to_str(&self) -> ~str { copy *self } } impl &str: ToStr { #[inline(always)] - pure fn to_str() -> ~str { ::str::from_slice(self) } + pure fn to_str(&self) -> ~str { ::str::from_slice(*self) } } impl @str: ToStr { #[inline(always)] - pure fn to_str() -> ~str { ::str::from_slice(self) } + pure fn to_str(&self) -> ~str { ::str::from_slice(*self) } } -impl<A: ToStr Copy, B: ToStr Copy> (A, B): ToStr { - #[inline(always)] - pure fn to_str() -> ~str { - let (a, b) = self; - ~"(" + a.to_str() + ~", " + b.to_str() + ~")" +impl<A: ToStr, B: ToStr> (A, B): ToStr { + #[inline(always)] + pure fn to_str(&self) -> ~str { + // FIXME(#4760): this causes an llvm assertion + //let &(ref a, ref b) = self; + match *self { + (ref a, ref b) => { + ~"(" + a.to_str() + ~", " + b.to_str() + ~")" + } + } } } -impl<A: ToStr Copy, B: ToStr Copy, C: ToStr Copy> (A, B, C): ToStr { - #[inline(always)] - pure fn to_str() -> ~str { - let (a, b, c) = self; - ~"(" + a.to_str() + ~", " + b.to_str() + ~", " + c.to_str() + ~")" +impl<A: ToStr, B: ToStr, C: ToStr> (A, B, C): ToStr { + #[inline(always)] + pure fn to_str(&self) -> ~str { + // FIXME(#4760): this causes an llvm assertion + //let &(ref a, ref b, ref c) = self; + match *self { + (ref a, ref b, ref c) => { + fmt!("(%s, %s, %s)", + (*a).to_str(), + (*b).to_str(), + (*c).to_str() + ) + } + } } } impl<A: ToStr> ~[A]: ToStr { #[inline(always)] - pure fn to_str() -> ~str { + pure fn to_str(&self) -> ~str { unsafe { // Bleh -- not really unsafe // push_str and push_char let mut acc = ~"[", first = true; - for vec::each(self) |elt| { + for self.each |elt| { unsafe { if first { first = false; } else { str::push_str(&mut acc, ~", "); } @@ -134,11 +98,11 @@ impl<A: ToStr> ~[A]: ToStr { impl<A: ToStr> @A: ToStr { #[inline(always)] - pure fn to_str() -> ~str { ~"@" + (*self).to_str() } + pure fn to_str(&self) -> ~str { ~"@" + (**self).to_str() } } impl<A: ToStr> ~A: ToStr { #[inline(always)] - pure fn to_str() -> ~str { ~"~" + (*self).to_str() } + pure fn to_str(&self) -> ~str { ~"~" + (**self).to_str() } } #[cfg(test)] diff --git a/src/libcore/util.rs b/src/libcore/util.rs index fba3e68511c..8dff492e634 100644 --- a/src/libcore/util.rs +++ b/src/libcore/util.rs @@ -100,7 +100,7 @@ fn choose_weighted_item(v: &[Item]) -> Item { */ pub fn unreachable() -> ! { - fail ~"internal error: entered unreachable code"; + die!(~"internal error: entered unreachable code"); } mod tests { diff --git a/src/libcore/vec.rs b/src/libcore/vec.rs index ef7a07ca131..7846d3d0302 100644 --- a/src/libcore/vec.rs +++ b/src/libcore/vec.rs @@ -241,7 +241,7 @@ pub pure fn init<T: Copy>(v: &[const T]) -> ~[T] { /// Returns the last element of the slice `v`, failing if the slice is empty. pub pure fn last<T: Copy>(v: &[const T]) -> T { - if len(v) == 0u { fail ~"last_unsafe: empty vector" } + if len(v) == 0u { die!(~"last_unsafe: empty vector") } v[len(v) - 1u] } @@ -568,7 +568,7 @@ pub fn consume_mut<T>(v: ~[mut T], f: fn(uint, v: T)) { pub fn pop<T>(v: &mut ~[T]) -> T { let ln = v.len(); if ln == 0 { - fail ~"sorry, cannot vec::pop an empty vector" + die!(~"sorry, cannot vec::pop an empty vector") } let valptr = ptr::to_mut_unsafe_ptr(&mut v[ln - 1u]); unsafe { @@ -589,7 +589,7 @@ pub fn pop<T>(v: &mut ~[T]) -> T { pub fn swap_remove<T>(v: &mut ~[T], index: uint) -> T { let ln = v.len(); if index >= ln { - fail fmt!("vec::swap_remove - index %u >= length %u", index, ln); + die!(fmt!("vec::swap_remove - index %u >= length %u", index, ln)); } if index < ln - 1 { v[index] <-> v[ln - 1]; @@ -831,7 +831,7 @@ pub pure fn flat_map<T, U>(v: &[T], f: fn(t: &T) -> ~[U]) -> ~[U] { pub pure fn map2<T: Copy, U: Copy, V>(v0: &[T], v1: &[U], f: fn(t: &T, v: &U) -> V) -> ~[V] { let v0_len = len(v0); - if v0_len != len(v1) { fail; } + if v0_len != len(v1) { die!(); } let mut u: ~[V] = ~[]; let mut i = 0u; while i < v0_len { @@ -2859,7 +2859,7 @@ mod tests { #[test] fn test_each_empty() { for each::<int>(~[]) |_v| { - fail; // should never be executed + die!(); // should never be executed } } @@ -2886,7 +2886,7 @@ mod tests { #[test] fn test_reach_empty() { for rev_each::<int>(~[]) |_v| { - fail; // should never execute + die!(); // should never execute } } @@ -3388,7 +3388,7 @@ mod tests { #[should_fail] fn test_from_fn_fail() { do from_fn(100) |v| { - if v == 50 { fail } + if v == 50 { die!() } (~0, @0) }; } @@ -3402,7 +3402,7 @@ mod tests { push((~0, @0)); push((~0, @0)); push((~0, @0)); - fail; + die!(); }; } @@ -3415,7 +3415,7 @@ mod tests { let mut i = 0; do split(v) |_elt| { if i == 2 { - fail + die!() } i += 1; @@ -3432,7 +3432,7 @@ mod tests { let mut i = 0; do split(v) |_elt| { if i == 2 { - fail + die!() } i += 1; @@ -3449,7 +3449,7 @@ mod tests { let mut i = 0; do splitn(v, 100) |_elt| { if i == 2 { - fail + die!() } i += 1; @@ -3466,7 +3466,7 @@ mod tests { let mut i = 0; do split(v) |_elt| { if i == 2 { - fail + die!() } i += 1; @@ -3483,7 +3483,7 @@ mod tests { let mut i = 0; do rsplit(v) |_elt| { if i == 2 { - fail + die!() } i += 1; @@ -3500,7 +3500,7 @@ mod tests { let mut i = 0; do rsplit(v) |_elt| { if i == 2 { - fail + die!() } i += 1; @@ -3517,7 +3517,7 @@ mod tests { let mut i = 0; do rsplitn(v, 100) |_elt| { if i == 2 { - fail + die!() } i += 1; @@ -3534,7 +3534,7 @@ mod tests { let mut i = 0; do rsplitn(v, 100) |_elt| { if i == 2 { - fail + die!() } i += 1; @@ -3550,7 +3550,7 @@ mod tests { let mut i = 0; do consume(v) |_i, _elt| { if i == 2 { - fail + die!() } i += 1; }; @@ -3564,7 +3564,7 @@ mod tests { let mut i = 0; do consume_mut(v) |_i, _elt| { if i == 2 { - fail + die!() } i += 1; }; @@ -3578,7 +3578,7 @@ mod tests { let mut v = ~[]; do v.grow_fn(100) |i| { if i == 50 { - fail + die!() } (~0, @0) } @@ -3592,7 +3592,7 @@ mod tests { let mut i = 0; do map(v) |_elt| { if i == 2 { - fail + die!() } i += 0; ~[(~0, @0)] @@ -3607,7 +3607,7 @@ mod tests { let mut i = 0; do map_consume(v) |_elt| { if i == 2 { - fail + die!() } i += 0; ~[(~0, @0)] @@ -3622,7 +3622,7 @@ mod tests { let mut i = 0; do mapi(v) |_i, _elt| { if i == 2 { - fail + die!() } i += 0; ~[(~0, @0)] @@ -3637,7 +3637,7 @@ mod tests { let mut i = 0; do map(v) |_elt| { if i == 2 { - fail + die!() } i += 0; ~[(~0, @0)] @@ -3653,7 +3653,7 @@ mod tests { let mut i = 0; do map2(v, v) |_elt1, _elt2| { if i == 2 { - fail + die!() } i += 0; ~[(~0, @0)] @@ -3669,7 +3669,7 @@ mod tests { let mut i = 0; do filter_map(v) |_elt| { if i == 2 { - fail + die!() } i += 0; Some((~0, @0)) @@ -3685,7 +3685,7 @@ mod tests { let mut i = 0; do v.filtered |_elt| { if i == 2 { - fail + die!() } i += 0; true @@ -3701,7 +3701,7 @@ mod tests { let mut i = 0; do foldl((~0, @0), v) |_a, _b| { if i == 2 { - fail + die!() } i += 0; (~0, @0) @@ -3717,7 +3717,7 @@ mod tests { let mut i = 0; do foldr(v, (~0, @0)) |_a, _b| { if i == 2 { - fail + die!() } i += 0; (~0, @0) @@ -3732,7 +3732,7 @@ mod tests { let mut i = 0; do any(v) |_elt| { if i == 2 { - fail + die!() } i += 0; false @@ -3747,7 +3747,7 @@ mod tests { let mut i = 0; do any(v) |_elt| { if i == 2 { - fail + die!() } i += 0; false @@ -3762,7 +3762,7 @@ mod tests { let mut i = 0; do all(v) |_elt| { if i == 2 { - fail + die!() } i += 0; true @@ -3777,7 +3777,7 @@ mod tests { let mut i = 0; do alli(v) |_i, _elt| { if i == 2 { - fail + die!() } i += 0; true @@ -3792,7 +3792,7 @@ mod tests { let mut i = 0; do all2(v, v) |_elt1, _elt2| { if i == 2 { - fail + die!() } i += 0; true @@ -3808,7 +3808,7 @@ mod tests { let mut i = 0; do find(v) |_elt| { if i == 2 { - fail + die!() } i += 0; false @@ -3823,7 +3823,7 @@ mod tests { let mut i = 0; do position(v) |_elt| { if i == 2 { - fail + die!() } i += 0; false @@ -3838,7 +3838,7 @@ mod tests { let mut i = 0; do rposition(v) |_elt| { if i == 2 { - fail + die!() } i += 0; false @@ -3853,7 +3853,7 @@ mod tests { let mut i = 0; do each(v) |_elt| { if i == 2 { - fail + die!() } i += 0; false @@ -3868,7 +3868,7 @@ mod tests { let mut i = 0; do eachi(v) |_i, _elt| { if i == 2 { - fail + die!() } i += 0; false @@ -3884,7 +3884,7 @@ mod tests { let mut i = 0; for each_permutation(v) |_elt| { if i == 2 { - fail + die!() } i += 0; } @@ -3896,7 +3896,7 @@ mod tests { fn test_as_imm_buf_fail() { let v = [(~0, @0), (~0, @0), (~0, @0), (~0, @0)]; do as_imm_buf(v) |_buf, _i| { - fail + die!() } } @@ -3906,7 +3906,7 @@ mod tests { fn test_as_const_buf_fail() { let v = [(~0, @0), (~0, @0), (~0, @0), (~0, @0)]; do as_const_buf(v) |_buf, _i| { - fail + die!() } } @@ -3916,7 +3916,7 @@ mod tests { fn test_as_mut_buf_fail() { let v = [mut (~0, @0), (~0, @0), (~0, @0), (~0, @0)]; do as_mut_buf(v) |_buf, _i| { - fail + die!() } } diff --git a/src/libfuzzer/cycles.rs b/src/libfuzzer/cycles.rs index 5824fac8287..a64700494c8 100644 --- a/src/libfuzzer/cycles.rs +++ b/src/libfuzzer/cycles.rs @@ -43,7 +43,7 @@ type pointy = { mut g : fn~()->(), mut m : ~[maybe_pointy], - mut n : ~[mut maybe_pointy], + mut n : ~[maybe_pointy], mut o : {x : int, y : maybe_pointy} }; // To add: objects; traits; anything type-parameterized? @@ -58,7 +58,7 @@ fn empty_pointy() -> @pointy { mut g : fn~()->(){}, mut m : ~[], - mut n : ~[mut], + mut n : ~[], mut o : {x : 0, y : none} } } @@ -68,7 +68,7 @@ fn nop<T>(_x: T) { } fn test_cycles(r : rand::rng, k: uint, n: uint) { - let v : ~[mut @pointy] = ~[mut]; + let mut v : ~[@pointy] = ~[]; // Create a graph with no edges range(0u, vlen) {|_i| diff --git a/src/libfuzzer/fuzzer.rc b/src/libfuzzer/fuzzer.rc index 03b96e34e75..c8083554c8b 100644 --- a/src/libfuzzer/fuzzer.rc +++ b/src/libfuzzer/fuzzer.rc @@ -74,19 +74,16 @@ pub fn common_exprs() -> ~[ast::expr] { id: 0, callee_id: -1, node: e, - span: ast_util::dummy_sp(), + span: codemap::dummy_sp(), } } fn dsl(l: ast::lit_) -> ast::lit { - ast::spanned { node: l, span: ast_util::dummy_sp() } + codemap::spanned { node: l, span: codemap::dummy_sp() } } ~[dse(ast::expr_break(option::None)), dse(ast::expr_again(option::None)), - dse(ast::expr_fail(option::None)), - dse(ast::expr_fail(option::Some( - @dse(ast::expr_lit(@dsl(ast::lit_str(@~"boo"))))))), dse(ast::expr_ret(option::None)), dse(ast::expr_lit(@dsl(ast::lit_nil))), dse(ast::expr_lit(@dsl(ast::lit_bool(false)))), @@ -117,11 +114,10 @@ pub pure fn safe_to_use_expr(e: ast::expr, tm: test_mode) -> bool { ast::expr_binary(*) | ast::expr_assign(*) | ast::expr_assign_op(*) => { false } - ast::expr_fail(option::None) | ast::expr_ret(option::None) => { false } // https://github.com/mozilla/rust/issues/953 - ast::expr_fail(option::Some(_)) => { false } + //ast::expr_fail(option::Some(_)) => { false } // https://github.com/mozilla/rust/issues/928 //ast::expr_cast(_, _) { false } @@ -573,7 +569,7 @@ pub fn check_roundtrip_convergence(code: @~str, maxIters: uint) { run::run_program(~"diff", ~[~"-w", ~"-u", ~"round-trip-a.rs", ~"round-trip-b.rs"]); - fail ~"Mismatch"; + die!(~"Mismatch"); } } diff --git a/src/libfuzzer/rand_util.rs b/src/libfuzzer/rand_util.rs index d16a7d0f17f..ea8bd05c38b 100644 --- a/src/libfuzzer/rand_util.rs +++ b/src/libfuzzer/rand_util.rs @@ -25,7 +25,7 @@ fn choice<T: copy>(r : rand::rng, v : ~[T]) -> T { fn unlikely(r : rand::rng, n : uint) -> bool { under(r, n) == 0u } // shuffle a vec in place -fn shuffle<T>(r : rand::rng, &v : ~[mut T]) { +fn shuffle<T>(r : rand::rng, &v : ~[T]) { let i = vec::len(v); while i >= 2u { // Loop invariant: elements with index >= i have been locked in place. @@ -42,7 +42,7 @@ fn shuffled<T: copy>(r : rand::rng, v : ~[T]) -> ~[T] { } // sample from a population without replacement -//fn sample<T>(r : rand::rng, pop : ~[T], k : uint) -> ~[T] { fail } +//fn sample<T>(r : rand::rng, pop : ~[T], k : uint) -> ~[T] { die!() } // Two ways to make a weighted choice. // * weighted_choice is O(number of choices) time @@ -86,7 +86,7 @@ fn main() log(error, choice(r, ~[10, 20, 30])); log(error, if unlikely(r, 5u) { "unlikely" } else { "likely" }); - let a = ~[mut 1, 2, 3]; + let mut a = ~[1, 2, 3]; shuffle(r, a); log(error, a); diff --git a/src/librustc/back/link.rs b/src/librustc/back/link.rs index 53179d4377e..22923cb7290 100644 --- a/src/librustc/back/link.rs +++ b/src/librustc/back/link.rs @@ -36,7 +36,7 @@ use core::ptr; use core::run; use core::str; use core::vec; -use std::map::HashMap; +use std::oldmap::HashMap; use std::sha1::sha1; use syntax::ast; use syntax::ast_map::{path, path_mod, path_name}; @@ -509,7 +509,7 @@ pub fn build_link_meta(sess: Session, c: &ast::crate, output: &Path, } ast::meta_list(_, _) => { // FIXME (#607): Implement this - fail ~"unimplemented meta_item variant"; + die!(~"unimplemented meta_item variant"); } } } diff --git a/src/librustc/back/rpath.rs b/src/librustc/back/rpath.rs index 560b26951a6..f6a5fec75ad 100644 --- a/src/librustc/back/rpath.rs +++ b/src/librustc/back/rpath.rs @@ -18,8 +18,8 @@ use core::os; use core::uint; use core::util; use core::vec; -use std::map::HashMap; -use std::map; +use std::oldmap::HashMap; +use std::oldmap; pure fn not_win32(os: session::os) -> bool { match os { @@ -179,7 +179,7 @@ pub fn get_install_prefix_rpath(target_triple: &str) -> Path { let install_prefix = env!("CFG_PREFIX"); if install_prefix == ~"" { - fail ~"rustc compiled without CFG_PREFIX environment variable"; + die!(~"rustc compiled without CFG_PREFIX environment variable"); } let tlib = filesearch::relative_target_lib_path(target_triple); @@ -187,7 +187,7 @@ pub fn get_install_prefix_rpath(target_triple: &str) -> Path { } pub fn minimize_rpaths(rpaths: &[Path]) -> ~[Path] { - let set = map::HashMap(); + let set = oldmap::HashMap(); let mut minimized = ~[]; for rpaths.each |rpath| { let s = rpath.to_str(); diff --git a/src/librustc/driver/driver.rs b/src/librustc/driver/driver.rs index eca6a598f8d..1464fa29afc 100644 --- a/src/librustc/driver/driver.rs +++ b/src/librustc/driver/driver.rs @@ -35,7 +35,7 @@ use std::getopts::groups::{optopt, optmulti, optflag, optflagopt, getopts}; use std::getopts::groups; use std::getopts::{opt_present}; use std::getopts; -use std::map::HashMap; +use std::oldmap::HashMap; use std; use syntax::ast; use syntax::ast_map; @@ -382,21 +382,21 @@ pub fn pretty_print_input(sess: Session, +cfg: ast::crate_cfg, input: input, match node { pprust::node_item(s, item) => { pp::space(s.s); - pprust::synth_comment(s, int::to_str(item.id, 10u)); + pprust::synth_comment(s, int::to_str(item.id)); } pprust::node_block(s, ref blk) => { pp::space(s.s); pprust::synth_comment( - s, ~"block " + int::to_str((*blk).node.id, 10u)); + s, ~"block " + int::to_str((*blk).node.id)); } pprust::node_expr(s, expr) => { pp::space(s.s); - pprust::synth_comment(s, int::to_str(expr.id, 10u)); + pprust::synth_comment(s, int::to_str(expr.id)); pprust::pclose(s); } pprust::node_pat(s, pat) => { pp::space(s.s); - pprust::synth_comment(s, ~"pat " + int::to_str(pat.id, 10u)); + pprust::synth_comment(s, ~"pat " + int::to_str(pat.id)); } } } @@ -506,7 +506,7 @@ pub fn host_triple() -> ~str { return if ht != ~"" { ht } else { - fail ~"rustc built without CFG_HOST_TRIPLE" + die!(~"rustc built without CFG_HOST_TRIPLE") }; } @@ -846,7 +846,7 @@ pub fn build_output_filenames(input: input, pub fn early_error(emitter: diagnostic::emitter, msg: ~str) -> ! { emitter(None, msg, diagnostic::fatal); - fail; + die!(); } pub fn list_metadata(sess: Session, path: &Path, out: io::Writer) { @@ -874,8 +874,8 @@ pub mod test { let matches = &match getopts(~[~"--test"], optgroups()) { Ok(copy m) => m, - Err(copy f) => fail ~"test_switch_implies_cfg_test: " + - getopts::fail_str(f) + Err(copy f) => die!(~"test_switch_implies_cfg_test: " + + getopts::fail_str(f)) }; let sessopts = build_session_options( ~"rustc", matches, diagnostic::emit); @@ -892,8 +892,8 @@ pub mod test { &match getopts(~[~"--test", ~"--cfg=test"], optgroups()) { Ok(copy m) => m, Err(copy f) => { - fail ~"test_switch_implies_cfg_test_unless_cfg_test: " + - getopts::fail_str(f); + die!(~"test_switch_implies_cfg_test_unless_cfg_test: " + + getopts::fail_str(f)); } }; let sessopts = build_session_options( diff --git a/src/librustc/driver/session.rs b/src/librustc/driver/session.rs index 3b32952ba31..9ffb29bc885 100644 --- a/src/librustc/driver/session.rs +++ b/src/librustc/driver/session.rs @@ -344,14 +344,15 @@ pub mod test { use syntax::ast; use syntax::ast_util; + use syntax::codemap; pub fn make_crate_type_attr(+t: ~str) -> ast::attribute { - ast_util::respan(ast_util::dummy_sp(), ast::attribute_ { + codemap::respan(codemap::dummy_sp(), ast::attribute_ { style: ast::attr_outer, - value: ast_util::respan(ast_util::dummy_sp(), + value: codemap::respan(codemap::dummy_sp(), ast::meta_name_value( ~"crate_type", - ast_util::respan(ast_util::dummy_sp(), + codemap::respan(codemap::dummy_sp(), ast::lit_str(@t)))), is_sugared_doc: false }) @@ -361,7 +362,7 @@ pub mod test { let mut attrs = ~[]; if with_bin { attrs += ~[make_crate_type_attr(~"bin")]; } if with_lib { attrs += ~[make_crate_type_attr(~"lib")]; } - @ast_util::respan(ast_util::dummy_sp(), ast::crate_ { + @codemap::respan(codemap::dummy_sp(), ast::crate_ { module: ast::_mod { view_items: ~[], items: ~[] }, attrs: attrs, config: ~[] diff --git a/src/librustc/front/core_inject.rs b/src/librustc/front/core_inject.rs index 835203f4efe..143eb556f96 100644 --- a/src/librustc/front/core_inject.rs +++ b/src/librustc/front/core_inject.rs @@ -17,6 +17,7 @@ use syntax::ast; use syntax::ast_util::*; use syntax::attr; use syntax::codemap; +use syntax::codemap::dummy_sp; use syntax::fold; const CORE_VERSION: &static/str = "0.6"; @@ -36,8 +37,8 @@ fn use_core(crate: @ast::crate) -> bool { fn inject_libcore_ref(sess: Session, crate: @ast::crate) -> @ast::crate { - fn spanned<T: Copy>(x: T) -> ast::spanned<T> { - ast::spanned { node: x, span: dummy_sp() } + fn spanned<T: Copy>(x: T) -> codemap::spanned<T> { + codemap::spanned { node: x, span: dummy_sp() } } let precursor = @fold::AstFoldFns { diff --git a/src/librustc/front/intrinsic_inject.rs b/src/librustc/front/intrinsic_inject.rs index 94333e0126c..c660fa3ef80 100644 --- a/src/librustc/front/intrinsic_inject.rs +++ b/src/librustc/front/intrinsic_inject.rs @@ -13,6 +13,7 @@ use core::prelude::*; use driver::session::Session; use syntax::parse; use syntax::ast; +use syntax::codemap::spanned; use core::vec; @@ -34,7 +35,7 @@ pub fn inject_intrinsic(sess: Session, crate: @ast::crate) -> @ast::crate { let items = vec::append(~[item], crate.node.module.items); - @ast::spanned { + @spanned { node: ast::crate_ { module: ast::_mod { items: items, diff --git a/src/librustc/front/test.rs b/src/librustc/front/test.rs index a33d78c3b58..91eb8148bb7 100644 --- a/src/librustc/front/test.rs +++ b/src/librustc/front/test.rs @@ -21,7 +21,8 @@ use core::option; use core::vec; use syntax::ast_util::*; use syntax::attr; -use syntax::codemap::span; +use syntax::codemap::{dummy_sp, span}; +use syntax::codemap; use syntax::fold; use syntax::print::pprust; use syntax::{ast, ast_util}; @@ -237,8 +238,8 @@ fn mk_test_module(cx: test_ctxt) -> @ast::item { return @item; } -fn nospan<T: Copy>(t: T) -> ast::spanned<T> { - ast::spanned { node: t, span: dummy_sp() } +fn nospan<T: Copy>(t: T) -> codemap::spanned<T> { + codemap::spanned { node: t, span: dummy_sp() } } fn path_node(+ids: ~[ast::ident]) -> @ast::path { @@ -535,7 +536,7 @@ fn mk_main(cx: test_ctxt) -> @ast::item { let body_: ast::blk_ = default_block(~[], option::Some(test_main_call_expr), cx.sess.next_node_id()); - let body = ast::spanned { node: body_, span: dummy_sp() }; + let body = codemap::spanned { node: body_, span: dummy_sp() }; let item_ = ast::item_fn(decl, ast::impure_fn, ~[], body); let item = ast::item { diff --git a/src/librustc/lib/llvm.rs b/src/librustc/lib/llvm.rs index 375a3b43aad..e114a18f4fd 100644 --- a/src/librustc/lib/llvm.rs +++ b/src/librustc/lib/llvm.rs @@ -20,7 +20,7 @@ use core::ptr; use core::str; use core::uint; use core::vec; -use std::map::HashMap; +use std::oldmap::HashMap; pub type Opcode = u32; pub type Bool = c_uint; @@ -1451,7 +1451,7 @@ pub fn float_width(llt: TypeRef) -> uint { 2 => 64u, 3 => 80u, 4 | 5 => 128u, - _ => fail ~"llvm_float_width called on a non-float type" + _ => die!(~"llvm_float_width called on a non-float type") }; } } diff --git a/src/librustc/metadata/creader.rs b/src/librustc/metadata/creader.rs index e91c4f93864..66956489a27 100644 --- a/src/librustc/metadata/creader.rs +++ b/src/librustc/metadata/creader.rs @@ -24,13 +24,13 @@ use core::either; use core::option; use core::vec; use syntax::attr; -use syntax::codemap::span; +use syntax::codemap::{span, dummy_sp}; use syntax::diagnostic::span_handler; use syntax::parse::token::ident_interner; use syntax::print::pprust; use syntax::visit; use syntax::{ast, ast_util}; -use std::map::HashMap; +use std::oldmap::HashMap; // Traverses an AST, reading all the information about use'd crates and extern // libraries necessary for later resolving, typechecking, linking, etc. @@ -294,7 +294,7 @@ fn resolve_crate_deps(e: env, cdata: @~[u8]) -> cstore::cnum_map { // This is a new one so we've got to load it // FIXME (#2404): Need better error reporting than just a bogus // span. - let fake_span = ast_util::dummy_sp(); + let fake_span = dummy_sp(); let local_cnum = resolve_crate(e, cname, cmetas, /*bad*/copy dep.hash, fake_span); cnum_map.insert(extrn_cnum, local_cnum); diff --git a/src/librustc/metadata/csearch.rs b/src/librustc/metadata/csearch.rs index a150ef6e337..59cc7d1dba6 100644 --- a/src/librustc/metadata/csearch.rs +++ b/src/librustc/metadata/csearch.rs @@ -23,10 +23,10 @@ use core::dvec::DVec; use core::vec; use reader = std::ebml::reader; use std::ebml; -use std::map::HashMap; +use std::oldmap::HashMap; use syntax::ast; use syntax::ast_map; -use syntax::ast_util::dummy_sp; +use syntax::codemap::dummy_sp; use syntax::ast_util; use syntax::diagnostic::expect; use syntax::diagnostic::span_handler; diff --git a/src/librustc/metadata/cstore.rs b/src/librustc/metadata/cstore.rs index f2bd998b557..c8a1a619436 100644 --- a/src/librustc/metadata/cstore.rs +++ b/src/librustc/metadata/cstore.rs @@ -21,8 +21,8 @@ use metadata::decoder; use core::option; use core::str; use core::vec; -use std::map::HashMap; -use std::map; +use std::oldmap::HashMap; +use std::oldmap; use std; use syntax::{ast, attr}; use syntax::parse::token::ident_interner; @@ -31,7 +31,7 @@ use syntax::parse::token::ident_interner; // local crate numbers (as generated during this session). Each external // crate may refer to types in other external crates, and each has their // own crate numbers. -pub type cnum_map = map::HashMap<ast::crate_num, ast::crate_num>; +pub type cnum_map = oldmap::HashMap<ast::crate_num, ast::crate_num>; pub type crate_metadata = @{name: ~str, data: @~[u8], @@ -46,7 +46,7 @@ pub type crate_metadata = @{name: ~str, pub enum CStore { private(cstore_private), } type cstore_private = - @{metas: map::HashMap<ast::crate_num, crate_metadata>, + @{metas: oldmap::HashMap<ast::crate_num, crate_metadata>, use_crate_map: use_crate_map, mut used_crate_files: ~[Path], mut used_libraries: ~[~str], @@ -54,7 +54,7 @@ type cstore_private = intr: @ident_interner}; // Map from node_id's of local use statements to crate numbers -type use_crate_map = map::HashMap<ast::node_id, ast::crate_num>; +type use_crate_map = oldmap::HashMap<ast::node_id, ast::crate_num>; // Internal method to retrieve the data from the cstore pure fn p(cstore: CStore) -> cstore_private { @@ -62,8 +62,8 @@ pure fn p(cstore: CStore) -> cstore_private { } pub fn mk_cstore(intr: @ident_interner) -> CStore { - let meta_cache = map::HashMap(); - let crate_map = map::HashMap(); + let meta_cache = oldmap::HashMap(); + let crate_map = oldmap::HashMap(); return private(@{metas: meta_cache, use_crate_map: crate_map, mut used_crate_files: ~[], @@ -94,12 +94,12 @@ pub fn set_crate_data(cstore: CStore, } pub fn have_crate_data(cstore: CStore, cnum: ast::crate_num) -> bool { - return p(cstore).metas.contains_key(cnum); + return p(cstore).metas.contains_key_ref(&cnum); } pub fn iter_crate_data(cstore: CStore, i: fn(ast::crate_num, crate_metadata)) { - for p(cstore).metas.each |k,v| { i(k, v);}; + for p(cstore).metas.each_ref |&k, &v| { i(k, v);}; } pub fn add_used_crate_file(cstore: CStore, lib: &Path) { @@ -148,7 +148,7 @@ pub fn get_dep_hashes(cstore: CStore) -> ~[~str] { type crate_hash = {name: ~str, hash: ~str}; let mut result = ~[]; - for p(cstore).use_crate_map.each_value |cnum| { + for p(cstore).use_crate_map.each_value_ref |&cnum| { let cdata = cstore::get_crate_data(cstore, cnum); let hash = decoder::get_crate_hash(cdata.data); debug!("Add hash[%s]: %s", cdata.name, hash); diff --git a/src/librustc/metadata/decoder.rs b/src/librustc/metadata/decoder.rs index 173547a268d..c3c7c969cd8 100644 --- a/src/librustc/metadata/decoder.rs +++ b/src/librustc/metadata/decoder.rs @@ -36,8 +36,8 @@ use core::str; use core::vec; use std::ebml::reader; use std::ebml; -use std::map::HashMap; -use std::map; +use std::oldmap::HashMap; +use std::oldmap; use std::serialize::Decodable; use syntax::ast_map; use syntax::attr; @@ -45,6 +45,7 @@ use syntax::diagnostic::span_handler; use syntax::parse::token::ident_interner; use syntax::print::pprust; use syntax::{ast, ast_util}; +use syntax::codemap; // A function that takes a def_id relative to the crate being searched and // returns a def_id relative to the compilation environment, i.e. if we hit a @@ -91,7 +92,7 @@ fn find_item(item_id: int, items: ebml::Doc) -> ebml::Doc { fn lookup_item(item_id: int, data: @~[u8]) -> ebml::Doc { let items = reader::get_doc(reader::Doc(data), tag_items); match maybe_find_item(item_id, items) { - None => fail(fmt!("lookup_item: id not found: %d", item_id)), + None => die!(fmt!("lookup_item: id not found: %d", item_id)), Some(d) => d } } @@ -149,7 +150,7 @@ fn item_family(item: ebml::Doc) -> Family { 'g' => PublicField, 'j' => PrivateField, 'N' => InheritedField, - c => fail (fmt!("unexpected family char: %c", c)) + c => die!(fmt!("unexpected family char: %c", c)) } } @@ -396,7 +397,7 @@ pub fn struct_dtor(cdata: cmd, id: ast::node_id) -> Option<ast::def_id> { let mut found = None; let cls_items = match maybe_find_item(id, items) { Some(it) => it, - None => fail (fmt!("struct_dtor: class id not found \ + None => die!(fmt!("struct_dtor: class id not found \ when looking up dtor for %d", id)) }; for reader::tagged_docs(cls_items, tag_item_dtor) |doc| { @@ -421,8 +422,8 @@ pub enum def_like { fn def_like_to_def(def_like: def_like) -> ast::def { match def_like { dl_def(def) => return def, - dl_impl(*) => fail ~"found impl in def_like_to_def", - dl_field => fail ~"found field in def_like_to_def" + dl_impl(*) => die!(~"found impl in def_like_to_def"), + dl_field => die!(~"found field in def_like_to_def") } } @@ -625,7 +626,7 @@ fn get_self_ty(item: ebml::Doc) -> ast::self_ty_ { 'm' => { ast::m_mutbl } 'c' => { ast::m_const } _ => { - fail fmt!("unknown mutability character: `%c`", ch as char) + die!(fmt!("unknown mutability character: `%c`", ch as char)) } } } @@ -642,7 +643,7 @@ fn get_self_ty(item: ebml::Doc) -> ast::self_ty_ { '~' => { return ast::sty_uniq(get_mutability(string[1])); } '&' => { return ast::sty_region(get_mutability(string[1])); } _ => { - fail fmt!("unknown self type code: `%c`", self_ty_kind as char); + die!(fmt!("unknown self type code: `%c`", self_ty_kind as char)); } } } @@ -832,7 +833,7 @@ pub fn get_static_methods_if_impl(intr: @ident_interner, StaticMethod => purity = ast::impure_fn, UnsafeStaticMethod => purity = ast::unsafe_fn, PureStaticMethod => purity = ast::pure_fn, - _ => fail + _ => die!() } static_impl_methods.push(StaticMethodInfo { @@ -865,7 +866,7 @@ pure fn family_to_visibility(family: Family) -> ast::visibility { PublicField => ast::public, PrivateField => ast::private, InheritedField => ast::inherited, - _ => fail + _ => die!() } } @@ -915,7 +916,7 @@ fn describe_def(items: ebml::Doc, id: ast::def_id) -> ~str { if id.crate != ast::local_crate { return ~"external"; } let it = match maybe_find_item(id.node, items) { Some(it) => it, - None => fail (fmt!("describe_def: item not found %?", id)) + None => die!(fmt!("describe_def: item not found %?", id)) }; return item_family_to_str(item_family(it)); } @@ -981,13 +982,13 @@ fn get_attributes(md: ebml::Doc) -> ~[ast::attribute] { assert (vec::len(meta_items) == 1u); let meta_item = meta_items[0]; attrs.push( - ast::spanned { + codemap::spanned { node: ast::attribute_ { style: ast::attr_outer, value: /*bad*/copy *meta_item, is_sugared_doc: false, }, - span: ast_util::dummy_sp() + span: codemap::dummy_sp() }); }; } @@ -1100,7 +1101,7 @@ pub fn translate_def_id(cdata: cmd, did: ast::def_id) -> ast::def_id { match cdata.cnum_map.find(did.crate) { option::Some(n) => ast::def_id { crate: n, node: did.node }, - option::None => fail ~"didn't find a crate in the cnum_map" + option::None => die!(~"didn't find a crate in the cnum_map") } } diff --git a/src/librustc/metadata/encoder.rs b/src/librustc/metadata/encoder.rs index 49d7bfeb2f9..438084a3bd7 100644 --- a/src/librustc/metadata/encoder.rs +++ b/src/librustc/metadata/encoder.rs @@ -36,9 +36,9 @@ use core::str; use core::to_bytes::IterBytes; use core::uint; use core::vec; -use std::map::HashMap; +use std::oldmap::HashMap; use std::serialize::Encodable; -use std::{ebml, map}; +use std::{ebml, oldmap}; use std; use syntax::ast::*; use syntax::ast; @@ -52,7 +52,7 @@ use syntax; use writer = std::ebml::writer; // used by astencode: -type abbrev_map = map::HashMap<ty::t, tyencode::ty_abbrev>; +type abbrev_map = oldmap::HashMap<ty::t, tyencode::ty_abbrev>; pub type encode_inlined_item = fn@(ecx: @encode_ctxt, ebml_w: writer::Encoder, @@ -99,7 +99,7 @@ pub enum encode_ctxt = { }; pub fn reachable(ecx: @encode_ctxt, id: node_id) -> bool { - ecx.reachable.contains_key(id) + ecx.reachable.contains_key_ref(&id) } fn encode_name(ecx: @encode_ctxt, ebml_w: writer::Encoder, name: ident) { @@ -245,7 +245,7 @@ fn encode_discriminant(ecx: @encode_ctxt, ebml_w: writer::Encoder, fn encode_disr_val(_ecx: @encode_ctxt, ebml_w: writer::Encoder, disr_val: int) { ebml_w.start_tag(tag_disr_val); - ebml_w.writer.write(str::to_bytes(int::to_str(disr_val,10u))); + ebml_w.writer.write(str::to_bytes(int::to_str(disr_val))); ebml_w.end_tag(); } @@ -527,7 +527,7 @@ fn purity_static_method_family(p: purity) -> char { unsafe_fn => 'U', pure_fn => 'P', impure_fn => 'F', - _ => fail ~"extern fn can't be static" + _ => die!(~"extern fn can't be static") } } @@ -547,8 +547,8 @@ fn encode_info_for_item(ecx: @encode_ctxt, ebml_w: writer::Encoder, let tcx = ecx.tcx; let must_write = match item.node { - item_enum(_, _) | item_impl(*) - | item_trait(*) | item_struct(*) => true, + item_enum(_, _) | item_impl(*) | item_trait(*) | item_struct(*) | + item_mod(*) | item_foreign_mod(*) => true, _ => false }; if !must_write && !reachable(ecx, item.id) { return; } @@ -829,7 +829,7 @@ fn encode_info_for_item(ecx: @encode_ctxt, ebml_w: writer::Encoder, true, item.id, *m, /*bad*/copy m.tps); } } - item_mac(*) => fail ~"item macros unimplemented" + item_mac(*) => die!(~"item macros unimplemented") } } @@ -886,7 +886,7 @@ fn encode_info_for_items(ecx: @encode_ctxt, ebml_w: writer::Encoder, encode_info_for_item(ecx, ebml_w, i, index, *pt); } - _ => fail ~"bad item" + _ => die!(~"bad item") } } }, @@ -901,7 +901,7 @@ fn encode_info_for_items(ecx: @encode_ctxt, ebml_w: writer::Encoder, abi); } // case for separate item and foreign-item tables - _ => fail ~"bad foreign item" + _ => die!(~"bad foreign item") } } }, diff --git a/src/librustc/metadata/filesearch.rs b/src/librustc/metadata/filesearch.rs index cd0544202a7..dfccaf77dfd 100644 --- a/src/librustc/metadata/filesearch.rs +++ b/src/librustc/metadata/filesearch.rs @@ -108,7 +108,7 @@ fn make_target_lib_path(sysroot: &Path, fn get_or_default_sysroot() -> Path { match os::self_exe_path() { option::Some(ref p) => (*p).pop(), - option::None => fail ~"can't determine value for sysroot" + option::None => die!(~"can't determine value for sysroot") } } @@ -176,7 +176,7 @@ fn get_cargo_lib_path_nearest() -> Result<Path, ~str> { pub fn libdir() -> ~str { let libdir = env!("CFG_LIBDIR"); if str::is_empty(libdir) { - fail ~"rustc compiled without CFG_LIBDIR environment variable"; + die!(~"rustc compiled without CFG_LIBDIR environment variable"); } libdir } diff --git a/src/librustc/metadata/loader.rs b/src/librustc/metadata/loader.rs index d523b198b31..c4cb154e21f 100644 --- a/src/librustc/metadata/loader.rs +++ b/src/librustc/metadata/loader.rs @@ -150,10 +150,10 @@ pub fn crate_name_from_metas(+metas: ~[@ast::meta_item]) -> ~str { Some(ref n) => (/*bad*/copy *n), // FIXME (#2406): Probably want a warning here since the user // is using the wrong type of meta item. - _ => fail + _ => die!() } } - None => fail ~"expected to find the crate name" + None => die!(~"expected to find the crate name") } } diff --git a/src/librustc/metadata/tydecode.rs b/src/librustc/metadata/tydecode.rs index 4c2937b952e..5dd499dfd63 100644 --- a/src/librustc/metadata/tydecode.rs +++ b/src/librustc/metadata/tydecode.rs @@ -26,9 +26,8 @@ use core::uint; use core::vec; use syntax::ast; use syntax::ast::*; -use syntax::ast_util; -use syntax::ast_util::respan; -use std::map::HashMap; +use syntax::codemap::{respan, dummy_sp}; +use std::oldmap::HashMap; // Compact string representation for ty::t values. API ty_str & // parse_from_str. Extra parameters are for converting to/from def_ids in the @@ -114,7 +113,7 @@ fn parse_path(st: @pstate) -> @ast::path { ':' => { next(st); next(st); } c => { if c == '(' { - return @ast::path { span: ast_util::dummy_sp(), + return @ast::path { span: dummy_sp(), global: false, idents: idents, rp: None, @@ -135,7 +134,7 @@ fn parse_proto(st: @pstate) -> ast::Proto { '@' => ast::ProtoBox, '~' => ast::ProtoUniq, '&' => ast::ProtoBorrowed, - _ => fail ~"parse_proto(): bad input" + _ => die!(~"parse_proto(): bad input") } } @@ -153,7 +152,7 @@ fn parse_vstore(st: @pstate) -> ty::vstore { '~' => ty::vstore_uniq, '@' => ty::vstore_box, '&' => ty::vstore_slice(parse_region(st)), - _ => fail ~"parse_vstore: bad input" + _ => die!(~"parse_vstore: bad input") } } @@ -188,7 +187,7 @@ fn parse_bound_region(st: @pstate) -> ty::bound_region { assert next(st) == '|'; ty::br_cap_avoid(id, @parse_bound_region(st)) }, - _ => fail ~"parse_bound_region: bad input" + _ => die!(~"parse_bound_region: bad input") } } @@ -213,7 +212,7 @@ fn parse_region(st: @pstate) -> ty::Region { 't' => { ty::re_static } - _ => fail ~"parse_region: bad input" + _ => die!(~"parse_region: bad input") } } @@ -221,7 +220,7 @@ fn parse_opt<T>(st: @pstate, f: fn() -> T) -> Option<T> { match next(st) { 'n' => None, 's' => Some(f()), - _ => fail ~"parse_opt: bad input" + _ => die!(~"parse_opt: bad input") } } @@ -254,7 +253,7 @@ fn parse_ty(st: @pstate, conv: conv_did) -> ty::t { 'D' => return ty::mk_mach_int(st.tcx, ast::ty_i64), 'f' => return ty::mk_mach_float(st.tcx, ast::ty_f32), 'F' => return ty::mk_mach_float(st.tcx, ast::ty_f64), - _ => fail ~"parse_ty: bad numeric type" + _ => die!(~"parse_ty: bad numeric type") } } 'c' => return ty::mk_char(st.tcx), @@ -353,7 +352,7 @@ fn parse_ty(st: @pstate, conv: conv_did) -> ty::t { assert (next(st) == ']'); return ty::mk_struct(st.tcx, did, substs); } - c => { error!("unexpected char in type string: %c", c); fail;} + c => { error!("unexpected char in type string: %c", c); die!();} } } @@ -405,7 +404,7 @@ fn parse_purity(c: char) -> purity { 'p' => pure_fn, 'i' => impure_fn, 'c' => extern_fn, - _ => fail ~"parse_purity: bad purity" + _ => die!(~"parse_purity: bad purity") } } @@ -413,7 +412,7 @@ fn parse_onceness(c: char) -> ast::Onceness { match c { 'o' => ast::Once, 'm' => ast::Many, - _ => fail ~"parse_onceness: bad onceness" + _ => die!(~"parse_onceness: bad onceness") } } @@ -426,7 +425,7 @@ fn parse_mode(st: @pstate) -> ast::mode { '+' => ast::by_copy, '=' => ast::by_ref, '#' => ast::by_val, - _ => fail ~"bad mode" + _ => die!(~"bad mode") }); return m; } @@ -464,7 +463,7 @@ pub fn parse_def_id(buf: &[u8]) -> ast::def_id { while colon_idx < len && buf[colon_idx] != ':' as u8 { colon_idx += 1u; } if colon_idx == len { error!("didn't find ':' when parsing def id"); - fail; + die!(); } let crate_part = vec::view(buf, 0u, colon_idx); @@ -472,12 +471,12 @@ pub fn parse_def_id(buf: &[u8]) -> ast::def_id { let crate_num = match uint::parse_bytes(crate_part, 10u) { Some(cn) => cn as int, - None => fail (fmt!("internal error: parse_def_id: crate number \ + None => die!(fmt!("internal error: parse_def_id: crate number \ expected, but found %?", crate_part)) }; let def_num = match uint::parse_bytes(def_part, 10u) { Some(dn) => dn as int, - None => fail (fmt!("internal error: parse_def_id: id expected, but \ + None => die!(fmt!("internal error: parse_def_id: id expected, but \ found %?", def_part)) }; ast::def_id { crate: crate_num, node: def_num } @@ -500,7 +499,7 @@ fn parse_bounds(st: @pstate, conv: conv_did) -> @~[ty::param_bound] { 'O' => ty::bound_durable, 'I' => ty::bound_trait(parse_ty(st, conv)), '.' => break, - _ => fail ~"parse_bounds: bad bounds" + _ => die!(~"parse_bounds: bad bounds") }); } @bounds diff --git a/src/librustc/metadata/tyencode.rs b/src/librustc/metadata/tyencode.rs index 97f8c8f12a1..a0e2065b20b 100644 --- a/src/librustc/metadata/tyencode.rs +++ b/src/librustc/metadata/tyencode.rs @@ -20,7 +20,7 @@ use core::io::WriterUtil; use core::io; use core::uint; use core::vec; -use std::map::HashMap; +use std::oldmap::HashMap; use syntax::ast::*; use syntax::diagnostic::span_handler; use syntax::print::pprust::*; @@ -98,8 +98,8 @@ pub fn enc_ty(w: io::Writer, cx: @ctxt, t: ty::t) { let abbrev_len = 3u + estimate_sz(pos) + estimate_sz(len); if abbrev_len < len { // I.e. it's actually an abbreviation. - let s = ~"#" + uint::to_str(pos, 16u) + ~":" + - uint::to_str(len, 16u) + ~"#"; + let s = ~"#" + uint::to_str_radix(pos, 16u) + ~":" + + uint::to_str_radix(len, 16u) + ~"#"; let a = {pos: pos, len: len, s: @s}; abbrevs.insert(t, a); } @@ -321,7 +321,7 @@ fn enc_sty(w: io::Writer, cx: @ctxt, +st: ty::sty) { debug!("~~~~ %s", ~"]"); w.write_char(']'); } - ty::ty_err => fail ~"Shouldn't encode error type" + ty::ty_err => die!(~"Shouldn't encode error type") } } diff --git a/src/librustc/middle/astencode.rs b/src/librustc/middle/astencode.rs index 95a9f602a6d..2fc592e131e 100644 --- a/src/librustc/middle/astencode.rs +++ b/src/librustc/middle/astencode.rs @@ -31,7 +31,7 @@ use std::ebml::reader::get_doc; use std::ebml::reader; use std::ebml::writer::Encoder; use std::ebml; -use std::map::HashMap; +use std::oldmap::HashMap; use std::prettyprint; use std::serialize; use std::serialize::{Encodable, EncoderHelpers, DecoderHelpers}; @@ -220,7 +220,7 @@ impl extended_decode_ctxt { ast::def_id { crate: ast::local_crate, node: self.tr_id(did.node) } } fn tr_span(_span: span) -> span { - ast_util::dummy_sp() // FIXME (#1972): handle span properly + codemap::dummy_sp() // FIXME (#1972): handle span properly } } @@ -300,11 +300,11 @@ fn simplify_ast(ii: ast::inlined_item) -> ast::inlined_item { let stmts_sans_items = do blk.stmts.filtered |stmt| { match stmt.node { ast::stmt_expr(_, _) | ast::stmt_semi(_, _) | - ast::stmt_decl(@ast::spanned { node: ast::decl_local(_), + ast::stmt_decl(@codemap::spanned { node: ast::decl_local(_), span: _}, _) => true, - ast::stmt_decl(@ast::spanned { node: ast::decl_item(_), + ast::stmt_decl(@codemap::spanned { node: ast::decl_item(_), span: _}, _) => false, - ast::stmt_mac(*) => fail ~"unexpanded macro in astencode" + ast::stmt_mac(*) => die!(~"unexpanded macro in astencode") } }; let blk_sans_items = ast::blk_ { @@ -336,7 +336,7 @@ fn simplify_ast(ii: ast::inlined_item) -> ast::inlined_item { ast::ii_dtor(ref dtor, nm, ref tps, parent_id) => { let dtor_body = fld.fold_block((*dtor).node.body); ast::ii_dtor( - ast::spanned { + codemap::spanned { node: ast::struct_dtor_ { body: dtor_body, .. /*bad*/copy (*dtor).node }, .. (/*bad*/copy *dtor) }, @@ -377,7 +377,7 @@ fn renumber_ast(xcx: extended_decode_ctxt, ii: ast::inlined_item) let new_parent = xcx.tr_def_id(parent_id); let new_self = fld.new_id((*dtor).node.self_id); ast::ii_dtor( - ast::spanned { + codemap::spanned { node: ast::struct_dtor_ { id: dtor_id, attrs: dtor_attrs, self_id: new_self, @@ -717,7 +717,7 @@ impl reader::Decoder: vtable_decoder_helpers { ) } // hard to avoid - user input - _ => fail ~"bad enum variant" + _ => die!(~"bad enum variant") } } } @@ -1288,6 +1288,6 @@ fn test_simplification() { assert pprust::item_to_str(item_out, ext_cx.parse_sess().interner) == pprust::item_to_str(item_exp, ext_cx.parse_sess().interner); } - _ => fail + _ => die!() } } diff --git a/src/librustc/middle/borrowck/check_loans.rs b/src/librustc/middle/borrowck/check_loans.rs index 76b3aea2dd1..19740b6a929 100644 --- a/src/librustc/middle/borrowck/check_loans.rs +++ b/src/librustc/middle/borrowck/check_loans.rs @@ -35,7 +35,7 @@ use core::cmp; use core::dvec::DVec; use core::uint; use core::vec; -use std::map::HashMap; +use std::oldmap::HashMap; use syntax::ast::{m_const, m_imm, m_mutbl}; use syntax::ast; use syntax::ast_util; @@ -665,7 +665,7 @@ fn check_loans_in_expr(expr: @ast::expr, self.check_for_conflicting_loans(expr.id); - if self.bccx.moves_map.contains_key(expr.id) { + if self.bccx.moves_map.contains_key_ref(&expr.id) { self.check_move_out_from_expr(expr); } @@ -686,7 +686,7 @@ fn check_loans_in_expr(expr: @ast::expr, } ast::expr_index(_, rval) | ast::expr_binary(_, _, rval) - if self.bccx.method_map.contains_key(expr.id) => { + if self.bccx.method_map.contains_key_ref(&expr.id) => { self.check_call(expr, None, expr.callee_id, @@ -694,7 +694,7 @@ fn check_loans_in_expr(expr: @ast::expr, ~[rval]); } ast::expr_unary(*) | ast::expr_index(*) - if self.bccx.method_map.contains_key(expr.id) => { + if self.bccx.method_map.contains_key_ref(&expr.id) => { self.check_call(expr, None, expr.callee_id, diff --git a/src/librustc/middle/borrowck/gather_loans.rs b/src/librustc/middle/borrowck/gather_loans.rs index bfcdacf811d..b7b99424924 100644 --- a/src/librustc/middle/borrowck/gather_loans.rs +++ b/src/librustc/middle/borrowck/gather_loans.rs @@ -33,7 +33,7 @@ use util::ppaux::{expr_repr, region_to_str}; use core::dvec; use core::hashmap::linear::LinearSet; use core::vec; -use std::map::HashMap; +use std::oldmap::HashMap; use syntax::ast::{m_const, m_imm, m_mutbl}; use syntax::ast; use syntax::codemap::span; @@ -204,7 +204,7 @@ fn req_loans_in_expr(ex: @ast::expr, ast::expr_binary(_, rcvr, _) | ast::expr_unary(_, rcvr) | ast::expr_assign_op(_, rcvr, _) - if self.bccx.method_map.contains_key(ex.id) => { + if self.bccx.method_map.contains_key_ref(&ex.id) => { // Receivers in method calls are always passed by ref. // // Here, in an overloaded operator, the call is this expression, @@ -241,7 +241,7 @@ fn req_loans_in_expr(ex: @ast::expr, // } ast::expr_field(rcvr, _, _) - if self.bccx.method_map.contains_key(ex.id) => { + if self.bccx.method_map.contains_key_ref(&ex.id) => { // Receivers in method calls are always passed by ref. // // Here, the field a.b is in fact a closure. Eventually, this diff --git a/src/librustc/middle/borrowck/loan.rs b/src/librustc/middle/borrowck/loan.rs index c4b36085ec8..0b06fbd2a3a 100644 --- a/src/librustc/middle/borrowck/loan.rs +++ b/src/librustc/middle/borrowck/loan.rs @@ -33,7 +33,7 @@ mutability M_L, and a lifetime L_L where: - immutable/mutable: the data cannot be moved or mutated - The lifetime L_L indicates the *scope* of the loan. -XXX --- much more needed, don't have time to write this all up now +FIXME #4730 --- much more needed, don't have time to write this all up now */ diff --git a/src/librustc/middle/borrowck/mod.rs b/src/librustc/middle/borrowck/mod.rs index c0c59c68699..b160c2e5a14 100644 --- a/src/librustc/middle/borrowck/mod.rs +++ b/src/librustc/middle/borrowck/mod.rs @@ -241,7 +241,7 @@ use core::io; use core::result::{Result, Ok, Err}; use std::list::{List, Cons, Nil}; use std::list; -use std::map::{HashMap, Set}; +use std::oldmap::{HashMap, Set}; use syntax::ast::{mutability, m_mutbl, m_imm, m_const}; use syntax::ast; use syntax::ast_map; diff --git a/src/librustc/middle/borrowck/preserve.rs b/src/librustc/middle/borrowck/preserve.rs index 570b439cf8c..3bc34d2ef29 100644 --- a/src/librustc/middle/borrowck/preserve.rs +++ b/src/librustc/middle/borrowck/preserve.rs @@ -375,7 +375,7 @@ impl PreserveCtxt { // scope_id;`. Though that would potentially re-introduce // the ICE. See #3511 for more details. let scope_to_use = if - self.bccx.stmt_map.contains_key(scope_id) { + self.bccx.stmt_map.contains_key_ref(&scope_id) { // Root it in its parent scope, b/c // trans won't introduce a new scope for the // stmt diff --git a/src/librustc/middle/check_const.rs b/src/librustc/middle/check_const.rs index a018c44c7b8..98c3fdaa8c3 100644 --- a/src/librustc/middle/check_const.rs +++ b/src/librustc/middle/check_const.rs @@ -18,8 +18,9 @@ use util::ppaux; use core::dvec::DVec; use core::option; -use std::map::HashMap; +use std::oldmap::HashMap; use syntax::ast::*; +use syntax::codemap; use syntax::{visit, ast_util, ast_map}; pub fn check_crate(sess: Session, @@ -64,7 +65,10 @@ pub fn check_pat(p: @pat, &&_is_const: bool, v: visit::vt<bool>) { fn is_str(e: @expr) -> bool { match e.node { expr_vstore( - @expr { node: expr_lit(@spanned { node: lit_str(_), _}), _ }, + @expr { node: expr_lit(@codemap::spanned { + node: lit_str(_), + _}), + _ }, expr_vstore_uniq ) => true, _ => false @@ -96,9 +100,9 @@ pub fn check_expr(sess: Session, ~"disallowed operator in constant expression"); return; } - expr_lit(@spanned {node: lit_str(_), _}) => { } + expr_lit(@codemap::spanned {node: lit_str(_), _}) => { } expr_binary(_, _, _) | expr_unary(_, _) => { - if method_map.contains_key(e.id) { + if method_map.contains_key_ref(&e.id) { sess.span_err(e.span, ~"user-defined operators are not \ allowed in constant expressions"); } @@ -183,7 +187,7 @@ pub fn check_expr(sess: Session, } } match e.node { - expr_lit(@spanned {node: lit_int(v, t), _}) => { + expr_lit(@codemap::spanned {node: lit_int(v, t), _}) => { if t != ty_char { if (v as u64) > ast_util::int_ty_max( if t == ty_i { sess.targ_cfg.int_type } else { t }) { @@ -191,7 +195,7 @@ pub fn check_expr(sess: Session, } } } - expr_lit(@spanned {node: lit_uint(v, t), _}) => { + expr_lit(@codemap::spanned {node: lit_uint(v, t), _}) => { if v > ast_util::uint_ty_max( if t == ty_u { sess.targ_cfg.uint_type } else { t }) { sess.span_err(e.span, ~"literal out of range for its type"); @@ -249,7 +253,7 @@ pub fn check_item_recursion(sess: Session, ast_map::node_item(it, _) => { (v.visit_item)(it, env, v); } - _ => fail ~"const not bound to an item" + _ => die!(~"const not bound to an item") } } _ => () diff --git a/src/librustc/middle/check_match.rs b/src/librustc/middle/check_match.rs index 406fdbaeac7..e25ceee5d30 100644 --- a/src/librustc/middle/check_match.rs +++ b/src/librustc/middle/check_match.rs @@ -23,12 +23,11 @@ use core::cmp; use core::option; use core::uint; use core::vec; -use std::map::HashMap; +use std::oldmap::HashMap; use std::sort; use syntax::ast::*; -use syntax::ast_util::{variant_def_ids, dummy_sp, unguarded_pat, walk_pat}; -use syntax::ast_util; -use syntax::codemap::span; +use syntax::ast_util::{variant_def_ids, unguarded_pat, walk_pat}; +use syntax::codemap::{span, dummy_sp, spanned}; use syntax::print::pprust::pat_to_str; use syntax::visit; @@ -60,7 +59,7 @@ pub fn expr_is_non_moving_lvalue(cx: @MatchCheckCtxt, expr: @expr) -> bool { return false; } - !cx.moves_map.contains_key(expr.id) + !cx.moves_map.contains_key_ref(&expr.id) } pub fn check_expr(cx: @MatchCheckCtxt, ex: @expr, &&s: (), v: visit::vt<()>) { @@ -148,11 +147,11 @@ pub fn check_exhaustive(cx: @MatchCheckCtxt, sp: span, pats: ~[@pat]) { } ty::ty_enum(id, _) => { let vid = match (*ctor) { variant(id) => id, - _ => fail ~"check_exhaustive: non-variant ctor" }; + _ => die!(~"check_exhaustive: non-variant ctor") }; match vec::find(*ty::enum_variants(cx.tcx, id), |v| v.id == vid) { Some(v) => Some(cx.tcx.sess.str_of(v.name)), - None => fail ~"check_exhaustive: bad variant in ctor" + None => die!(~"check_exhaustive: bad variant in ctor") } } ty::ty_unboxed_vec(*) | ty::ty_evec(*) => { @@ -367,7 +366,7 @@ pub fn missing_ctor(cx: @MatchCheckCtxt, return Some(variant(v.id)); } } - fail; + die!(); } else { None } } ty::ty_nil => None, @@ -378,7 +377,7 @@ pub fn missing_ctor(cx: @MatchCheckCtxt, None => (), Some(val(const_bool(true))) => true_found = true, Some(val(const_bool(false))) => false_found = true, - _ => fail ~"impossible case" + _ => die!(~"impossible case") } } if true_found && false_found { None } @@ -446,10 +445,10 @@ pub fn ctor_arity(cx: @MatchCheckCtxt, ctor: ctor, ty: ty::t) -> uint { ty::ty_box(_) | ty::ty_uniq(_) | ty::ty_rptr(*) => 1u, ty::ty_enum(eid, _) => { let id = match ctor { variant(id) => id, - _ => fail ~"impossible case" }; + _ => die!(~"impossible case") }; match vec::find(*ty::enum_variants(cx.tcx, eid), |v| v.id == id ) { Some(v) => v.args.len(), - None => fail ~"impossible case" + None => die!(~"impossible case") } } ty::ty_struct(cid, _) => ty::lookup_struct_fields(cx.tcx, cid).len(), @@ -464,7 +463,7 @@ pub fn ctor_arity(cx: @MatchCheckCtxt, ctor: ctor, ty: ty::t) -> uint { } pub fn wild() -> @pat { - @pat {id: 0, node: pat_wild, span: ast_util::dummy_sp()} + @pat {id: 0, node: pat_wild, span: dummy_sp()} } pub fn specialize(cx: @MatchCheckCtxt, @@ -497,7 +496,7 @@ pub fn specialize(cx: @MatchCheckCtxt, compare_const_vals((*c_hi), e_v) <= 0 } single => true, - _ => fail ~"type error" + _ => die!(~"type error") }; if match_ { Some(vec::tail(r)) } else { None } } @@ -516,7 +515,7 @@ pub fn specialize(cx: @MatchCheckCtxt, } def_variant(_, _) => None, def_struct(*) => { - // XXX: Is this right? --pcw + // FIXME #4731: Is this right? --pcw let new_args; match args { Some(args) => new_args = args, @@ -530,7 +529,7 @@ pub fn specialize(cx: @MatchCheckCtxt, pat_rec(ref flds, _) => { let ty_flds = match /*bad*/copy ty::get(left_ty).sty { ty::ty_rec(flds) => flds, - _ => fail ~"bad type for pat_rec" + _ => die!(~"bad type for pat_rec") }; let args = vec::map(ty_flds, |ty_fld| { match flds.find(|f| f.ident == ty_fld.ident) { @@ -545,7 +544,7 @@ pub fn specialize(cx: @MatchCheckCtxt, match cx.tcx.def_map.get(pat_id) { def_variant(_, variant_id) => { if variant(variant_id) == ctor_id { - // XXX: Is this right? --pcw + // FIXME #4731: Is this right? --pcw let args = flds.map(|ty_field| { match flds.find(|f| f.ident == ty_field.ident) { @@ -596,7 +595,7 @@ pub fn specialize(cx: @MatchCheckCtxt, compare_const_vals((*c_hi), e_v) <= 0 } single => true, - _ => fail ~"type error" + _ => die!(~"type error") }; if match_ { Some(vec::tail(r)) } else { None } } @@ -606,7 +605,7 @@ pub fn specialize(cx: @MatchCheckCtxt, range(ref lo, ref hi) => ((/*bad*/copy *lo), (/*bad*/copy *hi)), single => return Some(vec::tail(r)), - _ => fail ~"type error" + _ => die!(~"type error") }; let v_lo = eval_const_expr(cx.tcx, lo), v_hi = eval_const_expr(cx.tcx, hi); @@ -735,7 +734,7 @@ pub fn check_legality_of_move_bindings(cx: @MatchCheckCtxt, by_ref_span = Some(span); } bind_infer => { - if cx.moves_map.contains_key(id) { + if cx.moves_map.contains_key_ref(&id) { any_by_move = true; } } @@ -775,7 +774,7 @@ pub fn check_legality_of_move_bindings(cx: @MatchCheckCtxt, if pat_is_binding(def_map, p) { match p.node { pat_ident(_, _, sub) => { - if cx.moves_map.contains_key(p.id) { + if cx.moves_map.contains_key_ref(&p.id) { check_move(p, sub); } } @@ -801,7 +800,7 @@ pub fn check_legality_of_move_bindings(cx: @MatchCheckCtxt, behind_bad_pointer); if behind_bad_pointer && - cx.moves_map.contains_key(pat.id) + cx.moves_map.contains_key_ref(&pat.id) { cx.tcx.sess.span_err( pat.span, diff --git a/src/librustc/middle/const_eval.rs b/src/librustc/middle/const_eval.rs index 7edc345adc4..f917964d234 100644 --- a/src/librustc/middle/const_eval.rs +++ b/src/librustc/middle/const_eval.rs @@ -233,7 +233,7 @@ pub enum const_val { pub fn eval_const_expr(tcx: middle::ty::ctxt, e: @expr) -> const_val { match eval_const_expr_partial(tcx, e) { Ok(ref r) => (/*bad*/copy *r), - Err(ref s) => fail (/*bad*/copy *s) + Err(ref s) => die!(/*bad*/copy *s) } } @@ -459,7 +459,7 @@ pub fn compare_const_vals(a: const_val, b: const_val) -> int { 1 } } - _ => fail ~"compare_const_vals: ill-typed comparison" + _ => die!(~"compare_const_vals: ill-typed comparison") } } diff --git a/src/librustc/middle/freevars.rs b/src/librustc/middle/freevars.rs index 35c6b625e11..1e9d8c9c08e 100644 --- a/src/librustc/middle/freevars.rs +++ b/src/librustc/middle/freevars.rs @@ -18,7 +18,7 @@ use middle::ty; use core::int; use core::option::*; use core::vec; -use std::map::*; +use std::oldmap::*; use syntax::codemap::span; use syntax::print::pprust::path_to_str; use syntax::{ast, ast_util, visit}; @@ -59,7 +59,7 @@ fn collect_freevars(def_map: resolve::DefMap, blk: ast::blk) ast::expr_path(*) => { let mut i = 0; match def_map.find(expr.id) { - None => fail ~"path not found", + None => die!(~"path not found"), Some(df) => { let mut def = df; while i < depth { @@ -71,7 +71,7 @@ fn collect_freevars(def_map: resolve::DefMap, blk: ast::blk) } if i == depth { // Made it to end of loop let dnum = ast_util::def_id_of_def(def).node; - if !seen.contains_key(dnum) { + if !seen.contains_key_ref(&dnum) { refs.push(@freevar_entry { def: def, span: expr.span, @@ -119,7 +119,7 @@ pub fn annotate_freevars(def_map: resolve::DefMap, crate: @ast::crate) -> pub fn get_freevars(tcx: ty::ctxt, fid: ast::node_id) -> freevar_info { match tcx.freevars.find(fid) { - None => fail ~"get_freevars: " + int::str(fid) + ~" has no freevars", + None => die!(~"get_freevars: " + int::str(fid) + ~" has no freevars"), Some(d) => return d } } diff --git a/src/librustc/middle/kind.rs b/src/librustc/middle/kind.rs index 8977052e029..09232a2a0c5 100644 --- a/src/librustc/middle/kind.rs +++ b/src/librustc/middle/kind.rs @@ -24,9 +24,9 @@ use util::ppaux::{ty_to_str, tys_to_str}; use core::option; use core::str; use core::vec; -use std::map::HashMap; +use std::oldmap::HashMap; use syntax::ast::*; -use syntax::codemap::span; +use syntax::codemap::{span, spanned}; use syntax::print::pprust::expr_to_str; use syntax::{visit, ast_util}; @@ -213,11 +213,11 @@ pub fn check_expr(e: @expr, cx: ctx, v: visit::vt<ctx>) { }; if vec::len(*ts) != vec::len(*bounds) { // Fail earlier to make debugging easier - fail fmt!("internal error: in kind::check_expr, length \ + die!(fmt!("internal error: in kind::check_expr, length \ mismatch between actual and declared bounds: actual = \ %s (%u tys), declared = %? (%u tys)", tys_to_str(cx.tcx, *ts), ts.len(), - *bounds, (*bounds).len()); + *bounds, (*bounds).len())); } for vec::each2(*ts, *bounds) |ty, bound| { check_bounds(cx, type_parameter_id, e.span, *ty, *bound) diff --git a/src/librustc/middle/lang_items.rs b/src/librustc/middle/lang_items.rs index 6d691438359..3eb65505e64 100644 --- a/src/librustc/middle/lang_items.rs +++ b/src/librustc/middle/lang_items.rs @@ -33,7 +33,7 @@ use syntax::visit::{default_simple_visitor, mk_simple_visitor, SimpleVisitor}; use syntax::visit::{visit_crate, visit_item}; use core::ptr; -use std::map::HashMap; +use std::oldmap::HashMap; use str_eq = str::eq; pub enum LangItem { @@ -391,7 +391,7 @@ impl LanguageItemCollector { } fn check_completeness() { - for self.item_refs.each |key, item_ref| { + for self.item_refs.each_ref |&key, &item_ref| { match self.items.items[item_ref] { None => { self.session.err(fmt!("no item found for `%s`", key)); diff --git a/src/librustc/middle/lint.rs b/src/librustc/middle/lint.rs index 1bc3827586c..0dc7a746e9e 100644 --- a/src/librustc/middle/lint.rs +++ b/src/librustc/middle/lint.rs @@ -32,13 +32,14 @@ use core::u32; use core::u64; use core::uint; use core::vec; -use std::map::{Map, HashMap}; -use std::map; -use std::smallintmap::{Map, SmallIntMap}; -use std::smallintmap; +use std::oldmap::{Map, HashMap}; +use std::oldmap; +use std::oldsmallintmap::{Map, SmallIntMap}; +use std::oldsmallintmap; use syntax::ast_util::{path_to_ident}; use syntax::attr; use syntax::codemap::span; +use syntax::codemap; use syntax::print::pprust::{expr_to_str, mode_to_str, pat_to_str}; use syntax::{ast, ast_util, visit}; @@ -232,7 +233,7 @@ pub fn get_lint_dict() -> lint_dict { default: warn}), */ ]; - map::hash_from_vec(v) + oldmap::hash_from_vec(v) } // This is a highly not-optimal set of data structure decisions. @@ -248,7 +249,7 @@ pub type lint_settings = { }; pub fn mk_lint_settings() -> lint_settings { - {default_settings: smallintmap::mk(), + {default_settings: oldsmallintmap::mk(), settings_map: HashMap()} } @@ -273,7 +274,8 @@ pub fn get_lint_settings_level(settings: lint_settings, // This is kind of unfortunate. It should be somewhere else, or we should use // a persistent data structure... fn clone_lint_modes(modes: lint_modes) -> lint_modes { - smallintmap::SmallIntMap_(@smallintmap::SmallIntMap_ { v: copy modes.v }) + oldsmallintmap::SmallIntMap_(@oldsmallintmap::SmallIntMap_ + {v: copy modes.v}) } type ctxt_ = {dict: lint_dict, @@ -393,12 +395,14 @@ fn build_settings_item(i: @ast::item, &&cx: ctxt, v: visit::vt<ctxt>) { pub fn build_settings_crate(sess: session::Session, crate: @ast::crate) { let cx = ctxt_({dict: get_lint_dict(), - curr: smallintmap::mk(), + curr: oldsmallintmap::mk(), is_default: true, sess: sess}); // Install defaults. - for cx.dict.each |_k, spec| { cx.set_level(spec.lint, spec.default); } + for cx.dict.each_value_ref |&spec| { + cx.set_level(spec.lint, spec.default); + } // Install command-line options, overriding defaults. for sess.opts.lint_opts.each |pair| { @@ -452,7 +456,7 @@ fn check_item_while_true(cx: ty::ctxt, it: @ast::item) { match e.node { ast::expr_while(cond, _) => { match cond.node { - ast::expr_lit(@ast::spanned { + ast::expr_lit(@codemap::spanned { node: ast::lit_bool(true), _}) => { cx.sess.span_lint( @@ -481,7 +485,7 @@ fn check_item_type_limits(cx: ty::ctxt, it: @ast::item) { ast::gt => v >= min, ast::ge => v > min, ast::eq | ast::ne => v >= min && v <= max, - _ => fail + _ => die!() } } @@ -540,7 +544,7 @@ fn check_item_type_limits(cx: ty::ctxt, it: @ast::item) { ast::lit_int_unsuffixed(v) => v, _ => return true }, - _ => fail + _ => die!() }; is_valid(norm_binop, lit_val, min, max) } @@ -553,7 +557,7 @@ fn check_item_type_limits(cx: ty::ctxt, it: @ast::item) { ast::lit_int_unsuffixed(v) => v as u64, _ => return true }, - _ => fail + _ => die!() }; is_valid(norm_binop, lit_val, min, max) } @@ -954,7 +958,7 @@ fn check_fn_deprecated_modes(tcx: ty::ctxt, fn_ty: ty::t, decl: ast::fn_decl, ty_to_str(tcx, arg_ty.ty), mode_to_str(arg_ast.mode)); error!("%?",arg_ast.ty.node); - fail + die!() } }; } diff --git a/src/librustc/middle/liveness.rs b/src/librustc/middle/liveness.rs index 0cafe528d04..c13af3a32f2 100644 --- a/src/librustc/middle/liveness.rs +++ b/src/librustc/middle/liveness.rs @@ -119,7 +119,7 @@ use core::ptr; use core::to_str; use core::uint; use core::vec; -use std::map::HashMap; +use std::oldmap::HashMap; use syntax::ast::*; use syntax::codemap::span; use syntax::parse::token::special_idents; @@ -222,11 +222,11 @@ pub fn check_crate(tcx: ty::ctxt, } impl LiveNode: to_str::ToStr { - pure fn to_str() -> ~str { fmt!("ln(%u)", *self) } + pure fn to_str(&self) -> ~str { fmt!("ln(%u)", **self) } } impl Variable: to_str::ToStr { - pure fn to_str() -> ~str { fmt!("v(%u)", *self) } + pure fn to_str(&self) -> ~str { fmt!("v(%u)", **self) } } // ______________________________________________________________________ @@ -610,7 +610,7 @@ fn visit_expr(expr: @expr, &&self: @IrMaps, vt: vt<@IrMaps>) { expr_tup(*) | expr_log(*) | expr_binary(*) | expr_assert(*) | expr_addr_of(*) | expr_copy(*) | expr_loop_body(*) | expr_do_body(*) | expr_cast(*) | - expr_unary(*) | expr_fail(*) | + expr_unary(*) | expr_break(_) | expr_again(_) | expr_lit(_) | expr_ret(*) | expr_block(*) | expr_assign(*) | expr_swap(*) | expr_assign_op(*) | expr_mac(*) | expr_struct(*) | @@ -1191,7 +1191,7 @@ impl Liveness { self.propagate_through_expr(e, ln) } - expr_ret(o_e) | expr_fail(o_e) => { + expr_ret(o_e) => { // ignore succ and subst exit_ln: self.propagate_through_opt_expr(o_e, self.s.exit_ln) } @@ -1608,7 +1608,7 @@ fn check_expr(expr: @expr, &&self: @Liveness, vt: vt<@Liveness>) { expr_log(*) | expr_binary(*) | expr_assert(*) | expr_copy(*) | expr_loop_body(*) | expr_do_body(*) | - expr_cast(*) | expr_unary(*) | expr_fail(*) | + expr_cast(*) | expr_unary(*) | expr_ret(*) | expr_break(*) | expr_again(*) | expr_lit(_) | expr_block(*) | expr_swap(*) | expr_mac(*) | expr_addr_of(*) | expr_struct(*) | expr_repeat(*) | expr_paren(*) => { @@ -1754,7 +1754,8 @@ impl @Liveness { // used by ExitNode would be arguments or fields in a ctor. // we give a slightly different error message in those cases. if lnk == ExitNode { - // XXX this seems like it should be reported in the borrow checker + // FIXME #4715: this seems like it should be reported in the + // borrow checker let vk = self.ir.var_kinds[*var]; match vk { Arg(_, name, _) => { diff --git a/src/librustc/middle/mem_categorization.rs b/src/librustc/middle/mem_categorization.rs index 625b9889aad..94fc63b75dd 100644 --- a/src/librustc/middle/mem_categorization.rs +++ b/src/librustc/middle/mem_categorization.rs @@ -348,7 +348,7 @@ pub impl &mem_categorization_ctxt { let expr_ty = tcx.ty(expr); match expr.node { ast::expr_unary(ast::deref, e_base) => { - if self.method_map.contains_key(expr.id) { + if self.method_map.contains_key_ref(&expr.id) { return self.cat_rvalue(expr, expr_ty); } @@ -357,7 +357,7 @@ pub impl &mem_categorization_ctxt { } ast::expr_field(base, f_name, _) => { - if self.method_map.contains_key(expr.id) { + if self.method_map.contains_key_ref(&expr.id) { return self.cat_method_ref(expr, expr_ty); } @@ -366,7 +366,7 @@ pub impl &mem_categorization_ctxt { } ast::expr_index(base, _) => { - if self.method_map.contains_key(expr.id) { + if self.method_map.contains_key_ref(&expr.id) { return self.cat_rvalue(expr, expr_ty); } @@ -387,7 +387,7 @@ pub impl &mem_categorization_ctxt { ast::expr_assert(*) | ast::expr_ret(*) | ast::expr_loop_body(*) | ast::expr_do_body(*) | ast::expr_unary(*) | ast::expr_method_call(*) | - ast::expr_copy(*) | ast::expr_cast(*) | ast::expr_fail(*) | + ast::expr_copy(*) | ast::expr_cast(*) | ast::expr_vstore(*) | ast::expr_vec(*) | ast::expr_tup(*) | ast::expr_if(*) | ast::expr_log(*) | ast::expr_binary(*) | ast::expr_while(*) | diff --git a/src/librustc/middle/moves.rs b/src/librustc/middle/moves.rs index 81b3761451c..8adebdb4582 100644 --- a/src/librustc/middle/moves.rs +++ b/src/librustc/middle/moves.rs @@ -217,7 +217,7 @@ use util::ppaux; use util::common::indenter; use core::vec; -use std::map::HashMap; +use std::oldmap::HashMap; use syntax::ast::*; use syntax::ast_util; use syntax::visit; @@ -573,7 +573,6 @@ impl VisitContext { self.consume_block(blk, visitor); } - expr_fail(ref opt_expr) | expr_ret(ref opt_expr) => { for opt_expr.each |expr| { self.consume_expr(*expr, visitor); @@ -641,7 +640,7 @@ impl VisitContext { arg_exprs: &[@expr], visitor: vt<VisitContext>) -> bool { - if !self.method_map.contains_key(expr.id) { + if !self.method_map.contains_key_ref(&expr.id) { return false; } @@ -772,7 +771,7 @@ impl VisitContext { for arm.pats.each |pat| { let mut found = false; do pat_bindings(self.tcx.def_map, *pat) |_, node_id, _, _| { - if moves_map.contains_key(node_id) { + if moves_map.contains_key_ref(&node_id) { found = true; } } @@ -812,4 +811,4 @@ impl VisitContext { }) } } -} \ No newline at end of file +} diff --git a/src/librustc/middle/pat_util.rs b/src/librustc/middle/pat_util.rs index 205be5f891b..c39d750a581 100644 --- a/src/librustc/middle/pat_util.rs +++ b/src/librustc/middle/pat_util.rs @@ -14,12 +14,11 @@ use middle::resolve; use middle::ty; use syntax::ast::*; -use syntax::ast_util; -use syntax::ast_util::{path_to_ident, respan, walk_pat}; +use syntax::ast_util::{path_to_ident, walk_pat}; use syntax::fold; use syntax::fold::*; -use syntax::codemap::span; -use std::map::HashMap; +use syntax::codemap::{span, respan}; +use std::oldmap::HashMap; pub type PatIdMap = HashMap<ident, node_id>; diff --git a/src/librustc/middle/privacy.rs b/src/librustc/middle/privacy.rs index eb90acb2d36..482f01f7201 100644 --- a/src/librustc/middle/privacy.rs +++ b/src/librustc/middle/privacy.rs @@ -131,7 +131,7 @@ pub fn check_crate(tcx: ty::ctxt, } } } else { - // XXX: External crates. + // FIXME #4732: External crates. } } method_param(method_param { @@ -195,7 +195,7 @@ pub fn check_crate(tcx: ty::ctxt, } } } else { - // XXX: External crates. + // FIXME #4732: External crates. } } } diff --git a/src/librustc/middle/region.rs b/src/librustc/middle/region.rs index 31ac2f0f676..4602d2aff4e 100644 --- a/src/librustc/middle/region.rs +++ b/src/librustc/middle/region.rs @@ -32,7 +32,7 @@ use core::dvec::DVec; use core::vec; use std::list; use std::list::list; -use std::map::HashMap; +use std::oldmap::HashMap; use syntax::ast_map; use syntax::codemap::span; use syntax::print::pprust; @@ -296,7 +296,7 @@ pub fn resolve_expr(expr: @ast::expr, cx: ctxt, visitor: visit::vt<ctxt>) { _ => {} }; - if new_cx.root_exprs.contains_key(expr.id) { + if new_cx.root_exprs.contains_key_ref(&expr.id) { new_cx.parent = Some(expr.id); } @@ -833,7 +833,7 @@ pub fn determine_rp_in_crate(sess: Session, debug!("%s", { debug!("Region variance results:"); - for cx.region_paramd_items.each |key, value| { + for cx.region_paramd_items.each_ref |&key, &value| { debug!("item %? (%s) is parameterized with variance %?", key, ast_map::node_id_to_str(ast_map, key, diff --git a/src/librustc/middle/resolve.rs b/src/librustc/middle/resolve.rs index f7488156204..c40b6df6926 100644 --- a/src/librustc/middle/resolve.rs +++ b/src/librustc/middle/resolve.rs @@ -58,7 +58,7 @@ use syntax::ast::{variant, view_item, view_item_import}; use syntax::ast::{view_item_use, view_path_glob, view_path_list}; use syntax::ast::{view_path_simple, visibility, anonymous, named, not}; use syntax::ast::{unsafe_fn}; -use syntax::ast_util::{def_id_of_def, dummy_sp, local_def}; +use syntax::ast_util::{def_id_of_def, local_def}; use syntax::ast_util::{path_to_ident, walk_pat, trait_method_to_ty_method}; use syntax::ast_util::{Privacy, Public, Private}; use syntax::ast_util::{variant_visibility_to_privacy, visibility_to_privacy}; @@ -66,7 +66,7 @@ use syntax::attr::{attr_metas, contains_name, attrs_contains_name}; use syntax::parse::token::ident_interner; use syntax::parse::token::special_idents; use syntax::print::pprust::{pat_to_str, path_to_str}; -use syntax::codemap::span; +use syntax::codemap::{span, dummy_sp}; use syntax::visit::{default_visitor, fk_method, mk_vt, Visitor, visit_block}; use syntax::visit::{visit_crate, visit_expr, visit_expr_opt, visit_fn}; use syntax::visit::{visit_foreign_item, visit_item, visit_method_helper}; @@ -79,7 +79,7 @@ use str::{connect, split_str}; use vec::pop; use std::list::{Cons, List, Nil}; -use std::map::HashMap; +use std::oldmap::HashMap; use str_eq = str::eq; // Definition mapping @@ -322,7 +322,7 @@ pub fn namespace_for_duplicate_checking_mode(mode: DuplicateCheckingMode) ForbidDuplicateModules | ForbidDuplicateTypes | ForbidDuplicateTypesAndValues => TypeNS, ForbidDuplicateValues => ValueNS, - OverwriteDuplicates => fail ~"OverwriteDuplicates has no namespace" + OverwriteDuplicates => die!(~"OverwriteDuplicates has no namespace") } } @@ -604,8 +604,8 @@ pub impl NameBindings { fn get_module() -> @Module { match self.get_module_if_available() { None => { - fail ~"get_module called on a node with no module \ - definition!" + die!(~"get_module called on a node with no module \ + definition!") } Some(module_def) => module_def } @@ -1212,7 +1212,7 @@ pub impl Resolver { let parent_link = self.get_parent_link(new_parent, ident); let def_id = local_def(item.id); - name_bindings.define_module(privacy, + name_bindings.define_module(Public, parent_link, Some(def_id), TraitModuleKind, @@ -1326,7 +1326,7 @@ pub impl Resolver { } item_mac(*) => { - fail ~"item macros unimplemented" + die!(~"item macros unimplemented") } } } @@ -1579,7 +1579,7 @@ pub impl Resolver { match existing_module.parent_link { NoParentLink | BlockParentLink(*) => { - fail ~"can't happen"; + die!(~"can't happen"); } ModuleParentLink(parent_module, ident) => { let name_bindings = parent_module.children.get(ident); @@ -1645,7 +1645,7 @@ pub impl Resolver { def_prim_ty(*) | def_ty_param(*) | def_binding(*) | def_use(*) | def_upvar(*) | def_region(*) | def_typaram_binder(*) | def_label(*) | def_self_ty(*) => { - fail fmt!("didn't expect `%?`", def); + die!(fmt!("didn't expect `%?`", def)); } } } @@ -1913,7 +1913,7 @@ pub impl Resolver { self.module_to_str(module_)); self.resolve_imports_for_module(module_); - for module_.children.each |_name, child_node| { + for module_.children.each_value_ref |&child_node| { match child_node.get_module_if_available() { None => { // Nothing to do. @@ -1924,7 +1924,7 @@ pub impl Resolver { } } - for module_.anonymous_children.each |_block_id, child_module| { + for module_.anonymous_children.each_value_ref |&child_module| { self.resolve_imports_for_module_subtree(child_module); } } @@ -2211,7 +2211,7 @@ pub impl Resolver { } // We've successfully resolved the import. Write the results in. - assert module_.import_resolutions.contains_key(target); + assert module_.import_resolutions.contains_key_ref(&target); let import_resolution = module_.import_resolutions.get(target); match value_result { @@ -2221,7 +2221,7 @@ pub impl Resolver { } UnboundResult => { /* Continue. */ } UnknownResult => { - fail ~"value result should be known at this point"; + die!(~"value result should be known at this point"); } } match type_result { @@ -2231,7 +2231,7 @@ pub impl Resolver { } UnboundResult => { /* Continue. */ } UnknownResult => { - fail ~"type result should be known at this point"; + die!(~"type result should be known at this point"); } } @@ -2370,7 +2370,7 @@ pub impl Resolver { } // We've successfully resolved the import. Write the results in. - assert module_.import_resolutions.contains_key(target); + assert module_.import_resolutions.contains_key_ref(&target); let import_resolution = module_.import_resolutions.get(target); match module_result { @@ -2384,7 +2384,7 @@ pub impl Resolver { binding"); } UnknownResult => { - fail ~"module result should be known at this point"; + die!(~"module result should be known at this point"); } } @@ -2430,8 +2430,8 @@ pub impl Resolver { assert containing_module.glob_count == 0; // Add all resolved imports from the containing module. - for containing_module.import_resolutions.each - |ident, target_import_resolution| { + for containing_module.import_resolutions.each_ref + |&ident, &target_import_resolution| { debug!("(resolving glob import) writing module resolution \ %? into `%s`", @@ -2480,7 +2480,7 @@ pub impl Resolver { } // Add all children from the containing module. - for containing_module.children.each |ident, name_bindings| { + for containing_module.children.each_ref |&ident, &name_bindings| { let mut dest_import_resolution; match module_.import_resolutions.find(ident) { None => { @@ -2996,7 +2996,7 @@ pub impl Resolver { allowable_namespaces = namespaces; } GlobImport => { - fail ~"found `import *`, which is invalid"; + die!(~"found `import *`, which is invalid"); } } @@ -3116,9 +3116,9 @@ pub impl Resolver { // Otherwise, proceed and write in the bindings. match module_.import_resolutions.find(target_name) { None => { - fail ~"(resolving one-level renaming import) reduced graph \ + die!(~"(resolving one-level renaming import) reduced graph \ construction or glob importing should have created the \ - import resolution name by now"; + import resolution name by now"); } Some(import_resolution) => { debug!("(resolving one-level renaming import) writing module \ @@ -3148,7 +3148,7 @@ pub impl Resolver { } // Descend into children and anonymous children. - for module_.children.each |_name, child_node| { + for module_.children.each_value_ref |&child_node| { match child_node.get_module_if_available() { None => { // Continue. @@ -3159,7 +3159,7 @@ pub impl Resolver { } } - for module_.anonymous_children.each |_name, module_| { + for module_.anonymous_children.each_value_ref |&module_| { self.report_unresolved_imports(module_); } } @@ -3204,7 +3204,7 @@ pub impl Resolver { self.record_exports_for_module(module_); - for module_.children.each |_ident, child_name_bindings| { + for module_.children.each_value_ref |&child_name_bindings| { match child_name_bindings.get_module_if_available() { None => { // Nothing to do. @@ -3215,7 +3215,7 @@ pub impl Resolver { } } - for module_.anonymous_children.each |_node_id, child_module| { + for module_.anonymous_children.each_value_ref |&child_module| { self.record_exports_for_module_subtree(child_module); } } @@ -3732,7 +3732,7 @@ pub impl Resolver { } item_mac(*) => { - fail ~"item macros unimplemented" + die!(~"item macros unimplemented") } } @@ -4068,7 +4068,7 @@ pub impl Resolver { for arm.pats.eachi() |i, p| { let map_i = self.binding_mode_map(*p); - for map_0.each |key, binding_0| { + for map_0.each_ref |&key, &binding_0| { match map_i.find(key) { None => { self.session.span_err( @@ -4089,8 +4089,8 @@ pub impl Resolver { } } - for map_i.each |key, binding| { - if !map_0.contains_key(key) { + for map_i.each_ref |&key, &binding| { + if !map_0.contains_key_ref(&key) { self.session.span_err( binding.span, fmt!("variable `%s` from pattern #%u is \ @@ -4319,7 +4319,8 @@ pub impl Resolver { match bindings_list { Some(bindings_list) - if !bindings_list.contains_key(ident) => { + if !bindings_list.contains_key_ref(&ident) + => { let last_rib = (*self.value_ribs).last(); last_rib.bindings.insert(ident, dl_def(def)); @@ -4391,16 +4392,19 @@ pub impl Resolver { pat_struct(path, _, _) => { match self.resolve_path(path, TypeNS, false, visitor) { Some(def_ty(class_id)) - if self.structs.contains_key(class_id) => { + if self.structs.contains_key_ref(&class_id) + => { let class_def = def_struct(class_id); self.record_def(pattern.id, class_def); } Some(definition @ def_struct(class_id)) - if self.structs.contains_key(class_id) => { + if self.structs.contains_key_ref(&class_id) + => { self.record_def(pattern.id, definition); } Some(definition @ def_variant(_, variant_id)) - if self.structs.contains_key(variant_id) => { + if self.structs.contains_key_ref(&variant_id) + => { self.record_def(pattern.id, definition); } result => { @@ -4430,8 +4434,8 @@ pub impl Resolver { Success(target) => { match target.bindings.value_def { None => { - fail ~"resolved name in the value namespace to a set \ - of name bindings with no def?!"; + die!(~"resolved name in the value namespace to a set \ + of name bindings with no def?!"); } Some(def) => { match def.def { @@ -4450,7 +4454,7 @@ pub impl Resolver { } Indeterminate => { - fail ~"unexpected indeterminate result"; + die!(~"unexpected indeterminate result"); } Failed => { @@ -4611,7 +4615,7 @@ pub impl Resolver { } Indeterminate => { - fail ~"indeterminate unexpected"; + die!(~"indeterminate unexpected"); } Success(resulting_module) => { @@ -4658,7 +4662,7 @@ pub impl Resolver { } Indeterminate => { - fail ~"indeterminate unexpected"; + die!(~"indeterminate unexpected"); } Success(resulting_module) => { @@ -4736,7 +4740,7 @@ pub impl Resolver { } } Indeterminate => { - fail ~"unexpected indeterminate result"; + die!(~"unexpected indeterminate result"); } Failed => { return None; @@ -4848,12 +4852,12 @@ pub impl Resolver { match self.resolve_path(path, TypeNS, false, visitor) { Some(def_ty(class_id)) | Some(def_struct(class_id)) - if self.structs.contains_key(class_id) => { + if self.structs.contains_key_ref(&class_id) => { let class_def = def_struct(class_id); self.record_def(expr.id, class_def); } Some(definition @ def_variant(_, class_id)) - if self.structs.contains_key(class_id) => { + if self.structs.contains_key_ref(&class_id) => { self.record_def(expr.id, definition); } _ => { @@ -4997,7 +5001,7 @@ pub impl Resolver { } // Look for trait children. - for search_module.children.each |_name, child_name_bindings| { + for search_module.children.each_value_ref |&child_name_bindings| { match child_name_bindings.def_for_namespace(TypeNS) { Some(def) => { match def { @@ -5017,8 +5021,8 @@ pub impl Resolver { } // Look for imports. - for search_module.import_resolutions.each - |_ident, import_resolution| { + for search_module.import_resolutions.each_value_ref + |&import_resolution| { match import_resolution.target_for_namespace(TypeNS) { None => { @@ -5073,7 +5077,7 @@ pub impl Resolver { self.session.str_of(name)); match self.trait_info.find(trait_def_id) { - Some(trait_info) if trait_info.contains_key(name) => { + Some(trait_info) if trait_info.contains_key_ref(&name) => { debug!("(adding trait info if containing method) found trait \ %d:%d for method '%s'", trait_def_id.crate, @@ -5180,7 +5184,7 @@ pub impl Resolver { self.check_for_unused_imports_in_module(module_); - for module_.children.each |_ident, child_name_bindings| { + for module_.children.each_value_ref |&child_name_bindings| { match (*child_name_bindings).get_module_if_available() { None => { // Nothing to do. @@ -5192,13 +5196,13 @@ pub impl Resolver { } } - for module_.anonymous_children.each |_node_id, child_module| { + for module_.anonymous_children.each_value_ref |&child_module| { self.check_for_unused_imports_in_module_subtree(child_module); } } fn check_for_unused_imports_in_module(module_: @Module) { - for module_.import_resolutions.each |_name, import_resolution| { + for module_.import_resolutions.each_value_ref |&import_resolution| { if !import_resolution.used { match self.unused_import_lint_level { warn => { @@ -5257,12 +5261,12 @@ pub impl Resolver { debug!("Dump of module `%s`:", self.module_to_str(module_)); debug!("Children:"); - for module_.children.each |name, _child| { + for module_.children.each_key_ref |&name| { debug!("* %s", self.session.str_of(name)); } debug!("Import resolutions:"); - for module_.import_resolutions.each |name, import_resolution| { + for module_.import_resolutions.each_ref |&name, &import_resolution| { let mut value_repr; match (*import_resolution).target_for_namespace(ValueNS) { None => { value_repr = ~""; } diff --git a/src/librustc/middle/trans/_match.rs b/src/librustc/middle/trans/_match.rs index 2c36d0d088a..6913cf8e2f5 100644 --- a/src/librustc/middle/trans/_match.rs +++ b/src/librustc/middle/trans/_match.rs @@ -164,7 +164,7 @@ use util::common::indenter; use core::dvec::DVec; use core::dvec; -use std::map::HashMap; +use std::oldmap::HashMap; use syntax::ast::def_id; use syntax::ast; use syntax::ast_util::{dummy_sp, path_to_ident}; @@ -209,8 +209,8 @@ pub fn opt_eq(tcx: ty::ctxt, a: &Opt, b: &Opt) -> bool { a_expr = e.get(); } UnitLikeStructLit(_) => { - fail ~"UnitLikeStructLit should have been handled \ - above" + die!(~"UnitLikeStructLit should have been handled \ + above") } } @@ -222,8 +222,8 @@ pub fn opt_eq(tcx: ty::ctxt, a: &Opt, b: &Opt) -> bool { b_expr = e.get(); } UnitLikeStructLit(_) => { - fail ~"UnitLikeStructLit should have been handled \ - above" + die!(~"UnitLikeStructLit should have been handled \ + above") } } @@ -1085,7 +1085,7 @@ pub fn store_non_ref_bindings(bcx: block, */ let mut bcx = bcx; - for data.bindings_map.each_value |binding_info| { + for data.bindings_map.each_value_ref |&binding_info| { match binding_info.trmode { TrByValue(is_move, lldest) => { let llval = Load(bcx, binding_info.llmatch); // get a T* @@ -1119,7 +1119,7 @@ pub fn insert_lllocals(bcx: block, * the `fcx.lllocals` map. If add_cleans is true, then adds cleanups for * the bindings. */ - for data.bindings_map.each_value |binding_info| { + for data.bindings_map.each_value_ref |&binding_info| { let llval = match binding_info.trmode { // By value bindings: use the stack slot that we // copied/moved the value into @@ -1191,14 +1191,14 @@ pub fn compile_guard(bcx: block, fn drop_bindings(bcx: block, data: &ArmData) -> block { let mut bcx = bcx; - for data.bindings_map.each_value |binding_info| { + for data.bindings_map.each_value_ref |&binding_info| { match binding_info.trmode { TrByValue(_, llval) => { bcx = glue::drop_ty(bcx, llval, binding_info.ty); } TrByRef | TrByImplicitRef => {} } - bcx.fcx.lllocals.remove(binding_info.id); + bcx.fcx.lllocals.remove(&binding_info.id); } return bcx; } @@ -1586,7 +1586,7 @@ pub fn trans_match_inner(scope_cx: block, // but during matching we need to store a *T as explained // above let is_move = - scope_cx.ccx().maps.moves_map.contains_key(p_id); + scope_cx.ccx().maps.moves_map.contains_key_ref(&p_id); llmatch = alloca(bcx, T_ptr(llvariable_ty)); trmode = TrByValue(is_move, alloca(bcx, llvariable_ty)); } diff --git a/src/librustc/middle/trans/base.rs b/src/librustc/middle/trans/base.rs index 75c3a3f1c6c..a858ecb520a 100644 --- a/src/librustc/middle/trans/base.rs +++ b/src/librustc/middle/trans/base.rs @@ -75,9 +75,9 @@ use core::libc::{c_uint, c_ulonglong}; use core::option::{is_none, is_some}; use core::option; use core::uint; -use std::map::HashMap; -use std::smallintmap; -use std::{map, time, list}; +use std::oldmap::HashMap; +use std::oldsmallintmap; +use std::{oldmap, time, list}; use syntax::ast_map::{path, path_elt_to_str, path_mod, path_name}; use syntax::ast_util::{def_id_of_def, local_def, path_to_ident}; use syntax::attr; @@ -169,8 +169,7 @@ pub fn get_extern_fn(externs: HashMap<~str, ValueRef>, +name: ~str, cc: lib::llvm::CallConv, ty: TypeRef) -> ValueRef { - // XXX: Bad copy. - if externs.contains_key(copy name) { return externs.get(name); } + if externs.contains_key_ref(&name) { return externs.get(name); } // XXX: Bad copy. let f = decl_fn(llmod, copy name, cc, ty); externs.insert(name, f); @@ -180,8 +179,7 @@ pub fn get_extern_fn(externs: HashMap<~str, ValueRef>, pub fn get_extern_const(externs: HashMap<~str, ValueRef>, llmod: ModuleRef, +name: ~str, ty: TypeRef) -> ValueRef { unsafe { - // XXX: Bad copy. - if externs.contains_key(copy name) { return externs.get(name); } + if externs.contains_key_ref(&name) { return externs.get(name); } let c = str::as_c_str(name, |buf| { llvm::LLVMAddGlobal(llmod, ty, buf) }); @@ -451,7 +449,7 @@ pub fn set_glue_inlining(f: ValueRef, t: ty::t) { // silently mangles such symbols, breaking our linkage model. pub fn note_unique_llvm_symbol(ccx: @crate_ctxt, +sym: ~str) { // XXX: Bad copy. - if ccx.all_llvm_symbols.contains_key(copy sym) { + if ccx.all_llvm_symbols.contains_key_ref(&sym) { ccx.sess.bug(~"duplicate LLVM symbol: " + sym); } ccx.all_llvm_symbols.insert(sym, ()); @@ -679,7 +677,7 @@ pub fn iter_structural_ty(cx: block, av: ValueRef, t: ty::t, let variant_cx = sub_block(cx, ~"enum-iter-variant-" + - int::to_str(variant.disr_val, 10u)); + int::to_str(variant.disr_val)); AddCase(llswitch, C_int(ccx, variant.disr_val), variant_cx.llbb); let variant_cx = iter_variant(variant_cx, llunion_a_ptr, *variant, @@ -1850,7 +1848,7 @@ pub fn trans_enum_variant(ccx: @crate_ctxt, ty: varg.ty, pat: ast_util::ident_to_pat( ccx.tcx.sess.next_node_id(), - ast_util::dummy_sp(), + codemap::dummy_sp(), special_idents::arg), id: varg.id, } @@ -1888,7 +1886,7 @@ pub fn trans_enum_variant(ccx: @crate_ctxt, // works. So we have to cast to the destination's view of the type. let llarg = match fcx.llargs.find(va.id) { Some(local_mem(x)) => x, - _ => fail ~"trans_enum_variant: how do we know this works?", + _ => die!(~"trans_enum_variant: how do we know this works?"), }; let arg_ty = arg_tys[i].ty; memcpy_ty(bcx, lldestptr, llarg, arg_ty); @@ -1913,7 +1911,7 @@ pub fn trans_tuple_struct(ccx: @crate_ctxt, is_mutbl: false, ty: field.node.ty, pat: ast_util::ident_to_pat(ccx.tcx.sess.next_node_id(), - ast_util::dummy_sp(), + codemap::dummy_sp(), special_idents::arg), id: field.node.id } @@ -2024,7 +2022,7 @@ pub fn trans_item(ccx: @crate_ctxt, item: ast::item) { let path = match ccx.tcx.items.get(item.id) { ast_map::node_item(_, p) => p, // tjc: ? - _ => fail ~"trans_item", + _ => die!(~"trans_item"), }; match /*bad*/copy item.node { // XXX: Bad copies. @@ -2044,7 +2042,7 @@ pub fn trans_item(ccx: @crate_ctxt, item: ast::item) { } else { for vec::each((*body).node.stmts) |stmt| { match stmt.node { - ast::stmt_decl(@ast::spanned { node: ast::decl_item(i), + ast::stmt_decl(@codemap::spanned { node: ast::decl_item(i), _ }, _) => { trans_item(ccx, *i); } @@ -2280,7 +2278,7 @@ pub fn item_path(ccx: @crate_ctxt, i: @ast::item) -> path { /*bad*/copy *match ccx.tcx.items.get(i.id) { ast_map::node_item(_, p) => p, // separate map for paths? - _ => fail ~"item_path" + _ => die!(~"item_path") }, ~[path_name(i.ident)]) } @@ -2367,7 +2365,7 @@ pub fn get_item_val(ccx: @crate_ctxt, id: ast::node_id) -> ValueRef { set_inline_hint_if_appr(/*bad*/copy i.attrs, llfn); llfn } - _ => fail ~"get_item_val: weird result in table" + _ => die!(~"get_item_val: weird result in table") } } ast_map::node_trait_method(trait_method, _, pth) => { @@ -2448,14 +2446,14 @@ pub fn get_item_val(ccx: @crate_ctxt, id: ast::node_id) -> ValueRef { ast::item_enum(_, _) => { register_fn(ccx, (*v).span, pth, id, enm.attrs) } - _ => fail ~"node_variant, shouldn't happen" + _ => die!(~"node_variant, shouldn't happen") }; } ast::struct_variant_kind(_) => { - fail ~"struct variant kind unexpected in get_item_val" + die!(~"struct variant kind unexpected in get_item_val") } ast::enum_variant_kind(_) => { - fail ~"enum variant kind unexpected in get_item_val" + die!(~"enum variant kind unexpected in get_item_val") } } set_inline_hint(llfn); @@ -2485,7 +2483,7 @@ pub fn get_item_val(ccx: @crate_ctxt, id: ast::node_id) -> ValueRef { ccx.sess.bug(~"get_item_val(): unexpected variant") } }; - if !(exprt || ccx.reachable.contains_key(id)) { + if !(exprt || ccx.reachable.contains_key_ref(&id)) { lib::llvm::SetLinkage(val, lib::llvm::InternalLinkage); } ccx.item_vals.insert(id, val); @@ -2798,7 +2796,7 @@ pub fn decl_gc_metadata(ccx: @crate_ctxt, llmod_id: ~str) { pub fn create_module_map(ccx: @crate_ctxt) -> ValueRef { let elttype = T_struct(~[ccx.int_type, ccx.int_type]); - let maptype = T_array(elttype, ccx.module_data.size() + 1u); + let maptype = T_array(elttype, ccx.module_data.len() + 1); let map = str::as_c_str(~"_rust_mod_map", |buf| { unsafe { llvm::LLVMAddGlobal(ccx.llmod, maptype, buf) @@ -2808,7 +2806,7 @@ pub fn create_module_map(ccx: @crate_ctxt) -> ValueRef { lib::llvm::SetLinkage(map, lib::llvm::InternalLinkage); } let mut elts: ~[ValueRef] = ~[]; - for ccx.module_data.each |key, val| { + for ccx.module_data.each_ref |&key, &val| { let elt = C_struct(~[p2i(ccx, C_cstr(ccx, key)), p2i(ccx, val)]); elts.push(elt); @@ -3016,7 +3014,7 @@ pub fn trans_crate(sess: session::Session, monomorphized: HashMap(), monomorphizing: HashMap(), type_use_cache: HashMap(), - vtables: map::HashMap(), + vtables: oldmap::HashMap(), const_cstr_cache: HashMap(), const_globals: HashMap(), const_values: HashMap(), @@ -3089,7 +3087,7 @@ pub fn trans_crate(sess: session::Session, } if ccx.sess.count_llvm_insns() { - for ccx.stats.llvm_insns.each |k, v| { + for ccx.stats.llvm_insns.each_ref |&k, &v| { io::println(fmt!("%-7u %s", v, k)); } } diff --git a/src/librustc/middle/trans/build.rs b/src/librustc/middle/trans/build.rs index 850da79290c..79236433580 100644 --- a/src/librustc/middle/trans/build.rs +++ b/src/librustc/middle/trans/build.rs @@ -22,7 +22,7 @@ use core::cast; use core::libc; use core::str; use core::vec; -use std::map::HashMap; +use std::oldmap::HashMap; use syntax::codemap; pub fn terminate(cx: block, _: &str) { @@ -33,7 +33,7 @@ pub fn terminate(cx: block, _: &str) { pub fn check_not_terminated(cx: block) { if cx.terminated { - fail ~"already terminated!"; + die!(~"already terminated!"); } } diff --git a/src/librustc/middle/trans/cabi_x86_64.rs b/src/librustc/middle/trans/cabi_x86_64.rs index e4a70241d1a..d3eb2157ee3 100644 --- a/src/librustc/middle/trans/cabi_x86_64.rs +++ b/src/librustc/middle/trans/cabi_x86_64.rs @@ -96,7 +96,7 @@ fn classify_ty(ty: TypeRef) -> ~[x86_64_reg_class] { let elt = llvm::LLVMGetElementType(ty); ty_align(elt) } - _ => fail ~"ty_size: unhandled type" + _ => die!(~"ty_size: unhandled type") }; } } @@ -122,7 +122,7 @@ fn classify_ty(ty: TypeRef) -> ~[x86_64_reg_class] { let eltsz = ty_size(elt); len * eltsz } - _ => fail ~"ty_size: unhandled type" + _ => die!(~"ty_size: unhandled type") }; } } @@ -215,7 +215,7 @@ fn classify_ty(ty: TypeRef) -> ~[x86_64_reg_class] { i += 1u; } } - _ => fail ~"classify: unhandled type" + _ => die!(~"classify: unhandled type") } } } @@ -315,7 +315,7 @@ fn llreg_ty(cls: &[x86_64_reg_class]) -> TypeRef { sse_ds_class => { tys.push(T_f64()); } - _ => fail ~"llregtype: unhandled class" + _ => die!(~"llregtype: unhandled class") } i += 1u; } diff --git a/src/librustc/middle/trans/callee.rs b/src/librustc/middle/trans/callee.rs index 91eabaf6ab8..833cff80d2d 100644 --- a/src/librustc/middle/trans/callee.rs +++ b/src/librustc/middle/trans/callee.rs @@ -383,7 +383,7 @@ pub fn trans_rtcall_or_lang_call_with_type_params(bcx: block, llfnty = T_ptr(struct_elt(llfnty, 0)); new_llval = PointerCast(callee.bcx, fn_data.llfn, llfnty); } - _ => fail + _ => die!() } Callee { bcx: callee.bcx, data: Fn(FnData { llfn: new_llval }) } }, @@ -672,7 +672,8 @@ pub fn trans_arg_expr(bcx: block, // FIXME(#3548) use the adjustments table match autoref_arg { DoAutorefArg => { - assert !bcx.ccx().maps.moves_map.contains_key(arg_expr.id); + assert !bcx.ccx().maps.moves_map.contains_key_ref( + &arg_expr.id); val = arg_datum.to_ref_llval(bcx); } DontAutorefArg => { @@ -682,16 +683,16 @@ pub fn trans_arg_expr(bcx: block, // the explicit self code currently passes by-ref, it // does not hold. // - //assert !bcx.ccx().maps.moves_map.contains_key( - // arg_expr.id); + //assert !bcx.ccx().maps.moves_map.contains_key_ref( + // &arg_expr.id); val = arg_datum.to_ref_llval(bcx); } ast::by_val => { // NB: avoid running the take glue. - assert !bcx.ccx().maps.moves_map.contains_key( - arg_expr.id); + assert !bcx.ccx().maps.moves_map.contains_key_ref( + &arg_expr.id); val = arg_datum.to_value_llval(bcx); } diff --git a/src/librustc/middle/trans/closure.rs b/src/librustc/middle/trans/closure.rs index 52bb8f56218..4cbf6a4f4b7 100644 --- a/src/librustc/middle/trans/closure.rs +++ b/src/librustc/middle/trans/closure.rs @@ -28,7 +28,7 @@ use middle::trans::type_of::*; use util::ppaux::ty_to_str; use core::libc::c_uint; -use std::map::HashMap; +use std::oldmap::HashMap; use syntax::ast; use syntax::ast_map::{path, path_mod, path_name}; use syntax::ast_util; @@ -121,8 +121,8 @@ pub struct EnvValue { } pub impl EnvAction { - fn to_str() -> ~str { - match self { + fn to_str(&self) -> ~str { + match *self { EnvCopy => ~"EnvCopy", EnvMove => ~"EnvMove", EnvRef => ~"EnvRef" diff --git a/src/librustc/middle/trans/common.rs b/src/librustc/middle/trans/common.rs index 6a2618412b9..571f16e4b34 100644 --- a/src/librustc/middle/trans/common.rs +++ b/src/librustc/middle/trans/common.rs @@ -53,7 +53,7 @@ use core::str; use core::to_bytes; use core::vec::raw::to_ptr; use core::vec; -use std::map::{HashMap, Set}; +use std::oldmap::{HashMap, Set}; use syntax::ast::ident; use syntax::ast_map::path; use syntax::codemap::span; @@ -720,7 +720,7 @@ pub impl block { fn ty_to_str(t: ty::t) -> ~str { ty_to_str(self.tcx(), t) } - fn to_str() -> ~str { + fn to_str(&self) -> ~str { match self.node_info { Some(node_info) => { fmt!("[block %d]", node_info.id) diff --git a/src/librustc/middle/trans/consts.rs b/src/librustc/middle/trans/consts.rs index 947e67c9e43..b5652fed10e 100644 --- a/src/librustc/middle/trans/consts.rs +++ b/src/librustc/middle/trans/consts.rs @@ -126,7 +126,7 @@ pub fn get_const_val(cx: @crate_ctxt, def_id: ast::def_id) -> ValueRef { if !ast_util::is_local(def_id) { cx.tcx.sess.bug(~"cross-crate constants"); } - if !cx.const_values.contains_key(def_id.node) { + if !cx.const_values.contains_key_ref(&def_id.node) { match cx.tcx.items.get(def_id.node) { ast_map::node_item(@ast::item { node: ast::item_const(_, subexpr), _ diff --git a/src/librustc/middle/trans/controlflow.rs b/src/librustc/middle/trans/controlflow.rs index 92ea60d1946..240c323965f 100644 --- a/src/librustc/middle/trans/controlflow.rs +++ b/src/librustc/middle/trans/controlflow.rs @@ -183,8 +183,7 @@ pub fn trans_log(log_ex: @ast::expr, // XXX: Bad copy. let modname = path_str(ccx.sess, copy modpath); - // XXX: Bad copy. - let global = if ccx.module_data.contains_key(copy modname) { + let global = if ccx.module_data.contains_key_ref(&modname) { ccx.module_data.get(modname) } else { let s = link::mangle_internal_name_by_path_and_seq( diff --git a/src/librustc/middle/trans/datum.rs b/src/librustc/middle/trans/datum.rs index 6498b69fbc0..554cebbbcb7 100644 --- a/src/librustc/middle/trans/datum.rs +++ b/src/librustc/middle/trans/datum.rs @@ -223,7 +223,7 @@ pub impl Datum { * `id` is located in the move table, but copies otherwise. */ - if bcx.ccx().maps.moves_map.contains_key(id) { + if bcx.ccx().maps.moves_map.contains_key_ref(&id) { self.move_to(bcx, action, dst) } else { self.copy_to(bcx, action, dst) @@ -841,7 +841,7 @@ pub impl DatumBlock { self.bcx.tcx() } - fn to_str() -> ~str { + fn to_str(&self) -> ~str { self.datum.to_str(self.ccx()) } } diff --git a/src/librustc/middle/trans/debuginfo.rs b/src/librustc/middle/trans/debuginfo.rs index d4c86cbaa09..35abddfb85a 100644 --- a/src/librustc/middle/trans/debuginfo.rs +++ b/src/librustc/middle/trans/debuginfo.rs @@ -26,8 +26,8 @@ use util::ppaux::ty_to_str; use core::libc; use core::option; use core::sys; -use std::map::HashMap; -use std::map; +use std::oldmap::HashMap; +use std::oldmap; use syntax::ast::Ty; use syntax::codemap::{span, CharPos}; use syntax::parse::token::ident_interner; @@ -111,13 +111,13 @@ pub type debug_ctxt = { }; pub fn mk_ctxt(+crate: ~str, intr: @ident_interner) -> debug_ctxt { - {llmetadata: map::HashMap(), + {llmetadata: oldmap::HashMap(), names: new_namegen(intr), crate_file: crate} } fn update_cache(cache: metadata_cache, mdtag: int, val: debug_metadata) { - let existing = if cache.contains_key(mdtag) { + let existing = if cache.contains_key_ref(&mdtag) { cache.get(mdtag) } else { ~[] @@ -176,7 +176,7 @@ fn cached_metadata<T: Copy>(cache: metadata_cache, eq_fn: fn(md: T) -> bool) -> Option<T> { unsafe { - if cache.contains_key(mdtag) { + if cache.contains_key_ref(&mdtag) { let items = cache.get(mdtag); for items.each |item| { let md: T = md_from_metadata::<T>(*item); @@ -268,7 +268,7 @@ fn create_block(cx: block) -> @metadata<block_md> { while cx.node_info.is_none() { match cx.parent { Some(b) => cx = b, - None => fail + None => die!() } } let sp = cx.node_info.get().span; @@ -548,7 +548,7 @@ fn create_ty(_cx: @crate_ctxt, _t: ty::t, _ty: @ast::Ty) * elsewhere, not be self-contained. */ - fail; + die!(); /* fn t_to_ty(cx: crate_ctxt, t: ty::t, span: span) -> @ast::ty { let ty = match ty::get(t).struct { @@ -664,7 +664,7 @@ pub fn create_local_var(bcx: block, local: @ast::local) let name = match local.node.pat.node { ast::pat_ident(_, pth, _) => ast_util::path_to_ident(pth), // FIXME this should be handled (#2533) - _ => fail ~"no single variable name for local" + _ => die!(~"no single variable name for local") }; let loc = cx.sess.codemap.lookup_char_pos(local.span.lo); let ty = node_id_type(bcx, local.node.id); diff --git a/src/librustc/middle/trans/expr.rs b/src/librustc/middle/trans/expr.rs index 2443f426ee4..4cf449cd972 100644 --- a/src/librustc/middle/trans/expr.rs +++ b/src/librustc/middle/trans/expr.rs @@ -142,7 +142,7 @@ use util::ppaux::ty_to_str; use syntax::print::pprust::{expr_to_str}; use syntax::ast; -use syntax::ast::spanned; +use syntax::codemap::spanned; // Destinations @@ -265,7 +265,7 @@ pub fn trans_to_datum(bcx: block, expr: @ast::expr) -> DatumBlock { } pub fn trans_into(bcx: block, expr: @ast::expr, dest: Dest) -> block { - if bcx.tcx().adjustments.contains_key(expr.id) { + if bcx.tcx().adjustments.contains_key_ref(&expr.id) { // use trans_to_datum, which is mildly less efficient but // which will perform the adjustments: let datumblock = trans_to_datum(bcx, expr); @@ -426,7 +426,7 @@ fn trans_rvalue_datum_unadjusted(bcx: block, expr: @ast::expr) -> DatumBlock { } ast::expr_binary(op, lhs, rhs) => { // if overloaded, would be RvalueDpsExpr - assert !bcx.ccx().maps.method_map.contains_key(expr.id); + assert !bcx.ccx().maps.method_map.contains_key_ref(&expr.id); return trans_binary(bcx, expr, op, lhs, rhs); } @@ -468,9 +468,6 @@ fn trans_rvalue_stmt_unadjusted(bcx: block, expr: @ast::expr) -> block { ast::expr_ret(ex) => { return controlflow::trans_ret(bcx, ex); } - ast::expr_fail(why) => { - return controlflow::trans_fail_expr(bcx, Some(expr.span), why); - } ast::expr_log(_, lvl, a) => { return controlflow::trans_log(expr, lvl, bcx, a); } @@ -552,7 +549,7 @@ fn trans_rvalue_dps_unadjusted(bcx: block, expr: @ast::expr, ast::expr_tup(ref args) => { return trans_tup(bcx, *args, dest); } - ast::expr_lit(@ast::spanned {node: ast::lit_str(s), _}) => { + ast::expr_lit(@codemap::spanned {node: ast::lit_str(s), _}) => { return tvec::trans_lit_str(bcx, expr, s, dest); } ast::expr_vstore(contents, ast::expr_vstore_slice) | @@ -1246,7 +1243,7 @@ fn trans_unary_datum(bcx: block, assert op != ast::deref; // if overloaded, would be RvalueDpsExpr - assert !bcx.ccx().maps.method_map.contains_key(un_expr.id); + assert !bcx.ccx().maps.method_map.contains_key_ref(&un_expr.id); let un_ty = expr_ty(bcx, un_expr); let sub_ty = expr_ty(bcx, sub_expr); diff --git a/src/librustc/middle/trans/foreign.rs b/src/librustc/middle/trans/foreign.rs index 0431d0aa4dd..3d441dc973a 100644 --- a/src/librustc/middle/trans/foreign.rs +++ b/src/librustc/middle/trans/foreign.rs @@ -500,7 +500,7 @@ pub fn trans_intrinsic(ccx: @crate_ctxt, if tp_sz != out_sz { let sp = match ccx.tcx.items.get(ref_id.get()) { ast_map::node_expr(e) => e.span, - _ => fail ~"reinterpret_cast or forget has non-expr arg" + _ => die!(~"reinterpret_cast or forget has non-expr arg") }; ccx.sess.span_fatal( sp, fmt!("reinterpret_cast called on types \ @@ -958,7 +958,7 @@ fn abi_of_foreign_fn(ccx: @crate_ctxt, i: @ast::foreign_item) None => match ccx.tcx.items.get(i.id) { ast_map::node_foreign_item(_, abi, _) => abi, // ?? - _ => fail ~"abi_of_foreign_fn: not foreign" + _ => die!(~"abi_of_foreign_fn: not foreign") }, Some(_) => match attr::foreign_abi(i.attrs) { either::Right(abi) => abi, diff --git a/src/librustc/middle/trans/glue.rs b/src/librustc/middle/trans/glue.rs index 4e557082e61..849a718a52e 100644 --- a/src/librustc/middle/trans/glue.rs +++ b/src/librustc/middle/trans/glue.rs @@ -380,7 +380,7 @@ pub fn make_visit_glue(bcx: block, v: ValueRef, t: ty::t) { let _icx = bcx.insn_ctxt("make_visit_glue"); let mut bcx = bcx; let ty_visitor_name = special_idents::ty_visitor; - assert bcx.ccx().tcx.intrinsic_defs.contains_key(ty_visitor_name); + assert bcx.ccx().tcx.intrinsic_defs.contains_key_ref(&ty_visitor_name); let (trait_id, ty) = bcx.ccx().tcx.intrinsic_defs.get(ty_visitor_name); let v = PointerCast(bcx, v, T_ptr(type_of::type_of(bcx.ccx(), ty))); bcx = reflect::emit_calls_to_trait_visit_ty(bcx, t, v, trait_id); @@ -757,7 +757,7 @@ pub fn emit_tydescs(ccx: @crate_ctxt) { let _icx = ccx.insn_ctxt("emit_tydescs"); // As of this point, allow no more tydescs to be created. ccx.finished_tydescs = true; - for ccx.tydescs.each |_key, val| { + for ccx.tydescs.each_value_ref |&val| { let glue_fn_ty = T_ptr(T_generic_glue_fn(ccx)); let ti = val; diff --git a/src/librustc/middle/trans/machine.rs b/src/librustc/middle/trans/machine.rs index 7af3b7a0683..1b3e13cddab 100644 --- a/src/librustc/middle/trans/machine.rs +++ b/src/librustc/middle/trans/machine.rs @@ -178,7 +178,7 @@ pub fn llalign_of(cx: @crate_ctxt, t: TypeRef) -> ValueRef { // Computes the size of the data part of an enum. pub fn static_size_of_enum(cx: @crate_ctxt, t: ty::t) -> uint { - if cx.enum_sizes.contains_key(t) { return cx.enum_sizes.get(t); } + if cx.enum_sizes.contains_key_ref(&t) { return cx.enum_sizes.get(t); } match ty::get(t).sty { ty::ty_enum(tid, ref substs) => { // Compute max(variant sizes). diff --git a/src/librustc/middle/trans/meth.rs b/src/librustc/middle/trans/meth.rs index bb815df6b75..f488c32437c 100644 --- a/src/librustc/middle/trans/meth.rs +++ b/src/librustc/middle/trans/meth.rs @@ -33,7 +33,7 @@ use middle::typeck; use util::ppaux::{ty_to_str, tys_to_str}; use core::libc::c_uint; -use std::map::HashMap; +use std::oldmap::HashMap; use syntax::ast_map::{path, path_mod, path_name, node_id_to_str}; use syntax::ast_util::local_def; use syntax::print::pprust::expr_to_str; @@ -253,7 +253,7 @@ pub fn trans_method_callee(bcx: block, trait_id, off, vtbl) } // how to get rid of this? - None => fail ~"trans_method_callee: missing param_substs" + None => die!(~"trans_method_callee: missing param_substs") } } typeck::method_trait(_, off, vstore) => { @@ -265,7 +265,8 @@ pub fn trans_method_callee(bcx: block, mentry.explicit_self) } typeck::method_self(*) | typeck::method_super(*) => { - fail ~"method_self or method_super should have been handled above" + die!(~"method_self or method_super should have been handled \ + above") } } } @@ -311,13 +312,13 @@ pub fn trans_static_method_callee(bcx: block, ast_map::node_trait_method(trait_method, _, _) => { ast_util::trait_method_to_ty_method(*trait_method).ident } - _ => fail ~"callee is not a trait method" + _ => die!(~"callee is not a trait method") } } else { let path = csearch::get_item_path(bcx.tcx(), method_id); match path[path.len()-1] { path_name(s) => { s } - path_mod(_) => { fail ~"path doesn't have a name?" } + path_mod(_) => { die!(~"path doesn't have a name?") } } }; debug!("trans_static_method_callee: method_id=%?, callee_id=%?, \ @@ -347,8 +348,8 @@ pub fn trans_static_method_callee(bcx: block, FnData {llfn: PointerCast(bcx, lval, llty)} } _ => { - fail ~"vtable_param left in monomorphized \ - function's vtable substs"; + die!(~"vtable_param left in monomorphized \ + function's vtable substs"); } } } @@ -368,7 +369,7 @@ pub fn method_with_name(ccx: @crate_ctxt, impl_id: ast::def_id, }, _) => { method_from_methods(/*bad*/copy *ms, name).get() } - _ => fail ~"method_with_name" + _ => die!(~"method_with_name") } } else { csearch::get_impl_method(ccx.sess.cstore, impl_id, name) @@ -396,13 +397,13 @@ pub fn method_with_name_or_default(ccx: @crate_ctxt, impl_id: ast::def_id, return pmi.method_info.did; } } - fail + die!() } - None => fail + None => die!() } } } - _ => fail ~"method_with_name" + _ => die!(~"method_with_name") } } else { csearch::get_impl_method(ccx.sess.cstore, impl_id, name) @@ -421,14 +422,14 @@ pub fn method_ty_param_count(ccx: @crate_ctxt, m_id: ast::def_id, method_ty_param_count( ccx, source.method_id, source.impl_id) } - None => fail + None => die!() } } Some(ast_map::node_trait_method(@ast::provided(@ref m), _, _)) => { m.tps.len() } - copy e => fail fmt!("method_ty_param_count %?", e) + copy e => die!(fmt!("method_ty_param_count %?", e)) } } else { csearch::get_type_param_count(ccx.sess.cstore, m_id) - @@ -493,7 +494,8 @@ pub fn trans_monomorphized_callee(bcx: block, mentry.explicit_self) } typeck::vtable_param(*) => { - fail ~"vtable_param left in monomorphized function's vtable substs"; + die!(~"vtable_param left in monomorphized function's " + + "vtable substs"); } }; @@ -768,7 +770,7 @@ pub fn vtable_id(ccx: @crate_ctxt, } } // can't this be checked at the callee? - _ => fail ~"vtable_id" + _ => die!(~"vtable_id") } } @@ -783,7 +785,7 @@ pub fn get_vtable(ccx: @crate_ctxt, typeck::vtable_static(id, substs, sub_vtables) => { make_impl_vtable(ccx, id, substs, sub_vtables) } - _ => fail ~"get_vtable: expected a static origin" + _ => die!(~"get_vtable: expected a static origin") } } } @@ -869,7 +871,7 @@ pub fn trans_trait_cast(bcx: block, match vstore { ty::vstore_slice(*) | ty::vstore_box => { let mut llboxdest = GEPi(bcx, lldest, [0u, 1u]); - if bcx.tcx().legacy_boxed_traits.contains_key(id) { + if bcx.tcx().legacy_boxed_traits.contains_key_ref(&id) { // Allocate an @ box and store the value into it let {bcx: new_bcx, box: llbox, body: body} = malloc_boxed(bcx, v_ty); diff --git a/src/librustc/middle/trans/reachable.rs b/src/librustc/middle/trans/reachable.rs index 6b266f1d963..02e07e8484a 100644 --- a/src/librustc/middle/trans/reachable.rs +++ b/src/librustc/middle/trans/reachable.rs @@ -22,7 +22,7 @@ use middle::ty; use middle::typeck; use core::vec; -use std::map::HashMap; +use std::oldmap::HashMap; use syntax::ast::*; use syntax::ast_util::def_id_of_def; use syntax::attr; @@ -95,7 +95,7 @@ fn traverse_public_mod(cx: ctx, mod_id: node_id, m: _mod) { } fn traverse_public_item(cx: ctx, item: @item) { - if cx.rmap.contains_key(item.id) { return; } + if cx.rmap.contains_key_ref(&item.id) { return; } cx.rmap.insert(item.id, ()); match /*bad*/copy item.node { item_mod(m) => traverse_public_mod(cx, item.id, m), @@ -135,7 +135,7 @@ fn traverse_public_item(cx: ctx, item: @item) { } item_const(*) | item_enum(*) | item_trait(*) => (), - item_mac(*) => fail ~"item macros unimplemented" + item_mac(*) => die!(~"item macros unimplemented") } } @@ -145,7 +145,7 @@ fn mk_ty_visitor() -> visit::vt<ctx> { } fn traverse_ty(ty: @Ty, cx: ctx, v: visit::vt<ctx>) { - if cx.rmap.contains_key(ty.id) { return; } + if cx.rmap.contains_key_ref(&ty.id) { return; } cx.rmap.insert(ty.id, ()); match ty.node { @@ -223,7 +223,7 @@ fn traverse_inline_body(cx: ctx, body: blk) { fn traverse_all_resources_and_impls(cx: ctx, crate_mod: _mod) { visit::visit_mod( - crate_mod, ast_util::dummy_sp(), 0, cx, + crate_mod, codemap::dummy_sp(), 0, cx, visit::mk_vt(@visit::Visitor { visit_expr: |_e, _cx, _v| { }, visit_item: |i, cx, v| { diff --git a/src/librustc/middle/trans/reflect.rs b/src/librustc/middle/trans/reflect.rs index 26ea47d7e73..b9a055ad8ab 100644 --- a/src/librustc/middle/trans/reflect.rs +++ b/src/librustc/middle/trans/reflect.rs @@ -24,7 +24,7 @@ use middle::trans::meth; use middle::trans::type_of::*; use util::ppaux::ty_to_str; -use std::map::HashMap; +use std::oldmap::HashMap; use syntax::ast::def_id; use syntax::ast; @@ -316,7 +316,7 @@ pub fn emit_calls_to_trait_visit_ty(bcx: block, -> block { use syntax::parse::token::special_idents::tydesc; let final = sub_block(bcx, ~"final"); - assert bcx.ccx().tcx.intrinsic_defs.contains_key(tydesc); + assert bcx.ccx().tcx.intrinsic_defs.contains_key_ref(&tydesc); let (_, tydesc_ty) = bcx.ccx().tcx.intrinsic_defs.get(tydesc); let tydesc_ty = type_of::type_of(bcx.ccx(), tydesc_ty); let r = reflector({ diff --git a/src/librustc/middle/trans/shape.rs b/src/librustc/middle/trans/shape.rs index a4cd967115b..4f0e59b723e 100644 --- a/src/librustc/middle/trans/shape.rs +++ b/src/librustc/middle/trans/shape.rs @@ -26,9 +26,9 @@ use util::ppaux::ty_to_str; use core::dvec::DVec; use core::option::is_some; use core::vec; -use std::map::HashMap; +use std::oldmap::HashMap; use syntax::ast; -use syntax::ast_util::dummy_sp; +use syntax::codemap::dummy_sp; use syntax::codemap::span; use syntax::util::interner; diff --git a/src/librustc/middle/trans/tvec.rs b/src/librustc/middle/trans/tvec.rs index 1608bc35c26..e103ae15593 100644 --- a/src/librustc/middle/trans/tvec.rs +++ b/src/librustc/middle/trans/tvec.rs @@ -201,7 +201,7 @@ pub fn trans_slice_vstore(bcx: block, // Handle the &"..." case: match content_expr.node { - ast::expr_lit(@ast::spanned {node: ast::lit_str(s), span: _}) => { + ast::expr_lit(@codemap::spanned {node: ast::lit_str(s), span: _}) => { return trans_lit_str(bcx, content_expr, s, dest); } _ => {} @@ -296,7 +296,7 @@ pub fn trans_uniq_or_managed_vstore(bcx: block, match heap { heap_exchange => { match content_expr.node { - ast::expr_lit(@ast::spanned { + ast::expr_lit(@codemap::spanned { node: ast::lit_str(s), _ }) => { let llptrval = C_cstr(bcx.ccx(), copy *s); @@ -354,7 +354,7 @@ pub fn write_content(bcx: block, let _indenter = indenter(); match /*bad*/copy content_expr.node { - ast::expr_lit(@ast::spanned { node: ast::lit_str(s), _ }) => { + ast::expr_lit(@codemap::spanned { node: ast::lit_str(s), _ }) => { match dest { Ignore => { return bcx; @@ -461,7 +461,7 @@ pub fn elements_required(bcx: block, content_expr: @ast::expr) -> uint { //! Figure out the number of elements we need to store this content match /*bad*/copy content_expr.node { - ast::expr_lit(@ast::spanned { node: ast::lit_str(s), _ }) => { + ast::expr_lit(@codemap::spanned { node: ast::lit_str(s), _ }) => { s.len() + 1 }, ast::expr_vec(es, _) => es.len(), diff --git a/src/librustc/middle/trans/type_of.rs b/src/librustc/middle/trans/type_of.rs index 6f183aa50b0..72efab0c371 100644 --- a/src/librustc/middle/trans/type_of.rs +++ b/src/librustc/middle/trans/type_of.rs @@ -17,7 +17,7 @@ use middle::trans::expr; use middle::trans::machine; use util::ppaux; -use std::map::HashMap; +use std::oldmap::HashMap; use syntax::ast; pub fn type_of_explicit_arg(ccx: @crate_ctxt, arg: ty::arg) -> TypeRef { @@ -87,7 +87,7 @@ pub fn type_of(cx: @crate_ctxt, t: ty::t) -> TypeRef { debug!("type_of %?: %?", t, ty::get(t)); // Check the cache. - if cx.lltypes.contains_key(t) { return cx.lltypes.get(t); } + if cx.lltypes.contains_key_ref(&t) { return cx.lltypes.get(t); } // Replace any typedef'd types with their equivalent non-typedef // type. This ensures that all LLVM nominal types that contain diff --git a/src/librustc/middle/trans/type_use.rs b/src/librustc/middle/trans/type_use.rs index d678b76a1e1..350b1393c33 100644 --- a/src/librustc/middle/trans/type_use.rs +++ b/src/librustc/middle/trans/type_use.rs @@ -38,7 +38,7 @@ use core::uint; use core::vec; use std::list::{List, Cons, Nil}; use std::list; -use std::map::HashMap; +use std::oldmap::HashMap; use syntax::ast::*; use syntax::ast_map; use syntax::ast_util; @@ -147,7 +147,7 @@ pub fn type_uses_for(ccx: @crate_ctxt, fn_id: def_id, n_tps: uint) ~"bswap16" | ~"bswap32" | ~"bswap64" => 0, // would be cool to make these an enum instead of strings! - _ => fail ~"unknown intrinsic in type_use" + _ => die!(~"unknown intrinsic in type_use") }; for uint::range(0u, n_tps) |n| { cx.uses[n] |= flags;} } @@ -340,7 +340,7 @@ pub fn mark_for_expr(cx: ctx, e: @expr) { } expr_paren(e) => mark_for_expr(cx, e), expr_match(*) | expr_block(_) | expr_if(*) | - expr_while(*) | expr_fail(_) | expr_break(_) | expr_again(_) | + expr_while(*) | expr_break(_) | expr_again(_) | expr_unary(_, _) | expr_lit(_) | expr_assert(_) | expr_mac(_) | expr_addr_of(_, _) | expr_ret(_) | expr_loop(_, _) | diff --git a/src/librustc/middle/ty.rs b/src/librustc/middle/ty.rs index 255b87e2d5e..8610e3c85d7 100644 --- a/src/librustc/middle/ty.rs +++ b/src/librustc/middle/ty.rs @@ -41,12 +41,13 @@ use core::result; use core::to_bytes; use core::uint; use core::vec; -use std::map::HashMap; -use std::{map, smallintmap}; +use std::oldmap::HashMap; +use std::{oldmap, oldsmallintmap}; use syntax::ast::*; use syntax::ast_util::{is_local, local_def}; use syntax::ast_util; use syntax::codemap::span; +use syntax::codemap; use syntax::print::pprust; use syntax::{ast, ast_map}; use syntax; @@ -666,7 +667,7 @@ pub impl TyVid: Vid { } pub impl TyVid: ToStr { - pure fn to_str() -> ~str { fmt!("<V%u>", self.to_uint()) } + pure fn to_str(&self) -> ~str { fmt!("<V%u>", self.to_uint()) } } pub impl IntVid: Vid { @@ -674,7 +675,7 @@ pub impl IntVid: Vid { } pub impl IntVid: ToStr { - pure fn to_str() -> ~str { fmt!("<VI%u>", self.to_uint()) } + pure fn to_str(&self) -> ~str { fmt!("<VI%u>", self.to_uint()) } } pub impl FloatVid: Vid { @@ -682,7 +683,7 @@ pub impl FloatVid: Vid { } pub impl FloatVid: ToStr { - pure fn to_str() -> ~str { fmt!("<VF%u>", self.to_uint()) } + pure fn to_str(&self) -> ~str { fmt!("<VF%u>", self.to_uint()) } } pub impl RegionVid: Vid { @@ -690,19 +691,19 @@ pub impl RegionVid: Vid { } pub impl RegionVid: ToStr { - pure fn to_str() -> ~str { fmt!("%?", self) } + pure fn to_str(&self) -> ~str { fmt!("%?", self) } } pub impl FnSig : ToStr { - pure fn to_str() -> ~str { + pure fn to_str(&self) -> ~str { // grr, without tcx not much we can do. return ~"(...)"; } } pub impl InferTy: ToStr { - pure fn to_str() -> ~str { - match self { + pure fn to_str(&self) -> ~str { + match *self { TyVar(ref v) => v.to_str(), IntVar(ref v) => v.to_str(), FloatVar(ref v) => v.to_str() @@ -711,8 +712,8 @@ pub impl InferTy: ToStr { } pub impl IntVarValue : ToStr { - pure fn to_str() -> ~str { - match self { + pure fn to_str(&self) -> ~str { + match *self { IntType(ref v) => v.to_str(), UintType(ref v) => v.to_str(), } @@ -785,15 +786,15 @@ type type_cache = HashMap<ast::def_id, ty_param_bounds_and_ty>; type constness_cache = HashMap<ast::def_id, const_eval::constness>; -pub type node_type_table = @smallintmap::SmallIntMap<t>; +pub type node_type_table = @oldsmallintmap::SmallIntMap<t>; fn mk_rcache() -> creader_cache { type val = {cnum: int, pos: uint, len: uint}; - return map::HashMap(); + return oldmap::HashMap(); } -pub fn new_ty_hash<V: Copy>() -> map::HashMap<t, V> { - map::HashMap() +pub fn new_ty_hash<V: Copy>() -> oldmap::HashMap<t, V> { + oldmap::HashMap() } pub fn mk_ctxt(s: session::Session, @@ -821,7 +822,7 @@ pub fn mk_ctxt(s: session::Session, } } - let interner = map::HashMap(); + let interner = oldmap::HashMap(); let vecs_implicitly_copyable = get_lint_level(s.lint_settings.default_settings, lint::vecs_implicitly_copyable) == allow; @@ -837,10 +838,10 @@ pub fn mk_ctxt(s: session::Session, def_map: dm, region_map: region_map, region_paramd_items: region_paramd_items, - node_types: @smallintmap::mk(), - node_type_substs: map::HashMap(), + node_types: @oldsmallintmap::mk(), + node_type_substs: oldmap::HashMap(), items: amap, - intrinsic_defs: map::HashMap(), + intrinsic_defs: oldmap::HashMap(), freevars: freevars, tcache: HashMap(), rcache: mk_rcache(), @@ -1568,7 +1569,7 @@ pub fn get_element_type(ty: t, i: uint) -> t { match /*bad*/copy get(ty).sty { ty_rec(flds) => return flds[i].mt.ty, ty_tup(ts) => return ts[i], - _ => fail ~"get_element_type called on invalid type" + _ => die!(~"get_element_type called on invalid type") } } @@ -1744,7 +1745,7 @@ pub fn type_needs_unwind_cleanup(cx: ctxt, ty: t) -> bool { } fn type_needs_unwind_cleanup_(cx: ctxt, ty: t, - tycache: map::HashMap<t, ()>, + tycache: oldmap::HashMap<t, ()>, encountered_box: bool) -> bool { // Prevent infinite recursion @@ -2794,12 +2795,12 @@ impl sty : to_bytes::IterBytes { } pub fn br_hashmap<V:Copy>() -> HashMap<bound_region, V> { - map::HashMap() + oldmap::HashMap() } pub fn node_id_to_type(cx: ctxt, id: ast::node_id) -> t { - //io::println(fmt!("%?/%?", id, cx.node_types.size())); - match smallintmap::find(*cx.node_types, id as uint) { + //io::println(fmt!("%?/%?", id, cx.node_types.len())); + match oldsmallintmap::find(*cx.node_types, id as uint) { Some(t) => t, None => cx.sess.bug( fmt!("node_id_to_type: no type for node `%s`", @@ -2816,35 +2817,35 @@ pub fn node_id_to_type_params(cx: ctxt, id: ast::node_id) -> ~[t] { } fn node_id_has_type_params(cx: ctxt, id: ast::node_id) -> bool { - return cx.node_type_substs.contains_key(id); + return cx.node_type_substs.contains_key_ref(&id); } // Type accessors for substructures of types pub fn ty_fn_args(fty: t) -> ~[arg] { match get(fty).sty { ty_fn(ref f) => /*bad*/copy f.sig.inputs, - _ => fail ~"ty_fn_args() called on non-fn type" + _ => die!(~"ty_fn_args() called on non-fn type") } } pub fn ty_fn_proto(fty: t) -> Proto { match get(fty).sty { ty_fn(ref f) => f.meta.proto, - _ => fail ~"ty_fn_proto() called on non-fn type" + _ => die!(~"ty_fn_proto() called on non-fn type") } } pub fn ty_fn_purity(fty: t) -> ast::purity { match get(fty).sty { ty_fn(ref f) => f.meta.purity, - _ => fail ~"ty_fn_purity() called on non-fn type" + _ => die!(~"ty_fn_purity() called on non-fn type") } } pub pure fn ty_fn_ret(fty: t) -> t { match get(fty).sty { ty_fn(ref f) => f.sig.output, - _ => fail ~"ty_fn_ret() called on non-fn type" + _ => die!(~"ty_fn_ret() called on non-fn type") } } @@ -2859,7 +2860,7 @@ pub pure fn ty_vstore(ty: t) -> vstore { match get(ty).sty { ty_evec(_, vstore) => vstore, ty_estr(vstore) => vstore, - ref s => fail fmt!("ty_vstore() called on invalid sty: %?", s) + ref s => die!(fmt!("ty_vstore() called on invalid sty: %?", s)) } } @@ -2868,7 +2869,8 @@ pub fn ty_region(ty: t) -> Region { ty_rptr(r, _) => r, ty_evec(_, vstore_slice(r)) => r, ty_estr(vstore_slice(r)) => r, - ref s => fail fmt!("ty_region() invoked on in appropriate ty: %?", (*s)) + ref s => die!(fmt!("ty_region() invoked on in appropriate ty: %?", + (*s))) } } @@ -3112,7 +3114,7 @@ pub enum ExprKind { pub fn expr_kind(tcx: ctxt, method_map: typeck::method_map, expr: @ast::expr) -> ExprKind { - if method_map.contains_key(expr.id) { + if method_map.contains_key_ref(&expr.id) { // Overloaded operations are generally calls, and hence they are // generated via DPS. However, assign_op (e.g., `x += y`) is an // exception, as its result is always unit. @@ -3166,7 +3168,7 @@ pub fn expr_kind(tcx: ctxt, ast::expr_block(*) | ast::expr_copy(*) | ast::expr_repeat(*) | - ast::expr_lit(@ast::spanned {node: lit_str(_), _}) | + ast::expr_lit(@codemap::spanned {node: lit_str(_), _}) | ast::expr_vstore(_, ast::expr_vstore_slice) | ast::expr_vstore(_, ast::expr_vstore_mut_slice) | ast::expr_vstore(_, ast::expr_vstore_fixed(_)) | @@ -3175,7 +3177,7 @@ pub fn expr_kind(tcx: ctxt, } ast::expr_cast(*) => { - match smallintmap::find(*tcx.node_types, expr.id as uint) { + match oldsmallintmap::find(*tcx.node_types, expr.id as uint) { Some(t) => { if ty::type_is_immediate(t) { RvalueDatumExpr @@ -3204,7 +3206,6 @@ pub fn expr_kind(tcx: ctxt, ast::expr_again(*) | ast::expr_ret(*) | ast::expr_log(*) | - ast::expr_fail(*) | ast::expr_assert(*) | ast::expr_while(*) | ast::expr_loop(*) | @@ -3239,7 +3240,7 @@ pub fn stmt_node_id(s: @ast::stmt) -> ast::node_id { ast::stmt_decl(_, id) | stmt_expr(_, id) | stmt_semi(_, id) => { return id; } - ast::stmt_mac(*) => fail ~"unexpanded macro in trans" + ast::stmt_mac(*) => die!(~"unexpanded macro in trans") } } @@ -3263,7 +3264,7 @@ pub fn get_field(tcx: ctxt, rec_ty: t, id: ast::ident) -> field { match vec::find(get_fields(rec_ty), |f| f.ident == id) { Some(f) => f, // Do we only call this when we know the field is legit? - None => fail (fmt!("get_field: ty doesn't have a field %s", + None => die!(fmt!("get_field: ty doesn't have a field %s", tcx.sess.str_of(id))) } } @@ -3272,7 +3273,7 @@ pub fn get_fields(rec_ty:t) -> ~[field] { match /*bad*/copy get(rec_ty).sty { ty_rec(fields) => fields, // Can we check at the caller? - _ => fail ~"get_fields: not a record type" + _ => die!(~"get_fields: not a record type") } } @@ -3929,10 +3930,10 @@ pub fn enum_variants(cx: ctxt, id: ast::def_id) -> @~[VariantInfo] { } } ast::struct_variant_kind(_) => { - fail ~"struct variant kinds unimpl in enum_variants" + die!(~"struct variant kinds unimpl in enum_variants") } ast::enum_variant_kind(_) => { - fail ~"enum variant kinds unimpl in enum_variants" + die!(~"enum variant kinds unimpl in enum_variants") } } }) @@ -4358,7 +4359,7 @@ pub fn iter_bound_traits_and_supertraits(tcx: ctxt, if f(trait_ty) { // Add all the supertraits to the hash map, // executing <f> on each of them - while i < supertrait_map.size() && !fin { + while i < supertrait_map.len() && !fin { let init_trait_id = seen_def_ids[i]; i += 1; // Add supertraits to supertrait_map @@ -4367,7 +4368,7 @@ pub fn iter_bound_traits_and_supertraits(tcx: ctxt, let super_t = supertrait.tpt.ty; let d_id = ty_to_def_id(super_t).expect("supertrait \ should be a trait ty"); - if !supertrait_map.contains_key(d_id) { + if !supertrait_map.contains_key_ref(&d_id) { supertrait_map.insert(d_id, super_t); trait_ty = super_t; seen_def_ids.push(d_id); diff --git a/src/librustc/middle/typeck/check/_match.rs b/src/librustc/middle/typeck/check/_match.rs index 33250c294e0..3e898ce3aa6 100644 --- a/src/librustc/middle/typeck/check/_match.rs +++ b/src/librustc/middle/typeck/check/_match.rs @@ -20,7 +20,7 @@ use middle::typeck::check::{structure_of, valid_range_bounds}; use middle::typeck::require_same_types; use core::vec; -use std::map::HashMap; +use std::oldmap::HashMap; use syntax::ast; use syntax::ast_util::walk_pat; use syntax::ast_util; @@ -239,7 +239,7 @@ pub fn check_struct_pat_fields(pcx: pat_ctxt, // Report an error if not all the fields were specified. if !etc { for class_fields.eachi |i, field| { - if found_fields.contains_key(i) { + if found_fields.contains_key_ref(&i) { loop; } tcx.sess.span_err(span, diff --git a/src/librustc/middle/typeck/check/method.rs b/src/librustc/middle/typeck/check/method.rs index 44dd65f238b..5a12f9fc3a1 100644 --- a/src/librustc/middle/typeck/check/method.rs +++ b/src/librustc/middle/typeck/check/method.rs @@ -101,14 +101,14 @@ use core::dvec::DVec; use core::result; use core::uint; use core::vec; -use std::map::HashMap; +use std::oldmap::HashMap; use syntax::ast::{def_id, sty_by_ref, sty_value, sty_region, sty_box}; use syntax::ast::{sty_uniq, sty_static, node_id, by_copy, by_ref}; use syntax::ast::{m_const, m_mutbl, m_imm}; use syntax::ast; use syntax::ast_map; use syntax::ast_map::node_id_to_str; -use syntax::ast_util::dummy_sp; +use syntax::codemap::dummy_sp; use syntax::codemap::span; pub fn lookup( @@ -1171,11 +1171,12 @@ pub impl LookupContext { match candidate.origin { method_static(method_id) | method_self(method_id, _) | method_super(method_id, _) => { - bad = self.tcx().destructors.contains_key(method_id); + bad = self.tcx().destructors.contains_key_ref(&method_id); } method_param(method_param { trait_id: trait_id, _ }) | method_trait(trait_id, _, _) => { - bad = self.tcx().destructor_for_type.contains_key(trait_id); + bad = self.tcx().destructor_for_type.contains_key_ref( + &trait_id); } } @@ -1233,7 +1234,7 @@ pub impl LookupContext { let span = if did.crate == ast::local_crate { match self.tcx().items.find(did.node) { Some(ast_map::node_method(m, _, _)) => m.span, - _ => fail fmt!("report_static_candidate: bad item %?", did) + _ => die!(fmt!("report_static_candidate: bad item %?", did)) } } else { self.expr.span diff --git a/src/librustc/middle/typeck/check/mod.rs b/src/librustc/middle/typeck/check/mod.rs index 620c0d80440..f3abfe3282a 100644 --- a/src/librustc/middle/typeck/check/mod.rs +++ b/src/librustc/middle/typeck/check/mod.rs @@ -115,15 +115,15 @@ use core::result; use core::str; use core::vec; use std::list::Nil; -use std::map::HashMap; -use std::map; -use syntax::ast::{provided, required, spanned, ty_i}; +use std::oldmap::HashMap; +use std::oldmap; +use syntax::ast::{provided, required, ty_i}; use syntax::ast; use syntax::ast_map; -use syntax::ast_util::{Private, Public, is_local, local_def, respan}; +use syntax::ast_util::{Private, Public, is_local, local_def}; use syntax::ast_util::{visibility_to_privacy}; use syntax::ast_util; -use syntax::codemap::span; +use syntax::codemap::{span, spanned, respan}; use syntax::codemap; use syntax::parse::token::special_idents; use syntax::print::pprust; @@ -209,9 +209,9 @@ pub fn blank_inherited(ccx: @crate_ctxt) -> @inherited { @inherited { infcx: infer::new_infer_ctxt(ccx.tcx), locals: HashMap(), - node_types: map::HashMap(), - node_type_substs: map::HashMap(), - adjustments: map::HashMap() + node_types: oldmap::HashMap(), + node_type_substs: oldmap::HashMap(), + adjustments: oldmap::HashMap() } } @@ -528,7 +528,7 @@ pub fn check_struct(ccx: @crate_ctxt, struct_def: @ast::struct_def, def_id: local_def(id), explicit_self: spanned { node: ast::sty_by_ref, - span: ast_util::dummy_sp() } }; + span: codemap::dummy_sp() } }; // typecheck the dtor let dtor_dec = ast_util::dtor_dec(); check_bare_fn(ccx, &dtor_dec, @@ -1919,7 +1919,7 @@ pub fn check_expr_with_unifier(fcx: @fn_ctxt, match /*bad*/copy expr.node { ast::expr_vstore(ev, vst) => { let typ = match /*bad*/copy ev.node { - ast::expr_lit(@ast::spanned { node: ast::lit_str(s), _ }) => { + ast::expr_lit(@codemap::spanned { node: ast::lit_str(s), _ }) => { let tt = ast_expr_vstore_to_vstore(fcx, ev, str::len(*s), vst); ty::mk_estr(tcx, tt) } @@ -2087,17 +2087,6 @@ pub fn check_expr_with_unifier(fcx: @fn_ctxt, instantiate_path(fcx, pth, tpt, expr.span, expr.id, region_lb); } ast::expr_mac(_) => tcx.sess.bug(~"unexpanded macro"), - ast::expr_fail(expr_opt) => { - bot = true; - match expr_opt { - None => {/* do nothing */ } - Some(e) => { - check_expr_has_type( - fcx, e, ty::mk_estr(tcx, ty::vstore_uniq)); - } - } - fcx.write_bot(id); - } ast::expr_break(_) => { fcx.write_bot(id); bot = true; } ast::expr_again(_) => { fcx.write_bot(id); bot = true; } ast::expr_ret(expr_opt) => { @@ -2247,7 +2236,7 @@ pub fn check_expr_with_unifier(fcx: @fn_ctxt, demand::suptype(fcx, b.span, inner_ty, fcx.expr_ty(b)); } // argh - _ => fail ~"expr_fn_block" + _ => die!(~"expr_fn_block") } let block_ty = structurally_resolved_type( fcx, expr.span, fcx.node_ty(b.id)); @@ -2287,7 +2276,7 @@ pub fn check_expr_with_unifier(fcx: @fn_ctxt, demand::suptype(fcx, b.span, inner_ty, fcx.expr_ty(b)); } // argh - _ => fail ~"expected fn ty" + _ => die!(~"expected fn ty") } fcx.write_ty(expr.id, fcx.node_ty(b.id)); } @@ -2608,7 +2597,7 @@ pub fn check_block_with_expected(fcx0: @fn_ctxt, for blk.node.stmts.each |s| { if bot && !warned && match s.node { - ast::stmt_decl(@ast::spanned { node: ast::decl_local(_), + ast::stmt_decl(@codemap::spanned { node: ast::decl_local(_), _}, _) | ast::stmt_expr(_, _) | ast::stmt_semi(_, _) => { true @@ -3089,8 +3078,8 @@ pub fn check_intrinsic_type(ccx: @crate_ctxt, it: @ast::foreign_item) { ~"visit_tydesc" => { let tydesc_name = special_idents::tydesc; let ty_visitor_name = tcx.sess.ident_of(~"TyVisitor"); - assert tcx.intrinsic_defs.contains_key(tydesc_name); - assert ccx.tcx.intrinsic_defs.contains_key(ty_visitor_name); + assert tcx.intrinsic_defs.contains_key_ref(&tydesc_name); + assert ccx.tcx.intrinsic_defs.contains_key_ref(&ty_visitor_name); let (_, tydesc_ty) = tcx.intrinsic_defs.get(tydesc_name); let (_, visitor_trait) = tcx.intrinsic_defs.get(ty_visitor_name); let td_ptr = ty::mk_ptr(ccx.tcx, ty::mt {ty: tydesc_ty, diff --git a/src/librustc/middle/typeck/check/regionck.rs b/src/librustc/middle/typeck/check/regionck.rs index ae8574f8d1e..9ae55d4556b 100644 --- a/src/librustc/middle/typeck/check/regionck.rs +++ b/src/librustc/middle/typeck/check/regionck.rs @@ -211,7 +211,7 @@ pub fn visit_expr(expr: @ast::expr, &&rcx: @rcx, v: rvt) { // `constrain_auto_ref()` on all exprs. But that causes a // lot of spurious errors because of how the region // hierarchy is setup. - if rcx.fcx.ccx.method_map.contains_key(callee.id) { + if rcx.fcx.ccx.method_map.contains_key_ref(&callee.id) { match callee.node { ast::expr_field(base, _, _) => { constrain_auto_ref(rcx, base); @@ -689,7 +689,6 @@ pub mod guarantor { ast::expr_again(*) | ast::expr_ret(*) | ast::expr_log(*) | - ast::expr_fail(*) | ast::expr_assert(*) | ast::expr_while(*) | ast::expr_loop(*) | @@ -751,7 +750,7 @@ pub mod guarantor { let _i = ::util::common::indenter(); let guarantor = { - if rcx.fcx.ccx.method_map.contains_key(expr.id) { + if rcx.fcx.ccx.method_map.contains_key_ref(&expr.id) { None } else { guarantor(rcx, expr) diff --git a/src/librustc/middle/typeck/check/regionmanip.rs b/src/librustc/middle/typeck/check/regionmanip.rs index 2e652f90b8c..8ea35824e32 100644 --- a/src/librustc/middle/typeck/check/regionmanip.rs +++ b/src/librustc/middle/typeck/check/regionmanip.rs @@ -22,6 +22,7 @@ use util::ppaux; use std::list::Cons; use syntax::ast; +use syntax::codemap; use syntax::print::pprust::{expr_to_str}; // Helper functions related to manipulating region types. @@ -57,7 +58,7 @@ pub fn replace_bound_regions_in_fn_sig( let mut all_tys = ty::tys_in_fn_sig(fn_sig); match self_info { - Some({explicit_self: ast::spanned { node: ast::sty_region(m), + Some({explicit_self: codemap::spanned { node: ast::sty_region(m), _}, _}) => { let region = ty::re_bound(ty::br_self); let ty = ty::mk_rptr(tcx, region, diff --git a/src/librustc/middle/typeck/check/vtable.rs b/src/librustc/middle/typeck/check/vtable.rs index 85db1fd6e10..18a4f20d031 100644 --- a/src/librustc/middle/typeck/check/vtable.rs +++ b/src/librustc/middle/typeck/check/vtable.rs @@ -28,7 +28,7 @@ use core::result; use core::uint; use core::vec; use result::{Result, Ok, Err}; -use std::map::HashMap; +use std::oldmap::HashMap; use syntax::ast; use syntax::ast_util; use syntax::codemap::span; @@ -148,7 +148,7 @@ pub fn fixup_substs(vcx: &VtableContext, location_info: &LocationInfo, do fixup_ty(vcx, location_info, t, is_early).map |t_f| { match ty::get(*t_f).sty { ty::ty_trait(_, ref substs_f, _) => (/*bad*/copy *substs_f), - _ => fail ~"t_f should be a trait" + _ => die!(~"t_f should be a trait") } } } @@ -268,7 +268,7 @@ pub fn lookup_vtable(vcx: &VtableContext, // im is one specific impl of trait_ty. // First, ensure we haven't processed this impl yet. - if impls_seen.contains_key(im.did) { + if impls_seen.contains_key_ref(&im.did) { loop; } impls_seen.insert(im.did, ()); diff --git a/src/librustc/middle/typeck/check/writeback.rs b/src/librustc/middle/typeck/check/writeback.rs index 8fe9b140406..64ea45c8704 100644 --- a/src/librustc/middle/typeck/check/writeback.rs +++ b/src/librustc/middle/typeck/check/writeback.rs @@ -28,7 +28,7 @@ use util::ppaux; use core::result::{Result, Ok, Err}; use core::vec; -use std::map::HashMap; +use std::oldmap::HashMap; use syntax::ast; use syntax::codemap::span; use syntax::print::pprust::pat_to_str; @@ -141,7 +141,7 @@ fn maybe_resolve_type_vars_for_node(wbcx: wb_ctxt, sp: span, id: ast::node_id) -> Option<ty::t> { - if wbcx.fcx.inh.node_types.contains_key(id) { + if wbcx.fcx.inh.node_types.contains_key_ref(&id) { resolve_type_vars_for_node(wbcx, sp, id) } else { None diff --git a/src/librustc/middle/typeck/coherence.rs b/src/librustc/middle/typeck/coherence.rs index 334b2f46c3b..5ad8fd4c820 100644 --- a/src/librustc/middle/typeck/coherence.rs +++ b/src/librustc/middle/typeck/coherence.rs @@ -46,9 +46,9 @@ use syntax::ast::{trait_ref}; use syntax::ast; use syntax::ast_map::node_item; use syntax::ast_map; -use syntax::ast_util::{def_id_of_def, dummy_sp, local_def}; +use syntax::ast_util::{def_id_of_def, local_def}; use syntax::attr; -use syntax::codemap::span; +use syntax::codemap::{span, dummy_sp}; use syntax::parse; use syntax::visit::{default_simple_visitor, default_visitor}; use syntax::visit::{mk_simple_visitor, mk_vt, visit_crate, visit_item}; @@ -63,7 +63,7 @@ use core::uint::range; use core::uint; use core::vec::{len, push}; use core::vec; -use std::map::HashMap; +use std::oldmap::HashMap; pub struct UniversalQuantificationResult { monotype: t, @@ -135,8 +135,8 @@ pub fn get_base_type_def_id(inference_context: @InferCtxt, return Some(def_id); } _ => { - fail ~"get_base_type() returned a type that wasn't an \ - enum, class, or trait"; + die!(~"get_base_type() returned a type that wasn't an \ + enum, class, or trait"); } } } @@ -417,7 +417,7 @@ pub impl CoherenceChecker { let coherence_info = &self.crate_context.coherence_info; let extension_methods = &coherence_info.extension_methods; - for extension_methods.each_key |trait_id| { + for extension_methods.each_key_ref |&trait_id| { self.check_implementation_coherence_of(trait_id); } } @@ -502,7 +502,7 @@ pub impl CoherenceChecker { } for ty::trait_methods(tcx, trait_did).each |method| { - if provided_method_idents.contains_key(method.ident) { + if provided_method_idents.contains_key_ref(&method.ident) { if !f(method) { break; } @@ -912,7 +912,7 @@ pub impl CoherenceChecker { let tcx = self.crate_context.tcx; let pmm = tcx.provided_methods; - if pmm.contains_key(trait_def_id) { return; } + if pmm.contains_key_ref(&trait_def_id) { return; } debug!("(adding default methods for trait) processing trait"); diff --git a/src/librustc/middle/typeck/collect.rs b/src/librustc/middle/typeck/collect.rs index 3693a2779b8..32d92489188 100644 --- a/src/librustc/middle/typeck/collect.rs +++ b/src/librustc/middle/typeck/collect.rs @@ -326,7 +326,7 @@ pub fn ensure_supertraits(ccx: @crate_ctxt, rp: Option<ty::region_variance>, trait_refs: &[@ast::trait_ref]) { let tcx = ccx.tcx; - if tcx.supertraits.contains_key(local_def(id)) { return; } + if tcx.supertraits.contains_key_ref(&local_def(id)) { return; } let instantiated = dvec::DVec(); for trait_refs.each |trait_ref| { @@ -913,8 +913,8 @@ pub fn ty_of_item(ccx: @crate_ctxt, it: @ast::item) return tpt; } ast::item_impl(*) | ast::item_mod(_) | - ast::item_foreign_mod(_) => fail, - ast::item_mac(*) => fail ~"item macros unimplemented" + ast::item_foreign_mod(_) => die!(), + ast::item_mac(*) => die!(~"item macros unimplemented") } } diff --git a/src/librustc/middle/typeck/infer/mod.rs b/src/librustc/middle/typeck/infer/mod.rs index 2272e99995d..6140390a24e 100644 --- a/src/librustc/middle/typeck/infer/mod.rs +++ b/src/librustc/middle/typeck/infer/mod.rs @@ -280,13 +280,14 @@ use core::result::{Result, Ok, Err, map_vec, map_vec2, iter_vec2}; use core::result; use core::vec; use std::list::Nil; -use std::map::HashMap; -use std::smallintmap; +use std::oldmap::HashMap; +use std::oldsmallintmap; use syntax::ast::{ret_style, purity}; use syntax::ast::{m_const, m_imm, m_mutbl}; use syntax::ast::{unsafe_fn, impure_fn, pure_fn, extern_fn}; use syntax::ast; -use syntax::ast_util::dummy_sp; +use syntax::codemap::dummy_sp; +use syntax::codemap; use syntax::ast_util; use syntax::codemap::span; @@ -353,7 +354,7 @@ pub fn fixup_err_to_str(f: fixup_err) -> ~str { fn new_ValsAndBindings<V:Copy, T:Copy>() -> ValsAndBindings<V, T> { ValsAndBindings { - vals: smallintmap::mk(), + vals: oldsmallintmap::mk(), mut bindings: ~[] } } @@ -389,7 +390,7 @@ pub fn can_mk_subty(cx: @InferCtxt, a: ty::t, b: ty::t) -> ures { debug!("can_mk_subty(%s <: %s)", a.inf_str(cx), b.inf_str(cx)); do indent { do cx.probe { - cx.sub(true, ast_util::dummy_sp()).tys(a, b) + cx.sub(true, codemap::dummy_sp()).tys(a, b) } }.to_ures() } @@ -429,7 +430,7 @@ pub fn can_mk_coercety(cx: @InferCtxt, a: ty::t, b: ty::t) -> ures { debug!("can_mk_coercety(%s -> %s)", a.inf_str(cx), b.inf_str(cx)); do indent { do cx.probe { - let span = ast_util::dummy_sp(); + let span = codemap::dummy_sp(); Coerce(cx.combine_fields(true, span)).tys(a, b) } }.to_ures() diff --git a/src/librustc/middle/typeck/infer/region_inference.rs b/src/librustc/middle/typeck/infer/region_inference.rs index 5d602ab88bb..1a8e25239b3 100644 --- a/src/librustc/middle/typeck/infer/region_inference.rs +++ b/src/librustc/middle/typeck/infer/region_inference.rs @@ -559,7 +559,7 @@ use core::uint; use core::vec; use result::Result; use result::{Ok, Err}; -use std::map::HashMap; +use std::oldmap::HashMap; use std::cell::{Cell, empty_cell}; use std::list::{List, Nil, Cons}; use syntax::codemap::span; @@ -712,11 +712,11 @@ pub impl RegionVarBindings { assert self.var_spans.len() == *vid + 1; self.var_spans.pop(); } - AddConstraint(constraint) => { + AddConstraint(ref constraint) => { self.constraints.remove(constraint); } AddCombination(map, ref regions) => { - map.remove((*regions)); + map.remove(regions); } } } @@ -1226,7 +1226,7 @@ impl RegionVarBindings { fn construct_graph(&self) -> Graph { let num_vars = self.num_vars(); - let num_edges = self.constraints.size(); + let num_edges = self.constraints.len(); let nodes = vec::from_fn(num_vars, |var_idx| { GraphNode { diff --git a/src/librustc/middle/typeck/infer/test.rs b/src/librustc/middle/typeck/infer/test.rs index 5f85d6c4268..416dcbcd30a 100644 --- a/src/librustc/middle/typeck/infer/test.rs +++ b/src/librustc/middle/typeck/infer/test.rs @@ -30,8 +30,8 @@ use std::getopts::groups; use std::getopts::{opt_present}; use std::getopts; use std::getopts; -use std::map::HashMap; -use syntax::ast_util::dummy_sp; +use std::oldmap::HashMap; +use syntax::codemap::dummy_sp; use syntax::parse::parse_crate_from_source_str; use syntax::{ast, attr, parse}; @@ -102,7 +102,7 @@ impl Env { return match search_mod(self, &self.crate.node.module, 0, names) { Some(id) => id, None => { - fail fmt!("No item found: `%s`", str::connect(names, "::")); + die!(fmt!("No item found: `%s`", str::connect(names, "::"))); } }; @@ -155,17 +155,17 @@ impl Env { fn assert_subtype(&self, a: ty::t, b: ty::t) { if !self.is_subtype(a, b) { - fail fmt!("%s is not a subtype of %s, but it should be", + die!(fmt!("%s is not a subtype of %s, but it should be", self.ty_to_str(a), - self.ty_to_str(b)); + self.ty_to_str(b))); } } fn assert_not_subtype(&self, a: ty::t, b: ty::t) { if self.is_subtype(a, b) { - fail fmt!("%s is a subtype of %s, but it shouldn't be", + die!(fmt!("%s is a subtype of %s, but it shouldn't be", self.ty_to_str(a), - self.ty_to_str(b)); + self.ty_to_str(b))); } } @@ -240,7 +240,7 @@ impl Env { fn check_lub(&self, t1: ty::t, t2: ty::t, t_lub: ty::t) { match self.lub().tys(t1, t2) { Err(e) => { - fail fmt!("Unexpected error computing LUB: %?", e) + die!(fmt!("Unexpected error computing LUB: %?", e)) } Ok(t) => { self.assert_eq(t, t_lub); @@ -262,7 +262,7 @@ impl Env { self.ty_to_str(t_glb)); match self.glb().tys(t1, t2) { Err(e) => { - fail fmt!("Unexpected error computing LUB: %?", e) + die!(fmt!("Unexpected error computing LUB: %?", e)) } Ok(t) => { self.assert_eq(t, t_glb); @@ -281,8 +281,8 @@ impl Env { match self.lub().tys(t1, t2) { Err(_) => {} Ok(t) => { - fail fmt!("Unexpected success computing LUB: %?", - self.ty_to_str(t)) + die!(fmt!("Unexpected success computing LUB: %?", + self.ty_to_str(t))) } } } @@ -292,8 +292,8 @@ impl Env { match self.glb().tys(t1, t2) { Err(_) => {} Ok(t) => { - fail fmt!("Unexpected success computing GLB: %?", - self.ty_to_str(t)) + die!(fmt!("Unexpected success computing GLB: %?", + self.ty_to_str(t))) } } } diff --git a/src/librustc/middle/typeck/infer/to_str.rs b/src/librustc/middle/typeck/infer/to_str.rs index e100392bba9..57e05926173 100644 --- a/src/librustc/middle/typeck/infer/to_str.rs +++ b/src/librustc/middle/typeck/infer/to_str.rs @@ -88,7 +88,7 @@ pub impl<V:Vid ToStr, T:InferStr> VarValue<V, T> : InferStr { match *self { Redirect(ref vid) => fmt!("Redirect(%s)", vid.to_str()), Root(ref pt, rk) => fmt!("Root(%s, %s)", pt.inf_str(cx), - uint::to_str(rk, 10u)) + uint::to_str_radix(rk, 10u)) } } } diff --git a/src/librustc/middle/typeck/infer/unify.rs b/src/librustc/middle/typeck/infer/unify.rs index 30329f29945..3b38197c51c 100644 --- a/src/librustc/middle/typeck/infer/unify.rs +++ b/src/librustc/middle/typeck/infer/unify.rs @@ -10,7 +10,7 @@ use core::prelude::*; use core::result; -use std::smallintmap::SmallIntMap; +use std::oldsmallintmap::SmallIntMap; use middle::ty::{Vid, expected_found, IntVarValue}; use middle::ty; diff --git a/src/librustc/middle/typeck/mod.rs b/src/librustc/middle/typeck/mod.rs index ae57cd90bd7..d292f04caa4 100644 --- a/src/librustc/middle/typeck/mod.rs +++ b/src/librustc/middle/typeck/mod.rs @@ -67,13 +67,13 @@ use core::result; use core::vec; use std::list::{List, Nil, Cons}; use std::list; -use std::map::HashMap; -use std::map; -use std::smallintmap; -use syntax::ast::{provided, required, spanned}; +use std::oldmap::HashMap; +use std::oldmap; +use std::oldsmallintmap; +use syntax::ast::{provided, required}; use syntax::ast_map::node_id_to_str; -use syntax::ast_util::{local_def, respan, split_trait_methods}; -use syntax::codemap::span; +use syntax::ast_util::{local_def, split_trait_methods}; +use syntax::codemap::{span, spanned, respan}; use syntax::print::pprust::*; use syntax::visit; use syntax::{ast, ast_util, ast_map}; @@ -212,7 +212,7 @@ pub enum crate_ctxt { // Functions that write types into the node type table pub fn write_ty_to_tcx(tcx: ty::ctxt, node_id: ast::node_id, ty: ty::t) { debug!("write_ty_to_tcx(%d, %s)", node_id, ppaux::ty_to_str(tcx, ty)); - smallintmap::insert(*tcx.node_types, node_id as uint, ty); + oldsmallintmap::insert(*tcx.node_types, node_id as uint, ty); } pub fn write_substs_to_tcx(tcx: ty::ctxt, node_id: ast::node_id, @@ -377,8 +377,8 @@ pub fn check_crate(tcx: ty::ctxt, let ccx = @crate_ctxt_(crate_ctxt__ { trait_map: trait_map, - method_map: map::HashMap(), - vtable_map: map::HashMap(), + method_map: oldmap::HashMap(), + vtable_map: oldmap::HashMap(), coherence_info: @coherence::CoherenceInfo(), tcx: tcx }); diff --git a/src/librustc/rustc.rc b/src/librustc/rustc.rc index 71a4600f4ad..99203d9d6a4 100644 --- a/src/librustc/rustc.rc +++ b/src/librustc/rustc.rc @@ -136,7 +136,7 @@ pub mod lib { use result::{Ok, Err}; use io::ReaderUtil; use std::getopts; -use std::map::HashMap; +use std::oldmap::HashMap; use getopts::{opt_present}; use getopts::groups; use syntax::codemap; @@ -177,7 +177,7 @@ Available lint options: let lint_dict = lint::get_lint_dict(); let mut max_key = 0; - for lint_dict.each_key |k| { max_key = uint::max(k.len(), max_key); } + for lint_dict.each_key_ref |&k| { max_key = uint::max(k.len(), max_key); } fn padded(max: uint, s: &str) -> ~str { str::from_bytes(vec::from_elem(max - s.len(), ' ' as u8)) + s } @@ -186,7 +186,7 @@ Available lint options: padded(max_key, ~"name"), ~"default", ~"meaning")); io::println(fmt!(" %s %7.7s %s\n", padded(max_key, ~"----"), ~"-------", ~"-------")); - for lint_dict.each |k, v| { + for lint_dict.each_ref |&k, &v| { let k = str::replace(k, ~"_", ~"-"); io::println(fmt!(" %s %7.7s %s", padded(max_key, k), @@ -368,7 +368,7 @@ pub fn monitor(+f: fn~(diagnostic::emitter)) { } } // Fail so the process returns a failure code - fail; + die!(); } } } diff --git a/src/librustc/util/common.rs b/src/librustc/util/common.rs index 04cd9c4c03b..85f4ba94e5a 100644 --- a/src/librustc/util/common.rs +++ b/src/librustc/util/common.rs @@ -19,7 +19,7 @@ use syntax; use core::option; use core::str; use core::vec; -use std::map::HashMap; +use std::oldmap::HashMap; pub fn indent<R>(op: fn() -> R) -> R { // Use in conjunction with the log post-processor like `src/etc/indenter` diff --git a/src/librustc/util/ppaux.rs b/src/librustc/util/ppaux.rs index 10d49ad4b0f..2ed2d3ea5d7 100644 --- a/src/librustc/util/ppaux.rs +++ b/src/librustc/util/ppaux.rs @@ -36,7 +36,7 @@ use syntax::ast_map; use core::str; use core::vec; -use std::map::HashMap; +use std::oldmap::HashMap; pub fn note_and_explain_region(cx: ctxt, prefix: ~str, diff --git a/src/librustdoc/astsrv.rs b/src/librustdoc/astsrv.rs index cdfc13e4fa7..dd6e889008f 100644 --- a/src/librustdoc/astsrv.rs +++ b/src/librustdoc/astsrv.rs @@ -22,9 +22,9 @@ use core::prelude::*; use parse; use util; -use core::pipes::stream; -use core::oldcomm; +use core::pipes::{stream, Chan, SharedChan, Port}; use core::vec; +use core::ops::Drop; use rustc::back::link; use rustc::driver::driver; use rustc::driver::session::Session; @@ -32,7 +32,7 @@ use rustc::driver::session::{basic_options, options}; use rustc::driver::session; use rustc::front; use rustc::metadata::filesearch; -use std::map::HashMap; +use std::oldmap::HashMap; use syntax::ast; use syntax::ast_map; use syntax::codemap; @@ -55,11 +55,15 @@ enum Msg { } pub struct Srv { - ch: oldcomm::Chan<Msg> + ch: SharedChan<Msg> } impl Srv: Clone { - fn clone(&self) -> Srv { copy *self } + fn clone(&self) -> Srv { + Srv { + ch: self.ch.clone() + } + } } pub fn from_str<T>(source: ~str, owner: SrvOwner<T>) -> T { @@ -72,18 +76,22 @@ pub fn from_file<T>(file: ~str, owner: SrvOwner<T>) -> T { fn run<T>(owner: SrvOwner<T>, source: ~str, parse: Parser) -> T { + let (po, ch) = stream(); + + do task::spawn { + act(&po, copy source, copy parse); + } + let srv_ = Srv { - ch: do util::spawn_listener |copy source, move parse, po| { - act(po, copy source, copy parse); - } + ch: SharedChan(ch) }; - let res = owner(srv_); - oldcomm::send(srv_.ch, Exit); + let res = owner(srv_.clone()); + srv_.ch.send(Exit); move res } -fn act(po: oldcomm::Port<Msg>, source: ~str, parse: Parser) { +fn act(po: &Port<Msg>, source: ~str, parse: Parser) { let sess = build_session(); let ctxt = build_ctxt( @@ -93,7 +101,7 @@ fn act(po: oldcomm::Port<Msg>, source: ~str, parse: Parser) { let mut keep_going = true; while keep_going { - match oldcomm::recv(po) { + match po.recv() { HandleRequest(f) => { f(ctxt); } @@ -112,7 +120,7 @@ pub fn exec<T:Owned>( let msg = HandleRequest(fn~(move f, ctxt: Ctxt) { ch.send(f(ctxt)) }); - oldcomm::send(srv.ch, move msg); + srv.ch.send(move msg); po.recv() } @@ -156,7 +164,7 @@ fn srv_should_build_ast_map() { let source = ~"fn a() { }"; do from_str(source) |srv| { do exec(srv) |ctxt| { - assert ctxt.ast_map.size() != 0u + assert !ctxt.ast_map.is_empty() }; } } diff --git a/src/librustdoc/attr_pass.rs b/src/librustdoc/attr_pass.rs index f3826af6cae..0e70900520d 100644 --- a/src/librustdoc/attr_pass.rs +++ b/src/librustdoc/attr_pass.rs @@ -31,7 +31,7 @@ use core::option; use core::vec; use syntax::ast; use syntax::ast_map; -use std::map::HashMap; +use std::oldmap::HashMap; use std::par; pub fn mk_pass() -> Pass { @@ -46,6 +46,7 @@ pub fn run( doc: doc::Doc ) -> doc::Doc { let fold = Fold { + ctxt: srv.clone(), fold_crate: fold_crate, fold_item: fold_item, fold_enum: fold_enum, @@ -61,7 +62,7 @@ fn fold_crate( doc: doc::CrateDoc ) -> doc::CrateDoc { - let srv = fold.ctxt; + let srv = fold.ctxt.clone(); let doc = fold::default_seq_fold_crate(fold, doc); let attrs = do astsrv::exec(srv) |ctxt| { @@ -92,7 +93,7 @@ fn fold_item( doc: doc::ItemDoc ) -> doc::ItemDoc { - let srv = fold.ctxt; + let srv = fold.ctxt.clone(); let doc = fold::default_seq_fold_item(fold, doc); let desc = if doc.id == ast::crate_node_id { @@ -118,7 +119,7 @@ fn parse_item_attrs<T:Owned>( let attrs = match ctxt.ast_map.get(id) { ast_map::node_item(item, _) => copy item.attrs, ast_map::node_foreign_item(item, _, _) => copy item.attrs, - _ => fail ~"parse_item_attrs: not an item" + _ => die!(~"parse_item_attrs: not an item") }; parse_attrs(attrs) } @@ -159,16 +160,16 @@ fn fold_enum( doc: doc::EnumDoc ) -> doc::EnumDoc { - let srv = fold.ctxt; + let srv = fold.ctxt.clone(); let doc_id = doc.id(); let doc = fold::default_seq_fold_enum(fold, doc); doc::EnumDoc { - variants: do par::map(doc.variants) |variant| { + variants: do vec::map(doc.variants) |variant| { let variant = copy *variant; let desc = { let variant = copy variant; - do astsrv::exec(srv) |ctxt| { + do astsrv::exec(srv.clone()) |ctxt| { match ctxt.ast_map.get(doc_id) { ast_map::node_item(@ast::item { node: ast::item_enum(ref enum_definition, _), _ @@ -182,9 +183,9 @@ fn fold_enum( copy ast_variant.node.attrs) } _ => { - fail fmt!("Enum variant %s has id that's \ + die!(fmt!("Enum variant %s has id that's \ not bound to an enum item", - variant.name) + variant.name)) } } } @@ -216,7 +217,7 @@ fn fold_trait( fold: &fold::Fold<astsrv::Srv>, doc: doc::TraitDoc ) -> doc::TraitDoc { - let srv = fold.ctxt; + let srv = fold.ctxt.clone(); let doc = fold::default_seq_fold_trait(fold, doc); doc::TraitDoc { @@ -257,7 +258,7 @@ fn merge_method_attrs( attr_parser::parse_desc(copy method.attrs)) }) } - _ => fail ~"unexpected item" + _ => die!(~"unexpected item") } }; @@ -293,7 +294,7 @@ fn fold_impl( fold: &fold::Fold<astsrv::Srv>, doc: doc::ImplDoc ) -> doc::ImplDoc { - let srv = fold.ctxt; + let srv = fold.ctxt.clone(); let doc = fold::default_seq_fold_impl(fold, doc); doc::ImplDoc { @@ -328,8 +329,8 @@ mod test { pub fn mk_doc(source: ~str) -> doc::Doc { do astsrv::from_str(copy source) |srv| { - let doc = extract::from_srv(srv, ~""); - run(srv, doc) + let doc = extract::from_srv(srv.clone(), ~""); + run(srv.clone(), doc) } } } diff --git a/src/librustdoc/demo.rs b/src/librustdoc/demo.rs index 2d3e84b319e..ff6b745612d 100644 --- a/src/librustdoc/demo.rs +++ b/src/librustdoc/demo.rs @@ -71,7 +71,7 @@ fn take_my_order_please( * This function is full of fail */ - fail; + die!(); } mod fortress_of_solitude { @@ -192,6 +192,6 @@ impl OmNomNomy: TheShunnedHouse { } fn construct(&self) -> bool { - fail; + die!(); } } diff --git a/src/librustdoc/desc_to_brief_pass.rs b/src/librustdoc/desc_to_brief_pass.rs index 6b04903601c..225b62f72cb 100644 --- a/src/librustdoc/desc_to_brief_pass.rs +++ b/src/librustdoc/desc_to_brief_pass.rs @@ -111,9 +111,9 @@ pub mod test { pub fn mk_doc(source: ~str) -> doc::Doc { do astsrv::from_str(copy source) |srv| { - let doc = extract::from_srv(srv, ~""); - let doc = (attr_pass::mk_pass().f)(srv, doc); - run(srv, doc) + let doc = extract::from_srv(srv.clone(), ~""); + let doc = (attr_pass::mk_pass().f)(srv.clone(), doc); + run(srv.clone(), doc) } } } diff --git a/src/librustdoc/extract.rs b/src/librustdoc/extract.rs index de336d9e07e..fc572e3da2c 100644 --- a/src/librustdoc/extract.rs +++ b/src/librustdoc/extract.rs @@ -322,7 +322,8 @@ fn structdoc_from_struct( fields: do struct_def.fields.map |field| { match field.node.kind { ast::named_field(ident, _, _) => to_str(ident), - ast::unnamed_field => fail ~"what is an unnamed struct field?" + ast::unnamed_field => die!( + ~"what is an unnamed struct field?") } }, sig: None diff --git a/src/librustdoc/fold.rs b/src/librustdoc/fold.rs index e85f8595a5a..c93d9f3d7c1 100644 --- a/src/librustdoc/fold.rs +++ b/src/librustdoc/fold.rs @@ -193,11 +193,10 @@ pub fn default_any_fold_mod<T:Owned Clone>( fold: &Fold<T>, doc: doc::ModDoc ) -> doc::ModDoc { - let fold_copy = fold.clone(); doc::ModDoc { item: (fold.fold_item)(fold, copy doc.item), - items: par::map(doc.items, |ItemTag, move fold_copy| { - fold_ItemTag(&fold_copy, copy *ItemTag) + items: vec::map(doc.items, |ItemTag| { + fold_ItemTag(fold, copy *ItemTag) }), .. doc } @@ -220,11 +219,10 @@ pub fn default_par_fold_mod<T:Owned Clone>( fold: &Fold<T>, doc: doc::ModDoc ) -> doc::ModDoc { - let fold_copy = fold.clone(); doc::ModDoc { item: (fold.fold_item)(fold, copy doc.item), - items: par::map(doc.items, |ItemTag, move fold_copy| { - fold_ItemTag(&fold_copy, copy *ItemTag) + items: vec::map(doc.items, |ItemTag| { + fold_ItemTag(fold, copy *ItemTag) }), .. doc } @@ -234,11 +232,10 @@ pub fn default_any_fold_nmod<T:Owned Clone>( fold: &Fold<T>, doc: doc::NmodDoc ) -> doc::NmodDoc { - let fold_copy = fold.clone(); doc::NmodDoc { item: (fold.fold_item)(fold, copy doc.item), - fns: par::map(doc.fns, |FnDoc, move fold_copy| { - (fold_copy.fold_fn)(&fold_copy, copy *FnDoc) + fns: vec::map(doc.fns, |FnDoc| { + (fold.fold_fn)(fold, copy *FnDoc) }), .. doc } @@ -261,11 +258,10 @@ pub fn default_par_fold_nmod<T:Owned Clone>( fold: &Fold<T>, doc: doc::NmodDoc ) -> doc::NmodDoc { - let fold_copy = fold.clone(); doc::NmodDoc { item: (fold.fold_item)(fold, copy doc.item), - fns: par::map(doc.fns, |FnDoc, move fold_copy| { - (fold_copy.fold_fn)(&fold_copy, copy *FnDoc) + fns: vec::map(doc.fns, |FnDoc| { + (fold.fold_fn)(fold, copy *FnDoc) }), .. doc } diff --git a/src/librustdoc/markdown_index_pass.rs b/src/librustdoc/markdown_index_pass.rs index c5db7685080..776d2fe9083 100644 --- a/src/librustdoc/markdown_index_pass.rs +++ b/src/librustdoc/markdown_index_pass.rs @@ -274,11 +274,11 @@ mod test { output_style: output_style, .. config::default_config(&Path("whatever")) }; - let doc = extract::from_srv(srv, ~""); - let doc = (attr_pass::mk_pass().f)(srv, doc); - let doc = (desc_to_brief_pass::mk_pass().f)(srv, doc); - let doc = (path_pass::mk_pass().f)(srv, doc); - run(srv, doc, config) + let doc = extract::from_srv(srv.clone(), ~""); + let doc = (attr_pass::mk_pass().f)(srv.clone(), doc); + let doc = (desc_to_brief_pass::mk_pass().f)(srv.clone(), doc); + let doc = (path_pass::mk_pass().f)(srv.clone(), doc); + run(srv.clone(), doc, config) } } } diff --git a/src/librustdoc/markdown_pass.rs b/src/librustdoc/markdown_pass.rs index 359d0097165..fc13af8a221 100644 --- a/src/librustdoc/markdown_pass.rs +++ b/src/librustdoc/markdown_pass.rs @@ -35,16 +35,17 @@ use trim_pass; use unindent_pass; use core::iter; -use core::oldcomm; use core::str; use core::vec; use std::par; +use std::cell::Cell; use syntax; pub fn mk_pass(writer_factory: WriterFactory) -> Pass { + let writer_factory = Cell(writer_factory); let f = fn~(move writer_factory, srv: astsrv::Srv, doc: doc::Doc) -> doc::Doc { - run(srv, doc, copy writer_factory) + run(srv, doc, writer_factory.take()) }; Pass { @@ -155,7 +156,7 @@ fn should_request_new_writer_for_each_page() { write_markdown(doc, move writer_factory); // We expect two pages to have been written for iter::repeat(2) { - oldcomm::recv(po); + po.recv(); } } @@ -186,7 +187,7 @@ fn should_write_title_for_each_page() { let doc = (page_pass::mk_pass(config::DocPerMod).f)(srv, doc); write_markdown(doc, move writer_factory); for iter::repeat(2) { - let (page, markdown) = oldcomm::recv(po); + let (page, markdown) = po.recv(); match page { doc::CratePage(_) => { assert str::contains(markdown, ~"% Crate core"); @@ -331,7 +332,7 @@ fn should_write_full_path_to_mod() { assert str::contains(markdown, ~"# Module `a::b::c`"); } -fn write_oldcommon( +fn write_common( ctxt: &Ctxt, desc: Option<~str>, sections: &[doc::Section] @@ -380,7 +381,7 @@ fn write_mod_contents( ctxt: &Ctxt, doc: doc::ModDoc ) { - write_oldcommon(ctxt, doc.desc(), doc.sections()); + write_common(ctxt, doc.desc(), doc.sections()); if doc.index.is_some() { write_index(ctxt, (&doc.index).get()); } @@ -483,7 +484,7 @@ fn should_write_index_for_foreign_mods() { } fn write_nmod(ctxt: &Ctxt, doc: doc::NmodDoc) { - write_oldcommon(ctxt, doc.desc(), doc.sections()); + write_common(ctxt, doc.desc(), doc.sections()); if doc.index.is_some() { write_index(ctxt, (&doc.index).get()); } @@ -534,7 +535,7 @@ fn write_fnlike( sections: &[doc::Section] ) { write_sig(ctxt, sig); - write_oldcommon(ctxt, desc, sections); + write_common(ctxt, desc, sections); } fn write_sig(ctxt: &Ctxt, sig: Option<~str>) { @@ -543,7 +544,7 @@ fn write_sig(ctxt: &Ctxt, sig: Option<~str>) { ctxt.w.write_line(code_block_indent(sig)); ctxt.w.write_line(~""); } - None => fail ~"unimplemented" + None => die!(~"unimplemented") } } @@ -603,7 +604,7 @@ fn write_const( doc: doc::ConstDoc ) { write_sig(ctxt, copy doc.sig); - write_oldcommon(ctxt, doc.desc(), doc.sections()); + write_common(ctxt, doc.desc(), doc.sections()); } #[test] @@ -624,7 +625,7 @@ fn write_enum( ctxt: &Ctxt, doc: doc::EnumDoc ) { - write_oldcommon(ctxt, doc.desc(), doc.sections()); + write_common(ctxt, doc.desc(), doc.sections()); write_variants(ctxt, doc.variants); } @@ -705,7 +706,7 @@ fn should_write_variant_list_with_signatures() { } fn write_trait(ctxt: &Ctxt, doc: doc::TraitDoc) { - write_oldcommon(ctxt, doc.desc(), doc.sections()); + write_common(ctxt, doc.desc(), doc.sections()); write_methods(ctxt, doc.methods); } @@ -753,7 +754,7 @@ fn should_write_trait_method_signature() { } fn write_impl(ctxt: &Ctxt, doc: doc::ImplDoc) { - write_oldcommon(ctxt, doc.desc(), doc.sections()); + write_common(ctxt, doc.desc(), doc.sections()); write_methods(ctxt, doc.methods); } @@ -795,7 +796,7 @@ fn write_type( doc: doc::TyDoc ) { write_sig(ctxt, copy doc.sig); - write_oldcommon(ctxt, doc.desc(), doc.sections()); + write_common(ctxt, doc.desc(), doc.sections()); } #[test] @@ -822,7 +823,7 @@ fn write_struct( doc: doc::StructDoc ) { write_sig(ctxt, copy doc.sig); - write_oldcommon(ctxt, doc.desc(), doc.sections()); + write_common(ctxt, doc.desc(), doc.sections()); } #[test] @@ -848,7 +849,6 @@ mod test { use tystr_pass; use unindent_pass; - use core::oldcomm; use core::path::Path; use core::str; @@ -867,25 +867,26 @@ mod test { .. config::default_config(&Path("whatever")) }; - let doc = extract::from_srv(srv, ~""); + let doc = extract::from_srv(srv.clone(), ~""); debug!("doc (extract): %?", doc); - let doc = (tystr_pass::mk_pass().f)(srv, doc); + let doc = (tystr_pass::mk_pass().f)(srv.clone(), doc); debug!("doc (tystr): %?", doc); - let doc = (path_pass::mk_pass().f)(srv, doc); + let doc = (path_pass::mk_pass().f)(srv.clone(), doc); debug!("doc (path): %?", doc); - let doc = (attr_pass::mk_pass().f)(srv, doc); + let doc = (attr_pass::mk_pass().f)(srv.clone(), doc); debug!("doc (attr): %?", doc); - let doc = (desc_to_brief_pass::mk_pass().f)(srv, doc); + let doc = (desc_to_brief_pass::mk_pass().f)(srv.clone(), doc); debug!("doc (desc_to_brief): %?", doc); - let doc = (unindent_pass::mk_pass().f)(srv, doc); + let doc = (unindent_pass::mk_pass().f)(srv.clone(), doc); debug!("doc (unindent): %?", doc); - let doc = (sectionalize_pass::mk_pass().f)(srv, doc); + let doc = (sectionalize_pass::mk_pass().f)(srv.clone(), doc); debug!("doc (trim): %?", doc); - let doc = (trim_pass::mk_pass().f)(srv, doc); + let doc = (trim_pass::mk_pass().f)(srv.clone(), doc); debug!("doc (sectionalize): %?", doc); - let doc = (markdown_index_pass::mk_pass(config).f)(srv, doc); + let doc = (markdown_index_pass::mk_pass(config).f)( + srv.clone(), doc); debug!("doc (index): %?", doc); - (srv, doc) + (srv.clone(), doc) } } @@ -899,7 +900,7 @@ mod test { ) -> ~str { let (writer_factory, po) = markdown_writer::future_writer_factory(); write_markdown(doc, move writer_factory); - return oldcomm::recv(po).second(); + return po.recv().second(); } pub fn write_markdown_str_srv( @@ -909,7 +910,7 @@ mod test { let (writer_factory, po) = markdown_writer::future_writer_factory(); let pass = mk_pass(move writer_factory); (pass.f)(srv, doc); - return oldcomm::recv(po).second(); + return po.recv().second(); } #[test] diff --git a/src/librustdoc/markdown_writer.rs b/src/librustdoc/markdown_writer.rs index 50e4fd759c4..9b5efb7c90d 100644 --- a/src/librustdoc/markdown_writer.rs +++ b/src/librustdoc/markdown_writer.rs @@ -19,13 +19,13 @@ use pass::Pass; use core::io::ReaderUtil; use core::io; use core::libc; -use core::oldcomm; use core::os; use core::pipes; use core::result; use core::run; use core::str; use core::task; +use core::pipes::*; use std::future; use syntax; @@ -145,7 +145,7 @@ fn pandoc_writer( if status != 0 { error!("pandoc-out: %s", stdout); error!("pandoc-err: %s", stderr); - fail ~"pandoc failed"; + die!(~"pandoc failed"); } } } @@ -156,7 +156,7 @@ fn readclose(fd: libc::c_int) -> ~str { let file = os::fdopen(fd); let reader = io::FILE_reader(file, false); let buf = io::with_bytes_writer(|writer| { - let mut bytes = [mut 0, ..4096]; + let mut bytes = [0, ..4096]; while !reader.eof() { let nread = reader.read(bytes, bytes.len()); writer.write(bytes.view(0, nread)); @@ -168,12 +168,8 @@ fn readclose(fd: libc::c_int) -> ~str { } fn generic_writer(process: fn~(markdown: ~str)) -> Writer { - let (setup_po, setup_ch) = pipes::stream(); + let (po, ch) = stream::<WriteInstr>(); do task::spawn |move process, move setup_ch| { - let po: oldcomm::Port<WriteInstr> = oldcomm::Port(); - let ch = oldcomm::Chan(&po); - setup_ch.send(ch); - let mut markdown = ~""; let mut keep_going = true; while keep_going { @@ -184,10 +180,8 @@ fn generic_writer(process: fn~(markdown: ~str)) -> Writer { } process(move markdown); }; - let ch = setup_po.recv(); - fn~(instr: WriteInstr) { - oldcomm::send(ch, instr); + ch.send(instr); } } @@ -279,8 +273,8 @@ mod test { pub fn mk_doc(name: ~str, source: ~str) -> doc::Doc { do astsrv::from_str(source) |srv| { - let doc = extract::from_srv(srv, copy name); - let doc = (path_pass::mk_pass().f)(srv, doc); + let doc = extract::from_srv(srv.clone(), copy name); + let doc = (path_pass::mk_pass().f)(srv.clone(), doc); doc } } @@ -293,21 +287,22 @@ fn write_file(path: &Path, s: ~str) { result::Ok(writer) => { writer.write_str(s); } - result::Err(e) => fail e + result::Err(e) => die!(e) } } pub fn future_writer_factory( -) -> (WriterFactory, oldcomm::Port<(doc::Page, ~str)>) { - let markdown_po = oldcomm::Port(); - let markdown_ch = oldcomm::Chan(&markdown_po); +) -> (WriterFactory, Port<(doc::Page, ~str)>) { + let (markdown_po, markdown_ch) = stream(); + let markdown_ch = SharedChan(markdown_ch); let writer_factory = fn~(page: doc::Page) -> Writer { let (writer_po, writer_ch) = pipes::stream(); + let markdown_ch = markdown_ch.clone(); do task::spawn |move writer_ch| { let (writer, future) = future_writer(); writer_ch.send(move writer); let s = future.get(); - oldcomm::send(markdown_ch, (copy page, s)); + markdown_ch.send((copy page, s)); } writer_po.recv() }; diff --git a/src/librustdoc/page_pass.rs b/src/librustdoc/page_pass.rs index 1649a7ee823..c8509826fdb 100644 --- a/src/librustdoc/page_pass.rs +++ b/src/librustdoc/page_pass.rs @@ -28,9 +28,9 @@ use sort_pass; use util::NominalOp; use util; -use core::oldcomm; use core::option; use core::vec; +use core::pipes::*; use syntax::ast; pub fn mk_pass(output_style: config::OutputStyle) -> Pass { @@ -52,24 +52,26 @@ pub fn run( return doc; } - let (result_port, page_chan) = do util::spawn_conversation - |page_port, result_chan| { - oldcomm::send(result_chan, make_doc_from_pages(page_port)); + let (result_port, result_chan) = stream(); + let (page_port, page_chan) = stream(); + let page_chan = SharedChan(page_chan); + do task::spawn { + result_chan.send(make_doc_from_pages(&page_port)); }; find_pages(doc, page_chan); - oldcomm::recv(result_port) + result_port.recv() } -type PagePort = oldcomm::Port<Option<doc::Page>>; -type PageChan = oldcomm::Chan<Option<doc::Page>>; +type PagePort = Port<Option<doc::Page>>; +type PageChan = SharedChan<Option<doc::Page>>; type NominalPageChan = NominalOp<PageChan>; -fn make_doc_from_pages(page_port: PagePort) -> doc::Doc { +fn make_doc_from_pages(page_port: &PagePort) -> doc::Doc { let mut pages = ~[]; loop { - let val = oldcomm::recv(page_port); + let val = page_port.recv(); if val.is_some() { pages += ~[option::unwrap(move val)]; } else { @@ -83,14 +85,15 @@ fn make_doc_from_pages(page_port: PagePort) -> doc::Doc { fn find_pages(doc: doc::Doc, page_chan: PageChan) { let fold = Fold { + ctxt: NominalOp { op: page_chan.clone() }, fold_crate: fold_crate, fold_mod: fold_mod, fold_nmod: fold_nmod, - .. fold::default_any_fold(NominalOp { op: page_chan }) + .. fold::default_any_fold(NominalOp { op: page_chan.clone() }) }; (fold.fold_doc)(&fold, copy doc); - oldcomm::send(page_chan, None); + page_chan.send(None); } fn fold_crate( @@ -105,7 +108,7 @@ fn fold_crate( .. copy doc }); - oldcomm::send(fold.ctxt.op, Some(page)); + fold.ctxt.op.send(Some(page)); doc } @@ -121,7 +124,7 @@ fn fold_mod( let doc = strip_mod(copy doc); let page = doc::ItemPage(doc::ModTag(doc)); - oldcomm::send(fold.ctxt.op, Some(page)); + fold.ctxt.op.send(Some(page)); } doc @@ -146,7 +149,7 @@ fn fold_nmod( ) -> doc::NmodDoc { let doc = fold::default_seq_fold_nmod(fold, doc); let page = doc::ItemPage(doc::NmodTag(copy doc)); - oldcomm::send(fold.ctxt.op, Some(page)); + fold.ctxt.op.send(Some(page)); return doc; } @@ -196,8 +199,8 @@ mod test { source: ~str ) -> doc::Doc { do astsrv::from_str(copy source) |srv| { - let doc = extract::from_srv(srv, ~""); - run(srv, doc, output_style) + let doc = extract::from_srv(srv.clone(), ~""); + run(srv.clone(), doc, output_style) } } diff --git a/src/librustdoc/pass.rs b/src/librustdoc/pass.rs index afd93175c9b..91e3264db1c 100644 --- a/src/librustdoc/pass.rs +++ b/src/librustdoc/pass.rs @@ -33,7 +33,7 @@ pub fn run_passes( log(debug, fmt!("pass #%d", passno)); passno += 1; do time(copy pass.name) { - (pass.f)(srv, copy doc) + (pass.f)(srv.clone(), copy doc) } } } @@ -90,7 +90,7 @@ fn test_run_passes() { f: pass2 } ]; - let doc = extract::from_srv(srv, ~"one"); + let doc = extract::from_srv(srv.clone(), ~"one"); let doc = run_passes(srv, doc, passes); assert doc.cratemod().name() == ~"onetwothree"; } diff --git a/src/librustdoc/path_pass.rs b/src/librustdoc/path_pass.rs index 9c781c30dbc..165ab989a2f 100644 --- a/src/librustdoc/path_pass.rs +++ b/src/librustdoc/path_pass.rs @@ -35,7 +35,12 @@ struct Ctxt { } impl Ctxt: Clone { - fn clone(&self) -> Ctxt { copy *self } + fn clone(&self) -> Ctxt { + Ctxt { + srv: self.srv.clone(), + path: copy self.path + } + } } #[allow(non_implicitly_copyable_typarams)] @@ -45,6 +50,7 @@ fn run(srv: astsrv::Srv, doc: doc::Doc) -> doc::Doc { mut path: ~[] }; let fold = Fold { + ctxt: ctxt.clone(), fold_item: fold_item, fold_mod: fold_mod, fold_nmod: fold_nmod, @@ -89,8 +95,8 @@ fn fold_nmod(fold: &fold::Fold<Ctxt>, doc: doc::NmodDoc) -> doc::NmodDoc { fn should_record_mod_paths() { let source = ~"mod a { mod b { mod c { } } mod d { mod e { } } }"; do astsrv::from_str(source) |srv| { - let doc = extract::from_srv(srv, ~""); - let doc = run(srv, doc); + let doc = extract::from_srv(srv.clone(), ~""); + let doc = run(srv.clone(), doc); assert doc.cratemod().mods()[0].mods()[0].mods()[0].path() == ~[~"a", ~"b"]; assert doc.cratemod().mods()[0].mods()[1].mods()[0].path() @@ -102,8 +108,8 @@ fn should_record_mod_paths() { fn should_record_fn_paths() { let source = ~"mod a { fn b() { } }"; do astsrv::from_str(source) |srv| { - let doc = extract::from_srv(srv, ~""); - let doc = run(srv, doc); + let doc = extract::from_srv(srv.clone(), ~""); + let doc = run(srv.clone(), doc); assert doc.cratemod().mods()[0].fns()[0].path() == ~[~"a"]; } } @@ -112,8 +118,8 @@ fn should_record_fn_paths() { fn should_record_foreign_mod_paths() { let source = ~"mod a { extern mod b { } }"; do astsrv::from_str(source) |srv| { - let doc = extract::from_srv(srv, ~""); - let doc = run(srv, doc); + let doc = extract::from_srv(srv.clone(), ~""); + let doc = run(srv.clone(), doc); assert doc.cratemod().mods()[0].nmods()[0].path() == ~[~"a"]; } } @@ -122,8 +128,8 @@ fn should_record_foreign_mod_paths() { fn should_record_foreign_fn_paths() { let source = ~"extern mod a { fn b(); }"; do astsrv::from_str(source) |srv| { - let doc = extract::from_srv(srv, ~""); - let doc = run(srv, doc); + let doc = extract::from_srv(srv.clone(), ~""); + let doc = run(srv.clone(), doc); assert doc.cratemod().nmods()[0].fns[0].path() == ~[~"a"]; } } diff --git a/src/librustdoc/prune_hidden_pass.rs b/src/librustdoc/prune_hidden_pass.rs index 9a9ec19b7db..f039bb74583 100644 --- a/src/librustdoc/prune_hidden_pass.rs +++ b/src/librustdoc/prune_hidden_pass.rs @@ -19,7 +19,7 @@ use fold; use pass::Pass; use core::vec; -use std::map::HashMap; +use std::oldmap::HashMap; pub fn mk_pass() -> Pass { Pass { @@ -30,6 +30,7 @@ pub fn mk_pass() -> Pass { pub fn run(srv: astsrv::Srv, doc: doc::Doc) -> doc::Doc { let fold = Fold { + ctxt: srv.clone(), fold_mod: fold_mod, .. fold::default_any_fold(srv) }; @@ -44,7 +45,7 @@ fn fold_mod( doc::ModDoc { items: do doc.items.filtered |ItemTag| { - !is_hidden(fold.ctxt, ItemTag.item()) + !is_hidden(fold.ctxt.clone(), ItemTag.item()) }, .. doc } @@ -78,8 +79,8 @@ pub mod test { pub fn mk_doc(source: ~str) -> doc::Doc { do astsrv::from_str(copy source) |srv| { - let doc = extract::from_srv(srv, ~""); - run(srv, doc) + let doc = extract::from_srv(srv.clone(), ~""); + run(srv.clone(), doc) } } } diff --git a/src/librustdoc/prune_private_pass.rs b/src/librustdoc/prune_private_pass.rs index 94098e4df86..4b47b71449a 100644 --- a/src/librustdoc/prune_private_pass.rs +++ b/src/librustdoc/prune_private_pass.rs @@ -31,6 +31,7 @@ pub fn mk_pass() -> Pass { pub fn run(srv: astsrv::Srv, doc: doc::Doc) -> doc::Doc { let fold = Fold { + ctxt: srv.clone(), fold_mod: fold_mod, .. fold::default_any_fold(srv) }; @@ -45,7 +46,7 @@ fn fold_mod( doc::ModDoc { items: doc.items.filtered(|ItemTag| { - is_visible(fold.ctxt, ItemTag.item()) + is_visible(fold.ctxt.clone(), ItemTag.item()) }), .. doc } @@ -82,8 +83,8 @@ pub mod test { pub fn mk_doc(source: ~str) -> doc::Doc { do astsrv::from_str(copy source) |srv| { - let doc = extract::from_srv(srv, ~""); - run(srv, doc) + let doc = extract::from_srv(srv.clone(), ~""); + run(srv.clone(), doc) } } } diff --git a/src/librustdoc/rustdoc.rc b/src/librustdoc/rustdoc.rc index ab17d829c69..b3e9c43e87a 100644 --- a/src/librustdoc/rustdoc.rc +++ b/src/librustdoc/rustdoc.rc @@ -94,14 +94,14 @@ fn run(config: Config) { // Just time how long it takes for the AST to become available do time(~"wait_ast") { - do astsrv::exec(srv) |_ctxt| { } + do astsrv::exec(srv.clone()) |_ctxt| { } }; // Extract the initial doc tree from the AST. This contains // just names and node ids. let doc = time(~"extract", || { let default_name = copy source_file; - extract::from_srv(srv, default_name.to_str()) + extract::from_srv(srv.clone(), default_name.to_str()) }); // Refine and publish the document diff --git a/src/librustdoc/sectionalize_pass.rs b/src/librustdoc/sectionalize_pass.rs index 2e04f416176..d6455c4c783 100644 --- a/src/librustdoc/sectionalize_pass.rs +++ b/src/librustdoc/sectionalize_pass.rs @@ -261,9 +261,9 @@ pub mod test { pub fn mk_doc(source: ~str) -> doc::Doc { do astsrv::from_str(copy source) |srv| { - let doc = extract::from_srv(srv, ~""); - let doc = (attr_pass::mk_pass().f)(srv, doc); - run(srv, doc) + let doc = extract::from_srv(srv.clone(), ~""); + let doc = (attr_pass::mk_pass().f)(srv.clone(), doc); + run(srv.clone(), doc) } } } diff --git a/src/librustdoc/sort_item_name_pass.rs b/src/librustdoc/sort_item_name_pass.rs index 9a777d79345..946be67ee10 100644 --- a/src/librustdoc/sort_item_name_pass.rs +++ b/src/librustdoc/sort_item_name_pass.rs @@ -28,8 +28,8 @@ pub fn mk_pass() -> Pass { fn test() { let source = ~"mod z { } fn y() { }"; do astsrv::from_str(source) |srv| { - let doc = extract::from_srv(srv, ~""); - let doc = (mk_pass().f)(srv, doc); + let doc = extract::from_srv(srv.clone(), ~""); + let doc = (mk_pass().f)(srv.clone(), doc); assert doc.cratemod().items[0].name() == ~"y"; assert doc.cratemod().items[1].name() == ~"z"; } diff --git a/src/librustdoc/sort_item_type_pass.rs b/src/librustdoc/sort_item_type_pass.rs index ad737567d01..646dc12d336 100644 --- a/src/librustdoc/sort_item_type_pass.rs +++ b/src/librustdoc/sort_item_type_pass.rs @@ -55,8 +55,8 @@ fn test() { type itype = int; \ struct istruct { f: () }"; do astsrv::from_str(source) |srv| { - let doc = extract::from_srv(srv, ~""); - let doc = (mk_pass().f)(srv, doc); + let doc = extract::from_srv(srv.clone(), ~""); + let doc = (mk_pass().f)(srv.clone(), doc); assert doc.cratemod().items[0].name() == ~"iconst"; assert doc.cratemod().items[1].name() == ~"itype"; assert doc.cratemod().items[2].name() == ~"ienum"; diff --git a/src/librustdoc/sort_pass.rs b/src/librustdoc/sort_pass.rs index dcc4902c9b8..2792508483c 100644 --- a/src/librustdoc/sort_pass.rs +++ b/src/librustdoc/sort_pass.rs @@ -69,8 +69,8 @@ fn test() { let source = ~"mod z { mod y { } fn x() { } } mod w { }"; do astsrv::from_str(source) |srv| { - let doc = extract::from_srv(srv, ~""); - let doc = (mk_pass(~"", name_lteq).f)(srv, doc); + let doc = extract::from_srv(srv.clone(), ~""); + let doc = (mk_pass(~"", name_lteq).f)(srv.clone(), doc); assert doc.cratemod().mods()[0].name() == ~"w"; assert doc.cratemod().mods()[1].items[0].name() == ~"x"; assert doc.cratemod().mods()[1].items[1].name() == ~"y"; @@ -86,11 +86,11 @@ fn should_be_stable() { let source = ~"mod a { mod b { } } mod c { mod d { } }"; do astsrv::from_str(source) |srv| { - let doc = extract::from_srv(srv, ~""); - let doc = (mk_pass(~"", always_eq).f)(srv, doc); + let doc = extract::from_srv(srv.clone(), ~""); + let doc = (mk_pass(~"", always_eq).f)(srv.clone(), doc); assert doc.cratemod().mods()[0].items[0].name() == ~"b"; assert doc.cratemod().mods()[1].items[0].name() == ~"d"; - let doc = (mk_pass(~"", always_eq).f)(srv, doc); + let doc = (mk_pass(~"", always_eq).f)(srv.clone(), doc); assert doc.cratemod().mods()[0].items[0].name() == ~"b"; assert doc.cratemod().mods()[1].items[0].name() == ~"d"; } diff --git a/src/librustdoc/text_pass.rs b/src/librustdoc/text_pass.rs index d5c4dda6d95..aec8b56341f 100644 --- a/src/librustdoc/text_pass.rs +++ b/src/librustdoc/text_pass.rs @@ -73,7 +73,7 @@ fn fold_item( } fn apply_to_sections( - +op: NominalOp<Op>, + op: NominalOp<Op>, sections: ~[doc::Section] ) -> ~[doc::Section] { par::map(sections, |section, copy op| doc::Section { @@ -306,11 +306,11 @@ mod test { pub fn mk_doc(source: ~str) -> doc::Doc { do astsrv::from_str(copy source) |srv| { - let doc = extract::from_srv(srv, ~""); - let doc = (attr_pass::mk_pass().f)(srv, doc); - let doc = (desc_to_brief_pass::mk_pass().f)(srv, doc); - let doc = (sectionalize_pass::mk_pass().f)(srv, doc); - (mk_pass(~"", |s| str::trim(s) ).f)(srv, doc) + let doc = extract::from_srv(srv.clone(), ~""); + let doc = (attr_pass::mk_pass().f)(srv.clone(), doc); + let doc = (desc_to_brief_pass::mk_pass().f)(srv.clone(), doc); + let doc = (sectionalize_pass::mk_pass().f)(srv.clone(), doc); + (mk_pass(~"", |s| str::trim(s) ).f)(srv.clone(), doc) } } } diff --git a/src/librustdoc/trim_pass.rs b/src/librustdoc/trim_pass.rs index bac69e32848..39557a92e01 100644 --- a/src/librustdoc/trim_pass.rs +++ b/src/librustdoc/trim_pass.rs @@ -45,9 +45,9 @@ mod test { pub fn mk_doc(source: ~str) -> doc::Doc { do astsrv::from_str(copy source) |srv| { - let doc = extract::from_srv(srv, ~""); - let doc = (attr_pass::mk_pass().f)(srv, doc); - (mk_pass().f)(srv, doc) + let doc = extract::from_srv(srv.clone(), ~""); + let doc = (attr_pass::mk_pass().f)(srv.clone(), doc); + (mk_pass().f)(srv.clone(), doc) } } } diff --git a/src/librustdoc/tystr_pass.rs b/src/librustdoc/tystr_pass.rs index 016c554be27..4ab40530cfb 100644 --- a/src/librustdoc/tystr_pass.rs +++ b/src/librustdoc/tystr_pass.rs @@ -22,7 +22,7 @@ use fold; use pass::Pass; use core::vec; -use std::map::HashMap; +use std::oldmap::HashMap; use std::par; use syntax::ast; use syntax::print::pprust; @@ -40,6 +40,7 @@ pub fn run( doc: doc::Doc ) -> doc::Doc { let fold = Fold { + ctxt: srv.clone(), fold_fn: fold_fn, fold_const: fold_const, fold_enum: fold_enum, @@ -57,7 +58,7 @@ fn fold_fn( doc: doc::FnDoc ) -> doc::FnDoc { - let srv = fold.ctxt; + let srv = fold.ctxt.clone(); doc::SimpleItemDoc { sig: get_fn_sig(srv, doc.id()), @@ -79,7 +80,7 @@ fn get_fn_sig(srv: astsrv::Srv, fn_id: doc::AstId) -> Option<~str> { Some(pprust::fun_to_str(*decl, ident, copy *tys, extract::interner())) } - _ => fail ~"get_fn_sig: fn_id not bound to a fn item" + _ => die!(~"get_fn_sig: fn_id not bound to a fn item") } } } @@ -100,7 +101,7 @@ fn fold_const( fold: &fold::Fold<astsrv::Srv>, doc: doc::ConstDoc ) -> doc::ConstDoc { - let srv = fold.ctxt; + let srv = fold.ctxt.clone(); doc::SimpleItemDoc { sig: Some({ @@ -112,7 +113,7 @@ fn fold_const( }, _) => { pprust::ty_to_str(ty, extract::interner()) } - _ => fail ~"fold_const: id not bound to a const item" + _ => die!(~"fold_const: id not bound to a const item") } }}), .. doc @@ -130,13 +131,13 @@ fn fold_enum( doc: doc::EnumDoc ) -> doc::EnumDoc { let doc_id = doc.id(); - let srv = fold.ctxt; + let srv = fold.ctxt.clone(); doc::EnumDoc { - variants: do par::map(doc.variants) |variant| { + variants: do vec::map(doc.variants) |variant| { let sig = { let variant = copy *variant; - do astsrv::exec(srv) |copy variant, ctxt| { + do astsrv::exec(srv.clone()) |copy variant, ctxt| { match ctxt.ast_map.get(doc_id) { ast_map::node_item(@ast::item { node: ast::item_enum(ref enum_definition, _), _ @@ -149,7 +150,7 @@ fn fold_enum( pprust::variant_to_str( ast_variant, extract::interner()) } - _ => fail ~"enum variant not bound to an enum item" + _ => die!(~"enum variant not bound to an enum item") } } }; @@ -174,7 +175,7 @@ fn fold_trait( doc: doc::TraitDoc ) -> doc::TraitDoc { doc::TraitDoc { - methods: merge_methods(fold.ctxt, doc.id(), copy doc.methods), + methods: merge_methods(fold.ctxt.clone(), doc.id(), copy doc.methods), .. doc } } @@ -184,9 +185,9 @@ fn merge_methods( item_id: doc::AstId, docs: ~[doc::MethodDoc] ) -> ~[doc::MethodDoc] { - do par::map(docs) |doc| { + do vec::map(docs) |doc| { doc::MethodDoc { - sig: get_method_sig(srv, item_id, copy doc.name), + sig: get_method_sig(srv.clone(), item_id, copy doc.name), .. copy *doc } } @@ -228,7 +229,7 @@ fn get_method_sig( } } } - _ => fail ~"method not found" + _ => die!(~"method not found") } } ast_map::node_item(@ast::item { @@ -245,10 +246,10 @@ fn get_method_sig( extract::interner() )) } - None => fail ~"method not found" + None => die!(~"method not found") } } - _ => fail ~"get_method_sig: item ID not bound to trait or impl" + _ => die!(~"get_method_sig: item ID not bound to trait or impl") } } } @@ -265,7 +266,7 @@ fn fold_impl( doc: doc::ImplDoc ) -> doc::ImplDoc { - let srv = fold.ctxt; + let srv = fold.ctxt.clone(); let (trait_types, self_ty) = { let doc = copy doc; @@ -281,7 +282,7 @@ fn fold_impl( Some(pprust::ty_to_str( self_ty, extract::interner()))) } - _ => fail ~"expected impl" + _ => die!(~"expected impl") } } }; @@ -289,7 +290,7 @@ fn fold_impl( doc::ImplDoc { trait_types: trait_types, self_ty: self_ty, - methods: merge_methods(fold.ctxt, doc.id(), copy doc.methods), + methods: merge_methods(fold.ctxt.clone(), doc.id(), copy doc.methods), .. doc } } @@ -314,7 +315,7 @@ fn should_add_impl_self_ty() { #[test] fn should_add_impl_method_sigs() { - let doc = test::mk_doc(~"impl int { fn a<T>() -> int { fail } }"); + let doc = test::mk_doc(~"impl int { fn a<T>() -> int { die!() } }"); assert doc.cratemod().impls()[0].methods[0].sig == Some(~"fn a<T>() -> int"); } @@ -324,7 +325,7 @@ fn fold_type( doc: doc::TyDoc ) -> doc::TyDoc { - let srv = fold.ctxt; + let srv = fold.ctxt.clone(); doc::SimpleItemDoc { sig: { @@ -344,7 +345,7 @@ fn fold_type( extract::interner()) )) } - _ => fail ~"expected type" + _ => die!(~"expected type") } } }, @@ -362,7 +363,7 @@ fn fold_struct( fold: &fold::Fold<astsrv::Srv>, doc: doc::StructDoc ) -> doc::StructDoc { - let srv = fold.ctxt; + let srv = fold.ctxt.clone(); doc::StructDoc { sig: { @@ -374,7 +375,7 @@ fn fold_struct( Some(pprust::item_to_str(item, extract::interner())) } - _ => fail ~"not an item" + _ => die!(~"not an item") } } }, @@ -395,7 +396,7 @@ fn strip_struct_extra_stuff(item: @ast::item) -> @ast::item { }; ast::item_struct(def, tys) } - _ => fail ~"not a struct" + _ => die!(~"not a struct") }; @ast::item { @@ -434,8 +435,8 @@ pub mod test { pub fn mk_doc(source: ~str) -> doc::Doc { do astsrv::from_str(copy source) |srv| { - let doc = extract::from_srv(srv, ~""); - run(srv, doc) + let doc = extract::from_srv(srv.clone(), ~""); + run(srv.clone(), doc) } } } diff --git a/src/librustdoc/util.rs b/src/librustdoc/util.rs index 23741ed5acf..aa15c104540 100644 --- a/src/librustdoc/util.rs +++ b/src/librustdoc/util.rs @@ -10,7 +10,6 @@ use core::prelude::*; -use core::oldcomm; use core::task; // Just a named container for our op, so it can have impls @@ -21,27 +20,3 @@ pub struct NominalOp<T> { impl<T: Copy> NominalOp<T>: Clone { fn clone(&self) -> NominalOp<T> { copy *self } } - -pub fn spawn_listener<A: Owned>( - f: fn~(oldcomm::Port<A>)) -> oldcomm::Chan<A> { - let setup_po = oldcomm::Port(); - let setup_ch = oldcomm::Chan(&setup_po); - do task::spawn |move f| { - let po = oldcomm::Port(); - let ch = oldcomm::Chan(&po); - oldcomm::send(setup_ch, ch); - f(move po); - } - oldcomm::recv(setup_po) -} - -pub fn spawn_conversation<A: Owned, B: Owned> - (f: fn~(oldcomm::Port<A>, oldcomm::Chan<B>)) - -> (oldcomm::Port<B>, oldcomm::Chan<A>) { - let from_child = oldcomm::Port(); - let to_parent = oldcomm::Chan(&from_child); - let to_child = do spawn_listener |move f, from_parent| { - f(from_parent, to_parent) - }; - (from_child, to_child) -} diff --git a/src/librusti/rusti.rc b/src/librusti/rusti.rc index a8dba459aba..0e551066449 100644 --- a/src/librusti/rusti.rc +++ b/src/librusti/rusti.rc @@ -178,10 +178,10 @@ fn run(repl: Repl, input: ~str) -> Repl { ast::expr_call(_, exprs, _) => { match exprs[0].node { ast::expr_block(blk) => @blk, - _ => fail + _ => die!() } } - _ => fail + _ => die!() }; debug!("recording input into repl history"); record(repl, blk, sess.parse_sess.interner) @@ -320,7 +320,7 @@ fn run_cmd(repl: &mut Repl, _in: io::Reader, _out: io::Writer, let mut end_multiline = false; while (!end_multiline) { match get_line(~"rusti| ") { - None => fail ~"unterminated multiline command :{ .. :}", + None => die!(~"unterminated multiline command :{ .. :}"), Some(line) => { if str::trim(line) == ~":}" { end_multiline = true; diff --git a/src/libstd/arc.rs b/src/libstd/arc.rs index e50245168b1..a8d3f156104 100644 --- a/src/libstd/arc.rs +++ b/src/libstd/arc.rs @@ -221,7 +221,7 @@ pub fn unwrap_mutex_arc<T: Owned>(arc: MutexARC<T>) -> T { let inner = unsafe { unwrap_shared_mutable_state(move x) }; let MutexARCInner { failed: failed, data: data, _ } = move inner; if failed { - fail ~"Can't unwrap poisoned MutexARC - another task failed inside!" + die!(~"Can't unwrap poisoned MutexARC - another task failed inside!") } move data } @@ -232,9 +232,9 @@ pub fn unwrap_mutex_arc<T: Owned>(arc: MutexARC<T>) -> T { fn check_poison(is_mutex: bool, failed: bool) { if failed { if is_mutex { - fail ~"Poisoned MutexARC - another task failed inside!"; + die!(~"Poisoned MutexARC - another task failed inside!"); } else { - fail ~"Poisoned rw_arc - another task failed inside!"; + die!(~"Poisoned rw_arc - another task failed inside!"); } } } @@ -410,7 +410,7 @@ pub fn unwrap_rw_arc<T: Const Owned>(arc: RWARC<T>) -> T { let inner = unsafe { unwrap_shared_mutable_state(move x) }; let RWARCInner { failed: failed, data: data, _ } = move inner; if failed { - fail ~"Can't unwrap poisoned RWARC - another task failed inside!" + die!(~"Can't unwrap poisoned RWARC - another task failed inside!") } move data } diff --git a/src/libstd/arena.rs b/src/libstd/arena.rs index eef84ae2422..3e21a320d44 100644 --- a/src/libstd/arena.rs +++ b/src/libstd/arena.rs @@ -305,6 +305,6 @@ fn test_arena_destructors_fail() { // get freed too. do arena.alloc { @20 }; // Now fail. - fail; + die!(); }; } diff --git a/src/libstd/base64.rs b/src/libstd/base64.rs index a9b57137709..5813e0919d9 100644 --- a/src/libstd/base64.rs +++ b/src/libstd/base64.rs @@ -65,7 +65,7 @@ impl &[u8]: ToBase64 { str::push_char(&mut s, chars[(n >> 6u) & 63u]); str::push_char(&mut s, '='); } - _ => fail ~"Algebra is broken, please alert the math police" + _ => die!(~"Algebra is broken, please alert the math police") } } s @@ -84,7 +84,7 @@ pub trait FromBase64 { impl ~[u8]: FromBase64 { pure fn from_base64() -> ~[u8] { - if self.len() % 4u != 0u { fail ~"invalid base64 length"; } + if self.len() % 4u != 0u { die!(~"invalid base64 length"); } let len = self.len(); let mut padding = 0u; @@ -126,10 +126,10 @@ impl ~[u8]: FromBase64 { r.push(((n >> 10u) & 0xFFu) as u8); return copy r; } - _ => fail ~"invalid base64 padding" + _ => die!(~"invalid base64 padding") } } else { - fail ~"invalid base64 character"; + die!(~"invalid base64 character"); } i += 1u; diff --git a/src/libstd/bigint.rs b/src/libstd/bigint.rs index 4283a7e402b..092a0d18a0f 100644 --- a/src/libstd/bigint.rs +++ b/src/libstd/bigint.rs @@ -88,7 +88,7 @@ impl BigUint : Ord { } impl BigUint : ToStr { - pure fn to_str() -> ~str { self.to_str_radix(10) } + pure fn to_str(&self) -> ~str { self.to_str_radix(10) } } impl BigUint : from_str::FromStr { @@ -245,7 +245,7 @@ impl BigUint : Modulo<BigUint, BigUint> { } impl BigUint : Neg<BigUint> { - pure fn neg(&self) -> BigUint { fail } + pure fn neg(&self) -> BigUint { die!() } } impl BigUint : IntConvertible { @@ -332,7 +332,7 @@ pub impl BigUint { } pure fn divmod(&self, other: &BigUint) -> (BigUint, BigUint) { - if other.is_zero() { fail } + if other.is_zero() { die!() } if self.is_zero() { return (Zero::zero(), Zero::zero()); } if *other == One::one() { return (copy *self, Zero::zero()); } @@ -456,7 +456,7 @@ pub impl BigUint { pure fn fill_concat(v: &[BigDigit], radix: uint, l: uint) -> ~str { if v.is_empty() { return ~"0" } str::trim_left_chars(str::concat(vec::reversed(v).map(|n| { - let s = uint::to_str(*n as uint, radix); + let s = uint::to_str_radix(*n as uint, radix); str::from_chars(vec::from_elem(l - s.len(), '0')) + s })), ['0']) } @@ -523,7 +523,7 @@ priv pure fn get_radix_base(radix: uint) -> (uint, uint) { 14 => (1475789056, 8), 15 => (2562890625, 8), 16 => (4294967296, 8), - _ => fail + _ => die!() } } @@ -547,7 +547,7 @@ priv pure fn get_radix_base(radix: uint) -> (uint, uint) { 14 => (38416, 4), 15 => (50625, 4), 16 => (65536, 4), - _ => fail + _ => die!() } } @@ -605,7 +605,7 @@ impl BigInt : Ord { } impl BigInt : ToStr { - pure fn to_str() -> ~str { self.to_str_radix(10) } + pure fn to_str(&self) -> ~str { self.to_str_radix(10) } } impl BigInt : from_str::FromStr { @@ -797,7 +797,7 @@ pub impl BigInt { let d = BigInt::from_biguint(Plus, d_ui), m = BigInt::from_biguint(Plus, m_ui); match (self.sign, other.sign) { - (_, Zero) => fail, + (_, Zero) => die!(), (Plus, Plus) | (Zero, Plus) => (d, m), (Plus, Minus) | (Zero, Minus) => if m.is_zero() { (-d, Zero::zero()) @@ -828,7 +828,7 @@ pub impl BigInt { let q = BigInt::from_biguint(Plus, q_ui); let r = BigInt::from_biguint(Plus, r_ui); match (self.sign, other.sign) { - (_, Zero) => fail, + (_, Zero) => die!(), (Plus, Plus) | (Zero, Plus) => ( q, r), (Plus, Minus) | (Zero, Minus) => (-q, r), (Minus, Plus) => (-q, -r), @@ -1193,7 +1193,7 @@ mod biguint_tests { ~"2" + str::from_chars(vec::from_elem(bits / 2 - 1, '0')) + "1"), (10, match bits { - 32 => ~"8589934593", 16 => ~"131073", _ => fail + 32 => ~"8589934593", 16 => ~"131073", _ => die!() }), (16, ~"2" + @@ -1210,7 +1210,7 @@ mod biguint_tests { (10, match bits { 32 => ~"55340232229718589441", 16 => ~"12885032961", - _ => fail + _ => die!() }), (16, ~"3" + str::from_chars(vec::from_elem(bits / 4 - 1, '0')) + "2" + @@ -1257,7 +1257,7 @@ mod biguint_tests { fn check(n: uint, s: &str) { let n = factor(n); let ans = match BigUint::from_str_radix(s, 10) { - Some(x) => x, None => fail + Some(x) => x, None => die!() }; assert n == ans; } diff --git a/src/libstd/bitv.rs b/src/libstd/bitv.rs index ec7fc431ab7..d49c2ef95f6 100644 --- a/src/libstd/bitv.rs +++ b/src/libstd/bitv.rs @@ -106,10 +106,10 @@ impl SmallBitv { struct BigBitv { // only mut b/c of clone and lack of other constructor - mut storage: ~[mut uint] + mut storage: ~[uint] } -fn BigBitv(storage: ~[mut uint]) -> BigBitv { +fn BigBitv(storage: ~[uint]) -> BigBitv { BigBitv {storage: move storage} } @@ -233,7 +233,7 @@ pub fn Bitv (nbits: uint, init: bool) -> Bitv { let nelems = nbits/uint_bits + if nbits % uint_bits == 0 {0} else {1}; let elem = if init {!0} else {0}; - let s = cast_to_mut(from_elem(nelems, elem)); + let s = from_elem(nelems, elem); Big(~BigBitv(move s)) }; Bitv {rep: move rep, nbits: nbits} @@ -242,7 +242,7 @@ pub fn Bitv (nbits: uint, init: bool) -> Bitv { priv impl Bitv { fn die() -> ! { - fail ~"Tried to do operation on bit vectors with different sizes"; + die!(~"Tried to do operation on bit vectors with different sizes"); } #[inline(always)] @@ -474,7 +474,7 @@ impl Bitv { * The resulting string has the same length as `self`, and each * character is either '0' or '1'. */ - fn to_str() -> ~str { + fn to_str(&self) -> ~str { let mut rs = ~""; for self.each() |i| { if i { rs += ~"1"; } else { rs += ~"0"; } }; rs @@ -518,7 +518,7 @@ impl Bitv: Clone { Bitv{nbits: self.nbits, rep: Small(~SmallBitv{bits: b.bits})} } Big(ref b) => { - let st = cast_to_mut(from_elem(self.nbits / uint_bits + 1, 0)); + let mut st = from_elem(self.nbits / uint_bits + 1, 0); let len = st.len(); for uint::range(0, len) |i| { st[i] = b.storage[i]; }; Bitv{nbits: self.nbits, rep: Big(~BigBitv{storage: move st})} diff --git a/src/libstd/cell.rs b/src/libstd/cell.rs index d4077e94617..aae84a86957 100644 --- a/src/libstd/cell.rs +++ b/src/libstd/cell.rs @@ -34,7 +34,7 @@ impl<T> Cell<T> { /// Yields the value, failing if the cell is empty. fn take() -> T { if self.is_empty() { - fail ~"attempt to take an empty cell"; + die!(~"attempt to take an empty cell"); } let mut value = None; @@ -45,7 +45,7 @@ impl<T> Cell<T> { /// Returns the value, failing if the cell is full. fn put_back(value: T) { if !self.is_empty() { - fail ~"attempt to put a value back into a full cell"; + die!(~"attempt to put a value back into a full cell"); } self.value = Some(move value); } diff --git a/src/libstd/deque.rs b/src/libstd/deque.rs index 2abd59523a1..2f001ae866c 100644 --- a/src/libstd/deque.rs +++ b/src/libstd/deque.rs @@ -58,7 +58,7 @@ pub fn create<T: Copy>() -> Deque<T> { move rv } fn get<T: Copy>(elts: &DVec<Cell<T>>, i: uint) -> T { - match (*elts).get_elt(i) { Some(move t) => t, _ => fail } + match (*elts).get_elt(i) { Some(move t) => t, _ => die!() } } struct Repr<T> { diff --git a/src/libstd/ebml.rs b/src/libstd/ebml.rs index f93705c0c62..25deaf2a9b5 100644 --- a/src/libstd/ebml.rs +++ b/src/libstd/ebml.rs @@ -104,7 +104,7 @@ pub mod reader { (data[start + 2u] as uint) << 8u | (data[start + 3u] as uint), next: start + 4u}; - } else { error!("vint too big"); fail; } + } else { error!("vint too big"); die!(); } } pub fn Doc(data: @~[u8]) -> Doc { @@ -140,7 +140,7 @@ pub mod reader { Some(d) => d, None => { error!("failed to find block with tag %u", tg); - fail; + die!(); } } } @@ -227,7 +227,8 @@ pub mod reader { self.pos = r_doc.end; let str = doc_as_str(r_doc); if lbl != str { - fail fmt!("Expected label %s but found %s", lbl, str); + die!(fmt!("Expected label %s but found %s", lbl, + str)); } } } @@ -236,7 +237,7 @@ pub mod reader { fn next_doc(exp_tag: EbmlEncoderTag) -> Doc { debug!(". next_doc(exp_tag=%?)", exp_tag); if self.pos >= self.parent.end { - fail ~"no more documents in current node!"; + die!(~"no more documents in current node!"); } let TaggedDoc { tag: r_tag, doc: r_doc } = doc_at(self.parent.data, self.pos); @@ -244,12 +245,12 @@ pub mod reader { copy self.parent.start, copy self.parent.end, copy self.pos, r_tag, r_doc.start, r_doc.end); if r_tag != (exp_tag as uint) { - fail fmt!("expected EBML doc with tag %? but found tag %?", - exp_tag, r_tag); + die!(fmt!("expected EBML doc with tag %? but found tag %?", + exp_tag, r_tag)); } if r_doc.end > self.parent.end { - fail fmt!("invalid EBML, child extends to 0x%x, \ - parent to 0x%x", r_doc.end, self.parent.end); + die!(fmt!("invalid EBML, child extends to 0x%x, \ + parent to 0x%x", r_doc.end, self.parent.end)); } self.pos = r_doc.end; r_doc @@ -291,7 +292,7 @@ pub mod reader { fn read_uint(&self) -> uint { let v = doc_as_u64(self.next_doc(EsUint)); if v > (::core::uint::max_value as u64) { - fail fmt!("uint %? too large for this architecture", v); + die!(fmt!("uint %? too large for this architecture", v)); } v as uint } @@ -303,7 +304,7 @@ pub mod reader { fn read_int(&self) -> int { let v = doc_as_u64(self.next_doc(EsInt)) as i64; if v > (int::max_value as i64) || v < (int::min_value as i64) { - fail fmt!("int %? out of range for this architecture", v); + die!(fmt!("int %? out of range for this architecture", v)); } v as int } @@ -311,14 +312,14 @@ pub mod reader { fn read_bool(&self) -> bool { doc_as_u8(self.next_doc(EsBool)) as bool } - fn read_f64(&self) -> f64 { fail ~"read_f64()"; } - fn read_f32(&self) -> f32 { fail ~"read_f32()"; } - fn read_float(&self) -> float { fail ~"read_float()"; } + fn read_f64(&self) -> f64 { die!(~"read_f64()"); } + fn read_f32(&self) -> f32 { die!(~"read_f32()"); } + fn read_float(&self) -> float { die!(~"read_float()"); } - fn read_char(&self) -> char { fail ~"read_char()"; } + fn read_char(&self) -> char { die!(~"read_char()"); } fn read_owned_str(&self) -> ~str { doc_as_str(self.next_doc(EsStr)) } - fn read_managed_str(&self) -> @str { fail ~"read_managed_str()"; } + fn read_managed_str(&self) -> @str { die!(~"read_managed_str()"); } // Compound types: fn read_owned<T>(&self, f: fn() -> T) -> T { @@ -427,7 +428,7 @@ pub mod writer { n as u8]), 4u => w.write(&[0x10u8 | ((n >> 24_u) as u8), (n >> 16_u) as u8, (n >> 8_u) as u8, n as u8]), - _ => fail fmt!("vint to write too big: %?", n) + _ => die!(fmt!("vint to write too big: %?", n)) }; } @@ -436,7 +437,7 @@ pub mod writer { if n < 0x4000_u { write_sized_vuint(w, n, 2u); return; } if n < 0x200000_u { write_sized_vuint(w, n, 3u); return; } if n < 0x10000000_u { write_sized_vuint(w, n, 4u); return; } - fail fmt!("vint to write too big: %?", n); + die!(fmt!("vint to write too big: %?", n)); } pub fn Encoder(w: io::Writer) -> Encoder { @@ -598,17 +599,17 @@ pub mod writer { // FIXME (#2742): implement these fn emit_f64(&self, _v: f64) { - fail ~"Unimplemented: serializing an f64"; + die!(~"Unimplemented: serializing an f64"); } fn emit_f32(&self, _v: f32) { - fail ~"Unimplemented: serializing an f32"; + die!(~"Unimplemented: serializing an f32"); } fn emit_float(&self, _v: float) { - fail ~"Unimplemented: serializing a float"; + die!(~"Unimplemented: serializing a float"); } fn emit_char(&self, _v: char) { - fail ~"Unimplemented: serializing a char"; + die!(~"Unimplemented: serializing a char"); } fn emit_borrowed_str(&self, v: &str) { diff --git a/src/libstd/flatpipes.rs b/src/libstd/flatpipes.rs index e108643790e..ba95fa5b661 100644 --- a/src/libstd/flatpipes.rs +++ b/src/libstd/flatpipes.rs @@ -262,7 +262,7 @@ pub impl<T,U:Unflattener<T>,P:BytePort> FlatPort<T, U, P>: GenericPort<T> { fn recv() -> T { match self.try_recv() { Some(move val) => move val, - None => fail ~"port is closed" + None => die!(~"port is closed") } } fn try_recv() -> Option<T> { @@ -298,7 +298,7 @@ pub impl<T,U:Unflattener<T>,P:BytePort> FlatPort<T, U, P>: GenericPort<T> { } } else { - fail ~"flatpipe: unrecognized command"; + die!(~"flatpipe: unrecognized command"); } } } @@ -480,7 +480,7 @@ pub mod flatteners { Ok(move json) => { json::Decoder(move json) } - Err(e) => fail fmt!("flatpipe: can't parse json: %?", e) + Err(e) => die!(fmt!("flatpipe: can't parse json: %?", e)) } } } diff --git a/src/libstd/future.rs b/src/libstd/future.rs index 7d61326c02f..57b768a742f 100644 --- a/src/libstd/future.rs +++ b/src/libstd/future.rs @@ -65,14 +65,14 @@ impl<A> Future<A> { unsafe { match self.state { Forced(ref mut v) => { return cast::transmute(v); } - Evaluating => fail ~"Recursive forcing of future!", + Evaluating => die!(~"Recursive forcing of future!"), Pending(_) => {} } let mut state = Evaluating; self.state <-> state; match move state { - Forced(_) | Evaluating => fail ~"Logic error.", + Forced(_) | Evaluating => die!(~"Logic error."), Pending(move f) => { self.state = Forced(move f()); self.get_ref() @@ -195,7 +195,7 @@ pub mod test { #[should_fail] #[ignore(cfg(target_os = "win32"))] pub fn test_futurefail() { - let f = spawn(|| fail); + let f = spawn(|| die!()); let _x: ~str = f.get(); } diff --git a/src/libstd/getopts.rs b/src/libstd/getopts.rs index f4ebed7da96..6e1a0861035 100644 --- a/src/libstd/getopts.rs +++ b/src/libstd/getopts.rs @@ -56,7 +56,7 @@ * ]; * let matches = match getopts(vec::tail(args), opts) { * result::ok(m) { m } - * result::err(f) { fail fail_str(f) } + * result::err(f) { die!(fail_str(f)) } * }; * if opt_present(matches, "h") || opt_present(matches, "help") { * print_usage(program); @@ -348,7 +348,7 @@ fn opt_vals(mm: &Matches, nm: &str) -> ~[Optval] { Some(id) => mm.vals[id], None => { error!("No option '%s' defined", nm); - fail + die!() } }; } @@ -384,7 +384,7 @@ pub fn opts_present(mm: &Matches, names: &[~str]) -> bool { * argument */ pub fn opt_str(mm: &Matches, nm: &str) -> ~str { - return match opt_val(mm, nm) { Val(copy s) => s, _ => fail }; + return match opt_val(mm, nm) { Val(copy s) => s, _ => die!() }; } /** @@ -400,7 +400,7 @@ pub fn opts_str(mm: &Matches, names: &[~str]) -> ~str { _ => () } } - fail; + die!(); } @@ -550,7 +550,7 @@ pub mod groups { match ((*lopt).short_name.len(), (*lopt).long_name.len()) { - (0,0) => fail ~"this long-format option was given no name", + (0,0) => die!(~"this long-format option was given no name"), (0,_) => ~[Opt {name: Long(((*lopt).long_name)), hasarg: (*lopt).hasarg, @@ -567,7 +567,7 @@ pub mod groups { hasarg: (*lopt).hasarg, occur: (*lopt).occur}], - (_,_) => fail ~"something is wrong with the long-form opt" + (_,_) => die!(~"something is wrong with the long-form opt") } } @@ -598,7 +598,7 @@ pub mod groups { row += match short_name.len() { 0 => ~"", 1 => ~"-" + short_name + " ", - _ => fail ~"the short name should only be 1 char long", + _ => die!(~"the short name should only be 1 char long"), }; // long option @@ -668,7 +668,7 @@ mod tests { assert (opt_present(m, ~"test")); assert (opt_str(m, ~"test") == ~"20"); } - _ => { fail ~"test_reqopt_long failed"; } + _ => { die!(~"test_reqopt_long failed"); } } } @@ -679,7 +679,7 @@ mod tests { let rs = getopts(args, opts); match rs { Err(copy f) => check_fail_type(f, OptionMissing_), - _ => fail + _ => die!() } } @@ -690,7 +690,7 @@ mod tests { let rs = getopts(args, opts); match rs { Err(copy f) => check_fail_type(f, ArgumentMissing_), - _ => fail + _ => die!() } } @@ -701,7 +701,7 @@ mod tests { let rs = getopts(args, opts); match rs { Err(copy f) => check_fail_type(f, OptionDuplicated_), - _ => fail + _ => die!() } } @@ -715,7 +715,7 @@ mod tests { assert (opt_present(m, ~"t")); assert (opt_str(m, ~"t") == ~"20"); } - _ => fail + _ => die!() } } @@ -726,7 +726,7 @@ mod tests { let rs = getopts(args, opts); match rs { Err(copy f) => check_fail_type(f, OptionMissing_), - _ => fail + _ => die!() } } @@ -737,7 +737,7 @@ mod tests { let rs = getopts(args, opts); match rs { Err(copy f) => check_fail_type(f, ArgumentMissing_), - _ => fail + _ => die!() } } @@ -748,7 +748,7 @@ mod tests { let rs = getopts(args, opts); match rs { Err(copy f) => check_fail_type(f, OptionDuplicated_), - _ => fail + _ => die!() } } @@ -764,7 +764,7 @@ mod tests { assert (opt_present(m, ~"test")); assert (opt_str(m, ~"test") == ~"20"); } - _ => fail + _ => die!() } } @@ -775,7 +775,7 @@ mod tests { let rs = getopts(args, opts); match rs { Ok(ref m) => assert (!opt_present(m, ~"test")), - _ => fail + _ => die!() } } @@ -786,7 +786,7 @@ mod tests { let rs = getopts(args, opts); match rs { Err(copy f) => check_fail_type(f, ArgumentMissing_), - _ => fail + _ => die!() } } @@ -797,7 +797,7 @@ mod tests { let rs = getopts(args, opts); match rs { Err(copy f) => check_fail_type(f, OptionDuplicated_), - _ => fail + _ => die!() } } @@ -811,7 +811,7 @@ mod tests { assert (opt_present(m, ~"t")); assert (opt_str(m, ~"t") == ~"20"); } - _ => fail + _ => die!() } } @@ -822,7 +822,7 @@ mod tests { let rs = getopts(args, opts); match rs { Ok(ref m) => assert (!opt_present(m, ~"t")), - _ => fail + _ => die!() } } @@ -833,7 +833,7 @@ mod tests { let rs = getopts(args, opts); match rs { Err(copy f) => check_fail_type(f, ArgumentMissing_), - _ => fail + _ => die!() } } @@ -844,7 +844,7 @@ mod tests { let rs = getopts(args, opts); match rs { Err(copy f) => check_fail_type(f, OptionDuplicated_), - _ => fail + _ => die!() } } @@ -857,7 +857,7 @@ mod tests { let rs = getopts(args, opts); match rs { Ok(ref m) => assert (opt_present(m, ~"test")), - _ => fail + _ => die!() } } @@ -868,7 +868,7 @@ mod tests { let rs = getopts(args, opts); match rs { Ok(ref m) => assert (!opt_present(m, ~"test")), - _ => fail + _ => die!() } } @@ -882,7 +882,7 @@ mod tests { log(error, fail_str(f)); check_fail_type(f, UnexpectedArgument_); } - _ => fail + _ => die!() } } @@ -893,7 +893,7 @@ mod tests { let rs = getopts(args, opts); match rs { Err(copy f) => check_fail_type(f, OptionDuplicated_), - _ => fail + _ => die!() } } @@ -904,7 +904,7 @@ mod tests { let rs = getopts(args, opts); match rs { Ok(ref m) => assert (opt_present(m, ~"t")), - _ => fail + _ => die!() } } @@ -915,7 +915,7 @@ mod tests { let rs = getopts(args, opts); match rs { Ok(ref m) => assert (!opt_present(m, ~"t")), - _ => fail + _ => die!() } } @@ -930,7 +930,7 @@ mod tests { assert (m.free[0] == ~"20"); } - _ => fail + _ => die!() } } @@ -941,7 +941,7 @@ mod tests { let rs = getopts(args, opts); match rs { Err(copy f) => check_fail_type(f, OptionDuplicated_), - _ => fail + _ => die!() } } @@ -955,7 +955,7 @@ mod tests { Ok(ref m) => { assert (opt_count(m, ~"v") == 1); } - _ => fail + _ => die!() } } @@ -968,7 +968,7 @@ mod tests { Ok(ref m) => { assert (opt_count(m, ~"v") == 2); } - _ => fail + _ => die!() } } @@ -981,7 +981,7 @@ mod tests { Ok(ref m) => { assert (opt_count(m, ~"v") == 2); } - _ => fail + _ => die!() } } @@ -994,7 +994,7 @@ mod tests { Ok(ref m) => { assert (opt_count(m, ~"verbose") == 1); } - _ => fail + _ => die!() } } @@ -1007,7 +1007,7 @@ mod tests { Ok(ref m) => { assert (opt_count(m, ~"verbose") == 2); } - _ => fail + _ => die!() } } @@ -1022,7 +1022,7 @@ mod tests { assert (opt_present(m, ~"test")); assert (opt_str(m, ~"test") == ~"20"); } - _ => fail + _ => die!() } } @@ -1033,7 +1033,7 @@ mod tests { let rs = getopts(args, opts); match rs { Ok(ref m) => assert (!opt_present(m, ~"test")), - _ => fail + _ => die!() } } @@ -1044,7 +1044,7 @@ mod tests { let rs = getopts(args, opts); match rs { Err(copy f) => check_fail_type(f, ArgumentMissing_), - _ => fail + _ => die!() } } @@ -1061,7 +1061,7 @@ mod tests { assert (pair[0] == ~"20"); assert (pair[1] == ~"30"); } - _ => fail + _ => die!() } } @@ -1075,7 +1075,7 @@ mod tests { assert (opt_present(m, ~"t")); assert (opt_str(m, ~"t") == ~"20"); } - _ => fail + _ => die!() } } @@ -1086,7 +1086,7 @@ mod tests { let rs = getopts(args, opts); match rs { Ok(ref m) => assert (!opt_present(m, ~"t")), - _ => fail + _ => die!() } } @@ -1097,7 +1097,7 @@ mod tests { let rs = getopts(args, opts); match rs { Err(copy f) => check_fail_type(f, ArgumentMissing_), - _ => fail + _ => die!() } } @@ -1114,7 +1114,7 @@ mod tests { assert (pair[0] == ~"20"); assert (pair[1] == ~"30"); } - _ => fail + _ => die!() } } @@ -1125,7 +1125,7 @@ mod tests { let rs = getopts(args, opts); match rs { Err(copy f) => check_fail_type(f, UnrecognizedOption_), - _ => fail + _ => die!() } } @@ -1136,7 +1136,7 @@ mod tests { let rs = getopts(args, opts); match rs { Err(copy f) => check_fail_type(f, UnrecognizedOption_), - _ => fail + _ => die!() } } @@ -1168,7 +1168,7 @@ mod tests { assert (pair[1] == ~"-60 70"); assert (!opt_present(m, ~"notpresent")); } - _ => fail + _ => die!() } } @@ -1178,7 +1178,7 @@ mod tests { let opts = ~[optopt(~"e"), optopt(~"encrypt")]; let matches = &match getopts(args, opts) { result::Ok(move m) => m, - result::Err(_) => fail + result::Err(_) => die!() }; assert opts_present(matches, ~[~"e"]); assert opts_present(matches, ~[~"encrypt"]); @@ -1199,7 +1199,7 @@ mod tests { let opts = ~[optmulti(~"L"), optmulti(~"M")]; let matches = &match getopts(args, opts) { result::Ok(move m) => m, - result::Err(_) => fail + result::Err(_) => die!() }; assert opts_present(matches, ~[~"L"]); assert opts_str(matches, ~[~"L"]) == ~"foo"; diff --git a/src/libstd/io_util.rs b/src/libstd/io_util.rs index fb410c19a76..9a90b811e44 100644 --- a/src/libstd/io_util.rs +++ b/src/libstd/io_util.rs @@ -43,7 +43,7 @@ pub impl BufReader { } impl BufReader: Reader { - fn read(&self, bytes: &[mut u8], len: uint) -> uint { + fn read(&self, bytes: &mut [u8], len: uint) -> uint { self.as_bytes_reader(|r| r.read(bytes, len) ) } fn read_byte(&self) -> int { diff --git a/src/libstd/json.rs b/src/libstd/json.rs index 1361d8647b5..4b34f318e91 100644 --- a/src/libstd/json.rs +++ b/src/libstd/json.rs @@ -109,7 +109,7 @@ pub impl Encoder: serialize::Encoder { fn emit_f64(&self, v: f64) { self.emit_float(v as float); } fn emit_f32(&self, v: f32) { self.emit_float(v as float); } fn emit_float(&self, v: float) { - self.wr.write_str(float::to_str(v, 6u)); + self.wr.write_str(float::to_str_digits(v, 6u)); } fn emit_char(&self, v: char) { self.emit_borrowed_str(str::from_char(v)) } @@ -123,7 +123,7 @@ pub impl Encoder: serialize::Encoder { fn emit_managed(&self, f: fn()) { f() } fn emit_enum(&self, name: &str, f: fn()) { - if name != "option" { fail ~"only supports option enum" } + if name != "option" { die!(~"only supports option enum") } f() } fn emit_enum_variant(&self, _name: &str, id: uint, _cnt: uint, f: fn()) { @@ -213,7 +213,7 @@ pub impl PrettyEncoder: serialize::Encoder { fn emit_f64(&self, v: f64) { self.emit_float(v as float); } fn emit_f32(&self, v: f32) { self.emit_float(v as float); } fn emit_float(&self, v: float) { - self.wr.write_str(float::to_str(v, 6u)); + self.wr.write_str(float::to_str_digits(v, 6u)); } fn emit_char(&self, v: char) { self.emit_borrowed_str(str::from_char(v)) } @@ -227,7 +227,7 @@ pub impl PrettyEncoder: serialize::Encoder { fn emit_managed(&self, f: fn()) { f() } fn emit_enum(&self, name: &str, f: fn()) { - if name != "option" { fail ~"only supports option enum" } + if name != "option" { die!(~"only supports option enum") } f() } fn emit_enum_variant(&self, _name: &str, id: uint, _cnt: uint, f: fn()) { @@ -743,7 +743,7 @@ pub impl Decoder: serialize::Decoder { debug!("read_nil"); match *self.pop() { Null => (), - _ => fail ~"not a null" + _ => die!(~"not a null") } } @@ -763,7 +763,7 @@ pub impl Decoder: serialize::Decoder { debug!("read_bool"); match *self.pop() { Boolean(b) => b, - _ => fail ~"not a boolean" + _ => die!(~"not a boolean") } } @@ -773,13 +773,13 @@ pub impl Decoder: serialize::Decoder { debug!("read_float"); match *self.pop() { Number(f) => f, - _ => fail ~"not a number" + _ => die!(~"not a number") } } fn read_char(&self) -> char { let v = str::chars(self.read_owned_str()); - if v.len() != 1 { fail ~"string must have one character" } + if v.len() != 1 { die!(~"string must have one character") } v[0] } @@ -787,7 +787,7 @@ pub impl Decoder: serialize::Decoder { debug!("read_owned_str"); match *self.pop() { String(ref s) => copy *s, - _ => fail ~"not a string" + _ => die!(~"not a string") } } @@ -795,7 +795,7 @@ pub impl Decoder: serialize::Decoder { debug!("read_managed_str"); match *self.pop() { String(ref s) => s.to_managed(), - _ => fail ~"not a string" + _ => die!(~"not a string") } } @@ -811,7 +811,7 @@ pub impl Decoder: serialize::Decoder { fn read_enum<T>(&self, name: &str, f: fn() -> T) -> T { debug!("read_enum(%s)", name); - if name != ~"option" { fail ~"only supports the option enum" } + if name != ~"option" { die!(~"only supports the option enum") } f() } @@ -826,7 +826,7 @@ pub impl Decoder: serialize::Decoder { fn read_enum_variant_arg<T>(&self, idx: uint, f: fn() -> T) -> T { debug!("read_enum_variant_arg(idx=%u)", idx); - if idx != 0 { fail ~"unknown index" } + if idx != 0 { die!(~"unknown index") } f() } @@ -834,7 +834,7 @@ pub impl Decoder: serialize::Decoder { debug!("read_owned_vec()"); let len = match *self.peek() { List(list) => list.len(), - _ => fail ~"not a list", + _ => die!(~"not a list"), }; let res = f(len); self.pop(); @@ -845,7 +845,7 @@ pub impl Decoder: serialize::Decoder { debug!("read_owned_vec()"); let len = match *self.peek() { List(ref list) => list.len(), - _ => fail ~"not a list", + _ => die!(~"not a list"), }; let res = f(len); self.pop(); @@ -862,7 +862,7 @@ pub impl Decoder: serialize::Decoder { self.stack.push(&list[idx]); f() } - _ => fail ~"not a list", + _ => die!(~"not a list"), } } @@ -889,20 +889,20 @@ pub impl Decoder: serialize::Decoder { let obj: &self/~Object = obj; match obj.find(&name.to_owned()) { - None => fail fmt!("no such field: %s", name), + None => die!(fmt!("no such field: %s", name)), Some(json) => { self.stack.push(json); f() } } } - Number(_) => fail ~"num", - String(_) => fail ~"str", - Boolean(_) => fail ~"bool", - List(_) => fail fmt!("list: %?", top), - Null => fail ~"null", + Number(_) => die!(~"num"), + String(_) => die!(~"str"), + Boolean(_) => die!(~"bool"), + List(_) => die!(fmt!("list: %?", top)), + Null => die!(~"null"), - //_ => fail fmt!("not an object: %?", *top) + //_ => die!(fmt!("not an object: %?", *top)) } } @@ -922,7 +922,7 @@ pub impl Decoder: serialize::Decoder { self.stack.push(&list[idx]); f() } - _ => fail ~"not a list" + _ => die!(~"not a list") } } } @@ -1162,18 +1162,6 @@ impl <A: ToJson Copy> LinearMap<~str, A>: ToJson { } } -/* -impl <A: ToJson Copy> @std::map::HashMap<~str, A>: ToJson { - fn to_json() -> Json { - let mut d = LinearMap::new(); - for self.each_ref |key, value| { - d.insert(copy *key, value.to_json()); - } - Object(~d) - } -} -*/ - impl <A: ToJson> Option<A>: ToJson { fn to_json() -> Json { match self { @@ -1184,11 +1172,11 @@ impl <A: ToJson> Option<A>: ToJson { } impl Json: to_str::ToStr { - pure fn to_str() -> ~str { to_str(&self) } + pure fn to_str(&self) -> ~str { to_str(self) } } impl Error: to_str::ToStr { - pure fn to_str() -> ~str { + pure fn to_str(&self) -> ~str { fmt!("%u:%u: %s", self.line, self.col, *self.msg) } } diff --git a/src/libstd/list.rs b/src/libstd/list.rs index 68571382631..3016abee464 100644 --- a/src/libstd/list.rs +++ b/src/libstd/list.rs @@ -94,7 +94,7 @@ pub pure fn len<T>(ls: @List<T>) -> uint { pub pure fn tail<T: Copy>(ls: @List<T>) -> @List<T> { match *ls { Cons(_, tl) => return tl, - Nil => fail ~"list empty" + Nil => die!(~"list empty") } } @@ -103,7 +103,7 @@ pub pure fn head<T: Copy>(ls: @List<T>) -> T { match *ls { Cons(copy hd, _) => hd, // makes me sad - _ => fail ~"head invoked on empty list" + _ => die!(~"head invoked on empty list") } } diff --git a/src/libstd/md4.rs b/src/libstd/md4.rs index 06b6aca6895..e1e2bb2697f 100644 --- a/src/libstd/md4.rs +++ b/src/libstd/md4.rs @@ -109,7 +109,7 @@ pub pure fn md4_str(msg: &[u8]) -> ~str { while i < 4u32 { let byte = (u >> (i * 8u32)) as u8; if byte <= 16u8 { result += ~"0"; } - result += uint::to_str(byte as uint, 16u); + result += uint::to_str_radix(byte as uint, 16u); i += 1u32; } } diff --git a/src/libstd/net_ip.rs b/src/libstd/net_ip.rs index 2447c2eb530..f4fd69aae1e 100644 --- a/src/libstd/net_ip.rs +++ b/src/libstd/net_ip.rs @@ -64,14 +64,14 @@ pub fn format_addr(ip: &IpAddr) -> ~str { Ipv4(ref addr) => unsafe { let result = uv_ip4_name(addr); if result == ~"" { - fail ~"failed to convert inner sockaddr_in address to str" + die!(~"failed to convert inner sockaddr_in address to str") } result }, Ipv6(ref addr) => unsafe { let result = uv_ip6_name(addr); if result == ~"" { - fail ~"failed to convert inner sockaddr_in address to str" + die!(~"failed to convert inner sockaddr_in address to str") } result } @@ -183,7 +183,7 @@ pub mod v4 { pub fn parse_addr(ip: &str) -> IpAddr { match try_parse_addr(ip) { result::Ok(move addr) => move addr, - result::Err(ref err_data) => fail err_data.err_msg + result::Err(ref err_data) => die!(err_data.err_msg) } } // the simple, old style numberic representation of @@ -278,7 +278,7 @@ pub mod v6 { pub fn parse_addr(ip: &str) -> IpAddr { match try_parse_addr(ip) { result::Ok(move addr) => move addr, - result::Err(copy err_data) => fail err_data.err_msg + result::Err(copy err_data) => die!(err_data.err_msg) } } pub fn try_parse_addr(ip: &str) -> result::Result<IpAddr,ParseAddrErr> { @@ -400,7 +400,7 @@ mod test { assert true; } result::Ok(ref addr) => { - fail fmt!("Expected failure, but got addr %?", addr); + die!(fmt!("Expected failure, but got addr %?", addr)); } } } @@ -413,7 +413,7 @@ mod test { assert true; } result::Ok(ref addr) => { - fail fmt!("Expected failure, but got addr %?", addr); + die!(fmt!("Expected failure, but got addr %?", addr)); } } } @@ -424,7 +424,7 @@ mod test { let iotask = &uv::global_loop::get(); let ga_result = get_addr(localhost_name, iotask); if result::is_err(&ga_result) { - fail ~"got err result from net::ip::get_addr();" + die!(~"got err result from net::ip::get_addr();") } // note really sure how to realiably test/assert // this.. mostly just wanting to see it work, atm. diff --git a/src/libstd/net_tcp.rs b/src/libstd/net_tcp.rs index d9e4bfc540c..429bd6ae474 100644 --- a/src/libstd/net_tcp.rs +++ b/src/libstd/net_tcp.rs @@ -863,7 +863,7 @@ impl TcpSocket { /// Implementation of `io::reader` trait for a buffered `net::tcp::tcp_socket` impl TcpSocketBuf: io::Reader { - fn read(&self, buf: &[mut u8], len: uint) -> uint { + fn read(&self, buf: &mut [u8], len: uint) -> uint { if len == 0 { return 0 } let mut count: uint = 0; @@ -940,7 +940,7 @@ impl TcpSocketBuf: io::Reader { } else { debug!("ERROR sock_buf as io::reader.read err %? %?", err_data.err_name, err_data.err_msg); - fail + die!() } } else { @@ -1644,7 +1644,7 @@ pub mod test { hl_loop); match actual_resp_result.get_err() { ConnectionRefused => (), - _ => fail ~"unknown error.. expected connection_refused" + _ => die!(~"unknown error.. expected connection_refused") } } pub fn impl_gl_tcp_ipv4_server_address_in_use() { @@ -1685,8 +1685,8 @@ pub mod test { assert true; } _ => { - fail ~"expected address_in_use listen error,"+ - ~"but got a different error varient. check logs."; + die!(~"expected address_in_use listen error,"+ + ~"but got a different error varient. check logs."); } } } @@ -1704,8 +1704,8 @@ pub mod test { assert true; } _ => { - fail ~"expected address_in_use listen error,"+ - ~"but got a different error varient. check logs."; + die!(~"expected address_in_use listen error,"+ + ~"but got a different error varient. check logs."); } } } @@ -1884,14 +1884,14 @@ pub mod test { if result::is_err(&listen_result) { match result::get_err(&listen_result) { GenericListenErr(ref name, ref msg) => { - fail fmt!("SERVER: exited abnormally name %s msg %s", - *name, *msg); + die!(fmt!("SERVER: exited abnormally name %s msg %s", + *name, *msg)); } AccessDenied => { - fail ~"SERVER: exited abnormally, got access denied.."; + die!(~"SERVER: exited abnormally, got access denied.."); } AddressInUse => { - fail ~"SERVER: exited abnormally, got address in use..."; + die!(~"SERVER: exited abnormally, got address in use..."); } } } @@ -1910,15 +1910,15 @@ pub mod test { debug!("establish_cb %?", kill_ch); }, |new_conn, kill_ch| { - fail fmt!("SERVER: shouldn't be called.. %? %?", - new_conn, kill_ch); + die!(fmt!("SERVER: shouldn't be called.. %? %?", + new_conn, kill_ch)); }); // err check on listen_result if result::is_err(&listen_result) { result::get_err(&listen_result) } else { - fail ~"SERVER: did not fail as expected" + die!(~"SERVER: did not fail as expected") } } @@ -1962,7 +1962,7 @@ pub mod test { debug!("tcp_write_single err name: %s msg: %s", err_data.err_name, err_data.err_msg); // meh. torn on what to do here. - fail ~"tcp_write_single failed"; + die!(~"tcp_write_single failed"); } } } diff --git a/src/libstd/net_url.rs b/src/libstd/net_url.rs index 89b19fccc1c..b32c97c6998 100644 --- a/src/libstd/net_url.rs +++ b/src/libstd/net_url.rs @@ -718,8 +718,8 @@ pub pure fn to_str(url: &Url) -> ~str { } impl Url: to_str::ToStr { - pub pure fn to_str() -> ~str { - to_str(&self) + pub pure fn to_str(&self) -> ~str { + to_str(self) } } diff --git a/src/libstd/map.rs b/src/libstd/oldmap.rs index 2fa2825eb4c..a4d4a4e806b 100644 --- a/src/libstd/map.rs +++ b/src/libstd/oldmap.rs @@ -8,16 +8,16 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -//! A map type +//! A map type - **deprecated**, use `core::hashmap` instead #[forbid(deprecated_mode)]; +use core::container::{Container, Mutable, Map}; use core::cmp::Eq; use core::hash::Hash; use core::io::WriterUtil; use core::io; use core::ops; use core::to_str::ToStr; -use core::mutable::Mut; use core::prelude::*; use core::to_bytes::IterBytes; use core::uint; @@ -28,84 +28,6 @@ pub type Set<K> = HashMap<K, ()>; pub type HashMap<K, V> = chained::T<K, V>; -pub trait StdMap<K:Eq IterBytes Hash Copy, V: Copy> { - /// Return the number of elements in the map - pure fn size() -> uint; - - /** - * Add a value to the map. - * - * If the map already contains a value for the specified key then the - * original value is replaced. - * - * Returns true if the key did not already exist in the map - */ - fn insert(key: K, value: V) -> bool; - - /** - * Add a value to the map. - * - * If the map contains a value for the key, use the function - * to set a new value. - */ - fn update_with_key(key: K, newval: V, ff: fn(K, V, V) -> V) -> bool; - - /** - * Add a value to the map. - * - * If the map contains a value for the key, use the function to - * set a new value. (Like `update_with_key`, but with a - * function of only values.) - */ - fn update(key: K, newval: V, ff: fn(V, V) -> V) -> bool; - - /// Returns true if the map contains a value for the specified key - pure fn contains_key(key: K) -> bool; - - /// Returns true if the map contains a value for the specified - /// key, taking the key by reference. - pure fn contains_key_ref(key: &K) -> bool; - - /** - * Get the value for the specified key. Fails if the key does not exist in - * the map. - */ - pure fn get(key: K) -> V; - - /** - * Get the value for the specified key. If the key does not exist in - * the map then returns none. - */ - pure fn find(key: K) -> Option<V>; - - /** - * Remove and return a value from the map. Returns true if the - * key was present in the map, otherwise false. - */ - fn remove(key: K) -> bool; - - /// Clear the map, removing all key/value pairs. - fn clear(); - - /// Iterate over all the key/value pairs in the map by value - pure fn each(fn(key: K, value: V) -> bool); - - /// Iterate over all the keys in the map by value - pure fn each_key(fn(key: K) -> bool); - - /// Iterate over all the values in the map by value - pure fn each_value(fn(value: V) -> bool); - - /// Iterate over all the key/value pairs in the map by reference - pure fn each_ref(fn(key: &K, value: &V) -> bool); - - /// Iterate over all the keys in the map by reference - pure fn each_key_ref(fn(key: &K) -> bool); - - /// Iterate over all the values in the map by reference - pure fn each_value_ref(fn(value: &V) -> bool); -} - pub mod util { pub struct Rational { // : int::positive(*.den); @@ -124,7 +46,7 @@ pub mod util { // FIXME (#2344): package this up and export it as a datatype usable for // external code that doesn't want to pay the cost of a box. pub mod chained { - use map::{StdMap, util}; + use super::util; use core::io; use core::ops; @@ -144,7 +66,7 @@ pub mod chained { struct HashMap_<K, V> { mut count: uint, - mut chains: ~[mut Option<@Entry<K,V>>] + mut chains: ~[Option<@Entry<K,V>>] } pub type T<K, V> = @HashMap_<K, V>; @@ -209,7 +131,7 @@ pub mod chained { fn rehash() { let n_old_chains = self.chains.len(); let n_new_chains: uint = uint::next_power_of_two(n_old_chains+1u); - let new_chains = chains(n_new_chains); + let mut new_chains = chains(n_new_chains); for self.each_entry |entry| { let idx = entry.hash % n_new_chains; entry.next = new_chains[idx]; @@ -239,14 +161,20 @@ pub mod chained { } } - impl<K:Eq IterBytes Hash Copy, V: Copy> T<K, V>: StdMap<K, V> { - pure fn size() -> uint { self.count } + impl<K: Eq IterBytes Hash, V> T<K, V>: Container { + pure fn len(&self) -> uint { self.count } + pure fn is_empty(&self) -> bool { self.count == 0 } + } - pure fn contains_key(k: K) -> bool { - self.contains_key_ref(&k) + impl<K: Eq IterBytes Hash, V> T<K, V>: Mutable { + fn clear(&mut self) { + self.count = 0u; + self.chains = chains(initial_capacity); } + } - pure fn contains_key_ref(k: &K) -> bool { + impl<K:Eq IterBytes Hash Copy, V: Copy> T<K, V> { + pure fn contains_key_ref(&self, k: &K) -> bool { let hash = k.hash_keyed(0,0) as uint; match self.search_tbl(k, hash) { NotFound => false, @@ -298,7 +226,7 @@ pub mod chained { } } - pure fn find(k: K) -> Option<V> { + pure fn find(&self, k: K) -> Option<V> { unsafe { match self.search_tbl(&k, k.hash_keyed(0,0) as uint) { NotFound => None, @@ -363,16 +291,16 @@ pub mod chained { return self.update_with_key(key, newval, |_k, v, v1| ff(v,v1)); } - pure fn get(k: K) -> V { + pure fn get(&self, k: K) -> V { let opt_v = self.find(k); if opt_v.is_none() { - fail fmt!("Key not found in table: %?", k); + die!(fmt!("Key not found in table: %?", k)); } option::unwrap(move opt_v) } - fn remove(k: K) -> bool { - match self.search_tbl(&k, k.hash_keyed(0,0) as uint) { + fn remove(k: &K) -> bool { + match self.search_tbl(k, k.hash_keyed(0,0) as uint) { NotFound => false, FoundFirst(idx, entry) => { self.count -= 1u; @@ -387,34 +315,17 @@ pub mod chained { } } - fn clear() { - self.count = 0u; - self.chains = chains(initial_capacity); - } - - pure fn each(blk: fn(key: K, value: V) -> bool) { - self.each_ref(|k, v| blk(*k, *v)) - } - - pure fn each_key(blk: fn(key: K) -> bool) { - self.each_key_ref(|p| blk(*p)) - } - - pure fn each_value(blk: fn(value: V) -> bool) { - self.each_value_ref(|p| blk(*p)) - } - - pure fn each_ref(blk: fn(key: &K, value: &V) -> bool) { + pure fn each_ref(&self, blk: fn(key: &K, value: &V) -> bool) { for self.each_entry |entry| { if !blk(&entry.key, &entry.value) { break; } } } - pure fn each_key_ref(blk: fn(key: &K) -> bool) { + pure fn each_key_ref(&self, blk: fn(key: &K) -> bool) { self.each_ref(|k, _v| blk(k)) } - pure fn each_value_ref(blk: fn(value: &V) -> bool) { + pure fn each_value_ref(&self, blk: fn(value: &V) -> bool) { self.each_ref(|_k, v| blk(v)) } } @@ -442,7 +353,7 @@ pub mod chained { } impl<K:Eq IterBytes Hash Copy ToStr, V: ToStr Copy> T<K, V>: ToStr { - pure fn to_str() -> ~str { + pure fn to_str(&self) -> ~str { unsafe { // Meh -- this should be safe do io::with_str_writer |wr| { self.to_writer(wr) } @@ -458,8 +369,8 @@ pub mod chained { } } - fn chains<K,V>(nchains: uint) -> ~[mut Option<@Entry<K,V>>] { - vec::cast_to_mut(vec::from_elem(nchains, None)) + fn chains<K,V>(nchains: uint) -> ~[Option<@Entry<K,V>>] { + vec::from_elem(nchains, None) } pub fn mk<K:Eq IterBytes Hash, V: Copy>() -> T<K,V> { @@ -486,8 +397,8 @@ pub fn set_add<K:Eq IterBytes Hash Const Copy>(set: Set<K>, key: K) -> bool { /// Convert a set into a vector. pub pure fn vec_from_set<T:Eq IterBytes Hash Copy>(s: Set<T>) -> ~[T] { - do vec::build_sized(s.size()) |push| { - for s.each_key() |k| { + do vec::build_sized(s.len()) |push| { + for s.each_key_ref() |&k| { push(k); } } @@ -509,20 +420,20 @@ pub fn hash_from_vec<K: Eq IterBytes Hash Const Copy, V: Copy>( #[cfg(test)] mod tests { - use map; - use core::option::None; use core::option; use core::uint; + use super::*; + #[test] fn test_simple() { debug!("*** starting test_simple"); pure fn eq_uint(x: &uint, y: &uint) -> bool { *x == *y } pure fn uint_id(x: &uint) -> uint { *x } debug!("uint -> uint"); - let hm_uu: map::HashMap<uint, uint> = - map::HashMap::<uint, uint>(); + let hm_uu: HashMap<uint, uint> = + HashMap::<uint, uint>(); assert (hm_uu.insert(10u, 12u)); assert (hm_uu.insert(11u, 13u)); assert (hm_uu.insert(12u, 14u)); @@ -537,8 +448,8 @@ mod tests { let eleven: ~str = ~"eleven"; let twelve: ~str = ~"twelve"; debug!("str -> uint"); - let hm_su: map::HashMap<~str, uint> = - map::HashMap::<~str, uint>(); + let hm_su: HashMap<~str, uint> = + HashMap::<~str, uint>(); assert (hm_su.insert(~"ten", 12u)); assert (hm_su.insert(eleven, 13u)); assert (hm_su.insert(~"twelve", 14u)); @@ -551,8 +462,8 @@ mod tests { assert (!hm_su.insert(~"twelve", 12u)); assert (hm_su.get(~"twelve") == 12u); debug!("uint -> str"); - let hm_us: map::HashMap<uint, ~str> = - map::HashMap::<uint, ~str>(); + let hm_us: HashMap<uint, ~str> = + HashMap::<uint, ~str>(); assert (hm_us.insert(10u, ~"twelve")); assert (hm_us.insert(11u, ~"thirteen")); assert (hm_us.insert(12u, ~"fourteen")); @@ -564,8 +475,8 @@ mod tests { assert (!hm_us.insert(12u, ~"twelve")); assert hm_us.get(12u) == ~"twelve"; debug!("str -> str"); - let hm_ss: map::HashMap<~str, ~str> = - map::HashMap::<~str, ~str>(); + let hm_ss: HashMap<~str, ~str> = + HashMap::<~str, ~str>(); assert (hm_ss.insert(ten, ~"twelve")); assert (hm_ss.insert(eleven, ~"thirteen")); assert (hm_ss.insert(twelve, ~"fourteen")); @@ -590,8 +501,8 @@ mod tests { pure fn eq_uint(x: &uint, y: &uint) -> bool { *x == *y } pure fn uint_id(x: &uint) -> uint { *x } debug!("uint -> uint"); - let hm_uu: map::HashMap<uint, uint> = - map::HashMap::<uint, uint>(); + let hm_uu: HashMap<uint, uint> = + HashMap::<uint, uint>(); let mut i: uint = 0u; while i < num_to_insert { assert (hm_uu.insert(i, i * i)); @@ -615,36 +526,39 @@ mod tests { i += 1u; } debug!("str -> str"); - let hm_ss: map::HashMap<~str, ~str> = - map::HashMap::<~str, ~str>(); + let hm_ss: HashMap<~str, ~str> = + HashMap::<~str, ~str>(); i = 0u; while i < num_to_insert { - assert hm_ss.insert(uint::to_str(i, 2u), uint::to_str(i * i, 2u)); + assert hm_ss.insert(uint::to_str_radix(i, 2u), + uint::to_str_radix(i * i, 2u)); debug!("inserting \"%s\" -> \"%s\"", - uint::to_str(i, 2u), - uint::to_str(i*i, 2u)); + uint::to_str_radix(i, 2u), + uint::to_str_radix(i*i, 2u)); i += 1u; } debug!("-----"); i = 0u; while i < num_to_insert { debug!("get(\"%s\") = \"%s\"", - uint::to_str(i, 2u), - hm_ss.get(uint::to_str(i, 2u))); - assert hm_ss.get(uint::to_str(i, 2u)) == uint::to_str(i * i, 2u); + uint::to_str_radix(i, 2u), + hm_ss.get(uint::to_str_radix(i, 2u))); + assert hm_ss.get(uint::to_str_radix(i, 2u)) == + uint::to_str_radix(i * i, 2u); i += 1u; } - assert (hm_ss.insert(uint::to_str(num_to_insert, 2u), - uint::to_str(17u, 2u))); - assert hm_ss.get(uint::to_str(num_to_insert, 2u)) == - uint::to_str(17u, 2u); + assert (hm_ss.insert(uint::to_str_radix(num_to_insert, 2u), + uint::to_str_radix(17u, 2u))); + assert hm_ss.get(uint::to_str_radix(num_to_insert, 2u)) == + uint::to_str_radix(17u, 2u); debug!("-----"); i = 0u; while i < num_to_insert { debug!("get(\"%s\") = \"%s\"", - uint::to_str(i, 2u), - hm_ss.get(uint::to_str(i, 2u))); - assert hm_ss.get(uint::to_str(i, 2u)) == uint::to_str(i * i, 2u); + uint::to_str_radix(i, 2u), + hm_ss.get(uint::to_str_radix(i, 2u))); + assert hm_ss.get(uint::to_str_radix(i, 2u)) == + uint::to_str_radix(i * i, 2u); i += 1u; } debug!("*** finished test_growth"); @@ -654,24 +568,24 @@ mod tests { fn test_removal() { debug!("*** starting test_removal"); let num_to_insert: uint = 64u; - let hm: map::HashMap<uint, uint> = - map::HashMap::<uint, uint>(); + let hm: HashMap<uint, uint> = + HashMap::<uint, uint>(); let mut i: uint = 0u; while i < num_to_insert { assert (hm.insert(i, i * i)); debug!("inserting %u -> %u", i, i*i); i += 1u; } - assert (hm.size() == num_to_insert); + assert (hm.len() == num_to_insert); debug!("-----"); debug!("removing evens"); i = 0u; while i < num_to_insert { - let v = hm.remove(i); + let v = hm.remove(&i); assert v; i += 2u; } - assert (hm.size() == num_to_insert / 2u); + assert (hm.len() == num_to_insert / 2u); debug!("-----"); i = 1u; while i < num_to_insert { @@ -693,7 +607,7 @@ mod tests { debug!("inserting %u -> %u", i, i*i); i += 2u; } - assert (hm.size() == num_to_insert); + assert (hm.len() == num_to_insert); debug!("-----"); i = 0u; while i < num_to_insert { @@ -702,7 +616,7 @@ mod tests { i += 1u; } debug!("-----"); - assert (hm.size() == num_to_insert); + assert (hm.len() == num_to_insert); i = 0u; while i < num_to_insert { debug!("get(%u) = %u", i, hm.get(i)); @@ -715,16 +629,16 @@ mod tests { #[test] fn test_contains_key() { let key = ~"k"; - let map = map::HashMap::<~str, ~str>(); - assert (!map.contains_key(key)); + let map = HashMap::<~str, ~str>(); + assert (!map.contains_key_ref(&key)); map.insert(key, ~"val"); - assert (map.contains_key(key)); + assert (map.contains_key_ref(&key)); } #[test] fn test_find() { let key = ~"k"; - let map = map::HashMap::<~str, ~str>(); + let map = HashMap::<~str, ~str>(); assert (option::is_none(&map.find(key))); map.insert(key, ~"val"); assert (option::get(map.find(key)) == ~"val"); @@ -733,23 +647,23 @@ mod tests { #[test] fn test_clear() { let key = ~"k"; - let map = map::HashMap::<~str, ~str>(); + let mut map = HashMap::<~str, ~str>(); map.insert(key, ~"val"); - assert (map.size() == 1); - assert (map.contains_key(key)); + assert (map.len() == 1); + assert (map.contains_key_ref(&key)); map.clear(); - assert (map.size() == 0); - assert (!map.contains_key(key)); + assert (map.len() == 0); + assert (!map.contains_key_ref(&key)); } #[test] fn test_hash_from_vec() { - let map = map::hash_from_vec(~[ + let map = hash_from_vec(~[ (~"a", 1), (~"b", 2), (~"c", 3) ]); - assert map.size() == 3u; + assert map.len() == 3u; assert map.get(~"a") == 1; assert map.get(~"b") == 2; assert map.get(~"c") == 3; @@ -757,7 +671,7 @@ mod tests { #[test] fn test_update_with_key() { - let map = map::HashMap::<~str, uint>(); + let map = HashMap::<~str, uint>(); // given a new key, initialize it with this new count, given // given an existing key, add more to its count diff --git a/src/libstd/oldsmallintmap.rs b/src/libstd/oldsmallintmap.rs new file mode 100644 index 00000000000..803e75e4cf7 --- /dev/null +++ b/src/libstd/oldsmallintmap.rs @@ -0,0 +1,237 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +/*! + * A simple map based on a vector for small integer keys. Space requirements + * are O(highest integer key). + */ +#[forbid(deprecated_mode)]; + +use core::container::{Container, Mutable, Map, Set}; +use core::dvec::DVec; +use core::ops; +use core::option::{Some, None}; +use core::option; +use core::prelude::*; + +// FIXME (#2347): Should not be @; there's a bug somewhere in rustc that +// requires this to be. +struct SmallIntMap_<T> { + v: DVec<Option<T>>, +} + +pub enum SmallIntMap<T> { + SmallIntMap_(@SmallIntMap_<T>) +} + +/// Create a smallintmap +pub fn mk<T: Copy>() -> SmallIntMap<T> { + let v = DVec(); + SmallIntMap_(@SmallIntMap_ { v: v } ) +} + +/** + * Add a value to the map. If the map already contains a value for + * the specified key then the original value is replaced. + */ +#[inline(always)] +pub fn insert<T: Copy>(self: SmallIntMap<T>, key: uint, val: T) { + //io::println(fmt!("%?", key)); + self.v.grow_set_elt(key, &None, Some(val)); +} + +/** + * Get the value for the specified key. If the key does not exist + * in the map then returns none + */ +pub pure fn find<T: Copy>(self: SmallIntMap<T>, key: uint) -> Option<T> { + if key < self.v.len() { return self.v.get_elt(key); } + return None::<T>; +} + +/** + * Get the value for the specified key + * + * # Failure + * + * If the key does not exist in the map + */ +pub pure fn get<T: Copy>(self: SmallIntMap<T>, key: uint) -> T { + match find(self, key) { + None => { + error!("smallintmap::get(): key not present"); + die!(); + } + Some(move v) => return v + } +} + +/// Returns true if the map contains a value for the specified key +pub pure fn contains_key<T: Copy>(self: SmallIntMap<T>, key: uint) -> bool { + return !find(self, key).is_none(); +} + +impl<V> SmallIntMap<V>: Container { + /// Return the number of elements in the map + pure fn len(&self) -> uint { + let mut sz = 0u; + for self.v.each |item| { + match *item { + Some(_) => sz += 1u, + _ => () + } + } + sz + } + + /// Return true if the map contains no elements + pure fn is_empty(&self) -> bool { self.len() == 0 } +} + +impl<V> SmallIntMap<V>: Mutable { + fn clear(&mut self) { self.v.set(~[]) } +} + +/// Implements the map::map interface for smallintmap +impl<V: Copy> SmallIntMap<V> { + #[inline(always)] + fn insert(key: uint, value: V) -> bool { + let exists = contains_key(self, key); + insert(self, key, value); + return !exists; + } + fn remove(key: uint) -> bool { + if key >= self.v.len() { + return false; + } + let old = self.v.get_elt(key); + self.v.set_elt(key, None); + old.is_some() + } + pure fn contains_key(key: uint) -> bool { + contains_key(self, key) + } + pure fn contains_key_ref(key: &uint) -> bool { + contains_key(self, *key) + } + pure fn get(key: uint) -> V { get(self, key) } + pure fn find(key: uint) -> Option<V> { find(self, key) } + + fn update_with_key(key: uint, val: V, ff: fn(uint, V, V) -> V) -> bool { + match self.find(key) { + None => return self.insert(key, val), + Some(copy orig) => return self.insert(key, ff(key, orig, val)), + } + } + + fn update(key: uint, newval: V, ff: fn(V, V) -> V) -> bool { + return self.update_with_key(key, newval, |_k, v, v1| ff(v,v1)); + } + + pure fn each(it: fn(key: uint, value: V) -> bool) { + self.each_ref(|k, v| it(*k, *v)) + } + pure fn each_key(it: fn(key: uint) -> bool) { + self.each_ref(|k, _v| it(*k)) + } + pure fn each_value(it: fn(value: V) -> bool) { + self.each_ref(|_k, v| it(*v)) + } + pure fn each_ref(it: fn(key: &uint, value: &V) -> bool) { + let mut idx = 0u, l = self.v.len(); + while idx < l { + match self.v.get_elt(idx) { + Some(ref elt) => if !it(&idx, elt) { break }, + None => () + } + idx += 1u; + } + } + pure fn each_key_ref(blk: fn(key: &uint) -> bool) { + self.each_ref(|k, _v| blk(k)) + } + pure fn each_value_ref(blk: fn(value: &V) -> bool) { + self.each_ref(|_k, v| blk(v)) + } +} + +impl<V: Copy> SmallIntMap<V>: ops::Index<uint, V> { + pure fn index(&self, key: uint) -> V { + unsafe { + get(*self, key) + } + } +} + +#[cfg(test)] +mod tests { + use super::{mk, SmallIntMap}; + + use core::option::None; + + #[test] + fn test_len() { + let mut map = mk(); + assert map.len() == 0; + assert map.is_empty(); + map.insert(5, 20); + assert map.len() == 1; + assert !map.is_empty(); + map.insert(11, 12); + assert map.len() == 2; + assert !map.is_empty(); + map.insert(14, 22); + assert map.len() == 3; + assert !map.is_empty(); + } + + #[test] + fn test_clear() { + let mut map = mk(); + map.insert(5, 20); + map.insert(11, 12); + map.insert(14, 22); + map.clear(); + assert map.is_empty(); + assert map.find(5).is_none(); + assert map.find(11).is_none(); + assert map.find(14).is_none(); + } + + #[test] + fn test_insert_with_key() { + let map: SmallIntMap<uint> = mk(); + + // given a new key, initialize it with this new count, given + // given an existing key, add more to its count + fn addMoreToCount(_k: uint, v0: uint, v1: uint) -> uint { + v0 + v1 + } + + fn addMoreToCount_simple(v0: uint, v1: uint) -> uint { + v0 + v1 + } + + // count integers + map.update(3, 1, addMoreToCount_simple); + map.update_with_key(9, 1, addMoreToCount); + map.update(3, 7, addMoreToCount_simple); + map.update_with_key(5, 3, addMoreToCount); + map.update_with_key(3, 2, addMoreToCount); + + // check the total counts + assert map.find(3).get() == 10; + assert map.find(5).get() == 3; + assert map.find(9).get() == 1; + + // sadly, no sevens were counted + assert None == map.find(7); + } +} diff --git a/src/libstd/rope.rs b/src/libstd/rope.rs index ded0f316a15..c7601f6b6b5 100644 --- a/src/libstd/rope.rs +++ b/src/libstd/rope.rs @@ -100,7 +100,7 @@ pub fn of_str(str: @~str) -> Rope { */ pub fn of_substr(str: @~str, byte_offset: uint, byte_len: uint) -> Rope { if byte_len == 0u { return node::Empty; } - if byte_offset + byte_len > str::len(*str) { fail; } + if byte_offset + byte_len > str::len(*str) { die!(); } return node::Content(node::of_substr(str, byte_offset, byte_len)); } @@ -246,9 +246,9 @@ Section: Transforming ropes pub fn sub_chars(rope: Rope, char_offset: uint, char_len: uint) -> Rope { if char_len == 0u { return node::Empty; } match (rope) { - node::Empty => fail, + node::Empty => die!(), node::Content(node) => if char_len > node::char_len(node) { - fail + die!() } else { return node::Content(node::sub_chars(node, char_offset, char_len)) } @@ -271,9 +271,9 @@ pub fn sub_chars(rope: Rope, char_offset: uint, char_len: uint) -> Rope { pub fn sub_bytes(rope: Rope, byte_offset: uint, byte_len: uint) -> Rope { if byte_len == 0u { return node::Empty; } match (rope) { - node::Empty => fail, + node::Empty => die!(), node::Content(node) =>if byte_len > node::byte_len(node) { - fail + die!() } else { return node::Content(node::sub_bytes(node, byte_offset, byte_len)) } @@ -550,7 +550,7 @@ pub pure fn byte_len(rope: Rope) -> uint { */ pub fn char_at(rope: Rope, pos: uint) -> char { match (rope) { - node::Empty => fail, + node::Empty => die!(), node::Content(x) => return node::char_at(x, pos) } } @@ -788,7 +788,7 @@ pub mod node { * * forest - The forest. This vector is progressively rewritten during * execution and should be discarded as meaningless afterwards. */ - pub fn tree_from_forest_destructive(forest: &[mut @Node]) -> @Node { + pub fn tree_from_forest_destructive(forest: &mut [@Node]) -> @Node { let mut i; let mut len = vec::len(forest); while len > 1u { @@ -1158,18 +1158,17 @@ pub mod node { use core::vec; pub struct T { - stack: ~[mut @Node], + mut stack: ~[@Node], mut stackpos: int, } pub fn empty() -> T { - let stack : ~[mut @Node] = ~[mut]; + let mut stack : ~[@Node] = ~[]; T { stack: stack, stackpos: -1 } } pub fn start(node: @Node) -> T { - let stack = vec::cast_to_mut( - vec::from_elem(height(node)+1u, node)); + let stack = vec::from_elem(height(node)+1u, node); T { stack: stack, stackpos: 0, diff --git a/src/libstd/serialize.rs b/src/libstd/serialize.rs index 91e1f05daae..4938ead9ea8 100644 --- a/src/libstd/serialize.rs +++ b/src/libstd/serialize.rs @@ -390,7 +390,7 @@ pub impl<D: Decoder, T: Decodable<D>> Option<T>: Decodable<D> { 0 => None, 1 => Some(d.read_enum_variant_arg( 0u, || Decodable::decode(d))), - _ => fail(fmt!("Bad variant for option: %u", i)) + _ => die!(fmt!("Bad variant for option: %u", i)) } } } diff --git a/src/libstd/sha1.rs b/src/libstd/sha1.rs index c2599864c90..a5c740c343c 100644 --- a/src/libstd/sha1.rs +++ b/src/libstd/sha1.rs @@ -85,7 +85,7 @@ pub fn sha1() -> Sha1 { st.len_high += 1u32; if st.len_high == 0u32 { // FIXME: Need better failure mode (#2346) - fail; + die!(); } } if st.msg_block_idx == msg_block_len { process_msg_block(st); } @@ -253,7 +253,7 @@ pub fn sha1() -> Sha1 { let rr = mk_result(&self); let mut s = ~""; for vec::each(rr) |b| { - s += uint::to_str(*b as uint, 16u); + s += uint::to_str_radix(*b as uint, 16u); } return s; } diff --git a/src/libstd/smallintmap.rs b/src/libstd/smallintmap.rs index f17fce28ea9..a21328b3d63 100644 --- a/src/libstd/smallintmap.rs +++ b/src/libstd/smallintmap.rs @@ -14,171 +14,161 @@ */ #[forbid(deprecated_mode)]; -use map; -use map::StdMap; - -use core::dvec::DVec; -use core::ops; +use core::container::{Container, Mutable, Map, Set}; use core::option::{Some, None}; -use core::option; use core::prelude::*; -// FIXME (#2347): Should not be @; there's a bug somewhere in rustc that -// requires this to be. -struct SmallIntMap_<T> { - v: DVec<Option<T>>, -} - -pub enum SmallIntMap<T> { - SmallIntMap_(@SmallIntMap_<T>) +pub struct SmallIntMap<T> { + priv v: ~[Option<T>], } -/// Create a smallintmap -pub fn mk<T: Copy>() -> SmallIntMap<T> { - let v = DVec(); - SmallIntMap_(@SmallIntMap_ { v: v } ) -} +impl<V> SmallIntMap<V>: Container { + /// Return the number of elements in the map + pure fn len(&self) -> uint { + let mut sz = 0; + for self.v.each |item| { + if item.is_some() { + sz += 1; + } + } + sz + } -/** - * Add a value to the map. If the map already contains a value for - * the specified key then the original value is replaced. - */ -#[inline(always)] -pub fn insert<T: Copy>(self: SmallIntMap<T>, key: uint, val: T) { - //io::println(fmt!("%?", key)); - self.v.grow_set_elt(key, &None, Some(val)); + /// Return true if the map contains no elements + pure fn is_empty(&self) -> bool { self.len() == 0 } } -/** - * Get the value for the specified key. If the key does not exist - * in the map then returns none - */ -pub pure fn find<T: Copy>(self: SmallIntMap<T>, key: uint) -> Option<T> { - if key < self.v.len() { return self.v.get_elt(key); } - return None::<T>; +impl<V> SmallIntMap<V>: Mutable { + /// Clear the map, removing all key-value pairs. + fn clear(&mut self) { self.v.clear() } } -/** - * Get the value for the specified key - * - * # Failure - * - * If the key does not exist in the map - */ -pub pure fn get<T: Copy>(self: SmallIntMap<T>, key: uint) -> T { - match find(self, key) { - None => { - error!("smallintmap::get(): key not present"); - fail; - } - Some(move v) => return v +impl<V> SmallIntMap<V>: Map<uint, V> { + /// Return true if the map contains a value for the specified key + pure fn contains_key(&self, key: &uint) -> bool { + self.find(key).is_some() } -} - -/// Returns true if the map contains a value for the specified key -pub pure fn contains_key<T: Copy>(self: SmallIntMap<T>, key: uint) -> bool { - return !find(self, key).is_none(); -} -/// Implements the map::map interface for smallintmap -impl<V: Copy> SmallIntMap<V>: map::StdMap<uint, V> { - pure fn size() -> uint { - let mut sz = 0u; - for self.v.each |item| { - match *item { - Some(_) => sz += 1u, - _ => () + /// Visit all key-value pairs + pure fn each(&self, it: fn(key: &uint, value: &V) -> bool) { + for uint::range(0, self.v.len()) |i| { + match self.v[i] { + Some(ref elt) => if !it(&i, elt) { break }, + None => () } } - sz - } - #[inline(always)] - fn insert(key: uint, value: V) -> bool { - let exists = contains_key(self, key); - insert(self, key, value); - return !exists; - } - fn remove(key: uint) -> bool { - if key >= self.v.len() { - return false; - } - let old = self.v.get_elt(key); - self.v.set_elt(key, None); - old.is_some() } - fn clear() { - self.v.set(~[]); - } - pure fn contains_key(key: uint) -> bool { - contains_key(self, key) + + /// Visit all keys + pure fn each_key(&self, blk: fn(key: &uint) -> bool) { + self.each(|k, _| blk(k)) } - pure fn contains_key_ref(key: &uint) -> bool { - contains_key(self, *key) + + /// Visit all values + pure fn each_value(&self, blk: fn(value: &V) -> bool) { + self.each(|_, v| blk(v)) } - pure fn get(key: uint) -> V { get(self, key) } - pure fn find(key: uint) -> Option<V> { find(self, key) } - fn update_with_key(key: uint, val: V, ff: fn(uint, V, V) -> V) -> bool { - match self.find(key) { - None => return self.insert(key, val), - Some(copy orig) => return self.insert(key, ff(key, orig, val)), + /// Return the value corresponding to the key in the map + pure fn find(&self, key: &uint) -> Option<&self/V> { + if *key < self.v.len() { + match self.v[*key] { + Some(ref value) => Some(value), + None => None + } + } else { + None } } - fn update(key: uint, newval: V, ff: fn(V, V) -> V) -> bool { - return self.update_with_key(key, newval, |_k, v, v1| ff(v,v1)); + /// Insert a key-value pair into the map. An existing value for a + /// key is replaced by the new value. Return true if the key did + /// not already exist in the map. + fn insert(&mut self, key: uint, value: V) -> bool { + let exists = self.contains_key(&key); + let len = self.v.len(); + if len <= key { + vec::grow_fn(&mut self.v, key - len + 1, |_| None); + } + self.v[key] = Some(value); + !exists } - pure fn each(it: fn(key: uint, value: V) -> bool) { - self.each_ref(|k, v| it(*k, *v)) - } - pure fn each_key(it: fn(key: uint) -> bool) { - self.each_ref(|k, _v| it(*k)) - } - pure fn each_value(it: fn(value: V) -> bool) { - self.each_ref(|_k, v| it(*v)) - } - pure fn each_ref(it: fn(key: &uint, value: &V) -> bool) { - let mut idx = 0u, l = self.v.len(); - while idx < l { - match self.v.get_elt(idx) { - Some(ref elt) => if !it(&idx, elt) { break }, - None => () - } - idx += 1u; + /// Remove a key-value pair from the map. Return true if the key + /// was present in the map, otherwise false. + fn remove(&mut self, key: &uint) -> bool { + if *key >= self.v.len() { + return false; } + let removed = self.v[*key].is_some(); + self.v[*key] = None; + removed } - pure fn each_key_ref(blk: fn(key: &uint) -> bool) { - self.each_ref(|k, _v| blk(k)) - } - pure fn each_value_ref(blk: fn(value: &V) -> bool) { - self.each_ref(|_k, v| blk(v)) +} + +pub impl<V> SmallIntMap<V> { + /// Create an empty SmallIntMap + static pure fn new() -> SmallIntMap<V> { SmallIntMap{v: ~[]} } + + pure fn get(&self, key: &uint) -> &self/V { + self.find(key).expect("key not present") } } -impl<V: Copy> SmallIntMap<V>: ops::Index<uint, V> { - pure fn index(&self, key: uint) -> V { - unsafe { - get(*self, key) +pub impl<V: Copy> SmallIntMap<V> { + // FIXME: #4733, remove after the next snapshot + #[cfg(stage2)] + fn update_with_key(&mut self, key: uint, val: V, + ff: fn(uint, V, V) -> V) -> bool { + match self.find(&key) { + None => self.insert(key, val), + Some(orig) => self.insert(key, ff(key, copy *orig, val)), } } -} -/// Cast the given smallintmap to a map::map -pub fn as_map<V: Copy>(s: SmallIntMap<V>) -> map::StdMap<uint, V> { - s as map::StdMap::<uint, V> + // FIXME: #4733, remove after the next snapshot + #[cfg(stage2)] + fn update(&mut self, key: uint, newval: V, ff: fn(V, V) -> V) -> bool { + self.update_with_key(key, newval, |_k, v, v1| ff(v,v1)) + } } #[cfg(test)] mod tests { - use smallintmap::{mk, SmallIntMap}; + use super::SmallIntMap; - use core::option::None; - use core::option; + #[test] + fn test_len() { + let mut map = SmallIntMap::new(); + assert map.len() == 0; + assert map.is_empty(); + assert map.insert(5, 20); + assert map.len() == 1; + assert !map.is_empty(); + assert map.insert(11, 12); + assert map.len() == 2; + assert !map.is_empty(); + assert map.insert(14, 22); + assert map.len() == 3; + assert !map.is_empty(); + } + + #[test] + fn test_clear() { + let mut map = SmallIntMap::new(); + assert map.insert(5, 20); + assert map.insert(11, 12); + assert map.insert(14, 22); + map.clear(); + assert map.is_empty(); + assert map.find(&5).is_none(); + assert map.find(&11).is_none(); + assert map.find(&14).is_none(); + } #[test] fn test_insert_with_key() { - let map: SmallIntMap<uint> = mk(); + let mut map = SmallIntMap::new(); // given a new key, initialize it with this new count, given // given an existing key, add more to its count @@ -198,11 +188,11 @@ mod tests { map.update_with_key(3, 2, addMoreToCount); // check the total counts - assert 10 == option::get(map.find(3)); - assert 3 == option::get(map.find(5)); - assert 1 == option::get(map.find(9)); + assert map.find(&3).get() == &10; + assert map.find(&5).get() == &3; + assert map.find(&9).get() == &1; // sadly, no sevens were counted - assert None == map.find(7); + assert map.find(&7).is_none(); } } diff --git a/src/libstd/sort.rs b/src/libstd/sort.rs index 577fea7769a..6e89cd9e24f 100644 --- a/src/libstd/sort.rs +++ b/src/libstd/sort.rs @@ -64,7 +64,7 @@ pub pure fn merge_sort<T: Copy>(v: &[const T], le: Le<T>) -> ~[T] { } } -fn part<T: Copy>(arr: &[mut T], left: uint, +fn part<T: Copy>(arr: &mut [T], left: uint, right: uint, pivot: uint, compare_func: Le<T>) -> uint { let pivot_value = arr[pivot]; arr[pivot] <-> arr[right]; @@ -81,7 +81,7 @@ fn part<T: Copy>(arr: &[mut T], left: uint, return storage_index; } -fn qsort<T: Copy>(arr: &[mut T], left: uint, +fn qsort<T: Copy>(arr: &mut [T], left: uint, right: uint, compare_func: Le<T>) { if right > left { let pivot = (left + right) / 2u; @@ -100,12 +100,12 @@ fn qsort<T: Copy>(arr: &[mut T], left: uint, * Has worst case O(n^2) performance, average case O(n log n). * This is an unstable sort. */ -pub fn quick_sort<T: Copy>(arr: &[mut T], compare_func: Le<T>) { +pub fn quick_sort<T: Copy>(arr: &mut [T], compare_func: Le<T>) { if len::<T>(arr) == 0u { return; } qsort::<T>(arr, 0u, len::<T>(arr) - 1u, compare_func); } -fn qsort3<T: Copy Ord Eq>(arr: &[mut T], left: int, right: int) { +fn qsort3<T: Copy Ord Eq>(arr: &mut [T], left: int, right: int) { if right <= left { return; } let v: T = arr[right]; let mut i: int = left - 1; @@ -162,7 +162,7 @@ fn qsort3<T: Copy Ord Eq>(arr: &[mut T], left: int, right: int) { * * This is an unstable sort. */ -pub fn quick_sort3<T: Copy Ord Eq>(arr: &[mut T]) { +pub fn quick_sort3<T: Copy Ord Eq>(arr: &mut [T]) { if arr.len() <= 1 { return; } qsort3(arr, 0, (arr.len() - 1) as int); } @@ -171,7 +171,7 @@ pub trait Sort { fn qsort(self); } -impl<T: Copy Ord Eq> &[mut T] : Sort { +impl<T: Copy Ord Eq> &mut [T] : Sort { fn qsort(self) { quick_sort3(self); } } @@ -179,7 +179,7 @@ const MIN_MERGE: uint = 64; const MIN_GALLOP: uint = 7; const INITIAL_TMP_STORAGE: uint = 128; -pub fn tim_sort<T: Copy Ord>(array: &[mut T]) { +pub fn tim_sort<T: Copy Ord>(array: &mut [T]) { let size = array.len(); if size < 2 { return; @@ -218,7 +218,7 @@ pub fn tim_sort<T: Copy Ord>(array: &[mut T]) { ms.merge_force_collapse(array); } -fn binarysort<T: Copy Ord>(array: &[mut T], start: uint) { +fn binarysort<T: Copy Ord>(array: &mut [T], start: uint) { let size = array.len(); let mut start = start; assert start <= size; @@ -249,7 +249,7 @@ fn binarysort<T: Copy Ord>(array: &[mut T], start: uint) { } // Reverse the order of elements in a slice, in place -fn reverse_slice<T>(v: &[mut T], start: uint, end:uint) { +fn reverse_slice<T>(v: &mut [T], start: uint, end:uint) { let mut i = start; while i < end / 2 { util::swap(&mut v[i], &mut v[end - i - 1]); @@ -268,7 +268,7 @@ pure fn min_run_length(n: uint) -> uint { return n + r; } -fn count_run_ascending<T: Copy Ord>(array: &[mut T]) -> uint { +fn count_run_ascending<T: Copy Ord>(array: &mut [T]) -> uint { let size = array.len(); assert size > 0; if size == 1 { return 1; } @@ -412,7 +412,7 @@ impl<T: Copy Ord> MergeState<T> { self.runs.push(tmp); } - fn merge_at(&self, n: uint, array: &[mut T]) { + fn merge_at(&self, n: uint, array: &mut [T]) { let mut size = self.runs.len(); assert size >= 2; assert n == size-2 || n == size-3; @@ -453,7 +453,7 @@ impl<T: Copy Ord> MergeState<T> { self.runs.pop(); } - fn merge_lo(&self, array: &[mut T], base1: uint, len1: uint, + fn merge_lo(&self, array: &mut [T], base1: uint, len1: uint, base2: uint, len2: uint) { assert len1 != 0 && len2 != 0 && base1+len1 == base2; @@ -548,7 +548,7 @@ impl<T: Copy Ord> MergeState<T> { copy_vec(array, dest, array, c2, len2); array[dest+len2] <-> tmp[c1]; } else if len1 == 0 { - fail ~"Comparison violates its contract!"; + die!(~"Comparison violates its contract!"); } else { assert len2 == 0; assert len1 > 1; @@ -556,7 +556,7 @@ impl<T: Copy Ord> MergeState<T> { } } - fn merge_hi(&self, array: &[mut T], base1: uint, len1: uint, + fn merge_hi(&self, array: &mut [T], base1: uint, len1: uint, base2: uint, len2: uint) { assert len1 != 1 && len2 != 0 && base1 + len1 == base2; @@ -666,7 +666,7 @@ impl<T: Copy Ord> MergeState<T> { copy_vec(array, dest+1, array, c1+1, len1); array[dest] <-> tmp[c2]; } else if len2 == 0 { - fail ~"Comparison violates its contract!"; + die!(~"Comparison violates its contract!"); } else { assert len1 == 0; assert len2 != 0; @@ -674,7 +674,7 @@ impl<T: Copy Ord> MergeState<T> { } } - fn merge_collapse(&self, array: &[mut T]) { + fn merge_collapse(&self, array: &mut [T]) { while self.runs.len() > 1 { let mut n = self.runs.len()-2; let chk = do self.runs.borrow |arr| { @@ -692,7 +692,7 @@ impl<T: Copy Ord> MergeState<T> { } } - fn merge_force_collapse(&self, array: &[mut T]) { + fn merge_force_collapse(&self, array: &mut [T]) { while self.runs.len() > 1 { let mut n = self.runs.len()-2; if n > 0 { @@ -708,7 +708,7 @@ impl<T: Copy Ord> MergeState<T> { } #[inline(always)] -fn copy_vec<T: Copy>(dest: &[mut T], s1: uint, +fn copy_vec<T: Copy>(dest: &mut [T], s1: uint, from: &[const T], s2: uint, len: uint) { assert s1+len <= dest.len() && s2+len <= from.len(); @@ -726,7 +726,7 @@ mod test_qsort3 { use core::vec; - pub fn check_sort(v1: &[mut int], v2: &[mut int]) { + pub fn check_sort(v1: &mut [int], v2: &mut [int]) { let len = vec::len::<int>(v1); quick_sort3::<int>(v1); let mut i = 0; @@ -740,24 +740,24 @@ mod test_qsort3 { #[test] pub fn test() { { - let v1 = ~[mut 3, 7, 4, 5, 2, 9, 5, 8]; - let v2 = ~[mut 2, 3, 4, 5, 5, 7, 8, 9]; + let mut v1 = ~[3, 7, 4, 5, 2, 9, 5, 8]; + let mut v2 = ~[2, 3, 4, 5, 5, 7, 8, 9]; check_sort(v1, v2); } { - let v1 = ~[mut 1, 1, 1]; - let v2 = ~[mut 1, 1, 1]; + let mut v1 = ~[1, 1, 1]; + let mut v2 = ~[1, 1, 1]; check_sort(v1, v2); } { - let v1: ~[mut int] = ~[mut]; - let v2: ~[mut int] = ~[mut]; + let mut v1: ~[int] = ~[]; + let mut v2: ~[int] = ~[]; check_sort(v1, v2); } - { let v1 = ~[mut 9]; let v2 = ~[mut 9]; check_sort(v1, v2); } + { let mut v1 = ~[9]; let mut v2 = ~[9]; check_sort(v1, v2); } { - let v1 = ~[mut 9, 3, 3, 3, 9]; - let v2 = ~[mut 3, 3, 3, 9, 9]; + let mut v1 = ~[9, 3, 3, 3, 9]; + let mut v2 = ~[3, 3, 3, 9, 9]; check_sort(v1, v2); } } @@ -772,7 +772,7 @@ mod test_qsort { use core::int; use core::vec; - pub fn check_sort(v1: &[mut int], v2: &[mut int]) { + pub fn check_sort(v1: &mut [int], v2: &mut [int]) { let len = vec::len::<int>(v1); pure fn leual(a: &int, b: &int) -> bool { *a <= *b } quick_sort::<int>(v1, leual); @@ -787,24 +787,24 @@ mod test_qsort { #[test] pub fn test() { { - let v1 = ~[mut 3, 7, 4, 5, 2, 9, 5, 8]; - let v2 = ~[mut 2, 3, 4, 5, 5, 7, 8, 9]; + let mut v1 = ~[3, 7, 4, 5, 2, 9, 5, 8]; + let mut v2 = ~[2, 3, 4, 5, 5, 7, 8, 9]; check_sort(v1, v2); } { - let v1 = ~[mut 1, 1, 1]; - let v2 = ~[mut 1, 1, 1]; + let mut v1 = ~[1, 1, 1]; + let mut v2 = ~[1, 1, 1]; check_sort(v1, v2); } { - let v1: ~[mut int] = ~[mut]; - let v2: ~[mut int] = ~[mut]; + let mut v1: ~[int] = ~[]; + let mut v2: ~[int] = ~[]; check_sort(v1, v2); } - { let v1 = ~[mut 9]; let v2 = ~[mut 9]; check_sort(v1, v2); } + { let mut v1 = ~[9]; let mut v2 = ~[9]; check_sort(v1, v2); } { - let v1 = ~[mut 9, 3, 3, 3, 9]; - let v2 = ~[mut 3, 3, 3, 9, 9]; + let mut v1 = ~[9, 3, 3, 3, 9]; + let mut v2 = ~[3, 3, 3, 9, 9]; check_sort(v1, v2); } } @@ -812,13 +812,13 @@ mod test_qsort { // Regression test for #750 #[test] pub fn test_simple() { - let names = ~[mut 2, 1, 3]; + let mut names = ~[2, 1, 3]; let expected = ~[1, 2, 3]; do quick_sort(names) |x, y| { int::le(*x, *y) }; - let immut_names = vec::cast_from_mut(move names); + let immut_names = move names; let pairs = vec::zip_slice(expected, immut_names); for vec::each(pairs) |p| { @@ -870,7 +870,7 @@ mod tests { #[test] pub fn test_merge_sort_mutable() { pub pure fn le(a: &int, b: &int) -> bool { *a <= *b } - let v1 = ~[mut 3, 2, 1]; + let mut v1 = ~[3, 2, 1]; let v2 = merge_sort(v1, le); assert v2 == ~[1, 2, 3]; } @@ -914,7 +914,7 @@ mod test_tim_sort { pure fn lt(&self, other: &CVal) -> bool { unsafe { let rng = rand::Rng(); - if rng.gen_float() > 0.995 { fail ~"It's happening!!!"; } + if rng.gen_float() > 0.995 { die!(~"It's happening!!!"); } } (*self).val < other.val } @@ -923,7 +923,7 @@ mod test_tim_sort { pure fn ge(&self, other: &CVal) -> bool { (*self).val >= other.val } } - fn check_sort(v1: &[mut int], v2: &[mut int]) { + fn check_sort(v1: &mut [int], v2: &mut [int]) { let len = vec::len::<int>(v1); tim_sort::<int>(v1); let mut i = 0u; @@ -937,24 +937,24 @@ mod test_tim_sort { #[test] fn test() { { - let v1 = ~[mut 3, 7, 4, 5, 2, 9, 5, 8]; - let v2 = ~[mut 2, 3, 4, 5, 5, 7, 8, 9]; + let mut v1 = ~[3, 7, 4, 5, 2, 9, 5, 8]; + let mut v2 = ~[2, 3, 4, 5, 5, 7, 8, 9]; check_sort(v1, v2); } { - let v1 = ~[mut 1, 1, 1]; - let v2 = ~[mut 1, 1, 1]; + let mut v1 = ~[1, 1, 1]; + let mut v2 = ~[1, 1, 1]; check_sort(v1, v2); } { - let v1: ~[mut int] = ~[mut]; - let v2: ~[mut int] = ~[mut]; + let mut v1: ~[int] = ~[]; + let mut v2: ~[int] = ~[]; check_sort(v1, v2); } - { let v1 = ~[mut 9]; let v2 = ~[mut 9]; check_sort(v1, v2); } + { let mut v1 = ~[9]; let mut v2 = ~[9]; check_sort(v1, v2); } { - let v1 = ~[mut 9, 3, 3, 3, 9]; - let v2 = ~[mut 3, 3, 3, 9, 9]; + let mut v1 = ~[9, 3, 3, 3, 9]; + let mut v2 = ~[3, 3, 3, 9, 9]; check_sort(v1, v2); } } @@ -970,7 +970,7 @@ mod test_tim_sort { }; tim_sort(arr); - fail ~"Guarantee the fail"; + die!(~"Guarantee the fail"); } struct DVal { val: uint } @@ -1019,12 +1019,12 @@ mod big_tests { tabulate_managed(low, high); } - fn multiplyVec<T: Copy>(arr: &[const T], num: uint) -> ~[mut T] { + fn multiplyVec<T: Copy>(arr: &[const T], num: uint) -> ~[T] { let size = arr.len(); let res = do vec::from_fn(num) |i| { arr[i % size] }; - vec::cast_to_mut(move res) + move res } fn makeRange(n: uint) -> ~[uint] { @@ -1038,7 +1038,7 @@ mod big_tests { fn isSorted<T: Ord>(arr: &[const T]) { for uint::range(0, arr.len()-1) |i| { if arr[i] > arr[i+1] { - fail ~"Array not sorted"; + die!(~"Array not sorted"); } } } @@ -1050,7 +1050,7 @@ mod big_tests { let arr = do vec::from_fn(n) |_i| { rng.gen_float() }; - let arr = vec::cast_to_mut(move arr); + let mut arr = move arr; tim_sort(arr); // *sort isSorted(arr); @@ -1088,7 +1088,7 @@ mod big_tests { tim_sort(arr); isSorted(arr); - let arr = if n > 4 { + let mut arr = if n > 4 { let part = vec::view(arr, 0, 4); multiplyVec(part, n) } else { move arr }; @@ -1110,7 +1110,7 @@ mod big_tests { fn isSorted<T: Ord>(arr: &[const @T]) { for uint::range(0, arr.len()-1) |i| { if arr[i] > arr[i+1] { - fail ~"Array not sorted"; + die!(~"Array not sorted"); } } } @@ -1122,7 +1122,7 @@ mod big_tests { let arr = do vec::from_fn(n) |_i| { @rng.gen_float() }; - let arr = vec::cast_to_mut(move arr); + let mut arr = move arr; tim_sort(arr); // *sort isSorted(arr); @@ -1160,7 +1160,7 @@ mod big_tests { tim_sort(arr); isSorted(arr); - let arr = if n > 4 { + let mut arr = if n > 4 { let part = vec::view(arr, 0, 4); multiplyVec(part, n) } else { move arr }; @@ -1193,7 +1193,7 @@ mod big_tests { task::local_data::local_data_set(self.key, @(y+1)); } } - _ => fail ~"Expected key to work", + _ => die!(~"Expected key to work"), } } } diff --git a/src/libstd/std.rc b/src/libstd/std.rc index 51b55b1c46f..65122bea750 100644 --- a/src/libstd/std.rc +++ b/src/libstd/std.rc @@ -79,10 +79,11 @@ pub mod bitv; pub mod deque; pub mod fun_treemap; pub mod list; -pub mod map; +pub mod oldmap; pub mod priority_queue; pub mod rope; pub mod smallintmap; +pub mod oldsmallintmap; pub mod sort; pub mod treemap; diff --git a/src/libstd/sync.rs b/src/libstd/sync.rs index bd9386845ae..31c596c5038 100644 --- a/src/libstd/sync.rs +++ b/src/libstd/sync.rs @@ -92,12 +92,12 @@ fn new_sem<Q: Owned>(count: int, q: Q) -> Sem<Q> { } #[doc(hidden)] fn new_sem_and_signal(count: int, num_condvars: uint) - -> Sem<~[mut Waitqueue]> { + -> Sem<~[Waitqueue]> { let mut queues = ~[]; for num_condvars.times { queues.push(new_waitqueue()); } - new_sem(count, vec::cast_to_mut(move queues)) + new_sem(count, queues) } #[doc(hidden)] @@ -150,7 +150,7 @@ impl &Sem<()> { } } #[doc(hidden)] -impl &Sem<~[mut Waitqueue]> { +impl &Sem<~[Waitqueue]> { fn access<U>(blk: fn() -> U) -> U { let mut release = None; unsafe { @@ -166,7 +166,7 @@ impl &Sem<~[mut Waitqueue]> { // FIXME(#3588) should go inside of access() #[doc(hidden)] type SemRelease = SemReleaseGeneric<()>; -type SemAndSignalRelease = SemReleaseGeneric<~[mut Waitqueue]>; +type SemAndSignalRelease = SemReleaseGeneric<~[Waitqueue]>; struct SemReleaseGeneric<Q> { sem: &Sem<Q> } impl<Q: Owned> SemReleaseGeneric<Q> : Drop { @@ -181,7 +181,7 @@ fn SemRelease(sem: &r/Sem<()>) -> SemRelease/&r { } } -fn SemAndSignalRelease(sem: &r/Sem<~[mut Waitqueue]>) +fn SemAndSignalRelease(sem: &r/Sem<~[Waitqueue]>) -> SemAndSignalRelease/&r { SemReleaseGeneric { sem: sem @@ -189,7 +189,7 @@ fn SemAndSignalRelease(sem: &r/Sem<~[mut Waitqueue]>) } /// A mechanism for atomic-unlock-and-deschedule blocking and signalling. -pub struct Condvar { priv sem: &Sem<~[mut Waitqueue]> } +pub struct Condvar { priv sem: &Sem<~[Waitqueue]> } impl Condvar : Drop { fn finalize(&self) {} } @@ -259,7 +259,7 @@ impl &Condvar { // mutex during unwinding. As long as the wrapper (mutex, etc) is // bounded in when it gets released, this shouldn't hang forever. struct SemAndSignalReacquire { - sem: &Sem<~[mut Waitqueue]>, + sem: &Sem<~[Waitqueue]>, } impl SemAndSignalReacquire : Drop { @@ -273,7 +273,7 @@ impl &Condvar { } } - fn SemAndSignalReacquire(sem: &r/Sem<~[mut Waitqueue]>) + fn SemAndSignalReacquire(sem: &r/Sem<~[Waitqueue]>) -> SemAndSignalReacquire/&r { SemAndSignalReacquire { sem: sem @@ -335,17 +335,17 @@ fn check_cvar_bounds<U>(out_of_bounds: Option<uint>, id: uint, act: &str, blk: fn() -> U) -> U { match out_of_bounds { Some(0) => - fail fmt!("%s with illegal ID %u - this lock has no condvars!", - act, id), + die!(fmt!("%s with illegal ID %u - this lock has no condvars!", + act, id)), Some(length) => - fail fmt!("%s with illegal ID %u - ID must be less than %u", - act, id, length), + die!(fmt!("%s with illegal ID %u - ID must be less than %u", + act, id, length)), None => blk() } } #[doc(hidden)] -impl &Sem<~[mut Waitqueue]> { +impl &Sem<~[Waitqueue]> { // The only other place that condvars get built is rwlock_write_mode. fn access_cond<U>(blk: fn(c: &Condvar) -> U) -> U { do self.access { blk(&Condvar { sem: self }) } @@ -400,7 +400,7 @@ impl &Semaphore { * A task which fails while holding a mutex will unlock the mutex as it * unwinds. */ -struct Mutex { priv sem: Sem<~[mut Waitqueue]> } +struct Mutex { priv sem: Sem<~[Waitqueue]> } /// Create a new mutex, with one associated condvar. pub fn Mutex() -> Mutex { mutex_with_condvars(1) } @@ -450,7 +450,7 @@ struct RWlockInner { */ struct RWlock { priv order_lock: Semaphore, - priv access_lock: Sem<~[mut Waitqueue]>, + priv access_lock: Sem<~[Waitqueue]>, priv state: Exclusive<RWlockInner> } @@ -582,7 +582,7 @@ impl &RWlock { /// To be called inside of the write_downgrade block. fn downgrade(token: RWlockWriteMode/&a) -> RWlockReadMode/&a { if !ptr::ref_eq(self, token.lock) { - fail ~"Can't downgrade() with a different rwlock's write_mode!"; + die!(~"Can't downgrade() with a different rwlock's write_mode!"); } unsafe { do task::unkillable { @@ -935,7 +935,7 @@ mod tests { let result: result::Result<(),()> = do task::try |move m2| { do m2.lock { - fail; + die!(); } }; assert result.is_err(); @@ -954,7 +954,7 @@ mod tests { do task::spawn |move p| { // linked let _ = p.recv(); // wait for sibling to get in the mutex task::yield(); - fail; + die!(); } do m2.lock_cond |cond| { c.send(()); // tell sibling go ahead @@ -996,7 +996,7 @@ mod tests { } do m2.lock { } c.send(move sibling_convos); // let parent wait on all children - fail; + die!(); }; assert result.is_err(); // child task must have finished by the time try returns @@ -1050,7 +1050,7 @@ mod tests { let _ = p.recv(); do m.lock_cond |cond| { if !cond.signal_on(0) { - fail; // success; punt sibling awake. + die!(); // success; punt sibling awake. } } }; @@ -1290,7 +1290,7 @@ mod tests { let result: result::Result<(),()> = do task::try |move x2| { do lock_rwlock_in_mode(x2, mode1) { - fail; + die!(); } }; assert result.is_err(); diff --git a/src/libstd/test.rs b/src/libstd/test.rs index 58bc32b71af..5a2693a42c1 100644 --- a/src/libstd/test.rs +++ b/src/libstd/test.rs @@ -68,9 +68,9 @@ pub fn test_main(args: &[~str], tests: &[TestDesc]) { let opts = match parse_opts(args) { either::Left(move o) => o, - either::Right(move m) => fail m + either::Right(move m) => die!(m) }; - if !run_tests_console(&opts, tests) { fail ~"Some tests failed"; } + if !run_tests_console(&opts, tests) { die!(~"Some tests failed"); } } pub struct TestOpts { @@ -167,7 +167,7 @@ pub fn run_tests_console(opts: &TestOpts, ~[io::Create, io::Truncate]) { result::Ok(w) => Some(w), result::Err(ref s) => { - fail(fmt!("can't open output file: %s", *s)) + die!(fmt!("can't open output file: %s", *s)) } }, None => None @@ -446,7 +446,7 @@ mod tests { #[test] pub fn do_not_run_ignored_tests() { - fn f() { fail; } + fn f() { die!(); } let desc = TestDesc { name: ~"whatever", testfn: f, @@ -479,7 +479,7 @@ mod tests { #[test] #[ignore(cfg(windows))] pub fn test_should_fail() { - fn f() { fail; } + fn f() { die!(); } let desc = TestDesc { name: ~"whatever", testfn: f, @@ -514,7 +514,7 @@ mod tests { let args = ~[~"progname", ~"filter"]; let opts = match parse_opts(args) { either::Left(copy o) => o, - _ => fail ~"Malformed arg in first_free_arg_should_be_a_filter" + _ => die!(~"Malformed arg in first_free_arg_should_be_a_filter") }; assert ~"filter" == opts.filter.get(); } @@ -524,7 +524,7 @@ mod tests { let args = ~[~"progname", ~"filter", ~"--ignored"]; let opts = match parse_opts(args) { either::Left(copy o) => o, - _ => fail ~"Malformed arg in parse_ignored_flag" + _ => die!(~"Malformed arg in parse_ignored_flag") }; assert (opts.run_ignored); } diff --git a/src/libstd/time.rs b/src/libstd/time.rs index 4217e9fb058..dd25fc36d2d 100644 --- a/src/libstd/time.rs +++ b/src/libstd/time.rs @@ -926,7 +926,7 @@ mod tests { let s0 = precise_time_s(); let ns1 = precise_time_ns(); - log(debug, ~"s0=" + float::to_str(s0, 9u) + ~" sec"); + log(debug, ~"s0=" + float::to_str_digits(s0, 9u) + ~" sec"); assert s0 > 0.; let ns0 = (s0 * 1000000000.) as u64; log(debug, ~"ns0=" + u64::str(ns0) + ~" ns"); @@ -1042,7 +1042,7 @@ mod tests { == Err(~"Invalid time"); match strptime(~"Fri Feb 13 15:31:30 2009", format) { - Err(copy e) => fail e, + Err(copy e) => die!(e), Ok(ref tm) => { assert tm.tm_sec == 30_i32; assert tm.tm_min == 31_i32; @@ -1062,7 +1062,7 @@ mod tests { fn test(s: &str, format: &str) -> bool { match strptime(s, format) { Ok(ref tm) => tm.strftime(format) == str::from_slice(s), - Err(copy e) => fail e + Err(copy e) => die!(e) } } diff --git a/src/libstd/timer.rs b/src/libstd/timer.rs index b967f92a22e..f89830ed12a 100644 --- a/src/libstd/timer.rs +++ b/src/libstd/timer.rs @@ -69,13 +69,13 @@ pub fn delayed_send<T: Owned>(iotask: &IoTask, } else { let error_msg = uv::ll::get_last_err_info( loop_ptr); - fail ~"timer::delayed_send() start failed: " + - error_msg; + die!(~"timer::delayed_send() start failed: " + + error_msg); } } else { let error_msg = uv::ll::get_last_err_info(loop_ptr); - fail ~"timer::delayed_send() init failed: " + - error_msg; + die!(~"timer::delayed_send() init failed: " + + error_msg); } } }; @@ -159,7 +159,7 @@ extern fn delayed_send_cb(handle: *uv::ll::uv_timer_t, } else { let loop_ptr = uv::ll::get_loop_for_uv_handle(handle); let error_msg = uv::ll::get_last_err_info(loop_ptr); - fail ~"timer::sleep() init failed: "+error_msg; + die!(~"timer::sleep() init failed: "+error_msg); } } } diff --git a/src/libstd/uv_global_loop.rs b/src/libstd/uv_global_loop.rs index 8ae3e24abee..736954f6b22 100644 --- a/src/libstd/uv_global_loop.rs +++ b/src/libstd/uv_global_loop.rs @@ -185,14 +185,12 @@ mod test { let start_status = ll::timer_start(timer_ptr, simple_timer_cb, 1u, 0u); - if(start_status == 0i32) { - } - else { - fail ~"failure on ll::timer_start()"; + if(start_status != 0i32) { + die!(~"failure on ll::timer_start()"); } } else { - fail ~"failure on ll::timer_init()"; + die!(~"failure on ll::timer_init()"); } } }; diff --git a/src/libstd/workcache.rs b/src/libstd/workcache.rs index f9a2f934e46..4e9df14419b 100644 --- a/src/libstd/workcache.rs +++ b/src/libstd/workcache.rs @@ -380,7 +380,7 @@ fn unwrap<T:Owned ww.res <-> s; match move s { - None => fail, + None => die!(), Some(Left(move v)) => move v, Some(Right(move port)) => { diff --git a/src/libsyntax/ast.rs b/src/libsyntax/ast.rs index e85f41c54a2..bc808495ca3 100644 --- a/src/libsyntax/ast.rs +++ b/src/libsyntax/ast.rs @@ -10,7 +10,7 @@ // The Rust abstract syntax tree. -use codemap::{span, FileName}; +use codemap::{span, FileName, spanned}; use core::cast; use core::cmp; @@ -21,10 +21,6 @@ use core::to_bytes; use core::to_str::ToStr; use std::serialize::{Encodable, Decodable, Encoder, Decoder}; -#[auto_encode] -#[auto_decode] -pub struct spanned<T> { node: T, span: span } - /* can't import macros yet, so this is copied from token.rs. See its comment * there. */ macro_rules! interner_key ( @@ -40,7 +36,7 @@ pub impl<S: Encoder> ident: Encodable<S> { let intr = match unsafe { task::local_data::local_data_get(interner_key!()) } { - None => fail ~"encode: TLS interner not set up", + None => die!(~"encode: TLS interner not set up"), Some(intr) => intr }; @@ -53,7 +49,7 @@ pub impl<D: Decoder> ident: Decodable<D> { let intr = match unsafe { task::local_data::local_data_get(interner_key!()) } { - None => fail ~"decode: TLS interner not set up", + None => die!(~"decode: TLS interner not set up"), Some(intr) => intr }; @@ -690,7 +686,7 @@ pub enum expr_ { expr_cast(@expr, @Ty), expr_if(@expr, blk, Option<@expr>), expr_while(@expr, blk), - /* Conditionless loop (can be exited with break, cont, ret, or fail) + /* Conditionless loop (can be exited with break, cont, or ret) Same semantics as while(true) { body }, but typestate knows that the (implicit) condition is always true. */ expr_loop(blk, Option<ident>), @@ -716,7 +712,6 @@ pub 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>), @@ -928,8 +923,8 @@ pub enum trait_method { pub enum int_ty { ty_i, ty_char, ty_i8, ty_i16, ty_i32, ty_i64, } pub impl int_ty : ToStr { - pure fn to_str() -> ~str { - ::ast_util::int_ty_to_str(self) + pure fn to_str(&self) -> ~str { + ::ast_util::int_ty_to_str(*self) } } @@ -964,8 +959,8 @@ pub impl int_ty : cmp::Eq { pub enum uint_ty { ty_u, ty_u8, ty_u16, ty_u32, ty_u64, } pub impl uint_ty : ToStr { - pure fn to_str() -> ~str { - ::ast_util::uint_ty_to_str(self) + pure fn to_str(&self) -> ~str { + ::ast_util::uint_ty_to_str(*self) } } @@ -998,8 +993,8 @@ pub impl uint_ty : cmp::Eq { pub enum float_ty { ty_f, ty_f32, ty_f64, } pub impl float_ty : ToStr { - pure fn to_str() -> ~str { - ::ast_util::float_ty_to_str(self) + pure fn to_str(&self) -> ~str { + ::ast_util::float_ty_to_str(*self) } } @@ -1101,8 +1096,8 @@ pub enum Onceness { } pub impl Onceness : ToStr { - pure fn to_str() -> ~str { - match self { + pure fn to_str(&self) -> ~str { + match *self { Once => ~"once", Many => ~"many" } @@ -1193,8 +1188,8 @@ pub enum purity { } pub impl purity : ToStr { - pure fn to_str() -> ~str { - match self { + pure fn to_str(&self) -> ~str { + match *self { impure_fn => ~"impure", unsafe_fn => ~"unsafe", pure_fn => ~"pure", diff --git a/src/libsyntax/ast_map.rs b/src/libsyntax/ast_map.rs index a96829ed063..e6a4639ad80 100644 --- a/src/libsyntax/ast_map.rs +++ b/src/libsyntax/ast_map.rs @@ -25,8 +25,8 @@ use core::cmp; use core::either; use core::str; use core::vec; -use std::map::HashMap; -use std::map; +use std::oldmap::HashMap; +use std::oldmap; use std; pub enum path_elt { @@ -106,7 +106,7 @@ pub enum ast_node { node_struct_ctor(@struct_def, @item, @path), } -pub type map = std::map::HashMap<node_id, ast_node>; +pub type map = std::oldmap::HashMap<node_id, ast_node>; pub struct ctx { map: map, mut path: path, @@ -134,7 +134,7 @@ pub fn mk_ast_map_visitor() -> vt { pub fn map_crate(diag: span_handler, c: crate) -> map { let cx = ctx { - map: std::map::HashMap(), + map: std::oldmap::HashMap(), mut path: ~[], mut local_id: 0u, diag: diag, @@ -316,7 +316,7 @@ pub fn map_struct_def(struct_def: @ast::struct_def, parent_node: ast_node, cx.map.insert(ctor_id, node_struct_ctor(struct_def, item, p)); } - _ => fail ~"struct def parent wasn't an item" + _ => die!(~"struct def parent wasn't an item") } } } @@ -400,7 +400,7 @@ pub fn node_item_query<Result>(items: map, id: node_id, error_msg: ~str) -> Result { match items.find(id) { Some(node_item(it, _)) => query(it), - _ => fail(error_msg) + _ => die!(error_msg) } } diff --git a/src/libsyntax/ast_util.rs b/src/libsyntax/ast_util.rs index 1ae23240404..c659d6d6020 100644 --- a/src/libsyntax/ast_util.rs +++ b/src/libsyntax/ast_util.rs @@ -13,7 +13,7 @@ use core::prelude::*; use ast::*; use ast; use ast_util; -use codemap::{span, BytePos}; +use codemap::{span, BytePos, dummy_sp}; use parse::token; use visit; @@ -24,28 +24,6 @@ use core::str; use core::to_bytes; use core::vec; -pub pure fn spanned<T>(+lo: BytePos, +hi: BytePos, +t: T) -> spanned<T> { - respan(mk_sp(lo, hi), move t) -} - -pub pure fn respan<T>(sp: span, +t: T) -> spanned<T> { - spanned {node: t, span: sp} -} - -pub pure fn dummy_spanned<T>(+t: T) -> spanned<T> { - respan(dummy_sp(), move t) -} - -/* assuming that we're not in macro expansion */ -pub pure fn mk_sp(+lo: BytePos, +hi: BytePos) -> span { - span {lo: lo, hi: hi, expn_info: None} -} - -// make this a const, once the compiler supports it -pub pure fn dummy_sp() -> span { return mk_sp(BytePos(0), BytePos(0)); } - - - pub pure fn path_name_i(idents: &[ident], intr: @token::ident_interner) -> ~str { // FIXME: Bad copies (#2543 -- same for everything else that says "bad") @@ -66,7 +44,7 @@ pub pure fn stmt_id(s: stmt) -> node_id { stmt_decl(_, id) => id, stmt_expr(_, id) => id, stmt_semi(_, id) => id, - stmt_mac(*) => fail ~"attempted to analyze unexpanded stmt", + stmt_mac(*) => die!(~"attempted to analyze unexpanded stmt") } } @@ -75,7 +53,7 @@ pub fn variant_def_ids(d: def) -> {enm: def_id, var: def_id} { def_variant(enum_id, var_id) => { return {enm: enum_id, var: var_id} } - _ => fail ~"non-variant in variant_def_ids" + _ => die!(~"non-variant in variant_def_ids") } } @@ -93,7 +71,7 @@ pub pure fn def_id_of_def(d: def) -> def_id { local_def(id) } - def_prim_ty(_) => fail + def_prim_ty(_) => die!() } } @@ -320,38 +298,38 @@ pub pure fn struct_field_visibility(field: ast::struct_field) -> visibility { } pub trait inlined_item_utils { - fn ident() -> ident; - fn id() -> ast::node_id; - fn accept<E>(e: E, v: visit::vt<E>); + fn ident(&self) -> ident; + fn id(&self) -> ast::node_id; + fn accept<E>(&self, e: E, v: visit::vt<E>); } pub impl inlined_item: inlined_item_utils { - fn ident() -> ident { - match self { - ii_item(i) => /* FIXME (#2543) */ copy i.ident, - ii_foreign(i) => /* FIXME (#2543) */ copy i.ident, - ii_method(_, m) => /* FIXME (#2543) */ copy m.ident, - ii_dtor(_, nm, _, _) => /* FIXME (#2543) */ copy nm + fn ident(&self) -> ident { + match *self { + ii_item(i) => /* FIXME (#2543) */ copy i.ident, + ii_foreign(i) => /* FIXME (#2543) */ copy i.ident, + ii_method(_, m) => /* FIXME (#2543) */ copy m.ident, + ii_dtor(_, nm, _, _) => /* FIXME (#2543) */ copy nm } } - fn id() -> ast::node_id { - match self { - ii_item(i) => i.id, - ii_foreign(i) => i.id, - ii_method(_, m) => m.id, - ii_dtor(ref dtor, _, _, _) => (*dtor).node.id + fn id(&self) -> ast::node_id { + match *self { + ii_item(i) => i.id, + ii_foreign(i) => i.id, + ii_method(_, m) => m.id, + ii_dtor(ref dtor, _, _, _) => (*dtor).node.id } } - fn accept<E>(e: E, v: visit::vt<E>) { - match self { - ii_item(i) => (v.visit_item)(i, e, v), - ii_foreign(i) => (v.visit_foreign_item)(i, e, v), - ii_method(_, m) => visit::visit_method_helper(m, e, v), - ii_dtor(ref dtor, _, tps, parent_id) => { + fn accept<E>(&self, e: E, v: visit::vt<E>) { + match *self { + ii_item(i) => (v.visit_item)(i, e, v), + ii_foreign(i) => (v.visit_foreign_item)(i, e, v), + ii_method(_, m) => visit::visit_method_helper(m, e, v), + ii_dtor(ref dtor, _, tps, parent_id) => { visit::visit_struct_dtor_helper((*dtor), tps, parent_id, e, v); - } + } } } } diff --git a/src/libsyntax/attr.rs b/src/libsyntax/attr.rs index dd6a996b730..ca28641c4a3 100644 --- a/src/libsyntax/attr.rs +++ b/src/libsyntax/attr.rs @@ -13,7 +13,7 @@ use core::prelude::*; use ast; -use ast_util::{spanned, dummy_spanned}; +use codemap::{spanned, dummy_spanned}; use attr; use codemap::BytePos; use diagnostic::span_handler; @@ -24,8 +24,8 @@ use core::either::Either; use core::either; use core::option; use core::vec; -use std::map::HashMap; -use std::map; +use std::oldmap::HashMap; +use std::oldmap; use std; /* Constructors */ @@ -199,7 +199,7 @@ fn eq(a: @ast::meta_item, b: @ast::meta_item) -> bool { // FIXME (#607): Needs implementing // This involves probably sorting the list by name and // meta_item variant - fail ~"unimplemented meta_item variant" + die!(~"unimplemented meta_item variant") } } } @@ -269,9 +269,9 @@ pub fn sort_meta_items(+items: ~[@ast::meta_item]) -> ~[@ast::meta_item] { } // This is sort of stupid here, converting to a vec of mutables and back - let v: ~[mut @ast::meta_item] = vec::cast_to_mut(items); + let mut v: ~[@ast::meta_item] = items; std::sort::quick_sort(v, lteq); - vec::cast_from_mut(move v) + move v } pub fn remove_meta_items_by_name(items: ~[@ast::meta_item], name: ~str) -> @@ -358,12 +358,12 @@ pub fn find_inline_attr(attrs: &[ast::attribute]) -> inline_attr { pub fn require_unique_names(diagnostic: span_handler, metas: &[@ast::meta_item]) { - let map = map::HashMap(); + let map = oldmap::HashMap(); for metas.each |meta| { let name = get_meta_item_name(*meta); // FIXME: How do I silence the warnings? --pcw (#2619) - if map.contains_key(name) { + if map.contains_key_ref(&name) { diagnostic.span_fatal(meta.span, fmt!("duplicate meta item `%s`", name)); } diff --git a/src/libsyntax/codemap.rs b/src/libsyntax/codemap.rs index 980d4a236e0..31ed65d8065 100644 --- a/src/libsyntax/codemap.rs +++ b/src/libsyntax/codemap.rs @@ -23,8 +23,6 @@ source code snippets, etc. use core::prelude::*; -use ast_util; - use core::cmp; use core::dvec::DVec; use core::str; @@ -130,6 +128,10 @@ pub struct span { expn_info: Option<@ExpnInfo> } +#[auto_encode] +#[auto_decode] +pub struct spanned<T> { node: T, span: span } + pub impl span : cmp::Eq { pure fn eq(&self, other: &span) -> bool { return (*self).lo == (*other).lo && (*self).hi == (*other).hi; @@ -144,10 +146,32 @@ pub impl<S: Encoder> span: Encodable<S> { pub impl<D: Decoder> span: Decodable<D> { static fn decode(_d: &D) -> span { - ast_util::dummy_sp() + dummy_sp() } } +pub pure fn spanned<T>(+lo: BytePos, +hi: BytePos, +t: T) -> spanned<T> { + respan(mk_sp(lo, hi), move t) +} + +pub pure fn respan<T>(sp: span, +t: T) -> spanned<T> { + spanned {node: t, span: sp} +} + +pub pure fn dummy_spanned<T>(+t: T) -> spanned<T> { + respan(dummy_sp(), move t) +} + +/* assuming that we're not in macro expansion */ +pub pure fn mk_sp(+lo: BytePos, +hi: BytePos) -> span { + span {lo: lo, hi: hi, expn_info: None} +} + +// make this a const, once the compiler supports it +pub pure fn dummy_sp() -> span { return mk_sp(BytePos(0), BytePos(0)); } + + + /// A source code location used for error reporting pub struct Loc { /// Information about the original source @@ -158,6 +182,20 @@ pub struct Loc { col: CharPos } +/// A source code location used as the result of lookup_char_pos_adj +// Actually, *none* of the clients use the filename *or* file field; +// perhaps they should just be removed. +pub struct LocWithOpt { + filename: ~str, + line: uint, + col: CharPos, + file: Option<@FileMap>, +} + +// used to be structural records. Better names, anyone? +pub struct FileMapAndLine {fm: @FileMap, line: uint} +pub struct FileMapAndBytePos {fm: @FileMap, pos: BytePos} + /// Extra information for tracking macro expansion of spans pub enum ExpnInfo { ExpandedFrom({call_site: span, @@ -204,10 +242,19 @@ pub struct FileMap { } pub impl FileMap { + // EFFECT: register a start-of-line offset in the + // table of line-beginnings. + // UNCHECKED INVARIANT: these offsets must be added in the right + // order and must be in the right places; there is shared knowledge + // about what ends a line between this file and parse.rs fn next_line(&self, +pos: BytePos) { + // the new charpos must be > the last one (or it's the first one). + assert ((self.lines.len() == 0) + || (self.lines[self.lines.len() - 1] < pos)); self.lines.push(pos); } + // get a line from the list of pre-computed line-beginnings pub fn get_line(&self, line: int) -> ~str { unsafe { let begin: BytePos = self.lines[line] - self.start_pos; @@ -279,27 +326,25 @@ pub impl CodeMap { return self.lookup_pos(pos); } - pub fn lookup_char_pos_adj(&self, +pos: BytePos) - -> {filename: ~str, line: uint, col: CharPos, file: Option<@FileMap>} + pub fn lookup_char_pos_adj(&self, +pos: BytePos) -> LocWithOpt { let loc = self.lookup_char_pos(pos); match (loc.file.substr) { - FssNone => { - {filename: /* FIXME (#2543) */ copy loc.file.name, - line: loc.line, - col: loc.col, - file: Some(loc.file)} - } - FssInternal(sp) => { - self.lookup_char_pos_adj( - sp.lo + (pos - loc.file.start_pos)) - } - FssExternal(ref eloc) => { - {filename: /* FIXME (#2543) */ copy (*eloc).filename, - line: (*eloc).line + loc.line - 1u, - col: if loc.line == 1 {eloc.col + loc.col} else {loc.col}, - file: None} - } + FssNone => + LocWithOpt { + filename: /* FIXME (#2543) */ copy loc.file.name, + line: loc.line, + col: loc.col, + file: Some(loc.file)}, + FssInternal(sp) => + self.lookup_char_pos_adj( + sp.lo + (pos - loc.file.start_pos)), + FssExternal(ref eloc) => + LocWithOpt { + filename: /* FIXME (#2543) */ copy (*eloc).filename, + line: (*eloc).line + loc.line - 1u, + col: if loc.line == 1 {eloc.col + loc.col} else {loc.col}, + file: None} } } @@ -319,7 +364,7 @@ pub impl CodeMap { } pub fn span_to_str(&self, sp: span) -> ~str { - if self.files.len() == 0 && sp == ast_util::dummy_sp() { + if self.files.len() == 0 && sp == dummy_sp() { return ~"no-location"; } @@ -356,7 +401,7 @@ pub impl CodeMap { for self.files.each |fm| { if fm.name == filename { return *fm; } } //XXjdm the following triggers a mismatched type bug // (or expected function, found _|_) - fail; // ("asking for " + filename + " which we don't know about"); + die!(); // ("asking for " + filename + " which we don't know about"); } } @@ -376,15 +421,14 @@ priv impl CodeMap { } } if (a >= len) { - fail fmt!("position %u does not resolve to a source location", - pos.to_uint()) + die!(fmt!("position %u does not resolve to a source location", + pos.to_uint())) } return a; } - fn lookup_line(&self, +pos: BytePos) - -> {fm: @FileMap, line: uint} + fn lookup_line(&self, pos: BytePos) -> FileMapAndLine { let idx = self.lookup_filemap_idx(pos); let f = self.files[idx]; @@ -394,11 +438,11 @@ priv impl CodeMap { let m = (a + b) / 2u; if f.lines[m] > pos { b = m; } else { a = m; } } - return {fm: f, line: a}; + return FileMapAndLine {fm: f, line: a}; } fn lookup_pos(&self, +pos: BytePos) -> Loc { - let {fm: f, line: a} = self.lookup_line(pos); + let FileMapAndLine {fm: f, line: a} = self.lookup_line(pos); let line = a + 1u; // Line numbers start at 1 let chpos = self.bytepos_to_local_charpos(pos); let linebpos = f.lines[a]; @@ -424,11 +468,11 @@ priv impl CodeMap { } fn lookup_byte_offset(&self, +bpos: BytePos) - -> {fm: @FileMap, pos: BytePos} { + -> FileMapAndBytePos { let idx = self.lookup_filemap_idx(bpos); let fm = self.files[idx]; let offset = bpos - fm.start_pos; - return {fm: fm, pos: offset}; + return FileMapAndBytePos {fm: fm, pos: offset}; } // Converts an absolute BytePos to a CharPos relative to the file it is @@ -458,6 +502,36 @@ priv impl CodeMap { } } +#[cfg(test)] +mod test { + use super::*; + use util::testing::check_equal; + + #[test] + fn t1 () { + let cm = CodeMap::new(); + let fm = cm.new_filemap(~"blork.rs",@~"first line.\nsecond line"); + fm.next_line(BytePos(0)); + check_equal(&fm.get_line(0),&~"first line."); + // TESTING BROKEN BEHAVIOR: + fm.next_line(BytePos(10)); + check_equal(&fm.get_line(1),&~"."); + } + + #[test] + #[should_fail] + fn t2 () { + let cm = CodeMap::new(); + let fm = cm.new_filemap(~"blork.rs",@~"first line.\nsecond line"); + // TESTING *REALLY* BROKEN BEHAVIOR: + fm.next_line(BytePos(0)); + fm.next_line(BytePos(10)); + fm.next_line(BytePos(2)); + } +} + + + // // Local Variables: // mode: rust diff --git a/src/libsyntax/diagnostic.rs b/src/libsyntax/diagnostic.rs index d2f6b7956ef..c454f5dde2b 100644 --- a/src/libsyntax/diagnostic.rs +++ b/src/libsyntax/diagnostic.rs @@ -63,7 +63,7 @@ struct codemap_t { impl codemap_t: span_handler { fn span_fatal(sp: span, msg: &str) -> ! { self.handler.emit(Some((self.cm, sp)), msg, fatal); - fail; + die!(); } fn span_err(sp: span, msg: &str) { self.handler.emit(Some((self.cm, sp)), msg, error); @@ -89,7 +89,7 @@ impl codemap_t: span_handler { impl handler_t: handler { fn fatal(msg: &str) -> ! { (self.emit)(None, msg, fatal); - fail; + die!(); } fn err(msg: &str) { (self.emit)(None, msg, error); diff --git a/src/libsyntax/ext/auto_encode.rs b/src/libsyntax/ext/auto_encode.rs index a2484e2d6df..03aa0cde811 100644 --- a/src/libsyntax/ext/auto_encode.rs +++ b/src/libsyntax/ext/auto_encode.rs @@ -98,8 +98,8 @@ use ext::base::*; use parse; use core::vec; -use std::map; -use std::map::HashMap; +use std::oldmap; +use std::oldmap::HashMap; // Transitional reexports so qquote can find the paths it is looking for mod syntax { @@ -311,7 +311,7 @@ priv impl ext_ctxt { } fn stmt(expr: @ast::expr) -> @ast::stmt { - @ast::spanned { node: ast::stmt_semi(expr, self.next_id()), + @codemap::spanned { node: ast::stmt_semi(expr, self.next_id()), span: expr.span } } @@ -322,7 +322,7 @@ priv impl ext_ctxt { self.expr( span, ast::expr_lit( - @ast::spanned { node: ast::lit_str(s), + @codemap::spanned { node: ast::lit_str(s), span: span})), ast::expr_vstore_uniq)) } @@ -331,7 +331,7 @@ priv impl ext_ctxt { self.expr( span, ast::expr_lit( - @ast::spanned { node: ast::lit_uint(i as u64, ast::ty_u), + @codemap::spanned { node: ast::lit_uint(i as u64, ast::ty_u), span: span})) } @@ -342,7 +342,7 @@ priv impl ext_ctxt { } fn blk(span: span, stmts: ~[@ast::stmt]) -> ast::blk { - ast::spanned { + codemap::spanned { node: ast::blk_ { view_items: ~[], stmts: stmts, @@ -355,7 +355,7 @@ priv impl ext_ctxt { } fn expr_blk(expr: @ast::expr) -> ast::blk { - ast::spanned { + codemap::spanned { node: ast::blk_ { view_items: ~[], stmts: ~[], @@ -593,7 +593,7 @@ fn mk_ser_method( ident: cx.ident_of(~"encode"), attrs: ~[], tps: ~[], - self_ty: ast::spanned { node: ast::sty_region(ast::m_imm), + self_ty: codemap::spanned { node: ast::sty_region(ast::m_imm), span: span }, purity: ast::impure_fn, decl: ser_decl, @@ -651,7 +651,7 @@ fn mk_deser_method( ident: cx.ident_of(~"decode"), attrs: ~[], tps: ~[], - self_ty: ast::spanned { node: ast::sty_static, span: span }, + self_ty: codemap::spanned { node: ast::sty_static, span: span }, purity: ast::impure_fn, decl: deser_decl, body: deser_body, @@ -762,7 +762,7 @@ fn mk_struct_deser_impl( ] ); - ast::spanned { + codemap::spanned { node: ast::field_ { mutbl: field.mutbl, ident: field.ident, @@ -812,8 +812,8 @@ fn mk_struct_fields(fields: ~[@ast::struct_field]) -> ~[field] { do fields.map |field| { let (ident, mutbl) = match field.node.kind { ast::named_field(ident, mutbl, _) => (ident, mutbl), - _ => fail ~"[auto_encode] does not support \ - unnamed fields", + _ => die!(~"[auto_encode] does not support \ + unnamed fields") }; field { @@ -954,9 +954,9 @@ fn mk_enum_ser_body( ast::tuple_variant_kind(args) => ser_variant(cx, span, variant.node.name, v_idx, args), ast::struct_variant_kind(*) => - fail ~"struct variants unimplemented", + die!(~"struct variants unimplemented"), ast::enum_variant_kind(*) => - fail ~"enum variants unimplemented", + die!(~"enum variants unimplemented"), } }; @@ -1025,7 +1025,7 @@ fn mk_enum_deser_variant_nary( } fn mk_enum_deser_body( - cx: ext_ctxt, + ext_cx: ext_ctxt, span: span, name: ast::ident, variants: ~[ast::variant] @@ -1035,11 +1035,11 @@ fn mk_enum_deser_body( ast::tuple_variant_kind(args) => { if args.is_empty() { // for a nullary variant v, do "v" - cx.expr_path(span, ~[variant.node.name]) + ext_cx.expr_path(span, ~[variant.node.name]) } else { // for an n-ary variant v, do "v(a_1, ..., a_n)" mk_enum_deser_variant_nary( - cx, + ext_cx, span, variant.node.name, args @@ -1047,100 +1047,105 @@ fn mk_enum_deser_body( } }, ast::struct_variant_kind(*) => - fail ~"struct variants unimplemented", + die!(~"struct variants unimplemented"), ast::enum_variant_kind(*) => - fail ~"enum variants unimplemented", + die!(~"enum variants unimplemented") }; let pat = @ast::pat { - id: cx.next_id(), - node: ast::pat_lit(cx.lit_uint(span, v_idx)), + id: ext_cx.next_id(), + node: ast::pat_lit(ext_cx.lit_uint(span, v_idx)), span: span, }; ast::arm { pats: ~[pat], guard: None, - body: cx.expr_blk(body), + body: ext_cx.expr_blk(body), } }; + let quoted_expr = quote_expr!( + ::core::sys::begin_unwind(~"explicit failure", ~"empty", 1); + ).node; + let impossible_case = ast::arm { pats: ~[@ast::pat { - id: cx.next_id(), + id: ext_cx.next_id(), node: ast::pat_wild, span: span, }], guard: None, // FIXME(#3198): proper error message - body: cx.expr_blk(cx.expr(span, ast::expr_fail(None))), + body: ext_cx.expr_blk(ext_cx.expr(span, quoted_expr)), }; arms.push(impossible_case); // ast for `|i| { match i { $(arms) } }` - let expr_lambda = cx.expr( + let expr_lambda = ext_cx.expr( span, ast::expr_fn_block( ast::fn_decl { inputs: ~[ast::arg { - mode: ast::infer(cx.next_id()), + mode: ast::infer(ext_cx.next_id()), is_mutbl: false, ty: @ast::Ty { - id: cx.next_id(), + id: ext_cx.next_id(), node: ast::ty_infer, span: span }, pat: @ast::pat { - id: cx.next_id(), + id: ext_cx.next_id(), node: ast::pat_ident( ast::bind_by_copy, - ast_util::ident_to_path(span, cx.ident_of(~"i")), + ast_util::ident_to_path(span, + ext_cx.ident_of(~"i")), None), span: span, }, - id: cx.next_id(), + id: ext_cx.next_id(), }], output: @ast::Ty { - id: cx.next_id(), + id: ext_cx.next_id(), node: ast::ty_infer, span: span, }, cf: ast::return_val, }, - cx.expr_blk( - cx.expr( + ext_cx.expr_blk( + ext_cx.expr( span, - ast::expr_match(cx.expr_var(span, ~"i"), arms) + ast::expr_match(ext_cx.expr_var(span, ~"i"), arms) ) ) ) ); // ast for `__d.read_enum_variant($(expr_lambda))` - let expr_lambda = cx.lambda_expr( - cx.expr_call( + let expr_lambda = ext_cx.lambda_expr( + ext_cx.expr_call( span, - cx.expr_field( + ext_cx.expr_field( span, - cx.expr_var(span, ~"__d"), - cx.ident_of(~"read_enum_variant") + ext_cx.expr_var(span, ~"__d"), + ext_cx.ident_of(~"read_enum_variant") ), ~[expr_lambda] ) ); // ast for `__d.read_enum($(e_name), $(expr_lambda))` - cx.expr_call( + ext_cx.expr_call( span, - cx.expr_field( + ext_cx.expr_field( span, - cx.expr_var(span, ~"__d"), - cx.ident_of(~"read_enum") + ext_cx.expr_var(span, ~"__d"), + ext_cx.ident_of(~"read_enum") ), ~[ - cx.lit_str(span, @cx.str_of(name)), + ext_cx.lit_str(span, @ext_cx.str_of(name)), expr_lambda ] ) diff --git a/src/libsyntax/ext/base.rs b/src/libsyntax/ext/base.rs index d0974e0654c..3efae955965 100644 --- a/src/libsyntax/ext/base.rs +++ b/src/libsyntax/ext/base.rs @@ -11,9 +11,8 @@ use core::prelude::*; use ast; -use ast_util::dummy_sp; use codemap; -use codemap::{CodeMap, span, ExpnInfo, ExpandedFrom}; +use codemap::{CodeMap, span, ExpnInfo, ExpandedFrom, dummy_sp}; use diagnostic::span_handler; use ext; use parse; @@ -21,7 +20,7 @@ use parse::{parser, token}; use core::io; use core::vec; -use std::map::HashMap; +use std::oldmap::HashMap; // new-style macro! tt code: // diff --git a/src/libsyntax/ext/build.rs b/src/libsyntax/ext/build.rs index 6d44a412742..4d8fd39c960 100644 --- a/src/libsyntax/ext/build.rs +++ b/src/libsyntax/ext/build.rs @@ -32,7 +32,7 @@ pub fn mk_expr(cx: ext_ctxt, } pub fn mk_lit(cx: ext_ctxt, sp: span, lit: ast::lit_) -> @ast::expr { - let sp_lit = @ast::spanned { node: lit, span: sp }; + let sp_lit = @codemap::spanned { node: lit, span: sp }; mk_expr(cx, sp, ast::expr_lit(sp_lit)) } pub fn mk_int(cx: ext_ctxt, sp: span, i: int) -> @ast::expr { @@ -149,7 +149,7 @@ pub fn mk_uniq_str(cx: ext_ctxt, sp: span, s: ~str) -> @ast::expr { } pub fn mk_field(sp: span, f: &{ident: ast::ident, ex: @ast::expr}) -> ast::field { - ast::spanned { + codemap::spanned { node: ast::field_ { mutbl: ast::m_imm, ident: f.ident, expr: f.ex }, span: sp, } @@ -188,7 +188,7 @@ pub fn mk_global_struct_e(cx: ext_ctxt, pub fn mk_glob_use(cx: ext_ctxt, sp: span, path: ~[ast::ident]) -> @ast::view_item { - let glob = @ast::spanned { + let glob = @codemap::spanned { node: ast::view_path_glob(mk_raw_path(sp, path), cx.next_id()), span: sp, }; @@ -209,7 +209,7 @@ pub fn mk_local(cx: ext_ctxt, sp: span, mutbl: bool, span: sp, }; let ty = @ast::Ty { id: cx.next_id(), node: ast::ty_infer, span: sp }; - let local = @ast::spanned { + let local = @codemap::spanned { node: ast::local_ { is_mutbl: mutbl, ty: ty, @@ -219,14 +219,14 @@ pub fn mk_local(cx: ext_ctxt, sp: span, mutbl: bool, }, span: sp, }; - let decl = ast::spanned {node: ast::decl_local(~[local]), span: sp}; - @ast::spanned { node: ast::stmt_decl(@decl, cx.next_id()), span: sp } + let decl = codemap::spanned {node: ast::decl_local(~[local]), span: sp}; + @codemap::spanned { node: ast::stmt_decl(@decl, cx.next_id()), span: sp } } pub fn mk_block(cx: ext_ctxt, span: span, view_items: ~[@ast::view_item], stmts: ~[@ast::stmt], expr: Option<@ast::expr>) -> @ast::expr { - let blk = ast::spanned { + let blk = codemap::spanned { node: ast::blk_ { view_items: view_items, stmts: stmts, @@ -242,7 +242,7 @@ pub fn mk_block_(cx: ext_ctxt, span: span, +stmts: ~[@ast::stmt]) -> ast::blk { - ast::spanned { + codemap::spanned { node: ast::blk_ { view_items: ~[], stmts: stmts, @@ -257,7 +257,7 @@ pub fn mk_simple_block(cx: ext_ctxt, span: span, expr: @ast::expr) -> ast::blk { - ast::spanned { + codemap::spanned { node: ast::blk_ { view_items: ~[], stmts: ~[], @@ -307,13 +307,14 @@ pub fn mk_pat_struct(cx: ext_ctxt, mk_pat(cx, span, move pat) } pub fn mk_bool(cx: ext_ctxt, span: span, value: bool) -> @ast::expr { - let lit_expr = ast::expr_lit(@ast::spanned { node: ast::lit_bool(value), - span: span }); + let lit_expr = ast::expr_lit(@codemap::spanned { + node: ast::lit_bool(value), + span: span }); build::mk_expr(cx, span, move lit_expr) } pub fn mk_stmt(cx: ext_ctxt, span: span, expr: @ast::expr) -> @ast::stmt { let stmt_ = ast::stmt_semi(expr, cx.next_id()); - @ast::spanned { node: move stmt_, span: span } + @codemap::spanned { node: move stmt_, span: span } } pub fn mk_ty_path(cx: ext_ctxt, span: span, diff --git a/src/libsyntax/ext/deriving.rs b/src/libsyntax/ext/deriving.rs index d542b104e54..8e87357f8b5 100644 --- a/src/libsyntax/ext/deriving.rs +++ b/src/libsyntax/ext/deriving.rs @@ -18,12 +18,12 @@ use ast::{TraitTyParamBound, Ty, and, bind_by_ref, binop, deref, enum_def}; use ast::{enum_variant_kind, expr, expr_match, ident, item, item_}; use ast::{item_enum, item_impl, item_struct, m_imm, meta_item, method}; use ast::{named_field, or, pat, pat_ident, pat_wild, public, pure_fn}; -use ast::{re_anon, spanned, stmt, struct_def, struct_variant_kind}; +use ast::{re_anon, stmt, struct_def, struct_variant_kind}; use ast::{sty_by_ref, sty_region, tuple_variant_kind, ty_nil, ty_param}; use ast::{ty_param_bound, ty_path, ty_rptr, unnamed_field, variant}; use ext::base::ext_ctxt; use ext::build; -use codemap::span; +use codemap::{span, spanned}; use parse::token::special_idents::clownshoes_extensions; use core::dvec; diff --git a/src/libsyntax/ext/expand.rs b/src/libsyntax/ext/expand.rs index 0ab94710f40..227a86e0766 100644 --- a/src/libsyntax/ext/expand.rs +++ b/src/libsyntax/ext/expand.rs @@ -20,7 +20,7 @@ use parse::{parser, parse_expr_from_source_str, new_parser_from_tts}; use core::option; use core::vec; -use std::map::HashMap; +use std::oldmap::HashMap; pub fn expand_expr(exts: HashMap<~str, SyntaxExtension>, cx: ext_ctxt, e: expr_, s: span, fld: ast_fold, @@ -154,7 +154,7 @@ pub fn expand_item_mac(exts: HashMap<~str, SyntaxExtension>, fld: ast_fold) -> Option<@ast::item> { let (pth, tts) = match it.node { - item_mac(ast::spanned { node: mac_invoc_tt(pth, ref tts), _}) => { + item_mac(codemap::spanned { node: mac_invoc_tt(pth, ref tts), _}) => { (pth, (*tts)) } _ => cx.span_bug(it.span, ~"invalid item macro invocation") @@ -234,7 +234,7 @@ pub fn expand_stmt(exts: HashMap<~str, SyntaxExtension>, cx: ext_ctxt, {call_site: sp, callie: {name: *extname, span: exp_sp}})); let expanded = match exp(cx, mac.span, tts) { MRExpr(e) => - @ast::spanned { node: stmt_expr(e, cx.next_id()), + @codemap::spanned { node: stmt_expr(e, cx.next_id()), span: e.span}, MRAny(_,_,stmt_mkr) => stmt_mkr(), _ => cx.span_fatal( @@ -296,6 +296,15 @@ pub fn core_macros() -> ~str { ) ) + macro_rules! fail( + ($msg: expr) => ( + ::core::sys::begin_unwind($msg, file!().to_owned(), line!()) + ); + () => ( + die!(~\"explicit failure\") + ) + ) + macro_rules! fail_unless( ($cond:expr) => { if !$cond { diff --git a/src/libsyntax/ext/pipes/ast_builder.rs b/src/libsyntax/ext/pipes/ast_builder.rs index 8abca3d97f9..58ab05987a6 100644 --- a/src/libsyntax/ext/pipes/ast_builder.rs +++ b/src/libsyntax/ext/pipes/ast_builder.rs @@ -17,10 +17,11 @@ use core::prelude::*; use ast::{ident, node_id}; use ast; -use ast_util::{ident_to_path, respan, dummy_sp}; +use ast_util::{ident_to_path}; use ast_util; use attr; -use codemap::span; +use codemap::{span, respan, dummy_sp}; +use codemap; use ext::base::{ext_ctxt, mk_ctxt}; use ext::quote::rt::*; @@ -310,7 +311,7 @@ pub impl ext_ctxt: ext_ctxt_ast_builder { // XXX: Total hack: import `core::kinds::Owned` to work around a // parser bug whereby `fn f<T: ::kinds::Owned>` doesn't parse. let vi = ast::view_item_import(~[ - @ast::spanned { + @codemap::spanned { node: ast::view_path_simple( self.ident_of(~"Owned"), path( @@ -319,19 +320,19 @@ pub impl ext_ctxt: ext_ctxt_ast_builder { self.ident_of(~"kinds"), self.ident_of(~"Owned") ], - ast_util::dummy_sp() + codemap::dummy_sp() ), ast::type_value_ns, self.next_id() ), - span: ast_util::dummy_sp() + span: codemap::dummy_sp() } ]); let vi = @ast::view_item { node: vi, attrs: ~[], vis: ast::private, - span: ast_util::dummy_sp() + span: codemap::dummy_sp() }; self.item( diff --git a/src/libsyntax/ext/pipes/parse_proto.rs b/src/libsyntax/ext/pipes/parse_proto.rs index a74214c8758..1502332859c 100644 --- a/src/libsyntax/ext/pipes/parse_proto.rs +++ b/src/libsyntax/ext/pipes/parse_proto.rs @@ -40,13 +40,13 @@ pub impl parser::Parser: proto_parser { self.expect(token::COLON); let dir = match copy self.token { token::IDENT(n, _) => self.interner.get(n), - _ => fail + _ => die!() }; self.bump(); let dir = match dir { @~"send" => send, @~"recv" => recv, - _ => fail + _ => die!() }; let typarms = if self.token == token::LT { diff --git a/src/libsyntax/ext/pipes/pipec.rs b/src/libsyntax/ext/pipes/pipec.rs index 7bf4f2dc1d9..da0ac4e08ab 100644 --- a/src/libsyntax/ext/pipes/pipec.rs +++ b/src/libsyntax/ext/pipes/pipec.rs @@ -11,7 +11,7 @@ // A protocol compiler for Rust. use ast::ident; -use ast_util::dummy_sp; +use codemap::dummy_sp; use ext::base::ext_ctxt; use ext::pipes::ast_builder::{append_types, ext_ctxt_ast_builder, path}; use ext::pipes::ast_builder::{path_global}; diff --git a/src/libsyntax/ext/pipes/proto.rs b/src/libsyntax/ext/pipes/proto.rs index 5c2dd82eb7f..6a1d9357694 100644 --- a/src/libsyntax/ext/pipes/proto.rs +++ b/src/libsyntax/ext/pipes/proto.rs @@ -34,8 +34,8 @@ pub impl direction : cmp::Eq { } pub impl direction: ToStr { - pure fn to_str() -> ~str { - match self { + pure fn to_str(&self) -> ~str { + match *self { send => ~"Send", recv => ~"Recv" } diff --git a/src/libsyntax/ext/quote.rs b/src/libsyntax/ext/quote.rs index 7605e01fbf0..4a9a22de50f 100644 --- a/src/libsyntax/ext/quote.rs +++ b/src/libsyntax/ext/quote.rs @@ -184,7 +184,7 @@ pub mod rt { Some(ast) => ast, None => { error!("Parse error with ```\n%s\n```", s); - fail + die!() } } } @@ -399,7 +399,7 @@ fn mk_token(cx: ext_ctxt, sp: span, tok: token::Token) -> @ast::expr { ~[mk_ident(cx, sp, ident)]); } - INTERPOLATED(_) => fail ~"quote! with interpolated token", + INTERPOLATED(_) => die!(~"quote! with interpolated token"), _ => () } @@ -437,7 +437,7 @@ fn mk_token(cx: ext_ctxt, sp: span, tok: token::Token) -> @ast::expr { DOLLAR => "DOLLAR", UNDERSCORE => "UNDERSCORE", EOF => "EOF", - _ => fail + _ => die!() }; build::mk_path(cx, sp, ids_ext(cx, ~[name.to_owned()])) @@ -467,7 +467,7 @@ fn mk_tt(cx: ext_ctxt, sp: span, tt: &ast::token_tree) } ast::tt_delim(ref tts) => mk_tts(cx, sp, *tts), - ast::tt_seq(*) => fail ~"tt_seq in quote!", + ast::tt_seq(*) => die!(~"tt_seq in quote!"), ast::tt_nonterminal(sp, ident) => { diff --git a/src/libsyntax/ext/tt/macro_parser.rs b/src/libsyntax/ext/tt/macro_parser.rs index 4c0550b3c3a..9548db70b94 100644 --- a/src/libsyntax/ext/tt/macro_parser.rs +++ b/src/libsyntax/ext/tt/macro_parser.rs @@ -10,8 +10,7 @@ // Earley-like parser for macros. use ast::{matcher, match_tok, match_seq, match_nonterminal, ident}; -use ast_util::mk_sp; -use codemap::BytePos; +use codemap::{BytePos, mk_sp}; use codemap; use parse::common::*; //resolve bug? use parse::lexer::*; //resolve bug? @@ -27,7 +26,7 @@ use core::option; use core::str; use core::uint; use core::vec; -use std::map::HashMap; +use std::oldmap::HashMap; /* This is an Earley-like parser, without support for in-grammar nonterminals, only by calling out to the main rust parser for named nonterminals (which it @@ -125,7 +124,7 @@ pub type matcher_pos = ~{ pub fn copy_up(&& mpu: matcher_pos_up) -> matcher_pos { match &mpu { &matcher_pos_up(Some(ref mp)) => copy (*mp), - _ => fail + _ => die!() } } @@ -189,16 +188,16 @@ pub fn nameize(p_s: parse_sess, ms: ~[matcher], res: ~[@named_match]) fn n_rec(p_s: parse_sess, m: matcher, res: ~[@named_match], ret_val: HashMap<ident, @named_match>) { match m { - ast::spanned {node: match_tok(_), _} => (), - ast::spanned {node: match_seq(ref more_ms, _, _, _, _), _} => { + codemap::spanned {node: match_tok(_), _} => (), + codemap::spanned {node: match_seq(ref more_ms, _, _, _, _), _} => { for (*more_ms).each() |next_m| { n_rec(p_s, *next_m, res, ret_val) }; } - ast::spanned { + codemap::spanned { node: match_nonterminal(bind_name, _, idx), span: sp } => { - if ret_val.contains_key(bind_name) { + if ret_val.contains_key_ref(&bind_name) { p_s.span_diagnostic.span_fatal(sp, ~"Duplicated bind name: "+ *p_s.interner.get(bind_name)) } @@ -239,7 +238,7 @@ pub fn parse(sess: parse_sess, let mut next_eis = ~[]; // or proceed normally let mut eof_eis = ~[]; - let {tok: tok, sp: sp} = rdr.peek(); + let TokenAndSpan {tok: tok, sp: sp} = rdr.peek(); /* we append new items to this while we go */ while cur_eis.len() > 0u { /* for each Earley Item */ @@ -362,7 +361,7 @@ pub fn parse(sess: parse_sess, fmt!("%s ('%s')", *sess.interner.get(name), *sess.interner.get(bind)) } - _ => fail + _ => die!() } }), ~" or "); return error(sp, fmt!( "Local ambiguity: multiple parsing options: \ @@ -387,7 +386,7 @@ pub fn parse(sess: parse_sess, parse_nt(rust_parser, *sess.interner.get(name)))); ei.idx += 1u; } - _ => fail + _ => die!() } cur_eis.push(move ei); diff --git a/src/libsyntax/ext/tt/macro_rules.rs b/src/libsyntax/ext/tt/macro_rules.rs index f7ef79db466..31172cbfa85 100644 --- a/src/libsyntax/ext/tt/macro_rules.rs +++ b/src/libsyntax/ext/tt/macro_rules.rs @@ -13,8 +13,7 @@ use core::prelude::*; use ast::{ident, matcher_, matcher, match_tok, match_nonterminal, match_seq}; use ast::{tt_delim}; use ast; -use ast_util::dummy_sp; -use codemap::span; +use codemap::{span, spanned, dummy_sp}; use ext::base::{ext_ctxt, MacResult, MRAny, MRDef, MacroDef, NormalTT}; use ext::base; use ext::tt::macro_parser::{error}; @@ -27,13 +26,13 @@ use parse::token::{FAT_ARROW, SEMI, LBRACE, RBRACE, nt_matchers, nt_tt}; use print; use core::io; -use std::map::HashMap; +use std::oldmap::HashMap; pub fn add_new_extension(cx: ext_ctxt, sp: span, name: ident, arg: ~[ast::token_tree]) -> base::MacResult { // these spans won't matter, anyways fn ms(m: matcher_) -> matcher { - ast::spanned { node: m, span: dummy_sp() } + spanned { node: m, span: dummy_sp() } } let lhs_nm = cx.parse_sess().interner.gensym(@~"lhs"); diff --git a/src/libsyntax/ext/tt/transcribe.rs b/src/libsyntax/ext/tt/transcribe.rs index b3b1e04976a..6bf90617a6e 100644 --- a/src/libsyntax/ext/tt/transcribe.rs +++ b/src/libsyntax/ext/tt/transcribe.rs @@ -13,15 +13,16 @@ use core::prelude::*; use ast; use ast::{token_tree, tt_delim, tt_tok, tt_seq, tt_nonterminal,ident}; use ast_util; -use codemap::span; +use codemap::{span, dummy_sp}; use diagnostic::span_handler; use ext::tt::macro_parser::{named_match, matched_seq, matched_nonterminal}; use parse::token::{EOF, INTERPOLATED, IDENT, Token, nt_ident, ident_interner}; +use parse::lexer::TokenAndSpan; use core::option; use core::vec; use std; -use std::map::HashMap; +use std::oldmap::HashMap; enum tt_frame_up { /* to break a circularity */ tt_frame_up(Option<tt_frame>) @@ -43,7 +44,7 @@ pub type tt_reader = @{ interner: @ident_interner, mut cur: tt_frame, /* for MBE-style macro transcription */ - interpolations: std::map::HashMap<ident, @named_match>, + interpolations: std::oldmap::HashMap<ident, @named_match>, mut repeat_idx: ~[uint], mut repeat_len: ~[uint], /* cached: */ @@ -55,21 +56,21 @@ pub type tt_reader = @{ * `src` contains no `tt_seq`s and `tt_nonterminal`s, `interp` can (and * should) be none. */ pub fn new_tt_reader(sp_diag: span_handler, itr: @ident_interner, - interp: Option<std::map::HashMap<ident,@named_match>>, + interp: Option<std::oldmap::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)}, interpolations: match interp { /* just a convienience */ - None => std::map::HashMap(), + None => std::oldmap::HashMap(), Some(x) => x }, mut repeat_idx: ~[], mut repeat_len: ~[], /* dummy values, never read: */ mut cur_tok: EOF, - mut cur_span: ast_util::dummy_sp() + mut cur_span: dummy_sp() }; tt_next_token(r); /* get cur_tok and cur_span set up */ return r; @@ -149,8 +150,8 @@ fn lockstep_iter_size(t: token_tree, r: tt_reader) -> lis { } -pub fn tt_next_token(&&r: tt_reader) -> {tok: Token, sp: span} { - let ret_val = { tok: r.cur_tok, sp: r.cur_span }; +pub fn tt_next_token(&&r: tt_reader) -> TokenAndSpan { + let ret_val = TokenAndSpan { tok: r.cur_tok, sp: r.cur_span }; while r.cur.idx >= r.cur.readme.len() { /* done with this set; pop or repeat? */ if ! r.cur.dotdotdoted diff --git a/src/libsyntax/fold.rs b/src/libsyntax/fold.rs index 5c80a6664de..cfa8a3c1153 100644 --- a/src/libsyntax/fold.rs +++ b/src/libsyntax/fold.rs @@ -495,7 +495,6 @@ pub 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_break(opt_ident) => expr_break(option::map(&opt_ident, |x| fld.fold_ident(*x))), expr_again(opt_ident) => diff --git a/src/libsyntax/parse/attr.rs b/src/libsyntax/parse/attr.rs index 3ed31c0953c..e6ba543cf79 100644 --- a/src/libsyntax/parse/attr.rs +++ b/src/libsyntax/parse/attr.rs @@ -11,7 +11,7 @@ use core::prelude::*; use ast; -use ast_util::spanned; +use codemap::spanned; use codemap::BytePos; use parse::common::*; //resolve bug? use parse::token; diff --git a/src/libsyntax/parse/classify.rs b/src/libsyntax/parse/classify.rs index afe6823e76d..4ceb04c55d0 100644 --- a/src/libsyntax/parse/classify.rs +++ b/src/libsyntax/parse/classify.rs @@ -13,6 +13,7 @@ */ use ast; +use codemap; use ast_util::operator_prec; pub fn expr_requires_semi_to_be_stmt(e: @ast::expr) -> bool { @@ -31,7 +32,8 @@ pub fn expr_requires_semi_to_be_stmt(e: @ast::expr) -> bool { pub fn expr_is_simple_block(e: @ast::expr) -> bool { match e.node { ast::expr_block( - ast::spanned { node: ast::blk_ { rules: ast::default_blk, _ }, _ } + codemap::spanned { + node: ast::blk_ { rules: ast::default_blk, _ }, _ } ) => true, _ => false } diff --git a/src/libsyntax/parse/comments.rs b/src/libsyntax/parse/comments.rs index 26de85548e1..d7640ce3a23 100644 --- a/src/libsyntax/parse/comments.rs +++ b/src/libsyntax/parse/comments.rs @@ -14,7 +14,7 @@ use ast; use codemap::{BytePos, CharPos, CodeMap, FileMap, Pos}; use diagnostic; use parse::lexer::{is_whitespace, get_str_from, reader}; -use parse::lexer::{string_reader, bump, is_eof, nextch}; +use parse::lexer::{string_reader, bump, is_eof, nextch, TokenAndSpan}; use parse::lexer; use parse::token; use parse; @@ -117,7 +117,7 @@ pub fn strip_doc_comment_decoration(comment: ~str) -> ~str { return str::connect(lines, ~"\n"); } - fail ~"not a doc-comment: " + comment; + die!(~"not a doc-comment: " + comment); } fn read_to_eol(rdr: string_reader) -> ~str { @@ -295,7 +295,7 @@ fn consume_comment(rdr: string_reader, code_to_the_left: bool, read_block_comment(rdr, code_to_the_left, comments); } else if rdr.curr == '#' && nextch(rdr) == '!' { read_shebang_comment(rdr, code_to_the_left, comments); - } else { fail; } + } else { die!(); } debug!("<<< consume comment"); } @@ -334,7 +334,7 @@ pub fn gather_comments_and_literals(span_diagnostic: diagnostic::span_handler, let bstart = rdr.pos; rdr.next_token(); //discard, and look ahead; we're working with internal state - let {tok: tok, sp: sp} = rdr.peek(); + let TokenAndSpan {tok: tok, sp: sp} = rdr.peek(); if token::is_lit(tok) { let s = get_str_from(rdr, bstart); literals.push({lit: s, pos: sp.lo}); diff --git a/src/libsyntax/parse/common.rs b/src/libsyntax/parse/common.rs index 583ad982000..d82a5a18039 100644 --- a/src/libsyntax/parse/common.rs +++ b/src/libsyntax/parse/common.rs @@ -11,15 +11,14 @@ use core::prelude::*; use ast; -use ast_util::spanned; -use codemap::BytePos; +use codemap::{BytePos, spanned}; use parse::lexer::reader; use parse::parser::Parser; use parse::token; use core::option::{None, Option, Some}; use core::option; -use std::map::HashMap; +use std::oldmap::HashMap; pub type seq_sep = { sep: Option<token::Token>, @@ -190,7 +189,9 @@ pub impl Parser { if self.token == token::GT { self.bump(); } else if self.token == token::BINOP(token::SHR) { - self.swap(token::GT, self.span.lo + BytePos(1u), self.span.hi); + self.replace_token(token::GT, + self.span.lo + BytePos(1u), + self.span.hi); } else { let mut s: ~str = ~"expected `"; s += token_to_str(self.reader, token::GT); @@ -229,7 +230,7 @@ pub impl Parser { } fn parse_seq_lt_gt<T: Copy>(sep: Option<token::Token>, - f: fn(Parser) -> T) -> ast::spanned<~[T]> { + f: fn(Parser) -> T) -> spanned<~[T]> { let lo = self.span.lo; self.expect(token::LT); let result = self.parse_seq_to_before_gt::<T>(sep, f); @@ -277,7 +278,7 @@ pub impl Parser { // NB: Do not use this function unless you actually plan to place the // spanned list in the AST. fn parse_seq<T: Copy>(bra: token::Token, ket: token::Token, sep: seq_sep, - f: fn(Parser) -> T) -> ast::spanned<~[T]> { + f: fn(Parser) -> T) -> spanned<~[T]> { let lo = self.span.lo; self.expect(bra); let result = self.parse_seq_to_before_end::<T>(ket, sep, f); diff --git a/src/libsyntax/parse/eval.rs b/src/libsyntax/parse/eval.rs index caab03afb76..5decb2351e3 100644 --- a/src/libsyntax/parse/eval.rs +++ b/src/libsyntax/parse/eval.rs @@ -10,8 +10,7 @@ use parser::Parser; use attr::parser_attr; -use ast_util::mk_sp; -use codemap::span; +use codemap::{span, mk_sp}; type ctx = @{sess: parse::parse_sess, @@ -75,7 +74,7 @@ fn parse_companion_mod(cx: ctx, prefix: &Path, suffix: &Option<Path>) // XXX: Using a dummy span, but this code will go away soon let p0 = new_sub_parser_from_file(cx.sess, cx.cfg, modpath, - ast_util::dummy_sp()); + codemap::dummy_sp()); let inner_attrs = p0.parse_inner_attrs_and_next(); let m0 = p0.parse_mod_items(token::EOF, inner_attrs.next); return (m0.view_items, m0.items, inner_attrs.inner); diff --git a/src/libsyntax/parse/lexer.rs b/src/libsyntax/parse/lexer.rs index c3b94182cc2..381183e736c 100644 --- a/src/libsyntax/parse/lexer.rs +++ b/src/libsyntax/parse/lexer.rs @@ -30,14 +30,17 @@ use std; pub trait reader { fn is_eof() -> bool; - fn next_token() -> {tok: token::Token, sp: span}; + fn next_token() -> TokenAndSpan; fn fatal(~str) -> !; fn span_diag() -> span_handler; pure fn interner() -> @token::ident_interner; - fn peek() -> {tok: token::Token, sp: span}; + fn peek() -> TokenAndSpan; fn dup() -> reader; } +#[deriving_eq] +pub struct TokenAndSpan {tok: token::Token, sp: span} + pub type string_reader = @{ span_diagnostic: span_handler, src: @~str, @@ -79,11 +82,14 @@ pub fn new_low_level_string_reader(span_diagnostic: span_handler, filemap: filemap, interner: itr, /* dummy values; not read */ mut peek_tok: token::EOF, - mut peek_span: ast_util::dummy_sp()}; + mut peek_span: codemap::dummy_sp()}; bump(r); return r; } +// duplicating the string reader is probably a bad idea, in +// that using them will cause interleaved pushes of line +// offsets to the underlying filemap... fn dup_string_reader(&&r: string_reader) -> string_reader { @{span_diagnostic: r.span_diagnostic, src: r.src, mut pos: r.pos, @@ -95,8 +101,9 @@ fn dup_string_reader(&&r: string_reader) -> string_reader { impl string_reader: reader { fn is_eof() -> bool { is_eof(self) } - fn next_token() -> {tok: token::Token, sp: span} { - let ret_val = {tok: self.peek_tok, sp: self.peek_span}; + // return the next token. EFFECT: advances the string_reader. + fn next_token() -> TokenAndSpan { + let ret_val = TokenAndSpan {tok: self.peek_tok, sp: self.peek_span}; string_advance_token(self); return ret_val; } @@ -105,15 +112,15 @@ impl string_reader: reader { } fn span_diag() -> span_handler { self.span_diagnostic } pure fn interner() -> @token::ident_interner { self.interner } - fn peek() -> {tok: token::Token, sp: span} { - {tok: self.peek_tok, sp: self.peek_span} + fn peek() -> TokenAndSpan { + TokenAndSpan {tok: self.peek_tok, sp: self.peek_span} } fn dup() -> reader { dup_string_reader(self) as reader } } pub impl tt_reader: reader { fn is_eof() -> bool { self.cur_tok == token::EOF } - fn next_token() -> {tok: token::Token, sp: span} { + fn next_token() -> TokenAndSpan { /* weird resolve bug: if the following `if`, or any of its statements are removed, we get resolution errors */ if false { @@ -127,27 +134,29 @@ pub impl tt_reader: reader { } fn span_diag() -> span_handler { self.sp_diag } pure fn interner() -> @token::ident_interner { self.interner } - fn peek() -> {tok: token::Token, sp: span} { - { tok: self.cur_tok, sp: self.cur_span } + fn peek() -> TokenAndSpan { + TokenAndSpan { tok: self.cur_tok, sp: self.cur_span } } fn dup() -> reader { dup_tt_reader(self) as reader } } +// EFFECT: advance peek_tok and peek_span to refer to the next token. fn string_advance_token(&&r: string_reader) { - for consume_whitespace_and_comments(r).each |comment| { - r.peek_tok = comment.tok; - r.peek_span = comment.sp; - return; + match (consume_whitespace_and_comments(r)) { + Some(comment) => { + r.peek_tok = comment.tok; + r.peek_span = comment.sp; + }, + None => { + if is_eof(r) { + r.peek_tok = token::EOF; + } else { + let start_bytepos = r.last_pos; + r.peek_tok = next_token_inner(r); + r.peek_span = codemap::mk_sp(start_bytepos, r.last_pos); + }; + } } - - if is_eof(r) { - r.peek_tok = token::EOF; - } else { - let start_bytepos = r.last_pos; - r.peek_tok = next_token_inner(r); - r.peek_span = ast_util::mk_sp(start_bytepos, r.last_pos); - }; - } fn byte_offset(rdr: string_reader) -> BytePos { @@ -163,6 +172,8 @@ pub fn get_str_from(rdr: string_reader, start: BytePos) -> ~str { } } +// EFFECT: advance the StringReader by one character. If a newline is +// discovered, add it to the FileMap's list of line start offsets. pub fn bump(rdr: string_reader) { rdr.last_pos = rdr.pos; let current_byte_offset = byte_offset(rdr).to_uint();; @@ -203,7 +214,7 @@ fn hex_digit_val(c: char) -> int { if in_range(c, '0', '9') { return (c as int) - ('0' as int); } if in_range(c, 'a', 'f') { return (c as int) - ('a' as int) + 10; } if in_range(c, 'A', 'F') { return (c as int) - ('A' as int) + 10; } - fail; + die!(); } fn bin_digit_value(c: char) -> int { if c == '0' { return 0; } return 1; } @@ -233,16 +244,19 @@ fn is_hex_digit(c: char) -> bool { fn is_bin_digit(c: char) -> bool { return c == '0' || c == '1'; } -// might return a sugared-doc-attr +// EFFECT: eats whitespace and comments. +// returns a Some(sugared-doc-attr) if one exists, None otherwise. fn consume_whitespace_and_comments(rdr: string_reader) - -> Option<{tok: token::Token, sp: span}> { + -> Option<TokenAndSpan> { while is_whitespace(rdr.curr) { bump(rdr); } return consume_any_line_comment(rdr); } -// might return a sugared-doc-attr +// PRECONDITION: rdr.curr is not whitespace +// EFFECT: eats any kind of comment. +// returns a Some(sugared-doc-attr) if one exists, None otherwise fn consume_any_line_comment(rdr: string_reader) - -> Option<{tok: token::Token, sp: span}> { + -> Option<TokenAndSpan> { if rdr.curr == '/' { match nextch(rdr) { '/' => { @@ -256,9 +270,9 @@ fn consume_any_line_comment(rdr: string_reader) str::push_char(&mut acc, rdr.curr); bump(rdr); } - return Some({ + return Some(TokenAndSpan{ tok: token::DOC_COMMENT(rdr.interner.intern(@acc)), - sp: ast_util::mk_sp(start_bpos, rdr.pos) + sp: codemap::mk_sp(start_bpos, rdr.pos) }); } else { while rdr.curr != '\n' && !is_eof(rdr) { bump(rdr); } @@ -285,7 +299,7 @@ fn consume_any_line_comment(rdr: string_reader) // might return a sugared-doc-attr fn consume_block_comment(rdr: string_reader) - -> Option<{tok: token::Token, sp: span}> { + -> Option<TokenAndSpan> { // block comments starting with "/**" or "/*!" are doc-comments if rdr.curr == '*' || rdr.curr == '!' { @@ -301,9 +315,9 @@ fn consume_block_comment(rdr: string_reader) acc += ~"*/"; bump(rdr); bump(rdr); - return Some({ + return Some(TokenAndSpan{ tok: token::DOC_COMMENT(rdr.interner.intern(@acc)), - sp: ast_util::mk_sp(start_bpos, rdr.pos) + sp: codemap::mk_sp(start_bpos, rdr.pos) }); } } else { @@ -403,7 +417,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 = u64::from_str_radix(num_str, base as u64).get(); + let parsed = u64::from_str_radix(num_str, base as uint).get(); match tp { either::Left(t) => return token::LIT_INT(parsed as i64, t), either::Right(t) => return token::LIT_UINT(parsed, t) @@ -457,7 +471,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 = u64::from_str_radix(num_str, base as u64).get(); + let parsed = u64::from_str_radix(num_str, base as uint).get(); debug!("lexing %s as an unsuffixed integer literal", num_str); @@ -702,6 +716,41 @@ fn consume_whitespace(rdr: string_reader) { while is_whitespace(rdr.curr) && !is_eof(rdr) { bump(rdr); } } +#[cfg(test)] +pub mod test { + + use super::*; + use util::interner; + use diagnostic; + use util::testing::{check_equal, check_equal_ptr}; + #[test] fn t1 () { + let teststr = + @~"/* my source file */ +fn main() { io::println(~\"zebra\"); }\n"; + let cm = CodeMap::new(); + let fm = cm.new_filemap(~"zebra.rs",teststr); + let ident_interner = token::mk_ident_interner(); // interner::mk(); + let id = ident_interner.intern(@~"fn"); + let span_handler = + diagnostic::mk_span_handler(diagnostic::mk_handler(None),@cm); + let string_reader = new_string_reader(span_handler,fm,ident_interner); + let tok1 = string_reader.next_token(); + let tok2 = TokenAndSpan{ + tok:token::IDENT(id, false), + sp:span {lo:BytePos(21),hi:BytePos(23),expn_info: None}}; + check_equal (tok1,tok2); + // the 'main' id is already read: + check_equal (string_reader.last_pos,BytePos(28)); + // read another token: + let tok3 = string_reader.next_token(); + let tok4 = TokenAndSpan{ + tok:token::IDENT(ident_interner.intern (@~"main"), false), + sp:span {lo:BytePos(24),hi:BytePos(28),expn_info: None}}; + check_equal (tok3,tok4); + // the lparen is already read: + check_equal (string_reader.last_pos,BytePos(29)) + } +} // // Local Variables: diff --git a/src/libsyntax/parse/mod.rs b/src/libsyntax/parse/mod.rs index f9088bfd635..6169233c1b7 100644 --- a/src/libsyntax/parse/mod.rs +++ b/src/libsyntax/parse/mod.rs @@ -10,6 +10,7 @@ //! The main parser interface + use ast::node_id; use ast; use codemap::{span, CodeMap, FileMap, CharPos, BytePos}; @@ -33,6 +34,7 @@ pub mod token; pub mod comments; pub mod attr; + /// Common routines shared by parser mods pub mod common; @@ -215,3 +217,4 @@ pub fn new_parser_from_tts(sess: parse_sess, cfg: ast::crate_cfg, None, tts); return Parser(sess, cfg, trdr as reader) } + diff --git a/src/libsyntax/parse/obsolete.rs b/src/libsyntax/parse/obsolete.rs index 7dad15f9dfc..cdde542bb1f 100644 --- a/src/libsyntax/parse/obsolete.rs +++ b/src/libsyntax/parse/obsolete.rs @@ -21,8 +21,7 @@ use core::prelude::*; use ast::{expr, expr_lit, lit_nil}; use ast; -use ast_util::{respan}; -use codemap::span; +use codemap::{span, respan}; use parse::parser::Parser; use parse::token::Token; use parse::token; @@ -138,7 +137,7 @@ pub impl Parser { desc: &str) { self.span_err(sp, fmt!("obsolete syntax: %s", kind_str)); - if !self.obsolete_set.contains_key(kind) { + if !self.obsolete_set.contains_key_ref(&kind) { self.sess.span_diagnostic.handler().note(fmt!("%s", desc)); self.obsolete_set.insert(kind, ()); } diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index 48f38092f88..5cd78dd9049 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -20,7 +20,7 @@ use ast::{decl_local, default_blk, deref, div, enum_def, enum_variant_kind}; use ast::{expl, expr, expr_, expr_addr_of, expr_match, expr_again}; use ast::{expr_assert, expr_assign, expr_assign_op, expr_binary, expr_block}; use ast::{expr_break, expr_call, expr_cast, expr_copy, expr_do_body}; -use ast::{expr_fail, expr_field, expr_fn, expr_fn_block, expr_if, expr_index}; +use ast::{expr_field, expr_fn, expr_fn_block, expr_if, expr_index}; use ast::{expr_lit, expr_log, expr_loop, expr_loop_body, expr_mac}; use ast::{expr_method_call, expr_paren, expr_path, expr_rec, expr_repeat}; use ast::{expr_ret, expr_swap, expr_struct, expr_tup, expr_unary}; @@ -55,15 +55,16 @@ use ast::{view_path, view_path_glob, view_path_list, view_path_simple}; use ast::{visibility, vstore, vstore_box, vstore_fixed, vstore_slice}; use ast::{vstore_uniq}; use ast; -use ast_util::{spanned, respan, mk_sp, ident_to_path, operator_prec}; +use ast_util::{ident_to_path, operator_prec}; use ast_util; use classify; -use codemap::{span,FssNone, BytePos}; +use codemap::{span,FssNone, BytePos, spanned, respan, mk_sp}; use codemap; use parse::attr::parser_attr; use parse::common::{seq_sep_none, token_to_str}; use parse::common::{seq_sep_trailing_disallowed, seq_sep_trailing_allowed}; use parse::lexer::reader; +use parse::lexer::TokenAndSpan; use parse::obsolete::{ObsoleteClassTraits, ObsoleteModeInFnType}; use parse::obsolete::{ObsoleteLet, ObsoleteFieldTerminator}; use parse::obsolete::{ObsoleteMoveInit, ObsoleteBinaryMove}; @@ -86,7 +87,7 @@ use core::either; use core::result::Result; use core::vec::push; use core::vec; -use std::map::HashMap; +use std::oldmap::HashMap; #[deriving_eq] enum restriction { @@ -193,7 +194,7 @@ pub fn Parser(sess: parse_sess, token: tok0.tok, span: span0, last_span: span0, - buffer: [mut {tok: tok0.tok, sp: span0}, ..4], + mut buffer: [TokenAndSpan {tok: tok0.tok, sp: span0}, ..4], buffer_start: 0, buffer_end: 0, tokens_consumed: 0u, @@ -213,7 +214,7 @@ pub struct Parser { mut token: token::Token, mut span: span, mut last_span: span, - mut buffer: [mut {tok: token::Token, sp: span} * 4], + mut buffer: [TokenAndSpan * 4], mut buffer_start: int, mut buffer_end: int, mut tokens_consumed: uint, @@ -234,6 +235,7 @@ pub struct Parser { } pub impl Parser { + // advance the parser by one token fn bump() { self.last_span = self.span; let next = if self.buffer_start == self.buffer_end { @@ -247,7 +249,8 @@ pub impl Parser { self.span = next.sp; self.tokens_consumed += 1u; } - fn swap(next: token::Token, +lo: BytePos, +hi: BytePos) { + // EFFECT: replace the current token and span with the given one + fn replace_token(next: token::Token, +lo: BytePos, +hi: BytePos) { self.token = next; self.span = mk_sp(lo, hi); } @@ -800,7 +803,7 @@ pub impl Parser { self.bump(); self.lit_from_token(tok) }; - ast::spanned { node: lit, span: mk_sp(lo, self.last_span.hi) } + codemap::spanned { node: lit, span: mk_sp(lo, self.last_span.hi) } } fn parse_path_without_tps() -> @path { @@ -875,7 +878,7 @@ pub impl Parser { self.parse_seq_lt_gt(Some(token::COMMA), |p| p.parse_ty(false)) } else { - ast::spanned {node: ~[], span: path.span} + codemap::spanned {node: ~[], span: path.span} } }; @@ -917,14 +920,14 @@ pub impl Parser { @expr { id: self.get_id(), callee_id: self.get_id(), - node: expr_mac(ast::spanned {node: m, span: mk_sp(lo, hi)}), + node: expr_mac(codemap::spanned {node: m, span: mk_sp(lo, hi)}), span: mk_sp(lo, hi), } } fn mk_lit_u32(i: u32) -> @expr { let span = self.span; - let lv_lit = @ast::spanned { node: lit_uint(i as u64, ty_u32), + let lv_lit = @codemap::spanned { node: lit_uint(i as u64, ty_u32), span: span }; @expr { @@ -1031,12 +1034,6 @@ pub impl Parser { } } hi = self.span.hi; - } else if self.eat_keyword(~"fail") { - 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); } } else if self.eat_keyword(~"log") { self.expect(token::LPAREN); let lvl = self.parse_expr(); @@ -1404,7 +1401,7 @@ pub impl Parser { hi = e.span.hi; // HACK: turn &[...] into a &-evec ex = match e.node { - expr_vec(*) | expr_lit(@ast::spanned { + expr_vec(*) | expr_lit(@codemap::spanned { node: lit_str(_), span: _ }) if m == m_imm => { @@ -1429,7 +1426,7 @@ pub impl Parser { expr_vec(*) if m == m_mutbl => expr_vstore(e, expr_vstore_mut_box), expr_vec(*) if m == m_imm => expr_vstore(e, expr_vstore_box), - expr_lit(@ast::spanned { + expr_lit(@codemap::spanned { node: lit_str(_), span: _}) if m == m_imm => expr_vstore(e, expr_vstore_box), _ => expr_unary(box(m), e) @@ -1442,7 +1439,7 @@ pub impl Parser { hi = e.span.hi; // HACK: turn ~[...] into a ~-evec ex = match e.node { - expr_vec(*) | expr_lit(@ast::spanned { + expr_vec(*) | expr_lit(@codemap::spanned { node: lit_str(_), span: _}) if m == m_imm => expr_vstore(e, expr_vstore_uniq), _ => expr_unary(uniq(m), e) @@ -1453,11 +1450,12 @@ pub impl Parser { return self.mk_expr(lo, hi, ex); } - + // parse an expression of binops fn parse_binops() -> @expr { - return self.parse_more_binops(self.parse_prefix_expr(), 0); + self.parse_more_binops(self.parse_prefix_expr(), 0) } + // parse an expression of binops of at least min_prec precedence fn parse_more_binops(lhs: @expr, min_prec: uint) -> @expr { if self.expr_is_complete(lhs) { return lhs; } @@ -1465,65 +1463,73 @@ pub impl Parser { if peeked == token::BINOP(token::OR) && (self.restriction == RESTRICT_NO_BAR_OP || self.restriction == RESTRICT_NO_BAR_OR_DOUBLEBAR_OP) { - return lhs; - } - if peeked == token::OROR && + lhs + } else if peeked == token::OROR && self.restriction == RESTRICT_NO_BAR_OR_DOUBLEBAR_OP { - return lhs; - } - let cur_opt = token_to_binop(peeked); - match cur_opt { - Some(cur_op) => { - let cur_prec = operator_prec(cur_op); - if cur_prec > min_prec { - self.bump(); - let expr = self.parse_prefix_expr(); - let rhs = self.parse_more_binops(expr, cur_prec); - self.get_id(); // see ast_util::op_expr_callee_id - let bin = self.mk_expr(lhs.span.lo, rhs.span.hi, - expr_binary(cur_op, lhs, rhs)); - return self.parse_more_binops(bin, min_prec); + lhs + } else { + let cur_opt = token_to_binop(peeked); + match cur_opt { + Some(cur_op) => { + let cur_prec = operator_prec(cur_op); + if cur_prec > min_prec { + self.bump(); + let expr = self.parse_prefix_expr(); + let rhs = self.parse_more_binops(expr, cur_prec); + self.get_id(); // see ast_util::op_expr_callee_id + let bin = self.mk_expr(lhs.span.lo, rhs.span.hi, + expr_binary(cur_op, lhs, rhs)); + self.parse_more_binops(bin, min_prec) + } else { + lhs + } + } + None => { + if as_prec > min_prec && self.eat_keyword(~"as") { + let rhs = self.parse_ty(true); + let _as = self.mk_expr(lhs.span.lo, + rhs.span.hi, + expr_cast(lhs, rhs)); + self.parse_more_binops(_as, min_prec) + } else { + lhs + } + } } - } - _ => () - } - if as_prec > min_prec && self.eat_keyword(~"as") { - let rhs = self.parse_ty(true); - let _as = - self.mk_expr(lhs.span.lo, rhs.span.hi, expr_cast(lhs, rhs)); - return self.parse_more_binops(_as, min_prec); } - return lhs; } + // parse an assignment expression.... + // actually, this seems to be the main entry point for + // parsing an arbitrary expression. fn parse_assign_expr() -> @expr { let lo = self.span.lo; let lhs = self.parse_binops(); match copy self.token { - token::EQ => { - self.bump(); - let rhs = self.parse_expr(); - return self.mk_expr(lo, rhs.span.hi, expr_assign(lhs, rhs)); + token::EQ => { + self.bump(); + let rhs = self.parse_expr(); + self.mk_expr(lo, rhs.span.hi, expr_assign(lhs, rhs)) } token::BINOPEQ(op) => { - self.bump(); - let rhs = self.parse_expr(); - let mut aop; - match op { - token::PLUS => aop = add, - token::MINUS => aop = subtract, - token::STAR => aop = mul, - token::SLASH => aop = div, - token::PERCENT => aop = rem, - token::CARET => aop = bitxor, - token::AND => aop = bitand, - token::OR => aop = bitor, - token::SHL => aop = shl, - token::SHR => aop = shr - } - self.get_id(); // see ast_util::op_expr_callee_id - return self.mk_expr(lo, rhs.span.hi, - expr_assign_op(aop, lhs, rhs)); + self.bump(); + let rhs = self.parse_expr(); + let mut aop; + match op { + token::PLUS => aop = add, + token::MINUS => aop = subtract, + token::STAR => aop = mul, + token::SLASH => aop = div, + token::PERCENT => aop = rem, + token::CARET => aop = bitxor, + token::AND => aop = bitand, + token::OR => aop = bitor, + token::SHL => aop = shl, + token::SHR => aop = shr + } + self.get_id(); // see ast_util::op_expr_callee_id + self.mk_expr(lo, rhs.span.hi, + expr_assign_op(aop, lhs, rhs)) } token::LARROW => { self.obsolete(copy self.span, ObsoleteBinaryMove); @@ -1531,17 +1537,18 @@ pub impl Parser { self.bump(); // <- self.bump(); // rhs self.bump(); // ; - return self.mk_expr(lo, self.span.hi, - expr_break(None)); + self.mk_expr(lo, self.span.hi, + expr_break(None)) } token::DARROW => { self.bump(); let rhs = self.parse_expr(); - return self.mk_expr(lo, rhs.span.hi, expr_swap(lhs, rhs)); + self.mk_expr(lo, rhs.span.hi, expr_swap(lhs, rhs)) + } + _ => { + lhs } - _ => {/* fall through */ } } - return lhs; } fn parse_if_expr() -> @expr { @@ -1556,7 +1563,7 @@ pub impl Parser { hi = elexpr.span.hi; } let q = {cond: cond, then: thn, els: els, lo: lo, hi: hi}; - return self.mk_expr(q.lo, q.hi, expr_if(q.cond, q.then, q.els)); + self.mk_expr(q.lo, q.hi, expr_if(q.cond, q.then, q.els)) } fn parse_fn_expr(proto: Proto) -> @expr { @@ -1567,8 +1574,9 @@ pub impl Parser { let decl = self.parse_fn_decl(|p| p.parse_arg_or_capture_item()); let body = self.parse_block(); - return self.mk_expr(lo, body.span.hi, - expr_fn(proto, decl, body, @())); + + self.mk_expr(lo, body.span.hi, + expr_fn(proto, decl, body, @())) } // `|args| { ... }` like in `do` expressions @@ -1794,7 +1802,7 @@ pub impl Parser { self.eat(token::COMMA); } - let blk = ast::spanned { + let blk = codemap::spanned { node: ast::blk_ { view_items: ~[], stmts: ~[], @@ -1812,10 +1820,12 @@ pub impl Parser { return self.mk_expr(lo, hi, expr_match(discriminant, arms)); } + // parse an expression fn parse_expr() -> @expr { return self.parse_expr_res(UNRESTRICTED); } + // parse an expression, subject to the given restriction fn parse_expr_res(r: restriction) -> @expr { let old = self.restriction; self.restriction = r; @@ -1943,7 +1953,9 @@ pub impl Parser { // HACK: parse @"..." as a literal of a vstore @str pat = match sub.node { pat_lit(e@@expr { - node: expr_lit(@ast::spanned {node: lit_str(_), span: _}), _ + node: expr_lit(@codemap::spanned { + node: lit_str(_), + span: _}), _ }) => { let vst = @expr { id: self.get_id(), @@ -1963,7 +1975,9 @@ pub impl Parser { // HACK: parse ~"..." as a literal of a vstore ~str pat = match sub.node { pat_lit(e@@expr { - node: expr_lit(@ast::spanned {node: lit_str(_), span: _}), _ + node: expr_lit(@codemap::spanned { + node: lit_str(_), + span: _}), _ }) => { let vst = @expr { id: self.get_id(), @@ -1985,7 +1999,7 @@ pub impl Parser { // HACK: parse &"..." as a literal of a borrowed str pat = match sub.node { pat_lit(e@@expr { - node: expr_lit(@ast::spanned { + node: expr_lit(@codemap::spanned { node: lit_str(_), span: _}), _ }) => { let vst = @expr { @@ -2011,7 +2025,9 @@ pub impl Parser { if self.token == token::RPAREN { hi = self.span.hi; self.bump(); - let lit = @ast::spanned {node: lit_nil, span: mk_sp(lo, hi)}; + let lit = @codemap::spanned { + node: lit_nil, + span: mk_sp(lo, hi)}; let expr = self.mk_expr(lo, hi, expr_lit(lit)); pat = pat_lit(expr); } else { @@ -2381,7 +2397,7 @@ pub impl Parser { match self.token { token::SEMI => { self.bump(); - stmts.push(@ast::spanned { + stmts.push(@codemap::spanned { node: stmt_semi(e, stmt_id), .. *stmt}); } @@ -2406,7 +2422,7 @@ pub impl Parser { match self.token { token::SEMI => { self.bump(); - stmts.push(@ast::spanned { + stmts.push(@codemap::spanned { node: stmt_mac((*m), true), .. *stmt}); } @@ -2500,7 +2516,7 @@ pub impl Parser { _ => None } } - _ => fail + _ => die!() }; match maybe_bound { @@ -2940,7 +2956,7 @@ pub impl Parser { let actual_dtor = do the_dtor.map |dtor| { let (d_body, d_attrs, d_s) = *dtor; - ast::spanned { node: ast::struct_dtor_ { id: self.get_id(), + codemap::spanned { node: ast::struct_dtor_ { id: self.get_id(), attrs: d_attrs, self_id: self.get_id(), body: d_body}, @@ -3445,7 +3461,7 @@ pub impl Parser { self.bump(); let mut actual_dtor = do the_dtor.map |dtor| { let (d_body, d_attrs, d_s) = *dtor; - ast::spanned { node: ast::struct_dtor_ { id: self.get_id(), + codemap::spanned { node: ast::struct_dtor_ { id: self.get_id(), attrs: d_attrs, self_id: self.get_id(), body: d_body }, @@ -3737,7 +3753,7 @@ pub impl Parser { _ => self.fatal(~"expected open delimiter") }; let m = ast::mac_invoc_tt(pth, tts); - let m: ast::mac = ast::spanned { node: m, + let m: ast::mac = codemap::spanned { node: m, span: mk_sp(self.span.lo, self.span.hi) }; let item_ = item_mac(m); @@ -3892,7 +3908,7 @@ pub impl Parser { let metadata = self.parse_optional_meta(); view_item_use(ident, metadata, self.get_id()) } else { - fail; + die!(); }; self.expect(token::SEMI); @ast::view_item { node: node, diff --git a/src/libsyntax/parse/token.rs b/src/libsyntax/parse/token.rs index 2093b5caebd..2770d823bf3 100644 --- a/src/libsyntax/parse/token.rs +++ b/src/libsyntax/parse/token.rs @@ -21,7 +21,7 @@ use core::char; use core::cmp; use core::str; use core::task; -use std::map::HashMap; +use std::oldmap::HashMap; #[auto_encode] #[auto_decode] @@ -209,7 +209,7 @@ pub fn to_str(in: @ident_interner, t: Token) -> ~str { nt_block(*) => ~"block", nt_stmt(*) => ~"statement", nt_pat(*) => ~"pattern", - nt_expr(*) => fail ~"should have been handled above", + nt_expr(*) => die!(~"should have been handled above"), nt_ty(*) => ~"type", nt_ident(*) => ~"identifier", nt_path(*) => ~"path", @@ -262,7 +262,7 @@ pub fn flip_delimiter(t: token::Token) -> token::Token { token::RPAREN => token::LPAREN, token::RBRACE => token::LBRACE, token::RBRACKET => token::LBRACKET, - _ => fail + _ => die!() } } @@ -454,13 +454,13 @@ pub fn mk_fake_ident_interner() -> @ident_interner { */ pub fn keyword_table() -> HashMap<~str, ()> { let keywords = HashMap(); - for temporary_keyword_table().each_key |word| { + for temporary_keyword_table().each_key_ref |&word| { keywords.insert(word, ()); } - for strict_keyword_table().each_key |word| { + for strict_keyword_table().each_key_ref |&word| { keywords.insert(word, ()); } - for reserved_keyword_table().each_key |word| { + for reserved_keyword_table().each_key_ref |&word| { keywords.insert(word, ()); } keywords @@ -487,7 +487,7 @@ pub fn strict_keyword_table() -> HashMap<~str, ()> { ~"const", ~"copy", ~"do", ~"drop", ~"else", ~"enum", ~"extern", - ~"fail", ~"false", ~"fn", ~"for", + ~"false", ~"fn", ~"for", ~"if", ~"impl", ~"let", ~"log", ~"loop", ~"match", ~"mod", ~"move", ~"mut", diff --git a/src/libsyntax/print/pp.rs b/src/libsyntax/print/pp.rs index d3487fa845f..34ba4526c47 100644 --- a/src/libsyntax/print/pp.rs +++ b/src/libsyntax/print/pp.rs @@ -119,7 +119,7 @@ pub fn tok_str(++t: token) -> ~str { } } -pub fn buf_str(toks: ~[mut token], szs: ~[mut int], left: uint, right: uint, +pub fn buf_str(toks: ~[token], szs: ~[int], left: uint, right: uint, lim: uint) -> ~str { let n = vec::len(toks); assert (n == vec::len(szs)); @@ -148,17 +148,17 @@ pub fn mk_printer(out: io::Writer, linewidth: uint) -> printer { // fall behind. let n: uint = 3 * linewidth; debug!("mk_printer %u", linewidth); - let token: ~[mut token] = vec::cast_to_mut(vec::from_elem(n, EOF)); - let size: ~[mut int] = vec::cast_to_mut(vec::from_elem(n, 0)); - let scan_stack: ~[mut uint] = vec::cast_to_mut(vec::from_elem(n, 0u)); + let mut token: ~[token] = vec::from_elem(n, EOF); + let mut size: ~[int] = vec::from_elem(n, 0); + let mut scan_stack: ~[uint] = vec::from_elem(n, 0u); printer_(@{out: out, buf_len: n, mut margin: linewidth as int, mut space: linewidth as int, mut left: 0, mut right: 0, - token: move token, - size: move size, + mut token: move token, + mut size: move size, mut left_total: 0, mut right_total: 0, mut scan_stack: move scan_stack, @@ -254,8 +254,8 @@ pub type printer_ = { mut space: int, // number of spaces left on line mut left: uint, // index of left side of input stream mut right: uint, // index of right side of input stream - token: ~[mut token], // ring-buffr stream goes through - size: ~[mut int], // ring-buffer of calculated sizes + mut token: ~[token], // ring-buffr stream goes through + mut size: ~[int], // ring-buffer of calculated sizes mut left_total: int, // running size of stream "...left" mut right_total: int, // running size of stream "...right" // pseudo-stack, really a ring too. Holds the @@ -264,7 +264,7 @@ pub type printer_ = { // BEGIN (if there is any) on top of it. Stuff is flushed off the // bottom as it becomes irrelevant due to the primary ring-buffer // advancing. - mut scan_stack: ~[mut uint], + mut scan_stack: ~[uint], mut scan_stack_empty: bool, // top==bottom disambiguator mut top: uint, // index of top of scan_stack mut bottom: uint, // index of bottom of scan_stack @@ -532,7 +532,7 @@ pub impl printer { } EOF => { // EOF should never get here. - fail; + die!(); } } } diff --git a/src/libsyntax/print/pprust.rs b/src/libsyntax/print/pprust.rs index 6661f5e810a..5079766239b 100644 --- a/src/libsyntax/print/pprust.rs +++ b/src/libsyntax/print/pprust.rs @@ -422,10 +422,10 @@ pub fn print_type_ex(s: ps, &&ty: @ast::Ty, print_colons: bool) { word(s.s, ~"]"); } ast::ty_mac(_) => { - fail ~"print_type doesn't know how to print a ty_mac"; + die!(~"print_type doesn't know how to print a ty_mac"); } ast::ty_infer => { - fail ~"print_type shouldn't see a ty_infer"; + die!(~"print_type shouldn't see a ty_infer"); } } @@ -575,7 +575,7 @@ pub fn print_item(s: ps, &&item: @ast::item) { } bclose(s, item.span); } - ast::item_mac(ast::spanned { node: ast::mac_invoc_tt(pth, ref tts), + ast::item_mac(codemap::spanned { node: ast::mac_invoc_tt(pth, ref tts), _}) => { print_visibility(s, item.vis); print_path(s, pth, false); @@ -617,7 +617,7 @@ pub fn print_enum_def(s: ps, enum_definition: ast::enum_def, word_space(s, ~"="); match enum_definition.variants[0].node.kind { ast::tuple_variant_kind(args) => print_type(s, args[0].ty), - _ => fail ~"newtype syntax with struct?" + _ => die!(~"newtype syntax with struct?") } word(s.s, ~";"); end(s); @@ -686,7 +686,7 @@ pub fn print_struct(s: ps, } match field.node.kind { - ast::named_field(*) => fail ~"unexpected named field", + ast::named_field(*) => die!(~"unexpected named field"), ast::unnamed_field => { maybe_print_comment(s, field.span.lo); print_type(s, field.node.ty); @@ -709,7 +709,7 @@ pub fn print_struct(s: ps, for struct_def.fields.each |field| { match field.node.kind { - ast::unnamed_field => fail ~"unexpected unnamed field", + ast::unnamed_field => die!(~"unexpected unnamed field"), ast::named_field(ident, mutability, visibility) => { hardbreak_if_not_bol(s); maybe_print_comment(s, field.span.lo); @@ -995,7 +995,7 @@ pub fn print_if(s: ps, test: @ast::expr, blk: ast::blk, } // BLEAH, constraints would be great here _ => { - fail ~"print_if saw if with weird alternative"; + die!(~"print_if saw if with weird alternative"); } } } @@ -1296,7 +1296,7 @@ pub fn print_expr(s: ps, &&expr: @ast::expr) { } end(s); // close enclosing cbox } - None => fail + None => die!() } } else { // the block will close the pattern's ibox @@ -1393,13 +1393,6 @@ pub fn print_expr(s: ps, &&expr: @ast::expr) { word(s.s, ~"]"); } ast::expr_path(path) => print_path(s, path, true), - ast::expr_fail(maybe_fail_val) => { - word(s.s, ~"fail"); - match maybe_fail_val { - Some(expr) => { word(s.s, ~" "); print_expr(s, expr); } - _ => () - } - } ast::expr_break(opt_ident) => { word(s.s, ~"break"); space(s.s); @@ -2013,24 +2006,24 @@ pub fn print_literal(s: ps, &&lit: @ast::lit) { ast::lit_int(i, t) => { if i < 0_i64 { word(s.s, - ~"-" + u64::to_str(-i as u64, 10u) + ~"-" + u64::to_str_radix(-i as u64, 10u) + ast_util::int_ty_to_str(t)); } else { word(s.s, - u64::to_str(i as u64, 10u) + u64::to_str_radix(i as u64, 10u) + ast_util::int_ty_to_str(t)); } } ast::lit_uint(u, t) => { word(s.s, - u64::to_str(u, 10u) + u64::to_str_radix(u, 10u) + ast_util::uint_ty_to_str(t)); } ast::lit_int_unsuffixed(i) => { if i < 0_i64 { - word(s.s, ~"-" + u64::to_str(-i as u64, 10u)); + word(s.s, ~"-" + u64::to_str_radix(-i as u64, 10u)); } else { - word(s.s, u64::to_str(i as u64, 10u)); + word(s.s, u64::to_str_radix(i as u64, 10u)); } } ast::lit_float(f, t) => { @@ -2241,10 +2234,11 @@ pub mod test { use parse; use super::*; //use util; + use util::testing::check_equal; fn string_check<T : Eq> (given : &T, expected: &T) { if !(given == expected) { - fail (fmt!("given %?, expected %?",given,expected)); + die!(fmt!("given %?, expected %?",given,expected)); } } @@ -2257,11 +2251,11 @@ pub mod test { inputs: ~[], output: @ast::Ty {id: 0, node: ast::ty_nil, - span: ast_util::dummy_sp()}, + span: codemap::dummy_sp()}, cf: ast::return_val }; - assert fun_to_str(decl, abba_ident, ~[],mock_interner) - == ~"fn abba()"; + check_equal (&fun_to_str(decl, abba_ident, ~[],mock_interner), + &~"fn abba()"); } #[test] @@ -2269,7 +2263,7 @@ pub mod test { let mock_interner = parse::token::mk_fake_ident_interner(); let ident = mock_interner.intern(@~"principal_skinner"); - let var = ast_util::respan(ast_util::dummy_sp(), ast::variant_ { + let var = codemap::respan(codemap::dummy_sp(), ast::variant_ { name: ident, attrs: ~[], // making this up as I go.... ? @@ -2280,7 +2274,7 @@ pub mod test { }); let varstr = variant_to_str(var,mock_interner); - string_check(&varstr,&~"pub principal_skinner"); + check_equal(&varstr,&~"pub principal_skinner"); } } diff --git a/src/libsyntax/syntax.rc b/src/libsyntax/syntax.rc index dc5964e6a12..a6d50b9cf09 100644 --- a/src/libsyntax/syntax.rc +++ b/src/libsyntax/syntax.rc @@ -46,10 +46,11 @@ pub mod ast_map; pub mod visit; pub mod fold; pub mod util { - #[path = "interner.rs"] pub mod interner; + pub mod testing; } + #[path = "parse/mod.rs"] pub mod parse; @@ -86,3 +87,4 @@ pub mod ext { pub mod trace_macros; } + diff --git a/src/libsyntax/util/interner.rs b/src/libsyntax/util/interner.rs index 23db470391a..19b938ccd68 100644 --- a/src/libsyntax/util/interner.rs +++ b/src/libsyntax/util/interner.rs @@ -15,13 +15,13 @@ use core::prelude::*; use core::dvec::DVec; -use std::map::HashMap; -use std::map; +use std::oldmap::HashMap; +use std::oldmap; pub type hash_interner<T> = {map: HashMap<T, uint>, vect: DVec<T>}; pub fn mk<T:Eq IterBytes Hash Const Copy>() -> Interner<T> { - let m = map::HashMap::<T, uint>(); + let m = oldmap::HashMap::<T, uint>(); let hi: hash_interner<T> = {map: m, vect: DVec()}; move ((move hi) as Interner::<T>) diff --git a/src/libsyntax/util/testing.rs b/src/libsyntax/util/testing.rs new file mode 100644 index 00000000000..39d3b003e66 --- /dev/null +++ b/src/libsyntax/util/testing.rs @@ -0,0 +1,24 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// support for test cases. +use core::cmp; + +pub pure fn check_equal_ptr<T : cmp::Eq> (given : &T, expected: &T) { + if !((given == expected) && (expected == given )) { + die!(fmt!("given %?, expected %?",given,expected)); + } +} + +pub pure fn check_equal<T : cmp::Eq> (given : T, expected: T) { + if !((given == expected) && (expected == given )) { + die!(fmt!("given %?, expected %?",given,expected)); + } +} diff --git a/src/libsyntax/visit.rs b/src/libsyntax/visit.rs index a174ea47740..eea1a6906e4 100644 --- a/src/libsyntax/visit.rs +++ b/src/libsyntax/visit.rs @@ -485,7 +485,6 @@ pub fn visit_expr<E>(ex: @expr, e: E, v: vt<E>) { (v.visit_expr)(b, e, v); } expr_path(p) => visit_path(p, e, v), - expr_fail(eo) => visit_expr_opt(eo, e, v), expr_break(_) => (), expr_again(_) => (), expr_ret(eo) => visit_expr_opt(eo, e, v), diff --git a/src/rt/circular_buffer.cpp b/src/rt/circular_buffer.cpp deleted file mode 100644 index c4fd0e3d935..00000000000 --- a/src/rt/circular_buffer.cpp +++ /dev/null @@ -1,204 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or -// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license -// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -/* - * A simple resizable circular buffer. - */ - -#include "circular_buffer.h" -#include "rust_globals.h" -#include "rust_kernel.h" - -circular_buffer::circular_buffer(rust_kernel *kernel, size_t unit_sz) : - kernel(kernel), - unit_sz(unit_sz), - _buffer_sz(initial_size()), - _next(0), - _unread(0), - _buffer((uint8_t *)kernel->malloc(_buffer_sz, "circular_buffer")) { - - assert(unit_sz && "Unit size must be larger than zero."); - - KLOG(kernel, mem, "new circular_buffer(buffer_sz=%d, unread=%d)" - "-> circular_buffer=0x%" PRIxPTR, - _buffer_sz, _unread, this); - - assert(_buffer && "Failed to allocate buffer."); -} - -circular_buffer::~circular_buffer() { - KLOG(kernel, mem, "~circular_buffer 0x%" PRIxPTR, this); - assert(_buffer); - assert(_unread == 0 && "didn't expect bytes in the circular buffer"); - - kernel->free(_buffer); -} - -size_t -circular_buffer::initial_size() { - assert(unit_sz > 0); - return INITIAL_CIRCULAR_BUFFER_SIZE_IN_UNITS * unit_sz; -} - -/** - * Copies the unread data from this buffer to the "dst" address. - */ -void -circular_buffer::transfer(void *dst) { - assert(dst); - assert(_unread <= _buffer_sz); - - uint8_t *ptr = (uint8_t *) dst; - - // First copy from _next to either the end of the unread - // items or the end of the buffer - size_t head_sz; - if (_next + _unread <= _buffer_sz) { - head_sz = _unread; - } else { - head_sz = _buffer_sz - _next; - } - assert(_next + head_sz <= _buffer_sz); - memcpy(ptr, _buffer + _next, head_sz); - - // Then copy any other items from the beginning of the buffer - assert(_unread >= head_sz); - size_t tail_sz = _unread - head_sz; - assert(head_sz + tail_sz <= _buffer_sz); - memcpy(ptr + head_sz, _buffer, tail_sz); -} - -/** - * Copies the data at the "src" address into this buffer. The buffer is - * grown if it isn't large enough. - */ -void -circular_buffer::enqueue(void *src) { - assert(src); - assert(_unread <= _buffer_sz); - assert(_buffer); - - // Grow if necessary. - if (_unread == _buffer_sz) { - grow(); - } - - KLOG(kernel, mem, "circular_buffer enqueue " - "unread: %d, next: %d, buffer_sz: %d, unit_sz: %d", - _unread, _next, _buffer_sz, unit_sz); - - assert(_unread < _buffer_sz); - assert(_unread + unit_sz <= _buffer_sz); - - // Copy data - size_t dst_idx = _next + _unread; - assert(dst_idx >= _buffer_sz || dst_idx + unit_sz <= _buffer_sz); - if (dst_idx >= _buffer_sz) { - dst_idx -= _buffer_sz; - - assert(_next >= unit_sz); - assert(dst_idx <= _next - unit_sz); - } - - assert(dst_idx + unit_sz <= _buffer_sz); - memcpy(&_buffer[dst_idx], src, unit_sz); - _unread += unit_sz; - - KLOG(kernel, mem, "circular_buffer pushed data at index: %d", dst_idx); -} - -/** - * Copies data from this buffer to the "dst" address. The buffer is - * shrunk if possible. If the "dst" address is NULL, then the message - * is dequeued but is not copied. - */ -void -circular_buffer::dequeue(void *dst) { - assert(unit_sz > 0); - assert(_unread >= unit_sz); - assert(_unread <= _buffer_sz); - assert(_buffer); - - KLOG(kernel, mem, - "circular_buffer dequeue " - "unread: %d, next: %d, buffer_sz: %d, unit_sz: %d", - _unread, _next, _buffer_sz, unit_sz); - - assert(_next + unit_sz <= _buffer_sz); - if (dst != NULL) { - memcpy(dst, &_buffer[_next], unit_sz); - } - KLOG(kernel, mem, "shifted data from index %d", _next); - _unread -= unit_sz; - _next += unit_sz; - if (_next == _buffer_sz) { - _next = 0; - } - - // Shrink if possible. - if (_buffer_sz > initial_size() && _unread <= _buffer_sz / 4) { - shrink(); - } -} - -void -circular_buffer::grow() { - size_t new_buffer_sz = _buffer_sz * 2; - KLOG(kernel, mem, "circular_buffer is growing to %d bytes", - new_buffer_sz); - void *new_buffer = kernel->malloc(new_buffer_sz, - "new circular_buffer (grow)"); - transfer(new_buffer); - kernel->free(_buffer); - _buffer = (uint8_t *)new_buffer; - _next = 0; - _buffer_sz = new_buffer_sz; -} - -void -circular_buffer::shrink() { - size_t new_buffer_sz = _buffer_sz / 2; - assert(initial_size() <= new_buffer_sz); - KLOG(kernel, mem, "circular_buffer is shrinking to %d bytes", - new_buffer_sz); - void *new_buffer = kernel->malloc(new_buffer_sz, - "new circular_buffer (shrink)"); - transfer(new_buffer); - kernel->free(_buffer); - _buffer = (uint8_t *)new_buffer; - _next = 0; - _buffer_sz = new_buffer_sz; -} - -uint8_t * -circular_buffer::peek() { - return &_buffer[_next]; -} - -bool -circular_buffer::is_empty() { - return _unread == 0; -} - -size_t -circular_buffer::size() { - return _unread; -} - -// -// Local Variables: -// mode: C++ -// fill-column: 78; -// indent-tabs-mode: nil -// c-basic-offset: 4 -// buffer-file-coding-system: utf-8-unix -// compile-command: "make -k -C $RBUILD 2>&1 | sed -e 's/\\/x\\//x:\\//g'"; -// End: -// diff --git a/src/rt/circular_buffer.h b/src/rt/circular_buffer.h deleted file mode 100644 index 172fa5c625b..00000000000 --- a/src/rt/circular_buffer.h +++ /dev/null @@ -1,72 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or -// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license -// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -/* - * - */ - -#ifndef CIRCULAR_BUFFER_H -#define CIRCULAR_BUFFER_H - -#include "rust_globals.h" -#include "rust_kernel.h" - -class -circular_buffer : public kernel_owned<circular_buffer> { - static const size_t INITIAL_CIRCULAR_BUFFER_SIZE_IN_UNITS = 8; - -public: - rust_kernel *kernel; - // Size of the data unit in bytes. - const size_t unit_sz; - circular_buffer(rust_kernel *kernel, size_t unit_sz); - ~circular_buffer(); - void transfer(void *dst); - void enqueue(void *src); - void dequeue(void *dst); - uint8_t *peek(); - bool is_empty(); - size_t size(); - -private: - // private and undefined to disable copying - circular_buffer(const circular_buffer& rhs); - circular_buffer& operator=(const circular_buffer& rhs); - -private: - size_t initial_size(); - void grow(); - void shrink(); - - // Size of the buffer in bytes. - size_t _buffer_sz; - - // Byte offset within the buffer where to read the next unit of data. - size_t _next; - - // Number of bytes that have not been read from the buffer. - size_t _unread; - - // The buffer itself. - uint8_t *_buffer; -}; - -// -// Local Variables: -// mode: C++ -// fill-column: 78; -// indent-tabs-mode: nil -// c-basic-offset: 4 -// buffer-file-coding-system: utf-8-unix -// compile-command: "make -k -C $RBUILD 2>&1 | sed -e 's/\\/x\\//x:\\//g'"; -// End: -// - -#endif /* CIRCULAR_BUFFER_H */ diff --git a/src/rt/rust_builtin.cpp b/src/rt/rust_builtin.cpp index 4fcfc11b325..32f2c4ebde2 100644 --- a/src/rt/rust_builtin.cpp +++ b/src/rt/rust_builtin.cpp @@ -17,7 +17,6 @@ #include "sync/timer.h" #include "sync/rust_thread.h" #include "rust_abi.h" -#include "rust_port.h" #include <time.h> @@ -694,68 +693,6 @@ rust_sched_threads() { return task->sched->max_number_of_threads(); } -extern "C" CDECL rust_port* -rust_port_take(rust_port_id id) { - rust_task *task = rust_get_current_task(); - return task->kernel->get_port_by_id(id); -} - -extern "C" CDECL void -rust_port_drop(rust_port *p) { - assert(p != NULL); - p->deref(); -} - -extern "C" CDECL rust_task_id -rust_port_task(rust_port *p) { - assert(p != NULL); - return p->task->id; -} - -extern "C" CDECL rust_port* -new_port(size_t unit_sz) { - rust_task *task = rust_get_current_task(); - LOG(task, comm, "new_port(task=0x%" PRIxPTR " (%s), unit_sz=%d)", - (uintptr_t) task, task->name, unit_sz); - // port starts with refcount == 1 - return new (task->kernel, "rust_port") rust_port(task, unit_sz); -} - -extern "C" CDECL void -rust_port_begin_detach(rust_port *port, uintptr_t *yield) { - rust_task *task = rust_get_current_task(); - LOG(task, comm, "rust_port_detach(0x%" PRIxPTR ")", (uintptr_t) port); - port->begin_detach(yield); -} - -extern "C" CDECL void -rust_port_end_detach(rust_port *port) { - port->end_detach(); -} - -extern "C" CDECL void -del_port(rust_port *port) { - rust_task *task = rust_get_current_task(); - LOG(task, comm, "del_port(0x%" PRIxPTR ")", (uintptr_t) port); - delete port; -} - -extern "C" CDECL size_t -rust_port_size(rust_port *port) { - return port->size(); -} - -extern "C" CDECL rust_port_id -get_port_id(rust_port *port) { - return port->id; -} - -extern "C" CDECL uintptr_t -rust_port_id_send(rust_port_id target_port_id, void *sptr) { - rust_task *task = rust_get_current_task(); - return (uintptr_t)task->kernel->send_to_port(target_port_id, sptr); -} - // This is called by an intrinsic on the Rust stack and must run // entirely in the red zone. Do not call on the C stack. extern "C" CDECL MUST_CHECK bool @@ -764,19 +701,6 @@ rust_task_yield(rust_task *task, bool *killed) { } extern "C" CDECL void -port_recv(uintptr_t *dptr, rust_port *port, uintptr_t *yield) { - port->receive(dptr, yield); -} - -extern "C" CDECL void -rust_port_select(rust_port **dptr, rust_port **ports, - size_t n_ports, uintptr_t *yield) { - rust_task *task = rust_get_current_task(); - rust_port_selector *selector = task->get_port_selector(); - selector->select(task, dptr, ports, n_ports, yield); -} - -extern "C" CDECL void rust_set_exit_status(intptr_t code) { rust_task *task = rust_get_current_task(); task->kernel->set_exit_status((int)code); diff --git a/src/rt/rust_kernel.cpp b/src/rt/rust_kernel.cpp index c365f3cca1e..99a6ed94944 100644 --- a/src/rt/rust_kernel.cpp +++ b/src/rt/rust_kernel.cpp @@ -11,7 +11,6 @@ #include "rust_kernel.h" -#include "rust_port.h" #include "rust_util.h" #include "rust_scheduler.h" #include "rust_sched_launcher.h" @@ -26,7 +25,6 @@ rust_kernel::rust_kernel(rust_env *env) : _region(env, true), _log(NULL), max_task_id(INIT_TASK_ID-1), // sync_add_and_fetch increments first - max_port_id(1), rval(0), max_sched_id(1), killed(false), @@ -264,47 +262,6 @@ rust_kernel::generate_task_id() { return id; } -rust_port_id -rust_kernel::register_port(rust_port *port) { - uintptr_t new_live_ports; - rust_port_id new_port_id; - { - scoped_lock with(port_lock); - new_port_id = max_port_id++; - port_table.put(new_port_id, port); - new_live_ports = port_table.count(); - } - assert(new_port_id != INTPTR_MAX && "Hit the maximum port id"); - KLOG_("Registered port %" PRIdPTR, new_port_id); - KLOG_("Total outstanding ports: %d", new_live_ports); - return new_port_id; -} - -void -rust_kernel::release_port_id(rust_port_id id) { - KLOG_("Releasing port %" PRIdPTR, id); - uintptr_t new_live_ports; - { - scoped_lock with(port_lock); - port_table.remove(id); - new_live_ports = port_table.count(); - } - KLOG_("Total outstanding ports: %d", new_live_ports); -} - -rust_port * -rust_kernel::get_port_by_id(rust_port_id id) { - assert(id != 0 && "invalid port id"); - scoped_lock with(port_lock); - rust_port *port = NULL; - // get leaves port unchanged if not found. - port_table.get(id, &port); - if(port) { - port->ref(); - } - return port; -} - #ifdef __WIN32__ void rust_kernel::win32_require(LPCTSTR fn, BOOL ok) { @@ -400,21 +357,6 @@ rust_kernel::begin_shutdown() { allow_scheduler_exit(); } -bool -rust_kernel::send_to_port(rust_port_id chan, void *sptr) { - KLOG_("rust_port_id*_send port: 0x%" PRIxPTR, (uintptr_t) chan); - - rust_port *port = get_port_by_id(chan); - if(port) { - port->send(sptr); - port->deref(); - return true; - } else { - KLOG_("didn't get the port"); - return false; - } -} - void rust_kernel::register_exit_function(spawn_fn runner, fn_env_pair *f) { scoped_lock with(at_exit_lock); diff --git a/src/rt/rust_kernel.h b/src/rt/rust_kernel.h index a7c6249e3db..c3d5a5a19bb 100644 --- a/src/rt/rust_kernel.h +++ b/src/rt/rust_kernel.h @@ -15,8 +15,7 @@ The kernel is primarily responsible for managing the lifetime of schedulers, which in turn run rust tasks. It provides a memory allocator and logging service for use by other runtime components, - it creates unique task and port ids and provides global access - to ports by id. + it creates unique task ids. The kernel runs until there are no live schedulers. @@ -56,13 +55,11 @@ class rust_scheduler; class rust_sched_driver; class rust_sched_launcher_factory; struct rust_task_thread; -class rust_port; -// Scheduler, task, and port handles. These uniquely identify within a +// Scheduler, task handles. These uniquely identify within a // single kernel instance the objects they represent. typedef intptr_t rust_sched_id; typedef intptr_t rust_task_id; -typedef intptr_t rust_port_id; typedef std::map<rust_sched_id, rust_scheduler*> sched_map; @@ -80,12 +77,6 @@ class rust_kernel { // The next task id rust_task_id max_task_id; - // Protects max_port_id and port_table - lock_and_signal port_lock; - // The next port id - rust_task_id max_port_id; - hash_map<rust_port_id, rust_port *> port_table; - lock_and_signal rval_lock; int rval; @@ -163,10 +154,6 @@ public: rust_task_id generate_task_id(); - rust_port_id register_port(rust_port *port); - rust_port *get_port_by_id(rust_port_id id); - void release_port_id(rust_port_id tid); - void set_exit_status(int code); rust_sched_id main_sched_id() { return main_scheduler; } @@ -177,8 +164,6 @@ public: void inc_weak_task_count(); void dec_weak_task_count(); - bool send_to_port(rust_port_id chan, void *sptr); - void register_exit_function(spawn_fn runner, fn_env_pair *f); }; diff --git a/src/rt/rust_port.cpp b/src/rt/rust_port.cpp deleted file mode 100644 index befa209d62f..00000000000 --- a/src/rt/rust_port.cpp +++ /dev/null @@ -1,153 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or -// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license -// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - - -#include "rust_port.h" -#include "rust_task.h" - -rust_port::rust_port(rust_task *task, size_t unit_sz) - : ref_count(1), kernel(task->kernel), task(task), - unit_sz(unit_sz), buffer(kernel, unit_sz) { - - LOG(task, comm, - "new rust_port(task=0x%" PRIxPTR ", unit_sz=%d) -> port=0x%" - PRIxPTR, (uintptr_t)task, unit_sz, (uintptr_t)this); - - id = kernel->register_port(this); -} - -rust_port::~rust_port() { - LOG(task, comm, "~rust_port 0x%" PRIxPTR, (uintptr_t) this); -} - -void rust_port::ref() { - scoped_lock with(ref_lock); - ref_count++; -} - -void rust_port::deref() { - scoped_lock with(ref_lock); - ref_count--; - if (!ref_count) { - // The port owner is waiting for the port to be detached (if it - // hasn't already been killed) - scoped_lock with(task->lifecycle_lock); - if (task->blocked_on(&detach_cond)) { - task->wakeup_inner(&detach_cond); - } - } -} - -void rust_port::begin_detach(uintptr_t *yield) { - *yield = false; - - kernel->release_port_id(id); - - scoped_lock with(ref_lock); - ref_count--; - - if (ref_count != 0) { - task->block(&detach_cond, "waiting for port detach"); - *yield = true; - } -} - -void rust_port::end_detach() { - // Just take the lock to make sure that the thread that signaled - // the detach_cond isn't still holding it - scoped_lock with(ref_lock); - assert(ref_count == 0); -} - -void rust_port::send(void *sptr) { - bool did_rendezvous = false; - { - scoped_lock with(lock); - - buffer.enqueue(sptr); - - assert(!buffer.is_empty() && - "rust_chan::transmit with nothing to send."); - - { - scoped_lock with(task->lifecycle_lock); - if (task->blocked_on(this)) { - KLOG(kernel, comm, "dequeued in rendezvous_ptr"); - buffer.dequeue(task->rendezvous_ptr); - task->rendezvous_ptr = 0; - task->wakeup_inner(this); - did_rendezvous = true; - } - } - } - - if (!did_rendezvous) { - // If the task wasn't waiting specifically on this port, - // it may be waiting on a group of ports - - rust_port_selector *port_selector = task->get_port_selector(); - // The port selector will check if the task is blocked, not us. - port_selector->msg_sent_on(this); - } -} - -void rust_port::receive(void *dptr, uintptr_t *yield) { - LOG(task, comm, "port: 0x%" PRIxPTR ", dptr: 0x%" PRIxPTR - ", size: 0x%" PRIxPTR, - (uintptr_t) this, (uintptr_t) dptr, unit_sz); - - scoped_lock with(lock); - - *yield = false; - - if (buffer.is_empty() == false) { - buffer.dequeue(dptr); - LOG(task, comm, "<=== read data ==="); - return; - } - memset(dptr, 0, buffer.unit_sz); - - // No data was buffered on any incoming channel, so block this task on - // the port. Remember the rendezvous location so that any sender task - // can write to it before waking up this task. - - LOG(task, comm, "<=== waiting for rendezvous data ==="); - task->rendezvous_ptr = (uintptr_t*) dptr; - task->block(this, "waiting for rendezvous data"); - - // Blocking the task might fail if the task has already been killed, but - // in the event of both failure and success the task needs to yield. On - // success, it yields and waits to be unblocked. On failure it yields and - // is then fails the task. - - *yield = true; -} - -size_t rust_port::size() { - scoped_lock with(lock); - return buffer.size(); -} - -void rust_port::log_state() { - LOG(task, comm, - "port size: %d", - buffer.size()); -} - -// -// Local Variables: -// mode: C++ -// fill-column: 78; -// indent-tabs-mode: nil -// c-basic-offset: 4 -// buffer-file-coding-system: utf-8-unix -// compile-command: "make -k -C $RBUILD 2>&1 | sed -e 's/\\/x\\//x:\\//g'"; -// End: -// diff --git a/src/rt/rust_port.h b/src/rt/rust_port.h deleted file mode 100644 index 3bbc3cfaa32..00000000000 --- a/src/rt/rust_port.h +++ /dev/null @@ -1,64 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or -// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license -// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#ifndef RUST_PORT_H -#define RUST_PORT_H - -#include "rust_globals.h" -#include "circular_buffer.h" - -class port_detach_cond : public rust_cond { }; - -class rust_port : public kernel_owned<rust_port>, public rust_cond { -private: - // Protects ref_count and detach_cond - lock_and_signal ref_lock; - intptr_t ref_count; - port_detach_cond detach_cond; - -public: - void ref(); - void deref(); - -public: - rust_port_id id; - - rust_kernel *kernel; - rust_task *task; - size_t unit_sz; - circular_buffer buffer; - - lock_and_signal lock; - -public: - rust_port(rust_task *task, size_t unit_sz); - ~rust_port(); - - void log_state(); - void send(void *sptr); - void receive(void *dptr, uintptr_t *yield); - size_t size(); - - void begin_detach(uintptr_t *yield); - void end_detach(); -}; - -// -// Local Variables: -// mode: C++ -// fill-column: 78; -// indent-tabs-mode: nil -// c-basic-offset: 4 -// buffer-file-coding-system: utf-8-unix -// compile-command: "make -k -C $RBUILD 2>&1 | sed -e 's/\\/x\\//x:\\//g'"; -// End: -// - -#endif /* RUST_PORT_H */ diff --git a/src/rt/rust_port_selector.cpp b/src/rt/rust_port_selector.cpp deleted file mode 100644 index 19745ffc7a1..00000000000 --- a/src/rt/rust_port_selector.cpp +++ /dev/null @@ -1,103 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or -// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license -// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - - -#include "rust_port.h" -#include "rust_port_selector.h" -#include "rust_task.h" - -rust_port_selector::rust_port_selector() - : ports(NULL), n_ports(0) { -} - -void -rust_port_selector::select(rust_task *task, rust_port **dptr, - rust_port **ports, - size_t n_ports, uintptr_t *yield) { - - assert(this->ports == NULL); - assert(this->n_ports == 0); - assert(dptr != NULL); - assert(ports != NULL); - assert(n_ports != 0); - assert(yield != NULL); - - *yield = false; - size_t locks_taken = 0; - bool found_msg = false; - - // Take each port's lock as we iterate through them because - // if none of them contain a usable message then we need to - // block the task before any of them can try to send another - // message. - - // Start looking for ports from a different index each time. - size_t j = isaac_rand(&task->sched_loop->rctx); - for (size_t i = 0; i < n_ports; i++) { - size_t k = (i + j) % n_ports; - rust_port *port = ports[k]; - assert(port != NULL); - - port->lock.lock(); - locks_taken++; - - if (port->buffer.size() > 0) { - *dptr = port; - found_msg = true; - break; - } - } - - if (!found_msg) { - this->ports = ports; - this->n_ports = n_ports; - assert(task->rendezvous_ptr == NULL); - task->rendezvous_ptr = (uintptr_t*)dptr; - task->block(this, "waiting for select rendezvous"); - - // Blocking the task might fail if the task has already been - // killed, but in the event of both failure and success the - // task needs to yield. On success, it yields and waits to be - // unblocked. On failure it yields and is then fails the task. - - *yield = true; - } - - for (size_t i = 0; i < locks_taken; i++) { - size_t k = (i + j) % n_ports; - rust_port *port = ports[k]; - port->lock.unlock(); - } -} - -void -rust_port_selector::msg_sent_on(rust_port *port) { - rust_task *task = port->task; - - port->lock.must_not_have_lock(); - - // Prevent two ports from trying to wake up the task - // simultaneously - scoped_lock with(task->lifecycle_lock); - - if (task->blocked_on(this)) { - for (size_t i = 0; i < n_ports; i++) { - if (port == ports[i]) { - // This was one of the ports we were waiting on - ports = NULL; - n_ports = 0; - *task->rendezvous_ptr = (uintptr_t) port; - task->rendezvous_ptr = NULL; - task->wakeup_inner(this); - return; - } - } - } -} diff --git a/src/rt/rust_port_selector.h b/src/rt/rust_port_selector.h deleted file mode 100644 index 919d61f7cee..00000000000 --- a/src/rt/rust_port_selector.h +++ /dev/null @@ -1,35 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or -// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license -// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#ifndef RUST_PORT_SELECTOR_H -#define RUST_PORT_SELECTOR_H - -#include "rust_globals.h" - -class rust_port; - -class rust_port_selector : public rust_cond { - private: - rust_port **ports; - size_t n_ports; - - public: - rust_port_selector(); - - void select(rust_task *task, - rust_port **dptr, - rust_port **ports, - size_t n_ports, - uintptr_t *yield); - - void msg_sent_on(rust_port *port); -}; - -#endif /* RUST_PORT_SELECTOR_H */ diff --git a/src/rt/rust_task.cpp b/src/rt/rust_task.cpp index 435f563713e..a9246963ca4 100644 --- a/src/rt/rust_task.cpp +++ b/src/rt/rust_task.cpp @@ -21,7 +21,6 @@ #include "rust_task.h" #include "rust_env.h" -#include "rust_port.h" #include "rust_globals.h" #include "rust_crate_map.h" @@ -37,7 +36,6 @@ rust_task::rust_task(rust_sched_loop *sched_loop, rust_task_state state, kernel(sched_loop->kernel), name(name), list_index(-1), - rendezvous_ptr(0), boxed(sched_loop->kernel->env, &local_region), local_region(&sched_loop->local_region), unwinding(false), @@ -344,12 +342,6 @@ void rust_task::fail_sched_loop() { sched_loop->fail(); } -frame_glue_fns* -rust_task::get_frame_glue_fns(uintptr_t fp) { - fp -= sizeof(uintptr_t); - return *((frame_glue_fns**) fp); -} - void rust_task::assert_is_running() { scoped_lock with(lifecycle_lock); diff --git a/src/rt/rust_task.h b/src/rt/rust_task.h index 20c9a48f1dd..bff4af09b32 100644 --- a/src/rt/rust_task.h +++ b/src/rt/rust_task.h @@ -116,7 +116,6 @@ #include "rust_kernel.h" #include "boxed_region.h" #include "rust_stack.h" -#include "rust_port_selector.h" #include "rust_type.h" #include "rust_sched_loop.h" @@ -219,14 +218,6 @@ rust_task : public kernel_owned<rust_task> const char *const name; int32_t list_index; - // Rendezvous pointer for receiving data when blocked on a port. If we're - // trying to read data and no data is available on any incoming channel, - // we block on the port, and yield control to the scheduler. Since, we - // were not able to read anything, we remember the location where the - // result should go in the rendezvous_ptr, and let the sender write to - // that location before waking us up. - uintptr_t* rendezvous_ptr; - boxed_region boxed; memory_region local_region; @@ -270,8 +261,6 @@ private: uintptr_t next_c_sp; uintptr_t next_rust_sp; - rust_port_selector port_selector; - // Called when the atomic refcount reaches zero void delete_this(); @@ -302,8 +291,6 @@ private: char const *file, size_t line); - friend class rust_port; - friend class rust_port_selector; bool block_inner(rust_cond *on, const char* name); void wakeup_inner(rust_cond *from); bool blocked_on(rust_cond *cond); @@ -360,8 +347,6 @@ public: // Propagate failure to the entire rust runtime. void fail_sched_loop(); - frame_glue_fns *get_frame_glue_fns(uintptr_t fp); - void *calloc(size_t size, const char *tag); // Use this function sparingly. Depending on the ref count is generally @@ -381,8 +366,6 @@ public: void call_on_rust_stack(void *args, void *fn_ptr); bool have_c_stack() { return c_stack != NULL; } - rust_port_selector *get_port_selector() { return &port_selector; } - rust_task_state get_state() { return state; } rust_cond *get_cond() { return cond; } const char *get_cond_name() { return cond_name; } diff --git a/src/rt/rust_upcall.cpp b/src/rt/rust_upcall.cpp index 8197d9c5450..0e6df8e14a4 100644 --- a/src/rt/rust_upcall.cpp +++ b/src/rt/rust_upcall.cpp @@ -124,23 +124,6 @@ struct s_trace_args { size_t line; }; -extern "C" CDECL void -upcall_s_trace(s_trace_args *args) { - rust_task *task = args->task; - LOG_UPCALL_ENTRY(task); - LOG(task, trace, "Trace %s:%d: %s", - args->file, args->line, args->msg); -} - -extern "C" CDECL void -upcall_trace(char const *msg, - char const *file, - size_t line) { - rust_task *task = rust_get_current_task(); - s_trace_args args = {task,msg,file,line}; - UPCALL_SWITCH_STACK(task, &args, upcall_s_trace); -} - /********************************************************************** * Allocate an object in the exchange heap */ @@ -302,17 +285,6 @@ rust_upcall_free(void* ptr) { upcall_free(ptr); } -/********************************************************************** - * Sanity checks on boxes, insert when debugging possible - * use-after-free bugs. See maybe_validate_box() in trans.rs. - */ - -extern "C" CDECL void -upcall_validate_box(rust_opaque_box* ptr) { - // XXX: Remove after snapshot - abort(); -} - /**********************************************************************/ extern "C" _Unwind_Reason_Code @@ -369,12 +341,6 @@ upcall_rust_personality(int version, return args.retval; } -extern "C" void -upcall_log_type(const type_desc *tydesc, uint8_t *data, uint32_t level) { - // XXX: Remove after snapshot - abort(); -} - // NB: This needs to be blazing fast. Don't switch stacks extern "C" CDECL void * upcall_new_stack(size_t stk_sz, void *args_addr, size_t args_sz) { diff --git a/src/rt/rustrt.def.in b/src/rt/rustrt.def.in index eb9db6c1d57..dcc02341e76 100644 --- a/src/rt/rustrt.def.in +++ b/src/rt/rustrt.def.in @@ -1,14 +1,12 @@ debug_box debug_fn debug_opaque -del_port debug_ptrcast debug_tag debug_tydesc debug_get_stk_seg debug_abi_1 debug_abi_2 -get_port_id get_task_id get_time rust_tzset @@ -17,12 +15,8 @@ rust_localtime rust_timegm rust_mktime last_os_error -new_port new_task -port_recv precise_time_ns -rust_port_id_send -rust_port_select rand_free rand_new rand_new_seeded @@ -45,9 +39,6 @@ rust_list_files rust_list_files2 rust_log_console_on rust_log_console_off -rust_port_begin_detach -rust_port_end_detach -rust_port_size rust_process_wait rust_ptr_eq rust_run_program @@ -69,10 +60,7 @@ task_clear_event_reject task_wait_event task_signal_event upcall_fail -upcall_trace upcall_free -upcall_validate_box -upcall_log_type upcall_malloc upcall_rust_personality upcall_call_shim_on_c_stack @@ -171,9 +159,6 @@ rust_dbg_do_nothing rust_dbg_breakpoint rust_osmain_sched_id rust_compare_and_swap_ptr -rust_port_take -rust_port_drop -rust_port_task rust_task_inhibit_kill rust_task_allow_kill rust_task_inhibit_yield diff --git a/src/test/auxiliary/cci_class_cast.rs b/src/test/auxiliary/cci_class_cast.rs index 1225e2fe8a7..c0140bff5b1 100644 --- a/src/test/auxiliary/cci_class_cast.rs +++ b/src/test/auxiliary/cci_class_cast.rs @@ -18,7 +18,7 @@ pub mod kitty { } pub impl cat : ToStr { - pure fn to_str() -> ~str { copy self.name } + pure fn to_str(&self) -> ~str { copy self.name } } priv impl cat { diff --git a/src/test/auxiliary/cci_nested_lib.rs b/src/test/auxiliary/cci_nested_lib.rs index b3557801b32..e9f799d1f75 100644 --- a/src/test/auxiliary/cci_nested_lib.rs +++ b/src/test/auxiliary/cci_nested_lib.rs @@ -25,7 +25,7 @@ pub fn alist_get<A: Copy, B: Copy>(lst: alist<A,B>, k: A) -> B { for lst.data.each |entry| { if eq_fn(entry.key, k) { return entry.value; } } - fail; + die!(); } #[inline] diff --git a/src/test/auxiliary/impl_privacy_xc_1.rs b/src/test/auxiliary/impl_privacy_xc_1.rs new file mode 100644 index 00000000000..05d5cee47f2 --- /dev/null +++ b/src/test/auxiliary/impl_privacy_xc_1.rs @@ -0,0 +1,10 @@ +#[crate_type = "lib"]; + +pub struct Fish { + x: int +} + +impl Fish { + fn swim(&self) {} +} + diff --git a/src/test/auxiliary/impl_privacy_xc_2.rs b/src/test/auxiliary/impl_privacy_xc_2.rs new file mode 100644 index 00000000000..009e132f598 --- /dev/null +++ b/src/test/auxiliary/impl_privacy_xc_2.rs @@ -0,0 +1,15 @@ +#[crate_type = "lib"]; + +pub struct Fish { + x: int +} + +mod unexported { + use super::Fish; + impl Fish : Eq { + pure fn eq(&self, _: &Fish) -> bool { true } + pure fn ne(&self, _: &Fish) -> bool { false } + } +} + + diff --git a/src/test/auxiliary/issue-2631-a.rs b/src/test/auxiliary/issue-2631-a.rs index 197ad840234..748c209229c 100644 --- a/src/test/auxiliary/issue-2631-a.rs +++ b/src/test/auxiliary/issue-2631-a.rs @@ -14,7 +14,7 @@ extern mod std; use core::dvec::*; -use std::map::HashMap; +use std::oldmap::HashMap; pub type header_map = HashMap<~str, @DVec<@~str>>; diff --git a/src/test/auxiliary/issue2378a.rs b/src/test/auxiliary/issue2378a.rs index d7d8aed80f0..a27d7a771c5 100644 --- a/src/test/auxiliary/issue2378a.rs +++ b/src/test/auxiliary/issue2378a.rs @@ -14,7 +14,7 @@ impl methods<T:copy> for maybe<T> { fn ~[](idx: uint) -> T { match self { just(t) { t } - nothing { fail; } + nothing { die!(); } } } -} \ No newline at end of file +} diff --git a/src/test/auxiliary/issue_2723_a.rs b/src/test/auxiliary/issue_2723_a.rs index 5afb2161b41..ef74b61f93a 100644 --- a/src/test/auxiliary/issue_2723_a.rs +++ b/src/test/auxiliary/issue_2723_a.rs @@ -9,5 +9,5 @@ // except according to those terms. pub unsafe fn f(xs: ~[int]) { - xs.map(|_x| { unsafe fn q() { fail; } }); + xs.map(|_x| { unsafe fn q() { die!(); } }); } diff --git a/src/test/auxiliary/static-methods-crate.rs b/src/test/auxiliary/static-methods-crate.rs index 798f05b8485..cda4f32ab5c 100644 --- a/src/test/auxiliary/static-methods-crate.rs +++ b/src/test/auxiliary/static-methods-crate.rs @@ -36,6 +36,6 @@ impl bool: read { pub fn read<T: read Copy>(s: ~str) -> T { match read::readMaybe(s) { Some(x) => x, - _ => fail ~"read failed!" + _ => die!(~"read failed!") } } diff --git a/src/test/bench/core-map.rs b/src/test/bench/core-map.rs index d401b594c4c..67c071da26d 100644 --- a/src/test/bench/core-map.rs +++ b/src/test/bench/core-map.rs @@ -9,7 +9,7 @@ // except according to those terms. extern mod std; -use std::map; +use std::oldmap; use std::treemap::TreeMap; use core::hashmap::linear::*; use core::io::WriterUtil; @@ -35,7 +35,7 @@ fn timed(result: &mut float, fn old_int_benchmarks(rng: @rand::Rng, num_keys: uint, results: &mut Results) { { - let map = map::HashMap(); + let map = oldmap::HashMap(); do timed(&mut results.sequential_ints) { for uint::range(0, num_keys) |i| { map.insert(i, i+1); @@ -48,7 +48,7 @@ fn old_int_benchmarks(rng: @rand::Rng, num_keys: uint, results: &mut Results) { } { - let map = map::HashMap(); + let map = oldmap::HashMap(); do timed(&mut results.random_ints) { for uint::range(0, num_keys) |i| { map.insert(rng.next() as uint, i); @@ -57,14 +57,14 @@ fn old_int_benchmarks(rng: @rand::Rng, num_keys: uint, results: &mut Results) { } { - let map = map::HashMap(); + let map = oldmap::HashMap(); for uint::range(0, num_keys) |i| { map.insert(i, i);; } do timed(&mut results.delete_ints) { for uint::range(0, num_keys) |i| { - assert map.remove(i); + assert map.remove(&i); } } } @@ -72,38 +72,38 @@ fn old_int_benchmarks(rng: @rand::Rng, num_keys: uint, results: &mut Results) { fn old_str_benchmarks(rng: @rand::Rng, num_keys: uint, results: &mut Results) { { - let map = map::HashMap(); + let map = oldmap::HashMap(); do timed(&mut results.sequential_strings) { for uint::range(0, num_keys) |i| { - let s = uint::to_str(i, 10); + let s = uint::to_str(i); map.insert(s, i); } for uint::range(0, num_keys) |i| { - let s = uint::to_str(i, 10); + let s = uint::to_str(i); assert map.get(s) == i; } } } { - let map = map::HashMap(); + let map = oldmap::HashMap(); do timed(&mut results.random_strings) { for uint::range(0, num_keys) |i| { - let s = uint::to_str(rng.next() as uint, 10); + let s = uint::to_str(rng.next() as uint); map.insert(s, i); } } } { - let map = map::HashMap(); + let map = oldmap::HashMap(); for uint::range(0, num_keys) |i| { - map.insert(uint::to_str(i, 10), i); + map.insert(uint::to_str(i), i); } do timed(&mut results.delete_strings) { for uint::range(0, num_keys) |i| { - assert map.remove(uint::to_str(i, 10)); + assert map.remove(&uint::to_str(i)); } } } @@ -151,12 +151,12 @@ fn linear_str_benchmarks(rng: @rand::Rng, num_keys: uint, results: &mut Results) let mut map = LinearMap::new(); do timed(&mut results.sequential_strings) { for uint::range(0, num_keys) |i| { - let s = uint::to_str(i, 10); + let s = uint::to_str(i); map.insert(s, i); } for uint::range(0, num_keys) |i| { - let s = uint::to_str(i, 10); + let s = uint::to_str(i); assert map.find(&s).unwrap() == &i; } } @@ -166,7 +166,7 @@ fn linear_str_benchmarks(rng: @rand::Rng, num_keys: uint, results: &mut Results) let mut map = LinearMap::new(); do timed(&mut results.random_strings) { for uint::range(0, num_keys) |i| { - let s = uint::to_str(rng.next() as uint, 10); + let s = uint::to_str(rng.next() as uint); map.insert(s, i); } } @@ -175,11 +175,11 @@ fn linear_str_benchmarks(rng: @rand::Rng, num_keys: uint, results: &mut Results) { let mut map = LinearMap::new(); for uint::range(0, num_keys) |i| { - map.insert(uint::to_str(i, 10), i); + map.insert(uint::to_str(i), i); } do timed(&mut results.delete_strings) { for uint::range(0, num_keys) |i| { - assert map.remove(&uint::to_str(i, 10)); + assert map.remove(&uint::to_str(i)); } } } @@ -227,12 +227,12 @@ fn tree_str_benchmarks(rng: @rand::Rng, num_keys: uint, results: &mut Results) { let mut map = TreeMap::new(); do timed(&mut results.sequential_strings) { for uint::range(0, num_keys) |i| { - let s = uint::to_str(i, 10); + let s = uint::to_str(i); map.insert(s, i); } for uint::range(0, num_keys) |i| { - let s = uint::to_str(i, 10); + let s = uint::to_str(i); assert map.find(&s).unwrap() == &i; } } @@ -242,7 +242,7 @@ fn tree_str_benchmarks(rng: @rand::Rng, num_keys: uint, results: &mut Results) { let mut map = TreeMap::new(); do timed(&mut results.random_strings) { for uint::range(0, num_keys) |i| { - let s = uint::to_str(rng.next() as uint, 10); + let s = uint::to_str(rng.next() as uint); map.insert(s, i); } } @@ -251,11 +251,11 @@ fn tree_str_benchmarks(rng: @rand::Rng, num_keys: uint, results: &mut Results) { { let mut map = TreeMap::new(); for uint::range(0, num_keys) |i| { - map.insert(uint::to_str(i, 10), i); + map.insert(uint::to_str(i), i); } do timed(&mut results.delete_strings) { for uint::range(0, num_keys) |i| { - assert map.remove(&uint::to_str(i, 10)); + assert map.remove(&uint::to_str(i)); } } } @@ -309,7 +309,7 @@ fn main() { let mut results = empty_results(); old_int_benchmarks(rng, num_keys, &mut results); old_str_benchmarks(rng, num_keys, &mut results); - write_results("std::map::HashMap", &results); + write_results("std::oldmap::HashMap", &results); } { diff --git a/src/test/bench/core-std.rs b/src/test/bench/core-std.rs index bc20eddfda1..32b6c491898 100644 --- a/src/test/bench/core-std.rs +++ b/src/test/bench/core-std.rs @@ -13,8 +13,8 @@ extern mod std; use std::time::precise_time_s; -use std::map; -use std::map::{Map, HashMap}; +use std::oldmap; +use std::oldmap::{Map, HashMap}; use io::{Reader, ReaderUtil}; @@ -75,12 +75,12 @@ fn read_line() { fn str_set() { let r = rand::Rng(); - let s = map::HashMap(); + let s = oldmap::HashMap(); for int::range(0, 1000) |_i| { - map::set_add(s, r.gen_str(10)); + oldmap::set_add(s, r.gen_str(10)); } - + let mut found = 0; for int::range(0, 1000) |_i| { match s.find(r.gen_str(10)) { @@ -93,7 +93,7 @@ fn str_set() { fn vec_plus() { let r = rand::Rng(); - let mut v = ~[]; + let mut v = ~[]; let mut i = 0; while i < 1500 { let rv = vec::from_elem(r.gen_uint_range(0, i + 1), i); diff --git a/src/test/bench/core-uint-to-str.rs b/src/test/bench/core-uint-to-str.rs index df4962fb44c..56f616c6f28 100644 --- a/src/test/bench/core-uint-to-str.rs +++ b/src/test/bench/core-uint-to-str.rs @@ -21,7 +21,7 @@ fn main() { let n = uint::from_str(args[1]).get(); for uint::range(0u, n) |i| { - let x = uint::to_str(i, 10u); + let x = uint::to_str(i); log(debug, x); } } diff --git a/src/test/bench/graph500-bfs.rs b/src/test/bench/graph500-bfs.rs index 9667c1d82d8..5ade0c9ed25 100644 --- a/src/test/bench/graph500-bfs.rs +++ b/src/test/bench/graph500-bfs.rs @@ -19,9 +19,9 @@ An implementation of the Graph500 Breadth First Search problem in Rust. extern mod std; use std::arc; use std::time; -use std::map; -use std::map::Map; -use std::map::HashMap; +use std::oldmap; +use std::oldmap::Map; +use std::oldmap::HashMap; use std::deque; use std::deque::Deque; use std::par; @@ -41,7 +41,7 @@ fn make_edges(scale: uint, edgefactor: uint) -> ~[(node_id, node_id)] { let A = 0.57; let B = 0.19; let C = 0.19; - + if scale == 0u { (i, j) } @@ -49,7 +49,7 @@ fn make_edges(scale: uint, edgefactor: uint) -> ~[(node_id, node_id)] { let i = i * 2i64; let j = j * 2i64; let scale = scale - 1u; - + let x = r.gen_float(); if x < A { @@ -80,38 +80,38 @@ fn make_edges(scale: uint, edgefactor: uint) -> ~[(node_id, node_id)] { fn make_graph(N: uint, edges: ~[(node_id, node_id)]) -> graph { let graph = do vec::from_fn(N) |_i| { - map::HashMap::<node_id, ()>() + oldmap::HashMap::<node_id, ()>() }; do vec::each(edges) |e| { match *e { (i, j) => { - map::set_add(graph[i], j); - map::set_add(graph[j], i); + oldmap::set_add(graph[i], j); + oldmap::set_add(graph[j], i); } } true } do graph.map() |v| { - map::vec_from_set(*v) + oldmap::vec_from_set(*v) } } fn gen_search_keys(graph: graph, n: uint) -> ~[node_id] { - let keys = map::HashMap::<node_id, ()>(); + let keys = oldmap::HashMap::<node_id, ()>(); let r = rand::Rng(); - while keys.size() < n { + while keys.len() < n { let k = r.gen_uint_range(0u, graph.len()); if graph[k].len() > 0u && vec::any(graph[k], |i| { *i != k as node_id }) { - map::set_add(keys, k as node_id); + oldmap::set_add(keys, k as node_id); } } - map::vec_from_set(keys) + oldmap::vec_from_set(keys) } /** @@ -120,8 +120,8 @@ fn gen_search_keys(graph: graph, n: uint) -> ~[node_id] { * Nodes that are unreachable have a parent of -1. */ fn bfs(graph: graph, key: node_id) -> bfs_result { - let marks : ~[mut node_id] - = vec::cast_to_mut(vec::from_elem(vec::len(graph), -1i64)); + let mut marks : ~[node_id] + = vec::from_elem(vec::len(graph), -1i64); let Q = deque::create(); @@ -140,7 +140,7 @@ fn bfs(graph: graph, key: node_id) -> bfs_result { }; } - vec::cast_from_mut(move marks) + move marks } /** @@ -212,7 +212,7 @@ fn bfs2(graph: graph, key: node_id) -> bfs_result { match *c { white => { -1i64 } black(parent) => { parent } - _ => { fail ~"Found remaining gray nodes in BFS" } + _ => { die!(~"Found remaining gray nodes in BFS") } } } } @@ -294,13 +294,13 @@ fn pbfs(&&graph: arc::ARC<graph>, key: node_id) -> bfs_result { match *c { white => { -1i64 } black(parent) => { parent } - _ => { fail ~"Found remaining gray nodes in BFS" } + _ => { die!(~"Found remaining gray nodes in BFS") } } } } /// Performs at least some of the validation in the Graph500 spec. -fn validate(edges: ~[(node_id, node_id)], +fn validate(edges: ~[(node_id, node_id)], root: node_id, tree: bfs_result) -> bool { // There are 5 things to test. Below is code for each of them. @@ -336,7 +336,7 @@ fn validate(edges: ~[(node_id, node_id)], path.len() as int } }; - + if !status { return status } // 2. Each tree edge connects vertices whose BFS levels differ by @@ -366,7 +366,7 @@ fn validate(edges: ~[(node_id, node_id)], abs(level[u] - level[v]) <= 1 }; - if !status { return status } + if !status { return status } // 4. The BFS tree spans an entire connected component's vertices. @@ -388,7 +388,7 @@ fn validate(edges: ~[(node_id, node_id)], } }; - if !status { return status } + if !status { return status } // If we get through here, all the tests passed! true @@ -440,44 +440,44 @@ fn main() { let start = time::precise_time_s(); let bfs_tree = bfs(copy graph, *root); let stop = time::precise_time_s(); - + //total_seq += stop - start; io::stdout().write_line( fmt!("Sequential BFS completed in %? seconds.", stop - start)); - + if do_validate { let start = time::precise_time_s(); assert(validate(copy edges, *root, bfs_tree)); let stop = time::precise_time_s(); - + io::stdout().write_line( fmt!("Validation completed in %? seconds.", stop - start)); } - + let start = time::precise_time_s(); let bfs_tree = bfs2(copy graph, *root); let stop = time::precise_time_s(); - + total_seq += stop - start; - + io::stdout().write_line( fmt!("Alternate Sequential BFS completed in %? seconds.", stop - start)); - + if do_validate { let start = time::precise_time_s(); assert(validate(copy edges, *root, bfs_tree)); let stop = time::precise_time_s(); - + io::stdout().write_line( fmt!("Validation completed in %? seconds.", stop - start)); } } - + let start = time::precise_time_s(); let bfs_tree = pbfs(graph_arc, *root); let stop = time::precise_time_s(); @@ -491,7 +491,7 @@ fn main() { let start = time::precise_time_s(); assert(validate(copy edges, *root, bfs_tree)); let stop = time::precise_time_s(); - + io::stdout().write_line(fmt!("Validation completed in %? seconds.", stop - start)); } diff --git a/src/test/bench/pingpong.rs b/src/test/bench/pingpong.rs index c09d277e382..4a6eaad9e14 100644 --- a/src/test/bench/pingpong.rs +++ b/src/test/bench/pingpong.rs @@ -56,7 +56,7 @@ macro_rules! follow ( $(Some($message($($x,)* move next)) => { let $next = move next; move $e })+ - _ => { fail } + _ => { die!() } } ); @@ -67,7 +67,7 @@ macro_rules! follow ( $(Some($message(move next)) => { let $next = move next; move $e })+ - _ => { fail } + _ => { die!() } } ) ) diff --git a/src/test/bench/shootout-chameneos-redux.rs b/src/test/bench/shootout-chameneos-redux.rs index 740a2754e24..6de8d13529a 100644 --- a/src/test/bench/shootout-chameneos-redux.rs +++ b/src/test/bench/shootout-chameneos-redux.rs @@ -11,8 +11,8 @@ // chameneos extern mod std; -use std::map; -use std::map::HashMap; +use std::oldmap; +use std::oldmap::HashMap; use std::sort; use std::cell::Cell; use core::pipes::*; @@ -63,7 +63,7 @@ fn show_digit(nn: uint) -> ~str { 7 => {~"seven"} 8 => {~"eight"} 9 => {~"nine"} - _ => {fail ~"expected digits from 0 to 9..."} + _ => {die!(~"expected digits from 0 to 9...")} } } diff --git a/src/test/bench/shootout-k-nucleotide-pipes.rs b/src/test/bench/shootout-k-nucleotide-pipes.rs index fab0af479cc..0f4f22196ce 100644 --- a/src/test/bench/shootout-k-nucleotide-pipes.rs +++ b/src/test/bench/shootout-k-nucleotide-pipes.rs @@ -14,15 +14,15 @@ #[legacy_modes]; extern mod std; -use std::map; -use std::map::HashMap; +use std::oldmap; +use std::oldmap::HashMap; use std::sort; use io::ReaderUtil; use pipes::{stream, Port, Chan}; use cmp::Ord; // given a map, print a sorted version of it -fn sort_and_fmt(mm: HashMap<~[u8], uint>, total: uint) -> ~str { +fn sort_and_fmt(mm: HashMap<~[u8], uint>, total: uint) -> ~str { fn pct(xx: uint, yy: uint) -> float { return (xx as float) * 100f / (yy as float); } @@ -49,10 +49,9 @@ fn sort_and_fmt(mm: HashMap<~[u8], uint>, total: uint) -> ~str { let mut pairs = ~[]; // map -> [(k,%)] - mm.each(fn&(key: ~[u8], val: uint) -> bool { + for mm.each_ref |&key, &val| { pairs.push((key, pct(val, total))); - return true; - }); + } let pairs_sorted = sortKV(pairs); @@ -95,13 +94,13 @@ fn windows_with_carry(bb: &[u8], nn: uint, ii += 1u; } - return vec::slice(bb, len - (nn - 1u), len); + return vec::slice(bb, len - (nn - 1u), len); } fn make_sequence_processor(sz: uint, from_parent: pipes::Port<~[u8]>, to_parent: pipes::Chan<~str>) { - - let freqs: HashMap<~[u8], uint> = map::HashMap(); + + let freqs: HashMap<~[u8], uint> = oldmap::HashMap(); let mut carry: ~[u8] = ~[]; let mut total: uint = 0u; @@ -118,7 +117,7 @@ fn make_sequence_processor(sz: uint, from_parent: pipes::Port<~[u8]>, }); } - let buffer = match sz { + let buffer = match sz { 1u => { sort_and_fmt(freqs, total) } 2u => { sort_and_fmt(freqs, total) } 3u => { fmt!("%u\t%s", find(freqs, ~"GGT"), ~"GGT") } @@ -165,11 +164,11 @@ fn main() { do task::spawn_with(move from_parent) |move to_parent_, from_parent| { make_sequence_processor(sz, from_parent, to_parent_); }; - + move to_child }); - - + + // latch stores true after we've started // reading the sequence of interest let mut proc_mode = false; diff --git a/src/test/bench/shootout-mandelbrot.rs b/src/test/bench/shootout-mandelbrot.rs index 6133f9befcf..8cf57b19825 100644 --- a/src/test/bench/shootout-mandelbrot.rs +++ b/src/test/bench/shootout-mandelbrot.rs @@ -22,7 +22,7 @@ extern mod std; use io::WriterUtil; -use std::map::HashMap; +use std::oldmap::HashMap; struct cmplx { re: f64, @@ -134,11 +134,11 @@ fn writer(path: ~str, pport: pipes::Port<Line>, size: uint) done += 1_u; let mut prev = done; while prev <= i { - if lines.contains_key(prev) { + if lines.contains_key_ref(&prev) { debug!("WS %u", prev); cout.write(lines.get(prev)); done += 1_u; - lines.remove(prev); + lines.remove(&prev); prev += 1_u; } else { diff --git a/src/test/bench/shootout-pfib.rs b/src/test/bench/shootout-pfib.rs index c146b6ac371..06b46eab759 100644 --- a/src/test/bench/shootout-pfib.rs +++ b/src/test/bench/shootout-pfib.rs @@ -68,7 +68,7 @@ fn parse_opts(argv: ~[~str]) -> Config { Ok(ref m) => { return Config {stress: getopts::opt_present(m, ~"stress")} } - Err(_) => { fail; } + Err(_) => { die!(); } } } diff --git a/src/test/bench/shootout-spectralnorm.rs b/src/test/bench/shootout-spectralnorm.rs index 89827c8be77..b679b832285 100644 --- a/src/test/bench/shootout-spectralnorm.rs +++ b/src/test/bench/shootout-spectralnorm.rs @@ -16,7 +16,7 @@ fn eval_A(i: uint, j: uint) -> float { 1.0/(((i+j)*(i+j+1u)/2u+i+1u) as float) } -fn eval_A_times_u(u: &[const float], Au: &[mut float]) { +fn eval_A_times_u(u: &[const float], Au: &mut [float]) { let N = vec::len(u); let mut i = 0u; while i < N { @@ -30,7 +30,7 @@ fn eval_A_times_u(u: &[const float], Au: &[mut float]) { } } -fn eval_At_times_u(u: &[const float], Au: &[mut float]) { +fn eval_At_times_u(u: &[const float], Au: &mut [float]) { let N = vec::len(u); let mut i = 0u; while i < N { @@ -44,7 +44,7 @@ fn eval_At_times_u(u: &[const float], Au: &[mut float]) { } } -fn eval_AtA_times_u(u: &[const float], AtAu: &[mut float]) { +fn eval_AtA_times_u(u: &[const float], AtAu: &mut [float]) { let v = vec::cast_to_mut(vec::from_elem(vec::len(u), 0.0)); eval_A_times_u(u, v); eval_At_times_u(v, AtAu); diff --git a/src/test/bench/std-smallintmap.rs b/src/test/bench/std-smallintmap.rs index a72831c2b06..0687799cf28 100644 --- a/src/test/bench/std-smallintmap.rs +++ b/src/test/bench/std-smallintmap.rs @@ -11,19 +11,18 @@ // Microbenchmark for the smallintmap library extern mod std; -use std::smallintmap; use std::smallintmap::SmallIntMap; use io::WriterUtil; -fn append_sequential(min: uint, max: uint, map: SmallIntMap<uint>) { +fn append_sequential(min: uint, max: uint, map: &mut SmallIntMap<uint>) { for uint::range(min, max) |i| { map.insert(i, i + 22u); } } -fn check_sequential(min: uint, max: uint, map: SmallIntMap<uint>) { +fn check_sequential(min: uint, max: uint, map: &SmallIntMap<uint>) { for uint::range(min, max) |i| { - assert map.get(i) == i + 22u; + assert *map.get(&i) == i + 22u; } } @@ -43,11 +42,11 @@ fn main() { let mut appendf = 0.0; for uint::range(0u, rep) |_r| { - let map = smallintmap::mk(); + let mut map = SmallIntMap::new(); let start = std::time::precise_time_s(); - append_sequential(0u, max, map); + append_sequential(0u, max, &mut map); let mid = std::time::precise_time_s(); - check_sequential(0u, max, map); + check_sequential(0u, max, &map); let end = std::time::precise_time_s(); checkf += (end - mid) as float; diff --git a/src/test/bench/sudoku.rs b/src/test/bench/sudoku.rs index 06108a2fd32..750874e80c3 100644 --- a/src/test/bench/sudoku.rs +++ b/src/test/bench/sudoku.rs @@ -30,7 +30,7 @@ use io::{ReaderUtil, WriterUtil}; // // internal type of sudoku grids -type grid = ~[~[mut u8]]; +type grid = ~[~[u8]]; // exported type of sudoku grids pub enum grid_t { grid_ctor(grid), } @@ -39,8 +39,8 @@ pub enum grid_t { grid_ctor(grid), } pub fn read_grid(f: io::Reader) -> grid_t { assert f.read_line() == ~"9,9"; /* assert first line is exactly "9,9" */ - let g = vec::from_fn(10u, {|_i| - vec::cast_to_mut(vec::from_elem(10u, 0 as u8)) + let mut g = vec::from_fn(10u, {|_i| + vec::from_elem(10u, 0 as u8) }); while !f.eof() { let comps = str::split_char(str::trim(f.read_line()), ','); @@ -55,7 +55,7 @@ pub fn read_grid(f: io::Reader) -> grid_t { // solve sudoku grid pub fn solve_grid(g: grid_t) { - fn next_color(g: grid, row: u8, col: u8, start_color: u8) -> bool { + fn next_color(mut g: grid, row: u8, col: u8, start_color: u8) -> bool { if start_color < 10u8 { // colors not yet used let avail = bitv::Bitv(10u, false); @@ -118,7 +118,7 @@ pub fn solve_grid(g: grid_t) { ptr = ptr + 1u; } else { // no: redo this field aft recoloring pred; unless there is none - if ptr == 0u { fail ~"No solution found for this sudoku"; } + if ptr == 0u { die!(~"No solution found for this sudoku"); } ptr = ptr - 1u; } } @@ -139,8 +139,8 @@ fn main() { let grid = if vec::len(args) == 1u { // FIXME create sudoku inline since nested vec consts dont work yet // (#3733) - let g = vec::from_fn(10u, |_i| { - vec::cast_to_mut(vec::from_elem(10u, 0 as u8)) + let mut g = vec::from_fn(10u, |_i| { + vec::from_elem(10u, 0 as u8) }); g[0][1] = 4u8; g[0][3] = 6u8; diff --git a/src/test/bench/task-perf-alloc-unwind.rs b/src/test/bench/task-perf-alloc-unwind.rs index 52826752922..20dcb079597 100644 --- a/src/test/bench/task-perf-alloc-unwind.rs +++ b/src/test/bench/task-perf-alloc-unwind.rs @@ -66,7 +66,7 @@ fn r(l: @nillist) -> r { fn recurse_or_fail(depth: int, st: Option<State>) { if depth == 0 { debug!("unwinding %.4f", precise_time_s()); - fail; + die!(); } else { let depth = depth - 1; diff --git a/src/test/bench/task-perf-jargon-metal-smoke.rs b/src/test/bench/task-perf-jargon-metal-smoke.rs index 3d886e561a7..415df0e9fa8 100644 --- a/src/test/bench/task-perf-jargon-metal-smoke.rs +++ b/src/test/bench/task-perf-jargon-metal-smoke.rs @@ -46,6 +46,6 @@ fn main() { let (p,c) = pipes::stream(); child_generation(uint::from_str(args[1]).get(), move c); if p.try_recv().is_none() { - fail ~"it happened when we slumbered"; + die!(~"it happened when we slumbered"); } } diff --git a/src/test/bench/task-perf-linked-failure.rs b/src/test/bench/task-perf-linked-failure.rs index d2dd0eaf745..3b1a20136b6 100644 --- a/src/test/bench/task-perf-linked-failure.rs +++ b/src/test/bench/task-perf-linked-failure.rs @@ -77,7 +77,7 @@ fn main() { } // Grandparent group waits for middle group to be gone, then fails error!("Grandparent group wakes up and fails"); - fail; + die!(); }; assert x.is_err(); } diff --git a/src/test/compile-fail/alt-join.rs b/src/test/compile-fail/alt-join.rs index ff83285a0bd..1cce1dee2f7 100644 --- a/src/test/compile-fail/alt-join.rs +++ b/src/test/compile-fail/alt-join.rs @@ -11,7 +11,7 @@ // a good test that we merge paths correctly in the presence of a // variable that's used before it's declared -fn my_fail() -> ! { fail; } +fn my_fail() -> ! { die!(); } fn main() { match true { false => { my_fail(); } true => { } } diff --git a/src/test/compile-fail/bad-bang-ann.rs b/src/test/compile-fail/bad-bang-ann.rs index 4dbe5876a97..d044d9bdc96 100644 --- a/src/test/compile-fail/bad-bang-ann.rs +++ b/src/test/compile-fail/bad-bang-ann.rs @@ -12,7 +12,7 @@ // Tests that a function with a ! annotation always actually fails fn bad_bang(i: uint) -> ! { - if i < 0u { } else { fail; } + if i < 0u { } else { die!(); } //~^ ERROR expected `!` but found `()` } diff --git a/src/test/compile-fail/bind-by-move-neither-can-live-while-the-other-survives-1.rs b/src/test/compile-fail/bind-by-move-neither-can-live-while-the-other-survives-1.rs index 6dbd01e5191..fea31ef1738 100644 --- a/src/test/compile-fail/bind-by-move-neither-can-live-while-the-other-survives-1.rs +++ b/src/test/compile-fail/bind-by-move-neither-can-live-while-the-other-survives-1.rs @@ -20,6 +20,6 @@ fn main() { let x = Some(X { x: () }); match move x { Some(ref _y @ move _z) => { }, //~ ERROR cannot bind by-move and by-ref in the same pattern - None => fail + None => die!() } } diff --git a/src/test/compile-fail/bind-by-move-neither-can-live-while-the-other-survives-2.rs b/src/test/compile-fail/bind-by-move-neither-can-live-while-the-other-survives-2.rs index aac69a847cf..b58fe788846 100644 --- a/src/test/compile-fail/bind-by-move-neither-can-live-while-the-other-survives-2.rs +++ b/src/test/compile-fail/bind-by-move-neither-can-live-while-the-other-survives-2.rs @@ -20,6 +20,6 @@ fn main() { let x = Some((X { x: () }, X { x: () })); match move x { Some((ref _y, move _z)) => { }, //~ ERROR cannot bind by-move and by-ref in the same pattern - None => fail + None => die!() } } diff --git a/src/test/compile-fail/bind-by-move-neither-can-live-while-the-other-survives-3.rs b/src/test/compile-fail/bind-by-move-neither-can-live-while-the-other-survives-3.rs index aa15364b8fc..8f9682e662c 100644 --- a/src/test/compile-fail/bind-by-move-neither-can-live-while-the-other-survives-3.rs +++ b/src/test/compile-fail/bind-by-move-neither-can-live-while-the-other-survives-3.rs @@ -22,6 +22,6 @@ fn main() { let x = some2(X { x: () }, X { x: () }); match move x { some2(ref _y, move _z) => { }, //~ ERROR cannot bind by-move and by-ref in the same pattern - none2 => fail + none2 => die!() } } diff --git a/src/test/compile-fail/bind-by-move-neither-can-live-while-the-other-survives-4.rs b/src/test/compile-fail/bind-by-move-neither-can-live-while-the-other-survives-4.rs index 41ef2fd8e2c..6c14dd4d141 100644 --- a/src/test/compile-fail/bind-by-move-neither-can-live-while-the-other-survives-4.rs +++ b/src/test/compile-fail/bind-by-move-neither-can-live-while-the-other-survives-4.rs @@ -20,6 +20,6 @@ fn main() { let x = Some((X { x: () }, X { x: () })); match move x { Some((move _y, ref _z)) => { }, //~ ERROR cannot bind by-move and by-ref in the same pattern - None => fail + None => die!() } } diff --git a/src/test/compile-fail/bind-by-move-no-guards.rs b/src/test/compile-fail/bind-by-move-no-guards.rs index a5cc7ea10d7..45b5a896f6b 100644 --- a/src/test/compile-fail/bind-by-move-no-guards.rs +++ b/src/test/compile-fail/bind-by-move-no-guards.rs @@ -13,8 +13,8 @@ fn main() { let x = Some(p); c.send(false); match move x { - Some(move z) if z.recv() => { fail }, //~ ERROR cannot bind by-move into a pattern guard + Some(move z) if z.recv() => { die!() }, //~ ERROR cannot bind by-move into a pattern guard Some(move z) => { assert !z.recv(); }, - None => fail + None => die!() } } diff --git a/src/test/compile-fail/bind-by-move-no-lvalues-1.rs b/src/test/compile-fail/bind-by-move-no-lvalues-1.rs index 391f1e51180..c8b8ebecce8 100644 --- a/src/test/compile-fail/bind-by-move-no-lvalues-1.rs +++ b/src/test/compile-fail/bind-by-move-no-lvalues-1.rs @@ -22,6 +22,6 @@ fn main() { let x = Some(X { x: () }); match x { Some(move _z) => { }, //~ ERROR cannot bind by-move when matching an lvalue - None => fail + None => die!() } } diff --git a/src/test/compile-fail/bind-by-move-no-lvalues-2.rs b/src/test/compile-fail/bind-by-move-no-lvalues-2.rs index 0c1856a334c..889ccb3fd99 100644 --- a/src/test/compile-fail/bind-by-move-no-lvalues-2.rs +++ b/src/test/compile-fail/bind-by-move-no-lvalues-2.rs @@ -24,6 +24,6 @@ fn main() { let x = Y { y: Some(X { x: () }) }; match x.y { Some(move _z) => { }, //~ ERROR cannot bind by-move when matching an lvalue - None => fail + None => die!() } } diff --git a/src/test/compile-fail/bind-by-move-no-sub-bindings.rs b/src/test/compile-fail/bind-by-move-no-sub-bindings.rs index 8c71109f748..40196fe0817 100644 --- a/src/test/compile-fail/bind-by-move-no-sub-bindings.rs +++ b/src/test/compile-fail/bind-by-move-no-sub-bindings.rs @@ -20,6 +20,6 @@ fn main() { let x = Some(X { x: () }); match move x { Some(move _y @ ref _z) => { }, //~ ERROR cannot bind by-move with sub-bindings - None => fail + None => die!() } } diff --git a/src/test/compile-fail/borrowck-autoref-3261.rs b/src/test/compile-fail/borrowck-autoref-3261.rs index 0aec458aef4..6ce631c68a3 100644 --- a/src/test/compile-fail/borrowck-autoref-3261.rs +++ b/src/test/compile-fail/borrowck-autoref-3261.rs @@ -23,7 +23,7 @@ fn main() { x = X(Left((0,0))); //~ ERROR assigning to captured outer mutable variable (*f)() }, - _ => fail + _ => die!() } } } diff --git a/src/test/compile-fail/borrowck-borrowed-uniq-rvalue.rs b/src/test/compile-fail/borrowck-borrowed-uniq-rvalue.rs index 19cdfe784d2..55cbb1cbdca 100644 --- a/src/test/compile-fail/borrowck-borrowed-uniq-rvalue.rs +++ b/src/test/compile-fail/borrowck-borrowed-uniq-rvalue.rs @@ -10,8 +10,8 @@ //buggy.rs extern mod std; -use std::map::HashMap; -use std::map; +use std::oldmap::HashMap; +use std::oldmap; fn main() { let buggy_map :HashMap<uint, &uint> = diff --git a/src/test/compile-fail/borrowck-loan-local-as-both-mut-and-imm.rs b/src/test/compile-fail/borrowck-loan-local-as-both-mut-and-imm.rs index 4459a9a384e..9aec4b49ef2 100644 --- a/src/test/compile-fail/borrowck-loan-local-as-both-mut-and-imm.rs +++ b/src/test/compile-fail/borrowck-loan-local-as-both-mut-and-imm.rs @@ -16,7 +16,7 @@ use core::either::{Either, Left, Right}; *x = Right(1.0); *z } - _ => fail + _ => die!() } } diff --git a/src/test/compile-fail/borrowck-ref-into-rvalue.rs b/src/test/compile-fail/borrowck-ref-into-rvalue.rs index 529c17f6772..0c2903765fc 100644 --- a/src/test/compile-fail/borrowck-ref-into-rvalue.rs +++ b/src/test/compile-fail/borrowck-ref-into-rvalue.rs @@ -14,7 +14,7 @@ fn main() { Some(ref m) => { msg = m; }, - None => { fail } + None => { die!() } } io::println(*msg); } diff --git a/src/test/compile-fail/borrowck-vec-pattern-element-loan.rs b/src/test/compile-fail/borrowck-vec-pattern-element-loan.rs index 358917de85f..94067700270 100644 --- a/src/test/compile-fail/borrowck-vec-pattern-element-loan.rs +++ b/src/test/compile-fail/borrowck-vec-pattern-element-loan.rs @@ -2,7 +2,7 @@ fn a() -> &[int] { let vec = [1, 2, 3, 4]; let tail = match vec { //~ ERROR illegal borrow [_a, ..tail] => tail, - _ => fail ~"foo" + _ => die!(~"foo") }; move tail } diff --git a/src/test/compile-fail/borrowck-vec-pattern-nesting.rs b/src/test/compile-fail/borrowck-vec-pattern-nesting.rs index 50feff707ad..0a200e736ba 100644 --- a/src/test/compile-fail/borrowck-vec-pattern-nesting.rs +++ b/src/test/compile-fail/borrowck-vec-pattern-nesting.rs @@ -4,7 +4,7 @@ fn a() { [~ref _a] => { vec[0] = ~4; //~ ERROR prohibited due to outstanding loan } - _ => fail ~"foo" + _ => die!(~"foo") } } diff --git a/src/test/compile-fail/borrowck-vec-pattern-tail-element-loan.rs b/src/test/compile-fail/borrowck-vec-pattern-tail-element-loan.rs index 6477fd9fb2c..64bb571b2dc 100644 --- a/src/test/compile-fail/borrowck-vec-pattern-tail-element-loan.rs +++ b/src/test/compile-fail/borrowck-vec-pattern-tail-element-loan.rs @@ -2,7 +2,7 @@ fn a() -> &int { let vec = [1, 2, 3, 4]; let tail = match vec { //~ ERROR illegal borrow [_a, ..tail] => &tail[0], - _ => fail ~"foo" + _ => die!(~"foo") }; move tail } diff --git a/src/test/compile-fail/closure-that-fails.rs b/src/test/compile-fail/closure-that-fails.rs index 00bfa7a2233..a76649fb990 100644 --- a/src/test/compile-fail/closure-that-fails.rs +++ b/src/test/compile-fail/closure-that-fails.rs @@ -2,6 +2,6 @@ fn foo(f: fn() -> !) {} fn main() { // Type inference didn't use to be able to handle this: - foo(|| fail); + foo(|| die!()); foo(|| 22); //~ ERROR mismatched types } diff --git a/src/test/compile-fail/deref-non-pointer.rs b/src/test/compile-fail/deref-non-pointer.rs index 6dacfc03f21..ef84b11d5fc 100644 --- a/src/test/compile-fail/deref-non-pointer.rs +++ b/src/test/compile-fail/deref-non-pointer.rs @@ -11,6 +11,6 @@ // error-pattern:cannot be dereferenced fn main() { match *1 { - _ => { fail; } + _ => { die!(); } } -} \ No newline at end of file +} diff --git a/src/test/compile-fail/fail-expr.rs b/src/test/compile-fail/fail-expr.rs index ea446ada029..6d4f5ba2f4c 100644 --- a/src/test/compile-fail/fail-expr.rs +++ b/src/test/compile-fail/fail-expr.rs @@ -10,4 +10,4 @@ // error-pattern:mismatched types -fn main() { fail 5; } +fn main() { die!(5); } diff --git a/src/test/compile-fail/fail-simple.rs b/src/test/compile-fail/fail-simple.rs index 580f02ba391..eab577f713b 100644 --- a/src/test/compile-fail/fail-simple.rs +++ b/src/test/compile-fail/fail-simple.rs @@ -12,5 +12,5 @@ // error-pattern:unexpected token fn main() { - fail @ ; + die!(@); } diff --git a/src/test/compile-fail/fail-type-err.rs b/src/test/compile-fail/fail-type-err.rs index 90989141b8d..8e32c086962 100644 --- a/src/test/compile-fail/fail-type-err.rs +++ b/src/test/compile-fail/fail-type-err.rs @@ -9,4 +9,4 @@ // except according to those terms. // error-pattern:expected `~str` but found `~[int]` -fn main() { fail ~[0i]; } +fn main() { die!(~[0i]); } diff --git a/src/test/compile-fail/for-loop-decl.rs b/src/test/compile-fail/for-loop-decl.rs index 9745f80a909..3f497094208 100644 --- a/src/test/compile-fail/for-loop-decl.rs +++ b/src/test/compile-fail/for-loop-decl.rs @@ -10,7 +10,7 @@ // error-pattern: mismatched types extern mod std; -use std::map::HashMap; +use std::oldmap::HashMap; use std::bitv; type fn_info = {vars: HashMap<uint, var_info>}; diff --git a/src/test/compile-fail/issue-2149.rs b/src/test/compile-fail/issue-2149.rs index f29afabf556..3df9dc8300a 100644 --- a/src/test/compile-fail/issue-2149.rs +++ b/src/test/compile-fail/issue-2149.rs @@ -14,7 +14,7 @@ trait vec_monad<A> { impl<A> ~[A]: vec_monad<A> { fn bind<B>(f: fn(A) -> ~[B]) { - let mut r = fail; + let mut r = die!(); for self.each |elt| { r += f(*elt); } //~^ WARNING unreachable expression //~^^ ERROR the type of this value must be known diff --git a/src/test/compile-fail/issue-2150.rs b/src/test/compile-fail/issue-2150.rs index 44b4384e853..51883aa9734 100644 --- a/src/test/compile-fail/issue-2150.rs +++ b/src/test/compile-fail/issue-2150.rs @@ -9,10 +9,10 @@ // except according to those terms. fn fail_len(v: ~[const int]) -> uint { - let mut i = fail; + let mut i = die!(); for v.each |x| { i += 1u; } //~^ WARNING unreachable statement //~^^ ERROR the type of this value must be known return i; } -fn main() {} \ No newline at end of file +fn main() {} diff --git a/src/test/compile-fail/issue-2151.rs b/src/test/compile-fail/issue-2151.rs index f95452fa048..ef72f7245ac 100644 --- a/src/test/compile-fail/issue-2151.rs +++ b/src/test/compile-fail/issue-2151.rs @@ -9,8 +9,8 @@ // except according to those terms. fn main() { - for vec::each(fail) |i| { + for vec::each(die!()) |i| { log (debug, i * 2); //~^ ERROR the type of this value must be known }; -} \ No newline at end of file +} diff --git a/src/test/compile-fail/issue-2330.rs b/src/test/compile-fail/issue-2330.rs index f9649b9db92..abaeb37e6c2 100644 --- a/src/test/compile-fail/issue-2330.rs +++ b/src/test/compile-fail/issue-2330.rs @@ -16,7 +16,7 @@ trait channel<T> { // `chan` is not a trait, it's an enum impl int: chan { //~ ERROR can only implement trait types - fn send(v: int) { fail } + fn send(v: int) { die!() } } fn main() { diff --git a/src/test/compile-fail/issue-2354.rs b/src/test/compile-fail/issue-2354.rs index 2505859a737..37945839de4 100644 --- a/src/test/compile-fail/issue-2354.rs +++ b/src/test/compile-fail/issue-2354.rs @@ -16,8 +16,8 @@ */ fn foo() { //~ ERROR this open brace is not closed match Some(x) { - Some(y) { fail; } - None { fail; } + Some(y) { die!(); } + None { die!(); } } fn bar() { diff --git a/src/test/compile-fail/issue-2611-3.rs b/src/test/compile-fail/issue-2611-3.rs index ce337589a13..7624e33e9ad 100644 --- a/src/test/compile-fail/issue-2611-3.rs +++ b/src/test/compile-fail/issue-2611-3.rs @@ -24,7 +24,7 @@ struct E { } impl E: A { - fn b<F:Copy, G>(_x: F) -> F { fail } //~ ERROR in method `b`, type parameter 0 has 1 bound, but + fn b<F:Copy, G>(_x: F) -> F { die!() } //~ ERROR in method `b`, type parameter 0 has 1 bound, but } -fn main() {} \ No newline at end of file +fn main() {} diff --git a/src/test/compile-fail/issue-2611-4.rs b/src/test/compile-fail/issue-2611-4.rs index a92b6c76d98..1e923974d33 100644 --- a/src/test/compile-fail/issue-2611-4.rs +++ b/src/test/compile-fail/issue-2611-4.rs @@ -21,7 +21,7 @@ struct E { } impl E: A { - fn b<F:Copy Const, G>(_x: F) -> F { fail } //~ ERROR in method `b`, type parameter 0 has 2 bounds, but + fn b<F:Copy Const, G>(_x: F) -> F { die!() } //~ ERROR in method `b`, type parameter 0 has 2 bounds, but } -fn main() {} \ No newline at end of file +fn main() {} diff --git a/src/test/compile-fail/issue-2611-5.rs b/src/test/compile-fail/issue-2611-5.rs index 5ab882d1c36..e868d022d57 100644 --- a/src/test/compile-fail/issue-2611-5.rs +++ b/src/test/compile-fail/issue-2611-5.rs @@ -22,7 +22,7 @@ struct E { impl E: A { // n.b. The error message is awful -- see #3404 - fn b<F:Copy, G>(_x: G) -> G { fail } //~ ERROR method `b` has an incompatible type + fn b<F:Copy, G>(_x: G) -> G { die!() } //~ ERROR method `b` has an incompatible type } -fn main() {} \ No newline at end of file +fn main() {} diff --git a/src/test/compile-fail/issue-2817.rs b/src/test/compile-fail/issue-2817.rs index e9c38d17838..45b72634293 100644 --- a/src/test/compile-fail/issue-2817.rs +++ b/src/test/compile-fail/issue-2817.rs @@ -8,11 +8,11 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -fn uuid() -> uint { fail; } +fn uuid() -> uint { die!(); } -fn from_str(s: ~str) -> uint { fail; } -fn to_str(u: uint) -> ~str { fail; } -fn uuid_random() -> uint { fail; } +fn from_str(s: ~str) -> uint { die!(); } +fn to_str(u: uint) -> ~str { die!(); } +fn uuid_random() -> uint { die!(); } fn main() { do uint::range(0, 100000) |_i| { //~ ERROR Do-block body must return bool, but @@ -22,4 +22,4 @@ fn main() { do uint::range(0, 100000) |_i| { //~ ERROR mismatched types ~"str" } -} \ No newline at end of file +} diff --git a/src/test/compile-fail/issue-3021.rs b/src/test/compile-fail/issue-3021.rs index 620b2a84ba8..cde878e122a 100644 --- a/src/test/compile-fail/issue-3021.rs +++ b/src/test/compile-fail/issue-3021.rs @@ -26,7 +26,7 @@ fn siphash(k0 : u64) -> siphash { //~^ ERROR unresolved name: k0 } } - fail; + die!(); } fn main() {} diff --git a/src/test/compile-fail/issue-3601.rs b/src/test/compile-fail/issue-3601.rs index 3e54aaa287c..74136d95573 100644 --- a/src/test/compile-fail/issue-3601.rs +++ b/src/test/compile-fail/issue-3601.rs @@ -37,6 +37,6 @@ fn main() { ~Element(ed) => match ed.kind { ~HTMLImageElement(d) if d.image.is_some() => { true } }, - _ => fail ~"WAT" //~ ERROR wat + _ => die!(~"WAT") //~ ERROR wat }; } diff --git a/src/test/compile-fail/issue-3668.rs b/src/test/compile-fail/issue-3668.rs index 60306a1aa6a..5fc692ed3ec 100644 --- a/src/test/compile-fail/issue-3668.rs +++ b/src/test/compile-fail/issue-3668.rs @@ -16,7 +16,7 @@ trait PTrait { impl P: PTrait { fn getChildOption() -> Option<@P> { const childVal: @P = self.child.get(); //~ ERROR attempt to use a non-constant value in a constant - fail; + die!(); } } diff --git a/src/test/compile-fail/issue-3973.rs b/src/test/compile-fail/issue-3973.rs index 6c977840c22..5d49610a4e5 100644 --- a/src/test/compile-fail/issue-3973.rs +++ b/src/test/compile-fail/issue-3973.rs @@ -20,7 +20,7 @@ impl Point : ToStr { //~ ERROR implements a method not defined in the trait Point { x: x, y: y } } - pure fn to_str() -> ~str { + pure fn to_str(&self) -> ~str { fmt!("(%f, %f)", self.x, self.y) } } diff --git a/src/test/compile-fail/issue-897-2.rs b/src/test/compile-fail/issue-897-2.rs index 61afdab405d..e910ea1fa57 100644 --- a/src/test/compile-fail/issue-897-2.rs +++ b/src/test/compile-fail/issue-897-2.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -fn g() -> ! { fail; } +fn g() -> ! { die!(); } fn f() -> ! { return 42i; //~ ERROR expected `!` but found `int` g(); //~ WARNING unreachable statement diff --git a/src/test/compile-fail/issue-897.rs b/src/test/compile-fail/issue-897.rs index 1ed7034be77..f5f4b376a99 100644 --- a/src/test/compile-fail/issue-897.rs +++ b/src/test/compile-fail/issue-897.rs @@ -10,6 +10,6 @@ fn f() -> ! { return 42i; //~ ERROR expected `!` but found `int` - fail; //~ WARNING unreachable statement + die!(); //~ WARNING unreachable statement } fn main() { } diff --git a/src/test/compile-fail/liveness-use-after-send.rs b/src/test/compile-fail/liveness-use-after-send.rs index 2746c5a304b..fcdf9438e3d 100644 --- a/src/test/compile-fail/liveness-use-after-send.rs +++ b/src/test/compile-fail/liveness-use-after-send.rs @@ -11,7 +11,7 @@ fn send<T: Owned>(ch: _chan<T>, -data: T) { log(debug, ch); log(debug, data); - fail; + die!(); } enum _chan<T> = int; @@ -23,4 +23,4 @@ fn test00_start(ch: _chan<~int>, message: ~int, _count: ~int) { log(debug, message); //~ ERROR use of moved value: `message` } -fn main() { fail; } +fn main() { die!(); } diff --git a/src/test/compile-fail/map-types.rs b/src/test/compile-fail/map-types.rs index 7161e854447..f829c730637 100644 --- a/src/test/compile-fail/map-types.rs +++ b/src/test/compile-fail/map-types.rs @@ -8,16 +8,14 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -extern mod std; -use std::map; -use std::map::HashMap; -use std::map::StdMap; +use core::container::Map; +use core::hashmap::linear::LinearMap; // Test that trait types printed in error msgs include the type arguments. fn main() { - let x: StdMap<~str,~str> = map::HashMap::<~str,~str>() as - StdMap::<~str,~str>; - let y: StdMap<uint,~str> = x; - //~^ ERROR mismatched types: expected `@std::map::StdMap<uint,~str>` + let x: Map<~str, ~str> = LinearMap::new::<~str, ~str>() as + Map::<~str, ~str>; + let y: Map<uint, ~str> = x; + //~^ ERROR mismatched types: expected `@core::container::Map/&<uint,~str>` } diff --git a/src/test/compile-fail/moves-based-on-type-exprs.rs b/src/test/compile-fail/moves-based-on-type-exprs.rs index 07fe8318836..be842a4cdd7 100644 --- a/src/test/compile-fail/moves-based-on-type-exprs.rs +++ b/src/test/compile-fail/moves-based-on-type-exprs.rs @@ -2,7 +2,7 @@ // they occur as part of various kinds of expressions. struct Foo<A> { f: A } -fn guard(_s: ~str) -> bool {fail} +fn guard(_s: ~str) -> bool {die!()} fn touch<A>(_a: &A) {} fn f10() { @@ -92,4 +92,4 @@ fn f120() { touch(&x[1]); } -fn main() {} \ No newline at end of file +fn main() {} diff --git a/src/test/compile-fail/multitrait.rs b/src/test/compile-fail/multitrait.rs index 6fe93c151e6..a0a9e3f0ddf 100644 --- a/src/test/compile-fail/multitrait.rs +++ b/src/test/compile-fail/multitrait.rs @@ -14,5 +14,5 @@ struct S { impl S: Cmp, ToStr { //~ ERROR: expected `{` but found `,` fn eq(&&other: S) { false } - fn to_str() -> ~str { ~"hi" } -} \ No newline at end of file + fn to_str(&self) -> ~str { ~"hi" } +} diff --git a/src/test/compile-fail/non-exhaustive-match-nested.rs b/src/test/compile-fail/non-exhaustive-match-nested.rs index 01e7e40be55..b8db996ebfa 100644 --- a/src/test/compile-fail/non-exhaustive-match-nested.rs +++ b/src/test/compile-fail/non-exhaustive-match-nested.rs @@ -16,8 +16,8 @@ enum u { c, d } fn main() { let x = a(c); match x { - a(d) => { fail ~"hello"; } - b => { fail ~"goodbye"; } + a(d) => { die!(~"hello"); } + b => { die!(~"goodbye"); } } } diff --git a/src/test/compile-fail/noncopyable-match-pattern.rs b/src/test/compile-fail/noncopyable-match-pattern.rs index 27dbfdf4319..9b2d129a1a8 100644 --- a/src/test/compile-fail/noncopyable-match-pattern.rs +++ b/src/test/compile-fail/noncopyable-match-pattern.rs @@ -14,6 +14,6 @@ fn main() { Some(copy z) => { //~ ERROR copying a noncopyable value do z.with |b| { assert !*b; } } - None => fail + None => die!() } } diff --git a/src/test/compile-fail/not-enough-arguments.rs b/src/test/compile-fail/not-enough-arguments.rs index d79889c7157..ef4f0f4fb53 100644 --- a/src/test/compile-fail/not-enough-arguments.rs +++ b/src/test/compile-fail/not-enough-arguments.rs @@ -13,7 +13,7 @@ // unrelated errors. fn foo(a: int, b: int, c: int, d:int) { - fail; + die!(); } fn main() { diff --git a/src/test/compile-fail/pattern-tyvar-2.rs b/src/test/compile-fail/pattern-tyvar-2.rs index 37efa3174bc..7942a38caa0 100644 --- a/src/test/compile-fail/pattern-tyvar-2.rs +++ b/src/test/compile-fail/pattern-tyvar-2.rs @@ -17,6 +17,6 @@ use option::Some; enum bar { t1((), Option<~[int]>), t2, } -fn foo(t: bar) -> int { match t { t1(_, Some(x)) => { return x * 3; } _ => { fail; } } } +fn foo(t: bar) -> int { match t { t1(_, Some(x)) => { return x * 3; } _ => { die!(); } } } fn main() { } diff --git a/src/test/compile-fail/pattern-tyvar.rs b/src/test/compile-fail/pattern-tyvar.rs index 66cf814fe2c..3b4200bb4be 100644 --- a/src/test/compile-fail/pattern-tyvar.rs +++ b/src/test/compile-fail/pattern-tyvar.rs @@ -21,7 +21,7 @@ fn foo(t: bar) { t1(_, Some::<int>(x)) => { log(debug, x); } - _ => { fail; } + _ => { die!(); } } } diff --git a/src/test/compile-fail/qquote-1.rs b/src/test/compile-fail/qquote-1.rs index a343158337d..2fc487d13d2 100644 --- a/src/test/compile-fail/qquote-1.rs +++ b/src/test/compile-fail/qquote-1.rs @@ -63,6 +63,6 @@ fn main() { } fn check_pp<T>(expr: T, f: fn(pprust::ps, T), expect: str) { - fail; + die!(); } diff --git a/src/test/compile-fail/qquote-2.rs b/src/test/compile-fail/qquote-2.rs index b7e33f99e3b..43b1d287739 100644 --- a/src/test/compile-fail/qquote-2.rs +++ b/src/test/compile-fail/qquote-2.rs @@ -58,6 +58,6 @@ fn main() { } fn check_pp<T>(expr: T, f: fn(pprust::ps, T), expect: str) { - fail; + die!(); } diff --git a/src/test/compile-fail/regions-fn-bound.rs b/src/test/compile-fail/regions-fn-bound.rs index a878e87c7a1..95a5222d14c 100644 --- a/src/test/compile-fail/regions-fn-bound.rs +++ b/src/test/compile-fail/regions-fn-bound.rs @@ -8,8 +8,8 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -fn of<T>() -> @fn(T) { fail; } -fn subtype<T>(x: @fn(T)) { fail; } +fn of<T>() -> @fn(T) { die!(); } +fn subtype<T>(x: @fn(T)) { die!(); } fn test_fn<T>(_x: &x/T, _y: &y/T, _z: &z/T) { // Here, x, y, and z are free. Other letters diff --git a/src/test/compile-fail/regions-fn-subtyping.rs b/src/test/compile-fail/regions-fn-subtyping.rs index 6163e6ee744..3ead89b2082 100644 --- a/src/test/compile-fail/regions-fn-subtyping.rs +++ b/src/test/compile-fail/regions-fn-subtyping.rs @@ -8,8 +8,8 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -fn of<T>() -> @fn(T) { fail; } -fn subtype<T>(x: @fn(T)) { fail; } +fn of<T>() -> @fn(T) { die!(); } +fn subtype<T>(x: @fn(T)) { die!(); } fn test_fn<T>(_x: &x/T, _y: &y/T, _z: &z/T) { // Here, x, y, and z are free. Other letters @@ -54,4 +54,4 @@ fn test_fn<T>(_x: &x/T, _y: &y/T, _z: &z/T) { of::<fn(&a/T) -> @fn(&a/T)>()); } -fn main() {} \ No newline at end of file +fn main() {} diff --git a/src/test/compile-fail/tag-that-dare-not-speak-its-name.rs b/src/test/compile-fail/tag-that-dare-not-speak-its-name.rs index 8f7d8734a6a..c6cd05b7a65 100644 --- a/src/test/compile-fail/tag-that-dare-not-speak-its-name.rs +++ b/src/test/compile-fail/tag-that-dare-not-speak-its-name.rs @@ -16,7 +16,7 @@ extern mod core; fn last<T>(v: ~[const &T]) -> core::Option<T> { - fail; + die!(); } fn main() { diff --git a/src/test/compile-fail/tag-type-args.rs b/src/test/compile-fail/tag-type-args.rs index dd29c6bf659..ea40d8bd077 100644 --- a/src/test/compile-fail/tag-type-args.rs +++ b/src/test/compile-fail/tag-type-args.rs @@ -14,4 +14,4 @@ enum quux<T> { bar } fn foo(c: quux) { assert (false); } -fn main() { fail; } +fn main() { die!(); } diff --git a/src/test/compile-fail/warn-foreign-int-types.rs b/src/test/compile-fail/warn-foreign-int-types.rs index 1c312de7726..801e3e71030 100644 --- a/src/test/compile-fail/warn-foreign-int-types.rs +++ b/src/test/compile-fail/warn-foreign-int-types.rs @@ -16,5 +16,5 @@ extern mod xx { fn main() { // let it fail to verify warning message - fail + die!() } diff --git a/src/test/pretty/issue-929.rs b/src/test/pretty/issue-929.rs index 8d4f86adc53..7b24d256cb0 100644 --- a/src/test/pretty/issue-929.rs +++ b/src/test/pretty/issue-929.rs @@ -8,6 +8,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -fn f() { if (1 == fail) { } else { } } +fn f() { if (1 == die!()) { } else { } } -fn main() { } \ No newline at end of file +fn main() { } diff --git a/src/test/run-fail/alt-bot-fail.rs b/src/test/run-fail/alt-bot-fail.rs index 4f2372326fa..ac465d81b7e 100644 --- a/src/test/run-fail/alt-bot-fail.rs +++ b/src/test/run-fail/alt-bot-fail.rs @@ -14,6 +14,6 @@ fn foo(s: ~str) { } fn main() { let i = - match Some::<int>(3) { None::<int> => { fail } Some::<int>(_) => { fail } }; + match Some::<int>(3) { None::<int> => { die!() } Some::<int>(_) => { die!() } }; foo(i); } diff --git a/src/test/run-fail/alt-disc-bot.rs b/src/test/run-fail/alt-disc-bot.rs index 6380a82de9a..c74e16f4222 100644 --- a/src/test/run-fail/alt-disc-bot.rs +++ b/src/test/run-fail/alt-disc-bot.rs @@ -9,6 +9,6 @@ // except according to those terms. // error-pattern:quux -fn f() -> ! { fail ~"quux" } +fn f() -> ! { die!(~"quux") } fn g() -> int { match f() { true => { 1 } false => { 0 } } } fn main() { g(); } diff --git a/src/test/run-fail/alt-wildcards.rs b/src/test/run-fail/alt-wildcards.rs index 8fee5a90dd4..e30a73601c6 100644 --- a/src/test/run-fail/alt-wildcards.rs +++ b/src/test/run-fail/alt-wildcards.rs @@ -11,9 +11,9 @@ // error-pattern:squirrelcupcake fn cmp() -> int { match (option::Some('a'), option::None::<char>) { - (option::Some(_), _) => { fail ~"squirrelcupcake"; } - (_, option::Some(_)) => { fail; } - _ => { fail ~"wat"; } + (option::Some(_), _) => { die!(~"squirrelcupcake"); } + (_, option::Some(_)) => { die!(); } + _ => { die!(~"wat"); } } } diff --git a/src/test/run-fail/args-fail.rs b/src/test/run-fail/args-fail.rs index 5829f5ce646..c3675109948 100644 --- a/src/test/run-fail/args-fail.rs +++ b/src/test/run-fail/args-fail.rs @@ -9,6 +9,6 @@ // except according to those terms. // error-pattern:meep -fn f(a: int, b: int, c: @int) { fail ~"moop"; } +fn f(a: int, b: int, c: @int) { die!(~"moop"); } -fn main() { f(1, fail ~"meep", @42); } +fn main() { f(1, die!(~"meep"), @42); } diff --git a/src/test/run-fail/binop-fail-2.rs b/src/test/run-fail/binop-fail-2.rs index 7acfdc31051..1e553d1089d 100644 --- a/src/test/run-fail/binop-fail-2.rs +++ b/src/test/run-fail/binop-fail-2.rs @@ -9,5 +9,5 @@ // except according to those terms. // error-pattern:quux -fn my_err(s: ~str) -> ! { log(error, s); fail ~"quux"; } +fn my_err(s: ~str) -> ! { log(error, s); die!(~"quux"); } fn main() { 3u == my_err(~"bye"); } diff --git a/src/test/run-fail/binop-fail.rs b/src/test/run-fail/binop-fail.rs index 7acfdc31051..1e553d1089d 100644 --- a/src/test/run-fail/binop-fail.rs +++ b/src/test/run-fail/binop-fail.rs @@ -9,5 +9,5 @@ // except according to those terms. // error-pattern:quux -fn my_err(s: ~str) -> ! { log(error, s); fail ~"quux"; } +fn my_err(s: ~str) -> ! { log(error, s); die!(~"quux"); } fn main() { 3u == my_err(~"bye"); } diff --git a/src/test/run-fail/bug-811.rs b/src/test/run-fail/bug-811.rs index 31158df4185..f16e838aaf5 100644 --- a/src/test/run-fail/bug-811.rs +++ b/src/test/run-fail/bug-811.rs @@ -16,6 +16,6 @@ type port_id = int; enum chan_t<T> = {task: task_id, port: port_id}; -fn send<T: Owned>(ch: chan_t<T>, data: T) { fail; } +fn send<T: Owned>(ch: chan_t<T>, data: T) { die!(); } -fn main() { fail ~"quux"; } +fn main() { die!(~"quux"); } diff --git a/src/test/run-fail/doublefail.rs b/src/test/run-fail/doublefail.rs index 559983022fe..38e29d02fdd 100644 --- a/src/test/run-fail/doublefail.rs +++ b/src/test/run-fail/doublefail.rs @@ -10,6 +10,6 @@ //error-pattern:One fn main() { - fail ~"One"; - fail ~"Two"; -} \ No newline at end of file + die!(~"One"); + die!(~"Two"); +} diff --git a/src/test/run-fail/explicit-fail-msg.rs b/src/test/run-fail/explicit-fail-msg.rs index c88eb7296aa..ac5eaefe32b 100644 --- a/src/test/run-fail/explicit-fail-msg.rs +++ b/src/test/run-fail/explicit-fail-msg.rs @@ -10,5 +10,5 @@ // error-pattern:wooooo fn main() { - let mut a = 1; if 1 == 1 { a = 2; } fail ~"woooo" + ~"o"; + let mut a = 1; if 1 == 1 { a = 2; } die!(~"woooo" + ~"o"); } diff --git a/src/test/run-fail/explicit-fail.rs b/src/test/run-fail/explicit-fail.rs index fe4a1e82061..acc5ef91668 100644 --- a/src/test/run-fail/explicit-fail.rs +++ b/src/test/run-fail/explicit-fail.rs @@ -12,4 +12,4 @@ // error-pattern:explicit -fn main() { fail; } +fn main() { die!(); } diff --git a/src/test/run-fail/expr-alt-fail-fn.rs b/src/test/run-fail/expr-alt-fail-fn.rs index 366831b74d8..6cb0f4f3260 100644 --- a/src/test/run-fail/expr-alt-fail-fn.rs +++ b/src/test/run-fail/expr-alt-fail-fn.rs @@ -12,7 +12,7 @@ // error-pattern:explicit failure -fn f() -> ! { fail } +fn f() -> ! { die!() } fn g() -> int { let x = match true { true => { f() } false => { 10 } }; return x; } diff --git a/src/test/run-fail/expr-alt-fail.rs b/src/test/run-fail/expr-alt-fail.rs index 9eae7440086..b70382955e3 100644 --- a/src/test/run-fail/expr-alt-fail.rs +++ b/src/test/run-fail/expr-alt-fail.rs @@ -12,4 +12,4 @@ // error-pattern:explicit failure -fn main() { let x = match true { false => { 0 } true => { fail } }; } +fn main() { let x = match true { false => { 0 } true => { die!() } }; } diff --git a/src/test/run-fail/expr-fn-fail.rs b/src/test/run-fail/expr-fn-fail.rs index 6dacdf0b466..2b840a71b8b 100644 --- a/src/test/run-fail/expr-fn-fail.rs +++ b/src/test/run-fail/expr-fn-fail.rs @@ -12,6 +12,6 @@ // error-pattern:explicit failure -fn f() -> ! { fail } +fn f() -> ! { die!() } fn main() { f(); } diff --git a/src/test/run-fail/expr-if-fail-fn.rs b/src/test/run-fail/expr-if-fail-fn.rs index 2f59f8c8c0a..cd6efa7302a 100644 --- a/src/test/run-fail/expr-if-fail-fn.rs +++ b/src/test/run-fail/expr-if-fail-fn.rs @@ -12,7 +12,7 @@ // error-pattern:explicit failure -fn f() -> ! { fail } +fn f() -> ! { die!() } fn g() -> int { let x = if true { f() } else { 10 }; return x; } diff --git a/src/test/run-fail/expr-if-fail.rs b/src/test/run-fail/expr-if-fail.rs index 8b1ff8baf03..d39a0271e64 100644 --- a/src/test/run-fail/expr-if-fail.rs +++ b/src/test/run-fail/expr-if-fail.rs @@ -12,4 +12,4 @@ // error-pattern:explicit failure -fn main() { let x = if false { 0 } else if true { fail } else { 10 }; } +fn main() { let x = if false { 0 } else if true { die!() } else { 10 }; } diff --git a/src/test/run-fail/extern-fail.rs b/src/test/run-fail/extern-fail.rs index f84f428bd4e..7f59d499fd3 100644 --- a/src/test/run-fail/extern-fail.rs +++ b/src/test/run-fail/extern-fail.rs @@ -37,7 +37,7 @@ fn main() { do task::spawn { let result = count(5u); debug!("result = %?", result); - fail; + die!(); }; } } diff --git a/src/test/run-fail/fail-arg.rs b/src/test/run-fail/fail-arg.rs index 62d3c824223..4ead0db2d42 100644 --- a/src/test/run-fail/fail-arg.rs +++ b/src/test/run-fail/fail-arg.rs @@ -11,4 +11,4 @@ // error-pattern:woe fn f(a: int) { log(debug, a); } -fn main() { f(fail ~"woe"); } +fn main() { f(die!(~"woe")); } diff --git a/src/test/run-fail/fail-main.rs b/src/test/run-fail/fail-main.rs index f21b765f56f..2755f8e47a2 100644 --- a/src/test/run-fail/fail-main.rs +++ b/src/test/run-fail/fail-main.rs @@ -10,4 +10,4 @@ // error-pattern:moop extern mod std; -fn main() { fail ~"moop"; } +fn main() { die!(~"moop"); } diff --git a/src/test/run-fail/fail-parens.rs b/src/test/run-fail/fail-parens.rs index 20ad9b00284..144a36bd730 100644 --- a/src/test/run-fail/fail-parens.rs +++ b/src/test/run-fail/fail-parens.rs @@ -8,13 +8,13 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -// Fail statements without arguments need to be disambiguated in +// Fail macros without arguments need to be disambiguated in // certain positions // error-pattern:oops fn bigfail() { - while (fail ~"oops") { if (fail) { - match (fail) { () => { + while (die!(~"oops")) { if (die!()) { + match (die!()) { () => { } } }}; diff --git a/src/test/run-fail/fmt-fail.rs b/src/test/run-fail/fmt-fail.rs index 47878edbf63..3e6f8a433c6 100644 --- a/src/test/run-fail/fmt-fail.rs +++ b/src/test/run-fail/fmt-fail.rs @@ -11,4 +11,4 @@ // error-pattern:meh extern mod std; -fn main() { let str_var: ~str = ~"meh"; fail fmt!("%s", str_var); } +fn main() { let str_var: ~str = ~"meh"; die!(fmt!("%s", str_var)); } diff --git a/src/test/run-fail/for-each-loop-fail.rs b/src/test/run-fail/for-each-loop-fail.rs index 5a2ad5acc6e..bbae1b1739d 100644 --- a/src/test/run-fail/for-each-loop-fail.rs +++ b/src/test/run-fail/for-each-loop-fail.rs @@ -10,4 +10,4 @@ // error-pattern:moop extern mod std; -fn main() { for uint::range(0u, 10u) |_i| { fail ~"moop"; } } +fn main() { for uint::range(0u, 10u) |_i| { die!(~"moop"); } } diff --git a/src/test/run-fail/if-check-fail.rs b/src/test/run-fail/if-check-fail.rs index 1a2baf902f2..f0bc250f1cb 100644 --- a/src/test/run-fail/if-check-fail.rs +++ b/src/test/run-fail/if-check-fail.rs @@ -19,7 +19,7 @@ fn foo(x: uint) { if even(x) { log(debug, x); } else { - fail ~"Number is odd"; + die!(~"Number is odd"); } } diff --git a/src/test/run-fail/if-cond-bot.rs b/src/test/run-fail/if-cond-bot.rs index 7aa0568896d..1212b550cfb 100644 --- a/src/test/run-fail/if-cond-bot.rs +++ b/src/test/run-fail/if-cond-bot.rs @@ -9,5 +9,5 @@ // except according to those terms. // error-pattern:quux -fn my_err(s: ~str) -> ! { log(error, s); fail ~"quux"; } +fn my_err(s: ~str) -> ! { log(error, s); die!(~"quux"); } fn main() { if my_err(~"bye") { } } diff --git a/src/test/run-fail/issue-1459.rs b/src/test/run-fail/issue-1459.rs index 3480d5e7c71..bb97e5b2b6a 100644 --- a/src/test/run-fail/issue-1459.rs +++ b/src/test/run-fail/issue-1459.rs @@ -10,5 +10,5 @@ // error-pattern:roflcopter fn main() { - log (fail ~"roflcopter", 2); + log (die!(~"roflcopter"), 2); } diff --git a/src/test/run-fail/issue-2156.rs b/src/test/run-fail/issue-2156.rs index 90e32e532fe..deb8192fc3b 100644 --- a/src/test/run-fail/issue-2156.rs +++ b/src/test/run-fail/issue-2156.rs @@ -15,6 +15,6 @@ use io::ReaderUtil; fn main() { do io::with_str_reader(~"") |rdr| { - match rdr.read_char() { '=' => { } _ => { fail } } + match rdr.read_char() { '=' => { } _ => { die!() } } } } diff --git a/src/test/run-fail/issue-2272.rs b/src/test/run-fail/issue-2272.rs index c81ef07f5d7..de7475b3303 100644 --- a/src/test/run-fail/issue-2272.rs +++ b/src/test/run-fail/issue-2272.rs @@ -22,5 +22,5 @@ fn main() { }, a: ~0 }; - fail; -} \ No newline at end of file + die!(); +} diff --git a/src/test/run-fail/issue-2444.rs b/src/test/run-fail/issue-2444.rs index 9172364a2f9..a4c329a41fc 100644 --- a/src/test/run-fail/issue-2444.rs +++ b/src/test/run-fail/issue-2444.rs @@ -15,7 +15,7 @@ use std::arc; enum e<T> { e(arc::ARC<T>) } -fn foo() -> e<int> {fail;} +fn foo() -> e<int> {die!();} fn main() { let f = foo(); diff --git a/src/test/run-fail/issue-3029.rs b/src/test/run-fail/issue-3029.rs index 1998cc0be91..ca4774cd53e 100644 --- a/src/test/run-fail/issue-3029.rs +++ b/src/test/run-fail/issue-3029.rs @@ -11,7 +11,7 @@ // error-pattern:so long fn main() { let x = ~[], y = ~[3]; - fail ~"so long"; + die!(~"so long"); x += y; ~"good" + ~"bye"; } diff --git a/src/test/run-fail/issue-948.rs b/src/test/run-fail/issue-948.rs index 7a41eb0ca50..ddb3eecdbf1 100644 --- a/src/test/run-fail/issue-948.rs +++ b/src/test/run-fail/issue-948.rs @@ -14,5 +14,5 @@ struct Point { x: int, y: int } fn main() { let origin = Point {x: 0, y: 0}; - let f: Point = Point {x: (fail ~"beep boop"),.. origin}; + let f: Point = Point {x: (die!(~"beep boop")),.. origin}; } diff --git a/src/test/run-fail/linked-failure2.rs b/src/test/run-fail/linked-failure2.rs index dc571af636e..f020cb7eafd 100644 --- a/src/test/run-fail/linked-failure2.rs +++ b/src/test/run-fail/linked-failure2.rs @@ -12,7 +12,7 @@ // error-pattern:fail -fn child() { fail; } +fn child() { die!(); } fn main() { let (p, _c) = pipes::stream::<()>(); diff --git a/src/test/run-fail/linked-failure3.rs b/src/test/run-fail/linked-failure3.rs index b9f785a7958..78e3798399c 100644 --- a/src/test/run-fail/linked-failure3.rs +++ b/src/test/run-fail/linked-failure3.rs @@ -12,7 +12,7 @@ // error-pattern:fail -fn grandchild() { fail ~"grandchild dies"; } +fn grandchild() { die!(~"grandchild dies"); } fn child() { let (p, _c) = pipes::stream::<int>(); diff --git a/src/test/run-fail/morestack1.rs b/src/test/run-fail/morestack1.rs index d6d14ba9d84..63a7cc7ed89 100644 --- a/src/test/run-fail/morestack1.rs +++ b/src/test/run-fail/morestack1.rs @@ -8,15 +8,15 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -// error-pattern:explicit failure +// error-pattern:fail fn getbig(i: int) { if i != 0 { getbig(i - 1); } else { - fail; + die!(); } } fn main() { getbig(100000); -} \ No newline at end of file +} diff --git a/src/test/run-fail/morestack2.rs b/src/test/run-fail/morestack2.rs index 2b8a8b13eac..58957aac203 100644 --- a/src/test/run-fail/morestack2.rs +++ b/src/test/run-fail/morestack2.rs @@ -27,7 +27,7 @@ fn getbig_call_c_and_fail(i: int) { } else { unsafe { rustrt::last_os_error(); - fail; + die!(); } } } diff --git a/src/test/run-fail/morestack3.rs b/src/test/run-fail/morestack3.rs index c2cf3ca6e6a..01296a82969 100644 --- a/src/test/run-fail/morestack3.rs +++ b/src/test/run-fail/morestack3.rs @@ -19,7 +19,7 @@ fn getbig_and_fail(&&i: int) { if i != 0 { getbig_and_fail(i - 1); } else { - fail; + die!(); } } diff --git a/src/test/run-fail/morestack4.rs b/src/test/run-fail/morestack4.rs index 38a88284a00..e8b6785d1e8 100644 --- a/src/test/run-fail/morestack4.rs +++ b/src/test/run-fail/morestack4.rs @@ -19,7 +19,7 @@ fn getbig_and_fail(&&i: int) { if i != 0 { getbig_and_fail(i - 1); } else { - fail; + die!(); } } diff --git a/src/test/run-fail/rhs-type.rs b/src/test/run-fail/rhs-type.rs index 54a3e9d5a97..32d8f84292b 100644 --- a/src/test/run-fail/rhs-type.rs +++ b/src/test/run-fail/rhs-type.rs @@ -14,4 +14,4 @@ struct T { t: ~str } -fn main() { let pth = fail ~"bye"; let rs: T = T {t: pth}; } +fn main() { let pth = die!(~"bye"); let rs: T = T {t: pth}; } diff --git a/src/test/run-fail/rt-log-trunc.rs b/src/test/run-fail/rt-log-trunc.rs index c3b7b69bdeb..a27404e46fe 100644 --- a/src/test/run-fail/rt-log-trunc.rs +++ b/src/test/run-fail/rt-log-trunc.rs @@ -12,7 +12,7 @@ // error-pattern:[...] fn main() { - fail ~"\ + die!(~"\ aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\ aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\ aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\ @@ -70,5 +70,5 @@ fn main() { aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\ aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\ aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\ - "; + "); } diff --git a/src/test/run-fail/rt-set-exit-status-fail.rs b/src/test/run-fail/rt-set-exit-status-fail.rs index a0023675bc2..de4b062d700 100644 --- a/src/test/run-fail/rt-set-exit-status-fail.rs +++ b/src/test/run-fail/rt-set-exit-status-fail.rs @@ -16,5 +16,5 @@ fn main() { // normally. In this case we're going to fail, so instead of of // returning 50 the process will return the typical rt failure code. os::set_exit_status(50); - fail; -} \ No newline at end of file + die!(); +} diff --git a/src/test/run-fail/rt-set-exit-status-fail2.rs b/src/test/run-fail/rt-set-exit-status-fail2.rs index ddbe6a0a408..ece9f5fdc51 100644 --- a/src/test/run-fail/rt-set-exit-status-fail2.rs +++ b/src/test/run-fail/rt-set-exit-status-fail2.rs @@ -34,5 +34,5 @@ fn main() { do task::spawn { let i = r(5); }; - fail; + die!(); } diff --git a/src/test/run-fail/run-unexported-tests.rs b/src/test/run-fail/run-unexported-tests.rs index 8d229a191b7..48adac55586 100644 --- a/src/test/run-fail/run-unexported-tests.rs +++ b/src/test/run-fail/run-unexported-tests.rs @@ -17,5 +17,5 @@ mod m { pub fn exported() { } #[test] - fn unexported() { fail ~"runned an unexported test"; } + fn unexported() { die!(~"runned an unexported test"); } } diff --git a/src/test/run-fail/spawnfail.rs b/src/test/run-fail/spawnfail.rs index 5915ca46d72..e7bfe1b67c5 100644 --- a/src/test/run-fail/spawnfail.rs +++ b/src/test/run-fail/spawnfail.rs @@ -15,7 +15,7 @@ extern mod std; // We don't want to see any invalid reads fn main() { fn f() { - fail; + die!(); } task::spawn(|| f() ); -} \ No newline at end of file +} diff --git a/src/test/run-fail/task-comm-recv-block.rs b/src/test/run-fail/task-comm-recv-block.rs index 9c8ec249255..0b36977d9b5 100644 --- a/src/test/run-fail/task-comm-recv-block.rs +++ b/src/test/run-fail/task-comm-recv-block.rs @@ -12,7 +12,7 @@ fn goodfail() { task::yield(); - fail ~"goodfail"; + die!(~"goodfail"); } fn main() { @@ -21,5 +21,5 @@ fn main() { // We shouldn't be able to get past this recv since there's no // message available let i: int = po.recv(); - fail ~"badfail"; + die!(~"badfail"); } diff --git a/src/test/run-fail/unique-fail.rs b/src/test/run-fail/unique-fail.rs index e66688dadbe..0cb37dfd260 100644 --- a/src/test/run-fail/unique-fail.rs +++ b/src/test/run-fail/unique-fail.rs @@ -9,4 +9,4 @@ // except according to those terms. // error-pattern: fail -fn main() { ~fail; } +fn main() { ~die!(); } diff --git a/src/test/run-fail/unwind-alt.rs b/src/test/run-fail/unwind-alt.rs index 9e6729e41bb..559c7c2d89d 100644 --- a/src/test/run-fail/unwind-alt.rs +++ b/src/test/run-fail/unwind-alt.rs @@ -15,10 +15,10 @@ fn test_box() { } fn test_str() { let res = match false { true => { ~"happy" }, - _ => fail ~"non-exhaustive match failure" }; + _ => die!(~"non-exhaustive match failure") }; assert res == ~"happy"; } fn main() { test_box(); test_str(); -} \ No newline at end of file +} diff --git a/src/test/run-fail/unwind-box-fn-unique.rs b/src/test/run-fail/unwind-box-fn-unique.rs index fc304317c93..ca6d154f4e6 100644 --- a/src/test/run-fail/unwind-box-fn-unique.rs +++ b/src/test/run-fail/unwind-box-fn-unique.rs @@ -11,7 +11,7 @@ // error-pattern:fail fn failfn() { - fail; + die!(); } fn main() { diff --git a/src/test/run-fail/unwind-box-fn.rs b/src/test/run-fail/unwind-box-fn.rs index 6cca9332779..94a03142bec 100644 --- a/src/test/run-fail/unwind-box-fn.rs +++ b/src/test/run-fail/unwind-box-fn.rs @@ -11,7 +11,7 @@ // error-pattern:fail fn failfn() { - fail; + die!(); } fn main() { diff --git a/src/test/run-fail/unwind-box-res.rs b/src/test/run-fail/unwind-box-res.rs index b38651b3165..13b1bc36ba9 100644 --- a/src/test/run-fail/unwind-box-res.rs +++ b/src/test/run-fail/unwind-box-res.rs @@ -11,7 +11,7 @@ // error-pattern:fail fn failfn() { - fail; + die!(); } struct r { diff --git a/src/test/run-fail/unwind-box-str.rs b/src/test/run-fail/unwind-box-str.rs index 98043f09f23..1469a56a6d4 100644 --- a/src/test/run-fail/unwind-box-str.rs +++ b/src/test/run-fail/unwind-box-str.rs @@ -11,11 +11,11 @@ // error-pattern:fail fn failfn() { - fail; + die!(); } fn main() { let x = @~"hi"; failfn(); log(error, x); -} \ No newline at end of file +} diff --git a/src/test/run-fail/unwind-box-trait.rs b/src/test/run-fail/unwind-box-trait.rs index 3bae24b3721..d41e0f19324 100644 --- a/src/test/run-fail/unwind-box-trait.rs +++ b/src/test/run-fail/unwind-box-trait.rs @@ -11,7 +11,7 @@ // error-pattern:fail fn failfn() { - fail; + die!(); } trait i { @@ -26,4 +26,4 @@ fn main() { let x = ~0 as i; failfn(); log(error, x); -} \ No newline at end of file +} diff --git a/src/test/run-fail/unwind-box-unique-unique.rs b/src/test/run-fail/unwind-box-unique-unique.rs index 19a6c0685e8..8f24d2922f9 100644 --- a/src/test/run-fail/unwind-box-unique-unique.rs +++ b/src/test/run-fail/unwind-box-unique-unique.rs @@ -11,11 +11,11 @@ // error-pattern:fail fn failfn() { - fail; + die!(); } fn main() { let x = @~~0; failfn(); log(error, x); -} \ No newline at end of file +} diff --git a/src/test/run-fail/unwind-box-unique.rs b/src/test/run-fail/unwind-box-unique.rs index 85ed6090deb..8a1dcef5ca5 100644 --- a/src/test/run-fail/unwind-box-unique.rs +++ b/src/test/run-fail/unwind-box-unique.rs @@ -11,11 +11,11 @@ // error-pattern:fail fn failfn() { - fail; + die!(); } fn main() { let x = @~0; failfn(); log(error, x); -} \ No newline at end of file +} diff --git a/src/test/run-fail/unwind-box-vec.rs b/src/test/run-fail/unwind-box-vec.rs index 14fb50e27f2..e2559e66eae 100644 --- a/src/test/run-fail/unwind-box-vec.rs +++ b/src/test/run-fail/unwind-box-vec.rs @@ -11,11 +11,11 @@ // error-pattern:fail fn failfn() { - fail; + die!(); } fn main() { let x = @~[0, 1, 2, 3, 4, 5]; failfn(); log(error, x); -} \ No newline at end of file +} diff --git a/src/test/run-fail/unwind-box.rs b/src/test/run-fail/unwind-box.rs index 473adaee9e5..02761fef976 100644 --- a/src/test/run-fail/unwind-box.rs +++ b/src/test/run-fail/unwind-box.rs @@ -11,10 +11,10 @@ // error-pattern:fail fn failfn() { - fail; + die!(); } fn main() { @0; failfn(); -} \ No newline at end of file +} diff --git a/src/test/run-fail/unwind-closure.rs b/src/test/run-fail/unwind-closure.rs index 5d0f6bb3e04..f6a3fa1ab67 100644 --- a/src/test/run-fail/unwind-closure.rs +++ b/src/test/run-fail/unwind-closure.rs @@ -11,11 +11,11 @@ // error-pattern:fail fn f(a: @int) { - fail; + die!(); } fn main() { let b = @0; let g : fn@() = |move b|f(b); g(); -} \ No newline at end of file +} diff --git a/src/test/run-fail/unwind-fail.rs b/src/test/run-fail/unwind-fail.rs index b6f7507ac90..5c776b5fd7a 100644 --- a/src/test/run-fail/unwind-fail.rs +++ b/src/test/run-fail/unwind-fail.rs @@ -12,5 +12,5 @@ fn main() { @0; - fail; -} \ No newline at end of file + die!(); +} diff --git a/src/test/run-fail/unwind-initializer-indirect.rs b/src/test/run-fail/unwind-initializer-indirect.rs index 54672f9d560..69106602ec8 100644 --- a/src/test/run-fail/unwind-initializer-indirect.rs +++ b/src/test/run-fail/unwind-initializer-indirect.rs @@ -10,8 +10,8 @@ // error-pattern:fail -fn f() -> @int { fail; } +fn f() -> @int { die!(); } fn main() { let a: @int = f(); -} \ No newline at end of file +} diff --git a/src/test/run-fail/unwind-initializer.rs b/src/test/run-fail/unwind-initializer.rs index e3c9e3bd764..7047a77a6e7 100644 --- a/src/test/run-fail/unwind-initializer.rs +++ b/src/test/run-fail/unwind-initializer.rs @@ -12,6 +12,6 @@ fn main() { let a: @int = { - fail; + die!(); }; -} \ No newline at end of file +} diff --git a/src/test/run-fail/unwind-interleaved.rs b/src/test/run-fail/unwind-interleaved.rs index 29ec85ab51b..4dac04d379d 100644 --- a/src/test/run-fail/unwind-interleaved.rs +++ b/src/test/run-fail/unwind-interleaved.rs @@ -12,11 +12,11 @@ fn a() { } -fn b() { fail; } +fn b() { die!(); } fn main() { let x = ~[0]; a(); let y = ~[0]; b(); -} \ No newline at end of file +} diff --git a/src/test/run-fail/unwind-iter.rs b/src/test/run-fail/unwind-iter.rs index 2280ca4e05c..7c5782a1813 100644 --- a/src/test/run-fail/unwind-iter.rs +++ b/src/test/run-fail/unwind-iter.rs @@ -11,11 +11,11 @@ // error-pattern:fail fn x(it: fn(int)) { - fail; + die!(); it(0); } fn main() { let a = @0; x(|_i| { } ); -} \ No newline at end of file +} diff --git a/src/test/run-fail/unwind-iter2.rs b/src/test/run-fail/unwind-iter2.rs index 781b9300794..8621209fd5d 100644 --- a/src/test/run-fail/unwind-iter2.rs +++ b/src/test/run-fail/unwind-iter2.rs @@ -16,5 +16,5 @@ fn x(it: fn(int)) { } fn main() { - x(|_x| fail ); -} \ No newline at end of file + x(|_x| die!() ); +} diff --git a/src/test/run-fail/unwind-lambda.rs b/src/test/run-fail/unwind-lambda.rs index f2a95728237..89d6dd4970e 100644 --- a/src/test/run-fail/unwind-lambda.rs +++ b/src/test/run-fail/unwind-lambda.rs @@ -21,8 +21,8 @@ fn main() { let cheese = copy cheese; let f = fn@() { let chew = mush + cheese; - fail ~"so yummy" + die!(~"so yummy") }; f(); }); -} \ No newline at end of file +} diff --git a/src/test/run-fail/unwind-misc-1.rs b/src/test/run-fail/unwind-misc-1.rs index 2ba118bdd6f..a504e374b95 100644 --- a/src/test/run-fail/unwind-misc-1.rs +++ b/src/test/run-fail/unwind-misc-1.rs @@ -11,18 +11,18 @@ // error-pattern:fail extern mod std; -use std::map; -use std::map::HashMap; +use std::oldmap; +use std::oldmap::HashMap; fn main() { let count = @mut 0u; - let map = map::HashMap(); + let map = oldmap::HashMap(); let mut arr = ~[]; for uint::range(0u, 10u) |i| { arr += ~[@~"key stuff"]; map.insert(copy arr, arr + ~[@~"value stuff"]); if arr.len() == 5 { - fail; + die!(); } } } diff --git a/src/test/run-fail/unwind-move.rs b/src/test/run-fail/unwind-move.rs index a3b458c2a36..2419edf650c 100644 --- a/src/test/run-fail/unwind-move.rs +++ b/src/test/run-fail/unwind-move.rs @@ -10,10 +10,10 @@ // error-pattern:fail fn f(-_a: @int) { - fail; + die!(); } fn main() { let a = @0; f(move a); -} \ No newline at end of file +} diff --git a/src/test/run-fail/unwind-nested.rs b/src/test/run-fail/unwind-nested.rs index 43c1e4b75c5..450c982eb3f 100644 --- a/src/test/run-fail/unwind-nested.rs +++ b/src/test/run-fail/unwind-nested.rs @@ -15,7 +15,7 @@ fn main() { { let b = @0; { - fail; + die!(); } } -} \ No newline at end of file +} diff --git a/src/test/run-fail/unwind-partial-box.rs b/src/test/run-fail/unwind-partial-box.rs index 67039e7381c..7a5c81eed7a 100644 --- a/src/test/run-fail/unwind-partial-box.rs +++ b/src/test/run-fail/unwind-partial-box.rs @@ -10,7 +10,7 @@ // error-pattern:fail -fn f() -> ~[int] { fail; } +fn f() -> ~[int] { die!(); } // Voodoo. In unwind-alt we had to do this to trigger the bug. Might // have been to do with memory allocation patterns. @@ -25,4 +25,4 @@ fn partial() { fn main() { prime(); partial(); -} \ No newline at end of file +} diff --git a/src/test/run-fail/unwind-partial-unique.rs b/src/test/run-fail/unwind-partial-unique.rs index db18964fa9b..12f0a7b4785 100644 --- a/src/test/run-fail/unwind-partial-unique.rs +++ b/src/test/run-fail/unwind-partial-unique.rs @@ -10,7 +10,7 @@ // error-pattern:fail -fn f() -> ~[int] { fail; } +fn f() -> ~[int] { die!(); } // Voodoo. In unwind-alt we had to do this to trigger the bug. Might // have been to do with memory allocation patterns. @@ -25,4 +25,4 @@ fn partial() { fn main() { prime(); partial(); -} \ No newline at end of file +} diff --git a/src/test/run-fail/unwind-partial-vec.rs b/src/test/run-fail/unwind-partial-vec.rs index b6ea8caaa6a..87df161cfd3 100644 --- a/src/test/run-fail/unwind-partial-vec.rs +++ b/src/test/run-fail/unwind-partial-vec.rs @@ -10,7 +10,7 @@ // error-pattern:fail -fn f() -> ~[int] { fail; } +fn f() -> ~[int] { die!(); } // Voodoo. In unwind-alt we had to do this to trigger the bug. Might // have been to do with memory allocation patterns. @@ -25,4 +25,4 @@ fn partial() { fn main() { prime(); partial(); -} \ No newline at end of file +} diff --git a/src/test/run-fail/unwind-rec.rs b/src/test/run-fail/unwind-rec.rs index 200d511db54..324783893f9 100644 --- a/src/test/run-fail/unwind-rec.rs +++ b/src/test/run-fail/unwind-rec.rs @@ -11,7 +11,7 @@ // error-pattern:fail fn build() -> ~[int] { - fail; + die!(); } struct Blk { node: ~[int] } @@ -20,4 +20,4 @@ fn main() { let blk = Blk { node: build() }; -} \ No newline at end of file +} diff --git a/src/test/run-fail/unwind-rec2.rs b/src/test/run-fail/unwind-rec2.rs index bf35abdafaf..0e2c279e98a 100644 --- a/src/test/run-fail/unwind-rec2.rs +++ b/src/test/run-fail/unwind-rec2.rs @@ -15,7 +15,7 @@ fn build1() -> ~[int] { } fn build2() -> ~[int] { - fail; + die!(); } struct Blk { node: ~[int], span: ~[int] } @@ -25,4 +25,4 @@ fn main() { node: build1(), span: build2() }; -} \ No newline at end of file +} diff --git a/src/test/run-fail/unwind-resource-fail.rs b/src/test/run-fail/unwind-resource-fail.rs index a11c99dfb07..a5ff8302495 100644 --- a/src/test/run-fail/unwind-resource-fail.rs +++ b/src/test/run-fail/unwind-resource-fail.rs @@ -12,7 +12,7 @@ struct r { i: int, - drop { fail ~"squirrel" } + drop { die!(~"squirrel") } } fn r(i: int) -> r { r { i: i } } diff --git a/src/test/run-fail/unwind-resource-fail2.rs b/src/test/run-fail/unwind-resource-fail2.rs index d435990eb0e..69575e6e13a 100644 --- a/src/test/run-fail/unwind-resource-fail2.rs +++ b/src/test/run-fail/unwind-resource-fail2.rs @@ -13,7 +13,7 @@ struct r { i: int, - drop { fail ~"wombat" } + drop { die!(~"wombat") } } fn r(i: int) -> r { r { i: i } } @@ -21,5 +21,5 @@ fn r(i: int) -> r { r { i: i } } fn main() { @0; let r = move r(0); - fail; -} \ No newline at end of file + die!(); +} diff --git a/src/test/run-fail/unwind-resource-fail3.rs b/src/test/run-fail/unwind-resource-fail3.rs index 5c66e415582..10adfdf1fa3 100644 --- a/src/test/run-fail/unwind-resource-fail3.rs +++ b/src/test/run-fail/unwind-resource-fail3.rs @@ -19,7 +19,7 @@ fn faily_box(i: @int) -> faily_box { faily_box { i: i } } impl faily_box : Drop { fn finalize(&self) { - fail ~"quux"; + die!(~"quux"); } } diff --git a/src/test/run-fail/unwind-stacked.rs b/src/test/run-fail/unwind-stacked.rs index 730bbf2c196..42a4a7e376d 100644 --- a/src/test/run-fail/unwind-stacked.rs +++ b/src/test/run-fail/unwind-stacked.rs @@ -12,7 +12,7 @@ fn f() { let a = @0; - fail; + die!(); } fn g() { @@ -23,4 +23,4 @@ fn g() { fn main() { let a = @0; g(); -} \ No newline at end of file +} diff --git a/src/test/run-fail/unwind-tup.rs b/src/test/run-fail/unwind-tup.rs index 207adcec9f1..6cd234ae770 100644 --- a/src/test/run-fail/unwind-tup.rs +++ b/src/test/run-fail/unwind-tup.rs @@ -11,7 +11,7 @@ // error-pattern:fail fn fold_local() -> @~[int]{ - fail; + die!(); } fn main() { diff --git a/src/test/run-fail/unwind-tup2.rs b/src/test/run-fail/unwind-tup2.rs index fa9ccbfcc14..83ed7efcd44 100644 --- a/src/test/run-fail/unwind-tup2.rs +++ b/src/test/run-fail/unwind-tup2.rs @@ -15,7 +15,7 @@ fn fold_local() -> @~[int]{ } fn fold_remote() -> @~[int]{ - fail; + die!(); } fn main() { diff --git a/src/test/run-fail/unwind-uninitialized.rs b/src/test/run-fail/unwind-uninitialized.rs index 04f42c497da..56321e33829 100644 --- a/src/test/run-fail/unwind-uninitialized.rs +++ b/src/test/run-fail/unwind-uninitialized.rs @@ -11,10 +11,10 @@ // error-pattern:fail fn f() { - fail; + die!(); } fn main() { f(); let a = @0; -} \ No newline at end of file +} diff --git a/src/test/run-fail/unwind-unique.rs b/src/test/run-fail/unwind-unique.rs index 0c65cce9d0f..e9de0c4520a 100644 --- a/src/test/run-fail/unwind-unique.rs +++ b/src/test/run-fail/unwind-unique.rs @@ -11,10 +11,10 @@ // error-pattern:fail fn failfn() { - fail; + die!(); } fn main() { ~0; failfn(); -} \ No newline at end of file +} diff --git a/src/test/run-fail/while-body-fails.rs b/src/test/run-fail/while-body-fails.rs index 67a3bcbeeec..de483d6dc47 100644 --- a/src/test/run-fail/while-body-fails.rs +++ b/src/test/run-fail/while-body-fails.rs @@ -9,4 +9,4 @@ // except according to those terms. // error-pattern:quux -fn main() { let x: int = { while true { fail ~"quux"; } ; 8 } ; } +fn main() { let x: int = { while true { die!(~"quux"); } ; 8 } ; } diff --git a/src/test/run-fail/while-fail.rs b/src/test/run-fail/while-fail.rs index c09fd4a9a48..951737aa9b2 100644 --- a/src/test/run-fail/while-fail.rs +++ b/src/test/run-fail/while-fail.rs @@ -10,5 +10,5 @@ // error-pattern:giraffe fn main() { - fail { while true { fail ~"giraffe"}; ~"clandestine" }; + die!({ while true { die!(~"giraffe")}; ~"clandestine" }); } diff --git a/src/test/run-fail/zip-different-lengths.rs b/src/test/run-fail/zip-different-lengths.rs index 8c3c6f52f10..2a27be56bec 100644 --- a/src/test/run-fail/zip-different-lengths.rs +++ b/src/test/run-fail/zip-different-lengths.rs @@ -37,5 +37,5 @@ fn main() { assert same_length(chars, ints); let ps = zip(chars, ints); - fail ~"the impossible happened"; + die!(~"the impossible happened"); } diff --git a/src/test/run-pass/alias-uninit-value.rs b/src/test/run-pass/alias-uninit-value.rs index 888acf30b2a..ab395466afc 100644 --- a/src/test/run-pass/alias-uninit-value.rs +++ b/src/test/run-pass/alias-uninit-value.rs @@ -20,4 +20,4 @@ fn mk_raw_ty(st: sty, cname: Option<~str>) -> RawT { return RawT {struct_: st, cname: cname, hash: 0u}; } -fn main() { mk_raw_ty(ty_nil, None::<~str>); } +pub fn main() { mk_raw_ty(ty_nil, None::<~str>); } diff --git a/src/test/run-pass/alignment-gep-tup-like-1.rs b/src/test/run-pass/alignment-gep-tup-like-1.rs index a880b50d628..64cc58c2af5 100644 --- a/src/test/run-pass/alignment-gep-tup-like-1.rs +++ b/src/test/run-pass/alignment-gep-tup-like-1.rs @@ -16,7 +16,7 @@ fn f<A:Copy &static>(a: A, b: u16) -> fn@() -> (A, u16) { fn@() -> (A, u16) { (a, b) } } -fn main() { +pub fn main() { let (a, b) = f(22_u64, 44u16)(); debug!("a=%? b=%?", a, b); assert a == 22u64; diff --git a/src/test/run-pass/alignment-gep-tup-like-2.rs b/src/test/run-pass/alignment-gep-tup-like-2.rs index 2e0e3ea8f55..01dcd6a3647 100644 --- a/src/test/run-pass/alignment-gep-tup-like-2.rs +++ b/src/test/run-pass/alignment-gep-tup-like-2.rs @@ -27,7 +27,7 @@ fn f<A:Owned Copy, B:Owned Copy>(a: A, b: B) -> fn@() -> (A, B) { fn@() -> (A, B) { (a, b) } } -fn main() { +pub fn main() { let x = 22_u8; let y = 44_u64; let z = f(~x, y); diff --git a/src/test/run-pass/alloca-from-derived-tydesc.rs b/src/test/run-pass/alloca-from-derived-tydesc.rs index 2901754c8f2..37fdfca4468 100644 --- a/src/test/run-pass/alloca-from-derived-tydesc.rs +++ b/src/test/run-pass/alloca-from-derived-tydesc.rs @@ -14,4 +14,4 @@ struct R<T> {mut v: ~[option<T>]} fn f<T>() -> ~[T] { return ~[]; } -fn main() { let r: R<int> = R {mut v: ~[]}; r.v = f(); } +pub fn main() { let r: R<int> = R {mut v: ~[]}; r.v = f(); } diff --git a/src/test/run-pass/alt-borrowed_str.rs b/src/test/run-pass/alt-borrowed_str.rs index a1a02b99962..1a58174a3fb 100644 --- a/src/test/run-pass/alt-borrowed_str.rs +++ b/src/test/run-pass/alt-borrowed_str.rs @@ -33,7 +33,7 @@ fn g2(ref_1: &str, ref_2: &str) { } } -fn main() { +pub fn main() { f1(@"a"); f1(~"b"); f1(&"c"); diff --git a/src/test/run-pass/alt-bot-2.rs b/src/test/run-pass/alt-bot-2.rs index cd943a7963b..2ca1881417e 100644 --- a/src/test/run-pass/alt-bot-2.rs +++ b/src/test/run-pass/alt-bot-2.rs @@ -9,5 +9,5 @@ // except according to those terms. // n.b. This was only ever failing with optimization disabled. -fn a() -> int { match return 1 { 2 => 3, _ => fail } } -fn main() { a(); } +fn a() -> int { match return 1 { 2 => 3, _ => die!() } } +pub fn main() { a(); } diff --git a/src/test/run-pass/alt-bot.rs b/src/test/run-pass/alt-bot.rs index 73597704b4c..cb30c5e96a0 100644 --- a/src/test/run-pass/alt-bot.rs +++ b/src/test/run-pass/alt-bot.rs @@ -9,8 +9,8 @@ // except according to those terms. -fn main() { +pub fn main() { let i: int = - match Some::<int>(3) { None::<int> => { fail } Some::<int>(_) => { 5 } }; + match Some::<int>(3) { None::<int> => { die!() } Some::<int>(_) => { 5 } }; log(debug, i); } diff --git a/src/test/run-pass/alt-implicit-copy-unique.rs b/src/test/run-pass/alt-implicit-copy-unique.rs index a30a0c64215..58076b59ceb 100644 --- a/src/test/run-pass/alt-implicit-copy-unique.rs +++ b/src/test/run-pass/alt-implicit-copy-unique.rs @@ -10,7 +10,7 @@ struct Pair { mut a: ~int, mut b: ~int } -fn main() { +pub fn main() { let x = ~Pair {mut a: ~10, b: ~20}; match x { ~Pair {a: ref mut a, b: ref b} => { diff --git a/src/test/run-pass/alt-join.rs b/src/test/run-pass/alt-join.rs index 2dfda0fcb34..b9f25396b32 100644 --- a/src/test/run-pass/alt-join.rs +++ b/src/test/run-pass/alt-join.rs @@ -28,4 +28,4 @@ fn foo<T>(y: Option<T>) { return; } -fn main() { debug!("hello"); foo::<int>(Some::<int>(5)); } +pub fn main() { debug!("hello"); foo::<int>(Some::<int>(5)); } diff --git a/src/test/run-pass/alt-naked-record-expr.rs b/src/test/run-pass/alt-naked-record-expr.rs index f23cf72cf1f..649bdd202df 100644 --- a/src/test/run-pass/alt-naked-record-expr.rs +++ b/src/test/run-pass/alt-naked-record-expr.rs @@ -10,7 +10,7 @@ struct X { x: int } -fn main() { +pub fn main() { let x = match 0 { _ => X { x: 0 diff --git a/src/test/run-pass/alt-naked-record.rs b/src/test/run-pass/alt-naked-record.rs index dbb8b07b8e8..4d89fdc6910 100644 --- a/src/test/run-pass/alt-naked-record.rs +++ b/src/test/run-pass/alt-naked-record.rs @@ -10,7 +10,7 @@ struct X { x: int } -fn main() { +pub fn main() { let x = match 0 { _ => X { x: 0 diff --git a/src/test/run-pass/alt-path.rs b/src/test/run-pass/alt-path.rs index 0d00dec6760..3da6bb93486 100644 --- a/src/test/run-pass/alt-path.rs +++ b/src/test/run-pass/alt-path.rs @@ -16,4 +16,4 @@ mod m1 { fn bar(x: m1::foo) { match x { m1::foo1 => { } m1::foo2 => { } } } -fn main() { } +pub fn main() { } diff --git a/src/test/run-pass/alt-pattern-drop.rs b/src/test/run-pass/alt-pattern-drop.rs index ccc65cdab75..53ec6e0ed85 100644 --- a/src/test/run-pass/alt-pattern-drop.rs +++ b/src/test/run-pass/alt-pattern-drop.rs @@ -22,14 +22,14 @@ fn foo(s: @int) { log(debug, y); // ref up then down } - _ => { debug!("?"); fail; } + _ => { debug!("?"); die!(); } } log(debug, ::core::sys::refcount(s)); assert (::core::sys::refcount(s) == count + 1u); let _ = ::core::sys::refcount(s); // don't get bitten by last-use. } -fn main() { +pub fn main() { let s: @int = @0; // ref up let count = ::core::sys::refcount(s); diff --git a/src/test/run-pass/alt-pattern-lit.rs b/src/test/run-pass/alt-pattern-lit.rs index 57a71563c58..91e2643dd75 100644 --- a/src/test/run-pass/alt-pattern-lit.rs +++ b/src/test/run-pass/alt-pattern-lit.rs @@ -14,8 +14,8 @@ fn altlit(f: int) -> int { match f { 10 => { debug!("case 10"); return 20; } 11 => { debug!("case 11"); return 22; } - _ => fail ~"the impossible happened" + _ => die!(~"the impossible happened") } } -fn main() { assert (altlit(10) == 20); assert (altlit(11) == 22); } +pub fn main() { assert (altlit(10) == 20); assert (altlit(11) == 22); } diff --git a/src/test/run-pass/alt-pattern-no-type-params.rs b/src/test/run-pass/alt-pattern-no-type-params.rs index 1f1bd37f1a5..feabf7a8f4d 100644 --- a/src/test/run-pass/alt-pattern-no-type-params.rs +++ b/src/test/run-pass/alt-pattern-no-type-params.rs @@ -14,4 +14,4 @@ fn foo(x: maybe<int>) { match x { nothing => { error!("A"); } just(a) => { error!("B"); } } } -fn main() { } +pub fn main() { } diff --git a/src/test/run-pass/alt-pattern-simple.rs b/src/test/run-pass/alt-pattern-simple.rs index 417978a0b46..f4056008103 100644 --- a/src/test/run-pass/alt-pattern-simple.rs +++ b/src/test/run-pass/alt-pattern-simple.rs @@ -12,4 +12,4 @@ fn altsimple(f: int) { match f { x => () } } -fn main() { } +pub fn main() { } diff --git a/src/test/run-pass/alt-phi.rs b/src/test/run-pass/alt-phi.rs index 4ab30c79832..3702db8327e 100644 --- a/src/test/run-pass/alt-phi.rs +++ b/src/test/run-pass/alt-phi.rs @@ -14,7 +14,7 @@ enum thing { a, b, c, } fn foo(it: fn(int)) { it(10); } -fn main() { +pub fn main() { let mut x = true; match a { a => { x = true; foo(|_i| { } ) } diff --git a/src/test/run-pass/alt-range.rs b/src/test/run-pass/alt-range.rs index 92a906d85ee..b4e40a7b7ab 100644 --- a/src/test/run-pass/alt-range.rs +++ b/src/test/run-pass/alt-range.rs @@ -8,34 +8,34 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -fn main() { +pub fn main() { match 5u { 1u..5u => {} - _ => fail ~"should match range", + _ => die!(~"should match range"), } match 5u { - 6u..7u => fail ~"shouldn't match range", + 6u..7u => die!(~"shouldn't match range"), _ => {} } match 5u { - 1u => fail ~"should match non-first range", + 1u => die!(~"should match non-first range"), 2u..6u => {} - _ => fail ~"math is broken" + _ => die!(~"math is broken") } match 'c' { 'a'..'z' => {} - _ => fail ~"should suppport char ranges" + _ => die!(~"should suppport char ranges") } match -3 { -7..5 => {} - _ => fail ~"should match signed range" + _ => die!(~"should match signed range") } match 3.0 { 1.0..5.0 => {} - _ => fail ~"should match float range" + _ => die!(~"should match float range") } match -1.5 { -3.6..3.6 => {} - _ => fail ~"should match negative float range" + _ => die!(~"should match negative float range") } } diff --git a/src/test/run-pass/alt-ref-binding-in-guard-3256.rs b/src/test/run-pass/alt-ref-binding-in-guard-3256.rs index c3903abefba..407d496236f 100644 --- a/src/test/run-pass/alt-ref-binding-in-guard-3256.rs +++ b/src/test/run-pass/alt-ref-binding-in-guard-3256.rs @@ -8,12 +8,12 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -fn main() { +pub fn main() { let x = Some(private::exclusive(true)); match move x { Some(ref z) if z.with(|b| *b) => { do z.with |b| { assert *b; } }, - _ => fail + _ => die!() } -} \ No newline at end of file +} diff --git a/src/test/run-pass/alt-ref-binding-mut-option.rs b/src/test/run-pass/alt-ref-binding-mut-option.rs index 5a86fff3190..50bcd3644ed 100644 --- a/src/test/run-pass/alt-ref-binding-mut-option.rs +++ b/src/test/run-pass/alt-ref-binding-mut-option.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -fn main() { +pub fn main() { let mut v = Some(22); match v { None => {} diff --git a/src/test/run-pass/alt-ref-binding-mut.rs b/src/test/run-pass/alt-ref-binding-mut.rs index fc124041fd4..9f062f7b001 100644 --- a/src/test/run-pass/alt-ref-binding-mut.rs +++ b/src/test/run-pass/alt-ref-binding-mut.rs @@ -18,7 +18,7 @@ fn destructure(x: &mut Rec) { } } -fn main() { +pub fn main() { let mut v = Rec {f: 22}; destructure(&mut v); assert v.f == 23; diff --git a/src/test/run-pass/alt-ref-binding.rs b/src/test/run-pass/alt-ref-binding.rs index 05c40f7bb30..abb7aa30a01 100644 --- a/src/test/run-pass/alt-ref-binding.rs +++ b/src/test/run-pass/alt-ref-binding.rs @@ -15,6 +15,6 @@ fn destructure(x: Option<int>) -> int { } } -fn main() { +pub fn main() { assert destructure(Some(22)) == 22; } diff --git a/src/test/run-pass/alt-str.rs b/src/test/run-pass/alt-str.rs index 81506caf524..57e47854ce8 100644 --- a/src/test/run-pass/alt-str.rs +++ b/src/test/run-pass/alt-str.rs @@ -10,22 +10,22 @@ // Issue #53 -fn main() { - match ~"test" { ~"not-test" => fail, ~"test" => (), _ => fail } +pub fn main() { + match ~"test" { ~"not-test" => die!(), ~"test" => (), _ => die!() } enum t { tag1(~str), tag2, } match tag1(~"test") { - tag2 => fail, - tag1(~"not-test") => fail, + tag2 => die!(), + tag1(~"not-test") => die!(), tag1(~"test") => (), - _ => fail + _ => die!() } - let x = match ~"a" { ~"a" => 1, ~"b" => 2, _ => fail }; + let x = match ~"a" { ~"a" => 1, ~"b" => 2, _ => die!() }; assert (x == 1); - match ~"a" { ~"a" => { } ~"b" => { }, _ => fail } + match ~"a" { ~"a" => { } ~"b" => { }, _ => die!() } } diff --git a/src/test/run-pass/alt-tag.rs b/src/test/run-pass/alt-tag.rs index 76e688e37b0..624c57a614e 100644 --- a/src/test/run-pass/alt-tag.rs +++ b/src/test/run-pass/alt-tag.rs @@ -28,7 +28,7 @@ fn process(c: color) -> int { return x; } -fn main() { +pub fn main() { let gray: color = rgb(127, 127, 127); let clear: color = rgba(50, 150, 250, 0); let red: color = hsl(0, 255, 255); diff --git a/src/test/run-pass/alt-type-simple.rs b/src/test/run-pass/alt-type-simple.rs index 4881a6bba4a..dbe9ae7cba5 100644 --- a/src/test/run-pass/alt-type-simple.rs +++ b/src/test/run-pass/alt-type-simple.rs @@ -8,7 +8,7 @@ fn altsimple(any x) { } } -fn main() { +pub fn main() { altsimple(5); altsimple("asdfasdfsDF"); } diff --git a/src/test/run-pass/alt-unique-bind.rs b/src/test/run-pass/alt-unique-bind.rs index e2e87de3af8..902f95e7ef1 100644 --- a/src/test/run-pass/alt-unique-bind.rs +++ b/src/test/run-pass/alt-unique-bind.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -fn main() { +pub fn main() { match ~100 { ~x => { debug!("%?", x); diff --git a/src/test/run-pass/alt-value-binding-in-guard-3291.rs b/src/test/run-pass/alt-value-binding-in-guard-3291.rs index a6ede8dcd1d..460e8873a17 100644 --- a/src/test/run-pass/alt-value-binding-in-guard-3291.rs +++ b/src/test/run-pass/alt-value-binding-in-guard-3291.rs @@ -16,7 +16,7 @@ fn foo(x: Option<~int>, b: bool) -> int { } } -fn main() { +pub fn main() { foo(Some(~22), true); foo(Some(~22), false); foo(None, true); diff --git a/src/test/run-pass/alt-with-ret-arm.rs b/src/test/run-pass/alt-with-ret-arm.rs index 45ddcffcfd9..29247e47fa5 100644 --- a/src/test/run-pass/alt-with-ret-arm.rs +++ b/src/test/run-pass/alt-with-ret-arm.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -fn main() { +pub fn main() { // sometimes we have had trouble finding // the right type for f, as we unified // bot and u32 here diff --git a/src/test/run-pass/anon-extern-mod-cross-crate-2.rs b/src/test/run-pass/anon-extern-mod-cross-crate-2.rs index 3eb4fd52b8f..939903b3b12 100644 --- a/src/test/run-pass/anon-extern-mod-cross-crate-2.rs +++ b/src/test/run-pass/anon-extern-mod-cross-crate-2.rs @@ -14,6 +14,6 @@ extern mod anonexternmod; use anonexternmod::*; -fn main() { +pub fn main() { last_os_error(); } diff --git a/src/test/run-pass/anon-extern-mod.rs b/src/test/run-pass/anon-extern-mod.rs index fc624bdd031..525e6b9fbd6 100644 --- a/src/test/run-pass/anon-extern-mod.rs +++ b/src/test/run-pass/anon-extern-mod.rs @@ -14,7 +14,7 @@ extern { fn last_os_error() -> ~str; } -fn main() { +pub fn main() { unsafe { let _ = last_os_error(); } diff --git a/src/test/run-pass/anon-trait-static-method.rs b/src/test/run-pass/anon-trait-static-method.rs index 3682fd7d01d..4143c12cf67 100644 --- a/src/test/run-pass/anon-trait-static-method.rs +++ b/src/test/run-pass/anon-trait-static-method.rs @@ -18,7 +18,7 @@ impl Foo { } } -fn main() { +pub fn main() { let x = Foo::new(); io::println(x.x.to_str()); } diff --git a/src/test/run-pass/anon_trait_static_method_exe.rs b/src/test/run-pass/anon_trait_static_method_exe.rs index 5244f91a5a7..5d8b7983688 100644 --- a/src/test/run-pass/anon_trait_static_method_exe.rs +++ b/src/test/run-pass/anon_trait_static_method_exe.rs @@ -14,7 +14,7 @@ extern mod anon_trait_static_method_lib; use anon_trait_static_method_lib::Foo; -fn main() { +pub fn main() { let x = Foo::new(); io::println(x.x.to_str()); } diff --git a/src/test/run-pass/argument-passing.rs b/src/test/run-pass/argument-passing.rs index 560a6cbb823..e58dc29578d 100644 --- a/src/test/run-pass/argument-passing.rs +++ b/src/test/run-pass/argument-passing.rs @@ -22,7 +22,7 @@ fn f1(a: X, b: &mut int, -c: int) -> int { fn f2(a: int, f: fn(int)) -> int { f(1); return a; } -fn main() { +pub fn main() { let mut a = X {mut x: 1}, b = 2, c = 3; assert (f1(a, &mut b, move c) == 6); assert (a.x == 0); diff --git a/src/test/run-pass/arith-0.rs b/src/test/run-pass/arith-0.rs index 0c780adecc5..6f5ef7837c3 100644 --- a/src/test/run-pass/arith-0.rs +++ b/src/test/run-pass/arith-0.rs @@ -10,7 +10,7 @@ -fn main() { +pub fn main() { let a: int = 10; log(debug, a); assert (a * (a - 1) == 90); diff --git a/src/test/run-pass/arith-1.rs b/src/test/run-pass/arith-1.rs index 667b6fddc53..652f433e33d 100644 --- a/src/test/run-pass/arith-1.rs +++ b/src/test/run-pass/arith-1.rs @@ -10,7 +10,7 @@ -fn main() { +pub fn main() { let i32_a: int = 10; assert (i32_a == 10); assert (i32_a - 10 == 0); diff --git a/src/test/run-pass/arith-2.rs b/src/test/run-pass/arith-2.rs index 2c36562c297..658f5d61bb8 100644 --- a/src/test/run-pass/arith-2.rs +++ b/src/test/run-pass/arith-2.rs @@ -10,7 +10,7 @@ -fn main() { +pub fn main() { let i32_c: int = 0x10101010; assert (i32_c + i32_c * 2 / 3 * 2 + (i32_c - 7 % 3) == i32_c + i32_c * 2 / 3 * 2 + (i32_c - 7 % 3)); diff --git a/src/test/run-pass/arith-unsigned.rs b/src/test/run-pass/arith-unsigned.rs index a52336aec5f..651bf865eab 100644 --- a/src/test/run-pass/arith-unsigned.rs +++ b/src/test/run-pass/arith-unsigned.rs @@ -12,7 +12,7 @@ // Unsigned integer operations -fn main() { +pub fn main() { assert (0u8 < 255u8); assert (0u8 <= 255u8); assert (255u8 > 0u8); diff --git a/src/test/run-pass/artificial-block.rs b/src/test/run-pass/artificial-block.rs index 17da95ab596..3911c2c76be 100644 --- a/src/test/run-pass/artificial-block.rs +++ b/src/test/run-pass/artificial-block.rs @@ -10,4 +10,4 @@ fn f() -> int { { return 3; } } -fn main() { assert (f() == 3); } +pub fn main() { assert (f() == 3); } diff --git a/src/test/run-pass/assign-assign.rs b/src/test/run-pass/assign-assign.rs index bc2f7d85c2a..3f73d61090a 100644 --- a/src/test/run-pass/assign-assign.rs +++ b/src/test/run-pass/assign-assign.rs @@ -29,4 +29,4 @@ fn test_assign_op() { assert (x == 33); } -fn main() { test_assign(); test_assign_op(); } +pub fn main() { test_assign(); test_assign_op(); } diff --git a/src/test/run-pass/assignability-trait.rs b/src/test/run-pass/assignability-trait.rs index 2724684dea4..d0dc2638ee5 100644 --- a/src/test/run-pass/assignability-trait.rs +++ b/src/test/run-pass/assignability-trait.rs @@ -38,7 +38,7 @@ fn length<A, T: iterable<A>>(x: T) -> uint { return len; } -fn main() { +pub fn main() { let x = ~[0,1,2,3]; // Call a method for x.iterate() |y| { assert x[*y] == *y; } diff --git a/src/test/run-pass/attr-before-view-item.rs b/src/test/run-pass/attr-before-view-item.rs index b46c56fa1c9..aa5c3bb22a3 100644 --- a/src/test/run-pass/attr-before-view-item.rs +++ b/src/test/run-pass/attr-before-view-item.rs @@ -13,5 +13,5 @@ #[foo = "bar"] extern mod std; -fn main() { +pub fn main() { } diff --git a/src/test/run-pass/attr-before-view-item2.rs b/src/test/run-pass/attr-before-view-item2.rs index 072a0ebb0a7..e0d9a05b8aa 100644 --- a/src/test/run-pass/attr-before-view-item2.rs +++ b/src/test/run-pass/attr-before-view-item2.rs @@ -15,5 +15,5 @@ mod m { extern mod std; } -fn main() { +pub fn main() { } diff --git a/src/test/run-pass/attr-main-2.rs b/src/test/run-pass/attr-main-2.rs index 2978a72cfa9..b343799e00a 100644 --- a/src/test/run-pass/attr-main-2.rs +++ b/src/test/run-pass/attr-main-2.rs @@ -10,8 +10,8 @@ // xfail-fast -fn main() { - fail +pub fn main() { + die!() } #[main] diff --git a/src/test/run-pass/auto-encode.rs b/src/test/run-pass/auto-encode.rs index 28ae13896f0..316f5ed1950 100644 --- a/src/test/run-pass/auto-encode.rs +++ b/src/test/run-pass/auto-encode.rs @@ -158,7 +158,7 @@ enum Quark<T> { #[auto_decode] enum CLike { A, B, C } -fn main() { +pub fn main() { let a = &Plus(@Minus(@Val(3u), @Val(10u)), @Plus(@Val(22u), @Val(5u))); test_prettyprint(a, &~"Plus(@Minus(@Val(3u), @Val(10u)), \ @Plus(@Val(22u), @Val(5u)))"); diff --git a/src/test/run-pass/auto-instantiate.rs b/src/test/run-pass/auto-instantiate.rs index a2031019a4d..8f7a88f19a7 100644 --- a/src/test/run-pass/auto-instantiate.rs +++ b/src/test/run-pass/auto-instantiate.rs @@ -18,7 +18,7 @@ struct Triple { x: int, y: int, z: int } fn f<T: Copy, U: Copy>(x: T, y: U) -> Pair<T, U> { return Pair {a: x, b: y}; } -fn main() { +pub fn main() { log(debug, f(Triple {x: 3, y: 4, z: 5}, 4).a.x); log(debug, f(5, 6).a); } diff --git a/src/test/run-pass/auto-loop.rs b/src/test/run-pass/auto-loop.rs index 4bd032cb93d..91dc9fde143 100644 --- a/src/test/run-pass/auto-loop.rs +++ b/src/test/run-pass/auto-loop.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -fn main() { +pub fn main() { let mut sum = 0; for vec::each(~[1, 2, 3, 4, 5]) |x| { sum += *x; diff --git a/src/test/run-pass/auto-ref-bounded-ty-param.rs b/src/test/run-pass/auto-ref-bounded-ty-param.rs index bd0e91f153e..4b943e62fd2 100644 --- a/src/test/run-pass/auto-ref-bounded-ty-param.rs +++ b/src/test/run-pass/auto-ref-bounded-ty-param.rs @@ -32,7 +32,7 @@ impl Bar : Baz { } } -fn main() { +pub fn main() { let y = Bar { x: 42 }; y.f(); } diff --git a/src/test/run-pass/auto-ref-newtype.rs b/src/test/run-pass/auto-ref-newtype.rs index 6e69c487e06..80f20b13bdd 100644 --- a/src/test/run-pass/auto-ref-newtype.rs +++ b/src/test/run-pass/auto-ref-newtype.rs @@ -17,7 +17,7 @@ impl Foo { fn len(&self) -> uint { **self } } -fn main() { +pub fn main() { let m = Foo(3); assert m.len() == 3; } diff --git a/src/test/run-pass/auto-ref-slice-plus-ref.rs b/src/test/run-pass/auto-ref-slice-plus-ref.rs index 82c090e16b4..7c284bd8202 100644 --- a/src/test/run-pass/auto-ref-slice-plus-ref.rs +++ b/src/test/run-pass/auto-ref-slice-plus-ref.rs @@ -26,7 +26,7 @@ impl &str: MyIter { pure fn test_const(&const self) { assert *self == "test" } } -fn main() { +pub fn main() { // NB: Associativity of ~, etc. in this context is surprising. These must be parenthesized ([1]).test_imm(); diff --git a/src/test/run-pass/auto-ref-sliceable.rs b/src/test/run-pass/auto-ref-sliceable.rs index d3dbb23f23b..8423ea8c2d8 100644 --- a/src/test/run-pass/auto-ref-sliceable.rs +++ b/src/test/run-pass/auto-ref-sliceable.rs @@ -18,7 +18,7 @@ impl<T> ~[T]: Pushable<T> { } } -fn main() { +pub fn main() { let mut v = ~[1]; v.push_val(2); v.push_val(3); diff --git a/src/test/run-pass/auto-ref.rs b/src/test/run-pass/auto-ref.rs index 59f0342780d..f3a1c824f80 100644 --- a/src/test/run-pass/auto-ref.rs +++ b/src/test/run-pass/auto-ref.rs @@ -22,7 +22,7 @@ impl &Foo : Stuff { } } -fn main() { +pub fn main() { let x = Foo { x: 3 }; x.printme(); } diff --git a/src/test/run-pass/autobind.rs b/src/test/run-pass/autobind.rs index e82e6c2316b..0b969540d74 100644 --- a/src/test/run-pass/autobind.rs +++ b/src/test/run-pass/autobind.rs @@ -12,7 +12,7 @@ fn f<T: Copy>(x: ~[T]) -> T { return x[0]; } fn g(act: fn(~[int]) -> int) -> int { return act(~[1, 2, 3]); } -fn main() { +pub fn main() { assert (g(f) == 1); let f1: fn(~[~str]) -> ~str = f; assert (f1(~[~"x", ~"y", ~"z"]) == ~"x"); diff --git a/src/test/run-pass/autoderef-and-borrow-method-receiver.rs b/src/test/run-pass/autoderef-and-borrow-method-receiver.rs index fccf2937021..6e6d289e90f 100644 --- a/src/test/run-pass/autoderef-and-borrow-method-receiver.rs +++ b/src/test/run-pass/autoderef-and-borrow-method-receiver.rs @@ -20,6 +20,6 @@ fn g(x: &mut Foo) { x.f(); } -fn main() { +pub fn main() { } diff --git a/src/test/run-pass/autoderef-method-newtype.rs b/src/test/run-pass/autoderef-method-newtype.rs index b7010c620b3..cc45c75968c 100644 --- a/src/test/run-pass/autoderef-method-newtype.rs +++ b/src/test/run-pass/autoderef-method-newtype.rs @@ -18,7 +18,7 @@ impl uint: double { enum foo = uint; -fn main() { +pub fn main() { let x = foo(3u); assert x.double() == 6u; } diff --git a/src/test/run-pass/autoderef-method-on-trait-monomorphized.rs b/src/test/run-pass/autoderef-method-on-trait-monomorphized.rs index 7117ecfced3..d3377d196a4 100644 --- a/src/test/run-pass/autoderef-method-on-trait-monomorphized.rs +++ b/src/test/run-pass/autoderef-method-on-trait-monomorphized.rs @@ -20,7 +20,7 @@ fn is_equal<D: double>(x: @D, exp: uint) { assert x.double() == exp; } -fn main() { +pub fn main() { let x = @(3u as double); is_equal(x, 6); } diff --git a/src/test/run-pass/autoderef-method-on-trait.rs b/src/test/run-pass/autoderef-method-on-trait.rs index 200517abe96..0071cc5923a 100644 --- a/src/test/run-pass/autoderef-method-on-trait.rs +++ b/src/test/run-pass/autoderef-method-on-trait.rs @@ -16,7 +16,7 @@ impl uint: double { fn double() -> uint { self * 2u } } -fn main() { +pub fn main() { let x = @(3u as double); assert x.double() == 6u; } diff --git a/src/test/run-pass/autoderef-method-priority.rs b/src/test/run-pass/autoderef-method-priority.rs index 59c5f3b0ab0..aa487a52966 100644 --- a/src/test/run-pass/autoderef-method-priority.rs +++ b/src/test/run-pass/autoderef-method-priority.rs @@ -20,7 +20,7 @@ impl @uint: double { fn double() -> uint { *self * 2u } } -fn main() { +pub fn main() { let x = @3u; assert x.double() == 6u; } diff --git a/src/test/run-pass/autoderef-method-twice-but-not-thrice.rs b/src/test/run-pass/autoderef-method-twice-but-not-thrice.rs index e032c3aa478..cab69a243d4 100644 --- a/src/test/run-pass/autoderef-method-twice-but-not-thrice.rs +++ b/src/test/run-pass/autoderef-method-twice-but-not-thrice.rs @@ -16,7 +16,7 @@ impl @@uint: double { fn double() -> uint { **self * 2u } } -fn main() { +pub fn main() { let x = @@@@@3u; assert x.double() == 6u; } diff --git a/src/test/run-pass/autoderef-method-twice.rs b/src/test/run-pass/autoderef-method-twice.rs index fb985fac573..5b307478887 100644 --- a/src/test/run-pass/autoderef-method-twice.rs +++ b/src/test/run-pass/autoderef-method-twice.rs @@ -16,7 +16,7 @@ impl uint: double { fn double() -> uint { self * 2u } } -fn main() { +pub fn main() { let x = @@3u; assert x.double() == 6u; } diff --git a/src/test/run-pass/autoderef-method.rs b/src/test/run-pass/autoderef-method.rs index 6282bc72618..66372654701 100644 --- a/src/test/run-pass/autoderef-method.rs +++ b/src/test/run-pass/autoderef-method.rs @@ -16,7 +16,7 @@ impl uint: double { fn double() -> uint { self * 2u } } -fn main() { +pub fn main() { let x = @3u; assert x.double() == 6u; } diff --git a/src/test/run-pass/autoref-intermediate-types-issue-3585.rs b/src/test/run-pass/autoref-intermediate-types-issue-3585.rs index bad719a1f0d..1d7aa862a2a 100644 --- a/src/test/run-pass/autoref-intermediate-types-issue-3585.rs +++ b/src/test/run-pass/autoref-intermediate-types-issue-3585.rs @@ -24,7 +24,7 @@ impl uint: Foo { } } -fn main() { +pub fn main() { let x = @3u; assert x.foo() == ~"@3"; } \ No newline at end of file diff --git a/src/test/run-pass/bare-static-string.rs b/src/test/run-pass/bare-static-string.rs index d0db9abfba7..ceae1392d3b 100644 --- a/src/test/run-pass/bare-static-string.rs +++ b/src/test/run-pass/bare-static-string.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -fn main() { +pub fn main() { let x: &static/str = "foo"; io::println(x); } diff --git a/src/test/run-pass/big-literals.rs b/src/test/run-pass/big-literals.rs index 5883ddba675..338c264b65b 100644 --- a/src/test/run-pass/big-literals.rs +++ b/src/test/run-pass/big-literals.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -fn main() { +pub fn main() { assert 0xffffffffu32 == (-1 as u32); assert 4294967295u32 == (-1 as u32); assert 0xffffffffffffffffu64 == (-1 as u64); diff --git a/src/test/run-pass/binary-minus-without-space.rs b/src/test/run-pass/binary-minus-without-space.rs index 5c6c7f12b37..5a7ac1042d3 100644 --- a/src/test/run-pass/binary-minus-without-space.rs +++ b/src/test/run-pass/binary-minus-without-space.rs @@ -10,7 +10,7 @@ // Check that issue #954 stays fixed -fn main() { - match -1 { -1 => {}, _ => fail ~"wat" } +pub fn main() { + match -1 { -1 => {}, _ => die!(~"wat") } assert 1-1 == 0; } diff --git a/src/test/run-pass/bind-by-move.rs b/src/test/run-pass/bind-by-move.rs index eda015cce18..4c30d1e00d9 100644 --- a/src/test/run-pass/bind-by-move.rs +++ b/src/test/run-pass/bind-by-move.rs @@ -14,11 +14,11 @@ extern mod std; use std::arc; fn dispose(+_x: arc::ARC<bool>) unsafe { } -fn main() { +pub fn main() { let p = arc::arc(true); let x = Some(p); match move x { Some(move z) => { dispose(z); }, - None => fail + None => die!() } } diff --git a/src/test/run-pass/binops.rs b/src/test/run-pass/binops.rs index 04dc555e404..d27ca86c26a 100644 --- a/src/test/run-pass/binops.rs +++ b/src/test/run-pass/binops.rs @@ -121,7 +121,7 @@ fn test_class() { assert(q != r); } -fn main() { +pub fn main() { test_nil(); test_bool(); test_char(); diff --git a/src/test/run-pass/bitv-perf-test.rs b/src/test/run-pass/bitv-perf-test.rs index ff0de7a4696..097db4436fd 100644 --- a/src/test/run-pass/bitv-perf-test.rs +++ b/src/test/run-pass/bitv-perf-test.rs @@ -20,6 +20,6 @@ fn bitv_test() -> bool { true } -fn main() { +pub fn main() { do iter::repeat(10000) || {bitv_test()}; } diff --git a/src/test/run-pass/bitwise.rs b/src/test/run-pass/bitwise.rs index ae41c83afb3..680ffb73855 100644 --- a/src/test/run-pass/bitwise.rs +++ b/src/test/run-pass/bitwise.rs @@ -38,7 +38,7 @@ fn general() { assert (0b1010_1010 | 0b0101_0101 == 0xff); } -fn main() { +pub fn main() { general(); target(); } diff --git a/src/test/run-pass/block-arg-call-as.rs b/src/test/run-pass/block-arg-call-as.rs index cdef15758ab..fd5662bd46b 100644 --- a/src/test/run-pass/block-arg-call-as.rs +++ b/src/test/run-pass/block-arg-call-as.rs @@ -26,7 +26,7 @@ fn asAny( f : fn()->uint ) -> uint { return f(); } -fn main() { +pub fn main() { let x = asSendfn(|| 22u); assert(x == 22u); let x = asLambda(|| 22u); diff --git a/src/test/run-pass/block-arg-can-be-followed-by-binop.rs b/src/test/run-pass/block-arg-can-be-followed-by-binop.rs index bbeb30971a0..09bfe1720f7 100644 --- a/src/test/run-pass/block-arg-can-be-followed-by-binop.rs +++ b/src/test/run-pass/block-arg-can-be-followed-by-binop.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -fn main() { +pub fn main() { let v = ~[-1f, 0f, 1f, 2f, 3f]; // Trailing expressions don't require parentheses: diff --git a/src/test/run-pass/block-arg-can-be-followed-by-block-arg.rs b/src/test/run-pass/block-arg-can-be-followed-by-block-arg.rs index da03b91fd33..f908bbf745a 100644 --- a/src/test/run-pass/block-arg-can-be-followed-by-block-arg.rs +++ b/src/test/run-pass/block-arg-can-be-followed-by-block-arg.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -fn main() { +pub fn main() { fn f(i: fn() -> uint) -> uint { i() } let v = ~[-1f, 0f, 1f, 2f, 3f]; let z = do do vec::foldl(f, v) |x, _y| { x } { 22u }; diff --git a/src/test/run-pass/block-arg-can-be-followed-by-call.rs b/src/test/run-pass/block-arg-can-be-followed-by-call.rs index a762d7f98a6..9fd3c76bd34 100644 --- a/src/test/run-pass/block-arg-can-be-followed-by-call.rs +++ b/src/test/run-pass/block-arg-can-be-followed-by-call.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -fn main() { +pub fn main() { fn f(i: uint) -> uint { i } let v = ~[-1f, 0f, 1f, 2f, 3f]; let z = do vec::foldl(f, v) |x, _y| { x } (22u); diff --git a/src/test/run-pass/block-arg-in-parentheses.rs b/src/test/run-pass/block-arg-in-parentheses.rs index e433617c271..8eb0a8bef93 100644 --- a/src/test/run-pass/block-arg-in-parentheses.rs +++ b/src/test/run-pass/block-arg-in-parentheses.rs @@ -27,7 +27,7 @@ fn w_ret(v: ~[int]) -> int { return do vec::foldl(0, v) |x,y| { x+*y } - 10; } -fn main() { +pub fn main() { assert w_semi(~[0, 1, 2, 3]) == -10; assert w_paren1(~[0, 1, 2, 3]) == -4; assert w_paren2(~[0, 1, 2, 3]) == -4; diff --git a/src/test/run-pass/block-arg-used-as-any.rs b/src/test/run-pass/block-arg-used-as-any.rs index 6023b03cdeb..af2e6815e07 100644 --- a/src/test/run-pass/block-arg-used-as-any.rs +++ b/src/test/run-pass/block-arg-used-as-any.rs @@ -12,7 +12,7 @@ fn call_any(f: fn() -> uint) -> uint { return f(); } -fn main() { +pub fn main() { let x_r = do call_any { 22u }; assert x_r == 22u; } diff --git a/src/test/run-pass/block-arg-used-as-lambda.rs b/src/test/run-pass/block-arg-used-as-lambda.rs index 572d9a265db..20a1123ecf4 100644 --- a/src/test/run-pass/block-arg-used-as-lambda.rs +++ b/src/test/run-pass/block-arg-used-as-lambda.rs @@ -12,7 +12,7 @@ fn to_lambda(f: fn@(uint) -> uint) -> fn@(uint) -> uint { return f; } -fn main() { +pub fn main() { let x: fn@(uint) -> uint = to_lambda(|x| x * 2u ); let y = to_lambda(x); diff --git a/src/test/run-pass/block-arg.rs b/src/test/run-pass/block-arg.rs index 45594f0329b..e9c2eec510a 100644 --- a/src/test/run-pass/block-arg.rs +++ b/src/test/run-pass/block-arg.rs @@ -9,7 +9,7 @@ // except according to those terms. // Check usage and precedence of block arguments in expressions: -fn main() { +pub fn main() { let v = ~[-1f, 0f, 1f, 2f, 3f]; // Statement form does not require parentheses: @@ -35,14 +35,14 @@ fn main() { assert false; } match do vec::all(v) |e| { float::is_negative(*e) } { - true => { fail ~"incorrect answer."; } + true => { die!(~"incorrect answer."); } false => { } } match 3 { _ if do vec::any(v) |e| { float::is_negative(*e) } => { } _ => { - fail ~"wrong answer."; + die!(~"wrong answer."); } } diff --git a/src/test/run-pass/block-explicit-types.rs b/src/test/run-pass/block-explicit-types.rs index 6721f590375..f6bbb94690f 100644 --- a/src/test/run-pass/block-explicit-types.rs +++ b/src/test/run-pass/block-explicit-types.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -fn main() { +pub fn main() { fn as_buf<T>(s: ~str, f: fn(~str) -> T) -> T { f(s) } as_buf(~"foo", |foo: ~str| -> () log(error, foo) ); } diff --git a/src/test/run-pass/block-expr-precedence.rs b/src/test/run-pass/block-expr-precedence.rs index a87c8fab96f..7d56a6a46ff 100644 --- a/src/test/run-pass/block-expr-precedence.rs +++ b/src/test/run-pass/block-expr-precedence.rs @@ -54,7 +54,7 @@ * */ -fn main() { +pub fn main() { let num = 12; diff --git a/src/test/run-pass/block-fn-coerce.rs b/src/test/run-pass/block-fn-coerce.rs index 02c1d4ac298..3cd5f36fcb6 100644 --- a/src/test/run-pass/block-fn-coerce.rs +++ b/src/test/run-pass/block-fn-coerce.rs @@ -9,7 +9,7 @@ // except according to those terms. fn force(f: fn() -> int) -> int { return f(); } -fn main() { +pub fn main() { fn f() -> int { return 7; } assert (force(f) == 7); let g = {||force(f)}; diff --git a/src/test/run-pass/block-iter-1.rs b/src/test/run-pass/block-iter-1.rs index c702b46e9a7..6faf4129ba7 100644 --- a/src/test/run-pass/block-iter-1.rs +++ b/src/test/run-pass/block-iter-1.rs @@ -13,7 +13,7 @@ fn iter_vec<T>(v: ~[T], f: fn(T)) { for v.each |x| { f(*x); } } -fn main() { +pub fn main() { let v = ~[1, 2, 3, 4, 5, 6, 7]; let mut odds = 0; iter_vec(v, |i| { diff --git a/src/test/run-pass/block-iter-2.rs b/src/test/run-pass/block-iter-2.rs index 333933f750b..d57346a3299 100644 --- a/src/test/run-pass/block-iter-2.rs +++ b/src/test/run-pass/block-iter-2.rs @@ -13,7 +13,7 @@ fn iter_vec<T>(v: ~[T], f: fn(T)) { for v.each |x| { f(*x); } } -fn main() { +pub fn main() { let v = ~[1, 2, 3, 4, 5]; let mut sum = 0; iter_vec(copy v, |i| { diff --git a/src/test/run-pass/block-vec-map2.rs b/src/test/run-pass/block-vec-map2.rs index 53e98d779f6..cfc18d29e78 100644 --- a/src/test/run-pass/block-vec-map2.rs +++ b/src/test/run-pass/block-vec-map2.rs @@ -10,7 +10,7 @@ extern mod std; -fn main() { +pub fn main() { let v = vec::map2(~[1, 2, 3, 4, 5], ~[true, false, false, true, true], diff --git a/src/test/run-pass/bool-not.rs b/src/test/run-pass/bool-not.rs index 47085b4874e..d79b6f73398 100644 --- a/src/test/run-pass/bool-not.rs +++ b/src/test/run-pass/bool-not.rs @@ -12,7 +12,7 @@ // -*- rust -*- -fn main() { +pub fn main() { if !false { assert (true); } else { assert (false); } if !true { assert (false); } else { assert (true); } } diff --git a/src/test/run-pass/borrow-by-val-method-receiver.rs b/src/test/run-pass/borrow-by-val-method-receiver.rs index e5133475a24..daed89033fc 100644 --- a/src/test/run-pass/borrow-by-val-method-receiver.rs +++ b/src/test/run-pass/borrow-by-val-method-receiver.rs @@ -16,7 +16,7 @@ impl &[int]: Foo { fn foo(self) {} } -fn main() { +pub fn main() { let items = ~[ 3, 5, 1, 2, 4 ]; items.foo(); } diff --git a/src/test/run-pass/borrowck-binding-mutbl.rs b/src/test/run-pass/borrowck-binding-mutbl.rs index 7a620d58481..6e8b35f7678 100644 --- a/src/test/run-pass/borrowck-binding-mutbl.rs +++ b/src/test/run-pass/borrowck-binding-mutbl.rs @@ -13,7 +13,7 @@ struct F { mut f: ~[int] } fn impure(_v: &[int]) { } -fn main() { +pub fn main() { let x = F {f: ~[3]}; match x { diff --git a/src/test/run-pass/borrowck-borrow-from-at-vec.rs b/src/test/run-pass/borrowck-borrow-from-at-vec.rs index d3af2460fdd..88c06476243 100644 --- a/src/test/run-pass/borrowck-borrow-from-at-vec.rs +++ b/src/test/run-pass/borrowck-borrow-from-at-vec.rs @@ -14,7 +14,7 @@ fn sum_slice(x: &[int]) -> int { return sum; } -fn main() { +pub fn main() { let x = @[1, 2, 3]; assert sum_slice(x) == 6; } \ No newline at end of file diff --git a/src/test/run-pass/borrowck-borrow-from-expr-block.rs b/src/test/run-pass/borrowck-borrow-from-expr-block.rs index f13d6eef136..4196527728a 100644 --- a/src/test/run-pass/borrowck-borrow-from-expr-block.rs +++ b/src/test/run-pass/borrowck-borrow-from-expr-block.rs @@ -20,6 +20,6 @@ fn test1(x: @~int) { } } -fn main() { +pub fn main() { test1(@~22); } diff --git a/src/test/run-pass/borrowck-fixed-length-vecs.rs b/src/test/run-pass/borrowck-fixed-length-vecs.rs index 7abe109d824..647c0b646cf 100644 --- a/src/test/run-pass/borrowck-fixed-length-vecs.rs +++ b/src/test/run-pass/borrowck-fixed-length-vecs.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -fn main() { +pub fn main() { let x = [22]; let y = &x[0]; assert *y == 22; diff --git a/src/test/run-pass/borrowck-lend-args.rs b/src/test/run-pass/borrowck-lend-args.rs index 745f8f7f357..44be8f2724a 100644 --- a/src/test/run-pass/borrowck-lend-args.rs +++ b/src/test/run-pass/borrowck-lend-args.rs @@ -30,5 +30,5 @@ fn borrow_from_arg_val(++v: ~int) { borrow(v); } -fn main() { +pub fn main() { } diff --git a/src/test/run-pass/borrowck-move-from-unsafe-ptr-ok.rs b/src/test/run-pass/borrowck-move-from-unsafe-ptr-ok.rs index 66abe7e905e..8db3bdd5e64 100644 --- a/src/test/run-pass/borrowck-move-from-unsafe-ptr-ok.rs +++ b/src/test/run-pass/borrowck-move-from-unsafe-ptr-ok.rs @@ -17,5 +17,5 @@ fn bar(x: *~int) -> ~int { } } -fn main() { +pub fn main() { } \ No newline at end of file diff --git a/src/test/run-pass/borrowck-mut-uniq.rs b/src/test/run-pass/borrowck-mut-uniq.rs index b6c205524a8..2cd445ee7af 100644 --- a/src/test/run-pass/borrowck-mut-uniq.rs +++ b/src/test/run-pass/borrowck-mut-uniq.rs @@ -23,7 +23,7 @@ fn iter_ints(x: &Ints, f: fn(x: &int) -> bool) { uint::range(0, l, |i| f(&x.values[i])) } -fn main() { +pub fn main() { let mut ints = ~Ints {sum: ~0, values: ~[]}; add_int(ints, 22); add_int(ints, 44); diff --git a/src/test/run-pass/borrowck-mut-vec-as-imm-slice.rs b/src/test/run-pass/borrowck-mut-vec-as-imm-slice.rs index 7d6c0bf6a9d..9126a327d86 100644 --- a/src/test/run-pass/borrowck-mut-vec-as-imm-slice.rs +++ b/src/test/run-pass/borrowck-mut-vec-as-imm-slice.rs @@ -14,10 +14,10 @@ fn want_slice(v: &[int]) -> int { return sum; } -fn has_mut_vec(+v: ~[mut int]) -> int { +fn has_mut_vec(+v: ~[int]) -> int { want_slice(v) } -fn main() { - assert has_mut_vec(~[mut 1, 2, 3]) == 6; +pub fn main() { + assert has_mut_vec(~[1, 2, 3]) == 6; } \ No newline at end of file diff --git a/src/test/run-pass/borrowck-newtype-issue-2573.rs b/src/test/run-pass/borrowck-newtype-issue-2573.rs index d9d6efe6ad9..88ddf4e081a 100644 --- a/src/test/run-pass/borrowck-newtype-issue-2573.rs +++ b/src/test/run-pass/borrowck-newtype-issue-2573.rs @@ -27,4 +27,4 @@ fn really_impure(++bar: baz) { bar.baz = 3; } -fn main() {} +pub fn main() {} diff --git a/src/test/run-pass/borrowck-pat-reassign-no-binding.rs b/src/test/run-pass/borrowck-pat-reassign-no-binding.rs index 36b578aa6e9..d7551f792f3 100644 --- a/src/test/run-pass/borrowck-pat-reassign-no-binding.rs +++ b/src/test/run-pass/borrowck-pat-reassign-no-binding.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -fn main() { +pub fn main() { let mut x = None; match x { None => { diff --git a/src/test/run-pass/borrowck-preserve-box-in-arm-not-taken.rs b/src/test/run-pass/borrowck-preserve-box-in-arm-not-taken.rs index ca72181b5fb..47bc6344bc2 100644 --- a/src/test/run-pass/borrowck-preserve-box-in-arm-not-taken.rs +++ b/src/test/run-pass/borrowck-preserve-box-in-arm-not-taken.rs @@ -10,7 +10,7 @@ // exec-env:RUST_POISON_ON_FREE=1 -fn main() { +pub fn main() { let x: @mut @Option<~int> = @mut @None; match x { @@Some(ref y) => { diff --git a/src/test/run-pass/borrowck-preserve-box-in-discr.rs b/src/test/run-pass/borrowck-preserve-box-in-discr.rs index 14757bfa3d8..c6fc92bd56d 100644 --- a/src/test/run-pass/borrowck-preserve-box-in-discr.rs +++ b/src/test/run-pass/borrowck-preserve-box-in-discr.rs @@ -12,7 +12,7 @@ struct F { f: ~int } -fn main() { +pub fn main() { let mut x = @F {f: ~3}; match x { @F {f: ref b_x} => { diff --git a/src/test/run-pass/borrowck-preserve-box-in-field.rs b/src/test/run-pass/borrowck-preserve-box-in-field.rs index 87592f54817..482673f9184 100644 --- a/src/test/run-pass/borrowck-preserve-box-in-field.rs +++ b/src/test/run-pass/borrowck-preserve-box-in-field.rs @@ -19,7 +19,7 @@ fn borrow(x: &int, f: fn(x: &int)) { struct F { f: ~int } -fn main() { +pub fn main() { let mut x = @F {f: ~3}; do borrow(x.f) |b_x| { assert *b_x == 3; diff --git a/src/test/run-pass/borrowck-preserve-box-in-pat.rs b/src/test/run-pass/borrowck-preserve-box-in-pat.rs index ccf9be1d585..29d94a0e8ea 100644 --- a/src/test/run-pass/borrowck-preserve-box-in-pat.rs +++ b/src/test/run-pass/borrowck-preserve-box-in-pat.rs @@ -12,7 +12,7 @@ struct F { f: ~int } -fn main() { +pub fn main() { let mut x = @mut @F {f: ~3}; match x { @@F{f: ref b_x} => { diff --git a/src/test/run-pass/borrowck-preserve-box-in-uniq.rs b/src/test/run-pass/borrowck-preserve-box-in-uniq.rs index 1f6bfe20bb1..3f5708a8930 100644 --- a/src/test/run-pass/borrowck-preserve-box-in-uniq.rs +++ b/src/test/run-pass/borrowck-preserve-box-in-uniq.rs @@ -19,7 +19,7 @@ fn borrow(x: &int, f: fn(x: &int)) { struct F { f: ~int } -fn main() { +pub fn main() { let mut x = ~mut @F{f: ~3}; do borrow(x.f) |b_x| { assert *b_x == 3; diff --git a/src/test/run-pass/borrowck-preserve-box-sometimes-needed.rs b/src/test/run-pass/borrowck-preserve-box-sometimes-needed.rs index e23626d7eea..b4b5a622408 100644 --- a/src/test/run-pass/borrowck-preserve-box-sometimes-needed.rs +++ b/src/test/run-pass/borrowck-preserve-box-sometimes-needed.rs @@ -18,7 +18,7 @@ fn switcher(x: Option<@int>) { } } -fn main() { +pub fn main() { switcher(None); switcher(Some(@3)); } \ No newline at end of file diff --git a/src/test/run-pass/borrowck-preserve-box.rs b/src/test/run-pass/borrowck-preserve-box.rs index c6521be04eb..37c598f01a7 100644 --- a/src/test/run-pass/borrowck-preserve-box.rs +++ b/src/test/run-pass/borrowck-preserve-box.rs @@ -17,7 +17,7 @@ fn borrow(x: &int, f: fn(x: &int)) { assert before == after; } -fn main() { +pub fn main() { let mut x = @3; do borrow(x) |b_x| { assert *b_x == 3; diff --git a/src/test/run-pass/borrowck-preserve-cond-box.rs b/src/test/run-pass/borrowck-preserve-cond-box.rs index 7bb7eeb6216..490db9c47f7 100644 --- a/src/test/run-pass/borrowck-preserve-cond-box.rs +++ b/src/test/run-pass/borrowck-preserve-cond-box.rs @@ -34,7 +34,7 @@ fn testfn(cond: bool) { assert *r == exp; } -fn main() { +pub fn main() { testfn(true); testfn(false); } \ No newline at end of file diff --git a/src/test/run-pass/borrowck-preserve-expl-deref.rs b/src/test/run-pass/borrowck-preserve-expl-deref.rs index 30250c26a9a..8e16565bf53 100644 --- a/src/test/run-pass/borrowck-preserve-expl-deref.rs +++ b/src/test/run-pass/borrowck-preserve-expl-deref.rs @@ -19,7 +19,7 @@ fn borrow(x: &int, f: fn(x: &int)) { struct F { f: ~int } -fn main() { +pub fn main() { let mut x = @F {f: ~3}; do borrow((*x).f) |b_x| { assert *b_x == 3; diff --git a/src/test/run-pass/borrowck-root-while-cond-2.rs b/src/test/run-pass/borrowck-root-while-cond-2.rs index 0e4f15d49db..5b2232daa4a 100644 --- a/src/test/run-pass/borrowck-root-while-cond-2.rs +++ b/src/test/run-pass/borrowck-root-while-cond-2.rs @@ -11,7 +11,7 @@ struct F { mut f: @G } struct G { g: ~[int] } -fn main() { +pub fn main() { let rec = @F {mut f: @G {g: ~[1, 2, 3]}}; while rec.f.g.len() == 23 {} } diff --git a/src/test/run-pass/borrowck-root-while-cond.rs b/src/test/run-pass/borrowck-root-while-cond.rs index e8e3cf297ba..432847cc198 100644 --- a/src/test/run-pass/borrowck-root-while-cond.rs +++ b/src/test/run-pass/borrowck-root-while-cond.rs @@ -12,7 +12,7 @@ fn borrow<T>(x: &r/T) -> &r/T {x} struct Rec { mut f: @int } -fn main() { +pub fn main() { let rec = @Rec {mut f: @22}; while *borrow(rec.f) == 23 {} } diff --git a/src/test/run-pass/borrowck-univariant-enum.rs b/src/test/run-pass/borrowck-univariant-enum.rs index 581e0e02423..531c49b82d7 100644 --- a/src/test/run-pass/borrowck-univariant-enum.rs +++ b/src/test/run-pass/borrowck-univariant-enum.rs @@ -12,7 +12,7 @@ enum newtype { newtype(int) } -fn main() { +pub fn main() { // Test that borrowck treats enums with a single variant // specially. diff --git a/src/test/run-pass/borrowck-wg-borrow-mut-to-imm-2.rs b/src/test/run-pass/borrowck-wg-borrow-mut-to-imm-2.rs index 12dc0c3a310..d721704ba55 100644 --- a/src/test/run-pass/borrowck-wg-borrow-mut-to-imm-2.rs +++ b/src/test/run-pass/borrowck-wg-borrow-mut-to-imm-2.rs @@ -7,7 +7,7 @@ fn foo(cat: &mut Cat) { bar(&*cat); } -fn main() { +pub fn main() { let mut mimi = ~Cat; foo(mimi); } diff --git a/src/test/run-pass/borrowck-wg-borrow-mut-to-imm-3.rs b/src/test/run-pass/borrowck-wg-borrow-mut-to-imm-3.rs index 66e29f3af3d..748672ef050 100644 --- a/src/test/run-pass/borrowck-wg-borrow-mut-to-imm-3.rs +++ b/src/test/run-pass/borrowck-wg-borrow-mut-to-imm-3.rs @@ -10,7 +10,7 @@ impl Wizard { } } -fn main() { +pub fn main() { let mut harry = Wizard { spells: ~[ "expelliarmus", "expecto patronum", "incendio" ] }; diff --git a/src/test/run-pass/borrowck-wg-borrow-mut-to-imm.rs b/src/test/run-pass/borrowck-wg-borrow-mut-to-imm.rs index 36155a9d266..dea4ec4959b 100644 --- a/src/test/run-pass/borrowck-wg-borrow-mut-to-imm.rs +++ b/src/test/run-pass/borrowck-wg-borrow-mut-to-imm.rs @@ -6,7 +6,7 @@ fn f(x: &mut Option<int>) { g(&*x); } -fn main() { +pub fn main() { let mut x = ~Some(3); f(x); } diff --git a/src/test/run-pass/borrowck-wg-simple.rs b/src/test/run-pass/borrowck-wg-simple.rs index bc370b20d15..adf2403ec63 100644 --- a/src/test/run-pass/borrowck-wg-simple.rs +++ b/src/test/run-pass/borrowck-wg-simple.rs @@ -2,7 +2,7 @@ fn f(x: &int) { io::println(x.to_str()); } -fn main() { +pub fn main() { let x = @mut 3; f(x); } diff --git a/src/test/run-pass/borrowed-ptr-pattern-2.rs b/src/test/run-pass/borrowed-ptr-pattern-2.rs index 631c376738e..48af01c6f55 100644 --- a/src/test/run-pass/borrowed-ptr-pattern-2.rs +++ b/src/test/run-pass/borrowed-ptr-pattern-2.rs @@ -15,7 +15,7 @@ fn foo(s: &~str) -> bool { } } -fn main() { +pub fn main() { assert foo(&~"kitty"); assert !foo(&~"gata"); } diff --git a/src/test/run-pass/borrowed-ptr-pattern-3.rs b/src/test/run-pass/borrowed-ptr-pattern-3.rs index a49e2aa59ac..138b224e3cb 100644 --- a/src/test/run-pass/borrowed-ptr-pattern-3.rs +++ b/src/test/run-pass/borrowed-ptr-pattern-3.rs @@ -15,7 +15,7 @@ fn foo(s: &r/uint) -> bool { } } -fn main() { +pub fn main() { assert foo(&3); assert !foo(&4); } diff --git a/src/test/run-pass/borrowed-ptr-pattern-infallible.rs b/src/test/run-pass/borrowed-ptr-pattern-infallible.rs index 8781ede6933..e28b4e425eb 100644 --- a/src/test/run-pass/borrowed-ptr-pattern-infallible.rs +++ b/src/test/run-pass/borrowed-ptr-pattern-infallible.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -fn main() { +pub fn main() { let (&x, &y, &z) = (&3, &'a', &@"No pets!"); assert x == 3; assert y == 'a'; diff --git a/src/test/run-pass/borrowed-ptr-pattern-option.rs b/src/test/run-pass/borrowed-ptr-pattern-option.rs index 180d15017da..f709448d431 100644 --- a/src/test/run-pass/borrowed-ptr-pattern-option.rs +++ b/src/test/run-pass/borrowed-ptr-pattern-option.rs @@ -16,7 +16,7 @@ fn select(x: &r/Option<int>, y: &r/Option<int>) -> &r/Option<int> { } } -fn main() { +pub fn main() { let x = None; let y = Some(3); assert select(&x, &y).get() == 3; diff --git a/src/test/run-pass/borrowed-ptr-pattern.rs b/src/test/run-pass/borrowed-ptr-pattern.rs index b9248cdd136..fdf4a161560 100644 --- a/src/test/run-pass/borrowed-ptr-pattern.rs +++ b/src/test/run-pass/borrowed-ptr-pattern.rs @@ -14,7 +14,7 @@ fn foo<T: Copy>(x: &T) -> T{ } } -fn main() { +pub fn main() { assert foo(&3) == 3; assert foo(&'a') == 'a'; assert foo(&@"Dogs rule, cats drool") == @"Dogs rule, cats drool"; diff --git a/src/test/run-pass/bounded-fn-type.rs b/src/test/run-pass/bounded-fn-type.rs index 507bd347fef..5f4a88375a4 100644 --- a/src/test/run-pass/bounded-fn-type.rs +++ b/src/test/run-pass/bounded-fn-type.rs @@ -10,7 +10,7 @@ fn ignore<T>(_x: T) {} -fn main() { +pub fn main() { let f: fn@:Owned() = ||(); ignore(f); } diff --git a/src/test/run-pass/box-compare.rs b/src/test/run-pass/box-compare.rs index 157f9abe84a..4893040ff34 100644 --- a/src/test/run-pass/box-compare.rs +++ b/src/test/run-pass/box-compare.rs @@ -10,7 +10,7 @@ -fn main() { +pub fn main() { assert (@1 < @3); assert (@@~"hello " > @@~"hello"); assert (@@@~"hello" != @@@~"there"); diff --git a/src/test/run-pass/box-in-tup.rs b/src/test/run-pass/box-in-tup.rs index 8e17884f855..22857aaefec 100644 --- a/src/test/run-pass/box-in-tup.rs +++ b/src/test/run-pass/box-in-tup.rs @@ -8,4 +8,4 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -fn main() { let i: (@int, int) = (@10, 10); let (a, _) = i; } +pub fn main() { let i: (@int, int) = (@10, 10); let (a, _) = i; } diff --git a/src/test/run-pass/box-inside-if.rs b/src/test/run-pass/box-inside-if.rs index 6351dcf991f..e9838ec17ae 100644 --- a/src/test/run-pass/box-inside-if.rs +++ b/src/test/run-pass/box-inside-if.rs @@ -22,4 +22,4 @@ fn foo(acc: int, n: int) { if is_odd(n) && length_is_even(some_box(1)) { error!("bloop"); } } -fn main() { foo(67, 5); } +pub fn main() { foo(67, 5); } diff --git a/src/test/run-pass/box-inside-if2.rs b/src/test/run-pass/box-inside-if2.rs index 32230d7f498..bcadc69bb0a 100644 --- a/src/test/run-pass/box-inside-if2.rs +++ b/src/test/run-pass/box-inside-if2.rs @@ -22,4 +22,4 @@ fn foo(acc: int, n: int) { if is_odd(n) || length_is_even(some_box(1)) { error!("bloop"); } } -fn main() { foo(67, 5); } +pub fn main() { foo(67, 5); } diff --git a/src/test/run-pass/box-pattern.rs b/src/test/run-pass/box-pattern.rs index 91e416b72e1..ccdaeab3273 100644 --- a/src/test/run-pass/box-pattern.rs +++ b/src/test/run-pass/box-pattern.rs @@ -11,7 +11,7 @@ struct Foo {a: int, b: uint} enum bar { u(@Foo), w(int), } -fn main() { +pub fn main() { assert (match u(@Foo{a: 10, b: 40u}) { u(@Foo{a: a, b: b}) => { a + (b as int) } _ => { 66 } diff --git a/src/test/run-pass/box-unbox.rs b/src/test/run-pass/box-unbox.rs index ad32ffc75c9..6889d764cbb 100644 --- a/src/test/run-pass/box-unbox.rs +++ b/src/test/run-pass/box-unbox.rs @@ -14,7 +14,7 @@ struct Box<T> {c: @T} fn unbox<T: Copy>(b: Box<T>) -> T { return *b.c; } -fn main() { +pub fn main() { let foo: int = 17; let bfoo: Box<int> = Box {c: @foo}; debug!("see what's in our box"); diff --git a/src/test/run-pass/box.rs b/src/test/run-pass/box.rs index f92be529048..05b32150e2d 100644 --- a/src/test/run-pass/box.rs +++ b/src/test/run-pass/box.rs @@ -10,4 +10,4 @@ -fn main() { let x: @int = @10; assert (*x == 10); } +pub fn main() { let x: @int = @10; assert (*x == 10); } diff --git a/src/test/run-pass/boxed-class-type-substitution.rs b/src/test/run-pass/boxed-class-type-substitution.rs index 7e1ab1004b1..9e6af13dca2 100644 --- a/src/test/run-pass/boxed-class-type-substitution.rs +++ b/src/test/run-pass/boxed-class-type-substitution.rs @@ -15,7 +15,7 @@ type Tree<T> = { mut parent: Option<T>, }; -fn empty<T>() -> Tree<T> { fail } +fn empty<T>() -> Tree<T> { die!() } struct Box { tree: Tree<@Box> @@ -31,4 +31,4 @@ enum layout_data = { mut box: Option<@Box> }; -fn main() { } \ No newline at end of file +pub fn main() { } diff --git a/src/test/run-pass/boxed-trait-with-vstore.rs b/src/test/run-pass/boxed-trait-with-vstore.rs index b7f5ffb896d..1347430e4a0 100644 --- a/src/test/run-pass/boxed-trait-with-vstore.rs +++ b/src/test/run-pass/boxed-trait-with-vstore.rs @@ -18,7 +18,7 @@ impl int : Foo { } } -fn main() { +pub fn main() { let x = 3 as @Foo; x.foo(); } diff --git a/src/test/run-pass/break-value.rs b/src/test/run-pass/break-value.rs index a3d11f04828..efc3ab32a1a 100644 --- a/src/test/run-pass/break-value.rs +++ b/src/test/run-pass/break-value.rs @@ -10,4 +10,4 @@ fn int_id(x: int) -> int { return x; } -fn main() { loop { int_id(break); } } +pub fn main() { loop { int_id(break); } } diff --git a/src/test/run-pass/break.rs b/src/test/run-pass/break.rs index 1d373bda859..9d4b0dffdba 100644 --- a/src/test/run-pass/break.rs +++ b/src/test/run-pass/break.rs @@ -10,7 +10,7 @@ -fn main() { +pub fn main() { let mut i = 0; while i < 20 { i += 1; if i == 10 { break; } } assert (i == 10); diff --git a/src/test/run-pass/by-val-and-by-move.rs b/src/test/run-pass/by-val-and-by-move.rs index 1d3ad7c8577..d361b20e833 100644 --- a/src/test/run-pass/by-val-and-by-move.rs +++ b/src/test/run-pass/by-val-and-by-move.rs @@ -20,7 +20,7 @@ fn it_takes_two(x: @int, -y: @int) -> int { fn free<T>(-_t: T) { } -fn main() { +pub fn main() { let z = @3; assert 3 == it_takes_two(z, z); } diff --git a/src/test/run-pass/c-stack-as-value.rs b/src/test/run-pass/c-stack-as-value.rs index 5d435fa646a..9b1d6af0891 100644 --- a/src/test/run-pass/c-stack-as-value.rs +++ b/src/test/run-pass/c-stack-as-value.rs @@ -13,7 +13,7 @@ extern mod rustrt { pub fn get_task_id() -> libc::intptr_t; } -fn main() { +pub fn main() { unsafe { let _foo = rustrt::get_task_id; } diff --git a/src/test/run-pass/c-stack-returning-int64.rs b/src/test/run-pass/c-stack-returning-int64.rs index aec0054a3c3..02c2ab92725 100644 --- a/src/test/run-pass/c-stack-returning-int64.rs +++ b/src/test/run-pass/c-stack-returning-int64.rs @@ -25,7 +25,7 @@ fn atoll(s: ~str) -> i64 { return str::as_buf(s, { |x, _len| unsafe { libc::atoll(x) } }); } -fn main() { +pub fn main() { unsafe { assert atol(~"1024") * 10 == atol(~"10240"); assert (atoll(~"11111111111111111") * 10i64) diff --git a/src/test/run-pass/call-closure-from-overloaded-op.rs b/src/test/run-pass/call-closure-from-overloaded-op.rs index 3eaf273a578..5abf499937a 100644 --- a/src/test/run-pass/call-closure-from-overloaded-op.rs +++ b/src/test/run-pass/call-closure-from-overloaded-op.rs @@ -10,7 +10,7 @@ fn foo() -> int { 22 } -fn main() { +pub fn main() { let x = dvec::DVec::<@fn() -> int>(); x.push(foo); assert (x[0])() == 22; diff --git a/src/test/run-pass/cap-clause-move.rs b/src/test/run-pass/cap-clause-move.rs index a196593743f..dd4c7ba6a85 100644 --- a/src/test/run-pass/cap-clause-move.rs +++ b/src/test/run-pass/cap-clause-move.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -fn main() { +pub fn main() { let x = ~1; let y = ptr::addr_of(&(*x)) as uint; let lam_move = fn@(move x) -> uint { ptr::addr_of(&(*x)) as uint }; diff --git a/src/test/run-pass/cap-clause-not-used.rs b/src/test/run-pass/cap-clause-not-used.rs index 7236727f421..e26a8ae11fd 100644 --- a/src/test/run-pass/cap-clause-not-used.rs +++ b/src/test/run-pass/cap-clause-not-used.rs @@ -9,7 +9,7 @@ // except according to those terms. // error-pattern: warning: Captured variable 'y' not used in closure -fn main() { +pub fn main() { let x = 5; let _y = fn~(copy x) { }; } diff --git a/src/test/run-pass/capture_nil.rs b/src/test/run-pass/capture_nil.rs index 6d57084f85a..6c052b95a2b 100644 --- a/src/test/run-pass/capture_nil.rs +++ b/src/test/run-pass/capture_nil.rs @@ -34,6 +34,6 @@ fn foo(&&x: ()) -> Port<()> { p } -fn main() { +pub fn main() { foo(()).recv() } diff --git a/src/test/run-pass/cast-region-to-uint.rs b/src/test/run-pass/cast-region-to-uint.rs index 2d2eba228b0..bd099f45e49 100644 --- a/src/test/run-pass/cast-region-to-uint.rs +++ b/src/test/run-pass/cast-region-to-uint.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -fn main() { +pub fn main() { let x = 3; debug!("&x=%x", ptr::to_uint(&x)); } \ No newline at end of file diff --git a/src/test/run-pass/cast.rs b/src/test/run-pass/cast.rs index 77dcef8c2c1..b7d23c5176e 100644 --- a/src/test/run-pass/cast.rs +++ b/src/test/run-pass/cast.rs @@ -12,7 +12,7 @@ // -*- rust -*- -fn main() { +pub fn main() { let i: int = 'Q' as int; assert (i == 0x51); let u: u32 = i as u32; diff --git a/src/test/run-pass/cci_impl_exe.rs b/src/test/run-pass/cci_impl_exe.rs index 2141d2b60de..2897ad24fd4 100644 --- a/src/test/run-pass/cci_impl_exe.rs +++ b/src/test/run-pass/cci_impl_exe.rs @@ -14,7 +14,7 @@ extern mod cci_impl_lib; use cci_impl_lib::uint_helpers; -fn main() { +pub fn main() { //let bt0 = sys::frame_address(); //debug!("%?", bt0); diff --git a/src/test/run-pass/cci_iter_exe.rs b/src/test/run-pass/cci_iter_exe.rs index f1f217030eb..01054ba44cf 100644 --- a/src/test/run-pass/cci_iter_exe.rs +++ b/src/test/run-pass/cci_iter_exe.rs @@ -15,7 +15,7 @@ extern mod cci_iter_lib; -fn main() { +pub fn main() { //let bt0 = sys::rusti::frame_address(1u32); //debug!("%?", bt0); do cci_iter_lib::iter(~[1, 2, 3]) |i| { diff --git a/src/test/run-pass/cfg-family.rs b/src/test/run-pass/cfg-family.rs index dc6ad9929e7..d3a8dd53014 100644 --- a/src/test/run-pass/cfg-family.rs +++ b/src/test/run-pass/cfg-family.rs @@ -9,9 +9,9 @@ // except according to those terms. #[cfg(windows)] -fn main() { +pub fn main() { } #[cfg(unix)] -fn main() { +pub fn main() { } \ No newline at end of file diff --git a/src/test/run-pass/cfg-target-family.rs b/src/test/run-pass/cfg-target-family.rs index e10272e37d4..ddf58d310cf 100644 --- a/src/test/run-pass/cfg-target-family.rs +++ b/src/test/run-pass/cfg-target-family.rs @@ -9,9 +9,9 @@ // except according to those terms. #[cfg(target_family = "windows")] -fn main() { +pub fn main() { } #[cfg(target_family = "unix")] -fn main() { +pub fn main() { } \ No newline at end of file diff --git a/src/test/run-pass/char.rs b/src/test/run-pass/char.rs index 5f5fc0502d7..7900b2ffa7c 100644 --- a/src/test/run-pass/char.rs +++ b/src/test/run-pass/char.rs @@ -10,7 +10,7 @@ -fn main() { +pub fn main() { let c: char = 'x'; let d: char = 'x'; assert (c == 'x'); diff --git a/src/test/run-pass/child-outlives-parent.rs b/src/test/run-pass/child-outlives-parent.rs index 62542b29685..50c6b821143 100644 --- a/src/test/run-pass/child-outlives-parent.rs +++ b/src/test/run-pass/child-outlives-parent.rs @@ -14,4 +14,4 @@ extern mod std; fn child2(&&s: ~str) { } -fn main() { let x = task::spawn(|| child2(~"hi") ); } +pub fn main() { let x = task::spawn(|| child2(~"hi") ); } diff --git a/src/test/run-pass/class-attributes-1.rs b/src/test/run-pass/class-attributes-1.rs index ef3a82d1e2b..9382cc8ac34 100644 --- a/src/test/run-pass/class-attributes-1.rs +++ b/src/test/run-pass/class-attributes-1.rs @@ -23,4 +23,4 @@ impl cat: Drop { #[cat_maker] fn cat(name: ~str) -> cat { cat{name: name,} } -fn main() { let _kitty = cat(~"Spotty"); } +pub fn main() { let _kitty = cat(~"Spotty"); } diff --git a/src/test/run-pass/class-attributes-2.rs b/src/test/run-pass/class-attributes-2.rs index c062f793b42..471f830c3e2 100644 --- a/src/test/run-pass/class-attributes-2.rs +++ b/src/test/run-pass/class-attributes-2.rs @@ -32,6 +32,6 @@ fn cat(name: ~str) -> cat { } } -fn main() { +pub fn main() { let _kitty = cat(~"Spotty"); } diff --git a/src/test/run-pass/class-cast-to-trait-cross-crate-2.rs b/src/test/run-pass/class-cast-to-trait-cross-crate-2.rs index 5d53453ffc0..1d1b07ae324 100644 --- a/src/test/run-pass/class-cast-to-trait-cross-crate-2.rs +++ b/src/test/run-pass/class-cast-to-trait-cross-crate-2.rs @@ -20,7 +20,7 @@ fn print_out<T: ToStr>(thing: T, expected: ~str) { assert(actual == expected); } -fn main() { +pub fn main() { let nyan : ToStr = cat(0u, 2, ~"nyan") as ToStr; print_out(nyan, ~"nyan"); } diff --git a/src/test/run-pass/class-cast-to-trait-cross-crate.rs b/src/test/run-pass/class-cast-to-trait-cross-crate.rs index a421d050363..36e6c6b487d 100644 --- a/src/test/run-pass/class-cast-to-trait-cross-crate.rs +++ b/src/test/run-pass/class-cast-to-trait-cross-crate.rs @@ -54,7 +54,7 @@ fn print_out<T: to_str>(thing: T, expected: str) { assert(actual == expected); } -fn main() { +pub fn main() { let nyan : to_str = cat(0u, 2, "nyan") as to_str; print_out(nyan, "nyan"); } diff --git a/src/test/run-pass/class-cast-to-trait-multiple-types.rs b/src/test/run-pass/class-cast-to-trait-multiple-types.rs index c32b63b8f70..2f7ede7e59e 100644 --- a/src/test/run-pass/class-cast-to-trait-multiple-types.rs +++ b/src/test/run-pass/class-cast-to-trait-multiple-types.rs @@ -83,7 +83,7 @@ fn annoy_neighbors<T: noisy>(critter: T) { for uint::range(0u, 10u) |i| { critter.speak(); } } -fn main() { +pub fn main() { let nyan : cat = cat(0u, 2, ~"nyan"); let whitefang : dog = dog(); annoy_neighbors((copy nyan) as noisy); diff --git a/src/test/run-pass/class-cast-to-trait.rs b/src/test/run-pass/class-cast-to-trait.rs index 845ff78ad91..014b5441cc2 100644 --- a/src/test/run-pass/class-cast-to-trait.rs +++ b/src/test/run-pass/class-cast-to-trait.rs @@ -55,7 +55,7 @@ fn cat(in_x : uint, in_y : int, in_name: ~str) -> cat { } -fn main() { +pub fn main() { let nyan : noisy = cat(0u, 2, ~"nyan") as noisy; nyan.speak(); } \ No newline at end of file diff --git a/src/test/run-pass/class-dtor.rs b/src/test/run-pass/class-dtor.rs index 6f458fe580c..07193400c6a 100644 --- a/src/test/run-pass/class-dtor.rs +++ b/src/test/run-pass/class-dtor.rs @@ -26,4 +26,4 @@ fn cat(done: extern fn(uint)) -> cat { } } -fn main() {} +pub fn main() {} diff --git a/src/test/run-pass/class-exports.rs b/src/test/run-pass/class-exports.rs index 184d2788329..f0044f8d17c 100644 --- a/src/test/run-pass/class-exports.rs +++ b/src/test/run-pass/class-exports.rs @@ -33,6 +33,6 @@ mod kitty { } } -fn main() { +pub fn main() { assert(cat(~"Spreckles").get_name() == ~"Spreckles"); } diff --git a/src/test/run-pass/class-impl-parameterized-trait.rs b/src/test/run-pass/class-impl-parameterized-trait.rs index 0bf5b7de75d..4b4eb1fc774 100644 --- a/src/test/run-pass/class-impl-parameterized-trait.rs +++ b/src/test/run-pass/class-impl-parameterized-trait.rs @@ -12,7 +12,7 @@ // xfail-fast extern mod std; -use std::map::*; +use std::oldmap::*; class cat : map<int, bool> { priv { @@ -73,7 +73,7 @@ class cat : map<int, bool> { fn clear() { } } -fn main() { +pub fn main() { let nyan : cat = cat(0, 2, "nyan"); for uint::range(1u, 5u) |_i| { nyan.speak(); } // cat returns true if uint input is greater than diff --git a/src/test/run-pass/class-impl-very-parameterized-trait.rs b/src/test/run-pass/class-impl-very-parameterized-trait.rs index bccb42c4938..b7c8322316f 100644 --- a/src/test/run-pass/class-impl-very-parameterized-trait.rs +++ b/src/test/run-pass/class-impl-very-parameterized-trait.rs @@ -9,10 +9,8 @@ // except according to those terms. // xfail-fast -#[legacy_modes]; -extern mod std; -use std::map::*; +use core::container::{Container, Mutable, Map}; enum cat_type { tuxedo, tabby, tortoiseshell } @@ -28,121 +26,110 @@ impl cat_type : cmp::Eq { // ok: T should be in scope when resolving the trait ref for map struct cat<T> { - // Yes, you can have negative meows - priv mut meows : int, + // Yes, you can have negative meows + priv mut meows : int, - mut how_hungry : int, - name : T, + mut how_hungry : int, + name : T, } -impl<T: Copy> cat<T> { - fn speak() { self.meow(); } - - fn eat() -> bool { - if self.how_hungry > 0 { - error!("OM NOM NOM"); - self.how_hungry -= 2; - return true; - } - else { - error!("Not hungry!"); - return false; +impl<T> cat<T> { + fn speak(&mut self) { self.meow(); } + + fn eat(&mut self) -> bool { + if self.how_hungry > 0 { + error!("OM NOM NOM"); + self.how_hungry -= 2; + return true; + } else { + error!("Not hungry!"); + return false; + } } - } } -impl<T: Copy> cat<T> : StdMap<int, T> { - pure fn size() -> uint { self.meows as uint } - fn insert(+k: int, +_v: T) -> bool { - self.meows += k; - true - } - pure fn contains_key(+k: int) -> bool { k <= self.meows } - pure fn contains_key_ref(k: &int) -> bool { self.contains_key(*k) } - - pure fn get(+k:int) -> T { match self.find(k) { - Some(v) => { v } - None => { fail ~"epic fail"; } - } - } - pure fn find(+k:int) -> Option<T> { if k <= self.meows { - Some(self.name) - } - else { None } - } - - fn update_with_key(+key: int, +val: T, ff: fn(+k: int, +v0: T, +v1: T) -> T) -> bool { - match self.find(key) { - None => return self.insert(key, val), - Some(copy orig) => return self.insert(key, ff(key, orig, val)) - } - } +impl<T> cat<T>: Container { + pure fn len(&self) -> uint { self.meows as uint } + pure fn is_empty(&self) -> bool { self.meows == 0 } +} - fn update(+key: int, +val: T, ff: fn(+v0: T, +v1: T) -> T) -> bool { - match self.find(key) { - None => return self.insert(key, val), - Some(copy orig) => return self.insert(key, ff(orig, val)) - } - } +impl<T> cat<T>: Mutable { + fn clear(&mut self) {} +} +impl<T> cat<T>: Map<int, T> { + pure fn contains_key(&self, k: &int) -> bool { *k <= self.meows } - fn remove(+k:int) -> bool { - match self.find(k) { - Some(x) => { - self.meows -= k; true - } - None => { false } + pure fn each(&self, f: fn(v: &int, v: &T) -> bool) { + let mut n = int::abs(self.meows); + while n > 0 { + if !f(&n, &self.name) { break; } + n -= 1; + } } - } - pure fn each(f: fn(+v: int, +v: T) -> bool) { - let mut n = int::abs(self.meows); - while n > 0 { - if !f(n, self.name) { break; } - n -= 1; + pure fn each_key(&self, f: fn(v: &int) -> bool) { + for self.each |k, _| { if !f(k) { break; } loop;}; } - } - pure fn each_key(&&f: fn(+v: int) -> bool) { - for self.each |k, _v| { if !f(k) { break; } loop;}; - } - pure fn each_value(&&f: fn(+v: T) -> bool) { - for self.each |_k, v| { if !f(v) { break; } loop;}; - } + pure fn each_value(&self, f: fn(v: &T) -> bool) { + for self.each |_, v| { if !f(v) { break; } loop;}; + } + + fn insert(&mut self, k: int, _: T) -> bool { + self.meows += k; + true + } - pure fn each_ref(f: fn(k: &int, v: &T) -> bool) {} - pure fn each_key_ref(f: fn(k: &int) -> bool) {} - pure fn each_value_ref(f: fn(k: &T) -> bool) {} + pure fn find(&self, k: &int) -> Option<&self/T> { + if *k <= self.meows { + Some(&self.name) + } else { + None + } + } - fn clear() { } + fn remove(&mut self, k: &int) -> bool { + match self.find(k) { + Some(_) => { + self.meows -= *k; true + } + None => { false } + } + } } -priv impl<T: Copy> cat<T> { - fn meow() { - self.meows += 1; - error!("Meow %d", self.meows); - if self.meows % 5 == 0 { - self.how_hungry += 1; - } +impl<T> cat<T> { + pure fn get(&self, k: &int) -> &self/T { + match self.find(k) { + Some(v) => { v } + None => { die!(~"epic fail"); } + } + } + + static pure fn new(in_x: int, in_y: int, in_name: T) -> cat<T> { + cat{meows: in_x, how_hungry: in_y, name: in_name } } } -fn cat<T: Copy>(in_x : int, in_y : int, in_name: T) -> cat<T> { - cat { - meows: in_x, - how_hungry: in_y, - name: in_name +priv impl<T> cat<T> { + fn meow(&mut self) { + self.meows += 1; + error!("Meow %d", self.meows); + if self.meows % 5 == 0 { + self.how_hungry += 1; + } } } fn main() { - let nyan : cat<~str> = cat(0, 2, ~"nyan"); - for uint::range(1u, 5u) |_i| { nyan.speak(); } - assert(nyan.find(1) == Some(~"nyan")); - assert(nyan.find(10) == None); - let spotty : cat<cat_type> = cat(2, 57, tuxedo); - for uint::range(0u, 6u) |_i| { spotty.speak(); } - assert(spotty.size() == 8u); - assert(spotty.contains_key(2)); - assert(spotty.get(3) == tuxedo); + let mut nyan: cat<~str> = cat::new(0, 2, ~"nyan"); + for uint::range(1, 5) |_| { nyan.speak(); } + assert(*nyan.find(&1).unwrap() == ~"nyan"); + assert(nyan.find(&10) == None); + let mut spotty: cat<cat_type> = cat::new(2, 57, tuxedo); + for uint::range(0, 6) |_| { spotty.speak(); } + assert(spotty.len() == 8); + assert(spotty.contains_key(&2)); + assert(spotty.get(&3) == &tuxedo); } diff --git a/src/test/run-pass/class-implement-trait-cross-crate.rs b/src/test/run-pass/class-implement-trait-cross-crate.rs index 3125913ba48..ff052259a76 100644 --- a/src/test/run-pass/class-implement-trait-cross-crate.rs +++ b/src/test/run-pass/class-implement-trait-cross-crate.rs @@ -59,7 +59,7 @@ fn cat(in_x : uint, in_y : int, in_name: ~str) -> cat { } -fn main() { +pub fn main() { let nyan = cat(0u, 2, ~"nyan"); nyan.eat(); assert(!nyan.eat()); diff --git a/src/test/run-pass/class-implement-traits.rs b/src/test/run-pass/class-implement-traits.rs index 1047f632c0f..4679abe21d7 100644 --- a/src/test/run-pass/class-implement-traits.rs +++ b/src/test/run-pass/class-implement-traits.rs @@ -63,7 +63,7 @@ fn make_speak<C: noisy>(c: C) { c.speak(); } -fn main() { +pub fn main() { let nyan = cat(0u, 2, ~"nyan"); nyan.eat(); assert(!nyan.eat()); diff --git a/src/test/run-pass/class-implements-multiple-traits.rs b/src/test/run-pass/class-implements-multiple-traits.rs index f80e3956eda..6d2fb984365 100644 --- a/src/test/run-pass/class-implements-multiple-traits.rs +++ b/src/test/run-pass/class-implements-multiple-traits.rs @@ -11,7 +11,7 @@ // xfail-test extern mod std; -use std::map::*; +use std::oldmap::*; use vec::*; use dvec::{dvec, extensions}; @@ -122,7 +122,7 @@ fn scratched_something<T: scratchy>(critter: T) -> bool { option::is_some(critter.scratch()) } -fn main() { +pub fn main() { let nyan : cat = cat(0u, 2, "nyan"); annoy_neighbors(nyan as noisy); assert(nyan.meow_count() == 10u); diff --git a/src/test/run-pass/class-method-cross-crate.rs b/src/test/run-pass/class-method-cross-crate.rs index abed2e5fb73..bfa61c2f264 100644 --- a/src/test/run-pass/class-method-cross-crate.rs +++ b/src/test/run-pass/class-method-cross-crate.rs @@ -13,7 +13,7 @@ extern mod cci_class_2; use cci_class_2::kitties::*; -fn main() { +pub fn main() { let nyan : cat = cat(52u, 99); let kitty = cat(1000u, 2); assert(nyan.how_hungry == 99); diff --git a/src/test/run-pass/class-methods-cross-crate.rs b/src/test/run-pass/class-methods-cross-crate.rs index b7394405c20..b555abb6ec5 100644 --- a/src/test/run-pass/class-methods-cross-crate.rs +++ b/src/test/run-pass/class-methods-cross-crate.rs @@ -13,7 +13,7 @@ extern mod cci_class_3; use cci_class_3::kitties::*; -fn main() { +pub fn main() { let nyan : cat = cat(52u, 99); let kitty = cat(1000u, 2); assert(nyan.how_hungry == 99); diff --git a/src/test/run-pass/class-methods.rs b/src/test/run-pass/class-methods.rs index 37e2c9a9116..fa43968da0a 100644 --- a/src/test/run-pass/class-methods.rs +++ b/src/test/run-pass/class-methods.rs @@ -27,7 +27,7 @@ fn cat(in_x : uint, in_y : int) -> cat { } } -fn main() { +pub fn main() { let nyan : cat = cat(52u, 99); let kitty = cat(1000u, 2); assert(nyan.how_hungry == 99); diff --git a/src/test/run-pass/class-poly-methods-cross-crate.rs b/src/test/run-pass/class-poly-methods-cross-crate.rs index 018b8cc3706..b0f5b916dd4 100644 --- a/src/test/run-pass/class-poly-methods-cross-crate.rs +++ b/src/test/run-pass/class-poly-methods-cross-crate.rs @@ -13,7 +13,7 @@ extern mod cci_class_6; use cci_class_6::kitties::*; -fn main() { +pub fn main() { let nyan : cat<char> = cat::<char>(52u, 99, ~['p']); let kitty = cat(1000u, 2, ~[~"tabby"]); assert(nyan.how_hungry == 99); diff --git a/src/test/run-pass/class-poly-methods.rs b/src/test/run-pass/class-poly-methods.rs index a91b263d3ec..b7e638f40e8 100644 --- a/src/test/run-pass/class-poly-methods.rs +++ b/src/test/run-pass/class-poly-methods.rs @@ -30,7 +30,7 @@ fn cat<U>(in_x : uint, in_y : int, -in_info: ~[U]) -> cat<U> { } } -fn main() { +pub fn main() { let nyan : cat<int> = cat::<int>(52u, 99, ~[9]); let kitty = cat(1000u, 2, ~[~"tabby"]); assert(nyan.how_hungry == 99); diff --git a/src/test/run-pass/class-separate-impl.rs b/src/test/run-pass/class-separate-impl.rs index eb3728f2c6f..7e59b5d7a87 100644 --- a/src/test/run-pass/class-separate-impl.rs +++ b/src/test/run-pass/class-separate-impl.rs @@ -54,7 +54,7 @@ fn cat(in_x : uint, in_y : int, in_name: ~str) -> cat { } impl cat: ToStr { - pure fn to_str() -> ~str { copy self.name } + pure fn to_str(&self) -> ~str { copy self.name } } fn print_out<T: ToStr>(thing: T, expected: ~str) { @@ -63,7 +63,7 @@ fn print_out<T: ToStr>(thing: T, expected: ~str) { assert(actual == expected); } -fn main() { +pub fn main() { let nyan : ToStr = cat(0u, 2, ~"nyan") as ToStr; print_out(nyan, ~"nyan"); } diff --git a/src/test/run-pass/class-str-field.rs b/src/test/run-pass/class-str-field.rs index a8d980fc8aa..060ad2b4beb 100644 --- a/src/test/run-pass/class-str-field.rs +++ b/src/test/run-pass/class-str-field.rs @@ -20,6 +20,6 @@ fn cat(in_name: ~str) -> cat { } } -fn main() { +pub fn main() { let nyan = cat(~"nyan"); } \ No newline at end of file diff --git a/src/test/run-pass/class-trait-bounded-param.rs b/src/test/run-pass/class-trait-bounded-param.rs index b6e9d66ec72..e3c4703432f 100644 --- a/src/test/run-pass/class-trait-bounded-param.rs +++ b/src/test/run-pass/class-trait-bounded-param.rs @@ -11,7 +11,7 @@ // xfail-test extern mod std; -use std::map::{map, hashmap, int_hash}; +use std::oldmap::{map, hashmap, int_hash}; class keys<K: Copy, V: Copy, M: Copy map<K,V>> : iter::base_iter<K> { @@ -27,7 +27,7 @@ class keys<K: Copy, V: Copy, M: Copy map<K,V>> fn eachi(blk: fn(uint, K) -> bool) { iter::eachi(self, blk) } } -fn main() { +pub fn main() { let m = int_hash(); m.insert(1, 2); m.insert(3, 4); diff --git a/src/test/run-pass/class-typarams.rs b/src/test/run-pass/class-typarams.rs index a64b33e11d3..b8d0e593286 100644 --- a/src/test/run-pass/class-typarams.rs +++ b/src/test/run-pass/class-typarams.rs @@ -29,7 +29,7 @@ fn cat<U>(in_x : uint, in_y : int) -> cat<U> { } -fn main() { +pub fn main() { let _nyan : cat<int> = cat::<int>(52u, 99); // let kitty = cat(1000u, 2); } diff --git a/src/test/run-pass/classes-cross-crate.rs b/src/test/run-pass/classes-cross-crate.rs index e41879e5f38..1b68e6c519a 100644 --- a/src/test/run-pass/classes-cross-crate.rs +++ b/src/test/run-pass/classes-cross-crate.rs @@ -13,7 +13,7 @@ extern mod cci_class_4; use cci_class_4::kitties::*; -fn main() { +pub fn main() { let nyan = cat(0u, 2, ~"nyan"); nyan.eat(); assert(!nyan.eat()); diff --git a/src/test/run-pass/classes-self-referential.rs b/src/test/run-pass/classes-self-referential.rs index 075d10e742d..4f2499eced4 100644 --- a/src/test/run-pass/classes-self-referential.rs +++ b/src/test/run-pass/classes-self-referential.rs @@ -20,4 +20,4 @@ fn kitten(cat: Option<cat>) -> kitten { type cat = @kitten; -fn main() {} +pub fn main() {} diff --git a/src/test/run-pass/classes-simple-cross-crate.rs b/src/test/run-pass/classes-simple-cross-crate.rs index 345e661d536..74f4b0aac69 100644 --- a/src/test/run-pass/classes-simple-cross-crate.rs +++ b/src/test/run-pass/classes-simple-cross-crate.rs @@ -13,7 +13,7 @@ extern mod cci_class; use cci_class::kitties::*; -fn main() { +pub fn main() { let nyan : cat = cat(52u, 99); let kitty = cat(1000u, 2); assert(nyan.how_hungry == 99); diff --git a/src/test/run-pass/classes-simple-method.rs b/src/test/run-pass/classes-simple-method.rs index a0b2f900e7f..f44ee4bd502 100644 --- a/src/test/run-pass/classes-simple-method.rs +++ b/src/test/run-pass/classes-simple-method.rs @@ -25,7 +25,7 @@ fn cat(in_x : uint, in_y : int) -> cat { } } -fn main() { +pub fn main() { let nyan : cat = cat(52u, 99); let kitty = cat(1000u, 2); assert(nyan.how_hungry == 99); diff --git a/src/test/run-pass/classes-simple.rs b/src/test/run-pass/classes-simple.rs index 2f0ae25f1ab..3520719d499 100644 --- a/src/test/run-pass/classes-simple.rs +++ b/src/test/run-pass/classes-simple.rs @@ -22,7 +22,7 @@ fn cat(in_x : uint, in_y : int) -> cat { } } -fn main() { +pub fn main() { let nyan : cat = cat(52u, 99); let kitty = cat(1000u, 2); assert(nyan.how_hungry == 99); diff --git a/src/test/run-pass/classes.rs b/src/test/run-pass/classes.rs index 41af1f2d741..c3bc2f096ba 100644 --- a/src/test/run-pass/classes.rs +++ b/src/test/run-pass/classes.rs @@ -50,7 +50,7 @@ fn cat(in_x : uint, in_y : int, in_name: ~str) -> cat { } } -fn main() { +pub fn main() { let nyan = cat(0u, 2, ~"nyan"); nyan.eat(); assert(!nyan.eat()); diff --git a/src/test/run-pass/cleanup-copy-mode.rs b/src/test/run-pass/cleanup-copy-mode.rs index be1f80ceb2d..c7c42c7fcac 100644 --- a/src/test/run-pass/cleanup-copy-mode.rs +++ b/src/test/run-pass/cleanup-copy-mode.rs @@ -10,8 +10,8 @@ // xfail-win32 fn adder(+x: @int, +y: @int) -> int { return *x + *y; } -fn failer() -> @int { fail; } -fn main() { +fn failer() -> @int { die!(); } +pub fn main() { assert(result::is_err(&task::try(|| { adder(@2, failer()); () }))); diff --git a/src/test/run-pass/clone-with-exterior.rs b/src/test/run-pass/clone-with-exterior.rs index a2d739a2584..09b57ebd617 100644 --- a/src/test/run-pass/clone-with-exterior.rs +++ b/src/test/run-pass/clone-with-exterior.rs @@ -17,7 +17,7 @@ fn f(x : @{a:int, b:int}) { assert (x.b == 12); } -fn main() { +pub fn main() { let z : @{a:int, b:int} = @{ a : 10, b : 12}; let p = task::_spawn(bind f(z)); task::join_id(p); diff --git a/src/test/run-pass/close-over-big-then-small-data.rs b/src/test/run-pass/close-over-big-then-small-data.rs index a2a97f531de..d218519a4f3 100644 --- a/src/test/run-pass/close-over-big-then-small-data.rs +++ b/src/test/run-pass/close-over-big-then-small-data.rs @@ -20,7 +20,7 @@ fn f<A:Copy &static>(a: A, b: u16) -> fn@() -> (A, u16) { fn@() -> (A, u16) { (a, b) } } -fn main() { +pub fn main() { let (a, b) = f(22_u64, 44u16)(); debug!("a=%? b=%?", a, b); assert a == 22u64; diff --git a/src/test/run-pass/closure-inference.rs b/src/test/run-pass/closure-inference.rs index df71bd76747..99c8fd6e2d3 100644 --- a/src/test/run-pass/closure-inference.rs +++ b/src/test/run-pass/closure-inference.rs @@ -15,7 +15,7 @@ fn foo(i: int) -> int { i + 1 } fn apply<A>(f: fn(A) -> A, v: A) -> A { f(v) } -fn main() { +pub fn main() { let f = {|i| foo(i)}; assert apply(f, 2) == 3; } diff --git a/src/test/run-pass/closure-inference2.rs b/src/test/run-pass/closure-inference2.rs index f449880521a..ed86326cb38 100644 --- a/src/test/run-pass/closure-inference2.rs +++ b/src/test/run-pass/closure-inference2.rs @@ -10,7 +10,7 @@ // Test a rather underspecified example: -fn main() { +pub fn main() { let f = {|i| i}; assert f(2) == 2; assert f(5) == 5; diff --git a/src/test/run-pass/coerce-reborrow-imm-ptr-arg.rs b/src/test/run-pass/coerce-reborrow-imm-ptr-arg.rs index 3c9748f29d9..37770f4d59b 100644 --- a/src/test/run-pass/coerce-reborrow-imm-ptr-arg.rs +++ b/src/test/run-pass/coerce-reborrow-imm-ptr-arg.rs @@ -14,4 +14,4 @@ fn negate_const(y: &const int) -> int { negate(y) } -fn main() {} +pub fn main() {} diff --git a/src/test/run-pass/coerce-reborrow-imm-ptr-rcvr.rs b/src/test/run-pass/coerce-reborrow-imm-ptr-rcvr.rs index 0d8f40677f8..268e540c10e 100644 --- a/src/test/run-pass/coerce-reborrow-imm-ptr-rcvr.rs +++ b/src/test/run-pass/coerce-reborrow-imm-ptr-rcvr.rs @@ -10,7 +10,7 @@ fn foo(speaker: &const SpeechMaker) -> uint { speaker.how_many() + 33 } -fn main() { +pub fn main() { let mut lincoln = SpeechMaker {speeches: 22}; assert foo(&const lincoln) == 55; } diff --git a/src/test/run-pass/coerce-reborrow-imm-vec-arg.rs b/src/test/run-pass/coerce-reborrow-imm-vec-arg.rs index 54a6b35b8ba..ba7d78ba04f 100644 --- a/src/test/run-pass/coerce-reborrow-imm-vec-arg.rs +++ b/src/test/run-pass/coerce-reborrow-imm-vec-arg.rs @@ -4,7 +4,7 @@ pure fn sum(x: &[int]) -> int { return sum; } -fn sum_mut(y: &[mut int]) -> int { +fn sum_mut(y: &mut [int]) -> int { sum(y) } @@ -16,4 +16,4 @@ fn sum_const(y: &[const int]) -> int { sum(y) } -fn main() {} \ No newline at end of file +pub fn main() {} diff --git a/src/test/run-pass/coerce-reborrow-imm-vec-rcvr.rs b/src/test/run-pass/coerce-reborrow-imm-vec-rcvr.rs index 24fb5cbd883..7b01fe81c67 100644 --- a/src/test/run-pass/coerce-reborrow-imm-vec-rcvr.rs +++ b/src/test/run-pass/coerce-reborrow-imm-vec-rcvr.rs @@ -2,7 +2,7 @@ fn foo(v: &[const uint]) -> ~[uint] { v.to_vec() } -fn bar(v: &[mut uint]) -> ~[uint] { +fn bar(v: &mut [uint]) -> ~[uint] { v.to_vec() } @@ -10,7 +10,7 @@ fn bip(v: &[uint]) -> ~[uint] { v.to_vec() } -fn main() { +pub fn main() { let mut the_vec = ~[1, 2, 3, 100]; assert the_vec == foo(the_vec); assert the_vec == bar(the_vec); diff --git a/src/test/run-pass/coerce-reborrow-mut-ptr-arg.rs b/src/test/run-pass/coerce-reborrow-mut-ptr-arg.rs index 4579907dfbd..f8650c856c6 100644 --- a/src/test/run-pass/coerce-reborrow-mut-ptr-arg.rs +++ b/src/test/run-pass/coerce-reborrow-mut-ptr-arg.rs @@ -16,7 +16,7 @@ fn give_a_few_speeches(speaker: &mut SpeechMaker) { talk(speaker); } -fn main() { +pub fn main() { let mut lincoln = SpeechMaker {speeches: 22}; give_a_few_speeches(&mut lincoln); } diff --git a/src/test/run-pass/coerce-reborrow-mut-ptr-rcvr.rs b/src/test/run-pass/coerce-reborrow-mut-ptr-rcvr.rs index c915c01416e..a2ba4ddb827 100644 --- a/src/test/run-pass/coerce-reborrow-mut-ptr-rcvr.rs +++ b/src/test/run-pass/coerce-reborrow-mut-ptr-rcvr.rs @@ -18,7 +18,7 @@ fn give_a_few_speeches(speaker: &mut SpeechMaker) { speaker.talk(); } -fn main() { +pub fn main() { let mut lincoln = SpeechMaker {speeches: 22}; give_a_few_speeches(&mut lincoln); } diff --git a/src/test/run-pass/coerce-reborrow-mut-vec-arg.rs b/src/test/run-pass/coerce-reborrow-mut-vec-arg.rs index 0cce52e7dc8..0c31560e981 100644 --- a/src/test/run-pass/coerce-reborrow-mut-vec-arg.rs +++ b/src/test/run-pass/coerce-reborrow-mut-vec-arg.rs @@ -2,13 +2,13 @@ trait Reverser { fn reverse(&self); } -fn bar(v: &[mut uint]) { +fn bar(v: &mut [uint]) { vec::reverse(v); vec::reverse(v); vec::reverse(v); } -fn main() { +pub fn main() { let mut the_vec = ~[1, 2, 3, 100]; bar(the_vec); assert the_vec == ~[100, 3, 2, 1]; diff --git a/src/test/run-pass/coerce-reborrow-mut-vec-rcvr.rs b/src/test/run-pass/coerce-reborrow-mut-vec-rcvr.rs index 9fb748f049f..0820af24c49 100644 --- a/src/test/run-pass/coerce-reborrow-mut-vec-rcvr.rs +++ b/src/test/run-pass/coerce-reborrow-mut-vec-rcvr.rs @@ -2,19 +2,19 @@ trait Reverser { fn reverse(&self); } -impl &[mut uint] : Reverser { +impl &mut [uint] : Reverser { fn reverse(&self) { vec::reverse(*self); } } -fn bar(v: &[mut uint]) { +fn bar(v: &mut [uint]) { v.reverse(); v.reverse(); v.reverse(); } -fn main() { +pub fn main() { let mut the_vec = ~[1, 2, 3, 100]; bar(the_vec); assert the_vec == ~[100, 3, 2, 1]; diff --git a/src/test/run-pass/coherence-copy-bound.rs b/src/test/run-pass/coherence-copy-bound.rs index fc6c1592119..7435096c275 100644 --- a/src/test/run-pass/coherence-copy-bound.rs +++ b/src/test/run-pass/coherence-copy-bound.rs @@ -9,5 +9,5 @@ struct S { impl S : X {} -fn main(){} +pub fn main(){} diff --git a/src/test/run-pass/coherence-impl-in-fn.rs b/src/test/run-pass/coherence-impl-in-fn.rs index e014ffe4bef..561187d1934 100644 --- a/src/test/run-pass/coherence-impl-in-fn.rs +++ b/src/test/run-pass/coherence-impl-in-fn.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -fn main() { +pub fn main() { enum x { foo } impl x : ::core::cmp::Eq { pure fn eq(&self, other: &x) -> bool { diff --git a/src/test/run-pass/comm.rs b/src/test/run-pass/comm.rs index 4197a63107c..1af0bb003f2 100644 --- a/src/test/run-pass/comm.rs +++ b/src/test/run-pass/comm.rs @@ -11,7 +11,7 @@ use core::pipes::*; -fn main() { +pub fn main() { let (p, ch) = stream(); let t = task::spawn(|| child(&ch) ); let y = p.recv(); diff --git a/src/test/run-pass/common-fields-trivial.rs b/src/test/run-pass/common-fields-trivial.rs index b0fac593ca4..fd5079b8f54 100644 --- a/src/test/run-pass/common-fields-trivial.rs +++ b/src/test/run-pass/common-fields-trivial.rs @@ -18,7 +18,7 @@ enum Foo { Baz(int) } -fn main() { +pub fn main() { let x = Bar(3); } diff --git a/src/test/run-pass/compare-generic-enums.rs b/src/test/run-pass/compare-generic-enums.rs index c8b4945c719..e73e1e97555 100644 --- a/src/test/run-pass/compare-generic-enums.rs +++ b/src/test/run-pass/compare-generic-enums.rs @@ -14,7 +14,7 @@ fn cmp(x: Option<an_int>, y: Option<int>) -> bool { x == y } -fn main() { +pub fn main() { assert !cmp(Some(3), None); assert !cmp(Some(3), Some(4)); assert cmp(Some(3), Some(3)); diff --git a/src/test/run-pass/complex.rs b/src/test/run-pass/complex.rs index 57835b8b7a8..de60a56ba4a 100644 --- a/src/test/run-pass/complex.rs +++ b/src/test/run-pass/complex.rs @@ -35,7 +35,7 @@ fn foo(x: int) -> int { return 0; } -fn main() { +pub fn main() { let x: int = 2 + 2; log(debug, x); debug!("hello, world"); diff --git a/src/test/run-pass/conditional-compile-arch.rs b/src/test/run-pass/conditional-compile-arch.rs index 959805bd911..a47e9d9ea81 100644 --- a/src/test/run-pass/conditional-compile-arch.rs +++ b/src/test/run-pass/conditional-compile-arch.rs @@ -9,7 +9,7 @@ // except according to those terms. #[cfg(target_arch = "x86")] -fn main() { } +pub fn main() { } #[cfg(target_arch = "x86_64")] -fn main() { } +pub fn main() { } diff --git a/src/test/run-pass/conditional-compile.rs b/src/test/run-pass/conditional-compile.rs index 404a58e1a4b..33b5d275a45 100644 --- a/src/test/run-pass/conditional-compile.rs +++ b/src/test/run-pass/conditional-compile.rs @@ -81,9 +81,9 @@ mod m { // Since the bogus configuration isn't defined main will just be // parsed, but nothing further will be done with it #[cfg(bogus)] -fn main() { fail } +pub fn main() { die!() } -fn main() { +pub fn main() { // Exercise some of the configured items in ways that wouldn't be possible // if they had the bogus definition assert (b); @@ -95,7 +95,7 @@ fn main() { fn test_in_fn_ctxt() { #[cfg(bogus)] - fn f() { fail } + fn f() { die!() } fn f() { } f(); diff --git a/src/test/run-pass/const-big-enum.rs b/src/test/run-pass/const-big-enum.rs index aa977f17e69..1a41efd41d1 100644 --- a/src/test/run-pass/const-big-enum.rs +++ b/src/test/run-pass/const-big-enum.rs @@ -16,21 +16,21 @@ enum Foo { const X: Foo = Baz; -fn main() { +pub fn main() { match X { Baz => {} - _ => fail + _ => die!() } match Y { Bar(s) => assert(s == 2654435769), - _ => fail + _ => die!() } match Z { Quux(d,h) => { assert(d == 0x123456789abcdef0); assert(h == 0x1234); } - _ => fail + _ => die!() } } diff --git a/src/test/run-pass/const-bound.rs b/src/test/run-pass/const-bound.rs index 3c55409dde8..2320a5b1aa3 100644 --- a/src/test/run-pass/const-bound.rs +++ b/src/test/run-pass/const-bound.rs @@ -16,7 +16,7 @@ fn foo<T: Copy Const>(x: T) -> T { x } struct F { field: int } -fn main() { +pub fn main() { foo(1); foo(~"hi"); foo(~[1, 2, 3]); diff --git a/src/test/run-pass/const-const.rs b/src/test/run-pass/const-const.rs index 7fec4011af4..b3498b4dc58 100644 --- a/src/test/run-pass/const-const.rs +++ b/src/test/run-pass/const-const.rs @@ -11,6 +11,6 @@ const a: int = 1; const b: int = a + 2; -fn main() { +pub fn main() { assert b == 3; } \ No newline at end of file diff --git a/src/test/run-pass/const-contents.rs b/src/test/run-pass/const-contents.rs index 7ad7795ba3b..512ecc6d351 100644 --- a/src/test/run-pass/const-contents.rs +++ b/src/test/run-pass/const-contents.rs @@ -17,7 +17,7 @@ const not : int = !0; const notb : bool = !true; const neg : int = -(1); -fn main() { +pub fn main() { assert(lsl == 4); assert(add == 3); assert(addf == 3.0f); diff --git a/src/test/run-pass/const-enum-byref-self.rs b/src/test/run-pass/const-enum-byref-self.rs index cd939bc14d4..6751a0787e4 100644 --- a/src/test/run-pass/const-enum-byref-self.rs +++ b/src/test/run-pass/const-enum-byref-self.rs @@ -15,11 +15,11 @@ impl E { fn method(&self) { match *self { V => {} - VV(*) => fail + VV(*) => die!() } } } -fn main() { +pub fn main() { C.method() } diff --git a/src/test/run-pass/const-enum-byref.rs b/src/test/run-pass/const-enum-byref.rs index 8ee9e79670b..f3ea9e08343 100644 --- a/src/test/run-pass/const-enum-byref.rs +++ b/src/test/run-pass/const-enum-byref.rs @@ -14,10 +14,10 @@ const C: E = V; fn f(a: &E) { match *a { V => {} - VV(*) => fail + VV(*) => die!() } } -fn main() { +pub fn main() { f(&C) } diff --git a/src/test/run-pass/const-extern-function.rs b/src/test/run-pass/const-extern-function.rs index e8fd09137a5..4d7dc6bac9d 100644 --- a/src/test/run-pass/const-extern-function.rs +++ b/src/test/run-pass/const-extern-function.rs @@ -17,7 +17,7 @@ struct S { f: *u8 } -fn main() { +pub fn main() { assert foopy == f; assert f == s.f; } \ No newline at end of file diff --git a/src/test/run-pass/const-fields-and-indexing.rs b/src/test/run-pass/const-fields-and-indexing.rs index 6dccecb5aa8..a417ad3ca6e 100644 --- a/src/test/run-pass/const-fields-and-indexing.rs +++ b/src/test/run-pass/const-fields-and-indexing.rs @@ -25,7 +25,7 @@ const k : K = K {a: 10, b: 20, c: D {d: 30, e: 40}}; const m : int = k.c.e; -fn main() { +pub fn main() { io::println(fmt!("%?", p)); io::println(fmt!("%?", q)); io::println(fmt!("%?", t)); diff --git a/src/test/run-pass/const-fn-val.rs b/src/test/run-pass/const-fn-val.rs index 21a39805ac3..17c66b354a1 100644 --- a/src/test/run-pass/const-fn-val.rs +++ b/src/test/run-pass/const-fn-val.rs @@ -16,6 +16,6 @@ struct Bar { f: &fn() -> int } const b : Bar = Bar { f: foo }; -fn main() { +pub fn main() { assert (b.f)() == 0xca7f000d; } \ No newline at end of file diff --git a/src/test/run-pass/const-negative.rs b/src/test/run-pass/const-negative.rs index dd795966376..44917e23293 100644 --- a/src/test/run-pass/const-negative.rs +++ b/src/test/run-pass/const-negative.rs @@ -12,6 +12,6 @@ const toplevel_mod: int = -1; -fn main() { +pub fn main() { assert toplevel_mod == -1; } \ No newline at end of file diff --git a/src/test/run-pass/const-newtype-enum.rs b/src/test/run-pass/const-newtype-enum.rs index 069565aa4f8..5e1bc7561d9 100644 --- a/src/test/run-pass/const-newtype-enum.rs +++ b/src/test/run-pass/const-newtype-enum.rs @@ -12,7 +12,7 @@ enum Foo = u32; const X: Foo = Foo(17); -fn main() { +pub fn main() { assert(*X == 17); assert(*Y == 23); } diff --git a/src/test/run-pass/const-nullary-enum.rs b/src/test/run-pass/const-nullary-enum.rs index 098305bbe35..5a266e4c15a 100644 --- a/src/test/run-pass/const-nullary-enum.rs +++ b/src/test/run-pass/const-nullary-enum.rs @@ -16,14 +16,14 @@ enum Foo { const X: Foo = Bar; -fn main() { +pub fn main() { match X { Bar => {} - Baz | Boo => fail + Baz | Boo => die!() } match Y { Baz => {} - Bar | Boo => fail + Bar | Boo => die!() } } diff --git a/src/test/run-pass/const-nullary-univariant-enum.rs b/src/test/run-pass/const-nullary-univariant-enum.rs index 2fa5a7760f6..2709d0d8a56 100644 --- a/src/test/run-pass/const-nullary-univariant-enum.rs +++ b/src/test/run-pass/const-nullary-univariant-enum.rs @@ -14,7 +14,7 @@ enum Foo { const X: Foo = Bar; -fn main() { +pub fn main() { assert((X as uint) == 0xDEADBEE); assert((Y as uint) == 0xDEADBEE); } diff --git a/src/test/run-pass/const-rec-and-tup.rs b/src/test/run-pass/const-rec-and-tup.rs index b3d971a2cef..04d1aa11478 100644 --- a/src/test/run-pass/const-rec-and-tup.rs +++ b/src/test/run-pass/const-rec-and-tup.rs @@ -18,7 +18,7 @@ const y : AnotherPair = AnotherPair{ x: (0xf0f0f0f0_f0f0f0f0, y: Pair { a: 3.14159265358979323846, b: 2.7182818284590452354 }}; -fn main() { +pub fn main() { let (p, _) = y.x; assert p == 0xf0f0f0f0_f0f0f0f0; io::println(fmt!("0x%x", p as uint)); diff --git a/src/test/run-pass/const-region-ptrs.rs b/src/test/run-pass/const-region-ptrs.rs index c8b08b1e35a..ce626cf612f 100644 --- a/src/test/run-pass/const-region-ptrs.rs +++ b/src/test/run-pass/const-region-ptrs.rs @@ -15,7 +15,7 @@ const x: &int = &10; const y: &Pair = &Pair {a: 15, b: x}; -fn main() { +pub fn main() { io::println(fmt!("x = %?", *x)); io::println(fmt!("y = {a: %?, b: %?}", y.a, *(y.b))); assert *x == 10; diff --git a/src/test/run-pass/const-struct.rs b/src/test/run-pass/const-struct.rs index 8a7b5b474ec..58c09ccce92 100644 --- a/src/test/run-pass/const-struct.rs +++ b/src/test/run-pass/const-struct.rs @@ -24,7 +24,7 @@ const x : foo = foo { a:1, b:2, c: 3 }; const y : foo = foo { b:2, c:3, a: 1 }; const z : &foo = &foo { a: 10, b: 22, c: 12 }; -fn main() { +pub fn main() { assert x.b == 2; assert x == y; assert z.b == 22; diff --git a/src/test/run-pass/const-tuple-struct.rs b/src/test/run-pass/const-tuple-struct.rs index 91dc2576f8a..9f8618d82ca 100644 --- a/src/test/run-pass/const-tuple-struct.rs +++ b/src/test/run-pass/const-tuple-struct.rs @@ -12,7 +12,7 @@ struct Bar(int, int); const X: Bar = Bar(1, 2); -fn main() { +pub fn main() { match X { Bar(x, y) => { assert x == 1; diff --git a/src/test/run-pass/const-unit-struct.rs b/src/test/run-pass/const-unit-struct.rs index ebad469088d..bc996314e03 100644 --- a/src/test/run-pass/const-unit-struct.rs +++ b/src/test/run-pass/const-unit-struct.rs @@ -12,7 +12,7 @@ struct Foo; const X: Foo = Foo; -fn main() { +pub fn main() { match X { Foo => {} } diff --git a/src/test/run-pass/const-vecs-and-slices.rs b/src/test/run-pass/const-vecs-and-slices.rs index c4e406d9adc..a0ac67288cf 100644 --- a/src/test/run-pass/const-vecs-and-slices.rs +++ b/src/test/run-pass/const-vecs-and-slices.rs @@ -11,7 +11,7 @@ const x : [int * 4] = [1,2,3,4]; const y : &[int] = &[1,2,3,4]; -fn main() { +pub fn main() { io::println(fmt!("%?", x[1])); io::println(fmt!("%?", y[1])); assert x[1] == 2; diff --git a/src/test/run-pass/const.rs b/src/test/run-pass/const.rs index 38835873cc5..28cca2f413b 100644 --- a/src/test/run-pass/const.rs +++ b/src/test/run-pass/const.rs @@ -12,4 +12,4 @@ const i: int = 10; -fn main() { log(debug, i); } +pub fn main() { log(debug, i); } diff --git a/src/test/run-pass/consts-in-patterns.rs b/src/test/run-pass/consts-in-patterns.rs index 31968ccc244..1356ff0a043 100644 --- a/src/test/run-pass/consts-in-patterns.rs +++ b/src/test/run-pass/consts-in-patterns.rs @@ -11,7 +11,7 @@ const FOO: int = 10; const BAR: int = 3; -fn main() { +pub fn main() { let x: int = 3; let y = match x { FOO => 1, diff --git a/src/test/run-pass/core-export-f64-sqrt.rs b/src/test/run-pass/core-export-f64-sqrt.rs index 9b080206fcd..d7ac91fe75c 100644 --- a/src/test/run-pass/core-export-f64-sqrt.rs +++ b/src/test/run-pass/core-export-f64-sqrt.rs @@ -10,9 +10,9 @@ // Regression test that f64 exports things properly -fn main() { +pub fn main() { let digits: uint = 10 as uint; - ::core::io::println(float::to_str(f64::sqrt(42.0f64) as float, digits)); + ::core::io::println(float::to_str_digits(f64::sqrt(42.0f64) as float, digits)); } diff --git a/src/test/run-pass/crate-method-reexport-grrrrrrr.rs b/src/test/run-pass/crate-method-reexport-grrrrrrr.rs index 6f0ee563d6e..ac79a2256fd 100644 --- a/src/test/run-pass/crate-method-reexport-grrrrrrr.rs +++ b/src/test/run-pass/crate-method-reexport-grrrrrrr.rs @@ -17,7 +17,7 @@ extern mod crate_method_reexport_grrrrrrr2; -fn main() { +pub fn main() { use crate_method_reexport_grrrrrrr2::rust::add; use crate_method_reexport_grrrrrrr2::rust::cx; let x = @(); diff --git a/src/test/run-pass/crateresolve1.rs b/src/test/run-pass/crateresolve1.rs index aceac3a12c1..4b037919154 100644 --- a/src/test/run-pass/crateresolve1.rs +++ b/src/test/run-pass/crateresolve1.rs @@ -15,6 +15,6 @@ extern mod crateresolve1(vers = "0.2"); -fn main() { +pub fn main() { assert crateresolve1::f() == 20; } diff --git a/src/test/run-pass/crateresolve2.rs b/src/test/run-pass/crateresolve2.rs index 407c8792d88..dd9f60687b3 100644 --- a/src/test/run-pass/crateresolve2.rs +++ b/src/test/run-pass/crateresolve2.rs @@ -28,7 +28,7 @@ mod c { pub fn f() { assert crateresolve2::f() == 30; } } -fn main() { +pub fn main() { a::f(); b::f(); c::f(); diff --git a/src/test/run-pass/crateresolve3.rs b/src/test/run-pass/crateresolve3.rs index e92febf9637..71f0fa8adfa 100644 --- a/src/test/run-pass/crateresolve3.rs +++ b/src/test/run-pass/crateresolve3.rs @@ -25,7 +25,7 @@ mod b { pub fn f() { assert crateresolve3::g() == 20; } } -fn main() { +pub fn main() { a::f(); b::f(); } diff --git a/src/test/run-pass/crateresolve5.rs b/src/test/run-pass/crateresolve5.rs index 0b0d9a839ce..d6a4ab210ed 100644 --- a/src/test/run-pass/crateresolve5.rs +++ b/src/test/run-pass/crateresolve5.rs @@ -15,7 +15,7 @@ extern mod cr5_1 (name = "crateresolve5", vers = "0.1"); extern mod cr5_2 (name = "crateresolve5", vers = "0.2"); -fn main() { +pub fn main() { // Structural types can be used between two versions of the same crate assert cr5_1::struct_nameval().name == cr5_2::struct_nameval().name; assert cr5_1::struct_nameval().val == cr5_2::struct_nameval().val; diff --git a/src/test/run-pass/crateresolve6.rs b/src/test/run-pass/crateresolve6.rs index 6aadb2805db..cabc60a00ee 100644 --- a/src/test/run-pass/crateresolve6.rs +++ b/src/test/run-pass/crateresolve6.rs @@ -17,7 +17,7 @@ extern mod cr6_1 (name = "crateresolve_calories", vers = "0.1", calories="100"); extern mod cr6_2 (name = "crateresolve_calories", vers = "0.1", calories="200"); -fn main() { +pub fn main() { assert cr6_1::f() == 100; assert cr6_2::f() == 200; } diff --git a/src/test/run-pass/crateresolve7.rs b/src/test/run-pass/crateresolve7.rs index 1dca6813732..f6dccdbfd70 100644 --- a/src/test/run-pass/crateresolve7.rs +++ b/src/test/run-pass/crateresolve7.rs @@ -15,7 +15,7 @@ extern mod crateresolve7x; -fn main() { +pub fn main() { assert crateresolve7x::a::f() == 100; assert crateresolve7x::b::f() == 200; } diff --git a/src/test/run-pass/cycle-collection.rs b/src/test/run-pass/cycle-collection.rs index e3965b64e6a..0512b8a1267 100644 --- a/src/test/run-pass/cycle-collection.rs +++ b/src/test/run-pass/cycle-collection.rs @@ -18,7 +18,7 @@ fn f() { *box = cons(box); } -fn main() { +pub fn main() { f(); } diff --git a/src/test/run-pass/cycle-collection2.rs b/src/test/run-pass/cycle-collection2.rs index 69f2995df30..8eaad5c08b2 100644 --- a/src/test/run-pass/cycle-collection2.rs +++ b/src/test/run-pass/cycle-collection2.rs @@ -13,7 +13,7 @@ struct foo { mut z : fn@() } fn nop() { } fn nop_foo(_x : @foo) { } -fn main() { +pub fn main() { let w = @foo{ mut z: || nop() }; let x : fn@() = || nop_foo(w); w.z = x; diff --git a/src/test/run-pass/cycle-collection4.rs b/src/test/run-pass/cycle-collection4.rs index f7c7cdc76f5..b34ff10b531 100644 --- a/src/test/run-pass/cycle-collection4.rs +++ b/src/test/run-pass/cycle-collection4.rs @@ -13,7 +13,7 @@ struct foo { mut z : fn@() } fn nop() { } fn nop_foo(_y: ~[int], _x : @foo) { } -fn main() { +pub fn main() { let w = @foo{ z: || nop() }; let x : fn@() = || nop_foo(~[], w); w.z = x; diff --git a/src/test/run-pass/cycle-collection5.rs b/src/test/run-pass/cycle-collection5.rs index 2d05de2d4fd..9a5d776bacc 100644 --- a/src/test/run-pass/cycle-collection5.rs +++ b/src/test/run-pass/cycle-collection5.rs @@ -15,7 +15,7 @@ fn nop_foo(_y: @int, _x : @foo) { } fn o() -> @int { @10 } -fn main() { +pub fn main() { let w = @foo { mut z: || nop() }; let x : fn@() = || nop_foo(o(), w); w.z = x; diff --git a/src/test/run-pass/dead-code-one-arm-if.rs b/src/test/run-pass/dead-code-one-arm-if.rs index d705f5b3d06..eb30b36e48a 100644 --- a/src/test/run-pass/dead-code-one-arm-if.rs +++ b/src/test/run-pass/dead-code-one-arm-if.rs @@ -12,4 +12,4 @@ // -*- rust -*- -fn main() { if 1 == 1 { return; } debug!("Paul is dead"); } +pub fn main() { if 1 == 1 { return; } debug!("Paul is dead"); } diff --git a/src/test/run-pass/deep-vector.rs b/src/test/run-pass/deep-vector.rs index 548b0a33f99..d2d8181e114 100644 --- a/src/test/run-pass/deep-vector.rs +++ b/src/test/run-pass/deep-vector.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -fn main() { +pub fn main() { let _x = ~[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, diff --git a/src/test/run-pass/deep-vector2.rs b/src/test/run-pass/deep-vector2.rs index 91af56c2555..e66cf1bbea6 100644 --- a/src/test/run-pass/deep-vector2.rs +++ b/src/test/run-pass/deep-vector2.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -fn main() { +pub fn main() { let x = ~[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, diff --git a/src/test/run-pass/deep.rs b/src/test/run-pass/deep.rs index 860a49031da..2f51ec4a7dc 100644 --- a/src/test/run-pass/deep.rs +++ b/src/test/run-pass/deep.rs @@ -16,4 +16,4 @@ fn f(x: int) -> int { if x == 1 { return 1; } else { let y: int = 1 + f(x - 1); return y; } } -fn main() { assert (f(5000) == 5000); } +pub fn main() { assert (f(5000) == 5000); } diff --git a/src/test/run-pass/default-method-simple.rs b/src/test/run-pass/default-method-simple.rs index 5d3dc42c41e..41ab5b1d3c8 100644 --- a/src/test/run-pass/default-method-simple.rs +++ b/src/test/run-pass/default-method-simple.rs @@ -28,7 +28,7 @@ impl A : Foo { } } -fn main() { +pub fn main() { let a = A { x: 1 }; a.f(); } diff --git a/src/test/run-pass/deref-lval.rs b/src/test/run-pass/deref-lval.rs index 5638a905256..ec5cc6293e4 100644 --- a/src/test/run-pass/deref-lval.rs +++ b/src/test/run-pass/deref-lval.rs @@ -10,4 +10,4 @@ -fn main() { let x = @mut 5; *x = 1000; log(debug, *x); } +pub fn main() { let x = @mut 5; *x = 1000; log(debug, *x); } diff --git a/src/test/run-pass/deref.rs b/src/test/run-pass/deref.rs index 31a354bb226..01a7792ce88 100644 --- a/src/test/run-pass/deref.rs +++ b/src/test/run-pass/deref.rs @@ -10,4 +10,4 @@ -fn main() { let x: @int = @10; let y: int = *x; } +pub fn main() { let x: @int = @10; let y: int = *x; } diff --git a/src/test/run-pass/deriving-enum-single-variant.rs b/src/test/run-pass/deriving-enum-single-variant.rs index 40055a61380..7b86a6299f6 100644 --- a/src/test/run-pass/deriving-enum-single-variant.rs +++ b/src/test/run-pass/deriving-enum-single-variant.rs @@ -5,4 +5,4 @@ pub enum Task { TaskHandle(task_id) } -fn main() { } +pub fn main() { } diff --git a/src/test/run-pass/deriving-via-extension-c-enum.rs b/src/test/run-pass/deriving-via-extension-c-enum.rs index 1e7afc80b7d..22c12e7f795 100644 --- a/src/test/run-pass/deriving-via-extension-c-enum.rs +++ b/src/test/run-pass/deriving-via-extension-c-enum.rs @@ -15,7 +15,7 @@ enum Foo { Boo } -fn main() { +pub fn main() { let a = Bar; let b = Bar; assert a == b; diff --git a/src/test/run-pass/deriving-via-extension-enum.rs b/src/test/run-pass/deriving-via-extension-enum.rs index 04d585fe906..22cee722bb3 100644 --- a/src/test/run-pass/deriving-via-extension-enum.rs +++ b/src/test/run-pass/deriving-via-extension-enum.rs @@ -14,7 +14,7 @@ enum Foo { Baz(float, float) } -fn main() { +pub fn main() { let a = Bar(1, 2); let b = Bar(1, 2); assert a == b; diff --git a/src/test/run-pass/deriving-via-extension-iter-bytes-enum.rs b/src/test/run-pass/deriving-via-extension-iter-bytes-enum.rs index 849ad64270d..b41d41192fe 100644 --- a/src/test/run-pass/deriving-via-extension-iter-bytes-enum.rs +++ b/src/test/run-pass/deriving-via-extension-iter-bytes-enum.rs @@ -24,5 +24,5 @@ enum A { E } -fn main(){} +pub fn main(){} diff --git a/src/test/run-pass/deriving-via-extension-iter-bytes-struct.rs b/src/test/run-pass/deriving-via-extension-iter-bytes-struct.rs index 5855b1a530b..18336d74c7e 100644 --- a/src/test/run-pass/deriving-via-extension-iter-bytes-struct.rs +++ b/src/test/run-pass/deriving-via-extension-iter-bytes-struct.rs @@ -17,6 +17,6 @@ struct Foo { z: int } -fn main() {} +pub fn main() {} diff --git a/src/test/run-pass/deriving-via-extension-struct-like-enum-variant.rs b/src/test/run-pass/deriving-via-extension-struct-like-enum-variant.rs index c5e41826a35..e2bb4c446e3 100644 --- a/src/test/run-pass/deriving-via-extension-struct-like-enum-variant.rs +++ b/src/test/run-pass/deriving-via-extension-struct-like-enum-variant.rs @@ -4,7 +4,7 @@ enum S { Y } -fn main() { +pub fn main() { let x = X { x: 1, y: 2 }; assert x == x; assert !(x != x); diff --git a/src/test/run-pass/deriving-via-extension-struct.rs b/src/test/run-pass/deriving-via-extension-struct.rs index 23d7f9bacb1..cdd0f544626 100644 --- a/src/test/run-pass/deriving-via-extension-struct.rs +++ b/src/test/run-pass/deriving-via-extension-struct.rs @@ -15,7 +15,7 @@ struct Foo { z: int, } -fn main() { +pub fn main() { let a = Foo { x: 1, y: 2, z: 3 }; let b = Foo { x: 1, y: 2, z: 3 }; assert a == b; diff --git a/src/test/run-pass/deriving-via-extension-type-params.rs b/src/test/run-pass/deriving-via-extension-type-params.rs index b1b196e6986..5040b08d003 100644 --- a/src/test/run-pass/deriving-via-extension-type-params.rs +++ b/src/test/run-pass/deriving-via-extension-type-params.rs @@ -18,7 +18,7 @@ struct Foo<T> { z: int } -fn main() { +pub fn main() { let a = Foo { x: 1, y: 2.0, z: 3 }; let b = Foo { x: 1, y: 2.0, z: 3 }; assert a == b; diff --git a/src/test/run-pass/die-macro.rs b/src/test/run-pass/die-macro.rs index 59d297473fe..1174cb5df92 100644 --- a/src/test/run-pass/die-macro.rs +++ b/src/test/run-pass/die-macro.rs @@ -6,6 +6,6 @@ fn f() { let x: int = die!(); } -fn main() { +pub fn main() { } diff --git a/src/test/run-pass/div-mod.rs b/src/test/run-pass/div-mod.rs index 8624d063fd6..dfe8c3f9730 100644 --- a/src/test/run-pass/div-mod.rs +++ b/src/test/run-pass/div-mod.rs @@ -12,7 +12,7 @@ // -*- rust -*- -fn main() { +pub fn main() { let x: int = 15; let y: int = 5; assert (x / 5 == 3); diff --git a/src/test/run-pass/do-for-empty-args.rs b/src/test/run-pass/do-for-empty-args.rs index 1ebfb3c39ad..2a7091cb163 100644 --- a/src/test/run-pass/do-for-empty-args.rs +++ b/src/test/run-pass/do-for-empty-args.rs @@ -14,7 +14,7 @@ fn f(f: fn() -> bool) { } -fn main() { +pub fn main() { do f() || { true } do f() { true } do f || { true } diff --git a/src/test/run-pass/do-for-no-args.rs b/src/test/run-pass/do-for-no-args.rs index e61088f8a28..5c5cec1fac1 100644 --- a/src/test/run-pass/do-for-no-args.rs +++ b/src/test/run-pass/do-for-no-args.rs @@ -14,7 +14,7 @@ fn f(f: fn@() -> bool) { } fn d(f: fn@()) { } -fn main() { +pub fn main() { for f { } do d { } } \ No newline at end of file diff --git a/src/test/run-pass/do-pure.rs b/src/test/run-pass/do-pure.rs index 52e8fc0cc7a..5cad9235af8 100644 --- a/src/test/run-pass/do-pure.rs +++ b/src/test/run-pass/do-pure.rs @@ -16,5 +16,5 @@ pure fn g() { do f { } } -fn main() { +pub fn main() { } \ No newline at end of file diff --git a/src/test/run-pass/do-stack.rs b/src/test/run-pass/do-stack.rs index 06d89d1b209..c42a0dc5739 100644 --- a/src/test/run-pass/do-stack.rs +++ b/src/test/run-pass/do-stack.rs @@ -10,6 +10,6 @@ fn f(f: fn&(int)) { f(10) } -fn main() { +pub fn main() { do f() |i| { assert i == 10 } } diff --git a/src/test/run-pass/do1.rs b/src/test/run-pass/do1.rs index 814a19ae282..f6b00ce7881 100644 --- a/src/test/run-pass/do1.rs +++ b/src/test/run-pass/do1.rs @@ -10,6 +10,6 @@ fn f(f: fn@(int)) { f(10) } -fn main() { +pub fn main() { do f() |i| { assert i == 10 } } diff --git a/src/test/run-pass/do2.rs b/src/test/run-pass/do2.rs index 881bfb0506c..1f0d82ec7b5 100644 --- a/src/test/run-pass/do2.rs +++ b/src/test/run-pass/do2.rs @@ -10,6 +10,6 @@ fn f(f: fn@(int) -> int) -> int { f(10) } -fn main() { +pub fn main() { assert do f() |i| { i } == 10; } diff --git a/src/test/run-pass/do3.rs b/src/test/run-pass/do3.rs index 717c553cc47..f7660e35f59 100644 --- a/src/test/run-pass/do3.rs +++ b/src/test/run-pass/do3.rs @@ -10,6 +10,6 @@ fn f(f: fn@(int) -> int) -> int { f(10) } -fn main() { +pub fn main() { assert do f |i| { i } == 10; } diff --git a/src/test/run-pass/double-unbox.rs b/src/test/run-pass/double-unbox.rs index a3415562920..2dc246d6c33 100644 --- a/src/test/run-pass/double-unbox.rs +++ b/src/test/run-pass/double-unbox.rs @@ -13,4 +13,4 @@ type quux = {bar: int}; fn g(i: int) { } fn f(foo: @@quux) { g(foo.bar); } -fn main() { } +pub fn main() { } diff --git a/src/test/run-pass/drop-on-empty-block-exit.rs b/src/test/run-pass/drop-on-empty-block-exit.rs index 4a1d32c4bfc..246306e4c47 100644 --- a/src/test/run-pass/drop-on-empty-block-exit.rs +++ b/src/test/run-pass/drop-on-empty-block-exit.rs @@ -12,4 +12,4 @@ enum t { foo(@int), } -fn main() { let tt = foo(@10); match tt { foo(z) => { } } } +pub fn main() { let tt = foo(@10); match tt { foo(z) => { } } } diff --git a/src/test/run-pass/drop-on-ret.rs b/src/test/run-pass/drop-on-ret.rs index 2f6f862f054..932da027b70 100644 --- a/src/test/run-pass/drop-on-ret.rs +++ b/src/test/run-pass/drop-on-ret.rs @@ -14,4 +14,4 @@ // -*- rust -*- fn f() -> int { if true { let s: ~str = ~"should not leak"; return 1; } return 0; } -fn main() { f(); } +pub fn main() { f(); } diff --git a/src/test/run-pass/drop-trait-generic.rs b/src/test/run-pass/drop-trait-generic.rs index 238f3b8b587..256461b61bd 100644 --- a/src/test/run-pass/drop-trait-generic.rs +++ b/src/test/run-pass/drop-trait-generic.rs @@ -18,7 +18,7 @@ impl<T> S<T> : ::core::ops::Drop { } } -fn main() { +pub fn main() { let x = S { x: 1 }; } diff --git a/src/test/run-pass/drop-trait.rs b/src/test/run-pass/drop-trait.rs index 12b2c5e67ab..084bff63743 100644 --- a/src/test/run-pass/drop-trait.rs +++ b/src/test/run-pass/drop-trait.rs @@ -18,7 +18,7 @@ impl Foo : Drop { } } -fn main() { +pub fn main() { let x: Foo = Foo { x: 3 }; } diff --git a/src/test/run-pass/duplicate-use.rs b/src/test/run-pass/duplicate-use.rs index 45207215789..f81b33105e6 100644 --- a/src/test/run-pass/duplicate-use.rs +++ b/src/test/run-pass/duplicate-use.rs @@ -11,9 +11,9 @@ // xfail-test extern mod std; -use list = std::map::chained; +use list = std::oldmap::chained; use std::list; -fn main() { +pub fn main() { let _x: list::T<int, int> = list::mk(); } diff --git a/src/test/run-pass/dvec-index-op.rs b/src/test/run-pass/dvec-index-op.rs index 797901e9a8d..e061464c7b2 100644 --- a/src/test/run-pass/dvec-index-op.rs +++ b/src/test/run-pass/dvec-index-op.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -fn main() { +pub fn main() { let x = dvec::DVec(); x.push(1); io::println(fmt!("%d", x[0])); diff --git a/src/test/run-pass/dvec-test.rs b/src/test/run-pass/dvec-test.rs index f569e9116e3..a0c6b666554 100644 --- a/src/test/run-pass/dvec-test.rs +++ b/src/test/run-pass/dvec-test.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -fn main() { +pub fn main() { let d = dvec::DVec(); d.push(3); d.push(4); diff --git a/src/test/run-pass/early-ret-binop-add.rs b/src/test/run-pass/early-ret-binop-add.rs index 6f6db719551..97e873e9aff 100644 --- a/src/test/run-pass/early-ret-binop-add.rs +++ b/src/test/run-pass/early-ret-binop-add.rs @@ -9,4 +9,4 @@ // except according to those terms. fn wsucc(n: int) -> int { 0 + { return n + 1 } } -fn main() { } +pub fn main() { } diff --git a/src/test/run-pass/early-vtbl-resolution.rs b/src/test/run-pass/early-vtbl-resolution.rs index 2e647d25c74..d71edb66098 100644 --- a/src/test/run-pass/early-vtbl-resolution.rs +++ b/src/test/run-pass/early-vtbl-resolution.rs @@ -19,7 +19,7 @@ fn foo_func<A, B: thing<A>>(x: B) -> Option<A> { x.foo() } struct A { a: int } -fn main() { +pub fn main() { for iter::eachi(&(Some(A {a: 0}))) |i, a| { debug!("%u %d", i, a.a); diff --git a/src/test/run-pass/else-if.rs b/src/test/run-pass/else-if.rs index 10aebc8c6a8..6fc2b7d2a1b 100644 --- a/src/test/run-pass/else-if.rs +++ b/src/test/run-pass/else-if.rs @@ -10,7 +10,7 @@ -fn main() { +pub fn main() { if 1 == 2 { assert (false); } else if 2 == 3 { diff --git a/src/test/run-pass/empty-mutable-vec.rs b/src/test/run-pass/empty-mutable-vec.rs index 71271e874da..d7e649a8fb6 100644 --- a/src/test/run-pass/empty-mutable-vec.rs +++ b/src/test/run-pass/empty-mutable-vec.rs @@ -10,4 +10,4 @@ -fn main() { let v: ~[mut int] = ~[mut]; } +pub fn main() { let mut v: ~[int] = ~[]; } diff --git a/src/test/run-pass/empty-tag.rs b/src/test/run-pass/empty-tag.rs index fb72a53d5a6..0dd6c2773ce 100644 --- a/src/test/run-pass/empty-tag.rs +++ b/src/test/run-pass/empty-tag.rs @@ -21,7 +21,7 @@ fn wrapper3(i: chan) { assert i == chan_t; } -fn main() { +pub fn main() { let wrapped = {||wrapper3(chan_t)}; wrapped(); } diff --git a/src/test/run-pass/enum-disr-val-pretty.rs b/src/test/run-pass/enum-disr-val-pretty.rs index dfabda56ea2..19045500cf2 100644 --- a/src/test/run-pass/enum-disr-val-pretty.rs +++ b/src/test/run-pass/enum-disr-val-pretty.rs @@ -12,7 +12,7 @@ enum color { red = 1, green, blue, imaginary = -1, } -fn main() { +pub fn main() { test_color(red, 1, ~"red"); test_color(green, 2, ~"green"); test_color(blue, 3, ~"blue"); diff --git a/src/test/run-pass/enum-export-inheritance.rs b/src/test/run-pass/enum-export-inheritance.rs index b54e7be1fef..c3beebdb8ae 100644 --- a/src/test/run-pass/enum-export-inheritance.rs +++ b/src/test/run-pass/enum-export-inheritance.rs @@ -16,7 +16,7 @@ mod a { } } -fn main() { +pub fn main() { let x = a::Bar; } diff --git a/src/test/run-pass/enum-variants.rs b/src/test/run-pass/enum-variants.rs index 26fae68e158..a8a0a72dd3c 100644 --- a/src/test/run-pass/enum-variants.rs +++ b/src/test/run-pass/enum-variants.rs @@ -3,7 +3,7 @@ enum Animal { Cat { name: ~str, weight: float } } -fn main() { +pub fn main() { let mut a: Animal = Dog(~"Cocoa", 37.2); a = Cat{ name: ~"Spotty", weight: 2.7 }; // permuting the fields should work too diff --git a/src/test/run-pass/estr-shared.rs b/src/test/run-pass/estr-shared.rs index 241a416cf74..5668c18e95b 100644 --- a/src/test/run-pass/estr-shared.rs +++ b/src/test/run-pass/estr-shared.rs @@ -9,6 +9,6 @@ // except according to those terms. // xfail-test -fn main() { +pub fn main() { let x : @str = @"hello"; } diff --git a/src/test/run-pass/estr-slice.rs b/src/test/run-pass/estr-slice.rs index 82bd613be66..ca6928556fa 100644 --- a/src/test/run-pass/estr-slice.rs +++ b/src/test/run-pass/estr-slice.rs @@ -9,7 +9,7 @@ // except according to those terms. -fn main() { +pub fn main() { let x = &"hello"; let v = &"hello"; let mut y : &str = &"there"; diff --git a/src/test/run-pass/estr-uniq.rs b/src/test/run-pass/estr-uniq.rs index 4e0803e0a83..c6b8cc9fab9 100644 --- a/src/test/run-pass/estr-uniq.rs +++ b/src/test/run-pass/estr-uniq.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -fn main() { +pub fn main() { let x : ~str = ~"hello"; let _y : ~str = ~"there"; let mut z = ~"thing"; diff --git a/src/test/run-pass/evec-internal-boxes.rs b/src/test/run-pass/evec-internal-boxes.rs index 8d4a9b7c0d2..5357bcc6ab0 100644 --- a/src/test/run-pass/evec-internal-boxes.rs +++ b/src/test/run-pass/evec-internal-boxes.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -fn main() { +pub fn main() { let x : [@int * 5] = [@1,@2,@3,@4,@5]; let _y : [@int * 5] = [@1,@2,@3,@4,@5]; let mut z = [@1,@2,@3,@4,@5]; diff --git a/src/test/run-pass/evec-internal.rs b/src/test/run-pass/evec-internal.rs index 64d12f548f9..a97eacfee88 100644 --- a/src/test/run-pass/evec-internal.rs +++ b/src/test/run-pass/evec-internal.rs @@ -13,7 +13,7 @@ // Doesn't work; needs a design decision. -fn main() { +pub fn main() { let x : [int * 5] = [1,2,3,4,5]; let _y : [int * 5] = [1,2,3,4,5]; let mut z = [1,2,3,4,5]; diff --git a/src/test/run-pass/evec-slice.rs b/src/test/run-pass/evec-slice.rs index eef47ca29ca..e8e4f64a9cd 100644 --- a/src/test/run-pass/evec-slice.rs +++ b/src/test/run-pass/evec-slice.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -fn main() { +pub fn main() { let x : &[int] = &[1,2,3,4,5]; let mut z = &[1,2,3,4,5]; z = x; diff --git a/src/test/run-pass/exec-env.rs b/src/test/run-pass/exec-env.rs index 263913c0a32..67cc820ac5d 100644 --- a/src/test/run-pass/exec-env.rs +++ b/src/test/run-pass/exec-env.rs @@ -11,6 +11,6 @@ // xfail-fast (exec-env not supported in fast mode) // exec-env:TEST_EXEC_ENV=22 -fn main() { +pub fn main() { assert os::getenv(~"TEST_EXEC_ENV") == Some(~"22"); } diff --git a/src/test/run-pass/explicit-i-suffix.rs b/src/test/run-pass/explicit-i-suffix.rs index fa5ff20bcf8..45cfee76fb8 100644 --- a/src/test/run-pass/explicit-i-suffix.rs +++ b/src/test/run-pass/explicit-i-suffix.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -fn main() { +pub fn main() { let x: int = 8i; let y = 9i; x + y; diff --git a/src/test/run-pass/explicit-self-closures.rs b/src/test/run-pass/explicit-self-closures.rs index 9743fbc79da..4c12b6ad47c 100644 --- a/src/test/run-pass/explicit-self-closures.rs +++ b/src/test/run-pass/explicit-self-closures.rs @@ -26,4 +26,4 @@ impl Box { } } -fn main() {} +pub fn main() {} diff --git a/src/test/run-pass/explicit-self-generic.rs b/src/test/run-pass/explicit-self-generic.rs index bb57710969f..d03893367b4 100644 --- a/src/test/run-pass/explicit-self-generic.rs +++ b/src/test/run-pass/explicit-self-generic.rs @@ -36,7 +36,7 @@ impl<K,V> LinearMap<K,V> { } } -fn main() { +pub fn main() { let mut m = ~linear_map::<(),()>(); assert m.len() == 0; } diff --git a/src/test/run-pass/explicit-self-objects-box.rs b/src/test/run-pass/explicit-self-objects-box.rs index a92a70934f9..8d081c16830 100644 --- a/src/test/run-pass/explicit-self-objects-box.rs +++ b/src/test/run-pass/explicit-self-objects-box.rs @@ -22,7 +22,7 @@ impl S : Foo { } } -fn main() { +pub fn main() { let x = @S { x: 3 }; let y = x as @Foo; y.f(); diff --git a/src/test/run-pass/explicit-self-objects-ext-1.rs b/src/test/run-pass/explicit-self-objects-ext-1.rs index 52a880eb103..f6a6ae5ed49 100644 --- a/src/test/run-pass/explicit-self-objects-ext-1.rs +++ b/src/test/run-pass/explicit-self-objects-ext-1.rs @@ -4,7 +4,7 @@ pub trait Reader { /// Read up to len bytes (or EOF) and put them into bytes (which /// must be at least len bytes long). Return number of bytes read. // FIXME (#2982): This should probably return an error. - fn read(&self, bytes: &[mut u8], len: uint) -> uint; + fn read(&self, bytes: &mut [u8], len: uint) -> uint; } pub trait ReaderUtil { @@ -16,7 +16,7 @@ pub trait ReaderUtil { impl<T: Reader> T : ReaderUtil { fn read_bytes(&self, len: uint) { - let count = self.read(&[mut 0], len); + let mut count = self.read(&mut [0], len); } } @@ -27,12 +27,12 @@ struct S { } impl S: Reader { - fn read(&self, bytes: &[mut u8], len: uint) -> uint { + fn read(&self, bytes: &mut [u8], len: uint) -> uint { 0 } } -fn main() { +pub fn main() { let x = S { x: 1, y: 2 }; let x = x as @Reader; x.read_bytes(0); diff --git a/src/test/run-pass/explicit-self-objects-ext-2.rs b/src/test/run-pass/explicit-self-objects-ext-2.rs index 52a880eb103..f6a6ae5ed49 100644 --- a/src/test/run-pass/explicit-self-objects-ext-2.rs +++ b/src/test/run-pass/explicit-self-objects-ext-2.rs @@ -4,7 +4,7 @@ pub trait Reader { /// Read up to len bytes (or EOF) and put them into bytes (which /// must be at least len bytes long). Return number of bytes read. // FIXME (#2982): This should probably return an error. - fn read(&self, bytes: &[mut u8], len: uint) -> uint; + fn read(&self, bytes: &mut [u8], len: uint) -> uint; } pub trait ReaderUtil { @@ -16,7 +16,7 @@ pub trait ReaderUtil { impl<T: Reader> T : ReaderUtil { fn read_bytes(&self, len: uint) { - let count = self.read(&[mut 0], len); + let mut count = self.read(&mut [0], len); } } @@ -27,12 +27,12 @@ struct S { } impl S: Reader { - fn read(&self, bytes: &[mut u8], len: uint) -> uint { + fn read(&self, bytes: &mut [u8], len: uint) -> uint { 0 } } -fn main() { +pub fn main() { let x = S { x: 1, y: 2 }; let x = x as @Reader; x.read_bytes(0); diff --git a/src/test/run-pass/explicit-self-objects-ext-3.rs b/src/test/run-pass/explicit-self-objects-ext-3.rs index 521d5a75701..1804c24708b 100644 --- a/src/test/run-pass/explicit-self-objects-ext-3.rs +++ b/src/test/run-pass/explicit-self-objects-ext-3.rs @@ -4,7 +4,7 @@ pub trait Reader { /// Read up to len bytes (or EOF) and put them into bytes (which /// must be at least len bytes long). Return number of bytes read. // FIXME (#2982): This should probably return an error. - fn read(&self, bytes: &[mut u8], len: uint) -> uint; + fn read(&self, bytes: &mut [u8], len: uint) -> uint; } pub trait ReaderUtil { @@ -16,7 +16,7 @@ pub trait ReaderUtil { impl<T: Reader> T : ReaderUtil { fn read_bytes(len: uint) { - let count = self.read(&[mut 0], len); + let mut count = self.read(&mut [0], len); } } @@ -27,12 +27,12 @@ struct S { } impl S: Reader { - fn read(&self, bytes: &[mut u8], len: uint) -> uint { + fn read(&self, bytes: &mut [u8], len: uint) -> uint { 0 } } -fn main() { +pub fn main() { let x = S { x: 1, y: 2 }; let x = x as @Reader; x.read_bytes(0); diff --git a/src/test/run-pass/explicit-self-objects-ext-4.rs b/src/test/run-pass/explicit-self-objects-ext-4.rs index 759097a771b..b4601314612 100644 --- a/src/test/run-pass/explicit-self-objects-ext-4.rs +++ b/src/test/run-pass/explicit-self-objects-ext-4.rs @@ -4,7 +4,7 @@ pub trait Reader { /// Read up to len bytes (or EOF) and put them into bytes (which /// must be at least len bytes long). Return number of bytes read. // FIXME (#2982): This should probably return an error. - fn read(bytes: &[mut u8], len: uint) -> uint; + fn read(bytes: &mut [u8], len: uint) -> uint; } pub trait ReaderUtil { @@ -16,7 +16,7 @@ pub trait ReaderUtil { impl<T: Reader> T : ReaderUtil { fn read_bytes(len: uint) { - let count = self.read(&[mut 0], len); + let mut count = self.read(&mut [0], len); } } @@ -27,12 +27,12 @@ struct S { } impl S: Reader { - fn read(bytes: &[mut u8], len: uint) -> uint { + fn read(bytes: &mut [u8], len: uint) -> uint { 0 } } -fn main() { +pub fn main() { let x = S { x: 1, y: 2 }; let x = x as @Reader; x.read_bytes(0); diff --git a/src/test/run-pass/explicit-self-objects-simple.rs b/src/test/run-pass/explicit-self-objects-simple.rs index 51c2a9ad53d..79d5d7791f4 100644 --- a/src/test/run-pass/explicit-self-objects-simple.rs +++ b/src/test/run-pass/explicit-self-objects-simple.rs @@ -22,7 +22,7 @@ impl S : Foo { } } -fn main() { +pub fn main() { let x = @S { x: 3 }; let y = x as @Foo; y.f(); diff --git a/src/test/run-pass/explicit-self-objects-uniq.rs b/src/test/run-pass/explicit-self-objects-uniq.rs index 49979559644..bf1776e598e 100644 --- a/src/test/run-pass/explicit-self-objects-uniq.rs +++ b/src/test/run-pass/explicit-self-objects-uniq.rs @@ -22,7 +22,7 @@ impl S : Foo { } } -fn main() { +pub fn main() { let x = ~S { x: 3 }; let y = x as ~Foo; y.f(); diff --git a/src/test/run-pass/explicit-self.rs b/src/test/run-pass/explicit-self.rs index b4a80906b33..ebffa131fb6 100644 --- a/src/test/run-pass/explicit-self.rs +++ b/src/test/run-pass/explicit-self.rs @@ -65,7 +65,7 @@ impl thing { trait Nus { fn f(&self); } impl thing: Nus { fn f(&self) {} } -fn main() { +pub fn main() { let x = @thing(A {mut a: @10}); assert x.foo() == 10; diff --git a/src/test/run-pass/explicit_self_xcrate_exe.rs b/src/test/run-pass/explicit_self_xcrate_exe.rs index f38774934d0..e217e6ebd41 100644 --- a/src/test/run-pass/explicit_self_xcrate_exe.rs +++ b/src/test/run-pass/explicit_self_xcrate_exe.rs @@ -14,7 +14,7 @@ extern mod explicit_self_xcrate; use explicit_self_xcrate::{Foo, Bar}; -fn main() { +pub fn main() { let x = Bar { x: ~"hello" }; x.f(); } diff --git a/src/test/run-pass/export-abstract-tag.rs b/src/test/run-pass/export-abstract-tag.rs index cc7793fdf28..209dbb3741a 100644 --- a/src/test/run-pass/export-abstract-tag.rs +++ b/src/test/run-pass/export-abstract-tag.rs @@ -17,4 +17,4 @@ mod foo { pub fn f() -> t { return t1; } } -fn main() { let v: foo::t = foo::f(); } +pub fn main() { let v: foo::t = foo::f(); } diff --git a/src/test/run-pass/export-glob-imports-target.rs b/src/test/run-pass/export-glob-imports-target.rs index 33a54b85ea8..ae17d6ca8b3 100644 --- a/src/test/run-pass/export-glob-imports-target.rs +++ b/src/test/run-pass/export-glob-imports-target.rs @@ -25,4 +25,4 @@ mod foo { } } -fn main() { } +pub fn main() { } diff --git a/src/test/run-pass/export-multi.rs b/src/test/run-pass/export-multi.rs index d19f7c0d31c..396e4e6b250 100644 --- a/src/test/run-pass/export-multi.rs +++ b/src/test/run-pass/export-multi.rs @@ -18,4 +18,4 @@ mod m { pub fn g() { } } -fn main() { f(); g(); m::f(); m::g(); } +pub fn main() { f(); g(); m::f(); m::g(); } diff --git a/src/test/run-pass/export-non-interference2.rs b/src/test/run-pass/export-non-interference2.rs index dae4e15fee0..9889b559bca 100644 --- a/src/test/run-pass/export-non-interference2.rs +++ b/src/test/run-pass/export-non-interference2.rs @@ -16,4 +16,4 @@ mod foo { pub fn x() { debug!("x"); } } -fn main() { self::foo::bar::y(); } +pub fn main() { self::foo::bar::y(); } diff --git a/src/test/run-pass/export-non-interference3.rs b/src/test/run-pass/export-non-interference3.rs index 5f8a74203e4..36c9fe6cf42 100644 --- a/src/test/run-pass/export-non-interference3.rs +++ b/src/test/run-pass/export-non-interference3.rs @@ -18,4 +18,4 @@ pub mod bar { pub fn x() { debug!("x"); } } -fn main() { foo::x(); } +pub fn main() { foo::x(); } diff --git a/src/test/run-pass/export-tag-variant.rs b/src/test/run-pass/export-tag-variant.rs index 06b513c4ad9..47ac4bd4a9a 100644 --- a/src/test/run-pass/export-tag-variant.rs +++ b/src/test/run-pass/export-tag-variant.rs @@ -12,4 +12,4 @@ mod foo { pub enum t { t1, } } -fn main() { let v = foo::t1; } +pub fn main() { let v = foo::t1; } diff --git a/src/test/run-pass/export-unexported-dep.rs b/src/test/run-pass/export-unexported-dep.rs index 1119bfde2fc..16f24674226 100644 --- a/src/test/run-pass/export-unexported-dep.rs +++ b/src/test/run-pass/export-unexported-dep.rs @@ -27,4 +27,4 @@ mod foo { pub fn g(v: t) { assert (v == t1); } } -fn main() { foo::g(foo::f()); } +pub fn main() { foo::g(foo::f()); } diff --git a/src/test/run-pass/expr-alt-box.rs b/src/test/run-pass/expr-alt-box.rs index 581614d49af..fd1a5ad4969 100644 --- a/src/test/run-pass/expr-alt-box.rs +++ b/src/test/run-pass/expr-alt-box.rs @@ -15,14 +15,14 @@ // Tests for match as expressions resulting in boxed types fn test_box() { - let res = match true { true => { @100 } _ => fail ~"wat" }; + let res = match true { true => { @100 } _ => die!(~"wat") }; assert (*res == 100); } fn test_str() { let res = match true { true => { ~"happy" }, - _ => fail ~"not happy at all" }; + _ => die!(~"not happy at all") }; assert (res == ~"happy"); } -fn main() { test_box(); test_str(); } +pub fn main() { test_box(); test_str(); } diff --git a/src/test/run-pass/expr-alt-fail-all.rs b/src/test/run-pass/expr-alt-fail-all.rs index aaaa68a6078..e806907129f 100644 --- a/src/test/run-pass/expr-alt-fail-all.rs +++ b/src/test/run-pass/expr-alt-fail-all.rs @@ -13,10 +13,10 @@ // When all branches of an match expression result in fail, the entire // match expression results in fail. -fn main() { +pub fn main() { let x = match true { true => { 10 } - false => { match true { true => { fail } false => { fail } } } + false => { match true { true => { die!() } false => { die!() } } } }; } diff --git a/src/test/run-pass/expr-alt-fail.rs b/src/test/run-pass/expr-alt-fail.rs index b180dd66690..f26f1f1e6f7 100644 --- a/src/test/run-pass/expr-alt-fail.rs +++ b/src/test/run-pass/expr-alt-fail.rs @@ -9,13 +9,13 @@ // except according to those terms. fn test_simple() { - let r = match true { true => { true } false => { fail } }; + let r = match true { true => { true } false => { die!() } }; assert (r == true); } fn test_box() { - let r = match true { true => { ~[10] } false => { fail } }; + let r = match true { true => { ~[10] } false => { die!() } }; assert (r[0] == 10); } -fn main() { test_simple(); test_box(); } +pub fn main() { test_simple(); test_box(); } diff --git a/src/test/run-pass/expr-alt-generic-box1.rs b/src/test/run-pass/expr-alt-generic-box1.rs index 3609de3c1cc..ecb2bf91702 100644 --- a/src/test/run-pass/expr-alt-generic-box1.rs +++ b/src/test/run-pass/expr-alt-generic-box1.rs @@ -15,7 +15,7 @@ type compare<T> = fn@(@T, @T) -> bool; fn test_generic<T>(expected: @T, eq: compare<T>) { - let actual: @T = match true { true => { expected }, _ => fail }; + let actual: @T = match true { true => { expected }, _ => die!() }; assert (eq(expected, actual)); } @@ -24,4 +24,4 @@ fn test_box() { test_generic::<bool>(@true, compare_box); } -fn main() { test_box(); } +pub fn main() { test_box(); } diff --git a/src/test/run-pass/expr-alt-generic-box2.rs b/src/test/run-pass/expr-alt-generic-box2.rs index 012b090601f..6962f4b5e0f 100644 --- a/src/test/run-pass/expr-alt-generic-box2.rs +++ b/src/test/run-pass/expr-alt-generic-box2.rs @@ -16,7 +16,7 @@ type compare<T> = fn@(T, T) -> bool; fn test_generic<T: Copy>(expected: T, eq: compare<T>) { - let actual: T = match true { true => { expected }, _ => fail ~"wat" }; + let actual: T = match true { true => { expected }, _ => die!(~"wat") }; assert (eq(expected, actual)); } @@ -25,4 +25,4 @@ fn test_vec() { test_generic::<@int>(@1, compare_box); } -fn main() { test_vec(); } +pub fn main() { test_vec(); } diff --git a/src/test/run-pass/expr-alt-generic-unique1.rs b/src/test/run-pass/expr-alt-generic-unique1.rs index 06812e00205..b0a5af1cd53 100644 --- a/src/test/run-pass/expr-alt-generic-unique1.rs +++ b/src/test/run-pass/expr-alt-generic-unique1.rs @@ -16,7 +16,7 @@ type compare<T> = fn@(~T, ~T) -> bool; fn test_generic<T: Copy>(expected: ~T, eq: compare<T>) { let actual: ~T = match true { true => { copy expected }, - _ => fail ~"wat" + _ => die!(~"wat") }; assert (eq(expected, actual)); } @@ -26,4 +26,4 @@ fn test_box() { test_generic::<bool>(~true, compare_box); } -fn main() { test_box(); } +pub fn main() { test_box(); } diff --git a/src/test/run-pass/expr-alt-generic-unique2.rs b/src/test/run-pass/expr-alt-generic-unique2.rs index eb611b4bd05..02bc248fc4f 100644 --- a/src/test/run-pass/expr-alt-generic-unique2.rs +++ b/src/test/run-pass/expr-alt-generic-unique2.rs @@ -18,7 +18,7 @@ type compare<T> = fn@(T, T) -> bool; fn test_generic<T: Copy>(expected: T, eq: compare<T>) { let actual: T = match true { true => copy expected, - _ => fail ~"wat" + _ => die!(~"wat") }; assert (eq(expected, actual)); } @@ -28,4 +28,4 @@ fn test_vec() { test_generic::<~int>(~1, compare_box); } -fn main() { test_vec(); } +pub fn main() { test_vec(); } diff --git a/src/test/run-pass/expr-alt-generic.rs b/src/test/run-pass/expr-alt-generic.rs index 61e92500cc8..a3281ba57f1 100644 --- a/src/test/run-pass/expr-alt-generic.rs +++ b/src/test/run-pass/expr-alt-generic.rs @@ -15,7 +15,7 @@ type compare<T> = fn@(T, T) -> bool; fn test_generic<T: Copy>(expected: T, eq: compare<T>) { - let actual: T = match true { true => { expected }, _ => fail ~"wat" }; + let actual: T = match true { true => { expected }, _ => die!(~"wat") }; assert (eq(expected, actual)); } @@ -33,4 +33,4 @@ fn test_rec() { test_generic::<Pair>(Pair {a: 1, b: 2}, compare_rec); } -fn main() { test_bool(); test_rec(); } +pub fn main() { test_bool(); test_rec(); } diff --git a/src/test/run-pass/expr-alt-struct.rs b/src/test/run-pass/expr-alt-struct.rs index 1cc9d4ba684..bcf07586f24 100644 --- a/src/test/run-pass/expr-alt-struct.rs +++ b/src/test/run-pass/expr-alt-struct.rs @@ -17,7 +17,7 @@ struct R { i: int } fn test_rec() { - let rs = match true { true => R {i: 100}, _ => fail }; + let rs = match true { true => R {i: 100}, _ => die!() }; assert (rs.i == 100); } @@ -35,4 +35,4 @@ fn test_tag() { assert (rs == happy); } -fn main() { test_rec(); test_tag(); } +pub fn main() { test_rec(); test_tag(); } diff --git a/src/test/run-pass/expr-alt-unique.rs b/src/test/run-pass/expr-alt-unique.rs index 43b926ee6e3..1ce8e2d7624 100644 --- a/src/test/run-pass/expr-alt-unique.rs +++ b/src/test/run-pass/expr-alt-unique.rs @@ -15,8 +15,8 @@ // Tests for match as expressions resulting in boxed types fn test_box() { - let res = match true { true => { ~100 }, _ => fail }; + let res = match true { true => { ~100 }, _ => die!() }; assert (*res == 100); } -fn main() { test_box(); } +pub fn main() { test_box(); } diff --git a/src/test/run-pass/expr-alt.rs b/src/test/run-pass/expr-alt.rs index 24ba6f622b0..c10f922e880 100644 --- a/src/test/run-pass/expr-alt.rs +++ b/src/test/run-pass/expr-alt.rs @@ -46,7 +46,7 @@ fn test_alt_as_block_result() { assert (rs); } -fn main() { +pub fn main() { test_basic(); test_inferrence(); test_alt_as_alt_head(); diff --git a/src/test/run-pass/expr-block-box.rs b/src/test/run-pass/expr-block-box.rs index 075020a10b8..f1fa9d8e2d5 100644 --- a/src/test/run-pass/expr-block-box.rs +++ b/src/test/run-pass/expr-block-box.rs @@ -12,4 +12,4 @@ // -*- rust -*- -fn main() { let x = { @100 }; assert (*x == 100); } +pub fn main() { let x = { @100 }; assert (*x == 100); } diff --git a/src/test/run-pass/expr-block-fn.rs b/src/test/run-pass/expr-block-fn.rs index d24273991b3..fd69a702f1b 100644 --- a/src/test/run-pass/expr-block-fn.rs +++ b/src/test/run-pass/expr-block-fn.rs @@ -17,4 +17,4 @@ fn test_fn() { //assert (rs() == 10); } -fn main() { test_fn(); } +pub fn main() { test_fn(); } diff --git a/src/test/run-pass/expr-block-generic-box1.rs b/src/test/run-pass/expr-block-generic-box1.rs index 81936c1fbd1..440a25b59cd 100644 --- a/src/test/run-pass/expr-block-generic-box1.rs +++ b/src/test/run-pass/expr-block-generic-box1.rs @@ -28,4 +28,4 @@ fn test_box() { test_generic::<bool>(@true, compare_box); } -fn main() { test_box(); } +pub fn main() { test_box(); } diff --git a/src/test/run-pass/expr-block-generic-box2.rs b/src/test/run-pass/expr-block-generic-box2.rs index 66edbdab8e6..94627082eb4 100644 --- a/src/test/run-pass/expr-block-generic-box2.rs +++ b/src/test/run-pass/expr-block-generic-box2.rs @@ -24,4 +24,4 @@ fn test_vec() { test_generic::<@int>(@1, compare_vec); } -fn main() { test_vec(); } +pub fn main() { test_vec(); } diff --git a/src/test/run-pass/expr-block-generic-unique1.rs b/src/test/run-pass/expr-block-generic-unique1.rs index d95e7fe1c0e..b3637f80535 100644 --- a/src/test/run-pass/expr-block-generic-unique1.rs +++ b/src/test/run-pass/expr-block-generic-unique1.rs @@ -27,4 +27,4 @@ fn test_box() { test_generic::<bool>(~true, compare_box); } -fn main() { test_box(); } +pub fn main() { test_box(); } diff --git a/src/test/run-pass/expr-block-generic-unique2.rs b/src/test/run-pass/expr-block-generic-unique2.rs index 210b4c5afb1..39585f7cc67 100644 --- a/src/test/run-pass/expr-block-generic-unique2.rs +++ b/src/test/run-pass/expr-block-generic-unique2.rs @@ -24,4 +24,4 @@ fn test_vec() { test_generic::<~int>(~1, compare_vec); } -fn main() { test_vec(); } +pub fn main() { test_vec(); } diff --git a/src/test/run-pass/expr-block-generic.rs b/src/test/run-pass/expr-block-generic.rs index 6cfc06307c4..dca3030df14 100644 --- a/src/test/run-pass/expr-block-generic.rs +++ b/src/test/run-pass/expr-block-generic.rs @@ -35,4 +35,4 @@ fn test_rec() { test_generic::<Pair>(Pair {a: 1, b: 2}, compare_rec); } -fn main() { test_bool(); test_rec(); } +pub fn main() { test_bool(); test_rec(); } diff --git a/src/test/run-pass/expr-block-ref.rs b/src/test/run-pass/expr-block-ref.rs index c70faf935ba..8b10bd7c51c 100644 --- a/src/test/run-pass/expr-block-ref.rs +++ b/src/test/run-pass/expr-block-ref.rs @@ -9,4 +9,4 @@ // except according to those terms. // Regression test for issue #388 -fn main() { let x = { { @10 } }; } +pub fn main() { let x = { { @10 } }; } diff --git a/src/test/run-pass/expr-block-slot.rs b/src/test/run-pass/expr-block-slot.rs index 8c173ae5d76..1e3a91ae2ce 100644 --- a/src/test/run-pass/expr-block-slot.rs +++ b/src/test/run-pass/expr-block-slot.rs @@ -13,7 +13,7 @@ struct A { a: int } struct V { v: int } -fn main() { +pub fn main() { let a = { let b = A {a: 3}; b }; assert (a.a == 3); let c = { let d = V {v: 3}; d }; diff --git a/src/test/run-pass/expr-block-unique.rs b/src/test/run-pass/expr-block-unique.rs index e9c971e5435..f6b31ee3733 100644 --- a/src/test/run-pass/expr-block-unique.rs +++ b/src/test/run-pass/expr-block-unique.rs @@ -12,4 +12,4 @@ // -*- rust -*- -fn main() { let x = { ~100 }; assert (*x == 100); } +pub fn main() { let x = { ~100 }; assert (*x == 100); } diff --git a/src/test/run-pass/expr-block.rs b/src/test/run-pass/expr-block.rs index 490f3950f9f..fb3d3efd650 100644 --- a/src/test/run-pass/expr-block.rs +++ b/src/test/run-pass/expr-block.rs @@ -25,4 +25,4 @@ fn test_filled_with_stuff() { assert (rs == 10); } -fn main() { test_basic(); test_rec(); test_filled_with_stuff(); } +pub fn main() { test_basic(); test_rec(); test_filled_with_stuff(); } diff --git a/src/test/run-pass/expr-copy.rs b/src/test/run-pass/expr-copy.rs index 69dcac9f03a..56cc5204b0a 100644 --- a/src/test/run-pass/expr-copy.rs +++ b/src/test/run-pass/expr-copy.rs @@ -17,7 +17,7 @@ fn f(arg: A) { struct A { mut a: int } -fn main() { +pub fn main() { let x = A {a: 10}; f(x); assert x.a == 100; diff --git a/src/test/run-pass/expr-elseif-ref.rs b/src/test/run-pass/expr-elseif-ref.rs index a1973334e47..ffcfe6448bc 100644 --- a/src/test/run-pass/expr-elseif-ref.rs +++ b/src/test/run-pass/expr-elseif-ref.rs @@ -10,7 +10,7 @@ // Make sure we drop the refs of the temporaries needed to return the // values from the else if branch -fn main() { +pub fn main() { let y: @uint = @10u; let x = if false { y } else if true { y } else { y }; assert (*y == 10u); diff --git a/src/test/run-pass/expr-elseif-ref2.rs b/src/test/run-pass/expr-elseif-ref2.rs index 8f593bf4acf..2832e4a760c 100644 --- a/src/test/run-pass/expr-elseif-ref2.rs +++ b/src/test/run-pass/expr-elseif-ref2.rs @@ -9,4 +9,4 @@ // except according to those terms. // Regression test for issue #388 -fn main() { let x = if false { @0u } else if true { @10u } else { @0u }; } +pub fn main() { let x = if false { @0u } else if true { @10u } else { @0u }; } diff --git a/src/test/run-pass/expr-empty-ret.rs b/src/test/run-pass/expr-empty-ret.rs index 5366499a25a..fa84e81f775 100644 --- a/src/test/run-pass/expr-empty-ret.rs +++ b/src/test/run-pass/expr-empty-ret.rs @@ -12,4 +12,4 @@ fn f() { let x = match true { true => { 10 } false => { return } }; } -fn main() { } +pub fn main() { } diff --git a/src/test/run-pass/expr-fn.rs b/src/test/run-pass/expr-fn.rs index 6f6c48c7994..727524f5677 100644 --- a/src/test/run-pass/expr-fn.rs +++ b/src/test/run-pass/expr-fn.rs @@ -55,7 +55,7 @@ fn test_372() { fn test_nil() { () } -fn main() { +pub fn main() { test_int(); test_vec(); test_generic(); diff --git a/src/test/run-pass/expr-if-box.rs b/src/test/run-pass/expr-if-box.rs index e1b4c9c1033..7ca8c8f88c8 100644 --- a/src/test/run-pass/expr-if-box.rs +++ b/src/test/run-pass/expr-if-box.rs @@ -24,4 +24,4 @@ fn test_str() { assert (rs == ~"happy"); } -fn main() { test_box(); test_str(); } +pub fn main() { test_box(); test_str(); } diff --git a/src/test/run-pass/expr-if-fail-all.rs b/src/test/run-pass/expr-if-fail-all.rs index 855f14bf55b..a4c5799f445 100644 --- a/src/test/run-pass/expr-if-fail-all.rs +++ b/src/test/run-pass/expr-if-fail-all.rs @@ -10,4 +10,4 @@ // When all branches of an if expression result in fail, the entire if // expression results in fail. -fn main() { let x = if true { 10 } else { if true { fail } else { fail } }; } +pub fn main() { let x = if true { 10 } else { if true { die!() } else { die!() } }; } diff --git a/src/test/run-pass/expr-if-fail.rs b/src/test/run-pass/expr-if-fail.rs index da2d316810e..698db97407c 100644 --- a/src/test/run-pass/expr-if-fail.rs +++ b/src/test/run-pass/expr-if-fail.rs @@ -8,16 +8,16 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -fn test_if_fail() { let x = if false { fail } else { 10 }; assert (x == 10); } +fn test_if_fail() { let x = if false { die!() } else { 10 }; assert (x == 10); } fn test_else_fail() { - let x = if true { 10 } else { fail }; + let x = if true { 10 } else { die!() }; assert (x == 10); } fn test_elseif_fail() { - let x = if false { 0 } else if false { fail } else { 10 }; + let x = if false { 0 } else if false { die!() } else { 10 }; assert (x == 10); } -fn main() { test_if_fail(); test_else_fail(); test_elseif_fail(); } +pub fn main() { test_if_fail(); test_else_fail(); test_elseif_fail(); } diff --git a/src/test/run-pass/expr-if-generic-box1.rs b/src/test/run-pass/expr-if-generic-box1.rs index 99c63f3e6dc..16677886d09 100644 --- a/src/test/run-pass/expr-if-generic-box1.rs +++ b/src/test/run-pass/expr-if-generic-box1.rs @@ -24,4 +24,4 @@ fn test_box() { test_generic::<bool>(@true, @false, compare_box); } -fn main() { test_box(); } +pub fn main() { test_box(); } diff --git a/src/test/run-pass/expr-if-generic-box2.rs b/src/test/run-pass/expr-if-generic-box2.rs index bb382d13833..c1bd2589301 100644 --- a/src/test/run-pass/expr-if-generic-box2.rs +++ b/src/test/run-pass/expr-if-generic-box2.rs @@ -24,4 +24,4 @@ fn test_vec() { test_generic::<@int>(@1, @2, compare_box); } -fn main() { test_vec(); } +pub fn main() { test_vec(); } diff --git a/src/test/run-pass/expr-if-generic.rs b/src/test/run-pass/expr-if-generic.rs index 92f9117dde8..537f6039af8 100644 --- a/src/test/run-pass/expr-if-generic.rs +++ b/src/test/run-pass/expr-if-generic.rs @@ -34,4 +34,4 @@ fn test_rec() { test_generic::<Pair>(Pair{a: 1, b: 2}, Pair{a: 2, b: 3}, compare_rec); } -fn main() { test_bool(); test_rec(); } +pub fn main() { test_bool(); test_rec(); } diff --git a/src/test/run-pass/expr-if-struct.rs b/src/test/run-pass/expr-if-struct.rs index 506d607e7e8..2f222c2d08e 100644 --- a/src/test/run-pass/expr-if-struct.rs +++ b/src/test/run-pass/expr-if-struct.rs @@ -36,4 +36,4 @@ fn test_tag() { assert (rs == happy); } -fn main() { test_rec(); test_tag(); } +pub fn main() { test_rec(); test_tag(); } diff --git a/src/test/run-pass/expr-if-unique.rs b/src/test/run-pass/expr-if-unique.rs index 443847bfd50..4cf99f83039 100644 --- a/src/test/run-pass/expr-if-unique.rs +++ b/src/test/run-pass/expr-if-unique.rs @@ -19,4 +19,4 @@ fn test_box() { assert (*rs == 100); } -fn main() { test_box(); } +pub fn main() { test_box(); } diff --git a/src/test/run-pass/expr-if.rs b/src/test/run-pass/expr-if.rs index 6fc5a1c38c2..b75c633671b 100644 --- a/src/test/run-pass/expr-if.rs +++ b/src/test/run-pass/expr-if.rs @@ -53,7 +53,7 @@ fn test_if_as_block_result() { assert (rs); } -fn main() { +pub fn main() { test_if(); test_else(); test_elseif1(); diff --git a/src/test/run-pass/expr-scope.rs b/src/test/run-pass/expr-scope.rs index 35e3ff60243..942147f1eba 100644 --- a/src/test/run-pass/expr-scope.rs +++ b/src/test/run-pass/expr-scope.rs @@ -12,4 +12,4 @@ // xfail-fast pub fn f() { } -fn main() { return ::f(); } +pub fn main() { return ::f(); } diff --git a/src/test/run-pass/exterior.rs b/src/test/run-pass/exterior.rs index 2d77a775f34..f7faf26bc4c 100644 --- a/src/test/run-pass/exterior.rs +++ b/src/test/run-pass/exterior.rs @@ -16,7 +16,7 @@ struct Point {x: int, y: int, mut z: int} fn f(p: @Point) { assert (p.z == 12); p.z = 13; assert (p.z == 13); } -fn main() { +pub fn main() { let a: Point = Point {x: 10, y: 11, mut z: 12}; let b: @Point = @copy a; assert (b.z == 12); diff --git a/src/test/run-pass/extern-1.rs b/src/test/run-pass/extern-1.rs index 93da915f669..3aaa514eea2 100644 --- a/src/test/run-pass/extern-1.rs +++ b/src/test/run-pass/extern-1.rs @@ -11,5 +11,5 @@ extern fn f() { } -fn main() { +pub fn main() { } \ No newline at end of file diff --git a/src/test/run-pass/extern-call-deep.rs b/src/test/run-pass/extern-call-deep.rs index da09dd02be3..c0032cb055a 100644 --- a/src/test/run-pass/extern-call-deep.rs +++ b/src/test/run-pass/extern-call-deep.rs @@ -28,7 +28,7 @@ fn count(n: uint) -> uint { } } -fn main() { +pub fn main() { let result = count(1000u); debug!("result = %?", result); assert result == 1000u; diff --git a/src/test/run-pass/extern-call-deep2.rs b/src/test/run-pass/extern-call-deep2.rs index 52753e2549f..970bc935227 100644 --- a/src/test/run-pass/extern-call-deep2.rs +++ b/src/test/run-pass/extern-call-deep2.rs @@ -28,7 +28,7 @@ fn count(n: uint) -> uint { } } -fn main() { +pub fn main() { // Make sure we're on a task with small Rust stacks (main currently // has a large stack) do task::spawn { diff --git a/src/test/run-pass/extern-call-scrub.rs b/src/test/run-pass/extern-call-scrub.rs index 1db40fbcc21..3067707019b 100644 --- a/src/test/run-pass/extern-call-scrub.rs +++ b/src/test/run-pass/extern-call-scrub.rs @@ -32,7 +32,7 @@ fn count(n: uint) -> uint { } } -fn main() { +pub fn main() { // Make sure we're on a task with small Rust stacks (main currently // has a large stack) do task::spawn { diff --git a/src/test/run-pass/extern-call.rs b/src/test/run-pass/extern-call.rs index 2c92202992d..44051b8074a 100644 --- a/src/test/run-pass/extern-call.rs +++ b/src/test/run-pass/extern-call.rs @@ -28,7 +28,7 @@ fn fact(n: uint) -> uint { } } -fn main() { +pub fn main() { let result = fact(10u); debug!("result = %?", result); assert result == 3628800u; diff --git a/src/test/run-pass/extern-crosscrate.rs b/src/test/run-pass/extern-crosscrate.rs index 3ce4aa741ca..b95074c6f88 100644 --- a/src/test/run-pass/extern-crosscrate.rs +++ b/src/test/run-pass/extern-crosscrate.rs @@ -20,7 +20,7 @@ fn fact(n: uint) -> uint { } } -fn main() { +pub fn main() { let result = fact(10u); debug!("result = %?", result); assert result == 3628800u; diff --git a/src/test/run-pass/extern-mod-abi.rs b/src/test/run-pass/extern-mod-abi.rs index baf19150ad4..7eada51b7c7 100644 --- a/src/test/run-pass/extern-mod-abi.rs +++ b/src/test/run-pass/extern-mod-abi.rs @@ -12,5 +12,5 @@ extern "C" { fn pow(x: f64, y: f64) -> f64; } -fn main() {} +pub fn main() {} diff --git a/src/test/run-pass/extern-mod-syntax.rs b/src/test/run-pass/extern-mod-syntax.rs index badff7bdfd6..2a7843bdccd 100644 --- a/src/test/run-pass/extern-mod-syntax.rs +++ b/src/test/run-pass/extern-mod-syntax.rs @@ -11,9 +11,9 @@ // except according to those terms. extern mod std; -use std::map::HashMap; +use std::oldmap::HashMap; -fn main() { +pub fn main() { io::println("Hello world!"); } diff --git a/src/test/run-pass/extern-pub.rs b/src/test/run-pass/extern-pub.rs index 92e580253a8..9bfeec8c7d6 100644 --- a/src/test/run-pass/extern-pub.rs +++ b/src/test/run-pass/extern-pub.rs @@ -4,7 +4,7 @@ extern { ++n: libc::size_t); } -fn main() { +pub fn main() { } diff --git a/src/test/run-pass/extern-stress.rs b/src/test/run-pass/extern-stress.rs index bd6d597c74c..80b234e84ec 100644 --- a/src/test/run-pass/extern-stress.rs +++ b/src/test/run-pass/extern-stress.rs @@ -31,7 +31,7 @@ fn count(n: uint) -> uint { } } -fn main() { +pub fn main() { for iter::repeat(100u) { do task::spawn { assert count(5u) == 16u; diff --git a/src/test/run-pass/extern-take-value.rs b/src/test/run-pass/extern-take-value.rs index 4f2ca4a657a..d3d99f0fffc 100644 --- a/src/test/run-pass/extern-take-value.rs +++ b/src/test/run-pass/extern-take-value.rs @@ -14,7 +14,7 @@ extern fn f() { extern fn g() { } -fn main() { +pub fn main() { // extern functions are *u8 types let a: *u8 = f; let b: *u8 = f; diff --git a/src/test/run-pass/extern-yield.rs b/src/test/run-pass/extern-yield.rs index 1ec8f8ab8a3..aa8f8ab82cc 100644 --- a/src/test/run-pass/extern-yield.rs +++ b/src/test/run-pass/extern-yield.rs @@ -28,7 +28,7 @@ fn count(n: uint) -> uint { } } -fn main() { +pub fn main() { for iter::repeat(10u) { do task::spawn { let result = count(5u); diff --git a/src/test/run-pass/fact.rs b/src/test/run-pass/fact.rs index e9839711770..93f4dd43959 100644 --- a/src/test/run-pass/fact.rs +++ b/src/test/run-pass/fact.rs @@ -31,7 +31,7 @@ fn f(x: int) -> int { } } -fn main() { +pub fn main() { assert (f(5) == 120); // debug!("all done"); diff --git a/src/test/run-pass/fat-arrow-alt.rs b/src/test/run-pass/fat-arrow-alt.rs index b6882e65e7f..0c19655c9f5 100644 --- a/src/test/run-pass/fat-arrow-alt.rs +++ b/src/test/run-pass/fat-arrow-alt.rs @@ -16,7 +16,7 @@ enum color { blue } -fn main() { +pub fn main() { log(error, match red { red => { 1 } green => { 2 } diff --git a/src/test/run-pass/fixed-point-bind-box.rs b/src/test/run-pass/fixed-point-bind-box.rs index d906ea6f91e..48772aa7889 100644 --- a/src/test/run-pass/fixed-point-bind-box.rs +++ b/src/test/run-pass/fixed-point-bind-box.rs @@ -24,7 +24,7 @@ fn fact_(f: fn@(&&v: int) -> int, &&n: int) -> int { return if n == 0 { 1 } else { n * f(n - 1) }; } -fn main() { +pub fn main() { let fact = fix(fact_); assert (fact(5) == 120); assert (fact(2) == 2); diff --git a/src/test/run-pass/fixed-point-bind-unique.rs b/src/test/run-pass/fixed-point-bind-unique.rs index 06f01a67453..e41fa1af90f 100644 --- a/src/test/run-pass/fixed-point-bind-unique.rs +++ b/src/test/run-pass/fixed-point-bind-unique.rs @@ -24,7 +24,7 @@ fn fact_(f: fn@(&&v: int) -> int, &&n: int) -> int { return if n == 0 { 1 } else { n * f(n - 1) }; } -fn main() { +pub fn main() { let fact = fix(fact_); assert (fact(5) == 120); assert (fact(2) == 2); diff --git a/src/test/run-pass/fixed_length_copy.rs b/src/test/run-pass/fixed_length_copy.rs index 176d3024619..54a7c9959ff 100644 --- a/src/test/run-pass/fixed_length_copy.rs +++ b/src/test/run-pass/fixed_length_copy.rs @@ -12,7 +12,7 @@ // error on implicit copies to check fixed length vectors // are implicitly copyable #[deny(implicit_copies)] -fn main() { +pub fn main() { let arr = [1,2,3]; let arr2 = arr; assert(arr[1] == 2); diff --git a/src/test/run-pass/fixed_length_vec_glue.rs b/src/test/run-pass/fixed_length_vec_glue.rs index 3d6e781c512..1ee1ad02201 100644 --- a/src/test/run-pass/fixed_length_vec_glue.rs +++ b/src/test/run-pass/fixed_length_vec_glue.rs @@ -10,7 +10,7 @@ struct Struc { a: u8, b: [int * 3], c: int } -fn main() { +pub fn main() { let arr = [1,2,3]; let struc = Struc {a: 13u8, b: arr, c: 42}; let s = sys::log_str(&struc); diff --git a/src/test/run-pass/float-literal-inference.rs b/src/test/run-pass/float-literal-inference.rs index 6ae66fd442c..2b59d7bfcee 100644 --- a/src/test/run-pass/float-literal-inference.rs +++ b/src/test/run-pass/float-literal-inference.rs @@ -12,7 +12,7 @@ struct S { z: f64 } -fn main() { +pub fn main() { let x: f32 = 4.0; io::println(x.to_str()); let y: float = 64.0; diff --git a/src/test/run-pass/float-nan.rs b/src/test/run-pass/float-nan.rs index e80e2ae17b4..daab9684cf4 100644 --- a/src/test/run-pass/float-nan.rs +++ b/src/test/run-pass/float-nan.rs @@ -10,7 +10,7 @@ extern mod std; -fn main() { +pub fn main() { let nan = float::NaN; assert(float::is_NaN(nan)); diff --git a/src/test/run-pass/float-signature.rs b/src/test/run-pass/float-signature.rs index 3116c6e4d83..aeb94760e63 100644 --- a/src/test/run-pass/float-signature.rs +++ b/src/test/run-pass/float-signature.rs @@ -10,7 +10,7 @@ -fn main() { +pub fn main() { fn foo(n: float) -> float { return n + 0.12345; } let n: float = 0.1; let m: float = foo(n); diff --git a/src/test/run-pass/float.rs b/src/test/run-pass/float.rs index 47097928c8b..53e19b62a28 100644 --- a/src/test/run-pass/float.rs +++ b/src/test/run-pass/float.rs @@ -10,7 +10,7 @@ -fn main() { +pub fn main() { let pi = 3.1415927; log(debug, -pi * (pi + 2.0 / pi) - pi * 5.0); if pi == 5.0 || pi < 10.0 || pi <= 2.0 || pi != 22.0 / 7.0 || pi >= 10.0 diff --git a/src/test/run-pass/float2.rs b/src/test/run-pass/float2.rs index bf2b38e72b2..12d2dbafc4b 100644 --- a/src/test/run-pass/float2.rs +++ b/src/test/run-pass/float2.rs @@ -10,7 +10,7 @@ -fn main() { +pub fn main() { let a = 1.5e6; let b = 1.5E6; let c = 1e6; diff --git a/src/test/run-pass/floatlits.rs b/src/test/run-pass/floatlits.rs index eb97402e481..573c5302698 100644 --- a/src/test/run-pass/floatlits.rs +++ b/src/test/run-pass/floatlits.rs @@ -10,7 +10,7 @@ -fn main() { +pub fn main() { let f = 4.999999999999; assert (f > 4.90); assert (f < 5.0); diff --git a/src/test/run-pass/fn-assign-managed-to-bare-1.rs b/src/test/run-pass/fn-assign-managed-to-bare-1.rs index 17becfb4ee3..6561708192b 100644 --- a/src/test/run-pass/fn-assign-managed-to-bare-1.rs +++ b/src/test/run-pass/fn-assign-managed-to-bare-1.rs @@ -12,7 +12,7 @@ fn add(n: int) -> fn@(int) -> int { fn@(m: int) -> int { m + n } } -fn main() +pub fn main() { assert add(3)(4) == 7; let add3 : fn(int)->int = add(3); diff --git a/src/test/run-pass/fn-assign-managed-to-bare-2.rs b/src/test/run-pass/fn-assign-managed-to-bare-2.rs index 2f98cf68d96..013b8ba4adb 100644 --- a/src/test/run-pass/fn-assign-managed-to-bare-2.rs +++ b/src/test/run-pass/fn-assign-managed-to-bare-2.rs @@ -12,7 +12,7 @@ fn add(n: int) -> fn@(int) -> int { fn@(m: int) -> int { m + n } } -fn main() +pub fn main() { assert add(3)(4) == 7; diff --git a/src/test/run-pass/fn-bare-assign.rs b/src/test/run-pass/fn-bare-assign.rs index f879c72cd18..1d523e180ff 100644 --- a/src/test/run-pass/fn-bare-assign.rs +++ b/src/test/run-pass/fn-bare-assign.rs @@ -17,7 +17,7 @@ fn g(f: extern fn(int, v: &mut bool), called: &mut bool) { f(10, called); } -fn main() { +pub fn main() { let mut called = false; let h = f; g(h, &mut called); diff --git a/src/test/run-pass/fn-bare-coerce-to-block.rs b/src/test/run-pass/fn-bare-coerce-to-block.rs index 9bd67ee1aa4..b243ce63e18 100644 --- a/src/test/run-pass/fn-bare-coerce-to-block.rs +++ b/src/test/run-pass/fn-bare-coerce-to-block.rs @@ -12,6 +12,6 @@ fn bare() {} fn likes_block(f: fn()) { f() } -fn main() { +pub fn main() { likes_block(bare); } \ No newline at end of file diff --git a/src/test/run-pass/fn-bare-coerce-to-shared.rs b/src/test/run-pass/fn-bare-coerce-to-shared.rs index 80617605bba..91b0abbb3ec 100644 --- a/src/test/run-pass/fn-bare-coerce-to-shared.rs +++ b/src/test/run-pass/fn-bare-coerce-to-shared.rs @@ -12,6 +12,6 @@ fn bare() {} fn likes_shared(f: fn@()) { f() } -fn main() { +pub fn main() { likes_shared(bare); } \ No newline at end of file diff --git a/src/test/run-pass/fn-bare-item.rs b/src/test/run-pass/fn-bare-item.rs index 1765947ee68..c224f48cbc3 100644 --- a/src/test/run-pass/fn-bare-item.rs +++ b/src/test/run-pass/fn-bare-item.rs @@ -12,6 +12,6 @@ fn f() { debug!("This is a bare function"); } -fn main() { +pub fn main() { f(); } \ No newline at end of file diff --git a/src/test/run-pass/fn-bare-size.rs b/src/test/run-pass/fn-bare-size.rs index 596bd048577..499dc6a4a2b 100644 --- a/src/test/run-pass/fn-bare-size.rs +++ b/src/test/run-pass/fn-bare-size.rs @@ -12,7 +12,7 @@ extern mod std; -fn main() { +pub fn main() { // Bare functions should just be a pointer assert sys::rustrt::size_of::<fn()>() == sys::rustrt::size_of::<int>(); diff --git a/src/test/run-pass/fn-bare-spawn.rs b/src/test/run-pass/fn-bare-spawn.rs index 53e66f950d3..163063ab745 100644 --- a/src/test/run-pass/fn-bare-spawn.rs +++ b/src/test/run-pass/fn-bare-spawn.rs @@ -18,6 +18,6 @@ fn f(+i: int) { assert i == 100; } -fn main() { +pub fn main() { spawn(100, f); } diff --git a/src/test/run-pass/fn-coerce-field.rs b/src/test/run-pass/fn-coerce-field.rs index 0e7d90e2fd8..028fb0f4440 100644 --- a/src/test/run-pass/fn-coerce-field.rs +++ b/src/test/run-pass/fn-coerce-field.rs @@ -12,7 +12,7 @@ struct r { field: fn@() } -fn main() { +pub fn main() { fn f() {} let i: r = r {field: f}; } \ No newline at end of file diff --git a/src/test/run-pass/fn-lval.rs b/src/test/run-pass/fn-lval.rs index ae646150bb6..2754fdea4d4 100644 --- a/src/test/run-pass/fn-lval.rs +++ b/src/test/run-pass/fn-lval.rs @@ -16,4 +16,4 @@ fn foo(f: extern fn(int) -> int) { } fn id(x: int) -> int { return x; } -fn main() { foo(id); } +pub fn main() { foo(id); } diff --git a/src/test/run-pass/fn-pattern-expected-type-2.rs b/src/test/run-pass/fn-pattern-expected-type-2.rs index 2442af5a402..f9bf9b5915e 100644 --- a/src/test/run-pass/fn-pattern-expected-type-2.rs +++ b/src/test/run-pass/fn-pattern-expected-type-2.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -fn main() { +pub fn main() { let v : &[(int,int)] = &[ (1, 2), (3, 4), (5, 6) ]; for v.each |&(x, y)| { io::println(y.to_str()); diff --git a/src/test/run-pass/fn-pattern-expected-type.rs b/src/test/run-pass/fn-pattern-expected-type.rs index 6f8db90289b..28ac3f88b24 100644 --- a/src/test/run-pass/fn-pattern-expected-type.rs +++ b/src/test/run-pass/fn-pattern-expected-type.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -fn main() { +pub fn main() { let f: fn((int,int)) = |(x, y)| { assert x == 1; assert y == 2; diff --git a/src/test/run-pass/fn-type-infer.rs b/src/test/run-pass/fn-type-infer.rs index 055aa268f20..4fd78286e33 100644 --- a/src/test/run-pass/fn-type-infer.rs +++ b/src/test/run-pass/fn-type-infer.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -fn main() { +pub fn main() { // We should be able to type infer inside of fn@s. let f = fn@() { let i = 10; }; } diff --git a/src/test/run-pass/for-destruct.rs b/src/test/run-pass/for-destruct.rs index 47da343764c..6a91c5b0ee8 100644 --- a/src/test/run-pass/for-destruct.rs +++ b/src/test/run-pass/for-destruct.rs @@ -10,7 +10,7 @@ struct Pair { x: int, y: int } -fn main() { +pub fn main() { for vec::each(~[Pair {x: 10, y: 20}, Pair {x: 30, y: 0}]) |elt| { assert (elt.x + elt.y == 30); } diff --git a/src/test/run-pass/for-loop-fail.rs b/src/test/run-pass/for-loop-fail.rs index 0fd2fba8a9a..55ffc3d0258 100644 --- a/src/test/run-pass/for-loop-fail.rs +++ b/src/test/run-pass/for-loop-fail.rs @@ -8,4 +8,4 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -fn main() { let x: ~[int] = ~[]; for x.each |_i| { fail ~"moop"; } } +pub fn main() { let x: ~[int] = ~[]; for x.each |_i| { die!(~"moop"); } } diff --git a/src/test/run-pass/foreach-nested.rs b/src/test/run-pass/foreach-nested.rs index 13da4306ab3..4d7486b7263 100644 --- a/src/test/run-pass/foreach-nested.rs +++ b/src/test/run-pass/foreach-nested.rs @@ -14,8 +14,8 @@ // -*- rust -*- fn two(it: fn(int)) { it(0); it(1); } -fn main() { - let a: ~[mut int] = ~[mut -1, -1, -1, -1]; +pub fn main() { + let mut a: ~[int] = ~[-1, -1, -1, -1]; let mut p: int = 0; do two |i| { do two |j| { a[p] = 10 * i + j; p += 1; } diff --git a/src/test/run-pass/foreach-put-structured.rs b/src/test/run-pass/foreach-put-structured.rs index 71da4638c09..d1fe6fab63c 100644 --- a/src/test/run-pass/foreach-put-structured.rs +++ b/src/test/run-pass/foreach-put-structured.rs @@ -16,7 +16,7 @@ fn pairs(it: fn((int, int))) { while i < 10 { it((i, j)); i += 1; j += i; } } -fn main() { +pub fn main() { let mut i: int = 10; let mut j: int = 0; do pairs() |p| { diff --git a/src/test/run-pass/foreach-simple-outer-slot.rs b/src/test/run-pass/foreach-simple-outer-slot.rs index 20e00d57e1a..86456321e80 100644 --- a/src/test/run-pass/foreach-simple-outer-slot.rs +++ b/src/test/run-pass/foreach-simple-outer-slot.rs @@ -12,7 +12,7 @@ // -*- rust -*- -fn main() { +pub fn main() { let mut sum: int = 0; do first_ten |i| { debug!("main"); log(debug, i); sum = sum + i; } debug!("sum"); diff --git a/src/test/run-pass/foreign-dupe.rs b/src/test/run-pass/foreign-dupe.rs index b06afbfe55e..77ed95a8099 100644 --- a/src/test/run-pass/foreign-dupe.rs +++ b/src/test/run-pass/foreign-dupe.rs @@ -23,7 +23,7 @@ extern mod rustrt2 { pub fn last_os_error() -> ~str; } -fn main() { +pub fn main() { unsafe { rustrt1::last_os_error(); rustrt2::last_os_error(); diff --git a/src/test/run-pass/foreign-fn-linkname.rs b/src/test/run-pass/foreign-fn-linkname.rs index ffadd4bd41b..a17a5c3c723 100644 --- a/src/test/run-pass/foreign-fn-linkname.rs +++ b/src/test/run-pass/foreign-fn-linkname.rs @@ -26,7 +26,7 @@ fn strlen(str: ~str) -> uint { } } -fn main() { +pub fn main() { let len = strlen(~"Rust"); assert(len == 4u); } diff --git a/src/test/run-pass/foreign-lib-path.rs b/src/test/run-pass/foreign-lib-path.rs index b2935ba9f10..2974f46bf08 100644 --- a/src/test/run-pass/foreign-lib-path.rs +++ b/src/test/run-pass/foreign-lib-path.rs @@ -19,6 +19,6 @@ extern mod WHATGOESHERE { pub fn IDONTKNOW() -> u32; } -fn main() { +pub fn main() { assert IDONTKNOW() == 0x_BAD_DOOD_u32; } diff --git a/src/test/run-pass/foreign-mod-src/inner.rs b/src/test/run-pass/foreign-mod-src/inner.rs index 8488b20a50b..8f92cb95187 100644 --- a/src/test/run-pass/foreign-mod-src/inner.rs +++ b/src/test/run-pass/foreign-mod-src/inner.rs @@ -12,7 +12,7 @@ // -*- rust -*- -fn main() { +pub fn main() { let f = "Makefile"; let s = rustrt.str_buf(f); let buf = libc.malloc(1024); diff --git a/src/test/run-pass/foreign-mod-unused-const.rs b/src/test/run-pass/foreign-mod-unused-const.rs index f05d40ad1d6..ece201bc3a2 100644 --- a/src/test/run-pass/foreign-mod-unused-const.rs +++ b/src/test/run-pass/foreign-mod-unused-const.rs @@ -13,6 +13,6 @@ extern mod foo { pub const errno: int; } -fn main() { +pub fn main() { } diff --git a/src/test/run-pass/foreign-no-abi.rs b/src/test/run-pass/foreign-no-abi.rs index 1782778e5d7..9c1ffd5e9e4 100644 --- a/src/test/run-pass/foreign-no-abi.rs +++ b/src/test/run-pass/foreign-no-abi.rs @@ -14,7 +14,7 @@ extern mod rustrt { pub fn get_task_id() -> libc::intptr_t; } -fn main() { +pub fn main() { unsafe { rustrt::get_task_id(); } diff --git a/src/test/run-pass/foreign-src/foreign.rs b/src/test/run-pass/foreign-src/foreign.rs index f560d779741..df0d1bcd4b9 100644 --- a/src/test/run-pass/foreign-src/foreign.rs +++ b/src/test/run-pass/foreign-src/foreign.rs @@ -12,7 +12,7 @@ // -*- rust -*- -fn main() { +pub fn main() { libc.puts(rustrt.str_buf("hello, extern world 1")); libc.puts(rustrt.str_buf("hello, extern world 2")); libc.puts(rustrt.str_buf("hello, extern world 3")); diff --git a/src/test/run-pass/foreign-struct.rs b/src/test/run-pass/foreign-struct.rs index 3adc983a062..aef96b84619 100644 --- a/src/test/run-pass/foreign-struct.rs +++ b/src/test/run-pass/foreign-struct.rs @@ -18,4 +18,4 @@ extern mod bindgen { pub fn printf(++v: void); } -fn main() { } +pub fn main() { } diff --git a/src/test/run-pass/foreign2.rs b/src/test/run-pass/foreign2.rs index 9a5d747521b..c09bfc22171 100644 --- a/src/test/run-pass/foreign2.rs +++ b/src/test/run-pass/foreign2.rs @@ -27,4 +27,4 @@ extern mod libc { #[nolink] extern mod baz {} -fn main() { } +pub fn main() { } diff --git a/src/test/run-pass/fun-call-variants.rs b/src/test/run-pass/fun-call-variants.rs index 5ee05ff34d3..88bd1653861 100644 --- a/src/test/run-pass/fun-call-variants.rs +++ b/src/test/run-pass/fun-call-variants.rs @@ -13,7 +13,7 @@ fn ho(f: fn@(int) -> int) -> int { let n: int = f(3); return n; } fn direct(x: int) -> int { return x + 1; } -fn main() { +pub fn main() { let a: int = direct(3); // direct let b: int = ho(direct); // indirect unbound diff --git a/src/test/run-pass/fun-indirect-call.rs b/src/test/run-pass/fun-indirect-call.rs index 1ee7b0c3a29..a200d5f6559 100644 --- a/src/test/run-pass/fun-indirect-call.rs +++ b/src/test/run-pass/fun-indirect-call.rs @@ -14,7 +14,7 @@ // -*- rust -*- fn f() -> int { return 42; } -fn main() { +pub fn main() { let g: extern fn() -> int = f; let i: int = g(); assert (i == 42); diff --git a/src/test/run-pass/functional-struct-update.rs b/src/test/run-pass/functional-struct-update.rs index 5109e0658fb..f1db6db417a 100644 --- a/src/test/run-pass/functional-struct-update.rs +++ b/src/test/run-pass/functional-struct-update.rs @@ -13,7 +13,7 @@ struct Foo { y: int } -fn main() { +pub fn main() { let a = Foo { x: 1, y: 2 }; let c = Foo { x: 4, .. a}; io::println(fmt!("%?", c)); diff --git a/src/test/run-pass/generic-alias-box.rs b/src/test/run-pass/generic-alias-box.rs index b3dcc1031b0..3830d89616c 100644 --- a/src/test/run-pass/generic-alias-box.rs +++ b/src/test/run-pass/generic-alias-box.rs @@ -12,7 +12,7 @@ fn id<T: Copy>(t: T) -> T { return t; } -fn main() { +pub fn main() { let expected = @100; let actual = id::<@int>(expected); log(debug, *actual); diff --git a/src/test/run-pass/generic-alias-unique.rs b/src/test/run-pass/generic-alias-unique.rs index 6537be69a1d..0aa1b4dd651 100644 --- a/src/test/run-pass/generic-alias-unique.rs +++ b/src/test/run-pass/generic-alias-unique.rs @@ -12,7 +12,7 @@ fn id<T: Copy Owned>(t: T) -> T { return t; } -fn main() { +pub fn main() { let expected = ~100; let actual = id::<~int>(copy expected); log(debug, *actual); diff --git a/src/test/run-pass/generic-box.rs b/src/test/run-pass/generic-box.rs index f68cf1676c7..05f4908b3b2 100644 --- a/src/test/run-pass/generic-box.rs +++ b/src/test/run-pass/generic-box.rs @@ -14,7 +14,7 @@ fn box<T: Copy>(x: Box<T>) -> @Box<T> { return @x; } struct Box<T> {x: T, y: T, z: T} -fn main() { +pub fn main() { let x: @Box<int> = box::<int>(Box{x: 1, y: 2, z: 3}); assert (x.y == 2); } diff --git a/src/test/run-pass/generic-derived-type.rs b/src/test/run-pass/generic-derived-type.rs index 03f5a84de69..3667e549745 100644 --- a/src/test/run-pass/generic-derived-type.rs +++ b/src/test/run-pass/generic-derived-type.rs @@ -20,7 +20,7 @@ fn f<T: Copy>(t: T) -> Pair<T> { return g::<Pair<T>>(x); } -fn main() { +pub fn main() { let b = f::<int>(10); log(debug, b.a); log(debug, b.b); diff --git a/src/test/run-pass/generic-drop-glue.rs b/src/test/run-pass/generic-drop-glue.rs index aad24e99058..b8de3e0b5e3 100644 --- a/src/test/run-pass/generic-drop-glue.rs +++ b/src/test/run-pass/generic-drop-glue.rs @@ -13,4 +13,4 @@ struct Pair { x: @int, y: @int } fn f<T: Copy>(t: T) { let t1: T = t; } -fn main() { let x = Pair {x: @10, y: @12}; f(x); } +pub fn main() { let x = Pair {x: @10, y: @12}; f(x); } diff --git a/src/test/run-pass/generic-exterior-box.rs b/src/test/run-pass/generic-exterior-box.rs index c2abcc75283..4c8de2fbffc 100644 --- a/src/test/run-pass/generic-exterior-box.rs +++ b/src/test/run-pass/generic-exterior-box.rs @@ -14,7 +14,7 @@ struct Recbox<T> {x: @T} fn reclift<T: Copy>(t: T) -> Recbox<T> { return Recbox {x: @t}; } -fn main() { +pub fn main() { let foo: int = 17; let rbfoo: Recbox<int> = reclift::<int>(foo); assert (*rbfoo.x == foo); diff --git a/src/test/run-pass/generic-exterior-unique.rs b/src/test/run-pass/generic-exterior-unique.rs index a4a576abc75..741d9f0e179 100644 --- a/src/test/run-pass/generic-exterior-unique.rs +++ b/src/test/run-pass/generic-exterior-unique.rs @@ -12,7 +12,7 @@ struct Recbox<T> {x: ~T} fn reclift<T: Copy>(t: T) -> Recbox<T> { return Recbox {x: ~t}; } -fn main() { +pub fn main() { let foo: int = 17; let rbfoo: Recbox<int> = reclift::<int>(foo); assert (*rbfoo.x == foo); diff --git a/src/test/run-pass/generic-fn-box.rs b/src/test/run-pass/generic-fn-box.rs index 5c4cee2c182..0a496b2bcf5 100644 --- a/src/test/run-pass/generic-fn-box.rs +++ b/src/test/run-pass/generic-fn-box.rs @@ -12,4 +12,4 @@ fn f<T>(x: @T) -> @T { return x; } -fn main() { let x = f(@3); log(debug, *x); } +pub fn main() { let x = f(@3); log(debug, *x); } diff --git a/src/test/run-pass/generic-fn-infer.rs b/src/test/run-pass/generic-fn-infer.rs index 1f4ab0db835..88130af2ccc 100644 --- a/src/test/run-pass/generic-fn-infer.rs +++ b/src/test/run-pass/generic-fn-infer.rs @@ -16,4 +16,4 @@ // Issue #45: infer type parameters in function applications fn id<T: Copy>(x: T) -> T { return x; } -fn main() { let x: int = 42; let y: int = id(x); assert (x == y); } +pub fn main() { let x: int = 42; let y: int = id(x); assert (x == y); } diff --git a/src/test/run-pass/generic-fn-twice.rs b/src/test/run-pass/generic-fn-twice.rs index 2316ca61a3c..aace9571a09 100644 --- a/src/test/run-pass/generic-fn-twice.rs +++ b/src/test/run-pass/generic-fn-twice.rs @@ -16,4 +16,4 @@ mod foomod { pub fn foo<T>() { } } -fn main() { foomod::foo::<int>(); foomod::foo::<int>(); } +pub fn main() { foomod::foo::<int>(); foomod::foo::<int>(); } diff --git a/src/test/run-pass/generic-fn-unique.rs b/src/test/run-pass/generic-fn-unique.rs index 3ca56428706..b58b68ee5ae 100644 --- a/src/test/run-pass/generic-fn-unique.rs +++ b/src/test/run-pass/generic-fn-unique.rs @@ -11,4 +11,4 @@ fn f<T: Copy>(x: ~T) -> ~T { return x; } -fn main() { let x = f(~3); log(debug, *x); } +pub fn main() { let x = f(~3); log(debug, *x); } diff --git a/src/test/run-pass/generic-fn.rs b/src/test/run-pass/generic-fn.rs index 13ed32e0c2d..551fe221eda 100644 --- a/src/test/run-pass/generic-fn.rs +++ b/src/test/run-pass/generic-fn.rs @@ -16,7 +16,7 @@ fn id<T: Copy>(x: T) -> T { return x; } struct Triple {x: int, y: int, z: int} -fn main() { +pub fn main() { let mut x = 62; let mut y = 63; let a = 'a'; diff --git a/src/test/run-pass/generic-ivec-leak.rs b/src/test/run-pass/generic-ivec-leak.rs index e6eef56d10e..8d9b0fa6ddb 100644 --- a/src/test/run-pass/generic-ivec-leak.rs +++ b/src/test/run-pass/generic-ivec-leak.rs @@ -10,5 +10,5 @@ enum wrapper<T> { wrapped(T), } -fn main() { let w = wrapped(~[1, 2, 3, 4, 5]); } +pub fn main() { let w = wrapped(~[1, 2, 3, 4, 5]); } diff --git a/src/test/run-pass/generic-ivec.rs b/src/test/run-pass/generic-ivec.rs index 8ea4c1ff74c..031821d9909 100644 --- a/src/test/run-pass/generic-ivec.rs +++ b/src/test/run-pass/generic-ivec.rs @@ -9,5 +9,5 @@ // except according to those terms. fn f<T>(v: @T) { } -fn main() { f(@~[1, 2, 3, 4, 5]); } +pub fn main() { f(@~[1, 2, 3, 4, 5]); } diff --git a/src/test/run-pass/generic-newtype-struct.rs b/src/test/run-pass/generic-newtype-struct.rs index 8b9d6479ed3..7c7d73eda10 100644 --- a/src/test/run-pass/generic-newtype-struct.rs +++ b/src/test/run-pass/generic-newtype-struct.rs @@ -1,6 +1,6 @@ struct S<T>(T); -fn main() { +pub fn main() { let s = S(2i); io::println(s.to_str()); } diff --git a/src/test/run-pass/generic-object.rs b/src/test/run-pass/generic-object.rs index 2318f166873..497739471d8 100644 --- a/src/test/run-pass/generic-object.rs +++ b/src/test/run-pass/generic-object.rs @@ -22,7 +22,7 @@ impl S : Foo<int> { } } -fn main() { +pub fn main() { let x = @S { x: 1 }; let y = x as @Foo<int>; assert y.get() == 1; diff --git a/src/test/run-pass/generic-recursive-tag.rs b/src/test/run-pass/generic-recursive-tag.rs index 4d725f638b5..af92bb4c8d8 100644 --- a/src/test/run-pass/generic-recursive-tag.rs +++ b/src/test/run-pass/generic-recursive-tag.rs @@ -12,7 +12,7 @@ enum list<T> { cons(@T, @list<T>), nil, } -fn main() { +pub fn main() { let a: list<int> = cons::<int>(@10, @cons::<int>(@12, @cons::<int>(@13, @nil::<int>))); } diff --git a/src/test/run-pass/generic-tag-alt.rs b/src/test/run-pass/generic-tag-alt.rs index 172eeea454f..020111d55ac 100644 --- a/src/test/run-pass/generic-tag-alt.rs +++ b/src/test/run-pass/generic-tag-alt.rs @@ -18,4 +18,4 @@ fn altfoo<T>(f: foo<T>) { assert (hit); } -fn main() { altfoo::<int>(arm::<int>(10)); } +pub fn main() { altfoo::<int>(arm::<int>(10)); } diff --git a/src/test/run-pass/generic-tag-corruption.rs b/src/test/run-pass/generic-tag-corruption.rs index f8da08e87d2..5cf56b8083d 100644 --- a/src/test/run-pass/generic-tag-corruption.rs +++ b/src/test/run-pass/generic-tag-corruption.rs @@ -14,4 +14,4 @@ // This causes memory corruption in stage0. enum thing<K> { some(K), } -fn main() { let x = some(~"hi"); } +pub fn main() { let x = some(~"hi"); } diff --git a/src/test/run-pass/generic-tag-local.rs b/src/test/run-pass/generic-tag-local.rs index 58656c908cd..21e113f40a5 100644 --- a/src/test/run-pass/generic-tag-local.rs +++ b/src/test/run-pass/generic-tag-local.rs @@ -12,4 +12,4 @@ enum clam<T> { a(T), } -fn main() { let c = a(3); } +pub fn main() { let c = a(3); } diff --git a/src/test/run-pass/generic-tag-values.rs b/src/test/run-pass/generic-tag-values.rs index 9fd5f4fadff..c9024756328 100644 --- a/src/test/run-pass/generic-tag-values.rs +++ b/src/test/run-pass/generic-tag-values.rs @@ -16,7 +16,7 @@ enum noption<T> { some(T), } struct Pair { x: int, y: int } -fn main() { +pub fn main() { let nop: noption<int> = some::<int>(5); match nop { some::<int>(n) => { log(debug, n); assert (n == 5); } } let nop2: noption<Pair> = some(Pair{x: 17, y: 42}); diff --git a/src/test/run-pass/generic-tag.rs b/src/test/run-pass/generic-tag.rs index c8566735b9c..b38c494662f 100644 --- a/src/test/run-pass/generic-tag.rs +++ b/src/test/run-pass/generic-tag.rs @@ -12,4 +12,4 @@ enum option<T> { some(@T), none, } -fn main() { let mut a: option<int> = some::<int>(@10); a = none::<int>; } +pub fn main() { let mut a: option<int> = some::<int>(@10); a = none::<int>; } diff --git a/src/test/run-pass/generic-temporary.rs b/src/test/run-pass/generic-temporary.rs index 25c27e4b262..d2100e8d065 100644 --- a/src/test/run-pass/generic-temporary.rs +++ b/src/test/run-pass/generic-temporary.rs @@ -20,7 +20,7 @@ fn apply<T>(produce: extern fn() -> T, consume(produce()); } -fn main() { +pub fn main() { let produce: extern fn() -> int = mk; let consume: extern fn(&&v: int) = chk; apply::<int>(produce, consume); diff --git a/src/test/run-pass/generic-tup.rs b/src/test/run-pass/generic-tup.rs index d64e10a09af..8db1c4673bd 100644 --- a/src/test/run-pass/generic-tup.rs +++ b/src/test/run-pass/generic-tup.rs @@ -10,7 +10,7 @@ fn get_third<T: Copy>(t: (T, T, T)) -> T { let (_, _, x) = t; return x; } -fn main() { +pub fn main() { log(debug, get_third((1, 2, 3))); assert (get_third((1, 2, 3)) == 3); assert (get_third((5u8, 6u8, 7u8)) == 7u8); diff --git a/src/test/run-pass/generic-type-synonym.rs b/src/test/run-pass/generic-type-synonym.rs index 25da97a854f..662cfa110c4 100644 --- a/src/test/run-pass/generic-type-synonym.rs +++ b/src/test/run-pass/generic-type-synonym.rs @@ -16,4 +16,4 @@ type bar<T> = foo<T>; fn takebar<T>(b: bar<T>) { } -fn main() { } +pub fn main() { } diff --git a/src/test/run-pass/generic-type.rs b/src/test/run-pass/generic-type.rs index e0f6363eb6b..bc62b23bc48 100644 --- a/src/test/run-pass/generic-type.rs +++ b/src/test/run-pass/generic-type.rs @@ -12,7 +12,7 @@ struct Pair<T> {x: T, y: T} -fn main() { +pub fn main() { let x: Pair<int> = Pair {x: 10, y: 12}; assert (x.x == 10); assert (x.y == 12); diff --git a/src/test/run-pass/generic-unique.rs b/src/test/run-pass/generic-unique.rs index 01e899db23a..0ae417e711e 100644 --- a/src/test/run-pass/generic-unique.rs +++ b/src/test/run-pass/generic-unique.rs @@ -12,7 +12,7 @@ struct Triple<T> { x: T, y: T, z: T } fn box<T: Copy>(x: Triple<T>) -> ~Triple<T> { return ~x; } -fn main() { +pub fn main() { let x: ~Triple<int> = box::<int>(Triple{x: 1, y: 2, z: 3}); assert (x.y == 2); } diff --git a/src/test/run-pass/getopts_ref.rs b/src/test/run-pass/getopts_ref.rs index 166625ce1a8..baed91df020 100644 --- a/src/test/run-pass/getopts_ref.rs +++ b/src/test/run-pass/getopts_ref.rs @@ -14,14 +14,14 @@ extern mod std; use std::getopts::*; -fn main() { +pub fn main() { let args = ~[]; let opts = ~[optopt(~"b")]; match getopts(args, opts) { result::Ok(ref m) => assert !opt_present(m, "b"), - result::Err(ref f) => fail fail_str(copy *f) + result::Err(ref f) => die!(fail_str(copy *f)) }; } diff --git a/src/test/run-pass/global-scope.rs b/src/test/run-pass/global-scope.rs index 0da95be3106..8af3cf75a00 100644 --- a/src/test/run-pass/global-scope.rs +++ b/src/test/run-pass/global-scope.rs @@ -17,5 +17,5 @@ pub mod foo { pub fn g() { assert (f() == 2); assert (::f() == 1); } } -fn main() { return foo::g(); } +pub fn main() { return foo::g(); } diff --git a/src/test/run-pass/guards-not-exhaustive.rs b/src/test/run-pass/guards-not-exhaustive.rs index 66e48d1e7a9..5aac0ab3fed 100644 --- a/src/test/run-pass/guards-not-exhaustive.rs +++ b/src/test/run-pass/guards-not-exhaustive.rs @@ -8,6 +8,6 @@ fn xyzzy(q: Q) -> uint { } -fn main() { +pub fn main() { assert xyzzy(R(Some(5))) == 0; } diff --git a/src/test/run-pass/guards.rs b/src/test/run-pass/guards.rs index 2ba0660cc70..7aba929d626 100644 --- a/src/test/run-pass/guards.rs +++ b/src/test/run-pass/guards.rs @@ -10,7 +10,7 @@ struct Pair { x: int, y: int } -fn main() { +pub fn main() { let a = match 10 { x if x < 7 => { 1 } x if x < 11 => { 2 } 10 => { 3 } _ => { 4 } }; assert (a == 2); diff --git a/src/test/run-pass/hashmap-memory.rs b/src/test/run-pass/hashmap-memory.rs index 2f4d69ee856..43e2bee644a 100644 --- a/src/test/run-pass/hashmap-memory.rs +++ b/src/test/run-pass/hashmap-memory.rs @@ -18,15 +18,15 @@ extern mod std; -use std::map; -use std::map::HashMap; +use std::oldmap; +use std::oldmap::HashMap; use core::pipes::*; pub fn map(filename: ~str, emit: map_reduce::putter) { emit(filename, ~"1"); } mod map_reduce { - use std::map; - use std::map::HashMap; + use std::oldmap; + use std::oldmap::HashMap; use core::pipes::*; pub type putter = fn@(~str, ~str); @@ -44,9 +44,9 @@ mod map_reduce { } fn map_task(ctrl: SharedChan<ctrl_proto>, input: ~str) { - let intermediates = map::HashMap(); + let intermediates = oldmap::HashMap(); - fn emit(im: map::HashMap<~str, int>, ctrl: SharedChan<ctrl_proto>, key: ~str, + fn emit(im: oldmap::HashMap<~str, int>, ctrl: SharedChan<ctrl_proto>, key: ~str, val: ~str) { let mut c; match im.find(copy key) { @@ -75,9 +75,9 @@ mod map_reduce { // This task becomes the master control task. It spawns others // to do the rest. - let mut reducers: map::HashMap<~str, int>; + let mut reducers: oldmap::HashMap<~str, int>; - reducers = map::HashMap(); + reducers = oldmap::HashMap(); start_mappers(ctrl_chan, copy inputs); @@ -99,6 +99,6 @@ mod map_reduce { } } -fn main() { +pub fn main() { map_reduce::map_reduce(~[~"../src/test/run-pass/hashmap-memory.rs"]); } diff --git a/src/test/run-pass/hello.rs b/src/test/run-pass/hello.rs index 522e6c488b4..84d525dd0e6 100644 --- a/src/test/run-pass/hello.rs +++ b/src/test/run-pass/hello.rs @@ -10,6 +10,6 @@ // except according to those terms. -fn main() { +pub fn main() { io::println("hello, world"); } diff --git a/src/test/run-pass/html-literals.rs b/src/test/run-pass/html-literals.rs index 84f23e57796..42a4075d411 100644 --- a/src/test/run-pass/html-literals.rs +++ b/src/test/run-pass/html-literals.rs @@ -84,7 +84,7 @@ macro_rules! parse_node ( ( []; [:$e:expr]; ) => ( $e ); ) -fn main() { +pub fn main() { let page = html! ( <html> <head><title>This is the title.</title></head> diff --git a/src/test/run-pass/i32-sub.rs b/src/test/run-pass/i32-sub.rs index 28065febefe..a7364d7cf65 100644 --- a/src/test/run-pass/i32-sub.rs +++ b/src/test/run-pass/i32-sub.rs @@ -12,4 +12,4 @@ // -*- rust -*- -fn main() { let mut x: i32 = -400_i32; x = 0_i32 - x; assert (x == 400_i32); } +pub fn main() { let mut x: i32 = -400_i32; x = 0_i32 - x; assert (x == 400_i32); } diff --git a/src/test/run-pass/i8-incr.rs b/src/test/run-pass/i8-incr.rs index 7ea68e17b79..9f1a75dbf23 100644 --- a/src/test/run-pass/i8-incr.rs +++ b/src/test/run-pass/i8-incr.rs @@ -12,7 +12,7 @@ // -*- rust -*- -fn main() { +pub fn main() { let mut x: i8 = -12i8; let y: i8 = -12i8; x = x + 1i8; diff --git a/src/test/run-pass/if-bot.rs b/src/test/run-pass/if-bot.rs index 47aae4b8d7e..c830ff1e3eb 100644 --- a/src/test/run-pass/if-bot.rs +++ b/src/test/run-pass/if-bot.rs @@ -10,7 +10,7 @@ -fn main() { - let i: int = if false { fail } else { 5 }; +pub fn main() { + let i: int = if false { die!() } else { 5 }; log(debug, i); } diff --git a/src/test/run-pass/if-check.rs b/src/test/run-pass/if-check.rs index 486608cde19..b4170fa6acc 100644 --- a/src/test/run-pass/if-check.rs +++ b/src/test/run-pass/if-check.rs @@ -18,8 +18,8 @@ fn foo(x: uint) { if even(x) { log(debug, x); } else { - fail; + die!(); } } -fn main() { foo(2u); } +pub fn main() { foo(2u); } diff --git a/src/test/run-pass/if-ret.rs b/src/test/run-pass/if-ret.rs index 80e2236a6d8..b589c083a97 100644 --- a/src/test/run-pass/if-ret.rs +++ b/src/test/run-pass/if-ret.rs @@ -10,4 +10,4 @@ fn foo() { if (return) { } } -fn main() { foo(); } +pub fn main() { foo(); } diff --git a/src/test/run-pass/impl-implicit-trait.rs b/src/test/run-pass/impl-implicit-trait.rs index 56c5db747dc..8afa762c0a3 100644 --- a/src/test/run-pass/impl-implicit-trait.rs +++ b/src/test/run-pass/impl-implicit-trait.rs @@ -26,5 +26,5 @@ impl option__ { fn foo() -> bool { true } } -fn main() { +pub fn main() { } \ No newline at end of file diff --git a/src/test/run-pass/impl-privacy-xc-1.rs b/src/test/run-pass/impl-privacy-xc-1.rs new file mode 100644 index 00000000000..33f6cfa1b77 --- /dev/null +++ b/src/test/run-pass/impl-privacy-xc-1.rs @@ -0,0 +1,10 @@ +// aux-build:impl_privacy_xc_1.rs +// xfail-fast + +extern mod impl_privacy_xc_1; + +fn main() { + let fish = impl_privacy_xc_1::Fish { x: 1 }; + fish.swim(); +} + diff --git a/src/test/run-pass/impl-privacy-xc-2.rs b/src/test/run-pass/impl-privacy-xc-2.rs new file mode 100644 index 00000000000..8355d4c96ff --- /dev/null +++ b/src/test/run-pass/impl-privacy-xc-2.rs @@ -0,0 +1,11 @@ +// aux-build:impl_privacy_xc_2.rs +// xfail-fast + +extern mod impl_privacy_xc_2; + +fn main() { + let fish1 = impl_privacy_xc_2::Fish { x: 1 }; + let fish2 = impl_privacy_xc_2::Fish { x: 2 }; + io::println(if fish1.eq(&fish2) { "yes" } else { "no " }); +} + diff --git a/src/test/run-pass/impl-variance.rs b/src/test/run-pass/impl-variance.rs index 69e0a120865..972bd959a1d 100644 --- a/src/test/run-pass/impl-variance.rs +++ b/src/test/run-pass/impl-variance.rs @@ -16,11 +16,11 @@ impl<T> ~[const T]: foo { fn foo() -> uint { vec::len(self) } } -fn main() { +pub fn main() { let v = ~[const 0]; assert v.foo() == 1u; let v = ~[0]; assert v.foo() == 1u; - let v = ~[mut 0]; + let mut v = ~[0]; assert v.foo() == 1u; } diff --git a/src/test/run-pass/import-from-foreign.rs b/src/test/run-pass/import-from-foreign.rs index 11affd7f9e6..37447fe1408 100644 --- a/src/test/run-pass/import-from-foreign.rs +++ b/src/test/run-pass/import-from-foreign.rs @@ -20,4 +20,4 @@ extern mod rustrt { pub use spam::{ham, eggs}; } -fn main() { rustrt::ham(); rustrt::eggs(); } +pub fn main() { rustrt::ham(); rustrt::eggs(); } diff --git a/src/test/run-pass/import-from.rs b/src/test/run-pass/import-from.rs index 7b739fa9d66..5cc51a6461c 100644 --- a/src/test/run-pass/import-from.rs +++ b/src/test/run-pass/import-from.rs @@ -17,4 +17,4 @@ mod spam { pub fn eggs() { } } -fn main() { ham(); eggs(); } +pub fn main() { ham(); eggs(); } diff --git a/src/test/run-pass/import-glob-0.rs b/src/test/run-pass/import-glob-0.rs index 6e3d995ed41..5576824e13a 100644 --- a/src/test/run-pass/import-glob-0.rs +++ b/src/test/run-pass/import-glob-0.rs @@ -36,4 +36,4 @@ mod dug { } -fn main() { f1(); f2(); f4(); nameless_fear(); also_redstone(); } +pub fn main() { f1(); f2(); f4(); nameless_fear(); also_redstone(); } diff --git a/src/test/run-pass/import-glob-crate.rs b/src/test/run-pass/import-glob-crate.rs index eba69134c4f..ed532fab544 100644 --- a/src/test/run-pass/import-glob-crate.rs +++ b/src/test/run-pass/import-glob-crate.rs @@ -14,7 +14,7 @@ extern mod std; use core::vec::*; -fn main() { +pub fn main() { let mut v = from_elem(0u, 0); v = vec::append(v, ~[4, 2]); assert (reversed(v) == ~[2, 4]); diff --git a/src/test/run-pass/import-in-block.rs b/src/test/run-pass/import-in-block.rs index 56756086a26..a41633c0b82 100644 --- a/src/test/run-pass/import-in-block.rs +++ b/src/test/run-pass/import-in-block.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -fn main() { +pub fn main() { use vec::cast_to_mut; log(debug, vec::len(cast_to_mut(~[1, 2]))); { diff --git a/src/test/run-pass/import-trailing-comma.rs b/src/test/run-pass/import-trailing-comma.rs index d04212155a8..dcd843e9b12 100644 --- a/src/test/run-pass/import-trailing-comma.rs +++ b/src/test/run-pass/import-trailing-comma.rs @@ -19,4 +19,4 @@ mod foo { } } -fn main() { baz(); quux(); } +pub fn main() { baz(); quux(); } diff --git a/src/test/run-pass/import.rs b/src/test/run-pass/import.rs index 2379cca3111..be515172de1 100644 --- a/src/test/run-pass/import.rs +++ b/src/test/run-pass/import.rs @@ -20,4 +20,4 @@ mod bar { pub fn thing() { x(10); z(10); } } -fn main() { bar::thing(); } +pub fn main() { bar::thing(); } diff --git a/src/test/run-pass/import2.rs b/src/test/run-pass/import2.rs index 37c11b81b4a..7383d818ee7 100644 --- a/src/test/run-pass/import2.rs +++ b/src/test/run-pass/import2.rs @@ -17,4 +17,4 @@ mod zed { pub fn bar() { debug!("bar"); } } -fn main() { bar(); } +pub fn main() { bar(); } diff --git a/src/test/run-pass/import3.rs b/src/test/run-pass/import3.rs index 757034d4b41..dedb2f2a99d 100644 --- a/src/test/run-pass/import3.rs +++ b/src/test/run-pass/import3.rs @@ -20,4 +20,4 @@ mod baz { } } -fn main() { bar(); } +pub fn main() { bar(); } diff --git a/src/test/run-pass/import4.rs b/src/test/run-pass/import4.rs index 4ea180a1e25..41ed3549684 100644 --- a/src/test/run-pass/import4.rs +++ b/src/test/run-pass/import4.rs @@ -17,4 +17,4 @@ mod zed { pub fn bar() { debug!("bar"); } } -fn main() { let zed = 42; bar(); } +pub fn main() { let zed = 42; bar(); } diff --git a/src/test/run-pass/import5.rs b/src/test/run-pass/import5.rs index ab94fea0971..14061edc166 100644 --- a/src/test/run-pass/import5.rs +++ b/src/test/run-pass/import5.rs @@ -18,4 +18,4 @@ mod foo { } } -fn main() { bar(); } +pub fn main() { bar(); } diff --git a/src/test/run-pass/import6.rs b/src/test/run-pass/import6.rs index 2a789969bcb..88b839c0c08 100644 --- a/src/test/run-pass/import6.rs +++ b/src/test/run-pass/import6.rs @@ -20,4 +20,4 @@ mod foo { mod bar { pub use zed::baz; } -fn main() { baz(); } +pub fn main() { baz(); } diff --git a/src/test/run-pass/import7.rs b/src/test/run-pass/import7.rs index 91b0943a833..d5e15ea48e9 100644 --- a/src/test/run-pass/import7.rs +++ b/src/test/run-pass/import7.rs @@ -23,4 +23,4 @@ mod bar { pub mod zed {} } } -fn main() { baz(); } +pub fn main() { baz(); } diff --git a/src/test/run-pass/import8.rs b/src/test/run-pass/import8.rs index 4572f59aeea..229374c861e 100644 --- a/src/test/run-pass/import8.rs +++ b/src/test/run-pass/import8.rs @@ -18,4 +18,4 @@ mod foo { pub fn x(y: int) { log(debug, y); } } -fn main() { x(10); z(10); } +pub fn main() { x(10); z(10); } diff --git a/src/test/run-pass/infer-fn-tail-expr.rs b/src/test/run-pass/infer-fn-tail-expr.rs index 18f7d6d3793..eb8601361cd 100644 --- a/src/test/run-pass/infer-fn-tail-expr.rs +++ b/src/test/run-pass/infer-fn-tail-expr.rs @@ -12,4 +12,4 @@ fn f() -> ~[int] { ~[] } -fn main() { } +pub fn main() { } diff --git a/src/test/run-pass/infer-with-expected.rs b/src/test/run-pass/infer-with-expected.rs index c87987aac3a..bbb094d0cad 100644 --- a/src/test/run-pass/infer-with-expected.rs +++ b/src/test/run-pass/infer-with-expected.rs @@ -19,7 +19,7 @@ fn eat_rec(_r: @~Rec) {} struct Rec { a: int, b: fn(Pair) -> int } struct Pair { x: int, y: int } -fn main() { +pub fn main() { eat_tup(~@(10, |a| a.x )); eat_rec(@~Rec{a: 10, b: |a| a.x }); } diff --git a/src/test/run-pass/inferred-suffix-in-pattern-range.rs b/src/test/run-pass/inferred-suffix-in-pattern-range.rs index de6ad9bc68c..c72df610210 100644 --- a/src/test/run-pass/inferred-suffix-in-pattern-range.rs +++ b/src/test/run-pass/inferred-suffix-in-pattern-range.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -fn main() { +pub fn main() { let x = 2; let x_message = match x { 0 .. 1 => { ~"not many" } diff --git a/src/test/run-pass/infinite-loops.rs b/src/test/run-pass/infinite-loops.rs index 7a549183546..70a4cecf47a 100644 --- a/src/test/run-pass/infinite-loops.rs +++ b/src/test/run-pass/infinite-loops.rs @@ -27,4 +27,4 @@ fn loop(n: int) { loop { } } -fn main() { let t: task = spawn loop(5); join(t); } \ No newline at end of file +pub fn main() { let t: task = spawn loop(5); join(t); } \ No newline at end of file diff --git a/src/test/run-pass/init-res-into-things.rs b/src/test/run-pass/init-res-into-things.rs index 11efd61072c..965c14f7315 100644 --- a/src/test/run-pass/init-res-into-things.rs +++ b/src/test/run-pass/init-res-into-things.rs @@ -83,7 +83,7 @@ fn test_box_rec() { assert *i == 1; } -fn main() { +pub fn main() { test_box(); test_rec(); test_tag(); diff --git a/src/test/run-pass/inner-module.rs b/src/test/run-pass/inner-module.rs index 1754eddb2ca..042988c916f 100644 --- a/src/test/run-pass/inner-module.rs +++ b/src/test/run-pass/inner-module.rs @@ -19,4 +19,4 @@ mod inner { pub fn hello() { inner2::hello(); } } -fn main() { inner::hello(); inner::inner2::hello(); } +pub fn main() { inner::hello(); inner::inner2::hello(); } diff --git a/src/test/run-pass/instantiable.rs b/src/test/run-pass/instantiable.rs index 57065ec44a5..2230c2df9fc 100644 --- a/src/test/run-pass/instantiable.rs +++ b/src/test/run-pass/instantiable.rs @@ -15,7 +15,7 @@ enum foo = X; struct X { x: uint, nxt: *foo } -fn main() { +pub fn main() { let x = foo(X {x: 0, nxt: ptr::null()}); } diff --git a/src/test/run-pass/int-conversion-coherence.rs b/src/test/run-pass/int-conversion-coherence.rs index 75ae976d63d..d4d765dfc1d 100644 --- a/src/test/run-pass/int-conversion-coherence.rs +++ b/src/test/run-pass/int-conversion-coherence.rs @@ -20,7 +20,7 @@ trait plus { impl foo of plus for uint { fn plus() -> int { self as int + 20 } } impl foo of plus for int { fn plus() -> int { self + 10 } } -fn main() { +pub fn main() { assert 10.plus() == 20; } diff --git a/src/test/run-pass/int.rs b/src/test/run-pass/int.rs index 11f3c92c0a5..33239a1441c 100644 --- a/src/test/run-pass/int.rs +++ b/src/test/run-pass/int.rs @@ -12,4 +12,4 @@ // -*- rust -*- -fn main() { let x: int = 10; } +pub fn main() { let x: int = 10; } diff --git a/src/test/run-pass/integer-literal-suffix-inference.rs b/src/test/run-pass/integer-literal-suffix-inference.rs index dd40e0af29b..542efe33459 100644 --- a/src/test/run-pass/integer-literal-suffix-inference.rs +++ b/src/test/run-pass/integer-literal-suffix-inference.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -fn main() { +pub fn main() { fn id_i8(n: i8) -> i8 { n } fn id_i16(n: i16) -> i16 { n } fn id_i32(n: i32) -> i32 { n } diff --git a/src/test/run-pass/integral-indexing.rs b/src/test/run-pass/integral-indexing.rs index 0f5705e826f..7673cc034d1 100644 --- a/src/test/run-pass/integral-indexing.rs +++ b/src/test/run-pass/integral-indexing.rs @@ -12,7 +12,7 @@ // This is a testcase for issue #94. -fn main() { +pub fn main() { let v: ~[int] = ~[0, 1, 2, 3, 4, 5]; let s: ~str = ~"abcdef"; assert (v[3u] == 3); diff --git a/src/test/run-pass/intrinsic-atomics-cc.rs b/src/test/run-pass/intrinsic-atomics-cc.rs index 86b120ca273..24a4de89b45 100644 --- a/src/test/run-pass/intrinsic-atomics-cc.rs +++ b/src/test/run-pass/intrinsic-atomics-cc.rs @@ -14,7 +14,7 @@ extern mod cci_intrinsic; use cci_intrinsic::atomic_xchg; -fn main() { +pub fn main() { unsafe { let mut x = 1; atomic_xchg(&mut x, 5); diff --git a/src/test/run-pass/intrinsic-atomics.rs b/src/test/run-pass/intrinsic-atomics.rs index bee9e1dd1dd..eb10a51c0bd 100644 --- a/src/test/run-pass/intrinsic-atomics.rs +++ b/src/test/run-pass/intrinsic-atomics.rs @@ -27,7 +27,7 @@ extern mod rusti { pub fn atomic_xsub_rel(dst: &mut int, src: int) -> int; } -fn main() { +pub fn main() { unsafe { let x = ~mut 1; diff --git a/src/test/run-pass/intrinsic-frame-address.rs b/src/test/run-pass/intrinsic-frame-address.rs index 603f3d7dc81..36fbc87ccdb 100644 --- a/src/test/run-pass/intrinsic-frame-address.rs +++ b/src/test/run-pass/intrinsic-frame-address.rs @@ -15,7 +15,7 @@ extern mod rusti { pub fn frame_address(f: &once fn(*u8)); } -fn main() { +pub fn main() { unsafe { do rusti::frame_address |addr| { assert addr.is_not_null(); diff --git a/src/test/run-pass/intrinsic-move-val.rs b/src/test/run-pass/intrinsic-move-val.rs index 3761d873fe2..b17eb37438a 100644 --- a/src/test/run-pass/intrinsic-move-val.rs +++ b/src/test/run-pass/intrinsic-move-val.rs @@ -14,7 +14,7 @@ extern mod rusti { pub fn move_val<T>(dst: &mut T, -src: T); } -fn main() { +pub fn main() { unsafe { let mut x = @1; let mut y = @2; diff --git a/src/test/run-pass/intrinsics-integer.rs b/src/test/run-pass/intrinsics-integer.rs index 08b976a9096..6a9d66e16a2 100644 --- a/src/test/run-pass/intrinsics-integer.rs +++ b/src/test/run-pass/intrinsics-integer.rs @@ -34,7 +34,7 @@ extern mod rusti { fn bswap64(x: i64) -> i64; } -fn main() { +pub fn main() { unsafe { use rusti::*; diff --git a/src/test/run-pass/intrinsics-math.rs b/src/test/run-pass/intrinsics-math.rs index 61594d19a6d..6b80da4afff 100644 --- a/src/test/run-pass/intrinsics-math.rs +++ b/src/test/run-pass/intrinsics-math.rs @@ -48,7 +48,7 @@ extern mod rusti { fn truncf64(x: f64) -> f64; } -fn main() { +pub fn main() { unsafe { use rusti::*; diff --git a/src/test/run-pass/invoke-external-foreign.rs b/src/test/run-pass/invoke-external-foreign.rs index 17da3de7d55..cc50e06199d 100644 --- a/src/test/run-pass/invoke-external-foreign.rs +++ b/src/test/run-pass/invoke-external-foreign.rs @@ -17,6 +17,6 @@ extern mod foreign_lib; -fn main() { +pub fn main() { let foo = foreign_lib::rustrt::last_os_error(); } diff --git a/src/test/run-pass/irrefutable-unit.rs b/src/test/run-pass/irrefutable-unit.rs index 102338dcbc0..51adeea394c 100644 --- a/src/test/run-pass/irrefutable-unit.rs +++ b/src/test/run-pass/irrefutable-unit.rs @@ -8,6 +8,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -fn main() { +pub fn main() { let ((),()) = ((),()); } diff --git a/src/test/run-pass/issue-1112.rs b/src/test/run-pass/issue-1112.rs index a29d6d1e3e4..e2a91910975 100644 --- a/src/test/run-pass/issue-1112.rs +++ b/src/test/run-pass/issue-1112.rs @@ -21,7 +21,7 @@ struct X<T> { g: u8 } -fn main() { +pub fn main() { let x: X<int> = X { a: 12345678, b: 9u8, diff --git a/src/test/run-pass/issue-1251.rs b/src/test/run-pass/issue-1251.rs index bc330902b76..27b41c510d6 100644 --- a/src/test/run-pass/issue-1251.rs +++ b/src/test/run-pass/issue-1251.rs @@ -14,4 +14,4 @@ extern mod rustrt { pub fn get_task_id() -> libc::intptr_t; } -fn main() { } +pub fn main() { } diff --git a/src/test/run-pass/issue-1458.rs b/src/test/run-pass/issue-1458.rs index 15d809e8208..b5c8a0d3138 100644 --- a/src/test/run-pass/issue-1458.rs +++ b/src/test/run-pass/issue-1458.rs @@ -16,7 +16,7 @@ fn ret_plus_one() -> extern fn(fn() -> int) -> int { return plus_one; } -fn main() { +pub fn main() { let z = do (ret_plus_one()) || { 2 }; assert z == 3; } diff --git a/src/test/run-pass/issue-1460.rs b/src/test/run-pass/issue-1460.rs index 216093cd7aa..44465fe5f80 100644 --- a/src/test/run-pass/issue-1460.rs +++ b/src/test/run-pass/issue-1460.rs @@ -9,6 +9,6 @@ // except according to those terms. -fn main() { +pub fn main() { {|i| if 1 == i { }}; } diff --git a/src/test/run-pass/issue-1466.rs b/src/test/run-pass/issue-1466.rs index b719f4f3df7..1915f1b3a41 100644 --- a/src/test/run-pass/issue-1466.rs +++ b/src/test/run-pass/issue-1466.rs @@ -11,7 +11,7 @@ // exec-env:RUST_CC_ZEAL=1 // xfail-test -fn main() { +pub fn main() { error!("%?", os::getenv(~"RUST_CC_ZEAL")); let _x = @{a: @10, b: ~true}; } diff --git a/src/test/run-pass/issue-1516.rs b/src/test/run-pass/issue-1516.rs index 209e7e42a2e..d36cb993092 100644 --- a/src/test/run-pass/issue-1516.rs +++ b/src/test/run-pass/issue-1516.rs @@ -9,5 +9,5 @@ // except according to those terms. // xfail-test -fn main() { let early_error: fn@(str) -> ! = {|msg| fail }; } +pub fn main() { let early_error: fn@(str) -> ! = {|msg| die!() }; } diff --git a/src/test/run-pass/issue-1660.rs b/src/test/run-pass/issue-1660.rs index 8d55fe36d68..da8dfbf6792 100644 --- a/src/test/run-pass/issue-1660.rs +++ b/src/test/run-pass/issue-1660.rs @@ -8,6 +8,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -fn main() { +pub fn main() { const _x: int = 1<<2; } diff --git a/src/test/run-pass/issue-1696.rs b/src/test/run-pass/issue-1696.rs index 72ce678cd23..fb61e34f351 100644 --- a/src/test/run-pass/issue-1696.rs +++ b/src/test/run-pass/issue-1696.rs @@ -11,11 +11,10 @@ // except according to those terms. extern mod std; -use std::map; -use std::map::HashMap; +use std::oldmap::HashMap; -fn main() { - let m = map::HashMap(); +pub fn main() { + let m = HashMap(); m.insert(str::to_bytes(~"foo"), str::to_bytes(~"bar")); log(error, m); } diff --git a/src/test/run-pass/issue-1701.rs b/src/test/run-pass/issue-1701.rs index 0e0ab115327..33caaf1b53f 100644 --- a/src/test/run-pass/issue-1701.rs +++ b/src/test/run-pass/issue-1701.rs @@ -23,7 +23,7 @@ fn noise(a: animal) -> Option<~str> { } } -fn main() { +pub fn main() { assert noise(cat(tabby)) == Some(~"meow"); assert noise(dog(pug)) == Some(~"woof"); assert noise(rabbit(~"Hilbert", upright)) == None; diff --git a/src/test/run-pass/issue-1821.rs b/src/test/run-pass/issue-1821.rs index f0f9eb5014f..092d2b05cb7 100644 --- a/src/test/run-pass/issue-1821.rs +++ b/src/test/run-pass/issue-1821.rs @@ -12,4 +12,4 @@ enum t { foo(~[t]) } -fn main() {} \ No newline at end of file +pub fn main() {} \ No newline at end of file diff --git a/src/test/run-pass/issue-1866.rs b/src/test/run-pass/issue-1866.rs index 72fc38e9a0f..9fa8aa39fda 100644 --- a/src/test/run-pass/issue-1866.rs +++ b/src/test/run-pass/issue-1866.rs @@ -23,4 +23,4 @@ mod b { } } -fn main() { } +pub fn main() { } diff --git a/src/test/run-pass/issue-1895.rs b/src/test/run-pass/issue-1895.rs index 4557d063e1b..3d20eb813d8 100644 --- a/src/test/run-pass/issue-1895.rs +++ b/src/test/run-pass/issue-1895.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -fn main() { +pub fn main() { let x = 1; let y = fn@(move x) -> int { x diff --git a/src/test/run-pass/issue-1974.rs b/src/test/run-pass/issue-1974.rs index c41e14a16de..a28d5a205e9 100644 --- a/src/test/run-pass/issue-1974.rs +++ b/src/test/run-pass/issue-1974.rs @@ -10,7 +10,7 @@ // Issue 1974 // Don't double free the condition allocation -fn main() { +pub fn main() { let s = ~"hej"; while s != ~"" { return; diff --git a/src/test/run-pass/issue-1989.rs b/src/test/run-pass/issue-1989.rs index ab0e0aa1aba..f941a9002ef 100644 --- a/src/test/run-pass/issue-1989.rs +++ b/src/test/run-pass/issue-1989.rs @@ -27,7 +27,7 @@ fn empty_pointy() -> @Pointy { } } -fn main() +pub fn main() { let v = ~[empty_pointy(), empty_pointy()]; v[0].a = p(v[0]); diff --git a/src/test/run-pass/issue-2101.rs b/src/test/run-pass/issue-2101.rs index c9df6fcd3e0..4564e089147 100644 --- a/src/test/run-pass/issue-2101.rs +++ b/src/test/run-pass/issue-2101.rs @@ -19,7 +19,7 @@ fn init(ar: &a.arena::Arena, str: str) -> &a.hold { new(*ar) s(str) } -fn main(args: ~[str]) { +pub fn main(args: ~[str]) { let ar = arena::Arena(); let leak = init(&ar, args[0]); match *leak { diff --git a/src/test/run-pass/issue-2185.rs b/src/test/run-pass/issue-2185.rs index 8e34936384b..e24defbf40c 100644 --- a/src/test/run-pass/issue-2185.rs +++ b/src/test/run-pass/issue-2185.rs @@ -50,7 +50,7 @@ fn range(lo: uint, hi: uint, it: fn(uint)) { } } -fn main() { +pub fn main() { let range: fn@(fn&(uint)) = |a| range(0u, 1000u, a); let filt: fn@(fn&(&&v: uint)) = |a| filter( range, diff --git a/src/test/run-pass/issue-2190-1.rs b/src/test/run-pass/issue-2190-1.rs index 16231009620..82d4eea3af4 100644 --- a/src/test/run-pass/issue-2190-1.rs +++ b/src/test/run-pass/issue-2190-1.rs @@ -19,6 +19,6 @@ fn child_no(x: uint) -> fn~() { } } -fn main() { +pub fn main() { task::spawn(child_no(0)); } diff --git a/src/test/run-pass/issue-2190-2.rs b/src/test/run-pass/issue-2190-2.rs index 831fe086a02..b28055eca27 100644 --- a/src/test/run-pass/issue-2190-2.rs +++ b/src/test/run-pass/issue-2190-2.rs @@ -12,20 +12,20 @@ mod a { fn foo(f: fn&()) { f() } fn bar() {} -fn main() { foo(||bar()); } +pub fn main() { foo(||bar()); } } mod b { fn foo(f: Option<fn&()>) { f.iter(|x|x()) } fn bar() {} -fn main() { foo(Some(bar)); } +pub fn main() { foo(Some(bar)); } } mod c { fn foo(f: Option<fn&()>) { f.iter(|x|x()) } fn bar() {} -fn main() { foo(Some(||bar())); } +pub fn main() { foo(Some(||bar())); } } -fn main() { +pub fn main() { } \ No newline at end of file diff --git a/src/test/run-pass/issue-2190.rs b/src/test/run-pass/issue-2190.rs index 3e07efe544a..2e956e0be5e 100644 --- a/src/test/run-pass/issue-2190.rs +++ b/src/test/run-pass/issue-2190.rs @@ -13,6 +13,6 @@ type t = { f: fn~() }; -fn main() { +pub fn main() { let _t: t = { f: {||()} }; } diff --git a/src/test/run-pass/issue-2196.rs b/src/test/run-pass/issue-2196.rs index 18a5be1e4a9..3fce821561a 100644 --- a/src/test/run-pass/issue-2196.rs +++ b/src/test/run-pass/issue-2196.rs @@ -16,4 +16,4 @@ use c(name = "issue2196c"); use c::t; -fn main() { } +pub fn main() { } diff --git a/src/test/run-pass/issue-2214.rs b/src/test/run-pass/issue-2214.rs index e8d07b4b2ad..8abe49dd45c 100644 --- a/src/test/run-pass/issue-2214.rs +++ b/src/test/run-pass/issue-2214.rs @@ -38,7 +38,7 @@ extern mod m { } -fn main() { +pub fn main() { let mut y: int = 5; let x: &mut int = &mut y; assert (lgamma(1.0 as c_double, x) == 0.0 as c_double); diff --git a/src/test/run-pass/issue-2216.rs b/src/test/run-pass/issue-2216.rs index 858f4ccc920..730646e4075 100644 --- a/src/test/run-pass/issue-2216.rs +++ b/src/test/run-pass/issue-2216.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -fn main() { +pub fn main() { let mut x = 0; loop foo: { diff --git a/src/test/run-pass/issue-2284.rs b/src/test/run-pass/issue-2284.rs index 36009957239..e2484433448 100644 --- a/src/test/run-pass/issue-2284.rs +++ b/src/test/run-pass/issue-2284.rs @@ -16,5 +16,5 @@ fn f<T: Send>(t: T) { t.f(); } -fn main() { +pub fn main() { } \ No newline at end of file diff --git a/src/test/run-pass/issue-2288.rs b/src/test/run-pass/issue-2288.rs index 0fa06e2f212..a77bbe150ab 100644 --- a/src/test/run-pass/issue-2288.rs +++ b/src/test/run-pass/issue-2288.rs @@ -30,7 +30,7 @@ fn f<A: Copy>(x: clam<A>, a: A) { x.chowder(a); } -fn main() { +pub fn main() { let c = foo(42); let d: clam<int> = c as clam::<int>; diff --git a/src/test/run-pass/issue-2311-2.rs b/src/test/run-pass/issue-2311-2.rs index 21201d0a957..0e974a8e6a8 100644 --- a/src/test/run-pass/issue-2311-2.rs +++ b/src/test/run-pass/issue-2311-2.rs @@ -15,7 +15,7 @@ struct foo<A> { impl<A: Copy> foo<A> { fn bar<B,C:clam<A>>(c: C) -> B { - fail; + die!(); } } @@ -25,4 +25,4 @@ fn foo<A: Copy>(b: A) -> foo<A> { } } -fn main() { } +pub fn main() { } diff --git a/src/test/run-pass/issue-2311.rs b/src/test/run-pass/issue-2311.rs index 9e0e6041e14..f3ced02c122 100644 --- a/src/test/run-pass/issue-2311.rs +++ b/src/test/run-pass/issue-2311.rs @@ -13,4 +13,4 @@ trait foo<A> { fn bar<B,C:clam<A>>(c: C) -> B; } -fn main() { } +pub fn main() { } diff --git a/src/test/run-pass/issue-2312.rs b/src/test/run-pass/issue-2312.rs index 3a6d8f38d48..f491d5f86fa 100644 --- a/src/test/run-pass/issue-2312.rs +++ b/src/test/run-pass/issue-2312.rs @@ -15,7 +15,7 @@ trait clam<A> { } enum foo = int; impl foo { - fn bar<B,C:clam<B>>(c: C) -> B { fail; } + fn bar<B,C:clam<B>>(c: C) -> B { die!(); } } -fn main() { } \ No newline at end of file +pub fn main() { } diff --git a/src/test/run-pass/issue-2316-c.rs b/src/test/run-pass/issue-2316-c.rs index a42557ea129..4a12440040c 100644 --- a/src/test/run-pass/issue-2316-c.rs +++ b/src/test/run-pass/issue-2316-c.rs @@ -15,6 +15,6 @@ extern mod issue_2316_b; use issue_2316_b::cloth; -fn main() { +pub fn main() { let _c: cloth::fabric = cloth::calico; } \ No newline at end of file diff --git a/src/test/run-pass/issue-2380-b.rs b/src/test/run-pass/issue-2380-b.rs index 8ea26f41b21..d61622e6b0f 100644 --- a/src/test/run-pass/issue-2380-b.rs +++ b/src/test/run-pass/issue-2380-b.rs @@ -13,6 +13,6 @@ extern mod a; -fn main() { +pub fn main() { a::f::<()>(); } diff --git a/src/test/run-pass/issue-2383.rs b/src/test/run-pass/issue-2383.rs index eb7506aa3d2..e45d9d60555 100644 --- a/src/test/run-pass/issue-2383.rs +++ b/src/test/run-pass/issue-2383.rs @@ -14,7 +14,7 @@ extern mod std; use std::deque; use std::deque::Deque; -fn main() { +pub fn main() { let Q = deque::create(); Q.add_back(10); } diff --git a/src/test/run-pass/issue-2414-c.rs b/src/test/run-pass/issue-2414-c.rs index 5bb43e2d9db..1bc88e74f7f 100644 --- a/src/test/run-pass/issue-2414-c.rs +++ b/src/test/run-pass/issue-2414-c.rs @@ -14,4 +14,4 @@ extern mod b; -fn main() {} +pub fn main() {} diff --git a/src/test/run-pass/issue-2428.rs b/src/test/run-pass/issue-2428.rs index d4f131f06e7..d8b11dc0113 100644 --- a/src/test/run-pass/issue-2428.rs +++ b/src/test/run-pass/issue-2428.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -fn main() { +pub fn main() { let foo = 100; const quux: int = 5; diff --git a/src/test/run-pass/issue-2445-b.rs b/src/test/run-pass/issue-2445-b.rs index f1b7d45e440..2fce24c0670 100644 --- a/src/test/run-pass/issue-2445-b.rs +++ b/src/test/run-pass/issue-2445-b.rs @@ -29,7 +29,7 @@ impl<T: Copy> c1<T> { } -fn main() { +pub fn main() { c1::<int>(3).f1(4); c1::<int>(3).f2(4); } diff --git a/src/test/run-pass/issue-2445.rs b/src/test/run-pass/issue-2445.rs index fada6a7b02e..ea1cec61867 100644 --- a/src/test/run-pass/issue-2445.rs +++ b/src/test/run-pass/issue-2445.rs @@ -27,7 +27,7 @@ impl<T: Copy> c1<T> { } -fn main() { +pub fn main() { c1::<int>(3).f1(4); c1::<int>(3).f2(4); } diff --git a/src/test/run-pass/issue-2463.rs b/src/test/run-pass/issue-2463.rs index b787677db68..9b774ed5243 100644 --- a/src/test/run-pass/issue-2463.rs +++ b/src/test/run-pass/issue-2463.rs @@ -10,7 +10,7 @@ struct Pair { f: int, g: int } -fn main() { +pub fn main() { let x = Pair { f: 0, diff --git a/src/test/run-pass/issue-2472.rs b/src/test/run-pass/issue-2472.rs index dc5bc42295b..db116cded11 100644 --- a/src/test/run-pass/issue-2472.rs +++ b/src/test/run-pass/issue-2472.rs @@ -15,7 +15,7 @@ extern mod issue_2472_b; use issue_2472_b::{S, T}; -fn main() { +pub fn main() { let s = S(()); s.foo(); s.bar(); diff --git a/src/test/run-pass/issue-2487-a.rs b/src/test/run-pass/issue-2487-a.rs index 8a35894ae09..62fef8202aa 100644 --- a/src/test/run-pass/issue-2487-a.rs +++ b/src/test/run-pass/issue-2487-a.rs @@ -36,4 +36,4 @@ fn closure(f: fn()) { f() } fn setsockopt_bytes(_sock: int) { } -fn main() {} +pub fn main() {} diff --git a/src/test/run-pass/issue-2502.rs b/src/test/run-pass/issue-2502.rs index d6385ccb378..7696ec37217 100644 --- a/src/test/run-pass/issue-2502.rs +++ b/src/test/run-pass/issue-2502.rs @@ -24,4 +24,4 @@ fn font(fontbuf: &r/~[u8]) -> font/&r { } } -fn main() { } +pub fn main() { } diff --git a/src/test/run-pass/issue-2526-a.rs b/src/test/run-pass/issue-2526-a.rs index 739c5a04692..c91b5dd303c 100644 --- a/src/test/run-pass/issue-2526-a.rs +++ b/src/test/run-pass/issue-2526-a.rs @@ -14,5 +14,5 @@ extern mod issue_2526; use issue_2526::*; -fn main() {} +pub fn main() {} diff --git a/src/test/run-pass/issue-2550.rs b/src/test/run-pass/issue-2550.rs index 4e9e21b29bf..f5977713890 100644 --- a/src/test/run-pass/issue-2550.rs +++ b/src/test/run-pass/issue-2550.rs @@ -22,6 +22,6 @@ fn f<T:Copy>(_x: T) { } #[deny(non_implicitly_copyable_typarams)] -fn main() { +pub fn main() { f(C(1u)); } diff --git a/src/test/run-pass/issue-2611.rs b/src/test/run-pass/issue-2611.rs index 0a8bd250bb5..de03e3382a6 100644 --- a/src/test/run-pass/issue-2611.rs +++ b/src/test/run-pass/issue-2611.rs @@ -20,4 +20,4 @@ impl<A:Copy> BaseIter<A>: FlatMapToVec<A> { } } -fn main() {} +pub fn main() {} diff --git a/src/test/run-pass/issue-2631-b.rs b/src/test/run-pass/issue-2631-b.rs index 810ac8efaf7..79c884f869f 100644 --- a/src/test/run-pass/issue-2631-b.rs +++ b/src/test/run-pass/issue-2631-b.rs @@ -15,10 +15,10 @@ extern mod req; extern mod std; use req::*; -use std::map::*; -use std::map::HashMap; +use std::oldmap::*; +use std::oldmap::HashMap; -fn main() { +pub fn main() { let v = ~[@~"hi"]; let m: req::header_map = HashMap(); m.insert(~"METHOD", @dvec::from_vec(v)); diff --git a/src/test/run-pass/issue-2633-2.rs b/src/test/run-pass/issue-2633-2.rs index a676e6d83e0..5c3a2f0a4f6 100644 --- a/src/test/run-pass/issue-2633-2.rs +++ b/src/test/run-pass/issue-2633-2.rs @@ -12,7 +12,7 @@ fn a_val(&&x: ~int, +y: ~int) -> int { *x + *y } -fn main() { +pub fn main() { let z = ~22; a_val(copy z, copy z); } diff --git a/src/test/run-pass/issue-2633.rs b/src/test/run-pass/issue-2633.rs index e209a9a03ed..8ff51b0c28e 100644 --- a/src/test/run-pass/issue-2633.rs +++ b/src/test/run-pass/issue-2633.rs @@ -25,7 +25,7 @@ fn nyan(kitty: cat, _kitty_info: KittyInfo) { (kitty.meow)(); } -fn main() { +pub fn main() { let mut kitty = cat(); nyan(copy kitty, KittyInfo {kitty: copy kitty}); } diff --git a/src/test/run-pass/issue-2642.rs b/src/test/run-pass/issue-2642.rs index e43fad50be9..dc601554542 100644 --- a/src/test/run-pass/issue-2642.rs +++ b/src/test/run-pass/issue-2642.rs @@ -12,5 +12,5 @@ fn f() { let _x: uint = loop { loop { break; } }; } -fn main() { +pub fn main() { } diff --git a/src/test/run-pass/issue-2708.rs b/src/test/run-pass/issue-2708.rs index 45f9eabcf2f..f16a65c9309 100644 --- a/src/test/run-pass/issue-2708.rs +++ b/src/test/run-pass/issue-2708.rs @@ -27,6 +27,6 @@ fn Font() -> Font { } } -fn main() { +pub fn main() { let _f = @Font(); } diff --git a/src/test/run-pass/issue-2718.rs b/src/test/run-pass/issue-2718.rs index 68a318eab4e..0827d280cf7 100644 --- a/src/test/run-pass/issue-2718.rs +++ b/src/test/run-pass/issue-2718.rs @@ -53,9 +53,9 @@ pub mod pipes { #[abi = "rust-intrinsic"] mod rusti { - pub fn atomic_xchg(_dst: &mut int, _src: int) -> int { fail; } - pub fn atomic_xchg_acq(_dst: &mut int, _src: int) -> int { fail; } - pub fn atomic_xchg_rel(_dst: &mut int, _src: int) -> int { fail; } + pub fn atomic_xchg(_dst: &mut int, _src: int) -> int { die!(); } + pub fn atomic_xchg_acq(_dst: &mut int, _src: int) -> int { die!(); } + pub fn atomic_xchg_rel(_dst: &mut int, _src: int) -> int { die!(); } } // We should consider moving this to ::core::unsafe, although I @@ -89,7 +89,7 @@ pub mod pipes { // The receiver will eventually clean this up. unsafe { forget(move p); } } - full => { fail ~"duplicate send" } + full => { die!(~"duplicate send") } blocked => { // The receiver will eventually clean this up. @@ -132,7 +132,7 @@ pub mod pipes { } full => { // This is impossible - fail ~"you dun goofed" + die!(~"you dun goofed") } terminated => { // I have to clean up, use drop_glue @@ -149,7 +149,7 @@ pub mod pipes { } blocked => { // this shouldn't happen. - fail ~"terminating a blocked packet" + die!(~"terminating a blocked packet") } terminated | full => { // I have to clean up, use drop_glue @@ -269,7 +269,7 @@ pub mod pingpong { pub fn do_pong(-c: pong) -> (ping, ()) { let packet = ::pipes::recv(move c); if packet.is_none() { - fail ~"sender closed the connection" + die!(~"sender closed the connection") } (pingpong::liberate_pong(option::unwrap(move packet)), ()) } @@ -284,7 +284,7 @@ pub mod pingpong { pub fn do_ping(-c: ping) -> (pong, ()) { let packet = ::pipes::recv(move c); if packet.is_none() { - fail ~"sender closed the connection" + die!(~"sender closed the connection") } (pingpong::liberate_ping(option::unwrap(move packet)), ()) } @@ -311,7 +311,7 @@ fn server(-chan: pingpong::server::ping) { log(error, ~"Sent pong"); } -fn main() { +pub fn main() { /* // Commented out because of option::get error diff --git a/src/test/run-pass/issue-2723-b.rs b/src/test/run-pass/issue-2723-b.rs index 9a0fbdfb77a..2ca56ae0b7a 100644 --- a/src/test/run-pass/issue-2723-b.rs +++ b/src/test/run-pass/issue-2723-b.rs @@ -14,7 +14,7 @@ extern mod issue_2723_a; use issue_2723_a::*; -fn main() { +pub fn main() { unsafe { f(~[2]); } diff --git a/src/test/run-pass/issue-2734.rs b/src/test/run-pass/issue-2734.rs index 0ab6c630ac8..d389ff34abe 100644 --- a/src/test/run-pass/issue-2734.rs +++ b/src/test/run-pass/issue-2734.rs @@ -19,6 +19,6 @@ fn deadcode() { perform_hax(@~"deadcode"); } -fn main() { +pub fn main() { let _ = perform_hax(@42); } diff --git a/src/test/run-pass/issue-2735-2.rs b/src/test/run-pass/issue-2735-2.rs index 3f9a27c6b78..21bd5e2ebc1 100644 --- a/src/test/run-pass/issue-2735-2.rs +++ b/src/test/run-pass/issue-2735-2.rs @@ -25,7 +25,7 @@ fn defer(b: &r/mut bool) -> defer/&r { } } -fn main() { +pub fn main() { let mut dtor_ran = false; let _ = defer(&mut dtor_ran); assert(dtor_ran); diff --git a/src/test/run-pass/issue-2735-3.rs b/src/test/run-pass/issue-2735-3.rs index e7f986bf7fe..6a706404e33 100644 --- a/src/test/run-pass/issue-2735-3.rs +++ b/src/test/run-pass/issue-2735-3.rs @@ -25,7 +25,7 @@ fn defer(b: &r/mut bool) -> defer/&r { } } -fn main() { +pub fn main() { let mut dtor_ran = false; defer(&mut dtor_ran); assert(dtor_ran); diff --git a/src/test/run-pass/issue-2735.rs b/src/test/run-pass/issue-2735.rs index 675397a0881..709227c83e3 100644 --- a/src/test/run-pass/issue-2735.rs +++ b/src/test/run-pass/issue-2735.rs @@ -19,6 +19,6 @@ fn deadcode() { perform_hax(@~"deadcode"); } -fn main() { +pub fn main() { perform_hax(@42); } diff --git a/src/test/run-pass/issue-2748-a.rs b/src/test/run-pass/issue-2748-a.rs index b08d3ce686a..bdf9109abd9 100644 --- a/src/test/run-pass/issue-2748-a.rs +++ b/src/test/run-pass/issue-2748-a.rs @@ -18,4 +18,4 @@ fn CMap(buf: &r/[u8]) -> CMap/&r { } } -fn main() { } +pub fn main() { } diff --git a/src/test/run-pass/issue-2748-b.rs b/src/test/run-pass/issue-2748-b.rs index dc1d7c4056f..f5720881221 100644 --- a/src/test/run-pass/issue-2748-b.rs +++ b/src/test/run-pass/issue-2748-b.rs @@ -9,7 +9,7 @@ // except according to those terms. fn thing(x: &r/[int]) -> &r/[int] { x } -fn main() { +pub fn main() { let x = &[1,2,3]; let y = x; let z = thing(x); diff --git a/src/test/run-pass/issue-2804-2.rs b/src/test/run-pass/issue-2804-2.rs index c79b59f7cd9..9fe88227c44 100644 --- a/src/test/run-pass/issue-2804-2.rs +++ b/src/test/run-pass/issue-2804-2.rs @@ -13,10 +13,10 @@ // Minimized version of issue-2804.rs. Both check that callee IDs don't // clobber the previous node ID in a macro expr extern mod std; -use std::map::HashMap; +use std::oldmap::HashMap; -fn add_interfaces(managed_ip: ~str, device: std::map::HashMap<~str, int>) { +fn add_interfaces(managed_ip: ~str, device: std::oldmap::HashMap<~str, int>) { error!("%s, %?", managed_ip, device[~"interfaces"]); } -fn main() {} +pub fn main() {} diff --git a/src/test/run-pass/issue-2804.rs b/src/test/run-pass/issue-2804.rs index 4ea59fc4b69..613652ec852 100644 --- a/src/test/run-pass/issue-2804.rs +++ b/src/test/run-pass/issue-2804.rs @@ -12,7 +12,7 @@ extern mod std; use io::WriterUtil; -use std::map::HashMap; +use std::oldmap::HashMap; use std::json; enum object @@ -60,7 +60,7 @@ fn add_interface(store: int, managed_ip: ~str, data: std::json::Json) -> (~str, } } -fn add_interfaces(store: int, managed_ip: ~str, device: std::map::HashMap<~str, std::json::Json>) -> ~[(~str, object)] +fn add_interfaces(store: int, managed_ip: ~str, device: std::oldmap::HashMap<~str, std::json::Json>) -> ~[(~str, object)] { match device[~"interfaces"] { @@ -78,4 +78,4 @@ fn add_interfaces(store: int, managed_ip: ~str, device: std::map::HashMap<~str, } } -fn main() {} +pub fn main() {} diff --git a/src/test/run-pass/issue-2834.rs b/src/test/run-pass/issue-2834.rs index dad0427adcc..b78cefe1c95 100644 --- a/src/test/run-pass/issue-2834.rs +++ b/src/test/run-pass/issue-2834.rs @@ -24,7 +24,7 @@ fn rendezvous() { error!("%?", streams[0]); } -fn main() { +pub fn main() { //os::getenv("FOO"); rendezvous(); } diff --git a/src/test/run-pass/issue-2869.rs b/src/test/run-pass/issue-2869.rs index fddc41a3761..619f4b4d7db 100644 --- a/src/test/run-pass/issue-2869.rs +++ b/src/test/run-pass/issue-2869.rs @@ -21,4 +21,4 @@ fn num_bindings(pat: pat) -> uint { } } -fn main() {} +pub fn main() {} diff --git a/src/test/run-pass/issue-2895.rs b/src/test/run-pass/issue-2895.rs index a21cad8fd39..be1cb3bef8f 100644 --- a/src/test/run-pass/issue-2895.rs +++ b/src/test/run-pass/issue-2895.rs @@ -21,13 +21,13 @@ impl Kitty : Drop { } #[cfg(target_arch = "x86_64")] -fn main() { +pub fn main() { assert (sys::size_of::<Cat>() == 8 as uint); assert (sys::size_of::<Kitty>() == 16 as uint); } #[cfg(target_arch = "x86")] -fn main() { +pub fn main() { assert (sys::size_of::<Cat>() == 4 as uint); assert (sys::size_of::<Kitty>() == 8 as uint); } diff --git a/src/test/run-pass/issue-2904.rs b/src/test/run-pass/issue-2904.rs index 482d2665b2b..25d460656fd 100644 --- a/src/test/run-pass/issue-2904.rs +++ b/src/test/run-pass/issue-2904.rs @@ -28,8 +28,8 @@ enum square { } impl square: to_str::ToStr { - pure fn to_str() -> ~str { - match self { + pure fn to_str(&self) -> ~str { + match *self { bot => { ~"R" } wall => { ~"#" } rock => { ~"*" } @@ -54,7 +54,7 @@ fn square_from_char(c: char) -> square { ' ' => { empty } _ => { error!("invalid square: %?", c); - fail + die!() } } } @@ -87,4 +87,4 @@ mod test { } } -fn main() {} +pub fn main() {} diff --git a/src/test/run-pass/issue-2930.rs b/src/test/run-pass/issue-2930.rs index 1ad51582067..4b6985f057e 100644 --- a/src/test/run-pass/issue-2930.rs +++ b/src/test/run-pass/issue-2930.rs @@ -14,7 +14,7 @@ proto! stream ( } ) -fn main() { +pub fn main() { let (bc, _bp) = stream::init(); stream::client::send(move bc, ~"abc"); diff --git a/src/test/run-pass/issue-2935.rs b/src/test/run-pass/issue-2935.rs index cac60676be8..e30d8997b3b 100644 --- a/src/test/run-pass/issue-2935.rs +++ b/src/test/run-pass/issue-2935.rs @@ -20,7 +20,7 @@ impl t: it { fn f() { } } -fn main() { +pub fn main() { // let x = ({a: 4i} as it); // let y = @({a: 4i}); // let z = @({a: 4i} as it); diff --git a/src/test/run-pass/issue-2936.rs b/src/test/run-pass/issue-2936.rs index 00c18f2e5c9..3a024c73791 100644 --- a/src/test/run-pass/issue-2936.rs +++ b/src/test/run-pass/issue-2936.rs @@ -32,7 +32,7 @@ fn cbar(x: int) -> cbar { } } -fn main() { +pub fn main() { let x: int = foo::<int, cbar>(cbar(5)); assert x == 5; } diff --git a/src/test/run-pass/issue-2989.rs b/src/test/run-pass/issue-2989.rs index d77a0817b82..40a78d7114a 100644 --- a/src/test/run-pass/issue-2989.rs +++ b/src/test/run-pass/issue-2989.rs @@ -33,7 +33,7 @@ fn to_bools(bitv: Storage) -> ~[bool] { struct Storage { storage: ~[u64] } -fn main() { +pub fn main() { let bools = ~[false, false, true, false, false, true, true, false]; let bools2 = to_bools(Storage{storage: ~[0b01100100]}); diff --git a/src/test/run-pass/issue-3012-2.rs b/src/test/run-pass/issue-3012-2.rs index 84a98bf91db..ef115c5c02c 100644 --- a/src/test/run-pass/issue-3012-2.rs +++ b/src/test/run-pass/issue-3012-2.rs @@ -13,7 +13,7 @@ extern mod socketlib; use socketlib::socket; -fn main() { +pub fn main() { let fd: libc::c_int = 1 as libc::c_int; let sock = @socket::socket_handle(fd); } diff --git a/src/test/run-pass/issue-3026.rs b/src/test/run-pass/issue-3026.rs index 8a7ebb8d129..32f7d2ee07c 100644 --- a/src/test/run-pass/issue-3026.rs +++ b/src/test/run-pass/issue-3026.rs @@ -11,10 +11,10 @@ // except according to those terms. extern mod std; -use std::map::HashMap; -use std::map; +use std::oldmap::HashMap; +use std::oldmap; -fn main() { +pub fn main() { let buggy_map :HashMap<uint, &uint> = HashMap::<uint, &uint>(); let x = ~1; buggy_map.insert(42, &*x); diff --git a/src/test/run-pass/issue-3037.rs b/src/test/run-pass/issue-3037.rs index 33956a97d0b..ef403a6c9cb 100644 --- a/src/test/run-pass/issue-3037.rs +++ b/src/test/run-pass/issue-3037.rs @@ -16,6 +16,6 @@ fn what_to_str(x: what) -> ~str } } -fn main() +pub fn main() { } diff --git a/src/test/run-pass/issue-3052.rs b/src/test/run-pass/issue-3052.rs index 74f67ff9280..f01ef370e2a 100644 --- a/src/test/run-pass/issue-3052.rs +++ b/src/test/run-pass/issue-3052.rs @@ -15,5 +15,5 @@ fn f() -> Option<Connection> { Some(mock_connection) } -fn main() { +pub fn main() { } diff --git a/src/test/run-pass/issue-3091.rs b/src/test/run-pass/issue-3091.rs index e06acc8cca3..5a38da1f1d2 100644 --- a/src/test/run-pass/issue-3091.rs +++ b/src/test/run-pass/issue-3091.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -fn main() { +pub fn main() { let x = 1; let y = 1; assert &x == &y; diff --git a/src/test/run-pass/issue-3109.rs b/src/test/run-pass/issue-3109.rs index dfb529dcd1d..be38e9080e5 100644 --- a/src/test/run-pass/issue-3109.rs +++ b/src/test/run-pass/issue-3109.rs @@ -8,6 +8,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -fn main() { +pub fn main() { log(error, ("hi there!", "you")); } diff --git a/src/test/run-pass/issue-3121.rs b/src/test/run-pass/issue-3121.rs index c61e222d789..522a68856b6 100644 --- a/src/test/run-pass/issue-3121.rs +++ b/src/test/run-pass/issue-3121.rs @@ -23,6 +23,6 @@ fn foo(m: @meal, cond: bool) { } } -fn main() { +pub fn main() { foo(@for_here(hamburger), true) } diff --git a/src/test/run-pass/issue-3149.rs b/src/test/run-pass/issue-3149.rs index c578f1144a7..805aac92937 100644 --- a/src/test/run-pass/issue-3149.rs +++ b/src/test/run-pass/issue-3149.rs @@ -29,4 +29,4 @@ struct Matrix4<T> { m41: T, m42: T, m43: T, m44: T, } -fn main() {} +pub fn main() {} diff --git a/src/test/run-pass/issue-3168.rs b/src/test/run-pass/issue-3168.rs index 5caf5e05ab6..a2c181569ce 100644 --- a/src/test/run-pass/issue-3168.rs +++ b/src/test/run-pass/issue-3168.rs @@ -10,14 +10,14 @@ // xfail-fast -fn main() { +pub fn main() { let (p,c) = pipes::stream(); do task::try |move c| { let (p2,c2) = pipes::stream(); do task::spawn |move p2| { p2.recv(); error!("sibling fails"); - fail; + die!(); } let (p3,c3) = pipes::stream(); c.send(move c3); diff --git a/src/test/run-pass/issue-3176.rs b/src/test/run-pass/issue-3176.rs index 817d4b9a375..911e50a0ed7 100644 --- a/src/test/run-pass/issue-3176.rs +++ b/src/test/run-pass/issue-3176.rs @@ -12,14 +12,14 @@ use pipes::{Select2, Selectable}; -fn main() { +pub fn main() { let (p,c) = pipes::stream(); do task::try |move c| { let (p2,c2) = pipes::stream(); do task::spawn |move p2| { p2.recv(); error!("sibling fails"); - fail; + die!(); } let (p3,c3) = pipes::stream(); c.send(move c3); diff --git a/src/test/run-pass/issue-3186.rs b/src/test/run-pass/issue-3186.rs index f582e905451..6b35cd7e0c9 100644 --- a/src/test/run-pass/issue-3186.rs +++ b/src/test/run-pass/issue-3186.rs @@ -12,4 +12,4 @@ enum y { x } enum x {} -fn main() {} +pub fn main() {} diff --git a/src/test/run-pass/issue-3211.rs b/src/test/run-pass/issue-3211.rs index ecdd0a2c2a7..2bb57d6c95a 100644 --- a/src/test/run-pass/issue-3211.rs +++ b/src/test/run-pass/issue-3211.rs @@ -1,4 +1,4 @@ -fn main() { +pub fn main() { let mut x = 0; for 4096.times { x += 1; diff --git a/src/test/run-pass/issue-3220.rs b/src/test/run-pass/issue-3220.rs index 33161adc4af..561a1925a97 100644 --- a/src/test/run-pass/issue-3220.rs +++ b/src/test/run-pass/issue-3220.rs @@ -21,7 +21,7 @@ fn thing() -> thing { } impl thing { fn f(self) {} } -fn main() { +pub fn main() { let z = thing(); (move z).f(); } diff --git a/src/test/run-pass/issue-3250.rs b/src/test/run-pass/issue-3250.rs index 086f94b2f62..a563544b5c7 100644 --- a/src/test/run-pass/issue-3250.rs +++ b/src/test/run-pass/issue-3250.rs @@ -4,4 +4,4 @@ type t = (uint, uint); -fn main() { } +pub fn main() { } diff --git a/src/test/run-pass/issue-3305.rs b/src/test/run-pass/issue-3305.rs index 7117ecfced3..d3377d196a4 100644 --- a/src/test/run-pass/issue-3305.rs +++ b/src/test/run-pass/issue-3305.rs @@ -20,7 +20,7 @@ fn is_equal<D: double>(x: @D, exp: uint) { assert x.double() == exp; } -fn main() { +pub fn main() { let x = @(3u as double); is_equal(x, 6); } diff --git a/src/test/run-pass/issue-333.rs b/src/test/run-pass/issue-333.rs index a3fef098c88..8b863bd90b6 100644 --- a/src/test/run-pass/issue-333.rs +++ b/src/test/run-pass/issue-333.rs @@ -12,4 +12,4 @@ fn quux<T: Copy>(x: T) -> T { let f = id::<T>; return f(x); } fn id<T: Copy>(x: T) -> T { return x; } -fn main() { assert (quux(10) == 10); } +pub fn main() { assert (quux(10) == 10); } diff --git a/src/test/run-pass/issue-3389.rs b/src/test/run-pass/issue-3389.rs index 37882ad4241..b25e6ae2d2d 100644 --- a/src/test/run-pass/issue-3389.rs +++ b/src/test/run-pass/issue-3389.rs @@ -19,7 +19,7 @@ fn print_str_vector(vector: ~[~str]) { } } -fn main() { +pub fn main() { let node: trie_node = trie_node { content: ~[], children: ~[] diff --git a/src/test/run-pass/issue-3424.rs b/src/test/run-pass/issue-3424.rs index 6064713b295..5d6367df3b6 100644 --- a/src/test/run-pass/issue-3424.rs +++ b/src/test/run-pass/issue-3424.rs @@ -25,4 +25,4 @@ fn tester() assert loader(&path).is_ok(); } -fn main() {} +pub fn main() {} diff --git a/src/test/run-pass/issue-3447.rs b/src/test/run-pass/issue-3447.rs index eaba3b16d3e..18b47e2925d 100644 --- a/src/test/run-pass/issue-3447.rs +++ b/src/test/run-pass/issue-3447.rs @@ -24,7 +24,7 @@ impl<T> list<T>{ } } -fn main() { +pub fn main() { let s = @"str"; let ls = list { element: &s, diff --git a/src/test/run-pass/issue-3461.rs b/src/test/run-pass/issue-3461.rs index 0823395945f..f285479df20 100644 --- a/src/test/run-pass/issue-3461.rs +++ b/src/test/run-pass/issue-3461.rs @@ -9,7 +9,7 @@ // except according to those terms. // xfail-test -fn main() { +pub fn main() { fn foo() { } diff --git a/src/test/run-pass/issue-3480.rs b/src/test/run-pass/issue-3480.rs index d2e84036fba..8e4f3446953 100644 --- a/src/test/run-pass/issue-3480.rs +++ b/src/test/run-pass/issue-3480.rs @@ -24,4 +24,4 @@ impl<K: Copy, V: Copy> IMap<K, V> : ImmutableMap<K, V> } } -fn main() {} \ No newline at end of file +pub fn main() {} \ No newline at end of file diff --git a/src/test/run-pass/issue-3500.rs b/src/test/run-pass/issue-3500.rs index 5ee7f499d1c..99def5476f9 100644 --- a/src/test/run-pass/issue-3500.rs +++ b/src/test/run-pass/issue-3500.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -fn main() { +pub fn main() { let x = &Some(1); match x { &Some(_) => (), diff --git a/src/test/run-pass/issue-3559.rs b/src/test/run-pass/issue-3559.rs index da7746681f2..aff0b4fc71e 100644 --- a/src/test/run-pass/issue-3559.rs +++ b/src/test/run-pass/issue-3559.rs @@ -14,7 +14,7 @@ extern mod std; use core::io::{WriterUtil}; -use std::map::*; +use std::oldmap::*; #[cfg(test)] fn check_strs(actual: &str, expected: &str) -> bool @@ -36,4 +36,4 @@ fn tester() assert check_strs(table.to_str(), ~"xxx"); // not sure what expected should be } -fn main() {} +pub fn main() {} diff --git a/src/test/run-pass/issue-3563-2.rs b/src/test/run-pass/issue-3563-2.rs index aa4598fc90b..332127d0204 100644 --- a/src/test/run-pass/issue-3563-2.rs +++ b/src/test/run-pass/issue-3563-2.rs @@ -19,4 +19,4 @@ trait Canvas { } -fn main() {} +pub fn main() {} diff --git a/src/test/run-pass/issue-3563-3.rs b/src/test/run-pass/issue-3563-3.rs index 50ca15cbd1d..88f31189a0c 100644 --- a/src/test/run-pass/issue-3563-3.rs +++ b/src/test/run-pass/issue-3563-3.rs @@ -51,7 +51,7 @@ struct AsciiArt width: uint, height: uint, priv fill: char, - priv lines: ~[~[mut char]], + priv lines: ~[~[char]], // This struct can be quite large so we'll disable copying: developers need // to either pass these structs around via borrowed pointers or move them. @@ -65,14 +65,14 @@ fn AsciiArt(width: uint, height: uint, fill: char) -> AsciiArt { // Use an anonymous function to build a vector of vectors containing // blank characters for each position in our canvas. - let lines = do vec::build_sized(height) + let mut lines = do vec::build_sized(height) |push| { for height.times { let mut line = ~[]; vec::grow_set(&mut line, width-1, &'.', '.'); - push(vec::cast_to_mut(line)); + push(line); } }; @@ -84,7 +84,7 @@ fn AsciiArt(width: uint, height: uint, fill: char) -> AsciiArt // Methods particular to the AsciiArt struct. impl AsciiArt { - fn add_pt(x: int, y: int) + fn add_pt(&mut self, x: int, y: int) { if x >= 0 && x < self.width as int { @@ -99,7 +99,7 @@ impl AsciiArt // element is: // 1) potentially large // 2) needs to be modified - let row = &self.lines[v]; + let row = &mut self.lines[v]; row[h] = self.fill; } } @@ -110,7 +110,7 @@ impl AsciiArt // Note that the %s fmt! specifier will not call this automatically. impl AsciiArt : ToStr { - pure fn to_str() -> ~str + pure fn to_str(&self) -> ~str { // Convert each line into a string. let lines = do self.lines.map |line| {str::from_chars(*line)}; @@ -125,12 +125,12 @@ impl AsciiArt : ToStr #[allow(default_methods)] trait Canvas { - fn add_point(shape: Point); - fn add_rect(shape: Rect); + fn add_point(&mut self, shape: Point); + fn add_rect(&mut self, shape: Rect); // Unlike interfaces traits support default implementations. // Got an ICE as soon as I added this method. - fn add_points(shapes: &[Point]) + fn add_points(&mut self, shapes: &[Point]) { for shapes.each |pt| {self.add_point(*pt)}; } @@ -141,12 +141,12 @@ trait Canvas // and code can use them polymorphically via the Canvas trait. impl AsciiArt : Canvas { - fn add_point(shape: Point) + fn add_point(&mut self, shape: Point) { self.add_pt(shape.x, shape.y); } - fn add_rect(shape: Rect) + fn add_rect(&mut self, shape: Rect) { // Add the top and bottom lines. for int::range(shape.top_left.x, shape.top_left.x + shape.size.width) @@ -188,7 +188,7 @@ fn test_ascii_art_ctor() fn test_add_pt() { - let art = AsciiArt(3, 3, '*'); + let mut art = AsciiArt(3, 3, '*'); art.add_pt(0, 0); art.add_pt(0, -10); art.add_pt(1, 2); @@ -198,13 +198,13 @@ fn test_add_pt() fn test_shapes() { - let art = AsciiArt(4, 4, '*'); + let mut art = AsciiArt(4, 4, '*'); art.add_rect(Rect {top_left: Point {x: 0, y: 0}, size: Size {width: 4, height: 4}}); art.add_point(Point {x: 2, y: 2}); assert check_strs(art.to_str(), "****\n*..*\n*.**\n****"); } -fn main() { +pub fn main() { test_ascii_art_ctor(); test_add_pt(); test_shapes(); diff --git a/src/test/run-pass/issue-3574.rs b/src/test/run-pass/issue-3574.rs index 3744b857dc1..1b666fd5649 100644 --- a/src/test/run-pass/issue-3574.rs +++ b/src/test/run-pass/issue-3574.rs @@ -20,7 +20,7 @@ fn compare(x: &str, y: &str) -> bool } } -fn main() +pub fn main() { assert compare("foo", "foo"); assert compare(@"foo", @"foo"); diff --git a/src/test/run-pass/issue-3609.rs b/src/test/run-pass/issue-3609.rs index 9eff98ff424..0eacb34b1ef 100644 --- a/src/test/run-pass/issue-3609.rs +++ b/src/test/run-pass/issue-3609.rs @@ -24,5 +24,5 @@ fn foo(name: ~str, samples_chan: Chan<Msg>) { }; } -fn main() {} +pub fn main() {} diff --git a/src/test/run-pass/issue-3656.rs b/src/test/run-pass/issue-3656.rs index 66c2a4672b4..edb9278781f 100644 --- a/src/test/run-pass/issue-3656.rs +++ b/src/test/run-pass/issue-3656.rs @@ -27,5 +27,5 @@ extern { pub fn malloc(++data: KEYGEN); } -fn main() { +pub fn main() { } diff --git a/src/test/run-pass/issue-3683.rs b/src/test/run-pass/issue-3683.rs index d4b343a88b7..729f91760b1 100644 --- a/src/test/run-pass/issue-3683.rs +++ b/src/test/run-pass/issue-3683.rs @@ -23,6 +23,6 @@ impl int: Foo { } } -fn main() { +pub fn main() { assert(3.b() == 5); } diff --git a/src/test/run-pass/issue-3702.rs b/src/test/run-pass/issue-3702.rs index 9045e3aecda..eaa2ac4c4ba 100644 --- a/src/test/run-pass/issue-3702.rs +++ b/src/test/run-pass/issue-3702.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -fn main() { +pub fn main() { trait Text { fn to_str(&self) -> ~str; } diff --git a/src/test/run-pass/issue-3753.rs b/src/test/run-pass/issue-3753.rs index dcd85916918..39d3e20ae2f 100644 --- a/src/test/run-pass/issue-3753.rs +++ b/src/test/run-pass/issue-3753.rs @@ -31,7 +31,7 @@ pub impl Shape { } } -fn main(){ +pub fn main(){ let s = Circle(Point { x: 1f, y: 2f }, 3f); io::println(fmt!("%f", s.area(s))); } \ No newline at end of file diff --git a/src/test/run-pass/issue-3794.rs b/src/test/run-pass/issue-3794.rs index 9d39d59b24f..47373e5490a 100644 --- a/src/test/run-pass/issue-3794.rs +++ b/src/test/run-pass/issue-3794.rs @@ -31,7 +31,7 @@ fn print_s(s: &S) { s.print(); } -fn main() { +pub fn main() { let s: @S = @S { s: 5 }; print_s(s); let t: @T = s as @T; diff --git a/src/test/run-pass/issue-3847.rs b/src/test/run-pass/issue-3847.rs index 878f6c6ccb1..4d1b042661c 100644 --- a/src/test/run-pass/issue-3847.rs +++ b/src/test/run-pass/issue-3847.rs @@ -12,7 +12,7 @@ mod buildings { pub struct Tower { height: uint } } -fn main() { +pub fn main() { let sears = buildings::Tower { height: 1451 }; let h: uint = match sears { buildings::Tower { height: h } => { h } diff --git a/src/test/run-pass/issue-3860.rs b/src/test/run-pass/issue-3860.rs index 7a7c307e23d..ba519fe5812 100644 --- a/src/test/run-pass/issue-3860.rs +++ b/src/test/run-pass/issue-3860.rs @@ -16,7 +16,7 @@ impl Foo { } } -fn main() { +pub fn main() { let mut x = @mut Foo { x: 3 }; // Neither of the next two lines should cause an error let _ = x.stuff(); diff --git a/src/test/run-pass/issue-3874.rs b/src/test/run-pass/issue-3874.rs index 03f0a98092b..d709757adb0 100644 --- a/src/test/run-pass/issue-3874.rs +++ b/src/test/run-pass/issue-3874.rs @@ -16,4 +16,4 @@ pure fn each(self: PureCounter, blk: fn(v: &uint)) { blk(x); } -fn main() {} +pub fn main() {} diff --git a/src/test/run-pass/issue-3878.rs b/src/test/run-pass/issue-3878.rs index 2b058fbedb7..dd41d696b3a 100644 --- a/src/test/run-pass/issue-3878.rs +++ b/src/test/run-pass/issue-3878.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -fn main() +pub fn main() { let y = ~1; move y; diff --git a/src/test/run-pass/issue-3888-2.rs b/src/test/run-pass/issue-3888-2.rs index f3a7840dce0..19f05c61ba4 100644 --- a/src/test/run-pass/issue-3888-2.rs +++ b/src/test/run-pass/issue-3888-2.rs @@ -14,4 +14,4 @@ fn vec_peek<T>(v: &r/[T]) -> &r/[T] { vec::view(v, 1, 5) } -fn main() {} +pub fn main() {} diff --git a/src/test/run-pass/issue-3895.rs b/src/test/run-pass/issue-3895.rs index 62ca63e47d6..e12d2cbae4d 100644 --- a/src/test/run-pass/issue-3895.rs +++ b/src/test/run-pass/issue-3895.rs @@ -9,11 +9,11 @@ // except according to those terms. // xfail-test -fn main() { +pub fn main() { enum State { BadChar, BadSyntax } match BadChar { _ if true => BadChar, - BadChar | BadSyntax => fail , + BadChar | BadSyntax => die!() , }; } diff --git a/src/test/run-pass/issue-3904.rs b/src/test/run-pass/issue-3904.rs index 047791a0e89..885b8da9325 100644 --- a/src/test/run-pass/issue-3904.rs +++ b/src/test/run-pass/issue-3904.rs @@ -29,7 +29,7 @@ impl X { } } -fn main(){ +pub fn main(){ let val = &X{ err: example_err, }; diff --git a/src/test/run-pass/issue-3979-2.rs b/src/test/run-pass/issue-3979-2.rs index 9401b24abb8..c485590f4aa 100644 --- a/src/test/run-pass/issue-3979-2.rs +++ b/src/test/run-pass/issue-3979-2.rs @@ -23,5 +23,5 @@ trait C: B { } } -fn main() {} +pub fn main() {} diff --git a/src/test/run-pass/issue-3979-generics.rs b/src/test/run-pass/issue-3979-generics.rs index 7261b74a7fa..0f349473096 100644 --- a/src/test/run-pass/issue-3979-generics.rs +++ b/src/test/run-pass/issue-3979-generics.rs @@ -34,7 +34,7 @@ impl Point: Positioned<int> { impl Point: Movable<int, int>; -fn main() { +pub fn main() { let p = Point{ x: 1, y: 2}; p.translate(3); assert p.X() == 4; diff --git a/src/test/run-pass/issue-3979-xcrate.rs b/src/test/run-pass/issue-3979-xcrate.rs index bd48950534a..888fee6317d 100644 --- a/src/test/run-pass/issue-3979-xcrate.rs +++ b/src/test/run-pass/issue-3979-xcrate.rs @@ -26,7 +26,7 @@ impl Point: Positioned { impl Point: Movable; -fn main() { +pub fn main() { let p = Point{ x: 1, y: 2}; p.translate(3); assert p.X() == 4; diff --git a/src/test/run-pass/issue-3979.rs b/src/test/run-pass/issue-3979.rs index 2c680d178b2..3a112de5503 100644 --- a/src/test/run-pass/issue-3979.rs +++ b/src/test/run-pass/issue-3979.rs @@ -33,7 +33,7 @@ impl Point: Positioned { impl Point: Movable; -fn main() { +pub fn main() { let p = Point{ x: 1, y: 2}; p.translate(3); assert p.X() == 4; diff --git a/src/test/run-pass/issue-4016.rs b/src/test/run-pass/issue-4016.rs index 253e0bd633b..a8204d56f45 100644 --- a/src/test/run-pass/issue-4016.rs +++ b/src/test/run-pass/issue-4016.rs @@ -21,7 +21,7 @@ trait JD : Deserializable<json::Deserializer> { } fn exec<T: JD>() { let doc = result::unwrap(json::from_str("")); let _v: T = deserialize(&json::Deserializer(move doc)); - fail + die!() } -fn main() {} +pub fn main() {} diff --git a/src/test/run-pass/issue-4092.rs b/src/test/run-pass/issue-4092.rs index 4cccd28590f..5cfb5809feb 100644 --- a/src/test/run-pass/issue-4092.rs +++ b/src/test/run-pass/issue-4092.rs @@ -10,7 +10,7 @@ extern mod std; -fn main() { - let x = std::map::HashMap(); +pub fn main() { + let x = std::oldmap::HashMap(); x.insert((@"abc", 0), 0); } diff --git a/src/test/run-pass/issue-4401.rs b/src/test/run-pass/issue-4401.rs index 0fc2e4f1695..2af0246fb37 100644 --- a/src/test/run-pass/issue-4401.rs +++ b/src/test/run-pass/issue-4401.rs @@ -1,4 +1,4 @@ -fn main() { +pub fn main() { let mut count = 0; for 999_999.times() { count += 1; diff --git a/src/test/run-pass/issue-4541.rs b/src/test/run-pass/issue-4541.rs index 2d4a210f4f9..fdc2cc1b013 100644 --- a/src/test/run-pass/issue-4541.rs +++ b/src/test/run-pass/issue-4541.rs @@ -26,6 +26,6 @@ fn parse_args() -> ~str { return ~"" } -fn main() { +pub fn main() { io::println(parse_args()); } diff --git a/src/test/run-pass/issue-4542.rs b/src/test/run-pass/issue-4542.rs index 37508d8fa23..329e3647fae 100644 --- a/src/test/run-pass/issue-4542.rs +++ b/src/test/run-pass/issue-4542.rs @@ -9,7 +9,7 @@ // except according to those terms. // xfail-test -fn main() { +pub fn main() { for os::args().each |arg| { match copy *arg { s => { } diff --git a/src/test/run-pass/issue-868.rs b/src/test/run-pass/issue-868.rs index 743e2a8e238..55c5dcb4e07 100644 --- a/src/test/run-pass/issue-868.rs +++ b/src/test/run-pass/issue-868.rs @@ -10,7 +10,7 @@ fn f<T>(g: fn() -> T) -> T { g() } -fn main() { +pub fn main() { let _x = f( | | { 10 }); // used to be: cannot determine a type for this expression f(| | { }); diff --git a/src/test/run-pass/issue-912.rs b/src/test/run-pass/issue-912.rs index 688535a15c0..dddcb8b957f 100644 --- a/src/test/run-pass/issue-912.rs +++ b/src/test/run-pass/issue-912.rs @@ -11,7 +11,7 @@ // xfail-test fn find<T>(_f: fn(@T) -> bool, _v: [@T]) {} -fn main() { +pub fn main() { let x = 10, arr = []; find({|f| f.id == x}, arr); arr += [{id: 20}]; // This assigns a type to arr diff --git a/src/test/run-pass/issue-979.rs b/src/test/run-pass/issue-979.rs index f0b57c50bd5..38fbc44e851 100644 --- a/src/test/run-pass/issue-979.rs +++ b/src/test/run-pass/issue-979.rs @@ -24,7 +24,7 @@ fn r(b: @mut int) -> r { } } -fn main() { +pub fn main() { let b = @mut 0; { let p = Some(r(b)); diff --git a/src/test/run-pass/issue-980.rs b/src/test/run-pass/issue-980.rs index f29231b53d0..842eabf8fc5 100644 --- a/src/test/run-pass/issue-980.rs +++ b/src/test/run-pass/issue-980.rs @@ -17,7 +17,7 @@ struct Pointy { mut x : maybe_pointy } -fn main() { +pub fn main() { let m = @Pointy { mut x : no_pointy }; m.x = yes_pointy(m); } diff --git a/src/test/run-pass/issue2170exe.rs b/src/test/run-pass/issue2170exe.rs index e51ec46021d..64b6593723b 100644 --- a/src/test/run-pass/issue2170exe.rs +++ b/src/test/run-pass/issue2170exe.rs @@ -12,6 +12,6 @@ // aux-build:issue2170lib.rs extern mod issue2170lib; -fn main() { +pub fn main() { // let _ = issue2170lib::rsrc(2i32); } diff --git a/src/test/run-pass/issue2378c.rs b/src/test/run-pass/issue2378c.rs index 2e2bb5471b9..572cf69e1d9 100644 --- a/src/test/run-pass/issue2378c.rs +++ b/src/test/run-pass/issue2378c.rs @@ -18,7 +18,7 @@ use issue2378b; use issue2378a::{just, methods}; use issue2378b::{methods}; -fn main() { +pub fn main() { let x = {a: just(3), b: just(5)}; assert x[0u] == (3, 5); } diff --git a/src/test/run-pass/issue4516_ty_param.rs b/src/test/run-pass/issue4516_ty_param.rs index 279766d9bbf..35df47df036 100644 --- a/src/test/run-pass/issue4516_ty_param.rs +++ b/src/test/run-pass/issue4516_ty_param.rs @@ -20,6 +20,6 @@ extern mod issue4516_ty_param_lib; use issue4516_ty_param_lib::to_closure; -fn main() { +pub fn main() { to_closure(22)(); } diff --git a/src/test/run-pass/issue_3136_b.rs b/src/test/run-pass/issue_3136_b.rs index 4a762a6c4d3..c5b6b6b220c 100644 --- a/src/test/run-pass/issue_3136_b.rs +++ b/src/test/run-pass/issue_3136_b.rs @@ -12,5 +12,5 @@ // aux-build:issue_3136_a.rc extern mod issue_3136_a; -fn main() {} +pub fn main() {} diff --git a/src/test/run-pass/issue_3882.rs b/src/test/run-pass/issue_3882.rs index b56884622da..7b1af0d151f 100644 --- a/src/test/run-pass/issue_3882.rs +++ b/src/test/run-pass/issue_3882.rs @@ -14,4 +14,4 @@ extern mod linenoise; use linenoise::issue_3882::*; -fn main() {} +pub fn main() {} diff --git a/src/test/run-pass/istr.rs b/src/test/run-pass/istr.rs index 184987afeec..943d87a5222 100644 --- a/src/test/run-pass/istr.rs +++ b/src/test/run-pass/istr.rs @@ -60,7 +60,7 @@ fn test_append() { assert (s == ~"coffee&tea"); } -fn main() { +pub fn main() { test_stack_assign(); test_heap_lit(); test_heap_assign(); diff --git a/src/test/run-pass/item-attributes.rs b/src/test/run-pass/item-attributes.rs index d949516a257..2be072bb242 100644 --- a/src/test/run-pass/item-attributes.rs +++ b/src/test/run-pass/item-attributes.rs @@ -184,7 +184,7 @@ fn test_fn_inner() { #[inner_fn_attr]; } -fn main() { } +pub fn main() { } // // Local Variables: diff --git a/src/test/run-pass/item-name-overload.rs b/src/test/run-pass/item-name-overload.rs index fd3ba938b1c..c6b777d3d8a 100644 --- a/src/test/run-pass/item-name-overload.rs +++ b/src/test/run-pass/item-name-overload.rs @@ -20,4 +20,4 @@ mod bar { pub fn baz() { } } -fn main() { } +pub fn main() { } diff --git a/src/test/run-pass/iter-all.rs b/src/test/run-pass/iter-all.rs index 00f566c817f..3da5c01d197 100644 --- a/src/test/run-pass/iter-all.rs +++ b/src/test/run-pass/iter-all.rs @@ -10,7 +10,7 @@ fn is_even(x: &uint) -> bool { (*x % 2) == 0 } -fn main() { +pub fn main() { assert ![1u, 2u].all(is_even); assert [2u, 4u].all(is_even); assert [].all(is_even); diff --git a/src/test/run-pass/iter-any.rs b/src/test/run-pass/iter-any.rs index 38b5b7c0a42..eb0b09327bb 100644 --- a/src/test/run-pass/iter-any.rs +++ b/src/test/run-pass/iter-any.rs @@ -10,7 +10,7 @@ fn is_even(x: &uint) -> bool { (*x % 2) == 0 } -fn main() { +pub fn main() { assert ![1u, 3u].any(is_even); assert [1u, 2u].any(is_even); assert ![].any(is_even); diff --git a/src/test/run-pass/iter-contains.rs b/src/test/run-pass/iter-contains.rs index 3042a1e62e8..6e1fd498119 100644 --- a/src/test/run-pass/iter-contains.rs +++ b/src/test/run-pass/iter-contains.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -fn main() { +pub fn main() { assert [].contains(&22u) == false; assert [1u, 3u].contains(&22u) == false; assert [22u, 1u, 3u].contains(&22u) == true; diff --git a/src/test/run-pass/iter-count.rs b/src/test/run-pass/iter-count.rs index c2359606e77..1bc6155dce3 100644 --- a/src/test/run-pass/iter-count.rs +++ b/src/test/run-pass/iter-count.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -fn main() { +pub fn main() { assert [].count(&22u) == 0u; assert [1u, 3u].count(&22u) == 0u; assert [22u, 1u, 3u].count(&22u) == 1u; diff --git a/src/test/run-pass/iter-eachi.rs b/src/test/run-pass/iter-eachi.rs index 31373fe1f8d..b96d017eb9e 100644 --- a/src/test/run-pass/iter-eachi.rs +++ b/src/test/run-pass/iter-eachi.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -fn main() { +pub fn main() { let mut c = 0u; for [1u, 2u, 3u, 4u, 5u].eachi |i, v| { assert (i + 1u) == *v; @@ -16,7 +16,7 @@ fn main() { } assert c == 5u; - for None::<uint>.eachi |i, v| { fail; } + for None::<uint>.eachi |i, v| { die!(); } let mut c = 0u; for Some(1u).eachi |i, v| { diff --git a/src/test/run-pass/iter-filter-to-vec.rs b/src/test/run-pass/iter-filter-to-vec.rs index e3f8790e302..8f286ae9049 100644 --- a/src/test/run-pass/iter-filter-to-vec.rs +++ b/src/test/run-pass/iter-filter-to-vec.rs @@ -10,7 +10,7 @@ fn is_even(x: &uint) -> bool { (*x % 2) == 0 } -fn main() { +pub fn main() { assert [1, 3].filter_to_vec(is_even) == ~[]; assert [1, 2, 3].filter_to_vec(is_even) == ~[2]; assert None.filter_to_vec(is_even) == ~[]; diff --git a/src/test/run-pass/iter-flat-map-to-vec.rs b/src/test/run-pass/iter-flat-map-to-vec.rs index a90206188e3..c8df707ce97 100644 --- a/src/test/run-pass/iter-flat-map-to-vec.rs +++ b/src/test/run-pass/iter-flat-map-to-vec.rs @@ -14,7 +14,7 @@ fn incd_if_even(x: &uint) -> Option<uint> { if (*x % 2u) == 0u {Some(*x + 1u)} else {None} } -fn main() { +pub fn main() { assert (~[1u, 3u]).flat_map_to_vec(repeat) == ~[1u, 1u, 3u, 3u]; assert (~[]).flat_map_to_vec(repeat) == ~[]; assert None.flat_map_to_vec(repeat) == ~[]; diff --git a/src/test/run-pass/iter-foldl.rs b/src/test/run-pass/iter-foldl.rs index 8c6d5a9ed60..ef1e83235a5 100644 --- a/src/test/run-pass/iter-foldl.rs +++ b/src/test/run-pass/iter-foldl.rs @@ -10,7 +10,7 @@ fn add(x: &float, y: &uint) -> float { *x + ((*y) as float) } -fn main() { +pub fn main() { assert [1u, 3u].foldl(20f, add) == 24f; assert [].foldl(20f, add) == 20f; assert None.foldl(20f, add) == 20f; diff --git a/src/test/run-pass/iter-map-to-vec.rs b/src/test/run-pass/iter-map-to-vec.rs index ffd7afe923d..4277ce77762 100644 --- a/src/test/run-pass/iter-map-to-vec.rs +++ b/src/test/run-pass/iter-map-to-vec.rs @@ -10,7 +10,7 @@ fn inc(x: &uint) -> uint { *x + 1 } -fn main() { +pub fn main() { assert [1, 3].map_to_vec(inc) == ~[2, 4]; assert [1, 2, 3].map_to_vec(inc) == ~[2, 3, 4]; assert None.map_to_vec(inc) == ~[]; diff --git a/src/test/run-pass/iter-min-max.rs b/src/test/run-pass/iter-min-max.rs index 2b8023cb502..7c75d80bd0f 100644 --- a/src/test/run-pass/iter-min-max.rs +++ b/src/test/run-pass/iter-min-max.rs @@ -10,7 +10,7 @@ fn is_even(&&x: uint) -> bool { (x % 2u) == 0u } -fn main() { +pub fn main() { assert [1u, 3u].min() == 1u; assert [3u, 1u].min() == 1u; assert Some(1u).min() == 1u; diff --git a/src/test/run-pass/iter-range.rs b/src/test/run-pass/iter-range.rs index 4754bf243b3..16f27db7bf2 100644 --- a/src/test/run-pass/iter-range.rs +++ b/src/test/run-pass/iter-range.rs @@ -16,7 +16,7 @@ fn range(a: int, b: int, it: fn(int)) { while i < b { it(i); i += 1; } } -fn main() { +pub fn main() { let mut sum: int = 0; range(0, 100, |x| sum += x ); log(debug, sum); diff --git a/src/test/run-pass/iter-to-vec.rs b/src/test/run-pass/iter-to-vec.rs index dcac8c11e14..c613c688c9d 100644 --- a/src/test/run-pass/iter-to-vec.rs +++ b/src/test/run-pass/iter-to-vec.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -fn main() { +pub fn main() { assert [1u, 3u].to_vec() == ~[1u, 3u]; let e: ~[uint] = ~[]; assert e.to_vec() == ~[]; diff --git a/src/test/run-pass/ivec-add.rs b/src/test/run-pass/ivec-add.rs index 814578f1a1c..f06185f3727 100644 --- a/src/test/run-pass/ivec-add.rs +++ b/src/test/run-pass/ivec-add.rs @@ -12,7 +12,7 @@ fn double<T: Copy>(a: T) -> ~[T] { return ~[a] + ~[a]; } fn double_int(a: int) -> ~[int] { return ~[a] + ~[a]; } -fn main() { +pub fn main() { let mut d = double(1); assert (d[0] == 1); assert (d[1] == 1); diff --git a/src/test/run-pass/ivec-pass-by-value.rs b/src/test/run-pass/ivec-pass-by-value.rs index 84d0a22cf7f..756f38196fd 100644 --- a/src/test/run-pass/ivec-pass-by-value.rs +++ b/src/test/run-pass/ivec-pass-by-value.rs @@ -9,5 +9,5 @@ // except according to those terms. fn f(a: ~[int]) { } -fn main() { f(~[1, 2, 3, 4, 5]); } +pub fn main() { f(~[1, 2, 3, 4, 5]); } diff --git a/src/test/run-pass/ivec-tag.rs b/src/test/run-pass/ivec-tag.rs index b890160ea17..9971b098bb0 100644 --- a/src/test/run-pass/ivec-tag.rs +++ b/src/test/run-pass/ivec-tag.rs @@ -6,7 +6,7 @@ fn producer(c: &Chan<~[u8]>) { 13u8]); } -fn main() { +pub fn main() { let (p, ch) = stream::<~[u8]>(); let prod = task::spawn(|| producer(&ch) ); diff --git a/src/test/run-pass/keyword-changes-2012-07-31.rs b/src/test/run-pass/keyword-changes-2012-07-31.rs index 7a8c3cdaa39..ff568b77f08 100644 --- a/src/test/run-pass/keyword-changes-2012-07-31.rs +++ b/src/test/run-pass/keyword-changes-2012-07-31.rs @@ -12,7 +12,7 @@ // mod -> module // match -> match -fn main() { +pub fn main() { } mod foo { diff --git a/src/test/run-pass/kindck-owned-trait-contains-1.rs b/src/test/run-pass/kindck-owned-trait-contains-1.rs index 573aae94925..f87e55173ab 100644 --- a/src/test/run-pass/kindck-owned-trait-contains-1.rs +++ b/src/test/run-pass/kindck-owned-trait-contains-1.rs @@ -19,7 +19,7 @@ fn repeater<A:Copy>(v: @A) -> repeat<A> { v as repeat::<A> // No } -fn main() { +pub fn main() { let x = &3; let y = repeater(@x); assert *x == *(y.get()); diff --git a/src/test/run-pass/labeled-break.rs b/src/test/run-pass/labeled-break.rs index a2af5764e8a..b26d8f78e64 100644 --- a/src/test/run-pass/labeled-break.rs +++ b/src/test/run-pass/labeled-break.rs @@ -11,7 +11,7 @@ // xfail-fast // xfail-test -fn main() { +pub fn main() { loop foo: { loop { break foo; diff --git a/src/test/run-pass/lambda-infer-unresolved.rs b/src/test/run-pass/lambda-infer-unresolved.rs index 1e94f6af90f..e6c2ff28142 100644 --- a/src/test/run-pass/lambda-infer-unresolved.rs +++ b/src/test/run-pass/lambda-infer-unresolved.rs @@ -14,7 +14,7 @@ struct Refs { mut refs: ~[int], n: int } -fn main() { +pub fn main() { let e = @Refs{mut refs: ~[], n: 0}; let f = fn@ () { log(error, e.n); }; e.refs += ~[1]; diff --git a/src/test/run-pass/lambda-no-leak.rs b/src/test/run-pass/lambda-no-leak.rs index 9282509fe17..9868f026c65 100644 --- a/src/test/run-pass/lambda-no-leak.rs +++ b/src/test/run-pass/lambda-no-leak.rs @@ -10,7 +10,7 @@ // Make sure we don't leak fn@s in silly ways. fn force(f: fn@()) { f() } -fn main() { +pub fn main() { let x = 7; let _f = fn@() { log(error, x); }; force(fn@() { log(error, x); }); diff --git a/src/test/run-pass/large-records.rs b/src/test/run-pass/large-records.rs index 21b68a07560..1ba5b10e9b7 100644 --- a/src/test/run-pass/large-records.rs +++ b/src/test/run-pass/large-records.rs @@ -41,4 +41,4 @@ fn f() { l: 0}; } -fn main() { f(); } +pub fn main() { f(); } diff --git a/src/test/run-pass/last-use-in-block.rs b/src/test/run-pass/last-use-in-block.rs index a770a8217c9..77dfbe237e3 100644 --- a/src/test/run-pass/last-use-in-block.rs +++ b/src/test/run-pass/last-use-in-block.rs @@ -15,7 +15,7 @@ fn lp<T>(s: ~str, f: fn(~str) -> T) -> T { let r = f(s); return (move r); } - fail; + die!(); } fn apply<T>(s: ~str, f: fn(~str) -> T) -> T { @@ -23,4 +23,4 @@ fn apply<T>(s: ~str, f: fn(~str) -> T) -> T { g(s, |v| { let r = f(v); move r }) } -fn main() {} +pub fn main() {} diff --git a/src/test/run-pass/last-use-in-cap-clause.rs b/src/test/run-pass/last-use-in-cap-clause.rs index ee08b18de16..e8cb47b3738 100644 --- a/src/test/run-pass/last-use-in-cap-clause.rs +++ b/src/test/run-pass/last-use-in-cap-clause.rs @@ -18,6 +18,6 @@ fn foo() -> fn@() -> int { return fn@(move k) -> int { 22 }; } -fn main() { +pub fn main() { assert foo()() == 22; } diff --git a/src/test/run-pass/last-use-is-capture.rs b/src/test/run-pass/last-use-is-capture.rs index 885b3a83da6..7f4551b9f39 100644 --- a/src/test/run-pass/last-use-is-capture.rs +++ b/src/test/run-pass/last-use-is-capture.rs @@ -12,7 +12,7 @@ struct A { a: ~int } -fn main() { +pub fn main() { fn invoke(f: fn@()) { f(); } let k = ~22; let _u = A {a: copy k}; diff --git a/src/test/run-pass/lazy-and-or.rs b/src/test/run-pass/lazy-and-or.rs index 3af7902ef57..258f4714cf8 100644 --- a/src/test/run-pass/lazy-and-or.rs +++ b/src/test/run-pass/lazy-and-or.rs @@ -12,7 +12,7 @@ fn incr(x: &mut int) -> bool { *x += 1; assert (false); return false; } -fn main() { +pub fn main() { let x = 1 == 2 || 3 == 3; assert (x); let mut y: int = 10; diff --git a/src/test/run-pass/lazy-init.rs b/src/test/run-pass/lazy-init.rs index 662a4ddc61a..0ccecba58c0 100644 --- a/src/test/run-pass/lazy-init.rs +++ b/src/test/run-pass/lazy-init.rs @@ -12,4 +12,4 @@ fn foo(x: int) { log(debug, x); } -fn main() { let mut x: int; if 1 > 2 { x = 12; } else { x = 10; } foo(x); } +pub fn main() { let mut x: int; if 1 > 2 { x = 12; } else { x = 10; } foo(x); } diff --git a/src/test/run-pass/leak-box-as-tydesc.rs b/src/test/run-pass/leak-box-as-tydesc.rs index 152818e395a..94bd54e5b7c 100644 --- a/src/test/run-pass/leak-box-as-tydesc.rs +++ b/src/test/run-pass/leak-box-as-tydesc.rs @@ -12,4 +12,4 @@ fn leaky<T>(t: T) { } -fn main() { let x = @10; leaky::<@int>(x); } +pub fn main() { let x = @10; leaky::<@int>(x); } diff --git a/src/test/run-pass/leak-tag-copy.rs b/src/test/run-pass/leak-tag-copy.rs index 089febc49f1..05b8e361ae7 100644 --- a/src/test/run-pass/leak-tag-copy.rs +++ b/src/test/run-pass/leak-tag-copy.rs @@ -12,4 +12,4 @@ enum t { a, b(@int), } -fn main() { let mut x = b(@10); x = a; } +pub fn main() { let mut x = b(@10); x = a; } diff --git a/src/test/run-pass/leak-unique-as-tydesc.rs b/src/test/run-pass/leak-unique-as-tydesc.rs index b58adde6a6e..98c092a68c9 100644 --- a/src/test/run-pass/leak-unique-as-tydesc.rs +++ b/src/test/run-pass/leak-unique-as-tydesc.rs @@ -12,4 +12,4 @@ fn leaky<T>(t: T) { } -fn main() { let x = ~10; leaky::<~int>(x); } +pub fn main() { let x = ~10; leaky::<~int>(x); } diff --git a/src/test/run-pass/let-assignability.rs b/src/test/run-pass/let-assignability.rs index 453d556b13c..51fa84613ca 100644 --- a/src/test/run-pass/let-assignability.rs +++ b/src/test/run-pass/let-assignability.rs @@ -14,7 +14,7 @@ fn f() { io::println(b); } -fn main() { +pub fn main() { f(); } diff --git a/src/test/run-pass/let-destruct-fresh-mem.rs b/src/test/run-pass/let-destruct-fresh-mem.rs index ba7fd4fee5e..caccd1ac15c 100644 --- a/src/test/run-pass/let-destruct-fresh-mem.rs +++ b/src/test/run-pass/let-destruct-fresh-mem.rs @@ -11,7 +11,7 @@ struct X { x: int, y: @A } struct A { a: int } -fn main() { +pub fn main() { let u = X {x: 10, y: @A {a: 20}}; let mut X {x: x, y: @A {a: a}} = u; x = 100; diff --git a/src/test/run-pass/let-destruct.rs b/src/test/run-pass/let-destruct.rs index be9c8bdf2d6..1a111135563 100644 --- a/src/test/run-pass/let-destruct.rs +++ b/src/test/run-pass/let-destruct.rs @@ -12,7 +12,7 @@ enum xx = int; struct X { x: xx, y: int } -fn main() { +pub fn main() { let @X {x: xx(x), y: y} = @X{x: xx(10), y: 20}; assert (x + y == 30); } diff --git a/src/test/run-pass/linear-for-loop.rs b/src/test/run-pass/linear-for-loop.rs index 6abf9369645..bad813aef52 100644 --- a/src/test/run-pass/linear-for-loop.rs +++ b/src/test/run-pass/linear-for-loop.rs @@ -10,7 +10,7 @@ -fn main() { +pub fn main() { let x = ~[1, 2, 3]; let mut y = 0; for x.each |i| { log(debug, *i); y += *i; } diff --git a/src/test/run-pass/lint-non-camel-case-with-trailing-underscores.rs b/src/test/run-pass/lint-non-camel-case-with-trailing-underscores.rs index 2aab96b3177..f51312bc257 100644 --- a/src/test/run-pass/lint-non-camel-case-with-trailing-underscores.rs +++ b/src/test/run-pass/lint-non-camel-case-with-trailing-underscores.rs @@ -13,4 +13,4 @@ #[forbid(non_camel_case_types)] type Foo_ = int; -fn main() { } +pub fn main() { } diff --git a/src/test/run-pass/lint-structural-records.rs b/src/test/run-pass/lint-structural-records.rs index 1ed4226155e..9a812b77cb8 100644 --- a/src/test/run-pass/lint-structural-records.rs +++ b/src/test/run-pass/lint-structural-records.rs @@ -9,6 +9,6 @@ // except according to those terms. #[warn(structural_records)]; -fn main() { +pub fn main() { let _foo = {x:5}; } \ No newline at end of file diff --git a/src/test/run-pass/list.rs b/src/test/run-pass/list.rs index 25402bf4878..b8a9d2ee9e3 100644 --- a/src/test/run-pass/list.rs +++ b/src/test/run-pass/list.rs @@ -14,4 +14,4 @@ // -*- rust -*- enum list { cons(int, @list), nil, } -fn main() { cons(10, @cons(11, @cons(12, @nil))); } +pub fn main() { cons(10, @cons(11, @cons(12, @nil))); } diff --git a/src/test/run-pass/liveness-assign-imm-local-after-loop.rs b/src/test/run-pass/liveness-assign-imm-local-after-loop.rs index 570f5979bd7..f352a2b5273 100644 --- a/src/test/run-pass/liveness-assign-imm-local-after-loop.rs +++ b/src/test/run-pass/liveness-assign-imm-local-after-loop.rs @@ -15,6 +15,6 @@ fn test(cond: bool) { v = 2; } -fn main() { +pub fn main() { // note: don't call test()... :) } diff --git a/src/test/run-pass/liveness-assign-imm-local-after-ret.rs b/src/test/run-pass/liveness-assign-imm-local-after-ret.rs index 5a2cac57130..e9c12277286 100644 --- a/src/test/run-pass/liveness-assign-imm-local-after-ret.rs +++ b/src/test/run-pass/liveness-assign-imm-local-after-ret.rs @@ -15,5 +15,5 @@ fn test() { _v = 2; //~ WARNING: unreachable statement } -fn main() { +pub fn main() { } diff --git a/src/test/run-pass/liveness-loop-break.rs b/src/test/run-pass/liveness-loop-break.rs index 11c3c6e7eb1..7a379d10ff9 100644 --- a/src/test/run-pass/liveness-loop-break.rs +++ b/src/test/run-pass/liveness-loop-break.rs @@ -17,6 +17,6 @@ fn test() { debug!("%d", v); } -fn main() { +pub fn main() { test(); } diff --git a/src/test/run-pass/liveness-move-in-loop.rs b/src/test/run-pass/liveness-move-in-loop.rs index 9c649fed87b..f8166e2443d 100644 --- a/src/test/run-pass/liveness-move-in-loop.rs +++ b/src/test/run-pass/liveness-move-in-loop.rs @@ -22,4 +22,4 @@ fn the_loop() { } } -fn main() {} +pub fn main() {} diff --git a/src/test/run-pass/log-degen-enum.rs b/src/test/run-pass/log-degen-enum.rs index ba9a2e9a641..fc17ec96ea6 100644 --- a/src/test/run-pass/log-degen-enum.rs +++ b/src/test/run-pass/log-degen-enum.rs @@ -10,7 +10,7 @@ enum Foo = uint; -fn main() { +pub fn main() { let x = Foo(1); let y = fmt!("%?", x); assert y == ~"Foo(1)"; diff --git a/src/test/run-pass/log-err-phi.rs b/src/test/run-pass/log-err-phi.rs index c3e20b85840..df4f754ae7e 100644 --- a/src/test/run-pass/log-err-phi.rs +++ b/src/test/run-pass/log-err-phi.rs @@ -10,4 +10,4 @@ -fn main() { if false { log(error, ~"foo" + ~"bar"); } } +pub fn main() { if false { log(error, ~"foo" + ~"bar"); } } diff --git a/src/test/run-pass/log-knows-the-names-of-variants-in-std.rs b/src/test/run-pass/log-knows-the-names-of-variants-in-std.rs index af2fe623c44..46db3d32340 100644 --- a/src/test/run-pass/log-knows-the-names-of-variants-in-std.rs +++ b/src/test/run-pass/log-knows-the-names-of-variants-in-std.rs @@ -22,7 +22,7 @@ fn check_log<T>(exp: ~str, v: T) { assert exp == fmt!("%?", v); } -fn main() { +pub fn main() { let x = list::from_vec(~[a(22u), b(~"hi")]); let exp = ~"@Cons(a(22), @Cons(b(~\"hi\"), @Nil))"; let act = fmt!("%?", x); diff --git a/src/test/run-pass/log-knows-the-names-of-variants.rs b/src/test/run-pass/log-knows-the-names-of-variants.rs index 0b9d07b1948..dcf11afbc17 100644 --- a/src/test/run-pass/log-knows-the-names-of-variants.rs +++ b/src/test/run-pass/log-knows-the-names-of-variants.rs @@ -18,7 +18,7 @@ enum bar { d, e, f } -fn main() { +pub fn main() { assert ~"a(22)" == fmt!("%?", a(22u)); assert ~"b(~\"hi\")" == fmt!("%?", b(~"hi")); assert ~"c" == fmt!("%?", c); diff --git a/src/test/run-pass/log-linearized.rs b/src/test/run-pass/log-linearized.rs index 73e16085c4e..db0b24fca1d 100644 --- a/src/test/run-pass/log-linearized.rs +++ b/src/test/run-pass/log-linearized.rs @@ -15,12 +15,12 @@ enum option<T> { some(T), } -struct Smallintmap<T> {mut v: ~[mut option<T>]} +struct Smallintmap<T> {mut v: ~[option<T>]} -struct V<T> { v: ~[mut option<T>] } +struct V<T> { v: ~[option<T>] } fn mk<T>() -> @Smallintmap<T> { - let v: ~[mut option<T>] = ~[mut]; + let mut v: ~[option<T>] = ~[]; return @Smallintmap {mut v: move v}; } @@ -29,7 +29,7 @@ fn f<T,U>() { log(error, sim); } -fn main() { +pub fn main() { f::<int,int>(); } diff --git a/src/test/run-pass/log-str.rs b/src/test/run-pass/log-str.rs index 64616f26c88..3774253b59b 100644 --- a/src/test/run-pass/log-str.rs +++ b/src/test/run-pass/log-str.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -fn main() { +pub fn main() { let act = sys::log_str(&~[1, 2, 3]); assert ~"~[1, 2, 3]" == act; diff --git a/src/test/run-pass/long-while.rs b/src/test/run-pass/long-while.rs index 27dc8b494b1..3e4a33981d9 100644 --- a/src/test/run-pass/long-while.rs +++ b/src/test/run-pass/long-while.rs @@ -10,4 +10,4 @@ -fn main() { let mut i: int = 0; while i < 1000000 { i += 1; let x = 3; } } +pub fn main() { let mut i: int = 0; while i < 1000000 { i += 1; let x = 3; } } diff --git a/src/test/run-pass/loop-break-cont-1.rs b/src/test/run-pass/loop-break-cont-1.rs index f04fe4c87f4..1634f36df53 100644 --- a/src/test/run-pass/loop-break-cont-1.rs +++ b/src/test/run-pass/loop-break-cont-1.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -fn main() { +pub fn main() { let i = 0u; loop { break; diff --git a/src/test/run-pass/loop-break-cont.rs b/src/test/run-pass/loop-break-cont.rs index 0035cb15b71..3be3d5f7585 100644 --- a/src/test/run-pass/loop-break-cont.rs +++ b/src/test/run-pass/loop-break-cont.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -fn main() { +pub fn main() { let mut i = 0u; loop { log(error, ~"a"); diff --git a/src/test/run-pass/loop-diverges.rs b/src/test/run-pass/loop-diverges.rs index 63ccf383e15..27838fe642a 100644 --- a/src/test/run-pass/loop-diverges.rs +++ b/src/test/run-pass/loop-diverges.rs @@ -15,6 +15,6 @@ fn forever() -> ! { loop{} } -fn main() { +pub fn main() { if (1 == 2) { forever(); } } \ No newline at end of file diff --git a/src/test/run-pass/loop-scope.rs b/src/test/run-pass/loop-scope.rs index 0f0582940fa..df5b55268a1 100644 --- a/src/test/run-pass/loop-scope.rs +++ b/src/test/run-pass/loop-scope.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -fn main() { +pub fn main() { let x = ~[10, 20, 30]; let mut sum = 0; for x.each |x| { sum += *x; } diff --git a/src/test/run-pass/lots-a-fail.rs b/src/test/run-pass/lots-a-fail.rs index ae759e07437..41c3516bef2 100644 --- a/src/test/run-pass/lots-a-fail.rs +++ b/src/test/run-pass/lots-a-fail.rs @@ -12,14 +12,14 @@ extern mod std; fn die() { - fail; + die!(); } fn iloop() { task::spawn(|| die() ); } -fn main() { +pub fn main() { for uint::range(0u, 100u) |_i| { task::spawn_unlinked(|| iloop() ); } diff --git a/src/test/run-pass/macro-2.rs b/src/test/run-pass/macro-2.rs index 79690e5061a..c280423190f 100644 --- a/src/test/run-pass/macro-2.rs +++ b/src/test/run-pass/macro-2.rs @@ -10,7 +10,7 @@ // xfail-pretty - token trees can't pretty print -fn main() { +pub fn main() { macro_rules! mylambda_tt( ($x:ident, $body:expr) => ({ diff --git a/src/test/run-pass/macro-interpolation.rs b/src/test/run-pass/macro-interpolation.rs index fa6fdf73e79..4bb87ab0cca 100644 --- a/src/test/run-pass/macro-interpolation.rs +++ b/src/test/run-pass/macro-interpolation.rs @@ -17,13 +17,13 @@ macro_rules! overly_complicated ( Some($pat) => { $res } - _ => { fail; } + _ => { die!(); } } }) ) -fn main() { +pub fn main() { assert overly_complicated!(f, x, Option<uint>, { return Some(x); }, Some(8u), Some(y), y) == 8u -} \ No newline at end of file +} diff --git a/src/test/run-pass/macro-path.rs b/src/test/run-pass/macro-path.rs index 6b59ff66709..a721f8c9469 100644 --- a/src/test/run-pass/macro-path.rs +++ b/src/test/run-pass/macro-path.rs @@ -19,6 +19,6 @@ macro_rules! foo { }) } -fn main() { +pub fn main() { assert foo!(m::t) == 10; } diff --git a/src/test/run-pass/macro-stmt.rs b/src/test/run-pass/macro-stmt.rs index dfaaf0e54d3..b4b0d3d0a22 100644 --- a/src/test/run-pass/macro-stmt.rs +++ b/src/test/run-pass/macro-stmt.rs @@ -18,7 +18,7 @@ macro_rules! myfn( myfn!(add, (a,b), { return a+b; } ) -fn main() { +pub fn main() { macro_rules! mylet( ($x:ident, $val:expr) => ( diff --git a/src/test/run-pass/max-min-classes.rs b/src/test/run-pass/max-min-classes.rs index 816fe99c2d8..7247afeacd6 100644 --- a/src/test/run-pass/max-min-classes.rs +++ b/src/test/run-pass/max-min-classes.rs @@ -33,7 +33,7 @@ fn Foo(x: int, y: int) -> Foo { Foo { x: x, y: y } } -fn main() { +pub fn main() { let foo = Foo(3, 20); io::println(fmt!("%d %d", foo.sum(), foo.product())); } diff --git a/src/test/run-pass/maybe-mutable.rs b/src/test/run-pass/maybe-mutable.rs index f18d201f5ab..c2532369942 100644 --- a/src/test/run-pass/maybe-mutable.rs +++ b/src/test/run-pass/maybe-mutable.rs @@ -18,9 +18,9 @@ fn len(v: ~[const int]) -> uint { return i; } -fn main() { +pub fn main() { let v0 = ~[1, 2, 3, 4, 5]; log(debug, len(v0)); - let v1 = ~[mut 1, 2, 3, 4, 5]; + let mut v1 = ~[1, 2, 3, 4, 5]; log(debug, len(v1)); } diff --git a/src/test/run-pass/method-attributes.rs b/src/test/run-pass/method-attributes.rs index ed911abdb46..e3d4a2aff9f 100644 --- a/src/test/run-pass/method-attributes.rs +++ b/src/test/run-pass/method-attributes.rs @@ -31,4 +31,4 @@ impl int: frobable { } } -fn main() { } +pub fn main() { } diff --git a/src/test/run-pass/mlist-cycle.rs b/src/test/run-pass/mlist-cycle.rs index 7dd2fc99ad3..537ce1bb218 100644 --- a/src/test/run-pass/mlist-cycle.rs +++ b/src/test/run-pass/mlist-cycle.rs @@ -16,7 +16,7 @@ type cell = {mut c: @list}; enum list { link(@cell), nil, } -fn main() { +pub fn main() { let first: @cell = @{mut c: @nil()}; let second: @cell = @{mut c: @link(first)}; first._0 = @link(second); diff --git a/src/test/run-pass/mlist.rs b/src/test/run-pass/mlist.rs index 45f03d751b7..cfb1db49465 100644 --- a/src/test/run-pass/mlist.rs +++ b/src/test/run-pass/mlist.rs @@ -11,4 +11,4 @@ enum mlist { cons(int, @mlist), nil, } -fn main() { cons(10, @cons(11, @cons(12, @nil))); } +pub fn main() { cons(10, @cons(11, @cons(12, @nil))); } diff --git a/src/test/run-pass/mod-inside-fn.rs b/src/test/run-pass/mod-inside-fn.rs index 79b43173228..75dd2af9943 100644 --- a/src/test/run-pass/mod-inside-fn.rs +++ b/src/test/run-pass/mod-inside-fn.rs @@ -16,6 +16,6 @@ fn f() -> int { m::g() } -fn main() { +pub fn main() { assert f() == 720; } diff --git a/src/test/run-pass/mod-merge-hack.rs b/src/test/run-pass/mod-merge-hack.rs index 471c0602cd4..20df4978508 100644 --- a/src/test/run-pass/mod-merge-hack.rs +++ b/src/test/run-pass/mod-merge-hack.rs @@ -13,7 +13,7 @@ #[merge = "mod-merge-hack-inst.rs"] mod myint32; -fn main() { +pub fn main() { assert myint32::bits == 32; assert myint32::min(10, 20) == 10; } \ No newline at end of file diff --git a/src/test/run-pass/mod-view-items.rs b/src/test/run-pass/mod-view-items.rs index fdb1d01727a..7dbcb72f1ea 100644 --- a/src/test/run-pass/mod-view-items.rs +++ b/src/test/run-pass/mod-view-items.rs @@ -21,4 +21,4 @@ mod m { pub fn f() -> ~[int] { vec::from_elem(1u, 0) } } -fn main() { let x = m::f(); } +pub fn main() { let x = m::f(); } diff --git a/src/test/run-pass/mod_dir_path.rs b/src/test/run-pass/mod_dir_path.rs index dd422ecda85..a79115a6fb8 100644 --- a/src/test/run-pass/mod_dir_path.rs +++ b/src/test/run-pass/mod_dir_path.rs @@ -16,6 +16,6 @@ mod mod_dir_simple { pub mod syrup; } -fn main() { +pub fn main() { assert mod_dir_simple::syrup::foo() == 10; } diff --git a/src/test/run-pass/mod_dir_path2.rs b/src/test/run-pass/mod_dir_path2.rs index a47ff1153ea..0d3ed8b2b0b 100644 --- a/src/test/run-pass/mod_dir_path2.rs +++ b/src/test/run-pass/mod_dir_path2.rs @@ -17,6 +17,6 @@ mod pancakes { pub mod syrup; } -fn main() { +pub fn main() { assert pancakes::syrup::foo() == 10; } diff --git a/src/test/run-pass/mod_dir_path3.rs b/src/test/run-pass/mod_dir_path3.rs index 64e3a9e8277..06c9e507d2f 100644 --- a/src/test/run-pass/mod_dir_path3.rs +++ b/src/test/run-pass/mod_dir_path3.rs @@ -16,6 +16,6 @@ mod pancakes { pub mod test; } -fn main() { +pub fn main() { assert pancakes::test::foo() == 10; } diff --git a/src/test/run-pass/mod_dir_path_multi.rs b/src/test/run-pass/mod_dir_path_multi.rs index 6a50d479e06..43f94303863 100644 --- a/src/test/run-pass/mod_dir_path_multi.rs +++ b/src/test/run-pass/mod_dir_path_multi.rs @@ -21,7 +21,7 @@ mod gravy { pub mod test; } -fn main() { +pub fn main() { assert biscuits::test::foo() == 10; assert gravy::test::foo() == 10; } diff --git a/src/test/run-pass/mod_dir_recursive.rs b/src/test/run-pass/mod_dir_recursive.rs index b95852f3a31..4377334309f 100644 --- a/src/test/run-pass/mod_dir_recursive.rs +++ b/src/test/run-pass/mod_dir_recursive.rs @@ -19,6 +19,6 @@ mod mod_dir_simple { pub mod load_another_mod; } -fn main() { +pub fn main() { assert mod_dir_simple::load_another_mod::test::foo() == 10; } diff --git a/src/test/run-pass/mod_dir_simple.rs b/src/test/run-pass/mod_dir_simple.rs index 7f07982a65b..9303d8184e0 100644 --- a/src/test/run-pass/mod_dir_simple.rs +++ b/src/test/run-pass/mod_dir_simple.rs @@ -15,6 +15,6 @@ mod mod_dir_simple { pub mod test; } -fn main() { +pub fn main() { assert mod_dir_simple::test::foo() == 10; } diff --git a/src/test/run-pass/mod_file.rs b/src/test/run-pass/mod_file.rs index 962c47df384..1fedf0c7874 100644 --- a/src/test/run-pass/mod_file.rs +++ b/src/test/run-pass/mod_file.rs @@ -14,6 +14,6 @@ mod mod_file_aux; -fn main() { +pub fn main() { assert mod_file_aux::foo() == 10; } \ No newline at end of file diff --git a/src/test/run-pass/mod_file_with_path_attr.rs b/src/test/run-pass/mod_file_with_path_attr.rs index 5b03e5dc3aa..b7172a3d50c 100644 --- a/src/test/run-pass/mod_file_with_path_attr.rs +++ b/src/test/run-pass/mod_file_with_path_attr.rs @@ -15,6 +15,6 @@ #[path = "mod_file_aux.rs"] mod m; -fn main() { +pub fn main() { assert m::foo() == 10; } \ No newline at end of file diff --git a/src/test/run-pass/module-qualified-struct-destructure.rs b/src/test/run-pass/module-qualified-struct-destructure.rs index be0b9e85ff0..6fb6d21f13f 100644 --- a/src/test/run-pass/module-qualified-struct-destructure.rs +++ b/src/test/run-pass/module-qualified-struct-destructure.rs @@ -15,7 +15,7 @@ mod m { } } -fn main() { +pub fn main() { let x = m::S { x: 1, y: 2 }; let m::S { x: a, y: b } = x; } diff --git a/src/test/run-pass/monad.rs b/src/test/run-pass/monad.rs index 210defa5789..b5c6d835374 100644 --- a/src/test/run-pass/monad.rs +++ b/src/test/run-pass/monad.rs @@ -40,7 +40,7 @@ fn transform(x: Option<int>) -> Option<~str> { x.bind(|n| Some(n + 1) ).bind(|n| Some(int::str(n)) ) } -fn main() { +pub fn main() { assert transform(Some(10)) == Some(~"11"); assert transform(None) == None; assert (~[~"hi"]) diff --git a/src/test/run-pass/monomorphize-trait-in-fn-at.rs b/src/test/run-pass/monomorphize-trait-in-fn-at.rs index bdb5aac439e..bce5bb9cade 100644 --- a/src/test/run-pass/monomorphize-trait-in-fn-at.rs +++ b/src/test/run-pass/monomorphize-trait-in-fn-at.rs @@ -24,7 +24,7 @@ impl (): ty_ops { fn mk() -> uint { 22u } } -fn main() { +pub fn main() { let fn_env = fn@() -> uint { mk_nil(()) }; diff --git a/src/test/run-pass/monomorphized-callees-with-ty-params-3314.rs b/src/test/run-pass/monomorphized-callees-with-ty-params-3314.rs index f020449e567..72933f18d6f 100644 --- a/src/test/run-pass/monomorphized-callees-with-ty-params-3314.rs +++ b/src/test/run-pass/monomorphized-callees-with-ty-params-3314.rs @@ -32,7 +32,7 @@ impl<A: Copy Serializable> F<A>: Serializable { impl io::Writer: Serializer { } -fn main() { +pub fn main() { do io::with_str_writer |wr| { let foo = F { a: 1 }; foo.serialize(wr); diff --git a/src/test/run-pass/morestack-address.rs b/src/test/run-pass/morestack-address.rs index 609d7d57011..f33af8abd57 100644 --- a/src/test/run-pass/morestack-address.rs +++ b/src/test/run-pass/morestack-address.rs @@ -14,7 +14,7 @@ extern mod rusti { pub fn morestack_addr() -> *(); } -fn main() { +pub fn main() { unsafe { let addr = rusti::morestack_addr(); assert addr.is_not_null(); diff --git a/src/test/run-pass/morestack1.rs b/src/test/run-pass/morestack1.rs index 5e93a2a88c3..c31dae404c6 100644 --- a/src/test/run-pass/morestack1.rs +++ b/src/test/run-pass/morestack1.rs @@ -14,6 +14,6 @@ fn getbig(i: int) { } } -fn main() { +pub fn main() { getbig(100000); } \ No newline at end of file diff --git a/src/test/run-pass/morestack2.rs b/src/test/run-pass/morestack2.rs index 03288711bb2..5b2c016d44b 100644 --- a/src/test/run-pass/morestack2.rs +++ b/src/test/run-pass/morestack2.rs @@ -19,6 +19,6 @@ fn getbig(i: int) -> int { m } -fn main() { +pub fn main() { getbig(10000); } \ No newline at end of file diff --git a/src/test/run-pass/morestack3.rs b/src/test/run-pass/morestack3.rs index a6317980b65..717536a2fbc 100644 --- a/src/test/run-pass/morestack3.rs +++ b/src/test/run-pass/morestack3.rs @@ -46,7 +46,7 @@ fn getbig(a0: int, return a0; } -fn main() { +pub fn main() { let a = 10000; getbig(a, a+1, a+2, a+3, a+4, a+5, a+6, a+7, a+8, a+9); } \ No newline at end of file diff --git a/src/test/run-pass/morestack4.rs b/src/test/run-pass/morestack4.rs index 35b2993ca33..8f9a2575412 100644 --- a/src/test/run-pass/morestack4.rs +++ b/src/test/run-pass/morestack4.rs @@ -61,7 +61,7 @@ fn getbig(i: Biggy) { } } -fn main() { +pub fn main() { getbig(Biggy { a00: 10000u64, a01: 10000u64, diff --git a/src/test/run-pass/morestack5.rs b/src/test/run-pass/morestack5.rs index 4652ad3edfc..c0407b6e786 100644 --- a/src/test/run-pass/morestack5.rs +++ b/src/test/run-pass/morestack5.rs @@ -18,7 +18,7 @@ fn getbig(&&i: int) { } } -fn main() { +pub fn main() { let mut sz = 400u; while sz < 500u { task::try(|| getbig(200) ); diff --git a/src/test/run-pass/morestack6.rs b/src/test/run-pass/morestack6.rs index 352fe3e129d..4a254f6a7eb 100644 --- a/src/test/run-pass/morestack6.rs +++ b/src/test/run-pass/morestack6.rs @@ -53,7 +53,7 @@ fn runtest2(f: fn~(), frame_backoff: u32, last_stk: *u8) -> u32 { } } -fn main() { +pub fn main() { let fns = ~[ calllink01, calllink02, diff --git a/src/test/run-pass/move-1-unique.rs b/src/test/run-pass/move-1-unique.rs index c5d7e9783e4..380c969fa1c 100644 --- a/src/test/run-pass/move-1-unique.rs +++ b/src/test/run-pass/move-1-unique.rs @@ -17,7 +17,7 @@ fn test(x: bool, foo: ~Triple) -> int { return y.y; } -fn main() { +pub fn main() { let x = ~Triple{x: 1, y: 2, z: 3}; assert (test(true, copy x) == 2); assert (test(true, copy x) == 2); diff --git a/src/test/run-pass/move-1.rs b/src/test/run-pass/move-1.rs index 4c7e5682a13..ea6dc94bb8e 100644 --- a/src/test/run-pass/move-1.rs +++ b/src/test/run-pass/move-1.rs @@ -17,7 +17,7 @@ fn test(x: bool, foo: @Triple) -> int { return y.y; } -fn main() { +pub fn main() { let x = @Triple {x: 1, y: 2, z: 3}; assert (test(true, x) == 2); assert (test(true, x) == 2); diff --git a/src/test/run-pass/move-2-unique.rs b/src/test/run-pass/move-2-unique.rs index 096daf315eb..133837089b8 100644 --- a/src/test/run-pass/move-2-unique.rs +++ b/src/test/run-pass/move-2-unique.rs @@ -11,4 +11,4 @@ struct X { x: int, y: int, z: int } -fn main() { let x = ~X{x: 1, y: 2, z: 3}; let y = move x; assert (y.y == 2); } +pub fn main() { let x = ~X{x: 1, y: 2, z: 3}; let y = move x; assert (y.y == 2); } diff --git a/src/test/run-pass/move-2.rs b/src/test/run-pass/move-2.rs index 23746c924ad..f2b534765cf 100644 --- a/src/test/run-pass/move-2.rs +++ b/src/test/run-pass/move-2.rs @@ -11,4 +11,4 @@ struct X { x: int, y: int, z: int } -fn main() { let x = @X {x: 1, y: 2, z: 3}; let y = move x; assert (y.y == 2); } +pub fn main() { let x = @X {x: 1, y: 2, z: 3}; let y = move x; assert (y.y == 2); } diff --git a/src/test/run-pass/move-3-unique.rs b/src/test/run-pass/move-3-unique.rs index 5bf5654320a..40d8f9a9bce 100644 --- a/src/test/run-pass/move-3-unique.rs +++ b/src/test/run-pass/move-3-unique.rs @@ -19,7 +19,7 @@ fn test(x: bool, foo: ~Triple) -> int { return y.y; } -fn main() { +pub fn main() { let x = ~Triple{x: 1, y: 2, z: 3}; for uint::range(0u, 10000u) |_i| { assert (test(true, copy x) == 2); diff --git a/src/test/run-pass/move-3.rs b/src/test/run-pass/move-3.rs index 80de11091ee..0e57d0f6126 100644 --- a/src/test/run-pass/move-3.rs +++ b/src/test/run-pass/move-3.rs @@ -19,7 +19,7 @@ fn test(x: bool, foo: @Triple) -> int { return y.y; } -fn main() { +pub fn main() { let x = @Triple{x: 1, y: 2, z: 3}; for uint::range(0u, 10000u) |i| { assert (test(true, x) == 2); diff --git a/src/test/run-pass/move-4-unique.rs b/src/test/run-pass/move-4-unique.rs index 0c2ce79e6aa..7b7b816aeb2 100644 --- a/src/test/run-pass/move-4-unique.rs +++ b/src/test/run-pass/move-4-unique.rs @@ -20,4 +20,4 @@ fn test(foo: ~Triple) -> ~Triple { return quux; } -fn main() { let x = ~Triple{a: 1, b: 2, c: 3}; let y = test(x); assert (y.c == 3); } +pub fn main() { let x = ~Triple{a: 1, b: 2, c: 3}; let y = test(x); assert (y.c == 3); } diff --git a/src/test/run-pass/move-4.rs b/src/test/run-pass/move-4.rs index 351b78807b8..cdb48b43b35 100644 --- a/src/test/run-pass/move-4.rs +++ b/src/test/run-pass/move-4.rs @@ -21,7 +21,7 @@ fn test(foo: @Triple) -> @Triple { return quux; } -fn main() { +pub fn main() { let x = @Triple{a: 1, b: 2, c: 3}; let y = test(x); assert (y.c == 3); diff --git a/src/test/run-pass/move-arg-2-unique.rs b/src/test/run-pass/move-arg-2-unique.rs index ac2f60900d6..e6a3670804b 100644 --- a/src/test/run-pass/move-arg-2-unique.rs +++ b/src/test/run-pass/move-arg-2-unique.rs @@ -10,7 +10,7 @@ fn test(-foo: ~~[int]) { assert (foo[0] == 10); } -fn main() { +pub fn main() { let x = ~~[10]; // Test forgetting a local by move-in test(move x); diff --git a/src/test/run-pass/move-arg-2.rs b/src/test/run-pass/move-arg-2.rs index b66e251dc43..09dc47ab50e 100644 --- a/src/test/run-pass/move-arg-2.rs +++ b/src/test/run-pass/move-arg-2.rs @@ -10,7 +10,7 @@ fn test(-foo: @~[int]) { assert (foo[0] == 10); } -fn main() { +pub fn main() { let x = @~[10]; // Test forgetting a local by move-in test(move x); diff --git a/src/test/run-pass/move-arg.rs b/src/test/run-pass/move-arg.rs index 8187b59da3b..8e65981ebdf 100644 --- a/src/test/run-pass/move-arg.rs +++ b/src/test/run-pass/move-arg.rs @@ -10,4 +10,4 @@ fn test(-foo: int) { assert (foo == 10); } -fn main() { let x = 10; test(move x); } +pub fn main() { let x = 10; test(move x); } diff --git a/src/test/run-pass/move-nullary-fn.rs b/src/test/run-pass/move-nullary-fn.rs index 854a00c37d6..77d4d2ccb36 100644 --- a/src/test/run-pass/move-nullary-fn.rs +++ b/src/test/run-pass/move-nullary-fn.rs @@ -15,6 +15,6 @@ fn f(-thing: fn@()) { f2(move thing); } -fn main() { +pub fn main() { f(fn@() {}); } \ No newline at end of file diff --git a/src/test/run-pass/move-scalar.rs b/src/test/run-pass/move-scalar.rs index c2f6466d4c6..533543ad138 100644 --- a/src/test/run-pass/move-scalar.rs +++ b/src/test/run-pass/move-scalar.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -fn main() { +pub fn main() { let y: int = 42; let mut x: int; diff --git a/src/test/run-pass/move-self.rs b/src/test/run-pass/move-self.rs index 5598839e31d..170dd520ed6 100644 --- a/src/test/run-pass/move-self.rs +++ b/src/test/run-pass/move-self.rs @@ -12,7 +12,7 @@ impl S { } } -fn main() { +pub fn main() { let x = S { x: ~"Hello!" }; x.foo(); } diff --git a/src/test/run-pass/moves-based-on-type-capture-clause.rs b/src/test/run-pass/moves-based-on-type-capture-clause.rs index 206d45b74fa..2f427ca48aa 100644 --- a/src/test/run-pass/moves-based-on-type-capture-clause.rs +++ b/src/test/run-pass/moves-based-on-type-capture-clause.rs @@ -1,4 +1,4 @@ -fn main() { +pub fn main() { let x = ~"Hello world!"; do task::spawn { io::println(x); diff --git a/src/test/run-pass/moves-based-on-type-cross-crate.rs b/src/test/run-pass/moves-based-on-type-cross-crate.rs index b2a5f7750dd..11038699a10 100644 --- a/src/test/run-pass/moves-based-on-type-cross-crate.rs +++ b/src/test/run-pass/moves-based-on-type-cross-crate.rs @@ -14,6 +14,6 @@ extern mod moves_based_on_type_lib; use moves_based_on_type_lib::f; -fn main() { +pub fn main() { f(); } diff --git a/src/test/run-pass/multi-let.rs b/src/test/run-pass/multi-let.rs index 06159a796d4..332e104ed77 100644 --- a/src/test/run-pass/multi-let.rs +++ b/src/test/run-pass/multi-let.rs @@ -8,4 +8,4 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -fn main() { let x = 10, y = x; assert (y == 10); } +pub fn main() { let x = 10, y = x; assert (y == 10); } diff --git a/src/test/run-pass/multiline-comment.rs b/src/test/run-pass/multiline-comment.rs index 993dea560cf..08fd933a142 100644 --- a/src/test/run-pass/multiline-comment.rs +++ b/src/test/run-pass/multiline-comment.rs @@ -13,4 +13,4 @@ /* * This is a multi-line oldcomment. */ -fn main() { } +pub fn main() { } diff --git a/src/test/run-pass/multiple-trait-bounds.rs b/src/test/run-pass/multiple-trait-bounds.rs index e64b51888ef..3c6559b9c0d 100644 --- a/src/test/run-pass/multiple-trait-bounds.rs +++ b/src/test/run-pass/multiple-trait-bounds.rs @@ -1,7 +1,7 @@ fn f<T:Eq + Ord>(_: T) { } -fn main() { +pub fn main() { f(3); } diff --git a/src/test/run-pass/mut-function-arguments.rs b/src/test/run-pass/mut-function-arguments.rs index b125db6f79c..ffa18e040e7 100644 --- a/src/test/run-pass/mut-function-arguments.rs +++ b/src/test/run-pass/mut-function-arguments.rs @@ -20,7 +20,7 @@ fn g() { } -fn main() { +pub fn main() { let z = ~17; f(z); g(); diff --git a/src/test/run-pass/mut-vstore-expr.rs b/src/test/run-pass/mut-vstore-expr.rs index e8d26e84f46..0ababc43c3f 100644 --- a/src/test/run-pass/mut-vstore-expr.rs +++ b/src/test/run-pass/mut-vstore-expr.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -fn main() { +pub fn main() { let x: &mut [int] = &mut [ 1, 2, 3 ]; } diff --git a/src/test/run-pass/mutability-inherits-through-fixed-length-vec.rs b/src/test/run-pass/mutability-inherits-through-fixed-length-vec.rs index 05b2aef8623..4acc052a732 100644 --- a/src/test/run-pass/mutability-inherits-through-fixed-length-vec.rs +++ b/src/test/run-pass/mutability-inherits-through-fixed-length-vec.rs @@ -20,7 +20,7 @@ fn test2() { for ints.each |i| { assert *i == 22; } } -fn main() { +pub fn main() { test1(); test2(); } diff --git a/src/test/run-pass/mutable-alias-vec.rs b/src/test/run-pass/mutable-alias-vec.rs index c7ebe4ad81c..b82bd82ea6b 100644 --- a/src/test/run-pass/mutable-alias-vec.rs +++ b/src/test/run-pass/mutable-alias-vec.rs @@ -15,7 +15,7 @@ extern mod std; fn grow(v: &mut ~[int]) { *v += ~[1]; } -fn main() { +pub fn main() { let mut v: ~[int] = ~[]; grow(&mut v); grow(&mut v); diff --git a/src/test/run-pass/mutable-huh-variance-vec1.rs b/src/test/run-pass/mutable-huh-variance-vec1.rs index 6ada02ee537..8db2705de2b 100644 --- a/src/test/run-pass/mutable-huh-variance-vec1.rs +++ b/src/test/run-pass/mutable-huh-variance-vec1.rs @@ -10,7 +10,7 @@ // error-pattern: mismatched types -fn main() { +pub fn main() { let v = ~[~[0]]; // This is ok because the outer vec is covariant with respect diff --git a/src/test/run-pass/mutable-huh-variance-vec2.rs b/src/test/run-pass/mutable-huh-variance-vec2.rs index b58404a40f0..7c48744000d 100644 --- a/src/test/run-pass/mutable-huh-variance-vec2.rs +++ b/src/test/run-pass/mutable-huh-variance-vec2.rs @@ -10,7 +10,7 @@ // error-pattern: mismatched types -fn main() { +pub fn main() { let v = ~[~[0]]; // This is ok because the outer vec is covariant with respect diff --git a/src/test/run-pass/mutable-vec-drop.rs b/src/test/run-pass/mutable-vec-drop.rs index f774e421348..d807791027f 100644 --- a/src/test/run-pass/mutable-vec-drop.rs +++ b/src/test/run-pass/mutable-vec-drop.rs @@ -11,8 +11,8 @@ struct Pair { a: int, b: int} -fn main() { +pub fn main() { // This just tests whether the vec leaks its members. - let pvec: ~[mut @Pair] = - ~[mut @Pair{a: 1, b: 2}, @Pair{a: 3, b: 4}, @Pair{a: 5, b: 6}]; + let mut pvec: ~[@Pair] = + ~[@Pair{a: 1, b: 2}, @Pair{a: 3, b: 4}, @Pair{a: 5, b: 6}]; } diff --git a/src/test/run-pass/mutual-recursion-group.rs b/src/test/run-pass/mutual-recursion-group.rs index c7da25eae3f..cf007e99d38 100644 --- a/src/test/run-pass/mutual-recursion-group.rs +++ b/src/test/run-pass/mutual-recursion-group.rs @@ -20,4 +20,4 @@ enum list { cons(@tree, @list), nil, } enum small_list { kons(int, @small_list), neel, } -fn main() { } +pub fn main() { } diff --git a/src/test/run-pass/negative.rs b/src/test/run-pass/negative.rs index fe1d19ee140..5b80a746260 100644 --- a/src/test/run-pass/negative.rs +++ b/src/test/run-pass/negative.rs @@ -8,9 +8,9 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -fn main() { +pub fn main() { match -5 { -5 => {} - _ => { fail } + _ => { die!() } } -} \ No newline at end of file +} diff --git a/src/test/run-pass/nested-alts.rs b/src/test/run-pass/nested-alts.rs index b88db77b653..f3b667209a0 100644 --- a/src/test/run-pass/nested-alts.rs +++ b/src/test/run-pass/nested-alts.rs @@ -9,7 +9,7 @@ // except according to those terms. -fn baz() -> ! { fail; } +fn baz() -> ! { die!(); } fn foo() { match Some::<int>(5) { @@ -22,4 +22,4 @@ fn foo() { } } -fn main() { foo(); } +pub fn main() { foo(); } diff --git a/src/test/run-pass/nested-class.rs b/src/test/run-pass/nested-class.rs index a67afb791e2..a753ec4b68b 100644 --- a/src/test/run-pass/nested-class.rs +++ b/src/test/run-pass/nested-class.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -fn main() { +pub fn main() { struct b { i: int, @@ -24,10 +24,10 @@ fn main() { } } - // fn b(x:int) -> int { fail; } + // fn b(x:int) -> int { die!(); } let z = b(42); assert(z.i == 42); assert(z.do_stuff() == 37); -} \ No newline at end of file +} diff --git a/src/test/run-pass/nested-exhaustive-alt.rs b/src/test/run-pass/nested-exhaustive-alt.rs index c6eb91c564d..e5ecd82be1d 100644 --- a/src/test/run-pass/nested-exhaustive-alt.rs +++ b/src/test/run-pass/nested-exhaustive-alt.rs @@ -10,7 +10,7 @@ struct Foo { foo: bool, bar: Option<int>, baz: int } -fn main() { +pub fn main() { match @Foo{foo: true, bar: Some(10), baz: 20} { @Foo{foo: true, bar: Some(_), _} => {} @Foo{foo: false, bar: None, _} => {} diff --git a/src/test/run-pass/nested-pattern.rs b/src/test/run-pass/nested-pattern.rs index 450b697bfb1..470aa43d1ad 100644 --- a/src/test/run-pass/nested-pattern.rs +++ b/src/test/run-pass/nested-pattern.rs @@ -16,9 +16,9 @@ enum t { foo(int, uint), bar(int, Option<int>), } fn nested(o: t) { match o { - bar(i, Some::<int>(_)) => { error!("wrong pattern matched"); fail; } + bar(i, Some::<int>(_)) => { error!("wrong pattern matched"); die!(); } _ => { error!("succeeded"); } } } -fn main() { nested(bar(1, None::<int>)); } +pub fn main() { nested(bar(1, None::<int>)); } diff --git a/src/test/run-pass/nested-patterns.rs b/src/test/run-pass/nested-patterns.rs index 06d630255c0..c4cc1519735 100644 --- a/src/test/run-pass/nested-patterns.rs +++ b/src/test/run-pass/nested-patterns.rs @@ -13,10 +13,10 @@ struct B { a: int, b: C } struct D { a: int, d: C } struct C { mut c: int } -fn main() { +pub fn main() { match A {a: 10, b: @20} { x@A {a, b: @20} => { assert x.a == 10; assert a == 10; } - A {b, _} => { fail; } + A {b, _} => { die!(); } } let x@B {b, _} = B {a: 10, b: C {mut c: 20}}; x.b.c = 30; diff --git a/src/test/run-pass/new-impl-syntax.rs b/src/test/run-pass/new-impl-syntax.rs index 4cb30ffa213..aad7ded42d3 100644 --- a/src/test/run-pass/new-impl-syntax.rs +++ b/src/test/run-pass/new-impl-syntax.rs @@ -4,7 +4,7 @@ struct Thingy { } impl ToStr for Thingy { - pure fn to_str() -> ~str { + pure fn to_str(&self) -> ~str { fmt!("{ x: %d, y: %d }", self.x, self.y) } } @@ -14,12 +14,12 @@ struct PolymorphicThingy<T> { } impl<T:ToStr> ToStr for PolymorphicThingy<T> { - pure fn to_str() -> ~str { + pure fn to_str(&self) -> ~str { self.x.to_str() } } -fn main() { +pub fn main() { io::println(Thingy { x: 1, y: 2 }.to_str()); io::println(PolymorphicThingy { x: Thingy { x: 1, y: 2 } }.to_str()); } diff --git a/src/test/run-pass/new-import-syntax.rs b/src/test/run-pass/new-import-syntax.rs index 37e47197c9a..3bc1b6c1eba 100644 --- a/src/test/run-pass/new-import-syntax.rs +++ b/src/test/run-pass/new-import-syntax.rs @@ -10,7 +10,7 @@ use io::println; -fn main() { +pub fn main() { println("Hello world!"); } diff --git a/src/test/run-pass/new-vstore-mut-box-syntax.rs b/src/test/run-pass/new-vstore-mut-box-syntax.rs index 85d7bbf27e1..971e870d1f8 100644 --- a/src/test/run-pass/new-vstore-mut-box-syntax.rs +++ b/src/test/run-pass/new-vstore-mut-box-syntax.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -fn main() { +pub fn main() { let x: @mut [int] = @mut [ 1, 2, 3 ]; } diff --git a/src/test/run-pass/newlambdas-ret-infer.rs b/src/test/run-pass/newlambdas-ret-infer.rs index b79573b1f30..0838ae83cb5 100644 --- a/src/test/run-pass/newlambdas-ret-infer.rs +++ b/src/test/run-pass/newlambdas-ret-infer.rs @@ -15,5 +15,5 @@ fn shared() -> fn@() { return || (); } fn unique() -> fn~() { return || (); } -fn main() { +pub fn main() { } diff --git a/src/test/run-pass/newlambdas-ret-infer2.rs b/src/test/run-pass/newlambdas-ret-infer2.rs index 68106f4d20d..4a4be9859d1 100644 --- a/src/test/run-pass/newlambdas-ret-infer2.rs +++ b/src/test/run-pass/newlambdas-ret-infer2.rs @@ -16,5 +16,5 @@ fn shared() -> fn@() { || () } fn unique() -> fn~() { || () } -fn main() { +pub fn main() { } diff --git a/src/test/run-pass/newlambdas.rs b/src/test/run-pass/newlambdas.rs index 0b881d95c55..c47ee5098a5 100644 --- a/src/test/run-pass/newlambdas.rs +++ b/src/test/run-pass/newlambdas.rs @@ -18,7 +18,7 @@ fn ff() -> fn@(int) -> int { return |x| x + 1; } -fn main() { +pub fn main() { assert f(10, |a| a) == 10; g(||()); assert do f(10) |a| { a } == 10; diff --git a/src/test/run-pass/newtype-polymorphic.rs b/src/test/run-pass/newtype-polymorphic.rs index 6eb2fcdd520..dfa1008a69e 100644 --- a/src/test/run-pass/newtype-polymorphic.rs +++ b/src/test/run-pass/newtype-polymorphic.rs @@ -14,7 +14,7 @@ fn myvec_deref<X: Copy>(mv: myvec<X>) -> ~[X] { return copy *mv; } fn myvec_elt<X: Copy>(mv: myvec<X>) -> X { return mv[0]; } -fn main() { +pub fn main() { let mv = myvec(~[1, 2, 3]); assert (myvec_deref(copy mv)[1] == 2); assert (myvec_elt(copy mv) == 1); diff --git a/src/test/run-pass/newtype.rs b/src/test/run-pass/newtype.rs index cb781ae6a99..697a579f4bc 100644 --- a/src/test/run-pass/newtype.rs +++ b/src/test/run-pass/newtype.rs @@ -14,7 +14,7 @@ struct Mytype {compute: extern fn(mytype) -> int, val: int} fn compute(i: mytype) -> int { return i.val + 20; } -fn main() { +pub fn main() { let myval = mytype(Mytype{compute: compute, val: 30}); assert ((myval.compute)(myval) == 50); } diff --git a/src/test/run-pass/nil-decl-in-foreign.rs b/src/test/run-pass/nil-decl-in-foreign.rs index 40f4b2339e5..edd3eac48b2 100644 --- a/src/test/run-pass/nil-decl-in-foreign.rs +++ b/src/test/run-pass/nil-decl-in-foreign.rs @@ -13,4 +13,4 @@ extern mod libc { pub fn printf(x: ()); } -fn main() { } +pub fn main() { } diff --git a/src/test/run-pass/nil-pattern.rs b/src/test/run-pass/nil-pattern.rs index 9c629935ba2..329590b547d 100644 --- a/src/test/run-pass/nil-pattern.rs +++ b/src/test/run-pass/nil-pattern.rs @@ -8,4 +8,4 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -fn main() { let x = (); match x { () => { } } } +pub fn main() { let x = (); match x { () => { } } } diff --git a/src/test/run-pass/non-boolean-pure-fns.rs b/src/test/run-pass/non-boolean-pure-fns.rs index ae0af82057f..3fb9a557fa1 100644 --- a/src/test/run-pass/non-boolean-pure-fns.rs +++ b/src/test/run-pass/non-boolean-pure-fns.rs @@ -27,7 +27,7 @@ fn safe_head<T: Copy>(ls: @List<T>) -> T { return head(ls); } -fn main() { +pub fn main() { let mylist = @Cons(@1u, @Nil); assert (nonempty_list(mylist)); assert (*safe_head(mylist) == 1u); diff --git a/src/test/run-pass/non-legacy-modes.rs b/src/test/run-pass/non-legacy-modes.rs index a8a6d232360..6db971121b7 100644 --- a/src/test/run-pass/non-legacy-modes.rs +++ b/src/test/run-pass/non-legacy-modes.rs @@ -24,7 +24,7 @@ fn check_struct(x: X) { check_int(x.repr); } -fn main() { +pub fn main() { apply(22, check_int); apply(X {repr: 22}, check_struct); } diff --git a/src/test/run-pass/nullary-or-pattern.rs b/src/test/run-pass/nullary-or-pattern.rs index 2cbfb885e21..4b913ccb9b6 100644 --- a/src/test/run-pass/nullary-or-pattern.rs +++ b/src/test/run-pass/nullary-or-pattern.rs @@ -14,7 +14,7 @@ fn or_alt(q: blah) -> int { match q { a | b => { 42 } } } -fn main() { +pub fn main() { assert (or_alt(a) == 42); assert (or_alt(b) == 42); } diff --git a/src/test/run-pass/numeric-method-autoexport.rs b/src/test/run-pass/numeric-method-autoexport.rs index d94d2bf5811..f5c49bbf4d0 100644 --- a/src/test/run-pass/numeric-method-autoexport.rs +++ b/src/test/run-pass/numeric-method-autoexport.rs @@ -12,7 +12,7 @@ // reachable for each numeric type, for each exported impl, with no imports // necessary. Testing the methods of the impls is done within the source // file for each numeric type. -fn main() { +pub fn main() { // ints // num assert 15i.add(&6) == 21; diff --git a/src/test/run-pass/opeq.rs b/src/test/run-pass/opeq.rs index 814da229e7d..ee669899154 100644 --- a/src/test/run-pass/opeq.rs +++ b/src/test/run-pass/opeq.rs @@ -12,7 +12,7 @@ // -*- rust -*- -fn main() { +pub fn main() { let mut x: int = 1; x *= 2; log(debug, x); diff --git a/src/test/run-pass/operator-associativity.rs b/src/test/run-pass/operator-associativity.rs index f9ebed3afce..0223fee549f 100644 --- a/src/test/run-pass/operator-associativity.rs +++ b/src/test/run-pass/operator-associativity.rs @@ -12,4 +12,4 @@ // Testcase for issue #130, operator associativity. -fn main() { assert (3 * 5 / 2 == 7); } +pub fn main() { assert (3 * 5 / 2 == 7); } diff --git a/src/test/run-pass/operator-overloading-explicit-self.rs b/src/test/run-pass/operator-overloading-explicit-self.rs index 2834e17dbc8..5a3ed4c6082 100644 --- a/src/test/run-pass/operator-overloading-explicit-self.rs +++ b/src/test/run-pass/operator-overloading-explicit-self.rs @@ -18,7 +18,7 @@ impl S { } } -fn main() { +pub fn main() { let mut s = S { x: 1 }; s += S { x: 2 }; assert s.x == 3; diff --git a/src/test/run-pass/operator-overloading.rs b/src/test/run-pass/operator-overloading.rs index 13439c6e7e6..1ffdc6a21ca 100644 --- a/src/test/run-pass/operator-overloading.rs +++ b/src/test/run-pass/operator-overloading.rs @@ -53,7 +53,7 @@ impl Point : cmp::Eq { pure fn ne(&self, other: &Point) -> bool { !(*self).eq(other) } } -fn main() { +pub fn main() { let mut p = Point {x: 10, y: 20}; p += Point {x: 101, y: 102}; p = p - Point {x: 100, y: 100}; diff --git a/src/test/run-pass/option-ext.rs b/src/test/run-pass/option-ext.rs index 29bdbebbc3e..63114da9d9d 100644 --- a/src/test/run-pass/option-ext.rs +++ b/src/test/run-pass/option-ext.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -fn main() { +pub fn main() { let thing = ~"{{ f }}"; let f = str::find_str(thing, ~"{{"); diff --git a/src/test/run-pass/option-unwrap.rs b/src/test/run-pass/option-unwrap.rs index 552dfccfdbc..604edc5e447 100644 --- a/src/test/run-pass/option-unwrap.rs +++ b/src/test/run-pass/option-unwrap.rs @@ -23,11 +23,11 @@ impl dtor : Drop { fn unwrap<T>(+o: Option<T>) -> T { match move o { Some(move v) => move v, - None => fail + None => die!() } } -fn main() { +pub fn main() { let x = @mut 1; { diff --git a/src/test/run-pass/or-pattern.rs b/src/test/run-pass/or-pattern.rs index a19fe8ecc4f..cc0a9e05f61 100644 --- a/src/test/run-pass/or-pattern.rs +++ b/src/test/run-pass/or-pattern.rs @@ -14,7 +14,7 @@ fn or_alt(q: blah) -> int { match q { a(x, y, _) | b(x, y) => { return x + y; } c => { return 0; } } } -fn main() { +pub fn main() { assert (or_alt(c) == 0); assert (or_alt(a(10, 100, 0u)) == 110); assert (or_alt(b(20, 200)) == 220); diff --git a/src/test/run-pass/output-slot-variants.rs b/src/test/run-pass/output-slot-variants.rs index 3667a980251..e45d2280bf0 100644 --- a/src/test/run-pass/output-slot-variants.rs +++ b/src/test/run-pass/output-slot-variants.rs @@ -23,7 +23,7 @@ fn ret_ext_mem() -> Abox { return Abox {a: @10, b: @10}; } fn ret_ext_ext_mem() -> @Abox { return @Abox{a: @10, b: @10}; } -fn main() { +pub fn main() { let mut int_i: int; let mut ext_i: @int; let mut int_rec: A; diff --git a/src/test/run-pass/over-constrained-vregs.rs b/src/test/run-pass/over-constrained-vregs.rs index 29b235ed988..14756904693 100644 --- a/src/test/run-pass/over-constrained-vregs.rs +++ b/src/test/run-pass/over-constrained-vregs.rs @@ -12,7 +12,7 @@ // Regression test for issue #152. -fn main() { +pub fn main() { let mut b: uint = 1u; while b <= 32u { 0u << b; diff --git a/src/test/run-pass/paren-free.rs b/src/test/run-pass/paren-free.rs index a101fc12225..b4d34d0c902 100644 --- a/src/test/run-pass/paren-free.rs +++ b/src/test/run-pass/paren-free.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -fn main() { +pub fn main() { let x = true; if x { let mut i = 10; while i > 0 { i -= 1; } } match x { true => { debug!("right"); } false => { debug!("wrong"); } } diff --git a/src/test/run-pass/parse-fail.rs b/src/test/run-pass/parse-fail.rs index 13d9eac1986..c280bc0dde5 100644 --- a/src/test/run-pass/parse-fail.rs +++ b/src/test/run-pass/parse-fail.rs @@ -12,6 +12,6 @@ // -*- rust -*- -fn dont_call_me() { fail; log(debug, 1); } +fn dont_call_me() { die!(); log(debug, 1); } -fn main() { } +pub fn main() { } diff --git a/src/test/run-pass/pass-by-copy.rs b/src/test/run-pass/pass-by-copy.rs index 2821ab3e3eb..44ec68dd346 100644 --- a/src/test/run-pass/pass-by-copy.rs +++ b/src/test/run-pass/pass-by-copy.rs @@ -13,7 +13,7 @@ fn magic2(+x: @int) { log(debug, x); } struct A { a: @int } -fn main() { +pub fn main() { let a = A {a: @10}, b = @10; magic(a); magic(A {a: @20}); magic2(b); magic2(@20); diff --git a/src/test/run-pass/path.rs b/src/test/run-pass/path.rs index 9f600e106b3..ee90cdc253a 100644 --- a/src/test/run-pass/path.rs +++ b/src/test/run-pass/path.rs @@ -14,4 +14,4 @@ mod foo { pub fn bar(offset: uint) { } } -fn main() { foo::bar(0u); } +pub fn main() { foo::bar(0u); } diff --git a/src/test/run-pass/pattern-bound-var-in-for-each.rs b/src/test/run-pass/pattern-bound-var-in-for-each.rs index 9a2199ec08f..c667aeb1c10 100644 --- a/src/test/run-pass/pattern-bound-var-in-for-each.rs +++ b/src/test/run-pass/pattern-bound-var-in-for-each.rs @@ -25,4 +25,4 @@ fn foo(src: uint) { } } -fn main() { foo(0u); } +pub fn main() { foo(0u); } diff --git a/src/test/run-pass/pattern-in-closure.rs b/src/test/run-pass/pattern-in-closure.rs index 64114a4822d..7194fca519b 100644 --- a/src/test/run-pass/pattern-in-closure.rs +++ b/src/test/run-pass/pattern-in-closure.rs @@ -13,7 +13,7 @@ struct Foo { y: int } -fn main() { +pub fn main() { let f = |(x, _): (int, int)| io::println((x + 1).to_str()); let g = |Foo { x: x, y: y }: Foo| io::println((x + 1).to_str()); f((2, 3)); diff --git a/src/test/run-pass/pipe-bank-proto.rs b/src/test/run-pass/pipe-bank-proto.rs index 856057e10ae..995ad4e71c0 100644 --- a/src/test/run-pass/pipe-bank-proto.rs +++ b/src/test/run-pass/pipe-bank-proto.rs @@ -62,7 +62,7 @@ macro_rules! follow ( $(Some($message($($($x,)+)* next)) => { let $next = move_it!(next); $e })+ - _ => { fail } + _ => { die!() } } ); ) @@ -73,7 +73,7 @@ fn client_follow(+bank: bank::client::login) { let bank = client::login(move bank, ~"theincredibleholk", ~"1234"); let bank = switch(move bank, follow! ( ok -> connected { move connected } - invalid -> _next { fail ~"bank closed the connected" } + invalid -> _next { die!(~"bank closed the connected") } )); let bank = client::deposit(move bank, 100.00); @@ -83,7 +83,7 @@ fn client_follow(+bank: bank::client::login) { io::println(~"Yay! I got money!"); } insufficient_funds -> _next { - fail ~"someone stole my money" + die!(~"someone stole my money") } )); } @@ -96,8 +96,8 @@ fn bank_client(+bank: bank::client::login) { Some(ok(connected)) => { move_it!(connected) } - Some(invalid(_)) => { fail ~"login unsuccessful" } - None => { fail ~"bank closed the connection" } + Some(invalid(_)) => { die!(~"login unsuccessful") } + None => { die!(~"bank closed the connection") } }; let bank = client::deposit(move bank, 100.00); @@ -107,13 +107,13 @@ fn bank_client(+bank: bank::client::login) { io::println(~"Yay! I got money!"); } Some(insufficient_funds(_)) => { - fail ~"someone stole my money" + die!(~"someone stole my money") } None => { - fail ~"bank closed the connection" + die!(~"bank closed the connection") } } } -fn main() { +pub fn main() { } diff --git a/src/test/run-pass/pipe-detect-term.rs b/src/test/run-pass/pipe-detect-term.rs index 99e4acde147..0bd06909ebb 100644 --- a/src/test/run-pass/pipe-detect-term.rs +++ b/src/test/run-pass/pipe-detect-term.rs @@ -28,12 +28,12 @@ proto! oneshot ( } ) -fn main() { +pub fn main() { let iotask = &uv::global_loop::get(); pipes::spawn_service(oneshot::init, |p| { match try_recv(move p) { - Some(*) => { fail } + Some(*) => { die!() } None => { } } }); @@ -48,7 +48,7 @@ fn failtest() { let (c, p) = oneshot::init(); do task::spawn_with(move c) |_c| { - fail; + die!(); } error!("%?", recv(move p)); diff --git a/src/test/run-pass/pipe-peek.rs b/src/test/run-pass/pipe-peek.rs index 5bf85a80f7c..7dc1feb2417 100644 --- a/src/test/run-pass/pipe-peek.rs +++ b/src/test/run-pass/pipe-peek.rs @@ -22,7 +22,7 @@ proto! oneshot ( } ) -fn main() { +pub fn main() { let (c, p) = oneshot::init(); assert !pipes::peek(&p); diff --git a/src/test/run-pass/pipe-pingpong-bounded.rs b/src/test/run-pass/pipe-pingpong-bounded.rs index e8ae5db62aa..a3b03daf02f 100644 --- a/src/test/run-pass/pipe-pingpong-bounded.rs +++ b/src/test/run-pass/pipe-pingpong-bounded.rs @@ -107,7 +107,7 @@ mod test { } } -fn main() { +pub fn main() { let (client_, server_) = ::pingpong::init(); let client_ = ~mut Some(move client_); let server_ = ~mut Some(move server_); diff --git a/src/test/run-pass/pipe-pingpong-proto.rs b/src/test/run-pass/pipe-pingpong-proto.rs index 840acd5b287..97afbba42c5 100644 --- a/src/test/run-pass/pipe-pingpong-proto.rs +++ b/src/test/run-pass/pipe-pingpong-proto.rs @@ -49,7 +49,7 @@ mod test { } } -fn main() { +pub fn main() { let (client_, server_) = pingpong::init(); let client_ = ~mut Some(move client_); let server_ = ~mut Some(move server_); diff --git a/src/test/run-pass/pipe-presentation-examples.rs b/src/test/run-pass/pipe-presentation-examples.rs index 8bfac5d0545..b16f02e78de 100644 --- a/src/test/run-pass/pipe-presentation-examples.rs +++ b/src/test/run-pass/pipe-presentation-examples.rs @@ -39,7 +39,7 @@ macro_rules! select_if ( let $next = move next; move $e })+ - _ => fail + _ => die!() } } else { select_if!( @@ -57,7 +57,7 @@ macro_rules! select_if ( $index:expr, $count:expr, } => { - fail + die!() } ) @@ -173,4 +173,4 @@ fn draw_two_frames_bad2(+channel: double_buffer::client::acquire) { ); } -fn main() { } +pub fn main() { } diff --git a/src/test/run-pass/pipe-select-macro.rs b/src/test/run-pass/pipe-select-macro.rs index ec792b38f94..368cda63394 100644 --- a/src/test/run-pass/pipe-select-macro.rs +++ b/src/test/run-pass/pipe-select-macro.rs @@ -60,5 +60,5 @@ fn test(+foo: foo::client::foo, +bar: bar::client::bar) { ) } -fn main() { +pub fn main() { } diff --git a/src/test/run-pass/pipe-select.rs b/src/test/run-pass/pipe-select.rs index 97480fbbb05..362fe3265f6 100644 --- a/src/test/run-pass/pipe-select.rs +++ b/src/test/run-pass/pipe-select.rs @@ -33,7 +33,7 @@ proto! stream ( } ) -fn main() { +pub fn main() { use oneshot::client::*; use stream::client::*; @@ -94,7 +94,7 @@ fn test_select2() { match pipes::select2(move ap, move bp) { either::Left(*) => { } - either::Right(*) => { fail } + either::Right(*) => { die!() } } stream::client::send(move bc, ~"abc"); @@ -107,7 +107,7 @@ fn test_select2() { stream::client::send(move bc, ~"abc"); match pipes::select2(move ap, move bp) { - either::Left(*) => { fail } + either::Left(*) => { die!() } either::Right(*) => { } } diff --git a/src/test/run-pass/pipe-sleep.rs b/src/test/run-pass/pipe-sleep.rs index 6d6c6cf4a08..ac4829a9c19 100644 --- a/src/test/run-pass/pipe-sleep.rs +++ b/src/test/run-pass/pipe-sleep.rs @@ -23,7 +23,7 @@ proto! oneshot ( } ) -fn main() { +pub fn main() { use oneshot::client::*; let c = pipes::spawn_service(oneshot::init, |p| { recv(move p); }); diff --git a/src/test/run-pass/placement-new-arena.rs b/src/test/run-pass/placement-new-arena.rs index 71023d6c7f4..5112f2be4d9 100644 --- a/src/test/run-pass/placement-new-arena.rs +++ b/src/test/run-pass/placement-new-arena.rs @@ -13,7 +13,7 @@ extern mod std; use std::arena; -fn main() { +pub fn main() { let p = &arena::Arena(); let x = p.alloc(|| 4u); io::print(fmt!("%u", *x)); diff --git a/src/test/run-pass/platform_thread.rs b/src/test/run-pass/platform_thread.rs index 2a61e83a537..40b9a7b92c0 100644 --- a/src/test/run-pass/platform_thread.rs +++ b/src/test/run-pass/platform_thread.rs @@ -12,7 +12,7 @@ // The OS main scheduler should continue to be available and not terminate // while it is not in use. -fn main() { +pub fn main() { run(100); } diff --git a/src/test/run-pass/pred-not-bool.rs b/src/test/run-pass/pred-not-bool.rs index 738d1932a89..4b90b99cb31 100644 --- a/src/test/run-pass/pred-not-bool.rs +++ b/src/test/run-pass/pred-not-bool.rs @@ -13,4 +13,4 @@ pure fn bad(a: int) -> int { return 37; } //~ ERROR Non-boolean return type -fn main() { } +pub fn main() { } diff --git a/src/test/run-pass/preempt.rs b/src/test/run-pass/preempt.rs index 5cc6361f7ca..e0434c14048 100644 --- a/src/test/run-pass/preempt.rs +++ b/src/test/run-pass/preempt.rs @@ -19,7 +19,7 @@ fn starve_main(alive: chan<int>) { loop { i += 1; } } -fn main() { +pub fn main() { let alive: port<int> = port(); debug!("main started"); let s: task = spawn starve_main(chan(alive)); diff --git a/src/test/run-pass/private-class-field.rs b/src/test/run-pass/private-class-field.rs index 59b07a21e19..3be87fd5047 100644 --- a/src/test/run-pass/private-class-field.rs +++ b/src/test/run-pass/private-class-field.rs @@ -25,7 +25,7 @@ fn cat(in_x : uint, in_y : int) -> cat { } } -fn main() { +pub fn main() { let nyan : cat = cat(52u, 99); assert (nyan.meow_count() == 52u); } diff --git a/src/test/run-pass/private-method.rs b/src/test/run-pass/private-method.rs index 0022343b1ba..ae149421f0a 100644 --- a/src/test/run-pass/private-method.rs +++ b/src/test/run-pass/private-method.rs @@ -32,7 +32,7 @@ fn cat(in_x : uint, in_y : int) -> cat { } } -fn main() { +pub fn main() { let nyan : cat = cat(52u, 99); nyan.play(); } diff --git a/src/test/run-pass/propagate-expected-type-through-block.rs b/src/test/run-pass/propagate-expected-type-through-block.rs index 3c40d2e36c1..525535dd139 100644 --- a/src/test/run-pass/propagate-expected-type-through-block.rs +++ b/src/test/run-pass/propagate-expected-type-through-block.rs @@ -2,7 +2,7 @@ // did not, then the type of `x` would not be known and a compilation // error would result. -fn main() { +pub fn main() { let y = ~3; let foo: @fn(&int) -> int = { let y = copy y; diff --git a/src/test/run-pass/pub-use-xcrate.rs b/src/test/run-pass/pub-use-xcrate.rs index d00e2114b03..03004e5e475 100644 --- a/src/test/run-pass/pub-use-xcrate.rs +++ b/src/test/run-pass/pub-use-xcrate.rs @@ -16,7 +16,7 @@ extern mod pub_use_xcrate2; use pub_use_xcrate2::Foo; -fn main() { +pub fn main() { let foo: Foo = Foo { name: 0 }; diff --git a/src/test/run-pass/pub_use_mods_xcrate_exe.rs b/src/test/run-pass/pub_use_mods_xcrate_exe.rs index 3398ff063ee..1d60cab3a82 100644 --- a/src/test/run-pass/pub_use_mods_xcrate_exe.rs +++ b/src/test/run-pass/pub_use_mods_xcrate_exe.rs @@ -14,5 +14,5 @@ extern mod pub_use_mods_xcrate; use pub_use_mods_xcrate::a::c; -fn main(){} +pub fn main(){} diff --git a/src/test/run-pass/pure-fmt.rs b/src/test/run-pass/pure-fmt.rs index 572720f5808..b65c33939c8 100644 --- a/src/test/run-pass/pure-fmt.rs +++ b/src/test/run-pass/pure-fmt.rs @@ -30,5 +30,5 @@ pure fn foo() { debug!("test %b", a.g); } -fn main() { +pub fn main() { } diff --git a/src/test/run-pass/pure-sum.rs b/src/test/run-pass/pure-sum.rs index 84792d52c13..19957a67c04 100644 --- a/src/test/run-pass/pure-sum.rs +++ b/src/test/run-pass/pure-sum.rs @@ -48,5 +48,5 @@ pure fn sums_to_using_uniq_rec(v: ~[int], sum: int) -> bool { return *sum0.f == sum; } -fn main() { +pub fn main() { } \ No newline at end of file diff --git a/src/test/run-pass/purity-infer.rs b/src/test/run-pass/purity-infer.rs index ec5e6d61628..9aba5046955 100644 --- a/src/test/run-pass/purity-infer.rs +++ b/src/test/run-pass/purity-infer.rs @@ -10,6 +10,6 @@ fn something(f: pure fn()) { f(); } -fn main() { +pub fn main() { something(|| log(error, "hi!") ); } diff --git a/src/test/run-pass/rcvr-borrowed-to-region.rs b/src/test/run-pass/rcvr-borrowed-to-region.rs index 2b511f6ecad..7f8e9cfdd69 100644 --- a/src/test/run-pass/rcvr-borrowed-to-region.rs +++ b/src/test/run-pass/rcvr-borrowed-to-region.rs @@ -19,7 +19,7 @@ impl &int: get { } } -fn main() { +pub fn main() { /* let x = @mut 6; let y = x.get(); diff --git a/src/test/run-pass/rcvr-borrowed-to-slice.rs b/src/test/run-pass/rcvr-borrowed-to-slice.rs index 26eb815d20f..51f4b4c953d 100644 --- a/src/test/run-pass/rcvr-borrowed-to-slice.rs +++ b/src/test/run-pass/rcvr-borrowed-to-slice.rs @@ -23,13 +23,13 @@ impl &[int]: sum { fn call_sum(x: &[int]) -> int { x.sum() } -fn main() { +pub fn main() { let x = ~[1, 2, 3]; let y = call_sum(x); debug!("y==%d", y); assert y == 6; - let x = ~[mut 1, 2, 3]; + let mut x = ~[1, 2, 3]; let y = x.sum(); debug!("y==%d", y); assert y == 6; diff --git a/src/test/run-pass/readalias.rs b/src/test/run-pass/readalias.rs index 5c3f77b994b..555a73c73d3 100644 --- a/src/test/run-pass/readalias.rs +++ b/src/test/run-pass/readalias.rs @@ -16,4 +16,4 @@ struct Point {x: int, y: int, z: int} fn f(p: Point) { assert (p.z == 12); } -fn main() { let x: Point = Point {x: 10, y: 11, z: 12}; f(x); } +pub fn main() { let x: Point = Point {x: 10, y: 11, z: 12}; f(x); } diff --git a/src/test/run-pass/rec-align-u32.rs b/src/test/run-pass/rec-align-u32.rs index 15538648363..ccf243aa072 100644 --- a/src/test/run-pass/rec-align-u32.rs +++ b/src/test/run-pass/rec-align-u32.rs @@ -41,7 +41,7 @@ mod m { pub fn size() -> uint { 8u } } -fn main() { +pub fn main() { unsafe { let x = Outer {c8: 22u8, t: Inner {c64: 44u32}}; diff --git a/src/test/run-pass/rec-align-u64.rs b/src/test/run-pass/rec-align-u64.rs index 30978deb374..eb309efd49c 100644 --- a/src/test/run-pass/rec-align-u64.rs +++ b/src/test/run-pass/rec-align-u64.rs @@ -55,7 +55,7 @@ mod m { } } -fn main() { +pub fn main() { unsafe { let x = Outer {c8: 22u8, t: Inner {c64: 44u64}}; diff --git a/src/test/run-pass/rec-auto.rs b/src/test/run-pass/rec-auto.rs index 05428879fd2..7dd13001de4 100644 --- a/src/test/run-pass/rec-auto.rs +++ b/src/test/run-pass/rec-auto.rs @@ -17,7 +17,7 @@ struct X { foo: ~str, bar: ~str } -fn main() { +pub fn main() { let x = X {foo: ~"hello", bar: ~"world"}; log(debug, copy x.foo); log(debug, copy x.bar); diff --git a/src/test/run-pass/rec-extend.rs b/src/test/run-pass/rec-extend.rs index ca353455c13..6b9eb51ef25 100644 --- a/src/test/run-pass/rec-extend.rs +++ b/src/test/run-pass/rec-extend.rs @@ -14,7 +14,7 @@ // -*- rust -*- struct Point {x: int, y: int} -fn main() { +pub fn main() { let origin: Point = Point {x: 0, y: 0}; let right: Point = Point {x: origin.x + 10,.. origin}; let up: Point = Point {y: origin.y + 10,.. origin}; diff --git a/src/test/run-pass/rec-tup.rs b/src/test/run-pass/rec-tup.rs index 8c20e4f342b..8d49ed43ffc 100644 --- a/src/test/run-pass/rec-tup.rs +++ b/src/test/run-pass/rec-tup.rs @@ -23,7 +23,7 @@ fn f(r: rect, x1: int, y1: int, x2: int, y2: int) { assert (snd(r).y == y2); } -fn main() { +pub fn main() { let r: rect = (Point {x: 10, y: 20}, Point {x: 11, y: 22}); assert (fst(r).x == 10); assert (fst(r).y == 20); diff --git a/src/test/run-pass/rec.rs b/src/test/run-pass/rec.rs index 6ff36355875..34d0ad7535b 100644 --- a/src/test/run-pass/rec.rs +++ b/src/test/run-pass/rec.rs @@ -21,7 +21,7 @@ fn f(r: Rect, x: int, y: int, w: int, h: int) { assert (r.h == h); } -fn main() { +pub fn main() { let r: Rect = Rect {x: 10, y: 20, w: 100, h: 200}; assert (r.x == 10); assert (r.y == 20); diff --git a/src/test/run-pass/record-pat.rs b/src/test/run-pass/record-pat.rs index 026b9c93203..ad986ddb752 100644 --- a/src/test/run-pass/record-pat.rs +++ b/src/test/run-pass/record-pat.rs @@ -19,7 +19,7 @@ fn m(in: t3) -> int { } } -fn main() { +pub fn main() { assert (m(c(T2 {x: a(10), y: 5}, 4u)) == 10); assert (m(c(T2 {x: b(10u), y: 5}, 4u)) == 19); } diff --git a/src/test/run-pass/recursion.rs b/src/test/run-pass/recursion.rs index 8cc2c8cc80a..77c0872b7c4 100644 --- a/src/test/run-pass/recursion.rs +++ b/src/test/run-pass/recursion.rs @@ -28,7 +28,7 @@ fn test<T:Dot> (n:int, i:int, first:T, second:T) ->int { _ => {test (n-1, i+1, Cons {head:2*i+1, tail:first}, Cons{head:i*i, tail:second})} } } -fn main() { +pub fn main() { let n = test(1, 0, Nil, Nil); io::println(fmt!("%d", n)); } diff --git a/src/test/run-pass/reexport-star.rs b/src/test/run-pass/reexport-star.rs index b59ce4d9020..3b9fe688d4d 100644 --- a/src/test/run-pass/reexport-star.rs +++ b/src/test/run-pass/reexport-star.rs @@ -21,7 +21,7 @@ mod b { pub use a::*; } -fn main() { +pub fn main() { b::f(); b::g(); } diff --git a/src/test/run-pass/reflect-visit-data.rs b/src/test/run-pass/reflect-visit-data.rs index c7c1a6bb331..96bddf7099b 100644 --- a/src/test/run-pass/reflect-visit-data.rs +++ b/src/test/run-pass/reflect-visit-data.rs @@ -517,7 +517,7 @@ impl my_visitor: TyVisitor { } fn visit_int(&self) -> bool { do self.get::<int>() |i| { - self.vals += ~[int::to_str(i, 10u)]; + self.vals += ~[int::to_str(i)]; }; true } @@ -634,7 +634,7 @@ fn get_tydesc_for<T>(&&_t: T) -> *TyDesc { struct Triple { x: int, y: int, z: int } -fn main() { +pub fn main() { unsafe { let r = (1,2,3,true,false, Triple {x:5,y:4,z:3}); let p = ptr::addr_of(&r) as *c_void; diff --git a/src/test/run-pass/reflect-visit-type.rs b/src/test/run-pass/reflect-visit-type.rs index edb11c7a979..9c8c65698b3 100644 --- a/src/test/run-pass/reflect-visit-type.rs +++ b/src/test/run-pass/reflect-visit-type.rs @@ -140,7 +140,7 @@ fn visit_ty<T>(v: TyVisitor) { visit_tydesc(get_tydesc::<T>(), v); } -fn main() { +pub fn main() { let v = my_visitor(@{mut types: ~[]}); let vv = v as TyVisitor; diff --git a/src/test/run-pass/region-dependent-addr-of.rs b/src/test/run-pass/region-dependent-addr-of.rs index 6765c1a11ae..ab6d9cd58ea 100644 --- a/src/test/run-pass/region-dependent-addr-of.rs +++ b/src/test/run-pass/region-dependent-addr-of.rs @@ -54,21 +54,21 @@ fn get_v5(a: &v/A, i: uint) -> &v/int { fn get_v6_a(a: &v/A, i: uint) -> &v/int { match a.value.v6 { Some(ref v) => &v.f, - None => fail + None => die!() } } fn get_v6_b(a: &v/A, i: uint) -> &v/int { match *a { A { value: B { v6: Some(ref v), _ } } => &v.f, - _ => fail + _ => die!() } } fn get_v6_c(a: &v/A, i: uint) -> &v/int { match a { &A { value: B { v6: Some(ref v), _ } } => &v.f, - _ => fail + _ => die!() } } @@ -78,7 +78,7 @@ fn get_v5_ref(a: &v/A, i: uint) -> &v/int { } } -fn main() { +pub fn main() { let a = A {value: B {v1: 22, v2: [23, 24, 25], v3: ~[26, 27, 28], diff --git a/src/test/run-pass/region-return-interior-of-option.rs b/src/test/run-pass/region-return-interior-of-option.rs index 9e960acbcdc..b71707488e8 100644 --- a/src/test/run-pass/region-return-interior-of-option.rs +++ b/src/test/run-pass/region-return-interior-of-option.rs @@ -11,11 +11,11 @@ fn get<T>(opt: &r/Option<T>) -> &r/T { match *opt { Some(ref v) => v, - None => fail ~"none" + None => die!(~"none") } } -fn main() { +pub fn main() { let mut x = Some(23); { @@ -29,4 +29,4 @@ fn main() { let y = get(&x); assert *y == 24; } -} \ No newline at end of file +} diff --git a/src/test/run-pass/regions-addr-of-interior-of-unique-box.rs b/src/test/run-pass/regions-addr-of-interior-of-unique-box.rs index b07f53aba12..5a13ae58ae9 100644 --- a/src/test/run-pass/regions-addr-of-interior-of-unique-box.rs +++ b/src/test/run-pass/regions-addr-of-interior-of-unique-box.rs @@ -18,6 +18,6 @@ fn get_x(x: &r/character) -> &r/int { return &x.pos.x; } -fn main() { +pub fn main() { } diff --git a/src/test/run-pass/regions-addr-of-ret.rs b/src/test/run-pass/regions-addr-of-ret.rs index ac847f18128..88a378e7b49 100644 --- a/src/test/run-pass/regions-addr-of-ret.rs +++ b/src/test/run-pass/regions-addr-of-ret.rs @@ -12,7 +12,7 @@ fn f(x : &a/int) -> &a/int { return &*x; } -fn main() { +pub fn main() { let three = &3; log(error, fmt!("%d", *f(three))); } diff --git a/src/test/run-pass/regions-appearance-constraint.rs b/src/test/run-pass/regions-appearance-constraint.rs index 1881a5d9c3c..0b7b9728ae4 100644 --- a/src/test/run-pass/regions-appearance-constraint.rs +++ b/src/test/run-pass/regions-appearance-constraint.rs @@ -28,5 +28,5 @@ fn testfn(cond: bool) { assert *a == exp; } -fn main() { +pub fn main() { } diff --git a/src/test/run-pass/regions-borrow-at.rs b/src/test/run-pass/regions-borrow-at.rs index dd48c66406c..f42e7015969 100644 --- a/src/test/run-pass/regions-borrow-at.rs +++ b/src/test/run-pass/regions-borrow-at.rs @@ -12,7 +12,7 @@ fn foo(x: &uint) -> uint { *x } -fn main() { +pub fn main() { let p = @22u; let r = foo(p); debug!("r=%u", r); diff --git a/src/test/run-pass/regions-borrow-estr-uniq.rs b/src/test/run-pass/regions-borrow-estr-uniq.rs index b44f60cb705..987f672a2fb 100644 --- a/src/test/run-pass/regions-borrow-estr-uniq.rs +++ b/src/test/run-pass/regions-borrow-estr-uniq.rs @@ -12,7 +12,7 @@ fn foo(x: &str) -> u8 { x[0] } -fn main() { +pub fn main() { let p = ~"hello"; let r = foo(p); assert r == 'h' as u8; diff --git a/src/test/run-pass/regions-borrow-evec-at.rs b/src/test/run-pass/regions-borrow-evec-at.rs index c7aec8eb47b..73764ee1a6c 100644 --- a/src/test/run-pass/regions-borrow-evec-at.rs +++ b/src/test/run-pass/regions-borrow-evec-at.rs @@ -14,7 +14,7 @@ fn foo(x: &[uint]) -> uint { x[0] } -fn main() { +pub fn main() { let p = @[22u]; let r = foo(p); assert r == 22u; diff --git a/src/test/run-pass/regions-borrow-evec-fixed.rs b/src/test/run-pass/regions-borrow-evec-fixed.rs index 218631a2a65..9f45da1268a 100644 --- a/src/test/run-pass/regions-borrow-evec-fixed.rs +++ b/src/test/run-pass/regions-borrow-evec-fixed.rs @@ -14,7 +14,7 @@ fn foo(x: &[int]) -> int { x[0] } -fn main() { +pub fn main() { let p = [1,2,3,4,5]; assert foo(p) == 1; } diff --git a/src/test/run-pass/regions-borrow-evec-uniq.rs b/src/test/run-pass/regions-borrow-evec-uniq.rs index 43e335a2ac8..09a3e6f4a84 100644 --- a/src/test/run-pass/regions-borrow-evec-uniq.rs +++ b/src/test/run-pass/regions-borrow-evec-uniq.rs @@ -12,7 +12,7 @@ fn foo(x: &[int]) -> int { x[0] } -fn main() { +pub fn main() { let p = ~[1,2,3,4,5]; let r = foo(p); assert r == 1; diff --git a/src/test/run-pass/regions-borrow-uniq.rs b/src/test/run-pass/regions-borrow-uniq.rs index 3b5c27bf440..00d7ec6448c 100644 --- a/src/test/run-pass/regions-borrow-uniq.rs +++ b/src/test/run-pass/regions-borrow-uniq.rs @@ -12,7 +12,7 @@ fn foo(x: &uint) -> uint { *x } -fn main() { +pub fn main() { let p = ~3u; let r = foo(p); assert r == 3u; diff --git a/src/test/run-pass/regions-bot.rs b/src/test/run-pass/regions-bot.rs index d3c5c9f1b93..3c7a6dcbb85 100644 --- a/src/test/run-pass/regions-bot.rs +++ b/src/test/run-pass/regions-bot.rs @@ -10,9 +10,9 @@ // A very limited test of the "bottom" region -fn produce_static<T>() -> &static/T { fail; } +fn produce_static<T>() -> &static/T { die!(); } fn foo<T>(x: &T) -> &uint { produce_static() } -fn main() { -} \ No newline at end of file +pub fn main() { +} diff --git a/src/test/run-pass/regions-copy-closure.rs b/src/test/run-pass/regions-copy-closure.rs index b98603f33d4..bfb4ac5f60c 100644 --- a/src/test/run-pass/regions-copy-closure.rs +++ b/src/test/run-pass/regions-copy-closure.rs @@ -16,7 +16,7 @@ fn box_it(+x: &r/fn()) -> closure_box/&r { closure_box {cl: move x} } -fn main() { +pub fn main() { let mut i = 3; let cl_box = box_it(|| i += 1); assert i == 3; diff --git a/src/test/run-pass/regions-creating-enums2.rs b/src/test/run-pass/regions-creating-enums2.rs index c58512439cb..2245bd72f88 100644 --- a/src/test/run-pass/regions-creating-enums2.rs +++ b/src/test/run-pass/regions-creating-enums2.rs @@ -17,5 +17,5 @@ fn mk_add_ok(x: &r/ast, y: &r/ast) -> ast/&r { add(x, y) } -fn main() { +pub fn main() { } \ No newline at end of file diff --git a/src/test/run-pass/regions-creating-enums5.rs b/src/test/run-pass/regions-creating-enums5.rs index f5c558405bc..959a40055fd 100644 --- a/src/test/run-pass/regions-creating-enums5.rs +++ b/src/test/run-pass/regions-creating-enums5.rs @@ -17,5 +17,5 @@ fn mk_add_ok(x: &a/ast, y: &a/ast, z: &ast) -> ast/&a { add(x, y) } -fn main() { +pub fn main() { } \ No newline at end of file diff --git a/src/test/run-pass/regions-equiv-fns.rs b/src/test/run-pass/regions-equiv-fns.rs index 0d28629f047..fb68e3e2b08 100644 --- a/src/test/run-pass/regions-equiv-fns.rs +++ b/src/test/run-pass/regions-equiv-fns.rs @@ -17,7 +17,7 @@ fn ok(a: &uint) { g(a); } -fn main() { +pub fn main() { } diff --git a/src/test/run-pass/regions-escape-into-other-fn.rs b/src/test/run-pass/regions-escape-into-other-fn.rs index 5f0e37768ba..a35a7cfa829 100644 --- a/src/test/run-pass/regions-escape-into-other-fn.rs +++ b/src/test/run-pass/regions-escape-into-other-fn.rs @@ -11,7 +11,7 @@ fn foo(x: &r/uint) -> &r/uint { x } fn bar(x: &uint) -> uint { *x } -fn main() { +pub fn main() { let p = @3u; assert bar(foo(p)) == 3; } diff --git a/src/test/run-pass/regions-fn-subtyping-2.rs b/src/test/run-pass/regions-fn-subtyping-2.rs index d84b504ab68..ad9ede07f77 100644 --- a/src/test/run-pass/regions-fn-subtyping-2.rs +++ b/src/test/run-pass/regions-fn-subtyping-2.rs @@ -24,7 +24,7 @@ fn has_same_region(f: fn(x: &a.int, g: fn(y: &a.int))) { fn wants_same_region(_f: fn(x: &b.int, g: fn(y: &b.int))) { } -fn main() { +pub fn main() { } diff --git a/src/test/run-pass/regions-fn-subtyping.rs b/src/test/run-pass/regions-fn-subtyping.rs index 28fdc3d26f3..2ed0d499e18 100644 --- a/src/test/run-pass/regions-fn-subtyping.rs +++ b/src/test/run-pass/regions-fn-subtyping.rs @@ -29,5 +29,5 @@ fn ok_inferred(f: fn@(x: &uint)) { g = f; } -fn main() { +pub fn main() { } diff --git a/src/test/run-pass/regions-infer-borrow-scope-addr-of.rs b/src/test/run-pass/regions-infer-borrow-scope-addr-of.rs index 76ac8fa9de5..a31354512b3 100644 --- a/src/test/run-pass/regions-infer-borrow-scope-addr-of.rs +++ b/src/test/run-pass/regions-infer-borrow-scope-addr-of.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -fn main() { +pub fn main() { let mut x = 4; for uint::range(0, 3) |i| { diff --git a/src/test/run-pass/regions-infer-borrow-scope-view.rs b/src/test/run-pass/regions-infer-borrow-scope-view.rs index c0898916cae..676d595f212 100644 --- a/src/test/run-pass/regions-infer-borrow-scope-view.rs +++ b/src/test/run-pass/regions-infer-borrow-scope-view.rs @@ -10,7 +10,7 @@ fn view<T>(x: &r/[T]) -> &r/[T] {x} -fn main() { +pub fn main() { let v = ~[1, 2, 3]; let x = view(v); let y = view(x); diff --git a/src/test/run-pass/regions-infer-borrow-scope-within-loop-ok.rs b/src/test/run-pass/regions-infer-borrow-scope-within-loop-ok.rs index 40ee9e318eb..444aca8b138 100644 --- a/src/test/run-pass/regions-infer-borrow-scope-within-loop-ok.rs +++ b/src/test/run-pass/regions-infer-borrow-scope-within-loop-ok.rs @@ -10,7 +10,7 @@ fn borrow<T>(x: &r/T) -> &r/T {x} -fn main() { +pub fn main() { let x = @3; loop { let y = borrow(x); diff --git a/src/test/run-pass/regions-infer-borrow-scope.rs b/src/test/run-pass/regions-infer-borrow-scope.rs index e1d54f33dcb..3054438387b 100644 --- a/src/test/run-pass/regions-infer-borrow-scope.rs +++ b/src/test/run-pass/regions-infer-borrow-scope.rs @@ -14,7 +14,7 @@ fn x_coord(p: &r/Point) -> &r/int { return &p.x; } -fn main() { +pub fn main() { let p = @Point {x: 3, y: 4}; let xc = x_coord(p); assert *xc == 3; diff --git a/src/test/run-pass/regions-infer-call-2.rs b/src/test/run-pass/regions-infer-call-2.rs index b3defb42813..940c087ea62 100644 --- a/src/test/run-pass/regions-infer-call-2.rs +++ b/src/test/run-pass/regions-infer-call-2.rs @@ -18,6 +18,6 @@ fn has_one(x: &a/int) -> int { do with |y| { takes_two(x, y) } } -fn main() { +pub fn main() { assert has_one(&2) == 22; } \ No newline at end of file diff --git a/src/test/run-pass/regions-infer-call.rs b/src/test/run-pass/regions-infer-call.rs index f065bc73956..d546bed4fde 100644 --- a/src/test/run-pass/regions-infer-call.rs +++ b/src/test/run-pass/regions-infer-call.rs @@ -14,6 +14,6 @@ fn has_two(x: &a/int, y: &b/int) -> int { takes_two(x, y) } -fn main() { +pub fn main() { assert has_two(&20, &2) == 22; } \ No newline at end of file diff --git a/src/test/run-pass/regions-infer-contravariance-due-to-ret.rs b/src/test/run-pass/regions-infer-contravariance-due-to-ret.rs index 72a6d2449aa..414f12bf3da 100644 --- a/src/test/run-pass/regions-infer-contravariance-due-to-ret.rs +++ b/src/test/run-pass/regions-infer-contravariance-due-to-ret.rs @@ -21,7 +21,7 @@ fn with(bi: &boxed_int) -> int { max(bi, &i) } -fn main() { +pub fn main() { let g = 21; let foo = boxed_int { f: &g }; assert with(&foo) == 22; diff --git a/src/test/run-pass/regions-infer-contravariance.rs b/src/test/run-pass/regions-infer-contravariance.rs index 78690277815..eccc75ed11f 100644 --- a/src/test/run-pass/regions-infer-contravariance.rs +++ b/src/test/run-pass/regions-infer-contravariance.rs @@ -24,7 +24,7 @@ fn with(bi: &r/boxed_int) { assert *get(bi) == 22; } -fn main() { +pub fn main() { let g = 22; let foo = boxed_int { f: &g }; with(&foo); diff --git a/src/test/run-pass/regions-mock-trans-impls.rs b/src/test/run-pass/regions-mock-trans-impls.rs index 71bf0ac8269..5c1255f2aa2 100644 --- a/src/test/run-pass/regions-mock-trans-impls.rs +++ b/src/test/run-pass/regions-mock-trans-impls.rs @@ -42,7 +42,7 @@ fn f(ccx : &Ccx) { return g(fcx); } -fn main() { +pub fn main() { let ccx = Ccx { x: 0 }; f(&ccx); } diff --git a/src/test/run-pass/regions-mock-trans.rs b/src/test/run-pass/regions-mock-trans.rs index 2ef63af3be1..d002de2249a 100644 --- a/src/test/run-pass/regions-mock-trans.rs +++ b/src/test/run-pass/regions-mock-trans.rs @@ -48,7 +48,7 @@ fn f(ccx : &Ccx) { return g(&fcx); } -fn main() { +pub fn main() { let ccx = Ccx { x: 0 }; f(&ccx); } diff --git a/src/test/run-pass/regions-nullary-variant.rs b/src/test/run-pass/regions-nullary-variant.rs index faefe675aaf..ac416dd4468 100644 --- a/src/test/run-pass/regions-nullary-variant.rs +++ b/src/test/run-pass/regions-nullary-variant.rs @@ -16,4 +16,4 @@ fn mk(cond: bool, ptr: &r/uint) -> roption/&r { if cond {a} else {b(ptr)} } -fn main() {} \ No newline at end of file +pub fn main() {} \ No newline at end of file diff --git a/src/test/run-pass/regions-params.rs b/src/test/run-pass/regions-params.rs index 5d3d1c9c87b..0691f42bb7b 100644 --- a/src/test/run-pass/regions-params.rs +++ b/src/test/run-pass/regions-params.rs @@ -22,7 +22,7 @@ fn parameterized(x: &uint) -> uint { *z } -fn main() { +pub fn main() { let x = 3u; assert parameterized(&x) == 3u; } diff --git a/src/test/run-pass/regions-self-impls.rs b/src/test/run-pass/regions-self-impls.rs index 975d96dc420..40c83a17089 100644 --- a/src/test/run-pass/regions-self-impls.rs +++ b/src/test/run-pass/regions-self-impls.rs @@ -18,7 +18,7 @@ impl Clam: get_chowder { fn get_chowder() -> &self/int { return self.chowder; } } -fn main() { +pub fn main() { let clam = Clam { chowder: &3 }; log(debug, *clam.get_chowder()); clam.get_chowder(); diff --git a/src/test/run-pass/regions-self-in-enums.rs b/src/test/run-pass/regions-self-in-enums.rs index 4b9cae12606..8ddbea5d3ed 100644 --- a/src/test/run-pass/regions-self-in-enums.rs +++ b/src/test/run-pass/regions-self-in-enums.rs @@ -12,7 +12,7 @@ enum int_wrapper { int_wrapper_ctor(&int) } -fn main() { +pub fn main() { let x = 3; let y = int_wrapper_ctor(&x); let mut z : ∫ diff --git a/src/test/run-pass/regions-simple.rs b/src/test/run-pass/regions-simple.rs index 0238660c100..c32e08fc76b 100644 --- a/src/test/run-pass/regions-simple.rs +++ b/src/test/run-pass/regions-simple.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -fn main() { +pub fn main() { let mut x: int = 3; let y: &mut int = &mut x; *y = 5; diff --git a/src/test/run-pass/regions-static-closure.rs b/src/test/run-pass/regions-static-closure.rs index faeba03128d..8b7fbfd3758 100644 --- a/src/test/run-pass/regions-static-closure.rs +++ b/src/test/run-pass/regions-static-closure.rs @@ -20,7 +20,7 @@ fn call_static_closure(cl: closure_box/&static) { (cl.cl)(); } -fn main() { +pub fn main() { let cl_box = box_it(|| debug!("Hello, world!")); call_static_closure(move cl_box); } diff --git a/src/test/run-pass/regions-trait.rs b/src/test/run-pass/regions-trait.rs index 575fefa9db5..86da7c722ff 100644 --- a/src/test/run-pass/regions-trait.rs +++ b/src/test/run-pass/regions-trait.rs @@ -26,7 +26,7 @@ fn get_v(gc: get_ctxt) -> uint { gc.get_ctxt().v } -fn main() { +pub fn main() { let ctxt = Ctxt { v: 22 }; let hc = HasCtxt { c: &ctxt }; diff --git a/src/test/run-pass/repeated-vector-syntax.rs b/src/test/run-pass/repeated-vector-syntax.rs index fe319fd0049..49d0c49b396 100644 --- a/src/test/run-pass/repeated-vector-syntax.rs +++ b/src/test/run-pass/repeated-vector-syntax.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -fn main() { +pub fn main() { let x = [ @[true], ..512 ]; let y = [ 0, ..1 ]; error!("%?", x); diff --git a/src/test/run-pass/resolve-issue-2428.rs b/src/test/run-pass/resolve-issue-2428.rs index c8f64bec19d..b5d3514154a 100644 --- a/src/test/run-pass/resolve-issue-2428.rs +++ b/src/test/run-pass/resolve-issue-2428.rs @@ -12,4 +12,4 @@ const foo: int = 4 >> 1; enum bs { thing = foo } -fn main() { assert(thing as int == foo); } +pub fn main() { assert(thing as int == foo); } diff --git a/src/test/run-pass/resource-assign-is-not-copy.rs b/src/test/run-pass/resource-assign-is-not-copy.rs index 72c9cce6b7b..9de6fbebf85 100644 --- a/src/test/run-pass/resource-assign-is-not-copy.rs +++ b/src/test/run-pass/resource-assign-is-not-copy.rs @@ -24,7 +24,7 @@ fn r(i: @mut int) -> r { } } -fn main() { +pub fn main() { let i = @mut 0; // Even though these look like copies, they are guaranteed not to be { diff --git a/src/test/run-pass/resource-cycle.rs b/src/test/run-pass/resource-cycle.rs index f2926c5e1c5..fa9832125b3 100644 --- a/src/test/run-pass/resource-cycle.rs +++ b/src/test/run-pass/resource-cycle.rs @@ -41,7 +41,7 @@ struct Node { r: r } -fn main() { +pub fn main() { unsafe { let i1 = ~0; let i1p = cast::reinterpret_cast(&i1); diff --git a/src/test/run-pass/resource-cycle2.rs b/src/test/run-pass/resource-cycle2.rs index 56ca229b055..0b7179cc819 100644 --- a/src/test/run-pass/resource-cycle2.rs +++ b/src/test/run-pass/resource-cycle2.rs @@ -41,7 +41,7 @@ struct Node { r: r } -fn main() { +pub fn main() { unsafe { let i1 = ~0xA; let i1p = cast::reinterpret_cast(&i1); diff --git a/src/test/run-pass/resource-cycle3.rs b/src/test/run-pass/resource-cycle3.rs index 59a6d703c7c..4bec2f10f98 100644 --- a/src/test/run-pass/resource-cycle3.rs +++ b/src/test/run-pass/resource-cycle3.rs @@ -50,7 +50,7 @@ struct Node { r: R } -fn main() { +pub fn main() { unsafe { let i1 = ~0xA; let i1p = cast::reinterpret_cast(&i1); diff --git a/src/test/run-pass/resource-destruct.rs b/src/test/run-pass/resource-destruct.rs index f60df9300ef..6d4ddd13041 100644 --- a/src/test/run-pass/resource-destruct.rs +++ b/src/test/run-pass/resource-destruct.rs @@ -28,7 +28,7 @@ fn shrinky_pointer(i: @@mut int) -> shrinky_pointer { } } -fn main() { +pub fn main() { let my_total = @@mut 10; { let pt = move shrinky_pointer(my_total); assert (pt.look_at() == 10); } log(error, fmt!("my_total = %d", **my_total)); diff --git a/src/test/run-pass/resource-generic.rs b/src/test/run-pass/resource-generic.rs index 7165d6089e8..86e023c4e8a 100644 --- a/src/test/run-pass/resource-generic.rs +++ b/src/test/run-pass/resource-generic.rs @@ -29,7 +29,7 @@ fn finish<T: Copy>(arg: Arg<T>) -> finish<T> { } } -fn main() { +pub fn main() { let box = @mut 10; fn dec_box(&&i: @mut int) { *i -= 1; } diff --git a/src/test/run-pass/resource-in-struct.rs b/src/test/run-pass/resource-in-struct.rs index 8fda3d0d949..50e60cb0f37 100644 --- a/src/test/run-pass/resource-in-struct.rs +++ b/src/test/run-pass/resource-in-struct.rs @@ -34,7 +34,7 @@ enum option<T> { none, some(T), } fn sink(res: option<close_res>) { } -fn main() { +pub fn main() { let c = @mut true; sink(none); sink(some(close_res(c))); diff --git a/src/test/run-pass/ret-bang.rs b/src/test/run-pass/ret-bang.rs index ff960790762..5086e8af50a 100644 --- a/src/test/run-pass/ret-bang.rs +++ b/src/test/run-pass/ret-bang.rs @@ -12,10 +12,10 @@ // -*- rust -*- -fn my_err(s: ~str) -> ! { log(error, s); fail; } +fn my_err(s: ~str) -> ! { log(error, s); die!(); } fn okay(i: uint) -> int { if i == 3u { my_err(~"I don't like three"); } else { return 42; } } -fn main() { okay(4u); } +pub fn main() { okay(4u); } diff --git a/src/test/run-pass/ret-break-cont-in-block.rs b/src/test/run-pass/ret-break-cont-in-block.rs index 9ecc7168f6e..97fa11bef1b 100644 --- a/src/test/run-pass/ret-break-cont-in-block.rs +++ b/src/test/run-pass/ret-break-cont-in-block.rs @@ -50,7 +50,7 @@ fn ret_deep() -> ~str { return ~"bye"; } -fn main() { +pub fn main() { let mut last = 0; for vec::all(~[1, 2, 3, 4, 5, 6, 7]) |e| { last = *e; diff --git a/src/test/run-pass/ret-none.rs b/src/test/run-pass/ret-none.rs index 5e3e543e09e..1df01a5e579 100644 --- a/src/test/run-pass/ret-none.rs +++ b/src/test/run-pass/ret-none.rs @@ -14,4 +14,4 @@ enum option<T> { none, some(T), } fn f<T: Copy>() -> option<T> { return none; } -fn main() { f::<int>(); } +pub fn main() { f::<int>(); } diff --git a/src/test/run-pass/return-nil.rs b/src/test/run-pass/return-nil.rs index a53d5aa3d6a..c86c6394228 100644 --- a/src/test/run-pass/return-nil.rs +++ b/src/test/run-pass/return-nil.rs @@ -12,4 +12,4 @@ fn f() { let x: () = (); return x; } -fn main() { let x = f(); } +pub fn main() { let x = f(); } diff --git a/src/test/run-pass/rt-sched-1.rs b/src/test/run-pass/rt-sched-1.rs index 6922156f5ef..badd9632cc8 100644 --- a/src/test/run-pass/rt-sched-1.rs +++ b/src/test/run-pass/rt-sched-1.rs @@ -25,7 +25,7 @@ extern mod rustrt { pub fn start_task(id: task_id, f: closure); } -fn main() { +pub fn main() { unsafe { let (po, ch) = stream(); let parent_sched_id = rustrt::rust_get_sched_id(); diff --git a/src/test/run-pass/select-macro.rs b/src/test/run-pass/select-macro.rs index ad4a57f13a0..83746c728e8 100644 --- a/src/test/run-pass/select-macro.rs +++ b/src/test/run-pass/select-macro.rs @@ -19,7 +19,7 @@ macro_rules! select_if ( $index:expr, $count:expr } => { - fail + die!() }; { @@ -40,7 +40,7 @@ macro_rules! select_if ( let $next = move next; move $e })+ - _ => fail + _ => die!() } } else { select_if!( diff --git a/src/test/run-pass/self-shadowing-import.rs b/src/test/run-pass/self-shadowing-import.rs index 22562d65e37..7846db4ff2f 100644 --- a/src/test/run-pass/self-shadowing-import.rs +++ b/src/test/run-pass/self-shadowing-import.rs @@ -23,4 +23,4 @@ mod c { pub fn bar() { assert (a::foo() == 1); } } -fn main() { c::bar(); } +pub fn main() { c::bar(); } diff --git a/src/test/run-pass/self-type-param.rs b/src/test/run-pass/self-type-param.rs index ea42045fc46..d0d20d096b4 100644 --- a/src/test/run-pass/self-type-param.rs +++ b/src/test/run-pass/self-type-param.rs @@ -12,5 +12,5 @@ impl S : MyTrait { } } -fn main() {} +pub fn main() {} diff --git a/src/test/run-pass/send-iloop.rs b/src/test/run-pass/send-iloop.rs index 28877f7eb94..848eb64235d 100644 --- a/src/test/run-pass/send-iloop.rs +++ b/src/test/run-pass/send-iloop.rs @@ -12,7 +12,7 @@ extern mod std; fn die() { - fail; + die!(); } fn iloop() { @@ -29,7 +29,7 @@ fn iloop() { } } -fn main() { +pub fn main() { for uint::range(0u, 16u) |_i| { task::spawn_unlinked(|| iloop() ); } diff --git a/src/test/run-pass/send-resource.rs b/src/test/run-pass/send-resource.rs index be0546c6883..11d1af2b399 100644 --- a/src/test/run-pass/send-resource.rs +++ b/src/test/run-pass/send-resource.rs @@ -24,7 +24,7 @@ fn test(f: int) -> test { } } -fn main() { +pub fn main() { let (p, c) = stream(); do task::spawn() { diff --git a/src/test/run-pass/send-type-inference.rs b/src/test/run-pass/send-type-inference.rs index c2f7ed28f81..bf1ab6e07d2 100644 --- a/src/test/run-pass/send-type-inference.rs +++ b/src/test/run-pass/send-type-inference.rs @@ -17,4 +17,4 @@ fn cache_server<K: Owned, V: Owned>(c: Chan<Chan<command<K, V>>>) { let (ctrl_port, ctrl_chan) = stream(); c.send(ctrl_chan); } -fn main() { } +pub fn main() { } diff --git a/src/test/run-pass/sendable-class.rs b/src/test/run-pass/sendable-class.rs index 0a1afc68a5b..a5691e289d7 100644 --- a/src/test/run-pass/sendable-class.rs +++ b/src/test/run-pass/sendable-class.rs @@ -22,7 +22,7 @@ fn foo(i:int, j: char) -> foo { } } -fn main() { +pub fn main() { let (_po, ch) = pipes::stream(); ch.send(foo(42, 'c')); } \ No newline at end of file diff --git a/src/test/run-pass/sendfn-deep-copy.rs b/src/test/run-pass/sendfn-deep-copy.rs index 01a480ff25d..520ddf3f73a 100644 --- a/src/test/run-pass/sendfn-deep-copy.rs +++ b/src/test/run-pass/sendfn-deep-copy.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -fn main() { test05(); } +pub fn main() { test05(); } fn mk_counter<A:Copy>() -> fn~(A) -> (A,uint) { // The only reason that the counter is generic is so that it closes diff --git a/src/test/run-pass/sendfn-generic-fn.rs b/src/test/run-pass/sendfn-generic-fn.rs index 8cc1d77a3d3..be4b609afab 100644 --- a/src/test/run-pass/sendfn-generic-fn.rs +++ b/src/test/run-pass/sendfn-generic-fn.rs @@ -11,7 +11,7 @@ // xfail-fast #[legacy_modes]; -fn main() { test05(); } +pub fn main() { test05(); } struct Pair<A,B> { a: A, b: B } diff --git a/src/test/run-pass/sendfn-is-a-block.rs b/src/test/run-pass/sendfn-is-a-block.rs index a9c16ea634e..2d995191785 100644 --- a/src/test/run-pass/sendfn-is-a-block.rs +++ b/src/test/run-pass/sendfn-is-a-block.rs @@ -15,7 +15,7 @@ fn test(f: fn(uint) -> uint) -> uint { return f(22u); } -fn main() { +pub fn main() { let y = test(fn~(x: uint) -> uint { return 4u * x; }); assert y == 88u; } diff --git a/src/test/run-pass/sendfn-spawn-with-fn-arg.rs b/src/test/run-pass/sendfn-spawn-with-fn-arg.rs index 504d7948ffc..d86dc4d56d7 100644 --- a/src/test/run-pass/sendfn-spawn-with-fn-arg.rs +++ b/src/test/run-pass/sendfn-spawn-with-fn-arg.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -fn main() { test05(); } +pub fn main() { test05(); } fn test05_start(&&f: fn~(int)) { f(22); diff --git a/src/test/run-pass/seq-compare.rs b/src/test/run-pass/seq-compare.rs index 10e44b2b9d1..6a7832fe6a9 100644 --- a/src/test/run-pass/seq-compare.rs +++ b/src/test/run-pass/seq-compare.rs @@ -10,7 +10,7 @@ -fn main() { +pub fn main() { assert (~"hello" < ~"hellr"); assert (~"hello " > ~"hello"); assert (~"hello" != ~"there"); diff --git a/src/test/run-pass/shadow.rs b/src/test/run-pass/shadow.rs index e3fe7a34ff9..a23bb21c77d 100644 --- a/src/test/run-pass/shadow.rs +++ b/src/test/run-pass/shadow.rs @@ -28,4 +28,4 @@ fn foo(c: ~[int]) { enum t<T> { none, some(T), } -fn main() { let x = 10; let x = x + 20; assert (x == 30); foo(~[]); } +pub fn main() { let x = 10; let x = x + 20; assert (x == 30); foo(~[]); } diff --git a/src/test/run-pass/shape_intrinsic_tag_then_rec.rs b/src/test/run-pass/shape_intrinsic_tag_then_rec.rs index 53a09b385b3..578e8d9318f 100644 --- a/src/test/run-pass/shape_intrinsic_tag_then_rec.rs +++ b/src/test/run-pass/shape_intrinsic_tag_then_rec.rs @@ -33,7 +33,7 @@ type ty = Spanned<ty_>; struct X { sp: Span, path: path } -fn main() { +pub fn main() { let sp: Span = Span {lo: 57451u, hi: 57542u, expanded_from: os_none}; let t: @ty = @Spanned { data: 3u, span: sp }; let p_: Path_ = Path_ { global: true, idents: ~[~"hi"], types: ~[t] }; diff --git a/src/test/run-pass/shebang.rs b/src/test/run-pass/shebang.rs index e4a9dee4ed7..f47faca52c0 100644 --- a/src/test/run-pass/shebang.rs +++ b/src/test/run-pass/shebang.rs @@ -11,4 +11,4 @@ // pp-exact -fn main() { io::println("Hello World"); } +pub fn main() { io::println("Hello World"); } diff --git a/src/test/run-pass/shift.rs b/src/test/run-pass/shift.rs index 1b650a48be1..ad0b82a905b 100644 --- a/src/test/run-pass/shift.rs +++ b/src/test/run-pass/shift.rs @@ -11,7 +11,7 @@ // Testing shifts for various combinations of integers // Issue #1570 -fn main() { +pub fn main() { test_misc(); test_expr(); test_const(); diff --git a/src/test/run-pass/signed-shift-const-eval.rs b/src/test/run-pass/signed-shift-const-eval.rs index 932d94a3d6c..fbce196dd39 100644 --- a/src/test/run-pass/signed-shift-const-eval.rs +++ b/src/test/run-pass/signed-shift-const-eval.rs @@ -9,6 +9,6 @@ // except according to those terms. enum test { thing = -5 >> 1u } -fn main() { +pub fn main() { assert(thing as int == -3); } diff --git a/src/test/run-pass/simple-alt-generic-tag.rs b/src/test/run-pass/simple-alt-generic-tag.rs index a7d5433ff83..6f7f2af6820 100644 --- a/src/test/run-pass/simple-alt-generic-tag.rs +++ b/src/test/run-pass/simple-alt-generic-tag.rs @@ -12,7 +12,7 @@ enum opt<T> { none, } -fn main() { +pub fn main() { let x = none::<int>; match x { none::<int> => { debug!("hello world"); } } } diff --git a/src/test/run-pass/simple-generic-alt.rs b/src/test/run-pass/simple-generic-alt.rs index 865e5f735a3..3f3b1c8b783 100644 --- a/src/test/run-pass/simple-generic-alt.rs +++ b/src/test/run-pass/simple-generic-alt.rs @@ -12,4 +12,4 @@ enum clam<T> { a(T), } -fn main() { let c = a(2); match c { a::<int>(_) => { } } } +pub fn main() { let c = a(2); match c { a::<int>(_) => { } } } diff --git a/src/test/run-pass/simple-generic-tag.rs b/src/test/run-pass/simple-generic-tag.rs index 893d5fc934e..8a36f9e17f3 100644 --- a/src/test/run-pass/simple-generic-tag.rs +++ b/src/test/run-pass/simple-generic-tag.rs @@ -12,4 +12,4 @@ enum clam<T> { a(T), } -fn main() { } +pub fn main() { } diff --git a/src/test/run-pass/simple-infer.rs b/src/test/run-pass/simple-infer.rs index bb20951ca54..137c973d590 100644 --- a/src/test/run-pass/simple-infer.rs +++ b/src/test/run-pass/simple-infer.rs @@ -10,4 +10,4 @@ -fn main() { let mut n; n = 1; log(debug, n); } +pub fn main() { let mut n; n = 1; log(debug, n); } diff --git a/src/test/run-pass/size-and-align.rs b/src/test/run-pass/size-and-align.rs index 0f62b52e4d3..b94439e6b9d 100644 --- a/src/test/run-pass/size-and-align.rs +++ b/src/test/run-pass/size-and-align.rs @@ -16,12 +16,12 @@ enum clam<T> { a(T, int), b, } fn uhoh<T>(v: ~[clam<T>]) { match v[1] { - a::<T>(ref t, ref u) => { debug!("incorrect"); log(debug, u); fail; } + a::<T>(ref t, ref u) => { debug!("incorrect"); log(debug, u); die!(); } b::<T> => { debug!("correct"); } } } -fn main() { +pub fn main() { let v: ~[clam<int>] = ~[b::<int>, b::<int>, a::<int>(42, 17)]; uhoh::<int>(v); } diff --git a/src/test/run-pass/spawn-fn.rs b/src/test/run-pass/spawn-fn.rs index 5ae5bbaeec9..c2a0015f6e6 100644 --- a/src/test/run-pass/spawn-fn.rs +++ b/src/test/run-pass/spawn-fn.rs @@ -15,7 +15,7 @@ fn x(s: ~str, n: int) { log(debug, n); } -fn main() { +pub fn main() { task::spawn(|| x(~"hello from first spawned fn", 65) ); task::spawn(|| x(~"hello from second spawned fn", 66) ); task::spawn(|| x(~"hello from third spawned fn", 67) ); diff --git a/src/test/run-pass/spawn-types.rs b/src/test/run-pass/spawn-types.rs index f722a91d196..6090f2eb71c 100644 --- a/src/test/run-pass/spawn-types.rs +++ b/src/test/run-pass/spawn-types.rs @@ -22,7 +22,7 @@ fn iotask(cx: &ctx, ip: ~str) { assert (ip == ~"localhost"); } -fn main() { +pub fn main() { let (p, ch) = stream::<int>(); task::spawn(|| iotask(&ch, ~"localhost") ); } diff --git a/src/test/run-pass/spawn.rs b/src/test/run-pass/spawn.rs index 35680a90cf2..8c328081186 100644 --- a/src/test/run-pass/spawn.rs +++ b/src/test/run-pass/spawn.rs @@ -13,7 +13,7 @@ extern mod std; -fn main() { +pub fn main() { task::spawn(|| child(10) ); } diff --git a/src/test/run-pass/spawn2.rs b/src/test/run-pass/spawn2.rs index fb3dc1ff741..f62593cecec 100644 --- a/src/test/run-pass/spawn2.rs +++ b/src/test/run-pass/spawn2.rs @@ -9,7 +9,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -fn main() { task::spawn(|| child((10, 20, 30, 40, 50, 60, 70, 80, 90)) ); } +pub fn main() { task::spawn(|| child((10, 20, 30, 40, 50, 60, 70, 80, 90)) ); } fn child(&&args: (int, int, int, int, int, int, int, int, int)) { let (i1, i2, i3, i4, i5, i6, i7, i8, i9) = args; diff --git a/src/test/run-pass/stable-addr-of.rs b/src/test/run-pass/stable-addr-of.rs index bbfbf3d02c1..f1f50d83d1a 100644 --- a/src/test/run-pass/stable-addr-of.rs +++ b/src/test/run-pass/stable-addr-of.rs @@ -10,7 +10,7 @@ // Issue #2040 -fn main() { +pub fn main() { let foo = 1; assert ptr::addr_of(&foo) == ptr::addr_of(&foo); } diff --git a/src/test/run-pass/stat.rs b/src/test/run-pass/stat.rs index f170f7c09a0..e71444294dc 100644 --- a/src/test/run-pass/stat.rs +++ b/src/test/run-pass/stat.rs @@ -14,13 +14,13 @@ extern mod std; use io::WriterUtil; use std::tempfile; -fn main() { +pub fn main() { let dir = option::unwrap(tempfile::mkdtemp(&Path("."), "")); let path = dir.with_filename("file"); { match io::file_writer(&path, [io::Create, io::Truncate]) { - Err(copy e) => fail e, + Err(copy e) => die!(e), Ok(f) => { for uint::range(0, 1000) |_i| { f.write_u8(0); diff --git a/src/test/run-pass/static-fn-inline-xc.rs b/src/test/run-pass/static-fn-inline-xc.rs index aa19fa56040..000f43684d4 100644 --- a/src/test/run-pass/static-fn-inline-xc.rs +++ b/src/test/run-pass/static-fn-inline-xc.rs @@ -15,6 +15,6 @@ extern mod mycore(name ="static_fn_inline_xc_aux"); use mycore::num; -fn main() { +pub fn main() { let _1:float = num::Num2::from_int2(1i); } diff --git a/src/test/run-pass/static-fn-trait-xc.rs b/src/test/run-pass/static-fn-trait-xc.rs index eb465ecff32..55db2018aae 100644 --- a/src/test/run-pass/static-fn-trait-xc.rs +++ b/src/test/run-pass/static-fn-trait-xc.rs @@ -5,6 +5,6 @@ extern mod mycore(name ="static_fn_trait_xc_aux"); use mycore::num; -fn main() { +pub fn main() { let _1:float = num::Num2::from_int2(1i); } diff --git a/src/test/run-pass/static-impl.rs b/src/test/run-pass/static-impl.rs index 6987dfab1b5..2aeabcf4872 100644 --- a/src/test/run-pass/static-impl.rs +++ b/src/test/run-pass/static-impl.rs @@ -54,7 +54,7 @@ impl<T> ~[T]: vec_utils<T> { } } -fn main() { +pub fn main() { assert 10u.plus() == 30; assert (~"hi").plus() == 200; diff --git a/src/test/run-pass/static-method-in-trait-with-tps-intracrate.rs b/src/test/run-pass/static-method-in-trait-with-tps-intracrate.rs index 6eba8771fce..bf70b86a4c6 100644 --- a/src/test/run-pass/static-method-in-trait-with-tps-intracrate.rs +++ b/src/test/run-pass/static-method-in-trait-with-tps-intracrate.rs @@ -28,7 +28,7 @@ impl FromThinAir: Deserializer { fn read_int() -> int { 22 } } -fn main() { +pub fn main() { let d = FromThinAir { dummy: () }; let i: int = Deserializable::deserialize(&d); assert i == 22; diff --git a/src/test/run-pass/static-method-test.rs b/src/test/run-pass/static-method-test.rs index 9ee65547cba..28bdcddb3ad 100644 --- a/src/test/run-pass/static-method-test.rs +++ b/src/test/run-pass/static-method-test.rs @@ -78,7 +78,7 @@ fn seq_range<BT: buildable<int>>(lo: uint, hi: uint) -> BT { } } -fn main() { +pub fn main() { let v: @[int] = seq_range(0, 10); assert v == @[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]; diff --git a/src/test/run-pass/static-method-xcrate.rs b/src/test/run-pass/static-method-xcrate.rs index ca42742a576..30fcc7aec34 100644 --- a/src/test/run-pass/static-method-xcrate.rs +++ b/src/test/run-pass/static-method-xcrate.rs @@ -15,7 +15,7 @@ extern mod static_methods_crate; use static_methods_crate::read; use readMaybeRenamed = static_methods_crate::read::readMaybe; -fn main() { +pub fn main() { let result: int = read(~"5"); assert result == 5; assert readMaybeRenamed(~"false") == Some(false); diff --git a/src/test/run-pass/static-methods-in-traits.rs b/src/test/run-pass/static-methods-in-traits.rs index 6e5160da763..d144181984f 100644 --- a/src/test/run-pass/static-methods-in-traits.rs +++ b/src/test/run-pass/static-methods-in-traits.rs @@ -26,7 +26,7 @@ mod a { } } -fn main() { +pub fn main() { let x: int = a::Foo::foo(); let y: uint = a::Foo::foo(); assert x == 3; diff --git a/src/test/run-pass/static-methods-in-traits2.rs b/src/test/run-pass/static-methods-in-traits2.rs index 7851aa481d3..8c61f60eaac 100644 --- a/src/test/run-pass/static-methods-in-traits2.rs +++ b/src/test/run-pass/static-methods-in-traits2.rs @@ -14,6 +14,6 @@ pub impl float: NumConv { pure fn to_float(&self) -> float { *self } } -fn main() { +pub fn main() { let _: float = Number::from(0.0f); } diff --git a/src/test/run-pass/str-append.rs b/src/test/run-pass/str-append.rs index 0bf640b1251..a3eaf6198fb 100644 --- a/src/test/run-pass/str-append.rs +++ b/src/test/run-pass/str-append.rs @@ -32,4 +32,4 @@ fn test2() { assert (b == ~"ABCabcABC"); } -fn main() { test1(); test2(); } +pub fn main() { test1(); test2(); } diff --git a/src/test/run-pass/str-concat.rs b/src/test/run-pass/str-concat.rs index acfbde9783c..6901adaec70 100644 --- a/src/test/run-pass/str-concat.rs +++ b/src/test/run-pass/str-concat.rs @@ -12,7 +12,7 @@ // -*- rust -*- -fn main() { +pub fn main() { let a: ~str = ~"hello"; let b: ~str = ~"world"; let s: ~str = a + b; diff --git a/src/test/run-pass/str-growth.rs b/src/test/run-pass/str-growth.rs index 7835f867d14..3240ab0831d 100644 --- a/src/test/run-pass/str-growth.rs +++ b/src/test/run-pass/str-growth.rs @@ -10,7 +10,7 @@ -fn main() { +pub fn main() { let mut s = ~"a"; s += ~"b"; assert (s[0] == 'a' as u8); diff --git a/src/test/run-pass/str-idx.rs b/src/test/run-pass/str-idx.rs index 2e73877bff1..a9484ccccdc 100644 --- a/src/test/run-pass/str-idx.rs +++ b/src/test/run-pass/str-idx.rs @@ -10,7 +10,7 @@ -fn main() { +pub fn main() { let s = ~"hello"; let c: u8 = s[4]; log(debug, c); diff --git a/src/test/run-pass/str-multiline.rs b/src/test/run-pass/str-multiline.rs index 54119941325..8ff84536227 100644 --- a/src/test/run-pass/str-multiline.rs +++ b/src/test/run-pass/str-multiline.rs @@ -13,7 +13,7 @@ // -*- rust -*- extern mod std; -fn main() { +pub fn main() { let a: ~str = ~"this \ is a test"; let b: ~str = diff --git a/src/test/run-pass/string-self-append.rs b/src/test/run-pass/string-self-append.rs index 54ca0f195ee..7bda8476763 100644 --- a/src/test/run-pass/string-self-append.rs +++ b/src/test/run-pass/string-self-append.rs @@ -10,7 +10,7 @@ extern mod std; -fn main() { +pub fn main() { // Make sure we properly handle repeated self-appends. let mut a: ~str = ~"A"; let mut i = 20; diff --git a/src/test/run-pass/struct-deref.rs b/src/test/run-pass/struct-deref.rs index d04bd20442e..5bf2b70e7fb 100644 --- a/src/test/run-pass/struct-deref.rs +++ b/src/test/run-pass/struct-deref.rs @@ -10,7 +10,7 @@ struct Foo(int); -fn main() { +pub fn main() { let x: Foo = Foo(2); assert *x == 2; } diff --git a/src/test/run-pass/struct-destructuring-cross-crate.rs b/src/test/run-pass/struct-destructuring-cross-crate.rs index c2870f13fa2..6c2324bbc50 100644 --- a/src/test/run-pass/struct-destructuring-cross-crate.rs +++ b/src/test/run-pass/struct-destructuring-cross-crate.rs @@ -13,7 +13,7 @@ extern mod struct_destructuring_cross_crate; -fn main() { +pub fn main() { let x = struct_destructuring_cross_crate::S { x: 1, y: 2 }; let struct_destructuring_cross_crate::S { x: a, y: b } = x; assert a == 1; diff --git a/src/test/run-pass/struct-field-assignability.rs b/src/test/run-pass/struct-field-assignability.rs index 93c490bd5f3..2df92ace6a5 100644 --- a/src/test/run-pass/struct-field-assignability.rs +++ b/src/test/run-pass/struct-field-assignability.rs @@ -2,7 +2,7 @@ struct Foo { x: &int } -fn main() { +pub fn main() { let f = Foo { x: @3 }; assert *f.x == 3; } diff --git a/src/test/run-pass/struct-like-variant-construct.rs b/src/test/run-pass/struct-like-variant-construct.rs index 5796dbd73e2..0d14d90c1f1 100644 --- a/src/test/run-pass/struct-like-variant-construct.rs +++ b/src/test/run-pass/struct-like-variant-construct.rs @@ -19,7 +19,7 @@ enum Foo { } } -fn main() { +pub fn main() { let x = Bar { a: 2, b: 3 }; } diff --git a/src/test/run-pass/struct-like-variant-match.rs b/src/test/run-pass/struct-like-variant-match.rs index 4c01f115295..e36f2d91e42 100644 --- a/src/test/run-pass/struct-like-variant-match.rs +++ b/src/test/run-pass/struct-like-variant-match.rs @@ -32,7 +32,7 @@ fn f(x: &Foo) { } } -fn main() { +pub fn main() { let x = Bar { x: 1, y: 2 }; f(&x); let y = Baz { x: 1.0, y: 2.0 }; diff --git a/src/test/run-pass/struct-literal-dtor.rs b/src/test/run-pass/struct-literal-dtor.rs index 0afeb14ff19..668e7a80b35 100644 --- a/src/test/run-pass/struct-literal-dtor.rs +++ b/src/test/run-pass/struct-literal-dtor.rs @@ -18,6 +18,6 @@ impl foo : Drop { } } -fn main() { +pub fn main() { let _z = foo { x: ~"Hello" }; } diff --git a/src/test/run-pass/struct-pattern-matching.rs b/src/test/run-pass/struct-pattern-matching.rs index bf95f20f4aa..1d7bcb2585f 100644 --- a/src/test/run-pass/struct-pattern-matching.rs +++ b/src/test/run-pass/struct-pattern-matching.rs @@ -13,7 +13,7 @@ struct Foo { y: int, } -fn main() { +pub fn main() { let a = Foo { x: 1, y: 2 }; match a { Foo { x: x, y: y } => io::println(fmt!("yes, %d, %d", x, y)) diff --git a/src/test/run-pass/struct-return.rs b/src/test/run-pass/struct-return.rs index 07855181501..3d75f7b9050 100644 --- a/src/test/run-pass/struct-return.rs +++ b/src/test/run-pass/struct-return.rs @@ -55,7 +55,7 @@ fn test2() { fn test2() { } -fn main() { +pub fn main() { test1(); test2(); } diff --git a/src/test/run-pass/structured-compare.rs b/src/test/run-pass/structured-compare.rs index 18398ad6710..17a4c904470 100644 --- a/src/test/run-pass/structured-compare.rs +++ b/src/test/run-pass/structured-compare.rs @@ -19,7 +19,7 @@ impl foo : cmp::Eq { pure fn ne(&self, other: &foo) -> bool { !(*self).eq(other) } } -fn main() { +pub fn main() { let a = (1, 2, 3); let b = (1, 2, 3); assert (a == b); diff --git a/src/test/run-pass/super.rs b/src/test/run-pass/super.rs index 0eb922643c6..2fe0696b2f2 100644 --- a/src/test/run-pass/super.rs +++ b/src/test/run-pass/super.rs @@ -7,6 +7,6 @@ pub mod a { } } -fn main() { +pub fn main() { } diff --git a/src/test/run-pass/supported-cast.rs b/src/test/run-pass/supported-cast.rs index f8bd90b0eaf..cc9214121e9 100644 --- a/src/test/run-pass/supported-cast.rs +++ b/src/test/run-pass/supported-cast.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -fn main() { +pub fn main() { let f = 1 as *libc::FILE; log(debug, f as int); log(debug, f as uint); diff --git a/src/test/run-pass/swap-1.rs b/src/test/run-pass/swap-1.rs index a67a8d7724b..d4d4668cd55 100644 --- a/src/test/run-pass/swap-1.rs +++ b/src/test/run-pass/swap-1.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -fn main() { +pub fn main() { let mut x = 3; let mut y = 7; x <-> y; assert (x == 7); assert (y == 3); } diff --git a/src/test/run-pass/swap-2.rs b/src/test/run-pass/swap-2.rs index 6a0ee0c69c8..0f1ad1624c6 100644 --- a/src/test/run-pass/swap-2.rs +++ b/src/test/run-pass/swap-2.rs @@ -8,10 +8,10 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -fn swap<T>(v: &[mut T], i: int, j: int) { v[i] <-> v[j]; } +fn swap<T>(v: &mut [T], i: int, j: int) { v[i] <-> v[j]; } -fn main() { - let a: ~[mut int] = ~[mut 0, 1, 2, 3, 4, 5, 6]; +pub fn main() { + let mut a: ~[int] = ~[0, 1, 2, 3, 4, 5, 6]; swap(a, 2, 4); assert (a[2] == 4); assert (a[4] == 2); diff --git a/src/test/run-pass/syntax-extension-fmt.rs b/src/test/run-pass/syntax-extension-fmt.rs index 43ba9504ee2..ddd0743083f 100644 --- a/src/test/run-pass/syntax-extension-fmt.rs +++ b/src/test/run-pass/syntax-extension-fmt.rs @@ -16,7 +16,7 @@ fn test(actual: ~str, expected: ~str) { assert (actual == expected); } -fn main() { +pub fn main() { test(fmt!("hello %d friends and %s things", 10, ~"formatted"), ~"hello 10 friends and formatted things"); diff --git a/src/test/run-pass/syntax-extension-minor.rs b/src/test/run-pass/syntax-extension-minor.rs index aafd71d9162..42a475866a9 100644 --- a/src/test/run-pass/syntax-extension-minor.rs +++ b/src/test/run-pass/syntax-extension-minor.rs @@ -9,7 +9,7 @@ // except according to those terms. -fn main() { +pub fn main() { let asdf_fdsa = ~"<.<"; assert (concat_idents!(asd, f_f, dsa) == ~"<.<"); diff --git a/src/test/run-pass/syntax-extension-shell.rs b/src/test/run-pass/syntax-extension-shell.rs index f0ea92b65d3..cc934b97368 100644 --- a/src/test/run-pass/syntax-extension-shell.rs +++ b/src/test/run-pass/syntax-extension-shell.rs @@ -9,7 +9,7 @@ // except according to those terms. // xfail-test -fn main() { +pub fn main() { let s = shell!( uname -a ); log(debug, s); } diff --git a/src/test/run-pass/syntax-extension-source-utils.rs b/src/test/run-pass/syntax-extension-source-utils.rs index af1b20eb49d..342ee4e3510 100644 --- a/src/test/run-pass/syntax-extension-source-utils.rs +++ b/src/test/run-pass/syntax-extension-source-utils.rs @@ -17,7 +17,7 @@ pub mod m1 { } } -fn main() { +pub fn main() { assert(line!() == 21); assert(col!() == 11); assert(file!().to_owned().ends_with(~"syntax-extension-source-utils.rs")); diff --git a/src/test/run-pass/tag-align-dyn-u64.rs b/src/test/run-pass/tag-align-dyn-u64.rs index 4e358d18f6f..ffbd91d0a3a 100644 --- a/src/test/run-pass/tag-align-dyn-u64.rs +++ b/src/test/run-pass/tag-align-dyn-u64.rs @@ -28,7 +28,7 @@ fn is_8_byte_aligned(&&u: a_tag<u64>) -> bool { return (p & 7u) == 0u; } -fn main() { +pub fn main() { let x = mk_rec(); assert is_8_byte_aligned(x.t); } diff --git a/src/test/run-pass/tag-align-dyn-variants.rs b/src/test/run-pass/tag-align-dyn-variants.rs index 04ef8734247..953b4d55177 100644 --- a/src/test/run-pass/tag-align-dyn-variants.rs +++ b/src/test/run-pass/tag-align-dyn-variants.rs @@ -38,7 +38,7 @@ fn variant_data_is_aligned<A,B>(amnt: uint, &&u: a_tag<A,B>) -> bool { } } -fn main() { +pub fn main() { let x = mk_rec(22u64, 23u64); assert is_aligned(8u, x.tA); assert variant_data_is_aligned(8u, x.tA); diff --git a/src/test/run-pass/tag-align-shape.rs b/src/test/run-pass/tag-align-shape.rs index 6eaa15bf329..2ebb9b2a7d5 100644 --- a/src/test/run-pass/tag-align-shape.rs +++ b/src/test/run-pass/tag-align-shape.rs @@ -21,7 +21,7 @@ type t_rec = { t: a_tag }; -fn main() { +pub fn main() { let x = {c8: 22u8, t: a_tag(44u64)}; let y = fmt!("%?", x); debug!("y = %s", y); diff --git a/src/test/run-pass/tag-align-u64.rs b/src/test/run-pass/tag-align-u64.rs index b7c2925ba4a..29043554c72 100644 --- a/src/test/run-pass/tag-align-u64.rs +++ b/src/test/run-pass/tag-align-u64.rs @@ -28,7 +28,7 @@ fn is_8_byte_aligned(&&u: a_tag) -> bool { return (p & 7u64) == 0u64; } -fn main() { +pub fn main() { let x = mk_rec(); assert is_8_byte_aligned(x.t); } diff --git a/src/test/run-pass/tag-disr-val-shape.rs b/src/test/run-pass/tag-disr-val-shape.rs index 973e210eaf7..244712836d1 100644 --- a/src/test/run-pass/tag-disr-val-shape.rs +++ b/src/test/run-pass/tag-disr-val-shape.rs @@ -16,7 +16,7 @@ enum color { white = 0xFFFFFF, } -fn main() { +pub fn main() { let act = fmt!("%?", red); io::println(act); assert ~"red" == act; diff --git a/src/test/run-pass/tag-exports.rs b/src/test/run-pass/tag-exports.rs index 124afc4364f..e901196387e 100644 --- a/src/test/run-pass/tag-exports.rs +++ b/src/test/run-pass/tag-exports.rs @@ -19,7 +19,7 @@ mod alder { pub enum marshall { northrup, overton } } -fn main() { +pub fn main() { let _pettygrove: burnside = couch; let _quimby: everett = flanders; let _raleigh: irving = johnson; diff --git a/src/test/run-pass/tag-in-block.rs b/src/test/run-pass/tag-in-block.rs index f768d268e62..b3f1d128843 100644 --- a/src/test/run-pass/tag-in-block.rs +++ b/src/test/run-pass/tag-in-block.rs @@ -16,4 +16,4 @@ fn foo() { fn baz() { zed(nil); } } -fn main() { } +pub fn main() { } diff --git a/src/test/run-pass/tag-variant-disr-val.rs b/src/test/run-pass/tag-variant-disr-val.rs index 64eb50cf0ff..c573ee376c7 100644 --- a/src/test/run-pass/tag-variant-disr-val.rs +++ b/src/test/run-pass/tag-variant-disr-val.rs @@ -26,7 +26,7 @@ impl color : cmp::Eq { pure fn ne(&self, other: &color) -> bool { !(*self).eq(other) } } -fn main() { +pub fn main() { test_color(red, 0xff0000, ~"red"); test_color(green, 0x00ff00, ~"green"); test_color(blue, 0x0000ff, ~"blue"); diff --git a/src/test/run-pass/tag.rs b/src/test/run-pass/tag.rs index f103a2c14c6..e74237c7494 100644 --- a/src/test/run-pass/tag.rs +++ b/src/test/run-pass/tag.rs @@ -36,4 +36,4 @@ impl colour : cmp::Eq { fn f() { let x = red(1, 2); let y = green; assert (x != y); } -fn main() { f(); } +pub fn main() { f(); } diff --git a/src/test/run-pass/tail-call-arg-leak.rs b/src/test/run-pass/tail-call-arg-leak.rs index fbeaa9c59c8..6649649d55a 100644 --- a/src/test/run-pass/tail-call-arg-leak.rs +++ b/src/test/run-pass/tail-call-arg-leak.rs @@ -14,4 +14,4 @@ // use of tail calls causes arg slot leaks, issue #160. fn inner(dummy: ~str, b: bool) { if b { return inner(dummy, false); } } -fn main() { inner(~"hi", true); } +pub fn main() { inner(~"hi", true); } diff --git a/src/test/run-pass/tail-cps.rs b/src/test/run-pass/tail-cps.rs index 50d19d31d41..3d1c9842476 100644 --- a/src/test/run-pass/tail-cps.rs +++ b/src/test/run-pass/tail-cps.rs @@ -14,7 +14,7 @@ // -*- rust -*- fn checktrue(rs: bool) -> bool { assert (rs); return true; } -fn main() { let k = checktrue; evenk(42, k); oddk(45, k); } +pub fn main() { let k = checktrue; evenk(42, k); oddk(45, k); } fn evenk(n: int, k: extern fn(bool) -> bool) -> bool { debug!("evenk"); diff --git a/src/test/run-pass/tail-direct.rs b/src/test/run-pass/tail-direct.rs index 3e5b6231e57..1a7733274fe 100644 --- a/src/test/run-pass/tail-direct.rs +++ b/src/test/run-pass/tail-direct.rs @@ -12,7 +12,7 @@ // -*- rust -*- -fn main() { assert (even(42)); assert (odd(45)); } +pub fn main() { assert (even(42)); assert (odd(45)); } fn even(n: int) -> bool { if n == 0 { return true; } else { return odd(n - 1); } } diff --git a/src/test/run-pass/task-comm-0.rs b/src/test/run-pass/task-comm-0.rs index a473d631819..b66f295e1ba 100644 --- a/src/test/run-pass/task-comm-0.rs +++ b/src/test/run-pass/task-comm-0.rs @@ -16,7 +16,7 @@ extern mod std; use pipes::Chan; use pipes::Port; -fn main() { test05(); } +pub fn main() { test05(); } fn test05_start(ch : Chan<int>) { ch.send(10); diff --git a/src/test/run-pass/task-comm-1.rs b/src/test/run-pass/task-comm-1.rs index 2dea2078413..b8e314c4c6e 100644 --- a/src/test/run-pass/task-comm-1.rs +++ b/src/test/run-pass/task-comm-1.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -fn main() { test00(); } +pub fn main() { test00(); } fn start() { debug!("Started / Finished task."); } diff --git a/src/test/run-pass/task-comm-10.rs b/src/test/run-pass/task-comm-10.rs index 5188ec7b71b..a5d55fd823b 100644 --- a/src/test/run-pass/task-comm-10.rs +++ b/src/test/run-pass/task-comm-10.rs @@ -27,7 +27,7 @@ fn start(c: pipes::Chan<pipes::Chan<~str>>) { log(error, move b); } -fn main() { +pub fn main() { let (p, ch) = pipes::stream(); let child = task::spawn(|move ch| start(ch) ); diff --git a/src/test/run-pass/task-comm-11.rs b/src/test/run-pass/task-comm-11.rs index 8d0a8a425b0..498b0b74238 100644 --- a/src/test/run-pass/task-comm-11.rs +++ b/src/test/run-pass/task-comm-11.rs @@ -18,7 +18,7 @@ fn start(c: pipes::Chan<pipes::Chan<int>>) { c.send(move ch); } -fn main() { +pub fn main() { let (p, ch) = pipes::stream(); let child = task::spawn(|move ch| start(ch) ); let c = p.recv(); diff --git a/src/test/run-pass/task-comm-12.rs b/src/test/run-pass/task-comm-12.rs index 5f58f8ab2e3..d32e9454f53 100644 --- a/src/test/run-pass/task-comm-12.rs +++ b/src/test/run-pass/task-comm-12.rs @@ -10,7 +10,7 @@ extern mod std; -fn main() { test00(); } +pub fn main() { test00(); } fn start(&&task_number: int) { debug!("Started / Finished task."); } diff --git a/src/test/run-pass/task-comm-13.rs b/src/test/run-pass/task-comm-13.rs index 89097776b90..c52facf230b 100644 --- a/src/test/run-pass/task-comm-13.rs +++ b/src/test/run-pass/task-comm-13.rs @@ -19,7 +19,7 @@ fn start(c: pipes::Chan<int>, start: int, number_of_messages: int) { while i < number_of_messages { c.send(start + i); i += 1; } } -fn main() { +pub fn main() { debug!("Check that we don't deadlock."); let (p, ch) = pipes::stream(); task::try(|move ch| start(ch, 0, 10) ); diff --git a/src/test/run-pass/task-comm-14.rs b/src/test/run-pass/task-comm-14.rs index f49a095c334..dbf8c034935 100644 --- a/src/test/run-pass/task-comm-14.rs +++ b/src/test/run-pass/task-comm-14.rs @@ -11,7 +11,7 @@ // xfail-fast #[legacy_modes]; -fn main() { +pub fn main() { let po = pipes::PortSet(); // Spawn 10 tasks each sending us back one int. diff --git a/src/test/run-pass/task-comm-15.rs b/src/test/run-pass/task-comm-15.rs index d8a537f2c5c..c65e10d36b7 100644 --- a/src/test/run-pass/task-comm-15.rs +++ b/src/test/run-pass/task-comm-15.rs @@ -22,7 +22,7 @@ fn start(c: pipes::Chan<int>, i0: int) { } } -fn main() { +pub fn main() { // Spawn a task that sends us back messages. The parent task // is likely to terminate before the child completes, so from // the child's point of view the receiver may die. We should diff --git a/src/test/run-pass/task-comm-16.rs b/src/test/run-pass/task-comm-16.rs index 83e34ba84e1..91925fc1917 100644 --- a/src/test/run-pass/task-comm-16.rs +++ b/src/test/run-pass/task-comm-16.rs @@ -110,7 +110,7 @@ fn test_chan() { assert (i == 10); } -fn main() { +pub fn main() { test_rec(); test_vec(); test_str(); diff --git a/src/test/run-pass/task-comm-17.rs b/src/test/run-pass/task-comm-17.rs index 269bb1951f1..e146afa3a0f 100644 --- a/src/test/run-pass/task-comm-17.rs +++ b/src/test/run-pass/task-comm-17.rs @@ -17,6 +17,6 @@ extern mod std; fn f() { } -fn main() { +pub fn main() { task::spawn(|| f() ); } \ No newline at end of file diff --git a/src/test/run-pass/task-comm-3.rs b/src/test/run-pass/task-comm-3.rs index ebbac2d1a0a..97280d37c63 100644 --- a/src/test/run-pass/task-comm-3.rs +++ b/src/test/run-pass/task-comm-3.rs @@ -16,7 +16,7 @@ use pipes::Chan; use pipes::send; use pipes::recv; -fn main() { debug!("===== WITHOUT THREADS ====="); test00(); } +pub fn main() { debug!("===== WITHOUT THREADS ====="); test00(); } fn test00_start(ch: Chan<int>, message: int, count: int) { debug!("Starting test00_start"); diff --git a/src/test/run-pass/task-comm-4.rs b/src/test/run-pass/task-comm-4.rs index dc82ae214dc..d7997d93248 100644 --- a/src/test/run-pass/task-comm-4.rs +++ b/src/test/run-pass/task-comm-4.rs @@ -10,7 +10,7 @@ use pipes::send; -fn main() { test00(); } +pub fn main() { test00(); } fn test00() { let mut r: int = 0; diff --git a/src/test/run-pass/task-comm-5.rs b/src/test/run-pass/task-comm-5.rs index dbf43df4069..f8f19d804c8 100644 --- a/src/test/run-pass/task-comm-5.rs +++ b/src/test/run-pass/task-comm-5.rs @@ -10,7 +10,7 @@ extern mod std; -fn main() { test00(); } +pub fn main() { test00(); } fn test00() { let r: int = 0; diff --git a/src/test/run-pass/task-comm-6.rs b/src/test/run-pass/task-comm-6.rs index cad0f4f1dde..5d19075a71e 100644 --- a/src/test/run-pass/task-comm-6.rs +++ b/src/test/run-pass/task-comm-6.rs @@ -12,7 +12,7 @@ use pipes::send; use pipes::Chan; use pipes::recv; -fn main() { test00(); } +pub fn main() { test00(); } fn test00() { let mut r: int = 0; diff --git a/src/test/run-pass/task-comm-7.rs b/src/test/run-pass/task-comm-7.rs index 313107537dd..5ebd191944b 100644 --- a/src/test/run-pass/task-comm-7.rs +++ b/src/test/run-pass/task-comm-7.rs @@ -13,7 +13,7 @@ extern mod std; -fn main() { test00(); } +pub fn main() { test00(); } fn test00_start(c: pipes::Chan<int>, start: int, number_of_messages: int) { let mut i: int = 0; diff --git a/src/test/run-pass/task-comm-9.rs b/src/test/run-pass/task-comm-9.rs index c12a9fc4f2f..ac259e7f785 100644 --- a/src/test/run-pass/task-comm-9.rs +++ b/src/test/run-pass/task-comm-9.rs @@ -13,7 +13,7 @@ extern mod std; -fn main() { test00(); } +pub fn main() { test00(); } fn test00_start(c: pipes::Chan<int>, number_of_messages: int) { let mut i: int = 0; diff --git a/src/test/run-pass/task-comm-chan-nil.rs b/src/test/run-pass/task-comm-chan-nil.rs index ae2ee7880bd..cb62e2f87ee 100644 --- a/src/test/run-pass/task-comm-chan-nil.rs +++ b/src/test/run-pass/task-comm-chan-nil.rs @@ -15,7 +15,7 @@ extern mod std; // rustboot can't transmit nils across channels because they don't have // any size, but rustc currently can because they do have size. Whether // or not this is desirable I don't know, but here's a regression test. -fn main() { +pub fn main() { let (po, ch) = pipes::stream(); ch.send(()); let n: () = po.recv(); diff --git a/src/test/run-pass/task-killjoin-rsrc.rs b/src/test/run-pass/task-killjoin-rsrc.rs index ca4e8916cc0..65cc8e897d6 100644 --- a/src/test/run-pass/task-killjoin-rsrc.rs +++ b/src/test/run-pass/task-killjoin-rsrc.rs @@ -69,7 +69,7 @@ fn supervised() { // runs first, but I can imagine that changing. error!("supervised task=%?", task::get_task); task::yield(); - fail; + die!(); } fn supervisor() { @@ -78,7 +78,7 @@ fn supervisor() { join(t); } -fn main() { +pub fn main() { join(joinable(supervisor)); } diff --git a/src/test/run-pass/task-killjoin.rs b/src/test/run-pass/task-killjoin.rs index 7ef94afa54f..7ab533bd870 100644 --- a/src/test/run-pass/task-killjoin.rs +++ b/src/test/run-pass/task-killjoin.rs @@ -20,7 +20,7 @@ fn supervised() { // currently not needed because the supervisor runs first, but I can // imagine that changing. task::yield(); - fail; + die!(); } fn supervisor() { @@ -30,7 +30,7 @@ fn supervisor() { task::try(supervised); } -fn main() { +pub fn main() { task::spawn_unlinked(supervisor) } diff --git a/src/test/run-pass/task-life-0.rs b/src/test/run-pass/task-life-0.rs index 00fbbd4b212..3e27ffb4152 100644 --- a/src/test/run-pass/task-life-0.rs +++ b/src/test/run-pass/task-life-0.rs @@ -9,7 +9,7 @@ // except according to those terms. extern mod std; -fn main() { +pub fn main() { task::spawn(|| child(~"Hello") ); } diff --git a/src/test/run-pass/task-spawn-move-and-copy.rs b/src/test/run-pass/task-spawn-move-and-copy.rs index e68d6dd7483..d9b06627c80 100644 --- a/src/test/run-pass/task-spawn-move-and-copy.rs +++ b/src/test/run-pass/task-spawn-move-and-copy.rs @@ -10,7 +10,7 @@ use core::pipes::*; -fn main() { +pub fn main() { let (p, ch) = stream::<uint>(); let x = ~1; diff --git a/src/test/run-pass/terminate-in-initializer.rs b/src/test/run-pass/terminate-in-initializer.rs index db91094b50b..183db464fe2 100644 --- a/src/test/run-pass/terminate-in-initializer.rs +++ b/src/test/run-pass/terminate-in-initializer.rs @@ -21,17 +21,17 @@ fn test_cont() { let mut i = 0; while i < 1 { i += 1; let x: @int = loop; } } fn test_ret() { let x: @int = return; } fn test_fail() { - fn f() { let x: @int = fail; } + fn f() { let x: @int = die!(); } task::try(|| f() ); } fn test_fail_indirect() { - fn f() -> ! { fail; } + fn f() -> ! { die!(); } fn g() { let x: @int = f(); } task::try(|| g() ); } -fn main() { +pub fn main() { test_break(); test_cont(); test_ret(); diff --git a/src/test/run-pass/test-runner-hides-main.rs b/src/test/run-pass/test-runner-hides-main.rs index 59751cb1c01..0c7710585a9 100644 --- a/src/test/run-pass/test-runner-hides-main.rs +++ b/src/test/run-pass/test-runner-hides-main.rs @@ -15,4 +15,4 @@ extern mod std; // Building as a test runner means that a synthetic main will be run, // not ours -fn main() { fail; } +pub fn main() { die!(); } diff --git a/src/test/run-pass/threads.rs b/src/test/run-pass/threads.rs index 02dcebb1132..bd7bab60cb3 100644 --- a/src/test/run-pass/threads.rs +++ b/src/test/run-pass/threads.rs @@ -12,7 +12,7 @@ extern mod std; -fn main() { +pub fn main() { let mut i = 10; while i > 0 { task::spawn({let i = i; || child(i)}); i = i - 1; } debug!("main thread exiting"); diff --git a/src/test/run-pass/too-much-recursion.rs b/src/test/run-pass/too-much-recursion.rs index 9e732c8e3ef..adccc786926 100644 --- a/src/test/run-pass/too-much-recursion.rs +++ b/src/test/run-pass/too-much-recursion.rs @@ -14,7 +14,7 @@ // Test that the task fails after hitting the recursion limit, but // that it doesn't bring down the whole proc -fn main() { +pub fn main() { do task::spawn_unlinked { fn f() { f() }; f(); diff --git a/src/test/run-pass/trait-bounds.rs b/src/test/run-pass/trait-bounds.rs index 4579616176a..8c737428ba9 100644 --- a/src/test/run-pass/trait-bounds.rs +++ b/src/test/run-pass/trait-bounds.rs @@ -27,7 +27,7 @@ impl my_connection_factory: connection_factory<my_connection> { fn create() -> my_connection { () } } -fn main() { +pub fn main() { let factory = (); let connection = factory.create(); let result = connection.read(); diff --git a/src/test/run-pass/trait-cast.rs b/src/test/run-pass/trait-cast.rs index cbc093fcc19..cfb0096f97f 100644 --- a/src/test/run-pass/trait-cast.rs +++ b/src/test/run-pass/trait-cast.rs @@ -44,7 +44,7 @@ impl Tree: to_str { fn foo<T: to_str>(x: T) -> ~str { x.to_str() } -fn main() { +pub fn main() { let t1 = Tree(@TreeR{mut left: None, mut right: None, val: 1 as to_str }); diff --git a/src/test/run-pass/trait-composition-trivial.rs b/src/test/run-pass/trait-composition-trivial.rs index bd4b1a9f4de..56645b48218 100644 --- a/src/test/run-pass/trait-composition-trivial.rs +++ b/src/test/run-pass/trait-composition-trivial.rs @@ -16,6 +16,6 @@ trait Bar : Foo { fn bar(); } -fn main() {} +pub fn main() {} diff --git a/src/test/run-pass/trait-generic.rs b/src/test/run-pass/trait-generic.rs index 25531ee278d..8a8efb4b991 100644 --- a/src/test/run-pass/trait-generic.rs +++ b/src/test/run-pass/trait-generic.rs @@ -42,7 +42,7 @@ fn bar<U: to_str, T: map<U>>(x: T) -> ~[~str] { x.map(|_e| _e.to_str() ) } -fn main() { +pub fn main() { assert foo(~[1]) == ~[~"hi"]; assert bar::<int, ~[int]>(~[4, 5]) == ~[~"4", ~"5"]; assert bar::<~str, ~[~str]>(~[~"x", ~"y"]) == ~[~"x", ~"y"]; diff --git a/src/test/run-pass/trait-inheritance-auto-xc-2.rs b/src/test/run-pass/trait-inheritance-auto-xc-2.rs index 852e41ef078..105cf9ba2ab 100644 --- a/src/test/run-pass/trait-inheritance-auto-xc-2.rs +++ b/src/test/run-pass/trait-inheritance-auto-xc-2.rs @@ -26,7 +26,7 @@ fn f<T: Quux>(a: &T) { assert a.h() == 30; } -fn main() { +pub fn main() { let a = &A { x: 3 }; f(a); } diff --git a/src/test/run-pass/trait-inheritance-auto-xc.rs b/src/test/run-pass/trait-inheritance-auto-xc.rs index c57a2d1dd23..5856d48aec4 100644 --- a/src/test/run-pass/trait-inheritance-auto-xc.rs +++ b/src/test/run-pass/trait-inheritance-auto-xc.rs @@ -27,7 +27,7 @@ fn f<T: Quux>(a: &T) { assert a.h() == 30; } -fn main() { +pub fn main() { let a = &A { x: 3 }; f(a); } diff --git a/src/test/run-pass/trait-inheritance-auto.rs b/src/test/run-pass/trait-inheritance-auto.rs index 70c0aca25ea..c07c03c108d 100644 --- a/src/test/run-pass/trait-inheritance-auto.rs +++ b/src/test/run-pass/trait-inheritance-auto.rs @@ -30,7 +30,7 @@ fn f<T: Quux>(a: &T) { assert a.h() == 30; } -fn main() { +pub fn main() { let a = &A { x: 3 }; f(a); } diff --git a/src/test/run-pass/trait-inheritance-call-bound-inherited.rs b/src/test/run-pass/trait-inheritance-call-bound-inherited.rs index f051187072b..8a3e81c3fdb 100644 --- a/src/test/run-pass/trait-inheritance-call-bound-inherited.rs +++ b/src/test/run-pass/trait-inheritance-call-bound-inherited.rs @@ -21,7 +21,7 @@ fn gg<T:Bar>(a: &T) -> int { a.f() } -fn main() { +pub fn main() { let a = &A { x: 3 }; assert gg(a) == 10; } diff --git a/src/test/run-pass/trait-inheritance-call-bound-inherited2.rs b/src/test/run-pass/trait-inheritance-call-bound-inherited2.rs index bd2e6b09c24..a6bac1a0583 100644 --- a/src/test/run-pass/trait-inheritance-call-bound-inherited2.rs +++ b/src/test/run-pass/trait-inheritance-call-bound-inherited2.rs @@ -24,7 +24,7 @@ fn gg<T: Baz>(a: &T) -> int { a.f() } -fn main() { +pub fn main() { let a = &A { x: 3 }; assert gg(a) == 10; } diff --git a/src/test/run-pass/trait-inheritance-cast-without-call-to-supertrait.rs b/src/test/run-pass/trait-inheritance-cast-without-call-to-supertrait.rs index 100108f9ec9..1ef250f215c 100644 --- a/src/test/run-pass/trait-inheritance-cast-without-call-to-supertrait.rs +++ b/src/test/run-pass/trait-inheritance-cast-without-call-to-supertrait.rs @@ -31,7 +31,7 @@ impl A : Bar { fn g() -> int { 20 } } -fn main() { +pub fn main() { let a = &A { x: 3 }; let afoo = a as &Foo; let abar = a as &Bar; diff --git a/src/test/run-pass/trait-inheritance-cast.rs b/src/test/run-pass/trait-inheritance-cast.rs index 426e407cd36..2fbfaf483e9 100644 --- a/src/test/run-pass/trait-inheritance-cast.rs +++ b/src/test/run-pass/trait-inheritance-cast.rs @@ -32,7 +32,7 @@ impl A : Bar { fn g() -> int { 20 } } -fn main() { +pub fn main() { let a = &A { x: 3 }; let afoo = a as &Foo; let abar = a as &Bar; diff --git a/src/test/run-pass/trait-inheritance-cross-trait-call-xc.rs b/src/test/run-pass/trait-inheritance-cross-trait-call-xc.rs index 7dab7064a41..ce0a5fe5465 100644 --- a/src/test/run-pass/trait-inheritance-cross-trait-call-xc.rs +++ b/src/test/run-pass/trait-inheritance-cross-trait-call-xc.rs @@ -21,7 +21,7 @@ impl aux::A : Bar { fn g() -> int { self.f() } } -fn main() { +pub fn main() { let a = &aux::A { x: 3 }; assert a.g() == 10; } diff --git a/src/test/run-pass/trait-inheritance-cross-trait-call.rs b/src/test/run-pass/trait-inheritance-cross-trait-call.rs index ec3ec4fbee2..78e258bac48 100644 --- a/src/test/run-pass/trait-inheritance-cross-trait-call.rs +++ b/src/test/run-pass/trait-inheritance-cross-trait-call.rs @@ -20,7 +20,7 @@ impl A : Bar { fn g() -> int { self.f() } } -fn main() { +pub fn main() { let a = &A { x: 3 }; assert a.g() == 10; } diff --git a/src/test/run-pass/trait-inheritance-diamond.rs b/src/test/run-pass/trait-inheritance-diamond.rs index 83e90854265..42042641357 100644 --- a/src/test/run-pass/trait-inheritance-diamond.rs +++ b/src/test/run-pass/trait-inheritance-diamond.rs @@ -29,7 +29,7 @@ fn f<T: D>(x: &T) { assert x.d() == 40; } -fn main() { +pub fn main() { let value = &S { bogus: () }; f(value); } \ No newline at end of file diff --git a/src/test/run-pass/trait-inheritance-multiple-inheritors.rs b/src/test/run-pass/trait-inheritance-multiple-inheritors.rs index 3f7f61b94b8..a293051d360 100644 --- a/src/test/run-pass/trait-inheritance-multiple-inheritors.rs +++ b/src/test/run-pass/trait-inheritance-multiple-inheritors.rs @@ -25,6 +25,6 @@ fn f<T: B C>(x: &T) { assert x.c() == 30; } -fn main() { +pub fn main() { f(&S { bogus: () }) } \ No newline at end of file diff --git a/src/test/run-pass/trait-inheritance-multiple-params.rs b/src/test/run-pass/trait-inheritance-multiple-params.rs index 748659cb121..7008b098d8a 100644 --- a/src/test/run-pass/trait-inheritance-multiple-params.rs +++ b/src/test/run-pass/trait-inheritance-multiple-params.rs @@ -27,7 +27,7 @@ fn f<X: A, Y: B, Z: C>(x: &X, y: &Y, z: &Z) { assert z.c() == 30; } -fn main() { +pub fn main() { let s = &S { bogus: () }; f(s, s, s); } \ No newline at end of file diff --git a/src/test/run-pass/trait-inheritance-num.rs b/src/test/run-pass/trait-inheritance-num.rs index 05e91912c24..90e7db7dbbb 100644 --- a/src/test/run-pass/trait-inheritance-num.rs +++ b/src/test/run-pass/trait-inheritance-num.rs @@ -23,4 +23,4 @@ pub trait FloatExt: NumExt FuzzyEq {} fn greater_than_one<T:NumExt>(n: &T) -> bool { *n > from_int(1) } fn greater_than_one_float<T:FloatExt>(n: &T) -> bool { *n > from_int(1) } -fn main() {} +pub fn main() {} diff --git a/src/test/run-pass/trait-inheritance-num0.rs b/src/test/run-pass/trait-inheritance-num0.rs index 2d82832652f..c7f43e055a4 100644 --- a/src/test/run-pass/trait-inheritance-num0.rs +++ b/src/test/run-pass/trait-inheritance-num0.rs @@ -25,4 +25,4 @@ fn greater_than_one<T:NumExt>(n: &T) -> bool { n.gt(&from_int(1)) } -fn main() {} +pub fn main() {} diff --git a/src/test/run-pass/trait-inheritance-num1.rs b/src/test/run-pass/trait-inheritance-num1.rs index 3740e484a45..75467359936 100644 --- a/src/test/run-pass/trait-inheritance-num1.rs +++ b/src/test/run-pass/trait-inheritance-num1.rs @@ -19,4 +19,4 @@ fn greater_than_one<T:NumExt>(n: &T) -> bool { *n > from_int(1) } -fn main() {} +pub fn main() {} diff --git a/src/test/run-pass/trait-inheritance-num2.rs b/src/test/run-pass/trait-inheritance-num2.rs index 7686f388e2c..455b3946ec0 100644 --- a/src/test/run-pass/trait-inheritance-num2.rs +++ b/src/test/run-pass/trait-inheritance-num2.rs @@ -103,6 +103,6 @@ pub impl float: FloatExt {} fn test_float_ext<T:FloatExt>(n: T) { io::println(fmt!("%?", n < n)) } -fn main() { +pub fn main() { test_float_ext(1f32); } diff --git a/src/test/run-pass/trait-inheritance-num3.rs b/src/test/run-pass/trait-inheritance-num3.rs index 78dfee136a9..939b074e2dd 100644 --- a/src/test/run-pass/trait-inheritance-num3.rs +++ b/src/test/run-pass/trait-inheritance-num3.rs @@ -17,6 +17,6 @@ pub impl f32: NumExt {} fn num_eq_one<T:NumExt>(n: T) { io::println(fmt!("%?", n == from_int(1))) } -fn main() { +pub fn main() { num_eq_one(1f32); // you need to actually use the function to trigger the ICE } \ No newline at end of file diff --git a/src/test/run-pass/trait-inheritance-num5.rs b/src/test/run-pass/trait-inheritance-num5.rs index c8db6f17a81..bb9b57d4afb 100644 --- a/src/test/run-pass/trait-inheritance-num5.rs +++ b/src/test/run-pass/trait-inheritance-num5.rs @@ -20,6 +20,6 @@ fn num_eq_one<T:NumExt>() -> T { from_int(1) } -fn main() { +pub fn main() { num_eq_one::<int>(); // you need to actually use the function to trigger the ICE } diff --git a/src/test/run-pass/trait-inheritance-overloading-simple.rs b/src/test/run-pass/trait-inheritance-overloading-simple.rs index 63df8397bc5..70c8981fd3c 100644 --- a/src/test/run-pass/trait-inheritance-overloading-simple.rs +++ b/src/test/run-pass/trait-inheritance-overloading-simple.rs @@ -27,7 +27,7 @@ fn f<T:MyNum>(x: T, y: T) -> bool { pure fn mi(v: int) -> MyInt { MyInt { val: v } } -fn main() { +pub fn main() { let (x, y, z) = (mi(3), mi(5), mi(3)); assert x != y; assert x == z; diff --git a/src/test/run-pass/trait-inheritance-overloading-xc-exe.rs b/src/test/run-pass/trait-inheritance-overloading-xc-exe.rs index f0e33b69540..f7798507871 100644 --- a/src/test/run-pass/trait-inheritance-overloading-xc-exe.rs +++ b/src/test/run-pass/trait-inheritance-overloading-xc-exe.rs @@ -20,7 +20,7 @@ fn f<T:Copy MyNum>(x: T, y: T) -> (T, T, T) { pure fn mi(v: int) -> MyInt { MyInt { val: v } } -fn main() { +pub fn main() { let (x, y) = (mi(3), mi(5)); let (a, b, c) = f(x, y); assert a == mi(8); diff --git a/src/test/run-pass/trait-inheritance-overloading.rs b/src/test/run-pass/trait-inheritance-overloading.rs index e4f98bb7962..6794e8130e5 100644 --- a/src/test/run-pass/trait-inheritance-overloading.rs +++ b/src/test/run-pass/trait-inheritance-overloading.rs @@ -39,7 +39,7 @@ fn f<T:Copy MyNum>(x: T, y: T) -> (T, T, T) { pure fn mi(v: int) -> MyInt { MyInt { val: v } } -fn main() { +pub fn main() { let (x, y) = (mi(3), mi(5)); let (a, b, c) = f(x, y); assert a == mi(8); diff --git a/src/test/run-pass/trait-inheritance-self.rs b/src/test/run-pass/trait-inheritance-self.rs index 636cd5cd397..3f157f31283 100644 --- a/src/test/run-pass/trait-inheritance-self.rs +++ b/src/test/run-pass/trait-inheritance-self.rs @@ -22,7 +22,7 @@ impl S : Bar { } } -fn main() { +pub fn main() { let s = S { x: 1 }; s.g(); } diff --git a/src/test/run-pass/trait-inheritance-simple.rs b/src/test/run-pass/trait-inheritance-simple.rs index 5d3bafc0810..b119438240a 100644 --- a/src/test/run-pass/trait-inheritance-simple.rs +++ b/src/test/run-pass/trait-inheritance-simple.rs @@ -24,7 +24,7 @@ fn gg<T:Bar>(a: &T) -> int { a.g() } -fn main() { +pub fn main() { let a = &A { x: 3 }; assert ff(a) == 10; assert gg(a) == 20; diff --git a/src/test/run-pass/trait-inheritance-static.rs b/src/test/run-pass/trait-inheritance-static.rs index 4a874f02a6a..4b40d759609 100644 --- a/src/test/run-pass/trait-inheritance-static.rs +++ b/src/test/run-pass/trait-inheritance-static.rs @@ -28,7 +28,7 @@ impl S: NumExt { } fn greater_than_one<T:NumExt>() -> T { MyNum::from_int(1) } -fn main() { +pub fn main() { let v: S = greater_than_one(); assert v.v == 1; } diff --git a/src/test/run-pass/trait-inheritance-static2.rs b/src/test/run-pass/trait-inheritance-static2.rs index b767f34b4b1..8967bd91b8b 100644 --- a/src/test/run-pass/trait-inheritance-static2.rs +++ b/src/test/run-pass/trait-inheritance-static2.rs @@ -32,7 +32,7 @@ impl S: NumExt { } fn greater_than_one<T:NumExt>() -> T { MyNum::from_int(1) } -fn main() { +pub fn main() { let v: S = greater_than_one(); assert v.v == 1; } diff --git a/src/test/run-pass/trait-inheritance-subst.rs b/src/test/run-pass/trait-inheritance-subst.rs index 686c5cba633..c8b270cad76 100644 --- a/src/test/run-pass/trait-inheritance-subst.rs +++ b/src/test/run-pass/trait-inheritance-subst.rs @@ -28,7 +28,7 @@ fn f<T:MyNum>(x: T, y: T) -> T { pure fn mi(v: int) -> MyInt { MyInt { val: v } } -fn main() { +pub fn main() { let (x, y) = (mi(3), mi(5)); let z = f(x, y); assert z.val == 8 diff --git a/src/test/run-pass/trait-inheritance-subst2.rs b/src/test/run-pass/trait-inheritance-subst2.rs index 54a7e811a1c..5659fed9c9b 100644 --- a/src/test/run-pass/trait-inheritance-subst2.rs +++ b/src/test/run-pass/trait-inheritance-subst2.rs @@ -38,7 +38,7 @@ fn f<T:MyNum>(x: T, y: T) -> T { fn mi(v: int) -> MyInt { MyInt { val: v } } -fn main() { +pub fn main() { let (x, y) = (mi(3), mi(5)); let z = f(x, y); assert z.val == 13; diff --git a/src/test/run-pass/trait-inheritance-visibility.rs b/src/test/run-pass/trait-inheritance-visibility.rs index d18a4fa1142..70b0302de8c 100644 --- a/src/test/run-pass/trait-inheritance-visibility.rs +++ b/src/test/run-pass/trait-inheritance-visibility.rs @@ -23,6 +23,6 @@ fn f<T: Quux>(x: &T) { assert x.f() == 10; } -fn main() { +pub fn main() { f(&0) } \ No newline at end of file diff --git a/src/test/run-pass/trait-inheritance2.rs b/src/test/run-pass/trait-inheritance2.rs index a09432ebf5d..951c03fd016 100644 --- a/src/test/run-pass/trait-inheritance2.rs +++ b/src/test/run-pass/trait-inheritance2.rs @@ -27,7 +27,7 @@ fn f<T: Quux Foo Bar Baz>(a: &T) { assert a.h() == 30; } -fn main() { +pub fn main() { let a = &A { x: 3 }; f(a); } diff --git a/src/test/run-pass/trait-region-pointer-simple.rs b/src/test/run-pass/trait-region-pointer-simple.rs index 2d963d59c1f..1cd34e264e8 100644 --- a/src/test/run-pass/trait-region-pointer-simple.rs +++ b/src/test/run-pass/trait-region-pointer-simple.rs @@ -23,7 +23,7 @@ impl A : Foo { } } -fn main() { +pub fn main() { let a = A { x: 3 }; let b = (&a) as &Foo; assert b.f() == 3; diff --git a/src/test/run-pass/trait-static-method-overwriting.rs b/src/test/run-pass/trait-static-method-overwriting.rs index d8a8fc26d7f..9538ea497ec 100644 --- a/src/test/run-pass/trait-static-method-overwriting.rs +++ b/src/test/run-pass/trait-static-method-overwriting.rs @@ -38,7 +38,7 @@ mod base { } } -fn main() { +pub fn main() { let f: base::Foo = base::HasNew::new::<base::Foo, base::Foo>(); let b: base::Bar = base::HasNew::new::<base::Bar, base::Bar>(); } diff --git a/src/test/run-pass/trait-to-str.rs b/src/test/run-pass/trait-to-str.rs index 43cafa49b4e..8b6f61117e8 100644 --- a/src/test/run-pass/trait-to-str.rs +++ b/src/test/run-pass/trait-to-str.rs @@ -30,7 +30,7 @@ impl<T: to_str> ~[T]: to_str { } } -fn main() { +pub fn main() { assert 1.to_str() == ~"1"; assert (~[2, 3, 4]).to_str() == ~"[2, 3, 4]"; diff --git a/src/test/run-pass/trait-typedef-cc.rs b/src/test/run-pass/trait-typedef-cc.rs index 8b1366bb220..9e75a6625a5 100644 --- a/src/test/run-pass/trait-typedef-cc.rs +++ b/src/test/run-pass/trait-typedef-cc.rs @@ -22,7 +22,7 @@ impl S: Foo { fn bar() { } } -fn main() { +pub fn main() { let s = S { name: 0 }; diff --git a/src/test/run-pass/traits-default-method-macro.rs b/src/test/run-pass/traits-default-method-macro.rs index 9e49b249c18..66f4c431141 100644 --- a/src/test/run-pass/traits-default-method-macro.rs +++ b/src/test/run-pass/traits-default-method-macro.rs @@ -23,7 +23,7 @@ enum Baz { impl Baz: Foo { } -fn main() { +pub fn main() { let q = Quux; assert q.bar() == ~"test"; } diff --git a/src/test/run-pass/traits-default-method-self.rs b/src/test/run-pass/traits-default-method-self.rs index 6626c97bab1..b0742255ba3 100644 --- a/src/test/run-pass/traits-default-method-self.rs +++ b/src/test/run-pass/traits-default-method-self.rs @@ -24,6 +24,6 @@ impl int : Cat { } } -fn main() { +pub fn main() { assert 5.meow(); } diff --git a/src/test/run-pass/traits-default-method-trivial.rs b/src/test/run-pass/traits-default-method-trivial.rs index 9dbb26af441..e9850588e9e 100644 --- a/src/test/run-pass/traits-default-method-trivial.rs +++ b/src/test/run-pass/traits-default-method-trivial.rs @@ -25,6 +25,6 @@ impl int : Cat { } } -fn main() { +pub fn main() { assert 5.meow(); } diff --git a/src/test/run-pass/trivial-message.rs b/src/test/run-pass/trivial-message.rs index e5bcba59ea2..21524d3fc54 100644 --- a/src/test/run-pass/trivial-message.rs +++ b/src/test/run-pass/trivial-message.rs @@ -14,7 +14,7 @@ use pipes::{Port, Chan}; This is about the simplest program that can successfully send a message. */ -fn main() { +pub fn main() { let (po, ch) = pipes::stream(); ch.send(42); let r = po.recv(); diff --git a/src/test/run-pass/tstate-loop-break.rs b/src/test/run-pass/tstate-loop-break.rs index 7c4f941c524..8b626611c41 100644 --- a/src/test/run-pass/tstate-loop-break.rs +++ b/src/test/run-pass/tstate-loop-break.rs @@ -22,6 +22,6 @@ fn test() { even(v); } -fn main() { +pub fn main() { test(); } diff --git a/src/test/run-pass/tup.rs b/src/test/run-pass/tup.rs index cb58d926bb1..01d2600708d 100644 --- a/src/test/run-pass/tup.rs +++ b/src/test/run-pass/tup.rs @@ -17,7 +17,7 @@ fn f(p: point, x: int, y: int) { assert (b == y); } -fn main() { +pub fn main() { let p: point = (10, 20); let (a, b) = p; assert (a == 10); diff --git a/src/test/run-pass/tuple-struct-construct.rs b/src/test/run-pass/tuple-struct-construct.rs index 5fb48d3a079..ea410093c4b 100644 --- a/src/test/run-pass/tuple-struct-construct.rs +++ b/src/test/run-pass/tuple-struct-construct.rs @@ -10,7 +10,7 @@ struct Foo(int, int); -fn main() { +pub fn main() { let x = Foo(1, 2); io::println(fmt!("%?", x)); } diff --git a/src/test/run-pass/tuple-struct-destructuring.rs b/src/test/run-pass/tuple-struct-destructuring.rs index 61799f11046..dcecacf975a 100644 --- a/src/test/run-pass/tuple-struct-destructuring.rs +++ b/src/test/run-pass/tuple-struct-destructuring.rs @@ -10,7 +10,7 @@ struct Foo(int, int); -fn main() { +pub fn main() { let x = Foo(1, 2); let Foo(y, z) = x; io::println(fmt!("%d %d", y, z)); diff --git a/src/test/run-pass/tuple-struct-matching.rs b/src/test/run-pass/tuple-struct-matching.rs index ab7b83e56ef..e127ba6d4c9 100644 --- a/src/test/run-pass/tuple-struct-matching.rs +++ b/src/test/run-pass/tuple-struct-matching.rs @@ -10,7 +10,7 @@ struct Foo(int, int); -fn main() { +pub fn main() { let x = Foo(1, 2); match x { Foo(a, b) => { diff --git a/src/test/run-pass/tuple-struct-trivial.rs b/src/test/run-pass/tuple-struct-trivial.rs index 520d5c60114..8ddc04a186f 100644 --- a/src/test/run-pass/tuple-struct-trivial.rs +++ b/src/test/run-pass/tuple-struct-trivial.rs @@ -12,6 +12,6 @@ struct Foo(int, int, int); -fn main() { +pub fn main() { } diff --git a/src/test/run-pass/type-in-nested-module.rs b/src/test/run-pass/type-in-nested-module.rs index bb7b9aa46eb..e2ccee013c2 100644 --- a/src/test/run-pass/type-in-nested-module.rs +++ b/src/test/run-pass/type-in-nested-module.rs @@ -18,4 +18,4 @@ mod a { } } -fn main() { } +pub fn main() { } diff --git a/src/test/run-pass/type-namespace.rs b/src/test/run-pass/type-namespace.rs index 4215a8597f2..56b9c4700b9 100644 --- a/src/test/run-pass/type-namespace.rs +++ b/src/test/run-pass/type-namespace.rs @@ -12,4 +12,4 @@ struct A { a: int } fn a(a: A) -> int { return a.a; } -fn main() { let x: A = A {a: 1}; assert (a(x) == 1); } +pub fn main() { let x: A = A {a: 1}; assert (a(x) == 1); } diff --git a/src/test/run-pass/type-param-constraints.rs b/src/test/run-pass/type-param-constraints.rs index aa0485f7994..d5749155456 100644 --- a/src/test/run-pass/type-param-constraints.rs +++ b/src/test/run-pass/type-param-constraints.rs @@ -29,7 +29,7 @@ fn r(i:int) -> r { } } -fn main() { +pub fn main() { p_foo(r(10)); p_foo(@r(10)); diff --git a/src/test/run-pass/type-param.rs b/src/test/run-pass/type-param.rs index 7efad62276e..209dade8d0c 100644 --- a/src/test/run-pass/type-param.rs +++ b/src/test/run-pass/type-param.rs @@ -12,4 +12,4 @@ type lteq<T> = extern fn(T) -> bool; -fn main() { } +pub fn main() { } diff --git a/src/test/run-pass/type-params-in-for-each.rs b/src/test/run-pass/type-params-in-for-each.rs index dd8f321f5f4..f4ec8b0c9e8 100644 --- a/src/test/run-pass/type-params-in-for-each.rs +++ b/src/test/run-pass/type-params-in-for-each.rs @@ -19,4 +19,4 @@ fn create_index<T>(index: ~[{a: T, b: uint}], hash_fn: extern fn(T) -> uint) { range(0u, 256u, |_i| { let bucket: ~[T] = ~[]; } ) } -fn main() { } +pub fn main() { } diff --git a/src/test/run-pass/type-ptr.rs b/src/test/run-pass/type-ptr.rs index defa98990f0..a00b6b8153e 100644 --- a/src/test/run-pass/type-ptr.rs +++ b/src/test/run-pass/type-ptr.rs @@ -12,4 +12,4 @@ fn f(a: *int) -> *int { return a; } fn g(a: *int) -> *int { let b = f(a); return b; } -fn main() { return; } +pub fn main() { return; } diff --git a/src/test/run-pass/type-sizes.rs b/src/test/run-pass/type-sizes.rs index 0a2863b6a96..2c50e73cd57 100644 --- a/src/test/run-pass/type-sizes.rs +++ b/src/test/run-pass/type-sizes.rs @@ -12,7 +12,7 @@ use sys::rustrt::size_of; extern mod std; -fn main() { +pub fn main() { assert (size_of::<u8>() == 1 as uint); assert (size_of::<u32>() == 4 as uint); assert (size_of::<char>() == 4 as uint); diff --git a/src/test/run-pass/type-use-i1-versus-i8.rs b/src/test/run-pass/type-use-i1-versus-i8.rs index 4c92374409e..5f0414cdb78 100644 --- a/src/test/run-pass/type-use-i1-versus-i8.rs +++ b/src/test/run-pass/type-use-i1-versus-i8.rs @@ -9,7 +9,7 @@ // except according to those terms. use io::ReaderUtil; -fn main() { +pub fn main() { let mut x: bool = false; // this line breaks it vec::rusti::move_val_init(&mut x, false); diff --git a/src/test/run-pass/typeclasses-eq-example-static.rs b/src/test/run-pass/typeclasses-eq-example-static.rs index 3da714f0a7b..13afc62baeb 100644 --- a/src/test/run-pass/typeclasses-eq-example-static.rs +++ b/src/test/run-pass/typeclasses-eq-example-static.rs @@ -46,7 +46,7 @@ impl ColorTree : Equal { } } -fn main() { +pub fn main() { assert Equal::isEq(cyan, cyan); assert Equal::isEq(magenta, magenta); assert !Equal::isEq(cyan, yellow); diff --git a/src/test/run-pass/typeclasses-eq-example.rs b/src/test/run-pass/typeclasses-eq-example.rs index 75a574b1dda..cf2c2e27fa5 100644 --- a/src/test/run-pass/typeclasses-eq-example.rs +++ b/src/test/run-pass/typeclasses-eq-example.rs @@ -45,7 +45,7 @@ impl ColorTree : Equal { } } -fn main() { +pub fn main() { assert cyan.isEq(cyan); assert magenta.isEq(magenta); assert !cyan.isEq(yellow); diff --git a/src/test/run-pass/typestate-cfg-nesting.rs b/src/test/run-pass/typestate-cfg-nesting.rs index 5dee498d6b1..997464ba50a 100644 --- a/src/test/run-pass/typestate-cfg-nesting.rs +++ b/src/test/run-pass/typestate-cfg-nesting.rs @@ -15,7 +15,7 @@ fn f() { if true { match x { _ => { y = x; } } } else { } } -fn main() { +pub fn main() { let x = 10; let mut y = 11; if true { while false { y = x; } } else { } diff --git a/src/test/run-pass/typestate-multi-decl.rs b/src/test/run-pass/typestate-multi-decl.rs index d5c44a65f92..68fff0cf8f5 100644 --- a/src/test/run-pass/typestate-multi-decl.rs +++ b/src/test/run-pass/typestate-multi-decl.rs @@ -8,4 +8,4 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -fn main() { let x = 10, y = 20; let z = x + y; assert (z == 30); } +pub fn main() { let x = 10, y = 20; let z = x + y; assert (z == 30); } diff --git a/src/test/run-pass/u32-decr.rs b/src/test/run-pass/u32-decr.rs index b8e1c389f68..a720bd5f2b5 100644 --- a/src/test/run-pass/u32-decr.rs +++ b/src/test/run-pass/u32-decr.rs @@ -12,7 +12,7 @@ // -*- rust -*- -fn main() { +pub fn main() { let mut word: u32 = 200000u32; word = word - 1u32; assert (word == 199999u32); diff --git a/src/test/run-pass/u8-incr-decr.rs b/src/test/run-pass/u8-incr-decr.rs index 561e0d7f840..e99a5d9e081 100644 --- a/src/test/run-pass/u8-incr-decr.rs +++ b/src/test/run-pass/u8-incr-decr.rs @@ -15,7 +15,7 @@ // These constants were chosen because they aren't used anywhere // in the rest of the generated code so they're easily grep-able. -fn main() { +pub fn main() { let mut x: u8 = 19u8; // 0x13 let mut y: u8 = 35u8; // 0x23 diff --git a/src/test/run-pass/u8-incr.rs b/src/test/run-pass/u8-incr.rs index 0cfef4f3ff4..44f0c9b19ba 100644 --- a/src/test/run-pass/u8-incr.rs +++ b/src/test/run-pass/u8-incr.rs @@ -12,7 +12,7 @@ // -*- rust -*- -fn main() { +pub fn main() { let mut x: u8 = 12u8; let y: u8 = 12u8; x = x + 1u8; diff --git a/src/test/run-pass/uint.rs b/src/test/run-pass/uint.rs index 72b467aa3a1..b865b302668 100644 --- a/src/test/run-pass/uint.rs +++ b/src/test/run-pass/uint.rs @@ -12,4 +12,4 @@ // -*- rust -*- -fn main() { let x: uint = 10 as uint; } +pub fn main() { let x: uint = 10 as uint; } diff --git a/src/test/run-pass/unary-minus-suffix-inference.rs b/src/test/run-pass/unary-minus-suffix-inference.rs index ac558c515de..d48b8bd7b4e 100644 --- a/src/test/run-pass/unary-minus-suffix-inference.rs +++ b/src/test/run-pass/unary-minus-suffix-inference.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -fn main() { +pub fn main() { let a = 1; let a_neg: i8 = -a; log(error, a_neg); diff --git a/src/test/run-pass/unify-return-ty.rs b/src/test/run-pass/unify-return-ty.rs index 3f925e34475..5452936c411 100644 --- a/src/test/run-pass/unify-return-ty.rs +++ b/src/test/run-pass/unify-return-ty.rs @@ -19,4 +19,4 @@ fn null<T>() -> *T { } } -fn main() { null::<int>(); } +pub fn main() { null::<int>(); } diff --git a/src/test/run-pass/uniq-cc-generic.rs b/src/test/run-pass/uniq-cc-generic.rs index b1cde5b2e85..8de91acd185 100644 --- a/src/test/run-pass/uniq-cc-generic.rs +++ b/src/test/run-pass/uniq-cc-generic.rs @@ -29,7 +29,7 @@ fn empty_pointy() -> @Pointy { } } -fn main() +pub fn main() { let v = empty_pointy(); v.a = p(v); diff --git a/src/test/run-pass/uniq-cc.rs b/src/test/run-pass/uniq-cc.rs index deaf09a2392..384450ec57f 100644 --- a/src/test/run-pass/uniq-cc.rs +++ b/src/test/run-pass/uniq-cc.rs @@ -27,7 +27,7 @@ fn empty_pointy() -> @Pointy { } } -fn main() +pub fn main() { let v = empty_pointy(); v.a = p(v); diff --git a/src/test/run-pass/unique-alt-discrim.rs b/src/test/run-pass/unique-alt-discrim.rs index fcc800c1c18..60c5bf068f0 100644 --- a/src/test/run-pass/unique-alt-discrim.rs +++ b/src/test/run-pass/unique-alt-discrim.rs @@ -15,4 +15,4 @@ fn altsimple() { _ => { } } } -fn main() { } \ No newline at end of file +pub fn main() { } \ No newline at end of file diff --git a/src/test/run-pass/unique-assign-copy.rs b/src/test/run-pass/unique-assign-copy.rs index 2c5d49130a5..4723356dcd0 100644 --- a/src/test/run-pass/unique-assign-copy.rs +++ b/src/test/run-pass/unique-assign-copy.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -fn main() { +pub fn main() { let i = ~mut 1; // Should be a copy let mut j; diff --git a/src/test/run-pass/unique-assign-drop.rs b/src/test/run-pass/unique-assign-drop.rs index bb412f61720..07c1d522157 100644 --- a/src/test/run-pass/unique-assign-drop.rs +++ b/src/test/run-pass/unique-assign-drop.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -fn main() { +pub fn main() { let i = ~1; let mut j = ~2; // Should drop the previous value of j diff --git a/src/test/run-pass/unique-assign-generic.rs b/src/test/run-pass/unique-assign-generic.rs index d00d8cfc9c3..9ad5575be9d 100644 --- a/src/test/run-pass/unique-assign-generic.rs +++ b/src/test/run-pass/unique-assign-generic.rs @@ -13,7 +13,7 @@ fn f<T: Copy>(t: T) -> T { t1 } -fn main() { +pub fn main() { let t = f(~100); assert t == ~100; let t = f(~@~[100]); diff --git a/src/test/run-pass/unique-assign.rs b/src/test/run-pass/unique-assign.rs index 36bf2905e58..9089ac9a327 100644 --- a/src/test/run-pass/unique-assign.rs +++ b/src/test/run-pass/unique-assign.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -fn main() { +pub fn main() { let mut i; i = ~1; assert *i == 1; diff --git a/src/test/run-pass/unique-autoderef-field.rs b/src/test/run-pass/unique-autoderef-field.rs index d53d89457f1..eac67c65b8f 100644 --- a/src/test/run-pass/unique-autoderef-field.rs +++ b/src/test/run-pass/unique-autoderef-field.rs @@ -10,7 +10,7 @@ struct J { j: int } -fn main() { +pub fn main() { let i = ~J { j: 100 }; diff --git a/src/test/run-pass/unique-autoderef-index.rs b/src/test/run-pass/unique-autoderef-index.rs index d61afb384ea..45e4b798969 100644 --- a/src/test/run-pass/unique-autoderef-index.rs +++ b/src/test/run-pass/unique-autoderef-index.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -fn main() { +pub fn main() { let i = ~~[100]; assert i[0] == 100; } diff --git a/src/test/run-pass/unique-cmp.rs b/src/test/run-pass/unique-cmp.rs index 3b22b0198fe..5a565d4b81c 100644 --- a/src/test/run-pass/unique-cmp.rs +++ b/src/test/run-pass/unique-cmp.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -fn main() { +pub fn main() { let i = ~100; assert i == ~100; assert i < ~101; diff --git a/src/test/run-pass/unique-containing-tag.rs b/src/test/run-pass/unique-containing-tag.rs index 4aa35ea6752..05d57967340 100644 --- a/src/test/run-pass/unique-containing-tag.rs +++ b/src/test/run-pass/unique-containing-tag.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -fn main() { +pub fn main() { enum t { t1(int), t2(int), } let x = ~t1(10); @@ -17,13 +17,13 @@ fn main() { t1(a) { assert a == 10; } - _ { fail; } + _ { die!(); } }*/ /*alt x { ~t1(a) { assert a == 10; } - _ { fail; } + _ { die!(); } }*/ -} \ No newline at end of file +} diff --git a/src/test/run-pass/unique-copy-box.rs b/src/test/run-pass/unique-copy-box.rs index 95d3703a28c..c1ee7f844d3 100644 --- a/src/test/run-pass/unique-copy-box.rs +++ b/src/test/run-pass/unique-copy-box.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -fn main() { +pub fn main() { unsafe { let i = ~@1; let j = ~@2; diff --git a/src/test/run-pass/unique-create.rs b/src/test/run-pass/unique-create.rs index 0179e03d67f..989ee58a793 100644 --- a/src/test/run-pass/unique-create.rs +++ b/src/test/run-pass/unique-create.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -fn main() { +pub fn main() { ~100; } diff --git a/src/test/run-pass/unique-decl-init-copy.rs b/src/test/run-pass/unique-decl-init-copy.rs index 6271f968885..628eb7265a5 100644 --- a/src/test/run-pass/unique-decl-init-copy.rs +++ b/src/test/run-pass/unique-decl-init-copy.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -fn main() { +pub fn main() { let i = ~mut 1; // Should be a copy let j = copy i; diff --git a/src/test/run-pass/unique-decl-init.rs b/src/test/run-pass/unique-decl-init.rs index fc9e2f81127..8c6420a4df7 100644 --- a/src/test/run-pass/unique-decl-init.rs +++ b/src/test/run-pass/unique-decl-init.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -fn main() { +pub fn main() { let i = ~1; let j = i; assert *j == 1; diff --git a/src/test/run-pass/unique-decl-move-temp.rs b/src/test/run-pass/unique-decl-move-temp.rs index 8e4b9a53adc..56cbc044c01 100644 --- a/src/test/run-pass/unique-decl-move-temp.rs +++ b/src/test/run-pass/unique-decl-move-temp.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -fn main() { +pub fn main() { let i = move ~100; assert *i == 100; } \ No newline at end of file diff --git a/src/test/run-pass/unique-decl-move.rs b/src/test/run-pass/unique-decl-move.rs index 894886544e4..d41e6f99ec5 100644 --- a/src/test/run-pass/unique-decl-move.rs +++ b/src/test/run-pass/unique-decl-move.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -fn main() { +pub fn main() { let i = ~100; let j = move i; assert *j == 100; diff --git a/src/test/run-pass/unique-decl.rs b/src/test/run-pass/unique-decl.rs index 8339fddb507..2bc95754e08 100644 --- a/src/test/run-pass/unique-decl.rs +++ b/src/test/run-pass/unique-decl.rs @@ -8,10 +8,10 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -fn main() { +pub fn main() { let _: ~int; } fn f(i: ~int) -> ~int { - fail; + die!(); } diff --git a/src/test/run-pass/unique-deref.rs b/src/test/run-pass/unique-deref.rs index 3a660fad105..625a8f8982e 100644 --- a/src/test/run-pass/unique-deref.rs +++ b/src/test/run-pass/unique-deref.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -fn main() { +pub fn main() { let i = ~100; assert *i == 100; } \ No newline at end of file diff --git a/src/test/run-pass/unique-destructure.rs b/src/test/run-pass/unique-destructure.rs index 5f88a9fce03..4c4f46607d2 100644 --- a/src/test/run-pass/unique-destructure.rs +++ b/src/test/run-pass/unique-destructure.rs @@ -10,7 +10,7 @@ struct Foo { a: int, b: int } -fn main() { +pub fn main() { let ~Foo{a, b} = ~Foo{a: 100, b: 200}; assert a + b == 300; } \ No newline at end of file diff --git a/src/test/run-pass/unique-drop-complex.rs b/src/test/run-pass/unique-drop-complex.rs index 362859d8be8..aabf6c7878e 100644 --- a/src/test/run-pass/unique-drop-complex.rs +++ b/src/test/run-pass/unique-drop-complex.rs @@ -8,6 +8,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -fn main() { +pub fn main() { let x = ~~[0,0,0,0,0]; } diff --git a/src/test/run-pass/unique-fn-arg-move.rs b/src/test/run-pass/unique-fn-arg-move.rs index 72b56998e81..2246fa2270a 100644 --- a/src/test/run-pass/unique-fn-arg-move.rs +++ b/src/test/run-pass/unique-fn-arg-move.rs @@ -12,7 +12,7 @@ fn f(-i: ~int) { assert *i == 100; } -fn main() { +pub fn main() { let i = ~100; f(move i); } \ No newline at end of file diff --git a/src/test/run-pass/unique-fn-arg-mut.rs b/src/test/run-pass/unique-fn-arg-mut.rs index 6ad0cbe03c1..82462c0c11c 100644 --- a/src/test/run-pass/unique-fn-arg-mut.rs +++ b/src/test/run-pass/unique-fn-arg-mut.rs @@ -12,7 +12,7 @@ fn f(i: &mut ~int) { *i = ~200; } -fn main() { +pub fn main() { let mut i = ~100; f(&mut i); assert *i == 200; diff --git a/src/test/run-pass/unique-fn-arg.rs b/src/test/run-pass/unique-fn-arg.rs index 8a68dab6264..2dbd924a6ad 100644 --- a/src/test/run-pass/unique-fn-arg.rs +++ b/src/test/run-pass/unique-fn-arg.rs @@ -12,7 +12,7 @@ fn f(i: ~int) { assert *i == 100; } -fn main() { +pub fn main() { f(~100); let i = ~100; f(i); diff --git a/src/test/run-pass/unique-fn-ret.rs b/src/test/run-pass/unique-fn-ret.rs index 4421a658cb1..b5127571a21 100644 --- a/src/test/run-pass/unique-fn-ret.rs +++ b/src/test/run-pass/unique-fn-ret.rs @@ -12,6 +12,6 @@ fn f() -> ~int { ~100 } -fn main() { +pub fn main() { assert f() == ~100; } \ No newline at end of file diff --git a/src/test/run-pass/unique-generic-assign.rs b/src/test/run-pass/unique-generic-assign.rs index 5642a4d76e7..5d3b550c430 100644 --- a/src/test/run-pass/unique-generic-assign.rs +++ b/src/test/run-pass/unique-generic-assign.rs @@ -13,4 +13,4 @@ fn f<T: Copy>(x: ~T) { let _x2 = x; } -fn main() { } +pub fn main() { } diff --git a/src/test/run-pass/unique-in-tag.rs b/src/test/run-pass/unique-in-tag.rs index a9bc558dba8..6e454d40032 100644 --- a/src/test/run-pass/unique-in-tag.rs +++ b/src/test/run-pass/unique-in-tag.rs @@ -21,6 +21,6 @@ fn test1() { } == 10; } -fn main() { +pub fn main() { test1(); } diff --git a/src/test/run-pass/unique-in-vec-copy.rs b/src/test/run-pass/unique-in-vec-copy.rs index 6f95a2f7b6a..54ea0258c7c 100644 --- a/src/test/run-pass/unique-in-vec-copy.rs +++ b/src/test/run-pass/unique-in-vec-copy.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -fn main() { +pub fn main() { let a = ~[~mut 10]; let b = copy a; diff --git a/src/test/run-pass/unique-in-vec.rs b/src/test/run-pass/unique-in-vec.rs index 0aa4b1e58da..0a6a3a0ef5d 100644 --- a/src/test/run-pass/unique-in-vec.rs +++ b/src/test/run-pass/unique-in-vec.rs @@ -8,6 +8,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -fn main() { +pub fn main() { assert (~[~100])[0] == ~100; } diff --git a/src/test/run-pass/unique-init.rs b/src/test/run-pass/unique-init.rs index 79c90714270..0d58e2fcd2e 100644 --- a/src/test/run-pass/unique-init.rs +++ b/src/test/run-pass/unique-init.rs @@ -8,6 +8,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -fn main() { +pub fn main() { let i = ~100; } \ No newline at end of file diff --git a/src/test/run-pass/unique-kinds.rs b/src/test/run-pass/unique-kinds.rs index f3637ef7d6e..0cffa14fb70 100644 --- a/src/test/run-pass/unique-kinds.rs +++ b/src/test/run-pass/unique-kinds.rs @@ -64,7 +64,7 @@ fn noncopyable() { g(i, j); } -fn main() { +pub fn main() { sendable(); copyable(); noncopyable(); diff --git a/src/test/run-pass/unique-log.rs b/src/test/run-pass/unique-log.rs index ee5261e63ff..27a4cbf8d4b 100644 --- a/src/test/run-pass/unique-log.rs +++ b/src/test/run-pass/unique-log.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -fn main() { +pub fn main() { let i = ~100; log(error, i); } \ No newline at end of file diff --git a/src/test/run-pass/unique-move-drop.rs b/src/test/run-pass/unique-move-drop.rs index 4dadf5ee160..6aac2ac3963 100644 --- a/src/test/run-pass/unique-move-drop.rs +++ b/src/test/run-pass/unique-move-drop.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -fn main() { +pub fn main() { let i = ~100; let j = ~200; let j = move i; diff --git a/src/test/run-pass/unique-move-temp.rs b/src/test/run-pass/unique-move-temp.rs index a9e45e626be..df6ed48fa60 100644 --- a/src/test/run-pass/unique-move-temp.rs +++ b/src/test/run-pass/unique-move-temp.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -fn main() { +pub fn main() { let mut i; i = move ~100; assert *i == 100; diff --git a/src/test/run-pass/unique-move.rs b/src/test/run-pass/unique-move.rs index 4f508783846..771e8652876 100644 --- a/src/test/run-pass/unique-move.rs +++ b/src/test/run-pass/unique-move.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -fn main() { +pub fn main() { let i = ~100; let mut j; j = move i; diff --git a/src/test/run-pass/unique-mutable.rs b/src/test/run-pass/unique-mutable.rs index c83a2bcb04b..95ef19600e6 100644 --- a/src/test/run-pass/unique-mutable.rs +++ b/src/test/run-pass/unique-mutable.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -fn main() { +pub fn main() { let i = ~mut 0; *i = 1; assert *i == 1; diff --git a/src/test/run-pass/unique-object.rs b/src/test/run-pass/unique-object.rs index 6d9a1d19c87..058d212eb69 100644 --- a/src/test/run-pass/unique-object.rs +++ b/src/test/run-pass/unique-object.rs @@ -22,7 +22,7 @@ impl Bar : Foo { } } -fn main() { +pub fn main() { let x = ~Bar { x: 10 }; let y = x as ~Foo; let z = copy y; diff --git a/src/test/run-pass/unique-pat-2.rs b/src/test/run-pass/unique-pat-2.rs index 48c90d3ba63..8eb68dacbe3 100644 --- a/src/test/run-pass/unique-pat-2.rs +++ b/src/test/run-pass/unique-pat-2.rs @@ -13,7 +13,7 @@ struct Foo {a: int, b: uint} enum bar { u(~Foo), w(int), } -fn main() { +pub fn main() { assert (match u(~Foo{a: 10, b: 40u}) { u(~Foo{a: a, b: b}) => { a + (b as int) } _ => { 66 } diff --git a/src/test/run-pass/unique-pat-3.rs b/src/test/run-pass/unique-pat-3.rs index f518c270152..f4e895a0915 100644 --- a/src/test/run-pass/unique-pat-3.rs +++ b/src/test/run-pass/unique-pat-3.rs @@ -11,7 +11,7 @@ enum bar { u(~int), w(int), } -fn main() { +pub fn main() { assert match u(~10) { u(a) => { log(error, a); diff --git a/src/test/run-pass/unique-pat.rs b/src/test/run-pass/unique-pat.rs index d4ed2ab6350..82e3f6c9486 100644 --- a/src/test/run-pass/unique-pat.rs +++ b/src/test/run-pass/unique-pat.rs @@ -11,10 +11,10 @@ fn simple() { match ~true { ~true => { } - _ => { fail; } + _ => { die!(); } } } -fn main() { +pub fn main() { simple(); -} \ No newline at end of file +} diff --git a/src/test/run-pass/unique-pinned-nocopy-2.rs b/src/test/run-pass/unique-pinned-nocopy-2.rs index 7401bb56b1e..089deeb20ac 100644 --- a/src/test/run-pass/unique-pinned-nocopy-2.rs +++ b/src/test/run-pass/unique-pinned-nocopy-2.rs @@ -24,7 +24,7 @@ fn r(i: @mut int) -> r { } } -fn main() { +pub fn main() { let i = @mut 0; { let j = ~r(i); diff --git a/src/test/run-pass/unique-rec.rs b/src/test/run-pass/unique-rec.rs index 4beaa080f8b..20d30e45d08 100644 --- a/src/test/run-pass/unique-rec.rs +++ b/src/test/run-pass/unique-rec.rs @@ -10,7 +10,7 @@ struct X { x: int } -fn main() { +pub fn main() { let x = ~X {x: 1}; let bar = x; assert bar.x == 1; diff --git a/src/test/run-pass/unique-send-2.rs b/src/test/run-pass/unique-send-2.rs index fbf4e0bd757..a79c7bd6d5b 100644 --- a/src/test/run-pass/unique-send-2.rs +++ b/src/test/run-pass/unique-send-2.rs @@ -14,7 +14,7 @@ fn child(c: &SharedChan<~uint>, i: uint) { c.send(~i); } -fn main() { +pub fn main() { let (p, ch) = stream(); let ch = SharedChan(ch); let n = 100u; diff --git a/src/test/run-pass/unique-send.rs b/src/test/run-pass/unique-send.rs index 17827bb39ca..b6c5b2948a0 100644 --- a/src/test/run-pass/unique-send.rs +++ b/src/test/run-pass/unique-send.rs @@ -10,7 +10,7 @@ use core::pipes::*; -fn main() { +pub fn main() { let (p, c) = stream(); c.send(~100); let v = p.recv(); diff --git a/src/test/run-pass/unique-swap.rs b/src/test/run-pass/unique-swap.rs index 48365efe43c..d0e8c463f00 100644 --- a/src/test/run-pass/unique-swap.rs +++ b/src/test/run-pass/unique-swap.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -fn main() { +pub fn main() { let mut i = ~100; let mut j = ~200; i <-> j; diff --git a/src/test/run-pass/unit-like-struct.rs b/src/test/run-pass/unit-like-struct.rs index 8cd15bb5f6b..837bfa50b8e 100644 --- a/src/test/run-pass/unit-like-struct.rs +++ b/src/test/run-pass/unit-like-struct.rs @@ -10,7 +10,7 @@ struct Foo; -fn main() { +pub fn main() { let x: Foo = Foo; match x { Foo => { io::println("hi"); } diff --git a/src/test/run-pass/unit.rs b/src/test/run-pass/unit.rs index a6afe26d4f2..78510a57459 100644 --- a/src/test/run-pass/unit.rs +++ b/src/test/run-pass/unit.rs @@ -14,7 +14,7 @@ // -*- rust -*- fn f(u: ()) { return u; } -fn main() { +pub fn main() { let u1: () = (); let mut u2: () = f(u1); u2 = (); diff --git a/src/test/run-pass/unnamed_argument_mode.rs b/src/test/run-pass/unnamed_argument_mode.rs index 97e7582e142..e8ceeab3bf6 100644 --- a/src/test/run-pass/unnamed_argument_mode.rs +++ b/src/test/run-pass/unnamed_argument_mode.rs @@ -6,6 +6,6 @@ fn good(a: &int) { fn called(f: fn(&int)) { } -fn main() { +pub fn main() { called(good); } diff --git a/src/test/run-pass/unreachable-code-1.rs b/src/test/run-pass/unreachable-code-1.rs index 836eca6a6b6..54cd961dbf6 100644 --- a/src/test/run-pass/unreachable-code-1.rs +++ b/src/test/run-pass/unreachable-code-1.rs @@ -12,11 +12,11 @@ fn id(x: bool) -> bool { x } fn call_id() { - let c = move fail; + let c = move die!(); id(c); //~ WARNING unreachable statement } fn call_id_3() { id(return) && id(return); } -fn main() { +pub fn main() { } diff --git a/src/test/run-pass/unreachable-code.rs b/src/test/run-pass/unreachable-code.rs index 560de0d64f9..5c046ff0d16 100644 --- a/src/test/run-pass/unreachable-code.rs +++ b/src/test/run-pass/unreachable-code.rs @@ -12,7 +12,7 @@ fn id(x: bool) -> bool { x } fn call_id() { - let c = move fail; + let c = move die!(); id(c); } @@ -20,7 +20,7 @@ fn call_id_2() { id(true) && id(return); } fn call_id_3() { id(return) && id(return); } -fn log_fail() { log(error, fail); } +fn log_fail() { log(error, die!()); } fn log_ret() { log(error, return); } @@ -37,4 +37,4 @@ fn ret_guard() { } } -fn main() {} +pub fn main() {} diff --git a/src/test/run-pass/unsafe-fn-called-from-unsafe-blk.rs b/src/test/run-pass/unsafe-fn-called-from-unsafe-blk.rs index 5c6fb247497..8b1c003c66f 100644 --- a/src/test/run-pass/unsafe-fn-called-from-unsafe-blk.rs +++ b/src/test/run-pass/unsafe-fn-called-from-unsafe-blk.rs @@ -20,5 +20,5 @@ fn g() { } } -fn main() { +pub fn main() { } diff --git a/src/test/run-pass/unsafe-fn-called-from-unsafe-fn.rs b/src/test/run-pass/unsafe-fn-called-from-unsafe-fn.rs index c4a7350b9c4..1564045a435 100644 --- a/src/test/run-pass/unsafe-fn-called-from-unsafe-fn.rs +++ b/src/test/run-pass/unsafe-fn-called-from-unsafe-fn.rs @@ -18,6 +18,6 @@ unsafe fn g() { f(); } -fn main() { +pub fn main() { return; } diff --git a/src/test/run-pass/unsafe-pointer-assignability.rs b/src/test/run-pass/unsafe-pointer-assignability.rs index 7b683f22a86..6684069c38b 100644 --- a/src/test/run-pass/unsafe-pointer-assignability.rs +++ b/src/test/run-pass/unsafe-pointer-assignability.rs @@ -14,7 +14,7 @@ fn f(x: *int) { } } -fn main() { +pub fn main() { f(&3); } diff --git a/src/test/run-pass/unused-move-capture.rs b/src/test/run-pass/unused-move-capture.rs index 649506e7817..8f3a6f91d17 100644 --- a/src/test/run-pass/unused-move-capture.rs +++ b/src/test/run-pass/unused-move-capture.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -fn main() { +pub fn main() { let x = ~1; let lam_move = fn@(move x) { }; lam_move(); diff --git a/src/test/run-pass/unused-move.rs b/src/test/run-pass/unused-move.rs index 1916b23dec0..95b224fa2b7 100644 --- a/src/test/run-pass/unused-move.rs +++ b/src/test/run-pass/unused-move.rs @@ -12,7 +12,7 @@ // Issue Name: Unused move causes a crash // Abstract: zero-fill to block after drop -fn main() +pub fn main() { let y = ~1; move y; diff --git a/src/test/run-pass/unwind-box.rs b/src/test/run-pass/unwind-box.rs index 7ecd4f270bc..80bdc9adf41 100644 --- a/src/test/run-pass/unwind-box.rs +++ b/src/test/run-pass/unwind-box.rs @@ -13,9 +13,9 @@ extern mod std; fn f() { let a = @0; - fail; + die!(); } -fn main() { +pub fn main() { task::spawn_unlinked(f); } diff --git a/src/test/run-pass/unwind-resource.rs b/src/test/run-pass/unwind-resource.rs index c591c3d1086..5e885f781e2 100644 --- a/src/test/run-pass/unwind-resource.rs +++ b/src/test/run-pass/unwind-resource.rs @@ -34,10 +34,10 @@ fn complainer(c: SharedChan<bool>) -> complainer { fn f(c: SharedChan<bool>) { let _c = move complainer(c); - fail; + die!(); } -fn main() { +pub fn main() { let (p, c) = stream(); let c = SharedChan(c); task::spawn_unlinked(|| f(c.clone()) ); diff --git a/src/test/run-pass/unwind-resource2.rs b/src/test/run-pass/unwind-resource2.rs index 879053a1a0a..52a64863e72 100644 --- a/src/test/run-pass/unwind-resource2.rs +++ b/src/test/run-pass/unwind-resource2.rs @@ -27,9 +27,9 @@ fn complainer(c: @int) -> complainer { fn f() { let c = move complainer(@0); - fail; + die!(); } -fn main() { +pub fn main() { task::spawn_unlinked(f); } diff --git a/src/test/run-pass/unwind-unique.rs b/src/test/run-pass/unwind-unique.rs index c07834e6146..5edf4de3be3 100644 --- a/src/test/run-pass/unwind-unique.rs +++ b/src/test/run-pass/unwind-unique.rs @@ -13,9 +13,9 @@ extern mod std; fn f() { let a = ~0; - fail; + die!(); } -fn main() { +pub fn main() { task::spawn_unlinked(f); } diff --git a/src/test/run-pass/use-crate-name-alias.rs b/src/test/run-pass/use-crate-name-alias.rs index dc01a62efde..ea9dcc2f562 100644 --- a/src/test/run-pass/use-crate-name-alias.rs +++ b/src/test/run-pass/use-crate-name-alias.rs @@ -11,4 +11,4 @@ // Issue #1706 extern mod stdlib(name="std"); -fn main() {} +pub fn main() {} diff --git a/src/test/run-pass/use-import-export.rs b/src/test/run-pass/use-import-export.rs index 70c21c6ac4f..ec8033ff3b0 100644 --- a/src/test/run-pass/use-import-export.rs +++ b/src/test/run-pass/use-import-export.rs @@ -18,4 +18,4 @@ mod bar { pub fn y() -> int { return 1; } } -fn main() { foo::x(); bar::y(); } +pub fn main() { foo::x(); bar::y(); } diff --git a/src/test/run-pass/use-mod.rs b/src/test/run-pass/use-mod.rs index bd273e64b1a..1b1402e0a0e 100644 --- a/src/test/run-pass/use-mod.rs +++ b/src/test/run-pass/use-mod.rs @@ -18,7 +18,7 @@ mod a { } } -fn main() { +pub fn main() { b::f(); } diff --git a/src/test/run-pass/use-trait-before-def.rs b/src/test/run-pass/use-trait-before-def.rs index 1f268c5c4c1..30646c4a356 100644 --- a/src/test/run-pass/use-trait-before-def.rs +++ b/src/test/run-pass/use-trait-before-def.rs @@ -12,4 +12,4 @@ impl int: foo { fn foo() -> int { 10 } } trait foo { fn foo() -> int; } -fn main() {} \ No newline at end of file +pub fn main() {} \ No newline at end of file diff --git a/src/test/run-pass/use-uninit-alt.rs b/src/test/run-pass/use-uninit-alt.rs index 95c36df48c5..17600f5f514 100644 --- a/src/test/run-pass/use-uninit-alt.rs +++ b/src/test/run-pass/use-uninit-alt.rs @@ -18,4 +18,4 @@ fn foo<T>(o: myoption<T>) -> int { enum myoption<T> { none, some(T), } -fn main() { log(debug, 5); } +pub fn main() { log(debug, 5); } diff --git a/src/test/run-pass/use-uninit-alt2.rs b/src/test/run-pass/use-uninit-alt2.rs index 31fc055d8fe..af0c796ca27 100644 --- a/src/test/run-pass/use-uninit-alt2.rs +++ b/src/test/run-pass/use-uninit-alt2.rs @@ -12,10 +12,10 @@ fn foo<T>(o: myoption<T>) -> int { let mut x: int; - match o { none::<T> => { fail; } some::<T>(t) => { x = 5; } } + match o { none::<T> => { die!(); } some::<T>(t) => { x = 5; } } return x; } enum myoption<T> { none, some(T), } -fn main() { log(debug, 5); } +pub fn main() { log(debug, 5); } diff --git a/src/test/run-pass/use.rs b/src/test/run-pass/use.rs index 5f57e1c1475..2a24bfe72d2 100644 --- a/src/test/run-pass/use.rs +++ b/src/test/run-pass/use.rs @@ -23,4 +23,4 @@ mod baz { pub use x = core::str; } -fn main() { } +pub fn main() { } diff --git a/src/test/run-pass/utf8.rs b/src/test/run-pass/utf8.rs index c9698dacd83..0a6e1471671 100644 --- a/src/test/run-pass/utf8.rs +++ b/src/test/run-pass/utf8.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -fn main() { +pub fn main() { let yen: char = '¥'; // 0xa5 let c_cedilla: char = 'ç'; // 0xe7 let thorn: char = 'þ'; // 0xfe diff --git a/src/test/run-pass/utf8_chars.rs b/src/test/run-pass/utf8_chars.rs index 6922bcf7505..147c81a263f 100644 --- a/src/test/run-pass/utf8_chars.rs +++ b/src/test/run-pass/utf8_chars.rs @@ -10,7 +10,7 @@ extern mod std; -fn main() { +pub fn main() { // Chars of 1, 2, 3, and 4 bytes let chs: ~[char] = ~['e', 'é', '€', 0x10000 as char]; let s: ~str = str::from_chars(chs); diff --git a/src/test/run-pass/utf8_idents.rs b/src/test/run-pass/utf8_idents.rs index bebe40824cd..7cd04d5f7b4 100644 --- a/src/test/run-pass/utf8_idents.rs +++ b/src/test/run-pass/utf8_idents.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -fn main() { +pub fn main() { let ε = 0.00001; let Π = 3.14; let लंच = Π * Π + 1.54; diff --git a/src/test/run-pass/variant-attributes.rs b/src/test/run-pass/variant-attributes.rs index 86df25d5496..54a1dd0143e 100644 --- a/src/test/run-pass/variant-attributes.rs +++ b/src/test/run-pass/variant-attributes.rs @@ -36,4 +36,4 @@ enum crew_of_enterprise_d { fn boldly_go(_crew_member: crew_of_enterprise_d, _where: ~str) { } -fn main() { boldly_go(worf, ~"where no one has gone before"); } +pub fn main() { boldly_go(worf, ~"where no one has gone before"); } diff --git a/src/test/run-pass/variant-structs-trivial.rs b/src/test/run-pass/variant-structs-trivial.rs index 6001c5a3e17..e078fa1485d 100644 --- a/src/test/run-pass/variant-structs-trivial.rs +++ b/src/test/run-pass/variant-structs-trivial.rs @@ -13,4 +13,4 @@ enum Foo { Baz { y: int } } -fn main() { } +pub fn main() { } diff --git a/src/test/run-pass/vec-concat.rs b/src/test/run-pass/vec-concat.rs index f29bce204e4..82a18a8ebfc 100644 --- a/src/test/run-pass/vec-concat.rs +++ b/src/test/run-pass/vec-concat.rs @@ -9,7 +9,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -fn main() { +pub fn main() { let a: ~[int] = ~[1, 2, 3, 4, 5]; let b: ~[int] = ~[6, 7, 8, 9, 0]; let v: ~[int] = a + b; diff --git a/src/test/run-pass/vec-drop.rs b/src/test/run-pass/vec-drop.rs index f7d7c1474f7..16cca5cd6cf 100644 --- a/src/test/run-pass/vec-drop.rs +++ b/src/test/run-pass/vec-drop.rs @@ -12,7 +12,7 @@ struct Pair { x: int, y: int } -fn main() { +pub fn main() { // This just tests whether the vec leaks its members. let pvec: ~[@Pair] = diff --git a/src/test/run-pass/vec-fixed-length.rs b/src/test/run-pass/vec-fixed-length.rs index 918d6de9dcb..5d0620be28c 100644 --- a/src/test/run-pass/vec-fixed-length.rs +++ b/src/test/run-pass/vec-fixed-length.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -fn main() { +pub fn main() { let x: [int*4] = [1, 2, 3, 4]; io::println(fmt!("%d", x[0])); } diff --git a/src/test/run-pass/vec-growth.rs b/src/test/run-pass/vec-growth.rs index 0689338e943..ebfb3831045 100644 --- a/src/test/run-pass/vec-growth.rs +++ b/src/test/run-pass/vec-growth.rs @@ -10,7 +10,7 @@ -fn main() { +pub fn main() { let mut v = ~[1]; v += ~[2]; v += ~[3]; diff --git a/src/test/run-pass/vec-ivec-deadlock.rs b/src/test/run-pass/vec-ivec-deadlock.rs index 6dfacfa55ae..505b57ec7bb 100644 --- a/src/test/run-pass/vec-ivec-deadlock.rs +++ b/src/test/run-pass/vec-ivec-deadlock.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -fn main() { +pub fn main() { let a = ~[1, 2, 3, 4, 5]; let mut b = ~[copy a, copy a]; b = b + b; // FIXME(#3387)---can't write b += b diff --git a/src/test/run-pass/vec-late-init.rs b/src/test/run-pass/vec-late-init.rs index 9912c0e88db..918f7e70f4e 100644 --- a/src/test/run-pass/vec-late-init.rs +++ b/src/test/run-pass/vec-late-init.rs @@ -10,7 +10,7 @@ -fn main() { +pub fn main() { let mut later: ~[int]; if true { later = ~[1]; } else { later = ~[2]; } log(debug, later[0]); diff --git a/src/test/run-pass/vec-matching-autoslice.rs b/src/test/run-pass/vec-matching-autoslice.rs index 298253b8825..f4eedb288b6 100644 --- a/src/test/run-pass/vec-matching-autoslice.rs +++ b/src/test/run-pass/vec-matching-autoslice.rs @@ -1,4 +1,4 @@ -fn main() { +pub fn main() { let x = @[1, 2, 3]; match x { [2, .._] => ::core::util::unreachable(), diff --git a/src/test/run-pass/vec-matching-legal-tail-element-borrow.rs b/src/test/run-pass/vec-matching-legal-tail-element-borrow.rs index 0d093a1b4b0..561d5555f12 100644 --- a/src/test/run-pass/vec-matching-legal-tail-element-borrow.rs +++ b/src/test/run-pass/vec-matching-legal-tail-element-borrow.rs @@ -1,4 +1,4 @@ -fn main() { +pub fn main() { let x = &[1, 2, 3, 4, 5]; if !x.is_empty() { let el = match x { diff --git a/src/test/run-pass/vec-matching.rs b/src/test/run-pass/vec-matching.rs index 687788d8ce8..1c7aec7682f 100644 --- a/src/test/run-pass/vec-matching.rs +++ b/src/test/run-pass/vec-matching.rs @@ -10,7 +10,7 @@ fn foldl<T, U: Copy>( } } -fn main() { +pub fn main() { let x = [1, 2, 3, 4, 5]; match x { [a, b, c, d, e, f] => { diff --git a/src/test/run-pass/vec-push.rs b/src/test/run-pass/vec-push.rs index 13869b912f1..50e76db0314 100644 --- a/src/test/run-pass/vec-push.rs +++ b/src/test/run-pass/vec-push.rs @@ -8,4 +8,4 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -fn main() { let mut v = ~[1, 2, 3]; v.push(1); } +pub fn main() { let mut v = ~[1, 2, 3]; v.push(1); } diff --git a/src/test/run-pass/vec-self-append.rs b/src/test/run-pass/vec-self-append.rs index 9536e30bfbf..44031f5deaa 100644 --- a/src/test/run-pass/vec-self-append.rs +++ b/src/test/run-pass/vec-self-append.rs @@ -55,4 +55,4 @@ fn test_loop() { } } -fn main() { test_heap_to_heap(); test_stack_to_heap(); test_loop(); } +pub fn main() { test_heap_to_heap(); test_stack_to_heap(); test_loop(); } diff --git a/src/test/run-pass/vec-slice-drop.rs b/src/test/run-pass/vec-slice-drop.rs index d3c6ed57c14..a73b12bef94 100644 --- a/src/test/run-pass/vec-slice-drop.rs +++ b/src/test/run-pass/vec-slice-drop.rs @@ -25,7 +25,7 @@ fn foo(x: @mut int) -> foo { } } -fn main() { +pub fn main() { let x = @mut 0; { let l = &[foo(x)]; diff --git a/src/test/run-pass/vec-slice.rs b/src/test/run-pass/vec-slice.rs index 4901157c4fa..e77f8c72033 100644 --- a/src/test/run-pass/vec-slice.rs +++ b/src/test/run-pass/vec-slice.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -fn main() { +pub fn main() { let v = ~[1,2,3,4,5]; let v2 = vec::slice(v, 1, 3); assert (v2[0] == 2); diff --git a/src/test/run-pass/vec-tail-matching.rs b/src/test/run-pass/vec-tail-matching.rs index 8a50d7b1643..0dc66c091ba 100644 --- a/src/test/run-pass/vec-tail-matching.rs +++ b/src/test/run-pass/vec-tail-matching.rs @@ -2,7 +2,7 @@ struct Foo { string: ~str } -fn main() { +pub fn main() { let x = [ Foo { string: ~"foo" }, Foo { string: ~"bar" }, diff --git a/src/test/run-pass/vec-trailing-comma.rs b/src/test/run-pass/vec-trailing-comma.rs index 8fc7adc5445..d433aa5534c 100644 --- a/src/test/run-pass/vec-trailing-comma.rs +++ b/src/test/run-pass/vec-trailing-comma.rs @@ -10,7 +10,7 @@ // Issue #2482. -fn main() { +pub fn main() { let v1: ~[int] = ~[10, 20, 30,]; let v2: ~[int] = ~[10, 20, 30]; assert (v1[2] == v2[2]); diff --git a/src/test/run-pass/vec.rs b/src/test/run-pass/vec.rs index a27b0240c6a..4a1be51e55e 100644 --- a/src/test/run-pass/vec.rs +++ b/src/test/run-pass/vec.rs @@ -12,7 +12,7 @@ // -*- rust -*- -fn main() { +pub fn main() { let v: ~[int] = ~[10, 20]; assert (v[0] == 10); assert (v[1] == 20); diff --git a/src/test/run-pass/vector-no-ann-2.rs b/src/test/run-pass/vector-no-ann-2.rs index 5d5db1e7573..f73b75b2f4c 100644 --- a/src/test/run-pass/vector-no-ann-2.rs +++ b/src/test/run-pass/vector-no-ann-2.rs @@ -8,4 +8,4 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -fn main() { let quux: @~[uint] = @~[]; } +pub fn main() { let quux: @~[uint] = @~[]; } diff --git a/src/test/run-pass/warn-ctypes-inhibit.rs b/src/test/run-pass/warn-ctypes-inhibit.rs index 91617fb1c6d..2b5ac075cb5 100644 --- a/src/test/run-pass/warn-ctypes-inhibit.rs +++ b/src/test/run-pass/warn-ctypes-inhibit.rs @@ -17,5 +17,5 @@ extern mod libc { pub fn malloc(size: int) -> *u8; } -fn main() { +pub fn main() { } diff --git a/src/test/run-pass/weird-exprs.rs b/src/test/run-pass/weird-exprs.rs index d65cb0c3e1b..5ade8825289 100644 --- a/src/test/run-pass/weird-exprs.rs +++ b/src/test/run-pass/weird-exprs.rs @@ -69,13 +69,13 @@ fn canttouchthis() -> uint { fn angrydome() { loop { if break { } } let mut i = 0; - loop { i += 1; if i == 1 { match (loop) { 1 => { }, _ => fail ~"wat" } } + loop { i += 1; if i == 1 { match (loop) { 1 => { }, _ => die!(~"wat") } } break; } } fn evil_lincoln() { let evil = move debug!("lincoln"); } -fn main() { +pub fn main() { strange(); funny(); what(); diff --git a/src/test/run-pass/while-cont.rs b/src/test/run-pass/while-cont.rs index e1d880bfa0e..c13c2d1e7d7 100644 --- a/src/test/run-pass/while-cont.rs +++ b/src/test/run-pass/while-cont.rs @@ -9,7 +9,7 @@ // except according to those terms. // Issue #825: Should recheck the loop contition after continuing -fn main() { +pub fn main() { let mut i = 1; while i > 0 { assert (i > 0); diff --git a/src/test/run-pass/while-flow-graph.rs b/src/test/run-pass/while-flow-graph.rs index 67c2d813a5d..2e9fb981be4 100644 --- a/src/test/run-pass/while-flow-graph.rs +++ b/src/test/run-pass/while-flow-graph.rs @@ -10,4 +10,4 @@ -fn main() { let x: int = 10; while x == 10 && x == 11 { let y = 0xf00; } } +pub fn main() { let x: int = 10; while x == 10 && x == 11 { let y = 0xf00; } } diff --git a/src/test/run-pass/while-loop-constraints-2.rs b/src/test/run-pass/while-loop-constraints-2.rs index 0fdd91f4fa4..3d44cf2669b 100644 --- a/src/test/run-pass/while-loop-constraints-2.rs +++ b/src/test/run-pass/while-loop-constraints-2.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -fn main() { +pub fn main() { let mut y: int = 42; let mut z: int = 42; diff --git a/src/test/run-pass/while-prelude-drop.rs b/src/test/run-pass/while-prelude-drop.rs index cf196278746..da3f28f5b7b 100644 --- a/src/test/run-pass/while-prelude-drop.rs +++ b/src/test/run-pass/while-prelude-drop.rs @@ -21,7 +21,7 @@ fn make(i: int) -> t { return b(s); } -fn main() { +pub fn main() { let mut i = 0; diff --git a/src/test/run-pass/while-with-break.rs b/src/test/run-pass/while-with-break.rs index f0cfb7d6058..8bbea140c60 100644 --- a/src/test/run-pass/while-with-break.rs +++ b/src/test/run-pass/while-with-break.rs @@ -2,7 +2,7 @@ // -*- rust -*- -fn main() { +pub fn main() { let mut i: int = 90; while i < 100 { log(debug, i); diff --git a/src/test/run-pass/while.rs b/src/test/run-pass/while.rs index 27d2bca0056..64de4963b8a 100644 --- a/src/test/run-pass/while.rs +++ b/src/test/run-pass/while.rs @@ -10,7 +10,7 @@ -fn main() { +pub fn main() { let mut x: int = 10; let mut y: int = 0; while y < x { log(debug, y); debug!("hello"); y = y + 1; } diff --git a/src/test/run-pass/writealias.rs b/src/test/run-pass/writealias.rs index 6d93f837aff..2aa3bc30d07 100644 --- a/src/test/run-pass/writealias.rs +++ b/src/test/run-pass/writealias.rs @@ -16,7 +16,7 @@ struct Point {x: int, y: int, mut z: int} fn f(p: &mut Point) { p.z = 13; } -fn main() { +pub fn main() { let mut x: Point = Point {x: 10, y: 11, mut z: 12}; f(&mut x); assert (x.z == 13); diff --git a/src/test/run-pass/x86stdcall.rs b/src/test/run-pass/x86stdcall.rs index 3d42b680813..fb1ec6cd891 100644 --- a/src/test/run-pass/x86stdcall.rs +++ b/src/test/run-pass/x86stdcall.rs @@ -19,7 +19,7 @@ extern "stdcall" mod kernel32 { #[cfg(target_os = "win32")] -fn main() { +pub fn main() { unsafe { let expected = 1234u; kernel32::SetLastError(expected); @@ -32,4 +32,4 @@ fn main() { #[cfg(target_os = "macos")] #[cfg(target_os = "linux")] #[cfg(target_os = "freebsd")] -fn main() { } +pub fn main() { } diff --git a/src/test/run-pass/x86stdcall2.rs b/src/test/run-pass/x86stdcall2.rs index 88d5d659169..ad1dbd551b1 100644 --- a/src/test/run-pass/x86stdcall2.rs +++ b/src/test/run-pass/x86stdcall2.rs @@ -25,7 +25,7 @@ extern mod kernel32 { #[cfg(target_os = "win32")] -fn main() { +pub fn main() { let heap = unsafe { kernel32::GetProcessHeap() }; let mem = unsafe { kernel32::HeapAlloc(heap, 0u32, 100u32) }; assert mem != 0u; @@ -36,4 +36,4 @@ fn main() { #[cfg(target_os = "macos")] #[cfg(target_os = "linux")] #[cfg(target_os = "freebsd")] -fn main() { } +pub fn main() { } diff --git a/src/test/run-pass/yield.rs b/src/test/run-pass/yield.rs index 2d73e672131..d5c58bbd0fa 100644 --- a/src/test/run-pass/yield.rs +++ b/src/test/run-pass/yield.rs @@ -9,7 +9,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -fn main() { +pub fn main() { let mut result = None; task::task().future_result(|+r| { result = Some(move r); }).spawn(child); error!("1"); diff --git a/src/test/run-pass/yield1.rs b/src/test/run-pass/yield1.rs index 34e2f7b3c5d..1f617062434 100644 --- a/src/test/run-pass/yield1.rs +++ b/src/test/run-pass/yield1.rs @@ -9,7 +9,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -fn main() { +pub fn main() { let mut result = None; task::task().future_result(|+r| { result = Some(move r); }).spawn(child); error!("1"); diff --git a/src/test/run-pass/yield2.rs b/src/test/run-pass/yield2.rs index 85a8befd3ba..eaaa226c286 100644 --- a/src/test/run-pass/yield2.rs +++ b/src/test/run-pass/yield2.rs @@ -9,7 +9,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -fn main() { +pub fn main() { let mut i: int = 0; while i < 100 { i = i + 1; log(error, i); task::yield(); } } diff --git a/src/test/run-pass/zip-same-length.rs b/src/test/run-pass/zip-same-length.rs index 62b6ebf20ae..167448cfe25 100644 --- a/src/test/run-pass/zip-same-length.rs +++ b/src/test/run-pass/zip-same-length.rs @@ -28,7 +28,7 @@ fn enum_uints(start: uint, end: uint) -> ~[uint] { return r; } -fn main() { +pub fn main() { let a = 'a' as u8, j = 'j' as u8, k = 1u, l = 10u; let chars = enum_chars(a, j); let ints = enum_uints(k, l); |
