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#![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_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_ASSIGNMENTS,
295        DEAD_CODE,
296        UNUSED_MUT,
297        UNREACHABLE_CODE,
298        UNREACHABLE_PATTERNS,
299        UNUSED_MUST_USE,
300        UNUSED_UNSAFE,
301        PATH_STATEMENTS,
302        UNUSED_ATTRIBUTES,
303        UNUSED_MACROS,
304        UNUSED_MACRO_RULES,
305        UNUSED_ALLOCATION,
306        UNUSED_DOC_COMMENTS,
307        UNUSED_EXTERN_CRATES,
308        UNUSED_FEATURES,
309        UNUSED_LABELS,
310        UNUSED_PARENS,
311        UNUSED_BRACES,
312        REDUNDANT_SEMICOLONS,
313        MAP_UNIT_FN
314    );
315
316    add_lint_group!("let_underscore", LET_UNDERSCORE_DROP, LET_UNDERSCORE_LOCK);
317
318    add_lint_group!(
319        "rust_2018_idioms",
320        BARE_TRAIT_OBJECTS,
321        UNUSED_EXTERN_CRATES,
322        ELLIPSIS_INCLUSIVE_RANGE_PATTERNS,
323        ELIDED_LIFETIMES_IN_PATHS,
324        EXPLICIT_OUTLIVES_REQUIREMENTS // FIXME(#52665, #47816) not always applicable and not all
325                                       // macros are ready for this yet.
326                                       // UNREACHABLE_PUB,
327
328                                       // FIXME macro crates are not up for this yet, too much
329                                       // breakage is seen if we try to encourage this lint.
330                                       // MACRO_USE_EXTERN_CRATE
331    );
332
333    add_lint_group!("keyword_idents", KEYWORD_IDENTS_2018, KEYWORD_IDENTS_2024);
334
335    add_lint_group!(
336        "refining_impl_trait",
337        REFINING_IMPL_TRAIT_REACHABLE,
338        REFINING_IMPL_TRAIT_INTERNAL
339    );
340
341    add_lint_group!("deprecated_safe", DEPRECATED_SAFE_2024);
342
343    add_lint_group!(
344        "unknown_or_malformed_diagnostic_attributes",
345        MALFORMED_DIAGNOSTIC_ATTRIBUTES,
346        MALFORMED_DIAGNOSTIC_FORMAT_LITERALS,
347        MISPLACED_DIAGNOSTIC_ATTRIBUTES,
348        UNKNOWN_DIAGNOSTIC_ATTRIBUTES
349    );
350
351    // Register renamed and removed lints.
352    store.register_renamed("single_use_lifetime", "single_use_lifetimes");
353    store.register_renamed("elided_lifetime_in_path", "elided_lifetimes_in_paths");
354    store.register_renamed("bare_trait_object", "bare_trait_objects");
355    store.register_renamed("unstable_name_collision", "unstable_name_collisions");
356    store.register_renamed("unused_doc_comment", "unused_doc_comments");
357    store.register_renamed("async_idents", "keyword_idents_2018");
358    store.register_renamed("exceeding_bitshifts", "arithmetic_overflow");
359    store.register_renamed("redundant_semicolon", "redundant_semicolons");
360    store.register_renamed("overlapping_patterns", "overlapping_range_endpoints");
361    store.register_renamed("disjoint_capture_migration", "rust_2021_incompatible_closure_captures");
362    store.register_renamed("or_patterns_back_compat", "rust_2021_incompatible_or_patterns");
363    store.register_renamed("non_fmt_panic", "non_fmt_panics");
364    store.register_renamed("unused_tuple_struct_fields", "dead_code");
365    store.register_renamed("static_mut_ref", "static_mut_refs");
366    store.register_renamed("temporary_cstring_as_ptr", "dangling_pointers_from_temporaries");
367    store.register_renamed("elided_named_lifetimes", "mismatched_lifetime_syntaxes");
368    store.register_renamed(
369        "repr_transparent_external_private_fields",
370        "repr_transparent_non_zst_fields",
371    );
372
373    // These were moved to tool lints, but rustc still sees them when compiling normally, before
374    // tool lints are registered, so `check_tool_name_for_backwards_compat` doesn't work. Use
375    // `register_removed` explicitly.
376    const RUSTDOC_LINTS: &[&str] = &[
377        "broken_intra_doc_links",
378        "private_intra_doc_links",
379        "missing_crate_level_docs",
380        "missing_doc_code_examples",
381        "private_doc_tests",
382        "invalid_codeblock_attributes",
383        "invalid_html_tags",
384        "non_autolinks",
385    ];
386    for rustdoc_lint in RUSTDOC_LINTS {
387        store.register_ignored(rustdoc_lint);
388    }
389    store.register_removed(
390        "intra_doc_link_resolution_failure",
391        "use `rustdoc::broken_intra_doc_links` instead",
392    );
393    store.register_removed("rustdoc", "use `rustdoc::all` instead");
394
395    store.register_removed("unknown_features", "replaced by an error");
396    store.register_removed("unsigned_negation", "replaced by negate_unsigned feature gate");
397    store.register_removed("negate_unsigned", "cast a signed value instead");
398    store.register_removed("raw_pointer_derive", "using derive with raw pointers is ok");
399    // Register lint group aliases.
400    store.register_group_alias("nonstandard_style", "bad_style");
401    // This was renamed to `raw_pointer_derive`, which was then removed,
402    // so it is also considered removed.
403    store.register_removed("raw_pointer_deriving", "using derive with raw pointers is ok");
404    store.register_removed("drop_with_repr_extern", "drop flags have been removed");
405    store.register_removed("fat_ptr_transmutes", "was accidentally removed back in 2014");
406    store.register_removed("deprecated_attr", "use `deprecated` instead");
407    store.register_removed(
408        "transmute_from_fn_item_types",
409        "always cast functions before transmuting them",
410    );
411    store.register_removed(
412        "hr_lifetime_in_assoc_type",
413        "converted into hard error, see issue #33685 \
414         <https://github.com/rust-lang/rust/issues/33685> for more information",
415    );
416    store.register_removed(
417        "inaccessible_extern_crate",
418        "converted into hard error, see issue #36886 \
419         <https://github.com/rust-lang/rust/issues/36886> for more information",
420    );
421    store.register_removed(
422        "super_or_self_in_global_path",
423        "converted into hard error, see issue #36888 \
424         <https://github.com/rust-lang/rust/issues/36888> for more information",
425    );
426    store.register_removed(
427        "overlapping_inherent_impls",
428        "converted into hard error, see issue #36889 \
429         <https://github.com/rust-lang/rust/issues/36889> for more information",
430    );
431    store.register_removed(
432        "illegal_floating_point_constant_pattern",
433        "converted into hard error, see issue #36890 \
434         <https://github.com/rust-lang/rust/issues/36890> for more information",
435    );
436    store.register_removed(
437        "illegal_struct_or_enum_constant_pattern",
438        "converted into hard error, see issue #36891 \
439         <https://github.com/rust-lang/rust/issues/36891> for more information",
440    );
441    store.register_removed(
442        "lifetime_underscore",
443        "converted into hard error, see issue #36892 \
444         <https://github.com/rust-lang/rust/issues/36892> for more information",
445    );
446    store.register_removed(
447        "extra_requirement_in_impl",
448        "converted into hard error, see issue #37166 \
449         <https://github.com/rust-lang/rust/issues/37166> for more information",
450    );
451    store.register_removed(
452        "legacy_imports",
453        "converted into hard error, see issue #38260 \
454         <https://github.com/rust-lang/rust/issues/38260> for more information",
455    );
456    store.register_removed(
457        "coerce_never",
458        "converted into hard error, see issue #48950 \
459         <https://github.com/rust-lang/rust/issues/48950> for more information",
460    );
461    store.register_removed(
462        "resolve_trait_on_defaulted_unit",
463        "converted into hard error, see issue #48950 \
464         <https://github.com/rust-lang/rust/issues/48950> for more information",
465    );
466    store.register_removed(
467        "private_no_mangle_fns",
468        "no longer a warning, `#[no_mangle]` functions always exported",
469    );
470    store.register_removed(
471        "private_no_mangle_statics",
472        "no longer a warning, `#[no_mangle]` statics always exported",
473    );
474    store.register_removed("bad_repr", "replaced with a generic attribute input check");
475    store.register_removed(
476        "duplicate_matcher_binding_name",
477        "converted into hard error, see issue #57742 \
478         <https://github.com/rust-lang/rust/issues/57742> for more information",
479    );
480    store.register_removed(
481        "incoherent_fundamental_impls",
482        "converted into hard error, see issue #46205 \
483         <https://github.com/rust-lang/rust/issues/46205> for more information",
484    );
485    store.register_removed(
486        "legacy_constructor_visibility",
487        "converted into hard error, see issue #39207 \
488         <https://github.com/rust-lang/rust/issues/39207> for more information",
489    );
490    store.register_removed(
491        "legacy_directory_ownership",
492        "converted into hard error, see issue #37872 \
493         <https://github.com/rust-lang/rust/issues/37872> for more information",
494    );
495    store.register_removed(
496        "safe_extern_statics",
497        "converted into hard error, see issue #36247 \
498         <https://github.com/rust-lang/rust/issues/36247> for more information",
499    );
500    store.register_removed(
501        "parenthesized_params_in_types_and_modules",
502        "converted into hard error, see issue #42238 \
503         <https://github.com/rust-lang/rust/issues/42238> for more information",
504    );
505    store.register_removed(
506        "duplicate_macro_exports",
507        "converted into hard error, see issue #35896 \
508         <https://github.com/rust-lang/rust/issues/35896> for more information",
509    );
510    store.register_removed(
511        "nested_impl_trait",
512        "converted into hard error, see issue #59014 \
513         <https://github.com/rust-lang/rust/issues/59014> for more information",
514    );
515    store.register_removed("plugin_as_library", "plugins have been deprecated and retired");
516    store.register_removed(
517        "unsupported_naked_functions",
518        "converted into hard error, see RFC 2972 \
519         <https://github.com/rust-lang/rfcs/blob/master/text/2972-constrained-naked.md> for more information",
520    );
521    store.register_removed(
522        "mutable_borrow_reservation_conflict",
523        "now allowed, see issue #59159 \
524         <https://github.com/rust-lang/rust/issues/59159> for more information",
525    );
526    store.register_removed(
527        "const_err",
528        "converted into hard error, see issue #71800 \
529         <https://github.com/rust-lang/rust/issues/71800> for more information",
530    );
531    store.register_removed(
532        "safe_packed_borrows",
533        "converted into hard error, see issue #82523 \
534         <https://github.com/rust-lang/rust/issues/82523> for more information",
535    );
536    store.register_removed(
537        "unaligned_references",
538        "converted into hard error, see issue #82523 \
539         <https://github.com/rust-lang/rust/issues/82523> for more information",
540    );
541    store.register_removed(
542        "private_in_public",
543        "replaced with another group of lints, see RFC \
544         <https://rust-lang.github.io/rfcs/2145-type-privacy.html> for more information",
545    );
546    store.register_removed(
547        "invalid_alignment",
548        "converted into hard error, see PR #104616 \
549         <https://github.com/rust-lang/rust/pull/104616> for more information",
550    );
551    store.register_removed(
552        "implied_bounds_entailment",
553        "converted into hard error, see PR #117984 \
554        <https://github.com/rust-lang/rust/pull/117984> for more information",
555    );
556    store.register_removed(
557        "coinductive_overlap_in_coherence",
558        "converted into hard error, see PR #118649 \
559         <https://github.com/rust-lang/rust/pull/118649> for more information",
560    );
561    store.register_removed(
562        "illegal_floating_point_literal_pattern",
563        "no longer a warning, float patterns behave the same as `==`",
564    );
565    store.register_removed(
566        "nontrivial_structural_match",
567        "no longer needed, see RFC #3535 \
568         <https://rust-lang.github.io/rfcs/3535-constants-in-patterns.html> for more information",
569    );
570    store.register_removed(
571        "suspicious_auto_trait_impls",
572        "no longer needed, see issue #93367 \
573         <https://github.com/rust-lang/rust/issues/93367> for more information",
574    );
575    store.register_removed(
576        "const_patterns_without_partial_eq",
577        "converted into hard error, see RFC #3535 \
578         <https://rust-lang.github.io/rfcs/3535-constants-in-patterns.html> for more information",
579    );
580    store.register_removed(
581        "indirect_structural_match",
582        "converted into hard error, see RFC #3535 \
583         <https://rust-lang.github.io/rfcs/3535-constants-in-patterns.html> for more information",
584    );
585    store.register_removed(
586        "deprecated_cfg_attr_crate_type_name",
587        "converted into hard error, see issue #91632 \
588         <https://github.com/rust-lang/rust/issues/91632> for more information",
589    );
590    store.register_removed(
591        "pointer_structural_match",
592        "converted into hard error, see RFC #3535 \
593         <https://rust-lang.github.io/rfcs/3535-constants-in-patterns.html> for more information",
594    );
595    store.register_removed(
596        "box_pointers",
597        "it does not detect other kinds of allocations, and existed only for historical reasons",
598    );
599    store.register_removed(
600        "byte_slice_in_packed_struct_with_derive",
601        "converted into hard error, see issue #107457 \
602         <https://github.com/rust-lang/rust/issues/107457> for more information",
603    );
604    store.register_removed("writes_through_immutable_pointer", "converted into hard error");
605    store.register_removed(
606        "const_eval_mutable_ptr_in_final_value",
607        "partially allowed now, otherwise turned into a hard error",
608    );
609    store.register_removed(
610        "where_clauses_object_safety",
611        "converted into hard error, see PR #125380 \
612         <https://github.com/rust-lang/rust/pull/125380> for more information",
613    );
614    store.register_removed(
615        "cenum_impl_drop_cast",
616        "converted into hard error, \
617         see <https://github.com/rust-lang/rust/issues/73333> for more information",
618    );
619    store.register_removed(
620        "ptr_cast_add_auto_to_object",
621        "converted into hard error, see issue #127323 \
622         <https://github.com/rust-lang/rust/issues/127323> for more information",
623    );
624    store.register_removed("unsupported_fn_ptr_calling_conventions", "converted into hard error");
625    store.register_removed(
626        "undefined_naked_function_abi",
627        "converted into hard error, see PR #139001 \
628         <https://github.com/rust-lang/rust/issues/139001> for more information",
629    );
630    store.register_removed(
631        "abi_unsupported_vector_types",
632        "converted into hard error, \
633         see <https://github.com/rust-lang/rust/issues/116558> for more information",
634    );
635    store.register_removed(
636        "missing_fragment_specifier",
637        "converted into hard error, \
638         see <https://github.com/rust-lang/rust/issues/40107> for more information",
639    );
640    store.register_removed("wasm_c_abi", "the wasm C ABI has been fixed");
641}
642
643fn register_internals(store: &mut LintStore) {
644    store.register_lints(&LintPassImpl::lint_vec());
645    store.register_early_pass(|| Box::new(LintPassImpl));
646    store.register_lints(&DefaultHashTypes::lint_vec());
647    store.register_late_mod_pass(|_| Box::new(DefaultHashTypes));
648    store.register_lints(&QueryStability::lint_vec());
649    store.register_late_mod_pass(|_| Box::new(QueryStability));
650    store.register_lints(&TyTyKind::lint_vec());
651    store.register_late_mod_pass(|_| Box::new(TyTyKind));
652    store.register_lints(&TypeIr::lint_vec());
653    store.register_late_mod_pass(|_| Box::new(TypeIr));
654    store.register_lints(&Diagnostics::lint_vec());
655    store.register_late_mod_pass(|_| Box::new(Diagnostics));
656    store.register_lints(&BadOptAccess::lint_vec());
657    store.register_late_mod_pass(|_| Box::new(BadOptAccess));
658    store.register_lints(&PassByValue::lint_vec());
659    store.register_late_mod_pass(|_| Box::new(PassByValue));
660    store.register_lints(&SpanUseEqCtxt::lint_vec());
661    store.register_late_mod_pass(|_| Box::new(SpanUseEqCtxt));
662    store.register_lints(&SymbolInternStringLiteral::lint_vec());
663    store.register_late_mod_pass(|_| Box::new(SymbolInternStringLiteral));
664    store.register_lints(&ImplicitSysrootCrateImport::lint_vec());
665    store.register_early_pass(|| Box::new(ImplicitSysrootCrateImport));
666    // FIXME(davidtwco): deliberately do not include `UNTRANSLATABLE_DIAGNOSTIC` and
667    // `DIAGNOSTIC_OUTSIDE_OF_IMPL` here because `-Wrustc::internal` is provided to every crate and
668    // these lints will trigger all of the time - change this once migration to diagnostic structs
669    // and translation is completed
670    store.register_group(
671        false,
672        "rustc::internal",
673        None,
674        vec![
675            LintId::of(DEFAULT_HASH_TYPES),
676            LintId::of(POTENTIAL_QUERY_INSTABILITY),
677            LintId::of(UNTRACKED_QUERY_INFORMATION),
678            LintId::of(USAGE_OF_TY_TYKIND),
679            LintId::of(PASS_BY_VALUE),
680            LintId::of(LINT_PASS_IMPL_WITHOUT_MACRO),
681            LintId::of(USAGE_OF_QUALIFIED_TY),
682            LintId::of(NON_GLOB_IMPORT_OF_TYPE_IR_INHERENT),
683            LintId::of(USAGE_OF_TYPE_IR_INHERENT),
684            LintId::of(USAGE_OF_TYPE_IR_TRAITS),
685            LintId::of(BAD_OPT_ACCESS),
686            LintId::of(SPAN_USE_EQ_CTXT),
687            LintId::of(DIRECT_USE_OF_RUSTC_TYPE_IR),
688            LintId::of(IMPLICIT_SYSROOT_CRATE_IMPORT),
689        ],
690    );
691}
692
693#[cfg(test)]
694mod tests;