]> git.proxmox.com Git - rustc.git/blob - src/test/ui/methods/auxiliary/method_self_arg1.rs
New upstream version 1.57.0+dfsg1
[rustc.git] / src / test / ui / methods / auxiliary / method_self_arg1.rs
1 #![crate_type = "lib"]
2
3 static mut COUNT: u64 = 1;
4
5 pub fn get_count() -> u64 { unsafe { COUNT } }
6
7 #[derive(Copy, Clone)]
8 pub struct Foo;
9
10 impl Foo {
11 pub fn foo(self, x: &Foo) {
12 unsafe { COUNT *= 2; }
13 // Test internal call.
14 Foo::bar(&self);
15 Foo::bar(x);
16
17 Foo::baz(self);
18 Foo::baz(*x);
19
20 Foo::qux(Box::new(self));
21 Foo::qux(Box::new(*x));
22 }
23
24 pub fn bar(&self) {
25 unsafe { COUNT *= 3; }
26 }
27
28 pub fn baz(self) {
29 unsafe { COUNT *= 5; }
30 }
31
32 pub fn qux(self: Box<Foo>) {
33 unsafe { COUNT *= 7; }
34 }
35 }