Commit Graph

21199 Commits

Author SHA1 Message Date
Andreas Martens
c4b4cb36c8 Fix segfault when calling tuple struct constructor as extern fn
Fixes #5315
2013-08-17 22:42:31 +02:00
bors
7503396070 auto merge of #8441 : erickt/rust/deny-warnings, r=erickt
This patch makes sure that code is warning-free for all of the rust libraries.
2013-08-17 10:12:04 -07:00
Erick Tryzelaar
cc567085c0 Deny warnings in stage1+ libsyntax/librustc/librustdoc/librusti/librust 2013-08-17 08:42:39 -07:00
Erick Tryzelaar
ad5c676853 Fix warnings it tests 2013-08-17 08:42:35 -07:00
Erick Tryzelaar
e20d46056d Fix warnings in librustc and libsyntax 2013-08-17 08:41:42 -07:00
Erick Tryzelaar
be86bc81a7 Fix warnings in tests 2013-08-17 08:41:35 -07:00
bors
29a67d1dc2 auto merge of #8272 : DaGenix/rust/digest-md5-impl-not-unrolled, r=cmr
An MD5 implementation was originally included in #8097, but, since there are a couple different implementations of that digest algorithm (@alco mentioned his implementation on the mailing list just before I opened that PR), it was suggested that I remove it from that PR and open up a new PR to discuss the different implementations and the best way forward. If anyone wants to discuss a different implementation, feel free to present it here and discuss and compare it to this one. I'll just discuss my implementation and I'll leave it to others to present details of theirs.

This implementation relies on the FixedBuffer struct from cryptoutil.rs for managing the input buffer, just like the Sha1 and Sha2 digest implementations do. I tried manually unrolling the loops in the compression function, but I got slightly worse performance when I did that.

Outside of the #[test]s, I also tested the implementation by generating 1,000 inputs of up to 10MB in size and checking the MD5 digest calculated by this code against the MD5 digest calculated by Java's implementation.

On my computer, I'm getting the following performance:

```
test md5::bench::md5_10 ... bench: 52 ns/iter (+/- 1) = 192 MB/s
test md5::bench::md5_1k ... bench: 2819 ns/iter (+/- 44) = 363 MB/s
test md5::bench::md5_64k ... bench: 178566 ns/iter (+/- 4927) = 367 MB/s
```
2013-08-17 07:42:01 -07:00
bors
1942a7a3fb auto merge of #8053 : gavinb/rust/uuid_std, r=alexcrichton
Addresses part of #7104

This module adds the ability to generate UUIDs (on all Rust-supported platforms).

I reviewed the existing UUID support in libraries for a range of languages; Go, D, C#, Java and Boost++. The features were all very similar, and this patch essentially covers the union.  The implmentation is quite straightforward, and uses the underlying rng support which is assumed to be sufficiently strong for this purpose.

This patch is not complete, however I have put this up for review to gather feedback before finalising. It has tests for most features and documentation for most functions.

Outstanding issues:

* Only generates V4 (Random) UUIDs. Do we want to support the SHA-1 hash based flavour as well?
* Is it worth having the field-based struct public as well as the byte array?
* Formatting the string with '-' between groups not done yet.
* Parsing full string not done as there appears to be no regexp support yet. I can write a simple manual parser for now?
* D has a generator as well. This would be easy to add. However, given the simple interface for creating a new one, and the presence of the macro, is this useful?
* Is it worth having a separate UUID trait and specific implementation? Or should it just have a struct+impl with the same name? Currently it feels weird to have the trait (which can't be named UUID so as to conflict) a separate thing.
* Should the macro be visible at the top level scope?

As this is a first attempt, some code may not be idiomatic. Please comment below...

Thanks for all feedback!
2013-08-17 05:12:03 -07:00
bors
8ac17731eb auto merge of #8531 : brson/rust/test-waitpid-workaround, r=graydon
...er

I believe the calls to waitpid are interacting badly with the message passing that goes
on between schedulers and causing us to have very little parallelism in
the test suite. I don't fully understand the sequence of events that causes
the problem here but clearly blocking on waitpid is something that a
well-behaved task should not be doing.

Unfortunately this adds quite a bit of overhead to each test: one thread, two
tasks, three stacks, so there's a tradeoff. The time to execute run-pass on
my 4-core machine goes from ~750s to ~300s.

This should have a pretty good impact on cycle times.

cc @toddaaro
2013-08-17 00:22:05 -07:00
Palmer Cox
b00aa12374 Crypto: Add tests for add_bytes_to_bits functions. 2013-08-17 00:22:27 -04:00
Palmer Cox
6386f887a7 Crypto: update checked addition functions to use CheckedAdd intrinsic.
The shift_add_check_overflow and shift_add_check_overflow_tuple functions are
re-written to be more efficient and to make use of the CheckedAdd instrinsic
instead of manually checking for integer overflow.

* The invokation leading_zeros() is removed and replaced with simple integer
  comparison. The leading_zeros() method results in a ctpop LLVM instruction
  and it may not be efficient on all architectures; integer comparisons,
  however, are efficient on just about any architecture.
* The methods lose the ability for the caller to specify a particular shift
  value - that functionality wasn't being used and removing it allows for the
  code to be simplified.
* Finally, the methods are renamed to add_bytes_to_bits and
  add_bytes_to_bits_tuple to reflect their very specific purposes.
2013-08-17 00:22:27 -04:00
Palmer Cox
c707065325 MD5: Create an implementation of MD5. 2013-08-17 00:22:05 -04:00
Palmer Cox
a37f2844e0 Crypto: Add little-endian versions of existing functions: read_u32v_le and write_u32_le. 2013-08-17 00:22:04 -04:00
bors
a1674b6150 auto merge of #8534 : huonw/rust/tls-key-macro, r=alexcrichton
This allows the internal implementation details of the TLS keys to be
changed without requiring the update of all the users. (Or, applying
changes that *have* to be applied for the keys to work correctly, e.g.
forcing LLVM to not merge these constants.)
2013-08-16 08:05:10 -07:00
bors
680eb71564 auto merge of #8532 : kballard/rust/cstr-cleanup, r=erickt
Implement interior null checking in `.to_c_str()`, among other changes.
2013-08-16 06:02:14 -07:00
Gavin Baker
328261aa54 Add UUID support to libextra
- generate random UUIDs
- convert to and from strings and bytes
- parse common string formats
- implements Zero, Clone, FromStr, ToStr, Eq, TotalEq and Rand
- unit tests and documentation
- parsing error codes and strings
- incorporate feedback from PR review
2013-08-16 23:00:35 +10:00
bors
8caf517622 auto merge of #8530 : brson/rust/rt-backtrace, r=alexcrichton
The new scheduler didn't preserve this behavior.
2013-08-16 03:59:14 -07:00
bors
72b50e729d auto merge of #8526 : blake2-ppc/rust/either-result, r=catamorphism
Retry of PR #8471

Replace the remaining functions marked for issue #8228 with similar functions that are iterator-based.

Change `either::{lefts, rights}` to be iterator-filtering instead of returning a vector.

Replace `map_vec`, `map_vec2`, `iter_vec2` in std::result with three functions:

* `result::collect` gathers `Iterator<Result<V, U>>` to `Result<~[V], U>`
* `result::fold` folds `Iterator<Result<T, E>>` to `Result<V, E>`
* `result::fold_` folds `Iterator<Result<T, E>>` to `Result<(), E>`
2013-08-16 01:56:16 -07:00
bors
92af0db0a3 auto merge of #8518 : catamorphism/rust/issue-8498-workaround, r=brson
r? @brson
2013-08-15 23:56:14 -07:00
Huon Wilson
3ad23552fb syntax: add a local_data_key macro that creates a key for access to the TLS.
This allows the internal implementation details of the TLS keys to be
changed without requiring the update of all the users. (Or, applying
changes that have to be applied for the keys to work correctly, e.g.
forcing LLVM to not merge these constants.)
2013-08-16 14:37:24 +10:00
bors
253337de82 auto merge of #7917 : catamorphism/rust/resolve-and-testcases, r=catamorphism 2013-08-15 20:56:12 -07:00
Tim Chevalier
0266172eae testsuite: xfailed test cases 2013-08-15 19:22:26 -07:00
bors
1ad0cf5841 auto merge of #8503 : thestinger/rust/iterator, r=alexcrichton 2013-08-15 18:23:14 -07:00
Daniel Micay
3cec67bbf2 rm obsolete test 2013-08-15 21:12:54 -04:00
Daniel Micay
486501963a vec: rm redundant is_empty implementations 2013-08-15 21:12:35 -04:00
Daniel Micay
fe047e07ba iterator: cleanup 2013-08-15 21:12:34 -04:00
Daniel Micay
45426c3b4c vec: rm obsolete zip and zip_slice
These are obsoleted by the generic iterator `zip` adaptor. Unlike
these, it does not clone the elements or allocate a new vector by
default.
2013-08-15 21:12:34 -04:00
Daniel Micay
1f89eb867a tuple: remove obsolete ExtendedTupleOps
replaced by iterators (generic composable `map` and `zip` adaptors)
2013-08-15 21:12:34 -04:00
Daniel Micay
6a21f22767 update the iterator tutorial 2013-08-15 21:12:34 -04:00
Daniel Micay
af9ddd7563 kinds: update documentation 2013-08-15 21:12:34 -04:00
Daniel Micay
062747b9c9 ptr: inline the Clone implementation 2013-08-15 21:12:34 -04:00
bors
c4656cfd04 auto merge of #8485 : alexcrichton/rust/add-tests, r=catamorphism
Closes #3907
Closes #5493
Closes #4464
Closes #4759
Closes #5666
Closes #5884
Closes #5926
Closes #6318
Closes #6557
Closes #6898
Closes #6919
Closes #7222
2013-08-15 15:41:11 -07:00
Alex Crichton
1764e207fb Add even more tests
Closes #8248
Closes #8249
Closes #8398
Closes #8401
2013-08-15 14:22:36 -07:00
Alex Crichton
443bf93e48 Fix a typo in the ifmt dox 2013-08-15 14:19:09 -07:00
bors
5c0d1923bc auto merge of #8515 : kballard/rust/saturating-checked, r=thestinger
r? @thestinger
2013-08-15 13:50:10 -07:00
bors
fc3297ff05 auto merge of #8499 : nickdesaulniers/rust/issue7169, r=graydon
review? @brson 
tests are green
2013-08-15 09:26:08 -07:00
bors
435020ecc4 auto merge of #8491 : robertknight/rust/7722-reservoir_sampling, r=graydon
Fixes #7722

I had a couple of queries:
- Should this return an array or an iterator?
- Should this be a method on iterators or on the rng? I implemented it in RngUtils as it seemed to belong with shuffle().
2013-08-15 06:56:06 -07:00
bors
77739a7084 auto merge of #8527 : pnkfelix/rust/fsk-visitor-vpar-defaults-step1, r=nikomatsakis
Rewriting visit.rs to operate on a borrowed `&mut V` where `<V:Visitor>`

r? @nikomatsakis
r? @pcwalton

This is the first in a planned series of incremental pull requests.  (There will probably be five pull requests including this one, though they can be combined or split as necessary.)

Part of #7081.  (But definitely does *not* complete it, not on its own, and not even after all five parts land; there are still a few loose ends to tie up or trim afterwards.)

The bulk of this change for this particular PR is pnkfelix@3d83010, which has the changes necessary to visit.rs to support everything else that comes later.  The other commits are illustrating the standard mechanical transformation that I am applying.

One important point for nearly *all* of these pull requests: I was deliberately *not* trying to be intelligent in the transformation. 

 * My goal was to minimize code churn, and make the transformation as mechanical as possible.  
 * For example, I kept the separation between the Visitor struct (corresponding to the earlier vtable of functions that were potentially closed over local state) and the explicitly passed (and clones) visitor Env.  I am certain that this is almost always unnecessary, and a later task will be to go through an meld the Env's into the Visitors as appropriate.  (My original goal had been to make such melding part of this task; that's why I turned them into a (Env, vtable) tuple way back when.  But I digress.)
 * Also, my main goal here was to get rid of the record of `@fn`'s as described by the oldvisit.rs API.  (This series gets rid of all but one such case; I'm still investigating that.)  There is *still* plenty of `@`-boxing left to be removed, I'm sure, and even still some `@fn`'s too; removing all of those is not the goal here; its just to get rid of the encoded protocol of `@fn`'s in the (old)visit API.

To see where things will be going in the future (i.e., to get a sneak-preview of future pull-requests in the series), see:

 * https://github.com/pnkfelix/rust/commits/fsk-visitor-vpar-defaults-step1 (that's this one)
 * https://github.com/pnkfelix/rust/commits/fsk-visitor-vpar-defaults-step2
 * https://github.com/pnkfelix/rust/commits/fsk-visitor-vpar-defaults-step3
 * https://github.com/pnkfelix/rust/commits/fsk-visitor-vpar-defaults-step4
 * https://github.com/pnkfelix/rust/commits/fsk-visitor-vpar-defaults-step5
    * Note that between step 4 and step 5 there is just a single commit, but its a doozy because its the only case where my mechanical transformation did not apply, and thus more serious rewriting was necessary.  See commit pnkfelix@da902b2ff3b1e0bee9fc63cf00c449cceea8abf7
2013-08-15 04:56:06 -07:00
bors
790e6bb397 auto merge of #8490 : huonw/rust/fromiterator-extendable, r=catamorphism
If they are on the trait then it is extremely annoying to use them as
generic parameters to a function, e.g. with the iterator param on the trait
itself, if one was to pass an Extendable<int> to a function that filled it
either from a Range or a Map<VecIterator>, one needs to write something
like:

    fn foo<E: Extendable<int, Range<int>> +
              Extendable<int, Map<&'self int, int, VecIterator<int>>>
          (e: &mut E, ...) { ... }

since using a generic, i.e. `foo<E: Extendable<int, I>, I: Iterator<int>>`
means that `foo` takes 2 type parameters, and the caller has to specify them
(which doesn't work anyway, as they'll mismatch with the iterators used in
`foo` itself).

This patch changes it to:

    fn foo<E: Extendable<int>>(e: &mut E, ...) { ... }
2013-08-15 02:56:08 -07:00
Kevin Ballard
5ca4cdc7b8 Remove inappropriate .to_c_str() in C_cstr()
LLVMConstStringInContext() doesn't need a null-terminated string. It
takes a length instead. Using .to_c_str() here triggers an ICE whenever
the string literal embeds a null, as in "\x00".
2013-08-15 01:33:10 -07:00
Kevin Ballard
f744cf157e Make CString.iter() public 2013-08-15 01:33:10 -07:00
Kevin Ballard
03ef71e262 Add ToCStr method .with_c_str()
.with_c_str() is a replacement for the old .as_c_str(), to avoid
unnecessary boilerplate.

Replace all usages of .to_c_str().with_ref() with .with_c_str().
2013-08-15 01:33:10 -07:00
Kevin Ballard
48265b779f Check for interior nulls in .to_c_str()
Previous dicussions about CString suggested that interior nulls should
throw an error. This was never implemented. Add this now, using a
condition (named null_byte) to allow for recovery.

Add method .to_c_str_unchecked() that skips this check.
2013-08-15 01:32:10 -07:00
bors
7f58552cce auto merge of #8483 : luqmana/rust/rexprs, r=catamorphism
Fixes #8152.
2013-08-15 00:29:11 -07:00
Brian Anderson
15fca2dad7 compiletest: Run tests in their own thread to avoid blocking the scheduler
The calls to waitpid are interacting badly with the message passing that goes
on between schedulers and causing us to have very little parallelism in
the test suite. I don't fully understand the sequence of events that causes
the problem here but clearly blocking on waitpid is something that a
well-behaved task should not be doing.

Unfortunately this adds quite a bit of overhead to each test: one thread, two
tasks, three stacks, so there's a tradeoff. The time to execute run-pass on
my 4-core machine goes from ~750s to ~300s.
2013-08-14 23:41:31 -07:00
bors
7cda0d4316 auto merge of #8481 : cmr/rust/bench/std/at_vec, r=graydon 2013-08-14 22:29:06 -07:00
Brian Anderson
494da5a30b rustc: Change ICE message to reflect that ::rt::backtrace doesn't exist 2013-08-14 22:27:03 -07:00
bors
13c82549bd auto merge of #8525 : graydon/rust/2013-08-14-register-snapshots, r=brson
r? someone
2013-08-14 20:29:10 -07:00
Kevin Ballard
1e4f13f95f Clarify docs on CString.unwrap()
CString.unwrap() drops ownership of the buffer on the floor. Put this in
the docs.
2013-08-14 19:18:24 -07:00
Felix S. Klock II
ef854c9b04 Switch main borrowck to <V:Visitor> trait API.
fix borrowck/mod.rs to deal with fn_kind enum fallout.
2013-08-15 04:06:17 +02:00