bors [Fri, 24 Oct 2014 03:22:29 +0000 (03:22 +0000)]
auto merge of #17896 : mahkoh/rust/intmax, r=alexcrichton
Closes #17075
I don't know if this is correct. The easiest way to find out is to run the following program on all targets but I can't do it myself.
```c
#include <stdint.h>
#include <stdio.h>
int main(void)
{
if (sizeof(intmax_t) != 8) {
puts("ERROR");
return 1;
}
}
```
Alex Crichton [Thu, 23 Oct 2014 16:38:37 +0000 (09:38 -0700)]
Register new snapshots
This in theory enables uncommenting IndexMut implementations, but upon doing so
the compiler immediately segfaulted in stage1, so I'll leave those to a later
time.
We effectively get two mutable references to the same variable `foo` at
the same time. One for the parameter `f`, and one for the hidden
out-pointer. So we can't just `trans_into` the destination directly, but
must use `trans` to get a new temporary slot from which the result can
be copied.
areski [Wed, 22 Oct 2014 22:44:17 +0000 (00:44 +0200)]
Fixed single quote around string slice and simplify example
This patch contains a fix for:
- single quote around string slice
- string: String is confusing for newbies and it's more readble if the
argument name is different that the argument type name
bors [Wed, 22 Oct 2014 14:32:11 +0000 (14:32 +0000)]
auto merge of #18230 : cakebaker/rust/adapt_range_value_to_variable_name, r=steveklabnik
The variable name <code>one_to_one_hundred</code> implies that it will contain a collection with the values from 1 to 100, but the collection contains the values from 0 to 99. This patch changes the ranges to produce a collection with the values from 1 to 100.
bors [Wed, 22 Oct 2014 04:42:11 +0000 (04:42 +0000)]
auto merge of #18213 : pcwalton/rust/pcg-default, r=aturon
Enable parallel codegen (2 units) by default when --opt-level is 0 or 1. This
gives a minor speedup on large crates (~10%), with only a tiny slowdown (~2%)
for small ones (which usually build in under a second regardless). The current
default (no parallelization) is used when the user requests optimization
(--opt-level 2 or 3), and when the user has enabled LTO (which is incompatible
with parallel codegen).
This commit also changes the rust build system to use parallel codegen
when appropriate. This means codegen-units=4 for stage0 always, and
also for stage1 and stage2 when configured with --disable-optimize.
(Other settings use codegen-units=1 for stage1 and stage2, to get
maximum performance for release binaries.) The build system also sets
codegen-units=1 for compiletest tests (compiletest does its own
parallelization) and uses the same setting as stage2 for crate tests.
bors [Wed, 22 Oct 2014 00:22:04 +0000 (00:22 +0000)]
auto merge of #18121 : nikomatsakis/rust/method-call-use-trait-matching-infrastructure-2, r=pcwalton
Convert trait method dispatch to use new trait matching machinery.
This fixes about 90% of #17918. What remains to be done is to make inherent dispatch work with conditional dispatch as well. I plan to do this in a future patch by generalizing the "method match" code slightly to work for inherent impls as well (the basic algorithm is precisely the same).
Fixes #17178.
This is a [breaking-change] for two reasons:
1. The old code was a bit broken. I found various minor cases, particularly around operators, where the old code incorrectly matched, but an extra `*` or other change is now required. (See commit e8cef25 ("Correct case where the old version of method lookup...") for examples.)
2. The old code didn't type check calls against the method signature from the *trait* but rather the *impl*. The two can be different in subtle ways. This makes the new method dispatch both more liberal and more conservative than the original. (See commit 8308332 ("The new method lookup mechanism typechecks...") for examples.)
r? @pcwalton since he's been reviewing most of this series of changes
f? @nick29581 for commit 39df55f ("Permit DST types to unify like other types")
cc @aturon as this relates to library stabilization
Enable parallel codegen (2 units) by default when --opt-level is 0 or 1. This
gives a minor speedup on large crates (~10%), with only a tiny slowdown (~2%)
for small ones (which usually build in under a second regardless). The current
default (no parallelization) is used when the user requests optimization
(--opt-level 2 or 3), and when the user has enabled LTO (which is incompatible
with parallel codegen).
This commit also changes the rust build system to use parallel codegen
when appropriate. This means codegen-units=4 for stage0 always, and
also for stage1 and stage2 when configured with --disable-optimize.
(Other settings use codegen-units=1 for stage1 and stage2, to get
maximum performance for release binaries.) The build system also sets
codegen-units=1 for compiletest tests (compiletest does its own
parallelization) and uses the same setting as stage2 for crate tests.
Niko Matsakis [Fri, 17 Oct 2014 13:13:12 +0000 (09:13 -0400)]
Tests for method resolution in the face of various ambiguities or non-ambiguities. These
are mostly new tests though I also revamped (and renamed) some of the existing tests.
Niko Matsakis [Fri, 17 Oct 2014 13:11:10 +0000 (09:11 -0400)]
The new method lookup mechanism typechecks calls against the method type declared in the trait, not in the impl. In some cases that results in tighter rules, and in some cases looser. Correct for that.
Niko Matsakis [Fri, 17 Oct 2014 13:07:45 +0000 (09:07 -0400)]
Change method lookup infrastructure to use the trait methods. Instead
of tracking individual candidates per impl, we just track one
candidate for the extension trait itself, and let the trait resolution
handle walking the individual impls and so forth. Also change the
interface to report back a richer notion of error.
Niko Matsakis [Fri, 17 Oct 2014 12:51:43 +0000 (08:51 -0400)]
Implement "method matching". Similar to trait matching, but with the twist that we
have to take the transformed self type into account, and allow for coercion between
the receiver and the actual type declared on the impl.
John Kleint [Mon, 20 Oct 2014 00:49:10 +0000 (20:49 -0400)]
Guide: articulate the advantages of ownership over garbage collection.
Explain the primary disadvantage of garbage collection is runtime
overhead and unpredictable pauses. Elucidate where the name "race
condition" comes from. Emphasize that Rust can guarantee your code is
free of race conditions and other memory errors, with no runtime
overhead.
bors [Tue, 21 Oct 2014 11:37:14 +0000 (11:37 +0000)]
auto merge of #17508 : vberger/rust/stability_lint_for_nested_macros, r=pnkfelix
Finishes the job of #17286.
Now the stability lint will successfully detect patterns such as:
```
first_macro!(second_macro!(deprecated_function()));
```
```
macro_rules! foo (
($e: expr) => (bar!($e))
)
foo!(deprected_function());
```
and
```
println!("{}", deprecated_function());
```
even with more levels of nesting, such as
```
println!("{}", foo!(bar!(deprecated_function())));
```
bors [Tue, 21 Oct 2014 08:22:09 +0000 (08:22 +0000)]
auto merge of #18194 : jmesmon/rust/libbacktrace-env, r=alexcrichton
This was run into while attempting to integrate rust with bitbake's build system. I expect it's caused by some other environment variables being set to gcc but didn't track down the exact cause myself.
bors [Tue, 21 Oct 2014 00:07:33 +0000 (00:07 +0000)]
auto merge of #17555 : steveklabnik/rust/module_guide, r=alexcrichton
This is an almost-done draft of a guide on crates and modules. This is a hard guide to get right, I had to remove a chunk of the Guide because it was confusing.
I've also pushed up https://github.com/steveklabnik/phrases which has matching code. Whenever we finish this guide, I think it'd be good to have a sample crate like this in the rust-lang org for people to compare against. The hardest part of a guide like this is that it depends on multiple files being correct, and being able to point to a repository would be very helpful.
Things yet to do:
1. external crates via cargo
2. documentation
I'm super open to still revising this if it's still confusing. There's been a lot of Reddit discussion about the module system, and I tried to incorporate those posts and the comments into this.
bors [Mon, 20 Oct 2014 16:07:43 +0000 (16:07 +0000)]
auto merge of #18070 : alexcrichton/rust/spring-cleaning, r=aturon
This is a large spring-cleaning commit now that the 0.12.0 release has passed removing an amount of deprecated functionality. This removes a number of deprecated crates (all still available as cargo packages in the rust-lang organization) as well as a slew of deprecated functions. All `#[crate_id]` support has also been removed.
I tried to avoid anything that was recently deprecated, but I may have missed something! The major pain points of this commit is the fact that rustc/syntax have `#[allow(deprecated)]`, but I've removed that annotation so moving forward they should be cleaned up as we go.
bors [Mon, 20 Oct 2014 03:27:12 +0000 (03:27 +0000)]
auto merge of #18108 : mahkoh/rust/buffered_reader, r=alexcrichton
This optimizes `read` for the case in which the number of bytes
requested is larger than the internal buffer. Note that the first
comparison occurs again right afterwards and should thus be free. The
second comparison occurs only in the cold branch.
Julian Orth [Fri, 17 Oct 2014 00:48:29 +0000 (02:48 +0200)]
Optimize BufferedReader::read for large buffers.
This optimizes `read` for the case in which the number of bytes
requested is larger than the internal buffer. Note that the first
comparison occurs again right afterwards and should thus be free. The
second comparison occurs only in the cold branch.
bors [Sun, 19 Oct 2014 23:32:07 +0000 (23:32 +0000)]
auto merge of #18160 : koshlo/rust/to-source-fix, r=alexcrichton
Fix for issue #18091
The problem seems to be that `ast_util::int_ty_to_string` takes unsigned number, and no one adds `-` to result string. I've fixed it by putting `-` before result string using `format!`.
I've also added `test_signed_int_to_string()` to check if implementation is valid.
Alex Crichton [Wed, 15 Oct 2014 06:05:01 +0000 (23:05 -0700)]
Remove a large amount of deprecated functionality
Spring cleaning is here! In the Fall! This commit removes quite a large amount
of deprecated functionality from the standard libraries. I tried to ensure that
only old deprecated functionality was removed.
This is removing lots and lots of deprecated features, so this is a breaking
change. Please consult the deprecation messages of the deleted code to see how
to migrate code forward if it still needs migration.
bors [Sun, 19 Oct 2014 00:47:18 +0000 (00:47 +0000)]
auto merge of #18120 : jrincayc/rust/match_exp, r=thestinger
Use a match expression directly in the println statement, instead of creating a second variable. It seems weird that the current guide.md complains about creating an extra variable, when the same feature could be demonstrated without creating the extra variable.