You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[move-only] When assigning a var that escapes into a closure into another local, emit the correct error message.
With some of the changes that I have made, we began to emit a mark_must_check
[no_copy] on a copy_addr here. This change teaches the move address checker how
to recognize that in this case if we have a project_box it is actually b/c we
have something captured by an escaping closure.
Copy file name to clipboardExpand all lines: test/SILOptimizer/moveonly_addresschecker_diagnostics.swift
+3-3Lines changed: 3 additions & 3 deletions
Original file line number
Diff line number
Diff line change
@@ -3109,9 +3109,9 @@ public func closureCaptureClassUseAfterConsumeError() {
3109
3109
consumeVal(x2) // expected-error {{'x2' was consumed but it is illegal to consume a noncopyable mutable capture of an escaping closure. One can only read from it or assign over it}}
3110
3110
}
3111
3111
f()
3112
-
// TODO: This is wrong
3113
-
letx3= x2 // expected-note {{consuming use here}}
3114
-
// expected-error @-1 {{'x2' has guaranteed ownership but was consumed}}
3112
+
consumeVal(x2)// expected-error {{'x2' was consumed but it is illegal to consume a noncopyable mutable capture of an escaping closure. One can only read from it or assign over it}}
3113
+
letx3= x2 // expected-error {{'x2' was consumed but it is illegal to consume a noncopyable mutable capture of an escaping closure. One can only read from it or assign over it}}
consumeVal(x2) // expected-error {{'x2' was consumed but it is illegal to consume a noncopyable mutable capture of an escaping closure. One can only read from it or assign over it}}
2871
2871
}
2872
2872
f()
2873
-
// TODO: This is wrong
2874
-
letx3= x2 // expected-note {{consuming use here}}
2875
-
// expected-error @-1 {{'x2' has guaranteed ownership but was consumed}}
2873
+
letx3= x2 // expected-error {{'x2' was consumed but it is illegal to consume a noncopyable mutable capture of an escaping closure. One can only read from it or assign over it}}
2874
+
consumeVal(x2) // expected-error {{'x2' was consumed but it is illegal to consume a noncopyable mutable capture of an escaping closure. One can only read from it or assign over it}}
2875
+
x2 =Klass()
2876
2876
let _ = x3
2877
2877
}
2878
2878
@@ -3107,8 +3107,29 @@ public func closureAndClosureCaptureClassUseAfterConsume2(_ x: borrowing Klass)
3107
3107
}
3108
3108
f()
3109
3109
consumeVal(x2) // expected-error {{'x2' was consumed but it is illegal to consume a noncopyable immutable capture of an escaping closure. One can only read from it}}
3110
+
letx3= x2 // expected-error {{'x2' was consumed but it is illegal to consume a noncopyable immutable capture of an escaping closure. One can only read from it}}
3111
+
_ = x3
3110
3112
}
3111
3113
3114
+
publicfunc closureAndClosureCaptureClassUseAfterConsume3(_ x:borrowingKlass){ // expected-error {{'x' has guaranteed ownership but was consumed}}
3115
+
varx2= x
3116
+
// expected-note @-1 {{consuming use here}}
3117
+
x2 = x
3118
+
// expected-note @-1 {{consuming use here}}
3119
+
3120
+
letf={
3121
+
letg={
3122
+
borrowVal(x2)
3123
+
consumeVal(x2) // expected-error {{'x2' was consumed but it is illegal to consume a noncopyable mutable capture of an escaping closure. One can only read from it or assign over it}}
3124
+
consumeVal(x2) // expected-error {{'x2' was consumed but it is illegal to consume a noncopyable mutable capture of an escaping closure. One can only read from it or assign over it}}
3125
+
}
3126
+
g()
3127
+
}
3128
+
f()
3129
+
consumeVal(x2) // expected-error {{'x2' was consumed but it is illegal to consume a noncopyable mutable capture of an escaping closure. One can only read from it or assign over it}}
3130
+
letx3= x2 // expected-error {{'x2' was consumed but it is illegal to consume a noncopyable mutable capture of an escaping closure. One can only read from it or assign over it}}
// expected-error @-1 {{'x2' consumed in closure. This is illegal since if the closure is invoked more than once the binding will be uninitialized on later invocations}}
Copy file name to clipboardExpand all lines: test/SILOptimizer/moveonly_trivial_addresschecker_diagnostics.swift
+5-3Lines changed: 5 additions & 3 deletions
Original file line number
Diff line number
Diff line change
@@ -1218,9 +1218,11 @@ public func closureCaptureClassUseAfterConsumeError() {
1218
1218
consumeVal(x2) // expected-error {{'x2' was consumed but it is illegal to consume a noncopyable mutable capture of an escaping closure. One can only read from it or assign over it}}
1219
1219
}
1220
1220
f()
1221
-
// TODO: MG This is wrong
1222
-
letx3= x2 // expected-note {{consuming use here}}
1223
-
// expected-error @-1 {{'x2' has guaranteed ownership but was consumed}}
1221
+
letx3= x2 // expected-error {{'x2' was consumed but it is illegal to consume a noncopyable mutable capture of an escaping closure. One can only read from it or assign over it}}
1222
+
consumeVal(x2) // expected-error {{'x2' was consumed but it is illegal to consume a noncopyable mutable capture of an escaping closure. One can only read from it or assign over it}}
1223
+
varx4= x2 // expected-error {{'x2' was consumed but it is illegal to consume a noncopyable mutable capture of an escaping closure. One can only read from it or assign over it}}
1224
+
x4 = x2 // expected-error {{'x2' was consumed but it is illegal to consume a noncopyable mutable capture of an escaping closure. One can only read from it or assign over it}}
Copy file name to clipboardExpand all lines: test/SILOptimizer/moveonly_trivial_objectchecker_diagnostics.swift
+2-3Lines changed: 2 additions & 3 deletions
Original file line number
Diff line number
Diff line change
@@ -1829,9 +1829,8 @@ public func closureCaptureClassOwnedArgUseAfterConsume4(_ x2: consuming NonTrivi
1829
1829
consumeVal(x2) // expected-error {{'x2' was consumed but it is illegal to consume a noncopyable mutable capture of an escaping closure. One can only read from it or assign over it}}
1830
1830
}
1831
1831
f()
1832
-
// TODO (MG): This is wrong
1833
-
letx3= x2 // expected-note {{consuming use here}}
1834
-
// expected-error @-1 {{'x2' has guaranteed ownership but was consumed}}
1832
+
letx3= x2 // expected-error {{'x2' was consumed but it is illegal to consume a noncopyable mutable capture of an escaping closure. One can only read from it or assign over it}}
1833
+
consumeVal(x2) // expected-error {{'x2' was consumed but it is illegal to consume a noncopyable mutable capture of an escaping closure. One can only read from it or assign over it}}
0 commit comments