Skip to content

Commit

Permalink
move test to intergrated test in library/core
Browse files Browse the repository at this point in the history
  • Loading branch information
tesuji committed Sep 24, 2020
1 parent 4387480 commit 382d724
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 17 deletions.
15 changes: 15 additions & 0 deletions library/core/tests/intrinsics.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use core::any::TypeId;
use core::intrinsics::assume;

#[test]
fn test_typeid_sized_types() {
Expand All @@ -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);
}
2 changes: 2 additions & 0 deletions library/core/tests/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
Expand Down
17 changes: 0 additions & 17 deletions src/test/ui/consts/const-eval/const_assume.rs

This file was deleted.

0 comments on commit 382d724

Please sign in to comment.