diff --git a/Examples/BPListParser/BinaryPList.swift b/Examples/BPListParser/BinaryPList.swift index bed0222..634284f 100644 --- a/Examples/BPListParser/BinaryPList.swift +++ b/Examples/BPListParser/BinaryPList.swift @@ -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) @@ -146,7 +145,6 @@ extension BPList { } @inlinable - @_lifetime(&input) init(parsingIndexAndObject input: inout ParserSpan, trailingObject: Trailer) throws { @@ -158,7 +156,6 @@ extension BPList { } @inlinable - @_lifetime(&input) init(parsing input: inout ParserSpan, trailingObject: Trailer) throws { let marker = try UInt8(parsing: &input) diff --git a/Examples/BPListParser/Deferred.swift b/Examples/BPListParser/Deferred.swift index e9c3b77..dcc135c 100644 --- a/Examples/BPListParser/Deferred.swift +++ b/Examples/BPListParser/Deferred.swift @@ -39,7 +39,6 @@ public struct DeferredBPList { self.pos = pos } - @_lifetime(&input) @usableFromInline init(parsing input: inout ParserSpan, trailingObject: BPList.Trailer) throws { @@ -107,7 +106,6 @@ extension DeferredBPList { } } - @_lifetime(&input) init( parsingIndexAndObject input: inout ParserSpan, trailingObject: BPList.Trailer @@ -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 { diff --git a/Examples/ELFParser/ELF+Parsing.swift b/Examples/ELFParser/ELF+Parsing.swift index e956b05..2a0985c 100644 --- a/Examples/ELFParser/ELF+Parsing.swift +++ b/Examples/ELFParser/ELF+Parsing.swift @@ -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 { @@ -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 { diff --git a/Examples/LZ4Parser/LZ4.swift b/Examples/LZ4Parser/LZ4.swift index 95f16da..463ac78 100644 --- a/Examples/LZ4Parser/LZ4.swift +++ b/Examples/LZ4Parser/LZ4.swift @@ -18,7 +18,6 @@ import Foundation extension Int { @inlinable - @_lifetime(&input) init( parsingLZ4Sequence input: inout ParserSpan, token: UInt8, constant: UInt8 ) throws { diff --git a/Examples/PCAPNGParser/Blocks/Block.swift b/Examples/PCAPNGParser/Blocks/Block.swift index 6393786..07dd765 100644 --- a/Examples/PCAPNGParser/Blocks/Block.swift +++ b/Examples/PCAPNGParser/Blocks/Block.swift @@ -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 { @@ -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 = diff --git a/Examples/PCAPNGParser/Blocks/BlockOption.swift b/Examples/PCAPNGParser/Blocks/BlockOption.swift index a99c13d..0a5e311 100644 --- a/Examples/PCAPNGParser/Blocks/BlockOption.swift +++ b/Examples/PCAPNGParser/Blocks/BlockOption.swift @@ -12,7 +12,6 @@ import BinaryParsing protocol BlockOption: Equatable { - @_lifetime(&input) init( parsing input: inout ParserSpan, for optionCode: UInt16, @@ -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( diff --git a/Examples/PCAPNGParser/Blocks/EnhancedPacket.swift b/Examples/PCAPNGParser/Blocks/EnhancedPacket.swift index a0bba15..2299a4a 100644 --- a/Examples/PCAPNGParser/Blocks/EnhancedPacket.swift +++ b/Examples/PCAPNGParser/Blocks/EnhancedPacket.swift @@ -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 = @@ -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 @@ -155,7 +153,6 @@ public struct EnhancedPacket { } extension EnhancedPacket.Option: BlockOption { - @_lifetime(&input) init( parsing input: inout ParserSpan, for optionCode: UInt16, endianness: Endianness @@ -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) diff --git a/Examples/PCAPNGParser/Blocks/InterfaceDescription.swift b/Examples/PCAPNGParser/Blocks/InterfaceDescription.swift index 053f168..38f9d3e 100644 --- a/Examples/PCAPNGParser/Blocks/InterfaceDescription.swift +++ b/Examples/PCAPNGParser/Blocks/InterfaceDescription.swift @@ -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 @@ -90,7 +89,6 @@ public struct InterfaceDescription { } extension InterfaceDescription.Option: BlockOption { - @_lifetime(&input) init( parsing input: inout ParserSpan, for optionCode: UInt16, endianness: Endianness diff --git a/Examples/PCAPNGParser/Blocks/SectionHeader.swift b/Examples/PCAPNGParser/Blocks/SectionHeader.swift index 5a947f9..4c93ef5 100644 --- a/Examples/PCAPNGParser/Blocks/SectionHeader.swift +++ b/Examples/PCAPNGParser/Blocks/SectionHeader.swift @@ -108,7 +108,6 @@ public struct SectionHeader: Equatable { } extension SectionHeader.Option: BlockOption { - @_lifetime(&input) init( parsing input: inout ParserSpan, for optionCode: UInt16, diff --git a/Examples/PNGParser/Chunks/Chunk.swift b/Examples/PNGParser/Chunks/Chunk.swift index 5dbd962..b543ba6 100644 --- a/Examples/PNGParser/Chunks/Chunk.swift +++ b/Examples/PNGParser/Chunks/Chunk.swift @@ -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) diff --git a/Examples/QOIParser/QOI.swift b/Examples/QOIParser/QOI.swift index a41850a..709ee49 100644 --- a/Examples/QOIParser/QOI.swift +++ b/Examples/QOIParser/QOI.swift @@ -110,7 +110,6 @@ extension Pixel { ) } - @_lifetime(&input) init(parsingRGB input: inout ParserSpan, alpha: UInt8) throws { self.v = try ( UInt8(parsing: &input), @@ -127,7 +126,6 @@ extension Pixel { self.v.b &+= (b1 & 0x03) &- 2 } - @_lifetime(&input) init( parsingLuma input: inout ParserSpan, initialByte b1: UInt8, previous: Pixel diff --git a/Examples/RawParser/Raw.swift b/Examples/RawParser/Raw.swift index 513fd95..b62de3d 100644 --- a/Examples/RawParser/Raw.swift +++ b/Examples/RawParser/Raw.swift @@ -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)) diff --git a/Sources/BinaryParsing/Macros/MagicNumber.swift b/Sources/BinaryParsing/Macros/MagicNumber.swift index c0f61d7..d5895e2 100644 --- a/Sources/BinaryParsing/Macros/MagicNumber.swift +++ b/Sources/BinaryParsing/Macros/MagicNumber.swift @@ -9,7 +9,6 @@ // //===----------------------------------------------------------------------===// -@_lifetime(&input) public func _loadAndCheckDirectBytes< T: FixedWidthInteger & MultiByteInteger & BitwiseCopyable >( @@ -23,7 +22,6 @@ public func _loadAndCheckDirectBytes< } } -@_lifetime(&input) public func _loadAndCheckDirectBytesByteOrder< T: FixedWidthInteger & MultiByteInteger & BitwiseCopyable >( diff --git a/Sources/BinaryParsing/Parser Types/ParserSource.swift b/Sources/BinaryParsing/Parser Types/ParserSource.swift index 633e4e6..05f5f21 100644 --- a/Sources/BinaryParsing/Parser Types/ParserSource.swift +++ b/Sources/BinaryParsing/Parser Types/ParserSource.swift @@ -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) } diff --git a/Sources/BinaryParsing/Parser Types/ParserSpan.swift b/Sources/BinaryParsing/Parser Types/ParserSpan.swift index 34525b4..dd7f0ed 100644 --- a/Sources/BinaryParsing/Parser Types/ParserSpan.swift +++ b/Sources/BinaryParsing/Parser Types/ParserSpan.swift @@ -180,7 +180,9 @@ extension ParserSpan { @unsafe @inlinable + #if compiler(<6.3) @_lifetime(copy self) + #endif mutating func consumeUnchecked(type: UInt8.Type = UInt8.self) -> UInt8 { defer { _lowerBound &+= 1 } return unsafe _bytes.unsafeLoad( @@ -190,7 +192,9 @@ extension ParserSpan { @unsafe @inlinable + #if compiler(<6.3) @_lifetime(copy self) + #endif mutating func consumeUnchecked( type: T.Type ) -> T { @@ -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( _ body: (inout ParserSpan) throws(E) -> T ) throws(E) -> T { diff --git a/Sources/BinaryParsing/Parser Types/Seeking.swift b/Sources/BinaryParsing/Parser Types/Seeking.swift index f2f229d..6e94348 100644 --- a/Sources/BinaryParsing/Parser Types/Seeking.swift +++ b/Sources/BinaryParsing/Parser Types/Seeking.swift @@ -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) @@ -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) { @@ -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) { @@ -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) { diff --git a/Sources/BinaryParsing/Parser Types/Slicing.swift b/Sources/BinaryParsing/Parser Types/Slicing.swift index ba39e4a..8ab1311 100644 --- a/Sources/BinaryParsing/Parser Types/Slicing.swift +++ b/Sources/BinaryParsing/Parser Types/Slicing.swift @@ -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 { @@ -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 @@ -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 } diff --git a/Sources/BinaryParsing/Parsers/Array.swift b/Sources/BinaryParsing/Parsers/Array.swift index 145868c..678aa22 100644 --- a/Sources/BinaryParsing/Parsers/Array.swift +++ b/Sources/BinaryParsing/Parsers/Array.swift @@ -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 @@ -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) { @@ -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, @@ -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, @@ -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( parsingAll input: inout ParserSpan, parser: (inout ParserSpan) throws(E) -> Element diff --git a/Sources/BinaryParsing/Parsers/Data.swift b/Sources/BinaryParsing/Parsers/Data.swift index fcc54ff..85836a1 100644 --- a/Sources/BinaryParsing/Parsers/Data.swift +++ b/Sources/BinaryParsing/Parsers/Data.swift @@ -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 @@ -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) { diff --git a/Sources/BinaryParsing/Parsers/InlineArray.swift b/Sources/BinaryParsing/Parsers/InlineArray.swift index 26262b8..2fb49bd 100644 --- a/Sources/BinaryParsing/Parsers/InlineArray.swift +++ b/Sources/BinaryParsing/Parsers/InlineArray.swift @@ -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 @@ -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 diff --git a/Sources/BinaryParsing/Parsers/Integer.swift b/Sources/BinaryParsing/Parsers/Integer.swift index 43f1bd6..2366ffd 100644 --- a/Sources/BinaryParsing/Parsers/Integer.swift +++ b/Sources/BinaryParsing/Parsers/Integer.swift @@ -36,7 +36,6 @@ extension FixedWidthInteger { extension FixedWidthInteger where Self: BitwiseCopyable { @unsafe @inlinable - @_lifetime(&input) init( _unchecked _: Void, _parsingBigEndian input: inout ParserSpan @@ -45,7 +44,6 @@ extension FixedWidthInteger where Self: BitwiseCopyable { } @inlinable - @_lifetime(&input) init( _parsingBigEndian input: inout ParserSpan ) throws(ParsingError) { @@ -55,7 +53,6 @@ extension FixedWidthInteger where Self: BitwiseCopyable { @unsafe @inlinable - @_lifetime(&input) init( _unchecked _: Void, _parsingLittleEndian input: inout ParserSpan @@ -64,7 +61,6 @@ extension FixedWidthInteger where Self: BitwiseCopyable { } @inlinable - @_lifetime(&input) init(_parsingLittleEndian input: inout ParserSpan) throws(ParsingError) { try input._checkCount(minimum: MemoryLayout.size) unsafe self.init(_unchecked: (), _parsingLittleEndian: &input) @@ -72,7 +68,6 @@ extension FixedWidthInteger where Self: BitwiseCopyable { @unsafe @inlinable - @_lifetime(&input) init( _unchecked _: Void, _parsingSigned input: inout ParserSpan, @@ -110,7 +105,6 @@ extension FixedWidthInteger where Self: BitwiseCopyable { @unsafe @inlinable - @_lifetime(&input) init( _unchecked _: Void, _parsingUnsigned input: inout ParserSpan, @@ -133,7 +127,6 @@ extension FixedWidthInteger where Self: BitwiseCopyable { @unsafe @inlinable - @_lifetime(&input) init( _unchecked _: Void, _parsingSigned input: inout ParserSpan, @@ -195,7 +188,6 @@ extension FixedWidthInteger where Self: BitwiseCopyable { @unsafe @inlinable - @_lifetime(&input) init( _unchecked _: Void, _parsingUnsigned input: inout ParserSpan, @@ -232,7 +224,6 @@ extension FixedWidthInteger where Self: BitwiseCopyable { @unsafe @inlinable - @_lifetime(&input) init( _unchecked _: Void, _parsing input: inout ParserSpan, @@ -262,7 +253,6 @@ extension FixedWidthInteger where Self: BitwiseCopyable { } @inlinable - @_lifetime(&input) init( _parsing input: inout ParserSpan, endianness: Endianness, @@ -283,7 +273,6 @@ extension FixedWidthInteger where Self: BitwiseCopyable { extension MultiByteInteger { @unsafe @inlinable - @_lifetime(&input) public init(_unchecked _: Void, parsingBigEndian input: inout ParserSpan) { unsafe self.init(_unchecked: (), _parsingBigEndian: &input) } @@ -297,14 +286,12 @@ extension MultiByteInteger { /// - Throws: A `ParsingError` if `input` does not have enough bytes to store /// this integer type. @inlinable - @_lifetime(&input) public init(parsingBigEndian input: inout ParserSpan) throws(ParsingError) { try self.init(_parsingBigEndian: &input) } @unsafe @inlinable - @_lifetime(&input) public init(_unchecked _: Void, parsingLittleEndian input: inout ParserSpan) { unsafe self.init(_unchecked: (), _parsingLittleEndian: &input) } @@ -318,7 +305,6 @@ extension MultiByteInteger { /// - Throws: A `ParsingError` if `input` does not have enough bytes to store /// this integer type. @inlinable - @_lifetime(&input) public init(parsingLittleEndian input: inout ParserSpan) throws(ParsingError) { try self.init(_parsingLittleEndian: &input) @@ -326,7 +312,6 @@ extension MultiByteInteger { @unsafe @inlinable - @_lifetime(&input) public init( _unchecked _: Void, parsing input: inout ParserSpan, endianness: Endianness ) { @@ -346,7 +331,6 @@ extension MultiByteInteger { /// - Throws: A `ParsingError` if `input` does not have enough bytes to store /// this integer type. @inlinable - @_lifetime(&input) public init(parsing input: inout ParserSpan, endianness: Endianness) throws(ParsingError) { @@ -360,7 +344,6 @@ extension MultiByteInteger { extension SingleByteInteger { @unsafe @inlinable - @_lifetime(&input) public init(_unchecked _: Void, parsing input: inout ParserSpan) { self = unsafe input.consumeUnchecked(type: Self.self) } @@ -382,7 +365,6 @@ extension SingleByteInteger { } @unsafe - @_lifetime(&input) @available( *, deprecated, message: "This initializer should only be used for performance testing." @@ -396,7 +378,6 @@ extension SingleByteInteger { extension FixedWidthInteger where Self: BitwiseCopyable { @unsafe @inlinable - @_lifetime(&input) public init( _unchecked _: Void, parsingBigEndian input: inout ParserSpan, byteCount: Int ) throws(ParsingError) { @@ -420,7 +401,6 @@ extension FixedWidthInteger where Self: BitwiseCopyable { /// - Throws: A `ParsingError` if `input` contains fewer than `byteCount` /// bytes, or if the parsed value overflows this integer type. @inlinable - @_lifetime(&input) public init(parsingBigEndian input: inout ParserSpan, byteCount: Int) throws(ParsingError) { @@ -429,7 +409,6 @@ extension FixedWidthInteger where Self: BitwiseCopyable { @unsafe @inlinable - @_lifetime(&input) public init( _unchecked _: Void, parsingLittleEndian input: inout ParserSpan, byteCount: Int @@ -455,7 +434,6 @@ extension FixedWidthInteger where Self: BitwiseCopyable { /// - Throws: A `ParsingError` if `input` contains fewer than `byteCount` /// bytes, or if the parsed value overflows this integer type. @inlinable - @_lifetime(&input) public init(parsingLittleEndian input: inout ParserSpan, byteCount: Int) throws(ParsingError) { @@ -464,7 +442,6 @@ extension FixedWidthInteger where Self: BitwiseCopyable { @unsafe @inlinable - @_lifetime(&input) public init( _unchecked _: Void, parsing input: inout ParserSpan, endianness: Endianness, byteCount: Int @@ -492,7 +469,6 @@ extension FixedWidthInteger where Self: BitwiseCopyable { /// bytes, if the parsed value overflows this integer type, or if the /// padding bytes are invalid. @inlinable - @_lifetime(&input) public init( parsing input: inout ParserSpan, endianness: Endianness, byteCount: Int ) throws(ParsingError) { @@ -502,7 +478,6 @@ extension FixedWidthInteger where Self: BitwiseCopyable { @unsafe @inlinable - @_lifetime(&input) public init( _unchecked _: Void, parsing input: inout ParserSpan, @@ -537,7 +512,6 @@ extension FixedWidthInteger where Self: BitwiseCopyable { /// `storageType`, or if converting the parsed value to this integer type /// overflows. @inlinable - @_lifetime(&input) public init( parsing input: inout ParserSpan, storedAsBigEndian storageType: T.Type @@ -548,7 +522,6 @@ extension FixedWidthInteger where Self: BitwiseCopyable { @unsafe @inlinable - @_lifetime(&input) public init( _unchecked _: Void, parsing input: inout ParserSpan, @@ -583,7 +556,6 @@ extension FixedWidthInteger where Self: BitwiseCopyable { /// `storageType`, or if converting the parsed value to this integer type /// overflows. @inlinable - @_lifetime(&input) public init( parsing input: inout ParserSpan, storedAsLittleEndian storageType: T.Type @@ -594,7 +566,6 @@ extension FixedWidthInteger where Self: BitwiseCopyable { @unsafe @inlinable - @_lifetime(&input) public init( _unchecked _: Void, parsing input: inout ParserSpan, @@ -634,7 +605,6 @@ extension FixedWidthInteger where Self: BitwiseCopyable { /// `storageType`, or if converting the parsed value to this integer type /// overflows. @inlinable - @_lifetime(&input) public init( parsing input: inout ParserSpan, storedAs storageType: T.Type, @@ -649,7 +619,6 @@ extension FixedWidthInteger where Self: BitwiseCopyable { @unsafe @inlinable - @_lifetime(&input) public init( _unchecked _: Void, parsing input: inout ParserSpan, @@ -684,7 +653,6 @@ extension FixedWidthInteger where Self: BitwiseCopyable { /// `storageType`, or if converting the parsed value to this integer type /// overflows. @inlinable - @_lifetime(&input) public init( parsing input: inout ParserSpan, storedAs storageType: T.Type @@ -709,7 +677,6 @@ extension FixedWidthInteger where Self: BitwiseCopyable { /// - Throws: A `ParsingError` if `input` overflows the max value of this integer type, /// or if the maximum byte count for this type's size has been consumed. @inlinable - @_lifetime(&input) public init(parsingLEB128 input: inout ParserSpan) throws(ParsingError) { var result: Self = 0 var shift = 0 @@ -780,20 +747,17 @@ extension FixedWidthInteger where Self: BitwiseCopyable { extension RawRepresentable where RawValue: MultiByteInteger { @inlinable - @_lifetime(&input) public init(parsingBigEndian input: inout ParserSpan) throws(ParsingError) { self = try Self(_rawValueThrowing: .init(parsingBigEndian: &input)) } @inlinable - @_lifetime(&input) public init(parsingLittleEndian input: inout ParserSpan) throws(ParsingError) { self = try Self(_rawValueThrowing: .init(parsingLittleEndian: &input)) } @inlinable - @_lifetime(&input) public init(parsing input: inout ParserSpan, endianness: Endianness) throws(ParsingError) { @@ -805,7 +769,6 @@ extension RawRepresentable where RawValue: MultiByteInteger { extension RawRepresentable where RawValue: SingleByteInteger { @inlinable - @_lifetime(&input) public init(parsing input: inout ParserSpan) throws(ParsingError) { guard let value = try Self(rawValue: .init(_parsingBigEndian: &input)) else { @@ -829,7 +792,6 @@ extension RawRepresentable where RawValue: FixedWidthInteger & BitwiseCopyable { } @inlinable - @_lifetime(&input) public init( parsing input: inout ParserSpan, storedAsBigEndian storageType: T.Type @@ -840,7 +802,6 @@ extension RawRepresentable where RawValue: FixedWidthInteger & BitwiseCopyable { } @inlinable - @_lifetime(&input) public init( parsing input: inout ParserSpan, storedAsLittleEndian storageType: T.Type @@ -851,7 +812,6 @@ extension RawRepresentable where RawValue: FixedWidthInteger & BitwiseCopyable { } @inlinable - @_lifetime(&input) public init( parsing input: inout ParserSpan, storedAs: T.Type, @@ -863,7 +823,6 @@ extension RawRepresentable where RawValue: FixedWidthInteger & BitwiseCopyable { } @inlinable - @_lifetime(&input) public init( parsing input: inout ParserSpan, storedAs: T.Type diff --git a/Sources/BinaryParsing/Parsers/Range.swift b/Sources/BinaryParsing/Parsers/Range.swift index 890e1fc..2c97bfe 100644 --- a/Sources/BinaryParsing/Parsers/Range.swift +++ b/Sources/BinaryParsing/Parsers/Range.swift @@ -25,7 +25,6 @@ extension Range where Bound: FixedWidthInteger { /// - input: The `ParserSpan` to parse from. /// - parser: The closure to use when parsing the start and count. /// - Throws: An error if `parser` throws an error. - @_lifetime(&input) public init( parsingStartAndCount input: inout ParserSpan, parser: (inout ParserSpan) throws -> Bound @@ -53,7 +52,6 @@ extension Range where Bound: FixedWidthInteger { /// - input: The `ParserSpan` to parse from. /// - parser: The closure to use when parsing the start and count. /// - Throws: An error if `parser` throws an error. - @_lifetime(&input) public init( parsingStartAndCount input: inout ParserSpan, parser: (inout ParserSpan) throws(ParsingError) -> Bound @@ -76,7 +74,6 @@ extension ClosedRange where Bound: FixedWidthInteger { message: "The behavior of this parser is unintuitive; instead, parse the start and count separately, then form the end of the closed range." ) - @_lifetime(&_input) public init( parsingStartAndCount _input: inout ParserSpan, parser: (inout ParserSpan) throws -> Bound @@ -97,7 +94,6 @@ extension ClosedRange where Bound: FixedWidthInteger { message: "The behavior of this parser is unintuitive; instead, parse the start and count separately, then form the end of the closed range." ) - @_lifetime(&_input) public init( parsingStartAndCount _input: inout ParserSpan, parser: (inout ParserSpan) throws(ParsingError) -> Bound @@ -129,7 +125,6 @@ extension Range { /// - input: The `ParserSpan` to parse from. /// - parser: The closure to use when parsing the start and end. /// - Throws: An error if `parser` throws an error. - @_lifetime(&input) public init( parsingStartAndEnd input: inout ParserSpan, boundsParser parser: (inout ParserSpan) throws -> Bound @@ -157,7 +152,6 @@ extension Range { /// - input: The `ParserSpan` to parse from. /// - parser: The closure to use when parsing the start and end. /// - Throws: An error if `parser` throws an error. - @_lifetime(&input) public init( parsingStartAndEnd input: inout ParserSpan, boundsParser parser: (inout ParserSpan) throws(ParsingError) -> Bound @@ -187,7 +181,6 @@ extension ClosedRange { /// - input: The `ParserSpan` to parse from. /// - parser: The closure to use when parsing the start and end. /// - Throws: An error if `parser` throws an error. - @_lifetime(&input) public init( parsingStartAndEnd input: inout ParserSpan, boundsParser parser: (inout ParserSpan) throws -> Bound @@ -215,7 +208,6 @@ extension ClosedRange { /// - input: The `ParserSpan` to parse from. /// - parser: The closure to use when parsing the start and end. /// - Throws: An error if `parser` throws an error. - @_lifetime(&input) public init( parsingStartAndEnd input: inout ParserSpan, boundsParser parser: (inout ParserSpan) throws(ParsingError) -> Bound diff --git a/Sources/BinaryParsing/Parsers/String.swift b/Sources/BinaryParsing/Parsers/String.swift index a67a463..28aae71 100644 --- a/Sources/BinaryParsing/Parsers/String.swift +++ b/Sources/BinaryParsing/Parsers/String.swift @@ -15,7 +15,6 @@ extension String { /// The bytes of the string and the NUL are all consumed from `input`. This /// initializer throws an error if `input` does not contain a NUL byte. @inlinable - @_lifetime(&input) public init(parsingNulTerminated input: inout ParserSpan) throws(ParsingError) { guard @@ -35,7 +34,6 @@ extension String { /// code units are repaired by replacing with the Unicode replacement /// character `U+FFFD`. @inlinable - @_lifetime(&input) public init(parsingUTF8 input: inout ParserSpan) { let stringBytes = input.divide(at: input.endPosition) self = unsafe stringBytes.withUnsafeBytes { buffer in @@ -50,7 +48,6 @@ extension String { /// required by `count`. Any invalid UTF-8 code units are repaired by /// replacing with the Unicode replacement character `U+FFFD`. @inlinable - @_lifetime(&input) public init(parsingUTF8 input: inout ParserSpan, count: Int) throws(ParsingError) { @@ -60,7 +57,6 @@ extension String { @unsafe @inlinable - @_lifetime(&input) internal init(_uncheckedParsingUTF16 input: inout ParserSpan) throws(ParsingError) { @@ -78,7 +74,6 @@ extension String { /// units or incomplete surrogate pairs are repaired by replacing with the /// Unicode replacement character `U+FFFD`. @inlinable - @_lifetime(&input) public init(parsingUTF16 input: inout ParserSpan) throws(ParsingError) { guard input.count.isMultiple(of: 2) else { throw ParsingError(status: .invalidValue, location: input.startPosition) @@ -101,7 +96,6 @@ extension String { /// - Throws: A `ParsingError` if `input` doesn't have at least /// `2 * codeUnitCount` bytes remaining. @inlinable - @_lifetime(&input) public init(parsingUTF16 input: inout ParserSpan, codeUnitCount: Int) throws(ParsingError) { diff --git a/Tests/BinaryParsingTests/OptimizationTests.swift b/Tests/BinaryParsingTests/OptimizationTests.swift index 30d47f9..1b0f9d6 100644 --- a/Tests/BinaryParsingTests/OptimizationTests.swift +++ b/Tests/BinaryParsingTests/OptimizationTests.swift @@ -24,7 +24,6 @@ private let data: [UInt8] = [ ] struct OptimizationTests { - @_lifetime(&input) func precheckParseFour(parsing input: inout ParserSpan) throws -> Int { try input._checkCount(minimum: 16) let a = UInt32(_unchecked: (), parsingBigEndian: &input) @@ -34,7 +33,6 @@ struct OptimizationTests { return Int(a + b + c + d) } - @_lifetime(&input) func parseFour(parsing input: inout ParserSpan) throws -> Int { let a = try UInt32(parsingBigEndian: &input) let b = try UInt32(parsingBigEndian: &input)