Skip to content

Commit 382d724

Browse files
committed
move test to intergrated test in library/core
1 parent 4387480 commit 382d724

File tree

3 files changed

+17
-17
lines changed

3 files changed

+17
-17
lines changed

library/core/tests/intrinsics.rs

+15
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
use core::any::TypeId;
2+
use core::intrinsics::assume;
23

34
#[test]
45
fn test_typeid_sized_types() {
@@ -20,3 +21,17 @@ fn test_typeid_unsized_types() {
2021
assert_eq!(TypeId::of::<Y>(), TypeId::of::<Y>());
2122
assert!(TypeId::of::<X>() != TypeId::of::<Y>());
2223
}
24+
25+
// Check that `const_assume` feature allow `assume` intrinsic
26+
// to be used in const contexts.
27+
#[test]
28+
fn test_assume_can_be_in_const_contexts() {
29+
const unsafe fn foo(x: usize, y: usize) -> usize {
30+
// SAFETY: the entire function is not safe,
31+
// but it is just an example not used elsewhere.
32+
unsafe { assume(y != 0) };
33+
x / y
34+
}
35+
let rs = unsafe { foo(42, 97) };
36+
assert_eq!(rs, 0);
37+
}

library/core/tests/lib.rs

+2
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
#![feature(bound_cloned)]
88
#![feature(box_syntax)]
99
#![feature(cell_update)]
10+
#![feature(const_assume)]
11+
#![feature(core_intrinsics)]
1012
#![feature(core_private_bignum)]
1113
#![feature(core_private_diy_float)]
1214
#![feature(debug_non_exhaustive)]

src/test/ui/consts/const-eval/const_assume.rs

-17
This file was deleted.

0 commit comments

Comments
 (0)