]> git.lizzy.rs Git - rust.git/commitdiff
make sure [CONST; N] drops N times
authorRalf Jung <post@ralfj.de>
Sat, 28 Nov 2020 16:32:48 +0000 (17:32 +0100)
committerRalf Jung <post@ralfj.de>
Sun, 20 Dec 2020 14:15:29 +0000 (15:15 +0100)
src/test/ui/consts/rfc-2203-const-array-repeat-exprs/const-repeat.rs

index 11611a949187b8663bbcc90ad85c0b313daba888..65d02317d34c57a0482fef35d2d35f94166b861d 100644 (file)
@@ -1,4 +1,4 @@
-// check-pass
+// run-pass
 
 // Repeating a *constant* of non-Copy type (not just a constant expression) is already stable.
 
 
 // Repeating a *constant* of non-Copy type (not just a constant expression) is already stable.
 
@@ -8,6 +8,20 @@
     [EMPTY; 2]
 }
 
     [EMPTY; 2]
 }
 
+struct Bomb;
+
+impl Drop for Bomb {
+    fn drop(&mut self) {
+        panic!("BOOM!");
+    }
+}
+
+const BOOM: Bomb = Bomb;
+
 fn main() {
 fn main() {
-    let x = bar();
+    let _x = bar();
+
+    // Make sure the destructor does not get called for empty arrays. `[CONST; N]` should
+    // instantiate (and then later drop) the const exactly `N` times.
+    let _x = [BOOM; 0];
 }
 }