Commit Graph

58447 Commits

Author SHA1 Message Date
Nicholas Nethercote
eca1cc957f Add FxHasher, a faster alternative to FnvHasher. 2016-11-08 15:14:00 +11:00
bors
57f971bc16 Auto merge of #36365 - matthew-piziak:silent-overflow, r=eddyb
fix silent overflows on `Step` impls

Part of https://github.com/rust-lang/rust/issues/36110

r? @eddyb
2016-11-07 11:48:16 -08:00
bors
ec0d1ceb42 Auto merge of #37625 - xen0n:rustbuild-mips, r=alexcrichton
rustbuild: support MIPS host builds

There is a *little* code duplication, but primarily for sake of "match exhaustiveness". Let's blame Linux/MIPS for not exposing endianness explicitly in `uname -m` (that's user-space interface and as such is frozen).

Currently the build won't work as we have to wait for a new stage0 for the MIPS host compilers, but this paves the way to self-hosted Rust on MIPS. The cross-compiled MIPS binaries are confirmed to work on the Loongson 3A2000 (MIPS64r2-compatible) so we have plenty of confidence that they'll work on other MIPS platforms too, as Linux/MIPS user-space ABI is consistent across machines of the same bitness.

r? @alexcrichton
2016-11-07 08:39:16 -08:00
bors
c9f16bbc41 Auto merge of #37624 - xen0n:remove-bogus-mipsel-arches, r=alexcrichton
Remove mention of mipsel target_arch

This is the only remaining instance in rustc. All others were in the libc repo, removed with rust-lang/libc#445.

Actually there's more to clean in `libsyntax/abi.rs`, but let's save that for another commit...
2016-11-07 04:14:00 -08:00
bors
045a727b83 Auto merge of #37605 - dsprenkels:arc-max-refcount, r=alexcrichton
Fix Arc::clone()'s MAX_REFCOUNT check (off-by-one)

Before, the strong count of an `Arc` could be set to
`MAX_REFCOUNT + 1`, because when this happened, `old_size` would
be exactly `MAX_REFCOUNT`. `Arc::clone()` would not abort.

This commit changes the check in `Arc::clone()` to also abort if
the old value is equal to `MAX_REFCOUNT`, because then the new
value will be equal to `MAX_REFCOUNT + 1`.

A test would require allocating memory for `isize::MAX` pointers.
This would probably crash any machine, so no test is submitted
with this commit.
2016-11-06 23:05:58 -08:00
Wang Xuerui
0d433a8feb rustbuild: support MIPS host builds
There is a *little* code duplication, but primarily for sake of "match
exhaustiveness". Let's blame Linux/MIPS for not exposing endianness
explicitly in `uname -m` (that's user-space interface and as such is
frozen).

Currently the build won't work as we have to wait for a new stage0 for
the MIPS host compilers, but this paves the way to self-hosted Rust on
MIPS. The cross-compiled MIPS binaries are confirmed to work on the
Loongson 3A2000 (MIPS64r2-compatible) so we have plenty of confidence
that they'll work on other MIPS platforms too, as Linux/MIPS user-space
ABI is consistent across machines of the same bitness.
2016-11-07 14:29:15 +08:00
Wang Xuerui
a28c01bdf9 Remove mention of mipsel target_arch
The `mipsel` `target_arch` was introduced with the initial MIPSel
support (rust-lang/rust@82ec1aef29),
but was subsequently removed with implementation of the Flexible Target
Specification (Rust RFC 0131,
rust-lang/rust@3a8f4ec32a).
This is the only remaining instance in rustc. All others are in the libc
repo, and are fixed in rust-lang/libc@b3676593f6.
2016-11-07 14:15:58 +08:00
bors
09fc1af9d8 Auto merge of #37506 - jseyfried:improve_shadowing_checks, r=nrc
macros: improve shadowing checks

This PR improves macro-expanded shadowing checks to work with out-of-(pre)order expansion.

Out-of-order expansion became possible in #37084, so this technically a [breaking-change] for nightly.
The regression test from this PR is an example of code that would break.

r? @nrc
2016-11-06 19:12:28 -08:00
bors
8e2b57d3e4 Auto merge of #37619 - TimNN:aarch64-fuchsia-abi-blacklist, r=alexcrichton
use arm abi blacklist for aarch64 fuchsia

r? @alexcrichton
2016-11-06 15:59:45 -08:00
bors
4742008742 Auto merge of #37617 - pweyck:force-static-llvm-linking, r=alexcrichton
Force static linking of LLVM

Run `llvm-config` with `--link-static` if available, to force static linking of LLVM.
This option was added in LLVM 3.8.

This is my first pull request, any feedback is welcome!

Fixes #36854
See also: #36996
2016-11-06 12:47:14 -08:00
Tim Neumann
9bae00332c use arm abi blacklist for aarch64 fuchsia 2016-11-06 20:41:46 +01:00
Daan Sprenkels
99aaccd32f Add a comment to Arc::MAX_REFCOUNT
The constant name `MAX_REFCOUNT` suggests that the value is a
_hard_ limit on the amount of references to an `Arc`. This is
a more soft limit however. This commit adds a comment to the
constant to annotate this.

See also: PR #37605
2016-11-06 20:07:28 +01:00
bors
2a44315fc7 Auto merge of #37616 - jneem:master, r=alexcrichton
Add test for issue 18060.

Closes #18060
2016-11-06 09:34:15 -08:00
pweyck
bcfbbd8645 Force static linking of LLVM
Run llvm-config with "--link-static" if available, to force static linking of LLVM.
This option was added in LLVM 3.8.

Fixes #36854
See also: #36996
2016-11-06 16:33:34 +01:00
Joe Neeman
6829c3ded8 Add test for issue 18060. 2016-11-06 16:32:49 +01:00
bors
5fe733a159 Auto merge of #37404 - eddyb:lazy-4, r=nikomatsakis
[4/n] rustc: harden against InferOk having obligations in more cases.

_This is part of a series ([prev](https://github.com/rust-lang/rust/pull/37402) | [next](https://github.com/rust-lang/rust/pull/37408)) of patches designed to rework rustc into an out-of-order on-demand pipeline model for both better feature support (e.g. [MIR-based](https://github.com/solson/miri) early constant evaluation) and incremental execution of compiler passes (e.g. type-checking), with beneficial consequences to IDE support as well.
If any motivation is unclear, please ask for additional PR description clarifications or code comments._

<hr>

This adds more asserts that `InferOk` results have no obligations, pending completion of #32730.

Each of these could accidentally drop obligations on the floor if they start getting produced by unification, and a future change does just that, in order to produce a "shallow success" (hopefully leading to ambiguities during trait selection), _without_ the possibility of an eventual success - mostly guarded by ICEs for now.
2016-11-06 06:22:38 -08:00
Eduard Burtescu
aee1ee3cc2 rustc: harden against InferOk having obligations in more cases. 2016-11-06 16:22:11 +02:00
bors
161f2623bd Auto merge of #37386 - johnthagen:Self-reference-example, r=GuillaumeGomez
Add example using Self to reference

When I first came across `Self` I had a hard time finding references to it in the docs (and it's also been asked about on [StackOverflow](http://stackoverflow.com/questions/32304595/whats-the-difference-between-self-and-self).

I hope this example provides someone who comes across it for the first time a little more help.  If there is a better way to show an example actually using `Self`, I'm happy to modify this.  It was just the simplest place to start I could see.
2016-11-06 02:28:58 -08:00
bors
3fc8304fd9 Auto merge of #37597 - alexcrichton:rollup, r=alexcrichton
Rollup of 24 pull requests

- Successful merges: #37255, #37317, #37408, #37410, #37422, #37427, #37470, #37501, #37537, #37556, #37557, #37564, #37565, #37566, #37569, #37574, #37577, #37579, #37583, #37585, #37586, #37587, #37589, #37596
- Failed merges: #37521, #37547
2016-11-05 22:34:25 -07:00
Alex Crichton
bdacb63f5a Only test docs and such for the host 2016-11-05 19:29:53 -07:00
johnthagen
434c314405 Use From trait as an example usage of Self. 2016-11-05 18:21:17 -04:00
Alex Crichton
18ee04b3df Merge branch 'gdb-next-gen' of https://github.com/TimNN/rust into rollup 2016-11-05 10:51:34 -07:00
Alex Crichton
11251e59b9 Fix tests from the rollup 2016-11-05 10:51:04 -07:00
Alex Crichton
e126f3c6c6 Merge branch 'selfgate' of https://github.com/petrochenkov/rust into rollup 2016-11-05 10:50:47 -07:00
Alex Crichton
0eff43ff75 Merge branch 'new-rustbuild' into rollup 2016-11-05 10:50:26 -07:00
Alex Crichton
9847bd3d68 Rollup merge of #37596 - est31:master, r=alexcrichton
Add error when proc_macro_derive is used not on functions

Fixes #37590
2016-11-05 10:50:25 -07:00
Alex Crichton
8e5c91a6fb Rollup merge of #37589 - raphlinus:fuchsia_random, r=alexcrichton
std: Track change to cprng syscall signature (Fuchsia)

The mx_cprng_draw syscall has changed signature to separate the status
and size return values, rather than multiplexing them into a single
value with errors interpreted as a negative value. This patch tracks
that change.
2016-11-05 10:50:25 -07:00
Alex Crichton
5bce6ad16a Rollup merge of #37587 - ollie27:to_mut, r=alexcrichton
Remove recursive call from Cow::to_mut

It seems to prevent it from being inlined.
2016-11-05 10:50:25 -07:00
Alex Crichton
78f18647e8 Rollup merge of #37586 - TimNN:fix-37559, r=alexcrichton
fix #37559: update compiler-rt

Fixes #37559

r? @alexcrichton
2016-11-05 10:50:25 -07:00
Alex Crichton
727f1d3f16 Rollup merge of #37585 - leodasvacas:change_into_to_from, r=alexcrichton
Change `Into<Vec<u8>> for String` and `Into<OsString> for PathBuf` to From

Fixes #37561. First contribution, happy with any and all feedback!
2016-11-05 10:50:25 -07:00
Alex Crichton
0670d4b7f3 Rollup merge of #37583 - michaelwoerister:hir-stats, r=alexcrichton
Add `-Z hir-stats` for collecting statistics on HIR and AST

The data collected will be printed to the commandline and looks like the following:

```
// stats for libcore

PRE EXPANSION AST STATS

Name                Accumulated Size         Count     Item Size
----------------------------------------------------------------
TypeBinding                    2_280            57            40
Mod                            3_560            89            40
PathListItem                   6_516           181            36
Variant                        7_872            82            96
LifetimeDef                   21_280           380            56
StructField                   22_880           260            88
Lifetime                      23_800         1_190            20
Local                         30_192           629            48
ForeignItem                   31_504           179           176
Arm                           42_880           670            64
Mac                           46_960           587            80
FnDecl                        57_792         1_204            48
TraitItem                     69_504           362           192
TyParamBound                  98_280           945           104
Block                        108_384         2_258            48
Stmt                         144_720         3_618            40
ImplItem                     230_272         1_028           224
Item                         467_456         1_826           256
Pat                          517_776         4_623           112
Attribute                    745_680        15_535            48
Ty                         1_114_848         9_954           112
PathSegment                1_218_528        16_924            72
Expr                       3_082_408        20_279           152
----------------------------------------------------------------
Total                      8_095_372

POST EXPANSION AST STATS

Name                Accumulated Size         Count     Item Size
----------------------------------------------------------------
MacroDef                       1_056            12            88
Mod                            3_400            85            40
TypeBinding                    4_280           107            40
PathListItem                   6_516           181            36
Variant                        7_872            82            96
StructField                   24_904           283            88
ForeignItem                   31_504           179           176
TraitItem                     69_504           362           192
Local                         85_008         1_771            48
Arm                          100_288         1_567            64
Lifetime                     123_980         6_199            20
LifetimeDef                  126_728         2_263            56
TyParamBound                 297_128         2_857           104
FnDecl                       305_856         6_372            48
Block                        481_104        10_023            48
Stmt                         535_120        13_378            40
Item                       1_469_952         5_742           256
Attribute                  1_629_840        33_955            48
ImplItem                   1_732_864         7_736           224
Pat                        2_360_176        21_073           112
PathSegment                5_888_448        81_784            72
Ty                         6_237_168        55_689           112
Expr                      12_013_320        79_035           152
----------------------------------------------------------------
Total                     33_536_016

HIR STATS

Name                Accumulated Size         Count     Item Size
----------------------------------------------------------------
MacroDef                         864            12            72
Mod                            2_720            85            32
TypeBinding                    3_424           107            32
PathListItem                   5_068           181            28
Variant                        6_560            82            80
StructField                   20_376           283            72
ForeignItem                   27_208           179           152
WherePredicate                43_776           684            64
TraitItem                     52_128           362           144
Decl                          68_992         2_156            32
Local                         89_184         1_858            48
Arm                           94_368         1_966            48
LifetimeDef                  108_624         2_263            48
Lifetime                     123_980         6_199            20
Stmt                         168_000         4_200            40
TyParamBound                 251_416         2_857            88
FnDecl                       254_880         6_372            40
Block                        583_968        12_166            48
Item                       1_240_272         5_742           216
ImplItem                   1_361_536         7_736           176
Attribute                  1_620_480        33_760            48
Pat                        2_073_120        21_595            96
Path                       2_385_856        74_558            32
Ty                         4_455_040        55_688            80
PathSegment                5_587_904        87_311            64
Expr                       7_588_992        79_052            96
----------------------------------------------------------------
Total                     28_218_736
```
2016-11-05 10:50:25 -07:00
Alex Crichton
50def8ea3c Rollup merge of #37579 - liigo:defaulthasher, r=alexcrichton
reference full path DefaultHasher

Since `DefaultHasher` does not in scope, it's not obvious where to find it.
2016-11-05 10:50:24 -07:00
Alex Crichton
07cf4b418f Rollup merge of #37577 - nnethercote:shrink-Expr-slightly, r=eddyb
Shrink `hir::Expr` slightly

r? @eddyb
2016-11-05 10:50:24 -07:00
Alex Crichton
638436e55f Rollup merge of #37574 - ollie27:cow_add, r=alexcrichton
Fix issues with the Add/AddAssign impls for Cow<str>

* Correct the stability attributes.
* Make Add and AddAssign actually behave the same.
* Use String::with_capacity when allocating a new string.
* Fix the tests.
2016-11-05 10:50:24 -07:00
Alex Crichton
b9cbbe184a Rollup merge of #37569 - jseyfried:improve_expansion_perf, r=eddyb
macros: improve expansion performance

This PR fixes that regression, further improves performance on recursive, `tt`-heavy workloads, and makes a variety of other improvements to parsing and expansion performance.

Expansion performance improvements:

| Test case      | Run-time | Memory usage |
| -------------- | -------- | ------------ |
| libsyntax      | 8%       | 10%          |
| librustc       | 15%      | 6%           |
| librustc_trans | 30%      | 6%           |
| #37074         | 20%      | 15%          |
| #34630         | 40%      | 8%           |

r? @eddyb
2016-11-05 10:50:24 -07:00
Alex Crichton
9f882b997e Rollup merge of #37566 - brson:env, r=alexcrichton
Set RUSTC_BOOTSTRAP to some value.

Environment variables on windows can't be empty.
2016-11-05 10:50:24 -07:00
Alex Crichton
b9f18bf79b Rollup merge of #37565 - mglagla:peek_use_as_ref, r=alexcrichton
Peekable::peek(): Use Option::as_ref()

Replace the match expression in .peek() with Option::as_ref() since it's the same functionality.
2016-11-05 10:50:23 -07:00
Alex Crichton
7c7bc2c296 Rollup merge of #37564 - Mark-Simulacrum:sized-ice, r=eddyb
Fix ICE when querying DefId on Def::Err.

Also moves computations into check that `kind_id` is `Ok(_)`, which is in theory an optimization, though I expect it's minor.

Fixes #37534.

r? @eddyb.
2016-11-05 10:50:23 -07:00
Alex Crichton
b4aee37224 Rollup merge of #37557 - TimNN:fix-36954, r=eddyb
Use DefId's in const eval for cross-crate const fn's

Fixes #36954.

r? @eddyb

cc @raphaelcohn
2016-11-05 10:50:23 -07:00
Alex Crichton
ee90485e24 Rollup merge of #37556 - dinfuehr:main_frame_pointer, r=eddyb
set frame pointer elimination attribute for main

The rustc-generated function `main` should respect the same config for
frame pointer elimination as the rest of code.
2016-11-05 10:50:23 -07:00
Alex Crichton
112a4ff748 Rollup merge of #37537 - GuillaumeGomez:error_kind_doc, r=steveklabnik
Add missing urls for ErrorKind's variants

r? @steveklabnik
2016-11-05 10:50:23 -07:00
Alex Crichton
8a38b24d95 Rollup merge of #37501 - alexcrichton:windows-subsystem, r=brson
rustc: Add knowledge of Windows subsystems.

This commit is an implementation of [RFC 1665] which adds support for the
`#![windows_subsystem]` attribute. This attribute allows specifying either the
"windows" or "console" subsystems on Windows to the linker.

[RFC 1665]: https://github.com/rust-lang/rfcs/blob/master/text/1665-windows-subsystem.md

Previously all Rust executables were compiled as the "console" subsystem which
meant that if you wanted a graphical application it would erroneously pop up a
console whenever opened. When compiling an application, however, this is
undesired behavior and the "windows" subsystem is used instead to have control
over user interactions.

This attribute is validated, but ignored on all non-Windows platforms.

cc #37499
2016-11-05 10:50:23 -07:00
Alex Crichton
1d41d5bd01 Rollup merge of #37470 - arthurprs:sip-smaller, r=alexcrichton
Don't reuse RandomState seeds

cc #36481
2016-11-05 10:50:22 -07:00
Alex Crichton
1ff3dfd25c Rollup merge of #37427 - nnethercote:opt-IchHasher, r=michaelwoerister
Reduce the number of bytes hashed by IchHasher.

IchHasher uses blake2b hashing, which is expensive, so the fewer bytes hashed
the better. There are two big ways to reduce the number of bytes hashed.
- Filenames in spans account for ~66% of all bytes (for builds with debuginfo).
  The vast majority of spans have the same filename for the start of the span
  and the end of the span, so hashing the filename just once in those cases is
  a big win.
- u32 and u64 and usize values account for ~25%--33% of all bytes (for builds
  with debuginfo). The vast majority of these are small, i.e. fit in a u8, so
  shrinking them down before hashing is also a big win.

This PR implements these two optimizations. I'm certain the first one is safe.
I'm about 90% sure that the second one is safe.

Here are measurements of the number of bytes hashed when doing
debuginfo-enabled builds of stdlib and
rustc-benchmarks/syntex-0.42.2-incr-clean.

```
                    stdlib   syntex-incr
                    ------   -----------
original       156,781,386   255,095,596
half-SawSpan   106,744,403   176,345,419
short-ints      45,890,534   118,014,227
no-SawSpan[*]    6,831,874    45,875,714

[*] don't hash the SawSpan at all. Not part of this PR, just implemented for
    comparison's sake.
```

For debug builds of syntex-0.42.2-incr-clean, the two changes give a 1--2%
speed-up.
2016-11-05 10:50:22 -07:00
Alex Crichton
041f890cfe Rollup merge of #37422 - bluss:wrapping-offset, r=alexcrichton
Add .wrapping_offset() methods

.wrapping_offset() exposes the arith_offset intrinsic in the core
module (as methods on raw pointers, next to offset). This is the
first step in making it possible to stabilize the interface later.

`arith_offset` is a useful tool for developing iterators for two
reasons:
1. `arith_offset` is used by the slice's iterator, the most important
   iterator in libcore, and it is natural that Rust users need the same
   power available to implement similar iterators.
2. It is a good way to implement raw pointer iterations with step
   greater than one.

The name seems to fit the style of methods like "wrapping_add".
2016-11-05 10:50:22 -07:00
bors
cae6ab1c45 Auto merge of #37470 - arthurprs:sip-smaller, r=alexcrichton
Don't reuse RandomState seeds

cc #36481
2016-11-05 04:32:04 -07:00
Tim Neumann
d2cb515ab0 ignore gdb check for android 2016-11-05 10:23:55 +01:00
bors
08839965f9 Auto merge of #37427 - nnethercote:opt-IchHasher, r=michaelwoerister
Reduce the number of bytes hashed by IchHasher.

IchHasher uses blake2b hashing, which is expensive, so the fewer bytes hashed
the better. There are two big ways to reduce the number of bytes hashed.
- Filenames in spans account for ~66% of all bytes (for builds with debuginfo).
  The vast majority of spans have the same filename for the start of the span
  and the end of the span, so hashing the filename just once in those cases is
  a big win.
- u32 and u64 and usize values account for ~25%--33% of all bytes (for builds
  with debuginfo). The vast majority of these are small, i.e. fit in a u8, so
  shrinking them down before hashing is also a big win.

This PR implements these two optimizations. I'm certain the first one is safe.
I'm about 90% sure that the second one is safe.

Here are measurements of the number of bytes hashed when doing
debuginfo-enabled builds of stdlib and
rustc-benchmarks/syntex-0.42.2-incr-clean.

```
                    stdlib   syntex-incr
                    ------   -----------
original       156,781,386   255,095,596
half-SawSpan   106,744,403   176,345,419
short-ints      45,890,534   118,014,227
no-SawSpan[*]    6,831,874    45,875,714

[*] don't hash the SawSpan at all. Not part of this PR, just implemented for
    comparison's sake.
```

For debug builds of syntex-0.42.2-incr-clean, the two changes give a 1--2%
speed-up.
2016-11-05 01:10:57 -07:00
bors
e96b9d2bb4 Auto merge of #37422 - bluss:wrapping-offset, r=alexcrichton
Add .wrapping_offset() methods

.wrapping_offset() exposes the arith_offset intrinsic in the core
module (as methods on raw pointers, next to offset). This is the
first step in making it possible to stabilize the interface later.

`arith_offset` is a useful tool for developing iterators for two
reasons:
1. `arith_offset` is used by the slice's iterator, the most important
   iterator in libcore, and it is natural that Rust users need the same
   power available to implement similar iterators.
2. It is a good way to implement raw pointer iterations with step
   greater than one.

The name seems to fit the style of methods like "wrapping_add".
2016-11-04 17:48:07 -07:00
Alex Crichton
1a0963292a Rollup merge of #37408 - eddyb:lazy-5, r=nikomatsakis
[5/n] rustc: record the target type of every adjustment.

_This is part of a series ([prev](https://github.com/rust-lang/rust/pull/37404) | [next](https://github.com/rust-lang/rust/pull/37412)) of patches designed to rework rustc into an out-of-order on-demand pipeline model for both better feature support (e.g. [MIR-based](https://github.com/solson/miri) early constant evaluation) and incremental execution of compiler passes (e.g. type-checking), with beneficial consequences to IDE support as well.
If any motivation is unclear, please ask for additional PR description clarifications or code comments._

<hr>

The first commit rearranges `tcx.tables` so that all users go through `tcx.tables()`. This in preparation for per-body `Tables` where they will be requested for a specific `DefId`. Included to minimize churn.

The rest of the changes focus on adjustments, there are some renamings, but the main addition is the target type, always available in all cases (as opposed to just for unsizing where it was previously needed).

Possibly the most significant effect of this change is that figuring out the final type of an expression is now _always_ just one successful `HashMap` lookup (either the adjustment or, if that doesn't exist, the node type).
2016-11-04 16:49:28 -07:00