Previously, Miri would always print a backtrace including all frames
when encountering an error. This adds -Zmiri-backtrace which defaults
to 1, internally called BacktraceStyle::Short. By default, backtraces
are pruned to start at __rust_begin_short_backtrace, similar to std.
Then we also remove non-local frames from the bottom of the trace.
This cleans up the last one or two shims outside main or a test.
Users can opt out of pruning by setting -Zmiri-backtrace=full, and will
be automatically opted out if there are no local frames because that
means the reported error is likely in the Rust runtime, which this
pruning is crafted to remove.
implement simd_eq and simd_reduce_any
This lets us re-enable the division and modulo tests, since those operations now internally use simd_eq and simd_reduce_any.
However, I am not sure what exactly the rules are for simd_reduce_any. `@workingjubilee` for now I made it UB to call those with inputs that are not all-0 or all-1, but that might be taking it too far?
rustup: disable read_dir test for now
I don't currently have time to fix our read_dir support, so I disabled the tests for now. https://github.com/rust-lang/miri/issues/1966 tracks bringing back that functionality.
exclude mutable references to !Unpin types from uniqueness guarantees
This basically works around https://github.com/rust-lang/unsafe-code-guidelines/issues/148 by not requiring uniqueness any more for mutable references to self-referential generators. That corresponds to [the same work-around that was applied in rustc itself](b815532674/compiler/rustc_middle/src/ty/layout.rs (L2482)).
I am not entirely sure if this is a good idea since it might hide too many errors in case types are "accidentally" `!Unpin`. OTOH, our test suite still passes, and to my knowledge the vast majority of types is `Unpin`. (`place.layout.ty` is monomorphic, we should always exactly know which type this is.)
add and document MIRI_LIB_SRC env var to set the source from which Miri builds the standard library
This is just an alias of `XARGO_RUST_SRC`, but avoids exposing how exactly we use xargo.
Provide slightly better notes when tracking a pointer tag
I slapped this in as a sort of advanced println-based debugging when trying to figure out a track-raw-pointers finding in `smallvec`. Perhaps this looks like a good idea to you all?
EDIT: User scenario
Run `MIRIFLAGS=-Ztag-raw-pointers cargo miri test`, get a diagnostic that looks like
```
error: Undefined Behavior: trying to reborrow for SharedReadOnly at alloc99465+0x9, but parent tag <265507> does not have an appropriate item in the borrow stack
```
So now run `MIRIFLAGS=-Ztag-raw-pointers -Zmiri-track-pointer-tag=265507 cargo miri test`
Old:
```
note: tracking was triggered
--> src/lib.rs:822:36
|
822 | vec: NonNull::from(self),
| ^^^^ popped tracked tag for item [SharedReadOnly for <265507>]
```
New:
```
note: tracking was triggered
--> src/lib.rs:822:36
|
822 | vec: NonNull::from(self),
| ^^^^ popped tracked tag for item [SharedReadOnly for <265507>] due to Write access for <265356>
```
So that if a user is now beginning to question their sanity because they don't really understand SB yet, they can then track the tag which caused the parent tag to be removed from the stack to be sure what's going on here:
```
--> src/lib.rs:792:5
|
792 | / pub fn drain<R>(&mut self, range: R) -> Drain<'_, A>
793 | | where
794 | | R: RangeBounds<usize>,
795 | | {
... |
824 | | }
825 | | }
| |_____^ created tag 265356
```
The existing diagnostic can tell you where the tag you'd need was invalidated, but it cannot tell you what and why that tag was invalidated.