Debian Codegraph @

gcc/testsuite/rust/execute/torture/trait10.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 struct S;
27 impl S {
28 fn dynamic_dispatch(self, t: &dyn Bar) {
29 // { dg-warning "unused name" "" { target *-*-* } .-1 }
30 t.baz();
31 }
32 }
33
34 pub fn main() -> i32 {
35 let a;
36 a = &Foo(123);
37
38 let b;
39 b = S;
40
41 b.dynamic_dispatch(a);
42
43 0
44 }