about summary refs log tree commit diff
diff options
context:
space:
mode:
authorPhilipp Hansch <dev@phansch.net>2018-10-04 22:26:54 +0200
committerPhilipp Hansch <dev@phansch.net>2018-10-04 22:26:54 +0200
commit8b3d2073fa8b1f48a27081944c1a7010a8d7b7b1 (patch)
treeb5b819b5b048366f144e4e791046b531a56b708d
parent391d53db6657be45fb85835c3e042e2287035ece (diff)
downloadrust-8b3d2073fa8b1f48a27081944c1a7010a8d7b7b1.tar.gz
rust-8b3d2073fa8b1f48a27081944c1a7010a8d7b7b1.zip
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.
-rw-r--r--tests/ui/fn_to_numeric_cast_with_truncation.rs8
-rw-r--r--tests/ui/fn_to_numeric_cast_with_truncation.stderr32
2 files changed, 21 insertions, 19 deletions
diff --git a/tests/ui/fn_to_numeric_cast_with_truncation.rs b/tests/ui/fn_to_numeric_cast_with_truncation.rs
index 82bbaec201f..4ebde4e8c1d 100644
--- a/tests/ui/fn_to_numeric_cast_with_truncation.rs
+++ b/tests/ui/fn_to_numeric_cast_with_truncation.rs
@@ -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() {}
diff --git a/tests/ui/fn_to_numeric_cast_with_truncation.stderr b/tests/ui/fn_to_numeric_cast_with_truncation.stderr
index cae4b6fbd40..65c996814ca 100644
--- a/tests/ui/fn_to_numeric_cast_with_truncation.stderr
+++ b/tests/ui/fn_to_numeric_cast_with_truncation.stderr
@@ -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`
+  --> $DIR/fn_to_numeric_cast_with_truncation.rs:10:13
+   |
+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:10:13
+  --> $DIR/fn_to_numeric_cast_with_truncation.rs:11:13
    |
-10 |     let _ = foo as i16;
+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