diff --git a/doc/rust.md b/doc/rust.md index 80f8b8f49c1a..b45a6a3dd450 100644 --- a/doc/rust.md +++ b/doc/rust.md @@ -1360,7 +1360,7 @@ Functions within foreign modules are declared in the same way as other Rust func with the exception that they may not have a body and are instead terminated by a semicolon. ~~~ -# use libc::{c_char, FILE}; +# use core::libc::{c_char, FILE}; # #[nolink] extern mod c { diff --git a/doc/tutorial-ffi.md b/doc/tutorial-ffi.md index b7659376ed65..add3718ea7fb 100644 --- a/doc/tutorial-ffi.md +++ b/doc/tutorial-ffi.md @@ -14,7 +14,7 @@ should compile and run without any extra effort. ~~~~ {.xfail-test} extern mod std; -use libc::c_uint; +use core::libc::c_uint; extern mod crypto { fn SHA1(src: *u8, sz: c_uint, out: *u8) -> *u8; @@ -217,7 +217,7 @@ microsecond-resolution timer. ~~~~ extern mod std; -use libc::c_ulonglong; +use core::libc::c_ulonglong; struct timeval { tv_sec: c_ulonglong, diff --git a/doc/tutorial-tasks.md b/doc/tutorial-tasks.md index 22d0ff8bf78a..52f63be984a3 100644 --- a/doc/tutorial-tasks.md +++ b/doc/tutorial-tasks.md @@ -80,8 +80,8 @@ calling the `spawn` function with a closure argument. `spawn` executes the closure in the new task. ~~~~ -# use io::println; -use task::spawn; +# use core::io::println; +use core::task::spawn; // Print something profound in a different task using a named function fn print_message() { println("I am running in a different task!"); } @@ -110,8 +110,8 @@ execution. Like any closure, the function passed to `spawn` may capture an environment that it carries across tasks. ~~~ -# use io::println; -# use task::spawn; +# use core::io::println; +# use core::task::spawn; # fn generate_task_number() -> int { 0 } // Generate some state locally let child_task_number = generate_task_number(); @@ -127,8 +127,8 @@ in parallel. Thus, on a multicore machine, running the following code should interleave the output in vaguely random order. ~~~ -# use io::print; -# use task::spawn; +# use core::io::print; +# use core::task::spawn; for int::range(0, 20) |child_task_number| { do spawn { @@ -156,8 +156,8 @@ endpoint. Consider the following example of calculating two results concurrently: ~~~~ -use task::spawn; -use comm::{stream, Port, Chan}; +use core::task::spawn; +use core::comm::{stream, Port, Chan}; let (port, chan): (Port, Chan) = stream(); @@ -178,7 +178,7 @@ stream for sending and receiving integers (the left-hand side of the `let`, a tuple into its component parts). ~~~~ -# use comm::{stream, Chan, Port}; +# use core::comm::{stream, Chan, Port}; let (port, chan): (Port, Chan) = stream(); ~~~~ @@ -187,9 +187,8 @@ which will wait to receive the data on the port. The next statement spawns the child task. ~~~~ -# use task::{spawn}; -# use task::spawn; -# use comm::{stream, Port, Chan}; +# use core::task::spawn; +# use core::comm::{stream, Port, Chan}; # fn some_expensive_computation() -> int { 42 } # let (port, chan) = stream(); do spawn || { @@ -209,7 +208,7 @@ computation, then waits for the child's result to arrive on the port: ~~~~ -# use comm::{stream, Port, Chan}; +# use core::comm::{stream, Port, Chan}; # fn some_other_expensive_computation() {} # let (port, chan) = stream::(); # chan.send(0); @@ -224,8 +223,8 @@ example needed to compute multiple results across a number of tasks? The following program is ill-typed: ~~~ {.xfail-test} -# use task::{spawn}; -# use comm::{stream, Port, Chan}; +# use core::task::{spawn}; +# use core::comm::{stream, Port, Chan}; # fn some_expensive_computation() -> int { 42 } let (port, chan) = stream(); @@ -244,8 +243,8 @@ Instead we can use a `SharedChan`, a type that allows a single `Chan` to be shared by multiple senders. ~~~ -# use task::spawn; -use comm::{stream, SharedChan}; +# use core::task::spawn; +use core::comm::{stream, SharedChan}; let (port, chan) = stream(); let chan = SharedChan(chan); @@ -277,8 +276,8 @@ illustrate the point. For reference, written with multiple streams, it might look like the example below. ~~~ -# use task::spawn; -# use comm::{stream, Port, Chan}; +# use core::task::spawn; +# use core::comm::{stream, Port, Chan}; // Create a vector of ports, one for each child task let ports = do vec::from_fn(3) |init_val| { @@ -309,7 +308,7 @@ All tasks are, by default, _linked_ to each other. That means that the fates of all tasks are intertwined: if one fails, so do all the others. ~~~ -# use task::spawn; +# use core::task::spawn; # fn do_some_work() { loop { task::yield() } } # do task::try { // Create a child task that fails @@ -393,8 +392,8 @@ internally, with additional logic to wait for the child task to finish before returning. Hence: ~~~ -# use comm::{stream, Chan, Port}; -# use task::{spawn, try}; +# use core::comm::{stream, Chan, Port}; +# use core::task::{spawn, try}; # fn sleep_forever() { loop { task::yield() } } # do task::try { let (receiver, sender): (Port, Chan) = stream(); @@ -489,8 +488,8 @@ response itself is simply the stringified version of the received value, Here is the code for the parent task: ~~~~ +# use core::task::spawn; # use std::comm::DuplexStream; -# use task::spawn; # fn stringifier(channel: &DuplexStream<~str, uint>) { # let mut value: uint; # loop { diff --git a/doc/tutorial.md b/doc/tutorial.md index d31fbbb0c07a..b425c595f82e 100644 --- a/doc/tutorial.md +++ b/doc/tutorial.md @@ -1313,7 +1313,7 @@ and [`core::str`]. Here are some examples. [`core::str`]: core/str.html ~~~ -# use io::println; +# use core::io::println; # enum Crayon { # Almond, AntiqueBrass, Apricot, # Aquamarine, Asparagus, AtomicTangerine, @@ -1368,7 +1368,7 @@ Rust also supports _closures_, functions that can access variables in the enclosing scope. ~~~~ -# use println = io::println; +# use println = core::io::println; fn call_closure_with_ten(b: fn(int)) { b(10); } let captured_var = 20; @@ -1525,7 +1525,7 @@ words, it is a function that takes an owned closure that takes no arguments. ~~~~ -use task::spawn; +use core::task::spawn; do spawn() || { debug!("I'm a task, whatever"); @@ -1537,7 +1537,7 @@ lists back to back. Since that is so unsightly, empty argument lists may be omitted from `do` expressions. ~~~~ -# use task::spawn; +# use core::task::spawn; do spawn { debug!("Kablam!"); } @@ -1568,8 +1568,8 @@ fn each(v: &[int], op: fn(v: &int) -> bool) { And using this function to iterate over a vector: ~~~~ -# use each = vec::each; -# use println = io::println; +# use each = core::vec::each; +# use println = core::io::println; each([2, 4, 8, 5, 16], |n| { if *n % 2 != 0 { println("found odd number!"); @@ -1585,8 +1585,8 @@ out of the loop, you just write `break`. To skip ahead to the next iteration, write `loop`. ~~~~ -# use each = vec::each; -# use println = io::println; +# use each = core::vec::each; +# use println = core::io::println; for each([2, 4, 8, 5, 16]) |n| { if *n % 2 != 0 { println("found odd number!"); @@ -1601,7 +1601,7 @@ normally allowed in closures, in a block that appears as the body of a the enclosing function, not just the loop body. ~~~~ -# use each = vec::each; +# use each = core::vec::each; fn contains(v: &[int], elt: int) -> bool { for each(v) |x| { if (*x == elt) { return true; } @@ -1616,7 +1616,7 @@ In these situations it can be convenient to lean on Rust's argument patterns to bind `x` to the actual value, not the pointer. ~~~~ -# use each = vec::each; +# use each = core::vec::each; # fn contains(v: &[int], elt: int) -> bool { for each(v) |&x| { if (x == elt) { return true; } @@ -1758,8 +1758,8 @@ Constructors are one common application for static methods, as in `new` above. To call a static method, you have to prefix it with the type name and a double colon: ~~~~ -# use float::consts::pi; -# use float::sqrt; +# use core::float::consts::pi; +# use core::float::sqrt; struct Circle { radius: float } impl Circle { static fn new(area: float) -> Circle { Circle { radius: sqrt(area / pi) } } @@ -2030,8 +2030,8 @@ The compiler will use type inference to decide which implementation to call. ~~~~ trait Shape { static fn new(area: float) -> Self; } -# use float::consts::pi; -# use float::sqrt; +# use core::float::consts::pi; +# use core::float::sqrt; struct Circle { radius: float } struct Square { length: float } @@ -2189,8 +2189,8 @@ Now, we can implement `Circle` on a type only if we also implement `Shape`. # trait Shape { fn area(&self) -> float; } # trait Circle : Shape { fn radius(&self) -> float; } # struct Point { x: float, y: float } -# use float::consts::pi; -# use float::sqrt; +# use core::float::consts::pi; +# use core::float::sqrt; # fn square(x: float) -> float { x * x } struct CircleStruct { center: Point, radius: float } impl Circle for CircleStruct { @@ -2224,8 +2224,8 @@ Likewise, supertrait methods may also be called on trait objects. ~~~ {.xfail-test} # trait Shape { fn area(&self) -> float; } # trait Circle : Shape { fn radius(&self) -> float; } -# use float::consts::pi; -# use float::sqrt; +# use core::float::consts::pi; +# use core::float::sqrt; # struct Point { x: float, y: float } # struct CircleStruct { center: Point, radius: float } # impl Circle for CircleStruct { fn radius(&self) -> float { sqrt(self.area() / pi) } } @@ -2291,13 +2291,12 @@ be private. But this encapsulation is at the module level, not the struct level. Note that fields and methods are _public_ by default. ~~~ -mod farm { -# use farm; +pub mod farm { # pub type Chicken = int; # type Cow = int; # enum Human = int; # impl Human { fn rest(&self) { } } -# pub fn make_me_a_farm() -> farm::Farm { farm::Farm { chickens: ~[], cows: ~[], farmer: Human(0) } } +# pub fn make_me_a_farm() -> Farm { Farm { chickens: ~[], cows: ~[], farmer: Human(0) } } pub struct Farm { priv chickens: ~[Chicken], priv cows: ~[Cow], diff --git a/src/compiletest/compiletest.rc b/src/compiletest/compiletest.rc index 6748edb9dbdf..bccaf0ddf601 100644 --- a/src/compiletest/compiletest.rc +++ b/src/compiletest/compiletest.rc @@ -22,18 +22,18 @@ extern mod std(vers = "0.6"); use core::*; -mod procsrv; -mod util; -mod header; -mod runtest; -mod common; -mod errors; +pub mod procsrv; +pub mod util; +pub mod header; +pub mod runtest; +pub mod common; +pub mod errors; use std::getopts; use std::test; use core::{result, either}; -use result::{Ok, Err}; +use core::result::{Ok, Err}; use common::config; use common::mode_run_pass; @@ -223,7 +223,7 @@ pub fn make_test_name(config: config, testfile: &Path) -> test::TestName { pub fn make_test_closure(config: config, testfile: &Path) -> test::TestFn { let testfile = testfile.to_str(); - test::DynTestFn(fn~() { runtest::run(config, testfile) }) + test::DynTestFn(|| runtest::run(config, testfile)) } // Local Variables: diff --git a/src/compiletest/errors.rs b/src/compiletest/errors.rs index d41a4b7360c7..39b70299ba5b 100644 --- a/src/compiletest/errors.rs +++ b/src/compiletest/errors.rs @@ -11,9 +11,10 @@ use core::prelude::*; use common::config; -use io; -use io::ReaderUtil; -use str; + +use core::io; +use core::io::ReaderUtil; +use core::str; pub struct ExpectedError { line: uint, kind: ~str, msg: ~str } diff --git a/src/compiletest/header.rs b/src/compiletest/header.rs index 6db55853f9ce..64d1aae5ff5e 100644 --- a/src/compiletest/header.rs +++ b/src/compiletest/header.rs @@ -12,10 +12,11 @@ use core::prelude::*; use common; use common::config; -use io; -use io::ReaderUtil; -use os; -use str; + +use core::io::ReaderUtil; +use core::io; +use core::os; +use core::str; pub struct TestProps { // Lines that should be expected, in order, on standard out diff --git a/src/compiletest/procsrv.rs b/src/compiletest/procsrv.rs index 6c8bd7ea4426..8d8cdb3c719c 100644 --- a/src/compiletest/procsrv.rs +++ b/src/compiletest/procsrv.rs @@ -10,17 +10,17 @@ use core::prelude::*; -use io; -use io::{ReaderUtil, WriterUtil}; -use libc; -use libc::{c_int, pid_t}; -use os; -use run; -use run::spawn_process; -use pipes; -use str; -use task; -use vec; +use core::io::{ReaderUtil, WriterUtil}; +use core::io; +use core::libc::{c_int, pid_t}; +use core::libc; +use core::os; +use core::pipes; +use core::run::spawn_process; +use core::run; +use core::str; +use core::task; +use core::vec; #[cfg(target_os = "win32")] fn target_env(lib_path: ~str, prog: ~str) -> ~[(~str,~str)] { diff --git a/src/compiletest/runtest.rs b/src/compiletest/runtest.rs index 3213a11cbb51..b5def15fc509 100644 --- a/src/compiletest/runtest.rs +++ b/src/compiletest/runtest.rs @@ -10,13 +10,6 @@ use core::prelude::*; -use io; -use io::WriterUtil; -use os; -use str; -use uint; -use vec; - use common; use common::mode_run_pass; use common::mode_run_fail; @@ -31,6 +24,13 @@ use procsrv; use util; use util::logv; +use core::io::WriterUtil; +use core::io; +use core::os; +use core::str; +use core::uint; +use core::vec; + pub fn run(config: config, testfile: ~str) { if config.verbose { // We're going to be dumping a lot of info. Start on a new line. diff --git a/src/compiletest/util.rs b/src/compiletest/util.rs index e4028549f28a..ad60e532f3cb 100644 --- a/src/compiletest/util.rs +++ b/src/compiletest/util.rs @@ -10,13 +10,13 @@ use core::prelude::*; -use io; -use os; -use os::getenv; - use common; use common::config; +use core::io; +use core::os::getenv; +use core::os; + pub fn make_new_path(path: ~str) -> ~str { // Windows just uses PATH as the library search path, so we have to diff --git a/src/etc/combine-tests.py b/src/etc/combine-tests.py index 8e1a916e2f19..93989f8e4a90 100755 --- a/src/etc/combine-tests.py +++ b/src/etc/combine-tests.py @@ -52,7 +52,7 @@ d.write("// AUTO-GENERATED FILE: DO NOT EDIT\n") d.write("extern mod std;\n") d.write("extern mod run_pass_stage2;\n") d.write("use run_pass_stage2::*;\n") -d.write("use io::WriterUtil;\n"); +d.write("use core::io::WriterUtil;\n"); d.write("fn main() {\n"); d.write(" let out = io::stdout();\n"); i = 0 diff --git a/src/libcore/core.rc b/src/libcore/core.rc index c8d2da28255f..190421955734 100644 --- a/src/libcore/core.rc +++ b/src/libcore/core.rc @@ -235,10 +235,10 @@ pub mod private { /* For internal use, not exported */ -mod unicode; +pub mod unicode; #[path = "num/cmath.rs"] -mod cmath; -mod stackwalk; +pub mod cmath; +pub mod stackwalk; // A curious inner-module that's not exported that contains the binding diff --git a/src/libcore/io.rs b/src/libcore/io.rs index fdb622f65393..4f9b8ccf7576 100644 --- a/src/libcore/io.rs +++ b/src/libcore/io.rs @@ -1139,7 +1139,7 @@ pub mod fsync { pub struct Arg { val: t, opt_level: Option, - fsync_fn: fn@(f: t, Level) -> int, + fsync_fn: @fn(f: t, Level) -> int, } // fsync file after executing blk @@ -1150,9 +1150,9 @@ pub mod fsync { unsafe { blk(Res(Arg { val: file.f, opt_level: opt_level, - fsync_fn: fn@(file: *libc::FILE, l: Level) -> int { + fsync_fn: |file, l| { unsafe { - return os::fsync_fd(libc::fileno(file), l) as int; + os::fsync_fd(libc::fileno(file), l) as int } } })); @@ -1164,9 +1164,7 @@ pub mod fsync { blk: fn(v: Res)) { blk(Res(Arg { val: fd.fd, opt_level: opt_level, - fsync_fn: fn@(fd: fd_t, l: Level) -> int { - return os::fsync_fd(fd, l) as int; - } + fsync_fn: |fd, l| os::fsync_fd(fd, l) as int })); } @@ -1178,9 +1176,7 @@ pub mod fsync { blk: fn(v: Res)) { blk(Res(Arg { val: o, opt_level: opt_level, - fsync_fn: fn@(o: FSyncable, l: Level) -> int { - return o.fsync(l); - } + fsync_fn: |o, l| o.fsync(l) })); } } diff --git a/src/libcore/num/num.rs b/src/libcore/num/num.rs index 7038ba07c0de..4d97df621da3 100644 --- a/src/libcore/num/num.rs +++ b/src/libcore/num/num.rs @@ -9,7 +9,7 @@ // except according to those terms. //! An interface for numeric types -use core::cmp::{Ord, Eq}; +use cmp::{Ord, Eq}; use ops::{Add, Div, Modulo, Mul, Neg, Sub}; use option::{None, Option, Some}; use char; diff --git a/src/libcore/pipes.rs b/src/libcore/pipes.rs index 58ab2ce78f5f..e4fc9528f23f 100644 --- a/src/libcore/pipes.rs +++ b/src/libcore/pipes.rs @@ -910,11 +910,10 @@ endpoint is passed to the new task. */ pub fn spawn_service( - init: extern fn() -> (SendPacketBuffered, - RecvPacketBuffered), - service: fn~(v: RecvPacketBuffered)) - -> SendPacketBuffered -{ + init: extern fn() -> (SendPacketBuffered, + RecvPacketBuffered), + service: ~fn(v: RecvPacketBuffered)) + -> SendPacketBuffered { let (client, server) = init(); // This is some nasty gymnastics required to safely move the pipe @@ -932,11 +931,10 @@ receive state. */ pub fn spawn_service_recv( - init: extern fn() -> (RecvPacketBuffered, - SendPacketBuffered), - service: fn~(v: SendPacketBuffered)) - -> RecvPacketBuffered -{ + init: extern fn() -> (RecvPacketBuffered, + SendPacketBuffered), + service: ~fn(v: SendPacketBuffered)) + -> RecvPacketBuffered { let (client, server) = init(); // This is some nasty gymnastics required to safely move the pipe diff --git a/src/libcore/reflect.rs b/src/libcore/reflect.rs index 2a688482f618..06ae4eb17a53 100644 --- a/src/libcore/reflect.rs +++ b/src/libcore/reflect.rs @@ -489,9 +489,9 @@ impl TyVisitor for MovePtrAdaptor { } fn visit_closure_ptr(&self, ck: uint) -> bool { - self.align_to::(); + self.align_to::<@fn()>(); if ! self.inner.visit_closure_ptr(ck) { return false; } - self.bump_past::(); + self.bump_past::<@fn()>(); true } } diff --git a/src/libcore/task/local_data.rs b/src/libcore/task/local_data.rs index ae101faaf026..185d8caae01f 100644 --- a/src/libcore/task/local_data.rs +++ b/src/libcore/task/local_data.rs @@ -27,8 +27,8 @@ magic. */ use prelude::*; -use rt; use task::local_data_priv::{local_get, local_pop, local_modify, local_set}; +use task::rt; use task; /** diff --git a/src/libcore/task/mod.rs b/src/libcore/task/mod.rs index 49507897392d..0835d4400ede 100644 --- a/src/libcore/task/mod.rs +++ b/src/libcore/task/mod.rs @@ -191,7 +191,7 @@ pub struct TaskOpts { // FIXME (#3724): Replace the 'consumed' bit with move mode on self pub struct TaskBuilder { opts: TaskOpts, - gen_body: fn@(v: fn~()) -> fn~(), + gen_body: @fn(v: ~fn()) -> ~fn(), can_not_copy: Option, mut consumed: bool, } @@ -357,7 +357,7 @@ pub impl TaskBuilder { * generator by applying the task body which results from the * existing body generator to the new body generator. */ - fn add_wrapper(wrapper: fn@(v: fn~()) -> fn~()) -> TaskBuilder { + fn add_wrapper(wrapper: @fn(v: ~fn()) -> ~fn()) -> TaskBuilder { let prev_gen_body = self.gen_body; let notify_chan = replace(&mut self.opts.notify_chan, None); TaskBuilder { @@ -385,7 +385,7 @@ pub impl TaskBuilder { * When spawning into a new scheduler, the number of threads requested * must be greater than zero. */ - fn spawn(f: fn~()) { + fn spawn(f: ~fn()) { let notify_chan = replace(&mut self.opts.notify_chan, None); let x = self.consume(); let opts = TaskOpts { @@ -397,7 +397,7 @@ pub impl TaskBuilder { spawn::spawn_raw(opts, (x.gen_body)(f)); } /// Runs a task, while transfering ownership of one argument to the child. - fn spawn_with(arg: A, f: fn~(v: A)) { + fn spawn_with(arg: A, f: ~fn(v: A)) { let arg = Cell(arg); do self.spawn { f(arg.take()); @@ -417,7 +417,7 @@ pub impl TaskBuilder { * # Failure * Fails if a future_result was already set for this task. */ - fn try(f: fn~() -> T) -> Result { + fn try(f: ~fn() -> T) -> Result { let (po, ch) = stream::(); let mut result = None; @@ -458,7 +458,7 @@ pub fn default_task_opts() -> TaskOpts { /* Spawn convenience functions */ -pub fn spawn(f: fn~()) { +pub fn spawn(f: ~fn()) { /*! * Creates and executes a new child task * @@ -471,7 +471,7 @@ pub fn spawn(f: fn~()) { task().spawn(f) } -pub fn spawn_unlinked(f: fn~()) { +pub fn spawn_unlinked(f: ~fn()) { /*! * Creates a child task unlinked from the current one. If either this * task or the child task fails, the other will not be killed. @@ -480,7 +480,7 @@ pub fn spawn_unlinked(f: fn~()) { task().unlinked().spawn(f) } -pub fn spawn_supervised(f: fn~()) { +pub fn spawn_supervised(f: ~fn()) { /*! * Creates a child task unlinked from the current one. If either this * task or the child task fails, the other will not be killed. @@ -489,7 +489,7 @@ pub fn spawn_supervised(f: fn~()) { task().supervised().spawn(f) } -pub fn spawn_with(arg: A, f: fn~(v: A)) { +pub fn spawn_with(arg: A, f: ~fn(v: A)) { /*! * Runs a task, while transfering ownership of one argument to the * child. @@ -503,7 +503,7 @@ pub fn spawn_with(arg: A, f: fn~(v: A)) { task().spawn_with(arg, f) } -pub fn spawn_sched(mode: SchedMode, f: fn~()) { +pub fn spawn_sched(mode: SchedMode, f: ~fn()) { /*! * Creates a new task on a new or existing scheduler @@ -519,7 +519,7 @@ pub fn spawn_sched(mode: SchedMode, f: fn~()) { task().sched_mode(mode).spawn(f) } -pub fn try(f: fn~() -> T) -> Result { +pub fn try(f: ~fn() -> T) -> Result { /*! * Execute a function in another task and return either the return value * of the function or result::err. @@ -840,11 +840,12 @@ fn test_add_wrapper() { let ch = Wrapper { f: Some(ch) }; let b1 = do b0.add_wrapper |body| { let ch = Wrapper { f: Some(ch.f.swap_unwrap()) }; - fn~() { + let result: ~fn() = || { let ch = ch.f.swap_unwrap(); body(); ch.send(()); - } + }; + result }; do b1.spawn { } po.recv(); @@ -1015,7 +1016,7 @@ fn test_spawn_sched_blocking() { } #[cfg(test)] -fn avoid_copying_the_body(spawnfn: fn(v: fn~())) { +fn avoid_copying_the_body(spawnfn: &fn(v: ~fn())) { let (p, ch) = stream::(); let x = ~1; @@ -1164,7 +1165,7 @@ fn test_child_doesnt_ref_parent() { // (well, it would if the constant were 8000+ - I lowered it to be more // valgrind-friendly. try this at home, instead..!) const generations: uint = 16; - fn child_no(x: uint) -> fn~() { + fn child_no(x: uint) -> ~fn() { return || { if x < generations { task::spawn(child_no(x+1)); diff --git a/src/libcore/task/spawn.rs b/src/libcore/task/spawn.rs index 6cc3657a32b4..152e602eeee0 100644 --- a/src/libcore/task/spawn.rs +++ b/src/libcore/task/spawn.rs @@ -173,19 +173,19 @@ fn access_ancestors(x: &unstable::Exclusive, // taskgroups that forward_blk already ran on successfully (Note: bail_blk // is NOT called on the block that forward_blk broke on!). // (3) As a bonus, coalesces away all 'dead' taskgroup nodes in the list. -// FIXME(#2190): Change Option to Option, to save on +// FIXME(#2190): Change Option<@fn(...)> to Option<&fn(...)>, to save on // allocations. Once that bug is fixed, changing the sigil should suffice. fn each_ancestor(list: &mut AncestorList, - bail_opt: Option, - forward_blk: fn(TaskGroupInner) -> bool) - -> bool { + bail_opt: Option<@fn(TaskGroupInner)>, + forward_blk: fn(TaskGroupInner) -> bool) + -> bool { // "Kickoff" call - there was no last generation. return !coalesce(list, bail_opt, forward_blk, uint::max_value); // Recursively iterates, and coalesces afterwards if needed. Returns // whether or not unwinding is needed (i.e., !successful iteration). fn coalesce(list: &mut AncestorList, - bail_opt: Option, + bail_opt: Option<@fn(TaskGroupInner)>, forward_blk: fn(TaskGroupInner) -> bool, last_generation: uint) -> bool { // Need to swap the list out to use it, to appease borrowck. @@ -213,9 +213,10 @@ fn each_ancestor(list: &mut AncestorList, // True if the supplied block did 'break', here or in any recursive // calls. If so, must call the unwinder on all previous nodes. fn iterate(ancestors: &AncestorList, - bail_opt: Option, - forward_blk: fn(TaskGroupInner) -> bool, - last_generation: uint) -> (Option, bool) { + bail_opt: Option<@fn(TaskGroupInner)>, + forward_blk: &fn(TaskGroupInner) -> bool, + last_generation: uint) + -> (Option, bool) { // At each step of iteration, three booleans are at play which govern // how the iteration should behave. // 'nobe_is_dead' - Should the list should be coalesced at this point? @@ -532,7 +533,7 @@ fn gen_child_taskgroup(linked: bool, supervised: bool) } } -pub fn spawn_raw(opts: TaskOpts, f: fn~()) { +pub fn spawn_raw(opts: TaskOpts, f: ~fn()) { let (child_tg, ancestors, is_main) = gen_child_taskgroup(opts.linked, opts.supervised); @@ -577,9 +578,10 @@ pub fn spawn_raw(opts: TaskOpts, f: fn~()) { fn make_child_wrapper(child: *rust_task, child_arc: TaskGroupArc, ancestors: AncestorList, is_main: bool, notify_chan: Option>, - f: fn~()) -> fn~() { + f: ~fn()) + -> ~fn() { let child_data = Cell((child_arc, ancestors)); - return fn~() { + let result: ~fn() = || { // Agh. Get move-mode items into the closure. FIXME (#2829) let mut (child_arc, ancestors) = child_data.take(); // Child task runs this code. @@ -613,6 +615,7 @@ pub fn spawn_raw(opts: TaskOpts, f: fn~()) { // FIXME #4428: Crashy. // unsafe { cleanup::annihilate(); } }; + return result; // Set up membership in taskgroup and descendantship in all ancestor // groups. If any enlistment fails, Some task was already failing, so diff --git a/src/libcore/unstable/finally.rs b/src/libcore/unstable/finally.rs index ff75963511c3..c995d914a7a6 100644 --- a/src/libcore/unstable/finally.rs +++ b/src/libcore/unstable/finally.rs @@ -79,9 +79,8 @@ fn test_fail() { #[test] fn test_retval() { - let i = do (fn&() -> int { - 10 - }).finally { }; + let closure: &fn() -> int = || 10; + let i = do closure.finally { }; assert i == 10; } diff --git a/src/libcore/unstable/weak_task.rs b/src/libcore/unstable/weak_task.rs index 0e1181f43dbc..bff5e9750ec1 100644 --- a/src/libcore/unstable/weak_task.rs +++ b/src/libcore/unstable/weak_task.rs @@ -43,9 +43,9 @@ pub unsafe fn weaken_task(f: &fn(Port)) { // Expect the weak task service to be alive assert service.try_send(RegisterWeakTask(task, shutdown_chan)); unsafe { rust_dec_kernel_live_count(); } - do fn&() { + do (|| { f(shutdown_port.take()) - }.finally || { + }).finally || { unsafe { rust_inc_kernel_live_count(); } // Service my have already exited service.send(UnregisterWeakTask(task)); @@ -74,13 +74,13 @@ fn create_global_service() -> ~WeakTaskService { do task().unlinked().spawn { debug!("running global weak task service"); let port = Cell(port.take()); - do fn&() { + do (|| { let port = port.take(); // The weak task service is itself a weak task debug!("weakening the weak service task"); unsafe { rust_dec_kernel_live_count(); } run_weak_task_service(port); - }.finally { + }).finally { debug!("unweakening the weak service task"); unsafe { rust_inc_kernel_live_count(); } } diff --git a/src/libfuzzer/ast_match.rs b/src/libfuzzer/ast_match.rs index 417141fd865c..afbe0c930ccc 100644 --- a/src/libfuzzer/ast_match.rs +++ b/src/libfuzzer/ast_match.rs @@ -11,8 +11,9 @@ use std; use vec; -fn vec_equal(v: ~[T], u: ~[T], - element_equality_test: fn@(&&T, &&T) -> bool) -> +fn vec_equal(v: ~[T], + u: ~[T], + element_equality_test: @fn(&&T, &&T) -> bool) -> bool { let Lv = vec::len(v); if Lv != vec::len(u) { return false; } diff --git a/src/libfuzzer/cycles.rs b/src/libfuzzer/cycles.rs index 7288b6d261d2..fb4c6400434f 100644 --- a/src/libfuzzer/cycles.rs +++ b/src/libfuzzer/cycles.rs @@ -39,8 +39,8 @@ type pointy = { mut b : ~maybe_pointy, mut c : @maybe_pointy, - mut f : fn@()->(), - mut g : fn~()->(), + mut f : @fn()->(), + mut g : ~fn()->(), mut m : ~[maybe_pointy], mut n : ~[maybe_pointy], @@ -54,8 +54,8 @@ fn empty_pointy() -> @pointy { mut b : ~none, mut c : @none, - mut f : fn@()->(){}, - mut g : fn~()->(){}, + mut f : || {}, + mut g : || {}, mut m : ~[], mut n : ~[], @@ -82,7 +82,7 @@ fn test_cycles(r : rand::rng, k: uint, n: uint) if (likelihood(r, k, n)) { v[i].c = @p(choice(r, v)); } if (likelihood(r, k, n)) { v[i].f = bind nopP(choice(r, v)); } - //if (false) { v[i].g = bind (fn~(_x: @pointy) { })( + //if (false) { v[i].g = bind (|_: @pointy| { })( // choice(r, v)); } // https://github.com/mozilla/rust/issues/1899 diff --git a/src/libfuzzer/fuzzer.rc b/src/libfuzzer/fuzzer.rc index c16a7cf8d3eb..1eb4ff98a6e6 100644 --- a/src/libfuzzer/fuzzer.rc +++ b/src/libfuzzer/fuzzer.rc @@ -31,8 +31,7 @@ extern mod std(vers = "0.6"); extern mod syntax(vers = "0.6"); use core::*; - -use io::WriterUtil; +use core::io::WriterUtil; use syntax::{ast, ast_util, fold, visit, codemap}; use syntax::parse; @@ -138,7 +137,7 @@ pub fn safe_to_steal_ty(t: @ast::Ty, tm: test_mode) -> bool { } // Not type-parameterized: https://github.com/mozilla/rust/issues/898 (FIXED) -pub fn stash_expr_if(c: fn@(@ast::expr, test_mode)->bool, +pub fn stash_expr_if(c: @fn(@ast::expr, test_mode)->bool, es: @mut ~[ast::expr], e: @ast::expr, tm: test_mode) { @@ -149,7 +148,7 @@ pub fn stash_expr_if(c: fn@(@ast::expr, test_mode)->bool, } } -pub fn stash_ty_if(c: fn@(@ast::Ty, test_mode)->bool, +pub fn stash_ty_if(c: @fn(@ast::Ty, test_mode)->bool, es: @mut ~[ast::Ty], e: @ast::Ty, tm: test_mode) { @@ -253,7 +252,7 @@ pub fn under(n: uint, it: fn(uint)) { while i < n { it(i); i += 1u; } } -pub fn as_str(f: fn@(+x: io::Writer)) -> ~str { +pub fn as_str(f: @fn(+x: io::Writer)) -> ~str { io::with_str_writer(f) } @@ -276,8 +275,8 @@ pub fn check_variants_T( filename: &Path, thing_label: ~str, things: ~[T], - stringifier: fn@(@T, @syntax::parse::token::ident_interner) -> ~str, - replacer: fn@(ast::crate, uint, T, test_mode) -> ast::crate, + stringifier: @fn(@T, @syntax::parse::token::ident_interner) -> ~str, + replacer: @fn(ast::crate, uint, T, test_mode) -> ast::crate, cx: Context ) { error!("%s contains %u %s objects", filename.to_str(), diff --git a/src/librust/rust.rc b/src/librust/rust.rc index e60f2bfaa501..37e0f874b40d 100644 --- a/src/librust/rust.rc +++ b/src/librust/rust.rc @@ -220,7 +220,7 @@ fn usage() { } -fn main() { +pub fn main() { let args = os::args().tail(); if !args.is_empty() { diff --git a/src/librustc/back/arm.rs b/src/librustc/back/arm.rs index faaddfed1e8b..95337b4150c2 100644 --- a/src/librustc/back/arm.rs +++ b/src/librustc/back/arm.rs @@ -9,8 +9,8 @@ // except according to those terms. use back::target_strs; +use driver::session::sess_os_to_meta_os; use driver::session; -use session::sess_os_to_meta_os; use metadata::loader::meta_section_name; pub fn get_target_strs(target_os: session::os) -> target_strs::t { diff --git a/src/librustc/back/link.rs b/src/librustc/back/link.rs index 8db27bd675d6..446b83af425a 100644 --- a/src/librustc/back/link.rs +++ b/src/librustc/back/link.rs @@ -11,6 +11,7 @@ use core::prelude::*; use back::rpath; +use driver::session::Session; use driver::session; use lib::llvm::llvm; use lib::llvm::{ModuleRef, mk_pass_manager, mk_target_data, True, False}; @@ -21,8 +22,6 @@ use metadata::filesearch; use metadata::{encoder, cstore}; use middle::trans::common::CrateContext; use middle::ty; -use session::Session; -use session; use util::ppaux; use core::char; @@ -89,10 +88,10 @@ pub fn WriteOutputFile(sess: Session, pub mod jit { use back::link::llvm_err; + use driver::session::Session; use lib::llvm::llvm; use lib::llvm::{ModuleRef, PassManagerRef, mk_target_data}; use metadata::cstore; - use session::Session; use core::cast; use core::libc::c_int; @@ -170,11 +169,11 @@ pub mod write { use back::link::{output_type_assembly, output_type_bitcode}; use back::link::{output_type_exe, output_type_llvm_assembly}; use back::link::{output_type_object}; + use driver::session::Session; use driver::session; use lib::llvm::llvm; use lib::llvm::{False, True, ModuleRef, mk_pass_manager, mk_target_data}; use lib; - use session::Session; use core::char; use core::libc::{c_char, c_int, c_uint}; diff --git a/src/librustc/back/x86.rs b/src/librustc/back/x86.rs index a768edcc00bb..2cc812c3d410 100644 --- a/src/librustc/back/x86.rs +++ b/src/librustc/back/x86.rs @@ -10,9 +10,9 @@ use back::target_strs; +use driver::session::sess_os_to_meta_os; use driver::session; use metadata::loader::meta_section_name; -use session::sess_os_to_meta_os; pub fn get_target_strs(target_os: session::os) -> target_strs::t { return target_strs::t { diff --git a/src/librustc/back/x86_64.rs b/src/librustc/back/x86_64.rs index dc4883137596..b68073974dcf 100644 --- a/src/librustc/back/x86_64.rs +++ b/src/librustc/back/x86_64.rs @@ -10,9 +10,9 @@ use back::target_strs; +use driver::session::sess_os_to_meta_os; use driver::session; use metadata::loader::meta_section_name; -use session::sess_os_to_meta_os; pub fn get_target_strs(target_os: session::os) -> target_strs::t { return target_strs::t { diff --git a/src/librustc/driver/driver.rs b/src/librustc/driver/driver.rs index 61bb03dd7f90..6e6213d4427d 100644 --- a/src/librustc/driver/driver.rs +++ b/src/librustc/driver/driver.rs @@ -12,14 +12,15 @@ use core::prelude::*; use back::link; use back::{arm, x86, x86_64}; +use driver::session::{Aggressive}; +use driver::session::{Session, Session_, OptLevel, No, Less, Default}; +use driver::session; use front; use lib::llvm::llvm; use metadata::{creader, cstore, filesearch}; use metadata; use middle::{trans, freevars, kind, ty, typeck, lint, astencode}; use middle; -use session::{Session, Session_, OptLevel, No, Less, Default, Aggressive}; -use session; use util::ppaux; use core::cmp; diff --git a/src/librustc/driver/session.rs b/src/librustc/driver/session.rs index 94dbfb51eb82..5da16dd53420 100644 --- a/src/librustc/driver/session.rs +++ b/src/librustc/driver/session.rs @@ -13,7 +13,7 @@ use core::prelude::*; use back::link; use back::target_strs; use back; -use driver; +use driver::driver::host_triple; use driver::session; use metadata::filesearch; use metadata; @@ -293,7 +293,7 @@ pub fn basic_options() -> @options { output_type: link::output_type_exe, addl_lib_search_paths: ~[], maybe_sysroot: None, - target_triple: driver::host_triple(), + target_triple: host_triple(), cfg: ~[], binary: ~"rustc", test: false, diff --git a/src/librustc/front/config.rs b/src/librustc/front/config.rs index faa1ad9854af..cdf63c49de3a 100644 --- a/src/librustc/front/config.rs +++ b/src/librustc/front/config.rs @@ -15,7 +15,7 @@ use syntax::{ast, fold, attr}; use core::option; use core::vec; -type in_cfg_pred = fn@(+attrs: ~[ast::attribute]) -> bool; +type in_cfg_pred = @fn(+attrs: ~[ast::attribute]) -> bool; struct Context { in_cfg: in_cfg_pred diff --git a/src/librustc/front/intrinsic.rs b/src/librustc/front/intrinsic.rs index 02e964ac3d35..059cd9723e76 100644 --- a/src/librustc/front/intrinsic.rs +++ b/src/librustc/front/intrinsic.rs @@ -11,7 +11,7 @@ // NB: this file is include_str!'ed into the compiler, re-parsed // and injected into each crate the compiler builds. Keep it small. -mod intrinsic { +pub mod intrinsic { pub use intrinsic::rusti::visit_tydesc; // FIXME (#3727): remove this when the interface has settled and the diff --git a/src/librustc/front/test.rs b/src/librustc/front/test.rs index 94b49e9d266e..524e46db7388 100644 --- a/src/librustc/front/test.rs +++ b/src/librustc/front/test.rs @@ -12,25 +12,24 @@ use core::prelude::*; +use driver::session::Session; use driver::session; use front::config; -use session::Session; use core::dvec::DVec; use core::option; use core::vec; use syntax::ast_util::*; +use syntax::attr::attrs_contains_name; use syntax::attr; use syntax::codemap::{dummy_sp, span, ExpandedFrom, CallInfo, NameAndSpan}; use syntax::codemap; +use syntax::ext::base::{mk_ctxt, ext_ctxt}; use syntax::fold; use syntax::print::pprust; use syntax::{ast, ast_util}; -use syntax::attr::attrs_contains_name; -use syntax::ext::base::{mk_ctxt, ext_ctxt}; - -type node_id_gen = fn@() -> ast::node_id; +type node_id_gen = @fn() -> ast::node_id; struct Test { span: span, @@ -286,7 +285,7 @@ fn mk_std(cx: &TestCtxt) -> @ast::view_item { let vi = ast::view_item { node: vi, attrs: ~[], - vis: ast::private, + vis: ast::public, span: dummy_sp() }; return @vi; diff --git a/src/librustc/metadata/creader.rs b/src/librustc/metadata/creader.rs index 79dec35e4abb..307a58135e13 100644 --- a/src/librustc/metadata/creader.rs +++ b/src/librustc/metadata/creader.rs @@ -80,7 +80,7 @@ fn dump_crates(+crate_cache: @mut ~[cache_entry]) { fn warn_if_multiple_versions(e: @mut Env, diag: span_handler, crate_cache: @mut ~[cache_entry]) { - use either::*; + use core::either::*; if crate_cache.len() != 0u { let name = loader::crate_name_from_metas( diff --git a/src/librustc/metadata/decoder.rs b/src/librustc/metadata/decoder.rs index cbe2217c9fc9..f660c796fa3b 100644 --- a/src/librustc/metadata/decoder.rs +++ b/src/librustc/metadata/decoder.rs @@ -14,9 +14,6 @@ use core::prelude::*; use metadata::cstore::crate_metadata; -use dvec::DVec; -use hash::{Hash, HashUtil}; -use io::WriterUtil; use metadata::common::*; use metadata::csearch::{ProvidedTraitMethodInfo, StaticMethodInfo}; use metadata::csearch; @@ -28,8 +25,11 @@ use middle::{ty, resolve}; use util::ppaux::ty_to_str; use core::cmp; +use core::dvec::DVec; use core::dvec; +use core::hash::{Hash, HashUtil}; use core::int; +use core::io::WriterUtil; use core::io; use core::option; use core::str; diff --git a/src/librustc/metadata/encoder.rs b/src/librustc/metadata/encoder.rs index 7d2423c7c5d3..403cc1cf9784 100644 --- a/src/librustc/metadata/encoder.rs +++ b/src/librustc/metadata/encoder.rs @@ -57,7 +57,7 @@ use writer = std::ebml::writer; // used by astencode: type abbrev_map = oldmap::HashMap; -pub type encode_inlined_item = fn@(ecx: @EncodeContext, +pub type encode_inlined_item = @fn(ecx: @EncodeContext, ebml_w: writer::Encoder, path: &[ast_map::path_elt], ii: ast::inlined_item); diff --git a/src/librustc/metadata/tydecode.rs b/src/librustc/metadata/tydecode.rs index 8da6ddda4b31..233c0949fa66 100644 --- a/src/librustc/metadata/tydecode.rs +++ b/src/librustc/metadata/tydecode.rs @@ -81,7 +81,7 @@ pub fn parse_ident(st: @mut PState, last: char) -> ast::ident { return parse_ident_(st, |a| is_last(last, a) ); } -fn parse_ident_(st: @mut PState, is_last: fn@(char) -> bool) -> +fn parse_ident_(st: @mut PState, is_last: @fn(char) -> bool) -> ast::ident { let mut rslt = ~""; while !is_last(peek(st)) { diff --git a/src/librustc/metadata/tyencode.rs b/src/librustc/metadata/tyencode.rs index dccbf7c778eb..8fd1d176b659 100644 --- a/src/librustc/metadata/tyencode.rs +++ b/src/librustc/metadata/tyencode.rs @@ -29,10 +29,10 @@ use middle::ty::Vid; pub struct ctxt { diag: span_handler, // Def -> str Callback: - ds: fn@(def_id) -> ~str, + ds: @fn(def_id) -> ~str, // The type context. tcx: ty::ctxt, - reachable: fn@(node_id) -> bool, + reachable: @fn(node_id) -> bool, abbrevs: abbrev_ctxt } diff --git a/src/librustc/middle/astencode.rs b/src/librustc/middle/astencode.rs index d5cb2f8726d1..b52a2d0bb093 100644 --- a/src/librustc/middle/astencode.rs +++ b/src/librustc/middle/astencode.rs @@ -843,7 +843,7 @@ fn encode_side_tables_for_ii(ecx: @e::EncodeContext, let ebml_w = copy ebml_w; ast_util::visit_ids_for_inlined_item( ii, - fn@(id: ast::node_id) { + |id: ast::node_id| { // Note: this will cause a copy of ebml_w, which is bad as // it has mut fields. But I believe it's harmless since // we generate balanced EBML. diff --git a/src/librustc/middle/borrowck/check_loans.rs b/src/librustc/middle/borrowck/check_loans.rs index c3555e54519a..d6af2f786264 100644 --- a/src/librustc/middle/borrowck/check_loans.rs +++ b/src/librustc/middle/borrowck/check_loans.rs @@ -212,8 +212,8 @@ pub impl CheckLoanCtxt { (*self.fn_args).contains(&(did.node)); if is_fn_arg { return; } // case (a) above } - ast::expr_fn_block(*) | ast::expr_fn(*) | - ast::expr_loop_body(*) | ast::expr_do_body(*) => { + ast::expr_fn_block(*) | ast::expr_loop_body(*) | + ast::expr_do_body(*) => { if self.is_stack_closure(expr.id) { // case (b) above return; @@ -244,7 +244,7 @@ pub impl CheckLoanCtxt { } // True if the expression with the given `id` is a stack closure. - // The expression must be an expr_fn(*) or expr_fn_block(*) + // The expression must be an expr_fn_block(*) fn is_stack_closure(@mut self, id: ast::node_id) -> bool { let fn_ty = ty::node_id_to_type(self.tcx(), id); match ty::get(fn_ty).sty { @@ -262,10 +262,8 @@ pub impl CheckLoanCtxt { did.crate == ast::local_crate && (*self.fn_args).contains(&(did.node)) } - ast::expr_fn_block(*) | ast::expr_fn(*) => { - self.is_stack_closure(expr.id) - } - _ => false + ast::expr_fn_block(*) => self.is_stack_closure(expr.id), + _ => false, }; } diff --git a/src/librustc/middle/borrowck/gather_loans.rs b/src/librustc/middle/borrowck/gather_loans.rs index ab343456ef46..457701e659a6 100644 --- a/src/librustc/middle/borrowck/gather_loans.rs +++ b/src/librustc/middle/borrowck/gather_loans.rs @@ -251,7 +251,7 @@ fn req_loans_in_expr(ex: @ast::expr, // Receivers in method calls are always passed by ref. // // Here, the field a.b is in fact a closure. Eventually, this - // should be an fn&, but for now it's an fn@. In any case, + // should be an &fn, but for now it's an @fn. In any case, // the enclosing scope is either the call where it is a rcvr // (if used like `a.b(...)`), the call where it's an argument // (if used like `x(a.b)`), or the block (if used like `let x diff --git a/src/librustc/middle/check_loop.rs b/src/librustc/middle/check_loop.rs index 15f64b0fa2f0..74a79e5e5609 100644 --- a/src/librustc/middle/check_loop.rs +++ b/src/librustc/middle/check_loop.rs @@ -38,12 +38,6 @@ pub fn check_crate(tcx: ty::ctxt, crate: @crate) { expr_loop(ref b, _) => { (v.visit_block)(b, Context { in_loop: true,.. cx }, v); } - expr_fn(*) => { - visit::visit_expr(e, Context { - in_loop: false, - can_ret: true - }, v); - } expr_fn_block(_, ref b) => { (v.visit_block)(b, Context { in_loop: false, diff --git a/src/librustc/middle/freevars.rs b/src/librustc/middle/freevars.rs index 7d2ab1700ddb..52520b59b446 100644 --- a/src/librustc/middle/freevars.rs +++ b/src/librustc/middle/freevars.rs @@ -46,14 +46,10 @@ fn collect_freevars(def_map: resolve::DefMap, blk: &ast::blk) fn ignore_item(_i: @ast::item, &&_depth: int, _v: visit::vt) { } - let walk_expr = fn@(expr: @ast::expr, &&depth: int, v: visit::vt) { + let walk_expr: @fn(expr: @ast::expr, &&depth: int, v: visit::vt) = + |expr, depth, v| { match expr.node { - ast::expr_fn(_, _, _, _) => { - visit::visit_expr(expr, depth + 1, v); - } - ast::expr_fn_block(*) => { - visit::visit_expr(expr, depth + 1, v); - } + ast::expr_fn_block(*) => visit::visit_expr(expr, depth + 1, v), ast::expr_path(*) => { let mut i = 0; match def_map.find(&expr.id) { @@ -100,8 +96,11 @@ pub fn annotate_freevars(def_map: resolve::DefMap, crate: @ast::crate) -> freevar_map { let freevars = HashMap(); - let walk_fn = fn@(_fk: &visit::fn_kind, _decl: &ast::fn_decl, - blk: &ast::blk, _sp: span, nid: ast::node_id) { + let walk_fn: @fn(&visit::fn_kind, + &ast::fn_decl, + &ast::blk, + span, + ast::node_id) = |_, _, blk, _, nid| { let vars = collect_freevars(def_map, blk); freevars.insert(nid, vars); }; diff --git a/src/librustc/middle/kind.rs b/src/librustc/middle/kind.rs index 355ec5bf9e54..aca5675aa151 100644 --- a/src/librustc/middle/kind.rs +++ b/src/librustc/middle/kind.rs @@ -84,7 +84,7 @@ pub fn check_crate(tcx: ty::ctxt, visit_expr: check_expr, visit_fn: check_fn, visit_ty: check_ty, - visit_item: fn@(i: @item, cx: Context, v: visit::vt) { + visit_item: |i, cx, v| { visit::visit_item(i, Context { current_item: i.id,.. cx }, v); }, .. *visit::default_visitor() @@ -93,7 +93,7 @@ pub fn check_crate(tcx: ty::ctxt, tcx.sess.abort_if_errors(); } -type check_fn = fn@(Context, @freevar_entry); +type check_fn = @fn(Context, @freevar_entry); // Yields the appropriate function to check the kind of closed over // variables. `id` is the node_id for some expression that creates the diff --git a/src/librustc/middle/lang_items.rs b/src/librustc/middle/lang_items.rs index d399f0e6886e..c0ce6ee515fa 100644 --- a/src/librustc/middle/lang_items.rs +++ b/src/librustc/middle/lang_items.rs @@ -34,7 +34,7 @@ use syntax::visit::{visit_crate, visit_item}; use core::ptr; use std::oldmap::HashMap; -use str_eq = str::eq; +use str_eq = core::str::eq; pub enum LangItem { ConstTraitLangItem, // 0 diff --git a/src/librustc/middle/liveness.rs b/src/librustc/middle/liveness.rs index 5286fa1025a7..95f28578fec6 100644 --- a/src/librustc/middle/liveness.rs +++ b/src/librustc/middle/liveness.rs @@ -570,7 +570,6 @@ fn visit_expr(expr: @expr, &&self: @mut IrMaps, vt: vt<@mut IrMaps>) { } visit::visit_expr(expr, self, vt); } - expr_fn(*) | expr_fn_block(*) => { // Interesting control flow (for loops can contain labeled // breaks or continues) @@ -1123,8 +1122,8 @@ pub impl Liveness { self.propagate_through_expr(e, succ) } - expr_fn(_, _, ref blk, _) | expr_fn_block(_, ref blk) => { - debug!("%s is an expr_fn or expr_fn_block", + expr_fn_block(_, ref blk) => { + debug!("%s is an expr_fn_block", expr_to_str(expr, self.tcx.sess.intr())); /* @@ -1592,7 +1591,7 @@ fn check_expr(expr: @expr, &&self: @Liveness, vt: vt<@Liveness>) { visit::visit_expr(expr, self, vt); } - expr_fn(*) | expr_fn_block(*) => { + expr_fn_block(*) => { let caps = self.ir.captures(expr); for caps.each |cap| { let var = self.variable(cap.var_nid, expr.span); @@ -1794,7 +1793,7 @@ pub impl @Liveness { } match move_expr.node { - expr_fn(*) | expr_fn_block(*) => { + expr_fn_block(*) => { self.report_illegal_read( move_expr.span, lnk, var, MovedValue); let name = self.ir.variable_name(var); diff --git a/src/librustc/middle/mem_categorization.rs b/src/librustc/middle/mem_categorization.rs index 7a6a434c41fd..bcbb2d6fd175 100644 --- a/src/librustc/middle/mem_categorization.rs +++ b/src/librustc/middle/mem_categorization.rs @@ -441,7 +441,7 @@ pub impl mem_categorization_ctxt { ast::expr_addr_of(*) | ast::expr_call(*) | ast::expr_swap(*) | ast::expr_assign(*) | - ast::expr_assign_op(*) | ast::expr_fn(*) | ast::expr_fn_block(*) | + ast::expr_assign_op(*) | ast::expr_fn_block(*) | ast::expr_assert(*) | ast::expr_ret(*) | ast::expr_loop_body(*) | ast::expr_do_body(*) | ast::expr_unary(*) | ast::expr_method_call(*) | diff --git a/src/librustc/middle/moves.rs b/src/librustc/middle/moves.rs index b9f35af37e01..c360b3a23e73 100644 --- a/src/librustc/middle/moves.rs +++ b/src/librustc/middle/moves.rs @@ -644,7 +644,6 @@ pub impl VisitContext { self.use_expr(base, comp_mode, visitor); } - expr_fn(_, _, ref body, _) | expr_fn_block(_, ref body) => { let cap_vars = self.compute_captures(expr.id); self.move_maps.capture_map.insert(expr.id, cap_vars); diff --git a/src/librustc/middle/resolve.rs b/src/librustc/middle/resolve.rs index 1c4928fd3745..5298f6c632d6 100644 --- a/src/librustc/middle/resolve.rs +++ b/src/librustc/middle/resolve.rs @@ -34,12 +34,12 @@ use syntax::ast::{def_local, def_mod, def_prim_ty, def_region, def_self}; use syntax::ast::{def_self_ty, def_static_method, def_struct, def_ty}; use syntax::ast::{def_ty_param, def_typaram_binder}; use syntax::ast::{def_upvar, def_use, def_variant, expr, expr_assign_op}; -use syntax::ast::{expr_binary, expr_break, expr_cast, expr_field, expr_fn}; +use syntax::ast::{expr_binary, expr_break, expr_cast, expr_field}; use syntax::ast::{expr_fn_block, expr_index, expr_method_call, expr_path}; use syntax::ast::{def_prim_ty, def_region, def_self, def_ty, def_ty_param}; use syntax::ast::{def_upvar, def_use, def_variant, div, eq}; use syntax::ast::{enum_variant_kind, expr, expr_again, expr_assign_op}; -use syntax::ast::{expr_fn_block, expr_index, expr_loop}; +use syntax::ast::{expr_index, expr_loop}; use syntax::ast::{expr_path, expr_struct, expr_unary, fn_decl}; use syntax::ast::{foreign_item, foreign_item_const, foreign_item_fn, ge}; use syntax::ast::{Generics}; @@ -77,15 +77,14 @@ use syntax::visit::{visit_mod, visit_ty, vt}; use syntax::opt_vec; use syntax::opt_vec::OptVec; -use managed::ptr_eq; -use dvec::DVec; -use option::{Some, get, is_some, is_none}; -use str::{connect, split_str}; -use vec::pop; - +use core::dvec::DVec; +use core::managed::ptr_eq; +use core::option::{Some, get, is_some, is_none}; +use core::str::{connect, split_str}; +use core::vec::pop; use std::list::{Cons, List, Nil}; use std::oldmap::HashMap; -use str_eq = str::eq; +use str_eq = core::str::eq; // Definition mapping pub type DefMap = HashMap; @@ -305,6 +304,12 @@ pub enum AllowCapturingSelfFlag { DontAllowCapturingSelf, //< The "self" definition cannot be captured. } +#[deriving_eq] +enum NameSearchType { + SearchItemsAndPublicImports, //< Search items and public imports. + SearchItemsAndAllImports, //< Search items and all imports. +} + pub enum BareIdentifierPatternResolution { FoundStructOrEnumVariant(def), FoundConst(def), @@ -1488,7 +1493,7 @@ pub impl Resolver { let parent_link = ModuleParentLink (self.get_module_from_parent(new_parent), name); - child_name_bindings.define_module(privacy, + child_name_bindings.define_module(Public, parent_link, Some(def_id), NormalModuleKind, @@ -1948,10 +1953,8 @@ pub impl Resolver { } } - /** - * Attempts to resolve imports for the given module and all of its - * submodules. - */ + /// Attempts to resolve imports for the given module and all of its + /// submodules. fn resolve_imports_for_module_subtree(@mut self, module_: @mut Module) { debug!("(resolving imports for module subtree) resolving %s", self.module_to_str(module_)); @@ -1974,19 +1977,19 @@ pub impl Resolver { } /// Attempts to resolve imports for the given module only. - fn resolve_imports_for_module(@mut self, module_: @mut Module) { - if (*module_).all_imports_resolved() { + fn resolve_imports_for_module(@mut self, module: @mut Module) { + if module.all_imports_resolved() { debug!("(resolving imports for module) all imports resolved for \ %s", - self.module_to_str(module_)); + self.module_to_str(module)); return; } - let import_count = module_.imports.len(); - while module_.resolved_import_count < import_count { - let import_index = module_.resolved_import_count; - let import_directive = module_.imports.get_elt(import_index); - match self.resolve_import_for_module(module_, import_directive) { + let import_count = module.imports.len(); + while module.resolved_import_count < import_count { + let import_index = module.resolved_import_count; + let import_directive = module.imports.get_elt(import_index); + match self.resolve_import_for_module(module, import_directive) { Failed => { // We presumably emitted an error. Continue. let idents = import_directive.module_path.get(); @@ -2004,7 +2007,7 @@ pub impl Resolver { } } - module_.resolved_import_count += 1; + module.resolved_import_count += 1; } } @@ -2037,72 +2040,71 @@ pub impl Resolver { } } - /** - * Attempts to resolve the given import. The return value indicates - * failure if we're certain the name does not exist, indeterminate if we - * don't know whether the name exists at the moment due to other - * currently-unresolved imports, or success if we know the name exists. - * If successful, the resolved bindings are written into the module. - */ - fn resolve_import_for_module(@mut self, - module_: @mut Module, + /// Attempts to resolve the given import. The return value indicates + /// failure if we're certain the name does not exist, indeterminate if we + /// don't know whether the name exists at the moment due to other + /// currently-unresolved imports, or success if we know the name exists. + /// If successful, the resolved bindings are written into the module. + fn resolve_import_for_module(@mut self, module_: @mut Module, import_directive: @ImportDirective) -> ResolveResult<()> { - let mut resolution_result; + let mut resolution_result = Failed; let module_path = import_directive.module_path; debug!("(resolving import for module) resolving import `%s::...` in \ `%s`", - self.idents_to_str((*module_path).get()), + self.idents_to_str(module_path.get()), self.module_to_str(module_)); - // One-level renaming imports of the form `import foo = bar;` are - // handled specially. - - if (*module_path).len() == 0 { - resolution_result = - self.resolve_one_level_renaming_import(module_, - import_directive); + // First, resolve the module path for the directive, if necessary. + let containing_module = if module_path.len() == 0 { + // Use the crate root. + Some(self.graph_root.get_module()) } else { - // First, resolve the module path for the directive, if necessary. match self.resolve_module_path_for_import(module_, module_path, DontUseLexicalScope, import_directive.span) { - Failed => { - resolution_result = Failed; - } + Failed => None, Indeterminate => { resolution_result = Indeterminate; + None } - Success(containing_module) => { - // We found the module that the target is contained - // within. Attempt to resolve the import within it. + Success(containing_module) => Some(containing_module), + } + }; - match *import_directive.subclass { - SingleImport(target, source, AnyNS) => { - resolution_result = - self.resolve_single_import(module_, - containing_module, - target, - source); - } - SingleImport(target, source, TypeNSOnly) => { - resolution_result = - self.resolve_single_module_import - (module_, containing_module, target, - source); - } - GlobImport => { - let span = import_directive.span; - let p = import_directive.privacy; - resolution_result = - self.resolve_glob_import(p, - module_, - containing_module, - span); - } + match containing_module { + None => {} + Some(containing_module) => { + // We found the module that the target is contained + // within. Attempt to resolve the import within it. + + match *import_directive.subclass { + SingleImport(target, source, AnyNS) => { + resolution_result = + self.resolve_single_import(module_, + containing_module, + target, + source); + } + SingleImport(target, source, TypeNSOnly) => { + resolution_result = + self.resolve_single_module_import( + module_, + containing_module, + target, + source); + } + GlobImport => { + let span = import_directive.span; + let privacy = import_directive.privacy; + resolution_result = + self.resolve_glob_import(privacy, + module_, + containing_module, + span); } } } @@ -2575,11 +2577,13 @@ pub impl Resolver { return Success(()); } + /// Resolves the given module path from the given root `module_`. fn resolve_module_path_from_root(@mut self, module_: @mut Module, module_path: @DVec, index: uint, - span: span) + span: span, + mut name_search_type: NameSearchType) -> ResolveResult<@mut Module> { let mut search_module = module_; let mut index = index; @@ -2594,7 +2598,7 @@ pub impl Resolver { match self.resolve_name_in_module(search_module, name, TypeNS, - false) { + name_search_type) { Failed => { self.session.span_err(span, ~"unresolved name"); return Failed; @@ -2639,22 +2643,33 @@ pub impl Resolver { } index += 1; + + // After the first element of the path, allow searching through + // items and imports unconditionally. This allows things like: + // + // pub mod core { + // pub use vec; + // } + // + // pub mod something_else { + // use core::vec; + // } + + name_search_type = SearchItemsAndPublicImports; } return Success(search_module); } - /** - * Attempts to resolve the module part of an import directive or path - * rooted at the given module. - */ + /// Attempts to resolve the module part of an import directive or path + /// rooted at the given module. fn resolve_module_path_for_import(@mut self, module_: @mut Module, module_path: @DVec, use_lexical_scope: UseLexicalScopeFlag, span: span) -> ResolveResult<@mut Module> { - let module_path_len = (*module_path).len(); + let module_path_len = module_path.len(); assert module_path_len > 0; debug!("(resolving module path for import) processing `%s` rooted at \ @@ -2721,12 +2736,15 @@ pub impl Resolver { } } - return self.resolve_module_path_from_root(search_module, - module_path, - start_index, - span); + self.resolve_module_path_from_root(search_module, + module_path, + start_index, + span, + SearchItemsAndPublicImports) } + /// Invariant: This must only be called during main resolution, not during + /// import resolution. fn resolve_item_in_lexical_scope(@mut self, module_: @mut Module, name: ident, @@ -2822,7 +2840,7 @@ pub impl Resolver { match self.resolve_name_in_module(search_module, name, namespace, - false) { + SearchItemsAndAllImports) { Failed => { // Continue up the search chain. } @@ -2973,16 +2991,14 @@ pub impl Resolver { return Success(PrefixFound(containing_module, i)); } - /** - * Attempts to resolve the supplied name in the given module for the - * given namespace. If successful, returns the target corresponding to - * the name. - */ + /// Attempts to resolve the supplied name in the given module for the + /// given namespace. If successful, returns the target corresponding to + /// the name. fn resolve_name_in_module(@mut self, module_: @mut Module, name: ident, namespace: Namespace, - allow_globs: bool) + +name_search_type: NameSearchType) -> ResolveResult { debug!("(resolving name in module) resolving `%s` in `%s`", *self.session.str_of(name), @@ -3001,35 +3017,42 @@ pub impl Resolver { } } - // Next, check the module's imports. If the module has a glob and - // globs were not allowed, then we bail out; we don't know its imports - // yet. - if !allow_globs && module_.glob_count > 0 { - debug!("(resolving name in module) module has glob; bailing out"); - return Indeterminate; + // Next, check the module's imports if necessary. + + // If this is a search of all imports, we should be done with glob + // resolution at this point. + if name_search_type == SearchItemsAndAllImports { + assert module_.glob_count == 0; } - // Otherwise, we check the list of resolved imports. + // Check the list of resolved imports. match module_.import_resolutions.find(&name) { Some(import_resolution) => { if import_resolution.outstanding_references != 0 { - debug!("(resolving name in module) import unresolved; \ - bailing out"); + debug!("(resolving name in module) import \ + unresolved; bailing out"); return Indeterminate; } - match (*import_resolution).target_for_namespace(namespace) { + match import_resolution.target_for_namespace(namespace) { None => { - debug!("(resolving name in module) name found, but \ - not in namespace %?", + debug!("(resolving name in module) name found, \ + but not in namespace %?", namespace); } - Some(target) => { + Some(target) + if name_search_type == + SearchItemsAndAllImports || + import_resolution.privacy == Public => { debug!("(resolving name in module) resolved to \ import"); import_resolution.state.used = true; return Success(copy target); } + Some(_) => { + debug!("(resolving name in module) name found, \ + but not public"); + } } } None => { @@ -3043,168 +3066,6 @@ pub impl Resolver { return Failed; } - /** - * Resolves a one-level renaming import of the kind `import foo = bar;` - * This needs special handling, as, unlike all of the other imports, it - * needs to look in the scope chain for modules and non-modules alike. - */ - fn resolve_one_level_renaming_import(@mut self, - module_: @mut Module, - import_directive: @ImportDirective) - -> ResolveResult<()> { - let mut target_name; - let mut source_name; - let allowable_namespaces; - match *import_directive.subclass { - SingleImport(target, source, namespaces) => { - target_name = target; - source_name = source; - allowable_namespaces = namespaces; - } - GlobImport => { - fail!(~"found `import *`, which is invalid"); - } - } - - debug!("(resolving one-level naming result) resolving import `%s` = \ - `%s` in `%s`", - *self.session.str_of(target_name), - *self.session.str_of(source_name), - self.module_to_str(module_)); - - // Find the matching items in the lexical scope chain for every - // namespace. If any of them come back indeterminate, this entire - // import is indeterminate. - - let mut module_result; - debug!("(resolving one-level naming result) searching for module"); - match self.resolve_item_in_lexical_scope(module_, - source_name, - TypeNS, - SearchThroughModules) { - Failed => { - debug!("(resolving one-level renaming import) didn't find \ - module result"); - module_result = None; - } - Indeterminate => { - debug!("(resolving one-level renaming import) module result \ - is indeterminate; bailing"); - return Indeterminate; - } - Success(name_bindings) => { - debug!("(resolving one-level renaming import) module result \ - found"); - module_result = Some(copy name_bindings); - } - } - - let mut value_result; - let mut type_result; - if allowable_namespaces == TypeNSOnly { - value_result = None; - type_result = None; - } else { - debug!("(resolving one-level naming result) searching for value"); - match self.resolve_item_in_lexical_scope(module_, - source_name, - ValueNS, - SearchThroughModules) { - - Failed => { - debug!("(resolving one-level renaming import) didn't \ - find value result"); - value_result = None; - } - Indeterminate => { - debug!("(resolving one-level renaming import) value \ - result is indeterminate; bailing"); - return Indeterminate; - } - Success(name_bindings) => { - debug!("(resolving one-level renaming import) value \ - result found"); - value_result = Some(copy name_bindings); - } - } - - debug!("(resolving one-level naming result) searching for type"); - match self.resolve_item_in_lexical_scope(module_, - source_name, - TypeNS, - SearchThroughModules) { - - Failed => { - debug!("(resolving one-level renaming import) didn't \ - find type result"); - type_result = None; - } - Indeterminate => { - debug!("(resolving one-level renaming import) type \ - result is indeterminate; bailing"); - return Indeterminate; - } - Success(name_bindings) => { - debug!("(resolving one-level renaming import) type \ - result found"); - type_result = Some(copy name_bindings); - } - } - } - - // - // NB: This one results in effects that may be somewhat surprising. It - // means that this: - // - // mod A { - // impl foo for ... { ... } - // mod B { - // impl foo for ... { ... } - // import bar = foo; - // ... - // } - // } - // - // results in only A::B::foo being aliased to A::B::bar, not A::foo - // *and* A::B::foo being aliased to A::B::bar. - // - - // If nothing at all was found, that's an error. - if is_none(&module_result) && - is_none(&value_result) && - is_none(&type_result) { - - self.session.span_err(import_directive.span, - ~"unresolved import"); - return Failed; - } - - // Otherwise, proceed and write in the bindings. - match module_.import_resolutions.find(&target_name) { - None => { - fail!(~"(resolving one-level renaming import) reduced graph \ - construction or glob importing should have created the \ - import resolution name by now"); - } - Some(import_resolution) => { - debug!("(resolving one-level renaming import) writing module \ - result %? for `%s` into `%s`", - is_none(&module_result), - *self.session.str_of(target_name), - self.module_to_str(module_)); - - import_resolution.value_target = value_result; - import_resolution.type_target = type_result; - - assert import_resolution.outstanding_references >= 1; - import_resolution.outstanding_references -= 1; - } - } - - debug!("(resolving one-level renaming import) successfully resolved"); - return Success(()); - } - fn report_unresolved_imports(@mut self, module_: @mut Module) { let index = module_.resolved_import_count; let import_count = module_.imports.len(); @@ -4538,10 +4399,8 @@ pub impl Resolver { } } - /** - * If `check_ribs` is true, checks the local definitions first; i.e. - * doesn't skip straight to the containing module. - */ + /// If `check_ribs` is true, checks the local definitions first; i.e. + /// doesn't skip straight to the containing module. fn resolve_path(@mut self, path: @path, namespace: Namespace, @@ -4714,6 +4573,8 @@ pub impl Resolver { } } + /// Invariant: This must be called only during main resolution, not during + /// import resolution. fn resolve_crate_relative_path(@mut self, path: @path, +xray: XrayFlag, @@ -4727,8 +4588,8 @@ pub impl Resolver { match self.resolve_module_path_from_root(root_module, module_path_idents, 0, - path.span) { - + path.span, + SearchItemsAndAllImports) { Failed => { self.session.span_err(path.span, fmt!("use of undeclared module `::%s`", @@ -4949,7 +4810,6 @@ pub impl Resolver { visit_expr(expr, (), visitor); } - expr_fn(_, ref fn_decl, ref block, _) | expr_fn_block(ref fn_decl, ref block) => { self.resolve_function(FunctionRibKind(expr.id, block.node.id), Some(@/*bad*/copy *fn_decl), diff --git a/src/librustc/middle/trans/_match.rs b/src/librustc/middle/trans/_match.rs index 2f9203780873..0d3524ed7fb2 100644 --- a/src/librustc/middle/trans/_match.rs +++ b/src/librustc/middle/trans/_match.rs @@ -1003,7 +1003,7 @@ pub fn any_tuple_struct_pat(bcx: block, m: &[@Match], col: uint) -> bool { }) } -pub type mk_fail = fn@() -> BasicBlockRef; +pub type mk_fail = @fn() -> BasicBlockRef; pub fn pick_col(m: &[@Match]) -> uint { fn score(p: @ast::pat) -> uint { diff --git a/src/librustc/middle/trans/base.rs b/src/librustc/middle/trans/base.rs index d1472f63ae74..a714446235ae 100644 --- a/src/librustc/middle/trans/base.rs +++ b/src/librustc/middle/trans/base.rs @@ -634,8 +634,8 @@ pub fn compare_scalar_values(cx: block, } } -pub type val_pair_fn = fn@(block, ValueRef, ValueRef) -> block; -pub type val_and_ty_fn = fn@(block, ValueRef, ty::t) -> block; +pub type val_pair_fn = @fn(block, ValueRef, ValueRef) -> block; +pub type val_and_ty_fn = @fn(block, ValueRef, ty::t) -> block; pub fn load_inbounds(cx: block, p: ValueRef, idxs: &[uint]) -> ValueRef { return Load(cx, GEPi(cx, p, idxs)); diff --git a/src/librustc/middle/trans/build.rs b/src/librustc/middle/trans/build.rs index 7ac54518d374..8db48e1de605 100644 --- a/src/librustc/middle/trans/build.rs +++ b/src/librustc/middle/trans/build.rs @@ -8,26 +8,25 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. - -use codemap::span; -use lib; use lib::llvm::llvm; use lib::llvm::{CallConv, TypeKind, AtomicBinOp, AtomicOrdering}; use lib::llvm::{Opcode, IntPredicate, RealPredicate, True, False}; use lib::llvm::{ValueRef, TypeRef, BasicBlockRef, BuilderRef, ModuleRef}; -use libc::{c_uint, c_int, c_ulonglong}; +use lib; use middle::trans::common::*; use middle::trans::machine::llsize_of_real; use core::prelude::*; use core::cast::transmute; use core::cast; +use core::libc::{c_uint, c_int, c_ulonglong}; use core::libc; use core::option::Some; use core::ptr; use core::str; use core::vec; use std::oldmap::HashMap; +use syntax::codemap::span; use syntax::codemap; pub fn terminate(cx: block, _: &str) { diff --git a/src/librustc/middle/trans/closure.rs b/src/librustc/middle/trans/closure.rs index 949318d1723b..fd149aa71e57 100644 --- a/src/librustc/middle/trans/closure.rs +++ b/src/librustc/middle/trans/closure.rs @@ -42,7 +42,7 @@ use syntax::print::pprust::expr_to_str; // roughly as follows: // // struct rust_opaque_box { // see rust_internal.h -// unsigned ref_count; // only used for fn@() +// unsigned ref_count; // only used for @fn() // type_desc *tydesc; // describes closure_data struct // rust_opaque_box *prev; // (used internally by memory alloc) // rust_opaque_box *next; // (used internally by memory alloc) @@ -57,7 +57,7 @@ use syntax::print::pprust::expr_to_str; // }; // // Note that the closure is itself a rust_opaque_box. This is true -// even for fn~ and fn&, because we wish to keep binary compatibility +// even for ~fn and &fn, because we wish to keep binary compatibility // between all kinds of closures. The allocation strategy for this // closure depends on the closure type. For a sendfn, the closure // (and the referenced type descriptors) will be allocated in the @@ -440,11 +440,10 @@ pub fn trans_expr_fn(bcx: block, } pub fn make_closure_glue( - cx: block, - v: ValueRef, - t: ty::t, - glue_fn: fn@(block, v: ValueRef, t: ty::t) -> block) -> block -{ + cx: block, + v: ValueRef, + t: ty::t, + glue_fn: @fn(block, v: ValueRef, t: ty::t) -> block) -> block { let _icx = cx.insn_ctxt("closure::make_closure_glue"); let bcx = cx; let tcx = cx.tcx(); @@ -483,7 +482,7 @@ pub fn make_opaque_cbox_take_glue( } } - // fn~ requires a deep copy. + // ~fn requires a deep copy. let ccx = bcx.ccx(), tcx = ccx.tcx; let llopaquecboxty = T_opaque_box_ptr(ccx); let cbox_in = Load(bcx, cboxptr); diff --git a/src/librustc/middle/trans/common.rs b/src/librustc/middle/trans/common.rs index c2a7abe747bb..bd8bbfce5a41 100644 --- a/src/librustc/middle/trans/common.rs +++ b/src/librustc/middle/trans/common.rs @@ -61,14 +61,15 @@ use syntax::parse::token::ident_interner; use syntax::print::pprust::expr_to_str; use syntax::{ast, ast_map}; -pub type namegen = fn@(~str) -> ident; +pub type namegen = @fn(~str) -> ident; pub fn new_namegen(intr: @ident_interner) -> namegen { - return fn@(prefix: ~str) -> ident { + let f: @fn(~str) -> ident = |prefix| { // XXX: Bad copies. - return intr.gensym(@fmt!("%s_%u", - prefix, - intr.gensym(@copy prefix).repr)) + intr.gensym(@fmt!("%s_%u", + prefix, + intr.gensym(@copy prefix).repr)) }; + f } pub type addrspace = c_uint; @@ -81,10 +82,11 @@ pub type addrspace = c_uint; pub const default_addrspace: addrspace = 0; pub const gc_box_addrspace: addrspace = 1; -pub type addrspace_gen = fn@() -> addrspace; +pub type addrspace_gen = @fn() -> addrspace; pub fn new_addrspace_gen() -> addrspace_gen { let i = @mut 1; - return fn@() -> addrspace { *i += 1; *i }; + let result: addrspace_gen = || { *i += 1; *i }; + result } pub struct tydesc_info { @@ -349,8 +351,8 @@ pub enum cleantype { } pub enum cleanup { - clean(fn@(block) -> block, cleantype), - clean_temp(ValueRef, fn@(block) -> block, cleantype), + clean(@fn(block) -> block, cleantype), + clean_temp(ValueRef, @fn(block) -> block, cleantype), } // Used to remember and reuse existing cleanup paths @@ -1034,7 +1036,7 @@ pub fn T_typaram_ptr(tn: @TypeNames) -> TypeRef { } pub fn T_opaque_cbox_ptr(cx: @CrateContext) -> TypeRef { - // closures look like boxes (even when they are fn~ or fn&) + // closures look like boxes (even when they are ~fn or &fn) // see trans_closure.rs return T_opaque_box_ptr(cx); } diff --git a/src/librustc/middle/trans/debuginfo.rs b/src/librustc/middle/trans/debuginfo.rs index 8a28769756e6..d6c691f66676 100644 --- a/src/librustc/middle/trans/debuginfo.rs +++ b/src/librustc/middle/trans/debuginfo.rs @@ -869,15 +869,12 @@ pub fn create_function(fcx: fn_ctxt) -> @Metadata { } ast_map::node_expr(expr) => { match /*bad*/copy expr.node { - ast::expr_fn(_, decl, _, _) => { - ((dbg_cx.names)(~"fn"), decl.output, expr.id) - } ast::expr_fn_block(decl, _) => { ((dbg_cx.names)(~"fn"), decl.output, expr.id) } _ => fcx.ccx.sess.span_bug(expr.span, ~"create_function: \ - expected an expr_fn or fn_block here") + expected an expr_fn_block here") } } ast_map::node_dtor(_, _, did, _) => { diff --git a/src/librustc/middle/trans/expr.rs b/src/librustc/middle/trans/expr.rs index 7fe2bd605e9f..74cebaee2da4 100644 --- a/src/librustc/middle/trans/expr.rs +++ b/src/librustc/middle/trans/expr.rs @@ -619,7 +619,6 @@ fn trans_rvalue_dps_unadjusted(bcx: block, expr: @ast::expr, ast::expr_vec(*) | ast::expr_repeat(*) => { return tvec::trans_fixed_vstore(bcx, expr, expr, dest); } - ast::expr_fn(_, ref decl, ref body, _) | ast::expr_fn_block(ref decl, ref body) => { let expr_ty = expr_ty(bcx, expr); let sigil = ty::ty_closure_sigil(expr_ty); diff --git a/src/librustc/middle/trans/glue.rs b/src/librustc/middle/trans/glue.rs index 96deb2906eb7..de6d22cd6b89 100644 --- a/src/librustc/middle/trans/glue.rs +++ b/src/librustc/middle/trans/glue.rs @@ -709,7 +709,7 @@ pub fn declare_tydesc(ccx: @CrateContext, t: ty::t) -> @mut tydesc_info { return inf; } -pub type glue_helper = fn@(block, ValueRef, ty::t); +pub type glue_helper = @fn(block, ValueRef, ty::t); pub fn declare_generic_glue(ccx: @CrateContext, t: ty::t, llfnty: TypeRef, +name: ~str) -> ValueRef { diff --git a/src/librustc/middle/trans/tvec.rs b/src/librustc/middle/trans/tvec.rs index 9e9b9da369a9..3542b5acf053 100644 --- a/src/librustc/middle/trans/tvec.rs +++ b/src/librustc/middle/trans/tvec.rs @@ -520,9 +520,9 @@ pub fn get_base_and_len(bcx: block, } } -pub type val_and_ty_fn = fn@(block, ValueRef, ty::t) -> Result; +pub type val_and_ty_fn = @fn(block, ValueRef, ty::t) -> Result; -pub type iter_vec_block = fn(block, ValueRef, ty::t) -> block; +pub type iter_vec_block = &fn(block, ValueRef, ty::t) -> block; pub fn iter_vec_raw(bcx: block, data_ptr: ValueRef, vec_ty: ty::t, fill: ValueRef, f: iter_vec_block) -> block { diff --git a/src/librustc/middle/trans/type_use.rs b/src/librustc/middle/trans/type_use.rs index ff92f265cc06..7b7a6eee92e7 100644 --- a/src/librustc/middle/trans/type_use.rs +++ b/src/librustc/middle/trans/type_use.rs @@ -301,7 +301,7 @@ pub fn mark_for_expr(cx: Context, e: @expr) { } } } - expr_fn(*) | expr_fn_block(*) => { + expr_fn_block(*) => { match ty::ty_closure_sigil(ty::expr_ty(cx.ccx.tcx, e)) { ast::OwnedSigil => {} ast::BorrowedSigil | ast::ManagedSigil => { diff --git a/src/librustc/middle/ty.rs b/src/librustc/middle/ty.rs index 3c25f2bfc595..0b0715dd9ca3 100644 --- a/src/librustc/middle/ty.rs +++ b/src/librustc/middle/ty.rs @@ -10,6 +10,7 @@ use core::prelude::*; +use driver::session::Session; use driver::session; use metadata::csearch; use metadata; @@ -22,7 +23,6 @@ use middle::resolve; use middle::ty; use middle::typeck; use middle; -use session::Session; use util::ppaux::{note_and_explain_region, bound_region_to_str}; use util::ppaux::{region_to_str, explain_region, vstore_to_str}; use util::ppaux::{ty_to_str, tys_to_str}; @@ -525,7 +525,7 @@ pub enum sty { // "Fake" types, used for trans purposes ty_type, // type_desc* ty_opaque_box, // used by monomorphizer to represent any @ box - ty_opaque_closure_ptr(Sigil), // ptr to env for fn, fn@, fn~ + ty_opaque_closure_ptr(Sigil), // ptr to env for &fn, @fn, ~fn ty_unboxed_vec(mt), } @@ -1102,8 +1102,8 @@ pub pure fn mach_sty(cfg: @session::config, t: t) -> sty { } pub fn default_arg_mode_for_ty(tcx: ctxt, ty: ty::t) -> ast::rmode { - // FIXME(#2202) --- We retain by-ref for fn& things to workaround a - // memory leak that otherwise results when @fn is upcast to &fn. + // FIXME(#2202) --- We retain by-ref for &fn things to workaround a + // memory leak that otherwise results when @fn is upcast to &fn. match ty::get(ty).sty { ty::ty_closure(ClosureTy {sigil: ast::BorrowedSigil, _}) => { return ast::by_ref; @@ -3124,7 +3124,6 @@ pub fn expr_kind(tcx: ctxt, ast::expr_tup(*) | ast::expr_if(*) | ast::expr_match(*) | - ast::expr_fn(*) | ast::expr_fn_block(*) | ast::expr_loop_body(*) | ast::expr_do_body(*) | diff --git a/src/librustc/middle/typeck/check/mod.rs b/src/librustc/middle/typeck/check/mod.rs index 570793e1b437..f724a442902f 100644 --- a/src/librustc/middle/typeck/check/mod.rs +++ b/src/librustc/middle/typeck/check/mod.rs @@ -389,7 +389,7 @@ pub fn check_fn(ccx: @mut CrateCtxt, self_info: Option) { let tcx = fcx.ccx.tcx; - let assign = fn@(nid: ast::node_id, ty_opt: Option) { + let assign: @fn(ast::node_id, Option) = |nid, ty_opt| { match ty_opt { None => { // infer the variable's type @@ -432,8 +432,8 @@ pub fn check_fn(ccx: @mut CrateCtxt, } // Add explicitly-declared locals. - let visit_local = fn@(local: @ast::local, - &&e: (), v: visit::vt<()>) { + let visit_local: @fn(@ast::local, &&e: (), visit::vt<()>) = + |local, e, v| { let o_ty = match local.node.ty.node { ast::ty_infer => None, _ => Some(fcx.to_ty(local.node.ty)) @@ -447,7 +447,7 @@ pub fn check_fn(ccx: @mut CrateCtxt, }; // Add pattern bindings. - let visit_pat = fn@(p: @ast::pat, &&e: (), v: visit::vt<()>) { + let visit_pat: @fn(@ast::pat, &&e: (), visit::vt<()>) = |p, e, v| { match p.node { ast::pat_ident(_, path, _) if pat_util::pat_is_binding(fcx.ccx.tcx.def_map, p) => { @@ -462,7 +462,7 @@ pub fn check_fn(ccx: @mut CrateCtxt, visit::visit_pat(p, e, v); }; - let visit_block = fn@(b: &ast::blk, &&e: (), v: visit::vt<()>) { + let visit_block: @fn(&ast::blk, &&e: (), visit::vt<()>) = |b, e, v| { // non-obvious: the `blk` variable maps to region lb, so // we have to keep this up-to-date. This // is... unfortunate. It'd be nice to not need this. @@ -2373,10 +2373,6 @@ pub fn check_expr_with_unifier(fcx: @mut FnCtxt, ast::expr_match(discrim, ref arms) => { bot = _match::check_match(fcx, expr, discrim, (/*bad*/copy *arms)); } - ast::expr_fn(sigil, ref decl, ref body, _) => { - check_expr_fn(fcx, expr, Some(sigil), - decl, body, Vanilla, expected); - } ast::expr_fn_block(ref decl, ref body) => { check_expr_fn(fcx, expr, None, decl, body, Vanilla, expected); diff --git a/src/librustc/middle/typeck/check/regionck.rs b/src/librustc/middle/typeck/check/regionck.rs index 1f2dfe7192fb..8a7726650722 100644 --- a/src/librustc/middle/typeck/check/regionck.rs +++ b/src/librustc/middle/typeck/check/regionck.rs @@ -282,7 +282,7 @@ pub fn visit_expr(expr: @ast::expr, &&rcx: @mut Rcx, v: rvt) { guarantor::for_match(rcx, discr, *arms); } - ast::expr_fn(*) | ast::expr_fn_block(*) => { + ast::expr_fn_block(*) => { let function_type = rcx.resolve_node_type(expr.id); match ty::get(function_type).sty { ty::ty_closure(ty::ClosureTy {sigil: ast::BorrowedSigil, @@ -708,7 +708,6 @@ pub mod guarantor { ast::expr_tup(*) | ast::expr_if(*) | ast::expr_match(*) | - ast::expr_fn(*) | ast::expr_fn_block(*) | ast::expr_loop_body(*) | ast::expr_do_body(*) | diff --git a/src/librustc/middle/typeck/check/vtable.rs b/src/librustc/middle/typeck/check/vtable.rs index 2dbf74e1666b..b2d399ac8da4 100644 --- a/src/librustc/middle/typeck/check/vtable.rs +++ b/src/librustc/middle/typeck/check/vtable.rs @@ -24,10 +24,10 @@ use util::common::indenter; use util::ppaux::tys_to_str; use util::ppaux; +use core::result::{Result, Ok, Err}; use core::result; use core::uint; use core::vec; -use result::{Result, Ok, Err}; use std::oldmap::HashMap; use syntax::ast; use syntax::ast_util; diff --git a/src/librustc/middle/typeck/infer/region_inference.rs b/src/librustc/middle/typeck/infer/region_inference.rs index d016a6f790a6..1ad89fe6f1e5 100644 --- a/src/librustc/middle/typeck/infer/region_inference.rs +++ b/src/librustc/middle/typeck/infer/region_inference.rs @@ -552,13 +552,12 @@ use util::ppaux::note_and_explain_region; use core::cell::{Cell, empty_cell}; use core::cmp; use core::dvec::DVec; +use core::result::{Err, Ok, Result}; use core::to_bytes; use core::uint; use core::vec; -use result::Result; -use result::{Ok, Err}; -use std::oldmap::HashMap; use std::list::{List, Nil, Cons}; +use std::oldmap::HashMap; use syntax::codemap::span; use syntax::codemap; diff --git a/src/librustc/rustc.rc b/src/librustc/rustc.rc index 140b52f03aaf..8ab6a07a9101 100644 --- a/src/librustc/rustc.rc +++ b/src/librustc/rustc.rc @@ -134,22 +134,22 @@ pub mod lib { pub mod llvm; } -use result::{Ok, Err}; -use io::ReaderUtil; -use std::getopts; -use std::oldmap::HashMap; -use getopts::{opt_present}; -use getopts::groups; -use syntax::codemap; -use syntax::diagnostic; -use driver::driver::{host_triple, optgroups, early_error, - str_input, file_input, build_session_options, - build_session, build_configuration, parse_pretty, - pp_mode, pretty_print_input, list_metadata, - compile_input}; +use driver::driver::{host_triple, optgroups, early_error}; +use driver::driver::{str_input, file_input, build_session_options}; +use driver::driver::{build_session, build_configuration, parse_pretty}; +use driver::driver::{pp_mode, pretty_print_input, list_metadata}; +use driver::driver::{compile_input}; use driver::session; use middle::lint; +use core::io::ReaderUtil; +use core::result::{Ok, Err}; +use std::getopts::{groups, opt_present}; +use std::getopts; +use std::oldmap::HashMap; +use syntax::codemap; +use syntax::diagnostic; + pub fn version(argv0: &str) { let mut vers = ~"unknown version"; let env_vers = env!("CFG_VERSION"); @@ -315,7 +315,7 @@ diagnostic emitter which records when we hit a fatal error. If the task fails without recording a fatal error then we've encountered a compiler bug and need to present an error. */ -pub fn monitor(+f: fn~(diagnostic::Emitter)) { +pub fn monitor(+f: ~fn(diagnostic::Emitter)) { use core::cell::Cell; use core::comm::*; let (p, ch) = stream(); @@ -326,8 +326,10 @@ pub fn monitor(+f: fn~(diagnostic::Emitter)) { let ch_capture = ch.clone(); // The 'diagnostics emitter'. Every error, warning, etc. should // go through this function. - let demitter = fn@(cmsp: Option<(@codemap::CodeMap, codemap::span)>, - msg: &str, lvl: diagnostic::level) { + let demitter: @fn(Option<(@codemap::CodeMap, codemap::span)>, + &str, + diagnostic::level) = + |cmsp, msg, lvl| { if lvl == diagnostic::fatal { ch_capture.send(fatal); } diff --git a/src/librustc/util/common.rs b/src/librustc/util/common.rs index 6357198fdf2c..8729ca5f6e17 100644 --- a/src/librustc/util/common.rs +++ b/src/librustc/util/common.rs @@ -59,7 +59,7 @@ pub fn field_exprs(fields: ~[ast::field]) -> ~[@ast::expr] { // Takes a predicate p, returns true iff p is true for any subexpressions // of b -- skipping any inner loops (loop, while, loop_body) -pub fn loop_query(b: &ast::blk, p: fn@(ast::expr_) -> bool) -> bool { +pub fn loop_query(b: &ast::blk, p: @fn(ast::expr_) -> bool) -> bool { let rs = @mut false; let visit_expr: @fn(@ast::expr, &&flag: @mut bool, @@ -82,7 +82,7 @@ pub fn loop_query(b: &ast::blk, p: fn@(ast::expr_) -> bool) -> bool { // Takes a predicate p, returns true iff p is true for any subexpressions // of b -- skipping any inner loops (loop, while, loop_body) -pub fn block_query(b: &ast::blk, p: fn@(@ast::expr) -> bool) -> bool { +pub fn block_query(b: &ast::blk, p: @fn(@ast::expr) -> bool) -> bool { let rs = @mut false; let visit_expr: @fn(@ast::expr, &&flag: @mut bool, diff --git a/src/librustdoc/astsrv.rs b/src/librustdoc/astsrv.rs index 1c45fdafa189..03410ee30fc7 100644 --- a/src/librustdoc/astsrv.rs +++ b/src/librustdoc/astsrv.rs @@ -46,12 +46,12 @@ pub struct Ctxt { ast_map: ast_map::map } -type SrvOwner = fn(srv: Srv) -> T; -pub type CtxtHandler = fn~(ctxt: Ctxt) -> T; -type Parser = fn~(Session, s: ~str) -> @ast::crate; +type SrvOwner = &fn(srv: Srv) -> T; +pub type CtxtHandler = ~fn(ctxt: Ctxt) -> T; +type Parser = ~fn(Session, s: ~str) -> @ast::crate; enum Msg { - HandleRequest(fn~(Ctxt)), + HandleRequest(~fn(Ctxt)), Exit } @@ -117,12 +117,10 @@ fn act(po: &Port, source: ~str, parse: Parser) { pub fn exec( srv: Srv, - f: fn~(ctxt: Ctxt) -> T + f: ~fn(ctxt: Ctxt) -> T ) -> T { let (po, ch) = stream(); - let msg = HandleRequest(fn~(ctxt: Ctxt) { - ch.send(f(ctxt)) - }); + let msg = HandleRequest(|ctxt| ch.send(f(ctxt))); srv.ch.send(msg); po.recv() } diff --git a/src/librustdoc/attr_pass.rs b/src/librustdoc/attr_pass.rs index 85ac952d6d48..28322450c4da 100644 --- a/src/librustdoc/attr_pass.rs +++ b/src/librustdoc/attr_pass.rs @@ -114,7 +114,7 @@ fn fold_item( fn parse_item_attrs( srv: astsrv::Srv, id: doc::AstId, - parse_attrs: fn~(a: ~[ast::attribute]) -> T) -> T { + parse_attrs: ~fn(a: ~[ast::attribute]) -> T) -> T { do astsrv::exec(srv) |ctxt| { let attrs = match ctxt.ast_map.get(&id) { ast_map::node_item(item, _) => copy item.attrs, diff --git a/src/librustdoc/config.rs b/src/librustdoc/config.rs index 0add79266302..21c0393f68f6 100644 --- a/src/librustdoc/config.rs +++ b/src/librustdoc/config.rs @@ -85,7 +85,7 @@ fn opts() -> ~[(getopts::Opt, ~str)] { } pub fn usage() { - use io::println; + use core::io::println; println(~"Usage: rustdoc [options] \n"); println(~"Options:\n"); @@ -105,7 +105,7 @@ pub fn default_config(input_crate: &Path) -> Config { } } -type Process = fn~((&str), (&[~str])) -> ProgramOutput; +type Process = ~fn((&str), (&[~str])) -> ProgramOutput; pub fn mock_program_output(_prog: &str, _args: &[~str]) -> ProgramOutput { ProgramOutput { @@ -262,11 +262,8 @@ fn should_find_pandoc() { output_format: PandocHtml, .. default_config(&Path("test")) }; - let mock_program_output = fn~(_prog: &str, _args: &[~str]) - -> ProgramOutput { - ProgramOutput { - status: 0, out: ~"pandoc 1.8.2.1", err: ~"" - } + let mock_program_output: ~fn(&str, &[~str]) -> ProgramOutput = |prog, _| { + ProgramOutput { status: 0, out: ~"pandoc 1.8.2.1", err: ~"" } }; let result = maybe_find_pandoc(&config, None, mock_program_output); assert result == result::Ok(Some(~"pandoc")); @@ -278,11 +275,8 @@ fn should_error_with_no_pandoc() { output_format: PandocHtml, .. default_config(&Path("test")) }; - let mock_program_output = fn~(_prog: &str, _args: &[~str]) - -> ProgramOutput { - ProgramOutput { - status: 1, out: ~"", err: ~"" - } + let mock_program_output: ~fn(&str, &[~str]) -> ProgramOutput = |_, _| { + ProgramOutput { status: 1, out: ~"", err: ~"" } }; let result = maybe_find_pandoc(&config, None, mock_program_output); assert result == result::Err(~"couldn't find pandoc"); diff --git a/src/librustdoc/markdown_index_pass.rs b/src/librustdoc/markdown_index_pass.rs index 42a7d0006db0..b37f8f8443e5 100644 --- a/src/librustdoc/markdown_index_pass.rs +++ b/src/librustdoc/markdown_index_pass.rs @@ -162,7 +162,6 @@ fn pandoc_header_id(header: &str) -> ~str { #[test] fn should_remove_punctuation_from_headers() { assert pandoc_header_id(~"impl foo of bar") == ~"impl-foo-of-bara"; - assert pandoc_header_id(~"fn@(~[~A])") == ~"fna"; assert pandoc_header_id(~"impl of num::num for int") == ~"impl-of-numnum-for-int"; assert pandoc_header_id(~"impl of num::num for int/&") diff --git a/src/librustdoc/markdown_writer.rs b/src/librustdoc/markdown_writer.rs index 45a8aa9fd292..020073f9b89d 100644 --- a/src/librustdoc/markdown_writer.rs +++ b/src/librustdoc/markdown_writer.rs @@ -34,8 +34,8 @@ pub enum WriteInstr { Done } -pub type Writer = fn~(v: WriteInstr); -pub type WriterFactory = fn~(page: doc::Page) -> Writer; +pub type Writer = ~fn(v: WriteInstr); +pub type WriterFactory = ~fn(page: doc::Page) -> Writer; pub trait WriterUtils { fn write_str(&self, +str: ~str); @@ -69,15 +69,17 @@ pub fn make_writer_factory(config: config::Config) -> WriterFactory { } fn markdown_writer_factory(config: config::Config) -> WriterFactory { - fn~(page: doc::Page) -> Writer { + let result: ~fn(page: doc::Page) -> Writer = |page| { markdown_writer(copy config, page) - } + }; + result } fn pandoc_writer_factory(config: config::Config) -> WriterFactory { - fn~(page: doc::Page) -> Writer { + let result: ~fn(doc::Page) -> Writer = |page| { pandoc_writer(copy config, page) - } + }; + result } fn markdown_writer( @@ -108,7 +110,7 @@ fn pandoc_writer( ]; do generic_writer |markdown| { - use io::WriterUtil; + use core::io::WriterUtil; debug!("pandoc cmd: %s", pandoc_cmd); debug!("pandoc args: %s", str::connect(pandoc_args, ~" ")); @@ -167,7 +169,7 @@ fn readclose(fd: libc::c_int) -> ~str { } } -fn generic_writer(process: fn~(markdown: ~str)) -> Writer { +fn generic_writer(process: ~fn(markdown: ~str)) -> Writer { let (po, ch) = stream::(); do task::spawn || { let mut markdown = ~""; @@ -180,9 +182,8 @@ fn generic_writer(process: fn~(markdown: ~str)) -> Writer { } process(markdown); }; - fn~(instr: WriteInstr) { - ch.send(instr); - } + let result: ~fn(instr: WriteInstr) = |instr| ch.send(instr); + result } fn make_local_filename( @@ -281,7 +282,7 @@ mod test { } fn write_file(path: &Path, s: ~str) { - use io::WriterUtil; + use core::io::WriterUtil; match io::file_writer(path, ~[io::Create, io::Truncate]) { result::Ok(writer) => { @@ -295,7 +296,7 @@ pub fn future_writer_factory( ) -> (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_factory: WriterFactory = |page| { let (writer_po, writer_ch) = comm::stream(); let markdown_ch = markdown_ch.clone(); do task::spawn || { @@ -312,9 +313,7 @@ pub fn future_writer_factory( fn future_writer() -> (Writer, future::Future<~str>) { let (port, chan) = comm::stream(); - let writer = fn~(instr: WriteInstr) { - chan.send(copy instr); - }; + let writer: ~fn(instr: WriteInstr) = |instr| chan.send(copy instr); let future = do future::from_fn || { let mut res = ~""; loop { diff --git a/src/librustdoc/rustdoc.rc b/src/librustdoc/rustdoc.rc index fc0ea4ce3960..54f1a779bcc6 100644 --- a/src/librustdoc/rustdoc.rc +++ b/src/librustdoc/rustdoc.rc @@ -31,41 +31,41 @@ extern mod syntax(vers = "0.6"); use core::*; use std::par; -mod pass; -mod config; -mod parse; -mod extract; -mod attr_parser; -mod doc; -mod markdown_index_pass; -mod markdown_pass; -mod markdown_writer; -mod fold; -mod path_pass; -mod attr_pass; -mod tystr_pass; -mod prune_hidden_pass; -mod desc_to_brief_pass; -mod text_pass; -mod unindent_pass; -mod trim_pass; -mod astsrv; -mod demo; -mod sort_pass; -mod sort_item_name_pass; -mod sort_item_type_pass; -mod page_pass; -mod sectionalize_pass; -mod escape_pass; -mod prune_private_pass; -mod util; +pub mod pass; +pub mod config; +pub mod parse; +pub mod extract; +pub mod attr_parser; +pub mod doc; +pub mod markdown_index_pass; +pub mod markdown_pass; +pub mod markdown_writer; +pub mod fold; +pub mod path_pass; +pub mod attr_pass; +pub mod tystr_pass; +pub mod prune_hidden_pass; +pub mod desc_to_brief_pass; +pub mod text_pass; +pub mod unindent_pass; +pub mod trim_pass; +pub mod astsrv; +pub mod demo; +pub mod sort_pass; +pub mod sort_item_name_pass; +pub mod sort_item_type_pass; +pub mod page_pass; +pub mod sectionalize_pass; +pub mod escape_pass; +pub mod prune_private_pass; +pub mod util; use doc::ItemUtils; use doc::Item; use pass::Pass; use config::Config; -fn main() { +pub fn main() { let args = os::args(); if args.contains(&~"-h") || args.contains(&~"--help") { @@ -144,7 +144,7 @@ fn run(config: Config) { } } -fn time(what: ~str, f: fn() -> T) -> T { +pub fn time(what: ~str, f: fn() -> T) -> T { let start = std::time::precise_time_s(); let rv = f(); let end = std::time::precise_time_s(); diff --git a/src/librustpkg/rustpkg.rc b/src/librustpkg/rustpkg.rc index b58b5977f97e..603480f907c0 100644 --- a/src/librustpkg/rustpkg.rc +++ b/src/librustpkg/rustpkg.rc @@ -27,14 +27,14 @@ extern mod rustc(vers = "0.6"); extern mod syntax(vers = "0.6"); use core::*; -use io::{ReaderUtil, WriterUtil}; -use std::{json, semver, getopts}; -use std::net::url; -use hashmap::linear::LinearMap; -use rustc::metadata::filesearch; +use core::hashmap::linear::LinearMap; +use core::io::{ReaderUtil, WriterUtil}; use rustc::driver::{driver, session}; -use syntax::{ast, attr, codemap, diagnostic, parse, visit}; +use rustc::metadata::filesearch; +use std::net::url; +use std::{json, semver, getopts}; use syntax::codemap::spanned; +use syntax::{ast, attr, codemap, diagnostic, parse, visit}; mod usage; mod util; @@ -926,7 +926,7 @@ pub struct Crate { pub struct Listener { cmds: ~[~str], - cb: fn~() + cb: ~fn() } pub fn run(listeners: ~[Listener]) { diff --git a/src/librustpkg/util.rs b/src/librustpkg/util.rs index fdabe86359a6..bd2dd102e45c 100644 --- a/src/librustpkg/util.rs +++ b/src/librustpkg/util.rs @@ -8,20 +8,20 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -use core::*; -use hashmap::linear::LinearMap; -use rustc::metadata::filesearch; -use rustc::driver::{driver, session}; -use syntax::ast_util::*; -use syntax::{ast, attr, codemap, diagnostic, fold, parse, visit}; -use codemap::{span, dummy_sp, spanned}; -use std::semver; -use std::{json, term, sort, getopts}; -use getopts::groups::getopts; use Listener; +use core::*; +use core::hashmap::linear::LinearMap; +use rustc::driver::{driver, session}; +use rustc::metadata::filesearch; +use std::getopts::groups::getopts; +use std::semver; +use std::{json, term, sort, getopts}; +use syntax::ast_util::*; +use syntax::codemap::{span, dummy_sp, spanned}; use syntax::ext::base::{mk_ctxt, ext_ctxt}; use syntax::ext::build; +use syntax::{ast, attr, codemap, diagnostic, fold, parse, visit}; pub struct Package { id: ~str, diff --git a/src/libstd/bigint.rs b/src/libstd/bigint.rs index 23a4769775c0..5212a17f3737 100644 --- a/src/libstd/bigint.rs +++ b/src/libstd/bigint.rs @@ -865,7 +865,7 @@ pub impl BigInt { mod biguint_tests { use core::*; - use num::{IntConvertible, Zero, One}; + use core::num::{IntConvertible, Zero, One}; use super::{BigInt, BigUint, BigDigit}; #[test] diff --git a/src/libstd/c_vec.rs b/src/libstd/c_vec.rs index 5af596c1f84e..30538a129425 100644 --- a/src/libstd/c_vec.rs +++ b/src/libstd/c_vec.rs @@ -53,7 +53,7 @@ pub struct CVec { } struct DtorRes { - dtor: Option, + dtor: Option<@fn()>, } impl Drop for DtorRes { @@ -65,7 +65,7 @@ impl Drop for DtorRes { } } -fn DtorRes(dtor: Option) -> DtorRes { +fn DtorRes(dtor: Option<@fn()>) -> DtorRes { DtorRes { dtor: dtor } @@ -102,7 +102,7 @@ pub unsafe fn CVec(base: *mut T, len: uint) -> CVec { * * dtor - A function to run when the value is destructed, useful * for freeing the buffer, etc. */ -pub unsafe fn c_vec_with_dtor(base: *mut T, len: uint, dtor: fn@()) +pub unsafe fn c_vec_with_dtor(base: *mut T, len: uint, dtor: @fn()) -> CVec { return CVec{ base: base, diff --git a/src/libstd/flatpipes.rs b/src/libstd/flatpipes.rs index 73dbe4bea574..42f954f7c390 100644 --- a/src/libstd/flatpipes.rs +++ b/src/libstd/flatpipes.rs @@ -771,10 +771,10 @@ mod test { writer_chan: WriterChanFactory, port: uint) { - use net::tcp; + use core::cell::Cell; use net::ip; - use cell::Cell; use net::tcp::TcpSocket; + use net::tcp; use uv; // Indicate to the client task that the server is listening diff --git a/src/libstd/future.rs b/src/libstd/future.rs index c57754061259..990c37ce807e 100644 --- a/src/libstd/future.rs +++ b/src/libstd/future.rs @@ -37,13 +37,13 @@ pub struct Future { } // FIXME(#2829) -- futures should not be copyable, because they close -// over fn~'s that have pipes and so forth within! +// over ~fn's that have pipes and so forth within! impl Drop for Future { fn finalize(&self) {} } priv enum FutureState { - Pending(fn~() -> A), + Pending(~fn() -> A), Evaluating, Forced(A) } @@ -125,7 +125,7 @@ pub fn from_fn(f: ~fn() -> A) -> Future { Future {state: Pending(f)} } -pub fn spawn(blk: fn~() -> A) -> Future { +pub fn spawn(blk: ~fn() -> A) -> Future { /*! * Create a future from a unique closure. * diff --git a/src/libstd/net_tcp.rs b/src/libstd/net_tcp.rs index 4266cab0a056..5b116705698f 100644 --- a/src/libstd/net_tcp.rs +++ b/src/libstd/net_tcp.rs @@ -625,8 +625,8 @@ pub fn accept(new_conn: TcpNewConnection) */ pub fn listen(host_ip: ip::IpAddr, port: uint, backlog: uint, iotask: &IoTask, - on_establish_cb: fn~(SharedChan>), - new_connect_cb: fn~(TcpNewConnection, + on_establish_cb: ~fn(SharedChan>), + new_connect_cb: ~fn(TcpNewConnection, SharedChan>)) -> result::Result<(), TcpListenErrData> { do listen_common(host_ip, port, backlog, iotask, @@ -643,11 +643,13 @@ pub fn listen(host_ip: ip::IpAddr, port: uint, backlog: uint, } } -fn listen_common(host_ip: ip::IpAddr, port: uint, backlog: uint, - iotask: &IoTask, - on_establish_cb: fn~(SharedChan>), - on_connect_cb: fn~(*uv::ll::uv_tcp_t)) - -> result::Result<(), TcpListenErrData> { +fn listen_common(host_ip: ip::IpAddr, + port: uint, + backlog: uint, + iotask: &IoTask, + on_establish_cb: ~fn(SharedChan>), + on_connect_cb: ~fn(*uv::ll::uv_tcp_t)) + -> result::Result<(), TcpListenErrData> { unsafe { let (stream_closed_po, stream_closed_ch) = stream::<()>(); let stream_closed_ch = SharedChan(stream_closed_ch); @@ -1197,7 +1199,7 @@ struct TcpListenFcData { server_stream_ptr: *uv::ll::uv_tcp_t, stream_closed_ch: SharedChan<()>, kill_ch: SharedChan>, - on_connect_cb: fn~(*uv::ll::uv_tcp_t), + on_connect_cb: ~fn(*uv::ll::uv_tcp_t), iotask: IoTask, ipv6: bool, mut active: bool, diff --git a/src/libstd/par.rs b/src/libstd/par.rs index 0839ce181235..d65921f910cb 100644 --- a/src/libstd/par.rs +++ b/src/libstd/par.rs @@ -94,24 +94,24 @@ pub fn map( xs: &[A], fn_factory: &fn() -> ~fn(&A) -> B) -> ~[B] { vec::concat(map_slices(xs, || { let f = fn_factory(); - fn~(_base: uint, slice : &[A]) -> ~[B] { - vec::map(slice, |x| f(x)) - } + let result: ~fn(uint, &[A]) -> ~[B] = + |_, slice| vec::map(slice, |x| f(x)); + result })) } /// A parallel version of mapi. pub fn mapi( - xs: &[A], - fn_factory: &fn() -> ~fn(uint, &A) -> B) -> ~[B] -{ + xs: &[A], + fn_factory: &fn() -> ~fn(uint, &A) -> B) -> ~[B] { let slices = map_slices(xs, || { let f = fn_factory(); - fn~(base: uint, slice : &[A]) -> ~[B] { + let result: ~fn(uint, &[A]) -> ~[B] = |base, slice| { vec::mapi(slice, |i, x| { f(i + base, x) }) - } + }; + result }); let r = vec::concat(slices); log(info, (r.len(), xs.len())); @@ -126,11 +126,12 @@ pub fn alli( { do vec::all(map_slices(xs, || { let f = fn_factory(); - fn~(base: uint, slice : &[A]) -> bool { + let result: ~fn(uint, &[A]) -> bool = |base, slice| { vec::alli(slice, |i, x| { f(i + base, x) }) - } + }; + result })) |x| { *x } } @@ -140,8 +141,8 @@ pub fn any( fn_factory: &fn() -> ~fn(&A) -> bool) -> bool { do vec::any(map_slices(xs, || { let f = fn_factory(); - fn~(_base : uint, slice: &[A]) -> bool { - vec::any(slice, |x| f(x)) - } + let result: ~fn(uint, &[A]) -> bool = + |_, slice| vec::any(slice, |x| f(x)); + result })) |x| { *x } } diff --git a/src/libstd/semver.rs b/src/libstd/semver.rs index 5f96687127ca..7c7f3390f2e9 100644 --- a/src/libstd/semver.rs +++ b/src/libstd/semver.rs @@ -10,14 +10,14 @@ //! Semver parsing and logic -use io; -use io::{ReaderUtil}; -use option::{Option, Some, None}; -use uint; -use str; -use to_str::ToStr; -use char; +use core::char; use core::cmp; +use core::io::{ReaderUtil}; +use core::io; +use core::option::{Option, Some, None}; +use core::str; +use core::to_str::ToStr; +use core::uint; #[deriving_eq] pub enum Identifier { diff --git a/src/libstd/std.rc b/src/libstd/std.rc index 2f6c4e3f1904..f29872bf3871 100644 --- a/src/libstd/std.rc +++ b/src/libstd/std.rc @@ -113,7 +113,7 @@ pub mod serialize; // 'std' so that macro-expanded references to std::serialize and such // can be resolved within libcore. #[doc(hidden)] // FIXME #3538 -mod std { +pub mod std { pub use serialize; pub use test; } diff --git a/src/libstd/test.rs b/src/libstd/test.rs index 49a8dff4a962..4ffa9b01d2b1 100644 --- a/src/libstd/test.rs +++ b/src/libstd/test.rs @@ -409,7 +409,7 @@ type MonitorMsg = (TestDesc, TestResult); fn run_tests(opts: &TestOpts, tests: ~[TestDescAndFn], - callback: fn@(e: TestEvent)) { + callback: @fn(e: TestEvent)) { let mut filtered_tests = filter_tests(opts, tests); let filtered_descs = filtered_tests.map(|t| t.desc); @@ -537,7 +537,7 @@ pub fn filter_tests( struct TestFuture { test: TestDesc, - wait: fn@() -> TestResult, + wait: @fn() -> TestResult, } pub fn run_test(force_ignore: bool, @@ -594,15 +594,14 @@ fn calc_result(desc: &TestDesc, task_succeeded: bool) -> TestResult { } pub mod bench { - - use rand; - use u64; - use vec; use time::precise_time_ns; use test::{BenchHarness, BenchSamples}; use stats::Stats; - use num; - use rand; + + use core::num; + use core::rand; + use core::u64; + use core::vec; pub impl BenchHarness { @@ -783,7 +782,7 @@ mod tests { ignore: true, should_fail: false }, - testfn: DynTestFn(fn~() { f()}), + testfn: DynTestFn(|| f()), }; let (p, ch) = stream(); let ch = SharedChan(ch); @@ -801,7 +800,7 @@ mod tests { ignore: true, should_fail: false }, - testfn: DynTestFn(fn~() { f()}), + testfn: DynTestFn(|| f()), }; let (p, ch) = stream(); let ch = SharedChan(ch); @@ -820,7 +819,7 @@ mod tests { ignore: false, should_fail: true }, - testfn: DynTestFn(fn~() { f() }), + testfn: DynTestFn(|| f()), }; let (p, ch) = stream(); let ch = SharedChan(ch); @@ -838,7 +837,7 @@ mod tests { ignore: false, should_fail: true }, - testfn: DynTestFn(fn~() { f() }), + testfn: DynTestFn(|| f()), }; let (p, ch) = stream(); let ch = SharedChan(ch); @@ -891,7 +890,7 @@ mod tests { ignore: true, should_fail: false, }, - testfn: DynTestFn(fn~() { }), + testfn: DynTestFn(|| {}), }, TestDescAndFn { desc: TestDesc { @@ -899,7 +898,7 @@ mod tests { ignore: false, should_fail: false }, - testfn: DynTestFn(fn~() { }), + testfn: DynTestFn(|| {}), }, ]; let filtered = filter_tests(&opts, tests); diff --git a/src/libstd/timer.rs b/src/libstd/timer.rs index b711825aecf7..7bd411315b22 100644 --- a/src/libstd/timer.rs +++ b/src/libstd/timer.rs @@ -221,7 +221,7 @@ mod test { let ch = ch.clone(); let hl_loop_clone = hl_loop.clone(); do task::spawn { - use rand::*; + use core::rand::*; let rng = Rng(); for iter::repeat(times) { sleep(&hl_loop_clone, rng.next() as uint % maxms); diff --git a/src/libstd/uv_global_loop.rs b/src/libstd/uv_global_loop.rs index 52cfc078bace..daf90f345e05 100644 --- a/src/libstd/uv_global_loop.rs +++ b/src/libstd/uv_global_loop.rs @@ -12,21 +12,20 @@ use ll = uv_ll; use iotask = uv_iotask; -use get_gl = get; +use get_gl = self::get; use uv_iotask::{IoTask, spawn_iotask}; +use core::clone::Clone; +use core::comm::{Port, Chan, SharedChan, select2i}; use core::either::{Left, Right}; use core::libc; -use core::comm::{Port, Chan, SharedChan, select2i}; -use core::unstable::global::{global_data_clone_create, - global_data_clone}; -use core::unstable::weak_task::weaken_task; +use core::option::{Some, None}; use core::str; use core::task::{task, SingleThreaded, spawn}; use core::task; +use core::unstable::global::{global_data_clone_create, global_data_clone}; +use core::unstable::weak_task::weaken_task; use core::vec; -use core::clone::Clone; -use core::option::{Some, None}; /** * Race-free helper to get access to a global task where a libuv @@ -98,7 +97,7 @@ fn get_monitor_task_gl() -> IoTask { fn spawn_loop() -> IoTask { let builder = do task().add_wrapper |task_body| { - fn~() { + let result: ~fn() = || { // The I/O loop task also needs to be weak so it doesn't keep // the runtime alive unsafe { @@ -113,7 +112,8 @@ fn spawn_loop() -> IoTask { debug!("global libuv task is leaving weakened state"); } } - } + }; + result }; let builder = builder.unlinked(); spawn_iotask(builder) @@ -123,7 +123,7 @@ fn spawn_loop() -> IoTask { mod test { use core::prelude::*; - use get_gl = get; + use get_gl = uv_global_loop::get; use uv::iotask; use uv::ll; use uv_global_loop::*; diff --git a/src/libstd/uv_iotask.rs b/src/libstd/uv_iotask.rs index 14726a0854de..6179b10f3c37 100644 --- a/src/libstd/uv_iotask.rs +++ b/src/libstd/uv_iotask.rs @@ -76,8 +76,7 @@ pub fn spawn_iotask(task: task::TaskBuilder) -> IoTask { * module. It is not safe to send the `loop_ptr` param to this callback out * via ports/chans. */ -pub unsafe fn interact(iotask: &IoTask, - cb: fn~(*c_void)) { +pub unsafe fn interact(iotask: &IoTask, cb: ~fn(*c_void)) { send_msg(iotask, Interaction(cb)); } @@ -98,7 +97,7 @@ pub fn exit(iotask: &IoTask) { // INTERNAL API enum IoTaskMsg { - Interaction (fn~(*libc::c_void)), + Interaction(~fn(*libc::c_void)), TeardownLoop } diff --git a/src/libstd/workcache.rs b/src/libstd/workcache.rs index 592ac40e0824..7f47db375041 100644 --- a/src/libstd/workcache.rs +++ b/src/libstd/workcache.rs @@ -396,7 +396,7 @@ fn unwrap + Decodable>( //#[test] fn test() { - use io::WriterUtil; + use core::io::WriterUtil; let db = @Mut(Database { db_filename: Path("db.json"), db_cache: LinearMap::new(), diff --git a/src/libsyntax/ast.rs b/src/libsyntax/ast.rs index 1053473a3a58..cec35b429b43 100644 --- a/src/libsyntax/ast.rs +++ b/src/libsyntax/ast.rs @@ -571,10 +571,6 @@ pub enum expr_ { (implicit) condition is always true. */ expr_loop(blk, Option), expr_match(@expr, ~[arm]), - - // FIXME(#4717) the @() is req'd on windows or else LLVM croaks - expr_fn(Sigil, fn_decl, blk, @()), - expr_fn_block(fn_decl, blk), // Inner expr is always an expr_fn_block. We need the wrapping node to // easily type this (a function returning nil on the inside but bool on diff --git a/src/libsyntax/ast_util.rs b/src/libsyntax/ast_util.rs index 7e0cd2640b2c..96f4dadb3dbe 100644 --- a/src/libsyntax/ast_util.rs +++ b/src/libsyntax/ast_util.rs @@ -396,8 +396,8 @@ pub fn empty(range: id_range) -> bool { range.min >= range.max } -pub fn id_visitor(vfn: fn@(node_id)) -> visit::vt<()> { - let visit_generics = fn@(generics: &Generics) { +pub fn id_visitor(vfn: @fn(node_id)) -> visit::vt<()> { + let visit_generics: @fn(&Generics) = |generics| { for generics.ty_params.each |p| { vfn(p.id); } @@ -408,7 +408,7 @@ pub fn id_visitor(vfn: fn@(node_id)) -> visit::vt<()> { visit::mk_simple_visitor(@visit::SimpleVisitor { visit_mod: |_m, _sp, id| vfn(id), - visit_view_item: fn@(vi: @view_item) { + visit_view_item: |vi| { match vi.node { view_item_extern_mod(_, _, id) => vfn(id), view_item_use(ref vps) => { @@ -423,11 +423,9 @@ pub fn id_visitor(vfn: fn@(node_id)) -> visit::vt<()> { } }, - visit_foreign_item: fn@(ni: @foreign_item) { - vfn(ni.id) - }, + visit_foreign_item: |ni| vfn(ni.id), - visit_item: fn@(i: @item) { + visit_item: |i| { vfn(i.id); match i.node { item_enum(ref enum_definition, _) => @@ -436,36 +434,21 @@ pub fn id_visitor(vfn: fn@(node_id)) -> visit::vt<()> { } }, - visit_local: fn@(l: @local) { - vfn(l.node.id); - }, + visit_local: |l| vfn(l.node.id), + visit_block: |b| vfn(b.node.id), + visit_stmt: |s| vfn(ast_util::stmt_id(*s)), + visit_arm: |_| {}, + visit_pat: |p| vfn(p.id), + visit_decl: |_| {}, - visit_block: fn@(b: &blk) { - vfn(b.node.id); - }, - - visit_stmt: fn@(s: @stmt) { - vfn(ast_util::stmt_id(*s)); - }, - - visit_arm: fn@(_a: &arm) { }, - - visit_pat: fn@(p: @pat) { - vfn(p.id) - }, - - visit_decl: fn@(_d: @decl) { - }, - - visit_expr: fn@(e: @expr) { + visit_expr: |e| { vfn(e.callee_id); vfn(e.id); }, - visit_expr_post: fn@(_e: @expr) { - }, + visit_expr_post: |_| {}, - visit_ty: fn@(t: @Ty) { + visit_ty: |t| { match t.node { ty_path(_, id) => vfn(id), _ => { /* fall through */ } @@ -474,8 +457,7 @@ pub fn id_visitor(vfn: fn@(node_id)) -> visit::vt<()> { visit_generics: visit_generics, - visit_fn: fn@(fk: &visit::fn_kind, d: &ast::fn_decl, - _b: &ast::blk, _sp: span, id: ast::node_id) { + visit_fn: |fk, d, _, _, id| { vfn(id); match *fk { @@ -502,32 +484,19 @@ pub fn id_visitor(vfn: fn@(node_id)) -> visit::vt<()> { } }, - visit_ty_method: fn@(_ty_m: &ty_method) { - }, - - visit_trait_method: fn@(_ty_m: &trait_method) { - }, - - visit_struct_def: fn@(_sd: @struct_def, - _id: ident, - _generics: &Generics, - _id: node_id) { - }, - - visit_struct_field: fn@(f: @struct_field) { - vfn(f.node.id); - }, - - visit_struct_method: fn@(_m: @method) { - } + visit_ty_method: |_| {}, + visit_trait_method: |_| {}, + visit_struct_def: |_, _, _, _| {}, + visit_struct_field: |f| vfn(f.node.id), + visit_struct_method: |_| {} }) } -pub fn visit_ids_for_inlined_item(item: inlined_item, vfn: fn@(node_id)) { +pub fn visit_ids_for_inlined_item(item: inlined_item, vfn: @fn(node_id)) { item.accept((), id_visitor(vfn)); } -pub fn compute_id_range(visit_ids_fn: fn(fn@(node_id))) -> id_range { +pub fn compute_id_range(visit_ids_fn: &fn(@fn(node_id))) -> id_range { let min = @mut int::max_value; let max = @mut int::min_value; do visit_ids_fn |id| { diff --git a/src/libsyntax/diagnostic.rs b/src/libsyntax/diagnostic.rs index 27483ae94a5b..ba4ec7fb6db2 100644 --- a/src/libsyntax/diagnostic.rs +++ b/src/libsyntax/diagnostic.rs @@ -23,8 +23,9 @@ use core::dvec::DVec; use std::term; -pub type Emitter = fn@(cmsp: Option<(@codemap::CodeMap, span)>, - msg: &str, lvl: level); +pub type Emitter = @fn(cmsp: Option<(@codemap::CodeMap, span)>, + msg: &str, + lvl: level); // a handler deals with errors; certain errors // (fatal, bug, unimpl) may cause immediate exit, @@ -204,8 +205,7 @@ fn print_diagnostic(topic: ~str, lvl: level, msg: &str) { } pub fn collect(messages: @DVec<~str>) - -> fn@(Option<(@codemap::CodeMap, span)>, &str, level) -{ + -> @fn(Option<(@codemap::CodeMap, span)>, &str, level) { let f: @fn(Option<(@codemap::CodeMap, span)>, &str, level) = |_o, msg: &str, _l| { messages.push(msg.to_str()); }; f diff --git a/src/libsyntax/ext/base.rs b/src/libsyntax/ext/base.rs index 7d3c7cafa952..b3d3358e5861 100644 --- a/src/libsyntax/ext/base.rs +++ b/src/libsyntax/ext/base.rs @@ -37,29 +37,39 @@ pub struct MacroDef { ext: SyntaxExtension } -pub type ItemDecorator = - fn@(ext_ctxt, span, @ast::meta_item, ~[@ast::item]) -> ~[@ast::item]; +pub type ItemDecorator = @fn(ext_ctxt, + span, + @ast::meta_item, + ~[@ast::item]) + -> ~[@ast::item]; pub struct SyntaxExpanderTT { expander: SyntaxExpanderTTFun, span: Option } -pub type SyntaxExpanderTTFun - = fn@(ext_ctxt, span, &[ast::token_tree]) -> MacResult; +pub type SyntaxExpanderTTFun = @fn(ext_ctxt, + span, + &[ast::token_tree]) + -> MacResult; pub struct SyntaxExpanderTTItem { expander: SyntaxExpanderTTItemFun, span: Option } -pub type SyntaxExpanderTTItemFun - = fn@(ext_ctxt, span, ast::ident, ~[ast::token_tree]) -> MacResult; +pub type SyntaxExpanderTTItemFun = @fn(ext_ctxt, + span, + ast::ident, + ~[ast::token_tree]) + -> MacResult; pub enum MacResult { MRExpr(@ast::expr), MRItem(@ast::item), - MRAny(fn@()-> @ast::expr, fn@()-> Option<@ast::item>, fn@()->@ast::stmt), + MRAny(@fn() -> @ast::expr, + @fn() -> Option<@ast::item>, + @fn() -> @ast::stmt), MRDef(MacroDef) } diff --git a/src/libsyntax/ext/env.rs b/src/libsyntax/ext/env.rs index 91a9de9c051e..c8fb83224ac7 100644 --- a/src/libsyntax/ext/env.rs +++ b/src/libsyntax/ext/env.rs @@ -15,7 +15,7 @@ * interface. */ -use prelude::*; +use core::prelude::*; use ast; use codemap::span; diff --git a/src/libsyntax/ext/expand.rs b/src/libsyntax/ext/expand.rs index e3408a47c9a4..858ce4b17a3e 100644 --- a/src/libsyntax/ext/expand.rs +++ b/src/libsyntax/ext/expand.rs @@ -26,9 +26,12 @@ use core::option; use core::vec; use core::hashmap::LinearMap; -pub fn expand_expr(extsbox: @mut SyntaxEnv, cx: ext_ctxt, - e: &expr_, s: span, fld: ast_fold, - orig: fn@(&expr_, span, ast_fold) -> (expr_, span)) +pub fn expand_expr(extsbox: @mut SyntaxEnv, + cx: ext_ctxt, + e: &expr_, + s: span, + fld: ast_fold, + orig: @fn(&expr_, span, ast_fold) -> (expr_, span)) -> (expr_, span) { match *e { // expr_mac should really be expr_ext or something; it's the @@ -105,9 +108,11 @@ pub fn expand_expr(extsbox: @mut SyntaxEnv, cx: ext_ctxt, // // NB: there is some redundancy between this and expand_item, below, and // they might benefit from some amount of semantic and language-UI merger. -pub fn expand_mod_items(extsbox: @mut SyntaxEnv, cx: ext_ctxt, - module_: &ast::_mod, fld: ast_fold, - orig: fn@(&ast::_mod, ast_fold) -> ast::_mod) +pub fn expand_mod_items(extsbox: @mut SyntaxEnv, + cx: ext_ctxt, + module_: &ast::_mod, + fld: ast_fold, + orig: @fn(&ast::_mod, ast_fold) -> ast::_mod) -> ast::_mod { // Fold the contents first: let module_ = orig(module_, fld); @@ -155,8 +160,10 @@ macro_rules! with_exts_frame ( // When we enter a module, record it, for the sake of `module!` pub fn expand_item(extsbox: @mut SyntaxEnv, - cx: ext_ctxt, it: @ast::item, fld: ast_fold, - orig: fn@(@ast::item, ast_fold) -> Option<@ast::item>) + cx: ext_ctxt, + it: @ast::item, + fld: ast_fold, + orig: @fn(@ast::item, ast_fold) -> Option<@ast::item>) -> Option<@ast::item> { // need to do expansion first... it might turn out to be a module. let maybe_it = match it.node { @@ -296,11 +303,13 @@ pub fn expand_item_mac(+extsbox: @mut SyntaxEnv, } // expand a stmt -pub fn expand_stmt(extsbox: @mut SyntaxEnv, cx: ext_ctxt, - s: &stmt_, sp: span, fld: ast_fold, - orig: fn@(s: &stmt_, span, ast_fold) -> (stmt_, span)) +pub fn expand_stmt(extsbox: @mut SyntaxEnv, + cx: ext_ctxt, + s: &stmt_, + sp: span, + fld: ast_fold, + orig: @fn(&stmt_, span, ast_fold) -> (stmt_, span)) -> (stmt_, span) { - let (mac, pth, tts, semi) = match *s { stmt_mac(ref mac, semi) => { match mac.node { @@ -356,10 +365,13 @@ pub fn expand_stmt(extsbox: @mut SyntaxEnv, cx: ext_ctxt, -pub fn expand_block(extsbox: @mut SyntaxEnv, cx: ext_ctxt, - blk: &blk_, sp: span, fld: ast_fold, - orig: fn@(&blk_, span, ast_fold) -> (blk_, span)) - -> (blk_, span) { +pub fn expand_block(extsbox: @mut SyntaxEnv, + cx: ext_ctxt, + blk: &blk_, + sp: span, + fld: ast_fold, + orig: @fn(&blk_, span, ast_fold) -> (blk_, span)) + -> (blk_, span) { match (*extsbox).find(&@~" block") { // no scope limit on macros in this block, no need // to push an exts frame: diff --git a/src/libsyntax/ext/fmt.rs b/src/libsyntax/ext/fmt.rs index e06e43f6287c..af558e6b330d 100644 --- a/src/libsyntax/ext/fmt.rs +++ b/src/libsyntax/ext/fmt.rs @@ -24,7 +24,8 @@ use ext::base::*; use ext::base; use ext::build; use ext::build::*; -use unstable::extfmt::ct::*; + +use core::unstable::extfmt::ct::*; pub fn expand_syntax_ext(cx: ext_ctxt, sp: span, tts: &[ast::token_tree]) -> base::MacResult { @@ -41,9 +42,7 @@ pub fn expand_syntax_ext(cx: ext_ctxt, sp: span, tts: &[ast::token_tree]) fn parse_fmt_err_(cx: ext_ctxt, sp: span, msg: &str) -> ! { cx.span_fatal(sp, msg); } - let parse_fmt_err = fn@(s: &str) -> ! { - parse_fmt_err_(cx, fmtspan, s) - }; + let parse_fmt_err: @fn(&str) -> ! = |s| parse_fmt_err_(cx, fmtspan, s); let pieces = parse_fmt_string(fmt, parse_fmt_err); MRExpr(pieces_to_expr(cx, sp, pieces, args)) } diff --git a/src/libsyntax/ext/log_syntax.rs b/src/libsyntax/ext/log_syntax.rs index 368520acd2d1..9072f4bdd01b 100644 --- a/src/libsyntax/ext/log_syntax.rs +++ b/src/libsyntax/ext/log_syntax.rs @@ -8,8 +8,8 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -use prelude::*; use core::io::WriterUtil; +use core::prelude::*; use ast; use codemap; diff --git a/src/libsyntax/ext/trace_macros.rs b/src/libsyntax/ext/trace_macros.rs index bb6d656d5cc1..d7f7f7c6510e 100644 --- a/src/libsyntax/ext/trace_macros.rs +++ b/src/libsyntax/ext/trace_macros.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -use prelude::*; +use core::prelude::*; use ast::tt_delim; use ast; diff --git a/src/libsyntax/fold.rs b/src/libsyntax/fold.rs index f820669ab1c6..b315e543f5f4 100644 --- a/src/libsyntax/fold.rs +++ b/src/libsyntax/fold.rs @@ -39,7 +39,7 @@ pub trait ast_fold { fn fold_ident(@self, ident) -> ident; fn fold_path(@self, @path) -> @path; fn fold_local(@self, @local) -> @local; - fn map_exprs(@self, fn@(@expr) -> @expr, &[@expr]) -> ~[@expr]; + fn map_exprs(@self, @fn(@expr) -> @expr, &[@expr]) -> ~[@expr]; fn new_id(@self, node_id) -> node_id; fn new_span(@self, span) -> span; } @@ -48,29 +48,29 @@ pub trait ast_fold { pub struct AstFoldFns { //unlike the others, item_ is non-trivial - fold_crate: fn@(&crate_, span, ast_fold) -> (crate_, span), - fold_view_item: fn@(view_item_, ast_fold) -> view_item_, - fold_foreign_item: fn@(@foreign_item, ast_fold) -> @foreign_item, - fold_item: fn@(@item, ast_fold) -> Option<@item>, - fold_struct_field: fn@(@struct_field, ast_fold) -> @struct_field, - fold_item_underscore: fn@(&item_, ast_fold) -> item_, - fold_method: fn@(@method, ast_fold) -> @method, - fold_block: fn@(&blk_, span, ast_fold) -> (blk_, span), - fold_stmt: fn@(&stmt_, span, ast_fold) -> (stmt_, span), - fold_arm: fn@(&arm, ast_fold) -> arm, - fold_pat: fn@(&pat_, span, ast_fold) -> (pat_, span), - fold_decl: fn@(&decl_, span, ast_fold) -> (decl_, span), - fold_expr: fn@(&expr_, span, ast_fold) -> (expr_, span), - fold_ty: fn@(&ty_, span, ast_fold) -> (ty_, span), - fold_mod: fn@(&_mod, ast_fold) -> _mod, - fold_foreign_mod: fn@(&foreign_mod, ast_fold) -> foreign_mod, - fold_variant: fn@(&variant_, span, ast_fold) -> (variant_, span), - fold_ident: fn@(ident, ast_fold) -> ident, - fold_path: fn@(@path, ast_fold) -> path, - fold_local: fn@(&local_, span, ast_fold) -> (local_, span), - map_exprs: fn@(fn@(@expr) -> @expr, &[@expr]) -> ~[@expr], - new_id: fn@(node_id) -> node_id, - new_span: fn@(span) -> span + fold_crate: @fn(&crate_, span, ast_fold) -> (crate_, span), + fold_view_item: @fn(view_item_, ast_fold) -> view_item_, + fold_foreign_item: @fn(@foreign_item, ast_fold) -> @foreign_item, + fold_item: @fn(@item, ast_fold) -> Option<@item>, + fold_struct_field: @fn(@struct_field, ast_fold) -> @struct_field, + fold_item_underscore: @fn(&item_, ast_fold) -> item_, + fold_method: @fn(@method, ast_fold) -> @method, + fold_block: @fn(&blk_, span, ast_fold) -> (blk_, span), + fold_stmt: @fn(&stmt_, span, ast_fold) -> (stmt_, span), + fold_arm: @fn(&arm, ast_fold) -> arm, + fold_pat: @fn(&pat_, span, ast_fold) -> (pat_, span), + fold_decl: @fn(&decl_, span, ast_fold) -> (decl_, span), + fold_expr: @fn(&expr_, span, ast_fold) -> (expr_, span), + fold_ty: @fn(&ty_, span, ast_fold) -> (ty_, span), + fold_mod: @fn(&_mod, ast_fold) -> _mod, + fold_foreign_mod: @fn(&foreign_mod, ast_fold) -> foreign_mod, + fold_variant: @fn(&variant_, span, ast_fold) -> (variant_, span), + fold_ident: @fn(ident, ast_fold) -> ident, + fold_path: @fn(@path, ast_fold) -> path, + fold_local: @fn(&local_, span, ast_fold) -> (local_, span), + map_exprs: @fn(@fn(@expr) -> @expr, &[@expr]) -> ~[@expr], + new_id: @fn(node_id) -> node_id, + new_span: @fn(span) -> span } pub type ast_fold_fns = @AstFoldFns; @@ -446,12 +446,12 @@ fn noop_fold_decl(d: &decl_, fld: @ast_fold) -> decl_ { } } -pub fn wrap(f: fn@(&T, ast_fold) -> T) - -> fn@(&T, span, ast_fold) -> (T, span) -{ - fn@(x: &T, s: span, fld: @ast_fold) -> (T, span) { +pub fn wrap(f: @fn(&T, ast_fold) -> T) + -> @fn(&T, span, ast_fold) -> (T, span) { + let result: @fn(&T, span, @ast_fold) -> (T, span) = |x, s, fld| { (f(x, fld), s) - } + }; + result } pub fn noop_fold_expr(e: &expr_, fld: @ast_fold) -> expr_ { @@ -533,14 +533,6 @@ pub fn noop_fold_expr(e: &expr_, fld: @ast_fold) -> expr_ { arms.map(|x| fld.fold_arm(x)) ) } - expr_fn(proto, ref decl, ref body, _) => { - expr_fn( - proto, - fold_fn_decl(decl, fld), - fld.fold_block(body), - @() - ) - } expr_fn_block(ref decl, ref body) => { expr_fn_block( fold_fn_decl(decl, fld), @@ -759,7 +751,7 @@ fn noop_fold_local(l: &local_, fld: @ast_fold) -> local_ { /* temporarily eta-expand because of a compiler bug with using `fn` as a value */ -fn noop_map_exprs(f: fn@(@expr) -> @expr, es: &[@expr]) -> ~[@expr] { +fn noop_map_exprs(f: @fn(@expr) -> @expr, es: &[@expr]) -> ~[@expr] { es.map(|x| f(*x)) } @@ -893,11 +885,10 @@ impl ast_fold for AstFoldFns { let (n, s) = (self.fold_local)(&x.node, x.span, self as @ast_fold); @spanned { node: n, span: (self.new_span)(s) } } - fn map_exprs( - @self, - f: fn@(@expr) -> @expr, - e: &[@expr] - ) -> ~[@expr] { + fn map_exprs(@self, + f: @fn(@expr) -> @expr, + e: &[@expr]) + -> ~[@expr] { (self.map_exprs)(f, e) } fn new_id(@self, node_id: ast::node_id) -> node_id { diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index 4c48b49b5d61..a3df97b3ae4c 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -23,7 +23,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_field, expr_fn, expr_fn_block, expr_if, expr_index}; +use ast::{expr_field, 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}; @@ -61,10 +61,10 @@ use ast::{vstore_uniq}; use ast; use ast_util::{ident_to_path, operator_prec}; use ast_util; -use classify; use codemap::{span,FssNone, BytePos, spanned, respan, mk_sp}; use codemap; use parse::attr::parser_attr; +use parse::classify; use parse::common::{seq_sep_none, token_to_str}; use parse::common::{seq_sep_trailing_disallowed, seq_sep_trailing_allowed}; use parse::lexer::reader; @@ -381,17 +381,8 @@ pub impl Parser { let purity = self.parse_purity(); let onceness = parse_onceness(&self); self.expect_keyword(&~"fn"); - let post_sigil = self.parse_fn_ty_sigil(); - let sigil = match (pre_sigil, post_sigil) { - (None, None) => BorrowedSigil, - (Some(p), None) | (None, Some(p)) => p, - (Some(_), Some(_)) => { - self.fatal(~"cannot combine prefix and postfix \ - syntax for closure kind; note that \ - postfix syntax is obsolete"); - } - }; + let sigil = match pre_sigil { None => BorrowedSigil, Some(p) => p }; let region = if pre_region_name.is_some() { Some(self.region_from_name(pre_region_name)) @@ -1150,15 +1141,6 @@ pub impl Parser { return self.parse_loop_expr(); } else if self.eat_keyword(&~"match") { return self.parse_match_expr(); - } else if self.eat_keyword(&~"fn") { - let opt_sigil = self.parse_fn_ty_sigil(); - let sigil = match opt_sigil { - None => { - self.fatal(~"fn expr are deprecated, use fn@") - } - Some(p) => { p } - }; - return self.parse_fn_expr(sigil); } else if self.eat_keyword(&~"unsafe") { return self.parse_block_expr(lo, unsafe_blk); } else if *self.token == token::LBRACKET { @@ -1775,19 +1757,6 @@ pub impl Parser { self.mk_expr(lo, hi, expr_if(cond, thn, els)) } - fn parse_fn_expr(sigil: Sigil) -> @expr { - let lo = self.last_span.lo; - - // if we want to allow fn expression argument types to be inferred in - // the future, just have to change parse_arg to parse_fn_block_arg. - let decl = self.parse_fn_decl(|p| p.parse_arg()); - - let body = self.parse_block(); - - self.mk_expr(lo, body.span.hi, - expr_fn(sigil, decl, body, @())) - } - // `|args| { ... }` like in `do` expressions fn parse_lambda_block_expr() -> @expr { self.parse_lambda_expr_( @@ -1822,8 +1791,8 @@ pub impl Parser { || self.parse_expr()) } - fn parse_lambda_expr_(parse_decl: fn&() -> fn_decl, - parse_body: fn&() -> @expr) -> @expr { + fn parse_lambda_expr_(parse_decl: &fn() -> fn_decl, + parse_body: &fn() -> @expr) -> @expr { let lo = self.last_span.lo; let decl = parse_decl(); let body = parse_body(); diff --git a/src/libsyntax/print/pprust.rs b/src/libsyntax/print/pprust.rs index 282980f0faae..f808a3be6bbe 100644 --- a/src/libsyntax/print/pprust.rs +++ b/src/libsyntax/print/pprust.rs @@ -47,8 +47,8 @@ pub enum ann_node/& { node_pat(@ps, @ast::pat), } pub struct pp_ann { - pre: fn@(ann_node), - post: fn@(ann_node) + pre: @fn(ann_node), + post: @fn(ann_node) } pub fn no_ann() -> pp_ann { @@ -1346,17 +1346,6 @@ pub fn print_expr(s: @ps, &&expr: @ast::expr) { } bclose_(s, expr.span, match_indent_unit); } - ast::expr_fn(sigil, ref decl, ref body, _) => { - // containing cbox, will be closed by print-block at } - cbox(s, indent_unit); - // head-box, will be closed by print-block at start - ibox(s, 0u); - print_fn_header_info(s, None, None, ast::Many, - Some(sigil), ast::inherited); - print_fn_args_and_ret(s, decl, None); - space(s.s); - print_block(s, body); - } ast::expr_fn_block(ref decl, ref body) => { // in do/for blocks we don't want to show an empty // argument list, but at this point we don't know which @@ -2190,7 +2179,7 @@ pub fn print_string(s: @ps, st: ~str) { word(s.s, ~"\""); } -pub fn to_str(t: T, f: fn@(@ps, T), intr: @ident_interner) -> ~str { +pub fn to_str(t: T, f: @fn(@ps, T), intr: @ident_interner) -> ~str { do io::with_str_writer |wr| { let s = rust_printer(wr, intr); f(s, t); diff --git a/src/libsyntax/util/interner.rs b/src/libsyntax/util/interner.rs index 41500d6a409a..5fc93412c501 100644 --- a/src/libsyntax/util/interner.rs +++ b/src/libsyntax/util/interner.rs @@ -13,9 +13,8 @@ // type, and vice versa. use core::prelude::*; - -use hashmap::linear::LinearMap; -use dvec::DVec; +use core::dvec::DVec; +use core::hashmap::linear::LinearMap; pub struct Interner { priv map: @mut LinearMap, diff --git a/src/libsyntax/visit.rs b/src/libsyntax/visit.rs index 5919271664e3..262754624cba 100644 --- a/src/libsyntax/visit.rs +++ b/src/libsyntax/visit.rs @@ -71,27 +71,26 @@ pub fn generics_of_fn(fk: &fn_kind) -> Generics { } pub struct Visitor { - visit_mod: fn@(&_mod, span, node_id, E, vt), - visit_view_item: fn@(@view_item, E, vt), - visit_foreign_item: fn@(@foreign_item, E, vt), - visit_item: fn@(@item, E, vt), - visit_local: fn@(@local, E, vt), - visit_block: fn@(&blk, E, vt), - visit_stmt: fn@(@stmt, E, vt), - visit_arm: fn@(&arm, E, vt), - visit_pat: fn@(@pat, E, vt), - visit_decl: fn@(@decl, E, vt), - visit_expr: fn@(@expr, E, vt), - visit_expr_post: fn@(@expr, E, vt), - visit_ty: fn@(@Ty, E, vt), - visit_generics: fn@(&Generics, E, vt), - visit_fn: fn@(&fn_kind, &fn_decl, &blk, span, node_id, E, vt), - visit_ty_method: fn@(&ty_method, E, vt), - visit_trait_method: fn@(&trait_method, E, vt), - visit_struct_def: fn@(@struct_def, ident, &Generics, node_id, E, - vt), - visit_struct_field: fn@(@struct_field, E, vt), - visit_struct_method: fn@(@method, E, vt) + visit_mod: @fn(&_mod, span, node_id, E, vt), + visit_view_item: @fn(@view_item, E, vt), + visit_foreign_item: @fn(@foreign_item, E, vt), + visit_item: @fn(@item, E, vt), + visit_local: @fn(@local, E, vt), + visit_block: @fn(&blk, E, vt), + visit_stmt: @fn(@stmt, E, vt), + visit_arm: @fn(&arm, E, vt), + visit_pat: @fn(@pat, E, vt), + visit_decl: @fn(@decl, E, vt), + visit_expr: @fn(@expr, E, vt), + visit_expr_post: @fn(@expr, E, vt), + visit_ty: @fn(@Ty, E, vt), + visit_generics: @fn(&Generics, E, vt), + visit_fn: @fn(&fn_kind, &fn_decl, &blk, span, node_id, E, vt), + visit_ty_method: @fn(&ty_method, E, vt), + visit_trait_method: @fn(&trait_method, E, vt), + visit_struct_def: @fn(@struct_def, ident, &Generics, node_id, E, vt), + visit_struct_field: @fn(@struct_field, E, vt), + visit_struct_method: @fn(@method, E, vt) } pub type visitor = @Visitor; @@ -535,17 +534,6 @@ pub fn visit_expr(ex: @expr, e: E, v: vt) { (v.visit_expr)(x, e, v); for arms.each |a| { (v.visit_arm)(a, e, v); } } - expr_fn(proto, ref decl, ref body, _) => { - (v.visit_fn)( - &fk_anon(proto), - decl, - body, - ex.span, - ex.id, - e, - v - ); - } expr_fn_block(ref decl, ref body) => { (v.visit_fn)( &fk_fn_block, @@ -603,26 +591,26 @@ pub fn visit_arm(a: &arm, e: E, v: vt) { // calls the given functions on the nodes. pub struct SimpleVisitor { - visit_mod: fn@(&_mod, span, node_id), - visit_view_item: fn@(@view_item), - visit_foreign_item: fn@(@foreign_item), - visit_item: fn@(@item), - visit_local: fn@(@local), - visit_block: fn@(&blk), - visit_stmt: fn@(@stmt), - visit_arm: fn@(&arm), - visit_pat: fn@(@pat), - visit_decl: fn@(@decl), - visit_expr: fn@(@expr), - visit_expr_post: fn@(@expr), - visit_ty: fn@(@Ty), - visit_generics: fn@(&Generics), - visit_fn: fn@(&fn_kind, &fn_decl, &blk, span, node_id), - visit_ty_method: fn@(&ty_method), - visit_trait_method: fn@(&trait_method), - visit_struct_def: fn@(@struct_def, ident, &Generics, node_id), - visit_struct_field: fn@(@struct_field), - visit_struct_method: fn@(@method) + visit_mod: @fn(&_mod, span, node_id), + visit_view_item: @fn(@view_item), + visit_foreign_item: @fn(@foreign_item), + visit_item: @fn(@item), + visit_local: @fn(@local), + visit_block: @fn(&blk), + visit_stmt: @fn(@stmt), + visit_arm: @fn(&arm), + visit_pat: @fn(@pat), + visit_decl: @fn(@decl), + visit_expr: @fn(@expr), + visit_expr_post: @fn(@expr), + visit_ty: @fn(@Ty), + visit_generics: @fn(&Generics), + visit_fn: @fn(&fn_kind, &fn_decl, &blk, span, node_id), + visit_ty_method: @fn(&ty_method), + visit_trait_method: @fn(&trait_method), + visit_struct_def: @fn(@struct_def, ident, &Generics, node_id), + visit_struct_field: @fn(@struct_field), + visit_struct_method: @fn(@method) } pub type simple_visitor = @SimpleVisitor; @@ -644,21 +632,19 @@ pub fn default_simple_visitor() -> @SimpleVisitor { visit_expr: |_e| { }, visit_expr_post: |_e| { }, visit_ty: simple_ignore_ty, - visit_generics: fn@(_ps: &Generics) { }, - visit_fn: fn@(_fk: &fn_kind, _d: &fn_decl, _b: &blk, _sp: span, - _id: node_id) { }, - visit_ty_method: fn@(_m: &ty_method) { }, - visit_trait_method: fn@(_m: &trait_method) { }, - visit_struct_def: fn@(_sd: @struct_def, _nm: ident, - _generics: &Generics, _id: node_id) { }, - visit_struct_field: fn@(_f: @struct_field) { }, - visit_struct_method: fn@(_m: @method) { } + visit_generics: |_| {}, + visit_fn: |_, _, _, _, _| {}, + visit_ty_method: |_| {}, + visit_trait_method: |_| {}, + visit_struct_def: |_, _, _, _| {}, + visit_struct_field: |_| {}, + visit_struct_method: |_| {}, } } pub fn mk_simple_visitor(v: simple_visitor) -> vt<()> { fn v_mod( - f: fn@(&_mod, span, node_id), + f: @fn(&_mod, span, node_id), m: &_mod, sp: span, id: node_id, @@ -668,65 +654,67 @@ pub fn mk_simple_visitor(v: simple_visitor) -> vt<()> { f(m, sp, id); visit_mod(m, sp, id, e, v); } - fn v_view_item(f: fn@(@view_item), vi: @view_item, &&e: (), v: vt<()>) { + fn v_view_item(f: @fn(@view_item), vi: @view_item, &&e: (), v: vt<()>) { f(vi); visit_view_item(vi, e, v); } - fn v_foreign_item(f: fn@(@foreign_item), ni: @foreign_item, &&e: (), - v: vt<()>) { + fn v_foreign_item(f: @fn(@foreign_item), ni: @foreign_item, &&e: (), + v: vt<()>) { f(ni); visit_foreign_item(ni, e, v); } - fn v_item(f: fn@(@item), i: @item, &&e: (), v: vt<()>) { + fn v_item(f: @fn(@item), i: @item, &&e: (), v: vt<()>) { f(i); visit_item(i, e, v); } - fn v_local(f: fn@(@local), l: @local, &&e: (), v: vt<()>) { + fn v_local(f: @fn(@local), l: @local, &&e: (), v: vt<()>) { f(l); visit_local(l, e, v); } - fn v_block(f: fn@(&blk), bl: &blk, &&e: (), v: vt<()>) { + fn v_block(f: @fn(&ast::blk), bl: &ast::blk, &&e: (), v: vt<()>) { f(bl); visit_block(bl, e, v); } - fn v_stmt(f: fn@(@stmt), st: @stmt, &&e: (), v: vt<()>) { + fn v_stmt(f: @fn(@stmt), st: @stmt, &&e: (), v: vt<()>) { f(st); visit_stmt(st, e, v); } - fn v_arm(f: fn@(&arm), a: &arm, &&e: (), v: vt<()>) { + fn v_arm(f: @fn(&arm), a: &arm, &&e: (), v: vt<()>) { f(a); visit_arm(a, e, v); } - fn v_pat(f: fn@(@pat), p: @pat, &&e: (), v: vt<()>) { + fn v_pat(f: @fn(@pat), p: @pat, &&e: (), v: vt<()>) { f(p); visit_pat(p, e, v); } - fn v_decl(f: fn@(@decl), d: @decl, &&e: (), v: vt<()>) { + fn v_decl(f: @fn(@decl), d: @decl, &&e: (), v: vt<()>) { f(d); visit_decl(d, e, v); } - fn v_expr(f: fn@(@expr), ex: @expr, &&e: (), v: vt<()>) { + fn v_expr(f: @fn(@expr), ex: @expr, &&e: (), v: vt<()>) { f(ex); visit_expr(ex, e, v); } - fn v_expr_post(f: fn@(@expr), ex: @expr, &&_e: (), _v: vt<()>) { + fn v_expr_post(f: @fn(@expr), ex: @expr, &&_e: (), _v: vt<()>) { f(ex); } - fn v_ty(f: fn@(@Ty), ty: @Ty, &&e: (), v: vt<()>) { + fn v_ty(f: @fn(@Ty), ty: @Ty, &&e: (), v: vt<()>) { f(ty); visit_ty(ty, e, v); } - fn v_ty_method(f: fn@(&ty_method), ty: &ty_method, &&e: (), v: vt<()>) { + fn v_ty_method(f: @fn(&ty_method), ty: &ty_method, &&e: (), v: vt<()>) { f(ty); visit_ty_method(ty, e, v); } - fn v_trait_method(f: fn@(&trait_method), m: &trait_method, &&e: (), + fn v_trait_method(f: @fn(&trait_method), + m: &trait_method, + &&e: (), v: vt<()>) { f(m); visit_trait_method(m, e, v); } fn v_struct_def( - f: fn@(@struct_def, ident, &Generics, node_id), + f: @fn(@struct_def, ident, &Generics, node_id), sd: @struct_def, nm: ident, generics: &Generics, @@ -738,7 +726,7 @@ pub fn mk_simple_visitor(v: simple_visitor) -> vt<()> { visit_struct_def(sd, nm, generics, id, e, v); } fn v_generics( - f: fn@(&Generics), + f: @fn(&Generics), ps: &Generics, &&e: (), v: vt<()> @@ -747,7 +735,7 @@ pub fn mk_simple_visitor(v: simple_visitor) -> vt<()> { visit_generics(ps, e, v); } fn v_fn( - f: fn@(&fn_kind, &fn_decl, &blk, span, node_id), + f: @fn(&fn_kind, &fn_decl, &blk, span, node_id), fk: &fn_kind, decl: &fn_decl, body: &blk, @@ -761,12 +749,12 @@ pub fn mk_simple_visitor(v: simple_visitor) -> vt<()> { } let visit_ty: @fn(@Ty, &&x: (), vt<()>) = |a,b,c| v_ty(v.visit_ty, a, b, c); - fn v_struct_field(f: fn@(@struct_field), sf: @struct_field, &&e: (), + fn v_struct_field(f: @fn(@struct_field), sf: @struct_field, &&e: (), v: vt<()>) { f(sf); visit_struct_field(sf, e, v); } - fn v_struct_method(f: fn@(@method), m: @method, &&e: (), v: vt<()>) { + fn v_struct_method(f: @fn(@method), m: @method, &&e: (), v: vt<()>) { f(m); visit_struct_method(m, e, v); } diff --git a/src/rt/rust_type.h b/src/rt/rust_type.h index b631cfa35f43..ece0d48c3ae4 100644 --- a/src/rt/rust_type.h +++ b/src/rt/rust_type.h @@ -36,7 +36,7 @@ struct rust_opaque_box { rust_opaque_box *next; }; -// corresponds to the layout of a fn(), fn@(), fn~() etc +// corresponds to the layout of a &fn(), @fn(), ~fn() etc struct fn_env_pair { spawn_fn f; rust_opaque_box *env; diff --git a/src/test/auxiliary/cci_nested_lib.rs b/src/test/auxiliary/cci_nested_lib.rs index 1be18459e407..a818ff58f944 100644 --- a/src/test/auxiliary/cci_nested_lib.rs +++ b/src/test/auxiliary/cci_nested_lib.rs @@ -10,11 +10,11 @@ #[legacy_modes]; -use dvec::DVec; +use core::dvec::DVec; pub struct Entry {key: A, value: B} -pub struct alist { eq_fn: fn@(A,A) -> bool, data: DVec> } +pub struct alist { eq_fn: @fn(A,A) -> bool, data: DVec> } pub fn alist_add(lst: alist, k: A, v: B) { lst.data.push(Entry{key:k, value:v}); diff --git a/src/test/auxiliary/issue4516_ty_param_lib.rs b/src/test/auxiliary/issue4516_ty_param_lib.rs index 0e2105243e70..dd2ffd5002c9 100644 --- a/src/test/auxiliary/issue4516_ty_param_lib.rs +++ b/src/test/auxiliary/issue4516_ty_param_lib.rs @@ -9,5 +9,6 @@ // except according to those terms. pub fn to_closure(x: A) -> @fn() -> A { - fn@() -> A { copy x } + let result: @fn() -> A = || copy x; + result } diff --git a/src/test/auxiliary/trait_inheritance_overloading_xc.rs b/src/test/auxiliary/trait_inheritance_overloading_xc.rs index 67da2541ca21..10a7238a3f7d 100644 --- a/src/test/auxiliary/trait_inheritance_overloading_xc.rs +++ b/src/test/auxiliary/trait_inheritance_overloading_xc.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -use cmp::Eq; +use core::cmp::Eq; pub trait MyNum : Add Sub Mul Eq { } diff --git a/src/test/bench/core-std.rs b/src/test/bench/core-std.rs index bd8757d51b74..e026e78ffb81 100644 --- a/src/test/bench/core-std.rs +++ b/src/test/bench/core-std.rs @@ -16,7 +16,7 @@ use std::time::precise_time_s; use std::oldmap; use std::oldmap::{Map, HashMap}; -use io::{Reader, ReaderUtil}; +use core::io::{Reader, ReaderUtil}; macro_rules! bench ( ($id:ident) => (maybe_run_test(argv, stringify!($id).to_owned(), $id)) diff --git a/src/test/bench/core-vec-append.rs b/src/test/bench/core-vec-append.rs index 1dfcb31f1963..7f1f4bd1834e 100644 --- a/src/test/bench/core-vec-append.rs +++ b/src/test/bench/core-vec-append.rs @@ -11,8 +11,8 @@ // A raw test of vector appending performance. extern mod std; -use dvec::DVec; -use io::WriterUtil; +use core::dvec::DVec; +use core::io::WriterUtil; fn collect_raw(num: uint) -> ~[uint] { let mut result = ~[]; diff --git a/src/test/bench/graph500-bfs.rs b/src/test/bench/graph500-bfs.rs index 52d08c548d72..0b172011648a 100644 --- a/src/test/bench/graph500-bfs.rs +++ b/src/test/bench/graph500-bfs.rs @@ -267,7 +267,7 @@ fn pbfs(&&graph: arc::ARC, key: node_id) -> bfs_result { colors = do par::mapi(*color_vec) { let colors = arc::clone(&color); let graph = arc::clone(&graph); - fn~(+i: uint, +c: &color) -> color { + let result: ~fn(+x: uint, +y: &color) -> color = |i, c| { let colors = arc::get(&colors); let graph = arc::get(&graph); match *c { @@ -290,20 +290,22 @@ fn pbfs(&&graph: arc::ARC, key: node_id) -> bfs_result { gray(parent) => { black(parent) } black(parent) => { black(parent) } } - } + }; + result }; assert(colors.len() == old_len); } // Convert the results. do par::map(colors) { - fn~(c: &color) -> i64 { + let result: ~fn(c: &color) -> i64 = |c| { match *c { white => { -1i64 } black(parent) => { parent } _ => { fail!(~"Found remaining gray nodes in BFS") } } - } + }; + result } } @@ -387,14 +389,15 @@ fn validate(edges: ~[(node_id, node_id)], let status = do par::alli(tree) { let edges = copy edges; - fn~(+u: uint, v: &i64) -> bool { + let result: ~fn(+x: uint, v: &i64) -> bool = |u, v| { let u = u as node_id; if *v == -1i64 || u == root { true } else { edges.contains(&(u, *v)) || edges.contains(&(*v, u)) } - } + }; + result }; if !status { return status } diff --git a/src/test/bench/msgsend-pipes-shared.rs b/src/test/bench/msgsend-pipes-shared.rs index 4bbd22786a56..fbd80d581300 100644 --- a/src/test/bench/msgsend-pipes-shared.rs +++ b/src/test/bench/msgsend-pipes-shared.rs @@ -21,10 +21,10 @@ #[legacy_modes]; extern mod std; -use io::Writer; -use io::WriterUtil; +use core::io::Writer; +use core::io::WriterUtil; -use comm::{Port, Chan, SharedChan}; +use core::comm::{Port, Chan, SharedChan}; macro_rules! move_out ( { $x:expr } => { unsafe { let y = *ptr::addr_of(&($x)); y } } diff --git a/src/test/bench/msgsend-pipes.rs b/src/test/bench/msgsend-pipes.rs index a969368ebaca..251353837459 100644 --- a/src/test/bench/msgsend-pipes.rs +++ b/src/test/bench/msgsend-pipes.rs @@ -17,10 +17,10 @@ #[legacy_modes]; extern mod std; -use io::Writer; -use io::WriterUtil; +use core::io::Writer; +use core::io::WriterUtil; -use comm::{Port, PortSet, Chan, stream}; +use core::comm::{Port, PortSet, Chan, stream}; macro_rules! move_out ( { $x:expr } => { unsafe { let y = *ptr::addr_of(&($x)); y } } diff --git a/src/test/bench/shootout-fasta.rs b/src/test/bench/shootout-fasta.rs index 509861e2f470..2bc89f64a298 100644 --- a/src/test/bench/shootout-fasta.rs +++ b/src/test/bench/shootout-fasta.rs @@ -16,7 +16,7 @@ * http://shootout.alioth.debian.org/ */ extern mod std; -use io::WriterUtil; +use core::io::WriterUtil; fn LINE_LENGTH() -> uint { return 60u; } diff --git a/src/test/bench/shootout-k-nucleotide-pipes.rs b/src/test/bench/shootout-k-nucleotide-pipes.rs index 3fe5f7057057..35c6694ee0c7 100644 --- a/src/test/bench/shootout-k-nucleotide-pipes.rs +++ b/src/test/bench/shootout-k-nucleotide-pipes.rs @@ -17,9 +17,9 @@ extern mod std; use std::oldmap; use std::oldmap::HashMap; use std::sort; -use io::ReaderUtil; -use comm::{stream, Port, Chan}; -use cmp::Ord; +use core::io::ReaderUtil; +use core::comm::{stream, Port, Chan}; +use core::cmp::Ord; // given a map, print a sorted version of it fn sort_and_fmt(mm: HashMap<~[u8], uint>, total: uint) -> ~str { diff --git a/src/test/bench/shootout-mandelbrot.rs b/src/test/bench/shootout-mandelbrot.rs index a52b7889017c..146a4b8c8692 100644 --- a/src/test/bench/shootout-mandelbrot.rs +++ b/src/test/bench/shootout-mandelbrot.rs @@ -24,7 +24,7 @@ // // writes pbm image to output path -use io::WriterUtil; +use core::io::WriterUtil; use core::hashmap::linear::LinearMap; struct cmplx { diff --git a/src/test/bench/shootout-nbody.rs b/src/test/bench/shootout-nbody.rs index e7b3547ab8c7..f4127e6c7726 100644 --- a/src/test/bench/shootout-nbody.rs +++ b/src/test/bench/shootout-nbody.rs @@ -45,7 +45,7 @@ fn main() { io::println(fmt!("%f", NBodySystem::energy(bodies))); } -mod NBodySystem { +pub mod NBodySystem { use Body; pub fn make() -> ~[Body::Props] { @@ -162,7 +162,7 @@ mod NBodySystem { } } -mod Body { +pub mod Body { use Body; pub const PI: float = 3.141592653589793; diff --git a/src/test/bench/shootout-pfib.rs b/src/test/bench/shootout-pfib.rs index 285338213654..e0d2fbb0513b 100644 --- a/src/test/bench/shootout-pfib.rs +++ b/src/test/bench/shootout-pfib.rs @@ -29,7 +29,7 @@ use core::comm::*; use core::io::WriterUtil; use core::result; -use result::{Ok, Err}; +use core::result::{Ok, Err}; fn fib(n: int) -> int { fn pfib(c: Chan, n: int) { diff --git a/src/test/bench/std-smallintmap.rs b/src/test/bench/std-smallintmap.rs index 0687799cf288..d54376a25325 100644 --- a/src/test/bench/std-smallintmap.rs +++ b/src/test/bench/std-smallintmap.rs @@ -12,7 +12,7 @@ extern mod std; use std::smallintmap::SmallIntMap; -use io::WriterUtil; +use core::io::WriterUtil; fn append_sequential(min: uint, max: uint, map: &mut SmallIntMap) { for uint::range(min, max) |i| { diff --git a/src/test/bench/sudoku.rs b/src/test/bench/sudoku.rs index 05dac339177b..dc8136bc122b 100644 --- a/src/test/bench/sudoku.rs +++ b/src/test/bench/sudoku.rs @@ -13,7 +13,8 @@ extern mod std; use std::bitv; -use io::{ReaderUtil, WriterUtil}; +use core::io::{ReaderUtil, WriterUtil}; +use core::io; // Computes a single solution to a given 9x9 sudoku // diff --git a/src/test/bench/task-perf-alloc-unwind.rs b/src/test/bench/task-perf-alloc-unwind.rs index b4b02c3aaa8d..05781b20a9b3 100644 --- a/src/test/bench/task-perf-alloc-unwind.rs +++ b/src/test/bench/task-perf-alloc-unwind.rs @@ -46,7 +46,7 @@ type nillist = List<()>; struct State { box: @nillist, unique: ~nillist, - fn_box: fn@() -> @nillist, + fn_box: @fn() -> @nillist, tuple: (@nillist, ~nillist), vec: ~[@nillist], res: r @@ -78,7 +78,7 @@ fn recurse_or_fail(depth: int, st: Option) { State { box: @Nil, unique: ~Nil, - fn_box: fn@() -> @nillist { @Nil::<()> }, + fn_box: || @Nil::<()>, tuple: (@Nil, ~Nil), vec: ~[@Nil], res: r(@Nil) @@ -90,7 +90,7 @@ fn recurse_or_fail(depth: int, st: Option) { State { box: @Cons((), st.box), unique: ~Cons((), @*st.unique), - fn_box: fn@() -> @nillist { @Cons((), fn_box()) }, + fn_box: || @Cons((), fn_box()), tuple: (@Cons((), st.tuple.first()), ~Cons((), @*st.tuple.second())), vec: st.vec + ~[@Cons((), st.vec.last())], diff --git a/src/test/bench/task-perf-linked-failure.rs b/src/test/bench/task-perf-linked-failure.rs index c6074cc522e6..40390ceeee49 100644 --- a/src/test/bench/task-perf-linked-failure.rs +++ b/src/test/bench/task-perf-linked-failure.rs @@ -46,7 +46,7 @@ fn grandchild_group(num_tasks: uint) { // Master grandchild task exits early. } -fn spawn_supervised_blocking(myname: &str, +f: fn~()) { +fn spawn_supervised_blocking(myname: &str, +f: ~fn()) { let mut res = None; task::task().future_result(|+r| res = Some(r)).supervised().spawn(f); error!("%s group waiting", myname); diff --git a/src/test/compile-fail/assign-to-method.rs b/src/test/compile-fail/assign-to-method.rs index 0a2834a95e62..2436e4da8df2 100644 --- a/src/test/compile-fail/assign-to-method.rs +++ b/src/test/compile-fail/assign-to-method.rs @@ -28,5 +28,5 @@ fn cat(in_x : uint, in_y : int) -> cat { fn main() { let nyan : cat = cat(52u, 99); - nyan.speak = fn@() { debug!("meow"); }; //~ ERROR attempted to take value of method + nyan.speak = || debug!("meow"); //~ ERROR attempted to take value of method } diff --git a/src/test/compile-fail/borrowck-addr-of-upvar.rs b/src/test/compile-fail/borrowck-addr-of-upvar.rs index 8bd3832d70ce..4e8af4f04210 100644 --- a/src/test/compile-fail/borrowck-addr-of-upvar.rs +++ b/src/test/compile-fail/borrowck-addr-of-upvar.rs @@ -8,16 +8,19 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -fn foo(x: @int) -> fn@() -> &static/int { - fn@() -> &static/int {&*x} //~ ERROR illegal borrow +fn foo(x: @int) -> @fn() -> &static/int { + let result: @fn() -> &static/int = || &*x; //~ ERROR illegal borrow + result } -fn bar(x: @int) -> fn@() -> &int { - fn@() -> &int {&*x} //~ ERROR illegal borrow +fn bar(x: @int) -> @fn() -> &int { + let result: @fn() -> &int = || &*x; //~ ERROR illegal borrow + result } -fn zed(x: @int) -> fn@() -> int { - fn@() -> int {*&*x} +fn zed(x: @int) -> @fn() -> int { + let result: @fn() -> int = || *&*x; + result } fn main() { diff --git a/src/test/compile-fail/borrowck-call-sendfn.rs b/src/test/compile-fail/borrowck-call-sendfn.rs index 51047631ea66..8dc86c9a1631 100644 --- a/src/test/compile-fail/borrowck-call-sendfn.rs +++ b/src/test/compile-fail/borrowck-call-sendfn.rs @@ -10,7 +10,11 @@ // xfail-test #2978 -fn call(x: @{f: fn~()}) { +struct Foo { + f: ~fn() +} + +fn call(x: @Foo) { x.f(); //~ ERROR foo //~^ NOTE bar } diff --git a/src/test/compile-fail/borrowck-loan-blocks-move-cc.rs b/src/test/compile-fail/borrowck-loan-blocks-move-cc.rs index 50bedc573406..aca63308d874 100644 --- a/src/test/compile-fail/borrowck-loan-blocks-move-cc.rs +++ b/src/test/compile-fail/borrowck-loan-blocks-move-cc.rs @@ -22,7 +22,7 @@ fn box_imm() { let v = ~3; let _w = &v; //~ NOTE loan of immutable local variable granted here - task::spawn(fn~() { + task::spawn(|| { debug!("v=%d", *v); //~^ ERROR by-move capture of immutable local variable prohibited due to outstanding loan }); diff --git a/src/test/compile-fail/do2.rs b/src/test/compile-fail/do2.rs index 5fb5f15806dc..103118349154 100644 --- a/src/test/compile-fail/do2.rs +++ b/src/test/compile-fail/do2.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -fn f(f: fn@(int) -> bool) -> bool { f(10i) } +fn f(f: @fn(int) -> bool) -> bool { f(10i) } fn main() { assert do f() |i| { i == 10i } == 10i; diff --git a/src/test/compile-fail/fn-variance-2.rs b/src/test/compile-fail/fn-variance-2.rs index 979dfac9a4de..2a30f9fb96fa 100644 --- a/src/test/compile-fail/fn-variance-2.rs +++ b/src/test/compile-fail/fn-variance-2.rs @@ -8,8 +8,9 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -fn reproduce(t: T) -> fn@() -> T { - fn@() -> T { t } +fn reproduce(t: T) -> @fn() -> T { + let result: @fn() -> T = || t; + result } fn main() { @@ -17,7 +18,7 @@ fn main() { // with the lower bound @mut int let x = @mut 3; - // type of r is fn@() -> X + // type of r is @fn() -> X let r = reproduce(x); // Requires that X be a subtype of diff --git a/src/test/compile-fail/fn-variance-3.rs b/src/test/compile-fail/fn-variance-3.rs index 7f7e1f2fc841..5df2007721de 100644 --- a/src/test/compile-fail/fn-variance-3.rs +++ b/src/test/compile-fail/fn-variance-3.rs @@ -8,12 +8,13 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -fn mk_identity() -> fn@(T) -> T { - fn@(t: T) -> T { t } +fn mk_identity() -> @fn(T) -> T { + let result: @fn(t: T) -> T = |t| t; + result } fn main() { - // type of r is fn@(X) -> X + // type of r is @fn(X) -> X // for some fresh X let r = mk_identity(); diff --git a/src/test/compile-fail/import2.rs b/src/test/compile-fail/import2.rs index c04bce49d4ad..5ee4a01f2b9c 100644 --- a/src/test/compile-fail/import2.rs +++ b/src/test/compile-fail/import2.rs @@ -8,8 +8,9 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -// error-pattern: unresolved -use baz::zed::bar; +use baz::zed::bar; //~ ERROR unresolved name +//~^ ERROR failed to resolve import + mod baz {} mod zed { pub fn bar() { debug!("bar3"); } diff --git a/src/test/compile-fail/issue-1451.rs b/src/test/compile-fail/issue-1451.rs index 2e80a7b09def..acc371076e70 100644 --- a/src/test/compile-fail/issue-1451.rs +++ b/src/test/compile-fail/issue-1451.rs @@ -9,8 +9,8 @@ // except according to those terms. // xfail-test -struct T { f: fn@() }; -struct S { f: fn@() }; +struct T { f: @fn() }; +struct S { f: @fn() }; fn fooS(t: S) { } @@ -22,11 +22,11 @@ fn bar() { } fn main() { - let x: fn@() = bar; + let x: @fn() = bar; fooS(S {f: x}); fooS(S {f: bar}); - let x: fn@() = bar; + let x: @fn() = bar; fooT(T {f: x}); fooT(T {f: bar}); } diff --git a/src/test/compile-fail/issue-1697.rs b/src/test/compile-fail/issue-1697.rs index 2a64666d94ca..a0d2536d85f0 100644 --- a/src/test/compile-fail/issue-1697.rs +++ b/src/test/compile-fail/issue-1697.rs @@ -10,7 +10,8 @@ // Testing that we don't fail abnormally after hitting the errors -use unresolved::*; //~ ERROR unresolved import +use unresolved::*; //~ ERROR unresolved name +//~^ ERROR failed to resolve import fn main() { } diff --git a/src/test/compile-fail/issue-1896-1.rs b/src/test/compile-fail/issue-1896-1.rs index 2be04929dc6a..af3794957310 100644 --- a/src/test/compile-fail/issue-1896-1.rs +++ b/src/test/compile-fail/issue-1896-1.rs @@ -8,10 +8,11 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -struct boxedFn { theFn: fn~() -> uint } +struct boxedFn { theFn: ~fn() -> uint } fn createClosure (closedUint: uint) -> boxedFn { - boxedFn {theFn: fn@ () -> uint { closedUint }} //~ ERROR mismatched types + let result: @fn() -> uint = || closedUint; + boxedFn { theFn: result } //~ ERROR mismatched types } fn main () { diff --git a/src/test/compile-fail/issue-2074.rs b/src/test/compile-fail/issue-2074.rs index be9eea8f72d5..40c2772f2347 100644 --- a/src/test/compile-fail/issue-2074.rs +++ b/src/test/compile-fail/issue-2074.rs @@ -10,13 +10,13 @@ // xfail-test fn main() { - let one = fn@() -> uint { + let one: @fn() -> uint = || { enum r { a }; - return a as uint; + a as uint }; - let two = fn@() -> uint { + let two = @fn() -> uint = || { enum r { a }; - return a as uint; + a as uint }; one(); two(); } diff --git a/src/test/compile-fail/issue-2590.rs b/src/test/compile-fail/issue-2590.rs index 22ae941350b4..1de311f4de54 100644 --- a/src/test/compile-fail/issue-2590.rs +++ b/src/test/compile-fail/issue-2590.rs @@ -8,11 +8,11 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -use dvec::DVec; +use core::dvec::DVec; -type parser = { +struct parser { tokens: DVec, -}; +} trait parse { fn parse() -> ~[int]; @@ -20,7 +20,7 @@ trait parse { impl parse for parser { fn parse() -> ~[int] { - dvec::unwrap(self.tokens) //~ ERROR moving out of immutable field + ::core::dvec::unwrap(self.tokens) //~ ERROR moving out of immutable field } } diff --git a/src/test/compile-fail/issue-2611-3.rs b/src/test/compile-fail/issue-2611-3.rs index c9aeaae0ff93..1f425b092233 100644 --- a/src/test/compile-fail/issue-2611-3.rs +++ b/src/test/compile-fail/issue-2611-3.rs @@ -13,7 +13,7 @@ // we let an impl method can have more permissive bounds than the trait // method it's implementing, the return type might be less specific than // needed. Just punt and make it invariant. -use iter::BaseIter; +use core::iter::BaseIter; trait A { fn b(x: C) -> C; diff --git a/src/test/compile-fail/issue-2611-4.rs b/src/test/compile-fail/issue-2611-4.rs index fb7c5bd6cb87..ae7869d4a689 100644 --- a/src/test/compile-fail/issue-2611-4.rs +++ b/src/test/compile-fail/issue-2611-4.rs @@ -10,7 +10,7 @@ // Tests that an impl method's bounds aren't *more* restrictive // than the trait method it's implementing -use iter::BaseIter; +use core::iter::BaseIter; trait A { fn b(x: C) -> C; diff --git a/src/test/compile-fail/issue-2611-5.rs b/src/test/compile-fail/issue-2611-5.rs index 35015a260f5a..c28fd462b410 100644 --- a/src/test/compile-fail/issue-2611-5.rs +++ b/src/test/compile-fail/issue-2611-5.rs @@ -10,7 +10,7 @@ // Tests that ty params get matched correctly when comparing // an impl against a trait -use iter::BaseIter; +use core::iter::BaseIter; trait A { fn b(x: C) -> C; diff --git a/src/test/compile-fail/issue-3953.rs b/src/test/compile-fail/issue-3953.rs index 90ca7c1797c3..c88a94ef6296 100644 --- a/src/test/compile-fail/issue-3953.rs +++ b/src/test/compile-fail/issue-3953.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -use cmp::Eq; +use core::cmp::Eq; trait Hahaha: Eq Eq Eq Eq Eq Eq Eq Eq Eq Eq Eq Eq Eq Eq Eq Eq //~ ERROR Duplicate supertrait in trait declaration Eq Eq Eq Eq Eq Eq Eq Eq Eq Eq Eq Eq Eq Eq Eq Eq diff --git a/src/test/compile-fail/issue-511.rs b/src/test/compile-fail/issue-511.rs index ba219f7b5fd2..f337914da6dc 100644 --- a/src/test/compile-fail/issue-511.rs +++ b/src/test/compile-fail/issue-511.rs @@ -9,7 +9,7 @@ // except according to those terms. extern mod std; -use cmp::Eq; +use core::cmp::Eq; fn f(o: &mut Option) { assert *o == option::None; diff --git a/src/test/compile-fail/kindck-nonsendable-1.rs b/src/test/compile-fail/kindck-nonsendable-1.rs index 397b0f682d62..928abae24238 100644 --- a/src/test/compile-fail/kindck-nonsendable-1.rs +++ b/src/test/compile-fail/kindck-nonsendable-1.rs @@ -12,7 +12,7 @@ fn foo(_x: @uint) {} fn main() { let x = @3u; - let _ = fn~() { foo(x); }; //~ ERROR value has non-owned type `@uint` - let _ = fn~() { foo(x); }; //~ ERROR value has non-owned type `@uint` - let _ = fn~() { foo(x); }; //~ ERROR value has non-owned type `@uint` + let _: ~fn() = || foo(x); //~ ERROR value has non-owned type `@uint` + let _: ~fn() = || foo(x); //~ ERROR value has non-owned type `@uint` + let _: ~fn() = || foo(x); //~ ERROR value has non-owned type `@uint` } diff --git a/src/test/compile-fail/kindck-owned.rs b/src/test/compile-fail/kindck-owned.rs index e792917622b3..31ab555b38ab 100644 --- a/src/test/compile-fail/kindck-owned.rs +++ b/src/test/compile-fail/kindck-owned.rs @@ -8,12 +8,14 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -fn copy1(t: T) -> fn@() -> T { - fn@() -> T { t } //~ ERROR value may contain borrowed pointers +fn copy1(t: T) -> @fn() -> T { + let result: @fn() -> T = || t; //~ ERROR value may contain borrowed pointers + result } -fn copy2(t: T) -> fn@() -> T { - fn@() -> T { t } +fn copy2(t: T) -> @fn() -> T { + let result: @fn() -> T = || t; + result } fn main() { @@ -23,7 +25,10 @@ fn main() { copy2(@3); copy2(@&x); //~ ERROR does not fulfill `&static` - copy2(fn@() {}); - copy2(fn~() {}); //~ ERROR does not fulfill `Copy` - copy2(fn&() {}); //~ ERROR does not fulfill `&static` + let boxed: @fn() = || {}; + copy2(boxed); + let owned: ~fn() = || {}; + copy2(owned); //~ ERROR does not fulfill `Copy` + let borrowed: &fn() = || {}; + copy2(borrowed); //~ ERROR does not fulfill `&static` } diff --git a/src/test/compile-fail/lambda-mutate-nested.rs b/src/test/compile-fail/lambda-mutate-nested.rs index e52444ba2932..1ed18a0297a9 100644 --- a/src/test/compile-fail/lambda-mutate-nested.rs +++ b/src/test/compile-fail/lambda-mutate-nested.rs @@ -9,13 +9,13 @@ // except according to those terms. // error-pattern:assigning to captured outer immutable variable in a stack closure -// Make sure that nesting a block within a fn@ doesn't let us -// mutate upvars from a fn@. -fn f2(x: fn()) { x(); } +// Make sure that nesting a block within a @fn doesn't let us +// mutate upvars from a @fn. +fn f2(x: &fn()) { x(); } fn main() { let i = 0; - let ctr = fn@ () -> int { f2(|| i = i + 1 ); return i; }; + let ctr: @fn() -> int = || { f2(|| i = i + 1 ); i }; log(error, ctr()); log(error, ctr()); log(error, ctr()); diff --git a/src/test/compile-fail/lambda-mutate.rs b/src/test/compile-fail/lambda-mutate.rs index 8de90f489a3b..eaa51a8c3dd5 100644 --- a/src/test/compile-fail/lambda-mutate.rs +++ b/src/test/compile-fail/lambda-mutate.rs @@ -9,10 +9,10 @@ // except according to those terms. // error-pattern:assigning to captured outer variable in a heap closure -// Make sure we can't write to upvars from fn@s +// Make sure we can't write to upvars from @fns fn main() { let i = 0; - let ctr = fn@ () -> int { i = i + 1; return i; }; + let ctr: @fn() -> int = || { i = i + 1; i }; log(error, ctr()); log(error, ctr()); log(error, ctr()); diff --git a/src/test/compile-fail/liveness-block-unint.rs b/src/test/compile-fail/liveness-block-unint.rs index e090e8d0b35f..75815d2643cb 100644 --- a/src/test/compile-fail/liveness-block-unint.rs +++ b/src/test/compile-fail/liveness-block-unint.rs @@ -8,10 +8,10 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -fn force(f: fn()) { f(); } +fn force(f: &fn()) { f(); } fn main() { let x: int; - force(fn&() { + force(|| { log(debug, x); //~ ERROR capture of possibly uninitialized variable: `x` }); } diff --git a/src/test/compile-fail/liveness-init-in-called-fn-expr.rs b/src/test/compile-fail/liveness-init-in-called-fn-expr.rs index f83d582923aa..1fddea809660 100644 --- a/src/test/compile-fail/liveness-init-in-called-fn-expr.rs +++ b/src/test/compile-fail/liveness-init-in-called-fn-expr.rs @@ -9,9 +9,9 @@ // except according to those terms. fn main() { - let j = fn@() -> int { + let j: @fn() -> int = || { let i: int; - return i; //~ ERROR use of possibly uninitialized variable: `i` + i //~ ERROR use of possibly uninitialized variable: `i` }; j(); } diff --git a/src/test/compile-fail/liveness-init-in-fn-expr.rs b/src/test/compile-fail/liveness-init-in-fn-expr.rs index 308430cffaaa..13b8fb04a426 100644 --- a/src/test/compile-fail/liveness-init-in-fn-expr.rs +++ b/src/test/compile-fail/liveness-init-in-fn-expr.rs @@ -9,9 +9,9 @@ // except according to those terms. fn main() { - let f = fn@() -> int { + let f: @fn() -> int = || { let i: int; - return i; //~ ERROR use of possibly uninitialized variable: `i` + i //~ ERROR use of possibly uninitialized variable: `i` }; log(error, f()); } diff --git a/src/test/compile-fail/liveness-issue-2163.rs b/src/test/compile-fail/liveness-issue-2163.rs index fb317a3988e4..914b7d9d677a 100644 --- a/src/test/compile-fail/liveness-issue-2163.rs +++ b/src/test/compile-fail/liveness-issue-2163.rs @@ -10,7 +10,7 @@ fn main() { let a: ~[int] = ~[]; - vec::each(a, fn@(_x: &int) -> bool { - //~^ ERROR not all control paths return a value + vec::each(a, |_| -> bool { + //~^ ERROR mismatched types }); } diff --git a/src/test/compile-fail/liveness-unused.rs b/src/test/compile-fail/liveness-unused.rs index 970abf4fd94b..9e4d16f96e6c 100644 --- a/src/test/compile-fail/liveness-unused.rs +++ b/src/test/compile-fail/liveness-unused.rs @@ -68,5 +68,5 @@ impl Drop for r { fn main() { let x = r { x: () }; - fn@() { copy x; }; //~ ERROR copying a value of non-copyable type + || { copy x; }; //~ ERROR copying a value of non-copyable type } diff --git a/src/test/compile-fail/omitted-arg-wrong-types.rs b/src/test/compile-fail/omitted-arg-wrong-types.rs index 13087e05d0be..d432c5eac46d 100644 --- a/src/test/compile-fail/omitted-arg-wrong-types.rs +++ b/src/test/compile-fail/omitted-arg-wrong-types.rs @@ -9,12 +9,12 @@ // except according to those terms. // xfail-test - #2093 -fn let_in(x: T, f: fn(T)) {} +fn let_in(x: T, f: &fn(T)) {} fn main() { - let_in(3u, fn&(i) { assert i == 3; }); + let_in(3u, |i| { assert i == 3; }); //~^ ERROR expected `uint` but found `int` - let_in(3, fn&(i) { assert i == 3u; }); + let_in(3, |i| { assert i == 3u; }); //~^ ERROR expected `int` but found `uint` } diff --git a/src/test/compile-fail/pattern-tyvar-2.rs b/src/test/compile-fail/pattern-tyvar-2.rs index 29eb1ec8d0a3..7e65d1908c4d 100644 --- a/src/test/compile-fail/pattern-tyvar-2.rs +++ b/src/test/compile-fail/pattern-tyvar-2.rs @@ -11,7 +11,6 @@ extern mod std; -use option::Some; // error-pattern: mismatched types diff --git a/src/test/compile-fail/pattern-tyvar.rs b/src/test/compile-fail/pattern-tyvar.rs index bb4e97f9101b..6b3b6f1463f5 100644 --- a/src/test/compile-fail/pattern-tyvar.rs +++ b/src/test/compile-fail/pattern-tyvar.rs @@ -10,7 +10,6 @@ // except according to those terms. extern mod std; -use option::Some; // error-pattern: mismatched types diff --git a/src/test/compile-fail/pure-subtyping.rs b/src/test/compile-fail/pure-subtyping.rs index ad3bea0055ba..2744afb113d5 100644 --- a/src/test/compile-fail/pure-subtyping.rs +++ b/src/test/compile-fail/pure-subtyping.rs @@ -12,36 +12,36 @@ fn take(_v: T) {} -fn assign_to_pure(x: pure fn(), y: fn(), z: unsafe fn()) { - take::(x); - take::(y); //~ ERROR expected pure fn but found impure fn - take::(z); //~ ERROR expected pure fn but found unsafe fn +fn assign_to_pure(x: &pure fn(), y: &fn(), z: &unsafe fn()) { + take::<&pure fn()>(x); + take::<&pure fn()>(y); //~ ERROR expected pure fn but found impure fn + take::<&pure fn()>(z); //~ ERROR expected pure fn but found unsafe fn } -fn assign_to_impure(x: pure fn(), y: fn(), z: unsafe fn()) { - take::(x); - take::(y); - take::(z); //~ ERROR expected impure fn but found unsafe fn +fn assign_to_impure(x: &pure fn(), y: &fn(), z: &unsafe fn()) { + take::<&fn()>(x); + take::<&fn()>(y); + take::<&fn()>(z); //~ ERROR expected impure fn but found unsafe fn } -fn assign_to_unsafe(x: pure fn(), y: fn(), z: unsafe fn()) { - take::(x); - take::(y); - take::(z); +fn assign_to_unsafe(x: &pure fn(), y: &fn(), z: &unsafe fn()) { + take::<&unsafe fn()>(x); + take::<&unsafe fn()>(y); + take::<&unsafe fn()>(z); } -fn assign_to_pure2(x: pure fn@(), y: fn@(), z: unsafe fn@()) { - take::(x); - take::(y); //~ ERROR expected pure fn but found impure fn - take::(z); //~ ERROR expected pure fn but found unsafe fn +fn assign_to_pure2(x: @pure fn(), y: @fn(), z: @unsafe fn()) { + take::<&pure fn()>(x); + take::<&pure fn()>(y); //~ ERROR expected pure fn but found impure fn + take::<&pure fn()>(z); //~ ERROR expected pure fn but found unsafe fn - take::(x); //~ ERROR expected ~ closure, found @ closure - take::(y); //~ ERROR expected ~ closure, found @ closure - take::(z); //~ ERROR expected ~ closure, found @ closure + take::<~pure fn()>(x); //~ ERROR expected ~ closure, found @ closure + take::<~pure fn()>(y); //~ ERROR expected ~ closure, found @ closure + take::<~pure fn()>(z); //~ ERROR expected ~ closure, found @ closure - take::(x); //~ ERROR expected ~ closure, found @ closure - take::(y); //~ ERROR expected ~ closure, found @ closure - take::(z); //~ ERROR expected ~ closure, found @ closure + take::<~unsafe fn()>(x); //~ ERROR expected ~ closure, found @ closure + take::<~unsafe fn()>(y); //~ ERROR expected ~ closure, found @ closure + take::<~unsafe fn()>(z); //~ ERROR expected ~ closure, found @ closure } fn main() { diff --git a/src/test/compile-fail/regions-fns.rs b/src/test/compile-fail/regions-fns.rs index 914dd22720b7..a4f1825fcaee 100644 --- a/src/test/compile-fail/regions-fns.rs +++ b/src/test/compile-fail/regions-fns.rs @@ -12,7 +12,7 @@ // we reported errors in this case: fn not_ok(a: &uint, b: &b/uint) { - let mut g: fn@(x: &uint) = fn@(x: &b/uint) {}; + let mut g: @fn(x: &uint) = |x: &b/uint| {}; //~^ ERROR mismatched types g(a); } diff --git a/src/test/compile-fail/regions-glb-free-free.rs b/src/test/compile-fail/regions-glb-free-free.rs index f9ea3c6f933a..c25205c58d19 100644 --- a/src/test/compile-fail/regions-glb-free-free.rs +++ b/src/test/compile-fail/regions-glb-free-free.rs @@ -11,7 +11,7 @@ mod argparse { extern mod std; - use either::{Either, Left, Right}; + use core::either::{Either, Left, Right}; pub struct Flag { name: &str, diff --git a/src/test/compile-fail/regions-infer-contravariance-due-to-ret.rs b/src/test/compile-fail/regions-infer-contravariance-due-to-ret.rs index 5c57fe26c24b..936aa79d0328 100644 --- a/src/test/compile-fail/regions-infer-contravariance-due-to-ret.rs +++ b/src/test/compile-fail/regions-infer-contravariance-due-to-ret.rs @@ -14,7 +14,7 @@ // the normal case. struct contravariant { - f: fn@() -> &self/int + f: @fn() -> &self/int } fn to_same_lifetime(bi: contravariant/&r) { diff --git a/src/test/compile-fail/regions-infer-covariance-due-to-arg.rs b/src/test/compile-fail/regions-infer-covariance-due-to-arg.rs index a7363867ddc5..27e1452d9572 100644 --- a/src/test/compile-fail/regions-infer-covariance-due-to-arg.rs +++ b/src/test/compile-fail/regions-infer-covariance-due-to-arg.rs @@ -13,7 +13,7 @@ // You can upcast to a *larger region* but not a smaller one. struct covariant { - f: fn@(x: &self/int) -> int + f: @fn(x: &self/int) -> int } fn to_same_lifetime(bi: covariant/&r) { diff --git a/src/test/compile-fail/regions-infer-invariance-due-to-mutability-3.rs b/src/test/compile-fail/regions-infer-invariance-due-to-mutability-3.rs index 3d831f02a916..c84afc6ca64f 100644 --- a/src/test/compile-fail/regions-infer-invariance-due-to-mutability-3.rs +++ b/src/test/compile-fail/regions-infer-invariance-due-to-mutability-3.rs @@ -9,7 +9,7 @@ // except according to those terms. struct invariant { - f: fn@(x: @mut &self/int) + f: @fn(x: @mut &self/int) } fn to_same_lifetime(bi: invariant/&r) { diff --git a/src/test/compile-fail/regions-infer-invariance-due-to-mutability-4.rs b/src/test/compile-fail/regions-infer-invariance-due-to-mutability-4.rs index 2c232f70bc41..b958aa70aa40 100644 --- a/src/test/compile-fail/regions-infer-invariance-due-to-mutability-4.rs +++ b/src/test/compile-fail/regions-infer-invariance-due-to-mutability-4.rs @@ -9,7 +9,7 @@ // except according to those terms. struct invariant { - f: fn@() -> @mut &self/int + f: @fn() -> @mut &self/int } fn to_same_lifetime(bi: invariant/&r) { diff --git a/src/test/compile-fail/regions-infer-not-param.rs b/src/test/compile-fail/regions-infer-not-param.rs index 33916a543cd4..ca105a1dd5e0 100644 --- a/src/test/compile-fail/regions-infer-not-param.rs +++ b/src/test/compile-fail/regions-infer-not-param.rs @@ -13,15 +13,15 @@ struct direct { } struct indirect1 { - g: fn@(direct) + g: @fn(direct) } struct indirect2 { - g: fn@(direct/&) + g: @fn(direct/&) } struct indirect3 { - g: fn@(direct/&self) + g: @fn(direct/&self) } fn take_direct(p: direct) -> direct { p } //~ ERROR mismatched types diff --git a/src/test/compile-fail/regions-infer-region-in-fn-but-not-type.rs b/src/test/compile-fail/regions-infer-region-in-fn-but-not-type.rs index 7b8b8daf565b..11414a111084 100644 --- a/src/test/compile-fail/regions-infer-region-in-fn-but-not-type.rs +++ b/src/test/compile-fail/regions-infer-region-in-fn-but-not-type.rs @@ -11,7 +11,7 @@ // check that the &int here does not cause us to think that `foo` // contains region pointers -enum foo = fn~(x: &int); +enum foo = ~fn(x: &int); fn take_foo(x: foo/&) {} //~ ERROR no region bound is allowed on `foo` diff --git a/src/test/compile-fail/regions-nested-fns-2.rs b/src/test/compile-fail/regions-nested-fns-2.rs index ee2aea1086be..b4cbbacea3f0 100644 --- a/src/test/compile-fail/regions-nested-fns-2.rs +++ b/src/test/compile-fail/regions-nested-fns-2.rs @@ -12,9 +12,8 @@ fn ignore(_t: T) {} fn nested() { let y = 3; - ignore(fn&(z: &z/int) -> &z/int { - if false { return &y; } //~ ERROR illegal borrow - return z; + ignore(|z: &z/int| -> &z/int { + if false { &y } else { z } //~ ERROR illegal borrow }); } diff --git a/src/test/compile-fail/regions-nested-fns.rs b/src/test/compile-fail/regions-nested-fns.rs index 4d53db35596b..714b863ca1d3 100644 --- a/src/test/compile-fail/regions-nested-fns.rs +++ b/src/test/compile-fail/regions-nested-fns.rs @@ -14,13 +14,13 @@ fn nested(x: &x/int) { let y = 3; let mut ay = &y; //~ ERROR cannot infer an appropriate lifetime - ignore(fn&(z: &z/int) { + ignore(|z: &z/int| { ay = x; ay = &y; //~ ERROR cannot infer an appropriate lifetime ay = z; }); - ignore(fn&(z: &z/int) -> &z/int { + ignore(|z: &z/int| -> &z/int { if false { return x; } //~ ERROR mismatched types if false { return ay; } return z; diff --git a/src/test/compile-fail/regions-scoping.rs b/src/test/compile-fail/regions-scoping.rs index 063bc32f7b44..66f1007afcf9 100644 --- a/src/test/compile-fail/regions-scoping.rs +++ b/src/test/compile-fail/regions-scoping.rs @@ -12,13 +12,12 @@ fn with(t: T, f: fn(T)) { f(t) } fn nested<'x>(x: &'x int) { // (1) do with( - fn&(x: &'x int, // Refers to the region `x` at (1) - y: &'y int, // A fresh region `y` (2) - z: fn<'z>(x: &'x int, // Refers to `x` at (1) - y: &'y int, // Refers to `y` at (2) - z: &'z int) -> &'z int) // A fresh region `z` (3) - -> &x/int { - + |x: &'x int, // Refers to the region `x` at (1) + y: &'y int, // A fresh region `y` (2) + z: &fn<'z>(x: &'x int, // Refers to `x` at (1) + y: &'y int, // Refers to `y` at (2) + z: &'z int) -> &'z int| // A fresh region `z` (3) + -> &x/int { if false { return z(x, y, x); } if false { return z(x, y, y); } diff --git a/src/test/compile-fail/sendfn-is-not-a-lambda.rs b/src/test/compile-fail/sendfn-is-not-a-lambda.rs index 1c6b1310f37f..33bb06e4f264 100644 --- a/src/test/compile-fail/sendfn-is-not-a-lambda.rs +++ b/src/test/compile-fail/sendfn-is-not-a-lambda.rs @@ -8,11 +8,11 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -fn test(f: fn@(uint) -> uint) -> uint { +fn test(f: @fn(uint) -> uint) -> uint { return f(22u); } fn main() { - let f = fn~(x: uint) -> uint { return 4u; }; + let f: ~fn(x: uint) -> uint = |x| 4u; log(debug, test(f)); //~ ERROR expected @ closure, found ~ closure } diff --git a/src/test/compile-fail/spawn-non-nil-fn.rs b/src/test/compile-fail/spawn-non-nil-fn.rs index 88d865d85339..00e3e612e8f5 100644 --- a/src/test/compile-fail/spawn-non-nil-fn.rs +++ b/src/test/compile-fail/spawn-non-nil-fn.rs @@ -12,4 +12,4 @@ extern mod std; -fn main() { task::spawn(fn~() -> int { 10 }); } +fn main() { task::spawn(|| -> int { 10 }); } diff --git a/src/test/pretty/block-arg-disambig.rs b/src/test/pretty/block-arg-disambig.rs index 16ada3de7b29..67fdfffe1d3b 100644 --- a/src/test/pretty/block-arg-disambig.rs +++ b/src/test/pretty/block-arg-disambig.rs @@ -8,5 +8,5 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -fn blk1(b: fn()) -> fn@() { return fn@() { }; } +fn blk1(b: &fn()) -> @fn() { return || { }; } fn test1() { (do blk1 { debug!("hi"); })(); } diff --git a/src/test/run-fail/issue-2144.rs b/src/test/run-fail/issue-2144.rs index d0599e3aaa64..56b7acc7f0f1 100644 --- a/src/test/run-fail/issue-2144.rs +++ b/src/test/run-fail/issue-2144.rs @@ -13,7 +13,7 @@ // Don't leak when the landing pads need to request more stack // than is allowed during normal execution -fn useBlock(f: fn~() -> uint) { useBlock(|| 22u ) } +fn useBlock(f: ~fn() -> uint) { useBlock(|| 22u ) } fn main() { useBlock(|| 22u ); } diff --git a/src/test/run-fail/issue-2156.rs b/src/test/run-fail/issue-2156.rs index a518816533e4..9ca343e3866b 100644 --- a/src/test/run-fail/issue-2156.rs +++ b/src/test/run-fail/issue-2156.rs @@ -11,7 +11,7 @@ // error-pattern:explicit failure // Don't double free the string extern mod std; -use io::ReaderUtil; +use core::io::ReaderUtil; fn main() { do io::with_str_reader(~"") |rdr| { diff --git a/src/test/run-fail/unwind-box-fn-unique.rs b/src/test/run-fail/unwind-box-fn-unique.rs index 6128e96d7bc4..326c304ef3b7 100644 --- a/src/test/run-fail/unwind-box-fn-unique.rs +++ b/src/test/run-fail/unwind-box-fn-unique.rs @@ -16,9 +16,9 @@ fn failfn() { fn main() { let y = ~0; - let x = @fn~() { + let x: @~fn() = @(|| { log(error, copy y); - }; + }); failfn(); log(error, x); } diff --git a/src/test/run-fail/unwind-box-fn.rs b/src/test/run-fail/unwind-box-fn.rs index e1d959694e2d..a2227e6c94ac 100644 --- a/src/test/run-fail/unwind-box-fn.rs +++ b/src/test/run-fail/unwind-box-fn.rs @@ -16,7 +16,7 @@ fn failfn() { fn main() { let y = ~0; - let x = @fn@() { + let x: @@fn() = @|| { log(error, copy y); }; failfn(); diff --git a/src/test/run-fail/unwind-closure.rs b/src/test/run-fail/unwind-closure.rs index 6d52046b3e2f..b84ae2e94fce 100644 --- a/src/test/run-fail/unwind-closure.rs +++ b/src/test/run-fail/unwind-closure.rs @@ -16,6 +16,6 @@ fn f(a: @int) { fn main() { let b = @0; - let g : fn@() = || f(b); + let g: @fn() = || f(b); g(); } diff --git a/src/test/run-fail/unwind-lambda.rs b/src/test/run-fail/unwind-lambda.rs index 1fff98c43384..f92f7874fc39 100644 --- a/src/test/run-fail/unwind-lambda.rs +++ b/src/test/run-fail/unwind-lambda.rs @@ -14,12 +14,13 @@ fn main() { let cheese = ~"roquefort"; let carrots = @~"crunchy"; - fn@(tasties: @~str, macerate: fn(~str)) { + let result: @fn(@~str, &fn(~str)) = (|tasties, macerate| { macerate(copy *tasties); - } (carrots, |food| { + }); + result(carrots, |food| { let mush = food + cheese; let cheese = copy cheese; - let f = fn@() { + let f: &fn() = || { let chew = mush + cheese; fail!(~"so yummy") }; diff --git a/src/test/run-fail/zip-different-lengths.rs b/src/test/run-fail/zip-different-lengths.rs index b50836beaa2e..6f7276af798d 100644 --- a/src/test/run-fail/zip-different-lengths.rs +++ b/src/test/run-fail/zip-different-lengths.rs @@ -12,7 +12,7 @@ // the assert should fail at runtime // error-pattern:Assertion same_length(chars, ints) failed extern mod std; -use vec::{same_length, zip}; +use core::vec::{same_length, zip}; fn enum_chars(start: u8, end: u8) -> ~[char] { assert start < end; 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 2972c425192a..0f19d4ee16b8 100644 --- a/src/test/run-pass/alignment-gep-tup-like-1.rs +++ b/src/test/run-pass/alignment-gep-tup-like-1.rs @@ -12,8 +12,9 @@ type pair = { a: A, b: B }; -fn f(a: A, b: u16) -> fn@() -> (A, u16) { - fn@() -> (A, u16) { (a, b) } +fn f(a: A, b: u16) -> @fn() -> (A, u16) { + let result: @fn() -> (A, u16) = || (a, b); + result } pub fn main() { 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 2f008e515869..1de3fde58f29 100644 --- a/src/test/run-pass/alignment-gep-tup-like-2.rs +++ b/src/test/run-pass/alignment-gep-tup-like-2.rs @@ -23,8 +23,9 @@ fn make_cycle(a: A) { g.rec = Some(g); } -fn f(a: A, b: B) -> fn@() -> (A, B) { - fn@() -> (A, B) { (a, b) } +fn f(a: A, b: B) -> @fn() -> (A, B) { + let result: @fn() -> (A, B) = || (a, b); + result } pub fn main() { diff --git a/src/test/run-pass/auto-encode.rs b/src/test/run-pass/auto-encode.rs index e4004c6dc221..171e7a836bee 100644 --- a/src/test/run-pass/auto-encode.rs +++ b/src/test/run-pass/auto-encode.rs @@ -17,13 +17,13 @@ extern mod std; // These tests used to be separate files, but I wanted to refactor all // the common code. -use cmp::Eq; -use std::ebml; use EBReader = std::ebml::reader; use EBWriter = std::ebml::writer; -use io::Writer; -use std::serialize::{Encodable, Decodable}; +use core::cmp::Eq; +use core::io::Writer; +use std::ebml; use std::prettyprint; +use std::serialize::{Encodable, Decodable}; use std::time; fn test_prettyprint>( diff --git a/src/test/run-pass/block-arg-call-as.rs b/src/test/run-pass/block-arg-call-as.rs index fd5662bd46b4..1549eb6fbc23 100644 --- a/src/test/run-pass/block-arg-call-as.rs +++ b/src/test/run-pass/block-arg-call-as.rs @@ -10,19 +10,15 @@ extern mod std; -fn asSendfn( f : fn~()->uint ) -> uint { +fn asSendfn( f : ~fn()->uint ) -> uint { return f(); } -fn asLambda( f : fn@()->uint ) -> uint { +fn asLambda( f : @fn()->uint ) -> uint { return f(); } -fn asBlock( f : fn&()->uint ) -> uint { - return f(); -} - -fn asAny( f : fn()->uint ) -> uint { +fn asBlock( f : &fn()->uint ) -> uint { return f(); } 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 20a1123ecf4c..04adeb9c71b1 100644 --- a/src/test/run-pass/block-arg-used-as-lambda.rs +++ b/src/test/run-pass/block-arg-used-as-lambda.rs @@ -8,12 +8,12 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -fn to_lambda(f: fn@(uint) -> uint) -> fn@(uint) -> uint { +fn to_lambda(f: @fn(uint) -> uint) -> @fn(uint) -> uint { return f; } pub fn main() { - let x: fn@(uint) -> uint = to_lambda(|x| x * 2u ); + let x: @fn(uint) -> uint = to_lambda(|x| x * 2u ); let y = to_lambda(x); let x_r = x(22u); diff --git a/src/test/run-pass/cap-clause-move.rs b/src/test/run-pass/cap-clause-move.rs index e27434400c18..7089e596619e 100644 --- a/src/test/run-pass/cap-clause-move.rs +++ b/src/test/run-pass/cap-clause-move.rs @@ -11,21 +11,21 @@ pub fn main() { let x = ~1; let y = ptr::addr_of(&(*x)) as uint; - let lam_move = fn@() -> uint { ptr::addr_of(&(*x)) as uint }; + let lam_move: @fn() -> uint = || ptr::addr_of(&(*x)) as uint; assert lam_move() == y; let x = ~2; let y = ptr::addr_of(&(*x)) as uint; - let lam_move: fn@() -> uint = || ptr::addr_of(&(*x)) as uint; + let lam_move: @fn() -> uint = || ptr::addr_of(&(*x)) as uint; assert lam_move() == y; let x = ~3; let y = ptr::addr_of(&(*x)) as uint; - let snd_move = fn~() -> uint { ptr::addr_of(&(*x)) as uint }; + let snd_move: ~fn() -> uint = || ptr::addr_of(&(*x)) as uint; assert snd_move() == y; let x = ~4; let y = ptr::addr_of(&(*x)) as uint; - let lam_move: fn~() -> uint = || ptr::addr_of(&(*x)) as uint; + let lam_move: ~fn() -> uint = || ptr::addr_of(&(*x)) as uint; assert lam_move() == y; } diff --git a/src/test/run-pass/class-implements-multiple-traits.rs b/src/test/run-pass/class-implements-multiple-traits.rs index a05b74c9a3c5..4b2c2d0d3081 100644 --- a/src/test/run-pass/class-implements-multiple-traits.rs +++ b/src/test/run-pass/class-implements-multiple-traits.rs @@ -58,10 +58,8 @@ class cat : noisy, scratchy, bitey { new(in_x : uint, in_y : int, in_name: str) { self.meows = @mut in_x; self.how_hungry = @mut in_y; self.name = in_name; self.scratched = dvec(); - let hsher: hashfn = - fn@(p: body_part) -> uint { int::hash(p as int) }; - let eqer : eqfn = - fn@(p: body_part, q: body_part) -> bool { p == q }; + let hsher: hashfn = |p| int::hash(p as int); + let eqer : eqfn = |p, q| p == q; let t : hashmap = hashmap::(hsher, eqer); self.bite_counts = t; 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 32f39177e1c0..8c31b39ac282 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 @@ -16,8 +16,9 @@ type pair = { a: A, b: B }; -fn f(a: A, b: u16) -> fn@() -> (A, u16) { - fn@() -> (A, u16) { (a, b) } +fn f(a: A, b: u16) -> @fn() -> (A, u16) { + let result: @fn() -> (A, u16) = || (a, b); + result } pub fn main() { diff --git a/src/test/run-pass/cycle-collection2.rs b/src/test/run-pass/cycle-collection2.rs index 125c3ba1027b..cd148417f4c6 100644 --- a/src/test/run-pass/cycle-collection2.rs +++ b/src/test/run-pass/cycle-collection2.rs @@ -8,13 +8,13 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -struct foo { z: fn@() } +struct foo { z: @fn() } fn nop() { } fn nop_foo(_x : @mut foo) { } pub fn main() { let w = @mut foo{ z: || nop() }; - let x: fn@() = || nop_foo(w); + 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 8a3139157fdf..8b613093944c 100644 --- a/src/test/run-pass/cycle-collection4.rs +++ b/src/test/run-pass/cycle-collection4.rs @@ -8,13 +8,13 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -struct foo { z : fn@() } +struct foo { z : @fn() } fn nop() { } fn nop_foo(_y: ~[int], _x : @mut foo) { } pub fn main() { let w = @mut foo{ z: || nop() }; - let x : fn@() = || nop_foo(~[], w); + 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 fe0d294f01a7..f724a86555c7 100644 --- a/src/test/run-pass/cycle-collection5.rs +++ b/src/test/run-pass/cycle-collection5.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -struct foo { z: fn@() } +struct foo { z: @fn() } fn nop() { } fn nop_foo(_y: @int, _x: @mut foo) { } @@ -17,6 +17,6 @@ fn o() -> @int { @10 } pub fn main() { let w = @mut foo { z: || nop() }; - let x : fn@() = || nop_foo(o(), w); + let x : @fn() = || nop_foo(o(), w); w.z = x; } diff --git a/src/test/run-pass/do-for-no-args.rs b/src/test/run-pass/do-for-no-args.rs index 745d941182e6..c89d693c8163 100644 --- a/src/test/run-pass/do-for-no-args.rs +++ b/src/test/run-pass/do-for-no-args.rs @@ -10,9 +10,9 @@ // Testing that we can drop the || in for/do exprs -fn f(f: fn@() -> bool) { } +fn f(f: @fn() -> bool) { } -fn d(f: fn@()) { } +fn d(f: @fn()) { } pub fn main() { for f { } diff --git a/src/test/run-pass/do-stack.rs b/src/test/run-pass/do-stack.rs index c42a0dc57392..b1113f5ad51f 100644 --- a/src/test/run-pass/do-stack.rs +++ b/src/test/run-pass/do-stack.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -fn f(f: fn&(int)) { f(10) } +fn f(f: &fn(int)) { f(10) } 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 f6b00ce78813..a7a34d06f1e8 100644 --- a/src/test/run-pass/do1.rs +++ b/src/test/run-pass/do1.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -fn f(f: fn@(int)) { f(10) } +fn f(f: @fn(int)) { f(10) } 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 1f0d82ec7b5f..d82331c60452 100644 --- a/src/test/run-pass/do2.rs +++ b/src/test/run-pass/do2.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -fn f(f: fn@(int) -> int) -> int { f(10) } +fn f(f: @fn(int) -> int) -> int { f(10) } 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 f7660e35f598..09337d892a71 100644 --- a/src/test/run-pass/do3.rs +++ b/src/test/run-pass/do3.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -fn f(f: fn@(int) -> int) -> int { f(10) } +fn f(f: @fn(int) -> int) -> int { f(10) } pub fn main() { assert do f |i| { i } == 10; diff --git a/src/test/run-pass/explicit-self-generic.rs b/src/test/run-pass/explicit-self-generic.rs index 5df155e4ad3f..88c78e9e9975 100644 --- a/src/test/run-pass/explicit-self-generic.rs +++ b/src/test/run-pass/explicit-self-generic.rs @@ -15,8 +15,8 @@ extern mod std; * * The hash should concentrate entropy in the lower bits. */ -type HashFn = pure fn~(K) -> uint; -type EqFn = pure fn~(K, K) -> bool; +type HashFn = ~pure fn(K) -> uint; +type EqFn = ~pure fn(K, K) -> bool; struct LM { resize_at: uint, size: uint } diff --git a/src/test/run-pass/expr-alt-generic-box1.rs b/src/test/run-pass/expr-alt-generic-box1.rs index 81e14b186388..7f477d3f103a 100644 --- a/src/test/run-pass/expr-alt-generic-box1.rs +++ b/src/test/run-pass/expr-alt-generic-box1.rs @@ -12,7 +12,7 @@ // -*- rust -*- -type compare = fn@(@T, @T) -> bool; +type compare = @fn(@T, @T) -> bool; fn test_generic(expected: @T, eq: compare) { let actual: @T = match true { true => { expected }, _ => fail!() }; diff --git a/src/test/run-pass/expr-alt-generic-box2.rs b/src/test/run-pass/expr-alt-generic-box2.rs index e5c82f9edb01..5612cca639d0 100644 --- a/src/test/run-pass/expr-alt-generic-box2.rs +++ b/src/test/run-pass/expr-alt-generic-box2.rs @@ -11,7 +11,7 @@ // xfail-fast // -*- rust -*- -type compare = fn@(T, T) -> bool; +type compare = @fn(T, T) -> bool; fn test_generic(expected: T, eq: compare) { let actual: T = match true { true => { expected }, _ => fail!(~"wat") }; diff --git a/src/test/run-pass/expr-alt-generic-unique1.rs b/src/test/run-pass/expr-alt-generic-unique1.rs index ec51fabd4a75..3c1131455f17 100644 --- a/src/test/run-pass/expr-alt-generic-unique1.rs +++ b/src/test/run-pass/expr-alt-generic-unique1.rs @@ -11,7 +11,7 @@ // -*- rust -*- -type compare = fn@(~T, ~T) -> bool; +type compare = @fn(~T, ~T) -> bool; fn test_generic(expected: ~T, eq: compare) { let actual: ~T = match true { diff --git a/src/test/run-pass/expr-alt-generic-unique2.rs b/src/test/run-pass/expr-alt-generic-unique2.rs index 7f1c2e17dd52..2d45e6a7a3ee 100644 --- a/src/test/run-pass/expr-alt-generic-unique2.rs +++ b/src/test/run-pass/expr-alt-generic-unique2.rs @@ -11,7 +11,7 @@ // xfail-fast // -*- rust -*- -type compare = fn@(T, T) -> bool; +type compare = @fn(T, T) -> bool; fn test_generic(expected: T, eq: compare) { let actual: T = match true { diff --git a/src/test/run-pass/expr-alt-generic.rs b/src/test/run-pass/expr-alt-generic.rs index dcffcd0ad23f..df7fbb8d5b2c 100644 --- a/src/test/run-pass/expr-alt-generic.rs +++ b/src/test/run-pass/expr-alt-generic.rs @@ -11,7 +11,7 @@ // xfail-fast // -*- rust -*- -type compare = fn@(T, T) -> bool; +type compare = @fn(T, T) -> bool; fn test_generic(expected: T, eq: compare) { let actual: T = match true { true => { expected }, _ => fail!(~"wat") }; diff --git a/src/test/run-pass/expr-block-fn.rs b/src/test/run-pass/expr-block-fn.rs index fd69a702f1b0..eb82a2a44454 100644 --- a/src/test/run-pass/expr-block-fn.rs +++ b/src/test/run-pass/expr-block-fn.rs @@ -11,7 +11,7 @@ fn test_fn() { - type t = fn@() -> int; + type t = @fn() -> int; fn ten() -> int { return 10; } let rs: t = { ten }; //assert (rs() == 10); diff --git a/src/test/run-pass/expr-block-generic-box1.rs b/src/test/run-pass/expr-block-generic-box1.rs index 440a25b59cda..737ff99440d5 100644 --- a/src/test/run-pass/expr-block-generic-box1.rs +++ b/src/test/run-pass/expr-block-generic-box1.rs @@ -12,7 +12,7 @@ // -*- rust -*- -type compare = fn@(@T, @T) -> bool; +type compare = @fn(@T, @T) -> bool; fn test_generic(expected: @T, eq: compare) { let actual: @T = { expected }; diff --git a/src/test/run-pass/expr-block-generic-box2.rs b/src/test/run-pass/expr-block-generic-box2.rs index 3851578d5474..eeda810b5c6c 100644 --- a/src/test/run-pass/expr-block-generic-box2.rs +++ b/src/test/run-pass/expr-block-generic-box2.rs @@ -12,7 +12,7 @@ // xfail-fast #[legacy_modes]; -type compare = fn@(T, T) -> bool; +type compare = @fn(T, T) -> bool; fn test_generic(expected: T, eq: compare) { let actual: T = { expected }; diff --git a/src/test/run-pass/expr-block-generic-unique1.rs b/src/test/run-pass/expr-block-generic-unique1.rs index c4efe32a31ec..a9074b6f97f3 100644 --- a/src/test/run-pass/expr-block-generic-unique1.rs +++ b/src/test/run-pass/expr-block-generic-unique1.rs @@ -11,7 +11,7 @@ // -*- rust -*- -type compare = fn@(~T, ~T) -> bool; +type compare = @fn(~T, ~T) -> bool; fn test_generic(expected: ~T, eq: compare) { let actual: ~T = { copy expected }; diff --git a/src/test/run-pass/expr-block-generic-unique2.rs b/src/test/run-pass/expr-block-generic-unique2.rs index b0a056e88918..6624e6ea0152 100644 --- a/src/test/run-pass/expr-block-generic-unique2.rs +++ b/src/test/run-pass/expr-block-generic-unique2.rs @@ -12,7 +12,7 @@ // -*- rust -*- #[legacy_modes]; -type compare = fn@(T, T) -> bool; +type compare = @fn(T, T) -> bool; fn test_generic(expected: T, eq: compare) { let actual: T = { expected }; diff --git a/src/test/run-pass/expr-block-generic.rs b/src/test/run-pass/expr-block-generic.rs index ef726e47df3c..63187bee76fe 100644 --- a/src/test/run-pass/expr-block-generic.rs +++ b/src/test/run-pass/expr-block-generic.rs @@ -13,7 +13,7 @@ // xfail-fast // Tests for standalone blocks as expressions with dynamic type sizes -type compare = fn@(T, T) -> bool; +type compare = @fn(T, T) -> bool; fn test_generic(expected: T, eq: compare) { let actual: T = { expected }; diff --git a/src/test/run-pass/expr-if-generic-box1.rs b/src/test/run-pass/expr-if-generic-box1.rs index 16677886d096..fd5e88da730d 100644 --- a/src/test/run-pass/expr-if-generic-box1.rs +++ b/src/test/run-pass/expr-if-generic-box1.rs @@ -12,7 +12,7 @@ // -*- rust -*- -type compare = fn@(@T, @T) -> bool; +type compare = @fn(@T, @T) -> bool; fn test_generic(expected: @T, not_expected: @T, eq: compare) { let actual: @T = if true { expected } else { not_expected }; diff --git a/src/test/run-pass/expr-if-generic-box2.rs b/src/test/run-pass/expr-if-generic-box2.rs index 5a879071a881..08809d035157 100644 --- a/src/test/run-pass/expr-if-generic-box2.rs +++ b/src/test/run-pass/expr-if-generic-box2.rs @@ -12,7 +12,7 @@ // -*- rust -*- #[legacy_modes]; -type compare = fn@(T, T) -> bool; +type compare = @fn(T, T) -> bool; fn test_generic(expected: T, not_expected: T, eq: compare) { let actual: T = if true { expected } else { not_expected }; diff --git a/src/test/run-pass/expr-if-generic.rs b/src/test/run-pass/expr-if-generic.rs index 4e52fec5c195..18cc4048242c 100644 --- a/src/test/run-pass/expr-if-generic.rs +++ b/src/test/run-pass/expr-if-generic.rs @@ -12,7 +12,7 @@ // -*- rust -*- // Tests for if as expressions with dynamic type sizes -type compare = fn@(T, T) -> bool; +type compare = @fn(T, T) -> bool; fn test_generic(expected: T, not_expected: T, eq: compare) { let actual: T = if true { expected } else { not_expected }; diff --git a/src/test/run-pass/fixed-point-bind-box.rs b/src/test/run-pass/fixed-point-bind-box.rs index a1b41ca4b527..e28191ce35ef 100644 --- a/src/test/run-pass/fixed-point-bind-box.rs +++ b/src/test/run-pass/fixed-point-bind-box.rs @@ -10,15 +10,15 @@ // xfail-fast -fn fix_help(f: extern fn(fn@(A) -> B, A) -> B, x: A) -> B { +fn fix_help(f: extern fn(@fn(A) -> B, A) -> B, x: A) -> B { return f( |a| fix_help(f, a), x); } -fn fix(f: extern fn(fn@(A) -> B, A) -> B) -> fn@(A) -> B { +fn fix(f: extern fn(@fn(A) -> B, A) -> B) -> @fn(A) -> B { return |a| fix_help(f, a); } -fn fact_(f: fn@(v: int) -> int, n: int) -> int { +fn fact_(f: @fn(v: int) -> int, n: int) -> int { // fun fact 0 = 1 return if n == 0 { 1 } else { n * f(n - 1) }; } diff --git a/src/test/run-pass/fixed-point-bind-unique.rs b/src/test/run-pass/fixed-point-bind-unique.rs index dfd52940e73c..0c34a94c9821 100644 --- a/src/test/run-pass/fixed-point-bind-unique.rs +++ b/src/test/run-pass/fixed-point-bind-unique.rs @@ -10,15 +10,15 @@ // xfail-fast -fn fix_help(f: extern fn(fn@(A) -> B, A) -> B, x: A) -> B { +fn fix_help(f: extern fn(@fn(A) -> B, A) -> B, x: A) -> B { return f(|a| fix_help(f, a), x); } -fn fix(f: extern fn(fn@(A) -> B, A) -> B) -> fn@(A) -> B { +fn fix(f: extern fn(@fn(A) -> B, A) -> B) -> @fn(A) -> B { return |a| fix_help(f, a); } -fn fact_(f: fn@(v: int) -> int, n: int) -> int { +fn fact_(f: @fn(v: int) -> int, n: int) -> int { // fun fact 0 = 1 return if n == 0 { 1 } else { n * f(n - 1) }; } 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 c08d8f61033b..6facfc92d3e2 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 @@ -8,12 +8,12 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -fn add(n: int) -> fn@(int) -> int { - fn@(m: int) -> int { m + n } +fn add(n: int) -> @fn(int) -> int { + let result: @fn(int) -> int = |m| m + n; + result } -pub fn main() -{ +pub fn main() { assert add(3)(4) == 7; let add3 : fn(int)->int = add(3); assert add3(4) == 7; 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 013b8ba4adb2..be07da77baa7 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 @@ -8,20 +8,21 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -fn add(n: int) -> fn@(int) -> int { - fn@(m: int) -> int { m + n } +fn add(n: int) -> @fn(int) -> int { + let result: @fn(int) -> int = |m| m + n; + result } pub fn main() { assert add(3)(4) == 7; - let add1 : fn@(int)->int = add(1); + let add1 : @fn(int)->int = add(1); assert add1(6) == 7; - let add2 : &(fn@(int)->int) = &add(2); + let add2 : &(@fn(int)->int) = &add(2); assert (*add2)(5) == 7; - let add3 : fn(int)->int = add(3); + let add3 : &fn(int)->int = add(3); assert add3(4) == 7; } 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 5f69af311347..853b44ed76cb 100644 --- a/src/test/run-pass/fn-bare-coerce-to-shared.rs +++ b/src/test/run-pass/fn-bare-coerce-to-shared.rs @@ -10,7 +10,7 @@ fn bare() {} -fn likes_shared(f: fn@()) { f() } +fn likes_shared(f: @fn()) { f() } pub fn main() { likes_shared(bare); diff --git a/src/test/run-pass/fn-coerce-field.rs b/src/test/run-pass/fn-coerce-field.rs index d1c903411afb..39e4f52873a3 100644 --- a/src/test/run-pass/fn-coerce-field.rs +++ b/src/test/run-pass/fn-coerce-field.rs @@ -9,7 +9,7 @@ // except according to those terms. struct r { - field: fn@() + field: @fn() } pub fn main() { diff --git a/src/test/run-pass/fn-type-infer.rs b/src/test/run-pass/fn-type-infer.rs index 4fd78286e33c..a753005069ff 100644 --- a/src/test/run-pass/fn-type-infer.rs +++ b/src/test/run-pass/fn-type-infer.rs @@ -9,6 +9,8 @@ // except according to those terms. pub fn main() { - // We should be able to type infer inside of fn@s. - let f = fn@() { let i = 10; }; + // We should be able to type infer inside of @fns. + let f = || { + let i = 10; + }; } diff --git a/src/test/run-pass/fun-call-variants.rs b/src/test/run-pass/fun-call-variants.rs index 88bd16538615..b51f60f95a8a 100644 --- a/src/test/run-pass/fun-call-variants.rs +++ b/src/test/run-pass/fun-call-variants.rs @@ -9,7 +9,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -fn ho(f: fn@(int) -> int) -> int { let n: int = f(3); return n; } +fn ho(f: @fn(int) -> int) -> int { let n: int = f(3); return n; } fn direct(x: int) -> int { return x + 1; } diff --git a/src/test/run-pass/hashmap-memory.rs b/src/test/run-pass/hashmap-memory.rs index b90633bab01e..72d4ab7aeabc 100644 --- a/src/test/run-pass/hashmap-memory.rs +++ b/src/test/run-pass/hashmap-memory.rs @@ -29,7 +29,7 @@ mod map_reduce { use std::oldmap::HashMap; use core::comm::*; - pub type putter = fn@(~str, ~str); + pub type putter = @fn(~str, ~str); pub type mapper = extern fn(~str, putter); diff --git a/src/test/run-pass/import-in-block.rs b/src/test/run-pass/import-in-block.rs index 72f6d23cacce..a6d8eac3bd16 100644 --- a/src/test/run-pass/import-in-block.rs +++ b/src/test/run-pass/import-in-block.rs @@ -9,10 +9,10 @@ // except according to those terms. pub fn main() { - use vec::from_fn; - log(debug, vec::len(from_fn(2, |i| i))); + use core::vec::from_fn; + log(debug, ::core::vec::len(from_fn(2, |i| i))); { - use vec::*; + use core::vec::*; log(debug, len(~[2])); } } diff --git a/src/test/run-pass/import3.rs b/src/test/run-pass/import3.rs index dedb2f2a99d5..972a36697317 100644 --- a/src/test/run-pass/import3.rs +++ b/src/test/run-pass/import3.rs @@ -12,7 +12,7 @@ use baz::zed; -use zed::bar; +use baz::zed::bar; mod baz { pub mod zed { diff --git a/src/test/run-pass/import6.rs b/src/test/run-pass/import6.rs index 88b839c0c08a..bbdbdd54f91f 100644 --- a/src/test/run-pass/import6.rs +++ b/src/test/run-pass/import6.rs @@ -18,6 +18,6 @@ mod foo { } } mod bar { - pub use zed::baz; + pub use foo::zed::baz; } pub fn main() { baz(); } diff --git a/src/test/run-pass/import7.rs b/src/test/run-pass/import7.rs index d5e15ea48e95..4c6cc3458c43 100644 --- a/src/test/run-pass/import7.rs +++ b/src/test/run-pass/import7.rs @@ -18,7 +18,7 @@ mod foo { } } mod bar { - pub use zed::baz; + pub use foo::zed::baz; pub mod foo { pub mod zed {} } diff --git a/src/test/run-pass/infer-with-expected.rs b/src/test/run-pass/infer-with-expected.rs index bbb094d0cade..723cc8ef633e 100644 --- a/src/test/run-pass/infer-with-expected.rs +++ b/src/test/run-pass/infer-with-expected.rs @@ -13,7 +13,7 @@ // type must be known in this context' if the passing down doesn't // happen.) -fn eat_tup(_r: ~@(int, fn@(Pair) -> int)) {} +fn eat_tup(_r: ~@(int, @fn(Pair) -> int)) {} fn eat_rec(_r: @~Rec) {} struct Rec { a: int, b: fn(Pair) -> int } diff --git a/src/test/run-pass/issue-1516.rs b/src/test/run-pass/issue-1516.rs index b277b880c76b..33be716cc5f4 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 -pub fn main() { let early_error: fn@(str) -> ! = {|msg| fail!() }; } +pub fn main() { let early_error: @fn(str) -> ! = {|msg| fail!() }; } diff --git a/src/test/run-pass/issue-1895.rs b/src/test/run-pass/issue-1895.rs index 42c6ae38b6af..67877795cc0d 100644 --- a/src/test/run-pass/issue-1895.rs +++ b/src/test/run-pass/issue-1895.rs @@ -10,8 +10,7 @@ pub fn main() { let x = 1; - let y = fn@() -> int { - x - }(); + let y: @fn() -> int = || x; + let z = y(); } diff --git a/src/test/run-pass/issue-1989.rs b/src/test/run-pass/issue-1989.rs index 95129851d5bc..e3327283a816 100644 --- a/src/test/run-pass/issue-1989.rs +++ b/src/test/run-pass/issue-1989.rs @@ -17,13 +17,13 @@ enum maybe_pointy { struct Pointy { a : maybe_pointy, - f : fn@()->(), + f : @fn()->(), } fn empty_pointy() -> @mut Pointy { return @mut Pointy{ a : none, - f : fn@()->(){}, + f : || {}, } } diff --git a/src/test/run-pass/issue-2185.rs b/src/test/run-pass/issue-2185.rs index a8533b574e86..cd2273ab173f 100644 --- a/src/test/run-pass/issue-2185.rs +++ b/src/test/run-pass/issue-2185.rs @@ -18,21 +18,21 @@ trait iterable { fn iter(blk: fn(A)); } -impl iterable for fn@(fn(A)) { +impl iterable for @fn(&fn(A)) { fn iter(blk: fn(A)) { self(blk); } } -impl iterable for fn@(fn(uint)) { +impl iterable for @fn(&fn(uint)) { fn iter(blk: fn(&&v: uint)) { self( |i| blk(i) ) } } -fn filter>(self: IA, prd: fn@(A) -> bool, blk: fn(A)) { +fn filter>(self: IA, prd: @fn(A) -> bool, blk: &fn(A)) { do self.iter |a| { if prd(a) { blk(a) } } } -fn foldl>(self: IA, b0: B, blk: fn(B, A) -> B) -> B { +fn foldl>(self: IA, b0: B, blk: &fn(B, A) -> B) -> B { let mut b = b0; do self.iter |a| { b = blk(b, a); @@ -40,7 +40,7 @@ fn foldl>(self: IA, b0: B, blk: fn(B, A) -> B) -> B { b } -fn range(lo: uint, hi: uint, it: fn(uint)) { +fn range(lo: uint, hi: uint, it: &fn(uint)) { let mut i = lo; while i < hi { it(i); @@ -49,8 +49,8 @@ fn range(lo: uint, hi: uint, it: fn(uint)) { } pub fn main() { - let range: fn@(fn&(uint)) = |a| range(0u, 1000u, a); - let filt: fn@(fn&(v: uint)) = |a| filter( + let range: @fn(&fn(uint)) = |a| range(0u, 1000u, a); + let filt: @fn(&fn(v: uint)) = |a| filter( range, |&&n: uint| n % 3u != 0u && n % 5u != 0u, a); diff --git a/src/test/run-pass/issue-2190-1.rs b/src/test/run-pass/issue-2190-1.rs index 82d4eea3af46..c769c33390fa 100644 --- a/src/test/run-pass/issue-2190-1.rs +++ b/src/test/run-pass/issue-2190-1.rs @@ -11,7 +11,7 @@ // xfail-test const generations: uint = 1024+256+128+49; -fn child_no(x: uint) -> fn~() { +fn child_no(x: uint) -> ~fn() { || { if x < generations { task::spawn(child_no(x+1)); diff --git a/src/test/run-pass/issue-2190-2.rs b/src/test/run-pass/issue-2190-2.rs index 245864cc3391..3842e073faf1 100644 --- a/src/test/run-pass/issue-2190-2.rs +++ b/src/test/run-pass/issue-2190-2.rs @@ -10,19 +10,19 @@ // xfail-test mod a { -fn foo(f: fn&()) { f() } +fn foo(f: &fn()) { f() } fn bar() {} pub fn main() { foo(||bar()); } } mod b { -fn foo(f: Option) { f.iter(|x|x()) } +fn foo(f: Option<&fn()>) { f.iter(|x|x()) } fn bar() {} pub fn main() { foo(Some(bar)); } } mod c { -fn foo(f: Option) { f.iter(|x|x()) } +fn foo(f: Option<&fn()>) { f.iter(|x|x()) } fn bar() {} pub fn main() { foo(Some(||bar())); } } diff --git a/src/test/run-pass/issue-2190.rs b/src/test/run-pass/issue-2190.rs index 2e956e0be5e0..05869952fb8b 100644 --- a/src/test/run-pass/issue-2190.rs +++ b/src/test/run-pass/issue-2190.rs @@ -10,7 +10,7 @@ // xfail-test type t = { - f: fn~() + f: ~fn() }; pub fn main() { diff --git a/src/test/run-pass/issue-2611.rs b/src/test/run-pass/issue-2611.rs index b70a9670df19..7b3247fafc7d 100644 --- a/src/test/run-pass/issue-2611.rs +++ b/src/test/run-pass/issue-2611.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -use iter::BaseIter; +use core::iter::BaseIter; trait FlatMapToVec { fn flat_map_to_vec>(op: fn(&A) -> IB) -> ~[B]; diff --git a/src/test/run-pass/issue-2633.rs b/src/test/run-pass/issue-2633.rs index 04d75fd08e18..2eb63102224c 100644 --- a/src/test/run-pass/issue-2633.rs +++ b/src/test/run-pass/issue-2633.rs @@ -9,12 +9,12 @@ // except according to those terms. struct cat { - meow: fn@(), + meow: @fn(), } fn cat() -> cat { cat { - meow: fn@() { error!("meow"); } + meow: || error!("meow") } } diff --git a/src/test/run-pass/issue-2804.rs b/src/test/run-pass/issue-2804.rs index 613652ec8524..2b4acc34f465 100644 --- a/src/test/run-pass/issue-2804.rs +++ b/src/test/run-pass/issue-2804.rs @@ -11,12 +11,11 @@ // except according to those terms. extern mod std; -use io::WriterUtil; +use core::io::WriterUtil; use std::oldmap::HashMap; use std::json; -enum object -{ +enum object { bool_value(bool), int_value(i64), } diff --git a/src/test/run-pass/issue-2904.rs b/src/test/run-pass/issue-2904.rs index 3ed7d2f842d1..3340a387a128 100644 --- a/src/test/run-pass/issue-2904.rs +++ b/src/test/run-pass/issue-2904.rs @@ -12,7 +12,7 @@ /// Map representation -use io::ReaderUtil; +use core::io::ReaderUtil; extern mod std; diff --git a/src/test/run-pass/issue-3052.rs b/src/test/run-pass/issue-3052.rs index f01ef370e2a8..852c6d995c60 100644 --- a/src/test/run-pass/issue-3052.rs +++ b/src/test/run-pass/issue-3052.rs @@ -8,10 +8,10 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -type Connection = fn@(~[u8]); +type Connection = @fn(~[u8]); fn f() -> Option { - let mock_connection: Connection = fn@(_data: ~[u8]) { }; + let mock_connection: Connection = |_| {}; Some(mock_connection) } diff --git a/src/test/run-pass/issue-3176.rs b/src/test/run-pass/issue-3176.rs index e441fa22b315..e0c074c968f3 100644 --- a/src/test/run-pass/issue-3176.rs +++ b/src/test/run-pass/issue-3176.rs @@ -10,7 +10,7 @@ // xfail-fast -use comm::{Select2, Selectable}; +use core::comm::{Select2, Selectable}; pub fn main() { let (p,c) = comm::stream(); diff --git a/src/test/run-pass/issue-3424.rs b/src/test/run-pass/issue-3424.rs index 5d6367df3b6a..0e4f7d9749dd 100644 --- a/src/test/run-pass/issue-3424.rs +++ b/src/test/run-pass/issue-3424.rs @@ -12,9 +12,9 @@ // rustc --test ignores2.rs && ./ignores2 extern mod std; -use path::{Path}; +use core::path::{Path}; -type rsrc_loader = fn~ (path: &Path) -> result::Result<~str, ~str>; +type rsrc_loader = ~fn(path: &Path) -> result::Result<~str, ~str>; #[test] fn tester() diff --git a/src/test/run-pass/issue-3563-3.rs b/src/test/run-pass/issue-3563-3.rs index f66a3cc474c2..4671b25ce22d 100644 --- a/src/test/run-pass/issue-3563-3.rs +++ b/src/test/run-pass/issue-3563-3.rs @@ -20,7 +20,7 @@ extern mod std; // Extern mod controls linkage. Use controls the visibility of names to modules that are // already linked in. Using WriterUtil allows us to use the write_line method. -use io::WriterUtil; +use core::io::WriterUtil; // Represents a position on a canvas. struct Point { diff --git a/src/test/run-pass/issue-3609.rs b/src/test/run-pass/issue-3609.rs index 83703dacc36e..d0afd0107ee3 100644 --- a/src/test/run-pass/issue-3609.rs +++ b/src/test/run-pass/issue-3609.rs @@ -1,9 +1,9 @@ extern mod std; -use comm::Chan; +use core::comm::Chan; type RingBuffer = ~[float]; -type SamplesFn = fn~ (samples: &RingBuffer); +type SamplesFn = ~fn(samples: &RingBuffer); enum Msg { diff --git a/src/test/run-pass/lambda-infer-unresolved.rs b/src/test/run-pass/lambda-infer-unresolved.rs index b68ec3755d5b..a1f57b380c17 100644 --- a/src/test/run-pass/lambda-infer-unresolved.rs +++ b/src/test/run-pass/lambda-infer-unresolved.rs @@ -9,13 +9,13 @@ // except according to those terms. // This should typecheck even though the type of e is not fully -// resolved when we finish typechecking the fn@. +// resolved when we finish typechecking the @fn. struct Refs { refs: ~[int], n: int } pub fn main() { let e = @mut Refs{refs: ~[], n: 0}; - let f = fn@ () { log(error, e.n); }; + 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 9868f026c650..2dc7079af532 100644 --- a/src/test/run-pass/lambda-no-leak.rs +++ b/src/test/run-pass/lambda-no-leak.rs @@ -8,10 +8,10 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -// Make sure we don't leak fn@s in silly ways. -fn force(f: fn@()) { f() } +// Make sure we don't leak @fns in silly ways. +fn force(f: @fn()) { f() } pub fn main() { let x = 7; - let _f = fn@() { log(error, x); }; - force(fn@() { log(error, x); }); + let _f: @fn() = || log(error, x); + force(|| log(error, x)); } 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 2fd2cc9d22b8..b5fb43680984 100644 --- a/src/test/run-pass/last-use-in-cap-clause.rs +++ b/src/test/run-pass/last-use-in-cap-clause.rs @@ -12,10 +12,11 @@ struct A { a: ~int } -fn foo() -> fn@() -> int { +fn foo() -> @fn() -> int { let k = ~22; let _u = A {a: copy k}; - return fn@() -> int { 22 }; + let result: @fn() -> int = || 22; + result } pub fn main() { diff --git a/src/test/run-pass/last-use-is-capture.rs b/src/test/run-pass/last-use-is-capture.rs index 7f4551b9f397..0535e63fcb49 100644 --- a/src/test/run-pass/last-use-is-capture.rs +++ b/src/test/run-pass/last-use-is-capture.rs @@ -13,7 +13,7 @@ struct A { a: ~int } pub fn main() { - fn invoke(f: fn@()) { f(); } + fn invoke(f: @fn()) { f(); } let k = ~22; let _u = A {a: copy k}; invoke(|| log(error, copy k) ) 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 3c491a7f6957..ee9af0d9d6c1 100644 --- a/src/test/run-pass/monomorphize-trait-in-fn-at.rs +++ b/src/test/run-pass/monomorphize-trait-in-fn-at.rs @@ -9,7 +9,7 @@ // except according to those terms. // test that invoking functions which require -// dictionaries from inside an fn@ works +// dictionaries from inside an @fn works // (at one point, it didn't) fn mk_nil(cx: C) -> uint { @@ -25,8 +25,6 @@ impl ty_ops for () { } pub fn main() { - let fn_env = fn@() -> uint { - mk_nil(()) - }; + let fn_env: @fn() -> uint = || mk_nil(()); assert fn_env() == 22u; } diff --git a/src/test/run-pass/move-nullary-fn.rs b/src/test/run-pass/move-nullary-fn.rs index 0114eeefbfb2..48f4a75ed4e4 100644 --- a/src/test/run-pass/move-nullary-fn.rs +++ b/src/test/run-pass/move-nullary-fn.rs @@ -9,12 +9,12 @@ // except according to those terms. // Issue #922 -fn f2(-thing: fn@()) { } +fn f2(-thing: @fn()) { } -fn f(-thing: fn@()) { +fn f(-thing: @fn()) { f2(thing); } pub fn main() { - f(fn@() {}); + f(|| {}); } diff --git a/src/test/run-pass/new-import-syntax.rs b/src/test/run-pass/new-import-syntax.rs index 3bc1b6c1eba9..267f365c7134 100644 --- a/src/test/run-pass/new-import-syntax.rs +++ b/src/test/run-pass/new-import-syntax.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -use io::println; +use core::io::println; pub fn main() { println("Hello world!"); diff --git a/src/test/run-pass/newlambdas-ret-infer.rs b/src/test/run-pass/newlambdas-ret-infer.rs index 0838ae83cb5a..10ac45922aa6 100644 --- a/src/test/run-pass/newlambdas-ret-infer.rs +++ b/src/test/run-pass/newlambdas-ret-infer.rs @@ -11,9 +11,9 @@ // Test that the lambda kind is inferred correctly as a return // expression -fn shared() -> fn@() { return || (); } +fn shared() -> @fn() { return || (); } -fn unique() -> fn~() { return || (); } +fn unique() -> ~fn() { return || (); } pub fn main() { } diff --git a/src/test/run-pass/newlambdas-ret-infer2.rs b/src/test/run-pass/newlambdas-ret-infer2.rs index 4a4be9859d16..4b580e7fa797 100644 --- a/src/test/run-pass/newlambdas-ret-infer2.rs +++ b/src/test/run-pass/newlambdas-ret-infer2.rs @@ -8,13 +8,13 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -// xfail-test fn~ is not inferred +// xfail-test ~fn is not inferred // Test that the lambda kind is inferred correctly as a return // expression -fn shared() -> fn@() { || () } +fn shared() -> @fn() { || () } -fn unique() -> fn~() { || () } +fn unique() -> ~fn() { || () } pub fn main() { } diff --git a/src/test/run-pass/newlambdas.rs b/src/test/run-pass/newlambdas.rs index c47ee5098a5b..21a3e3506891 100644 --- a/src/test/run-pass/newlambdas.rs +++ b/src/test/run-pass/newlambdas.rs @@ -10,11 +10,11 @@ // Tests for the new |args| expr lambda syntax -fn f(i: int, f: fn(int) -> int) -> int { f(i) } +fn f(i: int, f: &fn(int) -> int) -> int { f(i) } fn g(g: fn()) { } -fn ff() -> fn@(int) -> int { +fn ff() -> @fn(int) -> int { return |x| x + 1; } @@ -23,7 +23,7 @@ pub fn main() { g(||()); assert do f(10) |a| { a } == 10; do g() { } - let _x: fn@() -> int = || 10; - let _y: fn@(int) -> int = |a| a; + let _x: @fn() -> int = || 10; + let _y: @fn(int) -> int = |a| a; assert ff()(10) == 11; } diff --git a/src/test/run-pass/operator-overloading.rs b/src/test/run-pass/operator-overloading.rs index c9e8c6f4b149..8c3423bf8444 100644 --- a/src/test/run-pass/operator-overloading.rs +++ b/src/test/run-pass/operator-overloading.rs @@ -66,5 +66,6 @@ pub fn main() { assert q.y == !(p.y); // Issue #1733 - fn~(_x: int){}(p[true]); + let result: ~fn(int) = |_|(); + result(p[true]); } diff --git a/src/test/run-pass/reflect-visit-data.rs b/src/test/run-pass/reflect-visit-data.rs index c472e5305840..852c580667ad 100644 --- a/src/test/run-pass/reflect-visit-data.rs +++ b/src/test/run-pass/reflect-visit-data.rs @@ -11,9 +11,9 @@ // xfail-fast use core::bool; +use core::libc::c_void; +use core::vec::UnboxedVecRepr; use intrinsic::{TyDesc, get_tydesc, visit_tydesc, TyVisitor}; -use libc::c_void; -use vec::UnboxedVecRepr; #[doc = "High-level interfaces to `intrinsic::visit_ty` reflection system."] @@ -463,9 +463,9 @@ impl TyVisitor for ptr_visit_adaptor { } fn visit_closure_ptr(&self, ck: uint) -> bool { - self.align_to::(); + self.align_to::<@fn()>(); if ! self.inner.visit_closure_ptr(ck) { return false; } - self.bump_past::(); + self.bump_past::<@fn()>(); true } } diff --git a/src/test/run-pass/regions-equiv-fns.rs b/src/test/run-pass/regions-equiv-fns.rs index fb68e3e2b08c..e78a6e69bddb 100644 --- a/src/test/run-pass/regions-equiv-fns.rs +++ b/src/test/run-pass/regions-equiv-fns.rs @@ -13,7 +13,7 @@ fn ok(a: &uint) { // Here &r is an alias for &: - let mut g: fn@(x: &uint) = fn@(x: &r/uint) {}; + let mut g: @fn(x: &uint) = |x: &r/uint| {}; g(a); } diff --git a/src/test/run-pass/regions-fn-subtyping.rs b/src/test/run-pass/regions-fn-subtyping.rs index 2ed0d499e181..b28d8534feca 100644 --- a/src/test/run-pass/regions-fn-subtyping.rs +++ b/src/test/run-pass/regions-fn-subtyping.rs @@ -11,21 +11,21 @@ // Issue #2263. // Should pass region checking. -fn ok(f: fn@(x: &uint)) { +fn ok(f: @fn(x: &uint)) { // Here, g is a function that can accept a uint pointer with // lifetime r, and f is a function that can accept a uint pointer // with any lifetime. The assignment g = f should be OK (i.e., // f's type should be a subtype of g's type), because f can be // used in any context that expects g's type. But this currently // fails. - let mut g: fn@(y: &r/uint) = fn@(x: &r/uint) { }; + let mut g: @fn(y: &r/uint) = |x: &r/uint| { }; g = f; } // This version is the same as above, except that here, g's type is // inferred. -fn ok_inferred(f: fn@(x: &uint)) { - let mut g = fn@(x: &r/uint) { }; +fn ok_inferred(f: @fn(x: &uint)) { + let mut g: @fn(x: &r/uint) = |_| {}; g = f; } diff --git a/src/test/run-pass/regions-mock-trans-impls.rs b/src/test/run-pass/regions-mock-trans-impls.rs index 5c1255f2aa2d..12e8ab1384fc 100644 --- a/src/test/run-pass/regions-mock-trans-impls.rs +++ b/src/test/run-pass/regions-mock-trans-impls.rs @@ -11,7 +11,9 @@ // except according to those terms. extern mod std; -use libc, sys, cast; +use core::libc; +use core::sys; +use core::cast; use std::arena::Arena; struct Bcx { 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 2f0f9e5ae6ad..3f11a9bdce3c 100644 --- a/src/test/run-pass/ret-break-cont-in-block.rs +++ b/src/test/run-pass/ret-break-cont-in-block.rs @@ -10,7 +10,7 @@ // xfail-fast -use cmp::Eq; +use core::cmp::Eq; fn iter(v: ~[T], it: fn(&T) -> bool) { let mut i = 0u, l = v.len(); diff --git a/src/test/run-pass/rt-sched-1.rs b/src/test/run-pass/rt-sched-1.rs index ca37a6663fd6..ce4e6218d0bf 100644 --- a/src/test/run-pass/rt-sched-1.rs +++ b/src/test/run-pass/rt-sched-1.rs @@ -35,7 +35,7 @@ pub fn main() { error!("new_sched_id %?", new_sched_id); let new_task_id = rustrt::rust_new_task_in_sched(new_sched_id); assert !new_task_id.is_null(); - let f = fn~() { + let f: ~fn() = || { unsafe { let child_sched_id = rustrt::rust_get_sched_id(); error!("child_sched_id %?", child_sched_id); diff --git a/src/test/run-pass/sendfn-generic-fn.rs b/src/test/run-pass/sendfn-generic-fn.rs index 8ae976ccadec..c0af726dd8d6 100644 --- a/src/test/run-pass/sendfn-generic-fn.rs +++ b/src/test/run-pass/sendfn-generic-fn.rs @@ -31,10 +31,8 @@ fn test05_start(f: &~fn(v: float, v: ~str) -> Pair) { } fn spawn(f: extern fn(&~fn(A,B)->Pair)) { - let arg = fn~(a: A, b: B) -> Pair { - return make_generic_record(a, b); - }; - task::spawn(|| f(&arg) ); + let arg: ~fn(A, B) -> Pair = |a, b| make_generic_record(a, b); + task::spawn(|| f(&arg)); } fn test05() { diff --git a/src/test/run-pass/sendfn-is-a-block.rs b/src/test/run-pass/sendfn-is-a-block.rs index 099ba326300e..92e709a37387 100644 --- a/src/test/run-pass/sendfn-is-a-block.rs +++ b/src/test/run-pass/sendfn-is-a-block.rs @@ -15,6 +15,6 @@ fn test(f: fn(uint) -> uint) -> uint { } pub fn main() { - let y = test(fn~(x: uint) -> uint { return 4u * x; }); + let y = test(|x| 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 fce0889e0a9b..9b71f678122c 100644 --- a/src/test/run-pass/sendfn-spawn-with-fn-arg.rs +++ b/src/test/run-pass/sendfn-spawn-with-fn-arg.rs @@ -10,17 +10,17 @@ pub fn main() { test05(); } -fn test05_start(&&f: fn~(int)) { +fn test05_start(&&f: ~fn(int)) { f(22); } fn test05() { let three = ~3; - let fn_to_send = fn~(n: int) { + let fn_to_send: ~fn(int) = |n| { log(error, *three + n); // will copy x into the closure assert(*three == 3); }; - task::spawn(fn~() { + task::spawn(|| { test05_start(fn_to_send); }); } diff --git a/src/test/run-pass/stat.rs b/src/test/run-pass/stat.rs index 21d494e00886..c39a0f36d580 100644 --- a/src/test/run-pass/stat.rs +++ b/src/test/run-pass/stat.rs @@ -11,7 +11,7 @@ // xfail-fast extern mod std; -use io::WriterUtil; +use core::io::WriterUtil; use std::tempfile; pub fn main() { diff --git a/src/test/run-pass/task-comm-0.rs b/src/test/run-pass/task-comm-0.rs index f260e571b42a..3e71875c4b5c 100644 --- a/src/test/run-pass/task-comm-0.rs +++ b/src/test/run-pass/task-comm-0.rs @@ -13,8 +13,8 @@ extern mod std; -use comm::Chan; -use comm::Port; +use core::comm::Chan; +use core::comm::Port; pub fn main() { test05(); } diff --git a/src/test/run-pass/task-killjoin-rsrc.rs b/src/test/run-pass/task-killjoin-rsrc.rs index 991025a1ad28..48a2b3020982 100644 --- a/src/test/run-pass/task-killjoin-rsrc.rs +++ b/src/test/run-pass/task-killjoin-rsrc.rs @@ -39,7 +39,7 @@ fn notify(ch: Chan, v: @mut bool) -> notify { } } -fn joinable(f: fn~()) -> Port { +fn joinable(f: ~fn()) -> Port { fn wrapper(c: Chan, f: fn()) { let b = @mut false; error!("wrapper: task=%? allocated v=%x", 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 805f8e8b1e24..cbfff832736e 100644 --- a/src/test/run-pass/task-spawn-move-and-copy.rs +++ b/src/test/run-pass/task-spawn-move-and-copy.rs @@ -16,7 +16,7 @@ pub fn main() { let x = ~1; let x_in_parent = ptr::addr_of(&(*x)) as uint; - task::spawn(fn~() { + task::spawn(|| { let x_in_child = ptr::addr_of(&(*x)) as uint; ch.send(x_in_child); }); diff --git a/src/test/run-pass/trait-inheritance-num.rs b/src/test/run-pass/trait-inheritance-num.rs index 4e46d6b2b18b..36b1e6cd4de4 100644 --- a/src/test/run-pass/trait-inheritance-num.rs +++ b/src/test/run-pass/trait-inheritance-num.rs @@ -10,8 +10,8 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -use cmp::{Eq, Ord}; -use num::NumCast::from; +use core::cmp::{Eq, Ord}; +use core::num::NumCast::from; extern mod std; use std::cmp::FuzzyEq; diff --git a/src/test/run-pass/trait-inheritance-num0.rs b/src/test/run-pass/trait-inheritance-num0.rs index 1996e05618a0..70eed496db3f 100644 --- a/src/test/run-pass/trait-inheritance-num0.rs +++ b/src/test/run-pass/trait-inheritance-num0.rs @@ -12,7 +12,7 @@ // Extending Num and using inherited static methods -use num::NumCast::from; +use core::num::NumCast::from; trait Num { static fn from_int(i: int) -> Self; diff --git a/src/test/run-pass/trait-inheritance-num1.rs b/src/test/run-pass/trait-inheritance-num1.rs index 03230dc39af3..44b4bd60f1de 100644 --- a/src/test/run-pass/trait-inheritance-num1.rs +++ b/src/test/run-pass/trait-inheritance-num1.rs @@ -8,8 +8,8 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -use cmp::Ord; -use num::NumCast::from; +use core::cmp::Ord; +use core::num::NumCast::from; pub trait NumExt: NumCast Ord { } diff --git a/src/test/run-pass/trait-inheritance-num2.rs b/src/test/run-pass/trait-inheritance-num2.rs index f20181d22d34..5c9d9e6a13b5 100644 --- a/src/test/run-pass/trait-inheritance-num2.rs +++ b/src/test/run-pass/trait-inheritance-num2.rs @@ -12,8 +12,8 @@ // A more complex example of numeric extensions -use cmp::{Eq, Ord}; -use num::NumCast::from; +use core::cmp::{Eq, Ord}; +use core::num::NumCast::from; extern mod std; use std::cmp::FuzzyEq; diff --git a/src/test/run-pass/trait-inheritance-num3.rs b/src/test/run-pass/trait-inheritance-num3.rs index adb9f01fff8a..c2cd56ad1078 100644 --- a/src/test/run-pass/trait-inheritance-num3.rs +++ b/src/test/run-pass/trait-inheritance-num3.rs @@ -8,8 +8,8 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -use cmp::{Eq, Ord}; -use num::NumCast::from; +use core::cmp::{Eq, Ord}; +use core::num::NumCast::from; pub trait NumExt: Eq Ord NumCast {} diff --git a/src/test/run-pass/trait-inheritance-num5.rs b/src/test/run-pass/trait-inheritance-num5.rs index d10126dddb6c..ac8d80359d87 100644 --- a/src/test/run-pass/trait-inheritance-num5.rs +++ b/src/test/run-pass/trait-inheritance-num5.rs @@ -8,8 +8,8 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -use cmp::{Eq, Ord}; -use num::NumCast::from; +use core::cmp::{Eq, Ord}; +use core::num::NumCast::from; pub trait NumExt: Eq NumCast {} diff --git a/src/test/run-pass/trait-inheritance-overloading-simple.rs b/src/test/run-pass/trait-inheritance-overloading-simple.rs index b068d109ccfd..7ecc15a0d812 100644 --- a/src/test/run-pass/trait-inheritance-overloading-simple.rs +++ b/src/test/run-pass/trait-inheritance-overloading-simple.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -use cmp::Eq; +use core::cmp::Eq; trait MyNum : Eq { } diff --git a/src/test/run-pass/trait-inheritance-overloading.rs b/src/test/run-pass/trait-inheritance-overloading.rs index 08f3d41ddad9..54a9ea9ad1e3 100644 --- a/src/test/run-pass/trait-inheritance-overloading.rs +++ b/src/test/run-pass/trait-inheritance-overloading.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -use cmp::Eq; +use core::cmp::Eq; trait MyNum : Add Sub Mul Eq { } diff --git a/src/test/run-pass/uniq-cc-generic.rs b/src/test/run-pass/uniq-cc-generic.rs index def49ef0f8c3..3a23a8246a56 100644 --- a/src/test/run-pass/uniq-cc-generic.rs +++ b/src/test/run-pass/uniq-cc-generic.rs @@ -15,11 +15,12 @@ enum maybe_pointy { struct Pointy { a : maybe_pointy, - d : fn~() -> uint, + d : ~fn() -> uint, } -fn make_uniq_closure(a: A) -> fn~() -> uint { - fn~() -> uint { ptr::addr_of(&a) as uint } +fn make_uniq_closure(a: A) -> ~fn() -> uint { + let result: ~fn() -> uint = || ptr::addr_of(&a) as uint; + result } fn empty_pointy() -> @mut Pointy { diff --git a/src/test/run-pass/uniq-cc.rs b/src/test/run-pass/uniq-cc.rs index 3d72a4118286..b54daa477ecb 100644 --- a/src/test/run-pass/uniq-cc.rs +++ b/src/test/run-pass/uniq-cc.rs @@ -16,14 +16,14 @@ enum maybe_pointy { struct Pointy { a : maybe_pointy, c : ~int, - d : fn~()->(), + d : ~fn()->(), } fn empty_pointy() -> @mut Pointy { return @mut Pointy { a : none, c : ~22, - d : fn~()->(){}, + d : || {}, } } diff --git a/src/test/run-pass/unique-kinds.rs b/src/test/run-pass/unique-kinds.rs index 180ce716dcc9..3cc184572865 100644 --- a/src/test/run-pass/unique-kinds.rs +++ b/src/test/run-pass/unique-kinds.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -use cmp::Eq; +use core::cmp::Eq; fn sendable() { diff --git a/src/test/run-pass/unused-move-capture.rs b/src/test/run-pass/unused-move-capture.rs index 665abe23ee89..62023fdae53b 100644 --- a/src/test/run-pass/unused-move-capture.rs +++ b/src/test/run-pass/unused-move-capture.rs @@ -10,6 +10,6 @@ pub fn main() { let x = ~1; - let lam_move = fn@() { }; + let lam_move: @fn() = || {}; lam_move(); } diff --git a/src/test/run-pass/zip-same-length.rs b/src/test/run-pass/zip-same-length.rs index 167448cfe25b..1ade9e8246fd 100644 --- a/src/test/run-pass/zip-same-length.rs +++ b/src/test/run-pass/zip-same-length.rs @@ -10,7 +10,7 @@ // In this case, the code should compile and should // succeed at runtime -use vec::{head, last, same_length, zip}; +use core::vec::{head, last, same_length, zip}; fn enum_chars(start: u8, end: u8) -> ~[char] { assert start < end;