Commit Graph

21157 Commits

Author SHA1 Message Date
Brian Anderson
11fc1fd485 test: Use a test extern in various foreign fn tests 2013-07-30 21:13:55 -07:00
Brian Anderson
91f1ab4896 rt: Use the correct global change_dir lock 2013-07-30 21:06:02 -07:00
bors
38d62feec1 auto merge of #8111 : brson/rust/no-bench, r=graydon 2013-07-30 20:46:18 -07:00
bors
5633a5363b auto merge of #8008 : bblum/rust/select, r=brson
Main logic in ```Implement select() for new runtime pipes.```. The guts of the ```PortOne::try_recv()``` implementation are now split up across several functions, ```optimistic_check```, ```block_on```, and ```recv_ready```.

There is one weird FIXME I left open here, in the "implement select" commit -- an assertion I couldn't get to work in the receive path, on an invariant that for some reason doesn't hold with ```SharedPort```. Still investigating this.
2013-07-30 18:58:17 -07:00
Graydon Hoare
a696f0fecb test: add testcases for external iterators using foreach. 2013-07-30 18:50:28 -07:00
Graydon Hoare
62b6fa0943 rustc: silence unused-var warning. 2013-07-30 18:50:28 -07:00
Graydon Hoare
e5b0f1d132 rustc: fix a pp bug. 2013-07-30 18:50:28 -07:00
Graydon Hoare
c29e9fb60b syntax: implement foreach .. in .. { .. } via desugaring. 2013-07-30 18:50:28 -07:00
Brian Anderson
33df9fc1d0 std: Remove foreign_stack_size spawn option. Irrelevant to future FFI changes 2013-07-30 17:10:23 -07:00
Brian Anderson
8f835d42d7 std: Remove get_task function. Unused 2013-07-30 17:10:21 -07:00
bors
6534b4d4ce auto merge of #8115 : bjz/rust/num-traits, r=brson
Continues #4819
2013-07-30 17:10:19 -07:00
Graydon Hoare
9a2d183d6a syntax: add temporary 'foreach' keyword. 2013-07-30 16:11:49 -07:00
Graydon Hoare
a8840d70a5 syntax: add 'in' keyword 2013-07-30 16:11:49 -07:00
Gareth Smith
de0092c48e No longer treat \ as a path separator on posix systems. 2013-07-30 23:43:39 +01:00
bors
912d806d32 auto merge of #8137 : omasanori/rust/ubool-false, r=bblum
Obvious mistake, but there is no failure because no code uses FALSE.
2013-07-30 15:22:21 -07:00
OGINO Masanori
5ec1d5b69d FALSE is not 1u8 but 0u8, of cource.
Signed-off-by: OGINO Masanori <masanori.ogino@gmail.com>
2013-07-31 07:13:38 +09:00
Brian Anderson
81dda9d9cb std: Remove CurrentScheduler spawn mode. Unused 2013-07-30 14:23:46 -07:00
Brian Anderson
08480e4fda std: Remove ExistingScheduler spawn mode. Unused 2013-07-30 14:23:46 -07:00
Brian Anderson
5d2b8d4372 std: Remove PlatformThread spawn mode. Obsolete 2013-07-30 14:23:45 -07:00
Brian Anderson
85fd75ac47 std: Remove ThreadPerTask spawn mode. Unimplemented 2013-07-30 14:23:45 -07:00
Brian Anderson
cb9ee7f5be std: Remove ManualThreads spawn mode 2013-07-30 14:23:45 -07:00
Brian Anderson
0144c83213 std::rt: Change Thread interface to require an explicit join
Makes it more obvious what's going on
2013-07-30 14:23:44 -07:00
Brian Anderson
7265cc6530 std::rt: Use 2MB stacks
Seems to be around the minimum needed by rustc without split stacks
2013-07-30 14:17:56 -07:00
Dmitry Ermolov
ef7e94550c Fix comment. 2013-07-31 00:08:53 +04:00
Dmitry Ermolov
ed0f014935 Fix opts_str.
opt_val doesn't not fail! for missing options.

Closes #6492
2013-07-30 23:26:52 +04:00
Dmitry Ermolov
0ed8713d79 Modify test to expose issue #6492. 2013-07-30 23:23:19 +04:00
bors
436d9fa45d auto merge of #8133 : blake2-ppc/rust/overlong-utf8, r=cmr
Fix is_utf8 and UTF-8 char width functions to deny non-canonical 'overlong encodings' in UTF-8.

We address the function is_utf8 to make it more strict and correct, but no changes are made to the handling of invalid UTF-8.

Fixes issue #3787
2013-07-30 12:16:20 -07:00
blake2-ppc
8f9014c159 std: Mark the static constants in str.rs as private
static variables are pub by default, which is not reflected in our code
(we need to use priv).
2013-07-30 19:34:54 +02:00
bors
0068bd73e0 auto merge of #8131 : Seldaek/rust/getopt_usage_newline, r=brson
It makes things ugly when the last thing you print is the usage() output, resulting in something like:

```
$ rust run foo.rs -h
Lala

Options:
    -h --help           display this help and exit
    -V --version        output version information and exit

$ prompt
```
2013-07-30 10:28:18 -07:00
Ben Blum
6b75e92afe UnsafeArc methods return unsafe pointers, so are not themselves unsafe. 2013-07-30 13:19:26 -04:00
Ben Blum
fa8102ab4a Unkillable is not unsafe. Close #7832. 2013-07-30 13:19:25 -04:00
Ben Blum
9675cd311a (cleanup) Fix unimplemented message for kill_all in newsched. 2013-07-30 13:19:25 -04:00
Ben Blum
3f6b4c24ec Add a better-for-testing optimistic_check() for pipes with cfg(test). 2013-07-30 13:19:25 -04:00
Ben Blum
cccfa8acc4 Add test cases for select 2013-07-30 13:19:25 -04:00
Ben Blum
f34fadd126 Implement select() for new runtime pipes. 2013-07-30 13:19:25 -04:00
blake2-ppc
aa89325cb0 std: Add from_bytes test for utf-8 using codepoints above 0xffff 2013-07-30 19:16:12 +02:00
blake2-ppc
b4ff95599a std: Deny overlong encodings in UTF-8
An 'overlong encoding' is a codepoint encoded non-minimally using the
utf-8 format. Denying these enforce each codepoint to have only one
valid representation in utf-8.

An example is byte sequence 0xE0 0x80 0x80 which could be interpreted as
U+0, but it's an overlong encoding since the canonical form is just
0x00.

Another example is 0xE0 0x80 0xAF which was previously accepted and is
an overlong encoding of the solidus "/". Directory traversal characters
like / and . form the most compelling argument for why this commit is
security critical.

Factor out common UTF-8 decoding expressions as macros. This commit will
partly duplicate UTF-8 decoding, so it is now present in both
fn is_utf8() and .char_range_at(); the latter using an assumption of
a valid str.
2013-07-30 19:16:12 +02:00
Jordi Boggiano
f7ebab4403 Do not enforce two newlines after the options 2013-07-30 18:40:01 +02:00
blake2-ppc
6dd185930d std: Disallow bytes 0xC0, 0xC1 (192, 193) in utf-8
Bytes 0xC0, 0xC1 can only be used to start 2-byte codepoint encodings,
that are 'overlong encodings' of codepoints below 128.

The reference given in a comment -- https://tools.ietf.org/html/rfc3629
-- does in fact already exclude these bytes, so no additional comment
should be needed in the code.
2013-07-30 17:25:29 +02:00
bors
576f395ddf auto merge of #8121 : thestinger/rust/offset, r=alexcrichton
Closes #8118, #7136

~~~rust
extern mod extra;

use std::vec;
use std::ptr;

fn bench_from_elem(b: &mut extra::test::BenchHarness) {
    do b.iter {
        let v: ~[u8] = vec::from_elem(1024, 0u8);
    }
}

fn bench_set_memory(b: &mut extra::test::BenchHarness) {
    do b.iter {
        let mut v: ~[u8] = vec::with_capacity(1024);
        unsafe {
            let vp = vec::raw::to_mut_ptr(v);
            ptr::set_memory(vp, 0, 1024);
            vec::raw::set_len(&mut v, 1024);
        }
    }
}

fn bench_vec_repeat(b: &mut extra::test::BenchHarness) {
    do b.iter {
        let v: ~[u8] = ~[0u8, ..1024];
    }
}
~~~

Before:

    test bench_from_elem ... bench: 415 ns/iter (+/- 17)
    test bench_set_memory ... bench: 85 ns/iter (+/- 4)
    test bench_vec_repeat ... bench: 83 ns/iter (+/- 3)

After:

    test bench_from_elem ... bench: 84 ns/iter (+/- 2)
    test bench_set_memory ... bench: 84 ns/iter (+/- 5)
    test bench_vec_repeat ... bench: 84 ns/iter (+/- 3)
2013-07-30 07:01:19 -07:00
bors
7fc8c14c1b auto merge of #8082 : Kimundi/rust/master, r=huonw
Also renamed bytes_iter to byte_iter to match other iterators
2013-07-30 05:13:17 -07:00
Marvin Löbel
e33fca9ffe Added str::char_offset_iter() and str::rev_char_offset_iter()
Renamed bytes_iter to byte_iter to match other iterators
Refactored str Iterators to use DoubleEnded Iterators and typedefs instead of wrapper structs
Reordered the Iterator section
Whitespace fixup
Moved clunky `each_split_within` function to the one place in the tree where it's actually needed
Replaced all block doccomments in str with line doccomments
2013-07-30 12:55:48 +02:00
bors
c124f21af5 auto merge of #8110 : brson/rust/no-rebuild, r=bblum
...oses #8101
2013-07-30 03:25:19 -07:00
bors
d75ab4a5d7 auto merge of #8107 : michaelwoerister/rust/end_of_spanned, r=cmr
Contiunation of naming cleanup in `libsyntax::ast`:
```rust
ast::node_id => ast::NodeId
ast::local_crate => ast::LOCAL_CRATE
ast::crate_node_id => ast::CRATE_NODE_ID
ast::blk_check_mode => ast::BlockCheckMode
ast::ty_field => ast::TypeField
ast::ty_method => ast::TypeMethod
```
Also moved span field directly into `TypeField` struct and cleaned up overlooked `ast::CrateConfig` renamings from last pull request.

Cheers,
Michael
2013-07-30 01:37:17 -07:00
Daniel Micay
ef870d37a5 implement pointer arithmetic with GEP
Closes #8118, #7136

~~~rust
extern mod extra;

use std::vec;
use std::ptr;

fn bench_from_elem(b: &mut extra::test::BenchHarness) {
    do b.iter {
        let v: ~[u8] = vec::from_elem(1024, 0u8);
    }
}

fn bench_set_memory(b: &mut extra::test::BenchHarness) {
    do b.iter {
        let mut v: ~[u8] = vec::with_capacity(1024);
        unsafe {
            let vp = vec::raw::to_mut_ptr(v);
            ptr::set_memory(vp, 0, 1024);
            vec::raw::set_len(&mut v, 1024);
        }
    }
}

fn bench_vec_repeat(b: &mut extra::test::BenchHarness) {
    do b.iter {
        let v: ~[u8] = ~[0u8, ..1024];
    }
}
~~~

Before:

    test bench_from_elem ... bench: 415 ns/iter (+/- 17)
    test bench_set_memory ... bench: 85 ns/iter (+/- 4)
    test bench_vec_repeat ... bench: 83 ns/iter (+/- 3)

After:

    test bench_from_elem ... bench: 84 ns/iter (+/- 2)
    test bench_set_memory ... bench: 84 ns/iter (+/- 5)
    test bench_vec_repeat ... bench: 84 ns/iter (+/- 3)
2013-07-30 02:50:31 -04:00
bors
8695bc74a0 auto merge of #7223 : steveklabnik/rust/vec_initial_docs, r=pcwalton
Let's explain more of what this module is about, not just 'vectors.'
2013-07-29 23:49:23 -07:00
bors
e94e4d51ca auto merge of #8120 : blake2-ppc/rust/iterator-fixes, r=thestinger
Implement RandomAccessIterator (RAI) where possible, for Iterator adaptors such as Map, Enumerate, Peek, Skip, Take, Cycle, where the adapted iterator is already RAI, and for collections where it is relevant (ringbuf and bitv).

After discussion with thestinger, remove the RAI impl for VecMutIterator, we cannot soundly provide mutable access with this trait.

Implement Extendable everywhere FromIterator is already implemented.

Fixes issue #8108.
2013-07-29 19:04:22 -07:00
blake2-ppc
99490ad5ba std: Remove macro in vec that's only used once 2013-07-30 02:52:01 +02:00
blake2-ppc
ae09d95160 extra: Add .rev_iter() for bitv 2013-07-30 02:48:40 +02:00
blake2-ppc
5307d3674e std: Implement Extendable for hashmap, str and trie 2013-07-30 02:32:38 +02:00