]> git.lizzy.rs Git - rust.git/blob - tests/ui/cast_size.rs
Merge pull request #3265 from mikerite/fix-export
[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
11 #![feature(tool_lints)]
12
13 #[warn(clippy::cast_precision_loss, clippy::cast_possible_truncation, clippy::cast_sign_loss, clippy::cast_possible_wrap, clippy::cast_lossless)]
14 #[allow(clippy::no_effect, clippy::unnecessary_operation)]
15 fn main() {
16     // Casting from *size
17     1isize as i8;
18     1isize as f64;
19     1usize as f64;
20     1isize as f32;
21     1usize as f32;
22     1isize as i32;
23     1isize as u32;
24     1usize as u32;
25     1usize as i32;
26     // Casting to *size
27     1i64 as isize;
28     1i64 as usize;
29     1u64 as isize;
30     1u64 as usize;
31     1u32 as isize;
32     1u32 as usize; // Should not trigger any lint
33     1i32 as isize; // Neither should this
34     1i32 as usize;
35 }