Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
d6dc7df
Bump required toolchain to Swift 6.0
lorentey Aug 17, 2025
54c6531
Adopt #filePath in test assertions
lorentey Aug 17, 2025
5f03d1b
Adopt availability macros
lorentey Aug 17, 2025
04408a4
Minimal collections: add support for testing contiguous collection APIs
lorentey Aug 17, 2025
59bc4a4
Add support for lifetime tracked noncopyable structs
lorentey Aug 17, 2025
2ca8bca
Resolve Swift 6 concurrency issues
lorentey Aug 17, 2025
0e8dd37
Box → ClassBox
lorentey Aug 17, 2025
a0417c1
Add unsafe primitives for overriding lifetime dependencies
lorentey Aug 17, 2025
c4433dd
Add ContainersPreview module with `struct Box`
lorentey Aug 17, 2025
b6050e3
Add _isIdentical, _extracting(first:)/_extracting(last:) as UnsafeBuf…
lorentey Aug 17, 2025
f679ec9
[ArrayModule] Add new module with RigidArray and DynamicArray
lorentey Aug 17, 2025
c358154
[ContainersPreview] Add unstable previews `Borrow`, `Inout`, `Shared`
lorentey Aug 17, 2025
c68a2f9
[ContainersPreview] Add InputSpan
lorentey Aug 17, 2025
a95daaa
[ArrayModule] Add (not yet functional) experimental/unstable API
lorentey Aug 17, 2025
bc9c63a
[Rope] Highlight CoW issue in Swift 6 mode
lorentey Aug 17, 2025
b71cc36
[TestSupport] Add Container validator and StaccatoContainer
lorentey Aug 17, 2025
fd8eb14
[TestSupport] Add TestPrintable protocol
lorentey Aug 17, 2025
336567b
Silence very helpful concurrency error on stdout/stderr access
lorentey Aug 17, 2025
7d75a8e
[6.0] Add missing ArrayModule/_CollectionsTestSupport dependency
lorentey Aug 17, 2025
097f923
[workflows] Exclude Swift 5.10 toolchains
lorentey Aug 17, 2025
c844631
[ArrayModule] Disable new arrays on Windows under Swift 6.2 for now
lorentey Aug 18, 2025
66c4937
[ArrayModule] Update DynamicArray tests
lorentey Aug 18, 2025
39dc431
Adjust use of @_transparent
lorentey Aug 26, 2025
3ff6577
[DynamicArray] Reduce growth factor to 1.5
lorentey Aug 26, 2025
5cd5197
[Arrays] Use _assumeNonNegative on capacity properties
lorentey Aug 30, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/pull_request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ jobs:
name: Test
uses: swiftlang/github-workflows/.github/workflows/swift_package_test.yml@main
with:
linux_exclude_swift_versions: '[{"swift_version": "5.8"}, {"swift_version": "5.9"}]'
windows_exclude_swift_versions: '[{"swift_version": "5.9"}]'
linux_exclude_swift_versions: '[{"swift_version": "5.8"}, {"swift_version": "5.9"}, {"swift_version": "5.10"}]'
windows_exclude_swift_versions: '[{"swift_version": "5.9"}, {"swift_version": "5.10"}]'
macos_exclude_xcode_versions: '[{"xcode_version": "16.0"}, {"xcode_version": "16.1"}]'
enable_macos_checks: true
soundness:
Expand Down
27 changes: 27 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,33 @@ include(CTest)
include(GNUInstallDirs)
include(SwiftSupport)

set(collections_swift_flags
"-enable-upcoming-feature MemberImportVisibility"
"-enable-experimental-feature BuiltinModule"
"-enable-experimental-feature Lifetimes"
"-enable-experimental-feature InoutLifetimeDependence"
)
foreach(flag ${collections_swift_flags})
add_compile_options("$<$<COMPILE_LANGUAGE:Swift>:SHELL:${flag}>")
endforeach()

#add_compile_options("$<$<COMPILE_LANGUAGE:Swift>:SHELL:${collections_swift_flags}>")

set(availability_defs
"SwiftStdlib 5.0: macOS 10.14.4, iOS 12.2, watchOS 5.2, tvOS 12.2"
"SwiftStdlib 5.1: macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0"
"SwiftStdlib 5.6: macOS 12.3, iOS 15.4, watchOS 8.5, tvOS 15.4"
"SwiftStdlib 5.8: macOS 13.3, iOS 16.4, watchOS 9.4, tvOS 16.4"
"SwiftStdlib 5.9: macOS 14.0, iOS 17.0, watchOS 10.0, tvOS 17.0"
"SwiftStdlib 5.10: macOS 14.4, iOS 17.4, watchOS 10.4, tvOS 17.4, visionOS 1.1"
"SwiftStdlib 6.0: macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0"
"SwiftStdlib 6.1: macOS 15.4, iOS 18.4, watchOS 11.4, tvOS 18.4, visionOS 2.4"
"SwiftStdlib 6.2: macOS 26.0, iOS 26.0, watchOS 26.0, tvOS 26.0, visionOS 26.0"
)
foreach(def ${availability_defs})
add_compile_options("$<$<COMPILE_LANGUAGE:Swift>:SHELL:-enable-experimental-feature \"AvailabilityMacro=${def}\">")
endforeach()

add_subdirectory(Sources)
# if(BUILD_TESTING)
# add_subdirectory(Tests)
Expand Down
186 changes: 109 additions & 77 deletions Package.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// swift-tools-version:5.10
// swift-tools-version:6.2
//===----------------------------------------------------------------------===//
//
// This source file is part of the Swift Collections open source project
Expand All @@ -12,12 +12,29 @@

import PackageDescription

let _traits: Set<Trait> = [
.default(
enabledTraits: [
//"UnstableContainersPreview"
]),
.trait(
name: "UnstableContainersPreview",
description: """
Enables source-unstable components of the ContainersPreview module in
swift-collections. This allows experimental use of the Container
protocols and associated algorithms.
"""),
]

// This package recognizes the conditional compilation flags listed below.
// To use enable them, uncomment the corresponding lines or define them
// from the package manager command line:
//
// swift build -Xswiftc -DCOLLECTIONS_INTERNAL_CHECKS
var defines: [String] = [
var defines: [SwiftSetting] = [
.define(
"COLLECTIONS_UNSTABLE_CONTAINERS_PREVIEW",
.when(traits: ["UnstableContainersPreview"])),

// Enables internal consistency checks at the end of initializers and
// mutating operations. This can have very significant overhead, so enabling
Expand All @@ -26,7 +43,7 @@ var defines: [String] = [
// This is mostly useful while debugging an issue with the implementation of
// the hash table itself. This setting should never be enabled in production
// code.
// "COLLECTIONS_INTERNAL_CHECKS",
// .define("COLLECTIONS_INTERNAL_CHECKS"),

// Hashing collections provided by this package usually seed their hash
// function with the address of the memory location of their storage,
Expand All @@ -40,10 +57,10 @@ var defines: [String] = [
// This is mostly useful while debugging an issue with the implementation of
// the hash table itself. This setting should never be enabled in production
// code.
// "COLLECTIONS_DETERMINISTIC_HASHING",
// .define("COLLECTIONS_DETERMINISTIC_HASHING"),

// Enables randomized testing of some data structure implementations.
"COLLECTIONS_RANDOMIZED_TESTING",
.define("COLLECTIONS_RANDOMIZED_TESTING"),

// Enable this to build the sources as a single, large module.
// This removes the distinct modules for each data structure, instead
Expand All @@ -52,11 +69,45 @@ var defines: [String] = [
// "COLLECTIONS_SINGLE_MODULE",
]

var _settings: [SwiftSetting] = defines.map { .define($0) }
_settings += [
let availabilityMacros: KeyValuePairs<String, String> = [
"SwiftStdlib 5.0": "macOS 10.14.4, iOS 12.2, watchOS 5.2, tvOS 12.2",
"SwiftStdlib 5.1": "macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0",
"SwiftStdlib 5.6": "macOS 12.3, iOS 15.4, watchOS 8.5, tvOS 15.4",
"SwiftStdlib 5.8": "macOS 13.3, iOS 16.4, watchOS 9.4, tvOS 16.4",
"SwiftStdlib 5.9": "macOS 14.0, iOS 17.0, watchOS 10.0, tvOS 17.0",
"SwiftStdlib 5.10": "macOS 14.4, iOS 17.4, watchOS 10.4, tvOS 17.4, visionOS 1.1",
"SwiftStdlib 6.0": "macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0",
"SwiftStdlib 6.1": "macOS 15.4, iOS 18.4, watchOS 11.4, tvOS 18.4, visionOS 2.4",
"SwiftStdlib 6.2": "macOS 26.0, iOS 26.0, watchOS 26.0, tvOS 26.0, visionOS 26.0",
// Note: if you touch these, please make sure to also update the similar lists in
// CMakeLists.txt and Xcode/Shared.xcconfig.
]

let extraSettings: [SwiftSetting] = [
.enableUpcomingFeature("MemberImportVisibility"),
// .strictMemorySafety(),
.enableExperimentalFeature("BuiltinModule"),
.enableExperimentalFeature("Lifetimes"),
.enableExperimentalFeature("InoutLifetimeDependence"),
// .enableExperimentalFeature("SuppressedAssociatedTypes"),
// .enableExperimentalFeature("AddressableParameters"),
// .enableExperimentalFeature("AddressableTypes"),

// Note: if you touch these, please make sure to also update the similar lists in
// CMakeLists.txt and Xcode/Shared.xcconfig.
]

let _sharedSettings: [SwiftSetting] = (
defines
+ availabilityMacros.map { name, value in
.enableExperimentalFeature("AvailabilityMacro=\(name): \(value)")
}
+ extraSettings
)

let _settings: [SwiftSetting] = _sharedSettings + []
let _testSettings: [SwiftSetting] = _sharedSettings + []

struct CustomTarget {
enum Kind {
case exported
Expand All @@ -70,6 +121,8 @@ struct CustomTarget {
var dependencies: [Target.Dependency]
var directory: String
var exclude: [String]
var sources: [String]?
var settings: [SwiftSetting]
}

extension CustomTarget.Kind {
Expand All @@ -94,14 +147,18 @@ extension CustomTarget {
name: String,
dependencies: [Target.Dependency] = [],
directory: String? = nil,
exclude: [String] = []
exclude: [String] = [],
sources: [String]? = nil,
settings: [SwiftSetting]? = nil
) -> CustomTarget {
CustomTarget(
kind: kind,
name: name,
dependencies: dependencies,
directory: directory ?? name,
exclude: exclude)
exclude: exclude,
sources: sources,
settings: settings ?? (kind.isTest ? _testSettings : _settings))
}

func toTarget() -> Target {
Expand All @@ -117,71 +174,26 @@ extension CustomTarget {
dependencies: dependencies,
path: kind.path(for: directory),
exclude: exclude,
swiftSettings: _settings,
sources: sources,
swiftSettings: settings,
linkerSettings: linkerSettings)
case .test:
return Target.testTarget(
name: name,
dependencies: dependencies,
path: kind.path(for: directory),
exclude: exclude,
swiftSettings: _settings,
swiftSettings: settings,
linkerSettings: linkerSettings)
}
}
}

extension Array where Element == CustomTarget {
func toMonolithicTarget(
name: String,
linkerSettings: [LinkerSetting] = []
) -> Target {
let targets = self.filter { !$0.kind.isTest }
return Target.target(
name: name,
path: "Sources",
exclude: [
"CMakeLists.txt",
"BitCollections/BitCollections.docc",
"Collections/Collections.docc",
"DequeModule/DequeModule.docc",
"HashTreeCollections/HashTreeCollections.docc",
"HeapModule/HeapModule.docc",
"OrderedCollections/OrderedCollections.docc",
] + targets.flatMap { t in
t.exclude.map { "\(t.name)/\($0)" }
},
sources: targets.map { "\($0.directory)" },
swiftSettings: _settings,
linkerSettings: linkerSettings)
}

func toMonolithicTestTarget(
name: String,
dependencies: [Target.Dependency] = [],
linkerSettings: [LinkerSetting] = []
) -> Target {
let targets = self.filter { $0.kind.isTest }
return Target.testTarget(
name: name,
dependencies: dependencies,
path: "Tests",
exclude: [
"README.md",
] + targets.flatMap { t in
t.exclude.map { "\(t.name)/\($0)" }
},
sources: targets.map { "\($0.name)" },
swiftSettings: _settings,
linkerSettings: linkerSettings)
}
}

let targets: [CustomTarget] = [
.target(
kind: .testSupport,
name: "_CollectionsTestSupport",
dependencies: ["InternalCollectionsUtilities"]),
dependencies: ["InternalCollectionsUtilities", "ContainersPreview"]),
.target(
kind: .test,
name: "CollectionsTestSupportTests",
Expand All @@ -203,6 +215,25 @@ let targets: [CustomTarget] = [
"UnsafeBitSet/_UnsafeBitSet.swift.gyb",
"UnsafeBufferPointer+Extras.swift.gyb",
"UnsafeMutableBufferPointer+Extras.swift.gyb",
"UnsafeRawBufferPointer+Extras.swift.gyb",
"UnsafeMutableRawBufferPointer+Extras.swift.gyb",
"LifetimeOverride.swift.gyb",
]),

.target(
kind: .exported,
name: "ArrayModule",
dependencies: [
"InternalCollectionsUtilities",
"ContainersPreview",
],
exclude: ["CMakeLists.txt"]
),
.target(
kind: .test,
name: "ArrayTests",
dependencies: [
"ArrayModule", "_CollectionsTestSupport"
]),

.target(
Expand All @@ -217,6 +248,18 @@ let targets: [CustomTarget] = [
"BitCollections", "_CollectionsTestSupport", "OrderedCollections"
]),

.target(
kind: .exported,
name: "ContainersPreview",
dependencies: ["InternalCollectionsUtilities"],
exclude: ["CMakeLists.txt"]),
.target(
kind: .test,
name: "ContainersTests",
dependencies: [
"ContainersPreview", "_CollectionsTestSupport"
]),

.target(
kind: .exported,
name: "DequeModule",
Expand Down Expand Up @@ -262,7 +305,9 @@ let targets: [CustomTarget] = [
name: "_RopeModule",
dependencies: ["InternalCollectionsUtilities"],
directory: "RopeModule",
exclude: ["CMakeLists.txt"]),
exclude: ["CMakeLists.txt"],
// FIXME: _modify accessors in RopeModule seem to be broken in Swift 6 mode
settings: _sharedSettings + [.swiftLanguageMode(.v5)]),
.target(
kind: .test,
name: "RopeModuleTests",
Expand Down Expand Up @@ -294,28 +339,15 @@ let targets: [CustomTarget] = [
exclude: ["CMakeLists.txt"])
]

var _products: [Product] = []
var _targets: [Target] = []
if defines.contains("COLLECTIONS_SINGLE_MODULE") {
_products = [
.library(name: "Collections", targets: ["Collections"]),
]
_targets = [
targets.toMonolithicTarget(name: "Collections"),
targets.toMonolithicTestTarget(
name: "CollectionsTests",
dependencies: ["Collections"]),
]
} else {
_products = targets.compactMap { t in
guard t.kind == .exported else { return nil }
return .library(name: t.name, targets: [t.name])
}
_targets = targets.map { $0.toTarget() }
let _products: [Product] = targets.compactMap { t in
guard t.kind == .exported else { return nil }
return .library(name: t.name, targets: [t.name])
}
let _targets: [Target] = targets.map { $0.toTarget() }

let package = Package(
name: "swift-collections",
products: _products,
traits: _traits,
targets: _targets
)
Loading