Commit graph

18825 commits

Author SHA1 Message Date
blake2-ppc
52b01c50cb extra: External iterators for TreeSet set operations
Write external iterators for Difference, Sym. Difference, Intersection
and Union set operations.

These iterators are generic insofar that they could work on any ordered
sequence iterators, even though they are type specialized to the
TreeSetIterator in this case.

Looking at the `check` function in the treeset tests, rustc seems
unwilling to compile a function resembling::

    fn check<'a, T: Iterator<&'a int>>(... )

so the tests for these iterators are still running the legacy loop
protocol.
2013-08-07 22:41:14 -04:00
blake2-ppc
4ab05f91f4 extra: Simplify Eq/Ord in treemap
Write the Eq and Ord impls for TreeMap in a more straightforward way
using iterator::Zip
2013-08-07 22:41:14 -04:00
Simon Sapin
240f8f03c9 Gedit/gtksourceview language spec: add 'in' keyword 2013-08-07 22:41:14 -04:00
Huon Wilson
8460dac909 std: add missing #[inline] annotation to the f64 arithmetic trait impls. 2013-08-07 22:41:14 -04:00
Do Nhat Minh
a185343fc4 misc help message fix 2013-08-07 22:41:14 -04:00
Jordi Boggiano
403c52d2ae Add weak_rng to get a random algo that puts more emphasis on speed than security 2013-08-07 22:41:14 -04:00
Jordi Boggiano
3db9dc1dfd Document rand module with more emphasis on cryptographic security 2013-08-07 22:41:13 -04:00
Sangeun Kim
a9b7bec2e7 Change const to static 2013-08-07 22:41:13 -04:00
Sangeun Kim
19d0eb9060 Change Freeze to Static 2013-08-07 22:41:13 -04:00
Alex Crichton
ffd80aa276 Fix unit structs in cross-crate situtations 2013-08-07 22:41:13 -04:00
darkf
cc160a0028 extra: add internal to {de,in}flate_bytes_ naming to address nit 2013-08-07 22:41:13 -04:00
darkf
dd5e8b218f add extra::flate::deflate_bytes_zlib and a test 2013-08-07 22:41:13 -04:00
darkf
9b221f56f1 add inflate_bytes_zlib to exra::flate 2013-08-07 22:41:13 -04:00
Jordi Boggiano
a8f3f038c0 Turn OptGroups into a main opt and a main and an aliased opts
This way opt_present("apple") will match no matter if the user passed -a or --apple
2013-08-07 22:41:13 -04:00
Jordi Boggiano
a7f008bc39 Add missing getopts::groups::optflagmulti function 2013-08-07 22:41:13 -04:00
Alex Crichton
e99eff172a Forbid priv where it has no effect
This is everywhere except struct fields and enum variants.
2013-08-07 22:41:12 -04:00
Kevin Ballard
8964fcc5ac Implement DoubleEndedIterator on Range
Range is now invertable as long as its element type conforms to Integer.

Remove int::range_rev() et al in favor of range().invert().
2013-08-07 22:41:09 -04:00
blake2-ppc
8523f6d643 rustc: Fix for-range loops that can use iterators
Transform range loops that can be regular iterator loops.
2013-08-07 22:39:57 -04:00
blake2-ppc
e7d4a9c7f2 Bugfix .each_edge in middle/graph.rs
Edge iterator used the length of the nodes vector, must be a mistake.
2013-08-07 22:39:57 -04:00
blake2-ppc
40bdbf0f5d std: Fix for-range loops that can use iterators
Fix inappropriate for-range loops to use for-iterator constructs (or
other appropriate solution) instead.
2013-08-07 22:39:57 -04:00
blake2-ppc
026c1ae311 extra: Remove all .each methods in smallintmap 2013-08-07 22:39:57 -04:00
Alex Crichton
ffb670ffcd Add initial support for a new formatting syntax
The new macro is available under the name ifmt! (only an intermediate name)
2013-08-07 19:21:43 -07:00
bors
9db698a81b auto merge of #8358 : brson/rust/newrt, r=brson 2013-08-07 16:47:15 -07:00
Brian Anderson
85aaa44bec Turn on the new runtime 2013-08-07 16:32:20 -07:00
Brian Anderson
52a37b63f4 rusti: Disable tests
Segfaulted on one of the bots. Maybe out of stack?
2013-08-07 16:32:20 -07:00
Brian Anderson
ce95b01014 Disable linked failure tests
The implementation currently contains a race that leads to segfaults.
2013-08-07 16:32:20 -07:00
Brian Anderson
ad8010fdf2 xfail debug-info/option-like-enum
Don't understand why this broke.
2013-08-07 15:40:27 -07:00
Brian Anderson
b240524e5a test: Fix deadlock in task-perf-linked-failure 2013-08-07 15:40:27 -07:00
Brian Anderson
44403f77d1 test: xfail a bunch of tests that are incorrectly reading os::args()[1] 2013-08-07 15:40:27 -07:00
Brian Anderson
84d17445f8 rustpkg: Disable test_uninstall
Seems to not work
2013-08-07 15:40:27 -07:00
Brian Anderson
0929eb4ac8 rustc: Use 4MB stacks. Needed for unoptimized builds apparently. 2013-08-07 15:40:27 -07:00
Brian Anderson
ae1ed4fd78 std: Allow spawners to specify stack size 2013-08-07 15:40:27 -07:00
Brian Anderson
f82da818a7 std::rt: Pull RUST_MIN_STACK from the environment 2013-08-07 15:40:27 -07:00
Brian Anderson
eb6143257d std::rt: 2MB stacks again 2013-08-07 15:40:26 -07:00
bors
a85f9acbfc auto merge of #8320 : mihneadb/rust/freq_count, r=cmr 2013-08-07 15:02:19 -07:00
Erick Tryzelaar
a54476b0aa Merge remote-tracking branch 'remotes/origin/master' into remove-str-trailing-nulls 2013-08-07 14:10:39 -07:00
Erick Tryzelaar
aababbba8e std: fix a bad type cast for in str.to_c_str() 2013-08-07 14:06:50 -07:00
Erick Tryzelaar
72688eaa13 std: Make CString::new unsafe b/c it can mutate a *T ptr 2013-08-07 14:06:50 -07:00
Erick Tryzelaar
d6257b315b std: remove unnecessary test from c_str.drop and use safer transmute 2013-08-07 14:06:50 -07:00
Erick Tryzelaar
e053bff5d0 std: Fix c_str.iter() and add test 2013-08-07 14:06:45 -07:00
bors
98ec79c957 auto merge of #8294 : erickt/rust/map-move, r=bblum
According to #7887, we've decided to use the syntax of `fn map<U>(f: &fn(&T) -> U) -> U`, which passes a reference to the closure, and to `fn map_move<U>(f: &fn(T) -> U) -> U` which moves the value into the closure. This PR adds these `.map_move()` functions to `Option` and `Result`.

In addition, it has these other minor features:
 
* Replaces a couple uses of `option.get()`, `result.get()`, and `result.get_err()` with `option.unwrap()`, `result.unwrap()`, and `result.unwrap_err()`. (See #8268 and #8288 for a more thorough adaptation of this functionality.
* Removes `option.take_map()` and `option.take_map_default()`. These two functions can be easily written as `.take().map_move(...)`.
* Adds a better error message to `result.unwrap()` and `result.unwrap_err()`.
2013-08-07 13:23:07 -07:00
Stepan Koltsov
828bfb2c61 Fix incorrect non-exhaustive matching for fixed length vecs
Code like this is fixed now:

```
fn foo(p: [u8, ..4]) {
    match p {
        [a, b, c, d] => {}
    };
}
```

Invalid constructors are not reported as errors yet:

```
fn foo(p: [u8, ..4]) {
    match p {
        [_, _, _] => {} // this should be error
        [_, _, _, _, _, .._] => {} // and this
        _ => {}
    }
}
```

Issue #8311 is partially fixed by this commit. Fixed-length arrays in
let statement are not yet allowed:

```
let [a, b, c] = [1, 2, 3]; // still fails
```
2013-08-07 22:07:24 +04:00
bors
cdba212e72 auto merge of #8326 : thestinger/rust/iterator, r=alexcrichton
The `extra::iter` module wasn't actually included in `extra.rs` when it was moved from `std`... I assume no one is going to miss it.
2013-08-07 10:32:20 -07:00
Mihnea Dobrescu-Balaur
17c12bbd1b Add frequency count to extra::stat. #8281 2013-08-07 09:46:09 -07:00
bors
29ffbbaaa8 auto merge of #8373 : alexcrichton/rust/disable-rusti, r=cmr
These are causing problems on the linux bots, I'll investigate soon.
2013-08-07 08:53:20 -07:00
Erick Tryzelaar
19e17f54a0 std: removed option.take_map{,_default} 2013-08-07 08:52:09 -07:00
Erick Tryzelaar
1e490813b0 core: option.map_consume -> option.map_move 2013-08-07 08:52:09 -07:00
Alex Crichton
0927d62275 Revert "Re-enable rusti tests"
This reverts commit d5de801cc1.
2013-08-07 08:29:49 -07:00
Erick Tryzelaar
9218aaa00e std: add result.map_move, result.map_err_move 2013-08-07 08:23:55 -07:00
Erick Tryzelaar
5c08237456 option.get -> option.unwrap 2013-08-07 08:16:37 -07:00
bors
597b3fd03f auto merge of #8305 : huonw/rust/triage-fixes, r=cmr
The two deletions are because the test cases are very old (still using `class` and modes!), and, as far as I can tell (since they are so old), the areas they test are well tested by other rpass tests.
2013-08-07 06:56:19 -07:00
Huon Wilson
1ce5effac2 testsuite: add explanation to a Note, and remove duplicated code.
Fixes #7302.
2013-08-07 23:17:52 +10:00
Huon Wilson
e5fb4c4359 testsuite: remove incorrect section of 2 test cases. (Also, &const is disappearing.)
Fixes #7304.
2013-08-07 23:17:52 +10:00
Huon Wilson
1016e8b8f7 testsuite: remove 2 very outdated testcases; functionality is tested by other class-*.rs tests.
Fixes #7305, #7307.
2013-08-07 23:17:52 +10:00
Huon Wilson
c57fde2b5f std: adjust str::test_add so that the macro expands to all 3 items (#8012).
Closes #3682.
2013-08-07 23:17:52 +10:00
Michael Woerister
2c9922aa49 Enable privacy check for enum methods. 2013-08-07 14:30:00 +02:00
bors
54c8c23d05 auto merge of #8323 : kballard/rust/saturating, r=thestinger
Implement saturating math in `std::num::Saturating` and use it for `Iterator` impls
2013-08-07 04:02:16 -07:00
Young-il Choi
b32617666a std: run test fix for ARM android 2013-08-07 19:01:43 +09:00
bors
4da1cfe923 auto merge of #8285 : huonw/rust/deriving+++, r=alexcrichton
Some general clean-up relating to deriving:
- `TotalOrd` was too eager, and evaluated the `.cmp` call for every field, even if it could short-circuit earlier.
- the pointer types didn't have impls for `TotalOrd` or `TotalEq`.
- the Makefiles didn't reach deep enough into libsyntax for dependencies.

(Split out from https://github.com/mozilla/rust/pull/8258.)
2013-08-07 00:56:18 -07:00
Huon Wilson
4f3944a34f Add test for short-circuiting #[deriving(Eq,Ord,TotalEq,TotalOrd)]. 2013-08-07 16:56:50 +10:00
bors
62dbdc4ea2 auto merge of #8287 : sfackler/rust/hex, r=alexcrichton
FromHex ignores whitespace and parses either upper or lower case hex
digits. ToHex outputs lower case hex digits with no whitespace. Unlike
ToBase64, ToHex doesn't allow you to configure the output format. I
don't feel that it's super useful in this case.
2013-08-06 21:05:11 -07:00
Daniel Micay
55f3d04101 vec: use offset_inbounds for iterators
This allows LLVM to optimize vector iterators to an `getelementptr` and
`icmp` pair, instead of `getelementptr` and *two* comparisons.

Code snippet:

~~~
fn foo(xs: &mut [f64]) {
    for x in xs.mut_iter() {
        *x += 10.0;
    }
}
~~~

LLVM IR at stage0:

~~~
; Function Attrs: noinline uwtable
define void @"_ZN3foo17_68e1b25bca131dba7_0$x2e0E"({ i64, %tydesc*, i8*, i8*, i8 }* nocapture, { double*, i64 }* nocapture) #1 {
"function top level":
  %2 = getelementptr inbounds { double*, i64 }* %1, i64 0, i32 0
  %3 = load double** %2, align 8
  %4 = getelementptr inbounds { double*, i64 }* %1, i64 0, i32 1
  %5 = load i64* %4, align 8
  %6 = ptrtoint double* %3 to i64
  %7 = and i64 %5, -8
  %8 = add i64 %7, %6
  %9 = inttoptr i64 %8 to double*
  %10 = icmp eq double* %3, %9
  %11 = icmp eq double* %3, null
  %or.cond6 = or i1 %10, %11
  br i1 %or.cond6, label %match_case, label %match_else

match_else:                                       ; preds = %"function top level", %match_else
  %12 = phi double* [ %13, %match_else ], [ %3, %"function top level" ]
  %13 = getelementptr double* %12, i64 1
  %14 = load double* %12, align 8
  %15 = fadd double %14, 1.000000e+01
  store double %15, double* %12, align 8
  %16 = icmp eq double* %13, %9
  %17 = icmp eq double* %13, null
  %or.cond = or i1 %16, %17
  br i1 %or.cond, label %match_case, label %match_else

match_case:                                       ; preds = %match_else, %"function top level"
  ret void
}
~~~

Optimized LLVM IR at stage1/stage2:

~~~
; Function Attrs: noinline uwtable
define void @"_ZN3foo17_68e1b25bca131dba7_0$x2e0E"({ i64, %tydesc*, i8*, i8*, i8 }* nocapture, { double*, i64 }* nocapture) #1 {
"function top level":
  %2 = getelementptr inbounds { double*, i64 }* %1, i64 0, i32 0
  %3 = load double** %2, align 8
  %4 = getelementptr inbounds { double*, i64 }* %1, i64 0, i32 1
  %5 = load i64* %4, align 8
  %6 = lshr i64 %5, 3
  %7 = getelementptr inbounds double* %3, i64 %6
  %8 = icmp eq i64 %6, 0
  %9 = icmp eq double* %3, null
  %or.cond6 = or i1 %8, %9
  br i1 %or.cond6, label %match_case, label %match_else

match_else:                                       ; preds = %"function top level", %match_else
  %.sroa.0.0.in7 = phi double* [ %10, %match_else ], [ %3, %"function top level" ]
  %10 = getelementptr inbounds double* %.sroa.0.0.in7, i64 1
  %11 = load double* %.sroa.0.0.in7, align 8
  %12 = fadd double %11, 1.000000e+01
  store double %12, double* %.sroa.0.0.in7, align 8
  %13 = icmp eq double* %10, %7
  br i1 %13, label %match_case, label %match_else

match_case:                                       ; preds = %match_else, %"function top level"
  ret void
}
~~~
2013-08-06 23:54:24 -04:00
Daniel Micay
7d115c9420 add an intrinsic for inbounds GEP 2013-08-06 23:41:20 -04:00
Daniel Micay
f23fb19ee5 vec: avoid ptrtoint/inttoptr in the iterators
This results in throwing away alias analysis information, because LLVM
does *not* implement reasoning about these conversions yet.

We specialize zero-size types since a `getelementptr` offset will
return us the same pointer, making it broken as a simple counter.
2013-08-06 23:41:20 -04:00
Daniel Micay
8f9bbc476d remove extra::iter
This module provided adaptors for the old internal iterator protocol,
but they proved to be quite unreadable and are not generic enough to
handle borrowed pointers well.

Since Rust no longer defines an internal iteration protocol, I don't
think there's going to be any reuse via these adaptors.
2013-08-06 23:41:20 -04:00
Alex Crichton
0b47b4ccc9 Fix node hashes 2013-08-06 19:36:49 -07:00
Erick Tryzelaar
5eaa4d1d2f Merge remote-tracking branch 'remotes/origin/master' into remove-str-trailing-nulls 2013-08-06 16:21:02 -07:00
Erick Tryzelaar
5e7b666250 std: update str.push_byte to work without str trailing nulls 2013-08-06 16:19:31 -07:00
Erick Tryzelaar
8567611adf Merge commit 'd89ff7eef969aee6b493bc846b64d68358fafbcd' into remove-str-trailing-nulls 2013-08-06 16:18:58 -07:00
bors
5b4244d917 auto merge of #8231 : SimonSapin/rust/ascii-upper-lower-case, r=cmr
Original pull request: Add str.to_ascii_lower() and str.to_ascii_upper() methods in std::str.
2013-08-06 15:32:05 -07:00
Daniel Micay
40d11a5461 iterator: rename Counter::new to count
to match the convention used by `range`, since `iterator::count` is
already namespaced enough and won't be ambiguous
2013-08-06 18:09:20 -04:00
Daniel Micay
c13f4f398a add Extendable to the prelude 2013-08-06 18:09:20 -04:00
Daniel Micay
b3a317c368 iterator: simplify the take implementation 2013-08-06 18:09:20 -04:00
Dmitry Ermolov
0fadfc5fb7 Fix bug in matching struct patterns
Code that collects fields in struct-like patterns used to ignore
wildcard patterns like `Foo{_}`. But `enter_defaults` considered
struct-like patterns as default in order to overcome this
(accoring to my understanding of situation).

However such behaviour caused code like this:
```
enum E {
    Foo{f: int},
    Bar
}
let e = Bar;
match e {
    Foo{f: _f} => { /* do something (1) */ }
    _ => { /* do something (2) */ }
}
```
consider pattern `Foo{f: _f}` as default. That caused inproper behaviour
and even segfaults while trying to destruct `Bar` as `Foo{f: _f}`.
Issues: #5625 , #5530.

This patch fixes `collect_record_or_struct_fields` to split cases of
single wildcard struct-like pattern and no struct-like pattern at all.
Former case resolved with `enter_rec_or_struct` (and not with
`enter_defaults`).

Closes #5625.
Closes #5530.
2013-08-07 00:04:28 +04:00
Dmitry Ermolov
1710125f67 Added testcases for match keyword
Added testcases for `match` keyword including test for issue #5625.
2013-08-07 00:03:47 +04:00
Dmitry Ermolov
1fa0a8c9db Hide stuff that are not used outside of _match.rs 2013-08-06 23:59:51 +04:00
Dmitry Ermolov
8d3c62af9f Better documentation for --emit-llvm option.
Document possible use with -S option.
2013-08-06 23:55:46 +04:00
Simon Sapin
88b21f592c Add to_ascii_upper, to_ascii_lower and eq_ignore_ascii_case in std::ascii 2013-08-06 20:22:11 +01:00
bors
6972eb4cd7 auto merge of #8321 : alexcrichton/rust/enable-rusti, r=cmr
Now that LLVM has been upgraded, I think that we can try again to re-enable the rusti tests.
2013-08-06 12:14:07 -07:00
Steven Fackler
3b441c485f Result::get -> Result::unwrap 2013-08-06 10:42:06 -07:00
bors
72080954b9 auto merge of #8317 : bblum/rust/fast-spawn-unlinked, r=brson
This lazily initializes the taskgroup structs for ```spawn_unlinked``` tasks. If such a task never spawns another task linked to it (or a descendant of it), its taskgroup is simply never initialized at all. Also if an unlinked task spawns another unlinked task, neither of them will need to initialize their taskgroups. This works for the main task too.

I benchmarked this with the following test case and observed a ~~21% speedup (average over 4 runs: 7.85 sec -> 6.20 sec, 2.5 GHz)~~ 11% speedup, see comment below.
```
use std::task;
use std::cell::Cell;
use std::rt::comm;

static NUM: uint = 1024*256;

fn run(f: ~fn()) {
    let mut t = task::task();
    t.unlinked();
    t.spawn(f);
}

fn main() {
    do NUM.times {
        let (p,c) = comm::oneshot();
        let c = Cell::new(c);
        do run { c.take().send(()); }
        p.recv();
    }
}
```
2013-08-06 10:32:00 -07:00
Steven Fackler
e617651384 Removed convenience encoding trait impls
Encoding should really only be done from [u8]<->str. The extra
convenience implementations don't really have a place, especially since
they're so trivial.

Also improved error messages in FromBase64.
2013-08-06 09:58:36 -07:00
Steven Fackler
858e166119 Removing space for NULL terminator
String NULL terminators are going away soon, so we may as well get rid
of this now so it doesn't rot.
2013-08-06 09:58:36 -07:00
Steven Fackler
ff5fdffc13 ToBase64 and ToHex perf improvements
The overhead of str::push_char is high enough to cripple the performance
of these two functions. I've switched them to build the output in a
~[u8] and then convert to a string later. Since we know exactly the
bytes going into the vector, we can use the unsafe version to avoid the
is_utf8 check.

I could have riced it further with vec::raw::get, but it only added
~10MB/s so I didn't think it was worth it. ToHex is still ~30% slower
than FromHex, which is puzzling.

Before:

```
test base64::test::from_base64 ... bench: 1000 ns/iter (+/- 349) = 204 MB/s
test base64::test::to_base64 ... bench: 2390 ns/iter (+/- 1130) = 63 MB/s
...
test hex::tests::bench_from_hex ... bench: 884 ns/iter (+/- 220) = 341 MB/s
test hex::tests::bench_to_hex ... bench: 2453 ns/iter (+/- 919) = 61 MB/s
```

After:

```
test base64::test::from_base64 ... bench: 1271 ns/iter (+/- 600) = 160 MB/s
test base64::test::to_base64 ... bench: 759 ns/iter (+/- 286) = 198 MB/s
...
test hex::tests::bench_from_hex ... bench: 875 ns/iter (+/- 377) = 345 MB/s
test hex::tests::bench_to_hex ... bench: 593 ns/iter (+/- 240) = 254 MB/s
```
2013-08-06 09:58:36 -07:00
Steven Fackler
463e2416e9 Some minor hex changes 2013-08-06 09:58:36 -07:00
Steven Fackler
2266df51aa Added hexadecimal encoding module
FromHex ignores whitespace and parses either upper or lower case hex
digits. ToHex outputs lower case hex digits with no whitespace. Unlike
ToBase64, ToHex doesn't allow you to configure the output format. I
don't feel that it's super useful in this case.
2013-08-06 09:58:35 -07:00
Stepan Koltsov
58b11229e5 Use FromStr for IpAddr in rt::uv::net 2013-08-06 20:46:58 +04:00
bors
3dfb55ab09 auto merge of #8313 : msullivan/rust/cleanup, r=catamorphism 2013-08-06 08:44:05 -07:00
Stepan Koltsov
95b3689b34 Implement FromStr for IpAddr and SocketAddr
Better than that in rt::uv::net, because it:

* handles invalid input explicitly, without fail!()
* parses socket address, not just IP
* handles various ipv4-in-ipv6 addresses, like 2001:db8:122:344::192.0.2.33
  (see http://tools.ietf.org/html/rfc6052 for example)
* rejects output like `127.0000000.0.1`
* does not allocate heap memory
* have unit tests
2013-08-06 18:16:15 +04:00
bors
ba3d03d3a4 auto merge of #8312 : alexcrichton/rust/use-treemap, r=erickt
Closes #4430
2013-08-06 07:05:05 -07:00
bors
ca6385034c auto merge of #8308 : blake2-ppc/rust/str-slice-bytes, r=alexcrichton
`fn slice_bytes` is marked unsafe since it allows violating the valid
string encoding property; but the function did also allow extending the
lifetime of the slice by mistake, since it's returning `&str`.

Use the annotation `slice_bytes<'a>(&'a str, ...) -> &'a str` so
that all uses of `slice_bytes` are region checked correctly.
2013-08-06 05:26:01 -07:00
bors
8adcba4300 auto merge of #8054 : sammykim/rust/move-EnumSet, r=alexcrichton
Fix #8004
2013-08-06 02:26:06 -07:00
Kevin Ballard
3db3ce22f5 Update Iterator impls to use Saturating
Replace hand-rolled saturation math with calls to Saturating.

Fix one impl that didn't use saturating math.
2013-08-05 22:49:33 -07:00
Kevin Ballard
5f713da4aa Add std::num::Saturating
Saturating is an implementation of saturating math operations (at the
moment just add and sub) for integral types.
2013-08-05 22:49:33 -07:00
Sangeun Kim
a76943be47 Move EnumSet into libextra 2013-08-06 14:45:02 +09:00
bors
f8cf234b34 auto merge of #8265 : blake2-ppc/rust/std-iter, r=thestinger
Fix #8228 by replacing .iter() and .iter_err() in Result by external iterators.

Implement random access for `iterator::Invert` and `vec::ChunkIter` (and bidirectionality).

Implement Repeat iterator.
2013-08-05 22:38:15 -07:00
bors
6f88f4dea5 auto merge of #8278 : cmr/rust/workaround, r=brson 2013-08-05 20:07:59 -07:00
Erick Tryzelaar
fb9b27910b std: c_str should use regions on methods 2013-08-05 19:55:07 -07:00
Erick Tryzelaar
c8e454097b std: fix a typo where .to_c_str wasn't being called on android 2013-08-05 19:54:49 -07:00
blake2-ppc
45085b9f8d std: Fix bug in ChunkIter::idx
ChunkIter .idx() didn't handle overflow correctly, even though it tried.
2013-08-06 04:05:08 +02:00
blake2-ppc
ea9c5c405e std: Remove uint::iterate, replaced by range 2013-08-06 04:05:08 +02:00
blake2-ppc
08d0b70213 extra: Simplify the bitv iterators using Repeat 2013-08-06 04:05:08 +02:00
blake2-ppc
b5cd81d0e5 std: Improve the documentation for iterator::Invert 2013-08-06 04:05:08 +02:00
blake2-ppc
520f292e48 std: Use method name Option::consume
With Option as the simplest container, `consume` is the way to turn it
into a by-value iterator.
2013-08-06 04:05:07 +02:00
blake2-ppc
78effe7626 std: Rewrite the HashSet set operation iterators
Use the Repeat iterator to carry the "explicit closure capture" that was
previously done with the custom EnvFilterIterator.
2013-08-06 04:05:07 +02:00
blake2-ppc
8046218f0f std: Add iterator::Repeat to repeat an element endlessly 2013-08-06 04:05:07 +02:00
blake2-ppc
a05a9a1c02 std: Improve vec::ChunkIter
Implement clone, bidirectionality and random access for this iterator
2013-08-06 04:05:07 +02:00
blake2-ppc
872d15d464 std: Implement RandomAccessIterator for Invert 2013-08-06 04:05:07 +02:00
blake2-ppc
c5e4c55989 std: Remove unused trait bound in Result::map 2013-08-06 04:05:07 +02:00
blake2-ppc
109e0d85a1 std: Convert Result to use external iterators
convert iter() and iter_err() for Result. Use OptionIterator.
2013-08-06 04:02:21 +02:00
blake2-ppc
ce682cb45f std: Add .consume_iter() for Option, to make it reusable
Let Option be a base for a widely useful one- or zero- item iterator.
Refactor OptionIterator to support any generic element type, so the same
iterator impl can be used for both &T, &mut T and T iterators.
2013-08-06 03:59:56 +02:00
Alex Crichton
d5de801cc1 Re-enable rusti tests 2013-08-05 18:55:53 -07:00
bors
bbda3fa938 auto merge of #8288 : Kimundi/rust/opteitres4, r=brson
This is an alternative version to https://github.com/mozilla/rust/pull/8268, where instead of transitioning to `get()` completely, I transitioned to `unwrap()` completely.

My reasoning for also opening this PR is that having two different functions with identical behavior on a common datatype is bad for consistency and confusing for users, and should be solved as soon as possible. The fact that apparently half the code uses `get()`, and the other half `unwrap()` only makes it worse.

If the final naming decision ends up different, there needs to be a big renaming anyway, but until then it should at least be consistent.

---

- Made naming schemes consistent between Option, Result and Either
- Lifted the quality of the either and result module to that of option
- Changed Options Add implementation to work like the maybe Monad (return None if any of the inputs is None)  
  See https://github.com/mozilla/rust/issues/6002, especially my last comment.
- Removed duplicate Option::get and renamed all related functions to use the term `unwrap` instead  
  See also https://github.com/mozilla/rust/issues/7887.

Todo: 

Adding testcases for all function in the three modules. Even without the few functions I added, the coverage wasn't complete to begin with. But I'd rather do that as a follow up PR, I've touched to much code here already, need to go through them again later.
2013-08-05 16:47:01 -07:00
Ben Blum
1f95bd7684 Lazily initialize 'leaf node' taskgroups for unlinked spawns, for an apparent 11% speedup. 2013-08-05 19:30:25 -04:00
Ben Blum
47e82c8555 (cleanup) Uncomment an assertion that now holds. 2013-08-05 18:40:42 -04:00
bors
29099e450a auto merge of #8298 : darkf/rust/fix-3948, r=pcwalton 2013-08-05 13:49:55 -07:00
Marvin Löbel
0ac7a219f0 Updated std::Option, std::Either and std::Result
- Made naming schemes consistent between Option, Result and Either
- Changed Options Add implementation to work like the maybe monad (return None if any of the inputs is None)
- Removed duplicate Option::get and renamed all related functions to use the term `unwrap` instead
2013-08-05 22:42:21 +02:00
Alex Crichton
991648d099 Use TreeMap's ord implementation for Json
Closes #4430
2013-08-05 13:20:48 -07:00
Michael Sullivan
53c6de5684 Improve debug spew in _match. 2013-08-05 12:30:28 -07:00
Michael Sullivan
7dbc5ae79f Get rid of some NOTEs. 2013-08-05 12:30:28 -07:00
Michael Sullivan
fd01031f3a Warn when using -o option on libraries. Closes #6554. 2013-08-05 11:41:06 -07:00
Michael Sullivan
a20081666b Fix an unused variable warning and clean up some dead code/names. 2013-08-05 11:41:06 -07:00
bors
d8b299d179 auto merge of #8293 : dim-an/rust/trie-iterator, r=thestinger
Closes #5506.
2013-08-05 11:28:56 -07:00
Michael Sullivan
bcf62e7901 Make node_id_to_str print more useful info in some cases. Closes #2410. 2013-08-05 10:33:55 -07:00
bors
2d1eb1916e auto merge of #8292 : thestinger/rust/fix_loop_warning, r=brson 2013-08-05 09:49:56 -07:00
blake2-ppc
476dfc24b3 std: Use correct lifetime parameter on str::raw::slice_bytes
fn slice_bytes is marked unsafe since it allows violating the valid
string encoding property; but the function did also allow extending the
lifetime of the slice by mistake, since it's returning `&str`.

Use the annotation `slice_bytes<'a>(&'a str, ...) -> &'a str` so
that all uses of slice_bytes are region checked correctly.
2013-08-05 17:55:06 +02:00
bors
d89ff7eef9 auto merge of #8289 : sfackler/rust/push_byte, r=erickt
It was previously pushing the byte on top of the string's null
terminator. I added a test to make sure it doesn't break in the future.
2013-08-05 08:10:55 -07:00
bors
c2bacd2e80 auto merge of #8183 : omasanori/rust/migrate-new, r=sanxiyn
It seems that relatively new code uses `Foo::new()` instead of `Foo()` so I wrote a patch to migrate some structs to the former style.
Is it a right direction? If there are any guidelines not to use new()-style, could you add them to the [style guide](https://github.com/omasanori/rust/wiki/Note-style-guide)?
2013-08-05 06:22:57 -07:00
bors
dbaca98d78 auto merge of #8279 : pcwalton/rust/no-main, r=brson
Useful for SDL and possibly Android too.

r? @brson
2013-08-05 04:37:58 -07:00
bors
4db061160d auto merge of #8227 : dim-an/rust/tree-iter, r=thestinger 2013-08-05 02:52:55 -07:00
OGINO Masanori
eab97b5558 Add extra::arena::Arena::new{, _with_size}.
Signed-off-by: OGINO Masanori <masanori.ogino@gmail.com>
2013-08-05 17:43:40 +09:00
bors
7b2163d376 auto merge of #8303 : brson/rust/tls-magic-wtf, r=brson 2013-08-05 00:56:00 -07:00
Brian Anderson
1c1add23f6 std::rt: Use magic to make TLS work from annihilated boxes. #8302 2013-08-05 00:36:02 -07:00
bors
4fdd720421 auto merge of #8299 : brson/rust/yet-more-newsched-fixes, r=brson 2013-08-04 23:16:59 -07:00
Brian Anderson
167bdff041 std::rt: Schedule more scheduler callbacks to avoid dropping messages 2013-08-04 21:56:48 -07:00
Brian Anderson
d123df26ff std: Fix newsched logging truncation
The truncation needs to be done in the console logger in order
to catch all the logging output, and because truncation only matters
when outputting to the console.
2013-08-04 21:56:47 -07:00
darkf
180d050138 Open files in binary mode. Closes #3948 2013-08-04 21:54:24 -07:00
bors
83d2a0431c auto merge of #8220 : luqmana/rust/arm-linux, r=cmr
Update the arm linux support some more. We had a previous patch for the RasberryPi. This adds a new target `arm-unknown-linux-gnueabi` for more general arm linux support.

Build/Host machine: x86_64 Debian testing (jessie) with the `gcc-4.4-arm-linux-gnueabi` package

Tested on targets:

- TS-7800 Feroceon (ARMv5TEJ) running Debian 7.0 wheezy
- Beaglebone black (ARMv7) running Angstrom GNU/Linux v2012.12
   - rustc flags:  `--target=arm-unknown-linux-gnueabi --linker=arm-linux-gnueabi-gcc`

- Samsung Galaxy S II (to make sure android still works)
   - rustc flags:  `--target=arm-linux-androideabi --android-cross-path=[path to standalone toolchain]`

Since not all arm devices (i.e. afaik anything older than armv6 like the ts-7800 i tested on) supported getting the tls address via the `mrc` instruction, I made it also try via the magic address the kernel maps into the address space (0xFFFF0FF0). One or the other should work (and on android it seems like both work).

Also fixes a bug where rustc would always try to invoke the android assembler for any kind of arm target.
2013-08-04 21:34:54 -07:00
bors
6c12ca3ac2 auto merge of #8297 : brson/rust/dlist-dtor, r=brson
The compiler-generated dtor for DList recurses deeply to drop Nodes.
For big lists this can overflow the stack.

This is a problem for the new scheduler, where split stacks are not implemented.

Thanks @blake2-ppc
2013-08-04 19:52:57 -07:00
Brian Anderson
4898a0de04 extra: Don't recurse in DList drop glue. #8295
The compiler-generated dtor for DList recurses deeply to drop Nodes.
For big lists this can overflow the stack.
2013-08-04 18:38:06 -07:00
Erick Tryzelaar
986ba9c3c1 std: Update the c_str docs, and support CString not owning the pointer 2013-08-04 18:37:55 -07:00
bors
dc5b0b9410 auto merge of #8282 : brson/rust/more-newsched-fixes, r=brson 2013-08-04 18:10:53 -07:00
Luqman Aden
9c39992021 Add support for vanilla linux on arm. 2013-08-04 19:28:06 -04:00
bors
77bc6c5955 auto merge of #8218 : brson/rust/nogc, r=brson
These are both obsoleted by the forthcoming new GC.
2013-08-04 16:25:54 -07:00
Erick Tryzelaar
3c94b5044c Merge remote-tracking branch 'remotes/origin/master' into str-remove-null 2013-08-04 16:23:41 -07:00
Dmitry Ermolov
28165d5ad8 Remove debug printing. 2013-08-05 02:51:43 +04:00
Erick Tryzelaar
5865a7597b Remove trailing null from strings 2013-08-04 15:45:16 -07:00
Erick Tryzelaar
17e0089856 std: remove use of cast module from os. 2013-08-04 15:45:16 -07:00
Erick Tryzelaar
3629f702e9 std: merge str::raw::from_buf and str::raw::from_c_str 2013-08-04 15:45:16 -07:00
Erick Tryzelaar
bd908d4c0e std and rustc: explicitly pass c strings to c functions
When strings lose their trailing null, this pattern will become dangerous:

let foo = "bar";
let foo_ptr: *u8 = &foo[0];

Instead we should use c_strs to handle this correctly.
2013-08-04 15:45:16 -07:00
Dmitry Ermolov
d49bb43fc1 Implemented iterator for TrieMap
Closes #5506.
2013-08-05 02:29:51 +04:00
Daniel Micay
c327835a44 fix warning still mentioning the again keyword 2013-08-04 18:21:29 -04:00
Brian Anderson
3f4c6cead6 Remove old tests and code for select
Not compatible with newsched
2013-08-04 15:11:56 -07:00
Brian Anderson
2f8346b949 std::rt: Remove the test for context()
This is no longer testable once newsched is turned on
2013-08-04 15:11:56 -07:00
Brian Anderson
a27f339cb4 std::rt: Don't allow schedulers to exit before handling all messages
Every time run_sched_once performs a 'scheduling action' it needs to guarantee
that it runs at least one more time, so enqueue another run_sched_once callback.
The primary reason it needs to do this is because not all async callbacks
are guaranteed to run, it's only guaranteed that *a* callback will run after
enqueing one - some may get dropped.

At the moment this means we wastefully create lots of callbacks to ensure that
there will *definitely* be a callback queued up to continue running the scheduler.
The logic really needs to be tightened up here.
2013-08-04 15:11:56 -07:00
Brian Anderson
f0f7e1b3fc std::rt: 3MB stacks!
rustc needs *even more* megabytes when run without optimizations
2013-08-04 15:11:56 -07:00
Brian Anderson
75734a9cd3 std::rt: Run the tests for Local in a bare thread
Otherwise interferes with the existing runtime
2013-08-04 15:11:56 -07:00
Brian Anderson
835e963dbd std::rt: Improve the error message when the thread-local ptr is null
Also fix some incorrect comments and variable names.
2013-08-04 15:11:55 -07:00
bors
d6f2364076 auto merge of #8260 : omasanori/rust/fix-extra-unicode, r=pcwalton
WIth this patch `RUSTFLAGS='--cfg unicode' make check"` passed successfully.

* Why doesn't `#[link_name="icuuc"]` make libextra to link against libicuuc.so?
* In `extra::unicode::tests`, `use unicode; unicode::is_foo('a')` failed but `use unicode::*; is_foo('a')` succeeded. Is it right?
2013-08-04 14:43:51 -07:00
Erick Tryzelaar
3102b1797e std: replace str::as_c_str with std::c_str 2013-08-04 14:13:17 -07:00
Erick Tryzelaar
0512475fda extra: make sure time::match_digits does not read past the end of the str 2013-08-04 13:32:41 -07:00
Erick Tryzelaar
bb5bf7c3e0 std: remove str::from_bytes_with_null 2013-08-04 13:32:41 -07:00
Erick Tryzelaar
d5110854f7 std: add test for str::as_c_str 2013-08-04 13:32:41 -07:00
Erick Tryzelaar
cd94e9121b std: cleanup os and str tests 2013-08-04 13:32:41 -07:00
Erick Tryzelaar
dca9ff9a13 std: remove str::NullTerminatedStr 2013-08-04 13:32:41 -07:00
Erick Tryzelaar
fd293dfb0f std: rewrite run::with_{argv,envp,dirp} to copy C strings 2013-08-04 13:32:41 -07:00
Erick Tryzelaar
08b6cb46c6 std: add str.to_c_str() 2013-08-04 13:32:40 -07:00
Erick Tryzelaar
6011f83dec std: minor cleanup 2013-08-04 13:32:40 -07:00
Steven Fackler
147c4fd81b Fixed str::raw::push_byte
It was previously pushing the byte on top of the string's null
terminator. I added a test to make sure it doesn't break in the future.
2013-08-04 16:19:40 -04:00
bors
3d14470be4 auto merge of #7115 : alexcrichton/rust/llvm-upgrades, r=thestinger
This is a reopening of #6713

This is still blocked on windows failures. I'll re-push try once the existing crisis has passed.
2013-08-04 12:49:53 -07:00
Daniel Micay
b49d026ecd Merge pull request #8284 from huonw/emacs-in-kw
etc: add the `in` keyword to the emacs mode.
2013-08-04 12:49:11 -07:00
Alex Crichton
60e9507086 Integrate new arm patch and fix an LLVM bug
Thanks @luqama!
2013-08-04 10:58:23 -07:00
Alex Crichton
bb93930575 Add a workaround for 8199 for now 2013-08-04 10:58:23 -07:00
Alex Crichton
4ace3b7434 Fix setting the fixed stack segment attribute on LLVM functions
At the same time create a more robust wrapper to try to prevent this type of
issue from cropping up in the future.
2013-08-04 10:58:23 -07:00
Alex Crichton
8d29367650 Fix build issues once LLVM has been upgraded
* LLVM now has a C interface to LLVMBuildAtomicRMW
* The exception handling support for the JIT seems to have been dropped
* Various interfaces have been added or headers have changed
2013-08-04 10:58:23 -07:00
Alex Crichton
1d06aaae64 Update LLVM 2013-08-04 10:58:22 -07:00
bors
8495ee52b2 auto merge of #8262 : dotdash/rust/no_rval_copies, r=pcwalton
rvalues aren't going to be used anywhere but as the argument, so
there's no point in copying them. LLVM used to eliminate the copy
later, but why bother emitting it in the first place?
2013-08-04 10:55:53 -07:00
bors
22f9ce4df6 auto merge of #8243 : stepancheg/rust/ipv, r=brson
multicast functions now take IpAddr (without port), because they dont't
need port.

Uv* types renamed:
* UvIpAddr -> UvSocketAddr
* UvIpv4 -> UvIpv4SocketAddr
* UvIpv6 -> UvIpv6SocketAddr

"Socket address" is a common name for (ip-address, port) pair (e.g. in
sockaddr_in struct).

P. S. Are there any backward compatibility concerns? What is std::rt module, is it a part of public API?
2013-08-04 08:49:55 -07:00
bors
f7c4359a2c auto merge of #8237 : blake2-ppc/rust/faster-utf8, r=brson
Use unchecked vec indexing since the vector bounds are checked by the
loop. Iterators are not easy to use in this case since we skip 1-4 bytes
each lap. This part of the commit speeds up is_utf8 for ASCII input.

Check codepoint ranges by checking the byte ranges manually instead of
computing a full decoding for multibyte encodings. This is easy to read
and corresponds to the UTF-8 syntax in the RFC.

No changes to what we accept. A comment notes that surrogate halves are
accepted.

Before:

	test str::bench::is_utf8_100_ascii ... bench: 165 ns/iter (+/- 3)
	test str::bench::is_utf8_100_multibyte ... bench: 218 ns/iter (+/- 5)

After:
	test str::bench::is_utf8_100_ascii ... bench: 130 ns/iter (+/- 1)
	test str::bench::is_utf8_100_multibyte ... bench: 156 ns/iter (+/- 3)

An improvement upon the previous pull #8133
2013-08-04 07:10:56 -07:00
bors
5cf69d5bf8 auto merge of #8254 : brson/rust/libuv-mac-supp, r=pcwalton
I suspect that this is a race between process exit and the termination of
worker threads used by libuv (if I sleep before exit it doesn't leak). This
isn't going to cause any real problems but should probably be fixed at
some point.

r? @pcwalton

cc #8253
2013-08-04 05:28:57 -07:00
bors
91b711883c auto merge of #8217 : brson/rust/reset_stack_limit, r=pcwalton
In some scenarios upcall_rust_stack_limit fails to record the stack
limit, leaving it 0, and allowing subsequent Rust code to run into
the red zone.
2013-08-04 03:34:56 -07:00
Huon Wilson
88620c25f5 std: implement Total{Ord,Eq} for pointers. 2013-08-04 19:46:52 +10:00
Huon Wilson
8407ec9fed syntax: make #[deriving(TotalOrd)] lazy.
Previously it would call:

  f(sf1.cmp(&of1), f(sf2.cmp(&of2), ...))

(where s/of1 = 'self/other field 1', and f was
std::cmp::lexical_ordering)

This meant that every .cmp subcall got evaluated when calling a derived
TotalOrd.cmp.

This corrects this to use

   let test = sf1.cmp(&of1);
   if test == Equal {
      let test = sf2.cmp(&of2);
      if test == Equal {
        // ...
      } else {
        test
      }
   } else {
     test
   }

This gives a lexical ordering by short-circuiting on the first comparison
that is not Equal.
2013-08-04 19:46:52 +10:00
Dmitry Ermolov
73ec9f36e4 Implemented TreeMap::{lower_bound_iter,upper_bound_iter}
(issue #4604)
2013-08-04 13:14:13 +04:00
Dmitry Ermolov
98a66568ce Remove redundant print. 2013-08-04 13:14:13 +04:00
Dmitry Ermolov
d8e74b3dcb Additional check in treemap iterator test. 2013-08-04 13:14:13 +04:00
Brian Anderson
044fa35bf8 rt: Fix a corner-case in unwinding that leads to stack overflow
In some scenarios upcall_rust_stack_limit fails to record the stack
limit, leaving it 0, and allowing subsequent Rust code to run into
the red zone.
2013-08-03 23:40:25 -07:00
Brian Anderson
ea84c1fd69 std: Remove gc and stackwalk
These are both obsoleted by the forthcoming new GC.
2013-08-03 23:39:04 -07:00
bors
fbeeeebf47 auto merge of #8264 : thestinger/rust/snapshot, r=Aatch 2013-08-03 23:25:55 -07:00
bors
93432a2c2f auto merge of #8269 : brson/rust/fix-task-cleanup, r=brson
...y/catch

And before collect_failure. These are both running user dtors and need to be handled
in the task try/catch block and before the final task cleanup code.
2013-08-03 21:46:56 -07:00
Daniel Micay
e7bb33aed8 rm obsolete for support from the compiler 2013-08-04 00:39:48 -04:00
Patrick Walton
9c08db58ab librustc: Implement #[no_main], which omits the entry point entirely.
Useful for SDL and possibly Android too.
2013-08-03 20:01:00 -07:00
Daniel Micay
1008945528 remove obsolete foreach keyword
this has been replaced by `for`
2013-08-03 22:48:02 -04:00
Corey Richardson
118158729e Work around #8256, do not fail the task, just return None 2013-08-03 22:36:48 -04:00
Daniel Micay
9f74217d80 register snapshots 2013-08-03 21:09:28 -04:00
Daniel Micay
8ce953347c Merge pull request #8251 from chris-morgan/vim-sigil-highlighting
Highlight sigils and operators in Vim.

r=huonw, known spurious failure on one bot
2013-08-03 18:02:04 -07:00
Brian Anderson
3c9e393354 std::rt: Run local storage cleanup and the box annihilator inside the try/catch
And before collect_failure. These are both running user dtors and need to be handled
in the task try/catch block and before the final task cleanup code.
2013-08-03 14:43:16 -07:00
bors
18e3db7392 auto merge of #8246 : stepancheg/rust/contains-key, r=thestinger
Map::contains_key can be implemented with Map::find.

Remove several implementations of contains_key.
2013-08-03 13:40:49 -07:00
bors
b5d77d20ec auto merge of #8223 : davidhalperin/rust/master, r=Aatch
Closes #7907

This is my first pull request so let me know if I've done anything wrong.  I tried to pick off a nice easy one.
2013-08-03 11:52:50 -07:00
bors
800dbffa69 auto merge of #8219 : sstewartgallus/rust/fix_dynamic_lib, r=graydon
A test case was also created for this situation to prevent the problem
occuring again.

A similar problem was also fixed for the symbol method.

There was some minor code cleanup.

I am unsatisfied with using /dev/null as an invalid dynamic library. It is not cross platform.
2013-08-03 10:04:58 -07:00