Add #[track_caller] for some function in core::mem.

These functions can panic for some types. This makes the panic point to
the code that calls e.g. mem::uninitialized(), instead of inside the
definition of mem::uninitialized.
This commit is contained in:
Mara Bos 2021-06-27 12:41:50 +00:00
parent eba3228b2a
commit 3f6dc9a8ab
3 changed files with 7 additions and 10 deletions

View file

@ -1,17 +1,9 @@
error: any use of this value will cause an error
--> $SRC_DIR/core/src/mem/maybe_uninit.rs:LL:COL
|
LL | intrinsics::assert_inhabited::<T>();
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| |
| aborted execution: attempted to instantiate uninhabited type `!`
| inside `MaybeUninit::<!>::assume_init` at $SRC_DIR/core/src/mem/maybe_uninit.rs:LL:COL
| inside `_BAD` at $DIR/assume-type-intrinsics.rs:11:9
|
::: $DIR/assume-type-intrinsics.rs:10:5
--> $DIR/assume-type-intrinsics.rs:11:9
|
LL | / const _BAD: () = unsafe {
LL | | MaybeUninit::<!>::uninit().assume_init();
| | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ aborted execution: attempted to instantiate uninhabited type `!`
LL | | };
| |______-
|