Skip to content

Commit c2cac03

Browse files
committed
Introduce InoutLifetimeDependence feature
1 parent 142be66 commit c2cac03

File tree

3 files changed

+16
-0
lines changed

3 files changed

+16
-0
lines changed

include/swift/Basic/Features.def

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -416,6 +416,9 @@ EXPERIMENTAL_FEATURE(StructLetDestructuring, true)
416416
/// Enable returning non-escapable types from functions.
417417
EXPERIMENTAL_FEATURE(LifetimeDependence, true)
418418

419+
/// Enable inout lifetime dependence - @lifetime(&arg)
420+
EXPERIMENTAL_FEATURE(InoutLifetimeDependence, true)
421+
419422
/// Enable the `@_staticExclusiveOnly` attribute.
420423
EXPERIMENTAL_FEATURE(StaticExclusiveOnly, true)
421424

lib/AST/FeatureSet.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -271,6 +271,18 @@ static bool usesFeatureLifetimeDependence(Decl *decl) {
271271
return false;
272272
}
273273

274+
static bool usesFeatureInoutLifetimeDependence(Decl *decl) {
275+
for (auto attr : decl->getAttrs().getAttributes<LifetimeAttr>()) {
276+
for (auto source : attr->getLifetimeEntry()->getSources()) {
277+
if (source.getParsedLifetimeDependenceKind() ==
278+
ParsedLifetimeDependenceKind::Inout) {
279+
return true;
280+
}
281+
}
282+
}
283+
return false;
284+
}
285+
274286
UNINTERESTING_FEATURE(DynamicActorIsolation)
275287
UNINTERESTING_FEATURE(NonfrozenEnumExhaustivity)
276288
UNINTERESTING_FEATURE(ClosureIsolation)

stdlib/cmake/modules/SwiftSource.cmake

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -631,6 +631,7 @@ function(_compile_swift_files
631631

632632
list(APPEND swift_flags "-enable-experimental-feature" "NonescapableTypes")
633633
list(APPEND swift_flags "-enable-experimental-feature" "LifetimeDependence")
634+
list(APPEND swift_flags "-enable-experimental-feature" "InoutLifetimeDependence")
634635

635636
list(APPEND swift_flags "-enable-upcoming-feature" "MemberImportVisibility")
636637

0 commit comments

Comments
 (0)