Skip to content

Commit 3be14e0

Browse files
authored
Merge pull request #64622 from kavon/bifurcate-moveonly-featureflag
Fix minimal stdlib builds with noncopyable types
2 parents a976221 + 2be061c commit 3be14e0

File tree

8 files changed

+25
-5
lines changed

8 files changed

+25
-5
lines changed

include/swift/Basic/Features.def

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,8 @@ EXPERIMENTAL_FEATURE(FreestandingMacros, true)
116116
// but our tests currently rely on it, and we want to run those
117117
// tests in non-asserts builds too.
118118
EXPERIMENTAL_FEATURE(MoveOnlyClasses, true)
119+
EXPERIMENTAL_FEATURE(NoImplicitCopy, true)
120+
EXPERIMENTAL_FEATURE(OldOwnershipOperatorSpellings, true)
119121

120122
EXPERIMENTAL_FEATURE(OneWayClosureParameters, false)
121123
EXPERIMENTAL_FEATURE(TypeWitnessSystemInference, false)

lib/AST/ASTPrinter.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3232,6 +3232,14 @@ static bool usesFeatureMoveOnlyClasses(Decl *decl) {
32323232
return isa<ClassDecl>(decl) && usesFeatureMoveOnly(decl);
32333233
}
32343234

3235+
static bool usesFeatureNoImplicitCopy(Decl *decl) {
3236+
return decl->isNoImplicitCopy();
3237+
}
3238+
3239+
static bool usesFeatureOldOwnershipOperatorSpellings(Decl *decl) {
3240+
return false;
3241+
}
3242+
32353243
static bool usesFeatureOneWayClosureParameters(Decl *decl) {
32363244
return false;
32373245
}

lib/Frontend/CompilerInvocation.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -735,8 +735,12 @@ static bool ParseLangArgs(LangOptions &Opts, ArgList &Args,
735735
Opts.Features.insert(Feature::NamedOpaqueTypes);
736736
if (Args.hasArg(OPT_enable_experimental_flow_sensitive_concurrent_captures))
737737
Opts.Features.insert(Feature::FlowSensitiveConcurrencyCaptures);
738-
if (Args.hasArg(OPT_enable_experimental_move_only))
738+
if (Args.hasArg(OPT_enable_experimental_move_only)) {
739+
// FIXME: drop addition of Feature::MoveOnly once its queries are gone.
739740
Opts.Features.insert(Feature::MoveOnly);
741+
Opts.Features.insert(Feature::NoImplicitCopy);
742+
Opts.Features.insert(Feature::OldOwnershipOperatorSpellings);
743+
}
740744
if (Args.hasArg(OPT_experimental_one_way_closure_params))
741745
Opts.Features.insert(Feature::OneWayClosureParameters);
742746
if (Args.hasArg(OPT_enable_experimental_associated_type_inference))

lib/Parse/ParseExpr.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -422,7 +422,7 @@ ParserResult<Expr> Parser::parseExprSequenceElement(Diag<> message,
422422
return sub;
423423
}
424424

425-
if (Context.LangOpts.hasFeature(Feature::MoveOnly)) {
425+
if (Context.LangOpts.hasFeature(Feature::OldOwnershipOperatorSpellings)) {
426426
if (Tok.isContextualKeyword("_move")) {
427427
Tok.setKind(tok::contextual_keyword);
428428
SourceLoc awaitLoc = consumeToken();

lib/Sema/TypeCheckAttr.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -349,7 +349,7 @@ class AttributeChecker : public AttributeVisitor<AttributeChecker> {
349349
void AttributeChecker::visitNoImplicitCopyAttr(NoImplicitCopyAttr *attr) {
350350
// Only allow for this attribute to be used when experimental move only is
351351
// enabled.
352-
if (!D->getASTContext().LangOpts.hasFeature(Feature::MoveOnly)) {
352+
if (!D->getASTContext().LangOpts.hasFeature(Feature::NoImplicitCopy)) {
353353
auto error =
354354
diag::experimental_moveonly_feature_can_only_be_used_when_enabled;
355355
diagnoseAndRemoveAttr(attr, error);

stdlib/public/Concurrency/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,7 @@ add_swift_target_library(swift_Concurrency ${SWIFT_STDLIB_LIBRARY_BUILD_TYPES} I
149149
${SWIFT_STANDARD_LIBRARY_SWIFT_FLAGS}
150150
-parse-stdlib
151151
-Xfrontend -enable-experimental-concurrency
152+
-enable-experimental-feature MoveOnly
152153
-diagnostic-style swift
153154
${SWIFT_RUNTIME_CONCURRENCY_SWIFT_FLAGS}
154155
${swift_concurrency_options}

test/stdlib/move_function.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// RUN: %target-run-stdlib-swift(-O)
1+
// RUN: %target-run-stdlib-swift(-O -enable-experimental-feature MoveOnly)
22

33
// REQUIRES: executable_test
44

tools/sil-opt/SILOpt.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -581,8 +581,13 @@ int main(int argc, char **argv) {
581581
EnableExperimentalConcurrency;
582582
Optional<bool> enableExperimentalMoveOnly =
583583
toOptionalBool(EnableExperimentalMoveOnly);
584-
if (enableExperimentalMoveOnly && *enableExperimentalMoveOnly)
584+
if (enableExperimentalMoveOnly && *enableExperimentalMoveOnly) {
585+
// FIXME: drop addition of Feature::MoveOnly once its queries are gone.
585586
Invocation.getLangOptions().Features.insert(Feature::MoveOnly);
587+
Invocation.getLangOptions().Features.insert(Feature::NoImplicitCopy);
588+
Invocation.getLangOptions().Features.insert(
589+
Feature::OldOwnershipOperatorSpellings);
590+
}
586591
for (auto &featureName : ExperimentalFeatures) {
587592
if (auto feature = getExperimentalFeature(featureName)) {
588593
Invocation.getLangOptions().Features.insert(*feature);

0 commit comments

Comments
 (0)