File tree Expand file tree Collapse file tree 3 files changed +7
-10
lines changed Expand file tree Collapse file tree 3 files changed +7
-10
lines changed Original file line number Diff line number Diff line change @@ -619,6 +619,7 @@ impl<T> MaybeUninit<T> {
619619 #[ rustc_const_unstable( feature = "const_maybe_uninit_assume_init" , issue = "none" ) ]
620620 #[ inline( always) ]
621621 #[ rustc_diagnostic_item = "assume_init" ]
622+ #[ track_caller]
622623 pub const unsafe fn assume_init ( self ) -> T {
623624 // SAFETY: the caller must guarantee that `self` is initialized.
624625 // This also means that `self` must be a `value` variant.
@@ -690,6 +691,7 @@ impl<T> MaybeUninit<T> {
690691 #[ unstable( feature = "maybe_uninit_extra" , issue = "63567" ) ]
691692 #[ rustc_const_unstable( feature = "maybe_uninit_extra" , issue = "63567" ) ]
692693 #[ inline( always) ]
694+ #[ track_caller]
693695 pub const unsafe fn assume_init_read ( & self ) -> T {
694696 // SAFETY: the caller must guarantee that `self` is initialized.
695697 // Reading from `self.as_ptr()` is safe since `self` should be initialized.
@@ -937,6 +939,7 @@ impl<T> MaybeUninit<T> {
937939 /// ```
938940 #[ unstable( feature = "maybe_uninit_array_assume_init" , issue = "80908" ) ]
939941 #[ inline( always) ]
942+ #[ track_caller]
940943 pub unsafe fn array_assume_init < const N : usize > ( array : [ Self ; N ] ) -> [ T ; N ] {
941944 // SAFETY:
942945 // * The caller guarantees that all elements of the array are initialized
Original file line number Diff line number Diff line change @@ -622,6 +622,7 @@ pub const fn needs_drop<T>() -> bool {
622622#[ allow( deprecated_in_future) ]
623623#[ allow( deprecated) ]
624624#[ rustc_diagnostic_item = "mem_zeroed" ]
625+ #[ track_caller]
625626pub unsafe fn zeroed < T > ( ) -> T {
626627 // SAFETY: the caller must guarantee that an all-zero value is valid for `T`.
627628 unsafe {
@@ -657,6 +658,7 @@ pub unsafe fn zeroed<T>() -> T {
657658#[ allow( deprecated_in_future) ]
658659#[ allow( deprecated) ]
659660#[ rustc_diagnostic_item = "mem_uninitialized" ]
661+ #[ track_caller]
660662pub unsafe fn uninitialized < T > ( ) -> T {
661663 // SAFETY: the caller must guarantee that an unitialized value is valid for `T`.
662664 unsafe {
Original file line number Diff line number Diff line change 11error: any use of this value will cause an error
2- --> $SRC_DIR/core/src/mem/maybe_uninit.rs:LL:COL
3- |
4- LL | intrinsics::assert_inhabited::<T>();
5- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
6- | |
7- | aborted execution: attempted to instantiate uninhabited type `!`
8- | inside `MaybeUninit::<!>::assume_init` at $SRC_DIR/core/src/mem/maybe_uninit.rs:LL:COL
9- | inside `_BAD` at $DIR/assume-type-intrinsics.rs:11:9
10- |
11- ::: $DIR/assume-type-intrinsics.rs:10:5
2+ --> $DIR/assume-type-intrinsics.rs:11:9
123 |
134LL | / const _BAD: () = unsafe {
145LL | | MaybeUninit::<!>::uninit().assume_init();
6+ | | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ aborted execution: attempted to instantiate uninhabited type `!`
157LL | | };
168 | |______-
179 |
You can’t perform that action at this time.
0 commit comments