Commit Graph

20717 Commits

Author SHA1 Message Date
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
blake2-ppc
f8ae526f70 extra: Implement iterator::Extendable 2013-07-30 02:06:49 +02:00
blake2-ppc
f68621326e extra: Implement RandomAccessIterator for RingBuf 2013-07-30 01:48:17 +02:00
blake2-ppc
2f10d1e295 extra: Implement DoubleEnded and RandomAccess iterators for bitv 2013-07-30 01:48:17 +02:00
blake2-ppc
2ff84124f0 std: Remove RandomAccessIterator impl for VecMutIterator
The RandomAccessIterator implementation is not sound for the mutable vec
iterator, and makes it easy to duplicate &mut element pointers.
2013-07-30 01:48:17 +02:00
blake2-ppc
66fccdb295 std: Tests for RandomAccessIterators 2013-07-30 01:48:17 +02:00
blake2-ppc
630627c3d4 std: Implement RandomAccessIterator for iterator adaptors
Implement RAI where possible for iterator adaptors such as Map,
Enumerate, Skip, Take, Zip, Cycle (all of the requiring that the adapted
iterator also implements RAI).
2013-07-30 01:48:17 +02:00
blake2-ppc
5d4af58c1d iterator: implement size_hint() for FlatMap 2013-07-30 01:48:17 +02:00
blake2-ppc
4b2931c90f iterator: implement DoubleEndedIterator for FlatMap 2013-07-30 01:48:17 +02:00
Brendan Zabarauskas
4f65fc7ef2 Improve std::num module description, and fix some formatting 2013-07-30 08:59:43 +10:00
Brendan Zabarauskas
b6ea0538a9 Add some missing method wrappers to std::num 2013-07-30 08:58:46 +10:00
bors
bb996bf92e auto merge of #8090 : blake2-ppc/rust/iterator-adaptor-names, r=pcwalton
Drop the "Iterator" suffix for the the structs in std::iterator.
Filter, Zip, Chain etc. are shorter type names for when iterator
pipelines need their types written out in full in return value types, so
it's easier to read and write. the iterator module already forms enough
namespace.
2013-07-29 15:49:18 -07:00
bors
d34016d109 auto merge of #8109 : blake2-ppc/rust/extern-fn-clone, r=thestinger
Implement Clone and DeepClone for functions with 0 to 8 arguments.  `extern fn()` is implicitly copyable so it's simple, except there is no way to implement it generically over #n function arguments.

Allows deriving of Clone on structs containing `extern "Rust" fn`.
2013-07-29 14:01:24 -07:00
Steve Klabnik
538fbc38c9 Adding an initial description to vec.rs.
Let's explain more of what this module is about, not just 'vectors.'
2013-07-29 16:18:41 -04:00
Ben Blum
7326bc879e Optimize try_recv to not require the two context switches when data is available. 2013-07-29 16:04:16 -04:00
Ben Blum
1137fbd9ab Remove ChanOneHack/PortOneHack extra allocation 2013-07-29 16:04:16 -04:00
Brian Anderson
ceba95ced2 mk: Add NO_BENCH variable for turning off the --bench flag 2013-07-29 12:43:45 -07:00
Brian Anderson
ac2cd14867 mk: Rename CTEST_BENCH to TEST_BENCH
The CTEST prefix is specifically related to the compiletest driver
2013-07-29 12:38:12 -07:00
Brian Anderson
8ae900f51d mk: Fix NO_REBUILD so stdtest can be tested without re-bootstrapping. Closes #8101 2013-07-29 11:22:50 -07:00
bors
2830d7d013 auto merge of #8032 : catamorphism/rust/rustpkg-tags, r=graydon
r? @graydon    Package IDs can now be of the form a/b/c#FOO, where (if a/b/c is
    a git repository) FOO is any tag in the repository. Non-numeric
    tags only match against package IDs with the same tag, and aren't
    compared linearly like numeric versions.
    
 While I was at it, refactored the code that calls `git clone`,  and segregated build output properly for different packages.
2013-07-29 11:04:25 -07:00
blake2-ppc
11aad20cf8 std: Implement Clone and DeepClone for extern "Rust" fn
Implement Clone and DeepClone for functions with 0 to 8 arguments.
2013-07-29 19:43:21 +02:00
bors
fddb35e988 auto merge of #7984 : gifnksm/rust/tutorial-links, r=bstrie 2013-07-29 09:16:22 -07:00
bors
63c9b112b5 auto merge of #8003 : crnobog/rust/case-insensitive-error-prefix, r=cmr
Paths are case insensitive on windows and rustc and compiletest may disagree on casing.
Fixes test compile-fail/circular_modules_main on win32
2013-07-29 07:31:24 -07:00
Michael Woerister
8a329770b6 New naming convention for ast::{node_id, local_crate, crate_node_id, blk_check_mode, ty_field, ty_method} 2013-07-29 16:16:48 +02:00
bors
8413d4769f auto merge of #8085 : mrordinaire/rust/percent-p, r=huonw
pull request for #8011
2013-07-29 05:40:26 -07:00
Do Nhat Minh
79f1052b19 Added %p directive to fmt!, which expects *T as argument 2013-07-29 20:34:01 +08:00
bors
27812ea5e0 auto merge of #8091 : kevinmehall/rust/const-struct-base, r=alexcrichton
With an expression like

    static w : foo = foo { a:5, ..x };

Rust currently gives the error "constant contains unimplemented expression type". This branch implements support for constant structs with `..base`.
2013-07-28 20:34:29 -07:00
blake2-ppc
4b45f47881 std: Rename Iterator adaptor types to drop the -Iterator suffix
Drop the "Iterator" suffix for the the structs in std::iterator.
Filter, Zip, Chain etc. are shorter type names for when iterator
pipelines need their types written out in full in return value types, so
it's easier to read and write. the iterator module already forms enough
namespace.
2013-07-29 04:20:56 +02:00
Kevin Mehall
1493141bfd Add support for ..base on static struct initializers. 2013-07-28 22:07:27 -04:00
bors
52dbe138cf auto merge of #8100 : blake2-ppc/rust/str-collect, r=pcwalton
FromIterator initially only implemented for Iterator<char>, which is the
type of the main iterator.
2013-07-28 18:49:24 -07:00
blake2-ppc
4849a42bf6 std: Implement FromIterator for ~str
FromIterator initially only implemented for Iterator<char>, which is the
type of the main iterator.
2013-07-29 02:40:28 +02:00
bors
4cc3bbb83d auto merge of #8095 : jmgrosen/rust/no-iterator-prefixes, r=pcwalton
Resolves #8093
2013-07-28 15:46:37 -07:00
jmgrosen
a0f0f3012e Refactored vec and str iterators to remove prefixes 2013-07-28 13:37:35 -07:00
bors
6dc5e2c61f auto merge of #8046 : kmcallister/rust/unused-log, r=pcwalton 2013-07-28 12:52:25 -07:00
bors
85b55131be auto merge of #8092 : dotdash/rust/peak_mem, r=alexcrichton
This fixes the recently introduced peak memory usage regression by
freeing the intermediate results as soon as they're not required
anymore instead of keeping them around for the whole compilation
process.

Refs #8077
2013-07-28 11:04:27 -07:00
Björn Steinbrink
075560a9f2 Free intermediate translation results as soon as possible
This fixes the recently introduced peak memory usage regression by
freeing the intermediate results as soon as they're not required
anymore instead of keeping them around for the whole compilation
process.

Refs #8077
2013-07-28 20:02:31 +02:00
bors
293ec2c582 auto merge of #8081 : stepancheg/rust/each_byte, r=huonw
Took a patch by @martine, and fixed a tests: replaced with_str_reader with file_reader, because with_str_reader seems not to reveal the problem.
2013-07-28 06:58:21 -07:00
Stepan Koltsov
b92d1ea723 ReaderUtil::each_byte shouldn't include EOF byte -- Issue #5056 2013-07-28 16:53:00 +04:00
bors
5842ab36b8 auto merge of #8087 : Aatch/rust/atomics, r=huonw
Adds a fence operation to close #8061

Also adds static initializers to for atomic types. Since the fields are private, you aren't able to have `static mut` variables that are an atomic type. Each atomic type's initializer starts at a 0-value (so unset for `AtomicFlag` and false for `AtomicBool`).
2013-07-28 03:55:22 -07:00
bors
fe9929e303 auto merge of #8086 : luqmana/rust/rhelp, r=Aatch
#7617 

While the code that was there should've been perfectly fine (and seemingly is on linux at least) there seems to be some sort of weird interaction going on with statics and vectors. I couldn't get a smaller test case to reproduce that behaviour. The for loop in `rust::usage` seemingly just goes past the end of the vector thus getting garbage which it tries to pass to malloc somewhere down the line.

In any case, using a fixed length vector seems to mitigate this.
2013-07-28 02:07:27 -07:00
Luqman Aden
7bd6a92a5a librust: Stop rust tool from crashing on macos. 2013-07-28 04:52:13 -04:00