@@ -22,7 +22,7 @@ func nonConsumingUse(_ k: Klass) {}
2222// Let + Non Consuming Use
2323//
2424
25- public func simpleLinearUse( _ x: Klass ) {
25+ public func simpleLinearUse( _ x: __owned Klass) {
2626 let y = x // expected-error {{'y' used after being moved}}
2727 let _ = _move ( y) // expected-note {{move here}}
2828 nonConsumingUse ( y) // expected-note {{use here}}
@@ -110,24 +110,23 @@ public func conditionalBadConsumingUseLoop(_ x: Klass) {
110110//===
111111// Parameters
112112
113- // This is ok, no uses after.
114- public func simpleMoveOfParameter( _ x: Klass ) -> ( ) {
113+ public func simpleMoveOfParameter( _ x: __owned Klass) -> ( ) {
115114 let _ = _move ( x)
116115}
117116
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}}
119118 let _ = _move ( x) // expected-note {{move here}}
120119 let _ = _move ( x) // expected-note {{use here}}
121120}
122121
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}}
124123 let _ = _move ( x) // expected-note {{move here}}
125124 let _ = consumingUse ( x) // expected-note {{use here}}
126125}
127126
128127// TODO: I wonder if we could do better for the 2nd error. At least we tell the
129128// 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}}
131130 // expected-error @-1 {{'x' used after being moved}}
132131 let _ = _move ( x) // expected-note {{move here}}
133132 for _ in 0 ..< 1024 {
@@ -137,26 +136,26 @@ public func errorLoopMultipleMove(_ x: Klass) -> () { // expected-error {{'x' us
137136 }
138137}
139138
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}}
141140 let _ = _move ( x) // expected-note {{move here}}
142141 for _ in 0 ..< 1024 {
143142 consumingUse ( x) // expected-note {{use here}}
144143 }
145144}
146145
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}}
148147 let _ = _move ( x) // expected-note {{move here}}
149148 for _ in 0 ..< 1024 {
150149 nonConsumingUse ( x) // expected-note {{use here}}
151150 }
152151}
153152
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}}
155154 let _ = _move ( x) // expected-note {{move here}}
156155 let _ = nonConsumingUse ( x) // expected-note {{use here}}
157156}
158157
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}}
160159 let _ = _move ( x) // expected-note {{move here}}
161160 for _ in 0 ..< 1024 {
162161 nonConsumingUse ( x) // expected-note {{use here}}
@@ -167,14 +166,14 @@ public func errorLoopMoveOfParameterNonConsume(_ x: Klass) -> () { // expected-e
167166// Pattern Match Lets //
168167////////////////////////
169168
170- public func patternMatchIfCaseLet( _ x: Klass ? ) {
169+ public func patternMatchIfCaseLet( _ x: __owned Klass? ) {
171170 if case let . some( y) = x { // expected-error {{'y' used after being moved}}
172171 let _ = _move ( y) // expected-note {{move here}}
173172 nonConsumingUse ( y) // expected-note {{use here}}
174173 }
175174}
176175
177- public func patternMatchSwitchLet( _ x: Klass ? ) {
176+ public func patternMatchSwitchLet( _ x: __owned Klass? ) {
178177 switch x {
179178 case . none:
180179 break
@@ -184,7 +183,7 @@ public func patternMatchSwitchLet(_ x: Klass?) {
184183 }
185184}
186185
187- public func patternMatchSwitchLet2( _ x: ( Klass ? , Klass ? ) ? ) {
186+ public func patternMatchSwitchLet2( _ x: __owned ( Klass ? , Klass ? ) ? ) {
188187 switch x {
189188 case . some( ( . some( let y) , _) ) : // expected-error {{'y' used after being moved}}
190189 let _ = _move ( y) // expected-note {{move here}}
@@ -194,7 +193,7 @@ public func patternMatchSwitchLet2(_ x: (Klass?, Klass?)?) {
194193 }
195194}
196195
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}}
198197 let _ = _move ( x) // expected-note {{move here}}
199198 switch x { // expected-note {{use here}}
200199 case . some( ( . some( _) , . some( let z) ) ) : // expected-error {{'z' used after being moved}}
@@ -219,11 +218,10 @@ public struct Pair {
219218// have invalidated a part of pair. We can be less restrictive in the future.
220219//
221220// 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)
227225}
228226
229227public class KlassPair {
@@ -233,7 +231,7 @@ public class KlassPair {
233231
234232// TODO: Emit a better error here! We should state that we are applying _move to
235233// a class field and that is illegal.
236- public func performMoveOnOneEltOfKlassPair( _ p: KlassPair ) {
234+ public func performMoveOnOneEltOfKlassPair( _ p: __owned KlassPair) {
237235 let _ = _move ( p. x) // expected-error {{_move applied to value that the compiler does not support checking}}
238236 nonConsumingUse ( p. y)
239237}
0 commit comments