Skip to content

Commit d9746f2

Browse files
committed
[Parse] Drop Swift3 support for misc diagnostics
Several diagnostics were warnings in Swift3, but errors in Swift4+ Related: #10908
1 parent 622a140 commit d9746f2

File tree

4 files changed

+11
-52
lines changed

4 files changed

+11
-52
lines changed

include/swift/AST/DiagnosticsParse.def

Lines changed: 1 addition & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -339,9 +339,6 @@ ERROR(static_func_decl_global_scope,none,
339339
(StaticSpellingKind))
340340
ERROR(func_decl_expected_arrow,none,
341341
"expected '->' after function parameter tuple", ())
342-
WARNING(swift3_operator_static_in_protocol,none,
343-
"operator '%0' declared in protocol must be 'static'",
344-
(StringRef))
345342
ERROR(operator_static_in_protocol,none,
346343
"operator '%0' declared in protocol must be 'static'",
347344
(StringRef))
@@ -434,13 +431,8 @@ ERROR(expected_operator_name_after_operator,PointsToFirstBadToken,
434431
ERROR(identifier_when_expecting_operator,PointsToFirstBadToken,
435432
"%0 is considered to be an identifier, not an operator", (Identifier))
436433

437-
WARNING(swift3_deprecated_operator_body,PointsToFirstBadToken,
438-
"operator should no longer be declared with body", ())
439434
ERROR(deprecated_operator_body,PointsToFirstBadToken,
440435
"operator should no longer be declared with body", ())
441-
WARNING(swift3_deprecated_operator_body_use_group,PointsToFirstBadToken,
442-
"operator should no longer be declared with body; "
443-
"use a precedence group instead", ())
444436
ERROR(deprecated_operator_body_use_group,PointsToFirstBadToken,
445437
"operator should no longer be declared with body; "
446438
"use a precedence group instead", ())
@@ -775,16 +767,10 @@ ERROR(tuple_type_multiple_labels,none,
775767
ERROR(expected_rangle_protocol,PointsToFirstBadToken,
776768
"expected '>' to complete protocol-constrained type", ())
777769

778-
WARNING(swift3_deprecated_protocol_composition,none,
779-
"'protocol<...>' composition syntax is deprecated; join the protocols using '&'", ())
780770
ERROR(deprecated_protocol_composition,none,
781771
"'protocol<...>' composition syntax has been removed; join the protocols using '&'", ())
782-
WARNING(swift3_deprecated_protocol_composition_single,none,
783-
"'protocol<...>' composition syntax is deprecated and not needed here", ())
784772
ERROR(deprecated_protocol_composition_single,none,
785-
"'protocol<...>' composition syntax has been removed and is not needed here", ())
786-
WARNING(swift3_deprecated_any_composition,none,
787-
"'protocol<>' syntax is deprecated; use 'Any' instead", ())
773+
"'protocol<...>' composition syntax has been removed and is not needed here", ())
788774
ERROR(deprecated_any_composition,none,
789775
"'protocol<>' syntax has been removed; use 'Any' instead", ())
790776

@@ -891,8 +877,6 @@ ERROR(parameter_curry_syntax_removed,none,
891877
ERROR(initializer_as_typed_pattern,none,
892878
"unexpected initializer in pattern; did you mean to use '='?", ())
893879

894-
WARNING(swift3_unlabeled_parameter_following_variadic_parameter,none,
895-
"a parameter following a variadic parameter requires a label", ())
896880
ERROR(unlabeled_parameter_following_variadic_parameter,none,
897881
"a parameter following a variadic parameter requires a label", ())
898882

@@ -1348,15 +1332,9 @@ ERROR(attr_noescape_conflicts_escaping_autoclosure,none,
13481332
ERROR(attr_noescape_implied_by_autoclosure,none,
13491333
"@noescape is implied by @autoclosure and should not be "
13501334
"redundantly specified", ())
1351-
WARNING(swift3_attr_autoclosure_escaping_deprecated,none,
1352-
"@autoclosure(escaping) is deprecated; use @autoclosure @escaping instead",
1353-
())
13541335
ERROR(attr_autoclosure_escaping_deprecated,none,
13551336
"@autoclosure(escaping) has been removed; use @autoclosure @escaping instead",
13561337
())
1357-
WARNING(swift3_attr_noescape_deprecated,none,
1358-
"@noescape is the default and is deprecated",
1359-
())
13601338
ERROR(attr_noescape_deprecated,none,
13611339
"@noescape is the default and has been removed",
13621340
())

lib/Parse/ParseDecl.cpp

Lines changed: 5 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1823,9 +1823,7 @@ bool Parser::parseTypeAttribute(TypeAttributes &Attributes, bool justChecking) {
18231823
if (Attributes.has(TAK_noescape)) {
18241824
diagnose(Loc, diag::attr_noescape_conflicts_escaping_autoclosure);
18251825
} else {
1826-
diagnose(Loc, Context.isSwiftVersion3()
1827-
? diag::swift3_attr_autoclosure_escaping_deprecated
1828-
: diag::attr_autoclosure_escaping_deprecated)
1826+
diagnose(Loc, diag::attr_autoclosure_escaping_deprecated)
18291827
.fixItReplace(autoclosureEscapingParenRange, " @escaping ");
18301828
}
18311829
Attributes.setAttr(TAK_escaping, Loc);
@@ -1850,9 +1848,7 @@ bool Parser::parseTypeAttribute(TypeAttributes &Attributes, bool justChecking) {
18501848
// In SIL, the polarity of @escaping is reversed.
18511849
// @escaping is the default and @noescape is explicit.
18521850
if (!isInSILMode()) {
1853-
diagnose(Loc, Context.isSwiftVersion3()
1854-
? diag::swift3_attr_noescape_deprecated
1855-
: diag::attr_noescape_deprecated)
1851+
diagnose(Loc, diag::attr_noescape_deprecated)
18561852
.fixItRemove({Attributes.AtLoc, Loc});
18571853
}
18581854
break;
@@ -5192,10 +5188,7 @@ Parser::parseDeclFunc(SourceLoc StaticLoc, StaticSpellingKind StaticSpelling,
51925188
if (Flags & PD_InProtocol) {
51935189
switch (StaticSpelling) {
51945190
case StaticSpellingKind::None: {
5195-
auto Message = Context.isSwiftVersion3()
5196-
? diag::swift3_operator_static_in_protocol
5197-
: diag::operator_static_in_protocol;
5198-
diagnose(NameLoc, Message, SimpleName.str())
5191+
diagnose(NameLoc, diag::operator_static_in_protocol, SimpleName.str())
51995192
.fixItInsert(FuncLoc, "static ");
52005193
StaticSpelling = StaticSpellingKind::KeywordStatic;
52015194
break;
@@ -6428,15 +6421,9 @@ Parser::parseDeclOperatorImpl(SourceLoc OperatorLoc, Identifier Name,
64286421
SourceLoc lBraceLoc;
64296422
if (consumeIf(tok::l_brace, lBraceLoc)) {
64306423
if (isInfix && !Tok.is(tok::r_brace)) {
6431-
auto message = Context.isSwiftVersion3()
6432-
? diag::swift3_deprecated_operator_body_use_group
6433-
: diag::deprecated_operator_body_use_group;
6434-
diagnose(lBraceLoc, message);
6424+
diagnose(lBraceLoc, diag::deprecated_operator_body_use_group);
64356425
} else {
6436-
auto message = Context.isSwiftVersion3()
6437-
? diag::swift3_deprecated_operator_body
6438-
: diag::deprecated_operator_body;
6439-
auto Diag = diagnose(lBraceLoc, message);
6426+
auto Diag = diagnose(lBraceLoc, diag::deprecated_operator_body);
64406427
if (Tok.is(tok::r_brace)) {
64416428
SourceLoc lastGoodLoc = precedenceGroupNameLoc;
64426429
if (lastGoodLoc.isInvalid())

lib/Parse/ParsePattern.cpp

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -547,11 +547,8 @@ mapParsedParameters(Parser &parser,
547547
// Warn when an unlabeled parameter follows a variadic parameter
548548
if (ellipsisLoc.isValid() && elements.back()->isVariadic() &&
549549
param.FirstName.empty()) {
550-
auto message =
551-
parser.Context.isSwiftVersion3()
552-
? diag::swift3_unlabeled_parameter_following_variadic_parameter
553-
: diag::unlabeled_parameter_following_variadic_parameter;
554-
parser.diagnose(param.FirstNameLoc, message);
550+
parser.diagnose(param.FirstNameLoc,
551+
diag::unlabeled_parameter_following_variadic_parameter);
555552
}
556553

557554
// If this parameter had an ellipsis, check whether it's the last parameter.

lib/Parse/ParseType.cpp

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -828,16 +828,13 @@ ParserResult<TypeRepr> Parser::parseOldStyleProtocolComposition() {
828828
replacement += TrailingContent;
829829
}
830830

831-
auto isThree = Context.isSwiftVersion3();
832-
#define THREEIFY(MESSAGE) (isThree ? diag::swift3_##MESSAGE : diag::MESSAGE)
833831
// Replace 'protocol<T1, T2>' with 'T1 & T2'
834832
diagnose(ProtocolLoc,
835-
IsEmpty ? THREEIFY(deprecated_any_composition) :
836-
Protocols.size() > 1 ? THREEIFY(deprecated_protocol_composition) :
837-
THREEIFY(deprecated_protocol_composition_single))
833+
IsEmpty ? diag::deprecated_any_composition :
834+
Protocols.size() > 1 ? diag::deprecated_protocol_composition :
835+
diag::deprecated_protocol_composition_single)
838836
.highlight(composition->getSourceRange())
839837
.fixItReplace(composition->getSourceRange(), replacement);
840-
#undef THREEIFY
841838
}
842839

843840
return makeParserResult(Status, composition);

0 commit comments

Comments
 (0)