rustc_lint/
lib.rs

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