File tree 3 files changed +7
-10
lines changed
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> {
619
619
#[ rustc_const_unstable( feature = "const_maybe_uninit_assume_init" , issue = "none" ) ]
620
620
#[ inline( always) ]
621
621
#[ rustc_diagnostic_item = "assume_init" ]
622
+ #[ track_caller]
622
623
pub const unsafe fn assume_init ( self ) -> T {
623
624
// SAFETY: the caller must guarantee that `self` is initialized.
624
625
// This also means that `self` must be a `value` variant.
@@ -690,6 +691,7 @@ impl<T> MaybeUninit<T> {
690
691
#[ unstable( feature = "maybe_uninit_extra" , issue = "63567" ) ]
691
692
#[ rustc_const_unstable( feature = "maybe_uninit_extra" , issue = "63567" ) ]
692
693
#[ inline( always) ]
694
+ #[ track_caller]
693
695
pub const unsafe fn assume_init_read ( & self ) -> T {
694
696
// SAFETY: the caller must guarantee that `self` is initialized.
695
697
// Reading from `self.as_ptr()` is safe since `self` should be initialized.
@@ -937,6 +939,7 @@ impl<T> MaybeUninit<T> {
937
939
/// ```
938
940
#[ unstable( feature = "maybe_uninit_array_assume_init" , issue = "80908" ) ]
939
941
#[ inline( always) ]
942
+ #[ track_caller]
940
943
pub unsafe fn array_assume_init < const N : usize > ( array : [ Self ; N ] ) -> [ T ; N ] {
941
944
// SAFETY:
942
945
// * 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 {
622
622
#[ allow( deprecated_in_future) ]
623
623
#[ allow( deprecated) ]
624
624
#[ rustc_diagnostic_item = "mem_zeroed" ]
625
+ #[ track_caller]
625
626
pub unsafe fn zeroed < T > ( ) -> T {
626
627
// SAFETY: the caller must guarantee that an all-zero value is valid for `T`.
627
628
unsafe {
@@ -657,6 +658,7 @@ pub unsafe fn zeroed<T>() -> T {
657
658
#[ allow( deprecated_in_future) ]
658
659
#[ allow( deprecated) ]
659
660
#[ rustc_diagnostic_item = "mem_uninitialized" ]
661
+ #[ track_caller]
660
662
pub unsafe fn uninitialized < T > ( ) -> T {
661
663
// SAFETY: the caller must guarantee that an unitialized value is valid for `T`.
662
664
unsafe {
Original file line number Diff line number Diff line change 1
1
error: 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
12
3
|
13
4
LL | / const _BAD: () = unsafe {
14
5
LL | | MaybeUninit::<!>::uninit().assume_init();
6
+ | | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ aborted execution: attempted to instantiate uninhabited type `!`
15
7
LL | | };
16
8
| |______-
17
9
|
You can’t perform that action at this time.
0 commit comments