1 //! Some lints that are built in to the compiler.
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`.
7 use crate::{declare_lint, declare_lint_pass, FutureIncompatibilityReason};
8 use rustc_span::edition::Edition;
11 /// The `forbidden_lint_groups` lint detects violations of
12 /// `forbid` applied to a lint group. Due to a bug in the compiler,
13 /// these used to be overlooked entirely. They now generate a warning.
18 /// #![forbid(warnings)]
19 /// #![deny(bad_style)]
26 /// ### Recommended fix
28 /// If your crate is using `#![forbid(warnings)]`,
29 /// we recommend that you change to `#![deny(warnings)]`.
33 /// Due to a compiler bug, applying `forbid` to lint groups
34 /// previously had no effect. The bug is now fixed but instead of
35 /// enforcing `forbid` we issue this future-compatibility warning
36 /// to avoid breaking existing crates.
37 pub FORBIDDEN_LINT_GROUPS,
39 "applying forbid to lint-groups",
40 @future_incompatible = FutureIncompatibleInfo {
41 reference: "issue #81670 <https://github.com/rust-lang/rust/issues/81670>",
46 /// The `ill_formed_attribute_input` lint detects ill-formed attribute
47 /// inputs that were previously accepted and used in practice.
51 /// ```rust,compile_fail
52 /// #[inline = "this is not valid"]
60 /// Previously, inputs for many built-in attributes weren't validated and
61 /// nonsensical attribute inputs were accepted. After validation was
62 /// added, it was determined that some existing projects made use of these
63 /// invalid forms. This is a [future-incompatible] lint to transition this
64 /// to a hard error in the future. See [issue #57571] for more details.
66 /// Check the [attribute reference] for details on the valid inputs for
69 /// [issue #57571]: https://github.com/rust-lang/rust/issues/57571
70 /// [attribute reference]: https://doc.rust-lang.org/nightly/reference/attributes.html
71 /// [future-incompatible]: ../index.md#future-incompatible-lints
72 pub ILL_FORMED_ATTRIBUTE_INPUT,
74 "ill-formed attribute inputs that were previously accepted and used in practice",
75 @future_incompatible = FutureIncompatibleInfo {
76 reference: "issue #57571 <https://github.com/rust-lang/rust/issues/57571>",
82 /// The `conflicting_repr_hints` lint detects [`repr` attributes] with
83 /// conflicting hints.
85 /// [`repr` attributes]: https://doc.rust-lang.org/reference/type-layout.html#representations
89 /// ```rust,compile_fail
100 /// The compiler incorrectly accepted these conflicting representations in
101 /// the past. This is a [future-incompatible] lint to transition this to a
102 /// hard error in the future. See [issue #68585] for more details.
104 /// To correct the issue, remove one of the conflicting hints.
106 /// [issue #68585]: https://github.com/rust-lang/rust/issues/68585
107 /// [future-incompatible]: ../index.md#future-incompatible-lints
108 pub CONFLICTING_REPR_HINTS,
110 "conflicts between `#[repr(..)]` hints that were previously accepted and used in practice",
111 @future_incompatible = FutureIncompatibleInfo {
112 reference: "issue #68585 <https://github.com/rust-lang/rust/issues/68585>",
117 /// The `meta_variable_misuse` lint detects possible meta-variable misuse
118 /// in macro definitions.
122 /// ```rust,compile_fail
123 /// #![deny(meta_variable_misuse)]
125 /// macro_rules! foo {
127 /// ($( $i:ident = $($j:ident),+ );*) => { $( $( $i = $k; )+ )* };
139 /// There are quite a few different ways a [`macro_rules`] macro can be
140 /// improperly defined. Many of these errors were previously only detected
141 /// when the macro was expanded or not at all. This lint is an attempt to
142 /// catch some of these problems when the macro is *defined*.
144 /// This lint is "allow" by default because it may have false positives
145 /// and other issues. See [issue #61053] for more details.
147 /// [`macro_rules`]: https://doc.rust-lang.org/reference/macros-by-example.html
148 /// [issue #61053]: https://github.com/rust-lang/rust/issues/61053
149 pub META_VARIABLE_MISUSE,
151 "possible meta-variable misuse at macro definition"
155 /// The `incomplete_include` lint detects the use of the [`include!`]
156 /// macro with a file that contains more than one expression.
158 /// [`include!`]: https://doc.rust-lang.org/std/macro.include.html
162 /// ```rust,ignore (needs separate file)
164 /// include!("foo.txt");
168 /// where the file `foo.txt` contains:
177 /// error: include macro expected single expression in source
180 /// 1 | println!("1");
183 /// = note: `#[deny(incomplete_include)]` on by default
188 /// The [`include!`] macro is currently only intended to be used to
189 /// include a single [expression] or multiple [items]. Historically it
190 /// would ignore any contents after the first expression, but that can be
191 /// confusing. In the example above, the `println!` expression ends just
192 /// before the semicolon, making the semicolon "extra" information that is
193 /// ignored. Perhaps even more surprising, if the included file had
194 /// multiple print statements, the subsequent ones would be ignored!
196 /// One workaround is to place the contents in braces to create a [block
197 /// expression]. Also consider alternatives, like using functions to
198 /// encapsulate the expressions, or use [proc-macros].
200 /// This is a lint instead of a hard error because existing projects were
201 /// found to hit this error. To be cautious, it is a lint for now. The
202 /// future semantics of the `include!` macro are also uncertain, see
205 /// [items]: https://doc.rust-lang.org/reference/items.html
206 /// [expression]: https://doc.rust-lang.org/reference/expressions.html
207 /// [block expression]: https://doc.rust-lang.org/reference/expressions/block-expr.html
208 /// [proc-macros]: https://doc.rust-lang.org/reference/procedural-macros.html
209 /// [issue #35560]: https://github.com/rust-lang/rust/issues/35560
210 pub INCOMPLETE_INCLUDE,
212 "trailing content in included file"
216 /// The `arithmetic_overflow` lint detects that an arithmetic operation
219 /// [overflow]: https://doc.rust-lang.org/reference/expressions/operator-expr.html#overflow
223 /// ```rust,compile_fail
231 /// It is very likely a mistake to perform an arithmetic operation that
232 /// overflows its value. If the compiler is able to detect these kinds of
233 /// overflows at compile-time, it will trigger this lint. Consider
234 /// adjusting the expression to avoid overflow, or use a data type that
235 /// will not overflow.
236 pub ARITHMETIC_OVERFLOW,
238 "arithmetic operation overflows"
242 /// The `unconditional_panic` lint detects an operation that will cause a
243 /// panic at runtime.
247 /// ```rust,compile_fail
248 /// # #![allow(unused)]
256 /// This lint detects code that is very likely incorrect because it will
257 /// always panic, such as division by zero and out-of-bounds array
258 /// accesses. Consider adjusting your code if this is a bug, or using the
259 /// `panic!` or `unreachable!` macro instead in case the panic is intended.
260 pub UNCONDITIONAL_PANIC,
262 "operation will cause a panic at runtime"
266 /// The `const_err` lint detects an erroneous expression while doing
267 /// constant evaluation.
271 /// ```rust,compile_fail
272 /// #![allow(unconditional_panic)]
273 /// const C: i32 = 1/0;
280 /// This lint detects constants that fail to evaluate. Allowing the lint will accept the
281 /// constant declaration, but any use of this constant will still lead to a hard error. This is
282 /// a future incompatibility lint; the plan is to eventually entirely forbid even declaring
283 /// constants that cannot be evaluated. See [issue #71800] for more details.
285 /// [issue #71800]: https://github.com/rust-lang/rust/issues/71800
288 "constant evaluation encountered erroneous expression",
289 @future_incompatible = FutureIncompatibleInfo {
290 reference: "issue #71800 <https://github.com/rust-lang/rust/issues/71800>",
292 report_in_external_macro
296 /// The `unused_imports` lint detects imports that are never used.
301 /// use std::collections::HashMap;
308 /// Unused imports may signal a mistake or unfinished code, and clutter
309 /// the code, and should be removed. If you intended to re-export the item
310 /// to make it available outside of the module, add a visibility modifier
314 "imports that are never used"
318 /// The `must_not_suspend` lint guards against values that shouldn't be held across suspend points
324 /// #![feature(must_not_suspend)]
326 /// #[must_not_suspend]
327 /// struct SyncThing {}
329 /// async fn yield_now() {}
331 /// pub async fn uhoh() {
332 /// let guard = SyncThing {};
333 /// yield_now().await;
341 /// The `must_not_suspend` lint detects values that are marked with the `#[must_not_suspend]`
342 /// attribute being held across suspend points. A "suspend" point is usually a `.await` in an async
345 /// This attribute can be used to mark values that are semantically incorrect across suspends
346 /// (like certain types of timers), values that have async alternatives, and values that
347 /// regularly cause problems with the `Send`-ness of async fn's returned futures (like
350 pub MUST_NOT_SUSPEND,
352 "use of a `#[must_not_suspend]` value across a yield point",
356 /// The `unused_extern_crates` lint guards against `extern crate` items
357 /// that are never used.
361 /// ```rust,compile_fail
362 /// #![deny(unused_extern_crates)]
363 /// extern crate proc_macro;
370 /// `extern crate` items that are unused have no effect and should be
371 /// removed. Note that there are some cases where specifying an `extern
372 /// crate` is desired for the side effect of ensuring the given crate is
373 /// linked, even though it is not otherwise directly referenced. The lint
374 /// can be silenced by aliasing the crate to an underscore, such as
375 /// `extern crate foo as _`. Also note that it is no longer idiomatic to
376 /// use `extern crate` in the [2018 edition], as extern crates are now
377 /// automatically added in scope.
379 /// This lint is "allow" by default because it can be noisy, and produce
380 /// false-positives. If a dependency is being removed from a project, it
381 /// is recommended to remove it from the build configuration (such as
382 /// `Cargo.toml`) to ensure stale build entries aren't left behind.
384 /// [2018 edition]: https://doc.rust-lang.org/edition-guide/rust-2018/module-system/path-clarity.html#no-more-extern-crate
385 pub UNUSED_EXTERN_CRATES,
387 "extern crates that are never used"
391 /// The `unused_crate_dependencies` lint detects crate dependencies that
396 /// ```rust,ignore (needs extern crate)
397 /// #![deny(unused_crate_dependencies)]
400 /// This will produce:
403 /// error: external crate `regex` unused in `lint_example`: remove the dependency or add `use regex as _;`
405 /// note: the lint level is defined here
406 /// --> src/lib.rs:1:9
408 /// 1 | #![deny(unused_crate_dependencies)]
409 /// | ^^^^^^^^^^^^^^^^^^^^^^^^^
414 /// After removing the code that uses a dependency, this usually also
415 /// requires removing the dependency from the build configuration.
416 /// However, sometimes that step can be missed, which leads to time wasted
417 /// building dependencies that are no longer used. This lint can be
418 /// enabled to detect dependencies that are never used (more specifically,
419 /// any dependency passed with the `--extern` command-line flag that is
420 /// never referenced via [`use`], [`extern crate`], or in any [path]).
422 /// This lint is "allow" by default because it can provide false positives
423 /// depending on how the build system is configured. For example, when
424 /// using Cargo, a "package" consists of multiple crates (such as a
425 /// library and a binary), but the dependencies are defined for the
426 /// package as a whole. If there is a dependency that is only used in the
427 /// binary, but not the library, then the lint will be incorrectly issued
430 /// [path]: https://doc.rust-lang.org/reference/paths.html
431 /// [`use`]: https://doc.rust-lang.org/reference/items/use-declarations.html
432 /// [`extern crate`]: https://doc.rust-lang.org/reference/items/extern-crates.html
433 pub UNUSED_CRATE_DEPENDENCIES,
435 "crate dependencies that are never used",
440 /// The `unused_qualifications` lint detects unnecessarily qualified
445 /// ```rust,compile_fail
446 /// #![deny(unused_qualifications)]
461 /// If an item from another module is already brought into scope, then
462 /// there is no need to qualify it in this case. You can call `bar()`
463 /// directly, without the `foo::`.
465 /// This lint is "allow" by default because it is somewhat pedantic, and
466 /// doesn't indicate an actual problem, but rather a stylistic choice, and
467 /// can be noisy when refactoring or moving around code.
468 pub UNUSED_QUALIFICATIONS,
470 "detects unnecessarily qualified names"
474 /// The `unknown_lints` lint detects unrecognized lint attribute.
479 /// #![allow(not_a_real_lint)]
486 /// It is usually a mistake to specify a lint that does not exist. Check
487 /// the spelling, and check the lint listing for the correct name. Also
488 /// consider if you are using an old version of the compiler, and the lint
489 /// is only available in a newer version.
492 "unrecognized lint attribute"
496 /// The `unused_variables` lint detects variables which are not used in
509 /// Unused variables may signal a mistake or unfinished code. To silence
510 /// the warning for the individual variable, prefix it with an underscore
512 pub UNUSED_VARIABLES,
514 "detect variables which are not used in any way"
518 /// The `unused_assignments` lint detects assignments that will never be read.
531 /// Unused assignments may signal a mistake or unfinished code. If the
532 /// variable is never used after being assigned, then the assignment can
533 /// be removed. Variables with an underscore prefix such as `_x` will not
534 /// trigger this lint.
535 pub UNUSED_ASSIGNMENTS,
537 "detect assignments that will never be read"
541 /// The `dead_code` lint detects unused, unexported items.
553 /// Dead code may signal a mistake or unfinished code. To silence the
554 /// warning for individual items, prefix the name with an underscore such
555 /// as `_foo`. If it was intended to expose the item outside of the crate,
556 /// consider adding a visibility modifier like `pub`. Otherwise consider
557 /// removing the unused code.
560 "detect unused, unexported items"
564 /// The `unused_attributes` lint detects attributes that were not used by
577 /// Unused [attributes] may indicate the attribute is placed in the wrong
578 /// position. Consider removing it, or placing it in the correct position.
579 /// Also consider if you intended to use an _inner attribute_ (with a `!`
580 /// such as `#![allow(unused)]`) which applies to the item the attribute
581 /// is within, or an _outer attribute_ (without a `!` such as
582 /// `#[allow(unused)]`) which applies to the item *following* the
585 /// [attributes]: https://doc.rust-lang.org/reference/attributes.html
586 pub UNUSED_ATTRIBUTES,
588 "detects attributes that were not used by the compiler"
592 /// The `unreachable_code` lint detects unreachable code paths.
597 /// panic!("we never go past here!");
606 /// Unreachable code may signal a mistake or unfinished code. If the code
607 /// is no longer in use, consider removing it.
608 pub UNREACHABLE_CODE,
610 "detects unreachable code paths",
611 report_in_external_macro
615 /// The `unreachable_patterns` lint detects unreachable patterns.
631 /// This usually indicates a mistake in how the patterns are specified or
632 /// ordered. In this example, the `y` pattern will always match, so the
633 /// five is impossible to reach. Remember, match arms match in order, you
634 /// probably wanted to put the `5` case above the `y` case.
635 pub UNREACHABLE_PATTERNS,
637 "detects unreachable patterns"
641 /// The `overlapping_range_endpoints` lint detects `match` arms that have [range patterns] that
642 /// overlap on their endpoints.
644 /// [range patterns]: https://doc.rust-lang.org/nightly/reference/patterns.html#range-patterns
651 /// 0..=100 => { println!("small"); }
652 /// 100..=255 => { println!("large"); }
660 /// It is likely a mistake to have range patterns in a match expression that overlap in this
661 /// way. Check that the beginning and end values are what you expect, and keep in mind that
662 /// with `..=` the left and right bounds are inclusive.
663 pub OVERLAPPING_RANGE_ENDPOINTS,
665 "detects range patterns with overlapping endpoints"
669 /// The `bindings_with_variant_name` lint detects pattern bindings with
670 /// the same name as one of the matched variants.
680 /// pub fn foo(x: Enum) {
692 /// It is usually a mistake to specify an enum variant name as an
693 /// [identifier pattern]. In the example above, the `match` arms are
694 /// specifying a variable name to bind the value of `x` to. The second arm
695 /// is ignored because the first one matches *all* values. The likely
696 /// intent is that the arm was intended to match on the enum variant.
698 /// Two possible solutions are:
700 /// * Specify the enum variant using a [path pattern], such as
702 /// * Bring the enum variants into local scope, such as adding `use
703 /// Enum::*;` to the beginning of the `foo` function in the example
706 /// [identifier pattern]: https://doc.rust-lang.org/reference/patterns.html#identifier-patterns
707 /// [path pattern]: https://doc.rust-lang.org/reference/patterns.html#path-patterns
708 pub BINDINGS_WITH_VARIANT_NAME,
710 "detects pattern bindings with the same name as one of the matched variants"
714 /// The `unused_macros` lint detects macros that were not used.
719 /// macro_rules! unused {
731 /// Unused macros may signal a mistake or unfinished code. To silence the
732 /// warning for the individual macro, prefix the name with an underscore
733 /// such as `_my_macro`. If you intended to export the macro to make it
734 /// available outside of the crate, use the [`macro_export` attribute].
736 /// [`macro_export` attribute]: https://doc.rust-lang.org/reference/macros-by-example.html#path-based-scope
739 "detects macros that were not used"
743 /// The `warnings` lint allows you to change the level of other
744 /// lints which produce warnings.
749 /// #![deny(warnings)]
757 /// The `warnings` lint is a bit special; by changing its level, you
758 /// change every other warning that would produce a warning to whatever
759 /// value you'd like. As such, you won't ever trigger this lint in your
763 "mass-change the level for lints which produce warnings"
767 /// The `unused_features` lint detects unused or unknown features found in
768 /// crate-level [`feature` attributes].
770 /// [`feature` attributes]: https://doc.rust-lang.org/nightly/unstable-book/
772 /// Note: This lint is currently not functional, see [issue #44232] for
775 /// [issue #44232]: https://github.com/rust-lang/rust/issues/44232
778 "unused features found in crate-level `#[feature]` directives"
782 /// The `stable_features` lint detects a [`feature` attribute] that
783 /// has since been made stable.
785 /// [`feature` attribute]: https://doc.rust-lang.org/nightly/unstable-book/
790 /// #![feature(test_accepted_feature)]
798 /// When a feature is stabilized, it is no longer necessary to include a
799 /// `#![feature]` attribute for it. To fix, simply remove the
800 /// `#![feature]` attribute.
803 "stable features found in `#[feature]` directive"
807 /// The `unknown_crate_types` lint detects an unknown crate type found in
808 /// a [`crate_type` attribute].
812 /// ```rust,compile_fail
813 /// #![crate_type="lol"]
821 /// An unknown value give to the `crate_type` attribute is almost
822 /// certainly a mistake.
824 /// [`crate_type` attribute]: https://doc.rust-lang.org/reference/linkage.html
825 pub UNKNOWN_CRATE_TYPES,
827 "unknown crate type found in `#[crate_type]` directive",
832 /// The `trivial_casts` lint detects trivial casts which could be replaced
833 /// with coercion, which may require [type ascription] or a temporary
838 /// ```rust,compile_fail
839 /// #![deny(trivial_casts)]
840 /// let x: &u32 = &42;
841 /// let y = x as *const u32;
848 /// A trivial cast is a cast `e as T` where `e` has type `U` and `U` is a
849 /// subtype of `T`. This type of cast is usually unnecessary, as it can be
850 /// usually be inferred.
852 /// This lint is "allow" by default because there are situations, such as
853 /// with FFI interfaces or complex type aliases, where it triggers
854 /// incorrectly, or in situations where it will be more difficult to
855 /// clearly express the intent. It may be possible that this will become a
856 /// warning in the future, possibly with [type ascription] providing a
857 /// convenient way to work around the current issues. See [RFC 401] for
858 /// historical context.
860 /// [type ascription]: https://github.com/rust-lang/rust/issues/23416
861 /// [RFC 401]: https://github.com/rust-lang/rfcs/blob/master/text/0401-coercions.md
864 "detects trivial casts which could be removed"
868 /// The `trivial_numeric_casts` lint detects trivial numeric casts of types
869 /// which could be removed.
873 /// ```rust,compile_fail
874 /// #![deny(trivial_numeric_casts)]
875 /// let x = 42_i32 as i32;
882 /// A trivial numeric cast is a cast of a numeric type to the same numeric
883 /// type. This type of cast is usually unnecessary.
885 /// This lint is "allow" by default because there are situations, such as
886 /// with FFI interfaces or complex type aliases, where it triggers
887 /// incorrectly, or in situations where it will be more difficult to
888 /// clearly express the intent. It may be possible that this will become a
889 /// warning in the future, possibly with [type ascription] providing a
890 /// convenient way to work around the current issues. See [RFC 401] for
891 /// historical context.
893 /// [type ascription]: https://github.com/rust-lang/rust/issues/23416
894 /// [RFC 401]: https://github.com/rust-lang/rfcs/blob/master/text/0401-coercions.md
895 pub TRIVIAL_NUMERIC_CASTS,
897 "detects trivial casts of numeric types which could be removed"
901 /// The `private_in_public` lint detects private items in public
902 /// interfaces not caught by the old implementation.
907 /// # #![allow(unused)]
912 /// impl super::SemiPriv {
913 /// pub fn f(_: Priv) {}
923 /// The visibility rules are intended to prevent exposing private items in
924 /// public interfaces. This is a [future-incompatible] lint to transition
925 /// this to a hard error in the future. See [issue #34537] for more
928 /// [issue #34537]: https://github.com/rust-lang/rust/issues/34537
929 /// [future-incompatible]: ../index.md#future-incompatible-lints
930 pub PRIVATE_IN_PUBLIC,
932 "detect private items in public interfaces not caught by the old implementation",
933 @future_incompatible = FutureIncompatibleInfo {
934 reference: "issue #34537 <https://github.com/rust-lang/rust/issues/34537>",
939 /// The `exported_private_dependencies` lint detects private dependencies
940 /// that are exposed in a public interface.
944 /// ```rust,ignore (needs-dependency)
945 /// pub fn foo() -> Option<some_private_dependency::Thing> {
950 /// This will produce:
953 /// warning: type `bar::Thing` from private dependency 'bar' in public interface
954 /// --> src/lib.rs:3:1
956 /// 3 | pub fn foo() -> Option<bar::Thing> {
957 /// | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
959 /// = note: `#[warn(exported_private_dependencies)]` on by default
964 /// Dependencies can be marked as "private" to indicate that they are not
965 /// exposed in the public interface of a crate. This can be used by Cargo
966 /// to independently resolve those dependencies because it can assume it
967 /// does not need to unify them with other packages using that same
968 /// dependency. This lint is an indication of a violation of that
971 /// To fix this, avoid exposing the dependency in your public interface.
972 /// Or, switch the dependency to a public dependency.
974 /// Note that support for this is only available on the nightly channel.
975 /// See [RFC 1977] for more details, as well as the [Cargo documentation].
977 /// [RFC 1977]: https://github.com/rust-lang/rfcs/blob/master/text/1977-public-private-dependencies.md
978 /// [Cargo documentation]: https://doc.rust-lang.org/nightly/cargo/reference/unstable.html#public-dependency
979 pub EXPORTED_PRIVATE_DEPENDENCIES,
981 "public interface leaks type from a private dependency"
985 /// The `pub_use_of_private_extern_crate` lint detects a specific
986 /// situation of re-exporting a private `extern crate`.
990 /// ```rust,compile_fail
991 /// extern crate core;
992 /// pub use core as reexported_core;
999 /// A public `use` declaration should not be used to publicly re-export a
1000 /// private `extern crate`. `pub extern crate` should be used instead.
1002 /// This was historically allowed, but is not the intended behavior
1003 /// according to the visibility rules. This is a [future-incompatible]
1004 /// lint to transition this to a hard error in the future. See [issue
1005 /// #34537] for more details.
1007 /// [issue #34537]: https://github.com/rust-lang/rust/issues/34537
1008 /// [future-incompatible]: ../index.md#future-incompatible-lints
1009 pub PUB_USE_OF_PRIVATE_EXTERN_CRATE,
1011 "detect public re-exports of private extern crates",
1012 @future_incompatible = FutureIncompatibleInfo {
1013 reference: "issue #34537 <https://github.com/rust-lang/rust/issues/34537>",
1018 /// The `invalid_type_param_default` lint detects type parameter defaults
1019 /// erroneously allowed in an invalid location.
1023 /// ```rust,compile_fail
1024 /// fn foo<T=i32>(t: T) {}
1031 /// Default type parameters were only intended to be allowed in certain
1032 /// situations, but historically the compiler allowed them everywhere.
1033 /// This is a [future-incompatible] lint to transition this to a hard
1034 /// error in the future. See [issue #36887] for more details.
1036 /// [issue #36887]: https://github.com/rust-lang/rust/issues/36887
1037 /// [future-incompatible]: ../index.md#future-incompatible-lints
1038 pub INVALID_TYPE_PARAM_DEFAULT,
1040 "type parameter default erroneously allowed in invalid location",
1041 @future_incompatible = FutureIncompatibleInfo {
1042 reference: "issue #36887 <https://github.com/rust-lang/rust/issues/36887>",
1047 /// The `renamed_and_removed_lints` lint detects lints that have been
1048 /// renamed or removed.
1053 /// #![deny(raw_pointer_derive)]
1060 /// To fix this, either remove the lint or use the new name. This can help
1061 /// avoid confusion about lints that are no longer valid, and help
1062 /// maintain consistency for renamed lints.
1063 pub RENAMED_AND_REMOVED_LINTS,
1065 "lints that have been renamed or removed"
1069 /// The `unaligned_references` lint detects unaligned references to fields
1070 /// of [packed] structs.
1072 /// [packed]: https://doc.rust-lang.org/reference/type-layout.html#the-alignment-modifiers
1076 /// ```rust,compile_fail
1077 /// #![deny(unaligned_references)]
1080 /// pub struct Foo {
1087 /// let foo = Foo { field1: 0, field2: 0 };
1088 /// let _ = &foo.field1;
1089 /// println!("{}", foo.field1); // An implicit `&` is added here, triggering the lint.
1098 /// Creating a reference to an insufficiently aligned packed field is [undefined behavior] and
1099 /// should be disallowed. Using an `unsafe` block does not change anything about this. Instead,
1100 /// the code should do a copy of the data in the packed field or use raw pointers and unaligned
1101 /// accesses. See [issue #82523] for more information.
1103 /// [undefined behavior]: https://doc.rust-lang.org/reference/behavior-considered-undefined.html
1104 /// [issue #82523]: https://github.com/rust-lang/rust/issues/82523
1105 pub UNALIGNED_REFERENCES,
1107 "detects unaligned references to fields of packed structs",
1108 @future_incompatible = FutureIncompatibleInfo {
1109 reference: "issue #82523 <https://github.com/rust-lang/rust/issues/82523>",
1111 report_in_external_macro
1115 /// The `const_item_mutation` lint detects attempts to mutate a `const`
1121 /// const FOO: [i32; 1] = [0];
1125 /// // This will print "[0]".
1126 /// println!("{:?}", FOO);
1134 /// Trying to directly mutate a `const` item is almost always a mistake.
1135 /// What is happening in the example above is that a temporary copy of the
1136 /// `const` is mutated, but the original `const` is not. Each time you
1137 /// refer to the `const` by name (such as `FOO` in the example above), a
1138 /// separate copy of the value is inlined at that location.
1140 /// This lint checks for writing directly to a field (`FOO.field =
1141 /// some_value`) or array entry (`FOO[0] = val`), or taking a mutable
1142 /// reference to the const item (`&mut FOO`), including through an
1143 /// autoderef (`FOO.some_mut_self_method()`).
1145 /// There are various alternatives depending on what you are trying to
1148 /// * First, always reconsider using mutable globals, as they can be
1149 /// difficult to use correctly, and can make the code more difficult to
1150 /// use or understand.
1151 /// * If you are trying to perform a one-time initialization of a global:
1152 /// * If the value can be computed at compile-time, consider using
1153 /// const-compatible values (see [Constant Evaluation]).
1154 /// * For more complex single-initialization cases, consider using a
1155 /// third-party crate, such as [`lazy_static`] or [`once_cell`].
1156 /// * If you are using the [nightly channel], consider the new
1157 /// [`lazy`] module in the standard library.
1158 /// * If you truly need a mutable global, consider using a [`static`],
1159 /// which has a variety of options:
1160 /// * Simple data types can be directly defined and mutated with an
1161 /// [`atomic`] type.
1162 /// * More complex types can be placed in a synchronization primitive
1163 /// like a [`Mutex`], which can be initialized with one of the options
1165 /// * A [mutable `static`] is a low-level primitive, requiring unsafe.
1166 /// Typically This should be avoided in preference of something
1167 /// higher-level like one of the above.
1169 /// [Constant Evaluation]: https://doc.rust-lang.org/reference/const_eval.html
1170 /// [`static`]: https://doc.rust-lang.org/reference/items/static-items.html
1171 /// [mutable `static`]: https://doc.rust-lang.org/reference/items/static-items.html#mutable-statics
1172 /// [`lazy`]: https://doc.rust-lang.org/nightly/std/lazy/index.html
1173 /// [`lazy_static`]: https://crates.io/crates/lazy_static
1174 /// [`once_cell`]: https://crates.io/crates/once_cell
1175 /// [`atomic`]: https://doc.rust-lang.org/std/sync/atomic/index.html
1176 /// [`Mutex`]: https://doc.rust-lang.org/std/sync/struct.Mutex.html
1177 pub CONST_ITEM_MUTATION,
1179 "detects attempts to mutate a `const` item",
1183 /// The `patterns_in_fns_without_body` lint detects `mut` identifier
1184 /// patterns as a parameter in functions without a body.
1188 /// ```rust,compile_fail
1190 /// fn foo(mut arg: u8);
1198 /// To fix this, remove `mut` from the parameter in the trait definition;
1199 /// it can be used in the implementation. That is, the following is OK:
1203 /// fn foo(arg: u8); // Removed `mut` here
1206 /// impl Trait for i32 {
1207 /// fn foo(mut arg: u8) { // `mut` here is OK
1213 /// Trait definitions can define functions without a body to specify a
1214 /// function that implementors must define. The parameter names in the
1215 /// body-less functions are only allowed to be `_` or an [identifier] for
1216 /// documentation purposes (only the type is relevant). Previous versions
1217 /// of the compiler erroneously allowed [identifier patterns] with the
1218 /// `mut` keyword, but this was not intended to be allowed. This is a
1219 /// [future-incompatible] lint to transition this to a hard error in the
1220 /// future. See [issue #35203] for more details.
1222 /// [identifier]: https://doc.rust-lang.org/reference/identifiers.html
1223 /// [identifier patterns]: https://doc.rust-lang.org/reference/patterns.html#identifier-patterns
1224 /// [issue #35203]: https://github.com/rust-lang/rust/issues/35203
1225 /// [future-incompatible]: ../index.md#future-incompatible-lints
1226 pub PATTERNS_IN_FNS_WITHOUT_BODY,
1228 "patterns in functions without body were erroneously allowed",
1229 @future_incompatible = FutureIncompatibleInfo {
1230 reference: "issue #35203 <https://github.com/rust-lang/rust/issues/35203>",
1235 /// The `missing_fragment_specifier` lint is issued when an unused pattern in a
1236 /// `macro_rules!` macro definition has a meta-variable (e.g. `$e`) that is not
1237 /// followed by a fragment specifier (e.g. `:expr`).
1239 /// This warning can always be fixed by removing the unused pattern in the
1240 /// `macro_rules!` macro definition.
1244 /// ```rust,compile_fail
1245 /// macro_rules! foo {
1259 /// To fix this, remove the unused pattern from the `macro_rules!` macro definition:
1262 /// macro_rules! foo {
1269 pub MISSING_FRAGMENT_SPECIFIER,
1271 "detects missing fragment specifiers in unused `macro_rules!` patterns",
1272 @future_incompatible = FutureIncompatibleInfo {
1273 reference: "issue #40107 <https://github.com/rust-lang/rust/issues/40107>",
1278 /// The `late_bound_lifetime_arguments` lint detects generic lifetime
1279 /// arguments in path segments with late bound lifetime parameters.
1287 /// fn late<'a, 'b>(self, _: &'a u8, _: &'b u8) {}
1291 /// S.late::<'static>(&0, &0);
1299 /// It is not clear how to provide arguments for early-bound lifetime
1300 /// parameters if they are intermixed with late-bound parameters in the
1301 /// same list. For now, providing any explicit arguments will trigger this
1302 /// lint if late-bound parameters are present, so in the future a solution
1303 /// can be adopted without hitting backward compatibility issues. This is
1304 /// a [future-incompatible] lint to transition this to a hard error in the
1305 /// future. See [issue #42868] for more details, along with a description
1306 /// of the difference between early and late-bound parameters.
1308 /// [issue #42868]: https://github.com/rust-lang/rust/issues/42868
1309 /// [future-incompatible]: ../index.md#future-incompatible-lints
1310 pub LATE_BOUND_LIFETIME_ARGUMENTS,
1312 "detects generic lifetime arguments in path segments with late bound lifetime parameters",
1313 @future_incompatible = FutureIncompatibleInfo {
1314 reference: "issue #42868 <https://github.com/rust-lang/rust/issues/42868>",
1319 /// The `order_dependent_trait_objects` lint detects a trait coherency
1320 /// violation that would allow creating two trait impls for the same
1321 /// dynamic trait object involving marker traits.
1325 /// ```rust,compile_fail
1326 /// pub trait Trait {}
1328 /// impl Trait for dyn Send + Sync { }
1329 /// impl Trait for dyn Sync + Send { }
1336 /// A previous bug caused the compiler to interpret traits with different
1337 /// orders (such as `Send + Sync` and `Sync + Send`) as distinct types
1338 /// when they were intended to be treated the same. This allowed code to
1339 /// define separate trait implementations when there should be a coherence
1340 /// error. This is a [future-incompatible] lint to transition this to a
1341 /// hard error in the future. See [issue #56484] for more details.
1343 /// [issue #56484]: https://github.com/rust-lang/rust/issues/56484
1344 /// [future-incompatible]: ../index.md#future-incompatible-lints
1345 pub ORDER_DEPENDENT_TRAIT_OBJECTS,
1347 "trait-object types were treated as different depending on marker-trait order",
1348 @future_incompatible = FutureIncompatibleInfo {
1349 reference: "issue #56484 <https://github.com/rust-lang/rust/issues/56484>",
1354 /// The `coherence_leak_check` lint detects conflicting implementations of
1355 /// a trait that are only distinguished by the old leak-check code.
1360 /// trait SomeTrait { }
1361 /// impl SomeTrait for for<'a> fn(&'a u8) { }
1362 /// impl<'a> SomeTrait for fn(&'a u8) { }
1369 /// In the past, the compiler would accept trait implementations for
1370 /// identical functions that differed only in where the lifetime binder
1371 /// appeared. Due to a change in the borrow checker implementation to fix
1372 /// several bugs, this is no longer allowed. However, since this affects
1373 /// existing code, this is a [future-incompatible] lint to transition this
1374 /// to a hard error in the future.
1376 /// Code relying on this pattern should introduce "[newtypes]",
1377 /// like `struct Foo(for<'a> fn(&'a u8))`.
1379 /// See [issue #56105] for more details.
1381 /// [issue #56105]: https://github.com/rust-lang/rust/issues/56105
1382 /// [newtypes]: https://doc.rust-lang.org/book/ch19-04-advanced-types.html#using-the-newtype-pattern-for-type-safety-and-abstraction
1383 /// [future-incompatible]: ../index.md#future-incompatible-lints
1384 pub COHERENCE_LEAK_CHECK,
1386 "distinct impls distinguished only by the leak-check code",
1387 @future_incompatible = FutureIncompatibleInfo {
1388 reference: "issue #56105 <https://github.com/rust-lang/rust/issues/56105>",
1393 /// The `deprecated` lint detects use of deprecated items.
1410 /// Items may be marked "deprecated" with the [`deprecated` attribute] to
1411 /// indicate that they should no longer be used. Usually the attribute
1412 /// should include a note on what to use instead, or check the
1415 /// [`deprecated` attribute]: https://doc.rust-lang.org/reference/attributes/diagnostics.html#the-deprecated-attribute
1418 "detects use of deprecated items",
1419 report_in_external_macro
1423 /// The `unused_unsafe` lint detects unnecessary use of an `unsafe` block.
1435 /// If nothing within the block requires `unsafe`, then remove the
1436 /// `unsafe` marker because it is not required and may cause confusion.
1439 "unnecessary use of an `unsafe` block"
1443 /// The `unused_mut` lint detects mut variables which don't need to be
1456 /// The preferred style is to only mark variables as `mut` if it is
1460 "detect mut variables which don't need to be mutable"
1464 /// The `unconditional_recursion` lint detects functions that cannot
1465 /// return without calling themselves.
1479 /// It is usually a mistake to have a recursive call that does not have
1480 /// some condition to cause it to terminate. If you really intend to have
1481 /// an infinite loop, using a `loop` expression is recommended.
1482 pub UNCONDITIONAL_RECURSION,
1484 "functions that cannot return without calling themselves"
1488 /// The `single_use_lifetimes` lint detects lifetimes that are only used
1493 /// ```rust,compile_fail
1494 /// #![deny(single_use_lifetimes)]
1496 /// fn foo<'a>(x: &'a u32) {}
1503 /// Specifying an explicit lifetime like `'a` in a function or `impl`
1504 /// should only be used to link together two things. Otherwise, you should
1505 /// just use `'_` to indicate that the lifetime is not linked to anything,
1506 /// or elide the lifetime altogether if possible.
1508 /// This lint is "allow" by default because it was introduced at a time
1509 /// when `'_` and elided lifetimes were first being introduced, and this
1510 /// lint would be too noisy. Also, there are some known false positives
1511 /// that it produces. See [RFC 2115] for historical context, and [issue
1512 /// #44752] for more details.
1514 /// [RFC 2115]: https://github.com/rust-lang/rfcs/blob/master/text/2115-argument-lifetimes.md
1515 /// [issue #44752]: https://github.com/rust-lang/rust/issues/44752
1516 pub SINGLE_USE_LIFETIMES,
1518 "detects lifetime parameters that are only used once"
1522 /// The `unused_lifetimes` lint detects lifetime parameters that are never
1527 /// ```rust,compile_fail
1528 /// #[deny(unused_lifetimes)]
1530 /// pub fn foo<'a>() {}
1537 /// Unused lifetime parameters may signal a mistake or unfinished code.
1538 /// Consider removing the parameter.
1539 pub UNUSED_LIFETIMES,
1541 "detects lifetime parameters that are never used"
1545 /// The `tyvar_behind_raw_pointer` lint detects raw pointer to an
1546 /// inference variable.
1550 /// ```rust,edition2015
1552 /// let data = std::ptr::null();
1553 /// let _ = &data as *const *const ();
1555 /// if data.is_null() {}
1562 /// This kind of inference was previously allowed, but with the future
1563 /// arrival of [arbitrary self types], this can introduce ambiguity. To
1564 /// resolve this, use an explicit type instead of relying on type
1567 /// This is a [future-incompatible] lint to transition this to a hard
1568 /// error in the 2018 edition. See [issue #46906] for more details. This
1569 /// is currently a hard-error on the 2018 edition, and is "warn" by
1570 /// default in the 2015 edition.
1572 /// [arbitrary self types]: https://github.com/rust-lang/rust/issues/44874
1573 /// [issue #46906]: https://github.com/rust-lang/rust/issues/46906
1574 /// [future-incompatible]: ../index.md#future-incompatible-lints
1575 pub TYVAR_BEHIND_RAW_POINTER,
1577 "raw pointer to an inference variable",
1578 @future_incompatible = FutureIncompatibleInfo {
1579 reference: "issue #46906 <https://github.com/rust-lang/rust/issues/46906>",
1580 reason: FutureIncompatibilityReason::EditionError(Edition::Edition2018),
1585 /// The `elided_lifetimes_in_paths` lint detects the use of hidden
1586 /// lifetime parameters.
1590 /// ```rust,compile_fail
1591 /// #![deny(elided_lifetimes_in_paths)]
1592 /// struct Foo<'a> {
1596 /// fn foo(x: &Foo) {
1604 /// Elided lifetime parameters can make it difficult to see at a glance
1605 /// that borrowing is occurring. This lint ensures that lifetime
1606 /// parameters are always explicitly stated, even if it is the `'_`
1607 /// [placeholder lifetime].
1609 /// This lint is "allow" by default because it has some known issues, and
1610 /// may require a significant transition for old code.
1612 /// [placeholder lifetime]: https://doc.rust-lang.org/reference/lifetime-elision.html#lifetime-elision-in-functions
1613 pub ELIDED_LIFETIMES_IN_PATHS,
1615 "hidden lifetime parameters in types are deprecated",
1620 /// The `bare_trait_objects` lint suggests using `dyn Trait` for trait
1625 /// ```rust,edition2018
1628 /// fn takes_trait_object(_: Box<Trait>) {
1636 /// Without the `dyn` indicator, it can be ambiguous or confusing when
1637 /// reading code as to whether or not you are looking at a trait object.
1638 /// The `dyn` keyword makes it explicit, and adds a symmetry to contrast
1639 /// with [`impl Trait`].
1641 /// [`impl Trait`]: https://doc.rust-lang.org/book/ch10-02-traits.html#traits-as-parameters
1642 pub BARE_TRAIT_OBJECTS,
1644 "suggest using `dyn Trait` for trait objects",
1645 @future_incompatible = FutureIncompatibleInfo {
1646 reference: "<https://doc.rust-lang.org/nightly/edition-guide/rust-2021/warnings-promoted-to-error.html>",
1647 reason: FutureIncompatibilityReason::EditionError(Edition::Edition2021),
1652 /// The `absolute_paths_not_starting_with_crate` lint detects fully
1653 /// qualified paths that start with a module name instead of `crate`,
1654 /// `self`, or an extern crate name
1658 /// ```rust,edition2015,compile_fail
1659 /// #![deny(absolute_paths_not_starting_with_crate)]
1674 /// Rust [editions] allow the language to evolve without breaking
1675 /// backwards compatibility. This lint catches code that uses absolute
1676 /// paths in the style of the 2015 edition. In the 2015 edition, absolute
1677 /// paths (those starting with `::`) refer to either the crate root or an
1678 /// external crate. In the 2018 edition it was changed so that they only
1679 /// refer to external crates. The path prefix `crate::` should be used
1680 /// instead to reference items from the crate root.
1682 /// If you switch the compiler from the 2015 to 2018 edition without
1683 /// updating the code, then it will fail to compile if the old style paths
1684 /// are used. You can manually change the paths to use the `crate::`
1685 /// prefix to transition to the 2018 edition.
1687 /// This lint solves the problem automatically. It is "allow" by default
1688 /// because the code is perfectly valid in the 2015 edition. The [`cargo
1689 /// fix`] tool with the `--edition` flag will switch this lint to "warn"
1690 /// and automatically apply the suggested fix from the compiler. This
1691 /// provides a completely automated way to update old code to the 2018
1694 /// [editions]: https://doc.rust-lang.org/edition-guide/
1695 /// [`cargo fix`]: https://doc.rust-lang.org/cargo/commands/cargo-fix.html
1696 pub ABSOLUTE_PATHS_NOT_STARTING_WITH_CRATE,
1698 "fully qualified paths that start with a module name \
1699 instead of `crate`, `self`, or an extern crate name",
1700 @future_incompatible = FutureIncompatibleInfo {
1701 reference: "issue #53130 <https://github.com/rust-lang/rust/issues/53130>",
1702 reason: FutureIncompatibilityReason::EditionError(Edition::Edition2018),
1707 /// The `illegal_floating_point_literal_pattern` lint detects
1708 /// floating-point literals used in patterns.
1725 /// Previous versions of the compiler accepted floating-point literals in
1726 /// patterns, but it was later determined this was a mistake. The
1727 /// semantics of comparing floating-point values may not be clear in a
1728 /// pattern when contrasted with "structural equality". Typically you can
1729 /// work around this by using a [match guard], such as:
1735 /// y if y == 5.0 => {}
1740 /// This is a [future-incompatible] lint to transition this to a hard
1741 /// error in the future. See [issue #41620] for more details.
1743 /// [issue #41620]: https://github.com/rust-lang/rust/issues/41620
1744 /// [match guard]: https://doc.rust-lang.org/reference/expressions/match-expr.html#match-guards
1745 /// [future-incompatible]: ../index.md#future-incompatible-lints
1746 pub ILLEGAL_FLOATING_POINT_LITERAL_PATTERN,
1748 "floating-point literals cannot be used in patterns",
1749 @future_incompatible = FutureIncompatibleInfo {
1750 reference: "issue #41620 <https://github.com/rust-lang/rust/issues/41620>",
1755 /// The `unstable_name_collisions` lint detects that you have used a name
1756 /// that the standard library plans to add in the future.
1761 /// trait MyIterator : Iterator {
1762 /// // is_sorted is an unstable method that already exists on the Iterator trait
1763 /// fn is_sorted(self) -> bool where Self: Sized {true}
1766 /// impl<T: ?Sized> MyIterator for T where T: Iterator { }
1768 /// let x = vec![1, 2, 3];
1769 /// let _ = x.iter().is_sorted();
1776 /// When new methods are added to traits in the standard library, they are
1777 /// usually added in an "unstable" form which is only available on the
1778 /// [nightly channel] with a [`feature` attribute]. If there is any
1779 /// pre-existing code which extends a trait to have a method with the same
1780 /// name, then the names will collide. In the future, when the method is
1781 /// stabilized, this will cause an error due to the ambiguity. This lint
1782 /// is an early-warning to let you know that there may be a collision in
1783 /// the future. This can be avoided by adding type annotations to
1784 /// disambiguate which trait method you intend to call, such as
1785 /// `MyIterator::is_sorted(my_iter)` or renaming or removing the method.
1787 /// [nightly channel]: https://doc.rust-lang.org/book/appendix-07-nightly-rust.html
1788 /// [`feature` attribute]: https://doc.rust-lang.org/nightly/unstable-book/
1789 pub UNSTABLE_NAME_COLLISIONS,
1791 "detects name collision with an existing but unstable method",
1792 @future_incompatible = FutureIncompatibleInfo {
1793 reference: "issue #48919 <https://github.com/rust-lang/rust/issues/48919>",
1794 // Note: this item represents future incompatibility of all unstable functions in the
1795 // standard library, and thus should never be removed or changed to an error.
1800 /// The `irrefutable_let_patterns` lint detects [irrefutable patterns]
1801 /// in [`if let`]s, [`while let`]s, and `if let` guards.
1806 /// if let _ = 123 {
1807 /// println!("always runs!");
1815 /// There usually isn't a reason to have an irrefutable pattern in an
1816 /// `if let` or `while let` statement, because the pattern will always match
1817 /// successfully. A [`let`] or [`loop`] statement will suffice. However,
1818 /// when generating code with a macro, forbidding irrefutable patterns
1819 /// would require awkward workarounds in situations where the macro
1820 /// doesn't know if the pattern is refutable or not. This lint allows
1821 /// macros to accept this form, while alerting for a possibly incorrect
1822 /// use in normal code.
1824 /// See [RFC 2086] for more details.
1826 /// [irrefutable patterns]: https://doc.rust-lang.org/reference/patterns.html#refutability
1827 /// [`if let`]: https://doc.rust-lang.org/reference/expressions/if-expr.html#if-let-expressions
1828 /// [`while let`]: https://doc.rust-lang.org/reference/expressions/loop-expr.html#predicate-pattern-loops
1829 /// [`let`]: https://doc.rust-lang.org/reference/statements.html#let-statements
1830 /// [`loop`]: https://doc.rust-lang.org/reference/expressions/loop-expr.html#infinite-loops
1831 /// [RFC 2086]: https://github.com/rust-lang/rfcs/blob/master/text/2086-allow-if-let-irrefutables.md
1832 pub IRREFUTABLE_LET_PATTERNS,
1834 "detects irrefutable patterns in `if let` and `while let` statements"
1838 /// The `unused_labels` lint detects [labels] that are never used.
1840 /// [labels]: https://doc.rust-lang.org/reference/expressions/loop-expr.html#loop-labels
1845 /// 'unused_label: loop {}
1852 /// Unused labels may signal a mistake or unfinished code. To silence the
1853 /// warning for the individual label, prefix it with an underscore such as
1857 "detects labels that are never used"
1861 /// The `where_clauses_object_safety` lint detects for [object safety] of
1862 /// [where clauses].
1864 /// [object safety]: https://doc.rust-lang.org/reference/items/traits.html#object-safety
1865 /// [where clauses]: https://doc.rust-lang.org/reference/items/generics.html#where-clauses
1872 /// trait X { fn foo(&self) where Self: Trait; }
1874 /// impl X for () { fn foo(&self) {} }
1876 /// impl Trait for dyn X {}
1878 /// // Segfault at opt-level 0, SIGILL otherwise.
1879 /// pub fn main() { <dyn X as X>::foo(&()); }
1886 /// The compiler previously allowed these object-unsafe bounds, which was
1887 /// incorrect. This is a [future-incompatible] lint to transition this to
1888 /// a hard error in the future. See [issue #51443] for more details.
1890 /// [issue #51443]: https://github.com/rust-lang/rust/issues/51443
1891 /// [future-incompatible]: ../index.md#future-incompatible-lints
1892 pub WHERE_CLAUSES_OBJECT_SAFETY,
1894 "checks the object safety of where clauses",
1895 @future_incompatible = FutureIncompatibleInfo {
1896 reference: "issue #51443 <https://github.com/rust-lang/rust/issues/51443>",
1901 /// The `proc_macro_derive_resolution_fallback` lint detects proc macro
1902 /// derives using inaccessible names from parent modules.
1906 /// ```rust,ignore (proc-macro)
1908 /// #![crate_type = "proc-macro"]
1910 /// extern crate proc_macro;
1912 /// use proc_macro::*;
1914 /// #[proc_macro_derive(Foo)]
1915 /// pub fn foo1(a: TokenStream) -> TokenStream {
1917 /// "mod __bar { static mut BAR: Option<Something> = None; }".parse().unwrap()
1921 /// ```rust,ignore (needs-dependency)
1924 /// extern crate foo;
1926 /// struct Something;
1934 /// This will produce:
1937 /// warning: cannot find type `Something` in this scope
1938 /// --> src/main.rs:8:10
1940 /// 8 | #[derive(Foo)]
1941 /// | ^^^ names from parent modules are not accessible without an explicit import
1943 /// = note: `#[warn(proc_macro_derive_resolution_fallback)]` on by default
1944 /// = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
1945 /// = note: for more information, see issue #50504 <https://github.com/rust-lang/rust/issues/50504>
1950 /// If a proc-macro generates a module, the compiler unintentionally
1951 /// allowed items in that module to refer to items in the crate root
1952 /// without importing them. This is a [future-incompatible] lint to
1953 /// transition this to a hard error in the future. See [issue #50504] for
1956 /// [issue #50504]: https://github.com/rust-lang/rust/issues/50504
1957 /// [future-incompatible]: ../index.md#future-incompatible-lints
1958 pub PROC_MACRO_DERIVE_RESOLUTION_FALLBACK,
1960 "detects proc macro derives using inaccessible names from parent modules",
1961 @future_incompatible = FutureIncompatibleInfo {
1962 reference: "issue #83583 <https://github.com/rust-lang/rust/issues/83583>",
1963 reason: FutureIncompatibilityReason::FutureReleaseErrorReportNow,
1968 /// The `macro_use_extern_crate` lint detects the use of the
1969 /// [`macro_use` attribute].
1973 /// ```rust,ignore (needs extern crate)
1974 /// #![deny(macro_use_extern_crate)]
1977 /// extern crate serde_json;
1980 /// let _ = json!{{}};
1984 /// This will produce:
1987 /// error: deprecated `#[macro_use]` attribute used to import macros should be replaced at use sites with a `use` item to import the macro instead
1988 /// --> src/main.rs:3:1
1990 /// 3 | #[macro_use]
1993 /// note: the lint level is defined here
1994 /// --> src/main.rs:1:9
1996 /// 1 | #![deny(macro_use_extern_crate)]
1997 /// | ^^^^^^^^^^^^^^^^^^^^^^
2002 /// The [`macro_use` attribute] on an [`extern crate`] item causes
2003 /// macros in that external crate to be brought into the prelude of the
2004 /// crate, making the macros in scope everywhere. As part of the efforts
2005 /// to simplify handling of dependencies in the [2018 edition], the use of
2006 /// `extern crate` is being phased out. To bring macros from extern crates
2007 /// into scope, it is recommended to use a [`use` import].
2009 /// This lint is "allow" by default because this is a stylistic choice
2010 /// that has not been settled, see [issue #52043] for more information.
2012 /// [`macro_use` attribute]: https://doc.rust-lang.org/reference/macros-by-example.html#the-macro_use-attribute
2013 /// [`use` import]: https://doc.rust-lang.org/reference/items/use-declarations.html
2014 /// [issue #52043]: https://github.com/rust-lang/rust/issues/52043
2015 pub MACRO_USE_EXTERN_CRATE,
2017 "the `#[macro_use]` attribute is now deprecated in favor of using macros \
2018 via the module system"
2022 /// The `macro_expanded_macro_exports_accessed_by_absolute_paths` lint
2023 /// detects macro-expanded [`macro_export`] macros from the current crate
2024 /// that cannot be referred to by absolute paths.
2026 /// [`macro_export`]: https://doc.rust-lang.org/reference/macros-by-example.html#path-based-scope
2030 /// ```rust,compile_fail
2031 /// macro_rules! define_exported {
2034 /// macro_rules! exported {
2040 /// define_exported!();
2043 /// crate::exported!();
2051 /// The intent is that all macros marked with the `#[macro_export]`
2052 /// attribute are made available in the root of the crate. However, when a
2053 /// `macro_rules!` definition is generated by another macro, the macro
2054 /// expansion is unable to uphold this rule. This is a
2055 /// [future-incompatible] lint to transition this to a hard error in the
2056 /// future. See [issue #53495] for more details.
2058 /// [issue #53495]: https://github.com/rust-lang/rust/issues/53495
2059 /// [future-incompatible]: ../index.md#future-incompatible-lints
2060 pub MACRO_EXPANDED_MACRO_EXPORTS_ACCESSED_BY_ABSOLUTE_PATHS,
2062 "macro-expanded `macro_export` macros from the current crate \
2063 cannot be referred to by absolute paths",
2064 @future_incompatible = FutureIncompatibleInfo {
2065 reference: "issue #52234 <https://github.com/rust-lang/rust/issues/52234>",
2071 /// The `explicit_outlives_requirements` lint detects unnecessary
2072 /// lifetime bounds that can be inferred.
2076 /// ```rust,compile_fail
2077 /// # #![allow(unused)]
2078 /// #![deny(explicit_outlives_requirements)]
2080 /// struct SharedRef<'a, T>
2092 /// If a `struct` contains a reference, such as `&'a T`, the compiler
2093 /// requires that `T` outlives the lifetime `'a`. This historically
2094 /// required writing an explicit lifetime bound to indicate this
2095 /// requirement. However, this can be overly explicit, causing clutter and
2096 /// unnecessary complexity. The language was changed to automatically
2097 /// infer the bound if it is not specified. Specifically, if the struct
2098 /// contains a reference, directly or indirectly, to `T` with lifetime
2099 /// `'x`, then it will infer that `T: 'x` is a requirement.
2101 /// This lint is "allow" by default because it can be noisy for existing
2102 /// code that already had these requirements. This is a stylistic choice,
2103 /// as it is still valid to explicitly state the bound. It also has some
2104 /// false positives that can cause confusion.
2106 /// See [RFC 2093] for more details.
2108 /// [RFC 2093]: https://github.com/rust-lang/rfcs/blob/master/text/2093-infer-outlives.md
2109 pub EXPLICIT_OUTLIVES_REQUIREMENTS,
2111 "outlives requirements can be inferred"
2115 /// The `indirect_structural_match` lint detects a `const` in a pattern
2116 /// that manually implements [`PartialEq`] and [`Eq`].
2118 /// [`PartialEq`]: https://doc.rust-lang.org/std/cmp/trait.PartialEq.html
2119 /// [`Eq`]: https://doc.rust-lang.org/std/cmp/trait.Eq.html
2123 /// ```rust,compile_fail
2124 /// #![deny(indirect_structural_match)]
2126 /// struct NoDerive(i32);
2127 /// impl PartialEq for NoDerive { fn eq(&self, _: &Self) -> bool { false } }
2128 /// impl Eq for NoDerive { }
2129 /// #[derive(PartialEq, Eq)]
2130 /// struct WrapParam<T>(T);
2131 /// const WRAP_INDIRECT_PARAM: & &WrapParam<NoDerive> = & &WrapParam(NoDerive(0));
2133 /// match WRAP_INDIRECT_PARAM {
2134 /// WRAP_INDIRECT_PARAM => { }
2144 /// The compiler unintentionally accepted this form in the past. This is a
2145 /// [future-incompatible] lint to transition this to a hard error in the
2146 /// future. See [issue #62411] for a complete description of the problem,
2147 /// and some possible solutions.
2149 /// [issue #62411]: https://github.com/rust-lang/rust/issues/62411
2150 /// [future-incompatible]: ../index.md#future-incompatible-lints
2151 pub INDIRECT_STRUCTURAL_MATCH,
2153 "constant used in pattern contains value of non-structural-match type in a field or a variant",
2154 @future_incompatible = FutureIncompatibleInfo {
2155 reference: "issue #62411 <https://github.com/rust-lang/rust/issues/62411>",
2160 /// The `deprecated_in_future` lint is internal to rustc and should not be
2161 /// used by user code.
2163 /// This lint is only enabled in the standard library. It works with the
2164 /// use of `#[rustc_deprecated]` with a `since` field of a version in the
2165 /// future. This allows something to be marked as deprecated in a future
2166 /// version, and then this lint will ensure that the item is no longer
2167 /// used in the standard library. See the [stability documentation] for
2170 /// [stability documentation]: https://rustc-dev-guide.rust-lang.org/stability.html#rustc_deprecated
2171 pub DEPRECATED_IN_FUTURE,
2173 "detects use of items that will be deprecated in a future version",
2174 report_in_external_macro
2178 /// The `pointer_structural_match` lint detects pointers used in patterns whose behaviour
2179 /// cannot be relied upon across compiler versions and optimization levels.
2183 /// ```rust,compile_fail
2184 /// #![deny(pointer_structural_match)]
2185 /// fn foo(a: usize, b: usize) -> usize { a + b }
2186 /// const FOO: fn(usize, usize) -> usize = foo;
2199 /// Previous versions of Rust allowed function pointers and wide raw pointers in patterns.
2200 /// While these work in many cases as expected by users, it is possible that due to
2201 /// optimizations pointers are "not equal to themselves" or pointers to different functions
2202 /// compare as equal during runtime. This is because LLVM optimizations can deduplicate
2203 /// functions if their bodies are the same, thus also making pointers to these functions point
2204 /// to the same location. Additionally functions may get duplicated if they are instantiated
2205 /// in different crates and not deduplicated again via LTO.
2206 pub POINTER_STRUCTURAL_MATCH,
2208 "pointers are not structural-match",
2209 @future_incompatible = FutureIncompatibleInfo {
2210 reference: "issue #62411 <https://github.com/rust-lang/rust/issues/70861>",
2215 /// The `nontrivial_structural_match` lint detects constants that are used in patterns,
2216 /// whose type is not structural-match and whose initializer body actually uses values
2217 /// that are not structural-match. So `Option<NotStruturalMatch>` is ok if the constant
2222 /// ```rust,compile_fail
2223 /// #![deny(nontrivial_structural_match)]
2225 /// #[derive(Copy, Clone, Debug)]
2226 /// struct NoDerive(u32);
2227 /// impl PartialEq for NoDerive { fn eq(&self, _: &Self) -> bool { false } }
2228 /// impl Eq for NoDerive { }
2230 /// const INDEX: Option<NoDerive> = [None, Some(NoDerive(10))][0];
2231 /// match None { Some(_) => panic!("whoops"), INDEX => dbg!(INDEX), };
2239 /// Previous versions of Rust accepted constants in patterns, even if those constants's types
2240 /// did not have `PartialEq` derived. Thus the compiler falls back to runtime execution of
2241 /// `PartialEq`, which can report that two constants are not equal even if they are
2243 pub NONTRIVIAL_STRUCTURAL_MATCH,
2245 "constant used in pattern of non-structural-match type and the constant's initializer \
2246 expression contains values of non-structural-match types",
2247 @future_incompatible = FutureIncompatibleInfo {
2248 reference: "issue #73448 <https://github.com/rust-lang/rust/issues/73448>",
2253 /// The `ambiguous_associated_items` lint detects ambiguity between
2254 /// [associated items] and [enum variants].
2256 /// [associated items]: https://doc.rust-lang.org/reference/items/associated-items.html
2257 /// [enum variants]: https://doc.rust-lang.org/reference/items/enumerations.html
2261 /// ```rust,compile_fail
2268 /// fn foo() -> Self::V;
2273 /// // `Self::V` is ambiguous because it may refer to the associated type or
2274 /// // the enum variant.
2275 /// fn foo() -> Self::V { 0 }
2283 /// Previous versions of Rust did not allow accessing enum variants
2284 /// through [type aliases]. When this ability was added (see [RFC 2338]), this
2285 /// introduced some situations where it can be ambiguous what a type
2286 /// was referring to.
2288 /// To fix this ambiguity, you should use a [qualified path] to explicitly
2289 /// state which type to use. For example, in the above example the
2290 /// function can be written as `fn f() -> <Self as Tr>::V { 0 }` to
2291 /// specifically refer to the associated type.
2293 /// This is a [future-incompatible] lint to transition this to a hard
2294 /// error in the future. See [issue #57644] for more details.
2296 /// [issue #57644]: https://github.com/rust-lang/rust/issues/57644
2297 /// [type aliases]: https://doc.rust-lang.org/reference/items/type-aliases.html#type-aliases
2298 /// [RFC 2338]: https://github.com/rust-lang/rfcs/blob/master/text/2338-type-alias-enum-variants.md
2299 /// [qualified path]: https://doc.rust-lang.org/reference/paths.html#qualified-paths
2300 /// [future-incompatible]: ../index.md#future-incompatible-lints
2301 pub AMBIGUOUS_ASSOCIATED_ITEMS,
2303 "ambiguous associated items",
2304 @future_incompatible = FutureIncompatibleInfo {
2305 reference: "issue #57644 <https://github.com/rust-lang/rust/issues/57644>",
2310 /// The `mutable_borrow_reservation_conflict` lint detects the reservation
2311 /// of a two-phased borrow that conflicts with other shared borrows.
2316 /// let mut v = vec![0, 1, 2];
2317 /// let shared = &v;
2318 /// v.push(shared.len());
2325 /// This is a [future-incompatible] lint to transition this to a hard error
2326 /// in the future. See [issue #59159] for a complete description of the
2327 /// problem, and some possible solutions.
2329 /// [issue #59159]: https://github.com/rust-lang/rust/issues/59159
2330 /// [future-incompatible]: ../index.md#future-incompatible-lints
2331 pub MUTABLE_BORROW_RESERVATION_CONFLICT,
2333 "reservation of a two-phased borrow conflicts with other shared borrows",
2334 @future_incompatible = FutureIncompatibleInfo {
2335 reference: "issue #59159 <https://github.com/rust-lang/rust/issues/59159>",
2340 /// The `soft_unstable` lint detects unstable features that were
2341 /// unintentionally allowed on stable.
2345 /// ```rust,compile_fail
2347 /// extern crate test;
2350 /// fn name(b: &mut test::Bencher) {
2359 /// The [`bench` attribute] was accidentally allowed to be specified on
2360 /// the [stable release channel]. Turning this to a hard error would have
2361 /// broken some projects. This lint allows those projects to continue to
2362 /// build correctly when [`--cap-lints`] is used, but otherwise signal an
2363 /// error that `#[bench]` should not be used on the stable channel. This
2364 /// is a [future-incompatible] lint to transition this to a hard error in
2365 /// the future. See [issue #64266] for more details.
2367 /// [issue #64266]: https://github.com/rust-lang/rust/issues/64266
2368 /// [`bench` attribute]: https://doc.rust-lang.org/nightly/unstable-book/library-features/test.html
2369 /// [stable release channel]: https://doc.rust-lang.org/book/appendix-07-nightly-rust.html
2370 /// [`--cap-lints`]: https://doc.rust-lang.org/rustc/lints/levels.html#capping-lints
2371 /// [future-incompatible]: ../index.md#future-incompatible-lints
2374 "a feature gate that doesn't break dependent crates",
2375 @future_incompatible = FutureIncompatibleInfo {
2376 reference: "issue #64266 <https://github.com/rust-lang/rust/issues/64266>",
2381 /// The `inline_no_sanitize` lint detects incompatible use of
2382 /// [`#[inline(always)]`][inline] and [`#[no_sanitize(...)]`][no_sanitize].
2384 /// [inline]: https://doc.rust-lang.org/reference/attributes/codegen.html#the-inline-attribute
2385 /// [no_sanitize]: https://doc.rust-lang.org/nightly/unstable-book/language-features/no-sanitize.html
2390 /// #![feature(no_sanitize)]
2392 /// #[inline(always)]
2393 /// #[no_sanitize(address)]
2405 /// The use of the [`#[inline(always)]`][inline] attribute prevents the
2406 /// the [`#[no_sanitize(...)]`][no_sanitize] attribute from working.
2407 /// Consider temporarily removing `inline` attribute.
2408 pub INLINE_NO_SANITIZE,
2410 "detects incompatible use of `#[inline(always)]` and `#[no_sanitize(...)]`",
2414 /// The `asm_sub_register` lint detects using only a subset of a register
2415 /// for inline asm inputs.
2419 /// ```rust,ignore (fails on system llvm)
2420 /// #![feature(asm)]
2423 /// #[cfg(target_arch="x86_64")]
2425 /// asm!("mov {0}, {0}", in(reg) 0i16);
2430 /// This will produce:
2433 /// warning: formatting may not be suitable for sub-register argument
2434 /// --> src/main.rs:6:19
2436 /// 6 | asm!("mov {0}, {0}", in(reg) 0i16);
2437 /// | ^^^ ^^^ ---- for this argument
2439 /// = note: `#[warn(asm_sub_register)]` on by default
2440 /// = help: use the `x` modifier to have the register formatted as `ax`
2441 /// = help: or use the `r` modifier to keep the default formatting of `rax`
2446 /// Registers on some architectures can use different names to refer to a
2447 /// subset of the register. By default, the compiler will use the name for
2448 /// the full register size. To explicitly use a subset of the register,
2449 /// you can override the default by using a modifier on the template
2450 /// string operand to specify when subregister to use. This lint is issued
2451 /// if you pass in a value with a smaller data type than the default
2452 /// register size, to alert you of possibly using the incorrect width. To
2453 /// fix this, add the suggested modifier to the template, or cast the
2454 /// value to the correct size.
2456 /// See [register template modifiers] for more details.
2458 /// [register template modifiers]: https://doc.rust-lang.org/nightly/unstable-book/library-features/asm.html#register-template-modifiers
2459 pub ASM_SUB_REGISTER,
2461 "using only a subset of a register for inline asm inputs",
2465 /// The `bad_asm_style` lint detects the use of the `.intel_syntax` and
2466 /// `.att_syntax` directives.
2470 /// ```rust,ignore (fails on system llvm)
2471 /// #![feature(asm)]
2474 /// #[cfg(target_arch="x86_64")]
2478 /// "movl {0}, {0}", in(reg) 0usize
2484 /// This will produce:
2487 /// warning: avoid using `.att_syntax`, prefer using `options(att_syntax)` instead
2488 /// --> test.rs:7:14
2490 /// 7 | ".att_syntax",
2492 /// 8 | "movq {0}, {0}", out(reg) _,
2494 /// | - help: add option: `, options(att_syntax)`
2496 /// = note: `#[warn(bad_asm_style)]` on by default
2501 /// On x86, `asm!` uses the intel assembly syntax by default. While this
2502 /// can be switched using assembler directives like `.att_syntax`, using the
2503 /// `att_syntax` option is recommended instead because it will also properly
2504 /// prefix register placeholders with `%` as required by AT&T syntax.
2507 "incorrect use of inline assembly",
2511 /// The `unsafe_op_in_unsafe_fn` lint detects unsafe operations in unsafe
2512 /// functions without an explicit unsafe block.
2516 /// ```rust,compile_fail
2517 /// #![deny(unsafe_op_in_unsafe_fn)]
2519 /// unsafe fn foo() {}
2521 /// unsafe fn bar() {
2532 /// Currently, an [`unsafe fn`] allows any [unsafe] operation within its
2533 /// body. However, this can increase the surface area of code that needs
2534 /// to be scrutinized for proper behavior. The [`unsafe` block] provides a
2535 /// convenient way to make it clear exactly which parts of the code are
2536 /// performing unsafe operations. In the future, it is desired to change
2537 /// it so that unsafe operations cannot be performed in an `unsafe fn`
2538 /// without an `unsafe` block.
2540 /// The fix to this is to wrap the unsafe code in an `unsafe` block.
2542 /// This lint is "allow" by default since this will affect a large amount
2543 /// of existing code, and the exact plan for increasing the severity is
2544 /// still being considered. See [RFC #2585] and [issue #71668] for more
2547 /// [`unsafe fn`]: https://doc.rust-lang.org/reference/unsafe-functions.html
2548 /// [`unsafe` block]: https://doc.rust-lang.org/reference/expressions/block-expr.html#unsafe-blocks
2549 /// [unsafe]: https://doc.rust-lang.org/reference/unsafety.html
2550 /// [RFC #2585]: https://github.com/rust-lang/rfcs/blob/master/text/2585-unsafe-block-in-unsafe-fn.md
2551 /// [issue #71668]: https://github.com/rust-lang/rust/issues/71668
2552 pub UNSAFE_OP_IN_UNSAFE_FN,
2554 "unsafe operations in unsafe functions without an explicit unsafe block are deprecated",
2558 /// The `cenum_impl_drop_cast` lint detects an `as` cast of a field-less
2559 /// `enum` that implements [`Drop`].
2561 /// [`Drop`]: https://doc.rust-lang.org/std/ops/trait.Drop.html
2566 /// # #![allow(unused)]
2571 /// impl Drop for E {
2572 /// fn drop(&mut self) {
2573 /// println!("Drop");
2579 /// let i = e as u32;
2587 /// Casting a field-less `enum` that does not implement [`Copy`] to an
2588 /// integer moves the value without calling `drop`. This can result in
2589 /// surprising behavior if it was expected that `drop` should be called.
2590 /// Calling `drop` automatically would be inconsistent with other move
2591 /// operations. Since neither behavior is clear or consistent, it was
2592 /// decided that a cast of this nature will no longer be allowed.
2594 /// This is a [future-incompatible] lint to transition this to a hard error
2595 /// in the future. See [issue #73333] for more details.
2597 /// [future-incompatible]: ../index.md#future-incompatible-lints
2598 /// [issue #73333]: https://github.com/rust-lang/rust/issues/73333
2599 /// [`Copy`]: https://doc.rust-lang.org/std/marker/trait.Copy.html
2600 pub CENUM_IMPL_DROP_CAST,
2602 "a C-like enum implementing Drop is cast",
2603 @future_incompatible = FutureIncompatibleInfo {
2604 reference: "issue #73333 <https://github.com/rust-lang/rust/issues/73333>",
2609 /// The `const_evaluatable_unchecked` lint detects a generic constant used
2615 /// const fn foo<T>() -> usize {
2616 /// if std::mem::size_of::<*mut T>() < 8 { // size of *mut T does not depend on T
2624 /// let _ = [0; foo::<T>()];
2632 /// In the 1.43 release, some uses of generic parameters in array repeat
2633 /// expressions were accidentally allowed. This is a [future-incompatible]
2634 /// lint to transition this to a hard error in the future. See [issue
2635 /// #76200] for a more detailed description and possible fixes.
2637 /// [future-incompatible]: ../index.md#future-incompatible-lints
2638 /// [issue #76200]: https://github.com/rust-lang/rust/issues/76200
2639 pub CONST_EVALUATABLE_UNCHECKED,
2641 "detects a generic constant is used in a type without a emitting a warning",
2642 @future_incompatible = FutureIncompatibleInfo {
2643 reference: "issue #76200 <https://github.com/rust-lang/rust/issues/76200>",
2648 /// The `function_item_references` lint detects function references that are
2649 /// formatted with [`fmt::Pointer`] or transmuted.
2651 /// [`fmt::Pointer`]: https://doc.rust-lang.org/std/fmt/trait.Pointer.html
2659 /// println!("{:p}", &foo);
2667 /// Taking a reference to a function may be mistaken as a way to obtain a
2668 /// pointer to that function. This can give unexpected results when
2669 /// formatting the reference as a pointer or transmuting it. This lint is
2670 /// issued when function references are formatted as pointers, passed as
2671 /// arguments bound by [`fmt::Pointer`] or transmuted.
2672 pub FUNCTION_ITEM_REFERENCES,
2674 "suggest casting to a function pointer when attempting to take references to function items",
2678 /// The `uninhabited_static` lint detects uninhabited statics.
2685 /// static EXTERN: Void;
2693 /// Statics with an uninhabited type can never be initialized, so they are impossible to define.
2694 /// However, this can be side-stepped with an `extern static`, leading to problems later in the
2695 /// compiler which assumes that there are no initialized uninhabited places (such as locals or
2696 /// statics). This was accidentally allowed, but is being phased out.
2697 pub UNINHABITED_STATIC,
2699 "uninhabited static",
2700 @future_incompatible = FutureIncompatibleInfo {
2701 reference: "issue #74840 <https://github.com/rust-lang/rust/issues/74840>",
2706 /// The `useless_deprecated` lint detects deprecation attributes with no effect.
2710 /// ```rust,compile_fail
2713 /// #[deprecated = "message"]
2714 /// impl Default for X {
2715 /// fn default() -> Self {
2725 /// Deprecation attributes have no effect on trait implementations.
2726 pub USELESS_DEPRECATED,
2728 "detects deprecation attributes with no effect",
2732 /// The `undefined_naked_function_abi` lint detects naked function definitions that
2733 /// either do not specify an ABI or specify the Rust ABI.
2738 /// #![feature(naked_functions)]
2739 /// #![feature(asm)]
2742 /// pub fn default_abi() -> u32 {
2743 /// unsafe { asm!("", options(noreturn)); }
2747 /// pub extern "Rust" fn rust_abi() -> u32 {
2748 /// unsafe { asm!("", options(noreturn)); }
2756 /// The Rust ABI is currently undefined. Therefore, naked functions should
2757 /// specify a non-Rust ABI.
2758 pub UNDEFINED_NAKED_FUNCTION_ABI,
2760 "undefined naked function ABI"
2764 /// The `unsupported_naked_functions` lint detects naked function
2765 /// definitions that are unsupported but were previously accepted.
2770 /// #![feature(naked_functions)]
2773 /// pub extern "C" fn f() -> u32 {
2782 /// The naked functions must be defined using a single inline assembly
2785 /// The execution must never fall through past the end of the assembly
2786 /// code so the block must use `noreturn` option. The asm block can also
2787 /// use `att_syntax` option, but other options are not allowed.
2789 /// The asm block must not contain any operands other than `const` and
2790 /// `sym`. Additionally, naked function should specify a non-Rust ABI.
2792 /// Naked functions cannot be inlined. All forms of the `inline` attribute
2795 /// While other definitions of naked functions were previously accepted,
2796 /// they are unsupported and might not work reliably. This is a
2797 /// [future-incompatible] lint that will transition into hard error in
2800 /// [future-incompatible]: ../index.md#future-incompatible-lints
2801 pub UNSUPPORTED_NAKED_FUNCTIONS,
2803 "unsupported naked function definitions",
2804 @future_incompatible = FutureIncompatibleInfo {
2805 reference: "issue #32408 <https://github.com/rust-lang/rust/issues/32408>",
2810 /// The `ineffective_unstable_trait_impl` lint detects `#[unstable]` attributes which are not used.
2815 /// #![feature(staged_api)]
2817 /// #[derive(Clone)]
2818 /// #[stable(feature = "x", since = "1")]
2821 /// #[unstable(feature = "y", issue = "none")]
2822 /// impl Copy for S {}
2829 /// `staged_api` does not currently support using a stability attribute on `impl` blocks.
2830 /// `impl`s are always stable if both the type and trait are stable, and always unstable otherwise.
2831 pub INEFFECTIVE_UNSTABLE_TRAIT_IMPL,
2833 "detects `#[unstable]` on stable trait implementations for stable types"
2837 /// The `semicolon_in_expressions_from_macros` lint detects trailing semicolons
2838 /// in macro bodies when the macro is invoked in expression position.
2839 /// This was previous accepted, but is being phased out.
2843 /// ```rust,compile_fail
2844 /// #![deny(semicolon_in_expressions_from_macros)]
2845 /// macro_rules! foo {
2850 /// let val = match true {
2861 /// Previous, Rust ignored trailing semicolon in a macro
2862 /// body when a macro was invoked in expression position.
2863 /// However, this makes the treatment of semicolons in the language
2864 /// inconsistent, and could lead to unexpected runtime behavior
2865 /// in some circumstances (e.g. if the macro author expects
2866 /// a value to be dropped).
2868 /// This is a [future-incompatible] lint to transition this
2869 /// to a hard error in the future. See [issue #79813] for more details.
2871 /// [issue #79813]: https://github.com/rust-lang/rust/issues/79813
2872 /// [future-incompatible]: ../index.md#future-incompatible-lints
2873 pub SEMICOLON_IN_EXPRESSIONS_FROM_MACROS,
2875 "trailing semicolon in macro body used as expression",
2876 @future_incompatible = FutureIncompatibleInfo {
2877 reference: "issue #79813 <https://github.com/rust-lang/rust/issues/79813>",
2882 /// The `legacy_derive_helpers` lint detects derive helper attributes
2883 /// that are used before they are introduced.
2887 /// ```rust,ignore (needs extern crate)
2888 /// #[serde(rename_all = "camelCase")]
2889 /// #[derive(Deserialize)]
2890 /// struct S { /* fields */ }
2896 /// warning: derive helper attribute is used before it is introduced
2897 /// --> $DIR/legacy-derive-helpers.rs:1:3
2899 /// 1 | #[serde(rename_all = "camelCase")]
2902 /// 2 | #[derive(Deserialize)]
2903 /// | ----------- the attribute is introduced here
2908 /// Attributes like this work for historical reasons, but attribute expansion works in
2909 /// left-to-right order in general, so, to resolve `#[serde]`, compiler has to try to "look
2910 /// into the future" at not yet expanded part of the item , but such attempts are not always
2913 /// To fix the warning place the helper attribute after its corresponding derive.
2914 /// ```rust,ignore (needs extern crate)
2915 /// #[derive(Deserialize)]
2916 /// #[serde(rename_all = "camelCase")]
2917 /// struct S { /* fields */ }
2919 pub LEGACY_DERIVE_HELPERS,
2921 "detects derive helper attributes that are used before they are introduced",
2922 @future_incompatible = FutureIncompatibleInfo {
2923 reference: "issue #79202 <https://github.com/rust-lang/rust/issues/79202>",
2928 /// The `large_assignments` lint detects when objects of large
2929 /// types are being moved around.
2933 /// ```rust,ignore (can crash on some platforms)
2934 /// let x = [0; 50000];
2941 /// warning: moving a large value
2942 /// --> $DIR/move-large.rs:1:3
2944 /// - Copied large value here
2949 /// When using a large type in a plain assignment or in a function
2950 /// argument, idiomatic code can be inefficient.
2951 /// Ideally appropriate optimizations would resolve this, but such
2952 /// optimizations are only done in a best-effort manner.
2953 /// This lint will trigger on all sites of large moves and thus allow the
2954 /// user to resolve them in code.
2955 pub LARGE_ASSIGNMENTS,
2957 "detects large moves or copies",
2960 declare_lint_pass! {
2961 /// Does nothing as a lint pass, but registers some `Lint`s
2962 /// that are used by other parts of the compiler.
2964 FORBIDDEN_LINT_GROUPS,
2965 ILLEGAL_FLOATING_POINT_LITERAL_PATTERN,
2966 ARITHMETIC_OVERFLOW,
2967 UNCONDITIONAL_PANIC,
2969 UNUSED_EXTERN_CRATES,
2970 UNUSED_CRATE_DEPENDENCIES,
2971 UNUSED_QUALIFICATIONS,
2977 UNREACHABLE_PATTERNS,
2978 OVERLAPPING_RANGE_ENDPOINTS,
2979 BINDINGS_WITH_VARIANT_NAME,
2984 UNKNOWN_CRATE_TYPES,
2986 TRIVIAL_NUMERIC_CASTS,
2988 EXPORTED_PRIVATE_DEPENDENCIES,
2989 PUB_USE_OF_PRIVATE_EXTERN_CRATE,
2990 INVALID_TYPE_PARAM_DEFAULT,
2992 RENAMED_AND_REMOVED_LINTS,
2993 UNALIGNED_REFERENCES,
2994 CONST_ITEM_MUTATION,
2995 PATTERNS_IN_FNS_WITHOUT_BODY,
2996 MISSING_FRAGMENT_SPECIFIER,
2997 LATE_BOUND_LIFETIME_ARGUMENTS,
2998 ORDER_DEPENDENT_TRAIT_OBJECTS,
2999 COHERENCE_LEAK_CHECK,
3003 UNCONDITIONAL_RECURSION,
3004 SINGLE_USE_LIFETIMES,
3007 TYVAR_BEHIND_RAW_POINTER,
3008 ELIDED_LIFETIMES_IN_PATHS,
3010 ABSOLUTE_PATHS_NOT_STARTING_WITH_CRATE,
3011 UNSTABLE_NAME_COLLISIONS,
3012 IRREFUTABLE_LET_PATTERNS,
3013 WHERE_CLAUSES_OBJECT_SAFETY,
3014 PROC_MACRO_DERIVE_RESOLUTION_FALLBACK,
3015 MACRO_USE_EXTERN_CRATE,
3016 MACRO_EXPANDED_MACRO_EXPORTS_ACCESSED_BY_ABSOLUTE_PATHS,
3017 ILL_FORMED_ATTRIBUTE_INPUT,
3018 CONFLICTING_REPR_HINTS,
3019 META_VARIABLE_MISUSE,
3020 DEPRECATED_IN_FUTURE,
3021 AMBIGUOUS_ASSOCIATED_ITEMS,
3022 MUTABLE_BORROW_RESERVATION_CONFLICT,
3023 INDIRECT_STRUCTURAL_MATCH,
3024 POINTER_STRUCTURAL_MATCH,
3025 NONTRIVIAL_STRUCTURAL_MATCH,
3030 UNSAFE_OP_IN_UNSAFE_FN,
3032 CENUM_IMPL_DROP_CAST,
3033 CONST_EVALUATABLE_UNCHECKED,
3034 INEFFECTIVE_UNSTABLE_TRAIT_IMPL,
3037 FUNCTION_ITEM_REFERENCES,
3039 UNSUPPORTED_NAKED_FUNCTIONS,
3041 INVALID_DOC_ATTRIBUTES,
3042 SEMICOLON_IN_EXPRESSIONS_FROM_MACROS,
3043 RUST_2021_INCOMPATIBLE_CLOSURE_CAPTURES,
3044 LEGACY_DERIVE_HELPERS,
3045 PROC_MACRO_BACK_COMPAT,
3046 RUST_2021_INCOMPATIBLE_OR_PATTERNS,
3048 RUST_2021_PRELUDE_COLLISIONS,
3049 RUST_2021_PREFIXES_INCOMPATIBLE_SYNTAX,
3050 UNSUPPORTED_CALLING_CONVENTIONS,
3051 BREAK_WITH_LABEL_AND_LOOP,
3053 NON_EXHAUSTIVE_OMITTED_PATTERNS,
3054 DEREF_INTO_DYN_SUPERTRAIT,
3059 /// The `unused_doc_comments` lint detects doc comments that aren't used
3073 /// `rustdoc` does not use doc comments in all positions, and so the doc
3074 /// comment will be ignored. Try changing it to a normal comment with `//`
3075 /// to avoid the warning.
3076 pub UNUSED_DOC_COMMENTS,
3078 "detects doc comments that aren't used by rustdoc"
3082 /// The `rust_2021_incompatible_closure_captures` lint detects variables that aren't completely
3083 /// captured in Rust 2021, such that the `Drop` order of their fields may differ between
3084 /// Rust 2018 and 2021.
3086 /// It can also detect when a variable implements a trait like `Send`, but one of its fields does not,
3087 /// and the field is captured by a closure and used with the assumption that said field implements
3088 /// the same trait as the root variable.
3090 /// ### Example of drop reorder
3092 /// ```rust,compile_fail
3093 /// #![deny(rust_2021_incompatible_closure_captures)]
3094 /// # #![allow(unused)]
3096 /// struct FancyInteger(i32);
3098 /// impl Drop for FancyInteger {
3099 /// fn drop(&mut self) {
3100 /// println!("Just dropped {}", self.0);
3104 /// struct Point { x: FancyInteger, y: FancyInteger }
3107 /// let p = Point { x: FancyInteger(10), y: FancyInteger(20) };
3115 /// // ... More code ...
3123 /// In the above example, `p.y` will be dropped at the end of `f` instead of
3124 /// with `c` in Rust 2021.
3126 /// ### Example of auto-trait
3128 /// ```rust,compile_fail
3129 /// #![deny(rust_2021_incompatible_closure_captures)]
3130 /// use std::thread;
3132 /// struct Pointer(*mut i32);
3133 /// unsafe impl Send for Pointer {}
3137 /// let fptr = Pointer(&mut f as *mut i32);
3138 /// thread::spawn(move || unsafe {
3148 /// In the above example, only `fptr.0` is captured in Rust 2021.
3149 /// The field is of type `*mut i32`, which doesn't implement `Send`,
3150 /// making the code invalid as the field cannot be sent between threads safely.
3151 pub RUST_2021_INCOMPATIBLE_CLOSURE_CAPTURES,
3153 "detects closures affected by Rust 2021 changes",
3154 @future_incompatible = FutureIncompatibleInfo {
3155 reason: FutureIncompatibilityReason::EditionSemanticsChange(Edition::Edition2021),
3156 explain_reason: false,
3160 declare_lint_pass!(UnusedDocComment => [UNUSED_DOC_COMMENTS]);
3163 /// The `missing_abi` lint detects cases where the ABI is omitted from
3164 /// extern declarations.
3168 /// ```rust,compile_fail
3169 /// #![deny(missing_abi)]
3171 /// extern fn foo() {}
3178 /// Historically, Rust implicitly selected C as the ABI for extern
3179 /// declarations. We expect to add new ABIs, like `C-unwind`, in the future,
3180 /// though this has not yet happened, and especially with their addition
3181 /// seeing the ABI easily will make code review easier.
3184 "No declared ABI for extern declaration"
3188 /// The `invalid_doc_attributes` lint detects when the `#[doc(...)]` is
3193 /// ```rust,compile_fail
3194 /// #![deny(warnings)]
3196 /// pub mod submodule {
3197 /// #![doc(test(no_crate_inject))]
3205 /// Previously, there were very like checks being performed on `#[doc(..)]`
3206 /// unlike the other attributes. It'll now catch all the issues that it
3207 /// silently ignored previously.
3208 pub INVALID_DOC_ATTRIBUTES,
3210 "detects invalid `#[doc(...)]` attributes",
3211 @future_incompatible = FutureIncompatibleInfo {
3212 reference: "issue #82730 <https://github.com/rust-lang/rust/issues/82730>",
3217 /// The `proc_macro_back_compat` lint detects uses of old versions of certain
3218 /// proc-macro crates, which have hardcoded workarounds in the compiler.
3222 /// ```rust,ignore (needs-dependency)
3224 /// use time_macros_impl::impl_macros;
3226 /// impl_macros!(Foo);
3229 /// This will produce:
3232 /// warning: using an old version of `time-macros-impl`
3233 /// ::: $DIR/group-compat-hack.rs:27:5
3235 /// LL | impl_macros!(Foo);
3236 /// | ------------------ in this macro invocation
3238 /// = note: `#[warn(proc_macro_back_compat)]` on by default
3239 /// = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
3240 /// = note: for more information, see issue #83125 <https://github.com/rust-lang/rust/issues/83125>
3241 /// = 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
3242 /// = note: this warning originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
3247 /// Eventually, the backwards-compatibility hacks present in the compiler will be removed,
3248 /// causing older versions of certain crates to stop compiling.
3249 /// This is a [future-incompatible] lint to ease the transition to an error.
3250 /// See [issue #83125] for more details.
3252 /// [issue #83125]: https://github.com/rust-lang/rust/issues/83125
3253 /// [future-incompatible]: ../index.md#future-incompatible-lints
3254 pub PROC_MACRO_BACK_COMPAT,
3256 "detects usage of old versions of certain proc-macro crates",
3257 @future_incompatible = FutureIncompatibleInfo {
3258 reference: "issue #83125 <https://github.com/rust-lang/rust/issues/83125>",
3259 reason: FutureIncompatibilityReason::FutureReleaseErrorReportNow,
3264 /// The `rust_2021_incompatible_or_patterns` lint detects usage of old versions of or-patterns.
3268 /// ```rust,compile_fail
3269 /// #![deny(rust_2021_incompatible_or_patterns)]
3271 /// macro_rules! match_any {
3272 /// ( $expr:expr , $( $( $pat:pat )|+ => $expr_arm:expr ),+ ) => {
3275 /// $( $pat => $expr_arm, )+
3282 /// let result: Result<i64, i32> = Err(42);
3283 /// let int: i64 = match_any!(result, Ok(i) | Err(i) => i.into());
3284 /// assert_eq!(int, 42);
3292 /// In Rust 2021, the `pat` matcher will match additional patterns, which include the `|` character.
3293 pub RUST_2021_INCOMPATIBLE_OR_PATTERNS,
3295 "detects usage of old versions of or-patterns",
3296 @future_incompatible = FutureIncompatibleInfo {
3297 reference: "<https://doc.rust-lang.org/nightly/edition-guide/rust-2021/or-patterns-macro-rules.html>",
3298 reason: FutureIncompatibilityReason::EditionError(Edition::Edition2021),
3303 /// The `rust_2021_prelude_collisions` lint detects the usage of trait methods which are ambiguous
3304 /// with traits added to the prelude in future editions.
3308 /// ```rust,compile_fail
3309 /// #![deny(rust_2021_prelude_collisions)]
3312 /// fn try_into(self) -> Result<String, !>;
3315 /// impl Foo for &str {
3316 /// fn try_into(self) -> Result<String, !> {
3317 /// Ok(String::from(self))
3322 /// let x: String = "3".try_into().unwrap();
3324 /// // This call to try_into matches both Foo:try_into and TryInto::try_into as
3325 /// // `TryInto` has been added to the Rust prelude in 2021 edition.
3326 /// println!("{}", x);
3334 /// In Rust 2021, one of the important introductions is the [prelude changes], which add
3335 /// `TryFrom`, `TryInto`, and `FromIterator` into the standard library's prelude. Since this
3336 /// results in an ambiguity as to which method/function to call when an existing `try_into`
3337 /// method is called via dot-call syntax or a `try_from`/`from_iter` associated function
3338 /// is called directly on a type.
3340 /// [prelude changes]: https://blog.rust-lang.org/inside-rust/2021/03/04/planning-rust-2021.html#prelude-changes
3341 pub RUST_2021_PRELUDE_COLLISIONS,
3343 "detects the usage of trait methods which are ambiguous with traits added to the \
3344 prelude in future editions",
3345 @future_incompatible = FutureIncompatibleInfo {
3346 reference: "<https://doc.rust-lang.org/nightly/edition-guide/rust-2021/prelude.html>",
3347 reason: FutureIncompatibilityReason::EditionError(Edition::Edition2021),
3352 /// The `rust_2021_prefixes_incompatible_syntax` lint detects identifiers that will be parsed as a
3353 /// prefix instead in Rust 2021.
3357 /// ```rust,edition2018,compile_fail
3358 /// #![deny(rust_2021_prefixes_incompatible_syntax)]
3360 /// macro_rules! m {
3361 /// (z $x:expr) => ();
3371 /// In Rust 2015 and 2018, `z"hey"` is two tokens: the identifier `z`
3372 /// followed by the string literal `"hey"`. In Rust 2021, the `z` is
3373 /// considered a prefix for `"hey"`.
3375 /// This lint suggests to add whitespace between the `z` and `"hey"` tokens
3376 /// to keep them separated in Rust 2021.
3377 // Allow this lint -- rustdoc doesn't yet support threading edition into this lint's parser.
3378 #[allow(rustdoc::invalid_rust_codeblocks)]
3379 pub RUST_2021_PREFIXES_INCOMPATIBLE_SYNTAX,
3381 "identifiers that will be parsed as a prefix in Rust 2021",
3382 @future_incompatible = FutureIncompatibleInfo {
3383 reference: "<https://doc.rust-lang.org/nightly/edition-guide/rust-2021/reserving-syntax.html>",
3384 reason: FutureIncompatibilityReason::EditionError(Edition::Edition2021),
3390 /// The `unsupported_calling_conventions` lint is output whenever there is a use of the
3391 /// `stdcall`, `fastcall`, `thiscall`, `vectorcall` calling conventions (or their unwind
3392 /// variants) on targets that cannot meaningfully be supported for the requested target.
3394 /// For example `stdcall` does not make much sense for a x86_64 or, more apparently, powerpc
3395 /// code, because this calling convention was never specified for those targets.
3397 /// Historically MSVC toolchains have fallen back to the regular C calling convention for
3398 /// targets other than x86, but Rust doesn't really see a similar need to introduce a similar
3399 /// hack across many more targets.
3403 /// ```rust,ignore (needs specific targets)
3404 /// extern "stdcall" fn stdcall() {}
3407 /// This will produce:
3410 /// warning: use of calling convention not supported on this target
3411 /// --> $DIR/unsupported.rs:39:1
3413 /// LL | extern "stdcall" fn stdcall() {}
3414 /// | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
3416 /// = note: `#[warn(unsupported_calling_conventions)]` on by default
3417 /// = warning: this was previously accepted by the compiler but is being phased out;
3418 /// it will become a hard error in a future release!
3419 /// = note: for more information, see issue ...
3424 /// On most of the targets the behaviour of `stdcall` and similar calling conventions is not
3425 /// defined at all, but was previously accepted due to a bug in the implementation of the
3427 pub UNSUPPORTED_CALLING_CONVENTIONS,
3429 "use of unsupported calling convention",
3430 @future_incompatible = FutureIncompatibleInfo {
3431 reference: "issue #87678 <https://github.com/rust-lang/rust/issues/87678>",
3436 /// The `break_with_label_and_loop` lint detects labeled `break` expressions with
3437 /// an unlabeled loop as their value expression.
3443 /// break 'label loop { break 42; };
3451 /// In Rust, loops can have a label, and `break` expressions can refer to that label to
3452 /// break out of specific loops (and not necessarily the innermost one). `break` expressions
3453 /// can also carry a value expression, which can be another loop. A labeled `break` with an
3454 /// unlabeled loop as its value expression is easy to confuse with an unlabeled break with
3455 /// a labeled loop and is thus discouraged (but allowed for compatibility); use parentheses
3456 /// around the loop expression to silence this warning. Unlabeled `break` expressions with
3457 /// labeled loops yield a hard error, which can also be silenced by wrapping the expression
3459 pub BREAK_WITH_LABEL_AND_LOOP,
3461 "`break` expression with label and unlabeled loop as value expression"
3465 /// The `non_exhaustive_omitted_patterns` lint detects when a wildcard (`_` or `..`) in a
3466 /// pattern for a `#[non_exhaustive]` struct or enum is reachable.
3470 /// ```rust,ignore (needs separate crate)
3472 /// #[non_exhaustive]
3475 /// B, // added variant in non breaking change
3481 /// #[warn(non_exhaustive_omitted_patterns)]
3486 /// This will produce:
3489 /// warning: reachable patterns not covered of non exhaustive enum
3490 /// --> $DIR/reachable-patterns.rs:70:9
3493 /// | ^ pattern `B` not covered
3495 /// note: the lint level is defined here
3496 /// --> $DIR/reachable-patterns.rs:69:16
3498 /// LL | #[warn(non_exhaustive_omitted_patterns)]
3499 /// | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
3500 /// = help: ensure that all possible cases are being handled by adding the suggested match arms
3501 /// = note: the matched value is of type `Bar` and the `non_exhaustive_omitted_patterns` attribute was found
3506 /// Structs and enums tagged with `#[non_exhaustive]` force the user to add a
3507 /// (potentially redundant) wildcard when pattern-matching, to allow for future
3508 /// addition of fields or variants. The `non_exhaustive_omitted_patterns` lint
3509 /// detects when such a wildcard happens to actually catch some fields/variants.
3510 /// In other words, when the match without the wildcard would not be exhaustive.
3511 /// This lets the user be informed if new fields/variants were added.
3512 pub NON_EXHAUSTIVE_OMITTED_PATTERNS,
3514 "detect when patterns of types marked `non_exhaustive` are missed",
3518 /// The `deref_into_dyn_supertrait` lint is output whenever there is a use of the
3519 /// `Deref` implementation with a `dyn SuperTrait` type as `Output`.
3521 /// These implementations will become shadowed when the `trait_upcasting` feature is stablized.
3522 /// The `deref` functions will no longer be called implicitly, so there might be behavior change.
3526 /// ```rust,compile_fail
3527 /// #![deny(deref_into_dyn_supertrait)]
3528 /// #![allow(dead_code)]
3530 /// use core::ops::Deref;
3534 /// impl<'a> Deref for dyn 'a + B {
3535 /// type Target = dyn A;
3536 /// fn deref(&self) -> &Self::Target {
3541 /// fn take_a(_: &dyn A) { }
3543 /// fn take_b(b: &dyn B) {
3552 /// The dyn upcasting coercion feature adds new coercion rules, taking priority
3553 /// over certain other coercion rules, which will cause some behavior change.
3554 pub DEREF_INTO_DYN_SUPERTRAIT,
3556 "`Deref` implementation usage with a supertrait trait object for output might be shadowed in the future",
3557 @future_incompatible = FutureIncompatibleInfo {
3558 reference: "issue #89460 <https://github.com/rust-lang/rust/issues/89460>",