Skip to content

Commit 112071e

Browse files
committed
[sending] Remove transferring.
Out of an abundance of caution, we: 1. Left in parsing support for transferring but internally made it rely on the internals of sending. 2. Added a warning to tell people that transferring was going to be removed very soon. Now that we have given people some time, remove support for parsing transferring. rdar://130253724
1 parent d07e8ce commit 112071e

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+68
-834
lines changed

include/swift/ABI/MetadataValues.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -1197,7 +1197,7 @@ class TargetExtendedFunctionTypeFlags {
11971197
// Values for the enumerated isolation kinds
11981198
IsolatedAny = 0x00000002U,
11991199

1200-
// Values if we have a transferring result.
1200+
// Values if we have a sending result.
12011201
HasSendingResult = 0x00000010U,
12021202

12031203
/// A InvertibleProtocolSet in the high bits.

include/swift/AST/ASTBridging.h

-1
Original file line numberDiff line numberDiff line change
@@ -1550,7 +1550,6 @@ enum ENUM_EXTENSIBILITY_ATTR(open) BridgedAttributedTypeSpecifier : size_t {
15501550
BridgedAttributedTypeSpecifierLegacyOwned,
15511551
BridgedAttributedTypeSpecifierConst,
15521552
BridgedAttributedTypeSpecifierIsolated,
1553-
BridgedAttributedTypeSpecifierTransferring,
15541553
BridgedAttributedTypeSpecifierSending,
15551554
};
15561555

include/swift/AST/DiagnosticsParse.def

-9
Original file line numberDiff line numberDiff line change
@@ -2204,19 +2204,10 @@ ERROR(lifetime_dependence_invalid_init_return, PointsToFirstBadToken,
22042204
"specifiers",
22052205
())
22062206

2207-
ERROR(transferring_after_parameter_specifier,none,
2208-
"'transferring' must be placed before specifier '%0'", (StringRef))
2209-
ERROR(transferring_repeated,none,
2210-
"parameter may have at most one 'transferring' specifier", ())
22112207
ERROR(sending_before_parameter_specifier,none,
22122208
"'sending' must be placed after specifier '%0'", (StringRef))
22132209
ERROR(sending_repeated,none,
22142210
"parameter may have at most one 'sending' specifier", ())
2215-
ERROR(sending_and_transferring_used_together,none,
2216-
"'transferring' and 'sending' may not be used together", ())
2217-
WARNING(transferring_is_now_sendable,none,
2218-
"'transferring' has been renamed to 'sending' and the 'transferring' spelling will be removed shortly",
2219-
())
22202211
ERROR(sending_cannot_be_used_with_borrowing,none,
22212212
"'%0' cannot be used together with 'borrowing'", (StringRef))
22222213

include/swift/AST/DiagnosticsSema.def

+1-8
Original file line numberDiff line numberDiff line change
@@ -7979,16 +7979,9 @@ ERROR(lifetime_dependence_immortal_conflict_name, none,
79797979
"conflict between the parameter name and immortal keyword", ())
79807980

79817981
//===----------------------------------------------------------------------===//
7982-
// MARK: Transferring
7982+
// MARK: Sending
79837983
//===----------------------------------------------------------------------===//
79847984

7985-
ERROR(transferring_unsupported_param_specifier, none,
7986-
"'%0' cannot be applied to a 'transferring' parameter", (StringRef))
7987-
7988-
ERROR(transferring_only_on_parameters_and_results, none,
7989-
"'transferring' may only be used on parameters and results", ())
7990-
ERROR(transferring_cannot_be_applied_to_tuple_elt, none,
7991-
"'transferring' cannot be applied to tuple elements", ())
79927985
ERROR(sending_unsupported_param_specifier, none,
79937986
"'%0' cannot be applied to a 'sending' parameter", (StringRef))
79947987
ERROR(sending_only_on_parameters_and_results, none,

include/swift/AST/ExtInfo.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -486,15 +486,15 @@ class ASTExtInfoBuilder {
486486
DifferentiabilityKind::NonDifferentiable, nullptr,
487487
FunctionTypeIsolation::forNonIsolated(),
488488
LifetimeDependenceInfo(),
489-
false /*transferringResult*/) {}
489+
false /*sendingResult*/) {}
490490

491491
// Constructor for polymorphic type.
492492
ASTExtInfoBuilder(Representation rep, bool throws, Type thrownError)
493493
: ASTExtInfoBuilder(rep, false, throws, thrownError,
494494
DifferentiabilityKind::NonDifferentiable, nullptr,
495495
FunctionTypeIsolation::forNonIsolated(),
496496
LifetimeDependenceInfo(),
497-
false /*transferringResult*/) {}
497+
false /*sendingResult*/) {}
498498

499499
// Constructor with no defaults.
500500
ASTExtInfoBuilder(Representation rep, bool isNoEscape, bool throws,

include/swift/AST/TypeRepr.h

-17
Original file line numberDiff line numberDiff line change
@@ -1119,7 +1119,6 @@ class SpecifierTypeRepr : public TypeRepr {
11191119
T->getKind() == TypeReprKind::Isolated ||
11201120
T->getKind() == TypeReprKind::CompileTimeConst ||
11211121
T->getKind() == TypeReprKind::LifetimeDependentReturn ||
1122-
T->getKind() == TypeReprKind::Transferring ||
11231122
T->getKind() == TypeReprKind::Sending;
11241123
}
11251124
static bool classof(const SpecifierTypeRepr *T) { return true; }
@@ -1191,21 +1190,6 @@ class CompileTimeConstTypeRepr : public SpecifierTypeRepr {
11911190
static bool classof(const CompileTimeConstTypeRepr *T) { return true; }
11921191
};
11931192

1194-
/// A transferring type.
1195-
/// \code
1196-
/// x : transferring Int
1197-
/// \endcode
1198-
class TransferringTypeRepr : public SpecifierTypeRepr {
1199-
public:
1200-
TransferringTypeRepr(TypeRepr *Base, SourceLoc InOutLoc)
1201-
: SpecifierTypeRepr(TypeReprKind::Transferring, Base, InOutLoc) {}
1202-
1203-
static bool classof(const TypeRepr *T) {
1204-
return T->getKind() == TypeReprKind::Transferring;
1205-
}
1206-
static bool classof(const TransferringTypeRepr *T) { return true; }
1207-
};
1208-
12091193
/// A sending type.
12101194
/// \code
12111195
/// x : sending Int
@@ -1621,7 +1605,6 @@ inline bool TypeRepr::isSimple() const {
16211605
case TypeReprKind::Array:
16221606
case TypeReprKind::SILBox:
16231607
case TypeReprKind::Isolated:
1624-
case TypeReprKind::Transferring:
16251608
case TypeReprKind::Sending:
16261609
case TypeReprKind::Placeholder:
16271610
case TypeReprKind::CompileTimeConst:

include/swift/AST/TypeReprNodes.def

-1
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,6 @@ ABSTRACT_TYPEREPR(Specifier, TypeRepr)
7070
SPECIFIER_TYPEREPR(Ownership, SpecifierTypeRepr)
7171
SPECIFIER_TYPEREPR(Isolated, SpecifierTypeRepr)
7272
SPECIFIER_TYPEREPR(CompileTimeConst, SpecifierTypeRepr)
73-
SPECIFIER_TYPEREPR(Transferring, SpecifierTypeRepr)
7473
SPECIFIER_TYPEREPR(Sending, SpecifierTypeRepr)
7574
TYPEREPR(Fixed, TypeRepr)
7675
TYPEREPR(SILBox, TypeRepr)

include/swift/AST/Types.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -2429,7 +2429,7 @@ class YieldTypeFlags {
24292429
/*nonEphemeral*/ false, getOwnershipSpecifier(),
24302430
/*isolated*/ false, /*noDerivative*/ false,
24312431
/*compileTimeConst*/ false,
2432-
/*is transferring*/ false);
2432+
/*is sending*/ false);
24332433
}
24342434

24352435
bool operator ==(const YieldTypeFlags &other) const {

include/swift/Basic/Features.def

-1
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,6 @@ SUPPRESSIBLE_LANGUAGE_FEATURE(NoncopyableGenerics, 427, "Noncopyable generics")
196196
SUPPRESSIBLE_LANGUAGE_FEATURE(ConformanceSuppression, 426, "Suppressible inferred conformances")
197197
SUPPRESSIBLE_LANGUAGE_FEATURE(BitwiseCopyable2, 426, "BitwiseCopyable feature")
198198
LANGUAGE_FEATURE(BodyMacros, 415, "Function body macros")
199-
LANGUAGE_FEATURE(TransferringArgsAndResults, 430, "Transferring args and results")
200199
SUPPRESSIBLE_LANGUAGE_FEATURE(SendingArgsAndResults, 430, "Sending arg and results")
201200
LANGUAGE_FEATURE(BorrowingSwitch, 432, "Noncopyable type pattern matching")
202201
CONDITIONALLY_SUPPRESSIBLE_LANGUAGE_FEATURE(IsolatedAny, 431, "@isolated(any) function types")

include/swift/Option/FrontendOptions.td

-5
Original file line numberDiff line numberDiff line change
@@ -1371,11 +1371,6 @@ def disable_experimental_parser_round_trip : Flag<["-"],
13711371
"disable-experimental-parser-round-trip">,
13721372
HelpText<"Disable round trip through the new swift parser">;
13731373

1374-
def disable_transferring_args_and_results_with_region_isolation : Flag<["-"],
1375-
"disable-transferring-args-and-results-with-region-based-isolation">,
1376-
HelpText<"Disable transferring args and results when region based isolation is enabled. Only enabled with asserts">,
1377-
Flags<[HelpHidden]>;
1378-
13791374
def disable_sending_args_and_results_with_region_isolation : Flag<["-"],
13801375
"disable-sending-args-and-results-with-region-based-isolation">,
13811376
HelpText<"Disable sending args and results when region based isolation is enabled. Only enabled with asserts">,

include/swift/Parse/Parser.h

-7
Original file line numberDiff line numberDiff line change
@@ -1211,9 +1211,6 @@ class Parser {
12111211
Tok.isContextualKeyword("isolated") ||
12121212
Tok.isContextualKeyword("_const"))
12131213
return true;
1214-
if (Context.LangOpts.hasFeature(Feature::TransferringArgsAndResults) &&
1215-
Tok.isContextualKeyword("transferring"))
1216-
return true;
12171214
if (Context.LangOpts.hasFeature(Feature::SendingArgsAndResults) &&
12181215
Tok.isContextualKeyword("sending"))
12191216
return true;
@@ -1264,7 +1261,6 @@ class Parser {
12641261
SourceLoc SpecifierLoc;
12651262
SourceLoc IsolatedLoc;
12661263
SourceLoc ConstLoc;
1267-
SourceLoc TransferringLoc;
12681264
SourceLoc SendingLoc;
12691265
SmallVector<TypeOrCustomAttr> Attributes;
12701266
SmallVector<LifetimeDependenceSpecifier> lifetimeDependenceSpecifiers;
@@ -1577,9 +1573,6 @@ class Parser {
15771573
/// The location of the '_const' keyword, if present.
15781574
SourceLoc CompileConstLoc;
15791575

1580-
/// The location of the 'transferring' keyword if present.
1581-
SourceLoc TransferringLoc;
1582-
15831576
/// The location of the 'sending' keyword if present.
15841577
SourceLoc SendingLoc;
15851578

lib/AST/ASTBridging.cpp

-5
Original file line numberDiff line numberDiff line change
@@ -877,8 +877,6 @@ BridgedParamDecl BridgedParamDecl_createParsed(
877877
paramDecl->setIsolated(true);
878878
else if (isa<CompileTimeConstTypeRepr>(STR))
879879
paramDecl->setCompileTimeConst(true);
880-
else if (isa<TransferringTypeRepr>(STR))
881-
paramDecl->setSending(true);
882880
else if (isa<SendingTypeRepr>(STR))
883881
paramDecl->setSending(true);
884882

@@ -2225,9 +2223,6 @@ BridgedSpecifierTypeRepr BridgedSpecifierTypeRepr_createParsed(
22252223
return new (context)
22262224
OwnershipTypeRepr(baseType, ParamSpecifier::LegacyOwned, loc);
22272225
}
2228-
case BridgedAttributedTypeSpecifierTransferring: {
2229-
return new (context) TransferringTypeRepr(baseType, loc);
2230-
}
22312226
case BridgedAttributedTypeSpecifierSending: {
22322227
return new (context) SendingTypeRepr(baseType, loc);
22332228
}

lib/AST/ASTDumper.cpp

-6
Original file line numberDiff line numberDiff line change
@@ -3448,12 +3448,6 @@ class PrintTypeRepr : public TypeReprVisitor<PrintTypeRepr, void, StringRef>,
34483448
printFoot();
34493449
}
34503450

3451-
void visitTransferringTypeRepr(TransferringTypeRepr *T, StringRef label) {
3452-
printCommon("transferring", label);
3453-
printRec(T->getBase());
3454-
printFoot();
3455-
}
3456-
34573451
void visitSendingTypeRepr(SendingTypeRepr *T, StringRef label) {
34583452
printCommon("sending", label);
34593453
printRec(T->getBase());

lib/AST/ASTMangler.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -2165,7 +2165,7 @@ void ASTMangler::appendImplFunctionType(SILFunctionType *fn,
21652165
appendType(param.getInterfaceType(), sig, forDecl);
21662166
}
21672167

2168-
// Mangle if we have a transferring result.
2168+
// Mangle if we have a sending result.
21692169
if (isInRecursion && fn->hasSendingResult())
21702170
OpArgs.push_back('T');
21712171

lib/AST/ASTWalker.cpp

-4
Original file line numberDiff line numberDiff line change
@@ -2337,10 +2337,6 @@ bool Traversal::visitIsolatedTypeRepr(IsolatedTypeRepr *T) {
23372337
return doIt(T->getBase());
23382338
}
23392339

2340-
bool Traversal::visitTransferringTypeRepr(TransferringTypeRepr *T) {
2341-
return doIt(T->getBase());
2342-
}
2343-
23442340
bool Traversal::visitSendingTypeRepr(SendingTypeRepr *T) {
23452341
return doIt(T->getBase());
23462342
}

lib/AST/Builtins.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -1686,7 +1686,7 @@ static ValueDecl *getStartAsyncLet(ASTContext &ctx, Identifier id) {
16861686
bool hasSendingResult =
16871687
ctx.LangOpts.hasFeature(Feature::RegionBasedIsolation);
16881688

1689-
// operation async function pointer: () async throws -> transferring T
1689+
// operation async function pointer: () async throws -> sending T
16901690
auto extInfo = ASTExtInfoBuilder()
16911691
.withAsync()
16921692
.withThrows()

lib/AST/Decl.cpp

+1-2
Original file line numberDiff line numberDiff line change
@@ -10341,8 +10341,7 @@ FuncDecl *FuncDecl::create(ASTContext &Context, SourceLoc StaticLoc,
1034110341
ClangNode());
1034210342
FD->setParameters(BodyParams);
1034310343
FD->FnRetType = TypeLoc(ResultTyR);
10344-
if (llvm::isa_and_nonnull<TransferringTypeRepr>(ResultTyR) ||
10345-
llvm::isa_and_nonnull<SendingTypeRepr>(ResultTyR))
10344+
if (llvm::isa_and_nonnull<SendingTypeRepr>(ResultTyR))
1034610345
FD->setSendingResult();
1034710346
return FD;
1034810347
}

lib/AST/FeatureSet.cpp

-1
Original file line numberDiff line numberDiff line change
@@ -638,7 +638,6 @@ UNINTERESTING_FEATURE(BitwiseCopyable)
638638
UNINTERESTING_FEATURE(FixedArrays)
639639
UNINTERESTING_FEATURE(GroupActorErrors)
640640

641-
UNINTERESTING_FEATURE(TransferringArgsAndResults)
642641
static bool usesFeatureSendingArgsAndResults(Decl *decl) {
643642
auto isFunctionTypeWithSending = [](Type type) {
644643
auto fnType = type->getAs<AnyFunctionType>();

lib/AST/NameLookup.cpp

-1
Original file line numberDiff line numberDiff line change
@@ -3180,7 +3180,6 @@ directReferencesForTypeRepr(Evaluator &evaluator,
31803180
case TypeReprKind::NamedOpaqueReturn:
31813181
case TypeReprKind::Existential:
31823182
case TypeReprKind::LifetimeDependentReturn:
3183-
case TypeReprKind::Transferring:
31843183
case TypeReprKind::Sending:
31853184
return result;
31863185

lib/AST/TypeRepr.cpp

-3
Original file line numberDiff line numberDiff line change
@@ -852,9 +852,6 @@ void SpecifierTypeRepr::printImpl(ASTPrinter &Printer,
852852
case TypeReprKind::Isolated:
853853
Printer.printKeyword("isolated", Opts, " ");
854854
break;
855-
case TypeReprKind::Transferring:
856-
Printer.printKeyword("transferring", Opts, " ");
857-
break;
858855
case TypeReprKind::Sending:
859856
Printer.printKeyword("sending", Opts, " ");
860857
break;

lib/ASTGen/Sources/ASTGen/SourceFile.swift

-1
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,6 @@ extension Parser.ExperimentalFeatures {
6060
mapFeature(.ThenStatements, to: .thenStatements)
6161
mapFeature(.DoExpressions, to: .doExpressions)
6262
mapFeature(.NonescapableTypes, to: .nonescapableTypes)
63-
mapFeature(.TransferringArgsAndResults, to: .transferringArgsAndResults)
6463
mapFeature(.SendingArgsAndResults, to: .sendingArgsAndResults)
6564
}
6665
}

lib/ClangImporter/ClangImporter.cpp

+1-3
Original file line numberDiff line numberDiff line change
@@ -676,10 +676,8 @@ void importer::getNormalInvocationArguments(
676676
}
677677
}
678678

679-
// If we support TransferringArgsAndResults, set the -D flag to signal that it
679+
// If we support SendingArgsAndResults, set the -D flag to signal that it
680680
// is supported.
681-
if (LangOpts.hasFeature(Feature::TransferringArgsAndResults))
682-
invocationArgStrs.push_back("-D__SWIFT_ATTR_SUPPORTS_TRANSFERRING=1");
683681
if (LangOpts.hasFeature(Feature::SendingArgsAndResults))
684682
invocationArgStrs.push_back("-D__SWIFT_ATTR_SUPPORTS_SENDING=1");
685683

lib/ClangImporter/ImportDecl.cpp

-12
Original file line numberDiff line numberDiff line change
@@ -8071,18 +8071,6 @@ ClangImporter::Implementation::importSwiftAttrAttributes(Decl *MappedDecl) {
80718071
nominal->registerProtocolConformance(conformance, /*synthesized=*/true);
80728072
}
80738073

8074-
if (swiftAttr->getAttribute() == "transferring") {
8075-
// Swallow this if the feature is not enabled.
8076-
if (!SwiftContext.LangOpts.hasFeature(
8077-
Feature::TransferringArgsAndResults))
8078-
continue;
8079-
auto *funcDecl = dyn_cast<FuncDecl>(MappedDecl);
8080-
if (!funcDecl)
8081-
continue;
8082-
funcDecl->setSendingResult();
8083-
continue;
8084-
}
8085-
80868074
if (swiftAttr->getAttribute() == "sending") {
80878075
// Swallow this if the feature is not enabled.
80888076
if (!SwiftContext.LangOpts.hasFeature(Feature::SendingArgsAndResults))

lib/ClangImporter/ImportType.cpp

+2-13
Original file line numberDiff line numberDiff line change
@@ -2608,19 +2608,8 @@ static ParamDecl *getParameterInfo(ClangImporter::Implementation *impl,
26082608
impl->importSourceLoc(param->getLocation()), bodyName,
26092609
impl->ImportedHeaderUnit);
26102610

2611-
// If TransferringArgsAndResults are enabled and we have a transferring
2612-
// argument, set that the param was transferring.
2613-
if (paramInfo->getASTContext().LangOpts.hasFeature(
2614-
Feature::TransferringArgsAndResults)) {
2615-
if (auto *attr = param->getAttr<clang::SwiftAttrAttr>()) {
2616-
if (attr->getAttribute() == "transferring") {
2617-
paramInfo->setSending();
2618-
}
2619-
}
2620-
}
2621-
2622-
// If TransferringArgsAndResults are enabled and we have a transferring
2623-
// argument, set that the param was transferring.
2611+
// If SendingArgsAndResults are enabled and we have a sending argument,
2612+
// set that the param was sending.
26242613
if (paramInfo->getASTContext().LangOpts.hasFeature(
26252614
Feature::SendingArgsAndResults)) {
26262615
if (auto *attr = param->getAttr<clang::SwiftAttrAttr>()) {

lib/Migrator/APIDiffMigratorPass.cpp

-4
Original file line numberDiff line numberDiff line change
@@ -157,10 +157,6 @@ class ChildIndexFinder : public TypeReprVisitor<ChildIndexFinder, FoundResult> {
157157
return visit(T->getBase());
158158
}
159159

160-
FoundResult visitTransferringTypeRepr(TransferringTypeRepr *T) {
161-
return visit(T->getBase());
162-
}
163-
164160
FoundResult visitSendingTypeRepr(SendingTypeRepr *T) {
165161
return visit(T->getBase());
166162
}

0 commit comments

Comments
 (0)