Commit Graph

253406 Commits

Author SHA1 Message Date
Nadrieril
5c4909b8e1 Track mutability of deref patterns 2024-04-20 15:59:54 +02:00
Nadrieril
1dabacd059 Don't fake borrow inside a deref pattern 2024-04-20 15:59:54 +02:00
Nadrieril
c623319a30 Lower deref patterns to MIR
This handles using deref patterns to choose the correct match arm. This
does not handle bindings or guards.

Co-authored-by: Deadbeef <ent3rm4n@gmail.com>
2024-04-20 15:59:54 +02:00
Daniel Sedlak
be564a8add Print note with closure signature on type mismatch 2024-04-20 15:48:27 +02:00
bors
c3ceb00281 Auto merge of #124190 - RalfJung:pat-compare-with-fast-path, r=Nadrieril
PatRangeBoundary::compare_with: als add a fast-path for signed integers

Not sure if we have a benchmark that hits this... but it seems odd to only do this for unsigned integers.
2024-04-20 12:54:15 +00:00
Guillaume Gomez
dd01f75a89 Move duplicated code in functions in tests/rustdoc-gui/notable-trait.goml 2024-04-20 14:53:14 +02:00
Maybe Waffle
468179c680 Fixup rustc_codegen_gcc test signature 2024-04-20 12:18:21 +00:00
Ralf Jung
75d0fdd967 mir-opt tests: rename unit-test -> test-mir-pass 2024-04-20 13:19:34 +02:00
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
Ralf Jung
61a7d3d523 ensure the ICE-to-file logic does not affect our test 2024-04-20 11:42:10 +02:00
Matthias Krüger
f58ef084c9
Rollup merge of #124137 - tgross35:testsuite-multi-rev-regex, r=jieyouxu
Match hyphen in multi-revision comment matchers

Currently, the matcher `//[rev-foo,rev-bar]~` does not get selected by the regex. Change the matcher to include `-`.
2024-04-20 11:10:32 +02: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
Arpad Borsos
488598c183
Add a lower bound check to unicode-table-generator output
This adds a dedicated check for the lower bound
(if it is outside of ASCII range) to the output of the `unicode-table-generator` tool.

This generalized the ASCII-only fast-path, but only for the `Grapheme_Extend` property for now,
as that is the only one with a lower bound outside of ASCII.
2024-04-20 10:16:45 +02:00
bors
6b0ce8b1e2 Auto merge of #3495 - RalfJung:data-race-clocks, r=RalfJung
data_race: make the release/acquire API more clear
2024-04-20 08:11:15 +00:00
Ralf Jung
8cab0d5617 restrict VClock API surface 2024-04-20 10:09:31 +02:00
Jakub Beránek
d2059aef27
Move auto jobs to calculate-job-matrix.py 2024-04-20 09:54:47 +02:00
Jakub Beránek
6f0ff0b03a
Refactor calculate-job-matrix.py 2024-04-20 09:21:55 +02:00
Ralf Jung
cb1b4a6977 reuse_pool: only do acquire_clock if we reused from a different thread 2024-04-20 09:08:09 +02:00
Jakub Beránek
7a90679e28
Perform PR and try builds dynamically 2024-04-20 09:07:11 +02:00
Jakub Beránek
9fec43ddf1
Move calculate-job-matrix.py to ci/github-actions 2024-04-20 09:06:04 +02:00
Ralf Jung
7dcfb54dc6 data_race: make the release/acquire API more clear 2024-04-20 09:01:53 +02:00
David Tolnay
debdb72ba8
Give a name to each distinct manipulation of pretty-printer FixupContext 2024-04-19 23:49:44 -07:00
David Tolnay
912c67043b
Move pretty-printer FixupContext to a module
Required for being able to make the fields private and force the use of
accessor methods, which will be added in the next commit.
2024-04-19 23:46:12 -07: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
Ralf Jung
727fe81fd6 PatRangeBoundary::compare_with: als add a fast-path for signed integers 2024-04-20 08:34:57 +02:00
bors
9713ff45ab Auto merge of #3494 - rust-lang:rustup-2024-04-20, r=RalfJung
Automatic Rustup
2024-04-20 06:28:05 +00:00
Ralf Jung
7952316aff re-bless tests 2024-04-20 08:26:48 +02:00
Ralf Jung
8e1f18dce8 fix clippy warning 2024-04-20 08:26:42 +02:00
The Miri Cronjob Bot
b63bb1b374 Merge from rustc 2024-04-20 05:12:44 +00:00
The Miri Cronjob Bot
29e41fbc30 Preparing for merge from rustc 2024-04-20 05:05:23 +00:00
Gurinder Singh
02ac46c0c2 Suggest using unsigned_abs in abs documentation 2024-04-20 10:18:47 +05:30
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
c8d19a92aa Auto merge of #124177 - weihanglo:update-cargo, r=weihanglo
Update cargo

8 commits in 6f06fe908a5ee0f415c187f868ea627e82efe07d..80d5b607dde6ef97dfff4e23923822c01d2bb036
2024-04-16 18:47:44 +0000 to 2024-04-19 18:39:22 +0000
- fix 13773 - 'cargo build' fails when list_files() with gix is triggered (rust-lang/cargo#13777)
- fix(toml): Don't crash on parse errors that point to multi-byte character (rust-lang/cargo#13780)
- fix(toml)!: Disallow source-less dependencies (rust-lang/cargo#13775)
- fix(msrv): Put MSRV-aware resolver behind a config (rust-lang/cargo#13769)
- fix(msrv): Error, rather than panic, on rust-version 'x' (rust-lang/cargo#13771)
- fix(credential): trim newlines in tokens from stdin (rust-lang/cargo#13770)
- test(msrv): Re-organize MSRV tests (rust-lang/cargo#13767)
- feat(install): Including Locking message (rust-lang/cargo#13764)

r? ghost
2024-04-20 02:06:04 +00:00
Michael Goulet
86756c1804 Stop taking ParamTy/ParamConst/EarlyParamRegion/AliasTy by ref 2024-04-19 21:09:51 -04: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
Guillaume Gomez
d34be935ec Prevent creating the same Instance::mono multiple times 2024-04-19 23:13:58 +02: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
Weihang Lo
db881f67f3
Update cargo 2024-04-19 17:04:13 -04:00
bors
c83d8cf584 Auto merge of #17110 - Veykril:cargo-script-mvp, r=Veykril
Cargo script mvp

Based on https://github.com/rust-lang/rust-analyzer/pull/15456,

As the original PR stated, detached files are still horrendous to work with.
2024-04-19 20:51:10 +00:00
bors
e9ebc6f800 Auto merge of #3475 - RalfJung:reduce-reuse-recycle, r=RalfJung
Address reuse improvements and fixes

- when an address gets reused, establish a happens-before link in the data race model
- do not reuse stack addresses, and make the reuse rate configurable

Fixes https://github.com/rust-lang/miri/issues/3450
2024-04-19 20:50:04 +00:00
Trevor Gross
282488c808 Match hyphen in multi-revision comment matchers
Currently, the matcher `//[rev-foo,rev-bar]~` does not get selected by
the regex. Change the matcher to also match strings that contain a `-`.h
2024-04-19 16:03:44 -04:00
bors
f9b1614920 Auto merge of #124170 - matthiaskrgr:rollup-ldopl64, r=matthiaskrgr
Rollup of 5 pull requests

Successful merges:

 - #123571 (Correctly change type when adding adjustments on top of `NeverToAny`)
 - #123729 (run-make: refactor out command wrappers for `clang` and `llvm-readobj`)
 - #124106 (Don't repeatedly duplicate TAIT lifetimes for each subsequently nested TAIT)
 - #124149 (rustdoc-search: fix description on aliases in results)
 - #124155 (bootstrap: don't use rayon for sysinfo)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-04-19 19:18:56 +00:00
Maybe Waffle
c0b5cc9003 Do intrinsic changes in rustc_codegen_cranelift 2024-04-19 18:45:25 +00:00
bors
8621e79fa7 Auto merge of #17104 - hamirmahal:fix/usage-of-deprecated-version-of-node-in-metrics-yml, r=lnicola
fix: usage of `deprecated` version of `Node.js`

fixes #17103.
2024-04-19 18:36:33 +00:00
Hamir Mahal
3d6bd24dcb
fix: usage of deprecated version of Node.js 2024-04-19 11:18:25 -07:00
Michael Goulet
5daf58ffc1 Fix capturing duplicated lifetimes via parent 2024-04-19 14:12:21 -04:00