Skip to content

Commit 3a81548

Browse files
committed
[NoncopyablePartialConsumption] Promote to feature
1 parent 4d3307a commit 3a81548

File tree

44 files changed

+142
-1178
lines changed

Some content is hidden

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

44 files changed

+142
-1178
lines changed

include/swift/Basic/Features.def

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,7 @@ LANGUAGE_FEATURE(ExpressionMacroDefaultArguments, 422, "Expression macro as call
175175
LANGUAGE_FEATURE(BuiltinStoreRaw, 0, "Builtin.storeRaw")
176176
LANGUAGE_FEATURE(BuiltinCreateTask, 0, "Builtin.createTask and Builtin.createDiscardingTask")
177177
SUPPRESSIBLE_LANGUAGE_FEATURE(AssociatedTypeImplements, 0, "@_implements on associated types")
178+
LANGUAGE_FEATURE(MoveOnlyPartialConsumption, 429, "Partial consumption of noncopyable values")
178179

179180
// Swift 6
180181
UPCOMING_FEATURE(ConciseMagicFile, 274, 6)
@@ -191,7 +192,6 @@ UPCOMING_FEATURE(InferSendableFromCaptures, 418, 6)
191192
UPCOMING_FEATURE(ImplicitOpenExistentials, 352, 6)
192193
UPCOMING_FEATURE(RegionBasedIsolation, 414, 6)
193194
UPCOMING_FEATURE(DynamicActorIsolation, 423, 6)
194-
UPCOMING_FEATURE(MoveOnlyPartialConsumption, 429, 6)
195195

196196
// Swift 7
197197
UPCOMING_FEATURE(ExistentialAny, 335, 7)

test/Interpreter/move_expr_moveonly_partial_consumption.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
// RUN: %target-run-simple-swift(-parse-as-library -Xfrontend -sil-verify-all -enable-upcoming-feature MoveOnlyPartialConsumption) | %FileCheck %s
2-
// RUN: %target-run-simple-swift(-parse-as-library -O -Xfrontend -sil-verify-all -enable-upcoming-feature MoveOnlyPartialConsumption) | %FileCheck %s
1+
// RUN: %target-run-simple-swift(-parse-as-library -Xfrontend -sil-verify-all) | %FileCheck %s
2+
// RUN: %target-run-simple-swift(-parse-as-library -O -Xfrontend -sil-verify-all) | %FileCheck %s
33

44
// REQUIRES: executable_test
55

test/Interpreter/move_expr_moveonly_partial_consumption_addr.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
// RUN: %target-run-simple-swift(-parse-as-library -Xfrontend -sil-verify-all -enable-upcoming-feature MoveOnlyPartialConsumption) | %FileCheck %s
2-
// RUN: %target-run-simple-swift(-parse-as-library -O -Xfrontend -sil-verify-all -enable-upcoming-feature MoveOnlyPartialConsumption) | %FileCheck %s
1+
// RUN: %target-run-simple-swift(-parse-as-library -Xfrontend -sil-verify-all) | %FileCheck %s
2+
// RUN: %target-run-simple-swift(-parse-as-library -O -Xfrontend -sil-verify-all) | %FileCheck %s
33

44
// REQUIRES: executable_test
55

test/Interpreter/moveonly_address_maximize.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
// RUN: %target-run-simple-swift(-Xfrontend -sil-verify-all -enable-upcoming-feature MoveOnlyPartialConsumption) | %FileCheck %s
2-
// RUN: %target-run-simple-swift(-O -Xfrontend -sil-verify-all -enable-upcoming-feature MoveOnlyPartialConsumption) | %FileCheck %s
1+
// RUN: %target-run-simple-swift(-Xfrontend -sil-verify-all) | %FileCheck %s
2+
// RUN: %target-run-simple-swift(-O -Xfrontend -sil-verify-all) | %FileCheck %s
33

4-
// RUN: %target-run-simple-swift(-enable-experimental-feature NoncopyableGenerics -Xfrontend -sil-verify-all -enable-upcoming-feature MoveOnlyPartialConsumption) | %FileCheck %s
5-
// RUN: %target-run-simple-swift(-enable-experimental-feature NoncopyableGenerics -O -Xfrontend -sil-verify-all -enable-upcoming-feature MoveOnlyPartialConsumption) | %FileCheck %s
4+
// RUN: %target-run-simple-swift(-enable-experimental-feature NoncopyableGenerics -Xfrontend -sil-verify-all) | %FileCheck %s
5+
// RUN: %target-run-simple-swift(-enable-experimental-feature NoncopyableGenerics -O -Xfrontend -sil-verify-all) | %FileCheck %s
66

77
// REQUIRES: executable_test
88

test/Interpreter/moveonly_partial_consume_value.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
// RUN: %target-run-simple-swift(-Xfrontend -sil-verify-all -enable-upcoming-feature MoveOnlyPartialConsumption) | %FileCheck %s
2-
// RUN: %target-run-simple-swift(-O -Xfrontend -sil-verify-all -enable-upcoming-feature MoveOnlyPartialConsumption) | %FileCheck %s
1+
// RUN: %target-run-simple-swift(-Xfrontend -sil-verify-all) | %FileCheck %s
2+
// RUN: %target-run-simple-swift(-O -Xfrontend -sil-verify-all) | %FileCheck %s
33

44
// REQUIRES: executable_test
55

test/Parse/move_expr.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -76,9 +76,9 @@ struct Foo {
7676

7777
func consumePropertyWrapper() {
7878
// should still parse, even if it doesn't semantically work out
79-
_ = consume wrapperTest // expected-error{{can only be applied to a local binding ('let', 'var', or parameter)}}
80-
_ = consume _wrapperTest // expected-error{{can only be applied to a local binding ('let', 'var', or parameter)}}
81-
_ = consume $wrapperTest // expected-error{{can only be applied to a local binding ('let', 'var', or parameter)}}
79+
_ = consume wrapperTest // expected-error{{'consume' can only be used to partially consume storage of a noncopyable type}}
80+
_ = consume _wrapperTest // expected-error{{'consume' can only be used to partially consume storage of a noncopyable type}}
81+
_ = consume $wrapperTest // expected-error{{'consume' can only be used to partially consume storage of a noncopyable type}}
8282
}
8383
}
8484

test/SILGen/moveonly_consuming_switch.swift

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
// RUN: -emit-silgen \
33
// RUN: %s \
44
// RUN: -enable-experimental-feature BorrowingSwitch \
5-
// RUN: -enable-upcoming-feature MoveOnlyPartialConsumption \
65
// RUN: -enable-experimental-feature NoncopyableGenerics \
76
// RUN: | %FileCheck %s
87

test/SILGen/moveonly_deinits.swift

Lines changed: 43 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -65,16 +65,26 @@ var value: Bool { false }
6565

6666
// SILGEN-LABEL: sil hidden [ossa] @$s16moveonly_deinits19KlassPairWithDeinitVfD : $@convention(method) (@owned KlassPairWithDeinit) -> () {
6767
// SILGEN: bb0([[ARG:%.*]] :
68-
// SILGEN: [[MARK:%.*]] = mark_unresolved_non_copyable_value [consumable_and_assignable] [[ARG]]
68+
// SILGEN: [[STACK:%.*]] = alloc_stack
69+
// SILGEN: [[MARK:%.*]] = mark_unresolved_non_copyable_value [consumable_and_assignable] [[STACK]]
70+
// SILGEN: store [[ARG]] to [init] [[MARK]]
6971
// SILGEN: [[DD:%.*]] = drop_deinit [[MARK]]
70-
// SILGEN: destroy_value [[DD]]
72+
// SILGEN: [[L_ADDR:%[^,]+]] = struct_element_addr [[DD]]
73+
// SILGEN-SAME: #KlassPairWithDeinit.lhs
74+
// SILGEN: [[L_ACCESS:%[^,]+]] = begin_access [deinit] [static] [[L_ADDR]]
75+
// SILGEN: destroy_addr [[L_ACCESS]]
76+
// SILGEN: [[R_ADDR:%[^,]+]] = struct_element_addr [[DD]]
77+
// SILGEN-SAME: #KlassPairWithDeinit.rhs
78+
// SILGEN: [[R_ACCESS:%[^,]+]] = begin_access [deinit] [static] [[R_ADDR]]
79+
// SILGEN: destroy_addr [[R_ACCESS]]
7180
// SILGEN: } // end sil function '$s16moveonly_deinits19KlassPairWithDeinitVfD'
7281

7382
// SILGEN-LABEL: sil hidden [ossa] @$s16moveonly_deinits17IntPairWithDeinitVfD : $@convention(method) (@owned IntPairWithDeinit) -> () {
7483
// SILGEN: bb0([[ARG:%.*]] :
75-
// SILGEN: [[MARKED:%.*]] = mark_unresolved_non_copyable_value [consumable_and_assignable] [[ARG]]
76-
// SILGEN: [[DD:%.*]] = drop_deinit [[MARKED]]
77-
// SILGEN: destroy_value [[DD]]
84+
// SILGEN: [[STACK:%.*]] = alloc_stack
85+
// SILGEN: [[MARK:%.*]] = mark_unresolved_non_copyable_value [consumable_and_assignable] [[STACK]]
86+
// SILGEN: store [[ARG]] to [init] [[MARK]]
87+
// SILGEN: [[DD:%.*]] = drop_deinit [[MARK]]
7888
// SILGEN: } // end sil function '$s16moveonly_deinits17IntPairWithDeinitVfD'
7989

8090
////////////////////////
@@ -323,20 +333,40 @@ func consumeKlassEnumPairWithDeinit(_ x: __owned KlassEnumPairWithDeinit) { }
323333

324334
// SILGEN-LABEL: sil hidden [ossa] @$s16moveonly_deinits23KlassEnumPairWithDeinitOfD : $@convention(method) (@owned KlassEnumPairWithDeinit) -> () {
325335
// SILGEN: bb0([[ARG:%.*]] :
326-
// SILGEN: [[MARK:%.*]] = mark_unresolved_non_copyable_value [consumable_and_assignable] [[ARG]]
336+
// SILGEN: [[STACK:%.*]] = alloc_stack
337+
// SILGEN: [[MARK:%.*]] = mark_unresolved_non_copyable_value [consumable_and_assignable] [[STACK]]
338+
// SILGEN: store [[ARG]] to [init] [[MARK]]
327339
// SILGEN: [[DD:%.*]] = drop_deinit [[MARK]]
328-
// SILGEN: destroy_value [[DD]] : $KlassEnumPairWithDeinit
329-
// SILGEN-NEXT: tuple ()
330-
// SILGEN-NEXT: return
340+
// SILGEN: switch_enum_addr [[DD]]
341+
// SILGEN-SAME: case #KlassEnumPairWithDeinit.lhs!enumelt: [[BASIC_BLOCK1:bb[0-9]+]]
342+
// SILGEN-SAME: case #KlassEnumPairWithDeinit.rhs!enumelt: [[BASIC_BLOCK2:bb[0-9]+]]
343+
// SILGEN: [[BASIC_BLOCK1]]:
344+
// SILGEN: [[L_ADDR:%[^,]+]] = unchecked_take_enum_data_addr [[DD]]
345+
// SILGEN-SAME: #KlassEnumPairWithDeinit.lhs!enumelt
346+
// SILGEN: destroy_addr [[L_ADDR]]
347+
// SILGEN: [[BASIC_BLOCK2]]:
348+
// SILGEN: [[R_ADDR:%[^,]+]] = unchecked_take_enum_data_addr [[DD]]
349+
// SILGEN-SAME: #KlassEnumPairWithDeinit.rhs!enumelt
350+
// SILGEN: destroy_addr [[R_ADDR]]
331351
// SILGEN: } // end sil function '$s16moveonly_deinits23KlassEnumPairWithDeinitOfD'
332352

333353
// SILGEN-LABEL: sil hidden [ossa] @$s16moveonly_deinits21IntEnumPairWithDeinitOfD : $@convention(method) (@owned IntEnumPairWithDeinit) -> () {
334354
// SILGEN: bb0([[ARG:%.*]] :
335-
// SILGEN: [[MARK:%.*]] = mark_unresolved_non_copyable_value [consumable_and_assignable] [[ARG]]
355+
// SILGEN: [[STACK:%.*]] = alloc_stack
356+
// SILGEN: [[MARK:%.*]] = mark_unresolved_non_copyable_value [consumable_and_assignable] [[STACK]]
357+
// SILGEN: store [[ARG]] to [init] [[MARK]]
336358
// SILGEN: [[DD:%.*]] = drop_deinit [[MARK]]
337-
// SILGEN: destroy_value [[DD]] : $IntEnumPairWithDeinit
338-
// SILGEN-NEXT: tuple ()
339-
// SILGEN-NEXT: return
359+
// SILGEN: switch_enum_addr [[DD]]
360+
// SILGEN-SAME: case #IntEnumPairWithDeinit.lhs!enumelt: [[BASIC_BLOCK1:bb[0-9]+]]
361+
// SILGEN-SAME: case #IntEnumPairWithDeinit.rhs!enumelt: [[BASIC_BLOCK2:bb[0-9]+]]
362+
// SILGEN: [[BASIC_BLOCK1]]:
363+
// SILGEN: [[L_ADDR:%[^,]+]] = unchecked_take_enum_data_addr [[DD]]
364+
// SILGEN-SAME: #IntEnumPairWithDeinit.lhs!enumelt
365+
// SILGEN: destroy_addr [[L_ADDR]]
366+
// SILGEN: [[BASIC_BLOCK2]]:
367+
// SILGEN: [[R_ADDR:%[^,]+]] = unchecked_take_enum_data_addr [[DD]]
368+
// SILGEN-SAME: #IntEnumPairWithDeinit.rhs!enumelt
369+
// SILGEN: destroy_addr [[R_ADDR]]
340370
// SILGEN: } // end sil function '$s16moveonly_deinits21IntEnumPairWithDeinitOfD'
341371

342372
//////////////////////

test/SILGen/moveonly_library_evolution.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
// RUN: %target-swift-emit-silgen -enable-upcoming-feature MoveOnlyPartialConsumption -enable-experimental-feature NoImplicitCopy -enable-library-evolution %s | %FileCheck %s
2-
// RUN: %target-swift-emit-sil -O -sil-verify-all -enable-upcoming-feature MoveOnlyPartialConsumption -enable-experimental-feature NoImplicitCopy -enable-library-evolution %s
1+
// RUN: %target-swift-emit-silgen -enable-experimental-feature NoImplicitCopy -enable-library-evolution %s | %FileCheck %s
2+
// RUN: %target-swift-emit-sil -O -sil-verify-all -enable-experimental-feature NoImplicitCopy -enable-library-evolution %s
33

44
////////////////////////
55
// MARK: Declarations //

test/SILGen/moveonly_optional_operations_2.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// RUN: %target-swift-frontend -emit-silgen -enable-experimental-feature NoncopyableGenerics -enable-upcoming-feature MoveOnlyPartialConsumption -parse-stdlib -module-name Swift %s | %FileCheck %s
1+
// RUN: %target-swift-frontend -emit-silgen -enable-experimental-feature NoncopyableGenerics -parse-stdlib -module-name Swift %s | %FileCheck %s
22

33
@_marker protocol Copyable {}
44
@_marker protocol Escapable {}

0 commit comments

Comments
 (0)