]> git.lizzy.rs Git - rust.git/commitdiff
remove unused mut, restructure the test
authorDodo <kasper199914@gmail.com>
Mon, 2 Mar 2020 22:43:50 +0000 (23:43 +0100)
committerDodo <kasper199914@gmail.com>
Mon, 2 Mar 2020 22:43:50 +0000 (23:43 +0100)
src/libcore/tests/mem.rs

index 9ed2323e2873e60394fdd76f1f99e68d3dff8120..8337ab103419f82d6406359fbd0a542760b45818 100644 (file)
@@ -132,18 +132,18 @@ fn is_send_sync<T: Send + Sync>() {}
 
 #[test]
 fn test_const_forget() {
-    const fn test_const_forget<T>(x: T) {
-        forget(x);
-    }
+    const _: () = forget(0i32);
+    const _: () = forget(Vec::<Vec<Box<i32>>>::new());
 
     // Writing this function signature without const-forget
     // triggers compiler errors:
     // 1) That we use a non-const fn inside a const fn
     // 2) without the forget, it complains about the destructor of Box
-    const fn const_forget_box<T>(mut x: Box<T>) {
+    const fn const_forget_box<T>(x: Box<T>) {
         forget(x);
     }
 
-    const _: () = test_const_forget(0i32);
-    const _: () = test_const_forget(Vec::<Vec<Box<i32>>>::new());
+    // Call the forget_box at runtime,
+    // as we can't const-construct a box yet.
+    const_forget_box(Box::new(0i32));
 }