Skip to content

Commit 1b1f28d

Browse files
committed
Tighten up diagnostics wording a bit
1 parent 9ea735b commit 1b1f28d

15 files changed

+48
-51
lines changed

include/swift/AST/DiagnosticsSema.def

+4-6
Original file line numberDiff line numberDiff line change
@@ -5689,10 +5689,8 @@ NOTE(shared_state_make_immutable,none,
56895689
NOTE(shared_state_nonisolated_unsafe,none,
56905690
"disable concurrency-safety checks if accesses are protected by an external synchronization mechanism", (const ValueDecl *))
56915691
NOTE(note_actor_isolated_witness,none,
5692-
"%0 %kind1 cannot be used to satisfy %2 "
5693-
"requirement from protocol %base3",
5694-
(ActorIsolation, const ValueDecl *, ActorIsolation,
5695-
const ValueDecl *))
5692+
"%0 %kind1 cannot satisfy %2 requirement",
5693+
(ActorIsolation, const ValueDecl *, ActorIsolation))
56965694
ERROR(actor_cannot_conform_to_global_actor_protocol,none,
56975695
"actor %0 cannot conform to global actor isolated protocol %1",
56985696
(Type, Type))
@@ -8339,11 +8337,11 @@ ERROR(nonisolated_conformance_depends_on_isolated_conformance,none,
83398337
"conformance of %0 to %1 depends on %2 conformance of %3 to %4; mark it as '%5'",
83408338
(Type, DeclName, ActorIsolation, Type, DeclName, StringRef))
83418339
ERROR(isolated_conformance_with_sendable,none,
8342-
"%4 conformance of %0 to %1 cannot be used to satisfy conformance "
8340+
"%4 conformance of %0 to %1 cannot satisfy conformance "
83438341
"requirement for a %select{`Sendable`|`SendableMetatype`}2 type "
83448342
"parameter %3", (Type, DeclName, bool, Type, ActorIsolation))
83458343
ERROR(isolated_conformance_with_sendable_simple,none,
8346-
"%2 conformance of %0 to %1 cannot be used to satisfy "
8344+
"%2 conformance of %0 to %1 cannot satisfy "
83478345
"conformance requirement for a `Sendable` type parameter ",
83488346
(Type, DeclName, ActorIsolation))
83498347
ERROR(isolated_conformance_wrong_domain,none,

lib/Sema/TypeCheckProtocol.cpp

+1-2
Original file line numberDiff line numberDiff line change
@@ -4795,8 +4795,7 @@ void WitnessIsolationError::diagnose(
47954795
// Complain that this witness cannot conform to the requirement due to
47964796
// actor isolation.
47974797
witness->diagnose(diag::note_actor_isolated_witness,
4798-
referenceIsolation, witness, requirementIsolation,
4799-
conformance->getProtocol());
4798+
referenceIsolation, witness, requirementIsolation);
48004799
}
48014800

48024801
void AssociatedConformanceIsolationError::diagnose(

test/Concurrency/actor_isolation.swift

+2-2
Original file line numberDiff line numberDiff line change
@@ -1514,7 +1514,7 @@ class SGA_MA: MA, SGA_Proto {
15141514
// expected-note@-2{{turn data races into runtime errors with '@preconcurrency'}}
15151515

15161516
// expected-error@+2 {{call to global actor 'SomeGlobalActor'-isolated global function 'onions_sga()' in a synchronous main actor-isolated context}}
1517-
// expected-note@+1 {{main actor-isolated instance method 'method()' cannot be used to satisfy global actor 'SomeGlobalActor'-isolated requirement from protocol 'SGA_Proto'}}
1517+
// expected-note@+1 {{main actor-isolated instance method 'method()' cannot satisfy global actor 'SomeGlobalActor'-isolated requirement}}
15181518
override func method() { onions_sga() }
15191519
}
15201520

@@ -1624,7 +1624,7 @@ protocol NonisolatedProtocol {
16241624
actor ActorWithNonSendableLet: NonisolatedProtocol {
16251625
// expected-note@-1{{turn data races into runtime errors with '@preconcurrency'}}{{32-32=@preconcurrency }}
16261626

1627-
// expected-note@+1 {{actor-isolated property 'ns' cannot be used to satisfy nonisolated requirement from protocol 'NonisolatedProtocol'}}
1627+
// expected-note@+1 {{actor-isolated property 'ns' cannot satisfy nonisolated requirement}}
16281628
let ns = NonSendable()
16291629
}
16301630

test/Concurrency/actor_isolation_unsafe.swift

+2-2
Original file line numberDiff line numberDiff line change
@@ -43,15 +43,15 @@ struct S4_P1_not_quietly: P1 {
4343
// expected-note@-1{{turn data races into runtime errors with '@preconcurrency'}}
4444

4545
@SomeGlobalActor func onMainActor() { }
46-
// expected-note @-1 {{global actor 'SomeGlobalActor'-isolated instance method 'onMainActor()' cannot be used to satisfy main actor-isolated requirement from protocol 'P1'}}
46+
// expected-note @-1 {{global actor 'SomeGlobalActor'-isolated instance method 'onMainActor()' cannot satisfy main actor-isolated requirement}}
4747
}
4848

4949
// expected-warning@+2{{conformance of 'S4_P1' to protocol 'P1' involves isolation mismatches and can cause data races}}
5050
@SomeGlobalActor
5151
struct S4_P1: P1 {
5252
// expected-note@-1{{turn data races into runtime errors with '@preconcurrency'}}
5353

54-
@SomeGlobalActor func onMainActor() { } // expected-note{{global actor 'SomeGlobalActor'-isolated instance method 'onMainActor()' cannot be used to satisfy main actor-isolated requirement from protocol 'P1'}}
54+
@SomeGlobalActor func onMainActor() { } // expected-note{{global actor 'SomeGlobalActor'-isolated instance method 'onMainActor()' cannot satisfy main actor-isolated requirement}}
5555
}
5656

5757
// expected-warning@+1 {{'(unsafe)' global actors are deprecated; use '@preconcurrency' instead}}

test/Concurrency/global_actor_inference.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ protocol Interface {
128128
class Object: Interface {
129129
// expected-note@-1{{turn data races into runtime errors with '@preconcurrency'}}{{15-15=@preconcurrency }}
130130

131-
var baz: Int = 42 // expected-note{{main actor-isolated property 'baz' cannot be used to satisfy nonisolated requirement from protocol 'Interface'}}
131+
var baz: Int = 42 // expected-note{{main actor-isolated property 'baz' cannot satisfy nonisolated requirement}}
132132
}
133133

134134

test/Concurrency/global_actor_inference_swift6.swift

+2-2
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ struct S3: InferenceConflict {
180180
extension S3 {
181181

182182
func f() { }
183-
// expected-note@-1{{global actor 'SomeGlobalActor'-isolated instance method 'f()' cannot be used to satisfy main actor-isolated requirement from protocol 'InferMainActorInherited'}}
183+
// expected-note@-1{{global actor 'SomeGlobalActor'-isolated instance method 'f()' cannot satisfy main actor-isolated requirement}}
184184
}
185185

186186
@MainActor
@@ -211,7 +211,7 @@ class C2: MainActorSuperclass, InferenceConflictWithSuperclass {
211211
func f() {}
212212

213213
func g() {}
214-
// expected-note@-1 {{main actor-isolated instance method 'g()' cannot be used to satisfy nonisolated requirement from protocol 'InferenceConflictWithSuperclass'}}
214+
// expected-note@-1 {{main actor-isolated instance method 'g()' cannot satisfy nonisolated requirement}}
215215
}
216216

217217

test/Concurrency/isolated_conformance.swift

+7-7
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ protocol P {
1717
@MainActor
1818
class CWithNonIsolated: P {
1919
// expected-note@-1{{turn data races into runtime errors with '@preconcurrency'}}
20-
func f() { } // expected-note{{main actor-isolated instance method 'f()' cannot be used to satisfy nonisolated requirement from protocol 'P'}}
20+
func f() { } // expected-note{{main actor-isolated instance method 'f()' cannot satisfy nonisolated requirement}}
2121
}
2222

2323
actor SomeActor { }
@@ -108,8 +108,8 @@ struct PSendableMetaWrapper<T: P & SendableMetatype>: P {
108108
@MainActor
109109
func testIsolationConformancesInTypes() {
110110
typealias A1 = PWrapper<C>
111-
typealias A2 = PSendableWrapper<C> // expected-error{{isolated conformance of 'C' to 'P' cannot be used to satisfy conformance requirement for a `Sendable` type parameter 'T'}}
112-
typealias A3 = PSendableMetaWrapper<C> // expected-error{{isolated conformance of 'C' to 'P' cannot be used to satisfy conformance requirement for a `SendableMetatype` type parameter 'T'}}
111+
typealias A2 = PSendableWrapper<C> // expected-error{{isolated conformance of 'C' to 'P' cannot satisfy conformance requirement for a `Sendable` type parameter 'T'}}
112+
typealias A3 = PSendableMetaWrapper<C> // expected-error{{isolated conformance of 'C' to 'P' cannot satisfy conformance requirement for a `SendableMetatype` type parameter 'T'}}
113113
}
114114

115115
func acceptP<T: P>(_: T) { }
@@ -124,20 +124,20 @@ func acceptSendableMetaP<T: SendableMetatype & P>(_: T) { }
124124
func testIsolationConformancesInCall(c: C) {
125125
acceptP(c) // okay
126126

127-
acceptSendableP(c) // expected-error{{main actor-isolated conformance of 'C' to 'P' cannot be used to satisfy conformance requirement for a `Sendable` type parameter}}
128-
acceptSendableMetaP(c) // expected-error{{isolated conformance of 'C' to 'P' cannot be used to satisfy conformance requirement for a `Sendable` type parameter}}
127+
acceptSendableP(c) // expected-error{{main actor-isolated conformance of 'C' to 'P' cannot satisfy conformance requirement for a `Sendable` type parameter}}
128+
acceptSendableMetaP(c) // expected-error{{isolated conformance of 'C' to 'P' cannot satisfy conformance requirement for a `Sendable` type parameter}}
129129
}
130130

131131
@MainActor
132132
func testIsolatedConformancesOfActor(a: SomeActor) {
133133
acceptP(a)
134-
acceptSendableMetaP(a) // expected-error{{main actor-isolated conformance of 'SomeActor' to 'P' cannot be used to satisfy conformance requirement for a `Sendable` type parameter}}
134+
acceptSendableMetaP(a) // expected-error{{main actor-isolated conformance of 'SomeActor' to 'P' cannot satisfy conformance requirement for a `Sendable` type parameter}}
135135
}
136136

137137
@SomeGlobalActor
138138
func testIsolatedConformancesOfOtherGlobalActor(c: CMismatchedIsolation) {
139139
acceptP(c)
140-
acceptSendableMetaP(c) // expected-error{{global actor 'SomeGlobalActor'-isolated conformance of 'CMismatchedIsolation' to 'P' cannot be used to satisfy conformance requirement for a `Sendable` type parameter}}
140+
acceptSendableMetaP(c) // expected-error{{global actor 'SomeGlobalActor'-isolated conformance of 'CMismatchedIsolation' to 'P' cannot satisfy conformance requirement for a `Sendable` type parameter}}
141141
}
142142

143143
func testIsolationConformancesFromOutside(c: C) {

test/Concurrency/isolated_conformance_default_actor.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ extension CImplicitMainActor: Q {
4141
// expected-note@+2{{turn data races into runtime errors with '@preconcurrency'}}
4242
// expected-note@+1{{isolate this conformance to the main actor with '@MainActor'}}{{33-33=@MainActor }}
4343
nonisolated class CNonIsolated: P {
44-
@MainActor func f() { } // expected-note{{main actor-isolated instance method 'f()' cannot be used to satisfy nonisolated requirement from protocol 'P'}}
44+
@MainActor func f() { } // expected-note{{main actor-isolated instance method 'f()' cannot satisfy nonisolated requirement}}
4545
}
4646

4747
func acceptSendablePMeta<T: Sendable & P>(_: T.Type) { }

test/Concurrency/preconcurrency_conformances.swift

+8-8
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ final class K : @preconcurrency Initializable {
108108
final class MainActorK: Initializable {
109109
// expected-note@-1{{turn data races into runtime errors with '@preconcurrency'}}{{25-25=@preconcurrency }}
110110
// expected-note@-2{{mark all declarations used in the conformance 'nonisolated'}}
111-
init() { } // expected-note{{main actor-isolated initializer 'init()' cannot be used to satisfy nonisolated requirement from protocol 'Initializable'}}
111+
init() { } // expected-note{{main actor-isolated initializer 'init()' cannot satisfy nonisolated requirement}}
112112
}
113113

114114
protocol WithAssoc {
@@ -143,13 +143,13 @@ do {
143143
var a: Int = 42
144144

145145
@MainActor var b: Int {
146-
// expected-note@-1 {{main actor-isolated property 'b' cannot be used to satisfy global actor 'GlobalActor'-isolated requirement from protocol 'WithIndividuallyIsolatedRequirements'}}
146+
// expected-note@-1 {{main actor-isolated property 'b' cannot satisfy global actor 'GlobalActor'-isolated requirement}}
147147
get { 0 }
148148
set {}
149149
}
150150

151151
@MainActor func test() {
152-
// expected-note@-1 {{main actor-isolated instance method 'test()' cannot be used to satisfy global actor 'GlobalActor'-isolated requirement from protocol 'WithIndividuallyIsolatedRequirements'}}
152+
// expected-note@-1 {{main actor-isolated instance method 'test()' cannot satisfy global actor 'GlobalActor'-isolated requirement}}
153153
}
154154
}
155155
}
@@ -166,10 +166,10 @@ do {
166166
// expected-warning@-1 {{@preconcurrency attribute on conformance to 'WithNonIsolated' has no effect}}{{38-54=}}
167167

168168
@GlobalActor var prop: Int = 42
169-
// expected-note@-1 {{global actor 'GlobalActor'-isolated property 'prop' cannot be used to satisfy main actor-isolated requirement from protocol 'WithNonIsolated'}}
169+
// expected-note@-1 {{global actor 'GlobalActor'-isolated property 'prop' cannot satisfy main actor-isolated requirement}}
170170

171171
@MainActor func test() {}
172-
// expected-note@-1 {{main actor-isolated instance method 'test()' cannot be used to satisfy nonisolated requirement from protocol 'WithNonIsolated'}}
172+
// expected-note@-1 {{main actor-isolated instance method 'test()' cannot satisfy nonisolated requirement}}
173173
}
174174
}
175175

@@ -237,15 +237,15 @@ do {
237237
// expected-note@-2:45 {{turn data races into runtime errors with '@preconcurrency'}}
238238
// expected-note@-3{{mark all declarations used in the conformance 'nonisolated'}}
239239
func foo() {}
240-
// expected-note@-1 {{main actor-isolated instance method 'foo()' cannot be used to satisfy nonisolated requirement from protocol 'P2'}}
240+
// expected-note@-1 {{main actor-isolated instance method 'foo()' cannot satisfy nonisolated requirement}}
241241
}
242242
// expected-warning@+1{{conformance of 'S5' to protocol 'P2' crosses into main actor-isolated code and can cause data races; this is an error in the Swift 6 language mode}}
243243
@MainActor struct S5: P2, @preconcurrency P3 {
244244
// expected-warning@-1:21 {{@preconcurrency attribute on conformance to 'P3' has no effect}}
245245
// expected-note@-2:25 {{turn data races into runtime errors with '@preconcurrency'}}
246246
// expected-note@-3{{mark all declarations used in the conformance 'nonisolated'}}
247247
func foo() {}
248-
// expected-note@-1 {{main actor-isolated instance method 'foo()' cannot be used to satisfy nonisolated requirement from protocol 'P2'}}
248+
// expected-note@-1 {{main actor-isolated instance method 'foo()' cannot satisfy nonisolated requirement}}
249249
}
250250
// expected-warning@+1 {{@preconcurrency attribute on conformance to 'P3' has no effect}}
251251
@MainActor struct S6: @preconcurrency P2, @preconcurrency P3 {
@@ -305,7 +305,7 @@ do {
305305
// expected-note@-2{{turn data races into runtime errors with '@preconcurrency'}}
306306
// expected-note@-3{{mark all declarations used in the conformance 'nonisolated'}}
307307
func foo() {}
308-
// expected-note@-1 {{main actor-isolated instance method 'foo()' cannot be used to satisfy nonisolated requirement from protocol 'P2'}}
308+
// expected-note@-1 {{main actor-isolated instance method 'foo()' cannot satisfy nonisolated requirement}}
309309
}
310310
}
311311

test/Concurrency/predates_concurrency.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ extension MainActorPreconcurrency: NotIsolated {
235235
// expected-complete-tns-note@-2{{turn data races into runtime errors with '@preconcurrency'}}{{36-36=@preconcurrency }}
236236
// expected-complete-tns-note@-3{{mark all declarations used in the conformance 'nonisolated'}}
237237
func requirement() {}
238-
// expected-complete-tns-note@-1 {{main actor-isolated instance method 'requirement()' cannot be used to satisfy nonisolated requirement from protocol 'NotIsolated'}}
238+
// expected-complete-tns-note@-1 {{main actor-isolated instance method 'requirement()' cannot satisfy nonisolated requirement}}
239239
// expected-complete-tns-note@-2 {{calls to instance method 'requirement()' from outside of its actor context are implicitly asynchronous}}
240240

241241

test/Distributed/distributed_protocol_isolation.swift

+7-7
Original file line numberDiff line numberDiff line change
@@ -108,22 +108,22 @@ distributed actor Nope1_StrictlyLocal: StrictlyLocal {
108108
// expected-note@-2{{mark all declarations used in the conformance 'nonisolated'}}
109109

110110
func local() {}
111-
// expected-note@-1{{actor-isolated instance method 'local()' cannot be used to satisfy nonisolated requirement from protocol 'StrictlyLocal'}}
111+
// expected-note@-1{{actor-isolated instance method 'local()' cannot satisfy nonisolated requirement}}
112112
func localThrows() throws {}
113-
// expected-note@-1{{actor-isolated instance method 'localThrows()' cannot be used to satisfy nonisolated requirement from protocol 'StrictlyLocal'}}
113+
// expected-note@-1{{actor-isolated instance method 'localThrows()' cannot satisfy nonisolated requirement}}
114114
func localAsync() async {}
115-
// expected-note@-1{{actor-isolated instance method 'localAsync()' cannot be used to satisfy nonisolated requirement from protocol 'StrictlyLocal'}}
115+
// expected-note@-1{{actor-isolated instance method 'localAsync()' cannot satisfy nonisolated requirement}}
116116
}
117117

118118
// expected-error@+1{{conformance of 'Nope2_StrictlyLocal' to protocol 'StrictlyLocal' involves isolation mismatches and can cause data races}}
119119
distributed actor Nope2_StrictlyLocal: StrictlyLocal {
120120
// expected-note@-1{{turn data races into runtime errors with '@preconcurrency'}}
121121
distributed func local() {}
122-
// expected-note@-1{{actor-isolated distributed instance method 'local()' cannot be used to satisfy nonisolated requirement from protocol 'StrictlyLocal'}}
122+
// expected-note@-1{{actor-isolated distributed instance method 'local()' cannot satisfy nonisolated requirement}}
123123
distributed func localThrows() throws {}
124-
// expected-note@-1{{actor-isolated distributed instance method 'localThrows()' cannot be used to satisfy nonisolated requirement from protocol 'StrictlyLocal'}}
124+
// expected-note@-1{{actor-isolated distributed instance method 'localThrows()' cannot satisfy nonisolated requirement}}
125125
distributed func localAsync() async {}
126-
// expected-note@-1{{actor-isolated distributed instance method 'localAsync()' cannot be used to satisfy nonisolated requirement from protocol 'StrictlyLocal'}}
126+
// expected-note@-1{{actor-isolated distributed instance method 'localAsync()' cannot satisfy nonisolated requirement}}
127127
}
128128
distributed actor OK_StrictlyLocal: StrictlyLocal {
129129
nonisolated func local() {}
@@ -207,7 +207,7 @@ distributed actor DA_TerminationWatchingA: TerminationWatchingA {
207207
// expected-note@-2{{mark all declarations used in the conformance 'nonisolated'}}
208208

209209
func terminated(a: String) { }
210-
// expected-note@-1{{actor-isolated instance method 'terminated(a:)' cannot be used to satisfy nonisolated requirement from protocol 'TerminationWatchingA'}}
210+
// expected-note@-1{{actor-isolated instance method 'terminated(a:)' cannot satisfy nonisolated requirement}}
211211
}
212212

213213
distributed actor DA_TerminationWatchingDA: TerminationWatchingDA {

test/decl/class/actor/conformance.swift

+7-7
Original file line numberDiff line numberDiff line change
@@ -40,28 +40,28 @@ actor OtherActor: SyncProtocol {
4040
// expected-note@-2{{mark all declarations used in the conformance 'nonisolated'}}
4141

4242
var propertyB: Int = 17
43-
// expected-note@-1{{actor-isolated property 'propertyB' cannot be used to satisfy nonisolated requirement from protocol 'SyncProtocol'}}
43+
// expected-note@-1{{actor-isolated property 'propertyB' cannot satisfy nonisolated requirement}}
4444

4545
var propertyA: Int { 17 }
46-
// expected-note@-1{{actor-isolated property 'propertyA' cannot be used to satisfy nonisolated requirement from protocol 'SyncProtocol'}}
46+
// expected-note@-1{{actor-isolated property 'propertyA' cannot satisfy nonisolated requirement}}
4747

4848
func syncMethodA() { }
49-
// expected-note@-1{{actor-isolated instance method 'syncMethodA()' cannot be used to satisfy nonisolated requirement from protocol 'SyncProtocol'}}
49+
// expected-note@-1{{actor-isolated instance method 'syncMethodA()' cannot satisfy nonisolated requirement}}
5050

5151
// nonisolated methods are okay.
5252
nonisolated func syncMethodC() -> Int { 5 }
5353

5454
func syncMethodE() -> Void { }
55-
// expected-note@-1{{actor-isolated instance method 'syncMethodE()' cannot be used to satisfy nonisolated requirement from protocol 'SyncProtocol'}}
55+
// expected-note@-1{{actor-isolated instance method 'syncMethodE()' cannot satisfy nonisolated requirement}}
5656

5757
func syncMethodF(param: String) -> Int { 5 }
58-
// expected-note@-1{{actor-isolated instance method 'syncMethodF(param:)' cannot be used to satisfy nonisolated requirement from protocol 'SyncProtocol'}}
58+
// expected-note@-1{{actor-isolated instance method 'syncMethodF(param:)' cannot satisfy nonisolated requirement}}
5959

6060
func syncMethodG() { }
61-
// expected-note@-1{{actor-isolated instance method 'syncMethodG()' cannot be used to satisfy nonisolated requirement from protocol 'SyncProtocol'}}
61+
// expected-note@-1{{actor-isolated instance method 'syncMethodG()' cannot satisfy nonisolated requirement}}
6262

6363
subscript (index: Int) -> String { "\(index)" }
64-
// expected-note@-1{{actor-isolated subscript 'subscript(_:)' cannot be used to satisfy nonisolated requirement from protocol 'SyncProtocol'}}
64+
// expected-note@-1{{actor-isolated subscript 'subscript(_:)' cannot satisfy nonisolated requirement}}
6565

6666
// Static methods and properties are okay.
6767
static func staticMethod() { }

0 commit comments

Comments
 (0)