]> git.lizzy.rs Git - rust.git/log
rust.git
2 years agoAuto merge of #2139 - saethlin:lazy-current-span, r=RalfJung
bors [Mon, 23 May 2022 06:46:46 +0000 (06:46 +0000)]
Auto merge of #2139 - saethlin:lazy-current-span, r=RalfJung

Factor current-span logic into a caching handle

After https://github.com/rust-lang/miri/pull/2030 and while working on https://github.com/rust-lang/miri/pull/1935 it became quite clear that we need to do some caching here, because some retag operations generate many calls to `log_invalidation`, and would thus search the current thread's stack _many_ times for a local crate. This caching fixes that. This handle type also has the nice benefit of tucking away all the `ThreadManager` + `CrateNum` logic.

2 years agoFactor current-span logic into a lazy caching handle
Ben Kimock [Wed, 8 Dec 2021 03:05:13 +0000 (22:05 -0500)]
Factor current-span logic into a lazy caching handle

2 years agoAuto merge of #2144 - matthiaskrgr:stderrfix, r=RalfJung
bors [Sun, 22 May 2022 20:00:17 +0000 (20:00 +0000)]
Auto merge of #2144 - matthiaskrgr:stderrfix, r=RalfJung

mute_stdout_stderr: mute stderr instead of stdin

should fix #2143

note: this is entirely untested, I was getting tons of errors on `cargo test` because of some missing setup.
I hope that CI can tell me if this works or not :see_no_evil:

r? `@oli-obk`

2 years agoshims: fs: silence stderr instead of stdout.
Matthias Krüger [Sun, 22 May 2022 19:54:00 +0000 (21:54 +0200)]
shims: fs: silence stderr instead of stdout.

Fixes #2143

2 years ago[NFC] shims: fs: fmt
Matthias Krüger [Sun, 22 May 2022 19:47:44 +0000 (21:47 +0200)]
[NFC] shims: fs: fmt

2 years agoAuto merge of #2141 - saethlin:early-diagnostics-ice, r=RalfJung
bors [Sun, 22 May 2022 16:17:17 +0000 (16:17 +0000)]
Auto merge of #2141 - saethlin:early-diagnostics-ice, r=RalfJung

Adjust diagnostics assertion so we don't ICE in setup

Fixes https://github.com/rust-lang/miri/issues/2076 just by handling diagnostics produced during setup. The tracking notes don't have any spans but it's better than an ICE.

It looks like we leak allocations 1..20, and allocations 13..19 don't have any creation notes, and 14 only has a `FreedAlloc` alloc tracking diagnostic.

2 years agotweak comment
Ralf Jung [Sun, 22 May 2022 16:16:59 +0000 (18:16 +0200)]
tweak comment

2 years agoHandle diagnotics emitted in runtime initialization
Ben Kimock [Sat, 21 May 2022 16:14:17 +0000 (12:14 -0400)]
Handle diagnotics emitted in runtime initialization

2 years agoAuto merge of #2142 - saethlin:cleanup-data-race-ice, r=oli-obk
bors [Sun, 22 May 2022 06:18:29 +0000 (06:18 +0000)]
Auto merge of #2142 - saethlin:cleanup-data-race-ice, r=oli-obk

Make allow_data_races_* public and use it during EnvVars::cleanup

Fixes https://github.com/rust-lang/miri/issues/2020

I've tried for hours now to come up with a test case for this ICE with no luck. I suspect there's something about the way the data race detection works under these conditions that I just don't understand :weary:.

But I tried this change out on a handful of crates and I don't see any more ICEs of this form. For whatever reason it seems like `bastion==0.4.5` is a good way to run into this, with the flags
```
MIRIFLAGS="-Zmiri-tag-raw-pointers -Zmiri-panic-on-unsupported -Zmiri-disable-isolation" cargo +miri miri test --no-fail-fast --doc
```
I think all the cases I've run into with this involve both `-Zmiri-panic-on-unsupported` and `-Zmiri-tag-raw-pointers`, so it could be that the combination of an unexpected panic and a machine halt is required.

2 years agoAuto merge of #2140 - V0ldek:page_size, r=RalfJung
bors [Sun, 22 May 2022 05:59:39 +0000 (05:59 +0000)]
Auto merge of #2140 - V0ldek:page_size, r=RalfJung

Update GetSystemInfo to work with `page_size` (#2136)

- Change logic in GetSystemInfo shim to take into account the two possible layouts of `SYSTEM_INFO`, the first-field-is-union used by [winapi::um::sysinfoapi::SYSTEM_INFO](https://docs.rs/winapi/latest/winapi/um/sysinfoapi/struct.SYSTEM_INFO.html), and first-two-fields-are-inlined-union used by [num_cpus](https://github.com/seanmonstar/num_cpus/blob/5f1b03332000b4c4274b5bd35fac516049ff1c6b/src/lib.rs#L206).
- Fill out the `dwPageSize` field with the `PAGE_SIZE` constant of `4096`.

Closes #2136

2 years agocomment on test
Ralf Jung [Sun, 22 May 2022 05:59:18 +0000 (07:59 +0200)]
comment on test

2 years agoUse precomputed layouts.
Mateusz Gienieczko [Sat, 21 May 2022 23:01:12 +0000 (01:01 +0200)]
Use precomputed layouts.

2 years agoAdd `i16` and `u16` primitive layout.
Mateusz Gienieczko [Sat, 21 May 2022 23:00:59 +0000 (01:00 +0200)]
Add `i16` and `u16` primitive layout.

2 years agoFix comment formatting.
Mateusz Gienieczko [Sat, 21 May 2022 22:59:49 +0000 (00:59 +0200)]
Fix comment formatting.

2 years agoDynamic offset calculation in GetSystemInfo.
Mateusz Gienieczko [Sat, 21 May 2022 19:42:25 +0000 (21:42 +0200)]
Dynamic offset calculation in GetSystemInfo.

2 years agoMake allow_data_races_* public to silence data races during cleanup
Ben Kimock [Sat, 21 May 2022 17:37:41 +0000 (13:37 -0400)]
Make allow_data_races_* public to silence data races during cleanup

2 years agoChange GetSystemInfo to explicit offset.
Mateusz Gienieczko [Sat, 21 May 2022 17:44:12 +0000 (19:44 +0200)]
Change GetSystemInfo to explicit offset.

2 years agoSet page size in GetSystemInfo.
Mateusz Gienieczko [Sat, 21 May 2022 16:17:25 +0000 (18:17 +0200)]
Set page size in GetSystemInfo.

2 years agoAuto merge of #2137 - RalfJung:targets, r=oli-obk
bors [Sat, 21 May 2022 16:15:49 +0000 (16:15 +0000)]
Auto merge of #2137 - RalfJung:targets, r=oli-obk

explain which targets we support to what extent

This is basically documenting my policy so far: Linux is the target I know best and can spend most time on. Apple is so close to Linux that it can basically ride along without much extra work. I don't have a lot of time to spend on our Windows support.

Of course, if people commit to contributing and maintaining support for a target, we can promise more than what is documented here. :)  But this is what I am willing to promise.

Also reduce the amount of work we do on the Windows test runner, since that one currently takes 10min longer than the other two.

r? `@oli-obk`

2 years agoAdd failing page_size test.
Mateusz Gienieczko [Sat, 21 May 2022 14:10:08 +0000 (16:10 +0200)]
Add failing page_size test.

2 years agorefresh our GHA caches
Ralf Jung [Sat, 21 May 2022 07:33:47 +0000 (09:33 +0200)]
refresh our GHA caches

2 years agoexplain which targets we support to what extent
Ralf Jung [Fri, 20 May 2022 21:36:35 +0000 (23:36 +0200)]
explain which targets we support to what extent

2 years agothe Windows CI runner takes a lot longer than the others; let it do less work
Ralf Jung [Fri, 20 May 2022 21:35:42 +0000 (23:35 +0200)]
the Windows CI runner takes a lot longer than the others; let it do less work

x86_64-apple-darwin is also used as the host OS for the macOS runner, so no need
to test it twice.

2 years agoexplain what we mean by 'unsound'
Ralf Jung [Fri, 20 May 2022 21:35:31 +0000 (23:35 +0200)]
explain what we mean by 'unsound'

2 years agoAuto merge of #2135 - RalfJung:rustup, r=RalfJung
bors [Fri, 20 May 2022 16:38:24 +0000 (16:38 +0000)]
Auto merge of #2135 - RalfJung:rustup, r=RalfJung

rustup

2 years agorustup
Ralf Jung [Fri, 20 May 2022 16:11:31 +0000 (18:11 +0200)]
rustup

2 years agoAuto merge of #2130 - RalfJung:rustup, r=RalfJung
bors [Fri, 20 May 2022 06:09:13 +0000 (06:09 +0000)]
Auto merge of #2130 - RalfJung:rustup, r=RalfJung

rustup

`Display` of `Ref`/`RefMut` was broken by https://github.com/rust-lang/rust/pull/97027, let's deref them to use the underlying reference `Display`.

Cc https://github.com/rust-lang/rust/issues/97204

2 years agorustup
Ralf Jung [Fri, 20 May 2022 06:08:11 +0000 (08:08 +0200)]
rustup

2 years agoAuto merge of #2128 - saethlin:fix-creation-range, r=RalfJung
bors [Thu, 19 May 2022 15:08:22 +0000 (15:08 +0000)]
Auto merge of #2128 - saethlin:fix-creation-range, r=RalfJung

Pass the correct size to the AllocRange for log_creation

Fixes https://github.com/rust-lang/miri/issues/2127

I guess all I needed was a bit of sleep and reassurance that this diagnostic is the wrong part of that situation.

2 years agoPass the correct size to the AllocRange for log_creation
Ben Kimock [Thu, 19 May 2022 13:29:08 +0000 (09:29 -0400)]
Pass the correct size to the AllocRange for log_creation

2 years agoAuto merge of #2125 - RalfJung:ref-validity, r=RalfJung
bors [Wed, 18 May 2022 06:34:48 +0000 (06:34 +0000)]
Auto merge of #2125 - RalfJung:ref-validity, r=RalfJung

test for validity of references pointing to uninhabited types

The new tests for https://github.com/rust-lang/rust/pull/97116

2 years agorustup
Ralf Jung [Wed, 18 May 2022 06:33:10 +0000 (08:33 +0200)]
rustup

2 years agochange one of the ref-to-uninhbaited tests to Box
Ralf Jung [Wed, 18 May 2022 06:32:08 +0000 (08:32 +0200)]
change one of the ref-to-uninhbaited tests to Box

2 years agotest for validity of references pointing to uninhabited types
Ralf Jung [Tue, 17 May 2022 15:36:34 +0000 (17:36 +0200)]
test for validity of references pointing to uninhabited types

2 years agoAuto merge of #2126 - RalfJung:typo, r=RalfJung
bors [Tue, 17 May 2022 16:59:56 +0000 (16:59 +0000)]
Auto merge of #2126 - RalfJung:typo, r=RalfJung

I cannot type

2 years agoI cannot type
Ralf Jung [Tue, 17 May 2022 16:59:27 +0000 (18:59 +0200)]
I cannot type

2 years agoAuto merge of #2124 - RalfJung:rustup-toolchain, r=RalfJung
bors [Tue, 17 May 2022 13:40:16 +0000 (13:40 +0000)]
Auto merge of #2124 - RalfJung:rustup-toolchain, r=RalfJung

rustup-toolchain: also prepare toolchain for vscode

This is a work-around for https://github.com/rust-lang/cargo/issues/10096.

2 years agorustup-toolchain: also prepare toolchain for vscode
Ralf Jung [Tue, 17 May 2022 13:36:59 +0000 (15:36 +0200)]
rustup-toolchain: also prepare toolchain for vscode

2 years agoAuto merge of #2122 - RalfJung:rustup, r=RalfJung
bors [Sun, 15 May 2022 10:58:41 +0000 (10:58 +0000)]
Auto merge of #2122 - RalfJung:rustup, r=RalfJung

rustup

I am on mobile and so I couldn't test this... let's see how it goes. ;)

2 years agorustup
Ralf Jung [Sun, 15 May 2022 10:56:39 +0000 (12:56 +0200)]
rustup

2 years agoAuto merge of #2121 - RalfJung:less-ice, r=RalfJung
bors [Sun, 15 May 2022 08:27:43 +0000 (08:27 +0000)]
Auto merge of #2121 - RalfJung:less-ice, r=RalfJung

don't ICE when libcore is missing

Fixes https://github.com/rust-lang/miri/issues/2120

2 years agodon't ICE when libcore is missing
Ralf Jung [Sun, 15 May 2022 08:26:47 +0000 (10:26 +0200)]
don't ICE when libcore is missing

2 years agoAuto merge of #2116 - carbotaniuman:minimal-miri-changes, r=RalfJung
bors [Sun, 15 May 2022 07:11:51 +0000 (07:11 +0000)]
Auto merge of #2116 - carbotaniuman:minimal-miri-changes, r=RalfJung

Minimal miri changes for rustc permissive provenance

Simple no-op changes to adapt to new API surface.

2 years agoAuto merge of #2030 - saethlin:track-alloc-history, r=oli-obk
bors [Sat, 14 May 2022 19:27:04 +0000 (19:27 +0000)]
Auto merge of #2030 - saethlin:track-alloc-history, r=oli-obk

Print spans where tags are created and invalidated

5225225 called this "automatic tag tracking" and I think that may be a reasonable description, but I would like to kill tag tracking as a primary use of Miri if possible. Tag tracking isn't always possible; for example if the UB is only detected with isolation off and the failing tag is made unstable by removing isolation. (also it's bad UX to run the tool twice)

This is just one of the things we can do with https://github.com/rust-lang/miri/pull/2024

The memory usage of this is _shockingly_ low, I think because the memory usage of Miri is driven by allocations where each byte ends up with its own very large stack. The memory usage in this change is linear with the number of tags, not tags * bytes. If memory usage gets out of control we can cap the number of events we save per allocation, from experience we tend to only use the most recent few in diagnostics but of course there's no guarantee of that so if we can manage to keep everything that would be best.

In many cases now I can tell exactly what these codebases are doing wrong just from the new outputs here, which I think is extremely cool.

New helps generated with plain old `cargo miri test` on `rust-argon2` v1.0.0:
```
test argon2::tests::single_thread_verification_multi_lane_hash ... error: Undefined Behavior: trying to reborrow <1485898> for Unique permission at alloc110523[0x0], but that tag does not exist in the borrow stack for this location
   --> /home/ben/.rustup/toolchains/miri/lib/rustlib/src/rust/library/core/src/mem/manually_drop.rs:89:9
    |
89  |         slot.value
    |         ^^^^^^^^^^
    |         |
    |         trying to reborrow <1485898> for Unique permission at alloc110523[0x0], but that tag does not exist in the borrow stack for this location
    |         this error occurs as part of a reborrow at alloc110523[0x0..0x20]
    |
    = help: this indicates a potential bug in the program: it performed an invalid operation, but the rules it violated are still experimental
    = help: see https://github.com/rust-lang/unsafe-code-guidelines/blob/master/wip/stacked-borrows.md for further information
help: <1485898> was created by a retag at offsets [0x0..0x20]
   --> src/memory.rs:42:13
    |
42  |             vec.push(unsafe { &mut (*ptr) });
    |             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
help: <1485898> was later invalidated at offsets [0x0..0x20]
   --> src/memory.rs:42:31
    |
42  |             vec.push(unsafe { &mut (*ptr) });
    |                               ^^^^^^^^^^^
```

And with `-Zmiri-tag-raw-pointers` on `slab` v0.4.5
```
error: Undefined Behavior: trying to reborrow <2915> for Unique permission at alloc1418[0x0], but that tag does not exist in the borrow stack for this location
   --> /tmp/slab-0.4.5/src/lib.rs:835:16
    |
835 |         match (&mut *ptr1, &mut *ptr2) {
    |                ^^^^^^^^^^
    |                |
    |                trying to reborrow <2915> for Unique permission at alloc1418[0x0], but that tag does not exist in the borrow stack for this location
    |                this error occurs as part of a reborrow at alloc1418[0x0..0x10]
    |
    = help: this indicates a potential bug in the program: it performed an invalid operation, but the rules it violated are still experimental
    = help: see https://github.com/rust-lang/unsafe-code-guidelines/blob/master/wip/stacked-borrows.md for further information
help: <2915> was created by a retag at offsets [0x0..0x10]
   --> /tmp/slab-0.4.5/src/lib.rs:833:20
    |
833 |         let ptr1 = self.entries.get_unchecked_mut(key1) as *mut Entry<T>;
    |                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
help: <2915> was later invalidated at offsets [0x0..0x20]
   --> /tmp/slab-0.4.5/src/lib.rs:834:20
    |
834 |         let ptr2 = self.entries.get_unchecked_mut(key2) as *mut Entry<T>;
    |                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
```

And without raw pointer tagging, `cargo miri test` on `half` v1.8.2
```
error: Undefined Behavior: trying to reborrow <untagged> for Unique permission at alloc1340[0x0], but that tag only grants SharedReadOnly permission for this location
   --> /home/ben/.rustup/toolchains/miri/lib/rustlib/src/rust/library/core/src/slice/raw.rs:141:9
    |
141 |         &mut *ptr::slice_from_raw_parts_mut(data, len)
    |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |         |
    |         trying to reborrow <untagged> for Unique permission at alloc1340[0x0], but that tag only grants SharedReadOnly permission for this location
    |         this error occurs as part of a reborrow at alloc1340[0x0..0x6]
    |
    = help: this indicates a potential bug in the program: it performed an invalid operation, but the rules it violated are still experimental
    = help: see https://github.com/rust-lang/unsafe-code-guidelines/blob/master/wip/stacked-borrows.md for further information
help: tag was most recently created at offsets [0x0..0x6]
   --> /tmp/half-1.8.2/src/slice.rs:309:22
    |
309 |         let length = self.len();
    |                      ^^^^^^^^^^
help: this tag was also created here at offsets [0x0..0x6]
   --> /tmp/half-1.8.2/src/slice.rs:308:23
    |
308 |         let pointer = self.as_ptr() as *mut u16;
    |                       ^^^^^^^^^^^^^
```
The second suggestion is close to guesswork, but from experience it tends to be correct (as in, it tends to locate the pointer the user wanted) more often that it doesn't.

2 years agoBump rustc for permissive provenance
carbotaniuman [Sat, 14 May 2022 18:03:47 +0000 (13:03 -0500)]
Bump rustc for permissive provenance

2 years agoMore review feedback
Ben Kimock [Fri, 13 May 2022 23:04:51 +0000 (19:04 -0400)]
More review feedback

* Store the local crates in an Rc<[CrateNum]>
* Move all the allocation history into Stacks
* Clean up the implementation of get_logs_relevant_to a bit

2 years agoAuto merge of #2119 - RalfJung:glob, r=RalfJung
bors [Fri, 13 May 2022 21:19:59 +0000 (21:19 +0000)]
Auto merge of #2119 - RalfJung:glob, r=RalfJung

data_race: use glob import like most files

2 years agodata_race: use glob import like most files
Ralf Jung [Fri, 13 May 2022 21:19:17 +0000 (23:19 +0200)]
data_race: use glob import like most files

2 years agoAuto merge of #2114 - cbeuw:shim-rmw, r=RalfJung
bors [Fri, 13 May 2022 19:04:59 +0000 (19:04 +0000)]
Auto merge of #2114 - cbeuw:shim-rmw, r=RalfJung

Use atomic RMW for `{mutex, rwlock, cond, srwlock}_get_or_create_id` functions

This is required for #1963

`{mutex, rwlock, cond, srwlock}_get_or_create_id()` currently checks whether an ID field is 0 using an atomic read, allocate one and get a new ID if it is, then write it in a separate atomic write. This is fine without weak memory. For instance, in `pthread_mutex_lock` which may be called by two threads concurrently, only one thread can read 0, create and then write a new ID, the later-run thread will always see the newly created ID and never 0.
```rust
    fn pthread_mutex_lock(&mut self, mutex_op: &OpTy<'tcx, Tag>) -> InterpResult<'tcx, i32> {
        let this = self.eval_context_mut();

        let kind = mutex_get_kind(this, mutex_op)?.check_init()?;
        let id = mutex_get_or_create_id(this, mutex_op)?;
        let active_thread = this.get_active_thread();
```

However, with weak memory behaviour, both threads may read 0: the first thread has to see 0 because nothing else was written to it, and the second thread is not guaranteed to observe the latest value, causing a duplicate mutex to be created and both threads "successfully" acquiring the lock at the same time.

This is a pretty typical pattern requiring the use of atomic RMWs. RMW *always* reads the latest value in a location, so only one thread can create the new mutex and ID, all others scheduled later will see the new ID.

2 years agoMove and rename offset_and_layout_to_place to deref_operand_and_offset
Andy Wang [Fri, 13 May 2022 17:42:53 +0000 (18:42 +0100)]
Move and rename offset_and_layout_to_place to deref_operand_and_offset

2 years agoInline _create() calls and add assertions
Andy Wang [Thu, 12 May 2022 20:06:17 +0000 (21:06 +0100)]
Inline _create() calls and add assertions

2 years agoRefactor to hide *_next_id functions
Andy Wang [Thu, 12 May 2022 19:31:40 +0000 (20:31 +0100)]
Refactor to hide *_next_id functions

2 years agoAuto merge of #2117 - RalfJung:rustup, r=RalfJung
bors [Thu, 12 May 2022 17:02:04 +0000 (17:02 +0000)]
Auto merge of #2117 - RalfJung:rustup, r=RalfJung

rustup

Cc https://github.com/rust-lang/rust/issues/96975

2 years agorustup
Ralf Jung [Thu, 12 May 2022 17:01:04 +0000 (19:01 +0200)]
rustup

2 years agoAuto merge of #2115 - rust-lang:comment_nit, r=oli-obk
bors [Thu, 12 May 2022 10:43:48 +0000 (10:43 +0000)]
Auto merge of #2115 - rust-lang:comment_nit, r=oli-obk

Update a path to libstd source in our comments

Taken from review in https://github.com/rust-lang/miri/pull/2101

2 years agoUpdate a path to libstd source in our comments
Oli Scherer [Thu, 12 May 2022 10:42:53 +0000 (10:42 +0000)]
Update a path to libstd source in our comments

2 years agoCleanup/Refactoring from review
Ben Kimock [Wed, 11 May 2022 23:13:00 +0000 (19:13 -0400)]
Cleanup/Refactoring from review

* Pass a ThreadInfo down to grant/access to get the current span lazily
* Rename add_* to log_* for clarity
* Hoist borrow_mut calls out of loops by tweaking the for_each signature
* Explain the parameters of check_protector a bit more

2 years agoUse proper atomic rmw for {mutex, rwlock, cond, srwlock}_get_or_create_id
Andy Wang [Sat, 7 May 2022 20:30:15 +0000 (21:30 +0100)]
Use proper atomic rmw for {mutex, rwlock, cond, srwlock}_get_or_create_id

2 years agoAuto merge of #2113 - RalfJung:rustc-log, r=RalfJung
bors [Wed, 11 May 2022 09:29:43 +0000 (09:29 +0000)]
Auto merge of #2113 - RalfJung:rustc-log, r=RalfJung

when MIRI_LOG is set, set RUSTC_LOG_ENTRY_EXIT

This will be useful once https://github.com/rust-lang/rust/pull/96898 landed.

2 years agowhen MIRI_LOG is set, set RUSTC_LOG_ENTRY_EXIT
Ralf Jung [Wed, 11 May 2022 08:03:56 +0000 (10:03 +0200)]
when MIRI_LOG is set, set RUSTC_LOG_ENTRY_EXIT

2 years agoAuto merge of #2112 - y86-dev:clarify-custom-rustc-issues, r=RalfJung
bors [Tue, 10 May 2022 19:38:52 +0000 (19:38 +0000)]
Auto merge of #2112 - y86-dev:clarify-custom-rustc-issues, r=RalfJung

Clarified issues when building miri with a custom rustc

I came across these issues (see zulip threads [here](https://rust-lang.zulipchat.com/#narrow/stream/182449-t-compiler.2Fhelp/topic/.E2.9C.94.20Changes.20not.20in.20effect) and [here](https://rust-lang.zulipchat.com/#narrow/stream/182449-t-compiler.2Fhelp/topic/Missing.20.2Elibrustc.2Estamp), issue [here](https://github.com/rust-lang/rust/issues/90244)) and would like to add this small bit to the docs. Feel free to change the wording.

2 years agotweak wording
Ralf Jung [Tue, 10 May 2022 19:38:32 +0000 (21:38 +0200)]
tweak wording

2 years agoClarified issues when building miri with a custom rustc
y86-dev [Tue, 10 May 2022 18:46:12 +0000 (20:46 +0200)]
Clarified issues when building miri with a custom rustc

Co-authored-by: Ralf Jung <post@ralfj.de>
2 years agoAuto merge of #2111 - RalfJung:python, r=RalfJung
bors [Tue, 10 May 2022 10:21:33 +0000 (10:21 +0000)]
Auto merge of #2111 - RalfJung:python, r=RalfJung

stop relying on python being in the PATH

Even Debian removed the package that provides `/usr/bin/python`; I guess it is time to move on.

2 years agorustfmt
Ralf Jung [Tue, 10 May 2022 10:21:01 +0000 (12:21 +0200)]
rustfmt

2 years agostop relying on python being in the PATH
Ralf Jung [Tue, 10 May 2022 10:14:47 +0000 (12:14 +0200)]
stop relying on python being in the PATH

2 years agoAuto merge of #2084 - rust-lang:silence, r=RalfJung
bors [Tue, 10 May 2022 07:24:07 +0000 (07:24 +0000)]
Auto merge of #2084 - rust-lang:silence, r=RalfJung

Add a command line flag to avoid printing to stdout and stderr

This is practical for tests that don't actually care about the output and thus don't want it intermingled with miri's warnings, errors or ICEs

fixes #2083

2 years agoWording nit
Oli Scherer [Tue, 10 May 2022 07:23:50 +0000 (07:23 +0000)]
Wording nit

2 years agoUse alphabetical order for miri flags
Oli Scherer [Tue, 10 May 2022 07:23:03 +0000 (07:23 +0000)]
Use alphabetical order for miri flags

2 years agoAuto merge of #2109 - RalfJung:fmt, r=RalfJung
bors [Mon, 9 May 2022 09:18:52 +0000 (09:18 +0000)]
Auto merge of #2109 - RalfJung:fmt, r=RalfJung

rustfmt

2 years agorustfmt
Ralf Jung [Mon, 9 May 2022 09:17:48 +0000 (11:17 +0200)]
rustfmt

2 years agoAuto merge of #2108 - RalfJung:rustup, r=RalfJung
bors [Mon, 9 May 2022 08:22:07 +0000 (08:22 +0000)]
Auto merge of #2108 - RalfJung:rustup, r=RalfJung

rustup

Adjusts for https://github.com/rust-lang/rust/pull/96657. For now we use the fallback path in libstd.

2 years agorustup
Ralf Jung [Mon, 9 May 2022 08:21:15 +0000 (10:21 +0200)]
rustup

2 years agoAuto merge of #2107 - RalfJung:err, r=RalfJung
bors [Sun, 8 May 2022 15:57:22 +0000 (15:57 +0000)]
Auto merge of #2107 - RalfJung:err, r=RalfJung

test for "erroneous constant used" post-monomorphization error

Fixes https://github.com/rust-lang/miri/issues/2106

2 years agotest for "erroneous constant used" post-monomorphization error
Ralf Jung [Sun, 8 May 2022 15:56:09 +0000 (17:56 +0200)]
test for "erroneous constant used" post-monomorphization error

2 years agoAuto merge of #2103 - RalfJung:rustup, r=RalfJung
bors [Fri, 6 May 2022 15:28:39 +0000 (15:28 +0000)]
Auto merge of #2103 - RalfJung:rustup, r=RalfJung

rustup

2 years agorustup
Ralf Jung [Fri, 6 May 2022 15:28:01 +0000 (17:28 +0200)]
rustup

2 years agoAuto merge of #2100 - RalfJung:readme, r=RalfJung
bors [Thu, 5 May 2022 08:29:12 +0000 (08:29 +0000)]
Auto merge of #2100 - RalfJung:readme, r=RalfJung

tweak MIRI_SYSROOT docs

2 years agotweak MIRI_SYSROOT docs
Ralf Jung [Thu, 5 May 2022 08:28:40 +0000 (10:28 +0200)]
tweak MIRI_SYSROOT docs

2 years agoAuto merge of #2098 - RalfJung:papers, r=RalfJung
bors [Sun, 1 May 2022 11:45:31 +0000 (11:45 +0000)]
Auto merge of #2098 - RalfJung:papers, r=RalfJung

mention some papers that use Miri

2 years agomention some papers that use Miri
Ralf Jung [Sun, 1 May 2022 11:44:12 +0000 (13:44 +0200)]
mention some papers that use Miri

2 years agoAuto merge of #2094 - dtolnay-contrib:truncate, r=RalfJung
bors [Sun, 1 May 2022 07:06:57 +0000 (07:06 +0000)]
Auto merge of #2094 - dtolnay-contrib:truncate, r=RalfJung

Replace `as` casts in llvm.x86.addcarry.64 implementation

Recommended in https://github.com/rust-lang/miri/pull/2090#pullrequestreview-958491177.

2 years agoAuto merge of #2095 - dtolnay-contrib:ref, r=RalfJung
bors [Sun, 1 May 2022 06:34:32 +0000 (06:34 +0000)]
Auto merge of #2095 - dtolnay-contrib:ref, r=RalfJung

Replace unneeded use of `ref` in favor of "match ergonomics"

The signature of `check_shim` is very amenable to this.

```rust
fn check_shim<'a, const N: usize>(…) -> InterpResult<'tcx, &'a [OpTy<'tcx, Tag>; N]>
```

Instead of:

```rust
let &[ref ptr, ref flags] = this.check_shim(…)?;
```

we can write it just as:

```rust
let [ptr, flags] = this.check_shim(…)?;
```

2 years agoPass AccessKind to check_protector
Ben Kimock [Sat, 30 Apr 2022 17:50:35 +0000 (13:50 -0400)]
Pass AccessKind to check_protector

2 years agoAuto merge of #2096 - dtolnay-contrib:whitespace, r=RalfJung
bors [Sat, 30 Apr 2022 17:48:56 +0000 (17:48 +0000)]
Auto merge of #2096 - dtolnay-contrib:whitespace, r=RalfJung

Clean up all trailing whitespace

Editors commonly strip trailing whitespace from source code on save, because it's almost always undesired, and that leads to spurious diffs in these files when working with them in such an editor.

2 years agoClean up all trailing whitespace
David Tolnay [Sat, 30 Apr 2022 17:40:35 +0000 (10:40 -0700)]
Clean up all trailing whitespace

2 years agoReplace `as` casts in llvm.x86.addcarry.64 implementation
David Tolnay [Sat, 30 Apr 2022 17:06:19 +0000 (10:06 -0700)]
Replace `as` casts in llvm.x86.addcarry.64 implementation

2 years agoReplace unneeded use of `ref` in favor of "match ergonomics"
David Tolnay [Sat, 30 Apr 2022 17:14:24 +0000 (10:14 -0700)]
Replace unneeded use of `ref` in favor of "match ergonomics"

2 years agoAuto merge of #2093 - RalfJung:post-mono, r=RalfJung
bors [Sat, 30 Apr 2022 15:10:05 +0000 (15:10 +0000)]
Auto merge of #2093 - RalfJung:post-mono, r=RalfJung

gracefully handle type-too-large layout errors

Fixes https://github.com/rust-lang/miri/issues/2088

2 years agogracefully handle type-too-large layout errors
Ralf Jung [Sat, 30 Apr 2022 15:06:50 +0000 (17:06 +0200)]
gracefully handle type-too-large layout errors

2 years agoMove SB diagnostics to a module
Ben Kimock [Mon, 25 Apr 2022 18:18:52 +0000 (14:18 -0400)]
Move SB diagnostics to a module

2 years agoSet the current span (somewhat) lazily
Ben Kimock [Sat, 16 Apr 2022 03:04:07 +0000 (23:04 -0400)]
Set the current span (somewhat) lazily

2 years agoPrint spans where tags are created and invalidated
Ben Kimock [Sat, 12 Mar 2022 22:23:22 +0000 (17:23 -0500)]
Print spans where tags are created and invalidated

2 years agoAuto merge of #2090 - dtolnay-contrib:addcarry, r=oli-obk
bors [Sat, 30 Apr 2022 09:07:16 +0000 (09:07 +0000)]
Auto merge of #2090 - dtolnay-contrib:addcarry, r=oli-obk

Implement llvm.x86.addcarry.64

This is the only new shim I need for https://github.com/dtolnay/precise/issues/2. It's used by the `num-bigint` crate for bigint addition.

2 years agoAuto merge of #2091 - dtolnay-contrib:clippy, r=oli-obk
bors [Sat, 30 Apr 2022 06:52:13 +0000 (06:52 +0000)]
Auto merge of #2091 - dtolnay-contrib:clippy, r=oli-obk

Resolve some clippy lints, ignore the rest

`cargo clippy` finishes cleanly after this. I stuck to only what I think are the least objectionable lints: cleaning up useless identity conversions that do `from`/`try_from`/`into` going from T-&gt;T, extraneous `&` on expressions that are already a reference, unused lifetime parameters, and similar.

Below in the \<details\> is the complete remaining output of `cargo clippy` with the `allow` attribute removed. I think all the lints left are fine to keep ignoring.

<details>
<summary><code>$ cargo clippy -- -Dclippy::all</code></summary>

```console
error: this `else { if .. }` block can be collapsed
   --> src/data_race.rs:559:16
    |
559 |           } else {
    |  ________________^
560 | |             if lt { &rhs } else { &old }
561 | |         };
    | |_________^ help: collapse nested if block: `if lt { &rhs } else { &old }`
    |
    = note: `-D clippy::collapsible-else-if` implied by `-D clippy::all`
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#collapsible_else_if

error: this `if` statement can be collapsed
   --> src/range_map.rs:166:17
    |
166 | /                 if successful_merge_count > 0 {
167 | |                     if done || self.v[end_idx].data != self.v[equal_since_idx].data {
168 | |                         // Everything in `equal_since..end` was equal. Make them just one element covering
169 | |                         // the entire range.
...   |
187 | |                     }
188 | |                 }
    | |_________________^
    |
    = note: `-D clippy::collapsible-if` implied by `-D clippy::all`
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#collapsible_if
help: collapse nested if block
    |
166 ~                 if successful_merge_count > 0 && (done || self.v[end_idx].data != self.v[equal_since_idx].data) {
167 +                     // Everything in `equal_since..end` was equal. Make them just one element covering
168 +                     // the entire range.
169 +                     let removed_elems = end_idx - equal_since_idx - 1; // number of elements that we would remove
170 +                     if removed_elems > 0 {
171 +                         // Adjust the range of the first element to cover all of them.
  ...

error: this `else { if .. }` block can be collapsed
   --> src/shims/foreign_items.rs:114:16
    |
114 |           } else {
    |  ________________^
115 | |             if new_size == 0 {
116 | |                 this.deallocate_ptr(old_ptr, None, kind.into())?;
117 | |                 Ok(Pointer::null())
...   |
127 | |             }
128 | |         }
    | |_________^
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#collapsible_else_if
help: collapse nested if block
    |
114 ~         } else if new_size == 0 {
115 +             this.deallocate_ptr(old_ptr, None, kind.into())?;
116 +             Ok(Pointer::null())
117 +         } else {
118 +             let new_ptr = this.reallocate_ptr(
119 +                 old_ptr,
  ...

error: this `else { if .. }` block can be collapsed
   --> src/shims/posix/sync.rs:459:20
    |
459 |               } else {
    |  ____________________^
460 | |                 if is_mutex_kind_default(this, kind)?
461 | |                     || is_mutex_kind_normal(this, kind)?
462 | |                     || kind == this.eval_libc("PTHREAD_MUTEX_ERRORCHECK")?
...   |
472 | |                 }
473 | |             }
    | |_____________^
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#collapsible_else_if
help: collapse nested if block
    |
459 ~             } else if is_mutex_kind_default(this, kind)?
460 +                 || is_mutex_kind_normal(this, kind)?
461 +                 || kind == this.eval_libc("PTHREAD_MUTEX_ERRORCHECK")?
462 +             {
463 +                 this.eval_libc_i32("EBUSY")
464 +             } else if kind == this.eval_libc("PTHREAD_MUTEX_RECURSIVE")? {
  ...

error: this `if` statement can be collapsed
   --> src/thread.rs:132:9
    |
132 | /         if self.state == ThreadState::Enabled {
133 | |             if self.stack.is_empty() {
134 | |                 self.state = ThreadState::Terminated;
135 | |                 return true;
136 | |             }
137 | |         }
    | |_________^
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#collapsible_if
help: collapse nested if block
    |
132 ~         if self.state == ThreadState::Enabled && self.stack.is_empty() {
133 +             self.state = ThreadState::Terminated;
134 +             return true;
135 +         }
    |

error: this `if` statement can be collapsed
   --> src/thread.rs:523:13
    |
523 | /             if thread.state == ThreadState::Enabled {
524 | |                 if !self.yield_active_thread || id != self.active_thread {
525 | |                     self.active_thread = id;
526 | |                     if let Some(data_race) = data_race {
...   |
530 | |                 }
531 | |             }
    | |_____________^
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#collapsible_if
help: collapse nested if block
    |
523 ~             if thread.state == ThreadState::Enabled && (!self.yield_active_thread || id != self.active_thread) {
524 +                 self.active_thread = id;
525 +                 if let Some(data_race) = data_race {
526 +                     data_race.thread_set_active(self.active_thread);
527 +                 }
528 +                 break;
  ...

error: you should consider adding a `Default` implementation for `GlobalState`
    --> src/data_race.rs:1132:5
     |
1132 | /     pub fn new() -> Self {
1133 | |         let mut global_state = GlobalState {
1134 | |             multi_threaded: Cell::new(false),
1135 | |             vector_clocks: RefCell::new(IndexVec::new()),
...    |
1155 | |         global_state
1156 | |     }
     | |_____^
     |
     = note: `-D clippy::new-without-default` implied by `-D clippy::all`
     = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#new_without_default
help: try adding this
     |
1129 + impl Default for GlobalState {
1130 +     fn default() -> Self {
1131 +         Self::new()
1132 +     }
1133 + }
     |

error: useless use of `format!`
   --> src/diagnostics.rs:155:32
    |
155 |                         (None, format!("pass the flag `-Zmiri-disable-isolation` to disable isolation;")),
    |                                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `.to_string()`: `"pass the flag `-Zmiri-disable-isolation` to disable isolation;".to_string()`
    |
    = note: `-D clippy::useless-format` implied by `-D clippy::all`
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#useless_format

error: useless use of `format!`
   --> src/diagnostics.rs:156:32
    |
156 | ...e, format!("or pass `-Zmiri-isolation-error=warn` to configure Miri to return an error code from isolated operations (if supported for that operation) and continue with a warning"...
    |       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `.to_string()`: `"or pass `-Zmiri-isolation-error=warn` to configure Miri to return an error code from isolated operations (if supported for that operation) and continue with a warning".to_string()`
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#useless_format

error: useless use of `format!`
   --> src/diagnostics.rs:161:32
    |
161 | ...e, format!("this indicates a potential bug in the program: it performed an invalid operation, but the rules it violated are still experimental"...
    |       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `.to_string()`: `"this indicates a potential bug in the program: it performed an invalid operation, but the rules it violated are still experimental".to_string()`
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#useless_format

error: useless use of `format!`
   --> src/diagnostics.rs:197:33
    |
197 | ...e, format!("this is likely not a bug in the program; it indicates that the program performed an operation that the interpreter does not support")...
    |       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `.to_string()`: `"this is likely not a bug in the program; it indicates that the program performed an operation that the interpreter does not support".to_string()`
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#useless_format

error: useless use of `format!`
   --> src/diagnostics.rs:202:32
    |
202 | ...  (None, format!("this usually indicates that your program performed an invalid operation and caused Undefined Behavior")),
    |             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `.to_string()`: `"this usually indicates that your program performed an invalid operation and caused Undefined Behavior".to_string()`
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#useless_format

error: useless use of `format!`
   --> src/diagnostics.rs:203:32
    |
203 |                         (None, format!("but due to `-Zmiri-symbolic-alignment-check`, alignment errors can also be false positives")),
    |                                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `.to_string()`: `"but due to `-Zmiri-symbolic-alignment-check`, alignment errors can also be false positives".to_string()`
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#useless_format

error: useless use of `format!`
   --> src/diagnostics.rs:207:32
    |
207 | ...  (None, format!("this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior")),
    |             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `.to_string()`: `"this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior".to_string()`
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#useless_format

error: useless use of `format!`
   --> src/diagnostics.rs:208:32
    |
208 | ...(None, format!("see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information")),
    |           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `.to_string()`: `"see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information".to_string()`
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#useless_format

error: you seem to be trying to use `match` for destructuring a single pattern. Consider using `if let`
   --> src/diagnostics.rs:247:5
    |
247 | /     match e.kind() {
248 | |         UndefinedBehavior(UndefinedBehaviorInfo::InvalidUninitBytes(Some((alloc_id, access)))) => {
249 | |             eprintln!(
250 | |                 "Uninitialized read occurred at offsets 0x{:x}..0x{:x} into this allocation:",
...   |
256 | |         _ => {}
257 | |     }
    | |_____^
    |
    = note: `-D clippy::single-match` implied by `-D clippy::all`
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#single_match
help: try this
    |
247 ~     if let UndefinedBehavior(UndefinedBehaviorInfo::InvalidUninitBytes(Some((alloc_id, access)))) = e.kind() {
248 +         eprintln!(
249 +             "Uninitialized read occurred at offsets 0x{:x}..0x{:x} into this allocation:",
250 +             access.uninit_offset.bytes(),
251 +             access.uninit_offset.bytes() + access.uninit_size.bytes(),
252 +         );
  ...

error: an implementation of `From` is preferred since it gives you `Into<_>` for free where the reverse isn't true
  --> src/machine.rs:92:1
   |
92 | impl Into<MemoryKind<MiriMemoryKind>> for MiriMemoryKind {
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   |
   = note: `-D clippy::from-over-into` implied by `-D clippy::all`
   = help: consider to implement `From<machine::MiriMemoryKind>` instead
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#from_over_into

error: manual implementation of `Option::map`
   --> src/machine.rs:570:22
    |
570 |           let stacks = if let Some(stacked_borrows) = &ecx.machine.stacked_borrows {
    |  ______________________^
571 | |             Some(Stacks::new_allocation(id, alloc.size(), stacked_borrows, kind))
572 | |         } else {
573 | |             None
574 | |         };
    | |_________^ help: try this: `ecx.machine.stacked_borrows.as_ref().map(|stacked_borrows| Stacks::new_allocation(id, alloc.size(), stacked_borrows, kind))`
    |
    = note: `-D clippy::manual-map` implied by `-D clippy::all`
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#manual_map

error: manual implementation of `Option::map`
   --> src/machine.rs:575:26
    |
575 |           let race_alloc = if let Some(data_race) = &ecx.machine.data_race {
    |  __________________________^
576 | |             Some(data_race::AllocExtra::new_allocation(data_race, alloc.size(), kind))
577 | |         } else {
578 | |             None
579 | |         };
    | |_________^ help: try this: `ecx.machine.data_race.as_ref().map(|data_race| data_race::AllocExtra::new_allocation(data_race, alloc.size(), kind))`
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#manual_map

error: variant name ends with the enum's name
   --> src/shims/intrinsics.rs:354:21
    |
354 |                     MirOp(mir::UnOp),
    |                     ^^^^^^^^^^^^^^^^
    |
    = note: `-D clippy::enum-variant-names` implied by `-D clippy::all`
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#enum_variant_names

error: variant name ends with the enum's name
   --> src/shims/intrinsics.rs:453:21
    |
453 |                     MirOp(BinOp),
    |                     ^^^^^^^^^^^^
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#enum_variant_names

error: variant name ends with the enum's name
   --> src/shims/intrinsics.rs:454:21
    |
454 |                     SaturatingOp(BinOp),
    |                     ^^^^^^^^^^^^^^^^^^^
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#enum_variant_names

error: variant name ends with the enum's name
   --> src/shims/intrinsics.rs:580:21
    |
580 |                     MirOp(BinOp),
    |                     ^^^^^^^^^^^^
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#enum_variant_names

error: explicit lifetimes given in parameter types where they could be elided (or replaced with `'_` if needed by type declaration)
    --> src/shims/intrinsics.rs:1391:1
     |
1391 | fn simd_element_to_bool<'tcx>(elem: ImmTy<'tcx, Tag>) -> InterpResult<'tcx, bool> {
     | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
     |
     = note: `-D clippy::needless-lifetimes` implied by `-D clippy::all`
     = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_lifetimes

error: this `if` has identical blocks
   --> src/shims/posix/sync.rs:503:75
    |
503 |               } else if kind == this.eval_libc("PTHREAD_MUTEX_ERRORCHECK")? {
    |  ___________________________________________________________________________^
504 | |                 this.eval_libc_i32("EPERM")
505 | |             } else if kind == this.eval_libc("PTHREAD_MUTEX_RECURSIVE")? {
    | |_____________^
    |
    = note: `-D clippy::if-same-then-else` implied by `-D clippy::all`
note: same as this
   --> src/shims/posix/sync.rs:505:74
    |
505 |               } else if kind == this.eval_libc("PTHREAD_MUTEX_RECURSIVE")? {
    |  __________________________________________________________________________^
506 | |                 this.eval_libc_i32("EPERM")
507 | |             } else {
    | |_____________^
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#if_same_then_else

error: this `if` has identical blocks
   --> src/shims/posix/sync.rs:610:57
    |
610 |           if this.rwlock_reader_unlock(id, active_thread) {
    |  _________________________________________________________^
611 | |             Ok(0)
612 | |         } else if this.rwlock_writer_unlock(id, active_thread) {
    | |_________^
    |
note: same as this
   --> src/shims/posix/sync.rs:612:64
    |
612 |           } else if this.rwlock_writer_unlock(id, active_thread) {
    |  ________________________________________________________________^
613 | |             Ok(0)
614 | |         } else {
    | |_________^
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#if_same_then_else

error: useless use of `format!`
   --> src/stacked_borrows.rs:228:14
    |
228 |           url: format!(
    |  ______________^
229 | |             "https://github.com/rust-lang/unsafe-code-guidelines/blob/master/wip/stacked-borrows.md"
230 | |         ),
    | |_________^ help: consider using `.to_string()`: `"https://github.com/rust-lang/unsafe-code-guidelines/blob/master/wip/stacked-borrows.md".to_string()`
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#useless_format

error: field assignment outside of initializer for an instance created with Default::default()
   --> src/thread.rs:234:9
    |
234 |         main_thread.join_status = ThreadJoinStatus::Detached;
    |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |
    = note: `-D clippy::field-reassign-with-default` implied by `-D clippy::all`
note: consider initializing the variable with `Thread::<'_, '_> { join_status: ThreadJoinStatus::Detached, ..Default::default() }` and removing relevant reassignments
   --> src/thread.rs:232:9
    |
232 |         let mut main_thread = Thread::default();
    |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#field_reassign_with_default

error: `if` chain can be rewritten with `match`
   --> src/vector_clock.rs:224:17
    |
224 | /                 if l > r {
225 | |                     return false;
226 | |                 } else if l < r {
227 | |                     equal = false;
228 | |                 }
    | |_________________^
    |
    = note: `-D clippy::comparison-chain` implied by `-D clippy::all`
    = help: consider rewriting the `if` chain to use `cmp` and `match`
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#comparison_chain

error: `if` chain can be rewritten with `match`
   --> src/vector_clock.rs:278:17
    |
278 | /                 if l < r {
279 | |                     return false;
280 | |                 } else if l > r {
281 | |                     equal = false;
282 | |                 }
    | |_________________^
    |
    = help: consider rewriting the `if` chain to use `cmp` and `match`
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#comparison_chain

error: manual `RangeInclusive::contains` implementation
   --> src/bin/miri.rs:473:37
    |
473 |                         Ok(rate) if rate >= 0.0 && rate <= 1.0 => rate,
    |                                     ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use: `(0.0..=1.0).contains(&rate)`
    |
    = note: `-D clippy::manual-range-contains` implied by `-D clippy::all`
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#manual_range_contains
```
</details>

2 years agoAuto merge of #2092 - dtolnay-contrib:checkoutv3, r=oli-obk
bors [Sat, 30 Apr 2022 05:10:05 +0000 (05:10 +0000)]
Auto merge of #2092 - dtolnay-contrib:checkoutv3, r=oli-obk

Update GitHub Actions actions/checkout@v2 to v3

The v2 implementation uses Node 12, which is end-of-life on April 30, 2022. See https://nodejs.org/en/about/releases/. Update to v3, which is based on Node 16 whose support lasts until April 30, 2024.

2 years agoUpdate GitHub Actions actions/checkout@v2 to v3
David Tolnay [Sat, 30 Apr 2022 03:25:04 +0000 (20:25 -0700)]
Update GitHub Actions actions/checkout@v2 to v3

The v2 implementation uses Node 12, which is end-of-life on April 30, 2022.
See https://nodejs.org/en/about/releases/. Update to v3, which is based on
Node 16 whose support lasts until April 30, 2024.

2 years agoKeep remaining clippy ignores
David Tolnay [Fri, 29 Apr 2022 23:03:38 +0000 (16:03 -0700)]
Keep remaining clippy ignores

2 years agoResolve clippy::useless_conversion
David Tolnay [Fri, 29 Apr 2022 22:59:42 +0000 (15:59 -0700)]
Resolve clippy::useless_conversion

    error: useless conversion to the same type: `rustc_const_eval::interpret::Pointer<std::option::Option<machine::Tag>>`
       --> src/helpers.rs:668:36
        |
    668 |                 this.get_ptr_alloc(ptr.offset(len, this)?.into(), size1, Align::ONE)?.unwrap(); // not a ZST, so we will get a result
        |                                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider removing `.into()`: `ptr.offset(len, this)?`
        |
        = note: `-D clippy::useless-conversion` implied by `-D clippy::all`
        = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#useless_conversion

    error: useless conversion to the same type: `rustc_const_eval::interpret::Pointer<std::option::Option<machine::Tag>>`
       --> src/helpers.rs:678:29
        |
    678 |         this.read_bytes_ptr(ptr.into(), len)
        |                             ^^^^^^^^^^ help: consider removing `.into()`: `ptr`
        |
        = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#useless_conversion

    error: useless conversion to the same type: `rustc_const_eval::interpret::Pointer<std::option::Option<machine::Tag>>`
       --> src/helpers.rs:690:44
        |
    690 |             let alloc = this.get_ptr_alloc(ptr.into(), size2, align2)?.unwrap(); // not a ZST, so we will get a result
        |                                            ^^^^^^^^^^ help: consider removing `.into()`: `ptr`
        |
        = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#useless_conversion

    error: useless conversion to the same type: `rustc_const_eval::interpret::OpTy<machine::Tag>`
       --> src/shims/intrinsics.rs:778:42
        |
    778 |                         .read_immediate(&this.operand_index(index, i)?.into())?
        |                                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider removing `.into()`: `this.operand_index(index, i)?`
        |
        = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#useless_conversion

    error: useless conversion to the same type: `u32`
        --> src/shims/posix/fs.rs:1171:26
         |
    1171 |             builder.mode(mode.into());
         |                          ^^^^^^^^^^^ help: consider removing `.into()`: `mode`
         |
         = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#useless_conversion

    error: useless conversion to the same type: `std::ffi::OsString`
      --> src/shims/env.rs:67:53
       |
    67 |                     ecx.machine.env_vars.map.insert(OsString::from(name), var_ptr);
       |                                                     ^^^^^^^^^^^^^^^^^^^^ help: consider removing `OsString::from()`: `name`
       |
       = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#useless_conversion

    error: useless conversion to the same type: `rustc_const_eval::interpret::Scalar<machine::Tag>`
       --> src/shims/tls.rs:102:44
        |
    102 |                 Ok(value.unwrap_or_else(|| Scalar::null_ptr(cx).into()))
        |                                            ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider removing `.into()`: `Scalar::null_ptr(cx)`
        |
        = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#useless_conversion

    error: useless conversion to the same type: `u32`
      --> src/thread.rs:73:26
       |
    73 |         Scalar::from_u32(u32::try_from(self.0).unwrap())
       |                          ^^^^^^^^^^^^^^^^^^^^^
       |
       = help: consider removing `u32::try_from()`
       = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#useless_conversion

2 years agoResolve clippy::unnecessary_mut_passed
David Tolnay [Fri, 29 Apr 2022 22:59:03 +0000 (15:59 -0700)]
Resolve clippy::unnecessary_mut_passed

    error: the method `validate_lock_acquire` doesn't need a mutable reference
       --> src/sync.rs:477:49
        |
    477 |                 data_race.validate_lock_acquire(&mut condvar.data_race, waiter.thread);
        |                                                 ^^^^^^^^^^^^^^^^^^^^^^
        |
        = note: `-D clippy::unnecessary-mut-passed` implied by `-D clippy::all`
        = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_mut_passed