Skip to content

Commit b5bc9be

Browse files
author
Dave Abrahams
committed
<label> body => _ body
1 parent eb27bb6 commit b5bc9be

File tree

15 files changed

+36
-27
lines changed

15 files changed

+36
-27
lines changed

stdlib/private/StdlibUnittest/RaceTest.swift

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -596,7 +596,9 @@ internal struct ClosureBasedRaceTest : RaceTestWithPerTrialData {
596596
) {}
597597
}
598598

599-
public func runRaceTest(trials: Int, threads: Int? = nil, body: () -> ()) {
599+
public func runRaceTest(
600+
trials: Int, threads: Int? = nil, invoking body: () -> ()
601+
) {
600602
ClosureBasedRaceTest.thread = body
601603
runRaceTest(ClosureBasedRaceTest.self, trials: trials, threads: threads)
602604
}

stdlib/private/StdlibUnittest/StdlibCoreExtras.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ extension MutableCollection
214214
}
215215

216216
/// Generate all permutations.
217-
public func forAllPermutations(_ size: Int, body: ([Int]) -> Void) {
217+
public func forAllPermutations(_ size: Int, _ body: ([Int]) -> Void) {
218218
var data = Array(0..<size)
219219
repeat {
220220
body(data)
@@ -223,7 +223,7 @@ public func forAllPermutations(_ size: Int, body: ([Int]) -> Void) {
223223

224224
/// Generate all permutations.
225225
public func forAllPermutations<S : Sequence>(
226-
_ sequence: S, body: ([S.Iterator.Element]) -> Void
226+
_ sequence: S, _ body: ([S.Iterator.Element]) -> Void
227227
) {
228228
let data = Array(sequence)
229229
forAllPermutations(data.count) {

stdlib/private/StdlibUnittest/StdlibUnittest.swift.gyb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ var _seenExpectCrash = false
107107
/// Run `body` and expect a failure to happen.
108108
///
109109
/// The check passes iff `body` triggers one or more failures.
110-
public func expectFailure(${TRACE}, body: () -> Void) {
110+
public func expectFailure(${TRACE}, invoking body: () -> Void) {
111111
let startAnyExpectFailed = _anyExpectFailed
112112
_anyExpectFailed = false
113113
body()

stdlib/private/StdlibUnittest/TypeIndexed.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ extension TypeIndexed where Value : Strideable {
5959
showFrame: Bool = true,
6060
stackTrace: SourceLocStack = SourceLocStack(),
6161
file: String = #file, line: UInt = #line,
62-
body: () -> R
62+
invoking body: () -> R
6363
) -> R {
6464
let expected = self[t].advanced(by: 1)
6565
let r = body()
@@ -77,7 +77,7 @@ extension TypeIndexed where Value : Equatable {
7777
showFrame: Bool = true,
7878
stackTrace: SourceLocStack = SourceLocStack(),
7979
file: String = #file, line: UInt = #line,
80-
body: () -> R
80+
invoking body: () -> R
8181
) -> R {
8282
let expected = self[t]
8383
let r = body()

stdlib/private/StdlibUnittestFoundationExtras/StdlibUnittestFoundationExtras.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ public func withOverriddenLocaleCurrentLocale<Result>(
6565
/// return-autoreleased optimization.)
6666
@inline(never)
6767
public func autoreleasepoolIfUnoptimizedReturnAutoreleased(
68-
_ body: @noescape () -> Void
68+
invoking body: @noescape () -> Void
6969
) {
7070
#if arch(i386) && (os(iOS) || os(watchOS))
7171
autoreleasepool(body)

stdlib/public/SDK/Foundation/NSStringAPI.swift

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,8 @@ extension Optional {
7676
/// `body` is complicated than that results in unnecessarily repeated code.
7777
internal func _withNilOrAddress<NSType : AnyObject, ResultType>(
7878
of object: inout NSType?,
79-
body: @noescape (AutoreleasingUnsafeMutablePointer<NSType?>?) -> ResultType
79+
_ body:
80+
@noescape (AutoreleasingUnsafeMutablePointer<NSType?>?) -> ResultType
8081
) -> ResultType {
8182
return self == nil ? body(nil) : body(&object)
8283
}
@@ -495,7 +496,9 @@ extension String {
495496
// enumerateLinesUsing:(void (^)(NSString *line, BOOL *stop))block
496497

497498
/// Enumerates all the lines in a string.
498-
public func enumerateLines(_ body: (line: String, stop: inout Bool) -> ()) {
499+
public func enumerateLines(
500+
invoking body: (line: String, stop: inout Bool) -> ()
501+
) {
499502
_ns.enumerateLines {
500503
(line: String, stop: UnsafeMutablePointer<ObjCBool>)
501504
in
@@ -526,7 +529,7 @@ extension String {
526529
scheme tagScheme: String,
527530
options opts: NSLinguisticTagger.Options = [],
528531
orthography: NSOrthography? = nil,
529-
_ body:
532+
invoking body:
530533
(String, Range<Index>, Range<Index>, inout Bool) -> ()
531534
) {
532535
_ns.enumerateLinguisticTags(

stdlib/public/SDK/ObjectiveC/ObjectiveC.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ func __pushAutoreleasePool() -> OpaquePointer
187187
func __popAutoreleasePool(_ pool: OpaquePointer)
188188

189189
public func autoreleasepool<Result>(
190-
_ body: @noescape () throws -> Result
190+
invoking body: @noescape () throws -> Result
191191
) rethrows -> Result {
192192
let pool = __pushAutoreleasePool()
193193
defer {

stdlib/public/core/LifetimeManager.swift

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,19 +13,19 @@
1313
/// Evaluate `f()` and return its result, ensuring that `x` is not
1414
/// destroyed before f returns.
1515
public func withExtendedLifetime<T, Result>(
16-
_ x: T, _ f: @noescape () throws -> Result
16+
_ x: T, _ body: @noescape () throws -> Result
1717
) rethrows -> Result {
1818
defer { _fixLifetime(x) }
19-
return try f()
19+
return try body()
2020
}
2121

2222
/// Evaluate `f(x)` and return its result, ensuring that `x` is not
2323
/// destroyed before f returns.
2424
public func withExtendedLifetime<T, Result>(
25-
_ x: T, _ f: @noescape (T) throws -> Result
25+
_ x: T, _ body: @noescape (T) throws -> Result
2626
) rethrows -> Result {
2727
defer { _fixLifetime(x) }
28-
return try f(x)
28+
return try body(x)
2929
}
3030

3131
extension String {
@@ -41,10 +41,10 @@ extension String {
4141
/// it is used as the return value of the `withCString(_:)` method.
4242
/// - Returns: The return value of the `f` closure, if any.
4343
public func withCString<Result>(
44-
_ f: @noescape (UnsafePointer<Int8>) throws -> Result
44+
_ body: @noescape (UnsafePointer<Int8>) throws -> Result
4545
) rethrows -> Result {
4646
return try self.nulTerminatedUTF8.withUnsafeBufferPointer {
47-
try f(UnsafePointer($0.baseAddress!))
47+
try body(UnsafePointer($0.baseAddress!))
4848
}
4949
}
5050
}

stdlib/public/core/StaticString.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ public struct StaticString
124124
/// `withUTF8Buffer(invoke:)` method.
125125
/// - Returns: The return value of the `body` closure, if any.
126126
public func withUTF8Buffer<R>(
127-
invoke body: @noescape (UnsafeBufferPointer<UInt8>) -> R) -> R {
127+
_ body: @noescape (UnsafeBufferPointer<UInt8>) -> R) -> R {
128128
if hasPointerRepresentation {
129129
return body(UnsafeBufferPointer(
130130
start: utf8Start, count: Int(utf8CodeUnitCount)))

stdlib/public/core/StringCharacterView.swift

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,9 @@ extension String {
103103
/// - Parameter body: A closure that takes a character view as its argument.
104104
/// - Returns: The return value of the `body` closure, if any, is the return
105105
/// value of this method.
106-
public mutating func withMutableCharacters<R>(_ body: (inout CharacterView) -> R) -> R {
106+
public mutating func withMutableCharacters<R>(
107+
_ body: (inout CharacterView) -> R
108+
) -> R {
107109
// Naively mutating self.characters forces multiple references to
108110
// exist at the point of mutation. Instead, temporarily move the
109111
// core of this string into a CharacterView.

stdlib/public/core/Unmanaged.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -183,10 +183,10 @@ public struct Unmanaged<Instance : AnyObject> {
183183
/// }
184184
/// }
185185
public func _withUnsafeGuaranteedRef<Result>(
186-
_ closure: @noescape (Instance) throws -> Result
186+
_ body: @noescape (Instance) throws -> Result
187187
) rethrows -> Result {
188188
let (guaranteedInstance, token) = Builtin.unsafeGuaranteed(_value)
189-
let result = try closure(guaranteedInstance)
189+
let result = try body(guaranteedInstance)
190190
Builtin.unsafeGuaranteedEnd(token)
191191
return result
192192
}

stdlib/public/core/VarArgs.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,18 +65,18 @@ let _x86_64RegisterSaveWords = _x86_64CountGPRegisters + _x86_64CountSSERegister
6565

6666
/// Invoke `body` with a C `va_list` argument derived from `args`.
6767
public func withVaList<R>(_ args: [CVarArg],
68-
invoke body: @noescape (CVaListPointer) -> R) -> R {
68+
_ body: @noescape (CVaListPointer) -> R) -> R {
6969
let builder = _VaListBuilder()
7070
for a in args {
7171
builder.append(a)
7272
}
73-
return _withVaList(builder, invoke: body)
73+
return _withVaList(builder, body)
7474
}
7575

7676
/// Invoke `body` with a C `va_list` argument derived from `builder`.
7777
internal func _withVaList<R>(
7878
_ builder: _VaListBuilder,
79-
invoke body: @noescape (CVaListPointer) -> R
79+
_ body: @noescape (CVaListPointer) -> R
8080
) -> R {
8181
let result = body(builder.va_list())
8282
_fixLifetime(builder)

test/1_stdlib/ArrayTraps.swift.gyb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ ArrayTraps.test("unsafeLength")
138138

139139
expectCrashLater()
140140

141-
a.withUnsafeBufferPointer {
141+
_ = a.withUnsafeBufferPointer {
142142
UnsafeBufferPointer(start: $0.baseAddress, count: -1)
143143
}
144144
}

test/IDE/complete_literal.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
}
3939

4040
// LITERAL4: Begin completions
41-
// LITERAL4-DAG: Decl[InstanceMethod]/CurrNominal: withCString({#(f): (UnsafePointer<Int8>) throws -> Result##(UnsafePointer<Int8>) throws -> Result#})[' rethrows'][#Result#]; name=withCString(f: (UnsafePointer<Int8>) throws -> Result) rethrows{{$}}
41+
// LITERAL4-DAG: Decl[InstanceMethod]/CurrNominal: withCString({#(body): (UnsafePointer<Int8>) throws -> Result##(UnsafePointer<Int8>) throws -> Result#})[' rethrows'][#Result#]; name=withCString(body: (UnsafePointer<Int8>) throws -> Result) rethrows{{$}}
4242

4343
// FIXME: we should show the qualified String.Index type.
4444
// rdar://problem/20788802

test/Prototypes/Result.swift

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,9 @@ public func ?? <T> (
7979
}
8080

8181
/// Translate the execution of a throwing closure into a Result
82-
func catchResult<Success>(body: () throws -> Success) -> Result<Success> {
82+
func catchResult<Success>(
83+
invoking body: () throws -> Success
84+
) -> Result<Success> {
8385
do {
8486
return try .Success(body())
8587
}

0 commit comments

Comments
 (0)