Skip to content

Commit 39aa89b

Browse files
committed
Add a compile-fail test for Drop in constants in the presence of Options
1 parent efda681 commit 39aa89b

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed

src/test/ui/static/static-drop-scope.rs

+8
Original file line numberDiff line numberDiff line change
@@ -28,4 +28,12 @@ const fn const_drop2<T>(x: T) {
2828
//~^ ERROR destructors cannot be evaluated at compile-time
2929
}
3030

31+
const EARLY_DROP_C_OPTION: i32 = (Some(WithDtor), 0).1;
32+
//~^ ERROR destructors cannot be evaluated at compile-time
33+
34+
const HELPER: Option<WithDtor> = Some(WithDtor);
35+
36+
const EARLY_DROP_C_OPTION_CONSTANT: i32 = (HELPER, 0).1;
37+
//~^ ERROR destructors cannot be evaluated at compile-time
38+
3139
fn main () {}

src/test/ui/static/static-drop-scope.stderr

+13-1
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,19 @@ error[E0493]: destructors cannot be evaluated at compile-time
5454
LL | (x, ()).1
5555
| ^^^^^^^ constant functions cannot evaluate destructors
5656

57-
error: aborting due to 8 previous errors
57+
error[E0493]: destructors cannot be evaluated at compile-time
58+
--> $DIR/static-drop-scope.rs:31:34
59+
|
60+
LL | const EARLY_DROP_C_OPTION: i32 = (Some(WithDtor), 0).1;
61+
| ^^^^^^^^^^^^^^^^^^^ constants cannot evaluate destructors
62+
63+
error[E0493]: destructors cannot be evaluated at compile-time
64+
--> $DIR/static-drop-scope.rs:36:43
65+
|
66+
LL | const EARLY_DROP_C_OPTION_CONSTANT: i32 = (HELPER, 0).1;
67+
| ^^^^^^^^^^^ constants cannot evaluate destructors
68+
69+
error: aborting due to 10 previous errors
5870

5971
Some errors occurred: E0493, E0597.
6072
For more information about an error, try `rustc --explain E0493`.

0 commit comments

Comments
 (0)