| 1 |
/* { dg-output "123, 777\r*" } */ |
| 2 |
extern "C" { |
| 3 |
fn printf(s: *const i8, ...); |
| 4 |
} |
| 5 |
|
| 6 |
#[lang = "sized"] |
| 7 |
pub trait Sized {} |
| 8 |
|
| 9 |
trait A { |
| 10 |
fn a() -> i32 { |
| 11 |
123 |
| 12 |
} |
| 13 |
} |
| 14 |
|
| 15 |
trait B: A { |
| 16 |
fn b() -> i32 { |
| 17 |
<T as A>::a() + 456 |
| 18 |
} |
| 19 |
} |
| 20 |
|
| 21 |
struct T; |
| 22 |
// { dg-warning "struct is never constructed" "" { target *-*-* } .-1 } |
| 23 |
|
| 24 |
impl A for T { |
| 25 |
fn a() -> i32 { |
| 26 |
321 |
| 27 |
} |
| 28 |
} |
| 29 |
|
| 30 |
struct S; |
| 31 |
impl A for S {} |
| 32 |
impl B for S {} |
| 33 |
|
| 34 |
fn main() -> i32 { |
| 35 |
let aa = S::a(); |
| 36 |
let bb = S::b(); |
| 37 |
|
| 38 |
unsafe { |
| 39 |
let a = "%i, %i\n\0"; |
| 40 |
let b = a as *const str; |
| 41 |
let c = b as *const i8; |
| 42 |
|
| 43 |
printf(c, aa, bb); |
| 44 |
} |
| 45 |
0 |
| 46 |
} |