Commit Graph

9543 Commits

Author SHA1 Message Date
bors
584f183dc0 Auto merge of #124194 - matthiaskrgr:rollup-40s0c4q, r=matthiaskrgr
Rollup of 3 pull requests

Successful merges:

 - #123409 (Implement Modified Condition/Decision  Coverage)
 - #124104 (Fix capturing duplicated lifetimes via parent in `precise_captures` (`impl use<'...>`))
 - #124137 (Match hyphen in multi-revision comment matchers)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-04-20 10:50:39 +00:00
Matthias Krüger
ff9a0b19ff
Rollup merge of #124104 - compiler-errors:parent-generic-use, r=oli-obk
Fix capturing duplicated lifetimes via parent in `precise_captures` (`impl use<'...>`)

For technical reasons related to the way that `Self` and `T::Assoc` are lowered from HIR -> `rustc_middle::ty`, an opaque may mention in its bounds both the original early-bound lifetime from the parent `impl`/`fn`, *and* the *duplicated* early-bound lifetime on the opaque.

This is fine -- and has been fine since `@cjgillot` rewrote the way we handled opaque lifetime captures, and we went further to allow this behavior explicitly in https://github.com/rust-lang/rust/pull/115659. It's worthwhile to read this PR's technical section to recall how this duplication works and when it acts surprisingly.

The problem here is that the check that make sure that `impl use<'a, 'b>` lists all of the opaque's captured lifetimes wasn't smart enough to consider both these captured lifetimes and the original lifetimes they're duplicated from to be equal. This PR fixes that.

r? oli-obk
2024-04-20 11:10:31 +02:00
Matthias Krüger
efb264fa78
Rollup merge of #123409 - ZhuUx:master, r=oli-obk
Implement Modified Condition/Decision  Coverage

This is an implementation based on llvm backend support (>= 18) by `@evodius96` and branch coverage support by `@Zalathar.`

### Major changes:

* Add -Zcoverage-options=mcdc as switch. Now coverage options accept either `no-branch`, `branch`, or `mcdc`. `mcdc` also enables `branch` because it is essential to work.
* Add coverage mapping for MCDCBranch and MCDCDecision. Note that MCDCParameter evolves from  llvm 18 to llvm 19. The mapping in rust side mainly references to 19 and is casted to 18 types in llvm wrapper.
* Add wrapper for mcdc instrinc functions from llvm. And inject associated statements to mir.
* Add BcbMappingKind::Decision, I'm not sure is it proper but can't find a better way temporarily.
* Let coverage-dump support parsing MCDCBranch and MCDCDecision from llvm ir.
* Add simple tests to check whether mcdc works.
* Same as clang, currently rustc does not generate instrument for decision with more than 6 condtions or only 1 condition due to considerations of resource.

### Implementation Details

1. To get information about conditions and decisions, `MCDCState` in `BranchInfoBuilder` is used during hir lowering to mir. For expressions with logical op we call `Builder::visit_coverage_branch_operation` to record its sub conditions, generate condition ids for them and save their spans (to construct the span of whole decision). This process mainly references to the implementation in clang and is described in comments over `MCDCState::record_conditions`. Also true marks and false marks introduced by branch coverage are used to detect where the decision evaluation ends: the next id  of the condition == 0.
2. Once the `MCDCState::decision_stack` popped all recorded conditions, we can ensure that the decision is checked over and push it into `decision_spans`. We do not manually insert decision span to avoid complexity from then_else_break in nested if scopes.
3. When constructing CoverageSpans, add condition info to BcbMappingKind::Branch and decision info to BcbMappingKind::Decision. If the branch mapping has non-zero condition id it will be transformed to MCDCBranch mapping and insert `CondBitmapUpdate` statements to its evaluated blocks. While decision bcb mapping will insert `TestVectorBitmapUpdate` in all its end blocks.

### Usage
```bash
 echo "[build]\nprofiler=true" >> config.toml
./x build --stage 1
./x test tests/coverage/mcdc_if.rs
```
to build the compiler and run tests.

```shell
export PATH=path/to/llvm-build:$PATH
rustup toolchain link mcdc build/host/stage1
cargo +mcdc rustc --bin foo -- -Cinstrument-coverage -Zcoverage-options=mcdc
cd target/debug
LLVM_PROFILE_FILE="foo.profraw" ./foo
llvm-profdata merge -sparse foo.profraw -o foo.profdata
llvm-cov show ./foo -instr-profile=foo.profdata --show-mcdc
```
to check "foo" code.

### Problems to solve

For now decision mapping will insert statements to its all end blocks, which may be optimized by inserting a final block of the decision. To do this we must also trace the evaluated value at each end of the decision and join them separately.

This implementation is not heavily tested so there should be some unrevealed issues. We are going to check our rust products in the next.  Please let me know if you had any suggestions or comments.
2024-04-20 11:10:31 +02:00
bors
a61b14d15e Auto merge of #124156 - DianQK:disable-match_branches, r=RalfJung
Disable SimplifyToExp in MatchBranchSimplification

Due to the miscompilation mentioned in #124150, We need to disable MatchBranchSimplification temporarily.

To fully resolve this issue, my plan is:
1. Disable SimplifyToExp in MatchBranchSimplification (this PR).
2. Remove all potentially unclear transforms in #124122.
3. Gradually add back the removed transforms (possibly multiple PRs).

r? `@Nilstrieb` or `@oli-obk`
2024-04-20 08:47:07 +00:00
bors
f1bff1f323 Auto merge of #124176 - matthiaskrgr:tests_are_the_best, r=jieyouxu
add more known crashes tests

r? `@jieyouxu`
2024-04-20 06:36:58 +00:00
bors
9c7b1f4848 Auto merge of #124114 - scottmcm:better-checked, r=workingjubilee
Make `checked` ops emit *unchecked* LLVM operations where feasible

For things with easily pre-checked overflow conditions -- shifts and unsigned subtraction -- write the checked methods in such a way that we stop emitting wrapping versions of them.

For example, today <https://rust.godbolt.org/z/qM9YK8Txb> neither
```rust
a.checked_sub(b).unwrap()
```
nor
```rust
a.checked_sub(b).unwrap_unchecked()
```
actually optimizes to `sub nuw`.  After this PR they do.

cc #103299
2024-04-20 04:11:16 +00:00
bors
db701c2aad Auto merge of #124166 - oli-obk:define_opaque_types11, r=compiler-errors
Let inherent associated types constrain opaque types during projection

r? `@compiler-errors`

The same test ICEs on master: https://play.rust-lang.org/?version=nightly&mode=debug&edition=2021&gist=f4ff62663a5a3a0e16d00953ee7414d5
2024-04-20 00:02:59 +00:00
DianQK
b52be28fda
Disable SimplifyToExp in MatchBranchSimplification 2024-04-20 05:37:53 +08:00
Matthias Krüger
b015f61488 add more known-crashes tests 2024-04-19 23:09:37 +02:00
Matthias Krüger
e0586a6e1a add test for #83993
Fixes #83993
2024-04-19 23:09:37 +02:00
Michael Goulet
5daf58ffc1 Fix capturing duplicated lifetimes via parent 2024-04-19 14:12:21 -04:00
Matthias Krüger
f8afb6314b
Rollup merge of #124149 - notriddle:notriddle/desc-alias, r=GuillaumeGomez
rustdoc-search: fix description on aliases in results

This needs to start downloading the descriptions after aliases have been added to the result set.
2024-04-19 19:30:49 +02:00
Matthias Krüger
26d4b1bfba
Rollup merge of #124106 - compiler-errors:tait-lifetime-dedup, r=oli-obk
Don't repeatedly duplicate TAIT lifetimes for each subsequently nested TAIT

Make it so that nested TAITs inherit the lifetimes from their parent item, not their parent TAIT. This is because we don't need to re-duplicate lifetimes for nested TAITs over and over, since the only lifetimes they can capture are from the parent item anyways.

This mirrors how RPITs work. This is **not** a functional change that should be observable, since the whole point of duplicating lifetimes and marking the shadowed ones (and uncaptured ones) as bivariant is designed to *not* be observable.

r? oli-obk
2024-04-19 19:30:49 +02:00
Matthias Krüger
b1eee427a0
Rollup merge of #123729 - jieyouxu:rmake-refactor-2, r=oli-obk
run-make: refactor out command wrappers for `clang` and `llvm-readobj`

This PR is rebased on top of https://github.com/rust-lang/rust/pull/123699.

This PR is a follow up to https://github.com/rust-lang/rust/pull/123612 to refactor out command wrappers into the support library for `llvm-readobj` and `clang`.

r? ghost
2024-04-19 19:30:48 +02:00
Matthias Krüger
6c4657c086
Rollup merge of #123571 - WaffleLapkin:properly-adjust-never, r=compiler-errors
Correctly change type when adding adjustments on top of `NeverToAny`

I'm concerned that the check only caught the problem with `fallback = !`, because at least MIR contained `<() as PartialEq>::eq(move _5, move _7)` where `_5: ()`.

I rediscovered the issue when looking at #123482's crater run.

r? compiler-errors
Fixes #120600
2024-04-19 19:30:48 +02:00
zhuyunxing
402dc38d99 coverage. Add basic tests for MC/DC 2024-04-20 00:34:40 +08:00
Oli Scherer
dadece067e Let inherent associated types constrain opaque types during projection 2024-04-19 16:12:54 +00:00
bors
d1a0fa5ed3 Auto merge of #118441 - GuillaumeGomez:display-stability-version, r=rustdoc
Always display stability version even if it's the same as the containing item

Fixes https://github.com/rust-lang/rust/issues/118439.

Currently, if the containing item's version is the same as the item's version (like a method), we don't display it on the item.

This was something done on purpose as you can see [here](e9b7bf0114/src/librustdoc/html/render/mod.rs (L949-L955)). It was implemented in https://github.com/rust-lang/rust/pull/30686.

I think we should change this because on pages with a lot of items, if someone arrives (through the search or a link) to an item far below the page, they won't know the stability version unless they scroll to the top, which isn't great.

You can see the result [here](https://rustdoc.crud.net/imperio/display-stability-version/std/pin/struct.Pin.html#method.new).

r? `@notriddle`
2024-04-19 14:17:29 +00:00
Maybe Waffle
e5a6d8d0cd Remove old ICE tests that no longer ICE (yay!) 2024-04-19 11:34:37 +00:00
Maybe Waffle
0bbe362901 Correctly change type when adding adjustments on top of NeverToAny 2024-04-19 11:05:02 +00:00
Maybe Waffle
4d749cad25 Add a test for a == b where a: !, b: !
(this currently produces malformed mir: we call `eq` with first argument not
being a reference)
2024-04-19 11:05:02 +00:00
Maybe Waffle
662d276573 Add regression test for issue 120600 2024-04-19 11:05:02 +00:00
Michael Howell
2e7d9e9acb rustdoc-search: fix description on aliases in results
This needs to start downloading the descriptions after aliases
have been added to the result set.
2024-04-18 22:21:29 -07:00
Jubilee
f36ca7a75f
Rollup merge of #124110 - beetrees:neg-f16-f128, r=compiler-errors
Fix negating `f16` and `f128` constants

Make `f16` and `f128` constants respect `neg` in `parse_float_into_scalar`.

Tracking issue: #116909

```@rustbot``` label +F-f16_and_f128
2024-04-18 21:38:57 -07:00
Jubilee
f174c310ae
Rollup merge of #123935 - tstsrt:fix-115423, r=oli-obk
Don't inline integer literals when they overflow - new attempt

Basically #116633 but I implemented the suggested changes.
Fixes #115423. Fixes #116631.

This is my first contribution to this repo so please let me know if I'm supposed to change something :)
2024-04-18 21:38:55 -07:00
Jubilee
0a0a5a956c
Rollup merge of #123752 - estebank:emoji-prefix, r=wesleywiser
Properly handle emojis as literal prefix in macros

Do not accept the following

```rust
macro_rules! lexes {($($_:tt)*) => {}}
lexes!(🐛"foo");
```

Before, invalid emoji identifiers were gated during parsing instead of lexing in all cases, but this didn't account for macro pre-expansion of literal prefixes.

Fix #123696.
2024-04-18 21:38:55 -07:00
zhuyunxing
68f86381ee coverage. Add coverage-options=mcdc as gate for MC/DC instrument 2024-04-19 10:43:53 +08:00
Scott McMurray
986d9f104b Make checked ops emit *unchecked* LLVM operations where feasible
For things with easily pre-checked overflow conditions -- shifts and unsigned subtraction -- write then checked methods in such a way that we stop emitting wrapping versions of them.

For example, today <https://rust.godbolt.org/z/qM9YK8Txb> neither
```rust
a.checked_sub(b).unwrap()
```
nor
```rust
a.checked_sub(b).unwrap_unchecked()
```
actually optimizes to `sub nuw`.  After this PR they do.
2024-04-18 18:11:21 -07:00
bors
fa0068b541 Auto merge of #124038 - matthiaskrgr:one_or_two_more_tests, r=jieyouxu
crashes: add a couple more ice tests
2024-04-19 01:02:44 +00:00
bors
e3181b091e Auto merge of #119912 - notriddle:notriddle/reexport-dedup, r=GuillaumeGomez
rustdoc-search: single result for items with multiple paths

Part of #15723

Preview: https://notriddle.com/rustdoc-html-demo-9/reexport-dup/std/index.html?search=hashmap

This change uses the same "exact" paths as trait implementors and type alias inlining to track items with multiple reachable paths. This way, if you search for `vec`, you get only the `std` exports of it, and not the one from `alloc`.

It still includes all the items in the search index so that you can search for them by all available paths. For example, try `core::option` and `std::option`, and notice that the results page doesn't show duplicates, but still shows all the items in their respective crates.
2024-04-18 21:23:15 +00:00
bors
3412f01749 Auto merge of #123949 - scottmcm:debug-no-means-no-debug-info-when-inlined, r=oli-obk,onur-ozkan
At debuginfo=0, don't inline debuginfo when inlining

See https://github.com/rust-lang/rust/pull/123949#issuecomment-2060493285 for info.
2024-04-18 19:12:28 +00:00
Matthias Krüger
1d45b7adaf crashes: add a couple more tests 2024-04-18 18:55:20 +02:00
Scott McMurray
20cf59549f The ICE in 121127 needs debuginfo 2024-04-18 09:42:26 -07:00
Scott McMurray
90b4c86335 Ensure [rust] debuginfo-level-std doesn't change core's MIR 2024-04-18 09:35:36 -07:00
Scott McMurray
6094063c35 Update checked_ops so 32- and 64-bit gets the same checks 2024-04-18 09:35:36 -07:00
Scott McMurray
d05545c05d At debuginfo=0, don't inline debuginfo when inlining 2024-04-18 09:35:35 -07:00
bors
0e15f5ee8f Auto merge of #124072 - saethlin:less-sysroot-libc-misc, r=jieyouxu
Remove libc from more tests

The goal here is to trim down the number of tests that depend on libc from the sysroot to make https://github.com/rust-lang/rust/pull/123938 more plausible.

This PR is a few simple cases that I missed in https://github.com/rust-lang/rust/pull/123943.
2024-04-18 14:59:36 +00:00
Ben Kimock
8047fadbf3 Add an exception for windows-msvc 2024-04-18 09:52:00 -04:00
bors
ecd45472f8 Auto merge of #124111 - matthiaskrgr:rollup-cmmkryf, r=matthiaskrgr
Rollup of 5 pull requests

Successful merges:

 - #124041 (Fix copy path button)
 - #124047 (Match ergonomics 2024: miscellaneous code cleanups)
 - #124064 (Move confusing comment about otherwise blocks in `lower_match_tree`)
 - #124090 (llvm: update riscv target feature to match LLVM 19)
 - #124100 (fix: make `str::from_raw_parts_mut` `mut`)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-04-18 07:26:15 +00:00
Matthias Krüger
90013ff5ad
Rollup merge of #124090 - durin42:llvm-19-riscv-feature, r=cuviper
llvm: update riscv target feature to match LLVM 19

In llvm/llvm-project@9067070d91 they ended up largely reverting
llvm/llvm-project@e817966718. This means the change we did in
rust-lang/rust@b378059e6b is now only corrct for LLVM 18...so we have to adjust again.

``@rustbot`` label: +llvm-main
2024-04-18 08:37:49 +02:00
Matthias Krüger
7add0bdf7e
Rollup merge of #124047 - Jules-Bertholet:match-ergonomics-cleanups, r=Nadrieril
Match ergonomics 2024: miscellaneous code cleanups

- Store `ByRef` instead of `BindingAnnotation` in `PatInfo`
- Rename `BindingAnnotation` to `BindingMode`

r? ``@Nadrieril``

cc #123076

``@rustbot`` label A-patterns
2024-04-18 08:37:48 +02:00
Matthias Krüger
56f4ac308b
Rollup merge of #124041 - GuillaumeGomez:fix-copy-path-button, r=notriddle
Fix copy path button

Currently, on all nightly docs, clicking on the "copy path" button triggers a JS error. It's because changes in https://github.com/rust-lang/rust/pull/123706 forgot to update the JS (it contained an image before but not anymore).

I had to make some small changes in the CSS to fix the display when the button was clicked as well.

r? ``@notriddle``
2024-04-18 08:37:48 +02:00
beetrees
cc12a1b511
Fix negating f16 and f128 constants 2024-04-18 06:43:44 +01:00
bors
b1248bc60d Auto merge of #124046 - matthiaskrgr:one_or_two_more_tests____some_on_top, r=jieyouxu
crashes: add even more tests?!?

adds more tests that were not already added with https://github.com/rust-lang/rust/pull/124038 from the past 10 months or so.
Need a couple more passes through the tracker to filter out more missing ice /fixed tests but we're slowly getting there.
2024-04-18 05:23:09 +00:00
Matthias Krüger
06335c6532 crashes: add even more tests?!? 2024-04-18 06:13:47 +02:00
bors
5260893724 Auto merge of #122684 - oli-obk:delay_interning_errors_to_after_validaiton, r=RalfJung
Delay interning errors to after validation

fixes https://github.com/rust-lang/rust/issues/122398
fixes #122548

This improves diagnostics since validation errors are usually more helpful compared with interning errors that just make broad statements about the entire constant

r? `@RalfJung`
2024-04-18 02:34:04 +00:00
Michael Goulet
ffb4206577 Don't repeatedly duplicate TAIT lifetimes for each subsequently nested TAIT 2024-04-17 22:29:59 -04:00
Augie Fackler
22b704bac4 llvm: update riscv target feature to match LLVM 19
In llvm/llvm-project@9067070d91 they ended
up largely reverting
llvm/llvm-project@e817966718. This means
the change we did in
rust-lang/rust@b378059e6b is now only
corrct for LLVM 18...so we have to adjust again.

@rustbot label: +llvm-main
2024-04-17 16:15:24 -04:00
bors
38104f3a88 Auto merge of #123936 - Mark-Simulacrum:zst-no-alloc, r=oli-obk
Codegen ZSTs without an allocation

This makes sure that &[] is equivalent to unsafe code (from_raw_parts(dangling, 0)). No new stable guarantee is intended about whether or not we do this, this is just an optimization.

This regressed in #67000 (no comments I can see about that regression in the PR, though it did change the test modified here). We had previously performed this optimization since #63635.
2024-04-17 18:31:10 +00:00
许杰友 Jieyou Xu (Joe)
ca945e9ed8 tests: update cross-lang-lto-riscv-abi to use command wrappers 2024-04-17 16:28:49 +00:00