@@ -64,17 +64,7 @@ struct DeinitStruct : ~Copyable {
64
64
var fourth : ( MoveOnlyKlass , MoveOnlyKlass )
65
65
var fifth : MoveOnlyKlass
66
66
67
- deinit { }
68
- // expected-note @-1 {{deinit declared here}}
69
- // expected-note @-2 {{deinit declared here}}
70
- // expected-note @-3 {{deinit declared here}}
71
- // expected-note @-4 {{deinit declared here}}
72
- // expected-note @-5 {{deinit declared here}}
73
- // expected-note @-6 {{deinit declared here}}
74
- // expected-note @-7 {{deinit declared here}}
75
- // expected-note @-8 {{deinit declared here}}
76
- // expected-note @-9 {{deinit declared here}}
77
- // expected-note @-10 {{deinit declared here}}
67
+ deinit { } // expected-note 10{{deinit declared here}}
78
68
}
79
69
80
70
func testConsumeCopyable( _ x: consuming DeinitStruct ) {
@@ -84,24 +74,24 @@ func testConsumeCopyable(_ x: consuming DeinitStruct) {
84
74
}
85
75
86
76
func testConsumeNonCopyable1( _ x: consuming DeinitStruct ) {
87
- // expected-error @- 1 {{Cannot partially consume 'x' since it has a user defined deinit}}
88
- consume ( x. third. rhs) // expected-note {{consuming use here}}
77
+ // expected-error @+ 1 {{cannot partially consume 'x' since it has a user defined deinit}}
78
+ consume ( x. third. rhs)
89
79
}
90
80
91
81
func testConsumeNonCopyable2( _ x: consuming DeinitStruct ) {
92
- // expected-error @- 1 {{Cannot partially consume 'x' since it has a user defined deinit}}
93
- consume ( x. fourth. 0 ) // expected-note {{consuming use here}}
82
+ // expected-error @+ 1 {{cannot partially consume 'x' since it has a user defined deinit}}
83
+ consume ( x. fourth. 0 )
94
84
}
95
85
96
86
func testConsumeNonCopyable3( _ x: consuming DeinitStruct ) {
97
- // expected-error @- 1 {{Cannot partially consume 'x' since it has a user defined deinit}}
98
- consume ( x. fourth. 1 ) // expected-note {{consuming use here}}
87
+ // expected-error @+ 1 {{cannot partially consume 'x' since it has a user defined deinit}}
88
+ consume ( x. fourth. 1 )
99
89
}
100
90
101
91
102
92
func testConsumeNonCopyable4( _ x: consuming DeinitStruct ) {
103
- // expected-error @- 1 {{Cannot partially consume 'x' since it has a user defined deinit}}
104
- consume ( x. fifth) // expected-note {{consuming use here}}
93
+ // expected-error @+ 1 {{cannot partially consume 'x' since it has a user defined deinit}}
94
+ consume ( x. fifth)
105
95
}
106
96
107
97
@@ -129,35 +119,35 @@ func testStructContainDeinitStructConsumeCopyable1(_ x: consuming StructContainD
129
119
}
130
120
131
121
132
- func testStructContainStructContainDeinitStructConsumeNonCopyable1( _ x : consuming StructContainDeinitStruct ) {
133
- // expected-error @- 1 {{Cannot partially consume 'x' since it contains field 'x .first' whose type 'DeinitStruct' has a user defined deinit}}
134
- consume ( x . first. third. rhs) // expected-note {{consuming use here}}
122
+ func testStructContainStructContainDeinitStructConsumeNonCopyable1( _ xyz : consuming StructContainDeinitStruct ) {
123
+ // expected-error @+ 1 {{cannot partially consume 'xyz .first' since it has a user defined deinit}}
124
+ consume ( xyz . first. third. rhs)
135
125
}
136
126
137
127
func testStructContainStructContainDeinitStructConsumeNonCopyable1a( _ x: consuming StructContainDeinitStruct ) {
138
- // expected-error @- 1 {{Cannot partially consume 'x' since it contains field 'x .second.0' whose type 'DeinitStruct' has a user defined deinit}}
139
- consume ( x. second. 0 . third. rhs) // expected-note {{consuming use here}}
128
+ // expected-error @+ 1 {{cannot partially consume 'x.second.0' since it has a user defined deinit}}
129
+ consume ( x. second. 0 . third. rhs)
140
130
}
141
131
142
132
func testStructContainStructContainDeinitStructConsumeNonCopyable2( _ x: consuming StructContainDeinitStruct ) {
143
- // expected-error @- 1 {{Cannot partially consume 'x' since it contains field 'x .first' whose type 'DeinitStruct' has a user defined deinit}}
144
- consume ( x. first. fourth. 0 ) // expected-note {{consuming use here}}
133
+ // expected-error @+ 1 {{cannot partially consume 'x.first' since it has a user defined deinit}}
134
+ consume ( x. first. fourth. 0 )
145
135
}
146
136
147
137
func testStructContainStructContainDeinitStructConsumeNonCopyable2a( _ x: consuming StructContainDeinitStruct ) {
148
- // expected-error @- 1 {{Cannot partially consume 'x' since it contains field 'x .second.1' whose type 'DeinitStruct' has a user defined deinit}}
149
- consume ( x. second. 1 . fourth. 0 ) // expected-note {{consuming use here}}
138
+ // expected-error @+ 1 {{cannot partially consume 'x.second.1' since it has a user defined deinit}}
139
+ consume ( x. second. 1 . fourth. 0 )
150
140
}
151
141
152
142
func testStructContainStructContainDeinitStructConsumeNonCopyable3( _ x: consuming StructContainDeinitStruct ) {
153
- // expected-error @- 1 {{Cannot partially consume 'x' since it contains field 'x .first' whose type 'DeinitStruct' has a user defined deinit}}
154
- consume ( x. first. fourth. 1 ) // expected-note {{consuming use here}}
143
+ // expected-error @+ 1 {{cannot partially consume 'x.first' since it has a user defined deinit}}
144
+ consume ( x. first. fourth. 1 )
155
145
}
156
146
157
147
158
148
func testStructContainStructContainDeinitStructConsumeNonCopyable4( _ x: consuming StructContainDeinitStruct ) {
159
- // expected-error @- 1 {{Cannot partially consume 'x' since it contains field 'x .first' whose type 'DeinitStruct' has a user defined deinit}}
160
- consume ( x. first. fifth) // expected-note {{consuming use here}}
149
+ // expected-error @+ 1 {{cannot partially consume 'x.first' since it has a user defined deinit}}
150
+ consume ( x. first. fifth)
161
151
}
162
152
163
153
////////////////////////
@@ -169,12 +159,7 @@ struct AddressOnlyDeinitStruct<T : P> : ~Copyable {
169
159
var moveOnly = SingleIntContainingStruct ( )
170
160
var moveOnlyPair = MoveOnlyPair ( )
171
161
172
- deinit { }
173
- // expected-note @-1 {{deinit declared here}}
174
- // expected-note @-2 {{deinit declared here}}
175
- // expected-note @-3 {{deinit declared here}}
176
- // expected-note @-4 {{deinit declared here}}
177
- // expected-note @-5 {{deinit declared here}}
162
+ deinit { } // expected-note 5{{deinitializer declared here}}
178
163
}
179
164
180
165
func consume< T : P > ( _ x: consuming AddressOnlyDeinitStruct < T > ) { }
@@ -187,10 +172,8 @@ func testAddressOnlyCanConsumeEntireType<T : P>(_ x: consuming AddressOnlyDeinit
187
172
}
188
173
189
174
func testAddressOnlyCannotPartialConsume< T : P > ( _ x: consuming AddressOnlyDeinitStruct < T > ) {
190
- // expected-error @-1 {{Cannot partially consume 'x' since it has a user defined deinit}}
191
- // expected-error @-2 {{Cannot partially consume 'x' since it has a user defined deinit}}
192
- consume ( x. moveOnly) // expected-note {{consuming use here}}
193
- consume ( x. moveOnlyPair. first) // expected-note {{consuming use here}}
175
+ consume ( x. moveOnly) // expected-error {{cannot partially consume 'x' when it has a deinitializer}}
176
+ consume ( x. moveOnlyPair. first) // expected-error {{cannot partially consume 'x' when it has a deinitializer}}
194
177
consume ( x. copyable)
195
178
}
196
179
@@ -199,17 +182,14 @@ struct AddressOnlyContainingDeinitStruct<T : P> : ~Copyable {
199
182
}
200
183
201
184
func testAddressOnlyCannotPartialConsumeEvenIfSingleElt< T : P > ( _ x: consuming AddressOnlyContainingDeinitStruct < T > ) {
202
- // expected-error @-1 {{Cannot partially consume 'x' since it contains field 'x.a' whose type 'AddressOnlyDeinitStruct' has a user defined deinit}}
203
-
204
185
// We do not error here since we can partially consume x, but not x.a
205
186
consume ( x. a)
206
- consume ( x. a. moveOnlyPair) // expected-note {{consuming use here }}
187
+ consume ( x. a. moveOnlyPair) // expected-error {{cannot partially consume 'x.a' when it has a deinitializer }}
207
188
}
208
189
209
190
struct AddressOnlyContainingDeinitSingleField < T : P > : ~ Copyable {
210
191
var moveOnly = SingleIntContainingStruct ( )
211
- deinit { }
212
- // expected-note @-1 {{deinit declared here}}
192
+ deinit { } // expected-note {{deinitializer declared here}}
213
193
}
214
194
215
195
struct AddressOnlyContainingDeinitStruct3 < T : P > : ~ Copyable {
@@ -219,11 +199,9 @@ struct AddressOnlyContainingDeinitStruct3<T : P> : ~Copyable {
219
199
func consume< T : P > ( _ x: consuming AddressOnlyContainingDeinitSingleField < T > ) { }
220
200
221
201
func testAddressOnlyCannotPartialConsumeEvenIfSingleElt< T : P > ( _ x: consuming AddressOnlyContainingDeinitStruct3 < T > ) {
222
- // expected-error @-1 {{Cannot partially consume 'x' since it contains field 'x.a' whose type 'AddressOnlyContainingDeinitSingleField' has a user defined deinit}}
223
-
224
202
// We do not error here since we can partially consume x, but not x.a
225
203
consume ( x. a)
226
- consume ( x. a. moveOnly) // expected-note {{consuming use here }}
204
+ consume ( x. a. moveOnly) // expected-error {{cannot partially consume 'x.a' when it has a deinitializer }}
227
205
}
228
206
229
207
@@ -235,9 +213,7 @@ struct AddressOnlyContainingDeinitStructPair<T : P> : ~Copyable {
235
213
// Make sure that if the deinit is in an intermediate element of the path that
236
214
// we still handle it appropriately.
237
215
func testAddressOnlyDeinitInMiddlePath< T : P > ( _ x: consuming AddressOnlyContainingDeinitStructPair < T > ) {
238
- // expected-error @-1 {{Cannot partially consume 'x' since it contains field 'x.first' whose type 'AddressOnlyDeinitStruct' has a user defined deinit}}
239
- // expected-error @-2 {{Cannot partially consume 'x' since it contains field 'x.first' whose type 'AddressOnlyDeinitStruct' has a user defined deinit}}
240
- consume ( x. first. moveOnly) // expected-note {{consuming use here}}
241
- consume ( x. first. moveOnlyPair. first) // expected-note {{consuming use here}}
216
+ consume ( x. first. moveOnly) // expected-error {{cannot partially consume 'x.first' when it has a deinitializer}}
217
+ consume ( x. first. moveOnlyPair. first) // expected-error {{cannot partially consume 'x.first' when it has a deinitializer}}
242
218
consume ( x. first. copyable)
243
219
}
0 commit comments