]> git.lizzy.rs Git - rust.git/blob - compiler/rustc_lint_defs/src/builtin.rs
Auto merge of #96207 - nikic:distcheck-dir, r=Mark-Simulacrum
[rust.git] / compiler / rustc_lint_defs / src / 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 use crate::{declare_lint, declare_lint_pass, FutureIncompatibilityReason};
8 use rustc_span::edition::Edition;
9 use rustc_span::symbol::sym;
10
11 declare_lint! {
12     /// The `forbidden_lint_groups` lint detects violations of
13     /// `forbid` applied to a lint group. Due to a bug in the compiler,
14     /// these used to be overlooked entirely. They now generate a warning.
15     ///
16     /// ### Example
17     ///
18     /// ```rust
19     /// #![forbid(warnings)]
20     /// #![deny(bad_style)]
21     ///
22     /// fn main() {}
23     /// ```
24     ///
25     /// {{produces}}
26     ///
27     /// ### Recommended fix
28     ///
29     /// If your crate is using `#![forbid(warnings)]`,
30     /// we recommend that you change to `#![deny(warnings)]`.
31     ///
32     /// ### Explanation
33     ///
34     /// Due to a compiler bug, applying `forbid` to lint groups
35     /// previously had no effect. The bug is now fixed but instead of
36     /// enforcing `forbid` we issue this future-compatibility warning
37     /// to avoid breaking existing crates.
38     pub FORBIDDEN_LINT_GROUPS,
39     Warn,
40     "applying forbid to lint-groups",
41     @future_incompatible = FutureIncompatibleInfo {
42         reference: "issue #81670 <https://github.com/rust-lang/rust/issues/81670>",
43     };
44 }
45
46 declare_lint! {
47     /// The `ill_formed_attribute_input` lint detects ill-formed attribute
48     /// inputs that were previously accepted and used in practice.
49     ///
50     /// ### Example
51     ///
52     /// ```rust,compile_fail
53     /// #[inline = "this is not valid"]
54     /// fn foo() {}
55     /// ```
56     ///
57     /// {{produces}}
58     ///
59     /// ### Explanation
60     ///
61     /// Previously, inputs for many built-in attributes weren't validated and
62     /// nonsensical attribute inputs were accepted. After validation was
63     /// added, it was determined that some existing projects made use of these
64     /// invalid forms. This is a [future-incompatible] lint to transition this
65     /// to a hard error in the future. See [issue #57571] for more details.
66     ///
67     /// Check the [attribute reference] for details on the valid inputs for
68     /// attributes.
69     ///
70     /// [issue #57571]: https://github.com/rust-lang/rust/issues/57571
71     /// [attribute reference]: https://doc.rust-lang.org/nightly/reference/attributes.html
72     /// [future-incompatible]: ../index.md#future-incompatible-lints
73     pub ILL_FORMED_ATTRIBUTE_INPUT,
74     Deny,
75     "ill-formed attribute inputs that were previously accepted and used in practice",
76     @future_incompatible = FutureIncompatibleInfo {
77         reference: "issue #57571 <https://github.com/rust-lang/rust/issues/57571>",
78     };
79     crate_level_only
80 }
81
82 declare_lint! {
83     /// The `conflicting_repr_hints` lint detects [`repr` attributes] with
84     /// conflicting hints.
85     ///
86     /// [`repr` attributes]: https://doc.rust-lang.org/reference/type-layout.html#representations
87     ///
88     /// ### Example
89     ///
90     /// ```rust,compile_fail
91     /// #[repr(u32, u64)]
92     /// enum Foo {
93     ///     Variant1,
94     /// }
95     /// ```
96     ///
97     /// {{produces}}
98     ///
99     /// ### Explanation
100     ///
101     /// The compiler incorrectly accepted these conflicting representations in
102     /// the past. This is a [future-incompatible] lint to transition this to a
103     /// hard error in the future. See [issue #68585] for more details.
104     ///
105     /// To correct the issue, remove one of the conflicting hints.
106     ///
107     /// [issue #68585]: https://github.com/rust-lang/rust/issues/68585
108     /// [future-incompatible]: ../index.md#future-incompatible-lints
109     pub CONFLICTING_REPR_HINTS,
110     Deny,
111     "conflicts between `#[repr(..)]` hints that were previously accepted and used in practice",
112     @future_incompatible = FutureIncompatibleInfo {
113         reference: "issue #68585 <https://github.com/rust-lang/rust/issues/68585>",
114     };
115 }
116
117 declare_lint! {
118     /// The `meta_variable_misuse` lint detects possible meta-variable misuse
119     /// in macro definitions.
120     ///
121     /// ### Example
122     ///
123     /// ```rust,compile_fail
124     /// #![deny(meta_variable_misuse)]
125     ///
126     /// macro_rules! foo {
127     ///     () => {};
128     ///     ($( $i:ident = $($j:ident),+ );*) => { $( $( $i = $k; )+ )* };
129     /// }
130     ///
131     /// fn main() {
132     ///     foo!();
133     /// }
134     /// ```
135     ///
136     /// {{produces}}
137     ///
138     /// ### Explanation
139     ///
140     /// There are quite a few different ways a [`macro_rules`] macro can be
141     /// improperly defined. Many of these errors were previously only detected
142     /// when the macro was expanded or not at all. This lint is an attempt to
143     /// catch some of these problems when the macro is *defined*.
144     ///
145     /// This lint is "allow" by default because it may have false positives
146     /// and other issues. See [issue #61053] for more details.
147     ///
148     /// [`macro_rules`]: https://doc.rust-lang.org/reference/macros-by-example.html
149     /// [issue #61053]: https://github.com/rust-lang/rust/issues/61053
150     pub META_VARIABLE_MISUSE,
151     Allow,
152     "possible meta-variable misuse at macro definition"
153 }
154
155 declare_lint! {
156     /// The `incomplete_include` lint detects the use of the [`include!`]
157     /// macro with a file that contains more than one expression.
158     ///
159     /// [`include!`]: https://doc.rust-lang.org/std/macro.include.html
160     ///
161     /// ### Example
162     ///
163     /// ```rust,ignore (needs separate file)
164     /// fn main() {
165     ///     include!("foo.txt");
166     /// }
167     /// ```
168     ///
169     /// where the file `foo.txt` contains:
170     ///
171     /// ```text
172     /// println!("hi!");
173     /// ```
174     ///
175     /// produces:
176     ///
177     /// ```text
178     /// error: include macro expected single expression in source
179     ///  --> foo.txt:1:14
180     ///   |
181     /// 1 | println!("1");
182     ///   |              ^
183     ///   |
184     ///   = note: `#[deny(incomplete_include)]` on by default
185     /// ```
186     ///
187     /// ### Explanation
188     ///
189     /// The [`include!`] macro is currently only intended to be used to
190     /// include a single [expression] or multiple [items]. Historically it
191     /// would ignore any contents after the first expression, but that can be
192     /// confusing. In the example above, the `println!` expression ends just
193     /// before the semicolon, making the semicolon "extra" information that is
194     /// ignored. Perhaps even more surprising, if the included file had
195     /// multiple print statements, the subsequent ones would be ignored!
196     ///
197     /// One workaround is to place the contents in braces to create a [block
198     /// expression]. Also consider alternatives, like using functions to
199     /// encapsulate the expressions, or use [proc-macros].
200     ///
201     /// This is a lint instead of a hard error because existing projects were
202     /// found to hit this error. To be cautious, it is a lint for now. The
203     /// future semantics of the `include!` macro are also uncertain, see
204     /// [issue #35560].
205     ///
206     /// [items]: https://doc.rust-lang.org/reference/items.html
207     /// [expression]: https://doc.rust-lang.org/reference/expressions.html
208     /// [block expression]: https://doc.rust-lang.org/reference/expressions/block-expr.html
209     /// [proc-macros]: https://doc.rust-lang.org/reference/procedural-macros.html
210     /// [issue #35560]: https://github.com/rust-lang/rust/issues/35560
211     pub INCOMPLETE_INCLUDE,
212     Deny,
213     "trailing content in included file"
214 }
215
216 declare_lint! {
217     /// The `arithmetic_overflow` lint detects that an arithmetic operation
218     /// will [overflow].
219     ///
220     /// [overflow]: https://doc.rust-lang.org/reference/expressions/operator-expr.html#overflow
221     ///
222     /// ### Example
223     ///
224     /// ```rust,compile_fail
225     /// 1_i32 << 32;
226     /// ```
227     ///
228     /// {{produces}}
229     ///
230     /// ### Explanation
231     ///
232     /// It is very likely a mistake to perform an arithmetic operation that
233     /// overflows its value. If the compiler is able to detect these kinds of
234     /// overflows at compile-time, it will trigger this lint. Consider
235     /// adjusting the expression to avoid overflow, or use a data type that
236     /// will not overflow.
237     pub ARITHMETIC_OVERFLOW,
238     Deny,
239     "arithmetic operation overflows"
240 }
241
242 declare_lint! {
243     /// The `unconditional_panic` lint detects an operation that will cause a
244     /// panic at runtime.
245     ///
246     /// ### Example
247     ///
248     /// ```rust,compile_fail
249     /// # #![allow(unused)]
250     /// let x = 1 / 0;
251     /// ```
252     ///
253     /// {{produces}}
254     ///
255     /// ### Explanation
256     ///
257     /// This lint detects code that is very likely incorrect because it will
258     /// always panic, such as division by zero and out-of-bounds array
259     /// accesses. Consider adjusting your code if this is a bug, or using the
260     /// `panic!` or `unreachable!` macro instead in case the panic is intended.
261     pub UNCONDITIONAL_PANIC,
262     Deny,
263     "operation will cause a panic at runtime"
264 }
265
266 declare_lint! {
267     /// The `const_err` lint detects an erroneous expression while doing
268     /// constant evaluation.
269     ///
270     /// ### Example
271     ///
272     /// ```rust,compile_fail
273     /// #![allow(unconditional_panic)]
274     /// const C: i32 = 1/0;
275     /// ```
276     ///
277     /// {{produces}}
278     ///
279     /// ### Explanation
280     ///
281     /// This lint detects constants that fail to evaluate. Allowing the lint will accept the
282     /// constant declaration, but any use of this constant will still lead to a hard error. This is
283     /// a future incompatibility lint; the plan is to eventually entirely forbid even declaring
284     /// constants that cannot be evaluated.  See [issue #71800] for more details.
285     ///
286     /// [issue #71800]: https://github.com/rust-lang/rust/issues/71800
287     pub CONST_ERR,
288     Deny,
289     "constant evaluation encountered erroneous expression",
290     @future_incompatible = FutureIncompatibleInfo {
291         reference: "issue #71800 <https://github.com/rust-lang/rust/issues/71800>",
292     };
293     report_in_external_macro
294 }
295
296 declare_lint! {
297     /// The `unused_imports` lint detects imports that are never used.
298     ///
299     /// ### Example
300     ///
301     /// ```rust
302     /// use std::collections::HashMap;
303     /// ```
304     ///
305     /// {{produces}}
306     ///
307     /// ### Explanation
308     ///
309     /// Unused imports may signal a mistake or unfinished code, and clutter
310     /// the code, and should be removed. If you intended to re-export the item
311     /// to make it available outside of the module, add a visibility modifier
312     /// like `pub`.
313     pub UNUSED_IMPORTS,
314     Warn,
315     "imports that are never used"
316 }
317
318 declare_lint! {
319     /// The `must_not_suspend` lint guards against values that shouldn't be held across suspend points
320     /// (`.await`)
321     ///
322     /// ### Example
323     ///
324     /// ```rust
325     /// #![feature(must_not_suspend)]
326     /// #![warn(must_not_suspend)]
327     ///
328     /// #[must_not_suspend]
329     /// struct SyncThing {}
330     ///
331     /// async fn yield_now() {}
332     ///
333     /// pub async fn uhoh() {
334     ///     let guard = SyncThing {};
335     ///     yield_now().await;
336     /// }
337     /// ```
338     ///
339     /// {{produces}}
340     ///
341     /// ### Explanation
342     ///
343     /// The `must_not_suspend` lint detects values that are marked with the `#[must_not_suspend]`
344     /// attribute being held across suspend points. A "suspend" point is usually a `.await` in an async
345     /// function.
346     ///
347     /// This attribute can be used to mark values that are semantically incorrect across suspends
348     /// (like certain types of timers), values that have async alternatives, and values that
349     /// regularly cause problems with the `Send`-ness of async fn's returned futures (like
350     /// `MutexGuard`'s)
351     ///
352     pub MUST_NOT_SUSPEND,
353     Allow,
354     "use of a `#[must_not_suspend]` value across a yield point",
355     @feature_gate = rustc_span::symbol::sym::must_not_suspend;
356 }
357
358 declare_lint! {
359     /// The `unused_extern_crates` lint guards against `extern crate` items
360     /// that are never used.
361     ///
362     /// ### Example
363     ///
364     /// ```rust,compile_fail
365     /// #![deny(unused_extern_crates)]
366     /// extern crate proc_macro;
367     /// ```
368     ///
369     /// {{produces}}
370     ///
371     /// ### Explanation
372     ///
373     /// `extern crate` items that are unused have no effect and should be
374     /// removed. Note that there are some cases where specifying an `extern
375     /// crate` is desired for the side effect of ensuring the given crate is
376     /// linked, even though it is not otherwise directly referenced. The lint
377     /// can be silenced by aliasing the crate to an underscore, such as
378     /// `extern crate foo as _`. Also note that it is no longer idiomatic to
379     /// use `extern crate` in the [2018 edition], as extern crates are now
380     /// automatically added in scope.
381     ///
382     /// This lint is "allow" by default because it can be noisy, and produce
383     /// false-positives. If a dependency is being removed from a project, it
384     /// is recommended to remove it from the build configuration (such as
385     /// `Cargo.toml`) to ensure stale build entries aren't left behind.
386     ///
387     /// [2018 edition]: https://doc.rust-lang.org/edition-guide/rust-2018/module-system/path-clarity.html#no-more-extern-crate
388     pub UNUSED_EXTERN_CRATES,
389     Allow,
390     "extern crates that are never used"
391 }
392
393 declare_lint! {
394     /// The `unused_crate_dependencies` lint detects crate dependencies that
395     /// are never used.
396     ///
397     /// ### Example
398     ///
399     /// ```rust,ignore (needs extern crate)
400     /// #![deny(unused_crate_dependencies)]
401     /// ```
402     ///
403     /// This will produce:
404     ///
405     /// ```text
406     /// error: external crate `regex` unused in `lint_example`: remove the dependency or add `use regex as _;`
407     ///   |
408     /// note: the lint level is defined here
409     ///  --> src/lib.rs:1:9
410     ///   |
411     /// 1 | #![deny(unused_crate_dependencies)]
412     ///   |         ^^^^^^^^^^^^^^^^^^^^^^^^^
413     /// ```
414     ///
415     /// ### Explanation
416     ///
417     /// After removing the code that uses a dependency, this usually also
418     /// requires removing the dependency from the build configuration.
419     /// However, sometimes that step can be missed, which leads to time wasted
420     /// building dependencies that are no longer used. This lint can be
421     /// enabled to detect dependencies that are never used (more specifically,
422     /// any dependency passed with the `--extern` command-line flag that is
423     /// never referenced via [`use`], [`extern crate`], or in any [path]).
424     ///
425     /// This lint is "allow" by default because it can provide false positives
426     /// depending on how the build system is configured. For example, when
427     /// using Cargo, a "package" consists of multiple crates (such as a
428     /// library and a binary), but the dependencies are defined for the
429     /// package as a whole. If there is a dependency that is only used in the
430     /// binary, but not the library, then the lint will be incorrectly issued
431     /// in the library.
432     ///
433     /// [path]: https://doc.rust-lang.org/reference/paths.html
434     /// [`use`]: https://doc.rust-lang.org/reference/items/use-declarations.html
435     /// [`extern crate`]: https://doc.rust-lang.org/reference/items/extern-crates.html
436     pub UNUSED_CRATE_DEPENDENCIES,
437     Allow,
438     "crate dependencies that are never used",
439     crate_level_only
440 }
441
442 declare_lint! {
443     /// The `unused_qualifications` lint detects unnecessarily qualified
444     /// names.
445     ///
446     /// ### Example
447     ///
448     /// ```rust,compile_fail
449     /// #![deny(unused_qualifications)]
450     /// mod foo {
451     ///     pub fn bar() {}
452     /// }
453     ///
454     /// fn main() {
455     ///     use foo::bar;
456     ///     foo::bar();
457     /// }
458     /// ```
459     ///
460     /// {{produces}}
461     ///
462     /// ### Explanation
463     ///
464     /// If an item from another module is already brought into scope, then
465     /// there is no need to qualify it in this case. You can call `bar()`
466     /// directly, without the `foo::`.
467     ///
468     /// This lint is "allow" by default because it is somewhat pedantic, and
469     /// doesn't indicate an actual problem, but rather a stylistic choice, and
470     /// can be noisy when refactoring or moving around code.
471     pub UNUSED_QUALIFICATIONS,
472     Allow,
473     "detects unnecessarily qualified names"
474 }
475
476 declare_lint! {
477     /// The `unknown_lints` lint detects unrecognized lint attribute.
478     ///
479     /// ### Example
480     ///
481     /// ```rust
482     /// #![allow(not_a_real_lint)]
483     /// ```
484     ///
485     /// {{produces}}
486     ///
487     /// ### Explanation
488     ///
489     /// It is usually a mistake to specify a lint that does not exist. Check
490     /// the spelling, and check the lint listing for the correct name. Also
491     /// consider if you are using an old version of the compiler, and the lint
492     /// is only available in a newer version.
493     pub UNKNOWN_LINTS,
494     Warn,
495     "unrecognized lint attribute"
496 }
497
498 declare_lint! {
499     /// The `unfulfilled_lint_expectations` lint detects lint trigger expectations
500     /// that have not been fulfilled.
501     ///
502     /// ### Example
503     ///
504     /// ```rust
505     /// #![feature(lint_reasons)]
506     ///
507     /// #[expect(unused_variables)]
508     /// let x = 10;
509     /// println!("{}", x);
510     /// ```
511     ///
512     /// {{produces}}
513     ///
514     /// ### Explanation
515     ///
516     /// It was expected that the marked code would emit a lint. This expectation
517     /// has not been fulfilled.
518     ///
519     /// The `expect` attribute can be removed if this is intended behavior otherwise
520     /// it should be investigated why the expected lint is no longer issued.
521     ///
522     /// Part of RFC 2383. The progress is being tracked in [#54503]
523     ///
524     /// [#54503]: https://github.com/rust-lang/rust/issues/54503
525     pub UNFULFILLED_LINT_EXPECTATIONS,
526     Warn,
527     "unfulfilled lint expectation",
528     @feature_gate = rustc_span::sym::lint_reasons;
529 }
530
531 declare_lint! {
532     /// The `unused_variables` lint detects variables which are not used in
533     /// any way.
534     ///
535     /// ### Example
536     ///
537     /// ```rust
538     /// let x = 5;
539     /// ```
540     ///
541     /// {{produces}}
542     ///
543     /// ### Explanation
544     ///
545     /// Unused variables may signal a mistake or unfinished code. To silence
546     /// the warning for the individual variable, prefix it with an underscore
547     /// such as `_x`.
548     pub UNUSED_VARIABLES,
549     Warn,
550     "detect variables which are not used in any way"
551 }
552
553 declare_lint! {
554     /// The `unused_assignments` lint detects assignments that will never be read.
555     ///
556     /// ### Example
557     ///
558     /// ```rust
559     /// let mut x = 5;
560     /// x = 6;
561     /// ```
562     ///
563     /// {{produces}}
564     ///
565     /// ### Explanation
566     ///
567     /// Unused assignments may signal a mistake or unfinished code. If the
568     /// variable is never used after being assigned, then the assignment can
569     /// be removed. Variables with an underscore prefix such as `_x` will not
570     /// trigger this lint.
571     pub UNUSED_ASSIGNMENTS,
572     Warn,
573     "detect assignments that will never be read"
574 }
575
576 declare_lint! {
577     /// The `dead_code` lint detects unused, unexported items.
578     ///
579     /// ### Example
580     ///
581     /// ```rust
582     /// fn foo() {}
583     /// ```
584     ///
585     /// {{produces}}
586     ///
587     /// ### Explanation
588     ///
589     /// Dead code may signal a mistake or unfinished code. To silence the
590     /// warning for individual items, prefix the name with an underscore such
591     /// as `_foo`. If it was intended to expose the item outside of the crate,
592     /// consider adding a visibility modifier like `pub`. Otherwise consider
593     /// removing the unused code.
594     pub DEAD_CODE,
595     Warn,
596     "detect unused, unexported items"
597 }
598
599 declare_lint! {
600     /// The `unused_attributes` lint detects attributes that were not used by
601     /// the compiler.
602     ///
603     /// ### Example
604     ///
605     /// ```rust
606     /// #![ignore]
607     /// ```
608     ///
609     /// {{produces}}
610     ///
611     /// ### Explanation
612     ///
613     /// Unused [attributes] may indicate the attribute is placed in the wrong
614     /// position. Consider removing it, or placing it in the correct position.
615     /// Also consider if you intended to use an _inner attribute_ (with a `!`
616     /// such as `#![allow(unused)]`) which applies to the item the attribute
617     /// is within, or an _outer attribute_ (without a `!` such as
618     /// `#[allow(unused)]`) which applies to the item *following* the
619     /// attribute.
620     ///
621     /// [attributes]: https://doc.rust-lang.org/reference/attributes.html
622     pub UNUSED_ATTRIBUTES,
623     Warn,
624     "detects attributes that were not used by the compiler"
625 }
626
627 declare_lint! {
628     /// The `unreachable_code` lint detects unreachable code paths.
629     ///
630     /// ### Example
631     ///
632     /// ```rust,no_run
633     /// panic!("we never go past here!");
634     ///
635     /// let x = 5;
636     /// ```
637     ///
638     /// {{produces}}
639     ///
640     /// ### Explanation
641     ///
642     /// Unreachable code may signal a mistake or unfinished code. If the code
643     /// is no longer in use, consider removing it.
644     pub UNREACHABLE_CODE,
645     Warn,
646     "detects unreachable code paths",
647     report_in_external_macro
648 }
649
650 declare_lint! {
651     /// The `unreachable_patterns` lint detects unreachable patterns.
652     ///
653     /// ### Example
654     ///
655     /// ```rust
656     /// let x = 5;
657     /// match x {
658     ///     y => (),
659     ///     5 => (),
660     /// }
661     /// ```
662     ///
663     /// {{produces}}
664     ///
665     /// ### Explanation
666     ///
667     /// This usually indicates a mistake in how the patterns are specified or
668     /// ordered. In this example, the `y` pattern will always match, so the
669     /// five is impossible to reach. Remember, match arms match in order, you
670     /// probably wanted to put the `5` case above the `y` case.
671     pub UNREACHABLE_PATTERNS,
672     Warn,
673     "detects unreachable patterns"
674 }
675
676 declare_lint! {
677     /// The `overlapping_range_endpoints` lint detects `match` arms that have [range patterns] that
678     /// overlap on their endpoints.
679     ///
680     /// [range patterns]: https://doc.rust-lang.org/nightly/reference/patterns.html#range-patterns
681     ///
682     /// ### Example
683     ///
684     /// ```rust
685     /// let x = 123u8;
686     /// match x {
687     ///     0..=100 => { println!("small"); }
688     ///     100..=255 => { println!("large"); }
689     /// }
690     /// ```
691     ///
692     /// {{produces}}
693     ///
694     /// ### Explanation
695     ///
696     /// It is likely a mistake to have range patterns in a match expression that overlap in this
697     /// way. Check that the beginning and end values are what you expect, and keep in mind that
698     /// with `..=` the left and right bounds are inclusive.
699     pub OVERLAPPING_RANGE_ENDPOINTS,
700     Warn,
701     "detects range patterns with overlapping endpoints"
702 }
703
704 declare_lint! {
705     /// The `bindings_with_variant_name` lint detects pattern bindings with
706     /// the same name as one of the matched variants.
707     ///
708     /// ### Example
709     ///
710     /// ```rust
711     /// pub enum Enum {
712     ///     Foo,
713     ///     Bar,
714     /// }
715     ///
716     /// pub fn foo(x: Enum) {
717     ///     match x {
718     ///         Foo => {}
719     ///         Bar => {}
720     ///     }
721     /// }
722     /// ```
723     ///
724     /// {{produces}}
725     ///
726     /// ### Explanation
727     ///
728     /// It is usually a mistake to specify an enum variant name as an
729     /// [identifier pattern]. In the example above, the `match` arms are
730     /// specifying a variable name to bind the value of `x` to. The second arm
731     /// is ignored because the first one matches *all* values. The likely
732     /// intent is that the arm was intended to match on the enum variant.
733     ///
734     /// Two possible solutions are:
735     ///
736     /// * Specify the enum variant using a [path pattern], such as
737     ///   `Enum::Foo`.
738     /// * Bring the enum variants into local scope, such as adding `use
739     ///   Enum::*;` to the beginning of the `foo` function in the example
740     ///   above.
741     ///
742     /// [identifier pattern]: https://doc.rust-lang.org/reference/patterns.html#identifier-patterns
743     /// [path pattern]: https://doc.rust-lang.org/reference/patterns.html#path-patterns
744     pub BINDINGS_WITH_VARIANT_NAME,
745     Warn,
746     "detects pattern bindings with the same name as one of the matched variants"
747 }
748
749 declare_lint! {
750     /// The `unused_macros` lint detects macros that were not used.
751     ///
752     /// ### Example
753     ///
754     /// ```rust
755     /// macro_rules! unused {
756     ///     () => {};
757     /// }
758     ///
759     /// fn main() {
760     /// }
761     /// ```
762     ///
763     /// {{produces}}
764     ///
765     /// ### Explanation
766     ///
767     /// Unused macros may signal a mistake or unfinished code. To silence the
768     /// warning for the individual macro, prefix the name with an underscore
769     /// such as `_my_macro`. If you intended to export the macro to make it
770     /// available outside of the crate, use the [`macro_export` attribute].
771     ///
772     /// [`macro_export` attribute]: https://doc.rust-lang.org/reference/macros-by-example.html#path-based-scope
773     pub UNUSED_MACROS,
774     Warn,
775     "detects macros that were not used"
776 }
777
778 declare_lint! {
779     /// The `warnings` lint allows you to change the level of other
780     /// lints which produce warnings.
781     ///
782     /// ### Example
783     ///
784     /// ```rust
785     /// #![deny(warnings)]
786     /// fn foo() {}
787     /// ```
788     ///
789     /// {{produces}}
790     ///
791     /// ### Explanation
792     ///
793     /// The `warnings` lint is a bit special; by changing its level, you
794     /// change every other warning that would produce a warning to whatever
795     /// value you'd like. As such, you won't ever trigger this lint in your
796     /// code directly.
797     pub WARNINGS,
798     Warn,
799     "mass-change the level for lints which produce warnings"
800 }
801
802 declare_lint! {
803     /// The `unused_features` lint detects unused or unknown features found in
804     /// crate-level [`feature` attributes].
805     ///
806     /// [`feature` attributes]: https://doc.rust-lang.org/nightly/unstable-book/
807     ///
808     /// Note: This lint is currently not functional, see [issue #44232] for
809     /// more details.
810     ///
811     /// [issue #44232]: https://github.com/rust-lang/rust/issues/44232
812     pub UNUSED_FEATURES,
813     Warn,
814     "unused features found in crate-level `#[feature]` directives"
815 }
816
817 declare_lint! {
818     /// The `stable_features` lint detects a [`feature` attribute] that
819     /// has since been made stable.
820     ///
821     /// [`feature` attribute]: https://doc.rust-lang.org/nightly/unstable-book/
822     ///
823     /// ### Example
824     ///
825     /// ```rust
826     /// #![feature(test_accepted_feature)]
827     /// fn main() {}
828     /// ```
829     ///
830     /// {{produces}}
831     ///
832     /// ### Explanation
833     ///
834     /// When a feature is stabilized, it is no longer necessary to include a
835     /// `#![feature]` attribute for it. To fix, simply remove the
836     /// `#![feature]` attribute.
837     pub STABLE_FEATURES,
838     Warn,
839     "stable features found in `#[feature]` directive"
840 }
841
842 declare_lint! {
843     /// The `unknown_crate_types` lint detects an unknown crate type found in
844     /// a [`crate_type` attribute].
845     ///
846     /// ### Example
847     ///
848     /// ```rust,compile_fail
849     /// #![crate_type="lol"]
850     /// fn main() {}
851     /// ```
852     ///
853     /// {{produces}}
854     ///
855     /// ### Explanation
856     ///
857     /// An unknown value give to the `crate_type` attribute is almost
858     /// certainly a mistake.
859     ///
860     /// [`crate_type` attribute]: https://doc.rust-lang.org/reference/linkage.html
861     pub UNKNOWN_CRATE_TYPES,
862     Deny,
863     "unknown crate type found in `#[crate_type]` directive",
864     crate_level_only
865 }
866
867 declare_lint! {
868     /// The `trivial_casts` lint detects trivial casts which could be replaced
869     /// with coercion, which may require [type ascription] or a temporary
870     /// variable.
871     ///
872     /// ### Example
873     ///
874     /// ```rust,compile_fail
875     /// #![deny(trivial_casts)]
876     /// let x: &u32 = &42;
877     /// let y = x as *const u32;
878     /// ```
879     ///
880     /// {{produces}}
881     ///
882     /// ### Explanation
883     ///
884     /// A trivial cast is a cast `e as T` where `e` has type `U` and `U` is a
885     /// subtype of `T`. This type of cast is usually unnecessary, as it can be
886     /// usually be inferred.
887     ///
888     /// This lint is "allow" by default because there are situations, such as
889     /// with FFI interfaces or complex type aliases, where it triggers
890     /// incorrectly, or in situations where it will be more difficult to
891     /// clearly express the intent. It may be possible that this will become a
892     /// warning in the future, possibly with [type ascription] providing a
893     /// convenient way to work around the current issues. See [RFC 401] for
894     /// historical context.
895     ///
896     /// [type ascription]: https://github.com/rust-lang/rust/issues/23416
897     /// [RFC 401]: https://github.com/rust-lang/rfcs/blob/master/text/0401-coercions.md
898     pub TRIVIAL_CASTS,
899     Allow,
900     "detects trivial casts which could be removed"
901 }
902
903 declare_lint! {
904     /// The `trivial_numeric_casts` lint detects trivial numeric casts of types
905     /// which could be removed.
906     ///
907     /// ### Example
908     ///
909     /// ```rust,compile_fail
910     /// #![deny(trivial_numeric_casts)]
911     /// let x = 42_i32 as i32;
912     /// ```
913     ///
914     /// {{produces}}
915     ///
916     /// ### Explanation
917     ///
918     /// A trivial numeric cast is a cast of a numeric type to the same numeric
919     /// type. This type of cast is usually unnecessary.
920     ///
921     /// This lint is "allow" by default because there are situations, such as
922     /// with FFI interfaces or complex type aliases, where it triggers
923     /// incorrectly, or in situations where it will be more difficult to
924     /// clearly express the intent. It may be possible that this will become a
925     /// warning in the future, possibly with [type ascription] providing a
926     /// convenient way to work around the current issues. See [RFC 401] for
927     /// historical context.
928     ///
929     /// [type ascription]: https://github.com/rust-lang/rust/issues/23416
930     /// [RFC 401]: https://github.com/rust-lang/rfcs/blob/master/text/0401-coercions.md
931     pub TRIVIAL_NUMERIC_CASTS,
932     Allow,
933     "detects trivial casts of numeric types which could be removed"
934 }
935
936 declare_lint! {
937     /// The `private_in_public` lint detects private items in public
938     /// interfaces not caught by the old implementation.
939     ///
940     /// ### Example
941     ///
942     /// ```rust
943     /// # #![allow(unused)]
944     /// struct SemiPriv;
945     ///
946     /// mod m1 {
947     ///     struct Priv;
948     ///     impl super::SemiPriv {
949     ///         pub fn f(_: Priv) {}
950     ///     }
951     /// }
952     /// # fn main() {}
953     /// ```
954     ///
955     /// {{produces}}
956     ///
957     /// ### Explanation
958     ///
959     /// The visibility rules are intended to prevent exposing private items in
960     /// public interfaces. This is a [future-incompatible] lint to transition
961     /// this to a hard error in the future. See [issue #34537] for more
962     /// details.
963     ///
964     /// [issue #34537]: https://github.com/rust-lang/rust/issues/34537
965     /// [future-incompatible]: ../index.md#future-incompatible-lints
966     pub PRIVATE_IN_PUBLIC,
967     Warn,
968     "detect private items in public interfaces not caught by the old implementation",
969     @future_incompatible = FutureIncompatibleInfo {
970         reference: "issue #34537 <https://github.com/rust-lang/rust/issues/34537>",
971     };
972 }
973
974 declare_lint! {
975     /// The `exported_private_dependencies` lint detects private dependencies
976     /// that are exposed in a public interface.
977     ///
978     /// ### Example
979     ///
980     /// ```rust,ignore (needs-dependency)
981     /// pub fn foo() -> Option<some_private_dependency::Thing> {
982     ///     None
983     /// }
984     /// ```
985     ///
986     /// This will produce:
987     ///
988     /// ```text
989     /// warning: type `bar::Thing` from private dependency 'bar' in public interface
990     ///  --> src/lib.rs:3:1
991     ///   |
992     /// 3 | pub fn foo() -> Option<bar::Thing> {
993     ///   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
994     ///   |
995     ///   = note: `#[warn(exported_private_dependencies)]` on by default
996     /// ```
997     ///
998     /// ### Explanation
999     ///
1000     /// Dependencies can be marked as "private" to indicate that they are not
1001     /// exposed in the public interface of a crate. This can be used by Cargo
1002     /// to independently resolve those dependencies because it can assume it
1003     /// does not need to unify them with other packages using that same
1004     /// dependency. This lint is an indication of a violation of that
1005     /// contract.
1006     ///
1007     /// To fix this, avoid exposing the dependency in your public interface.
1008     /// Or, switch the dependency to a public dependency.
1009     ///
1010     /// Note that support for this is only available on the nightly channel.
1011     /// See [RFC 1977] for more details, as well as the [Cargo documentation].
1012     ///
1013     /// [RFC 1977]: https://github.com/rust-lang/rfcs/blob/master/text/1977-public-private-dependencies.md
1014     /// [Cargo documentation]: https://doc.rust-lang.org/nightly/cargo/reference/unstable.html#public-dependency
1015     pub EXPORTED_PRIVATE_DEPENDENCIES,
1016     Warn,
1017     "public interface leaks type from a private dependency"
1018 }
1019
1020 declare_lint! {
1021     /// The `pub_use_of_private_extern_crate` lint detects a specific
1022     /// situation of re-exporting a private `extern crate`.
1023     ///
1024     /// ### Example
1025     ///
1026     /// ```rust,compile_fail
1027     /// extern crate core;
1028     /// pub use core as reexported_core;
1029     /// ```
1030     ///
1031     /// {{produces}}
1032     ///
1033     /// ### Explanation
1034     ///
1035     /// A public `use` declaration should not be used to publicly re-export a
1036     /// private `extern crate`. `pub extern crate` should be used instead.
1037     ///
1038     /// This was historically allowed, but is not the intended behavior
1039     /// according to the visibility rules. This is a [future-incompatible]
1040     /// lint to transition this to a hard error in the future. See [issue
1041     /// #34537] for more details.
1042     ///
1043     /// [issue #34537]: https://github.com/rust-lang/rust/issues/34537
1044     /// [future-incompatible]: ../index.md#future-incompatible-lints
1045     pub PUB_USE_OF_PRIVATE_EXTERN_CRATE,
1046     Deny,
1047     "detect public re-exports of private extern crates",
1048     @future_incompatible = FutureIncompatibleInfo {
1049         reference: "issue #34537 <https://github.com/rust-lang/rust/issues/34537>",
1050     };
1051 }
1052
1053 declare_lint! {
1054     /// The `invalid_type_param_default` lint detects type parameter defaults
1055     /// erroneously allowed in an invalid location.
1056     ///
1057     /// ### Example
1058     ///
1059     /// ```rust,compile_fail
1060     /// fn foo<T=i32>(t: T) {}
1061     /// ```
1062     ///
1063     /// {{produces}}
1064     ///
1065     /// ### Explanation
1066     ///
1067     /// Default type parameters were only intended to be allowed in certain
1068     /// situations, but historically the compiler allowed them everywhere.
1069     /// This is a [future-incompatible] lint to transition this to a hard
1070     /// error in the future. See [issue #36887] for more details.
1071     ///
1072     /// [issue #36887]: https://github.com/rust-lang/rust/issues/36887
1073     /// [future-incompatible]: ../index.md#future-incompatible-lints
1074     pub INVALID_TYPE_PARAM_DEFAULT,
1075     Deny,
1076     "type parameter default erroneously allowed in invalid location",
1077     @future_incompatible = FutureIncompatibleInfo {
1078         reference: "issue #36887 <https://github.com/rust-lang/rust/issues/36887>",
1079     };
1080 }
1081
1082 declare_lint! {
1083     /// The `renamed_and_removed_lints` lint detects lints that have been
1084     /// renamed or removed.
1085     ///
1086     /// ### Example
1087     ///
1088     /// ```rust
1089     /// #![deny(raw_pointer_derive)]
1090     /// ```
1091     ///
1092     /// {{produces}}
1093     ///
1094     /// ### Explanation
1095     ///
1096     /// To fix this, either remove the lint or use the new name. This can help
1097     /// avoid confusion about lints that are no longer valid, and help
1098     /// maintain consistency for renamed lints.
1099     pub RENAMED_AND_REMOVED_LINTS,
1100     Warn,
1101     "lints that have been renamed or removed"
1102 }
1103
1104 declare_lint! {
1105     /// The `unaligned_references` lint detects unaligned references to fields
1106     /// of [packed] structs.
1107     ///
1108     /// [packed]: https://doc.rust-lang.org/reference/type-layout.html#the-alignment-modifiers
1109     ///
1110     /// ### Example
1111     ///
1112     /// ```rust,compile_fail
1113     /// #[repr(packed)]
1114     /// pub struct Foo {
1115     ///     field1: u64,
1116     ///     field2: u8,
1117     /// }
1118     ///
1119     /// fn main() {
1120     ///     unsafe {
1121     ///         let foo = Foo { field1: 0, field2: 0 };
1122     ///         let _ = &foo.field1;
1123     ///         println!("{}", foo.field1); // An implicit `&` is added here, triggering the lint.
1124     ///     }
1125     /// }
1126     /// ```
1127     ///
1128     /// {{produces}}
1129     ///
1130     /// ### Explanation
1131     ///
1132     /// Creating a reference to an insufficiently aligned packed field is [undefined behavior] and
1133     /// should be disallowed. Using an `unsafe` block does not change anything about this. Instead,
1134     /// the code should do a copy of the data in the packed field or use raw pointers and unaligned
1135     /// accesses. See [issue #82523] for more information.
1136     ///
1137     /// [undefined behavior]: https://doc.rust-lang.org/reference/behavior-considered-undefined.html
1138     /// [issue #82523]: https://github.com/rust-lang/rust/issues/82523
1139     pub UNALIGNED_REFERENCES,
1140     Deny,
1141     "detects unaligned references to fields of packed structs",
1142     @future_incompatible = FutureIncompatibleInfo {
1143         reference: "issue #82523 <https://github.com/rust-lang/rust/issues/82523>",
1144         reason: FutureIncompatibilityReason::FutureReleaseErrorReportNow,
1145     };
1146     report_in_external_macro
1147 }
1148
1149 declare_lint! {
1150     /// The `const_item_mutation` lint detects attempts to mutate a `const`
1151     /// item.
1152     ///
1153     /// ### Example
1154     ///
1155     /// ```rust
1156     /// const FOO: [i32; 1] = [0];
1157     ///
1158     /// fn main() {
1159     ///     FOO[0] = 1;
1160     ///     // This will print "[0]".
1161     ///     println!("{:?}", FOO);
1162     /// }
1163     /// ```
1164     ///
1165     /// {{produces}}
1166     ///
1167     /// ### Explanation
1168     ///
1169     /// Trying to directly mutate a `const` item is almost always a mistake.
1170     /// What is happening in the example above is that a temporary copy of the
1171     /// `const` is mutated, but the original `const` is not. Each time you
1172     /// refer to the `const` by name (such as `FOO` in the example above), a
1173     /// separate copy of the value is inlined at that location.
1174     ///
1175     /// This lint checks for writing directly to a field (`FOO.field =
1176     /// some_value`) or array entry (`FOO[0] = val`), or taking a mutable
1177     /// reference to the const item (`&mut FOO`), including through an
1178     /// autoderef (`FOO.some_mut_self_method()`).
1179     ///
1180     /// There are various alternatives depending on what you are trying to
1181     /// accomplish:
1182     ///
1183     /// * First, always reconsider using mutable globals, as they can be
1184     ///   difficult to use correctly, and can make the code more difficult to
1185     ///   use or understand.
1186     /// * If you are trying to perform a one-time initialization of a global:
1187     ///     * If the value can be computed at compile-time, consider using
1188     ///       const-compatible values (see [Constant Evaluation]).
1189     ///     * For more complex single-initialization cases, consider using a
1190     ///       third-party crate, such as [`lazy_static`] or [`once_cell`].
1191     ///     * If you are using the [nightly channel], consider the new
1192     ///       [`lazy`] module in the standard library.
1193     /// * If you truly need a mutable global, consider using a [`static`],
1194     ///   which has a variety of options:
1195     ///   * Simple data types can be directly defined and mutated with an
1196     ///     [`atomic`] type.
1197     ///   * More complex types can be placed in a synchronization primitive
1198     ///     like a [`Mutex`], which can be initialized with one of the options
1199     ///     listed above.
1200     ///   * A [mutable `static`] is a low-level primitive, requiring unsafe.
1201     ///     Typically This should be avoided in preference of something
1202     ///     higher-level like one of the above.
1203     ///
1204     /// [Constant Evaluation]: https://doc.rust-lang.org/reference/const_eval.html
1205     /// [`static`]: https://doc.rust-lang.org/reference/items/static-items.html
1206     /// [mutable `static`]: https://doc.rust-lang.org/reference/items/static-items.html#mutable-statics
1207     /// [`lazy`]: https://doc.rust-lang.org/nightly/std/lazy/index.html
1208     /// [`lazy_static`]: https://crates.io/crates/lazy_static
1209     /// [`once_cell`]: https://crates.io/crates/once_cell
1210     /// [`atomic`]: https://doc.rust-lang.org/std/sync/atomic/index.html
1211     /// [`Mutex`]: https://doc.rust-lang.org/std/sync/struct.Mutex.html
1212     pub CONST_ITEM_MUTATION,
1213     Warn,
1214     "detects attempts to mutate a `const` item",
1215 }
1216
1217 declare_lint! {
1218     /// The `patterns_in_fns_without_body` lint detects `mut` identifier
1219     /// patterns as a parameter in functions without a body.
1220     ///
1221     /// ### Example
1222     ///
1223     /// ```rust,compile_fail
1224     /// trait Trait {
1225     ///     fn foo(mut arg: u8);
1226     /// }
1227     /// ```
1228     ///
1229     /// {{produces}}
1230     ///
1231     /// ### Explanation
1232     ///
1233     /// To fix this, remove `mut` from the parameter in the trait definition;
1234     /// it can be used in the implementation. That is, the following is OK:
1235     ///
1236     /// ```rust
1237     /// trait Trait {
1238     ///     fn foo(arg: u8); // Removed `mut` here
1239     /// }
1240     ///
1241     /// impl Trait for i32 {
1242     ///     fn foo(mut arg: u8) { // `mut` here is OK
1243     ///
1244     ///     }
1245     /// }
1246     /// ```
1247     ///
1248     /// Trait definitions can define functions without a body to specify a
1249     /// function that implementors must define. The parameter names in the
1250     /// body-less functions are only allowed to be `_` or an [identifier] for
1251     /// documentation purposes (only the type is relevant). Previous versions
1252     /// of the compiler erroneously allowed [identifier patterns] with the
1253     /// `mut` keyword, but this was not intended to be allowed. This is a
1254     /// [future-incompatible] lint to transition this to a hard error in the
1255     /// future. See [issue #35203] for more details.
1256     ///
1257     /// [identifier]: https://doc.rust-lang.org/reference/identifiers.html
1258     /// [identifier patterns]: https://doc.rust-lang.org/reference/patterns.html#identifier-patterns
1259     /// [issue #35203]: https://github.com/rust-lang/rust/issues/35203
1260     /// [future-incompatible]: ../index.md#future-incompatible-lints
1261     pub PATTERNS_IN_FNS_WITHOUT_BODY,
1262     Deny,
1263     "patterns in functions without body were erroneously allowed",
1264     @future_incompatible = FutureIncompatibleInfo {
1265         reference: "issue #35203 <https://github.com/rust-lang/rust/issues/35203>",
1266     };
1267 }
1268
1269 declare_lint! {
1270     /// The `missing_fragment_specifier` lint is issued when an unused pattern in a
1271     /// `macro_rules!` macro definition has a meta-variable (e.g. `$e`) that is not
1272     /// followed by a fragment specifier (e.g. `:expr`).
1273     ///
1274     /// This warning can always be fixed by removing the unused pattern in the
1275     /// `macro_rules!` macro definition.
1276     ///
1277     /// ### Example
1278     ///
1279     /// ```rust,compile_fail
1280     /// macro_rules! foo {
1281     ///    () => {};
1282     ///    ($name) => { };
1283     /// }
1284     ///
1285     /// fn main() {
1286     ///    foo!();
1287     /// }
1288     /// ```
1289     ///
1290     /// {{produces}}
1291     ///
1292     /// ### Explanation
1293     ///
1294     /// To fix this, remove the unused pattern from the `macro_rules!` macro definition:
1295     ///
1296     /// ```rust
1297     /// macro_rules! foo {
1298     ///     () => {};
1299     /// }
1300     /// fn main() {
1301     ///     foo!();
1302     /// }
1303     /// ```
1304     pub MISSING_FRAGMENT_SPECIFIER,
1305     Deny,
1306     "detects missing fragment specifiers in unused `macro_rules!` patterns",
1307     @future_incompatible = FutureIncompatibleInfo {
1308         reference: "issue #40107 <https://github.com/rust-lang/rust/issues/40107>",
1309     };
1310 }
1311
1312 declare_lint! {
1313     /// The `late_bound_lifetime_arguments` lint detects generic lifetime
1314     /// arguments in path segments with late bound lifetime parameters.
1315     ///
1316     /// ### Example
1317     ///
1318     /// ```rust
1319     /// struct S;
1320     ///
1321     /// impl S {
1322     ///     fn late<'a, 'b>(self, _: &'a u8, _: &'b u8) {}
1323     /// }
1324     ///
1325     /// fn main() {
1326     ///     S.late::<'static>(&0, &0);
1327     /// }
1328     /// ```
1329     ///
1330     /// {{produces}}
1331     ///
1332     /// ### Explanation
1333     ///
1334     /// It is not clear how to provide arguments for early-bound lifetime
1335     /// parameters if they are intermixed with late-bound parameters in the
1336     /// same list. For now, providing any explicit arguments will trigger this
1337     /// lint if late-bound parameters are present, so in the future a solution
1338     /// can be adopted without hitting backward compatibility issues. This is
1339     /// a [future-incompatible] lint to transition this to a hard error in the
1340     /// future. See [issue #42868] for more details, along with a description
1341     /// of the difference between early and late-bound parameters.
1342     ///
1343     /// [issue #42868]: https://github.com/rust-lang/rust/issues/42868
1344     /// [future-incompatible]: ../index.md#future-incompatible-lints
1345     pub LATE_BOUND_LIFETIME_ARGUMENTS,
1346     Warn,
1347     "detects generic lifetime arguments in path segments with late bound lifetime parameters",
1348     @future_incompatible = FutureIncompatibleInfo {
1349         reference: "issue #42868 <https://github.com/rust-lang/rust/issues/42868>",
1350     };
1351 }
1352
1353 declare_lint! {
1354     /// The `order_dependent_trait_objects` lint detects a trait coherency
1355     /// violation that would allow creating two trait impls for the same
1356     /// dynamic trait object involving marker traits.
1357     ///
1358     /// ### Example
1359     ///
1360     /// ```rust,compile_fail
1361     /// pub trait Trait {}
1362     ///
1363     /// impl Trait for dyn Send + Sync { }
1364     /// impl Trait for dyn Sync + Send { }
1365     /// ```
1366     ///
1367     /// {{produces}}
1368     ///
1369     /// ### Explanation
1370     ///
1371     /// A previous bug caused the compiler to interpret traits with different
1372     /// orders (such as `Send + Sync` and `Sync + Send`) as distinct types
1373     /// when they were intended to be treated the same. This allowed code to
1374     /// define separate trait implementations when there should be a coherence
1375     /// error. This is a [future-incompatible] lint to transition this to a
1376     /// hard error in the future. See [issue #56484] for more details.
1377     ///
1378     /// [issue #56484]: https://github.com/rust-lang/rust/issues/56484
1379     /// [future-incompatible]: ../index.md#future-incompatible-lints
1380     pub ORDER_DEPENDENT_TRAIT_OBJECTS,
1381     Deny,
1382     "trait-object types were treated as different depending on marker-trait order",
1383     @future_incompatible = FutureIncompatibleInfo {
1384         reference: "issue #56484 <https://github.com/rust-lang/rust/issues/56484>",
1385     };
1386 }
1387
1388 declare_lint! {
1389     /// The `coherence_leak_check` lint detects conflicting implementations of
1390     /// a trait that are only distinguished by the old leak-check code.
1391     ///
1392     /// ### Example
1393     ///
1394     /// ```rust
1395     /// trait SomeTrait { }
1396     /// impl SomeTrait for for<'a> fn(&'a u8) { }
1397     /// impl<'a> SomeTrait for fn(&'a u8) { }
1398     /// ```
1399     ///
1400     /// {{produces}}
1401     ///
1402     /// ### Explanation
1403     ///
1404     /// In the past, the compiler would accept trait implementations for
1405     /// identical functions that differed only in where the lifetime binder
1406     /// appeared. Due to a change in the borrow checker implementation to fix
1407     /// several bugs, this is no longer allowed. However, since this affects
1408     /// existing code, this is a [future-incompatible] lint to transition this
1409     /// to a hard error in the future.
1410     ///
1411     /// Code relying on this pattern should introduce "[newtypes]",
1412     /// like `struct Foo(for<'a> fn(&'a u8))`.
1413     ///
1414     /// See [issue #56105] for more details.
1415     ///
1416     /// [issue #56105]: https://github.com/rust-lang/rust/issues/56105
1417     /// [newtypes]: https://doc.rust-lang.org/book/ch19-04-advanced-types.html#using-the-newtype-pattern-for-type-safety-and-abstraction
1418     /// [future-incompatible]: ../index.md#future-incompatible-lints
1419     pub COHERENCE_LEAK_CHECK,
1420     Warn,
1421     "distinct impls distinguished only by the leak-check code",
1422     @future_incompatible = FutureIncompatibleInfo {
1423         reference: "issue #56105 <https://github.com/rust-lang/rust/issues/56105>",
1424     };
1425 }
1426
1427 declare_lint! {
1428     /// The `deprecated` lint detects use of deprecated items.
1429     ///
1430     /// ### Example
1431     ///
1432     /// ```rust
1433     /// #[deprecated]
1434     /// fn foo() {}
1435     ///
1436     /// fn bar() {
1437     ///     foo();
1438     /// }
1439     /// ```
1440     ///
1441     /// {{produces}}
1442     ///
1443     /// ### Explanation
1444     ///
1445     /// Items may be marked "deprecated" with the [`deprecated` attribute] to
1446     /// indicate that they should no longer be used. Usually the attribute
1447     /// should include a note on what to use instead, or check the
1448     /// documentation.
1449     ///
1450     /// [`deprecated` attribute]: https://doc.rust-lang.org/reference/attributes/diagnostics.html#the-deprecated-attribute
1451     pub DEPRECATED,
1452     Warn,
1453     "detects use of deprecated items",
1454     report_in_external_macro
1455 }
1456
1457 declare_lint! {
1458     /// The `unused_unsafe` lint detects unnecessary use of an `unsafe` block.
1459     ///
1460     /// ### Example
1461     ///
1462     /// ```rust
1463     /// unsafe {}
1464     /// ```
1465     ///
1466     /// {{produces}}
1467     ///
1468     /// ### Explanation
1469     ///
1470     /// If nothing within the block requires `unsafe`, then remove the
1471     /// `unsafe` marker because it is not required and may cause confusion.
1472     pub UNUSED_UNSAFE,
1473     Warn,
1474     "unnecessary use of an `unsafe` block"
1475 }
1476
1477 declare_lint! {
1478     /// The `unused_mut` lint detects mut variables which don't need to be
1479     /// mutable.
1480     ///
1481     /// ### Example
1482     ///
1483     /// ```rust
1484     /// let mut x = 5;
1485     /// ```
1486     ///
1487     /// {{produces}}
1488     ///
1489     /// ### Explanation
1490     ///
1491     /// The preferred style is to only mark variables as `mut` if it is
1492     /// required.
1493     pub UNUSED_MUT,
1494     Warn,
1495     "detect mut variables which don't need to be mutable"
1496 }
1497
1498 declare_lint! {
1499     /// The `unconditional_recursion` lint detects functions that cannot
1500     /// return without calling themselves.
1501     ///
1502     /// ### Example
1503     ///
1504     /// ```rust
1505     /// fn foo() {
1506     ///     foo();
1507     /// }
1508     /// ```
1509     ///
1510     /// {{produces}}
1511     ///
1512     /// ### Explanation
1513     ///
1514     /// It is usually a mistake to have a recursive call that does not have
1515     /// some condition to cause it to terminate. If you really intend to have
1516     /// an infinite loop, using a `loop` expression is recommended.
1517     pub UNCONDITIONAL_RECURSION,
1518     Warn,
1519     "functions that cannot return without calling themselves"
1520 }
1521
1522 declare_lint! {
1523     /// The `single_use_lifetimes` lint detects lifetimes that are only used
1524     /// once.
1525     ///
1526     /// ### Example
1527     ///
1528     /// ```rust,compile_fail
1529     /// #![deny(single_use_lifetimes)]
1530     ///
1531     /// fn foo<'a>(x: &'a u32) {}
1532     /// ```
1533     ///
1534     /// {{produces}}
1535     ///
1536     /// ### Explanation
1537     ///
1538     /// Specifying an explicit lifetime like `'a` in a function or `impl`
1539     /// should only be used to link together two things. Otherwise, you should
1540     /// just use `'_` to indicate that the lifetime is not linked to anything,
1541     /// or elide the lifetime altogether if possible.
1542     ///
1543     /// This lint is "allow" by default because it was introduced at a time
1544     /// when `'_` and elided lifetimes were first being introduced, and this
1545     /// lint would be too noisy. Also, there are some known false positives
1546     /// that it produces. See [RFC 2115] for historical context, and [issue
1547     /// #44752] for more details.
1548     ///
1549     /// [RFC 2115]: https://github.com/rust-lang/rfcs/blob/master/text/2115-argument-lifetimes.md
1550     /// [issue #44752]: https://github.com/rust-lang/rust/issues/44752
1551     pub SINGLE_USE_LIFETIMES,
1552     Allow,
1553     "detects lifetime parameters that are only used once"
1554 }
1555
1556 declare_lint! {
1557     /// The `unused_lifetimes` lint detects lifetime parameters that are never
1558     /// used.
1559     ///
1560     /// ### Example
1561     ///
1562     /// ```rust,compile_fail
1563     /// #[deny(unused_lifetimes)]
1564     ///
1565     /// pub fn foo<'a>() {}
1566     /// ```
1567     ///
1568     /// {{produces}}
1569     ///
1570     /// ### Explanation
1571     ///
1572     /// Unused lifetime parameters may signal a mistake or unfinished code.
1573     /// Consider removing the parameter.
1574     pub UNUSED_LIFETIMES,
1575     Allow,
1576     "detects lifetime parameters that are never used"
1577 }
1578
1579 declare_lint! {
1580     /// The `tyvar_behind_raw_pointer` lint detects raw pointer to an
1581     /// inference variable.
1582     ///
1583     /// ### Example
1584     ///
1585     /// ```rust,edition2015
1586     /// // edition 2015
1587     /// let data = std::ptr::null();
1588     /// let _ = &data as *const *const ();
1589     ///
1590     /// if data.is_null() {}
1591     /// ```
1592     ///
1593     /// {{produces}}
1594     ///
1595     /// ### Explanation
1596     ///
1597     /// This kind of inference was previously allowed, but with the future
1598     /// arrival of [arbitrary self types], this can introduce ambiguity. To
1599     /// resolve this, use an explicit type instead of relying on type
1600     /// inference.
1601     ///
1602     /// This is a [future-incompatible] lint to transition this to a hard
1603     /// error in the 2018 edition. See [issue #46906] for more details. This
1604     /// is currently a hard-error on the 2018 edition, and is "warn" by
1605     /// default in the 2015 edition.
1606     ///
1607     /// [arbitrary self types]: https://github.com/rust-lang/rust/issues/44874
1608     /// [issue #46906]: https://github.com/rust-lang/rust/issues/46906
1609     /// [future-incompatible]: ../index.md#future-incompatible-lints
1610     pub TYVAR_BEHIND_RAW_POINTER,
1611     Warn,
1612     "raw pointer to an inference variable",
1613     @future_incompatible = FutureIncompatibleInfo {
1614         reference: "issue #46906 <https://github.com/rust-lang/rust/issues/46906>",
1615         reason: FutureIncompatibilityReason::EditionError(Edition::Edition2018),
1616     };
1617 }
1618
1619 declare_lint! {
1620     /// The `elided_lifetimes_in_paths` lint detects the use of hidden
1621     /// lifetime parameters.
1622     ///
1623     /// ### Example
1624     ///
1625     /// ```rust,compile_fail
1626     /// #![deny(elided_lifetimes_in_paths)]
1627     /// struct Foo<'a> {
1628     ///     x: &'a u32
1629     /// }
1630     ///
1631     /// fn foo(x: &Foo) {
1632     /// }
1633     /// ```
1634     ///
1635     /// {{produces}}
1636     ///
1637     /// ### Explanation
1638     ///
1639     /// Elided lifetime parameters can make it difficult to see at a glance
1640     /// that borrowing is occurring. This lint ensures that lifetime
1641     /// parameters are always explicitly stated, even if it is the `'_`
1642     /// [placeholder lifetime].
1643     ///
1644     /// This lint is "allow" by default because it has some known issues, and
1645     /// may require a significant transition for old code.
1646     ///
1647     /// [placeholder lifetime]: https://doc.rust-lang.org/reference/lifetime-elision.html#lifetime-elision-in-functions
1648     pub ELIDED_LIFETIMES_IN_PATHS,
1649     Allow,
1650     "hidden lifetime parameters in types are deprecated",
1651     crate_level_only
1652 }
1653
1654 declare_lint! {
1655     /// The `bare_trait_objects` lint suggests using `dyn Trait` for trait
1656     /// objects.
1657     ///
1658     /// ### Example
1659     ///
1660     /// ```rust,edition2018
1661     /// trait Trait { }
1662     ///
1663     /// fn takes_trait_object(_: Box<Trait>) {
1664     /// }
1665     /// ```
1666     ///
1667     /// {{produces}}
1668     ///
1669     /// ### Explanation
1670     ///
1671     /// Without the `dyn` indicator, it can be ambiguous or confusing when
1672     /// reading code as to whether or not you are looking at a trait object.
1673     /// The `dyn` keyword makes it explicit, and adds a symmetry to contrast
1674     /// with [`impl Trait`].
1675     ///
1676     /// [`impl Trait`]: https://doc.rust-lang.org/book/ch10-02-traits.html#traits-as-parameters
1677     pub BARE_TRAIT_OBJECTS,
1678     Warn,
1679     "suggest using `dyn Trait` for trait objects",
1680     @future_incompatible = FutureIncompatibleInfo {
1681         reference: "<https://doc.rust-lang.org/nightly/edition-guide/rust-2021/warnings-promoted-to-error.html>",
1682         reason: FutureIncompatibilityReason::EditionError(Edition::Edition2021),
1683     };
1684 }
1685
1686 declare_lint! {
1687     /// The `absolute_paths_not_starting_with_crate` lint detects fully
1688     /// qualified paths that start with a module name instead of `crate`,
1689     /// `self`, or an extern crate name
1690     ///
1691     /// ### Example
1692     ///
1693     /// ```rust,edition2015,compile_fail
1694     /// #![deny(absolute_paths_not_starting_with_crate)]
1695     ///
1696     /// mod foo {
1697     ///     pub fn bar() {}
1698     /// }
1699     ///
1700     /// fn main() {
1701     ///     ::foo::bar();
1702     /// }
1703     /// ```
1704     ///
1705     /// {{produces}}
1706     ///
1707     /// ### Explanation
1708     ///
1709     /// Rust [editions] allow the language to evolve without breaking
1710     /// backwards compatibility. This lint catches code that uses absolute
1711     /// paths in the style of the 2015 edition. In the 2015 edition, absolute
1712     /// paths (those starting with `::`) refer to either the crate root or an
1713     /// external crate. In the 2018 edition it was changed so that they only
1714     /// refer to external crates. The path prefix `crate::` should be used
1715     /// instead to reference items from the crate root.
1716     ///
1717     /// If you switch the compiler from the 2015 to 2018 edition without
1718     /// updating the code, then it will fail to compile if the old style paths
1719     /// are used. You can manually change the paths to use the `crate::`
1720     /// prefix to transition to the 2018 edition.
1721     ///
1722     /// This lint solves the problem automatically. It is "allow" by default
1723     /// because the code is perfectly valid in the 2015 edition. The [`cargo
1724     /// fix`] tool with the `--edition` flag will switch this lint to "warn"
1725     /// and automatically apply the suggested fix from the compiler. This
1726     /// provides a completely automated way to update old code to the 2018
1727     /// edition.
1728     ///
1729     /// [editions]: https://doc.rust-lang.org/edition-guide/
1730     /// [`cargo fix`]: https://doc.rust-lang.org/cargo/commands/cargo-fix.html
1731     pub ABSOLUTE_PATHS_NOT_STARTING_WITH_CRATE,
1732     Allow,
1733     "fully qualified paths that start with a module name \
1734      instead of `crate`, `self`, or an extern crate name",
1735      @future_incompatible = FutureIncompatibleInfo {
1736         reference: "issue #53130 <https://github.com/rust-lang/rust/issues/53130>",
1737         reason: FutureIncompatibilityReason::EditionError(Edition::Edition2018),
1738      };
1739 }
1740
1741 declare_lint! {
1742     /// The `illegal_floating_point_literal_pattern` lint detects
1743     /// floating-point literals used in patterns.
1744     ///
1745     /// ### Example
1746     ///
1747     /// ```rust
1748     /// let x = 42.0;
1749     ///
1750     /// match x {
1751     ///     5.0 => {}
1752     ///     _ => {}
1753     /// }
1754     /// ```
1755     ///
1756     /// {{produces}}
1757     ///
1758     /// ### Explanation
1759     ///
1760     /// Previous versions of the compiler accepted floating-point literals in
1761     /// patterns, but it was later determined this was a mistake. The
1762     /// semantics of comparing floating-point values may not be clear in a
1763     /// pattern when contrasted with "structural equality". Typically you can
1764     /// work around this by using a [match guard], such as:
1765     ///
1766     /// ```rust
1767     /// # let x = 42.0;
1768     ///
1769     /// match x {
1770     ///     y if y == 5.0 => {}
1771     ///     _ => {}
1772     /// }
1773     /// ```
1774     ///
1775     /// This is a [future-incompatible] lint to transition this to a hard
1776     /// error in the future. See [issue #41620] for more details.
1777     ///
1778     /// [issue #41620]: https://github.com/rust-lang/rust/issues/41620
1779     /// [match guard]: https://doc.rust-lang.org/reference/expressions/match-expr.html#match-guards
1780     /// [future-incompatible]: ../index.md#future-incompatible-lints
1781     pub ILLEGAL_FLOATING_POINT_LITERAL_PATTERN,
1782     Warn,
1783     "floating-point literals cannot be used in patterns",
1784     @future_incompatible = FutureIncompatibleInfo {
1785         reference: "issue #41620 <https://github.com/rust-lang/rust/issues/41620>",
1786     };
1787 }
1788
1789 declare_lint! {
1790     /// The `unstable_name_collisions` lint detects that you have used a name
1791     /// that the standard library plans to add in the future.
1792     ///
1793     /// ### Example
1794     ///
1795     /// ```rust
1796     /// trait MyIterator : Iterator {
1797     ///     // is_sorted is an unstable method that already exists on the Iterator trait
1798     ///     fn is_sorted(self) -> bool where Self: Sized {true}
1799     /// }
1800     ///
1801     /// impl<T: ?Sized> MyIterator for T where T: Iterator { }
1802     ///
1803     /// let x = vec![1, 2, 3];
1804     /// let _ = x.iter().is_sorted();
1805     /// ```
1806     ///
1807     /// {{produces}}
1808     ///
1809     /// ### Explanation
1810     ///
1811     /// When new methods are added to traits in the standard library, they are
1812     /// usually added in an "unstable" form which is only available on the
1813     /// [nightly channel] with a [`feature` attribute]. If there is any
1814     /// pre-existing code which extends a trait to have a method with the same
1815     /// name, then the names will collide. In the future, when the method is
1816     /// stabilized, this will cause an error due to the ambiguity. This lint
1817     /// is an early-warning to let you know that there may be a collision in
1818     /// the future. This can be avoided by adding type annotations to
1819     /// disambiguate which trait method you intend to call, such as
1820     /// `MyIterator::is_sorted(my_iter)` or renaming or removing the method.
1821     ///
1822     /// [nightly channel]: https://doc.rust-lang.org/book/appendix-07-nightly-rust.html
1823     /// [`feature` attribute]: https://doc.rust-lang.org/nightly/unstable-book/
1824     pub UNSTABLE_NAME_COLLISIONS,
1825     Warn,
1826     "detects name collision with an existing but unstable method",
1827     @future_incompatible = FutureIncompatibleInfo {
1828         reason: FutureIncompatibilityReason::Custom(
1829             "once this associated item is added to the standard library, \
1830              the ambiguity may cause an error or change in behavior!"
1831         ),
1832         reference: "issue #48919 <https://github.com/rust-lang/rust/issues/48919>",
1833         // Note: this item represents future incompatibility of all unstable functions in the
1834         //       standard library, and thus should never be removed or changed to an error.
1835     };
1836 }
1837
1838 declare_lint! {
1839     /// The `irrefutable_let_patterns` lint detects [irrefutable patterns]
1840     /// in [`if let`]s, [`while let`]s, and `if let` guards.
1841     ///
1842     /// ### Example
1843     ///
1844     /// ```rust
1845     /// if let _ = 123 {
1846     ///     println!("always runs!");
1847     /// }
1848     /// ```
1849     ///
1850     /// {{produces}}
1851     ///
1852     /// ### Explanation
1853     ///
1854     /// There usually isn't a reason to have an irrefutable pattern in an
1855     /// `if let` or `while let` statement, because the pattern will always match
1856     /// successfully. A [`let`] or [`loop`] statement will suffice. However,
1857     /// when generating code with a macro, forbidding irrefutable patterns
1858     /// would require awkward workarounds in situations where the macro
1859     /// doesn't know if the pattern is refutable or not. This lint allows
1860     /// macros to accept this form, while alerting for a possibly incorrect
1861     /// use in normal code.
1862     ///
1863     /// See [RFC 2086] for more details.
1864     ///
1865     /// [irrefutable patterns]: https://doc.rust-lang.org/reference/patterns.html#refutability
1866     /// [`if let`]: https://doc.rust-lang.org/reference/expressions/if-expr.html#if-let-expressions
1867     /// [`while let`]: https://doc.rust-lang.org/reference/expressions/loop-expr.html#predicate-pattern-loops
1868     /// [`let`]: https://doc.rust-lang.org/reference/statements.html#let-statements
1869     /// [`loop`]: https://doc.rust-lang.org/reference/expressions/loop-expr.html#infinite-loops
1870     /// [RFC 2086]: https://github.com/rust-lang/rfcs/blob/master/text/2086-allow-if-let-irrefutables.md
1871     pub IRREFUTABLE_LET_PATTERNS,
1872     Warn,
1873     "detects irrefutable patterns in `if let` and `while let` statements"
1874 }
1875
1876 declare_lint! {
1877     /// The `unused_labels` lint detects [labels] that are never used.
1878     ///
1879     /// [labels]: https://doc.rust-lang.org/reference/expressions/loop-expr.html#loop-labels
1880     ///
1881     /// ### Example
1882     ///
1883     /// ```rust,no_run
1884     /// 'unused_label: loop {}
1885     /// ```
1886     ///
1887     /// {{produces}}
1888     ///
1889     /// ### Explanation
1890     ///
1891     /// Unused labels may signal a mistake or unfinished code. To silence the
1892     /// warning for the individual label, prefix it with an underscore such as
1893     /// `'_my_label:`.
1894     pub UNUSED_LABELS,
1895     Warn,
1896     "detects labels that are never used"
1897 }
1898
1899 declare_lint! {
1900     /// The `where_clauses_object_safety` lint detects for [object safety] of
1901     /// [where clauses].
1902     ///
1903     /// [object safety]: https://doc.rust-lang.org/reference/items/traits.html#object-safety
1904     /// [where clauses]: https://doc.rust-lang.org/reference/items/generics.html#where-clauses
1905     ///
1906     /// ### Example
1907     ///
1908     /// ```rust,no_run
1909     /// trait Trait {}
1910     ///
1911     /// trait X { fn foo(&self) where Self: Trait; }
1912     ///
1913     /// impl X for () { fn foo(&self) {} }
1914     ///
1915     /// impl Trait for dyn X {}
1916     ///
1917     /// // Segfault at opt-level 0, SIGILL otherwise.
1918     /// pub fn main() { <dyn X as X>::foo(&()); }
1919     /// ```
1920     ///
1921     /// {{produces}}
1922     ///
1923     /// ### Explanation
1924     ///
1925     /// The compiler previously allowed these object-unsafe bounds, which was
1926     /// incorrect. This is a [future-incompatible] lint to transition this to
1927     /// a hard error in the future. See [issue #51443] for more details.
1928     ///
1929     /// [issue #51443]: https://github.com/rust-lang/rust/issues/51443
1930     /// [future-incompatible]: ../index.md#future-incompatible-lints
1931     pub WHERE_CLAUSES_OBJECT_SAFETY,
1932     Warn,
1933     "checks the object safety of where clauses",
1934     @future_incompatible = FutureIncompatibleInfo {
1935         reference: "issue #51443 <https://github.com/rust-lang/rust/issues/51443>",
1936     };
1937 }
1938
1939 declare_lint! {
1940     /// The `proc_macro_derive_resolution_fallback` lint detects proc macro
1941     /// derives using inaccessible names from parent modules.
1942     ///
1943     /// ### Example
1944     ///
1945     /// ```rust,ignore (proc-macro)
1946     /// // foo.rs
1947     /// #![crate_type = "proc-macro"]
1948     ///
1949     /// extern crate proc_macro;
1950     ///
1951     /// use proc_macro::*;
1952     ///
1953     /// #[proc_macro_derive(Foo)]
1954     /// pub fn foo1(a: TokenStream) -> TokenStream {
1955     ///     drop(a);
1956     ///     "mod __bar { static mut BAR: Option<Something> = None; }".parse().unwrap()
1957     /// }
1958     /// ```
1959     ///
1960     /// ```rust,ignore (needs-dependency)
1961     /// // bar.rs
1962     /// #[macro_use]
1963     /// extern crate foo;
1964     ///
1965     /// struct Something;
1966     ///
1967     /// #[derive(Foo)]
1968     /// struct Another;
1969     ///
1970     /// fn main() {}
1971     /// ```
1972     ///
1973     /// This will produce:
1974     ///
1975     /// ```text
1976     /// warning: cannot find type `Something` in this scope
1977     ///  --> src/main.rs:8:10
1978     ///   |
1979     /// 8 | #[derive(Foo)]
1980     ///   |          ^^^ names from parent modules are not accessible without an explicit import
1981     ///   |
1982     ///   = note: `#[warn(proc_macro_derive_resolution_fallback)]` on by default
1983     ///   = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
1984     ///   = note: for more information, see issue #50504 <https://github.com/rust-lang/rust/issues/50504>
1985     /// ```
1986     ///
1987     /// ### Explanation
1988     ///
1989     /// If a proc-macro generates a module, the compiler unintentionally
1990     /// allowed items in that module to refer to items in the crate root
1991     /// without importing them. This is a [future-incompatible] lint to
1992     /// transition this to a hard error in the future. See [issue #50504] for
1993     /// more details.
1994     ///
1995     /// [issue #50504]: https://github.com/rust-lang/rust/issues/50504
1996     /// [future-incompatible]: ../index.md#future-incompatible-lints
1997     pub PROC_MACRO_DERIVE_RESOLUTION_FALLBACK,
1998     Deny,
1999     "detects proc macro derives using inaccessible names from parent modules",
2000     @future_incompatible = FutureIncompatibleInfo {
2001         reference: "issue #83583 <https://github.com/rust-lang/rust/issues/83583>",
2002         reason: FutureIncompatibilityReason::FutureReleaseErrorReportNow,
2003     };
2004 }
2005
2006 declare_lint! {
2007     /// The `macro_use_extern_crate` lint detects the use of the
2008     /// [`macro_use` attribute].
2009     ///
2010     /// ### Example
2011     ///
2012     /// ```rust,ignore (needs extern crate)
2013     /// #![deny(macro_use_extern_crate)]
2014     ///
2015     /// #[macro_use]
2016     /// extern crate serde_json;
2017     ///
2018     /// fn main() {
2019     ///     let _ = json!{{}};
2020     /// }
2021     /// ```
2022     ///
2023     /// This will produce:
2024     ///
2025     /// ```text
2026     /// error: deprecated `#[macro_use]` attribute used to import macros should be replaced at use sites with a `use` item to import the macro instead
2027     ///  --> src/main.rs:3:1
2028     ///   |
2029     /// 3 | #[macro_use]
2030     ///   | ^^^^^^^^^^^^
2031     ///   |
2032     /// note: the lint level is defined here
2033     ///  --> src/main.rs:1:9
2034     ///   |
2035     /// 1 | #![deny(macro_use_extern_crate)]
2036     ///   |         ^^^^^^^^^^^^^^^^^^^^^^
2037     /// ```
2038     ///
2039     /// ### Explanation
2040     ///
2041     /// The [`macro_use` attribute] on an [`extern crate`] item causes
2042     /// macros in that external crate to be brought into the prelude of the
2043     /// crate, making the macros in scope everywhere. As part of the efforts
2044     /// to simplify handling of dependencies in the [2018 edition], the use of
2045     /// `extern crate` is being phased out. To bring macros from extern crates
2046     /// into scope, it is recommended to use a [`use` import].
2047     ///
2048     /// This lint is "allow" by default because this is a stylistic choice
2049     /// that has not been settled, see [issue #52043] for more information.
2050     ///
2051     /// [`macro_use` attribute]: https://doc.rust-lang.org/reference/macros-by-example.html#the-macro_use-attribute
2052     /// [`use` import]: https://doc.rust-lang.org/reference/items/use-declarations.html
2053     /// [issue #52043]: https://github.com/rust-lang/rust/issues/52043
2054     pub MACRO_USE_EXTERN_CRATE,
2055     Allow,
2056     "the `#[macro_use]` attribute is now deprecated in favor of using macros \
2057      via the module system"
2058 }
2059
2060 declare_lint! {
2061     /// The `macro_expanded_macro_exports_accessed_by_absolute_paths` lint
2062     /// detects macro-expanded [`macro_export`] macros from the current crate
2063     /// that cannot be referred to by absolute paths.
2064     ///
2065     /// [`macro_export`]: https://doc.rust-lang.org/reference/macros-by-example.html#path-based-scope
2066     ///
2067     /// ### Example
2068     ///
2069     /// ```rust,compile_fail
2070     /// macro_rules! define_exported {
2071     ///     () => {
2072     ///         #[macro_export]
2073     ///         macro_rules! exported {
2074     ///             () => {};
2075     ///         }
2076     ///     };
2077     /// }
2078     ///
2079     /// define_exported!();
2080     ///
2081     /// fn main() {
2082     ///     crate::exported!();
2083     /// }
2084     /// ```
2085     ///
2086     /// {{produces}}
2087     ///
2088     /// ### Explanation
2089     ///
2090     /// The intent is that all macros marked with the `#[macro_export]`
2091     /// attribute are made available in the root of the crate. However, when a
2092     /// `macro_rules!` definition is generated by another macro, the macro
2093     /// expansion is unable to uphold this rule. This is a
2094     /// [future-incompatible] lint to transition this to a hard error in the
2095     /// future. See [issue #53495] for more details.
2096     ///
2097     /// [issue #53495]: https://github.com/rust-lang/rust/issues/53495
2098     /// [future-incompatible]: ../index.md#future-incompatible-lints
2099     pub MACRO_EXPANDED_MACRO_EXPORTS_ACCESSED_BY_ABSOLUTE_PATHS,
2100     Deny,
2101     "macro-expanded `macro_export` macros from the current crate \
2102      cannot be referred to by absolute paths",
2103     @future_incompatible = FutureIncompatibleInfo {
2104         reference: "issue #52234 <https://github.com/rust-lang/rust/issues/52234>",
2105     };
2106     crate_level_only
2107 }
2108
2109 declare_lint! {
2110     /// The `explicit_outlives_requirements` lint detects unnecessary
2111     /// lifetime bounds that can be inferred.
2112     ///
2113     /// ### Example
2114     ///
2115     /// ```rust,compile_fail
2116     /// # #![allow(unused)]
2117     /// #![deny(explicit_outlives_requirements)]
2118     ///
2119     /// struct SharedRef<'a, T>
2120     /// where
2121     ///     T: 'a,
2122     /// {
2123     ///     data: &'a T,
2124     /// }
2125     /// ```
2126     ///
2127     /// {{produces}}
2128     ///
2129     /// ### Explanation
2130     ///
2131     /// If a `struct` contains a reference, such as `&'a T`, the compiler
2132     /// requires that `T` outlives the lifetime `'a`. This historically
2133     /// required writing an explicit lifetime bound to indicate this
2134     /// requirement. However, this can be overly explicit, causing clutter and
2135     /// unnecessary complexity. The language was changed to automatically
2136     /// infer the bound if it is not specified. Specifically, if the struct
2137     /// contains a reference, directly or indirectly, to `T` with lifetime
2138     /// `'x`, then it will infer that `T: 'x` is a requirement.
2139     ///
2140     /// This lint is "allow" by default because it can be noisy for existing
2141     /// code that already had these requirements. This is a stylistic choice,
2142     /// as it is still valid to explicitly state the bound. It also has some
2143     /// false positives that can cause confusion.
2144     ///
2145     /// See [RFC 2093] for more details.
2146     ///
2147     /// [RFC 2093]: https://github.com/rust-lang/rfcs/blob/master/text/2093-infer-outlives.md
2148     pub EXPLICIT_OUTLIVES_REQUIREMENTS,
2149     Allow,
2150     "outlives requirements can be inferred"
2151 }
2152
2153 declare_lint! {
2154     /// The `indirect_structural_match` lint detects a `const` in a pattern
2155     /// that manually implements [`PartialEq`] and [`Eq`].
2156     ///
2157     /// [`PartialEq`]: https://doc.rust-lang.org/std/cmp/trait.PartialEq.html
2158     /// [`Eq`]: https://doc.rust-lang.org/std/cmp/trait.Eq.html
2159     ///
2160     /// ### Example
2161     ///
2162     /// ```rust,compile_fail
2163     /// #![deny(indirect_structural_match)]
2164     ///
2165     /// struct NoDerive(i32);
2166     /// impl PartialEq for NoDerive { fn eq(&self, _: &Self) -> bool { false } }
2167     /// impl Eq for NoDerive { }
2168     /// #[derive(PartialEq, Eq)]
2169     /// struct WrapParam<T>(T);
2170     /// const WRAP_INDIRECT_PARAM: & &WrapParam<NoDerive> = & &WrapParam(NoDerive(0));
2171     /// fn main() {
2172     ///     match WRAP_INDIRECT_PARAM {
2173     ///         WRAP_INDIRECT_PARAM => { }
2174     ///         _ => { }
2175     ///     }
2176     /// }
2177     /// ```
2178     ///
2179     /// {{produces}}
2180     ///
2181     /// ### Explanation
2182     ///
2183     /// The compiler unintentionally accepted this form in the past. This is a
2184     /// [future-incompatible] lint to transition this to a hard error in the
2185     /// future. See [issue #62411] for a complete description of the problem,
2186     /// and some possible solutions.
2187     ///
2188     /// [issue #62411]: https://github.com/rust-lang/rust/issues/62411
2189     /// [future-incompatible]: ../index.md#future-incompatible-lints
2190     pub INDIRECT_STRUCTURAL_MATCH,
2191     Warn,
2192     "constant used in pattern contains value of non-structural-match type in a field or a variant",
2193     @future_incompatible = FutureIncompatibleInfo {
2194         reference: "issue #62411 <https://github.com/rust-lang/rust/issues/62411>",
2195     };
2196 }
2197
2198 declare_lint! {
2199     /// The `deprecated_in_future` lint is internal to rustc and should not be
2200     /// used by user code.
2201     ///
2202     /// This lint is only enabled in the standard library. It works with the
2203     /// use of `#[rustc_deprecated]` with a `since` field of a version in the
2204     /// future. This allows something to be marked as deprecated in a future
2205     /// version, and then this lint will ensure that the item is no longer
2206     /// used in the standard library. See the [stability documentation] for
2207     /// more details.
2208     ///
2209     /// [stability documentation]: https://rustc-dev-guide.rust-lang.org/stability.html#rustc_deprecated
2210     pub DEPRECATED_IN_FUTURE,
2211     Allow,
2212     "detects use of items that will be deprecated in a future version",
2213     report_in_external_macro
2214 }
2215
2216 declare_lint! {
2217     /// The `pointer_structural_match` lint detects pointers used in patterns whose behaviour
2218     /// cannot be relied upon across compiler versions and optimization levels.
2219     ///
2220     /// ### Example
2221     ///
2222     /// ```rust,compile_fail
2223     /// #![deny(pointer_structural_match)]
2224     /// fn foo(a: usize, b: usize) -> usize { a + b }
2225     /// const FOO: fn(usize, usize) -> usize = foo;
2226     /// fn main() {
2227     ///     match FOO {
2228     ///         FOO => {},
2229     ///         _ => {},
2230     ///     }
2231     /// }
2232     /// ```
2233     ///
2234     /// {{produces}}
2235     ///
2236     /// ### Explanation
2237     ///
2238     /// Previous versions of Rust allowed function pointers and wide raw pointers in patterns.
2239     /// While these work in many cases as expected by users, it is possible that due to
2240     /// optimizations pointers are "not equal to themselves" or pointers to different functions
2241     /// compare as equal during runtime. This is because LLVM optimizations can deduplicate
2242     /// functions if their bodies are the same, thus also making pointers to these functions point
2243     /// to the same location. Additionally functions may get duplicated if they are instantiated
2244     /// in different crates and not deduplicated again via LTO.
2245     pub POINTER_STRUCTURAL_MATCH,
2246     Allow,
2247     "pointers are not structural-match",
2248     @future_incompatible = FutureIncompatibleInfo {
2249         reference: "issue #62411 <https://github.com/rust-lang/rust/issues/70861>",
2250     };
2251 }
2252
2253 declare_lint! {
2254     /// The `nontrivial_structural_match` lint detects constants that are used in patterns,
2255     /// whose type is not structural-match and whose initializer body actually uses values
2256     /// that are not structural-match. So `Option<NotStructuralMatch>` is ok if the constant
2257     /// is just `None`.
2258     ///
2259     /// ### Example
2260     ///
2261     /// ```rust,compile_fail
2262     /// #![deny(nontrivial_structural_match)]
2263     ///
2264     /// #[derive(Copy, Clone, Debug)]
2265     /// struct NoDerive(u32);
2266     /// impl PartialEq for NoDerive { fn eq(&self, _: &Self) -> bool { false } }
2267     /// impl Eq for NoDerive { }
2268     /// fn main() {
2269     ///     const INDEX: Option<NoDerive> = [None, Some(NoDerive(10))][0];
2270     ///     match None { Some(_) => panic!("whoops"), INDEX => dbg!(INDEX), };
2271     /// }
2272     /// ```
2273     ///
2274     /// {{produces}}
2275     ///
2276     /// ### Explanation
2277     ///
2278     /// Previous versions of Rust accepted constants in patterns, even if those constants' types
2279     /// did not have `PartialEq` derived. Thus the compiler falls back to runtime execution of
2280     /// `PartialEq`, which can report that two constants are not equal even if they are
2281     /// bit-equivalent.
2282     pub NONTRIVIAL_STRUCTURAL_MATCH,
2283     Warn,
2284     "constant used in pattern of non-structural-match type and the constant's initializer \
2285     expression contains values of non-structural-match types",
2286     @future_incompatible = FutureIncompatibleInfo {
2287         reference: "issue #73448 <https://github.com/rust-lang/rust/issues/73448>",
2288     };
2289 }
2290
2291 declare_lint! {
2292     /// The `ambiguous_associated_items` lint detects ambiguity between
2293     /// [associated items] and [enum variants].
2294     ///
2295     /// [associated items]: https://doc.rust-lang.org/reference/items/associated-items.html
2296     /// [enum variants]: https://doc.rust-lang.org/reference/items/enumerations.html
2297     ///
2298     /// ### Example
2299     ///
2300     /// ```rust,compile_fail
2301     /// enum E {
2302     ///     V
2303     /// }
2304     ///
2305     /// trait Tr {
2306     ///     type V;
2307     ///     fn foo() -> Self::V;
2308     /// }
2309     ///
2310     /// impl Tr for E {
2311     ///     type V = u8;
2312     ///     // `Self::V` is ambiguous because it may refer to the associated type or
2313     ///     // the enum variant.
2314     ///     fn foo() -> Self::V { 0 }
2315     /// }
2316     /// ```
2317     ///
2318     /// {{produces}}
2319     ///
2320     /// ### Explanation
2321     ///
2322     /// Previous versions of Rust did not allow accessing enum variants
2323     /// through [type aliases]. When this ability was added (see [RFC 2338]), this
2324     /// introduced some situations where it can be ambiguous what a type
2325     /// was referring to.
2326     ///
2327     /// To fix this ambiguity, you should use a [qualified path] to explicitly
2328     /// state which type to use. For example, in the above example the
2329     /// function can be written as `fn f() -> <Self as Tr>::V { 0 }` to
2330     /// specifically refer to the associated type.
2331     ///
2332     /// This is a [future-incompatible] lint to transition this to a hard
2333     /// error in the future. See [issue #57644] for more details.
2334     ///
2335     /// [issue #57644]: https://github.com/rust-lang/rust/issues/57644
2336     /// [type aliases]: https://doc.rust-lang.org/reference/items/type-aliases.html#type-aliases
2337     /// [RFC 2338]: https://github.com/rust-lang/rfcs/blob/master/text/2338-type-alias-enum-variants.md
2338     /// [qualified path]: https://doc.rust-lang.org/reference/paths.html#qualified-paths
2339     /// [future-incompatible]: ../index.md#future-incompatible-lints
2340     pub AMBIGUOUS_ASSOCIATED_ITEMS,
2341     Deny,
2342     "ambiguous associated items",
2343     @future_incompatible = FutureIncompatibleInfo {
2344         reference: "issue #57644 <https://github.com/rust-lang/rust/issues/57644>",
2345     };
2346 }
2347
2348 declare_lint! {
2349     /// The `mutable_borrow_reservation_conflict` lint detects the reservation
2350     /// of a two-phased borrow that conflicts with other shared borrows.
2351     ///
2352     /// ### Example
2353     ///
2354     /// ```rust
2355     /// let mut v = vec![0, 1, 2];
2356     /// let shared = &v;
2357     /// v.push(shared.len());
2358     /// ```
2359     ///
2360     /// {{produces}}
2361     ///
2362     /// ### Explanation
2363     ///
2364     /// This is a [future-incompatible] lint to transition this to a hard error
2365     /// in the future. See [issue #59159] for a complete description of the
2366     /// problem, and some possible solutions.
2367     ///
2368     /// [issue #59159]: https://github.com/rust-lang/rust/issues/59159
2369     /// [future-incompatible]: ../index.md#future-incompatible-lints
2370     pub MUTABLE_BORROW_RESERVATION_CONFLICT,
2371     Warn,
2372     "reservation of a two-phased borrow conflicts with other shared borrows",
2373     @future_incompatible = FutureIncompatibleInfo {
2374         reason: FutureIncompatibilityReason::Custom(
2375             "this borrowing pattern was not meant to be accepted, \
2376             and may become a hard error in the future"
2377         ),
2378         reference: "issue #59159 <https://github.com/rust-lang/rust/issues/59159>",
2379     };
2380 }
2381
2382 declare_lint! {
2383     /// The `soft_unstable` lint detects unstable features that were
2384     /// unintentionally allowed on stable.
2385     ///
2386     /// ### Example
2387     ///
2388     /// ```rust,compile_fail
2389     /// #[cfg(test)]
2390     /// extern crate test;
2391     ///
2392     /// #[bench]
2393     /// fn name(b: &mut test::Bencher) {
2394     ///     b.iter(|| 123)
2395     /// }
2396     /// ```
2397     ///
2398     /// {{produces}}
2399     ///
2400     /// ### Explanation
2401     ///
2402     /// The [`bench` attribute] was accidentally allowed to be specified on
2403     /// the [stable release channel]. Turning this to a hard error would have
2404     /// broken some projects. This lint allows those projects to continue to
2405     /// build correctly when [`--cap-lints`] is used, but otherwise signal an
2406     /// error that `#[bench]` should not be used on the stable channel. This
2407     /// is a [future-incompatible] lint to transition this to a hard error in
2408     /// the future. See [issue #64266] for more details.
2409     ///
2410     /// [issue #64266]: https://github.com/rust-lang/rust/issues/64266
2411     /// [`bench` attribute]: https://doc.rust-lang.org/nightly/unstable-book/library-features/test.html
2412     /// [stable release channel]: https://doc.rust-lang.org/book/appendix-07-nightly-rust.html
2413     /// [`--cap-lints`]: https://doc.rust-lang.org/rustc/lints/levels.html#capping-lints
2414     /// [future-incompatible]: ../index.md#future-incompatible-lints
2415     pub SOFT_UNSTABLE,
2416     Deny,
2417     "a feature gate that doesn't break dependent crates",
2418     @future_incompatible = FutureIncompatibleInfo {
2419         reference: "issue #64266 <https://github.com/rust-lang/rust/issues/64266>",
2420     };
2421 }
2422
2423 declare_lint! {
2424     /// The `inline_no_sanitize` lint detects incompatible use of
2425     /// [`#[inline(always)]`][inline] and [`#[no_sanitize(...)]`][no_sanitize].
2426     ///
2427     /// [inline]: https://doc.rust-lang.org/reference/attributes/codegen.html#the-inline-attribute
2428     /// [no_sanitize]: https://doc.rust-lang.org/nightly/unstable-book/language-features/no-sanitize.html
2429     ///
2430     /// ### Example
2431     ///
2432     /// ```rust
2433     /// #![feature(no_sanitize)]
2434     ///
2435     /// #[inline(always)]
2436     /// #[no_sanitize(address)]
2437     /// fn x() {}
2438     ///
2439     /// fn main() {
2440     ///     x()
2441     /// }
2442     /// ```
2443     ///
2444     /// {{produces}}
2445     ///
2446     /// ### Explanation
2447     ///
2448     /// The use of the [`#[inline(always)]`][inline] attribute prevents the
2449     /// the [`#[no_sanitize(...)]`][no_sanitize] attribute from working.
2450     /// Consider temporarily removing `inline` attribute.
2451     pub INLINE_NO_SANITIZE,
2452     Warn,
2453     "detects incompatible use of `#[inline(always)]` and `#[no_sanitize(...)]`",
2454 }
2455
2456 declare_lint! {
2457     /// The `asm_sub_register` lint detects using only a subset of a register
2458     /// for inline asm inputs.
2459     ///
2460     /// ### Example
2461     ///
2462     /// ```rust,ignore (fails on non-x86_64)
2463     /// #[cfg(target_arch="x86_64")]
2464     /// use std::arch::asm;
2465     ///
2466     /// fn main() {
2467     ///     #[cfg(target_arch="x86_64")]
2468     ///     unsafe {
2469     ///         asm!("mov {0}, {0}", in(reg) 0i16);
2470     ///     }
2471     /// }
2472     /// ```
2473     ///
2474     /// This will produce:
2475     ///
2476     /// ```text
2477     /// warning: formatting may not be suitable for sub-register argument
2478     ///  --> src/main.rs:7:19
2479     ///   |
2480     /// 7 |         asm!("mov {0}, {0}", in(reg) 0i16);
2481     ///   |                   ^^^  ^^^           ---- for this argument
2482     ///   |
2483     ///   = note: `#[warn(asm_sub_register)]` on by default
2484     ///   = help: use the `x` modifier to have the register formatted as `ax`
2485     ///   = help: or use the `r` modifier to keep the default formatting of `rax`
2486     /// ```
2487     ///
2488     /// ### Explanation
2489     ///
2490     /// Registers on some architectures can use different names to refer to a
2491     /// subset of the register. By default, the compiler will use the name for
2492     /// the full register size. To explicitly use a subset of the register,
2493     /// you can override the default by using a modifier on the template
2494     /// string operand to specify when subregister to use. This lint is issued
2495     /// if you pass in a value with a smaller data type than the default
2496     /// register size, to alert you of possibly using the incorrect width. To
2497     /// fix this, add the suggested modifier to the template, or cast the
2498     /// value to the correct size.
2499     ///
2500     /// See [register template modifiers] in the reference for more details.
2501     ///
2502     /// [register template modifiers]: https://doc.rust-lang.org/nightly/reference/inline-assembly.html#template-modifiers
2503     pub ASM_SUB_REGISTER,
2504     Warn,
2505     "using only a subset of a register for inline asm inputs",
2506 }
2507
2508 declare_lint! {
2509     /// The `bad_asm_style` lint detects the use of the `.intel_syntax` and
2510     /// `.att_syntax` directives.
2511     ///
2512     /// ### Example
2513     ///
2514     /// ```rust,ignore (fails on non-x86_64)
2515     /// #[cfg(target_arch="x86_64")]
2516     /// use std::arch::asm;
2517     ///
2518     /// fn main() {
2519     ///     #[cfg(target_arch="x86_64")]
2520     ///     unsafe {
2521     ///         asm!(
2522     ///             ".att_syntax",
2523     ///             "movq %{0}, %{0}", in(reg) 0usize
2524     ///         );
2525     ///     }
2526     /// }
2527     /// ```
2528     ///
2529     /// This will produce:
2530     ///
2531     /// ```text
2532     /// warning: avoid using `.att_syntax`, prefer using `options(att_syntax)` instead
2533     ///  --> src/main.rs:8:14
2534     ///   |
2535     /// 8 |             ".att_syntax",
2536     ///   |              ^^^^^^^^^^^
2537     ///   |
2538     ///   = note: `#[warn(bad_asm_style)]` on by default
2539     /// ```
2540     ///
2541     /// ### Explanation
2542     ///
2543     /// On x86, `asm!` uses the intel assembly syntax by default. While this
2544     /// can be switched using assembler directives like `.att_syntax`, using the
2545     /// `att_syntax` option is recommended instead because it will also properly
2546     /// prefix register placeholders with `%` as required by AT&T syntax.
2547     pub BAD_ASM_STYLE,
2548     Warn,
2549     "incorrect use of inline assembly",
2550 }
2551
2552 declare_lint! {
2553     /// The `unsafe_op_in_unsafe_fn` lint detects unsafe operations in unsafe
2554     /// functions without an explicit unsafe block.
2555     ///
2556     /// ### Example
2557     ///
2558     /// ```rust,compile_fail
2559     /// #![deny(unsafe_op_in_unsafe_fn)]
2560     ///
2561     /// unsafe fn foo() {}
2562     ///
2563     /// unsafe fn bar() {
2564     ///     foo();
2565     /// }
2566     ///
2567     /// fn main() {}
2568     /// ```
2569     ///
2570     /// {{produces}}
2571     ///
2572     /// ### Explanation
2573     ///
2574     /// Currently, an [`unsafe fn`] allows any [unsafe] operation within its
2575     /// body. However, this can increase the surface area of code that needs
2576     /// to be scrutinized for proper behavior. The [`unsafe` block] provides a
2577     /// convenient way to make it clear exactly which parts of the code are
2578     /// performing unsafe operations. In the future, it is desired to change
2579     /// it so that unsafe operations cannot be performed in an `unsafe fn`
2580     /// without an `unsafe` block.
2581     ///
2582     /// The fix to this is to wrap the unsafe code in an `unsafe` block.
2583     ///
2584     /// This lint is "allow" by default since this will affect a large amount
2585     /// of existing code, and the exact plan for increasing the severity is
2586     /// still being considered. See [RFC #2585] and [issue #71668] for more
2587     /// details.
2588     ///
2589     /// [`unsafe fn`]: https://doc.rust-lang.org/reference/unsafe-functions.html
2590     /// [`unsafe` block]: https://doc.rust-lang.org/reference/expressions/block-expr.html#unsafe-blocks
2591     /// [unsafe]: https://doc.rust-lang.org/reference/unsafety.html
2592     /// [RFC #2585]: https://github.com/rust-lang/rfcs/blob/master/text/2585-unsafe-block-in-unsafe-fn.md
2593     /// [issue #71668]: https://github.com/rust-lang/rust/issues/71668
2594     pub UNSAFE_OP_IN_UNSAFE_FN,
2595     Allow,
2596     "unsafe operations in unsafe functions without an explicit unsafe block are deprecated",
2597 }
2598
2599 declare_lint! {
2600     /// The `cenum_impl_drop_cast` lint detects an `as` cast of a field-less
2601     /// `enum` that implements [`Drop`].
2602     ///
2603     /// [`Drop`]: https://doc.rust-lang.org/std/ops/trait.Drop.html
2604     ///
2605     /// ### Example
2606     ///
2607     /// ```rust
2608     /// # #![allow(unused)]
2609     /// enum E {
2610     ///     A,
2611     /// }
2612     ///
2613     /// impl Drop for E {
2614     ///     fn drop(&mut self) {
2615     ///         println!("Drop");
2616     ///     }
2617     /// }
2618     ///
2619     /// fn main() {
2620     ///     let e = E::A;
2621     ///     let i = e as u32;
2622     /// }
2623     /// ```
2624     ///
2625     /// {{produces}}
2626     ///
2627     /// ### Explanation
2628     ///
2629     /// Casting a field-less `enum` that does not implement [`Copy`] to an
2630     /// integer moves the value without calling `drop`. This can result in
2631     /// surprising behavior if it was expected that `drop` should be called.
2632     /// Calling `drop` automatically would be inconsistent with other move
2633     /// operations. Since neither behavior is clear or consistent, it was
2634     /// decided that a cast of this nature will no longer be allowed.
2635     ///
2636     /// This is a [future-incompatible] lint to transition this to a hard error
2637     /// in the future. See [issue #73333] for more details.
2638     ///
2639     /// [future-incompatible]: ../index.md#future-incompatible-lints
2640     /// [issue #73333]: https://github.com/rust-lang/rust/issues/73333
2641     /// [`Copy`]: https://doc.rust-lang.org/std/marker/trait.Copy.html
2642     pub CENUM_IMPL_DROP_CAST,
2643     Warn,
2644     "a C-like enum implementing Drop is cast",
2645     @future_incompatible = FutureIncompatibleInfo {
2646         reference: "issue #73333 <https://github.com/rust-lang/rust/issues/73333>",
2647     };
2648 }
2649
2650 declare_lint! {
2651     /// The `fuzzy_provenance_casts` lint detects an `as` cast between an integer
2652     /// and a pointer.
2653     ///
2654     /// ### Example
2655     ///
2656     /// ```rust
2657     /// #![feature(strict_provenance)]
2658     /// #![warn(fuzzy_provenance_casts)]
2659     ///
2660     /// fn main() {
2661     ///     let _dangling = 16_usize as *const u8;
2662     /// }
2663     /// ```
2664     ///
2665     /// {{produces}}
2666     ///
2667     /// ### Explanation
2668     ///
2669     /// This lint is part of the strict provenance effort, see [issue #95228].
2670     /// Casting an integer to a pointer is considered bad style, as a pointer
2671     /// contains, besides the *address* also a *provenance*, indicating what
2672     /// memory the pointer is allowed to read/write. Casting an integer, which
2673     /// doesn't have provenance, to a pointer requires the compiler to assign
2674     /// (guess) provenance. The compiler assigns "all exposed valid" (see the
2675     /// docs of [`ptr::from_exposed_addr`] for more information about this
2676     /// "exposing"). This penalizes the optimiser and is not well suited for
2677     /// dynamic analysis/dynamic program verification (e.g. Miri or CHERI
2678     /// platforms).
2679     ///
2680     /// It is much better to use [`ptr::with_addr`] instead to specify the
2681     /// provenance you want. If using this function is not possible because the
2682     /// code relies on exposed provenance then there is as an escape hatch
2683     /// [`ptr::from_exposed_addr`].
2684     ///
2685     /// [issue #95228]: https://github.com/rust-lang/rust/issues/95228
2686     /// [`ptr::with_addr`]: https://doc.rust-lang.org/core/ptr/fn.with_addr
2687     /// [`ptr::from_exposed_addr`]: https://doc.rust-lang.org/core/ptr/fn.from_exposed_addr
2688     pub FUZZY_PROVENANCE_CASTS,
2689     Allow,
2690     "a fuzzy integer to pointer cast is used",
2691     @feature_gate = sym::strict_provenance;
2692 }
2693
2694 declare_lint! {
2695     /// The `lossy_provenance_casts` lint detects an `as` cast between a pointer
2696     /// and an integer.
2697     ///
2698     /// ### Example
2699     ///
2700     /// ```rust
2701     /// #![feature(strict_provenance)]
2702     /// #![warn(lossy_provenance_casts)]
2703     ///
2704     /// fn main() {
2705     ///     let x: u8 = 37;
2706     ///     let _addr: usize = &x as *const u8 as usize;
2707     /// }
2708     /// ```
2709     ///
2710     /// {{produces}}
2711     ///
2712     /// ### Explanation
2713     ///
2714     /// This lint is part of the strict provenance effort, see [issue #95228].
2715     /// Casting a pointer to an integer is a lossy operation, because beyond
2716     /// just an *address* a pointer may be associated with a particular
2717     /// *provenance*. This information is used by the optimiser and for dynamic
2718     /// analysis/dynamic program verification (e.g. Miri or CHERI platforms).
2719     ///
2720     /// Since this cast is lossy, it is considered good style to use the
2721     /// [`ptr::addr`] method instead, which has a similar effect, but doesn't
2722     /// "expose" the pointer provenance. This improves optimisation potential.
2723     /// See the docs of [`ptr::addr`] and [`ptr::expose_addr`] for more information
2724     /// about exposing pointer provenance.
2725     ///
2726     /// If your code can't comply with strict provenance and needs to expose
2727     /// the provenance, then there is [`ptr::expose_addr`] as an escape hatch,
2728     /// which preserves the behaviour of `as usize` casts while being explicit
2729     /// about the semantics.
2730     ///
2731     /// [issue #95228]: https://github.com/rust-lang/rust/issues/95228
2732     /// [`ptr::addr`]: https://doc.rust-lang.org/core/ptr/fn.addr
2733     /// [`ptr::expose_addr`]: https://doc.rust-lang.org/core/ptr/fn.expose_addr
2734     pub LOSSY_PROVENANCE_CASTS,
2735     Allow,
2736     "a lossy pointer to integer cast is used",
2737     @feature_gate = sym::strict_provenance;
2738 }
2739
2740 declare_lint! {
2741     /// The `const_evaluatable_unchecked` lint detects a generic constant used
2742     /// in a type.
2743     ///
2744     /// ### Example
2745     ///
2746     /// ```rust
2747     /// const fn foo<T>() -> usize {
2748     ///     if std::mem::size_of::<*mut T>() < 8 { // size of *mut T does not depend on T
2749     ///         4
2750     ///     } else {
2751     ///         8
2752     ///     }
2753     /// }
2754     ///
2755     /// fn test<T>() {
2756     ///     let _ = [0; foo::<T>()];
2757     /// }
2758     /// ```
2759     ///
2760     /// {{produces}}
2761     ///
2762     /// ### Explanation
2763     ///
2764     /// In the 1.43 release, some uses of generic parameters in array repeat
2765     /// expressions were accidentally allowed. This is a [future-incompatible]
2766     /// lint to transition this to a hard error in the future. See [issue
2767     /// #76200] for a more detailed description and possible fixes.
2768     ///
2769     /// [future-incompatible]: ../index.md#future-incompatible-lints
2770     /// [issue #76200]: https://github.com/rust-lang/rust/issues/76200
2771     pub CONST_EVALUATABLE_UNCHECKED,
2772     Warn,
2773     "detects a generic constant is used in a type without a emitting a warning",
2774     @future_incompatible = FutureIncompatibleInfo {
2775         reference: "issue #76200 <https://github.com/rust-lang/rust/issues/76200>",
2776     };
2777 }
2778
2779 declare_lint! {
2780     /// The `function_item_references` lint detects function references that are
2781     /// formatted with [`fmt::Pointer`] or transmuted.
2782     ///
2783     /// [`fmt::Pointer`]: https://doc.rust-lang.org/std/fmt/trait.Pointer.html
2784     ///
2785     /// ### Example
2786     ///
2787     /// ```rust
2788     /// fn foo() { }
2789     ///
2790     /// fn main() {
2791     ///     println!("{:p}", &foo);
2792     /// }
2793     /// ```
2794     ///
2795     /// {{produces}}
2796     ///
2797     /// ### Explanation
2798     ///
2799     /// Taking a reference to a function may be mistaken as a way to obtain a
2800     /// pointer to that function. This can give unexpected results when
2801     /// formatting the reference as a pointer or transmuting it. This lint is
2802     /// issued when function references are formatted as pointers, passed as
2803     /// arguments bound by [`fmt::Pointer`] or transmuted.
2804     pub FUNCTION_ITEM_REFERENCES,
2805     Warn,
2806     "suggest casting to a function pointer when attempting to take references to function items",
2807 }
2808
2809 declare_lint! {
2810     /// The `uninhabited_static` lint detects uninhabited statics.
2811     ///
2812     /// ### Example
2813     ///
2814     /// ```rust
2815     /// enum Void {}
2816     /// extern {
2817     ///     static EXTERN: Void;
2818     /// }
2819     /// ```
2820     ///
2821     /// {{produces}}
2822     ///
2823     /// ### Explanation
2824     ///
2825     /// Statics with an uninhabited type can never be initialized, so they are impossible to define.
2826     /// However, this can be side-stepped with an `extern static`, leading to problems later in the
2827     /// compiler which assumes that there are no initialized uninhabited places (such as locals or
2828     /// statics). This was accidentally allowed, but is being phased out.
2829     pub UNINHABITED_STATIC,
2830     Warn,
2831     "uninhabited static",
2832     @future_incompatible = FutureIncompatibleInfo {
2833         reference: "issue #74840 <https://github.com/rust-lang/rust/issues/74840>",
2834     };
2835 }
2836
2837 declare_lint! {
2838     /// The `useless_deprecated` lint detects deprecation attributes with no effect.
2839     ///
2840     /// ### Example
2841     ///
2842     /// ```rust,compile_fail
2843     /// struct X;
2844     ///
2845     /// #[deprecated = "message"]
2846     /// impl Default for X {
2847     ///     fn default() -> Self {
2848     ///         X
2849     ///     }
2850     /// }
2851     /// ```
2852     ///
2853     /// {{produces}}
2854     ///
2855     /// ### Explanation
2856     ///
2857     /// Deprecation attributes have no effect on trait implementations.
2858     pub USELESS_DEPRECATED,
2859     Deny,
2860     "detects deprecation attributes with no effect",
2861 }
2862
2863 declare_lint! {
2864     /// The `undefined_naked_function_abi` lint detects naked function definitions that
2865     /// either do not specify an ABI or specify the Rust ABI.
2866     ///
2867     /// ### Example
2868     ///
2869     /// ```rust
2870     /// #![feature(naked_functions)]
2871     ///
2872     /// use std::arch::asm;
2873     ///
2874     /// #[naked]
2875     /// pub fn default_abi() -> u32 {
2876     ///     unsafe { asm!("", options(noreturn)); }
2877     /// }
2878     ///
2879     /// #[naked]
2880     /// pub extern "Rust" fn rust_abi() -> u32 {
2881     ///     unsafe { asm!("", options(noreturn)); }
2882     /// }
2883     /// ```
2884     ///
2885     /// {{produces}}
2886     ///
2887     /// ### Explanation
2888     ///
2889     /// The Rust ABI is currently undefined. Therefore, naked functions should
2890     /// specify a non-Rust ABI.
2891     pub UNDEFINED_NAKED_FUNCTION_ABI,
2892     Warn,
2893     "undefined naked function ABI"
2894 }
2895
2896 declare_lint! {
2897     /// The `ineffective_unstable_trait_impl` lint detects `#[unstable]` attributes which are not used.
2898     ///
2899     /// ### Example
2900     ///
2901     /// ```rust,compile_fail
2902     /// #![feature(staged_api)]
2903     ///
2904     /// #[derive(Clone)]
2905     /// #[stable(feature = "x", since = "1")]
2906     /// struct S {}
2907     ///
2908     /// #[unstable(feature = "y", issue = "none")]
2909     /// impl Copy for S {}
2910     /// ```
2911     ///
2912     /// {{produces}}
2913     ///
2914     /// ### Explanation
2915     ///
2916     /// `staged_api` does not currently support using a stability attribute on `impl` blocks.
2917     /// `impl`s are always stable if both the type and trait are stable, and always unstable otherwise.
2918     pub INEFFECTIVE_UNSTABLE_TRAIT_IMPL,
2919     Deny,
2920     "detects `#[unstable]` on stable trait implementations for stable types"
2921 }
2922
2923 declare_lint! {
2924     /// The `semicolon_in_expressions_from_macros` lint detects trailing semicolons
2925     /// in macro bodies when the macro is invoked in expression position.
2926     /// This was previous accepted, but is being phased out.
2927     ///
2928     /// ### Example
2929     ///
2930     /// ```rust,compile_fail
2931     /// #![deny(semicolon_in_expressions_from_macros)]
2932     /// macro_rules! foo {
2933     ///     () => { true; }
2934     /// }
2935     ///
2936     /// fn main() {
2937     ///     let val = match true {
2938     ///         true => false,
2939     ///         _ => foo!()
2940     ///     };
2941     /// }
2942     /// ```
2943     ///
2944     /// {{produces}}
2945     ///
2946     /// ### Explanation
2947     ///
2948     /// Previous, Rust ignored trailing semicolon in a macro
2949     /// body when a macro was invoked in expression position.
2950     /// However, this makes the treatment of semicolons in the language
2951     /// inconsistent, and could lead to unexpected runtime behavior
2952     /// in some circumstances (e.g. if the macro author expects
2953     /// a value to be dropped).
2954     ///
2955     /// This is a [future-incompatible] lint to transition this
2956     /// to a hard error in the future. See [issue #79813] for more details.
2957     ///
2958     /// [issue #79813]: https://github.com/rust-lang/rust/issues/79813
2959     /// [future-incompatible]: ../index.md#future-incompatible-lints
2960     pub SEMICOLON_IN_EXPRESSIONS_FROM_MACROS,
2961     Warn,
2962     "trailing semicolon in macro body used as expression",
2963     @future_incompatible = FutureIncompatibleInfo {
2964         reference: "issue #79813 <https://github.com/rust-lang/rust/issues/79813>",
2965     };
2966 }
2967
2968 declare_lint! {
2969     /// The `legacy_derive_helpers` lint detects derive helper attributes
2970     /// that are used before they are introduced.
2971     ///
2972     /// ### Example
2973     ///
2974     /// ```rust,ignore (needs extern crate)
2975     /// #[serde(rename_all = "camelCase")]
2976     /// #[derive(Deserialize)]
2977     /// struct S { /* fields */ }
2978     /// ```
2979     ///
2980     /// produces:
2981     ///
2982     /// ```text
2983     /// warning: derive helper attribute is used before it is introduced
2984     ///   --> $DIR/legacy-derive-helpers.rs:1:3
2985     ///    |
2986     ///  1 | #[serde(rename_all = "camelCase")]
2987     ///    |   ^^^^^
2988     /// ...
2989     ///  2 | #[derive(Deserialize)]
2990     ///    |          ----------- the attribute is introduced here
2991     /// ```
2992     ///
2993     /// ### Explanation
2994     ///
2995     /// Attributes like this work for historical reasons, but attribute expansion works in
2996     /// left-to-right order in general, so, to resolve `#[serde]`, compiler has to try to "look
2997     /// into the future" at not yet expanded part of the item , but such attempts are not always
2998     /// reliable.
2999     ///
3000     /// To fix the warning place the helper attribute after its corresponding derive.
3001     /// ```rust,ignore (needs extern crate)
3002     /// #[derive(Deserialize)]
3003     /// #[serde(rename_all = "camelCase")]
3004     /// struct S { /* fields */ }
3005     /// ```
3006     pub LEGACY_DERIVE_HELPERS,
3007     Warn,
3008     "detects derive helper attributes that are used before they are introduced",
3009     @future_incompatible = FutureIncompatibleInfo {
3010         reference: "issue #79202 <https://github.com/rust-lang/rust/issues/79202>",
3011     };
3012 }
3013
3014 declare_lint! {
3015     /// The `large_assignments` lint detects when objects of large
3016     /// types are being moved around.
3017     ///
3018     /// ### Example
3019     ///
3020     /// ```rust,ignore (can crash on some platforms)
3021     /// let x = [0; 50000];
3022     /// let y = x;
3023     /// ```
3024     ///
3025     /// produces:
3026     ///
3027     /// ```text
3028     /// warning: moving a large value
3029     ///   --> $DIR/move-large.rs:1:3
3030     ///   let y = x;
3031     ///           - Copied large value here
3032     /// ```
3033     ///
3034     /// ### Explanation
3035     ///
3036     /// When using a large type in a plain assignment or in a function
3037     /// argument, idiomatic code can be inefficient.
3038     /// Ideally appropriate optimizations would resolve this, but such
3039     /// optimizations are only done in a best-effort manner.
3040     /// This lint will trigger on all sites of large moves and thus allow the
3041     /// user to resolve them in code.
3042     pub LARGE_ASSIGNMENTS,
3043     Warn,
3044     "detects large moves or copies",
3045 }
3046
3047 declare_lint! {
3048     /// The `deprecated_cfg_attr_crate_type_name` lint detects uses of the
3049     /// `#![cfg_attr(..., crate_type = "...")]` and
3050     /// `#![cfg_attr(..., crate_name = "...")]` attributes to conditionally
3051     /// specify the crate type and name in the source code.
3052     ///
3053     /// ### Example
3054     ///
3055     /// ```rust
3056     /// #![cfg_attr(debug_assertions, crate_type = "lib")]
3057     /// ```
3058     ///
3059     /// {{produces}}
3060     ///
3061     ///
3062     /// ### Explanation
3063     ///
3064     /// The `#![crate_type]` and `#![crate_name]` attributes require a hack in
3065     /// the compiler to be able to change the used crate type and crate name
3066     /// after macros have been expanded. Neither attribute works in combination
3067     /// with Cargo as it explicitly passes `--crate-type` and `--crate-name` on
3068     /// the commandline. These values must match the value used in the source
3069     /// code to prevent an error.
3070     ///
3071     /// To fix the warning use `--crate-type` on the commandline when running
3072     /// rustc instead of `#![cfg_attr(..., crate_type = "...")]` and
3073     /// `--crate-name` instead of `#![cfg_attr(..., crate_name = "...")]`.
3074     pub DEPRECATED_CFG_ATTR_CRATE_TYPE_NAME,
3075     Warn,
3076     "detects usage of `#![cfg_attr(..., crate_type/crate_name = \"...\")]`",
3077     @future_incompatible = FutureIncompatibleInfo {
3078         reference: "issue #91632 <https://github.com/rust-lang/rust/issues/91632>",
3079     };
3080 }
3081
3082 declare_lint! {
3083     /// The `unexpected_cfgs` lint detects unexpected conditional compilation conditions.
3084     ///
3085     /// ### Example
3086     ///
3087     /// ```text
3088     /// rustc --check-cfg 'names()'
3089     /// ```
3090     ///
3091     /// ```rust,ignore (needs command line option)
3092     /// #[cfg(widnows)]
3093     /// fn foo() {}
3094     /// ```
3095     ///
3096     /// This will produce:
3097     ///
3098     /// ```text
3099     /// warning: unknown condition name used
3100     ///  --> lint_example.rs:1:7
3101     ///   |
3102     /// 1 | #[cfg(widnows)]
3103     ///   |       ^^^^^^^
3104     ///   |
3105     ///   = note: `#[warn(unexpected_cfgs)]` on by default
3106     /// ```
3107     ///
3108     /// ### Explanation
3109     ///
3110     /// This lint is only active when a `--check-cfg='names(...)'` option has been passed
3111     /// to the compiler and triggers whenever an unknown condition name or value is used.
3112     /// The known condition include names or values passed in `--check-cfg`, `--cfg`, and some
3113     /// well-knows names and values built into the compiler.
3114     pub UNEXPECTED_CFGS,
3115     Warn,
3116     "detects unexpected names and values in `#[cfg]` conditions",
3117 }
3118
3119 declare_lint_pass! {
3120     /// Does nothing as a lint pass, but registers some `Lint`s
3121     /// that are used by other parts of the compiler.
3122     HardwiredLints => [
3123         FORBIDDEN_LINT_GROUPS,
3124         ILLEGAL_FLOATING_POINT_LITERAL_PATTERN,
3125         ARITHMETIC_OVERFLOW,
3126         UNCONDITIONAL_PANIC,
3127         UNUSED_IMPORTS,
3128         UNUSED_EXTERN_CRATES,
3129         UNUSED_CRATE_DEPENDENCIES,
3130         UNUSED_QUALIFICATIONS,
3131         UNKNOWN_LINTS,
3132         UNFULFILLED_LINT_EXPECTATIONS,
3133         UNUSED_VARIABLES,
3134         UNUSED_ASSIGNMENTS,
3135         DEAD_CODE,
3136         UNREACHABLE_CODE,
3137         UNREACHABLE_PATTERNS,
3138         OVERLAPPING_RANGE_ENDPOINTS,
3139         BINDINGS_WITH_VARIANT_NAME,
3140         UNUSED_MACROS,
3141         WARNINGS,
3142         UNUSED_FEATURES,
3143         STABLE_FEATURES,
3144         UNKNOWN_CRATE_TYPES,
3145         TRIVIAL_CASTS,
3146         TRIVIAL_NUMERIC_CASTS,
3147         PRIVATE_IN_PUBLIC,
3148         EXPORTED_PRIVATE_DEPENDENCIES,
3149         PUB_USE_OF_PRIVATE_EXTERN_CRATE,
3150         INVALID_TYPE_PARAM_DEFAULT,
3151         CONST_ERR,
3152         RENAMED_AND_REMOVED_LINTS,
3153         UNALIGNED_REFERENCES,
3154         CONST_ITEM_MUTATION,
3155         PATTERNS_IN_FNS_WITHOUT_BODY,
3156         MISSING_FRAGMENT_SPECIFIER,
3157         LATE_BOUND_LIFETIME_ARGUMENTS,
3158         ORDER_DEPENDENT_TRAIT_OBJECTS,
3159         COHERENCE_LEAK_CHECK,
3160         DEPRECATED,
3161         UNUSED_UNSAFE,
3162         UNUSED_MUT,
3163         UNCONDITIONAL_RECURSION,
3164         SINGLE_USE_LIFETIMES,
3165         UNUSED_LIFETIMES,
3166         UNUSED_LABELS,
3167         TYVAR_BEHIND_RAW_POINTER,
3168         ELIDED_LIFETIMES_IN_PATHS,
3169         BARE_TRAIT_OBJECTS,
3170         ABSOLUTE_PATHS_NOT_STARTING_WITH_CRATE,
3171         UNSTABLE_NAME_COLLISIONS,
3172         IRREFUTABLE_LET_PATTERNS,
3173         WHERE_CLAUSES_OBJECT_SAFETY,
3174         PROC_MACRO_DERIVE_RESOLUTION_FALLBACK,
3175         MACRO_USE_EXTERN_CRATE,
3176         MACRO_EXPANDED_MACRO_EXPORTS_ACCESSED_BY_ABSOLUTE_PATHS,
3177         ILL_FORMED_ATTRIBUTE_INPUT,
3178         CONFLICTING_REPR_HINTS,
3179         META_VARIABLE_MISUSE,
3180         DEPRECATED_IN_FUTURE,
3181         AMBIGUOUS_ASSOCIATED_ITEMS,
3182         MUTABLE_BORROW_RESERVATION_CONFLICT,
3183         INDIRECT_STRUCTURAL_MATCH,
3184         POINTER_STRUCTURAL_MATCH,
3185         NONTRIVIAL_STRUCTURAL_MATCH,
3186         SOFT_UNSTABLE,
3187         INLINE_NO_SANITIZE,
3188         BAD_ASM_STYLE,
3189         ASM_SUB_REGISTER,
3190         UNSAFE_OP_IN_UNSAFE_FN,
3191         INCOMPLETE_INCLUDE,
3192         CENUM_IMPL_DROP_CAST,
3193         FUZZY_PROVENANCE_CASTS,
3194         LOSSY_PROVENANCE_CASTS,
3195         CONST_EVALUATABLE_UNCHECKED,
3196         INEFFECTIVE_UNSTABLE_TRAIT_IMPL,
3197         MUST_NOT_SUSPEND,
3198         UNINHABITED_STATIC,
3199         FUNCTION_ITEM_REFERENCES,
3200         USELESS_DEPRECATED,
3201         MISSING_ABI,
3202         INVALID_DOC_ATTRIBUTES,
3203         SEMICOLON_IN_EXPRESSIONS_FROM_MACROS,
3204         RUST_2021_INCOMPATIBLE_CLOSURE_CAPTURES,
3205         LEGACY_DERIVE_HELPERS,
3206         PROC_MACRO_BACK_COMPAT,
3207         RUST_2021_INCOMPATIBLE_OR_PATTERNS,
3208         LARGE_ASSIGNMENTS,
3209         RUST_2021_PRELUDE_COLLISIONS,
3210         RUST_2021_PREFIXES_INCOMPATIBLE_SYNTAX,
3211         UNSUPPORTED_CALLING_CONVENTIONS,
3212         BREAK_WITH_LABEL_AND_LOOP,
3213         UNUSED_ATTRIBUTES,
3214         NON_EXHAUSTIVE_OMITTED_PATTERNS,
3215         TEXT_DIRECTION_CODEPOINT_IN_COMMENT,
3216         DEREF_INTO_DYN_SUPERTRAIT,
3217         DEPRECATED_CFG_ATTR_CRATE_TYPE_NAME,
3218         DUPLICATE_MACRO_ATTRIBUTES,
3219         SUSPICIOUS_AUTO_TRAIT_IMPLS,
3220         UNEXPECTED_CFGS,
3221         DEPRECATED_WHERE_CLAUSE_LOCATION,
3222         TEST_UNSTABLE_LINT,
3223     ]
3224 }
3225
3226 declare_lint! {
3227     /// The `unused_doc_comments` lint detects doc comments that aren't used
3228     /// by `rustdoc`.
3229     ///
3230     /// ### Example
3231     ///
3232     /// ```rust
3233     /// /// docs for x
3234     /// let x = 12;
3235     /// ```
3236     ///
3237     /// {{produces}}
3238     ///
3239     /// ### Explanation
3240     ///
3241     /// `rustdoc` does not use doc comments in all positions, and so the doc
3242     /// comment will be ignored. Try changing it to a normal comment with `//`
3243     /// to avoid the warning.
3244     pub UNUSED_DOC_COMMENTS,
3245     Warn,
3246     "detects doc comments that aren't used by rustdoc"
3247 }
3248
3249 declare_lint! {
3250     /// The `rust_2021_incompatible_closure_captures` lint detects variables that aren't completely
3251     /// captured in Rust 2021, such that the `Drop` order of their fields may differ between
3252     /// Rust 2018 and 2021.
3253     ///
3254     /// It can also detect when a variable implements a trait like `Send`, but one of its fields does not,
3255     /// and the field is captured by a closure and used with the assumption that said field implements
3256     /// the same trait as the root variable.
3257     ///
3258     /// ### Example of drop reorder
3259     ///
3260     /// ```rust,compile_fail
3261     /// #![deny(rust_2021_incompatible_closure_captures)]
3262     /// # #![allow(unused)]
3263     ///
3264     /// struct FancyInteger(i32);
3265     ///
3266     /// impl Drop for FancyInteger {
3267     ///     fn drop(&mut self) {
3268     ///         println!("Just dropped {}", self.0);
3269     ///     }
3270     /// }
3271     ///
3272     /// struct Point { x: FancyInteger, y: FancyInteger }
3273     ///
3274     /// fn main() {
3275     ///   let p = Point { x: FancyInteger(10), y: FancyInteger(20) };
3276     ///
3277     ///   let c = || {
3278     ///      let x = p.x;
3279     ///   };
3280     ///
3281     ///   c();
3282     ///
3283     ///   // ... More code ...
3284     /// }
3285     /// ```
3286     ///
3287     /// {{produces}}
3288     ///
3289     /// ### Explanation
3290     ///
3291     /// In the above example, `p.y` will be dropped at the end of `f` instead of
3292     /// with `c` in Rust 2021.
3293     ///
3294     /// ### Example of auto-trait
3295     ///
3296     /// ```rust,compile_fail
3297     /// #![deny(rust_2021_incompatible_closure_captures)]
3298     /// use std::thread;
3299     ///
3300     /// struct Pointer(*mut i32);
3301     /// unsafe impl Send for Pointer {}
3302     ///
3303     /// fn main() {
3304     ///     let mut f = 10;
3305     ///     let fptr = Pointer(&mut f as *mut i32);
3306     ///     thread::spawn(move || unsafe {
3307     ///         *fptr.0 = 20;
3308     ///     });
3309     /// }
3310     /// ```
3311     ///
3312     /// {{produces}}
3313     ///
3314     /// ### Explanation
3315     ///
3316     /// In the above example, only `fptr.0` is captured in Rust 2021.
3317     /// The field is of type `*mut i32`, which doesn't implement `Send`,
3318     /// making the code invalid as the field cannot be sent between threads safely.
3319     pub RUST_2021_INCOMPATIBLE_CLOSURE_CAPTURES,
3320     Allow,
3321     "detects closures affected by Rust 2021 changes",
3322     @future_incompatible = FutureIncompatibleInfo {
3323         reason: FutureIncompatibilityReason::EditionSemanticsChange(Edition::Edition2021),
3324         explain_reason: false,
3325     };
3326 }
3327
3328 declare_lint_pass!(UnusedDocComment => [UNUSED_DOC_COMMENTS]);
3329
3330 declare_lint! {
3331     /// The `missing_abi` lint detects cases where the ABI is omitted from
3332     /// extern declarations.
3333     ///
3334     /// ### Example
3335     ///
3336     /// ```rust,compile_fail
3337     /// #![deny(missing_abi)]
3338     ///
3339     /// extern fn foo() {}
3340     /// ```
3341     ///
3342     /// {{produces}}
3343     ///
3344     /// ### Explanation
3345     ///
3346     /// Historically, Rust implicitly selected C as the ABI for extern
3347     /// declarations. We expect to add new ABIs, like `C-unwind`, in the future,
3348     /// though this has not yet happened, and especially with their addition
3349     /// seeing the ABI easily will make code review easier.
3350     pub MISSING_ABI,
3351     Allow,
3352     "No declared ABI for extern declaration"
3353 }
3354
3355 declare_lint! {
3356     /// The `invalid_doc_attributes` lint detects when the `#[doc(...)]` is
3357     /// misused.
3358     ///
3359     /// ### Example
3360     ///
3361     /// ```rust,compile_fail
3362     /// #![deny(warnings)]
3363     ///
3364     /// pub mod submodule {
3365     ///     #![doc(test(no_crate_inject))]
3366     /// }
3367     /// ```
3368     ///
3369     /// {{produces}}
3370     ///
3371     /// ### Explanation
3372     ///
3373     /// Previously, there were very like checks being performed on `#[doc(..)]`
3374     /// unlike the other attributes. It'll now catch all the issues that it
3375     /// silently ignored previously.
3376     pub INVALID_DOC_ATTRIBUTES,
3377     Warn,
3378     "detects invalid `#[doc(...)]` attributes",
3379     @future_incompatible = FutureIncompatibleInfo {
3380         reference: "issue #82730 <https://github.com/rust-lang/rust/issues/82730>",
3381     };
3382 }
3383
3384 declare_lint! {
3385     /// The `proc_macro_back_compat` lint detects uses of old versions of certain
3386     /// proc-macro crates, which have hardcoded workarounds in the compiler.
3387     ///
3388     /// ### Example
3389     ///
3390     /// ```rust,ignore (needs-dependency)
3391     ///
3392     /// use time_macros_impl::impl_macros;
3393     /// struct Foo;
3394     /// impl_macros!(Foo);
3395     /// ```
3396     ///
3397     /// This will produce:
3398     ///
3399     /// ```text
3400     /// warning: using an old version of `time-macros-impl`
3401     ///   ::: $DIR/group-compat-hack.rs:27:5
3402     ///    |
3403     /// LL |     impl_macros!(Foo);
3404     ///    |     ------------------ in this macro invocation
3405     ///    |
3406     ///    = note: `#[warn(proc_macro_back_compat)]` on by default
3407     ///    = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
3408     ///    = note: for more information, see issue #83125 <https://github.com/rust-lang/rust/issues/83125>
3409     ///    = note: the `time-macros-impl` crate will stop compiling in futures version of Rust. Please update to the latest version of the `time` crate to avoid breakage
3410     ///    = note: this warning originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
3411     /// ```
3412     ///
3413     /// ### Explanation
3414     ///
3415     /// Eventually, the backwards-compatibility hacks present in the compiler will be removed,
3416     /// causing older versions of certain crates to stop compiling.
3417     /// This is a [future-incompatible] lint to ease the transition to an error.
3418     /// See [issue #83125] for more details.
3419     ///
3420     /// [issue #83125]: https://github.com/rust-lang/rust/issues/83125
3421     /// [future-incompatible]: ../index.md#future-incompatible-lints
3422     pub PROC_MACRO_BACK_COMPAT,
3423     Deny,
3424     "detects usage of old versions of certain proc-macro crates",
3425     @future_incompatible = FutureIncompatibleInfo {
3426         reference: "issue #83125 <https://github.com/rust-lang/rust/issues/83125>",
3427         reason: FutureIncompatibilityReason::FutureReleaseErrorReportNow,
3428     };
3429 }
3430
3431 declare_lint! {
3432     /// The `rust_2021_incompatible_or_patterns` lint detects usage of old versions of or-patterns.
3433     ///
3434     /// ### Example
3435     ///
3436     /// ```rust,compile_fail
3437     /// #![deny(rust_2021_incompatible_or_patterns)]
3438     ///
3439     /// macro_rules! match_any {
3440     ///     ( $expr:expr , $( $( $pat:pat )|+ => $expr_arm:expr ),+ ) => {
3441     ///         match $expr {
3442     ///             $(
3443     ///                 $( $pat => $expr_arm, )+
3444     ///             )+
3445     ///         }
3446     ///     };
3447     /// }
3448     ///
3449     /// fn main() {
3450     ///     let result: Result<i64, i32> = Err(42);
3451     ///     let int: i64 = match_any!(result, Ok(i) | Err(i) => i.into());
3452     ///     assert_eq!(int, 42);
3453     /// }
3454     /// ```
3455     ///
3456     /// {{produces}}
3457     ///
3458     /// ### Explanation
3459     ///
3460     /// In Rust 2021, the `pat` matcher will match additional patterns, which include the `|` character.
3461     pub RUST_2021_INCOMPATIBLE_OR_PATTERNS,
3462     Allow,
3463     "detects usage of old versions of or-patterns",
3464     @future_incompatible = FutureIncompatibleInfo {
3465         reference: "<https://doc.rust-lang.org/nightly/edition-guide/rust-2021/or-patterns-macro-rules.html>",
3466         reason: FutureIncompatibilityReason::EditionError(Edition::Edition2021),
3467     };
3468 }
3469
3470 declare_lint! {
3471     /// The `rust_2021_prelude_collisions` lint detects the usage of trait methods which are ambiguous
3472     /// with traits added to the prelude in future editions.
3473     ///
3474     /// ### Example
3475     ///
3476     /// ```rust,compile_fail
3477     /// #![deny(rust_2021_prelude_collisions)]
3478     ///
3479     /// trait Foo {
3480     ///     fn try_into(self) -> Result<String, !>;
3481     /// }
3482     ///
3483     /// impl Foo for &str {
3484     ///     fn try_into(self) -> Result<String, !> {
3485     ///         Ok(String::from(self))
3486     ///     }
3487     /// }
3488     ///
3489     /// fn main() {
3490     ///     let x: String = "3".try_into().unwrap();
3491     ///     //                  ^^^^^^^^
3492     ///     // This call to try_into matches both Foo:try_into and TryInto::try_into as
3493     ///     // `TryInto` has been added to the Rust prelude in 2021 edition.
3494     ///     println!("{x}");
3495     /// }
3496     /// ```
3497     ///
3498     /// {{produces}}
3499     ///
3500     /// ### Explanation
3501     ///
3502     /// In Rust 2021, one of the important introductions is the [prelude changes], which add
3503     /// `TryFrom`, `TryInto`, and `FromIterator` into the standard library's prelude. Since this
3504     /// results in an ambiguity as to which method/function to call when an existing `try_into`
3505     /// method is called via dot-call syntax or a `try_from`/`from_iter` associated function
3506     /// is called directly on a type.
3507     ///
3508     /// [prelude changes]: https://blog.rust-lang.org/inside-rust/2021/03/04/planning-rust-2021.html#prelude-changes
3509     pub RUST_2021_PRELUDE_COLLISIONS,
3510     Allow,
3511     "detects the usage of trait methods which are ambiguous with traits added to the \
3512         prelude in future editions",
3513     @future_incompatible = FutureIncompatibleInfo {
3514         reference: "<https://doc.rust-lang.org/nightly/edition-guide/rust-2021/prelude.html>",
3515         reason: FutureIncompatibilityReason::EditionError(Edition::Edition2021),
3516     };
3517 }
3518
3519 declare_lint! {
3520     /// The `rust_2021_prefixes_incompatible_syntax` lint detects identifiers that will be parsed as a
3521     /// prefix instead in Rust 2021.
3522     ///
3523     /// ### Example
3524     ///
3525     /// ```rust,edition2018,compile_fail
3526     /// #![deny(rust_2021_prefixes_incompatible_syntax)]
3527     ///
3528     /// macro_rules! m {
3529     ///     (z $x:expr) => ();
3530     /// }
3531     ///
3532     /// m!(z"hey");
3533     /// ```
3534     ///
3535     /// {{produces}}
3536     ///
3537     /// ### Explanation
3538     ///
3539     /// In Rust 2015 and 2018, `z"hey"` is two tokens: the identifier `z`
3540     /// followed by the string literal `"hey"`. In Rust 2021, the `z` is
3541     /// considered a prefix for `"hey"`.
3542     ///
3543     /// This lint suggests to add whitespace between the `z` and `"hey"` tokens
3544     /// to keep them separated in Rust 2021.
3545     // Allow this lint -- rustdoc doesn't yet support threading edition into this lint's parser.
3546     #[allow(rustdoc::invalid_rust_codeblocks)]
3547     pub RUST_2021_PREFIXES_INCOMPATIBLE_SYNTAX,
3548     Allow,
3549     "identifiers that will be parsed as a prefix in Rust 2021",
3550     @future_incompatible = FutureIncompatibleInfo {
3551         reference: "<https://doc.rust-lang.org/nightly/edition-guide/rust-2021/reserving-syntax.html>",
3552         reason: FutureIncompatibilityReason::EditionError(Edition::Edition2021),
3553     };
3554     crate_level_only
3555 }
3556
3557 declare_lint! {
3558     /// The `unsupported_calling_conventions` lint is output whenever there is a use of the
3559     /// `stdcall`, `fastcall`, `thiscall`, `vectorcall` calling conventions (or their unwind
3560     /// variants) on targets that cannot meaningfully be supported for the requested target.
3561     ///
3562     /// For example `stdcall` does not make much sense for a x86_64 or, more apparently, powerpc
3563     /// code, because this calling convention was never specified for those targets.
3564     ///
3565     /// Historically MSVC toolchains have fallen back to the regular C calling convention for
3566     /// targets other than x86, but Rust doesn't really see a similar need to introduce a similar
3567     /// hack across many more targets.
3568     ///
3569     /// ### Example
3570     ///
3571     /// ```rust,ignore (needs specific targets)
3572     /// extern "stdcall" fn stdcall() {}
3573     /// ```
3574     ///
3575     /// This will produce:
3576     ///
3577     /// ```text
3578     /// warning: use of calling convention not supported on this target
3579     ///   --> $DIR/unsupported.rs:39:1
3580     ///    |
3581     /// LL | extern "stdcall" fn stdcall() {}
3582     ///    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
3583     ///    |
3584     ///    = note: `#[warn(unsupported_calling_conventions)]` on by default
3585     ///    = warning: this was previously accepted by the compiler but is being phased out;
3586     ///               it will become a hard error in a future release!
3587     ///    = note: for more information, see issue ...
3588     /// ```
3589     ///
3590     /// ### Explanation
3591     ///
3592     /// On most of the targets the behaviour of `stdcall` and similar calling conventions is not
3593     /// defined at all, but was previously accepted due to a bug in the implementation of the
3594     /// compiler.
3595     pub UNSUPPORTED_CALLING_CONVENTIONS,
3596     Warn,
3597     "use of unsupported calling convention",
3598     @future_incompatible = FutureIncompatibleInfo {
3599         reference: "issue #87678 <https://github.com/rust-lang/rust/issues/87678>",
3600     };
3601 }
3602
3603 declare_lint! {
3604     /// The `break_with_label_and_loop` lint detects labeled `break` expressions with
3605     /// an unlabeled loop as their value expression.
3606     ///
3607     /// ### Example
3608     ///
3609     /// ```rust
3610     /// 'label: loop {
3611     ///     break 'label loop { break 42; };
3612     /// };
3613     /// ```
3614     ///
3615     /// {{produces}}
3616     ///
3617     /// ### Explanation
3618     ///
3619     /// In Rust, loops can have a label, and `break` expressions can refer to that label to
3620     /// break out of specific loops (and not necessarily the innermost one). `break` expressions
3621     /// can also carry a value expression, which can be another loop. A labeled `break` with an
3622     /// unlabeled loop as its value expression is easy to confuse with an unlabeled break with
3623     /// a labeled loop and is thus discouraged (but allowed for compatibility); use parentheses
3624     /// around the loop expression to silence this warning. Unlabeled `break` expressions with
3625     /// labeled loops yield a hard error, which can also be silenced by wrapping the expression
3626     /// in parentheses.
3627     pub BREAK_WITH_LABEL_AND_LOOP,
3628     Warn,
3629     "`break` expression with label and unlabeled loop as value expression"
3630 }
3631
3632 declare_lint! {
3633     /// The `non_exhaustive_omitted_patterns` lint detects when a wildcard (`_` or `..`) in a
3634     /// pattern for a `#[non_exhaustive]` struct or enum is reachable.
3635     ///
3636     /// ### Example
3637     ///
3638     /// ```rust,ignore (needs separate crate)
3639     /// // crate A
3640     /// #[non_exhaustive]
3641     /// pub enum Bar {
3642     ///     A,
3643     ///     B, // added variant in non breaking change
3644     /// }
3645     ///
3646     /// // in crate B
3647     /// #![feature(non_exhaustive_omitted_patterns_lint)]
3648     ///
3649     /// match Bar::A {
3650     ///     Bar::A => {},
3651     ///     #[warn(non_exhaustive_omitted_patterns)]
3652     ///     _ => {},
3653     /// }
3654     /// ```
3655     ///
3656     /// This will produce:
3657     ///
3658     /// ```text
3659     /// warning: reachable patterns not covered of non exhaustive enum
3660     ///    --> $DIR/reachable-patterns.rs:70:9
3661     ///    |
3662     /// LL |         _ => {}
3663     ///    |         ^ pattern `B` not covered
3664     ///    |
3665     ///  note: the lint level is defined here
3666     ///   --> $DIR/reachable-patterns.rs:69:16
3667     ///    |
3668     /// LL |         #[warn(non_exhaustive_omitted_patterns)]
3669     ///    |                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
3670     ///    = help: ensure that all possible cases are being handled by adding the suggested match arms
3671     ///    = note: the matched value is of type `Bar` and the `non_exhaustive_omitted_patterns` attribute was found
3672     /// ```
3673     ///
3674     /// ### Explanation
3675     ///
3676     /// Structs and enums tagged with `#[non_exhaustive]` force the user to add a
3677     /// (potentially redundant) wildcard when pattern-matching, to allow for future
3678     /// addition of fields or variants. The `non_exhaustive_omitted_patterns` lint
3679     /// detects when such a wildcard happens to actually catch some fields/variants.
3680     /// In other words, when the match without the wildcard would not be exhaustive.
3681     /// This lets the user be informed if new fields/variants were added.
3682     pub NON_EXHAUSTIVE_OMITTED_PATTERNS,
3683     Allow,
3684     "detect when patterns of types marked `non_exhaustive` are missed",
3685     @feature_gate = sym::non_exhaustive_omitted_patterns_lint;
3686 }
3687
3688 declare_lint! {
3689     /// The `text_direction_codepoint_in_comment` lint detects Unicode codepoints in comments that
3690     /// change the visual representation of text on screen in a way that does not correspond to
3691     /// their on memory representation.
3692     ///
3693     /// ### Example
3694     ///
3695     /// ```rust,compile_fail
3696     /// #![deny(text_direction_codepoint_in_comment)]
3697     /// fn main() {
3698     ///     println!("{:?}"); // '‮');
3699     /// }
3700     /// ```
3701     ///
3702     /// {{produces}}
3703     ///
3704     /// ### Explanation
3705     ///
3706     /// Unicode allows changing the visual flow of text on screen in order to support scripts that
3707     /// are written right-to-left, but a specially crafted comment can make code that will be
3708     /// compiled appear to be part of a comment, depending on the software used to read the code.
3709     /// To avoid potential problems or confusion, such as in CVE-2021-42574, by default we deny
3710     /// their use.
3711     pub TEXT_DIRECTION_CODEPOINT_IN_COMMENT,
3712     Deny,
3713     "invisible directionality-changing codepoints in comment"
3714 }
3715
3716 declare_lint! {
3717     /// The `deref_into_dyn_supertrait` lint is output whenever there is a use of the
3718     /// `Deref` implementation with a `dyn SuperTrait` type as `Output`.
3719     ///
3720     /// These implementations will become shadowed when the `trait_upcasting` feature is stabilized.
3721     /// The `deref` functions will no longer be called implicitly, so there might be behavior change.
3722     ///
3723     /// ### Example
3724     ///
3725     /// ```rust,compile_fail
3726     /// #![deny(deref_into_dyn_supertrait)]
3727     /// #![allow(dead_code)]
3728     ///
3729     /// use core::ops::Deref;
3730     ///
3731     /// trait A {}
3732     /// trait B: A {}
3733     /// impl<'a> Deref for dyn 'a + B {
3734     ///     type Target = dyn A;
3735     ///     fn deref(&self) -> &Self::Target {
3736     ///         todo!()
3737     ///     }
3738     /// }
3739     ///
3740     /// fn take_a(_: &dyn A) { }
3741     ///
3742     /// fn take_b(b: &dyn B) {
3743     ///     take_a(b);
3744     /// }
3745     /// ```
3746     ///
3747     /// {{produces}}
3748     ///
3749     /// ### Explanation
3750     ///
3751     /// The dyn upcasting coercion feature adds new coercion rules, taking priority
3752     /// over certain other coercion rules, which will cause some behavior change.
3753     pub DEREF_INTO_DYN_SUPERTRAIT,
3754     Warn,
3755     "`Deref` implementation usage with a supertrait trait object for output might be shadowed in the future",
3756     @future_incompatible = FutureIncompatibleInfo {
3757         reference: "issue #89460 <https://github.com/rust-lang/rust/issues/89460>",
3758     };
3759 }
3760
3761 declare_lint! {
3762     /// The `duplicate_macro_attributes` lint detects when a `#[test]`-like built-in macro
3763     /// attribute is duplicated on an item. This lint may trigger on `bench`, `cfg_eval`, `test`
3764     /// and `test_case`.
3765     ///
3766     /// ### Example
3767     ///
3768     /// ```rust,ignore (needs --test)
3769     /// #[test]
3770     /// #[test]
3771     /// fn foo() {}
3772     /// ```
3773     ///
3774     /// This will produce:
3775     ///
3776     /// ```text
3777     /// warning: duplicated attribute
3778     ///  --> src/lib.rs:2:1
3779     ///   |
3780     /// 2 | #[test]
3781     ///   | ^^^^^^^
3782     ///   |
3783     ///   = note: `#[warn(duplicate_macro_attributes)]` on by default
3784     /// ```
3785     ///
3786     /// ### Explanation
3787     ///
3788     /// A duplicated attribute may erroneously originate from a copy-paste and the effect of it
3789     /// being duplicated may not be obvious or desirable.
3790     ///
3791     /// For instance, doubling the `#[test]` attributes registers the test to be run twice with no
3792     /// change to its environment.
3793     ///
3794     /// [issue #90979]: https://github.com/rust-lang/rust/issues/90979
3795     pub DUPLICATE_MACRO_ATTRIBUTES,
3796     Warn,
3797     "duplicated attribute"
3798 }
3799
3800 declare_lint! {
3801     /// The `suspicious_auto_trait_impls` lint checks for potentially incorrect
3802     /// implementations of auto traits.
3803     ///
3804     /// ### Example
3805     ///
3806     /// ```rust
3807     /// struct Foo<T>(T);
3808     ///
3809     /// unsafe impl<T> Send for Foo<*const T> {}
3810     /// ```
3811     ///
3812     /// {{produces}}
3813     ///
3814     /// ### Explanation
3815     ///
3816     /// A type can implement auto traits, e.g. `Send`, `Sync` and `Unpin`,
3817     /// in two different ways: either by writing an explicit impl or if
3818     /// all fields of the type implement that auto trait.
3819     ///
3820     /// The compiler disables the automatic implementation if an explicit one
3821     /// exists for given type constructor. The exact rules governing this
3822     /// are currently unsound and quite subtle and and will be modified in the future.
3823     /// This change will cause the automatic implementation to be disabled in more
3824     /// cases, potentially breaking some code.
3825     pub SUSPICIOUS_AUTO_TRAIT_IMPLS,
3826     Warn,
3827     "the rules governing auto traits will change in the future",
3828     @future_incompatible = FutureIncompatibleInfo {
3829         reason: FutureIncompatibilityReason::FutureReleaseSemanticsChange,
3830         reference: "issue #93367 <https://github.com/rust-lang/rust/issues/93367>",
3831     };
3832 }
3833
3834 declare_lint! {
3835     /// The `deprecated_where_clause_location` lint detects when a where clause in front of the equals
3836     /// in an associated type.
3837     ///
3838     /// ### Example
3839     ///
3840     /// ```rust
3841     /// #![feature(generic_associated_types)]
3842     ///
3843     /// trait Trait {
3844     ///   type Assoc<'a> where Self: 'a;
3845     /// }
3846     ///
3847     /// impl Trait for () {
3848     ///   type Assoc<'a> where Self: 'a = ();
3849     /// }
3850     /// ```
3851     ///
3852     /// {{produces}}
3853     ///
3854     /// ### Explanation
3855     ///
3856     /// The preferred location for where clauses on associated types in impls
3857     /// is after the type. However, for most of generic associated types development,
3858     /// it was only accepted before the equals. To provide a transition period and
3859     /// further evaluate this change, both are currently accepted. At some point in
3860     /// the future, this may be disallowed at an edition boundary; but, that is
3861     /// undecided currently.
3862     pub DEPRECATED_WHERE_CLAUSE_LOCATION,
3863     Warn,
3864     "deprecated where clause location"
3865 }
3866
3867 declare_lint! {
3868     /// The `test_unstable_lint` lint tests unstable lints and is perma-unstable.
3869     ///
3870     /// ### Example
3871     ///
3872     /// ```
3873     /// #![allow(test_unstable_lint)]
3874     /// ```
3875     ///
3876     /// {{produces}}
3877     ///
3878     /// ### Explanation
3879     ///
3880     /// In order to test the behavior of unstable lints, a permanently-unstable
3881     /// lint is required. This lint can be used to trigger warnings and errors
3882     /// from the compiler related to unstable lints.
3883     pub TEST_UNSTABLE_LINT,
3884     Deny,
3885     "this unstable lint is only for testing",
3886     @feature_gate = sym::test_unstable_lint;
3887 }