Skip to content

Commit

Permalink
Fix 32bit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
flip1995 committed Sep 7, 2023
1 parent 25e8639 commit 184c971
Show file tree
Hide file tree
Showing 6 changed files with 332 additions and 45 deletions.
3 changes: 3 additions & 0 deletions tests/ui/cast_size.32bit.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ LL | 1isize as i8;
|
= help: if this is intentional allow the lint with `#[allow(clippy::cast_possible_truncation)]` ...
= note: `-D clippy::cast-possible-truncation` implied by `-D warnings`
= help: to override `-D warnings` add `#[allow(clippy::cast_possible_truncation)]`
help: ... or use `try_from` and handle the error accordingly
|
LL | i8::try_from(1isize);
Expand All @@ -18,6 +19,7 @@ LL | x0 as f64;
| ^^^^^^^^^
|
= note: `-D clippy::cast-precision-loss` implied by `-D warnings`
= help: to override `-D warnings` add `#[allow(clippy::cast_precision_loss)]`

error: casting `usize` to `f64` causes a loss of precision on targets with 64-bit wide pointers (`usize` is 64 bits wide, but `f64`'s mantissa is only 52 bits wide)
--> $DIR/cast_size.rs:19:5
Expand Down Expand Up @@ -92,6 +94,7 @@ LL | 1usize as i32;
| ^^^^^^^^^^^^^
|
= note: `-D clippy::cast-possible-wrap` implied by `-D warnings`
= help: to override `-D warnings` add `#[allow(clippy::cast_possible_wrap)]`

error: casting `i64` to `isize` may truncate the value on targets with 32-bit wide pointers
--> $DIR/cast_size.rs:26:5
Expand Down
48 changes: 25 additions & 23 deletions tests/ui/fn_to_numeric_cast.32bit.stderr
Original file line number Diff line number Diff line change
@@ -1,141 +1,143 @@
error: casting function pointer `foo` to `i8`, which truncates the value
--> $DIR/fn_to_numeric_cast.rs:11:13
--> $DIR/fn_to_numeric_cast.rs:10:13
|
LL | let _ = foo as i8;
| ^^^^^^^^^ help: try: `foo as usize`
|
= note: `-D clippy::fn-to-numeric-cast-with-truncation` implied by `-D warnings`
= help: to override `-D warnings` add `#[allow(clippy::fn_to_numeric_cast_with_truncation)]`

error: casting function pointer `foo` to `i16`, which truncates the value
--> $DIR/fn_to_numeric_cast.rs:12:13
--> $DIR/fn_to_numeric_cast.rs:11:13
|
LL | let _ = foo as i16;
| ^^^^^^^^^^ help: try: `foo as usize`

error: casting function pointer `foo` to `i32`
--> $DIR/fn_to_numeric_cast.rs:13:13
--> $DIR/fn_to_numeric_cast.rs:12:13
|
LL | let _ = foo as i32;
| ^^^^^^^^^^ help: try: `foo as usize`
|
= note: `-D clippy::fn-to-numeric-cast` implied by `-D warnings`
= help: to override `-D warnings` add `#[allow(clippy::fn_to_numeric_cast)]`

error: casting function pointer `foo` to `i64`
--> $DIR/fn_to_numeric_cast.rs:14:13
--> $DIR/fn_to_numeric_cast.rs:13:13
|
LL | let _ = foo as i64;
| ^^^^^^^^^^ help: try: `foo as usize`

error: casting function pointer `foo` to `i128`
--> $DIR/fn_to_numeric_cast.rs:15:13
--> $DIR/fn_to_numeric_cast.rs:14:13
|
LL | let _ = foo as i128;
| ^^^^^^^^^^^ help: try: `foo as usize`

error: casting function pointer `foo` to `isize`
--> $DIR/fn_to_numeric_cast.rs:16:13
--> $DIR/fn_to_numeric_cast.rs:15:13
|
LL | let _ = foo as isize;
| ^^^^^^^^^^^^ help: try: `foo as usize`

error: casting function pointer `foo` to `u8`, which truncates the value
--> $DIR/fn_to_numeric_cast.rs:18:13
--> $DIR/fn_to_numeric_cast.rs:17:13
|
LL | 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.rs:19:13
--> $DIR/fn_to_numeric_cast.rs:18:13
|
LL | let _ = foo as u16;
| ^^^^^^^^^^ help: try: `foo as usize`

error: casting function pointer `foo` to `u32`
--> $DIR/fn_to_numeric_cast.rs:20:13
--> $DIR/fn_to_numeric_cast.rs:19:13
|
LL | let _ = foo as u32;
| ^^^^^^^^^^ help: try: `foo as usize`

error: casting function pointer `foo` to `u64`
--> $DIR/fn_to_numeric_cast.rs:21:13
--> $DIR/fn_to_numeric_cast.rs:20:13
|
LL | let _ = foo as u64;
| ^^^^^^^^^^ help: try: `foo as usize`

error: casting function pointer `foo` to `u128`
--> $DIR/fn_to_numeric_cast.rs:22:13
--> $DIR/fn_to_numeric_cast.rs:21:13
|
LL | let _ = foo as u128;
| ^^^^^^^^^^^ help: try: `foo as usize`

error: casting function pointer `abc` to `i8`, which truncates the value
--> $DIR/fn_to_numeric_cast.rs:35:13
--> $DIR/fn_to_numeric_cast.rs:34:13
|
LL | let _ = abc as i8;
| ^^^^^^^^^ help: try: `abc as usize`

error: casting function pointer `abc` to `i16`, which truncates the value
--> $DIR/fn_to_numeric_cast.rs:36:13
--> $DIR/fn_to_numeric_cast.rs:35:13
|
LL | let _ = abc as i16;
| ^^^^^^^^^^ help: try: `abc as usize`

error: casting function pointer `abc` to `i32`
--> $DIR/fn_to_numeric_cast.rs:37:13
--> $DIR/fn_to_numeric_cast.rs:36:13
|
LL | let _ = abc as i32;
| ^^^^^^^^^^ help: try: `abc as usize`

error: casting function pointer `abc` to `i64`
--> $DIR/fn_to_numeric_cast.rs:38:13
--> $DIR/fn_to_numeric_cast.rs:37:13
|
LL | let _ = abc as i64;
| ^^^^^^^^^^ help: try: `abc as usize`

error: casting function pointer `abc` to `i128`
--> $DIR/fn_to_numeric_cast.rs:39:13
--> $DIR/fn_to_numeric_cast.rs:38:13
|
LL | let _ = abc as i128;
| ^^^^^^^^^^^ help: try: `abc as usize`

error: casting function pointer `abc` to `isize`
--> $DIR/fn_to_numeric_cast.rs:40:13
--> $DIR/fn_to_numeric_cast.rs:39:13
|
LL | let _ = abc as isize;
| ^^^^^^^^^^^^ help: try: `abc as usize`

error: casting function pointer `abc` to `u8`, which truncates the value
--> $DIR/fn_to_numeric_cast.rs:42:13
--> $DIR/fn_to_numeric_cast.rs:41:13
|
LL | let _ = abc as u8;
| ^^^^^^^^^ help: try: `abc as usize`

error: casting function pointer `abc` to `u16`, which truncates the value
--> $DIR/fn_to_numeric_cast.rs:43:13
--> $DIR/fn_to_numeric_cast.rs:42:13
|
LL | let _ = abc as u16;
| ^^^^^^^^^^ help: try: `abc as usize`

error: casting function pointer `abc` to `u32`
--> $DIR/fn_to_numeric_cast.rs:44:13
--> $DIR/fn_to_numeric_cast.rs:43:13
|
LL | let _ = abc as u32;
| ^^^^^^^^^^ help: try: `abc as usize`

error: casting function pointer `abc` to `u64`
--> $DIR/fn_to_numeric_cast.rs:45:13
--> $DIR/fn_to_numeric_cast.rs:44:13
|
LL | let _ = abc as u64;
| ^^^^^^^^^^ help: try: `abc as usize`

error: casting function pointer `abc` to `u128`
--> $DIR/fn_to_numeric_cast.rs:46:13
--> $DIR/fn_to_numeric_cast.rs:45:13
|
LL | let _ = abc as u128;
| ^^^^^^^^^^^ help: try: `abc as usize`

error: casting function pointer `f` to `i32`
--> $DIR/fn_to_numeric_cast.rs:53:5
--> $DIR/fn_to_numeric_cast.rs:52:5
|
LL | f as i32
| ^^^^^^^^ help: try: `f as usize`
Expand Down
Loading

0 comments on commit 184c971

Please sign in to comment.