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