]> git.lizzy.rs Git - rust.git/blob - src/test/run-pass/auxiliary/method_self_arg2.rs
Convert unknown_features lint into an error
[rust.git] / src / test / run-pass / auxiliary / method_self_arg2.rs
1 // Copyright 2014 The Rust Project Developers. See the COPYRIGHT
2 // file at the top-level directory of this distribution and at
3 // http://rust-lang.org/COPYRIGHT.
4 //
5 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8 // option. This file may not be copied, modified, or distributed
9 // except according to those terms.
10
11 #![crate_type = "lib"]
12
13 #![feature(box_syntax)]
14
15 static mut COUNT: u64 = 1;
16
17 pub fn get_count() -> u64 { unsafe { COUNT } }
18
19 #[derive(Copy, Clone)]
20 pub struct Foo;
21
22 impl Foo {
23     pub fn run_trait(self) {
24         unsafe { COUNT *= 17; }
25         // Test internal call.
26         Bar::foo1(&self);
27         Bar::foo2(self);
28         Bar::foo3(box self);
29
30         Bar::bar1(&self);
31         Bar::bar2(self);
32         Bar::bar3(box self);
33     }
34 }
35
36 pub trait Bar : Sized {
37     fn foo1(&self);
38     fn foo2(self);
39     fn foo3(self: Box<Self>);
40
41     fn bar1(&self) {
42         unsafe { COUNT *= 7; }
43     }
44     fn bar2(self) {
45         unsafe { COUNT *= 11; }
46     }
47     fn bar3(self: Box<Self>) {
48         unsafe { COUNT *= 13; }
49     }
50 }
51
52 impl Bar for Foo {
53     fn foo1(&self) {
54         unsafe { COUNT *= 2; }
55     }
56
57     fn foo2(self) {
58         unsafe { COUNT *= 3; }
59     }
60
61     fn foo3(self: Box<Foo>) {
62         unsafe { COUNT *= 5; }
63     }
64 }