3 #![allow(unused_must_use)]
5 #![allow(unused_variables)]
6 // Test cleanup of rvalue temporary that occurs while `box` construction
7 // is in progress. This scenario revealed a rather terrible bug. The
10 // 1. Partial cleanup of `box` is in scope,
11 // 2. cleanup of return value from `get_bar()` is in scope,
14 // This led to a bug because `the top-most frame that was to be
15 // cleaned (which happens to be the partial cleanup of `box`) required
16 // multiple basic blocks, which led to us dropping part of the cleanup
17 // from the top-most frame.
19 // It's unclear how likely such a bug is to recur, but it seems like a
20 // scenario worth testing.
22 // ignore-emscripten no threads support
30 struct Foo { field: Box<usize> }
32 fn do_it(x: &[usize]) -> Foo {
36 fn get_bar(x: usize) -> Vec<usize> { vec![x * 2] }
40 let mut y: Vec<Box<_>> = Vec::new();
41 y.push(Box::new(Conzabble::Bickwick(do_it(&get_bar(x)))));
45 thread::spawn(fails).join();