Debian Codegraph @

gcc/testsuite/rust/execute/torture/trait4.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 struct Foo(i32);
10 trait Bar {
11 fn baz(&self);
12 }
13
14 impl Bar for Foo {
15 fn baz(&self) {
16 unsafe {
17 let a = "%i\n\0";
18 let b = a as *const str;
19 let c = b as *const i8;
20
21 printf(c, self.0);
22 }
23 }
24 }
25
26 fn type_bound<T: Bar>(t: &T) {
27 t.baz();
28 }
29
30 fn main() -> i32 {
31 let a;
32
33 a = &Foo(123);
34 type_bound(a);
35
36 0
37 }