aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/rust/compile/unify-errors1.rs
blob: 0fe95efd0d7f0a69eb0ceee8582c248b38abfb59 (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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#[lang = "sized"]
trait Sized {}

#[lang = "copy"]
trait Copy {}

trait MyTrait {}

struct Wrapper<T: MyTrait> {
    value: T,
}

struct NotImpl;

trait A {}
trait B {}

struct Wrapper2<T: A + B> {
    value: T,
}

struct NotImpl2;

impl A for NotImpl2 {}

fn takes_tuple(x: (i32, bool)) {}

fn requires_copy<T: Copy>(value: T) {}

pub fn test() {
    takes_tuple((1, 2));
    // { dg-error "mismatched types, expected .bool. but got .<integer>. .E0308." "" { target *-*-* } .-1 }

    takes_tuple((1, 2, 3));
    // { dg-error "mismatched types, expected ..i32, bool.. but got ..<integer>, <integer>, <integer>.. .E0308." "" { target *-*-* } .-1 }

    takes_tuple("hello");
    // { dg-error "mismatched types, expected ..i32, bool.. but got .& str. .E0308." "" { target *-*-* } .-1 }

    let x = &mut 5;
    requires_copy(x);
    // { dg-error "bounds not satisfied for &mut <integer> .Copy. is not satisfied .E0277." "" { target *-*-* } .-1 }

    let _x = Wrapper { value: NotImpl };
    // { dg-error "bounds not satisfied for NotImpl .MyTrait. is not satisfied .E0277." "" { target *-*-* } .-1 }

    let _x = Wrapper2 { value: NotImpl2 };
    // { dg-error "bounds not satisfied for NotImpl2 .B. is not satisfied .E0277." "" { target *-*-* } .-1 }
}