@@ -325,25 +325,29 @@ extension Array {
325
325
/// inout violation in user code.
326
326
@inlinable
327
327
@_semantics ( " array.props.isNativeTypeChecked " )
328
+ @_effects ( notEscaping self.** )
328
329
public // @testable
329
330
func _hoistableIsNativeTypeChecked( ) -> Bool {
330
331
return _buffer. arrayPropertyIsNativeTypeChecked
331
332
}
332
333
333
334
@inlinable
334
335
@_semantics ( " array.get_count " )
336
+ @_effects ( notEscaping self.** )
335
337
internal func _getCount( ) -> Int {
336
338
return _buffer. immutableCount
337
339
}
338
340
339
341
@inlinable
340
342
@_semantics ( " array.get_capacity " )
343
+ @_effects ( notEscaping self.** )
341
344
internal func _getCapacity( ) -> Int {
342
345
return _buffer. immutableCapacity
343
346
}
344
347
345
348
@inlinable
346
349
@_semantics ( " array.make_mutable " )
350
+ @_effects ( notEscaping self.** )
347
351
internal mutating func _makeMutableAndUnique( ) {
348
352
if _slowPath ( !_buffer. beginCOWMutation ( ) ) {
349
353
_buffer = _buffer. _consumeAndCreateNew ( )
@@ -356,6 +360,7 @@ extension Array {
356
360
/// to `_makeMutableAndUnique`.
357
361
@_alwaysEmitIntoClient
358
362
@_semantics ( " array.end_mutation " )
363
+ @_effects ( notEscaping self.** )
359
364
internal mutating func _endMutation( ) {
360
365
_buffer. endCOWMutation ( )
361
366
}
@@ -375,6 +380,7 @@ extension Array {
375
380
/// `0 ≤ index < count`.
376
381
@inlinable
377
382
@_semantics ( " array.check_subscript " )
383
+ @_effects ( notEscaping self.** )
378
384
public // @testable
379
385
func _checkSubscript(
380
386
_ index: Int , wasNativeTypeChecked: Bool
@@ -394,19 +400,23 @@ extension Array {
394
400
/// - Precondition: The buffer must be uniquely referenced and native.
395
401
@_alwaysEmitIntoClient
396
402
@_semantics ( " array.check_subscript " )
403
+ @_effects ( notEscaping self.** )
397
404
internal func _checkSubscript_mutating( _ index: Int ) {
398
405
_buffer. _checkValidSubscriptMutating ( index)
399
406
}
400
407
401
408
/// Check that the specified `index` is valid, i.e. `0 ≤ index ≤ count`.
402
409
@inlinable
403
410
@_semantics ( " array.check_index " )
411
+ @_effects ( notEscaping self.** )
404
412
internal func _checkIndex( _ index: Int ) {
405
413
_precondition ( index <= endIndex, " Array index is out of range " )
406
414
_precondition ( index >= startIndex, " Negative Array index is out of range " )
407
415
}
408
416
409
417
@_semantics ( " array.get_element " )
418
+ @_effects ( notEscaping self. value**)
419
+ @_effects ( escaping self. value** . class* . value** - > return . value**)
410
420
@inlinable // FIXME(inline-always)
411
421
@inline ( __always)
412
422
public // @testable
@@ -946,6 +956,9 @@ extension Array: RangeReplaceableCollection {
946
956
/// - Precondition: `storage is _ContiguousArrayStorage`.
947
957
@inlinable
948
958
@_semantics ( " array.uninitialized " )
959
+ @_effects ( escaping storage => return. 0 . value**)
960
+ @_effects ( escaping storage. class*. value** => return. 0 . value**. class*. value**)
961
+ @_effects ( escaping storage. class*. value** => return. 1 . value**)
949
962
internal static func _adoptStorage(
950
963
_ storage: __owned _ContiguousArrayStorage< Element > , count: Int
951
964
) -> ( Array , UnsafeMutablePointer < Element > ) {
@@ -1041,6 +1054,7 @@ extension Array: RangeReplaceableCollection {
1041
1054
/// - Complexity: O(*n*), where *n* is the number of elements in the array.
1042
1055
@inlinable
1043
1056
@_semantics ( " array.mutate_unknown " )
1057
+ @_effects ( notEscaping self.** )
1044
1058
public mutating func reserveCapacity( _ minimumCapacity: Int ) {
1045
1059
_reserveCapacityImpl ( minimumCapacity: minimumCapacity,
1046
1060
growForAppend: false )
@@ -1098,6 +1112,7 @@ extension Array: RangeReplaceableCollection {
1098
1112
1099
1113
@inlinable
1100
1114
@_semantics ( " array.make_mutable " )
1115
+ @_effects ( notEscaping self.** )
1101
1116
internal mutating func _makeUniqueAndReserveCapacityIfNotUnique( ) {
1102
1117
if _slowPath ( !_buffer. beginCOWMutation ( ) ) {
1103
1118
_createNewBuffer ( bufferIsUnique: false ,
@@ -1108,6 +1123,7 @@ extension Array: RangeReplaceableCollection {
1108
1123
1109
1124
@inlinable
1110
1125
@_semantics ( " array.mutate_unknown " )
1126
+ @_effects ( notEscaping self.** )
1111
1127
internal mutating func _reserveCapacityAssumingUniqueBuffer( oldCount: Int ) {
1112
1128
// Due to make_mutable hoisting the situation can arise where we hoist
1113
1129
// _makeMutableAndUnique out of loop and use it to replace
@@ -1130,6 +1146,7 @@ extension Array: RangeReplaceableCollection {
1130
1146
1131
1147
@inlinable
1132
1148
@_semantics ( " array.mutate_unknown " )
1149
+ @_effects ( notEscaping self.** )
1133
1150
internal mutating func _appendElementAssumeUniqueAndCapacity(
1134
1151
_ oldCount: Int ,
1135
1152
newElement: __owned Element
@@ -1164,6 +1181,7 @@ extension Array: RangeReplaceableCollection {
1164
1181
/// same array.
1165
1182
@inlinable
1166
1183
@_semantics ( " array.append_element " )
1184
+ @_effects ( notEscaping self. value**)
1167
1185
public mutating func append( _ newElement: __owned Element) {
1168
1186
// Separating uniqueness check and capacity check allows hoisting the
1169
1187
// uniqueness check out of a loop.
@@ -1192,6 +1210,7 @@ extension Array: RangeReplaceableCollection {
1192
1210
/// array.
1193
1211
@inlinable
1194
1212
@_semantics ( " array.append_contentsOf " )
1213
+ @_effects ( notEscaping self. value**)
1195
1214
public mutating func append< S: Sequence > ( contentsOf newElements: __owned S)
1196
1215
where S. Element == Element {
1197
1216
@@ -1257,6 +1276,7 @@ extension Array: RangeReplaceableCollection {
1257
1276
1258
1277
@inlinable
1259
1278
@_semantics ( " array.reserve_capacity_for_append " )
1279
+ @_effects ( notEscaping self.** )
1260
1280
internal mutating func reserveCapacityForAppend( newElementsCount: Int ) {
1261
1281
// Ensure uniqueness, mutability, and sufficient storage. Note that
1262
1282
// for consistency, we need unique self even if newElements is empty.
@@ -1267,6 +1287,8 @@ extension Array: RangeReplaceableCollection {
1267
1287
1268
1288
@inlinable
1269
1289
@_semantics ( " array.mutate_unknown " )
1290
+ @_effects ( notEscaping self. value**)
1291
+ @_effects ( escaping self. value** . class* . value** - > return . value**)
1270
1292
public mutating func _customRemoveLast( ) -> Element ? {
1271
1293
_makeMutableAndUnique ( )
1272
1294
let newCount = _buffer. mutableCount - 1
@@ -1296,6 +1318,8 @@ extension Array: RangeReplaceableCollection {
1296
1318
@inlinable
1297
1319
@discardableResult
1298
1320
@_semantics ( " array.mutate_unknown " )
1321
+ @_effects ( notEscaping self. value**)
1322
+ @_effects ( escaping self. value** . class* . value** - > return . value**)
1299
1323
public mutating func remove( at index: Int ) -> Element {
1300
1324
_makeMutableAndUnique ( )
1301
1325
let currentCount = _buffer. mutableCount
@@ -1595,6 +1619,7 @@ extension Array {
1595
1619
/// method's execution.
1596
1620
/// - Returns: The return value, if any, of the `body` closure parameter.
1597
1621
@_semantics ( " array.withUnsafeMutableBufferPointer " )
1622
+ @_effects ( notEscaping self. value**)
1598
1623
@inlinable // FIXME(inline-always)
1599
1624
@inline ( __always) // Performance: This method should get inlined into the
1600
1625
// caller such that we can combine the partial apply with the apply in this
@@ -1693,6 +1718,8 @@ extension Array {
1693
1718
/// equivalent to `append(contentsOf:)`.
1694
1719
@inlinable
1695
1720
@_semantics ( " array.mutate_unknown " )
1721
+ @_effects ( notEscaping self. value**)
1722
+ @_effects ( notEscaping self. value**. class*. value**)
1696
1723
public mutating func replaceSubrange< C> (
1697
1724
_ subrange: Range < Int > ,
1698
1725
with newElements: __owned C
0 commit comments