AST: Promote AsyncSequenceFailure feature to the baseline.

This commit is contained in:
Allan Shortlidge
2024-07-08 21:35:36 -07:00
parent 6f972fc275
commit b5acc6b07d
5 changed files with 3 additions and 42 deletions

View File

@@ -372,10 +372,6 @@ struct PrintOptions {
/// Whether to suppress printing of custom attributes that are expanded macros.
bool SuppressExpandedMacros = true;
/// Whether we're supposed to slap a @rethrows on `AsyncSequence` /
/// `AsyncIteratorProtocol` for backward-compatibility reasons.
bool AsyncSequenceRethrows = false;
/// Suppress the @isolated(any) attribute.
bool SuppressIsolatedAny = false;

View File

@@ -170,7 +170,7 @@ SUPPRESSIBLE_LANGUAGE_FEATURE(PrimaryAssociatedTypes2, 346, "Primary associated
BASELINE_LANGUAGE_FEATURE(UnavailableFromAsync, 0, "@_unavailableFromAsync")
BASELINE_LANGUAGE_FEATURE(NoAsyncAvailability, 340, "@available(*, noasync)")
BASELINE_LANGUAGE_FEATURE(AssociatedTypeAvailability, 0, "Availability on associated types")
SUPPRESSIBLE_LANGUAGE_FEATURE(AsyncSequenceFailure, 0, "Failure associated type on AsyncSequence and AsyncIteratorProtocol")
BASELINE_LANGUAGE_FEATURE(AsyncSequenceFailure, 0, "Failure associated type on AsyncSequence and AsyncIteratorProtocol")
BASELINE_LANGUAGE_FEATURE(BuiltinIntLiteralAccessors, 368, "Builtin.IntLiteral accessors")
LANGUAGE_FEATURE(Macros, 0, "Macros")
LANGUAGE_FEATURE(FreestandingExpressionMacros, 382, "Expression macros")

View File

@@ -1208,11 +1208,6 @@ static bool hasLessAccessibleSetter(const AbstractStorageDecl *ASD) {
return ASD->getSetterFormalAccess() < ASD->getFormalAccess();
}
static bool isImplicitRethrowsProtocol(const ProtocolDecl *proto) {
return proto->isSpecificProtocol(KnownProtocolKind::AsyncSequence) ||
proto->isSpecificProtocol(KnownProtocolKind::AsyncIteratorProtocol);
}
void PrintAST::printAttributes(const Decl *D) {
if (Options.SkipAttributes)
return;
@@ -1223,17 +1218,6 @@ void PrintAST::printAttributes(const Decl *D) {
auto attrs = D->getAttrs();
// When printing a Swift interface, make sure that older compilers see
// @rethrows on the AsyncSequence and AsyncIteratorProtocol.
if (Options.AsyncSequenceRethrows && Options.IsForSwiftInterface) {
if (auto proto = dyn_cast<ProtocolDecl>(D)) {
if (isImplicitRethrowsProtocol(proto)) {
Printer << "@rethrows";
Printer.printNewline();
}
}
}
// Save the current number of exclude attrs to restore once we're done.
unsigned originalExcludeAttrCount = Options.ExcludeAttrList.size();
@@ -3067,12 +3051,6 @@ static void suppressingFeaturePrimaryAssociatedTypes2(PrintOptions &options,
options.PrintPrimaryAssociatedTypes = originalPrintPrimaryAssociatedTypes;
}
static void
suppressingFeatureAsyncSequenceFailure(
PrintOptions &options, llvm::function_ref<void()> action) {
llvm::SaveAndRestore<bool> saved(options.AsyncSequenceRethrows, true);
action();
}
static void
suppressingFeatureLexicalLifetimes(PrintOptions &options,
llvm::function_ref<void()> action) {

View File

@@ -150,19 +150,6 @@ static bool usesFeaturePrimaryAssociatedTypes2(Decl *decl) {
return false;
}
static bool isImplicitRethrowsProtocol(const ProtocolDecl *proto) {
return proto->isSpecificProtocol(KnownProtocolKind::AsyncSequence) ||
proto->isSpecificProtocol(KnownProtocolKind::AsyncIteratorProtocol);
}
static bool usesFeatureAsyncSequenceFailure(Decl *decl) {
if (auto proto = dyn_cast<ProtocolDecl>(decl)) {
return isImplicitRethrowsProtocol(proto);
}
return false;
}
static bool usesFeatureMacros(Decl *decl) { return isa<MacroDecl>(decl); }
static bool usesFeatureFreestandingExpressionMacros(Decl *decl) {

View File

@@ -4,7 +4,7 @@
// REQUIRES: concurrency
// CHECK: @rethrows
// CHECK-NEXT: public protocol AsyncIteratorProtocol
// CHECK-NOT: @rethrows
// CHECK: public protocol AsyncIteratorProtocol
public protocol AsyncIteratorProtocol {
}