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