Debian Codegraph @

gcc/testsuite/rust/execute/torture/trait8.rs

raw
1 /* { dg-output "123\r*\n" } */
2 extern "C" {
3 fn printf(s: *const i8, ...);
4 }
5
6 #[lang = "sized"]
7 pub trait Sized {}
8
9 pub trait Foo {
10 type A;
11
12 fn bar(&self) -> Self::A;
13 }
14
15 struct S(i32);
16 impl Foo for S {
17 type A = i32;
18
19 fn bar(&self) -> Self::A {
20 self.0
21 }
22 }
23
24 fn test_bar<T: Foo>(x: T) -> T::A {
25 x.bar()
26 }
27
28 fn main() -> i32 {
29 let a;
30 a = S(123);
31
32 let bar: i32 = test_bar(a);
33 unsafe {
34 let a = "%i\n\0";
35 let b = a as *const str;
36 let c = b as *const i8;
37
38 printf(c, bar);
39 }
40
41 0
42 }