Copy first batch of material from libstd to libcore.

This commit is contained in:
Graydon Hoare 2011-12-13 16:25:51 -08:00
parent 32087f5c2a
commit fa9ad984fb
325 changed files with 5579 additions and 720 deletions

View file

@ -2,8 +2,8 @@
// -*- rust -*-
use std;
import std::comm;
import std::task;
import comm;
import task;
fn f(c: comm::_chan<int>) {
type t = {_0: int, _1: int, _2: int};

View file

@ -2,8 +2,8 @@
// Regression test for issue #374
use std;
import std::option;
import std::option::none;
import option;
import option::none;
tag sty { ty_nil; }

View file

@ -1,5 +1,5 @@
use std;
import std::option::*;
import option::*;
fn main() {
let i: int =

View file

@ -1,9 +1,9 @@
use std;
import std::option;
import std::option::t;
import std::option::none;
import std::option::some;
import option;
import option::t;
import option::none;
import option::some;
fn foo<T>(y: option::t<T>) {
let x: int;

View file

@ -1,11 +1,11 @@
// -*- rust -*-
use std;
import std::comm::chan;
import std::comm::port;
import std::comm::send;
import std::comm::recv;
import std::task;
import comm::chan;
import comm::port;
import comm::send;
import comm::recv;
import task;
fn a(c: chan<int>) { send(c, 10); }

View file

@ -1,11 +1,11 @@
// -*- rust -*-
use std;
import std::comm;
import std::comm::send;
import std::comm::chan;
import std::comm::recv;
import std::task;
import comm;
import comm::send;
import comm::chan;
import comm::recv;
import task;
fn a(c: chan<int>) { log "task a0"; log "task a1"; send(c, 10); }

View file

@ -1,11 +1,11 @@
// -*- rust -*-
use std;
import std::comm;
import std::comm::send;
import std::comm::chan;
import std::comm::recv;
import std::task;
import comm;
import comm::send;
import comm::chan;
import comm::recv;
import task;
fn a(c: chan<int>) {
if true {

View file

@ -2,8 +2,8 @@
// xfail-test bots are crashing on this on x86_64
use std;
import std::str;
import std::ctypes::*;
import str;
import ctypes::*;
#[link_name = ""]
native mod libc {
@ -14,7 +14,7 @@ fn main() {
let s = "hello world\n";
let b = str::bytes(s);
let l = str::byte_len(s);
let b8 = unsafe { std::vec::unsafe::to_ptr(b) };
let b8 = unsafe { vec::unsafe::to_ptr(b) };
libc::write(0i32, b8, l);
let a = bind libc::write(0i32, _, _);
a(b8, l);

View file

@ -1,9 +1,9 @@
// Binop corner cases
use std;
import std::unsafe::reinterpret_cast;
import std::task;
import std::comm;
import unsafe::reinterpret_cast;
import task;
import comm;
fn test_nil() {
assert (() == ());

View file

@ -1,9 +1,9 @@
use std;
import std::vec;
import vec;
fn main() {
let v =
std::vec::map2({|i, b| if b { -i } else { i } }, [1, 2, 3, 4, 5],
vec::map2({|i, b| if b { -i } else { i } }, [1, 2, 3, 4, 5],
[true, false, false, true, true]);
log_err v;
assert (v == [-1, 2, 3, -4, -5]);

View file

@ -1,5 +1,5 @@
use std;
import std::str;
import str;
#[abi = "cdecl"]
#[link_name = ""]

View file

@ -1,12 +1,12 @@
// Issue #763
use std;
import std::task;
import std::comm::chan;
import std::comm::send;
import std::comm;
import std::comm::port;
import std::comm::recv;
import task;
import comm::chan;
import comm::send;
import comm;
import comm::port;
import comm::recv;
tag request { quit; close(chan<bool>); }

View file

@ -1,5 +1,5 @@
use std;
import std::option::*;
import option::*;
pure fn p(x: int) -> bool { true }

View file

@ -1,7 +1,7 @@
// Reported as issue #126, child leaks the string.
use std;
import std::task;
import task;
fn child2(&&s: str) { }

View file

@ -1,6 +1,6 @@
// tests that the pred in a claim isn't actually eval'd
use std;
import std::uint::*;
import uint::*;
pure fn fails(a: uint) -> bool { fail; }

View file

@ -1,7 +1,7 @@
//xfail-test
use std;
import std::task;
import task;
fn f(x : @{a:int, b:int}) {
assert (x.a == 10);

View file

@ -1,11 +1,11 @@
// -*- rust -*-
use std;
import std::comm;
import std::comm::chan;
import std::comm::send;
import std::comm::recv;
import std::task;
import comm;
import comm::chan;
import comm::send;
import comm::recv;
import task;
fn main() {
let p = comm::port();

View file

@ -1,6 +1,6 @@
use std;
import std::str::*;
import std::uint::*;
import str::*;
import uint::*;
fn main() {
let a: uint = 1u;

View file

@ -1,6 +1,6 @@
use std;
import std::str::*;
import std::uint::*;
import str::*;
import uint::*;
fn main() {
let a: uint = 1u;

View file

@ -1,6 +1,6 @@
use std;
import std::str::*;
import std::uint::*;
import str::*;
import uint::*;
fn main() {
let a: uint = 4u;

View file

@ -1,6 +1,6 @@
use std;
import std::str::*;
import std::uint::*;
import str::*;
import uint::*;
fn main() {
let a: uint = 1u;

View file

@ -1,10 +1,10 @@
// -*- rust -*-
use std;
import std::comm::port;
import std::comm::chan;
import std::comm::send;
import std::comm::recv;
import comm::port;
import comm::chan;
import comm::send;
import comm::recv;
fn main() {
let po = port();

View file

@ -1,5 +1,5 @@
use std;
import std::float;
import float;
fn main() {
let nan = float::NaN;

View file

@ -4,6 +4,6 @@ use std;
fn main() {
// Bare functions should just be a pointer
assert std::sys::rustrt::size_of::<fn()>() ==
std::sys::rustrt::size_of::<int>();
assert sys::rustrt::size_of::<fn()>() ==
sys::rustrt::size_of::<int>();
}

View file

@ -1,6 +1,6 @@
use std;
import std::str::*;
import std::uint::*;
import str::*;
import uint::*;
fn main() {
let a: uint = 1u;

View file

@ -6,18 +6,18 @@
use std;
import option = std::option::t;
import std::option::some;
import std::option::none;
import std::str;
import std::vec;
import option = option::t;
import option::some;
import option::none;
import str;
import vec;
import std::map;
import std::task;
import std::comm::chan;
import std::comm::port;
import std::comm::send;
import std::comm::recv;
import std::comm;
import task;
import comm::chan;
import comm::port;
import comm::send;
import comm::recv;
import comm;
fn map(filename: str, emit: map_reduce::putter) { emit(filename, "1"); }

View file

@ -1,6 +1,6 @@
use std;
import std::vec::*;
import vec::*;
fn main() {
let v = init_elt(0, 0u);

View file

@ -1,7 +1,7 @@
use std;
fn main() {
import std::vec;
import vec;
import vec::to_mut;
log vec::len(to_mut([1, 2]));
{

View file

@ -5,7 +5,7 @@
// xfail-test
use std;
import std::task::join;
import task::join;
fn loop(n: int) {
let t1: task;

View file

@ -1,5 +1,5 @@
use std;
import std::sys;
import sys;
// The purpose of this test is to check that we can
// successfully (and safely) invoke external, cdecl

View file

@ -2,7 +2,7 @@
// Alignment of interior pointers to dynamic-size types
use std;
import std::ptr::addr_of;
import ptr::addr_of;
type x<T> = {
a: T,

View file

@ -8,7 +8,7 @@
*/
use std;
import std::task;
import task;
#[abi = "cdecl"]
native mod rustrt {

View file

@ -7,13 +7,13 @@
use std;
import std::task;
import std::task::join;
import std::comm;
import std::comm::chan;
import std::comm::send;
import std::comm::port;
import std::comm::recv;
import task;
import task::join;
import comm;
import comm::chan;
import comm::send;
import comm::port;
import comm::recv;
fn grandchild(c: chan<int>) { send(c, 42); }

View file

@ -1,5 +1,5 @@
use std;
import std::option;
import option;
fn f<T>(&o: option::t<T>) {
assert o == option::none;

View file

@ -1,11 +1,11 @@
use std;
import std::vec;
import std::task;
import std::comm;
import std::comm::chan;
import std::comm::port;
import std::comm::recv;
import std::comm::send;
import vec;
import task;
import comm;
import comm::chan;
import comm::port;
import comm::recv;
import comm::send;
tag msg { closed; received([u8]); }

View file

@ -1,6 +1,6 @@
use std;
import std::comm::*;
import std::task::*;
import comm::*;
import task::*;
fn a(&&_args: ()) {
fn doit() {

View file

@ -1,11 +1,11 @@
use std;
import std::task;
import std::comm;
import std::comm::chan;
import std::comm::port;
import std::comm::send;
import std::comm::recv;
import task;
import comm;
import comm::chan;
import comm::port;
import comm::send;
import comm::recv;
fn producer(c: chan<[u8]>) {
send(c,

View file

@ -2,7 +2,7 @@
use std;
import std::task::*;
import task::*;
fn main() {
let other = spawn_joinable((), child);

View file

@ -1,8 +1,8 @@
// -*- rust -*-
use std;
import std::task;
import std::comm::*;
import task;
import comm::*;
fn main() {
let p = port();

View file

@ -1,9 +1,9 @@
// -*- rust -*-
// xfail-win32
use std;
import std::task;
import std::comm::port;
import std::comm::recv;
import task;
import comm::port;
import comm::recv;
fn child(&&_i: ()) { assert (1 == 2); }

View file

@ -1,8 +1,8 @@
// xfail-win32 leaks
use std;
import std::task;
import std::comm;
import std::uint;
import task;
import comm;
import uint;
fn die(&&_i: ()) {
fail;

View file

@ -1,8 +1,8 @@
// -*- rust -*-
use std;
import std::task;
import std::comm;
import task;
import comm;
fn sub(&&args: (comm::chan<int>, int)) {
let (parent, id) = args;

View file

@ -10,6 +10,6 @@ fn main() {
let first: @cell = @{mutable c: @nil()};
let second: @cell = @{mutable c: @link(first)};
first._0 = @link(second);
std::sys.rustrt.gc();
sys.rustrt.gc();
let third: @cell = @{mutable c: @nil()};
}

View file

@ -6,7 +6,7 @@
mod m {
use std;
import std::vec;
import vec;
fn f() -> [int] { vec::init_elt(0, 1u) }
}

View file

@ -4,7 +4,7 @@
// This test will call __morestack with various minimum stack sizes
use std;
import std::task;
import task;
native mod rustrt {
fn set_min_stack(size: uint);

View file

@ -5,7 +5,7 @@
// external symbols as close to the red zone as possible.
use std;
import std::task;
import task;
import std::rand;
native mod rustrt {

View file

@ -1,5 +1,5 @@
use std;
import std::uint;
import uint;
fn test(x: bool, foo: ~{x: int, y: int, z: int}) -> int {
let bar = foo;

View file

@ -1,5 +1,5 @@
use std;
import std::uint;
import uint;
fn test(x: bool, foo: @{x: int, y: int, z: int}) -> int {
let bar = foo;

View file

@ -1,5 +1,5 @@
use std;
import std::uint;
import uint;
fn test(foo: ~{a: int, b: int, c: int}) -> ~{a: int, b: int, c: int} {
let foo = foo;

View file

@ -1,6 +1,6 @@
use std;
import std::uint;
import uint;
fn test(foo: @{a: int, b: int, c: int}) -> @{a: int, b: int, c: int} {
let foo = foo;

View file

@ -10,7 +10,7 @@ fn main() {
grow(v);
grow(v);
grow(v);
let len = std::vec::len::<int>(v);
let len = vec::len::<int>(v);
log len;
assert (len == 3 as uint);
}

View file

@ -1,7 +1,7 @@
use std;
import std::vec;
import std::str;
import vec;
import str;
#[link_name = ""]
#[abi = "cdecl"]

View file

@ -1,6 +1,6 @@
use std;
import std::option::*;
import option::*;
fn baz() -> ! { fail; }

View file

@ -2,9 +2,9 @@
// a bug was causing this to complain about leaked memory on exit
use std;
import std::option;
import std::option::some;
import std::option::none;
import option;
import option::some;
import option::none;
tag t { foo(int, uint); bar(int, option::t<int>); }

View file

@ -1,9 +1,9 @@
// Sanity-check the code examples that appear in the object system
// documentation.
use std;
import std::comm::chan;
import std::comm::send;
import std::comm::port;
import comm::chan;
import comm::send;
import comm::port;
fn main() {

View file

@ -2,8 +2,8 @@
// pattern-bound var is an upvar (when translating
// the for-each body)
use std;
import std::option::*;
import std::uint;
import option::*;
import uint;
fn foo(src: uint) {

View file

@ -3,13 +3,13 @@
// Regression tests for circular_buffer when using a unit
// that has a size that is not a power of two
use std;
import std::option;
import std::uint;
import std::comm;
import std::comm::port;
import std::comm::chan;
import std::comm::send;
import std::comm::recv;
import option;
import uint;
import comm;
import comm::port;
import comm::chan;
import comm::send;
import comm::recv;
// A 12-byte unit to send over the channel
type record = {val1: u32, val2: u32, val3: u32};

View file

@ -1,8 +1,8 @@
// xfail-win32
use std;
import std::task;
import std::comm;
import std::uint;
import task;
import comm;
import uint;
fn die(&&_i: ()) {
fail;

View file

@ -1,7 +1,7 @@
use std;
import std::comm::chan;
import std::comm::send;
import std::comm::port;
import comm::chan;
import comm::send;
import comm::port;
// tests that ctrl's type gets inferred properly
type command<send K, send V> = {key: K, val: V};

View file

@ -5,7 +5,7 @@
use std;
import std::list;
import std::list::list;
import std::option;
import option;
tag opt_span {

View file

@ -1,8 +1,8 @@
// -*- rust -*-
use std;
import std::task::yield;
import std::task;
import task::yield;
import task;
fn x(&&args: (str, int)) {
let (s, n) = args;

View file

@ -1,6 +1,6 @@
use std;
import std::task::join;
import std::task::spawn_joinable;
import task::join;
import task::spawn_joinable;
fn main() { let x = spawn_joinable(10, m::child); join(x); }

View file

@ -6,9 +6,9 @@
use std;
import std::str;
import std::comm;
import std::task;
import str;
import comm;
import task;
type ctx = comm::chan<int>;

View file

@ -2,7 +2,7 @@
use std;
import std::task;
import task;
fn main() { let t = task::spawn_joinable(10, child); task::join(t); }

View file

@ -1,7 +1,7 @@
// -*- rust -*-
use std;
import std::task::spawn;
import task::spawn;
fn main() { spawn((10, 20, 30, 40, 50, 60, 70, 80, 90), child); }

View file

@ -2,7 +2,7 @@
// -*- rust -*-
use std;
import std::str;
import str;
fn test1() {
let s: str = "hello";

View file

@ -2,7 +2,7 @@
// -*- rust -*-
use std;
import std::str;
import str;
fn main() {
let a: str = "this \

View file

@ -1,5 +1,5 @@
use std;
import std::str;
import str;
fn main() {
// Make sure we properly handle repeated self-appends.

View file

@ -1,5 +1,5 @@
use std;
import std::str;
import str;
fn test(actual: str, expected: str) {
log actual;

View file

@ -1,9 +1,9 @@
use std;
import std::comm;
import std::comm::chan;
import std::comm::send;
import std::task;
import comm;
import comm::chan;
import comm::send;
import task;
fn main() { test05(); }

View file

@ -1,7 +1,7 @@
use std;
import std::task::spawn_joinable;
import std::task::join;
import task::spawn_joinable;
import task::join;
fn main() { test00(); }

View file

@ -1,6 +1,6 @@
use std;
import std::task;
import std::comm;
import task;
import comm;
fn start(c: comm::chan<comm::chan<str>>) {
let p = comm::port();

View file

@ -1,6 +1,6 @@
use std;
import std::comm;
import std::task;
import comm;
import task;
fn start(c: comm::chan<comm::chan<int>>) {
let p: comm::port<int> = comm::port();

View file

@ -1,5 +1,5 @@
use std;
import std::task;
import task;
fn main() { test00(); }

View file

@ -1,7 +1,7 @@
use std;
import std::task;
import std::comm;
import std::comm::send;
import task;
import comm;
import comm::send;
fn start(&&args: (comm::chan<int>, int, int)) {
let (c, start, number_of_messages) = args;

View file

@ -1,6 +1,6 @@
use std;
import std::comm;
import std::task;
import comm;
import task;
fn main() {
let po = comm::port::<int>();

View file

@ -1,7 +1,7 @@
// xfail-win32
use std;
import std::comm;
import std::task;
import comm;
import task;
fn start(&&args: (comm::chan<int>, int)) {
let (c, i) = args;

View file

@ -1,11 +1,11 @@
// -*- rust -*-
use std;
import std::comm;
import std::comm::send;
import std::comm::port;
import std::comm::recv;
import std::comm::chan;
import comm;
import comm::send;
import comm::port;
import comm::recv;
import comm::chan;
// Tests of ports and channels on various types
fn test_rec() {

View file

@ -6,7 +6,7 @@
// until such time as we have unique closures.
use std;
import std::task;
import task;
fn f() {
}

View file

@ -1,7 +1,7 @@
// xfail-win32
use std;
import std::task;
import task;
fn main() { log "===== SPAWNING and JOINING THREAD TASKS ====="; test00(); }

View file

@ -1,9 +1,9 @@
use std;
import std::task;
import std::comm;
import std::comm::chan;
import std::comm::send;
import std::comm::recv;
import task;
import comm;
import comm::chan;
import comm::send;
import comm::recv;
fn main() { log "===== WITHOUT THREADS ====="; test00(); }

View file

@ -1,6 +1,6 @@
use std;
import std::comm;
import std::comm::send;
import comm;
import comm::send;
fn main() { test00(); }

View file

@ -1,5 +1,5 @@
use std;
import std::comm;
import comm;
fn main() { test00(); }

View file

@ -1,6 +1,6 @@
use std;
import std::comm;
import std::comm::send;
import comm;
import comm::send;
import comm::chan;
import comm::recv;

View file

@ -1,6 +1,6 @@
use std;
import std::task;
import std::comm;
import task;
import comm;
import comm::chan;
import comm::recv;
import comm::port;

View file

@ -1,6 +1,6 @@
use std;
import std::task;
import std::comm;
import task;
import comm;
fn main() { test00(); }

View file

@ -1,6 +1,6 @@
use std;
import std::task;
import std::comm;
import task;
import comm;
fn main() { test00(); }

View file

@ -1,5 +1,5 @@
use std;
import std::comm;
import comm;
fn main() {
let p = comm::port();

View file

@ -1,5 +1,5 @@
use std;
import std::comm;
import comm;
fn main() {
let p = comm::port();

View file

@ -1,5 +1,5 @@
use std;
import std::comm;
import comm;
fn main() {
let c = {

View file

@ -1,12 +1,12 @@
use std;
import std::int;
import std::comm;
import std::task;
import int;
import comm;
import task;
// We're trying to trigger a race between send and port destruction that
// results in the string not being freed
fn starship(&&ch: std::comm::chan<str>) {
fn starship(&&ch: comm::chan<str>) {
int::range(0, 10) { |_i|
comm::send(ch, "pew pew");
}

View file

@ -1,7 +1,7 @@
// -*- rust -*-
use std;
import std::comm;
import 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

View file

@ -1,12 +1,12 @@
use std;
import std::task;
import std::task::task;
import std::comm;
import std::comm::chan;
import std::comm::port;
import std::comm::send;
import std::comm::recv;
import task;
import task::task;
import comm;
import comm::chan;
import comm::port;
import comm::send;
import comm::recv;
fn main() {
test00();

View file

@ -6,9 +6,9 @@
// xfail-test
use std;
import std::task;
import std::task::join;
import std::comm;
import task;
import task::join;
import comm;
fn child() { }

View file

@ -7,7 +7,7 @@
// the supervised task exits.
use std;
import std::task;
import task;
fn supervised(&&_args: ()) {
// Yield to make sure the supervisor joins before we

View file

@ -1,5 +1,5 @@
use std;
import std::task;
import task;
fn main() { task::spawn("Hello", child); }
fn child(&&s: str) {

View file

@ -5,6 +5,6 @@
use std;
import std::task;
import task;
fn main() { task::pin(); task::unpin(); }

View file

@ -11,14 +11,14 @@ fn test_cont() { let i = 0; while i < 1 { i += 1; let x: @int = cont; } }
fn test_ret() { let x: @int = ret; }
fn test_fail() {
fn f(&&_i: ()) { std::task::unsupervise(); let x: @int = fail; }
std::task::spawn((), f);
fn f(&&_i: ()) { task::unsupervise(); let x: @int = fail; }
task::spawn((), f);
}
fn test_fail_indirect() {
fn f() -> ! { fail; }
fn g(&&_i: ()) { std::task::unsupervise(); let x: @int = f(); }
std::task::spawn((), g);
fn g(&&_i: ()) { task::unsupervise(); let x: @int = f(); }
task::spawn((), g);
}
fn main() {

View file

@ -3,8 +3,8 @@
// xfail-pretty
use std;
import std::option;
import std::vec;
import option;
import vec;
#[test]
#[ignore(cfg(ignorecfg))]

View file

@ -1,7 +1,7 @@
// -*- rust -*-
use std;
import std::task;
import task;
fn main() {
let i = 10;

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