add ui tests for unchecked math

This commit is contained in:
lcnr/Bastian Kauschke 2019-06-03 21:30:25 +02:00
parent 8a25fdb409
commit d7e0834c5f
4 changed files with 70 additions and 0 deletions

View File

@ -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
}

View File

@ -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`.

View File

@ -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
}
}

View File

@ -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`.