aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/rust/execute/torture/method1.rs
blob: c57944b93ebb4005864ad17e4446ac2338b7a330 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
/* { dg-output "124\r*\n458" } */
extern "C" {
    fn printf(s: *const i8, ...);
}

struct Foo(i32);
impl Foo {
    fn bar(&self, i: i32) {
        unsafe {
            let a = "%i\n\0";
            let b = a as *const str;
            let c = b as *const i8;

            printf(c, self.0 + i);
        }
    }
}

fn main() -> i32 {
    let a = Foo(123);
    a.bar(1);

    let b = &Foo(456);
    b.bar(2);

    0
}