Commit Graph

30527 Commits

Author SHA1 Message Date
Erick Tryzelaar
7d3899430b collections: flesh out the Vec::clone_from benchmarks to cover reuse 2014-07-07 09:16:36 -07:00
bors
4f120e6baf auto merge of #15496 : ruud-v-a/rust/patch-1, r=huonw
Also removes redundant newline in code block.
2014-07-07 08:16:29 +00:00
bors
f78d2f5900 auto merge of #15489 : jakub-/rust/issue-15488, r=pcwalton
Fixes #15488.
2014-07-07 06:31:30 +00:00
Ruud van Asseldonk
90b79b7686 manual: Fix typo.
Also removes redundant newline in code block.
2014-07-07 07:51:34 +02:00
bors
179b2b48ba auto merge of #15411 : mitchmindtree/rust/master, r=alexcrichton
I ran `make check` and everything went smoothly. I also tested `#[deriving(Decodable, Encodable)]` on a struct containing both Cell<T> and RefCell<T> and everything now seems to work fine.
2014-07-07 04:46:31 +00:00
mitchmindtree
0e84d6fc1a Implemented Decodable/Encodable for Cell and RefCell. Fixes #15395
Updated PR with fixme and test

Updated PR with fixme and test
2014-07-07 13:02:09 +10:00
bors
d9db7f6137 auto merge of #15464 : dotdash/rust/bool_stores, r=pcwalton
LLVM doesn't handle i1 value in allocas/memory very well and skips a number of optimizations if it hits it. So we have to do the same thing that Clang does, using i1 for SSA values, but storing i8 in memory.

Fixes #15203.
2014-07-07 03:01:34 +00:00
bors
21ef888bb7 auto merge of #15481 : alexcrichton/rust/fix-nightly, r=luqmana
The stage0 compiler for a non-CFG_BUILD architecture needs to have the new
`-C extra-filename` argument passed.
2014-07-06 23:06:34 +00:00
Jakub Wieczorek
9f460e7af8 Properly bind nested pattern bindings when there's more than one
Fixes #15488.
2014-07-07 00:26:41 +02:00
bors
c97f885aee auto merge of #15486 : jakub-/rust/test-case-12187, r=alexcrichton
Closes #12187.
2014-07-06 20:36:35 +00:00
Björn Steinbrink
dd4112bf79 Store booleans as i8 in memory to improve optimizations by LLVM
LLVM doesn't really like types with a bit-width that isn't a multiple of
8 and disable various optimizations if it encounters such types used
with loads/stores. OTOH, booleans must be represented as i1 when used as
SSA values. To get the best results, we must use i1 for SSA values, and
i8 when storing the value to memory.

By using range asserts on loads, LLVM can eliminate the required
zero-extend and truncate operations.

Fixes #15203
2014-07-06 22:12:10 +02:00
Björn Steinbrink
d2a22f520c Remove remainders from when booleans were i8 2014-07-06 22:12:00 +02:00
Jakub Wieczorek
e05ec9a2bf Add a test case for #12187, which appears to have been fixed
Closes #12187.
2014-07-06 21:40:16 +02:00
bors
51a7488532 auto merge of #15467 : brson/rust/guideversion, r=alexcrichton 2014-07-06 18:51:34 +00:00
bors
f601c3e7c3 auto merge of #15465 : SimonSapin/rust/patch-4, r=alexcrichton
`Vec::push_all` with a length 1 slice seems to have significant overhead compared to `Vec::push`.

```
test new_push_byte ... bench:      6985 ns/iter (+/- 487) = 17 MB/s
test old_push_byte ... bench:     19335 ns/iter (+/- 1368) = 6 MB/s
```

```rust
extern crate test;
use test::Bencher;

static TEXT: &'static str = "\
    Unicode est un standard informatique qui permet des échanges \
    de textes dans différentes langues, à un niveau mondial.";

#[bench]
fn old_push_byte(bencher: &mut Bencher) {
    bencher.bytes = TEXT.len() as u64;
    bencher.iter(|| {
        let mut new = String::new();
        for b in TEXT.bytes() {
            unsafe { new.as_mut_vec().push_all([b]) }
        }
    })
}

#[bench]
fn new_push_byte(bencher: &mut Bencher) {
    bencher.bytes = TEXT.len() as u64;
    bencher.iter(|| {
        let mut new = String::new();
        for b in TEXT.bytes() {
            unsafe { new.as_mut_vec().push(b) }
        }
    })
}
```
2014-07-06 17:06:36 +00:00
Alex Crichton
6d4d83c94d mk: Fix bootstrapping the nightly builds
The stage0 compiler for a non-CFG_BUILD architecture needs to have the new
`-C extra-filename` argument passed.
2014-07-06 08:28:06 -07:00
bors
00a32f2f18 auto merge of #15456 : aochagavia/rust/guide, r=alexcrichton
Fixes https://github.com/rust-lang/rust/issues/15452
2014-07-06 13:26:35 +00:00
bors
4c0cab7f2f auto merge of #15454 : jakub-/rust/15453, r=huonw
I forget we now have byte string literals.
2014-07-06 11:41:37 +00:00
bors
b7c4493b9f auto merge of #15447 : patrickyevsukov/rust/patch-1, r=alexcrichton
Fix Typos
2014-07-06 09:56:38 +00:00
bors
85d33e1aa1 auto merge of #15472 : luqmana/rust/snaps, r=alexcrichton 2014-07-06 07:31:38 +00:00
Luqman Aden
3fd2b0dc02 Register snapshot. 2014-07-06 02:13:35 -04:00
Erick Tryzelaar
90fe1a632b std: flesh out MemWriter benchmarks 2014-07-05 23:11:21 -07:00
Erick Tryzelaar
f1ea540e90 collections: Optimize Vec when cloning from a slice
llvm is currently not able to conver `Vec::extend` into a memcpy
for `Copy` types, which results in methods like `Vec::push_all`
to run twice as slow as it should be running. This patch takes
the unsafe `Vec::clone` optimization to speed up all the operations
that are cloning a slice into a `Vec`.

before:

test vec::tests::bench_clone_from_0000_0000                ... bench:        12 ns/iter (+/- 2)
test vec::tests::bench_clone_from_0000_0010                ... bench:       125 ns/iter (+/- 4) = 80 MB/s
test vec::tests::bench_clone_from_0000_0100                ... bench:       360 ns/iter (+/- 33) = 277 MB/s
test vec::tests::bench_clone_from_0000_1000                ... bench:      2601 ns/iter (+/- 175) = 384 MB/s
test vec::tests::bench_clone_from_0010_0000                ... bench:        12 ns/iter (+/- 2)
test vec::tests::bench_clone_from_0010_0010                ... bench:       125 ns/iter (+/- 10) = 80 MB/s
test vec::tests::bench_clone_from_0010_0100                ... bench:       361 ns/iter (+/- 28) = 277 MB/s
test vec::tests::bench_clone_from_0100_0010                ... bench:       131 ns/iter (+/- 13) = 76 MB/s
test vec::tests::bench_clone_from_0100_0100                ... bench:       360 ns/iter (+/- 9) = 277 MB/s
test vec::tests::bench_clone_from_0100_1000                ... bench:      2575 ns/iter (+/- 168) = 388 MB/s
test vec::tests::bench_clone_from_1000_0100                ... bench:       356 ns/iter (+/- 20) = 280 MB/s
test vec::tests::bench_clone_from_1000_1000                ... bench:      2605 ns/iter (+/- 167) = 383 MB/s
test vec::tests::bench_from_slice_0000                     ... bench:        11 ns/iter (+/- 0)
test vec::tests::bench_from_slice_0010                     ... bench:       115 ns/iter (+/- 5) = 86 MB/s
test vec::tests::bench_from_slice_0100                     ... bench:       309 ns/iter (+/- 170) = 323 MB/s
test vec::tests::bench_from_slice_1000                     ... bench:      2065 ns/iter (+/- 198) = 484 MB/s
test vec::tests::bench_push_all_0000_0000                  ... bench:         7 ns/iter (+/- 0)
test vec::tests::bench_push_all_0000_0010                  ... bench:        79 ns/iter (+/- 7) = 126 MB/s
test vec::tests::bench_push_all_0000_0100                  ... bench:       342 ns/iter (+/- 18) = 292 MB/s
test vec::tests::bench_push_all_0000_1000                  ... bench:      2873 ns/iter (+/- 75) = 348 MB/s
test vec::tests::bench_push_all_0010_0010                  ... bench:       154 ns/iter (+/- 8) = 64 MB/s
test vec::tests::bench_push_all_0100_0100                  ... bench:       518 ns/iter (+/- 18) = 193 MB/s
test vec::tests::bench_push_all_1000_1000                  ... bench:      4490 ns/iter (+/- 223) = 222 MB/s

after:

test vec::tests::bench_clone_from_0000_0000                ... bench:        12 ns/iter (+/- 1)
test vec::tests::bench_clone_from_0000_0010                ... bench:       123 ns/iter (+/- 5) = 81 MB/s
test vec::tests::bench_clone_from_0000_0100                ... bench:       367 ns/iter (+/- 23) = 272 MB/s
test vec::tests::bench_clone_from_0000_1000                ... bench:      2618 ns/iter (+/- 252) = 381 MB/s
test vec::tests::bench_clone_from_0010_0000                ... bench:        12 ns/iter (+/- 1)
test vec::tests::bench_clone_from_0010_0010                ... bench:       124 ns/iter (+/- 7) = 80 MB/s
test vec::tests::bench_clone_from_0010_0100                ... bench:       369 ns/iter (+/- 34) = 271 MB/s
test vec::tests::bench_clone_from_0100_0010                ... bench:       123 ns/iter (+/- 6) = 81 MB/s
test vec::tests::bench_clone_from_0100_0100                ... bench:       371 ns/iter (+/- 25) = 269 MB/s
test vec::tests::bench_clone_from_0100_1000                ... bench:      2713 ns/iter (+/- 532) = 368 MB/s
test vec::tests::bench_clone_from_1000_0100                ... bench:       369 ns/iter (+/- 14) = 271 MB/s
test vec::tests::bench_clone_from_1000_1000                ... bench:      2611 ns/iter (+/- 194) = 382 MB/s
test vec::tests::bench_from_slice_0000                     ... bench:         7 ns/iter (+/- 0)
test vec::tests::bench_from_slice_0010                     ... bench:       108 ns/iter (+/- 4) = 92 MB/s
test vec::tests::bench_from_slice_0100                     ... bench:       235 ns/iter (+/- 24) = 425 MB/s
test vec::tests::bench_from_slice_1000                     ... bench:      1318 ns/iter (+/- 96) = 758 MB/s
test vec::tests::bench_push_all_0000_0000                  ... bench:         7 ns/iter (+/- 0)
test vec::tests::bench_push_all_0000_0010                  ... bench:        70 ns/iter (+/- 4) = 142 MB/s
test vec::tests::bench_push_all_0000_0100                  ... bench:       176 ns/iter (+/- 16) = 568 MB/s
test vec::tests::bench_push_all_0000_1000                  ... bench:      1125 ns/iter (+/- 94) = 888 MB/s
test vec::tests::bench_push_all_0010_0010                  ... bench:       159 ns/iter (+/- 15) = 62 MB/s
test vec::tests::bench_push_all_0100_0100                  ... bench:       363 ns/iter (+/- 12) = 275 MB/s
test vec::tests::bench_push_all_1000_1000                  ... bench:      2860 ns/iter (+/- 415) = 349 MB/s
2014-07-05 23:11:18 -07:00
Erick Tryzelaar
065b98d577 collections: flesh out Vec benchmarks 2014-07-05 23:07:28 -07:00
bors
ea037d02de auto merge of #15441 : P1start/rust/lifetime-suggest, r=pcwalton
Closes #15433.
2014-07-06 05:46:36 +00:00
bors
0fa8a598f6 auto merge of #15439 : dotdash/rust/remove_entry_bcx, r=pcwalton
We no longer need to refer to the entry block from arbitrary places, so
we can drop it from FunctionContext.
2014-07-06 04:01:39 +00:00
bors
832731dace auto merge of #15417 : pfalabella/rust/rational-signed, r=alexcrichton 2014-07-06 01:26:41 +00:00
Brian Anderson
7b7d3c2458 doc: --version no longer displays the host triple 2014-07-05 17:54:24 -07:00
Simon Sapin
ed3eee2e2a Optimize String::push_byte()
```
test new_push_byte ... bench:      6985 ns/iter (+/- 487) = 17 MB/s
test old_push_byte ... bench:     19335 ns/iter (+/- 1368) = 6 MB/s
```

```rust
extern crate test;
use test::Bencher;

static TEXT: &'static str = "\
    Unicode est un standard informatique qui permet des échanges \
    de textes dans différentes langues, à un niveau mondial.";

#[bench]
fn old_push_byte(bencher: &mut Bencher) {
    bencher.bytes = TEXT.len() as u64;
    bencher.iter(|| {
        let mut new = String::new();
        for b in TEXT.bytes() {
            unsafe { new.as_mut_vec().push_all([b]) }
        }
    })
}

#[bench]
fn new_push_byte(bencher: &mut Bencher) {
    bencher.bytes = TEXT.len() as u64;
    bencher.iter(|| {
        let mut new = String::new();
        for b in TEXT.bytes() {
            unsafe { new.as_mut_vec().push(b) }
        }
    })
}
```
2014-07-06 01:11:13 +01:00
bors
c3ef04be55 auto merge of #15319 : alexcrichton/rust/no-crate-id, r=brson
This is an implementation of [RFC 35](https://github.com/rust-lang/rfcs/blob/master/active/0035-remove-crate-id.md).

The summary for this PR is the same as that of the RFC, with one addendum:


* Removes the `#[crate_id]` attribute and knowledge of versions from rustc.
* Added a `#[crate_name]` attribute similar to the old `#[crate_id]` attribute
* Output filenames no longer have versions or hashes
* Symbols no longer have versions (they still have hashes)
* A new flag, `--extern`, is used to override searching for external crates
* A new flag, `-C metadata=foo`, used when hashing symbols
* [added] An old flag, `--crate-name`, was re purposed to specify the crate name from the command line.

I tried to maintain backwards compatibility wherever possible (with warnings being printed). If I missed anywhere, however, please let me know!

[breaking-change]

Closes #14468
Closes #14469
Closes #14470
Closes #14471
2014-07-05 22:51:38 +00:00
bors
b8ef5cf131 auto merge of #15225 : Ryman/rust/liburl_minor, r=alexcrichton
See commits for info, a number of these are 'breaking', although liburl is marked experimental so I'm not sure that matters so much.

First two commits will be impacted if #15138 is adopted, but it's a simple rename.
2014-07-05 19:56:39 +00:00
Alex Crichton
56f7101551 rustc: Default #[crate_name] on input, not output 2014-07-05 12:46:42 -07:00
Alex Crichton
15b680ae86 Test fixes and rebase conflicts 2014-07-05 12:46:42 -07:00
Alex Crichton
41ed455db8 rustc: Repurpose the --crate-name CLI flag
In a cargo-driven world the primary location for the name of a crate will be in
its manifest, not in the source file itself. The purpose of this flag is to
reduce required duplication for new cargo projects.

This is a breaking change because the existing --crate-name flag actually
printed the crate name. This flag was renamed to --print-crate-name, and to
maintain consistence, the --crate-file-name flag was renamed to
--print-file-name.

To maintain backwards compatibility, the --crate-file-name flag is still
recognized, but it is deprecated.

[breaking-change]
2014-07-05 12:46:42 -07:00
Alex Crichton
812637e683 test: Fix tests for crate_id removal
This involved removing some tests whose functionality was removed such as many
of the crateresolve tests
2014-07-05 12:46:42 -07:00
Alex Crichton
cc3c8bbfaf rustc: Add a flag for specifying dependencies
This comit implements a new flag, --extern, which is used to specify where a
crate is located. The purpose of this flag is to bypass the normal crate
loading/matching of the compiler to point it directly at the right file.

This flag takes the form `--extern foo=bar` where `foo` is the name of a crate
and `bar` is the location at which to find the crate. Multiple `--extern`
directives are allowed with the same crate name to specify the rlib/dylib pair
for a crate. It is invalid to specify more than one rlib or more than one dylib,
and it's required that the crates are valid rust crates.

I have also added some extensive documentation to metadata::loader about how
crate loading should work.

RFC: 0035-remove-crate-id
2014-07-05 12:45:42 -07:00
Alex Crichton
df4ea9c39a rustc: Stop putting hashes in filenames by default
The compiler will no longer insert a hash or version into a filename by default.
Instead, all output is simply based off the crate name being compiled. For
example, a crate name of `foo` would produce the following outputs:

* bin => foo
* rlib => libfoo.rlib
* dylib => libfoo.{so,dylib} or foo.dll
* staticlib => libfoo.a

The old behavior has been moved behind a new codegen flag,
`-C extra-filename=<hash>`. For example, with the "extra filename" of `bar` and
a crate name of `foo`, the following outputs would be generated:

* bin => foo (same old behavior)
* rlib => libfoobar.rlib
* dylib => libfoobar.{so,dylib} or foobar.dll
* staticlib => libfoobar.a

The makefiles have been altered to pass a hash by default to invocations of
`rustc` so all installed rust libraries will have a hash in their filename. This
is done because the standard libraries are intended to be installed into
privileged directories such as /usr/local. Additionally, it involves very few
build system changes!

RFC: 0035-remove-crate-id
[breaking-change]
2014-07-05 12:45:42 -07:00
Alex Crichton
e44c2b9bbc Add #[crate_name] attributes as necessary 2014-07-05 12:45:42 -07:00
Alex Crichton
c956b70d7b rustc: Modify crate loading to ignore versions
This commit modifies crate loading to purely work off a `crate_name` and nothing
else. This commit also changes the patterns recognized from `lib<foo>-*` to
`lib<foo>*` to accomodate the future renamings of output files.

RFC: 0035-remove-crate-id
2014-07-05 12:38:42 -07:00
Alex Crichton
1007739b20 rustc: Add a new codegen flag, -C metadata=foo
This metadata is used to drive the hash of all symbols in a crate. The flag can
be specified a multiple number of times

RFC: 0035-remove-crate-id
2014-07-05 12:38:42 -07:00
Alex Crichton
50ee1ec1b4 rustc: Remove CrateId and all related support
This commit removes all support in the compiler for the #[crate_id] attribute
and all of its derivative infrastructure. A list of the functionality removed is:

* The #[crate_id] attribute no longer exists
* There is no longer the concept of a version of a crate
* Version numbers are no longer appended to symbol names
* The --crate-id command line option has been removed

To migrate forward, rename #[crate_id] to #[crate_name] and only the name of the
crate itself should be mentioned. The version/path of the old crate id should be
removed.

For a transitionary state, the #[crate_id] attribute is still accepted if
the #[crate_name] is not present, but it is warned about if it is the only
identifier present.

RFC: 0035-remove-crate-id
[breaking-change]
2014-07-05 12:38:42 -07:00
Paolo Falabella
8cec9d495d Added num::Signed implementation to Ratio (squashed) 2014-07-05 19:50:03 +01:00
bors
c8b2a3167b auto merge of #15431 : iliekturtles/rust/13279-error-msg-order, r=pcwalton
Moved note after error to reduce confusion when the pair appears in the
middle of other errors. Closes #13279.
2014-07-05 18:11:43 +00:00
bors
aaff4e05e1 auto merge of #15429 : kballard/rust/vim_tab_conventions, r=pcwalton 2014-07-05 16:26:44 +00:00
Adolfo Ochagavía
d6f8271602 Improved example in the Guide
Fixes https://github.com/rust-lang/rust/issues/15452
2014-07-05 18:19:08 +02:00
bors
98eb5f7498 auto merge of #15428 : phildawes/rust/master, r=huonw
Fix small bug introduced in e38cb972dc: PatIdent span was incorrect
because self.last_span was being used before the ident token was
parsed.
2014-07-05 14:41:44 +00:00
Jakub Wieczorek
1aa23b8e1c Fix #15453 2014-07-05 16:32:13 +02:00
bors
c8bbba9a4b auto merge of #15427 : aochagavia/rust/parse, r=pcwalton 2014-07-05 12:56:44 +00:00
bors
342321def6 auto merge of #15442 : luqmana/rust/odp, r=pnkfelix
Inadvertently changed the order in which destructors ran in certain cases with #15076.

Fixes #15438.
2014-07-05 11:11:47 +00:00
Luqman Aden
e9e5ea2f90 libcore: Fix Items iterator for zero sized types. 2014-07-05 02:49:03 -07:00