Skip to content

Commit b1bf693

Browse files
committed
stdlib: Remove #if $NoncopyableGenerics guards.
The stdlib is always built with NoncopyableGenerics enabled, so `#if $NoncopyableGenerics` guards in non-inlinable code are superfluous. Additionally, the stdlib's interface no longer needs to support compilers without the feature, so the guards in inlinable code can also be removed.
1 parent 4e4d547 commit b1bf693

File tree

6 files changed

+6
-22
lines changed

6 files changed

+6
-22
lines changed

stdlib/public/core/Bitset.swift

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -316,10 +316,8 @@ extension _UnsafeBitset.Word {
316316
// iterator, not the original word.
317317
extension _UnsafeBitset.Word: Sequence, IteratorProtocol {
318318

319-
#if $NoncopyableGenerics
320319
@usableFromInline
321320
typealias Element = Int
322-
#endif
323321

324322
@inlinable
325323
internal var count: Int {

stdlib/public/core/ExistentialCollection.swift

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1286,10 +1286,7 @@ internal struct _ClosureBasedSequence<Iterator: IteratorProtocol> {
12861286
extension _ClosureBasedSequence: Sendable {}
12871287

12881288
extension _ClosureBasedSequence: Sequence {
1289-
1290-
#if $NoncopyableGenerics
12911289
public typealias Element = Iterator.Element
1292-
#endif
12931290

12941291
@inlinable
12951292
internal func makeIterator() -> Iterator {

stdlib/public/core/Misc.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,7 @@ func _rethrowsViaClosure(_ fn: () throws -> ()) rethrows {
231231
@_marker public protocol Escapable {}
232232

233233
#if $BitwiseCopyable2
234-
#if $NoncopyableGenerics && $NonescapableTypes
234+
#if $NonescapableTypes
235235
@_marker public protocol BitwiseCopyable: ~Escapable { }
236236
#else
237237
@_marker public protocol BitwiseCopyable { }
@@ -240,7 +240,7 @@ func _rethrowsViaClosure(_ fn: () throws -> ()) rethrows {
240240
@available(*, deprecated, message: "Use BitwiseCopyable")
241241
public typealias _BitwiseCopyable = BitwiseCopyable
242242
#else
243-
#if $NoncopyableGenerics && $NonescapableTypes
243+
#if $NonescapableTypes
244244
@_marker public protocol _BitwiseCopyable: ~Escapable { }
245245
#else
246246
@_marker public protocol _BitwiseCopyable { }

stdlib/public/core/Optional.swift

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -230,16 +230,12 @@ extension Optional where Wrapped: ~Copyable {
230230
public borrowing func _borrowingMap<U: ~Copyable, E: Error>(
231231
_ transform: (borrowing Wrapped) throws(E) -> U
232232
) throws(E) -> U? {
233-
#if compiler(>=6.0) && $NoncopyableGenerics
234233
switch self {
235234
case .some(let y):
236235
return .some(try transform(y))
237236
case .none:
238237
return .none
239238
}
240-
#else
241-
fatalError("unsupported compiler")
242-
#endif
243239
}
244240
}
245241

@@ -308,16 +304,12 @@ extension Optional where Wrapped: ~Copyable {
308304
public func _borrowingFlatMap<U: ~Copyable, E: Error>(
309305
_ transform: (borrowing Wrapped) throws(E) -> U?
310306
) throws(E) -> U? {
311-
#if compiler(>=6.0) && $NoncopyableGenerics
312307
switch self {
313308
case .some(let y):
314309
return try transform(y)
315310
case .none:
316311
return .none
317312
}
318-
#else
319-
fatalError("Unsupported compiler")
320-
#endif
321313
}
322314
}
323315

stdlib/public/core/Sendable.swift

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -132,13 +132,12 @@
132132
/// ### Sendable Metatypes
133133
///
134134
/// Metatypes such as `Int.Type` implicitly conform to the `Sendable` protocol.
135-
#if $NoncopyableGenerics && $NonescapableTypes
135+
#if $NonescapableTypes
136136
@_marker public protocol Sendable: ~Copyable, ~Escapable { }
137-
#elseif $NoncopyableGenerics
138-
@_marker public protocol Sendable: ~Copyable { }
139137
#else
140-
@_marker public protocol Sendable { }
138+
@_marker public protocol Sendable: ~Copyable { }
141139
#endif
140+
142141
///
143142
/// A type whose values can safely be passed across concurrency domains by copying,
144143
/// but which disables some safety checking at the conformance site.

stdlib/public/core/Sequence.swift

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1272,9 +1272,7 @@ public struct IteratorSequence<Base: IteratorProtocol> {
12721272

12731273
extension IteratorSequence: IteratorProtocol, Sequence {
12741274

1275-
#if $NoncopyableGenerics
1276-
public typealias Element = Base.Element
1277-
#endif
1275+
public typealias Element = Base.Element
12781276

12791277
/// Advances to the next element and returns it, or `nil` if no next element
12801278
/// exists.

0 commit comments

Comments
 (0)