mirror of
https://github.com/rust-lang/rust.git
synced 2024-10-30 22:12:15 +00:00
add ui tests for unchecked math
This commit is contained in:
parent
8a25fdb409
commit
d7e0834c5f
8
src/test/ui/intrinsics/unchecked_math_unsafe.rs
Normal file
8
src/test/ui/intrinsics/unchecked_math_unsafe.rs
Normal 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
|
||||
}
|
27
src/test/ui/intrinsics/unchecked_math_unsafe.stderr
Normal file
27
src/test/ui/intrinsics/unchecked_math_unsafe.stderr
Normal 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`.
|
8
src/test/ui/intrinsics/unchecked_math_unstable.rs
Normal file
8
src/test/ui/intrinsics/unchecked_math_unstable.rs
Normal 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
|
||||
}
|
||||
}
|
27
src/test/ui/intrinsics/unchecked_math_unstable.stderr
Normal file
27
src/test/ui/intrinsics/unchecked_math_unstable.stderr
Normal 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`.
|
Loading…
Reference in New Issue
Block a user