File tree Expand file tree Collapse file tree 2 files changed +27
-1
lines changed Expand file tree Collapse file tree 2 files changed +27
-1
lines changed Original file line number Diff line number Diff line change @@ -389,6 +389,11 @@ namespace {
389389
390390 props = mergeIsTypeExpansionSensitive (isSensitive, props);
391391
392+ // Fixed array regions are implied to be addressable-for-dependencies,
393+ // since the developer probably wants to be able to form Spans etc.
394+ // over them.
395+ props.setAddressableForDependencies ();
396+
392397 // If the size isn't a known literal, then the layout is also dependent,
393398 // so make it address-only. If the size is massive, also treat it as
394399 // address-only since there's little practical benefit to passing around
@@ -2540,6 +2545,7 @@ namespace {
25402545 // If the type has raw storage, it is move-only and address-only.
25412546 if (D->getAttrs ().hasAttribute <RawLayoutAttr>()) {
25422547 properties.setAddressOnly ();
2548+ properties.setAddressableForDependencies ();
25432549 properties.setNonTrivial ();
25442550 properties.setLexical (IsLexical);
25452551 return handleMoveOnlyAddressOnly (structType, properties);
Original file line number Diff line number Diff line change 1- // RUN: %target-swift-frontend -emit-sil -enable-experimental-feature BuiltinModule -enable-experimental-feature LifetimeDependence -enable-experimental-feature AddressableTypes %s | %FileCheck %s
1+ // RUN: %target-swift-frontend -emit-sil -enable-experimental-feature BuiltinModule -enable-experimental-feature LifetimeDependence -enable-experimental-feature AddressableTypes -enable-experimental-feature ValueGenerics %s | %FileCheck %s
22
33// REQUIRES: swift_feature_BuiltinModule
44// REQUIRES: swift_feature_AddressableTypes
55// REQUIRES: swift_feature_LifetimeDependence
6+ // REQUIRES: swift_feature_ValueGenerics
67
78import Builtin
89
@@ -58,3 +59,22 @@ struct AllocatedNode: ~Copyable {
5859 }
5960}
6061
62+ struct Schmector {
63+ // structurally addressable-for-dependencies by virtue of containing a
64+ // Builtin.FixedArray
65+ private var elements : Builtin . FixedArray < 10 , Int >
66+
67+ var storage : Spam {
68+ // CHECK-LABEL: sil {{.*}}@${{.*}}9SchmectorV7storage{{.*}}Vvg :
69+ // CHECK-SAME: (@in_guaranteed Schmector) ->
70+ @lifetime ( borrow self)
71+ borrowing get {
72+ return Spam ( base: UnsafePointer ( Builtin . addressOfBorrow ( self ) ) , count: 10 )
73+ }
74+ }
75+ }
76+
77+ struct Spam : ~ Escapable {
78+ @_unsafeNonescapableResult
79+ init ( base: UnsafePointer < Int > , count: Int ) { }
80+ }
You can’t perform that action at this time.
0 commit comments