mirror of
https://github.com/rust-lang/rust.git
synced 2025-04-13 12:36:47 +00:00
move test to intergrated test in library/core
This commit is contained in:
parent
4387480dea
commit
382d7243a7
@ -1,4 +1,5 @@
|
||||
use core::any::TypeId;
|
||||
use core::intrinsics::assume;
|
||||
|
||||
#[test]
|
||||
fn test_typeid_sized_types() {
|
||||
@ -20,3 +21,17 @@ fn test_typeid_unsized_types() {
|
||||
assert_eq!(TypeId::of::<Y>(), TypeId::of::<Y>());
|
||||
assert!(TypeId::of::<X>() != TypeId::of::<Y>());
|
||||
}
|
||||
|
||||
// Check that `const_assume` feature allow `assume` intrinsic
|
||||
// to be used in const contexts.
|
||||
#[test]
|
||||
fn test_assume_can_be_in_const_contexts() {
|
||||
const unsafe fn foo(x: usize, y: usize) -> usize {
|
||||
// SAFETY: the entire function is not safe,
|
||||
// but it is just an example not used elsewhere.
|
||||
unsafe { assume(y != 0) };
|
||||
x / y
|
||||
}
|
||||
let rs = unsafe { foo(42, 97) };
|
||||
assert_eq!(rs, 0);
|
||||
}
|
||||
|
@ -7,6 +7,8 @@
|
||||
#![feature(bound_cloned)]
|
||||
#![feature(box_syntax)]
|
||||
#![feature(cell_update)]
|
||||
#![feature(const_assume)]
|
||||
#![feature(core_intrinsics)]
|
||||
#![feature(core_private_bignum)]
|
||||
#![feature(core_private_diy_float)]
|
||||
#![feature(debug_non_exhaustive)]
|
||||
|
@ -1,17 +0,0 @@
|
||||
// check-pass
|
||||
|
||||
// Check that `const_assume` feature allow `assume` intrinsic
|
||||
// to be used in const contexts.
|
||||
|
||||
#![feature(core_intrinsics, const_assume)]
|
||||
|
||||
extern crate core;
|
||||
|
||||
use core::intrinsics::assume;
|
||||
|
||||
pub const unsafe fn foo(x: usize, y: usize) -> usize {
|
||||
assume(y != 0);
|
||||
x / y
|
||||
}
|
||||
|
||||
fn main() {}
|
Loading…
Reference in New Issue
Block a user