From e71594725a5fc2d9f5134941de423b5f3d69b02d Mon Sep 17 00:00:00 2001 From: Kavon Farvardin Date: Mon, 12 Jun 2023 17:15:46 -0700 Subject: [PATCH 1/2] be specific that only escaping closures prevent consumption rdar://109908383 --- include/swift/AST/DiagnosticsSIL.def | 2 +- test/SILGen/moveonly_escaping_closure.swift | 112 ++++---- ...nite_init_moveonly_controlflowdep_init.sil | 2 +- .../moveonly_addresschecker_diagnostics.sil | 4 +- .../moveonly_addresschecker_diagnostics.swift | 86 +++--- .../moveonly_nonescaping_closures.swift | 2 +- .../moveonly_objectchecker_diagnostics.swift | 260 +++++++++--------- ...ly_trivial_objectchecker_diagnostics.swift | 68 ++--- .../noimplicitcopy_consuming_parameters.swift | 24 +- 9 files changed, 280 insertions(+), 280 deletions(-) diff --git a/include/swift/AST/DiagnosticsSIL.def b/include/swift/AST/DiagnosticsSIL.def index df082a3ce52fd..362dbc4ed7876 100644 --- a/include/swift/AST/DiagnosticsSIL.def +++ b/include/swift/AST/DiagnosticsSIL.def @@ -766,7 +766,7 @@ ERROR(sil_movechecking_borrowed_parameter_captured_by_closure, none, "parameter", (StringRef)) ERROR(sil_movechecking_capture_consumed, none, - "noncopyable '%0' cannot be consumed when captured by a closure", (StringRef)) + "noncopyable '%0' cannot be consumed when captured by an escaping closure", (StringRef)) ERROR(sil_movechecking_inout_not_reinitialized_before_end_of_function, none, "missing reinitialization of inout parameter '%0' after consume", (StringRef)) ERROR(sil_movechecking_value_consumed_in_a_loop, none, diff --git a/test/SILGen/moveonly_escaping_closure.swift b/test/SILGen/moveonly_escaping_closure.swift index 5492cfad38810..1b20481e0147e 100644 --- a/test/SILGen/moveonly_escaping_closure.swift +++ b/test/SILGen/moveonly_escaping_closure.swift @@ -73,9 +73,9 @@ func testGlobalClosureCaptureVar() { x = SingleElt() globalClosureCaptureVar = { borrowVal(x) - consumeVal(x) // expected-error {{noncopyable 'x' cannot be consumed when captured by a closure}} - consumeVal(x) // expected-error {{noncopyable 'x' cannot be consumed when captured by a closure}} - borrowConsumeVal(x, x) // expected-error {{noncopyable 'x' cannot be consumed when captured by a closure}} + consumeVal(x) // expected-error {{noncopyable 'x' cannot be consumed when captured by an escaping closure}} + consumeVal(x) // expected-error {{noncopyable 'x' cannot be consumed when captured by an escaping closure}} + borrowConsumeVal(x, x) // expected-error {{noncopyable 'x' cannot be consumed when captured by an escaping closure}} // expected-error @-1:29 {{overlapping accesses, but deinitialization requires exclusive access}} // expected-note @-2:26 {{conflicting access is here}} } @@ -196,9 +196,9 @@ func testLocalVarClosureCaptureVar() { x = SingleElt() var f = { borrowVal(x) - consumeVal(x) // expected-error {{noncopyable 'x' cannot be consumed when captured by a closure}} - consumeVal(x) // expected-error {{noncopyable 'x' cannot be consumed when captured by a closure}} - borrowConsumeVal(x, x) // expected-error {{noncopyable 'x' cannot be consumed when captured by a closure}} + consumeVal(x) // expected-error {{noncopyable 'x' cannot be consumed when captured by an escaping closure}} + consumeVal(x) // expected-error {{noncopyable 'x' cannot be consumed when captured by an escaping closure}} + borrowConsumeVal(x, x) // expected-error {{noncopyable 'x' cannot be consumed when captured by an escaping closure}} // expected-error @-1 {{overlapping accesses, but deinitialization requires exclusive access}} // expected-note @-2 {{conflicting access is here}} } @@ -257,9 +257,9 @@ func testInOutVarClosureCaptureVar(_ f: inout () -> ()) { x = SingleElt() f = { borrowVal(x) - consumeVal(x) // expected-error {{noncopyable 'x' cannot be consumed when captured by a closure}} - consumeVal(x) // expected-error {{noncopyable 'x' cannot be consumed when captured by a closure}} - borrowConsumeVal(x, x) // expected-error {{noncopyable 'x' cannot be consumed when captured by a closure}} + consumeVal(x) // expected-error {{noncopyable 'x' cannot be consumed when captured by an escaping closure}} + consumeVal(x) // expected-error {{noncopyable 'x' cannot be consumed when captured by an escaping closure}} + borrowConsumeVal(x, x) // expected-error {{noncopyable 'x' cannot be consumed when captured by an escaping closure}} // expected-error @-1 {{overlapping accesses, but deinitialization requires exclusive access}} // expected-note @-2 {{conflicting access is here}} } @@ -326,9 +326,9 @@ func testConsumingEscapeClosureCaptureVar(_ f: consuming @escaping () -> ()) { x = SingleElt() f = { borrowVal(x) - consumeVal(x) // expected-error {{noncopyable 'x' cannot be consumed when captured by a closure}} - consumeVal(x) // expected-error {{noncopyable 'x' cannot be consumed when captured by a closure}} - borrowConsumeVal(x, x) // expected-error {{noncopyable 'x' cannot be consumed when captured by a closure}} + consumeVal(x) // expected-error {{noncopyable 'x' cannot be consumed when captured by an escaping closure}} + consumeVal(x) // expected-error {{noncopyable 'x' cannot be consumed when captured by an escaping closure}} + borrowConsumeVal(x, x) // expected-error {{noncopyable 'x' cannot be consumed when captured by an escaping closure}} // expected-error @-1 {{overlapping accesses, but deinitialization requires exclusive access}} // expected-note @-2 {{conflicting access is here}} } @@ -379,9 +379,9 @@ func testGlobalClosureCaptureLet() { let x = SingleElt() globalClosureCaptureLet = { borrowVal(x) - consumeVal(x) // expected-error {{noncopyable 'x' cannot be consumed when captured by a closure}} - consumeVal(x) // expected-error {{noncopyable 'x' cannot be consumed when captured by a closure}} - borrowConsumeVal(x, x) // expected-error {{noncopyable 'x' cannot be consumed when captured by a closure}} + consumeVal(x) // expected-error {{noncopyable 'x' cannot be consumed when captured by an escaping closure}} + consumeVal(x) // expected-error {{noncopyable 'x' cannot be consumed when captured by an escaping closure}} + borrowConsumeVal(x, x) // expected-error {{noncopyable 'x' cannot be consumed when captured by an escaping closure}} } globalClosureCaptureLet() } @@ -423,9 +423,9 @@ func testGlobalClosureCaptureLet() { // CHECK: } // end sil function '$s16moveonly_closure026testLocalLetClosureCaptureE0yyFyycfU_' func testLocalLetClosureCaptureLet() { let x = SingleElt() - // expected-error @-1 {{noncopyable 'x' cannot be consumed when captured by a closure}} - // expected-error @-2 {{noncopyable 'x' cannot be consumed when captured by a closure}} - // expected-error @-3 {{noncopyable 'x' cannot be consumed when captured by a closure}} + // expected-error @-1 {{noncopyable 'x' cannot be consumed when captured by an escaping closure}} + // expected-error @-2 {{noncopyable 'x' cannot be consumed when captured by an escaping closure}} + // expected-error @-3 {{noncopyable 'x' cannot be consumed when captured by an escaping closure}} let f = { borrowVal(x) consumeVal(x) // expected-note {{consumed here}} @@ -471,9 +471,9 @@ func testLocalVarClosureCaptureLet() { let x = SingleElt() var f = { borrowVal(x) - consumeVal(x) // expected-error {{noncopyable 'x' cannot be consumed when captured by a closure}} - consumeVal(x) // expected-error {{noncopyable 'x' cannot be consumed when captured by a closure}} - borrowConsumeVal(x, x) // expected-error {{noncopyable 'x' cannot be consumed when captured by a closure}} + consumeVal(x) // expected-error {{noncopyable 'x' cannot be consumed when captured by an escaping closure}} + consumeVal(x) // expected-error {{noncopyable 'x' cannot be consumed when captured by an escaping closure}} + borrowConsumeVal(x, x) // expected-error {{noncopyable 'x' cannot be consumed when captured by an escaping closure}} } f = {} f() @@ -519,9 +519,9 @@ func testInOutVarClosureCaptureLet(_ f: inout () -> ()) { let x = SingleElt() f = { borrowVal(x) - consumeVal(x) // expected-error {{noncopyable 'x' cannot be consumed when captured by a closure}} - consumeVal(x) // expected-error {{noncopyable 'x' cannot be consumed when captured by a closure}} - borrowConsumeVal(x, x) // expected-error {{noncopyable 'x' cannot be consumed when captured by a closure}} + consumeVal(x) // expected-error {{noncopyable 'x' cannot be consumed when captured by an escaping closure}} + consumeVal(x) // expected-error {{noncopyable 'x' cannot be consumed when captured by an escaping closure}} + borrowConsumeVal(x, x) // expected-error {{noncopyable 'x' cannot be consumed when captured by an escaping closure}} } f() } @@ -575,9 +575,9 @@ func testConsumingEscapeClosureCaptureLet(_ f: consuming @escaping () -> ()) { let x = SingleElt() f = { borrowVal(x) - consumeVal(x) // expected-error {{noncopyable 'x' cannot be consumed when captured by a closure}} - consumeVal(x) // expected-error {{noncopyable 'x' cannot be consumed when captured by a closure}} - borrowConsumeVal(x, x) // expected-error {{noncopyable 'x' cannot be consumed when captured by a closure}} + consumeVal(x) // expected-error {{noncopyable 'x' cannot be consumed when captured by an escaping closure}} + consumeVal(x) // expected-error {{noncopyable 'x' cannot be consumed when captured by an escaping closure}} + borrowConsumeVal(x, x) // expected-error {{noncopyable 'x' cannot be consumed when captured by an escaping closure}} } f() } @@ -887,9 +887,9 @@ var globalClosureCaptureConsuming: () -> () = {} func testGlobalClosureCaptureConsuming(_ x: consuming SingleElt) { globalClosureCaptureConsuming = { borrowVal(x) - consumeVal(x) // expected-error {{noncopyable 'x' cannot be consumed when captured by a closure}} - consumeVal(x) // expected-error {{noncopyable 'x' cannot be consumed when captured by a closure}} - borrowConsumeVal(x, x) // expected-error {{noncopyable 'x' cannot be consumed when captured by a closure}} + consumeVal(x) // expected-error {{noncopyable 'x' cannot be consumed when captured by an escaping closure}} + consumeVal(x) // expected-error {{noncopyable 'x' cannot be consumed when captured by an escaping closure}} + borrowConsumeVal(x, x) // expected-error {{noncopyable 'x' cannot be consumed when captured by an escaping closure}} // expected-error @-1:29 {{overlapping accesses, but deinitialization requires exclusive access}} // expected-note @-2:26 {{conflicting access is here}} } @@ -963,9 +963,9 @@ func testLocalLetClosureCaptureConsuming(_ x: consuming SingleElt) { func testLocalLetClosureCaptureConsuming2(_ x: consuming SingleElt) -> (() -> ()) { let f = { borrowVal(x) - consumeVal(x) // expected-error {{noncopyable 'x' cannot be consumed when captured by a closure}} - consumeVal(x) // expected-error {{noncopyable 'x' cannot be consumed when captured by a closure}} - borrowConsumeVal(x, x) // expected-error {{noncopyable 'x' cannot be consumed when captured by a closure}} + consumeVal(x) // expected-error {{noncopyable 'x' cannot be consumed when captured by an escaping closure}} + consumeVal(x) // expected-error {{noncopyable 'x' cannot be consumed when captured by an escaping closure}} + borrowConsumeVal(x, x) // expected-error {{noncopyable 'x' cannot be consumed when captured by an escaping closure}} // expected-error @-1 {{overlapping accesses, but deinitialization requires exclusive access}} // expected-note @-2 {{conflicting access is here}} } @@ -1019,9 +1019,9 @@ func testLocalLetClosureCaptureConsuming2(_ x: consuming SingleElt) -> (() -> () func testLocalVarClosureCaptureConsuming(_ x: consuming SingleElt) { var f = { borrowVal(x) - consumeVal(x) // expected-error {{noncopyable 'x' cannot be consumed when captured by a closure}} - consumeVal(x) // expected-error {{noncopyable 'x' cannot be consumed when captured by a closure}} - borrowConsumeVal(x, x) // expected-error {{noncopyable 'x' cannot be consumed when captured by a closure}} + consumeVal(x) // expected-error {{noncopyable 'x' cannot be consumed when captured by an escaping closure}} + consumeVal(x) // expected-error {{noncopyable 'x' cannot be consumed when captured by an escaping closure}} + borrowConsumeVal(x, x) // expected-error {{noncopyable 'x' cannot be consumed when captured by an escaping closure}} // expected-error @-1 {{overlapping accesses, but deinitialization requires exclusive access}} // expected-note @-2 {{conflicting access is here}} } @@ -1087,9 +1087,9 @@ func testLocalVarClosureCaptureConsuming(_ x: consuming SingleElt) { func testConsumingEscapeClosureCaptureConsuming(_ f: consuming @escaping () -> (), _ x: consuming SingleElt) { f = { borrowVal(x) - consumeVal(x) // expected-error {{noncopyable 'x' cannot be consumed when captured by a closure}} - consumeVal(x) // expected-error {{noncopyable 'x' cannot be consumed when captured by a closure}} - borrowConsumeVal(x, x) // expected-error {{noncopyable 'x' cannot be consumed when captured by a closure}} + consumeVal(x) // expected-error {{noncopyable 'x' cannot be consumed when captured by an escaping closure}} + consumeVal(x) // expected-error {{noncopyable 'x' cannot be consumed when captured by an escaping closure}} + borrowConsumeVal(x, x) // expected-error {{noncopyable 'x' cannot be consumed when captured by an escaping closure}} // expected-error @-1 {{overlapping accesses, but deinitialization requires exclusive access}} // expected-note @-2 {{conflicting access is here}} } @@ -1139,9 +1139,9 @@ var globalClosureCaptureOwned: () -> () = {} func testGlobalClosureCaptureOwned(_ x: __owned SingleElt) { globalClosureCaptureOwned = { borrowVal(x) - consumeVal(x) // expected-error {{noncopyable 'x' cannot be consumed when captured by a closure}} - consumeVal(x) // expected-error {{noncopyable 'x' cannot be consumed when captured by a closure}} - borrowConsumeVal(x, x) // expected-error {{noncopyable 'x' cannot be consumed when captured by a closure}} + consumeVal(x) // expected-error {{noncopyable 'x' cannot be consumed when captured by an escaping closure}} + consumeVal(x) // expected-error {{noncopyable 'x' cannot be consumed when captured by an escaping closure}} + borrowConsumeVal(x, x) // expected-error {{noncopyable 'x' cannot be consumed when captured by an escaping closure}} } globalClosureCaptureOwned() } @@ -1182,9 +1182,9 @@ func testGlobalClosureCaptureOwned(_ x: __owned SingleElt) { // CHECK: apply {{%.*}}([[LOADED_READ]], [[LOADED_TAKE]]) // CHECK: } // end sil function '$s16moveonly_closure31testLocalLetClosureCaptureOwnedyyAA9SingleEltVnFyycfU_' func testLocalLetClosureCaptureOwned(_ x: __owned SingleElt) { - // expected-error @-1 {{noncopyable 'x' cannot be consumed when captured by a closure}} - // expected-error @-2 {{noncopyable 'x' cannot be consumed when captured by a closure}} - // expected-error @-3 {{noncopyable 'x' cannot be consumed when captured by a closure}} + // expected-error @-1 {{noncopyable 'x' cannot be consumed when captured by an escaping closure}} + // expected-error @-2 {{noncopyable 'x' cannot be consumed when captured by an escaping closure}} + // expected-error @-3 {{noncopyable 'x' cannot be consumed when captured by an escaping closure}} let f = { borrowVal(x) consumeVal(x) // expected-note {{consumed here}} @@ -1229,9 +1229,9 @@ func testLocalLetClosureCaptureOwned(_ x: __owned SingleElt) { func testLocalVarClosureCaptureOwned(_ x: __owned SingleElt) { var f = { borrowVal(x) - consumeVal(x) // expected-error {{noncopyable 'x' cannot be consumed when captured by a closure}} - consumeVal(x) // expected-error {{noncopyable 'x' cannot be consumed when captured by a closure}} - borrowConsumeVal(x, x) // expected-error {{noncopyable 'x' cannot be consumed when captured by a closure}} + consumeVal(x) // expected-error {{noncopyable 'x' cannot be consumed when captured by an escaping closure}} + consumeVal(x) // expected-error {{noncopyable 'x' cannot be consumed when captured by an escaping closure}} + borrowConsumeVal(x, x) // expected-error {{noncopyable 'x' cannot be consumed when captured by an escaping closure}} } f = {} f() @@ -1276,9 +1276,9 @@ func testLocalVarClosureCaptureOwned(_ x: __owned SingleElt) { func testInOutVarClosureCaptureOwned(_ f: inout () -> (), _ x: __owned SingleElt) { f = { borrowVal(x) - consumeVal(x) // expected-error {{noncopyable 'x' cannot be consumed when captured by a closure}} - consumeVal(x) // expected-error {{noncopyable 'x' cannot be consumed when captured by a closure}} - borrowConsumeVal(x, x) // expected-error {{noncopyable 'x' cannot be consumed when captured by a closure}} + consumeVal(x) // expected-error {{noncopyable 'x' cannot be consumed when captured by an escaping closure}} + consumeVal(x) // expected-error {{noncopyable 'x' cannot be consumed when captured by an escaping closure}} + borrowConsumeVal(x, x) // expected-error {{noncopyable 'x' cannot be consumed when captured by an escaping closure}} } f() } @@ -1332,9 +1332,9 @@ func testConsumingEscapeClosureCaptureOwned(_ f: consuming @escaping () -> (), _ x: __owned SingleElt) { f = { borrowVal(x) - consumeVal(x) // expected-error {{noncopyable 'x' cannot be consumed when captured by a closure}} - consumeVal(x) // expected-error {{noncopyable 'x' cannot be consumed when captured by a closure}} - borrowConsumeVal(x, x) // expected-error {{noncopyable 'x' cannot be consumed when captured by a closure}} + consumeVal(x) // expected-error {{noncopyable 'x' cannot be consumed when captured by an escaping closure}} + consumeVal(x) // expected-error {{noncopyable 'x' cannot be consumed when captured by an escaping closure}} + borrowConsumeVal(x, x) // expected-error {{noncopyable 'x' cannot be consumed when captured by an escaping closure}} } f() } @@ -1373,7 +1373,7 @@ func closureCoroutineAssignmentLetConsumingArgument(_ e: __owned Empty) { func closureCoroutineAssignmentVarConsumingArgument(_ e: consuming Empty) { let f: () -> () = { - _ = e // expected-error {{noncopyable 'e' cannot be consumed when captured by a closure}} + _ = e // expected-error {{noncopyable 'e' cannot be consumed when captured by an escaping closure}} } var c = ClosureHolder() c.fCoroutine = f @@ -1392,7 +1392,7 @@ func closureCoroutineAssignmentVarBinding() { var e = Empty() e = Empty() let f: () -> () = { - _ = e // expected-error {{noncopyable 'e' cannot be consumed when captured by a closure}} + _ = e // expected-error {{noncopyable 'e' cannot be consumed when captured by an escaping closure}} } var c = ClosureHolder() c.fCoroutine = f diff --git a/test/SILOptimizer/definite_init_moveonly_controlflowdep_init.sil b/test/SILOptimizer/definite_init_moveonly_controlflowdep_init.sil index f8030b7a933c7..fad9172ba0eec 100644 --- a/test/SILOptimizer/definite_init_moveonly_controlflowdep_init.sil +++ b/test/SILOptimizer/definite_init_moveonly_controlflowdep_init.sil @@ -119,7 +119,7 @@ bb3: %23 = apply %22(%21) : $@convention(thin) (@guaranteed S) -> () destroy_value %21 : $S %25 = mark_must_check [assignable_but_not_consumable] %3 : $*S - // expected-error @-1 {{noncopyable 's' cannot be consumed when captured by a closure}} + // expected-error @-1 {{noncopyable 's' cannot be consumed when captured by an escaping closure}} %26 = load [take] %25 : $*S %27 = function_ref @consumeVal : $@convention(thin) (@owned S) -> () %28 = apply %27(%26) : $@convention(thin) (@owned S) -> () diff --git a/test/SILOptimizer/moveonly_addresschecker_diagnostics.sil b/test/SILOptimizer/moveonly_addresschecker_diagnostics.sil index e9fd3072470aa..d8ab032f1d14e 100644 --- a/test/SILOptimizer/moveonly_addresschecker_diagnostics.sil +++ b/test/SILOptimizer/moveonly_addresschecker_diagnostics.sil @@ -359,7 +359,7 @@ bb0(%0 : @closureCapture @guaranteed $<τ_0_0 where τ_0_0 : P> { var AddressOnl end_access %12 : $*AddressOnlyGeneric %17 = begin_access [deinit] [dynamic] %1 : $*AddressOnlyGeneric %18 = mark_must_check [assignable_but_not_consumable] %17 : $*AddressOnlyGeneric - // expected-error @-1 {{noncopyable 'x' cannot be consumed when captured by a closure}} + // expected-error @-1 {{noncopyable 'x' cannot be consumed when captured by an escaping closure}} %19 = function_ref @addressOnlyGenericConsume : $@convention(thin) <τ_0_0 where τ_0_0 : P> (@in AddressOnlyGeneric<τ_0_0>) -> () %20 = apply %19(%18) : $@convention(thin) <τ_0_0 where τ_0_0 : P> (@in AddressOnlyGeneric<τ_0_0>) -> () end_access %17 : $*AddressOnlyGeneric @@ -528,4 +528,4 @@ bb0(%0 : @owned $NonTrivialStruct): dealloc_stack %1 : $*NonTrivialStruct %9999 = tuple() return %9999 : $() -} \ No newline at end of file +} diff --git a/test/SILOptimizer/moveonly_addresschecker_diagnostics.swift b/test/SILOptimizer/moveonly_addresschecker_diagnostics.swift index b8c06c599dcfc..ca449ab9416ab 100644 --- a/test/SILOptimizer/moveonly_addresschecker_diagnostics.swift +++ b/test/SILOptimizer/moveonly_addresschecker_diagnostics.swift @@ -3143,11 +3143,11 @@ func closureLetStoreClosureInVariableIsEscape() { let f = { borrowVal(s) - consumeVal(s) // expected-error {{noncopyable 's' cannot be consumed when captured by a closure}} + consumeVal(s) // expected-error {{noncopyable 's' cannot be consumed when captured by an escaping closure}} } let c = StoreClosure(f: f) _ = c - consumeVal(s) // expected-error {{noncopyable 's' cannot be consumed when captured by a closure}} + consumeVal(s) // expected-error {{noncopyable 's' cannot be consumed when captured by an escaping closure}} } ///////////////////////////// @@ -3202,8 +3202,8 @@ public func closureVarCaptureClassUseAfterConsume() { var f = {} f = { borrowVal(x2) - consumeVal(x2) // expected-error {{noncopyable 'x2' cannot be consumed when captured by a closure}} - consumeVal(x2) // expected-error {{noncopyable 'x2' cannot be consumed when captured by a closure}} + consumeVal(x2) // expected-error {{noncopyable 'x2' cannot be consumed when captured by an escaping closure}} + consumeVal(x2) // expected-error {{noncopyable 'x2' cannot be consumed when captured by an escaping closure}} } f() } @@ -3214,7 +3214,7 @@ public func closureVarCaptureClassUseAfterConsume2() { var f = {} f = { borrowVal(x2) - consumeVal(x2) // expected-error {{noncopyable 'x2' cannot be consumed when captured by a closure}} + consumeVal(x2) // expected-error {{noncopyable 'x2' cannot be consumed when captured by an escaping closure}} } f() } @@ -3225,12 +3225,12 @@ public func closureVarCaptureClassUseAfterConsumeError() { var f = {} f = { borrowVal(x2) - consumeVal(x2) // expected-error {{noncopyable 'x2' cannot be consumed when captured by a closure}} - consumeVal(x2) // expected-error {{noncopyable 'x2' cannot be consumed when captured by a closure}} + consumeVal(x2) // expected-error {{noncopyable 'x2' cannot be consumed when captured by an escaping closure}} + consumeVal(x2) // expected-error {{noncopyable 'x2' cannot be consumed when captured by an escaping closure}} } f() - consumeVal(x2) // expected-error {{noncopyable 'x2' cannot be consumed when captured by a closure}} - let x3 = x2 // expected-error {{noncopyable 'x2' cannot be consumed when captured by a closure}} + consumeVal(x2) // expected-error {{noncopyable 'x2' cannot be consumed when captured by an escaping closure}} + let x3 = x2 // expected-error {{noncopyable 'x2' cannot be consumed when captured by an escaping closure}} x2 = Klass() let _ = x3 } @@ -3458,7 +3458,7 @@ public func closureVarAndDeferCaptureClassUseAfterConsume2(_ x: borrowing Klass) x2 = x // expected-note {{consumed here}} var f = {} f = { - consumeVal(x2) // expected-error {{noncopyable 'x2' cannot be consumed when captured by a closure}} + consumeVal(x2) // expected-error {{noncopyable 'x2' cannot be consumed when captured by an escaping closure}} defer { borrowVal(x2) consumeVal(x2) // expected-note {{consumed here}} @@ -3479,7 +3479,7 @@ public func closureVarAndDeferCaptureClassUseAfterConsume3(_ x: borrowing Klass) // expected-note @-1 {{consumed here}} var f = {} f = { - consumeVal(x2) // expected-error {{noncopyable 'x2' cannot be consumed when captured by a closure}} + consumeVal(x2) // expected-error {{noncopyable 'x2' cannot be consumed when captured by an escaping closure}} defer { borrowVal(x2) consumeVal(x2) // expected-note {{consumed here}} @@ -3489,11 +3489,11 @@ public func closureVarAndDeferCaptureClassUseAfterConsume3(_ x: borrowing Klass) print("foo") } f() - consumeVal(x2) // expected-error {{noncopyable 'x2' cannot be consumed when captured by a closure}} + consumeVal(x2) // expected-error {{noncopyable 'x2' cannot be consumed when captured by an escaping closure}} } public func closureVarAndDeferCaptureClassArgUseAfterConsume(_ x2: borrowing Klass) { - // expected-error @-1 {{noncopyable 'x2' cannot be consumed when captured by a closure}} + // expected-error @-1 {{noncopyable 'x2' cannot be consumed when captured by an escaping closure}} // expected-error @-2 {{'x2' cannot be captured by an escaping closure since it is a borrowed parameter}} var f = {} f = {// expected-note {{closure capturing 'x2' here}} @@ -3508,7 +3508,7 @@ public func closureVarAndDeferCaptureClassArgUseAfterConsume(_ x2: borrowing Kla } public func closureVarAndDeferCaptureClassOwnedArgUseAfterConsume(_ x2: __owned Klass) { - // expected-error @-1 {{noncopyable 'x2' cannot be consumed when captured by a closure}} + // expected-error @-1 {{noncopyable 'x2' cannot be consumed when captured by an escaping closure}} var f = {} f = { defer { @@ -3539,7 +3539,7 @@ public func closureVarAndDeferCaptureClassOwnedArgUseAfterConsume2(_ x2: consumi // TODO: MG public func closureVarAndDeferCaptureClassOwnedArgUseAfterConsume3(_ x2: __owned Klass) { - // expected-error @-1 {{noncopyable 'x2' cannot be consumed when captured by a closure}} + // expected-error @-1 {{noncopyable 'x2' cannot be consumed when captured by an escaping closure}} var f = {} f = { defer { @@ -3550,7 +3550,7 @@ public func closureVarAndDeferCaptureClassOwnedArgUseAfterConsume3(_ x2: __owned print("foo") } f() - consumeVal(x2) // expected-error {{noncopyable 'x2' cannot be consumed when captured by a closure}} + consumeVal(x2) // expected-error {{noncopyable 'x2' cannot be consumed when captured by an escaping closure}} } public func closureVarAndDeferCaptureClassOwnedArgUseAfterConsume4(_ x2: consuming Klass) { @@ -3567,7 +3567,7 @@ public func closureVarAndDeferCaptureClassOwnedArgUseAfterConsume4(_ x2: consumi print("foo") } f() - consumeVal(x2) // expected-error {{noncopyable 'x2' cannot be consumed when captured by a closure}} + consumeVal(x2) // expected-error {{noncopyable 'x2' cannot be consumed when captured by an escaping closure}} } /////////////////////////////////////////// @@ -3582,11 +3582,11 @@ public func closureVarAndClosureCaptureClassUseAfterConsume(_ x: borrowing Klass var g = {} g = { borrowVal(x2) - consumeVal(x2) // expected-error {{noncopyable 'x2' cannot be consumed when captured by a closure}} - consumeVal(x2) // expected-error {{noncopyable 'x2' cannot be consumed when captured by a closure}} + consumeVal(x2) // expected-error {{noncopyable 'x2' cannot be consumed when captured by an escaping closure}} + consumeVal(x2) // expected-error {{noncopyable 'x2' cannot be consumed when captured by an escaping closure}} } g() - consumeVal(x2) // expected-error {{noncopyable 'x2' cannot be consumed when captured by a closure}} + consumeVal(x2) // expected-error {{noncopyable 'x2' cannot be consumed when captured by an escaping closure}} } f() } @@ -3601,14 +3601,14 @@ public func closureVarAndClosureCaptureClassUseAfterConsume2(_ x: borrowing Klas var g = {} g = { borrowVal(x2) - consumeVal(x2) // expected-error {{noncopyable 'x2' cannot be consumed when captured by a closure}} - consumeVal(x2) // expected-error {{noncopyable 'x2' cannot be consumed when captured by a closure}} + consumeVal(x2) // expected-error {{noncopyable 'x2' cannot be consumed when captured by an escaping closure}} + consumeVal(x2) // expected-error {{noncopyable 'x2' cannot be consumed when captured by an escaping closure}} } g() } f() - consumeVal(x2) // expected-error {{noncopyable 'x2' cannot be consumed when captured by a closure}} - let x3 = x2 // expected-error {{noncopyable 'x2' cannot be consumed when captured by a closure}} + consumeVal(x2) // expected-error {{noncopyable 'x2' cannot be consumed when captured by an escaping closure}} + let x3 = x2 // expected-error {{noncopyable 'x2' cannot be consumed when captured by an escaping closure}} _ = x3 } @@ -3623,19 +3623,19 @@ public func closureVarAndClosureCaptureClassUseAfterConsume3(_ x: borrowing Klas var g = {} g = { borrowVal(x2) - consumeVal(x2) // expected-error {{noncopyable 'x2' cannot be consumed when captured by a closure}} - consumeVal(x2) // expected-error {{noncopyable 'x2' cannot be consumed when captured by a closure}} + consumeVal(x2) // expected-error {{noncopyable 'x2' cannot be consumed when captured by an escaping closure}} + consumeVal(x2) // expected-error {{noncopyable 'x2' cannot be consumed when captured by an escaping closure}} } g() } f() - consumeVal(x2) // expected-error {{noncopyable 'x2' cannot be consumed when captured by a closure}} - let x3 = x2 // expected-error {{noncopyable 'x2' cannot be consumed when captured by a closure}} + consumeVal(x2) // expected-error {{noncopyable 'x2' cannot be consumed when captured by an escaping closure}} + let x3 = x2 // expected-error {{noncopyable 'x2' cannot be consumed when captured by an escaping closure}} _ = x3 } public func closureVarAndClosureCaptureClassArgUseAfterConsume(_ x2: borrowing Klass) { - // expected-error @-1 {{noncopyable 'x2' cannot be consumed when captured by a closure}} + // expected-error @-1 {{noncopyable 'x2' cannot be consumed when captured by an escaping closure}} // expected-error @-2 {{'x2' cannot be captured by an escaping closure since it is a borrowed parameter}} // expected-error @-3 {{'x2' cannot be captured by an escaping closure since it is a borrowed parameter}} var f = {} @@ -3657,8 +3657,8 @@ public func closureVarAndClosureCaptureClassOwnedArgUseAfterConsume(_ x2: __owne var g = {} g = { borrowVal(x2) - consumeVal(x2) // expected-error {{noncopyable 'x2' cannot be consumed when captured by a closure}} - consumeVal(x2) // expected-error {{noncopyable 'x2' cannot be consumed when captured by a closure}} + consumeVal(x2) // expected-error {{noncopyable 'x2' cannot be consumed when captured by an escaping closure}} + consumeVal(x2) // expected-error {{noncopyable 'x2' cannot be consumed when captured by an escaping closure}} } g() } @@ -3671,8 +3671,8 @@ public func closureVarAndClosureCaptureClassOwnedArgUseAfterConsume2(_ x2: consu var g = {} g = { borrowVal(x2) - consumeVal(x2) // expected-error {{noncopyable 'x2' cannot be consumed when captured by a closure}} - consumeVal(x2) // expected-error {{noncopyable 'x2' cannot be consumed when captured by a closure}} + consumeVal(x2) // expected-error {{noncopyable 'x2' cannot be consumed when captured by an escaping closure}} + consumeVal(x2) // expected-error {{noncopyable 'x2' cannot be consumed when captured by an escaping closure}} } g() } @@ -3685,13 +3685,13 @@ public func closureVarAndClosureCaptureClassOwnedArgUseAfterConsume3(_ x2: __own var g = {} g = { borrowVal(x2) - consumeVal(x2) // expected-error {{noncopyable 'x2' cannot be consumed when captured by a closure}} - consumeVal(x2) // expected-error {{noncopyable 'x2' cannot be consumed when captured by a closure}} + consumeVal(x2) // expected-error {{noncopyable 'x2' cannot be consumed when captured by an escaping closure}} + consumeVal(x2) // expected-error {{noncopyable 'x2' cannot be consumed when captured by an escaping closure}} } g() } f() - consumeVal(x2) // expected-error {{noncopyable 'x2' cannot be consumed when captured by a closure}} + consumeVal(x2) // expected-error {{noncopyable 'x2' cannot be consumed when captured by an escaping closure}} } public func closureVarAndClosureCaptureClassOwnedArgUseAfterConsume4(_ x2: consuming Klass) { @@ -3700,13 +3700,13 @@ public func closureVarAndClosureCaptureClassOwnedArgUseAfterConsume4(_ x2: consu var g = {} g = { borrowVal(x2) - consumeVal(x2) // expected-error {{noncopyable 'x2' cannot be consumed when captured by a closure}} - consumeVal(x2) // expected-error {{noncopyable 'x2' cannot be consumed when captured by a closure}} + consumeVal(x2) // expected-error {{noncopyable 'x2' cannot be consumed when captured by an escaping closure}} + consumeVal(x2) // expected-error {{noncopyable 'x2' cannot be consumed when captured by an escaping closure}} } g() } f() - consumeVal(x2) // expected-error {{noncopyable 'x2' cannot be consumed when captured by a closure}} + consumeVal(x2) // expected-error {{noncopyable 'x2' cannot be consumed when captured by an escaping closure}} } ///////////////////////////// @@ -4106,14 +4106,14 @@ func inoutCaptureTest() -> (() -> ()) { borrowVal(x) consumeVal(x) - // expected-error @-1 {{noncopyable 'x' cannot be consumed when captured by a closure}} + // expected-error @-1 {{noncopyable 'x' cannot be consumed when captured by an escaping closure}} x = NonTrivialStruct() let g = { x = NonTrivialStruct() useInOut(&x) consumeVal(x) - // expected-error @-1 {{noncopyable 'x' cannot be consumed when captured by a closure}} + // expected-error @-1 {{noncopyable 'x' cannot be consumed when captured by an escaping closure}} } g() @@ -4130,13 +4130,13 @@ func inoutCaptureTestAddressOnlyGeneric(_ t: T.Type) -> (() -> ()) { } borrowVal(x) - consumeVal(x) // expected-error {{noncopyable 'x' cannot be consumed when captured by a closure}} + consumeVal(x) // expected-error {{noncopyable 'x' cannot be consumed when captured by an escaping closure}} x = AddressOnlyGeneric() let g = { x = AddressOnlyGeneric() useInOut(&x) - consumeVal(x) // expected-error {{noncopyable 'x' cannot be consumed when captured by a closure}} + consumeVal(x) // expected-error {{noncopyable 'x' cannot be consumed when captured by an escaping closure}} } g() diff --git a/test/SILOptimizer/moveonly_nonescaping_closures.swift b/test/SILOptimizer/moveonly_nonescaping_closures.swift index 311b16701c7b7..3d37a81ae36cc 100644 --- a/test/SILOptimizer/moveonly_nonescaping_closures.swift +++ b/test/SILOptimizer/moveonly_nonescaping_closures.swift @@ -77,7 +77,7 @@ func c2(x: consuming M) { consume(x) } -func d(x: __owned M) { // expected-error {{noncopyable 'x' cannot be consumed when captured by a closure}} +func d(x: __owned M) { // expected-error {{noncopyable 'x' cannot be consumed when captured by an escaping closure}} clodger({ consume(x) }) // expected-note @-1 {{consumed here}} } diff --git a/test/SILOptimizer/moveonly_objectchecker_diagnostics.swift b/test/SILOptimizer/moveonly_objectchecker_diagnostics.swift index 08a73a77e080f..9146484efc167 100644 --- a/test/SILOptimizer/moveonly_objectchecker_diagnostics.swift +++ b/test/SILOptimizer/moveonly_objectchecker_diagnostics.swift @@ -2732,7 +2732,7 @@ public func enumPatternMatchSwitch2WhereClause2OwnedArg2(_ x2: consuming EnumTy) public func closureLetClassUseAfterConsume1(_ x: borrowing Klass) { // expected-error @-1 {{'x' cannot be captured by an escaping closure since it is a borrowed parameter}} - // expected-error @-2 {{noncopyable 'x' cannot be consumed when captured by a closure}} + // expected-error @-2 {{noncopyable 'x' cannot be consumed when captured by an escaping closure}} let f = { // expected-note {{closure capturing 'x' here}} let x2 = x // expected-error {{'x2' consumed more than once}} // expected-note @-1 {{consumed here}} @@ -2764,8 +2764,8 @@ public func closureLetClassUseAfterConsumeArg(_ argX: borrowing Klass) { } public func closureLetCaptureClassUseAfterConsume(_ x: consuming Klass) { - let x2 = x // expected-error {{noncopyable 'x2' cannot be consumed when captured by a closure}} - // expected-error @-1 {{noncopyable 'x2' cannot be consumed when captured by a closure}} + let x2 = x // expected-error {{noncopyable 'x2' cannot be consumed when captured by an escaping closure}} + // expected-error @-1 {{noncopyable 'x2' cannot be consumed when captured by an escaping closure}} let f = { borrowVal(x2) consumeVal(x2) // expected-note {{consumed here}} @@ -2816,8 +2816,8 @@ public func closureLetCaptureClassUseAfterConsume3(_ x2: inout Klass) { public func closureLetCaptureClassUseAfterConsumeError(_ x: borrowing Klass) { // expected-error {{'x' is borrowed and cannot be consumed}} let x2 = x // expected-note {{consumed here}} - // expected-error @-1 {{noncopyable 'x2' cannot be consumed when captured by a closure}} - // expected-error @-2 {{noncopyable 'x2' cannot be consumed when captured by a closure}} + // expected-error @-1 {{noncopyable 'x2' cannot be consumed when captured by an escaping closure}} + // expected-error @-2 {{noncopyable 'x2' cannot be consumed when captured by an escaping closure}} let f = { borrowVal(x2) consumeVal(x2) // expected-note {{consumed here}} @@ -2829,7 +2829,7 @@ public func closureLetCaptureClassUseAfterConsumeError(_ x: borrowing Klass) { / } public func closureLetCaptureClassArgUseAfterConsume(_ x2: borrowing Klass) { - // expected-error @-1 {{noncopyable 'x2' cannot be consumed when captured by a closure}} + // expected-error @-1 {{noncopyable 'x2' cannot be consumed when captured by an escaping closure}} // expected-error @-2 {{'x2' cannot be captured by an escaping closure since it is a borrowed parameter}} let f = { // expected-note {{closure capturing 'x2' here}} borrowVal(x2) @@ -2840,8 +2840,8 @@ public func closureLetCaptureClassArgUseAfterConsume(_ x2: borrowing Klass) { } public func closureLetCaptureClassOwnedArgUseAfterConsume(_ x2: __owned Klass) { - // expected-error @-1 {{noncopyable 'x2' cannot be consumed when captured by a closure}} - // expected-error @-2 {{noncopyable 'x2' cannot be consumed when captured by a closure}} + // expected-error @-1 {{noncopyable 'x2' cannot be consumed when captured by an escaping closure}} + // expected-error @-2 {{noncopyable 'x2' cannot be consumed when captured by an escaping closure}} let f = { borrowVal(x2) consumeVal(x2) // expected-note {{consumed here}} @@ -2863,8 +2863,8 @@ public func closureLetCaptureClassOwnedArgUseAfterConsume2(_ x2: consuming Klass } public func closureLetCaptureClassOwnedArgUseAfterConsume3(_ x2: __owned Klass) { - // expected-error @-1 {{noncopyable 'x2' cannot be consumed when captured by a closure}} - // expected-error @-2 {{noncopyable 'x2' cannot be consumed when captured by a closure}} + // expected-error @-1 {{noncopyable 'x2' cannot be consumed when captured by an escaping closure}} + // expected-error @-2 {{noncopyable 'x2' cannot be consumed when captured by an escaping closure}} let f = { borrowVal(x2) consumeVal(x2) // expected-note {{consumed here}} @@ -2898,7 +2898,7 @@ public func closureLetCaptureClassOwnedArgUseAfterConsume4(_ x2: consuming Klass public func closureVarClassUseAfterConsume1(_ x: borrowing Klass) { // expected-error @-1 {{'x' cannot be captured by an escaping closure since it is a borrowed parameter}} - // expected-error @-2 {{noncopyable 'x' cannot be consumed when captured by a closure}} + // expected-error @-2 {{noncopyable 'x' cannot be consumed when captured by an escaping closure}} var f = {} f = { // expected-note {{closure capturing 'x' here}} let x2 = x // expected-error {{'x2' consumed more than once}} @@ -2937,8 +2937,8 @@ public func closureVarCaptureClassUseAfterConsume(_ x: borrowing Klass) { // exp var f = {} f = { borrowVal(x2) - consumeVal(x2) // expected-error {{noncopyable 'x2' cannot be consumed when captured by a closure}} - consumeVal(x2) // expected-error {{noncopyable 'x2' cannot be consumed when captured by a closure}} + consumeVal(x2) // expected-error {{noncopyable 'x2' cannot be consumed when captured by an escaping closure}} + consumeVal(x2) // expected-error {{noncopyable 'x2' cannot be consumed when captured by an escaping closure}} } f() } @@ -2950,8 +2950,8 @@ public func closureVarCaptureClassUseAfterConsume1(_ x: borrowing Klass) { // ex var f = {} f = { borrowVal(x2) - consumeVal(x2) // expected-error {{noncopyable 'x2' cannot be consumed when captured by a closure}} - consumeVal(x2) // expected-error {{noncopyable 'x2' cannot be consumed when captured by a closure}} + consumeVal(x2) // expected-error {{noncopyable 'x2' cannot be consumed when captured by an escaping closure}} + consumeVal(x2) // expected-error {{noncopyable 'x2' cannot be consumed when captured by an escaping closure}} } f() } @@ -2997,16 +2997,16 @@ public func closureVarCaptureClassUseAfterConsumeError(_ x: borrowing Klass) { / var f = {} f = { borrowVal(x2) - consumeVal(x2) // expected-error {{noncopyable 'x2' cannot be consumed when captured by a closure}} - consumeVal(x2) // expected-error {{noncopyable 'x2' cannot be consumed when captured by a closure}} + consumeVal(x2) // expected-error {{noncopyable 'x2' cannot be consumed when captured by an escaping closure}} + consumeVal(x2) // expected-error {{noncopyable 'x2' cannot be consumed when captured by an escaping closure}} } f() - let x3 = x2 // expected-error {{noncopyable 'x2' cannot be consumed when captured by a closure}} + let x3 = x2 // expected-error {{noncopyable 'x2' cannot be consumed when captured by an escaping closure}} let _ = x3 } public func closureVarCaptureClassArgUseAfterConsume(_ x2: borrowing Klass) { - // expected-error @-1 {{noncopyable 'x2' cannot be consumed when captured by a closure}} + // expected-error @-1 {{noncopyable 'x2' cannot be consumed when captured by an escaping closure}} // expected-error @-2 {{'x2' cannot be captured by an escaping closure since it is a borrowed parameter}} var f = {} f = { // expected-note {{closure capturing 'x2' here}} @@ -3021,8 +3021,8 @@ public func closureVarCaptureClassOwnedArgUseAfterConsume(_ x2: __owned Klass) { var f = {} f = { borrowVal(x2) - consumeVal(x2) // expected-error {{noncopyable 'x2' cannot be consumed when captured by a closure}} - consumeVal(x2) // expected-error {{noncopyable 'x2' cannot be consumed when captured by a closure}} + consumeVal(x2) // expected-error {{noncopyable 'x2' cannot be consumed when captured by an escaping closure}} + consumeVal(x2) // expected-error {{noncopyable 'x2' cannot be consumed when captured by an escaping closure}} } f() } @@ -3031,8 +3031,8 @@ public func closureVarCaptureClassOwnedArgUseAfterConsume2(_ x2: consuming Klass var f = {} f = { borrowVal(x2) - consumeVal(x2) // expected-error {{noncopyable 'x2' cannot be consumed when captured by a closure}} - consumeVal(x2) // expected-error {{noncopyable 'x2' cannot be consumed when captured by a closure}} + consumeVal(x2) // expected-error {{noncopyable 'x2' cannot be consumed when captured by an escaping closure}} + consumeVal(x2) // expected-error {{noncopyable 'x2' cannot be consumed when captured by an escaping closure}} } f() } @@ -3041,11 +3041,11 @@ public func closureVarCaptureClassOwnedArgUseAfterConsume3(_ x2: __owned Klass) var f = {} f = { borrowVal(x2) - consumeVal(x2) // expected-error {{noncopyable 'x2' cannot be consumed when captured by a closure}} - consumeVal(x2) // expected-error {{noncopyable 'x2' cannot be consumed when captured by a closure}} + consumeVal(x2) // expected-error {{noncopyable 'x2' cannot be consumed when captured by an escaping closure}} + consumeVal(x2) // expected-error {{noncopyable 'x2' cannot be consumed when captured by an escaping closure}} } f() - let x3 = x2 // expected-error {{noncopyable 'x2' cannot be consumed when captured by a closure}} + let x3 = x2 // expected-error {{noncopyable 'x2' cannot be consumed when captured by an escaping closure}} let _ = x3 } @@ -3053,12 +3053,12 @@ public func closureVarCaptureClassOwnedArgUseAfterConsume4(_ x2: consuming Klass var f = {} f = { borrowVal(x2) - consumeVal(x2) // expected-error {{noncopyable 'x2' cannot be consumed when captured by a closure}} - consumeVal(x2) // expected-error {{noncopyable 'x2' cannot be consumed when captured by a closure}} + consumeVal(x2) // expected-error {{noncopyable 'x2' cannot be consumed when captured by an escaping closure}} + consumeVal(x2) // expected-error {{noncopyable 'x2' cannot be consumed when captured by an escaping closure}} } f() - let x3 = x2 // expected-error {{noncopyable 'x2' cannot be consumed when captured by a closure}} - consumeVal(x2) // expected-error {{noncopyable 'x2' cannot be consumed when captured by a closure}} + let x3 = x2 // expected-error {{noncopyable 'x2' cannot be consumed when captured by an escaping closure}} + consumeVal(x2) // expected-error {{noncopyable 'x2' cannot be consumed when captured by an escaping closure}} x2 = Klass() let _ = x3 } @@ -3069,7 +3069,7 @@ public func closureVarCaptureClassOwnedArgUseAfterConsume4(_ x2: consuming Klass public func deferCaptureClassUseAfterConsume(_ x: borrowing Klass) { // expected-error {{'x' is borrowed and cannot be consumed}} let x2 = x // expected-note {{consumed here}} - // expected-error @-1 {{noncopyable 'x2' cannot be consumed when captured by a closure}} + // expected-error @-1 {{noncopyable 'x2' cannot be consumed when captured by an escaping closure}} defer { borrowVal(x2) // TODO: Defer can only run once, so this error shouldn't occur. @@ -3082,7 +3082,7 @@ public func deferCaptureClassUseAfterConsume(_ x: borrowing Klass) { // expected public func deferCaptureClassUseAfterConsume2(_ x: borrowing Klass) { // expected-error {{'x' is borrowed and cannot be consumed}} let x2 = x // expected-note @-1 {{consumed here}} - // expected-error @-2 {{noncopyable 'x2' cannot be consumed when captured by a closure}} + // expected-error @-2 {{noncopyable 'x2' cannot be consumed when captured by an escaping closure}} // expected-error @-3 {{'x2' used after consume}} defer { // expected-note {{used here}} borrowVal(x2) @@ -3094,7 +3094,7 @@ public func deferCaptureClassUseAfterConsume2(_ x: borrowing Klass) { // expecte } public func deferCaptureClassArgUseAfterConsume(_ x2: borrowing Klass) { - // expected-error @-1 {{noncopyable 'x2' cannot be consumed when captured by a closure}} + // expected-error @-1 {{noncopyable 'x2' cannot be consumed when captured by an escaping closure}} borrowVal(x2) defer { borrowVal(x2) @@ -3105,7 +3105,7 @@ public func deferCaptureClassArgUseAfterConsume(_ x2: borrowing Klass) { } public func deferCaptureClassOwnedArgUseAfterConsume(_ x2: __owned Klass) { - // expected-error @-1 {{noncopyable 'x2' cannot be consumed when captured by a closure}} + // expected-error @-1 {{noncopyable 'x2' cannot be consumed when captured by an escaping closure}} defer { borrowVal(x2) consumeVal(x2) // expected-note {{consumed here}} @@ -3127,7 +3127,7 @@ public func deferCaptureClassOwnedArgUseAfterConsume2(_ x2: consuming Klass) { } public func deferCaptureClassOwnedArgUseAfterConsume3(_ x2: __owned Klass) { - // expected-error @-1 {{noncopyable 'x2' cannot be consumed when captured by a closure}} + // expected-error @-1 {{noncopyable 'x2' cannot be consumed when captured by an escaping closure}} // expected-error @-2 {{'x2' used after consume}} defer { // expected-note {{used here}} borrowVal(x2) @@ -3156,7 +3156,7 @@ public func deferCaptureClassOwnedArgUseAfterConsume4(_ x2: consuming Klass) { public func closureLetAndDeferCaptureClassUseAfterConsume(_ x: borrowing Klass) { // expected-error {{'x' is borrowed and cannot be consumed}} let x2 = x // expected-note {{consumed here}} - // expected-error @-1 {{noncopyable 'x2' cannot be consumed when captured by a closure}} + // expected-error @-1 {{noncopyable 'x2' cannot be consumed when captured by an escaping closure}} let f = { defer { borrowVal(x2) @@ -3170,9 +3170,9 @@ public func closureLetAndDeferCaptureClassUseAfterConsume(_ x: borrowing Klass) public func closureLetAndDeferCaptureClassUseAfterConsume2(_ x: borrowing Klass) { // expected-error {{'x' is borrowed and cannot be consumed}} // TODO: This is wrong - let x2 = x // expected-error {{noncopyable 'x2' cannot be consumed when captured by a closure}} + let x2 = x // expected-error {{noncopyable 'x2' cannot be consumed when captured by an escaping closure}} // expected-note @-1 {{consumed here}} - // expected-error @-2 {{noncopyable 'x2' cannot be consumed when captured by a closure}} + // expected-error @-2 {{noncopyable 'x2' cannot be consumed when captured by an escaping closure}} let f = { consumeVal(x2) // expected-note {{consumed here}} defer { @@ -3189,8 +3189,8 @@ public func closureLetAndDeferCaptureClassUseAfterConsume2(_ x: borrowing Klass) public func closureLetAndDeferCaptureClassUseAfterConsume3(_ x: borrowing Klass) { // expected-error {{'x' is borrowed and cannot be consumed}} let x2 = x // expected-note @-1 {{consumed here}} - // expected-error @-2 {{noncopyable 'x2' cannot be consumed when captured by a closure}} - // expected-error @-3 {{noncopyable 'x2' cannot be consumed when captured by a closure}} + // expected-error @-2 {{noncopyable 'x2' cannot be consumed when captured by an escaping closure}} + // expected-error @-3 {{noncopyable 'x2' cannot be consumed when captured by an escaping closure}} let f = { consumeVal(x2) // expected-note {{consumed here}} defer { @@ -3205,7 +3205,7 @@ public func closureLetAndDeferCaptureClassUseAfterConsume3(_ x: borrowing Klass) } public func closureLetAndDeferCaptureClassArgUseAfterConsume(_ x2: borrowing Klass) { - // expected-error @-1 {{noncopyable 'x2' cannot be consumed when captured by a closure}} + // expected-error @-1 {{noncopyable 'x2' cannot be consumed when captured by an escaping closure}} // expected-error @-2 {{'x2' cannot be captured by an escaping closure since it is a borrowed parameter}} let f = { // expected-note {{closure capturing 'x2' here}} defer { @@ -3219,7 +3219,7 @@ public func closureLetAndDeferCaptureClassArgUseAfterConsume(_ x2: borrowing Kla } public func closureLetAndDeferCaptureClassOwnedArgUseAfterConsume(_ x2: __owned Klass) { - // expected-error @-1 {{noncopyable 'x2' cannot be consumed when captured by a closure}} + // expected-error @-1 {{noncopyable 'x2' cannot be consumed when captured by an escaping closure}} let f = { defer { borrowVal(x2) @@ -3248,7 +3248,7 @@ public func closureLetAndDeferCaptureClassOwnedArgUseAfterConsume2(_ x2: consumi // TODO: MG public func closureLetAndDeferCaptureClassOwnedArgUseAfterConsume3(_ x2: __owned Klass) { - // expected-error @-1 {{noncopyable 'x2' cannot be consumed when captured by a closure}} + // expected-error @-1 {{noncopyable 'x2' cannot be consumed when captured by an escaping closure}} let f = { defer { borrowVal(x2) @@ -3283,8 +3283,8 @@ public func closureLetAndDeferCaptureClassOwnedArgUseAfterConsume4(_ x2: consumi public func closureLetAndClosureCaptureClassUseAfterConsume(_ x: borrowing Klass) { // expected-error {{'x' is borrowed and cannot be consumed}} let x2 = x // expected-note {{consumed here}} - // expected-error @-1 {{noncopyable 'x2' cannot be consumed when captured by a closure}} - // expected-error @-2 {{noncopyable 'x2' cannot be consumed when captured by a closure}} + // expected-error @-1 {{noncopyable 'x2' cannot be consumed when captured by an escaping closure}} + // expected-error @-2 {{noncopyable 'x2' cannot be consumed when captured by an escaping closure}} let f = { let g = { borrowVal(x2) @@ -3299,8 +3299,8 @@ public func closureLetAndClosureCaptureClassUseAfterConsume(_ x: borrowing Klass public func closureLetAndClosureCaptureClassUseAfterConsume2(_ x: borrowing Klass) { // expected-error {{'x' is borrowed and cannot be consumed}} let x2 = x // expected-note @-1 {{consumed here}} - // expected-error @-2 {{noncopyable 'x2' cannot be consumed when captured by a closure}} - // expected-error @-3 {{noncopyable 'x2' cannot be consumed when captured by a closure}} + // expected-error @-2 {{noncopyable 'x2' cannot be consumed when captured by an escaping closure}} + // expected-error @-3 {{noncopyable 'x2' cannot be consumed when captured by an escaping closure}} // expected-error @-4 {{'x2' consumed more than once}} let f = { @@ -3342,7 +3342,7 @@ public func closureLetAndClosureCaptureClassUseAfterConsume3(_ x: borrowing Klas } public func closureLetAndClosureCaptureClassArgUseAfterConsume(_ x2: borrowing Klass) { - // expected-error @-1 {{noncopyable 'x2' cannot be consumed when captured by a closure}} + // expected-error @-1 {{noncopyable 'x2' cannot be consumed when captured by an escaping closure}} // expected-error @-2 {{'x2' cannot be captured by an escaping closure since it is a borrowed parameter}} // expected-error @-3 {{'x2' cannot be captured by an escaping closure since it is a borrowed parameter}} let f = { // expected-note {{closure capturing 'x2' here}} @@ -3357,8 +3357,8 @@ public func closureLetAndClosureCaptureClassArgUseAfterConsume(_ x2: borrowing K } public func closureLetAndClosureCaptureClassOwnedArgUseAfterConsume(_ x2: __owned Klass) { - // expected-error @-1 {{noncopyable 'x2' cannot be consumed when captured by a closure}} - // expected-error @-2 {{noncopyable 'x2' cannot be consumed when captured by a closure}} + // expected-error @-1 {{noncopyable 'x2' cannot be consumed when captured by an escaping closure}} + // expected-error @-2 {{noncopyable 'x2' cannot be consumed when captured by an escaping closure}} let f = { let g = { borrowVal(x2) @@ -3386,8 +3386,8 @@ public func closureLetAndClosureCaptureClassOwnedArgUseAfterConsume2(_ x2: consu } public func closureLetAndClosureCaptureClassOwnedArgUseAfterConsume3(_ x2: __owned Klass) { - // expected-error @-1 {{noncopyable 'x2' cannot be consumed when captured by a closure}} - // expected-error @-2 {{noncopyable 'x2' cannot be consumed when captured by a closure}} + // expected-error @-1 {{noncopyable 'x2' cannot be consumed when captured by an escaping closure}} + // expected-error @-2 {{noncopyable 'x2' cannot be consumed when captured by an escaping closure}} let f = { let g = { borrowVal(x2) @@ -3440,7 +3440,7 @@ public func closureLetAndClosureCaptureClassOwnedArgUseAfterConsume5(_ x2: consu public func closureVarAndDeferCaptureClassUseAfterConsume(_ x: borrowing Klass) { // expected-error {{'x' is borrowed and cannot be consumed}} let x2 = x // expected-note {{consumed here}} - // expected-error @-1 {{noncopyable 'x2' cannot be consumed when captured by a closure}} + // expected-error @-1 {{noncopyable 'x2' cannot be consumed when captured by an escaping closure}} var f = {} f = { defer { @@ -3454,11 +3454,11 @@ public func closureVarAndDeferCaptureClassUseAfterConsume(_ x: borrowing Klass) } public func closureVarAndDeferCaptureClassUseAfterConsume2(_ x: borrowing Klass) { // expected-error {{'x' is borrowed and cannot be consumed}} - let x2 = x // expected-error {{noncopyable 'x2' cannot be consumed when captured by a closure}} + let x2 = x // expected-error {{noncopyable 'x2' cannot be consumed when captured by an escaping closure}} // expected-note @-1 {{consumed here}} var f = {} f = { - consumeVal(x2) // expected-error {{noncopyable 'x2' cannot be consumed when captured by a closure}} + consumeVal(x2) // expected-error {{noncopyable 'x2' cannot be consumed when captured by an escaping closure}} defer { borrowVal(x2) consumeVal(x2) // expected-note {{consumed here}} @@ -3473,10 +3473,10 @@ public func closureVarAndDeferCaptureClassUseAfterConsume2(_ x: borrowing Klass) public func closureVarAndDeferCaptureClassUseAfterConsume3(_ x: borrowing Klass) { // expected-error {{'x' is borrowed and cannot be consumed}} let x2 = x // expected-note @-1 {{consumed here}} - // expected-error @-2 {{noncopyable 'x2' cannot be consumed when captured by a closure}} + // expected-error @-2 {{noncopyable 'x2' cannot be consumed when captured by an escaping closure}} var f = {} f = { - consumeVal(x2) // expected-error {{noncopyable 'x2' cannot be consumed when captured by a closure}} + consumeVal(x2) // expected-error {{noncopyable 'x2' cannot be consumed when captured by an escaping closure}} defer { borrowVal(x2) consumeVal(x2) // expected-note {{consumed here}} @@ -3485,11 +3485,11 @@ public func closureVarAndDeferCaptureClassUseAfterConsume3(_ x: borrowing Klass) print("foo") } f() - consumeVal(x2) // expected-error {{noncopyable 'x2' cannot be consumed when captured by a closure}} + consumeVal(x2) // expected-error {{noncopyable 'x2' cannot be consumed when captured by an escaping closure}} } public func closureVarAndDeferCaptureClassArgUseAfterConsume(_ x2: borrowing Klass) { - // expected-error @-1 {{noncopyable 'x2' cannot be consumed when captured by a closure}} + // expected-error @-1 {{noncopyable 'x2' cannot be consumed when captured by an escaping closure}} // expected-error @-2 {{'x2' cannot be captured by an escaping closure since it is a borrowed parameter}} var f = {} f = {// expected-note {{closure capturing 'x2' here}} @@ -3504,7 +3504,7 @@ public func closureVarAndDeferCaptureClassArgUseAfterConsume(_ x2: borrowing Kla } public func closureVarAndDeferCaptureClassOwnedArgUseAfterConsume(_ x2: __owned Klass) { - // expected-error @-1 {{noncopyable 'x2' cannot be consumed when captured by a closure}} + // expected-error @-1 {{noncopyable 'x2' cannot be consumed when captured by an escaping closure}} var f = {} f = { defer { @@ -3535,7 +3535,7 @@ public func closureVarAndDeferCaptureClassOwnedArgUseAfterConsume2(_ x2: consumi // TODO: MG public func closureVarAndDeferCaptureClassOwnedArgUseAfterConsume3(_ x2: __owned Klass) { - // expected-error @-1 {{noncopyable 'x2' cannot be consumed when captured by a closure}} + // expected-error @-1 {{noncopyable 'x2' cannot be consumed when captured by an escaping closure}} var f = {} f = { defer { @@ -3546,7 +3546,7 @@ public func closureVarAndDeferCaptureClassOwnedArgUseAfterConsume3(_ x2: __owned print("foo") } f() - consumeVal(x2) // expected-error {{noncopyable 'x2' cannot be consumed when captured by a closure}} + consumeVal(x2) // expected-error {{noncopyable 'x2' cannot be consumed when captured by an escaping closure}} } public func closureVarAndDeferCaptureClassOwnedArgUseAfterConsume4(_ x2: consuming Klass) { @@ -3563,7 +3563,7 @@ public func closureVarAndDeferCaptureClassOwnedArgUseAfterConsume4(_ x2: consumi print("foo") } f() - consumeVal(x2) // expected-error {{noncopyable 'x2' cannot be consumed when captured by a closure}} + consumeVal(x2) // expected-error {{noncopyable 'x2' cannot be consumed when captured by an escaping closure}} } /////////////////////////////////////////// @@ -3577,11 +3577,11 @@ public func closureVarAndClosureCaptureClassUseAfterConsume(_ x: borrowing Klass var g = {} g = { borrowVal(x2) - consumeVal(x2) // expected-error {{noncopyable 'x2' cannot be consumed when captured by a closure}} - consumeVal(x2) // expected-error {{noncopyable 'x2' cannot be consumed when captured by a closure}} + consumeVal(x2) // expected-error {{noncopyable 'x2' cannot be consumed when captured by an escaping closure}} + consumeVal(x2) // expected-error {{noncopyable 'x2' cannot be consumed when captured by an escaping closure}} } g() - consumeVal(x2) // expected-error {{noncopyable 'x2' cannot be consumed when captured by a closure}} + consumeVal(x2) // expected-error {{noncopyable 'x2' cannot be consumed when captured by an escaping closure}} } f() } @@ -3595,14 +3595,14 @@ public func closureVarAndClosureCaptureClassUseAfterConsume2(_ x: borrowing Klas var g = {} g = { borrowVal(x2) - consumeVal(x2) // expected-error {{noncopyable 'x2' cannot be consumed when captured by a closure}} - consumeVal(x2) // expected-error {{noncopyable 'x2' cannot be consumed when captured by a closure}} + consumeVal(x2) // expected-error {{noncopyable 'x2' cannot be consumed when captured by an escaping closure}} + consumeVal(x2) // expected-error {{noncopyable 'x2' cannot be consumed when captured by an escaping closure}} } g() } f() - consumeVal(x2) // expected-error {{noncopyable 'x2' cannot be consumed when captured by a closure}} - let x3 = x2 // expected-error {{noncopyable 'x2' cannot be consumed when captured by a closure}} + consumeVal(x2) // expected-error {{noncopyable 'x2' cannot be consumed when captured by an escaping closure}} + let x3 = x2 // expected-error {{noncopyable 'x2' cannot be consumed when captured by an escaping closure}} _ = x3 } @@ -3617,19 +3617,19 @@ public func closureVarAndClosureCaptureClassUseAfterConsume3(_ x: borrowing Klas var g = {} g = { borrowVal(x2) - consumeVal(x2) // expected-error {{noncopyable 'x2' cannot be consumed when captured by a closure}} - consumeVal(x2) // expected-error {{noncopyable 'x2' cannot be consumed when captured by a closure}} + consumeVal(x2) // expected-error {{noncopyable 'x2' cannot be consumed when captured by an escaping closure}} + consumeVal(x2) // expected-error {{noncopyable 'x2' cannot be consumed when captured by an escaping closure}} } g() } f() - consumeVal(x2) // expected-error {{noncopyable 'x2' cannot be consumed when captured by a closure}} - let x3 = x2 // expected-error {{noncopyable 'x2' cannot be consumed when captured by a closure}} + consumeVal(x2) // expected-error {{noncopyable 'x2' cannot be consumed when captured by an escaping closure}} + let x3 = x2 // expected-error {{noncopyable 'x2' cannot be consumed when captured by an escaping closure}} _ = x3 } public func closureVarAndClosureCaptureClassArgUseAfterConsume(_ x2: borrowing Klass) { - // expected-error @-1 {{noncopyable 'x2' cannot be consumed when captured by a closure}} + // expected-error @-1 {{noncopyable 'x2' cannot be consumed when captured by an escaping closure}} // expected-error @-2 {{'x2' cannot be captured by an escaping closure since it is a borrowed parameter}} // expected-error @-3 {{'x2' cannot be captured by an escaping closure since it is a borrowed parameter}} var f = {} @@ -3651,8 +3651,8 @@ public func closureVarAndClosureCaptureClassOwnedArgUseAfterConsume(_ x2: __owne var g = {} g = { borrowVal(x2) - consumeVal(x2) // expected-error {{noncopyable 'x2' cannot be consumed when captured by a closure}} - consumeVal(x2) // expected-error {{noncopyable 'x2' cannot be consumed when captured by a closure}} + consumeVal(x2) // expected-error {{noncopyable 'x2' cannot be consumed when captured by an escaping closure}} + consumeVal(x2) // expected-error {{noncopyable 'x2' cannot be consumed when captured by an escaping closure}} } g() } @@ -3665,8 +3665,8 @@ public func closureVarAndClosureCaptureClassOwnedArgUseAfterConsume2(_ x2: consu var g = {} g = { borrowVal(x2) - consumeVal(x2) // expected-error {{noncopyable 'x2' cannot be consumed when captured by a closure}} - consumeVal(x2) // expected-error {{noncopyable 'x2' cannot be consumed when captured by a closure}} + consumeVal(x2) // expected-error {{noncopyable 'x2' cannot be consumed when captured by an escaping closure}} + consumeVal(x2) // expected-error {{noncopyable 'x2' cannot be consumed when captured by an escaping closure}} } g() } @@ -3679,13 +3679,13 @@ public func closureVarAndClosureCaptureClassOwnedArgUseAfterConsume3(_ x2: __own var g = {} g = { borrowVal(x2) - consumeVal(x2) // expected-error {{noncopyable 'x2' cannot be consumed when captured by a closure}} - consumeVal(x2) // expected-error {{noncopyable 'x2' cannot be consumed when captured by a closure}} + consumeVal(x2) // expected-error {{noncopyable 'x2' cannot be consumed when captured by an escaping closure}} + consumeVal(x2) // expected-error {{noncopyable 'x2' cannot be consumed when captured by an escaping closure}} } g() } f() - consumeVal(x2) // expected-error {{noncopyable 'x2' cannot be consumed when captured by a closure}} + consumeVal(x2) // expected-error {{noncopyable 'x2' cannot be consumed when captured by an escaping closure}} } public func closureVarAndClosureCaptureClassOwnedArgUseAfterConsume4(_ x2: consuming Klass) { @@ -3694,13 +3694,13 @@ public func closureVarAndClosureCaptureClassOwnedArgUseAfterConsume4(_ x2: consu var g = {} g = { borrowVal(x2) - consumeVal(x2) // expected-error {{noncopyable 'x2' cannot be consumed when captured by a closure}} - consumeVal(x2) // expected-error {{noncopyable 'x2' cannot be consumed when captured by a closure}} + consumeVal(x2) // expected-error {{noncopyable 'x2' cannot be consumed when captured by an escaping closure}} + consumeVal(x2) // expected-error {{noncopyable 'x2' cannot be consumed when captured by an escaping closure}} } g() } f() - consumeVal(x2) // expected-error {{noncopyable 'x2' cannot be consumed when captured by a closure}} + consumeVal(x2) // expected-error {{noncopyable 'x2' cannot be consumed when captured by an escaping closure}} } ///////////////////////////////// @@ -3713,11 +3713,11 @@ public func closureVarAndClosureLetCaptureClassUseAfterConsume(_ x: borrowing Kl f = { let g = { borrowVal(x2) - consumeVal(x2) // expected-error {{noncopyable 'x2' cannot be consumed when captured by a closure}} - consumeVal(x2) // expected-error {{noncopyable 'x2' cannot be consumed when captured by a closure}} + consumeVal(x2) // expected-error {{noncopyable 'x2' cannot be consumed when captured by an escaping closure}} + consumeVal(x2) // expected-error {{noncopyable 'x2' cannot be consumed when captured by an escaping closure}} } g() - consumeVal(x2) // expected-error {{noncopyable 'x2' cannot be consumed when captured by a closure}} + consumeVal(x2) // expected-error {{noncopyable 'x2' cannot be consumed when captured by an escaping closure}} } f() } @@ -3730,14 +3730,14 @@ public func closureVarAndClosureLetCaptureClassUseAfterConsume2(_ x: borrowing K f = { let g = { borrowVal(x2) - consumeVal(x2) // expected-error {{noncopyable 'x2' cannot be consumed when captured by a closure}} - consumeVal(x2) // expected-error {{noncopyable 'x2' cannot be consumed when captured by a closure}} + consumeVal(x2) // expected-error {{noncopyable 'x2' cannot be consumed when captured by an escaping closure}} + consumeVal(x2) // expected-error {{noncopyable 'x2' cannot be consumed when captured by an escaping closure}} } g() } f() - consumeVal(x2) // expected-error {{noncopyable 'x2' cannot be consumed when captured by a closure}} - let x3 = x2 // expected-error {{noncopyable 'x2' cannot be consumed when captured by a closure}} + consumeVal(x2) // expected-error {{noncopyable 'x2' cannot be consumed when captured by an escaping closure}} + let x3 = x2 // expected-error {{noncopyable 'x2' cannot be consumed when captured by an escaping closure}} _ = x3 } @@ -3751,19 +3751,19 @@ public func closureVarAndClosureLetCaptureClassUseAfterConsume3(_ x: borrowing K f = { let g = { borrowVal(x2) - consumeVal(x2) // expected-error {{noncopyable 'x2' cannot be consumed when captured by a closure}} - consumeVal(x2) // expected-error {{noncopyable 'x2' cannot be consumed when captured by a closure}} + consumeVal(x2) // expected-error {{noncopyable 'x2' cannot be consumed when captured by an escaping closure}} + consumeVal(x2) // expected-error {{noncopyable 'x2' cannot be consumed when captured by an escaping closure}} } g() } f() - consumeVal(x2) // expected-error {{noncopyable 'x2' cannot be consumed when captured by a closure}} - let x3 = x2 // expected-error {{noncopyable 'x2' cannot be consumed when captured by a closure}} + consumeVal(x2) // expected-error {{noncopyable 'x2' cannot be consumed when captured by an escaping closure}} + let x3 = x2 // expected-error {{noncopyable 'x2' cannot be consumed when captured by an escaping closure}} _ = x3 } public func closureVarAndClosureLetCaptureClassArgUseAfterConsume(_ x2: borrowing Klass) { - // expected-error @-1 {{noncopyable 'x2' cannot be consumed when captured by a closure}} + // expected-error @-1 {{noncopyable 'x2' cannot be consumed when captured by an escaping closure}} // expected-error @-2 {{'x2' cannot be captured by an escaping closure since it is a borrowed parameter}} // expected-error @-3 {{'x2' cannot be captured by an escaping closure since it is a borrowed parameter}} var f = {} @@ -3783,8 +3783,8 @@ public func closureVarAndClosureLetCaptureClassOwnedArgUseAfterConsume(_ x2: __o f = { let g = { borrowVal(x2) - consumeVal(x2) // expected-error {{noncopyable 'x2' cannot be consumed when captured by a closure}} - consumeVal(x2) // expected-error {{noncopyable 'x2' cannot be consumed when captured by a closure}} + consumeVal(x2) // expected-error {{noncopyable 'x2' cannot be consumed when captured by an escaping closure}} + consumeVal(x2) // expected-error {{noncopyable 'x2' cannot be consumed when captured by an escaping closure}} } g() } @@ -3796,8 +3796,8 @@ public func closureVarAndClosureLetCaptureClassOwnedArgUseAfterConsume2(_ x2: co f = { let g = { borrowVal(x2) - consumeVal(x2) // expected-error {{noncopyable 'x2' cannot be consumed when captured by a closure}} - consumeVal(x2) // expected-error {{noncopyable 'x2' cannot be consumed when captured by a closure}} + consumeVal(x2) // expected-error {{noncopyable 'x2' cannot be consumed when captured by an escaping closure}} + consumeVal(x2) // expected-error {{noncopyable 'x2' cannot be consumed when captured by an escaping closure}} } g() } @@ -3809,13 +3809,13 @@ public func closureVarAndClosureLetCaptureClassOwnedArgUseAfterConsume3(_ x2: __ f = { let g = { borrowVal(x2) - consumeVal(x2) // expected-error {{noncopyable 'x2' cannot be consumed when captured by a closure}} - consumeVal(x2) // expected-error {{noncopyable 'x2' cannot be consumed when captured by a closure}} + consumeVal(x2) // expected-error {{noncopyable 'x2' cannot be consumed when captured by an escaping closure}} + consumeVal(x2) // expected-error {{noncopyable 'x2' cannot be consumed when captured by an escaping closure}} } g() } f() - consumeVal(x2) // expected-error {{noncopyable 'x2' cannot be consumed when captured by a closure}} + consumeVal(x2) // expected-error {{noncopyable 'x2' cannot be consumed when captured by an escaping closure}} } public func closureVarAndClosureLetCaptureClassOwnedArgUseAfterConsume4(_ x2: consuming Klass) { @@ -3823,13 +3823,13 @@ public func closureVarAndClosureLetCaptureClassOwnedArgUseAfterConsume4(_ x2: co f = { let g = { borrowVal(x2) - consumeVal(x2) // expected-error {{noncopyable 'x2' cannot be consumed when captured by a closure}} - consumeVal(x2) // expected-error {{noncopyable 'x2' cannot be consumed when captured by a closure}} + consumeVal(x2) // expected-error {{noncopyable 'x2' cannot be consumed when captured by an escaping closure}} + consumeVal(x2) // expected-error {{noncopyable 'x2' cannot be consumed when captured by an escaping closure}} } g() } f() - consumeVal(x2) // expected-error {{noncopyable 'x2' cannot be consumed when captured by a closure}} + consumeVal(x2) // expected-error {{noncopyable 'x2' cannot be consumed when captured by an escaping closure}} } public func closureLetAndClosureVarCaptureClassUseAfterConsume(_ x: borrowing Klass) { // expected-error {{'x' is borrowed and cannot be consumed}} @@ -3838,11 +3838,11 @@ public func closureLetAndClosureVarCaptureClassUseAfterConsume(_ x: borrowing Kl var g = {} g = { borrowVal(x2) - consumeVal(x2) // expected-error {{noncopyable 'x2' cannot be consumed when captured by a closure}} - consumeVal(x2) // expected-error {{noncopyable 'x2' cannot be consumed when captured by a closure}} + consumeVal(x2) // expected-error {{noncopyable 'x2' cannot be consumed when captured by an escaping closure}} + consumeVal(x2) // expected-error {{noncopyable 'x2' cannot be consumed when captured by an escaping closure}} } g() - consumeVal(x2) // expected-error {{noncopyable 'x2' cannot be consumed when captured by a closure}} + consumeVal(x2) // expected-error {{noncopyable 'x2' cannot be consumed when captured by an escaping closure}} } f() } @@ -3856,17 +3856,17 @@ public func closureLetAndClosureVarCaptureClassUseAfterConsume2(_ x: borrowing K var g = {} g = { borrowVal(x2) - consumeVal(x2) // expected-error {{noncopyable 'x2' cannot be consumed when captured by a closure}} - consumeVal(x2) // expected-error {{noncopyable 'x2' cannot be consumed when captured by a closure}} + consumeVal(x2) // expected-error {{noncopyable 'x2' cannot be consumed when captured by an escaping closure}} + consumeVal(x2) // expected-error {{noncopyable 'x2' cannot be consumed when captured by an escaping closure}} } g() } h() - consumeVal(x2) // expected-error {{noncopyable 'x2' cannot be consumed when captured by a closure}} + consumeVal(x2) // expected-error {{noncopyable 'x2' cannot be consumed when captured by an escaping closure}} } f() - consumeVal(x2) // expected-error {{noncopyable 'x2' cannot be consumed when captured by a closure}} - let x3 = x2 // expected-error {{noncopyable 'x2' cannot be consumed when captured by a closure}} + consumeVal(x2) // expected-error {{noncopyable 'x2' cannot be consumed when captured by an escaping closure}} + let x3 = x2 // expected-error {{noncopyable 'x2' cannot be consumed when captured by an escaping closure}} _ = x3 } @@ -3880,19 +3880,19 @@ public func closureLetAndClosureVarCaptureClassUseAfterConsume3(_ x: borrowing K var g = {} g = { borrowVal(x2) - consumeVal(x2) // expected-error {{noncopyable 'x2' cannot be consumed when captured by a closure}} - consumeVal(x2) // expected-error {{noncopyable 'x2' cannot be consumed when captured by a closure}} + consumeVal(x2) // expected-error {{noncopyable 'x2' cannot be consumed when captured by an escaping closure}} + consumeVal(x2) // expected-error {{noncopyable 'x2' cannot be consumed when captured by an escaping closure}} } g() } f() - consumeVal(x2) // expected-error {{noncopyable 'x2' cannot be consumed when captured by a closure}} - let x3 = x2 // expected-error {{noncopyable 'x2' cannot be consumed when captured by a closure}} + consumeVal(x2) // expected-error {{noncopyable 'x2' cannot be consumed when captured by an escaping closure}} + let x3 = x2 // expected-error {{noncopyable 'x2' cannot be consumed when captured by an escaping closure}} _ = x3 } public func closureLetAndClosureVarCaptureClassArgUseAfterConsume(_ x2: borrowing Klass) { - // expected-error @-1 {{noncopyable 'x2' cannot be consumed when captured by a closure}} + // expected-error @-1 {{noncopyable 'x2' cannot be consumed when captured by an escaping closure}} // expected-error @-2 {{'x2' cannot be captured by an escaping closure since it is a borrowed parameter}} // expected-error @-3 {{'x2' cannot be captured by an escaping closure since it is a borrowed parameter}} let f = {// expected-note {{closure capturing 'x2' here}} @@ -3912,8 +3912,8 @@ public func closureLetAndClosureVarCaptureClassOwnedArgUseAfterConsume(_ x2: __o var g = {} g = { borrowVal(x2) - consumeVal(x2) // expected-error {{noncopyable 'x2' cannot be consumed when captured by a closure}} - consumeVal(x2) // expected-error {{noncopyable 'x2' cannot be consumed when captured by a closure}} + consumeVal(x2) // expected-error {{noncopyable 'x2' cannot be consumed when captured by an escaping closure}} + consumeVal(x2) // expected-error {{noncopyable 'x2' cannot be consumed when captured by an escaping closure}} } g() } @@ -3925,8 +3925,8 @@ public func closureLetAndClosureVarCaptureClassOwnedArgUseAfterConsume2(_ x2: co var g = {} g = { borrowVal(x2) - consumeVal(x2) // expected-error {{noncopyable 'x2' cannot be consumed when captured by a closure}} - consumeVal(x2) // expected-error {{noncopyable 'x2' cannot be consumed when captured by a closure}} + consumeVal(x2) // expected-error {{noncopyable 'x2' cannot be consumed when captured by an escaping closure}} + consumeVal(x2) // expected-error {{noncopyable 'x2' cannot be consumed when captured by an escaping closure}} } g() } @@ -3938,13 +3938,13 @@ public func closureLetAndClosureVarCaptureClassOwnedArgUseAfterConsume3(_ x2: __ var g = {} g = { borrowVal(x2) - consumeVal(x2) // expected-error {{noncopyable 'x2' cannot be consumed when captured by a closure}} - consumeVal(x2) // expected-error {{noncopyable 'x2' cannot be consumed when captured by a closure}} + consumeVal(x2) // expected-error {{noncopyable 'x2' cannot be consumed when captured by an escaping closure}} + consumeVal(x2) // expected-error {{noncopyable 'x2' cannot be consumed when captured by an escaping closure}} } g() } f() - consumeVal(x2) // expected-error {{noncopyable 'x2' cannot be consumed when captured by a closure}} + consumeVal(x2) // expected-error {{noncopyable 'x2' cannot be consumed when captured by an escaping closure}} } public func closureLetAndClosureVarCaptureClassOwnedArgUseAfterConsume4(_ x2: consuming Klass) { @@ -3952,13 +3952,13 @@ public func closureLetAndClosureVarCaptureClassOwnedArgUseAfterConsume4(_ x2: co var g = {} g = { borrowVal(x2) - consumeVal(x2) // expected-error {{noncopyable 'x2' cannot be consumed when captured by a closure}} - consumeVal(x2) // expected-error {{noncopyable 'x2' cannot be consumed when captured by a closure}} + consumeVal(x2) // expected-error {{noncopyable 'x2' cannot be consumed when captured by an escaping closure}} + consumeVal(x2) // expected-error {{noncopyable 'x2' cannot be consumed when captured by an escaping closure}} } g() } f() - consumeVal(x2) // expected-error {{noncopyable 'x2' cannot be consumed when captured by a closure}} + consumeVal(x2) // expected-error {{noncopyable 'x2' cannot be consumed when captured by an escaping closure}} } /////////////////////////////////// diff --git a/test/SILOptimizer/moveonly_trivial_objectchecker_diagnostics.swift b/test/SILOptimizer/moveonly_trivial_objectchecker_diagnostics.swift index 720b5082725c9..239dd82584050 100644 --- a/test/SILOptimizer/moveonly_trivial_objectchecker_diagnostics.swift +++ b/test/SILOptimizer/moveonly_trivial_objectchecker_diagnostics.swift @@ -1727,7 +1727,7 @@ public func enumPatternMatchSwitch2WhereClause2OwnedArg2(_ x2: consuming EnumTy) ///////////////////////////// public func closureClassUseAfterConsume1(_ x: borrowing NonTrivialStruct) { - // expected-error @-1 {{noncopyable 'x' cannot be consumed when captured by a closure}} + // expected-error @-1 {{noncopyable 'x' cannot be consumed when captured by an escaping closure}} // expected-error @-2 {{'x' cannot be captured by an escaping closure since it is a borrowed parameter}} let f = { // expected-note {{closure capturing 'x' here}} let x2 = x // expected-error {{'x2' consumed more than once}} @@ -1762,8 +1762,8 @@ public func closureClassUseAfterConsumeArg(_ argX: borrowing NonTrivialStruct) { public func closureCaptureClassUseAfterConsume(_ x: borrowing NonTrivialStruct) { // expected-error {{'x' is borrowed and cannot be consumed}} let x2 = x // expected-note {{consumed here}} - // expected-error @-1 {{noncopyable 'x2' cannot be consumed when captured by a closure}} - // expected-error @-2 {{noncopyable 'x2' cannot be consumed when captured by a closure}} + // expected-error @-1 {{noncopyable 'x2' cannot be consumed when captured by an escaping closure}} + // expected-error @-2 {{noncopyable 'x2' cannot be consumed when captured by an escaping closure}} let f = { borrowVal(x2) @@ -1775,8 +1775,8 @@ public func closureCaptureClassUseAfterConsume(_ x: borrowing NonTrivialStruct) public func closureCaptureClassUseAfterConsumeError(_ x: borrowing NonTrivialStruct) { // expected-error {{'x' is borrowed and cannot be consumed}} let x2 = x // expected-note {{consumed here}} - // expected-error @-1 {{noncopyable 'x2' cannot be consumed when captured by a closure}} - // expected-error @-2 {{noncopyable 'x2' cannot be consumed when captured by a closure}} + // expected-error @-1 {{noncopyable 'x2' cannot be consumed when captured by an escaping closure}} + // expected-error @-2 {{noncopyable 'x2' cannot be consumed when captured by an escaping closure}} let f = { borrowVal(x2) consumeVal(x2) // expected-note {{consumed here}} @@ -1788,7 +1788,7 @@ public func closureCaptureClassUseAfterConsumeError(_ x: borrowing NonTrivialStr } public func closureCaptureClassArgUseAfterConsume(_ x2: borrowing NonTrivialStruct) { - // expected-error @-1 {{noncopyable 'x2' cannot be consumed when captured by a closure}} + // expected-error @-1 {{noncopyable 'x2' cannot be consumed when captured by an escaping closure}} // expected-error @-2 {{'x2' cannot be captured by an escaping closure since it is a borrowed parameter}} let f = { // expected-note {{closure capturing 'x2' here}} borrowVal(x2) @@ -1799,8 +1799,8 @@ public func closureCaptureClassArgUseAfterConsume(_ x2: borrowing NonTrivialStru } public func closureCaptureClassOwnedArgUseAfterConsume(_ x2: __owned NonTrivialStruct) { - // expected-error @-1 {{noncopyable 'x2' cannot be consumed when captured by a closure}} - // expected-error @-2 {{noncopyable 'x2' cannot be consumed when captured by a closure}} + // expected-error @-1 {{noncopyable 'x2' cannot be consumed when captured by an escaping closure}} + // expected-error @-2 {{noncopyable 'x2' cannot be consumed when captured by an escaping closure}} let f = { borrowVal(x2) consumeVal(x2) // expected-note {{consumed here}} @@ -1822,8 +1822,8 @@ public func closureCaptureClassOwnedArgUseAfterConsume2(_ x2: consuming NonTrivi } public func closureCaptureClassOwnedArgUseAfterConsume3(_ x2: __owned NonTrivialStruct) { - // expected-error @-1 {{noncopyable 'x2' cannot be consumed when captured by a closure}} - // expected-error @-2 {{noncopyable 'x2' cannot be consumed when captured by a closure}} + // expected-error @-1 {{noncopyable 'x2' cannot be consumed when captured by an escaping closure}} + // expected-error @-2 {{noncopyable 'x2' cannot be consumed when captured by an escaping closure}} let f = { borrowVal(x2) consumeVal(x2) // expected-note {{consumed here}} @@ -1852,7 +1852,7 @@ public func closureCaptureClassOwnedArgUseAfterConsume4(_ x2: consuming NonTrivi public func deferCaptureClassUseAfterConsume(_ x: borrowing NonTrivialStruct) { // expected-error {{'x' is borrowed and cannot be consumed}} let x2 = x // expected-note {{consumed here}} - // expected-error @-1 {{noncopyable 'x2' cannot be consumed when captured by a closure}} + // expected-error @-1 {{noncopyable 'x2' cannot be consumed when captured by an escaping closure}} defer { borrowVal(x2) consumeVal(x2) // expected-note {{consumed here}} @@ -1864,7 +1864,7 @@ public func deferCaptureClassUseAfterConsume(_ x: borrowing NonTrivialStruct) { public func deferCaptureClassUseAfterConsume2(_ x: borrowing NonTrivialStruct) { // expected-error {{'x' is borrowed and cannot be consumed}} let x2 = x // expected-note @-1 {{consumed here}} - // expected-error @-2 {{noncopyable 'x2' cannot be consumed when captured by a closure}} + // expected-error @-2 {{noncopyable 'x2' cannot be consumed when captured by an escaping closure}} // expected-error @-3 {{'x2' used after consume}} defer { // expected-note {{used here}} borrowVal(x2) @@ -1876,7 +1876,7 @@ public func deferCaptureClassUseAfterConsume2(_ x: borrowing NonTrivialStruct) { } public func deferCaptureClassArgUseAfterConsume(_ x2: borrowing NonTrivialStruct) { - // expected-error @-1 {{noncopyable 'x2' cannot be consumed when captured by a closure}} + // expected-error @-1 {{noncopyable 'x2' cannot be consumed when captured by an escaping closure}} borrowVal(x2) defer { borrowVal(x2) @@ -1887,7 +1887,7 @@ public func deferCaptureClassArgUseAfterConsume(_ x2: borrowing NonTrivialStruct } public func deferCaptureClassOwnedArgUseAfterConsume(_ x2: __owned NonTrivialStruct) { - // expected-error @-1 {{noncopyable 'x2' cannot be consumed when captured by a closure}} + // expected-error @-1 {{noncopyable 'x2' cannot be consumed when captured by an escaping closure}} defer { borrowVal(x2) consumeVal(x2) // expected-note {{consumed here}} @@ -1909,7 +1909,7 @@ public func deferCaptureClassOwnedArgUseAfterConsume2(_ x2: consuming NonTrivial } public func deferCaptureClassOwnedArgUseAfterConsume3(_ x2: __owned NonTrivialStruct) { - // expected-error @-1 {{noncopyable 'x2' cannot be consumed when captured by a closure}} + // expected-error @-1 {{noncopyable 'x2' cannot be consumed when captured by an escaping closure}} // expected-error @-2 {{'x2' used after consume}} defer { // expected-note {{used here}} borrowVal(x2) @@ -1935,7 +1935,7 @@ public func deferCaptureClassOwnedArgUseAfterConsume4(_ x2: consuming NonTrivial public func closureAndDeferCaptureClassUseAfterConsume(_ x: borrowing NonTrivialStruct) { // expected-error @-1 {{'x' is borrowed and cannot be consumed}} let x2 = x // expected-note {{consumed here}} - // expected-error @-1 {{noncopyable 'x2' cannot be consumed when captured by a closure}} + // expected-error @-1 {{noncopyable 'x2' cannot be consumed when captured by an escaping closure}} let f = { defer { borrowVal(x2) @@ -1949,8 +1949,8 @@ public func closureAndDeferCaptureClassUseAfterConsume(_ x: borrowing NonTrivial public func closureAndDeferCaptureClassUseAfterConsume2(_ x: borrowing NonTrivialStruct) { // expected-error {{'x' is borrowed and cannot be consumed}} let x2 = x // expected-note {{consumed here}} - // expected-error @-1 {{noncopyable 'x2' cannot be consumed when captured by a closure}} - // expected-error @-2 {{noncopyable 'x2' cannot be consumed when captured by a closure}} + // expected-error @-1 {{noncopyable 'x2' cannot be consumed when captured by an escaping closure}} + // expected-error @-2 {{noncopyable 'x2' cannot be consumed when captured by an escaping closure}} let f = { consumeVal(x2) // expected-note {{consumed here}} defer { @@ -1966,8 +1966,8 @@ public func closureAndDeferCaptureClassUseAfterConsume2(_ x: borrowing NonTrivia public func closureAndDeferCaptureClassUseAfterConsume3(_ x: borrowing NonTrivialStruct) { // expected-error {{'x' is borrowed and cannot be consumed}} let x2 = x // expected-note @-1 {{consumed here}} - // expected-error @-2 {{noncopyable 'x2' cannot be consumed when captured by a closure}} - // expected-error @-3 {{noncopyable 'x2' cannot be consumed when captured by a closure}} + // expected-error @-2 {{noncopyable 'x2' cannot be consumed when captured by an escaping closure}} + // expected-error @-3 {{noncopyable 'x2' cannot be consumed when captured by an escaping closure}} let f = { consumeVal(x2) // expected-note {{consumed here}} defer { @@ -1983,7 +1983,7 @@ public func closureAndDeferCaptureClassUseAfterConsume3(_ x: borrowing NonTrivia public func closureAndDeferCaptureClassArgUseAfterConsume(_ x2: borrowing NonTrivialStruct) { // expected-error @-1 {{'x2' cannot be captured by an escaping closure since it is a borrowed parameter}} - // expected-error @-2 {{noncopyable 'x2' cannot be consumed when captured by a closure}} + // expected-error @-2 {{noncopyable 'x2' cannot be consumed when captured by an escaping closure}} let f = { // expected-note {{closure capturing 'x2' here}} defer { borrowVal(x2) @@ -1996,7 +1996,7 @@ public func closureAndDeferCaptureClassArgUseAfterConsume(_ x2: borrowing NonTri } public func closureAndDeferCaptureClassOwnedArgUseAfterConsume(_ x2: __owned NonTrivialStruct) { - // expected-error @-1 {{noncopyable 'x2' cannot be consumed when captured by a closure}} + // expected-error @-1 {{noncopyable 'x2' cannot be consumed when captured by an escaping closure}} let f = { defer { borrowVal(x2) @@ -2024,7 +2024,7 @@ public func closureAndDeferCaptureClassOwnedArgUseAfterConsume2(_ x2: consuming } public func closureAndDeferCaptureClassOwnedArgUseAfterConsume3(_ x2: __owned NonTrivialStruct) { - // expected-error @-1 {{noncopyable 'x2' cannot be consumed when captured by a closure}} + // expected-error @-1 {{noncopyable 'x2' cannot be consumed when captured by an escaping closure}} let f = { defer { borrowVal(x2) @@ -2055,8 +2055,8 @@ public func closureAndDeferCaptureClassOwnedArgUseAfterConsume4(_ x2: consuming public func closureAndClosureCaptureClassUseAfterConsume(_ x: borrowing NonTrivialStruct) { // expected-error {{'x' is borrowed and cannot be consumed}} let x2 = x // expected-note {{consumed here}} - // expected-error @-1 {{noncopyable 'x2' cannot be consumed when captured by a closure}} - // expected-error @-2 {{noncopyable 'x2' cannot be consumed when captured by a closure}} + // expected-error @-1 {{noncopyable 'x2' cannot be consumed when captured by an escaping closure}} + // expected-error @-2 {{noncopyable 'x2' cannot be consumed when captured by an escaping closure}} let f = { let g = { borrowVal(x2) @@ -2070,8 +2070,8 @@ public func closureAndClosureCaptureClassUseAfterConsume(_ x: borrowing NonTrivi public func closureAndClosureCaptureClassUseAfterConsume2(_ x: borrowing NonTrivialStruct) { // expected-error {{'x' is borrowed and cannot be consumed}} let x2 = x // expected-note {{consumed here}} - // expected-error @-1 {{noncopyable 'x2' cannot be consumed when captured by a closure}} - // expected-error @-2 {{noncopyable 'x2' cannot be consumed when captured by a closure}} + // expected-error @-1 {{noncopyable 'x2' cannot be consumed when captured by an escaping closure}} + // expected-error @-2 {{noncopyable 'x2' cannot be consumed when captured by an escaping closure}} let f = { let g = { borrowVal(x2) @@ -2086,7 +2086,7 @@ public func closureAndClosureCaptureClassUseAfterConsume2(_ x: borrowing NonTriv public func closureAndClosureCaptureClassArgUseAfterConsume(_ x2: borrowing NonTrivialStruct) { - // expected-error @-1 {{noncopyable 'x2' cannot be consumed when captured by a closure}} + // expected-error @-1 {{noncopyable 'x2' cannot be consumed when captured by an escaping closure}} // expected-error @-2 {{'x2' cannot be captured by an escaping closure since it is a borrowed parameter}} // expected-error @-3 {{'x2' cannot be captured by an escaping closure since it is a borrowed parameter}} let f = { // expected-note {{closure capturing 'x2' here}} @@ -2101,8 +2101,8 @@ public func closureAndClosureCaptureClassArgUseAfterConsume(_ x2: borrowing NonT } public func closureAndClosureCaptureClassOwnedArgUseAfterConsume(_ x2: __owned NonTrivialStruct) { - // expected-error @-1 {{noncopyable 'x2' cannot be consumed when captured by a closure}} - // expected-error @-2 {{noncopyable 'x2' cannot be consumed when captured by a closure}} + // expected-error @-1 {{noncopyable 'x2' cannot be consumed when captured by an escaping closure}} + // expected-error @-2 {{noncopyable 'x2' cannot be consumed when captured by an escaping closure}} let f = { let g = { borrowVal(x2) @@ -2130,8 +2130,8 @@ public func closureAndClosureCaptureClassOwnedArgUseAfterConsume2(_ x2: consumin } public func closureAndClosureCaptureClassOwnedArgUseAfterConsume3(_ x2: __owned NonTrivialStruct) { - // expected-error @-1 {{noncopyable 'x2' cannot be consumed when captured by a closure}} - // expected-error @-2 {{noncopyable 'x2' cannot be consumed when captured by a closure}} + // expected-error @-1 {{noncopyable 'x2' cannot be consumed when captured by an escaping closure}} + // expected-error @-2 {{noncopyable 'x2' cannot be consumed when captured by an escaping closure}} let f = { let g = { borrowVal(x2) @@ -2145,8 +2145,8 @@ public func closureAndClosureCaptureClassOwnedArgUseAfterConsume3(_ x2: __owned } public func closureAndClosureCaptureClassOwnedArgUseAfterConsume4(_ x2: __owned NonTrivialStruct) { - // expected-error @-1 {{noncopyable 'x2' cannot be consumed when captured by a closure}} - // expected-error @-2 {{noncopyable 'x2' cannot be consumed when captured by a closure}} + // expected-error @-1 {{noncopyable 'x2' cannot be consumed when captured by an escaping closure}} + // expected-error @-2 {{noncopyable 'x2' cannot be consumed when captured by an escaping closure}} let f = { let g = { borrowVal(x2) diff --git a/test/SILOptimizer/noimplicitcopy_consuming_parameters.swift b/test/SILOptimizer/noimplicitcopy_consuming_parameters.swift index e9a3f21e340db..380ca517062a7 100644 --- a/test/SILOptimizer/noimplicitcopy_consuming_parameters.swift +++ b/test/SILOptimizer/noimplicitcopy_consuming_parameters.swift @@ -151,7 +151,7 @@ func testLoadableConsumingEscapingClosure(_ x: consuming NonTrivialStruct) { } func testLoadableConsumingEscapingClosure2(_ x: consuming NonTrivialStruct) { - _ = x // expected-error {{noncopyable 'x' cannot be consumed when captured by a closure}} + _ = x // expected-error {{noncopyable 'x' cannot be consumed when captured by an escaping closure}} var f: () -> () = {} f = { _ = x @@ -165,7 +165,7 @@ func testLoadableConsumingEscapingClosure3(_ x: consuming NonTrivialStruct) { _ = x } _ = f - _ = x // expected-error {{noncopyable 'x' cannot be consumed when captured by a closure}} + _ = x // expected-error {{noncopyable 'x' cannot be consumed when captured by an escaping closure}} } func testLoadableConsumingNonEscapingClosure(_ x: consuming NonTrivialStruct) { @@ -302,7 +302,7 @@ func testTrivialConsumingEscapingClosure(_ x: consuming TrivialStruct) { } func testTrivialConsumingEscapingClosure2(_ x: consuming TrivialStruct) { - let _ = x // expected-error {{noncopyable 'x' cannot be consumed when captured by a closure}} + let _ = x // expected-error {{noncopyable 'x' cannot be consumed when captured by an escaping closure}} var f: () -> () = {} f = { _ = x @@ -316,7 +316,7 @@ func testTrivialConsumingEscapingClosure3(_ x: consuming TrivialStruct) { _ = x } _ = f - let _ = x // expected-error {{noncopyable 'x' cannot be consumed when captured by a closure}} + let _ = x // expected-error {{noncopyable 'x' cannot be consumed when captured by an escaping closure}} } func testTrivialConsumingNonEscapingClosure(_ x: consuming TrivialStruct) { @@ -440,7 +440,7 @@ func testAddressOnlyConsumingEscapingClosure(_ x: consuming GenericNonTri } func testAddressOnlyConsumingEscapingClosure2(_ x: consuming GenericNonTrivialStruct) { - let _ = x // expected-error {{noncopyable 'x' cannot be consumed when captured by a closure}} + let _ = x // expected-error {{noncopyable 'x' cannot be consumed when captured by an escaping closure}} var f: () -> () = {} f = { _ = x @@ -454,7 +454,7 @@ func testAddressOnlyConsumingEscapingClosure3(_ x: consuming GenericNonTr _ = x } _ = f - let _ = x // expected-error {{noncopyable 'x' cannot be consumed when captured by a closure}} + let _ = x // expected-error {{noncopyable 'x' cannot be consumed when captured by an escaping closure}} } func testAddressOnlyConsumingNonEscapingClosure(_ x: consuming GenericNonTrivialStruct) { @@ -646,7 +646,7 @@ struct LoadableSelfTest { } consuming func testCallEscapingClosure2() { - let _ = self // expected-error {{noncopyable 'self' cannot be consumed when captured by a closure}} + let _ = self // expected-error {{noncopyable 'self' cannot be consumed when captured by an escaping closure}} var f: () -> () = {} f = { let _ = self @@ -660,7 +660,7 @@ struct LoadableSelfTest { let _ = self } f() - let _ = self // expected-error {{noncopyable 'self' cannot be consumed when captured by a closure}} + let _ = self // expected-error {{noncopyable 'self' cannot be consumed when captured by an escaping closure}} } consuming func testCallNonEscapingClosure() { @@ -804,7 +804,7 @@ struct AddressOnlySelfTest { } consuming func testCallEscapingClosure2() { - let _ = self // expected-error {{noncopyable 'self' cannot be consumed when captured by a closure}} + let _ = self // expected-error {{noncopyable 'self' cannot be consumed when captured by an escaping closure}} var f: () -> () = {} f = { let _ = self @@ -818,7 +818,7 @@ struct AddressOnlySelfTest { let _ = self } f() - let _ = self // expected-error {{noncopyable 'self' cannot be consumed when captured by a closure}} + let _ = self // expected-error {{noncopyable 'self' cannot be consumed when captured by an escaping closure}} } consuming func testCallEscapingClosure4() { @@ -830,7 +830,7 @@ struct AddressOnlySelfTest { f = { let _ = self } - let _ = self // expected-error {{noncopyable 'self' cannot be consumed when captured by a closure}} + let _ = self // expected-error {{noncopyable 'self' cannot be consumed when captured by an escaping closure}} } consuming func testCallNonEscapingClosure() { @@ -956,7 +956,7 @@ struct TrivialSelfTest { } consuming func testCallEscapingClosure2() { - let _ = self // expected-error {{noncopyable 'self' cannot be consumed when captured by a closure}} + let _ = self // expected-error {{noncopyable 'self' cannot be consumed when captured by an escaping closure}} var f: () -> () = {} f = { let _ = self From 219f94fd1aeda6bef20637299e836ab03856448b Mon Sep 17 00:00:00 2001 From: Kavon Farvardin Date: Mon, 12 Jun 2023 17:54:13 -0700 Subject: [PATCH 2/2] tailor reinit-after-consume message for closure captures rdar://109908383 --- include/swift/AST/DiagnosticsSIL.def | 5 +-- .../Mandatory/MoveOnlyDiagnostics.cpp | 21 +++++++++--- test/SILOptimizer/discard_checking.swift | 2 +- .../moveonly_addresschecker_diagnostics.swift | 34 +++++++++---------- .../moveonly_nonescaping_closures.swift | 4 +-- .../moveonly_objectchecker_diagnostics.swift | 30 ++++++++-------- ...y_trivial_addresschecker_diagnostics.swift | 24 ++++++------- ...ly_trivial_objectchecker_diagnostics.swift | 14 ++++---- 8 files changed, 74 insertions(+), 60 deletions(-) diff --git a/include/swift/AST/DiagnosticsSIL.def b/include/swift/AST/DiagnosticsSIL.def index 362dbc4ed7876..896d472d69029 100644 --- a/include/swift/AST/DiagnosticsSIL.def +++ b/include/swift/AST/DiagnosticsSIL.def @@ -767,8 +767,9 @@ ERROR(sil_movechecking_borrowed_parameter_captured_by_closure, none, (StringRef)) ERROR(sil_movechecking_capture_consumed, none, "noncopyable '%0' cannot be consumed when captured by an escaping closure", (StringRef)) -ERROR(sil_movechecking_inout_not_reinitialized_before_end_of_function, none, - "missing reinitialization of inout parameter '%0' after consume", (StringRef)) +ERROR(sil_movechecking_not_reinitialized_before_end_of_function, none, + "missing reinitialization of %select{inout parameter|closure capture}1 '%0' " + "after consume", (StringRef, bool)) ERROR(sil_movechecking_value_consumed_in_a_loop, none, "'%0' consumed in a loop", (StringRef)) ERROR(sil_movechecking_use_after_partial_consume, none, diff --git a/lib/SILOptimizer/Mandatory/MoveOnlyDiagnostics.cpp b/lib/SILOptimizer/Mandatory/MoveOnlyDiagnostics.cpp index 913c373a26fac..4375ee9631556 100644 --- a/lib/SILOptimizer/Mandatory/MoveOnlyDiagnostics.cpp +++ b/lib/SILOptimizer/Mandatory/MoveOnlyDiagnostics.cpp @@ -542,6 +542,19 @@ void DiagnosticEmitter::emitObjectDiagnosticsForPartialApplyUses( // MARK: Address Diagnostics //===----------------------------------------------------------------------===// +static bool isClosureCapture(MarkMustCheckInst *markedValue) { + SILValue val = markedValue->getOperand(); + + // look past any project-box + if (auto *pbi = dyn_cast(val)) + val = pbi->getOperand(); + + if (auto *fArg = dyn_cast(val)) + return fArg->isClosureCapture(); + + return false; +} + void DiagnosticEmitter::emitAddressExclusivityHazardDiagnostic( MarkMustCheckInst *markedValue, SILInstruction *consumingUser) { if (!useWithDiagnostic.insert(consumingUser).second) @@ -596,8 +609,8 @@ void DiagnosticEmitter::emitAddressDiagnostic(MarkMustCheckInst *markedValue, diagnose( astContext, markedValue, diag:: - sil_movechecking_inout_not_reinitialized_before_end_of_function, - varName); + sil_movechecking_not_reinitialized_before_end_of_function, + varName, isClosureCapture(markedValue)); diagnose(astContext, violatingUser, diag::sil_movechecking_consuming_use_here); return; @@ -647,8 +660,8 @@ void DiagnosticEmitter::emitInOutEndOfFunctionDiagnostic( // consuming message: diagnose( astContext, markedValue, - diag::sil_movechecking_inout_not_reinitialized_before_end_of_function, - varName); + diag::sil_movechecking_not_reinitialized_before_end_of_function, + varName, isClosureCapture(markedValue)); diagnose(astContext, violatingUser, diag::sil_movechecking_consuming_use_here); } diff --git a/test/SILOptimizer/discard_checking.swift b/test/SILOptimizer/discard_checking.swift index d8c2ebba5ef57..322c1eb66487c 100644 --- a/test/SILOptimizer/discard_checking.swift +++ b/test/SILOptimizer/discard_checking.swift @@ -388,7 +388,7 @@ struct Basics: ~Copyable { // FIXME move checker is treating the defer like a closure capture (rdar://100468597) // not expecting any errors here - consuming func brokenPositiveTest(_ i: Int) { // expected-error {{missing reinitialization of inout parameter 'self' after consume}} + consuming func brokenPositiveTest(_ i: Int) { // expected-error {{missing reinitialization of closure capture 'self' after consume}} defer { discard self } // expected-note {{consumed here}} switch i { case 0, 1, 2, 3: return diff --git a/test/SILOptimizer/moveonly_addresschecker_diagnostics.swift b/test/SILOptimizer/moveonly_addresschecker_diagnostics.swift index ca449ab9416ab..44319d7b967dd 100644 --- a/test/SILOptimizer/moveonly_addresschecker_diagnostics.swift +++ b/test/SILOptimizer/moveonly_addresschecker_diagnostics.swift @@ -3083,7 +3083,7 @@ public func closureLetClassUseAfterConsumeArg(_ argX: inout Klass) { // We do not support captures of vars by closures today. public func closureLetCaptureClassUseAfterConsume() { - var x2 = Klass() // expected-error {{missing reinitialization of inout parameter 'x2' after consume}} + var x2 = Klass() // expected-error {{missing reinitialization of closure capture 'x2' after consume}} // expected-error @-1 {{'x2' consumed more than once}} x2 = Klass() let f = { @@ -3096,7 +3096,7 @@ public func closureLetCaptureClassUseAfterConsume() { } public func closureLetCaptureClassUseAfterConsume2() { - var x2 = Klass() // expected-error {{missing reinitialization of inout parameter 'x2' after consume}} + var x2 = Klass() // expected-error {{missing reinitialization of closure capture 'x2' after consume}} x2 = Klass() let f = { borrowVal(x2) @@ -3106,7 +3106,7 @@ public func closureLetCaptureClassUseAfterConsume2() { } public func closureLetCaptureClassUseAfterConsumeError() { - var x2 = Klass() // expected-error {{missing reinitialization of inout parameter 'x2' after consume}} + var x2 = Klass() // expected-error {{missing reinitialization of closure capture 'x2' after consume}} // expected-error @-1 {{'x2' consumed more than once}} // expected-error @-2 {{'x2' consumed more than once}} x2 = Klass() @@ -3254,7 +3254,7 @@ public func closureVarCaptureClassArgUseAfterConsume(_ x2: inout Klass) { public func deferCaptureClassUseAfterConsume() { var x2 = Klass() // expected-error @-1 {{'x2' used after consume}} - // expected-error @-2 {{missing reinitialization of inout parameter 'x2' after consume}} + // expected-error @-2 {{missing reinitialization of closure capture 'x2' after consume}} // expected-error @-3 {{'x2' consumed more than once}} x2 = Klass() defer { // expected-note {{used here}} @@ -3269,7 +3269,7 @@ public func deferCaptureClassUseAfterConsume() { public func deferCaptureClassUseAfterConsume2() { var x2 = Klass() - // expected-error @-1 {{missing reinitialization of inout parameter 'x2' after consume}} + // expected-error @-1 {{missing reinitialization of closure capture 'x2' after consume}} // expected-error @-2 {{'x2' consumed more than once}} // expected-error @-3 {{'x2' used after consume}} x2 = Klass() @@ -3284,7 +3284,7 @@ public func deferCaptureClassUseAfterConsume2() { } public func deferCaptureClassArgUseAfterConsume(_ x2: inout Klass) { - // expected-error @-1 {{missing reinitialization of inout parameter 'x2' after consume}} + // expected-error @-1 {{missing reinitialization of closure capture 'x2' after consume}} // expected-error @-2 {{'x2' consumed more than once}} borrowVal(x2) defer { @@ -3298,7 +3298,7 @@ public func deferCaptureClassArgUseAfterConsume(_ x2: inout Klass) { public func closureLetAndDeferCaptureClassUseAfterConsume() { var x2 = Klass() - // expected-error @-1 {{missing reinitialization of inout parameter 'x2' after consume}} + // expected-error @-1 {{missing reinitialization of closure capture 'x2' after consume}} // expected-error @-2 {{'x2' consumed more than once}} x2 = Klass() let f = { @@ -3316,7 +3316,7 @@ public func closureLetAndDeferCaptureClassUseAfterConsume() { public func closureLetAndDeferCaptureClassUseAfterConsume2() { var x2 = Klass() // expected-error {{'x2' used after consume}} - // expected-error @-1 {{missing reinitialization of inout parameter 'x2' after consume}} + // expected-error @-1 {{missing reinitialization of closure capture 'x2' after consume}} // expected-error @-2 {{'x2' consumed more than once}} x2 = Klass() let f = { @@ -3335,7 +3335,7 @@ public func closureLetAndDeferCaptureClassUseAfterConsume2() { public func closureLetAndDeferCaptureClassUseAfterConsume3() { var x2 = Klass() // expected-error {{'x2' used after consume}} - // expected-error @-1 {{missing reinitialization of inout parameter 'x2' after consume}} + // expected-error @-1 {{missing reinitialization of closure capture 'x2' after consume}} // expected-error @-2 {{'x2' consumed more than once}} x2 = Klass() let f = { @@ -3354,7 +3354,7 @@ public func closureLetAndDeferCaptureClassUseAfterConsume3() { } public func closureLetAndDeferCaptureClassArgUseAfterConsume(_ x2: inout Klass) { - // expected-error @-1 {{missing reinitialization of inout parameter 'x2' after consume}} + // expected-error @-1 {{missing reinitialization of closure capture 'x2' after consume}} // expected-error @-2 {{'x2' consumed more than once}} // expected-note @-3 {{'x2' is declared 'inout'}} let f = { // expected-error {{escaping closure captures 'inout' parameter 'x2'}} @@ -3377,7 +3377,7 @@ public func closureLetAndDeferCaptureClassArgUseAfterConsume(_ x2: inout Klass) public func closureLetAndClosureCaptureClassUseAfterConsume() { var x2 = Klass() // expected-error {{'x2' consumed more than once}} - // expected-error @-1 {{missing reinitialization of inout parameter 'x2' after consume}} + // expected-error @-1 {{missing reinitialization of closure capture 'x2' after consume}} x2 = Klass() let f = { let g = { @@ -3393,7 +3393,7 @@ public func closureLetAndClosureCaptureClassUseAfterConsume() { public func closureLetAndClosureCaptureClassUseAfterConsume2() { var x2 = Klass() // expected-error {{'x2' consumed more than once}} - // expected-error @-1 {{missing reinitialization of inout parameter 'x2' after consume}} + // expected-error @-1 {{missing reinitialization of closure capture 'x2' after consume}} x2 = Klass() let f = { let g = { @@ -3436,7 +3436,7 @@ public func closureLetAndClosureCaptureClassArgUseAfterConsume(_ x2: inout Klass public func closureVarAndDeferCaptureClassUseAfterConsume(_ x: borrowing Klass) { // expected-error {{'x' is borrowed and cannot be consumed}} var x2 = Klass() // expected-error {{'x2' consumed more than once}} - // expected-error @-1 {{missing reinitialization of inout parameter 'x2' after consume}} + // expected-error @-1 {{missing reinitialization of closure capture 'x2' after consume}} x2 = x // expected-note {{consumed here}} var f = {} f = { @@ -3453,7 +3453,7 @@ public func closureVarAndDeferCaptureClassUseAfterConsume(_ x: borrowing Klass) public func closureVarAndDeferCaptureClassUseAfterConsume2(_ x: borrowing Klass) { // expected-error {{'x' is borrowed and cannot be consumed}} var x2 = Klass() - // expected-error @-1 {{missing reinitialization of inout parameter 'x2' after consume}} + // expected-error @-1 {{missing reinitialization of closure capture 'x2' after consume}} // expected-error @-2 {{'x2' consumed more than once}} x2 = x // expected-note {{consumed here}} var f = {} @@ -3474,7 +3474,7 @@ public func closureVarAndDeferCaptureClassUseAfterConsume2(_ x: borrowing Klass) public func closureVarAndDeferCaptureClassUseAfterConsume3(_ x: borrowing Klass) { // expected-error {{'x' is borrowed and cannot be consumed}} var x2 = Klass() // expected-error @-1 {{'x2' consumed more than once}} - // expected-error @-2 {{missing reinitialization of inout parameter 'x2' after consume}} + // expected-error @-2 {{missing reinitialization of closure capture 'x2' after consume}} x2 = x // expected-note @-1 {{consumed here}} var f = {} @@ -3522,7 +3522,7 @@ public func closureVarAndDeferCaptureClassOwnedArgUseAfterConsume(_ x2: __owned } public func closureVarAndDeferCaptureClassOwnedArgUseAfterConsume2(_ x2: consuming Klass) { - // expected-error @-1 {{missing reinitialization of inout parameter 'x2' after consume}} + // expected-error @-1 {{missing reinitialization of closure capture 'x2' after consume}} // expected-error @-2 {{'x2' consumed more than once}} var f = {} f = { @@ -3555,7 +3555,7 @@ public func closureVarAndDeferCaptureClassOwnedArgUseAfterConsume3(_ x2: __owned public func closureVarAndDeferCaptureClassOwnedArgUseAfterConsume4(_ x2: consuming Klass) { // expected-error @-1 {{'x2' consumed more than once}} - // expected-error @-2 {{missing reinitialization of inout parameter 'x2' after consume}} + // expected-error @-2 {{missing reinitialization of closure capture 'x2' after consume}} var f = {} f = { defer { diff --git a/test/SILOptimizer/moveonly_nonescaping_closures.swift b/test/SILOptimizer/moveonly_nonescaping_closures.swift index 3d37a81ae36cc..c2c1bec70ee7e 100644 --- a/test/SILOptimizer/moveonly_nonescaping_closures.swift +++ b/test/SILOptimizer/moveonly_nonescaping_closures.swift @@ -82,7 +82,7 @@ func d(x: __owned M) { // expected-error {{noncopyable 'x' cannot be consumed wh // expected-note @-1 {{consumed here}} } -func d2(x: consuming M) { // expected-error {{missing reinitialization of inout parameter 'x' after consume}} +func d2(x: consuming M) { // expected-error {{missing reinitialization of closure capture 'x' after consume}} clodger({ consume(x) }) // expected-note @-1 {{consumed here}} } @@ -129,7 +129,7 @@ func k(x: borrowing M) { } -func l(x: inout M) { // expected-error {{missing reinitialization of inout parameter 'x' after consume}} +func l(x: inout M) { // expected-error {{missing reinitialization of closure capture 'x' after consume}} clodger({ consume(x) }) // expected-note {{consumed here}} } diff --git a/test/SILOptimizer/moveonly_objectchecker_diagnostics.swift b/test/SILOptimizer/moveonly_objectchecker_diagnostics.swift index 9146484efc167..97b95ef1f6934 100644 --- a/test/SILOptimizer/moveonly_objectchecker_diagnostics.swift +++ b/test/SILOptimizer/moveonly_objectchecker_diagnostics.swift @@ -2777,7 +2777,7 @@ public func closureLetCaptureClassUseAfterConsume(_ x: consuming Klass) { public func closureLetCaptureClassUseAfterConsume1(_ x: borrowing Klass) { // expected-error {{'x' is borrowed and cannot be consumed}} var x2 = x // expected-note {{consumed here}} // expected-error @-1 {{'x2' consumed more than once}} - // expected-error @-2 {{missing reinitialization of inout parameter 'x2' after consume}} + // expected-error @-2 {{missing reinitialization of closure capture 'x2' after consume}} x2 = x // expected-note {{consumed here}} let f = { @@ -2802,7 +2802,7 @@ public func closureLetCaptureClassUseAfterConsume2(_ x2: inout Klass) { // TODO: We are considering this to be an escaping use. public func closureLetCaptureClassUseAfterConsume3(_ x2: inout Klass) { // expected-error @-1 {{'x2' consumed more than once}} - // expected-error @-2 {{missing reinitialization of inout parameter 'x2' after consume}} + // expected-error @-2 {{missing reinitialization of closure capture 'x2' after consume}} func useClosure(_ x: () -> ()) {} useClosure { @@ -2852,7 +2852,7 @@ public func closureLetCaptureClassOwnedArgUseAfterConsume(_ x2: __owned Klass) { public func closureLetCaptureClassOwnedArgUseAfterConsume2(_ x2: consuming Klass) { // expected-error @-1 {{'x2' consumed more than once}} - // expected-error @-2 {{missing reinitialization of inout parameter 'x2' after consume}} + // expected-error @-2 {{missing reinitialization of closure capture 'x2' after consume}} let f = { borrowVal(x2) consumeVal(x2) // expected-note {{consumed here}} @@ -2878,7 +2878,7 @@ public func closureLetCaptureClassOwnedArgUseAfterConsume3(_ x2: __owned Klass) public func closureLetCaptureClassOwnedArgUseAfterConsume4(_ x2: consuming Klass) { // expected-error @-1 {{'x2' consumed more than once}} // expected-error @-2 {{'x2' consumed more than once}} - // expected-error @-3 {{missing reinitialization of inout parameter 'x2' after consume}} + // expected-error @-3 {{missing reinitialization of closure capture 'x2' after consume}} let f = { borrowVal(x2) consumeVal(x2) // expected-note {{consumed here}} @@ -2980,7 +2980,7 @@ public func closureVarCaptureClassUseAfterConsume3(_ x2: inout Klass) { public func closureVarCaptureClassUseAfterConsume4(_ x2: inout Klass) { // expected-error @-1 {{'x2' consumed more than once}} - // expected-error @-2 {{missing reinitialization of inout parameter 'x2' after consume}} + // expected-error @-2 {{missing reinitialization of closure capture 'x2' after consume}} func useClosure(_ x: () -> ()) {} useClosure { @@ -3115,7 +3115,7 @@ public func deferCaptureClassOwnedArgUseAfterConsume(_ x2: __owned Klass) { } public func deferCaptureClassOwnedArgUseAfterConsume2(_ x2: consuming Klass) { - // expected-error @-1 {{missing reinitialization of inout parameter 'x2' after consume}} + // expected-error @-1 {{missing reinitialization of closure capture 'x2' after consume}} // expected-error @-2 {{'x2' consumed more than once}} defer { borrowVal(x2) @@ -3138,7 +3138,7 @@ public func deferCaptureClassOwnedArgUseAfterConsume3(_ x2: __owned Klass) { } public func deferCaptureClassOwnedArgUseAfterConsume4(_ x2: consuming Klass) { - // expected-error @-1 {{missing reinitialization of inout parameter 'x2' after consume}} + // expected-error @-1 {{missing reinitialization of closure capture 'x2' after consume}} // expected-error @-2 {{'x2' consumed more than once}} // expected-error @-3 {{'x2' used after consume}} defer { // expected-note {{used here}} @@ -3232,7 +3232,7 @@ public func closureLetAndDeferCaptureClassOwnedArgUseAfterConsume(_ x2: __owned } public func closureLetAndDeferCaptureClassOwnedArgUseAfterConsume2(_ x2: consuming Klass) { - // expected-error @-1 {{missing reinitialization of inout parameter 'x2' after consume}} + // expected-error @-1 {{missing reinitialization of closure capture 'x2' after consume}} // expected-error @-2 {{'x2' consumed more than once}} let f = { defer { @@ -3263,7 +3263,7 @@ public func closureLetAndDeferCaptureClassOwnedArgUseAfterConsume3(_ x2: __owned public func closureLetAndDeferCaptureClassOwnedArgUseAfterConsume4(_ x2: consuming Klass) { // expected-error @-1 {{'x2' consumed more than once}} - // expected-error @-2 {{missing reinitialization of inout parameter 'x2' after consume}} + // expected-error @-2 {{missing reinitialization of closure capture 'x2' after consume}} let f = { defer { borrowVal(x2) @@ -3321,7 +3321,7 @@ public func closureLetAndClosureCaptureClassUseAfterConsume3(_ x: borrowing Klas var x2 = x // expected-note @-1 {{consumed here}} // expected-error @-2 {{'x2' consumed more than once}} - // expected-error @-3 {{missing reinitialization of inout parameter 'x2' after consume}} + // expected-error @-3 {{missing reinitialization of closure capture 'x2' after consume}} // expected-error @-4 {{'x2' consumed more than once}} x2 = x // expected-note @-1 {{consumed here}} @@ -3372,7 +3372,7 @@ public func closureLetAndClosureCaptureClassOwnedArgUseAfterConsume(_ x2: __owne public func closureLetAndClosureCaptureClassOwnedArgUseAfterConsume2(_ x2: consuming Klass) { // expected-error @-1 {{'x2' consumed more than once}} - // expected-error @-2 {{missing reinitialization of inout parameter 'x2' after consume}} + // expected-error @-2 {{missing reinitialization of closure capture 'x2' after consume}} let f = { let g = { borrowVal(x2) @@ -3401,7 +3401,7 @@ public func closureLetAndClosureCaptureClassOwnedArgUseAfterConsume3(_ x2: __own } public func closureLetAndClosureCaptureClassOwnedArgUseAfterConsume4(_ x2: consuming Klass) { - // expected-error @-1 {{missing reinitialization of inout parameter 'x2' after consume}} + // expected-error @-1 {{missing reinitialization of closure capture 'x2' after consume}} // expected-error @-2 {{'x2' consumed more than once}} let f = { let g = { @@ -3417,7 +3417,7 @@ public func closureLetAndClosureCaptureClassOwnedArgUseAfterConsume4(_ x2: consu } public func closureLetAndClosureCaptureClassOwnedArgUseAfterConsume5(_ x2: consuming Klass) { - // expected-error @-1 {{missing reinitialization of inout parameter 'x2' after consume}} + // expected-error @-1 {{missing reinitialization of closure capture 'x2' after consume}} // expected-error @-2 {{'x2' consumed more than once}} // expected-error @-3 {{'x2' used after consume}} let f = { @@ -3518,7 +3518,7 @@ public func closureVarAndDeferCaptureClassOwnedArgUseAfterConsume(_ x2: __owned } public func closureVarAndDeferCaptureClassOwnedArgUseAfterConsume2(_ x2: consuming Klass) { - // expected-error @-1 {{missing reinitialization of inout parameter 'x2' after consume}} + // expected-error @-1 {{missing reinitialization of closure capture 'x2' after consume}} // expected-error @-2 {{'x2' consumed more than once}} var f = {} f = { @@ -3551,7 +3551,7 @@ public func closureVarAndDeferCaptureClassOwnedArgUseAfterConsume3(_ x2: __owned public func closureVarAndDeferCaptureClassOwnedArgUseAfterConsume4(_ x2: consuming Klass) { // expected-error @-1 {{'x2' consumed more than once}} - // expected-error @-2 {{missing reinitialization of inout parameter 'x2' after consume}} + // expected-error @-2 {{missing reinitialization of closure capture 'x2' after consume}} var f = {} f = { defer { diff --git a/test/SILOptimizer/moveonly_trivial_addresschecker_diagnostics.swift b/test/SILOptimizer/moveonly_trivial_addresschecker_diagnostics.swift index 284745459fe04..0546c129efeea 100644 --- a/test/SILOptimizer/moveonly_trivial_addresschecker_diagnostics.swift +++ b/test/SILOptimizer/moveonly_trivial_addresschecker_diagnostics.swift @@ -1200,7 +1200,7 @@ public func closureClassUseAfterConsumeArg(_ argX: inout NonTrivialStruct) { // We do not support captures of vars by closures today. public func closureCaptureClassUseAfterConsume() { var x2 = NonTrivialStruct() - // expected-error @-1 {{missing reinitialization of inout parameter 'x2' after consume}} + // expected-error @-1 {{missing reinitialization of closure capture 'x2' after consume}} // expected-error @-2 {{'x2' consumed more than once}} x2 = NonTrivialStruct() let f = { @@ -1216,7 +1216,7 @@ public func closureCaptureClassUseAfterConsumeError() { var x2 = NonTrivialStruct() // expected-error @-1 {{'x2' consumed more than once}} // expected-error @-2 {{'x2' consumed more than once}} - // expected-error @-3 {{missing reinitialization of inout parameter 'x2' after consume}} + // expected-error @-3 {{missing reinitialization of closure capture 'x2' after consume}} // expected-error @-4 {{'x2' consumed more than once}} // expected-error @-5 {{'x2' consumed more than once}} x2 = NonTrivialStruct() @@ -1251,7 +1251,7 @@ public func closureCaptureClassArgUseAfterConsume(_ x2: inout NonTrivialStruct) // TODO: Improve error msg here to make it clear the use is due to the defer. public func deferCaptureClassUseAfterConsume() { var x2 = NonTrivialStruct() - // expected-error @-1 {{missing reinitialization of inout parameter 'x2' after consume}} + // expected-error @-1 {{missing reinitialization of closure capture 'x2' after consume}} // expected-error @-2 {{'x2' consumed more than once}} // expected-error @-3 {{'x2' used after consume}} x2 = NonTrivialStruct() @@ -1266,7 +1266,7 @@ public func deferCaptureClassUseAfterConsume() { public func deferCaptureClassUseAfterConsume2() { var x2 = NonTrivialStruct() - // expected-error @-1 {{missing reinitialization of inout parameter 'x2' after consume}} + // expected-error @-1 {{missing reinitialization of closure capture 'x2' after consume}} // expected-error @-2 {{'x2' consumed more than once}} // expected-error @-3 {{'x2' used after consume}} x2 = NonTrivialStruct() @@ -1281,7 +1281,7 @@ public func deferCaptureClassUseAfterConsume2() { } public func deferCaptureClassArgUseAfterConsume(_ x2: inout NonTrivialStruct) { - // expected-error @-1 {{missing reinitialization of inout parameter 'x2' after consume}} + // expected-error @-1 {{missing reinitialization of closure capture 'x2' after consume}} // expected-error @-2 {{'x2' consumed more than once}} borrowVal(x2) defer { @@ -1295,7 +1295,7 @@ public func deferCaptureClassArgUseAfterConsume(_ x2: inout NonTrivialStruct) { public func closureAndDeferCaptureClassUseAfterConsume() { var x2 = NonTrivialStruct() - // expected-error @-1 {{missing reinitialization of inout parameter 'x2' after consume}} + // expected-error @-1 {{missing reinitialization of closure capture 'x2' after consume}} // expected-error @-2 {{'x2' consumed more than once}} x2 = NonTrivialStruct() let f = { @@ -1313,7 +1313,7 @@ public func closureAndDeferCaptureClassUseAfterConsume() { public func closureAndDeferCaptureClassUseAfterConsume2() { var x2 = NonTrivialStruct() - // expected-error @-1 {{missing reinitialization of inout parameter 'x2' after consume}} + // expected-error @-1 {{missing reinitialization of closure capture 'x2' after consume}} // expected-error @-2 {{'x2' consumed more than once}} // expected-error @-3 {{'x2' used after consume}} x2 = NonTrivialStruct() @@ -1333,7 +1333,7 @@ public func closureAndDeferCaptureClassUseAfterConsume2() { public func closureAndDeferCaptureClassUseAfterConsume3() { var x2 = NonTrivialStruct() - // expected-error @-1 {{missing reinitialization of inout parameter 'x2' after consume}} + // expected-error @-1 {{missing reinitialization of closure capture 'x2' after consume}} // expected-error @-2 {{'x2' consumed more than once}} // expected-error @-3 {{'x2' used after consume}} x2 = NonTrivialStruct() @@ -1353,7 +1353,7 @@ public func closureAndDeferCaptureClassUseAfterConsume3() { } public func closureAndDeferCaptureClassArgUseAfterConsume(_ x2: inout NonTrivialStruct) { - // expected-error @-1 {{missing reinitialization of inout parameter 'x2' after consume}} + // expected-error @-1 {{missing reinitialization of closure capture 'x2' after consume}} // expected-error @-2 {{'x2' consumed more than once}} // expected-note @-3 {{'x2' is declared 'inout'}} let f = { // expected-error {{escaping closure captures 'inout' parameter 'x2'}} @@ -1373,7 +1373,7 @@ public func closureAndDeferCaptureClassArgUseAfterConsume(_ x2: inout NonTrivial public func closureAndClosureCaptureClassUseAfterConsume() { var x2 = NonTrivialStruct() // expected-error @-1 {{'x2' consumed more than once}} - // expected-error @-2 {{missing reinitialization of inout parameter 'x2' after consume}} + // expected-error @-2 {{missing reinitialization of closure capture 'x2' after consume}} x2 = NonTrivialStruct() let f = { let g = { @@ -1390,7 +1390,7 @@ public func closureAndClosureCaptureClassUseAfterConsume() { public func closureAndClosureCaptureClassUseAfterConsume2() { var x2 = NonTrivialStruct() // expected-error @-1 {{'x2' consumed more than once}} - // expected-error @-2 {{missing reinitialization of inout parameter 'x2' after consume}} + // expected-error @-2 {{missing reinitialization of closure capture 'x2' after consume}} x2 = NonTrivialStruct() let f = { let g = { @@ -1408,7 +1408,7 @@ public func closureAndClosureCaptureClassUseAfterConsume2() { public func closureAndClosureCaptureClassUseAfterConsume3() { var x2 = NonTrivialStruct() // expected-error @-1 {{'x2' consumed more than once}} - // expected-error @-2 {{missing reinitialization of inout parameter 'x2' after consume}} + // expected-error @-2 {{missing reinitialization of closure capture 'x2' after consume}} // expected-error @-3 {{'x2' used after consume}} x2 = NonTrivialStruct() let f = { diff --git a/test/SILOptimizer/moveonly_trivial_objectchecker_diagnostics.swift b/test/SILOptimizer/moveonly_trivial_objectchecker_diagnostics.swift index 239dd82584050..f08448dbeae24 100644 --- a/test/SILOptimizer/moveonly_trivial_objectchecker_diagnostics.swift +++ b/test/SILOptimizer/moveonly_trivial_objectchecker_diagnostics.swift @@ -1810,7 +1810,7 @@ public func closureCaptureClassOwnedArgUseAfterConsume(_ x2: __owned NonTrivialS } public func closureCaptureClassOwnedArgUseAfterConsume2(_ x2: consuming NonTrivialStruct) { - // expected-error @-1 {{missing reinitialization of inout parameter 'x2' after consume}} + // expected-error @-1 {{missing reinitialization of closure capture 'x2' after consume}} // expected-error @-2 {{'x2' consumed more than once}} let f = { borrowVal(x2) @@ -1835,7 +1835,7 @@ public func closureCaptureClassOwnedArgUseAfterConsume3(_ x2: __owned NonTrivial } public func closureCaptureClassOwnedArgUseAfterConsume4(_ x2: consuming NonTrivialStruct) { - // expected-error @-1 {{missing reinitialization of inout parameter 'x2' after consume}} + // expected-error @-1 {{missing reinitialization of closure capture 'x2' after consume}} // expected-error @-2 {{'x2' consumed more than once}} // expected-error @-3 {{'x2' consumed more than once}} let f = { @@ -1898,7 +1898,7 @@ public func deferCaptureClassOwnedArgUseAfterConsume(_ x2: __owned NonTrivialStr public func deferCaptureClassOwnedArgUseAfterConsume2(_ x2: consuming NonTrivialStruct) { // expected-error @-1 {{'x2' consumed more than once}} - // expected-error @-2 {{missing reinitialization of inout parameter 'x2' after consume}} + // expected-error @-2 {{missing reinitialization of closure capture 'x2' after consume}} defer { borrowVal(x2) consumeVal(x2) // expected-note {{consumed here}} @@ -1920,7 +1920,7 @@ public func deferCaptureClassOwnedArgUseAfterConsume3(_ x2: __owned NonTrivialSt } public func deferCaptureClassOwnedArgUseAfterConsume4(_ x2: consuming NonTrivialStruct) { - // expected-error @-1 {{missing reinitialization of inout parameter 'x2' after consume}} + // expected-error @-1 {{missing reinitialization of closure capture 'x2' after consume}} // expected-error @-2 {{'x2' used after consume}} // expected-error @-3 {{'x2' consumed more than once}} defer { // expected-note {{used here}} @@ -2009,7 +2009,7 @@ public func closureAndDeferCaptureClassOwnedArgUseAfterConsume(_ x2: __owned Non } public func closureAndDeferCaptureClassOwnedArgUseAfterConsume2(_ x2: consuming NonTrivialStruct) { - // expected-error @-1 {{missing reinitialization of inout parameter 'x2' after consume}} + // expected-error @-1 {{missing reinitialization of closure capture 'x2' after consume}} // expected-error @-2 {{'x2' consumed more than once}} let f = { defer { @@ -2038,7 +2038,7 @@ public func closureAndDeferCaptureClassOwnedArgUseAfterConsume3(_ x2: __owned No } public func closureAndDeferCaptureClassOwnedArgUseAfterConsume4(_ x2: consuming NonTrivialStruct) { - // expected-error @-1 {{missing reinitialization of inout parameter 'x2' after consume}} + // expected-error @-1 {{missing reinitialization of closure capture 'x2' after consume}} // expected-error @-2 {{'x2' consumed more than once}} let f = { defer { @@ -2116,7 +2116,7 @@ public func closureAndClosureCaptureClassOwnedArgUseAfterConsume(_ x2: __owned N public func closureAndClosureCaptureClassOwnedArgUseAfterConsume2(_ x2: consuming NonTrivialStruct) { // expected-error @-1 {{'x2' consumed more than once}} - // expected-error @-2 {{missing reinitialization of inout parameter 'x2' after consume}} + // expected-error @-2 {{missing reinitialization of closure capture 'x2' after consume}} let f = { let g = { borrowVal(x2)