Skip to content

Commit c73187a

Browse files
committed
[NFC] Update tests
1 parent 374ceb6 commit c73187a

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
@@ -36,7 +36,7 @@ public struct NonEscapableSelf : ~Swift.Escapable {
3636
@lifetime(copy self)
3737
public mutating func mutatingMethodNoParamCopy() -> lifetime_depend_infer.NonEscapableSelf
3838

39-
@lifetime(borrow self)
39+
@lifetime(&self)
4040
public mutating func mutatingMethodNoParamBorrow() -> lifetime_depend_infer.NonEscapableSelf
4141

4242
public func methodOneParam(_: Swift.Int) -> lifetime_depend_infer.NonEscapableSelf
@@ -56,7 +56,7 @@ public struct NonEscapableSelf : ~Swift.Escapable {
5656
@lifetime(copy self)
5757
public mutating func mutatingMethodOneParamCopy(_: Swift.Int) -> lifetime_depend_infer.NonEscapableSelf
5858

59-
@lifetime(borrow self)
59+
@lifetime(&self)
6060
public mutating func mutatingMethodOneParamBorrow(_: Swift.Int) -> lifetime_depend_infer.NonEscapableSelf
6161
}
6262

@@ -79,7 +79,7 @@ public struct EscapableTrivialSelf {
7979
@lifetime(self)
8080
public mutating func mutatingMethodNoParamLifetime() -> lifetime_depend_infer.NEImmortal
8181

82-
@lifetime(borrow self)
82+
@lifetime(&self)
8383
public mutating func mutatingMethodNoParamBorrow() -> lifetime_depend_infer.NEImmortal
8484

8585
@lifetime(self)
@@ -91,7 +91,7 @@ public struct EscapableTrivialSelf {
9191
@lifetime(self)
9292
public mutating func mutatingMethodOneParamLifetime(_: Swift.Int) -> lifetime_depend_infer.NEImmortal
9393

94-
@lifetime(borrow self)
94+
@lifetime(&self)
9595
public mutating func mutatingMethodOneParamBorrow(_: Swift.Int) -> lifetime_depend_infer.NEImmortal
9696

9797
}
@@ -110,7 +110,7 @@ public struct EscapableNonTrivialSelf {
110110
@lifetime(self)
111111
public mutating func mutatingMethodNoParamLifetime() -> lifetime_depend_infer.NEImmortal
112112

113-
@lifetime(borrow self)
113+
@lifetime(&self)
114114
public mutating func mutatingMethodNoParamBorrow() -> lifetime_depend_infer.NEImmortal
115115

116116
public func methodOneParam(_: Swift.Int) -> lifetime_depend_infer.NEImmortal
@@ -126,7 +126,7 @@ public struct EscapableNonTrivialSelf {
126126
@lifetime(self)
127127
public mutating func mutatingMethodOneParamLifetime(_: Swift.Int) -> lifetime_depend_infer.NEImmortal
128128

129-
@lifetime(borrow self)
129+
@lifetime(&self)
130130
public mutating func mutatingMethodOneParamBorrow(_: Swift.Int) -> lifetime_depend_infer.NEImmortal
131131

132132
}
@@ -209,7 +209,7 @@ public struct NonescapableSelfAccessors : ~Swift.Escapable {
209209

210210
public var neYielded: lifetime_depend_infer.NE {
211211
_read
212-
@lifetime(borrow self)
212+
@lifetime(&self)
213213
_modify
214214
}
215215

@@ -223,7 +223,7 @@ public struct NoncopyableSelfAccessors : ~Copyable & ~Escapable {
223223

224224
public var neYielded: lifetime_depend_infer.NE {
225225
_read
226-
@lifetime(borrow self)
226+
@lifetime(&self)
227227
_modify
228228
}
229229

@@ -258,14 +258,14 @@ public struct NoncopyableSelfAccessors : ~Copyable & ~Escapable {
258258
public var neComputedBorrow: lifetime_depend_infer.NE {
259259
@lifetime(borrow self)
260260
get
261-
@lifetime(borrow self)
261+
@lifetime(&self)
262262
set
263263
}
264264

265265
public var neYieldedBorrow: lifetime_depend_infer.NE {
266266
@lifetime(borrow self)
267267
_read
268-
@lifetime(borrow self)
268+
@lifetime(&self)
269269
_modify
270270
}
271271
}
@@ -285,7 +285,7 @@ public struct NonEscapableMutableSelf : ~Swift.Escapable {
285285
@lifetime(copy self)
286286
public mutating func mutatingMethodOneParamCopy(_: lifetime_depend_infer.NE)
287287

288-
@lifetime(borrow self)
288+
@lifetime(&self)
289289
public mutating func mutatingMethodOneParamBorrow(_: lifetime_depend_infer.NE)
290290
}
291291
#endif

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 an 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)