Commit Graph

253170 Commits

Author SHA1 Message Date
Caio
3aaa3941fd Move some tests 2024-04-21 15:43:43 -03:00
bors
fecb7b4309 Auto merge of #124193 - RalfJung:miri, r=RalfJung
Miri subtree update

r? `@ghost`
2024-04-21 11:01:46 +00:00
Ralf Jung
ae37b6ec58 the mir-validation ICE test behaves strangely on Windows hosts
let's just disable it there, this code is not platform-dependent anyway
2024-04-21 12:36:16 +02:00
bors
b9be3c47e5 Auto merge of #117457 - daxpedda:wasm-nontrapping-fptoint, r=wesleywiser
Stabilize Wasm target features that are in phase 4 and 5

This stabilizes the Wasm target features that are known to be working and in [phase 4 and 5](04fa8c810e).

Feature stabilized:
- [Non-trapping float-to-int conversions](https://github.com/WebAssembly/nontrapping-float-to-int-conversions)
- [Import/Export of Mutable Globals](https://github.com/WebAssembly/mutable-global)
- [Sign-extension operators](https://github.com/WebAssembly/sign-extension-ops)
- [Bulk memory operations](https://github.com/WebAssembly/bulk-memory-operations)
- [Extended Constant Expressions](https://github.com/WebAssembly/extended-const)

Features not stabilized:
- [Multi-value](https://github.com/WebAssembly/multi-value): requires rebuilding `std` #73755.
- [Reference Types](https://github.com/WebAssembly/reference-types): no point stabilizing without #103516.
- [Threads](https://github.com/webassembly/threads): requires rebuilding `std` #77839.
- [Relaxed SIMD](https://github.com/WebAssembly/relaxed-simd): separate PR #117468.
- [Multi Memory](https://github.com/WebAssembly/multi-memory): not implemented.

See https://github.com/rust-lang/rust/pull/117457#issuecomment-1787648070 for more context.

Documentation: https://github.com/rust-lang/reference/pull/1420
Tracking issue: https://github.com/rust-lang/rust/issues/44839
2024-04-21 06:32:10 +00:00
bors
13eb8c736c Auto merge of #123930 - Mark-Simulacrum:vec-length-invariant, r=jhpratt
Tell LLVM Vec::len is invariant across growth

This allows LLVM to avoid re-loading it from memory.
2024-04-21 03:08:50 +00:00
Mark Rousskov
f1ae5314be Avoid reloading Vec::len across grow_one in push
This saves an extra load from memory.
2024-04-20 21:07:00 -04:00
bors
426a698606 Auto merge of #123981 - Kobzol:update-nodejs, r=Mark-Simulacrum
CI: add script for installing NodeJS and update it to v20

I centralized the installation on a single place to make it simple to update the NodeJS version across the board.

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

r? `@Mark-Simulacrum`
2024-04-21 01:06:10 +00:00
bors
453ceafce3 Auto merge of #124208 - jieyouxu:rollup-gbgpu4u, r=jieyouxu
Rollup of 10 pull requests

Successful merges:

 - #123379 (Print note with closure signature on type mismatch)
 - #123967 (static_mut_refs: use raw pointers to remove the remaining FIXME)
 - #123976 (Use fake libc in core test)
 - #123986 (lint-docs: Add redirects for renamed lints.)
 - #124053 (coverage: Branch coverage tests for lazy boolean operators)
 - #124071 (Add llvm-bitcode-linker to build manifest)
 - #124103 (Improve std::fs::Metadata Debug representation)
 - #124132 (llvm RustWrapper: explain OpBundlesIndirect argument type)
 - #124191 (Give a name to each distinct manipulation of pretty-printer FixupContext)
 - #124196 (mir-opt tests: rename unit-test -> test-mir-pass)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-04-20 22:35:56 +00:00
许杰友 Jieyou Xu (Joe)
c72cfdd46f
Rollup merge of #124196 - RalfJung:mir-opt-tests, r=Mark-Simulacrum
mir-opt tests: rename unit-test -> test-mir-pass

"unit-test" is extremely non-descriptive, no idea how one is supposed to read that and know that this specifies the MIR pass being tested.
2024-04-20 21:45:38 +01:00
许杰友 Jieyou Xu (Joe)
b3f9117a2d
Rollup merge of #124191 - dtolnay:fixup, r=compiler-errors
Give a name to each distinct manipulation of pretty-printer FixupContext

There are only 7 distinct ways that the AST pretty-printer interacts with FixupContext: 3 constructors (including Default), 2 transformations, and 2 queries.

This PR turns these into associated functions which can be documented with examples.

This PR unblocks https://github.com/rust-lang/rust/pull/119427#discussion_r1439481201. In order to improve the pretty-printer's behavior regarding parenthesization of braced macro calls in match arms, which have different grammar than macro calls in statements, FixupContext needs to be extended with 2 new fields. In the previous approach, that would be onerous. In the new approach, all it entails is 1 new constructor (`FixupContext::new_match_arm()`).
2024-04-20 21:45:38 +01:00
许杰友 Jieyou Xu (Joe)
726361caf4
Rollup merge of #124132 - RalfJung:OpBundlesIndirect, r=Mark-Simulacrum
llvm RustWrapper: explain OpBundlesIndirect argument type

Follow-up to https://github.com/rust-lang/rust/pull/123941

r? ``@Mark-Simulacrum``
2024-04-20 21:45:37 +01:00
许杰友 Jieyou Xu (Joe)
418a07861a
Rollup merge of #124103 - dtolnay:metadatadebug, r=Mark-Simulacrum
Improve std::fs::Metadata Debug representation

- Remove duplication of `mode` between `file_type` and `permissions`, which both involve operating on the same mode_t integer
- Add `is_symlink`
- Add `len` in bytes
- Remove Ok wrapping around `modified`, `accessed`, `created`, which eliminates 6 useless lines

<table>
<tr><th>Before</th><th>After</th></tr>
<tr><td>

```console
Metadata {
    file_type: FileType(
        FileType {
            mode: 0o100600 (-rw-------),
        },
    ),
    is_dir: false,
    is_file: true,
    permissions: Permissions(
        FilePermissions {
            mode: 0o100600 (-rw-------),
        },
    ),
    modified: Ok(
        SystemTime {
            tv_sec: 1713402981,
            tv_nsec: 682983531,
        },
    ),
    accessed: Ok(
        SystemTime {
            tv_sec: 1713402983,
            tv_nsec: 206999623,
        },
    ),
    created: Ok(
        SystemTime {
            tv_sec: 1713402981,
            tv_nsec: 682983531,
        },
    ),
    ..
}
```
</td><td>

```console
Metadata {
    file_type: FileType {
        is_file: true,
        is_dir: false,
        is_symlink: false,
        ..
    },
    permissions: Permissions(
        FilePermissions {
            mode: 0o100600 (-rw-------),
        },
    ),
    len: 2096,
    modified: SystemTime {
        tv_sec: 1713402981,
        tv_nsec: 682983531,
    },
    accessed: SystemTime {
        tv_sec: 1713402983,
        tv_nsec: 206999623,
    },
    created: SystemTime {
        tv_sec: 1713402981,
        tv_nsec: 682983531,
    },
    ..
}

```
</td></tr></table>

Generated by:

```rust
fn main() {
    println!("{:#?}", std::fs::metadata("Cargo.toml").unwrap());
}
```
2024-04-20 21:45:37 +01:00
许杰友 Jieyou Xu (Joe)
29ee276368
Rollup merge of #124071 - kjetilkjeka:llvm_bitcode_linker_build_manifest, r=Mark-Simulacrum
Add llvm-bitcode-linker to build manifest

When creating #123423 I didn't realize I also had to add the new component to the build-manifest. This PR finishes the work of adding it, by also adding it to the build manifest.

r? ``@Mark-Simulacrum``
2024-04-20 21:45:36 +01:00
许杰友 Jieyou Xu (Joe)
f13cd0c8d0
Rollup merge of #124053 - Zalathar:lazy-boolean, r=Mark-Simulacrum
coverage: Branch coverage tests for lazy boolean operators

The current branch coverage implementation already supports the `&&` and `||` operators (even outside of an `if` condition), as a natural consequence of how they are desugared/lowered, but we didn't have any specific tests for them. This PR adds some appropriate tests.

I've also moved the existing branch coverage tests into a `coverage/branch` subdirectory, so that they don't become unwieldy as I add more branch coverage tests.

``@rustbot`` label +A-code-coverage
2024-04-20 21:45:36 +01:00
许杰友 Jieyou Xu (Joe)
871c3e3075
Rollup merge of #123986 - ehuss:lint-renamed, r=Mark-Simulacrum
lint-docs: Add redirects for renamed lints.

This updates the lint docs to include a redirect for renamed lints to the new name. This helps ensure that links to the old name will still be valid.

Note that this currently uses a hard-coded list. As mentioned in the comment, a future enhancement may gather this information in a better way.

Unblocks #123680
2024-04-20 21:45:35 +01:00
许杰友 Jieyou Xu (Joe)
a73aabfa92
Rollup merge of #123976 - ChrisDenton:no-libc-in-std-doc-tests, r=Mark-Simulacrum
Use fake libc in core test

The war on libc continues.

Some platforms may not need to link to the libc crate (and it's possible some may not even have a libc), therefore we shouldn't require it for tests. This creates dummy `malloc` and `free` implementations for use in the pointer docs, but, keeps the public documentation looking the same as before.
2024-04-20 21:45:35 +01:00
许杰友 Jieyou Xu (Joe)
ccd9880769
Rollup merge of #123967 - RalfJung:static_mut_refs, r=Nilstrieb
static_mut_refs: use raw pointers to remove the remaining FIXME

Using `SyncUnsafeCell` would not make a lot of sense IMO.
2024-04-20 21:45:35 +01:00
许杰友 Jieyou Xu (Joe)
e9e936cfa8
Rollup merge of #123379 - wutchzone:119266, r=compiler-errors
Print note with closure signature on type mismatch

Fixes #119266

r? Nilstrieb
2024-04-20 21:45:34 +01:00
bors
dbce3b43b6 Auto merge of #122013 - Swatinem:unicode-gen-fastpath, r=scottmcm
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 20:33:25 +00:00
bors
54692c3d0b Auto merge of #124202 - lnicola:sync-from-ra, r=lnicola
Subtree update of `rust-analyzer`

r? `@ghost`
2024-04-20 17:01:20 +00:00
Laurențiu Nicola
b0a18daa75 Merge commit '55d9a533b309119c8acd13061581b43ae8840823' into sync-from-ra 2024-04-20 19:17:08 +03:00
bors
55d9a533b3 Auto merge of #17114 - lnicola:hir-expand-in-tree, r=Veykril
minor: Add in-rust-tree feature to hir-expand

CC https://github.com/rust-lang/rust/pull/124199#issuecomment-2067701168
2024-04-20 16:02:57 +00:00
Laurențiu Nicola
4c94e69115 Add in-rust-tree feature to hir-expand 2024-04-20 18:44:27 +03:00
bors
8cf135e191 Auto merge of #121712 - mati865:provide-prebuilt-std-for-gnullvm, r=Mark-Simulacrum
Provide prebuilt std for gnullvm targets

Revival of https://github.com/rust-lang/rust/pull/114346 which waiting on MCP that was accepted recently: https://github.com/rust-lang/compiler-team/issues/710#issuecomment-1942014308
2024-04-20 14:58:25 +00: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
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
Ralf Jung
cb1b4a6977 reuse_pool: only do acquire_clock if we reused from a different thread 2024-04-20 09:08:09 +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
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
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