8
8
// option. This file may not be copied, modified, or distributed
9
9
// except according to those terms.
10
10
11
- // Verifies all possible restrictions for static items values.
11
+ // Verifies all possible restrictions for statics values.
12
12
13
13
use std:: kinds:: marker;
14
14
@@ -21,7 +21,7 @@ impl Drop for WithDtor {
21
21
// This enum will be used to test the following rules:
22
22
// 1. Variants are safe for static
23
23
// 2. Expr calls are allowed as long as they arguments are safe
24
- // 3. Expr calls with unsafe arguments for static items are rejected
24
+ // 3. Expr calls with unsafe arguments for statics are rejected
25
25
enum SafeEnum {
26
26
Variant1 ,
27
27
Variant2 ( int ) ,
@@ -35,7 +35,7 @@ static STATIC2: SafeEnum = Variant2(0);
35
35
36
36
// This one should fail
37
37
static STATIC3 : SafeEnum = Variant3 ( WithDtor ) ;
38
- //~^ ERROR static items are not allowed to have destructors
38
+ //~^ ERROR statics are not allowed to have destructors
39
39
40
40
41
41
// This enum will be used to test that variants
@@ -52,9 +52,9 @@ impl Drop for UnsafeEnum {
52
52
53
53
54
54
static STATIC4 : UnsafeEnum = Variant5 ;
55
- //~^ ERROR static items are not allowed to have destructors
55
+ //~^ ERROR statics are not allowed to have destructors
56
56
static STATIC5 : UnsafeEnum = Variant6 ( 0 ) ;
57
- //~^ ERROR static items are not allowed to have destructors
57
+ //~^ ERROR statics are not allowed to have destructors
58
58
59
59
60
60
struct SafeStruct {
@@ -68,7 +68,7 @@ static STATIC6: SafeStruct = SafeStruct{field1: Variant1, field2: Variant2(0)};
68
68
69
69
// field2 has an unsafe value, hence this should fail
70
70
static STATIC7 : SafeStruct = SafeStruct { field1 : Variant1 , field2 : Variant3 ( WithDtor ) } ;
71
- //~^ ERROR static items are not allowed to have destructors
71
+ //~^ ERROR statics are not allowed to have destructors
72
72
73
73
// Test variadic constructor for structs. The base struct should be examined
74
74
// as well as every field present in the constructor.
@@ -79,7 +79,7 @@ static STATIC8: SafeStruct = SafeStruct{field1: Variant1,
79
79
// This example should fail because field1 in the base struct is not safe
80
80
static STATIC9 : SafeStruct = SafeStruct { field1 : Variant1 ,
81
81
..SafeStruct { field1 : Variant3 ( WithDtor ) , field2 : Variant1 } } ;
82
- //~^ ERROR static items are not allowed to have destructors
82
+ //~^ ERROR statics are not allowed to have destructors
83
83
84
84
struct UnsafeStruct ;
85
85
@@ -89,44 +89,48 @@ impl Drop for UnsafeStruct {
89
89
90
90
// Types with destructors are not allowed for statics
91
91
static STATIC10 : UnsafeStruct = UnsafeStruct ;
92
- //~^ ERROR static items are not allowed to have destructor
92
+ //~^ ERROR statics are not allowed to have destructor
93
93
94
94
struct MyOwned ;
95
95
96
96
static STATIC11 : Box < MyOwned > = box MyOwned ;
97
- //~^ ERROR static items are not allowed to have custom pointers
97
+ //~^ ERROR statics are not allowed to have custom pointers
98
98
99
99
// The following examples test that mutable structs are just forbidden
100
100
// to have types with destructors
101
101
// These should fail
102
102
static mut STATIC12 : UnsafeStruct = UnsafeStruct ;
103
- //~^ ERROR mutable static items are not allowed to have destructors
103
+ //~^ ERROR mutable statics are not allowed to have destructors
104
+ //~^^ ERROR statics are not allowed to have destructors
104
105
105
106
static mut STATIC13 : SafeStruct = SafeStruct { field1 : Variant1 , field2 : Variant3 ( WithDtor ) } ;
106
- //~^ ERROR mutable static items are not allowed to have destructors
107
+ //~^ ERROR mutable statics are not allowed to have destructors
108
+ //~^^ ERROR: statics are not allowed to have destructors
107
109
108
110
static mut STATIC14 : SafeStruct = SafeStruct {
109
- //~^ ERROR mutable static items are not allowed to have destructors
111
+ //~^ ERROR mutable statics are not allowed to have destructors
110
112
field1 : Variant1 ,
111
113
field2 : Variant4 ( "str" . to_string ( ) )
112
114
} ;
113
115
114
- static STATIC15 : & ' static [ Box < MyOwned > ] = & [ box MyOwned , box MyOwned ] ;
115
- //~^ ERROR static items are not allowed to have custom pointers
116
- //~^^ ERROR static items are not allowed to have custom pointers
116
+ static STATIC15 : & ' static [ Box < MyOwned > ] = & [
117
+ box MyOwned , //~ ERROR statics are not allowed to have custom pointers
118
+ box MyOwned , //~ ERROR statics are not allowed to have custom pointers
119
+ ] ;
117
120
118
- static STATIC16 : ( & ' static Box < MyOwned > , & ' static Box < MyOwned > ) =
119
- ( & box MyOwned , & box MyOwned ) ;
120
- //~^ ERROR static items are not allowed to have custom pointers
121
- //~^^ ERROR static items are not allowed to have custom pointers
121
+ static STATIC16 : ( & ' static Box < MyOwned > , & ' static Box < MyOwned > ) = (
122
+ & box MyOwned , //~ ERROR statics are not allowed to have custom pointers
123
+ & box MyOwned , //~ ERROR statics are not allowed to have custom pointers
124
+ ) ;
122
125
123
126
static mut STATIC17 : SafeEnum = Variant1 ;
124
- //~^ ERROR mutable static items are not allowed to have destructors
127
+ //~^ ERROR mutable statics are not allowed to have destructors
125
128
126
- static STATIC19 : Box < int > = box 3 ;
127
- //~^ ERROR static items are not allowed to have custom pointers
129
+ static STATIC19 : Box < int > =
130
+ box 3 ;
131
+ //~^ ERROR statics are not allowed to have custom pointers
128
132
129
133
pub fn main ( ) {
130
134
let y = { static x: Box < int > = box 3 ; x } ;
131
- //~^ ERROR static items are not allowed to have custom pointers
135
+ //~^ ERROR statics are not allowed to have custom pointers
132
136
}
0 commit comments