]> git.lizzy.rs Git - rust.git/log
rust.git
10 years agoFix unit structs in cross-crate situtations
Alex Crichton [Wed, 7 Aug 2013 18:52:33 +0000 (11:52 -0700)]
Fix unit structs in cross-crate situtations

10 years agoextra: add `internal` to {de,in}flate_bytes_ naming to address nit
darkf [Mon, 5 Aug 2013 13:06:43 +0000 (06:06 -0700)]
extra: add `internal` to {de,in}flate_bytes_ naming to address nit

10 years agoadd extra::flate::deflate_bytes_zlib and a test
darkf [Mon, 5 Aug 2013 05:37:09 +0000 (22:37 -0700)]
add extra::flate::deflate_bytes_zlib and a test

10 years agoadd inflate_bytes_zlib to exra::flate
darkf [Mon, 5 Aug 2013 05:28:53 +0000 (22:28 -0700)]
add inflate_bytes_zlib to exra::flate

10 years agoTurn OptGroups into a main opt and a main and an aliased opts
Jordi Boggiano [Mon, 5 Aug 2013 12:37:54 +0000 (14:37 +0200)]
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

10 years agoAdd missing getopts::groups::optflagmulti function
Jordi Boggiano [Mon, 5 Aug 2013 12:34:58 +0000 (14:34 +0200)]
Add missing getopts::groups::optflagmulti function

10 years agoForbid `priv` where it has no effect
Alex Crichton [Wed, 7 Aug 2013 06:03:31 +0000 (23:03 -0700)]
Forbid `priv` where it has no effect

This is everywhere except struct fields and enum variants.

10 years agoImplement DoubleEndedIterator on Range
Kevin Ballard [Wed, 7 Aug 2013 05:34:22 +0000 (22:34 -0700)]
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().

10 years agorustc: Fix for-range loops that can use iterators
blake2-ppc [Wed, 7 Aug 2013 18:19:15 +0000 (20:19 +0200)]
rustc: Fix for-range loops that can use iterators

Transform range loops that can be regular iterator loops.

10 years agoBugfix .each_edge in middle/graph.rs
blake2-ppc [Wed, 7 Aug 2013 17:29:19 +0000 (19:29 +0200)]
Bugfix .each_edge in middle/graph.rs

Edge iterator used the length of the nodes vector, must be a mistake.

10 years agostd: Fix for-range loops that can use iterators
blake2-ppc [Wed, 7 Aug 2013 14:58:56 +0000 (16:58 +0200)]
std: Fix for-range loops that can use iterators

Fix inappropriate for-range loops to use for-iterator constructs (or
other appropriate solution) instead.

10 years agoextra: Remove all .each methods in smallintmap
blake2-ppc [Wed, 7 Aug 2013 14:59:17 +0000 (16:59 +0200)]
extra: Remove all .each methods in smallintmap

10 years agoauto merge of #8320 : mihneadb/rust/freq_count, r=cmr
bors [Wed, 7 Aug 2013 22:02:19 +0000 (15:02 -0700)]
auto merge of #8320 : mihneadb/rust/freq_count, r=cmr

10 years agoauto merge of #8294 : erickt/rust/map-move, r=bblum
bors [Wed, 7 Aug 2013 20:23:07 +0000 (13:23 -0700)]
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()`.

10 years agoauto merge of #8326 : thestinger/rust/iterator, r=alexcrichton
bors [Wed, 7 Aug 2013 17:32:20 +0000 (10:32 -0700)]
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.

10 years agoAdd frequency count to extra::stat. #8281
Mihnea Dobrescu-Balaur [Wed, 7 Aug 2013 16:46:09 +0000 (09:46 -0700)]
Add frequency count to extra::stat. #8281

10 years agoauto merge of #8373 : alexcrichton/rust/disable-rusti, r=cmr
bors [Wed, 7 Aug 2013 15:53:20 +0000 (08:53 -0700)]
auto merge of #8373 : alexcrichton/rust/disable-rusti, r=cmr

These are causing problems on the linux bots, I'll investigate soon.

10 years agostd: removed option.take_map{,_default}
Erick Tryzelaar [Sun, 4 Aug 2013 23:30:51 +0000 (16:30 -0700)]
std: removed option.take_map{,_default}

10 years agocore: option.map_consume -> option.map_move
Erick Tryzelaar [Sun, 4 Aug 2013 21:59:36 +0000 (14:59 -0700)]
core: option.map_consume -> option.map_move

10 years agoRevert "Re-enable rusti tests"
Alex Crichton [Wed, 7 Aug 2013 15:29:49 +0000 (08:29 -0700)]
Revert "Re-enable rusti tests"

This reverts commit d5de801cc1b4a3147dfd5a29a3d0e129ee0fe783.

10 years agostd: add result.map_move, result.map_err_move
Erick Tryzelaar [Sun, 4 Aug 2013 23:05:25 +0000 (16:05 -0700)]
std: add result.map_move, result.map_err_move

10 years agooption.get -> option.unwrap
Erick Tryzelaar [Sun, 28 Jul 2013 16:31:37 +0000 (09:31 -0700)]
option.get -> option.unwrap

10 years agoauto merge of #8305 : huonw/rust/triage-fixes, r=cmr
bors [Wed, 7 Aug 2013 13:56:19 +0000 (06:56 -0700)]
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.

10 years agotestsuite: add explanation to a Note, and remove duplicated code.
Huon Wilson [Mon, 5 Aug 2013 09:56:59 +0000 (19:56 +1000)]
testsuite: add explanation to a Note, and remove duplicated code.

Fixes #7302.

10 years agotestsuite: remove incorrect section of 2 test cases. (Also, &const is disappearing.)
Huon Wilson [Mon, 5 Aug 2013 09:53:42 +0000 (19:53 +1000)]
testsuite: remove incorrect section of 2 test cases. (Also, &const is disappearing.)

Fixes #7304.

10 years agotestsuite: remove 2 very outdated testcases; functionality is tested by other class...
Huon Wilson [Mon, 5 Aug 2013 09:50:23 +0000 (19:50 +1000)]
testsuite: remove 2 very outdated testcases; functionality is tested by other class-*.rs tests.

Fixes #7305, #7307.

10 years agostd: adjust str::test_add so that the macro expands to all 3 items (#8012).
Huon Wilson [Mon, 5 Aug 2013 09:46:22 +0000 (19:46 +1000)]
std: adjust str::test_add so that the macro expands to all 3 items (#8012).

Closes #3682.

10 years agoauto merge of #8323 : kballard/rust/saturating, r=thestinger
bors [Wed, 7 Aug 2013 11:02:16 +0000 (04:02 -0700)]
auto merge of #8323 : kballard/rust/saturating, r=thestinger

Implement saturating math in `std::num::Saturating` and use it for `Iterator` impls

10 years agoauto merge of #8285 : huonw/rust/deriving+++, r=alexcrichton
bors [Wed, 7 Aug 2013 07:56:18 +0000 (00:56 -0700)]
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.)

10 years agoAdd test for short-circuiting #[deriving(Eq,Ord,TotalEq,TotalOrd)].
Huon Wilson [Mon, 5 Aug 2013 09:09:15 +0000 (19:09 +1000)]
Add test for short-circuiting #[deriving(Eq,Ord,TotalEq,TotalOrd)].

10 years agoauto merge of #8287 : sfackler/rust/hex, r=alexcrichton
bors [Wed, 7 Aug 2013 04:05:11 +0000 (21:05 -0700)]
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.

10 years agovec: use `offset_inbounds` for iterators
Daniel Micay [Tue, 6 Aug 2013 22:05:43 +0000 (18:05 -0400)]
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
}
~~~

10 years agoadd an intrinsic for inbounds GEP
Daniel Micay [Tue, 6 Aug 2013 21:44:40 +0000 (17:44 -0400)]
add an intrinsic for inbounds GEP

10 years agovec: avoid `ptrtoint`/`inttoptr` in the iterators
Daniel Micay [Tue, 6 Aug 2013 21:15:43 +0000 (17:15 -0400)]
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.

10 years agoremove `extra::iter`
Daniel Micay [Tue, 6 Aug 2013 03:43:06 +0000 (23:43 -0400)]
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.

10 years agoauto merge of #8231 : SimonSapin/rust/ascii-upper-lower-case, r=cmr
bors [Tue, 6 Aug 2013 22:32:05 +0000 (15:32 -0700)]
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.

10 years agoiterator: rename `Counter::new` to `count`
Daniel Micay [Tue, 6 Aug 2013 00:02:26 +0000 (20:02 -0400)]
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

10 years agoadd Extendable to the prelude
Daniel Micay [Mon, 5 Aug 2013 23:58:56 +0000 (19:58 -0400)]
add Extendable to the prelude

10 years agoiterator: simplify the `take` implementation
Daniel Micay [Mon, 5 Aug 2013 23:23:29 +0000 (19:23 -0400)]
iterator: simplify the `take` implementation

10 years agoAdd to_ascii_upper, to_ascii_lower and eq_ignore_ascii_case in std::ascii
Simon Sapin [Fri, 2 Aug 2013 20:39:57 +0000 (21:39 +0100)]
Add to_ascii_upper, to_ascii_lower and eq_ignore_ascii_case in std::ascii

10 years agoauto merge of #8321 : alexcrichton/rust/enable-rusti, r=cmr
bors [Tue, 6 Aug 2013 19:14:07 +0000 (12:14 -0700)]
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.

10 years agoResult::get -> Result::unwrap
Steven Fackler [Tue, 6 Aug 2013 17:42:06 +0000 (10:42 -0700)]
Result::get -> Result::unwrap

10 years agoauto merge of #8317 : bblum/rust/fast-spawn-unlinked, r=brson
bors [Tue, 6 Aug 2013 17:32:00 +0000 (10:32 -0700)]
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();
    }
}
```

10 years agoRemoved convenience encoding trait impls
Steven Fackler [Mon, 5 Aug 2013 05:25:15 +0000 (01:25 -0400)]
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.

10 years agoRemoving space for NULL terminator
Steven Fackler [Mon, 5 Aug 2013 04:08:13 +0000 (00:08 -0400)]
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.

10 years agoToBase64 and ToHex perf improvements
Steven Fackler [Mon, 5 Aug 2013 03:51:26 +0000 (23:51 -0400)]
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
```

10 years agoSome minor hex changes
Steven Fackler [Sun, 4 Aug 2013 20:09:04 +0000 (16:09 -0400)]
Some minor hex changes

10 years agoAdded hexadecimal encoding module
Steven Fackler [Sun, 4 Aug 2013 18:42:39 +0000 (14:42 -0400)]
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.

10 years agoauto merge of #8313 : msullivan/rust/cleanup, r=catamorphism
bors [Tue, 6 Aug 2013 15:44:05 +0000 (08:44 -0700)]
auto merge of #8313 : msullivan/rust/cleanup, r=catamorphism

10 years agoauto merge of #8312 : alexcrichton/rust/use-treemap, r=erickt
bors [Tue, 6 Aug 2013 14:05:05 +0000 (07:05 -0700)]
auto merge of #8312 : alexcrichton/rust/use-treemap, r=erickt

Closes #4430

10 years agoauto merge of #8308 : blake2-ppc/rust/str-slice-bytes, r=alexcrichton
bors [Tue, 6 Aug 2013 12:26:01 +0000 (05:26 -0700)]
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.

10 years agoauto merge of #8054 : sammykim/rust/move-EnumSet, r=alexcrichton
bors [Tue, 6 Aug 2013 09:26:06 +0000 (02:26 -0700)]
auto merge of #8054 : sammykim/rust/move-EnumSet, r=alexcrichton

Fix #8004

10 years agoUpdate Iterator impls to use Saturating
Kevin Ballard [Tue, 6 Aug 2013 03:04:52 +0000 (20:04 -0700)]
Update Iterator impls to use Saturating

Replace hand-rolled saturation math with calls to Saturating.

Fix one impl that didn't use saturating math.

10 years agoAdd std::num::Saturating
Kevin Ballard [Tue, 6 Aug 2013 02:28:20 +0000 (19:28 -0700)]
Add std::num::Saturating

Saturating is an implementation of saturating math operations (at the
moment just add and sub) for integral types.

10 years agoMove EnumSet into libextra
Sangeun Kim [Fri, 26 Jul 2013 04:53:29 +0000 (13:53 +0900)]
Move EnumSet into libextra

10 years agoauto merge of #8265 : blake2-ppc/rust/std-iter, r=thestinger
bors [Tue, 6 Aug 2013 05:38:15 +0000 (22:38 -0700)]
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.

10 years agoauto merge of #8278 : cmr/rust/workaround, r=brson
bors [Tue, 6 Aug 2013 03:07:59 +0000 (20:07 -0700)]
auto merge of #8278 : cmr/rust/workaround, r=brson

10 years agostd: Fix bug in ChunkIter::idx
blake2-ppc [Sun, 4 Aug 2013 20:46:26 +0000 (22:46 +0200)]
std: Fix bug in ChunkIter::idx

ChunkIter .idx() didn't handle overflow correctly, even though it tried.

10 years agostd: Remove uint::iterate, replaced by `range`
blake2-ppc [Sun, 4 Aug 2013 15:10:09 +0000 (17:10 +0200)]
std: Remove uint::iterate, replaced by `range`

10 years agoextra: Simplify the bitv iterators using Repeat
blake2-ppc [Sun, 4 Aug 2013 02:49:44 +0000 (04:49 +0200)]
extra: Simplify the bitv iterators using Repeat

10 years agostd: Improve the documentation for iterator::Invert
blake2-ppc [Sat, 3 Aug 2013 19:34:00 +0000 (21:34 +0200)]
std: Improve the documentation for iterator::Invert

10 years agostd: Use method name Option::consume
blake2-ppc [Sat, 3 Aug 2013 19:34:00 +0000 (21:34 +0200)]
std: Use method name Option::consume

With Option as the simplest container, `consume` is the way to turn it
into a by-value iterator.

10 years agostd: Rewrite the HashSet set operation iterators
blake2-ppc [Sat, 3 Aug 2013 19:34:00 +0000 (21:34 +0200)]
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.

10 years agostd: Add iterator::Repeat to repeat an element endlessly
blake2-ppc [Sat, 3 Aug 2013 19:34:00 +0000 (21:34 +0200)]
std: Add iterator::Repeat to repeat an element endlessly

10 years agostd: Improve vec::ChunkIter
blake2-ppc [Sat, 3 Aug 2013 17:40:20 +0000 (19:40 +0200)]
std: Improve vec::ChunkIter

Implement clone, bidirectionality and random access for this iterator

10 years agostd: Implement RandomAccessIterator for Invert
blake2-ppc [Sat, 3 Aug 2013 17:40:20 +0000 (19:40 +0200)]
std: Implement RandomAccessIterator for Invert

10 years agostd: Remove unused trait bound in Result::map
blake2-ppc [Sat, 3 Aug 2013 17:40:20 +0000 (19:40 +0200)]
std: Remove unused trait bound in Result::map

10 years agostd: Convert Result to use external iterators
blake2-ppc [Sat, 3 Aug 2013 17:40:20 +0000 (19:40 +0200)]
std: Convert Result to use external iterators

convert iter() and iter_err() for Result. Use OptionIterator.

10 years agostd: Add .consume_iter() for Option, to make it reusable
blake2-ppc [Sat, 3 Aug 2013 17:40:20 +0000 (19:40 +0200)]
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.

10 years agoRe-enable rusti tests
Alex Crichton [Mon, 5 Aug 2013 16:25:20 +0000 (09:25 -0700)]
Re-enable rusti tests

10 years agoauto merge of #8288 : Kimundi/rust/opteitres4, r=brson
bors [Mon, 5 Aug 2013 23:47:01 +0000 (16:47 -0700)]
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.

10 years agoLazily initialize 'leaf node' taskgroups for unlinked spawns, for an apparent 11...
Ben Blum [Mon, 5 Aug 2013 20:55:08 +0000 (16:55 -0400)]
Lazily initialize 'leaf node' taskgroups for unlinked spawns, for an apparent 11% speedup.

10 years ago(cleanup) Uncomment an assertion that now holds.
Ben Blum [Fri, 2 Aug 2013 23:35:13 +0000 (19:35 -0400)]
(cleanup) Uncomment an assertion that now holds.

10 years agoauto merge of #8298 : darkf/rust/fix-3948, r=pcwalton
bors [Mon, 5 Aug 2013 20:49:55 +0000 (13:49 -0700)]
auto merge of #8298 : darkf/rust/fix-3948, r=pcwalton

10 years agoUpdated std::Option, std::Either and std::Result
Marvin Löbel [Sat, 3 Aug 2013 23:59:24 +0000 (01:59 +0200)]
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

10 years agoUse TreeMap's ord implementation for Json
Alex Crichton [Mon, 5 Aug 2013 17:37:53 +0000 (10:37 -0700)]
Use TreeMap's ord implementation for Json

Closes #4430

10 years agoImprove debug spew in _match.
Michael Sullivan [Fri, 2 Aug 2013 17:34:33 +0000 (10:34 -0700)]
Improve debug spew in _match.

10 years agoGet rid of some NOTEs.
Michael Sullivan [Tue, 30 Jul 2013 23:47:22 +0000 (16:47 -0700)]
Get rid of some NOTEs.

10 years agoWarn when using -o option on libraries. Closes #6554.
Michael Sullivan [Tue, 30 Jul 2013 22:40:19 +0000 (15:40 -0700)]
Warn when using -o option on libraries. Closes #6554.

10 years agoFix an unused variable warning and clean up some dead code/names.
Michael Sullivan [Mon, 29 Jul 2013 21:19:04 +0000 (14:19 -0700)]
Fix an unused variable warning and clean up some dead code/names.

10 years agoauto merge of #8293 : dim-an/rust/trie-iterator, r=thestinger
bors [Mon, 5 Aug 2013 18:28:56 +0000 (11:28 -0700)]
auto merge of #8293 : dim-an/rust/trie-iterator, r=thestinger

Closes #5506.

10 years agoMake node_id_to_str print more useful info in some cases. Closes #2410.
Michael Sullivan [Mon, 29 Jul 2013 20:44:53 +0000 (13:44 -0700)]
Make node_id_to_str print more useful info in some cases. Closes #2410.

10 years agoauto merge of #8292 : thestinger/rust/fix_loop_warning, r=brson
bors [Mon, 5 Aug 2013 16:49:56 +0000 (09:49 -0700)]
auto merge of #8292 : thestinger/rust/fix_loop_warning, r=brson

10 years agostd: Use correct lifetime parameter on str::raw::slice_bytes
blake2-ppc [Mon, 5 Aug 2013 15:52:03 +0000 (17:52 +0200)]
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.

10 years agoauto merge of #8289 : sfackler/rust/push_byte, r=erickt
bors [Mon, 5 Aug 2013 15:10:55 +0000 (08:10 -0700)]
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.

10 years agoauto merge of #8183 : omasanori/rust/migrate-new, r=sanxiyn
bors [Mon, 5 Aug 2013 13:22:57 +0000 (06:22 -0700)]
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)?

10 years agoauto merge of #8279 : pcwalton/rust/no-main, r=brson
bors [Mon, 5 Aug 2013 11:37:58 +0000 (04:37 -0700)]
auto merge of #8279 : pcwalton/rust/no-main, r=brson

Useful for SDL and possibly Android too.

r? @brson

10 years agoauto merge of #8227 : dim-an/rust/tree-iter, r=thestinger
bors [Mon, 5 Aug 2013 09:52:55 +0000 (02:52 -0700)]
auto merge of #8227 : dim-an/rust/tree-iter, r=thestinger

10 years agoAdd extra::arena::Arena::new{, _with_size}.
OGINO Masanori [Mon, 5 Aug 2013 08:43:40 +0000 (17:43 +0900)]
Add extra::arena::Arena::new{, _with_size}.

Signed-off-by: OGINO Masanori <masanori.ogino@gmail.com>
10 years agoauto merge of #8303 : brson/rust/tls-magic-wtf, r=brson
bors [Mon, 5 Aug 2013 07:56:00 +0000 (00:56 -0700)]
auto merge of #8303 : brson/rust/tls-magic-wtf, r=brson

10 years agostd::rt: Use magic to make TLS work from annihilated boxes. #8302
Brian Anderson [Mon, 5 Aug 2013 07:32:46 +0000 (00:32 -0700)]
std::rt: Use magic to make TLS work from annihilated boxes. #8302

10 years agoauto merge of #8299 : brson/rust/yet-more-newsched-fixes, r=brson
bors [Mon, 5 Aug 2013 06:16:59 +0000 (23:16 -0700)]
auto merge of #8299 : brson/rust/yet-more-newsched-fixes, r=brson

10 years agostd::rt: Schedule more scheduler callbacks to avoid dropping messages
Brian Anderson [Mon, 5 Aug 2013 04:55:52 +0000 (21:55 -0700)]
std::rt: Schedule more scheduler callbacks to avoid dropping messages

10 years agostd: Fix newsched logging truncation
Brian Anderson [Mon, 5 Aug 2013 04:54:59 +0000 (21:54 -0700)]
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.

10 years agoOpen files in binary mode. Closes #3948
darkf [Mon, 5 Aug 2013 04:54:24 +0000 (21:54 -0700)]
Open files in binary mode. Closes #3948

10 years agoauto merge of #8220 : luqmana/rust/arm-linux, r=cmr
bors [Mon, 5 Aug 2013 04:34:54 +0000 (21:34 -0700)]
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.

10 years agoauto merge of #8297 : brson/rust/dlist-dtor, r=brson
bors [Mon, 5 Aug 2013 02:52:57 +0000 (19:52 -0700)]
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

10 years agoextra: Don't recurse in DList drop glue. #8295
Brian Anderson [Mon, 5 Aug 2013 01:38:06 +0000 (18:38 -0700)]
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.

10 years agoauto merge of #8282 : brson/rust/more-newsched-fixes, r=brson
bors [Mon, 5 Aug 2013 01:10:53 +0000 (18:10 -0700)]
auto merge of #8282 : brson/rust/more-newsched-fixes, r=brson

10 years agoAdd support for vanilla linux on arm.
Luqman Aden [Thu, 1 Aug 2013 10:39:37 +0000 (06:39 -0400)]
Add support for vanilla linux on arm.