]> git.lizzy.rs Git - rust.git/blob - tests/ui/cast_size.rs
Merge branch 'master' into rustfmt_tests
[rust.git] / tests / ui / cast_size.rs
1 // Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT
2 // file at the top-level directory of this distribution.
3 //
4 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
5 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
6 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
7 // option. This file may not be copied, modified, or distributed
8 // except according to those terms.
9
10 #[warn(
11     clippy::cast_precision_loss,
12     clippy::cast_possible_truncation,
13     clippy::cast_sign_loss,
14     clippy::cast_possible_wrap,
15     clippy::cast_lossless
16 )]
17 #[allow(clippy::no_effect, clippy::unnecessary_operation)]
18 fn main() {
19     // Casting from *size
20     1isize as i8;
21     1isize as f64;
22     1usize as f64;
23     1isize as f32;
24     1usize as f32;
25     1isize as i32;
26     1isize as u32;
27     1usize as u32;
28     1usize as i32;
29     // Casting to *size
30     1i64 as isize;
31     1i64 as usize;
32     1u64 as isize;
33     1u64 as usize;
34     1u32 as isize;
35     1u32 as usize; // Should not trigger any lint
36     1i32 as isize; // Neither should this
37     1i32 as usize;
38 }