gcc/testsuite/rust/execute/torture/trait1.rs
raw| 1 | /* { dg-output "S::f\r*\nT1::f\r*\nT2::f\r*\n" } */ |
| 2 | extern "C" { |
| 3 | fn printf(s: *const i8, ...); |
| 4 | } |
| 5 | |
| 6 | #[lang = "sized"] |
| 7 | pub trait Sized {} |
| 8 | |
| 9 | struct S; |
| 10 | |
| 11 | impl S { |
| 12 | fn f() { |
| 13 | unsafe { |
| 14 | let a = "S::f\n\0"; |
| 15 | let b = a as *const str; |
| 16 | let c = b as *const i8; |
| 17 | |
| 18 | printf(c); |
| 19 | } |
| 20 | } |
| 21 | } |
| 22 | |
| 23 | trait T1 { |
| 24 | fn f() { |
| 25 | unsafe { |
| 26 | let a = "T1::f\n\0"; |
| 27 | let b = a as *const str; |
| 28 | let c = b as *const i8; |
| 29 | |
| 30 | printf(c); |
| 31 | } |
| 32 | } |
| 33 | } |
| 34 | impl T1 for S {} |
| 35 | |
| 36 | trait T2 { |
| 37 | fn f() { |
| 38 | unsafe { |
| 39 | let a = "T2::f\n\0"; |
| 40 | let b = a as *const str; |
| 41 | let c = b as *const i8; |
| 42 | |
| 43 | printf(c); |
| 44 | } |
| 45 | } |
| 46 | } |
| 47 | impl T2 for S {} |
| 48 | |
| 49 | fn main() -> i32 { |
| 50 | S::f(); |
| 51 | <S as T1>::f(); |
| 52 | <S as T2>::f(); |
| 53 | |
| 54 | 0 |
| 55 | } |