Another bit of an oddity.
I've added Span, RawSpan, MutableSpan, MutableRawSpan to my stdlib and when I try to compile I'm seeing these types of errors...
MutableRawSpan.swift:21:12: warning: unrecognized platform name 'SwiftCompatibilitySpan' [#AvailabilityUnrecognizedName]
19 | @safe
20 | @frozen
21 | @available(SwiftCompatibilitySpan 5.0, *)
| `- warning: unrecognized platform name 'SwiftCompatibilitySpan' [#AvailabilityUnrecognizedName]
22 | @_originallyDefinedIn(module: "Swift;CompatibilitySpan", SwiftCompatibilitySpan 6.2)
23 | public struct MutableRawSpan: ~Copyable & ~Escapable {
MutableRawSpan.swift:38:20: error: invalid use of borrow dependence with consuming ownership
36 | @_unsafeNonescapableResult
37 | @_alwaysEmitIntoClient
38 | @lifetime(borrow pointer)
| `- error: invalid use of borrow dependence with consuming ownership
39 | internal init(
40 | _unchecked pointer: UnsafeMutableRawPointer?,
The code in question so you don't have to go hunting is...
@safe
@frozen
@available(SwiftCompatibilitySpan 5.0, *)
@_originallyDefinedIn(module: "Swift;CompatibilitySpan", SwiftCompatibilitySpan 6.2)
public struct MutableRawSpan: ~Copyable & ~Escapable {
@usableFromInline
internal let _pointer: UnsafeMutableRawPointer?
@usableFromInline
internal let _count: Int
@_alwaysEmitIntoClient
internal func _start() -> UnsafeMutableRawPointer {
unsafe _pointer._unsafelyUnwrappedUnchecked
}
@unsafe
@_unsafeNonescapableResult
@_alwaysEmitIntoClient
@lifetime(borrow pointer)
internal init(
_unchecked pointer: UnsafeMutableRawPointer?,
byteCount: Int
) {
unsafe _pointer = pointer
_count = byteCount
}
}
FYI My compile command is...
"/Users/carl/Documents/Code/swift-project/build/Ninja-RelWithDebInfoAssert/swift-macosx-arm64/bin/swiftc" -parse-as-library -parse-stdlib -target avr-none-none-elf -nostdimport -I uSwiftShims -I "/Applications/S4A IDE Pro.app/Contents/XPCServices/BuildEngine.xpc/Contents/Resources/lib/avr-libgcc/include" -I "/Applications/S4A IDE Pro.app/Contents/XPCServices/BuildEngine.xpc/Contents/Resources/lib/avr-libc/include" -Xcc -DAVR_LIBC_DEFINED -Xcc -DLIBC_DEFINED -DAVR_LIBC_DEFINED_SWIFT -DFORCE_MAIN_SWIFT_ARRAYS -enable-experimental-feature Embedded -enable-experimental-feature LifetimeDependence -enable-experimental-feature MoveOnly -enable-experimental-feature ExistentialAny -enable-experimental-feature BitwiseCopyable -Xfrontend -disable-reflection-metadata -Xfrontend -disable-stack-protector -Osize -whole-module-optimization -emit-module -emit-module-path bin/AVR-Embedded/Swift.swiftmodule -module-name Swift CoreOperators.swift CoreAliases.swift RawRepresentable.swift LiteralProtocols.swift TopLevelFunctions.swift CoreProtocols.swift CoreFloatingPoint.swift CoreBinaryFloatingPoint.swift Float.swift Float16.swift CoreFloatingPointFunctions.swift Optional.swift Bridging.swift CoreNumericProtocols.swift BinaryInteger.swift CoreIntegers.swift ErrorType.swift Bool.swift Integers.swift Ranges.swift Sequence.swift Stride.swift Slice.swift Collection.swift BidirectionalCollection.swift RandomAccessCollection.swift ClosedRange.swift MutableCollection.swift Hash.swift Pointer.swift UnsafeBufferPointer.swift UnsafeRawBufferPointer.swift UnsafeRawPointer.swift Indices.swift Existential.swift Algorithm.swift FixedWidth.swift IntegerMath.swift CTypes.swift UnsafePointer.swift ObjectIdentifier.swift CollectionAlgorithms.swift WriteBackMutableSlice.swift Random.swift RangeReplaceableCollection.swift MemoryLayout.swift Tuple.swift SequenceAlgorithms.swift LifetimeManager.swift Repeat.swift EmptyCollection.swift CollectionOfOne.swift StringLiterals.swift StaticString.swift StringInterpolation.swift Unicode.swift UnicodeScalar.swift UnicodeEncoding.swift UTF8.swift UTF16.swift ValidUTF8Buffer.swift UnicodeParser.swift UIntBuffer.swift UTFEncoding.swift UTF32.swift ArrayType.swift ArrayBufferProtocol.swift ArrayLiterals.swift ArrayShared.swift ContiguousArray.swift SliceBuffer.swift ArraySlice.swift Array.swift ArrayBody.swift ArrayCast.swift AnyHashable.swift ManagedBuffer.swift Reverse.swift Map.swift Zip.swift LazySequence.swift LazyCollection.swift Filter.swift FlatMap.swift Flatten.swift DropWhile.swift Volatile.swift uSwift.swift Identifiable.swift OptionSet.swift Sendable.swift SetAlgebra.swift Unmanaged.swift ContiguousArrayBuffer.swift Volatile-stdlib.swift MutableRawSpan.swift MutableSpan.swift RawSpan.swift Span.swift Integer-16.swift IntegerMath-16.swift CTypes-16.swift Progmem.swift EmbeddedRuntime.swift version.swift
I don't understand why the compiler thinks this constructor has a "consuming ownership"?
What am I doing wrong here? Any advice gratefully received!
Carl