rustc_lint_defs/
builtin.rs

1//! Some lints that are built in to the compiler.
2//!
3//! These are the built-in lints that are emitted direct in the main
4//! compiler code, rather than using their own custom pass. Those
5//! lints are all available in `rustc_lint::builtin`.
6//!
7//! When removing a lint, make sure to also add a call to `register_removed` in
8//! compiler/rustc_lint/src/lib.rs.
9
10use rustc_span::edition::Edition;
11
12use crate::{FutureIncompatibilityReason, declare_lint, declare_lint_pass};
13
14declare_lint_pass! {
15    /// Does nothing as a lint pass, but registers some `Lint`s
16    /// that are used by other parts of the compiler.
17    HardwiredLints => [
18        // tidy-alphabetical-start
19        ABSOLUTE_PATHS_NOT_STARTING_WITH_CRATE,
20        AMBIGUOUS_ASSOCIATED_ITEMS,
21        AMBIGUOUS_GLOB_IMPORTS,
22        AMBIGUOUS_GLOB_REEXPORTS,
23        ARITHMETIC_OVERFLOW,
24        ASM_SUB_REGISTER,
25        BAD_ASM_STYLE,
26        BARE_TRAIT_OBJECTS,
27        BINDINGS_WITH_VARIANT_NAME,
28        BREAK_WITH_LABEL_AND_LOOP,
29        COHERENCE_LEAK_CHECK,
30        CONFLICTING_REPR_HINTS,
31        CONST_EVALUATABLE_UNCHECKED,
32        CONST_ITEM_MUTATION,
33        DEAD_CODE,
34        DEPENDENCY_ON_UNIT_NEVER_TYPE_FALLBACK,
35        DEPRECATED,
36        DEPRECATED_IN_FUTURE,
37        DEPRECATED_SAFE_2024,
38        DEPRECATED_WHERE_CLAUSE_LOCATION,
39        DUPLICATE_MACRO_ATTRIBUTES,
40        ELIDED_LIFETIMES_IN_ASSOCIATED_CONSTANT,
41        ELIDED_LIFETIMES_IN_PATHS,
42        ELIDED_NAMED_LIFETIMES,
43        EXPLICIT_BUILTIN_CFGS_IN_FLAGS,
44        EXPORTED_PRIVATE_DEPENDENCIES,
45        FFI_UNWIND_CALLS,
46        FORBIDDEN_LINT_GROUPS,
47        FUNCTION_ITEM_REFERENCES,
48        FUZZY_PROVENANCE_CASTS,
49        HIDDEN_GLOB_REEXPORTS,
50        ILL_FORMED_ATTRIBUTE_INPUT,
51        INCOMPLETE_INCLUDE,
52        INEFFECTIVE_UNSTABLE_TRAIT_IMPL,
53        INLINE_NO_SANITIZE,
54        INVALID_DOC_ATTRIBUTES,
55        INVALID_MACRO_EXPORT_ARGUMENTS,
56        INVALID_TYPE_PARAM_DEFAULT,
57        IRREFUTABLE_LET_PATTERNS,
58        LARGE_ASSIGNMENTS,
59        LATE_BOUND_LIFETIME_ARGUMENTS,
60        LEGACY_DERIVE_HELPERS,
61        LINKER_MESSAGES,
62        LONG_RUNNING_CONST_EVAL,
63        LOSSY_PROVENANCE_CASTS,
64        MACRO_EXPANDED_MACRO_EXPORTS_ACCESSED_BY_ABSOLUTE_PATHS,
65        MACRO_USE_EXTERN_CRATE,
66        META_VARIABLE_MISUSE,
67        MISSING_ABI,
68        MISSING_FRAGMENT_SPECIFIER,
69        MISSING_UNSAFE_ON_EXTERN,
70        MUST_NOT_SUSPEND,
71        NAMED_ARGUMENTS_USED_POSITIONALLY,
72        NEVER_TYPE_FALLBACK_FLOWING_INTO_UNSAFE,
73        NON_CONTIGUOUS_RANGE_ENDPOINTS,
74        NON_EXHAUSTIVE_OMITTED_PATTERNS,
75        OUT_OF_SCOPE_MACRO_CALLS,
76        OVERLAPPING_RANGE_ENDPOINTS,
77        PATTERNS_IN_FNS_WITHOUT_BODY,
78        PRIVATE_BOUNDS,
79        PRIVATE_INTERFACES,
80        PROC_MACRO_DERIVE_RESOLUTION_FALLBACK,
81        PTR_TO_INTEGER_TRANSMUTE_IN_CONSTS,
82        PUB_USE_OF_PRIVATE_EXTERN_CRATE,
83        REDUNDANT_IMPORTS,
84        REDUNDANT_LIFETIMES,
85        REFINING_IMPL_TRAIT_INTERNAL,
86        REFINING_IMPL_TRAIT_REACHABLE,
87        RENAMED_AND_REMOVED_LINTS,
88        REPR_TRANSPARENT_EXTERNAL_PRIVATE_FIELDS,
89        RUST_2021_INCOMPATIBLE_CLOSURE_CAPTURES,
90        RUST_2021_INCOMPATIBLE_OR_PATTERNS,
91        RUST_2021_PREFIXES_INCOMPATIBLE_SYNTAX,
92        RUST_2021_PRELUDE_COLLISIONS,
93        RUST_2024_GUARDED_STRING_INCOMPATIBLE_SYNTAX,
94        RUST_2024_INCOMPATIBLE_PAT,
95        RUST_2024_PRELUDE_COLLISIONS,
96        SELF_CONSTRUCTOR_FROM_OUTER_ITEM,
97        SEMICOLON_IN_EXPRESSIONS_FROM_MACROS,
98        SINGLE_USE_LIFETIMES,
99        SOFT_UNSTABLE,
100        STABLE_FEATURES,
101        SUPERTRAIT_ITEM_SHADOWING_DEFINITION,
102        SUPERTRAIT_ITEM_SHADOWING_USAGE,
103        TAIL_EXPR_DROP_ORDER,
104        TEST_UNSTABLE_LINT,
105        TEXT_DIRECTION_CODEPOINT_IN_COMMENT,
106        TRIVIAL_CASTS,
107        TRIVIAL_NUMERIC_CASTS,
108        TYVAR_BEHIND_RAW_POINTER,
109        UNCONDITIONAL_PANIC,
110        UNCONDITIONAL_RECURSION,
111        UNCOVERED_PARAM_IN_PROJECTION,
112        UNEXPECTED_CFGS,
113        UNFULFILLED_LINT_EXPECTATIONS,
114        UNINHABITED_STATIC,
115        UNKNOWN_CRATE_TYPES,
116        UNKNOWN_LINTS,
117        UNKNOWN_OR_MALFORMED_DIAGNOSTIC_ATTRIBUTES,
118        UNNAMEABLE_TEST_ITEMS,
119        UNNAMEABLE_TYPES,
120        UNNECESSARY_TRANSMUTES,
121        UNREACHABLE_CODE,
122        UNREACHABLE_PATTERNS,
123        UNSAFE_ATTR_OUTSIDE_UNSAFE,
124        UNSAFE_OP_IN_UNSAFE_FN,
125        UNSTABLE_NAME_COLLISIONS,
126        UNSTABLE_SYNTAX_PRE_EXPANSION,
127        UNSUPPORTED_FN_PTR_CALLING_CONVENTIONS,
128        UNUSED_ASSIGNMENTS,
129        UNUSED_ASSOCIATED_TYPE_BOUNDS,
130        UNUSED_ATTRIBUTES,
131        UNUSED_CRATE_DEPENDENCIES,
132        UNUSED_EXTERN_CRATES,
133        UNUSED_FEATURES,
134        UNUSED_IMPORTS,
135        UNUSED_LABELS,
136        UNUSED_LIFETIMES,
137        UNUSED_MACRO_RULES,
138        UNUSED_MACROS,
139        UNUSED_MUT,
140        UNUSED_QUALIFICATIONS,
141        UNUSED_UNSAFE,
142        UNUSED_VARIABLES,
143        USELESS_DEPRECATED,
144        WARNINGS,
145        WASM_C_ABI,
146        // tidy-alphabetical-end
147    ]
148}
149
150declare_lint! {
151    /// The `forbidden_lint_groups` lint detects violations of
152    /// `forbid` applied to a lint group. Due to a bug in the compiler,
153    /// these used to be overlooked entirely. They now generate a warning.
154    ///
155    /// ### Example
156    ///
157    /// ```rust
158    /// #![forbid(warnings)]
159    /// #![warn(bad_style)]
160    ///
161    /// fn main() {}
162    /// ```
163    ///
164    /// {{produces}}
165    ///
166    /// ### Recommended fix
167    ///
168    /// If your crate is using `#![forbid(warnings)]`,
169    /// we recommend that you change to `#![deny(warnings)]`.
170    ///
171    /// ### Explanation
172    ///
173    /// Due to a compiler bug, applying `forbid` to lint groups
174    /// previously had no effect. The bug is now fixed but instead of
175    /// enforcing `forbid` we issue this future-compatibility warning
176    /// to avoid breaking existing crates.
177    pub FORBIDDEN_LINT_GROUPS,
178    Warn,
179    "applying forbid to lint-groups",
180    @future_incompatible = FutureIncompatibleInfo {
181        reason: FutureIncompatibilityReason::FutureReleaseErrorReportInDeps,
182        reference: "issue #81670 <https://github.com/rust-lang/rust/issues/81670>",
183    };
184}
185
186declare_lint! {
187    /// The `ill_formed_attribute_input` lint detects ill-formed attribute
188    /// inputs that were previously accepted and used in practice.
189    ///
190    /// ### Example
191    ///
192    /// ```rust,compile_fail
193    /// #[inline = "this is not valid"]
194    /// fn foo() {}
195    /// ```
196    ///
197    /// {{produces}}
198    ///
199    /// ### Explanation
200    ///
201    /// Previously, inputs for many built-in attributes weren't validated and
202    /// nonsensical attribute inputs were accepted. After validation was
203    /// added, it was determined that some existing projects made use of these
204    /// invalid forms. This is a [future-incompatible] lint to transition this
205    /// to a hard error in the future. See [issue #57571] for more details.
206    ///
207    /// Check the [attribute reference] for details on the valid inputs for
208    /// attributes.
209    ///
210    /// [issue #57571]: https://github.com/rust-lang/rust/issues/57571
211    /// [attribute reference]: https://doc.rust-lang.org/nightly/reference/attributes.html
212    /// [future-incompatible]: ../index.md#future-incompatible-lints
213    pub ILL_FORMED_ATTRIBUTE_INPUT,
214    Deny,
215    "ill-formed attribute inputs that were previously accepted and used in practice",
216    @future_incompatible = FutureIncompatibleInfo {
217        reason: FutureIncompatibilityReason::FutureReleaseErrorDontReportInDeps,
218        reference: "issue #57571 <https://github.com/rust-lang/rust/issues/57571>",
219    };
220    crate_level_only
221}
222
223declare_lint! {
224    /// The `conflicting_repr_hints` lint detects [`repr` attributes] with
225    /// conflicting hints.
226    ///
227    /// [`repr` attributes]: https://doc.rust-lang.org/reference/type-layout.html#representations
228    ///
229    /// ### Example
230    ///
231    /// ```rust,compile_fail
232    /// #[repr(u32, u64)]
233    /// enum Foo {
234    ///     Variant1,
235    /// }
236    /// ```
237    ///
238    /// {{produces}}
239    ///
240    /// ### Explanation
241    ///
242    /// The compiler incorrectly accepted these conflicting representations in
243    /// the past. This is a [future-incompatible] lint to transition this to a
244    /// hard error in the future. See [issue #68585] for more details.
245    ///
246    /// To correct the issue, remove one of the conflicting hints.
247    ///
248    /// [issue #68585]: https://github.com/rust-lang/rust/issues/68585
249    /// [future-incompatible]: ../index.md#future-incompatible-lints
250    pub CONFLICTING_REPR_HINTS,
251    Deny,
252    "conflicts between `#[repr(..)]` hints that were previously accepted and used in practice",
253    @future_incompatible = FutureIncompatibleInfo {
254        reason: FutureIncompatibilityReason::FutureReleaseErrorReportInDeps,
255        reference: "issue #68585 <https://github.com/rust-lang/rust/issues/68585>",
256    };
257}
258
259declare_lint! {
260    /// The `meta_variable_misuse` lint detects possible meta-variable misuse
261    /// in macro definitions.
262    ///
263    /// ### Example
264    ///
265    /// ```rust,compile_fail
266    /// #![deny(meta_variable_misuse)]
267    ///
268    /// macro_rules! foo {
269    ///     () => {};
270    ///     ($( $i:ident = $($j:ident),+ );*) => { $( $( $i = $k; )+ )* };
271    /// }
272    ///
273    /// fn main() {
274    ///     foo!();
275    /// }
276    /// ```
277    ///
278    /// {{produces}}
279    ///
280    /// ### Explanation
281    ///
282    /// There are quite a few different ways a [`macro_rules`] macro can be
283    /// improperly defined. Many of these errors were previously only detected
284    /// when the macro was expanded or not at all. This lint is an attempt to
285    /// catch some of these problems when the macro is *defined*.
286    ///
287    /// This lint is "allow" by default because it may have false positives
288    /// and other issues. See [issue #61053] for more details.
289    ///
290    /// [`macro_rules`]: https://doc.rust-lang.org/reference/macros-by-example.html
291    /// [issue #61053]: https://github.com/rust-lang/rust/issues/61053
292    pub META_VARIABLE_MISUSE,
293    Allow,
294    "possible meta-variable misuse at macro definition"
295}
296
297declare_lint! {
298    /// The `incomplete_include` lint detects the use of the [`include!`]
299    /// macro with a file that contains more than one expression.
300    ///
301    /// [`include!`]: https://doc.rust-lang.org/std/macro.include.html
302    ///
303    /// ### Example
304    ///
305    /// ```rust,ignore (needs separate file)
306    /// fn main() {
307    ///     include!("foo.txt");
308    /// }
309    /// ```
310    ///
311    /// where the file `foo.txt` contains:
312    ///
313    /// ```text
314    /// println!("hi!");
315    /// ```
316    ///
317    /// produces:
318    ///
319    /// ```text
320    /// error: include macro expected single expression in source
321    ///  --> foo.txt:1:14
322    ///   |
323    /// 1 | println!("1");
324    ///   |              ^
325    ///   |
326    ///   = note: `#[deny(incomplete_include)]` on by default
327    /// ```
328    ///
329    /// ### Explanation
330    ///
331    /// The [`include!`] macro is currently only intended to be used to
332    /// include a single [expression] or multiple [items]. Historically it
333    /// would ignore any contents after the first expression, but that can be
334    /// confusing. In the example above, the `println!` expression ends just
335    /// before the semicolon, making the semicolon "extra" information that is
336    /// ignored. Perhaps even more surprising, if the included file had
337    /// multiple print statements, the subsequent ones would be ignored!
338    ///
339    /// One workaround is to place the contents in braces to create a [block
340    /// expression]. Also consider alternatives, like using functions to
341    /// encapsulate the expressions, or use [proc-macros].
342    ///
343    /// This is a lint instead of a hard error because existing projects were
344    /// found to hit this error. To be cautious, it is a lint for now. The
345    /// future semantics of the `include!` macro are also uncertain, see
346    /// [issue #35560].
347    ///
348    /// [items]: https://doc.rust-lang.org/reference/items.html
349    /// [expression]: https://doc.rust-lang.org/reference/expressions.html
350    /// [block expression]: https://doc.rust-lang.org/reference/expressions/block-expr.html
351    /// [proc-macros]: https://doc.rust-lang.org/reference/procedural-macros.html
352    /// [issue #35560]: https://github.com/rust-lang/rust/issues/35560
353    pub INCOMPLETE_INCLUDE,
354    Deny,
355    "trailing content in included file"
356}
357
358declare_lint! {
359    /// The `arithmetic_overflow` lint detects that an arithmetic operation
360    /// will [overflow].
361    ///
362    /// [overflow]: https://doc.rust-lang.org/reference/expressions/operator-expr.html#overflow
363    ///
364    /// ### Example
365    ///
366    /// ```rust,compile_fail
367    /// 1_i32 << 32;
368    /// ```
369    ///
370    /// {{produces}}
371    ///
372    /// ### Explanation
373    ///
374    /// It is very likely a mistake to perform an arithmetic operation that
375    /// overflows its value. If the compiler is able to detect these kinds of
376    /// overflows at compile-time, it will trigger this lint. Consider
377    /// adjusting the expression to avoid overflow, or use a data type that
378    /// will not overflow.
379    pub ARITHMETIC_OVERFLOW,
380    Deny,
381    "arithmetic operation overflows",
382    @eval_always = true
383}
384
385declare_lint! {
386    /// The `unconditional_panic` lint detects an operation that will cause a
387    /// panic at runtime.
388    ///
389    /// ### Example
390    ///
391    /// ```rust,compile_fail
392    /// # #![allow(unused)]
393    /// let x = 1 / 0;
394    /// ```
395    ///
396    /// {{produces}}
397    ///
398    /// ### Explanation
399    ///
400    /// This lint detects code that is very likely incorrect because it will
401    /// always panic, such as division by zero and out-of-bounds array
402    /// accesses. Consider adjusting your code if this is a bug, or using the
403    /// `panic!` or `unreachable!` macro instead in case the panic is intended.
404    pub UNCONDITIONAL_PANIC,
405    Deny,
406    "operation will cause a panic at runtime",
407    @eval_always = true
408}
409
410declare_lint! {
411    /// The `unused_imports` lint detects imports that are never used.
412    ///
413    /// ### Example
414    ///
415    /// ```rust
416    /// use std::collections::HashMap;
417    /// ```
418    ///
419    /// {{produces}}
420    ///
421    /// ### Explanation
422    ///
423    /// Unused imports may signal a mistake or unfinished code, and clutter
424    /// the code, and should be removed. If you intended to re-export the item
425    /// to make it available outside of the module, add a visibility modifier
426    /// like `pub`.
427    pub UNUSED_IMPORTS,
428    Warn,
429    "imports that are never used"
430}
431
432declare_lint! {
433    /// The `redundant_imports` lint detects imports that are redundant due to being
434    /// imported already; either through a previous import, or being present in
435    /// the prelude.
436    ///
437    /// ### Example
438    ///
439    /// ```rust,compile_fail
440    /// #![deny(redundant_imports)]
441    /// use std::option::Option::None;
442    /// fn foo() -> Option<i32> { None }
443    /// ```
444    ///
445    /// {{produces}}
446    ///
447    /// ### Explanation
448    ///
449    /// Redundant imports are unnecessary and can be removed to simplify code.
450    /// If you intended to re-export the item to make it available outside of the
451    /// module, add a visibility modifier like `pub`.
452    pub REDUNDANT_IMPORTS,
453    Allow,
454    "imports that are redundant due to being imported already"
455}
456
457declare_lint! {
458    /// The `must_not_suspend` lint guards against values that shouldn't be held across suspend points
459    /// (`.await`)
460    ///
461    /// ### Example
462    ///
463    /// ```rust
464    /// #![feature(must_not_suspend)]
465    /// #![warn(must_not_suspend)]
466    ///
467    /// #[must_not_suspend]
468    /// struct SyncThing {}
469    ///
470    /// async fn yield_now() {}
471    ///
472    /// pub async fn uhoh() {
473    ///     let guard = SyncThing {};
474    ///     yield_now().await;
475    ///     let _guard = guard;
476    /// }
477    /// ```
478    ///
479    /// {{produces}}
480    ///
481    /// ### Explanation
482    ///
483    /// The `must_not_suspend` lint detects values that are marked with the `#[must_not_suspend]`
484    /// attribute being held across suspend points. A "suspend" point is usually a `.await` in an async
485    /// function.
486    ///
487    /// This attribute can be used to mark values that are semantically incorrect across suspends
488    /// (like certain types of timers), values that have async alternatives, and values that
489    /// regularly cause problems with the `Send`-ness of async fn's returned futures (like
490    /// `MutexGuard`'s)
491    ///
492    pub MUST_NOT_SUSPEND,
493    Allow,
494    "use of a `#[must_not_suspend]` value across a yield point",
495    @feature_gate = must_not_suspend;
496}
497
498declare_lint! {
499    /// The `unused_extern_crates` lint guards against `extern crate` items
500    /// that are never used.
501    ///
502    /// ### Example
503    ///
504    /// ```rust,compile_fail
505    /// #![deny(unused_extern_crates)]
506    /// #![deny(warnings)]
507    /// extern crate proc_macro;
508    /// ```
509    ///
510    /// {{produces}}
511    ///
512    /// ### Explanation
513    ///
514    /// `extern crate` items that are unused have no effect and should be
515    /// removed. Note that there are some cases where specifying an `extern
516    /// crate` is desired for the side effect of ensuring the given crate is
517    /// linked, even though it is not otherwise directly referenced. The lint
518    /// can be silenced by aliasing the crate to an underscore, such as
519    /// `extern crate foo as _`. Also note that it is no longer idiomatic to
520    /// use `extern crate` in the [2018 edition], as extern crates are now
521    /// automatically added in scope.
522    ///
523    /// This lint is "allow" by default because it can be noisy, and produce
524    /// false-positives. If a dependency is being removed from a project, it
525    /// is recommended to remove it from the build configuration (such as
526    /// `Cargo.toml`) to ensure stale build entries aren't left behind.
527    ///
528    /// [2018 edition]: https://doc.rust-lang.org/edition-guide/rust-2018/module-system/path-clarity.html#no-more-extern-crate
529    pub UNUSED_EXTERN_CRATES,
530    Allow,
531    "extern crates that are never used"
532}
533
534declare_lint! {
535    /// The `unused_crate_dependencies` lint detects crate dependencies that
536    /// are never used.
537    ///
538    /// ### Example
539    ///
540    /// ```rust,ignore (needs extern crate)
541    /// #![deny(unused_crate_dependencies)]
542    /// ```
543    ///
544    /// This will produce:
545    ///
546    /// ```text
547    /// error: extern crate `regex` is unused in crate `lint_example`
548    ///   |
549    ///   = help: remove the dependency or add `use regex as _;` to the crate root
550    /// note: the lint level is defined here
551    ///  --> src/lib.rs:1:9
552    ///   |
553    /// 1 | #![deny(unused_crate_dependencies)]
554    ///   |         ^^^^^^^^^^^^^^^^^^^^^^^^^
555    /// ```
556    ///
557    /// ### Explanation
558    ///
559    /// After removing the code that uses a dependency, this usually also
560    /// requires removing the dependency from the build configuration.
561    /// However, sometimes that step can be missed, which leads to time wasted
562    /// building dependencies that are no longer used. This lint can be
563    /// enabled to detect dependencies that are never used (more specifically,
564    /// any dependency passed with the `--extern` command-line flag that is
565    /// never referenced via [`use`], [`extern crate`], or in any [path]).
566    ///
567    /// This lint is "allow" by default because it can provide false positives
568    /// depending on how the build system is configured. For example, when
569    /// using Cargo, a "package" consists of multiple crates (such as a
570    /// library and a binary), but the dependencies are defined for the
571    /// package as a whole. If there is a dependency that is only used in the
572    /// binary, but not the library, then the lint will be incorrectly issued
573    /// in the library.
574    ///
575    /// [path]: https://doc.rust-lang.org/reference/paths.html
576    /// [`use`]: https://doc.rust-lang.org/reference/items/use-declarations.html
577    /// [`extern crate`]: https://doc.rust-lang.org/reference/items/extern-crates.html
578    pub UNUSED_CRATE_DEPENDENCIES,
579    Allow,
580    "crate dependencies that are never used",
581    crate_level_only
582}
583
584declare_lint! {
585    /// The `unused_qualifications` lint detects unnecessarily qualified
586    /// names.
587    ///
588    /// ### Example
589    ///
590    /// ```rust,compile_fail
591    /// #![deny(unused_qualifications)]
592    /// mod foo {
593    ///     pub fn bar() {}
594    /// }
595    ///
596    /// fn main() {
597    ///     use foo::bar;
598    ///     foo::bar();
599    ///     bar();
600    /// }
601    /// ```
602    ///
603    /// {{produces}}
604    ///
605    /// ### Explanation
606    ///
607    /// If an item from another module is already brought into scope, then
608    /// there is no need to qualify it in this case. You can call `bar()`
609    /// directly, without the `foo::`.
610    ///
611    /// This lint is "allow" by default because it is somewhat pedantic, and
612    /// doesn't indicate an actual problem, but rather a stylistic choice, and
613    /// can be noisy when refactoring or moving around code.
614    pub UNUSED_QUALIFICATIONS,
615    Allow,
616    "detects unnecessarily qualified names"
617}
618
619declare_lint! {
620    /// The `unknown_lints` lint detects unrecognized lint attributes.
621    ///
622    /// ### Example
623    ///
624    /// ```rust
625    /// #![allow(not_a_real_lint)]
626    /// ```
627    ///
628    /// {{produces}}
629    ///
630    /// ### Explanation
631    ///
632    /// It is usually a mistake to specify a lint that does not exist. Check
633    /// the spelling, and check the lint listing for the correct name. Also
634    /// consider if you are using an old version of the compiler, and the lint
635    /// is only available in a newer version.
636    pub UNKNOWN_LINTS,
637    Warn,
638    "unrecognized lint attribute",
639    @eval_always = true
640}
641
642declare_lint! {
643    /// The `unfulfilled_lint_expectations` lint detects when a lint expectation is
644    /// unfulfilled.
645    ///
646    /// ### Example
647    ///
648    /// ```rust
649    /// #[expect(unused_variables)]
650    /// let x = 10;
651    /// println!("{}", x);
652    /// ```
653    ///
654    /// {{produces}}
655    ///
656    /// ### Explanation
657    ///
658    /// The `#[expect]` attribute can be used to create a lint expectation. The
659    /// expectation is fulfilled, if a `#[warn]` attribute at the same location
660    /// would result in a lint emission. If the expectation is unfulfilled,
661    /// because no lint was emitted, this lint will be emitted on the attribute.
662    ///
663    pub UNFULFILLED_LINT_EXPECTATIONS,
664    Warn,
665    "unfulfilled lint expectation"
666}
667
668declare_lint! {
669    /// The `unused_variables` lint detects variables which are not used in
670    /// any way.
671    ///
672    /// ### Example
673    ///
674    /// ```rust
675    /// let x = 5;
676    /// ```
677    ///
678    /// {{produces}}
679    ///
680    /// ### Explanation
681    ///
682    /// Unused variables may signal a mistake or unfinished code. To silence
683    /// the warning for the individual variable, prefix it with an underscore
684    /// such as `_x`.
685    pub UNUSED_VARIABLES,
686    Warn,
687    "detect variables which are not used in any way"
688}
689
690declare_lint! {
691    /// The `unused_assignments` lint detects assignments that will never be read.
692    ///
693    /// ### Example
694    ///
695    /// ```rust
696    /// let mut x = 5;
697    /// x = 6;
698    /// ```
699    ///
700    /// {{produces}}
701    ///
702    /// ### Explanation
703    ///
704    /// Unused assignments may signal a mistake or unfinished code. If the
705    /// variable is never used after being assigned, then the assignment can
706    /// be removed. Variables with an underscore prefix such as `_x` will not
707    /// trigger this lint.
708    pub UNUSED_ASSIGNMENTS,
709    Warn,
710    "detect assignments that will never be read"
711}
712
713declare_lint! {
714    /// The `dead_code` lint detects unused, unexported items.
715    ///
716    /// ### Example
717    ///
718    /// ```rust
719    /// fn foo() {}
720    /// ```
721    ///
722    /// {{produces}}
723    ///
724    /// ### Explanation
725    ///
726    /// Dead code may signal a mistake or unfinished code. To silence the
727    /// warning for individual items, prefix the name with an underscore such
728    /// as `_foo`. If it was intended to expose the item outside of the crate,
729    /// consider adding a visibility modifier like `pub`.
730    ///
731    /// To preserve the numbering of tuple structs with unused fields,
732    /// change the unused fields to have unit type or use
733    /// `PhantomData`.
734    ///
735    /// Otherwise consider removing the unused code.
736    ///
737    /// ### Limitations
738    ///
739    /// Removing fields that are only used for side-effects and never
740    /// read will result in behavioral changes. Examples of this
741    /// include:
742    ///
743    /// - If a field's value performs an action when it is dropped.
744    /// - If a field's type does not implement an auto trait
745    ///   (e.g. `Send`, `Sync`, `Unpin`).
746    ///
747    /// For side-effects from dropping field values, this lint should
748    /// be allowed on those fields. For side-effects from containing
749    /// field types, `PhantomData` should be used.
750    pub DEAD_CODE,
751    Warn,
752    "detect unused, unexported items"
753}
754
755declare_lint! {
756    /// The `unused_attributes` lint detects attributes that were not used by
757    /// the compiler.
758    ///
759    /// ### Example
760    ///
761    /// ```rust
762    /// #![ignore]
763    /// ```
764    ///
765    /// {{produces}}
766    ///
767    /// ### Explanation
768    ///
769    /// Unused [attributes] may indicate the attribute is placed in the wrong
770    /// position. Consider removing it, or placing it in the correct position.
771    /// Also consider if you intended to use an _inner attribute_ (with a `!`
772    /// such as `#![allow(unused)]`) which applies to the item the attribute
773    /// is within, or an _outer attribute_ (without a `!` such as
774    /// `#[allow(unused)]`) which applies to the item *following* the
775    /// attribute.
776    ///
777    /// [attributes]: https://doc.rust-lang.org/reference/attributes.html
778    pub UNUSED_ATTRIBUTES,
779    Warn,
780    "detects attributes that were not used by the compiler"
781}
782
783declare_lint! {
784    /// The `unreachable_code` lint detects unreachable code paths.
785    ///
786    /// ### Example
787    ///
788    /// ```rust,no_run
789    /// panic!("we never go past here!");
790    ///
791    /// let x = 5;
792    /// ```
793    ///
794    /// {{produces}}
795    ///
796    /// ### Explanation
797    ///
798    /// Unreachable code may signal a mistake or unfinished code. If the code
799    /// is no longer in use, consider removing it.
800    pub UNREACHABLE_CODE,
801    Warn,
802    "detects unreachable code paths",
803    report_in_external_macro
804}
805
806declare_lint! {
807    /// The `unreachable_patterns` lint detects unreachable patterns.
808    ///
809    /// ### Example
810    ///
811    /// ```rust
812    /// let x = 5;
813    /// match x {
814    ///     y => (),
815    ///     5 => (),
816    /// }
817    /// ```
818    ///
819    /// {{produces}}
820    ///
821    /// ### Explanation
822    ///
823    /// This usually indicates a mistake in how the patterns are specified or
824    /// ordered. In this example, the `y` pattern will always match, so the
825    /// five is impossible to reach. Remember, match arms match in order, you
826    /// probably wanted to put the `5` case above the `y` case.
827    pub UNREACHABLE_PATTERNS,
828    Warn,
829    "detects unreachable patterns"
830}
831
832declare_lint! {
833    /// The `overlapping_range_endpoints` lint detects `match` arms that have [range patterns] that
834    /// overlap on their endpoints.
835    ///
836    /// [range patterns]: https://doc.rust-lang.org/nightly/reference/patterns.html#range-patterns
837    ///
838    /// ### Example
839    ///
840    /// ```rust
841    /// let x = 123u8;
842    /// match x {
843    ///     0..=100 => { println!("small"); }
844    ///     100..=255 => { println!("large"); }
845    /// }
846    /// ```
847    ///
848    /// {{produces}}
849    ///
850    /// ### Explanation
851    ///
852    /// It is likely a mistake to have range patterns in a match expression that overlap in this
853    /// way. Check that the beginning and end values are what you expect, and keep in mind that
854    /// with `..=` the left and right bounds are inclusive.
855    pub OVERLAPPING_RANGE_ENDPOINTS,
856    Warn,
857    "detects range patterns with overlapping endpoints"
858}
859
860declare_lint! {
861    /// The `non_contiguous_range_endpoints` lint detects likely off-by-one errors when using
862    /// exclusive [range patterns].
863    ///
864    /// [range patterns]: https://doc.rust-lang.org/nightly/reference/patterns.html#range-patterns
865    ///
866    /// ### Example
867    ///
868    /// ```rust
869    /// let x = 123u32;
870    /// match x {
871    ///     0..100 => { println!("small"); }
872    ///     101..1000 => { println!("large"); }
873    ///     _ => { println!("larger"); }
874    /// }
875    /// ```
876    ///
877    /// {{produces}}
878    ///
879    /// ### Explanation
880    ///
881    /// It is likely a mistake to have range patterns in a match expression that miss out a single
882    /// number. Check that the beginning and end values are what you expect, and keep in mind that
883    /// with `..=` the right bound is inclusive, and with `..` it is exclusive.
884    pub NON_CONTIGUOUS_RANGE_ENDPOINTS,
885    Warn,
886    "detects off-by-one errors with exclusive range patterns"
887}
888
889declare_lint! {
890    /// The `bindings_with_variant_name` lint detects pattern bindings with
891    /// the same name as one of the matched variants.
892    ///
893    /// ### Example
894    ///
895    /// ```rust,compile_fail
896    /// pub enum Enum {
897    ///     Foo,
898    ///     Bar,
899    /// }
900    ///
901    /// pub fn foo(x: Enum) {
902    ///     match x {
903    ///         Foo => {}
904    ///         Bar => {}
905    ///     }
906    /// }
907    /// ```
908    ///
909    /// {{produces}}
910    ///
911    /// ### Explanation
912    ///
913    /// It is usually a mistake to specify an enum variant name as an
914    /// [identifier pattern]. In the example above, the `match` arms are
915    /// specifying a variable name to bind the value of `x` to. The second arm
916    /// is ignored because the first one matches *all* values. The likely
917    /// intent is that the arm was intended to match on the enum variant.
918    ///
919    /// Two possible solutions are:
920    ///
921    /// * Specify the enum variant using a [path pattern], such as
922    ///   `Enum::Foo`.
923    /// * Bring the enum variants into local scope, such as adding `use
924    ///   Enum::*;` to the beginning of the `foo` function in the example
925    ///   above.
926    ///
927    /// [identifier pattern]: https://doc.rust-lang.org/reference/patterns.html#identifier-patterns
928    /// [path pattern]: https://doc.rust-lang.org/reference/patterns.html#path-patterns
929    pub BINDINGS_WITH_VARIANT_NAME,
930    Deny,
931    "detects pattern bindings with the same name as one of the matched variants"
932}
933
934declare_lint! {
935    /// The `unused_macros` lint detects macros that were not used.
936    ///
937    /// Note that this lint is distinct from the `unused_macro_rules` lint,
938    /// which checks for single rules that never match of an otherwise used
939    /// macro, and thus never expand.
940    ///
941    /// ### Example
942    ///
943    /// ```rust
944    /// macro_rules! unused {
945    ///     () => {};
946    /// }
947    ///
948    /// fn main() {
949    /// }
950    /// ```
951    ///
952    /// {{produces}}
953    ///
954    /// ### Explanation
955    ///
956    /// Unused macros may signal a mistake or unfinished code. To silence the
957    /// warning for the individual macro, prefix the name with an underscore
958    /// such as `_my_macro`. If you intended to export the macro to make it
959    /// available outside of the crate, use the [`macro_export` attribute].
960    ///
961    /// [`macro_export` attribute]: https://doc.rust-lang.org/reference/macros-by-example.html#path-based-scope
962    pub UNUSED_MACROS,
963    Warn,
964    "detects macros that were not used"
965}
966
967declare_lint! {
968    /// The `unused_macro_rules` lint detects macro rules that were not used.
969    ///
970    /// Note that the lint is distinct from the `unused_macros` lint, which
971    /// fires if the entire macro is never called, while this lint fires for
972    /// single unused rules of the macro that is otherwise used.
973    /// `unused_macro_rules` fires only if `unused_macros` wouldn't fire.
974    ///
975    /// ### Example
976    ///
977    /// ```rust
978    /// #[warn(unused_macro_rules)]
979    /// macro_rules! unused_empty {
980    ///     (hello) => { println!("Hello, world!") }; // This rule is unused
981    ///     () => { println!("empty") }; // This rule is used
982    /// }
983    ///
984    /// fn main() {
985    ///     unused_empty!(hello);
986    /// }
987    /// ```
988    ///
989    /// {{produces}}
990    ///
991    /// ### Explanation
992    ///
993    /// Unused macro rules may signal a mistake or unfinished code. Furthermore,
994    /// they slow down compilation. Right now, silencing the warning is not
995    /// supported on a single rule level, so you have to add an allow to the
996    /// entire macro definition.
997    ///
998    /// If you intended to export the macro to make it
999    /// available outside of the crate, use the [`macro_export` attribute].
1000    ///
1001    /// [`macro_export` attribute]: https://doc.rust-lang.org/reference/macros-by-example.html#path-based-scope
1002    pub UNUSED_MACRO_RULES,
1003    Allow,
1004    "detects macro rules that were not used"
1005}
1006
1007declare_lint! {
1008    /// The `warnings` lint allows you to change the level of other
1009    /// lints which produce warnings.
1010    ///
1011    /// ### Example
1012    ///
1013    /// ```rust
1014    /// #![deny(warnings)]
1015    /// fn foo() {}
1016    /// ```
1017    ///
1018    /// {{produces}}
1019    ///
1020    /// ### Explanation
1021    ///
1022    /// The `warnings` lint is a bit special; by changing its level, you
1023    /// change every other warning that would produce a warning to whatever
1024    /// value you'd like. As such, you won't ever trigger this lint in your
1025    /// code directly.
1026    pub WARNINGS,
1027    Warn,
1028    "mass-change the level for lints which produce warnings"
1029}
1030
1031declare_lint! {
1032    /// The `unused_features` lint detects unused or unknown features found in
1033    /// crate-level [`feature` attributes].
1034    ///
1035    /// [`feature` attributes]: https://doc.rust-lang.org/nightly/unstable-book/
1036    ///
1037    /// Note: This lint is currently not functional, see [issue #44232] for
1038    /// more details.
1039    ///
1040    /// [issue #44232]: https://github.com/rust-lang/rust/issues/44232
1041    pub UNUSED_FEATURES,
1042    Warn,
1043    "unused features found in crate-level `#[feature]` directives"
1044}
1045
1046declare_lint! {
1047    /// The `stable_features` lint detects a [`feature` attribute] that
1048    /// has since been made stable.
1049    ///
1050    /// [`feature` attribute]: https://doc.rust-lang.org/nightly/unstable-book/
1051    ///
1052    /// ### Example
1053    ///
1054    /// ```rust
1055    /// #![feature(test_accepted_feature)]
1056    /// fn main() {}
1057    /// ```
1058    ///
1059    /// {{produces}}
1060    ///
1061    /// ### Explanation
1062    ///
1063    /// When a feature is stabilized, it is no longer necessary to include a
1064    /// `#![feature]` attribute for it. To fix, simply remove the
1065    /// `#![feature]` attribute.
1066    pub STABLE_FEATURES,
1067    Warn,
1068    "stable features found in `#[feature]` directive"
1069}
1070
1071declare_lint! {
1072    /// The `unknown_crate_types` lint detects an unknown crate type found in
1073    /// a [`crate_type` attribute].
1074    ///
1075    /// ### Example
1076    ///
1077    /// ```rust,compile_fail
1078    /// #![crate_type="lol"]
1079    /// fn main() {}
1080    /// ```
1081    ///
1082    /// {{produces}}
1083    ///
1084    /// ### Explanation
1085    ///
1086    /// An unknown value give to the `crate_type` attribute is almost
1087    /// certainly a mistake.
1088    ///
1089    /// [`crate_type` attribute]: https://doc.rust-lang.org/reference/linkage.html
1090    pub UNKNOWN_CRATE_TYPES,
1091    Deny,
1092    "unknown crate type found in `#[crate_type]` directive",
1093    crate_level_only
1094}
1095
1096declare_lint! {
1097    /// The `trivial_casts` lint detects trivial casts which could be replaced
1098    /// with coercion, which may require a temporary variable.
1099    ///
1100    /// ### Example
1101    ///
1102    /// ```rust,compile_fail
1103    /// #![deny(trivial_casts)]
1104    /// let x: &u32 = &42;
1105    /// let y = x as *const u32;
1106    /// ```
1107    ///
1108    /// {{produces}}
1109    ///
1110    /// ### Explanation
1111    ///
1112    /// A trivial cast is a cast `e as T` where `e` has type `U` and `U` is a
1113    /// subtype of `T`. This type of cast is usually unnecessary, as it can be
1114    /// usually be inferred.
1115    ///
1116    /// This lint is "allow" by default because there are situations, such as
1117    /// with FFI interfaces or complex type aliases, where it triggers
1118    /// incorrectly, or in situations where it will be more difficult to
1119    /// clearly express the intent. It may be possible that this will become a
1120    /// warning in the future, possibly with an explicit syntax for coercions
1121    /// providing a convenient way to work around the current issues.
1122    /// See [RFC 401 (coercions)][rfc-401], [RFC 803 (type ascription)][rfc-803] and
1123    /// [RFC 3307 (remove type ascription)][rfc-3307] for historical context.
1124    ///
1125    /// [rfc-401]: https://github.com/rust-lang/rfcs/blob/master/text/0401-coercions.md
1126    /// [rfc-803]: https://github.com/rust-lang/rfcs/blob/master/text/0803-type-ascription.md
1127    /// [rfc-3307]: https://github.com/rust-lang/rfcs/blob/master/text/3307-de-rfc-type-ascription.md
1128    pub TRIVIAL_CASTS,
1129    Allow,
1130    "detects trivial casts which could be removed"
1131}
1132
1133declare_lint! {
1134    /// The `trivial_numeric_casts` lint detects trivial numeric casts of types
1135    /// which could be removed.
1136    ///
1137    /// ### Example
1138    ///
1139    /// ```rust,compile_fail
1140    /// #![deny(trivial_numeric_casts)]
1141    /// let x = 42_i32 as i32;
1142    /// ```
1143    ///
1144    /// {{produces}}
1145    ///
1146    /// ### Explanation
1147    ///
1148    /// A trivial numeric cast is a cast of a numeric type to the same numeric
1149    /// type. This type of cast is usually unnecessary.
1150    ///
1151    /// This lint is "allow" by default because there are situations, such as
1152    /// with FFI interfaces or complex type aliases, where it triggers
1153    /// incorrectly, or in situations where it will be more difficult to
1154    /// clearly express the intent. It may be possible that this will become a
1155    /// warning in the future, possibly with an explicit syntax for coercions
1156    /// providing a convenient way to work around the current issues.
1157    /// See [RFC 401 (coercions)][rfc-401], [RFC 803 (type ascription)][rfc-803] and
1158    /// [RFC 3307 (remove type ascription)][rfc-3307] for historical context.
1159    ///
1160    /// [rfc-401]: https://github.com/rust-lang/rfcs/blob/master/text/0401-coercions.md
1161    /// [rfc-803]: https://github.com/rust-lang/rfcs/blob/master/text/0803-type-ascription.md
1162    /// [rfc-3307]: https://github.com/rust-lang/rfcs/blob/master/text/3307-de-rfc-type-ascription.md
1163    pub TRIVIAL_NUMERIC_CASTS,
1164    Allow,
1165    "detects trivial casts of numeric types which could be removed"
1166}
1167
1168declare_lint! {
1169    /// The `exported_private_dependencies` lint detects private dependencies
1170    /// that are exposed in a public interface.
1171    ///
1172    /// ### Example
1173    ///
1174    /// ```rust,ignore (needs-dependency)
1175    /// pub fn foo() -> Option<some_private_dependency::Thing> {
1176    ///     None
1177    /// }
1178    /// ```
1179    ///
1180    /// This will produce:
1181    ///
1182    /// ```text
1183    /// warning: type `bar::Thing` from private dependency 'bar' in public interface
1184    ///  --> src/lib.rs:3:1
1185    ///   |
1186    /// 3 | pub fn foo() -> Option<bar::Thing> {
1187    ///   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
1188    ///   |
1189    ///   = note: `#[warn(exported_private_dependencies)]` on by default
1190    /// ```
1191    ///
1192    /// ### Explanation
1193    ///
1194    /// Dependencies can be marked as "private" to indicate that they are not
1195    /// exposed in the public interface of a crate. This can be used by Cargo
1196    /// to independently resolve those dependencies because it can assume it
1197    /// does not need to unify them with other packages using that same
1198    /// dependency. This lint is an indication of a violation of that
1199    /// contract.
1200    ///
1201    /// To fix this, avoid exposing the dependency in your public interface.
1202    /// Or, switch the dependency to a public dependency.
1203    ///
1204    /// Note that support for this is only available on the nightly channel.
1205    /// See [RFC 1977] for more details, as well as the [Cargo documentation].
1206    ///
1207    /// [RFC 1977]: https://github.com/rust-lang/rfcs/blob/master/text/1977-public-private-dependencies.md
1208    /// [Cargo documentation]: https://doc.rust-lang.org/nightly/cargo/reference/unstable.html#public-dependency
1209    pub EXPORTED_PRIVATE_DEPENDENCIES,
1210    Warn,
1211    "public interface leaks type from a private dependency"
1212}
1213
1214declare_lint! {
1215    /// The `pub_use_of_private_extern_crate` lint detects a specific
1216    /// situation of re-exporting a private `extern crate`.
1217    ///
1218    /// ### Example
1219    ///
1220    /// ```rust,compile_fail
1221    /// extern crate core;
1222    /// pub use core as reexported_core;
1223    /// ```
1224    ///
1225    /// {{produces}}
1226    ///
1227    /// ### Explanation
1228    ///
1229    /// A public `use` declaration should not be used to publicly re-export a
1230    /// private `extern crate`. `pub extern crate` should be used instead.
1231    ///
1232    /// This was historically allowed, but is not the intended behavior
1233    /// according to the visibility rules. This is a [future-incompatible]
1234    /// lint to transition this to a hard error in the future. See [issue
1235    /// #127909] for more details.
1236    ///
1237    /// [issue #127909]: https://github.com/rust-lang/rust/issues/127909
1238    /// [future-incompatible]: ../index.md#future-incompatible-lints
1239    pub PUB_USE_OF_PRIVATE_EXTERN_CRATE,
1240    Deny,
1241    "detect public re-exports of private extern crates",
1242    @future_incompatible = FutureIncompatibleInfo {
1243        reason: FutureIncompatibilityReason::FutureReleaseErrorReportInDeps,
1244        reference: "issue #127909 <https://github.com/rust-lang/rust/issues/127909>",
1245    };
1246}
1247
1248declare_lint! {
1249    /// The `invalid_type_param_default` lint detects type parameter defaults
1250    /// erroneously allowed in an invalid location.
1251    ///
1252    /// ### Example
1253    ///
1254    /// ```rust,compile_fail
1255    /// fn foo<T=i32>(t: T) {}
1256    /// ```
1257    ///
1258    /// {{produces}}
1259    ///
1260    /// ### Explanation
1261    ///
1262    /// Default type parameters were only intended to be allowed in certain
1263    /// situations, but historically the compiler allowed them everywhere.
1264    /// This is a [future-incompatible] lint to transition this to a hard
1265    /// error in the future. See [issue #36887] for more details.
1266    ///
1267    /// [issue #36887]: https://github.com/rust-lang/rust/issues/36887
1268    /// [future-incompatible]: ../index.md#future-incompatible-lints
1269    pub INVALID_TYPE_PARAM_DEFAULT,
1270    Deny,
1271    "type parameter default erroneously allowed in invalid location",
1272    @future_incompatible = FutureIncompatibleInfo {
1273        reason: FutureIncompatibilityReason::FutureReleaseErrorReportInDeps,
1274        reference: "issue #36887 <https://github.com/rust-lang/rust/issues/36887>",
1275    };
1276}
1277
1278declare_lint! {
1279    /// The `renamed_and_removed_lints` lint detects lints that have been
1280    /// renamed or removed.
1281    ///
1282    /// ### Example
1283    ///
1284    /// ```rust
1285    /// #![deny(raw_pointer_derive)]
1286    /// ```
1287    ///
1288    /// {{produces}}
1289    ///
1290    /// ### Explanation
1291    ///
1292    /// To fix this, either remove the lint or use the new name. This can help
1293    /// avoid confusion about lints that are no longer valid, and help
1294    /// maintain consistency for renamed lints.
1295    pub RENAMED_AND_REMOVED_LINTS,
1296    Warn,
1297    "lints that have been renamed or removed"
1298}
1299
1300declare_lint! {
1301    /// The `const_item_mutation` lint detects attempts to mutate a `const`
1302    /// item.
1303    ///
1304    /// ### Example
1305    ///
1306    /// ```rust
1307    /// const FOO: [i32; 1] = [0];
1308    ///
1309    /// fn main() {
1310    ///     FOO[0] = 1;
1311    ///     // This will print "[0]".
1312    ///     println!("{:?}", FOO);
1313    /// }
1314    /// ```
1315    ///
1316    /// {{produces}}
1317    ///
1318    /// ### Explanation
1319    ///
1320    /// Trying to directly mutate a `const` item is almost always a mistake.
1321    /// What is happening in the example above is that a temporary copy of the
1322    /// `const` is mutated, but the original `const` is not. Each time you
1323    /// refer to the `const` by name (such as `FOO` in the example above), a
1324    /// separate copy of the value is inlined at that location.
1325    ///
1326    /// This lint checks for writing directly to a field (`FOO.field =
1327    /// some_value`) or array entry (`FOO[0] = val`), or taking a mutable
1328    /// reference to the const item (`&mut FOO`), including through an
1329    /// autoderef (`FOO.some_mut_self_method()`).
1330    ///
1331    /// There are various alternatives depending on what you are trying to
1332    /// accomplish:
1333    ///
1334    /// * First, always reconsider using mutable globals, as they can be
1335    ///   difficult to use correctly, and can make the code more difficult to
1336    ///   use or understand.
1337    /// * If you are trying to perform a one-time initialization of a global:
1338    ///     * If the value can be computed at compile-time, consider using
1339    ///       const-compatible values (see [Constant Evaluation]).
1340    ///     * For more complex single-initialization cases, consider using
1341    ///       [`std::sync::LazyLock`].
1342    /// * If you truly need a mutable global, consider using a [`static`],
1343    ///   which has a variety of options:
1344    ///   * Simple data types can be directly defined and mutated with an
1345    ///     [`atomic`] type.
1346    ///   * More complex types can be placed in a synchronization primitive
1347    ///     like a [`Mutex`], which can be initialized with one of the options
1348    ///     listed above.
1349    ///   * A [mutable `static`] is a low-level primitive, requiring unsafe.
1350    ///     Typically This should be avoided in preference of something
1351    ///     higher-level like one of the above.
1352    ///
1353    /// [Constant Evaluation]: https://doc.rust-lang.org/reference/const_eval.html
1354    /// [`static`]: https://doc.rust-lang.org/reference/items/static-items.html
1355    /// [mutable `static`]: https://doc.rust-lang.org/reference/items/static-items.html#mutable-statics
1356    /// [`std::sync::LazyLock`]: https://doc.rust-lang.org/stable/std/sync/struct.LazyLock.html
1357    /// [`atomic`]: https://doc.rust-lang.org/std/sync/atomic/index.html
1358    /// [`Mutex`]: https://doc.rust-lang.org/std/sync/struct.Mutex.html
1359    pub CONST_ITEM_MUTATION,
1360    Warn,
1361    "detects attempts to mutate a `const` item",
1362}
1363
1364declare_lint! {
1365    /// The `patterns_in_fns_without_body` lint detects `mut` identifier
1366    /// patterns as a parameter in functions without a body.
1367    ///
1368    /// ### Example
1369    ///
1370    /// ```rust,compile_fail
1371    /// trait Trait {
1372    ///     fn foo(mut arg: u8);
1373    /// }
1374    /// ```
1375    ///
1376    /// {{produces}}
1377    ///
1378    /// ### Explanation
1379    ///
1380    /// To fix this, remove `mut` from the parameter in the trait definition;
1381    /// it can be used in the implementation. That is, the following is OK:
1382    ///
1383    /// ```rust
1384    /// trait Trait {
1385    ///     fn foo(arg: u8); // Removed `mut` here
1386    /// }
1387    ///
1388    /// impl Trait for i32 {
1389    ///     fn foo(mut arg: u8) { // `mut` here is OK
1390    ///
1391    ///     }
1392    /// }
1393    /// ```
1394    ///
1395    /// Trait definitions can define functions without a body to specify a
1396    /// function that implementors must define. The parameter names in the
1397    /// body-less functions are only allowed to be `_` or an [identifier] for
1398    /// documentation purposes (only the type is relevant). Previous versions
1399    /// of the compiler erroneously allowed [identifier patterns] with the
1400    /// `mut` keyword, but this was not intended to be allowed. This is a
1401    /// [future-incompatible] lint to transition this to a hard error in the
1402    /// future. See [issue #35203] for more details.
1403    ///
1404    /// [identifier]: https://doc.rust-lang.org/reference/identifiers.html
1405    /// [identifier patterns]: https://doc.rust-lang.org/reference/patterns.html#identifier-patterns
1406    /// [issue #35203]: https://github.com/rust-lang/rust/issues/35203
1407    /// [future-incompatible]: ../index.md#future-incompatible-lints
1408    pub PATTERNS_IN_FNS_WITHOUT_BODY,
1409    Deny,
1410    "patterns in functions without body were erroneously allowed",
1411    @future_incompatible = FutureIncompatibleInfo {
1412        reason: FutureIncompatibilityReason::FutureReleaseErrorDontReportInDeps,
1413        reference: "issue #35203 <https://github.com/rust-lang/rust/issues/35203>",
1414    };
1415}
1416
1417declare_lint! {
1418    /// The `missing_fragment_specifier` lint is issued when an unused pattern in a
1419    /// `macro_rules!` macro definition has a meta-variable (e.g. `$e`) that is not
1420    /// followed by a fragment specifier (e.g. `:expr`).
1421    ///
1422    /// This warning can always be fixed by removing the unused pattern in the
1423    /// `macro_rules!` macro definition.
1424    ///
1425    /// ### Example
1426    ///
1427    /// ```rust,compile_fail,edition2021
1428    /// macro_rules! foo {
1429    ///    () => {};
1430    ///    ($name) => { };
1431    /// }
1432    ///
1433    /// fn main() {
1434    ///    foo!();
1435    /// }
1436    /// ```
1437    ///
1438    /// {{produces}}
1439    ///
1440    /// ### Explanation
1441    ///
1442    /// To fix this, remove the unused pattern from the `macro_rules!` macro definition:
1443    ///
1444    /// ```rust
1445    /// macro_rules! foo {
1446    ///     () => {};
1447    /// }
1448    /// fn main() {
1449    ///     foo!();
1450    /// }
1451    /// ```
1452    pub MISSING_FRAGMENT_SPECIFIER,
1453    Deny,
1454    "detects missing fragment specifiers in unused `macro_rules!` patterns",
1455    @future_incompatible = FutureIncompatibleInfo {
1456        reason: FutureIncompatibilityReason::FutureReleaseErrorReportInDeps,
1457        reference: "issue #40107 <https://github.com/rust-lang/rust/issues/40107>",
1458    };
1459}
1460
1461declare_lint! {
1462    /// The `late_bound_lifetime_arguments` lint detects generic lifetime
1463    /// arguments in path segments with late bound lifetime parameters.
1464    ///
1465    /// ### Example
1466    ///
1467    /// ```rust
1468    /// struct S;
1469    ///
1470    /// impl S {
1471    ///     fn late(self, _: &u8, _: &u8) {}
1472    /// }
1473    ///
1474    /// fn main() {
1475    ///     S.late::<'static>(&0, &0);
1476    /// }
1477    /// ```
1478    ///
1479    /// {{produces}}
1480    ///
1481    /// ### Explanation
1482    ///
1483    /// It is not clear how to provide arguments for early-bound lifetime
1484    /// parameters if they are intermixed with late-bound parameters in the
1485    /// same list. For now, providing any explicit arguments will trigger this
1486    /// lint if late-bound parameters are present, so in the future a solution
1487    /// can be adopted without hitting backward compatibility issues. This is
1488    /// a [future-incompatible] lint to transition this to a hard error in the
1489    /// future. See [issue #42868] for more details, along with a description
1490    /// of the difference between early and late-bound parameters.
1491    ///
1492    /// [issue #42868]: https://github.com/rust-lang/rust/issues/42868
1493    /// [future-incompatible]: ../index.md#future-incompatible-lints
1494    pub LATE_BOUND_LIFETIME_ARGUMENTS,
1495    Warn,
1496    "detects generic lifetime arguments in path segments with late bound lifetime parameters",
1497    @future_incompatible = FutureIncompatibleInfo {
1498        reason: FutureIncompatibilityReason::FutureReleaseErrorDontReportInDeps,
1499        reference: "issue #42868 <https://github.com/rust-lang/rust/issues/42868>",
1500    };
1501}
1502
1503declare_lint! {
1504    /// The `coherence_leak_check` lint detects conflicting implementations of
1505    /// a trait that are only distinguished by the old leak-check code.
1506    ///
1507    /// ### Example
1508    ///
1509    /// ```rust
1510    /// trait SomeTrait { }
1511    /// impl SomeTrait for for<'a> fn(&'a u8) { }
1512    /// impl<'a> SomeTrait for fn(&'a u8) { }
1513    /// ```
1514    ///
1515    /// {{produces}}
1516    ///
1517    /// ### Explanation
1518    ///
1519    /// In the past, the compiler would accept trait implementations for
1520    /// identical functions that differed only in where the lifetime binder
1521    /// appeared. Due to a change in the borrow checker implementation to fix
1522    /// several bugs, this is no longer allowed. However, since this affects
1523    /// existing code, this is a [future-incompatible] lint to transition this
1524    /// to a hard error in the future.
1525    ///
1526    /// Code relying on this pattern should introduce "[newtypes]",
1527    /// like `struct Foo(for<'a> fn(&'a u8))`.
1528    ///
1529    /// See [issue #56105] for more details.
1530    ///
1531    /// [issue #56105]: https://github.com/rust-lang/rust/issues/56105
1532    /// [newtypes]: https://doc.rust-lang.org/book/ch19-04-advanced-types.html#using-the-newtype-pattern-for-type-safety-and-abstraction
1533    /// [future-incompatible]: ../index.md#future-incompatible-lints
1534    pub COHERENCE_LEAK_CHECK,
1535    Warn,
1536    "distinct impls distinguished only by the leak-check code",
1537    @future_incompatible = FutureIncompatibleInfo {
1538        reason: FutureIncompatibilityReason::Custom("the behavior may change in a future release"),
1539        reference: "issue #56105 <https://github.com/rust-lang/rust/issues/56105>",
1540    };
1541}
1542
1543declare_lint! {
1544    /// The `deprecated` lint detects use of deprecated items.
1545    ///
1546    /// ### Example
1547    ///
1548    /// ```rust
1549    /// #[deprecated]
1550    /// fn foo() {}
1551    ///
1552    /// fn bar() {
1553    ///     foo();
1554    /// }
1555    /// ```
1556    ///
1557    /// {{produces}}
1558    ///
1559    /// ### Explanation
1560    ///
1561    /// Items may be marked "deprecated" with the [`deprecated` attribute] to
1562    /// indicate that they should no longer be used. Usually the attribute
1563    /// should include a note on what to use instead, or check the
1564    /// documentation.
1565    ///
1566    /// [`deprecated` attribute]: https://doc.rust-lang.org/reference/attributes/diagnostics.html#the-deprecated-attribute
1567    pub DEPRECATED,
1568    Warn,
1569    "detects use of deprecated items",
1570    report_in_external_macro
1571}
1572
1573declare_lint! {
1574    /// The `unused_unsafe` lint detects unnecessary use of an `unsafe` block.
1575    ///
1576    /// ### Example
1577    ///
1578    /// ```rust
1579    /// unsafe {}
1580    /// ```
1581    ///
1582    /// {{produces}}
1583    ///
1584    /// ### Explanation
1585    ///
1586    /// If nothing within the block requires `unsafe`, then remove the
1587    /// `unsafe` marker because it is not required and may cause confusion.
1588    pub UNUSED_UNSAFE,
1589    Warn,
1590    "unnecessary use of an `unsafe` block"
1591}
1592
1593declare_lint! {
1594    /// The `unused_mut` lint detects mut variables which don't need to be
1595    /// mutable.
1596    ///
1597    /// ### Example
1598    ///
1599    /// ```rust
1600    /// let mut x = 5;
1601    /// ```
1602    ///
1603    /// {{produces}}
1604    ///
1605    /// ### Explanation
1606    ///
1607    /// The preferred style is to only mark variables as `mut` if it is
1608    /// required.
1609    pub UNUSED_MUT,
1610    Warn,
1611    "detect mut variables which don't need to be mutable"
1612}
1613
1614declare_lint! {
1615    /// The `rust_2024_incompatible_pat` lint
1616    /// detects patterns whose meaning will change in the Rust 2024 edition.
1617    ///
1618    /// ### Example
1619    ///
1620    /// ```rust,edition2021
1621    /// #![warn(rust_2024_incompatible_pat)]
1622    ///
1623    /// if let Some(&a) = &Some(&0u8) {
1624    ///     let _: u8 = a;
1625    /// }
1626    /// if let Some(mut _a) = &mut Some(0u8) {
1627    ///     _a = 7u8;
1628    /// }
1629    /// ```
1630    ///
1631    /// {{produces}}
1632    ///
1633    /// ### Explanation
1634    ///
1635    /// In Rust 2024 and above, the `mut` keyword does not reset the pattern binding mode,
1636    /// and nor do `&` or `&mut` patterns. The lint will suggest code that
1637    /// has the same meaning in all editions.
1638    pub RUST_2024_INCOMPATIBLE_PAT,
1639    Allow,
1640    "detects patterns whose meaning will change in Rust 2024",
1641    @future_incompatible = FutureIncompatibleInfo {
1642        reason: FutureIncompatibilityReason::EditionSemanticsChange(Edition::Edition2024),
1643        reference: "<https://doc.rust-lang.org/nightly/edition-guide/rust-2024/match-ergonomics.html>",
1644    };
1645}
1646
1647declare_lint! {
1648    /// The `unconditional_recursion` lint detects functions that cannot
1649    /// return without calling themselves.
1650    ///
1651    /// ### Example
1652    ///
1653    /// ```rust
1654    /// fn foo() {
1655    ///     foo();
1656    /// }
1657    /// ```
1658    ///
1659    /// {{produces}}
1660    ///
1661    /// ### Explanation
1662    ///
1663    /// It is usually a mistake to have a recursive call that does not have
1664    /// some condition to cause it to terminate. If you really intend to have
1665    /// an infinite loop, using a `loop` expression is recommended.
1666    pub UNCONDITIONAL_RECURSION,
1667    Warn,
1668    "functions that cannot return without calling themselves"
1669}
1670
1671declare_lint! {
1672    /// The `single_use_lifetimes` lint detects lifetimes that are only used
1673    /// once.
1674    ///
1675    /// ### Example
1676    ///
1677    /// ```rust,compile_fail
1678    /// #![deny(single_use_lifetimes)]
1679    ///
1680    /// fn foo<'a>(x: &'a u32) {}
1681    /// ```
1682    ///
1683    /// {{produces}}
1684    ///
1685    /// ### Explanation
1686    ///
1687    /// Specifying an explicit lifetime like `'a` in a function or `impl`
1688    /// should only be used to link together two things. Otherwise, you should
1689    /// just use `'_` to indicate that the lifetime is not linked to anything,
1690    /// or elide the lifetime altogether if possible.
1691    ///
1692    /// This lint is "allow" by default because it was introduced at a time
1693    /// when `'_` and elided lifetimes were first being introduced, and this
1694    /// lint would be too noisy. Also, there are some known false positives
1695    /// that it produces. See [RFC 2115] for historical context, and [issue
1696    /// #44752] for more details.
1697    ///
1698    /// [RFC 2115]: https://github.com/rust-lang/rfcs/blob/master/text/2115-argument-lifetimes.md
1699    /// [issue #44752]: https://github.com/rust-lang/rust/issues/44752
1700    pub SINGLE_USE_LIFETIMES,
1701    Allow,
1702    "detects lifetime parameters that are only used once"
1703}
1704
1705declare_lint! {
1706    /// The `unused_lifetimes` lint detects lifetime parameters that are never
1707    /// used.
1708    ///
1709    /// ### Example
1710    ///
1711    /// ```rust,compile_fail
1712    /// #[deny(unused_lifetimes)]
1713    ///
1714    /// pub fn foo<'a>() {}
1715    /// ```
1716    ///
1717    /// {{produces}}
1718    ///
1719    /// ### Explanation
1720    ///
1721    /// Unused lifetime parameters may signal a mistake or unfinished code.
1722    /// Consider removing the parameter.
1723    pub UNUSED_LIFETIMES,
1724    Allow,
1725    "detects lifetime parameters that are never used"
1726}
1727
1728declare_lint! {
1729    /// The `redundant_lifetimes` lint detects lifetime parameters that are
1730    /// redundant because they are equal to another named lifetime.
1731    ///
1732    /// ### Example
1733    ///
1734    /// ```rust,compile_fail
1735    /// #[deny(redundant_lifetimes)]
1736    ///
1737    /// // `'a = 'static`, so all usages of `'a` can be replaced with `'static`
1738    /// pub fn bar<'a: 'static>() {}
1739    ///
1740    /// // `'a = 'b`, so all usages of `'b` can be replaced with `'a`
1741    /// pub fn bar<'a: 'b, 'b: 'a>() {}
1742    /// ```
1743    ///
1744    /// {{produces}}
1745    ///
1746    /// ### Explanation
1747    ///
1748    /// Unused lifetime parameters may signal a mistake or unfinished code.
1749    /// Consider removing the parameter.
1750    pub REDUNDANT_LIFETIMES,
1751    Allow,
1752    "detects lifetime parameters that are redundant because they are equal to some other named lifetime"
1753}
1754
1755declare_lint! {
1756    /// The `tyvar_behind_raw_pointer` lint detects raw pointer to an
1757    /// inference variable.
1758    ///
1759    /// ### Example
1760    ///
1761    /// ```rust,edition2015
1762    /// // edition 2015
1763    /// let data = std::ptr::null();
1764    /// let _ = &data as *const *const ();
1765    ///
1766    /// if data.is_null() {}
1767    /// ```
1768    ///
1769    /// {{produces}}
1770    ///
1771    /// ### Explanation
1772    ///
1773    /// This kind of inference was previously allowed, but with the future
1774    /// arrival of [arbitrary self types], this can introduce ambiguity. To
1775    /// resolve this, use an explicit type instead of relying on type
1776    /// inference.
1777    ///
1778    /// This is a [future-incompatible] lint to transition this to a hard
1779    /// error in the 2018 edition. See [issue #46906] for more details. This
1780    /// is currently a hard-error on the 2018 edition, and is "warn" by
1781    /// default in the 2015 edition.
1782    ///
1783    /// [arbitrary self types]: https://github.com/rust-lang/rust/issues/44874
1784    /// [issue #46906]: https://github.com/rust-lang/rust/issues/46906
1785    /// [future-incompatible]: ../index.md#future-incompatible-lints
1786    pub TYVAR_BEHIND_RAW_POINTER,
1787    Warn,
1788    "raw pointer to an inference variable",
1789    @future_incompatible = FutureIncompatibleInfo {
1790        reason: FutureIncompatibilityReason::EditionError(Edition::Edition2018),
1791        reference: "issue #46906 <https://github.com/rust-lang/rust/issues/46906>",
1792    };
1793}
1794
1795declare_lint! {
1796    /// The `elided_lifetimes_in_paths` lint detects the use of hidden
1797    /// lifetime parameters.
1798    ///
1799    /// ### Example
1800    ///
1801    /// ```rust,compile_fail
1802    /// #![deny(elided_lifetimes_in_paths)]
1803    /// #![deny(warnings)]
1804    /// struct Foo<'a> {
1805    ///     x: &'a u32
1806    /// }
1807    ///
1808    /// fn foo(x: &Foo) {
1809    /// }
1810    /// ```
1811    ///
1812    /// {{produces}}
1813    ///
1814    /// ### Explanation
1815    ///
1816    /// Elided lifetime parameters can make it difficult to see at a glance
1817    /// that borrowing is occurring. This lint ensures that lifetime
1818    /// parameters are always explicitly stated, even if it is the `'_`
1819    /// [placeholder lifetime].
1820    ///
1821    /// This lint is "allow" by default because it has some known issues, and
1822    /// may require a significant transition for old code.
1823    ///
1824    /// [placeholder lifetime]: https://doc.rust-lang.org/reference/lifetime-elision.html#lifetime-elision-in-functions
1825    pub ELIDED_LIFETIMES_IN_PATHS,
1826    Allow,
1827    "hidden lifetime parameters in types are deprecated"
1828}
1829
1830declare_lint! {
1831    /// The `elided_named_lifetimes` lint detects when an elided
1832    /// lifetime ends up being a named lifetime, such as `'static`
1833    /// or some lifetime parameter `'a`.
1834    ///
1835    /// ### Example
1836    ///
1837    /// ```rust,compile_fail
1838    /// #![deny(elided_named_lifetimes)]
1839    /// struct Foo;
1840    /// impl Foo {
1841    ///     pub fn get_mut(&'static self, x: &mut u8) -> &mut u8 {
1842    ///         unsafe { &mut *(x as *mut _) }
1843    ///     }
1844    /// }
1845    /// ```
1846    ///
1847    /// {{produces}}
1848    ///
1849    /// ### Explanation
1850    ///
1851    /// Lifetime elision is quite useful, because it frees you from having
1852    /// to give each lifetime its own name, but sometimes it can produce
1853    /// somewhat surprising resolutions. In safe code, it is mostly okay,
1854    /// because the borrow checker prevents any unsoundness, so the worst
1855    /// case scenario is you get a confusing error message in some other place.
1856    /// But with `unsafe` code, such unexpected resolutions may lead to unsound code.
1857    pub ELIDED_NAMED_LIFETIMES,
1858    Warn,
1859    "detects when an elided lifetime gets resolved to be `'static` or some named parameter"
1860}
1861
1862declare_lint! {
1863    /// The `bare_trait_objects` lint suggests using `dyn Trait` for trait
1864    /// objects.
1865    ///
1866    /// ### Example
1867    ///
1868    /// ```rust,edition2018
1869    /// trait Trait { }
1870    ///
1871    /// fn takes_trait_object(_: Box<Trait>) {
1872    /// }
1873    /// ```
1874    ///
1875    /// {{produces}}
1876    ///
1877    /// ### Explanation
1878    ///
1879    /// Without the `dyn` indicator, it can be ambiguous or confusing when
1880    /// reading code as to whether or not you are looking at a trait object.
1881    /// The `dyn` keyword makes it explicit, and adds a symmetry to contrast
1882    /// with [`impl Trait`].
1883    ///
1884    /// [`impl Trait`]: https://doc.rust-lang.org/book/ch10-02-traits.html#traits-as-parameters
1885    pub BARE_TRAIT_OBJECTS,
1886    Warn,
1887    "suggest using `dyn Trait` for trait objects",
1888    @future_incompatible = FutureIncompatibleInfo {
1889        reason: FutureIncompatibilityReason::EditionError(Edition::Edition2021),
1890        reference: "<https://doc.rust-lang.org/nightly/edition-guide/rust-2021/warnings-promoted-to-error.html>",
1891    };
1892}
1893
1894declare_lint! {
1895    /// The `absolute_paths_not_starting_with_crate` lint detects fully
1896    /// qualified paths that start with a module name instead of `crate`,
1897    /// `self`, or an extern crate name
1898    ///
1899    /// ### Example
1900    ///
1901    /// ```rust,edition2015,compile_fail
1902    /// #![deny(absolute_paths_not_starting_with_crate)]
1903    ///
1904    /// mod foo {
1905    ///     pub fn bar() {}
1906    /// }
1907    ///
1908    /// fn main() {
1909    ///     ::foo::bar();
1910    /// }
1911    /// ```
1912    ///
1913    /// {{produces}}
1914    ///
1915    /// ### Explanation
1916    ///
1917    /// Rust [editions] allow the language to evolve without breaking
1918    /// backwards compatibility. This lint catches code that uses absolute
1919    /// paths in the style of the 2015 edition. In the 2015 edition, absolute
1920    /// paths (those starting with `::`) refer to either the crate root or an
1921    /// external crate. In the 2018 edition it was changed so that they only
1922    /// refer to external crates. The path prefix `crate::` should be used
1923    /// instead to reference items from the crate root.
1924    ///
1925    /// If you switch the compiler from the 2015 to 2018 edition without
1926    /// updating the code, then it will fail to compile if the old style paths
1927    /// are used. You can manually change the paths to use the `crate::`
1928    /// prefix to transition to the 2018 edition.
1929    ///
1930    /// This lint solves the problem automatically. It is "allow" by default
1931    /// because the code is perfectly valid in the 2015 edition. The [`cargo
1932    /// fix`] tool with the `--edition` flag will switch this lint to "warn"
1933    /// and automatically apply the suggested fix from the compiler. This
1934    /// provides a completely automated way to update old code to the 2018
1935    /// edition.
1936    ///
1937    /// [editions]: https://doc.rust-lang.org/edition-guide/
1938    /// [`cargo fix`]: https://doc.rust-lang.org/cargo/commands/cargo-fix.html
1939    pub ABSOLUTE_PATHS_NOT_STARTING_WITH_CRATE,
1940    Allow,
1941    "fully qualified paths that start with a module name \
1942     instead of `crate`, `self`, or an extern crate name",
1943     @future_incompatible = FutureIncompatibleInfo {
1944        reason: FutureIncompatibilityReason::EditionError(Edition::Edition2018),
1945        reference: "issue #53130 <https://github.com/rust-lang/rust/issues/53130>",
1946     };
1947}
1948
1949declare_lint! {
1950    /// The `unstable_name_collisions` lint detects that you have used a name
1951    /// that the standard library plans to add in the future.
1952    ///
1953    /// ### Example
1954    ///
1955    /// ```rust
1956    /// trait MyIterator : Iterator {
1957    ///     // is_partitioned is an unstable method that already exists on the Iterator trait
1958    ///     fn is_partitioned<P>(self, predicate: P) -> bool
1959    ///     where
1960    ///         Self: Sized,
1961    ///         P: FnMut(Self::Item) -> bool,
1962    ///     {true}
1963    /// }
1964    ///
1965    /// impl<T: ?Sized> MyIterator for T where T: Iterator { }
1966    ///
1967    /// let x = vec![1, 2, 3];
1968    /// let _ = x.iter().is_partitioned(|_| true);
1969    /// ```
1970    ///
1971    /// {{produces}}
1972    ///
1973    /// ### Explanation
1974    ///
1975    /// When new methods are added to traits in the standard library, they are
1976    /// usually added in an "unstable" form which is only available on the
1977    /// [nightly channel] with a [`feature` attribute]. If there is any
1978    /// preexisting code which extends a trait to have a method with the same
1979    /// name, then the names will collide. In the future, when the method is
1980    /// stabilized, this will cause an error due to the ambiguity. This lint
1981    /// is an early-warning to let you know that there may be a collision in
1982    /// the future. This can be avoided by adding type annotations to
1983    /// disambiguate which trait method you intend to call, such as
1984    /// `MyIterator::is_partitioned(my_iter, my_predicate)` or renaming or removing the method.
1985    ///
1986    /// [nightly channel]: https://doc.rust-lang.org/book/appendix-07-nightly-rust.html
1987    /// [`feature` attribute]: https://doc.rust-lang.org/nightly/unstable-book/
1988    pub UNSTABLE_NAME_COLLISIONS,
1989    Warn,
1990    "detects name collision with an existing but unstable method",
1991    @future_incompatible = FutureIncompatibleInfo {
1992        reason: FutureIncompatibilityReason::Custom(
1993            "once this associated item is added to the standard library, \
1994             the ambiguity may cause an error or change in behavior!"
1995        ),
1996        reference: "issue #48919 <https://github.com/rust-lang/rust/issues/48919>",
1997        // Note: this item represents future incompatibility of all unstable functions in the
1998        //       standard library, and thus should never be removed or changed to an error.
1999    };
2000}
2001
2002declare_lint! {
2003    /// The `irrefutable_let_patterns` lint detects [irrefutable patterns]
2004    /// in [`if let`]s, [`while let`]s, and `if let` guards.
2005    ///
2006    /// ### Example
2007    ///
2008    /// ```rust
2009    /// if let _ = 123 {
2010    ///     println!("always runs!");
2011    /// }
2012    /// ```
2013    ///
2014    /// {{produces}}
2015    ///
2016    /// ### Explanation
2017    ///
2018    /// There usually isn't a reason to have an irrefutable pattern in an
2019    /// `if let` or `while let` statement, because the pattern will always match
2020    /// successfully. A [`let`] or [`loop`] statement will suffice. However,
2021    /// when generating code with a macro, forbidding irrefutable patterns
2022    /// would require awkward workarounds in situations where the macro
2023    /// doesn't know if the pattern is refutable or not. This lint allows
2024    /// macros to accept this form, while alerting for a possibly incorrect
2025    /// use in normal code.
2026    ///
2027    /// See [RFC 2086] for more details.
2028    ///
2029    /// [irrefutable patterns]: https://doc.rust-lang.org/reference/patterns.html#refutability
2030    /// [`if let`]: https://doc.rust-lang.org/reference/expressions/if-expr.html#if-let-expressions
2031    /// [`while let`]: https://doc.rust-lang.org/reference/expressions/loop-expr.html#predicate-pattern-loops
2032    /// [`let`]: https://doc.rust-lang.org/reference/statements.html#let-statements
2033    /// [`loop`]: https://doc.rust-lang.org/reference/expressions/loop-expr.html#infinite-loops
2034    /// [RFC 2086]: https://github.com/rust-lang/rfcs/blob/master/text/2086-allow-if-let-irrefutables.md
2035    pub IRREFUTABLE_LET_PATTERNS,
2036    Warn,
2037    "detects irrefutable patterns in `if let` and `while let` statements"
2038}
2039
2040declare_lint! {
2041    /// The `unused_labels` lint detects [labels] that are never used.
2042    ///
2043    /// [labels]: https://doc.rust-lang.org/reference/expressions/loop-expr.html#loop-labels
2044    ///
2045    /// ### Example
2046    ///
2047    /// ```rust,no_run
2048    /// 'unused_label: loop {}
2049    /// ```
2050    ///
2051    /// {{produces}}
2052    ///
2053    /// ### Explanation
2054    ///
2055    /// Unused labels may signal a mistake or unfinished code. To silence the
2056    /// warning for the individual label, prefix it with an underscore such as
2057    /// `'_my_label:`.
2058    pub UNUSED_LABELS,
2059    Warn,
2060    "detects labels that are never used"
2061}
2062
2063declare_lint! {
2064    /// The `proc_macro_derive_resolution_fallback` lint detects proc macro
2065    /// derives using inaccessible names from parent modules.
2066    ///
2067    /// ### Example
2068    ///
2069    /// ```rust,ignore (proc-macro)
2070    /// // foo.rs
2071    /// #![crate_type = "proc-macro"]
2072    ///
2073    /// extern crate proc_macro;
2074    ///
2075    /// use proc_macro::*;
2076    ///
2077    /// #[proc_macro_derive(Foo)]
2078    /// pub fn foo1(a: TokenStream) -> TokenStream {
2079    ///     drop(a);
2080    ///     "mod __bar { static mut BAR: Option<Something> = None; }".parse().unwrap()
2081    /// }
2082    /// ```
2083    ///
2084    /// ```rust,ignore (needs-dependency)
2085    /// // bar.rs
2086    /// #[macro_use]
2087    /// extern crate foo;
2088    ///
2089    /// struct Something;
2090    ///
2091    /// #[derive(Foo)]
2092    /// struct Another;
2093    ///
2094    /// fn main() {}
2095    /// ```
2096    ///
2097    /// This will produce:
2098    ///
2099    /// ```text
2100    /// warning: cannot find type `Something` in this scope
2101    ///  --> src/main.rs:8:10
2102    ///   |
2103    /// 8 | #[derive(Foo)]
2104    ///   |          ^^^ names from parent modules are not accessible without an explicit import
2105    ///   |
2106    ///   = note: `#[warn(proc_macro_derive_resolution_fallback)]` on by default
2107    ///   = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
2108    ///   = note: for more information, see issue #50504 <https://github.com/rust-lang/rust/issues/50504>
2109    /// ```
2110    ///
2111    /// ### Explanation
2112    ///
2113    /// If a proc-macro generates a module, the compiler unintentionally
2114    /// allowed items in that module to refer to items in the crate root
2115    /// without importing them. This is a [future-incompatible] lint to
2116    /// transition this to a hard error in the future. See [issue #50504] for
2117    /// more details.
2118    ///
2119    /// [issue #50504]: https://github.com/rust-lang/rust/issues/50504
2120    /// [future-incompatible]: ../index.md#future-incompatible-lints
2121    pub PROC_MACRO_DERIVE_RESOLUTION_FALLBACK,
2122    Deny,
2123    "detects proc macro derives using inaccessible names from parent modules",
2124    @future_incompatible = FutureIncompatibleInfo {
2125        reason: FutureIncompatibilityReason::FutureReleaseErrorReportInDeps,
2126        reference: "issue #83583 <https://github.com/rust-lang/rust/issues/83583>",
2127    };
2128}
2129
2130declare_lint! {
2131    /// The `macro_use_extern_crate` lint detects the use of the [`macro_use` attribute].
2132    ///
2133    /// ### Example
2134    ///
2135    /// ```rust,ignore (needs extern crate)
2136    /// #![deny(macro_use_extern_crate)]
2137    ///
2138    /// #[macro_use]
2139    /// extern crate serde_json;
2140    ///
2141    /// fn main() {
2142    ///     let _ = json!{{}};
2143    /// }
2144    /// ```
2145    ///
2146    /// This will produce:
2147    ///
2148    /// ```text
2149    /// error: applying the `#[macro_use]` attribute to an `extern crate` item is deprecated
2150    ///  --> src/main.rs:3:1
2151    ///   |
2152    /// 3 | #[macro_use]
2153    ///   | ^^^^^^^^^^^^
2154    ///   |
2155    ///   = help: remove it and import macros at use sites with a `use` item instead
2156    /// note: the lint level is defined here
2157    ///  --> src/main.rs:1:9
2158    ///   |
2159    /// 1 | #![deny(macro_use_extern_crate)]
2160    ///   |         ^^^^^^^^^^^^^^^^^^^^^^
2161    /// ```
2162    ///
2163    /// ### Explanation
2164    ///
2165    /// The [`macro_use` attribute] on an [`extern crate`] item causes
2166    /// macros in that external crate to be brought into the prelude of the
2167    /// crate, making the macros in scope everywhere. As part of the efforts
2168    /// to simplify handling of dependencies in the [2018 edition], the use of
2169    /// `extern crate` is being phased out. To bring macros from extern crates
2170    /// into scope, it is recommended to use a [`use` import].
2171    ///
2172    /// This lint is "allow" by default because this is a stylistic choice
2173    /// that has not been settled, see [issue #52043] for more information.
2174    ///
2175    /// [`macro_use` attribute]: https://doc.rust-lang.org/reference/macros-by-example.html#the-macro_use-attribute
2176    /// [`use` import]: https://doc.rust-lang.org/reference/items/use-declarations.html
2177    /// [issue #52043]: https://github.com/rust-lang/rust/issues/52043
2178    pub MACRO_USE_EXTERN_CRATE,
2179    Allow,
2180    "the `#[macro_use]` attribute is now deprecated in favor of using macros \
2181     via the module system"
2182}
2183
2184declare_lint! {
2185    /// The `macro_expanded_macro_exports_accessed_by_absolute_paths` lint
2186    /// detects macro-expanded [`macro_export`] macros from the current crate
2187    /// that cannot be referred to by absolute paths.
2188    ///
2189    /// [`macro_export`]: https://doc.rust-lang.org/reference/macros-by-example.html#path-based-scope
2190    ///
2191    /// ### Example
2192    ///
2193    /// ```rust,compile_fail
2194    /// macro_rules! define_exported {
2195    ///     () => {
2196    ///         #[macro_export]
2197    ///         macro_rules! exported {
2198    ///             () => {};
2199    ///         }
2200    ///     };
2201    /// }
2202    ///
2203    /// define_exported!();
2204    ///
2205    /// fn main() {
2206    ///     crate::exported!();
2207    /// }
2208    /// ```
2209    ///
2210    /// {{produces}}
2211    ///
2212    /// ### Explanation
2213    ///
2214    /// The intent is that all macros marked with the `#[macro_export]`
2215    /// attribute are made available in the root of the crate. However, when a
2216    /// `macro_rules!` definition is generated by another macro, the macro
2217    /// expansion is unable to uphold this rule. This is a
2218    /// [future-incompatible] lint to transition this to a hard error in the
2219    /// future. See [issue #53495] for more details.
2220    ///
2221    /// [issue #53495]: https://github.com/rust-lang/rust/issues/53495
2222    /// [future-incompatible]: ../index.md#future-incompatible-lints
2223    pub MACRO_EXPANDED_MACRO_EXPORTS_ACCESSED_BY_ABSOLUTE_PATHS,
2224    Deny,
2225    "macro-expanded `macro_export` macros from the current crate \
2226     cannot be referred to by absolute paths",
2227    @future_incompatible = FutureIncompatibleInfo {
2228        reason: FutureIncompatibilityReason::FutureReleaseErrorDontReportInDeps,
2229        reference: "issue #52234 <https://github.com/rust-lang/rust/issues/52234>",
2230    };
2231    crate_level_only
2232}
2233
2234declare_lint! {
2235    /// The `explicit_outlives_requirements` lint detects unnecessary
2236    /// lifetime bounds that can be inferred.
2237    ///
2238    /// ### Example
2239    ///
2240    /// ```rust,compile_fail
2241    /// # #![allow(unused)]
2242    /// #![deny(explicit_outlives_requirements)]
2243    /// #![deny(warnings)]
2244    ///
2245    /// struct SharedRef<'a, T>
2246    /// where
2247    ///     T: 'a,
2248    /// {
2249    ///     data: &'a T,
2250    /// }
2251    /// ```
2252    ///
2253    /// {{produces}}
2254    ///
2255    /// ### Explanation
2256    ///
2257    /// If a `struct` contains a reference, such as `&'a T`, the compiler
2258    /// requires that `T` outlives the lifetime `'a`. This historically
2259    /// required writing an explicit lifetime bound to indicate this
2260    /// requirement. However, this can be overly explicit, causing clutter and
2261    /// unnecessary complexity. The language was changed to automatically
2262    /// infer the bound if it is not specified. Specifically, if the struct
2263    /// contains a reference, directly or indirectly, to `T` with lifetime
2264    /// `'x`, then it will infer that `T: 'x` is a requirement.
2265    ///
2266    /// This lint is "allow" by default because it can be noisy for existing
2267    /// code that already had these requirements. This is a stylistic choice,
2268    /// as it is still valid to explicitly state the bound. It also has some
2269    /// false positives that can cause confusion.
2270    ///
2271    /// See [RFC 2093] for more details.
2272    ///
2273    /// [RFC 2093]: https://github.com/rust-lang/rfcs/blob/master/text/2093-infer-outlives.md
2274    pub EXPLICIT_OUTLIVES_REQUIREMENTS,
2275    Allow,
2276    "outlives requirements can be inferred"
2277}
2278
2279declare_lint! {
2280    /// The `deprecated_in_future` lint is internal to rustc and should not be
2281    /// used by user code.
2282    ///
2283    /// This lint is only enabled in the standard library. It works with the
2284    /// use of `#[deprecated]` with a `since` field of a version in the future.
2285    /// This allows something to be marked as deprecated in a future version,
2286    /// and then this lint will ensure that the item is no longer used in the
2287    /// standard library. See the [stability documentation] for more details.
2288    ///
2289    /// [stability documentation]: https://rustc-dev-guide.rust-lang.org/stability.html#deprecated
2290    pub DEPRECATED_IN_FUTURE,
2291    Allow,
2292    "detects use of items that will be deprecated in a future version",
2293    report_in_external_macro
2294}
2295
2296declare_lint! {
2297    /// The `ambiguous_associated_items` lint detects ambiguity between
2298    /// [associated items] and [enum variants].
2299    ///
2300    /// [associated items]: https://doc.rust-lang.org/reference/items/associated-items.html
2301    /// [enum variants]: https://doc.rust-lang.org/reference/items/enumerations.html
2302    ///
2303    /// ### Example
2304    ///
2305    /// ```rust,compile_fail
2306    /// enum E {
2307    ///     V
2308    /// }
2309    ///
2310    /// trait Tr {
2311    ///     type V;
2312    ///     fn foo() -> Self::V;
2313    /// }
2314    ///
2315    /// impl Tr for E {
2316    ///     type V = u8;
2317    ///     // `Self::V` is ambiguous because it may refer to the associated type or
2318    ///     // the enum variant.
2319    ///     fn foo() -> Self::V { 0 }
2320    /// }
2321    /// ```
2322    ///
2323    /// {{produces}}
2324    ///
2325    /// ### Explanation
2326    ///
2327    /// Previous versions of Rust did not allow accessing enum variants
2328    /// through [type aliases]. When this ability was added (see [RFC 2338]), this
2329    /// introduced some situations where it can be ambiguous what a type
2330    /// was referring to.
2331    ///
2332    /// To fix this ambiguity, you should use a [qualified path] to explicitly
2333    /// state which type to use. For example, in the above example the
2334    /// function can be written as `fn f() -> <Self as Tr>::V { 0 }` to
2335    /// specifically refer to the associated type.
2336    ///
2337    /// This is a [future-incompatible] lint to transition this to a hard
2338    /// error in the future. See [issue #57644] for more details.
2339    ///
2340    /// [issue #57644]: https://github.com/rust-lang/rust/issues/57644
2341    /// [type aliases]: https://doc.rust-lang.org/reference/items/type-aliases.html#type-aliases
2342    /// [RFC 2338]: https://github.com/rust-lang/rfcs/blob/master/text/2338-type-alias-enum-variants.md
2343    /// [qualified path]: https://doc.rust-lang.org/reference/paths.html#qualified-paths
2344    /// [future-incompatible]: ../index.md#future-incompatible-lints
2345    pub AMBIGUOUS_ASSOCIATED_ITEMS,
2346    Deny,
2347    "ambiguous associated items",
2348    @future_incompatible = FutureIncompatibleInfo {
2349        reason: FutureIncompatibilityReason::FutureReleaseErrorDontReportInDeps,
2350        reference: "issue #57644 <https://github.com/rust-lang/rust/issues/57644>",
2351    };
2352}
2353
2354declare_lint! {
2355    /// The `soft_unstable` lint detects unstable features that were unintentionally allowed on
2356    /// stable. This is a [future-incompatible] lint to transition this to a hard error in the
2357    /// future. See [issue #64266] for more details.
2358    ///
2359    /// [issue #64266]: https://github.com/rust-lang/rust/issues/64266
2360    /// [future-incompatible]: ../index.md#future-incompatible-lints
2361    pub SOFT_UNSTABLE,
2362    Deny,
2363    "a feature gate that doesn't break dependent crates",
2364    @future_incompatible = FutureIncompatibleInfo {
2365        reason: FutureIncompatibilityReason::FutureReleaseErrorReportInDeps,
2366        reference: "issue #64266 <https://github.com/rust-lang/rust/issues/64266>",
2367    };
2368}
2369
2370declare_lint! {
2371    /// The `inline_no_sanitize` lint detects incompatible use of
2372    /// [`#[inline(always)]`][inline] and [`#[no_sanitize(...)]`][no_sanitize].
2373    ///
2374    /// [inline]: https://doc.rust-lang.org/reference/attributes/codegen.html#the-inline-attribute
2375    /// [no_sanitize]: https://doc.rust-lang.org/nightly/unstable-book/language-features/no-sanitize.html
2376    ///
2377    /// ### Example
2378    ///
2379    /// ```rust
2380    /// #![feature(no_sanitize)]
2381    ///
2382    /// #[inline(always)]
2383    /// #[no_sanitize(address)]
2384    /// fn x() {}
2385    ///
2386    /// fn main() {
2387    ///     x()
2388    /// }
2389    /// ```
2390    ///
2391    /// {{produces}}
2392    ///
2393    /// ### Explanation
2394    ///
2395    /// The use of the [`#[inline(always)]`][inline] attribute prevents the
2396    /// the [`#[no_sanitize(...)]`][no_sanitize] attribute from working.
2397    /// Consider temporarily removing `inline` attribute.
2398    pub INLINE_NO_SANITIZE,
2399    Warn,
2400    "detects incompatible use of `#[inline(always)]` and `#[no_sanitize(...)]`",
2401}
2402
2403declare_lint! {
2404    /// The `asm_sub_register` lint detects using only a subset of a register
2405    /// for inline asm inputs.
2406    ///
2407    /// ### Example
2408    ///
2409    /// ```rust,ignore (fails on non-x86_64)
2410    /// #[cfg(target_arch="x86_64")]
2411    /// use std::arch::asm;
2412    ///
2413    /// fn main() {
2414    ///     #[cfg(target_arch="x86_64")]
2415    ///     unsafe {
2416    ///         asm!("mov {0}, {0}", in(reg) 0i16);
2417    ///     }
2418    /// }
2419    /// ```
2420    ///
2421    /// This will produce:
2422    ///
2423    /// ```text
2424    /// warning: formatting may not be suitable for sub-register argument
2425    ///  --> src/main.rs:7:19
2426    ///   |
2427    /// 7 |         asm!("mov {0}, {0}", in(reg) 0i16);
2428    ///   |                   ^^^  ^^^           ---- for this argument
2429    ///   |
2430    ///   = note: `#[warn(asm_sub_register)]` on by default
2431    ///   = help: use the `x` modifier to have the register formatted as `ax`
2432    ///   = help: or use the `r` modifier to keep the default formatting of `rax`
2433    /// ```
2434    ///
2435    /// ### Explanation
2436    ///
2437    /// Registers on some architectures can use different names to refer to a
2438    /// subset of the register. By default, the compiler will use the name for
2439    /// the full register size. To explicitly use a subset of the register,
2440    /// you can override the default by using a modifier on the template
2441    /// string operand to specify when subregister to use. This lint is issued
2442    /// if you pass in a value with a smaller data type than the default
2443    /// register size, to alert you of possibly using the incorrect width. To
2444    /// fix this, add the suggested modifier to the template, or cast the
2445    /// value to the correct size.
2446    ///
2447    /// See [register template modifiers] in the reference for more details.
2448    ///
2449    /// [register template modifiers]: https://doc.rust-lang.org/nightly/reference/inline-assembly.html#template-modifiers
2450    pub ASM_SUB_REGISTER,
2451    Warn,
2452    "using only a subset of a register for inline asm inputs",
2453}
2454
2455declare_lint! {
2456    /// The `bad_asm_style` lint detects the use of the `.intel_syntax` and
2457    /// `.att_syntax` directives.
2458    ///
2459    /// ### Example
2460    ///
2461    /// ```rust,ignore (fails on non-x86_64)
2462    /// #[cfg(target_arch="x86_64")]
2463    /// use std::arch::asm;
2464    ///
2465    /// fn main() {
2466    ///     #[cfg(target_arch="x86_64")]
2467    ///     unsafe {
2468    ///         asm!(
2469    ///             ".att_syntax",
2470    ///             "movq %{0}, %{0}", in(reg) 0usize
2471    ///         );
2472    ///     }
2473    /// }
2474    /// ```
2475    ///
2476    /// This will produce:
2477    ///
2478    /// ```text
2479    /// warning: avoid using `.att_syntax`, prefer using `options(att_syntax)` instead
2480    ///  --> src/main.rs:8:14
2481    ///   |
2482    /// 8 |             ".att_syntax",
2483    ///   |              ^^^^^^^^^^^
2484    ///   |
2485    ///   = note: `#[warn(bad_asm_style)]` on by default
2486    /// ```
2487    ///
2488    /// ### Explanation
2489    ///
2490    /// On x86, `asm!` uses the intel assembly syntax by default. While this
2491    /// can be switched using assembler directives like `.att_syntax`, using the
2492    /// `att_syntax` option is recommended instead because it will also properly
2493    /// prefix register placeholders with `%` as required by AT&T syntax.
2494    pub BAD_ASM_STYLE,
2495    Warn,
2496    "incorrect use of inline assembly",
2497}
2498
2499declare_lint! {
2500    /// The `unsafe_op_in_unsafe_fn` lint detects unsafe operations in unsafe
2501    /// functions without an explicit unsafe block.
2502    ///
2503    /// ### Example
2504    ///
2505    /// ```rust,compile_fail
2506    /// #![deny(unsafe_op_in_unsafe_fn)]
2507    ///
2508    /// unsafe fn foo() {}
2509    ///
2510    /// unsafe fn bar() {
2511    ///     foo();
2512    /// }
2513    ///
2514    /// fn main() {}
2515    /// ```
2516    ///
2517    /// {{produces}}
2518    ///
2519    /// ### Explanation
2520    ///
2521    /// Currently, an [`unsafe fn`] allows any [unsafe] operation within its
2522    /// body. However, this can increase the surface area of code that needs
2523    /// to be scrutinized for proper behavior. The [`unsafe` block] provides a
2524    /// convenient way to make it clear exactly which parts of the code are
2525    /// performing unsafe operations. In the future, it is desired to change
2526    /// it so that unsafe operations cannot be performed in an `unsafe fn`
2527    /// without an `unsafe` block.
2528    ///
2529    /// The fix to this is to wrap the unsafe code in an `unsafe` block.
2530    ///
2531    /// This lint is "allow" by default on editions up to 2021, from 2024 it is
2532    /// "warn" by default; the plan for increasing severity further is
2533    /// still being considered. See [RFC #2585] and [issue #71668] for more
2534    /// details.
2535    ///
2536    /// [`unsafe fn`]: https://doc.rust-lang.org/reference/unsafe-functions.html
2537    /// [`unsafe` block]: https://doc.rust-lang.org/reference/expressions/block-expr.html#unsafe-blocks
2538    /// [unsafe]: https://doc.rust-lang.org/reference/unsafety.html
2539    /// [RFC #2585]: https://github.com/rust-lang/rfcs/blob/master/text/2585-unsafe-block-in-unsafe-fn.md
2540    /// [issue #71668]: https://github.com/rust-lang/rust/issues/71668
2541    pub UNSAFE_OP_IN_UNSAFE_FN,
2542    Allow,
2543    "unsafe operations in unsafe functions without an explicit unsafe block are deprecated",
2544    @future_incompatible = FutureIncompatibleInfo {
2545        reason: FutureIncompatibilityReason::EditionSemanticsChange(Edition::Edition2024),
2546        reference: "<https://doc.rust-lang.org/nightly/edition-guide/rust-2024/unsafe-op-in-unsafe-fn.html>",
2547        explain_reason: false
2548    };
2549    @edition Edition2024 => Warn;
2550}
2551
2552declare_lint! {
2553    /// The `fuzzy_provenance_casts` lint detects an `as` cast between an integer
2554    /// and a pointer.
2555    ///
2556    /// ### Example
2557    ///
2558    /// ```rust
2559    /// #![feature(strict_provenance_lints)]
2560    /// #![warn(fuzzy_provenance_casts)]
2561    ///
2562    /// fn main() {
2563    ///     let _dangling = 16_usize as *const u8;
2564    /// }
2565    /// ```
2566    ///
2567    /// {{produces}}
2568    ///
2569    /// ### Explanation
2570    ///
2571    /// This lint is part of the strict provenance effort, see [issue #95228].
2572    /// Casting an integer to a pointer is considered bad style, as a pointer
2573    /// contains, besides the *address* also a *provenance*, indicating what
2574    /// memory the pointer is allowed to read/write. Casting an integer, which
2575    /// doesn't have provenance, to a pointer requires the compiler to assign
2576    /// (guess) provenance. The compiler assigns "all exposed valid" (see the
2577    /// docs of [`ptr::with_exposed_provenance`] for more information about this
2578    /// "exposing"). This penalizes the optimiser and is not well suited for
2579    /// dynamic analysis/dynamic program verification (e.g. Miri or CHERI
2580    /// platforms).
2581    ///
2582    /// It is much better to use [`ptr::with_addr`] instead to specify the
2583    /// provenance you want. If using this function is not possible because the
2584    /// code relies on exposed provenance then there is as an escape hatch
2585    /// [`ptr::with_exposed_provenance`].
2586    ///
2587    /// [issue #95228]: https://github.com/rust-lang/rust/issues/95228
2588    /// [`ptr::with_addr`]: https://doc.rust-lang.org/core/primitive.pointer.html#method.with_addr
2589    /// [`ptr::with_exposed_provenance`]: https://doc.rust-lang.org/core/ptr/fn.with_exposed_provenance.html
2590    pub FUZZY_PROVENANCE_CASTS,
2591    Allow,
2592    "a fuzzy integer to pointer cast is used",
2593    @feature_gate = strict_provenance_lints;
2594}
2595
2596declare_lint! {
2597    /// The `lossy_provenance_casts` lint detects an `as` cast between a pointer
2598    /// and an integer.
2599    ///
2600    /// ### Example
2601    ///
2602    /// ```rust
2603    /// #![feature(strict_provenance_lints)]
2604    /// #![warn(lossy_provenance_casts)]
2605    ///
2606    /// fn main() {
2607    ///     let x: u8 = 37;
2608    ///     let _addr: usize = &x as *const u8 as usize;
2609    /// }
2610    /// ```
2611    ///
2612    /// {{produces}}
2613    ///
2614    /// ### Explanation
2615    ///
2616    /// This lint is part of the strict provenance effort, see [issue #95228].
2617    /// Casting a pointer to an integer is a lossy operation, because beyond
2618    /// just an *address* a pointer may be associated with a particular
2619    /// *provenance*. This information is used by the optimiser and for dynamic
2620    /// analysis/dynamic program verification (e.g. Miri or CHERI platforms).
2621    ///
2622    /// Since this cast is lossy, it is considered good style to use the
2623    /// [`ptr::addr`] method instead, which has a similar effect, but doesn't
2624    /// "expose" the pointer provenance. This improves optimisation potential.
2625    /// See the docs of [`ptr::addr`] and [`ptr::expose_provenance`] for more information
2626    /// about exposing pointer provenance.
2627    ///
2628    /// If your code can't comply with strict provenance and needs to expose
2629    /// the provenance, then there is [`ptr::expose_provenance`] as an escape hatch,
2630    /// which preserves the behaviour of `as usize` casts while being explicit
2631    /// about the semantics.
2632    ///
2633    /// [issue #95228]: https://github.com/rust-lang/rust/issues/95228
2634    /// [`ptr::addr`]: https://doc.rust-lang.org/core/primitive.pointer.html#method.addr
2635    /// [`ptr::expose_provenance`]: https://doc.rust-lang.org/core/primitive.pointer.html#method.expose_provenance
2636    pub LOSSY_PROVENANCE_CASTS,
2637    Allow,
2638    "a lossy pointer to integer cast is used",
2639    @feature_gate = strict_provenance_lints;
2640}
2641
2642declare_lint! {
2643    /// The `const_evaluatable_unchecked` lint detects a generic constant used
2644    /// in a type.
2645    ///
2646    /// ### Example
2647    ///
2648    /// ```rust
2649    /// const fn foo<T>() -> usize {
2650    ///     if size_of::<*mut T>() < 8 { // size of *mut T does not depend on T
2651    ///         4
2652    ///     } else {
2653    ///         8
2654    ///     }
2655    /// }
2656    ///
2657    /// fn test<T>() {
2658    ///     let _ = [0; foo::<T>()];
2659    /// }
2660    /// ```
2661    ///
2662    /// {{produces}}
2663    ///
2664    /// ### Explanation
2665    ///
2666    /// In the 1.43 release, some uses of generic parameters in array repeat
2667    /// expressions were accidentally allowed. This is a [future-incompatible]
2668    /// lint to transition this to a hard error in the future. See [issue
2669    /// #76200] for a more detailed description and possible fixes.
2670    ///
2671    /// [future-incompatible]: ../index.md#future-incompatible-lints
2672    /// [issue #76200]: https://github.com/rust-lang/rust/issues/76200
2673    pub CONST_EVALUATABLE_UNCHECKED,
2674    Warn,
2675    "detects a generic constant is used in a type without a emitting a warning",
2676    @future_incompatible = FutureIncompatibleInfo {
2677        reason: FutureIncompatibilityReason::FutureReleaseErrorDontReportInDeps,
2678        reference: "issue #76200 <https://github.com/rust-lang/rust/issues/76200>",
2679    };
2680}
2681
2682declare_lint! {
2683    /// The `function_item_references` lint detects function references that are
2684    /// formatted with [`fmt::Pointer`] or transmuted.
2685    ///
2686    /// [`fmt::Pointer`]: https://doc.rust-lang.org/std/fmt/trait.Pointer.html
2687    ///
2688    /// ### Example
2689    ///
2690    /// ```rust
2691    /// fn foo() { }
2692    ///
2693    /// fn main() {
2694    ///     println!("{:p}", &foo);
2695    /// }
2696    /// ```
2697    ///
2698    /// {{produces}}
2699    ///
2700    /// ### Explanation
2701    ///
2702    /// Taking a reference to a function may be mistaken as a way to obtain a
2703    /// pointer to that function. This can give unexpected results when
2704    /// formatting the reference as a pointer or transmuting it. This lint is
2705    /// issued when function references are formatted as pointers, passed as
2706    /// arguments bound by [`fmt::Pointer`] or transmuted.
2707    pub FUNCTION_ITEM_REFERENCES,
2708    Warn,
2709    "suggest casting to a function pointer when attempting to take references to function items",
2710}
2711
2712declare_lint! {
2713    /// The `uninhabited_static` lint detects uninhabited statics.
2714    ///
2715    /// ### Example
2716    ///
2717    /// ```rust
2718    /// enum Void {}
2719    /// unsafe extern {
2720    ///     static EXTERN: Void;
2721    /// }
2722    /// ```
2723    ///
2724    /// {{produces}}
2725    ///
2726    /// ### Explanation
2727    ///
2728    /// Statics with an uninhabited type can never be initialized, so they are impossible to define.
2729    /// However, this can be side-stepped with an `extern static`, leading to problems later in the
2730    /// compiler which assumes that there are no initialized uninhabited places (such as locals or
2731    /// statics). This was accidentally allowed, but is being phased out.
2732    pub UNINHABITED_STATIC,
2733    Warn,
2734    "uninhabited static",
2735    @future_incompatible = FutureIncompatibleInfo {
2736        reason: FutureIncompatibilityReason::FutureReleaseErrorDontReportInDeps,
2737        reference: "issue #74840 <https://github.com/rust-lang/rust/issues/74840>",
2738    };
2739}
2740
2741declare_lint! {
2742    /// The `unnameable_test_items` lint detects [`#[test]`][test] functions
2743    /// that are not able to be run by the test harness because they are in a
2744    /// position where they are not nameable.
2745    ///
2746    /// [test]: https://doc.rust-lang.org/reference/attributes/testing.html#the-test-attribute
2747    ///
2748    /// ### Example
2749    ///
2750    /// ```rust,test
2751    /// fn main() {
2752    ///     #[test]
2753    ///     fn foo() {
2754    ///         // This test will not fail because it does not run.
2755    ///         assert_eq!(1, 2);
2756    ///     }
2757    /// }
2758    /// ```
2759    ///
2760    /// {{produces}}
2761    ///
2762    /// ### Explanation
2763    ///
2764    /// In order for the test harness to run a test, the test function must be
2765    /// located in a position where it can be accessed from the crate root.
2766    /// This generally means it must be defined in a module, and not anywhere
2767    /// else such as inside another function. The compiler previously allowed
2768    /// this without an error, so a lint was added as an alert that a test is
2769    /// not being used. Whether or not this should be allowed has not yet been
2770    /// decided, see [RFC 2471] and [issue #36629].
2771    ///
2772    /// [RFC 2471]: https://github.com/rust-lang/rfcs/pull/2471#issuecomment-397414443
2773    /// [issue #36629]: https://github.com/rust-lang/rust/issues/36629
2774    pub UNNAMEABLE_TEST_ITEMS,
2775    Warn,
2776    "detects an item that cannot be named being marked as `#[test_case]`",
2777    report_in_external_macro
2778}
2779
2780declare_lint! {
2781    /// The `useless_deprecated` lint detects deprecation attributes with no effect.
2782    ///
2783    /// ### Example
2784    ///
2785    /// ```rust,compile_fail
2786    /// struct X;
2787    ///
2788    /// #[deprecated = "message"]
2789    /// impl Default for X {
2790    ///     fn default() -> Self {
2791    ///         X
2792    ///     }
2793    /// }
2794    /// ```
2795    ///
2796    /// {{produces}}
2797    ///
2798    /// ### Explanation
2799    ///
2800    /// Deprecation attributes have no effect on trait implementations.
2801    pub USELESS_DEPRECATED,
2802    Deny,
2803    "detects deprecation attributes with no effect",
2804}
2805
2806declare_lint! {
2807    /// The `ineffective_unstable_trait_impl` lint detects `#[unstable]` attributes which are not used.
2808    ///
2809    /// ### Example
2810    ///
2811    /// ```rust,compile_fail
2812    /// #![feature(staged_api)]
2813    ///
2814    /// #[derive(Clone)]
2815    /// #[stable(feature = "x", since = "1")]
2816    /// struct S {}
2817    ///
2818    /// #[unstable(feature = "y", issue = "none")]
2819    /// impl Copy for S {}
2820    /// ```
2821    ///
2822    /// {{produces}}
2823    ///
2824    /// ### Explanation
2825    ///
2826    /// `staged_api` does not currently support using a stability attribute on `impl` blocks.
2827    /// `impl`s are always stable if both the type and trait are stable, and always unstable otherwise.
2828    pub INEFFECTIVE_UNSTABLE_TRAIT_IMPL,
2829    Deny,
2830    "detects `#[unstable]` on stable trait implementations for stable types"
2831}
2832
2833declare_lint! {
2834    /// The `self_constructor_from_outer_item` lint detects cases where the `Self` constructor
2835    /// was silently allowed due to a bug in the resolver, and which may produce surprising
2836    /// and unintended behavior.
2837    ///
2838    /// Using a `Self` type alias from an outer item was never intended, but was silently allowed.
2839    /// This is deprecated -- and is a hard error when the `Self` type alias references generics
2840    /// that are not in scope.
2841    ///
2842    /// ### Example
2843    ///
2844    /// ```rust,compile_fail
2845    /// #![deny(self_constructor_from_outer_item)]
2846    ///
2847    /// struct S0(usize);
2848    ///
2849    /// impl S0 {
2850    ///     fn foo() {
2851    ///         const C: S0 = Self(0);
2852    ///         fn bar() -> S0 {
2853    ///             Self(0)
2854    ///         }
2855    ///     }
2856    /// }
2857    /// ```
2858    ///
2859    /// {{produces}}
2860    ///
2861    /// ### Explanation
2862    ///
2863    /// The `Self` type alias should not be reachable because nested items are not associated with
2864    /// the scope of the parameters from the parent item.
2865    pub SELF_CONSTRUCTOR_FROM_OUTER_ITEM,
2866    Warn,
2867    "detect unsupported use of `Self` from outer item",
2868    @future_incompatible = FutureIncompatibleInfo {
2869        reason: FutureIncompatibilityReason::FutureReleaseErrorDontReportInDeps,
2870        reference: "issue #124186 <https://github.com/rust-lang/rust/issues/124186>",
2871    };
2872}
2873
2874declare_lint! {
2875    /// The `semicolon_in_expressions_from_macros` lint detects trailing semicolons
2876    /// in macro bodies when the macro is invoked in expression position.
2877    /// This was previous accepted, but is being phased out.
2878    ///
2879    /// ### Example
2880    ///
2881    /// ```rust,compile_fail
2882    /// #![deny(semicolon_in_expressions_from_macros)]
2883    /// macro_rules! foo {
2884    ///     () => { true; }
2885    /// }
2886    ///
2887    /// fn main() {
2888    ///     let val = match true {
2889    ///         true => false,
2890    ///         _ => foo!()
2891    ///     };
2892    /// }
2893    /// ```
2894    ///
2895    /// {{produces}}
2896    ///
2897    /// ### Explanation
2898    ///
2899    /// Previous, Rust ignored trailing semicolon in a macro
2900    /// body when a macro was invoked in expression position.
2901    /// However, this makes the treatment of semicolons in the language
2902    /// inconsistent, and could lead to unexpected runtime behavior
2903    /// in some circumstances (e.g. if the macro author expects
2904    /// a value to be dropped).
2905    ///
2906    /// This is a [future-incompatible] lint to transition this
2907    /// to a hard error in the future. See [issue #79813] for more details.
2908    ///
2909    /// [issue #79813]: https://github.com/rust-lang/rust/issues/79813
2910    /// [future-incompatible]: ../index.md#future-incompatible-lints
2911    pub SEMICOLON_IN_EXPRESSIONS_FROM_MACROS,
2912    Warn,
2913    "trailing semicolon in macro body used as expression",
2914    @future_incompatible = FutureIncompatibleInfo {
2915        reason: FutureIncompatibilityReason::FutureReleaseErrorReportInDeps,
2916        reference: "issue #79813 <https://github.com/rust-lang/rust/issues/79813>",
2917    };
2918}
2919
2920declare_lint! {
2921    /// The `legacy_derive_helpers` lint detects derive helper attributes
2922    /// that are used before they are introduced.
2923    ///
2924    /// ### Example
2925    ///
2926    /// ```rust,ignore (needs extern crate)
2927    /// #[serde(rename_all = "camelCase")]
2928    /// #[derive(Deserialize)]
2929    /// struct S { /* fields */ }
2930    /// ```
2931    ///
2932    /// produces:
2933    ///
2934    /// ```text
2935    /// warning: derive helper attribute is used before it is introduced
2936    ///   --> $DIR/legacy-derive-helpers.rs:1:3
2937    ///    |
2938    ///  1 | #[serde(rename_all = "camelCase")]
2939    ///    |   ^^^^^
2940    /// ...
2941    ///  2 | #[derive(Deserialize)]
2942    ///    |          ----------- the attribute is introduced here
2943    /// ```
2944    ///
2945    /// ### Explanation
2946    ///
2947    /// Attributes like this work for historical reasons, but attribute expansion works in
2948    /// left-to-right order in general, so, to resolve `#[serde]`, compiler has to try to "look
2949    /// into the future" at not yet expanded part of the item , but such attempts are not always
2950    /// reliable.
2951    ///
2952    /// To fix the warning place the helper attribute after its corresponding derive.
2953    /// ```rust,ignore (needs extern crate)
2954    /// #[derive(Deserialize)]
2955    /// #[serde(rename_all = "camelCase")]
2956    /// struct S { /* fields */ }
2957    /// ```
2958    pub LEGACY_DERIVE_HELPERS,
2959    Warn,
2960    "detects derive helper attributes that are used before they are introduced",
2961    @future_incompatible = FutureIncompatibleInfo {
2962        reason: FutureIncompatibilityReason::FutureReleaseErrorDontReportInDeps,
2963        reference: "issue #79202 <https://github.com/rust-lang/rust/issues/79202>",
2964    };
2965}
2966
2967declare_lint! {
2968    /// The `large_assignments` lint detects when objects of large
2969    /// types are being moved around.
2970    ///
2971    /// ### Example
2972    ///
2973    /// ```rust,ignore (can crash on some platforms)
2974    /// let x = [0; 50000];
2975    /// let y = x;
2976    /// ```
2977    ///
2978    /// produces:
2979    ///
2980    /// ```text
2981    /// warning: moving a large value
2982    ///   --> $DIR/move-large.rs:1:3
2983    ///   let y = x;
2984    ///           - Copied large value here
2985    /// ```
2986    ///
2987    /// ### Explanation
2988    ///
2989    /// When using a large type in a plain assignment or in a function
2990    /// argument, idiomatic code can be inefficient.
2991    /// Ideally appropriate optimizations would resolve this, but such
2992    /// optimizations are only done in a best-effort manner.
2993    /// This lint will trigger on all sites of large moves and thus allow the
2994    /// user to resolve them in code.
2995    pub LARGE_ASSIGNMENTS,
2996    Warn,
2997    "detects large moves or copies",
2998}
2999
3000declare_lint! {
3001    /// The `unexpected_cfgs` lint detects unexpected conditional compilation conditions.
3002    ///
3003    /// ### Example
3004    ///
3005    /// ```text
3006    /// rustc --check-cfg 'cfg()'
3007    /// ```
3008    ///
3009    /// ```rust,ignore (needs command line option)
3010    /// #[cfg(widnows)]
3011    /// fn foo() {}
3012    /// ```
3013    ///
3014    /// This will produce:
3015    ///
3016    /// ```text
3017    /// warning: unexpected `cfg` condition name: `widnows`
3018    ///  --> lint_example.rs:1:7
3019    ///   |
3020    /// 1 | #[cfg(widnows)]
3021    ///   |       ^^^^^^^
3022    ///   |
3023    ///   = note: `#[warn(unexpected_cfgs)]` on by default
3024    /// ```
3025    ///
3026    /// ### Explanation
3027    ///
3028    /// This lint is only active when [`--check-cfg`][check-cfg] arguments are being
3029    /// passed to the compiler and triggers whenever an unexpected condition name or value is
3030    /// used.
3031    ///
3032    /// See the [Checking Conditional Configurations][check-cfg] section for more
3033    /// details.
3034    ///
3035    /// See the [Cargo Specifics][unexpected_cfgs_lint_config] section for configuring this lint in
3036    /// `Cargo.toml`.
3037    ///
3038    /// [check-cfg]: https://doc.rust-lang.org/nightly/rustc/check-cfg.html
3039    /// [unexpected_cfgs_lint_config]: https://doc.rust-lang.org/nightly/rustc/check-cfg/cargo-specifics.html#check-cfg-in-lintsrust-table
3040    pub UNEXPECTED_CFGS,
3041    Warn,
3042    "detects unexpected names and values in `#[cfg]` conditions",
3043    report_in_external_macro
3044}
3045
3046declare_lint! {
3047    /// The `explicit_builtin_cfgs_in_flags` lint detects builtin cfgs set via the `--cfg` flag.
3048    ///
3049    /// ### Example
3050    ///
3051    /// ```text
3052    /// rustc --cfg unix
3053    /// ```
3054    ///
3055    /// ```rust,ignore (needs command line option)
3056    /// fn main() {}
3057    /// ```
3058    ///
3059    /// This will produce:
3060    ///
3061    /// ```text
3062    /// error: unexpected `--cfg unix` flag
3063    ///   |
3064    ///   = note: config `unix` is only supposed to be controlled by `--target`
3065    ///   = note: manually setting a built-in cfg can and does create incoherent behaviors
3066    ///   = note: `#[deny(explicit_builtin_cfgs_in_flags)]` on by default
3067    /// ```
3068    ///
3069    /// ### Explanation
3070    ///
3071    /// Setting builtin cfgs can and does produce incoherent behavior, it's better to the use
3072    /// the appropriate `rustc` flag that controls the config. For example setting the `windows`
3073    /// cfg but on Linux based target.
3074    pub EXPLICIT_BUILTIN_CFGS_IN_FLAGS,
3075    Deny,
3076    "detects builtin cfgs set via the `--cfg`"
3077}
3078
3079declare_lint! {
3080    /// The `repr_transparent_external_private_fields` lint
3081    /// detects types marked `#[repr(transparent)]` that (transitively)
3082    /// contain an external ZST type marked `#[non_exhaustive]` or containing
3083    /// private fields
3084    ///
3085    /// ### Example
3086    ///
3087    /// ```rust,ignore (needs external crate)
3088    /// #![deny(repr_transparent_external_private_fields)]
3089    /// use foo::NonExhaustiveZst;
3090    ///
3091    /// #[repr(transparent)]
3092    /// struct Bar(u32, ([u32; 0], NonExhaustiveZst));
3093    /// ```
3094    ///
3095    /// This will produce:
3096    ///
3097    /// ```text
3098    /// error: zero-sized fields in repr(transparent) cannot contain external non-exhaustive types
3099    ///  --> src/main.rs:5:28
3100    ///   |
3101    /// 5 | struct Bar(u32, ([u32; 0], NonExhaustiveZst));
3102    ///   |                            ^^^^^^^^^^^^^^^^
3103    ///   |
3104    /// note: the lint level is defined here
3105    ///  --> src/main.rs:1:9
3106    ///   |
3107    /// 1 | #![deny(repr_transparent_external_private_fields)]
3108    ///   |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
3109    ///   = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
3110    ///   = note: for more information, see issue #78586 <https://github.com/rust-lang/rust/issues/78586>
3111    ///   = note: this struct contains `NonExhaustiveZst`, which is marked with `#[non_exhaustive]`, and makes it not a breaking change to become non-zero-sized in the future.
3112    /// ```
3113    ///
3114    /// ### Explanation
3115    ///
3116    /// Previous, Rust accepted fields that contain external private zero-sized types,
3117    /// even though it should not be a breaking change to add a non-zero-sized field to
3118    /// that private type.
3119    ///
3120    /// This is a [future-incompatible] lint to transition this
3121    /// to a hard error in the future. See [issue #78586] for more details.
3122    ///
3123    /// [issue #78586]: https://github.com/rust-lang/rust/issues/78586
3124    /// [future-incompatible]: ../index.md#future-incompatible-lints
3125    pub REPR_TRANSPARENT_EXTERNAL_PRIVATE_FIELDS,
3126    Warn,
3127    "transparent type contains an external ZST that is marked #[non_exhaustive] or contains private fields",
3128    @future_incompatible = FutureIncompatibleInfo {
3129        reason: FutureIncompatibilityReason::FutureReleaseErrorDontReportInDeps,
3130        reference: "issue #78586 <https://github.com/rust-lang/rust/issues/78586>",
3131    };
3132}
3133
3134declare_lint! {
3135    /// The `unstable_syntax_pre_expansion` lint detects the use of unstable
3136    /// syntax that is discarded during attribute expansion.
3137    ///
3138    /// ### Example
3139    ///
3140    /// ```rust
3141    /// #[cfg(FALSE)]
3142    /// macro foo() {}
3143    /// ```
3144    ///
3145    /// {{produces}}
3146    ///
3147    /// ### Explanation
3148    ///
3149    /// The input to active attributes such as `#[cfg]` or procedural macro
3150    /// attributes is required to be valid syntax. Previously, the compiler only
3151    /// gated the use of unstable syntax features after resolving `#[cfg]` gates
3152    /// and expanding procedural macros.
3153    ///
3154    /// To avoid relying on unstable syntax, move the use of unstable syntax
3155    /// into a position where the compiler does not parse the syntax, such as a
3156    /// functionlike macro.
3157    ///
3158    /// ```rust
3159    /// # #![deny(unstable_syntax_pre_expansion)]
3160    ///
3161    /// macro_rules! identity {
3162    ///    ( $($tokens:tt)* ) => { $($tokens)* }
3163    /// }
3164    ///
3165    /// #[cfg(FALSE)]
3166    /// identity! {
3167    ///    macro foo() {}
3168    /// }
3169    /// ```
3170    ///
3171    /// This is a [future-incompatible] lint to transition this
3172    /// to a hard error in the future. See [issue #65860] for more details.
3173    ///
3174    /// [issue #65860]: https://github.com/rust-lang/rust/issues/65860
3175    /// [future-incompatible]: ../index.md#future-incompatible-lints
3176    pub UNSTABLE_SYNTAX_PRE_EXPANSION,
3177    Warn,
3178    "unstable syntax can change at any point in the future, causing a hard error!",
3179    @future_incompatible = FutureIncompatibleInfo {
3180        reason: FutureIncompatibilityReason::FutureReleaseErrorDontReportInDeps,
3181        reference: "issue #65860 <https://github.com/rust-lang/rust/issues/65860>",
3182    };
3183}
3184
3185declare_lint! {
3186    /// The `ambiguous_glob_reexports` lint detects cases where names re-exported via globs
3187    /// collide. Downstream users trying to use the same name re-exported from multiple globs
3188    /// will receive a warning pointing out redefinition of the same name.
3189    ///
3190    /// ### Example
3191    ///
3192    /// ```rust,compile_fail
3193    /// #![deny(ambiguous_glob_reexports)]
3194    /// pub mod foo {
3195    ///     pub type X = u8;
3196    /// }
3197    ///
3198    /// pub mod bar {
3199    ///     pub type Y = u8;
3200    ///     pub type X = u8;
3201    /// }
3202    ///
3203    /// pub use foo::*;
3204    /// pub use bar::*;
3205    ///
3206    ///
3207    /// pub fn main() {}
3208    /// ```
3209    ///
3210    /// {{produces}}
3211    ///
3212    /// ### Explanation
3213    ///
3214    /// This was previously accepted but it could silently break a crate's downstream users code.
3215    /// For example, if `foo::*` and `bar::*` were re-exported before `bar::X` was added to the
3216    /// re-exports, down stream users could use `this_crate::X` without problems. However, adding
3217    /// `bar::X` would cause compilation errors in downstream crates because `X` is defined
3218    /// multiple times in the same namespace of `this_crate`.
3219    pub AMBIGUOUS_GLOB_REEXPORTS,
3220    Warn,
3221    "ambiguous glob re-exports",
3222}
3223
3224declare_lint! {
3225    /// The `hidden_glob_reexports` lint detects cases where glob re-export items are shadowed by
3226    /// private items.
3227    ///
3228    /// ### Example
3229    ///
3230    /// ```rust,compile_fail
3231    /// #![deny(hidden_glob_reexports)]
3232    ///
3233    /// pub mod upstream {
3234    ///     mod inner { pub struct Foo {}; pub struct Bar {}; }
3235    ///     pub use self::inner::*;
3236    ///     struct Foo {} // private item shadows `inner::Foo`
3237    /// }
3238    ///
3239    /// // mod downstream {
3240    /// //     fn test() {
3241    /// //         let _ = crate::upstream::Foo; // inaccessible
3242    /// //     }
3243    /// // }
3244    ///
3245    /// pub fn main() {}
3246    /// ```
3247    ///
3248    /// {{produces}}
3249    ///
3250    /// ### Explanation
3251    ///
3252    /// This was previously accepted without any errors or warnings but it could silently break a
3253    /// crate's downstream user code. If the `struct Foo` was added, `dep::inner::Foo` would
3254    /// silently become inaccessible and trigger a "`struct `Foo` is private`" visibility error at
3255    /// the downstream use site.
3256    pub HIDDEN_GLOB_REEXPORTS,
3257    Warn,
3258    "name introduced by a private item shadows a name introduced by a public glob re-export",
3259}
3260
3261declare_lint! {
3262    /// The `long_running_const_eval` lint is emitted when const
3263    /// eval is running for a long time to ensure rustc terminates
3264    /// even if you accidentally wrote an infinite loop.
3265    ///
3266    /// ### Example
3267    ///
3268    /// ```rust,compile_fail
3269    /// const FOO: () = loop {};
3270    /// ```
3271    ///
3272    /// {{produces}}
3273    ///
3274    /// ### Explanation
3275    ///
3276    /// Loops allow const evaluation to compute arbitrary code, but may also
3277    /// cause infinite loops or just very long running computations.
3278    /// Users can enable long running computations by allowing the lint
3279    /// on individual constants or for entire crates.
3280    ///
3281    /// ### Unconditional warnings
3282    ///
3283    /// Note that regardless of whether the lint is allowed or set to warn,
3284    /// the compiler will issue warnings if constant evaluation runs significantly
3285    /// longer than this lint's limit. These warnings are also shown to downstream
3286    /// users from crates.io or similar registries. If you are above the lint's limit,
3287    /// both you and downstream users might be exposed to these warnings.
3288    /// They might also appear on compiler updates, as the compiler makes minor changes
3289    /// about how complexity is measured: staying below the limit ensures that there
3290    /// is enough room, and given that the lint is disabled for people who use your
3291    /// dependency it means you will be the only one to get the warning and can put
3292    /// out an update in your own time.
3293    pub LONG_RUNNING_CONST_EVAL,
3294    Deny,
3295    "detects long const eval operations",
3296    report_in_external_macro
3297}
3298
3299declare_lint! {
3300    /// The `unused_associated_type_bounds` lint is emitted when an
3301    /// associated type bound is added to a trait object, but the associated
3302    /// type has a `where Self: Sized` bound, and is thus unavailable on the
3303    /// trait object anyway.
3304    ///
3305    /// ### Example
3306    ///
3307    /// ```rust
3308    /// trait Foo {
3309    ///     type Bar where Self: Sized;
3310    /// }
3311    /// type Mop = dyn Foo<Bar = ()>;
3312    /// ```
3313    ///
3314    /// {{produces}}
3315    ///
3316    /// ### Explanation
3317    ///
3318    /// Just like methods with `Self: Sized` bounds are unavailable on trait
3319    /// objects, associated types can be removed from the trait object.
3320    pub UNUSED_ASSOCIATED_TYPE_BOUNDS,
3321    Warn,
3322    "detects unused `Foo = Bar` bounds in `dyn Trait<Foo = Bar>`"
3323}
3324
3325declare_lint! {
3326    /// The `unused_doc_comments` lint detects doc comments that aren't used
3327    /// by `rustdoc`.
3328    ///
3329    /// ### Example
3330    ///
3331    /// ```rust
3332    /// /// docs for x
3333    /// let x = 12;
3334    /// ```
3335    ///
3336    /// {{produces}}
3337    ///
3338    /// ### Explanation
3339    ///
3340    /// `rustdoc` does not use doc comments in all positions, and so the doc
3341    /// comment will be ignored. Try changing it to a normal comment with `//`
3342    /// to avoid the warning.
3343    pub UNUSED_DOC_COMMENTS,
3344    Warn,
3345    "detects doc comments that aren't used by rustdoc"
3346}
3347
3348declare_lint! {
3349    /// The `rust_2021_incompatible_closure_captures` lint detects variables that aren't completely
3350    /// captured in Rust 2021, such that the `Drop` order of their fields may differ between
3351    /// Rust 2018 and 2021.
3352    ///
3353    /// It can also detect when a variable implements a trait like `Send`, but one of its fields does not,
3354    /// and the field is captured by a closure and used with the assumption that said field implements
3355    /// the same trait as the root variable.
3356    ///
3357    /// ### Example of drop reorder
3358    ///
3359    /// ```rust,edition2018,compile_fail
3360    /// #![deny(rust_2021_incompatible_closure_captures)]
3361    /// # #![allow(unused)]
3362    ///
3363    /// struct FancyInteger(i32);
3364    ///
3365    /// impl Drop for FancyInteger {
3366    ///     fn drop(&mut self) {
3367    ///         println!("Just dropped {}", self.0);
3368    ///     }
3369    /// }
3370    ///
3371    /// struct Point { x: FancyInteger, y: FancyInteger }
3372    ///
3373    /// fn main() {
3374    ///   let p = Point { x: FancyInteger(10), y: FancyInteger(20) };
3375    ///
3376    ///   let c = || {
3377    ///      let x = p.x;
3378    ///   };
3379    ///
3380    ///   c();
3381    ///
3382    ///   // ... More code ...
3383    /// }
3384    /// ```
3385    ///
3386    /// {{produces}}
3387    ///
3388    /// ### Explanation
3389    ///
3390    /// In the above example, `p.y` will be dropped at the end of `f` instead of
3391    /// with `c` in Rust 2021.
3392    ///
3393    /// ### Example of auto-trait
3394    ///
3395    /// ```rust,edition2018,compile_fail
3396    /// #![deny(rust_2021_incompatible_closure_captures)]
3397    /// use std::thread;
3398    ///
3399    /// struct Pointer(*mut i32);
3400    /// unsafe impl Send for Pointer {}
3401    ///
3402    /// fn main() {
3403    ///     let mut f = 10;
3404    ///     let fptr = Pointer(&mut f as *mut i32);
3405    ///     thread::spawn(move || unsafe {
3406    ///         *fptr.0 = 20;
3407    ///     });
3408    /// }
3409    /// ```
3410    ///
3411    /// {{produces}}
3412    ///
3413    /// ### Explanation
3414    ///
3415    /// In the above example, only `fptr.0` is captured in Rust 2021.
3416    /// The field is of type `*mut i32`, which doesn't implement `Send`,
3417    /// making the code invalid as the field cannot be sent between threads safely.
3418    pub RUST_2021_INCOMPATIBLE_CLOSURE_CAPTURES,
3419    Allow,
3420    "detects closures affected by Rust 2021 changes",
3421    @future_incompatible = FutureIncompatibleInfo {
3422        reason: FutureIncompatibilityReason::EditionSemanticsChange(Edition::Edition2021),
3423        explain_reason: false,
3424    };
3425}
3426
3427declare_lint_pass!(UnusedDocComment => [UNUSED_DOC_COMMENTS]);
3428
3429declare_lint! {
3430    /// The `missing_abi` lint detects cases where the ABI is omitted from
3431    /// `extern` declarations.
3432    ///
3433    /// ### Example
3434    ///
3435    /// ```rust,compile_fail
3436    /// #![deny(missing_abi)]
3437    ///
3438    /// extern fn foo() {}
3439    /// ```
3440    ///
3441    /// {{produces}}
3442    ///
3443    /// ### Explanation
3444    ///
3445    /// For historic reasons, Rust implicitly selects `C` as the default ABI for
3446    /// `extern` declarations. [Other ABIs] like `C-unwind` and `system` have
3447    /// been added since then, and especially with their addition seeing the ABI
3448    /// easily makes code review easier.
3449    ///
3450    /// [Other ABIs]: https://doc.rust-lang.org/reference/items/external-blocks.html#abi
3451    pub MISSING_ABI,
3452    Warn,
3453    "No declared ABI for extern declaration"
3454}
3455
3456declare_lint! {
3457    /// The `invalid_doc_attributes` lint detects when the `#[doc(...)]` is
3458    /// misused.
3459    ///
3460    /// ### Example
3461    ///
3462    /// ```rust,compile_fail
3463    /// #![deny(warnings)]
3464    ///
3465    /// pub mod submodule {
3466    ///     #![doc(test(no_crate_inject))]
3467    /// }
3468    /// ```
3469    ///
3470    /// {{produces}}
3471    ///
3472    /// ### Explanation
3473    ///
3474    /// Previously, incorrect usage of the `#[doc(..)]` attribute was not
3475    /// being validated. Usually these should be rejected as a hard error,
3476    /// but this lint was introduced to avoid breaking any existing
3477    /// crates which included them.
3478    pub INVALID_DOC_ATTRIBUTES,
3479    Deny,
3480    "detects invalid `#[doc(...)]` attributes",
3481}
3482
3483declare_lint! {
3484    /// The `rust_2021_incompatible_or_patterns` lint detects usage of old versions of or-patterns.
3485    ///
3486    /// ### Example
3487    ///
3488    /// ```rust,edition2018,compile_fail
3489    /// #![deny(rust_2021_incompatible_or_patterns)]
3490    ///
3491    /// macro_rules! match_any {
3492    ///     ( $expr:expr , $( $( $pat:pat )|+ => $expr_arm:expr ),+ ) => {
3493    ///         match $expr {
3494    ///             $(
3495    ///                 $( $pat => $expr_arm, )+
3496    ///             )+
3497    ///         }
3498    ///     };
3499    /// }
3500    ///
3501    /// fn main() {
3502    ///     let result: Result<i64, i32> = Err(42);
3503    ///     let int: i64 = match_any!(result, Ok(i) | Err(i) => i.into());
3504    ///     assert_eq!(int, 42);
3505    /// }
3506    /// ```
3507    ///
3508    /// {{produces}}
3509    ///
3510    /// ### Explanation
3511    ///
3512    /// In Rust 2021, the `pat` matcher will match additional patterns, which include the `|` character.
3513    pub RUST_2021_INCOMPATIBLE_OR_PATTERNS,
3514    Allow,
3515    "detects usage of old versions of or-patterns",
3516    @future_incompatible = FutureIncompatibleInfo {
3517        reason: FutureIncompatibilityReason::EditionError(Edition::Edition2021),
3518        reference: "<https://doc.rust-lang.org/nightly/edition-guide/rust-2021/or-patterns-macro-rules.html>",
3519    };
3520}
3521
3522declare_lint! {
3523    /// The `rust_2021_prelude_collisions` lint detects the usage of trait methods which are ambiguous
3524    /// with traits added to the prelude in future editions.
3525    ///
3526    /// ### Example
3527    ///
3528    /// ```rust,edition2018,compile_fail
3529    /// #![deny(rust_2021_prelude_collisions)]
3530    ///
3531    /// trait Foo {
3532    ///     fn try_into(self) -> Result<String, !>;
3533    /// }
3534    ///
3535    /// impl Foo for &str {
3536    ///     fn try_into(self) -> Result<String, !> {
3537    ///         Ok(String::from(self))
3538    ///     }
3539    /// }
3540    ///
3541    /// fn main() {
3542    ///     let x: String = "3".try_into().unwrap();
3543    ///     //                  ^^^^^^^^
3544    ///     // This call to try_into matches both Foo::try_into and TryInto::try_into as
3545    ///     // `TryInto` has been added to the Rust prelude in 2021 edition.
3546    ///     println!("{x}");
3547    /// }
3548    /// ```
3549    ///
3550    /// {{produces}}
3551    ///
3552    /// ### Explanation
3553    ///
3554    /// In Rust 2021, one of the important introductions is the [prelude changes], which add
3555    /// `TryFrom`, `TryInto`, and `FromIterator` into the standard library's prelude. Since this
3556    /// results in an ambiguity as to which method/function to call when an existing `try_into`
3557    /// method is called via dot-call syntax or a `try_from`/`from_iter` associated function
3558    /// is called directly on a type.
3559    ///
3560    /// [prelude changes]: https://blog.rust-lang.org/inside-rust/2021/03/04/planning-rust-2021.html#prelude-changes
3561    pub RUST_2021_PRELUDE_COLLISIONS,
3562    Allow,
3563    "detects the usage of trait methods which are ambiguous with traits added to the \
3564        prelude in future editions",
3565    @future_incompatible = FutureIncompatibleInfo {
3566        reason: FutureIncompatibilityReason::EditionError(Edition::Edition2021),
3567        reference: "<https://doc.rust-lang.org/nightly/edition-guide/rust-2021/prelude.html>",
3568    };
3569}
3570
3571declare_lint! {
3572    /// The `rust_2024_prelude_collisions` lint detects the usage of trait methods which are ambiguous
3573    /// with traits added to the prelude in future editions.
3574    ///
3575    /// ### Example
3576    ///
3577    /// ```rust,edition2021,compile_fail
3578    /// #![deny(rust_2024_prelude_collisions)]
3579    /// trait Meow {
3580    ///     fn poll(&self) {}
3581    /// }
3582    /// impl<T> Meow for T {}
3583    ///
3584    /// fn main() {
3585    ///     core::pin::pin!(async {}).poll();
3586    ///     //                        ^^^^^^
3587    ///     // This call to try_into matches both Future::poll and Meow::poll as
3588    ///     // `Future` has been added to the Rust prelude in 2024 edition.
3589    /// }
3590    /// ```
3591    ///
3592    /// {{produces}}
3593    ///
3594    /// ### Explanation
3595    ///
3596    /// Rust 2024, introduces two new additions to the standard library's prelude:
3597    /// `Future` and `IntoFuture`. This results in an ambiguity as to which method/function
3598    /// to call when an existing `poll`/`into_future` method is called via dot-call syntax or
3599    /// a `poll`/`into_future` associated function is called directly on a type.
3600    ///
3601    pub RUST_2024_PRELUDE_COLLISIONS,
3602    Allow,
3603    "detects the usage of trait methods which are ambiguous with traits added to the \
3604        prelude in future editions",
3605    @future_incompatible = FutureIncompatibleInfo {
3606        reason: FutureIncompatibilityReason::EditionError(Edition::Edition2024),
3607        reference: "<https://doc.rust-lang.org/nightly/edition-guide/rust-2024/prelude.html>",
3608    };
3609}
3610
3611declare_lint! {
3612    /// The `rust_2021_prefixes_incompatible_syntax` lint detects identifiers that will be parsed as a
3613    /// prefix instead in Rust 2021.
3614    ///
3615    /// ### Example
3616    ///
3617    /// ```rust,edition2018,compile_fail
3618    /// #![deny(rust_2021_prefixes_incompatible_syntax)]
3619    ///
3620    /// macro_rules! m {
3621    ///     (z $x:expr) => ();
3622    /// }
3623    ///
3624    /// m!(z"hey");
3625    /// ```
3626    ///
3627    /// {{produces}}
3628    ///
3629    /// ### Explanation
3630    ///
3631    /// In Rust 2015 and 2018, `z"hey"` is two tokens: the identifier `z`
3632    /// followed by the string literal `"hey"`. In Rust 2021, the `z` is
3633    /// considered a prefix for `"hey"`.
3634    ///
3635    /// This lint suggests to add whitespace between the `z` and `"hey"` tokens
3636    /// to keep them separated in Rust 2021.
3637    // Allow this lint -- rustdoc doesn't yet support threading edition into this lint's parser.
3638    #[allow(rustdoc::invalid_rust_codeblocks)]
3639    pub RUST_2021_PREFIXES_INCOMPATIBLE_SYNTAX,
3640    Allow,
3641    "identifiers that will be parsed as a prefix in Rust 2021",
3642    @future_incompatible = FutureIncompatibleInfo {
3643        reason: FutureIncompatibilityReason::EditionError(Edition::Edition2021),
3644        reference: "<https://doc.rust-lang.org/nightly/edition-guide/rust-2021/reserving-syntax.html>",
3645    };
3646    crate_level_only
3647}
3648
3649declare_lint! {
3650    /// The `unsupported_fn_ptr_calling_conventions` lint is output whenever there is a use of
3651    /// a target dependent calling convention on a target that does not support this calling
3652    /// convention on a function pointer.
3653    ///
3654    /// For example `stdcall` does not make much sense for a x86_64 or, more apparently, powerpc
3655    /// code, because this calling convention was never specified for those targets.
3656    ///
3657    /// ### Example
3658    ///
3659    /// ```rust,ignore (needs specific targets)
3660    /// fn stdcall_ptr(f: extern "stdcall" fn ()) {
3661    ///     f()
3662    /// }
3663    /// ```
3664    ///
3665    /// This will produce:
3666    ///
3667    /// ```text
3668    /// warning: the calling convention `"stdcall"` is not supported on this target
3669    ///   --> $DIR/unsupported.rs:34:15
3670    ///    |
3671    /// LL | fn stdcall_ptr(f: extern "stdcall" fn()) {
3672    ///    |               ^^^^^^^^^^^^^^^^^^^^^^^^
3673    ///    |
3674    ///    = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
3675    ///    = note: for more information, see issue #130260 <https://github.com/rust-lang/rust/issues/130260>
3676    ///    = note: `#[warn(unsupported_fn_ptr_calling_conventions)]` on by default
3677    /// ```
3678    ///
3679    /// ### Explanation
3680    ///
3681    /// On most of the targets the behaviour of `stdcall` and similar calling conventions is not
3682    /// defined at all, but was previously accepted due to a bug in the implementation of the
3683    /// compiler.
3684    pub UNSUPPORTED_FN_PTR_CALLING_CONVENTIONS,
3685    Warn,
3686    "use of unsupported calling convention for function pointer",
3687    @future_incompatible = FutureIncompatibleInfo {
3688        reason: FutureIncompatibilityReason::FutureReleaseErrorReportInDeps,
3689        reference: "issue #130260 <https://github.com/rust-lang/rust/issues/130260>",
3690    };
3691}
3692
3693declare_lint! {
3694    /// The `break_with_label_and_loop` lint detects labeled `break` expressions with
3695    /// an unlabeled loop as their value expression.
3696    ///
3697    /// ### Example
3698    ///
3699    /// ```rust
3700    /// 'label: loop {
3701    ///     break 'label loop { break 42; };
3702    /// };
3703    /// ```
3704    ///
3705    /// {{produces}}
3706    ///
3707    /// ### Explanation
3708    ///
3709    /// In Rust, loops can have a label, and `break` expressions can refer to that label to
3710    /// break out of specific loops (and not necessarily the innermost one). `break` expressions
3711    /// can also carry a value expression, which can be another loop. A labeled `break` with an
3712    /// unlabeled loop as its value expression is easy to confuse with an unlabeled break with
3713    /// a labeled loop and is thus discouraged (but allowed for compatibility); use parentheses
3714    /// around the loop expression to silence this warning. Unlabeled `break` expressions with
3715    /// labeled loops yield a hard error, which can also be silenced by wrapping the expression
3716    /// in parentheses.
3717    pub BREAK_WITH_LABEL_AND_LOOP,
3718    Warn,
3719    "`break` expression with label and unlabeled loop as value expression"
3720}
3721
3722declare_lint! {
3723    /// The `non_exhaustive_omitted_patterns` lint aims to help consumers of a `#[non_exhaustive]`
3724    /// struct or enum who want to match all of its fields/variants explicitly.
3725    ///
3726    /// The `#[non_exhaustive]` annotation forces matches to use wildcards, so exhaustiveness
3727    /// checking cannot be used to ensure that all fields/variants are matched explicitly. To remedy
3728    /// this, this allow-by-default lint warns the user when a match mentions some but not all of
3729    /// the fields/variants of a `#[non_exhaustive]` struct or enum.
3730    ///
3731    /// ### Example
3732    ///
3733    /// ```rust,ignore (needs separate crate)
3734    /// // crate A
3735    /// #[non_exhaustive]
3736    /// pub enum Bar {
3737    ///     A,
3738    ///     B, // added variant in non breaking change
3739    /// }
3740    ///
3741    /// // in crate B
3742    /// #![feature(non_exhaustive_omitted_patterns_lint)]
3743    /// #[warn(non_exhaustive_omitted_patterns)]
3744    /// match Bar::A {
3745    ///     Bar::A => {},
3746    ///     _ => {},
3747    /// }
3748    /// ```
3749    ///
3750    /// This will produce:
3751    ///
3752    /// ```text
3753    /// warning: some variants are not matched explicitly
3754    ///    --> $DIR/reachable-patterns.rs:70:9
3755    ///    |
3756    /// LL |         match Bar::A {
3757    ///    |               ^ pattern `Bar::B` not covered
3758    ///    |
3759    ///  note: the lint level is defined here
3760    ///   --> $DIR/reachable-patterns.rs:69:16
3761    ///    |
3762    /// LL |         #[warn(non_exhaustive_omitted_patterns)]
3763    ///    |                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
3764    ///    = help: ensure that all variants are matched explicitly by adding the suggested match arms
3765    ///    = note: the matched value is of type `Bar` and the `non_exhaustive_omitted_patterns` attribute was found
3766    /// ```
3767    ///
3768    /// Warning: setting this to `deny` will make upstream non-breaking changes (adding fields or
3769    /// variants to a `#[non_exhaustive]` struct or enum) break your crate. This goes against
3770    /// expected semver behavior.
3771    ///
3772    /// ### Explanation
3773    ///
3774    /// Structs and enums tagged with `#[non_exhaustive]` force the user to add a (potentially
3775    /// redundant) wildcard when pattern-matching, to allow for future addition of fields or
3776    /// variants. The `non_exhaustive_omitted_patterns` lint detects when such a wildcard happens to
3777    /// actually catch some fields/variants. In other words, when the match without the wildcard
3778    /// would not be exhaustive. This lets the user be informed if new fields/variants were added.
3779    pub NON_EXHAUSTIVE_OMITTED_PATTERNS,
3780    Allow,
3781    "detect when patterns of types marked `non_exhaustive` are missed",
3782    @feature_gate = non_exhaustive_omitted_patterns_lint;
3783}
3784
3785declare_lint! {
3786    #[allow(text_direction_codepoint_in_literal)]
3787    /// The `text_direction_codepoint_in_comment` lint detects Unicode codepoints in comments that
3788    /// change the visual representation of text on screen in a way that does not correspond to
3789    /// their on memory representation.
3790    ///
3791    /// ### Example
3792    ///
3793    /// ```rust,compile_fail
3794    /// #![deny(text_direction_codepoint_in_comment)]
3795    /// fn main() {
3796    ///     println!("{:?}"); // '‮');
3797    /// }
3798    /// ```
3799    ///
3800    /// {{produces}}
3801    ///
3802    /// ### Explanation
3803    ///
3804    /// Unicode allows changing the visual flow of text on screen in order to support scripts that
3805    /// are written right-to-left, but a specially crafted comment can make code that will be
3806    /// compiled appear to be part of a comment, depending on the software used to read the code.
3807    /// To avoid potential problems or confusion, such as in CVE-2021-42574, by default we deny
3808    /// their use.
3809    pub TEXT_DIRECTION_CODEPOINT_IN_COMMENT,
3810    Deny,
3811    "invisible directionality-changing codepoints in comment"
3812}
3813
3814declare_lint! {
3815    /// The `duplicate_macro_attributes` lint detects when a `#[test]`-like built-in macro
3816    /// attribute is duplicated on an item. This lint may trigger on `bench`, `cfg_eval`, `test`
3817    /// and `test_case`.
3818    ///
3819    /// ### Example
3820    ///
3821    /// ```rust,ignore (needs --test)
3822    /// #[test]
3823    /// #[test]
3824    /// fn foo() {}
3825    /// ```
3826    ///
3827    /// This will produce:
3828    ///
3829    /// ```text
3830    /// warning: duplicated attribute
3831    ///  --> src/lib.rs:2:1
3832    ///   |
3833    /// 2 | #[test]
3834    ///   | ^^^^^^^
3835    ///   |
3836    ///   = note: `#[warn(duplicate_macro_attributes)]` on by default
3837    /// ```
3838    ///
3839    /// ### Explanation
3840    ///
3841    /// A duplicated attribute may erroneously originate from a copy-paste and the effect of it
3842    /// being duplicated may not be obvious or desirable.
3843    ///
3844    /// For instance, doubling the `#[test]` attributes registers the test to be run twice with no
3845    /// change to its environment.
3846    ///
3847    /// [issue #90979]: https://github.com/rust-lang/rust/issues/90979
3848    pub DUPLICATE_MACRO_ATTRIBUTES,
3849    Warn,
3850    "duplicated attribute"
3851}
3852
3853declare_lint! {
3854    /// The `deprecated_where_clause_location` lint detects when a where clause in front of the equals
3855    /// in an associated type.
3856    ///
3857    /// ### Example
3858    ///
3859    /// ```rust
3860    /// trait Trait {
3861    ///   type Assoc<'a> where Self: 'a;
3862    /// }
3863    ///
3864    /// impl Trait for () {
3865    ///   type Assoc<'a> where Self: 'a = ();
3866    /// }
3867    /// ```
3868    ///
3869    /// {{produces}}
3870    ///
3871    /// ### Explanation
3872    ///
3873    /// The preferred location for where clauses on associated types
3874    /// is after the type. However, for most of generic associated types development,
3875    /// it was only accepted before the equals. To provide a transition period and
3876    /// further evaluate this change, both are currently accepted. At some point in
3877    /// the future, this may be disallowed at an edition boundary; but, that is
3878    /// undecided currently.
3879    pub DEPRECATED_WHERE_CLAUSE_LOCATION,
3880    Warn,
3881    "deprecated where clause location"
3882}
3883
3884declare_lint! {
3885    /// The `test_unstable_lint` lint tests unstable lints and is perma-unstable.
3886    ///
3887    /// ### Example
3888    ///
3889    /// ```rust
3890    /// // This lint is intentionally used to test the compiler's behavior
3891    /// // when an unstable lint is enabled without the corresponding feature gate.
3892    /// #![allow(test_unstable_lint)]
3893    /// ```
3894    ///
3895    /// {{produces}}
3896    ///
3897    /// ### Explanation
3898    ///
3899    /// In order to test the behavior of unstable lints, a permanently-unstable
3900    /// lint is required. This lint can be used to trigger warnings and errors
3901    /// from the compiler related to unstable lints.
3902    pub TEST_UNSTABLE_LINT,
3903    Deny,
3904    "this unstable lint is only for testing",
3905    @feature_gate = test_unstable_lint;
3906}
3907
3908declare_lint! {
3909    /// The `ffi_unwind_calls` lint detects calls to foreign functions or function pointers with
3910    /// `C-unwind` or other FFI-unwind ABIs.
3911    ///
3912    /// ### Example
3913    ///
3914    /// ```rust
3915    /// #![warn(ffi_unwind_calls)]
3916    ///
3917    /// unsafe extern "C-unwind" {
3918    ///     fn foo();
3919    /// }
3920    ///
3921    /// fn bar() {
3922    ///     unsafe { foo(); }
3923    ///     let ptr: unsafe extern "C-unwind" fn() = foo;
3924    ///     unsafe { ptr(); }
3925    /// }
3926    /// ```
3927    ///
3928    /// {{produces}}
3929    ///
3930    /// ### Explanation
3931    ///
3932    /// For crates containing such calls, if they are compiled with `-C panic=unwind` then the
3933    /// produced library cannot be linked with crates compiled with `-C panic=abort`. For crates
3934    /// that desire this ability it is therefore necessary to avoid such calls.
3935    pub FFI_UNWIND_CALLS,
3936    Allow,
3937    "call to foreign functions or function pointers with FFI-unwind ABI"
3938}
3939
3940declare_lint! {
3941    /// The `linker_messages` lint forwards warnings from the linker.
3942    ///
3943    /// ### Example
3944    ///
3945    /// ```rust,ignore (needs CLI args, platform-specific)
3946    /// #[warn(linker_messages)]
3947    /// extern "C" {
3948    ///   fn foo();
3949    /// }
3950    /// fn main () { unsafe { foo(); } }
3951    /// ```
3952    ///
3953    /// On Linux, using `gcc -Wl,--warn-unresolved-symbols` as a linker, this will produce
3954    ///
3955    /// ```text
3956    /// warning: linker stderr: rust-lld: undefined symbol: foo
3957    ///          >>> referenced by rust_out.69edbd30df4ae57d-cgu.0
3958    ///          >>>               rust_out.rust_out.69edbd30df4ae57d-cgu.0.rcgu.o:(rust_out::main::h3a90094b06757803)
3959    ///   |
3960    /// note: the lint level is defined here
3961    ///  --> warn.rs:1:9
3962    ///   |
3963    /// 1 | #![warn(linker_messages)]
3964    ///   |         ^^^^^^^^^^^^^^^
3965    /// warning: 1 warning emitted
3966    /// ```
3967    ///
3968    /// ### Explanation
3969    ///
3970    /// Linkers emit platform-specific and program-specific warnings that cannot be predicted in
3971    /// advance by the Rust compiler. Such messages are ignored by default for now. While linker
3972    /// warnings could be very useful they have been ignored for many years by essentially all
3973    /// users, so we need to do a bit more work than just surfacing their text to produce a clear
3974    /// and actionable warning of similar quality to our other diagnostics. See this tracking
3975    /// issue for more details: <https://github.com/rust-lang/rust/issues/136096>.
3976    pub LINKER_MESSAGES,
3977    Allow,
3978    "warnings emitted at runtime by the target-specific linker program"
3979}
3980
3981declare_lint! {
3982    /// The `named_arguments_used_positionally` lint detects cases where named arguments are only
3983    /// used positionally in format strings. This usage is valid but potentially very confusing.
3984    ///
3985    /// ### Example
3986    ///
3987    /// ```rust,compile_fail
3988    /// #![deny(named_arguments_used_positionally)]
3989    /// fn main() {
3990    ///     let _x = 5;
3991    ///     println!("{}", _x = 1); // Prints 1, will trigger lint
3992    ///
3993    ///     println!("{}", _x); // Prints 5, no lint emitted
3994    ///     println!("{_x}", _x = _x); // Prints 5, no lint emitted
3995    /// }
3996    /// ```
3997    ///
3998    /// {{produces}}
3999    ///
4000    /// ### Explanation
4001    ///
4002    /// Rust formatting strings can refer to named arguments by their position, but this usage is
4003    /// potentially confusing. In particular, readers can incorrectly assume that the declaration
4004    /// of named arguments is an assignment (which would produce the unit type).
4005    /// For backwards compatibility, this is not a hard error.
4006    pub NAMED_ARGUMENTS_USED_POSITIONALLY,
4007    Warn,
4008    "named arguments in format used positionally"
4009}
4010
4011declare_lint! {
4012    /// The `never_type_fallback_flowing_into_unsafe` lint detects cases where never type fallback
4013    /// affects unsafe function calls.
4014    ///
4015    /// ### Never type fallback
4016    ///
4017    /// When the compiler sees a value of type [`!`] it implicitly inserts a coercion (if possible),
4018    /// to allow type check to infer any type:
4019    ///
4020    /// ```ignore (illustrative-and-has-placeholders)
4021    /// // this
4022    /// let x: u8 = panic!();
4023    ///
4024    /// // is (essentially) turned by the compiler into
4025    /// let x: u8 = absurd(panic!());
4026    ///
4027    /// // where absurd is a function with the following signature
4028    /// // (it's sound, because `!` always marks unreachable code):
4029    /// fn absurd<T>(never: !) -> T { ... }
4030    /// ```
4031    ///
4032    /// While it's convenient to be able to use non-diverging code in one of the branches (like
4033    /// `if a { b } else { return }`) this could lead to compilation errors:
4034    ///
4035    /// ```compile_fail
4036    /// // this
4037    /// { panic!() };
4038    ///
4039    /// // gets turned into this
4040    /// { absurd(panic!()) }; // error: can't infer the type of `absurd`
4041    /// ```
4042    ///
4043    /// To prevent such errors, compiler remembers where it inserted `absurd` calls, and if it
4044    /// can't infer their type, it sets the type to fallback. `{ absurd::<Fallback>(panic!()) };`.
4045    /// This is what is known as "never type fallback".
4046    ///
4047    /// ### Example
4048    ///
4049    /// ```rust,compile_fail
4050    /// #![deny(never_type_fallback_flowing_into_unsafe)]
4051    /// fn main() {
4052    ///     if true {
4053    ///         // return has type `!` which, is some cases, causes never type fallback
4054    ///         return
4055    ///     } else {
4056    ///         // `zeroed` is an unsafe function, which returns an unbounded type
4057    ///         unsafe { std::mem::zeroed() }
4058    ///     };
4059    ///     // depending on the fallback, `zeroed` may create `()` (which is completely sound),
4060    ///     // or `!` (which is instant undefined behavior)
4061    /// }
4062    /// ```
4063    ///
4064    /// {{produces}}
4065    ///
4066    /// ### Explanation
4067    ///
4068    /// Due to historic reasons never type fallback was `()`, meaning that `!` got spontaneously
4069    /// coerced to `()`. There are plans to change that, but they may make the code such as above
4070    /// unsound. Instead of depending on the fallback, you should specify the type explicitly:
4071    /// ```
4072    /// if true {
4073    ///     return
4074    /// } else {
4075    ///     // type is explicitly specified, fallback can't hurt us no more
4076    ///     unsafe { std::mem::zeroed::<()>() }
4077    /// };
4078    /// ```
4079    ///
4080    /// See [Tracking Issue for making `!` fall back to `!`](https://github.com/rust-lang/rust/issues/123748).
4081    ///
4082    /// [`!`]: https://doc.rust-lang.org/core/primitive.never.html
4083    /// [`()`]: https://doc.rust-lang.org/core/primitive.unit.html
4084    pub NEVER_TYPE_FALLBACK_FLOWING_INTO_UNSAFE,
4085    Warn,
4086    "never type fallback affecting unsafe function calls",
4087    @future_incompatible = FutureIncompatibleInfo {
4088        reason: FutureIncompatibilityReason::EditionAndFutureReleaseSemanticsChange(Edition::Edition2024),
4089        reference: "<https://doc.rust-lang.org/nightly/edition-guide/rust-2024/never-type-fallback.html>",
4090    };
4091    @edition Edition2024 => Deny;
4092    report_in_external_macro
4093}
4094
4095declare_lint! {
4096    /// The `dependency_on_unit_never_type_fallback` lint detects cases where code compiles with
4097    /// [never type fallback] being [`()`], but will stop compiling with fallback being [`!`].
4098    ///
4099    /// [never type fallback]: https://doc.rust-lang.org/nightly/core/primitive.never.html#never-type-fallback
4100    /// [`!`]: https://doc.rust-lang.org/core/primitive.never.html
4101    /// [`()`]: https://doc.rust-lang.org/core/primitive.unit.html
4102    ///
4103    /// ### Example
4104    ///
4105    /// ```rust,compile_fail,edition2021
4106    /// #![deny(dependency_on_unit_never_type_fallback)]
4107    /// fn main() {
4108    ///     if true {
4109    ///         // return has type `!` which, is some cases, causes never type fallback
4110    ///         return
4111    ///     } else {
4112    ///         // the type produced by this call is not specified explicitly,
4113    ///         // so it will be inferred from the previous branch
4114    ///         Default::default()
4115    ///     };
4116    ///     // depending on the fallback, this may compile (because `()` implements `Default`),
4117    ///     // or it may not (because `!` does not implement `Default`)
4118    /// }
4119    /// ```
4120    ///
4121    /// {{produces}}
4122    ///
4123    /// ### Explanation
4124    ///
4125    /// Due to historic reasons never type fallback was `()`, meaning that `!` got spontaneously
4126    /// coerced to `()`. There are plans to change that, but they may make the code such as above
4127    /// not compile. Instead of depending on the fallback, you should specify the type explicitly:
4128    /// ```
4129    /// if true {
4130    ///     return
4131    /// } else {
4132    ///     // type is explicitly specified, fallback can't hurt us no more
4133    ///     <() as Default>::default()
4134    /// };
4135    /// ```
4136    ///
4137    /// See [Tracking Issue for making `!` fall back to `!`](https://github.com/rust-lang/rust/issues/123748).
4138    pub DEPENDENCY_ON_UNIT_NEVER_TYPE_FALLBACK,
4139    Warn,
4140    "never type fallback affecting unsafe function calls",
4141    @future_incompatible = FutureIncompatibleInfo {
4142        reason: FutureIncompatibilityReason::EditionAndFutureReleaseError(Edition::Edition2024),
4143        reference: "<https://doc.rust-lang.org/nightly/edition-guide/rust-2024/never-type-fallback.html>",
4144    };
4145    report_in_external_macro
4146}
4147
4148declare_lint! {
4149    /// The `invalid_macro_export_arguments` lint detects cases where `#[macro_export]` is being used with invalid arguments.
4150    ///
4151    /// ### Example
4152    ///
4153    /// ```rust,compile_fail
4154    /// #![deny(invalid_macro_export_arguments)]
4155    ///
4156    /// #[macro_export(invalid_parameter)]
4157    /// macro_rules! myMacro {
4158    ///    () => {
4159    ///         // [...]
4160    ///    }
4161    /// }
4162    ///
4163    /// #[macro_export(too, many, items)]
4164    /// ```
4165    ///
4166    /// {{produces}}
4167    ///
4168    /// ### Explanation
4169    ///
4170    /// The only valid argument is `#[macro_export(local_inner_macros)]` or no argument (`#[macro_export]`).
4171    /// You can't have multiple arguments in a `#[macro_export(..)]`, or mention arguments other than `local_inner_macros`.
4172    ///
4173    pub INVALID_MACRO_EXPORT_ARGUMENTS,
4174    Warn,
4175    "\"invalid_parameter\" isn't a valid argument for `#[macro_export]`",
4176}
4177
4178declare_lint! {
4179    /// The `private_interfaces` lint detects types in a primary interface of an item,
4180    /// that are more private than the item itself. Primary interface of an item is all
4181    /// its interface except for bounds on generic parameters and where clauses.
4182    ///
4183    /// ### Example
4184    ///
4185    /// ```rust,compile_fail
4186    /// # #![allow(unused)]
4187    /// #![deny(private_interfaces)]
4188    /// struct SemiPriv;
4189    ///
4190    /// mod m1 {
4191    ///     struct Priv;
4192    ///     impl crate::SemiPriv {
4193    ///         pub fn f(_: Priv) {}
4194    ///     }
4195    /// }
4196    ///
4197    /// # fn main() {}
4198    /// ```
4199    ///
4200    /// {{produces}}
4201    ///
4202    /// ### Explanation
4203    ///
4204    /// Having something private in primary interface guarantees that
4205    /// the item will be unusable from outer modules due to type privacy.
4206    pub PRIVATE_INTERFACES,
4207    Warn,
4208    "private type in primary interface of an item",
4209}
4210
4211declare_lint! {
4212    /// The `private_bounds` lint detects types in a secondary interface of an item,
4213    /// that are more private than the item itself. Secondary interface of an item consists of
4214    /// bounds on generic parameters and where clauses, including supertraits for trait items.
4215    ///
4216    /// ### Example
4217    ///
4218    /// ```rust,compile_fail
4219    /// # #![allow(unused)]
4220    /// #![deny(private_bounds)]
4221    ///
4222    /// struct PrivTy;
4223    /// pub struct S
4224    ///     where PrivTy:
4225    /// {}
4226    /// # fn main() {}
4227    /// ```
4228    ///
4229    /// {{produces}}
4230    ///
4231    /// ### Explanation
4232    ///
4233    /// Having private types or traits in item bounds makes it less clear what interface
4234    /// the item actually provides.
4235    pub PRIVATE_BOUNDS,
4236    Warn,
4237    "private type in secondary interface of an item",
4238}
4239
4240declare_lint! {
4241    /// The `unnameable_types` lint detects types for which you can get objects of that type,
4242    /// but cannot name the type itself.
4243    ///
4244    /// ### Example
4245    ///
4246    /// ```rust,compile_fail
4247    /// # #![allow(unused)]
4248    /// #![deny(unnameable_types)]
4249    /// mod m {
4250    ///     pub struct S;
4251    /// }
4252    ///
4253    /// pub fn get_unnameable() -> m::S { m::S }
4254    /// # fn main() {}
4255    /// ```
4256    ///
4257    /// {{produces}}
4258    ///
4259    /// ### Explanation
4260    ///
4261    /// It is often expected that if you can obtain an object of type `T`, then
4262    /// you can name the type `T` as well; this lint attempts to enforce this rule.
4263    /// The recommended action is to either reexport the type properly to make it nameable,
4264    /// or document that users are not supposed to be able to name it for one reason or another.
4265    ///
4266    /// Besides types, this lint applies to traits because traits can also leak through signatures,
4267    /// and you may obtain objects of their `dyn Trait` or `impl Trait` types.
4268    pub UNNAMEABLE_TYPES,
4269    Allow,
4270    "effective visibility of a type is larger than the area in which it can be named",
4271}
4272
4273declare_lint! {
4274    /// The `unknown_or_malformed_diagnostic_attributes` lint detects unrecognized or otherwise malformed
4275    /// diagnostic attributes.
4276    ///
4277    /// ### Example
4278    ///
4279    /// ```rust
4280    /// #![feature(diagnostic_namespace)]
4281    /// #[diagnostic::does_not_exist]
4282    /// struct Foo;
4283    /// ```
4284    ///
4285    /// {{produces}}
4286    ///
4287    ///
4288    /// ### Explanation
4289    ///
4290    /// It is usually a mistake to specify a diagnostic attribute that does not exist. Check
4291    /// the spelling, and check the diagnostic attribute listing for the correct name. Also
4292    /// consider if you are using an old version of the compiler, and the attribute
4293    /// is only available in a newer version.
4294    pub UNKNOWN_OR_MALFORMED_DIAGNOSTIC_ATTRIBUTES,
4295    Warn,
4296    "unrecognized or malformed diagnostic attribute",
4297}
4298
4299declare_lint! {
4300    /// The `ambiguous_glob_imports` lint detects glob imports that should report ambiguity
4301    /// errors, but previously didn't do that due to rustc bugs.
4302    ///
4303    /// ### Example
4304    ///
4305    /// ```rust,compile_fail
4306    /// #![deny(ambiguous_glob_imports)]
4307    /// pub fn foo() -> u32 {
4308    ///     use sub::*;
4309    ///     C
4310    /// }
4311    ///
4312    /// mod sub {
4313    ///     mod mod1 { pub const C: u32 = 1; }
4314    ///     mod mod2 { pub const C: u32 = 2; }
4315    ///
4316    ///     pub use mod1::*;
4317    ///     pub use mod2::*;
4318    /// }
4319    /// ```
4320    ///
4321    /// {{produces}}
4322    ///
4323    /// ### Explanation
4324    ///
4325    /// Previous versions of Rust compile it successfully because it
4326    /// had lost the ambiguity error when resolve `use sub::mod2::*`.
4327    ///
4328    /// This is a [future-incompatible] lint to transition this to a
4329    /// hard error in the future.
4330    ///
4331    /// [future-incompatible]: ../index.md#future-incompatible-lints
4332    pub AMBIGUOUS_GLOB_IMPORTS,
4333    Warn,
4334    "detects certain glob imports that require reporting an ambiguity error",
4335    @future_incompatible = FutureIncompatibleInfo {
4336        reason: FutureIncompatibilityReason::FutureReleaseErrorDontReportInDeps,
4337        reference: "issue #114095 <https://github.com/rust-lang/rust/issues/114095>",
4338    };
4339}
4340
4341declare_lint! {
4342    /// The `refining_impl_trait_reachable` lint detects `impl Trait` return
4343    /// types in method signatures that are refined by a publically reachable
4344    /// trait implementation, meaning the implementation adds information about
4345    /// the return type that is not present in the trait.
4346    ///
4347    /// ### Example
4348    ///
4349    /// ```rust,compile_fail
4350    /// #![deny(refining_impl_trait)]
4351    ///
4352    /// use std::fmt::Display;
4353    ///
4354    /// pub trait AsDisplay {
4355    ///     fn as_display(&self) -> impl Display;
4356    /// }
4357    ///
4358    /// impl<'s> AsDisplay for &'s str {
4359    ///     fn as_display(&self) -> Self {
4360    ///         *self
4361    ///     }
4362    /// }
4363    ///
4364    /// fn main() {
4365    ///     // users can observe that the return type of
4366    ///     // `<&str as AsDisplay>::as_display()` is `&str`.
4367    ///     let _x: &str = "".as_display();
4368    /// }
4369    /// ```
4370    ///
4371    /// {{produces}}
4372    ///
4373    /// ### Explanation
4374    ///
4375    /// Callers of methods for types where the implementation is known are
4376    /// able to observe the types written in the impl signature. This may be
4377    /// intended behavior, but may also lead to implementation details being
4378    /// revealed unintentionally. In particular, it may pose a semver hazard
4379    /// for authors of libraries who do not wish to make stronger guarantees
4380    /// about the types than what is written in the trait signature.
4381    ///
4382    /// `refining_impl_trait` is a lint group composed of two lints:
4383    ///
4384    /// * `refining_impl_trait_reachable`, for refinements that are publically
4385    ///   reachable outside a crate, and
4386    /// * `refining_impl_trait_internal`, for refinements that are only visible
4387    ///    within a crate.
4388    ///
4389    /// We are seeking feedback on each of these lints; see issue
4390    /// [#121718](https://github.com/rust-lang/rust/issues/121718) for more
4391    /// information.
4392    pub REFINING_IMPL_TRAIT_REACHABLE,
4393    Warn,
4394    "impl trait in impl method signature does not match trait method signature",
4395}
4396
4397declare_lint! {
4398    /// The `refining_impl_trait_internal` lint detects `impl Trait` return
4399    /// types in method signatures that are refined by a trait implementation,
4400    /// meaning the implementation adds information about the return type that
4401    /// is not present in the trait.
4402    ///
4403    /// ### Example
4404    ///
4405    /// ```rust,compile_fail
4406    /// #![deny(refining_impl_trait)]
4407    ///
4408    /// use std::fmt::Display;
4409    ///
4410    /// trait AsDisplay {
4411    ///     fn as_display(&self) -> impl Display;
4412    /// }
4413    ///
4414    /// impl<'s> AsDisplay for &'s str {
4415    ///     fn as_display(&self) -> Self {
4416    ///         *self
4417    ///     }
4418    /// }
4419    ///
4420    /// fn main() {
4421    ///     // users can observe that the return type of
4422    ///     // `<&str as AsDisplay>::as_display()` is `&str`.
4423    ///     let _x: &str = "".as_display();
4424    /// }
4425    /// ```
4426    ///
4427    /// {{produces}}
4428    ///
4429    /// ### Explanation
4430    ///
4431    /// Callers of methods for types where the implementation is known are
4432    /// able to observe the types written in the impl signature. This may be
4433    /// intended behavior, but may also lead to implementation details being
4434    /// revealed unintentionally. In particular, it may pose a semver hazard
4435    /// for authors of libraries who do not wish to make stronger guarantees
4436    /// about the types than what is written in the trait signature.
4437    ///
4438    /// `refining_impl_trait` is a lint group composed of two lints:
4439    ///
4440    /// * `refining_impl_trait_reachable`, for refinements that are publically
4441    ///   reachable outside a crate, and
4442    /// * `refining_impl_trait_internal`, for refinements that are only visible
4443    ///    within a crate.
4444    ///
4445    /// We are seeking feedback on each of these lints; see issue
4446    /// [#121718](https://github.com/rust-lang/rust/issues/121718) for more
4447    /// information.
4448    pub REFINING_IMPL_TRAIT_INTERNAL,
4449    Warn,
4450    "impl trait in impl method signature does not match trait method signature",
4451}
4452
4453declare_lint! {
4454    /// The `elided_lifetimes_in_associated_constant` lint detects elided lifetimes
4455    /// in associated constants when there are other lifetimes in scope. This was
4456    /// accidentally supported, and this lint was later relaxed to allow eliding
4457    /// lifetimes to `'static` when there are no lifetimes in scope.
4458    ///
4459    /// ### Example
4460    ///
4461    /// ```rust,compile_fail
4462    /// #![deny(elided_lifetimes_in_associated_constant)]
4463    ///
4464    /// struct Foo<'a>(&'a ());
4465    ///
4466    /// impl<'a> Foo<'a> {
4467    ///     const STR: &str = "hello, world";
4468    /// }
4469    /// ```
4470    ///
4471    /// {{produces}}
4472    ///
4473    /// ### Explanation
4474    ///
4475    /// Previous version of Rust
4476    ///
4477    /// Implicit static-in-const behavior was decided [against] for associated
4478    /// constants because of ambiguity. This, however, regressed and the compiler
4479    /// erroneously treats elided lifetimes in associated constants as lifetime
4480    /// parameters on the impl.
4481    ///
4482    /// This is a [future-incompatible] lint to transition this to a
4483    /// hard error in the future.
4484    ///
4485    /// [against]: https://github.com/rust-lang/rust/issues/38831
4486    /// [future-incompatible]: ../index.md#future-incompatible-lints
4487    pub ELIDED_LIFETIMES_IN_ASSOCIATED_CONSTANT,
4488    Deny,
4489    "elided lifetimes cannot be used in associated constants in impls",
4490    @future_incompatible = FutureIncompatibleInfo {
4491        reason: FutureIncompatibilityReason::FutureReleaseErrorDontReportInDeps,
4492        reference: "issue #115010 <https://github.com/rust-lang/rust/issues/115010>",
4493    };
4494}
4495
4496declare_lint! {
4497    /// The `private_macro_use` lint detects private macros that are imported
4498    /// with `#[macro_use]`.
4499    ///
4500    /// ### Example
4501    ///
4502    /// ```rust,ignore (needs extern crate)
4503    /// // extern_macro.rs
4504    /// macro_rules! foo_ { () => {}; }
4505    /// use foo_ as foo;
4506    ///
4507    /// // code.rs
4508    ///
4509    /// #![deny(private_macro_use)]
4510    ///
4511    /// #[macro_use]
4512    /// extern crate extern_macro;
4513    ///
4514    /// fn main() {
4515    ///     foo!();
4516    /// }
4517    /// ```
4518    ///
4519    /// This will produce:
4520    ///
4521    /// ```text
4522    /// error: cannot find macro `foo` in this scope
4523    /// ```
4524    ///
4525    /// ### Explanation
4526    ///
4527    /// This lint arises from overlooking visibility checks for macros
4528    /// in an external crate.
4529    ///
4530    /// This is a [future-incompatible] lint to transition this to a
4531    /// hard error in the future.
4532    ///
4533    /// [future-incompatible]: ../index.md#future-incompatible-lints
4534    pub PRIVATE_MACRO_USE,
4535    Warn,
4536    "detects certain macro bindings that should not be re-exported",
4537    @future_incompatible = FutureIncompatibleInfo {
4538        reason: FutureIncompatibilityReason::FutureReleaseErrorDontReportInDeps,
4539        reference: "issue #120192 <https://github.com/rust-lang/rust/issues/120192>",
4540    };
4541}
4542
4543declare_lint! {
4544    /// The `uncovered_param_in_projection` lint detects a violation of one of Rust's orphan rules for
4545    /// foreign trait implementations that concerns the use of type parameters inside trait associated
4546    /// type paths ("projections") whose output may not be a local type that is mistakenly considered
4547    /// to "cover" said parameters which is **unsound** and which may be rejected by a future version
4548    /// of the compiler.
4549    ///
4550    /// Originally reported in [#99554].
4551    ///
4552    /// [#99554]: https://github.com/rust-lang/rust/issues/99554
4553    ///
4554    /// ### Example
4555    ///
4556    /// ```rust,ignore (dependent)
4557    /// // dependency.rs
4558    /// #![crate_type = "lib"]
4559    ///
4560    /// pub trait Trait<T, U> {}
4561    /// ```
4562    ///
4563    /// ```edition2021,ignore (needs dependency)
4564    /// // dependent.rs
4565    /// trait Identity {
4566    ///     type Output;
4567    /// }
4568    ///
4569    /// impl<T> Identity for T {
4570    ///     type Output = T;
4571    /// }
4572    ///
4573    /// struct Local;
4574    ///
4575    /// impl<T> dependency::Trait<Local, T> for <T as Identity>::Output {}
4576    ///
4577    /// fn main() {}
4578    /// ```
4579    ///
4580    /// This will produce:
4581    ///
4582    /// ```text
4583    /// warning[E0210]: type parameter `T` must be covered by another type when it appears before the first local type (`Local`)
4584    ///   --> dependent.rs:11:6
4585    ///    |
4586    /// 11 | impl<T> dependency::Trait<Local, T> for <T as Identity>::Output {}
4587    ///    |      ^ type parameter `T` must be covered by another type when it appears before the first local type (`Local`)
4588    ///    |
4589    ///    = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
4590    ///    = note: for more information, see issue #124559 <https://github.com/rust-lang/rust/issues/124559>
4591    ///    = note: implementing a foreign trait is only possible if at least one of the types for which it is implemented is local, and no uncovered type parameters appear before that first local type
4592    ///    = note: in this case, 'before' refers to the following order: `impl<..> ForeignTrait<T1, ..., Tn> for T0`, where `T0` is the first and `Tn` is the last
4593    ///    = note: `#[warn(uncovered_param_in_projection)]` on by default
4594    /// ```
4595    ///
4596    /// ### Explanation
4597    ///
4598    /// FIXME(fmease): Write explainer.
4599    pub UNCOVERED_PARAM_IN_PROJECTION,
4600    Warn,
4601    "impl contains type parameters that are not covered",
4602    @future_incompatible = FutureIncompatibleInfo {
4603        reason: FutureIncompatibilityReason::FutureReleaseErrorDontReportInDeps,
4604        reference: "issue #124559 <https://github.com/rust-lang/rust/issues/124559>",
4605    };
4606}
4607
4608declare_lint! {
4609    /// The `deprecated_safe_2024` lint detects unsafe functions being used as
4610    /// safe functions.
4611    ///
4612    /// ### Example
4613    ///
4614    /// ```rust,edition2021,compile_fail
4615    /// #![deny(deprecated_safe)]
4616    /// // edition 2021
4617    /// use std::env;
4618    /// fn enable_backtrace() {
4619    ///     env::set_var("RUST_BACKTRACE", "1");
4620    /// }
4621    /// ```
4622    ///
4623    /// {{produces}}
4624    ///
4625    /// ### Explanation
4626    ///
4627    /// Rust [editions] allow the language to evolve without breaking backward
4628    /// compatibility. This lint catches code that uses `unsafe` functions that
4629    /// were declared as safe (non-`unsafe`) in editions prior to Rust 2024. If
4630    /// you switch the compiler to Rust 2024 without updating the code, then it
4631    /// will fail to compile if you are using a function previously marked as
4632    /// safe.
4633    ///
4634    /// You can audit the code to see if it suffices the preconditions of the
4635    /// `unsafe` code, and if it does, you can wrap it in an `unsafe` block. If
4636    /// you can't fulfill the preconditions, you probably need to switch to a
4637    /// different way of doing what you want to achieve.
4638    ///
4639    /// This lint can automatically wrap the calls in `unsafe` blocks, but this
4640    /// obviously cannot verify that the preconditions of the `unsafe`
4641    /// functions are fulfilled, so that is still up to the user.
4642    ///
4643    /// The lint is currently "allow" by default, but that might change in the
4644    /// future.
4645    ///
4646    /// [editions]: https://doc.rust-lang.org/edition-guide/
4647    pub DEPRECATED_SAFE_2024,
4648    Allow,
4649    "detects unsafe functions being used as safe functions",
4650    @future_incompatible = FutureIncompatibleInfo {
4651        reason: FutureIncompatibilityReason::EditionError(Edition::Edition2024),
4652        reference: "<https://doc.rust-lang.org/nightly/edition-guide/rust-2024/newly-unsafe-functions.html>",
4653    };
4654}
4655
4656declare_lint! {
4657    /// The `missing_unsafe_on_extern` lint detects missing unsafe keyword on extern declarations.
4658    ///
4659    /// ### Example
4660    ///
4661    /// ```rust,edition2021
4662    /// #![warn(missing_unsafe_on_extern)]
4663    /// #![allow(dead_code)]
4664    ///
4665    /// extern "C" {
4666    ///     fn foo(_: i32);
4667    /// }
4668    ///
4669    /// fn main() {}
4670    /// ```
4671    ///
4672    /// {{produces}}
4673    ///
4674    /// ### Explanation
4675    ///
4676    /// Declaring extern items, even without ever using them, can cause Undefined Behavior. We
4677    /// should consider all sources of Undefined Behavior to be unsafe.
4678    ///
4679    /// This is a [future-incompatible] lint to transition this to a
4680    /// hard error in the future.
4681    ///
4682    /// [future-incompatible]: ../index.md#future-incompatible-lints
4683    pub MISSING_UNSAFE_ON_EXTERN,
4684    Allow,
4685    "detects missing unsafe keyword on extern declarations",
4686    @future_incompatible = FutureIncompatibleInfo {
4687        reason: FutureIncompatibilityReason::EditionError(Edition::Edition2024),
4688        reference: "<https://doc.rust-lang.org/nightly/edition-guide/rust-2024/unsafe-extern.html>",
4689    };
4690}
4691
4692declare_lint! {
4693    /// The `unsafe_attr_outside_unsafe` lint detects a missing unsafe keyword
4694    /// on attributes considered unsafe.
4695    ///
4696    /// ### Example
4697    ///
4698    /// ```rust,edition2021
4699    /// #![warn(unsafe_attr_outside_unsafe)]
4700    ///
4701    /// #[no_mangle]
4702    /// extern "C" fn foo() {}
4703    ///
4704    /// fn main() {}
4705    /// ```
4706    ///
4707    /// {{produces}}
4708    ///
4709    /// ### Explanation
4710    ///
4711    /// Some attributes (e.g. `no_mangle`, `export_name`, `link_section` -- see
4712    /// [issue #82499] for a more complete list) are considered "unsafe" attributes.
4713    /// An unsafe attribute must only be used inside unsafe(...).
4714    ///
4715    /// This lint can automatically wrap the attributes in `unsafe(...)` , but this
4716    /// obviously cannot verify that the preconditions of the `unsafe`
4717    /// attributes are fulfilled, so that is still up to the user.
4718    ///
4719    /// The lint is currently "allow" by default, but that might change in the
4720    /// future.
4721    ///
4722    /// [editions]: https://doc.rust-lang.org/edition-guide/
4723    /// [issue #82499]: https://github.com/rust-lang/rust/issues/82499
4724    pub UNSAFE_ATTR_OUTSIDE_UNSAFE,
4725    Allow,
4726    "detects unsafe attributes outside of unsafe",
4727    @future_incompatible = FutureIncompatibleInfo {
4728        reason: FutureIncompatibilityReason::EditionError(Edition::Edition2024),
4729        reference: "<https://doc.rust-lang.org/nightly/edition-guide/rust-2024/unsafe-attributes.html>",
4730    };
4731}
4732
4733declare_lint! {
4734    /// The `out_of_scope_macro_calls` lint detects `macro_rules` called when they are not in scope,
4735    /// above their definition, which may happen in key-value attributes.
4736    ///
4737    /// ### Example
4738    ///
4739    /// ```rust
4740    /// #![doc = in_root!()]
4741    ///
4742    /// macro_rules! in_root { () => { "" } }
4743    ///
4744    /// fn main() {}
4745    /// ```
4746    ///
4747    /// {{produces}}
4748    ///
4749    /// ### Explanation
4750    ///
4751    /// The scope in which a `macro_rules` item is visible starts at that item and continues
4752    /// below it. This is more similar to `let` than to other items, which are in scope both above
4753    /// and below their definition.
4754    /// Due to a bug `macro_rules` were accidentally in scope inside some key-value attributes
4755    /// above their definition. The lint catches such cases.
4756    /// To address the issue turn the `macro_rules` into a regularly scoped item by importing it
4757    /// with `use`.
4758    ///
4759    /// This is a [future-incompatible] lint to transition this to a
4760    /// hard error in the future.
4761    ///
4762    /// [future-incompatible]: ../index.md#future-incompatible-lints
4763    pub OUT_OF_SCOPE_MACRO_CALLS,
4764    Warn,
4765    "detects out of scope calls to `macro_rules` in key-value attributes",
4766    @future_incompatible = FutureIncompatibleInfo {
4767        reason: FutureIncompatibilityReason::FutureReleaseErrorDontReportInDeps,
4768        reference: "issue #124535 <https://github.com/rust-lang/rust/issues/124535>",
4769    };
4770}
4771
4772declare_lint! {
4773    /// The `supertrait_item_shadowing_usage` lint detects when the
4774    /// usage of an item that is provided by both a subtrait and supertrait
4775    /// is shadowed, preferring the subtrait.
4776    ///
4777    /// ### Example
4778    ///
4779    /// ```rust,compile_fail
4780    /// #![feature(supertrait_item_shadowing)]
4781    /// #![deny(supertrait_item_shadowing_usage)]
4782    ///
4783    /// trait Upstream {
4784    ///     fn hello(&self) {}
4785    /// }
4786    /// impl<T> Upstream for T {}
4787    ///
4788    /// trait Downstream: Upstream {
4789    ///     fn hello(&self) {}
4790    /// }
4791    /// impl<T> Downstream for T {}
4792    ///
4793    /// struct MyType;
4794    /// MyType.hello();
4795    /// ```
4796    ///
4797    /// {{produces}}
4798    ///
4799    /// ### Explanation
4800    ///
4801    /// RFC 3624 specified a heuristic in which a supertrait item would be
4802    /// shadowed by a subtrait item when ambiguity occurs during item
4803    /// selection. In order to mitigate side-effects of this happening
4804    /// silently, this lint detects these cases when users want to deny them
4805    /// or fix the call sites.
4806    pub SUPERTRAIT_ITEM_SHADOWING_USAGE,
4807    // FIXME(supertrait_item_shadowing): It is not decided if this should
4808    // warn by default at the call site.
4809    Allow,
4810    "detects when a supertrait item is shadowed by a subtrait item",
4811    @feature_gate = supertrait_item_shadowing;
4812}
4813
4814declare_lint! {
4815    /// The `supertrait_item_shadowing_definition` lint detects when the
4816    /// definition of an item that is provided by both a subtrait and
4817    /// supertrait is shadowed, preferring the subtrait.
4818    ///
4819    /// ### Example
4820    ///
4821    /// ```rust,compile_fail
4822    /// #![feature(supertrait_item_shadowing)]
4823    /// #![deny(supertrait_item_shadowing_definition)]
4824    ///
4825    /// trait Upstream {
4826    ///     fn hello(&self) {}
4827    /// }
4828    /// impl<T> Upstream for T {}
4829    ///
4830    /// trait Downstream: Upstream {
4831    ///     fn hello(&self) {}
4832    /// }
4833    /// impl<T> Downstream for T {}
4834    /// ```
4835    ///
4836    /// {{produces}}
4837    ///
4838    /// ### Explanation
4839    ///
4840    /// RFC 3624 specified a heuristic in which a supertrait item would be
4841    /// shadowed by a subtrait item when ambiguity occurs during item
4842    /// selection. In order to mitigate side-effects of this happening
4843    /// silently, this lint detects these cases when users want to deny them
4844    /// or fix their trait definitions.
4845    pub SUPERTRAIT_ITEM_SHADOWING_DEFINITION,
4846    // FIXME(supertrait_item_shadowing): It is not decided if this should
4847    // warn by default at the usage site.
4848    Allow,
4849    "detects when a supertrait item is shadowed by a subtrait item",
4850    @feature_gate = supertrait_item_shadowing;
4851}
4852
4853declare_lint! {
4854    /// The `ptr_to_integer_transmute_in_consts` lint detects pointer to integer
4855    /// transmute in const functions and associated constants.
4856    ///
4857    /// ### Example
4858    ///
4859    /// ```rust
4860    /// const fn foo(ptr: *const u8) -> usize {
4861    ///    unsafe {
4862    ///        std::mem::transmute::<*const u8, usize>(ptr)
4863    ///    }
4864    /// }
4865    /// ```
4866    ///
4867    /// {{produces}}
4868    ///
4869    /// ### Explanation
4870    ///
4871    /// Transmuting pointers to integers in a `const` context is undefined behavior.
4872    /// Any attempt to use the resulting integer will abort const-evaluation.
4873    ///
4874    /// But sometimes the compiler might not emit an error for pointer to integer transmutes
4875    /// inside const functions and associated consts because they are evaluated only when referenced.
4876    /// Therefore, this lint serves as an extra layer of defense to prevent any undefined behavior
4877    /// from compiling without any warnings or errors.
4878    ///
4879    /// See [std::mem::transmute] in the reference for more details.
4880    ///
4881    /// [std::mem::transmute]: https://doc.rust-lang.org/std/mem/fn.transmute.html
4882    pub PTR_TO_INTEGER_TRANSMUTE_IN_CONSTS,
4883    Warn,
4884    "detects pointer to integer transmutes in const functions and associated constants",
4885}
4886
4887declare_lint! {
4888    /// The `unnecessary_transmutes` lint detects transmutations that have safer alternatives.
4889    ///
4890    /// ### Example
4891    ///
4892    /// ```rust
4893    /// fn bytes_at_home(x: [u8; 4]) -> u32 {
4894    ///   unsafe { std::mem::transmute(x) }
4895    /// }
4896    /// ```
4897    ///
4898    /// {{produces}}
4899    ///
4900    /// ### Explanation
4901    ///
4902    /// Using an explicit method is preferable over calls to
4903    /// [`transmute`](https://doc.rust-lang.org/std/mem/fn.transmute.html) as
4904    /// they more clearly communicate the intent, are easier to review, and
4905    /// are less likely to accidentally result in unsoundness.
4906    pub UNNECESSARY_TRANSMUTES,
4907    Warn,
4908    "detects transmutes that are shadowed by std methods"
4909}
4910
4911declare_lint! {
4912    /// The `tail_expr_drop_order` lint looks for those values generated at the tail expression location,
4913    /// that runs a custom `Drop` destructor.
4914    /// Some of them may be dropped earlier in Edition 2024 that they used to in Edition 2021 and prior.
4915    /// This lint detects those cases and provides you information on those values and their custom destructor implementations.
4916    /// Your discretion on this information is required.
4917    ///
4918    /// ### Example
4919    /// ```rust,edition2021
4920    /// #![warn(tail_expr_drop_order)]
4921    /// struct Droppy(i32);
4922    /// impl Droppy {
4923    ///     fn get(&self) -> i32 {
4924    ///         self.0
4925    ///     }
4926    /// }
4927    /// impl Drop for Droppy {
4928    ///     fn drop(&mut self) {
4929    ///         // This is a custom destructor and it induces side-effects that is observable
4930    ///         // especially when the drop order at a tail expression changes.
4931    ///         println!("loud drop {}", self.0);
4932    ///     }
4933    /// }
4934    /// fn edition_2021() -> i32 {
4935    ///     let another_droppy = Droppy(0);
4936    ///     Droppy(1).get()
4937    /// }
4938    /// fn main() {
4939    ///     edition_2021();
4940    /// }
4941    /// ```
4942    ///
4943    /// {{produces}}
4944    ///
4945    /// ### Explanation
4946    ///
4947    /// In tail expression of blocks or function bodies,
4948    /// values of type with significant `Drop` implementation has an ill-specified drop order
4949    /// before Edition 2024 so that they are dropped only after dropping local variables.
4950    /// Edition 2024 introduces a new rule with drop orders for them,
4951    /// so that they are dropped first before dropping local variables.
4952    ///
4953    /// A significant `Drop::drop` destructor here refers to an explicit, arbitrary
4954    /// implementation of the `Drop` trait on the type, with exceptions including `Vec`,
4955    /// `Box`, `Rc`, `BTreeMap` and `HashMap` that are marked by the compiler otherwise
4956    /// so long that the generic types have no significant destructor recursively.
4957    /// In other words, a type has a significant drop destructor when it has a `Drop` implementation
4958    /// or its destructor invokes a significant destructor on a type.
4959    /// Since we cannot completely reason about the change by just inspecting the existence of
4960    /// a significant destructor, this lint remains only a suggestion and is set to `allow` by default.
4961    ///
4962    /// This lint only points out the issue with `Droppy`, which will be dropped before `another_droppy`
4963    /// does in Edition 2024.
4964    /// No fix will be proposed by this lint.
4965    /// However, the most probable fix is to hoist `Droppy` into its own local variable binding.
4966    /// ```rust
4967    /// struct Droppy(i32);
4968    /// impl Droppy {
4969    ///     fn get(&self) -> i32 {
4970    ///         self.0
4971    ///     }
4972    /// }
4973    /// fn edition_2024() -> i32 {
4974    ///     let value = Droppy(0);
4975    ///     let another_droppy = Droppy(1);
4976    ///     value.get()
4977    /// }
4978    /// ```
4979    pub TAIL_EXPR_DROP_ORDER,
4980    Allow,
4981    "Detect and warn on significant change in drop order in tail expression location",
4982    @future_incompatible = FutureIncompatibleInfo {
4983        reason: FutureIncompatibilityReason::EditionSemanticsChange(Edition::Edition2024),
4984        reference: "<https://doc.rust-lang.org/nightly/edition-guide/rust-2024/temporary-tail-expr-scope.html>",
4985    };
4986}
4987
4988declare_lint! {
4989    /// The `rust_2024_guarded_string_incompatible_syntax` lint detects `#` tokens
4990    /// that will be parsed as part of a guarded string literal in Rust 2024.
4991    ///
4992    /// ### Example
4993    ///
4994    /// ```rust,edition2021,compile_fail
4995    /// #![deny(rust_2024_guarded_string_incompatible_syntax)]
4996    ///
4997    /// macro_rules! m {
4998    ///     (# $x:expr #) => ();
4999    ///     (# $x:expr) => ();
5000    /// }
5001    ///
5002    /// m!(#"hey"#);
5003    /// m!(#"hello");
5004    /// ```
5005    ///
5006    /// {{produces}}
5007    ///
5008    /// ### Explanation
5009    ///
5010    /// Prior to Rust 2024, `#"hey"#` is three tokens: the first `#`
5011    /// followed by the string literal `"hey"` then the final `#`.
5012    /// In Rust 2024, the whole sequence is considered a single token.
5013    ///
5014    /// This lint suggests to add whitespace between the leading `#`
5015    /// and the string to keep them separated in Rust 2024.
5016    // Allow this lint -- rustdoc doesn't yet support threading edition into this lint's parser.
5017    #[allow(rustdoc::invalid_rust_codeblocks)]
5018    pub RUST_2024_GUARDED_STRING_INCOMPATIBLE_SYNTAX,
5019    Allow,
5020    "will be parsed as a guarded string in Rust 2024",
5021    @future_incompatible = FutureIncompatibleInfo {
5022        reason: FutureIncompatibilityReason::EditionError(Edition::Edition2024),
5023        reference: "<https://doc.rust-lang.org/nightly/edition-guide/rust-2024/reserved-syntax.html>",
5024    };
5025    crate_level_only
5026}
5027
5028declare_lint! {
5029    /// The `wasm_c_abi` lint detects usage of the `extern "C"` ABI of wasm that is affected
5030    /// by a planned ABI change that has the goal of aligning Rust with the standard C ABI
5031    /// of this target.
5032    ///
5033    /// ### Example
5034    ///
5035    /// ```rust,ignore (needs wasm32-unknown-unknown)
5036    /// #[repr(C)]
5037    /// struct MyType(i32, i32);
5038    ///
5039    /// extern "C" my_fun(x: MyType) {}
5040    /// ```
5041    ///
5042    /// This will produce:
5043    ///
5044    /// ```text
5045    /// error: this function function definition is affected by the wasm ABI transition: it passes an argument of non-scalar type `MyType`
5046    /// --> $DIR/wasm_c_abi_transition.rs:17:1
5047    ///  |
5048    ///  | pub extern "C" fn my_fun(_x: MyType) {}
5049    ///  | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
5050    ///  |
5051    ///  = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
5052    ///  = note: for more information, see issue #138762 <https://github.com/rust-lang/rust/issues/138762>
5053    ///  = help: the "C" ABI Rust uses on wasm32-unknown-unknown will change to align with the standard "C" ABI for this target
5054    /// ```
5055    ///
5056    /// ### Explanation
5057    ///
5058    /// Rust has historically implemented a non-spec-compliant C ABI on wasm32-unknown-unknown. This
5059    /// has caused incompatibilities with other compilers and Wasm targets. In a future version
5060    /// of Rust, this will be fixed, and therefore code relying on the non-spec-compliant C ABI will
5061    /// stop functioning.
5062    pub WASM_C_ABI,
5063    Warn,
5064    "detects code relying on rustc's non-spec-compliant wasm C ABI",
5065    @future_incompatible = FutureIncompatibleInfo {
5066        reason: FutureIncompatibilityReason::FutureReleaseErrorReportInDeps,
5067        reference: "issue #138762 <https://github.com/rust-lang/rust/issues/138762>",
5068    };
5069}