Skip to content

Commit 5fb8082

Browse files
committed
AST: Promote various move-only features to the baseline.
1 parent e1082bb commit 5fb8082

File tree

2 files changed

+5
-61
lines changed

2 files changed

+5
-61
lines changed

include/swift/Basic/Features.def

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -176,8 +176,8 @@ BASELINE_LANGUAGE_FEATURE(Macros, 0, "Macros")
176176
BASELINE_LANGUAGE_FEATURE(FreestandingExpressionMacros, 382, "Expression macros")
177177
BASELINE_LANGUAGE_FEATURE(AttachedMacros, 389, "Attached macros")
178178
BASELINE_LANGUAGE_FEATURE(ExtensionMacros, 402, "Extension macros")
179-
LANGUAGE_FEATURE(MoveOnly, 390, "noncopyable types")
180-
LANGUAGE_FEATURE(MoveOnlyResilientTypes, 390, "non-@frozen noncopyable types with library evolution")
179+
BASELINE_LANGUAGE_FEATURE(MoveOnly, 390, "noncopyable types")
180+
BASELINE_LANGUAGE_FEATURE(MoveOnlyResilientTypes, 390, "non-@frozen noncopyable types with library evolution")
181181
BASELINE_LANGUAGE_FEATURE(ParameterPacks, 393, "Value and type parameter packs")
182182
SUPPRESSIBLE_LANGUAGE_FEATURE(LexicalLifetimes, 0, "@_eagerMove/@_noEagerMove/@_lexicalLifetimes annotations")
183183
BASELINE_LANGUAGE_FEATURE(FreestandingMacros, 397, "freestanding declaration macros")
@@ -191,7 +191,7 @@ LANGUAGE_FEATURE(BuiltinStoreRaw, 0, "Builtin.storeRaw")
191191
BASELINE_LANGUAGE_FEATURE(BuiltinCreateTask, 0, "Builtin.createTask and Builtin.createDiscardingTask")
192192
SUPPRESSIBLE_LANGUAGE_FEATURE(AssociatedTypeImplements, 0, "@_implements on associated types")
193193
LANGUAGE_FEATURE(BuiltinAddressOfRawLayout, 0, "Builtin.addressOfRawLayout")
194-
LANGUAGE_FEATURE(MoveOnlyPartialConsumption, 429, "Partial consumption of noncopyable values")
194+
BASELINE_LANGUAGE_FEATURE(MoveOnlyPartialConsumption, 429, "Partial consumption of noncopyable values")
195195
LANGUAGE_FEATURE(BitwiseCopyable, 426, "BitwiseCopyable protocol")
196196
BASELINE_LANGUAGE_FEATURE(NoncopyableGenerics, 427, "Noncopyable generics")
197197
BASELINE_LANGUAGE_FEATURE(NoncopyableGenerics2, 427, "Noncopyable generics alias")

lib/AST/FeatureSet.cpp

Lines changed: 2 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -141,48 +141,6 @@ static bool usesFeatureSpecializeAttributeWithAvailability(Decl *decl) {
141141
return false;
142142
}
143143

144-
static bool usesFeatureMoveOnly(Decl *decl) {
145-
if (auto *extension = dyn_cast<ExtensionDecl>(decl)) {
146-
if (auto *nominal = extension->getExtendedNominal())
147-
return usesFeatureMoveOnly(nominal);
148-
return false;
149-
}
150-
151-
auto hasInverseInType = [&](Type type) {
152-
return type.findIf([&](Type type) -> bool {
153-
if (auto *NTD = type->getAnyNominal()) {
154-
if (NTD->getAttrs().hasAttribute<MoveOnlyAttr>())
155-
return true;
156-
}
157-
return false;
158-
});
159-
};
160-
161-
if (auto *TD = dyn_cast<TypeDecl>(decl)) {
162-
if (auto *alias = dyn_cast<TypeAliasDecl>(TD))
163-
return hasInverseInType(alias->getUnderlyingType());
164-
165-
if (auto *NTD = dyn_cast<NominalTypeDecl>(TD)) {
166-
if (NTD->getAttrs().hasAttribute<MoveOnlyAttr>())
167-
return true;
168-
}
169-
170-
return false;
171-
}
172-
173-
if (auto *VD = dyn_cast<ValueDecl>(decl)) {
174-
return hasInverseInType(VD->getInterfaceType());
175-
}
176-
177-
return false;
178-
}
179-
180-
static bool usesFeatureMoveOnlyResilientTypes(Decl *decl) {
181-
if (auto *nomDecl = dyn_cast<NominalTypeDecl>(decl))
182-
return nomDecl->isResilient() && usesFeatureMoveOnly(decl);
183-
return false;
184-
}
185-
186144
static bool hasParameterPacks(Decl *decl) {
187145
if (auto genericContext = decl->getAsGenericContext()) {
188146
auto sig = genericContext->getGenericSignature();
@@ -341,29 +299,15 @@ static bool usesFeatureSymbolLinkageMarkers(Decl *decl) {
341299
}
342300

343301
UNINTERESTING_FEATURE(LazyImmediate)
344-
345-
static bool usesFeatureMoveOnlyClasses(Decl *decl) {
346-
return isa<ClassDecl>(decl) && usesFeatureMoveOnly(decl);
347-
}
302+
UNINTERESTING_FEATURE(MoveOnlyClasses)
348303

349304
static bool usesFeatureNoImplicitCopy(Decl *decl) {
350305
return decl->isNoImplicitCopy();
351306
}
352307

353308
UNINTERESTING_FEATURE(OldOwnershipOperatorSpellings)
354-
355-
static bool usesFeatureMoveOnlyEnumDeinits(Decl *decl) {
356-
if (auto *ei = dyn_cast<EnumDecl>(decl)) {
357-
return usesFeatureMoveOnly(ei) && ei->getValueTypeDestructor();
358-
}
359-
return false;
360-
}
361-
309+
UNINTERESTING_FEATURE(MoveOnlyEnumDeinits)
362310
UNINTERESTING_FEATURE(MoveOnlyTuples)
363-
364-
// Partial consumption does not affect declarations directly.
365-
UNINTERESTING_FEATURE(MoveOnlyPartialConsumption)
366-
367311
UNINTERESTING_FEATURE(MoveOnlyPartialReinitialization)
368312

369313
UNINTERESTING_FEATURE(OneWayClosureParameters)

0 commit comments

Comments
 (0)