Improve error message of calling unsupported non-"C"/"system"-ABI foreign function
Miri currently reports the following `foo()` call has ABI-mismatch UB:
```rust
#[cfg(unix)]
extern "Rust" { // or any non-"C" ABI
fn foo();
}
#[cfg(windows)]
extern "C" { // or any non-"system" ABI
fn foo();
}
fn main() {
unsafe {
foo();
}
}
```
[Output when targeting Linux](https://play.rust-lang.org/?version=nightly&mode=debug&edition=2018&gist=72afc3bd4d9fdab962422cfc2c5a2166) (and maybe also macOS):
```
error: Undefined Behavior: calling a function with ABI C using caller ABI Rust
--> src/main.rs:13:9
|
13 | foo();
| ^^^^^ calling a function with ABI C using caller ABI Rust
|
= help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavio
```
Output when targeting Windows:
```
error: Undefined Behavior: calling a function with ABI system using caller ABI C
--> <anon>:13:9
|
13 | foo();
| ^^^^^ calling a function with ABI system using caller ABI C
|
= help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior
```
However, to my knowledge, that's not UB -- it's just unsupported by Miri (and Miri can't assume the function has `"C"` or `"system"` ABI since Miri doesn't know about it). I believe that is because of the overzealous `check_abi()` call before the long `match` in `src/shims/{posix,windows}/foreign_items.rs`. The ABI is checked to match the system one (`"system"` on Windows, `"C"` otherwise) no matter the callee is recognized as a shim or an unsupported foreign function.
Therefore, this PR removes the `check_abi()` call before the `match` and inserts a `check_abi()` call to each non-wildcard match.
Remove unwrap_none/expect_none, take 2.
This is https://github.com/rust-lang/miri/pull/1734, but now with a better alternative.
This also upgrades rustc to the latest version, to be able to use the better alternative (`try_insert`).
Support breakpoint intrinsic
The `breakpoint` intrinsic raises a `SIGTRAP` signal. If a debugger is attached to a normal program, then `SIGTRAP` can be used to trigger breakpoints in debuggers like `gdb`. If there is no debugger, then the program exits with a message like `Trace/breakpoint trap (core dumped)`. This adds support for the intrinsic in Miri. While actually passing through the `SIGTRAP` doesn't make sense in a Miri context (if it just raised the signal normally then it would allow for debugging Miri itself, not the program being evaluated). As such, it just raises an error.
Add atomic min and max
Closes#1718
Previous attempt: #1653
TODO:
- [x] Merge `atomic_op` and `atomic_min_max` functions
- [x] Fix CI
**Note:** this PR also removes arbitrary trailing whitespace and generally formats the affected files
add date to Zulip notification subject
We sometimes have discussions in those threads; let's make sure we have a new thread for each new day (which likely means a new problem... or nobody got around to fixing things yet^^).
adjust CI test flags
`RUST_TEST_NOCAPTURE` seems to make no difference except for making compiletest output not use colors any more; `RUST_BACKTRACE` is already set by `compiletest.rs`.
rustup; fix tests for new MIR optimization
Somehow https://github.com/rust-lang/rust/pull/78360 manages to mask UB. This would make sense if there were loops or things like that, but there are not, so really this is just very confusing...