aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/rust/compile/bad-rpit1.rs
blob: d8c21b11c64ab0c6ff2512ed410c8268a6b874a9 (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
#[lang = "sized"]
trait Sized {}

trait Foo {
    fn id(&self) -> i32;
}

struct A;
struct B;

impl Foo for A {
    fn id(&self) -> i32 {
        1
    }
}

impl Foo for B {
    fn id(&self) -> i32 {
        2
    }
}

fn make_foo(cond: bool) -> impl Foo {
    if cond { A } else { B }
    // { dg-error "mismatched types, expected .A. but got .B. .E0308." "" { target *-*-* } .-1 }
}