move test to intergrated test in library/core

This commit is contained in:
Lzu Tao 2020-09-24 14:41:40 +00:00
parent 4387480dea
commit 382d7243a7
3 changed files with 17 additions and 17 deletions

View File

@ -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);
}

View File

@ -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)]

View File

@ -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() {}