Skip to content

librustc: Stop parsing fn@, fn~, and fn& #5197

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 8 commits into from
2 changes: 1 addition & 1 deletion doc/rust.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
4 changes: 2 additions & 2 deletions doc/tutorial-ffi.md
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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,
Expand Down
45 changes: 22 additions & 23 deletions doc/tutorial-tasks.md
Original file line number Diff line number Diff line change
Expand Up @@ -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!"); }
Expand Down Expand Up @@ -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();
Expand All @@ -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 {
Expand Down Expand Up @@ -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();

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

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

Expand All @@ -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);
Expand Down Expand Up @@ -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| {
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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 {
Expand Down
41 changes: 20 additions & 21 deletions doc/tutorial.md
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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");
Expand All @@ -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!");
}
Expand Down Expand Up @@ -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!");
Expand All @@ -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!");
Expand All @@ -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; }
Expand All @@ -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; }
Expand Down Expand Up @@ -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) } }
Expand Down Expand Up @@ -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 }

Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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) } }
Expand Down Expand Up @@ -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],
Expand Down
16 changes: 8 additions & 8 deletions src/compiletest/compiletest.rc
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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:
Expand Down
7 changes: 4 additions & 3 deletions src/compiletest/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 }

Expand Down
9 changes: 5 additions & 4 deletions src/compiletest/header.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
22 changes: 11 additions & 11 deletions src/compiletest/procsrv.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)] {
Expand Down
Loading