task in a _failing state_.
~~~~
+# use std::task;
# do task::spawn_unlinked {
([1, 2, 3, 4])[0];
}
}
-ten_times(|j| io::println(fmt!("hello, %d", j)));
+ten_times(|j| println(fmt!("hello, %d", j)));
~~~~
let mut i = 0;
while i < 10 {
- io::println("hello\n");
+ println("hello\n");
i = i + 1;
}
~~~~
An example of a for loop over a series of integers:
~~~~
+# use std::uint;
# fn bar(b:uint) { }
for uint::range(0, 256) |i| {
bar(i);
An example of an object type:
~~~~~~~~
+# use std::int;
trait Printable {
fn to_str(&self) -> ~str;
}
}
fn print(a: @Printable) {
- io::println(a.to_str());
+ println(a.to_str());
}
fn main() {
wrapping `malloc` and `free`:
~~~~
+use std::cast;
use std::libc::{c_void, size_t, malloc, free};
+use std::ptr;
use std::unstable::intrinsics;
use std::util;
~~~
# use std::io::print;
# use std::task::spawn;
+# use std::int;
for int::range(0, 20) |child_task_number| {
do spawn {
~~~
# use std::task::spawn;
# use std::comm::{stream, SharedChan};
+# use std::uint;
let (port, chan) = stream();
let chan = SharedChan::new(chan);
~~~
# use std::task::spawn;
# use std::comm::stream;
+# use std::vec;
// Create a vector of ports, one for each child task
let ports = do vec::from_fn(3) |init_val| {
Here is another example showing how futures allow you to background computations. The workload will
be distributed on the available cores.
~~~
+# use std::vec;
+# use std::uint;
fn partial_sum(start: uint) -> f64 {
let mut local_sum = 0f64;
for uint::range(start*100000, (start+1)*100000) |num| {
Here is a small example showing how to use ARCs. We wish to run concurrently several computations on
a single large vector of floats. Each task needs the full vector to perform its duty.
~~~
+# use std::vec;
+# use std::uint;
+# use std::rand;
use extra::arc::ARC;
fn pnorm(nums: &~[float], p: uint) -> float {
}
fn main() {
- let numbers=vec::from_fn(1000000, |_| rand::random::<float>());
+ let numbers = vec::from_fn(1000000, |_| rand::random::<float>());
println(fmt!("Inf-norm = %?", numbers.max()));
let numbers_arc = ARC(numbers);
created by the line
~~~
# use extra::arc::ARC;
-# let numbers=vec::from_fn(1000000, |_| rand::random::<float>());
+# use std::vec;
+# use std::rand;
+# let numbers = vec::from_fn(1000000, |_| rand::random::<float>());
let numbers_arc=ARC(numbers);
~~~
and a clone of it is sent to each task
~~~
# use extra::arc::ARC;
+# use std::vec;
+# use std::rand;
# let numbers=vec::from_fn(1000000, |_| rand::random::<float>());
# let numbers_arc = ARC(numbers);
# let (port, chan) = stream();
Each task recovers the underlying data by
~~~
# use extra::arc::ARC;
+# use std::vec;
+# use std::rand;
# let numbers=vec::from_fn(1000000, |_| rand::random::<float>());
# let numbers_arc=ARC(numbers);
# let (port, chan) = stream();
~~~
# use std::task::spawn;
+# use std::task;
# fn do_some_work() { loop { task::yield() } }
# do task::try {
// Create a child task that fails
termination with an error).
~~~
+# use std::task;
# fn some_condition() -> bool { false }
# fn calculate_result() -> int { 0 }
let result: Result<int, ()> = do task::try {
either task fails, it kills the other one.
~~~
+# use std::task;
# fn sleep_forever() { loop { task::yield() } }
# do task::try {
do spawn {
~~~
# use std::comm::{stream, Chan, Port};
# use std::task::{spawn, try};
+# use std::task;
# fn sleep_forever() { loop { task::yield() } }
# do task::try {
let (receiver, sender): (Port<int>, Chan<int>) = stream();
an intermediate generation has already exited:
~~~
+# use std::task;
# fn sleep_forever() { loop { task::yield() } }
# fn wait_for_a_while() { for 1000.times { task::yield() } }
# do task::try::<int> {
other at all, using `task::spawn_unlinked` for _isolated failure_.
~~~
+# use std::task;
# fn random() -> uint { 100 }
# fn sleep_for(i: uint) { for i.times { task::yield() } }
# do task::try::<()> {
~~~~
# use extra::comm::DuplexStream;
+# use std::uint;
fn stringifier(channel: &DuplexStream<~str, uint>) {
let mut value: uint;
loop {
~~~~
# use std::task::spawn;
+# use std::uint;
# use extra::comm::DuplexStream;
# fn stringifier(channel: &DuplexStream<~str, uint>) {
# let mut value: uint;
> items.
~~~~
+# use std::float;
fn angle(vector: (float, float)) -> float {
let pi = float::consts::pi;
match vector {
`loop` denotes an infinite loop, and is the preferred way of writing `while true`:
~~~~
+# use std::int;
let mut x = 5;
loop {
x += x - 3;
patterns, as in this definition of `area`:
~~~~
+# use std::float;
# struct Point {x: float, y: float}
# enum Shape { Circle(Point, float), Rectangle(Point, Point) }
fn area(sh: Shape) -> float {
of `vector`:
~~~~
+# use std::vec;
fn map<T, U>(vector: &[T], function: &fn(v: &T) -> U) -> ~[U] {
let mut accumulator = ~[];
for vec::each(vector) |element| {
types might look like the following:
~~~~
+# use std::vec;
trait Seq<T> {
fn len(&self) -> uint;
fn iter(&self, b: &fn(v: &T));
#[no_std];
extern mod core(name = "std", vers = "0.7-pre");
-extern mod std(name = "extra", vers = "0.7-pre");
+extern mod extra(name = "extra", vers = "0.7-pre");
use core::prelude::*;
use core::*;
-use std::getopts;
-use std::test;
+use extra::getopts;
+use extra::test;
use core::result::{Ok, Err};
pub mod common;
pub mod errors;
+mod std {
+ pub use core::cmp;
+ pub use core::str;
+ pub use core::sys;
+ pub use core::unstable;
+}
+
pub fn main() {
let args = os::args();
let config = parse_config(args);
use core::prelude::*;
+use core::io;
+use core::str;
+
pub struct ExpectedError { line: uint, kind: ~str, msg: ~str }
// Load any test directives embedded in the file
use core::prelude::*;
-use common;
use common::config;
+use common;
+
+use core::io;
+use core::os;
+use core::str;
pub struct TestProps {
// Lines that should be expected, in order, on standard out
use core::prelude::*;
+use core::comm;
+use core::io;
+use core::libc::c_int;
+use core::os;
use core::run;
+use core::str;
+use core::task;
#[cfg(target_os = "win32")]
fn target_env(lib_path: &str, prog: &str) -> ~[(~str,~str)] {
use util;
use util::logv;
+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.
use common::config;
+use core::io;
use core::os::getenv;
pub fn make_new_path(path: &str) -> ~str {
#[cfg(test)]
mod tests {
use core::prelude::*;
- use core::cell::Cell;
+
use arc::*;
+ use core::cell::Cell;
+ use core::comm;
+ use core::task;
+
#[test]
fn manually_share_arc() {
let v = ~[1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
#[test]
fn test_mutex_arc_condvar() {
- let arc = ~MutexARC(false);
- let arc2 = ~arc.clone();
- let (p,c) = comm::oneshot();
- let (c,p) = (Cell(c), Cell(p));
- do task::spawn || {
- // wait until parent gets in
- comm::recv_one(p.take());
- do arc2.access_cond |state, cond| {
- *state = true;
- cond.signal();
+ unsafe {
+ let arc = ~MutexARC(false);
+ let arc2 = ~arc.clone();
+ let (p,c) = comm::oneshot();
+ let (c,p) = (Cell(c), Cell(p));
+ do task::spawn || {
+ // wait until parent gets in
+ comm::recv_one(p.take());
+ do arc2.access_cond |state, cond| {
+ *state = true;
+ cond.signal();
+ }
}
- }
- do arc.access_cond |state, cond| {
- comm::send_one(c.take(), ());
- assert!(!*state);
- while !*state {
- cond.wait();
+ do arc.access_cond |state, cond| {
+ comm::send_one(c.take(), ());
+ assert!(!*state);
+ while !*state {
+ cond.wait();
+ }
}
}
}
#[test] #[should_fail] #[ignore(cfg(windows))]
fn test_arc_condvar_poison() {
- let arc = ~MutexARC(1);
- let arc2 = ~arc.clone();
- let (p, c) = comm::stream();
-
- do task::spawn_unlinked || {
- let _ = p.recv();
- do arc2.access_cond |one, cond| {
- cond.signal();
- // Parent should fail when it wakes up.
- assert_eq!(*one, 0);
+ unsafe {
+ let arc = ~MutexARC(1);
+ let arc2 = ~arc.clone();
+ let (p, c) = comm::stream();
+
+ do task::spawn_unlinked || {
+ let _ = p.recv();
+ do arc2.access_cond |one, cond| {
+ cond.signal();
+ // Parent should fail when it wakes up.
+ assert_eq!(*one, 0);
+ }
}
- }
- do arc.access_cond |one, cond| {
- c.send(());
- while *one == 1 {
- cond.wait();
+ do arc.access_cond |one, cond| {
+ c.send(());
+ while *one == 1 {
+ cond.wait();
+ }
}
}
}
#[test] #[should_fail] #[ignore(cfg(windows))]
fn test_mutex_arc_poison() {
- let arc = ~MutexARC(1);
- let arc2 = ~arc.clone();
- do task::try || {
- do arc2.access |one| {
- assert_eq!(*one, 2);
+ unsafe {
+ let arc = ~MutexARC(1);
+ let arc2 = ~arc.clone();
+ do task::try || {
+ do arc2.access |one| {
+ assert_eq!(*one, 2);
+ }
+ };
+ do arc.access |one| {
+ assert_eq!(*one, 1);
}
- };
- do arc.access |one| {
- assert_eq!(*one, 1);
}
}
#[test] #[should_fail] #[ignore(cfg(windows))]
use core::prelude::*;
+use core::str;
+use core::vec;
+
pub trait ToBase64 {
fn to_base64(&self) -> ~str;
}
use core::prelude::*;
+use core::cmp;
+use core::ops;
+use core::uint;
+use core::vec::from_elem;
+use core::vec;
+
struct SmallBitv {
/// only the lowest nbits of this value are used. the rest is undefined.
bits: uint
use core::prelude::*;
+use core::option;
+use core::ptr;
+
/**
* The type representing a foreign chunk of memory
*
use core::comm::{GenericChan, GenericSmartChan, GenericPort};
use core::comm::{Chan, Port, Selectable, Peekable};
+use core::comm;
use core::pipes;
/// An extension of `pipes::stream` that allows both sending and receiving.
use core::prelude::*;
+use core::uint;
use core::util::replace;
+use core::vec;
static initial_capacity: uint = 32u; // 2^5
use core::prelude::*;
use core::managed;
+use core::old_iter;
+use core::vec;
pub type DListLink<T> = Option<@mut DListNode<T>>;
use super::*;
+ use core::old_iter;
+ use core::vec;
+
#[test]
fn test_dlist_concat() {
let a = from_vec([1,2]);
use core::prelude::*;
+use core::io::ReaderUtil;
+use core::io;
+use core::os;
+use core::vec;
+
/**
A summary of the internal state of a `FileInput` object. `line_num`
and `line_num_file` represent the number of lines read in total and in
use super::{FileInput, pathify, input_vec, input_vec_state};
+ use core::io;
+ use core::str;
+ use core::uint;
+ use core::vec;
+
fn make_file(path : &Path, contents: &[~str]) {
let file = io::file_writer(path, [io::Create, io::Truncate]).get();
use core::prelude::*;
-use core::libc;
use core::libc::{c_void, size_t, c_int};
+use core::libc;
+use core::vec;
pub mod rustrt {
use core::libc::{c_int, c_void, size_t};
use core::cast;
use core::io::{Writer, Reader, ReaderUtil};
+ use core::io;
use core::ptr;
use core::sys::size_of;
use core::vec;
-
// FIXME #4074: Copy + Owned != POD
pub struct PodUnflattener<T> {
bogus: ()
use flatpipes::{ByteChan, BytePort};
- use core::io::{Writer, Reader, ReaderUtil};
use core::comm::{Port, Chan};
+ use core::comm;
+ use core::io::{Writer, Reader, ReaderUtil};
+ use core::vec;
pub struct ReaderBytePort<R> {
reader: R
use flatpipes::{BytePort, FlatChan, FlatPort};
use net::tcp::TcpSocketBuf;
+ use core::comm;
+ use core::int;
use core::io::BytesWriter;
+ use core::result;
+ use core::sys;
+ use core::task;
#[test]
#[ignore(reason = "ebml failure")]
use flatpipes::pod;
use io_util::BufReader;
+ use core::comm;
+ use core::io;
+ use core::sys;
+ use core::task;
+
type PortLoader<P> =
~fn(~[u8]) -> FlatPort<int, PodUnflattener<int>, P>;
use core::prelude::*;
-use core::io::{WriterUtil, ReaderUtil};
+use core::char;
+use core::float;
use core::hashmap::HashMap;
+use core::io::{WriterUtil, ReaderUtil};
+use core::io;
+use core::str;
+use core::to_str;
+use core::vec;
use serialize::Encodable;
use serialize;
use super::*;
use core::hashmap::HashMap;
+ use core::io;
+ use core::result;
use std::serialize::Decodable;
// option. This file may not be copied, modified, or distributed
// except according to those terms.
-//! A standard linked list
+//! A standard, garbage-collected linked list.
use core::prelude::*;
+use core::vec;
+
#[deriving(Eq)]
pub enum List<T> {
Cons(T, @List<T>),
use core::cell::Cell;
use core::comm::{stream, SharedChan};
+ use core::io;
+ use core::result;
+ use core::str;
+ use core::task;
// FIXME don't run on fbsd or linux 32 bit (#2064)
#[cfg(target_os="win32")]
use core::prelude::*;
use core::cmp::{Eq, Ord, TotalEq, TotalOrd, Ordering, Less, Equal, Greater};
+use core::int;
use core::num::{IntConvertible, Zero, One, ToStrRadix, FromStrRadix, Orderable};
+use core::str;
+use core::uint;
+use core::vec;
/**
A BigDigit is a BigUint's composing element.
use core::prelude::*;
use super::*;
- use core::num::{IntConvertible, Zero, One, FromStrRadix};
+
use core::cmp::{Less, Equal, Greater};
+ use core::int;
+ use core::num::{IntConvertible, Zero, One, FromStrRadix};
+ use core::str;
+ use core::uint;
+ use core::vec;
#[test]
fn test_from_slice() {
use core::prelude::*;
use super::*;
+
use core::cmp::{Less, Equal, Greater};
+ use core::int;
use core::num::{IntConvertible, Zero, One, FromStrRadix};
+ use core::uint;
+ use core::vec;
#[test]
fn test_from_biguint() {
use core::prelude::*;
-use core::num::{Zero,One,ToStrRadix,FromStrRadix,Round};
+use core::cmp;
use core::from_str::FromStr;
+use core::num::{Zero,One,ToStrRadix,FromStrRadix,Round};
+use core::str;
+use core::vec;
use super::bigint::BigInt;
/// Represents the ratio between 2 numbers.
use core::prelude::*;
+use core::cast;
+use core::ptr;
+use core::sys;
+use core::uint;
+use core::vec;
use future_spawn = future::spawn;
/**
use core::old_iter::BaseIter;
use core::unstable::intrinsics::{move_val_init, init};
use core::util::{replace, swap};
+use core::vec;
pub struct PriorityQueue<T> {
priv data: ~[T],
use core::prelude::*;
+use core::cast;
use core::libc::{c_void, size_t, malloc, free};
+use core::ptr;
+use core::sys;
use core::unstable::intrinsics;
use core::util;
use core::prelude::*;
use core::libc::{c_char, c_int};
+use core::local_data;
+use core::str;
pub mod rustrt {
use core::libc::{c_char, c_int};
use core::prelude::*;
+use core::str;
+use core::uint;
+use core::vec;
+
/// The type of ropes.
pub type Rope = node::Root;
use rope::node;
+ use core::cast;
+ use core::str;
+ use core::uint;
+ use core::vec;
+
/// Implementation of type `rope`
pub enum Root {
/// An empty rope
use rope::node::{Concat, Leaf, Node, height};
+ use core::vec;
+
pub struct T {
stack: ~[@Node],
stackpos: int,
pub mod char_iterator {
use core::prelude::*;
+ use core::str;
+
use rope::node::{Leaf, Node};
use rope::node::leaf_iterator;
#[cfg(test)]
mod tests {
- use rope::*;
use core::prelude::*;
+ use rope::*;
+
+ use core::str;
+ use core::uint;
+ use core::vec;
+
//Utility function, used for sanity check
fn rope_to_string(r: Rope) -> ~str {
match (r) {
use core::prelude::*;
+use core::at_vec;
use core::hashmap::{HashMap, HashSet};
use core::trie::{TrieMap, TrieSet};
+use core::uint;
+use core::vec;
use deque::Deque;
use dlist::DList;
use treemap::{TreeMap, TreeSet};
use core::prelude::*;
+use core::cmp;
use core::container::{Container, Mutable, Map, Set};
use core::old_iter::BaseIter;
use core::old_iter;
-use core::option::{Some, None};
+use core::uint;
use core::util::replace;
+use core::vec;
pub struct SmallIntMap<T> {
priv v: ~[Option<T>],
use super::SmallIntMap;
+ use core::local_data;
+ use core::rand;
+ use core::uint;
+ use core::vec;
+
#[test]
fn test_find_mut() {
let mut m = SmallIntMap::new();
use super::SmallIntSet;
+ use core::vec;
+
#[test]
fn test_disjoint() {
let mut xs = SmallIntSet::new();
use core::prelude::*;
use core::cmp::{Eq, Ord};
+use core::uint;
+use core::util::swap;
use core::vec::len;
use core::vec;
-use core::util::swap;
type Le<'self, T> = &'self fn(v1: &T, v2: &T) -> bool;
use core::prelude::*;
use sort::tim_sort;
+
+ use core::local_data;
use core::rand::RngUtil;
+ use core::rand;
+ use core::uint;
+ use core::vec;
struct CVal {
val: float,
use core::prelude::*;
use sort::*;
+
+ use core::local_data;
use core::rand::RngUtil;
+ use core::rand;
+ use core::uint;
+ use core::vec;
#[test]
fn test_unique() {
pub use core::condition;
pub use core::cmp;
pub use core::sys;
+ pub use core::unstable;
+ pub use core::str;
+ pub use core::os;
}
#[doc(hidden)]
pub mod extra {
use core::prelude::*;
-use core::unstable::sync::{Exclusive, exclusive};
+use core::comm;
use core::ptr;
use core::task;
+use core::unstable::sync::{Exclusive, exclusive};
use core::util;
/****************************************************************************
use core::cast;
use core::cell::Cell;
+ use core::comm;
+ use core::ptr;
use core::result;
use core::task;
use core::vec;
use core::prelude::*;
use core::comm::Chan;
+use core::comm;
use core::task::SchedMode;
use core::task;
use core::vec;
};
let mut pool = TaskPool::new(4, Some(SingleThreaded), f);
for 8.times {
- pool.execute(|i| io::println(fmt!("Hello from thread %u!", *i)));
+ pool.execute(|i| println(fmt!("Hello from thread %u!", *i)));
}
}
use core::prelude::*;
+use core::os;
use core::rand::RngUtil;
+use core::rand;
pub fn mkdtemp(tmpdir: &Path, suffix: &str) -> Option<Path> {
let mut r = rand::rng();
use core::prelude::*;
use tempfile::mkdtemp;
+ use tempfile;
+
use core::os;
+ use core::str;
#[test]
fn test_mkdtemp() {
use sort;
use term;
-use core::to_str::ToStr;
use core::comm::{stream, SharedChan};
+use core::either;
+use core::io;
+use core::num;
+use core::option;
+use core::result;
+use core::str;
+use core::task;
+use core::to_str::ToStr;
+use core::u64;
+use core::uint;
+use core::vec;
pub mod rustrt {
use core::libc::size_t;
pub mod bench {
use core::prelude::*;
- use time::precise_time_ns;
- use test::{BenchHarness, BenchSamples};
- use stats::Stats;
+ use core::num;
use core::rand::RngUtil;
+ use core::rand;
+ use core::u64;
+ use core::vec;
+ use stats::Stats;
+ use test::{BenchHarness, BenchSamples};
+ use time::precise_time_ns;
pub impl BenchHarness {
use core::prelude::*;
+use core::i32;
+use core::int;
+use core::io;
+use core::str;
+
static NSEC_PER_SEC: i32 = 1_000_000_000_i32;
pub mod rustrt {
use core::cast::transmute;
use core::cast;
use core::comm::{stream, Chan, SharedChan, Port, select2i};
+use core::either;
use core::libc::c_void;
use core::libc;
use timer::*;
use uv;
+
use core::cell::Cell;
- use core::rand::RngUtil;
use core::pipes::{stream, SharedChan};
+ use core::rand::RngUtil;
+ use core::rand;
+ use core::task;
#[test]
fn test_gl_timer_simple_sleep_test() {
use core::prelude::*;
use core::iterator::*;
+use core::uint;
use core::util::{swap, replace};
// This is implemented as an AA tree, which is a simplified variation of
mod test_treemap {
use core::prelude::*;
- use core::iterator::*;
use super::*;
+
+ use core::iterator::*;
use core::rand::RngUtil;
+ use core::rand;
+ use core::str;
+ use core::vec;
#[test]
fn find_empty() {
mod test_set {
use core::prelude::*;
use core::iterator::*;
+
use super::*;
+ use core::vec;
+
#[test]
fn test_clear() {
let mut s = TreeSet::new();
use uv_iotask::{IoTask, spawn_iotask};
use core::comm::Chan;
+use core::libc;
use core::option::{Some, None};
+use core::str;
use core::task::task;
use core::unstable::global::{global_data_clone_create, global_data_clone};
use core::unstable::weak_task::weaken_task;
use core::comm::{stream, Port, Chan, SharedChan};
use core::libc::c_void;
use core::libc;
+use core::task;
/// Used to abstract-away direct interaction with a libuv loop.
pub struct IoTask {
#[cfg(test)]
fn impl_uv_iotask_async(iotask: &IoTask) {
+ use core::ptr;
+
let async_handle = ll::async_t();
let ah_ptr: *ll::uv_async_t = &async_handle;
let (exit_po, exit_ch) = stream::<()>();
use core::prelude::*;
-use core::libc::size_t;
-use core::libc::c_void;
+use core::libc::{c_void, size_t};
+use core::libc;
use core::ptr::to_unsafe_ptr;
+use core::ptr;
+use core::str;
+use core::vec;
pub type uv_handle_t = c_void;
pub type uv_loop_t = c_void;
#[cfg(test)]
mod test {
use core::prelude::*;
- use core::comm::{SharedChan, stream, GenericChan, GenericPort};
+
use super::*;
+ use core::comm::{SharedChan, stream, GenericChan, GenericPort};
+ use core::libc;
+ use core::result;
+ use core::str;
+ use core::sys;
+ use core::task;
+ use core::vec;
+
enum tcp_read_data {
tcp_read_eof,
tcp_read_more(~[u8]),
use core::either::{Either, Left, Right};
use core::hashmap::HashMap;
use core::io;
+use core::result;
use core::run;
+use core::task;
use core::to_bytes;
use core::util::replace;
extern mod syntax(vers = "0.7-pre");
use std::prelude::*;
+
+use std::int;
+use std::io;
+use std::option;
+use std::os;
+use std::result;
use std::run;
+use std::str;
+use std::uint;
+use std::vec;
use syntax::diagnostic;
use syntax::parse::token::ident_interner;
use core::prelude::*;
+use core::io;
+use core::os;
use core::run;
use core::libc::exit;
+use core::str;
+
+// For bootstrapping.
+mod std {
+ pub use core::os;
+ pub use core::str;
+ pub use core::unstable;
+}
enum ValidUsage {
Valid(int), Invalid
use middle::ty;
use util::ppaux;
+use core::char;
use core::hash::Streaming;
use core::hash;
use core::libc::{c_int, c_uint};
use core::os::consts::{macos, freebsd, linux, android, win32};
+use core::os;
+use core::ptr;
use core::rt::io::Writer;
use core::run;
+use core::str;
+use core::vec;
use syntax::ast;
use syntax::ast_map::{path, path_mod, path_name};
use syntax::attr;
use lib::llvm::{ModuleRef, PassManagerRef};
use metadata::cstore;
+ use core::cast;
+ use core::char;
use core::libc::c_int;
+ use core::os;
+ use core::ptr;
+ use core::str;
pub mod rusti {
#[nolink]
use core::libc::{c_int, c_uint};
use core::path::Path;
use core::run;
+ use core::str;
pub fn is_object_or_assembly_or_exe(ot: output_type) -> bool {
if ot == output_type_assembly || ot == output_type_object ||
use metadata::cstore;
use metadata::filesearch;
-use core::util;
use core::hashmap::HashSet;
+use core::os;
+use core::uint;
+use core::util;
+use core::vec;
fn not_win32(os: session::os) -> bool {
match os {
mod test {
use core::prelude::*;
+ use core::os;
+ use core::str;
+
+ // FIXME(#2119): the outer attribute should be #[cfg(unix, test)], then
+ // these redundant #[cfg(test)] blocks can be removed
+ #[cfg(test)]
+ #[cfg(test)]
use back::rpath::{get_absolute_rpath, get_install_prefix_rpath};
use back::rpath::{get_relative_to, get_rpath_relative_to_output};
use back::rpath::{minimize_rpaths, rpaths_to_flags};
use core::prelude::*;
+use core::option;
+use core::vec;
use syntax::{ast, fold, attr};
type in_cfg_pred = @fn(attrs: ~[ast::attribute]) -> bool;
use core::prelude::*;
+use core::vec;
use driver::session::Session;
use syntax::parse;
use syntax::ast;
use driver::session::Session;
+use core::vec;
use syntax::ast;
use syntax::attr;
-use syntax::codemap;
use syntax::codemap::dummy_sp;
+use syntax::codemap;
use syntax::fold;
static STD_VERSION: &'static str = "0.7-pre";
use driver::session;
use front::config;
+use core::vec;
use syntax::ast_util::*;
use syntax::attr;
use syntax::codemap::{dummy_sp, span, ExpandedFrom, CallInfo, NameAndSpan};
let mainfn = (quote_item!(
pub fn main() {
#[main];
- extra::test::test_main_static(::os::args(), tests);
+ extra::test::test_main_static(::std::os::args(), tests);
}
)).get();
use core::hashmap::HashMap;
use core::libc::{c_uint, c_ushort};
+use core::option;
+use core::ptr;
+use core::str;
+use core::vec;
pub type Opcode = u32;
pub type Bool = c_uint;
use metadata::loader;
use core::hashmap::HashMap;
+use core::vec;
use syntax::attr;
use syntax::codemap::{span, dummy_sp};
use syntax::diagnostic::span_handler;
use metadata;
use middle::{ty, resolve};
+use core::vec;
use reader = extra::ebml::reader;
use syntax::ast;
use syntax::ast_map;
use metadata::decoder;
use core::hashmap::HashMap;
+use core::vec;
use extra;
use syntax::ast;
use syntax::parse::token::ident_interner;
use middle;
use util::ppaux::ty_to_str;
-use extra::flate;
use core::hash::HashUtil;
use core::hashmap::HashMap;
+use core::int;
+use core::io;
+use core::str;
+use core::uint;
+use core::vec;
+use extra::flate;
use extra::serialize::Encodable;
use extra;
use syntax::abi::AbiSet;
use syntax::ast_util::*;
use syntax::attr;
use syntax::diagnostic::span_handler;
-use syntax::parse::token::special_idents;
-use syntax::{ast_util, visit};
use syntax::opt_vec::OptVec;
use syntax::opt_vec;
+use syntax::parse::token::special_idents;
+use syntax::{ast_util, visit};
use syntax;
use writer = extra::ebml::writer;
use core::prelude::*;
+use core::option;
+use core::os;
+use core::result;
+use core::str;
+
// A module for searching for libraries
// FIXME (#2658): I'm not happy how this module turned out. Should
// probably just be folded into cstore.
use syntax::print::pprust;
use syntax::{ast, attr};
-use extra::flate;
+use core::cast;
+use core::io;
+use core::option;
use core::os::consts::{macos, freebsd, linux, android, win32};
+use core::ptr;
+use core::str;
+use core::uint;
+use core::vec;
+use extra::flate;
pub enum os {
os_macos,
use middle::ty;
+use core::str;
+use core::uint;
+use core::vec;
use syntax::abi::AbiSet;
use syntax::abi;
use syntax::ast;
use middle;
use util::ppaux::ty_to_str;
+use core::at_vec;
+use core::str;
+use core::uint;
use extra::ebml::reader;
use extra::ebml;
use extra::serialize;
use core::prelude::*;
-use middle::moves;
-use middle::borrowck::*;
+use core::hashmap::HashSet;
+use core::uint;
use mc = middle::mem_categorization;
+use middle::borrowck::*;
+use middle::moves;
use middle::ty;
-use util::ppaux::Repr;
-use core::hashmap::HashSet;
use syntax::ast::{m_mutbl, m_imm, m_const};
use syntax::ast;
use syntax::ast_util;
-use syntax::visit;
use syntax::codemap::span;
+use syntax::visit;
+use util::ppaux::Repr;
struct CheckLoanCtxt<'self> {
bccx: @BorrowckCtxt,
use core::prelude::*;
+use core::vec;
use middle::borrowck::*;
use mc = middle::mem_categorization;
use middle::ty;
use core::hashmap::{HashSet, HashMap};
use core::io;
-use core::result::{Result};
use core::ops::{BitOr, BitAnd};
+use core::result::{Result};
+use core::str;
use syntax::ast;
use syntax::ast_map;
use syntax::visit;
*/
use core::prelude::*;
+
use core::hashmap::{HashMap, HashSet};
+use core::uint;
use middle::borrowck::*;
use middle::dataflow::DataFlowContext;
use middle::dataflow::DataFlowOperator;
use middle::moves;
use util::ppaux::ty_to_str;
+use core::uint;
+use core::vec;
use extra::sort;
use syntax::ast::*;
use syntax::ast_util::{unguarded_pat, walk_pat};
use syntax::{ast, ast_map, ast_util, visit};
use syntax::ast::*;
+use core::float;
use core::hashmap::{HashMap, HashSet};
+use core::vec;
//
// This pass classifies expressions by their constant-ness.
use core::prelude::*;
use core::cast;
+use core::io;
+use core::str;
use core::uint;
+use core::vec;
use syntax::ast;
use syntax::ast_util;
use syntax::ast_util::id_range;
let visitor = visit::mk_vt(@visit::Visitor {
visit_fn: |fn_kind, fn_decl, block, span, node_id, _, visitor| {
- let is_unsafe_fn = match *fn_kind {
- fk_item_fn(_, _, purity, _) => purity == unsafe_fn,
- fk_method(_, _, method) => method.purity == unsafe_fn,
- _ => false,
+ let (is_item_fn, is_unsafe_fn) = match *fn_kind {
+ fk_item_fn(_, _, purity, _) => (true, purity == unsafe_fn),
+ fk_method(_, _, method) => (true, method.purity == unsafe_fn),
+ _ => (false, false),
};
let old_unsafe_context = context.unsafe_context;
if is_unsafe_fn {
context.unsafe_context = UnsafeFn
+ } else if is_item_fn {
+ context.unsafe_context = SafeContext
}
visit::visit_fn(fn_kind,
visit_block: |block, _, visitor| {
let old_unsafe_context = context.unsafe_context;
- if block.node.rules == unsafe_blk {
+ if block.node.rules == unsafe_blk &&
+ context.unsafe_context == SafeContext {
context.unsafe_context = UnsafeBlock(block.node.id)
}
use middle::ty;
use core::hashmap::HashMap;
+use core::vec;
use syntax::codemap::span;
use syntax::{ast, ast_util, visit};
use util::ppaux::{Repr, ty_to_str};
use util::ppaux::UserString;
+use core::vec;
use syntax::ast::*;
use syntax::attr::attrs_contains_name;
use syntax::codemap::span;
use middle::pat_util;
use util::ppaux::{ty_to_str};
+use core::char;
+use core::cmp;
use core::hashmap::HashMap;
+use core::i16;
+use core::i32;
+use core::i64;
+use core::i8;
+use core::str;
+use core::u16;
+use core::u32;
+use core::u64;
+use core::u8;
+use core::vec;
use extra::smallintmap::SmallIntMap;
use syntax::attr;
use syntax::codemap::span;
use core::cast::transmute;
use core::hashmap::HashMap;
+use core::io;
+use core::old_iter;
+use core::to_str;
+use core::uint;
+use core::vec;
use syntax::ast::*;
use syntax::codemap::span;
use syntax::parse::token::special_idents;
use util::ppaux::{ty_to_str, region_to_str, Repr};
use util::common::indenter;
+use core::uint;
use syntax::ast::{m_imm, m_const, m_mutbl};
use syntax::ast;
use syntax::codemap::span;
use util::ppaux::Repr;
use util::common::indenter;
+use core::at_vec;
use core::hashmap::{HashSet, HashMap};
use syntax::ast::*;
use syntax::ast_util;
use syntax::visit::{visit_mod, visit_ty, vt};
use syntax::opt_vec::OptVec;
-use core::option::Some;
use core::str::each_split_str;
+use core::str;
+use core::uint;
+use core::vec;
use core::hashmap::{HashMap, HashSet};
use core::util;
use util::common::indenter;
use core::hashmap::HashMap;
+use core::vec;
use syntax::ast;
use syntax::ast::ident;
use syntax::ast_util::path_to_ident;
use middle::trans::common::*;
use middle::ty;
+use core::str;
use syntax::ast;
// Take an inline assembly expression and splat it out via LLVM
use core::hash;
use core::hashmap::{HashMap, HashSet};
+use core::int;
+use core::io;
use core::libc::c_uint;
+use core::str;
+use core::uint;
+use core::vec;
use extra::time;
use syntax::ast::ident;
use syntax::ast_map::{path, path_elt_to_str, path_name};
use middle::trans::machine::llalign_of_min;
use syntax::codemap::span;
+use core::cast;
use core::hashmap::HashMap;
use core::libc::{c_uint, c_ulonglong, c_char};
+use core::str;
+use core::vec;
pub fn terminate(cx: block, _: &str) {
cx.terminated = true;
use core::prelude::*;
use core::libc::c_uint;
+use core::ptr;
+use core::uint;
+use core::vec;
use lib::llvm::{llvm, TypeRef, Integer, Pointer, Float, Double};
use lib::llvm::{Struct, Array, Attribute};
use lib::llvm::{StructRetAttribute};
use middle::typeck;
use util::ppaux::Repr;
+use core::vec;
use syntax::ast;
use syntax::ast_map;
use syntax::visit;
use middle::ty;
use util::ppaux::ty_to_str;
+use core::str;
+use core::vec;
use syntax::ast;
use syntax::ast_map::path_name;
use syntax::ast_util;
use util::ppaux::{Repr};
use core::cast::transmute;
+use core::cast;
use core::hash;
use core::hashmap::{HashMap, HashSet};
use core::libc::{c_uint, c_longlong, c_ulonglong};
+use core::ptr;
+use core::str;
use core::to_bytes;
use core::vec::raw::to_ptr;
+use core::vec;
use syntax::ast::ident;
use syntax::ast_map::{path, path_elt};
use syntax::codemap::span;
use util::ppaux::{Repr, ty_to_str};
use core::libc::c_uint;
+use core::str;
use syntax::{ast, ast_util, ast_map};
pub fn const_lit(cx: @CrateContext, e: @ast::expr, lit: ast::lit)
use util::common::indenter;
use util::ppaux;
+use core::str;
+use core::vec;
use syntax::ast;
use syntax::ast::ident;
use syntax::ast_map::path_mod;
use util::ppaux::ty_to_str;
use core::to_bytes;
+use core::uint;
use syntax::ast;
use syntax::codemap::span;
use syntax::parse::token::special_idents;
use middle::ty;
use util::ppaux::ty_to_str;
+use core::cast;
use core::hashmap::HashMap;
use core::libc;
+use core::option;
+use core::ptr;
+use core::str;
+use core::sys;
+use core::vec;
use syntax::codemap::span;
use syntax::parse::token::ident_interner;
use syntax::{ast, codemap, ast_util, ast_map};
use core::cast::transmute;
use core::hashmap::HashMap;
+use core::vec;
use syntax::print::pprust::{expr_to_str};
use syntax::ast;
use syntax::codemap;
use middle::ty::FnSig;
use util::ppaux::ty_to_str;
+use core::str;
+use core::uint;
+use core::vec;
use syntax::codemap::span;
use syntax::{ast, ast_util};
use syntax::{attr, ast_map};
use util::ppaux;
use util::ppaux::ty_to_short_str;
+use core::io;
use core::libc::c_uint;
+use core::str;
+use core::vec;
use extra::time;
use syntax::ast;
use middle::ty;
use util::ppaux::ty_to_str;
+use core::vec;
use syntax::ast;
use syntax::ast_map::path_name;
use syntax::ast_util::local_def;
use util::common::indenter;
use util::ppaux::Repr;
+use core::str;
+use core::vec;
use syntax::ast_map::{path, path_mod, path_name};
use syntax::ast_util;
use syntax::{ast, ast_map};
use middle::typeck;
use util::ppaux::Repr;
+use core::vec;
use syntax::ast;
use syntax::ast_map;
use syntax::ast_map::path_name;
use util::common::{indenter};
use util::enum_set::{EnumSet, CLike};
+use core::cast;
+use core::cmp;
+use core::hashmap::{HashMap, HashSet};
+use core::iter;
+use core::ops;
use core::ptr::to_unsafe_ptr;
use core::to_bytes;
-use core::hashmap::{HashMap, HashSet};
+use core::u32;
+use core::uint;
+use core::vec;
+use extra::smallintmap::SmallIntMap;
use syntax::ast::*;
use syntax::ast_util::is_local;
use syntax::ast_util;
use middle::typeck::rscope::RegionParamNames;
use middle::typeck::lookup_def_tcx;
+use core::result;
+use core::vec;
use syntax::abi::AbiSet;
use syntax::{ast, ast_util};
use syntax::codemap::span;
use middle::typeck::require_same_types;
use core::hashmap::{HashMap, HashSet};
+use core::vec;
use syntax::ast;
use syntax::ast_util;
use syntax::codemap::span;
use util::common::indenter;
use core::hashmap::HashSet;
+use core::result;
+use core::uint;
+use core::vec;
use extra::list::Nil;
use syntax::ast::{def_id, sty_value, sty_region, sty_box};
use syntax::ast::{sty_uniq, sty_static, node_id};
use core::cast::transmute;
use core::hashmap::HashMap;
+use core::result;
+use core::str;
use core::util::replace;
+use core::vec;
use extra::list::Nil;
use syntax::abi::AbiSet;
use syntax::ast::{provided, required};
use middle::typeck::check::regionmanip::relate_nested_regions;
use middle::typeck::infer::resolve_and_force_all_but_regions;
use middle::typeck::infer::resolve_type;
-use util::ppaux::{note_and_explain_region, ty_to_str,
- region_to_str};
+use util::ppaux::{note_and_explain_region, ty_to_str, region_to_str};
use middle::pat_util;
+use core::result;
+use core::uint;
use syntax::ast::{ManagedSigil, OwnedSigil, BorrowedSigil};
use syntax::ast::{def_arg, def_binding, def_local, def_self, def_upvar};
use syntax::ast;
use syntax::codemap::span;
use util::ppaux::{ty_to_str};
+ use core::uint;
+
pub fn for_addr_of(rcx: @mut Rcx, expr: @ast::expr, base: @ast::expr) {
/*!
* Computes the guarantor for an expression `&base` and then
use util::ppaux;
use core::hashmap::HashSet;
+use core::result;
+use core::uint;
use syntax::ast;
use syntax::ast_util;
use syntax::codemap::span;
use syntax::visit::{visit_mod};
use util::ppaux::ty_to_str;
-use core::result::Ok;
use core::hashmap::{HashMap, HashSet};
+use core::old_iter;
+use core::result::Ok;
use core::uint;
+use core::vec;
pub struct UniversalQuantificationResult {
monotype: t,
use util::ppaux;
use util::ppaux::UserString;
+use core::result;
+use core::vec;
use syntax::abi::AbiSet;
use syntax::ast::{RegionTyParamBound, TraitTyParamBound};
use syntax::ast;
use util::common::indent;
use core::result::{iter_vec2, map_vec2};
+use core::vec;
use syntax::ast::{Onceness, purity};
use syntax::ast;
use syntax::opt_vec;
use util::common::indent;
use util::ppaux::{bound_region_to_str, ty_to_str, trait_ref_to_str};
+use core::result;
+use core::vec;
use extra::list::Nil;
use extra::smallintmap::SmallIntMap;
use syntax::ast::{m_imm, m_mutbl};
use util::common::{indent, indenter};
use util::ppaux::ty_to_str;
+use core::vec;
use syntax::ast;
pub static resolve_nested_tvar: uint = 0b0000000001;
use middle::typeck::infer::unify::{Redirect, Root, VarValue};
use util::ppaux::{mt_to_str, ty_to_str, trait_ref_to_str};
+use core::str;
+use core::uint;
use syntax::ast;
pub trait InferStr {
use util::ppaux;
use core::hashmap::HashMap;
+use core::result;
use extra::list::List;
use extra::list;
use syntax::codemap::span;
use middle::ty;
+use core::result;
use syntax::ast;
use syntax::codemap::span;
use syntax::opt_vec::OptVec;
#[cfg(not(stage0))]
extern mod std(name = "std", vers = "0.7-pre");
+// For bootstrapping purposes.
+#[cfg(stage0)]
+pub use core::str;
+#[cfg(stage0)]
+pub use core::unstable;
+
use core::prelude::*;
use driver::driver::{host_triple, optgroups, early_error};
use driver::session;
use middle::lint;
+use core::io;
+use core::os;
+use core::result;
+use core::str;
+use core::task;
+use core::uint;
+use core::vec;
use extra::getopts::{groups, opt_present};
use extra::getopts;
use syntax::codemap;
pub mod llvm;
}
+// A curious inner module that allows ::std::foo to be available in here for
+// macros.
+mod std {
+ pub use core::cmp;
+ pub use core::os;
+ pub use core::str;
+ pub use core::sys;
+ pub use core::to_bytes;
+ pub use core::unstable;
+ pub use extra::serialize;
+}
+
pub fn version(argv0: &str) {
let mut vers = ~"unknown version";
let env_vers = env!("CFG_VERSION");
use syntax::visit;
use core::hashmap::HashSet;
+use core::io;
+use core::str;
use extra;
pub fn time<T>(do_it: bool, what: ~str, thunk: &fn() -> T) -> T {
mod test {
use core::prelude::*;
+ use core::cast;
use core::iter;
use util::enum_set::*;
use syntax::print::pprust;
use syntax::{ast, ast_util};
+use core::str;
+use core::vec;
+
/// Produces a string suitable for debugging output.
pub trait Repr {
fn repr(&self, tcx: ctxt) -> ~str;
use core::cell::Cell;
use core::comm::{stream, SharedChan, Port};
+use core::task;
+use core::vec;
use rustc::driver::driver;
use rustc::driver::session::Session;
use rustc::driver::session::{basic_options, options};
use core::prelude::*;
+use core::str;
use syntax::ast;
use syntax::attr;
use fold;
use pass::Pass;
+use core::vec;
use syntax::ast;
use syntax::ast_map;
use core::prelude::*;
use core::cell::Cell;
-use core::run;
-use core::run::ProcessOutput;
+use core::os;
use core::result::Result;
+use core::result;
+use core::run::ProcessOutput;
+use core::run;
+use core::vec;
use extra::getopts;
/// The type of document to output
#[cfg(test)]
mod test {
use core::prelude::*;
+
use config::*;
+ use core::result;
use core::run::ProcessOutput;
fn parse_config(args: &[~str]) -> Result<Config, ~str> {
use fold;
use pass::Pass;
+use core::str;
use core::util;
+use core::vec;
pub fn mk_pass() -> Pass {
Pass {
use doc;
+use core::vec;
+
pub type AstId = int;
#[deriving(Eq)]
use doc::ItemUtils;
use doc;
+use core::local_data::local_data_get;
+use core::vec;
use syntax::ast;
use syntax::parse::token::{ident_interner};
use syntax::parse::token;
#[cfg(test)] use extract;
#[cfg(test)] use parse;
+use core::vec;
+
pub struct Fold<T> {
ctxt: T,
fold_doc: FoldDoc<T>,
use markdown_writer;
use pass::Pass;
+use core::str;
+
pub fn mk_pass(config: config::Config) -> Pass {
Pass {
name: ~"markdown_index",
use sort_pass;
use core::cell::Cell;
+use core::str;
+use core::vec;
use syntax;
pub fn mk_pass(writer_factory: WriterFactory) -> Pass {
use tystr_pass;
use unindent_pass;
+ use core::str;
+
fn render(source: ~str) -> ~str {
let (srv, doc) = create_doc_srv(source);
let markdown = write_markdown_str_srv(srv, doc);
use doc::ItemUtils;
use doc;
-use core::run;
use core::comm::*;
+use core::comm;
+use core::io;
+use core::libc;
+use core::os;
+use core::result;
+use core::run;
+use core::str;
+use core::task;
use extra::future;
pub enum WriteInstr {
use util::NominalOp;
use core::comm::*;
+use core::task;
use syntax::ast;
#[cfg(test)] use doc::PageUtils;
use core::prelude::*;
+use core::vec;
+
use astsrv;
use doc;
use time;
pub mod prune_private_pass;
pub mod util;
+mod std {
+ pub use core::clone;
+ pub use core::cmp;
+ pub use core::os;
+ pub use core::str;
+ pub use core::sys;
+ pub use core::unstable;
+}
+
pub fn main() {
let args = os::args();
use fold;
use pass::Pass;
+use core::str;
+
pub fn mk_pass() -> Pass {
Pass {
name: ~"sectionalize",
use extract;
use sectionalize_pass::run;
+ use core::str;
+ use core::vec;
+
fn mk_doc(source: ~str) -> doc::Doc {
do astsrv::from_str(copy source) |srv| {
let doc = extract::from_srv(srv.clone(), ~"");
use sectionalize_pass;
use text_pass::mk_pass;
+ use core::str;
+
fn mk_doc(source: ~str) -> doc::Doc {
do astsrv::from_str(copy source) |srv| {
let doc = extract::from_srv(srv.clone(), ~"");
use fold;
use pass::Pass;
+use core::vec;
use syntax::ast;
use syntax::print::pprust;
use syntax::ast_map;
use core::prelude::*;
+use core::str;
+use core::task;
+use core::uint;
+use core::vec;
use pass::Pass;
use text_pass;
None => { },
}
if (should_compile) {
- io::println(fmt!("compiling %s...", src_filename));
+ println(fmt!("compiling %s...", src_filename));
driver::compile_upto(sess, cfg, &input, driver::cu_everything,
Some(outputs));
true
//rl::clear();
}
~"help" => {
- io::println(
+ println(
~":{\\n ..lines.. \\n:}\\n - execute multiline command\n" +
":load <crate> ... - \
loads given crates as dynamic libraries\n" +
}
}
if loaded_crates.is_empty() {
- io::println("no crates loaded");
+ println("no crates loaded");
} else {
- io::println(fmt!("crates loaded: %s",
+ println(fmt!("crates loaded: %s",
str::connect(loaded_crates, ", ")));
}
}
}
action = action_run_line(multiline_cmd);
}
- _ => io::println(~"unknown cmd: " + cmd)
+ _ => println(~"unknown cmd: " + cmd)
}
return action;
}
// only print this stuff if the user is actually typing into rusti
if istty {
- io::println("WARNING: The Rust REPL is experimental and may be");
- io::println("unstable. If you encounter problems, please use the");
- io::println("compiler instead. Type :help for help.");
+ println("WARNING: The Rust REPL is experimental and may be");
+ println("unstable. If you encounter problems, please use the");
+ println("compiler instead. Type :help for help.");
unsafe {
do rl::complete |line, suggest| {
Some(line) => {
if line.is_empty() {
if istty {
- io::println("()");
+ println("()");
}
loop;
}
extern mod std;
fn print<T>(result: T) {
- io::println(fmt!("%?", result));
+ println(fmt!("%?", result));
}
// rustpkg utilities having to do with paths and directories
use core::prelude::*;
+
pub use util::{PkgId, RemotePath, LocalPath};
+pub use util::{normalize, OutputType, Main, Lib, Bench, Test};
use core::libc::consts::os::posix88::{S_IRUSR, S_IWUSR, S_IXUSR};
use core::os::mkdir_recursive;
-pub use util::{normalize, OutputType, Main, Lib, Bench, Test};
+use core::os;
/// Returns the value of RUST_PATH, as a list
/// of Paths. In general this should be read from the
#[no_std];
extern mod core(name = "std");
-extern mod std(name = "extra");
+extern mod extra(name = "extra");
extern mod rustc;
extern mod syntax;
use core::hashmap::HashMap;
use rustc::driver::{driver, session};
use rustc::metadata::filesearch;
-use std::{getopts};
+use extra::{getopts};
use syntax::{ast, diagnostic};
use util::*;
use path_util::{build_pkg_id_in_workspace, pkgid_src_in_workspace, u_rwx};
pub mod usage;
+mod std {
+ pub use core::cmp;
+ pub use core::condition;
+ pub use core::os;
+ pub use core::str;
+ pub use core::sys;
+ pub use core::unstable;
+}
+
/// A PkgScript represents user-supplied custom logic for
/// special build hooks. This only exists for packages with
/// an explicit package script.
use context::Ctx;
use core::hashmap::HashMap;
+use core::io;
+use core::os;
use core::prelude::*;
-use std::tempfile::mkdtemp;
+use core::result;
+use extra::tempfile::mkdtemp;
use util::{PkgId, default_version};
use path_util::{target_executable_in_workspace, target_library_in_workspace,
target_test_in_workspace, target_bench_in_workspace,
use core::rt::io::Writer;
use rustc::driver::{driver, session};
use rustc::metadata::filesearch;
-use std::getopts::groups::getopts;
-use std::semver;
-use std::term;
+use extra::getopts::groups::getopts;
+use extra::semver;
+use extra::term;
use syntax::ast_util::*;
use syntax::codemap::{dummy_sp, spanned, dummy_spanned};
use syntax::ext::base::ExtCtxt;
use super::*;
use prelude::*;
+ use uint;
+
#[test]
fn test() {
// Some code that could use that, then:
//! A mutable, nullable memory location
use cast::transmute_mut;
+use cmp;
use prelude::*;
use util::replace;
/*! Condition handling */
-use prelude::*;
use local_data::{local_data_pop, local_data_set};
+use local_data;
+use prelude::*;
// helper for transmutation, shown below.
type RustClosure = (int, int);
pub use kinds;
pub use sys;
pub use pipes;
+ pub use unstable;
+ pub use str;
+ pub use os;
}
use super::*;
use prelude::*;
+ use uint;
+
#[test]
fn test_siphash() {
let vecs : [[u8, ..8], ..64] = [
use super::*;
use prelude::*;
+ use int;
+ use uint;
+
#[test]
fn test_to_vec() {
let xs = ~[1, 2, 3];
*/
-use prelude::*;
+use cmp;
+use iter;
use num::{Zero, One};
+use num;
+use prelude::*;
pub trait Iterator<A> {
/// Advance the iterator and return the next value. Return `None` when the end is reached.
use super::*;
use prelude::*;
+ use iter;
+ use uint;
+
#[test]
fn test_counter_to_vec() {
let mut it = Counter::new(0, 5).take(10);
*/
use prelude::*;
+
use task::local_data_priv::{local_get, local_pop, local_modify, local_set, Handle};
+use task;
/**
* Indexes a task-local data slot. The function's code pointer is used for
use libc::c_int;
use num::{Zero, One, strconv};
use num::{FPCategory, FPNaN, FPInfinite , FPZero, FPSubnormal, FPNormal};
+use num;
use prelude::*;
+use to_str;
pub use cmath::c_float_targ_consts::*;
#[cfg(test)]
mod tests {
use f32::*;
- use num::*;
use prelude::*;
+ use num::*;
+ use num;
+ use sys;
+
#[test]
fn test_num() {
num::test_num(10f32, 2f32);
use libc::c_int;
use num::{Zero, One, strconv};
use num::{FPCategory, FPNaN, FPInfinite , FPZero, FPSubnormal, FPNormal};
+use num;
use prelude::*;
+use to_str;
pub use cmath::c_double_targ_consts::*;
pub use cmp::{min, max};
#[cfg(test)]
mod tests {
use f64::*;
- use num::*;
use prelude::*;
+ use num::*;
+ use num;
+ use sys;
+
#[test]
fn test_num() {
num::test_num(10f64, 2f64);
// PORT this must match in width according to architecture
+use f64;
use libc::c_int;
use num::{Zero, One, strconv};
use num::FPCategory;
+use num;
use prelude::*;
+use to_str;
pub use f64::{add, sub, mul, div, rem, lt, le, eq, ne, ge, gt};
pub use f64::{acos, asin, atan2, cbrt, ceil, copysign, cosh, floor};
pub mod consts {
// FIXME (requires Issue #1433 to fix): replace with mathematical
// staticants from cmath.
- /// Archimedes' staticant
+ /// Archimedes' constant
pub static pi: float = 3.14159265358979323846264338327950288;
/// pi/2.0
#[cfg(test)]
mod tests {
- use num::*;
use super::*;
use prelude::*;
+ use num::*;
+ use num;
+ use sys;
+
#[test]
fn test_num() {
num::test_num(10f, 2f);
use super::*;
use prelude::*;
+ use i16;
+ use i32;
+ use i64;
+ use i8;
+ use num;
+ use sys;
+
#[test]
fn test_num() {
num::test_num(10 as $T, 2 as $T);
use super::*;
use prelude::*;
+ use num;
+ use sys;
+ use u16;
+ use u32;
+ use u64;
+ use u8;
+ use uint;
+
#[test]
fn test_num() {
num::test_num(10 as $T, 2 as $T);
use libc;
use libc::{c_char, c_void, c_int, size_t};
use libc::{mode_t, FILE};
+use local_data;
use option;
use option::{Some, None};
+use os;
use prelude::*;
use ptr;
use str;
//! The Rust prelude. Imported into every module by default.
-/* Reexported core operators */
-
+// Reexported core operators
pub use either::{Either, Left, Right};
pub use kinds::{Const, Copy, Owned};
pub use ops::{Add, Sub, Mul, Div, Rem, Neg, Not};
pub use option::{Option, Some, None};
pub use result::{Result, Ok, Err};
-/* Reexported functions */
-
+// Reexported functions
pub use io::{print, println};
-/* Reexported types and traits */
-
+// Reexported types and traits
pub use clone::{Clone, DeepClone};
pub use cmp::{Eq, ApproxEq, Ord, TotalEq, TotalOrd, Ordering, Less, Equal, Greater, Equiv};
pub use char::Char;
pub use vec::{OwnedVector, OwnedCopyableVector, MutableVector};
pub use io::{Reader, ReaderUtil, Writer, WriterUtil};
-/* Reexported runtime types */
+// Reexported runtime types
pub use comm::{stream, Port, Chan, GenericChan, GenericSmartChan, GenericPort, Peekable};
pub use task::spawn;
-/* Reexported modules */
-
-pub use at_vec;
-pub use bool;
-pub use cast;
-pub use char;
-pub use cmp;
-pub use either;
-pub use f32;
-pub use f64;
-pub use float;
-pub use i16;
-pub use i32;
-pub use i64;
-pub use i8;
-pub use int;
-pub use io;
-pub use iter;
-pub use old_iter;
-pub use libc;
-pub use local_data;
-pub use num;
-pub use ops;
-pub use option;
-pub use os;
-pub use path;
-pub use comm;
-pub use unstable;
-pub use ptr;
-pub use rand;
-pub use result;
-pub use str;
-pub use sys;
-pub use task;
-pub use to_str;
-pub use u16;
-pub use u32;
-pub use u64;
-pub use u8;
-pub use uint;
-pub use vec;
use super::*;
use prelude::*;
+ use cast;
+ use libc;
+ use str;
+ use vec;
+
#[test]
fn test() {
unsafe {
#[test]
fn test_to_option() {
- let p: *int = null();
- // FIXME (#6641): Usage of unsafe methods in safe code doesn't cause an error.
- assert_eq!(p.to_option(), None);
+ unsafe {
+ let p: *int = null();
+ assert_eq!(p.to_option(), None);
- let q: *int = &2;
- assert_eq!(q.to_option().unwrap(), &2); // FIXME (#6641)
+ let q: *int = &2;
+ assert_eq!(q.to_option().unwrap(), &2);
- let p: *mut int = mut_null();
- assert_eq!(p.to_option(), None); // FIXME (#6641)
+ let p: *mut int = mut_null();
+ assert_eq!(p.to_option(), None);
- let q: *mut int = &mut 2;
- assert_eq!(q.to_option().unwrap(), &2); // FIXME (#6641)
+ let q: *mut int = &mut 2;
+ assert_eq!(q.to_option().unwrap(), &2);
+ }
}
#[test]
~~~
*/
-
+use cast;
+use cmp;
use int;
+use local_data;
use prelude::*;
use str;
+use sys;
use u32;
use uint;
use util;
// Generating Random Variables"], but more robust. If one wanted, one
// could implement VIZIGNOR the ZIGNOR paper for more speed.
+use f64;
use prelude::*;
use rand::{Rng,Rand};
use super::super::mem::*;
use super::super::Decorator;
+ use str;
+
#[test]
#[ignore]
fn smoke_test() {
//! * Should probably have something like this for strings.
//! * Should they implement Closable? Would take extra state.
+use cmp::min;
use prelude::*;
use super::*;
-use cmp::min;
+use vec;
/// Writes to an owned, growable byte vector
pub struct MemWriter {
//! local storage, and logging. Even a 'freestanding' Rust would likely want
//! to implement this.
-use prelude::*;
-use libc::{c_void, uintptr_t};
use cast::transmute;
+use libc::{c_void, uintptr_t};
+use ptr;
+use prelude::*;
use rt::local::Local;
-use super::local_heap::LocalHeap;
use rt::logging::StdErrLogger;
+use super::local_heap::LocalHeap;
+use super::sched::Scheduler;
pub struct Task {
heap: LocalHeap,
use libc::{size_t, c_int, c_uint, c_void, c_char, uintptr_t};
use libc::{malloc, free};
+use libc;
use prelude::*;
+use ptr;
+use str;
+use vec;
pub static UNKNOWN: c_int = -1;
pub static OK: c_int = 0;
//! Process spawning.
use cast;
+use comm::{stream, SharedChan, GenericChan, GenericPort};
+use int;
use io;
-use libc;
use libc::{pid_t, c_void, c_int};
-use comm::{stream, SharedChan, GenericChan, GenericPort};
+use libc;
use option::{Some, None};
use os;
use prelude::*;
};
use libc::funcs::extra::msvcrt::get_osfhandle;
+ use sys;
+ use uint;
+
unsafe {
let mut si = zeroed_startupinfo();
#[cfg(windows)]
pub fn make_command_line(prog: &str, args: &[~str]) -> ~str {
+ use uint;
+
let mut cmd = ~"";
append_arg(&mut cmd, prog);
for args.each |arg| {
* ~~~
*/
+use prelude::*;
+
+use cast;
use cell::Cell;
use cmp::Eq;
-use result::Result;
use comm::{stream, Chan, GenericChan, GenericPort, Port};
-use prelude::*;
+use comm;
+use ptr;
+use result::Result;
use result;
+use rt::{context, OldTaskContext};
use task::rt::{task_id, sched_id};
-use util;
-use util::replace;
+use task;
use unstable::finally::Finally;
-use rt::{context, OldTaskContext};
+use util::replace;
+use util;
#[cfg(test)] use comm::SharedChan;
#[doc(hidden)];
+use prelude::*;
+
use cast::transmute;
use cast;
use cell::Cell;
use container::Map;
use comm::{Chan, GenericChan};
-use prelude::*;
+use comm;
use ptr;
use hashmap::HashSet;
use task::local_data_priv::{local_get, local_set, OldHandle};
use task::{Success, TaskOpts, TaskResult, ThreadPerCore, ThreadPerTask};
use task::{ExistingScheduler, SchedulerHandle};
use task::unkillable;
+use task;
use uint;
use util;
use unstable::sync::{Exclusive, exclusive};
//! An ordered map and set for integer keys implemented as a radix trie
+use local_data;
+use os;
use prelude::*;
+use uint;
use util::{swap, replace};
+use vec;
// FIXME: #5244: need to manually update the TrieNode constructor
static SHIFT: uint = 4;
#[doc(hidden)];
-use libc;
use comm::{GenericChan, GenericPort};
+use comm;
+use libc;
use prelude::*;
+use ptr;
use task;
pub mod at_exit;
#[test]
fn exclusive_arc() {
- let mut futures = ~[];
+ unsafe {
+ let mut futures = ~[];
- let num_tasks = 10;
- let count = 10;
+ let num_tasks = 10;
+ let count = 10;
- let total = exclusive(~0);
+ let total = exclusive(~0);
- for uint::range(0, num_tasks) |_i| {
- let total = total.clone();
- let (port, chan) = comm::stream();
- futures.push(port);
+ for uint::range(0, num_tasks) |_i| {
+ let total = total.clone();
+ let (port, chan) = comm::stream();
+ futures.push(port);
- do task::spawn || {
- for uint::range(0, count) |_i| {
- do total.with |count| {
- **count += 1;
+ do task::spawn || {
+ for uint::range(0, count) |_i| {
+ do total.with |count| {
+ **count += 1;
+ }
}
+ chan.send(());
}
- chan.send(());
- }
- };
+ };
- for futures.each |f| { f.recv() }
+ for futures.each |f| { f.recv() }
- do total.with |total| {
- assert!(**total == num_tasks * count)
- };
+ do total.with |total| {
+ assert!(**total == num_tasks * count)
+ };
+ }
}
#[test] #[should_fail] #[ignore(cfg(windows))]
fn exclusive_poison() {
- // Tests that if one task fails inside of an exclusive, subsequent
- // accesses will also fail.
- let x = exclusive(1);
- let x2 = x.clone();
- do task::try || {
- do x2.with |one| {
- assert_eq!(*one, 2);
+ unsafe {
+ // Tests that if one task fails inside of an exclusive, subsequent
+ // accesses will also fail.
+ let x = exclusive(1);
+ let x2 = x.clone();
+ do task::try || {
+ do x2.with |one| {
+ assert_eq!(*one, 2);
+ }
+ };
+ do x.with |one| {
+ assert_eq!(*one, 1);
}
- };
- do x.with |one| {
- assert_eq!(*one, 1);
}
}
}
// option. This file may not be copied, modified, or distributed
// except according to those terms.
-/*!
-
-Miscellaneous helpers for common patterns.
-
-*/
+//! Miscellaneous helpers for common patterns.
+use cast;
+use local_data;
+use ptr;
use prelude::*;
use unstable::intrinsics;
use core::prelude::*;
+use core::str;
use core::to_bytes;
#[deriving(Eq)]
use visit;
use syntax::parse::token::special_idents;
+use core::cmp;
use core::hashmap::HashMap;
+use core::str;
+use core::vec;
pub enum path_elt {
path_mod(ident),
use ast;
use ast_util;
use codemap::{span, spanned};
+use opt_vec;
use parse::token;
use visit;
-use opt_vec;
-use core::hashmap::HashMap;
+use core::hashmap::HashMap;
+use core::int;
+use core::option;
+use core::str;
use core::to_bytes;
pub fn path_name_i(idents: &[ident], intr: @token::ident_interner) -> ~str {
use parse::comments::{doc_comment_style, strip_doc_comment_decoration};
use core::hashmap::HashSet;
+use core::vec;
use extra;
/* Constructors */
use core::prelude::*;
+use core::cmp;
+use core::str;
use core::to_bytes;
+use core::uint;
use extra::serialize::{Encodable, Decodable, Encoder, Decoder};
pub trait Pos {
use codemap::{Pos, span};
use codemap;
+use core::io;
+use core::str;
+use core::uint;
+use core::vec;
use extra::term;
pub type Emitter = @fn(cmsp: Option<(@codemap::CodeMap, span)>,
use parse;
use parse::token;
+use core::str;
+use core::vec;
+
enum State {
Asm,
Outputs,
use parse::token;
use core::hashmap::HashMap;
+use core::vec;
// new-style macro! tt code:
//
use core::prelude::*;
-use ast;
use ast::*;
+use ast;
+use ast_util;
+use codemap::{span, spanned};
use ext::base::ExtCtxt;
use ext::build::AstBuilder;
use ext::deriving::*;
-use codemap::{span, spanned};
-use ast_util;
use opt_vec;
+use core::uint;
+
pub fn expand_deriving_decodable(
cx: @ExtCtxt,
span: span,
use codemap::{span,respan};
use opt_vec;
+use core::uint;
+use core::vec;
+
pub use self::ty::*;
mod ty;
use ext::build::AstBuilder;
use ext::deriving::generic::*;
+use core::vec;
+
pub fn expand_deriving_iter_bytes(cx: @ExtCtxt,
span: span,
mitem: @meta_item,
use parse::token::special_idents::clownshoes_extensions;
use opt_vec;
+use core::uint;
+use core::vec;
+
pub mod clone;
pub mod iter_bytes;
pub mod encodable;
use ext::build::{AstBuilder, Duplicate};
use ext::deriving::generic::*;
+use core::vec;
+
pub fn expand_deriving_rand(cx: @ExtCtxt,
span: span,
mitem: @meta_item,
use ext::base;
use ext::build::AstBuilder;
+use core::os;
+
pub fn expand_syntax_ext(cx: @ExtCtxt, sp: span, tts: &[ast::token_tree])
-> base::MacResult {
use parse;
use parse::{parse_item_from_source_str};
+use core::vec;
+
pub fn expand_expr(extsbox: @mut SyntaxEnv,
cx: @ExtCtxt,
e: &expr_,
use ext::base;
use ext::build::AstBuilder;
+use core::option;
use core::unstable::extfmt::ct::*;
+use core::vec;
pub fn expand_syntax_ext(cx: @ExtCtxt, sp: span, tts: &[ast::token_tree])
-> base::MacResult {
-> @ast::expr {
fn make_path_vec(cx: @ExtCtxt, ident: &str) -> ~[ast::ident] {
let intr = cx.parse_sess().interner;
- return ~[intr.intern("unstable"), intr.intern("extfmt"),
- intr.intern("rt"), intr.intern(ident)];
+ return ~[intr.intern("std"),
+ intr.intern("unstable"),
+ intr.intern("extfmt"),
+ intr.intern("rt"),
+ intr.intern(ident)];
}
fn make_rt_path_expr(cx: @ExtCtxt, sp: span, nm: &str) -> @ast::expr {
let path = make_path_vec(cx, nm);
/* 'ident' is the local buffer building up the result of fmt! */
let ident = cx.parse_sess().interner.intern("__fmtbuf");
let buf = || cx.expr_ident(fmt_sp, ident);
+ let core_ident = cx.parse_sess().interner.intern("std");
let str_ident = cx.parse_sess().interner.intern("str");
let push_ident = cx.parse_sess().interner.intern("push_str");
let mut stms = ~[];
} else {
let args = ~[cx.expr_mut_addr_of(fmt_sp, buf()), cx.expr_str(fmt_sp, s)];
let call = cx.expr_call_global(fmt_sp,
- ~[str_ident, push_ident],
+ ~[core_ident,
+ str_ident,
+ push_ident],
args);
stms.push(cx.stmt_expr(call));
}
use ext::base;
use print;
+use core::io;
+use core::vec;
+
pub fn expand_syntax_ext(cx: @ExtCtxt,
sp: codemap::span,
tt: &[ast::token_tree])
use ast;
use codemap::span;
+use core::str;
+use core::vec;
+
// Transitional reexports so qquote can find the paths it is looking for
mod syntax {
pub use ext;
use ext::base::ExtCtxt;
use ext::pipes::proto::{protocol_};
+use core::str;
use extra::bitv::Bitv;
pub fn analyze(proto: @mut protocol_, _cx: @ExtCtxt) {
use opt_vec;
use opt_vec::OptVec;
+use core::str;
+use core::vec;
+
pub trait gen_send {
fn gen_send(&mut self, cx: @ExtCtxt, try: bool) -> @ast::item;
fn to_ty(&mut self, cx: @ExtCtxt) -> @ast::Ty;
use parse::token;
use parse;
+use core::vec;
+
/**
*
* Quasiquoting works via token trees.
use parse;
use print::pprust;
+use core::io;
+use core::result;
+use core::str;
+use core::vec;
+
// These macros all relate to the file system; they either return
// the column/row/filename of the expression, or they include
// a given file into the current one.
use parse::parser::Parser;
use parse::token::keywords;
+use core::vec;
+
pub fn expand_trace_macros(cx: @ExtCtxt,
sp: span,
tt: &[ast::token_tree])
use parse::token;
use core::hashmap::HashMap;
+use core::str;
+use core::uint;
+use core::vec;
/* This is an Earley-like parser, without support for in-grammar nonterminals,
only by calling out to the main rust parser for named nonterminals (which it
use print;
use core::io;
+use core::vec;
pub fn add_new_extension(cx: @ExtCtxt,
sp: span,
use parse::lexer::TokenAndSpan;
use core::hashmap::HashMap;
+use core::option;
+use core::vec;
///an unzipping of `token_tree`s
struct TtFrame {
use codemap::{span, spanned};
use opt_vec::OptVec;
+use core::vec;
+
pub trait ast_fold {
fn fold_crate(@self, &crate) -> crate;
fn fold_view_item(@self, @view_item) -> @view_item;
use parse::token;
use parse;
+use core::io;
+use core::str;
+use core::uint;
+
#[deriving(Eq)]
pub enum cmnt_style {
isolated, // No code on either side of each line of the comment
use ext::tt::transcribe::{dup_tt_reader};
use parse::token;
+use core::char;
+use core::either;
+use core::str;
+use core::u64;
+
pub use ext::tt::transcribe::{TtReader, new_tt_reader};
pub trait reader {
use parse::token::{keywords, Token};
use parse::token;
+use core::str;
use core::to_bytes;
/// The specific types of unsupported syntax
use opt_vec;
use opt_vec::OptVec;
+use core::char;
use core::either::Either;
use core::either;
use core::hashmap::HashSet;
+use core::str;
use core::vec;
#[deriving(Eq)]
use util::interner::StrInterner;
use util::interner;
+use core::cast;
+use core::char;
use core::cmp::Equiv;
+use core::hashmap::HashSet;
+use core::local_data;
+use core::str;
use core::to_bytes;
+use core::vec;
#[deriving(Encodable, Decodable, Eq)]
pub enum binop {
use core::prelude::*;
+use core::io;
+use core::vec;
+
#[deriving(Eq)]
pub enum breaks { consistent, inconsistent, }
use print::pp;
use print::pprust;
+use core::char;
+use core::io;
+use core::str;
+use core::u64;
+use core::uint;
+use core::vec;
+
// The @ps is stored here to prevent recursive type.
pub enum ann_node<'self> {
node_block(@ps, &'self ast::blk),
#[cfg(not(stage0))]
extern mod std(name = "std");
+// For bootstrapping purposes.
+#[cfg(stage0)]
+pub use core::str;
+#[cfg(stage0)]
+pub use core::unstable;
+
use core::prelude::*;
pub mod util {
vers = "0.1")];
#[crate_type = "lib"];
+
+use std::libc;
+
extern {
- fn rust_get_argc() -> libc::c_int;
+ pub fn rust_get_argc() -> libc::c_int;
}
+
// except according to those terms.
use std::comm::*;
+use std::task;
pub fn foo<T:Owned + Copy>(x: T) -> Port<T> {
let (p, c) = stream();
// except according to those terms.
pub mod kitties {
+ use std::uint;
+
pub struct cat {
priv meows : uint,
how_hungry : int,
impl Foo for Bar {
#[inline(always)]
fn f(&self) {
- io::println((*self).x);
+ println((*self).x);
}
}
#[crate_type = "lib"];
+use std::libc;
+
pub mod rustrt {
+ use std::libc;
+
pub extern {
pub fn rust_dbg_call(cb: *u8, data: libc::uintptr_t)
-> libc::uintptr_t;
#[link(name="foreign_lib", vers="0.0")];
pub mod rustrt {
+ use std::libc;
+
pub extern {
pub fn rust_get_argc() -> libc::c_int;
}
#[crate_type = "lib"];
pub mod socket {
+ use std::libc;
+
pub struct socket_handle {
sockfd: libc::c_int,
}
impl Drop for S {
fn finalize(&self) {
- io::println("goodbye");
+ println("goodbye");
}
}
#[crate_type = "lib"];
+use std::int;
+
pub trait read {
fn readMaybe(s: ~str) -> Option<Self>;
}
extern mod extra;
-use std::io;
use extra::time;
use extra::treemap::TreeMap;
use std::hashmap::{HashMap, HashSet};
-use std::trie::TrieMap;
+use std::io;
+use std::os;
use std::rand::Rng;
+use std::trie::TrieMap;
+use std::uint;
+use std::vec;
fn timed(label: &str, f: &fn()) {
let start = time::precise_time_s();
// except according to those terms.
extern mod extra;
-use std::hashmap::HashSet;
+
use extra::bitv::BitvSet;
use extra::treemap::TreeSet;
+use std::hashmap::HashSet;
+use std::io;
+use std::os;
+use std::rand;
+use std::uint;
struct Results {
sequential_ints: float,
extern mod extra;
use extra::time::precise_time_s;
+use std::int;
+use std::io;
+use std::os;
use std::rand::RngUtil;
+use std::rand;
+use std::result;
+use std::uint;
use std::util;
+use std::vec;
macro_rules! bench (
($id:ident) => (maybe_run_test(argv, stringify!($id).to_owned(), $id))
// option. This file may not be copied, modified, or distributed
// except according to those terms.
+use std::os;
+use std::uint;
+
fn main() {
let args = os::args();
let args = if os::getenv(~"RUST_BENCH").is_some() {
use extra::par;
use std::hashmap::HashSet;
use std::int::abs;
+use std::io;
+use std::os;
use std::rand::RngUtil;
+use std::rand;
+use std::uint;
+use std::vec;
type node_id = i64;
type graph = ~[~[node_id]];
// version.
extern mod extra;
-use std::io::Writer;
-use std::io::WriterUtil;
use std::comm::{Port, Chan, SharedChan};
+use std::comm;
+use std::io::{Writer, WriterUtil};
+use std::io;
+use std::os;
+use std::task;
+use std::ptr;
+use std::uint;
+use std::vec;
macro_rules! move_out (
{ $x:expr } => { unsafe { let y = *ptr::to_unsafe_ptr(&($x)); y } }
// I *think* it's the same, more or less.
extern mod extra;
-use std::io::Writer;
-use std::io::WriterUtil;
use std::comm::{Port, PortSet, Chan, stream};
+use std::io::{Writer, WriterUtil};
+use std::io;
+use std::os;
+use std::ptr;
+use std::task;
+use std::uint;
+use std::vec;
macro_rules! move_out (
{ $x:expr } => { unsafe { let y = *ptr::to_unsafe_ptr(&($x)); y } }
// This also serves as a pipes test, because ARCs are implemented with pipes.
extern mod extra;
-use extra::time;
+
use extra::arc;
use extra::future;
+use extra::time;
use std::cell::Cell;
+use std::io;
+use std::os;
+use std::uint;
+use std::vec;
// A poor man's pipe.
type pipe = arc::MutexARC<~[uint]>;
fn send(p: &pipe, msg: uint) {
- do p.access_cond |state, cond| {
- state.push(msg);
- cond.signal();
+ unsafe {
+ do p.access_cond |state, cond| {
+ state.push(msg);
+ cond.signal();
+ }
}
}
fn recv(p: &pipe) -> uint {
- do p.access_cond |state, cond| {
- while vec::is_empty(*state) {
- cond.wait();
+ unsafe {
+ do p.access_cond |state, cond| {
+ while vec::is_empty(*state) {
+ cond.wait();
+ }
+ state.pop()
}
- state.pop()
}
}
extern mod extra;
+use extra::future;
+use extra::time;
use std::cell::Cell;
+use std::io;
+use std::os;
use std::pipes::recv;
+use std::ptr;
+use std::uint;
use std::util;
-use extra::time;
-use extra::future;
proto! ring (
num:send {
extern mod extra;
-use std::cell::Cell;
-use extra::time;
use extra::arc;
use extra::future;
+use extra::time;
+use std::cell::Cell;
+use std::io;
+use std::os;
+use std::uint;
+use std::vec;
// A poor man's pipe.
type pipe = arc::RWARC<~[uint]>;
// Perlin noise benchmark from https://gist.github.com/1170424
+use std::f32;
+use std::float;
+use std::int;
use std::rand::{Rng, RngUtil};
+use std::rand;
struct Vec2 {
x: f32,
extern mod extra;
+use extra::time::precise_time_s;
use std::cell::Cell;
+use std::io;
+use std::os;
use std::pipes::*;
-use extra::time::precise_time_s;
+use std::task;
proto! pingpong (
ping: send {
extern mod extra;
+use std::int;
+use std::io;
+use std::os;
+
fn ack(m: int, n: int) -> int {
if m == 0 {
return n + 1
// chameneos
extern mod extra;
+
use extra::sort;
use std::cell::Cell;
use std::comm::*;
+use std::io;
+use std::option;
+use std::os;
+use std::task;
+use std::uint;
+use std::vec;
fn print_complements() {
let all = ~[Blue, Red, Yellow];
use std::from_str::FromStr;
use std::i32::range;
+use std::os;
use std::vec::MutableVector;
+use std::vec;
fn max(a: i32, b: i32) -> i32 {
if a > b {
use std::cast::transmute;
use std::from_str::FromStr;
use std::libc::{FILE, STDOUT_FILENO, c_int, fdopen, fputc, fputs, fwrite, size_t};
+use std::os;
+use std::str;
use std::uint::{min, range};
use std::vec::bytes::copy_memory;
+use std::vec;
static LINE_LEN: uint = 60;
static LOOKUP_SIZE: uint = 4 * 1024;
* http://shootout.alioth.debian.org/
*/
extern mod extra;
+
+use std::int;
+use std::io;
+use std::option;
+use std::os;
use std::rand::Rng;
+use std::rand;
+use std::result;
+use std::str;
+use std::uint;
+use std::vec;
fn LINE_LENGTH() -> uint { return 60u; }
extern mod extra;
+use std::int;
+use std::io;
+use std::os;
+
fn fib(n: int) -> int {
if n < 2 {
return 1;
// multi tasking k-nucleotide
extern mod extra;
+
use extra::sort;
+use std::cmp::Ord;
+use std::comm::{stream, Port, Chan};
+use std::comm;
use std::hashmap::HashMap;
use std::io::ReaderUtil;
-use std::comm::{stream, Port, Chan};
-use std::cmp::Ord;
+use std::io;
+use std::option;
+use std::os;
+use std::result;
+use std::str;
+use std::task;
use std::util;
+use std::vec;
// given a map, print a sorted version of it
fn sort_and_fmt(mm: &HashMap<~[u8], uint>, total: uint) -> ~str {
use std::from_str::FromStr;
use std::i32::range;
use std::libc::{STDOUT_FILENO, c_int, fdopen, fputc};
+use std::os;
static ITER: uint = 50;
static LIMIT: f64 = 2.0;
+use std::f64;
use std::from_str::FromStr;
+use std::os;
use std::uint::range;
+use std::vec;
static PI: f64 = 3.141592653589793;
static SOLAR_MASS: f64 = 4.0 * PI * PI;
extern mod extra;
use extra::{time, getopts};
-use std::int::range;
use std::comm::*;
+use std::int::range;
use std::io::WriterUtil;
-
+use std::io;
+use std::os;
use std::result::{Ok, Err};
+use std::str;
+use std::task;
+use std::u64;
+use std::uint;
+use std::vec;
fn fib(n: int) -> int {
fn pfib(c: &Chan<int>, n: int) {
+use std::f64;
use std::from_str::FromStr;
use std::iter::ExtendedMutableIter;
+use std::os;
+use std::vec;
#[inline]
fn A(i: i32, j: i32) -> i32 {
// Microbenchmark for the smallintmap library
extern mod extra;
+
use extra::smallintmap::SmallIntMap;
use std::io::WriterUtil;
+use std::io;
+use std::os;
+use std::uint;
fn append_sequential(min: uint, max: uint, map: &mut SmallIntMap<uint>) {
for uint::range(min, max) |i| {
use std::io::{ReaderUtil, WriterUtil};
use std::io;
+use std::os;
+use std::str;
+use std::u8;
+use std::uint;
use std::unstable::intrinsics::cttz16;
+use std::vec;
// Computes a single solution to a given 9x9 sudoku
//
let val = **self & heads;
if (0u16 == val) {
return 0u8;
- }
- else
- {
- return cttz16(val as i16) as u8;
+ } else {
+ unsafe {
+ return cttz16(val as i16) as u8;
+ }
}
}
use extra::list::{List, Cons, Nil};
use extra::time::precise_time_s;
+use std::os;
+use std::task;
enum UniqueList {
ULNil, ULCons(~UniqueList)
// The filename is a song reference; google it in quotes.
use std::cell::Cell;
+use std::comm;
+use std::os;
+use std::task;
+use std::uint;
fn child_generation(gens_left: uint, c: comm::Chan<()>) {
// This used to be O(n^2) in the number of generations that ever existed.
// Doesn't return until all such tasks are ready, but doesn't block forever itself.
use std::comm::*;
+use std::os;
+use std::result;
+use std::task;
+use std::uint;
fn grandchild_group(num_tasks: uint) {
let (po, ch) = stream();
// Test for concurrent tasks
use std::comm::*;
+use std::os;
+use std::task;
+use std::uint;
+use std::vec;
fn calc(children: uint, parent_wait_chan: &Chan<Chan<Chan<int>>>) {
// option. This file may not be copied, modified, or distributed
// except according to those terms.
+use std::os;
+use std::task;
+use std::uint;
+
fn f(n: uint) {
let mut i = 0u;
while i < n {
// except according to those terms.
struct cat {
- priv mut meows : uint,
+ priv meows : uint,
how_hungry : int,
}
// option. This file may not be copied, modified, or distributed
// except according to those terms.
+use std::comm;
+
fn main() {
let (p,c) = comm::stream();
let x = Some(p);
// option. This file may not be copied, modified, or distributed
// except according to those terms.
+use std::vec;
fn compute1() -> float {
let v = ~[0f, 1f, 2f, 3f];
// option. This file may not be copied, modified, or distributed
// except according to those terms.
+use std::vec;
+
fn main() {
for vec::each(~[0]) |_i| { //~ ERROR A for-loop body must return (), but
true
// Tests that auto-ref can't create mutable aliases to immutable memory.
+use std::io;
+
struct Foo {
x: int
}
// option. This file may not be copied, modified, or distributed
// except according to those terms.
+use std::task;
+
fn borrow(v: &int, f: &fn(x: &int)) {
f(v);
}
fn g() {
let mut x: Either<int,float> = Left(3);
- io::println(f(&mut x, &x).to_str()); //~ ERROR cannot borrow
+ println(f(&mut x, &x).to_str()); //~ ERROR cannot borrow
}
fn h() {
y: int,
}
-impl ops::Add<int,int> for Point {
+impl Add<int,int> for Point {
fn add(&self, z: &int) -> int {
self.x + self.y + (*z)
}
},
None => { fail!() }
}
- io::println(*msg);
+ println(*msg);
}
fn main() {
let fifth = a();
- io::println(fmt!("%d", *fifth));
+ println(fmt!("%d", *fifth));
}
};
match &s.x {
&Foo => {}
- &Bar(ref identifier) => io::println(*identifier)
+ &Bar(ref identifier) => println(*identifier)
};
}
}
struct cat {
- priv mut meows : uint,
+ priv meows : uint,
- mut how_hungry : int,
+ how_hungry : int,
name : ~str,
}
// except according to those terms.
struct cat {
- priv mut meows : uint,
+ priv meows : uint,
}
priv impl cat {
+use std::str;
+
fn main() {
let v = ~"test";
let sslice = str::slice(v, 0, v.len());
impl Drop for Foo { //~ ERROR the Drop trait may only be implemented
//~^ ERROR cannot provide an extension implementation
fn finalize(&self) {
- io::println("kaboom");
+ println("kaboom");
}
}
impl Drop for Foo {
fn finalize(&self) {
- io::println("kaboom");
+ println("kaboom");
}
}
impl Drop for Foo {
fn finalize(&self) {
- io::println("kaboom");
+ println("kaboom");
}
}
+++ /dev/null
-// -*- rust -*-
-// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
-// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-
-mod test {
- #[abi = "cdecl"]
- pub extern {
- pub unsafe fn free();
- }
-}
-
-fn main() {
- let x = test::free;
- //~^ ERROR call to unsafe function requires unsafe function or block
-}
// option. This file may not be copied, modified, or distributed
// except according to those terms.
+use std::vec;
+
fn main() {
for vec::each(fail!()) |i| {
let _ = i * 2; //~ ERROR the type of this value must be known
impl Drop for foo {
fn finalize(&self) {
unsafe {
- io::println("Goodbye, World!");
+ println("Goodbye, World!");
*self.x += 1;
}
}
// option. This file may not be copied, modified, or distributed
// except according to those terms.
+use std::uint;
+
fn not_bool(f: &fn(int) -> ~str) -> bool {}
fn main() {
// option. This file may not be copied, modified, or distributed
// except according to those terms.
+use std::uint;
+
fn uuid() -> uint { fail!(); }
fn from_str(s: ~str) -> uint { fail!(); }
// option. This file may not be copied, modified, or distributed
// except according to those terms.
+use std::vec;
+
fn main() {
let needlesArr: ~[char] = ~['a', 'f'];
do vec::foldr(needlesArr) |x, y| {
// option. This file may not be copied, modified, or distributed
// except according to those terms.
+use std::ptr;
+
enum bottom { }
fn main() {
// except according to those terms.
struct thing(uint);
-impl cmp::Ord for thing { //~ ERROR missing method `gt`
+impl Ord for thing { //~ ERROR missing method `gt`
fn lt(&self, other: &thing) -> bool { **self < **other }
fn le(&self, other: &thing) -> bool { **self < **other }
fn ge(&self, other: &thing) -> bool { **self < **other }
// option. This file may not be copied, modified, or distributed
// except according to those terms.
+use std::task;
+
fn main() {
for task::spawn { return true; } //~ ERROR A `for` loop iterator should expect a closure that
//~^ ERROR expected `for` closure to return `bool`
let u = Thing {x: 2};
let _v = u.mul(&3); // This is ok
let w = u * 3; //~ ERROR binary operation * cannot be applied to type `Thing`
- io::println(fmt!("%i", w.x));
+ println(fmt!("%i", w.x));
}
fn main() {
if Lol(2) == Lol(4) {
- io::println("2 == 4");
+ println("2 == 4");
} else {
- io::println("2 != 4");
+ println("2 != 4");
}
}
fn main() {
let v = &5;
- io::println(fmt!("%d", f(v)()));
+ println(fmt!("%d", f(v)()));
}
use std::cmp::Eq;
fn f<T:Eq>(o: &mut Option<T>) {
- assert!(*o == option::None);
+ assert!(*o == None);
}
fn main() {
- f::<int>(&mut option::None);
+ f::<int>(&mut None);
//~^ ERROR cannot borrow
}
// option. This file may not be copied, modified, or distributed
// except according to those terms.
+use std::task;
+
fn user(_i: int) {}
fn foo() {
#[forbid(default_methods)];
trait Foo { //~ ERROR default methods are experimental
- fn bar(&self) { io::println("hi"); }
+ fn bar(&self) { println("hi"); }
}
fn main() {}
use cal = bar::c::cc;
+use std::io;
+
use std::either::Right; //~ ERROR unused import
use std::util::*; // shouldn't get errors for not using
fn bad4() { unsafe { do callback {} } } //~ ERROR: unnecessary `unsafe` block
unsafe fn bad5() { unsafe { unsf() } } //~ ERROR: unnecessary `unsafe` block
fn bad6() {
- unsafe { //~ ERROR: unnecessary `unsafe` block
- unsafe { // don't put the warning here
+ unsafe { // don't put the warning here
+ unsafe { //~ ERROR: unnecessary `unsafe` block
unsf()
}
}
// option. This file may not be copied, modified, or distributed
// except according to those terms.
+use std::vec;
+
fn main() {
let a: ~[int] = ~[];
vec::each(a, |_| -> bool {
}
match [~"foo", ~"bar", ~"baz"] {
- [a, _, _, .._] => { io::println(a); }
+ [a, _, _, .._] => { println(a); }
[~"foo", ~"bar", ~"baz", ~"foo", ~"bar"] => { } //~ ERROR unreachable pattern
_ => { }
}
do f(&s) |hellothere| {
match hellothere.x {
~Foo(_) => {}
- ~Bar(x) => io::println(x.to_str()), //~ ERROR cannot move out
+ ~Bar(x) => println(x.to_str()), //~ ERROR cannot move out
~Baz => {}
}
}
+use std::task;
+
fn main() {
let x = ~"Hello world!";
do task::spawn {
- io::println(x);
+ println(x);
}
- io::println(x); //~ ERROR use of moved value
+ println(x); //~ ERROR use of moved value
}
// Tests that references to move-by-default values trigger moves when
// they occur as part of various kinds of expressions.
+use std::vec;
+
struct Foo<A> { f: A }
fn guard(_s: ~str) -> bool {fail!()}
fn touch<A>(_a: &A) {}
// option. This file may not be copied, modified, or distributed
// except according to those terms.
+use std::uint;
+
fn test(_x: ~uint) {}
fn main() {
// except according to those terms.
struct cat {
- priv mut meows : uint,
+ priv meows : uint,
how_hungry : int,
}
// except according to those terms.
struct cat {
- priv mut meows : uint,
+ priv meows : uint,
how_hungry : int,
}
extern mod extra;
use extra::arc;
+use std::task;
+
fn main() {
let v = ~[1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
let arc_v = arc::ARC(v);
extern mod extra;
use extra::arc;
+use std::task;
+
fn main() {
let v = ~[1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
let arc_v = arc::ARC(v);
// except according to those terms.
use std::cell::Cell;
+use std::task;
struct Port<T>(@T);
// option. This file may not be copied, modified, or distributed
// except according to those terms.
+use std::libc;
+
fn main() {
let x : *~[int] = &~[1,2,3];
let y : *libc::c_void = x as *libc::c_void;
// option. This file may not be copied, modified, or distributed
// except according to those terms.
+use std::unstable;
+
fn main() {
- let x = Some(unstable::sync::exclusive(false));
- match x {
- Some(copy z) => { //~ ERROR copying a value of non-copyable type
- do z.with |b| { assert!(!*b); }
+ unsafe {
+ let x = Some(unstable::sync::exclusive(false));
+ match x {
+ Some(copy z) => { //~ ERROR copying a value of non-copyable type
+ do z.with |b| { assert!(!*b); }
+ }
+ None => fail!()
}
- None => fail!()
}
}
// error-pattern: transmute called on types with different size
+use std::cast;
+
#[packed]
struct Foo<T,S> {
bar: T,
// error-pattern: transmute called on types with different size
+use std::cast;
+
#[packed]
struct Foo {
bar: u8,
// error-pattern:method `nap` is private
mod kitties {
+ use std::uint;
+
pub struct cat {
- priv mut meows : uint,
+ priv meows : uint,
how_hungry : int,
}
// except according to those terms.
fn main() {
- let f = |3: int| io::println("hello"); //~ ERROR refutable pattern
+ let f = |3: int| println("hello"); //~ ERROR refutable pattern
f(4);
}
// option. This file may not be copied, modified, or distributed
// except according to those terms.
+use std::uint;
+
struct dog {
food: uint,
}
impl Drop for Foo {
fn finalize(&self) {
- io::println("Goodbye!");
+ println("Goodbye!");
}
}
extern mod extra;
+use std::task;
+
fn main() { task::spawn(|| -> int { 10 }); }
fn main() {
let x = Foo(1, 2);
match x { //~ ERROR non-exhaustive
- Foo(1, b) => io::println(fmt!("%d", b)),
- Foo(2, b) => io::println(fmt!("%d", b))
+ Foo(1, b) => println(fmt!("%d", b)),
+ Foo(2, b) => println(fmt!("%d", b))
}
}
impl Foo for Bar {
fn f(&self) {
- io::println("hi");
+ println("hi");
}
}
// Test that a class with an unsendable field can't be
// sent
+use std::comm;
+
struct foo {
i: int,
j: @~str,
// error-pattern:unsupported cast
+use std::libc;
+
fn main() {
debug!(1.0 as *libc::FILE); // Can't cast float to foreign.
}
fn main() {
let x = ~"Hello!";
let _y = x;
- io::println(x); //~ ERROR use of moved value
+ println(x); //~ ERROR use of moved value
}
fn main() {
let x = S { x: 1 };
- io::println(x.foo().to_str());
+ println(x.foo().to_str());
}
fn main() {
let x = S { x: ~1 };
- io::println(x.foo().to_str());
+ println(x.foo().to_str());
}
// error-pattern:index out of bounds
+use std::sys;
+use std::vec;
+
fn main() {
// This should cause a bounds-check failure, but may not if we do our
// Testing that runtime failure doesn't cause callbacks to abort abnormally.
// Instead the failure will be delivered after the callbacks return.
+use std::libc;
use std::old_iter;
+use std::task;
mod rustrt {
+ use std::libc;
+
pub extern {
pub fn rust_dbg_call(cb: *u8, data: libc::uintptr_t)
-> libc::uintptr_t;
// error-pattern:moop
extern mod extra;
+
+use std::uint;
+
fn main() { for uint::range(0u, 10u) |_i| { fail!("moop"); } }
// error-pattern:explicit failure
// Don't double free the string
extern mod extra;
+
use std::io::ReaderUtil;
+use std::io;
fn main() {
do io::with_str_reader(~"") |rdr| {
// error-pattern:1 == 2
extern mod extra;
+use std::comm;
+use std::task;
+
fn child() { assert!((1 == 2)); }
fn main() {
// error-pattern:fail
+use std::comm;
+use std::task;
+
fn child() { fail!(); }
fn main() {
// error-pattern:fail
+use std::comm;
+use std::task;
+
fn grandchild() { fail!("grandchild dies"); }
fn child() {
// error-pattern:1 == 2
+use std::comm;
+use std::task;
+
fn child() { assert!((1 == 2)); }
fn parent() {
// error-pattern:squirrelcupcake
fn cmp() -> int {
- match (option::Some('a'), option::None::<char>) {
- (option::Some(_), _) => { fail!("squirrelcupcake"); }
- (_, option::Some(_)) => { fail!(); }
+ match (Some('a'), None::<char>) {
+ (Some(_), _) => { fail!("squirrelcupcake"); }
+ (_, Some(_)) => { fail!(); }
_ => { fail!("wat"); }
}
}
extern mod extra;
+use std::libc;
+use std::task;
+
mod rustrt {
+ use std::libc;
+
pub extern {
pub fn rust_get_argc() -> libc::c_int;
}
extern mod extra;
+use std::task;
+
fn getbig_and_fail(i: int) {
let _r = and_then_get_big_again(5);
if i != 0 {
extern mod extra;
+use std::task;
+
fn getbig_and_fail(i: int) {
let r = and_then_get_big_again(5);
if i != 0 {
// except according to those terms.
// error-pattern:get called on error result: ~"kitty"
+
+use std::result;
+
fn main() {
error!(result::get(&result::Err::<int,~str>(~"kitty")));
}
// error-pattern:whatever
+use std::os;
+
fn main() {
error!(~"whatever");
// Setting the exit status only works when the scheduler terminates
// error-pattern:whatever
+use std::os;
+use std::task;
+
struct r {
x:int,
}
// error-pattern:whatever
+use std::os;
+
fn main() {
error!(~"whatever");
// 101 is the code the runtime uses on task failure and the value
// except according to those terms.
// error-pattern:index out of bounds: the len is 1024 but the index is -1
+
+use std::vec;
+
fn main() {
let v = vec::from_fn(1024u, {|n| n});
// this should trip a bounds check
// error-pattern:explicit
extern mod extra;
+use std::task;
+
// We don't want to see any invalid reads
fn main() {
fn f() {
// error-pattern:goodfail
+use std::comm;
+use std::task;
+
fn goodfail() {
task::yield();
fail!("goodfail");
// error-pattern:Ensure that the child task runs by failing
+use std::str;
+use std::task;
+
fn main() {
// the purpose of this test is to make sure that task::spawn()
// works when provided with a bare function:
// error-pattern:fail
+use std::cast;
+
fn failfn() {
fail!();
}
use anonexternmod::*;
pub fn main() {
- rust_get_argc();
+ unsafe {
+ rust_get_argc();
+ }
}
// option. This file may not be copied, modified, or distributed
// except according to those terms.
+use std::libc;
+
#[abi = "cdecl"]
#[link_name = "rustrt"]
extern {
pub fn main() {
let x = Foo::new();
- io::println(x.x.to_str());
+ println(x.x.to_str());
}
pub fn main() {
let x = Foo::new();
- io::println(x.x.to_str());
+ println(x.x.to_str());
}
// making method calls, but only if there aren't any matches without
// it.
+use std::vec;
+
trait iterable<A> {
fn iterate(&self, blk: &fn(x: &A) -> bool) -> bool;
}
use EBReader = extra::ebml::reader;
use EBWriter = extra::ebml::writer;
use std::cmp::Eq;
+use std::cmp;
use std::io::Writer;
+use std::io;
use extra::ebml;
use extra::serialize::{Decodable, Encodable};
use extra::time;
// option. This file may not be copied, modified, or distributed
// except according to those terms.
+use std::vec;
+
pub fn main() {
let mut sum = 0;
for vec::each(~[1, 2, 3, 4, 5]) |x| {
// option. This file may not be copied, modified, or distributed
// except according to those terms.
+use std::io;
+
trait Foo {
fn f(&self);
}
impl Stuff for Foo {
fn printme(&self) {
- io::println(fmt!("%d", self.x));
+ println(fmt!("%d", self.x));
}
}
pub fn main() {
let x: &'static str = "foo";
- io::println(x);
+ println(x);
}
// Binop corner cases
+use std::libc;
+
fn test_nil() {
assert_eq!((), ());
assert!((!(() != ())));
}
mod test {
+ use std::libc;
+
#[abi = "cdecl"]
#[nolink]
pub extern {
// option. This file may not be copied, modified, or distributed
// except according to those terms.
+use std::vec;
+
pub fn main() {
let v = ~[-1f, 0f, 1f, 2f, 3f];
// option. This file may not be copied, modified, or distributed
// except according to those terms.
+use std::vec;
+
pub fn main() {
fn f(i: &fn() -> uint) -> uint { i() }
let v = ~[-1f, 0f, 1f, 2f, 3f];
// option. This file may not be copied, modified, or distributed
// except according to those terms.
+use std::vec;
+
pub fn main() {
fn f(i: uint) -> uint { i }
let v = ~[-1f, 0f, 1f, 2f, 3f];
// option. This file may not be copied, modified, or distributed
// except according to those terms.
+use std::vec;
+
fn w_semi(v: ~[int]) -> int {
// the semicolon causes compiler not to
// complain about the ignored return value:
// option. This file may not be copied, modified, or distributed
// except according to those terms.
+use std::vec;
+
// Check usage and precedence of block arguments in expressions:
pub fn main() {
let v = ~[-1f, 0f, 1f, 2f, 3f];
// option. This file may not be copied, modified, or distributed
// except according to those terms.
-extern mod extra;
+use std::vec;
pub fn main() {
let v =
// option. This file may not be copied, modified, or distributed
// except according to those terms.
+use std::ptr;
+
fn borrow(x: &int, f: &fn(x: &int)) {
f(x)
}
// option. This file may not be copied, modified, or distributed
// except according to those terms.
+use std::uint;
use std::util;
struct Ints {sum: ~int, values: ~[int]}
// option. This file may not be copied, modified, or distributed
// except according to those terms.
+use std::vec;
+
fn want_slice(v: &[int]) -> int {
let mut sum = 0;
for vec::each(v) |i| { sum += *i; }
// exec-env:RUST_POISON_ON_FREE=1
+use std::ptr;
+
struct F { f: ~int }
pub fn main() {
// exec-env:RUST_POISON_ON_FREE=1
+use std::ptr;
+
fn borrow(x: &int, f: &fn(x: &int)) {
let before = *x;
f(x);
// exec-env:RUST_POISON_ON_FREE=1
+use std::ptr;
+
struct F { f: ~int }
pub fn main() {
// exec-env:RUST_POISON_ON_FREE=1
+use std::ptr;
+
fn borrow(x: &int, f: &fn(x: &int)) {
let before = *x;
f(x);
// exec-env:RUST_POISON_ON_FREE=1
+use std::ptr;
+
fn borrow(x: &int, f: &fn(x: &int)) {
let before = *x;
f(x);
// exec-env:RUST_POISON_ON_FREE=1
+use std::ptr;
+
fn borrow(x: &int, f: &fn(x: &int)) {
let before = *x;
f(x);
pub impl Wizard {
fn cast(&mut self) {
for self.spells.each |&spell| {
- io::println(spell);
+ println(spell);
}
}
}
fn g(x: &Option<int>) {
- io::println(x.get().to_str());
+ println(x.get().to_str());
}
fn f(x: &mut Option<int>) {
fn f(x: &int) {
- io::println(x.to_str());
+ println(x.to_str());
}
pub fn main() {
impl Foo for int {
fn foo(@self) {
- io::println("Hello world!");
+ println("Hello world!");
}
}
// option. This file may not be copied, modified, or distributed
// except according to those terms.
+use std::vec;
+
pub fn main() {
let mut i = 0;
while i < 20 { i += 1; if i == 10 { break; } }
// option. This file may not be copied, modified, or distributed
// except according to those terms.
+use std::libc;
+
mod rustrt {
+ use std::libc;
+
#[abi = "cdecl"]
pub extern {
pub fn get_task_id() -> libc::intptr_t;
// option. This file may not be copied, modified, or distributed
// except according to those terms.
-extern mod extra;
+use std::str;
mod libc {
#[abi = "cdecl"]
// option. This file may not be copied, modified, or distributed
// except according to those terms.
+use std::ptr;
+
pub fn main() {
let x = ~1;
let y = ptr::to_unsafe_ptr(&(*x)) as uint;
// irrelevant).
use std::comm::*;
+use std::task;
fn foo(x: ()) -> Port<()> {
let (p, c) = stream::<()>();
// option. This file may not be copied, modified, or distributed
// except according to those terms.
+use std::ptr;
+
pub fn main() {
let x = 3;
debug!("&x=%x", ptr::to_uint(&x));
//debug!("%?", bt0);
do 3u.to(10u) |i| {
- io::print(fmt!("%u\n", i));
+ print(fmt!("%u\n", i));
//let bt1 = sys::frame_address();
//debug!("%?", bt1);
//let bt0 = sys::rusti::frame_address(1u32);
//debug!("%?", bt0);
do cci_iter_lib::iter(~[1, 2, 3]) |i| {
- io::print(fmt!("%d", *i));
+ print(fmt!("%d", *i));
//assert!(bt0 == sys::rusti::frame_address(2u32));
}
}
//let bt0 = sys::frame_address();
//debug!("%?", bt0);
do iter(~[1u, 2u, 3u]) |i| {
- io::print(fmt!("%u\n", i));
+ print(fmt!("%u\n", i));
//let bt1 = sys::frame_address();
//debug!("%?", bt1);
// Reported as issue #126, child leaks the string.
-extern mod extra;
+use std::task;
fn child2(s: ~str) { }
// option. This file may not be copied, modified, or distributed
// except according to those terms.
+use std::uint;
+
trait noisy {
fn speak(&self) -> int;
}
// xfail-fast
+use std::cmp;
use std::container::{Container, Mutable, Map};
+use std::int;
use std::old_iter::BaseIter;
+use std::uint;
enum cat_type { tuxedo, tabby, tortoiseshell }
extern mod cci_class_trait;
use cci_class_trait::animals::*;
+use std::uint;
+
struct cat {
priv meows: uint,
// xfail-fast
+use std::uint;
+
trait noisy {
fn speak(&mut self);
}
extern mod cci_class_4;
use cci_class_4::kitties::*;
+use std::uint;
+
pub fn main() {
let mut nyan = cat(0u, 2, ~"nyan");
nyan.eat();
// option. This file may not be copied, modified, or distributed
// except according to those terms.
+use std::uint;
+
struct cat {
priv meows : uint,
// except according to those terms.
// xfail-win32
+
+use std::result;
+use std::task;
+
fn adder(x: @int, y: @int) -> int { return *x + *y; }
fn failer() -> @int { fail!(); }
pub fn main() {
+use std::vec;
+
trait Reverser {
fn reverse(&self);
}
+use std::vec;
+
trait Reverser {
fn reverse(self);
}
// except according to those terms.
use std::comm::*;
+use std::task;
pub fn main() {
let (p, ch) = stream();
// option. This file may not be copied, modified, or distributed
// except according to those terms.
+use std::ptr;
+
static a: *u8 = 0 as *u8;
pub fn main() {
// option. This file may not be copied, modified, or distributed
// except according to those terms.
+use std::libc;
+
extern fn foo() {}
static x: *u8 = foo;
// option. This file may not be copied, modified, or distributed
// except according to those terms.
+use std::io;
+
static x : [int, ..4] = [1,2,3,4];
static p : int = x[2];
static y : &'static [int] = &[1,2,3,4];
pub fn main() {
let (p, _) = y.x;
assert_eq!(p, - 1085102592571150096);
- io::println(fmt!("0x%x", p as uint));
+ println(fmt!("0x%x", p as uint));
}
// option. This file may not be copied, modified, or distributed
// except according to those terms.
+use std::ptr;
+
type Big = [u64, ..8];
struct Pair<'self> { a: int, b: &'self Big }
static x: &'static Big = &([13, 14, 10, 13, 11, 14, 14, 15]);
// option. This file may not be copied, modified, or distributed
// except according to those terms.
+use std::io;
struct Pair<'self> { a: int, b: &'self int }
// option. This file may not be copied, modified, or distributed
// except according to those terms.
+use std::str;
+
static a: [u8, ..3] = ['h' as u8, 'i' as u8, 0 as u8];
static c: &'static [u8, ..3] = &a;
static b: *u8 = c as *u8;
// option. This file may not be copied, modified, or distributed
// except according to those terms.
+use std::cmp;
+use std::io;
struct foo { a: int, b: int, c: int }
// option. This file may not be copied, modified, or distributed
// except according to those terms.
+use std::io;
+
static x : [int, ..4] = [1,2,3,4];
static y : &'static [int] = &[1,2,3,4];
// Regression test that f64 exports things properly
+use std::f64;
+use std::float;
+
pub fn main() {
let digits: uint = 10 as uint;
- ::std::io::println(float::to_str_digits(f64::sqrt(42.0f64) as float, digits));
+ println(float::to_str_digits(f64::sqrt(42.0f64) as float, digits));
}
// memory, which makes for some *confusing* logs. That's why these are here
// instead of in std.
-use std::run;
+use std::libc;
+use std::os;
use std::run::*;
+use std::run;
+use std::str;
#[test]
fn test_destroy_once() {
trait Foo {
fn f(&self) {
- io::println("Hello!");
+ println("Hello!");
self.g();
}
fn g(&self);
impl Foo for A {
fn g(&self) {
- io::println("Goodbye!");
+ println("Goodbye!");
}
}
// option. This file may not be copied, modified, or distributed
// except according to those terms.
+use std::rand;
+
#[deriving(Rand)]
struct A;
rand::random::<C>();
rand::random::<D>();
}
-}
\ No newline at end of file
+}
// option. This file may not be copied, modified, or distributed
// except according to those terms.
+use std::rand;
+
#[deriving(Rand,ToStr)]
struct A;
t!(C);
t!(D);
}
-}
\ No newline at end of file
+}
#[unsafe_destructor]
impl<T> ::std::ops::Drop for S<T> {
fn finalize(&self) {
- io::println("bye");
+ println("bye");
}
}
impl Drop for Foo {
fn finalize(&self) {
- io::println("bye");
+ println("bye");
}
}
// option. This file may not be copied, modified, or distributed
// except according to those terms.
+use std::old_iter;
trait thing<A> {
fn foo(&self) -> Option<A>;
enum chan { chan_t, }
-impl cmp::Eq for chan {
+impl Eq for chan {
fn eq(&self, other: &chan) -> bool {
((*self) as uint) == ((*other) as uint)
}
// option. This file may not be copied, modified, or distributed
// except according to those terms.
+use std::cast;
+use std::ptr;
+use std::sys;
+
fn addr_of<T>(ptr: &T) -> uint {
let ptr = ptr::to_unsafe_ptr(ptr);
unsafe { ptr as uint }
// xfail-fast (exec-env not supported in fast mode)
// exec-env:TEST_EXEC_ENV=22
+use std::os;
+
pub fn main() {
assert_eq!(os::getenv(~"TEST_EXEC_ENV"), Some(~"22"));
}
// not exported
enum t { t1, t2, }
- impl cmp::Eq for t {
+ impl Eq for t {
fn eq(&self, other: &t) -> bool {
((*self) as uint) == ((*other) as uint)
}
enum mood { happy, sad, }
-impl cmp::Eq for mood {
+impl Eq for mood {
fn eq(&self, other: &mood) -> bool {
((*self) as uint) == ((*other) as uint)
}
enum mood { happy, sad, }
-impl cmp::Eq for mood {
+impl Eq for mood {
fn eq(&self, other: &mood) -> bool {
((*self) as uint) == ((*other) as uint)
}
// option. This file may not be copied, modified, or distributed
// except according to those terms.
+use std::libc;
+
mod rustrt {
+ use std::libc;
+
pub extern {
pub fn rust_dbg_call(cb: *u8, data: libc::uintptr_t)
-> libc::uintptr_t;
// option. This file may not be copied, modified, or distributed
// except according to those terms.
+use std::libc;
+use std::task;
+
mod rustrt {
+ use std::libc;
+
pub extern {
pub fn rust_dbg_call(cb: *u8, data: libc::uintptr_t)
-> libc::uintptr_t;
// make sure the stack pointers are maintained properly in both
// directions
+use std::libc;
+use std::task;
+
mod rustrt {
+ use std::libc;
+
pub extern {
pub fn rust_dbg_call(cb: *u8, data: libc::uintptr_t)
-> libc::uintptr_t;
// option. This file may not be copied, modified, or distributed
// except according to those terms.
+use std::libc;
+
mod rustrt {
+ use std::libc;
+
pub extern {
pub fn rust_dbg_call(cb: *u8, data: libc::uintptr_t)
-> libc::uintptr_t;
use extra::json::Object;
pub fn main() {
- io::println("Hello world!");
+ println("Hello world!");
}
+use std::libc;
+use std::sys;
+use std::vec;
+
extern {
pub unsafe fn vec_reserve_shared_actual(t: *sys::TypeDesc,
v: **vec::raw::VecRepr,
// This creates a bunch of yielding tasks that run concurrently
// while holding onto C stacks
+use std::libc;
+use std::task;
+
mod rustrt {
+ use std::libc;
+
pub extern {
pub fn rust_dbg_call(cb: *u8, data: libc::uintptr_t)
-> libc::uintptr_t;
// option. This file may not be copied, modified, or distributed
// except according to those terms.
+use std::libc;
+use std::task;
+
mod rustrt {
+ use std::libc;
+
pub extern {
pub fn rust_dbg_call(cb: *u8, data: libc::uintptr_t)
-> libc::uintptr_t;
// option. This file may not be copied, modified, or distributed
// except according to those terms.
+use std::sys;
+
struct Struc { a: u8, b: [int, ..3], c: int }
pub fn main() {
pub fn main() {
let x: f32 = 4.0;
- io::println(x.to_str());
+ println(x.to_str());
let y: float = 64.0;
- io::println(y.to_str());
+ println(y.to_str());
let z = S { z: 1.0 };
- io::println(z.z.to_str());
+ println(z.z.to_str());
}
pub fn main() {
let v : &[(int,int)] = &[ (1, 2), (3, 4), (5, 6) ];
for v.each |&(x, y)| {
- io::println(y.to_str());
- io::println(x.to_str());
+ println(y.to_str());
+ println(x.to_str());
}
}
// option. This file may not be copied, modified, or distributed
// except according to those terms.
+use std::vec;
+
struct Pair { x: int, y: int }
pub fn main() {
+use std::cast;
+use std::libc;
use std::unstable::run_in_bare_thread;
extern {
// calling pin_task and that's having wierd side-effects.
mod rustrt1 {
+ use std::libc;
+
#[abi = "cdecl"]
#[link_name = "rustrt"]
pub extern {
}
mod rustrt2 {
+ use std::libc;
+
#[abi = "cdecl"]
#[link_name = "rustrt"]
pub extern {
extern mod extra;
+use std::libc;
+use std::str;
+use std::vec;
+
mod libc {
#[nolink]
#[abi = "cdecl"]
// ABI is cdecl by default
mod rustrt {
+ use std::libc;
+
pub extern {
pub fn get_task_id() -> libc::intptr_t;
}
pub fn main() {
let a = Foo { x: 1, y: 2 };
let c = Foo { x: 4, .. a};
- io::println(fmt!("%?", c));
+ println(fmt!("%?", c));
}
pub fn main() {
let s = S(2i);
- io::println(s.to_str());
+ println(s.to_str());
}
let opts = ~[optopt(~"b")];
match getopts(args, opts) {
- result::Ok(ref m) =>
+ Ok(ref m) =>
assert!(!opt_present(m, "b")),
- result::Err(ref f) => fail!(fail_str(copy *f))
+ Err(ref f) => fail!(fail_str(copy *f))
};
}
pub fn map(filename: ~str, emit: map_reduce::putter) { emit(filename, ~"1"); }
mod map_reduce {
- use std::hashmap::HashMap;
use std::comm::*;
+ use std::hashmap::HashMap;
+ use std::str;
+ use std::task;
pub type putter = @fn(~str, ~str);
// option. This file may not be copied, modified, or distributed
// except according to those terms.
-
pub fn main() {
- io::println("hello, world");
+ println("hello, world");
}
pub fn main() {
let fish1 = impl_privacy_xc_2::Fish { x: 1 };
let fish2 = impl_privacy_xc_2::Fish { x: 2 };
- io::println(if fish1.eq(&fish2) { "yes" } else { "no " });
+ println(if fish1.eq(&fish2) { "yes" } else { "no " });
}
pub fn main() {
let mut v = from_elem(0u, 0);
- v = vec::append(v, ~[4, 2]);
+ v = append(v, ~[4, 2]);
assert_eq!(reversed(v), ~[2, 4]);
}
// option. This file may not be copied, modified, or distributed
// except according to those terms.
+use std::ptr;
// check that we do not report a type like this as uninstantiable,
// even though it would be if the nxt field had type @foo:
// option. This file may not be copied, modified, or distributed
// except according to those terms.
+use std::f64;
+
mod rusti {
#[abi = "rust-intrinsic"]
pub extern "rust-intrinsic" {
unsafe {
use rusti::*;
+ use std::f32;
+ use std::f64;
+
assert!((sqrtf32(64f32).approx_eq(&8f32)));
assert!((sqrtf64(64f64).approx_eq(&8f64)));
extern mod foreign_lib;
pub fn main() {
- let foo = foreign_lib::rustrt::rust_get_argc();
+ unsafe {
+ let foo = foreign_lib::rustrt::rust_get_argc();
+ }
}
#[link(name = "get_task_id")];
mod rustrt {
+ use std::libc;
+
pub extern {
pub fn get_task_id() -> libc::intptr_t;
}
// except according to those terms.
use std::hashmap::HashMap;
+use std::str;
pub fn main() {
let mut m = HashMap::new();
// except according to those terms.
use std::old_iter::BaseIter;
+use std::old_iter;
trait FlatMapToVec<A> {
fn flat_map_to_vec<B, IB:BaseIter<B>>(&self, op: &fn(&A) -> IB) -> ~[B];
// tjc: I don't know why
pub mod pipes {
- use std::util;
use std::cast::{forget, transmute};
+ use std::cast;
+ use std::task;
+ use std::util;
pub struct Stuff<T> {
state: state,
// except according to those terms.
extern mod extra;
-use std::hashmap::HashMap;
+
use extra::json;
+use std::hashmap::HashMap;
+use std::option;
enum object {
bool_value(bool),
// option. This file may not be copied, modified, or distributed
// except according to those terms.
+use std::sys;
+
struct Cat {
x: int
}
extern mod extra;
use std::io::ReaderUtil;
+use std::io;
+use std::str;
+use std::to_str;
enum square {
bot,
extern mod extra;
+use std::io;
+use std::uint;
+use std::vec;
+
trait methods {
fn to_bytes(&self) -> ~[u8];
}
// xfail-fast
// aux-build:issue-3012-1.rs
extern mod socketlib;
+
use socketlib::socket;
+use std::libc;
pub fn main() {
let fd: libc::c_int = 1 as libc::c_int;
// xfail-fast
+use std::comm;
+use std::task;
+
pub fn main() {
let (p,c) = comm::stream();
do task::try || {
// xfail-fast
use std::comm::{Select2, Selectable};
+use std::comm;
+use std::task;
pub fn main() {
let (p,c) = comm::stream();
x += 1;
}
assert_eq!(x, 4096);
- io::println(fmt!("x = %u", x));
+ println(fmt!("x = %u", x));
}
fn print_str_vector(vector: ~[~str]) {
for vector.each() |string| {
- io::println(*string);
+ println(*string);
}
}
// rustc --test ignores2.rs && ./ignores2
extern mod extra;
+
use std::path::{Path};
+use std::path;
+use std::result;
type rsrc_loader = ~fn(path: &Path) -> result::Result<~str, ~str>;
fn addEnd(&mut self, element: &'self T) {
let newList = list {
element: element,
- next: option::None
+ next: None
};
self.next = Some(@mut newList);
let s = @"str";
let ls = list {
element: &s,
- next: option::None
+ next: None
};
- io::println(*ls.element);
+ println(*ls.element);
}
// except according to those terms.
extern mod extra;
+
use std::io::WriterUtil;
+use std::io;
enum Token {
Text(@~str),
// Extern mod controls linkage. Use controls the visibility of names to modules that are
// already linked in. Using WriterUtil allows us to use the write_line method.
+use std::int;
use std::io::WriterUtil;
+use std::io;
+use std::str;
+use std::vec;
// Represents a position on a canvas.
struct Point {
extern mod extra;
use std::comm::Chan;
+use std::task;
+use std::uint;
type RingBuffer = ~[float];
type SamplesFn = ~fn(samples: &RingBuffer);
}
fn to_string(t: @Text) {
- io::println(t.to_str());
+ println(t.to_str());
}
}
// Issue Name: pub method preceeded by attribute can't be parsed
// Abstract: Visibility parsing failed when compiler parsing
+use std::float;
+
struct Point {
x: float,
y: float
pub fn main(){
let s = Circle(Point { x: 1f, y: 2f }, 3f);
- io::println(fmt!("%f", s.area(s)));
+ println(fmt!("%f", s.area(s)));
}
buildings::Tower { height: h } => { h }
};
- io::println(h.to_str());
+ println(h.to_str());
}
// option. This file may not be copied, modified, or distributed
// except according to those terms.
+use std::vec;
+
fn vec_peek<'r, T>(v: &'r [T]) -> &'r [T] {
// This doesn't work, and should.
// v.slice(1, 5)
// option. This file may not be copied, modified, or distributed
// except according to those terms.
+use std::io;
+
fn main() {
let stdout = &io::stdout() as &io::WriterUtil;
stdout.write_line("Hello!");
count += 1;
}
assert_eq!(count, 999_999);
- io::println(fmt!("%u", count));
+ println(fmt!("%u", count));
}
// option. This file may not be copied, modified, or distributed
// except according to those terms.
+use std::comm;
+use std::task;
+
pub fn main() {
let (port, chan) = comm::stream::<&'static str>();
-fn foo<T: ::cmp::Eq>(t: T) { }
+fn foo<T: ::std::cmp::Eq>(t: T) { }
fn main() { }
// option. This file may not be copied, modified, or distributed
// except according to those terms.
+use std::io;
+
fn main() {
return;
while io::stdin().read_line() != ~"quit" { };
mod test_foreign_items {
pub mod rustrt {
+ use std::libc;
+
#[abi = "cdecl"]
pub extern {
#[attr];
// option. This file may not be copied, modified, or distributed
// except according to those terms.
+use std::old_iter;
+
fn is_even(x: &uint) -> bool { (*x % 2) == 0 }
pub fn main() {
// option. This file may not be copied, modified, or distributed
// except according to those terms.
+use std::old_iter;
+
fn is_even(x: &uint) -> bool { (*x % 2) == 0 }
pub fn main() {
// option. This file may not be copied, modified, or distributed
// except according to those terms.
+use std::old_iter;
+
pub fn main() {
assert_eq!([].contains(&22u), false);
assert_eq!([1u, 3u].contains(&22u), false);
// option. This file may not be copied, modified, or distributed
// except according to those terms.
+use std::old_iter;
+
pub fn main() {
assert_eq!([].count(&22u), 0u);
assert_eq!([1u, 3u].count(&22u), 0u);
// option. This file may not be copied, modified, or distributed
// except according to those terms.
+use std::old_iter;
+
pub fn main() {
let mut c = 0u;
for [1u, 2u, 3u, 4u, 5u].eachi |i, v| {
// option. This file may not be copied, modified, or distributed
// except according to those terms.
+use std::old_iter;
+
fn is_even(x: &uint) -> bool { (*x % 2) == 0 }
pub fn main() {
// option. This file may not be copied, modified, or distributed
// except according to those terms.
+use std::old_iter;
+
fn repeat(x: &uint) -> ~[uint] { ~[*x, *x] }
fn incd_if_even(x: &uint) -> Option<uint> {
// option. This file may not be copied, modified, or distributed
// except according to those terms.
+use std::old_iter;
+
fn add(x: &float, y: &uint) -> float { *x + ((*y) as float) }
pub fn main() {
// option. This file may not be copied, modified, or distributed
// except according to those terms.
+use std::old_iter;
+
fn inc(x: &uint) -> uint { *x + 1 }
pub fn main() {
// option. This file may not be copied, modified, or distributed
// except according to those terms.
+use std::old_iter;
+
fn is_even(x: uint) -> bool { (x % 2u) == 0u }
pub fn main() {
// option. This file may not be copied, modified, or distributed
// except according to those terms.
+use std::old_iter;
+
pub fn main() {
assert_eq!([1u, 3u].to_vec(), ~[1u, 3u]);
let e: ~[uint] = ~[];
use std::comm::*;
+use std::task;
fn producer(c: &Chan<~[u8]>) {
c.send(
fn f() {
let a = ~"hello";
let b: &str = a;
- io::println(b);
+ println(b);
}
pub fn main() {
// option. This file may not be copied, modified, or distributed
// except according to those terms.
-
+use std::str;
pub fn main() {
let x = ~[1, 2, 3];
// option. This file may not be copied, modified, or distributed
// except according to those terms.
+use std::sys;
+
pub fn main() {
let act = sys::log_str(&~[1, 2, 3]);
assert_eq!(~"~[1, 2, 3]", act);
// xfail-win32 leaks
extern mod extra;
+use std::task;
+use std::uint;
+
fn die() {
fail!();
}
// option. This file may not be copied, modified, or distributed
// except according to those terms.
+use std::unstable;
+
pub fn main() {
- let x = Some(unstable::sync::exclusive(true));
- match x {
- Some(ref z) if z.with(|b| *b) => {
- do z.with |b| { assert!(*b); }
- },
- _ => fail!()
+ unsafe {
+ let x = Some(unstable::sync::exclusive(true));
+ match x {
+ Some(ref z) if z.with(|b| *b) => {
+ do z.with |b| { assert!(*b); }
+ },
+ _ => fail!()
+ }
}
}
// option. This file may not be copied, modified, or distributed
// except according to those terms.
+use std::uint;
+
pub fn main() {
// sometimes we have had trouble finding
// the right type for f, as we unified
pub fn main() {
let foo = Foo(3, 20);
- io::println(fmt!("%d %d", foo.sum(), foo.product()));
+ println(fmt!("%d %d", foo.sum(), foo.product()));
}
// xfail-fast
+use std::int;
+
trait vec_monad<A> {
fn bind<B:Copy>(&self, f: &fn(&A) -> ~[B]) -> ~[B];
}
extern mod extra;
+use std::io;
+
trait Serializer {
}
extern mod extra;
+use std::task;
+
fn getbig(i: int) {
if i != 0 {
getbig(i - 1);
// This test attempts to force the dynamic linker to resolve
// external symbols as close to the red zone as possible.
+use std::rand;
+use std::task;
+
mod rustrt {
+ use std::libc;
+
pub extern {
pub fn debug_get_stk_seg() -> *u8;
extern mod extra;
+use std::uint;
+
struct Triple { x: int, y: int, z: int }
fn test(x: bool, foo: ~Triple) -> int {
extern mod extra;
+use std::uint;
+
struct Triple { x: int, y: int, z: int }
fn test(x: bool, foo: @Triple) -> int {
}
fn bar(self) {
- io::println(self.x);
+ println(self.x);
}
}
+use std::task;
+
pub fn main() {
let x = ~"Hello world!";
do task::spawn {
- io::println(x);
+ println(x);
}
}
// Test that multibyte characters don't crash the compiler
fn main() {
- io::println("마이너스 사인이 없으면");
+ println("마이너스 사인이 없으면");
}
// option. This file may not be copied, modified, or distributed
// except according to those terms.
+use std::vec;
+
fn test1() {
let mut ints = [0, ..32];
ints[0] += 1;
// option. This file may not be copied, modified, or distributed
// except according to those terms.
-
-
// -*- rust -*-
extern mod extra;
+use std::vec;
+
fn grow(v: &mut ~[int]) { *v += ~[1]; }
pub fn main() {
}
pub fn main() {
- io::println(Thingy { x: 1, y: 2 }.to_str());
- io::println(PolymorphicThingy { x: Thingy { x: 1, y: 2 } }.to_str());
+ println(Thingy { x: 1, y: 2 }.to_str());
+ println(PolymorphicThingy { x: Thingy { x: 1, y: 2 } }.to_str());
}
pub fn main() {
let myval = mytype(Mytype{compute: compute, val: 30});
- io::println(fmt!("%d", compute(myval)));
+ println(fmt!("%d", compute(myval)));
assert_eq!((myval.compute)(myval), 50);
}
// option. This file may not be copied, modified, or distributed
// except according to those terms.
+use std::sys;
+
enum E<T> { Thing(int, T), Nothing((), ((), ()), [i8, ..0]) }
struct S<T>(int, T);
// xfail-fast
+use std::cmp;
+use std::ops;
+
struct Point {
x: int,
y: int
// option. This file may not be copied, modified, or distributed
// except according to those terms.
+use std::str;
+
pub fn main() {
let thing = ~"{{ f }}";
let f = str::find_str(thing, ~"{{");
if f.is_none() {
- io::println(~"None!");
+ println(~"None!");
}
}
// option. This file may not be copied, modified, or distributed
// except according to those terms.
+use std::cast;
+
#[packed]
struct S<T, S> {
a: T,
// option. This file may not be copied, modified, or distributed
// except according to those terms.
+use std::sys;
+
#[packed]
struct S<T, S> {
a: T,
// option. This file may not be copied, modified, or distributed
// except according to those terms.
+use std::cast;
+
#[packed]
struct S4 {
a: u8,
extern mod packed;
+use std::sys;
+
fn main() {
assert_eq!(sys::size_of::<packed::S>(), 5);
}
// option. This file may not be copied, modified, or distributed
// except according to those terms.
+use std::sys;
+
#[packed]
struct S4 {
a: u8,
// option. This file may not be copied, modified, or distributed
// except according to those terms.
+use std::sys;
+use std::uint;
+
#[packed]
#[deriving(Eq)]
struct Foo {
// option. This file may not be copied, modified, or distributed
// except according to those terms.
+use std::cast;
+
#[packed]
struct S4(u8,[u8, .. 3]);
// option. This file may not be copied, modified, or distributed
// except according to those terms.
+use std::sys;
+
#[packed]
struct S4(u8,[u8, .. 3]);
// pattern-bound var is an upvar (when translating
// the for-each body)
+use std::uint;
+
fn foo(src: uint) {
match Some(src) {
}
pub fn main() {
- let f = |(x, _): (int, int)| io::println((x + 1).to_str());
- let g = |Foo { x: x, y: y }: Foo| io::println((x + 1).to_str());
+ let f = |(x, _): (int, int)| println((x + 1).to_str());
+ let g = |Foo { x: x, y: y }: Foo| println((x + 1).to_str());
f((2, 3));
g(Foo { x: 1, y: 2 });
}
use std::pipes;
use std::pipes::try_recv;
+use std::ptr;
pub type username = ~str;
pub type password = ~str;
let bank = client::withdrawal(bank, 50.00);
switch(bank, follow! (
money(m) -> _next {
- io::println(~"Yay! I got money!");
+ println(~"Yay! I got money!");
}
insufficient_funds -> _next {
fail!("someone stole my money")
let bank = client::withdrawal(bank, 50.00);
match try_recv(bank) {
Some(money(*)) => {
- io::println(~"Yay! I got money!");
+ println(~"Yay! I got money!");
}
Some(insufficient_funds(_)) => {
fail!("someone stole my money")
use std::cell::Cell;
use std::pipes::{try_recv, recv};
+use std::task;
proto! oneshot (
waiting:send {
// protocols.
use std::cell::Cell;
+use std::task;
// This was generated initially by the pipe compiler, but it's been
// modified in hopefully straightforward ways.
use std::cell::Cell;
use std::option;
+use std::task;
proto! pingpong (
ping:send {
use extra::uv;
use std::cell::Cell;
-use std::pipes;
use std::pipes::*;
+use std::pipes;
+use std::task;
proto! oneshot (
waiting:send {
stream::client::send(ac, 42);
match pipes::select2(ap, bp) {
- either::Left(*) => { }
- either::Right(*) => { fail!() }
+ Left(*) => { }
+ Right(*) => { fail!() }
}
stream::client::send(bc, ~"abc");
stream::client::send(bc, ~"abc");
match pipes::select2(ap, bp) {
- either::Left(*) => { fail!() }
- either::Right(*) => { }
+ Left(*) => { fail!() }
+ Right(*) => { }
}
stream::client::send(ac, 42);
// except according to those terms.
extern mod extra;
+
use extra::timer::sleep;
use extra::uv;
use std::cell::Cell;
-use std::pipes;
use std::pipes::*;
+use std::pipes;
+use std::task;
proto! oneshot (
waiting:send {
let mut arena = arena::Arena();
let p = &mut arena;
let x = p.alloc(|| 4u);
- io::print(fmt!("%u", *x));
+ print(fmt!("%u", *x));
assert_eq!(*x, 4u);
}
// The OS main scheduler should continue to be available and not terminate
// while it is not in use.
+use std::task;
+
pub fn main() {
run(100);
}
// option. This file may not be copied, modified, or distributed
// except according to those terms.
+use std::uint;
+
struct cat {
priv meows : uint,
// option. This file may not be copied, modified, or distributed
// except according to those terms.
+use std::vec;
+
trait sum {
fn sum(self) -> int;
}
// Issue #2303
+use std::sys;
+
mod rusti {
#[abi = "rust-intrinsic"]
pub extern "rust-intrinsic" {
// Issue #2303
+use std::sys;
+
mod rusti {
#[abi = "rust-intrinsic"]
pub extern "rust-intrinsic" {
// xfail-fast
use std::bool;
+use std::int;
use std::libc::c_void;
+use std::ptr;
+use std::sys;
use std::vec::UnboxedVecRepr;
use intrinsic::{TyDesc, get_tydesc, visit_tydesc, TyVisitor, Opaque};
visit_tydesc(td, v);
for (u.vals.clone()).each |s| {
- io::println(fmt!("val: %s", *s));
+ println(fmt!("val: %s", *s));
}
error!("%?", u.vals.clone());
assert!(u.vals == ~[
// option. This file may not be copied, modified, or distributed
// except according to those terms.
+use std::uint;
use std::util;
pub fn main() {
// option. This file may not be copied, modified, or distributed
// except according to those terms.
+use std::cast;
+use std::libc;
+use std::sys;
+
struct arena(());
struct Bcx<'self> {
// Don't leak the unique pointers
+use std::cast;
+
struct r {
v: *int,
}
// Don't leak the unique pointers
+use std::cast;
+
struct U {
a: int,
b: int,
// Don't leak the unique pointers
+use std::cast;
+
struct U {
a: int,
b: int,
// xfail-fast
use std::cmp::Eq;
+use std::vec;
fn iter<T>(v: ~[T], it: &fn(&T) -> bool) -> bool {
let mut i = 0u, l = v.len();
// Tests of the runtime's scheduler interface
+use std::cast;
use std::comm::*;
+use std::libc;
pub type sched_id = int;
pub type task_id = *libc::c_void;
mod rustrt {
use super::{closure, sched_id, task, task_id};
+ use std::libc;
+
pub extern {
pub fn rust_new_sched(num_threads: libc::uintptr_t) -> sched_id;
pub fn rust_get_sched_id() -> sched_id;
// xfail-win32
extern mod extra;
+use std::comm;
+use std::task;
+use std::uint;
+
fn die() {
fail!();
}
// except according to those terms.
use std::comm::*;
+use std::task;
struct test {
f: int,
// Test that a class with only sendable fields can be sent
+use std::comm;
+
struct foo {
i: int,
j: char,
// xfail-fast
+use std::task;
+
pub fn main() { test05(); }
struct Pair<A,B> { a: A, b: B }
// except according to those terms.
use std::cell::Cell;
+use std::task;
pub fn main() { test05(); }
// pp-exact
-pub fn main() { io::println("Hello World"); }
+pub fn main() { println("Hello World"); }
// option. This file may not be copied, modified, or distributed
// except according to those terms.
+use std::task;
fn x(s: ~str, n: int) {
debug!(s);
*/
use std::comm::*;
+use std::task;
type ctx = Chan<int>;
// option. This file may not be copied, modified, or distributed
// except according to those terms.
-
extern mod extra;
+use std::task;
pub fn main() {
task::spawn(|| child(10) );
// option. This file may not be copied, modified, or distributed
// except according to those terms.
+use std::task;
+
pub fn main() { task::spawn(|| child((10, 20, 30, 40, 50, 60, 70, 80, 90)) ); }
fn child(args: (int, int, int, int, int, int, int, int, int)) {
// Issue #2040
+use std::ptr;
+
pub fn main() {
let foo = 1;
assert_eq!(ptr::to_unsafe_ptr(&foo), ptr::to_unsafe_ptr(&foo));
// xfail-fast
extern mod extra;
-use std::io::WriterUtil;
+
use extra::tempfile;
+use std::io::WriterUtil;
+use std::io;
+use std::os;
+use std::uint;
pub fn main() {
let dir = tempfile::mkdtemp(&Path("."), "").unwrap();
// xfail-fast
+use std::uint;
+use std::vec;
+
pub trait plus {
fn plus(&self) -> int;
}
// xfail-fast
+use std::at_vec;
+use std::uint;
+use std::vec;
+
// A trait for objects that can be used to do an if-then-else
// (No actual need for this to be static, but it is a simple test.)
trait bool_like {
// aux-build:static-methods-crate.rs
extern mod static_methods_crate;
+
use static_methods_crate::read;
pub fn main() {
extern mod extra;
+use std::str;
+
pub fn main() {
// Make sure we properly handle repeated self-appends.
let mut a: ~str = ~"A";
// option. This file may not be copied, modified, or distributed
// except according to those terms.
+use std::str;
+
struct S { f0: ~str, f1: int }
pub fn main() {
// option. This file may not be copied, modified, or distributed
// except according to those terms.
+use std::str;
+
struct S { f0: ~str, f1: ~str }
pub fn main() {
pub fn main() {
let a = Foo { x: 1, y: 2 };
match a {
- Foo { x: x, y: y } => io::println(fmt!("yes, %d, %d", x, y))
+ Foo { x: x, y: y } => println(fmt!("yes, %d, %d", x, y))
}
}
enum foo { large, small, }
-impl cmp::Eq for foo {
+impl Eq for foo {
fn eq(&self, other: &foo) -> bool {
((*self) as uint) == ((*other) as uint)
}
// option. This file may not be copied, modified, or distributed
// except according to those terms.
+use std::libc;
+
pub fn main() {
let f = 1 as *libc::FILE;
debug!(f as int);
// except according to those terms.
use std::util;
+use std::vec;
pub fn main() {
let mut a: ~[int] = ~[0, 1, 2, 3, 4, 5, 6];
// Issue #5041 - avoid overlapping memcpy when src and dest of a swap are the same
+use std::ptr;
use std::util;
pub fn main() {
pub fn main() {
let act = fmt!("%?", red);
- io::println(act);
+ println(act);
assert_eq!(~"red", act);
assert_eq!(~"green", fmt!("%?", green));
assert_eq!(~"white", fmt!("%?", white));
orange = 8 >> 1
}
-impl cmp::Eq for color {
+impl Eq for color {
fn eq(&self, other: &color) -> bool {
((*self) as uint) == ((*other) as uint)
}
// option. This file may not be copied, modified, or distributed
// except according to those terms.
-
-
-
// -*- rust -*-
+
enum colour { red(int, int), green, }
-impl cmp::Eq for colour {
+impl Eq for colour {
fn eq(&self, other: &colour) -> bool {
match *self {
red(a0, b0) => {
use std::comm::Chan;
use std::comm::Port;
+use std::comm;
+use std::task;
pub fn main() { test05(); }
// option. This file may not be copied, modified, or distributed
// except according to those terms.
+use std::task;
+
pub fn main() { test00(); }
fn start() { debug!("Started / Finished task."); }
extern mod extra;
+use std::comm;
+use std::task;
+
fn start(c: &comm::Chan<comm::Chan<~str>>) {
let (p, ch) = comm::stream();
c.send(ch);
extern mod extra;
+use std::comm;
+use std::task;
+
fn start(c: &comm::Chan<comm::Chan<int>>) {
let (p, ch) = comm::stream();
c.send(ch);
extern mod extra;
+use std::task;
+
pub fn main() { test00(); }
fn start(task_number: int) { debug!("Started / Finished task."); }
extern mod extra;
+use std::comm;
+use std::task;
+
fn start(c: &comm::Chan<int>, start: int, number_of_messages: int) {
let mut i: int = 0;
while i < number_of_messages { c.send(start + i); i += 1; }
// xfail-fast
+use std::comm;
+use std::task;
+
pub fn main() {
let po = comm::PortSet::new();
extern mod extra;
+use std::comm;
+use std::task;
+
fn start(c: &comm::Chan<int>, i0: int) {
let mut i = i0;
while i > 0 {
// option. This file may not be copied, modified, or distributed
// except according to those terms.
+use std::comm;
+use std::cmp;
// Tests of ports and channels on various types
fn test_rec() {
extern mod extra;
+use std::task;
+
fn f() {
}
// xfail-fast
extern mod extra;
+
use std::comm::Chan;
+use std::comm;
+use std::task;
pub fn main() { debug!("===== WITHOUT THREADS ====="); test00(); }
// option. This file may not be copied, modified, or distributed
// except according to those terms.
+use std::comm;
+
pub fn main() { test00(); }
fn test00() {
extern mod extra;
+use std::comm;
+
pub fn main() { test00(); }
fn test00() {
// except according to those terms.
use std::comm::Chan;
+use std::comm;
pub fn main() { test00(); }
extern mod extra;
+use std::comm;
+use std::task;
+
pub fn main() { test00(); }
fn test00_start(c: &comm::Chan<int>, start: int, number_of_messages: int) {
extern mod extra;
+use std::comm;
+use std::task;
+
pub fn main() { test00(); }
fn test00_start(c: &comm::Chan<int>, number_of_messages: int) {
extern mod extra;
+use std::comm;
+
// rustboot can't transmit nils across channels because they don't have
// any size, but rustc currently can because they do have size. Whether
// or not this is desirable I don't know, but here's a regression test.
use std::cell::Cell;
use std::comm::*;
+use std::ptr;
+use std::task;
struct notify {
ch: Chan<bool>, v: @mut bool,
// task will kill the supervising task, waking it up. The supervising task no
// longer needs to be wakened when the supervised task exits.
+use std::task;
+
fn supervised() {
// Yield to make sure the supervisor joins before we fail. This is
// currently not needed because the supervisor runs first, but I can
// except according to those terms.
extern mod extra;
+
+use std::task;
+
pub fn main() {
task::spawn(|| child(~"Hello") );
}
// except according to those terms.
use std::comm::*;
+use std::ptr;
+use std::task;
pub fn main() {
let (p, ch) = stream::<uint>();
extern mod extra;
+use std::task;
+
fn test_break() { loop { let x: @int = break; } }
fn test_cont() { let mut i = 0; while i < 1 { i += 1; let x: @int = loop; } }
extern mod extra;
+use std::vec;
+
#[test]
#[ignore(cfg(ignorecfg))]
fn shouldignore() {
// option. This file may not be copied, modified, or distributed
// except according to those terms.
-
extern mod extra;
+use std::task;
+
pub fn main() {
let mut i = 10;
while i > 0 { task::spawn({let i = i; || child(i)}); i = i - 1; }
// xfail-fast
+use std::int;
+
trait to_str {
fn to_str(&self) -> ~str;
}
impl FloatExt for float {}
-fn test_float_ext<T:FloatExt>(n: T) { io::println(fmt!("%?", n < n)) }
+fn test_float_ext<T:FloatExt>(n: T) { println(fmt!("%?", n < n)) }
pub fn main() {
test_float_ext(1f32);
impl NumExt for f32 {}
fn num_eq_one<T:NumExt>(n: T) {
- io::println(fmt!("%?", n == NumCast::from(1)))
+ println(fmt!("%?", n == NumCast::from(1)))
}
pub fn main() {
// Test for issue #4183: use of Self in supertraits.
+use std::f32;
+use std::f64;
+
pub static FUZZY_EPSILON: float = 0.1;
pub trait FuzzyEq<Eps> {
assert!(compare::<f64>(6.19));
assert!(!compare::<f64>(7.28318530717958647692528676655900576));
assert!(!compare::<f64>(6.18));
-}
\ No newline at end of file
+}
impl Foo<S> for S {
fn f(&self, x: &S) {
- io::println(x.x.to_str());
+ println(x.x.to_str());
}
}
impl Foo for A {
fn f(&self) -> int {
- io::println(~"Today's number is " + self.x.to_str());
+ println(~"Today's number is " + self.x.to_str());
return self.x;
}
}
// except according to those terms.
mod base {
+ use std::io;
+
pub trait HasNew<T> {
fn new() -> T;
}
impl ::base::HasNew<Foo> for Foo {
fn new() -> Foo {
- unsafe { io::println("Foo"); }
+ unsafe { println("Foo"); }
Foo { dummy: () }
}
}
This is about the simplest program that can successfully send a
message.
*/
+
+use std::comm;
+
pub fn main() {
let (po, ch) = comm::stream();
ch.send(42);
pub fn main() {
let x = Foo(1, 2);
- io::println(fmt!("%?", x));
+ println(fmt!("%?", x));
}
pub fn main() {
let x = Foo(1, 2);
let Foo(y, z) = x;
- io::println(fmt!("%d %d", y, z));
+ println(fmt!("%d %d", y, z));
assert_eq!(y, 1);
assert_eq!(z, 2);
}
Foo(a, b) => {
assert_eq!(a, 1);
assert_eq!(b, 2);
- io::println(fmt!("%d %d", a, b));
+ println(fmt!("%d %d", a, b));
}
}
}
// option. This file may not be copied, modified, or distributed
// except according to those terms.
+use std::unstable;
+
pub fn main() {
- let mut x: bool = false;
- // this line breaks it
- unstable::intrinsics::move_val_init(&mut x, false);
+ unsafe {
+ let mut x: bool = false;
+ // this line breaks it
+ unstable::intrinsics::move_val_init(&mut x, false);
+ }
}
// in that type gets resolved.
extern mod extra;
+use std::cast;
+
fn null<T>() -> *T {
unsafe {
cast::transmute(0)
// option. This file may not be copied, modified, or distributed
// except according to those terms.
+use std::ptr;
+
enum maybe_pointy {
none,
p(@mut Pointy),
// option. This file may not be copied, modified, or distributed
// except according to those terms.
+use std::sys;
+
pub fn main() {
unsafe {
let i = ~@1;
// except according to those terms.
use std::comm::*;
+use std::task;
+use std::uint;
fn child(c: &SharedChan<~uint>, i: uint) {
c.send(~i);
pub fn main() {
let x: Foo = Foo;
match x {
- Foo => { io::println("hi"); }
+ Foo => { println("hi"); }
}
}
// xfail-win32
extern mod extra;
+use std::task;
+
fn f() {
let a = @0;
fail!();
extern mod extra;
use std::comm::*;
+use std::task;
struct complainer {
c: SharedChan<bool>,
// xfail-win32
extern mod extra;
+use std::task;
+
struct complainer {
c: @int,
}
// xfail-win32
extern mod extra;
+use std::task;
+
fn f() {
let a = ~0;
fail!();
// option. This file may not be copied, modified, or distributed
// except according to those terms.
+use std::str;
+
pub fn main() {
let yen: char = '¥'; // 0xa5
let c_cedilla: char = 'ç'; // 0xe7
extern mod extra;
+use std::str;
+use std::vec;
+
pub fn main() {
// Chars of 1, 2, 3, and 4 bytes
let chs: ~[char] = ~['e', 'é', '€', 0x10000 as char];
// option. This file may not be copied, modified, or distributed
// except according to those terms.
+use std::float;
+
pub fn main() {
let ε = 0.00001;
let Π = 3.14;
// except according to those terms.
// -*- rust -*-
+
+use std::io;
+use std::vec;
+
fn main(){
let mut t1 = ~[];
t1.push('a');
pub fn main() {
let x: [int, ..4] = [1, 2, 3, 4];
- io::println(fmt!("%d", x[0]));
+ println(fmt!("%d", x[0]));
}
[1, ..ref tail] => &tail[0],
_ => ::std::util::unreachable()
};
- io::println(fmt!("%d", *el));
+ println(fmt!("%d", *el));
}
}
// option. This file may not be copied, modified, or distributed
// except according to those terms.
+use std::vec;
+
pub fn main() {
let v = ~[1,2,3,4,5];
let v2 = vec::slice(v, 1, 3);
// except according to those terms.
+use std::unstable;
-
-// -*- rust -*-
struct Point {x: int, y: int, z: int}
fn f(p: &mut Point) { p.z = 13; }
pub fn main() {
- let mut x: Point = Point {x: 10, y: 11, z: 12};
- f(&mut x);
- assert_eq!(x.z, 13);
+ unsafe {
+ let x = Some(unstable::sync::exclusive(true));
+ match x {
+ Some(ref z) if z.with(|b| *b) => {
+ do z.with |b| { assert!(*b); }
+ },
+ _ => fail!()
+ }
+ }
}
// option. This file may not be copied, modified, or distributed
// except according to those terms.
+use std::task;
+
pub fn main() {
let mut result = None;
let mut builder = task::task();
// option. This file may not be copied, modified, or distributed
// except according to those terms.
+use std::task;
+
pub fn main() {
let mut result = None;
let mut builder = task::task();
// option. This file may not be copied, modified, or distributed
// except according to those terms.
+use std::task;
+
pub fn main() {
let mut i: int = 0;
while i < 100 { i = i + 1; error!(i); task::yield(); }
// In this case, the code should compile and should
// succeed at runtime
+use std::vec;
+
fn enum_chars(start: u8, end: u8) -> ~[char] {
assert!(start < end);
let mut i = start;