]> git.lizzy.rs Git - rust.git/blob - compiler/rustc_passes/src/errors.rs
Auto merge of #102106 - djkoloski:sync-from-clippy, r=Manishearth
[rust.git] / compiler / rustc_passes / src / errors.rs
1 use rustc_errors::{Applicability, MultiSpan};
2 use rustc_macros::{Diagnostic, LintDiagnostic, Subdiagnostic};
3 use rustc_span::{Span, Symbol};
4
5 #[derive(LintDiagnostic)]
6 #[diag(passes::outer_crate_level_attr)]
7 pub struct OuterCrateLevelAttr;
8
9 #[derive(LintDiagnostic)]
10 #[diag(passes::inner_crate_level_attr)]
11 pub struct InnerCrateLevelAttr;
12
13 #[derive(LintDiagnostic)]
14 #[diag(passes::ignored_attr_with_macro)]
15 pub struct IgnoredAttrWithMacro<'a> {
16     pub sym: &'a str,
17 }
18
19 #[derive(LintDiagnostic)]
20 #[diag(passes::ignored_attr)]
21 pub struct IgnoredAttr<'a> {
22     pub sym: &'a str,
23 }
24
25 #[derive(LintDiagnostic)]
26 #[diag(passes::inline_ignored_function_prototype)]
27 pub struct IgnoredInlineAttrFnProto;
28
29 #[derive(LintDiagnostic)]
30 #[diag(passes::inline_ignored_constants)]
31 #[warning]
32 #[note]
33 pub struct IgnoredInlineAttrConstants;
34
35 #[derive(Diagnostic)]
36 #[diag(passes::inline_not_fn_or_closure, code = "E0518")]
37 pub struct InlineNotFnOrClosure {
38     #[primary_span]
39     pub attr_span: Span,
40     #[label]
41     pub defn_span: Span,
42 }
43
44 #[derive(LintDiagnostic)]
45 #[diag(passes::no_coverage_ignored_function_prototype)]
46 pub struct IgnoredNoCoverageFnProto;
47
48 #[derive(LintDiagnostic)]
49 #[diag(passes::no_coverage_propagate)]
50 pub struct IgnoredNoCoveragePropagate;
51
52 #[derive(LintDiagnostic)]
53 #[diag(passes::no_coverage_fn_defn)]
54 pub struct IgnoredNoCoverageFnDefn;
55
56 #[derive(Diagnostic)]
57 #[diag(passes::no_coverage_not_coverable, code = "E0788")]
58 pub struct IgnoredNoCoverageNotCoverable {
59     #[primary_span]
60     pub attr_span: Span,
61     #[label]
62     pub defn_span: Span,
63 }
64
65 #[derive(Diagnostic)]
66 #[diag(passes::should_be_applied_to_fn)]
67 pub struct AttrShouldBeAppliedToFn {
68     #[primary_span]
69     pub attr_span: Span,
70     #[label]
71     pub defn_span: Span,
72 }
73
74 #[derive(Diagnostic)]
75 #[diag(passes::naked_tracked_caller, code = "E0736")]
76 pub struct NakedTrackedCaller {
77     #[primary_span]
78     pub attr_span: Span,
79 }
80
81 #[derive(Diagnostic)]
82 #[diag(passes::should_be_applied_to_fn, code = "E0739")]
83 pub struct TrackedCallerWrongLocation {
84     #[primary_span]
85     pub attr_span: Span,
86     #[label]
87     pub defn_span: Span,
88 }
89
90 #[derive(Diagnostic)]
91 #[diag(passes::should_be_applied_to_struct_enum, code = "E0701")]
92 pub struct NonExhaustiveWrongLocation {
93     #[primary_span]
94     pub attr_span: Span,
95     #[label]
96     pub defn_span: Span,
97 }
98
99 #[derive(Diagnostic)]
100 #[diag(passes::should_be_applied_to_trait)]
101 pub struct AttrShouldBeAppliedToTrait {
102     #[primary_span]
103     pub attr_span: Span,
104     #[label]
105     pub defn_span: Span,
106 }
107
108 #[derive(LintDiagnostic)]
109 #[diag(passes::target_feature_on_statement)]
110 pub struct TargetFeatureOnStatement;
111
112 #[derive(Diagnostic)]
113 #[diag(passes::should_be_applied_to_static)]
114 pub struct AttrShouldBeAppliedToStatic {
115     #[primary_span]
116     pub attr_span: Span,
117     #[label]
118     pub defn_span: Span,
119 }
120
121 #[derive(Diagnostic)]
122 #[diag(passes::doc_expect_str)]
123 pub struct DocExpectStr<'a> {
124     #[primary_span]
125     pub attr_span: Span,
126     pub attr_name: &'a str,
127 }
128
129 #[derive(Diagnostic)]
130 #[diag(passes::doc_alias_empty)]
131 pub struct DocAliasEmpty<'a> {
132     #[primary_span]
133     pub span: Span,
134     pub attr_str: &'a str,
135 }
136
137 #[derive(Diagnostic)]
138 #[diag(passes::doc_alias_bad_char)]
139 pub struct DocAliasBadChar<'a> {
140     #[primary_span]
141     pub span: Span,
142     pub attr_str: &'a str,
143     pub char_: char,
144 }
145
146 #[derive(Diagnostic)]
147 #[diag(passes::doc_alias_start_end)]
148 pub struct DocAliasStartEnd<'a> {
149     #[primary_span]
150     pub span: Span,
151     pub attr_str: &'a str,
152 }
153
154 #[derive(Diagnostic)]
155 #[diag(passes::doc_alias_bad_location)]
156 pub struct DocAliasBadLocation<'a> {
157     #[primary_span]
158     pub span: Span,
159     pub attr_str: &'a str,
160     pub location: &'a str,
161 }
162
163 #[derive(Diagnostic)]
164 #[diag(passes::doc_alias_not_an_alias)]
165 pub struct DocAliasNotAnAlias<'a> {
166     #[primary_span]
167     pub span: Span,
168     pub attr_str: &'a str,
169 }
170
171 #[derive(LintDiagnostic)]
172 #[diag(passes::doc_alias_duplicated)]
173 pub struct DocAliasDuplicated {
174     #[label]
175     pub first_defn: Span,
176 }
177
178 #[derive(Diagnostic)]
179 #[diag(passes::doc_alias_not_string_literal)]
180 pub struct DocAliasNotStringLiteral {
181     #[primary_span]
182     pub span: Span,
183 }
184
185 #[derive(Diagnostic)]
186 #[diag(passes::doc_alias_malformed)]
187 pub struct DocAliasMalformed {
188     #[primary_span]
189     pub span: Span,
190 }
191
192 #[derive(Diagnostic)]
193 #[diag(passes::doc_keyword_empty_mod)]
194 pub struct DocKeywordEmptyMod {
195     #[primary_span]
196     pub span: Span,
197 }
198
199 #[derive(Diagnostic)]
200 #[diag(passes::doc_keyword_not_mod)]
201 pub struct DocKeywordNotMod {
202     #[primary_span]
203     pub span: Span,
204 }
205
206 #[derive(Diagnostic)]
207 #[diag(passes::doc_keyword_invalid_ident)]
208 pub struct DocKeywordInvalidIdent {
209     #[primary_span]
210     pub span: Span,
211     pub doc_keyword: Symbol,
212 }
213
214 #[derive(Diagnostic)]
215 #[diag(passes::doc_fake_variadic_not_valid)]
216 pub struct DocFakeVariadicNotValid {
217     #[primary_span]
218     pub span: Span,
219 }
220
221 #[derive(Diagnostic)]
222 #[diag(passes::doc_keyword_only_impl)]
223 pub struct DocKeywordOnlyImpl {
224     #[primary_span]
225     pub span: Span,
226 }
227
228 #[derive(Diagnostic)]
229 #[diag(passes::doc_inline_conflict)]
230 #[help]
231 pub struct DocKeywordConflict {
232     #[primary_span]
233     pub spans: MultiSpan,
234 }
235
236 #[derive(LintDiagnostic)]
237 #[diag(passes::doc_inline_only_use)]
238 #[note]
239 pub struct DocInlineOnlyUse {
240     #[label]
241     pub attr_span: Span,
242     #[label(passes::not_a_use_item_label)]
243     pub item_span: Option<Span>,
244 }
245
246 #[derive(Diagnostic)]
247 #[diag(passes::doc_attr_not_crate_level)]
248 pub struct DocAttrNotCrateLevel<'a> {
249     #[primary_span]
250     pub span: Span,
251     pub attr_name: &'a str,
252 }
253
254 #[derive(LintDiagnostic)]
255 #[diag(passes::doc_test_unknown)]
256 pub struct DocTestUnknown {
257     pub path: String,
258 }
259
260 #[derive(LintDiagnostic)]
261 #[diag(passes::doc_test_takes_list)]
262 pub struct DocTestTakesList;
263
264 #[derive(LintDiagnostic)]
265 #[diag(passes::doc_primitive)]
266 pub struct DocPrimitive;
267
268 #[derive(LintDiagnostic)]
269 #[diag(passes::doc_test_unknown_any)]
270 pub struct DocTestUnknownAny {
271     pub path: String,
272 }
273
274 #[derive(LintDiagnostic)]
275 #[diag(passes::doc_test_unknown_spotlight)]
276 #[note]
277 #[note(passes::no_op_note)]
278 pub struct DocTestUnknownSpotlight {
279     pub path: String,
280     #[suggestion_short(applicability = "machine-applicable", code = "notable_trait")]
281     pub span: Span,
282 }
283
284 #[derive(LintDiagnostic)]
285 #[diag(passes::doc_test_unknown_include)]
286 pub struct DocTestUnknownInclude {
287     pub path: String,
288     pub value: String,
289     pub inner: &'static str,
290     #[suggestion(code = "#{inner}[doc = include_str!(\"{value}\")]")]
291     pub sugg: (Span, Applicability),
292 }
293
294 #[derive(LintDiagnostic)]
295 #[diag(passes::doc_invalid)]
296 pub struct DocInvalid;
297
298 #[derive(Diagnostic)]
299 #[diag(passes::pass_by_value)]
300 pub struct PassByValue {
301     #[primary_span]
302     pub attr_span: Span,
303     #[label]
304     pub span: Span,
305 }
306
307 #[derive(Diagnostic)]
308 #[diag(passes::allow_incoherent_impl)]
309 pub struct AllowIncoherentImpl {
310     #[primary_span]
311     pub attr_span: Span,
312     #[label]
313     pub span: Span,
314 }
315
316 #[derive(Diagnostic)]
317 #[diag(passes::has_incoherent_inherent_impl)]
318 pub struct HasIncoherentInherentImpl {
319     #[primary_span]
320     pub attr_span: Span,
321     #[label]
322     pub span: Span,
323 }
324
325 #[derive(LintDiagnostic)]
326 #[diag(passes::must_use_async)]
327 pub struct MustUseAsync {
328     #[label]
329     pub span: Span,
330 }
331
332 #[derive(LintDiagnostic)]
333 #[diag(passes::must_use_no_effect)]
334 pub struct MustUseNoEffect {
335     pub article: &'static str,
336     pub target: rustc_hir::Target,
337 }
338
339 #[derive(Diagnostic)]
340 #[diag(passes::must_not_suspend)]
341 pub struct MustNotSuspend {
342     #[primary_span]
343     pub attr_span: Span,
344     #[label]
345     pub span: Span,
346 }
347
348 #[derive(LintDiagnostic)]
349 #[diag(passes::cold)]
350 #[warning]
351 pub struct Cold {
352     #[label]
353     pub span: Span,
354 }
355
356 #[derive(LintDiagnostic)]
357 #[diag(passes::link)]
358 #[warning]
359 pub struct Link {
360     #[label]
361     pub span: Option<Span>,
362 }
363
364 #[derive(LintDiagnostic)]
365 #[diag(passes::link_name)]
366 #[warning]
367 pub struct LinkName<'a> {
368     #[help]
369     pub attr_span: Option<Span>,
370     #[label]
371     pub span: Span,
372     pub value: &'a str,
373 }
374
375 #[derive(Diagnostic)]
376 #[diag(passes::no_link)]
377 pub struct NoLink {
378     #[primary_span]
379     pub attr_span: Span,
380     #[label]
381     pub span: Span,
382 }
383
384 #[derive(Diagnostic)]
385 #[diag(passes::export_name)]
386 pub struct ExportName {
387     #[primary_span]
388     pub attr_span: Span,
389     #[label]
390     pub span: Span,
391 }
392
393 #[derive(Diagnostic)]
394 #[diag(passes::rustc_layout_scalar_valid_range_not_struct)]
395 pub struct RustcLayoutScalarValidRangeNotStruct {
396     #[primary_span]
397     pub attr_span: Span,
398     #[label]
399     pub span: Span,
400 }
401
402 #[derive(Diagnostic)]
403 #[diag(passes::rustc_layout_scalar_valid_range_arg)]
404 pub struct RustcLayoutScalarValidRangeArg {
405     #[primary_span]
406     pub attr_span: Span,
407 }
408
409 #[derive(Diagnostic)]
410 #[diag(passes::rustc_legacy_const_generics_only)]
411 pub struct RustcLegacyConstGenericsOnly {
412     #[primary_span]
413     pub attr_span: Span,
414     #[label]
415     pub param_span: Span,
416 }
417
418 #[derive(Diagnostic)]
419 #[diag(passes::rustc_legacy_const_generics_index)]
420 pub struct RustcLegacyConstGenericsIndex {
421     #[primary_span]
422     pub attr_span: Span,
423     #[label]
424     pub generics_span: Span,
425 }
426
427 #[derive(Diagnostic)]
428 #[diag(passes::rustc_legacy_const_generics_index_exceed)]
429 pub struct RustcLegacyConstGenericsIndexExceed {
430     #[primary_span]
431     #[label]
432     pub span: Span,
433     pub arg_count: usize,
434 }
435
436 #[derive(Diagnostic)]
437 #[diag(passes::rustc_legacy_const_generics_index_negative)]
438 pub struct RustcLegacyConstGenericsIndexNegative {
439     #[primary_span]
440     pub invalid_args: Vec<Span>,
441 }
442
443 #[derive(Diagnostic)]
444 #[diag(passes::rustc_dirty_clean)]
445 pub struct RustcDirtyClean {
446     #[primary_span]
447     pub span: Span,
448 }
449
450 #[derive(LintDiagnostic)]
451 #[diag(passes::link_section)]
452 #[warning]
453 pub struct LinkSection {
454     #[label]
455     pub span: Span,
456 }
457
458 #[derive(LintDiagnostic)]
459 #[diag(passes::no_mangle_foreign)]
460 #[warning]
461 #[note]
462 pub struct NoMangleForeign {
463     #[label]
464     pub span: Span,
465     #[suggestion(applicability = "machine-applicable")]
466     pub attr_span: Span,
467     pub foreign_item_kind: &'static str,
468 }
469
470 #[derive(LintDiagnostic)]
471 #[diag(passes::no_mangle)]
472 #[warning]
473 pub struct NoMangle {
474     #[label]
475     pub span: Span,
476 }
477
478 #[derive(Diagnostic)]
479 #[diag(passes::repr_ident, code = "E0565")]
480 pub struct ReprIdent {
481     #[primary_span]
482     pub span: Span,
483 }
484
485 #[derive(LintDiagnostic)]
486 #[diag(passes::repr_conflicting, code = "E0566")]
487 pub struct ReprConflicting;
488
489 #[derive(Diagnostic)]
490 #[diag(passes::used_static)]
491 pub struct UsedStatic {
492     #[primary_span]
493     pub span: Span,
494 }
495
496 #[derive(Diagnostic)]
497 #[diag(passes::used_compiler_linker)]
498 pub struct UsedCompilerLinker {
499     #[primary_span]
500     pub spans: Vec<Span>,
501 }
502
503 #[derive(Diagnostic)]
504 #[diag(passes::allow_internal_unstable)]
505 pub struct AllowInternalUnstable {
506     #[primary_span]
507     pub attr_span: Span,
508     #[label]
509     pub span: Span,
510 }
511
512 #[derive(Diagnostic)]
513 #[diag(passes::debug_visualizer_placement)]
514 pub struct DebugVisualizerPlacement {
515     #[primary_span]
516     pub span: Span,
517 }
518
519 #[derive(Diagnostic)]
520 #[diag(passes::debug_visualizer_invalid)]
521 #[note(passes::note_1)]
522 #[note(passes::note_2)]
523 #[note(passes::note_3)]
524 pub struct DebugVisualizerInvalid {
525     #[primary_span]
526     pub span: Span,
527 }
528
529 #[derive(Diagnostic)]
530 #[diag(passes::rustc_allow_const_fn_unstable)]
531 pub struct RustcAllowConstFnUnstable {
532     #[primary_span]
533     pub attr_span: Span,
534     #[label]
535     pub span: Span,
536 }
537
538 #[derive(Diagnostic)]
539 #[diag(passes::rustc_std_internal_symbol)]
540 pub struct RustcStdInternalSymbol {
541     #[primary_span]
542     pub attr_span: Span,
543     #[label]
544     pub span: Span,
545 }
546
547 #[derive(Diagnostic)]
548 #[diag(passes::const_trait)]
549 pub struct ConstTrait {
550     #[primary_span]
551     pub attr_span: Span,
552 }
553
554 #[derive(Diagnostic)]
555 #[diag(passes::link_ordinal)]
556 pub struct LinkOrdinal {
557     #[primary_span]
558     pub attr_span: Span,
559 }
560
561 #[derive(Diagnostic)]
562 #[diag(passes::stability_promotable)]
563 pub struct StabilityPromotable {
564     #[primary_span]
565     pub attr_span: Span,
566 }
567
568 #[derive(LintDiagnostic)]
569 #[diag(passes::deprecated)]
570 pub struct Deprecated;
571
572 #[derive(LintDiagnostic)]
573 #[diag(passes::macro_use)]
574 pub struct MacroUse {
575     pub name: Symbol,
576 }
577
578 #[derive(LintDiagnostic)]
579 #[diag(passes::macro_export)]
580 pub struct MacroExport;
581
582 #[derive(LintDiagnostic)]
583 #[diag(passes::plugin_registrar)]
584 pub struct PluginRegistrar;
585
586 #[derive(Subdiagnostic)]
587 pub enum UnusedNote {
588     #[note(passes::unused_empty_lints_note)]
589     EmptyList { name: Symbol },
590     #[note(passes::unused_no_lints_note)]
591     NoLints { name: Symbol },
592     #[note(passes::unused_default_method_body_const_note)]
593     DefaultMethodBodyConst,
594 }
595
596 #[derive(LintDiagnostic)]
597 #[diag(passes::unused)]
598 pub struct Unused {
599     #[suggestion(applicability = "machine-applicable")]
600     pub attr_span: Span,
601     #[subdiagnostic]
602     pub note: UnusedNote,
603 }
604
605 #[derive(Diagnostic)]
606 #[diag(passes::non_exported_macro_invalid_attrs, code = "E0518")]
607 pub struct NonExportedMacroInvalidAttrs {
608     #[primary_span]
609     #[label]
610     pub attr_span: Span,
611 }
612
613 #[derive(LintDiagnostic)]
614 #[diag(passes::unused_duplicate)]
615 pub struct UnusedDuplicate {
616     #[suggestion(code = "", applicability = "machine-applicable")]
617     pub this: Span,
618     #[note]
619     pub other: Span,
620     #[warning]
621     pub warning: Option<()>,
622 }
623
624 #[derive(Diagnostic)]
625 #[diag(passes::unused_multiple)]
626 pub struct UnusedMultiple {
627     #[primary_span]
628     #[suggestion(code = "", applicability = "machine-applicable")]
629     pub this: Span,
630     #[note]
631     pub other: Span,
632     pub name: Symbol,
633 }
634
635 #[derive(Diagnostic)]
636 #[diag(passes::rustc_lint_opt_ty)]
637 pub struct RustcLintOptTy {
638     #[primary_span]
639     pub attr_span: Span,
640     #[label]
641     pub span: Span,
642 }
643
644 #[derive(Diagnostic)]
645 #[diag(passes::rustc_lint_opt_deny_field_access)]
646 pub struct RustcLintOptDenyFieldAccess {
647     #[primary_span]
648     pub attr_span: Span,
649     #[label]
650     pub span: Span,
651 }
652
653 #[derive(Diagnostic)]
654 #[diag(passes::collapse_debuginfo)]
655 pub struct CollapseDebuginfo {
656     #[primary_span]
657     pub attr_span: Span,
658     #[label]
659     pub defn_span: Span,
660 }