Skip to content

Commit 5230b19

Browse files
committed
Test: replace '@_moveOnly' with '~Copyable'
1 parent 2557ba9 commit 5230b19

File tree

81 files changed

+250
-408
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

81 files changed

+250
-408
lines changed

test/Concurrency/transfernonsendable.sil

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,7 @@ sil @transferKlassContainingKlasses : $@convention(thin) @async (@guaranteed Kla
4848
sil @useKlassContainingKlasses : $@convention(thin) (@guaranteed KlassContainingKlasses) -> ()
4949
sil @constructKlassContainingKlasses : $@convention(thin) () -> @owned KlassContainingKlasses
5050

51-
@_moveOnly
52-
struct NonSendableMoveOnlyStruct {
51+
struct NonSendableMoveOnlyStruct: ~Copyable {
5352
var ns: NonSendableKlass
5453

5554
deinit

test/Concurrency/transfernonsendable_instruction_matching.sil

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,7 @@ sil @transferKlassContainingKlasses : $@convention(thin) @async (@guaranteed Kla
4242
sil @useKlassContainingKlasses : $@convention(thin) (@guaranteed KlassContainingKlasses) -> ()
4343
sil @constructKlassContainingKlasses : $@convention(thin) () -> @owned KlassContainingKlasses
4444

45-
@_moveOnly
46-
struct NonSendableMoveOnlyStruct {
45+
struct NonSendableMoveOnlyStruct: ~Copyable {
4746
var ns: NonSendableKlass
4847

4948
deinit

test/Concurrency/transfernonsendable_instruction_matching_differentiability.sil

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,7 @@ sil @transferKlassContainingKlasses : $@convention(thin) @async (@guaranteed Kla
3636
sil @useKlassContainingKlasses : $@convention(thin) (@guaranteed KlassContainingKlasses) -> ()
3737
sil @constructKlassContainingKlasses : $@convention(thin) () -> @owned KlassContainingKlasses
3838

39-
@_moveOnly
40-
struct NonSendableMoveOnlyStruct {
39+
struct NonSendableMoveOnlyStruct: ~Copyable {
4140
var ns: NonSendableKlass
4241

4342
deinit

test/Concurrency/transfernonsendable_instruction_matching_opaquevalues.sil

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,7 @@ class NonSendableKlass {}
2222

2323
final class SendableKlass : Sendable {}
2424

25-
@_moveOnly
26-
struct NonSendableMoveOnlyStruct {
25+
struct NonSendableMoveOnlyStruct: ~Copyable {
2726
var ns: NonSendableKlass
2827
}
2928

@@ -194,4 +193,4 @@ bb0:
194193

195194
%9999 = tuple ()
196195
return %9999 : $()
197-
}
196+
}

test/Constraints/moveonly_tuples.swift

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,14 @@
33
// Tuples with noncopyable elements are not yet supported. Make sure we reject
44
// them when code attempts to form such a type explicitly or by inference.
55

6-
@_moveOnly struct Butt {
6+
struct Butt: ~Copyable {
77
var x: Int
88
}
99

10-
@_moveOnly
11-
struct Foo {
10+
struct Foo: ~Copyable {
1211
var t: (Int, Butt) // expected-error{{tuple with noncopyable element type 'Butt' is not supported}}
1312
}
14-
@_moveOnly
15-
struct Bar<T> {
13+
struct Bar<T>: ~Copyable {
1614
var t: (T, Butt) // expected-error{{tuple with noncopyable element type 'Butt' is not supported}}
1715
var u: (Int, (T, Butt)) // expected-error{{tuple with noncopyable element type 'Butt' is not supported}}
1816
}

test/Generics/inverse_classes1.swift

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,11 @@
11
// RUN: %target-typecheck-verify-swift \
2-
// RUN: -parse-stdlib -module-name Swift \
32
// RUN: -enable-experimental-feature MoveOnlyClasses
43

5-
// NOTE: -parse-stdlib is a transitional workaround and should not be required.
6-
7-
@_moveOnly
8-
class KlassLegacy {}
9-
104
class KlassModern: ~Copyable {}
115

126
class Konditional<T: ~Copyable> {}
137

148
func checks<T: ~Copyable, C>(
15-
_ a: KlassLegacy, // expected-error {{parameter of noncopyable type 'KlassLegacy' must specify ownership}} // expected-note 3{{add}}
169
_ b: KlassModern, // expected-error {{parameter of noncopyable type 'KlassModern' must specify ownership}} // expected-note 3{{add}}
1710
_ c: Konditional<T>,
1811
_ d: Konditional<C>) {}

test/Generics/inverse_classes2.swift

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,12 @@
11
// RUN: %target-typecheck-verify-swift -disable-availability-checking
22

3-
@_moveOnly // expected-error {{'@_moveOnly' attribute is only valid on structs or enums}}
4-
class KlassLegacy {}
5-
63
class KlassModern: ~Copyable {} // expected-error {{classes cannot be '~Copyable'}}
74

85
actor FamousPerson: ~Copyable {} // expected-error{{actors cannot be '~Copyable'}}
96

107
class Konditional<T: ~Copyable> {}
118

129
func checks<T: ~Copyable, C>(
13-
_ a: KlassLegacy,
1410
_ b: KlassModern,
1511
_ c: Konditional<T>,
1612
_ d: Konditional<C>) {}

test/Generics/inverse_generics.swift

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -184,9 +184,6 @@ enum Sally: Copyable, ~Copyable, NeedsCopyable {} // expected-error {{enum 'Sall
184184

185185
class NiceTry: ~Copyable, Copyable {} // expected-error {{classes cannot be '~Copyable'}}
186186

187-
@_moveOnly class NiceTry2: Copyable {} // expected-error {{'@_moveOnly' attribute is only valid on structs or enums}}
188-
189-
190187
struct Extendo: ~Copyable {}
191188
extension Extendo: Copyable, ~Copyable {} // expected-error {{cannot suppress 'Copyable' in extension}}
192189
// expected-error@-1 {{struct 'Extendo' required to be 'Copyable' but is marked with '~Copyable'}}

test/IRGen/moveonly_deinit.sil

Lines changed: 12 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,7 @@ class C {}
1919
// noncopyable, nontrivial deinit, pointer aligned
2020
// CHECK-64-SAME: <i32 0x81_0007>
2121
// CHECK-32-SAME: <i32 0x81_0003>
22-
@_moveOnly
23-
struct MOStruct {
22+
struct MOStruct: ~Copyable {
2423
var x: Int
2524
var y: C
2625

@@ -32,8 +31,7 @@ struct MOStruct {
3231
// noncopyable, enum, nontrivial deinit, pointer aligned
3332
// CHECK-64-SAME: <i32 0xA1_0007>
3433
// CHECK-32-SAME: <i32 0xA1_0003>
35-
@_moveOnly
36-
enum MOEnum {
34+
enum MOEnum: ~Copyable {
3735
case x(Int)
3836
case y(C)
3937

@@ -45,8 +43,7 @@ enum MOEnum {
4543
// noncopyable, non-inline, nontrivial deinit, pointer aligned
4644
// CHECK-64-SAME: <i32 0x83_0007>
4745
// CHECK-32-SAME: <i32 0x83_0003>
48-
@_moveOnly
49-
struct MOComboStruct {
46+
struct MOComboStruct: ~Copyable {
5047
var a: MOStruct
5148
var b: MOEnum
5249
var c: C
@@ -57,8 +54,7 @@ struct MOComboStruct {
5754
// noncopyable, enum, nontrivial deinit, pointer aligned
5855
// CHECK-64-SAME: <i32 0xA1_0007>
5956
// CHECK-32-SAME: <i32 0xA1_0003>
60-
@_moveOnly
61-
enum MOComboEnum {
57+
enum MOComboEnum: ~Copyable {
6258
case a(MOStruct)
6359
case b(MOEnum)
6460
case c(C)
@@ -71,8 +67,7 @@ enum MOComboEnum {
7167
// CHECK-SAME: @__swift_cannot_copy_noncopyable_type
7268
// noncopyable, nontrivial deinit, byte aligned
7369
// CHECK-SAME: <i32 0x81_0000>
74-
@_moveOnly
75-
struct MOEmptyStruct {
70+
struct MOEmptyStruct: ~Copyable {
7671
deinit
7772
}
7873

@@ -81,8 +76,7 @@ struct MOEmptyStruct {
8176
// noncopyable, nontrivial deinit, pointer aligned
8277
// CHECK-64-SAME: <i32 0x81_0007>
8378
// CHECK-32-SAME: <i32 0x81_0003>
84-
@_moveOnly
85-
struct MOIntLikeStruct {
79+
struct MOIntLikeStruct: ~Copyable {
8680
var x: Int
8781

8882
deinit
@@ -93,8 +87,7 @@ struct MOIntLikeStruct {
9387
// noncopyable, nontrivial deinit, pointer aligned
9488
// CHECK-64-SAME: <i32 0x81_0007>
9589
// CHECK-32-SAME: <i32 0x81_0003>
96-
@_moveOnly
97-
struct MOSingleRefcountLikeStruct {
90+
struct MOSingleRefcountLikeStruct: ~Copyable {
9891
var x: C
9992

10093
deinit
@@ -106,17 +99,15 @@ struct MOSingleRefcountLikeStruct {
10699
// CHECK-SAME: @__swift_cannot_copy_noncopyable_type
107100
// noncopyable, trivial deinit, byte aligned
108101
// CHECK-SAME: <i32 0x80_0000>
109-
@_moveOnly
110-
struct MOEmptyStructNoDeinit {
102+
struct MOEmptyStructNoDeinit: ~Copyable {
111103
}
112104

113105
// CHECK-LABEL: @{{.*}}23MOIntLikeStructNoDeinitVWV" =
114106
// CHECK-SAME: @__swift_cannot_copy_noncopyable_type
115107
// noncopyable, trivial deinit, pointer aligned
116108
// CHECK-64-SAME: <i32 0x80_0007>
117109
// CHECK-32-SAME: <i32 0x80_0003>
118-
@_moveOnly
119-
struct MOIntLikeStructNoDeinit {
110+
struct MOIntLikeStructNoDeinit: ~Copyable {
120111
var x: Int
121112
}
122113

@@ -125,8 +116,7 @@ struct MOIntLikeStructNoDeinit {
125116
// noncopyable, nontrivial deinit, pointer aligned
126117
// CHECK-64-SAME: <i32 0x81_0007>
127118
// CHECK-32-SAME: <i32 0x81_0003>
128-
@_moveOnly
129-
struct MOSingleRefcountLikeStructNoDeinit {
119+
struct MOSingleRefcountLikeStructNoDeinit: ~Copyable {
130120
var x: C
131121
}
132122

@@ -146,8 +136,7 @@ struct MOSingleRefcountLikeStructNoDeinit {
146136

147137
// Very large structs will use indirect conventions for their deinit.
148138

149-
@_moveOnly
150-
struct MOVeryBigStructDeinit {
139+
struct MOVeryBigStructDeinit: ~Copyable {
151140
var x: Int, y: Int, z: Int, w: Int, a: Int, b: Int, c: Int, d: Int
152141

153142
deinit
@@ -158,8 +147,7 @@ struct MOVeryBigStructDeinit {
158147
protocol P {}
159148
extension Int: P {}
160149

161-
@_moveOnly
162-
struct MOGenericDeinit<T: P, U> {
150+
struct MOGenericDeinit<T: P, U>: ~Copyable {
163151
var t: T
164152
var u: U
165153

test/IRGen/moveonly_deinits.swift

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,12 @@ class Klass {}
2222
// Struct Declarations //
2323
/////////////////////////
2424

25-
@_moveOnly
26-
struct KlassPairWithoutDeinit {
25+
struct KlassPairWithoutDeinit: ~Copyable {
2726
var lhs = Klass()
2827
var rhs = Klass()
2928
}
3029

31-
@_moveOnly
32-
struct KlassPairWithDeinit {
30+
struct KlassPairWithDeinit: ~Copyable {
3331
var lhs = Klass()
3432
var rhs = Klass()
3533

@@ -38,14 +36,12 @@ struct KlassPairWithDeinit {
3836
}
3937
}
4038

41-
@_moveOnly
42-
struct IntPairWithoutDeinit {
39+
struct IntPairWithoutDeinit: ~Copyable {
4340
var k: Int = 5
4441
var k2: Int = 6
4542
}
4643

47-
@_moveOnly
48-
struct IntPairWithDeinit {
44+
struct IntPairWithDeinit: ~Copyable {
4945
var k: Int = 5
5046
var k2: Int = 6
5147

@@ -191,14 +187,12 @@ public func testKlassPairWithDeinit() {
191187
// Enum Declarations //
192188
///////////////////////
193189

194-
@_moveOnly
195-
enum KlassEnumPairWithoutDeinit {
190+
enum KlassEnumPairWithoutDeinit: ~Copyable {
196191
case lhs(Klass)
197192
case rhs(Klass)
198193
}
199194

200-
@_moveOnly
201-
enum KlassEnumPairWithDeinit {
195+
enum KlassEnumPairWithDeinit: ~Copyable {
202196
case lhs(Klass)
203197
case rhs(Klass)
204198

@@ -207,14 +201,12 @@ enum KlassEnumPairWithDeinit {
207201
}
208202
}
209203

210-
@_moveOnly
211-
enum IntEnumPairWithoutDeinit {
204+
enum IntEnumPairWithoutDeinit: ~Copyable {
212205
case lhs(Int)
213206
case rhs(Int)
214207
}
215208

216-
@_moveOnly
217-
enum IntEnumPairWithDeinit {
209+
enum IntEnumPairWithDeinit: ~Copyable {
218210
case lhs(Int)
219211
case rhs(Int)
220212

test/Inputs/clang-importer-sdk/swift-modules-concurrency-consuming-job-param/_Concurrency.swift

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,9 @@
22
// This simulates a pre-Swift5.9 concurrency library with an consuming declaration rather than __owned.
33
// This allows us to confirm the compiler and sdk can be mismatched but we'll build correctly.
44

5-
@_moveOnly
6-
public struct ExecutorJob {}
5+
public struct ExecutorJob: ~Copyable {}
76

87
public protocol SerialExecutor {
98
// pretend old SDK with `__owned` param rather than ``
109
func enqueue(_ job: consuming ExecutorJob)
11-
}
10+
}

test/Inputs/clang-importer-sdk/swift-modules-concurrency-owned-job-param/_Concurrency.swift

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,9 @@
22
// This simulates a pre-Swift5.9 concurrency library with an __owned declaration rather than consuming.
33
// This allows us to confirm the compiler and sdk can be mismatched but we'll build correctly.
44

5-
@_moveOnly
6-
public struct ExecutorJob {}
5+
public struct ExecutorJob: ~Copyable {}
76

87
public protocol SerialExecutor {
98
// pretend old SDK with `__owned` param rather than ``
109
func enqueue(_ job: __owned ExecutorJob)
11-
}
10+
}
Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11

2-
@_moveOnly
3-
public struct ExecutorJob {}
2+
public struct ExecutorJob: ~Copyable {}
43

54
public typealias Job = ExecutorJob
65

76
public protocol SerialExecutor {
87
func enqueue(_ job: __owned ExecutorJob)
9-
}
8+
}

test/Interpreter/moveonly.swift

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,7 @@ defer { runAllTests() }
99

1010
var Tests = TestSuite("MoveOnlyTests")
1111

12-
@_moveOnly
13-
struct FD {
12+
struct FD: ~Copyable {
1413
var a = LifetimeTracked(0)
1514

1615
deinit {
@@ -49,8 +48,7 @@ Tests.test("global destroyed once") {
4948
expectEqual(0, LifetimeTracked.instances)
5049
}
5150

52-
@_moveOnly
53-
struct FD2 {
51+
struct FD2: ~Copyable {
5452
var field = 5
5553
static var count = 0
5654
init() { FD2.count += 1 }
@@ -93,8 +91,7 @@ Tests.test("deinit not called in init when assigned") {
9391
}
9492

9593
Tests.test("empty struct") {
96-
@_moveOnly
97-
struct EmptyStruct {
94+
struct EmptyStruct: ~Copyable {
9895
func doSomething() {}
9996
var value: Bool { false }
10097
}
@@ -115,8 +112,7 @@ Tests.test("AddressOnly") {
115112
var name: String { "myName" }
116113
}
117114

118-
@_moveOnly
119-
struct S<T : P> {
115+
struct S<T : P>: ~Copyable {
120116
var t: T
121117
}
122118

test/Interpreter/moveonly_computed_property_in_class.swift

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@
22
// RUN: %target-run-simple-swift(-O -Xfrontend -sil-verify-all)
33

44
// REQUIRES: executable_test
5-
@_moveOnly
6-
struct FileDescriptor {
5+
struct FileDescriptor: ~Copyable {
76
let desc: Int
87

98
var empty: Bool { return desc == Int.min }

0 commit comments

Comments
 (0)