Skip to content

Commit 724a885

Browse files
committed
[Diagnostics] Tailor using diagnostic to current use-case - default isolation
1 parent 822ac93 commit 724a885

File tree

3 files changed

+6
-8
lines changed

3 files changed

+6
-8
lines changed

include/swift/AST/DiagnosticsParse.def

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2191,8 +2191,8 @@ ERROR(nonisolated_nonsending_repeated,none,
21912191
// MARK: using @<attribute> or using <identifier>
21922192
//------------------------------------------------------------------------------
21932193
ERROR(using_decl_invalid_specifier,PointsToFirstBadToken,
2194-
"'using' declaration does not support %0 %select{modifier|attribute}1",
2195-
(Identifier, bool))
2194+
"default isolation can only be set to '@MainActor' or 'nonisolated'",
2195+
())
21962196

21972197
#define UNDEFINE_DIAGNOSTIC_MACROS
21982198
#include "DefineDiagnosticMacros.h"

lib/Parse/ParseDecl.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6677,10 +6677,9 @@ ParserResult<UsingDecl> Parser::parseDeclUsing(ParseDeclOptions Flags,
66776677
return makeParserCodeCompletionStatus();
66786678
}
66796679

6680-
SourceLoc AtLoc;
66816680
// @<<attribute>>
66826681
if (Tok.is(tok::at_sign))
6683-
AtLoc = consumeToken();
6682+
consumeToken();
66846683

66856684
SourceLoc SpecifierLoc;
66866685
Identifier RawSpecifier;
@@ -6697,8 +6696,7 @@ ParserResult<UsingDecl> Parser::parseDeclUsing(ParseDeclOptions Flags,
66976696
.Default(std::nullopt);
66986697

66996698
if (!Specifier) {
6700-
diagnose(SpecifierLoc, diag::using_decl_invalid_specifier, RawSpecifier,
6701-
AtLoc.isValid());
6699+
diagnose(SpecifierLoc, diag::using_decl_invalid_specifier);
67026700
return nullptr;
67036701
}
67046702

test/Parse/using.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ using @MainActor
88
using nonisolated
99
// expected-error@-1 {{invalid redeclaration of file-level default actor isolation}}
1010

11-
using @Test // expected-error {{'using' declaration does not support 'Test' attribute}}
12-
using test // expected-error {{'using' declaration does not support 'test' modifier}}
11+
using @Test // expected-error {{default isolation can only be set to '@MainActor' or 'nonisolated'}}
12+
using test // expected-error {{default isolation can only be set to '@MainActor' or 'nonisolated'}}
1313

1414
do {
1515
using // expected-warning {{expression of type 'Int' is unused}}

0 commit comments

Comments
 (0)