Skip to content

Commit fc82692

Browse files
committed
moved renamed docs formatted | builtin-clone-unwind.rs
1 parent 430b4e1 commit fc82692

File tree

1 file changed

+9
-24
lines changed

1 file changed

+9
-24
lines changed
Lines changed: 9 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
1+
//! Tests cleanup behavior of the built-in `Clone` impl for tuples during unwinding.
2+
13
//@ run-pass
24
//@ needs-unwind
35

46
#![allow(unused_variables)]
57
#![allow(unused_imports)]
68

7-
// Test that builtin implementations of `Clone` cleanup everything
8-
// in case of unwinding.
9-
10-
use std::thread;
119
use std::rc::Rc;
10+
use std::thread;
1211

1312
struct S(Rc<()>);
1413

@@ -28,34 +27,20 @@ fn main() {
2827
// Unwinding with tuples...
2928
let ccounter = counter.clone();
3029
let result = std::panic::catch_unwind(move || {
31-
let _ = (
32-
S(ccounter.clone()),
33-
S(ccounter.clone()),
34-
S(ccounter.clone()),
35-
S(ccounter)
36-
).clone();
30+
let _ =
31+
(S(ccounter.clone()), S(ccounter.clone()), S(ccounter.clone()), S(ccounter)).clone();
3732
});
3833

3934
assert!(result.is_err());
40-
assert_eq!(
41-
1,
42-
Rc::strong_count(&counter)
43-
);
35+
assert_eq!(1, Rc::strong_count(&counter));
4436

4537
// ... and with arrays.
4638
let ccounter = counter.clone();
4739
let child = std::panic::catch_unwind(move || {
48-
let _ = [
49-
S(ccounter.clone()),
50-
S(ccounter.clone()),
51-
S(ccounter.clone()),
52-
S(ccounter)
53-
].clone();
40+
let _ =
41+
[S(ccounter.clone()), S(ccounter.clone()), S(ccounter.clone()), S(ccounter)].clone();
5442
});
5543

5644
assert!(child.is_err());
57-
assert_eq!(
58-
1,
59-
Rc::strong_count(&counter)
60-
);
45+
assert_eq!(1, Rc::strong_count(&counter));
6146
}

0 commit comments

Comments
 (0)