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

trait Foo {
    type A;

    fn test(a: Self::A) -> Self::A {
        a
    }
}

struct Bar(i32);
// { dg-warning "struct is never constructed" "" { target *-*-* } .-1 }

impl Foo for Bar {
    type A = i32;
}

struct Baz(f32);
// { dg-warning "struct is never constructed" "" { target *-*-* } .-1 }

impl Foo for Baz {
    type A = f32;
}

fn main() {
    let a: <Baz as Foo>::A;
    a = 123f32;

    let b;
    b = <Baz as Foo>::test(a);
}