]> git.lizzy.rs Git - rust.git/blob - src/test/run-pass/issue-8860.rs
auto merge of #12195 : kballard/rust/rustdoc-strip-impls-of-stripped, r=cmr
[rust.git] / src / test / run-pass / issue-8860.rs
1 // Copyright 2012-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 // ignore-fast
12
13 extern mod green;
14
15 static mut DROP: int = 0i;
16 static mut DROP_S: int = 0i;
17 static mut DROP_T: int = 0i;
18
19 #[start]
20 fn start(argc: int, argv: **u8) -> int {
21     let ret = green::start(argc, argv, main);
22     unsafe {
23         assert_eq!(2, DROP);
24         assert_eq!(1, DROP_S);
25         assert_eq!(1, DROP_T);
26     }
27     ret
28 }
29
30 struct S;
31 impl Drop for S {
32     fn drop(&mut self) {
33         unsafe {
34             DROP_S += 1;
35             DROP += 1;
36         }
37     }
38 }
39 fn f(ref _s: S) {}
40
41 struct T { i: int }
42 impl Drop for T {
43     fn drop(&mut self) {
44         unsafe {
45             DROP_T += 1;
46             DROP += 1;
47         }
48     }
49 }
50 fn g(ref _t: T) {}
51
52 fn main() {
53     let s = S;
54     f(s);
55     unsafe {
56         assert_eq!(1, DROP);
57         assert_eq!(1, DROP_S);
58     }
59     let t = T { i: 1 };
60     g(t);
61     unsafe { assert_eq!(1, DROP_T); }
62 }