@@ -22,7 +22,7 @@ func nonConsumingUse(_ k: Klass) {}
22
22
// Let + Non Consuming Use
23
23
//
24
24
25
- public func simpleLinearUse( _ x: Klass ) {
25
+ public func simpleLinearUse( _ x: __owned Klass) {
26
26
let y = x // expected-error {{'y' used after being moved}}
27
27
let _ = _move ( y) // expected-note {{move here}}
28
28
nonConsumingUse ( y) // expected-note {{use here}}
@@ -110,24 +110,23 @@ public func conditionalBadConsumingUseLoop(_ x: Klass) {
110
110
//===
111
111
// Parameters
112
112
113
- // This is ok, no uses after.
114
- public func simpleMoveOfParameter( _ x: Klass ) -> ( ) {
113
+ public func simpleMoveOfParameter( _ x: __owned Klass) -> ( ) {
115
114
let _ = _move ( x)
116
115
}
117
116
118
- public func errorSimpleMoveOfParameter( _ x: Klass ) -> ( ) { // expected-error {{'x' used after being moved}}
117
+ public func errorSimpleMoveOfParameter( _ x: __owned Klass) -> ( ) { // expected-error {{'x' used after being moved}}
119
118
let _ = _move ( x) // expected-note {{move here}}
120
119
let _ = _move ( x) // expected-note {{use here}}
121
120
}
122
121
123
- public func errorSimple2MoveOfParameter( _ x: Klass ) -> ( ) { // expected-error {{'x' used after being moved}}
122
+ public func errorSimple2MoveOfParameter( _ x: __owned Klass) -> ( ) { // expected-error {{'x' used after being moved}}
124
123
let _ = _move ( x) // expected-note {{move here}}
125
124
let _ = consumingUse ( x) // expected-note {{use here}}
126
125
}
127
126
128
127
// TODO: I wonder if we could do better for the 2nd error. At least we tell the
129
128
// user it is due to the loop.
130
- public func errorLoopMultipleMove( _ x: Klass ) -> ( ) { // expected-error {{'x' used after being moved}}
129
+ public func errorLoopMultipleMove( _ x: __owned Klass) -> ( ) { // expected-error {{'x' used after being moved}}
131
130
// expected-error @-1 {{'x' used after being moved}}
132
131
let _ = _move ( x) // expected-note {{move here}}
133
132
for _ in 0 ..< 1024 {
@@ -137,26 +136,26 @@ public func errorLoopMultipleMove(_ x: Klass) -> () { // expected-error {{'x' us
137
136
}
138
137
}
139
138
140
- public func errorLoopMoveOfParameter( _ x: Klass ) -> ( ) { // expected-error {{'x' used after being moved}}
139
+ public func errorLoopMoveOfParameter( _ x: __owned Klass) -> ( ) { // expected-error {{'x' used after being moved}}
141
140
let _ = _move ( x) // expected-note {{move here}}
142
141
for _ in 0 ..< 1024 {
143
142
consumingUse ( x) // expected-note {{use here}}
144
143
}
145
144
}
146
145
147
- public func errorLoop2MoveOfParameter( _ x: Klass ) -> ( ) { // expected-error {{'x' used after being moved}}
146
+ public func errorLoop2MoveOfParameter( _ x: __owned Klass) -> ( ) { // expected-error {{'x' used after being moved}}
148
147
let _ = _move ( x) // expected-note {{move here}}
149
148
for _ in 0 ..< 1024 {
150
149
nonConsumingUse ( x) // expected-note {{use here}}
151
150
}
152
151
}
153
152
154
- public func errorSimple2MoveOfParameterNonConsume( _ x: Klass ) -> ( ) { // expected-error {{'x' used after being moved}}
153
+ public func errorSimple2MoveOfParameterNonConsume( _ x: __owned Klass) -> ( ) { // expected-error {{'x' used after being moved}}
155
154
let _ = _move ( x) // expected-note {{move here}}
156
155
let _ = nonConsumingUse ( x) // expected-note {{use here}}
157
156
}
158
157
159
- public func errorLoopMoveOfParameterNonConsume( _ x: Klass ) -> ( ) { // expected-error {{'x' used after being moved}}
158
+ public func errorLoopMoveOfParameterNonConsume( _ x: __owned Klass) -> ( ) { // expected-error {{'x' used after being moved}}
160
159
let _ = _move ( x) // expected-note {{move here}}
161
160
for _ in 0 ..< 1024 {
162
161
nonConsumingUse ( x) // expected-note {{use here}}
@@ -167,14 +166,14 @@ public func errorLoopMoveOfParameterNonConsume(_ x: Klass) -> () { // expected-e
167
166
// Pattern Match Lets //
168
167
////////////////////////
169
168
170
- public func patternMatchIfCaseLet( _ x: Klass ? ) {
169
+ public func patternMatchIfCaseLet( _ x: __owned Klass? ) {
171
170
if case let . some( y) = x { // expected-error {{'y' used after being moved}}
172
171
let _ = _move ( y) // expected-note {{move here}}
173
172
nonConsumingUse ( y) // expected-note {{use here}}
174
173
}
175
174
}
176
175
177
- public func patternMatchSwitchLet( _ x: Klass ? ) {
176
+ public func patternMatchSwitchLet( _ x: __owned Klass? ) {
178
177
switch x {
179
178
case . none:
180
179
break
@@ -184,7 +183,7 @@ public func patternMatchSwitchLet(_ x: Klass?) {
184
183
}
185
184
}
186
185
187
- public func patternMatchSwitchLet2( _ x: ( Klass ? , Klass ? ) ? ) {
186
+ public func patternMatchSwitchLet2( _ x: __owned ( Klass ? , Klass ? ) ? ) {
188
187
switch x {
189
188
case . some( ( . some( let y) , _) ) : // expected-error {{'y' used after being moved}}
190
189
let _ = _move ( y) // expected-note {{move here}}
@@ -194,7 +193,7 @@ public func patternMatchSwitchLet2(_ x: (Klass?, Klass?)?) {
194
193
}
195
194
}
196
195
197
- public func patternMatchSwitchLet3( _ x: ( Klass ? , Klass ? ) ? ) { // expected-error {{'x' used after being moved}}
196
+ public func patternMatchSwitchLet3( _ x: __owned ( Klass ? , Klass ? ) ? ) { // expected-error {{'x' used after being moved}}
198
197
let _ = _move ( x) // expected-note {{move here}}
199
198
switch x { // expected-note {{use here}}
200
199
case . some( ( . some( _) , . some( let z) ) ) : // expected-error {{'z' used after being moved}}
@@ -219,11 +218,10 @@ public struct Pair {
219
218
// have invalidated a part of pair. We can be less restrictive in the future.
220
219
//
221
220
// TODO: Why are we emitting two uses here.
222
- public func performMoveOnOneEltOfPair( _ p: Pair ) { // expected-error {{'p' used after being moved}}
223
- let _ = p. z // Make sure we don't crash when we access a trivial value from Pair.
224
- let _ = _move ( p. x) // expected-note {{move here}}
225
- nonConsumingUse ( p. y) // expected-note {{use here}}
226
- // expected-note @-1 {{use here}}
221
+ public func performMoveOnOneEltOfPair( _ p: __owned Pair) {
222
+ let _ = p. z
223
+ let _ = _move ( p. x) // expected-error {{_move applied to value that the compiler does not support checking}}
224
+ nonConsumingUse ( p. y)
227
225
}
228
226
229
227
public class KlassPair {
@@ -233,7 +231,7 @@ public class KlassPair {
233
231
234
232
// TODO: Emit a better error here! We should state that we are applying _move to
235
233
// a class field and that is illegal.
236
- public func performMoveOnOneEltOfKlassPair( _ p: KlassPair ) {
234
+ public func performMoveOnOneEltOfKlassPair( _ p: __owned KlassPair) {
237
235
let _ = _move ( p. x) // expected-error {{_move applied to value that the compiler does not support checking}}
238
236
nonConsumingUse ( p. y)
239
237
}
0 commit comments