]> git.lizzy.rs Git - rust.git/blob - src/test/ui/tutorial-suffix-inference-test.rs
Rollup merge of #57132 - daxpedda:master, r=steveklabnik
[rust.git] / src / test / ui / tutorial-suffix-inference-test.rs
1 fn main() {
2     let x = 3;
3     let y: i32 = 3;
4
5     fn identity_u8(n: u8) -> u8 { n }
6     fn identity_u16(n: u16) -> u16 { n }
7
8     identity_u8(x);  // after this, `x` is assumed to have type `u8`
9     identity_u16(x);
10     //~^ ERROR mismatched types
11     //~| expected u16, found u8
12     identity_u16(y);
13     //~^ ERROR mismatched types
14     //~| expected u16, found i32
15
16     let a = 3;
17
18     fn identity_i(n: isize) -> isize { n }
19
20     identity_i(a); // ok
21     identity_u16(a);
22     //~^ ERROR mismatched types
23     //~| expected u16, found isize
24 }