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=.`
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.
When recovering from a `:` in a pattern, use adequate AST pattern
If the suggestion to use `::` instead of `:` in the pattern isn't correct, a second resolution error will be emitted.
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=.`
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.
Cc ```@rust-lang/wg-const-eval```
tests: Ignore `test/debuginfo/rc_arc.rs` on windows-gnu
The tests checks some pretty-printer output, but pretty-printers are not embedded on windows-gnu.
Regressed in https://github.com/rust-lang/rust/pull/85448.
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.
Accumulate all values of `-C remark` option
When `-C remark=...` option is specified multiple times,
accumulate all values instead of using only the last one.
r? `@nikic`
Add demonstration test for #91161
Since cross-crate things are hard to demonstrate in playground, here's a test showing that something currently works that shouldn't.
cc https://github.com/rust-lang/rust/issues/91161 that tracks fixing the problem (and updating this test)
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.
Fixes#90924.
r? `@nikic`
Fix ICE when lowering `trait A where for<'a> Self: 'a`
Fixes#88586.
r? `@jackh726`
Jack, this fix is much smaller in scope than what I think you were proposing in the issue. Let me know if you had a vision for a larger refactor here.
cc `@JohnTitor`
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.
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.
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.
Account for incorrect `where T::Assoc = Ty` bound
Provide suggestoin to constrain trait bound for associated type.
Revert incorrect changes to `missing-bounds` test.
Address part of #20041.
rustdoc: Consolidate static-file replacement mechanism
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.
Demo https://rustdoc.crud.net/jsha/static-file-replace/test_docs/
r? ``@GuillaumeGomez``
Remove `--display-doctest-warnings`
`--display-doctest-warnings` can be replicated in full with other existing features, there's no
need to have a separate option for it. This removes the option and documents the combination of other features to replicate it.
This also fixes a bug where `--test-args=--show-output` had no effect.
cc `@ollie27,` https://github.com/rust-lang/rust/pull/73314#issuecomment-668317262
Fixes https://github.com/rust-lang/rust/issues/41574
r? `@GuillaumeGomez`
Fix another ICE in rustdoc scrape_examples
This has occurred to me when documenting a crate with the arguments. Not sure what could have caused it.
r? `@willcrichton`
This can be replicated in full with other existing features, there's no
need to have a separate option for it.
This also fixes a bug where `--test-args=--show-output` had no effect,
and updates the documentation.
Rollup of 4 pull requests
Successful merges:
- #91169 (Change cg_ssa's get_param to borrow the builder mutably)
- #91176 (If the thread does not get the lock in the short term, yield the CPU)
- #91212 (Fix ICE due to out-of-bounds statement index when reporting borrowck error)
- #91225 (Fix invalid scrollbar display on source code page)
Failed merges:
r? `@ghost`
`@rustbot` modify labels: rollup
Fix ICE due to out-of-bounds statement index when reporting borrowck error
Replace an `[index]` with a `.get` when `statement_index` points to a basic-block terminator (and is therefore out-of-bounds in the statements list).
Fixes#91206
Cc ``@camsteffen``
r? ``@oli-obk``
Fix stack overflow in `usefulness.rs`
Fix#88747
Applied the suggestion from `@nbdd0121,` not sure if this has any drawbacks. The first call to `ensure_sufficient_stack` is not needed to fix the test case, but I added it to be safe.
Visit `param_env` field in Obligation's `TypeFoldable` impl
This oversight appears to have gone unnoticed for a long time
without causing issues, but it should still be fixed.
Improve rustdoc-gui CI
As commented [here](https://github.com/rust-lang/rust/pull/91179#discussion_r756023009):
When the text isn't displayed, the color returned by puppeteer is always `rgba(0,0,0,0)`, which is definitely not the right value. To prevent this error from happening again, `browser-ui-test` will now fail if a CSS color check is run when the text isn't displayed.
Either this PR or #91179 is merged first, they'll conflict because I made changes to the same test file.
cc `@jyn514`
r? `@jsha`
Diagnostic tweaks
* On type mismatch caused by assignment, point at the source of the expectation
* Hide redundant errors
* Suggest `while let` when `let` is missing in some cases