]> git.lizzy.rs Git - rust.git/blob - src/test/ui/numeric/numeric-cast-without-suggestion.rs
Suggest try_into when possible
[rust.git] / src / test / ui / numeric / numeric-cast-without-suggestion.rs
1 fn foo<N>(_x: N) {}
2
3 fn main() {
4     let x_usize: usize = 1;
5     let x_u64: u64 = 2;
6     let x_u32: u32 = 3;
7     let x_u16: u16 = 4;
8     let x_u8: u8 = 5;
9     let x_isize: isize = 6;
10     let x_i64: i64 = 7;
11     let x_i32: i32 = 8;
12     let x_i16: i16 = 9;
13     let x_i8: i8 = 10;
14     let x_f64: f64 = 11.0;
15     let x_f32: f32 = 12.0;
16
17     foo::<usize>(x_f64); //~ ERROR mismatched types
18     foo::<usize>(x_f32); //~ ERROR mismatched types
19     foo::<isize>(x_f64); //~ ERROR mismatched types
20     foo::<isize>(x_f32); //~ ERROR mismatched types
21     foo::<u64>(x_f64); //~ ERROR mismatched types
22     foo::<u64>(x_f32); //~ ERROR mismatched types
23     foo::<i64>(x_f64); //~ ERROR mismatched types
24     foo::<i64>(x_f32); //~ ERROR mismatched types
25     foo::<u32>(x_f64); //~ ERROR mismatched types
26     foo::<u32>(x_f32); //~ ERROR mismatched types
27     foo::<i32>(x_f64); //~ ERROR mismatched types
28     foo::<i32>(x_f32); //~ ERROR mismatched types
29     foo::<u16>(x_f64); //~ ERROR mismatched types
30     foo::<u16>(x_f32); //~ ERROR mismatched types
31     foo::<i16>(x_f64); //~ ERROR mismatched types
32     foo::<i16>(x_f32); //~ ERROR mismatched types
33     foo::<u8>(x_f64); //~ ERROR mismatched types
34     foo::<u8>(x_f32); //~ ERROR mismatched types
35     foo::<i8>(x_f64); //~ ERROR mismatched types
36     foo::<i8>(x_f32); //~ ERROR mismatched types
37     foo::<f32>(x_f64); //~ ERROR mismatched types
38 }