mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
Updated stdlib to use @discardableResult and _ = .
This commit is contained in:
@@ -48,7 +48,7 @@ public struct _stdlib_ShardedAtomicCounter {
|
||||
|
||||
public func add(_ operand: Int, randomInt: Int) {
|
||||
let shardIndex = Int(UInt(bitPattern: randomInt) % UInt(self._shardsCount))
|
||||
_swift_stdlib_atomicFetchAddInt(
|
||||
_ = _swift_stdlib_atomicFetchAddInt(
|
||||
object: self._shardsPtr + shardIndex, operand: operand)
|
||||
}
|
||||
|
||||
|
||||
@@ -125,7 +125,10 @@ public class _stdlib_Barrier {
|
||||
}
|
||||
|
||||
deinit {
|
||||
_stdlib_pthread_barrier_destroy(_pthreadBarrierPtr)
|
||||
let ret = _stdlib_pthread_barrier_destroy(_pthreadBarrierPtr)
|
||||
if ret != 0 {
|
||||
fatalError("_stdlib_pthread_barrier_destroy() failed")
|
||||
}
|
||||
}
|
||||
|
||||
public func wait() {
|
||||
|
||||
@@ -465,24 +465,28 @@ public func /=(lhs: inout CGFloat, rhs: CGFloat) {
|
||||
|
||||
@_transparent
|
||||
@available(*, unavailable, message: "use += 1")
|
||||
@discardableResult
|
||||
public prefix func ++(rhs: inout CGFloat) -> CGFloat {
|
||||
fatalError("++ is not available")
|
||||
}
|
||||
|
||||
@_transparent
|
||||
@available(*, unavailable, message: "use -= 1")
|
||||
@discardableResult
|
||||
public prefix func --(rhs: inout CGFloat) -> CGFloat {
|
||||
fatalError("-- is not available")
|
||||
}
|
||||
|
||||
@_transparent
|
||||
@available(*, unavailable, message: "use += 1")
|
||||
@discardableResult
|
||||
public postfix func ++(lhs: inout CGFloat) -> CGFloat {
|
||||
fatalError("++ is not available")
|
||||
}
|
||||
|
||||
@_transparent
|
||||
@available(*, unavailable, message: "use -= 1")
|
||||
@discardableResult
|
||||
public postfix func --(lhs: inout CGFloat) -> CGFloat {
|
||||
fatalError("-- is not available")
|
||||
}
|
||||
|
||||
@@ -145,6 +145,7 @@ struct _Prespecialize {
|
||||
}
|
||||
|
||||
// Force pre-specialization of Range<Int>
|
||||
@discardableResult
|
||||
static internal func _specializeRanges() -> Int {
|
||||
let a = [Int](repeating: 1, count: 10)
|
||||
var count = 0
|
||||
|
||||
@@ -202,6 +202,7 @@ extension _ArrayBuffer {
|
||||
/// Copy the elements in `bounds` from this buffer into uninitialized
|
||||
/// memory starting at `target`. Return a pointer past-the-end of the
|
||||
/// just-initialized memory.
|
||||
@discardableResult
|
||||
public func _copyContents(
|
||||
subRange bounds: Range<Int>,
|
||||
initializing target: UnsafeMutablePointer<Element>
|
||||
|
||||
@@ -29,6 +29,7 @@ public protocol _ArrayBufferProtocol
|
||||
/// Copy the elements in `bounds` from this buffer into uninitialized
|
||||
/// memory starting at `target`. Return a pointer past-the-end of the
|
||||
/// just-initialized memory.
|
||||
@discardableResult
|
||||
func _copyContents(
|
||||
subRange bounds: Range<Int>,
|
||||
initializing target: UnsafeMutablePointer<Element>
|
||||
|
||||
@@ -793,7 +793,7 @@ ${SubscriptDocComment}
|
||||
% if Self != 'Array':
|
||||
_buffer._checkValidSubscript(index)
|
||||
% else:
|
||||
_checkSubscript(index, wasNativeTypeChecked: true)
|
||||
_ = _checkSubscript(index, wasNativeTypeChecked: true)
|
||||
% end
|
||||
}
|
||||
|
||||
|
||||
@@ -61,6 +61,7 @@ public protocol _ObjectiveCBridgeable {
|
||||
/// information is provided for the convenience of the runtime's `dynamic_cast`
|
||||
/// implementation, so that it need not look into the optional representation
|
||||
/// to determine success.
|
||||
@discardableResult
|
||||
static func _conditionallyBridgeFromObjectiveC(
|
||||
_ source: _ObjectiveCType,
|
||||
result: inout Self?
|
||||
@@ -255,7 +256,7 @@ public func _conditionallyBridgeFromObjectiveC<T>(
|
||||
}
|
||||
|
||||
var result: T?
|
||||
_bridgeNonVerbatimFromObjectiveCConditional(x, T.self, &result)
|
||||
_ = _bridgeNonVerbatimFromObjectiveCConditional(x, T.self, &result)
|
||||
return result
|
||||
}
|
||||
|
||||
|
||||
@@ -219,7 +219,7 @@ public struct Character :
|
||||
u16 = u16 << 16
|
||||
u16 = u16 | UInt64($0)
|
||||
}
|
||||
transcode(
|
||||
_ = transcode(
|
||||
_SmallUTF8(u8).makeIterator(),
|
||||
from: UTF8.self, to: UTF16.self,
|
||||
stoppingOnError: false,
|
||||
|
||||
@@ -1301,7 +1301,7 @@ extension Collection {
|
||||
}
|
||||
|
||||
if maxSplits == 0 || isEmpty {
|
||||
appendSubsequence(end: endIndex)
|
||||
_ = appendSubsequence(end: endIndex)
|
||||
return result
|
||||
}
|
||||
|
||||
@@ -1426,6 +1426,7 @@ extension Collection where SubSequence == Self {
|
||||
extension Sequence
|
||||
where Self : _ArrayProtocol, Self.Element == Self.Iterator.Element {
|
||||
// A fast implementation for when you are backed by a contiguous array.
|
||||
@discardableResult
|
||||
public func _copyContents(
|
||||
initializing ptr: UnsafeMutablePointer<Iterator.Element>
|
||||
) -> UnsafeMutablePointer<Iterator.Element> {
|
||||
|
||||
@@ -384,6 +384,7 @@ public struct _ContiguousArrayBuffer<Element> : _ArrayBufferProtocol {
|
||||
/// Copy the elements in `bounds` from this buffer into uninitialized
|
||||
/// memory starting at `target`. Return a pointer past-the-end of the
|
||||
/// just-initialized memory.
|
||||
@discardableResult
|
||||
public func _copyContents(
|
||||
subRange bounds: Range<Int>,
|
||||
initializing target: UnsafeMutablePointer<Element>
|
||||
|
||||
@@ -609,6 +609,7 @@ extension ${Self} {
|
||||
|
||||
@_transparent
|
||||
@available(*, unavailable, message: "it has been removed in Swift 3")
|
||||
@discardableResult
|
||||
public prefix func ++ (x: inout ${Self}) -> ${Self} {
|
||||
x = x + 1
|
||||
return x
|
||||
@@ -616,6 +617,7 @@ public prefix func ++ (x: inout ${Self}) -> ${Self} {
|
||||
|
||||
@_transparent
|
||||
@available(*, unavailable, message: "it has been removed in Swift 3")
|
||||
@discardableResult
|
||||
public postfix func ++ (x: inout ${Self}) -> ${Self} {
|
||||
let ret = x
|
||||
x = x + 1
|
||||
@@ -624,6 +626,7 @@ public postfix func ++ (x: inout ${Self}) -> ${Self} {
|
||||
|
||||
@_transparent
|
||||
@available(*, unavailable, message: "it has been removed in Swift 3")
|
||||
@discardableResult
|
||||
public prefix func -- (x: inout ${Self}) -> ${Self} {
|
||||
x = x - 1
|
||||
return x
|
||||
@@ -631,6 +634,7 @@ public prefix func -- (x: inout ${Self}) -> ${Self} {
|
||||
|
||||
@_transparent
|
||||
@available(*, unavailable, message: "it has been removed in Swift 3")
|
||||
@discardableResult
|
||||
public postfix func -- (x: inout ${Self}) -> ${Self} {
|
||||
let ret = x
|
||||
x = x - 1
|
||||
|
||||
@@ -872,21 +872,25 @@ public func %=(lhs: inout ${Self}, rhs: ${Self}) {
|
||||
|
||||
@_transparent
|
||||
@available(*, unavailable, message: "use += 1")
|
||||
@discardableResult
|
||||
public prefix func ++(rhs: inout ${Self}) -> ${Self} {
|
||||
fatalError("++ is not available")
|
||||
}
|
||||
@_transparent
|
||||
@available(*, unavailable, message: "use -= 1")
|
||||
@discardableResult
|
||||
public prefix func --(rhs: inout ${Self}) -> ${Self} {
|
||||
fatalError("-- is not available")
|
||||
}
|
||||
@_transparent
|
||||
@available(*, unavailable, message: "use += 1")
|
||||
@discardableResult
|
||||
public postfix func ++(lhs: inout ${Self}) -> ${Self} {
|
||||
fatalError("++ is not available")
|
||||
}
|
||||
@_transparent
|
||||
@available(*, unavailable, message: "use -= 1")
|
||||
@discardableResult
|
||||
public postfix func --(lhs: inout ${Self}) -> ${Self} {
|
||||
fatalError("-- is not available")
|
||||
}
|
||||
|
||||
@@ -579,6 +579,7 @@ public struct Set<Element : Hashable> :
|
||||
/// distinguishable from `newMember`, e.g. via `===`).
|
||||
///
|
||||
/// - Postcondition: `self.contains(newMember)`.
|
||||
@discardableResult
|
||||
public mutating func insert(
|
||||
_ newMember: Element
|
||||
) -> (inserted: Bool, memberAfterInsert: Element) {
|
||||
@@ -592,6 +593,7 @@ public struct Set<Element : Hashable> :
|
||||
/// `===`), or `nil` if no such element existed.
|
||||
///
|
||||
/// - Postcondition: `self.contains(newMember)`
|
||||
@discardableResult
|
||||
public mutating func update(with newMember: Element) -> Element? {
|
||||
return _variantStorage.updateValue(newMember, forKey: newMember)
|
||||
}
|
||||
@@ -610,6 +612,7 @@ public struct Set<Element : Hashable> :
|
||||
/// - Parameter member: The element to remove from the set.
|
||||
/// - Returns: The value of the `member` parameter if it was a member of the
|
||||
/// set; otherwise, `nil`.
|
||||
@discardableResult
|
||||
public mutating func remove(_ member: Element) -> Element? {
|
||||
return _variantStorage.removeValue(forKey: member)
|
||||
}
|
||||
|
||||
@@ -14,21 +14,25 @@
|
||||
public protocol _Incrementable : Equatable {}
|
||||
|
||||
@available(*, unavailable, message: "Use \'-= 1\' or call collection.prior(Index)")
|
||||
@discardableResult
|
||||
public prefix func -- <T : _Incrementable> (i: inout T) -> T {
|
||||
Builtin.unreachable()
|
||||
}
|
||||
|
||||
@available(*, unavailable, message: "Use \'-= 1\' or call collection.prior(Index)")
|
||||
@discardableResult
|
||||
public postfix func -- <T : _Incrementable> (i: inout T) -> T {
|
||||
Builtin.unreachable()
|
||||
}
|
||||
|
||||
@available(*, unavailable, message: "Use \'+= 1\' or call 'collection.index(after: Index)")
|
||||
@discardableResult
|
||||
public prefix func ++ <T : _Incrementable> (i: inout T) -> T {
|
||||
Builtin.unreachable()
|
||||
}
|
||||
|
||||
@available(*, unavailable, message: "Use \'+= 1\' or call 'collection.index(after: Index)")
|
||||
@discardableResult
|
||||
public postfix func ++ <T : _Incrementable> (i: inout T) -> T {
|
||||
Builtin.unreachable()
|
||||
}
|
||||
|
||||
@@ -94,6 +94,7 @@ extension ${Self} : Sequence {
|
||||
return _base._copyToNativeArrayBuffer()
|
||||
}
|
||||
|
||||
@discardableResult
|
||||
public func _copyContents(
|
||||
initializing ptr: UnsafeMutablePointer<Base.Iterator.Element>
|
||||
) -> UnsafeMutablePointer<Base.Iterator.Element> {
|
||||
|
||||
@@ -288,6 +288,7 @@ extension OptionSet where Element == Self {
|
||||
/// non-empty. Returns `nil` otherwise.
|
||||
///
|
||||
/// - Postcondition: `self.contains(e)`
|
||||
@discardableResult
|
||||
public mutating func update(with e: Element) -> Element? {
|
||||
let r = self.intersection(e)
|
||||
self.formUnion(e)
|
||||
|
||||
@@ -150,6 +150,7 @@ func _getSummary<T>(_ out: UnsafeMutablePointer<String>, x: T) {
|
||||
internal func _reflect<T>(_ x: T) -> _Mirror
|
||||
|
||||
/// Dump an object's contents using its mirror to the specified output stream.
|
||||
@discardableResult
|
||||
public func dump<T, TargetStream : OutputStream>(
|
||||
_ value: T,
|
||||
to target: inout TargetStream,
|
||||
@@ -174,6 +175,7 @@ public func dump<T, TargetStream : OutputStream>(
|
||||
}
|
||||
|
||||
/// Dump an object's contents using its mirror to standard output.
|
||||
@discardableResult
|
||||
public func dump<T>(
|
||||
_ value: T,
|
||||
name: String? = nil,
|
||||
|
||||
@@ -78,6 +78,7 @@ func _stdlib_atomicCompareExchangeStrongPtr<T>(
|
||||
}
|
||||
|
||||
@_transparent
|
||||
@discardableResult
|
||||
public // @testable
|
||||
func _stdlib_atomicInitializeARCRef(
|
||||
object target: UnsafeMutablePointer<AnyObject?>,
|
||||
@@ -518,7 +519,7 @@ class _SwiftNativeNSEnumerator {}
|
||||
@objc dynamic func initializeReturnAutoreleased() {
|
||||
// On x86_64 it is sufficient to perform one cycle of return-autoreleased
|
||||
// call sequence in order to initialize all required PLT entries.
|
||||
self.returnsAutoreleased(self)
|
||||
_ = self.returnsAutoreleased(self)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -581,6 +581,7 @@ public protocol Sequence {
|
||||
|
||||
/// Copy a Sequence into an array, returning one past the last
|
||||
/// element initialized.
|
||||
@discardableResult
|
||||
func _copyContents(initializing ptr: UnsafeMutablePointer<Iterator.Element>)
|
||||
-> UnsafeMutablePointer<Iterator.Element>
|
||||
}
|
||||
@@ -861,6 +862,7 @@ extension Sequence {
|
||||
var result: [AnySequence<Iterator.Element>] = []
|
||||
var subSequence: [Iterator.Element] = []
|
||||
|
||||
@discardableResult
|
||||
func appendSubsequence() -> Bool {
|
||||
if subSequence.isEmpty && omittingEmptySubsequences {
|
||||
return false
|
||||
@@ -1144,6 +1146,7 @@ extension Sequence {
|
||||
}
|
||||
|
||||
extension Sequence {
|
||||
@discardableResult
|
||||
public func _copyContents(
|
||||
initializing ptr: UnsafeMutablePointer<Iterator.Element>
|
||||
) -> UnsafeMutablePointer<Iterator.Element> {
|
||||
|
||||
@@ -119,6 +119,7 @@ extension Sequence
|
||||
|
||||
/// Copy a Sequence into an array, returning one past the last
|
||||
/// element initialized.
|
||||
@discardableResult
|
||||
public func _copyContents(
|
||||
initializing ptr: UnsafeMutablePointer<Base.Iterator.Element>
|
||||
) -> UnsafeMutablePointer<Base.Iterator.Element> {
|
||||
|
||||
@@ -184,6 +184,7 @@ public protocol SetAlgebra : Equatable, ArrayLiteralConvertible {
|
||||
/// distinguishable from `newMember`, e.g. via `===`).
|
||||
///
|
||||
/// - Postcondition: `self.contains(newMember)`.
|
||||
@discardableResult
|
||||
mutating func insert(
|
||||
_ newMember: Element
|
||||
) -> (inserted: Bool, memberAfterInsert: Element)
|
||||
@@ -198,6 +199,7 @@ public protocol SetAlgebra : Equatable, ArrayLiteralConvertible {
|
||||
/// `===`), or returns `nil` if no such element existed.
|
||||
///
|
||||
/// - Postcondition: `self.intersection([e]).isEmpty`
|
||||
@discardableResult
|
||||
mutating func remove(_ e: Element) -> Element?
|
||||
|
||||
/// Inserts `e` unconditionally.
|
||||
@@ -212,6 +214,7 @@ public protocol SetAlgebra : Equatable, ArrayLiteralConvertible {
|
||||
/// `===`), or returns `nil` if no such element existed.
|
||||
///
|
||||
/// - Postcondition: `self.contains(e)`
|
||||
@discardableResult
|
||||
mutating func update(with e: Element) -> Element?
|
||||
|
||||
/// Adds the elements of the given set to the set.
|
||||
|
||||
@@ -185,6 +185,7 @@ struct _SliceBuffer<Element> : _ArrayBufferProtocol, RandomAccessCollection {
|
||||
return nil
|
||||
}
|
||||
|
||||
@discardableResult
|
||||
public func _copyContents(
|
||||
subRange bounds: Range<Int>,
|
||||
initializing target: UnsafeMutablePointer<Element>
|
||||
|
||||
@@ -4846,7 +4846,7 @@ var FooSubUnnamedEnumeratorA1: Int { get }
|
||||
key.doc.full_as_xml: "<Function><Name>update(with:)</Name><USR>s:FesRxs9OptionSetxzwx7ElementrS_6updateFT4withwxS0__GSqwxS0__</USR><Declaration>mutating func update(with e: Self) -> Self?</Declaration><Abstract><Para>Inserts <codeVoice>e</codeVoice> unconditionally.</Para></Abstract><ResultDiscussion><Para>a former member <codeVoice>r</codeVoice> of <codeVoice>self</codeVoice> such that <codeVoice>self.intersection([e]) == [r]</codeVoice> if <codeVoice>self.intersection([e])</codeVoice> was non-empty. Returns <codeVoice>nil</codeVoice> otherwise.</Para></ResultDiscussion><Discussion><Postcondition><Para><codeVoice>self.contains(e)</codeVoice></Para></Postcondition></Discussion></Function>",
|
||||
key.offset: 1314,
|
||||
key.length: 43,
|
||||
key.fully_annotated_decl: "<decl.function.method.instance><syntaxtype.keyword>mutating</syntaxtype.keyword> <syntaxtype.keyword>func</syntaxtype.keyword> <decl.name>update</decl.name>(<decl.var.parameter><decl.var.parameter.argument_label>with</decl.var.parameter.argument_label> <decl.var.parameter.name>e</decl.var.parameter.name>: <decl.var.parameter.type><ref.generic_type_param usr=\"s:tPs9OptionSet4SelfMx\">Self</ref.generic_type_param></decl.var.parameter.type></decl.var.parameter>) -> <decl.function.returntype><ref.generic_type_param usr=\"s:tPs9OptionSet4SelfMx\">Self</ref.generic_type_param>?</decl.function.returntype></decl.function.method.instance>",
|
||||
key.fully_annotated_decl: "<decl.function.method.instance><syntaxtype.attribute.builtin><syntaxtype.attribute.name>@discardableResult</syntaxtype.attribute.name></syntaxtype.attribute.builtin> <syntaxtype.keyword>mutating</syntaxtype.keyword> <syntaxtype.keyword>func</syntaxtype.keyword> <decl.name>update</decl.name>(<decl.var.parameter><decl.var.parameter.argument_label>with</decl.var.parameter.argument_label> <decl.var.parameter.name>e</decl.var.parameter.name>: <decl.var.parameter.type><ref.generic_type_param usr=\"s:tPs9OptionSet4SelfMx\">Self</ref.generic_type_param></decl.var.parameter.type></decl.var.parameter>) -> <decl.function.returntype><ref.generic_type_param usr=\"s:tPs9OptionSet4SelfMx\">Self</ref.generic_type_param>?</decl.function.returntype></decl.function.method.instance>",
|
||||
key.entities: [
|
||||
{
|
||||
key.kind: source.lang.swift.decl.var.local,
|
||||
|
||||
Reference in New Issue
Block a user