]> git.lizzy.rs Git - rust.git/log
rust.git
10 years agoauto merge of #8357 : omasanori/rust/cleanup, r=alexcrichton
bors [Fri, 9 Aug 2013 07:17:06 +0000 (00:17 -0700)]
auto merge of #8357 : omasanori/rust/cleanup, r=alexcrichton

I feel it's time to eliminate them (and add some testcases.)

10 years agoRemove redundant Ord method impls.
OGINO Masanori [Thu, 8 Aug 2013 01:03:34 +0000 (10:03 +0900)]
Remove redundant Ord method impls.

Basically, generic containers should not use the default methods since a
type of elements may not guarantees total order. str could use them
since u8's Ord guarantees total order. Floating point numbers are also
broken with the default methods because of NaN. Thanks for @thestinger.

Timespec also guarantees total order AIUI. I'm unsure whether
extra::semver::Identifier does so I left it alone. Proof needed.

Signed-off-by: OGINO Masanori <masanori.ogino@gmail.com>
10 years agoauto merge of #8350 : dim-an/rust/fix-struct-match, r=pcwalton
bors [Fri, 9 Aug 2013 04:41:05 +0000 (21:41 -0700)]
auto merge of #8350 : dim-an/rust/fix-struct-match, r=pcwalton

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.

10 years agoauto merge of #8336 : stepancheg/rust/socket-addr-from-str, r=brson
bors [Fri, 9 Aug 2013 02:08:02 +0000 (19:08 -0700)]
auto merge of #8336 : stepancheg/rust/socket-addr-from-str, r=brson

FromStr implemented from scratch.

It is overengineered a bit, however.

Old implementation handles errors by fail!()-ing. And it has bugs, like it accepts `127.0.0.1::127.0.0.1` as IPv6 address, and does not handle all ipv4-in-ipv6 schemes. So I decided to implement parser from scratch.

10 years agoauto merge of #8356 : toddaaro/rust/ws, r=brson
bors [Thu, 8 Aug 2013 23:32:02 +0000 (16:32 -0700)]
auto merge of #8356 : toddaaro/rust/ws, r=brson

This pull request converts the scheduler from a naive shared queue scheduler to a naive workstealing scheduler. The deque is still a queue inside a lock, but there is still a substantial performance gain. Fiddling with the messaging benchmark I got a ~10x speedup and observed massively reduced memory usage.

There are still *many* locations for optimization, but based on my experience so far it is a clear performance win as it is now.

10 years agoauto merge of #8385 : cmr/rust/big-rollup, r=alexcrichton
bors [Thu, 8 Aug 2013 21:32:02 +0000 (14:32 -0700)]
auto merge of #8385 : cmr/rust/big-rollup, r=alexcrichton

This is a fairly large rollup, but I've tested everything locally, and none of
it should be platform-specific.

r=alexcrichton (bdfdbdd)
r=brson (d803c18)
r=alexcrichton (a5041d0)
r=bstrie (317412a)
r=alexcrichton (135c85e)
r=thestinger (8805baa)
r=pcwalton (0661178)
r=cmr (9397fe0)
r=cmr (caa4135)
r=cmr (6a21d93)
r=cmr (4dc3379)
r=cmr (0aa5154)
r=cmr (18be261)
r=thestinger (f10be03)

10 years agoEnabled workstealing in the scheduler. Previously we had one global work queue shared...
toddaaro [Mon, 5 Aug 2013 20:06:24 +0000 (13:06 -0700)]
Enabled workstealing in the scheduler. Previously we had one global work queue shared by each scheduler. Now there is a separate work queue for each scheduler, and work is "stolen" from other queues when it is exhausted locally.

10 years agoFix more priv fallout
Corey Richardson [Thu, 8 Aug 2013 21:02:03 +0000 (17:02 -0400)]
Fix more priv fallout

10 years agoxfail-fast an aux test
Corey Richardson [Thu, 8 Aug 2013 19:34:59 +0000 (15:34 -0400)]
xfail-fast an aux test

10 years agoauto merge of #8245 : alexcrichton/rust/fmt2, r=graydon
bors [Thu, 8 Aug 2013 07:22:52 +0000 (00:22 -0700)]
auto merge of #8245 : alexcrichton/rust/fmt2, r=graydon

This is a reopening of #8182, although this removes any abuse of the compiler internals. Now it's just a pure syntax extension (hard coded what the attribute names are).

10 years agoFix fallout
Corey Richardson [Thu, 8 Aug 2013 03:20:06 +0000 (23:20 -0400)]
Fix fallout

10 years ago(cleanup) Improve rtabort message for atomic-sleep.
Ben Blum [Tue, 6 Aug 2013 00:14:20 +0000 (20:14 -0400)]
(cleanup) Improve rtabort message for atomic-sleep.

10 years agofix recv_ready for Port to take &self and not need to return a tuple. Close #8192.
Ben Blum [Mon, 5 Aug 2013 23:58:10 +0000 (19:58 -0400)]
fix recv_ready for Port to take &self and not need to return a tuple. Close #8192.

10 years agoextra: Remove all each_* methods in treemap
blake2-ppc [Tue, 6 Aug 2013 20:53:51 +0000 (22:53 +0200)]
extra: Remove all each_* methods in treemap

.each_key(), .each_value() and the other methods are replaced by .iter()
and .rev_iter(), and restrictions of those iterators.

10 years agoextra: Implement .rev_iter() in treemap
blake2-ppc [Tue, 6 Aug 2013 19:57:46 +0000 (21:57 +0200)]
extra: Implement .rev_iter() in treemap

Implement reverse iterators for TreeMap and TreeSet, that produce the
keys in backward order.

10 years agoextra: External iterators for TreeSet set operations
blake2-ppc [Tue, 6 Aug 2013 18:17:06 +0000 (20:17 +0200)]
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.

10 years agoextra: Simplify Eq/Ord in treemap
blake2-ppc [Tue, 6 Aug 2013 15:27:39 +0000 (17:27 +0200)]
extra: Simplify Eq/Ord in treemap

Write the Eq and Ord impls for TreeMap in a more straightforward way
using iterator::Zip

10 years agoGedit/gtksourceview language spec: add 'in' keyword
Simon Sapin [Tue, 6 Aug 2013 19:31:35 +0000 (20:31 +0100)]
Gedit/gtksourceview language spec: add 'in' keyword

10 years agostd: add missing #[inline] annotation to the f64 arithmetic trait impls.
Huon Wilson [Tue, 6 Aug 2013 12:19:33 +0000 (22:19 +1000)]
std: add missing #[inline] annotation to the f64 arithmetic trait impls.

10 years agomisc help message fix
Do Nhat Minh [Tue, 6 Aug 2013 03:04:58 +0000 (11:04 +0800)]
misc help message fix

10 years agoAdd some documentation about globals in ffi docs
Alex Crichton [Tue, 6 Aug 2013 02:16:29 +0000 (19:16 -0700)]
Add some documentation about globals in ffi docs

10 years agoAdd weak_rng to get a random algo that puts more emphasis on speed than security
Jordi Boggiano [Tue, 6 Aug 2013 20:14:32 +0000 (22:14 +0200)]
Add weak_rng to get a random algo that puts more emphasis on speed than security

10 years agoDocument rand module with more emphasis on cryptographic security
Jordi Boggiano [Tue, 6 Aug 2013 20:13:26 +0000 (22:13 +0200)]
Document rand module with more emphasis on cryptographic security

10 years agoChange const to static
Sangeun Kim [Wed, 7 Aug 2013 07:47:21 +0000 (16:47 +0900)]
Change const to static

10 years agoChange Freeze to Static
Sangeun Kim [Wed, 7 Aug 2013 07:44:42 +0000 (16:44 +0900)]
Change Freeze to Static

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 agoAdd initial support for a new formatting syntax
Alex Crichton [Mon, 29 Jul 2013 08:12:41 +0000 (01:12 -0700)]
Add initial support for a new formatting syntax

The new macro is available under the name ifmt! (only an intermediate name)

10 years agoauto merge of #8358 : brson/rust/newrt, r=brson
bors [Wed, 7 Aug 2013 23:47:15 +0000 (16:47 -0700)]
auto merge of #8358 : brson/rust/newrt, r=brson

10 years agoTurn on the new runtime
Brian Anderson [Mon, 5 Aug 2013 07:47:04 +0000 (00:47 -0700)]
Turn on the new runtime

10 years agorusti: Disable tests
Brian Anderson [Wed, 7 Aug 2013 04:20:03 +0000 (21:20 -0700)]
rusti: Disable tests

Segfaulted on one of the bots. Maybe out of stack?

10 years agoDisable linked failure tests
Brian Anderson [Tue, 6 Aug 2013 21:32:30 +0000 (14:32 -0700)]
Disable linked failure tests

The implementation currently contains a race that leads to segfaults.

10 years agodoc: Fix deadlocks in tutorial due to yield bustage
Brian Anderson [Tue, 6 Aug 2013 20:25:09 +0000 (13:25 -0700)]
doc: Fix deadlocks in tutorial due to yield bustage

10 years agoxfail debug-info/option-like-enum
Brian Anderson [Tue, 6 Aug 2013 05:39:48 +0000 (22:39 -0700)]
xfail debug-info/option-like-enum

Don't understand why this broke.

10 years agotest: Fix deadlock in task-perf-linked-failure
Brian Anderson [Tue, 6 Aug 2013 04:15:02 +0000 (21:15 -0700)]
test: Fix deadlock in task-perf-linked-failure

10 years agotest: xfail a bunch of tests that are incorrectly reading os::args()[1]
Brian Anderson [Tue, 6 Aug 2013 04:11:25 +0000 (21:11 -0700)]
test: xfail a bunch of tests that are incorrectly reading os::args()[1]

10 years agorustpkg: Disable test_uninstall
Brian Anderson [Tue, 6 Aug 2013 01:15:07 +0000 (18:15 -0700)]
rustpkg: Disable test_uninstall

Seems to not work

10 years agorustc: Use 4MB stacks. Needed for unoptimized builds apparently.
Brian Anderson [Mon, 5 Aug 2013 20:10:34 +0000 (13:10 -0700)]
rustc: Use 4MB stacks. Needed for unoptimized builds apparently.

10 years agostd: Allow spawners to specify stack size
Brian Anderson [Mon, 5 Aug 2013 20:10:08 +0000 (13:10 -0700)]
std: Allow spawners to specify stack size

10 years agostd::rt: Pull RUST_MIN_STACK from the environment
Brian Anderson [Mon, 5 Aug 2013 19:43:33 +0000 (12:43 -0700)]
std::rt: Pull RUST_MIN_STACK from the environment

10 years agostd::rt: 2MB stacks again
Brian Anderson [Mon, 5 Aug 2013 19:14:03 +0000 (12:14 -0700)]
std::rt: 2MB stacks again

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 agoFix bug in `match`ing struct patterns
Dmitry Ermolov [Tue, 6 Aug 2013 18:43:57 +0000 (22:43 +0400)]
Fix bug in `match`ing 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.

10 years agoAdded testcases for `match` keyword
Dmitry Ermolov [Tue, 6 Aug 2013 18:37:27 +0000 (22:37 +0400)]
Added testcases for `match` keyword

Added testcases for `match` keyword including test for issue #5625.

10 years agoHide stuff that are not used outside of _match.rs
Dmitry Ermolov [Tue, 6 Aug 2013 07:08:50 +0000 (11:08 +0400)]
Hide stuff that are not used outside of _match.rs

10 years agoBetter documentation for --emit-llvm option.
Dmitry Ermolov [Mon, 5 Aug 2013 22:49:01 +0000 (02:49 +0400)]
Better documentation for --emit-llvm option.

Document possible use with -S option.

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 agoUse FromStr for IpAddr in rt::uv::net
Stepan Koltsov [Tue, 6 Aug 2013 09:35:13 +0000 (13:35 +0400)]
Use FromStr for IpAddr in rt::uv::net

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 agoImplement FromStr for IpAddr and SocketAddr
Stepan Koltsov [Mon, 5 Aug 2013 17:15:55 +0000 (21:15 +0400)]
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

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