forked from rust-lang/rust
-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rollup merge of rust-lang#91323 - RalfJung:assert-type, r=oli-obk
CTFE: support assert_zero_valid and assert_uninit_valid This ensures the implementation of all three type-based assert_ intrinsics remains consistent in Miri. `assert_inhabited` recently got stabilized in rust-lang#90896 (meaning stable `const fn` can call it), so do the same with these other intrinsics. Cc ```@rust-lang/wg-const-eval```
- Loading branch information
Showing
6 changed files
with
88 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
// error-pattern: any use of this value will cause an error | ||
|
||
#![feature(never_type)] | ||
#![feature(const_maybe_uninit_assume_init, const_assert_type2)] | ||
#![feature(core_intrinsics)] | ||
|
||
use std::intrinsics; | ||
|
||
#[allow(invalid_value)] | ||
fn main() { | ||
use std::mem::MaybeUninit; | ||
|
||
const _BAD1: () = unsafe { | ||
MaybeUninit::<!>::uninit().assume_init(); | ||
}; | ||
const _BAD2: () = unsafe { | ||
intrinsics::assert_uninit_valid::<bool>(); | ||
}; | ||
const _BAD3: () = unsafe { | ||
intrinsics::assert_zero_valid::<&'static i32>(); | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
error: any use of this value will cause an error | ||
--> $DIR/assert-type-intrinsics.rs:14:9 | ||
| | ||
LL | / const _BAD1: () = unsafe { | ||
LL | | MaybeUninit::<!>::uninit().assume_init(); | ||
| | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ aborted execution: attempted to instantiate uninhabited type `!` | ||
LL | | }; | ||
| |______- | ||
| | ||
= note: `#[deny(const_err)]` on by default | ||
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! | ||
= note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800> | ||
|
||
error: any use of this value will cause an error | ||
--> $DIR/assert-type-intrinsics.rs:17:9 | ||
| | ||
LL | / const _BAD2: () = unsafe { | ||
LL | | intrinsics::assert_uninit_valid::<bool>(); | ||
| | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ aborted execution: attempted to leave type `bool` uninitialized, which is invalid | ||
LL | | }; | ||
| |______- | ||
| | ||
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! | ||
= note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800> | ||
|
||
error: any use of this value will cause an error | ||
--> $DIR/assert-type-intrinsics.rs:20:9 | ||
| | ||
LL | / const _BAD3: () = unsafe { | ||
LL | | intrinsics::assert_zero_valid::<&'static i32>(); | ||
| | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ aborted execution: attempted to zero-initialize type `&i32`, which is invalid | ||
LL | | }; | ||
| |______- | ||
| | ||
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! | ||
= note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800> | ||
|
||
error: aborting due to 3 previous errors | ||
|
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.