Skip to content

Commit 7b92a8f

Browse files
committed
AST: Quote attributes more consistently in DiagnosticsParse.def
1 parent 5e41794 commit 7b92a8f

15 files changed

+61
-60
lines changed

include/swift/AST/DiagnosticsParse.def

Lines changed: 35 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -497,7 +497,7 @@ ERROR(expected_precedencegroup_relation,none,
497497
ERROR(expected_sil_keyword,none,
498498
"expected SIL keyword", ())
499499
ERROR(inout_not_attribute, none,
500-
"@inout is no longer an attribute", ())
500+
"'inout' is no longer an attribute", ())
501501
ERROR(only_allowed_in_sil,none,
502502
"'%0' only allowed in SIL modules", (StringRef))
503503
ERROR(expected_sil_type,none,
@@ -520,7 +520,7 @@ ERROR(silfunc_and_silarg_have_incompatible_sil_value_ownership,none,
520520
"Function type specifies: '@%0'. SIL argument specifies: '@%1'.",
521521
(StringRef, StringRef))
522522
ERROR(sil_arg_both_lexical_and_eagerMove,none,
523-
"Function argument is annotated both @_eagerMove and @_noEagerMove, "
523+
"Function argument is annotated both '@_eagerMove' and '@_noEagerMove', "
524524
"but these are incompatible alternatives", ())
525525
ERROR(expected_sil_colon,none,
526526
"expected ':' before %0", (StringRef))
@@ -1624,14 +1624,14 @@ ERROR(attr_availability_duplicate,none,
16241624

16251625
// originallyDefinedIn
16261626
ERROR(originally_defined_in_missing_rparen,none,
1627-
"expected ')' in @_originallyDefinedIn argument list", ())
1627+
"expected ')' in '@_originallyDefinedIn' argument list", ())
16281628

16291629
ERROR(originally_defined_in_need_original_module_name,none,
16301630
"expected 'module: \"original\"' in the first argument to "
1631-
"@_originallyDefinedIn", ())
1631+
"'@_originallyDefinedIn'", ())
16321632

16331633
ERROR(originally_defined_in_need_nonempty_module_name,none,
1634-
"original module name cannot be empty in @_originallyDefinedIn", ())
1634+
"original module name cannot be empty in '@_originallyDefinedIn'", ())
16351635

16361636
// backDeploy
16371637
ERROR(attr_back_deploy_expected_before_label,none,
@@ -1662,25 +1662,25 @@ ERROR(convention_attribute_witness_method_expected_protocol,none,
16621662

16631663
// objc
16641664
ERROR(attr_objc_missing_colon,none,
1665-
"missing ':' after selector piece in @objc attribute", ())
1665+
"missing ':' after selector piece in '@objc'", ())
16661666
ERROR(attr_objc_expected_rparen,none,
1667-
"expected ')' after name for @objc", ())
1667+
"expected ')' after name for '@objc'", ())
16681668
ERROR(attr_objc_empty_name,none,
1669-
"expected name within parentheses of @objc attribute", ())
1669+
"expected name within parentheses of '@objc'", ())
16701670

16711671
ERROR(attr_dynamic_replacement_expected_rparen,none,
1672-
"expected ')' after function name for @_dynamicReplacement", ())
1672+
"expected ')' after function name for '@_dynamicReplacement'", ())
16731673
ERROR(attr_dynamic_replacement_expected_function,none,
1674-
"expected a function name in @_dynamicReplacement(for:)", ())
1674+
"expected a function name in '@_dynamicReplacement(for:)'", ())
16751675
ERROR(attr_dynamic_replacement_expected_for,none,
16761676
"expected 'for' in '_dynamicReplacement' attribute", ())
16771677
ERROR(attr_dynamic_replacement_expected_colon,none,
1678-
"expected ':' after @_dynamicReplacement(for", ())
1678+
"expected ':' after '@_dynamicReplacement(for'", ())
16791679

16801680
ERROR(attr_type_eraser_expected_type_name,none,
1681-
"expected a type name in @_typeEraser()", ())
1681+
"expected a type name in '@_typeEraser()'", ())
16821682
ERROR(attr_type_eraser_expected_rparen,none,
1683-
"expected ')' after type name for @_typeEraser", ())
1683+
"expected ')' after type name for '@_typeEraser'", ())
16841684

16851685
ERROR(expected_thrown_error_type,none,
16861686
"expected thrown error type after 'throws('", ())
@@ -1698,13 +1698,13 @@ ERROR(attr_isolated_expected_kind,none,
16981698
"expected 'any' as the isolation kind", ())
16991699

17001700
ERROR(attr_private_import_expected_rparen,none,
1701-
"expected ')' after function name for @_private", ())
1701+
"expected ')' after function name for '@_private'", ())
17021702
ERROR(attr_private_import_expected_sourcefile, none,
17031703
"expected 'sourceFile' in '_private' attribute", ())
17041704
ERROR(attr_private_import_expected_sourcefile_name,none,
1705-
"expected a source file name in @_private(sourceFile:)", ())
1705+
"expected a source file name in '@_private(sourceFile:)'", ())
17061706
ERROR(attr_private_import_expected_colon,none,
1707-
"expected ':' after @_private(sourceFile", ())
1707+
"expected ':' after '@_private(sourceFile'", ())
17081708

17091709
// opened
17101710
ERROR(opened_attribute_expected_lparen,none,
@@ -1825,45 +1825,45 @@ ERROR(sil_inst_autodiff_expected_differentiability_witness_kind,PointsToFirstBad
18251825
"'[vjp]', or '[transpose]'", ())
18261826

18271827
WARNING(warn_attr_unsafe_removed,none,
1828-
"'%0' attribute has been removed in favor of @preconcurrency",
1828+
"'%0' attribute has been removed in favor of '@preconcurrency'",
18291829
(StringRef))
18301830

18311831
// _documentation
18321832
ERROR(documentation_attr_expected_argument,none,
1833-
"@_documentation attribute expected 'visibility' or 'metadata' argument",
1833+
"'_documentation' attribute expected 'visibility' or 'metadata' argument",
18341834
())
18351835
ERROR(documentation_attr_unknown_argument,none,
18361836
"unknown argument '%0', expected 'visibility' or 'metadata'",
18371837
(StringRef))
18381838
ERROR(documentation_attr_expected_access_level,none,
1839-
"@_documentation attribute's 'visibility' argument expected an access level",
1839+
"'_documentation' attribute's 'visibility' argument expected an access level",
18401840
())
18411841
ERROR(documentation_attr_unknown_access_level,none,
18421842
"unknown visibility '%0', expected an access level keyword",
18431843
(StringRef))
18441844
ERROR(documentation_attr_duplicate_visibility,none,
18451845
"cannot give more than one visibility to the same item", ())
18461846
ERROR(documentation_attr_metadata_expected_text,none,
1847-
"@_documentation attribute's 'metadata' argument expected an identifier or "
1847+
"'_documentation' attribute's 'metadata' argument expected an identifier or "
18481848
"quoted string",
18491849
())
18501850
ERROR(documentation_attr_duplicate_metadata,none,
18511851
"cannot give more than one metadata argument to the same item", ())
18521852

18531853
ERROR(attr_rawlayout_expected_label,none,
1854-
"expected %0 argument to @_rawLayout attribute", (StringRef))
1854+
"expected %0 argument to '@_rawLayout'", (StringRef))
18551855
ERROR(attr_rawlayout_expected_integer_size,none,
1856-
"expected integer literal size in @_rawLayout attribute", ())
1856+
"expected integer literal size in '@_rawLayout'", ())
18571857
ERROR(attr_rawlayout_expected_integer_alignment,none,
1858-
"expected integer literal alignment in @_rawLayout attribute", ())
1858+
"expected integer literal alignment in '@_rawLayout'", ())
18591859
ERROR(attr_rawlayout_expected_params,none,
1860-
"expected %1 argument after %0 argument in @_rawLayout attribute", (StringRef, StringRef))
1860+
"expected %1 argument after %0 argument in '@_rawLayout'", (StringRef, StringRef))
18611861

18621862
ERROR(attr_extern_expected_label,none,
1863-
"expected %0 argument to @_extern attribute", (StringRef))
1863+
"expected %0 argument to '@_extern'", (StringRef))
18641864

18651865
ERROR(attr_expected_feature_name,none,
1866-
"expected feature name in @%0 attribute", (StringRef))
1866+
"expected feature name in '@%0'", (StringRef))
18671867

18681868
//------------------------------------------------------------------------------
18691869
// MARK: Generics parsing diagnostics
@@ -2056,13 +2056,13 @@ ERROR(macro_role_syntax_mismatch,PointsToFirstBadToken,
20562056
"%select{a freestanding|an attached}0 macro cannot have the %1 role",
20572057
(bool, Identifier))
20582058
ERROR(macro_attribute_unknown_label,PointsToFirstBadToken,
2059-
"@%select{freestanding|attached}0 has no argument with label %1",
2059+
"'@%select{freestanding|attached}0' has no argument with label %1",
20602060
(bool, Identifier))
20612061
ERROR(macro_attribute_duplicate_label,PointsToFirstBadToken,
2062-
"@%select{freestanding|attached}0 already has an argument with "
2062+
"'@%select{freestanding|attached}0' already has an argument with "
20632063
"label %1", (bool, StringRef))
20642064
ERROR(macro_attribute_missing_label,none,
2065-
"@%select{freestanding|attached}0 argument is missing label '%1'",
2065+
"'@%select{freestanding|attached}0' argument is missing label '%1'",
20662066
(bool, StringRef))
20672067
ERROR(macro_attribute_unknown_name_kind,PointsToFirstBadToken,
20682068
"unknown introduced name kind %0", (Identifier))
@@ -2073,7 +2073,8 @@ ERROR(macro_attribute_introduced_name_requires_argument,PointsToFirstBadToken,
20732073
ERROR(macro_attribute_introduced_name_requires_no_argument,PointsToFirstBadToken,
20742074
"introduced name kind %0 must not have an argument", (Identifier))
20752075
WARNING(macro_expression_attribute_removed,PointsToFirstBadToken,
2076-
"@expression has been removed in favor of @freestanding(expression)", ())
2076+
"'@expression' has been removed in favor of '@freestanding(expression)'",
2077+
())
20772078

20782079
ERROR(unexpected_attribute_expansion,PointsToFirstBadToken,
20792080
"unexpected token '%0' in expanded attribute list",
@@ -2109,16 +2110,16 @@ ERROR(init_accessor_is_not_in_the_primary_declaration,none,
21092110
())
21102111

21112112
ERROR(missing_storage_restrictions_attr_label,none,
2112-
"missing label in @storageRestrictions attribute", ())
2113+
"missing label in '@storageRestrictions'", ())
21132114

21142115
ERROR(invalid_storage_restrictions_attr_label,none,
2115-
"unexpected label %0 in @storageRestrictions attribute", (Identifier))
2116+
"unexpected label %0 in '@storageRestrictions'", (Identifier))
21162117

21172118
ERROR(duplicate_storage_restrictions_attr_label,none,
2118-
"duplicate label %0 in @storageRestrictions attribute", (Identifier))
2119+
"duplicate label %0 in '@storageRestrictions'", (Identifier))
21192120

21202121
ERROR(storage_restrictions_attr_expected_name,none,
2121-
"expected property name in @storageRestrictions list", ())
2122+
"expected property name in '@storageRestrictions' list", ())
21222123

21232124
ERROR(requires_experimental_feature, none,
21242125
"'%0' %select{attribute|parameter specifier}1 is only valid when experimental feature "

test/Concurrency/predates_concurrency.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -148,10 +148,10 @@ struct S3: Q, Sendable {
148148
// Historical attribute names do nothing (but are permitted)
149149
// ---------------------------------------------------------------------------
150150
func aFailedExperiment(@_unsafeSendable _ body: @escaping () -> Void) { }
151-
// expected-warning@-1{{'_unsafeSendable' attribute has been removed in favor of @preconcurrency}}
151+
// expected-warning@-1{{'_unsafeSendable' attribute has been removed in favor of '@preconcurrency'}}
152152

153153
func anothingFailedExperiment(@_unsafeMainActor _ body: @escaping () -> Void) { }
154-
// expected-warning@-1{{'_unsafeMainActor' attribute has been removed in favor of @preconcurrency}}
154+
// expected-warning@-1{{'_unsafeMainActor' attribute has been removed in favor of '@preconcurrency'}}
155155

156156
// ---------------------------------------------------------------------------
157157
// Random bugs

test/Concurrency/predates_concurrency_swift6.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,10 +108,10 @@ struct S3: Q, Sendable {
108108
// Historical attribute names do nothing (but are permitted)
109109
// ---------------------------------------------------------------------------
110110
func aFailedExperiment(@_unsafeSendable _ body: @escaping () -> Void) { }
111-
// expected-warning@-1{{'_unsafeSendable' attribute has been removed in favor of @preconcurrency}}
111+
// expected-warning@-1{{'_unsafeSendable' attribute has been removed in favor of '@preconcurrency'}}
112112

113113
func anothingFailedExperiment(@_unsafeMainActor _ body: @escaping () -> Void) { }
114-
// expected-warning@-1{{'_unsafeMainActor' attribute has been removed in favor of @preconcurrency}}
114+
// expected-warning@-1{{'_unsafeMainActor' attribute has been removed in favor of '@preconcurrency'}}
115115

116116
// Override matching with @preconcurrency properties.
117117
do {

test/Constraints/issue-77393.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,6 @@ macro someMacro() = #externalMacro(module: "", type: "")
1919

2020
macro invalidMacro()
2121
// expected-error@-1 {{macro 'invalidMacro()' requires a definition}}
22-
// expected-error@-2 {{macro 'invalidMacro()' must declare its applicable roles via '@freestanding' or @attached'}}
22+
// expected-error@-2 {{macro 'invalidMacro()' must declare its applicable roles via '@freestanding' or '@attached'}}
2323

2424
#invalidMacro() // expected-error {{no macro named 'invalidMacro'}}

test/Constraints/suspicious_bit_casts.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ func escapeByBitCast(f: () -> ()) -> () -> () {
66
}
77

88
func changeFnRep(f: @escaping () -> ()) -> @convention(block) () -> () {
9-
// expected-warning@+1{{'unsafeBitCast' from function type '() -> ()' to '@convention(block) () -> ()' changes @convention and is undefined; use an implicit conversion to change conventions}}
9+
// expected-warning@+1{{'unsafeBitCast' from function type '() -> ()' to '@convention(block) () -> ()' changes '@convention' and is undefined; use an implicit conversion to change conventions}}
1010
return unsafeBitCast(f, to: (@convention(block) () -> ()).self)
1111
}
1212

test/Macros/external-macro-without-decl.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
// RUN: %target-typecheck-verify-swift -swift-version 5 -module-name Swift -parse-stdlib
44

5-
// expected-warning@+2{{@expression has been removed in favor of @freestanding(expression)}}
5+
// expected-warning@+2{{'@expression' has been removed in favor of '@freestanding(expression)'}}
66
// expected-warning@+1{{external macro implementation type 'A.B' could not be found for macro 'myMacro()'}}
77
@expression macro myMacro() = #externalMacro(module: "A", type: "B")
88

test/Macros/macros_diagnostics.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
@expression macro stringify<T>(_ value: T) -> (T, String) = #externalMacro(module: "MacroDefinition", type: "StringifyMacro")
77
// expected-note@-1 3{{'stringify' declared here}}
88
// expected-warning@-2{{external macro implementation type}}
9-
// expected-warning@-3{{@expression has been removed in favor of @freestanding(expression)}}{{1-12=@freestanding(expression)}}
9+
// expected-warning@-3{{'@expression' has been removed in favor of '@freestanding(expression)'}}{{1-12=@freestanding(expression)}}
1010
@freestanding(expression) macro missingMacro1(_: Any) = MissingModule.MissingType // expected-note{{'missingMacro1' declared here}}
1111
// expected-warning@-1{{external macro definitions are now written using #externalMacro}}
1212
// expected-warning@-2{{external macro implementation type}}

test/Macros/parsing.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ macro am1()
4646

4747
@attached(
4848
accessor,
49-
overloaded, // expected-error{{@attached argument is missing label 'names'}}
49+
overloaded, // expected-error{{'@attached' argument is missing label 'names'}}
5050
unknown, // expected-error{{unknown introduced name kind 'unknown'}}
5151
named, // expected-error{{introduced name kind 'named' requires a single argument '(name)'}}
5252
arbitrary(a) // expected-error{{introduced name kind 'arbitrary' must not have an argument}}

test/Parse/diagnose_dynamicReplacement.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,5 @@ func test_dynamic_replacement_for2() {
1616

1717
@_dynamicReplacement(for: dynamically_replaceable() // expected-note {{to match this opening '('}}
1818
func test_dynamic_replacement_for3() {
19-
// expected-error@-1 {{expected ')' after function name for @_dynamicReplacement}}
19+
// expected-error@-1 {{expected ')' after function name for '@_dynamicReplacement'}}
2020
}

test/Parse/original_defined_in_attr.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
@_originallyDefinedIn(module: "foo", OSX 13.13) // expected-error {{'@_originallyDefinedIn' requires that 'foo()' have explicit availability for macOS}}
55
public func foo() {}
66

7-
@_originallyDefinedIn(modulename: "foo", OSX 13.13) // expected-error {{expected 'module: "original"' in the first argument to @_originallyDefinedIn}}
7+
@_originallyDefinedIn(modulename: "foo", OSX 13.13) // expected-error {{expected 'module: "original"' in the first argument to '@_originallyDefinedIn'}}
88
public func foo1() {}
99

1010
@_originallyDefinedIn(module: "foo", OSX 13.13.3) // expected-warning {{'@_originallyDefinedIn' only uses major and minor version number}}
@@ -14,7 +14,7 @@ public class ToplevelClass {}
1414
@_originallyDefinedIn(module: "foo") // expected-error {{expected at least one platform version in '@_originallyDefinedIn' attribute}}
1515
public class ToplevelClass1 {}
1616

17-
@_originallyDefinedIn(OSX 13.13.3) // expected-error {{expected 'module: "original"' in the first argument to @_originallyDefinedIn}}
17+
@_originallyDefinedIn(OSX 13.13.3) // expected-error {{expected 'module: "original"' in the first argument to '@_originallyDefinedIn'}}
1818
public class ToplevelClass2 {}
1919

2020
@_originallyDefinedIn(module: "foo",

test/Parse/trailing-comma.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ struct Foo {
8888
var y: Int
8989

9090
var value: (Int, Int) {
91-
@storageRestrictions(initializes: x, y,) // expected-error {{expected property name in @storageRestrictions list}}
91+
@storageRestrictions(initializes: x, y,) // expected-error {{expected property name in '@storageRestrictions' list}}
9292
init(initialValue) {
9393
self.x = initialValue.0
9494
self.y = initialValue.1

test/Sema/raw_layout_parse.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,12 @@ struct SmallVectorBuf<T>: ~Copyable {}
2020
@_rawLayout // expected-error{{expected '('}}
2121
struct NoLayoutSpecified: ~Copyable {}
2222

23-
@_rawLayout() // expected-error{{expected 'size', 'like', or 'likeArrayOf' argument to @_rawLayout attribute}}
23+
@_rawLayout() // expected-error{{expected 'size', 'like', or 'likeArrayOf' argument to '@_rawLayout'}}
2424
struct NoParamsSpecified: ~Copyable {}
2525

26-
@_rawLayout(size: 4) // expected-error{{expected alignment argument after size argument in @_rawLayout attribute}}
26+
@_rawLayout(size: 4) // expected-error{{expected alignment argument after size argument in '@_rawLayout'}}
2727
struct SizeWithoutAlignment: ~Copyable {}
2828

29-
@_rawLayout(likeArrayOf: Optional<Int>) // expected-error{{expected count argument after likeArrayOf argument in @_rawLayout attribute}}
29+
@_rawLayout(likeArrayOf: Optional<Int>) // expected-error{{expected count argument after likeArrayOf argument in '@_rawLayout'}}
3030
struct ArrayWithoutSize: ~Copyable {}
3131

test/attr/attr_objc.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1999,7 +1999,7 @@ class Class_ObjC2 {
19991999
// CHECK-LABEL: @objc(isFoo) func foo() -> Bool {
20002000
}
20012001

2002-
@objc() // expected-error {{expected name within parentheses of @objc attribute}}
2002+
@objc() // expected-error {{expected name within parentheses of '@objc'}}
20032003
class Class_ObjC3 {
20042004
}
20052005

@@ -2016,8 +2016,8 @@ extension PlainClass {
20162016
// CHECK-LABEL: @objc(createWithRed:green:blue:alpha:) dynamic class func createWith
20172017
@objc(createWithRed:green blue:alpha)
20182018
class func createWithRed(_: Float, green: Float, blue: Float, alpha: Float) { }
2019-
// expected-error@-2{{missing ':' after selector piece in @objc attribute}}{{28-28=:}}
2020-
// expected-error@-3{{missing ':' after selector piece in @objc attribute}}{{39-39=:}}
2019+
// expected-error@-2{{missing ':' after selector piece in '@objc'}}{{28-28=:}}
2020+
// expected-error@-3{{missing ':' after selector piece in '@objc'}}{{39-39=:}}
20212021

20222022
// CHECK-LABEL: @objc(::) dynamic func badlyNamed
20232023
@objc(::) // access-note-move{{PlainClass.badlyNamed(_:y:)}}

test/attr/typeEraser.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,11 @@ protocol Collection {
2929
@_typeEraser // expected-error {{expected '(' in '_typeEraser' attribute}}
3030
protocol A1 {}
3131

32-
@_typeEraser() // expected-error {{expected a type name in @_typeEraser()}}
32+
@_typeEraser() // expected-error {{expected a type name in '@_typeEraser()'}}
3333
protocol A2 {}
3434

3535
@_typeEraser(AnyP // expected-note {{to match this opening '('}}
36-
protocol A3 {} // expected-error {{expected ')' after type name for @_typeEraser}}
36+
protocol A3 {} // expected-error {{expected ')' after type name for '@_typeEraser'}}
3737

3838
@_typeEraser(AnyP) // expected-error {{@_typeEraser may only be used on 'protocol' declarations}}
3939
func notAProtocol() {}

0 commit comments

Comments
 (0)