rustc_lint/
lib.rs

1//! Lints, aka compiler warnings.
2//!
3//! A 'lint' check is a kind of miscellaneous constraint that a user _might_
4//! want to enforce, but might reasonably want to permit as well, on a
5//! module-by-module basis. They contrast with static constraints enforced by
6//! other phases of the compiler, which are generally required to hold in order
7//! to compile the program at all.
8//!
9//! Most lints can be written as [`LintPass`] instances. These run after
10//! all other analyses. The `LintPass`es built into rustc are defined
11//! within [rustc_session::lint::builtin],
12//! which has further comments on how to add such a lint.
13//! rustc can also load external lint plugins, as is done for Clippy.
14//!
15//! See <https://rustc-dev-guide.rust-lang.org/diagnostics.html> for an
16//! overview of how lints are implemented.
17//!
18//! ## Note
19//!
20//! This API is completely unstable and subject to change.
21
22// tidy-alphabetical-start
23#![allow(internal_features)]
24#![cfg_attr(bootstrap, feature(array_windows))]
25#![feature(assert_matches)]
26#![feature(box_patterns)]
27#![feature(if_let_guard)]
28#![feature(iter_order_by)]
29#![feature(rustc_attrs)]
30#![feature(try_blocks)]
31// tidy-alphabetical-end
32
33mod async_closures;
34mod async_fn_in_trait;
35mod autorefs;
36pub mod builtin;
37mod context;
38mod dangling;
39mod default_could_be_derived;
40mod deref_into_dyn_supertrait;
41mod drop_forget_useless;
42mod early;
43mod enum_intrinsics_non_enums;
44mod errors;
45mod expect;
46mod for_loops_over_fallibles;
47mod foreign_modules;
48mod function_cast_as_integer;
49mod if_let_rescope;
50mod impl_trait_overcaptures;
51mod interior_mutable_consts;
52mod internal;
53mod invalid_from_utf8;
54mod late;
55mod let_underscore;
56mod levels;
57pub mod lifetime_syntax;
58mod lints;
59mod macro_expr_fragment_specifier_2024_migration;
60mod map_unit_fn;
61mod multiple_supertrait_upcastable;
62mod non_ascii_idents;
63mod non_fmt_panic;
64mod non_local_def;
65mod nonstandard_style;
66mod noop_method_call;
67mod opaque_hidden_inferred_bound;
68mod pass_by_value;
69mod passes;
70mod precedence;
71mod ptr_nulls;
72mod redundant_semicolon;
73mod reference_casting;
74mod shadowed_into_iter;
75mod static_mut_refs;
76mod traits;
77mod transmute;
78mod types;
79mod unit_bindings;
80mod unqualified_local_imports;
81mod unused;
82mod utils;
83
84use async_closures::AsyncClosureUsage;
85use async_fn_in_trait::AsyncFnInTrait;
86use autorefs::*;
87use builtin::*;
88use dangling::*;
89use default_could_be_derived::DefaultCouldBeDerived;
90use deref_into_dyn_supertrait::*;
91use drop_forget_useless::*;
92use enum_intrinsics_non_enums::EnumIntrinsicsNonEnums;
93use for_loops_over_fallibles::*;
94use function_cast_as_integer::*;
95use if_let_rescope::IfLetRescope;
96use impl_trait_overcaptures::ImplTraitOvercaptures;
97use interior_mutable_consts::*;
98use internal::*;
99use invalid_from_utf8::*;
100use let_underscore::*;
101use lifetime_syntax::*;
102use macro_expr_fragment_specifier_2024_migration::*;
103use map_unit_fn::*;
104use multiple_supertrait_upcastable::*;
105use non_ascii_idents::*;
106use non_fmt_panic::NonPanicFmt;
107use non_local_def::*;
108use nonstandard_style::*;
109use noop_method_call::*;
110use opaque_hidden_inferred_bound::*;
111use pass_by_value::*;
112use precedence::*;
113use ptr_nulls::*;
114use redundant_semicolon::*;
115use reference_casting::*;
116use rustc_hir::def_id::LocalModDefId;
117use rustc_middle::query::Providers;
118use rustc_middle::ty::TyCtxt;
119use shadowed_into_iter::ShadowedIntoIter;
120pub use shadowed_into_iter::{ARRAY_INTO_ITER, BOXED_SLICE_INTO_ITER};
121use static_mut_refs::*;
122use traits::*;
123use transmute::CheckTransmutes;
124use types::*;
125use unit_bindings::*;
126use unqualified_local_imports::*;
127use unused::*;
128
129#[rustfmt::skip]
130pub use builtin::{MissingDoc, SoftLints};
131pub use context::{CheckLintNameResult, EarlyContext, LateContext, LintContext, LintStore};
132pub use early::diagnostics::{decorate_attribute_lint, decorate_builtin_lint};
133pub use early::{EarlyCheckNode, check_ast_node};
134pub use late::{check_crate, late_lint_mod, unerased_lint_store};
135pub use levels::LintLevelsBuilder;
136pub use passes::{EarlyLintPass, LateLintPass};
137pub use rustc_errors::BufferedEarlyLint;
138pub use rustc_session::lint::Level::{self, *};
139pub use rustc_session::lint::{FutureIncompatibleInfo, Lint, LintId, LintPass, LintVec};
140
141rustc_fluent_macro::fluent_messages! { "../messages.ftl" }
142
143pub fn provide(providers: &mut Providers) {
144    levels::provide(providers);
145    expect::provide(providers);
146    foreign_modules::provide(providers);
147    *providers = Providers { lint_mod, ..*providers };
148}
149
150fn lint_mod(tcx: TyCtxt<'_>, module_def_id: LocalModDefId) {
151    late_lint_mod(tcx, module_def_id, BuiltinCombinedModuleLateLintPass::new());
152}
153
154early_lint_methods!(
155    declare_combined_early_lint_pass,
156    [
157        pub BuiltinCombinedPreExpansionLintPass,
158        [
159            KeywordIdents: KeywordIdents,
160        ]
161    ]
162);
163
164early_lint_methods!(
165    declare_combined_early_lint_pass,
166    [
167        pub BuiltinCombinedEarlyLintPass,
168        [
169            UnusedParens: UnusedParens::default(),
170            UnusedBraces: UnusedBraces,
171            UnusedImportBraces: UnusedImportBraces,
172            UnsafeCode: UnsafeCode,
173            SpecialModuleName: SpecialModuleName,
174            AnonymousParameters: AnonymousParameters,
175            EllipsisInclusiveRangePatterns: EllipsisInclusiveRangePatterns::default(),
176            NonCamelCaseTypes: NonCamelCaseTypes,
177            WhileTrue: WhileTrue,
178            NonAsciiIdents: NonAsciiIdents,
179            IncompleteInternalFeatures: IncompleteInternalFeatures,
180            RedundantSemicolons: RedundantSemicolons,
181            UnusedDocComment: UnusedDocComment,
182            Expr2024: Expr2024,
183            Precedence: Precedence,
184            DoubleNegations: DoubleNegations,
185        ]
186    ]
187);
188
189late_lint_methods!(
190    declare_combined_late_lint_pass,
191    [
192        BuiltinCombinedModuleLateLintPass,
193        [
194            ForLoopsOverFallibles: ForLoopsOverFallibles,
195            DefaultCouldBeDerived: DefaultCouldBeDerived,
196            DerefIntoDynSupertrait: DerefIntoDynSupertrait,
197            DropForgetUseless: DropForgetUseless,
198            ImproperCTypesLint: ImproperCTypesLint,
199            InvalidFromUtf8: InvalidFromUtf8,
200            VariantSizeDifferences: VariantSizeDifferences,
201            PathStatements: PathStatements,
202            LetUnderscore: LetUnderscore,
203            InvalidReferenceCasting: InvalidReferenceCasting,
204            ImplicitAutorefs: ImplicitAutorefs,
205            // Depends on referenced function signatures in expressions
206            UnusedResults: UnusedResults,
207            UnitBindings: UnitBindings,
208            NonUpperCaseGlobals: NonUpperCaseGlobals,
209            NonShorthandFieldPatterns: NonShorthandFieldPatterns,
210            UnusedAllocation: UnusedAllocation,
211            // Depends on types used in type definitions
212            MissingCopyImplementations: MissingCopyImplementations,
213            // Depends on referenced function signatures in expressions
214            PtrNullChecks: PtrNullChecks,
215            MutableTransmutes: MutableTransmutes,
216            TypeAliasBounds: TypeAliasBounds,
217            TrivialConstraints: TrivialConstraints,
218            TypeLimits: TypeLimits::new(),
219            NonSnakeCase: NonSnakeCase,
220            InvalidNoMangleItems: InvalidNoMangleItems,
221            // Depends on effective visibilities
222            UnreachablePub: UnreachablePub,
223            ExplicitOutlivesRequirements: ExplicitOutlivesRequirements,
224            InvalidValue: InvalidValue,
225            DerefNullPtr: DerefNullPtr,
226            UnstableFeatures: UnstableFeatures,
227            UngatedAsyncFnTrackCaller: UngatedAsyncFnTrackCaller,
228            ShadowedIntoIter: ShadowedIntoIter,
229            DropTraitConstraints: DropTraitConstraints,
230            DanglingPointers: DanglingPointers,
231            NonPanicFmt: NonPanicFmt,
232            NoopMethodCall: NoopMethodCall,
233            EnumIntrinsicsNonEnums: EnumIntrinsicsNonEnums,
234            InvalidAtomicOrdering: InvalidAtomicOrdering,
235            AsmLabels: AsmLabels,
236            OpaqueHiddenInferredBound: OpaqueHiddenInferredBound,
237            MultipleSupertraitUpcastable: MultipleSupertraitUpcastable,
238            MapUnitFn: MapUnitFn,
239            MissingDebugImplementations: MissingDebugImplementations,
240            MissingDoc: MissingDoc,
241            AsyncClosureUsage: AsyncClosureUsage,
242            AsyncFnInTrait: AsyncFnInTrait,
243            NonLocalDefinitions: NonLocalDefinitions::default(),
244            InteriorMutableConsts: InteriorMutableConsts,
245            ImplTraitOvercaptures: ImplTraitOvercaptures,
246            IfLetRescope: IfLetRescope::default(),
247            StaticMutRefs: StaticMutRefs,
248            UnqualifiedLocalImports: UnqualifiedLocalImports,
249            FunctionCastsAsInteger: FunctionCastsAsInteger,
250            CheckTransmutes: CheckTransmutes,
251            LifetimeSyntax: LifetimeSyntax,
252        ]
253    ]
254);
255
256pub fn new_lint_store(internal_lints: bool) -> LintStore {
257    let mut lint_store = LintStore::new();
258
259    register_builtins(&mut lint_store);
260    if internal_lints {
261        register_internals(&mut lint_store);
262    }
263
264    lint_store
265}
266
267/// Tell the `LintStore` about all the built-in lints (the ones
268/// defined in this crate and the ones defined in
269/// `rustc_session::lint::builtin`).
270fn register_builtins(store: &mut LintStore) {
271    macro_rules! add_lint_group {
272        ($name:expr, $($lint:ident),*) => (
273            store.register_group(false, $name, None, vec![$(LintId::of($lint)),*]);
274        )
275    }
276
277    store.register_lints(&BuiltinCombinedPreExpansionLintPass::get_lints());
278    store.register_lints(&BuiltinCombinedEarlyLintPass::get_lints());
279    store.register_lints(&BuiltinCombinedModuleLateLintPass::get_lints());
280    store.register_lints(&foreign_modules::get_lints());
281    store.register_lints(&HardwiredLints::lint_vec());
282
283    add_lint_group!(
284        "nonstandard_style",
285        NON_CAMEL_CASE_TYPES,
286        NON_SNAKE_CASE,
287        NON_UPPER_CASE_GLOBALS
288    );
289
290    add_lint_group!(
291        "unused",
292        UNUSED_IMPORTS,
293        UNUSED_VARIABLES,
294        UNUSED_VISIBILITIES,
295        UNUSED_ASSIGNMENTS,
296        DEAD_CODE,
297        UNUSED_MUT,
298        UNREACHABLE_CODE,
299        UNREACHABLE_PATTERNS,
300        UNUSED_MUST_USE,
301        UNUSED_UNSAFE,
302        PATH_STATEMENTS,
303        UNUSED_ATTRIBUTES,
304        UNUSED_MACROS,
305        UNUSED_MACRO_RULES,
306        UNUSED_ALLOCATION,
307        UNUSED_DOC_COMMENTS,
308        UNUSED_EXTERN_CRATES,
309        UNUSED_FEATURES,
310        UNUSED_LABELS,
311        UNUSED_PARENS,
312        UNUSED_BRACES,
313        REDUNDANT_SEMICOLONS,
314        MAP_UNIT_FN
315    );
316
317    add_lint_group!("let_underscore", LET_UNDERSCORE_DROP, LET_UNDERSCORE_LOCK);
318
319    add_lint_group!(
320        "rust_2018_idioms",
321        BARE_TRAIT_OBJECTS,
322        UNUSED_EXTERN_CRATES,
323        ELLIPSIS_INCLUSIVE_RANGE_PATTERNS,
324        ELIDED_LIFETIMES_IN_PATHS,
325        EXPLICIT_OUTLIVES_REQUIREMENTS // FIXME(#52665, #47816) not always applicable and not all
326                                       // macros are ready for this yet.
327                                       // UNREACHABLE_PUB,
328
329                                       // FIXME macro crates are not up for this yet, too much
330                                       // breakage is seen if we try to encourage this lint.
331                                       // MACRO_USE_EXTERN_CRATE
332    );
333
334    add_lint_group!("keyword_idents", KEYWORD_IDENTS_2018, KEYWORD_IDENTS_2024);
335
336    add_lint_group!(
337        "refining_impl_trait",
338        REFINING_IMPL_TRAIT_REACHABLE,
339        REFINING_IMPL_TRAIT_INTERNAL
340    );
341
342    add_lint_group!("deprecated_safe", DEPRECATED_SAFE_2024);
343
344    add_lint_group!(
345        "unknown_or_malformed_diagnostic_attributes",
346        MALFORMED_DIAGNOSTIC_ATTRIBUTES,
347        MALFORMED_DIAGNOSTIC_FORMAT_LITERALS,
348        MISPLACED_DIAGNOSTIC_ATTRIBUTES,
349        UNKNOWN_DIAGNOSTIC_ATTRIBUTES
350    );
351
352    // Register renamed and removed lints.
353    store.register_renamed("single_use_lifetime", "single_use_lifetimes");
354    store.register_renamed("elided_lifetime_in_path", "elided_lifetimes_in_paths");
355    store.register_renamed("bare_trait_object", "bare_trait_objects");
356    store.register_renamed("unstable_name_collision", "unstable_name_collisions");
357    store.register_renamed("unused_doc_comment", "unused_doc_comments");
358    store.register_renamed("async_idents", "keyword_idents_2018");
359    store.register_renamed("exceeding_bitshifts", "arithmetic_overflow");
360    store.register_renamed("redundant_semicolon", "redundant_semicolons");
361    store.register_renamed("overlapping_patterns", "overlapping_range_endpoints");
362    store.register_renamed("disjoint_capture_migration", "rust_2021_incompatible_closure_captures");
363    store.register_renamed("or_patterns_back_compat", "rust_2021_incompatible_or_patterns");
364    store.register_renamed("non_fmt_panic", "non_fmt_panics");
365    store.register_renamed("unused_tuple_struct_fields", "dead_code");
366    store.register_renamed("static_mut_ref", "static_mut_refs");
367    store.register_renamed("temporary_cstring_as_ptr", "dangling_pointers_from_temporaries");
368    store.register_renamed("elided_named_lifetimes", "mismatched_lifetime_syntaxes");
369    store.register_renamed(
370        "repr_transparent_external_private_fields",
371        "repr_transparent_non_zst_fields",
372    );
373
374    // These were moved to tool lints, but rustc still sees them when compiling normally, before
375    // tool lints are registered, so `check_tool_name_for_backwards_compat` doesn't work. Use
376    // `register_removed` explicitly.
377    const RUSTDOC_LINTS: &[&str] = &[
378        "broken_intra_doc_links",
379        "private_intra_doc_links",
380        "missing_crate_level_docs",
381        "missing_doc_code_examples",
382        "private_doc_tests",
383        "invalid_codeblock_attributes",
384        "invalid_html_tags",
385        "non_autolinks",
386    ];
387    for rustdoc_lint in RUSTDOC_LINTS {
388        store.register_ignored(rustdoc_lint);
389    }
390    store.register_removed(
391        "intra_doc_link_resolution_failure",
392        "use `rustdoc::broken_intra_doc_links` instead",
393    );
394    store.register_removed("rustdoc", "use `rustdoc::all` instead");
395
396    store.register_removed("unknown_features", "replaced by an error");
397    store.register_removed("unsigned_negation", "replaced by negate_unsigned feature gate");
398    store.register_removed("negate_unsigned", "cast a signed value instead");
399    store.register_removed("raw_pointer_derive", "using derive with raw pointers is ok");
400    // Register lint group aliases.
401    store.register_group_alias("nonstandard_style", "bad_style");
402    // This was renamed to `raw_pointer_derive`, which was then removed,
403    // so it is also considered removed.
404    store.register_removed("raw_pointer_deriving", "using derive with raw pointers is ok");
405    store.register_removed("drop_with_repr_extern", "drop flags have been removed");
406    store.register_removed("fat_ptr_transmutes", "was accidentally removed back in 2014");
407    store.register_removed("deprecated_attr", "use `deprecated` instead");
408    store.register_removed(
409        "transmute_from_fn_item_types",
410        "always cast functions before transmuting them",
411    );
412    store.register_removed(
413        "hr_lifetime_in_assoc_type",
414        "converted into hard error, see issue #33685 \
415         <https://github.com/rust-lang/rust/issues/33685> for more information",
416    );
417    store.register_removed(
418        "inaccessible_extern_crate",
419        "converted into hard error, see issue #36886 \
420         <https://github.com/rust-lang/rust/issues/36886> for more information",
421    );
422    store.register_removed(
423        "super_or_self_in_global_path",
424        "converted into hard error, see issue #36888 \
425         <https://github.com/rust-lang/rust/issues/36888> for more information",
426    );
427    store.register_removed(
428        "overlapping_inherent_impls",
429        "converted into hard error, see issue #36889 \
430         <https://github.com/rust-lang/rust/issues/36889> for more information",
431    );
432    store.register_removed(
433        "illegal_floating_point_constant_pattern",
434        "converted into hard error, see issue #36890 \
435         <https://github.com/rust-lang/rust/issues/36890> for more information",
436    );
437    store.register_removed(
438        "illegal_struct_or_enum_constant_pattern",
439        "converted into hard error, see issue #36891 \
440         <https://github.com/rust-lang/rust/issues/36891> for more information",
441    );
442    store.register_removed(
443        "lifetime_underscore",
444        "converted into hard error, see issue #36892 \
445         <https://github.com/rust-lang/rust/issues/36892> for more information",
446    );
447    store.register_removed(
448        "extra_requirement_in_impl",
449        "converted into hard error, see issue #37166 \
450         <https://github.com/rust-lang/rust/issues/37166> for more information",
451    );
452    store.register_removed(
453        "legacy_imports",
454        "converted into hard error, see issue #38260 \
455         <https://github.com/rust-lang/rust/issues/38260> for more information",
456    );
457    store.register_removed(
458        "coerce_never",
459        "converted into hard error, see issue #48950 \
460         <https://github.com/rust-lang/rust/issues/48950> for more information",
461    );
462    store.register_removed(
463        "resolve_trait_on_defaulted_unit",
464        "converted into hard error, see issue #48950 \
465         <https://github.com/rust-lang/rust/issues/48950> for more information",
466    );
467    store.register_removed(
468        "private_no_mangle_fns",
469        "no longer a warning, `#[no_mangle]` functions always exported",
470    );
471    store.register_removed(
472        "private_no_mangle_statics",
473        "no longer a warning, `#[no_mangle]` statics always exported",
474    );
475    store.register_removed("bad_repr", "replaced with a generic attribute input check");
476    store.register_removed(
477        "duplicate_matcher_binding_name",
478        "converted into hard error, see issue #57742 \
479         <https://github.com/rust-lang/rust/issues/57742> for more information",
480    );
481    store.register_removed(
482        "incoherent_fundamental_impls",
483        "converted into hard error, see issue #46205 \
484         <https://github.com/rust-lang/rust/issues/46205> for more information",
485    );
486    store.register_removed(
487        "legacy_constructor_visibility",
488        "converted into hard error, see issue #39207 \
489         <https://github.com/rust-lang/rust/issues/39207> for more information",
490    );
491    store.register_removed(
492        "legacy_directory_ownership",
493        "converted into hard error, see issue #37872 \
494         <https://github.com/rust-lang/rust/issues/37872> for more information",
495    );
496    store.register_removed(
497        "safe_extern_statics",
498        "converted into hard error, see issue #36247 \
499         <https://github.com/rust-lang/rust/issues/36247> for more information",
500    );
501    store.register_removed(
502        "parenthesized_params_in_types_and_modules",
503        "converted into hard error, see issue #42238 \
504         <https://github.com/rust-lang/rust/issues/42238> for more information",
505    );
506    store.register_removed(
507        "duplicate_macro_exports",
508        "converted into hard error, see issue #35896 \
509         <https://github.com/rust-lang/rust/issues/35896> for more information",
510    );
511    store.register_removed(
512        "nested_impl_trait",
513        "converted into hard error, see issue #59014 \
514         <https://github.com/rust-lang/rust/issues/59014> for more information",
515    );
516    store.register_removed("plugin_as_library", "plugins have been deprecated and retired");
517    store.register_removed(
518        "unsupported_naked_functions",
519        "converted into hard error, see RFC 2972 \
520         <https://github.com/rust-lang/rfcs/blob/master/text/2972-constrained-naked.md> for more information",
521    );
522    store.register_removed(
523        "mutable_borrow_reservation_conflict",
524        "now allowed, see issue #59159 \
525         <https://github.com/rust-lang/rust/issues/59159> for more information",
526    );
527    store.register_removed(
528        "const_err",
529        "converted into hard error, see issue #71800 \
530         <https://github.com/rust-lang/rust/issues/71800> for more information",
531    );
532    store.register_removed(
533        "safe_packed_borrows",
534        "converted into hard error, see issue #82523 \
535         <https://github.com/rust-lang/rust/issues/82523> for more information",
536    );
537    store.register_removed(
538        "unaligned_references",
539        "converted into hard error, see issue #82523 \
540         <https://github.com/rust-lang/rust/issues/82523> for more information",
541    );
542    store.register_removed(
543        "private_in_public",
544        "replaced with another group of lints, see RFC \
545         <https://rust-lang.github.io/rfcs/2145-type-privacy.html> for more information",
546    );
547    store.register_removed(
548        "invalid_alignment",
549        "converted into hard error, see PR #104616 \
550         <https://github.com/rust-lang/rust/pull/104616> for more information",
551    );
552    store.register_removed(
553        "implied_bounds_entailment",
554        "converted into hard error, see PR #117984 \
555        <https://github.com/rust-lang/rust/pull/117984> for more information",
556    );
557    store.register_removed(
558        "coinductive_overlap_in_coherence",
559        "converted into hard error, see PR #118649 \
560         <https://github.com/rust-lang/rust/pull/118649> for more information",
561    );
562    store.register_removed(
563        "illegal_floating_point_literal_pattern",
564        "no longer a warning, float patterns behave the same as `==`",
565    );
566    store.register_removed(
567        "nontrivial_structural_match",
568        "no longer needed, see RFC #3535 \
569         <https://rust-lang.github.io/rfcs/3535-constants-in-patterns.html> for more information",
570    );
571    store.register_removed(
572        "suspicious_auto_trait_impls",
573        "no longer needed, see issue #93367 \
574         <https://github.com/rust-lang/rust/issues/93367> for more information",
575    );
576    store.register_removed(
577        "const_patterns_without_partial_eq",
578        "converted into hard error, see RFC #3535 \
579         <https://rust-lang.github.io/rfcs/3535-constants-in-patterns.html> for more information",
580    );
581    store.register_removed(
582        "indirect_structural_match",
583        "converted into hard error, see RFC #3535 \
584         <https://rust-lang.github.io/rfcs/3535-constants-in-patterns.html> for more information",
585    );
586    store.register_removed(
587        "deprecated_cfg_attr_crate_type_name",
588        "converted into hard error, see issue #91632 \
589         <https://github.com/rust-lang/rust/issues/91632> for more information",
590    );
591    store.register_removed(
592        "pointer_structural_match",
593        "converted into hard error, see RFC #3535 \
594         <https://rust-lang.github.io/rfcs/3535-constants-in-patterns.html> for more information",
595    );
596    store.register_removed(
597        "box_pointers",
598        "it does not detect other kinds of allocations, and existed only for historical reasons",
599    );
600    store.register_removed(
601        "byte_slice_in_packed_struct_with_derive",
602        "converted into hard error, see issue #107457 \
603         <https://github.com/rust-lang/rust/issues/107457> for more information",
604    );
605    store.register_removed("writes_through_immutable_pointer", "converted into hard error");
606    store.register_removed(
607        "const_eval_mutable_ptr_in_final_value",
608        "partially allowed now, otherwise turned into a hard error",
609    );
610    store.register_removed(
611        "where_clauses_object_safety",
612        "converted into hard error, see PR #125380 \
613         <https://github.com/rust-lang/rust/pull/125380> for more information",
614    );
615    store.register_removed(
616        "cenum_impl_drop_cast",
617        "converted into hard error, \
618         see <https://github.com/rust-lang/rust/issues/73333> for more information",
619    );
620    store.register_removed(
621        "ptr_cast_add_auto_to_object",
622        "converted into hard error, see issue #127323 \
623         <https://github.com/rust-lang/rust/issues/127323> for more information",
624    );
625    store.register_removed("unsupported_fn_ptr_calling_conventions", "converted into hard error");
626    store.register_removed(
627        "undefined_naked_function_abi",
628        "converted into hard error, see PR #139001 \
629         <https://github.com/rust-lang/rust/issues/139001> for more information",
630    );
631    store.register_removed(
632        "abi_unsupported_vector_types",
633        "converted into hard error, \
634         see <https://github.com/rust-lang/rust/issues/116558> for more information",
635    );
636    store.register_removed(
637        "missing_fragment_specifier",
638        "converted into hard error, \
639         see <https://github.com/rust-lang/rust/issues/40107> for more information",
640    );
641    store.register_removed("wasm_c_abi", "the wasm C ABI has been fixed");
642}
643
644fn register_internals(store: &mut LintStore) {
645    store.register_lints(&LintPassImpl::lint_vec());
646    store.register_early_pass(|| Box::new(LintPassImpl));
647    store.register_lints(&DefaultHashTypes::lint_vec());
648    store.register_late_mod_pass(|_| Box::new(DefaultHashTypes));
649    store.register_lints(&QueryStability::lint_vec());
650    store.register_late_mod_pass(|_| Box::new(QueryStability));
651    store.register_lints(&TyTyKind::lint_vec());
652    store.register_late_mod_pass(|_| Box::new(TyTyKind));
653    store.register_lints(&TypeIr::lint_vec());
654    store.register_late_mod_pass(|_| Box::new(TypeIr));
655    store.register_lints(&Diagnostics::lint_vec());
656    store.register_late_mod_pass(|_| Box::new(Diagnostics));
657    store.register_lints(&BadOptAccess::lint_vec());
658    store.register_late_mod_pass(|_| Box::new(BadOptAccess));
659    store.register_lints(&PassByValue::lint_vec());
660    store.register_late_mod_pass(|_| Box::new(PassByValue));
661    store.register_lints(&SpanUseEqCtxt::lint_vec());
662    store.register_late_mod_pass(|_| Box::new(SpanUseEqCtxt));
663    store.register_lints(&SymbolInternStringLiteral::lint_vec());
664    store.register_late_mod_pass(|_| Box::new(SymbolInternStringLiteral));
665    store.register_lints(&ImplicitSysrootCrateImport::lint_vec());
666    store.register_early_pass(|| Box::new(ImplicitSysrootCrateImport));
667    // FIXME(davidtwco): deliberately do not include `UNTRANSLATABLE_DIAGNOSTIC` and
668    // `DIAGNOSTIC_OUTSIDE_OF_IMPL` here because `-Wrustc::internal` is provided to every crate and
669    // these lints will trigger all of the time - change this once migration to diagnostic structs
670    // and translation is completed
671    store.register_group(
672        false,
673        "rustc::internal",
674        None,
675        vec![
676            LintId::of(DEFAULT_HASH_TYPES),
677            LintId::of(POTENTIAL_QUERY_INSTABILITY),
678            LintId::of(UNTRACKED_QUERY_INFORMATION),
679            LintId::of(USAGE_OF_TY_TYKIND),
680            LintId::of(PASS_BY_VALUE),
681            LintId::of(LINT_PASS_IMPL_WITHOUT_MACRO),
682            LintId::of(USAGE_OF_QUALIFIED_TY),
683            LintId::of(NON_GLOB_IMPORT_OF_TYPE_IR_INHERENT),
684            LintId::of(USAGE_OF_TYPE_IR_INHERENT),
685            LintId::of(USAGE_OF_TYPE_IR_TRAITS),
686            LintId::of(BAD_OPT_ACCESS),
687            LintId::of(SPAN_USE_EQ_CTXT),
688            LintId::of(DIRECT_USE_OF_RUSTC_TYPE_IR),
689            LintId::of(IMPLICIT_SYSROOT_CRATE_IMPORT),
690        ],
691    );
692}
693
694#[cfg(test)]
695mod tests;