1use rustc_abi::ExternAbi;
4use rustc_ast::ParamKindOrd;
5use rustc_errors::codes::*;
6use rustc_errors::{Applicability, Diag, EmissionGuarantee, Subdiagnostic};
7use rustc_macros::{Diagnostic, LintDiagnostic, Subdiagnostic};
8use rustc_span::{Ident, Span, Symbol};
9
10use crate::fluent_generated as fluent;
11
12#[derive(Diagnostic)]
13#[diag(ast_passes_visibility_not_permitted, code = E0449)]
14pub(crate) struct VisibilityNotPermitted {
15 #[primary_span]
16 pub span: Span,
17 #[subdiagnostic]
18 pub note: VisibilityNotPermittedNote,
19 #[suggestion(
20 ast_passes_remove_qualifier_sugg,
21 code = "",
22 applicability = "machine-applicable"
23 )]
24 pub remove_qualifier_sugg: Span,
25}
26
27#[derive(Subdiagnostic)]
28pub(crate) enum VisibilityNotPermittedNote {
29 #[note(ast_passes_enum_variant)]
30 EnumVariant,
31 #[note(ast_passes_trait_impl)]
32 TraitImpl,
33 #[note(ast_passes_individual_impl_items)]
34 IndividualImplItems,
35 #[note(ast_passes_individual_foreign_items)]
36 IndividualForeignItems,
37}
38#[derive(Diagnostic)]
39#[diag(ast_passes_impl_fn_const)]
40pub(crate) struct ImplFnConst {
41 #[primary_span]
42 #[suggestion(ast_passes_label, code = "", applicability = "machine-applicable")]
43 pub span: Span,
44 #[label(ast_passes_parent_constness)]
45 pub parent_constness: Span,
46}
47
48#[derive(Diagnostic)]
49#[diag(ast_passes_trait_fn_const, code = E0379)]
50pub(crate) struct TraitFnConst {
51 #[primary_span]
52 #[label]
53 pub span: Span,
54 pub in_impl: bool,
55 #[label(ast_passes_const_context_label)]
56 pub const_context_label: Option<Span>,
57 #[suggestion(ast_passes_remove_const_sugg, code = "")]
58 pub remove_const_sugg: (Span, Applicability),
59 pub requires_multiple_changes: bool,
60 #[suggestion(
61 ast_passes_make_impl_const_sugg,
62 code = "const ",
63 applicability = "maybe-incorrect"
64 )]
65 pub make_impl_const_sugg: Option<Span>,
66 #[suggestion(
67 ast_passes_make_trait_const_sugg,
68 code = "const ",
69 applicability = "maybe-incorrect"
70 )]
71 pub make_trait_const_sugg: Option<Span>,
72}
73
74#[derive(Diagnostic)]
75#[diag(ast_passes_async_fn_in_const_trait_or_trait_impl)]
76pub(crate) struct AsyncFnInConstTraitOrTraitImpl {
77 #[primary_span]
78 pub async_keyword: Span,
79 pub context: &'static str,
80 #[label]
81 pub const_keyword: Span,
82}
83
84#[derive(Diagnostic)]
85#[diag(ast_passes_forbidden_bound)]
86pub(crate) struct ForbiddenBound {
87 #[primary_span]
88 pub spans: Vec<Span>,
89}
90
91#[derive(Diagnostic)]
92#[diag(ast_passes_forbidden_const_param)]
93pub(crate) struct ForbiddenConstParam {
94 #[primary_span]
95 pub const_param_spans: Vec<Span>,
96}
97
98#[derive(Diagnostic)]
99#[diag(ast_passes_fn_param_too_many)]
100pub(crate) struct FnParamTooMany {
101 #[primary_span]
102 pub span: Span,
103 pub max_num_args: usize,
104}
105
106#[derive(Diagnostic)]
107#[diag(ast_passes_fn_param_c_var_args_not_last)]
108pub(crate) struct FnParamCVarArgsNotLast {
109 #[primary_span]
110 pub span: Span,
111}
112
113#[derive(Diagnostic)]
114#[diag(ast_passes_fn_param_doc_comment)]
115pub(crate) struct FnParamDocComment {
116 #[primary_span]
117 #[label]
118 pub span: Span,
119}
120
121#[derive(Diagnostic)]
122#[diag(ast_passes_fn_param_forbidden_attr)]
123pub(crate) struct FnParamForbiddenAttr {
124 #[primary_span]
125 pub span: Span,
126}
127
128#[derive(Diagnostic)]
129#[diag(ast_passes_fn_param_forbidden_self)]
130#[note]
131pub(crate) struct FnParamForbiddenSelf {
132 #[primary_span]
133 #[label]
134 pub span: Span,
135}
136
137#[derive(Diagnostic)]
138#[diag(ast_passes_forbidden_default)]
139pub(crate) struct ForbiddenDefault {
140 #[primary_span]
141 pub span: Span,
142 #[label]
143 pub def_span: Span,
144}
145
146#[derive(Diagnostic)]
147#[diag(ast_passes_assoc_const_without_body)]
148pub(crate) struct AssocConstWithoutBody {
149 #[primary_span]
150 pub span: Span,
151 #[suggestion(code = " = <expr>;", applicability = "has-placeholders")]
152 pub replace_span: Span,
153}
154
155#[derive(Diagnostic)]
156#[diag(ast_passes_assoc_fn_without_body)]
157pub(crate) struct AssocFnWithoutBody {
158 #[primary_span]
159 pub span: Span,
160 #[suggestion(code = " {{ <body> }}", applicability = "has-placeholders")]
161 pub replace_span: Span,
162}
163
164#[derive(Diagnostic)]
165#[diag(ast_passes_assoc_type_without_body)]
166pub(crate) struct AssocTypeWithoutBody {
167 #[primary_span]
168 pub span: Span,
169 #[suggestion(code = " = <type>;", applicability = "has-placeholders")]
170 pub replace_span: Span,
171}
172
173#[derive(Diagnostic)]
174#[diag(ast_passes_const_without_body)]
175pub(crate) struct ConstWithoutBody {
176 #[primary_span]
177 pub span: Span,
178 #[suggestion(code = " = <expr>;", applicability = "has-placeholders")]
179 pub replace_span: Span,
180}
181
182#[derive(Diagnostic)]
183#[diag(ast_passes_static_without_body)]
184pub(crate) struct StaticWithoutBody {
185 #[primary_span]
186 pub span: Span,
187 #[suggestion(code = " = <expr>;", applicability = "has-placeholders")]
188 pub replace_span: Span,
189}
190
191#[derive(Diagnostic)]
192#[diag(ast_passes_ty_alias_without_body)]
193pub(crate) struct TyAliasWithoutBody {
194 #[primary_span]
195 pub span: Span,
196 #[suggestion(code = " = <type>;", applicability = "has-placeholders")]
197 pub replace_span: Span,
198}
199
200#[derive(Diagnostic)]
201#[diag(ast_passes_fn_without_body)]
202pub(crate) struct FnWithoutBody {
203 #[primary_span]
204 pub span: Span,
205 #[suggestion(code = " {{ <body> }}", applicability = "has-placeholders")]
206 pub replace_span: Span,
207 #[subdiagnostic]
208 pub extern_block_suggestion: Option<ExternBlockSuggestion>,
209}
210
211#[derive(Subdiagnostic)]
212pub(crate) enum ExternBlockSuggestion {
213 #[multipart_suggestion(ast_passes_extern_block_suggestion, applicability = "maybe-incorrect")]
214 Implicit {
215 #[suggestion_part(code = "extern {{")]
216 start_span: Span,
217 #[suggestion_part(code = " }}")]
218 end_span: Span,
219 },
220 #[multipart_suggestion(ast_passes_extern_block_suggestion, applicability = "maybe-incorrect")]
221 Explicit {
222 #[suggestion_part(code = "extern \"{abi}\" {{")]
223 start_span: Span,
224 #[suggestion_part(code = " }}")]
225 end_span: Span,
226 abi: Symbol,
227 },
228}
229
230#[derive(Diagnostic)]
231#[diag(ast_passes_extern_invalid_safety)]
232pub(crate) struct InvalidSafetyOnExtern {
233 #[primary_span]
234 pub item_span: Span,
235 #[suggestion(code = "unsafe ", applicability = "machine-applicable", style = "verbose")]
236 pub block: Option<Span>,
237}
238
239#[derive(Diagnostic)]
240#[diag(ast_passes_item_invalid_safety)]
241pub(crate) struct InvalidSafetyOnItem {
242 #[primary_span]
243 pub span: Span,
244}
245
246#[derive(Diagnostic)]
247#[diag(ast_passes_fn_ptr_invalid_safety)]
248pub(crate) struct InvalidSafetyOnFnPtr {
249 #[primary_span]
250 pub span: Span,
251}
252
253#[derive(Diagnostic)]
254#[diag(ast_passes_unsafe_static)]
255pub(crate) struct UnsafeStatic {
256 #[primary_span]
257 pub span: Span,
258}
259
260#[derive(Diagnostic)]
261#[diag(ast_passes_bound_in_context)]
262pub(crate) struct BoundInContext<'a> {
263 #[primary_span]
264 pub span: Span,
265 pub ctx: &'a str,
266}
267
268#[derive(Diagnostic)]
269#[diag(ast_passes_extern_types_cannot)]
270#[note(ast_passes_extern_keyword_link)]
271pub(crate) struct ExternTypesCannotHave<'a> {
272 #[primary_span]
273 #[suggestion(code = "", applicability = "maybe-incorrect")]
274 pub span: Span,
275 pub descr: &'a str,
276 pub remove_descr: &'a str,
277 #[label]
278 pub block_span: Span,
279}
280
281#[derive(Diagnostic)]
282#[diag(ast_passes_body_in_extern)]
283#[note(ast_passes_extern_keyword_link)]
284pub(crate) struct BodyInExtern<'a> {
285 #[primary_span]
286 #[label(ast_passes_cannot_have)]
287 pub span: Span,
288 #[label(ast_passes_invalid)]
289 pub body: Span,
290 #[label(ast_passes_existing)]
291 pub block: Span,
292 pub kind: &'a str,
293}
294
295#[derive(Diagnostic)]
296#[diag(ast_passes_fn_body_extern)]
297#[help]
298#[note(ast_passes_extern_keyword_link)]
299pub(crate) struct FnBodyInExtern {
300 #[primary_span]
301 #[label(ast_passes_cannot_have)]
302 pub span: Span,
303 #[suggestion(code = ";", applicability = "maybe-incorrect")]
304 pub body: Span,
305 #[label]
306 pub block: Span,
307}
308
309#[derive(Diagnostic)]
310#[diag(ast_passes_extern_fn_qualifiers)]
311pub(crate) struct FnQualifierInExtern {
312 #[primary_span]
313 #[suggestion(code = "", applicability = "maybe-incorrect")]
314 pub span: Span,
315 #[label]
316 pub block: Span,
317 pub kw: &'static str,
318}
319
320#[derive(Diagnostic)]
321#[diag(ast_passes_extern_item_ascii)]
322#[note]
323pub(crate) struct ExternItemAscii {
324 #[primary_span]
325 pub span: Span,
326 #[label]
327 pub block: Span,
328}
329
330#[derive(Diagnostic)]
331#[diag(ast_passes_c_variadic_no_extern)]
332#[help]
333pub(crate) struct CVariadicNoExtern {
334 #[primary_span]
335 pub span: Span,
336}
337
338#[derive(Diagnostic)]
339#[diag(ast_passes_c_variadic_must_be_unsafe)]
340pub(crate) struct CVariadicMustBeUnsafe {
341 #[primary_span]
342 pub span: Span,
343
344 #[suggestion(
345 ast_passes_suggestion,
346 applicability = "maybe-incorrect",
347 code = "unsafe ",
348 style = "verbose"
349 )]
350 pub unsafe_span: Span,
351}
352
353#[derive(Diagnostic)]
354#[diag(ast_passes_c_variadic_bad_extern)]
355#[help]
356pub(crate) struct CVariadicBadExtern {
357 #[primary_span]
358 pub span: Span,
359 pub abi: &'static str,
360 #[label]
361 pub extern_span: Span,
362}
363
364#[derive(Diagnostic)]
365#[diag(ast_passes_c_variadic_bad_naked_extern)]
366#[help]
367pub(crate) struct CVariadicBadNakedExtern {
368 #[primary_span]
369 pub span: Span,
370 pub abi: &'static str,
371 #[label]
372 pub extern_span: Span,
373}
374
375#[derive(Diagnostic)]
376#[diag(ast_passes_item_underscore)]
377pub(crate) struct ItemUnderscore<'a> {
378 #[primary_span]
379 #[label]
380 pub span: Span,
381 pub kind: &'a str,
382}
383
384#[derive(Diagnostic)]
385#[diag(ast_passes_nomangle_ascii, code = E0754)]
386pub(crate) struct NoMangleAscii {
387 #[primary_span]
388 pub span: Span,
389}
390
391#[derive(Diagnostic)]
392#[diag(ast_passes_module_nonascii, code = E0754)]
393#[help]
394pub(crate) struct ModuleNonAscii {
395 #[primary_span]
396 pub span: Span,
397 pub name: Symbol,
398}
399
400#[derive(Diagnostic)]
401#[diag(ast_passes_auto_generic, code = E0567)]
402pub(crate) struct AutoTraitGeneric {
403 #[primary_span]
404 #[suggestion(code = "", applicability = "machine-applicable", style = "tool-only")]
405 pub span: Span,
406 #[label]
407 pub ident: Span,
408}
409
410#[derive(Diagnostic)]
411#[diag(ast_passes_auto_super_lifetime, code = E0568)]
412pub(crate) struct AutoTraitBounds {
413 #[primary_span]
414 pub span: Vec<Span>,
415 #[suggestion(code = "", applicability = "machine-applicable", style = "tool-only")]
416 pub removal: Span,
417 #[label]
418 pub ident: Span,
419}
420
421#[derive(Diagnostic)]
422#[diag(ast_passes_auto_items, code = E0380)]
423pub(crate) struct AutoTraitItems {
424 #[primary_span]
425 pub spans: Vec<Span>,
426 #[suggestion(code = "", applicability = "machine-applicable", style = "tool-only")]
427 pub total: Span,
428 #[label]
429 pub ident: Span,
430}
431
432#[derive(Diagnostic)]
433#[diag(ast_passes_generic_before_constraints)]
434pub(crate) struct ArgsBeforeConstraint {
435 #[primary_span]
436 pub arg_spans: Vec<Span>,
437 #[label(ast_passes_constraints)]
438 pub constraints: Span,
439 #[label(ast_passes_args)]
440 pub args: Span,
441 #[suggestion(code = "{suggestion}", applicability = "machine-applicable", style = "verbose")]
442 pub data: Span,
443 pub suggestion: String,
444 pub constraint_len: usize,
445 pub args_len: usize,
446 #[subdiagnostic]
447 pub constraint_spans: EmptyLabelManySpans,
448 #[subdiagnostic]
449 pub arg_spans2: EmptyLabelManySpans,
450}
451
452pub(crate) struct EmptyLabelManySpans(pub Vec<Span>);
453
454impl Subdiagnostic for EmptyLabelManySpans {
456 fn add_to_diag<G: EmissionGuarantee>(self, diag: &mut Diag<'_, G>) {
457 diag.span_labels(self.0, "");
458 }
459}
460
461#[derive(Diagnostic)]
462#[diag(ast_passes_pattern_in_fn_pointer, code = E0561)]
463pub(crate) struct PatternFnPointer {
464 #[primary_span]
465 pub span: Span,
466}
467
468#[derive(Diagnostic)]
469#[diag(ast_passes_trait_object_single_bound, code = E0226)]
470pub(crate) struct TraitObjectBound {
471 #[primary_span]
472 pub span: Span,
473}
474
475#[derive(Diagnostic)]
476#[diag(ast_passes_nested_impl_trait, code = E0666)]
477pub(crate) struct NestedImplTrait {
478 #[primary_span]
479 pub span: Span,
480 #[label(ast_passes_outer)]
481 pub outer: Span,
482 #[label(ast_passes_inner)]
483 pub inner: Span,
484}
485
486#[derive(Diagnostic)]
487#[diag(ast_passes_at_least_one_trait)]
488pub(crate) struct AtLeastOneTrait {
489 #[primary_span]
490 pub span: Span,
491}
492
493#[derive(Diagnostic)]
494#[diag(ast_passes_out_of_order_params)]
495pub(crate) struct OutOfOrderParams<'a> {
496 #[primary_span]
497 pub spans: Vec<Span>,
498 #[suggestion(code = "{ordered_params}", applicability = "machine-applicable")]
499 pub sugg_span: Span,
500 pub param_ord: &'a ParamKindOrd,
501 pub max_param: &'a ParamKindOrd,
502 pub ordered_params: &'a str,
503}
504
505#[derive(Diagnostic)]
506#[diag(ast_passes_obsolete_auto)]
507#[help]
508pub(crate) struct ObsoleteAuto {
509 #[primary_span]
510 pub span: Span,
511}
512
513#[derive(Diagnostic)]
514#[diag(ast_passes_unsafe_negative_impl, code = E0198)]
515pub(crate) struct UnsafeNegativeImpl {
516 #[primary_span]
517 pub span: Span,
518 #[label(ast_passes_negative)]
519 pub negative: Span,
520 #[label(ast_passes_unsafe)]
521 pub r#unsafe: Span,
522}
523
524#[derive(Diagnostic)]
525#[diag(ast_passes_unsafe_item)]
526pub(crate) struct UnsafeItem {
527 #[primary_span]
528 pub span: Span,
529 pub kind: &'static str,
530}
531
532#[derive(Diagnostic)]
533#[diag(ast_passes_missing_unsafe_on_extern)]
534pub(crate) struct MissingUnsafeOnExtern {
535 #[primary_span]
536 pub span: Span,
537}
538
539#[derive(LintDiagnostic)]
540#[diag(ast_passes_missing_unsafe_on_extern_lint)]
541pub(crate) struct MissingUnsafeOnExternLint {
542 #[suggestion(code = "unsafe ", applicability = "machine-applicable")]
543 pub suggestion: Span,
544}
545
546#[derive(Diagnostic)]
547#[diag(ast_passes_fieldless_union)]
548pub(crate) struct FieldlessUnion {
549 #[primary_span]
550 pub span: Span,
551}
552
553#[derive(Diagnostic)]
554#[diag(ast_passes_where_clause_after_type_alias)]
555#[note]
556pub(crate) struct WhereClauseAfterTypeAlias {
557 #[primary_span]
558 pub span: Span,
559 #[help]
560 pub help: bool,
561}
562
563#[derive(Diagnostic)]
564#[diag(ast_passes_where_clause_before_type_alias)]
565#[note]
566pub(crate) struct WhereClauseBeforeTypeAlias {
567 #[primary_span]
568 pub span: Span,
569 #[subdiagnostic]
570 pub sugg: WhereClauseBeforeTypeAliasSugg,
571}
572
573#[derive(Subdiagnostic)]
574pub(crate) enum WhereClauseBeforeTypeAliasSugg {
575 #[suggestion(ast_passes_remove_suggestion, applicability = "machine-applicable", code = "")]
576 Remove {
577 #[primary_span]
578 span: Span,
579 },
580 #[multipart_suggestion(
581 ast_passes_move_suggestion,
582 applicability = "machine-applicable",
583 style = "verbose"
584 )]
585 Move {
586 #[suggestion_part(code = "")]
587 left: Span,
588 snippet: String,
589 #[suggestion_part(code = "{snippet}")]
590 right: Span,
591 },
592}
593
594#[derive(Diagnostic)]
595#[diag(ast_passes_generic_default_trailing)]
596pub(crate) struct GenericDefaultTrailing {
597 #[primary_span]
598 pub span: Span,
599}
600
601#[derive(Diagnostic)]
602#[diag(ast_passes_nested_lifetimes, code = E0316)]
603pub(crate) struct NestedLifetimes {
604 #[primary_span]
605 pub span: Span,
606}
607
608#[derive(Diagnostic)]
609#[diag(ast_passes_const_bound_trait_object)]
610pub(crate) struct ConstBoundTraitObject {
611 #[primary_span]
612 pub span: Span,
613}
614
615#[derive(Diagnostic)]
618#[diag(ast_passes_tilde_const_disallowed)]
619pub(crate) struct TildeConstDisallowed {
620 #[primary_span]
621 pub span: Span,
622 #[subdiagnostic]
623 pub reason: TildeConstReason,
624}
625
626#[derive(Subdiagnostic, Copy, Clone)]
627pub(crate) enum TildeConstReason {
628 #[note(ast_passes_closure)]
629 Closure,
630 #[note(ast_passes_function)]
631 Function {
632 #[primary_span]
633 ident: Span,
634 },
635 #[note(ast_passes_trait)]
636 Trait {
637 #[primary_span]
638 span: Span,
639 },
640 #[note(ast_passes_trait_impl)]
641 TraitImpl {
642 #[primary_span]
643 span: Span,
644 },
645 #[note(ast_passes_impl)]
646 Impl {
647 #[primary_span]
648 span: Span,
649 },
650 #[note(ast_passes_trait_assoc_ty)]
651 TraitAssocTy {
652 #[primary_span]
653 span: Span,
654 },
655 #[note(ast_passes_trait_impl_assoc_ty)]
656 TraitImplAssocTy {
657 #[primary_span]
658 span: Span,
659 },
660 #[note(ast_passes_inherent_assoc_ty)]
661 InherentAssocTy {
662 #[primary_span]
663 span: Span,
664 },
665 #[note(ast_passes_struct)]
666 Struct {
667 #[primary_span]
668 span: Span,
669 },
670 #[note(ast_passes_enum)]
671 Enum {
672 #[primary_span]
673 span: Span,
674 },
675 #[note(ast_passes_union)]
676 Union {
677 #[primary_span]
678 span: Span,
679 },
680 #[note(ast_passes_anon_const)]
681 AnonConst {
682 #[primary_span]
683 span: Span,
684 },
685 #[note(ast_passes_object)]
686 TraitObject,
687 #[note(ast_passes_item)]
688 Item,
689}
690
691#[derive(Diagnostic)]
692#[diag(ast_passes_const_and_coroutine)]
693pub(crate) struct ConstAndCoroutine {
694 #[primary_span]
695 pub spans: Vec<Span>,
696 #[label(ast_passes_const)]
697 pub const_span: Span,
698 #[label(ast_passes_coroutine)]
699 pub coroutine_span: Span,
700 #[label]
701 pub span: Span,
702 pub coroutine_kind: &'static str,
703}
704
705#[derive(Diagnostic)]
706#[diag(ast_passes_const_and_c_variadic)]
707pub(crate) struct ConstAndCVariadic {
708 #[primary_span]
709 pub spans: Vec<Span>,
710 #[label(ast_passes_const)]
711 pub const_span: Span,
712 #[label(ast_passes_variadic)]
713 pub variadic_span: Span,
714}
715
716#[derive(Diagnostic)]
717#[diag(ast_passes_coroutine_and_c_variadic)]
718pub(crate) struct CoroutineAndCVariadic {
719 #[primary_span]
720 pub spans: Vec<Span>,
721 pub coroutine_kind: &'static str,
722 #[label(ast_passes_const)]
723 pub coroutine_span: Span,
724 #[label(ast_passes_variadic)]
725 pub variadic_span: Span,
726}
727
728#[derive(Diagnostic)]
729#[diag(ast_passes_pattern_in_foreign, code = E0130)]
730pub(crate) struct PatternInForeign {
732 #[primary_span]
733 #[label]
734 pub span: Span,
735}
736
737#[derive(Diagnostic)]
738#[diag(ast_passes_pattern_in_bodiless, code = E0642)]
739pub(crate) struct PatternInBodiless {
741 #[primary_span]
742 #[label]
743 pub span: Span,
744}
745
746#[derive(Diagnostic)]
747#[diag(ast_passes_equality_in_where)]
748#[note]
749pub(crate) struct EqualityInWhere {
750 #[primary_span]
751 #[label]
752 pub span: Span,
753 #[subdiagnostic]
754 pub assoc: Option<AssociatedSuggestion>,
755 #[subdiagnostic]
756 pub assoc2: Option<AssociatedSuggestion2>,
757}
758
759#[derive(Subdiagnostic)]
760#[suggestion(
761 ast_passes_suggestion,
762 code = "{param}: {path}",
763 style = "verbose",
764 applicability = "maybe-incorrect"
765)]
766pub(crate) struct AssociatedSuggestion {
767 #[primary_span]
768 pub span: Span,
769 pub ident: Ident,
770 pub param: Ident,
771 pub path: String,
772}
773
774#[derive(Subdiagnostic)]
775#[multipart_suggestion(ast_passes_suggestion_path, applicability = "maybe-incorrect")]
776pub(crate) struct AssociatedSuggestion2 {
777 #[suggestion_part(code = "{args}")]
778 pub span: Span,
779 pub args: String,
780 #[suggestion_part(code = "")]
781 pub predicate: Span,
782 pub trait_segment: Ident,
783 pub potential_assoc: Ident,
784}
785
786#[derive(Diagnostic)]
787#[diag(ast_passes_feature_on_non_nightly, code = E0554)]
788pub(crate) struct FeatureOnNonNightly {
789 #[primary_span]
790 pub span: Span,
791 pub channel: &'static str,
792 #[subdiagnostic]
793 pub stable_features: Vec<StableFeature>,
794 #[suggestion(code = "", applicability = "machine-applicable")]
795 pub sugg: Option<Span>,
796}
797
798pub(crate) struct StableFeature {
799 pub name: Symbol,
800 pub since: Symbol,
801}
802
803impl Subdiagnostic for StableFeature {
804 fn add_to_diag<G: EmissionGuarantee>(self, diag: &mut Diag<'_, G>) {
805 diag.arg("name", self.name);
806 diag.arg("since", self.since);
807 diag.help(fluent::ast_passes_stable_since);
808 }
809}
810
811#[derive(Diagnostic)]
812#[diag(ast_passes_incompatible_features)]
813#[help]
814pub(crate) struct IncompatibleFeatures {
815 #[primary_span]
816 pub spans: Vec<Span>,
817 pub f1: Symbol,
818 pub f2: Symbol,
819}
820
821#[derive(Diagnostic)]
822#[diag(ast_passes_negative_bound_not_supported)]
823pub(crate) struct NegativeBoundUnsupported {
824 #[primary_span]
825 pub span: Span,
826}
827
828#[derive(Diagnostic)]
829#[diag(ast_passes_constraint_on_negative_bound)]
830pub(crate) struct ConstraintOnNegativeBound {
831 #[primary_span]
832 pub span: Span,
833}
834
835#[derive(Diagnostic)]
836#[diag(ast_passes_negative_bound_with_parenthetical_notation)]
837pub(crate) struct NegativeBoundWithParentheticalNotation {
838 #[primary_span]
839 pub span: Span,
840}
841
842#[derive(Diagnostic)]
843#[diag(ast_passes_match_arm_with_no_body)]
844pub(crate) struct MatchArmWithNoBody {
845 #[primary_span]
846 pub span: Span,
847 #[suggestion(
851 code = " => {{ todo!() }}",
852 applicability = "has-placeholders",
853 style = "verbose"
854 )]
855 pub suggestion: Span,
856}
857
858#[derive(Diagnostic)]
859#[diag(ast_passes_precise_capturing_not_allowed_here)]
860pub(crate) struct PreciseCapturingNotAllowedHere {
861 #[primary_span]
862 pub span: Span,
863 pub loc: &'static str,
864}
865
866#[derive(Diagnostic)]
867#[diag(ast_passes_precise_capturing_duplicated)]
868pub(crate) struct DuplicatePreciseCapturing {
869 #[primary_span]
870 pub bound1: Span,
871 #[label]
872 pub bound2: Span,
873}
874
875#[derive(Diagnostic)]
876#[diag(ast_passes_extern_without_abi)]
877#[help]
878pub(crate) struct MissingAbi {
879 #[primary_span]
880 #[suggestion(code = "extern \"<abi>\"", applicability = "has-placeholders")]
881 pub span: Span,
882}
883
884#[derive(LintDiagnostic)]
885#[diag(ast_passes_extern_without_abi_sugg)]
886pub(crate) struct MissingAbiSugg {
887 #[suggestion(code = "extern {default_abi}", applicability = "machine-applicable")]
888 pub span: Span,
889 pub default_abi: ExternAbi,
890}
891
892#[derive(Diagnostic)]
893#[diag(ast_passes_abi_custom_safe_foreign_function)]
894pub(crate) struct AbiCustomSafeForeignFunction {
895 #[primary_span]
896 pub span: Span,
897
898 #[suggestion(
899 ast_passes_suggestion,
900 applicability = "maybe-incorrect",
901 code = "",
902 style = "verbose"
903 )]
904 pub safe_span: Span,
905}
906
907#[derive(Diagnostic)]
908#[diag(ast_passes_abi_custom_safe_function)]
909pub(crate) struct AbiCustomSafeFunction {
910 #[primary_span]
911 pub span: Span,
912 pub abi: ExternAbi,
913
914 #[suggestion(
915 ast_passes_suggestion,
916 applicability = "maybe-incorrect",
917 code = "unsafe ",
918 style = "verbose"
919 )]
920 pub unsafe_span: Span,
921}
922
923#[derive(Diagnostic)]
924#[diag(ast_passes_abi_cannot_be_coroutine)]
925pub(crate) struct AbiCannotBeCoroutine {
926 #[primary_span]
927 pub span: Span,
928 pub abi: ExternAbi,
929
930 #[suggestion(
931 ast_passes_suggestion,
932 applicability = "maybe-incorrect",
933 code = "",
934 style = "verbose"
935 )]
936 pub coroutine_kind_span: Span,
937 pub coroutine_kind_str: &'static str,
938}
939
940#[derive(Diagnostic)]
941#[diag(ast_passes_abi_must_not_have_parameters_or_return_type)]
942#[note]
943pub(crate) struct AbiMustNotHaveParametersOrReturnType {
944 #[primary_span]
945 pub spans: Vec<Span>,
946 pub abi: ExternAbi,
947
948 #[suggestion(
949 ast_passes_suggestion,
950 applicability = "maybe-incorrect",
951 code = "{padding}fn {symbol}()",
952 style = "verbose"
953 )]
954 pub suggestion_span: Span,
955 pub symbol: Symbol,
956 pub padding: &'static str,
957}
958
959#[derive(Diagnostic)]
960#[diag(ast_passes_abi_must_not_have_return_type)]
961#[note]
962pub(crate) struct AbiMustNotHaveReturnType {
963 #[primary_span]
964 #[help]
965 pub span: Span,
966 pub abi: ExternAbi,
967}
968
969#[derive(Diagnostic)]
970#[diag(ast_passes_abi_x86_interrupt)]
971#[note]
972pub(crate) struct AbiX86Interrupt {
973 #[primary_span]
974 pub spans: Vec<Span>,
975 pub param_count: usize,
976}