about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--src/test/ui/intrinsics/unchecked_math_unsafe.rs8
-rw-r--r--src/test/ui/intrinsics/unchecked_math_unsafe.stderr27
-rw-r--r--src/test/ui/intrinsics/unchecked_math_unstable.rs8
-rw-r--r--src/test/ui/intrinsics/unchecked_math_unstable.stderr27
4 files changed, 70 insertions, 0 deletions
diff --git a/src/test/ui/intrinsics/unchecked_math_unsafe.rs b/src/test/ui/intrinsics/unchecked_math_unsafe.rs
new file mode 100644
index 00000000000..a034b45f530
--- /dev/null
+++ b/src/test/ui/intrinsics/unchecked_math_unsafe.rs
@@ -0,0 +1,8 @@
+#![feature(core_intrinsics)]
+
+fn main() {
+    let (x, y) = (1u32, 2u32);
+    let add = std::intrinsics::unchecked_add(x, y); //~ ERROR call to unsafe function
+    let sub = std::intrinsics::unchecked_sub(x, y); //~ ERROR call to unsafe function
+    let mul = std::intrinsics::unchecked_mul(x, y); //~ ERROR call to unsafe function
+}
diff --git a/src/test/ui/intrinsics/unchecked_math_unsafe.stderr b/src/test/ui/intrinsics/unchecked_math_unsafe.stderr
new file mode 100644
index 00000000000..4066cf8efb8
--- /dev/null
+++ b/src/test/ui/intrinsics/unchecked_math_unsafe.stderr
@@ -0,0 +1,27 @@
+error[E0133]: call to unsafe function is unsafe and requires unsafe function or block
+  --> $DIR/unchecked_math_unsafe.rs:5:15
+   |
+LL |     let add = std::intrinsics::unchecked_add(x, y);
+   |               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ call to unsafe function
+   |
+   = note: consult the function's documentation for information on how to avoid undefined behavior
+
+error[E0133]: call to unsafe function is unsafe and requires unsafe function or block
+  --> $DIR/unchecked_math_unsafe.rs:6:15
+   |
+LL |     let sub = std::intrinsics::unchecked_sub(x, y);
+   |               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ call to unsafe function
+   |
+   = note: consult the function's documentation for information on how to avoid undefined behavior
+
+error[E0133]: call to unsafe function is unsafe and requires unsafe function or block
+  --> $DIR/unchecked_math_unsafe.rs:7:15
+   |
+LL |     let mul = std::intrinsics::unchecked_mul(x, y);
+   |               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ call to unsafe function
+   |
+   = note: consult the function's documentation for information on how to avoid undefined behavior
+
+error: aborting due to 3 previous errors
+
+For more information about this error, try `rustc --explain E0133`.
diff --git a/src/test/ui/intrinsics/unchecked_math_unstable.rs b/src/test/ui/intrinsics/unchecked_math_unstable.rs
new file mode 100644
index 00000000000..8869063d1cc
--- /dev/null
+++ b/src/test/ui/intrinsics/unchecked_math_unstable.rs
@@ -0,0 +1,8 @@
+fn main() {
+    let (x, y) = (1u32, 2u32);
+    unsafe {
+        let add = std::intrinsics::unchecked_add(x, y); //~ ERROR use of unstable library feature
+        let sub = std::intrinsics::unchecked_sub(x, y); //~ ERROR use of unstable library feature
+        let mul = std::intrinsics::unchecked_mul(x, y); //~ ERROR use of unstable library feature
+    }
+}
diff --git a/src/test/ui/intrinsics/unchecked_math_unstable.stderr b/src/test/ui/intrinsics/unchecked_math_unstable.stderr
new file mode 100644
index 00000000000..6f5429127c6
--- /dev/null
+++ b/src/test/ui/intrinsics/unchecked_math_unstable.stderr
@@ -0,0 +1,27 @@
+error[E0658]: use of unstable library feature 'core_intrinsics': intrinsics are unlikely to ever be stabilized, instead they should be used through stabilized interfaces in the rest of the standard library
+  --> $DIR/unchecked_math_unstable.rs:4:19
+   |
+LL |         let add = std::intrinsics::unchecked_add(x, y);
+   |                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+   |
+   = help: add #![feature(core_intrinsics)] to the crate attributes to enable
+
+error[E0658]: use of unstable library feature 'core_intrinsics': intrinsics are unlikely to ever be stabilized, instead they should be used through stabilized interfaces in the rest of the standard library
+  --> $DIR/unchecked_math_unstable.rs:5:19
+   |
+LL |         let sub = std::intrinsics::unchecked_sub(x, y);
+   |                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+   |
+   = help: add #![feature(core_intrinsics)] to the crate attributes to enable
+
+error[E0658]: use of unstable library feature 'core_intrinsics': intrinsics are unlikely to ever be stabilized, instead they should be used through stabilized interfaces in the rest of the standard library
+  --> $DIR/unchecked_math_unstable.rs:6:19
+   |
+LL |         let mul = std::intrinsics::unchecked_mul(x, y);
+   |                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+   |
+   = help: add #![feature(core_intrinsics)] to the crate attributes to enable
+
+error: aborting due to 3 previous errors
+
+For more information about this error, try `rustc --explain E0658`.