auto merge of #5197 : pcwalton/rust/fn-types, r=pcwalton

r? @catamorphism
This commit is contained in:
bors 2013-03-02 19:18:37 -08:00
commit 5655ae46a7
270 changed files with 1100 additions and 1333 deletions

View File

@ -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 {

View File

@ -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,

View File

@ -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<int>, Chan<int>) = 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<int>, Chan<int>) = 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::<int>();
# 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<int>, Chan<int>) = 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 {

View File

@ -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],

View File

@ -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:

View File

@ -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 }

View File

@ -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

View File

@ -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)] {

View File

@ -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.

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -1139,7 +1139,7 @@ pub mod fsync {
pub struct Arg<t> {
val: t,
opt_level: Option<Level>,
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<fd_t>)) {
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<FSyncable>)) {
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)
}));
}
}

View File

@ -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;

View File

@ -910,11 +910,10 @@ endpoint is passed to the new task.
*/
pub fn spawn_service<T:Owned,Tb:Owned>(
init: extern fn() -> (SendPacketBuffered<T, Tb>,
RecvPacketBuffered<T, Tb>),
service: fn~(v: RecvPacketBuffered<T, Tb>))
-> SendPacketBuffered<T, Tb>
{
init: extern fn() -> (SendPacketBuffered<T, Tb>,
RecvPacketBuffered<T, Tb>),
service: ~fn(v: RecvPacketBuffered<T, Tb>))
-> SendPacketBuffered<T, Tb> {
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<T:Owned,Tb:Owned>(
init: extern fn() -> (RecvPacketBuffered<T, Tb>,
SendPacketBuffered<T, Tb>),
service: fn~(v: SendPacketBuffered<T, Tb>))
-> RecvPacketBuffered<T, Tb>
{
init: extern fn() -> (RecvPacketBuffered<T, Tb>,
SendPacketBuffered<T, Tb>),
service: ~fn(v: SendPacketBuffered<T, Tb>))
-> RecvPacketBuffered<T, Tb> {
let (client, server) = init();
// This is some nasty gymnastics required to safely move the pipe

View File

@ -489,9 +489,9 @@ impl<V:TyVisitor + MovePtr> TyVisitor for MovePtrAdaptor<V> {
}
fn visit_closure_ptr(&self, ck: uint) -> bool {
self.align_to::<fn@()>();
self.align_to::<@fn()>();
if ! self.inner.visit_closure_ptr(ck) { return false; }
self.bump_past::<fn@()>();
self.bump_past::<@fn()>();
true
}
}

View File

@ -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;
/**

View File

@ -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<util::NonCopyable>,
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<A:Owned>(arg: A, f: fn~(v: A)) {
fn spawn_with<A:Owned>(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<T:Owned>(f: fn~() -> T) -> Result<T,()> {
fn try<T:Owned>(f: ~fn() -> T) -> Result<T,()> {
let (po, ch) = stream::<T>();
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<A:Owned>(arg: A, f: fn~(v: A)) {
pub fn spawn_with<A:Owned>(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<A:Owned>(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<T:Owned>(f: fn~() -> T) -> Result<T,()> {
pub fn try<T:Owned>(f: ~fn() -> T) -> Result<T,()> {
/*!
* 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::<uint>();
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));

View File

@ -173,19 +173,19 @@ fn access_ancestors<U>(x: &unstable::Exclusive<AncestorNode>,
// 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<fn@(...)> to Option<fn&(...)>, 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<fn@(TaskGroupInner)>,
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<fn@(TaskGroupInner)>,
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<fn@(TaskGroupInner)>,
forward_blk: fn(TaskGroupInner) -> bool,
last_generation: uint) -> (Option<AncestorList>, bool) {
bail_opt: Option<@fn(TaskGroupInner)>,
forward_blk: &fn(TaskGroupInner) -> bool,
last_generation: uint)
-> (Option<AncestorList>, 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<Chan<TaskResult>>,
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

View File

@ -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;
}

View File

@ -43,9 +43,9 @@ pub unsafe fn weaken_task(f: &fn(Port<ShutdownMsg>)) {
// 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(); }
}

View File

@ -11,8 +11,9 @@
use std;
use vec;
fn vec_equal<T>(v: ~[T], u: ~[T],
element_equality_test: fn@(&&T, &&T) -> bool) ->
fn vec_equal<T>(v: ~[T],
u: ~[T],
element_equality_test: @fn(&&T, &&T) -> bool) ->
bool {
let Lv = vec::len(v);
if Lv != vec::len(u) { return false; }

View File

@ -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

View File

@ -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<T: Copy>(
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(),

View File

@ -220,7 +220,7 @@ fn usage() {
}
fn main() {
pub fn main() {
let args = os::args().tail();
if !args.is_empty() {

View File

@ -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 {

View File

@ -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};

View File

@ -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 {

View File

@ -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 {

View File

@ -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;

View File

@ -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,

View File

@ -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

View File

@ -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

View File

@ -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;

View File

@ -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(

View File

@ -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;

View File

@ -57,7 +57,7 @@ use writer = std::ebml::writer;
// used by astencode:
type abbrev_map = oldmap::HashMap<ty::t, tyencode::ty_abbrev>;
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);

View File

@ -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)) {

View File

@ -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
}

View File

@ -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.

View File

@ -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,
};
}

View File

@ -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

View File

@ -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,

View File

@ -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<int>) { }
let walk_expr = fn@(expr: @ast::expr, &&depth: int, v: visit::vt<int>) {
let walk_expr: @fn(expr: @ast::expr, &&depth: int, v: visit::vt<int>) =
|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);
};

View File

@ -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<Context>) {
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

View File

@ -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

View File

@ -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);

View File

@ -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(*) |

View File

@ -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);

View File

@ -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<node_id,def>;
@ -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<ident>,
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<ident>,
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<Target> {
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),

View File

@ -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 {

View File

@ -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));

View File

@ -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) {

View File

@ -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);

View File

@ -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);
}

View File

@ -869,15 +869,12 @@ pub fn create_function(fcx: fn_ctxt) -> @Metadata<SubProgramMetadata> {
}
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, _) => {

View File

@ -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);

View File

@ -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 {

View File

@ -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 {

View File

@ -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 => {

View File

@ -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(*) |

View File

@ -389,7 +389,7 @@ pub fn check_fn(ccx: @mut CrateCtxt,
self_info: Option<SelfInfo>) {
let tcx = fcx.ccx.tcx;
let assign = fn@(nid: ast::node_id, ty_opt: Option<ty::t>) {
let assign: @fn(ast::node_id, Option<ty::t>) = |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);

View File

@ -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(*) |

View File

@ -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;

View File

@ -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;

View File

@ -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);
}

View File

@ -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,

View File

@ -46,12 +46,12 @@ pub struct Ctxt {
ast_map: ast_map::map
}
type SrvOwner<T> = fn(srv: Srv) -> T;
pub type CtxtHandler<T> = fn~(ctxt: Ctxt) -> T;
type Parser = fn~(Session, s: ~str) -> @ast::crate;
type SrvOwner<T> = &fn(srv: Srv) -> T;
pub type CtxtHandler<T> = ~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<Msg>, source: ~str, parse: Parser) {
pub fn exec<T:Owned>(
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()
}

View File

@ -114,7 +114,7 @@ fn fold_item(
fn parse_item_attrs<T:Owned>(
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,

View File

@ -85,7 +85,7 @@ fn opts() -> ~[(getopts::Opt, ~str)] {
}
pub fn usage() {
use io::println;
use core::io::println;
println(~"Usage: rustdoc [options] <cratefile>\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");

View File

@ -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<A>") == ~"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/&")

View File

@ -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::<WriteInstr>();
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 {

View File

@ -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<T>(what: ~str, f: fn() -> T) -> T {
pub fn time<T>(what: ~str, f: fn() -> T) -> T {
let start = std::time::precise_time_s();
let rv = f();
let end = std::time::precise_time_s();

View File

@ -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]) {

View File

@ -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,

View File

@ -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]

View File

@ -53,7 +53,7 @@ pub struct CVec<T> {
}
struct DtorRes {
dtor: Option<fn@()>,
dtor: Option<@fn()>,
}
impl Drop for DtorRes {
@ -65,7 +65,7 @@ impl Drop for DtorRes {
}
}
fn DtorRes(dtor: Option<fn@()>) -> DtorRes {
fn DtorRes(dtor: Option<@fn()>) -> DtorRes {
DtorRes {
dtor: dtor
}
@ -102,7 +102,7 @@ pub unsafe fn CVec<T>(base: *mut T, len: uint) -> CVec<T> {
* * dtor - A function to run when the value is destructed, useful
* for freeing the buffer, etc.
*/
pub unsafe fn c_vec_with_dtor<T>(base: *mut T, len: uint, dtor: fn@())
pub unsafe fn c_vec_with_dtor<T>(base: *mut T, len: uint, dtor: @fn())
-> CVec<T> {
return CVec{
base: base,

View File

@ -771,10 +771,10 @@ mod test {
writer_chan: WriterChanFactory<F>,
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

View File

@ -37,13 +37,13 @@ pub struct Future<A> {
}
// 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<A> Drop for Future<A> {
fn finalize(&self) {}
}
priv enum FutureState<A> {
Pending(fn~() -> A),
Pending(~fn() -> A),
Evaluating,
Forced(A)
}
@ -125,7 +125,7 @@ pub fn from_fn<A>(f: ~fn() -> A) -> Future<A> {
Future {state: Pending(f)}
}
pub fn spawn<A:Owned>(blk: fn~() -> A) -> Future<A> {
pub fn spawn<A:Owned>(blk: ~fn() -> A) -> Future<A> {
/*!
* Create a future from a unique closure.
*

View File

@ -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<Option<TcpErrData>>),
new_connect_cb: fn~(TcpNewConnection,
on_establish_cb: ~fn(SharedChan<Option<TcpErrData>>),
new_connect_cb: ~fn(TcpNewConnection,
SharedChan<Option<TcpErrData>>))
-> 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<Option<TcpErrData>>),
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<Option<TcpErrData>>),
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<Option<TcpErrData>>,
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,

View File

@ -94,24 +94,24 @@ pub fn map<A:Copy + Owned,B:Copy + Owned>(
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<A:Copy + Owned,B:Copy + Owned>(
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<A:Copy + Owned>(
{
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<A:Copy + Owned>(
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 }
}

View File

@ -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 {

View File

@ -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;
}

View File

@ -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);

View File

@ -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);

View File

@ -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::*;

View File

@ -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
}

View File

@ -396,7 +396,7 @@ fn unwrap<T:Owned + Encodable<json::Encoder> + Decodable<json::Decoder>>(
//#[test]
fn test() {
use io::WriterUtil;
use core::io::WriterUtil;
let db = @Mut(Database { db_filename: Path("db.json"),
db_cache: LinearMap::new(),

View File

@ -571,10 +571,6 @@ pub enum expr_ {
(implicit) condition is always true. */
expr_loop(blk, Option<ident>),
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

View File

@ -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| {

View File

@ -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

View File

@ -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<span>
}
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<span>
}
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)
}

View File

@ -15,7 +15,7 @@
* interface.
*/
use prelude::*;
use core::prelude::*;
use ast;
use codemap::span;

View File

@ -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:

View File

@ -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))
}

View File

@ -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;

View File

@ -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;

View File

@ -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<T>(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<T>(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<T>` 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 {

View File

@ -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();

View File

@ -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: T, f: fn@(@ps, T), intr: @ident_interner) -> ~str {
pub fn to_str<T>(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);

Some files were not shown because too many files have changed in this diff Show More