From 18c58bcca4edc44d33de8abfc5e142c014fceb71 Mon Sep 17 00:00:00 2001 From: Karoy Lorentey Date: Wed, 6 May 2026 17:50:47 -0700 Subject: [PATCH] [ContainersPreview] Ref: Disable `Builtin.Borrow` for now --- Package.swift | 3 +++ Sources/ContainersPreview/Types/Ref.swift | 8 ++++---- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/Package.swift b/Package.swift index 9652e4ab..16b9a9c6 100644 --- a/Package.swift +++ b/Package.swift @@ -86,6 +86,9 @@ var defines: [SwiftSetting] = [ // Enables longer, more exhaustive tests. // .define("COLLECTIONS_LONG_TESTS"), + + // Enable the use of `Builtin.Borrow` in `struct Ref`. +// .define("COLLECTIONS_BORROW_BUILTIN") ] let availabilityMacros: KeyValuePairs = [ diff --git a/Sources/ContainersPreview/Types/Ref.swift b/Sources/ContainersPreview/Types/Ref.swift index 70eec0d4..32da8618 100644 --- a/Sources/ContainersPreview/Types/Ref.swift +++ b/Sources/ContainersPreview/Types/Ref.swift @@ -17,7 +17,7 @@ import Builtin @available(*, deprecated, renamed: "Ref") public typealias Borrow = Ref -#if compiler(>=6.4) +#if compiler(>=6.4) && COLLECTIONS_BORROW_BUILTIN /// A safe reference allowing in-place reads to a shared value. @available(SwiftStdlib 5.0, *) @frozen @@ -71,7 +71,7 @@ extension Ref where Value: ~Copyable { } } -#else // compiler(>=6.3) && compiler(<6.4) +#else /// A safe reference allowing in-place reads to a shared value. @available(SwiftStdlib 5.0, *) @@ -141,7 +141,7 @@ extension Ref where Value: ~Copyable { unsafeAddress pointer: UnsafePointer, copying owner: borrowing Owner ) { -#if compiler(>=6.4) +#if compiler(>=6.4) && COLLECTIONS_BORROW_BUILTIN _builtin = unsafe Builtin.makeBorrow(pointer.pointee) #else _pointer = pointer @@ -151,7 +151,7 @@ extension Ref where Value: ~Copyable { @available(SwiftStdlib 5.0, *) extension Ref where Value: ~Copyable { -#if compiler(>=6.4) +#if compiler(>=6.4) && COLLECTIONS_BORROW_BUILTIN @_alwaysEmitIntoClient @available(*, deprecated, renamed: "value") public subscript() -> Value {