]>
git.proxmox.com Git - rustc.git/blob - src/test/run-pass/issue-14875.rs
1 // Copyright 2016 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.
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.
11 // Check that values are not leaked when a dtor panics (#14875)
13 use std
::panic
::{self, UnwindSafe}
;
15 struct SetInnerOnDrop
<'a
>(&'a
mut bool
);
17 impl<'a
> UnwindSafe
for SetInnerOnDrop
<'a
> {}
19 impl<'a
> Drop
for SetInnerOnDrop
<'a
> {
26 impl Drop
for PanicOnDrop
{
34 let mut set_on_drop
= false;
36 let set_inner_on_drop
= SetInnerOnDrop(&mut set_on_drop
);
37 let _
= panic
::catch_unwind(|| {
38 let _set_inner_on_drop
= set_inner_on_drop
;
39 let _panic_on_drop
= PanicOnDrop
;