Skip to content

Commit 703595e

Browse files
committed
[Concurrent] Warnings/errors should use "sendable" not "concurrent"
Resolves rdar://83416205
1 parent 3ad6d00 commit 703595e

11 files changed

+39
-39
lines changed

include/swift/AST/DiagnosticsSIL.def

+2-2
Original file line numberDiff line numberDiff line change
@@ -676,9 +676,9 @@ WARNING(semantic_function_improper_nesting, none, "'@_semantics' function calls
676676

677677
// Capture promotion diagnostics
678678
WARNING(capturepromotion_concurrentcapture_mutation, none,
679-
"'%0' mutated after capture by concurrent closure", (StringRef))
679+
"'%0' mutated after capture by sendable closure", (StringRef))
680680
NOTE(capturepromotion_concurrentcapture_closure_here, none,
681-
"variable captured by concurrent closure", ())
681+
"variable captured by sendable closure", ())
682682
NOTE(capturepromotion_concurrentcapture_capturinguse_here, none,
683683
"capturing use", ())
684684
NOTE(capturepromotion_variable_defined_here,none,

include/swift/AST/DiagnosticsSema.def

+5-5
Original file line numberDiff line numberDiff line change
@@ -3883,28 +3883,28 @@ NOTE(silence_debug_description_in_interpolation_segment_call,none,
38833883
"use 'String(describing:)' to silence this warning", ())
38843884

38853885
NOTE(noescape_parameter,none,
3886-
"parameter %1 is implicitly %select{non-escaping|non-concurrent}0",
3886+
"parameter %1 is implicitly %select{non-escaping|non-sendable}0",
38873887
(unsigned, Identifier))
38883888
NOTE(generic_parameters_always_escaping,none,
38893889
"generic parameters are always considered '@escaping'", ())
38903890

38913891
ERROR(passing_noattrfunc_to_attrfunc,none,
3892-
"passing %select{non-escaping|non-concurrent}0 parameter %1 to function "
3892+
"passing %select{non-escaping|non-sendable}0 parameter %1 to function "
38933893
"expecting %select{an @escaping|a @Sendable}0 closure",
38943894
(unsigned, Identifier))
38953895
ERROR(converting_noespace_param_to_generic_type,none,
38963896
"converting non-escaping parameter %0 to generic parameter %1 may allow it to escape",
38973897
(Identifier, Type))
38983898
ERROR(assigning_noattrfunc_to_attrfunc,none,
3899-
"assigning %select{non-escaping|non-concurrent}0 parameter %1 to "
3899+
"assigning %select{non-escaping|non-sendable}0 parameter %1 to "
39003900
"%select{an @escaping|a @Sendable}0 closure",
39013901
(unsigned, Identifier))
39023902
ERROR(general_noattrfunc_to_attr,none,
3903-
"using %select{non-escaping|non-concurrent}0 parameter %1 in a context "
3903+
"using %select{non-escaping|non-sendable}0 parameter %1 in a context "
39043904
"expecting %select{an @escaping|a @Sendable}0 closure",
39053905
(unsigned, Identifier))
39063906
ERROR(converting_noattrfunc_to_type,none,
3907-
"converting %select{non-escaping|non-concurrent function}0 value to %1 "
3907+
"converting %select{non-escaping|non-sendable function}0 value to %1 "
39083908
"may %select{allow it to escape|introduce data races}0",
39093909
(unsigned, Type))
39103910
NOTE(escape_expected_at_parameter_position,none,

include/swift/Runtime/Concurrent.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ template <class ElemTy> struct ConcurrentList {
6363

6464
/// Remove all of the links in the chain. This method leaves
6565
/// the list at a usable state and new links can be added.
66-
/// Notice that this operation is non-concurrent because
66+
/// Notice that this operation is non-sendable because
6767
/// we have no way of ensuring that no one is currently
6868
/// traversing the list.
6969
void clear() {

lib/Sema/CSDiagnostics.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -754,7 +754,7 @@ class AttributedFuncToTypeConversionFailure final : public ContextualFailure {
754754
bool diagnoseAsError() override;
755755

756756
private:
757-
/// Emit tailored diagnostics for no-escape/non-concurrent parameter
757+
/// Emit tailored diagnostics for no-escape/non-sendable parameter
758758
/// conversions e.g. passing such parameter as an @escaping or @Sendable
759759
/// argument, or trying to assign it to a variable which expects @escaping
760760
/// or @Sendable function.

lib/Sema/TypeCheckConcurrency.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -1629,7 +1629,7 @@ namespace {
16291629
}
16301630

16311631
if (result == AsyncMarkingResult::FoundAsync) {
1632-
// Check for non-concurrent types.
1632+
// Check for non-sendable types.
16331633
bool problemFound =
16341634
diagnoseNonSendableTypesInReference(
16351635
concDeclRef, getDeclContext()->getParentModule(), declLoc,

lib/Sema/TypeCheckConcurrency.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ void checkOverrideActorIsolation(ValueDecl *value);
218218
/// as async functions or actors.
219219
bool contextUsesConcurrencyFeatures(const DeclContext *dc);
220220

221-
/// Diagnose the presence of any non-concurrent types when referencing a
221+
/// Diagnose the presence of any non-sendable types when referencing a
222222
/// given declaration from a particular declaration context.
223223
///
224224
/// This function should be invoked any time that the given declaration

lib/Sema/TypeCheckProtocol.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -2932,7 +2932,7 @@ bool ConformanceChecker::checkActorIsolation(
29322932
witnessGlobalActor->isEqual(requirementGlobalActor))
29332933
return false;
29342934

2935-
// For cross-actor references, check for non-concurrent types.
2935+
// For cross-actor references, check for non-sendable types.
29362936
if (isCrossActor) {
29372937
// If the requirement was imported from Objective-C, it may not have been
29382938
// annotated appropriately. Allow the mismatch.

test/ClangImporter/objc_async.swift

+2-2
Original file line numberDiff line numberDiff line change
@@ -90,9 +90,9 @@ func testSlowServerOldSchool(slowServer: SlowServer) {
9090
_ = slowServer.allOperations
9191
}
9292

93-
func testSendable(fn: () -> Void) { // expected-note{{parameter 'fn' is implicitly non-concurrent}}
93+
func testSendable(fn: () -> Void) { // expected-note{{parameter 'fn' is implicitly non-sendable}}
9494
doSomethingConcurrently(fn)
95-
// expected-error@-1{{passing non-concurrent parameter 'fn' to function expecting a @Sendable closure}}
95+
// expected-error@-1{{passing non-sendable parameter 'fn' to function expecting a @Sendable closure}}
9696
doSomethingConcurrentlyButUnsafe(fn) // okay, @Sendable not part of the type
9797

9898
var x = 17

test/Concurrency/actor_isolation.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -603,7 +603,7 @@ func checkLocalFunctions() async {
603603
local1()
604604
local2()
605605

606-
// Non-concurrent closures don't cause problems.
606+
// non-sendable closures don't cause problems.
607607
acceptClosure {
608608
local1()
609609
local2()

test/Concurrency/concurrentfunction_capturediagnostics.swift

+20-20
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,9 @@ func testCaseTrivialValue() {
2929
// We only emit a warning here since we use the last write.
3030
//
3131
// TODO: Should we emit for all writes?
32-
i.addOne() // expected-warning {{'i' mutated after capture by concurrent closure}}
32+
i.addOne() // expected-warning {{'i' mutated after capture by sendable closure}}
3333
// expected-note @-14 {{variable defined here}}
34-
// expected-note @-14 {{variable captured by concurrent closure}}
34+
// expected-note @-14 {{variable captured by sendable closure}}
3535
// expected-note @-14 {{capturing use}}
3636
// expected-note @-14 {{capturing use}}
3737
// expected-note @-14 {{capturing use}}
@@ -46,9 +46,9 @@ func testCaseTrivialValue2() {
4646
}
4747

4848
i2 = 20
49-
i2 += 21 // expected-warning {{'i2' mutated after capture by concurrent closure}}
49+
i2 += 21 // expected-warning {{'i2' mutated after capture by sendable closure}}
5050
// expected-note @-9 {{variable defined here}}
51-
// expected-note @-9 {{variable captured by concurrent closure}}
51+
// expected-note @-9 {{variable captured by sendable closure}}
5252
// expected-note @-9 {{capturing use}}
5353
// expected-note @-9 {{capturing use}}
5454
// expected-note @-9 {{capturing use}}
@@ -62,9 +62,9 @@ func testCaseTrivialValue3() {
6262
print(i3 + 19)
6363
}
6464

65-
i3 = 20 // expected-warning {{'i3' mutated after capture by concurrent closure}}
65+
i3 = 20 // expected-warning {{'i3' mutated after capture by sendable closure}}
6666
// expected-note @-8 {{variable defined here}}
67-
// expected-note @-8 {{variable captured by concurrent closure}}
67+
// expected-note @-8 {{variable captured by sendable closure}}
6868
// expected-note @-8 {{capturing use}}
6969
// expected-note @-8 {{capturing use}}
7070
// expected-note @-8 {{capturing use}}
@@ -78,9 +78,9 @@ func testCaseTrivialValue4() {
7878
print(i4 + 19)
7979
}
8080

81-
inoutUserInt(&i4) // expected-warning {{'i4' mutated after capture by concurrent closure}}
81+
inoutUserInt(&i4) // expected-warning {{'i4' mutated after capture by sendable closure}}
8282
// expected-note @-8 {{variable defined here}}
83-
// expected-note @-8 {{variable captured by concurrent closure}}
83+
// expected-note @-8 {{variable captured by sendable closure}}
8484
// expected-note @-8 {{capturing use}}
8585
// expected-note @-8 {{capturing use}}
8686
// expected-note @-8 {{capturing use}}
@@ -98,9 +98,9 @@ func testCaseClass() {
9898
print(i)
9999
}
100100

101-
i = Klass() // expected-warning {{'i' mutated after capture by concurrent closure}}
101+
i = Klass() // expected-warning {{'i' mutated after capture by sendable closure}}
102102
// expected-note @-6 {{variable defined here}}
103-
// expected-note @-6 {{variable captured by concurrent closure}}
103+
// expected-note @-6 {{variable captured by sendable closure}}
104104
// expected-note @-6 {{capturing use}}
105105
}
106106

@@ -109,9 +109,9 @@ func testCaseClassInout() {
109109
f {
110110
print(i2)
111111
}
112-
inoutUserKlass(&i2) // expected-warning {{'i2' mutated after capture by concurrent closure}}
112+
inoutUserKlass(&i2) // expected-warning {{'i2' mutated after capture by sendable closure}}
113113
// expected-note @-5 {{variable defined here}}
114-
// expected-note @-5 {{variable captured by concurrent closure}}
114+
// expected-note @-5 {{variable captured by sendable closure}}
115115
// expected-note @-5 {{capturing use}}
116116
}
117117

@@ -154,9 +154,9 @@ func testCaseNonTrivialValue() {
154154
// We only emit a warning here since we use the last write.
155155
//
156156
// TODO: Should we emit for all writes?
157-
i.i.addOne() // expected-warning {{'i' mutated after capture by concurrent closure}}
157+
i.i.addOne() // expected-warning {{'i' mutated after capture by sendable closure}}
158158
// expected-note @-14 {{variable defined here}}
159-
// expected-note @-14 {{variable captured by concurrent closure}}
159+
// expected-note @-14 {{variable captured by sendable closure}}
160160
// expected-note @-14 {{capturing use}}
161161
// expected-note @-14 {{capturing use}}
162162
// expected-note @-14 {{capturing use}}
@@ -170,9 +170,9 @@ func testCaseNonTrivialValueInout() {
170170
}
171171

172172
// We only emit a warning here since we use the last write.
173-
inoutUserOptKlass(&i.k) // expected-warning {{'i' mutated after capture by concurrent closure}}
173+
inoutUserOptKlass(&i.k) // expected-warning {{'i' mutated after capture by sendable closure}}
174174
// expected-note @-8 {{variable defined here}}
175-
// expected-note @-8 {{variable captured by concurrent closure}}
175+
// expected-note @-8 {{variable captured by sendable closure}}
176176
// expected-note @-8 {{capturing use}}
177177
// expected-note @-8 {{capturing use}}
178178
}
@@ -190,9 +190,9 @@ func testCaseAddressOnlyAllocBoxToStackable<T : MyProt & Sendable>(i : T) {
190190
}
191191

192192
// TODO: Make sure we emit these once we support address only types!
193-
inoutUserOptKlass(&i2.k) // xpected-warning {{'i2' mutated after capture by concurrent closure}}
193+
inoutUserOptKlass(&i2.k) // xpected-warning {{'i2' mutated after capture by sendable closure}}
194194
// xpected-note @-8 {{variable defined here}}
195-
// xpected-note @-8 {{variable captured by concurrent closure}}
195+
// xpected-note @-8 {{variable captured by sendable closure}}
196196
// xpected-note @-8 {{capturing use}}
197197
// xpected-note @-8 {{capturing use}}
198198
}
@@ -208,9 +208,9 @@ func testCaseAddressOnlyNoAllocBoxToStackable<T : MyProt & Sendable>(i : T) {
208208
}
209209

210210
// TODO: Make sure we emit these once we support address only types!
211-
inoutUserOptKlass(&i2.k) // xpected-warning {{'i2' mutated after capture by concurrent closure}}
211+
inoutUserOptKlass(&i2.k) // xpected-warning {{'i2' mutated after capture by sendable closure}}
212212
// xpected-note @-8 {{variable defined here}}
213-
// xpected-note @-8 {{variable captured by concurrent closure}}
213+
// xpected-note @-8 {{variable captured by sendable closure}}
214214
// xpected-note @-8 {{capturing use}}
215215
// xpected-note @-8 {{capturing use}}
216216
}

test/attr/attr_concurrent.swift

+4-4
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,14 @@ func acceptsNonConcurrent(_ fn: (Int) -> Int) { }
2222

2323
func passingConcurrentOrNot(
2424
_ cfn: @Sendable (Int) -> Int,
25-
ncfn: (Int) -> Int // expected-note{{parameter 'ncfn' is implicitly non-concurrent}}{{9-9=@Sendable }}
25+
ncfn: (Int) -> Int // expected-note{{parameter 'ncfn' is implicitly non-sendable}}{{9-9=@Sendable }}
2626
) {
2727
// Okay due to overloading
2828
f(cfn)
2929
f(ncfn)
3030

3131
acceptsConcurrent(cfn) // okay
32-
acceptsConcurrent(ncfn) // expected-error{{passing non-concurrent parameter 'ncfn' to function expecting a @Sendable closure}}
32+
acceptsConcurrent(ncfn) // expected-error{{passing non-sendable parameter 'ncfn' to function expecting a @Sendable closure}}
3333
acceptsNonConcurrent(cfn) // okay
3434
acceptsNonConcurrent(ncfn) // okay
3535

@@ -49,8 +49,8 @@ func closures() {
4949
return i
5050
})
5151

52-
let closure1 = { $0 + 1 } // inferred to be non-concurrent
53-
acceptsConcurrent(closure1) // expected-error{{converting non-concurrent function value to '@Sendable (Int) -> Int' may introduce data races}}
52+
let closure1 = { $0 + 1 } // inferred to be non-sendable
53+
acceptsConcurrent(closure1) // expected-error{{converting non-sendable function value to '@Sendable (Int) -> Int' may introduce data races}}
5454
}
5555

5656
// Mutation of captured locals from within @Sendable functions.

0 commit comments

Comments
 (0)