about summary refs log tree commit diff
path: root/library/std/src/sys/unix/stack_overflow.rs
diff options
context:
space:
mode:
authorMatthias Krüger <matthias.krueger@famsik.de>2022-10-27 09:25:08 +0200
committerGitHub <noreply@github.com>2022-10-27 09:25:08 +0200
commit2937621aa7ad494b1ef2da3a8e814ac6e101e181 (patch)
treec519f539d390f89ffaa84e59f5afc0bf4cb4a913 /library/std/src/sys/unix/stack_overflow.rs
parent44fcfb0a9606fa08ea293a71f2e6d470227ef9df (diff)
parent458aaa5a2343a58d169c21e90101376b83fd9fdc (diff)
downloadrust-2937621aa7ad494b1ef2da3a8e814ac6e101e181.tar.gz
rust-2937621aa7ad494b1ef2da3a8e814ac6e101e181.zip
Rollup merge of #103035 - saethlin:assert_unsafe_precondition3, r=thomcc
Even nicer errors from assert_unsafe_precondition

For example, now running `cargo test` with this patch I get things like:
```
$ cargo +stage1 test
    Finished test [unoptimized + debuginfo] target(s) in 0.01s
     Running unittests src/lib.rs (target/debug/deps/malloc_buf-9d105ddf86862995)

running 5 tests
thread 'tests::test_null_buf' panicked at 'unsafe precondition violated: is_aligned_and_not_null(data) &&
    crate::mem::size_of::<T>().saturating_mul(len) <= isize::MAX as usize', /home/ben/rust/library/core/src/slice/raw.rs:93:9
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
thread panicked while panicking. aborting.
error: test failed, to rerun pass `--lib`

Caused by:
  process didn't exit successfully: `/tmp/malloc_buf-1.0.0/target/debug/deps/malloc_buf-9d105ddf86862995` (signal: 6, SIGABRT: process abort signal)
```

This is still not perfect, but these are better for another PR:
* `stringify!` is trying to do clever pretty-printing on the `expr` inside `assert_unsafe_precondition` and can even add a newline.
* It would be nice to print a bit more information about where the problem is. Perhaps this is `cfg_attr(debug_assertions, track_caller)`, or perhaps it the function name added to `Location`.

cc ``@RalfJung`` this is what I was thinking of for https://github.com/rust-lang/rust/pull/102732#discussion_r989068907
Diffstat (limited to 'library/std/src/sys/unix/stack_overflow.rs')
0 files changed, 0 insertions, 0 deletions