summaryrefslogtreecommitdiffstats
path: root/src/tools/clippy/tests/ui/cast_size_32bit.rs
blob: 99aac6deca3240248356da5f3cc903cb2477178c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
// 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;
    let x0 = 1isize;
    let x1 = 1usize;
    x0 as f64;
    x1 as f64;
    x0 as f32;
    x1 as f32;
    1isize as i32;
    1isize as u32;
    1usize as u32;
    1usize as i32;
    // Casting to *size
    1i64 as isize;
    1i64 as usize;
    1u64 as isize;
    1u64 as usize;
    1u32 as isize;
    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;
    3_999_999_999usize as f64;
}