gccrs: Add execution test cases
[official-gcc.git] / gcc / testsuite / rust / execute / torture / trait11.rs
blob283c9ecd0ede503344f7dd69959ba29448bc832e
1 /* { dg-output "3\n" } */
2 extern "C" {
3     fn printf(s: *const i8, ...);
6 trait FnLike<A, R> {
7     fn call(&self, arg: A) -> R;
10 struct S;
11 impl<'a, T> FnLike<&'a T, &'a T> for S {
12     fn call(&self, arg: &'a T) -> &'a T {
13         // { dg-warning "unused name .self." "" { target *-*-* } .-1 }
14         arg
15     }
18 fn indirect<F>(f: F)
19 where
20     F: for<'a> FnLike<&'a isize, &'a isize>,
22     let x = 3;
23     let y = f.call(&x);
25     unsafe {
26         let a = "%i\n\0";
27         let b = a as *const str;
28         let c = b as *const i8;
30         printf(c, *y);
31     }
34 fn main() -> i32 {
35     indirect(S);
37     0