Commit Graph

21745 Commits

Author SHA1 Message Date
blake2-ppc
7c369ee733 std/extra: Add ExactSize for Bitv, DList, RingBuf, Option iterators 2013-09-01 18:20:24 +02:00
blake2-ppc
35040dfccc std::iterator: Use ExactSize, inheriting DoubleEndedIterator
Address discussion with acrichto; inherit DoubleEndedIterator so that
`.rposition()` can be a default method, and that the nische of the trait
is clear. Use assertions when using `.size_hint()` in reverse enumerate
and `.rposition()`
2013-09-01 18:17:26 +02:00
blake2-ppc
04845f0aeb std::iterator: Add back .rposition() test 2013-09-01 18:17:19 +02:00
blake2-ppc
43ef5ad184 std::select: Use correct indices from the front
Caught a bug where .enumerate() was used on a reverse iterator. The
indices should be counted from the front here (bblum confirms).
2013-08-30 20:06:26 +02:00
blake2-ppc
46a6dbc541 std::str: Use reverse enumerate and .rposition
Simplify code by using the reversibility of enumerate and use
.rposition().
2013-08-30 20:06:26 +02:00
blake2-ppc
db22f2627d std: Implement .rposition() on double-ended iterators with known size
This is a generalization of the vector .rposition() method, to all
double-ended iterators that have the ExactSizeHint trait.

This resolves the slight asymmetry around `position` and `rposition`

* position from front is `vec.iter().position()`
* position from the back was, `vec.rposition()` is now `vec.iter().rposition()`

Additionally, other indexed sequences (only `extra::ringbuf` I think),
will have the same method available once it implements ExactSizeHint.
2013-08-30 20:06:26 +02:00
blake2-ppc
e7955b2a7d std::iterator: Add tests for .next_back() on Zip and Enumerate 2013-08-30 20:06:26 +02:00
blake2-ppc
ed607dd24a std::iterator: Implement .next_back() for Zip
Let Zip be double-ended when both its children have the ExactSizeHint
trait.
2013-08-30 20:06:26 +02:00
blake2-ppc
4b2cc22031 std::iterator: Introduce trait ExactSizeHint
The trait `ExactSizeHint` is introduced to solve a few small niggles:

* We can't reverse (`.invert()`) an enumeration iterator
* for a vector, we have `v.iter().position(f)` but `v.rposition(f)`.
* We can't reverse `Zip` even if both iterators are from vectors

`ExactSizeHint` is an empty trait that is intended to indicate that an
iterator, for example `VecIterator`, knows its exact finite size and
reports it correctly using `.size_hint()`. Only adaptors that preserve
this at all times, can expose this trait further. (Where here we say
finite for fitting in uint).
2013-08-30 20:03:40 +02:00
bors
0ac3e023d8 auto merge of #8867 : thestinger/rust/smaller-arc, r=alexcrichton 2013-08-30 05:45:45 -07:00
bors
1f9bd62fd6 auto merge of #8857 : blake2-ppc/rust/std-str-remove, r=thestinger
These are very easy to replace with methods on string slices, basically
`.char_len()` and `.len()`.

These are the replacement implementations I did to clean these
functions up, but seeing this I propose removal:

/// ...
pub fn count_chars(s: &str, begin: uint, end: uint) -> uint {
    // .slice() checks the char boundaries
    s.slice(begin, end).char_len()
}

/// Counts the number of bytes taken by the first `n` chars in `s`
/// starting from byte index `begin`.
///
/// Fails if there are less than `n` chars past `begin`
pub fn count_bytes<'b>(s: &'b str, begin: uint, n: uint) -> uint {
    s.slice_from(begin).slice_chars(0, n).len()
}
2013-08-30 04:40:47 -07:00
bors
72bf895629 auto merge of #8854 : huonw/rust/rt-papercuts, r=brson
The only user-facing change is handling non-integer (and zero) `RUST_THREADS` more nicely:

```
$ RUST_THREADS=x rustc # old

You've met with a terrible fate, haven't you?

fatal runtime error: runtime tls key not initialized
Aborted
$ RUST_THREADS=x ./x86_64-unknown-linux-gnu/stage2/bin/rustc # new

You've met with a terrible fate, haven't you?

fatal runtime error: `RUST_THREADS` is `x`, should be a positive integer
Aborted
```

The other changes are converting some `for .. in range(x,y)` to `vec::from_fn` or `for .. in x.iter()` as appropriate; and removing a chain of (seemingly) unnecessary pointer casts.

(Also, fixes a typo in `extra::test` from #8823.)
2013-08-30 03:30:43 -07:00
bors
f10e50a4be auto merge of #8843 : alexcrichton/rust/fix-bug, r=huonw
Whenever a generic function was encountered, only the top-level items were
recursed upon, even though the function could contain items inside blocks or
nested inside of other expressions. This fixes the existing code from traversing
just the top level items to using a Visitor to deeply recurse and find any items
which need to be translated.

This was uncovered when building code with --lib, because the encode_symbol
function would panic once it found that an item hadn't been translated.

Closes #8134
2013-08-30 02:25:47 -07:00
bors
f94844c558 auto merge of #8820 : alexcrichton/rust/no-io-writer, r=brson
At the same time, this updates the TyVisitor to use a mutable self because it's
probably going to be mutating state as it goes along anyway.
2013-08-30 01:20:44 -07:00
bors
974f854bb5 auto merge of #8839 : sanxiyn/rust/env, r=thestinger 2013-08-30 00:15:47 -07:00
bors
ed422b8872 auto merge of #8819 : vadimcn/rust/unit-tests, r=brson
Some of the tests are failing.  I've only managed to fix 'memory_map_file', the rest are up for grabs...

Fixes #5261.
2013-08-29 20:40:47 -07:00
Alex Crichton
2c1d6568f2 Fix a bug with statics inside blocks in generic fns
Whenever a generic function was encountered, only the top-level items were
recursed upon, even though the function could contain items inside blocks or
nested inside of other expressions. This fixes the existing code from traversing
just the top level items to using a Visitor to deeply recurse and find any items
which need to be translated.

This was uncovered when building code with --lib, because the encode_symbol
function would panic once it found that an item hadn't been translated.

Closes #8134
2013-08-29 18:51:29 -07:00
bors
7c6c7519a7 auto merge of #8458 : cmr/rust/test-restructure, r=brson
This should make benchmarks easier to understand. But, it doesn't work.
BENCH_RS in mk/tests.mk has everything, from what I can tell in remake, but
only those that are direct children of src/test/bench get build and run.
@graydon, can you lend your expertise? I can't make heads or tails of this
makefile.
2013-08-29 18:45:47 -07:00
Daniel Micay
05bb4c4e1b reduce the size of UnsafeArc from 2 words to 1 2013-08-29 20:29:02 -04:00
bors
5ef8cdb8fd auto merge of #8866 : brson/rust/rvstdrun, r=alexcrichton
...ing, r=brson"

This reverts commit b8d1fa3994, reversing
changes made to f22b4b1698.

Conflicts:
	mk/rt.mk
	src/libuv

This caused a big performance regression on the windows bots and possibly some unexpected segfaults in pretty-printing tests.
2013-08-29 16:45:49 -07:00
Brian Anderson
3c5a43e5b6 Revert "auto merge of #8645 : alexcrichton/rust/issue-6436-run-non-blocking, r=brson"
This reverts commit b8d1fa3994, reversing
changes made to f22b4b1698.

Conflicts:
	mk/rt.mk
	src/libuv
2013-08-29 14:23:44 -07:00
bors
698873e3a8 auto merge of #8848 : ILyoan/rust/mk_libuv, r=cmr 2013-08-29 13:05:47 -07:00
bors
a6835dd3cb auto merge of #8842 : jfager/rust/remove-iter-module, r=pnkfelix
Moves the Times trait to num while the question of whether it should
exist at all gets hashed out as a completely separate question.
2013-08-29 11:10:47 -07:00
bors
58c3fa92ed auto merge of #8840 : alexcrichton/rust/update-vendors, r=cmr
The LLVM update includes patches from #8488 by @klutzy to build llvm on mingw-64 and also to enable segmented stacks on that platform.

The libuv patch is a rebase on the now-current joyent/master in order to fix #8829
2013-08-29 09:50:48 -07:00
blake2-ppc
b656bfaaa9 std::str: Remove functions count_chars, count_bytes
These are very easy to replace with methods on string slices, basically
`.char_len()` and `.len()`.

These are the replacement implementations I did to clean these
functions up, but seeing this I propose removal:

/// ...
pub fn count_chars(s: &str, begin: uint, end: uint) -> uint {
    // .slice() checks the char boundaries
    s.slice(begin, end).char_len()
}

/// Counts the number of bytes taken by the first `n` chars in `s`
/// starting from byte index `begin`.
///
/// Fails if there are less than `n` chars past `begin`
pub fn count_bytes<'b>(s: &'b str, begin: uint, n: uint) -> uint {
    s.slice_from(begin).slice_chars(0, n).len()
}
2013-08-29 15:51:39 +02:00
bors
2b035d908b auto merge of #8838 : brson/rust/rvfpelim, r=alexcrichton
This reverts commit 2c0f9bd354, reversing
changes made to f8c4f0ea9c.

Conflicts:
	src/rustllvm/RustWrapper.cpp

Fixes #8833
2013-08-29 06:00:48 -07:00
Huon Wilson
4fea236a85 extra: error message should reflact that RUST_TEST_TASKS should be strictly positive (zero is illegal). 2013-08-29 22:58:27 +10:00
Huon Wilson
e835c6b042 rt: remove a series of unfortunate casts. 2013-08-29 22:55:59 +10:00
Huon Wilson
440f1e2dad rt: use sugary functions rather than manual range loops. 2013-08-29 22:55:59 +10:00
Huon Wilson
54e7bdc48e rt: Handle non-integer RUST_THREADS (slightly) more gracefully.
Previously it would call Option.unwrap(), which calls `fail!` on None,
which doesn't work without the runtime (e.g. when initialising it).
2013-08-29 22:55:59 +10:00
bors
33d6572036 auto merge of #8823 : huonw/rust/6233, r=brson
Fixes #7335.
2013-08-29 04:50:43 -07:00
bors
518bd073b4 auto merge of #8830 : andersk/rust/indent-4, r=catamorphism
`default-tab-width` is standardly 8, but most programmers and style guides prefer an indentation width smaller than that.  Rust itself uses 4 space indents.  Most other Emacs modes define the indentation width as 4 or 2 spaces, independently of the width of a Tab character.  Depending on `default-tab-width` makes especially little sense for rust-mode because it sets `indent-tabs-mode` to `nil`.
2013-08-29 03:10:42 -07:00
Ilyong Cho
4cf8671d20 mk: Fix libuv makefile generation on android 2013-08-29 17:44:23 +09:00
Alex Crichton
97f61e7bbe Remove @io::Writer from sys/repr/reflect
At the same time, this updates the TyVisitor to use a mutable self because it's
probably going to be mutating state as it goes along anyway.
2013-08-28 23:00:46 -07:00
Jason Fager
dc30005ad8 Remove the iter module.
Moves the Times trait to num while the question of whether it should
exist at all gets hashed out as a completely separate question.
2013-08-29 01:27:24 -04:00
Alex Crichton
d02496d6d3 Enable segmented stacks for llvm on mingw-64
cc #8488
2013-08-28 20:44:46 -07:00
Alex Crichton
3beb7adf1a Update libuv to rebase on top of joyent/master
Closes #8829
2013-08-28 20:44:46 -07:00
bors
89d04009c1 auto merge of #8800 : fhahn/rust/ticket_5239, r=alexcrichton
I've added a test for the second example mentioned in #5239. The first example does not compile with a reasonable error message. Should I add a compile-fail test for that example as well?

    /rust/src/test/run-pass/issue-5239.rs:15:45: 15:51 error: binary operation + cannot be applied to type `&int`
    rust/src/test/run-pass/issue-5239.rs:15     let _f = |ref x: int| { x += 1};
                                                                                         ^~~~~~

    error: aborting due to previous error
2013-08-28 20:30:36 -07:00
Brian Anderson
3801534d10 Revert "auto merge of #8695 : thestinger/rust/build, r=pcwalton"
This reverts commit 2c0f9bd354, reversing
changes made to f8c4f0ea9c.

Conflicts:
	src/rustllvm/RustWrapper.cpp
2013-08-28 19:59:52 -07:00
Huon Wilson
3f791acf4d Make the unit-test framework check RUST_TEST_TASKS over RUST_THREADS.
Fixes #7335.
2013-08-29 11:17:09 +10:00
bors
26e925a1f0 auto merge of #8832 : alexcrichton/rust/fix-libuv-build, r=pcwalton
It turns out that gyp (libuv's new build system) wants x64 for a 64-bit x86
architecture and ia32 for a 32-bit architecture, so this performs the relevant
mapping and then invokes libuv's configure script with the appropriate target
architecture.

This can be verified by running make with VERBOSE=1 and seeing that beforehand
on a 64-bit build libuv was passed "-arch i386" and now it's passed
"-arch x86_64"

Closes #8826
2013-08-28 17:35:35 -07:00
Alex Crichton
188a9dd210 Fix compilation issues with libuv on OSX
It turns out that gyp (libuv's new build system) wants x64 for a 64-bit x86
architecture and ia32 for a 32-bit architecture, so this performs the relevant
mapping and then invokes libuv's configure script with the appropriate target
architecture.

This can be verified by running make with VERBOSE=1 and seeing that beforehand
on a 64-bit build libuv was passed "-arch i386" and now it's passed
"-arch x86_64"

Closes #8826
2013-08-28 17:32:27 -07:00
bors
7971c46c44 auto merge of #8718 : bblum/rust/typeof, r=pcwalton
r? anybody
2013-08-28 15:30:38 -07:00
Anders Kaseorg
60e84809f0 rust-mode: Default rust-indent-offset to 4, not default-tab-width
default-tab-width is standardly 8, but most programmers and style
guides prefer an indentation width smaller than that.  Rust itself
uses 4 space indents.  Most other Emacs modes define the indentation
width as 4 or 2 spaces, independently of the width of a Tab character.
Depending on default-tab-width makes especially little sense for
rust-mode because it sets indent-tabs-mode to nil.

Signed-off-by: Anders Kaseorg <andersk@mit.edu>
2013-08-28 18:09:02 -04:00
bors
da96b3ec6a auto merge of #8447 : alexcrichton/rust/local-data-merge, r=brson
This moves all local_data stuff into the `local_data` module and only that
module alone. It also removes a fair amount of "super-unsafe" code in favor of
just vanilla code generated by the compiler at the same time.

Closes #8113
2013-08-28 14:15:37 -07:00
bors
9c33ef5a7c auto merge of #8828 : brson/rust/randomness, r=thestinger
The new scheduler is not currently that random.
2013-08-28 12:30:52 -07:00
Brian Anderson
d923f75d79 doc: Remove statement about scheduling randomness
The new scheduler is not currently that random.
2013-08-28 11:23:32 -07:00
bors
64ed3721f7 auto merge of #8807 : alexcrichton/rust/remove-two-offsets, r=thestinger
Everything that we do is actually inbounds, so there's no reason for us to be exposing two of these functions
2013-08-28 11:00:41 -07:00
bors
9708ef03a6 auto merge of #8806 : klutzy/rust/winmain, r=cmr
Fixes #8510.
2013-08-28 07:25:42 -07:00
Seo Sanghyeon
97b542bd84 Android: Pass the environment when running tests 2013-08-28 21:44:55 +09:00