summaryrefslogtreecommitdiffstats
path: root/tests/ui/type/wrong-call-return-type-due-to-generic-arg.rs
blob: ba5b9f54246e2c63d061ed914e89b0f26a1f299b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
fn function<T>(x: T, y: bool) -> T {
    x
}

struct S {}
impl S {
    fn method<T>(&self, x: T) -> T {
        x
    }
}

fn wrong_arg_type(x: u32) -> u32 {
    x
}

fn main() {
    // Should not trigger.
    let x = wrong_arg_type(0u16); //~ ERROR mismatched types
    let x: u16 = function(0, 0u8); //~ ERROR mismatched types

    // Should trigger exactly once for the first argument.
    let x: u16 = function(0u32, 0u8); //~ ERROR arguments to this function are incorrect

    // Should trigger.
    let x: u16 = function(0u32, true); //~ ERROR mismatched types
    let x: u16 = (S {}).method(0u32); //~ ERROR mismatched types
    function(0u32, 8u8) //~ ERROR arguments to this function are incorrect
}