]> git.proxmox.com Git - rustc.git/blame - src/test/run-pass/methods/auxiliary/method_self_arg1.rs
New upstream version 1.37.0+dfsg1
[rustc.git] / src / test / run-pass / methods / auxiliary / method_self_arg1.rs
CommitLineData
1a4d82fc
JJ
1#![crate_type = "lib"]
2
1a4d82fc
JJ
3#![feature(box_syntax)]
4
5static mut COUNT: u64 = 1;
6
7pub fn get_count() -> u64 { unsafe { COUNT } }
8
c34b1796 9#[derive(Copy, Clone)]
1a4d82fc
JJ
10pub struct Foo;
11
1a4d82fc
JJ
12impl 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}