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