rust/tests/compile-fail
bors aa589d3dc7 Auto merge of #2145 - saethlin:zero-size-creation, r=RalfJung
Save a created event for zero-size reborrows

Currently, we don't save a created event for zero-sized reborrows. Attempting to use something from a zero-sized reborrow is surprisingly common, for example on `minimal-lexical==0.2.1` we previously just emit this:
```
Undefined Behavior: attempting a write access using <187021> at alloc72933[0x0], but that tag does not exist in the borrow stack for this location
    --> /root/rust/library/core/src/ptr/mod.rs:1287:9
     |
1287 |         copy_nonoverlapping(&src as *const T, dst, 1);
     |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
     |         |
     |         attempting a write access using <187021> at alloc72933[0x0], but that tag does not exist in the borrow stack for this location
     |         this error occurs as part of an access at alloc72933[0x0..0x8]
     |
     = 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

     = note: inside `std::ptr::write::<u64>` at /root/rust/library/core/src/ptr/mod.rs:1287:9
note: inside `minimal_lexical::stackvec::StackVec::push_unchecked` at /root/build/src/stackvec.rs:82:13
    --> /root/build/src/stackvec.rs:82:13
     |
82   |             ptr::write(self.as_mut_ptr().add(self.len()), value);
     |             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

... backtrace continues...
```
Which leaves us with the question "where did we make this pointer?" because for every other diagnostic you get a "was created by" note, so I suspect people might be tempted to think there is a Miri bug here. I certainly was.

---
This code duplication is so awful, I'm going to take a look at cleaning it up later. The fact that `ptr_get_alloc_id` can fail in this situation makes things annoying.
2022-05-30 23:43:51 +00:00
..
alloc Add a custom ui test runner and move all tests to it 2022-05-25 13:31:26 +00:00
backtrace Add a custom ui test runner and move all tests to it 2022-05-25 13:31:26 +00:00
concurrency Add a custom ui test runner and move all tests to it 2022-05-25 13:31:26 +00:00
dangling_pointers Add a custom ui test runner and move all tests to it 2022-05-25 13:31:26 +00:00
data_race Add a custom ui test runner and move all tests to it 2022-05-25 13:31:26 +00:00
fs Add a custom ui test runner and move all tests to it 2022-05-25 13:31:26 +00:00
function_calls Add a custom ui test runner and move all tests to it 2022-05-25 13:31:26 +00:00
function_pointers Add a custom ui test runner and move all tests to it 2022-05-25 13:31:26 +00:00
intrinsics Update all tests 2022-05-25 18:26:33 +00:00
panic normalize away some more line numbers 2022-05-30 19:21:22 -04:00
provenance enable number validity checking and ptr::invalid checking by default 2022-05-25 16:17:41 +02:00
stacked_borrows Auto merge of #2145 - saethlin:zero-size-creation, r=RalfJung 2022-05-30 23:43:51 +00:00
sync Add a custom ui test runner and move all tests to it 2022-05-25 13:31:26 +00:00
unaligned_pointers Update all tests 2022-05-25 18:26:33 +00:00
validity Update all tests 2022-05-25 18:26:33 +00:00
abort-terminator.rs Fix tests for C-unwind ABI changes 2021-08-07 15:57:54 +08:00
abort-terminator.stderr Add a custom ui test runner and move all tests to it 2022-05-25 13:31:26 +00:00
box-cell-alias.rs add -Zmiri-strict-provenance 2022-04-01 14:10:24 -04:00
box-cell-alias.stderr Add a custom ui test runner and move all tests to it 2022-05-25 13:31:26 +00:00
branchless-select-i128-pointer.rs add test by @eddyb 2021-02-16 10:18:31 +01:00
branchless-select-i128-pointer.stderr Add a custom ui test runner and move all tests to it 2022-05-25 13:31:26 +00:00
breakpoint.rs Support breakpoint intrinsic 2021-03-04 07:48:28 -05:00
breakpoint.stderr Add a custom ui test runner and move all tests to it 2022-05-25 13:31:26 +00:00
environ-gets-deallocated.rs fix some ignore-windows comments 2020-06-28 20:40:20 +02:00
environ-gets-deallocated.stderr Add a custom ui test runner and move all tests to it 2022-05-25 13:31:26 +00:00
erroneous_const2.rs test for "erroneous constant used" post-monomorphization error 2022-05-08 17:56:09 +02:00
erroneous_const2.stderr Add a custom ui test runner and move all tests to it 2022-05-25 13:31:26 +00:00
erroneous_const.rs gracefully handle type-too-large layout errors 2022-04-30 17:09:44 +02:00
erroneous_const.stderr Add a custom ui test runner and move all tests to it 2022-05-25 13:31:26 +00:00
extern_static.rs rustup 2021-01-31 13:12:25 +01:00
extern_static.stderr Add a custom ui test runner and move all tests to it 2022-05-25 13:31:26 +00:00
fast_math_both.rs Simplify finiteness checking 2021-05-03 10:08:42 -04:00
fast_math_both.stderr Add a custom ui test runner and move all tests to it 2022-05-25 13:31:26 +00:00
fast_math_first.rs Simplify finiteness checking 2021-05-03 10:08:42 -04:00
fast_math_first.stderr Add a custom ui test runner and move all tests to it 2022-05-25 13:31:26 +00:00
fast_math_second.rs test for infinite value in f*_fast 2021-05-03 09:56:51 -04:00
fast_math_second.stderr Add a custom ui test runner and move all tests to it 2022-05-25 13:31:26 +00:00
generator-pinned-moved.rs rustup 2022-05-30 19:19:39 -04:00
generator-pinned-moved.stderr normalize away some more line numbers 2022-05-30 19:21:22 -04:00
invalid_bool.rs Add a custom ui test runner and move all tests to it 2022-05-25 13:31:26 +00:00
invalid_bool.stderr Add a custom ui test runner and move all tests to it 2022-05-25 13:31:26 +00:00
invalid_char.rs Add a custom ui test runner and move all tests to it 2022-05-25 13:31:26 +00:00
invalid_char.stderr Add a custom ui test runner and move all tests to it 2022-05-25 13:31:26 +00:00
invalid_enum_tag.rs Add a custom ui test runner and move all tests to it 2022-05-25 13:31:26 +00:00
invalid_enum_tag.stderr Add a custom ui test runner and move all tests to it 2022-05-25 13:31:26 +00:00
invalid_int.rs make sure our disable flags do not miss all bugs; move type-assert intrinsic tests to their folder 2020-04-14 10:23:47 +02:00
invalid_int.stderr Add a custom ui test runner and move all tests to it 2022-05-25 13:31:26 +00:00
issue-miri-1112.rs rustup; fix error messages 2020-05-07 08:38:59 +02:00
issue-miri-1112.stderr Add a custom ui test runner and move all tests to it 2022-05-25 13:31:26 +00:00
memleak_rc.32bit.stderr Add a custom ui test runner and move all tests to it 2022-05-25 13:31:26 +00:00
memleak_rc.64bit.stderr Add a custom ui test runner and move all tests to it 2022-05-25 13:31:26 +00:00
memleak_rc.rs Add a custom ui test runner and move all tests to it 2022-05-25 13:31:26 +00:00
memleak.rs Add a custom ui test runner and move all tests to it 2022-05-25 13:31:26 +00:00
memleak.stderr Add a custom ui test runner and move all tests to it 2022-05-25 13:31:26 +00:00
modifying_constants.rs adjust for error reform 2020-03-19 08:25:08 +01:00
modifying_constants.stderr Add a custom ui test runner and move all tests to it 2022-05-25 13:31:26 +00:00
never_say_never.rs
never_say_never.stderr Add a custom ui test runner and move all tests to it 2022-05-25 13:31:26 +00:00
never_transmute_humans.rs
never_transmute_humans.stderr Add a custom ui test runner and move all tests to it 2022-05-25 13:31:26 +00:00
never_transmute_void.rs rustup 2022-04-20 17:46:31 -04:00
never_transmute_void.stderr Add a custom ui test runner and move all tests to it 2022-05-25 13:31:26 +00:00
no_main.rs Move no_main test to compile-fail 2020-07-09 17:21:09 +02:00
no_main.stderr Add a custom ui test runner and move all tests to it 2022-05-25 13:31:26 +00:00
null_pointer_deref_zst.stderr Add a custom ui test runner and move all tests to it 2022-05-25 13:31:26 +00:00
null_pointer_deref.stderr Add a custom ui test runner and move all tests to it 2022-05-25 13:31:26 +00:00
null_pointer_write_zst.stderr Add a custom ui test runner and move all tests to it 2022-05-25 13:31:26 +00:00
null_pointer_write.stderr Add a custom ui test runner and move all tests to it 2022-05-25 13:31:26 +00:00
pointer_partial_overwrite.rs adjust for ERR_ON_PARTIAL_PTR_OVERWRITE 2021-08-02 17:58:55 +02:00
pointer_partial_overwrite.stderr Add a custom ui test runner and move all tests to it 2022-05-25 13:31:26 +00:00
pointer_partial_read.rs adjust for ERR_ON_PARTIAL_PTR_OVERWRITE 2021-08-02 17:58:55 +02:00
pointer_partial_read.stderr Add a custom ui test runner and move all tests to it 2022-05-25 13:31:26 +00:00
ptr_integer_array_transmute.stderr Add a custom ui test runner and move all tests to it 2022-05-25 13:31:26 +00:00
ptr_integer_transmute.stderr Add a custom ui test runner and move all tests to it 2022-05-25 13:31:26 +00:00
rc_as_ptr.rs Clean up all trailing whitespace 2022-04-30 10:40:35 -07:00
rc_as_ptr.stderr Add a custom ui test runner and move all tests to it 2022-05-25 13:31:26 +00:00
reading_half_a_pointer.rs rustup, and some final message adjustments 2020-03-19 08:41:01 +01:00
reading_half_a_pointer.stderr Add a custom ui test runner and move all tests to it 2022-05-25 13:31:26 +00:00
rustc-error.rs fix exit code on rustc errors 2020-04-25 11:12:50 +02:00
rustc-error.stderr Add a custom ui test runner and move all tests to it 2022-05-25 13:31:26 +00:00
shim_arg_size.32bit.stderr Add a custom ui test runner and move all tests to it 2022-05-25 13:31:26 +00:00
shim_arg_size.64bit.stderr Add a custom ui test runner and move all tests to it 2022-05-25 13:31:26 +00:00
shim_arg_size.rs Add a custom ui test runner and move all tests to it 2022-05-25 13:31:26 +00:00
slice-too-big.stderr Add a custom ui test runner and move all tests to it 2022-05-25 13:31:26 +00:00
static_memory_modification1.rs adjust for error reform 2020-03-19 08:25:08 +01:00
static_memory_modification1.stderr Add a custom ui test runner and move all tests to it 2022-05-25 13:31:26 +00:00
static_memory_modification2.rs adjust for error reform 2020-03-19 08:25:08 +01:00
static_memory_modification2.stderr Add a custom ui test runner and move all tests to it 2022-05-25 13:31:26 +00:00
static_memory_modification3.rs adjust for error reform 2020-03-19 08:25:08 +01:00
static_memory_modification3.stderr Add a custom ui test runner and move all tests to it 2022-05-25 13:31:26 +00:00
strict_provenance_transmute.stderr Add a custom ui test runner and move all tests to it 2022-05-25 13:31:26 +00:00
strict-provenance-offset.stderr Add a custom ui test runner and move all tests to it 2022-05-25 13:31:26 +00:00
too-big-slice.stderr Add a custom ui test runner and move all tests to it 2022-05-25 13:31:26 +00:00
too-big-unsized.stderr Add a custom ui test runner and move all tests to it 2022-05-25 13:31:26 +00:00
transmute_fat1.rs rustup, and some final message adjustments 2020-03-19 08:41:01 +01:00
transmute_fat1.stderr Add a custom ui test runner and move all tests to it 2022-05-25 13:31:26 +00:00
transmute-pair-uninit.rs enable number validity checking and ptr::invalid checking by default 2022-05-25 16:17:41 +02:00
transmute-pair-uninit.stderr Add a custom ui test runner and move all tests to it 2022-05-25 13:31:26 +00:00
type-too-large.rs gracefully handle type-too-large layout errors 2022-04-30 17:09:44 +02:00
type-too-large.stderr Add a custom ui test runner and move all tests to it 2022-05-25 13:31:26 +00:00
uninit_buffer.rs Update to match rustc changes 2020-05-22 17:03:25 +02:00
uninit_buffer.stderr Add a custom ui test runner and move all tests to it 2022-05-25 13:31:26 +00:00
uninit_byte_read.rs enable number validity checking and ptr::invalid checking by default 2022-05-25 16:17:41 +02:00
uninit_byte_read.stderr Add a custom ui test runner and move all tests to it 2022-05-25 13:31:26 +00:00
uninit_float.stderr Add a custom ui test runner and move all tests to it 2022-05-25 13:31:26 +00:00
uninit_integer_signed.stderr Add a custom ui test runner and move all tests to it 2022-05-25 13:31:26 +00:00
uninit_integer.stderr Add a custom ui test runner and move all tests to it 2022-05-25 13:31:26 +00:00
uninit_raw_ptr.rs Add test for uninit raw ptrs 2021-11-10 11:36:42 -08:00
uninit_raw_ptr.stderr Add a custom ui test runner and move all tests to it 2022-05-25 13:31:26 +00:00
unreachable.rs test unreachable intrinsic 2020-03-25 09:32:15 +01:00
unreachable.stderr Add a custom ui test runner and move all tests to it 2022-05-25 13:31:26 +00:00
unsupported_foreign_function.rs Unsupported foreign non-"C"/"system"-ABI function calls are not UB 2021-03-17 21:20:04 +08:00
unsupported_foreign_function.stderr Add a custom ui test runner and move all tests to it 2022-05-25 13:31:26 +00:00
unsupported_signal.rs expand comment 2021-06-06 10:33:46 +02:00
unsupported_signal.stderr Add a custom ui test runner and move all tests to it 2022-05-25 13:31:26 +00:00
zst1.rs adjust Miri to Pointer type overhaul 2021-07-16 10:10:12 +02:00
zst1.stderr Add a custom ui test runner and move all tests to it 2022-05-25 13:31:26 +00:00
zst2.rs disable MIR opts for ZST-related tests 2021-03-25 12:44:30 +01:00
zst2.stderr Add a custom ui test runner and move all tests to it 2022-05-25 13:31:26 +00:00
zst3.rs adjust Miri to Pointer type overhaul 2021-07-16 10:10:12 +02:00
zst3.stderr Add a custom ui test runner and move all tests to it 2022-05-25 13:31:26 +00:00