]> git.lizzy.rs Git - rust.git/blob - compiler/rustc_passes/src/errors.rs
Port `dead_code` lints to be translatable.
[rust.git] / compiler / rustc_passes / src / errors.rs
1 use std::{
2     io::Error,
3     path::{Path, PathBuf},
4 };
5
6 use rustc_ast::Label;
7 use rustc_errors::{
8     error_code, Applicability, DiagnosticSymbolList, ErrorGuaranteed, IntoDiagnostic, MultiSpan,
9 };
10 use rustc_hir::{self as hir, ExprKind, Target};
11 use rustc_macros::{Diagnostic, LintDiagnostic, Subdiagnostic};
12 use rustc_middle::ty::{MainDefinition, Ty};
13 use rustc_span::{Span, Symbol, DUMMY_SP};
14
15 use rustc_errors::{pluralize, AddToDiagnostic, Diagnostic, SubdiagnosticMessage};
16
17 use crate::lang_items::Duplicate;
18
19 #[derive(LintDiagnostic)]
20 #[diag(passes_outer_crate_level_attr)]
21 pub struct OuterCrateLevelAttr;
22
23 #[derive(LintDiagnostic)]
24 #[diag(passes_inner_crate_level_attr)]
25 pub struct InnerCrateLevelAttr;
26
27 #[derive(LintDiagnostic)]
28 #[diag(passes_ignored_attr_with_macro)]
29 pub struct IgnoredAttrWithMacro<'a> {
30     pub sym: &'a str,
31 }
32
33 #[derive(LintDiagnostic)]
34 #[diag(passes_ignored_attr)]
35 pub struct IgnoredAttr<'a> {
36     pub sym: &'a str,
37 }
38
39 #[derive(LintDiagnostic)]
40 #[diag(passes_inline_ignored_function_prototype)]
41 pub struct IgnoredInlineAttrFnProto;
42
43 #[derive(LintDiagnostic)]
44 #[diag(passes_inline_ignored_constants)]
45 #[warning]
46 #[note]
47 pub struct IgnoredInlineAttrConstants;
48
49 #[derive(Diagnostic)]
50 #[diag(passes_inline_not_fn_or_closure, code = "E0518")]
51 pub struct InlineNotFnOrClosure {
52     #[primary_span]
53     pub attr_span: Span,
54     #[label]
55     pub defn_span: Span,
56 }
57
58 #[derive(LintDiagnostic)]
59 #[diag(passes_no_coverage_ignored_function_prototype)]
60 pub struct IgnoredNoCoverageFnProto;
61
62 #[derive(LintDiagnostic)]
63 #[diag(passes_no_coverage_propagate)]
64 pub struct IgnoredNoCoveragePropagate;
65
66 #[derive(LintDiagnostic)]
67 #[diag(passes_no_coverage_fn_defn)]
68 pub struct IgnoredNoCoverageFnDefn;
69
70 #[derive(Diagnostic)]
71 #[diag(passes_no_coverage_not_coverable, code = "E0788")]
72 pub struct IgnoredNoCoverageNotCoverable {
73     #[primary_span]
74     pub attr_span: Span,
75     #[label]
76     pub defn_span: Span,
77 }
78
79 #[derive(Diagnostic)]
80 #[diag(passes_should_be_applied_to_fn)]
81 pub struct AttrShouldBeAppliedToFn {
82     #[primary_span]
83     pub attr_span: Span,
84     #[label]
85     pub defn_span: Span,
86 }
87
88 #[derive(Diagnostic)]
89 #[diag(passes_naked_tracked_caller, code = "E0736")]
90 pub struct NakedTrackedCaller {
91     #[primary_span]
92     pub attr_span: Span,
93 }
94
95 #[derive(Diagnostic)]
96 #[diag(passes_should_be_applied_to_fn, code = "E0739")]
97 pub struct TrackedCallerWrongLocation {
98     #[primary_span]
99     pub attr_span: Span,
100     #[label]
101     pub defn_span: Span,
102 }
103
104 #[derive(Diagnostic)]
105 #[diag(passes_should_be_applied_to_struct_enum, code = "E0701")]
106 pub struct NonExhaustiveWrongLocation {
107     #[primary_span]
108     pub attr_span: Span,
109     #[label]
110     pub defn_span: Span,
111 }
112
113 #[derive(Diagnostic)]
114 #[diag(passes_should_be_applied_to_trait)]
115 pub struct AttrShouldBeAppliedToTrait {
116     #[primary_span]
117     pub attr_span: Span,
118     #[label]
119     pub defn_span: Span,
120 }
121
122 #[derive(LintDiagnostic)]
123 #[diag(passes_target_feature_on_statement)]
124 pub struct TargetFeatureOnStatement;
125
126 #[derive(Diagnostic)]
127 #[diag(passes_should_be_applied_to_static)]
128 pub struct AttrShouldBeAppliedToStatic {
129     #[primary_span]
130     pub attr_span: Span,
131     #[label]
132     pub defn_span: Span,
133 }
134
135 #[derive(Diagnostic)]
136 #[diag(passes_doc_expect_str)]
137 pub struct DocExpectStr<'a> {
138     #[primary_span]
139     pub attr_span: Span,
140     pub attr_name: &'a str,
141 }
142
143 #[derive(Diagnostic)]
144 #[diag(passes_doc_alias_empty)]
145 pub struct DocAliasEmpty<'a> {
146     #[primary_span]
147     pub span: Span,
148     pub attr_str: &'a str,
149 }
150
151 #[derive(Diagnostic)]
152 #[diag(passes_doc_alias_bad_char)]
153 pub struct DocAliasBadChar<'a> {
154     #[primary_span]
155     pub span: Span,
156     pub attr_str: &'a str,
157     pub char_: char,
158 }
159
160 #[derive(Diagnostic)]
161 #[diag(passes_doc_alias_start_end)]
162 pub struct DocAliasStartEnd<'a> {
163     #[primary_span]
164     pub span: Span,
165     pub attr_str: &'a str,
166 }
167
168 #[derive(Diagnostic)]
169 #[diag(passes_doc_alias_bad_location)]
170 pub struct DocAliasBadLocation<'a> {
171     #[primary_span]
172     pub span: Span,
173     pub attr_str: &'a str,
174     pub location: &'a str,
175 }
176
177 #[derive(Diagnostic)]
178 #[diag(passes_doc_alias_not_an_alias)]
179 pub struct DocAliasNotAnAlias<'a> {
180     #[primary_span]
181     pub span: Span,
182     pub attr_str: &'a str,
183 }
184
185 #[derive(LintDiagnostic)]
186 #[diag(passes_doc_alias_duplicated)]
187 pub struct DocAliasDuplicated {
188     #[label]
189     pub first_defn: Span,
190 }
191
192 #[derive(Diagnostic)]
193 #[diag(passes_doc_alias_not_string_literal)]
194 pub struct DocAliasNotStringLiteral {
195     #[primary_span]
196     pub span: Span,
197 }
198
199 #[derive(Diagnostic)]
200 #[diag(passes_doc_alias_malformed)]
201 pub struct DocAliasMalformed {
202     #[primary_span]
203     pub span: Span,
204 }
205
206 #[derive(Diagnostic)]
207 #[diag(passes_doc_keyword_empty_mod)]
208 pub struct DocKeywordEmptyMod {
209     #[primary_span]
210     pub span: Span,
211 }
212
213 #[derive(Diagnostic)]
214 #[diag(passes_doc_keyword_not_mod)]
215 pub struct DocKeywordNotMod {
216     #[primary_span]
217     pub span: Span,
218 }
219
220 #[derive(Diagnostic)]
221 #[diag(passes_doc_keyword_invalid_ident)]
222 pub struct DocKeywordInvalidIdent {
223     #[primary_span]
224     pub span: Span,
225     pub doc_keyword: Symbol,
226 }
227
228 #[derive(Diagnostic)]
229 #[diag(passes_doc_fake_variadic_not_valid)]
230 pub struct DocFakeVariadicNotValid {
231     #[primary_span]
232     pub span: Span,
233 }
234
235 #[derive(Diagnostic)]
236 #[diag(passes_doc_keyword_only_impl)]
237 pub struct DocKeywordOnlyImpl {
238     #[primary_span]
239     pub span: Span,
240 }
241
242 #[derive(Diagnostic)]
243 #[diag(passes_doc_inline_conflict)]
244 #[help]
245 pub struct DocKeywordConflict {
246     #[primary_span]
247     pub spans: MultiSpan,
248 }
249
250 #[derive(LintDiagnostic)]
251 #[diag(passes_doc_inline_only_use)]
252 #[note]
253 pub struct DocInlineOnlyUse {
254     #[label]
255     pub attr_span: Span,
256     #[label(not_a_use_item_label)]
257     pub item_span: Option<Span>,
258 }
259
260 #[derive(Diagnostic)]
261 #[diag(passes_doc_attr_not_crate_level)]
262 pub struct DocAttrNotCrateLevel<'a> {
263     #[primary_span]
264     pub span: Span,
265     pub attr_name: &'a str,
266 }
267
268 #[derive(LintDiagnostic)]
269 #[diag(passes_doc_test_unknown)]
270 pub struct DocTestUnknown {
271     pub path: String,
272 }
273
274 #[derive(LintDiagnostic)]
275 #[diag(passes_doc_test_takes_list)]
276 pub struct DocTestTakesList;
277
278 #[derive(LintDiagnostic)]
279 #[diag(passes_doc_cfg_hide_takes_list)]
280 pub struct DocCfgHideTakesList;
281
282 #[derive(LintDiagnostic)]
283 #[diag(passes_doc_primitive)]
284 pub struct DocPrimitive;
285
286 #[derive(LintDiagnostic)]
287 #[diag(passes_doc_test_unknown_any)]
288 pub struct DocTestUnknownAny {
289     pub path: String,
290 }
291
292 #[derive(LintDiagnostic)]
293 #[diag(passes_doc_test_unknown_spotlight)]
294 #[note]
295 #[note(no_op_note)]
296 pub struct DocTestUnknownSpotlight {
297     pub path: String,
298     #[suggestion_short(applicability = "machine-applicable", code = "notable_trait")]
299     pub span: Span,
300 }
301
302 #[derive(LintDiagnostic)]
303 #[diag(passes_doc_test_unknown_include)]
304 pub struct DocTestUnknownInclude {
305     pub path: String,
306     pub value: String,
307     pub inner: &'static str,
308     #[suggestion(code = "#{inner}[doc = include_str!(\"{value}\")]")]
309     pub sugg: (Span, Applicability),
310 }
311
312 #[derive(LintDiagnostic)]
313 #[diag(passes_doc_invalid)]
314 pub struct DocInvalid;
315
316 #[derive(Diagnostic)]
317 #[diag(passes_pass_by_value)]
318 pub struct PassByValue {
319     #[primary_span]
320     pub attr_span: Span,
321     #[label]
322     pub span: Span,
323 }
324
325 #[derive(Diagnostic)]
326 #[diag(passes_allow_incoherent_impl)]
327 pub struct AllowIncoherentImpl {
328     #[primary_span]
329     pub attr_span: Span,
330     #[label]
331     pub span: Span,
332 }
333
334 #[derive(Diagnostic)]
335 #[diag(passes_has_incoherent_inherent_impl)]
336 pub struct HasIncoherentInherentImpl {
337     #[primary_span]
338     pub attr_span: Span,
339     #[label]
340     pub span: Span,
341 }
342
343 #[derive(LintDiagnostic)]
344 #[diag(passes_must_use_async)]
345 pub struct MustUseAsync {
346     #[label]
347     pub span: Span,
348 }
349
350 #[derive(LintDiagnostic)]
351 #[diag(passes_must_use_no_effect)]
352 pub struct MustUseNoEffect {
353     pub article: &'static str,
354     pub target: rustc_hir::Target,
355 }
356
357 #[derive(Diagnostic)]
358 #[diag(passes_must_not_suspend)]
359 pub struct MustNotSuspend {
360     #[primary_span]
361     pub attr_span: Span,
362     #[label]
363     pub span: Span,
364 }
365
366 #[derive(LintDiagnostic)]
367 #[diag(passes_cold)]
368 #[warning]
369 pub struct Cold {
370     #[label]
371     pub span: Span,
372 }
373
374 #[derive(LintDiagnostic)]
375 #[diag(passes_link)]
376 #[warning]
377 pub struct Link {
378     #[label]
379     pub span: Option<Span>,
380 }
381
382 #[derive(LintDiagnostic)]
383 #[diag(passes_link_name)]
384 #[warning]
385 pub struct LinkName<'a> {
386     #[help]
387     pub attr_span: Option<Span>,
388     #[label]
389     pub span: Span,
390     pub value: &'a str,
391 }
392
393 #[derive(Diagnostic)]
394 #[diag(passes_no_link)]
395 pub struct NoLink {
396     #[primary_span]
397     pub attr_span: Span,
398     #[label]
399     pub span: Span,
400 }
401
402 #[derive(Diagnostic)]
403 #[diag(passes_export_name)]
404 pub struct ExportName {
405     #[primary_span]
406     pub attr_span: Span,
407     #[label]
408     pub span: Span,
409 }
410
411 #[derive(Diagnostic)]
412 #[diag(passes_rustc_layout_scalar_valid_range_not_struct)]
413 pub struct RustcLayoutScalarValidRangeNotStruct {
414     #[primary_span]
415     pub attr_span: Span,
416     #[label]
417     pub span: Span,
418 }
419
420 #[derive(Diagnostic)]
421 #[diag(passes_rustc_layout_scalar_valid_range_arg)]
422 pub struct RustcLayoutScalarValidRangeArg {
423     #[primary_span]
424     pub attr_span: Span,
425 }
426
427 #[derive(Diagnostic)]
428 #[diag(passes_rustc_legacy_const_generics_only)]
429 pub struct RustcLegacyConstGenericsOnly {
430     #[primary_span]
431     pub attr_span: Span,
432     #[label]
433     pub param_span: Span,
434 }
435
436 #[derive(Diagnostic)]
437 #[diag(passes_rustc_legacy_const_generics_index)]
438 pub struct RustcLegacyConstGenericsIndex {
439     #[primary_span]
440     pub attr_span: Span,
441     #[label]
442     pub generics_span: Span,
443 }
444
445 #[derive(Diagnostic)]
446 #[diag(passes_rustc_legacy_const_generics_index_exceed)]
447 pub struct RustcLegacyConstGenericsIndexExceed {
448     #[primary_span]
449     #[label]
450     pub span: Span,
451     pub arg_count: usize,
452 }
453
454 #[derive(Diagnostic)]
455 #[diag(passes_rustc_legacy_const_generics_index_negative)]
456 pub struct RustcLegacyConstGenericsIndexNegative {
457     #[primary_span]
458     pub invalid_args: Vec<Span>,
459 }
460
461 #[derive(Diagnostic)]
462 #[diag(passes_rustc_dirty_clean)]
463 pub struct RustcDirtyClean {
464     #[primary_span]
465     pub span: Span,
466 }
467
468 #[derive(LintDiagnostic)]
469 #[diag(passes_link_section)]
470 #[warning]
471 pub struct LinkSection {
472     #[label]
473     pub span: Span,
474 }
475
476 #[derive(LintDiagnostic)]
477 #[diag(passes_no_mangle_foreign)]
478 #[warning]
479 #[note]
480 pub struct NoMangleForeign {
481     #[label]
482     pub span: Span,
483     #[suggestion(code = "", applicability = "machine-applicable")]
484     pub attr_span: Span,
485     pub foreign_item_kind: &'static str,
486 }
487
488 #[derive(LintDiagnostic)]
489 #[diag(passes_no_mangle)]
490 #[warning]
491 pub struct NoMangle {
492     #[label]
493     pub span: Span,
494 }
495
496 #[derive(Diagnostic)]
497 #[diag(passes_repr_ident, code = "E0565")]
498 pub struct ReprIdent {
499     #[primary_span]
500     pub span: Span,
501 }
502
503 #[derive(LintDiagnostic)]
504 #[diag(passes_repr_conflicting, code = "E0566")]
505 pub struct ReprConflicting;
506
507 #[derive(Diagnostic)]
508 #[diag(passes_used_static)]
509 pub struct UsedStatic {
510     #[primary_span]
511     pub span: Span,
512 }
513
514 #[derive(Diagnostic)]
515 #[diag(passes_used_compiler_linker)]
516 pub struct UsedCompilerLinker {
517     #[primary_span]
518     pub spans: Vec<Span>,
519 }
520
521 #[derive(Diagnostic)]
522 #[diag(passes_allow_internal_unstable)]
523 pub struct AllowInternalUnstable {
524     #[primary_span]
525     pub attr_span: Span,
526     #[label]
527     pub span: Span,
528 }
529
530 #[derive(Diagnostic)]
531 #[diag(passes_debug_visualizer_placement)]
532 pub struct DebugVisualizerPlacement {
533     #[primary_span]
534     pub span: Span,
535 }
536
537 #[derive(Diagnostic)]
538 #[diag(passes_debug_visualizer_invalid)]
539 #[note(note_1)]
540 #[note(note_2)]
541 #[note(note_3)]
542 pub struct DebugVisualizerInvalid {
543     #[primary_span]
544     pub span: Span,
545 }
546
547 #[derive(Diagnostic)]
548 #[diag(passes_debug_visualizer_unreadable)]
549 pub struct DebugVisualizerUnreadable<'a> {
550     #[primary_span]
551     pub span: Span,
552     pub file: &'a Path,
553     pub error: Error,
554 }
555
556 #[derive(Diagnostic)]
557 #[diag(passes_rustc_allow_const_fn_unstable)]
558 pub struct RustcAllowConstFnUnstable {
559     #[primary_span]
560     pub attr_span: Span,
561     #[label]
562     pub span: Span,
563 }
564
565 #[derive(Diagnostic)]
566 #[diag(passes_rustc_std_internal_symbol)]
567 pub struct RustcStdInternalSymbol {
568     #[primary_span]
569     pub attr_span: Span,
570     #[label]
571     pub span: Span,
572 }
573
574 #[derive(Diagnostic)]
575 #[diag(passes_const_trait)]
576 pub struct ConstTrait {
577     #[primary_span]
578     pub attr_span: Span,
579 }
580
581 #[derive(Diagnostic)]
582 #[diag(passes_link_ordinal)]
583 pub struct LinkOrdinal {
584     #[primary_span]
585     pub attr_span: Span,
586 }
587
588 #[derive(Diagnostic)]
589 #[diag(passes_stability_promotable)]
590 pub struct StabilityPromotable {
591     #[primary_span]
592     pub attr_span: Span,
593 }
594
595 #[derive(LintDiagnostic)]
596 #[diag(passes_deprecated)]
597 pub struct Deprecated;
598
599 #[derive(LintDiagnostic)]
600 #[diag(passes_macro_use)]
601 pub struct MacroUse {
602     pub name: Symbol,
603 }
604
605 #[derive(LintDiagnostic)]
606 #[diag(passes_macro_export)]
607 pub struct MacroExport;
608
609 #[derive(LintDiagnostic)]
610 #[diag(passes_plugin_registrar)]
611 pub struct PluginRegistrar;
612
613 #[derive(Subdiagnostic)]
614 pub enum UnusedNote {
615     #[note(passes_unused_empty_lints_note)]
616     EmptyList { name: Symbol },
617     #[note(passes_unused_no_lints_note)]
618     NoLints { name: Symbol },
619     #[note(passes_unused_default_method_body_const_note)]
620     DefaultMethodBodyConst,
621 }
622
623 #[derive(LintDiagnostic)]
624 #[diag(passes_unused)]
625 pub struct Unused {
626     #[suggestion(code = "", applicability = "machine-applicable")]
627     pub attr_span: Span,
628     #[subdiagnostic]
629     pub note: UnusedNote,
630 }
631
632 #[derive(Diagnostic)]
633 #[diag(passes_non_exported_macro_invalid_attrs, code = "E0518")]
634 pub struct NonExportedMacroInvalidAttrs {
635     #[primary_span]
636     #[label]
637     pub attr_span: Span,
638 }
639
640 #[derive(LintDiagnostic)]
641 #[diag(passes_unused_duplicate)]
642 pub struct UnusedDuplicate {
643     #[suggestion(code = "", applicability = "machine-applicable")]
644     pub this: Span,
645     #[note]
646     pub other: Span,
647     #[warning]
648     pub warning: Option<()>,
649 }
650
651 #[derive(Diagnostic)]
652 #[diag(passes_unused_multiple)]
653 pub struct UnusedMultiple {
654     #[primary_span]
655     #[suggestion(code = "", applicability = "machine-applicable")]
656     pub this: Span,
657     #[note]
658     pub other: Span,
659     pub name: Symbol,
660 }
661
662 #[derive(Diagnostic)]
663 #[diag(passes_rustc_lint_opt_ty)]
664 pub struct RustcLintOptTy {
665     #[primary_span]
666     pub attr_span: Span,
667     #[label]
668     pub span: Span,
669 }
670
671 #[derive(Diagnostic)]
672 #[diag(passes_rustc_lint_opt_deny_field_access)]
673 pub struct RustcLintOptDenyFieldAccess {
674     #[primary_span]
675     pub attr_span: Span,
676     #[label]
677     pub span: Span,
678 }
679
680 #[derive(Diagnostic)]
681 #[diag(passes_collapse_debuginfo)]
682 pub struct CollapseDebuginfo {
683     #[primary_span]
684     pub attr_span: Span,
685     #[label]
686     pub defn_span: Span,
687 }
688
689 #[derive(LintDiagnostic)]
690 #[diag(passes_deprecated_annotation_has_no_effect)]
691 pub struct DeprecatedAnnotationHasNoEffect {
692     #[suggestion(applicability = "machine-applicable", code = "")]
693     pub span: Span,
694 }
695
696 #[derive(Diagnostic)]
697 #[diag(passes_unknown_external_lang_item, code = "E0264")]
698 pub struct UnknownExternLangItem {
699     #[primary_span]
700     pub span: Span,
701     pub lang_item: Symbol,
702 }
703
704 #[derive(Diagnostic)]
705 #[diag(passes_missing_panic_handler)]
706 pub struct MissingPanicHandler;
707
708 #[derive(Diagnostic)]
709 #[diag(passes_alloc_func_required)]
710 pub struct AllocFuncRequired;
711
712 #[derive(Diagnostic)]
713 #[diag(passes_missing_alloc_error_handler)]
714 pub struct MissingAllocErrorHandler;
715
716 #[derive(Diagnostic)]
717 #[diag(passes_missing_lang_item)]
718 #[note]
719 #[help]
720 pub struct MissingLangItem {
721     pub name: Symbol,
722 }
723
724 #[derive(Diagnostic)]
725 #[diag(passes_lang_item_on_incorrect_target, code = "E0718")]
726 pub struct LangItemOnIncorrectTarget {
727     #[primary_span]
728     #[label]
729     pub span: Span,
730     pub name: Symbol,
731     pub expected_target: Target,
732     pub actual_target: Target,
733 }
734
735 #[derive(Diagnostic)]
736 #[diag(passes_unknown_lang_item, code = "E0522")]
737 pub struct UnknownLangItem {
738     #[primary_span]
739     #[label]
740     pub span: Span,
741     pub name: Symbol,
742 }
743
744 pub struct InvalidAttrAtCrateLevel {
745     pub span: Span,
746     pub snippet: Option<String>,
747     pub name: Symbol,
748 }
749
750 impl IntoDiagnostic<'_> for InvalidAttrAtCrateLevel {
751     fn into_diagnostic(
752         self,
753         handler: &'_ rustc_errors::Handler,
754     ) -> rustc_errors::DiagnosticBuilder<'_, ErrorGuaranteed> {
755         let mut diag = handler.struct_err(rustc_errors::fluent::passes_invalid_attr_at_crate_level);
756         diag.set_span(self.span);
757         diag.set_arg("name", self.name);
758         // Only emit an error with a suggestion if we can create a string out
759         // of the attribute span
760         if let Some(src) = self.snippet {
761             let replacement = src.replace("#!", "#");
762             diag.span_suggestion_verbose(
763                 self.span,
764                 rustc_errors::fluent::suggestion,
765                 replacement,
766                 rustc_errors::Applicability::MachineApplicable,
767             );
768         }
769         diag
770     }
771 }
772
773 #[derive(Diagnostic)]
774 #[diag(passes_duplicate_diagnostic_item)]
775 pub struct DuplicateDiagnosticItem {
776     #[primary_span]
777     pub span: Span,
778     pub name: Symbol,
779 }
780
781 #[derive(Diagnostic)]
782 #[diag(passes_duplicate_diagnostic_item_in_crate)]
783 pub struct DuplicateDiagnosticItemInCrate {
784     #[note(passes_diagnostic_item_first_defined)]
785     pub span: Option<Span>,
786     pub orig_crate_name: Symbol,
787     #[note]
788     pub have_orig_crate_name: Option<()>,
789     pub crate_name: Symbol,
790     pub name: Symbol,
791 }
792
793 #[derive(Diagnostic)]
794 #[diag(passes_abi)]
795 pub struct Abi {
796     #[primary_span]
797     pub span: Span,
798     pub abi: String,
799 }
800
801 #[derive(Diagnostic)]
802 #[diag(passes_align)]
803 pub struct Align {
804     #[primary_span]
805     pub span: Span,
806     pub align: String,
807 }
808
809 #[derive(Diagnostic)]
810 #[diag(passes_size)]
811 pub struct Size {
812     #[primary_span]
813     pub span: Span,
814     pub size: String,
815 }
816
817 #[derive(Diagnostic)]
818 #[diag(passes_homogeneous_aggregate)]
819 pub struct HomogeneousAggregate {
820     #[primary_span]
821     pub span: Span,
822     pub homogeneous_aggregate: String,
823 }
824
825 #[derive(Diagnostic)]
826 #[diag(passes_layout_of)]
827 pub struct LayoutOf {
828     #[primary_span]
829     pub span: Span,
830     pub normalized_ty: String,
831     pub ty_layout: String,
832 }
833
834 #[derive(Diagnostic)]
835 #[diag(passes_unrecognized_field)]
836 pub struct UnrecognizedField {
837     #[primary_span]
838     pub span: Span,
839     pub name: Symbol,
840 }
841
842 #[derive(Diagnostic)]
843 #[diag(passes_feature_stable_twice, code = "E0711")]
844 pub struct FeatureStableTwice {
845     #[primary_span]
846     pub span: Span,
847     pub feature: Symbol,
848     pub since: Symbol,
849     pub prev_since: Symbol,
850 }
851
852 #[derive(Diagnostic)]
853 #[diag(passes_feature_previously_declared, code = "E0711")]
854 pub struct FeaturePreviouslyDeclared<'a, 'b> {
855     #[primary_span]
856     pub span: Span,
857     pub feature: Symbol,
858     pub declared: &'a str,
859     pub prev_declared: &'b str,
860 }
861
862 #[derive(Diagnostic)]
863 #[diag(passes_expr_not_allowed_in_context, code = "E0744")]
864 pub struct ExprNotAllowedInContext<'a> {
865     #[primary_span]
866     pub span: Span,
867     pub expr: String,
868     pub context: &'a str,
869 }
870
871 pub struct BreakNonLoop<'a> {
872     pub span: Span,
873     pub head: Option<Span>,
874     pub kind: &'a str,
875     pub suggestion: String,
876     pub loop_label: Option<Label>,
877     pub break_label: Option<Label>,
878     pub break_expr_kind: &'a ExprKind<'a>,
879     pub break_expr_span: Span,
880 }
881
882 impl<'a> IntoDiagnostic<'_> for BreakNonLoop<'a> {
883     fn into_diagnostic(
884         self,
885         handler: &rustc_errors::Handler,
886     ) -> rustc_errors::DiagnosticBuilder<'_, ErrorGuaranteed> {
887         let mut diag = handler.struct_span_err_with_code(
888             self.span,
889             rustc_errors::fluent::passes_break_non_loop,
890             error_code!(E0571),
891         );
892         diag.set_arg("kind", self.kind);
893         diag.span_label(self.span, rustc_errors::fluent::label);
894         if let Some(head) = self.head {
895             diag.span_label(head, rustc_errors::fluent::label2);
896         }
897         diag.span_suggestion(
898             self.span,
899             rustc_errors::fluent::suggestion,
900             self.suggestion,
901             Applicability::MaybeIncorrect,
902         );
903         if let (Some(label), None) = (self.loop_label, self.break_label) {
904             match self.break_expr_kind {
905                 ExprKind::Path(hir::QPath::Resolved(
906                     None,
907                     hir::Path { segments: [segment], res: hir::def::Res::Err, .. },
908                 )) if label.ident.to_string() == format!("'{}", segment.ident) => {
909                     // This error is redundant, we will have already emitted a
910                     // suggestion to use the label when `segment` wasn't found
911                     // (hence the `Res::Err` check).
912                     diag.delay_as_bug();
913                 }
914                 _ => {
915                     diag.span_suggestion(
916                         self.break_expr_span,
917                         rustc_errors::fluent::break_expr_suggestion,
918                         label.ident,
919                         Applicability::MaybeIncorrect,
920                     );
921                 }
922             }
923         }
924         diag
925     }
926 }
927
928 #[derive(Diagnostic)]
929 #[diag(passes_continue_labeled_block, code = "E0696")]
930 pub struct ContinueLabeledBlock {
931     #[primary_span]
932     #[label]
933     pub span: Span,
934     #[label(block_label)]
935     pub block_span: Span,
936 }
937
938 #[derive(Diagnostic)]
939 #[diag(passes_break_inside_closure, code = "E0267")]
940 pub struct BreakInsideClosure<'a> {
941     #[primary_span]
942     #[label]
943     pub span: Span,
944     #[label(closure_label)]
945     pub closure_span: Span,
946     pub name: &'a str,
947 }
948
949 #[derive(Diagnostic)]
950 #[diag(passes_break_inside_async_block, code = "E0267")]
951 pub struct BreakInsideAsyncBlock<'a> {
952     #[primary_span]
953     #[label]
954     pub span: Span,
955     #[label(async_block_label)]
956     pub closure_span: Span,
957     pub name: &'a str,
958 }
959
960 #[derive(Diagnostic)]
961 #[diag(passes_outside_loop, code = "E0268")]
962 pub struct OutsideLoop<'a> {
963     #[primary_span]
964     #[label]
965     pub span: Span,
966     pub name: &'a str,
967 }
968
969 #[derive(Diagnostic)]
970 #[diag(passes_unlabeled_in_labeled_block, code = "E0695")]
971 pub struct UnlabeledInLabeledBlock<'a> {
972     #[primary_span]
973     #[label]
974     pub span: Span,
975     pub cf_type: &'a str,
976 }
977
978 #[derive(Diagnostic)]
979 #[diag(passes_unlabeled_cf_in_while_condition, code = "E0590")]
980 pub struct UnlabeledCfInWhileCondition<'a> {
981     #[primary_span]
982     #[label]
983     pub span: Span,
984     pub cf_type: &'a str,
985 }
986
987 #[derive(Diagnostic)]
988 #[diag(passes_cannot_inline_naked_function)]
989 pub struct CannotInlineNakedFunction {
990     #[primary_span]
991     pub span: Span,
992 }
993
994 #[derive(LintDiagnostic)]
995 #[diag(passes_undefined_naked_function_abi)]
996 pub struct UndefinedNakedFunctionAbi;
997
998 #[derive(Diagnostic)]
999 #[diag(passes_no_patterns)]
1000 pub struct NoPatterns {
1001     #[primary_span]
1002     pub span: Span,
1003 }
1004
1005 #[derive(Diagnostic)]
1006 #[diag(passes_params_not_allowed)]
1007 #[help]
1008 pub struct ParamsNotAllowed {
1009     #[primary_span]
1010     pub span: Span,
1011 }
1012
1013 pub struct NakedFunctionsAsmBlock {
1014     pub span: Span,
1015     pub multiple_asms: Vec<Span>,
1016     pub non_asms: Vec<Span>,
1017 }
1018
1019 impl IntoDiagnostic<'_> for NakedFunctionsAsmBlock {
1020     fn into_diagnostic(
1021         self,
1022         handler: &rustc_errors::Handler,
1023     ) -> rustc_errors::DiagnosticBuilder<'_, ErrorGuaranteed> {
1024         let mut diag = handler.struct_span_err_with_code(
1025             self.span,
1026             rustc_errors::fluent::passes_naked_functions_asm_block,
1027             error_code!(E0787),
1028         );
1029         for span in self.multiple_asms.iter() {
1030             diag.span_label(*span, rustc_errors::fluent::label_multiple_asm);
1031         }
1032         for span in self.non_asms.iter() {
1033             diag.span_label(*span, rustc_errors::fluent::label_non_asm);
1034         }
1035         diag
1036     }
1037 }
1038
1039 #[derive(Diagnostic)]
1040 #[diag(passes_naked_functions_operands, code = "E0787")]
1041 pub struct NakedFunctionsOperands {
1042     #[primary_span]
1043     pub unsupported_operands: Vec<Span>,
1044 }
1045
1046 #[derive(Diagnostic)]
1047 #[diag(passes_naked_functions_asm_options, code = "E0787")]
1048 pub struct NakedFunctionsAsmOptions {
1049     #[primary_span]
1050     pub span: Span,
1051     pub unsupported_options: String,
1052 }
1053
1054 #[derive(Diagnostic)]
1055 #[diag(passes_naked_functions_must_use_noreturn, code = "E0787")]
1056 pub struct NakedFunctionsMustUseNoreturn {
1057     #[primary_span]
1058     pub span: Span,
1059     #[suggestion(code = ", options(noreturn)", applicability = "machine-applicable")]
1060     pub last_span: Span,
1061 }
1062
1063 #[derive(Diagnostic)]
1064 #[diag(passes_attr_only_on_main)]
1065 pub struct AttrOnlyOnMain {
1066     #[primary_span]
1067     pub span: Span,
1068     pub attr: Symbol,
1069 }
1070
1071 #[derive(Diagnostic)]
1072 #[diag(passes_attr_only_on_root_main)]
1073 pub struct AttrOnlyOnRootMain {
1074     #[primary_span]
1075     pub span: Span,
1076     pub attr: Symbol,
1077 }
1078
1079 #[derive(Diagnostic)]
1080 #[diag(passes_attr_only_in_functions)]
1081 pub struct AttrOnlyInFunctions {
1082     #[primary_span]
1083     pub span: Span,
1084     pub attr: Symbol,
1085 }
1086
1087 #[derive(Diagnostic)]
1088 #[diag(passes_multiple_rustc_main, code = "E0137")]
1089 pub struct MultipleRustcMain {
1090     #[primary_span]
1091     pub span: Span,
1092     #[label(first)]
1093     pub first: Span,
1094     #[label(additional)]
1095     pub additional: Span,
1096 }
1097
1098 #[derive(Diagnostic)]
1099 #[diag(passes_multiple_start_functions, code = "E0138")]
1100 pub struct MultipleStartFunctions {
1101     #[primary_span]
1102     pub span: Span,
1103     #[label]
1104     pub labeled: Span,
1105     #[label(previous)]
1106     pub previous: Span,
1107 }
1108
1109 #[derive(Diagnostic)]
1110 #[diag(passes_extern_main)]
1111 pub struct ExternMain {
1112     #[primary_span]
1113     pub span: Span,
1114 }
1115
1116 #[derive(Diagnostic)]
1117 #[diag(passes_unix_sigpipe_values)]
1118 pub struct UnixSigpipeValues {
1119     #[primary_span]
1120     pub span: Span,
1121 }
1122
1123 #[derive(Diagnostic)]
1124 #[diag(passes_no_main_function, code = "E0601")]
1125 pub struct NoMainFunction {
1126     #[primary_span]
1127     pub span: Span,
1128     pub crate_name: String,
1129 }
1130
1131 pub struct NoMainErr {
1132     pub sp: Span,
1133     pub crate_name: Symbol,
1134     pub has_filename: bool,
1135     pub filename: PathBuf,
1136     pub file_empty: bool,
1137     pub non_main_fns: Vec<Span>,
1138     pub main_def_opt: Option<MainDefinition>,
1139     pub add_teach_note: bool,
1140 }
1141
1142 impl<'a> IntoDiagnostic<'a> for NoMainErr {
1143     fn into_diagnostic(
1144         self,
1145         handler: &'a rustc_errors::Handler,
1146     ) -> rustc_errors::DiagnosticBuilder<'a, ErrorGuaranteed> {
1147         let mut diag = handler.struct_span_err_with_code(
1148             DUMMY_SP,
1149             rustc_errors::fluent::passes_no_main_function,
1150             error_code!(E0601),
1151         );
1152         diag.set_arg("crate_name", self.crate_name);
1153         diag.set_arg("filename", self.filename);
1154         diag.set_arg("has_filename", self.has_filename);
1155         let note = if !self.non_main_fns.is_empty() {
1156             for &span in &self.non_main_fns {
1157                 diag.span_note(span, rustc_errors::fluent::here_is_main);
1158             }
1159             diag.note(rustc_errors::fluent::one_or_more_possible_main);
1160             diag.help(rustc_errors::fluent::consider_moving_main);
1161             // There were some functions named `main` though. Try to give the user a hint.
1162             rustc_errors::fluent::main_must_be_defined_at_crate
1163         } else if self.has_filename {
1164             rustc_errors::fluent::consider_adding_main_to_file
1165         } else {
1166             rustc_errors::fluent::consider_adding_main_at_crate
1167         };
1168         if self.file_empty {
1169             diag.note(note);
1170         } else {
1171             diag.set_span(self.sp.shrink_to_hi());
1172             diag.span_label(self.sp.shrink_to_hi(), note);
1173         }
1174
1175         if let Some(main_def) = self.main_def_opt && main_def.opt_fn_def_id().is_none(){
1176             // There is something at `crate::main`, but it is not a function definition.
1177             diag.span_label(main_def.span, rustc_errors::fluent::non_function_main);
1178         }
1179
1180         if self.add_teach_note {
1181             diag.note(rustc_errors::fluent::teach_note);
1182         }
1183         diag
1184     }
1185 }
1186
1187 pub struct DuplicateLangItem {
1188     pub local_span: Option<Span>,
1189     pub lang_item_name: Symbol,
1190     pub crate_name: Symbol,
1191     pub dependency_of: Symbol,
1192     pub is_local: bool,
1193     pub path: String,
1194     pub first_defined_span: Option<Span>,
1195     pub orig_crate_name: Symbol,
1196     pub orig_dependency_of: Symbol,
1197     pub orig_is_local: bool,
1198     pub orig_path: String,
1199     pub(crate) duplicate: Duplicate,
1200 }
1201
1202 impl IntoDiagnostic<'_> for DuplicateLangItem {
1203     fn into_diagnostic(
1204         self,
1205         handler: &rustc_errors::Handler,
1206     ) -> rustc_errors::DiagnosticBuilder<'_, ErrorGuaranteed> {
1207         let mut diag = handler.struct_err_with_code(
1208             match self.duplicate {
1209                 Duplicate::Plain => rustc_errors::fluent::passes_duplicate_lang_item,
1210
1211                 Duplicate::Crate => rustc_errors::fluent::passes_duplicate_lang_item_crate,
1212                 Duplicate::CrateDepends => {
1213                     rustc_errors::fluent::passes_duplicate_lang_item_crate_depends
1214                 }
1215             },
1216             error_code!(E0152),
1217         );
1218         diag.set_arg("lang_item_name", self.lang_item_name);
1219         diag.set_arg("crate_name", self.crate_name);
1220         diag.set_arg("dependency_of", self.dependency_of);
1221         diag.set_arg("path", self.path);
1222         diag.set_arg("orig_crate_name", self.orig_crate_name);
1223         diag.set_arg("orig_dependency_of", self.orig_dependency_of);
1224         diag.set_arg("orig_path", self.orig_path);
1225         if let Some(span) = self.local_span {
1226             diag.set_span(span);
1227         }
1228         if let Some(span) = self.first_defined_span {
1229             diag.span_note(span, rustc_errors::fluent::first_defined_span);
1230         } else {
1231             if self.orig_dependency_of.is_empty() {
1232                 diag.note(rustc_errors::fluent::first_defined_crate);
1233             } else {
1234                 diag.note(rustc_errors::fluent::first_defined_crate_depends);
1235             }
1236
1237             if self.orig_is_local {
1238                 diag.note(rustc_errors::fluent::first_definition_local);
1239             } else {
1240                 diag.note(rustc_errors::fluent::first_definition_path);
1241             }
1242
1243             if self.is_local {
1244                 diag.note(rustc_errors::fluent::second_definition_local);
1245             } else {
1246                 diag.note(rustc_errors::fluent::second_definition_path);
1247             }
1248         }
1249         diag
1250     }
1251 }
1252
1253 #[derive(Diagnostic)]
1254 #[diag(passes_incorrect_target, code = "E0718")]
1255 pub struct IncorrectTarget<'a> {
1256     #[primary_span]
1257     pub span: Span,
1258     #[label]
1259     pub generics_span: Span,
1260     pub name: &'a str, // cannot be symbol because it renders e.g. `r#fn` instead of `fn`
1261     pub kind: &'static str,
1262     pub num: usize,
1263     pub actual_num: usize,
1264     pub at_least: bool,
1265 }
1266
1267 #[derive(LintDiagnostic)]
1268 #[diag(passes_useless_assignment)]
1269 pub struct UselessAssignment<'a> {
1270     pub is_field_assign: bool,
1271     pub ty: Ty<'a>,
1272 }
1273
1274 #[derive(LintDiagnostic)]
1275 #[diag(passes_only_has_effect_on)]
1276 pub struct OnlyHasEffectOn {
1277     pub attr_name: Symbol,
1278     pub target_name: String,
1279 }
1280
1281 #[derive(Diagnostic)]
1282 #[diag(passes_object_lifetime_err)]
1283 pub struct ObjectLifetimeErr {
1284     #[primary_span]
1285     pub span: Span,
1286     pub repr: String,
1287 }
1288
1289 #[derive(Diagnostic)]
1290 #[diag(passes_unrecognized_repr_hint, code = "E0552")]
1291 #[help]
1292 pub struct UnrecognizedReprHint {
1293     #[primary_span]
1294     pub span: Span,
1295 }
1296
1297 #[derive(Diagnostic)]
1298 pub enum AttrApplication {
1299     #[diag(passes_attr_application_enum, code = "E0517")]
1300     Enum {
1301         #[primary_span]
1302         hint_span: Span,
1303         #[label]
1304         span: Span,
1305     },
1306     #[diag(passes_attr_application_struct, code = "E0517")]
1307     Struct {
1308         #[primary_span]
1309         hint_span: Span,
1310         #[label]
1311         span: Span,
1312     },
1313     #[diag(passes_attr_application_struct_union, code = "E0517")]
1314     StructUnion {
1315         #[primary_span]
1316         hint_span: Span,
1317         #[label]
1318         span: Span,
1319     },
1320     #[diag(passes_attr_application_struct_enum_union, code = "E0517")]
1321     StructEnumUnion {
1322         #[primary_span]
1323         hint_span: Span,
1324         #[label]
1325         span: Span,
1326     },
1327     #[diag(passes_attr_application_struct_enum_function_union, code = "E0517")]
1328     StructEnumFunctionUnion {
1329         #[primary_span]
1330         hint_span: Span,
1331         #[label]
1332         span: Span,
1333     },
1334 }
1335
1336 #[derive(Diagnostic)]
1337 #[diag(passes_transparent_incompatible, code = "E0692")]
1338 pub struct TransparentIncompatible {
1339     #[primary_span]
1340     pub hint_spans: Vec<Span>,
1341     pub target: String,
1342 }
1343
1344 #[derive(Diagnostic)]
1345 #[diag(passes_deprecated_attribute, code = "E0549")]
1346 pub struct DeprecatedAttribute {
1347     #[primary_span]
1348     pub span: Span,
1349 }
1350
1351 #[derive(Diagnostic)]
1352 #[diag(passes_useless_stability)]
1353 pub struct UselessStability {
1354     #[primary_span]
1355     #[label]
1356     pub span: Span,
1357     #[label(item)]
1358     pub item_sp: Span,
1359 }
1360
1361 #[derive(Diagnostic)]
1362 #[diag(passes_invalid_stability)]
1363 pub struct InvalidStability {
1364     #[primary_span]
1365     #[label]
1366     pub span: Span,
1367     #[label(item)]
1368     pub item_sp: Span,
1369 }
1370
1371 #[derive(Diagnostic)]
1372 #[diag(passes_cannot_stabilize_deprecated)]
1373 pub struct CannotStabilizeDeprecated {
1374     #[primary_span]
1375     #[label]
1376     pub span: Span,
1377     #[label(item)]
1378     pub item_sp: Span,
1379 }
1380
1381 #[derive(Diagnostic)]
1382 #[diag(passes_invalid_deprecation_version)]
1383 pub struct InvalidDeprecationVersion {
1384     #[primary_span]
1385     #[label]
1386     pub span: Span,
1387     #[label(item)]
1388     pub item_sp: Span,
1389 }
1390
1391 #[derive(Diagnostic)]
1392 #[diag(passes_missing_stability_attr)]
1393 pub struct MissingStabilityAttr<'a> {
1394     #[primary_span]
1395     pub span: Span,
1396     pub descr: &'a str,
1397 }
1398
1399 #[derive(Diagnostic)]
1400 #[diag(passes_missing_const_stab_attr)]
1401 pub struct MissingConstStabAttr<'a> {
1402     #[primary_span]
1403     pub span: Span,
1404     pub descr: &'a str,
1405 }
1406
1407 #[derive(Diagnostic)]
1408 #[diag(passes_trait_impl_const_stable)]
1409 #[note]
1410 pub struct TraitImplConstStable {
1411     #[primary_span]
1412     pub span: Span,
1413 }
1414
1415 #[derive(Diagnostic)]
1416 #[diag(passes_feature_only_on_nightly, code = "E0554")]
1417 pub struct FeatureOnlyOnNightly {
1418     #[primary_span]
1419     pub span: Span,
1420     pub release_channel: &'static str,
1421 }
1422
1423 #[derive(Diagnostic)]
1424 #[diag(passes_unknown_feature, code = "E0635")]
1425 pub struct UnknownFeature {
1426     #[primary_span]
1427     pub span: Span,
1428     pub feature: Symbol,
1429 }
1430
1431 #[derive(Diagnostic)]
1432 #[diag(passes_implied_feature_not_exist)]
1433 pub struct ImpliedFeatureNotExist {
1434     #[primary_span]
1435     pub span: Span,
1436     pub feature: Symbol,
1437     pub implied_by: Symbol,
1438 }
1439
1440 #[derive(Diagnostic)]
1441 #[diag(passes_duplicate_feature_err, code = "E0636")]
1442 pub struct DuplicateFeatureErr {
1443     #[primary_span]
1444     pub span: Span,
1445     pub feature: Symbol,
1446 }
1447 #[derive(Diagnostic)]
1448 #[diag(passes_missing_const_err)]
1449 pub struct MissingConstErr {
1450     #[primary_span]
1451     #[help]
1452     pub fn_sig_span: Span,
1453     #[label]
1454     pub const_span: Span,
1455 }
1456
1457 #[derive(LintDiagnostic)]
1458 pub enum MultipleDeadCodes<'tcx> {
1459     #[diag(passes_dead_codes)]
1460     DeadCodes {
1461         multiple: bool,
1462         num: usize,
1463         descr: &'tcx str,
1464         participle: &'tcx str,
1465         name_list: DiagnosticSymbolList,
1466         #[subdiagnostic]
1467         parent_info: Option<ParentInfo<'tcx>>,
1468         #[subdiagnostic]
1469         ignored_derived_impls: Option<IgnoredDerivedImpls>,
1470     },
1471     #[diag(passes_dead_codes)]
1472     UnusedTupleStructFields {
1473         multiple: bool,
1474         num: usize,
1475         descr: &'tcx str,
1476         participle: &'tcx str,
1477         name_list: DiagnosticSymbolList,
1478         #[subdiagnostic]
1479         change_fields_suggestion: ChangeFieldsToBeOfUnitType,
1480         #[subdiagnostic]
1481         parent_info: Option<ParentInfo<'tcx>>,
1482         #[subdiagnostic]
1483         ignored_derived_impls: Option<IgnoredDerivedImpls>,
1484     },
1485 }
1486
1487 #[derive(Subdiagnostic)]
1488 #[label(passes_parent_info)]
1489 pub struct ParentInfo<'tcx> {
1490     pub num: usize,
1491     pub descr: &'tcx str,
1492     pub parent_descr: &'tcx str,
1493     #[primary_span]
1494     pub span: Span,
1495 }
1496
1497 #[derive(Subdiagnostic)]
1498 #[note(passes_ignored_derived_impls)]
1499 pub struct IgnoredDerivedImpls {
1500     pub name: Symbol,
1501     pub trait_list: DiagnosticSymbolList,
1502     pub trait_list_len: usize,
1503 }
1504
1505 pub struct ChangeFieldsToBeOfUnitType {
1506     pub num: usize,
1507     pub spans: Vec<Span>,
1508 }
1509
1510 // FIXME: Replace this impl with a derive.
1511 impl AddToDiagnostic for ChangeFieldsToBeOfUnitType {
1512     fn add_to_diagnostic_with<F>(self, diag: &mut Diagnostic, _: F)
1513     where
1514         F: Fn(&mut Diagnostic, SubdiagnosticMessage) -> SubdiagnosticMessage,
1515     {
1516         diag.multipart_suggestion(
1517             &format!(
1518                 "consider changing the field{s} to be of unit type to \
1519                           suppress this warning while preserving the field \
1520                           numbering, or remove the field{s}",
1521                 s = pluralize!(self.num)
1522             ),
1523             self.spans.iter().map(|sp| (*sp, "()".to_string())).collect(),
1524             // "HasPlaceholders" because applying this fix by itself isn't
1525             // enough: All constructor calls have to be adjusted as well
1526             Applicability::HasPlaceholders,
1527         );
1528     }
1529 }