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 {
389
389
390
390
props = mergeIsTypeExpansionSensitive (isSensitive, props);
391
391
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
+
392
397
// If the size isn't a known literal, then the layout is also dependent,
393
398
// so make it address-only. If the size is massive, also treat it as
394
399
// address-only since there's little practical benefit to passing around
@@ -2540,6 +2545,7 @@ namespace {
2540
2545
// If the type has raw storage, it is move-only and address-only.
2541
2546
if (D->getAttrs ().hasAttribute <RawLayoutAttr>()) {
2542
2547
properties.setAddressOnly ();
2548
+ properties.setAddressableForDependencies ();
2543
2549
properties.setNonTrivial ();
2544
2550
properties.setLexical (IsLexical);
2545
2551
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
2
2
3
3
// REQUIRES: swift_feature_BuiltinModule
4
4
// REQUIRES: swift_feature_AddressableTypes
5
5
// REQUIRES: swift_feature_LifetimeDependence
6
+ // REQUIRES: swift_feature_ValueGenerics
6
7
7
8
import Builtin
8
9
@@ -58,3 +59,22 @@ struct AllocatedNode: ~Copyable {
58
59
}
59
60
}
60
61
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