Skip to content

Commit 7f3e18c

Browse files
committed
make sure [CONST; N] drops N times
1 parent f8d4883 commit 7f3e18c

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// check-pass
1+
// run-pass
22

33
// Repeating a *constant* of non-Copy type (not just a constant expression) is already stable.
44

@@ -8,6 +8,20 @@ pub fn bar() -> [Vec<i32>; 2] {
88
[EMPTY; 2]
99
}
1010

11+
struct Bomb;
12+
13+
impl Drop for Bomb {
14+
fn drop(&mut self) {
15+
panic!("BOOM!");
16+
}
17+
}
18+
19+
const BOOM: Bomb = Bomb;
20+
1121
fn main() {
12-
let x = bar();
22+
let _x = bar();
23+
24+
// Make sure the destructor does not get called for empty arrays. `[CONST; N]` should
25+
// instantiate (and then later drop) the const exactly `N` times.
26+
let _x = [BOOM; 0];
1327
}

0 commit comments

Comments
 (0)