]> git.lizzy.rs Git - rust.git/blob - src/test/ui-fulldeps/session-diagnostic/diagnostic-derive.rs
Rollup merge of #102072 - scottmcm:ptr-alignment-type, r=thomcc
[rust.git] / src / test / ui-fulldeps / session-diagnostic / diagnostic-derive.rs
1 // check-fail
2 // Tests error conditions for specifying diagnostics using #[derive(Diagnostic)]
3
4 // normalize-stderr-test "the following other types implement trait `IntoDiagnosticArg`:(?:.*\n){0,9}\s+and \d+ others" -> "normalized in stderr"
5 // normalize-stderr-test "diagnostic_builder\.rs:[0-9]+:[0-9]+" -> "diagnostic_builder.rs:LL:CC"
6 // The proc_macro2 crate handles spans differently when on beta/stable release rather than nightly,
7 // changing the output of this test. Since Diagnostic is strictly internal to the compiler
8 // the test is just ignored on stable and beta:
9 // ignore-beta
10 // ignore-stable
11
12 #![feature(rustc_private)]
13 #![crate_type = "lib"]
14
15 extern crate rustc_span;
16 use rustc_span::symbol::Ident;
17 use rustc_span::Span;
18
19 extern crate rustc_macros;
20 use rustc_macros::{Diagnostic, LintDiagnostic, Subdiagnostic};
21
22 extern crate rustc_middle;
23 use rustc_middle::ty::Ty;
24
25 extern crate rustc_errors;
26 use rustc_errors::{Applicability, MultiSpan};
27
28 extern crate rustc_session;
29
30 #[derive(Diagnostic)]
31 #[diag(compiletest::example, code = "E0123")]
32 struct Hello {}
33
34 #[derive(Diagnostic)]
35 #[diag(compiletest::example, code = "E0123")]
36 struct HelloWarn {}
37
38 #[derive(Diagnostic)]
39 #[diag(compiletest::example, code = "E0123")]
40 //~^ ERROR unsupported type attribute for diagnostic derive enum
41 enum DiagnosticOnEnum {
42     Foo,
43 //~^ ERROR diagnostic slug not specified
44     Bar,
45 //~^ ERROR diagnostic slug not specified
46 }
47
48 #[derive(Diagnostic)]
49 #[diag(compiletest::example, code = "E0123")]
50 #[diag = "E0123"]
51 //~^ ERROR `#[diag = ...]` is not a valid attribute
52 struct WrongStructAttrStyle {}
53
54 #[derive(Diagnostic)]
55 #[nonsense(compiletest::example, code = "E0123")]
56 //~^ ERROR `#[nonsense(...)]` is not a valid attribute
57 //~^^ ERROR diagnostic slug not specified
58 //~^^^ ERROR cannot find attribute `nonsense` in this scope
59 struct InvalidStructAttr {}
60
61 #[derive(Diagnostic)]
62 #[diag("E0123")]
63 //~^ ERROR `#[diag("...")]` is not a valid attribute
64 //~^^ ERROR diagnostic slug not specified
65 struct InvalidLitNestedAttr {}
66
67 #[derive(Diagnostic)]
68 #[diag(nonsense, code = "E0123")]
69 //~^ ERROR cannot find value `nonsense` in module `rustc_errors::fluent`
70 struct InvalidNestedStructAttr {}
71
72 #[derive(Diagnostic)]
73 #[diag(nonsense("foo"), code = "E0123", slug = "foo")]
74 //~^ ERROR `#[diag(nonsense(...))]` is not a valid attribute
75 //~^^ ERROR diagnostic slug not specified
76 struct InvalidNestedStructAttr1 {}
77
78 #[derive(Diagnostic)]
79 #[diag(nonsense = "...", code = "E0123", slug = "foo")]
80 //~^ ERROR `#[diag(nonsense = ...)]` is not a valid attribute
81 //~| ERROR `#[diag(slug = ...)]` is not a valid attribute
82 //~| ERROR diagnostic slug not specified
83 struct InvalidNestedStructAttr2 {}
84
85 #[derive(Diagnostic)]
86 #[diag(nonsense = 4, code = "E0123", slug = "foo")]
87 //~^ ERROR `#[diag(nonsense = ...)]` is not a valid attribute
88 //~| ERROR `#[diag(slug = ...)]` is not a valid attribute
89 //~| ERROR diagnostic slug not specified
90 struct InvalidNestedStructAttr3 {}
91
92 #[derive(Diagnostic)]
93 #[diag(compiletest::example, code = "E0123", slug = "foo")]
94 //~^ ERROR `#[diag(slug = ...)]` is not a valid attribute
95 struct InvalidNestedStructAttr4 {}
96
97 #[derive(Diagnostic)]
98 #[diag(compiletest::example, code = "E0123")]
99 struct WrongPlaceField {
100     #[suggestion = "bar"]
101     //~^ ERROR `#[suggestion = ...]` is not a valid attribute
102     sp: Span,
103 }
104
105 #[derive(Diagnostic)]
106 #[diag(compiletest::example, code = "E0123")]
107 #[diag(compiletest::example, code = "E0456")]
108 //~^ ERROR specified multiple times
109 //~^^ ERROR specified multiple times
110 struct DiagSpecifiedTwice {}
111
112 #[derive(Diagnostic)]
113 #[diag(compiletest::example, code = "E0456", code = "E0457")]
114 //~^ ERROR specified multiple times
115 struct CodeSpecifiedTwice {}
116
117 #[derive(Diagnostic)]
118 #[diag(compiletest::example, compiletest::example, code = "E0456")]
119 //~^ ERROR `#[diag(compiletest::example)]` is not a valid attribute
120 struct SlugSpecifiedTwice {}
121
122 #[derive(Diagnostic)]
123 struct KindNotProvided {} //~ ERROR diagnostic slug not specified
124
125 #[derive(Diagnostic)]
126 #[diag(code = "E0456")]
127 //~^ ERROR diagnostic slug not specified
128 struct SlugNotProvided {}
129
130 #[derive(Diagnostic)]
131 #[diag(compiletest::example)]
132 struct CodeNotProvided {}
133
134 #[derive(Diagnostic)]
135 #[diag(compiletest::example, code = "E0123")]
136 struct MessageWrongType {
137     #[primary_span]
138     //~^ ERROR `#[primary_span]` attribute can only be applied to fields of type `Span` or `MultiSpan`
139     foo: String,
140 }
141
142 #[derive(Diagnostic)]
143 #[diag(compiletest::example, code = "E0123")]
144 struct InvalidPathFieldAttr {
145     #[nonsense]
146     //~^ ERROR `#[nonsense]` is not a valid attribute
147     //~^^ ERROR cannot find attribute `nonsense` in this scope
148     foo: String,
149 }
150
151 #[derive(Diagnostic)]
152 #[diag(compiletest::example, code = "E0123")]
153 struct ErrorWithField {
154     name: String,
155     #[label(compiletest::label)]
156     span: Span,
157 }
158
159 #[derive(Diagnostic)]
160 #[diag(compiletest::example, code = "E0123")]
161 struct ErrorWithMessageAppliedToField {
162     #[label(compiletest::label)]
163     //~^ ERROR the `#[label(...)]` attribute can only be applied to fields of type `Span` or `MultiSpan`
164     name: String,
165 }
166
167 #[derive(Diagnostic)]
168 #[diag(compiletest::example, code = "E0123")]
169 struct ErrorWithNonexistentField {
170     #[suggestion(compiletest::suggestion, code = "{name}")]
171     //~^ ERROR `name` doesn't refer to a field on this type
172     suggestion: (Span, Applicability),
173 }
174
175 #[derive(Diagnostic)]
176 //~^ ERROR invalid format string: expected `'}'`
177 #[diag(compiletest::example, code = "E0123")]
178 struct ErrorMissingClosingBrace {
179     #[suggestion(compiletest::suggestion, code = "{name")]
180     suggestion: (Span, Applicability),
181     name: String,
182     val: usize,
183 }
184
185 #[derive(Diagnostic)]
186 //~^ ERROR invalid format string: unmatched `}`
187 #[diag(compiletest::example, code = "E0123")]
188 struct ErrorMissingOpeningBrace {
189     #[suggestion(compiletest::suggestion, code = "name}")]
190     suggestion: (Span, Applicability),
191     name: String,
192     val: usize,
193 }
194
195 #[derive(Diagnostic)]
196 #[diag(compiletest::example, code = "E0123")]
197 struct LabelOnSpan {
198     #[label(compiletest::label)]
199     sp: Span,
200 }
201
202 #[derive(Diagnostic)]
203 #[diag(compiletest::example, code = "E0123")]
204 struct LabelOnNonSpan {
205     #[label(compiletest::label)]
206     //~^ ERROR the `#[label(...)]` attribute can only be applied to fields of type `Span` or `MultiSpan`
207     id: u32,
208 }
209
210 #[derive(Diagnostic)]
211 #[diag(compiletest::example, code = "E0123")]
212 struct Suggest {
213     #[suggestion(compiletest::suggestion, code = "This is the suggested code")]
214     #[suggestion_short(compiletest::suggestion, code = "This is the suggested code")]
215     #[suggestion_hidden(compiletest::suggestion, code = "This is the suggested code")]
216     #[suggestion_verbose(compiletest::suggestion, code = "This is the suggested code")]
217     suggestion: (Span, Applicability),
218 }
219
220 #[derive(Diagnostic)]
221 #[diag(compiletest::example, code = "E0123")]
222 struct SuggestWithoutCode {
223     #[suggestion(compiletest::suggestion)]
224     //~^ ERROR suggestion without `code = "..."`
225     suggestion: (Span, Applicability),
226 }
227
228 #[derive(Diagnostic)]
229 #[diag(compiletest::example, code = "E0123")]
230 struct SuggestWithBadKey {
231     #[suggestion(nonsense = "bar")]
232     //~^ ERROR `#[suggestion(nonsense = ...)]` is not a valid attribute
233     //~| ERROR suggestion without `code = "..."`
234     suggestion: (Span, Applicability),
235 }
236
237 #[derive(Diagnostic)]
238 #[diag(compiletest::example, code = "E0123")]
239 struct SuggestWithShorthandMsg {
240     #[suggestion(msg = "bar")]
241     //~^ ERROR `#[suggestion(msg = ...)]` is not a valid attribute
242     //~| ERROR suggestion without `code = "..."`
243     suggestion: (Span, Applicability),
244 }
245
246 #[derive(Diagnostic)]
247 #[diag(compiletest::example, code = "E0123")]
248 struct SuggestWithoutMsg {
249     #[suggestion(code = "bar")]
250     suggestion: (Span, Applicability),
251 }
252
253 #[derive(Diagnostic)]
254 #[diag(compiletest::example, code = "E0123")]
255 struct SuggestWithTypesSwapped {
256     #[suggestion(compiletest::suggestion, code = "This is suggested code")]
257     suggestion: (Applicability, Span),
258 }
259
260 #[derive(Diagnostic)]
261 #[diag(compiletest::example, code = "E0123")]
262 struct SuggestWithWrongTypeApplicabilityOnly {
263     #[suggestion(compiletest::suggestion, code = "This is suggested code")]
264     //~^ ERROR wrong field type for suggestion
265     suggestion: Applicability,
266 }
267
268 #[derive(Diagnostic)]
269 #[diag(compiletest::example, code = "E0123")]
270 struct SuggestWithSpanOnly {
271     #[suggestion(compiletest::suggestion, code = "This is suggested code")]
272     suggestion: Span,
273 }
274
275 #[derive(Diagnostic)]
276 #[diag(compiletest::example, code = "E0123")]
277 struct SuggestWithDuplicateSpanAndApplicability {
278     #[suggestion(compiletest::suggestion, code = "This is suggested code")]
279     suggestion: (Span, Span, Applicability),
280     //~^ ERROR specified multiple times
281 }
282
283 #[derive(Diagnostic)]
284 #[diag(compiletest::example, code = "E0123")]
285 struct SuggestWithDuplicateApplicabilityAndSpan {
286     #[suggestion(compiletest::suggestion, code = "This is suggested code")]
287     suggestion: (Applicability, Applicability, Span),
288     //~^ ERROR specified multiple times
289 }
290
291 #[derive(Diagnostic)]
292 #[diag(compiletest::example, code = "E0123")]
293 struct WrongKindOfAnnotation {
294     #[label = "bar"]
295     //~^ ERROR `#[label = ...]` is not a valid attribute
296     z: Span,
297 }
298
299 #[derive(Diagnostic)]
300 #[diag(compiletest::example, code = "E0123")]
301 struct OptionsInErrors {
302     #[label(compiletest::label)]
303     label: Option<Span>,
304     #[suggestion(compiletest::suggestion, code = "...")]
305     opt_sugg: Option<(Span, Applicability)>,
306 }
307
308 #[derive(Diagnostic)]
309 #[diag(compiletest::example, code = "E0456")]
310 struct MoveOutOfBorrowError<'tcx> {
311     name: Ident,
312     ty: Ty<'tcx>,
313     #[primary_span]
314     #[label(compiletest::label)]
315     span: Span,
316     #[label(compiletest::label)]
317     other_span: Span,
318     #[suggestion(compiletest::suggestion, code = "{name}.clone()")]
319     opt_sugg: Option<(Span, Applicability)>,
320 }
321
322 #[derive(Diagnostic)]
323 #[diag(compiletest::example, code = "E0123")]
324 struct ErrorWithLifetime<'a> {
325     #[label(compiletest::label)]
326     span: Span,
327     name: &'a str,
328 }
329
330 #[derive(Diagnostic)]
331 #[diag(compiletest::example, code = "E0123")]
332 struct ErrorWithDefaultLabelAttr<'a> {
333     #[label]
334     span: Span,
335     name: &'a str,
336 }
337
338 #[derive(Diagnostic)]
339 //~^ ERROR the trait bound `Hello: IntoDiagnosticArg` is not satisfied
340 #[diag(compiletest::example, code = "E0123")]
341 struct ArgFieldWithoutSkip {
342     #[primary_span]
343     span: Span,
344     other: Hello,
345 }
346
347 #[derive(Diagnostic)]
348 #[diag(compiletest::example, code = "E0123")]
349 struct ArgFieldWithSkip {
350     #[primary_span]
351     span: Span,
352     // `Hello` does not implement `IntoDiagnosticArg` so this would result in an error if
353     // not for `#[skip_arg]`.
354     #[skip_arg]
355     other: Hello,
356 }
357
358 #[derive(Diagnostic)]
359 #[diag(compiletest::example, code = "E0123")]
360 struct ErrorWithSpannedNote {
361     #[note]
362     span: Span,
363 }
364
365 #[derive(Diagnostic)]
366 #[diag(compiletest::example, code = "E0123")]
367 struct ErrorWithSpannedNoteCustom {
368     #[note(compiletest::note)]
369     span: Span,
370 }
371
372 #[derive(Diagnostic)]
373 #[diag(compiletest::example, code = "E0123")]
374 #[note]
375 struct ErrorWithNote {
376     val: String,
377 }
378
379 #[derive(Diagnostic)]
380 #[diag(compiletest::example, code = "E0123")]
381 #[note(compiletest::note)]
382 struct ErrorWithNoteCustom {
383     val: String,
384 }
385
386 #[derive(Diagnostic)]
387 #[diag(compiletest::example, code = "E0123")]
388 struct ErrorWithSpannedHelp {
389     #[help]
390     span: Span,
391 }
392
393 #[derive(Diagnostic)]
394 #[diag(compiletest::example, code = "E0123")]
395 struct ErrorWithSpannedHelpCustom {
396     #[help(compiletest::help)]
397     span: Span,
398 }
399
400 #[derive(Diagnostic)]
401 #[diag(compiletest::example, code = "E0123")]
402 #[help]
403 struct ErrorWithHelp {
404     val: String,
405 }
406
407 #[derive(Diagnostic)]
408 #[diag(compiletest::example, code = "E0123")]
409 #[help(compiletest::help)]
410 struct ErrorWithHelpCustom {
411     val: String,
412 }
413
414 #[derive(Diagnostic)]
415 #[help]
416 #[diag(compiletest::example, code = "E0123")]
417 struct ErrorWithHelpWrongOrder {
418     val: String,
419 }
420
421 #[derive(Diagnostic)]
422 #[help(compiletest::help)]
423 #[diag(compiletest::example, code = "E0123")]
424 struct ErrorWithHelpCustomWrongOrder {
425     val: String,
426 }
427
428 #[derive(Diagnostic)]
429 #[note]
430 #[diag(compiletest::example, code = "E0123")]
431 struct ErrorWithNoteWrongOrder {
432     val: String,
433 }
434
435 #[derive(Diagnostic)]
436 #[note(compiletest::note)]
437 #[diag(compiletest::example, code = "E0123")]
438 struct ErrorWithNoteCustomWrongOrder {
439     val: String,
440 }
441
442 #[derive(Diagnostic)]
443 #[diag(compiletest::example, code = "E0123")]
444 struct ApplicabilityInBoth {
445     #[suggestion(compiletest::suggestion, code = "...", applicability = "maybe-incorrect")]
446     //~^ ERROR specified multiple times
447     suggestion: (Span, Applicability),
448 }
449
450 #[derive(Diagnostic)]
451 #[diag(compiletest::example, code = "E0123")]
452 struct InvalidApplicability {
453     #[suggestion(compiletest::suggestion, code = "...", applicability = "batman")]
454     //~^ ERROR invalid applicability
455     suggestion: Span,
456 }
457
458 #[derive(Diagnostic)]
459 #[diag(compiletest::example, code = "E0123")]
460 struct ValidApplicability {
461     #[suggestion(compiletest::suggestion, code = "...", applicability = "maybe-incorrect")]
462     suggestion: Span,
463 }
464
465 #[derive(Diagnostic)]
466 #[diag(compiletest::example, code = "E0123")]
467 struct NoApplicability {
468     #[suggestion(compiletest::suggestion, code = "...")]
469     suggestion: Span,
470 }
471
472 #[derive(Subdiagnostic)]
473 #[note(parser::add_paren)]
474 struct Note;
475
476 #[derive(Diagnostic)]
477 #[diag(compiletest::example)]
478 struct Subdiagnostic {
479     #[subdiagnostic]
480     note: Note,
481 }
482
483 #[derive(Diagnostic)]
484 #[diag(compiletest::example, code = "E0123")]
485 struct VecField {
486     #[primary_span]
487     #[label]
488     spans: Vec<Span>,
489 }
490
491 #[derive(Diagnostic)]
492 #[diag(compiletest::example, code = "E0123")]
493 struct UnitField {
494     #[primary_span]
495     spans: Span,
496     #[help]
497     foo: (),
498     #[help(compiletest::help)]
499     bar: (),
500 }
501
502 #[derive(Diagnostic)]
503 #[diag(compiletest::example, code = "E0123")]
504 struct OptUnitField {
505     #[primary_span]
506     spans: Span,
507     #[help]
508     foo: Option<()>,
509     #[help(compiletest::help)]
510     bar: Option<()>,
511 }
512
513 #[derive(Diagnostic)]
514 #[diag(compiletest::example, code = "E0123")]
515 struct LabelWithTrailingPath {
516     #[label(compiletest::label, foo)]
517     //~^ ERROR `#[label(foo)]` is not a valid attribute
518     span: Span,
519 }
520
521 #[derive(Diagnostic)]
522 #[diag(compiletest::example, code = "E0123")]
523 struct LabelWithTrailingNameValue {
524     #[label(compiletest::label, foo = "...")]
525     //~^ ERROR `#[label(foo = ...)]` is not a valid attribute
526     span: Span,
527 }
528
529 #[derive(Diagnostic)]
530 #[diag(compiletest::example, code = "E0123")]
531 struct LabelWithTrailingList {
532     #[label(compiletest::label, foo("..."))]
533     //~^ ERROR `#[label(foo(...))]` is not a valid attribute
534     span: Span,
535 }
536
537 #[derive(LintDiagnostic)]
538 #[diag(compiletest::example)]
539 struct LintsGood {
540 }
541
542 #[derive(LintDiagnostic)]
543 #[diag(compiletest::example)]
544 struct PrimarySpanOnLint {
545     #[primary_span]
546     //~^ ERROR `#[primary_span]` is not a valid attribute
547     span: Span,
548 }
549
550 #[derive(Diagnostic)]
551 #[diag(compiletest::example, code = "E0123")]
552 struct ErrorWithMultiSpan {
553     #[primary_span]
554     span: MultiSpan,
555 }
556
557 #[derive(Diagnostic)]
558 #[diag(compiletest::example, code = "E0123")]
559 #[warning]
560 struct ErrorWithWarn {
561     val: String,
562 }
563
564 #[derive(Diagnostic)]
565 #[error(compiletest::example, code = "E0123")]
566 //~^ ERROR `#[error(...)]` is not a valid attribute
567 //~| ERROR diagnostic slug not specified
568 //~| ERROR cannot find attribute `error` in this scope
569 struct ErrorAttribute {}
570
571 #[derive(Diagnostic)]
572 #[warn_(compiletest::example, code = "E0123")]
573 //~^ ERROR `#[warn_(...)]` is not a valid attribute
574 //~| ERROR diagnostic slug not specified
575 //~| ERROR cannot find attribute `warn_` in this scope
576 struct WarnAttribute {}
577
578 #[derive(Diagnostic)]
579 #[lint(compiletest::example, code = "E0123")]
580 //~^ ERROR `#[lint(...)]` is not a valid attribute
581 //~| ERROR diagnostic slug not specified
582 //~| ERROR cannot find attribute `lint` in this scope
583 struct LintAttributeOnSessionDiag {}
584
585 #[derive(LintDiagnostic)]
586 #[lint(compiletest::example, code = "E0123")]
587 //~^ ERROR `#[lint(...)]` is not a valid attribute
588 //~| ERROR `#[lint(...)]` is not a valid attribute
589 //~| ERROR diagnostic slug not specified
590 //~| ERROR cannot find attribute `lint` in this scope
591 struct LintAttributeOnLintDiag {}
592
593 #[derive(Diagnostic)]
594 #[diag(compiletest::example, code = "E0123")]
595 struct DuplicatedSuggestionCode {
596     #[suggestion(compiletest::suggestion, code = "...", code = ",,,")]
597     //~^ ERROR specified multiple times
598     suggestion: Span,
599 }
600
601 #[derive(Diagnostic)]
602 #[diag(compiletest::example, code = "E0123")]
603 struct InvalidTypeInSuggestionTuple {
604     #[suggestion(compiletest::suggestion, code = "...")]
605     suggestion: (Span, usize),
606     //~^ ERROR wrong types for suggestion
607 }
608
609 #[derive(Diagnostic)]
610 #[diag(compiletest::example, code = "E0123")]
611 struct MissingApplicabilityInSuggestionTuple {
612     #[suggestion(compiletest::suggestion, code = "...")]
613     suggestion: (Span,),
614     //~^ ERROR wrong types for suggestion
615 }
616
617 #[derive(Diagnostic)]
618 #[diag(compiletest::example, code = "E0123")]
619 struct MissingCodeInSuggestion {
620     #[suggestion(compiletest::suggestion)]
621     //~^ ERROR suggestion without `code = "..."`
622     suggestion: Span,
623 }
624
625 #[derive(Diagnostic)]
626 #[diag(compiletest::example, code = "E0123")]
627 #[multipart_suggestion(compiletest::suggestion)]
628 //~^ ERROR `#[multipart_suggestion(...)]` is not a valid attribute
629 //~| ERROR cannot find attribute `multipart_suggestion` in this scope
630 #[multipart_suggestion()]
631 //~^ ERROR `#[multipart_suggestion(...)]` is not a valid attribute
632 //~| ERROR cannot find attribute `multipart_suggestion` in this scope
633 struct MultipartSuggestion {
634     #[multipart_suggestion(compiletest::suggestion)]
635     //~^ ERROR `#[multipart_suggestion(...)]` is not a valid attribute
636     //~| ERROR cannot find attribute `multipart_suggestion` in this scope
637     suggestion: Span,
638 }
639
640 #[derive(Diagnostic)]
641 #[diag(compiletest::example, code = "E0123")]
642 #[suggestion(compiletest::suggestion, code = "...")]
643 //~^ ERROR `#[suggestion(...)]` is not a valid attribute
644 struct SuggestionOnStruct {
645     #[primary_span]
646     suggestion: Span,
647 }
648
649 #[derive(Diagnostic)]
650 #[diag(compiletest::example, code = "E0123")]
651 #[label]
652 //~^ ERROR `#[label]` is not a valid attribute
653 struct LabelOnStruct {
654     #[primary_span]
655     suggestion: Span,
656 }
657
658 #[derive(Diagnostic)]
659 enum ExampleEnum {
660     #[diag(compiletest::example)]
661     Foo {
662         #[primary_span]
663         sp: Span,
664         #[note]
665         note_sp: Span,
666     },
667     #[diag(compiletest::example)]
668     Bar {
669         #[primary_span]
670         sp: Span,
671     },
672     #[diag(compiletest::example)]
673     Baz,
674 }
675
676 #[derive(Diagnostic)]
677 #[diag(compiletest::example, code = "E0123")]
678 struct RawIdentDiagnosticArg {
679     pub r#type: String,
680 }