Skip to content

Commit b2c6e5a

Browse files
committed
mbe: Split metavariable usage tests off from syntax tests
`syntax-errors` currently contains both actual syntax error tests and tests (which don't need expansion) and tests for incorrect usage of the `count` metavariable expression (which dos need expansion). Split the expansion-dependent tests to a separate file, remove unneeded invocations from `syntax-errors` to ensure we are catching these before expansion.
1 parent cf5eb27 commit b2c6e5a

File tree

6 files changed

+252
-377
lines changed

6 files changed

+252
-377
lines changed

tests/ui/macros/metavar-expressions/concat-syntax-errors.rs renamed to tests/ui/macros/metavar-expressions/concat-usage-errors.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ macro_rules! bad_tt_literal {
132132
}
133133

134134
fn main() {
135-
wrong_concat_declarations!(1);
135+
syntax_errors!(1);
136136

137137
dollar_sign_without_referenced_ident!(VAR);
138138

tests/ui/macros/metavar-expressions/concat-syntax-errors.stderr renamed to tests/ui/macros/metavar-expressions/concat-usage-errors.stderr

Lines changed: 33 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,85 +1,85 @@
11
error: expected identifier or string literal
2-
--> $DIR/concat-syntax-errors.rs:5:10
2+
--> $DIR/concat-usage-errors.rs:5:10
33
|
44
LL | ${concat()}
55
| ^^^^^^^^^^
66

77
error: `concat` must have at least two elements
8-
--> $DIR/concat-syntax-errors.rs:8:11
8+
--> $DIR/concat-usage-errors.rs:8:11
99
|
1010
LL | ${concat(aaaa)}
1111
| ^^^^^^
1212

1313
error: expected identifier or string literal
14-
--> $DIR/concat-syntax-errors.rs:11:10
14+
--> $DIR/concat-usage-errors.rs:11:10
1515
|
1616
LL | ${concat(aaaa,)}
1717
| ^^^^^^^^^^^^^^^
1818

1919
error: expected comma
20-
--> $DIR/concat-syntax-errors.rs:16:10
20+
--> $DIR/concat-usage-errors.rs:16:10
2121
|
2222
LL | ${concat(aaaa aaaa)}
2323
| ^^^^^^^^^^^^^^^^^^^
2424

2525
error: `concat` must have at least two elements
26-
--> $DIR/concat-syntax-errors.rs:19:11
26+
--> $DIR/concat-usage-errors.rs:19:11
2727
|
2828
LL | ${concat($ex)}
2929
| ^^^^^^
3030

3131
error: expected comma
32-
--> $DIR/concat-syntax-errors.rs:25:10
32+
--> $DIR/concat-usage-errors.rs:25:10
3333
|
3434
LL | ${concat($ex, aaaa 123)}
3535
| ^^^^^^^^^^^^^^^^^^^^^^^
3636

3737
error: expected identifier or string literal
38-
--> $DIR/concat-syntax-errors.rs:28:10
38+
--> $DIR/concat-usage-errors.rs:28:10
3939
|
4040
LL | ${concat($ex, aaaa,)}
4141
| ^^^^^^^^^^^^^^^^^^^^
4242

4343
error: expected identifier or string literal
44-
--> $DIR/concat-syntax-errors.rs:88:26
44+
--> $DIR/concat-usage-errors.rs:88:26
4545
|
4646
LL | let ${concat(_a, 'b')}: () = ();
4747
| ^^^
4848

4949
error: expected identifier or string literal
50-
--> $DIR/concat-syntax-errors.rs:91:26
50+
--> $DIR/concat-usage-errors.rs:91:26
5151
|
5252
LL | let ${concat(_a, 1)}: () = ();
5353
| ^
5454

5555
error: expected identifier or string literal
56-
--> $DIR/concat-syntax-errors.rs:94:30
56+
--> $DIR/concat-usage-errors.rs:94:30
5757
|
5858
LL | let ${concat($ident, 'b')}: () = ();
5959
| ^^^
6060

6161
error: expected identifier or string literal
62-
--> $DIR/concat-syntax-errors.rs:96:30
62+
--> $DIR/concat-usage-errors.rs:96:30
6363
|
6464
LL | let ${concat($ident, 1)}: () = ();
6565
| ^
6666

6767
error: metavariables of `${concat(..)}` must be of type `ident`, `literal` or `tt`
68-
--> $DIR/concat-syntax-errors.rs:22:19
68+
--> $DIR/concat-usage-errors.rs:22:19
6969
|
7070
LL | ${concat($ex, aaaa)}
7171
| ^^
7272
|
7373
= note: currently only string literals are supported
7474

7575
error: variable `foo` is not recognized in meta-variable expression
76-
--> $DIR/concat-syntax-errors.rs:35:30
76+
--> $DIR/concat-usage-errors.rs:35:30
7777
|
7878
LL | const ${concat(FOO, $foo)}: i32 = 2;
7979
| ^^^
8080

8181
error: `${concat(..)}` is not generating a valid identifier
82-
--> $DIR/concat-syntax-errors.rs:42:14
82+
--> $DIR/concat-usage-errors.rs:42:14
8383
|
8484
LL | let ${concat("1", $ident)}: () = ();
8585
| ^^^^^^^^^^^^^^^^^^^^^
@@ -90,7 +90,7 @@ LL | starting_number!(_abc);
9090
= note: this error originates in the macro `starting_number` (in Nightly builds, run with -Z macro-backtrace for more info)
9191

9292
error: `${concat(..)}` is not generating a valid identifier
93-
--> $DIR/concat-syntax-errors.rs:55:14
93+
--> $DIR/concat-usage-errors.rs:55:14
9494
|
9595
LL | let ${concat("\u{00BD}", $ident)}: () = ();
9696
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -101,7 +101,7 @@ LL | starting_invalid_unicode!(_abc);
101101
= note: this error originates in the macro `starting_invalid_unicode` (in Nightly builds, run with -Z macro-backtrace for more info)
102102

103103
error: `${concat(..)}` is not generating a valid identifier
104-
--> $DIR/concat-syntax-errors.rs:74:14
104+
--> $DIR/concat-usage-errors.rs:74:14
105105
|
106106
LL | let ${concat($ident, "\u{00BD}")}: () = ();
107107
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -112,7 +112,7 @@ LL | ending_invalid_unicode!(_abc);
112112
= note: this error originates in the macro `ending_invalid_unicode` (in Nightly builds, run with -Z macro-backtrace for more info)
113113

114114
error: expected pattern, found `$`
115-
--> $DIR/concat-syntax-errors.rs:88:13
115+
--> $DIR/concat-usage-errors.rs:88:13
116116
|
117117
LL | let ${concat(_a, 'b')}: () = ();
118118
| ^ expected pattern
@@ -123,7 +123,7 @@ LL | unsupported_literals!(_abc);
123123
= note: this error originates in the macro `unsupported_literals` (in Nightly builds, run with -Z macro-backtrace for more info)
124124

125125
error: `${concat(..)}` is not generating a valid identifier
126-
--> $DIR/concat-syntax-errors.rs:81:14
126+
--> $DIR/concat-usage-errors.rs:81:14
127127
|
128128
LL | let ${concat("", "")}: () = ();
129129
| ^^^^^^^^^^^^^^^^
@@ -134,7 +134,7 @@ LL | empty!();
134134
= note: this error originates in the macro `empty` (in Nightly builds, run with -Z macro-backtrace for more info)
135135

136136
error: `${concat(..)}` is not generating a valid identifier
137-
--> $DIR/concat-syntax-errors.rs:103:16
137+
--> $DIR/concat-usage-errors.rs:103:16
138138
|
139139
LL | const ${concat(_foo, $literal)}: () = ();
140140
| ^^^^^^^^^^^^^^^^^^^^^^^^
@@ -145,7 +145,7 @@ LL | bad_literal_string!("\u{00BD}");
145145
= note: this error originates in the macro `bad_literal_string` (in Nightly builds, run with -Z macro-backtrace for more info)
146146

147147
error: `${concat(..)}` is not generating a valid identifier
148-
--> $DIR/concat-syntax-errors.rs:103:16
148+
--> $DIR/concat-usage-errors.rs:103:16
149149
|
150150
LL | const ${concat(_foo, $literal)}: () = ();
151151
| ^^^^^^^^^^^^^^^^^^^^^^^^
@@ -156,7 +156,7 @@ LL | bad_literal_string!("\x41");
156156
= note: this error originates in the macro `bad_literal_string` (in Nightly builds, run with -Z macro-backtrace for more info)
157157

158158
error: `${concat(..)}` is not generating a valid identifier
159-
--> $DIR/concat-syntax-errors.rs:103:16
159+
--> $DIR/concat-usage-errors.rs:103:16
160160
|
161161
LL | const ${concat(_foo, $literal)}: () = ();
162162
| ^^^^^^^^^^^^^^^^^^^^^^^^
@@ -167,7 +167,7 @@ LL | bad_literal_string!("🤷");
167167
= note: this error originates in the macro `bad_literal_string` (in Nightly builds, run with -Z macro-backtrace for more info)
168168

169169
error: `${concat(..)}` is not generating a valid identifier
170-
--> $DIR/concat-syntax-errors.rs:103:16
170+
--> $DIR/concat-usage-errors.rs:103:16
171171
|
172172
LL | const ${concat(_foo, $literal)}: () = ();
173173
| ^^^^^^^^^^^^^^^^^^^^^^^^
@@ -178,7 +178,7 @@ LL | bad_literal_string!("d[-_-]b");
178178
= note: this error originates in the macro `bad_literal_string` (in Nightly builds, run with -Z macro-backtrace for more info)
179179

180180
error: `${concat(..)}` is not generating a valid identifier
181-
--> $DIR/concat-syntax-errors.rs:103:16
181+
--> $DIR/concat-usage-errors.rs:103:16
182182
|
183183
LL | const ${concat(_foo, $literal)}: () = ();
184184
| ^^^^^^^^^^^^^^^^^^^^^^^^
@@ -189,7 +189,7 @@ LL | bad_literal_string!("-1");
189189
= note: this error originates in the macro `bad_literal_string` (in Nightly builds, run with -Z macro-backtrace for more info)
190190

191191
error: `${concat(..)}` is not generating a valid identifier
192-
--> $DIR/concat-syntax-errors.rs:103:16
192+
--> $DIR/concat-usage-errors.rs:103:16
193193
|
194194
LL | const ${concat(_foo, $literal)}: () = ();
195195
| ^^^^^^^^^^^^^^^^^^^^^^^^
@@ -200,7 +200,7 @@ LL | bad_literal_string!("1.0");
200200
= note: this error originates in the macro `bad_literal_string` (in Nightly builds, run with -Z macro-backtrace for more info)
201201

202202
error: `${concat(..)}` is not generating a valid identifier
203-
--> $DIR/concat-syntax-errors.rs:103:16
203+
--> $DIR/concat-usage-errors.rs:103:16
204204
|
205205
LL | const ${concat(_foo, $literal)}: () = ();
206206
| ^^^^^^^^^^^^^^^^^^^^^^^^
@@ -211,15 +211,15 @@ LL | bad_literal_string!("'1'");
211211
= note: this error originates in the macro `bad_literal_string` (in Nightly builds, run with -Z macro-backtrace for more info)
212212

213213
error: metavariables of `${concat(..)}` must be of type `ident`, `literal` or `tt`
214-
--> $DIR/concat-syntax-errors.rs:116:31
214+
--> $DIR/concat-usage-errors.rs:116:31
215215
|
216216
LL | const ${concat(_foo, $literal)}: () = ();
217217
| ^^^^^^^
218218
|
219219
= note: currently only string literals are supported
220220

221221
error: metavariables of `${concat(..)}` must be of type `ident`, `literal` or `tt`
222-
--> $DIR/concat-syntax-errors.rs:116:31
222+
--> $DIR/concat-usage-errors.rs:116:31
223223
|
224224
LL | const ${concat(_foo, $literal)}: () = ();
225225
| ^^^^^^^
@@ -228,7 +228,7 @@ LL | const ${concat(_foo, $literal)}: () = ();
228228
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
229229

230230
error: metavariables of `${concat(..)}` must be of type `ident`, `literal` or `tt`
231-
--> $DIR/concat-syntax-errors.rs:116:31
231+
--> $DIR/concat-usage-errors.rs:116:31
232232
|
233233
LL | const ${concat(_foo, $literal)}: () = ();
234234
| ^^^^^^^
@@ -237,7 +237,7 @@ LL | const ${concat(_foo, $literal)}: () = ();
237237
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
238238

239239
error: metavariables of `${concat(..)}` must be of type `ident`, `literal` or `tt`
240-
--> $DIR/concat-syntax-errors.rs:116:31
240+
--> $DIR/concat-usage-errors.rs:116:31
241241
|
242242
LL | const ${concat(_foo, $literal)}: () = ();
243243
| ^^^^^^^
@@ -246,7 +246,7 @@ LL | const ${concat(_foo, $literal)}: () = ();
246246
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
247247

248248
error: metavariables of `${concat(..)}` must be of type `ident`, `literal` or `tt`
249-
--> $DIR/concat-syntax-errors.rs:116:31
249+
--> $DIR/concat-usage-errors.rs:116:31
250250
|
251251
LL | const ${concat(_foo, $literal)}: () = ();
252252
| ^^^^^^^
@@ -255,15 +255,15 @@ LL | const ${concat(_foo, $literal)}: () = ();
255255
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
256256

257257
error: metavariables of `${concat(..)}` must be of type `ident`, `literal` or `tt`
258-
--> $DIR/concat-syntax-errors.rs:127:31
258+
--> $DIR/concat-usage-errors.rs:127:31
259259
|
260260
LL | const ${concat(_foo, $tt)}: () = ();
261261
| ^^
262262
|
263263
= note: currently only string literals are supported
264264

265265
error: metavariables of `${concat(..)}` must be of type `ident`, `literal` or `tt`
266-
--> $DIR/concat-syntax-errors.rs:127:31
266+
--> $DIR/concat-usage-errors.rs:127:31
267267
|
268268
LL | const ${concat(_foo, $tt)}: () = ();
269269
| ^^
@@ -272,7 +272,7 @@ LL | const ${concat(_foo, $tt)}: () = ();
272272
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
273273

274274
error: metavariables of `${concat(..)}` must be of type `ident`, `literal` or `tt`
275-
--> $DIR/concat-syntax-errors.rs:127:31
275+
--> $DIR/concat-usage-errors.rs:127:31
276276
|
277277
LL | const ${concat(_foo, $tt)}: () = ();
278278
| ^^

0 commit comments

Comments
 (0)