Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
3 changes: 0 additions & 3 deletions Examples/BPListParser/BinaryPList.swift
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,6 @@ extension BPList.Trailer {

extension Int {
@inlinable
@_lifetime(&input)
init(parsingBPListCount input: inout ParserSpan, countMarker: UInt8) throws {
if countMarker != 0xf {
self = Int(countMarker)
Expand Down Expand Up @@ -146,7 +145,6 @@ extension BPList {
}

@inlinable
@_lifetime(&input)
init(parsingIndexAndObject input: inout ParserSpan, trailingObject: Trailer)
throws
{
Expand All @@ -158,7 +156,6 @@ extension BPList {
}

@inlinable
@_lifetime(&input)
init(parsing input: inout ParserSpan, trailingObject: Trailer) throws {
let marker = try UInt8(parsing: &input)

Expand Down
3 changes: 0 additions & 3 deletions Examples/BPListParser/Deferred.swift
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ public struct DeferredBPList {
self.pos = pos
}

@_lifetime(&input)
@usableFromInline
init(parsing input: inout ParserSpan, trailingObject: BPList.Trailer) throws
{
Expand Down Expand Up @@ -107,7 +106,6 @@ extension DeferredBPList {
}
}

@_lifetime(&input)
init(
parsingIndexAndObject input: inout ParserSpan,
trailingObject: BPList.Trailer
Expand All @@ -119,7 +117,6 @@ extension DeferredBPList {
self = try Object(parsing: &objectBuffer, trailingObject: trailingObject)
}

@_lifetime(&input)
@usableFromInline
init(parsing input: inout ParserSpan, trailingObject: BPList.Trailer) throws
{
Expand Down
2 changes: 0 additions & 2 deletions Examples/ELFParser/ELF+Parsing.swift
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ extension ELF: ExpressibleByParsing {
}

extension ELF.ProgramHeader {
@_lifetime(&input)
public init(
parsing input: inout ParserSpan, class: ELF.Header.Class, endian: Endianness
) throws {
Expand Down Expand Up @@ -89,7 +88,6 @@ extension ELF.ProgramHeader {
}

extension ELF.SectionHeader {
@_lifetime(&input)
public init(
parsing input: inout ParserSpan, class: ELF.Header.Class, endian: Endianness
) throws {
Expand Down
1 change: 0 additions & 1 deletion Examples/LZ4Parser/LZ4.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import Foundation

extension Int {
@inlinable
@_lifetime(&input)
init(
parsingLZ4Sequence input: inout ParserSpan, token: UInt8, constant: UInt8
) throws {
Expand Down
2 changes: 0 additions & 2 deletions Examples/PCAPNGParser/Blocks/Block.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ public enum Block {
case enhancedPacket(EnhancedPacket)
case custom(code: String, buffer: [UInt8])

@_lifetime(&input)
static func custom(
parsing input: inout ParserSpan, code: UInt32, endianness: Endianness
) throws -> Self {
Expand All @@ -35,7 +34,6 @@ public enum Block {
return .custom(code: String(code, radix: 16), buffer: data)
}

@_lifetime(&input)
init(parsing input: inout ParserSpan, endianness: Endianness) throws {
let code = try UInt32(parsing: &input, endianness: endianness)
self =
Expand Down
2 changes: 0 additions & 2 deletions Examples/PCAPNGParser/Blocks/BlockOption.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
import BinaryParsing

protocol BlockOption: Equatable {
@_lifetime(&input)
init(
parsing input: inout ParserSpan,
for optionCode: UInt16,
Expand All @@ -23,7 +22,6 @@ protocol BlockOption: Equatable {
}

extension BlockOption {
@_lifetime(&input)
init(parsing input: inout ParserSpan, endianness: Endianness) throws {
let optionCode = try UInt16(parsing: &input, endianness: endianness)
let optionSize = try Int(
Expand Down
4 changes: 0 additions & 4 deletions Examples/PCAPNGParser/Blocks/EnhancedPacket.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ public struct EnhancedPacket {
case sha1(UInt64, UInt64, UInt8)
case toeplitz(UInt32)

@_lifetime(&input)
init(parsing input: inout ParserSpan, endianness: Endianness) throws {
let code = try UInt8(parsing: &input)
self =
Expand Down Expand Up @@ -90,7 +89,6 @@ public struct EnhancedPacket {
public var packetData: Packet
public var options: [Option]

@_lifetime(&input)
init(parsing input: inout ParserSpan, endianness: Endianness) throws {
// 1 2 3
// 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
Expand Down Expand Up @@ -155,7 +153,6 @@ public struct EnhancedPacket {
}

extension EnhancedPacket.Option: BlockOption {
@_lifetime(&input)
init(
parsing input: inout ParserSpan, for optionCode: UInt16,
endianness: Endianness
Expand Down Expand Up @@ -190,7 +187,6 @@ extension EnhancedPacket.Option: BlockOption {
}

extension EnhancedPacket.Packet {
@_lifetime(&input)
init(parsing input: inout ParserSpan, endianness: Endianness) throws {
self.hasPreamble =
try UInt64(parsing: &input, endianness: endianness)
Expand Down
2 changes: 0 additions & 2 deletions Examples/PCAPNGParser/Blocks/InterfaceDescription.swift
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ public struct InterfaceDescription {
self.options = options
}

@_lifetime(&input)
init(parsing input: inout ParserSpan, endianness: Endianness) throws {
// 0 1 2 3
// 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
Expand Down Expand Up @@ -90,7 +89,6 @@ public struct InterfaceDescription {
}

extension InterfaceDescription.Option: BlockOption {
@_lifetime(&input)
init(
parsing input: inout ParserSpan, for optionCode: UInt16,
endianness: Endianness
Expand Down
1 change: 0 additions & 1 deletion Examples/PCAPNGParser/Blocks/SectionHeader.swift
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,6 @@ public struct SectionHeader: Equatable {
}

extension SectionHeader.Option: BlockOption {
@_lifetime(&input)
init(
parsing input: inout ParserSpan,
for optionCode: UInt16,
Expand Down
1 change: 0 additions & 1 deletion Examples/PNGParser/Chunks/Chunk.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ public enum Chunk {
case other(String, [UInt8])
case end

@_lifetime(&input)
init(parsing input: inout ParserSpan) throws {
let length = try UInt32(parsingBigEndian: &input)
let id = try UInt32(parsingBigEndian: &input)
Expand Down
2 changes: 0 additions & 2 deletions Examples/QOIParser/QOI.swift
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,6 @@ extension Pixel {
)
}

@_lifetime(&input)
init(parsingRGB input: inout ParserSpan, alpha: UInt8) throws {
self.v = try (
UInt8(parsing: &input),
Expand All @@ -127,7 +126,6 @@ extension Pixel {
self.v.b &+= (b1 & 0x03) &- 2
}

@_lifetime(&input)
init(
parsingLuma input: inout ParserSpan, initialByte b1: UInt8,
previous: Pixel
Expand Down
1 change: 0 additions & 1 deletion Examples/RawParser/Raw.swift
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ public func parseRaw(
}

extension String {
@_lifetime(&input)
init(parsingRaw input: inout ParserSpan, digits: Int, offset: Int) throws {
let start = input.startPosition
let row = try Array(parsing: &input, byteCount: Swift.min(16, input.count))
Expand Down
2 changes: 0 additions & 2 deletions Sources/BinaryParsing/Macros/MagicNumber.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
//
//===----------------------------------------------------------------------===//

@_lifetime(&input)
public func _loadAndCheckDirectBytes<
T: FixedWidthInteger & MultiByteInteger & BitwiseCopyable
>(
Expand All @@ -23,7 +22,6 @@ public func _loadAndCheckDirectBytes<
}
}

@_lifetime(&input)
public func _loadAndCheckDirectBytesByteOrder<
T: FixedWidthInteger & MultiByteInteger & BitwiseCopyable
>(
Expand Down
1 change: 0 additions & 1 deletion Sources/BinaryParsing/Parser Types/ParserSource.swift
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ public import Foundation
/// let imageData = try Data(contentsOfFile: ...)
/// let qoiImage = try QOI(parsing: imageData)
public protocol ExpressibleByParsing {
@_lifetime(&input)
init(parsing input: inout ParserSpan) throws(ThrownParsingError)
}

Expand Down
6 changes: 6 additions & 0 deletions Sources/BinaryParsing/Parser Types/ParserSpan.swift
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,9 @@ extension ParserSpan {

@unsafe
@inlinable
#if compiler(<6.3)
@_lifetime(copy self)
#endif

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't this be @_lifetime(self: copy self) ? I think that works for swift 6.2+

mutating func consumeUnchecked(type: UInt8.Type = UInt8.self) -> UInt8 {
defer { _lowerBound &+= 1 }
return unsafe _bytes.unsafeLoad(
Expand All @@ -190,7 +192,9 @@ extension ParserSpan {

@unsafe
@inlinable
#if compiler(<6.3)
@_lifetime(copy self)
#endif
mutating func consumeUnchecked<T: FixedWidthInteger & BitwiseCopyable>(
type: T.Type
) -> T {
Expand All @@ -209,7 +213,9 @@ extension ParserSpan {
/// later stage might render the entire parsing operation a failure. Using
/// `atomically` guarantees that the input span isn't modified in that case.
@inlinable
#if compiler(<6.3)
@_lifetime(&self)
#endif
public mutating func atomically<T, E>(
_ body: (inout ParserSpan) throws(E) -> T
) throws(E) -> T {
Expand Down
8 changes: 8 additions & 0 deletions Sources/BinaryParsing/Parser Types/Seeking.swift
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,9 @@ extension ParserSpan {
/// - Parameter range: The range to seek to.
/// - Throws: A `ParsingError` if `range` is out of bounds for this span.
@inlinable
#if compiler(<6.3)
@_lifetime(&self)
#endif
public mutating func seek(toRange range: ParserRange) throws(ParsingError) {
guard (0..._bytes.byteCount).contains(range.lowerBound),
(0..._bytes.byteCount).contains(range.upperBound)
Expand Down Expand Up @@ -204,7 +206,9 @@ extension ParserSpan {
/// - Throws: A `ParsingError` if `offset` is not in the closed range
/// `0...count`.
@inlinable
#if compiler(<6.3)
@_lifetime(&self)
#endif
public mutating func seek(toRelativeOffset offset: some FixedWidthInteger)
throws(ParsingError)
{
Expand Down Expand Up @@ -249,7 +253,9 @@ extension ParserSpan {
/// - Throws: A `ParsingError` if `offset` is not in the closed range
/// `0...bytes.count`.
@inlinable
#if compiler(<6.3)
@_lifetime(&self)
#endif
public mutating func seek(toAbsoluteOffset offset: some FixedWidthInteger)
throws(ParsingError)
{
Expand Down Expand Up @@ -293,7 +299,9 @@ extension ParserSpan {
/// - Throws: A `ParsingError` if `offset` is not in the closed range
/// `0...count`.
@inlinable
#if compiler(<6.3)
@_lifetime(&self)
#endif
public mutating func seek(toOffsetFromEnd offset: some FixedWidthInteger)
throws(ParsingError)
{
Expand Down
6 changes: 6 additions & 0 deletions Sources/BinaryParsing/Parser Types/Slicing.swift
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,9 @@ extension ParserSpan {
/// `Int`, if it's negative, or if there aren't enough bytes in the
/// original span.
@inlinable
#if compiler(<6.3)
@_lifetime(&self)
#endif
public mutating func sliceRange(byteCount: some FixedWidthInteger)
throws(ParsingError) -> ParserRange
{
Expand Down Expand Up @@ -132,7 +134,9 @@ extension ParserSpan {
/// cannot be represented as an `Int`, if their product would overflow, or
/// if the product is not in the range `0...count`.
@inlinable
#if compiler(<6.3)
@_lifetime(&self)
#endif
public mutating func sliceRange(
objectStride: some FixedWidthInteger,
objectCount: some FixedWidthInteger
Expand All @@ -151,7 +155,9 @@ extension ParserSpan {
/// - Returns: A parser range covering the rest of the memory represented
/// by this parser span.
@inlinable
#if compiler(<6.3)
@_lifetime(&self)
#endif
public mutating func sliceRemainingRange() -> ParserRange {
divide(atOffset: self.count).parserRange
}
Expand Down
5 changes: 0 additions & 5 deletions Sources/BinaryParsing/Parsers/Array.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ extension Array where Element == UInt8 {
///
/// - Parameter input: The `ParserSpan` to consume.
@inlinable
@_lifetime(&input)
public init(parsingRemainingBytes input: inout ParserSpan) {
defer { _ = input.divide(atOffset: input.count) }
self = unsafe input.withUnsafeBytes { buffer in
Expand All @@ -34,7 +33,6 @@ extension Array where Element == UInt8 {
/// - Throws: A `ParsingError` if `input` does not have at least `byteCount`
/// bytes remaining.
@inlinable
@_lifetime(&input)
public init(parsing input: inout ParserSpan, byteCount: Int)
throws(ParsingError)
{
Expand Down Expand Up @@ -74,7 +72,6 @@ extension Array {
/// - Throws: An error if one is thrown from `parser`, or if `count` isn't
/// representable.
@inlinable
@_lifetime(&input)
public init(
parsing input: inout ParserSpan,
count: some FixedWidthInteger,
Expand Down Expand Up @@ -119,7 +116,6 @@ extension Array {
/// - parser: A closure that parses each element from `input`.
/// - Throws: An error if one is thrown from `parser`.
@inlinable
@_lifetime(&input)
public init(
parsing input: inout ParserSpan,
count: Int,
Expand Down Expand Up @@ -161,7 +157,6 @@ extension Array {
/// - parser: A closure that parses each element from `input`.
/// - Throws: An error if one is thrown from `parser`.
@inlinable
@_lifetime(&input)
public init<E>(
parsingAll input: inout ParserSpan,
parser: (inout ParserSpan) throws(E) -> Element
Expand Down
2 changes: 0 additions & 2 deletions Sources/BinaryParsing/Parsers/Data.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ extension Data {
///
/// - Parameter input: The `ParserSpan` to consume.
@inlinable
@_lifetime(&input)
public init(parsingRemainingBytes input: inout ParserSpan) {
defer { _ = input.divide(atOffset: input.count) }
self = unsafe input.withUnsafeBytes { buffer in
Expand All @@ -37,7 +36,6 @@ extension Data {
/// - Throws: A `ParsingError` if `input` does not have at least `byteCount`
/// bytes remaining.
@inlinable
@_lifetime(&input)
public init(parsing input: inout ParserSpan, byteCount: Int)
throws(ParsingError)
{
Expand Down
2 changes: 0 additions & 2 deletions Sources/BinaryParsing/Parsers/InlineArray.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ extension InlineArray where Element == UInt8 {
/// - Throws: A `ParsingError` if `input` does not have at least `count`
/// bytes remaining.
@inlinable
@_lifetime(&input)
public init(parsing input: inout ParserSpan) throws {
let slice = try input._divide(atByteOffset: Self.count)
self = unsafe slice.withUnsafeBytes { buffer in
Expand Down Expand Up @@ -53,7 +52,6 @@ extension InlineArray where Element: ~Copyable {
/// - parser: A closure that parses each element from `input`.
/// - Throws: An error if one is thrown from `parser`.
@inlinable
@_lifetime(&input)
public init(
parsing input: inout ParserSpan,
parser: (inout ParserSpan) throws -> Element
Expand Down
Loading