diff --git a/include/swift/AST/ASTContext.h b/include/swift/AST/ASTContext.h index 229e13dc4b578..c62ff6aec2c76 100644 --- a/include/swift/AST/ASTContext.h +++ b/include/swift/AST/ASTContext.h @@ -698,6 +698,9 @@ class ASTContext final { FuncDecl *getMakeInvocationEncoderOnDistributedActorSystem( AbstractFunctionDecl *thunk) const; + /// Indicates whether move-only / noncopyable types are supported. + bool supportsMoveOnlyTypes() const; + // Retrieve the declaration of // DistributedInvocationEncoder.recordGenericSubstitution(_:). // diff --git a/include/swift/AST/DiagnosticsSema.def b/include/swift/AST/DiagnosticsSema.def index e669e834d01ef..6a2fe148cec8f 100644 --- a/include/swift/AST/DiagnosticsSema.def +++ b/include/swift/AST/DiagnosticsSema.def @@ -6744,11 +6744,6 @@ ERROR(experimental_moveonly_feature_can_only_be_used_when_enabled, none, "Can not use feature when experimental move only is disabled! Pass" " the frontend flag -enable-experimental-move-only to swift to enable " "the usage of this language feature", ()) -ERROR(experimental_moveonly_feature_can_only_be_imported_when_enabled, - none, "Can not import module %0 that uses move only features when " - "experimental move only is disabled! Pass the frontend flag " - "-enable-experimental-move-only to swift to enable the usage of this " - "language feature", (Identifier)) ERROR(noimplicitcopy_attr_valid_only_on_local_let_params, none, "'@_noImplicitCopy' attribute can only be applied to local lets and params", ()) ERROR(noimplicitcopy_attr_invalid_in_generic_context, @@ -6831,6 +6826,10 @@ ERROR(move_expression_not_passed_lvalue,none, ERROR(borrow_expression_not_passed_lvalue,none, "'borrow' can only be applied to lvalues", ()) +ERROR(moveOnly_requires_lexical_lifetimes,none, + "noncopyable types require lexical borrow scopes " + "(add -enable-lexical-borrow-scopes=true)", ()) + //------------------------------------------------------------------------------ // MARK: #_hasSymbol //------------------------------------------------------------------------------ diff --git a/include/swift/SIL/SILCloner.h b/include/swift/SIL/SILCloner.h index 3bcb1920c70de..1c7cc1755806d 100644 --- a/include/swift/SIL/SILCloner.h +++ b/include/swift/SIL/SILCloner.h @@ -1484,11 +1484,20 @@ template void SILCloner::visitExplicitCopyAddrInst( ExplicitCopyAddrInst *Inst) { getBuilder().setCurrentDebugScope(getOpScope(Inst->getDebugScope())); - recordClonedInstruction( - Inst, getBuilder().createExplicitCopyAddr( - getOpLocation(Inst->getLoc()), getOpValue(Inst->getSrc()), - getOpValue(Inst->getDest()), Inst->isTakeOfSrc(), - Inst->isInitializationOfDest())); + if (!getBuilder().hasOwnership()) { + recordClonedInstruction( + Inst, getBuilder().createCopyAddr( + getOpLocation(Inst->getLoc()), getOpValue(Inst->getSrc()), + getOpValue(Inst->getDest()), Inst->isTakeOfSrc(), + Inst->isInitializationOfDest())); + } else { + // preserve the explicit_* + recordClonedInstruction( + Inst, getBuilder().createExplicitCopyAddr( + getOpLocation(Inst->getLoc()), getOpValue(Inst->getSrc()), + getOpValue(Inst->getDest()), Inst->isTakeOfSrc(), + Inst->isInitializationOfDest())); + } } template diff --git a/lib/AST/ASTContext.cpp b/lib/AST/ASTContext.cpp index 321a8b0729394..d41ccea98caa3 100644 --- a/lib/AST/ASTContext.cpp +++ b/lib/AST/ASTContext.cpp @@ -6363,3 +6363,8 @@ ASTContext::lookupExecutablePluginByModuleName(Identifier moduleName) { return plugin.get(); } + +bool ASTContext::supportsMoveOnlyTypes() const { + // currently the only thing holding back whether the types can appear is this. + return SILOpts.LexicalLifetimes != LexicalLifetimesOption::Off; +} diff --git a/lib/SIL/Verifier/SILVerifier.cpp b/lib/SIL/Verifier/SILVerifier.cpp index 7b9e791e4acd6..559625cc270bc 100644 --- a/lib/SIL/Verifier/SILVerifier.cpp +++ b/lib/SIL/Verifier/SILVerifier.cpp @@ -2822,6 +2822,18 @@ class SILVerifier : public SILVerifierBase { "'MoveOnly' types can only be copied in Raw SIL?!"); } + void checkExplicitCopyAddrInst(ExplicitCopyAddrInst *ecai) { + require(F.hasOwnership(), "explicit_copy_* is only valid in OSSA."); + require(ecai->getSrc()->getType().isAddress(), + "Src value should be lvalue"); + require(ecai->getDest()->getType().isAddress(), + "Dest address should be lvalue"); + requireSameType(ecai->getDest()->getType(), ecai->getSrc()->getType(), + "Store operand type and dest type mismatch"); + require(F.isTypeABIAccessible(ecai->getDest()->getType()), + "cannot directly copy type with inaccessible ABI"); + } + void checkMarkUnresolvedMoveAddrInst(MarkUnresolvedMoveAddrInst *SI) { require(F.hasOwnership(), "Only valid in OSSA."); require(F.getModule().getStage() == SILStage::Raw, "Only valid in Raw SIL"); @@ -2861,6 +2873,14 @@ class SILVerifier : public SILVerifierBase { "'MoveOnly' types can only be copied in Raw SIL?!"); } + void checkExplicitCopyValueInst(ExplicitCopyValueInst *I) { + require(F.hasOwnership(), "explicit_copy_* is only valid in OSSA."); + require(I->getOperand()->getType().isObject(), + "Source value should be an object value"); + require(!I->getOperand()->getType().isTrivial(*I->getFunction()), + "Source value should be non-trivial"); + } + void checkDestroyValueInst(DestroyValueInst *I) { require(I->getOperand()->getType().isObject(), "Source value should be an object value"); diff --git a/lib/SILGen/SILGenDecl.cpp b/lib/SILGen/SILGenDecl.cpp index 95ad3659ce7c9..6ead74f108574 100644 --- a/lib/SILGen/SILGenDecl.cpp +++ b/lib/SILGen/SILGenDecl.cpp @@ -620,8 +620,7 @@ class LetValueInitialization : public Initialization { public: LetValueInitialization(VarDecl *vd, SILGenFunction &SGF) : vd(vd) { const TypeLowering *lowering = nullptr; - if (SGF.getASTContext().LangOpts.Features.count(Feature::MoveOnly) && - vd->isNoImplicitCopy()) { + if (vd->isNoImplicitCopy()) { lowering = &SGF.getTypeLowering( SILMoveOnlyWrappedType::get(vd->getType()->getCanonicalType())); } else { @@ -661,8 +660,7 @@ class LetValueInitialization : public Initialization { // Make sure that we have a non-address only type when binding a // @_noImplicitCopy let. - if (SGF.getASTContext().LangOpts.Features.count(Feature::MoveOnly) && - lowering->isAddressOnly() && vd->isNoImplicitCopy()) { + if (lowering->isAddressOnly() && vd->isNoImplicitCopy()) { auto d = diag::noimplicitcopy_used_on_generic_or_existential; diagnose(SGF.getASTContext(), vd->getLoc(), d); } @@ -740,10 +738,6 @@ class LetValueInitialization : public Initialization { SILValue value, bool wasPlusOne) { // If we have none... if (value->getOwnershipKind() == OwnershipKind::None) { - // If we don't have move only features enabled, just return, we are done. - if (!SGF.getASTContext().LangOpts.Features.count(Feature::MoveOnly)) - return value; - // Then check if we have a pure move only type. In that case, we need to // insert a no implicit copy if (value->getType().isPureMoveOnly()) { @@ -768,15 +762,6 @@ class LetValueInitialization : public Initialization { MarkMustCheckInst::CheckKind::ConsumableAndAssignable); } - // Then if we don't have move only, just perform a lexical borrow if the - // lifetime is lexical. - if (!SGF.getASTContext().LangOpts.Features.count(Feature::MoveOnly)) { - if (SGF.F.getLifetime(vd, value->getType()).isLexical()) - return SGF.B.createBeginBorrow(PrologueLoc, value, /*isLexical*/ true); - else - return value; - } - // Otherwise, we need to perform some additional processing. First, if we // have an owned moveonly value that had a cleanup, then create a move_value // that acts as a consuming use of the value. The reason why we want this is @@ -2136,35 +2121,22 @@ void SILGenFunction::destroyLocalVariable(SILLocation silLoc, VarDecl *vd) { return; } - if (getASTContext().LangOpts.hasFeature(Feature::MoveOnly)) { - if (auto *mvi = dyn_cast(Val.getDefiningInstruction())) { - if (mvi->hasMoveCheckerKind()) { - if (auto *cvi = dyn_cast(mvi->getOperand())) { - if (auto *bbi = dyn_cast(cvi->getOperand())) { - if (bbi->isLexical()) { - B.emitDestroyValueOperation(silLoc, mvi); - B.createEndBorrow(silLoc, bbi); - B.emitDestroyValueOperation(silLoc, bbi->getOperand()); - return; - } - } - } - - if (auto *copyToMove = dyn_cast( - mvi->getOperand())) { - if (auto *cvi = dyn_cast(copyToMove->getOperand())) { - if (auto *bbi = dyn_cast(cvi->getOperand())) { - if (bbi->isLexical()) { - B.emitDestroyValueOperation(silLoc, mvi); - B.createEndBorrow(silLoc, bbi); - B.emitDestroyValueOperation(silLoc, bbi->getOperand()); - return; - } - } + if (auto *mvi = dyn_cast(Val.getDefiningInstruction())) { + if (mvi->hasMoveCheckerKind()) { + if (auto *cvi = dyn_cast(mvi->getOperand())) { + if (auto *bbi = dyn_cast(cvi->getOperand())) { + if (bbi->isLexical()) { + B.emitDestroyValueOperation(silLoc, mvi); + B.createEndBorrow(silLoc, bbi); + B.emitDestroyValueOperation(silLoc, bbi->getOperand()); + return; } } + } - if (auto *cvi = dyn_cast(mvi->getOperand())) { + if (auto *copyToMove = dyn_cast( + mvi->getOperand())) { + if (auto *cvi = dyn_cast(copyToMove->getOperand())) { if (auto *bbi = dyn_cast(cvi->getOperand())) { if (bbi->isLexical()) { B.emitDestroyValueOperation(silLoc, mvi); @@ -2174,15 +2146,26 @@ void SILGenFunction::destroyLocalVariable(SILLocation silLoc, VarDecl *vd) { } } } + } - // Handle trivial arguments. - if (auto *move = dyn_cast(mvi->getOperand())) { - if (move->isLexical()) { + if (auto *cvi = dyn_cast(mvi->getOperand())) { + if (auto *bbi = dyn_cast(cvi->getOperand())) { + if (bbi->isLexical()) { B.emitDestroyValueOperation(silLoc, mvi); + B.createEndBorrow(silLoc, bbi); + B.emitDestroyValueOperation(silLoc, bbi->getOperand()); return; } } } + + // Handle trivial arguments. + if (auto *move = dyn_cast(mvi->getOperand())) { + if (move->isLexical()) { + B.emitDestroyValueOperation(silLoc, mvi); + return; + } + } } } diff --git a/lib/SILOptimizer/Mandatory/ConsumeOperatorCopyableAddressesChecker.cpp b/lib/SILOptimizer/Mandatory/ConsumeOperatorCopyableAddressesChecker.cpp index 9c3c5c459138e..455617fa75f42 100644 --- a/lib/SILOptimizer/Mandatory/ConsumeOperatorCopyableAddressesChecker.cpp +++ b/lib/SILOptimizer/Mandatory/ConsumeOperatorCopyableAddressesChecker.cpp @@ -2400,7 +2400,7 @@ class ConsumeOperatorCopyableAddressesCheckerPass auto &astContext = fn->getASTContext(); // Only run this pass if the move only language feature is enabled. - if (!astContext.LangOpts.Features.contains(Feature::MoveOnly)) + if (!astContext.supportsMoveOnlyTypes()) return; // Don't rerun diagnostics on deserialized functions. diff --git a/lib/SILOptimizer/Mandatory/ConsumeOperatorCopyableValuesChecker.cpp b/lib/SILOptimizer/Mandatory/ConsumeOperatorCopyableValuesChecker.cpp index 5f6366aea7744..5213b730b490f 100644 --- a/lib/SILOptimizer/Mandatory/ConsumeOperatorCopyableValuesChecker.cpp +++ b/lib/SILOptimizer/Mandatory/ConsumeOperatorCopyableValuesChecker.cpp @@ -527,7 +527,7 @@ class ConsumeOperatorCopyableValuesCheckerPass : public SILFunctionTransform { auto *fn = getFunction(); // Only run this pass if the move only language feature is enabled. - if (!fn->getASTContext().LangOpts.Features.contains(Feature::MoveOnly)) + if (!fn->getASTContext().supportsMoveOnlyTypes()) return; // Don't rerun diagnostics on deserialized functions. diff --git a/lib/SILOptimizer/Mandatory/MoveOnlyAddressCheckerTester.cpp b/lib/SILOptimizer/Mandatory/MoveOnlyAddressCheckerTester.cpp index 91a1c462dd9f6..741aeedffd171 100644 --- a/lib/SILOptimizer/Mandatory/MoveOnlyAddressCheckerTester.cpp +++ b/lib/SILOptimizer/Mandatory/MoveOnlyAddressCheckerTester.cpp @@ -79,7 +79,7 @@ class MoveOnlyAddressCheckerTesterPass : public SILFunctionTransform { auto *fn = getFunction(); // Only run this pass if the move only language feature is enabled. - if (!fn->getASTContext().LangOpts.Features.contains(Feature::MoveOnly)) + if (!fn->getASTContext().supportsMoveOnlyTypes()) return; // Don't rerun diagnostics on deserialized functions. diff --git a/lib/SILOptimizer/Mandatory/MoveOnlyBorrowToDestructureTester.cpp b/lib/SILOptimizer/Mandatory/MoveOnlyBorrowToDestructureTester.cpp index 56a254ac95da3..df768e827b54b 100644 --- a/lib/SILOptimizer/Mandatory/MoveOnlyBorrowToDestructureTester.cpp +++ b/lib/SILOptimizer/Mandatory/MoveOnlyBorrowToDestructureTester.cpp @@ -72,7 +72,7 @@ class MoveOnlyBorrowToDestructureTransformPass : public SILFunctionTransform { auto *fn = getFunction(); // Only run this pass if the move only language feature is enabled. - if (!fn->getASTContext().LangOpts.Features.contains(Feature::MoveOnly)) + if (!fn->getASTContext().supportsMoveOnlyTypes()) return; // Don't rerun diagnostics on deserialized functions. diff --git a/lib/SILOptimizer/Mandatory/MoveOnlyChecker.cpp b/lib/SILOptimizer/Mandatory/MoveOnlyChecker.cpp index 721b45b53af55..12f9c45013127 100644 --- a/lib/SILOptimizer/Mandatory/MoveOnlyChecker.cpp +++ b/lib/SILOptimizer/Mandatory/MoveOnlyChecker.cpp @@ -147,7 +147,7 @@ class MoveOnlyCheckerPass : public SILFunctionTransform { auto *fn = getFunction(); // Only run this pass if the move only language feature is enabled. - if (!fn->getASTContext().LangOpts.Features.contains(Feature::MoveOnly)) + if (!fn->getASTContext().supportsMoveOnlyTypes()) return; // Don't rerun diagnostics on deserialized functions. diff --git a/lib/SILOptimizer/Mandatory/MoveOnlyObjectCheckerTester.cpp b/lib/SILOptimizer/Mandatory/MoveOnlyObjectCheckerTester.cpp index 8b629c8ca8005..f1e6e555ccd52 100644 --- a/lib/SILOptimizer/Mandatory/MoveOnlyObjectCheckerTester.cpp +++ b/lib/SILOptimizer/Mandatory/MoveOnlyObjectCheckerTester.cpp @@ -76,7 +76,7 @@ class MoveOnlyObjectCheckerTesterPass : public SILFunctionTransform { auto *fn = getFunction(); // Only run this pass if the move only language feature is enabled. - if (!fn->getASTContext().LangOpts.Features.contains(Feature::MoveOnly)) + if (!fn->getASTContext().supportsMoveOnlyTypes()) return; // Don't rerun diagnostics on deserialized functions. diff --git a/lib/SILOptimizer/Mandatory/MoveOnlyUtils.cpp b/lib/SILOptimizer/Mandatory/MoveOnlyUtils.cpp index ac635e6fc773b..962b8652c3922 100644 --- a/lib/SILOptimizer/Mandatory/MoveOnlyUtils.cpp +++ b/lib/SILOptimizer/Mandatory/MoveOnlyUtils.cpp @@ -116,9 +116,12 @@ bool swift::siloptimizer::cleanupNonCopyableCopiesAfterEmittingDiagnostic( auto *inst = &*ii; ++ii; - // Convert load [copy] -> load_borrow + explicit_copy_value. + // Convert load [copy] *MoveOnly -> load_borrow + explicit_copy_value. if (auto *li = dyn_cast(inst)) { if (li->getOwnershipQualifier() == LoadOwnershipQualifier::Copy) { + if (!li->getType().isMoveOnly()) + continue; + SILBuilderWithScope builder(li); auto *lbi = builder.createLoadBorrow(li->getLoc(), li->getOperand()); auto *cvi = builder.createExplicitCopyValue(li->getLoc(), lbi); @@ -129,10 +132,13 @@ bool swift::siloptimizer::cleanupNonCopyableCopiesAfterEmittingDiagnostic( } } - // Convert copy_addr !take of src to its explicit value form so we don't - // error. + // Convert copy_addr !take MoveOnly ... -> explicit_copy_addr ...same... + // so we don't error. if (auto *copyAddr = dyn_cast(inst)) { if (!copyAddr->isTakeOfSrc()) { + if (!copyAddr->getSrc()->getType().isMoveOnly()) + continue; + SILBuilderWithScope builder(copyAddr); builder.createExplicitCopyAddr( copyAddr->getLoc(), copyAddr->getSrc(), copyAddr->getDest(), @@ -143,10 +149,11 @@ bool swift::siloptimizer::cleanupNonCopyableCopiesAfterEmittingDiagnostic( } } - // Convert any copy_value of move_only type to explicit copy value. + // Convert any copy_value of MoveOnly type -> explicit_copy_value. if (auto *cvi = dyn_cast(inst)) { if (!cvi->getOperand()->getType().isMoveOnly()) continue; + SILBuilderWithScope b(cvi); auto *expCopy = b.createExplicitCopyValue(cvi->getLoc(), cvi->getOperand()); diff --git a/lib/Sema/MiscDiagnostics.cpp b/lib/Sema/MiscDiagnostics.cpp index 85c86474c2cec..09a7473999eae 100644 --- a/lib/Sema/MiscDiagnostics.cpp +++ b/lib/Sema/MiscDiagnostics.cpp @@ -428,15 +428,6 @@ static void diagSyntacticUseRestrictions(const Expr *E, const DeclContext *DC, } void checkMoveExpr(MoveExpr *moveExpr) { - // Make sure the MoveOnly feature is set. If not, error. - // This should not currently be reached because the parse should ignore - // the _move keyword unless the feature flag is set. - if (!Ctx.LangOpts.hasFeature(Feature::MoveOnly)) { - auto error = - diag::experimental_moveonly_feature_can_only_be_used_when_enabled; - Ctx.Diags.diagnose(moveExpr->getLoc(), error); - } - if (!isa(moveExpr->getSubExpr())) { Ctx.Diags.diagnose(moveExpr->getLoc(), diag::move_expression_not_passed_lvalue); @@ -444,15 +435,6 @@ static void diagSyntacticUseRestrictions(const Expr *E, const DeclContext *DC, } void checkBorrowExpr(BorrowExpr *borrowExpr) { - // Make sure the MoveOnly feature is set. If not, error. - // This should not currently be reached because the parse should ignore - // the _move keyword unless the feature flag is set. - if (!Ctx.LangOpts.hasFeature(Feature::MoveOnly)) { - auto error = - diag::experimental_moveonly_feature_can_only_be_used_when_enabled; - Ctx.Diags.diagnose(borrowExpr->getLoc(), error); - } - // Allow for a chain of member_ref exprs that end in a decl_ref expr. auto *subExpr = borrowExpr->getSubExpr(); while (auto *memberRef = dyn_cast(subExpr)) @@ -6177,11 +6159,6 @@ bool swift::diagnoseUnhandledThrowsInAsyncContext(DeclContext *dc, void swift::diagnoseCopyableTypeContainingMoveOnlyType( NominalTypeDecl *copyableNominalType) { - // If we don't have move only enabled, bail early. - if (!copyableNominalType->getASTContext().LangOpts.Features.contains( - Feature::MoveOnly)) - return; - // If we already have a move only type, just bail, we have no further work to // do. if (copyableNominalType->isMoveOnly()) diff --git a/lib/Sema/TypeCheckAttr.cpp b/lib/Sema/TypeCheckAttr.cpp index 93df148d0df2f..72f7a9ed96d48 100644 --- a/lib/Sema/TypeCheckAttr.cpp +++ b/lib/Sema/TypeCheckAttr.cpp @@ -2159,12 +2159,8 @@ void AttributeChecker::visitFinalAttr(FinalAttr *attr) { } void AttributeChecker::visitMoveOnlyAttr(MoveOnlyAttr *attr) { - if (!D->getASTContext().LangOpts.hasFeature(Feature::MoveOnly)) { - auto error = - diag::experimental_moveonly_feature_can_only_be_used_when_enabled; - diagnoseAndRemoveAttr(attr, error); - return; - } + if (!D->getASTContext().supportsMoveOnlyTypes()) + D->diagnose(diag::moveOnly_requires_lexical_lifetimes); if (isa(D) || isa(D)) return; diff --git a/lib/Sema/TypeCheckDecl.cpp b/lib/Sema/TypeCheckDecl.cpp index 2e6903b3f5c95..ca33c9f775ad7 100644 --- a/lib/Sema/TypeCheckDecl.cpp +++ b/lib/Sema/TypeCheckDecl.cpp @@ -918,8 +918,14 @@ IsFinalRequest::evaluate(Evaluator &evaluator, ValueDecl *decl) const { bool IsMoveOnlyRequest::evaluate(Evaluator &evaluator, ValueDecl *decl) const { // For now only do this for nominal type decls. - if (isa(decl)) - return decl->getAttrs().hasAttribute(); + if (isa(decl)) { + if (decl->getAttrs().hasAttribute()) { + if (!decl->getASTContext().supportsMoveOnlyTypes()) + decl->diagnose(diag::moveOnly_requires_lexical_lifetimes); + + return true; + } + } return false; } diff --git a/lib/Serialization/Deserialization.cpp b/lib/Serialization/Deserialization.cpp index 664439b18c6b3..068a4120ec69f 100644 --- a/lib/Serialization/Deserialization.cpp +++ b/lib/Serialization/Deserialization.cpp @@ -5484,17 +5484,6 @@ llvm::Error DeclDeserializer::deserializeDeclCommon() { MF.fatal(llvm::make_error(recordID)); } - // Do a quick check to see if this attribute is a move only attribute. If - // so, emit a nice error if we don't have experimental move only enabled. - if (Attr && Attr->getKind() == DeclAttrKind::DAK_MoveOnly && - !MF.getContext().LangOpts.Features.contains(Feature::MoveOnly)) { - MF.getContext().Diags.diagnose( - SourceLoc(), - diag:: - experimental_moveonly_feature_can_only_be_imported_when_enabled, - MF.getAssociatedModule()->getName()); - } - if (!skipAttr) { if (!Attr) return llvm::Error::success(); diff --git a/test/Constraints/moveonly_constraints.swift b/test/Constraints/moveonly_constraints.swift index 5a4b312a00918..71f91f829c65e 100644 --- a/test/Constraints/moveonly_constraints.swift +++ b/test/Constraints/moveonly_constraints.swift @@ -1,4 +1,4 @@ -// RUN: %target-typecheck-verify-swift -enable-experimental-move-only +// RUN: %target-typecheck-verify-swift // a concrete move-only type @_moveOnly struct MO { diff --git a/test/DebugInfo/move_function_dbginfo.swift b/test/DebugInfo/move_function_dbginfo.swift index fb6473758bd44..0b9addfdedb1a 100644 --- a/test/DebugInfo/move_function_dbginfo.swift +++ b/test/DebugInfo/move_function_dbginfo.swift @@ -1,6 +1,6 @@ // RUN: %empty-directory(%t) -// RUN: %target-swift-frontend -enable-experimental-move-only -parse-as-library -g -emit-ir -o - %s | %FileCheck %s -// RUN: %target-swift-frontend -enable-experimental-move-only -parse-as-library -g -c %s -o %t/out.o +// RUN: %target-swift-frontend -parse-as-library -g -emit-ir -o - %s | %FileCheck %s +// RUN: %target-swift-frontend -parse-as-library -g -c %s -o %t/out.o // RUN: %llvm-dwarfdump --show-children %t/out.o | %FileCheck -check-prefix=DWARF %s // This test checks that: diff --git a/test/DebugInfo/move_function_dbginfo_async.swift b/test/DebugInfo/move_function_dbginfo_async.swift index 9feb4028a2a31..c50267d2791cf 100644 --- a/test/DebugInfo/move_function_dbginfo_async.swift +++ b/test/DebugInfo/move_function_dbginfo_async.swift @@ -1,7 +1,7 @@ // RUN: %empty-directory(%t) -// RUN: %target-swift-frontend -parse-as-library -enable-experimental-move-only -disable-availability-checking -g -emit-sil -o - %s | %FileCheck -check-prefix=SIL %s -// RUN: %target-swift-frontend -parse-as-library -enable-experimental-move-only -disable-availability-checking -g -emit-ir -o - %s | %FileCheck %s -// RUN: %target-swift-frontend -parse-as-library -enable-experimental-move-only -disable-availability-checking -g -c %s -o %t/out.o +// RUN: %target-swift-frontend -parse-as-library -disable-availability-checking -g -emit-sil -o - %s | %FileCheck -check-prefix=SIL %s +// RUN: %target-swift-frontend -parse-as-library -disable-availability-checking -g -emit-ir -o - %s | %FileCheck %s +// RUN: %target-swift-frontend -parse-as-library -disable-availability-checking -g -c %s -o %t/out.o // RUN: %llvm-dwarfdump --show-children %t/out.o | %FileCheck -check-prefix=DWARF %s // This test checks that: diff --git a/test/IRGen/moveonly_deinit.sil b/test/IRGen/moveonly_deinit.sil index 2708e9a691804..f67b8449518c1 100644 --- a/test/IRGen/moveonly_deinit.sil +++ b/test/IRGen/moveonly_deinit.sil @@ -1,6 +1,6 @@ // RUN: %empty-directory(%t) // RUN: %{python} %utils/chex.py < %s > %t/moveonly_deinit.sil -// RUN: %target-swift-frontend -enable-experimental-move-only -emit-ir %t/moveonly_deinit.sil | %FileCheck %t/moveonly_deinit.sil --check-prefix=CHECK --check-prefix=CHECK-%target-ptrsize +// RUN: %target-swift-frontend -emit-ir %t/moveonly_deinit.sil | %FileCheck %t/moveonly_deinit.sil --check-prefix=CHECK --check-prefix=CHECK-%target-ptrsize // UNSUPPORTED: CPU=arm64e diff --git a/test/IRGen/moveonly_deinits.swift b/test/IRGen/moveonly_deinits.swift index d55d4a2149cf9..361ed78f5e27c 100644 --- a/test/IRGen/moveonly_deinits.swift +++ b/test/IRGen/moveonly_deinits.swift @@ -1,5 +1,5 @@ // TODO: re-enable the simplification passes once rdar://104875010 is fixed -// RUN: %target-swift-emit-ir -enable-experimental-move-only -Xllvm -sil-disable-pass=simplification %s | %FileCheck -check-prefix=IR %s +// RUN: %target-swift-emit-ir -Xllvm -sil-disable-pass=simplification %s | %FileCheck -check-prefix=IR %s // Test that makes sure that at IRGen time we properly handle conditional // releases for trivial and non-trivial move only types. The SIL/SILGen part of diff --git a/test/IRGen/struct_resilience.swift b/test/IRGen/struct_resilience.swift index 8abeeb403fdb4..f658483249018 100644 --- a/test/IRGen/struct_resilience.swift +++ b/test/IRGen/struct_resilience.swift @@ -339,3 +339,8 @@ public func memoryLayoutDotOffsetOfWithResilientStruct() -> Int? { // CHECK: store i8** [[SIZE_AND_ALIGNMENT:%.*]], i8*** [[FIELD_4]] // CHECK: call void @swift_initStructMetadata(%swift.type* {{.*}}, [[INT]] 256, [[INT]] 4, i8*** [[FIELDS_ADDR]], i32* {{.*}}) + +// coverage for rdar://106669967 where a SIL crash can happen under `-enable-library-evolution -O` +public struct StructWithResilientInit { + public init() {} +} diff --git a/test/Interpreter/moveonly.swift b/test/Interpreter/moveonly.swift index ebf9bb44f0d8a..81337ab9a8f82 100644 --- a/test/Interpreter/moveonly.swift +++ b/test/Interpreter/moveonly.swift @@ -1,4 +1,4 @@ -// RUN: %target-run-simple-swift(-Xfrontend -enable-experimental-move-only -Xfrontend -sil-verify-all) | %FileCheck %s +// RUN: %target-run-simple-swift(-Xfrontend -sil-verify-all) | %FileCheck %s // REQUIRES: executable_test diff --git a/test/Interpreter/moveonly_bufferview.swift b/test/Interpreter/moveonly_bufferview.swift index be7ffd314dab2..dcf65d477261a 100644 --- a/test/Interpreter/moveonly_bufferview.swift +++ b/test/Interpreter/moveonly_bufferview.swift @@ -1,5 +1,5 @@ // TODO: re-enable the simplification passes once rdar://104875010 is fixed -// RUN: %target-run-simple-swift(-Xfrontend -enable-experimental-move-only -Xllvm -sil-disable-pass=simplification) | %FileCheck %s +// RUN: %target-run-simple-swift(-Xllvm -sil-disable-pass=simplification) | %FileCheck %s // REQUIRES: executable_test // REQUIRES: swift_test_mode_optimize_none diff --git a/test/Interpreter/moveonly_consuming_param.swift b/test/Interpreter/moveonly_consuming_param.swift index 3a8112ba5c84a..662655594f8b2 100644 --- a/test/Interpreter/moveonly_consuming_param.swift +++ b/test/Interpreter/moveonly_consuming_param.swift @@ -1,4 +1,4 @@ -// RUN: %target-run-simple-swift(-Xfrontend -enable-experimental-move-only) | %FileCheck %s +// RUN: %target-run-simple-swift | %FileCheck %s // REQUIRES: executable_test diff --git a/test/Interpreter/moveonly_escaping_capture.swift b/test/Interpreter/moveonly_escaping_capture.swift index a0b77a52a2995..6bea33e18bc6a 100644 --- a/test/Interpreter/moveonly_escaping_capture.swift +++ b/test/Interpreter/moveonly_escaping_capture.swift @@ -1,4 +1,4 @@ -// RUN: %target-run-simple-swift(-Xfrontend -enable-experimental-move-only) | %FileCheck %s +// RUN: %target-run-simple-swift | %FileCheck %s // REQUIRES: executable_test // TODO: SIL optimizations cause a miscompile of deinit rdar://105798769 // REQUIRES: swift_test_mode_optimize_none diff --git a/test/Interpreter/moveonly_forget.swift b/test/Interpreter/moveonly_forget.swift index b5b98b19ccf0a..bfd245e35c768 100644 --- a/test/Interpreter/moveonly_forget.swift +++ b/test/Interpreter/moveonly_forget.swift @@ -1,4 +1,4 @@ -// RUN: %target-run-simple-swift(-Xfrontend -enable-experimental-move-only -Xfrontend -sil-verify-all) | %FileCheck %s --implicit-check-not closing +// RUN: %target-run-simple-swift(-Xfrontend -sil-verify-all) | %FileCheck %s --implicit-check-not closing // REQUIRES: executable_test diff --git a/test/ModuleInterface/moveonly_interface.swift b/test/ModuleInterface/moveonly_interface.swift index e6a970dff277b..3fb8a535668b3 100644 --- a/test/ModuleInterface/moveonly_interface.swift +++ b/test/ModuleInterface/moveonly_interface.swift @@ -1,7 +1,7 @@ // RUN: %empty-directory(%t) // FIXME: should work without syntize accessors too -// RUN: %target-swift-frontend -DSYNTHESIZE_ACCESSORS -enable-library-evolution -module-name Hello -emit-module -o %t/Hello.swiftmodule -emit-module-interface-path %t/Hello.swiftinterface %S/Inputs/moveonly_simple.swift -enable-experimental-move-only +// RUN: %target-swift-frontend -DSYNTHESIZE_ACCESSORS -enable-library-evolution -module-name Hello -emit-module -o %t/Hello.swiftmodule -emit-module-interface-path %t/Hello.swiftinterface %S/Inputs/moveonly_simple.swift // rdar://106164128 // XFAIL: * diff --git a/test/ModuleInterface/moveonly_user.swift b/test/ModuleInterface/moveonly_user.swift index 65803c5dbe1dc..afcafa68ff0c6 100644 --- a/test/ModuleInterface/moveonly_user.swift +++ b/test/ModuleInterface/moveonly_user.swift @@ -1,13 +1,13 @@ // RUN: %empty-directory(%t) // >> first try when no library evolution is specified -// RUN: %target-swift-frontend -DSYNTHESIZE_ACCESSORS -enable-experimental-move-only -emit-module -o %t/Hello.swiftmodule %S/Inputs/moveonly_api.swift -// RUN: %target-swift-frontend -emit-sil -sil-verify-all -enable-experimental-move-only -I %t %s > /dev/null +// RUN: %target-swift-frontend -DSYNTHESIZE_ACCESSORS -emit-module -o %t/Hello.swiftmodule %S/Inputs/moveonly_api.swift +// RUN: %target-swift-frontend -emit-sil -sil-verify-all -I %t %s > /dev/null // >> now again with library evolution; we expect the same result. // FIXME: move checker doesn't like it when you specify library evolution -// RUN: %target-swift-frontend -DSYNTHESIZE_ACCESSORS -enable-library-evolution -enable-experimental-move-only -emit-module -o %t/Hello.swiftmodule %S/Inputs/moveonly_api.swift -// RUN: %target-swift-frontend -emit-sil -sil-verify-all -enable-experimental-move-only -I %t %s > /dev/null +// RUN: %target-swift-frontend -DSYNTHESIZE_ACCESSORS -enable-library-evolution -emit-module -o %t/Hello.swiftmodule %S/Inputs/moveonly_api.swift +// RUN: %target-swift-frontend -emit-sil -sil-verify-all -I %t %s > /dev/null // FIXME: ideally this would also try executing the program rather than just generating SIL diff --git a/test/Parse/move_expr.swift b/test/Parse/move_expr.swift index 4efe2c6eaf7fa..9639713fa6ee5 100644 --- a/test/Parse/move_expr.swift +++ b/test/Parse/move_expr.swift @@ -1,4 +1,4 @@ -// RUN: %target-typecheck-verify-swift -disable-availability-checking -enable-experimental-move-only +// RUN: %target-typecheck-verify-swift -disable-availability-checking var global: Int = 5 func testGlobal() { @@ -51,11 +51,6 @@ func useConsumeVar(consume: inout String) { let _ = consume[i] } -// Temporary `_move` syntax is still parsed but raises a warning and fixit. -func oldMoveSyntax(x: String) { - _ = _move x // expected-warning{{renamed to 'consume'}} {{9-14=consume}} -} - @propertyWrapper struct FooWrapper { var value: T diff --git a/test/Parse/move_expr_legacy.swift b/test/Parse/move_expr_legacy.swift new file mode 100644 index 0000000000000..1e66f9ab15f45 --- /dev/null +++ b/test/Parse/move_expr_legacy.swift @@ -0,0 +1,6 @@ +// RUN: %target-typecheck-verify-swift -disable-availability-checking -enable-experimental-move-only + +// Temporary `_move` syntax is still parsed but raises a warning and fixit. +func oldMoveSyntax(x: String) { + _ = _move x // expected-warning{{renamed to 'consume'}} {{7-12=consume}} +} diff --git a/test/Parse/move_func_decl.swift b/test/Parse/move_func_decl.swift index 44976a77404e7..3ec2d6f8b1546 100644 --- a/test/Parse/move_func_decl.swift +++ b/test/Parse/move_func_decl.swift @@ -12,3 +12,12 @@ func testUserMove() { let t = String() let _ = _move(t: t) } + +struct What { + func _move(_ x: String) -> String { return x } + + func testMethod() { + let t = String() + let _ = _move(t) + } +} diff --git a/test/SIL/Parser/basic2_moveonly.sil b/test/SIL/Parser/basic2_moveonly.sil index 118b93acb7b3e..189e51bf95fed 100644 --- a/test/SIL/Parser/basic2_moveonly.sil +++ b/test/SIL/Parser/basic2_moveonly.sil @@ -1,4 +1,4 @@ -// RUN: %target-sil-opt -enable-experimental-move-only %s | %target-sil-opt -enable-experimental-move-only | %FileCheck %s +// RUN: %target-sil-opt %s | %target-sil-opt | %FileCheck %s // Once move only is no longer behind a feature flag, merge this into basic2. @@ -31,4 +31,4 @@ bb0(%0 : @guaranteed $Klass): %9999 = tuple() return %9999 : $() -} \ No newline at end of file +} diff --git a/test/SIL/Serialization/basic2_moveonly.sil b/test/SIL/Serialization/basic2_moveonly.sil index dd55b83527c62..d89fc911079d5 100644 --- a/test/SIL/Serialization/basic2_moveonly.sil +++ b/test/SIL/Serialization/basic2_moveonly.sil @@ -1,7 +1,7 @@ // RUN: %empty-directory(%t) -// RUN: %target-sil-opt -enable-experimental-move-only %s -emit-sib -o %t/tmp.sib -module-name basic2 -// RUN: %target-sil-opt -enable-experimental-move-only %t/tmp.sib -o %t/tmp.2.sib -module-name basic2 -// RUN: %target-sil-opt -enable-experimental-move-only %t/tmp.2.sib -module-name basic2 -emit-sorted-sil | %FileCheck %s +// RUN: %target-sil-opt %s -emit-sib -o %t/tmp.sib -module-name basic2 +// RUN: %target-sil-opt %t/tmp.sib -o %t/tmp.2.sib -module-name basic2 +// RUN: %target-sil-opt %t/tmp.2.sib -module-name basic2 -emit-sorted-sil | %FileCheck %s // Once move only is no longer behind a feature flag, merge this into basic2. @@ -34,4 +34,4 @@ bb0(%0 : @guaranteed $Klass): %9999 = tuple() return %9999 : $() -} \ No newline at end of file +} diff --git a/test/SILGen/copy_operator.swift b/test/SILGen/copy_operator.swift index 2055dd6092ef6..0a022f3894dcd 100644 --- a/test/SILGen/copy_operator.swift +++ b/test/SILGen/copy_operator.swift @@ -1,6 +1,6 @@ -// RUN: %target-swift-emit-silgen -enable-copy-propagation=requested-passes-only -module-name moveonly -parse-stdlib %s -disable-access-control -disable-objc-attr-requires-foundation-module -enable-experimental-move-only | %FileCheck %s -// RUN: %target-swift-emit-sil -enable-copy-propagation=requested-passes-only -module-name moveonly -parse-stdlib %s -disable-access-control -disable-objc-attr-requires-foundation-module -enable-experimental-move-only | %FileCheck -check-prefix=CHECK-SIL %s -// RUN: %target-swift-emit-sil -enable-copy-propagation=requested-passes-only -module-name moveonly -parse-stdlib %s -disable-access-control -disable-objc-attr-requires-foundation-module -O -Xllvm -sil-disable-pass=FunctionSignatureOpts -enable-experimental-move-only | %FileCheck -check-prefix=CHECK-SIL-OPT %s +// RUN: %target-swift-emit-silgen -enable-copy-propagation=requested-passes-only -module-name moveonly -parse-stdlib %s -disable-access-control -disable-objc-attr-requires-foundation-module | %FileCheck %s +// RUN: %target-swift-emit-sil -enable-copy-propagation=requested-passes-only -module-name moveonly -parse-stdlib %s -disable-access-control -disable-objc-attr-requires-foundation-module | %FileCheck -check-prefix=CHECK-SIL %s +// RUN: %target-swift-emit-sil -enable-copy-propagation=requested-passes-only -module-name moveonly -parse-stdlib %s -disable-access-control -disable-objc-attr-requires-foundation-module -O -Xllvm -sil-disable-pass=FunctionSignatureOpts | %FileCheck -check-prefix=CHECK-SIL-OPT %s // REQUIRES: swift_in_compiler diff --git a/test/SILGen/copy_operator_generic_failure.swift b/test/SILGen/copy_operator_generic_failure.swift index afeabbbc7d662..893a833633936 100644 --- a/test/SILGen/copy_operator_generic_failure.swift +++ b/test/SILGen/copy_operator_generic_failure.swift @@ -1,4 +1,4 @@ -// RUN: %target-swift-emit-sil -enable-experimental-move-only -parse-stdlib %s -disable-access-control -disable-objc-attr-requires-foundation-module -verify +// RUN: %target-swift-emit-sil -parse-stdlib %s -disable-access-control -disable-objc-attr-requires-foundation-module -verify import Swift diff --git a/test/SILGen/forget.swift b/test/SILGen/forget.swift index 02a6f2d30e0ef..c2ef35d8545ac 100644 --- a/test/SILGen/forget.swift +++ b/test/SILGen/forget.swift @@ -1,5 +1,5 @@ -// RUN: %target-swift-emit-silgen -enable-experimental-move-only -module-name test %s | %FileCheck %s --enable-var-scope -// RUN: %target-swift-emit-sil -enable-experimental-move-only -module-name test -sil-verify-all %s | %FileCheck %s --check-prefix CHECK-SIL --enable-var-scope +// RUN: %target-swift-emit-silgen -module-name test %s | %FileCheck %s --enable-var-scope +// RUN: %target-swift-emit-sil -module-name test -sil-verify-all %s | %FileCheck %s --check-prefix CHECK-SIL --enable-var-scope func invokedDeinit() {} diff --git a/test/SILGen/moveonly.swift b/test/SILGen/moveonly.swift index 3fc60b51fc457..c1e7f3b69975b 100644 --- a/test/SILGen/moveonly.swift +++ b/test/SILGen/moveonly.swift @@ -1,4 +1,4 @@ -// RUN: %target-swift-emit-silgen -enable-experimental-move-only %s | %FileCheck %s +// RUN: %target-swift-emit-silgen %s | %FileCheck %s ////////////////// // Declarations // diff --git a/test/SILGen/moveonly_deinit_access.swift b/test/SILGen/moveonly_deinit_access.swift index 9cd8c52ff94f1..ae71e54d7ad34 100644 --- a/test/SILGen/moveonly_deinit_access.swift +++ b/test/SILGen/moveonly_deinit_access.swift @@ -1,5 +1,5 @@ -// RUN: %target-swift-emit-silgen -enable-experimental-move-only %s | %FileCheck %s -// RUN: %target-swift-emit-sil -enable-experimental-move-only %s | %FileCheck -check-prefix=SIL %s +// RUN: %target-swift-emit-silgen %s | %FileCheck %s +// RUN: %target-swift-emit-sil %s | %FileCheck -check-prefix=SIL %s // This test makes sure that in various situations (ignoring errors), we // properly handle deinits with move only types. diff --git a/test/SILGen/moveonly_deinit_module_no_body.swift b/test/SILGen/moveonly_deinit_module_no_body.swift index 0d8d81164e3dc..4cb3ae4d686eb 100644 --- a/test/SILGen/moveonly_deinit_module_no_body.swift +++ b/test/SILGen/moveonly_deinit_module_no_body.swift @@ -1,4 +1,4 @@ -// RUN: %target-swift-frontend -emit-module -g -enable-experimental-move-only -experimental-skip-non-inlinable-function-bodies-without-types %s +// RUN: %target-swift-frontend -emit-module -g -experimental-skip-non-inlinable-function-bodies-without-types %s // Just make sure we don't crash. diff --git a/test/SILGen/moveonly_deinits.swift b/test/SILGen/moveonly_deinits.swift index 2bda2b55cce1d..3030c12549da0 100644 --- a/test/SILGen/moveonly_deinits.swift +++ b/test/SILGen/moveonly_deinits.swift @@ -1,6 +1,6 @@ // TODO: re-enable the simplification passes once rdar://104875010 is fixed -// RUN: %target-swift-emit-silgen -enable-experimental-move-only -Xllvm -sil-disable-pass=simplification %s | %FileCheck -check-prefix=SILGEN %s -// RUN: %target-swift-emit-sil -enable-experimental-move-only -Xllvm -sil-disable-pass=simplification %s | %FileCheck -check-prefix=SIL %s +// RUN: %target-swift-emit-silgen -Xllvm -sil-disable-pass=simplification %s | %FileCheck -check-prefix=SILGEN %s +// RUN: %target-swift-emit-sil -Xllvm -sil-disable-pass=simplification %s | %FileCheck -check-prefix=SIL %s // Test that makes sure that throughout the pipeline we properly handle // conditional releases for trivial and non-trivial move only types. diff --git a/test/SILGen/moveonly_enum_literal.swift b/test/SILGen/moveonly_enum_literal.swift index 2ee929c4120d5..80ca7c4ac0e26 100644 --- a/test/SILGen/moveonly_enum_literal.swift +++ b/test/SILGen/moveonly_enum_literal.swift @@ -1,4 +1,4 @@ -// RUN: %target-swift-frontend -enable-experimental-move-only -emit-silgen %s | %FileCheck %s +// RUN: %target-swift-frontend -emit-silgen %s | %FileCheck %s // This test makes sure that we properly setup enums when we construct moveonly // enums from literals. diff --git a/test/SILGen/moveonly_var.swift b/test/SILGen/moveonly_var.swift index 84657605abc38..e29e12ed2557c 100644 --- a/test/SILGen/moveonly_var.swift +++ b/test/SILGen/moveonly_var.swift @@ -1,5 +1,5 @@ -// RUN: %target-swift-emit-silgen -enable-experimental-move-only -enable-experimental-feature MoveOnlyClasses %s | %FileCheck %s -// RUN: %target-swift-emit-sil -enable-experimental-move-only -enable-experimental-feature MoveOnlyClasses %s | %FileCheck %s +// RUN: %target-swift-emit-silgen -enable-experimental-feature MoveOnlyClasses %s | %FileCheck %s +// RUN: %target-swift-emit-sil -enable-experimental-feature MoveOnlyClasses %s | %FileCheck %s ////////////////// // Declarations // diff --git a/test/SILOptimizer/accessutils_raw.sil b/test/SILOptimizer/accessutils_raw.sil index d1f819a502f74..461c2a96308b1 100644 --- a/test/SILOptimizer/accessutils_raw.sil +++ b/test/SILOptimizer/accessutils_raw.sil @@ -1,4 +1,4 @@ -// RUN: %target-sil-opt -enable-experimental-move-only %s -dump-access -o /dev/null | %FileCheck %s +// RUN: %target-sil-opt %s -dump-access -o /dev/null | %FileCheck %s // REQUIRES: swift_in_compiler @@ -52,4 +52,4 @@ bb0(%0 : @guaranteed $List): %9999 = tuple() return %9999 : $() -} \ No newline at end of file +} diff --git a/test/SILOptimizer/allocbox_to_stack_noncopyable.sil b/test/SILOptimizer/allocbox_to_stack_noncopyable.sil index ddfb5039c88cb..9defd802277da 100644 --- a/test/SILOptimizer/allocbox_to_stack_noncopyable.sil +++ b/test/SILOptimizer/allocbox_to_stack_noncopyable.sil @@ -1,4 +1,4 @@ -// RUN: %target-sil-opt -enable-experimental-move-only -enable-sil-verify-all %s -allocbox-to-stack -enable-copy-propagation=requested-passes-only -enable-lexical-borrow-scopes=false | %FileCheck %s +// RUN: %target-sil-opt -enable-sil-verify-all %s -allocbox-to-stack -enable-copy-propagation=requested-passes-only | %FileCheck %s sil_stage raw @@ -159,4 +159,4 @@ bb2: bb3: %30 = tuple () return %30 : $() -} \ No newline at end of file +} diff --git a/test/SILOptimizer/consume_operator_kills_addresses_dbginfo.sil b/test/SILOptimizer/consume_operator_kills_addresses_dbginfo.sil index 54202d565adc8..4f145e3552a0b 100644 --- a/test/SILOptimizer/consume_operator_kills_addresses_dbginfo.sil +++ b/test/SILOptimizer/consume_operator_kills_addresses_dbginfo.sil @@ -1,4 +1,4 @@ -// RUN: %target-sil-opt %s -enable-experimental-move-only -sil-consume-operator-copyable-addresses-checker | %FileCheck %s +// RUN: %target-sil-opt %s -sil-consume-operator-copyable-addresses-checker | %FileCheck %s // REQUIRES: optimized_stdlib diff --git a/test/SILOptimizer/consume_operator_kills_copyable_addresses.sil b/test/SILOptimizer/consume_operator_kills_copyable_addresses.sil index a07d592378784..06275fe566c5b 100644 --- a/test/SILOptimizer/consume_operator_kills_copyable_addresses.sil +++ b/test/SILOptimizer/consume_operator_kills_copyable_addresses.sil @@ -1,4 +1,4 @@ -// RUN: %target-sil-opt -enable-experimental-move-only -enable-sil-verify-all -o - -sil-consume-operator-copyable-addresses-checker -verify %s +// RUN: %target-sil-opt -enable-sil-verify-all -o - -sil-consume-operator-copyable-addresses-checker -verify %s // This file is meant for specific SIL patterns that may be hard to produce with // the current swift frontend but have reproduced before and we want to make diff --git a/test/SILOptimizer/consume_operator_kills_copyable_addressonly_lets.swift b/test/SILOptimizer/consume_operator_kills_copyable_addressonly_lets.swift index 7076ef1f3e00e..cd6dada6bafc3 100644 --- a/test/SILOptimizer/consume_operator_kills_copyable_addressonly_lets.swift +++ b/test/SILOptimizer/consume_operator_kills_copyable_addressonly_lets.swift @@ -1,4 +1,4 @@ -// RUN: %target-swift-frontend -enable-experimental-move-only -verify %s -parse-stdlib -emit-sil -o /dev/null +// RUN: %target-swift-frontend -verify %s -parse-stdlib -emit-sil -o /dev/null import Swift diff --git a/test/SILOptimizer/consume_operator_kills_copyable_addressonly_vars.swift b/test/SILOptimizer/consume_operator_kills_copyable_addressonly_vars.swift index 8cc7941fe8508..5e6a43d3f47e5 100644 --- a/test/SILOptimizer/consume_operator_kills_copyable_addressonly_vars.swift +++ b/test/SILOptimizer/consume_operator_kills_copyable_addressonly_vars.swift @@ -1,4 +1,4 @@ -// RUN: %target-swift-frontend -enable-experimental-move-only -verify %s -parse-stdlib -emit-sil -o /dev/null +// RUN: %target-swift-frontend -verify %s -parse-stdlib -emit-sil -o /dev/null import Swift diff --git a/test/SILOptimizer/consume_operator_kills_copyable_addressonly_vars_crash.swift b/test/SILOptimizer/consume_operator_kills_copyable_addressonly_vars_crash.swift index 71f4af0b4579f..9343d06d3f0dd 100644 --- a/test/SILOptimizer/consume_operator_kills_copyable_addressonly_vars_crash.swift +++ b/test/SILOptimizer/consume_operator_kills_copyable_addressonly_vars_crash.swift @@ -1,4 +1,4 @@ -// RUN: %target-swift-frontend -enable-experimental-move-only %s -parse-stdlib -emit-sil -o /dev/null +// RUN: %target-swift-frontend %s -parse-stdlib -emit-sil -o /dev/null import Swift diff --git a/test/SILOptimizer/consume_operator_kills_copyable_loadable_vars.swift b/test/SILOptimizer/consume_operator_kills_copyable_loadable_vars.swift index 1da5d19e3e56d..daad3442be365 100644 --- a/test/SILOptimizer/consume_operator_kills_copyable_loadable_vars.swift +++ b/test/SILOptimizer/consume_operator_kills_copyable_loadable_vars.swift @@ -1,4 +1,4 @@ -// RUN: %target-swift-frontend -enable-experimental-move-only -verify %s -parse-stdlib -emit-sil -o /dev/null +// RUN: %target-swift-frontend -verify %s -parse-stdlib -emit-sil -o /dev/null import Swift diff --git a/test/SILOptimizer/consume_operator_kills_copyable_values.sil b/test/SILOptimizer/consume_operator_kills_copyable_values.sil index 26fb53cad5dff..4701eb90138c8 100644 --- a/test/SILOptimizer/consume_operator_kills_copyable_values.sil +++ b/test/SILOptimizer/consume_operator_kills_copyable_values.sil @@ -1,4 +1,4 @@ -// RUN: %target-sil-opt -enable-experimental-move-only -enable-sil-verify-all -o - -sil-consume-operator-copyable-values-checker -verify %s +// RUN: %target-sil-opt -enable-sil-verify-all -o - -sil-consume-operator-copyable-values-checker -verify %s // This file is meant for specific SIL patterns that may be hard to produce with // the current swift frontend but have reproduced before and we want to make diff --git a/test/SILOptimizer/consume_operator_kills_copyable_values.swift b/test/SILOptimizer/consume_operator_kills_copyable_values.swift index 8e388a55bacef..5c015e0f7973e 100644 --- a/test/SILOptimizer/consume_operator_kills_copyable_values.swift +++ b/test/SILOptimizer/consume_operator_kills_copyable_values.swift @@ -1,4 +1,4 @@ -// RUN: %target-swift-frontend -enable-experimental-move-only -verify %s -parse-stdlib -emit-sil -o /dev/null +// RUN: %target-swift-frontend -verify %s -parse-stdlib -emit-sil -o /dev/null import Swift diff --git a/test/SILOptimizer/consume_operator_kills_values_dbginfo.sil b/test/SILOptimizer/consume_operator_kills_values_dbginfo.sil index c052b9221ac47..641425a3156af 100644 --- a/test/SILOptimizer/consume_operator_kills_values_dbginfo.sil +++ b/test/SILOptimizer/consume_operator_kills_values_dbginfo.sil @@ -1,4 +1,4 @@ -// RUN: %target-sil-opt %s -enable-experimental-move-only -sil-consume-operator-copyable-values-checker | %FileCheck %s +// RUN: %target-sil-opt %s -sil-consume-operator-copyable-values-checker | %FileCheck %s // REQUIRES: optimized_stdlib diff --git a/test/SILOptimizer/moveonly_addresschecker.sil b/test/SILOptimizer/moveonly_addresschecker.sil index 22c2f3debfdf9..13d32669788e5 100644 --- a/test/SILOptimizer/moveonly_addresschecker.sil +++ b/test/SILOptimizer/moveonly_addresschecker.sil @@ -1,4 +1,4 @@ -// RUN: %target-sil-opt -module-name moveonly_addresschecker -sil-move-only-address-checker -enable-experimental-move-only -enable-experimental-feature MoveOnlyClasses -enable-sil-verify-all %s | %FileCheck %s +// RUN: %target-sil-opt -module-name moveonly_addresschecker -sil-move-only-address-checker -enable-experimental-feature MoveOnlyClasses -enable-sil-verify-all %s | %FileCheck %s sil_stage raw diff --git a/test/SILOptimizer/moveonly_addresschecker_diagnostics.sil b/test/SILOptimizer/moveonly_addresschecker_diagnostics.sil index 0c8d062c74e97..3ac609dee69d0 100644 --- a/test/SILOptimizer/moveonly_addresschecker_diagnostics.sil +++ b/test/SILOptimizer/moveonly_addresschecker_diagnostics.sil @@ -1,5 +1,5 @@ -// RUN: %target-sil-opt -sil-move-only-address-checker -enable-experimental-move-only -enable-experimental-feature MoveOnlyClasses -enable-sil-verify-all %s -verify -// RUN: %target-sil-opt -sil-move-only-address-checker -enable-experimental-move-only -enable-experimental-feature MoveOnlyClasses -enable-sil-verify-all -move-only-diagnostics-silently-emit-diagnostics %s | %FileCheck %s +// RUN: %target-sil-opt -sil-move-only-address-checker -enable-experimental-feature MoveOnlyClasses -enable-sil-verify-all %s -verify +// RUN: %target-sil-opt -sil-move-only-address-checker -enable-experimental-feature MoveOnlyClasses -enable-sil-verify-all -move-only-diagnostics-silently-emit-diagnostics %s | %FileCheck %s // TODO: Add FileCheck diff --git a/test/SILOptimizer/moveonly_addresschecker_diagnostics.swift b/test/SILOptimizer/moveonly_addresschecker_diagnostics.swift index cf0578cbaae5e..92f6c6781976a 100644 --- a/test/SILOptimizer/moveonly_addresschecker_diagnostics.swift +++ b/test/SILOptimizer/moveonly_addresschecker_diagnostics.swift @@ -1,4 +1,4 @@ -// RUN: %target-swift-emit-sil -sil-verify-all -verify -enable-experimental-move-only -enable-experimental-feature MoveOnlyClasses %s +// RUN: %target-swift-emit-sil -sil-verify-all -verify -enable-experimental-feature MoveOnlyClasses %s ////////////////// // Declarations // diff --git a/test/SILOptimizer/moveonly_borrow_to_destructure_transform.sil b/test/SILOptimizer/moveonly_borrow_to_destructure_transform.sil index 60bf258e7d172..41680fa5c076c 100644 --- a/test/SILOptimizer/moveonly_borrow_to_destructure_transform.sil +++ b/test/SILOptimizer/moveonly_borrow_to_destructure_transform.sil @@ -1,4 +1,4 @@ -// RUN: %target-sil-opt -enable-experimental-move-only -enable-experimental-feature MoveOnlyClasses -enable-sil-verify-all -sil-move-only-borrow-to-destructure %s | %FileCheck %s +// RUN: %target-sil-opt -enable-experimental-feature MoveOnlyClasses -enable-sil-verify-all -sil-move-only-borrow-to-destructure %s | %FileCheck %s sil_stage raw @@ -1026,4 +1026,4 @@ bbCont: destroy_value %2 : $E2 %9999 = tuple() return %9999 : $() -} \ No newline at end of file +} diff --git a/test/SILOptimizer/moveonly_borrow_to_destructure_transform_diagnostics.sil b/test/SILOptimizer/moveonly_borrow_to_destructure_transform_diagnostics.sil index b588a325b9605..0b77477ef32f9 100644 --- a/test/SILOptimizer/moveonly_borrow_to_destructure_transform_diagnostics.sil +++ b/test/SILOptimizer/moveonly_borrow_to_destructure_transform_diagnostics.sil @@ -1,5 +1,5 @@ -// RUN: %target-sil-opt -move-only-diagnostics-silently-emit-diagnostics -enable-experimental-move-only -enable-experimental-feature MoveOnlyClasses -enable-sil-verify-all -sil-move-only-borrow-to-destructure %s | %FileCheck %s -// RUN: %target-sil-opt -verify -enable-experimental-move-only -enable-experimental-feature MoveOnlyClasses -enable-sil-verify-all -sil-move-only-borrow-to-destructure %s +// RUN: %target-sil-opt -move-only-diagnostics-silently-emit-diagnostics -enable-experimental-feature MoveOnlyClasses -enable-sil-verify-all -sil-move-only-borrow-to-destructure %s | %FileCheck %s +// RUN: %target-sil-opt -verify -enable-experimental-feature MoveOnlyClasses -enable-sil-verify-all -sil-move-only-borrow-to-destructure %s sil_stage raw diff --git a/test/SILOptimizer/moveonly_coro_accessor.swift b/test/SILOptimizer/moveonly_coro_accessor.swift index 389a9e686e12a..e57456a42f549 100644 --- a/test/SILOptimizer/moveonly_coro_accessor.swift +++ b/test/SILOptimizer/moveonly_coro_accessor.swift @@ -1,4 +1,4 @@ -// RUN: %target-swift-emit-sil -module-name test -sil-verify-all -verify -enable-experimental-move-only %s | %FileCheck %s --enable-var-scope +// RUN: %target-swift-emit-sil -module-name test -sil-verify-all -verify %s | %FileCheck %s --enable-var-scope @inline(never) func someFunction() {} diff --git a/test/SILOptimizer/moveonly_deinit_insertion.sil b/test/SILOptimizer/moveonly_deinit_insertion.sil index 21d108f1521dd..5759ea375ebc8 100644 --- a/test/SILOptimizer/moveonly_deinit_insertion.sil +++ b/test/SILOptimizer/moveonly_deinit_insertion.sil @@ -1,4 +1,4 @@ -// RUN: %target-sil-opt -module-name main -enable-sil-verify-all -sil-move-only-deinit-insertion -enable-experimental-move-only -enable-experimental-feature MoveOnlyClasses %s | %FileCheck %s +// RUN: %target-sil-opt -module-name main -enable-sil-verify-all -sil-move-only-deinit-insertion -enable-experimental-feature MoveOnlyClasses %s | %FileCheck %s sil_stage raw @@ -339,4 +339,4 @@ sil_moveonlydeinit TrivialMoveOnlyEnum { sil_moveonlydeinit NonTrivialMoveOnlyEnum { @$s4main22NonTrivialMoveOnlyEnumOfD -} \ No newline at end of file +} diff --git a/test/SILOptimizer/moveonly_deinits.swift b/test/SILOptimizer/moveonly_deinits.swift index c511789be246b..24e27be466e67 100644 --- a/test/SILOptimizer/moveonly_deinits.swift +++ b/test/SILOptimizer/moveonly_deinits.swift @@ -1,4 +1,4 @@ -// RUN: %target-swift-frontend -sil-verify-all -enable-experimental-move-only -verify -emit-sil %s +// RUN: %target-swift-frontend -sil-verify-all -verify -emit-sil %s class Klass {} diff --git a/test/SILOptimizer/moveonly_forget.swift b/test/SILOptimizer/moveonly_forget.swift index db22c399d504c..d6dbe89b3cd4d 100644 --- a/test/SILOptimizer/moveonly_forget.swift +++ b/test/SILOptimizer/moveonly_forget.swift @@ -1,4 +1,4 @@ -// RUN: %target-swift-frontend -sil-verify-all -enable-experimental-move-only -verify -emit-sil %s +// RUN: %target-swift-frontend -sil-verify-all -verify -emit-sil %s func posix_close(_ t: Int) {} diff --git a/test/SILOptimizer/moveonly_lifetime.swift b/test/SILOptimizer/moveonly_lifetime.swift index 623430e1bd559..cf56d868f1dad 100644 --- a/test/SILOptimizer/moveonly_lifetime.swift +++ b/test/SILOptimizer/moveonly_lifetime.swift @@ -1,4 +1,4 @@ -// RUN: %target-swift-emit-sil -sil-verify-all -module-name moveonly_lifetime -o /dev/null -Xllvm -sil-print-canonical-module -Onone -verify -enable-experimental-move-only -enable-experimental-feature MoveOnlyClasses %s 2>&1 | %FileCheck %s +// RUN: %target-swift-emit-sil -sil-verify-all -module-name moveonly_lifetime -o /dev/null -Xllvm -sil-print-canonical-module -Onone -verify -enable-experimental-feature MoveOnlyClasses %s 2>&1 | %FileCheck %s @_moveOnly class C {} diff --git a/test/SILOptimizer/moveonly_nonescaping_closures.swift b/test/SILOptimizer/moveonly_nonescaping_closures.swift index 5a588bd49db68..6f48d0803de34 100644 --- a/test/SILOptimizer/moveonly_nonescaping_closures.swift +++ b/test/SILOptimizer/moveonly_nonescaping_closures.swift @@ -1,4 +1,4 @@ -// RUN: %target-swift-frontend -enable-experimental-move-only -emit-sil -verify %s +// RUN: %target-swift-frontend -emit-sil -verify %s // TODO: test with (-DNONTRIVIAL | -DADDRESS_ONLY) * (REABSTRACT) protocol P {} diff --git a/test/SILOptimizer/moveonly_objectchecker.sil b/test/SILOptimizer/moveonly_objectchecker.sil index 1f604018f16ec..0cbc5817c4f6b 100644 --- a/test/SILOptimizer/moveonly_objectchecker.sil +++ b/test/SILOptimizer/moveonly_objectchecker.sil @@ -1,4 +1,4 @@ -// RUN: %target-sil-opt -sil-move-only-object-checker -enable-experimental-move-only -enable-experimental-feature MoveOnlyClasses -enable-sil-verify-all -move-only-diagnostics-silently-emit-diagnostics %s | %FileCheck %s +// RUN: %target-sil-opt -sil-move-only-object-checker -enable-experimental-feature MoveOnlyClasses -enable-sil-verify-all -move-only-diagnostics-silently-emit-diagnostics %s | %FileCheck %s sil_stage raw diff --git a/test/SILOptimizer/moveonly_objectchecker_diagnostics.swift b/test/SILOptimizer/moveonly_objectchecker_diagnostics.swift index 5e9c0d2c9a885..174e8b685f666 100644 --- a/test/SILOptimizer/moveonly_objectchecker_diagnostics.swift +++ b/test/SILOptimizer/moveonly_objectchecker_diagnostics.swift @@ -1,4 +1,4 @@ -// RUN: %target-swift-emit-sil -sil-verify-all -verify -enable-experimental-move-only -enable-experimental-feature MoveOnlyClasses %s +// RUN: %target-swift-emit-sil -sil-verify-all -verify -enable-experimental-feature MoveOnlyClasses %s ////////////////// // Declarations // diff --git a/test/SILOptimizer/moveonly_trivial_addresschecker_diagnostics.swift b/test/SILOptimizer/moveonly_trivial_addresschecker_diagnostics.swift index 0be3efd0b93ef..52b4e1eaec8c4 100644 --- a/test/SILOptimizer/moveonly_trivial_addresschecker_diagnostics.swift +++ b/test/SILOptimizer/moveonly_trivial_addresschecker_diagnostics.swift @@ -1,4 +1,4 @@ -// RUN: %target-swift-emit-sil -sil-verify-all -verify -enable-experimental-move-only %s +// RUN: %target-swift-emit-sil -sil-verify-all -verify %s ////////////////// // Declarations // diff --git a/test/SILOptimizer/moveonly_trivial_objectchecker_diagnostics.swift b/test/SILOptimizer/moveonly_trivial_objectchecker_diagnostics.swift index 2a4fba5f7d049..86f909603cfd2 100644 --- a/test/SILOptimizer/moveonly_trivial_objectchecker_diagnostics.swift +++ b/test/SILOptimizer/moveonly_trivial_objectchecker_diagnostics.swift @@ -1,4 +1,4 @@ -// RUN: %target-swift-emit-sil -sil-verify-all -verify -enable-experimental-move-only %s +// RUN: %target-swift-emit-sil -sil-verify-all -verify %s ////////////////// // Declarations // diff --git a/test/Sema/copyable.swift b/test/Sema/copyable.swift index d4d6d2f420f9d..b99b469236587 100644 --- a/test/Sema/copyable.swift +++ b/test/Sema/copyable.swift @@ -1,4 +1,4 @@ -// RUN: %target-typecheck-verify-swift -enable-experimental-move-only +// RUN: %target-typecheck-verify-swift protocol P: _Copyable {} // expected-error {{'_Copyable' is unavailable}} struct S: P {} diff --git a/test/Sema/copyable_constraint.swift b/test/Sema/copyable_constraint.swift index 704a63af6faee..fbed87084eb71 100644 --- a/test/Sema/copyable_constraint.swift +++ b/test/Sema/copyable_constraint.swift @@ -1,9 +1,9 @@ // >> First verify that when building the stdlib, we do have the copyable constraint. Note the module-name!! -// RUN: %target-swift-frontend -enable-experimental-move-only -typecheck -verify -parse-stdlib -module-name Swift %s +// RUN: %target-swift-frontend -typecheck -verify -parse-stdlib -module-name Swift %s // FIXME: Now demonstrate that plain -parse-stdlib, such as in some arbitrary test, doesn't get the Copyable constraint :( -// RUN: not %target-swift-frontend -enable-experimental-move-only -typecheck -verify -parse-stdlib %s +// RUN: not %target-swift-frontend -typecheck -verify -parse-stdlib %s @_marker public protocol _Copyable {} diff --git a/test/Sema/forget.swift b/test/Sema/forget.swift index fa4366d7443a4..08f84bafcee04 100644 --- a/test/Sema/forget.swift +++ b/test/Sema/forget.swift @@ -1,4 +1,4 @@ -// RUN: %target-typecheck-verify-swift -enable-experimental-move-only +// RUN: %target-typecheck-verify-swift // Typechecking for the forget statement. diff --git a/test/Sema/forget_module.swift b/test/Sema/forget_module.swift index 3b7cd8c4636d8..70fc537bca093 100644 --- a/test/Sema/forget_module.swift +++ b/test/Sema/forget_module.swift @@ -1,12 +1,12 @@ // RUN: %empty-directory(%t) // >> first try when no library evolution is specified -// RUN: %target-swift-frontend -enable-experimental-move-only -emit-module -o %t/SorryModule.swiftmodule %S/Inputs/forget_module_defining.swift %S/Inputs/forget_module_adjacent.swift -// RUN: %target-typecheck-verify-swift -enable-experimental-move-only -I %t +// RUN: %target-swift-frontend -emit-module -o %t/SorryModule.swiftmodule %S/Inputs/forget_module_defining.swift %S/Inputs/forget_module_adjacent.swift +// RUN: %target-typecheck-verify-swift -I %t // >> now again with library evolution; we expect the same result. -// RUN: %target-swift-frontend -enable-library-evolution -enable-experimental-move-only -emit-module -o %t/SorryModule.swiftmodule %S/Inputs/forget_module_defining.swift %S/Inputs/forget_module_adjacent.swift -// RUN: %target-typecheck-verify-swift -enable-experimental-move-only -I %t +// RUN: %target-swift-frontend -enable-library-evolution -emit-module -o %t/SorryModule.swiftmodule %S/Inputs/forget_module_defining.swift %S/Inputs/forget_module_adjacent.swift +// RUN: %target-typecheck-verify-swift -I %t // "Sorry" is meaningless import SorryModule diff --git a/test/Sema/move_expr.swift b/test/Sema/move_expr.swift index 152122b522d0d..967cf1cc6a898 100644 --- a/test/Sema/move_expr.swift +++ b/test/Sema/move_expr.swift @@ -1,4 +1,4 @@ -// RUN: %target-typecheck-verify-swift -disable-availability-checking -enable-experimental-move-only +// RUN: %target-typecheck-verify-swift -disable-availability-checking class Klass { var k: Klass? = nil diff --git a/test/Sema/moveonly_decl_attr.swift b/test/Sema/moveonly_decl_attr.swift index 2387c1c742f44..1742592e59a3e 100644 --- a/test/Sema/moveonly_decl_attr.swift +++ b/test/Sema/moveonly_decl_attr.swift @@ -1,4 +1,4 @@ -// RUN: %target-typecheck-verify-swift -parse-stdlib -disable-availability-checking -enable-experimental-move-only +// RUN: %target-typecheck-verify-swift -parse-stdlib -disable-availability-checking import Swift @@ -23,4 +23,4 @@ enum E { @_moveOnly protocol P {} // expected-error {{'moveOnly' only applies to structs or enums}}{{1-12=}} @_moveOnly actor A {} // expected-error {{'moveOnly' only applies to structs or enums}}{{1-12=}} -@_moveOnly extension C {} // expected-error {{'@_moveOnly' attribute cannot be applied to this declaration}}{{1-12=}} \ No newline at end of file +@_moveOnly extension C {} // expected-error {{'@_moveOnly' attribute cannot be applied to this declaration}}{{1-12=}} diff --git a/test/Sema/moveonly_experimental.swift b/test/Sema/moveonly_experimental.swift new file mode 100644 index 0000000000000..50eecea954d38 --- /dev/null +++ b/test/Sema/moveonly_experimental.swift @@ -0,0 +1,36 @@ +// RUN: %target-typecheck-verify-swift + +// this test verifies what features are still behind the experimental flag by not providing it. + +struct SomeValue {} + +@_moveOnly class NoncopyableClass {} // expected-error {{'moveOnly' only applies to structs or enums}} + +func checkOldConsumeName() { + let x = SomeValue() + + let _ = _move x // expected-error {{cannot find '_move' in scope}} + // expected-error@-1 {{consecutive statements on a line must be separated by ';'}} + // expected-warning@-2 {{expression of type 'SomeValue' is unused}} +} + +func checkBorrow() { + let x = SomeValue() + + let _ = _borrow x // expected-error {{cannot find '_borrow' in scope}} + // expected-error@-1 {{consecutive statements on a line must be separated by ';'}} + // expected-warning@-2 {{expression of type 'SomeValue' is unused}} +} + +func checkNoImplicitCopy1(@_noImplicitCopy x: SomeValue) {} +// expected-error@-1 {{Can not use feature when experimental move only is disabled! Pass the frontend flag -enable-experimental-move-only to swift to enable the usage of this language feature}} + +func checkNoImplicitCopy2(_ x: SomeValue) { + @_noImplicitCopy let y = x + // expected-error@-1 {{Can not use feature when experimental move only is disabled! Pass the frontend flag -enable-experimental-move-only to swift to enable the usage of this language feature}} + checkNoImplicitCopy2(y) +} + + + + diff --git a/test/Sema/moveonly_illegal_types.swift b/test/Sema/moveonly_illegal_types.swift index 5547dac7137ce..e239b44313967 100644 --- a/test/Sema/moveonly_illegal_types.swift +++ b/test/Sema/moveonly_illegal_types.swift @@ -1,4 +1,4 @@ -// RUN: %target-typecheck-verify-swift -enable-experimental-move-only +// RUN: %target-typecheck-verify-swift // This test focuses on the prevention of users from _writing_ types where // a move-only type is substituted for a generic parameter. @@ -78,4 +78,4 @@ func illegalTypes(_ t: T) { func illegalInExpr() { -} \ No newline at end of file +} diff --git a/test/Sema/moveonly_indirect_enum.swift b/test/Sema/moveonly_indirect_enum.swift index ce372a27d7d4f..1159e47954b4e 100644 --- a/test/Sema/moveonly_indirect_enum.swift +++ b/test/Sema/moveonly_indirect_enum.swift @@ -1,4 +1,4 @@ -// RUN: %target-typecheck-verify-swift -enable-experimental-move-only +// RUN: %target-typecheck-verify-swift // This test validates that move only enums cannot be marked indirect or have // indirect cases. diff --git a/test/Sema/moveonly_lexical_borrow_required.swift b/test/Sema/moveonly_lexical_borrow_required.swift new file mode 100644 index 0000000000000..058fcd8dc63b3 --- /dev/null +++ b/test/Sema/moveonly_lexical_borrow_required.swift @@ -0,0 +1,9 @@ +// RUN: %target-swift-frontend -typecheck %s +// RUN: %target-typecheck-verify-swift -enable-lexical-borrow-scopes=false + +@_moveOnly +public struct MO { // expected-error 2{{noncopyable types require lexical borrow scopes (add -enable-lexical-borrow-scopes=true)}} + let x = 0 +} + +public func whatever(_ mo: borrowing MO) {} diff --git a/test/Sema/moveonly_objc_enum.swift b/test/Sema/moveonly_objc_enum.swift index d376ba5362c2d..ffc1e443c9aa2 100644 --- a/test/Sema/moveonly_objc_enum.swift +++ b/test/Sema/moveonly_objc_enum.swift @@ -1,4 +1,4 @@ -// RUN: %target-typecheck-verify-swift -enable-experimental-move-only +// RUN: %target-typecheck-verify-swift // REQUIRES: objc_interop diff --git a/test/Sema/moveonly_require_ownership_specifier.swift b/test/Sema/moveonly_require_ownership_specifier.swift index a9765ced0f3ba..96ecfab3b5261 100644 --- a/test/Sema/moveonly_require_ownership_specifier.swift +++ b/test/Sema/moveonly_require_ownership_specifier.swift @@ -1,4 +1,4 @@ -// RUN: %target-typecheck-verify-swift -enable-experimental-move-only +// RUN: %target-typecheck-verify-swift // Coverage for check that requires some ownership specifier to be written // when a move-only / noncopyable type appears as a parameter of a function. diff --git a/test/Sema/moveonly_restrictions.swift b/test/Sema/moveonly_restrictions.swift index 49b438ff2e911..a4002e23d1aa5 100644 --- a/test/Sema/moveonly_restrictions.swift +++ b/test/Sema/moveonly_restrictions.swift @@ -1,4 +1,4 @@ -// RUN: %target-typecheck-verify-swift -disable-availability-checking -enable-experimental-move-only -enable-experimental-feature MoveOnlyClasses +// RUN: %target-typecheck-verify-swift -disable-availability-checking -enable-experimental-feature MoveOnlyClasses // REQUIRES: concurrency diff --git a/test/Sema/moveonly_sendable.swift b/test/Sema/moveonly_sendable.swift index cd1b24280e872..87ff12a21cc9a 100644 --- a/test/Sema/moveonly_sendable.swift +++ b/test/Sema/moveonly_sendable.swift @@ -1,4 +1,4 @@ -// RUN: %target-typecheck-verify-swift -enable-experimental-move-only -strict-concurrency=complete -disable-availability-checking +// RUN: %target-typecheck-verify-swift -strict-concurrency=complete -disable-availability-checking // REQUIRES: concurrency diff --git a/test/Sema/noimplicitcopy_attr_check_behind_flag.swift b/test/Sema/noimplicitcopy_attr_check_behind_flag.swift deleted file mode 100644 index 77fddcab053bb..0000000000000 --- a/test/Sema/noimplicitcopy_attr_check_behind_flag.swift +++ /dev/null @@ -1,12 +0,0 @@ -// RUN: %target-typecheck-verify-swift -parse-stdlib -disable-availability-checking - -class Klass {} - -func useKlass(_ k: Klass) {} - -// Make sure that we properly error when someone uses no implicit copy without -// setting -enable-experimental-move-only. -func letDecls(_ x: Klass) -> () { - @_noImplicitCopy let y: Klass = x // expected-error {{Can not use feature when experimental move only is disabled! Pass the frontend flag -enable-experimental-move-only to swift to enable the usage of this language feature}} - useKlass(y) -} diff --git a/test/Serialization/moveonly_deinit.swift b/test/Serialization/moveonly_deinit.swift index 9081c98449f04..83e280d6232c7 100644 --- a/test/Serialization/moveonly_deinit.swift +++ b/test/Serialization/moveonly_deinit.swift @@ -1,7 +1,7 @@ // RUN: %empty-directory(%t) // TODO: re-enable the simplification passes once rdar://104875010 is fixed -// RUN: %target-swift-frontend -enable-experimental-move-only -Xllvm -sil-disable-pass=simplification -g -emit-module -module-name OtherModule %S/Inputs/moveonly_deinit.swift -emit-module-path %t/OtherModule.swiftmodule -// RUN: %target-swift-frontend -enable-experimental-move-only -Xllvm -sil-disable-pass=simplification -g -I %t %s -emit-silgen +// RUN: %target-swift-frontend -Xllvm -sil-disable-pass=simplification -g -emit-module -module-name OtherModule %S/Inputs/moveonly_deinit.swift -emit-module-path %t/OtherModule.swiftmodule +// RUN: %target-swift-frontend -Xllvm -sil-disable-pass=simplification -g -I %t %s -emit-silgen // Make sure we can deserialize deinits of both enums and structs. diff --git a/test/Serialization/moveonly_error_on_import_into_module_without_flag.swift b/test/Serialization/moveonly_error_on_import_into_module_without_flag.swift index 2907d97266ad2..dee2cdfb2f849 100644 --- a/test/Serialization/moveonly_error_on_import_into_module_without_flag.swift +++ b/test/Serialization/moveonly_error_on_import_into_module_without_flag.swift @@ -1,18 +1,26 @@ // RUN: %empty-directory(%t) // TODO: re-enable the simplification passes once rdar://104875010 is fixed -// RUN: %target-swift-frontend -Xllvm -sil-disable-pass=simplification -emit-module -o %t/Library.swiftmodule -module-name Library %S/Inputs/moveonly_deinit.swift -enable-experimental-move-only -// RUN: not %target-swift-frontend -DUSE_MOVEONLY_TYPE -I %t %s -emit-sil -o /dev/null 2>&1 | %FileCheck %s -// RUN: %target-swift-frontend -I %t %s -emit-sil -verify -o /dev/null +// RUN: %target-swift-frontend -Xllvm -sil-disable-pass=simplification -emit-module -o %t/Library.swiftmodule -module-name Library %S/Inputs/moveonly_deinit.swift -// This test makes sure that if we import a move only type and do not set the -// experimental move only flag, we get a nice error. +// >>> make sure borrow scopes are required when using a move-only type from another module +// RUN: not %target-swift-frontend -DUSE_MOVEONLY_TYPE -typecheck -enable-lexical-borrow-scopes=false -I %t %s 2>&1 | %FileCheck %s --check-prefix CHECK-ERROR +// RUN: %target-swift-frontend -DUSE_MOVEONLY_TYPE -typecheck -I %t %s 2>&1 | %FileCheck %s --allow-empty + +// >>> try turning off lexical borrow scopes with no move-only types; shouldn't be an error. +// we have to pipe into FileCheck because -verify ignores errors from other files. +// RUN: %target-swift-frontend -enable-lexical-borrow-scopes=false -typecheck -I %t %s 2>&1 | %FileCheck %s --allow-empty + +// This test makes sure that if we import a move only type +// and do not have lexical borrow scopes enabled, we emit an error. import Library -// CHECK: error: Can not import module 'Library' that uses move only features when experimental move only is disabled! Pass the frontend flag -enable-experimental-move-only to swift to enable the usage of this language feature +// CHECK-ERROR: Library.MoveOnlyStruct{{.*}} error: noncopyable types require lexical borrow scopes (add -enable-lexical-borrow-scopes=true) + +// CHECK-NOT: error #if USE_MOVEONLY_TYPE -func f(_ k: MoveOnlyStruct) {} +func f(_ k: borrowing MoveOnlyStruct) {} #endif func g(_ k: NormalStruct) {} diff --git a/test/expr/print/forget.swift b/test/expr/print/forget.swift index 9a6daa90f1979..437342c7f1ebb 100644 --- a/test/expr/print/forget.swift +++ b/test/expr/print/forget.swift @@ -1,4 +1,4 @@ -// RUN: %target-swift-frontend -enable-experimental-move-only -print-ast %s 2>&1 | %FileCheck %s +// RUN: %target-swift-frontend -print-ast %s 2>&1 | %FileCheck %s @_moveOnly struct S { diff --git a/test/stdlib/move_function.swift b/test/stdlib/move_function.swift index 7382819df9b31..a8646e294d8b9 100644 --- a/test/stdlib/move_function.swift +++ b/test/stdlib/move_function.swift @@ -1,8 +1,4 @@ -// RUN: %target-run-stdlib-swift(-Xllvm -sil-disable-pass=DestroyHoisting -Xfrontend -enable-experimental-move-only) -// -// NOTE ON ABOVE: I am disabling destroy hoisting on this test since we are -// going to move it out of the mandatory pipeline eventually and it causes the -// test to fail only when optimizations are enabled. +// RUN: %target-run-stdlib-swift(-O) // REQUIRES: executable_test