diff options
| author | Dylan DPC <99973273+Dylan-DPC@users.noreply.github.com> | 2022-08-14 17:09:17 +0530 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-08-14 17:09:17 +0530 |
| commit | 9de9786ef84f09b367d99bcce6e59a4ed75acd64 (patch) | |
| tree | d63a94dc1432882fa5856a412d0c28d40e978cfd /src | |
| parent | 38bc93730bcea6c0e6020fbf01a9e00c2a627e83 (diff) | |
| parent | 6b19a48e708609b456d3a6e90cafd63a6c348e86 (diff) | |
| download | rust-9de9786ef84f09b367d99bcce6e59a4ed75acd64.tar.gz rust-9de9786ef84f09b367d99bcce6e59a4ed75acd64.zip | |
Rollup merge of #100487 - tmiasko:assert-safe, r=petrochenkov
`assert_{inhabited,zero_valid,uninit_valid}` intrinsics are safe
Those intrinsics either panic or do nothing. They are safe.
Diffstat (limited to 'src')
| -rw-r--r-- | src/test/ui/consts/assert-type-intrinsics.rs | 4 | ||||
| -rw-r--r-- | src/test/ui/consts/assert-type-intrinsics.stderr | 8 |
2 files changed, 6 insertions, 6 deletions
diff --git a/src/test/ui/consts/assert-type-intrinsics.rs b/src/test/ui/consts/assert-type-intrinsics.rs index 38e5c454edf..3ce3e1bdbac 100644 --- a/src/test/ui/consts/assert-type-intrinsics.rs +++ b/src/test/ui/consts/assert-type-intrinsics.rs @@ -13,10 +13,10 @@ fn main() { const _BAD1: () = unsafe { MaybeUninit::<!>::uninit().assume_init(); }; - const _BAD2: () = unsafe { + const _BAD2: () = { intrinsics::assert_uninit_valid::<bool>(); }; - const _BAD3: () = unsafe { + const _BAD3: () = { intrinsics::assert_zero_valid::<&'static i32>(); }; } diff --git a/src/test/ui/consts/assert-type-intrinsics.stderr b/src/test/ui/consts/assert-type-intrinsics.stderr index f3b9170d428..6eab10197b8 100644 --- a/src/test/ui/consts/assert-type-intrinsics.stderr +++ b/src/test/ui/consts/assert-type-intrinsics.stderr @@ -13,7 +13,7 @@ LL | MaybeUninit::<!>::uninit().assume_init(); error: any use of this value will cause an error --> $DIR/assert-type-intrinsics.rs:17:9 | -LL | const _BAD2: () = unsafe { +LL | const _BAD2: () = { | --------------- LL | intrinsics::assert_uninit_valid::<bool>(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ aborted execution: attempted to leave type `bool` uninitialized, which is invalid @@ -24,7 +24,7 @@ LL | intrinsics::assert_uninit_valid::<bool>(); error: any use of this value will cause an error --> $DIR/assert-type-intrinsics.rs:20:9 | -LL | const _BAD3: () = unsafe { +LL | const _BAD3: () = { | --------------- LL | intrinsics::assert_zero_valid::<&'static i32>(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ aborted execution: attempted to zero-initialize type `&i32`, which is invalid @@ -51,7 +51,7 @@ Future breakage diagnostic: error: any use of this value will cause an error --> $DIR/assert-type-intrinsics.rs:17:9 | -LL | const _BAD2: () = unsafe { +LL | const _BAD2: () = { | --------------- LL | intrinsics::assert_uninit_valid::<bool>(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ aborted execution: attempted to leave type `bool` uninitialized, which is invalid @@ -64,7 +64,7 @@ Future breakage diagnostic: error: any use of this value will cause an error --> $DIR/assert-type-intrinsics.rs:20:9 | -LL | const _BAD3: () = unsafe { +LL | const _BAD3: () = { | --------------- LL | intrinsics::assert_zero_valid::<&'static i32>(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ aborted execution: attempted to zero-initialize type `&i32`, which is invalid |
