]>
Commit | Line | Data |
---|---|---|
1a4d82fc JJ |
1 | #![crate_type = "lib"] |
2 | ||
1a4d82fc JJ |
3 | #![feature(box_syntax)] |
4 | ||
5 | static mut COUNT: u64 = 1; | |
6 | ||
7 | pub fn get_count() -> u64 { unsafe { COUNT } } | |
8 | ||
c34b1796 | 9 | #[derive(Copy, Clone)] |
1a4d82fc JJ |
10 | pub struct Foo; |
11 | ||
1a4d82fc JJ |
12 | impl Foo { |
13 | pub fn foo(self, x: &Foo) { | |
14 | unsafe { COUNT *= 2; } | |
15 | // Test internal call. | |
16 | Foo::bar(&self); | |
17 | Foo::bar(x); | |
18 | ||
19 | Foo::baz(self); | |
20 | Foo::baz(*x); | |
21 | ||
22 | Foo::qux(box self); | |
23 | Foo::qux(box *x); | |
24 | } | |
25 | ||
26 | pub fn bar(&self) { | |
27 | unsafe { COUNT *= 3; } | |
28 | } | |
29 | ||
30 | pub fn baz(self) { | |
31 | unsafe { COUNT *= 5; } | |
32 | } | |
33 | ||
34 | pub fn qux(self: Box<Foo>) { | |
35 | unsafe { COUNT *= 7; } | |
36 | } | |
37 | } |