Skip to content

Commit 69ca588

Browse files
committed
Merge pull request #2601 from apple/stdlib-remove-warn-unused-result
stdlib: remove most uses of @warn_unused_result, which does nothing now
2 parents 455aa05 + d591f9c commit 69ca588

File tree

102 files changed

+1
-1185
lines changed

Some content is hidden

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

102 files changed

+1
-1185
lines changed

stdlib/private/StdlibCollectionUnittest/LoggingWrappers.swift.gyb

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -221,15 +221,13 @@ public struct ${Self}<
221221
return base.underestimatedCount
222222
}
223223

224-
@warn_unused_result
225224
public func map<T>(
226225
_ transform: @noescape (Base.Iterator.Element) throws -> T
227226
) rethrows -> [T] {
228227
Log.map[selfType] += 1
229228
return try base.map(transform)
230229
}
231230

232-
@warn_unused_result
233231
public func filter(
234232
_ includeElement: @noescape (Base.Iterator.Element) throws -> Bool
235233
) rethrows -> [Base.Iterator.Element] {
@@ -367,7 +365,6 @@ public struct ${Self}<
367365
base._failEarlyRangeCheck(range, bounds: bounds)
368366
}
369367

370-
@warn_unused_result
371368
public func index(after i: Index) -> Index {
372369
Log.successor[selfType] += 1
373370
return base.index(after: i)
@@ -424,21 +421,18 @@ public struct ${Self}<
424421
return base.first
425422
}
426423

427-
@warn_unused_result
428424
public func index(_ i: Index, offsetBy n: IndexDistance) -> Index {
429425
Log.advance[selfType] += 1
430426
return base.index(i, offsetBy: n)
431427
}
432428

433-
@warn_unused_result
434429
public func index(
435430
_ i: Index, offsetBy n: IndexDistance, limitedBy limit: Index
436431
) -> Index? {
437432
Log.advanceLimit[selfType] += 1
438433
return base.index(i, offsetBy: n, limitedBy: limit)
439434
}
440435

441-
@warn_unused_result
442436
public func distance(from start: Index, to end: Index) -> IndexDistance {
443437
Log.distance[selfType] += 1
444438
return base.distance(from: start, to: end)
@@ -555,7 +549,6 @@ public struct ${Self}<
555549
}
556550
% end
557551
% if Traversal in ['Bidirectional', 'RandomAccess']:
558-
@warn_unused_result
559552
public func index(before i: Index) -> Index {
560553
BidirectionalCollectionLog.predecessor[selfType] += 1
561554
return base.index(before: i)

stdlib/private/StdlibCollectionUnittest/MinimalCollections.swift.gyb

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,6 @@ public struct MinimalSequence<T> : Sequence, CustomDebugStringConvertible {
117117

118118
public let timesMakeIteratorCalled = ResettableValue(0)
119119

120-
@warn_unused_result
121120
public func makeIterator() -> MinimalIterator<T> {
122121
timesMakeIteratorCalled.value += 1
123122
return MinimalIterator(_sharedState)
@@ -480,14 +479,12 @@ public func < (lhs: ${Index}, rhs: ${Index}) -> Bool {
480479
extension MinimalStrideableIndex : Strideable {
481480
public typealias Stride = Int
482481

483-
@warn_unused_result
484482
public func distance(to other: MinimalStrideableIndex) -> Int {
485483
timesDistanceCalled.value += 1
486484
_expectCompatibleIndices(self, other)
487485
return other.position - position
488486
}
489487

490-
@warn_unused_result
491488
public func advanced(by n: Int) -> MinimalStrideableIndex {
492489
timesAdvancedCalled.value += 1
493490
return MinimalStrideableIndex(
@@ -652,22 +649,19 @@ public struct ${Self}<T> : ${SelfProtocols} {
652649
in: bounds.lowerBound.position..<bounds.upperBound.position)
653650
}
654651

655-
@warn_unused_result
656652
public func index(after i: ${Index}) -> ${Index} {
657653
_failEarlyRangeCheck(i, bounds: startIndex..<endIndex)
658654
return _uncheckedIndex(forPosition: i.position + 1)
659655
}
660656

661657
% if Traversal in ['Bidirectional', 'RandomAccess']:
662-
@warn_unused_result
663658
public func index(before i: ${Index}) -> ${Index} {
664659
// FIXME: swift-3-indexing-model: perform a range check and use
665660
// return _uncheckedIndex(forPosition: i.position - 1)
666661
return _index(forPosition: i.position - 1)
667662
}
668663
% end
669664

670-
@warn_unused_result
671665
public func distance(from start: ${Index}, to end: ${Index})
672666
-> IndexDistance {
673667
% if Traversal == 'Forward':
@@ -684,7 +678,6 @@ public struct ${Self}<T> : ${SelfProtocols} {
684678
return end.position - start.position
685679
}
686680

687-
@warn_unused_result
688681
public func index(_ i: Index, offsetBy n: IndexDistance) -> Index {
689682
% if Traversal == 'Forward':
690683
_precondition(n >= 0,
@@ -851,7 +844,6 @@ public struct DefaultedSequence<Element> : Sequence {
851844
elements: elements, underestimatedCount: underestimatedCount))
852845
}
853846

854-
@warn_unused_result
855847
public func makeIterator() -> MinimalIterator<Element> {
856848
return base.makeIterator()
857849
}
@@ -921,7 +913,6 @@ public struct ${Self}<Element> : ${SelfProtocols} {
921913

922914
public let timesMakeIteratorCalled = ResettableValue(0)
923915

924-
@warn_unused_result
925916
public func makeIterator() -> MinimalIterator<Element> {
926917
timesMakeIteratorCalled.value += 1
927918
return base.makeIterator()
@@ -931,7 +922,6 @@ public struct ${Self}<Element> : ${SelfProtocols} {
931922

932923
public let timesSuccessorCalled = ResettableValue(0)
933924

934-
@warn_unused_result
935925
public func index(after i: ${Index}) -> ${Index} {
936926
timesSuccessorCalled.value += 1
937927
return base.index(after: i)
@@ -940,21 +930,18 @@ public struct ${Self}<Element> : ${SelfProtocols} {
940930
% if Traversal in ['Bidirectional', 'RandomAccess']:
941931
public let timesPredecessorCalled = ResettableValue(0)
942932

943-
@warn_unused_result
944933
public func index(before i: ${Index}) -> ${Index} {
945934
timesPredecessorCalled.value += 1
946935
return base.index(before: i)
947936
}
948937
% end
949938

950939
% if Traversal == 'RandomAccess':
951-
@warn_unused_result
952940
public func distance(from start: ${Index}, to end: ${Index})
953941
-> IndexDistance {
954942
return base.distance(from: start, to: end)
955943
}
956944

957-
@warn_unused_result
958945
public func index(_ i: Index, offsetBy n: IndexDistance) -> Index {
959946
return base.index(i, offsetBy: n)
960947
}
@@ -1062,7 +1049,6 @@ public struct Defaulted${Traversal}RangeReplaceableSlice<Element>
10621049
base: Base(elements: elements))
10631050
}
10641051

1065-
@warn_unused_result
10661052
public func makeIterator() -> MinimalIterator<Element> {
10671053
return MinimalIterator(Array(self))
10681054
}

stdlib/private/StdlibUnittest/LifetimeTracked.swift

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,12 +42,10 @@ public final class LifetimeTracked {
4242
}
4343

4444
extension LifetimeTracked : Strideable {
45-
@warn_unused_result
4645
public func distance(to other: LifetimeTracked) -> Int {
4746
return self.value.distance(to: other.value)
4847
}
4948

50-
@warn_unused_result
5149
public func advanced(by n: Int) -> LifetimeTracked {
5250
return LifetimeTracked(self.value.advanced(by: n))
5351
}

stdlib/private/StdlibUnittest/MinimalTypes.swift.gyb

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -173,13 +173,11 @@ public struct MinimalStrideableValue : Equatable, Comparable, Strideable {
173173

174174
public typealias Stride = Int
175175

176-
@warn_unused_result
177176
public func distance(to other: MinimalStrideableValue) -> Stride {
178177
MinimalStrideableValue.timesDistanceWasCalled.value += 1
179178
return other.value - self.value
180179
}
181180

182-
@warn_unused_result
183181
public func advanced(by n: Stride) -> MinimalStrideableValue {
184182
MinimalStrideableValue.timesAdvancedWasCalled.value += 1
185183
return MinimalStrideableValue(self.value + n, identity: self.identity)

stdlib/private/StdlibUnittest/StringConvertible.swift.gyb

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,12 +70,10 @@ public struct CustomPrintableValue
7070

7171
public typealias Stride = Int
7272

73-
@warn_unused_result
7473
public func distance(to other: CustomPrintableValue) -> Stride {
7574
return other.value - self.value
7675
}
7776

78-
@warn_unused_result
7977
public func advanced(by n: Stride) -> CustomPrintableValue {
8078
return CustomPrintableValue(self.value + n, identity: self.identity)
8179
}

stdlib/public/Platform/Platform.swift

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -56,17 +56,14 @@ extension DarwinBoolean : CustomStringConvertible {
5656
}
5757

5858
extension DarwinBoolean : Equatable {}
59-
@warn_unused_result
6059
public func ==(lhs: DarwinBoolean, rhs: DarwinBoolean) -> Bool {
6160
return lhs.boolValue == rhs.boolValue
6261
}
6362

64-
@warn_unused_result
6563
public // COMPILER_INTRINSIC
6664
func _convertBoolToDarwinBoolean(_ x: Bool) -> DarwinBoolean {
6765
return DarwinBoolean(x)
6866
}
69-
@warn_unused_result
7067
public // COMPILER_INTRINSIC
7168
func _convertDarwinBooleanToBool(_ x: DarwinBoolean) -> Bool {
7269
return Bool(x)
@@ -76,7 +73,6 @@ func _convertDarwinBooleanToBool(_ x: DarwinBoolean) -> Bool {
7673
// rdar://problem/19418937, so here are some @_transparent overloads
7774
// for DarwinBoolean.
7875
@_transparent
79-
@warn_unused_result
8076
public func && <T : Boolean>(
8177
lhs: T,
8278
rhs: @autoclosure () -> DarwinBoolean
@@ -85,7 +81,6 @@ public func && <T : Boolean>(
8581
}
8682

8783
@_transparent
88-
@warn_unused_result
8984
public func || <T : Boolean>(
9085
lhs: T,
9186
rhs: @autoclosure () -> DarwinBoolean
@@ -160,15 +155,13 @@ public var stderr : UnsafeMutablePointer<FILE> {
160155
// fcntl.h
161156
//===----------------------------------------------------------------------===//
162157

163-
@warn_unused_result
164158
@_silgen_name("_swift_Platform_open")
165159
func _swift_Platform_open(
166160
_ path: UnsafePointer<CChar>,
167161
_ oflag: CInt,
168162
_ mode: mode_t
169163
) -> CInt
170164

171-
@warn_unused_result
172165
@_silgen_name("_swift_Platform_openat")
173166
func _swift_Platform_openat(
174167
_ fd: CInt,
@@ -177,15 +170,13 @@ func _swift_Platform_openat(
177170
_ mode: mode_t
178171
) -> CInt
179172

180-
@warn_unused_result
181173
public func open(
182174
_ path: UnsafePointer<CChar>,
183175
_ oflag: CInt
184176
) -> CInt {
185177
return _swift_Platform_open(path, oflag, 0)
186178
}
187179

188-
@warn_unused_result
189180
public func open(
190181
_ path: UnsafePointer<CChar>,
191182
_ oflag: CInt,
@@ -194,7 +185,6 @@ public func open(
194185
return _swift_Platform_open(path, oflag, mode)
195186
}
196187

197-
@warn_unused_result
198188
public func openat(
199189
_ fd: CInt,
200190
_ path: UnsafePointer<CChar>,
@@ -203,7 +193,6 @@ public func openat(
203193
return _swift_Platform_openat(fd, path, oflag, 0)
204194
}
205195

206-
@warn_unused_result
207196
public func openat(
208197
_ fd: CInt,
209198
_ path: UnsafePointer<CChar>,
@@ -213,31 +202,27 @@ public func openat(
213202
return _swift_Platform_openat(fd, path, oflag, mode)
214203
}
215204

216-
@warn_unused_result
217205
@_silgen_name("_swift_Platform_fcntl")
218206
internal func _swift_Platform_fcntl(
219207
_ fd: CInt,
220208
_ cmd: CInt,
221209
_ value: CInt
222210
) -> CInt
223211

224-
@warn_unused_result
225212
@_silgen_name("_swift_Platform_fcntlPtr")
226213
internal func _swift_Platform_fcntlPtr(
227214
_ fd: CInt,
228215
_ cmd: CInt,
229216
_ ptr: UnsafeMutablePointer<Void>
230217
) -> CInt
231218

232-
@warn_unused_result
233219
public func fcntl(
234220
_ fd: CInt,
235221
_ cmd: CInt
236222
) -> CInt {
237223
return _swift_Platform_fcntl(fd, cmd, 0)
238224
}
239225

240-
@warn_unused_result
241226
public func fcntl(
242227
_ fd: CInt,
243228
_ cmd: CInt,
@@ -246,7 +231,6 @@ public func fcntl(
246231
return _swift_Platform_fcntl(fd, cmd, value)
247232
}
248233

249-
@warn_unused_result
250234
public func fcntl(
251235
_ fd: CInt,
252236
_ cmd: CInt,
@@ -358,14 +342,12 @@ public var SEM_FAILED: UnsafeMutablePointer<sem_t>? {
358342
#endif
359343
}
360344

361-
@warn_unused_result
362345
@_silgen_name("_swift_Platform_sem_open2")
363346
internal func _swift_Platform_sem_open2(
364347
_ name: UnsafePointer<CChar>,
365348
_ oflag: CInt
366349
) -> UnsafeMutablePointer<sem_t>?
367350

368-
@warn_unused_result
369351
@_silgen_name("_swift_Platform_sem_open4")
370352
internal func _swift_Platform_sem_open4(
371353
_ name: UnsafePointer<CChar>,
@@ -374,15 +356,13 @@ internal func _swift_Platform_sem_open4(
374356
_ value: CUnsignedInt
375357
) -> UnsafeMutablePointer<sem_t>?
376358

377-
@warn_unused_result
378359
public func sem_open(
379360
_ name: UnsafePointer<CChar>,
380361
_ oflag: CInt
381362
) -> UnsafeMutablePointer<sem_t>? {
382363
return _swift_Platform_sem_open2(name, oflag)
383364
}
384365

385-
@warn_unused_result
386366
public func sem_open(
387367
_ name: UnsafePointer<CChar>,
388368
_ oflag: CInt,
@@ -398,7 +378,6 @@ public func sem_open(
398378

399379
// FreeBSD defines extern char **environ differently than Linux.
400380
#if os(FreeBSD)
401-
@warn_unused_result
402381
@_silgen_name("_swift_FreeBSD_getEnv")
403382
func _swift_FreeBSD_getEnv(
404383
) -> UnsafeMutablePointer<UnsafeMutablePointer<UnsafeMutablePointer<CChar>?>>

0 commit comments

Comments
 (0)