Skip to content

Commit 1b7707d

Browse files
committed
Remove the now-unused @safe(unchecked)
1 parent c043f11 commit 1b7707d

32 files changed

+19
-236
lines changed

include/swift/AST/Attr.h

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -2830,26 +2830,6 @@ class RawLayoutAttr final : public DeclAttribute {
28302830
UNIMPLEMENTED_CLONE(RawLayoutAttr)
28312831
};
28322832

2833-
class SafeAttr final : public DeclAttribute {
2834-
public:
2835-
/// The optional message.
2836-
const StringRef message;
2837-
2838-
SafeAttr(SourceLoc atLoc, SourceRange range, StringRef message,
2839-
bool isImplicit = false)
2840-
: DeclAttribute(DeclAttrKind::Safe, atLoc, range, isImplicit),
2841-
message(message) { }
2842-
2843-
static bool classof(const DeclAttribute *DA) {
2844-
return DA->getKind() == DeclAttrKind::Safe;
2845-
}
2846-
2847-
/// Create a copy of this attribute.
2848-
SafeAttr *clone(ASTContext &ctx) const {
2849-
return new (ctx) SafeAttr(AtLoc, Range, message, isImplicit());
2850-
}
2851-
};
2852-
28532833
class LifetimeAttr final : public DeclAttribute {
28542834
LifetimeEntry *entry;
28552835

include/swift/AST/Decl.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1820,10 +1820,6 @@ struct InheritedEntry : public TypeLoc {
18201820
return getOptions().contains(ProtocolConformanceFlags::Unsafe);
18211821
}
18221822

1823-
bool isSafe() const {
1824-
return getOptions().contains(ProtocolConformanceFlags::Safe);
1825-
}
1826-
18271823
bool isSuppressed() const { return IsSuppressed; }
18281824

18291825
void setOption(ProtocolConformanceFlags flag) {

include/swift/AST/DeclAttr.def

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -531,11 +531,7 @@ SIMPLE_DECL_ATTR(_addressableForDependencies, AddressableForDependencies,
531531
OnNominalType | ABIBreakingToAdd | ABIBreakingToRemove | APIBreakingToAdd | APIBreakingToRemove | UserInaccessible,
532532
163)
533533

534-
DECL_ATTR(safe, Safe,
535-
OnAbstractFunction | OnSubscript | OnVar | OnMacro | OnNominalType |
536-
OnExtension | OnTypeAlias | OnImport | UserInaccessible |
537-
ABIStableToAdd | ABIStableToRemove | APIBreakingToAdd | APIStableToRemove,
538-
164)
534+
// 164 was the never-shipped @safe attribute and can be reused
539535

540536
DECL_ATTR(abi, ABI,
541537
OnAbstractFunction | OnVar /* will eventually add types */ | LongAttribute | ABIStableToAdd | ABIStableToRemove | APIStableToAdd | APIStableToRemove,

include/swift/AST/DiagnosticsParse.def

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2111,9 +2111,6 @@ ERROR(parser_new_parser_errors,none,
21112111
"new Swift parser generated errors for code that C++ parser accepted",
21122112
())
21132113

2114-
ERROR(safe_attr_unchecked,none,
2115-
"'@safe' attribute must be written as '@safe(unchecked)'", ())
2116-
21172114
// MARK: Reference Binding Diagnostics
21182115
ERROR(sil_markuncheckedreferencebinding_requires_attribute,none,
21192116
"mark_unchecked_reference_binding requires an attribute like [inout]", ())

include/swift/AST/DiagnosticsSema.def

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8119,8 +8119,7 @@ GROUPED_WARNING(override_safe_with_unsafe,Unsafe,none,
81198119

81208120
GROUPED_WARNING(preconcurrency_import_unsafe,Unsafe,none,
81218121
"@preconcurrency import is not memory-safe because it can silently "
8122-
"introduce data races; use '@safe(unchecked)' to assert that the "
8123-
"code is memory-safe", ())
8122+
"introduce data races", ())
81248123
GROUPED_WARNING(unsafe_without_unsafe,Unsafe,none,
81258124
"expression uses unsafe constructs but is not marked with 'unsafe'", ())
81268125
WARNING(no_unsafe_in_unsafe,none,

include/swift/AST/NameLookup.h

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -612,21 +612,17 @@ struct InheritedNominalEntry : Located<NominalTypeDecl *> {
612612
/// The location of the "unsafe" attribute if present.
613613
SourceLoc unsafeLoc;
614614

615-
/// The range of the "safe(unchecked)" attribute if present.
616-
SourceRange safeRange;
617-
618615
/// Whether this inherited entry was suppressed via "~".
619616
bool isSuppressed;
620617

621618
InheritedNominalEntry() { }
622619

623620
InheritedNominalEntry(NominalTypeDecl *item, SourceLoc loc,
624621
SourceLoc uncheckedLoc, SourceLoc preconcurrencyLoc,
625-
SourceLoc unsafeLoc, SourceRange safeRange,
626-
bool isSuppressed)
622+
SourceLoc unsafeLoc, bool isSuppressed)
627623
: Located(item, loc), uncheckedLoc(uncheckedLoc),
628624
preconcurrencyLoc(preconcurrencyLoc), unsafeLoc(unsafeLoc),
629-
safeRange(safeRange), isSuppressed(isSuppressed) {}
625+
isSuppressed(isSuppressed) {}
630626
};
631627

632628
/// Retrieve the set of nominal type declarations that are directly

include/swift/AST/ProtocolConformance.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -659,11 +659,6 @@ class NormalProtocolConformance : public RootProtocolConformance,
659659
return getOptions().contains(ProtocolConformanceFlags::Unsafe);
660660
}
661661

662-
/// Whether this is an "safe(unchecked)" conformance.
663-
bool isSafe() const {
664-
return getOptions().contains(ProtocolConformanceFlags::Safe);
665-
}
666-
667662
/// Determine whether we've lazily computed the associated conformance array
668663
/// already.
669664
bool hasComputedAssociatedConformances() const {

include/swift/AST/ProtocolConformanceOptions.h

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,8 @@ enum class ProtocolConformanceFlags {
3131
/// @unsafe conformance
3232
Unsafe = 0x04,
3333

34-
/// @safe(unchecked) conformance
35-
Safe = 0x08,
36-
3734
/// @retroactive conformance
38-
Retroactive = 0x10,
35+
Retroactive = 0x08,
3936

4037
// Note: whenever you add a bit here, update
4138
// NumProtocolConformanceOptions below.
@@ -52,7 +49,7 @@ inline ProtocolConformanceOptions operator|(
5249
}
5350

5451
enum : unsigned {
55-
NumProtocolConformanceOptions = 5
52+
NumProtocolConformanceOptions = 4
5653
};
5754

5855
} // end namespace swift

include/swift/AST/TypeAttr.def

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,6 @@ SIMPLE_TYPE_ATTR(retroactive, Retroactive)
6161
SIMPLE_TYPE_ATTR(unchecked, Unchecked)
6262
SIMPLE_TYPE_ATTR(preconcurrency, Preconcurrency)
6363
SIMPLE_TYPE_ATTR(unsafe, Unsafe)
64-
SIMPLE_TYPE_ATTR(safe, Safe)
6564
SIMPLE_TYPE_ATTR(_local, Local)
6665
SIMPLE_TYPE_ATTR(_noMetadata, NoMetadata)
6766
TYPE_ATTR(_opaqueReturnTypeOf, OpaqueReturnTypeOf)

lib/AST/ASTDumper.cpp

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4144,11 +4144,6 @@ class PrintAttribute : public AttributeVisitor<PrintAttribute, void, StringRef>,
41444144
}
41454145
printFoot();
41464146
}
4147-
void visitSafeAttr(SafeAttr *Attr, StringRef label) {
4148-
printCommon(Attr, "safe_attr", label);
4149-
printFieldQuoted(Attr->message, "message");
4150-
printFoot();
4151-
}
41524147
void visitSILGenNameAttr(SILGenNameAttr *Attr, StringRef label) {
41534148
printCommon(Attr, "silgen_name_attr", label);
41544149
printFlag(Attr->Raw, "raw");

0 commit comments

Comments
 (0)