Skip to content

Commit dc5e9f5

Browse files
committed
Add some missing @lifetime attributes
We were relying on infererred lifetimes by accident — it’s better to spell things out for now.
1 parent 21169d1 commit dc5e9f5

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

stdlib/public/core/Optional.swift

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -365,6 +365,7 @@ extension Optional where Wrapped: ~Escapable {
365365
extension Optional where Wrapped: ~Copyable & ~Escapable {
366366
// FIXME(NCG): Do we want this? It seems like we do. Make this public.
367367
@_alwaysEmitIntoClient
368+
@lifetime(copy self)
368369
public consuming func _consumingUnsafelyUnwrap() -> Wrapped {
369370
switch consume self {
370371
case .some(let x):
@@ -384,6 +385,7 @@ extension Optional where Wrapped: ~Escapable {
384385
@_preInverseGenerics
385386
internal var _unsafelyUnwrappedUnchecked: Wrapped {
386387
@inline(__always)
388+
@lifetime(copy self)
387389
get {
388390
if let x = self {
389391
return x
@@ -476,11 +478,13 @@ extension Optional: CustomReflectable {
476478

477479
@_transparent
478480
public // COMPILER_INTRINSIC
479-
func _diagnoseUnexpectedNilOptional(_filenameStart: Builtin.RawPointer,
480-
_filenameLength: Builtin.Word,
481-
_filenameIsASCII: Builtin.Int1,
482-
_line: Builtin.Word,
483-
_isImplicitUnwrap: Builtin.Int1) {
481+
func _diagnoseUnexpectedNilOptional(
482+
_filenameStart: Builtin.RawPointer,
483+
_filenameLength: Builtin.Word,
484+
_filenameIsASCII: Builtin.Int1,
485+
_line: Builtin.Word,
486+
_isImplicitUnwrap: Builtin.Int1
487+
) {
484488
// Cannot use _preconditionFailure as the file and line info would not be
485489
// printed.
486490
if Bool(_isImplicitUnwrap) {

stdlib/public/core/Result.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,7 @@ extension Result where Success: ~Copyable & ~Escapable {
138138
/// - Returns: A `Result` instance with the result of evaluating `transform`
139139
/// as the new failure value if this instance represents a failure.
140140
@_alwaysEmitIntoClient
141+
@lifetime(copy self)
141142
public consuming func mapError<NewFailure>(
142143
_ transform: (Failure) -> NewFailure
143144
) -> Result<Success, NewFailure> {

0 commit comments

Comments
 (0)