Skip to content

Commit b103fed

Browse files
committed
Sema: Remove old diagnostics for misplaced InOutExpr
1 parent 5e4afc2 commit b103fed

File tree

2 files changed

+2
-28
lines changed

2 files changed

+2
-28
lines changed

include/swift/AST/DiagnosticsSema.def

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2790,8 +2790,6 @@ ERROR(object_literal_broken_proto,none,
27902790
ERROR(discard_expr_outside_of_assignment,none,
27912791
"'_' can only appear in a pattern or on the left side of an assignment",
27922792
())
2793-
ERROR(inout_expr_outside_of_call,none,
2794-
"'&' can only appear immediately in a call argument list", ())
27952793
ERROR(collection_literal_heterogeneous,none,
27962794
"heterogeneous collection literal could only be inferred to %0; add"
27972795
" explicit type annotation if this is intentional", (Type))

lib/Sema/MiscDiagnostics.cpp

Lines changed: 2 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -68,9 +68,6 @@ static void diagSyntacticUseRestrictions(TypeChecker &TC, const Expr *E,
6868
// Keep track of acceptable DiscardAssignmentExpr's.
6969
SmallPtrSet<DiscardAssignmentExpr*, 2> CorrectDiscardAssignmentExprs;
7070

71-
/// Keep track of InOutExprs
72-
SmallPtrSet<InOutExpr*, 2> AcceptableInOutExprs;
73-
7471
/// Keep track of the arguments to CallExprs.
7572
SmallPtrSet<Expr *, 2> CallArgs;
7673

@@ -127,15 +124,9 @@ static void diagSyntacticUseRestrictions(TypeChecker &TC, const Expr *E,
127124
if (isa<TypeExpr>(Base))
128125
checkUseOfMetaTypeName(Base);
129126

130-
if (auto *SE = dyn_cast<SubscriptExpr>(E)) {
127+
if (auto *SE = dyn_cast<SubscriptExpr>(E))
131128
CallArgs.insert(SE->getIndex());
132129

133-
// Implicit InOutExpr's are allowed in the base of a subscript expr.
134-
if (auto *IOE = dyn_cast<InOutExpr>(SE->getBase()))
135-
if (IOE->isImplicit())
136-
AcceptableInOutExprs.insert(IOE);
137-
}
138-
139130
if (auto *KPE = dyn_cast<KeyPathExpr>(E)) {
140131
for (auto Comp : KPE->getComponents()) {
141132
if (auto *Arg = Comp.getIndexExpr())
@@ -197,11 +188,6 @@ static void diagSyntacticUseRestrictions(TypeChecker &TC, const Expr *E,
197188
}
198189

199190
visitArguments(Call, [&](unsigned argIndex, Expr *arg) {
200-
// InOutExpr's are allowed in argument lists directly.
201-
if (auto *IOE = dyn_cast<InOutExpr>(arg)) {
202-
if (isa<CallExpr>(Call))
203-
AcceptableInOutExprs.insert(IOE);
204-
}
205191
// InOutExprs can be wrapped in some implicit casts.
206192
Expr *unwrapped = arg;
207193
if (auto *IIO = dyn_cast<InjectIntoOptionalExpr>(arg))
@@ -212,10 +198,8 @@ static void diagSyntacticUseRestrictions(TypeChecker &TC, const Expr *E,
212198
isa<ErasureExpr>(unwrapped)) {
213199
auto operand =
214200
cast<ImplicitConversionExpr>(unwrapped)->getSubExpr();
215-
if (auto *IOE = dyn_cast<InOutExpr>(operand)) {
216-
AcceptableInOutExprs.insert(IOE);
201+
if (auto *IOE = dyn_cast<InOutExpr>(operand))
217202
operand = IOE->getSubExpr();
218-
}
219203

220204
// Also do some additional work based on how the function uses
221205
// the argument.
@@ -238,14 +222,6 @@ static void diagSyntacticUseRestrictions(TypeChecker &TC, const Expr *E,
238222
TC.diagnose(DAE->getLoc(), diag::discard_expr_outside_of_assignment);
239223
}
240224

241-
// Diagnose an '&' that isn't in an argument lists.
242-
if (auto *IOE = dyn_cast<InOutExpr>(E)) {
243-
if (!IOE->isImplicit() && !AcceptableInOutExprs.count(IOE) &&
244-
!IOE->getType()->hasError())
245-
TC.diagnose(IOE->getLoc(), diag::inout_expr_outside_of_call)
246-
.highlight(IOE->getSubExpr()->getSourceRange());
247-
}
248-
249225
// Diagnose 'self.init' or 'super.init' nested in another expression
250226
// or closure.
251227
if (auto *rebindSelfExpr = dyn_cast<RebindSelfInConstructorExpr>(E)) {

0 commit comments

Comments
 (0)