]> git.lizzy.rs Git - rust.git/commitdiff
Correct the test.
authorChase Albert <thaoeuns@gmail.com>
Tue, 5 May 2020 03:22:00 +0000 (23:22 -0400)
committerChase Albert <thaoeuns@gmail.com>
Tue, 5 May 2020 03:22:00 +0000 (23:22 -0400)
tests/compile-fail/check_arg_count.rs [deleted file]
tests/compile-fail/check_arg_count_too_few_args.rs [new file with mode: 0644]
tests/compile-fail/check_arg_count_too_many_args.rs [new file with mode: 0644]

diff --git a/tests/compile-fail/check_arg_count.rs b/tests/compile-fail/check_arg_count.rs
deleted file mode 100644 (file)
index 0cc6dcb..0000000
+++ /dev/null
@@ -1,8 +0,0 @@
-#![feature(core_intrinsics)]
-
-use std::intrinsics;
-
-fn main() {
-    unsafe { intrinsics::forget(); } //~ ERROR this function takes 1 argument but 0 arguments were supplied
-    unsafe { intrinsics::forget(1, 2); } //~ ERROR this function takes 1 argument but 2 arguments were supplied
-}
diff --git a/tests/compile-fail/check_arg_count_too_few_args.rs b/tests/compile-fail/check_arg_count_too_few_args.rs
new file mode 100644 (file)
index 0000000..c6c19e0
--- /dev/null
@@ -0,0 +1,12 @@
+#![feature(core_intrinsics)]
+#![feature(rustc_private)]
+
+fn main() {
+    extern "C" {
+        fn malloc() -> *mut std::ffi::c_void;
+    }
+
+    unsafe {
+        let _ = malloc(); //~ ERROR Undefined Behavior: incorrect number of arguments: got 0, expected 1
+    };
+}
diff --git a/tests/compile-fail/check_arg_count_too_many_args.rs b/tests/compile-fail/check_arg_count_too_many_args.rs
new file mode 100644 (file)
index 0000000..cca03e5
--- /dev/null
@@ -0,0 +1,12 @@
+#![feature(core_intrinsics)]
+#![feature(rustc_private)]
+
+fn main() {
+    extern "C" {
+        fn malloc(_: i32, _: i32) -> *mut std::ffi::c_void;
+    }
+
+    unsafe {
+        let _ = malloc(1, 2); //~ ERROR Undefined Behavior: incorrect number of arguments: got 2, expected 1
+    };
+}