Auto merge of #82780 - cjgillot:dep-stream, r=michaelwoerister
Stream the dep-graph to a file instead of storing it in-memory.
This is a reimplementation of #60035.
Instead of storing the dep-graph in-memory, the nodes are encoded as they come
into the a temporary file as they come. At the end of a successful the compilation,
this file is renamed to be the persistent dep-graph, to be decoded during the next
compilation session.
This two-files scheme avoids overwriting the dep-graph on unsuccessful or crashing compilations.
The structure of the file is modified to be the sequence of `(DepNode, Fingerprint, EdgesVec)`.
The deserialization is responsible for going to the more compressed representation.
The `node_count` and `edge_count` are stored in the last 16 bytes of the file,
in order to accurately reserve capacity for the vectors.
At the end of the compilation, the encoder is flushed and dropped.
The graph is not usable after this point: any creation of a node will ICE.
I had to retrofit the debugging options, which is not really pretty.
Auto merge of #83726 - the8472:large-trustedlen-fail-fast, r=kennytm
panic early when `TrustedLen` indicates a `length > usize::MAX`
Changes `TrustedLen` specializations to immediately panic when `size_hint().1 == None`.
As far as I can tell this is ~not a change~ a minimal change in observable behavior for anything except ZSTs because the fallback path would go through `extend_desugared()` which tries to `reserve(lower_bound)` which already is `usize::MAX` and that would also lead to a panic. Before it might have popped somewhere between zero and a few elements from the iterator before panicking while it now panics immediately.
Overall this should reduce codegen by eliminating the fallback paths.
While looking into the `with_capacity()` behavior I also noticed that its documentation didn't have a *Panics* section, so I added that.
Auto merge of #83732 - ehuss:update-cargo, r=ehuss
Update cargo
5 commits in 1e8703890f285befb5e32627ad4e0a0454dde1fb..3c44c3c4b7900b8b13c85ead25ccaa8abb7d8989
2021-03-26 16:59:39 +0000 to 2021-03-31 21:21:15 +0000
- Fix semver docs for 1.51. (rust-lang/cargo#9316)
- Add `cargo config` subcommand. (rust-lang/cargo#9302)
- Give one more example for the --featuers CLI (rust-lang/cargo#9313)
- Bump to 0.54.0, update changelog (rust-lang/cargo#9308)
- Make the URL to the tracking issue for `--out-dir` into a link (rust-lang/cargo#9309)
Auto merge of #83731 - Dylan-DPC:rollup-v2z3gkt, r=Dylan-DPC
Rollup of 5 pull requests
Successful merges:
- #83015 (Add regression tests for #79825 and #81555)
- #83699 (Add a regression test for issue-68830)
- #83700 (Fix documentation of conversion from String to OsString)
- #83711 (Clarify `--print target-list` is a rustc's option)
- #83712 (Update LLVM with another wasm simd fix)
Rollup merge of #83700 - steffahn:string_to_pathbuf_conversion_documentation, r=JohnTitor
Fix documentation of conversion from String to OsString
From [this question on URLO](https://users.rust-lang.org/t/does-converting-a-string-into-a-pathbuf-allocate-new-buffer/57678), I noticed that the documentation of `From<String> for OsString` incorrectly claims to be copying data.
bors [Wed, 31 Mar 2021 05:47:22 +0000 (05:47 +0000)]
Auto merge of #83681 - jyn514:blanket-impls-tweaks, r=Aaron1011
rustdoc: Only look at blanket impls in `get_blanket_impls`
The idea here is that all the work in https://github.com/rust-lang/rust/blob/16156fb2787f745e57504197bd7fe38b69c6cbea/compiler/rustc_middle/src/ty/trait_def.rs#L172-L186 doesn't matter for `get_blanket_impls` - Rustdoc will already pick up on those blocks when it documents the item.
bors [Wed, 31 Mar 2021 03:20:33 +0000 (03:20 +0000)]
Auto merge of #83666 - Amanieu:instrprof-order, r=tmandry
Run LLVM coverage instrumentation passes before optimization passes
This matches the behavior of Clang and allows us to remove several
hacks which were needed to ensure functions weren't optimized away
before reaching the instrumentation pass.
bors [Tue, 30 Mar 2021 23:47:51 +0000 (23:47 +0000)]
Auto merge of #83692 - Dylan-DPC:rollup-2a2m3jy, r=Dylan-DPC
Rollup of 6 pull requests
Successful merges:
- #80720 (Make documentation of which items the prelude exports more readable.)
- #83654 (Do not emit a suggestion that causes the E0632 error)
- #83671 (Add a regression test for issue-75801)
- #83678 (Fix Self keyword doc URL conflict on case insensitive file systems (until definitely fixed on rustdoc))
- #83680 (Update for loop desugaring docs)
- #83683 (bootstrap: don't complain about linkcheck if it is excluded)
Dylan DPC [Tue, 30 Mar 2021 23:14:48 +0000 (01:14 +0200)]
Rollup merge of #83678 - GuillaumeGomez:hack-Self-keyword-conflict, r=jyn514
Fix Self keyword doc URL conflict on case insensitive file systems (until definitely fixed on rustdoc)
This is just a hack to allow rustup to work on macOS and windows again to distribute std documentation (hopefully once https://github.com/rust-lang/rfcs/pull/3097 or an equivalent is merged).
Fixes https://github.com/rust-lang/rust/issues/80504. Prevents https://github.com/rust-lang/rust/issues/83154 and https://github.com/rust-lang/rustup/issues/2694 in future releases.
Dylan DPC [Tue, 30 Mar 2021 23:14:40 +0000 (01:14 +0200)]
Rollup merge of #80720 - steffahn:prettify_prelude_imports, r=camelid,jyn514
Make documentation of which items the prelude exports more readable.
I recently figured out that rustdoc allows link inside of inline code blocks as long as they’re delimited with `<code> </code>` instead of `` ` ` ``. I think this applies nicely in the listing of prelude exports [in the docs](https://doc.rust-lang.org/std/prelude/index.html). There, currently unformatted `::` and `{ , }` is used in order to mimick import syntax while attatching links to individual identifiers.
## Rendered Comparison
### Currently (light)
![Screenshot_20210105_155801](https://user-images.githubusercontent.com/3986214/103661510-1a87be80-4f6f-11eb-8360-1dfb23f732e8.png)
### After this PR (light)
![Screenshot_20210105_155811](https://user-images.githubusercontent.com/3986214/103661533-1f4c7280-4f6f-11eb-89d4-874793937824.png)
### Currently (dark)
![Screenshot_20210105_155824](https://user-images.githubusercontent.com/3986214/103661571-2a9f9e00-4f6f-11eb-95f9-e291b5570b41.png)
### After this PR (dark)
![Screenshot_20210105_155836](https://user-images.githubusercontent.com/3986214/103661592-2ffce880-4f6f-11eb-977a-82afcb07d331.png)
### Currently (ayu)
![Screenshot_20210105_155917](https://user-images.githubusercontent.com/3986214/103661619-39865080-4f6f-11eb-9ca1-9045a107cddd.png)
### After this PR (ayu)
![Screenshot_20210105_155923](https://user-images.githubusercontent.com/3986214/103661652-3db26e00-4f6f-11eb-82b7-378e38f0c41f.png)
_Edit:_ I just noticed, the “current” screenshots are from stable, so there are a few more differences in the pictures than the ones from just this PR.
bors [Tue, 30 Mar 2021 19:34:23 +0000 (19:34 +0000)]
Auto merge of #83652 - xu-cheng:ipv4-octal, r=sfackler
Disallow octal format in Ipv4 string
In its original specification, leading zero in Ipv4 string is interpreted
as octal literals. So a IP address 0127.0.0.1 actually means 87.0.0.1.
This confusion can lead to many security vulnerabilities. Therefore, in
[IETF RFC 6943], it suggests to disallow octal/hexadecimal format in Ipv4
string all together.
Existing implementation already disallows hexadecimal numbers. This commit
makes Parser reject octal numbers.
Tom Eccles [Tue, 30 Mar 2021 17:36:53 +0000 (18:36 +0100)]
bootstrap: don't complain about linkcheck if it is excluded
We don't need to complain to the user about linkcheck having different
hosts and targets when it is already excluded. This can be achieved by
moving the check to when the step is run instead of in should_run.
Dylan DPC [Tue, 30 Mar 2021 09:34:29 +0000 (11:34 +0200)]
Rollup merge of #83662 - ehuss:update-books, r=ehuss
Update books
## reference
4 commits in d10a0af8dca25d9d548ca6a369fd66ad06acb3c9..fd97729e2d82f8b08d68a31c9bfdf0c37a7fd542
2021-03-21 11:14:06 -0700 to 2021-03-28 14:29:19 -0700
- Editorial cleanup on expressions (part 1) (rust-lang-nursery/reference#967)
- Update type casts section (rust-lang-nursery/reference#961)
- Add missing "?" notion (rust-lang-nursery/reference#989)
- Fix typo (rust-lang-nursery/reference#988)
## book
8 commits in fc2f690fc16592abbead2360cfc0a42f5df78052..b54090a99ec7c4b46a5203a9c927fdbc311bb1f5
2021-03-05 14:03:22 -0500 to 2021-03-24 11:21:46 -0500
- correct the signature of the `deref` method (rust-lang/book#2658)
- Clarify the immutability of a reference (rust-lang/book#2646)
- Tweak wording around Windows representation of enter
- Ch. 02 note - Enter results in CRLF on Windows (rust-lang/book#2648)
- Added an example of slicing result (rust-lang/book#2649)
- Fix word wrapping, mention dictionary.txt is also in the ci dir
- README: note that spellcheck.sh is in ci directory (rust-lang/book#2652)
- Change someurl.com to example.org (rust-lang/book#2655)
## rust-by-example
12 commits in eead22c6c030fa4f3a167d1798658c341199e2ae..29d91f591c90dd18fdca6d23f1a9caf9c139d0d7
2021-03-04 16:26:43 -0300 to 2021-03-23 09:03:39 -0300
- Unwrap some drinks. (rust-lang/rust-by-example#1431)
- doc(testcase_linked_list): add a little extra note about pattern (rust-lang/rust-by-example#1408)
- Update function name in comment (rust-lang/rust-by-example#1413)
- Fixes minor typo in src/types/cast.md (rust-lang/rust-by-example#1414)
- Add destructuring example to generics new type (rust-lang/rust-by-example#1416)
- update struct.md (rust-lang/rust-by-example#1419)
- fix name from rectangle to Rectangle (rust-lang/rust-by-example#1420)
- Typo "incures" in code comment (rust-lang/rust-by-example#1422)
- Changed impl to use Self::Item (rust-lang/rust-by-example#1425)
- Fix code highlighting in some places (rust-lang/rust-by-example#1427)
- Update multi_bounds.md (rust-lang/rust-by-example#1428)
- Reformulated text for redability (rust-lang/rust-by-example#1429)
## rustc-dev-guide
3 commits in 67ebd4b55dba44edfc351621cef6e5e758169c55..0687daac28939c476df51778f5a1d1aff1a3fddf
2021-03-11 13:36:25 -0800 to 2021-03-28 13:33:56 -0400
- Add notes about nightly rustc version for the rustc-driver examples
- Update rustc-driver-*.rs examples (rust-lang/rustc-dev-guide#1095)
- Fix rust compiler meeting info (rust-lang/rustc-dev-guide#1087)
Dylan DPC [Tue, 30 Mar 2021 09:34:26 +0000 (11:34 +0200)]
Rollup merge of #83579 - RalfJung:ptr-arithmetic, r=dtolnay
Improve pointer arithmetic docs
* Add slightly more detailed definition of "allocated object" to the module docs, and link it from everywhere.
* Clarify the "remains attached" wording a bit (at least I hope this is clearer).
* Remove the sentence about using integer arithmetic; this seems to confuse people even if it is technically correct.
As usual, the edit needs to be done in a dozen places to remain consistent, I hope I got them all.
Dylan DPC [Tue, 30 Mar 2021 09:34:25 +0000 (11:34 +0200)]
Rollup merge of #83571 - a1phyr:feature_const_slice_first_last, r=dtolnay
Constantify some slice methods
Tracking issue: #83570
This PR constantifies the following functions under feature `const_slice_first_last`:
- `slice::first`
- `slice::split_first`
- `slice::last`
- `slice::split_last`
bors [Tue, 30 Mar 2021 09:03:29 +0000 (09:03 +0000)]
Auto merge of #83458 - saethlin:improve-vec-benches, r=dtolnay
Clean up Vec's benchmarks
The Vec benchmarks need a lot of love. I sort of noticed this in https://github.com/rust-lang/rust/pull/83357 but the overall situation is much less awesome than I thought at the time. The first commit just removes a lot of asserts and does a touch of other cleanup.
A number of these benchmarks are poorly-named. For example, `bench_map_fast` is not in fact fast, `bench_rev_1` and `bench_rev_2` are vague, `bench_in_place_zip_iter_mut` doesn't call `zip`, `bench_in_place*` don't do anything in-place... Should I fix these, or is there tooling that depend on the names not changing?
I've also noticed that `bench_rev_1` and `bench_rev_2` are remarkably fragile. It looks like poking other code in `Vec` can cause the codegen of this benchmark to switch to a version that has almost exactly half its current throughput and I have absolutely no idea why.
bors [Tue, 30 Mar 2021 06:22:29 +0000 (06:22 +0000)]
Auto merge of #83649 - bjorn3:dedup_providers, r=petrochenkov
Don't duplicate the extern providers once for each crate
This should give a small perf improvement for small crates by avoiding a memcpy of a pretty big struct for each loaded crate. In addition would be useful for replacing the sequential `CrateNum` everywhere with the hash based `StableCrateId` introduced in #81635, which would allow avoiding remapping of `CrateNum`'s when loading crate metadata. While this PR is not strictly needed for that, it is necessary to prevent a performance loss due to it.
I think this duplication was done in https://github.com/rust-lang/rust/pull/40008 (which introduced the query system) to make it possible to compile multiple crates in a single session in the future. I think this is unlikely to be implemented any time soon. In addition this PR can easily be reverted if necessary to implement this.
bors [Tue, 30 Mar 2021 03:41:14 +0000 (03:41 +0000)]
Auto merge of #83357 - saethlin:vec-reserve-inlining, r=dtolnay
Reduce the impact of Vec::reserve calls that do not cause any allocation
I think a lot of callers expect `Vec::reserve` to be nearly free when no resizing is required, but unfortunately that isn't the case. LLVM makes remarkably poor inlining choices (along the path from `Vec::reserve` to `RawVec::grow_amortized`), so depending on the surrounding context you either get a huge blob of `RawVec`'s resizing logic inlined into some seemingly-unrelated function, or not enough inlining happens and/or the actual check in `needs_to_grow` ends up behind a function call. My goal is to make the codegen for `Vec::reserve` match the mental that callers seem to have: It's reliably just a `sub cmp ja` if there is already sufficient capacity.
This patch has the following impact on the serde_json benchmarks: https://github.com/serde-rs/json-benchmark/tree/ca3efde8a5b75ff59271539b67452911860248c7 run with `cargo +stage1 run --release -- -n 1024`
That's approximately a one-third increase in throughput on two of the benchmarks, and no effect on one (The benchmark suite has sufficient jitter that I could pick a run where there are no regressions, so I'm not convinced they're meaningful here).
This also produces perf increases on the order of 3-5% in a few other microbenchmarks that I'm tracking. It might be useful to see if this has a cascading effect on inlining choices in some large codebases.
Compiling this simple program demonstrates the change in codegen that causes the perf impact:
```rust
fn main() {
reserve(&mut Vec::new());
}
Esteban Küber [Tue, 30 Mar 2021 02:53:48 +0000 (19:53 -0700)]
Hide unnecessary reference to trait
When the problem for a method not being found in its receiver is due to
arbitrary self-types, we don't want to mention importing or implementing
the trait, instead we suggest wrapping.
Cheng XU [Tue, 30 Mar 2021 02:24:23 +0000 (10:24 +0800)]
Disallow octal format in Ipv4 string
In its original specification, leading zero in Ipv4 string is interpreted
as octal literals. So a IP address 0127.0.0.1 actually means 87.0.0.1.
This confusion can lead to many security vulnerabilities. Therefore, in
[IETF RFC 6943], it suggests to disallow octal/hexadecimal format in Ipv4
string all together.
Existing implementation already disallows hexadecimal numbers. This commit
makes Parser reject octal numbers.
bors [Tue, 30 Mar 2021 01:16:08 +0000 (01:16 +0000)]
Auto merge of #83664 - Dylan-DPC:rollup-wx6idpd, r=Dylan-DPC
Rollup of 7 pull requests
Successful merges:
- #82331 (alloc: Added `as_slice` method to `BinaryHeap` collection)
- #83130 (escape_ascii take 2)
- #83374 (unix: Fix feature(unix_socket_ancillary_data) on macos and other BSDs)
- #83543 (Lint on unknown intra-doc link disambiguators)
- #83636 (Add a regression test for issue-82792)
- #83643 (Remove a FIXME resolved by #73578)
- #83644 (:arrow_up: rust-analyzer)
Amanieu d'Antras [Sat, 27 Mar 2021 05:04:32 +0000 (05:04 +0000)]
Run LLVM coverage instrumentation passes before optimization passes
This matches the behavior of Clang and allows us to remove several
hacks which were needed to ensure functions weren't optimized away
before reaching the instrumentation pass.
Dylan DPC [Mon, 29 Mar 2021 22:32:21 +0000 (00:32 +0200)]
Rollup merge of #83374 - reyk:fix/bsd-ancillary, r=joshtriplett
unix: Fix feature(unix_socket_ancillary_data) on macos and other BSDs
This adds support for CMSG handling on macOS and fixes it on OpenBSD and possibly other BSDs.
When traversing the CMSG list, the previous code had an exception for Android where the next element after the last pointer could point to the first pointer instead of NULL. This is actually not specific to Android: the `libc::CMSG_NXTHDR` implementation for Linux and emscripten have a special case to return NULL when the length of the previous element is zero; most other implementations simply return the previous element plus a zero offset in this case.
This MR makes the check non-optional which fixes CMSG handling and a possible endless loop on such systems; tested with file descriptor passing on OpenBSD, Linux, and macOS.
This MR additionally adds `SocketAncillary::is_empty` because clippy is right that it should be added.
This belongs to the `feature(unix_socket_ancillary_data)` tracking issue: https://github.com/rust-lang/rust/issues/76915
Dylan DPC [Mon, 29 Mar 2021 22:32:20 +0000 (00:32 +0200)]
Rollup merge of #83130 - clarfonthey:escape, r=m-ou-se
escape_ascii take 2
The previous PR, #73111 was closed for inactivity; since I've had trouble in the past reopening closed PRs, I'm just making a new one.
I'm still running the tests locally but figured I'd open the PR in the meantime. Will fix whatever errors show up so we don't have to wait again for this.
Dylan DPC [Mon, 29 Mar 2021 22:32:18 +0000 (00:32 +0200)]
Rollup merge of #82331 - frol:feat/std-binary-heap-as-slice, r=Amanieu
alloc: Added `as_slice` method to `BinaryHeap` collection
I initially asked about whether it is useful addition on https://internals.rust-lang.org/t/should-i-add-as-slice-method-to-binaryheap/13816, and it seems there were no objections, so went ahead with this PR.
> There is [`BinaryHeap::into_vec`](https://doc.rust-lang.org/std/collections/struct.BinaryHeap.html#method.into_vec), but it consumes the value. I wonder if there is API design limitation that should be taken into account. Implementation-wise, the inner buffer is just a Vec, so it is trivial to expose as_slice from it.
Please, guide me through if I need to add tests or something else.
bors [Mon, 29 Mar 2021 22:27:16 +0000 (22:27 +0000)]
Auto merge of #82864 - jyn514:short-circuit, r=GuillaumeGomez
rustdoc: Don't enter an infer_ctxt in get_blanket_impls for impls that aren't blanket impls
Less broken version of https://github.com/rust-lang/rust/pull/82856.
get_blanket_impls is a *very* hot region of rustdoc, so even small changes like this should help. Unfortunately I don't have benchmarks for this until https://github.com/rust-lang/rustc-perf/pull/802 is merged.
Found with https://github.com/est31/warnalyzer.
See https://github.com/rust-lang/rust/pull/77739 for a similar change in the past.
Dubious changes:
- Maybe some of the dead code in rustc_data_structures should be kept, in case someone wants to use it in the future?
TODO:
- [ ] check if any of the comments on the deleted code should be kept.
- [x] update the compiler documentation; right now it fails to build
- [x] finish moving `cfg(test)` changes into https://github.com/rust-lang/rust/pull/83197
Joshua Nelson [Mon, 29 Mar 2021 17:50:40 +0000 (13:50 -0400)]
Revert changes to sync data structures
There isn't currently a good reviewer for these, and I don't want to
remove things that will just be added again. I plan to make a separate
PR for these changes so the rest of the cleanup can land.
bors [Mon, 29 Mar 2021 16:48:45 +0000 (16:48 +0000)]
Auto merge of #80839 - tblah:riscv64linux_links, r=Mark-Simulacrum
Riscv64linux Test fixes
Get tests passing again using the riscv64gc-unknown-linux-gnu docker image.
Test with
```
src/ci/docker/run.sh riscv64gc-linux
```
## linkcheck
Linkcheck tests that interdocument links in the documentation are correct. Some interdocument links go between rustc and tools (such as rustdoc and cargo). When cross compiling, rustc is built for the host while some tools are built for the target. This goes for the documentation too. Because of this, links in the rustc documentation reffering to cargo or rustdoc documentation look broken.
This issue is worked around by disabling linkcheck for cross compilation builds.
## run-make tests
#78911 seems to happen because `--target` was not passed to `rustc`, but the target linker was specified, causing the target linker to be called with options intended for the host.
Resolves #78911
In a separate issue, `issue-36710` was trying to run a binary built for the target on the host system. This will not work for any platform using `remote-test-server`/`client` (such as riscv64). I don't know of a way of skipping those platforms specifically, so I set this test to skip only on riscv64 for now.