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