Skip to content

Commit 7144863

Browse files
committed
Drop remaining Swift 6.1 compiler support.
This PR drops the remaining bits in the package that build with the Swift 6.1 compiler. Swift 6.2 has been released and our main branch no longer supports Swift 6.1 toolchains (and hasn't for a while now.)
1 parent 0d27f72 commit 7144863

File tree

13 files changed

+11
-100
lines changed

13 files changed

+11
-100
lines changed

Package.swift

Lines changed: 2 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// swift-tools-version: 6.1
1+
// swift-tools-version: 6.2
22

33
//
44
// This source file is part of the Swift.org open source project
@@ -164,7 +164,7 @@ let package = Package(
164164
"Testing",
165165
],
166166
path: "Tests/_MemorySafeTestingTests",
167-
swiftSettings: .packageSettings + .strictMemorySafety
167+
swiftSettings: .packageSettings + .strictMemorySafety()
168168
),
169169

170170
.macro(
@@ -369,17 +369,6 @@ extension Array where Element == PackageDescription.SwiftSetting {
369369
// proposal via Swift Evolution.
370370
.enableExperimentalFeature("SymbolLinkageMarkers"),
371371

372-
// This setting is no longer needed when building with a 6.2 or later
373-
// toolchain now that SE-0458 has been accepted and implemented, but it is
374-
// needed in order to preserve support for building with 6.1 development
375-
// snapshot toolchains. (Production 6.1 toolchains can build the testing
376-
// library even without this setting since this experimental feature is
377-
// _suppressible_.) This setting can be removed once the minimum supported
378-
// toolchain for building the testing library is ≥ 6.2. It is not needed
379-
// in the CMake settings since that is expected to build using a
380-
// new-enough toolchain.
381-
.enableExperimentalFeature("AllowUnsafeAttribute"),
382-
383372
.enableUpcomingFeature("InferIsolatedConformances"),
384373

385374
// When building as a package, the macro plugin always builds as an
@@ -436,18 +425,6 @@ extension Array where Element == PackageDescription.SwiftSetting {
436425

437426
return result
438427
}
439-
440-
/// Settings necessary to enable Strict Memory Safety, introduced in
441-
/// [SE-0458: Opt-in Strict Memory Safety Checking](https://github.com/swiftlang/swift-evolution/blob/main/proposals/0458-strict-memory-safety.md#swiftpm-integration).
442-
static var strictMemorySafety: Self {
443-
#if compiler(>=6.2)
444-
// FIXME: Adopt official `.strictMemorySafety()` condition once the minimum
445-
// supported toolchain is 6.2.
446-
[.unsafeFlags(["-strict-memory-safety"])]
447-
#else
448-
[]
449-
#endif
450-
}
451428
}
452429

453430
extension Array where Element == PackageDescription.CXXSetting {

Sources/Testing/ExitTests/ExitTest.swift

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -349,10 +349,7 @@ extension ExitTest {
349349
///
350350
/// - Warning: This function is used to implement the
351351
/// `#expect(processExitsWith:)` macro. Do not use it directly.
352-
#if compiler(>=6.2)
353-
@safe
354-
#endif
355-
public static func __store<each T>(
352+
@safe public static func __store<each T>(
356353
_ id: (UInt64, UInt64, UInt64, UInt64),
357354
_ body: @escaping @Sendable (repeat each T) async throws -> Void,
358355
into outValue: UnsafeMutableRawPointer,
@@ -394,10 +391,7 @@ extension ExitTest {
394391
///
395392
/// - Warning: This function is used to implement the
396393
/// `#expect(processExitsWith:)` macro. Do not use it directly.
397-
#if compiler(>=6.2)
398-
@safe
399-
#endif
400-
public static func __store<T>(
394+
@safe public static func __store<T>(
401395
_ id: (UInt64, UInt64, UInt64, UInt64),
402396
_ body: T,
403397
into outValue: UnsafeMutableRawPointer,

Sources/Testing/Expectations/Expectation+Macro.swift

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,6 @@ public macro require<T>(
131131

132132
// MARK: - Matching errors by type
133133

134-
#if compiler(>=6.2)
135134
/// Check that an expression always throws an error of a given type.
136135
///
137136
/// - Parameters:
@@ -197,7 +196,6 @@ public macro expect<E, R>(
197196
sourceLocation: SourceLocation = #_sourceLocation,
198197
performing expression: () throws -> R
199198
) -> E? = #externalMacro(module: "TestingMacros", type: "ExpectMacro") where E: Error
200-
#endif
201199

202200
/// Check that an expression always throws an error of a given type.
203201
///
@@ -263,7 +261,6 @@ public macro expect<E, R>(
263261
performing expression: () async throws -> R
264262
) -> E? = #externalMacro(module: "TestingMacros", type: "ExpectMacro") where E: Error
265263

266-
#if compiler(>=6.2)
267264
/// Check that an expression always throws an error of a given type, and throw
268265
/// an error if it does not.
269266
///
@@ -313,7 +310,6 @@ public macro require<E, R>(
313310
sourceLocation: SourceLocation = #_sourceLocation,
314311
performing expression: () throws -> R
315312
) -> E = #externalMacro(module: "TestingMacros", type: "RequireThrowsMacro") where E: Error
316-
#endif
317313

318314
/// Check that an expression always throws an error of a given type, and throw
319315
/// an error if it does not.
@@ -363,7 +359,6 @@ public macro require<E, R>(
363359
performing expression: () async throws -> R
364360
) -> E = #externalMacro(module: "TestingMacros", type: "RequireThrowsMacro") where E: Error
365361

366-
#if compiler(>=6.2)
367362
/// Check that an expression never throws an error, and throw an error if it
368363
/// does.
369364
///
@@ -383,7 +378,6 @@ public macro require<R>(
383378
sourceLocation: SourceLocation = #_sourceLocation,
384379
performing expression: () throws -> R
385380
) = #externalMacro(module: "TestingMacros", type: "RequireThrowsNeverMacro")
386-
#endif
387381

388382
/// Check that an expression never throws an error, and throw an error if it
389383
/// does.
@@ -407,7 +401,6 @@ public macro require<R>(
407401

408402
// MARK: - Matching instances of equatable errors
409403

410-
#if compiler(>=6.2)
411404
/// Check that an expression always throws a specific error.
412405
///
413406
/// - Parameters:
@@ -449,7 +442,6 @@ public macro expect<E, R>(
449442
sourceLocation: SourceLocation = #_sourceLocation,
450443
performing expression: () throws -> R
451444
) -> E? = #externalMacro(module: "TestingMacros", type: "ExpectMacro") where E: Error & Equatable
452-
#endif
453445

454446
/// Check that an expression always throws a specific error.
455447
///
@@ -491,7 +483,6 @@ public macro expect<E, R>(
491483
performing expression: () async throws -> R
492484
) -> E? = #externalMacro(module: "TestingMacros", type: "ExpectMacro") where E: Error & Equatable
493485

494-
#if compiler(>=6.2)
495486
/// Check that an expression always throws a specific error, and throw an error
496487
/// if it does not.
497488
///
@@ -537,7 +528,6 @@ public macro require<E, R>(
537528
sourceLocation: SourceLocation = #_sourceLocation,
538529
performing expression: () throws -> R
539530
) -> E = #externalMacro(module: "TestingMacros", type: "RequireMacro") where E: Error & Equatable
540-
#endif
541531

542532
/// Check that an expression always throws a specific error, and throw an error
543533
/// if it does not.
@@ -585,7 +575,6 @@ public macro require<E, R>(
585575

586576
// MARK: - Arbitrary error matching
587577

588-
#if compiler(>=6.2)
589578
/// Check that an expression always throws an error matching some condition.
590579
///
591580
/// - Parameters:
@@ -649,7 +638,6 @@ public macro expect<R>(
649638
performing expression: () throws -> R,
650639
throws errorMatcher: (any Error) throws -> Bool
651640
) -> (any Error)? = #externalMacro(module: "TestingMacros", type: "ExpectMacro")
652-
#endif
653641

654642
/// Check that an expression always throws an error matching some condition.
655643
///
@@ -713,7 +701,6 @@ public macro expect<R>(
713701
throws errorMatcher: (any Error) async throws -> Bool
714702
) -> (any Error)? = #externalMacro(module: "TestingMacros", type: "ExpectMacro")
715703

716-
#if compiler(>=6.2)
717704
/// Check that an expression always throws an error matching some condition, and
718705
/// throw an error if it does not.
719706
///
@@ -784,7 +771,6 @@ public macro require<R>(
784771
performing expression: () throws -> R,
785772
throws errorMatcher: (any Error) throws -> Bool
786773
) -> any Error = #externalMacro(module: "TestingMacros", type: "RequireMacro")
787-
#endif
788774

789775
/// Check that an expression always throws an error matching some condition, and
790776
/// throw an error if it does not.

Sources/Testing/Parameterization/TypeInfo.swift

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -405,23 +405,6 @@ extension TypeInfo: Hashable {
405405
}
406406
}
407407

408-
#if compiler(<6.2)
409-
// MARK: - ObjectIdentifier support
410-
411-
extension ObjectIdentifier {
412-
/// Initialize an instance of this type from a type reference.
413-
///
414-
/// - Parameters:
415-
/// - type: The type to initialize this instance from.
416-
///
417-
/// - Bug: The standard library should support this conversion.
418-
/// ([134276458](rdar://134276458), [134415960](rdar://134415960))
419-
fileprivate init(_ type: any ~Copyable.Type) {
420-
self.init(unsafeBitCast(type, to: Any.Type.self))
421-
}
422-
}
423-
#endif
424-
425408
// MARK: - Codable
426409

427410
extension TypeInfo: Codable {

Sources/Testing/Test+Discovery.swift

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,7 @@ extension Test {
3939
///
4040
/// - Warning: This function is used to implement the `@Test` macro. Do not
4141
/// use it directly.
42-
#if compiler(>=6.2)
43-
@safe
44-
#endif
45-
public static func __store(
42+
@safe public static func __store(
4643
_ generator: @escaping @Sendable () async -> Test,
4744
into outValue: UnsafeMutableRawPointer,
4845
asTypeAt typeAddress: UnsafeRawPointer

Sources/TestingMacros/ConditionMacro.swift

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -498,11 +498,10 @@ extension ExitTestConditionMacro {
498498
var recordDecl: DeclSyntax?
499499
#if !SWT_NO_LEGACY_TEST_DISCOVERY
500500
let legacyEnumName = context.makeUniqueName("__🟡$")
501-
let unsafeKeyword: TokenSyntax? = isUnsafeKeywordSupported ? .keyword(.unsafe, trailingTrivia: .space) : nil
502501
recordDecl = """
503502
enum \(legacyEnumName): Testing.__TestContentRecordContainer {
504503
nonisolated static var __testContentRecord: Testing.__TestContentRecord {
505-
\(unsafeKeyword)\(enumName).testContentRecord
504+
unsafe \(enumName).testContentRecord
506505
}
507506
}
508507
"""

Sources/TestingMacros/SuiteDeclarationMacro.swift

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -169,13 +169,12 @@ public struct SuiteDeclarationMacro: MemberMacro, PeerMacro, Sendable {
169169
#if !SWT_NO_LEGACY_TEST_DISCOVERY
170170
// Emit a type that contains a reference to the test content record.
171171
let enumName = context.makeUniqueName("__🟡$")
172-
let unsafeKeyword: TokenSyntax? = isUnsafeKeywordSupported ? .keyword(.unsafe, trailingTrivia: .space) : nil
173172
result.append(
174173
"""
175174
@available(*, deprecated, message: "This type is an implementation detail of the testing library. Do not use it directly.")
176175
enum \(enumName): Testing.__TestContentRecordContainer {
177176
nonisolated static var __testContentRecord: Testing.__TestContentRecord {
178-
\(unsafeKeyword)\(testContentRecordName)
177+
unsafe \(testContentRecordName)
179178
}
180179
}
181180
"""

Sources/TestingMacros/Support/EffectfulExpressionHandling.swift

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -130,17 +130,6 @@ extension BidirectionalCollection<Syntax> {
130130

131131
// MARK: - Inserting effect keywords/thunks
132132

133-
/// Whether or not the `unsafe` expression keyword is supported.
134-
var isUnsafeKeywordSupported: Bool {
135-
// The 'unsafe' keyword was introduced in 6.2 as part of SE-0458. Older
136-
// toolchains are not aware of it.
137-
#if compiler(>=6.2)
138-
true
139-
#else
140-
false
141-
#endif
142-
}
143-
144133
/// Make a function call expression to an effectful thunk function provided by
145134
/// the testing library.
146135
///
@@ -184,8 +173,7 @@ func applyEffectfulKeywords(_ effectfulKeywords: Set<Keyword>, to expr: some Exp
184173

185174
let needAwait = effectfulKeywords.contains(.await) && !expr.is(AwaitExprSyntax.self)
186175
let needTry = effectfulKeywords.contains(.try) && !expr.is(TryExprSyntax.self)
187-
188-
let needUnsafe = isUnsafeKeywordSupported && effectfulKeywords.contains(.unsafe) && !expr.is(UnsafeExprSyntax.self)
176+
let needUnsafe = effectfulKeywords.contains(.unsafe) && !expr.is(UnsafeExprSyntax.self)
189177

190178
// First, add thunk function calls.
191179
if insertThunkCalls {

Sources/TestingMacros/Support/TestContentGeneration.swift

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,13 +63,12 @@ func makeTestContentRecordDecl(named name: TokenSyntax, in typeName: TypeSyntax?
6363
IntegerLiteralExprSyntax(context, radix: .binary)
6464
}
6565

66-
let unsafeKeyword: TokenSyntax? = isUnsafeKeywordSupported ? .keyword(.unsafe, trailingTrivia: .space) : nil
6766
var result: DeclSyntax = """
6867
@available(*, deprecated, message: "This property is an implementation detail of the testing library. Do not use it directly.")
6968
private nonisolated \(staticKeyword(for: typeName)) let \(name): Testing.__TestContentRecord = (
7069
\(kindExpr), \(kind.commentRepresentation)
7170
0,
72-
\(unsafeKeyword)\(accessorName),
71+
unsafe \(accessorName),
7372
\(contextExpr),
7473
0
7574
)

Sources/TestingMacros/TestDeclarationMacro.swift

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -496,13 +496,12 @@ public struct TestDeclarationMacro: PeerMacro, Sendable {
496496
#if !SWT_NO_LEGACY_TEST_DISCOVERY
497497
// Emit a type that contains a reference to the test content record.
498498
let enumName = context.makeUniqueName(thunking: functionDecl, withPrefix: "__🟡$")
499-
let unsafeKeyword: TokenSyntax? = isUnsafeKeywordSupported ? .keyword(.unsafe, trailingTrivia: .space) : nil
500499
result.append(
501500
"""
502501
@available(*, deprecated, message: "This type is an implementation detail of the testing library. Do not use it directly.")
503502
enum \(enumName): Testing.__TestContentRecordContainer {
504503
nonisolated static var __testContentRecord: Testing.__TestContentRecord {
505-
\(unsafeKeyword)\(testContentRecordName)
504+
unsafe \(testContentRecordName)
506505
}
507506
}
508507
"""

0 commit comments

Comments
 (0)