Skip to content

Commit de418a4

Browse files
committed
[NFC] Update tests
1 parent e4b6ce7 commit de418a4

10 files changed

+44
-38
lines changed

test/SILOptimizer/Inputs/SpanExtras.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ internal func _overrideLifetime<
4040
@_unsafeNonescapableResult
4141
@_alwaysEmitIntoClient
4242
@_transparent
43-
@lifetime(borrow source)
43+
@lifetime(&source)
4444
internal func _overrideLifetime<
4545
T: ~Copyable & ~Escapable, U: ~Copyable & ~Escapable
4646
>(
@@ -310,7 +310,7 @@ extension MutableSpan where Element: ~Copyable {
310310
precondition(indices.contains(position), "index out of bounds")
311311
yield self[unchecked: position]
312312
}
313-
@lifetime(borrow self)
313+
@lifetime(&self)
314314
_modify {
315315
precondition(indices.contains(position), "index out of bounds")
316316
yield &self[unchecked: position]

test/SILOptimizer/lifetime_dependence/lifetime_dependence_diagnostics.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ public struct NEInt: ~Escapable {
3939
var iprop: NEInt {
4040
@lifetime(copy self)
4141
_read { yield self }
42-
@lifetime(borrow self)
42+
@lifetime(&self)
4343
_modify { yield &self }
4444
}
4545

test/SILOptimizer/lifetime_dependence/lifetime_dependence_mutate.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ internal func _overrideLifetime<
4141
/// the `source` argument.
4242
@_unsafeNonescapableResult
4343
@_transparent
44-
@lifetime(borrow source)
44+
@lifetime(&source)
4545
internal func _overrideLifetime<
4646
T: ~Copyable & ~Escapable, U: ~Copyable & ~Escapable
4747
>(
@@ -112,7 +112,7 @@ struct NC : ~Copyable {
112112
let c: Int
113113

114114
// Requires a mutable borrow.
115-
@lifetime(borrow self)
115+
@lifetime(&self)
116116
mutating func getMutableSpan() -> MutableSpan {
117117
MutableSpan(p, c)
118118
}

test/SILOptimizer/lifetime_dependence/semantics.swift

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ internal func _overrideLifetime<
4949
/// the `source` argument.
5050
@_unsafeNonescapableResult
5151
@_transparent
52-
@lifetime(borrow source)
52+
@lifetime(&source)
5353
internal func _overrideLifetime<
5454
T: ~Copyable & ~Escapable, U: ~Copyable & ~Escapable
5555
>(
@@ -110,7 +110,7 @@ struct MutableSpan<T>: ~Escapable, ~Copyable {
110110
let base: UnsafeMutablePointer<T>
111111
let count: Int
112112

113-
@lifetime(borrow base)
113+
@lifetime(&base)
114114
init(base: UnsafeMutablePointer<T>, count: Int) {
115115
self.base = base
116116
self.count = count
@@ -128,7 +128,7 @@ extension Array {
128128
}
129129

130130
extension Array {
131-
@lifetime(borrow self)
131+
@lifetime(&self)
132132
mutating func mutableSpan() -> MutableSpan<Element> {
133133
/* not the real implementation */
134134
let p = self.withUnsafeMutableBufferPointer { $0.baseAddress! }
@@ -263,7 +263,7 @@ struct MutableView: ~Escapable, ~Copyable {
263263
self.owner = copy owner // OK
264264
}
265265

266-
@lifetime(borrow mutableOwner)
266+
@lifetime(&mutableOwner)
267267
init(mutableOwner: inout AnyObject) {
268268
// Initialization of a ~Escapable value is unenforced. So we can initialize
269269
// the `owner` property without locally borrowing `mutableOwner`.
@@ -432,13 +432,13 @@ func testGlobal(local: InnerTrivial) -> Span<Int> {
432432
// Scoped dependence on mutable values
433433
// =============================================================================
434434

435-
@lifetime(borrow a)
435+
@lifetime(&a)
436436
func testInoutBorrow(a: inout [Int]) -> Span<Int> {
437437
a.span() // expected-error {{lifetime-dependent value escapes its scope}}
438438
// expected-note @-1{{it depends on this scoped access to variable 'a'}}
439439
} // expected-note {{this use causes the lifetime-dependent value to escape}}
440440

441-
@lifetime(borrow a)
441+
@lifetime(&a)
442442
func testInoutMutableBorrow(a: inout [Int]) -> MutableSpan<Int> {
443443
a.mutableSpan()
444444
}
@@ -460,7 +460,7 @@ extension Container {
460460
View(owner: self.owner) // OK
461461
}
462462

463-
@lifetime(borrow self)
463+
@lifetime(&self)
464464
mutating func mutableView() -> MutableView {
465465
// Reading 'self.owner' creates a local borrow scope. This new MutableView
466466
// depends on a the local borrow scope for 'self.owner', so it cannot be
@@ -469,15 +469,15 @@ extension Container {
469469
// expected-note @-1{{it depends on this scoped access to variable 'self'}}
470470
} // expected-note {{this use causes the lifetime-dependent value to escape}}
471471

472-
@lifetime(borrow self)
472+
@lifetime(&self)
473473
mutating func mutableViewModifiesOwner() -> MutableView {
474474
// Passing '&self.owner' inout creates a nested exclusive access that must extend to all uses of the new
475475
// MutableView. This is allowed because the nested access is logically extended to the end of the function (without
476476
// violating exclusivity).
477477
MutableView(mutableOwner: &self.owner)
478478
}
479479

480-
@lifetime(borrow self)
480+
@lifetime(&self)
481481
mutating func mutableSpan() -> MutableSpan<T> {
482482
// Reading 'self.pointer' creates a local borrow scope. The local borrow
483483
// scope is ignored because 'pointer' is a trivial value. Instead, the new

test/Sema/Inputs/lifetime_depend_infer.swiftinterface

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public struct NonEscapableSelf : ~Swift.Escapable {
4040
public mutating func mutatingMethodNoParamCopy() -> lifetime_depend_infer.NonEscapableSelf
4141
#endif
4242
#if $LifetimeDependence
43-
@lifetime(borrow self)
43+
@lifetime(&self)
4444
public mutating func mutatingMethodNoParamBorrow() -> lifetime_depend_infer.NonEscapableSelf
4545
#endif
4646
#if $LifetimeDependence
@@ -67,7 +67,7 @@ public struct NonEscapableSelf : ~Swift.Escapable {
6767
public mutating func mutatingMethodOneParamCopy(_: Swift.Int) -> lifetime_depend_infer.NonEscapableSelf
6868
#endif
6969
#if $LifetimeDependence
70-
@lifetime(borrow self)
70+
@lifetime(&self)
7171
public mutating func mutatingMethodOneParamBorrow(_: Swift.Int) -> lifetime_depend_infer.NonEscapableSelf
7272
#endif
7373
}
@@ -85,7 +85,7 @@ public struct EscapableTrivialSelf {
8585
public mutating func mutatingMethodNoParamLifetime() -> lifetime_depend_infer.NEImmortal
8686
#endif
8787
#if compiler(>=5.3) && $NonescapableTypes && $LifetimeDependence
88-
@lifetime(borrow self)
88+
@lifetime(&self)
8989
public mutating func mutatingMethodNoParamBorrow() -> lifetime_depend_infer.NEImmortal
9090
#endif
9191
#if compiler(>=5.3) && $NonescapableTypes && $LifetimeDependence
@@ -101,7 +101,7 @@ public struct EscapableTrivialSelf {
101101
public mutating func mutatingMethodOneParamLifetime(_: Swift.Int) -> lifetime_depend_infer.NEImmortal
102102
#endif
103103
#if compiler(>=5.3) && $NonescapableTypes && $LifetimeDependence
104-
@lifetime(borrow self)
104+
@lifetime(&self)
105105
public mutating func mutatingMethodOneParamBorrow(_: Swift.Int) -> lifetime_depend_infer.NEImmortal
106106
#endif
107107
}
@@ -126,7 +126,7 @@ public struct EscapableNonTrivialSelf {
126126
public mutating func mutatingMethodNoParamLifetime() -> lifetime_depend_infer.NEImmortal
127127
#endif
128128
#if compiler(>=5.3) && $NonescapableTypes && $LifetimeDependence
129-
@lifetime(borrow self)
129+
@lifetime(&self)
130130
public mutating func mutatingMethodNoParamBorrow() -> lifetime_depend_infer.NEImmortal
131131
#endif
132132
#if compiler(>=5.3) && $NonescapableTypes && $LifetimeDependence
@@ -148,7 +148,7 @@ public struct EscapableNonTrivialSelf {
148148
public mutating func mutatingMethodOneParamLifetime(_: Swift.Int) -> lifetime_depend_infer.NEImmortal
149149
#endif
150150
#if compiler(>=5.3) && $NonescapableTypes && $LifetimeDependence
151-
@lifetime(borrow self)
151+
@lifetime(&self)
152152
public mutating func mutatingMethodOneParamBorrow(_: Swift.Int) -> lifetime_depend_infer.NEImmortal
153153
#endif
154154
}
@@ -256,7 +256,7 @@ public struct NonescapableSelfAccessors : ~Swift.Escapable {
256256
#if $LifetimeDependence
257257
public var neYielded: lifetime_depend_infer.NE {
258258
_read
259-
@lifetime(borrow self)
259+
@lifetime(&self)
260260
_modify
261261
}
262262
#endif
@@ -272,7 +272,7 @@ public struct NoncopyableSelfAccessors : ~Copyable & ~Escapable {
272272
#if $LifetimeDependence
273273
public var neYielded: lifetime_depend_infer.NE {
274274
_read
275-
@lifetime(borrow self)
275+
@lifetime(&self)
276276
_modify
277277
}
278278
#endif
@@ -312,15 +312,15 @@ public struct NoncopyableSelfAccessors : ~Copyable & ~Escapable {
312312
public var neComputedBorrow: lifetime_depend_infer.NE {
313313
@lifetime(borrow self)
314314
get
315-
@lifetime(borrow self)
315+
@lifetime(&self)
316316
set
317317
}
318318
#endif
319319
#if $LifetimeDependence
320320
public var neYieldedBorrow: lifetime_depend_infer.NE {
321321
@lifetime(borrow self)
322322
_read
323-
@lifetime(borrow self)
323+
@lifetime(&self)
324324
_modify
325325
}
326326
#endif
@@ -346,7 +346,7 @@ public struct NonEscapableMutableSelf : ~Swift.Escapable {
346346
public mutating func mutatingMethodOneParamCopy(_: lifetime_depend_infer.NE)
347347
#endif
348348
#if $LifetimeDependence
349-
@lifetime(borrow self)
349+
@lifetime(&self)
350350
public mutating func mutatingMethodOneParamBorrow(_: lifetime_depend_infer.NE)
351351
#endif
352352
}

test/Sema/lifetime_attr.swift

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,3 +63,9 @@ do {
6363
// rdar://146401190 ([nonescapable] implement non-inout parameter dependencies)
6464
@lifetime(span: borrow holder)
6565
func testParameterDep(holder: AnyObject, span: Span<Int>) {} // expected-error{{lifetime-dependent parameter must be 'inout'}}
66+
67+
@lifetime(&ne)
68+
func inoutLifetimeDependence(_ ne: inout NE) -> NE {
69+
ne
70+
}
71+

test/Sema/lifetime_depend_infer.swift

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ struct EscapableNonTrivialSelf {
137137
@lifetime(copy self) // expected-error{{cannot copy the lifetime of an Escapable type, use '@lifetime(borrow self)' instead}}
138138
mutating func mutatingMethodNoParamCopy() -> NEImmortal { NEImmortal() }
139139

140-
@lifetime(borrow self)
140+
@lifetime(&self)
141141
mutating func mutatingMethodNoParamBorrow() -> NEImmortal { NEImmortal() }
142142

143143
func methodOneParam(_: Int) -> NEImmortal { NEImmortal() } // expected-error{{a method with a ~Escapable result requires '@lifetime(...)'}}
@@ -159,7 +159,7 @@ struct EscapableNonTrivialSelf {
159159
@lifetime(copy self) // expected-error{{cannot copy the lifetime of an Escapable type, use '@lifetime(borrow self)' instead}}
160160
mutating func mutatingMethodOneParamCopy(_: Int) -> NEImmortal { NEImmortal() }
161161

162-
@lifetime(borrow self)
162+
@lifetime(&self)
163163
mutating func mutatingMethodOneParamBorrow(_: Int) -> NEImmortal { NEImmortal() }
164164
}
165165

@@ -224,7 +224,7 @@ func oneParamLifetime(c: C) -> NEImmortal { NEImmortal() }
224224

225225
func oneParamConsume(c: consuming C) -> NEImmortal { NEImmortal() } // expected-error{{cannot borrow the lifetime of 'c', which has consuming ownership on a function}}
226226

227-
@lifetime(c) // expected-error{{invalid use of borrow dependence with consuming ownership}}
227+
@lifetime(c) // expected-error{{invalid lifetime dependence on Escapable value with consuming ownership}}
228228
func oneParamConsumeLifetime(c: consuming C) -> NEImmortal { NEImmortal() }
229229

230230
func oneParamBorrow(c: borrowing C) -> NEImmortal { NEImmortal() } // OK
@@ -424,7 +424,7 @@ struct NoncopyableSelfAccessors: ~Copyable & ~Escapable {
424424
yield ne
425425
}
426426

427-
@lifetime(borrow self)
427+
@lifetime(&self)
428428
_modify {
429429
yield &ne
430430
}
@@ -484,7 +484,7 @@ struct NoncopyableSelfAccessors: ~Copyable & ~Escapable {
484484
ne
485485
}
486486

487-
@lifetime(borrow self)
487+
@lifetime(&self)
488488
set {
489489
ne = newValue
490490
}
@@ -496,7 +496,7 @@ struct NoncopyableSelfAccessors: ~Copyable & ~Escapable {
496496
yield ne
497497
}
498498

499-
@lifetime(borrow self)
499+
@lifetime(&self)
500500
_modify {
501501
yield &ne
502502
}

test/Sema/lifetime_depend_infer_lazy.swift

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ struct EscapableNonTrivialSelf {
106106
@lifetime(self)
107107
mutating func mutatingMethodNoParamLifetime() -> NEImmortal { NEImmortal() }
108108

109-
@lifetime(borrow self)
109+
@lifetime(&self)
110110
mutating func mutatingMethodNoParamBorrow() -> NEImmortal { NEImmortal() }
111111

112112
func methodOneParam(_: Int) -> NEImmortal { NEImmortal() } // OK
@@ -122,7 +122,7 @@ struct EscapableNonTrivialSelf {
122122
@lifetime(self) // OK
123123
mutating func mutatingMethodOneParamLifetime(_: Int) -> NEImmortal { NEImmortal() }
124124

125-
@lifetime(borrow self) // OK
125+
@lifetime(&self) // OK
126126
mutating func mutatingMethodOneParamBorrow(_: Int) -> NEImmortal { NEImmortal() }
127127
}
128128

@@ -351,7 +351,7 @@ struct NoncopyableSelfAccessors: ~Copyable & ~Escapable {
351351
yield ne
352352
}
353353

354-
@lifetime(borrow self)
354+
@lifetime(&self)
355355
_modify {
356356
yield &ne
357357
}
@@ -411,7 +411,7 @@ struct NoncopyableSelfAccessors: ~Copyable & ~Escapable {
411411
ne
412412
}
413413

414-
@lifetime(borrow self)
414+
@lifetime(&self)
415415
set {
416416
ne = newValue
417417
}
@@ -423,7 +423,7 @@ struct NoncopyableSelfAccessors: ~Copyable & ~Escapable {
423423
yield ne
424424
}
425425

426-
@lifetime(borrow self)
426+
@lifetime(&self)
427427
_modify {
428428
yield &ne
429429
}

test/Serialization/Inputs/def_explicit_lifetime_dependence.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ public struct Wrapper : ~Escapable {
7272
_read {
7373
yield _view
7474
}
75-
@lifetime(borrow self)
75+
@lifetime(&self)
7676
_modify {
7777
yield &_view
7878
}

test/Serialization/Inputs/def_implicit_lifetime_dependence.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ public struct Wrapper : ~Escapable {
6262
_read {
6363
yield _view
6464
}
65-
@lifetime(borrow self)
65+
@lifetime(&self)
6666
_modify {
6767
yield &_view
6868
}

0 commit comments

Comments
 (0)