@@ -325,25 +325,29 @@ extension Array {
325325 /// inout violation in user code.
326326 @inlinable
327327 @_semantics ( " array.props.isNativeTypeChecked " )
328+ @_effects ( notEscaping self.** )
328329 public // @testable
329330 func _hoistableIsNativeTypeChecked( ) -> Bool {
330331 return _buffer. arrayPropertyIsNativeTypeChecked
331332 }
332333
333334 @inlinable
334335 @_semantics ( " array.get_count " )
336+ @_effects ( notEscaping self.** )
335337 internal func _getCount( ) -> Int {
336338 return _buffer. immutableCount
337339 }
338340
339341 @inlinable
340342 @_semantics ( " array.get_capacity " )
343+ @_effects ( notEscaping self.** )
341344 internal func _getCapacity( ) -> Int {
342345 return _buffer. immutableCapacity
343346 }
344347
345348 @inlinable
346349 @_semantics ( " array.make_mutable " )
350+ @_effects ( notEscaping self.** )
347351 internal mutating func _makeMutableAndUnique( ) {
348352 if _slowPath ( !_buffer. beginCOWMutation ( ) ) {
349353 _buffer = _buffer. _consumeAndCreateNew ( )
@@ -356,6 +360,7 @@ extension Array {
356360 /// to `_makeMutableAndUnique`.
357361 @_alwaysEmitIntoClient
358362 @_semantics ( " array.end_mutation " )
363+ @_effects ( notEscaping self.** )
359364 internal mutating func _endMutation( ) {
360365 _buffer. endCOWMutation ( )
361366 }
@@ -375,6 +380,7 @@ extension Array {
375380 /// `0 ≤ index < count`.
376381 @inlinable
377382 @_semantics ( " array.check_subscript " )
383+ @_effects ( notEscaping self.** )
378384 public // @testable
379385 func _checkSubscript(
380386 _ index: Int , wasNativeTypeChecked: Bool
@@ -394,19 +400,23 @@ extension Array {
394400 /// - Precondition: The buffer must be uniquely referenced and native.
395401 @_alwaysEmitIntoClient
396402 @_semantics ( " array.check_subscript " )
403+ @_effects ( notEscaping self.** )
397404 internal func _checkSubscript_mutating( _ index: Int ) {
398405 _buffer. _checkValidSubscriptMutating ( index)
399406 }
400407
401408 /// Check that the specified `index` is valid, i.e. `0 ≤ index ≤ count`.
402409 @inlinable
403410 @_semantics ( " array.check_index " )
411+ @_effects ( notEscaping self.** )
404412 internal func _checkIndex( _ index: Int ) {
405413 _precondition ( index <= endIndex, " Array index is out of range " )
406414 _precondition ( index >= startIndex, " Negative Array index is out of range " )
407415 }
408416
409417 @_semantics ( " array.get_element " )
418+ @_effects ( notEscaping self. value**)
419+ @_effects ( escaping self. value** . class* . value** - > return . value**)
410420 @inlinable // FIXME(inline-always)
411421 @inline ( __always)
412422 public // @testable
@@ -946,6 +956,9 @@ extension Array: RangeReplaceableCollection {
946956 /// - Precondition: `storage is _ContiguousArrayStorage`.
947957 @inlinable
948958 @_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**)
949962 internal static func _adoptStorage(
950963 _ storage: __owned _ContiguousArrayStorage< Element > , count: Int
951964 ) -> ( Array , UnsafeMutablePointer < Element > ) {
@@ -1041,6 +1054,7 @@ extension Array: RangeReplaceableCollection {
10411054 /// - Complexity: O(*n*), where *n* is the number of elements in the array.
10421055 @inlinable
10431056 @_semantics ( " array.mutate_unknown " )
1057+ @_effects ( notEscaping self.** )
10441058 public mutating func reserveCapacity( _ minimumCapacity: Int ) {
10451059 _reserveCapacityImpl ( minimumCapacity: minimumCapacity,
10461060 growForAppend: false )
@@ -1098,6 +1112,7 @@ extension Array: RangeReplaceableCollection {
10981112
10991113 @inlinable
11001114 @_semantics ( " array.make_mutable " )
1115+ @_effects ( notEscaping self.** )
11011116 internal mutating func _makeUniqueAndReserveCapacityIfNotUnique( ) {
11021117 if _slowPath ( !_buffer. beginCOWMutation ( ) ) {
11031118 _createNewBuffer ( bufferIsUnique: false ,
@@ -1108,6 +1123,7 @@ extension Array: RangeReplaceableCollection {
11081123
11091124 @inlinable
11101125 @_semantics ( " array.mutate_unknown " )
1126+ @_effects ( notEscaping self.** )
11111127 internal mutating func _reserveCapacityAssumingUniqueBuffer( oldCount: Int ) {
11121128 // Due to make_mutable hoisting the situation can arise where we hoist
11131129 // _makeMutableAndUnique out of loop and use it to replace
@@ -1130,6 +1146,7 @@ extension Array: RangeReplaceableCollection {
11301146
11311147 @inlinable
11321148 @_semantics ( " array.mutate_unknown " )
1149+ @_effects ( notEscaping self.** )
11331150 internal mutating func _appendElementAssumeUniqueAndCapacity(
11341151 _ oldCount: Int ,
11351152 newElement: __owned Element
@@ -1164,6 +1181,7 @@ extension Array: RangeReplaceableCollection {
11641181 /// same array.
11651182 @inlinable
11661183 @_semantics ( " array.append_element " )
1184+ @_effects ( notEscaping self. value**)
11671185 public mutating func append( _ newElement: __owned Element) {
11681186 // Separating uniqueness check and capacity check allows hoisting the
11691187 // uniqueness check out of a loop.
@@ -1192,6 +1210,7 @@ extension Array: RangeReplaceableCollection {
11921210 /// array.
11931211 @inlinable
11941212 @_semantics ( " array.append_contentsOf " )
1213+ @_effects ( notEscaping self. value**)
11951214 public mutating func append< S: Sequence > ( contentsOf newElements: __owned S)
11961215 where S. Element == Element {
11971216
@@ -1257,6 +1276,7 @@ extension Array: RangeReplaceableCollection {
12571276
12581277 @inlinable
12591278 @_semantics ( " array.reserve_capacity_for_append " )
1279+ @_effects ( notEscaping self.** )
12601280 internal mutating func reserveCapacityForAppend( newElementsCount: Int ) {
12611281 // Ensure uniqueness, mutability, and sufficient storage. Note that
12621282 // for consistency, we need unique self even if newElements is empty.
@@ -1267,6 +1287,8 @@ extension Array: RangeReplaceableCollection {
12671287
12681288 @inlinable
12691289 @_semantics ( " array.mutate_unknown " )
1290+ @_effects ( notEscaping self. value**)
1291+ @_effects ( escaping self. value** . class* . value** - > return . value**)
12701292 public mutating func _customRemoveLast( ) -> Element ? {
12711293 _makeMutableAndUnique ( )
12721294 let newCount = _buffer. mutableCount - 1
@@ -1296,6 +1318,8 @@ extension Array: RangeReplaceableCollection {
12961318 @inlinable
12971319 @discardableResult
12981320 @_semantics ( " array.mutate_unknown " )
1321+ @_effects ( notEscaping self. value**)
1322+ @_effects ( escaping self. value** . class* . value** - > return . value**)
12991323 public mutating func remove( at index: Int ) -> Element {
13001324 _makeMutableAndUnique ( )
13011325 let currentCount = _buffer. mutableCount
@@ -1595,6 +1619,7 @@ extension Array {
15951619 /// method's execution.
15961620 /// - Returns: The return value, if any, of the `body` closure parameter.
15971621 @_semantics ( " array.withUnsafeMutableBufferPointer " )
1622+ @_effects ( notEscaping self. value**)
15981623 @inlinable // FIXME(inline-always)
15991624 @inline ( __always) // Performance: This method should get inlined into the
16001625 // caller such that we can combine the partial apply with the apply in this
@@ -1693,6 +1718,8 @@ extension Array {
16931718 /// equivalent to `append(contentsOf:)`.
16941719 @inlinable
16951720 @_semantics ( " array.mutate_unknown " )
1721+ @_effects ( notEscaping self. value**)
1722+ @_effects ( notEscaping self. value**. class*. value**)
16961723 public mutating func replaceSubrange< C> (
16971724 _ subrange: Range < Int > ,
16981725 with newElements: __owned C
0 commit comments