Skip to content

Commit b7c9edd

Browse files
committed
[noescape by default] drop @NoEscape from stdlib
1 parent 9e9a1b9 commit b7c9edd

Some content is hidden

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

46 files changed

+168
-168
lines changed

stdlib/private/StdlibCollectionUnittest/CheckMutableCollectionType.swift.gyb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ public func withInvalidOrderings(_ body: (@escaping (Int, Int) -> Bool) -> Void)
6060

6161
internal func _mapInPlace<C : MutableCollection>(
6262
_ elements: inout C,
63-
_ transform: @noescape (C.Iterator.Element) -> C.Iterator.Element
63+
_ transform: (C.Iterator.Element) -> C.Iterator.Element
6464
) where C.Indices.Iterator.Element == C.Index {
6565
for i in elements.indices {
6666
elements[i] = transform(elements[i])

stdlib/private/StdlibCollectionUnittest/LoggingWrappers.swift.gyb

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -224,28 +224,28 @@ public struct ${Self}<
224224
}
225225

226226
public func map<T>(
227-
_ transform: @noescape (Base.Iterator.Element) throws -> T
227+
_ transform: (Base.Iterator.Element) throws -> T
228228
) rethrows -> [T] {
229229
Log.map[selfType] += 1
230230
return try base.map(transform)
231231
}
232232

233233
public func filter(
234-
_ isIncluded: @noescape (Base.Iterator.Element) throws -> Bool
234+
_ isIncluded: (Base.Iterator.Element) throws -> Bool
235235
) rethrows -> [Base.Iterator.Element] {
236236
Log.filter[selfType] += 1
237237
return try base.filter(isIncluded)
238238
}
239239

240240
public func forEach(
241-
_ body: @noescape (Base.Iterator.Element) throws -> Void
241+
_ body: (Base.Iterator.Element) throws -> Void
242242
) rethrows {
243243
Log.forEach[selfType] += 1
244244
try base.forEach(body)
245245
}
246246

247247
public func first(
248-
where predicate: @noescape (Base.Iterator.Element) throws -> Bool
248+
where predicate: (Base.Iterator.Element) throws -> Bool
249249
) rethrows -> Base.Iterator.Element? {
250250
Log.first[selfType] += 1
251251
return try base.first(where: predicate)
@@ -276,7 +276,7 @@ public struct ${Self}<
276276
public func split(
277277
maxSplits: Int = Int.max,
278278
omittingEmptySubsequences: Bool = true,
279-
whereSeparator isSeparator: @noescape (Base.Iterator.Element) throws -> Bool
279+
whereSeparator isSeparator: (Base.Iterator.Element) throws -> Bool
280280
) rethrows -> [SubSequence] {
281281
Log.split[selfType] += 1
282282
return try base.split(
@@ -296,7 +296,7 @@ public struct ${Self}<
296296
/// `preprocess` on `self` and return its result. Otherwise, return
297297
/// `nil`.
298298
public func _preprocessingPass<R>(
299-
_ preprocess: @noescape () throws -> R
299+
_ preprocess: () throws -> R
300300
) rethrows -> R? {
301301
Log._preprocessingPass[selfType] += 1
302302
return try base._preprocessingPass(preprocess)
@@ -443,14 +443,14 @@ public struct ${Self}<
443443

444444
% if Kind == 'MutableCollection':
445445
public mutating func partition(
446-
by belongsInSecondPartition: @noescape (Iterator.Element) throws -> Bool
446+
by belongsInSecondPartition: (Iterator.Element) throws -> Bool
447447
) rethrows -> Index {
448448
Log.partitionBy[selfType] += 1
449449
return try base.partition(by: belongsInSecondPartition)
450450
}
451451

452452
public mutating func _withUnsafeMutableBufferPointerIfSupported<R>(
453-
_ body: @noescape (UnsafeMutablePointer<Iterator.Element>, Int) throws -> R
453+
_ body: (UnsafeMutablePointer<Iterator.Element>, Int) throws -> R
454454
) rethrows -> R? {
455455
Log._withUnsafeMutableBufferPointerIfSupported[selfType] += 1
456456
let result = try base._withUnsafeMutableBufferPointerIfSupported(body)
@@ -650,7 +650,7 @@ public struct ${Self}<
650650
}
651651

652652
public mutating func _withUnsafeMutableBufferPointerIfSupported<R>(
653-
_ body: @noescape (UnsafeMutablePointer<Iterator.Element>, Int) throws -> R
653+
_ body: (UnsafeMutablePointer<Iterator.Element>, Int) throws -> R
654654
) rethrows -> R? {
655655
Log._withUnsafeMutableBufferPointerIfSupported[selfType] += 1
656656
let result = try base._withUnsafeMutableBufferPointerIfSupported(body)

stdlib/private/StdlibUnittest/RaceTest.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ import Glibc
4747
#if _runtime(_ObjC)
4848
import ObjectiveC
4949
#else
50-
func autoreleasepool(invoking code: @noescape () -> Void) {
50+
func autoreleasepool(invoking code: () -> Void) {
5151
// Native runtime does not have autorelease pools. Execute the code
5252
// directly.
5353
code()

stdlib/private/StdlibUnittestFoundationExtras/StdlibUnittestFoundationExtras.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ extension NSLocale {
2424

2525
public func withOverriddenLocaleCurrentLocale<Result>(
2626
_ temporaryLocale: NSLocale,
27-
_ body: @noescape () -> Result
27+
_ body: () -> Result
2828
) -> Result {
2929
let oldMethod = class_getClassMethod(
3030
NSLocale.self, #selector(getter: NSLocale.current))
@@ -48,7 +48,7 @@ public func withOverriddenLocaleCurrentLocale<Result>(
4848

4949
public func withOverriddenLocaleCurrentLocale<Result>(
5050
_ temporaryLocaleIdentifier: String,
51-
_ body: @noescape () -> Result
51+
_ body: () -> Result
5252
) -> Result {
5353
precondition(
5454
NSLocale.availableLocaleIdentifiers.contains(temporaryLocaleIdentifier),
@@ -65,7 +65,7 @@ public func withOverriddenLocaleCurrentLocale<Result>(
6565
/// return-autoreleased optimization.)
6666
@inline(never)
6767
public func autoreleasepoolIfUnoptimizedReturnAutoreleased(
68-
invoking body: @noescape () -> Void
68+
invoking body: () -> Void
6969
) {
7070
#if arch(i386) && (os(iOS) || os(watchOS))
7171
autoreleasepool(invoking: body)

stdlib/public/SDK/Dispatch/Block.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,9 @@ public class DispatchWorkItem {
4343
qos.qosClass.rawValue.rawValue, Int32(qos.relativePriority), block)
4444
}
4545

46-
// Used by DispatchQueue.synchronously<T> to provide a @noescape path through
46+
// Used by DispatchQueue.synchronously<T> to provide a path through
4747
// dispatch_block_t, as we know the lifetime of the block in question.
48-
internal init(flags: DispatchWorkItemFlags = [], noescapeBlock: @noescape () -> ()) {
48+
internal init(flags: DispatchWorkItemFlags = [], noescapeBlock: () -> ()) {
4949
_block = _swift_dispatch_block_create_noescape(flags.rawValue, noescapeBlock)
5050
}
5151

stdlib/public/SDK/Dispatch/Data.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ public struct DispatchData : RandomAccessCollection, _ObjectiveCBridgeable {
7070
}
7171

7272
public func withUnsafeBytes<Result, ContentType>(
73-
body: @noescape (UnsafePointer<ContentType>) throws -> Result) rethrows -> Result
73+
body: (UnsafePointer<ContentType>) throws -> Result) rethrows -> Result
7474
{
7575
var ptr: UnsafeRawPointer? = nil
7676
var size = 0
@@ -82,7 +82,7 @@ public struct DispatchData : RandomAccessCollection, _ObjectiveCBridgeable {
8282
}
8383

8484
public func enumerateBytes(
85-
block: @noescape (_ buffer: UnsafeBufferPointer<UInt8>, _ byteIndex: Int, _ stop: inout Bool) -> Void)
85+
block: (_ buffer: UnsafeBufferPointer<UInt8>, _ byteIndex: Int, _ stop: inout Bool) -> Void)
8686
{
8787
_swift_dispatch_data_apply(__wrapped) { (_, offset: Int, ptr: UnsafeRawPointer, size: Int) in
8888
let bytePtr = ptr.bindMemory(to: UInt8.self, capacity: size)

stdlib/public/SDK/Dispatch/Private.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ public func dispatch_io_set_interval(_ channel: DispatchIO, _ interval: UInt64,
139139
}
140140

141141
@available(*, unavailable, renamed:"DispatchQueue.apply(attributes:iterations:execute:)")
142-
public func dispatch_apply(_ iterations: Int, _ queue: DispatchQueue, _ block: @noescape (Int) -> Void)
142+
public func dispatch_apply(_ iterations: Int, _ queue: DispatchQueue, _ block: (Int) -> Void)
143143
{
144144
fatalError()
145145
}
@@ -205,7 +205,7 @@ public func dispatch_barrier_async(_ queue: DispatchQueue, _ block: () -> Void)
205205
}
206206

207207
@available(*, unavailable, renamed:"DispatchQueue.sync(self:flags:execute:)")
208-
public func dispatch_barrier_sync(_ queue: DispatchQueue, _ block: @noescape () -> Void)
208+
public func dispatch_barrier_sync(_ queue: DispatchQueue, _ block: () -> Void)
209209
{
210210
fatalError()
211211
}

stdlib/public/SDK/Dispatch/Queue.swift

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ public extension DispatchQueue {
111111
}
112112
}
113113

114-
public class func concurrentPerform(iterations: Int, execute work: @noescape (Int) -> Void) {
114+
public class func concurrentPerform(iterations: Int, execute work: (Int) -> Void) {
115115
_swift_dispatch_apply_current(UInt32(iterations), work)
116116
}
117117

@@ -221,13 +221,13 @@ public extension DispatchQueue {
221221
}
222222
}
223223

224-
private func _syncBarrier(block: @noescape () -> ()) {
224+
private func _syncBarrier(block: () -> ()) {
225225
__dispatch_barrier_sync(self, block)
226226
}
227227

228228
private func _syncHelper<T>(
229-
fn: (@noescape () -> ()) -> (),
230-
execute work: @noescape () throws -> T,
229+
fn: (() -> ()) -> (),
230+
execute work: () throws -> T,
231231
rescue: ((Error) throws -> (T))) rethrows -> T
232232
{
233233
var result: T?
@@ -250,7 +250,7 @@ public extension DispatchQueue {
250250
private func _syncHelper<T>(
251251
fn: (DispatchWorkItem) -> (),
252252
flags: DispatchWorkItemFlags,
253-
execute work: @noescape () throws -> T,
253+
execute work: () throws -> T,
254254
rescue: ((Error) throws -> (T))) rethrows -> T
255255
{
256256
var result: T?
@@ -270,11 +270,11 @@ public extension DispatchQueue {
270270
}
271271
}
272272

273-
public func sync<T>(execute work: @noescape () throws -> T) rethrows -> T {
273+
public func sync<T>(execute work: () throws -> T) rethrows -> T {
274274
return try self._syncHelper(fn: sync, execute: work, rescue: { throw $0 })
275275
}
276276

277-
public func sync<T>(flags: DispatchWorkItemFlags, execute work: @noescape () throws -> T) rethrows -> T {
277+
public func sync<T>(flags: DispatchWorkItemFlags, execute work: () throws -> T) rethrows -> T {
278278
if flags == .barrier {
279279
return try self._syncHelper(fn: _syncBarrier, execute: work, rescue: { throw $0 })
280280
} else if #available(OSX 10.10, iOS 8.0, *), !flags.isEmpty {

stdlib/public/SDK/Foundation/Boxing.swift

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ internal final class _MutableHandle<MutableType : NSObject>
2828
}
2929

3030
/// Apply a closure to the reference type.
31-
func map<ReturnType>(_ whatToDo : @noescape (MutableType) throws -> ReturnType) rethrows -> ReturnType {
31+
func map<ReturnType>(_ whatToDo : (MutableType) throws -> ReturnType) rethrows -> ReturnType {
3232
return try whatToDo(_pointer)
3333
}
3434

@@ -48,7 +48,7 @@ internal protocol _MutableBoxing : ReferenceConvertible {
4848
/// Apply a mutating closure to the reference type, regardless if it is mutable or immutable.
4949
///
5050
/// This function performs the correct copy-on-write check for efficient mutation.
51-
mutating func _applyMutation<ReturnType>(_ whatToDo : @noescape (ReferenceType) -> ReturnType) -> ReturnType
51+
mutating func _applyMutation<ReturnType>(_ whatToDo : (ReferenceType) -> ReturnType) -> ReturnType
5252
}
5353

5454
extension _MutableBoxing {
@@ -89,7 +89,7 @@ internal protocol _SwiftNativeFoundationType : class {
8989
extension _SwiftNativeFoundationType {
9090

9191
@inline(__always)
92-
func _mapUnmanaged<ReturnType>(_ whatToDo : @noescape (ImmutableType) throws -> ReturnType) rethrows -> ReturnType {
92+
func _mapUnmanaged<ReturnType>(_ whatToDo : (ImmutableType) throws -> ReturnType) rethrows -> ReturnType {
9393
defer { _fixLifetime(self) }
9494

9595
switch __wrapped {
@@ -145,7 +145,7 @@ internal protocol _MutablePairBoxing {
145145

146146
extension _MutablePairBoxing {
147147
@inline(__always)
148-
func _mapUnmanaged<ReturnType>(_ whatToDo : @noescape (WrappedSwiftNSType.ImmutableType) throws -> ReturnType) rethrows -> ReturnType {
148+
func _mapUnmanaged<ReturnType>(_ whatToDo : (WrappedSwiftNSType.ImmutableType) throws -> ReturnType) rethrows -> ReturnType {
149149
// We are using Unmanaged. Make sure that the owning container class
150150
// 'self' is guaranteed to be alive by extending the lifetime of 'self'
151151
// to the end of the scope of this function.
@@ -170,7 +170,7 @@ extension _MutablePairBoxing {
170170
}
171171

172172
@inline(__always)
173-
mutating func _applyUnmanagedMutation<ReturnType>(_ whatToDo : @noescape (WrappedSwiftNSType.MutableType) throws -> ReturnType) rethrows -> ReturnType {
173+
mutating func _applyUnmanagedMutation<ReturnType>(_ whatToDo : (WrappedSwiftNSType.MutableType) throws -> ReturnType) rethrows -> ReturnType {
174174
// We are using Unmanaged. Make sure that the owning container class
175175
// 'self' is guaranteed to be alive by extending the lifetime of 'self'
176176
// to the end of the scope of this function.

stdlib/public/SDK/Foundation/Calendar.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -805,7 +805,7 @@ public struct Calendar : Hashable, Equatable, ReferenceConvertible, _MutableBoxi
805805
}
806806

807807
@available(*, unavailable, message: "use nextWeekend(startingAfter:matching:matchingPolicy:repeatedTimePolicy:direction:using:) instead")
808-
public func enumerateDates(startingAfter start: Date, matching comps: DateComponents, options opts: NSCalendar.Options = [], using block: @noescape (Date?, Bool, UnsafeMutablePointer<ObjCBool>) -> Swift.Void) { fatalError() }
808+
public func enumerateDates(startingAfter start: Date, matching comps: DateComponents, options opts: NSCalendar.Options = [], using block: (Date?, Bool, UnsafeMutablePointer<ObjCBool>) -> Swift.Void) { fatalError() }
809809

810810
/// Computes the dates which match (or most closely match) a given set of components, and calls the closure once for each of them, until the enumeration is stopped.
811811
///
@@ -825,7 +825,7 @@ public struct Calendar : Hashable, Equatable, ReferenceConvertible, _MutableBoxi
825825
/// - parameter direction: Which direction in time to search. The default value is `.forward`, which means later in time.
826826
/// - parameter block: A closure that is called with search results.
827827
@available(iOS 8.0, *)
828-
public func enumerateDates(startingAfter start: Date, matching components: DateComponents, matchingPolicy: MatchingPolicy, repeatedTimePolicy: RepeatedTimePolicy = .first, direction: SearchDirection = .forward, using block: @noescape (_ result: Date?, _ exactMatch: Bool, _ stop: inout Bool) -> Void) {
828+
public func enumerateDates(startingAfter start: Date, matching components: DateComponents, matchingPolicy: MatchingPolicy, repeatedTimePolicy: RepeatedTimePolicy = .first, direction: SearchDirection = .forward, using block: (_ result: Date?, _ exactMatch: Bool, _ stop: inout Bool) -> Void) {
829829
_handle.map {
830830
$0.enumerateDates(startingAfter: start, matching: components, options: Calendar._toCalendarOptions(matchingPolicy: matchingPolicy, repeatedTimePolicy: repeatedTimePolicy, direction: direction)) { (result, exactMatch, stop) in
831831
var stopv = false

stdlib/public/SDK/Foundation/Data.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,7 @@ public struct Data : ReferenceConvertible, Equatable, Hashable, RandomAccessColl
278278
/// Access the bytes in the data.
279279
///
280280
/// - warning: The byte pointer argument should not be stored and used outside of the lifetime of the call to the closure.
281-
public func withUnsafeBytes<ResultType, ContentType>(_ body: @noescape (UnsafePointer<ContentType>) throws -> ResultType) rethrows -> ResultType {
281+
public func withUnsafeBytes<ResultType, ContentType>(_ body: (UnsafePointer<ContentType>) throws -> ResultType) rethrows -> ResultType {
282282
let bytes = _getUnsafeBytesPointer()
283283
defer { _fixLifetime(self)}
284284
let contentPtr = bytes.bindMemory(to: ContentType.self, capacity: count / MemoryLayout<ContentType>.stride)
@@ -295,7 +295,7 @@ public struct Data : ReferenceConvertible, Equatable, Hashable, RandomAccessColl
295295
///
296296
/// This function assumes that you are mutating the contents.
297297
/// - warning: The byte pointer argument should not be stored and used outside of the lifetime of the call to the closure.
298-
public mutating func withUnsafeMutableBytes<ResultType, ContentType>(_ body: @noescape (UnsafeMutablePointer<ContentType>) throws -> ResultType) rethrows -> ResultType {
298+
public mutating func withUnsafeMutableBytes<ResultType, ContentType>(_ body: (UnsafeMutablePointer<ContentType>) throws -> ResultType) rethrows -> ResultType {
299299
let mutableBytes = _getUnsafeMutableBytesPointer()
300300
defer { _fixLifetime(self)}
301301
let contentPtr = mutableBytes.bindMemory(to: ContentType.self, capacity: count / MemoryLayout<ContentType>.stride)
@@ -423,7 +423,7 @@ public struct Data : ReferenceConvertible, Equatable, Hashable, RandomAccessColl
423423
///
424424
/// In some cases, (for example, a `Data` backed by a `dispatch_data_t`, the bytes may be stored discontiguously. In those cases, this function invokes the closure for each contiguous region of bytes.
425425
/// - parameter block: The closure to invoke for each region of data. You may stop the enumeration by setting the `stop` parameter to `true`.
426-
public func enumerateBytes(_ block: @noescape (_ buffer: UnsafeBufferPointer<UInt8>, _ byteIndex: Index, _ stop: inout Bool) -> Void) {
426+
public func enumerateBytes(_ block: (_ buffer: UnsafeBufferPointer<UInt8>, _ byteIndex: Index, _ stop: inout Bool) -> Void) {
427427
_mapUnmanaged {
428428
$0.enumerateBytes { (ptr, range, stop) in
429429
var stopv = false
@@ -820,7 +820,7 @@ extension _SwiftNSData {
820820
}
821821

822822
@objc(enumerateByteRangesUsingBlock:)
823-
func enumerateByteRanges(using block: @noescape (UnsafeRawPointer, NSRange, UnsafeMutablePointer<ObjCBool>) -> Void) {
823+
func enumerateByteRanges(using block: (UnsafeRawPointer, NSRange, UnsafeMutablePointer<ObjCBool>) -> Void) {
824824
return _mapUnmanaged { $0.enumerateBytes(block) }
825825
}
826826

0 commit comments

Comments
 (0)