mirror of
https://github.com/rust-lang/rust-clippy
synced 2024-11-10 15:14:29 +00:00
Fix i686-unknown-linux-gnu CI job
This commit is contained in:
parent
eb0df1d4f4
commit
60ffff08e6
17 changed files with 174 additions and 618 deletions
33
.github/workflows/clippy_bors.yml
vendored
33
.github/workflows/clippy_bors.yml
vendored
|
@ -52,24 +52,14 @@ jobs:
|
|||
needs: changelog
|
||||
strategy:
|
||||
matrix:
|
||||
os: [ubuntu-latest, windows-latest, macos-latest]
|
||||
host: [x86_64-unknown-linux-gnu, i686-unknown-linux-gnu, x86_64-apple-darwin, x86_64-pc-windows-msvc]
|
||||
exclude:
|
||||
include:
|
||||
- os: ubuntu-latest
|
||||
host: x86_64-apple-darwin
|
||||
host: x86_64-unknown-linux-gnu
|
||||
- os: ubuntu-latest
|
||||
host: x86_64-pc-windows-msvc
|
||||
- os: macos-latest
|
||||
host: x86_64-unknown-linux-gnu
|
||||
- os: macos-latest
|
||||
host: i686-unknown-linux-gnu
|
||||
- os: macos-latest
|
||||
host: x86_64-pc-windows-msvc
|
||||
- os: windows-latest
|
||||
host: x86_64-unknown-linux-gnu
|
||||
- os: windows-latest
|
||||
host: i686-unknown-linux-gnu
|
||||
- os: windows-latest
|
||||
host: x86_64-pc-windows-msvc
|
||||
- os: macos-latest
|
||||
host: x86_64-apple-darwin
|
||||
|
||||
runs-on: ${{ matrix.os }}
|
||||
|
@ -84,8 +74,17 @@ jobs:
|
|||
- name: Checkout
|
||||
uses: actions/checkout@v3
|
||||
|
||||
- name: Install i686 dependencies
|
||||
if: matrix.host == 'i686-unknown-linux-gnu'
|
||||
run: |
|
||||
sudo dpkg --add-architecture i386
|
||||
sudo apt-get update
|
||||
sudo apt-get install gcc-multilib zlib1g-dev:i386
|
||||
|
||||
- name: Install toolchain
|
||||
run: rustup show active-toolchain
|
||||
run: |
|
||||
rustup set default-host ${{ matrix.host }}
|
||||
rustup show active-toolchain
|
||||
|
||||
# Run
|
||||
- name: Set LD_LIBRARY_PATH (Linux)
|
||||
|
@ -109,11 +108,11 @@ jobs:
|
|||
run: cargo build --tests --features deny-warnings,internal
|
||||
|
||||
- name: Test
|
||||
if: runner.os == 'Linux'
|
||||
if: matrix.host == 'x86_64-unknown-linux-gnu'
|
||||
run: cargo test --features deny-warnings,internal
|
||||
|
||||
- name: Test
|
||||
if: runner.os != 'Linux'
|
||||
if: matrix.host != 'x86_64-unknown-linux-gnu'
|
||||
run: cargo test --features deny-warnings,internal -- --skip dogfood
|
||||
|
||||
- name: Test clippy_lints
|
||||
|
|
|
@ -289,9 +289,16 @@ fn run_ui_cargo() {
|
|||
|
||||
let quiet = args.quiet;
|
||||
|
||||
let ignored_32bit = |path: &Path| {
|
||||
// FIXME: for some reason the modules are linted in a different order for this test
|
||||
cfg!(target_pointer_width = "32") && path.ends_with("tests/ui-cargo/module_style/fail_mod/Cargo.toml")
|
||||
};
|
||||
|
||||
ui_test::run_tests_generic(
|
||||
vec![config],
|
||||
|path, config| path.ends_with("Cargo.toml") && ui_test::default_any_file_filter(path, config),
|
||||
|path, config| {
|
||||
path.ends_with("Cargo.toml") && ui_test::default_any_file_filter(path, config) && !ignored_32bit(path)
|
||||
},
|
||||
|config, path, _file_contents| {
|
||||
config.out_dir = canonicalize(
|
||||
std::env::current_dir()
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
error: casting `isize` to `i8` may truncate the value
|
||||
--> $DIR/cast_size_32bit.rs:12:5
|
||||
--> $DIR/cast_size.rs:15:5
|
||||
|
|
||||
LL | 1isize as i8;
|
||||
| ^^^^^^^^^^^^
|
||||
|
@ -12,7 +12,7 @@ LL | i8::try_from(1isize);
|
|||
| ~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
error: casting `isize` to `f64` causes a loss of precision on targets with 64-bit wide pointers (`isize` is 64 bits wide, but `f64`'s mantissa is only 52 bits wide)
|
||||
--> $DIR/cast_size_32bit.rs:15:5
|
||||
--> $DIR/cast_size.rs:18:5
|
||||
|
|
||||
LL | x0 as f64;
|
||||
| ^^^^^^^^^
|
||||
|
@ -20,25 +20,25 @@ LL | x0 as f64;
|
|||
= note: `-D clippy::cast-precision-loss` implied by `-D warnings`
|
||||
|
||||
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_32bit.rs:16:5
|
||||
--> $DIR/cast_size.rs:19:5
|
||||
|
|
||||
LL | x1 as f64;
|
||||
| ^^^^^^^^^
|
||||
|
||||
error: casting `isize` to `f32` causes a loss of precision (`isize` is 32 or 64 bits wide, but `f32`'s mantissa is only 23 bits wide)
|
||||
--> $DIR/cast_size_32bit.rs:17:5
|
||||
--> $DIR/cast_size.rs:20:5
|
||||
|
|
||||
LL | x0 as f32;
|
||||
| ^^^^^^^^^
|
||||
|
||||
error: casting `usize` to `f32` causes a loss of precision (`usize` is 32 or 64 bits wide, but `f32`'s mantissa is only 23 bits wide)
|
||||
--> $DIR/cast_size_32bit.rs:18:5
|
||||
--> $DIR/cast_size.rs:21:5
|
||||
|
|
||||
LL | x1 as f32;
|
||||
| ^^^^^^^^^
|
||||
|
||||
error: casting `isize` to `i32` may truncate the value on targets with 64-bit wide pointers
|
||||
--> $DIR/cast_size_32bit.rs:19:5
|
||||
--> $DIR/cast_size.rs:22:5
|
||||
|
|
||||
LL | 1isize as i32;
|
||||
| ^^^^^^^^^^^^^
|
||||
|
@ -50,7 +50,7 @@ LL | i32::try_from(1isize);
|
|||
| ~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
error: casting `isize` to `u32` may truncate the value on targets with 64-bit wide pointers
|
||||
--> $DIR/cast_size_32bit.rs:20:5
|
||||
--> $DIR/cast_size.rs:23:5
|
||||
|
|
||||
LL | 1isize as u32;
|
||||
| ^^^^^^^^^^^^^
|
||||
|
@ -62,7 +62,7 @@ LL | u32::try_from(1isize);
|
|||
| ~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
error: casting `usize` to `u32` may truncate the value on targets with 64-bit wide pointers
|
||||
--> $DIR/cast_size_32bit.rs:21:5
|
||||
--> $DIR/cast_size.rs:24:5
|
||||
|
|
||||
LL | 1usize as u32;
|
||||
| ^^^^^^^^^^^^^
|
||||
|
@ -74,7 +74,7 @@ LL | u32::try_from(1usize);
|
|||
| ~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
error: casting `usize` to `i32` may truncate the value on targets with 64-bit wide pointers
|
||||
--> $DIR/cast_size_32bit.rs:22:5
|
||||
--> $DIR/cast_size.rs:25:5
|
||||
|
|
||||
LL | 1usize as i32;
|
||||
| ^^^^^^^^^^^^^
|
||||
|
@ -86,7 +86,7 @@ LL | i32::try_from(1usize);
|
|||
| ~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
error: casting `usize` to `i32` may wrap around the value on targets with 32-bit wide pointers
|
||||
--> $DIR/cast_size_32bit.rs:22:5
|
||||
--> $DIR/cast_size.rs:25:5
|
||||
|
|
||||
LL | 1usize as i32;
|
||||
| ^^^^^^^^^^^^^
|
||||
|
@ -94,7 +94,7 @@ LL | 1usize as i32;
|
|||
= note: `-D clippy::cast-possible-wrap` implied by `-D warnings`
|
||||
|
||||
error: casting `i64` to `isize` may truncate the value on targets with 32-bit wide pointers
|
||||
--> $DIR/cast_size_32bit.rs:24:5
|
||||
--> $DIR/cast_size.rs:26:5
|
||||
|
|
||||
LL | 1i64 as isize;
|
||||
| ^^^^^^^^^^^^^
|
||||
|
@ -106,7 +106,7 @@ LL | isize::try_from(1i64);
|
|||
| ~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
error: casting `i64` to `usize` may truncate the value on targets with 32-bit wide pointers
|
||||
--> $DIR/cast_size_32bit.rs:25:5
|
||||
--> $DIR/cast_size.rs:27:5
|
||||
|
|
||||
LL | 1i64 as usize;
|
||||
| ^^^^^^^^^^^^^
|
||||
|
@ -118,7 +118,7 @@ LL | usize::try_from(1i64);
|
|||
| ~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
error: casting `u64` to `isize` may truncate the value on targets with 32-bit wide pointers
|
||||
--> $DIR/cast_size_32bit.rs:26:5
|
||||
--> $DIR/cast_size.rs:28:5
|
||||
|
|
||||
LL | 1u64 as isize;
|
||||
| ^^^^^^^^^^^^^
|
||||
|
@ -130,13 +130,13 @@ LL | isize::try_from(1u64);
|
|||
| ~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
error: casting `u64` to `isize` may wrap around the value on targets with 64-bit wide pointers
|
||||
--> $DIR/cast_size_32bit.rs:26:5
|
||||
--> $DIR/cast_size.rs:28:5
|
||||
|
|
||||
LL | 1u64 as isize;
|
||||
| ^^^^^^^^^^^^^
|
||||
|
||||
error: casting `u64` to `usize` may truncate the value on targets with 32-bit wide pointers
|
||||
--> $DIR/cast_size_32bit.rs:27:5
|
||||
--> $DIR/cast_size.rs:29:5
|
||||
|
|
||||
LL | 1u64 as usize;
|
||||
| ^^^^^^^^^^^^^
|
||||
|
@ -148,24 +148,31 @@ LL | usize::try_from(1u64);
|
|||
| ~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
error: casting `u32` to `isize` may wrap around the value on targets with 32-bit wide pointers
|
||||
--> $DIR/cast_size_32bit.rs:28:5
|
||||
--> $DIR/cast_size.rs:30:5
|
||||
|
|
||||
LL | 1u32 as isize;
|
||||
| ^^^^^^^^^^^^^
|
||||
|
||||
error: casting `i32` to `f32` causes a loss of precision (`i32` is 32 bits wide, but `f32`'s mantissa is only 23 bits wide)
|
||||
--> $DIR/cast_size_32bit.rs:33:5
|
||||
--> $DIR/cast_size.rs:35:5
|
||||
|
|
||||
LL | 999_999_999 as f32;
|
||||
| ^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: casting integer literal to `f64` is unnecessary
|
||||
--> $DIR/cast_size_32bit.rs:34:5
|
||||
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:36:5
|
||||
|
|
||||
LL | 3_999_999_999usize as f64;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `3_999_999_999_f64`
|
||||
LL | 9_999_999_999_999_999usize as f64;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: literal out of range for `usize`
|
||||
--> $DIR/cast_size.rs:36:5
|
||||
|
|
||||
= note: `-D clippy::unnecessary-cast` implied by `-D warnings`
|
||||
LL | 9_999_999_999_999_999usize as f64;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= note: the literal `9_999_999_999_999_999usize` does not fit into the type `usize` whose range is `0..=4294967295`
|
||||
= note: `#[deny(overflowing_literals)]` on by default
|
||||
|
||||
error: aborting due to 18 previous errors
|
||||
error: aborting due to 19 previous errors
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
error: casting `isize` to `i8` may truncate the value
|
||||
--> $DIR/cast_size.rs:12:5
|
||||
--> $DIR/cast_size.rs:15:5
|
||||
|
|
||||
LL | 1isize as i8;
|
||||
| ^^^^^^^^^^^^
|
||||
|
@ -12,7 +12,7 @@ LL | i8::try_from(1isize);
|
|||
| ~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
error: casting `isize` to `f64` causes a loss of precision on targets with 64-bit wide pointers (`isize` is 64 bits wide, but `f64`'s mantissa is only 52 bits wide)
|
||||
--> $DIR/cast_size.rs:16:5
|
||||
--> $DIR/cast_size.rs:18:5
|
||||
|
|
||||
LL | x0 as f64;
|
||||
| ^^^^^^^^^
|
||||
|
@ -26,19 +26,19 @@ LL | x1 as f64;
|
|||
| ^^^^^^^^^
|
||||
|
||||
error: casting `isize` to `f32` causes a loss of precision (`isize` is 32 or 64 bits wide, but `f32`'s mantissa is only 23 bits wide)
|
||||
--> $DIR/cast_size.rs:21:5
|
||||
--> $DIR/cast_size.rs:20:5
|
||||
|
|
||||
LL | x0 as f32;
|
||||
| ^^^^^^^^^
|
||||
|
||||
error: casting `usize` to `f32` causes a loss of precision (`usize` is 32 or 64 bits wide, but `f32`'s mantissa is only 23 bits wide)
|
||||
--> $DIR/cast_size.rs:23:5
|
||||
--> $DIR/cast_size.rs:21:5
|
||||
|
|
||||
LL | x1 as f32;
|
||||
| ^^^^^^^^^
|
||||
|
||||
error: casting `isize` to `i32` may truncate the value on targets with 64-bit wide pointers
|
||||
--> $DIR/cast_size.rs:25:5
|
||||
--> $DIR/cast_size.rs:22:5
|
||||
|
|
||||
LL | 1isize as i32;
|
||||
| ^^^^^^^^^^^^^
|
||||
|
@ -50,7 +50,7 @@ LL | i32::try_from(1isize);
|
|||
| ~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
error: casting `isize` to `u32` may truncate the value on targets with 64-bit wide pointers
|
||||
--> $DIR/cast_size.rs:27:5
|
||||
--> $DIR/cast_size.rs:23:5
|
||||
|
|
||||
LL | 1isize as u32;
|
||||
| ^^^^^^^^^^^^^
|
||||
|
@ -62,7 +62,7 @@ LL | u32::try_from(1isize);
|
|||
| ~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
error: casting `usize` to `u32` may truncate the value on targets with 64-bit wide pointers
|
||||
--> $DIR/cast_size.rs:29:5
|
||||
--> $DIR/cast_size.rs:24:5
|
||||
|
|
||||
LL | 1usize as u32;
|
||||
| ^^^^^^^^^^^^^
|
||||
|
@ -74,7 +74,7 @@ LL | u32::try_from(1usize);
|
|||
| ~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
error: casting `usize` to `i32` may truncate the value on targets with 64-bit wide pointers
|
||||
--> $DIR/cast_size.rs:31:5
|
||||
--> $DIR/cast_size.rs:25:5
|
||||
|
|
||||
LL | 1usize as i32;
|
||||
| ^^^^^^^^^^^^^
|
||||
|
@ -86,7 +86,7 @@ LL | i32::try_from(1usize);
|
|||
| ~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
error: casting `usize` to `i32` may wrap around the value on targets with 32-bit wide pointers
|
||||
--> $DIR/cast_size.rs:31:5
|
||||
--> $DIR/cast_size.rs:25:5
|
||||
|
|
||||
LL | 1usize as i32;
|
||||
| ^^^^^^^^^^^^^
|
||||
|
@ -94,7 +94,7 @@ LL | 1usize as i32;
|
|||
= note: `-D clippy::cast-possible-wrap` implied by `-D warnings`
|
||||
|
||||
error: casting `i64` to `isize` may truncate the value on targets with 32-bit wide pointers
|
||||
--> $DIR/cast_size.rs:36:5
|
||||
--> $DIR/cast_size.rs:26:5
|
||||
|
|
||||
LL | 1i64 as isize;
|
||||
| ^^^^^^^^^^^^^
|
||||
|
@ -106,7 +106,7 @@ LL | isize::try_from(1i64);
|
|||
| ~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
error: casting `i64` to `usize` may truncate the value on targets with 32-bit wide pointers
|
||||
--> $DIR/cast_size.rs:38:5
|
||||
--> $DIR/cast_size.rs:27:5
|
||||
|
|
||||
LL | 1i64 as usize;
|
||||
| ^^^^^^^^^^^^^
|
||||
|
@ -118,7 +118,7 @@ LL | usize::try_from(1i64);
|
|||
| ~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
error: casting `u64` to `isize` may truncate the value on targets with 32-bit wide pointers
|
||||
--> $DIR/cast_size.rs:40:5
|
||||
--> $DIR/cast_size.rs:28:5
|
||||
|
|
||||
LL | 1u64 as isize;
|
||||
| ^^^^^^^^^^^^^
|
||||
|
@ -130,13 +130,13 @@ LL | isize::try_from(1u64);
|
|||
| ~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
error: casting `u64` to `isize` may wrap around the value on targets with 64-bit wide pointers
|
||||
--> $DIR/cast_size.rs:40:5
|
||||
--> $DIR/cast_size.rs:28:5
|
||||
|
|
||||
LL | 1u64 as isize;
|
||||
| ^^^^^^^^^^^^^
|
||||
|
||||
error: casting `u64` to `usize` may truncate the value on targets with 32-bit wide pointers
|
||||
--> $DIR/cast_size.rs:43:5
|
||||
--> $DIR/cast_size.rs:29:5
|
||||
|
|
||||
LL | 1u64 as usize;
|
||||
| ^^^^^^^^^^^^^
|
||||
|
@ -148,19 +148,19 @@ LL | usize::try_from(1u64);
|
|||
| ~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
error: casting `u32` to `isize` may wrap around the value on targets with 32-bit wide pointers
|
||||
--> $DIR/cast_size.rs:45:5
|
||||
--> $DIR/cast_size.rs:30:5
|
||||
|
|
||||
LL | 1u32 as isize;
|
||||
| ^^^^^^^^^^^^^
|
||||
|
||||
error: casting `i32` to `f32` causes a loss of precision (`i32` is 32 bits wide, but `f32`'s mantissa is only 23 bits wide)
|
||||
--> $DIR/cast_size.rs:51:5
|
||||
--> $DIR/cast_size.rs:35:5
|
||||
|
|
||||
LL | 999_999_999 as f32;
|
||||
| ^^^^^^^^^^^^^^^^^^
|
||||
|
||||
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:53:5
|
||||
--> $DIR/cast_size.rs:36:5
|
||||
|
|
||||
LL | 9_999_999_999_999_999usize as f64;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
|
@ -1,56 +1,37 @@
|
|||
//@ignore-32bit
|
||||
#[warn(
|
||||
//@stderr-per-bitwidth
|
||||
//@no-rustfix
|
||||
|
||||
#![warn(
|
||||
clippy::cast_precision_loss,
|
||||
clippy::cast_possible_truncation,
|
||||
clippy::cast_sign_loss,
|
||||
clippy::cast_possible_wrap,
|
||||
clippy::cast_lossless
|
||||
)]
|
||||
#[allow(clippy::no_effect, clippy::unnecessary_operation)]
|
||||
#![allow(clippy::no_effect, clippy::unnecessary_operation)]
|
||||
|
||||
fn main() {
|
||||
// Casting from *size
|
||||
1isize as i8;
|
||||
//~^ ERROR: casting `isize` to `i8` may truncate the value
|
||||
let x0 = 1isize;
|
||||
let x1 = 1usize;
|
||||
x0 as f64;
|
||||
//~^ ERROR: casting `isize` to `f64` causes a loss of precision on targets with 64-bit
|
||||
//~| NOTE: `-D clippy::cast-precision-loss` implied by `-D warnings`
|
||||
x1 as f64;
|
||||
//~^ ERROR: casting `usize` to `f64` causes a loss of precision on targets with 64-bit
|
||||
x0 as f32;
|
||||
//~^ ERROR: casting `isize` to `f32` causes a loss of precision (`isize` is 32 or 64 b
|
||||
x1 as f32;
|
||||
//~^ ERROR: casting `usize` to `f32` causes a loss of precision (`usize` is 32 or 64 b
|
||||
1isize as i32;
|
||||
//~^ ERROR: casting `isize` to `i32` may truncate the value on targets with 64-bit wid
|
||||
1isize as u32;
|
||||
//~^ ERROR: casting `isize` to `u32` may truncate the value on targets with 64-bit wid
|
||||
1usize as u32;
|
||||
//~^ ERROR: casting `usize` to `u32` may truncate the value on targets with 64-bit wid
|
||||
1usize as i32;
|
||||
//~^ ERROR: casting `usize` to `i32` may truncate the value on targets with 64-bit wid
|
||||
//~| ERROR: casting `usize` to `i32` may wrap around the value on targets with 32-bit
|
||||
//~| NOTE: `-D clippy::cast-possible-wrap` implied by `-D warnings`
|
||||
// Casting to *size
|
||||
1i64 as isize;
|
||||
//~^ ERROR: casting `i64` to `isize` may truncate the value on targets with 32-bit wid
|
||||
1i64 as usize;
|
||||
//~^ ERROR: casting `i64` to `usize` may truncate the value on targets with 32-bit wid
|
||||
1u64 as isize;
|
||||
//~^ ERROR: casting `u64` to `isize` may truncate the value on targets with 32-bit wid
|
||||
//~| ERROR: casting `u64` to `isize` may wrap around the value on targets with 64-bit
|
||||
1u64 as usize;
|
||||
//~^ ERROR: casting `u64` to `usize` may truncate the value on targets with 32-bit wid
|
||||
1u32 as isize;
|
||||
//~^ ERROR: casting `u32` to `isize` may wrap around the value on targets with 32-bit
|
||||
1u32 as usize; // Should not trigger any lint
|
||||
1i32 as isize; // Neither should this
|
||||
1i32 as usize;
|
||||
// Big integer literal to float
|
||||
999_999_999 as f32;
|
||||
//~^ ERROR: casting `i32` to `f32` causes a loss of precision (`i32` is 32 bits wide,
|
||||
9_999_999_999_999_999usize as f64;
|
||||
//~^ ERROR: casting `usize` to `f64` causes a loss of precision on targets with 64-bit
|
||||
}
|
||||
//@no-rustfix
|
||||
|
|
|
@ -1,56 +0,0 @@
|
|||
//@ignore-64bit
|
||||
#[warn(
|
||||
clippy::cast_precision_loss,
|
||||
clippy::cast_possible_truncation,
|
||||
clippy::cast_sign_loss,
|
||||
clippy::cast_possible_wrap,
|
||||
clippy::cast_lossless
|
||||
)]
|
||||
#[allow(clippy::no_effect, clippy::unnecessary_operation)]
|
||||
fn main() {
|
||||
// Casting from *size
|
||||
1isize as i8;
|
||||
//~^ ERROR: casting `isize` to `i8` may truncate the value
|
||||
let x0 = 1isize;
|
||||
let x1 = 1usize;
|
||||
x0 as f64;
|
||||
//~^ ERROR: casting `isize` to `f64` causes a loss of precision on targets with 64-bit
|
||||
//~| NOTE: `-D clippy::cast-precision-loss` implied by `-D warnings`
|
||||
x1 as f64;
|
||||
//~^ ERROR: casting `usize` to `f64` causes a loss of precision on targets with 64-bit
|
||||
x0 as f32;
|
||||
//~^ ERROR: casting `isize` to `f32` causes a loss of precision (`isize` is 32 or 64 b
|
||||
x1 as f32;
|
||||
//~^ ERROR: casting `usize` to `f32` causes a loss of precision (`usize` is 32 or 64 b
|
||||
1isize as i32;
|
||||
//~^ ERROR: casting `isize` to `i32` may truncate the value on targets with 64-bit wid
|
||||
1isize as u32;
|
||||
//~^ ERROR: casting `isize` to `u32` may truncate the value on targets with 64-bit wid
|
||||
1usize as u32;
|
||||
//~^ ERROR: casting `usize` to `u32` may truncate the value on targets with 64-bit wid
|
||||
1usize as i32;
|
||||
//~^ ERROR: casting `usize` to `i32` may truncate the value on targets with 64-bit wid
|
||||
//~| ERROR: casting `usize` to `i32` may wrap around the value on targets with 32-bit
|
||||
//~| NOTE: `-D clippy::cast-possible-wrap` implied by `-D warnings`
|
||||
// Casting to *size
|
||||
1i64 as isize;
|
||||
//~^ ERROR: casting `i64` to `isize` may truncate the value on targets with 32-bit wid
|
||||
1i64 as usize;
|
||||
//~^ ERROR: casting `i64` to `usize` may truncate the value on targets with 32-bit wid
|
||||
1u64 as isize;
|
||||
//~^ ERROR: casting `u64` to `isize` may truncate the value on targets with 32-bit wid
|
||||
//~| ERROR: casting `u64` to `isize` may wrap around the value on targets with 64-bit
|
||||
1u64 as usize;
|
||||
//~^ ERROR: casting `u64` to `usize` may truncate the value on targets with 32-bit wid
|
||||
1u32 as isize;
|
||||
//~^ ERROR: casting `u32` to `isize` may wrap around the value on targets with 32-bit
|
||||
1u32 as usize; // Should not trigger any lint
|
||||
1i32 as isize; // Neither should this
|
||||
1i32 as usize;
|
||||
// Big integer literal to float
|
||||
999_999_999 as f32;
|
||||
//~^ ERROR: casting `i32` to `f32` causes a loss of precision (`i32` is 32 bits wide,
|
||||
3_999_999_999usize as f64;
|
||||
//~^ ERROR: casting integer literal to `f64` is unnecessary
|
||||
//~| NOTE: `-D clippy::unnecessary-cast` implied by `-D warnings`
|
||||
}
|
|
@ -1,5 +1,5 @@
|
|||
error: casting function pointer `foo` to `i8`, which truncates the value
|
||||
--> $DIR/fn_to_numeric_cast_32bit.rs:10:13
|
||||
--> $DIR/fn_to_numeric_cast.rs:11:13
|
||||
|
|
||||
LL | let _ = foo as i8;
|
||||
| ^^^^^^^^^ help: try: `foo as usize`
|
||||
|
@ -7,135 +7,135 @@ LL | let _ = foo as i8;
|
|||
= 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_32bit.rs:11:13
|
||||
--> $DIR/fn_to_numeric_cast.rs:12:13
|
||||
|
|
||||
LL | 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_32bit.rs:12:13
|
||||
error: casting function pointer `foo` to `i32`
|
||||
--> $DIR/fn_to_numeric_cast.rs:13:13
|
||||
|
|
||||
LL | let _ = foo as i32;
|
||||
| ^^^^^^^^^^ help: try: `foo as usize`
|
||||
|
||||
error: casting function pointer `foo` to `i64`
|
||||
--> $DIR/fn_to_numeric_cast_32bit.rs:13:13
|
||||
|
|
||||
LL | let _ = foo as i64;
|
||||
| ^^^^^^^^^^ help: try: `foo as usize`
|
||||
|
|
||||
= note: `-D clippy::fn-to-numeric-cast` implied by `-D warnings`
|
||||
|
||||
error: casting function pointer `foo` to `i64`
|
||||
--> $DIR/fn_to_numeric_cast.rs:14:13
|
||||
|
|
||||
LL | let _ = foo as i64;
|
||||
| ^^^^^^^^^^ help: try: `foo as usize`
|
||||
|
||||
error: casting function pointer `foo` to `i128`
|
||||
--> $DIR/fn_to_numeric_cast_32bit.rs:14:13
|
||||
--> $DIR/fn_to_numeric_cast.rs:15:13
|
||||
|
|
||||
LL | let _ = foo as i128;
|
||||
| ^^^^^^^^^^^ help: try: `foo as usize`
|
||||
|
||||
error: casting function pointer `foo` to `isize`
|
||||
--> $DIR/fn_to_numeric_cast_32bit.rs:15:13
|
||||
--> $DIR/fn_to_numeric_cast.rs:16: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_32bit.rs:17:13
|
||||
--> $DIR/fn_to_numeric_cast.rs:18: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_32bit.rs:18:13
|
||||
--> $DIR/fn_to_numeric_cast.rs:19:13
|
||||
|
|
||||
LL | 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_32bit.rs:19:13
|
||||
error: casting function pointer `foo` to `u32`
|
||||
--> $DIR/fn_to_numeric_cast.rs:20:13
|
||||
|
|
||||
LL | let _ = foo as u32;
|
||||
| ^^^^^^^^^^ help: try: `foo as usize`
|
||||
|
||||
error: casting function pointer `foo` to `u64`
|
||||
--> $DIR/fn_to_numeric_cast_32bit.rs:20:13
|
||||
--> $DIR/fn_to_numeric_cast.rs:21:13
|
||||
|
|
||||
LL | let _ = foo as u64;
|
||||
| ^^^^^^^^^^ help: try: `foo as usize`
|
||||
|
||||
error: casting function pointer `foo` to `u128`
|
||||
--> $DIR/fn_to_numeric_cast_32bit.rs:21:13
|
||||
--> $DIR/fn_to_numeric_cast.rs:22: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_32bit.rs:34:13
|
||||
--> $DIR/fn_to_numeric_cast.rs:35: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_32bit.rs:35:13
|
||||
--> $DIR/fn_to_numeric_cast.rs:36:13
|
||||
|
|
||||
LL | let _ = abc as i16;
|
||||
| ^^^^^^^^^^ help: try: `abc as usize`
|
||||
|
||||
error: casting function pointer `abc` to `i32`, which truncates the value
|
||||
--> $DIR/fn_to_numeric_cast_32bit.rs:36:13
|
||||
error: casting function pointer `abc` to `i32`
|
||||
--> $DIR/fn_to_numeric_cast.rs:37:13
|
||||
|
|
||||
LL | let _ = abc as i32;
|
||||
| ^^^^^^^^^^ help: try: `abc as usize`
|
||||
|
||||
error: casting function pointer `abc` to `i64`
|
||||
--> $DIR/fn_to_numeric_cast_32bit.rs:37:13
|
||||
--> $DIR/fn_to_numeric_cast.rs:38:13
|
||||
|
|
||||
LL | let _ = abc as i64;
|
||||
| ^^^^^^^^^^ help: try: `abc as usize`
|
||||
|
||||
error: casting function pointer `abc` to `i128`
|
||||
--> $DIR/fn_to_numeric_cast_32bit.rs:38:13
|
||||
--> $DIR/fn_to_numeric_cast.rs:39:13
|
||||
|
|
||||
LL | let _ = abc as i128;
|
||||
| ^^^^^^^^^^^ help: try: `abc as usize`
|
||||
|
||||
error: casting function pointer `abc` to `isize`
|
||||
--> $DIR/fn_to_numeric_cast_32bit.rs:39:13
|
||||
--> $DIR/fn_to_numeric_cast.rs:40: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_32bit.rs:41:13
|
||||
--> $DIR/fn_to_numeric_cast.rs:42: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_32bit.rs:42:13
|
||||
--> $DIR/fn_to_numeric_cast.rs:43:13
|
||||
|
|
||||
LL | let _ = abc as u16;
|
||||
| ^^^^^^^^^^ help: try: `abc as usize`
|
||||
|
||||
error: casting function pointer `abc` to `u32`, which truncates the value
|
||||
--> $DIR/fn_to_numeric_cast_32bit.rs:43:13
|
||||
error: casting function pointer `abc` to `u32`
|
||||
--> $DIR/fn_to_numeric_cast.rs:44:13
|
||||
|
|
||||
LL | let _ = abc as u32;
|
||||
| ^^^^^^^^^^ help: try: `abc as usize`
|
||||
|
||||
error: casting function pointer `abc` to `u64`
|
||||
--> $DIR/fn_to_numeric_cast_32bit.rs:44:13
|
||||
--> $DIR/fn_to_numeric_cast.rs:45:13
|
||||
|
|
||||
LL | let _ = abc as u64;
|
||||
| ^^^^^^^^^^ help: try: `abc as usize`
|
||||
|
||||
error: casting function pointer `abc` to `u128`
|
||||
--> $DIR/fn_to_numeric_cast_32bit.rs:45:13
|
||||
--> $DIR/fn_to_numeric_cast.rs:46:13
|
||||
|
|
||||
LL | let _ = abc as u128;
|
||||
| ^^^^^^^^^^^ help: try: `abc as usize`
|
||||
|
||||
error: casting function pointer `f` to `i32`, which truncates the value
|
||||
--> $DIR/fn_to_numeric_cast_32bit.rs:52:5
|
||||
error: casting function pointer `f` to `i32`
|
||||
--> $DIR/fn_to_numeric_cast.rs:53:5
|
||||
|
|
||||
LL | f as i32
|
||||
| ^^^^^^^^ help: try: `f as usize`
|
|
@ -1,5 +1,5 @@
|
|||
error: casting function pointer `foo` to `i8`, which truncates the value
|
||||
--> $DIR/fn_to_numeric_cast.rs:10:13
|
||||
--> $DIR/fn_to_numeric_cast.rs:11:13
|
||||
|
|
||||
LL | let _ = foo as i8;
|
||||
| ^^^^^^^^^ help: try: `foo as usize`
|
||||
|
@ -7,19 +7,19 @@ LL | let _ = foo as i8;
|
|||
= 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.rs:13:13
|
||||
--> $DIR/fn_to_numeric_cast.rs:12:13
|
||||
|
|
||||
LL | 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.rs:15:13
|
||||
--> $DIR/fn_to_numeric_cast.rs:13:13
|
||||
|
|
||||
LL | let _ = foo as i32;
|
||||
| ^^^^^^^^^^ help: try: `foo as usize`
|
||||
|
||||
error: casting function pointer `foo` to `i64`
|
||||
--> $DIR/fn_to_numeric_cast.rs:17:13
|
||||
--> $DIR/fn_to_numeric_cast.rs:14:13
|
||||
|
|
||||
LL | let _ = foo as i64;
|
||||
| ^^^^^^^^^^ help: try: `foo as usize`
|
||||
|
@ -27,115 +27,115 @@ LL | let _ = foo as i64;
|
|||
= note: `-D clippy::fn-to-numeric-cast` implied by `-D warnings`
|
||||
|
||||
error: casting function pointer `foo` to `i128`
|
||||
--> $DIR/fn_to_numeric_cast.rs:20:13
|
||||
--> $DIR/fn_to_numeric_cast.rs:15:13
|
||||
|
|
||||
LL | let _ = foo as i128;
|
||||
| ^^^^^^^^^^^ help: try: `foo as usize`
|
||||
|
||||
error: casting function pointer `foo` to `isize`
|
||||
--> $DIR/fn_to_numeric_cast.rs:22:13
|
||||
--> $DIR/fn_to_numeric_cast.rs:16: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:25:13
|
||||
--> $DIR/fn_to_numeric_cast.rs:18: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:27:13
|
||||
--> $DIR/fn_to_numeric_cast.rs:19:13
|
||||
|
|
||||
LL | 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.rs:29:13
|
||||
--> $DIR/fn_to_numeric_cast.rs:20:13
|
||||
|
|
||||
LL | let _ = foo as u32;
|
||||
| ^^^^^^^^^^ help: try: `foo as usize`
|
||||
|
||||
error: casting function pointer `foo` to `u64`
|
||||
--> $DIR/fn_to_numeric_cast.rs:31:13
|
||||
--> $DIR/fn_to_numeric_cast.rs:21:13
|
||||
|
|
||||
LL | let _ = foo as u64;
|
||||
| ^^^^^^^^^^ help: try: `foo as usize`
|
||||
|
||||
error: casting function pointer `foo` to `u128`
|
||||
--> $DIR/fn_to_numeric_cast.rs:33:13
|
||||
--> $DIR/fn_to_numeric_cast.rs:22: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:47:13
|
||||
--> $DIR/fn_to_numeric_cast.rs:35: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:49:13
|
||||
--> $DIR/fn_to_numeric_cast.rs:36:13
|
||||
|
|
||||
LL | let _ = abc as i16;
|
||||
| ^^^^^^^^^^ help: try: `abc as usize`
|
||||
|
||||
error: casting function pointer `abc` to `i32`, which truncates the value
|
||||
--> $DIR/fn_to_numeric_cast.rs:51:13
|
||||
--> $DIR/fn_to_numeric_cast.rs:37:13
|
||||
|
|
||||
LL | let _ = abc as i32;
|
||||
| ^^^^^^^^^^ help: try: `abc as usize`
|
||||
|
||||
error: casting function pointer `abc` to `i64`
|
||||
--> $DIR/fn_to_numeric_cast.rs:53:13
|
||||
--> $DIR/fn_to_numeric_cast.rs:38:13
|
||||
|
|
||||
LL | let _ = abc as i64;
|
||||
| ^^^^^^^^^^ help: try: `abc as usize`
|
||||
|
||||
error: casting function pointer `abc` to `i128`
|
||||
--> $DIR/fn_to_numeric_cast.rs:55:13
|
||||
--> $DIR/fn_to_numeric_cast.rs:39:13
|
||||
|
|
||||
LL | let _ = abc as i128;
|
||||
| ^^^^^^^^^^^ help: try: `abc as usize`
|
||||
|
||||
error: casting function pointer `abc` to `isize`
|
||||
--> $DIR/fn_to_numeric_cast.rs:57:13
|
||||
--> $DIR/fn_to_numeric_cast.rs:40: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:60:13
|
||||
--> $DIR/fn_to_numeric_cast.rs:42: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:62:13
|
||||
--> $DIR/fn_to_numeric_cast.rs:43:13
|
||||
|
|
||||
LL | let _ = abc as u16;
|
||||
| ^^^^^^^^^^ help: try: `abc as usize`
|
||||
|
||||
error: casting function pointer `abc` to `u32`, which truncates the value
|
||||
--> $DIR/fn_to_numeric_cast.rs:64:13
|
||||
--> $DIR/fn_to_numeric_cast.rs:44:13
|
||||
|
|
||||
LL | let _ = abc as u32;
|
||||
| ^^^^^^^^^^ help: try: `abc as usize`
|
||||
|
||||
error: casting function pointer `abc` to `u64`
|
||||
--> $DIR/fn_to_numeric_cast.rs:66:13
|
||||
--> $DIR/fn_to_numeric_cast.rs:45:13
|
||||
|
|
||||
LL | let _ = abc as u64;
|
||||
| ^^^^^^^^^^ help: try: `abc as usize`
|
||||
|
||||
error: casting function pointer `abc` to `u128`
|
||||
--> $DIR/fn_to_numeric_cast.rs:68:13
|
||||
--> $DIR/fn_to_numeric_cast.rs:46:13
|
||||
|
|
||||
LL | let _ = abc as u128;
|
||||
| ^^^^^^^^^^^ help: try: `abc as usize`
|
||||
|
||||
error: casting function pointer `f` to `i32`, which truncates the value
|
||||
--> $DIR/fn_to_numeric_cast.rs:76:5
|
||||
--> $DIR/fn_to_numeric_cast.rs:53:5
|
||||
|
|
||||
LL | f as i32
|
||||
| ^^^^^^^^ help: try: `f as usize`
|
|
@ -1,5 +1,6 @@
|
|||
//@ignore-32bit
|
||||
//@stderr-per-bitwidth
|
||||
//@no-rustfix
|
||||
|
||||
#![warn(clippy::fn_to_numeric_cast, clippy::fn_to_numeric_cast_with_truncation)]
|
||||
|
||||
fn foo() -> String {
|
||||
|
@ -8,30 +9,17 @@ fn foo() -> String {
|
|||
|
||||
fn test_function_to_numeric_cast() {
|
||||
let _ = foo as i8;
|
||||
//~^ ERROR: casting function pointer `foo` to `i8`, which truncates the value
|
||||
//~| NOTE: `-D clippy::fn-to-numeric-cast-with-truncation` implied by `-D warnings`
|
||||
let _ = foo as i16;
|
||||
//~^ ERROR: casting function pointer `foo` to `i16`, which truncates the value
|
||||
let _ = foo as i32;
|
||||
//~^ ERROR: casting function pointer `foo` to `i32`, which truncates the value
|
||||
let _ = foo as i64;
|
||||
//~^ ERROR: casting function pointer `foo` to `i64`
|
||||
//~| NOTE: `-D clippy::fn-to-numeric-cast` implied by `-D warnings`
|
||||
let _ = foo as i128;
|
||||
//~^ ERROR: casting function pointer `foo` to `i128`
|
||||
let _ = foo as isize;
|
||||
//~^ ERROR: casting function pointer `foo` to `isize`
|
||||
|
||||
let _ = foo as u8;
|
||||
//~^ ERROR: casting function pointer `foo` to `u8`, which truncates the value
|
||||
let _ = foo as u16;
|
||||
//~^ ERROR: casting function pointer `foo` to `u16`, which truncates the value
|
||||
let _ = foo as u32;
|
||||
//~^ ERROR: casting function pointer `foo` to `u32`, which truncates the value
|
||||
let _ = foo as u64;
|
||||
//~^ ERROR: casting function pointer `foo` to `u64`
|
||||
let _ = foo as u128;
|
||||
//~^ ERROR: casting function pointer `foo` to `u128`
|
||||
|
||||
// Casting to usize is OK and should not warn
|
||||
let _ = foo as usize;
|
||||
|
@ -45,28 +33,17 @@ fn test_function_var_to_numeric_cast() {
|
|||
let abc: fn() -> String = foo;
|
||||
|
||||
let _ = abc as i8;
|
||||
//~^ ERROR: casting function pointer `abc` to `i8`, which truncates the value
|
||||
let _ = abc as i16;
|
||||
//~^ ERROR: casting function pointer `abc` to `i16`, which truncates the value
|
||||
let _ = abc as i32;
|
||||
//~^ ERROR: casting function pointer `abc` to `i32`, which truncates the value
|
||||
let _ = abc as i64;
|
||||
//~^ ERROR: casting function pointer `abc` to `i64`
|
||||
let _ = abc as i128;
|
||||
//~^ ERROR: casting function pointer `abc` to `i128`
|
||||
let _ = abc as isize;
|
||||
//~^ ERROR: casting function pointer `abc` to `isize`
|
||||
|
||||
let _ = abc as u8;
|
||||
//~^ ERROR: casting function pointer `abc` to `u8`, which truncates the value
|
||||
let _ = abc as u16;
|
||||
//~^ ERROR: casting function pointer `abc` to `u16`, which truncates the value
|
||||
let _ = abc as u32;
|
||||
//~^ ERROR: casting function pointer `abc` to `u32`, which truncates the value
|
||||
let _ = abc as u64;
|
||||
//~^ ERROR: casting function pointer `abc` to `u64`
|
||||
let _ = abc as u128;
|
||||
//~^ ERROR: casting function pointer `abc` to `u128`
|
||||
|
||||
// Casting to usize is OK and should not warn
|
||||
let _ = abc as usize;
|
||||
|
@ -74,7 +51,6 @@ fn test_function_var_to_numeric_cast() {
|
|||
|
||||
fn fn_with_fn_args(f: fn(i32) -> i32) -> i32 {
|
||||
f as i32
|
||||
//~^ ERROR: casting function pointer `f` to `i32`, which truncates the value
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
|
|
|
@ -1,80 +0,0 @@
|
|||
//@ignore-64bit
|
||||
|
||||
#![warn(clippy::fn_to_numeric_cast, clippy::fn_to_numeric_cast_with_truncation)]
|
||||
|
||||
fn foo() -> String {
|
||||
String::new()
|
||||
}
|
||||
|
||||
fn test_function_to_numeric_cast() {
|
||||
let _ = foo as i8;
|
||||
//~^ ERROR: casting function pointer `foo` to `i8`, which truncates the value
|
||||
//~| NOTE: `-D clippy::fn-to-numeric-cast-with-truncation` implied by `-D warnings`
|
||||
let _ = foo as i16;
|
||||
//~^ ERROR: casting function pointer `foo` to `i16`, which truncates the value
|
||||
let _ = foo as i32;
|
||||
//~^ ERROR: casting function pointer `foo` to `i32`, which truncates the value
|
||||
let _ = foo as i64;
|
||||
//~^ ERROR: casting function pointer `foo` to `i64`
|
||||
//~| NOTE: `-D clippy::fn-to-numeric-cast` implied by `-D warnings`
|
||||
let _ = foo as i128;
|
||||
//~^ ERROR: casting function pointer `foo` to `i128`
|
||||
let _ = foo as isize;
|
||||
//~^ ERROR: casting function pointer `foo` to `isize`
|
||||
|
||||
let _ = foo as u8;
|
||||
//~^ ERROR: casting function pointer `foo` to `u8`, which truncates the value
|
||||
let _ = foo as u16;
|
||||
//~^ ERROR: casting function pointer `foo` to `u16`, which truncates the value
|
||||
let _ = foo as u32;
|
||||
//~^ ERROR: casting function pointer `foo` to `u32`, which truncates the value
|
||||
let _ = foo as u64;
|
||||
//~^ ERROR: casting function pointer `foo` to `u64`
|
||||
let _ = foo as u128;
|
||||
//~^ ERROR: casting function pointer `foo` to `u128`
|
||||
|
||||
// Casting to usize is OK and should not warn
|
||||
let _ = foo as usize;
|
||||
|
||||
// Cast `f` (a `FnDef`) to `fn()` should not warn
|
||||
fn f() {}
|
||||
let _ = f as fn();
|
||||
}
|
||||
|
||||
fn test_function_var_to_numeric_cast() {
|
||||
let abc: fn() -> String = foo;
|
||||
|
||||
let _ = abc as i8;
|
||||
//~^ ERROR: casting function pointer `abc` to `i8`, which truncates the value
|
||||
let _ = abc as i16;
|
||||
//~^ ERROR: casting function pointer `abc` to `i16`, which truncates the value
|
||||
let _ = abc as i32;
|
||||
//~^ ERROR: casting function pointer `abc` to `i32`, which truncates the value
|
||||
let _ = abc as i64;
|
||||
//~^ ERROR: casting function pointer `abc` to `i64`
|
||||
let _ = abc as i128;
|
||||
//~^ ERROR: casting function pointer `abc` to `i128`
|
||||
let _ = abc as isize;
|
||||
//~^ ERROR: casting function pointer `abc` to `isize`
|
||||
|
||||
let _ = abc as u8;
|
||||
//~^ ERROR: casting function pointer `abc` to `u8`, which truncates the value
|
||||
let _ = abc as u16;
|
||||
//~^ ERROR: casting function pointer `abc` to `u16`, which truncates the value
|
||||
let _ = abc as u32;
|
||||
//~^ ERROR: casting function pointer `abc` to `u32`, which truncates the value
|
||||
let _ = abc as u64;
|
||||
//~^ ERROR: casting function pointer `abc` to `u64`
|
||||
let _ = abc as u128;
|
||||
//~^ ERROR: casting function pointer `abc` to `u128`
|
||||
|
||||
// Casting to usize is OK and should not warn
|
||||
let _ = abc as usize;
|
||||
}
|
||||
|
||||
fn fn_with_fn_args(f: fn(i32) -> i32) -> i32 {
|
||||
f as i32
|
||||
//~^ ERROR: casting function pointer `f` to `i32`, which truncates the value
|
||||
}
|
||||
|
||||
fn main() {}
|
|
@ -144,7 +144,7 @@ enum WithGenerics {
|
|||
Small(u8),
|
||||
}
|
||||
|
||||
enum PossiblyLargeEnumWithConst<const U: usize> {
|
||||
enum PossiblyLargeEnumWithConst<const U: u64> {
|
||||
SmallBuffer([u8; 4]),
|
||||
MightyBuffer([u16; U]),
|
||||
}
|
||||
|
|
|
@ -1,279 +1,9 @@
|
|||
error: large size difference between variants
|
||||
--> $DIR/large_enum_variant.rs:10:1
|
||||
error[E0308]: mismatched types
|
||||
--> $DIR/large_enum_variant.rs:149:24
|
||||
|
|
||||
LL | / enum LargeEnum {
|
||||
LL | | A(i32),
|
||||
| | ------ the second-largest variant contains at least 4 bytes
|
||||
LL | | B([i32; 8000]),
|
||||
| | -------------- the largest variant contains at least 32000 bytes
|
||||
LL | | }
|
||||
| |_^ the entire enum is at least 32004 bytes
|
||||
|
|
||||
= note: `-D clippy::large-enum-variant` implied by `-D warnings`
|
||||
help: consider boxing the large fields to reduce the total size of the enum
|
||||
|
|
||||
LL | B(Box<[i32; 8000]>),
|
||||
| ~~~~~~~~~~~~~~~~
|
||||
LL | MightyBuffer([u16; U]),
|
||||
| ^ expected `usize`, found `u64`
|
||||
|
||||
error: large size difference between variants
|
||||
--> $DIR/large_enum_variant.rs:34:1
|
||||
|
|
||||
LL | / enum LargeEnum2 {
|
||||
LL | | VariantOk(i32, u32),
|
||||
| | ------------------- the second-largest variant contains at least 8 bytes
|
||||
LL | | ContainingLargeEnum(LargeEnum),
|
||||
| | ------------------------------ the largest variant contains at least 32004 bytes
|
||||
LL | | }
|
||||
| |_^ the entire enum is at least 32004 bytes
|
||||
|
|
||||
help: consider boxing the large fields to reduce the total size of the enum
|
||||
|
|
||||
LL | ContainingLargeEnum(Box<LargeEnum>),
|
||||
| ~~~~~~~~~~~~~~
|
||||
|
||||
error: large size difference between variants
|
||||
--> $DIR/large_enum_variant.rs:39:1
|
||||
|
|
||||
LL | / enum LargeEnum3 {
|
||||
LL | | ContainingMoreThanOneField(i32, [i32; 8000], [i32; 9500]),
|
||||
| | --------------------------------------------------------- the largest variant contains at least 70004 bytes
|
||||
LL | | VoidVariant,
|
||||
LL | | StructLikeLittle { x: i32, y: i32 },
|
||||
| | ----------------------------------- the second-largest variant contains at least 8 bytes
|
||||
LL | | }
|
||||
| |_^ the entire enum is at least 70008 bytes
|
||||
|
|
||||
help: consider boxing the large fields to reduce the total size of the enum
|
||||
|
|
||||
LL | ContainingMoreThanOneField(i32, Box<[i32; 8000]>, Box<[i32; 9500]>),
|
||||
| ~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~
|
||||
|
||||
error: large size difference between variants
|
||||
--> $DIR/large_enum_variant.rs:45:1
|
||||
|
|
||||
LL | / enum LargeEnum4 {
|
||||
LL | | VariantOk(i32, u32),
|
||||
| | ------------------- the second-largest variant contains at least 8 bytes
|
||||
LL | | StructLikeLarge { x: [i32; 8000], y: i32 },
|
||||
| | ------------------------------------------ the largest variant contains at least 32004 bytes
|
||||
LL | | }
|
||||
| |_^ the entire enum is at least 32008 bytes
|
||||
|
|
||||
help: consider boxing the large fields to reduce the total size of the enum
|
||||
|
|
||||
LL | StructLikeLarge { x: Box<[i32; 8000]>, y: i32 },
|
||||
| ~~~~~~~~~~~~~~~~
|
||||
|
||||
error: large size difference between variants
|
||||
--> $DIR/large_enum_variant.rs:50:1
|
||||
|
|
||||
LL | / enum LargeEnum5 {
|
||||
LL | | VariantOk(i32, u32),
|
||||
| | ------------------- the second-largest variant contains at least 8 bytes
|
||||
LL | | StructLikeLarge2 { x: [i32; 8000] },
|
||||
| | ----------------------------------- the largest variant contains at least 32000 bytes
|
||||
LL | | }
|
||||
| |_^ the entire enum is at least 32004 bytes
|
||||
|
|
||||
help: consider boxing the large fields to reduce the total size of the enum
|
||||
|
|
||||
LL | StructLikeLarge2 { x: Box<[i32; 8000]> },
|
||||
| ~~~~~~~~~~~~~~~~
|
||||
|
||||
error: large size difference between variants
|
||||
--> $DIR/large_enum_variant.rs:66:1
|
||||
|
|
||||
LL | / enum LargeEnum7 {
|
||||
LL | | A,
|
||||
LL | | B([u8; 1255]),
|
||||
| | ------------- the largest variant contains at least 1255 bytes
|
||||
LL | | C([u8; 200]),
|
||||
| | ------------ the second-largest variant contains at least 200 bytes
|
||||
LL | | }
|
||||
| |_^ the entire enum is at least 1256 bytes
|
||||
|
|
||||
help: consider boxing the large fields to reduce the total size of the enum
|
||||
|
|
||||
LL | B(Box<[u8; 1255]>),
|
||||
| ~~~~~~~~~~~~~~~
|
||||
|
||||
error: large size difference between variants
|
||||
--> $DIR/large_enum_variant.rs:72:1
|
||||
|
|
||||
LL | / enum LargeEnum8 {
|
||||
LL | | VariantOk(i32, u32),
|
||||
| | ------------------- the second-largest variant contains at least 8 bytes
|
||||
LL | | ContainingMoreThanOneField([i32; 8000], [i32; 2], [i32; 9500], [i32; 30]),
|
||||
| | ------------------------------------------------------------------------- the largest variant contains at least 70128 bytes
|
||||
LL | | }
|
||||
| |_^ the entire enum is at least 70132 bytes
|
||||
|
|
||||
help: consider boxing the large fields to reduce the total size of the enum
|
||||
|
|
||||
LL | ContainingMoreThanOneField(Box<[i32; 8000]>, [i32; 2], Box<[i32; 9500]>, [i32; 30]),
|
||||
| ~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~
|
||||
|
||||
error: large size difference between variants
|
||||
--> $DIR/large_enum_variant.rs:77:1
|
||||
|
|
||||
LL | / enum LargeEnum9 {
|
||||
LL | | A(Struct<()>),
|
||||
| | ------------- the second-largest variant contains at least 4 bytes
|
||||
LL | | B(Struct2),
|
||||
| | ---------- the largest variant contains at least 32000 bytes
|
||||
LL | | }
|
||||
| |_^ the entire enum is at least 32004 bytes
|
||||
|
|
||||
help: consider boxing the large fields to reduce the total size of the enum
|
||||
|
|
||||
LL | B(Box<Struct2>),
|
||||
| ~~~~~~~~~~~~
|
||||
|
||||
error: large size difference between variants
|
||||
--> $DIR/large_enum_variant.rs:82:1
|
||||
|
|
||||
LL | / enum LargeEnumOk2<T> {
|
||||
LL | | A(T),
|
||||
| | ---- the second-largest variant contains at least 0 bytes
|
||||
LL | | B(Struct2),
|
||||
| | ---------- the largest variant contains at least 32000 bytes
|
||||
LL | | }
|
||||
| |_^ the entire enum is at least 32000 bytes
|
||||
|
|
||||
help: consider boxing the large fields to reduce the total size of the enum
|
||||
|
|
||||
LL | B(Box<Struct2>),
|
||||
| ~~~~~~~~~~~~
|
||||
|
||||
error: large size difference between variants
|
||||
--> $DIR/large_enum_variant.rs:87:1
|
||||
|
|
||||
LL | / enum LargeEnumOk3<T> {
|
||||
LL | | A(Struct<T>),
|
||||
| | ------------ the second-largest variant contains at least 4 bytes
|
||||
LL | | B(Struct2),
|
||||
| | ---------- the largest variant contains at least 32000 bytes
|
||||
LL | | }
|
||||
| |_^ the entire enum is at least 32000 bytes
|
||||
|
|
||||
help: consider boxing the large fields to reduce the total size of the enum
|
||||
|
|
||||
LL | B(Box<Struct2>),
|
||||
| ~~~~~~~~~~~~
|
||||
|
||||
error: large size difference between variants
|
||||
--> $DIR/large_enum_variant.rs:102:1
|
||||
|
|
||||
LL | / enum CopyableLargeEnum {
|
||||
LL | | A(bool),
|
||||
| | ------- the second-largest variant contains at least 1 bytes
|
||||
LL | | B([u64; 8000]),
|
||||
| | -------------- the largest variant contains at least 64000 bytes
|
||||
LL | | }
|
||||
| |_^ the entire enum is at least 64008 bytes
|
||||
|
|
||||
note: boxing a variant would require the type no longer be `Copy`
|
||||
--> $DIR/large_enum_variant.rs:102:6
|
||||
|
|
||||
LL | enum CopyableLargeEnum {
|
||||
| ^^^^^^^^^^^^^^^^^
|
||||
help: consider boxing the large fields to reduce the total size of the enum
|
||||
--> $DIR/large_enum_variant.rs:104:5
|
||||
|
|
||||
LL | B([u64; 8000]),
|
||||
| ^^^^^^^^^^^^^^
|
||||
|
||||
error: large size difference between variants
|
||||
--> $DIR/large_enum_variant.rs:107:1
|
||||
|
|
||||
LL | / enum ManuallyCopyLargeEnum {
|
||||
LL | | A(bool),
|
||||
| | ------- the second-largest variant contains at least 1 bytes
|
||||
LL | | B([u64; 8000]),
|
||||
| | -------------- the largest variant contains at least 64000 bytes
|
||||
LL | | }
|
||||
| |_^ the entire enum is at least 64008 bytes
|
||||
|
|
||||
note: boxing a variant would require the type no longer be `Copy`
|
||||
--> $DIR/large_enum_variant.rs:107:6
|
||||
|
|
||||
LL | enum ManuallyCopyLargeEnum {
|
||||
| ^^^^^^^^^^^^^^^^^^^^^
|
||||
help: consider boxing the large fields to reduce the total size of the enum
|
||||
--> $DIR/large_enum_variant.rs:109:5
|
||||
|
|
||||
LL | B([u64; 8000]),
|
||||
| ^^^^^^^^^^^^^^
|
||||
|
||||
error: large size difference between variants
|
||||
--> $DIR/large_enum_variant.rs:120:1
|
||||
|
|
||||
LL | / enum SomeGenericPossiblyCopyEnum<T> {
|
||||
LL | | A(bool, std::marker::PhantomData<T>),
|
||||
| | ------------------------------------ the second-largest variant contains at least 1 bytes
|
||||
LL | | B([u64; 4000]),
|
||||
| | -------------- the largest variant contains at least 32000 bytes
|
||||
LL | | }
|
||||
| |_^ the entire enum is at least 32008 bytes
|
||||
|
|
||||
note: boxing a variant would require the type no longer be `Copy`
|
||||
--> $DIR/large_enum_variant.rs:120:6
|
||||
|
|
||||
LL | enum SomeGenericPossiblyCopyEnum<T> {
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
help: consider boxing the large fields to reduce the total size of the enum
|
||||
--> $DIR/large_enum_variant.rs:122:5
|
||||
|
|
||||
LL | B([u64; 4000]),
|
||||
| ^^^^^^^^^^^^^^
|
||||
|
||||
error: large size difference between variants
|
||||
--> $DIR/large_enum_variant.rs:133:1
|
||||
|
|
||||
LL | / enum LargeEnumWithGenerics<T> {
|
||||
LL | | Small,
|
||||
| | ----- the second-largest variant carries no data at all
|
||||
LL | | Large((T, [u8; 512])),
|
||||
| | --------------------- the largest variant contains at least 512 bytes
|
||||
LL | | }
|
||||
| |_^ the entire enum is at least 512 bytes
|
||||
|
|
||||
help: consider boxing the large fields to reduce the total size of the enum
|
||||
|
|
||||
LL | Large(Box<(T, [u8; 512])>),
|
||||
| ~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
error: large size difference between variants
|
||||
--> $DIR/large_enum_variant.rs:142:1
|
||||
|
|
||||
LL | / enum WithGenerics {
|
||||
LL | | Large([Foo<u64>; 64]),
|
||||
| | --------------------- the largest variant contains at least 512 bytes
|
||||
LL | | Small(u8),
|
||||
| | --------- the second-largest variant contains at least 1 bytes
|
||||
LL | | }
|
||||
| |_^ the entire enum is at least 520 bytes
|
||||
|
|
||||
help: consider boxing the large fields to reduce the total size of the enum
|
||||
|
|
||||
LL | Large(Box<[Foo<u64>; 64]>),
|
||||
| ~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
error: large size difference between variants
|
||||
--> $DIR/large_enum_variant.rs:152:1
|
||||
|
|
||||
LL | / enum LargeEnumOfConst {
|
||||
LL | | Ok,
|
||||
| | -- the second-largest variant carries no data at all
|
||||
LL | | Error(PossiblyLargeEnumWithConst<256>),
|
||||
| | -------------------------------------- the largest variant contains at least 514 bytes
|
||||
LL | | }
|
||||
| |_^ the entire enum is at least 514 bytes
|
||||
|
|
||||
help: consider boxing the large fields to reduce the total size of the enum
|
||||
|
|
||||
LL | Error(Box<PossiblyLargeEnumWithConst<256>>),
|
||||
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
error: aborting due to 16 previous errors
|
||||
error: aborting due to previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0308`.
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
//@ignore-32bit
|
||||
|
||||
#![warn(clippy::result_large_err)]
|
||||
#![allow(clippy::large_enum_variant)]
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
error: the `Err`-variant returned from this function is very large
|
||||
--> $DIR/result_large_err.rs:8:23
|
||||
--> $DIR/result_large_err.rs:10:23
|
||||
|
|
||||
LL | pub fn large_err() -> Result<(), [u8; 512]> {
|
||||
| ^^^^^^^^^^^^^^^^^^^^^ the `Err`-variant is at least 512 bytes
|
||||
|
@ -8,7 +8,7 @@ LL | pub fn large_err() -> Result<(), [u8; 512]> {
|
|||
= note: `-D clippy::result-large-err` implied by `-D warnings`
|
||||
|
||||
error: the `Err`-variant returned from this function is very large
|
||||
--> $DIR/result_large_err.rs:20:21
|
||||
--> $DIR/result_large_err.rs:22:21
|
||||
|
|
||||
LL | pub fn ret() -> Result<(), Self> {
|
||||
| ^^^^^^^^^^^^^^^^ the `Err`-variant is at least 240 bytes
|
||||
|
@ -16,7 +16,7 @@ LL | pub fn ret() -> Result<(), Self> {
|
|||
= help: try reducing the size of `FullyDefinedLargeError`, for example by boxing large elements or replacing it with `Box<FullyDefinedLargeError>`
|
||||
|
||||
error: the `Err`-variant returned from this function is very large
|
||||
--> $DIR/result_large_err.rs:26:26
|
||||
--> $DIR/result_large_err.rs:28:26
|
||||
|
|
||||
LL | pub fn struct_error() -> Result<(), FullyDefinedLargeError> {
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the `Err`-variant is at least 240 bytes
|
||||
|
@ -24,7 +24,7 @@ LL | pub fn struct_error() -> Result<(), FullyDefinedLargeError> {
|
|||
= help: try reducing the size of `FullyDefinedLargeError`, for example by boxing large elements or replacing it with `Box<FullyDefinedLargeError>`
|
||||
|
||||
error: the `Err`-variant returned from this function is very large
|
||||
--> $DIR/result_large_err.rs:32:45
|
||||
--> $DIR/result_large_err.rs:34:45
|
||||
|
|
||||
LL | pub fn large_err_via_type_alias<T>(x: T) -> Fdlr<T> {
|
||||
| ^^^^^^^ the `Err`-variant is at least 240 bytes
|
||||
|
@ -32,7 +32,7 @@ LL | pub fn large_err_via_type_alias<T>(x: T) -> Fdlr<T> {
|
|||
= help: try reducing the size of `FullyDefinedLargeError`, for example by boxing large elements or replacing it with `Box<FullyDefinedLargeError>`
|
||||
|
||||
error: the `Err`-variant returned from this function is very large
|
||||
--> $DIR/result_large_err.rs:41:34
|
||||
--> $DIR/result_large_err.rs:43:34
|
||||
|
|
||||
LL | pub fn param_large_error<R>() -> Result<(), (u128, R, FullyDefinedLargeError)> {
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the `Err`-variant is at least 256 bytes
|
||||
|
@ -40,7 +40,7 @@ LL | pub fn param_large_error<R>() -> Result<(), (u128, R, FullyDefinedLargeErro
|
|||
= help: try reducing the size of `(u128, R, FullyDefinedLargeError)`, for example by boxing large elements or replacing it with `Box<(u128, R, FullyDefinedLargeError)>`
|
||||
|
||||
error: the `Err`-variant returned from this function is very large
|
||||
--> $DIR/result_large_err.rs:53:34
|
||||
--> $DIR/result_large_err.rs:55:34
|
||||
|
|
||||
LL | _Omg([u8; 512]),
|
||||
| --------------- the largest variant contains at least 512 bytes
|
||||
|
@ -51,7 +51,7 @@ LL | pub fn large_enum_error() -> Result<(), Self> {
|
|||
= help: try reducing the size of `LargeErrorVariants<()>`, for example by boxing large elements or replacing it with `Box<LargeErrorVariants<()>>`
|
||||
|
||||
error: the `Err`-variant returned from this function is very large
|
||||
--> $DIR/result_large_err.rs:66:30
|
||||
--> $DIR/result_large_err.rs:68:30
|
||||
|
|
||||
LL | _Biggest([u8; 1024]),
|
||||
| -------------------- the largest variant contains at least 1024 bytes
|
||||
|
@ -64,7 +64,7 @@ LL | fn large_enum_error() -> Result<(), Self> {
|
|||
= help: try reducing the size of `MultipleLargeVariants`, for example by boxing large elements or replacing it with `Box<MultipleLargeVariants>`
|
||||
|
||||
error: the `Err`-variant returned from this function is very large
|
||||
--> $DIR/result_large_err.rs:73:25
|
||||
--> $DIR/result_large_err.rs:75:25
|
||||
|
|
||||
LL | fn large_error() -> Result<(), [u8; 512]> {
|
||||
| ^^^^^^^^^^^^^^^^^^^^^ the `Err`-variant is at least 512 bytes
|
||||
|
@ -72,7 +72,7 @@ LL | fn large_error() -> Result<(), [u8; 512]> {
|
|||
= help: try reducing the size of `[u8; 512]`, for example by boxing large elements or replacing it with `Box<[u8; 512]>`
|
||||
|
||||
error: the `Err`-variant returned from this function is very large
|
||||
--> $DIR/result_large_err.rs:93:29
|
||||
--> $DIR/result_large_err.rs:95:29
|
||||
|
|
||||
LL | pub fn large_union_err() -> Result<(), FullyDefinedUnionError> {
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the `Err`-variant is at least 512 bytes
|
||||
|
@ -80,7 +80,7 @@ LL | pub fn large_union_err() -> Result<(), FullyDefinedUnionError> {
|
|||
= help: try reducing the size of `FullyDefinedUnionError`, for example by boxing large elements or replacing it with `Box<FullyDefinedUnionError>`
|
||||
|
||||
error: the `Err`-variant returned from this function is very large
|
||||
--> $DIR/result_large_err.rs:103:40
|
||||
--> $DIR/result_large_err.rs:105:40
|
||||
|
|
||||
LL | pub fn param_large_union<T: Copy>() -> Result<(), UnionError<T>> {
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^ the `Err`-variant is at least 512 bytes
|
||||
|
@ -88,7 +88,7 @@ LL | pub fn param_large_union<T: Copy>() -> Result<(), UnionError<T>> {
|
|||
= help: try reducing the size of `UnionError<T>`, for example by boxing large elements or replacing it with `Box<UnionError<T>>`
|
||||
|
||||
error: the `Err`-variant returned from this function is very large
|
||||
--> $DIR/result_large_err.rs:113:34
|
||||
--> $DIR/result_large_err.rs:115:34
|
||||
|
|
||||
LL | pub fn array_error_subst<U>() -> Result<(), ArrayError<i32, U>> {
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the `Err`-variant is at least 128 bytes
|
||||
|
@ -96,7 +96,7 @@ LL | pub fn array_error_subst<U>() -> Result<(), ArrayError<i32, U>> {
|
|||
= help: try reducing the size of `ArrayError<i32, U>`, for example by boxing large elements or replacing it with `Box<ArrayError<i32, U>>`
|
||||
|
||||
error: the `Err`-variant returned from this function is very large
|
||||
--> $DIR/result_large_err.rs:118:31
|
||||
--> $DIR/result_large_err.rs:120:31
|
||||
|
|
||||
LL | pub fn array_error<T, U>() -> Result<(), ArrayError<(i32, T), U>> {
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the `Err`-variant is at least 128 bytes
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
//@ignore-32bit
|
||||
//@aux-build:proc_macros.rs
|
||||
#![allow(clippy::redundant_closure_call, unused)]
|
||||
#![warn(clippy::single_call_fn)]
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
error: this function is only used once
|
||||
--> $DIR/single_call_fn.rs:33:1
|
||||
--> $DIR/single_call_fn.rs:34:1
|
||||
|
|
||||
LL | / fn c() {
|
||||
LL | | println!("really");
|
||||
|
@ -9,44 +9,44 @@ LL | | }
|
|||
| |_^
|
||||
|
|
||||
help: used here
|
||||
--> $DIR/single_call_fn.rs:40:5
|
||||
--> $DIR/single_call_fn.rs:41:5
|
||||
|
|
||||
LL | c();
|
||||
| ^
|
||||
= note: `-D clippy::single-call-fn` implied by `-D warnings`
|
||||
|
||||
error: this function is only used once
|
||||
--> $DIR/single_call_fn.rs:12:1
|
||||
--> $DIR/single_call_fn.rs:13:1
|
||||
|
|
||||
LL | fn i() {}
|
||||
| ^^^^^^^^^
|
||||
|
|
||||
help: used here
|
||||
--> $DIR/single_call_fn.rs:17:13
|
||||
--> $DIR/single_call_fn.rs:18:13
|
||||
|
|
||||
LL | let a = i;
|
||||
| ^
|
||||
|
||||
error: this function is only used once
|
||||
--> $DIR/single_call_fn.rs:43:1
|
||||
--> $DIR/single_call_fn.rs:44:1
|
||||
|
|
||||
LL | fn a() {}
|
||||
| ^^^^^^^^^
|
||||
|
|
||||
help: used here
|
||||
--> $DIR/single_call_fn.rs:46:5
|
||||
--> $DIR/single_call_fn.rs:47:5
|
||||
|
|
||||
LL | a();
|
||||
| ^
|
||||
|
||||
error: this function is only used once
|
||||
--> $DIR/single_call_fn.rs:13:1
|
||||
--> $DIR/single_call_fn.rs:14:1
|
||||
|
|
||||
LL | fn j() {}
|
||||
| ^^^^^^^^^
|
||||
|
|
||||
help: used here
|
||||
--> $DIR/single_call_fn.rs:24:9
|
||||
--> $DIR/single_call_fn.rs:25:9
|
||||
|
|
||||
LL | j();
|
||||
| ^
|
||||
|
|
|
@ -1,39 +1,28 @@
|
|||
error[E0512]: cannot transmute between types of different sizes, or dependently-sized types
|
||||
error: transmute from a `f32` to a pointer
|
||||
--> $DIR/transmute_32bit.rs:6:31
|
||||
|
|
||||
LL | let _: *const usize = std::mem::transmute(6.0f32);
|
||||
| ^^^^^^^^^^^^^^^^^^^
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= note: source type: `f32` (32 bits)
|
||||
= note: target type: `*const usize` (64 bits)
|
||||
= note: `-D clippy::wrong-transmute` implied by `-D warnings`
|
||||
|
||||
error[E0512]: cannot transmute between types of different sizes, or dependently-sized types
|
||||
error: transmute from a `f32` to a pointer
|
||||
--> $DIR/transmute_32bit.rs:8:29
|
||||
|
|
||||
LL | let _: *mut usize = std::mem::transmute(6.0f32);
|
||||
| ^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= note: source type: `f32` (32 bits)
|
||||
= note: target type: `*mut usize` (64 bits)
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error[E0512]: cannot transmute between types of different sizes, or dependently-sized types
|
||||
error: transmute from a `char` to a pointer
|
||||
--> $DIR/transmute_32bit.rs:10:31
|
||||
|
|
||||
LL | let _: *const usize = std::mem::transmute('x');
|
||||
| ^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= note: source type: `char` (32 bits)
|
||||
= note: target type: `*const usize` (64 bits)
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error[E0512]: cannot transmute between types of different sizes, or dependently-sized types
|
||||
error: transmute from a `char` to a pointer
|
||||
--> $DIR/transmute_32bit.rs:12:29
|
||||
|
|
||||
LL | let _: *mut usize = std::mem::transmute('x');
|
||||
| ^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= note: source type: `char` (32 bits)
|
||||
= note: target type: `*mut usize` (64 bits)
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: aborting due to 4 previous errors
|
||||
|
||||
For more information about this error, try `rustc --explain E0512`.
|
||||
|
|
Loading…
Reference in a new issue