Skip to content

Commit 8d86093

Browse files
authored
Merge pull request #81225 from glessard/override-lifetime-publicly-6.2
[6.2, stdlib] make _overrideLifetime() functions public
2 parents c3b1e97 + ca8fc0e commit 8d86093

10 files changed

+3
-256
lines changed

stdlib/public/core/LifetimeManager.swift

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -290,13 +290,11 @@ public func _copy<T>(_ value: T) -> T {
290290
@_alwaysEmitIntoClient
291291
@_transparent
292292
@lifetime(borrow source)
293-
internal func _overrideLifetime<
293+
public func _overrideLifetime<
294294
T: ~Copyable & ~Escapable, U: ~Copyable & ~Escapable
295295
>(
296296
_ dependent: consuming T, borrowing source: borrowing U
297297
) -> T {
298-
// TODO: Remove @_unsafeNonescapableResult. Instead, the unsafe dependence
299-
// should be expressed by a builtin that is hidden within the function body.
300298
dependent
301299
}
302300

@@ -308,13 +306,11 @@ internal func _overrideLifetime<
308306
@_alwaysEmitIntoClient
309307
@_transparent
310308
@lifetime(copy source)
311-
internal func _overrideLifetime<
309+
public func _overrideLifetime<
312310
T: ~Copyable & ~Escapable, U: ~Copyable & ~Escapable
313311
>(
314312
_ dependent: consuming T, copying source: borrowing U
315313
) -> T {
316-
// TODO: Remove @_unsafeNonescapableResult. Instead, the unsafe dependence
317-
// should be expressed by a builtin that is hidden within the function body.
318314
dependent
319315
}
320316

@@ -326,13 +322,11 @@ internal func _overrideLifetime<
326322
@_alwaysEmitIntoClient
327323
@_transparent
328324
@lifetime(&source)
329-
internal func _overrideLifetime<
325+
public func _overrideLifetime<
330326
T: ~Copyable & ~Escapable, U: ~Copyable & ~Escapable
331327
>(
332328
_ dependent: consuming T,
333329
mutating source: inout U
334330
) -> T {
335-
// TODO: Remove @_unsafeNonescapableResult. Instead, the unsafe dependence
336-
// should be expressed by a builtin that is hidden within the function body.
337331
dependent
338332
}

test/ModuleInterface/Inputs/lifetime_dependence.swift

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,3 @@
1-
@_unsafeNonescapableResult
2-
@_alwaysEmitIntoClient
3-
@_transparent
4-
@lifetime(borrow source)
5-
internal func _overrideLifetime<T: ~Copyable & ~Escapable, U: ~Copyable & ~Escapable>(
6-
_ dependent: consuming T, borrowing source: borrowing U) -> T {
7-
dependent
8-
}
9-
10-
@_unsafeNonescapableResult
11-
@_alwaysEmitIntoClient
12-
@_transparent
13-
@lifetime(copy source)
14-
internal func _overrideLifetime<T: ~Copyable & ~Escapable, U: ~Copyable & ~Escapable>(
15-
_ dependent: consuming T, copying source: borrowing U) -> T {
16-
dependent
17-
}
18-
191
public struct AnotherView : ~Escapable {
202
@usableFromInline let _ptr: UnsafeRawBufferPointer
213
@usableFromInline let _count: Int

test/SIL/explicit_lifetime_dependence_specifiers.swift

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -8,30 +8,6 @@
88

99
import Builtin
1010

11-
@_unsafeNonescapableResult
12-
@lifetime(borrow source)
13-
internal func _overrideLifetime<
14-
T: ~Copyable & ~Escapable, U: ~Copyable & ~Escapable
15-
>(
16-
_ dependent: consuming T, borrowing source: borrowing U
17-
) -> T {
18-
// TODO: Remove @_unsafeNonescapableResult. Instead, the unsafe dependence
19-
// should be expressed by a builtin that is hidden within the function body.
20-
dependent
21-
}
22-
23-
@_unsafeNonescapableResult
24-
@lifetime(copy source)
25-
internal func _overrideLifetime<
26-
T: ~Copyable & ~Escapable, U: ~Copyable & ~Escapable
27-
>(
28-
_ dependent: consuming T, copying source: borrowing U
29-
) -> T {
30-
// TODO: Remove @_unsafeNonescapableResult. Instead, the unsafe dependence
31-
// should be expressed by a builtin that is hidden within the function body.
32-
dependent
33-
}
34-
3511
struct BufferView : ~Escapable {
3612
let ptr: UnsafeRawBufferPointer
3713
// CHECK-LABEL: sil hidden @$s39explicit_lifetime_dependence_specifiers10BufferViewVyACSWcfC : $@convention(method) (UnsafeRawBufferPointer, @thin BufferView.Type) -> @lifetime(borrow 0) @owned BufferView {

test/SIL/implicit_lifetime_dependence.swift

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -5,30 +5,6 @@
55

66
// REQUIRES: swift_feature_LifetimeDependence
77

8-
@_unsafeNonescapableResult
9-
@lifetime(borrow source)
10-
internal func _overrideLifetime<
11-
T: ~Copyable & ~Escapable, U: ~Copyable & ~Escapable
12-
>(
13-
_ dependent: consuming T, borrowing source: borrowing U
14-
) -> T {
15-
// TODO: Remove @_unsafeNonescapableResult. Instead, the unsafe dependence
16-
// should be expressed by a builtin that is hidden within the function body.
17-
dependent
18-
}
19-
20-
@_unsafeNonescapableResult
21-
@lifetime(copy source)
22-
internal func _overrideLifetime<
23-
T: ~Copyable & ~Escapable, U: ~Copyable & ~Escapable
24-
>(
25-
_ dependent: consuming T, copying source: borrowing U
26-
) -> T {
27-
// TODO: Remove @_unsafeNonescapableResult. Instead, the unsafe dependence
28-
// should be expressed by a builtin that is hidden within the function body.
29-
dependent
30-
}
31-
328
struct BufferView : ~Escapable {
339
let ptr: UnsafeRawBufferPointer
3410
let c: Int

test/SIL/lifetime_dependence_span_lifetime_attr.swift

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -5,30 +5,6 @@
55
// REQUIRES: swift_in_compiler
66
// REQUIRES: swift_feature_LifetimeDependence
77

8-
@_unsafeNonescapableResult
9-
@lifetime(borrow source)
10-
internal func _overrideLifetime<
11-
T: ~Copyable & ~Escapable, U: ~Copyable & ~Escapable
12-
>(
13-
_ dependent: consuming T, borrowing source: borrowing U
14-
) -> T {
15-
// TODO: Remove @_unsafeNonescapableResult. Instead, the unsafe dependence
16-
// should be expressed by a builtin that is hidden within the function body.
17-
dependent
18-
}
19-
20-
@_unsafeNonescapableResult
21-
@lifetime(copy source)
22-
internal func _overrideLifetime<
23-
T: ~Copyable & ~Escapable, U: ~Copyable & ~Escapable
24-
>(
25-
_ dependent: consuming T, copying source: borrowing U
26-
) -> T {
27-
// TODO: Remove @_unsafeNonescapableResult. Instead, the unsafe dependence
28-
// should be expressed by a builtin that is hidden within the function body.
29-
dependent
30-
}
31-
328
// TODO: Use real Range
339
public struct FakeRange<Bound> {
3410
public let lowerBound: Bound

test/SILOptimizer/Inputs/SpanExtras.swift

Lines changed: 0 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -1,56 +1,5 @@
11
import Builtin
22

3-
/// Unsafely discard any lifetime dependency on the `dependent` argument. Return
4-
/// a value identical to `dependent` with a lifetime dependency on the caller's
5-
/// borrow scope of the `source` argument.
6-
@unsafe
7-
@_unsafeNonescapableResult
8-
@_alwaysEmitIntoClient
9-
@_transparent
10-
@lifetime(borrow source)
11-
internal func _overrideLifetime<
12-
T: ~Copyable & ~Escapable, U: ~Copyable & ~Escapable
13-
>(
14-
_ dependent: consuming T, borrowing source: borrowing U
15-
) -> T {
16-
// TODO: Remove @_unsafeNonescapableResult. Instead, the unsafe dependence
17-
// should be expressed by a builtin that is hidden within the function body.
18-
dependent
19-
}
20-
21-
/// Unsafely discard any lifetime dependency on the `dependent` argument. Return
22-
/// a value identical to `dependent` that inherits all lifetime dependencies from
23-
/// the `source` argument.
24-
@unsafe
25-
@_unsafeNonescapableResult
26-
@_alwaysEmitIntoClient
27-
@_transparent
28-
@lifetime(copy source)
29-
internal func _overrideLifetime<
30-
T: ~Copyable & ~Escapable, U: ~Copyable & ~Escapable
31-
>(
32-
_ dependent: consuming T, copying source: borrowing U
33-
) -> T {
34-
// TODO: Remove @_unsafeNonescapableResult. Instead, the unsafe dependence
35-
// should be expressed by a builtin that is hidden within the function body.
36-
dependent
37-
}
38-
39-
@unsafe
40-
@_unsafeNonescapableResult
41-
@_alwaysEmitIntoClient
42-
@_transparent
43-
@lifetime(&source)
44-
internal func _overrideLifetime<
45-
T: ~Copyable & ~Escapable, U: ~Copyable & ~Escapable
46-
>(
47-
_ dependent: consuming T, mutating source: inout U
48-
) -> T {
49-
// TODO: Remove @_unsafeNonescapableResult. Instead, the unsafe dependence
50-
// should be expressed by a builtin that is hidden within the function body.
51-
dependent
52-
}
53-
543
// A MutableSpan<Element> represents a span of memory which
554
// contains initialized `Element` instances.
565
@frozen

test/SILOptimizer/addressable_dependencies.swift

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,6 @@
66

77
import Builtin
88

9-
// Copied from the stdlib until we have Builtin.overrideLifetime.
10-
@_unsafeNonescapableResult
11-
@lifetime(borrow source)
12-
internal func _overrideLifetime<T: ~Copyable & ~Escapable, U: ~Copyable & ~Escapable>(
13-
_ dependent: consuming T, borrowing source: borrowing U) -> T {
14-
dependent
15-
}
16-
179
struct NodeRef: ~Escapable {
1810
private var parent: UnsafePointer<Node>
1911

test/SILOptimizer/lifetime_dependence/dependence_insertion.swift

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -17,19 +17,6 @@
1717

1818
import Builtin
1919

20-
@unsafe
21-
@_unsafeNonescapableResult
22-
@_alwaysEmitIntoClient
23-
@_transparent
24-
@lifetime(borrow source)
25-
internal func _overrideLifetime<
26-
T: ~Copyable & ~Escapable, U: ~Copyable & ~Escapable
27-
>(
28-
_ dependent: consuming T, borrowing source: borrowing U
29-
) -> T {
30-
dependent
31-
}
32-
3320
struct BV : ~Escapable {
3421
let p: UnsafeRawPointer
3522
let i: Int

test/SILOptimizer/lifetime_dependence/lifetime_dependence_mutate.swift

Lines changed: 0 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -8,48 +8,6 @@
88
// REQUIRES: swift_in_compiler
99
// REQUIRES: swift_feature_LifetimeDependence
1010

11-
/// Unsafely discard any lifetime dependency on the `dependent` argument. Return
12-
/// a value identical to `dependent` with a lifetime dependency on the caller's
13-
/// borrow scope of the `source` argument.
14-
@_unsafeNonescapableResult
15-
@_transparent
16-
@lifetime(borrow source)
17-
internal func _overrideLifetime<
18-
T: ~Copyable & ~Escapable, U: ~Copyable & ~Escapable
19-
>(
20-
_ dependent: consuming T, borrowing source: borrowing U
21-
) -> T {
22-
dependent
23-
}
24-
25-
/// Unsafely discard any lifetime dependency on the `dependent` argument. Return
26-
/// a value identical to `dependent` that inherits all lifetime dependencies from
27-
/// the `source` argument.
28-
@_unsafeNonescapableResult
29-
@_transparent
30-
@lifetime(copy source)
31-
internal func _overrideLifetime<
32-
T: ~Copyable & ~Escapable, U: ~Copyable & ~Escapable
33-
>(
34-
_ dependent: consuming T, copying source: borrowing U
35-
) -> T {
36-
dependent
37-
}
38-
39-
/// Unsafely discard any lifetime dependency on the `dependent` argument. Return
40-
/// a value identical to `dependent` that inherits all lifetime dependencies from
41-
/// the `source` argument.
42-
@_unsafeNonescapableResult
43-
@_transparent
44-
@lifetime(&source)
45-
internal func _overrideLifetime<
46-
T: ~Copyable & ~Escapable, U: ~Copyable & ~Escapable
47-
>(
48-
_ dependent: consuming T, mutating source: inout U
49-
) -> T {
50-
dependent
51-
}
52-
5311
struct MutableSpan : ~Escapable, ~Copyable {
5412
let base: UnsafeMutableRawPointer
5513
let count: Int

test/SILOptimizer/lifetime_dependence/semantics.swift

Lines changed: 0 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -15,49 +15,6 @@
1515

1616
import Builtin
1717

18-
@_unsafeNonescapableResult
19-
@_transparent
20-
@lifetime(borrow source)
21-
internal func _overrideLifetime<
22-
T: ~Copyable & ~Escapable, U: ~Copyable & ~Escapable
23-
>(
24-
_ dependent: consuming T, borrowing source: borrowing U
25-
) -> T {
26-
// TODO: Remove @_unsafeNonescapableResult. Instead, the unsafe dependence
27-
// should be expressed by a builtin that is hidden within the function body.
28-
dependent
29-
}
30-
31-
/// Unsafely discard any lifetime dependency on the `dependent` argument. Return
32-
/// a value identical to `dependent` that inherits all lifetime dependencies from
33-
/// the `source` argument.
34-
@_unsafeNonescapableResult
35-
@_transparent
36-
@lifetime(copy source)
37-
internal func _overrideLifetime<
38-
T: ~Copyable & ~Escapable, U: ~Copyable & ~Escapable
39-
>(
40-
_ dependent: consuming T, copying source: borrowing U
41-
) -> T {
42-
// TODO: Remove @_unsafeNonescapableResult. Instead, the unsafe dependence
43-
// should be expressed by a builtin that is hidden within the function body.
44-
dependent
45-
}
46-
47-
/// Unsafely discard any lifetime dependency on the `dependent` argument. Return
48-
/// a value identical to `dependent` that inherits all lifetime dependencies from
49-
/// the `source` argument.
50-
@_unsafeNonescapableResult
51-
@_transparent
52-
@lifetime(&source)
53-
internal func _overrideLifetime<
54-
T: ~Copyable & ~Escapable, U: ~Copyable & ~Escapable
55-
>(
56-
_ dependent: consuming T, mutating source: inout U
57-
) -> T {
58-
dependent
59-
}
60-
6118
struct NotEscapable: ~Escapable {}
6219

6320
// Lifetime dependence semantics by example.

0 commit comments

Comments
 (0)