Skip to content

Commit 70c828b

Browse files
committed
test some more extreme cast cases
1 parent fbf47d1 commit 70c828b

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#![feature(intrinsics)]
2+
3+
// Directly call intrinsic to avoid debug assertions in libstd
4+
extern "rust-intrinsic" {
5+
fn float_to_int_unchecked<Float: Copy, Int: Copy>(value: Float) -> Int;
6+
}
7+
8+
fn main() {
9+
unsafe { float_to_int_unchecked::<f64, u128>(f64::MAX); } //~ ERROR: cannot be represented in target type `u128`
10+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#![feature(intrinsics)]
2+
3+
// Directly call intrinsic to avoid debug assertions in libstd
4+
extern "rust-intrinsic" {
5+
fn float_to_int_unchecked<Float: Copy, Int: Copy>(value: Float) -> Int;
6+
}
7+
8+
fn main() {
9+
unsafe { float_to_int_unchecked::<f64, i128>(f64::MIN); } //~ ERROR: cannot be represented in target type `i128`
10+
}

0 commit comments

Comments
 (0)