Skip to content

Commit d7e0834

Browse files
committed
add ui tests for unchecked math
1 parent 8a25fdb commit d7e0834

4 files changed

+70
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#![feature(core_intrinsics)]
2+
3+
fn main() {
4+
let (x, y) = (1u32, 2u32);
5+
let add = std::intrinsics::unchecked_add(x, y); //~ ERROR call to unsafe function
6+
let sub = std::intrinsics::unchecked_sub(x, y); //~ ERROR call to unsafe function
7+
let mul = std::intrinsics::unchecked_mul(x, y); //~ ERROR call to unsafe function
8+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
error[E0133]: call to unsafe function is unsafe and requires unsafe function or block
2+
--> $DIR/unchecked_math_unsafe.rs:5:15
3+
|
4+
LL | let add = std::intrinsics::unchecked_add(x, y);
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ call to unsafe function
6+
|
7+
= note: consult the function's documentation for information on how to avoid undefined behavior
8+
9+
error[E0133]: call to unsafe function is unsafe and requires unsafe function or block
10+
--> $DIR/unchecked_math_unsafe.rs:6:15
11+
|
12+
LL | let sub = std::intrinsics::unchecked_sub(x, y);
13+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ call to unsafe function
14+
|
15+
= note: consult the function's documentation for information on how to avoid undefined behavior
16+
17+
error[E0133]: call to unsafe function is unsafe and requires unsafe function or block
18+
--> $DIR/unchecked_math_unsafe.rs:7:15
19+
|
20+
LL | let mul = std::intrinsics::unchecked_mul(x, y);
21+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ call to unsafe function
22+
|
23+
= note: consult the function's documentation for information on how to avoid undefined behavior
24+
25+
error: aborting due to 3 previous errors
26+
27+
For more information about this error, try `rustc --explain E0133`.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
fn main() {
2+
let (x, y) = (1u32, 2u32);
3+
unsafe {
4+
let add = std::intrinsics::unchecked_add(x, y); //~ ERROR use of unstable library feature
5+
let sub = std::intrinsics::unchecked_sub(x, y); //~ ERROR use of unstable library feature
6+
let mul = std::intrinsics::unchecked_mul(x, y); //~ ERROR use of unstable library feature
7+
}
8+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
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
2+
--> $DIR/unchecked_math_unstable.rs:4:19
3+
|
4+
LL | let add = std::intrinsics::unchecked_add(x, y);
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
6+
|
7+
= help: add #![feature(core_intrinsics)] to the crate attributes to enable
8+
9+
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
10+
--> $DIR/unchecked_math_unstable.rs:5:19
11+
|
12+
LL | let sub = std::intrinsics::unchecked_sub(x, y);
13+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
14+
|
15+
= help: add #![feature(core_intrinsics)] to the crate attributes to enable
16+
17+
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
18+
--> $DIR/unchecked_math_unstable.rs:6:19
19+
|
20+
LL | let mul = std::intrinsics::unchecked_mul(x, y);
21+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
22+
|
23+
= help: add #![feature(core_intrinsics)] to the crate attributes to enable
24+
25+
error: aborting due to 3 previous errors
26+
27+
For more information about this error, try `rustc --explain E0658`.

0 commit comments

Comments
 (0)