From 382d7243a70f7b9fd9330334a12f76985067ef06 Mon Sep 17 00:00:00 2001
From: Lzu Tao <taolzu@gmail.com>
Date: Thu, 24 Sep 2020 14:41:40 +0000
Subject: [PATCH] move test to intergrated test in library/core

---
 library/core/tests/intrinsics.rs              | 15 +++++++++++++++
 library/core/tests/lib.rs                     |  2 ++
 src/test/ui/consts/const-eval/const_assume.rs | 17 -----------------
 3 files changed, 17 insertions(+), 17 deletions(-)
 delete mode 100644 src/test/ui/consts/const-eval/const_assume.rs

diff --git a/library/core/tests/intrinsics.rs b/library/core/tests/intrinsics.rs
index fed7c4a5bf3..de163a60c98 100644
--- a/library/core/tests/intrinsics.rs
+++ b/library/core/tests/intrinsics.rs
@@ -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);
+}
diff --git a/library/core/tests/lib.rs b/library/core/tests/lib.rs
index 4db391f3e56..3a6caaa19fc 100644
--- a/library/core/tests/lib.rs
+++ b/library/core/tests/lib.rs
@@ -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)]
diff --git a/src/test/ui/consts/const-eval/const_assume.rs b/src/test/ui/consts/const-eval/const_assume.rs
deleted file mode 100644
index f72f151824b..00000000000
--- a/src/test/ui/consts/const-eval/const_assume.rs
+++ /dev/null
@@ -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() {}