1 use rustc_errors::{Applicability, MultiSpan};
2 use rustc_macros::{LintDiagnostic, SessionDiagnostic, SessionSubdiagnostic};
3 use rustc_span::{Span, Symbol};
5 #[derive(LintDiagnostic)]
6 #[lint(passes::outer_crate_level_attr)]
7 pub struct OuterCrateLevelAttr;
9 #[derive(LintDiagnostic)]
10 #[lint(passes::inner_crate_level_attr)]
11 pub struct InnerCrateLevelAttr;
13 #[derive(LintDiagnostic)]
14 #[lint(passes::ignored_attr_with_macro)]
15 pub struct IgnoredAttrWithMacro<'a> {
19 #[derive(LintDiagnostic)]
20 #[lint(passes::ignored_attr)]
21 pub struct IgnoredAttr<'a> {
25 #[derive(LintDiagnostic)]
26 #[lint(passes::inline_ignored_function_prototype)]
27 pub struct IgnoredInlineAttrFnProto;
29 #[derive(LintDiagnostic)]
30 #[lint(passes::inline_ignored_constants)]
33 pub struct IgnoredInlineAttrConstants;
35 #[derive(SessionDiagnostic)]
36 #[error(passes::inline_not_fn_or_closure, code = "E0518")]
37 pub struct InlineNotFnOrClosure {
44 #[derive(LintDiagnostic)]
45 #[lint(passes::no_coverage_ignored_function_prototype)]
46 pub struct IgnoredNoCoverageFnProto;
48 #[derive(LintDiagnostic)]
49 #[lint(passes::no_coverage_propagate)]
50 pub struct IgnoredNoCoveragePropagate;
52 #[derive(LintDiagnostic)]
53 #[lint(passes::no_coverage_fn_defn)]
54 pub struct IgnoredNoCoverageFnDefn;
56 #[derive(SessionDiagnostic)]
57 #[error(passes::no_coverage_not_coverable, code = "E0788")]
58 pub struct IgnoredNoCoverageNotCoverable {
65 #[derive(SessionDiagnostic)]
66 #[error(passes::should_be_applied_to_fn)]
67 pub struct AttrShouldBeAppliedToFn {
74 #[derive(SessionDiagnostic)]
75 #[error(passes::naked_tracked_caller, code = "E0736")]
76 pub struct NakedTrackedCaller {
81 #[derive(SessionDiagnostic)]
82 #[error(passes::should_be_applied_to_fn, code = "E0739")]
83 pub struct TrackedCallerWrongLocation {
90 #[derive(SessionDiagnostic)]
91 #[error(passes::should_be_applied_to_struct_enum, code = "E0701")]
92 pub struct NonExhaustiveWrongLocation {
99 #[derive(SessionDiagnostic)]
100 #[error(passes::should_be_applied_to_trait)]
101 pub struct AttrShouldBeAppliedToTrait {
108 #[derive(LintDiagnostic)]
109 #[lint(passes::target_feature_on_statement)]
110 pub struct TargetFeatureOnStatement;
112 #[derive(SessionDiagnostic)]
113 #[error(passes::should_be_applied_to_static)]
114 pub struct AttrShouldBeAppliedToStatic {
121 #[derive(SessionDiagnostic)]
122 #[error(passes::doc_expect_str)]
123 pub struct DocExpectStr<'a> {
126 pub attr_name: &'a str,
129 #[derive(SessionDiagnostic)]
130 #[error(passes::doc_alias_empty)]
131 pub struct DocAliasEmpty<'a> {
134 pub attr_str: &'a str,
137 #[derive(SessionDiagnostic)]
138 #[error(passes::doc_alias_bad_char)]
139 pub struct DocAliasBadChar<'a> {
142 pub attr_str: &'a str,
146 #[derive(SessionDiagnostic)]
147 #[error(passes::doc_alias_start_end)]
148 pub struct DocAliasStartEnd<'a> {
151 pub attr_str: &'a str,
154 #[derive(SessionDiagnostic)]
155 #[error(passes::doc_alias_bad_location)]
156 pub struct DocAliasBadLocation<'a> {
159 pub attr_str: &'a str,
160 pub location: &'a str,
163 #[derive(SessionDiagnostic)]
164 #[error(passes::doc_alias_not_an_alias)]
165 pub struct DocAliasNotAnAlias<'a> {
168 pub attr_str: &'a str,
171 #[derive(LintDiagnostic)]
172 #[lint(passes::doc_alias_duplicated)]
173 pub struct DocAliasDuplicated {
175 pub first_defn: Span,
178 #[derive(SessionDiagnostic)]
179 #[error(passes::doc_alias_not_string_literal)]
180 pub struct DocAliasNotStringLiteral {
185 #[derive(SessionDiagnostic)]
186 #[error(passes::doc_alias_malformed)]
187 pub struct DocAliasMalformed {
192 #[derive(SessionDiagnostic)]
193 #[error(passes::doc_keyword_empty_mod)]
194 pub struct DocKeywordEmptyMod {
199 #[derive(SessionDiagnostic)]
200 #[error(passes::doc_keyword_not_mod)]
201 pub struct DocKeywordNotMod {
206 #[derive(SessionDiagnostic)]
207 #[error(passes::doc_keyword_invalid_ident)]
208 pub struct DocKeywordInvalidIdent {
211 pub doc_keyword: Symbol,
214 #[derive(SessionDiagnostic)]
215 #[error(passes::doc_fake_variadic_not_valid)]
216 pub struct DocFakeVariadicNotValid {
221 #[derive(SessionDiagnostic)]
222 #[error(passes::doc_keyword_only_impl)]
223 pub struct DocKeywordOnlyImpl {
228 #[derive(SessionDiagnostic)]
229 #[error(passes::doc_inline_conflict)]
231 pub struct DocKeywordConflict {
233 pub spans: MultiSpan,
236 #[derive(LintDiagnostic)]
237 #[lint(passes::doc_inline_only_use)]
239 pub struct DocInlineOnlyUse {
242 #[label(passes::not_a_use_item_label)]
243 pub item_span: Option<Span>,
246 #[derive(SessionDiagnostic)]
247 #[error(passes::doc_attr_not_crate_level)]
248 pub struct DocAttrNotCrateLevel<'a> {
251 pub attr_name: &'a str,
254 #[derive(LintDiagnostic)]
255 #[lint(passes::doc_test_unknown)]
256 pub struct DocTestUnknown {
260 #[derive(LintDiagnostic)]
261 #[lint(passes::doc_test_takes_list)]
262 pub struct DocTestTakesList;
264 #[derive(LintDiagnostic)]
265 #[lint(passes::doc_primitive)]
266 pub struct DocPrimitive;
268 #[derive(LintDiagnostic)]
269 #[lint(passes::doc_test_unknown_any)]
270 pub struct DocTestUnknownAny {
274 #[derive(LintDiagnostic)]
275 #[lint(passes::doc_test_unknown_spotlight)]
277 #[note(passes::no_op_note)]
278 pub struct DocTestUnknownSpotlight {
280 #[suggestion_short(applicability = "machine-applicable", code = "notable_trait")]
284 #[derive(LintDiagnostic)]
285 #[lint(passes::doc_test_unknown_include)]
286 pub struct DocTestUnknownInclude {
289 pub inner: &'static str,
290 #[suggestion(code = "#{inner}[doc = include_str!(\"{value}\")]")]
291 pub sugg: (Span, Applicability),
294 #[derive(LintDiagnostic)]
295 #[lint(passes::doc_invalid)]
296 pub struct DocInvalid;
298 #[derive(SessionDiagnostic)]
299 #[error(passes::pass_by_value)]
300 pub struct PassByValue {
307 #[derive(SessionDiagnostic)]
308 #[error(passes::allow_incoherent_impl)]
309 pub struct AllowIncoherentImpl {
316 #[derive(SessionDiagnostic)]
317 #[error(passes::has_incoherent_inherent_impl)]
318 pub struct HasIncoherentInherentImpl {
325 #[derive(LintDiagnostic)]
326 #[lint(passes::must_use_async)]
327 pub struct MustUseAsync {
332 #[derive(LintDiagnostic)]
333 #[lint(passes::must_use_no_effect)]
334 pub struct MustUseNoEffect {
335 pub article: &'static str,
336 pub target: rustc_hir::Target,
339 #[derive(SessionDiagnostic)]
340 #[error(passes::must_not_suspend)]
341 pub struct MustNotSuspend {
348 #[derive(LintDiagnostic)]
349 #[lint(passes::cold)]
356 #[derive(LintDiagnostic)]
357 #[lint(passes::link)]
361 pub span: Option<Span>,
364 #[derive(LintDiagnostic)]
365 #[lint(passes::link_name)]
367 pub struct LinkName<'a> {
369 pub attr_span: Option<Span>,
375 #[derive(SessionDiagnostic)]
376 #[error(passes::no_link)]
384 #[derive(SessionDiagnostic)]
385 #[error(passes::export_name)]
386 pub struct ExportName {
393 #[derive(SessionDiagnostic)]
394 #[error(passes::rustc_layout_scalar_valid_range_not_struct)]
395 pub struct RustcLayoutScalarValidRangeNotStruct {
402 #[derive(SessionDiagnostic)]
403 #[error(passes::rustc_layout_scalar_valid_range_arg)]
404 pub struct RustcLayoutScalarValidRangeArg {
409 #[derive(SessionDiagnostic)]
410 #[error(passes::rustc_legacy_const_generics_only)]
411 pub struct RustcLegacyConstGenericsOnly {
415 pub param_span: Span,
418 #[derive(SessionDiagnostic)]
419 #[error(passes::rustc_legacy_const_generics_index)]
420 pub struct RustcLegacyConstGenericsIndex {
424 pub generics_span: Span,
427 #[derive(SessionDiagnostic)]
428 #[error(passes::rustc_legacy_const_generics_index_exceed)]
429 pub struct RustcLegacyConstGenericsIndexExceed {
433 pub arg_count: usize,
436 #[derive(SessionDiagnostic)]
437 #[error(passes::rustc_legacy_const_generics_index_negative)]
438 pub struct RustcLegacyConstGenericsIndexNegative {
440 pub invalid_args: Vec<Span>,
443 #[derive(SessionDiagnostic)]
444 #[error(passes::rustc_dirty_clean)]
445 pub struct RustcDirtyClean {
450 #[derive(LintDiagnostic)]
451 #[lint(passes::link_section)]
453 pub struct LinkSection {
458 #[derive(LintDiagnostic)]
459 #[lint(passes::no_mangle_foreign)]
462 pub struct NoMangleForeign {
465 #[suggestion(applicability = "machine-applicable")]
467 pub foreign_item_kind: &'static str,
470 #[derive(LintDiagnostic)]
471 #[lint(passes::no_mangle)]
473 pub struct NoMangle {
478 #[derive(SessionDiagnostic)]
479 #[error(passes::repr_ident, code = "E0565")]
480 pub struct ReprIdent {
485 #[derive(LintDiagnostic)]
486 #[lint(passes::repr_conflicting, code = "E0566")]
487 pub struct ReprConflicting;
489 #[derive(SessionDiagnostic)]
490 #[error(passes::used_static)]
491 pub struct UsedStatic {
496 #[derive(SessionDiagnostic)]
497 #[error(passes::used_compiler_linker)]
498 pub struct UsedCompilerLinker {
500 pub spans: Vec<Span>,
503 #[derive(SessionDiagnostic)]
504 #[error(passes::allow_internal_unstable)]
505 pub struct AllowInternalUnstable {
512 #[derive(SessionDiagnostic)]
513 #[error(passes::debug_visualizer_placement)]
514 pub struct DebugVisualizerPlacement {
519 #[derive(SessionDiagnostic)]
520 #[error(passes::debug_visualizer_invalid)]
521 #[note(passes::note_1)]
522 #[note(passes::note_2)]
523 #[note(passes::note_3)]
524 pub struct DebugVisualizerInvalid {
529 #[derive(SessionDiagnostic)]
530 #[error(passes::rustc_allow_const_fn_unstable)]
531 pub struct RustcAllowConstFnUnstable {
538 #[derive(SessionDiagnostic)]
539 #[error(passes::rustc_std_internal_symbol)]
540 pub struct RustcStdInternalSymbol {
547 #[derive(SessionDiagnostic)]
548 #[error(passes::const_trait)]
549 pub struct ConstTrait {
554 #[derive(SessionDiagnostic)]
555 #[error(passes::stability_promotable)]
556 pub struct StabilityPromotable {
561 #[derive(LintDiagnostic)]
562 #[lint(passes::deprecated)]
563 pub struct Deprecated;
565 #[derive(LintDiagnostic)]
566 #[lint(passes::macro_use)]
567 pub struct MacroUse {
571 #[derive(LintDiagnostic)]
572 #[lint(passes::macro_export)]
573 pub struct MacroExport;
575 #[derive(LintDiagnostic)]
576 #[lint(passes::plugin_registrar)]
577 pub struct PluginRegistrar;
579 #[derive(SessionSubdiagnostic)]
580 pub enum UnusedNote {
581 #[note(passes::unused_empty_lints_note)]
582 EmptyList { name: Symbol },
583 #[note(passes::unused_no_lints_note)]
584 NoLints { name: Symbol },
585 #[note(passes::unused_default_method_body_const_note)]
586 DefaultMethodBodyConst,
589 #[derive(LintDiagnostic)]
590 #[lint(passes::unused)]
592 #[suggestion(applicability = "machine-applicable")]
595 pub note: UnusedNote,
598 #[derive(SessionDiagnostic)]
599 #[error(passes::non_exported_macro_invalid_attrs, code = "E0518")]
600 pub struct NonExportedMacroInvalidAttrs {
606 #[derive(LintDiagnostic)]
607 #[lint(passes::unused_duplicate)]
608 pub struct UnusedDuplicate {
610 #[suggestion(code = "", applicability = "machine-applicable")]
615 pub warning: Option<()>,
618 #[derive(SessionDiagnostic)]
619 #[error(passes::unused_multiple)]
620 pub struct UnusedMultiple {
622 #[suggestion(code = "", applicability = "machine-applicable")]
629 #[derive(SessionDiagnostic)]
630 #[error(passes::rustc_lint_opt_ty)]
631 pub struct RustcLintOptTy {
638 #[derive(SessionDiagnostic)]
639 #[error(passes::rustc_lint_opt_deny_field_access)]
640 pub struct RustcLintOptDenyFieldAccess {