Commit Graph

21277 Commits

Author SHA1 Message Date
Niko Matsakis
6b23d20452 Prohibit assignment to &mut pointers that are found in frozen or borrowed locations.
Fixes #8625.
2013-08-21 12:02:21 -04:00
Niko Matsakis
0ea2a20397 Add PointerKind to LpDeref 2013-08-20 17:37:49 -04:00
bors
2246d56e71 auto merge of #8619 : pnkfelix/rust/fsk-visitor-vpar-defaults-step3, r=nmatsakis
Follow up to #8539 (step 2 of 5).

(See  #8527, which was step 1 of 5, for the full outline.)

Part of #7081.
2013-08-19 09:12:03 -07:00
bors
d597f54fc2 auto merge of #8539 : pnkfelix/rust/fsk-visitor-vpar-defaults-step2, r=graydon,nikomatsakis
r? @nikomatsakis

Follow up to #8527 (which was step 1 of 5).  See that for overall description 

Part of #7081
2013-08-19 06:52:03 -07:00
bors
81a78161b5 auto merge of #8535 : nikomatsakis/rust/issue-3678-wrappers-be-gone-2, r=graydon
Long-standing branch to remove foreign function wrappers altogether. Calls to C functions are done "in place" with no stack manipulation; the scheme relies entirely on the correct use of `#[fixed_stack_segment]` to guarantee adequate stack space. A linter is added to detect when `#[fixed_stack_segment]` annotations are missing. An `externfn!` macro is added to make it easier to declare foreign fns and wrappers in one go: this macro may need some refinement, though, for example it might be good to be able to declare a group of foreign fns. I leave that for future work (hopefully somebody else's work :) ).

Fixes #3678.
2013-08-19 04:32:04 -07:00
Niko Matsakis
0479d946c8 Add externfn macro and correctly label fixed_stack_segments 2013-08-19 07:13:15 -04:00
Niko Matsakis
303f650ecf Issue #3678: Remove wrappers and call foreign functions directly 2013-08-19 07:13:15 -04:00
bors
3e4f40ec5a auto merge of #8564 : alexcrichton/rust/ifmt+++, r=graydon
See discussion in #8489, but this selects option 3 by adding a `Default` trait to be implemented by various basic types.

Once this makes it into a snapshot I think it's about time to start overhauling all current use-cases of `fmt!` to move towards `ifmt!`. The goal is to replace `%X` with `{}` in 90% of situations, and this commit should enable that.
2013-08-19 01:42:05 -07:00
bors
c178b52fe5 auto merge of #8556 : sfackler/rust/quote, r=alexcrichton
They previously required one called "ext_cx" to be in scope.

Fixes part of #7727
2013-08-18 21:51:58 -07:00
bors
557ff049f0 auto merge of #8565 : bblum/rust/select-bugfix, r=brson
@brson grilled me about how this bugfix worked the first time around, and it occurred to me that it didn't in the case where the task is unwinding. Now it will.
2013-08-18 19:32:36 -07:00
bors
8fff3f40f2 auto merge of #8561 : kballard/rust/do-block-internal-err-msg, r=thestinger
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 `()`

r? @thestinger
2013-08-18 17:12:02 -07:00
bors
b26e11db86 auto merge of #8560 : kballard/rust/reserve-yield, r=pcwalton
Rename task::yield() to task::deschedule().

Fixes #8494.
2013-08-18 15:02:04 -07:00
bors
e185b049af auto merge of #8545 : blake2-ppc/rust/iterbytes, r=alexcrichton
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 12:41:59 -07:00
Steven Fackler
8b80922a4c quote_*! macros take an ExtCtx
They previously required one called "ext_cx" to be in scope.

Fixes part of #7727
2013-08-18 13:14:15 -04:00
bors
88bd2155d7 auto merge of #8558 : kballard/rust/xorshift-seed, r=cmr
Fixes #8359.
2013-08-18 10:01:55 -07:00
blake2-ppc
bfa1331cd7 std:#️⃣ Add testcase for colliding hashes of tuples
Add a testcase that verifies that (s, t) and (u, v) don't collide even if
s + t == u + v (concatenation).
2013-08-18 18:39:47 +02:00
blake2-ppc
73fdacbac9 std::to_bytes: Implement IterBytes on 1- to 8-tuples 2013-08-18 18:39:47 +02:00
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
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
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
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
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
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
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