You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[Macros] Improve diagnostics for missing macro implementation (#65814)
We should no longer say "macro implementation must be provided via '-load-plugin-library'" as there are multiple ways to pick up a macro dependency. Here's an improved version:
> warning: external macro implementation type 'MissingModule.MissingType' could not be found for macro 'missingMacro1'; the type must be public and provided by a macro target in a Swift package, or via '-plugin-path' or '-load-plugin-library'
Copy file name to clipboardExpand all lines: test/Macros/attached_macros_diags.swift
+1-1Lines changed: 1 addition & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -38,7 +38,7 @@ struct SkipNestedType {
38
38
39
39
// We select the macro, not the property wrapper.
40
40
@m1varx:Int=0
41
-
// expected-error@-1{{external macro implementation type 'MyMacros.Macro1' could not be found for macro 'm1()'; the type must be public and provided via '-load-plugin-library'}}
41
+
// expected-error@-1{{external macro implementation type 'MyMacros.Macro1' could not be found for macro 'm1()'}}
Copy file name to clipboardExpand all lines: test/Macros/external-macro-without-decl.swift
+1-1Lines changed: 1 addition & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -3,7 +3,7 @@
3
3
// RUN: %target-typecheck-verify-swift -swift-version 5 -module-name Swift -parse-stdlib
4
4
5
5
// expected-warning@+2{{@expression has been removed in favor of @freestanding(expression)}}
6
-
// expected-warning@+1{{external macro implementation type 'A.B' could not be found for macro 'myMacro()'; the type must be public and provided via '-load-plugin-library'}}
6
+
// expected-warning@+1{{external macro implementation type 'A.B' could not be found for macro 'myMacro()'}}
#missingMacro1("hello") // expected-error{{external macro implementation type 'MissingModule.MissingType' could not be found for macro 'missingMacro1'; the type must be public and provided via '-load-plugin-library'}}
140
+
#missingMacro1("hello") // expected-error{{external macro implementation type 'MissingModule.MissingType' could not be found for macro 'missingMacro1'; the type must be public and provided by a macro target in a Swift package, or via '-plugin-path' or '-load-plugin-library'}}
141
141
}
142
142
143
143
@freestanding(expression) macro undefined() // expected-error{{macro 'undefined()' requires a definition}}
// expected-warning@-1{{external macro implementation type 'A.M1' could not be found for macro 'm1()'; the type must be public and provided via '-load-plugin-library'}}
9
+
// expected-warning@-1{{external macro implementation type 'A.M1' could not be found for macro 'm1()'}}
// expected-warning@-1{{external macro implementation type 'A.M2' could not be found for macro 'm2'; the type must be public and provided via '-load-plugin-library'}}
12
+
// expected-warning@-1{{external macro implementation type 'A.M2' could not be found for macro 'm2'}}
// expected-warning@-1{{external macro implementation type 'A.M3' could not be found for macro 'm3(a:)'; the type must be public and provided via '-load-plugin-library'}}
14
+
// expected-warning@-1{{external macro implementation type 'A.M3' could not be found for macro 'm3(a:)'}}
// expected-warning@-1{{external macro implementation type 'A.M4' could not be found for macro 'm4()'; the type must be public and provided via '-load-plugin-library'}}
16
+
// expected-warning@-1{{external macro implementation type 'A.M4' could not be found for macro 'm4()'}}
// expected-warning@-1{{external macro implementation type 'A.M4' could not be found for macro 'm5'; the type must be public and provided via '-load-plugin-library'}}
18
+
// expected-warning@-1{{external macro implementation type 'A.M4' could not be found for macro 'm5'}}
19
19
20
20
@freestanding(expression) macro m6 = A // expected-error{{expected '(' for macro parameters or ':' for a value-like macro}}
21
21
// expected-error@-1{{by a macro expansion}}
22
22
23
23
// expected-error @+2 {{expected '('}}
24
24
// expected-error @+1 {{macro 'm7' must declare its applicable roles}}
// expected-warning@-1{{external macro implementation type 'A.M4' could not be found for macro 'm7'; the type must be public and provided via '-load-plugin-library'}}
26
+
// expected-warning@-1{{external macro implementation type 'A.M4' could not be found for macro 'm7'}}
27
27
28
28
// expected-error @+2 {{expected a freestanding macro role such as 'expression'}}
29
29
// expected-error @+1 {{macro 'm8' must declare its applicable roles}}
// expected-warning@-1{{external macro implementation type 'A.M4' could not be found for macro 'm8'; the type must be public and provided via '-load-plugin-library'}}
31
+
// expected-warning@-1{{external macro implementation type 'A.M4' could not be found for macro 'm8'}}
// expected-warning@-1{{external macro implementation type 'A.M4' could not be found for macro 'm9'; the type must be public and provided via '-load-plugin-library'}}
33
+
// expected-warning@-1{{external macro implementation type 'A.M4' could not be found for macro 'm9'}}
// expected-warning@-1{{external macro implementation type 'A.M4' could not be found for macro 'm10'; the type must be public and provided via '-load-plugin-library'}}
37
+
// expected-warning@-1{{external macro implementation type 'A.M4' could not be found for macro 'm10'}}
38
38
39
39
@attached(
40
40
accessor,
@@ -55,4 +55,4 @@ macro am2() -> Void
55
55
56
56
#m1+1
57
57
// expected-warning @-1 {{result of operator '+' is unused}}
58
-
// expected-error @-2 {{external macro implementation type 'A.M1' could not be found for macro 'm1()'; the type must be public and provided via '-load-plugin-library'}}
58
+
// expected-error @-2 {{external macro implementation type 'A.M1' could not be found for macro 'm1()'}}
0 commit comments