Skip to content

Commit 7b3916e

Browse files
authored
Merge pull request #67902 from kavon/remove-forget-spelling
remove support for `_forget`, the old spelling of `discard`
2 parents 37477b3 + 4e7e6f4 commit 7b3916e

File tree

7 files changed

+8
-113
lines changed

7 files changed

+8
-113
lines changed

include/swift/AST/DiagnosticsParse.def

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1104,10 +1104,6 @@ ERROR(expected_expr_throw,PointsToFirstBadToken,
11041104
// Discard Statement
11051105
ERROR(expected_expr_discard,PointsToFirstBadToken,
11061106
"expected expression in 'discard' statement", ())
1107-
WARNING(forget_is_deprecated,PointsToFirstBadToken,
1108-
"'_forget' keyword is deprecated and will be removed soon; "
1109-
"use 'discard' instead",
1110-
())
11111107

11121108
// Await/Async
11131109
ERROR(expected_await_not_async,none,

include/swift/AST/TokenKinds.def

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,6 @@ MISC(raw_string_delimiter)
257257
MISC(string_segment)
258258
MISC(string_interpolation_anchor)
259259
MISC(kw_yield)
260-
MISC(kw_forget)
261260
MISC(kw_discard)
262261

263262
// The following tokens are irrelevant for swiftSyntax and thus only declared

include/swift/Parse/Parser.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -613,8 +613,7 @@ class Parser {
613613
/// a nice diagnostic.
614614
bool isContextualDiscardKeyword() {
615615
// must be `discard` ...
616-
if (!(Tok.isContextualKeyword("_forget") // NOTE: support for deprecated _forget
617-
|| Tok.isContextualKeyword("discard")))
616+
if (!Tok.isContextualKeyword("discard"))
618617
return false;
619618

620619
// followed by either an identifier, `self`, or `Self`.

lib/Parse/ParseStmt.cpp

Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,6 @@ bool Parser::isStartOfStmt() {
5555
case tok::kw_case:
5656
case tok::kw_default:
5757
case tok::kw_yield:
58-
case tok::kw_forget: // NOTE: support for deprecated _forget
5958
case tok::kw_discard:
6059
case tok::pound_assert:
6160
case tok::pound_if:
@@ -560,11 +559,7 @@ ParserResult<Stmt> Parser::parseStmt() {
560559
if (isContextualYieldKeyword()) {
561560
Tok.setKind(tok::kw_yield);
562561
} else if (isContextualDiscardKeyword()) {
563-
// NOTE: support for deprecated _forget
564-
if (Tok.isContextualKeyword("_forget"))
565-
Tok.setKind(tok::kw_forget);
566-
else
567-
Tok.setKind(tok::kw_discard);
562+
Tok.setKind(tok::kw_discard);
568563
}
569564

570565
// This needs to handle everything that `Parser::isStartOfStmt()` accepts as
@@ -619,7 +614,6 @@ ParserResult<Stmt> Parser::parseStmt() {
619614
case tok::kw_for:
620615
if (tryLoc.isValid()) diagnose(tryLoc, diag::try_on_stmt, Tok.getText());
621616
return parseStmtForEach(LabelInfo);
622-
case tok::kw_forget: // NOTE: support for deprecated _forget
623617
case tok::kw_discard:
624618
if (LabelInfo) diagnose(LabelInfo.Loc, diag::invalid_label_on_stmt);
625619
if (tryLoc.isValid()) diagnose(tryLoc, diag::try_on_stmt, Tok.getText());
@@ -942,16 +936,7 @@ ParserResult<Stmt> Parser::parseStmtThrow(SourceLoc tryLoc) {
942936
/// 'discard' 'self'
943937
///
944938
ParserResult<Stmt> Parser::parseStmtDiscard() {
945-
SourceLoc discardLoc;
946-
947-
// NOTE: support for deprecated _forget
948-
if (Tok.is(tok::kw_forget)) {
949-
discardLoc = consumeToken(tok::kw_forget);
950-
diagnose(discardLoc, diag::forget_is_deprecated)
951-
.fixItReplace(discardLoc, "discard");
952-
} else {
953-
discardLoc = consumeToken(tok::kw_discard);
954-
}
939+
SourceLoc discardLoc = consumeToken(tok::kw_discard);
955940

956941
SourceLoc exprLoc;
957942
if (Tok.isNot(tok::eof))

test/ModuleInterface/discard_interface.swift

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,26 +3,16 @@
33
// RUN: %target-swift-typecheck-module-from-interface(%t/Library.swiftinterface) -I %t -enable-experimental-feature MoveOnlyResilientTypes
44
// RUN: %FileCheck %s < %t/Library.swiftinterface
55

6-
// This test makes sure that discard and _forget are emitted correctly in the
7-
// interfaces. We expect that if you use the old name _forget, you'll get that
8-
// in the interface file.
6+
// This test makes sure that discard is emitted correctly in the interfaces.
97

108
// CHECK: @_alwaysEmitIntoClient public consuming func AEIC_discard() { discard self }
119
// CHECK: @inlinable public consuming func inlinable_discard() { discard self }
1210

13-
// CHECK: @_alwaysEmitIntoClient public consuming func AEIC_forget() { _forget self }
14-
// CHECK: @inlinable public consuming func inlinable_forget() { _forget self }
15-
1611
public struct MoveOnlyStruct: ~Copyable {
1712
let x = 0
1813

1914
@_alwaysEmitIntoClient public consuming func AEIC_discard() { discard self }
2015
@inlinable public consuming func inlinable_discard() { discard self }
2116

22-
@_alwaysEmitIntoClient public consuming func AEIC_forget() { _forget self }
23-
// expected-warning@-1 {{'_forget' keyword is deprecated and will be removed soon; use 'discard' instead}}
24-
@inlinable public consuming func inlinable_forget() { _forget self }
25-
// expected-warning@-1 {{'_forget' keyword is deprecated and will be removed soon; use 'discard' instead}}
26-
2717
deinit {}
2818
}

test/Parse/discard.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,10 @@ func c() {
3333
discard self
3434
}
3535

36+
func c() {
37+
_forget self // expected-error {{consecutive statements on a line must be separated by ';'}}
38+
}
39+
3640
func c() {
3741
discard `self`
3842
}

test/Parse/forget.swift

Lines changed: 0 additions & 78 deletions
This file was deleted.

0 commit comments

Comments
 (0)