Only run tests if pointer width is 64bit

If the pointer width of the architechture is 32bit or something else,
then the tests will most likely produce different results.
This commit is contained in:
Philipp Hansch 2018-10-04 22:26:54 +02:00
parent 391d53db66
commit 8b3d2073fa
No known key found for this signature in database
GPG key ID: B6FA06A6E0E2665B
2 changed files with 22 additions and 20 deletions

View file

@ -1,3 +1,4 @@
// only-64bit
#![feature(tool_lints)]
#![warn(clippy::fn_to_numeric_cast_with_truncation)]
@ -13,11 +14,12 @@ fn test_fn_to_numeric_cast_with_truncation() {
let _ = foo as u16;
let _ = foo as u32;
// TODO: Is it bad to have these tests?
// Running the tests on a different architechture will
// produce different results
// These should not lint, because because casting to these types
// does not truncate the function pointer address.
let _ = foo as u64;
let _ = foo as i64;
let _ = foo as u128;
let _ = foo as i128;
}
fn main() {}

View file

@ -1,39 +1,39 @@
error: casting function pointer `foo` to `i8`, which truncates the value
--> $DIR/fn_to_numeric_cast_with_truncation.rs:9:13
|
9 | let _ = foo as i8;
| ^^^^^^^^^ help: try: `foo as usize`
|
= note: `-D clippy::fn-to-numeric-cast-with-truncation` implied by `-D warnings`
error: casting function pointer `foo` to `i16`, which truncates the value
--> $DIR/fn_to_numeric_cast_with_truncation.rs:10:13
|
10 | let _ = foo as i16;
10 | let _ = foo as i8;
| ^^^^^^^^^ help: try: `foo as usize`
|
= note: `-D clippy::fn-to-numeric-cast-with-truncation` implied by `-D warnings`
error: casting function pointer `foo` to `i16`, which truncates the value
--> $DIR/fn_to_numeric_cast_with_truncation.rs:11:13
|
11 | let _ = foo as i16;
| ^^^^^^^^^^ help: try: `foo as usize`
error: casting function pointer `foo` to `i32`, which truncates the value
--> $DIR/fn_to_numeric_cast_with_truncation.rs:11:13
--> $DIR/fn_to_numeric_cast_with_truncation.rs:12:13
|
11 | let _ = foo as i32;
12 | let _ = foo as i32;
| ^^^^^^^^^^ help: try: `foo as usize`
error: casting function pointer `foo` to `u8`, which truncates the value
--> $DIR/fn_to_numeric_cast_with_truncation.rs:12:13
--> $DIR/fn_to_numeric_cast_with_truncation.rs:13:13
|
12 | let _ = foo as u8;
13 | let _ = foo as u8;
| ^^^^^^^^^ help: try: `foo as usize`
error: casting function pointer `foo` to `u16`, which truncates the value
--> $DIR/fn_to_numeric_cast_with_truncation.rs:13:13
--> $DIR/fn_to_numeric_cast_with_truncation.rs:14:13
|
13 | let _ = foo as u16;
14 | let _ = foo as u16;
| ^^^^^^^^^^ help: try: `foo as usize`
error: casting function pointer `foo` to `u32`, which truncates the value
--> $DIR/fn_to_numeric_cast_with_truncation.rs:14:13
--> $DIR/fn_to_numeric_cast_with_truncation.rs:15:13
|
14 | let _ = foo as u32;
15 | let _ = foo as u32;
| ^^^^^^^^^^ help: try: `foo as usize`
error: aborting due to 6 previous errors