Commit Graph

66185 Commits

Author SHA1 Message Date
bors
cd87b5d516 Auto merge of #43605 - RalfJung:mapdoc, r=michaelwoerister
Improve hir::map::Map::get_parent_node doc

The documentation says
```
    /// Similar to get_parent, returns the parent node id or id if there is no
    /// parent.
    /// This function returns the immediate parent in the AST, whereas get_parent
    /// returns the enclosing item.
```
One would think that one can walk up the tree by repeatedly calling `get_parent_node` until it returns the argument, and then work on the `NodeId`s that arise. However, that is not true: `get_parent_node` will return id 0 (the crate itself) for items that sit directly in the crate; calling `get` on that `NodeId` will panic.

So, the fact that `get_parent_node` returns the root when passed the root is actually not really useful, because the root itself is already a somewhat degenerate node. This improves the doc so hopefully people writing code that "walks up the tree" don't run into this issue like I did...
2017-08-02 13:40:35 +00:00
bors
22f256f69e Auto merge of #43612 - michaelwoerister:fix-cgu-hashing, r=eddyb
incr.comp.: Properly incorporate symbol linkage and visibility into CGU hash.

This PR fixes the way the CGU hash for incr. comp. is computed. The CGU hash represents which `TransItems` are emitted into which codegen unit with which linkage and visibility. Before the new, LLVM-independent symbol internalizer the CGU hash did not accurately contain `TransItem` linkage and visibility because we would not enable symbol internalization in incremental mode anyway. The new internalizer is also run in incremental mode which uncovered the inaccuracy of CGU hashing. Luckily, the fix is rather simple.

r? @eddyb
cc @nikomatsakis
2017-08-02 11:14:54 +00:00
Michael Woerister
b2c3a413b9 incr.comp.: Properly incorporate symbol linkage and visibility into CGU hash. 2017-08-02 11:56:23 +02:00
bors
5c385bef7a Auto merge of #43602 - QuietMisdreavus:fantastic-shrinking-headings, r=GuillaumeGomez
rustdoc: shrink headings in non-top-level docblocks

Headings in per-method docs are often bigger than the function names/signatures themselves, so this tones those down to accentuate the methods.

![screenshot of this change on Vec::swap_remove](https://user-images.githubusercontent.com/5217170/28849380-6116a830-76dc-11e7-8ce2-04433d09463a.png)

Fixes #17193
2017-08-02 08:49:02 +00:00
bors
0b5c0874b8 Auto merge of #43584 - arielb1:unused-reads, r=eddyb
Fix quadratic performance with lots of use statements

This fixes 2 problems that caused quadratic performance when lots of use-statements were present. After this patch, performance is linear (and very fast) even with 1M uses.

Fixes #43572.
Fixes #43573.

r? @eddyb
2017-08-02 05:56:06 +00:00
bors
4f3062c88e Auto merge of #43603 - frewsxcv:rollup, r=frewsxcv
Rollup of 6 pull requests

- Successful merges: #43389, #43423, #43581, #43585, #43597, #43598
- Failed merges:
2017-08-02 03:39:27 +00:00
Ralf Jung
e92ddbf5f7 improve hir::map::Map::get_parent_node doc 2017-08-01 19:22:23 -07:00
QuietMisdreavus
5c4c2d9235 rustdoc: shrink headings in non-top-level docblocks 2017-08-01 21:09:34 -05:00
Corey Farwell
368f1a8e93 Rollup merge of #43598 - ibabushkin:master, r=eddyb
Derive `Hash` on `AssociatedKind`.

This is a trivial change useful in downstream code poking in rustc's
innards, in particular the semver verification tool I'm currently working on.

r? @eddyb
2017-08-02 01:22:30 +00:00
Corey Farwell
1c91c785da Rollup merge of #43597 - dhduvall:master, r=alexcrichton
Fix the Solaris pthread_t raw type in std to match what's in libc

The old type causes failures when building cargo 0.20.0 after rust-lang/libc@8304e06b5.
2017-08-02 01:22:29 +00:00
Corey Farwell
08c0bbd062 Rollup merge of #43585 - frewsxcv:frewsxcv-hashset-docs, r=steveklabnik,quietmisdreavus
Improve docs & doc examples for HashSet.

None
2017-08-02 01:22:28 +00:00
Corey Farwell
c96ce4064a Rollup merge of #43581 - alexcrichton:inline-more, r=michaelwoerister
rustc: Inline bitwise modification operators

These need to be inlined across crates to avoid showing up as one-instruction
functions in profiles! In the benchmark from #43578 this decreased the
translation item collection step from 30s to 23s, and looks like it also allowed
vectorization elsewhere of the operations!
2017-08-02 01:22:27 +00:00
Corey Farwell
2d9893fda7 Rollup merge of #43423 - xliiv:cell-example, r=steveklabnik
Add simple docs example for struct Cell
2017-08-02 01:22:27 +00:00
Corey Farwell
ab3fb956f3 Rollup merge of #43389 - alexcrichton:thread-error, r=michaelwoerister
Thread through the original error when opening archives

This updates the management of opening archives to thread through the original
piece of error information from LLVM over to the end consumer, trans.
2017-08-02 01:22:26 +00:00
bors
f5f58d0298 Auto merge of #43579 - cuviper:extern-llvm-features, r=alexcrichton
Gate LLVMRustHasFeature on LLVM_RUSTLLVM

Commit c4710203c0 in #43492 make `LLVMRustHasFeature` "more robust"
by using `getFeatureTable()`.  However, this function is specific to
Rust's own LLVM fork, not upstream LLVM-4.0, so we need to use
`#if LLVM_RUSTLLVM` to guard this call.

Closes #43555.
2017-08-02 01:13:02 +00:00
Corey Farwell
d9df2963ad Add doc example for HashSet::drain. 2017-08-01 19:51:00 -04:00
Corey Farwell
34c1bfb0e1 Remove unnecessary clones in doc examples. 2017-08-01 19:51:00 -04:00
Corey Farwell
1599fad5b4 Show the capacity in HashSet::with_capacity doc example. 2017-08-01 19:51:00 -04:00
Corey Farwell
9e2b0c6390 Remove unnecessary 'mut' bindings. 2017-08-01 19:51:00 -04:00
Corey Farwell
070eb3c667 Indicate HashSet is code-like in docs. 2017-08-01 19:51:00 -04:00
Corey Farwell
9e19260286 Show that the capacity changed in HashSet::reserve doc example. 2017-08-01 19:51:00 -04:00
Corey Farwell
881062776a Add doc example for HashSet::hasher. 2017-08-01 19:51:00 -04:00
bors
640cfc852a Auto merge of #43576 - arielb1:no-unneeded-unwind, r=eddyb
rustc_mir: don't build unused unwind cleanup blocks

When building a scope exit, don't build unwind cleanup blocks unless they will actually be used by the unwind path of a drop - the unused blocks are removed by SimplifyCfg, but they can cause a significant performance slowdown before they are removed. That fixes #43511.

Also a few other small MIR cleanups & optimizations.

r? @eddyb
2017-08-01 22:43:15 +00:00
Inokentiy Babushkin
1b831cf54e
Derive Hash on AssociatedKind.
This is a trivial change useful in downstream code poking in rustc's
innards.
2017-08-01 22:27:30 +02:00
bors
dd53dd5f9e Auto merge of #43529 - QuietMisdreavus:fn-docs, r=steveklabnik
add documentation for function pointers as a primitive

This PR adds a new kind of primitive to the standard library documentation: Function pointers. It's useful to be able to discuss them separately from closure-trait-objects, and to have something to point to when discussing function pointers as a *type* and not a *trait*.

Fixes #17104
2017-08-01 19:59:53 +00:00
Danek Duvall
bdb53e55b0 Fix the Solaris pthread_t raw type in std to match what's in libc
The old type causes failures when building cargo 0.20.0 after
changeset 8304e06b5 in the libc repo.
2017-08-01 12:38:36 -07:00
bors
e772c28d2e Auto merge of #43506 - michaelwoerister:async-llvm, r=alexcrichton
Run translation and LLVM in parallel when compiling with multiple CGUs

This is still a work in progress but the bulk of the implementation is done, so I thought it would be good to get it in front of more eyes.

This PR makes the compiler start running LLVM while translation is still in progress, effectively allowing for more parallelism towards the end of the compilation pipeline. It also allows the main thread to switch between either translation or running LLVM, which allows to reduce peak memory usage since not all LLVM module have to be kept in memory until linking. This is especially good for incr. comp. but it works just as well when running with `-Ccodegen-units=N`.

In order to help tuning and debugging the work scheduler, the PR adds the `-Ztrans-time-graph` flag which spits out html files that show how work packages where scheduled:
![Building regex](https://user-images.githubusercontent.com/1825894/28679272-f6752bd8-72f2-11e7-8a6c-56207855ce95.png)
(red is translation, green is llvm)

One side effect here is that `-Ztime-passes` might show something not quite correct because trans and LLVM are not strictly separated anymore. I plan to have some special handling there that will try to produce useful output.

One open question is how to determine whether the trans-thread should switch to intermediate LLVM processing.

TODO:
- [x] Restore `-Z time-passes` output for LLVM.
- [x] Update documentation, esp. for work package scheduling.
- [x] Tune the scheduling algorithm.

cc @alexcrichton @rust-lang/compiler
2017-08-01 17:21:24 +00:00
QuietMisdreavus
71751db491 add documentation for function pointers as a primitive 2017-08-01 09:42:12 -05:00
bors
c2407516ff Auto merge of #43568 - arielb1:constant-recovery, r=eddyb
trans::mir::constant - fix assignment error recovery

trans::mir::constant - fix assignment error recovery

We used to not store anything when the RHS of an assignment returned an error, which caused ICEs downstream.

Fixes #43197.
2017-08-01 14:20:23 +00:00
Michael Woerister
6468cad977 async-llvm(29): Adapt run-make/llvm-phase test case to LLVM module not being available in memory. 2017-08-01 15:57:38 +02:00
Michael Woerister
b8d441350b async-llvm(28): Make some error messages more informative. 2017-08-01 14:43:55 +02:00
Ariel Ben-Yehuda
70478ca5c8 rustc::hir::map::definitions - fix O(n^2) when disambiguating
Instead of finding the next free disambiguator by incrementing it until
you find a place, store the next available disambiguator in an hash-map.

This avoids O(n^2) performance when lots of items have the same
un-disambiguated `DefPathData` - e.g. all `use` items have
`DefPathData::Misc`.
2017-08-01 14:44:20 +03:00
Ariel Ben-Yehuda
c9d14a846f syntax: avoid loading the same source-file multiple times
We already had a cache for file contents, but we read the source-file
before testing the cache, causing obvious slowness, so this just avoids
loading the source-file when the cache already has the contents.
2017-08-01 14:18:49 +03:00
Ariel Ben-Yehuda
ce0ca76380 pacify the merciless tidy 2017-08-01 11:57:26 +03:00
bors
0bf018c588 Auto merge of #43560 - QuietMisdreavus:ref-docs, r=steveklabnik
add docs for references as a primitive

Just like #43529 did for function pointers, here is a new primitive page for references.

This PR will pull in impls on references if it's a reference to a generic type parameter. Initially i was only able to pull in impls that were re-exported from another crate; crate-local impls got a different representation in the AST, and i had to change how types were resolved when cleaning it. (This is the change at the bottom of `librustdoc/clean/mod.rs`, in `resolve_type`.) I'm unsure the full ramifications of the change, but from what it looks like, it shouldn't impact anything major. Likewise, references to generic type parameters also get the `&'a [mut]` linked to the new page.

cc @rust-lang/docs: Is this sufficient information? The listing of trait impls kinda feels redundant (especially if we can get the automated impl listing sorted again), but i still think it's useful to point out that you can use these in a generic context.

Fixes #15654
2017-08-01 08:23:41 +00:00
bors
6e8452ee4f Auto merge of #43552 - petrochenkov:instab, r=jseyfried
resolve: Try to fix instability in import suggestions

cc https://github.com/rust-lang/rust/pull/42033

`lookup_import_candidates` walks module graph in DFS order and skips modules that were already visited (which is correct because there can be cycles).
However it means that if we visited `std::prelude::v1::Result::Ok` first, we will never visit `std::result::Result::Ok` because `Result` will be skipped as already visited (note: enums are also modules here), and otherwise, if we visited `std::result::Result::Ok` first, we will never get to `std::prelude::v1::Result::Ok`.
What child module of `std` (`prelude` or `result`) we will visit first, depends on randomized hashing, so we have instability in diagnostics.

With this patch modules' children are visited in stable order in `lookup_import_candidates`, this should fix the issue, but let's see what Travis will say.

r? @oli-obk
2017-08-01 06:05:34 +00:00
bors
df90a54662 Auto merge of #43533 - nrc:macro-save, r=jseyfried,
Three small fixes for save-analysis

First commit does some naive deduplication of macro uses. We end up with lots of duplication here because of the weird way we get this data (we extract a use for every span generated by a macro use).

Second commit is basically a typo fix.

Third commit is a bit interesting, it partially reverts a change from #40939 where temporary variables in format! (and thus println!) got a span with the primary pointing at the value stored into the temporary (e.g., `x` in `println!("...", x)`). If `format!` had a definition it should point at the temporary in the macro def, but since it is built-in, that is not possible (for now), so `DUMMY_SP` is the best we can do (using the span in the callee really breaks save-analysis because it thinks `x` is a definition as well as a reference).

There aren't a test for this stuff because: the deduplication is filtered by any of the users of save-analysis, so it is purely an efficiency change. I couldn't actually find an example for the second commit that we have any machinery to test, and the third commit is tested by the RLS, so there will be a test once I update the RLS version and and uncomment the previously failing tests).

r? @jseyfried
2017-08-01 03:52:14 +00:00
Nick Cameron
27b9182d5b review changes 2017-08-01 15:06:22 +12:00
Alex Crichton
dd371a2069 rustc: Inline bitwise modification operators
These need to be inlined across crates to avoid showing up as one-instruction
functions in profiles! In the benchmark from #43578 this decreased the
translation item collection step from 30s to 23s, and looks like it also allowed
vectorization elsewhere of the operations!
2017-07-31 18:39:25 -07:00
Josh Stone
881a724660 Gate LLVMRustHasFeature on LLVM_RUSTLLVM
Commit c4710203c0 in #43492 make `LLVMRustHasFeature` "more robust"
by using `getFeatureTable()`.  However, this function is specific to
Rust's own LLVM fork, not upstream LLVM-4.0, so we need to use
`#if LLVM_RUSTLLVM` to guard this call.
2017-07-31 18:10:01 -07:00
bors
ebf74d99b0 Auto merge of #43547 - arielb1:no-borrow-no-check, r=nikomatsakis
borrowck: skip CFG construction when there is nothing to propagate

CFG construction takes a large amount of time and memory, especially for
large constants. If such a constant contains no actions on lvalues, it
can't have borrowck problems and can be ignored by it.

This removes the 4.9GB borrowck peak from #36799. It seems that HIR had
grown by 300MB and MIR had grown by 500MB from the last massif
collection and that remains to be investigated, but this at least shaves
the borrowck peak.

r? @nikomatsakis
2017-07-31 23:21:24 +00:00
Ariel Ben-Yehuda
5b99523de9 rustc_mir::transform::simplify - remove nops first
Removing nops can allow more basic blocks to be merged, but merging
basic blocks can't allow for more nops to be removed, so we should
remove nops first.

This doesn't matter *that* much, because normally we run SimplifyCfg
several times, but there's no reason not to do it.
2017-08-01 00:12:31 +03:00
Ariel Ben-Yehuda
ca3105cfdf use an iterator when visiting MIR basic blocks
I saw MIR cache invalidation somewhat hot on my profiler when per-BB
indexin was used. That shouldn't matter much, but there is no good
reason not to use an iterator.
2017-08-01 00:12:31 +03:00
Ariel Ben-Yehuda
85c102757a rustc_mir: don't build unused unwind cleanup blocks
The unused blocks are removed by SimplifyCfg, but they can cause a
significant performance slowdown before they are removed.
2017-08-01 00:12:30 +03:00
Ariel Ben-Yehuda
1447daa01d remove the span field from diverge_cleanup 2017-08-01 00:12:30 +03:00
bors
37c7d0ebb3 Auto merge of #43399 - tschottdorf:bndmode-pat-adjustments, r=nikomatsakis
default binding modes: add pat_binding_modes

This PR kicks off the implementation of the [default binding modes RFC][1] by
introducing the `pat_binding_modes` typeck table mentioned in the [mentoring
instructions][2].

It is a WIP because I wasn't able to avoid all uses of the binding modes as
not all call sites are close enough to the typeck tables. I added marker
comments to any line matching `BindByRef|BindByValue` so that reviewers
are aware of all of them.

I will look into changing the HIR (as suggested in [2]) to not carry a
`BindingMode` unless one was explicitly specified, but this PR is good for
a first round of comments.

The actual changes are quite small and CI will fail due to overlong lines
caused by the marker comments.

See #42640.

cc @nikomatsakis

[1]: https://github.com/rust-lang/rfcs/pull/2005
[2]: https://github.com/rust-lang/rust/issues/42640#issuecomment-313535089
2017-07-31 20:47:42 +00:00
Michael Woerister
b1e043e9e9 async-llvm(27): Move #[rustc_error] check to an earlier point in order to restore some test expections. 2017-07-31 18:51:39 +02:00
Niko Matsakis
8f67f1efaf add comments from arielb1 2017-07-31 18:13:49 +03:00
Ariel Ben-Yehuda
93db1f9923 trans::mir::constant - fix assignment error recovery
We used to not store anything when the RHS of an assignment returned an
error, which caused ICEs downstream.

Fixes #43197.
2017-07-31 18:09:02 +03:00
Ariel Ben-Yehuda
1057a728f5 fix -Z treat-err-as-bug 2017-07-31 18:09:02 +03:00