Commit Graph

58301 Commits

Author SHA1 Message Date
bors
49c36bf16f Auto merge of #36306 - nagisa:mir-local-cleanup, r=eddyb
A way to remove otherwise unused locals from MIR

There is a certain amount of desire for a pass which cleans up the provably unused variables (no assignments or reads). There has been an implementation of such pass by @scottcarr, and another (two!) implementations by me in my own dataflow efforts.

PR like https://github.com/rust-lang/rust/pull/35916 proves that this pass is useful even on its own, which is why I cherry-picked it out from my dataflow effort.

@nikomatsakis previously expressed concerns over this pass not seeming to be very cheap to run and therefore unsuitable for regular cleanup duties. Turns out, regular cleanup of local declarations is not at all necessary, at least now, because majority of passes simply do not (or should not) care about them. That’s why it is viable to only run this pass once (perhaps a few more times in the future?) per function, right before translation.

r? @eddyb or @nikomatsakis
2016-11-03 22:58:55 -07:00
bors
ac919fcd9d Auto merge of #37541 - nikomatsakis:issue-37291, r=brson
Use impl obligations as initial environment for specialization

This corrects a small regression in specialization that crept in, I think as part of the refactoring to introduce arenas. I also made an experiment (in the last commit) to cleanup the code to be more aggressive about normalization. As the commit log notes, I am not 100% sure that this is correct, but it feels safer, and I think that at worst it yields *more* ICEs (as opposed to admitting faulty code). I'll schedule a crater run to check beyond the testbase.

Fixes #37291.

r? @aturon
2016-11-02 22:58:01 -07:00
Simonas Kazlauskas
475236770f A way to remove otherwise unused locals from MIR
Replaces the hack where a similar thing is done within trans.
2016-11-03 06:17:01 +02:00
bors
f9f45c6dac Auto merge of #36993 - nnethercote:obligation, r=nikomatsakis
Optimize ObligationForest's NodeState handling.

This commit does the following.
- Changes `NodeState` from an enum to a `bitflags`. This makes it
  possible to check against multiple possible values in a single bitwise
  operation.
- Replaces all the hot `match`es involving `NodeState` with `if`/`else`
  chains that ensure that cases are handled in the order of frequency.
- Partially inlines two functions, `find_cycles_from_node` and
  `mark_as_waiting_from`, at two call sites in order to avoid function
  unnecessary function calls on hot paths.
- Fully inlines and removes `is_popped`.

These changes speeds up rustc-benchmarks/inflate-0.1.0 by about 7% when
doing debug builds with a stage1 compiler.

r? @arielb1
2016-11-02 17:46:44 -07:00
Niko Matsakis
b4f910d900 just use full-normalization when for the impl trait ref
This seems better because I want to avoid the situation where unresolved
inference variables make it into the environment.  On the other hand, I
am not 100% sure that this is correct. My assumption was that the WF
check should ensure that this normalization can succeed. But it occurs
to me that the WF checks may need to make use of the `specializes`
predicate themselves, and hence we may have a kind of cycle here (this
is a bigger problem with spec in any case that we need to resolve).

On the other hand, this should just cause extra errors I think, so it
seems like a safe thing to attempt. Certainly all tests pass.
2016-11-02 18:18:24 -04:00
Niko Matsakis
d9bc86032d normalize trait-ref in context of impl
The `specializes()` function was trying to normalize the impl trait in
an empty environment. This could lead to inexplicable failures.
2016-11-02 18:18:24 -04:00
Niko Matsakis
797e0420e3 add #32791 test case 2016-11-02 18:18:24 -04:00
bors
5665bdf3e3 Auto merge of #37540 - jonathandturner:rollup, r=jonathandturner
Rollup of 10 pull requests

- Successful merges: #37351, #37405, #37473, #37482, #37488, #37498, #37502, #37513, #37517, #37523
- Failed merges: #37521
2016-11-02 14:29:31 -07:00
Jonathan Turner
0befab2343 Rollup merge of #37523 - d-unseductable:deref_mut_lifetimes, r=bluss
Elide lifetimes in DerefMut documentation

 - Elide lifetimes to increase the readability of `DerefMut` examples
2016-11-02 15:09:43 -04:00
Jonathan Turner
805aecc36a Rollup merge of #37517 - Mark-Simulacrum:add-unwrap-default-tracking-issue, r=alexcrichton
Add tracking issue number to Result::unwrap_or_default unstable annotation.

Implemented in https://github.com/rust-lang/rust/pull/37299.

Tracking issue: https://github.com/rust-lang/rust/issues/37516.
2016-11-02 15:09:42 -04:00
Jonathan Turner
27f41b7001 Rollup merge of #37513 - michaelwoerister:hash-panic-spans, r=nikomatsakis
ICH: Hash expression spans if their source location is captured for panics.

Since the location of some expressions is captured in error message constants, it has an influence on machine code and consequently we need to take them into account by the incr. comp. hash. This PR makes this happen for `+, -, *, /, %` and for array indexing -- let me know if I forgot anything.

In the future we might want to change the codegen strategy for those error messages, so that they are stored in a separate object file with a stable symbol name, so that only this object file has to be regenerated when source locations change. This strategy would also eliminate unnecessary duplications due  to monomorphization, as @arielb1 has pointed out on IRC. I opened https://github.com/rust-lang/rust/issues/37512, so we don't forget about this.

r? @nikomatsakis
2016-11-02 15:09:42 -04:00
Jonathan Turner
62e026be5a Rollup merge of #37502 - CryZe:patch-4, r=sfackler
Add missing space in mutable_transmutes lint
2016-11-02 15:09:42 -04:00
Jonathan Turner
b333860611 Rollup merge of #37498 - sanxiyn:unused-type-alias, r=eddyb
Remove unused type aliases

Found by extending the dead code lint. The lint itself is work in progress because of false positives.

cc #37455.
2016-11-02 15:09:42 -04:00
Jonathan Turner
d2f4a9d7be Rollup merge of #37488 - frewsxcv:quiet-travis, r=alexcrichton
Use quieter test output when running tests on Travis CI.

Fixes https://github.com/rust-lang/rust/issues/36788.
2016-11-02 15:09:41 -04:00
Jonathan Turner
0a20ec3743 Rollup merge of #37482 - matwey:configure-arm, r=alexcrichton
Misc fixes for configure

Currently,
`./configure` at armv6 machines ends up with

```
configure: error: unknown CPU type: armv6l
```

`./configure` at armv7 machines **silently** produces build for armv6 (compatible, but suboptimal)

```
configure: CFG_BUILD            := arm-unknown-linux-gnueabihf
```
2016-11-02 15:09:41 -04:00
Jonathan Turner
3752673cbc Rollup merge of #37473 - joshtriplett:doc-copyedit-write-writeln, r=alexcrichton
Copyediting on documentation for write! and writeln!

Fix various sentence fragments, missing articles, and other grammatical issues in the documentation for write! and writeln!.

Also fix the links (and link names) for common return types.

(Noticed when preparing https://github.com/rust-lang/rust/pull/37472 ; posted separately to avoid mixing the new documentation with copyedits to existing documentation.)
2016-11-02 15:09:41 -04:00
Jonathan Turner
dbb2506b72 Rollup merge of #37405 - mikhail-m1:dnlle, r=jonathandturner
Improve "Doesn't live long enough" error

case with different lifetime scope

issue #36537 part of #35233
r? @jonathandturner
2016-11-02 15:09:41 -04:00
Jonathan Turner
d00e5e9343 Rollup merge of #37351 - Amanieu:consume, r=alexcrichton
Prevent exhaustive matching of Ordering to allow for future extension

The C++11 atomic memory model defines a `memory_order_consume` ordering which is generally equivalent to `memory_order_acquire` but can allow better code generation by avoiding memory barrier instructions. Most compilers (including LLVM) currently do not implement this ordering directly and instead treat it identically to `memory_order_acquire`, including adding a memory barrier instruction.

There is currently [work](http://open-std.org/Jtc1/sc22/wg21/docs/papers/2016/p0098r1.pdf) to support consume ordering in compilers, and it would be a shame if Rust did not support this. This PR therefore reserves a `__Nonexhaustive` variant in `Ordering` so that adding a new ordering is not a breaking change in the future.

This is a [breaking-change] since it disallows exhaustive matching on `Ordering`, however a search of all Rust code on Github shows that there is no code that does this. This makes sense since `Ordering` is typically only used as a parameter to an atomic operation.
2016-11-02 15:09:41 -04:00
bors
0ca9967af7 Auto merge of #36948 - brson:sys, r=brson
More refactoring to obey platform abstraction lint

The most interesting things here are moving `std/sys/common` to `std/sys_common`, and `std/num/{f32,f64}.rs` to `std/{f32,f64}.rs`, and adding more documentation to `std/lib.rs`.

r? @alexcrichton
2016-11-02 08:44:33 -07:00
Michael Woerister
0e391bf22c ICH: Add test case for when overflow checks are disabled. 2016-11-02 10:00:11 -04:00
bors
acfe959701 Auto merge of #37054 - rednum:master, r=alexcrichton
Add or and or_else for ordering.

Fixes https://github.com/rust-lang/rust/issues/37053 (see discussion in rust-lang/rfcs#1677).
2016-11-02 05:37:33 -07:00
bors
35a1fefa88 Auto merge of #36131 - Florob:entry_typeck, r=eddyb
typeck: Fix error reporting of wrong entry function signatures

Expected and actual type were switched, this was introduced by
refactoring in 8eb12d91aa.
2016-11-01 23:50:05 -07:00
bors
3fba503bf5 Auto merge of #37514 - GuillaumeGomez:rollup, r=GuillaumeGomez
Rollup of 7 pull requests

- Successful merges: #36849, #37059, #37296, #37316, #37484, #37485, #37495
- Failed merges:
2016-11-01 19:38:16 -07:00
Nicholas Nethercote
7b33f7e3e7 Optimize ObligationForest's NodeState handling.
This commit partially inlines two functions, `find_cycles_from_node` and
`mark_as_waiting_from`, at two call sites in order to avoid function
unnecessary function calls on hot paths.

It also fully inlines and removes `is_popped`.

These changes speeds up rustc-benchmarks/inflate-0.1.0 by about 2% when
doing debug builds with a stage1 compiler.
2016-11-02 13:37:10 +11:00
Dmitry Gritsay
7d5b788edf Elide lifetimes in DerefMut documentation
- Elide lifetimes to increase the readability
   of `DerefMut` examples
2016-11-01 23:18:02 +02:00
bors
7c69b0d5ae Auto merge of #37491 - Mark-Simulacrum:closure-ice, r=eddyb
Fix ICE when printing closures, and other similar types

Follow-up of https://github.com/rust-lang/rust/pull/37459, further fixes those problems.

Potentially actually fixes #36622, though @eddyb may want to not let that close if the rename of RUST_LOG is deemed part of that issue.

Potentially should be beta-nominated as well?

r? @eddyb
2016-11-01 12:20:03 -07:00
Brian Anderson
6135cbc9e2 std: Flatten the num directory to reflect the module layout
This makes it dissimilar to how core is structured on disk, but
more predictable on its own.
2016-11-01 17:08:24 +00:00
Brian Anderson
c251884575 Clean up and add more comments to libstd/lib.rs 2016-11-01 17:08:24 +00:00
Brian Anderson
8f5bb1f7c0 std: Remove unused test feature 2016-11-01 17:08:24 +00:00
Brian Anderson
ee71dc5476 Document sys_common and sys 2016-11-01 17:08:24 +00:00
Brian Anderson
ca30691813 std: Move sys_common to libstd/sys_common
Make the directory structure reflect the module structure. I've always
found the existing structure confusing.
2016-11-01 17:08:24 +00:00
Brian Anderson
f3a709dc52 std: Move platform-specific out of sys_common::util 2016-11-01 17:08:24 +00:00
Brian Anderson
219c018894 std: Move platform-specific code out of libstd/lib.rs 2016-11-01 17:08:24 +00:00
Brian Anderson
6d54cd4b2c std: Move a plattform-specific constant to sys::stdio 2016-11-01 17:08:24 +00:00
Brian Anderson
8b2600dbf9 Document reasoning for supporting both fast and OS TLS in the same bin 2016-11-01 17:08:24 +00:00
Brian Anderson
568840707c std: Move elf TLS to sys::fast_thread_local 2016-11-01 17:08:24 +00:00
Mikhail Modin
a0e7e357a7 Improve "Doesn't live long enough" error
case with different lifetime with spans
2016-11-01 19:39:28 +03:00
Mark-Simulacrum
6720e0191c Add tracking issue number to Result::unwrap_or_default unstable annotation. 2016-11-01 09:47:09 -06:00
Guillaume Gomez
f5c192a4b7 Rollup merge of #37495 - buntine:master, r=steveklabnik
Commented out final 'main' function in order to fit within pattern of…

… other examples and prevent incorrect indentation
2016-11-01 16:15:52 +01:00
Guillaume Gomez
d2f5d26a71 Rollup merge of #37485 - xfix:patch-2, r=steveklabnik
Don't mention "*" dependency version in guessing game example

It's a bad practice as far [RFC 1241](https://github.com/rust-lang/rfcs/blob/master/text/1241-no-wildcard-deps.md) is concerned, and introducing it in early tutorial may as well make it feel legitimate.
2016-11-01 16:15:52 +01:00
Guillaume Gomez
d5a2510574 Rollup merge of #37484 - pfrenssen:patch-1, r=steveklabnik
Update "Testing" chapter for 1.12

I followed the "Testing" chapter using Rust 1.12.1 but there are some differences. By default the `tests` module is now also generated by `cargo new`, and the console output is updated.
2016-11-01 16:15:52 +01:00
Guillaume Gomez
7e805eae8e Rollup merge of #37316 - ollie27:docs_links, r=GuillaumeGomez
Fix a few links in the docs

r? @steveklabnik
2016-11-01 16:15:52 +01:00
Guillaume Gomez
ed96e4fd2e Rollup merge of #37296 - srinivasreddy:librustc_driver, r=nikomatsakis
run rustfmt on librustc_driver folder
2016-11-01 16:15:51 +01:00
Guillaume Gomez
9820bd02a1 Rollup merge of #37059 - jfirebaugh:unused-RangeExpression, r=alexcrichton
Remove TypeOrigin::RangeExpression

This variant became unused in #30884.
2016-11-01 16:15:51 +01:00
Guillaume Gomez
79d3d26c2e Rollup merge of #36849 - diwic:69-fromutf8-doc, r=alexcrichton
str: Fix documentation typo

from_utf8 returns a Result, not an Option.

Signed-off-by: David Henningsson diwic@ubuntu.com
2016-11-01 16:15:51 +01:00
Marcin Fatyga
655effedf2 Merge branch 'master' of https://github.com/rust-lang/rust
Conflicts:
	src/libcoretest/lib.rs
2016-11-01 15:26:22 +01:00
bors
ea4b94dab0 Auto merge of #37332 - nikomatsakis:incr-comp-benchmark-2, r=michaelwoerister
add more incremental reuse test cases

r? @michaelwoerister

This is basically a port of the "private method in impl". It works better when it's a top-level fn. =)
2016-11-01 07:04:33 -07:00
Michael Woerister
e3025a0733 ICH: Hash expression spans if their source location is captured for panics 2016-11-01 09:41:46 -04:00
bors
ac968c4664 Auto merge of #37299 - devonhollowood:result-unwrap-or-default, r=alexcrichton
Add `unwrap_or_default` method to `Result`

Fixes #37025
2016-11-01 03:53:42 -07:00
bors
73f5cad6c4 Auto merge of #37178 - apasel422:issue-37136, r=alexcrichton
Implement `RefUnwindSafe` for atomic types

Closes #37136
2016-11-01 00:44:50 -07:00