Skip to content

Commit 9741db1

Browse files
authored
Merge pull request #3566 from rudkx/improve-inout-capture-diagnostic
Improve wording of diagnostic about escaping closures capturing inout…
2 parents 2a86010 + 04baadb commit 9741db1

File tree

3 files changed

+5
-4
lines changed

3 files changed

+5
-4
lines changed

include/swift/AST/DiagnosticsSema.def

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2155,7 +2155,7 @@ NOTE(transitive_capture_through_here,none,
21552155
(Identifier, Identifier))
21562156

21572157
ERROR(closure_implicit_capture_without_noescape,none,
2158-
"closure cannot implicitly capture an inout parameter unless @noescape",
2158+
"escaping closures can only capture inout parameters explicitly by value",
21592159
())
21602160
ERROR(closure_implicit_capture_mutating_self,none,
21612161
"closure cannot implicitly capture a mutating self parameter",

test/SILOptimizer/allocbox_to_stack_not_crash.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@ infix operator ~> { precedence 255 }
66
protocol Target {}
77

88
func ~> <Target, Arg0, Result>(x: inout Target, f: (_: inout Target, _: Arg0) -> Result) -> (Arg0) -> Result {
9-
return { f(&x, $0) } // expected-error {{closure cannot implicitly capture an inout parameter unless @noescape}}
9+
return { f(&x, $0) } // expected-error {{escaping closures can only capture inout parameters explicitly by value}}
1010
}
1111

1212
func ~> (x: inout Int, f: (_: inout Int, _: Target) -> Target) -> (Target) -> Target {
13-
return { f(&x, $0) } // expected-error {{closure cannot implicitly capture an inout parameter unless @noescape}}
13+
return { f(&x, $0) } // expected-error {{escaping closures can only capture inout parameters explicitly by value}}
1414
}
1515

test/Sema/diag_invalid_inout_captures.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ struct you_cry_in_your_tea {
1212

1313
func why_so_sad(line: inout String) {
1414
no_escape { line = "Remember we made an arrangement when you went away" } // OK
15-
do_escape { line = "now you're making me mad" } // expected-error {{closure cannot implicitly capture an inout parameter unless @noescape}}
15+
do_escape { line = "now you're making me mad" } // expected-error {{escaping closures can only capture inout parameters explicitly by value}}
16+
do_escape { [line] in _ = line } // OK
1617
}
1718

1819
func remember(line: inout String) -> () -> Void {

0 commit comments

Comments
 (0)