Skip to content

Commit 525723d

Browse files
Change expected_identifier from error code E0539 to the more specific E0565
1 parent b5d1746 commit 525723d

15 files changed

Lines changed: 72 additions & 69 deletions

compiler/rustc_attr_parsing/src/session_diagnostics.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -849,6 +849,7 @@ impl<'a, G: EmissionGuarantee> Diagnostic<'a, G> for AttributeParseError<'_> {
849849
}
850850
AttributeParseErrorReason::ExpectedIdentifier => {
851851
diag.span_label(self.span, "expected a valid identifier here");
852+
diag.code(E0565);
852853
}
853854
}
854855

tests/ui/attributes/invalid-macro-use.stderr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ LL - #[macro_use = 5]
2828
LL + #[macro_use]
2929
|
3030

31-
error[E0539]: malformed `macro_use` attribute input
31+
error[E0565]: malformed `macro_use` attribute input
3232
--> $DIR/invalid-macro-use.rs:10:1
3333
|
3434
LL | #[macro_use(5)]
@@ -82,7 +82,7 @@ LL - #[macro_use(a(b))]
8282
LL + #[macro_use]
8383
|
8484

85-
error[E0539]: malformed `macro_use` attribute input
85+
error[E0565]: malformed `macro_use` attribute input
8686
--> $DIR/invalid-macro-use.rs:28:1
8787
|
8888
LL | #[macro_use(a::b)]

tests/ui/cfg/cfg-path-error.stderr

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
error[E0539]: malformed `cfg` attribute input
1+
error[E0565]: malformed `cfg` attribute input
22
--> $DIR/cfg-path-error.rs:6:1
33
|
44
LL | #[cfg(any(foo, foo::bar))]
@@ -13,7 +13,7 @@ LL - #[cfg(any(foo, foo::bar))]
1313
LL + #[cfg(predicate)]
1414
|
1515

16-
error[E0539]: malformed `cfg` attribute input
16+
error[E0565]: malformed `cfg` attribute input
1717
--> $DIR/cfg-path-error.rs:12:1
1818
|
1919
LL | #[cfg(any(foo::bar, foo))]
@@ -28,7 +28,7 @@ LL - #[cfg(any(foo::bar, foo))]
2828
LL + #[cfg(predicate)]
2929
|
3030

31-
error[E0539]: malformed `cfg` attribute input
31+
error[E0565]: malformed `cfg` attribute input
3232
--> $DIR/cfg-path-error.rs:18:1
3333
|
3434
LL | #[cfg(all(foo, foo::bar))]
@@ -43,7 +43,7 @@ LL - #[cfg(all(foo, foo::bar))]
4343
LL + #[cfg(predicate)]
4444
|
4545

46-
error[E0539]: malformed `cfg` attribute input
46+
error[E0565]: malformed `cfg` attribute input
4747
--> $DIR/cfg-path-error.rs:24:1
4848
|
4949
LL | #[cfg(all(foo::bar, foo))]
@@ -60,4 +60,4 @@ LL + #[cfg(predicate)]
6060

6161
error: aborting due to 4 previous errors
6262

63-
For more information about this error, try `rustc --explain E0539`.
63+
For more information about this error, try `rustc --explain E0565`.

tests/ui/cfg/cfg-target-compact-errors.stderr

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
error[E0539]: malformed `cfg` attribute input
1+
error[E0565]: malformed `cfg` attribute input
22
--> $DIR/cfg-target-compact-errors.rs:5:1
33
|
44
LL | #[cfg(target(o::o))]
@@ -73,7 +73,7 @@ LL - #[cfg(target(true))]
7373
LL + #[cfg(predicate)]
7474
|
7575

76-
error[E0539]: malformed `cfg` attribute input
76+
error[E0565]: malformed `cfg` attribute input
7777
--> $DIR/cfg-target-compact-errors.rs:32:1
7878
|
7979
LL | #[cfg(target(clippy::os = "linux"))]
@@ -90,4 +90,5 @@ LL + #[cfg(predicate)]
9090

9191
error: aborting due to 6 previous errors
9292

93-
For more information about this error, try `rustc --explain E0539`.
93+
Some errors have detailed explanations: E0539, E0565.
94+
For more information about an error, try `rustc --explain E0539`.

tests/ui/cfg/path-kw-as-cfg-pred.stderr

Lines changed: 33 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ error: `_` cannot be a raw identifier
118118
LL | #[cfg_attr(r#_, cfg(r#_))]
119119
| ^^^
120120

121-
error[E0539]: malformed `cfg` attribute input
121+
error[E0565]: malformed `cfg` attribute input
122122
--> $DIR/path-kw-as-cfg-pred.rs:20:1
123123
|
124124
LL | #[cfg(crate)]
@@ -133,7 +133,7 @@ LL - #[cfg(crate)]
133133
LL + #[cfg(predicate)]
134134
|
135135

136-
error[E0539]: malformed `cfg` attribute input
136+
error[E0565]: malformed `cfg` attribute input
137137
--> $DIR/path-kw-as-cfg-pred.rs:22:1
138138
|
139139
LL | #[cfg(super)]
@@ -148,7 +148,7 @@ LL - #[cfg(super)]
148148
LL + #[cfg(predicate)]
149149
|
150150

151-
error[E0539]: malformed `cfg` attribute input
151+
error[E0565]: malformed `cfg` attribute input
152152
--> $DIR/path-kw-as-cfg-pred.rs:24:1
153153
|
154154
LL | #[cfg(self)]
@@ -163,7 +163,7 @@ LL - #[cfg(self)]
163163
LL + #[cfg(predicate)]
164164
|
165165

166-
error[E0539]: malformed `cfg` attribute input
166+
error[E0565]: malformed `cfg` attribute input
167167
--> $DIR/path-kw-as-cfg-pred.rs:26:1
168168
|
169169
LL | #[cfg(Self)]
@@ -178,7 +178,7 @@ LL - #[cfg(Self)]
178178
LL + #[cfg(predicate)]
179179
|
180180

181-
error[E0539]: malformed `cfg_attr` attribute input
181+
error[E0565]: malformed `cfg_attr` attribute input
182182
--> $DIR/path-kw-as-cfg-pred.rs:28:1
183183
|
184184
LL | #[cfg_attr(crate, path = "foo")]
@@ -193,7 +193,7 @@ LL - #[cfg_attr(crate, path = "foo")]
193193
LL + #[cfg_attr(predicate, attr1, attr2, ...)]
194194
|
195195

196-
error[E0539]: malformed `cfg_attr` attribute input
196+
error[E0565]: malformed `cfg_attr` attribute input
197197
--> $DIR/path-kw-as-cfg-pred.rs:30:1
198198
|
199199
LL | #[cfg_attr(super, path = "foo")]
@@ -208,7 +208,7 @@ LL - #[cfg_attr(super, path = "foo")]
208208
LL + #[cfg_attr(predicate, attr1, attr2, ...)]
209209
|
210210

211-
error[E0539]: malformed `cfg_attr` attribute input
211+
error[E0565]: malformed `cfg_attr` attribute input
212212
--> $DIR/path-kw-as-cfg-pred.rs:32:1
213213
|
214214
LL | #[cfg_attr(self, path = "foo")]
@@ -223,7 +223,7 @@ LL - #[cfg_attr(self, path = "foo")]
223223
LL + #[cfg_attr(predicate, attr1, attr2, ...)]
224224
|
225225

226-
error[E0539]: malformed `cfg_attr` attribute input
226+
error[E0565]: malformed `cfg_attr` attribute input
227227
--> $DIR/path-kw-as-cfg-pred.rs:34:1
228228
|
229229
LL | #[cfg_attr(Self, path = "foo")]
@@ -238,7 +238,7 @@ LL - #[cfg_attr(Self, path = "foo")]
238238
LL + #[cfg_attr(predicate, attr1, attr2, ...)]
239239
|
240240

241-
error[E0539]: malformed `cfg` attribute input
241+
error[E0565]: malformed `cfg` attribute input
242242
--> $DIR/path-kw-as-cfg-pred.rs:36:18
243243
|
244244
LL | #[cfg_attr(true, cfg(crate))]
@@ -253,7 +253,7 @@ LL - #[cfg_attr(true, cfg(crate))]
253253
LL + #[cfg_attr(true, cfg(predicate))]
254254
|
255255

256-
error[E0539]: malformed `cfg` attribute input
256+
error[E0565]: malformed `cfg` attribute input
257257
--> $DIR/path-kw-as-cfg-pred.rs:38:18
258258
|
259259
LL | #[cfg_attr(true, cfg(super))]
@@ -268,7 +268,7 @@ LL - #[cfg_attr(true, cfg(super))]
268268
LL + #[cfg_attr(true, cfg(predicate))]
269269
|
270270

271-
error[E0539]: malformed `cfg` attribute input
271+
error[E0565]: malformed `cfg` attribute input
272272
--> $DIR/path-kw-as-cfg-pred.rs:40:18
273273
|
274274
LL | #[cfg_attr(true, cfg(self))]
@@ -283,7 +283,7 @@ LL - #[cfg_attr(true, cfg(self))]
283283
LL + #[cfg_attr(true, cfg(predicate))]
284284
|
285285

286-
error[E0539]: malformed `cfg` attribute input
286+
error[E0565]: malformed `cfg` attribute input
287287
--> $DIR/path-kw-as-cfg-pred.rs:42:18
288288
|
289289
LL | #[cfg_attr(true, cfg(Self))]
@@ -362,7 +362,7 @@ error: expected identifier, found reserved identifier `_`
362362
LL | #[cfg_attr(true, cfg(_))]
363363
| ^ expected identifier, found reserved identifier
364364

365-
error[E0539]: malformed `cfg` attribute input
365+
error[E0565]: malformed `cfg` attribute input
366366
--> $DIR/path-kw-as-cfg-pred.rs:90:1
367367
|
368368
LL | #[cfg(r#crate)]
@@ -377,7 +377,7 @@ LL - #[cfg(r#crate)]
377377
LL + #[cfg(predicate)]
378378
|
379379

380-
error[E0539]: malformed `cfg` attribute input
380+
error[E0565]: malformed `cfg` attribute input
381381
--> $DIR/path-kw-as-cfg-pred.rs:93:1
382382
|
383383
LL | #[cfg(r#super)]
@@ -392,7 +392,7 @@ LL - #[cfg(r#super)]
392392
LL + #[cfg(predicate)]
393393
|
394394

395-
error[E0539]: malformed `cfg` attribute input
395+
error[E0565]: malformed `cfg` attribute input
396396
--> $DIR/path-kw-as-cfg-pred.rs:96:1
397397
|
398398
LL | #[cfg(r#self)]
@@ -407,7 +407,7 @@ LL - #[cfg(r#self)]
407407
LL + #[cfg(predicate)]
408408
|
409409

410-
error[E0539]: malformed `cfg` attribute input
410+
error[E0565]: malformed `cfg` attribute input
411411
--> $DIR/path-kw-as-cfg-pred.rs:99:1
412412
|
413413
LL | #[cfg(r#Self)]
@@ -422,7 +422,7 @@ LL - #[cfg(r#Self)]
422422
LL + #[cfg(predicate)]
423423
|
424424

425-
error[E0539]: malformed `cfg_attr` attribute input
425+
error[E0565]: malformed `cfg_attr` attribute input
426426
--> $DIR/path-kw-as-cfg-pred.rs:102:1
427427
|
428428
LL | #[cfg_attr(r#crate, cfg(r#crate))]
@@ -437,7 +437,7 @@ LL - #[cfg_attr(r#crate, cfg(r#crate))]
437437
LL + #[cfg_attr(predicate, attr1, attr2, ...)]
438438
|
439439

440-
error[E0539]: malformed `cfg_attr` attribute input
440+
error[E0565]: malformed `cfg_attr` attribute input
441441
--> $DIR/path-kw-as-cfg-pred.rs:106:1
442442
|
443443
LL | #[cfg_attr(r#super, cfg(r#super))]
@@ -452,7 +452,7 @@ LL - #[cfg_attr(r#super, cfg(r#super))]
452452
LL + #[cfg_attr(predicate, attr1, attr2, ...)]
453453
|
454454

455-
error[E0539]: malformed `cfg_attr` attribute input
455+
error[E0565]: malformed `cfg_attr` attribute input
456456
--> $DIR/path-kw-as-cfg-pred.rs:110:1
457457
|
458458
LL | #[cfg_attr(r#self, cfg(r#self))]
@@ -467,7 +467,7 @@ LL - #[cfg_attr(r#self, cfg(r#self))]
467467
LL + #[cfg_attr(predicate, attr1, attr2, ...)]
468468
|
469469

470-
error[E0539]: malformed `cfg_attr` attribute input
470+
error[E0565]: malformed `cfg_attr` attribute input
471471
--> $DIR/path-kw-as-cfg-pred.rs:114:1
472472
|
473473
LL | #[cfg_attr(r#Self, cfg(r#Self))]
@@ -482,7 +482,7 @@ LL - #[cfg_attr(r#Self, cfg(r#Self))]
482482
LL + #[cfg_attr(predicate, attr1, attr2, ...)]
483483
|
484484

485-
error[E0539]: malformed `cfg` attribute input
485+
error[E0565]: malformed `cfg` attribute input
486486
--> $DIR/path-kw-as-cfg-pred.rs:9:9
487487
|
488488
LL | #[cfg($crate)]
@@ -501,7 +501,7 @@ LL - #[cfg($crate)]
501501
LL + #[cfg(predicate)]
502502
|
503503

504-
error[E0539]: malformed `cfg_attr` attribute input
504+
error[E0565]: malformed `cfg_attr` attribute input
505505
--> $DIR/path-kw-as-cfg-pred.rs:11:9
506506
|
507507
LL | #[cfg_attr($crate, path = "foo")]
@@ -520,7 +520,7 @@ LL - #[cfg_attr($crate, path = "foo")]
520520
LL + #[cfg_attr(predicate, attr1, attr2, ...)]
521521
|
522522

523-
error[E0539]: malformed `cfg` attribute input
523+
error[E0565]: malformed `cfg` attribute input
524524
--> $DIR/path-kw-as-cfg-pred.rs:13:26
525525
|
526526
LL | #[cfg_attr(true, cfg($crate))]
@@ -539,7 +539,7 @@ LL - #[cfg_attr(true, cfg($crate))]
539539
LL + #[cfg_attr(true, cfg(predicate))]
540540
|
541541

542-
error[E0539]: malformed `cfg` macro input
542+
error[E0565]: malformed `cfg` macro input
543543
--> $DIR/path-kw-as-cfg-pred.rs:16:9
544544
|
545545
LL | cfg!($crate);
@@ -558,7 +558,7 @@ LL - cfg!($crate);
558558
LL + cfg!(predicate);
559559
|
560560

561-
error[E0539]: malformed `cfg` macro input
561+
error[E0565]: malformed `cfg` macro input
562562
--> $DIR/path-kw-as-cfg-pred.rs:67:5
563563
|
564564
LL | cfg!(crate);
@@ -573,7 +573,7 @@ LL - cfg!(crate);
573573
LL + cfg!(predicate);
574574
|
575575

576-
error[E0539]: malformed `cfg` macro input
576+
error[E0565]: malformed `cfg` macro input
577577
--> $DIR/path-kw-as-cfg-pred.rs:68:5
578578
|
579579
LL | cfg!(super);
@@ -588,7 +588,7 @@ LL - cfg!(super);
588588
LL + cfg!(predicate);
589589
|
590590

591-
error[E0539]: malformed `cfg` macro input
591+
error[E0565]: malformed `cfg` macro input
592592
--> $DIR/path-kw-as-cfg-pred.rs:69:5
593593
|
594594
LL | cfg!(self);
@@ -603,7 +603,7 @@ LL - cfg!(self);
603603
LL + cfg!(predicate);
604604
|
605605

606-
error[E0539]: malformed `cfg` macro input
606+
error[E0565]: malformed `cfg` macro input
607607
--> $DIR/path-kw-as-cfg-pred.rs:70:5
608608
|
609609
LL | cfg!(Self);
@@ -618,7 +618,7 @@ LL - cfg!(Self);
618618
LL + cfg!(predicate);
619619
|
620620

621-
error[E0539]: malformed `cfg` macro input
621+
error[E0565]: malformed `cfg` macro input
622622
--> $DIR/path-kw-as-cfg-pred.rs:72:5
623623
|
624624
LL | cfg!(r#crate);
@@ -633,7 +633,7 @@ LL - cfg!(r#crate);
633633
LL + cfg!(predicate);
634634
|
635635

636-
error[E0539]: malformed `cfg` macro input
636+
error[E0565]: malformed `cfg` macro input
637637
--> $DIR/path-kw-as-cfg-pred.rs:74:5
638638
|
639639
LL | cfg!(r#super);
@@ -648,7 +648,7 @@ LL - cfg!(r#super);
648648
LL + cfg!(predicate);
649649
|
650650

651-
error[E0539]: malformed `cfg` macro input
651+
error[E0565]: malformed `cfg` macro input
652652
--> $DIR/path-kw-as-cfg-pred.rs:76:5
653653
|
654654
LL | cfg!(r#self);
@@ -663,7 +663,7 @@ LL - cfg!(r#self);
663663
LL + cfg!(predicate);
664664
|
665665

666-
error[E0539]: malformed `cfg` macro input
666+
error[E0565]: malformed `cfg` macro input
667667
--> $DIR/path-kw-as-cfg-pred.rs:78:5
668668
|
669669
LL | cfg!(r#Self);
@@ -698,4 +698,4 @@ LL | cfg!(_);
698698

699699
error: aborting due to 64 previous errors
700700

701-
For more information about this error, try `rustc --explain E0539`.
701+
For more information about this error, try `rustc --explain E0565`.

0 commit comments

Comments
 (0)