Commit Graph

21430 Commits

Author SHA1 Message Date
blake2-ppc
6066118b29 std::to_bytes: Delimit sequences &[A] and ~str when hashing
Address issue #5257, for example these values all had the same hash value:

	("aaa", "bbb", "ccc")
	("aaab", "bb", "ccc")
	("aaabbb", "", "ccc")

IterBytes for &[A] now includes the length, before calling iter_bytes on
each element.

IterBytes for &str is now terminated by a byte that does not appear in
UTF-8. This way only one more byte is processed when hashing strings.
2013-08-18 18:39:47 +02:00
bors
0a238288d3 auto merge of #8555 : chris-morgan/rust/time-clone, r=huonw
I need `Clone` for `Tm` for my latest work on [rust-http](https://github.com/chris-morgan/rust-http) (static typing for headers, and headers like `Date` are a time), so here it is.

@huonw recommended deriving DeepClone while I was at it.

I also had to implement `DeepClone` for `~str` to get a derived implementation of `DeepClone` for `Tm`; I did `@str` while I was at it, for consistency.
2013-08-18 07:21:58 -07:00
bors
3bc6858428 auto merge of #8551 : huonw/rust/speling, r=alexcrichton
(This doesn't add/remove `u`s or change `ize` to `ise`, or anything like that.)
2013-08-18 05:11:58 -07:00
bors
600901152c auto merge of #8550 : kballard/rust/token-start-err-msg, r=catamorphism
The span was fixed at some point to point to the correct character, but
the error message is still bad. Update it to emit the actual character
in question (potentially escaped).

Fixes #3747.
2013-08-18 02:51:59 -07:00
Jan Kobler
c5c4a63aeb insert space
in the rust grammar

to avoid error messages like this:

  Exception: non-alpha apparent keyword: pub"

when using extract_grammar.py:

python2.7 src/etc/extract_grammar.py <doc/rust.md

Signed-off-by: Jan Kobler <eng1@koblersystems.de>
2013-08-18 08:00:23 +02:00
bors
758c5e8236 auto merge of #8547 : kballard/rust/trait-parse-err-msg, r=alexcrichton
When parsing a trait function, the function must end with either `;` or
`{` (signifying a default implementation). The error message incorrectly
stated that it must be `;` or `}`.

Fixes #6610.
2013-08-17 22:52:00 -07:00
Jan Kobler
87761c1f99 extract_grammar symnames
add missing symnames

Signed-off-by: Jan Kobler <eng1@koblersystems.de>
2013-08-18 07:25:54 +02:00
bors
6a88415ed8 auto merge of #8544 : dim-an/rust/fix-match-pipes, r=pcwalton
Pointers to bound variables shouldn't be stored before checking pattern,
otherwise piped patterns can conflict with each other (issue #6338).

Closes #6338.
2013-08-17 20:12:02 -07:00
Daniel Micay
0dceabda7f Revert "Turn off jemalloc"
This reverts commit 371a316ec9.

Closes #7217
2013-08-17 19:54:23 -04:00
Huon Wilson
6440343a6c More spelling corrections. 2013-08-18 08:28:04 +10:00
bors
679102109f auto merge of #8554 : michaelwoerister/rust/generics, r=brson
This pull request includes support for generic functions and self arguments in methods, and combinations thereof. This also encompasses any kind of trait methods, regular and static, with and without default implementation. The implementation is backed up by a felt ton of test cases `:)`

This is a very important step towards being able to compile larger programs with debug info, since practically any generic function caused an ICE before.

One point worth discussing is that activating debug info now automatically (and silently) sets the `no_monomorphic_collapse` flag. Otherwise debug info would show wrong type names in all but one instance of the monomorphized function.

Another thing to note is that the handling of generic types does not strictly follow the DWARF specification. That is, variables with type `T` (where `T=int`) are described as having type `int` and not as having type `T`. In other words, we are losing information whether a variable has been declared with a type parameter as its type. In practice this should not make much of difference though since the concrete type is mostly what one is interested in. I'll post an issue later so this won't be forgotten.

Also included are a number of bug fixes:
* Closes #1758
* Closes #8513
* Closes #8443
* Fixes handling of field names in tuple structs
* Fixes and re-enables test case for option-like enums that relied on undefined behavior before
* Closes #1339 (should have been closed a while ago)

Cheers,
Michael
2013-08-17 15:22:04 -07:00
Andreas Martens
c4b4cb36c8 Fix segfault when calling tuple struct constructor as extern fn
Fixes #5315
2013-08-17 22:42:31 +02:00
bors
cb8a231eb8 auto merge of #8433 : brson/rust/rm-more-oldrt-crud, r=brson
Just deleting more stuff.
2013-08-17 12:51:57 -07: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
Do Nhat Minh
4457d2b379 fix for #8088 (Cannot name a struct field new due to ancient syntax)
remove code for parsing ancient syntax
added a run-pass test
2013-08-18 00:07:14 +08: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
toddaaro
20213fcca4 A round of code cleaning for the primary scheduler code. Comments have been updated, a minor amount of support type restructing has happened, methods have been reordered, and some duplicate code has been purged. 2013-08-16 16:37:59 -07:00
toddaaro
f83835b0e7 Moved the logic for a pausible idle callback into a new type - PausibleIdleCallback and placed the appropriate signatures in rtio and implementation into uvio. 2013-08-16 16:37:09 -07:00
Brian Anderson
88d8baa76b std::rt: Fix a race in UvRemoteCallback's dtor that misses callbacks
Full description in comments.
2013-08-16 16:37:09 -07:00
Brian Anderson
bd382ee643 std::rt: Touch up idle logic 2013-08-16 16:37:09 -07:00
toddaaro
066ca17eaa an attempt at a singleton pausible idle callback for each scheduler. suffers from nondeterministic deadlock and also pending scheduler messages on scheduler shutdown. 2013-08-16 16:37:09 -07:00
Alex Crichton
22c7bbfd0c Delegate {} to Default instead of Poly
By using a separate trait this is overridable on a per-type basis and makes room
for the possibility of even more arguments passed in for the future.
2013-08-16 16:09:33 -07:00
Alex Crichton
109274426a Implement {:s} for ~str and @str as well 2013-08-16 16:09:33 -07:00
Kevin Ballard
0450cde37b Remove obsolete error message regarding do-blocks with internal iters
When using a `do` block to call an internal iterator, if you forgot to
return a value from the body, it would tell you

    error: Do-block body must return bool, but returns () here. Perhaps
    you meant to write a `for`-loop?

This advice no longer applies as `for` loops are now for external
iterators. Delete this message outright and let it use the default error
message

    error: mismatched types: expected `bool` but found `()`
2013-08-16 14:12:06 -07:00
Michael Woerister
80fb2f2056 debuginfo: Added test cases for static struct and enum methods. 2013-08-16 22:30:43 +02:00
Michael Woerister
5abb7c3a67 debuginfo: Test cases for [generic][default][static] methods and functions:
* closure-in-generic-function
* generic-functions-nested
* generic-method-on-generic-struct
* generic-trait-generic-static-default-method
* method-on-generic-struct
* self-in-generic-default-method
* trait-generic-static-default-method

Also, fixed an 'unused variable' warning in debuginfo.rs
2013-08-16 22:30:43 +02:00
Michael Woerister
0e7808c2e0 debuginfo: Support for combinations of Self type and type parameters. 2013-08-16 22:30:43 +02:00
Michael Woerister
024d644c68 debuginfo: Add test case for issue #8513. 2013-08-16 22:30:43 +02:00
Michael Woerister
c1734cef33 debuginfo: Implemented support for Self type parameter in trait methods with default implementation. 2013-08-16 22:30:43 +02:00
Michael Woerister
a36e53730f debuginfo: Added test cases for methods on structs, enums, traits, and tuple-structs.
Also new test cases for tuple structs and by-value parameter passing.
2013-08-16 22:30:43 +02:00
Michael Woerister
689929c51a debuginfo: Added support for self parameter in methods. 2013-08-16 22:30:42 +02:00
Michael Woerister
44557e7a33 debuginfo: Fixed crash occuring for parameterless closures. 2013-08-16 22:30:42 +02:00
Michael Woerister
5c9d7c2072 debuginfo: Added test cases for generic structs and enums.
Also, always set no_monomorphic_collapse flags if debuginfo is generated.
2013-08-16 22:30:42 +02:00
Michael Woerister
6c49c2df76 debuginfo: Properly handle monomorphization of generic functions. 2013-08-16 22:30:42 +02:00
Michael Woerister
907633b1bf debuginfo: Generate template type parameters for generic functions.
Conflicts:
	src/librustc/lib/llvm.rs
	src/librustc/middle/trans/debuginfo.rs
	src/rustllvm/RustWrapper.cpp
	src/rustllvm/rustllvm.def.in
2013-08-16 22:27:38 +02:00
Michael Woerister
1dec27bed5 debuginfo: Fixed option-like-enum test case so it does not rely on undefined behavior. 2013-08-16 22:27:38 +02:00
Kevin Ballard
418e1ebae6 Reserve 'yield' keyword
Rename task::yield() to task::deschedule().

Fixes #8494.
2013-08-16 13:26:50 -07:00
Brian Anderson
a4d171e009 rt: Remove unused uv helpers 2013-08-16 13:24:25 -07:00
Brian Anderson
5052773ad8 rt: Remove empty rust_upcall.h 2013-08-16 13:24:25 -07:00
Brian Anderson
450f16eb25 rt: Remove unused rust_clone_type_desc declaration 2013-08-16 13:24:25 -07:00