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