]> git.lizzy.rs Git - rust.git/blob - src/test/ui/static/static-drop-scope.rs
Rollup merge of #85174 - GuillaumeGomez:doc-code-block-border-radius, r=jsha
[rust.git] / src / test / ui / static / static-drop-scope.rs
1 struct WithDtor;
2
3 impl Drop for WithDtor {
4     fn drop(&mut self) {}
5 }
6
7 static PROMOTION_FAIL_S: Option<&'static WithDtor> = Some(&WithDtor);
8 //~^ ERROR destructors cannot be evaluated at compile-time
9 //~| ERROR temporary value dropped while borrowed
10
11 const PROMOTION_FAIL_C: Option<&'static WithDtor> = Some(&WithDtor);
12 //~^ ERROR destructors cannot be evaluated at compile-time
13 //~| ERROR temporary value dropped while borrowed
14
15 static EARLY_DROP_S: i32 = (WithDtor, 0).1;
16 //~^ ERROR destructors cannot be evaluated at compile-time
17
18 const EARLY_DROP_C: i32 = (WithDtor, 0).1;
19 //~^ ERROR destructors cannot be evaluated at compile-time
20
21 const fn const_drop<T>(_: T) {}
22 //~^ ERROR destructors cannot be evaluated at compile-time
23
24 const fn const_drop2<T>(x: T) {
25     (x, ()).1
26     //~^ ERROR destructors cannot be evaluated at compile-time
27 }
28
29 const EARLY_DROP_C_OPTION: i32 = (Some(WithDtor), 0).1;
30 //~^ ERROR destructors cannot be evaluated at compile-time
31
32 const HELPER: Option<WithDtor> = Some(WithDtor);
33
34 const EARLY_DROP_C_OPTION_CONSTANT: i32 = (HELPER, 0).1;
35 //~^ ERROR destructors cannot be evaluated at compile-time
36
37 fn main () {}