bors [Wed, 1 Dec 2021 09:51:00 +0000 (09:51 +0000)]
Auto merge of #91418 - matthiaskrgr:rollup-vn9f9w3, r=matthiaskrgr
Rollup of 7 pull requests
Successful merges:
- #87160 (When recovering from a `:` in a pattern, use adequate AST pattern)
- #90985 (Use `get_diagnostic_name` more)
- #91087 (Remove all migrate.nll.stderr files)
- #91207 (Add support for LLVM coverage mapping format versions 5 and 6)
- #91298 (Improve error message for `E0659` if the source is not available)
- #91346 (Add `Option::inspect` and `Result::{inspect, inspect_err}`)
- #91404 (Fix bad `NodeId` limit checking.)
Matthias Krüger [Wed, 1 Dec 2021 09:50:23 +0000 (10:50 +0100)]
Rollup merge of #91404 - nnethercote:fix-bad-NodeId-limit-checking, r=dtolnay
Fix bad `NodeId` limit checking.
`Resolver::next_node_id` converts a `u32` to a `usize` (which is
possibly bigger), does a checked add, and then converts the result back
to a `u32`. The `usize` conversion completely subverts the checked add!
This commit removes the conversion to/from `usize`.
Matthias Krüger [Wed, 1 Dec 2021 09:50:21 +0000 (10:50 +0100)]
Rollup merge of #91298 - FabianWolff:issue-91028-source-avail, r=cjgillot
Improve error message for `E0659` if the source is not available
Fixes #91028. The fix is similar to those in #89233 and #87088. With this change, instead of the dangling
```
note: `Option` could also refer to the enum defined here
```
I get
```
note: `Option` could also refer to an enum from prelude
```
If the standard library source code _is_ available, the output does not change.
Matthias Krüger [Wed, 1 Dec 2021 09:50:20 +0000 (10:50 +0100)]
Rollup merge of #91207 - richkadel:rk-bump-coverage-version, r=tmandry
Add support for LLVM coverage mapping format versions 5 and 6
This PR cherry-pick's Swatinem's initial commit in unsubmitted PR #90047.
My additional commit augments Swatinem's great starting point, but adds full support for LLVM
Coverage Mapping Format version 6, conditionally, if compiling with LLVM 13.
Version 6 requires adding the compilation directory when file paths are
relative, and since Rustc coverage maps use relative paths, we should
add the expected compilation directory entry.
Note, however, that with the compilation directory, coverage reports
from `llvm-cov show` can now report file names (when the report includes
more than one file) with the full absolute path to the file.
This would be a problem for test results, but the workaround (for the
rust coverage tests) is to include an additional `llvm-cov show`
parameter: `--compilation-dir=.`
Matthias Krüger [Wed, 1 Dec 2021 09:50:19 +0000 (10:50 +0100)]
Rollup merge of #91087 - rukai:fix_test_nll_revisions, r=jackh726
Remove all migrate.nll.stderr files
There are a few ui tests that setup the revisions like:
```rust
// revisions: migrate nll`
// [nll]compile-flags: -Zborrowck=mir
```
However most of them fail to disable the nll compare mode like this:
```rust
// ignore-compare-mode-nll
```
This ends up generating confusing files ending in `.migrate.nll.stderr` because the nll compare mode is run on top of the migrate revision.
This PR fixes this by adding `ignore-compare-mode-nll` to these tests.
I would have just made these tests use compare modes instead but I assume the reason these tests are messing around with revisions instead of just letting the nll compare mode do its thing is to enforce error annotations for both migrate and nll.
Relying on just compare modes would only have the error annotations for migrate.
`Resolver::next_node_id` converts a `u32` to a `usize` (which is
possibly bigger), does a checked add, and then converts the result back
to a `u32`. The `usize` conversion completely subverts the checked add!
This commit removes the conversion to/from `usize`.
bors [Wed, 1 Dec 2021 02:51:15 +0000 (02:51 +0000)]
Auto merge of #91406 - matthiaskrgr:rollup-a2whn8m, r=matthiaskrgr
Rollup of 4 pull requests
Successful merges:
- #91294 (Visit type in process_projection_elem.)
- #91340 (Bump compiler_builtins to 0.1.55 to bring in fixes for targets lackin…)
- #91366 (Only show notable traits if both types are the same)
- #91397 (Emit a warning on generic parameters with doc comments)
Matthias Krüger [Tue, 30 Nov 2021 22:43:31 +0000 (23:43 +0100)]
Rollup merge of #91340 - cr1901:no-atomic, r=Mark-Simulacrum
Bump compiler_builtins to 0.1.55 to bring in fixes for targets lackin…
…g atomic support.
This fixes a "Cannot select" LLVM error when compiling `compiler_builtins` for targets lacking atomics, like MSP430. Se https://github.com/rust-lang/compiler-builtins/issues/441 for more info. This PR is a more general version of #91248.
Rich Kadel [Thu, 25 Nov 2021 00:58:49 +0000 (16:58 -0800)]
Add conditional support for coverage map version 6
This commit augments Swatinem's initial commit in uncommitted PR #90047,
which was a great starting point, but did not fully support LLVM
Coverage Mapping Format version 6.
Version 6 requires adding the compilation directory when file paths are
relative, and since Rustc coverage maps use relative paths, we should
add the expected compilation directory entry.
Note, however, that with the compilation directory, coverage reports
from `llvm-cov show` can now report file names (when the report includes
more than one file) with the full absolute path to the file.
This would be a problem for test results, but the workaround (for the
rust coverage tests) is to include an additional `llvm-cov show`
parameter: `--compilation-dir=.`
Yuki Okushi [Tue, 30 Nov 2021 08:29:13 +0000 (17:29 +0900)]
Rollup merge of #91383 - ScriptDevil:drop-while-doc-alias, r=joshtriplett
Add `drop_while` as doc alias to `Iterator::skip_while`
`skip_while` is commonly referred to as `drop_while` in other languages (clojure/c++/haskell). This recently came up in [Zulip](https://rust-lang.zulipchat.com/#narrow/stream/122651-general/topic/.E2.9C.94.20DropWhile/near/262203352) as well.
This pull request adds 'drop_while' as a doc-alias for 'skip_while'.
Yuki Okushi [Tue, 30 Nov 2021 08:29:09 +0000 (17:29 +0900)]
Rollup merge of #91323 - RalfJung:assert-type, r=oli-obk
CTFE: support assert_zero_valid and assert_uninit_valid
This ensures the implementation of all three type-based assert_ intrinsics remains consistent in Miri.
`assert_inhabited` recently got stabilized in https://github.com/rust-lang/rust/pull/90896 (meaning stable `const fn` can call it), so do the same with these other intrinsics.
Yuki Okushi [Tue, 30 Nov 2021 08:29:07 +0000 (17:29 +0900)]
Rollup merge of #91250 - rukai:remove_trailing_whitespace, r=wesleywiser
Refactor EmitterWriter::emit_suggestion_default
Makes progress towards https://github.com/rust-lang/rust/issues/89979
Split into 2 commits:
* the first commit is purely a refactor and I verified that `./x.py test src/test/ui --stage 1` and `./x.py test src/test/rustdoc-ui --stage 1` continue to pass on this commit.
* ~~the second commit removes the empty trailing line from diff style suggestions.~~ - I discovered an issue with this so its just the refactor now.
bors [Tue, 30 Nov 2021 04:15:31 +0000 (04:15 +0000)]
Auto merge of #91379 - ehuss:update-cargo, r=ehuss
Update cargo
6 commits in 7f08ace4f1305de7f3b1b0e2f765911957226bd4..294967c53f0c70d598fc54ca189313c86c576ea7
2021-11-24 17:54:39 +0000 to 2021-11-29 19:04:22 +0000
- Fix some tests with output collisions. (rust-lang/cargo#10137)
- Description of the targets that can be applied (rust-lang/cargo#10109)
- Improve unused patch message when source URLs mismatched (rust-lang/cargo#10130)
- Add a note about doctest xcompile. (rust-lang/cargo#10132)
- book: add edit links to specific pages (rust-lang/cargo#10124)
- Add crate type flag to rustc command (rust-lang/cargo#10093)
bors [Tue, 30 Nov 2021 01:08:56 +0000 (01:08 +0000)]
Auto merge of #91244 - dtolnay:lossy, r=Mark-Simulacrum
Eliminate bunch of copies of error codepath from Utf8LossyChunksIter
Using a macro to stamp out 7 identical copies of the nontrivial slicing logic to exit this loop didn't seem like a necessary use of a macro. The early return case can be handled by `break` without practically any changes to the logic inside the loop.
All this code is from early 2014 (#12062—nearly 8 years ago; pre-1.0) so it's possible there were compiler limitations that forced the macro way at the time.
Confirmed that `x.py bench library/alloc --stage 0 --test-args from_utf8_lossy` is unaffected on my machine.
bors [Mon, 29 Nov 2021 15:02:01 +0000 (15:02 +0000)]
Auto merge of #91299 - cjgillot:expect-ldid, r=petrochenkov
Take a LocalDefId in expect_*item.
Items and item-likes are always HIR owners.
When trying to find such nodes, there is no ambiguity, the `LocalDefId` and the `HirId::owner` always match.
In such cases, `local_def_id_to_hir_id` does not carry any meaningful information, so we can just skip calling it altogether.
bors [Mon, 29 Nov 2021 10:34:52 +0000 (10:34 +0000)]
Auto merge of #91350 - matthiaskrgr:rollup-nleabdj, r=matthiaskrgr
Rollup of 5 pull requests
Successful merges:
- #91049 (Add a caveat to std::os::windows::fs::symlink_file)
- #91281 (Add demonstration test for #91161)
- #91327 (Delete an unreachable codepath from format_args implementation)
- #91336 (Remove unused root_parent.)
- #91349 (Accumulate all values of `-C remark` option)
Matthias Krüger [Mon, 29 Nov 2021 09:41:33 +0000 (10:41 +0100)]
Rollup merge of #91049 - dimo414:patch-1, r=kennytm
Add a caveat to std::os::windows::fs::symlink_file
This is similar to the note on [Python's `os.symlink()`](https://docs.python.org/3/library/os.html#os.symlink). Some additional notes in https://github.com/dimo414/bkt/issues/3.
bors [Mon, 29 Nov 2021 01:35:33 +0000 (01:35 +0000)]
Auto merge of #91338 - matthiaskrgr:rollup-46ry8wi, r=matthiaskrgr
Rollup of 3 pull requests
Successful merges:
- #90131 (Fix a format_args span to be expansion)
- #90832 (Add 1.57.0 release notes)
- #90833 (Emit LLVM optimization remarks when enabled with `-Cremark`)
Matthias Krüger [Sun, 28 Nov 2021 22:45:17 +0000 (23:45 +0100)]
Rollup merge of #90833 - tmiasko:optimization-remarks, r=nikic
Emit LLVM optimization remarks when enabled with `-Cremark`
The default diagnostic handler considers all remarks to be disabled by
default unless configured otherwise through LLVM internal flags:
`-pass-remarks`, `-pass-remarks-missed`, and `-pass-remarks-analysis`.
This behaviour makes `-Cremark` ineffective on its own.
Fix this by configuring a custom diagnostic handler that enables
optimization remarks based on the value of `-Cremark` option. With
`-Cremark=all` enabling all remarks.
bors [Sun, 28 Nov 2021 22:29:57 +0000 (22:29 +0000)]
Auto merge of #90681 - workingjubilee:update-libc, r=JohnTitor
Update libc to 0.2.108
Changelog:
https://github.com/rust-lang/libc/releases/tag/0.2.107
https://github.com/rust-lang/libc/releases/tag/0.2.108
Primarily intended to pull in rust-lang/libc@fd331f65f214ea75b6210b415b5fd8650be15c73
This should help with https://github.com/rust-lang/rust/pull/90044
bors [Sun, 28 Nov 2021 17:14:04 +0000 (17:14 +0000)]
Auto merge of #91320 - matthiaskrgr:rollup-r209seq, r=matthiaskrgr
Rollup of 3 pull requests
Successful merges:
- #91251 (Perform Sync check on static items in wf-check instead of during const checks)
- #91308 (Fix ICE when lowering `trait A where for<'a> Self: 'a`)
- #91319 (Change output path to {{build-base}} for rustdoc scrape_examples ui test)
Matthias Krüger [Sun, 28 Nov 2021 16:11:10 +0000 (17:11 +0100)]
Rollup merge of #91251 - oli-obk:wf_sync_statics, r=matthewjasper
Perform Sync check on static items in wf-check instead of during const checks
r? `@RalfJung`
This check is solely happening on the signature of the static item and not on its body, therefor it belongs into wf-checking instead of const checking.
bors [Sun, 28 Nov 2021 13:04:27 +0000 (13:04 +0000)]
Auto merge of #91230 - eggyal:fallible-type-fold, r=jackh726
Make `TypeFolder::fold_*` return `Result`
Implements rust-lang/compiler-team#432.
Initially this is just a rebase of `@LeSeulArtichaut's` work in #85469 (abandoned; see https://github.com/rust-lang/rust/pull/85485#issuecomment-908781112). At that time, it caused a regression in performance that required some further exploration... with this rebased PR bors can hopefully report some perf analysis from which we can investigate further (if the regression is indeed still present).
bors [Sun, 28 Nov 2021 09:57:59 +0000 (09:57 +0000)]
Auto merge of #91311 - matthiaskrgr:rollup-ju9xizl, r=matthiaskrgr
Rollup of 3 pull requests
Successful merges:
- #90896 (Stabilize some `MaybeUninit` behavior as const)
- #91254 (Only check for errors in predicate when skipping impl assembly)
- #91303 (Miri: fix alignment check in array initialization)
Matthias Krüger [Sun, 28 Nov 2021 09:42:40 +0000 (10:42 +0100)]
Rollup merge of #91303 - RalfJung:array-init-align, r=oli-obk
Miri: fix alignment check in array initialization
https://github.com/rust-lang/rust/pull/85376 introduced a regression in Miri, reported at https://github.com/rust-lang/miri/issues/1919 and https://github.com/rust-lang/miri/issues/1925. This PR fixes that. I will add tests to Miri once this lands.
Matthias Krüger [Sun, 28 Nov 2021 09:42:39 +0000 (10:42 +0100)]
Rollup merge of #91254 - Aaron1011:impl-candidate-err-ty, r=lcnr
Only check for errors in predicate when skipping impl assembly
Prior to PR #91205, checking for errors in the overall obligation
would check checking the `ParamEnv`, due to an incorrect
`super_visit_with` impl. With this bug fixed, we will now
bail out of impl candidate assembly if the `ParamEnv` contains
any error types.
In practice, this appears to be overly conservative - when an error
occurs early in compilation, we end up giving up early for some
predicates that we could have successfully evaluated without overflow.
By only checking for errors in the predicate itself, we avoid causing
additional spurious 'type annotations needed' errors after a 'real'
error has already occurred.
With this PR, the diagnostic changes caused by PR #91205 are reverted.
Matthias Krüger [Sun, 28 Nov 2021 09:42:38 +0000 (10:42 +0100)]
Rollup merge of #90896 - jhpratt:stabilize_const_maybe_uninit, r=oli-obk
Stabilize some `MaybeUninit` behavior as const
This stabilizes the `MaybeUninit::as_ptr`, `MaybeUninit::assume_init`, and `MaybeUninit::assume_init_ref` as `const fn`. `MaybeUninit::as_mut_ptr` has been moved to a new flag: `const_maybe_uninit_as_mut_ptr`, which is blocked on #57349. `MaybeUninit::slice_assume_init_ref` can be `const fn` when the method is stabilized in general.
The relevant intrinsic has been stabilized as `const` as well, though this isn't user-visible. Due to the seemingly unrelated feature name I performed `rg const_assert_type` and found no other instances of it being used.
Jubilee Young [Mon, 8 Nov 2021 01:28:04 +0000 (17:28 -0800)]
Update libc to 0.2.108
Changelog:
https://github.com/rust-lang/libc/releases/tag/0.2.107
https://github.com/rust-lang/libc/releases/tag/0.2.108
Primarily intended to pull in fd331f65f214ea75b6210b415b5fd8650be15c73
This should help with https://github.com/rust-lang/rust/pull/90044
Thus the only way the **first** chunk could have an empty `broken` is if it is the **final** chunk, i.e. there is only one chunk total. And the only way that there could be one chunk total with an empty `broken` is if the whole input is valid utf8 and non-empty.
That condition has already been handled by an early return, so at the point that the first `REPLACEMENT` is being pushed, it's impossible for `first_broken` to be empty.
Aaron Hill [Fri, 26 Nov 2021 15:14:16 +0000 (09:14 -0600)]
Only check for errors in predicate when skipping impl assembly
Prior to PR #91205, checking for errors in the overall obligation
would check checking the `ParamEnv`, due to an incorrect
`super_visit_with` impl. With this bug fixed, we will now
bail out of impl candidate assembly if the `ParamEnv` contains
any error types.
In practice, this appears to be overly conservative - when an error
occurs early in compilation, we end up giving up early for some
predicates that we could have successfully evaluated without overflow.
By only checking for errors in the predicate itself, we avoid causing
additional spurious 'type annotations needed' errors after a 'real'
error has already occurred.
With this PR, the diagnostic changes caused by PR #91205 are reverted.
bors [Sat, 27 Nov 2021 11:31:26 +0000 (11:31 +0000)]
Auto merge of #89916 - the8472:advance_by-avoid-err-0, r=dtolnay
Fix Iterator::advance_by contract inconsistency
The `advance_by(n)` docs state that in the error case `Err(k)` that k is always less than n.
It also states that `advance_by(0)` may return `Err(0)` to indicate an exhausted iterator.
These statements are inconsistent.
Since only one implementation (Skip) actually made use of that I changed it to return Ok(()) in that case too.
While adding some tests I also found a bug in `Take::advance_back_by`.
Matthias Krüger [Sat, 27 Nov 2021 10:46:45 +0000 (11:46 +0100)]
Rollup merge of #91266 - jam1garner:fmt-ptr-fix, r=dtolnay
Use non-generic inner function for pointer formatting
Previously, despite the implementation being type-unaware, `fmt::Pointer`'s implementation for `*const T` in monomorphized. This affects:
* `fmt::Debug` for `*const T`
* `fmt::Debug` for `*mut T`
* `fmt::Pointer` for `*const T`
* `fmt::Pointer` for `*mut T`
And since the implementation is non-trivial, this results in a large amount of LLVM bitcode being generated. For example, with a large bindgen project with Debug implementations enabled, it will generate a lot of calls to `fmt::Debug for *const T`, which in turn will perform codegen for a copy of this function for every type.
For example, in a real-world bindgen'd header I've been testing with (4,189,245 lines of bindgen Rust with layout tests disabled) the difference between a slightly old nightly (`rustc 1.58.0-nightly (e249ce6b2 2021-10-30)`) and this PR:
<details>
<summary>Nightly (Click to Expand)</summary>
Output generated using `cargo llvm-lines` version 0.4.12.
Summary of differences:
| rustc Version | Total LLVM line count | `*const T as fmt::Pointer` LLVM lines | Compilation Time |
|-|-|-|-|
| `nightly` | 7256000 | 1815449 (25.0% of binary) | 537.014 |
| PR | 5684504 (-21.65%) | 266265 (4.7% of binary) (-85.3% from nightly) | 502.990 |
This results in a pretty noticeable as the majority of rustc's time is spent in either codegen or LLVM, in this case, and is significantly improved by disabling derives for `fmt::Debug`, as it prevents generating all this LLVM IR to be handled.
Here's a run time comparison with nightly on the same codebase (commit 454cc5fb built from source vs 37c8f25 from my PR built from source):
<details>
<summary>nightly (Click to Expand)</summary>
There were a few places in rustdoc where we would take static JS or CSS and rewrite it at doc generation time to insert values. This consolidates all the CSS instances into one CSS file and replaces the JS examples with data- attributes on the rustdoc-vars div.