]> git.lizzy.rs Git - rust.git/blob - src/test/run-pass/issue-2735-2.rs
b44d50921a5ea4b55076a3f8f9d426b313c019c2
[rust.git] / src / test / run-pass / issue-2735-2.rs
1 // Copyright 2012 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 // This test should behave exactly like issue-2735-3
12 struct defer {
13     b: @mut bool,
14 }
15
16 #[unsafe_destructor]
17 impl Drop for defer {
18     fn drop(&self) {
19         *self.b = true;
20     }
21 }
22
23 fn defer(b: @mut bool) -> defer {
24     defer {
25         b: b
26     }
27 }
28
29 pub fn main() {
30     let dtor_ran = @mut false;
31     let _  = defer(dtor_ran);
32     assert!(*dtor_ran);
33 }