Skip to content

Commit b012270

Browse files
committed
Adopt experimental-feature infrastructure for move-only feature
1 parent 37dbf23 commit b012270

File tree

7 files changed

+13
-13
lines changed

7 files changed

+13
-13
lines changed

include/swift/Basic/Features.def

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ EXPERIMENTAL_FEATURE(StaticAssert)
8787
EXPERIMENTAL_FEATURE(VariadicGenerics)
8888
EXPERIMENTAL_FEATURE(NamedOpaqueTypes)
8989
EXPERIMENTAL_FEATURE(FlowSensitiveConcurrencyCaptures)
90+
EXPERIMENTAL_FEATURE(MoveOnly)
9091

9192
#undef EXPERIMENTAL_FEATURE
9293
#undef SUPPRESSIBLE_LANGUAGE_FEATURE

include/swift/Basic/LangOptions.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -330,9 +330,6 @@ namespace swift {
330330
/// Enable inference of Sendable conformances for public types.
331331
bool EnableInferPublicSendable = false;
332332

333-
/// Enable experimental 'move only' features.
334-
bool EnableExperimentalMoveOnly = false;
335-
336333
/// Enable experimental associated type inference using type witness
337334
/// systems.
338335
bool EnableExperimentalAssociatedTypeInference = false;

lib/AST/ASTPrinter.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3011,6 +3011,10 @@ static bool usesFeatureFlowSensitiveConcurrencyCaptures(Decl *decl) {
30113011
return false;
30123012
}
30133013

3014+
static bool usesFeatureMoveOnly(Decl *decl) {
3015+
return false;
3016+
}
3017+
30143018
static void
30153019
suppressingFeatureNoAsyncAvailability(PrintOptions &options,
30163020
llvm::function_ref<void()> action) {

lib/Frontend/CompilerInvocation.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -458,9 +458,6 @@ static bool ParseLangArgs(LangOptions &Opts, ArgList &Args,
458458
Opts.EnableExperimentalAssociatedTypeInference |=
459459
Args.hasArg(OPT_enable_experimental_associated_type_inference);
460460

461-
Opts.EnableExperimentalMoveOnly |=
462-
Args.hasArg(OPT_enable_experimental_move_only);
463-
464461
Opts.EnableInferPublicSendable |=
465462
Args.hasFlag(OPT_enable_infer_public_concurrent_value,
466463
OPT_disable_infer_public_concurrent_value,
@@ -662,6 +659,8 @@ static bool ParseLangArgs(LangOptions &Opts, ArgList &Args,
662659
Opts.Features.insert(Feature::NamedOpaqueTypes);
663660
if (Args.hasArg(OPT_enable_experimental_flow_sensitive_concurrent_captures))
664661
Opts.Features.insert(Feature::FlowSensitiveConcurrencyCaptures);
662+
if (Args.hasArg(OPT_enable_experimental_move_only))
663+
Opts.Features.insert(Feature::MoveOnly);
665664

666665
Opts.EnableAppExtensionRestrictions |= Args.hasArg(OPT_enable_app_extension);
667666

lib/SILGen/SILGenDecl.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -474,7 +474,7 @@ class LetValueInitialization : public Initialization {
474474

475475
// Make sure that we have a non-address only type when binding a
476476
// @_noImplicitCopy let.
477-
if (SGF.getASTContext().LangOpts.EnableExperimentalMoveOnly &&
477+
if (SGF.getASTContext().LangOpts.hasFeature(Feature::MoveOnly) &&
478478
lowering.isAddressOnly() &&
479479
vd->getAttrs().hasAttribute<NoImplicitCopyAttr>()) {
480480
auto d = diag::noimplicitcopy_used_on_generic_or_existential;
@@ -556,7 +556,7 @@ class LetValueInitialization : public Initialization {
556556

557557
if (SGF.getASTContext().SILOpts.supportsLexicalLifetimes(SGF.getModule()) &&
558558
value->getOwnershipKind() != OwnershipKind::None) {
559-
if (!SGF.getASTContext().LangOpts.EnableExperimentalMoveOnly) {
559+
if (!SGF.getASTContext().LangOpts.hasFeature(Feature::MoveOnly)) {
560560
value = SILValue(
561561
SGF.B.createBeginBorrow(PrologueLoc, value, /*isLexical*/ true));
562562
} else {
@@ -1801,7 +1801,7 @@ void SILGenFunction::destroyLocalVariable(SILLocation silLoc, VarDecl *vd) {
18011801
return;
18021802
}
18031803

1804-
if (getASTContext().LangOpts.EnableExperimentalMoveOnly) {
1804+
if (getASTContext().LangOpts.hasFeature(Feature::MoveOnly)) {
18051805
if (auto *mvi = dyn_cast<MarkMustCheckInst>(Val.getDefiningInstruction())) {
18061806
if (mvi->isNoImplicitCopy()) {
18071807
if (auto *cvi = dyn_cast<CopyValueInst>(mvi->getOperand())) {

lib/Sema/TypeCheckAttr.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -328,7 +328,7 @@ class AttributeChecker : public AttributeVisitor<AttributeChecker> {
328328
void AttributeChecker::visitNoImplicitCopyAttr(NoImplicitCopyAttr *attr) {
329329
// Only allow for this attribute to be used when experimental move only is
330330
// enabled.
331-
if (!D->getASTContext().LangOpts.EnableExperimentalMoveOnly) {
331+
if (!D->getASTContext().LangOpts.hasFeature(Feature::MoveOnly)) {
332332
auto error =
333333
diag::experimental_moveonly_feature_can_only_be_used_when_enabled;
334334
diagnoseAndRemoveAttr(attr, error);

tools/sil-opt/SILOpt.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -561,9 +561,8 @@ int main(int argc, char **argv) {
561561
EnableExperimentalConcurrency;
562562
Optional<bool> enableExperimentalMoveOnly =
563563
toOptionalBool(EnableExperimentalMoveOnly);
564-
if (enableExperimentalMoveOnly)
565-
Invocation.getLangOptions().EnableExperimentalMoveOnly =
566-
*enableExperimentalMoveOnly;
564+
if (enableExperimentalMoveOnly && *enableExperimentalMoveOnly)
565+
Invocation.getLangOptions().Features.insert(Feature::MoveOnly);
567566

568567
Invocation.getLangOptions().EnableObjCInterop =
569568
EnableObjCInterop ? true :

0 commit comments

Comments
 (0)