]> git.lizzy.rs Git - rust.git/blob - src/test/run-pass/issue-15858.rs
6a4f78442d149943ded6817b5663f3580dbf339c
[rust.git] / src / test / run-pass / issue-15858.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 #![feature(unsafe_destructor)]
12
13 static mut DROP_RAN: bool = false;
14
15 trait Bar {
16     fn do_something(&mut self);
17 }
18
19 struct BarImpl;
20
21 impl Bar for BarImpl {
22     fn do_something(&mut self) {}
23 }
24
25
26 struct Foo<B>(B);
27
28 #[unsafe_destructor]
29 impl<B: Bar> Drop for Foo<B> {
30     fn drop(&mut self) {
31         unsafe {
32             DROP_RAN = true;
33         }
34     }
35 }
36
37
38 fn main() {
39     {
40        let _x: Foo<BarImpl> = Foo(BarImpl);
41     }
42     unsafe {
43         assert_eq!(DROP_RAN, true);
44     }
45 }