]> git.lizzy.rs Git - rust.git/blob - tests/ui/type/wrong-call-return-type-due-to-generic-arg.rs
Make `output_filenames` a real query
[rust.git] / tests / ui / type / wrong-call-return-type-due-to-generic-arg.rs
1 fn function<T>(x: T, y: bool) -> T {
2     x
3 }
4
5 struct S {}
6 impl S {
7     fn method<T>(&self, x: T) -> T {
8         x
9     }
10 }
11
12 fn wrong_arg_type(x: u32) -> u32 {
13     x
14 }
15
16 fn main() {
17     // Should not trigger.
18     let x = wrong_arg_type(0u16); //~ ERROR mismatched types
19     let x: u16 = function(0, 0u8); //~ ERROR mismatched types
20
21     // Should trigger exactly once for the first argument.
22     let x: u16 = function(0u32, 0u8); //~ ERROR arguments to this function are incorrect
23
24     // Should trigger.
25     let x: u16 = function(0u32, true); //~ ERROR mismatched types
26     let x: u16 = (S {}).method(0u32); //~ ERROR mismatched types
27     function(0u32, 8u8) //~ ERROR arguments to this function are incorrect
28 }