Skip to main content

rustc_lint_defs/
lib.rs

1use std::borrow::Cow;
2use std::fmt::Display;
3
4use rustc_data_structures::fx::FxIndexSet;
5use rustc_data_structures::stable_hasher::{
6    HashStable, StableCompare, StableHasher, ToStableHashKey,
7};
8use rustc_error_messages::{DiagArgValue, IntoDiagArg};
9use rustc_hir_id::{HirId, ItemLocalId};
10use rustc_macros::{Decodable, Encodable, HashStable_Generic};
11use rustc_span::def_id::DefPathHash;
12pub use rustc_span::edition::Edition;
13use rustc_span::{AttrId, HashStableContext, Ident, Span, Symbol, sym};
14use serde::{Deserialize, Serialize};
15
16pub use self::Level::*;
17
18pub mod builtin;
19
20#[macro_export]
21macro_rules! pluralize {
22    // Pluralize based on count (e.g., apples)
23    ($x:expr) => {
24        if $x == 1 { "" } else { "s" }
25    };
26    ("has", $x:expr) => {
27        if $x == 1 { "has" } else { "have" }
28    };
29    ("is", $x:expr) => {
30        if $x == 1 { "is" } else { "are" }
31    };
32    ("was", $x:expr) => {
33        if $x == 1 { "was" } else { "were" }
34    };
35    ("this", $x:expr) => {
36        if $x == 1 { "this" } else { "these" }
37    };
38}
39
40/// Grammatical tool for displaying messages to end users in a nice form.
41///
42/// Take a list of items and a function to turn those items into a `String`, and output a display
43/// friendly comma separated list of those items.
44// FIXME(estebank): this needs to be changed to go through the translation machinery.
45pub fn listify<T>(list: &[T], fmt: impl Fn(&T) -> String) -> Option<String> {
46    Some(match list {
47        [only] => fmt(&only),
48        [others @ .., last] => ::alloc::__export::must_use({
        ::alloc::fmt::format(format_args!("{0} and {1}",
                others.iter().map(|i| fmt(i)).collect::<Vec<_>>().join(", "),
                fmt(&last)))
    })format!(
49            "{} and {}",
50            others.iter().map(|i| fmt(i)).collect::<Vec<_>>().join(", "),
51            fmt(&last),
52        ),
53        [] => return None,
54    })
55}
56
57/// Indicates the confidence in the correctness of a suggestion.
58///
59/// All suggestions are marked with an `Applicability`. Tools use the applicability of a suggestion
60/// to determine whether it should be automatically applied or if the user should be consulted
61/// before applying the suggestion.
62#[derive(#[automatically_derived]
impl ::core::marker::Copy for Applicability { }Copy, #[automatically_derived]
impl ::core::clone::Clone for Applicability {
    #[inline]
    fn clone(&self) -> Applicability { *self }
}Clone, #[automatically_derived]
impl ::core::fmt::Debug for Applicability {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::write_str(f,
            match self {
                Applicability::MachineApplicable => "MachineApplicable",
                Applicability::MaybeIncorrect => "MaybeIncorrect",
                Applicability::HasPlaceholders => "HasPlaceholders",
                Applicability::Unspecified => "Unspecified",
            })
    }
}Debug, #[automatically_derived]
impl ::core::hash::Hash for Applicability {
    #[inline]
    fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) {
        let __self_discr = ::core::intrinsics::discriminant_value(self);
        ::core::hash::Hash::hash(&__self_discr, state)
    }
}Hash, const _: () =
    {
        impl<__E: ::rustc_span::SpanEncoder> ::rustc_serialize::Encodable<__E>
            for Applicability {
            fn encode(&self, __encoder: &mut __E) {
                let disc =
                    match *self {
                        Applicability::MachineApplicable => { 0usize }
                        Applicability::MaybeIncorrect => { 1usize }
                        Applicability::HasPlaceholders => { 2usize }
                        Applicability::Unspecified => { 3usize }
                    };
                ::rustc_serialize::Encoder::emit_u8(__encoder, disc as u8);
                match *self {
                    Applicability::MachineApplicable => {}
                    Applicability::MaybeIncorrect => {}
                    Applicability::HasPlaceholders => {}
                    Applicability::Unspecified => {}
                }
            }
        }
    };Encodable, const _: () =
    {
        impl<__D: ::rustc_span::SpanDecoder> ::rustc_serialize::Decodable<__D>
            for Applicability {
            fn decode(__decoder: &mut __D) -> Self {
                match ::rustc_serialize::Decoder::read_u8(__decoder) as usize
                    {
                    0usize => { Applicability::MachineApplicable }
                    1usize => { Applicability::MaybeIncorrect }
                    2usize => { Applicability::HasPlaceholders }
                    3usize => { Applicability::Unspecified }
                    n => {
                        ::core::panicking::panic_fmt(format_args!("invalid enum variant tag while decoding `Applicability`, expected 0..4, actual {0}",
                                n));
                    }
                }
            }
        }
    };Decodable, #[doc(hidden)]
#[allow(non_upper_case_globals, unused_attributes, unused_qualifications,
clippy :: absolute_paths,)]
const _: () =
    {
        #[allow(unused_extern_crates, clippy :: useless_attribute)]
        extern crate serde as _serde;
        ;
        #[automatically_derived]
        impl _serde::Serialize for Applicability {
            fn serialize<__S>(&self, __serializer: __S)
                -> _serde::__private228::Result<__S::Ok, __S::Error> where
                __S: _serde::Serializer {
                match *self {
                    Applicability::MachineApplicable =>
                        _serde::Serializer::serialize_unit_variant(__serializer,
                            "Applicability", 0u32, "MachineApplicable"),
                    Applicability::MaybeIncorrect =>
                        _serde::Serializer::serialize_unit_variant(__serializer,
                            "Applicability", 1u32, "MaybeIncorrect"),
                    Applicability::HasPlaceholders =>
                        _serde::Serializer::serialize_unit_variant(__serializer,
                            "Applicability", 2u32, "HasPlaceholders"),
                    Applicability::Unspecified =>
                        _serde::Serializer::serialize_unit_variant(__serializer,
                            "Applicability", 3u32, "Unspecified"),
                }
            }
        }
    };Serialize, #[doc(hidden)]
#[allow(non_upper_case_globals, unused_attributes, unused_qualifications,
clippy :: absolute_paths,)]
const _: () =
    {
        #[allow(unused_extern_crates, clippy :: useless_attribute)]
        extern crate serde as _serde;
        ;
        #[automatically_derived]
        impl<'de> _serde::Deserialize<'de> for Applicability {
            fn deserialize<__D>(__deserializer: __D)
                -> _serde::__private228::Result<Self, __D::Error> where
                __D: _serde::Deserializer<'de> {
                #[allow(non_camel_case_types)]
                #[doc(hidden)]
                enum __Field { __field0, __field1, __field2, __field3, }
                #[doc(hidden)]
                struct __FieldVisitor;
                #[automatically_derived]
                impl<'de> _serde::de::Visitor<'de> for __FieldVisitor {
                    type Value = __Field;
                    fn expecting(&self,
                        __formatter: &mut _serde::__private228::Formatter)
                        -> _serde::__private228::fmt::Result {
                        _serde::__private228::Formatter::write_str(__formatter,
                            "variant identifier")
                    }
                    fn visit_u64<__E>(self, __value: u64)
                        -> _serde::__private228::Result<Self::Value, __E> where
                        __E: _serde::de::Error {
                        match __value {
                            0u64 => _serde::__private228::Ok(__Field::__field0),
                            1u64 => _serde::__private228::Ok(__Field::__field1),
                            2u64 => _serde::__private228::Ok(__Field::__field2),
                            3u64 => _serde::__private228::Ok(__Field::__field3),
                            _ =>
                                _serde::__private228::Err(_serde::de::Error::invalid_value(_serde::de::Unexpected::Unsigned(__value),
                                        &"variant index 0 <= i < 4")),
                        }
                    }
                    fn visit_str<__E>(self, __value: &str)
                        -> _serde::__private228::Result<Self::Value, __E> where
                        __E: _serde::de::Error {
                        match __value {
                            "MachineApplicable" =>
                                _serde::__private228::Ok(__Field::__field0),
                            "MaybeIncorrect" =>
                                _serde::__private228::Ok(__Field::__field1),
                            "HasPlaceholders" =>
                                _serde::__private228::Ok(__Field::__field2),
                            "Unspecified" =>
                                _serde::__private228::Ok(__Field::__field3),
                            _ => {
                                _serde::__private228::Err(_serde::de::Error::unknown_variant(__value,
                                        VARIANTS))
                            }
                        }
                    }
                    fn visit_bytes<__E>(self, __value: &[u8])
                        -> _serde::__private228::Result<Self::Value, __E> where
                        __E: _serde::de::Error {
                        match __value {
                            b"MachineApplicable" =>
                                _serde::__private228::Ok(__Field::__field0),
                            b"MaybeIncorrect" =>
                                _serde::__private228::Ok(__Field::__field1),
                            b"HasPlaceholders" =>
                                _serde::__private228::Ok(__Field::__field2),
                            b"Unspecified" =>
                                _serde::__private228::Ok(__Field::__field3),
                            _ => {
                                let __value =
                                    &_serde::__private228::from_utf8_lossy(__value);
                                _serde::__private228::Err(_serde::de::Error::unknown_variant(__value,
                                        VARIANTS))
                            }
                        }
                    }
                }
                #[automatically_derived]
                impl<'de> _serde::Deserialize<'de> for __Field {
                    #[inline]
                    fn deserialize<__D>(__deserializer: __D)
                        -> _serde::__private228::Result<Self, __D::Error> where
                        __D: _serde::Deserializer<'de> {
                        _serde::Deserializer::deserialize_identifier(__deserializer,
                            __FieldVisitor)
                    }
                }
                #[doc(hidden)]
                struct __Visitor<'de> {
                    marker: _serde::__private228::PhantomData<Applicability>,
                    lifetime: _serde::__private228::PhantomData<&'de ()>,
                }
                #[automatically_derived]
                impl<'de> _serde::de::Visitor<'de> for __Visitor<'de> {
                    type Value = Applicability;
                    fn expecting(&self,
                        __formatter: &mut _serde::__private228::Formatter)
                        -> _serde::__private228::fmt::Result {
                        _serde::__private228::Formatter::write_str(__formatter,
                            "enum Applicability")
                    }
                    fn visit_enum<__A>(self, __data: __A)
                        -> _serde::__private228::Result<Self::Value, __A::Error>
                        where __A: _serde::de::EnumAccess<'de> {
                        match _serde::de::EnumAccess::variant(__data)? {
                            (__Field::__field0, __variant) => {
                                _serde::de::VariantAccess::unit_variant(__variant)?;
                                _serde::__private228::Ok(Applicability::MachineApplicable)
                            }
                            (__Field::__field1, __variant) => {
                                _serde::de::VariantAccess::unit_variant(__variant)?;
                                _serde::__private228::Ok(Applicability::MaybeIncorrect)
                            }
                            (__Field::__field2, __variant) => {
                                _serde::de::VariantAccess::unit_variant(__variant)?;
                                _serde::__private228::Ok(Applicability::HasPlaceholders)
                            }
                            (__Field::__field3, __variant) => {
                                _serde::de::VariantAccess::unit_variant(__variant)?;
                                _serde::__private228::Ok(Applicability::Unspecified)
                            }
                        }
                    }
                }
                #[doc(hidden)]
                const VARIANTS: &'static [&'static str] =
                    &["MachineApplicable", "MaybeIncorrect", "HasPlaceholders",
                                "Unspecified"];
                _serde::Deserializer::deserialize_enum(__deserializer,
                    "Applicability", VARIANTS,
                    __Visitor {
                        marker: _serde::__private228::PhantomData::<Applicability>,
                        lifetime: _serde::__private228::PhantomData,
                    })
            }
        }
    };Deserialize)]
63#[derive(#[automatically_derived]
impl ::core::cmp::PartialEq for Applicability {
    #[inline]
    fn eq(&self, other: &Applicability) -> bool {
        let __self_discr = ::core::intrinsics::discriminant_value(self);
        let __arg1_discr = ::core::intrinsics::discriminant_value(other);
        __self_discr == __arg1_discr
    }
}PartialEq, #[automatically_derived]
impl ::core::cmp::Eq for Applicability {
    #[inline]
    #[doc(hidden)]
    #[coverage(off)]
    fn assert_fields_are_eq(&self) {}
}Eq, #[automatically_derived]
impl ::core::cmp::PartialOrd for Applicability {
    #[inline]
    fn partial_cmp(&self, other: &Applicability)
        -> ::core::option::Option<::core::cmp::Ordering> {
        let __self_discr = ::core::intrinsics::discriminant_value(self);
        let __arg1_discr = ::core::intrinsics::discriminant_value(other);
        ::core::cmp::PartialOrd::partial_cmp(&__self_discr, &__arg1_discr)
    }
}PartialOrd, #[automatically_derived]
impl ::core::cmp::Ord for Applicability {
    #[inline]
    fn cmp(&self, other: &Applicability) -> ::core::cmp::Ordering {
        let __self_discr = ::core::intrinsics::discriminant_value(self);
        let __arg1_discr = ::core::intrinsics::discriminant_value(other);
        ::core::cmp::Ord::cmp(&__self_discr, &__arg1_discr)
    }
}Ord)]
64pub enum Applicability {
65    /// The suggestion is definitely what the user intended, or maintains the exact meaning of the code.
66    /// This suggestion should be automatically applied.
67    ///
68    /// In case of multiple `MachineApplicable` suggestions (whether as part of
69    /// the same `multipart_suggestion` or not), all of them should be
70    /// automatically applied.
71    MachineApplicable,
72
73    /// The suggestion may be what the user intended, but it is uncertain. The suggestion should
74    /// result in valid Rust code if it is applied.
75    MaybeIncorrect,
76
77    /// The suggestion contains placeholders like `(...)` or `{ /* fields */ }`. The suggestion
78    /// cannot be applied automatically because it will not result in valid Rust code. The user
79    /// will need to fill in the placeholders.
80    HasPlaceholders,
81
82    /// The applicability of the suggestion is unknown.
83    Unspecified,
84}
85
86/// Each lint expectation has a `LintExpectationId` assigned by the `LintLevelsBuilder`.
87/// Expected diagnostics get the lint level `Expect` which stores the `LintExpectationId`
88/// to match it with the actual expectation later on.
89///
90/// The `LintExpectationId` has to be stable between compilations, as diagnostic
91/// instances might be loaded from cache. Lint messages can be emitted during an
92/// `EarlyLintPass` operating on the AST and during a `LateLintPass` traversing the
93/// HIR tree. The AST doesn't have enough information to create a stable id. The
94/// `LintExpectationId` will instead store the [`AttrId`] defining the expectation.
95/// These `LintExpectationId` will be updated to use the stable [`HirId`] once the
96/// AST has been lowered. The transformation is done by the `LintLevelsBuilder`
97///
98/// Each lint inside the `expect` attribute is tracked individually, the `lint_index`
99/// identifies the lint inside the attribute and ensures that the IDs are unique.
100///
101/// The index values have a type of `u16` to reduce the size of the `LintExpectationId`.
102/// It's reasonable to assume that no user will define 2^16 attributes on one node or
103/// have that amount of lints listed. `u16` values should therefore suffice.
104#[derive(#[automatically_derived]
impl ::core::clone::Clone for LintExpectationId {
    #[inline]
    fn clone(&self) -> LintExpectationId {
        let _: ::core::clone::AssertParamIsClone<AttrId>;
        let _: ::core::clone::AssertParamIsClone<u16>;
        let _: ::core::clone::AssertParamIsClone<HirId>;
        *self
    }
}Clone, #[automatically_derived]
impl ::core::marker::Copy for LintExpectationId { }Copy, #[automatically_derived]
impl ::core::cmp::PartialEq for LintExpectationId {
    #[inline]
    fn eq(&self, other: &LintExpectationId) -> bool {
        let __self_discr = ::core::intrinsics::discriminant_value(self);
        let __arg1_discr = ::core::intrinsics::discriminant_value(other);
        __self_discr == __arg1_discr &&
            match (self, other) {
                (LintExpectationId::Unstable {
                    attr_id: __self_0, lint_index: __self_1 },
                    LintExpectationId::Unstable {
                    attr_id: __arg1_0, lint_index: __arg1_1 }) =>
                    __self_1 == __arg1_1 && __self_0 == __arg1_0,
                (LintExpectationId::Stable {
                    hir_id: __self_0,
                    attr_id: __self_1,
                    attr_index: __self_2,
                    lint_index: __self_3 }, LintExpectationId::Stable {
                    hir_id: __arg1_0,
                    attr_id: __arg1_1,
                    attr_index: __arg1_2,
                    lint_index: __arg1_3 }) =>
                    __self_2 == __arg1_2 && __self_3 == __arg1_3 &&
                            __self_0 == __arg1_0 && __self_1 == __arg1_1,
                _ => unsafe { ::core::intrinsics::unreachable() }
            }
    }
}PartialEq, #[automatically_derived]
impl ::core::cmp::Eq for LintExpectationId {
    #[inline]
    #[doc(hidden)]
    #[coverage(off)]
    fn assert_fields_are_eq(&self) {
        let _: ::core::cmp::AssertParamIsEq<AttrId>;
        let _: ::core::cmp::AssertParamIsEq<u16>;
        let _: ::core::cmp::AssertParamIsEq<HirId>;
    }
}Eq, #[automatically_derived]
impl ::core::fmt::Debug for LintExpectationId {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        match self {
            LintExpectationId::Unstable {
                attr_id: __self_0, lint_index: __self_1 } =>
                ::core::fmt::Formatter::debug_struct_field2_finish(f,
                    "Unstable", "attr_id", __self_0, "lint_index", &__self_1),
            LintExpectationId::Stable {
                hir_id: __self_0,
                attr_id: __self_1,
                attr_index: __self_2,
                lint_index: __self_3 } =>
                ::core::fmt::Formatter::debug_struct_field4_finish(f,
                    "Stable", "hir_id", __self_0, "attr_id", __self_1,
                    "attr_index", __self_2, "lint_index", &__self_3),
        }
    }
}Debug, #[automatically_derived]
impl ::core::hash::Hash for LintExpectationId {
    #[inline]
    fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) {
        let __self_discr = ::core::intrinsics::discriminant_value(self);
        ::core::hash::Hash::hash(&__self_discr, state);
        match self {
            LintExpectationId::Unstable {
                attr_id: __self_0, lint_index: __self_1 } => {
                ::core::hash::Hash::hash(__self_0, state);
                ::core::hash::Hash::hash(__self_1, state)
            }
            LintExpectationId::Stable {
                hir_id: __self_0,
                attr_id: __self_1,
                attr_index: __self_2,
                lint_index: __self_3 } => {
                ::core::hash::Hash::hash(__self_0, state);
                ::core::hash::Hash::hash(__self_1, state);
                ::core::hash::Hash::hash(__self_2, state);
                ::core::hash::Hash::hash(__self_3, state)
            }
        }
    }
}Hash, const _: () =
    {
        impl<__E: ::rustc_span::SpanEncoder> ::rustc_serialize::Encodable<__E>
            for LintExpectationId {
            fn encode(&self, __encoder: &mut __E) {
                let disc =
                    match *self {
                        LintExpectationId::Unstable {
                            attr_id: ref __binding_0, lint_index: ref __binding_1 } => {
                            0usize
                        }
                        LintExpectationId::Stable {
                            hir_id: ref __binding_0,
                            attr_id: ref __binding_1,
                            attr_index: ref __binding_2,
                            lint_index: ref __binding_3 } => {
                            1usize
                        }
                    };
                ::rustc_serialize::Encoder::emit_u8(__encoder, disc as u8);
                match *self {
                    LintExpectationId::Unstable {
                        attr_id: ref __binding_0, lint_index: ref __binding_1 } => {
                        ::rustc_serialize::Encodable::<__E>::encode(__binding_0,
                            __encoder);
                        ::rustc_serialize::Encodable::<__E>::encode(__binding_1,
                            __encoder);
                    }
                    LintExpectationId::Stable {
                        hir_id: ref __binding_0,
                        attr_id: ref __binding_1,
                        attr_index: ref __binding_2,
                        lint_index: ref __binding_3 } => {
                        ::rustc_serialize::Encodable::<__E>::encode(__binding_0,
                            __encoder);
                        ::rustc_serialize::Encodable::<__E>::encode(__binding_1,
                            __encoder);
                        ::rustc_serialize::Encodable::<__E>::encode(__binding_2,
                            __encoder);
                        ::rustc_serialize::Encodable::<__E>::encode(__binding_3,
                            __encoder);
                    }
                }
            }
        }
    };Encodable, const _: () =
    {
        impl<__D: ::rustc_span::SpanDecoder> ::rustc_serialize::Decodable<__D>
            for LintExpectationId {
            fn decode(__decoder: &mut __D) -> Self {
                match ::rustc_serialize::Decoder::read_u8(__decoder) as usize
                    {
                    0usize => {
                        LintExpectationId::Unstable {
                            attr_id: ::rustc_serialize::Decodable::decode(__decoder),
                            lint_index: ::rustc_serialize::Decodable::decode(__decoder),
                        }
                    }
                    1usize => {
                        LintExpectationId::Stable {
                            hir_id: ::rustc_serialize::Decodable::decode(__decoder),
                            attr_id: ::rustc_serialize::Decodable::decode(__decoder),
                            attr_index: ::rustc_serialize::Decodable::decode(__decoder),
                            lint_index: ::rustc_serialize::Decodable::decode(__decoder),
                        }
                    }
                    n => {
                        ::core::panicking::panic_fmt(format_args!("invalid enum variant tag while decoding `LintExpectationId`, expected 0..2, actual {0}",
                                n));
                    }
                }
            }
        }
    };Decodable)]
105pub enum LintExpectationId {
106    /// Used for lints emitted during the `EarlyLintPass`. This id is not
107    /// hash stable and should not be cached.
108    Unstable { attr_id: AttrId, lint_index: u16 },
109    /// The [`HirId`] that the lint expectation is attached to. This id is
110    /// stable and can be cached. The additional index ensures that nodes with
111    /// several expectations can correctly match diagnostics to the individual
112    /// expectation.
113    Stable { hir_id: HirId, attr_id: AttrId, attr_index: u16, lint_index: u16 },
114}
115
116impl LintExpectationId {
117    pub fn is_stable(&self) -> bool {
118        match self {
119            LintExpectationId::Unstable { .. } => false,
120            LintExpectationId::Stable { .. } => true,
121        }
122    }
123
124    pub fn get_lint_index(&self) -> u16 {
125        let (LintExpectationId::Unstable { lint_index, .. }
126        | LintExpectationId::Stable { lint_index, .. }) = self;
127
128        *lint_index
129    }
130
131    pub fn set_lint_index(&mut self, new_lint_index: u16) {
132        let (LintExpectationId::Unstable { lint_index, .. }
133        | LintExpectationId::Stable { lint_index, .. }) = self;
134
135        *lint_index = new_lint_index
136    }
137}
138
139impl<Hcx: HashStableContext> HashStable<Hcx> for LintExpectationId {
140    #[inline]
141    fn hash_stable(&self, hcx: &mut Hcx, hasher: &mut StableHasher) {
142        match self {
143            LintExpectationId::Stable { hir_id, attr_index, lint_index, .. } => {
144                hir_id.hash_stable(hcx, hasher);
145                attr_index.hash_stable(hcx, hasher);
146                lint_index.hash_stable(hcx, hasher);
147            }
148            _ => {
149                {
    ::core::panicking::panic_fmt(format_args!("internal error: entered unreachable code: {0}",
            format_args!("HashStable should only be called for filled and stable `LintExpectationId`")));
}unreachable!(
150                    "HashStable should only be called for filled and stable `LintExpectationId`"
151                )
152            }
153        }
154    }
155}
156
157impl<Hcx: HashStableContext> ToStableHashKey<Hcx> for LintExpectationId {
158    type KeyType = (DefPathHash, ItemLocalId, u16, u16);
159
160    #[inline]
161    fn to_stable_hash_key(&self, hcx: &mut Hcx) -> Self::KeyType {
162        match self {
163            LintExpectationId::Stable { hir_id, attr_index, lint_index, .. } => {
164                let (def_path_hash, lint_idx) = hir_id.to_stable_hash_key(hcx);
165                (def_path_hash, lint_idx, *attr_index, *lint_index)
166            }
167            _ => {
168                {
    ::core::panicking::panic_fmt(format_args!("internal error: entered unreachable code: {0}",
            format_args!("HashStable should only be called for a filled `LintExpectationId`")));
}unreachable!("HashStable should only be called for a filled `LintExpectationId`")
169            }
170        }
171    }
172}
173
174/// Setting for how to handle a lint.
175///
176/// See: <https://doc.rust-lang.org/rustc/lints/levels.html>
177#[derive(
178    #[automatically_derived]
impl ::core::clone::Clone for Level {
    #[inline]
    fn clone(&self) -> Level { *self }
}Clone,
179    #[automatically_derived]
impl ::core::marker::Copy for Level { }Copy,
180    #[automatically_derived]
impl ::core::cmp::PartialEq for Level {
    #[inline]
    fn eq(&self, other: &Level) -> bool {
        let __self_discr = ::core::intrinsics::discriminant_value(self);
        let __arg1_discr = ::core::intrinsics::discriminant_value(other);
        __self_discr == __arg1_discr
    }
}PartialEq,
181    #[automatically_derived]
impl ::core::cmp::PartialOrd for Level {
    #[inline]
    fn partial_cmp(&self, other: &Level)
        -> ::core::option::Option<::core::cmp::Ordering> {
        let __self_discr = ::core::intrinsics::discriminant_value(self);
        let __arg1_discr = ::core::intrinsics::discriminant_value(other);
        ::core::cmp::PartialOrd::partial_cmp(&__self_discr, &__arg1_discr)
    }
}PartialOrd,
182    #[automatically_derived]
impl ::core::cmp::Eq for Level {
    #[inline]
    #[doc(hidden)]
    #[coverage(off)]
    fn assert_fields_are_eq(&self) {}
}Eq,
183    #[automatically_derived]
impl ::core::cmp::Ord for Level {
    #[inline]
    fn cmp(&self, other: &Level) -> ::core::cmp::Ordering {
        let __self_discr = ::core::intrinsics::discriminant_value(self);
        let __arg1_discr = ::core::intrinsics::discriminant_value(other);
        ::core::cmp::Ord::cmp(&__self_discr, &__arg1_discr)
    }
}Ord,
184    #[automatically_derived]
impl ::core::fmt::Debug for Level {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::write_str(f,
            match self {
                Level::Allow => "Allow",
                Level::Expect => "Expect",
                Level::Warn => "Warn",
                Level::ForceWarn => "ForceWarn",
                Level::Deny => "Deny",
                Level::Forbid => "Forbid",
            })
    }
}Debug,
185    #[automatically_derived]
impl ::core::hash::Hash for Level {
    #[inline]
    fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) {
        let __self_discr = ::core::intrinsics::discriminant_value(self);
        ::core::hash::Hash::hash(&__self_discr, state)
    }
}Hash,
186    const _: () =
    {
        impl<__E: ::rustc_span::SpanEncoder> ::rustc_serialize::Encodable<__E>
            for Level {
            fn encode(&self, __encoder: &mut __E) {
                let disc =
                    match *self {
                        Level::Allow => { 0usize }
                        Level::Expect => { 1usize }
                        Level::Warn => { 2usize }
                        Level::ForceWarn => { 3usize }
                        Level::Deny => { 4usize }
                        Level::Forbid => { 5usize }
                    };
                ::rustc_serialize::Encoder::emit_u8(__encoder, disc as u8);
                match *self {
                    Level::Allow => {}
                    Level::Expect => {}
                    Level::Warn => {}
                    Level::ForceWarn => {}
                    Level::Deny => {}
                    Level::Forbid => {}
                }
            }
        }
    };Encodable,
187    const _: () =
    {
        impl<__D: ::rustc_span::SpanDecoder> ::rustc_serialize::Decodable<__D>
            for Level {
            fn decode(__decoder: &mut __D) -> Self {
                match ::rustc_serialize::Decoder::read_u8(__decoder) as usize
                    {
                    0usize => { Level::Allow }
                    1usize => { Level::Expect }
                    2usize => { Level::Warn }
                    3usize => { Level::ForceWarn }
                    4usize => { Level::Deny }
                    5usize => { Level::Forbid }
                    n => {
                        ::core::panicking::panic_fmt(format_args!("invalid enum variant tag while decoding `Level`, expected 0..6, actual {0}",
                                n));
                    }
                }
            }
        }
    };Decodable,
188    const _: () =
    {
        impl<__CTX> ::rustc_data_structures::stable_hasher::HashStable<__CTX>
            for Level where __CTX: ::rustc_span::HashStableContext {
            #[inline]
            fn hash_stable(&self, __hcx: &mut __CTX,
                __hasher:
                    &mut ::rustc_data_structures::stable_hasher::StableHasher) {
                ::std::mem::discriminant(self).hash_stable(__hcx, __hasher);
                match *self {
                    Level::Allow => {}
                    Level::Expect => {}
                    Level::Warn => {}
                    Level::ForceWarn => {}
                    Level::Deny => {}
                    Level::Forbid => {}
                }
            }
        }
    };HashStable_Generic
189)]
190pub enum Level {
191    /// The `allow` level will not issue any message.
192    Allow,
193    /// The `expect` level will suppress the lint message but in turn produce a message
194    /// if the lint wasn't issued in the expected scope. `Expect` should not be used as
195    /// an initial level for a lint.
196    ///
197    /// Note that this still means that the lint is enabled in this position and should
198    /// be emitted, this will in turn fulfill the expectation and suppress the lint.
199    ///
200    /// See RFC 2383.
201    ///
202    /// Requires a [`LintExpectationId`] to later link a lint emission to the actual
203    /// expectation. It can be ignored in most cases.
204    Expect,
205    /// The `warn` level will produce a warning if the lint was violated, however the
206    /// compiler will continue with its execution.
207    Warn,
208    /// This lint level is a special case of [`Warn`], that can't be overridden. This is used
209    /// to ensure that a lint can't be suppressed. This lint level can currently only be set
210    /// via the console and is therefore session specific.
211    ///
212    /// Requires a [`LintExpectationId`] to fulfill expectations marked via the
213    /// `#[expect]` attribute, that will still be suppressed due to the level.
214    ForceWarn,
215    /// The `deny` level will produce an error and stop further execution after the lint
216    /// pass is complete.
217    Deny,
218    /// `Forbid` is equivalent to the `deny` level but can't be overwritten like the previous
219    /// levels.
220    Forbid,
221}
222
223impl Level {
224    /// Converts a level to a lower-case string.
225    pub fn as_str(self) -> &'static str {
226        match self {
227            Level::Allow => "allow",
228            Level::Expect => "expect",
229            Level::Warn => "warn",
230            Level::ForceWarn => "force-warn",
231            Level::Deny => "deny",
232            Level::Forbid => "forbid",
233        }
234    }
235
236    pub fn from_symbol(x: Symbol) -> Option<Self> {
237        match x {
238            sym::allow => Some(Level::Allow),
239            sym::deny => Some(Level::Deny),
240            sym::expect => Some(Level::Expect),
241            sym::forbid => Some(Level::Forbid),
242            sym::warn => Some(Level::Warn),
243            _ => None,
244        }
245    }
246
247    /// Converts a lower-case string to a level. This will never construct the expect
248    /// level as that would require a [`LintExpectationId`].
249    pub fn from_str(x: &str) -> Option<Self> {
250        match x {
251            "allow" => Some(Level::Allow),
252            "warn" => Some(Level::Warn),
253            "deny" => Some(Level::Deny),
254            "forbid" => Some(Level::Forbid),
255            "expect" | _ => None,
256        }
257    }
258
259    pub fn to_cmd_flag(self) -> &'static str {
260        match self {
261            Level::Warn => "-W",
262            Level::Deny => "-D",
263            Level::Forbid => "-F",
264            Level::Allow => "-A",
265            Level::ForceWarn => "--force-warn",
266            Level::Expect => {
267                {
    ::core::panicking::panic_fmt(format_args!("internal error: entered unreachable code: {0}",
            format_args!("the expect level does not have a commandline flag")));
}unreachable!("the expect level does not have a commandline flag")
268            }
269        }
270    }
271
272    pub fn is_error(self) -> bool {
273        match self {
274            Level::Allow | Level::Expect | Level::Warn | Level::ForceWarn => false,
275            Level::Deny | Level::Forbid => true,
276        }
277    }
278}
279
280impl IntoDiagArg for Level {
281    fn into_diag_arg(self, _: &mut Option<std::path::PathBuf>) -> DiagArgValue {
282        DiagArgValue::Str(Cow::Borrowed(self.to_cmd_flag()))
283    }
284}
285
286/// Specification of a single lint.
287#[derive(#[automatically_derived]
impl ::core::marker::Copy for Lint { }Copy, #[automatically_derived]
impl ::core::clone::Clone for Lint {
    #[inline]
    fn clone(&self) -> Lint {
        let _: ::core::clone::AssertParamIsClone<&'static str>;
        let _: ::core::clone::AssertParamIsClone<Level>;
        let _: ::core::clone::AssertParamIsClone<&'static str>;
        let _: ::core::clone::AssertParamIsClone<Option<(Edition, Level)>>;
        let _: ::core::clone::AssertParamIsClone<bool>;
        let _:
                ::core::clone::AssertParamIsClone<Option<FutureIncompatibleInfo>>;
        let _: ::core::clone::AssertParamIsClone<Option<Symbol>>;
        *self
    }
}Clone, #[automatically_derived]
impl ::core::fmt::Debug for Lint {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        let names: &'static _ =
            &["name", "default_level", "desc", "edition_lint_opts",
                        "report_in_external_macro", "future_incompatible",
                        "is_externally_loaded", "feature_gate", "crate_level_only",
                        "eval_always"];
        let values: &[&dyn ::core::fmt::Debug] =
            &[&self.name, &self.default_level, &self.desc,
                        &self.edition_lint_opts, &self.report_in_external_macro,
                        &self.future_incompatible, &self.is_externally_loaded,
                        &self.feature_gate, &self.crate_level_only,
                        &&self.eval_always];
        ::core::fmt::Formatter::debug_struct_fields_finish(f, "Lint", names,
            values)
    }
}Debug)]
288pub struct Lint {
289    /// A string identifier for the lint.
290    ///
291    /// This identifies the lint in attributes and in command-line arguments.
292    /// In those contexts it is always lowercase, but this field is compared
293    /// in a way which is case-insensitive for ASCII characters. This allows
294    /// `declare_lint!()` invocations to follow the convention of upper-case
295    /// statics without repeating the name.
296    ///
297    /// The name is written with underscores, e.g., "unused_imports".
298    /// On the command line, underscores become dashes.
299    ///
300    /// See <https://rustc-dev-guide.rust-lang.org/diagnostics.html#lint-naming>
301    /// for naming guidelines.
302    pub name: &'static str,
303
304    /// Default level for the lint.
305    ///
306    /// See <https://rustc-dev-guide.rust-lang.org/diagnostics.html#diagnostic-levels>
307    /// for guidelines on choosing a default level.
308    pub default_level: Level,
309
310    /// Description of the lint or the issue it detects.
311    ///
312    /// e.g., "imports that are never used"
313    pub desc: &'static str,
314
315    /// Starting at the given edition, default to the given lint level. If this is `None`, then use
316    /// `default_level`.
317    pub edition_lint_opts: Option<(Edition, Level)>,
318
319    /// `true` if this lint is reported even inside expansions of external macros.
320    pub report_in_external_macro: bool,
321
322    pub future_incompatible: Option<FutureIncompatibleInfo>,
323
324    /// `true` if this lint is being loaded by another tool (e.g. Clippy).
325    pub is_externally_loaded: bool,
326
327    /// `Some` if this lint is feature gated, otherwise `None`.
328    pub feature_gate: Option<Symbol>,
329
330    pub crate_level_only: bool,
331
332    /// `true` if this lint should not be filtered out under any circustamces
333    /// (e.g. the unknown_attributes lint)
334    pub eval_always: bool,
335}
336
337/// Extra information for a future incompatibility lint.
338#[derive(#[automatically_derived]
impl ::core::marker::Copy for FutureIncompatibleInfo { }Copy, #[automatically_derived]
impl ::core::clone::Clone for FutureIncompatibleInfo {
    #[inline]
    fn clone(&self) -> FutureIncompatibleInfo {
        let _: ::core::clone::AssertParamIsClone<FutureIncompatibilityReason>;
        let _: ::core::clone::AssertParamIsClone<bool>;
        *self
    }
}Clone, #[automatically_derived]
impl ::core::fmt::Debug for FutureIncompatibleInfo {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::debug_struct_field3_finish(f,
            "FutureIncompatibleInfo", "reason", &self.reason,
            "explain_reason", &self.explain_reason, "report_in_deps",
            &&self.report_in_deps)
    }
}Debug)]
339pub struct FutureIncompatibleInfo {
340    /// The reason for the lint used by diagnostics to provide
341    /// the right help message
342    pub reason: FutureIncompatibilityReason,
343    /// Whether to explain the reason to the user.
344    ///
345    /// Set to false for lints that already include a more detailed
346    /// explanation.
347    pub explain_reason: bool,
348    /// If set to `true`, this will make future incompatibility warnings show up in cargo's
349    /// reports.
350    ///
351    /// When a future incompatibility warning is first inroduced, set this to `false`
352    /// (or, rather, don't override the default). This allows crate developers an opportunity
353    /// to fix the warning before blasting all dependents with a warning they can't fix
354    /// (dependents have to wait for a new release of the affected crate to be published).
355    ///
356    /// After a lint has been in this state for a while, consider setting this to true, so it
357    /// warns for everyone. It is a good signal that it is ready if you can determine that all
358    /// or most affected crates on crates.io have been updated.
359    pub report_in_deps: bool,
360}
361
362#[derive(#[automatically_derived]
impl ::core::marker::Copy for EditionFcw { }Copy, #[automatically_derived]
impl ::core::clone::Clone for EditionFcw {
    #[inline]
    fn clone(&self) -> EditionFcw {
        let _: ::core::clone::AssertParamIsClone<Edition>;
        let _: ::core::clone::AssertParamIsClone<&'static str>;
        *self
    }
}Clone, #[automatically_derived]
impl ::core::fmt::Debug for EditionFcw {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::debug_struct_field2_finish(f, "EditionFcw",
            "edition", &self.edition, "page_slug", &&self.page_slug)
    }
}Debug)]
363pub struct EditionFcw {
364    pub edition: Edition,
365    pub page_slug: &'static str,
366}
367
368#[derive(#[automatically_derived]
impl ::core::marker::Copy for ReleaseFcw { }Copy, #[automatically_derived]
impl ::core::clone::Clone for ReleaseFcw {
    #[inline]
    fn clone(&self) -> ReleaseFcw {
        let _: ::core::clone::AssertParamIsClone<usize>;
        *self
    }
}Clone, #[automatically_derived]
impl ::core::fmt::Debug for ReleaseFcw {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::debug_struct_field1_finish(f, "ReleaseFcw",
            "issue_number", &&self.issue_number)
    }
}Debug)]
369pub struct ReleaseFcw {
370    pub issue_number: usize,
371}
372
373/// The reason for future incompatibility
374///
375/// Future-incompatible lints come in roughly two categories:
376///
377/// 1. There was a mistake in the compiler (such as a soundness issue), and
378///    we're trying to fix it, but it may be a breaking change.
379/// 2. A change across an Edition boundary, typically used for the
380///    introduction of new language features that can't otherwise be
381///    introduced in a backwards-compatible way.
382///
383/// See <https://rustc-dev-guide.rust-lang.org/bug-fix-procedure.html> and
384/// <https://rustc-dev-guide.rust-lang.org/diagnostics.html#future-incompatible-lints>
385/// for more information.
386#[derive(#[automatically_derived]
impl ::core::marker::Copy for FutureIncompatibilityReason { }Copy, #[automatically_derived]
impl ::core::clone::Clone for FutureIncompatibilityReason {
    #[inline]
    fn clone(&self) -> FutureIncompatibilityReason {
        let _: ::core::clone::AssertParamIsClone<ReleaseFcw>;
        let _: ::core::clone::AssertParamIsClone<EditionFcw>;
        let _: ::core::clone::AssertParamIsClone<&'static str>;
        *self
    }
}Clone, #[automatically_derived]
impl ::core::fmt::Debug for FutureIncompatibilityReason {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        match self {
            FutureIncompatibilityReason::FutureReleaseError(__self_0) =>
                ::core::fmt::Formatter::debug_tuple_field1_finish(f,
                    "FutureReleaseError", &__self_0),
            FutureIncompatibilityReason::FutureReleaseSemanticsChange(__self_0)
                =>
                ::core::fmt::Formatter::debug_tuple_field1_finish(f,
                    "FutureReleaseSemanticsChange", &__self_0),
            FutureIncompatibilityReason::EditionError(__self_0) =>
                ::core::fmt::Formatter::debug_tuple_field1_finish(f,
                    "EditionError", &__self_0),
            FutureIncompatibilityReason::EditionSemanticsChange(__self_0) =>
                ::core::fmt::Formatter::debug_tuple_field1_finish(f,
                    "EditionSemanticsChange", &__self_0),
            FutureIncompatibilityReason::EditionAndFutureReleaseError(__self_0)
                =>
                ::core::fmt::Formatter::debug_tuple_field1_finish(f,
                    "EditionAndFutureReleaseError", &__self_0),
            FutureIncompatibilityReason::EditionAndFutureReleaseSemanticsChange(__self_0)
                =>
                ::core::fmt::Formatter::debug_tuple_field1_finish(f,
                    "EditionAndFutureReleaseSemanticsChange", &__self_0),
            FutureIncompatibilityReason::Custom(__self_0, __self_1) =>
                ::core::fmt::Formatter::debug_tuple_field2_finish(f, "Custom",
                    __self_0, &__self_1),
            FutureIncompatibilityReason::Unreachable =>
                ::core::fmt::Formatter::write_str(f, "Unreachable"),
        }
    }
}Debug)]
387pub enum FutureIncompatibilityReason {
388    /// This will be an error in a future release for all editions
389    ///
390    /// Choose this variant when you are first introducing a "future
391    /// incompatible" warning that is intended to eventually be fixed in the
392    /// future.
393    ///
394    /// After a lint has been in this state for a while and you feel like it is ready to graduate
395    /// to warning everyone, consider setting [`FutureIncompatibleInfo::report_in_deps`] to true.
396    /// (see its documentation for more guidance)
397    ///
398    /// After some period of time, lints with this variant can be turned into
399    /// hard errors (and the lint removed). Preferably when there is some
400    /// confidence that the number of impacted projects is very small (few
401    /// should have a broken dependency in their dependency tree).
402    FutureReleaseError(ReleaseFcw),
403    /// Code that changes meaning in some way in a
404    /// future release.
405    ///
406    /// Choose this variant when the semantics of existing code is changing,
407    /// (as opposed to [`FutureIncompatibilityReason::FutureReleaseError`],
408    /// which is for when code is going to be rejected in the future).
409    FutureReleaseSemanticsChange(ReleaseFcw),
410    /// Previously accepted code that will become an
411    /// error in the provided edition
412    ///
413    /// Choose this variant for code that you want to start rejecting across
414    /// an edition boundary. This will automatically include the lint in the
415    /// `rust-20xx-compatibility` lint group, which is used by `cargo fix
416    /// --edition` to do migrations. The lint *should* be auto-fixable with
417    /// [`Applicability::MachineApplicable`].
418    ///
419    /// The lint can either be `Allow` or `Warn` by default. If it is `Allow`,
420    /// users usually won't see this warning unless they are doing an edition
421    /// migration manually or there is a problem during the migration (cargo's
422    /// automatic migrations will force the level to `Warn`). If it is `Warn`
423    /// by default, users on all editions will see this warning (only do this
424    /// if you think it is important for everyone to be aware of the change,
425    /// and to encourage people to update their code on all editions).
426    ///
427    /// See also [`FutureIncompatibilityReason::EditionSemanticsChange`] if
428    /// you have code that is changing semantics across the edition (as
429    /// opposed to being rejected).
430    EditionError(EditionFcw),
431    /// Code that changes meaning in some way in
432    /// the provided edition
433    ///
434    /// This is the same as [`FutureIncompatibilityReason::EditionError`],
435    /// except for situations where the semantics change across an edition. It
436    /// slightly changes the text of the diagnostic, but is otherwise the
437    /// same.
438    EditionSemanticsChange(EditionFcw),
439    /// This will be an error in the provided edition *and* in a future
440    /// release.
441    ///
442    /// This variant a combination of [`FutureReleaseError`] and [`EditionError`].
443    /// This is useful in rare cases when we want to have "preview" of a breaking
444    /// change in an edition, but do a breaking change later on all editions anyway.
445    ///
446    /// [`EditionError`]: FutureIncompatibilityReason::EditionError
447    /// [`FutureReleaseError`]: FutureIncompatibilityReason::FutureReleaseError
448    EditionAndFutureReleaseError(EditionFcw),
449    /// This will change meaning in the provided edition *and* in a future
450    /// release.
451    ///
452    /// This variant a combination of [`FutureReleaseSemanticsChange`]
453    /// and [`EditionSemanticsChange`]. This is useful in rare cases when we
454    /// want to have "preview" of a breaking change in an edition, but do a
455    /// breaking change later on all editions anyway.
456    ///
457    /// [`EditionSemanticsChange`]: FutureIncompatibilityReason::EditionSemanticsChange
458    /// [`FutureReleaseSemanticsChange`]: FutureIncompatibilityReason::FutureReleaseSemanticsChange
459    EditionAndFutureReleaseSemanticsChange(EditionFcw),
460    /// A custom reason.
461    ///
462    /// Choose this variant if the built-in text of the diagnostic of the
463    /// other variants doesn't match your situation. This is behaviorally
464    /// equivalent to
465    /// [`FutureIncompatibilityReason::FutureReleaseError`].
466    Custom(&'static str, ReleaseFcw),
467
468    /// Using the declare_lint macro a reason always needs to be specified.
469    /// So, this case can't actually be reached but a variant needs to exist for it.
470    /// Any code panics on seeing this variant. Do not use.
471    Unreachable,
472}
473
474impl FutureIncompatibleInfo {
475    pub const fn default_fields_for_macro() -> Self {
476        FutureIncompatibleInfo {
477            reason: FutureIncompatibilityReason::Unreachable,
478            explain_reason: true,
479            report_in_deps: false,
480        }
481    }
482}
483
484impl FutureIncompatibilityReason {
485    pub fn edition(self) -> Option<Edition> {
486        match self {
487            Self::EditionError(e)
488            | Self::EditionSemanticsChange(e)
489            | Self::EditionAndFutureReleaseError(e)
490            | Self::EditionAndFutureReleaseSemanticsChange(e) => Some(e.edition),
491
492            FutureIncompatibilityReason::FutureReleaseError(_)
493            | FutureIncompatibilityReason::FutureReleaseSemanticsChange(_)
494            | FutureIncompatibilityReason::Custom(_, _) => None,
495            Self::Unreachable => ::core::panicking::panic("internal error: entered unreachable code")unreachable!(),
496        }
497    }
498
499    pub fn reference(&self) -> String {
500        match self {
501            Self::FutureReleaseSemanticsChange(release_fcw)
502            | Self::FutureReleaseError(release_fcw)
503            | Self::Custom(_, release_fcw) => release_fcw.to_string(),
504            Self::EditionError(edition_fcw)
505            | Self::EditionSemanticsChange(edition_fcw)
506            | Self::EditionAndFutureReleaseError(edition_fcw)
507            | Self::EditionAndFutureReleaseSemanticsChange(edition_fcw) => edition_fcw.to_string(),
508            Self::Unreachable => ::core::panicking::panic("internal error: entered unreachable code")unreachable!(),
509        }
510    }
511}
512
513impl Display for ReleaseFcw {
514    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
515        let issue_number = self.issue_number;
516        f.write_fmt(format_args!("issue #{0} <https://github.com/rust-lang/rust/issues/{0}>",
        issue_number))write!(f, "issue #{issue_number} <https://github.com/rust-lang/rust/issues/{issue_number}>")
517    }
518}
519
520impl Display for EditionFcw {
521    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
522        f.write_fmt(format_args!("<https://doc.rust-lang.org/edition-guide/{0}/{1}.html>",
        match self.edition {
            Edition::Edition2015 => "rust-2015",
            Edition::Edition2018 => "rust-2018",
            Edition::Edition2021 => "rust-2021",
            Edition::Edition2024 => "rust-2024",
            Edition::EditionFuture => "future",
        }, self.page_slug))write!(
523            f,
524            "<https://doc.rust-lang.org/edition-guide/{}/{}.html>",
525            match self.edition {
526                Edition::Edition2015 => "rust-2015",
527                Edition::Edition2018 => "rust-2018",
528                Edition::Edition2021 => "rust-2021",
529                Edition::Edition2024 => "rust-2024",
530                Edition::EditionFuture => "future",
531            },
532            self.page_slug,
533        )
534    }
535}
536
537impl Lint {
538    pub const fn default_fields_for_macro() -> Self {
539        Lint {
540            name: "",
541            default_level: Level::Forbid,
542            desc: "",
543            edition_lint_opts: None,
544            is_externally_loaded: false,
545            report_in_external_macro: false,
546            future_incompatible: None,
547            feature_gate: None,
548            crate_level_only: false,
549            eval_always: false,
550        }
551    }
552
553    /// Gets the lint's name, with ASCII letters converted to lowercase.
554    pub fn name_lower(&self) -> String {
555        self.name.to_ascii_lowercase()
556    }
557
558    pub fn default_level(&self, edition: Edition) -> Level {
559        self.edition_lint_opts
560            .filter(|(e, _)| *e <= edition)
561            .map(|(_, l)| l)
562            .unwrap_or(self.default_level)
563    }
564}
565
566/// The target of the `by_name` map, which accounts for renaming/deprecation.
567#[derive(#[automatically_derived]
impl ::core::fmt::Debug for TargetLint {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        match self {
            TargetLint::Id(__self_0) =>
                ::core::fmt::Formatter::debug_tuple_field1_finish(f, "Id",
                    &__self_0),
            TargetLint::Renamed(__self_0, __self_1) =>
                ::core::fmt::Formatter::debug_tuple_field2_finish(f,
                    "Renamed", __self_0, &__self_1),
            TargetLint::Removed(__self_0) =>
                ::core::fmt::Formatter::debug_tuple_field1_finish(f,
                    "Removed", &__self_0),
            TargetLint::Ignored =>
                ::core::fmt::Formatter::write_str(f, "Ignored"),
        }
    }
}Debug)]
568pub enum TargetLint {
569    /// A direct lint target
570    Id(LintId),
571
572    /// Temporary renaming, used for easing migration pain; see #16545
573    Renamed(String, LintId),
574
575    /// Lint with this name existed previously, but has been removed/deprecated.
576    /// The string argument is the reason for removal.
577    Removed(String),
578
579    /// A lint name that should give no warnings and have no effect.
580    ///
581    /// This is used by rustc to avoid warning about old rustdoc lints before rustdoc registers
582    /// them as tool lints.
583    Ignored,
584}
585
586/// Identifies a lint known to the compiler.
587#[derive(#[automatically_derived]
impl ::core::clone::Clone for LintId {
    #[inline]
    fn clone(&self) -> LintId {
        let _: ::core::clone::AssertParamIsClone<&'static Lint>;
        *self
    }
}Clone, #[automatically_derived]
impl ::core::marker::Copy for LintId { }Copy, #[automatically_derived]
impl ::core::fmt::Debug for LintId {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::debug_struct_field1_finish(f, "LintId",
            "lint", &&self.lint)
    }
}Debug)]
588pub struct LintId {
589    // Identity is based on pointer equality of this field.
590    pub lint: &'static Lint,
591}
592
593impl PartialEq for LintId {
594    fn eq(&self, other: &LintId) -> bool {
595        std::ptr::eq(self.lint, other.lint)
596    }
597}
598
599impl Eq for LintId {}
600
601impl std::hash::Hash for LintId {
602    fn hash<H: std::hash::Hasher>(&self, state: &mut H) {
603        let ptr = self.lint as *const Lint;
604        ptr.hash(state);
605    }
606}
607
608impl LintId {
609    /// Gets the `LintId` for a `Lint`.
610    pub fn of(lint: &'static Lint) -> LintId {
611        LintId { lint }
612    }
613
614    pub fn lint_name_raw(&self) -> &'static str {
615        self.lint.name
616    }
617
618    /// Gets the name of the lint.
619    pub fn to_string(&self) -> String {
620        self.lint.name_lower()
621    }
622}
623
624impl<Hcx> HashStable<Hcx> for LintId {
625    #[inline]
626    fn hash_stable(&self, hcx: &mut Hcx, hasher: &mut StableHasher) {
627        self.lint_name_raw().hash_stable(hcx, hasher);
628    }
629}
630
631impl<Hcx> ToStableHashKey<Hcx> for LintId {
632    type KeyType = &'static str;
633
634    #[inline]
635    fn to_stable_hash_key(&self, _: &mut Hcx) -> &'static str {
636        self.lint_name_raw()
637    }
638}
639
640impl StableCompare for LintId {
641    const CAN_USE_UNSTABLE_SORT: bool = true;
642
643    fn stable_cmp(&self, other: &Self) -> std::cmp::Ordering {
644        self.lint_name_raw().cmp(&other.lint_name_raw())
645    }
646}
647
648#[derive(#[automatically_derived]
impl ::core::fmt::Debug for DeprecatedSinceKind {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        match self {
            DeprecatedSinceKind::InEffect =>
                ::core::fmt::Formatter::write_str(f, "InEffect"),
            DeprecatedSinceKind::InFuture =>
                ::core::fmt::Formatter::write_str(f, "InFuture"),
            DeprecatedSinceKind::InVersion(__self_0) =>
                ::core::fmt::Formatter::debug_tuple_field1_finish(f,
                    "InVersion", &__self_0),
        }
    }
}Debug, #[automatically_derived]
impl ::core::clone::Clone for DeprecatedSinceKind {
    #[inline]
    fn clone(&self) -> DeprecatedSinceKind {
        match self {
            DeprecatedSinceKind::InEffect => DeprecatedSinceKind::InEffect,
            DeprecatedSinceKind::InFuture => DeprecatedSinceKind::InFuture,
            DeprecatedSinceKind::InVersion(__self_0) =>
                DeprecatedSinceKind::InVersion(::core::clone::Clone::clone(__self_0)),
        }
    }
}Clone)]
649pub enum DeprecatedSinceKind {
650    InEffect,
651    InFuture,
652    InVersion(String),
653}
654
655#[derive(#[automatically_derived]
impl ::core::fmt::Debug for AttributeLintKind {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        match self {
            AttributeLintKind::UnusedDuplicate {
                this: __self_0, other: __self_1, warning: __self_2 } =>
                ::core::fmt::Formatter::debug_struct_field3_finish(f,
                    "UnusedDuplicate", "this", __self_0, "other", __self_1,
                    "warning", &__self_2),
            AttributeLintKind::IllFormedAttributeInput {
                suggestions: __self_0, docs: __self_1, help: __self_2 } =>
                ::core::fmt::Formatter::debug_struct_field3_finish(f,
                    "IllFormedAttributeInput", "suggestions", __self_0, "docs",
                    __self_1, "help", &__self_2),
            AttributeLintKind::EmptyAttribute {
                first_span: __self_0,
                attr_path: __self_1,
                valid_without_list: __self_2 } =>
                ::core::fmt::Formatter::debug_struct_field3_finish(f,
                    "EmptyAttribute", "first_span", __self_0, "attr_path",
                    __self_1, "valid_without_list", &__self_2),
            AttributeLintKind::InvalidTarget {
                name: __self_0,
                target: __self_1,
                applied: __self_2,
                only: __self_3,
                attr_span: __self_4 } =>
                ::core::fmt::Formatter::debug_struct_field5_finish(f,
                    "InvalidTarget", "name", __self_0, "target", __self_1,
                    "applied", __self_2, "only", __self_3, "attr_span",
                    &__self_4),
            AttributeLintKind::InvalidStyle {
                name: __self_0,
                is_used_as_inner: __self_1,
                target: __self_2,
                target_span: __self_3 } =>
                ::core::fmt::Formatter::debug_struct_field4_finish(f,
                    "InvalidStyle", "name", __self_0, "is_used_as_inner",
                    __self_1, "target", __self_2, "target_span", &__self_3),
            AttributeLintKind::UnsafeAttrOutsideUnsafe {
                attribute_name_span: __self_0, sugg_spans: __self_1 } =>
                ::core::fmt::Formatter::debug_struct_field2_finish(f,
                    "UnsafeAttrOutsideUnsafe", "attribute_name_span", __self_0,
                    "sugg_spans", &__self_1),
            AttributeLintKind::UnexpectedCfgName(__self_0, __self_1) =>
                ::core::fmt::Formatter::debug_tuple_field2_finish(f,
                    "UnexpectedCfgName", __self_0, &__self_1),
            AttributeLintKind::UnexpectedCfgValue(__self_0, __self_1) =>
                ::core::fmt::Formatter::debug_tuple_field2_finish(f,
                    "UnexpectedCfgValue", __self_0, &__self_1),
            AttributeLintKind::DuplicateDocAlias { first_definition: __self_0
                } =>
                ::core::fmt::Formatter::debug_struct_field1_finish(f,
                    "DuplicateDocAlias", "first_definition", &__self_0),
            AttributeLintKind::DocAutoCfgExpectsHideOrShow =>
                ::core::fmt::Formatter::write_str(f,
                    "DocAutoCfgExpectsHideOrShow"),
            AttributeLintKind::DocAutoCfgHideShowUnexpectedItem {
                attr_name: __self_0 } =>
                ::core::fmt::Formatter::debug_struct_field1_finish(f,
                    "DocAutoCfgHideShowUnexpectedItem", "attr_name", &__self_0),
            AttributeLintKind::DocAutoCfgHideShowExpectsList {
                attr_name: __self_0 } =>
                ::core::fmt::Formatter::debug_struct_field1_finish(f,
                    "DocAutoCfgHideShowExpectsList", "attr_name", &__self_0),
            AttributeLintKind::DocInvalid =>
                ::core::fmt::Formatter::write_str(f, "DocInvalid"),
            AttributeLintKind::AmbiguousDeriveHelpers =>
                ::core::fmt::Formatter::write_str(f,
                    "AmbiguousDeriveHelpers"),
            AttributeLintKind::DocUnknownInclude {
                span: __self_0, inner: __self_1, value: __self_2 } =>
                ::core::fmt::Formatter::debug_struct_field3_finish(f,
                    "DocUnknownInclude", "span", __self_0, "inner", __self_1,
                    "value", &__self_2),
            AttributeLintKind::DocUnknownSpotlight { span: __self_0 } =>
                ::core::fmt::Formatter::debug_struct_field1_finish(f,
                    "DocUnknownSpotlight", "span", &__self_0),
            AttributeLintKind::DocUnknownPasses {
                name: __self_0, span: __self_1 } =>
                ::core::fmt::Formatter::debug_struct_field2_finish(f,
                    "DocUnknownPasses", "name", __self_0, "span", &__self_1),
            AttributeLintKind::DocUnknownPlugins { span: __self_0 } =>
                ::core::fmt::Formatter::debug_struct_field1_finish(f,
                    "DocUnknownPlugins", "span", &__self_0),
            AttributeLintKind::DocUnknownAny { name: __self_0 } =>
                ::core::fmt::Formatter::debug_struct_field1_finish(f,
                    "DocUnknownAny", "name", &__self_0),
            AttributeLintKind::DocAutoCfgWrongLiteral =>
                ::core::fmt::Formatter::write_str(f,
                    "DocAutoCfgWrongLiteral"),
            AttributeLintKind::DocTestTakesList =>
                ::core::fmt::Formatter::write_str(f, "DocTestTakesList"),
            AttributeLintKind::DocTestUnknown { name: __self_0 } =>
                ::core::fmt::Formatter::debug_struct_field1_finish(f,
                    "DocTestUnknown", "name", &__self_0),
            AttributeLintKind::DocTestLiteral =>
                ::core::fmt::Formatter::write_str(f, "DocTestLiteral"),
            AttributeLintKind::AttrCrateLevelOnly =>
                ::core::fmt::Formatter::write_str(f, "AttrCrateLevelOnly"),
            AttributeLintKind::DoNotRecommendDoesNotExpectArgs =>
                ::core::fmt::Formatter::write_str(f,
                    "DoNotRecommendDoesNotExpectArgs"),
            AttributeLintKind::CrateTypeUnknown {
                span: __self_0, suggested: __self_1 } =>
                ::core::fmt::Formatter::debug_struct_field2_finish(f,
                    "CrateTypeUnknown", "span", __self_0, "suggested",
                    &__self_1),
            AttributeLintKind::MalformedDoc =>
                ::core::fmt::Formatter::write_str(f, "MalformedDoc"),
            AttributeLintKind::ExpectedNoArgs =>
                ::core::fmt::Formatter::write_str(f, "ExpectedNoArgs"),
            AttributeLintKind::ExpectedNameValue =>
                ::core::fmt::Formatter::write_str(f, "ExpectedNameValue"),
            AttributeLintKind::MalformedOnUnimplementedAttr { span: __self_0 }
                =>
                ::core::fmt::Formatter::debug_struct_field1_finish(f,
                    "MalformedOnUnimplementedAttr", "span", &__self_0),
            AttributeLintKind::MalformedOnConstAttr { span: __self_0 } =>
                ::core::fmt::Formatter::debug_struct_field1_finish(f,
                    "MalformedOnConstAttr", "span", &__self_0),
            AttributeLintKind::MalformedOnMoveAttr { span: __self_0 } =>
                ::core::fmt::Formatter::debug_struct_field1_finish(f,
                    "MalformedOnMoveAttr", "span", &__self_0),
            AttributeLintKind::MalformedDiagnosticFormat { warning: __self_0 }
                =>
                ::core::fmt::Formatter::debug_struct_field1_finish(f,
                    "MalformedDiagnosticFormat", "warning", &__self_0),
            AttributeLintKind::DiagnosticWrappedParserError {
                description: __self_0, label: __self_1, span: __self_2 } =>
                ::core::fmt::Formatter::debug_struct_field3_finish(f,
                    "DiagnosticWrappedParserError", "description", __self_0,
                    "label", __self_1, "span", &__self_2),
            AttributeLintKind::IgnoredDiagnosticOption {
                option_name: __self_0,
                first_span: __self_1,
                later_span: __self_2 } =>
                ::core::fmt::Formatter::debug_struct_field3_finish(f,
                    "IgnoredDiagnosticOption", "option_name", __self_0,
                    "first_span", __self_1, "later_span", &__self_2),
            AttributeLintKind::MissingOptionsForOnUnimplemented =>
                ::core::fmt::Formatter::write_str(f,
                    "MissingOptionsForOnUnimplemented"),
            AttributeLintKind::MissingOptionsForOnConst =>
                ::core::fmt::Formatter::write_str(f,
                    "MissingOptionsForOnConst"),
            AttributeLintKind::MissingOptionsForOnMove =>
                ::core::fmt::Formatter::write_str(f,
                    "MissingOptionsForOnMove"),
            AttributeLintKind::OnMoveMalformedFormatLiterals { name: __self_0
                } =>
                ::core::fmt::Formatter::debug_struct_field1_finish(f,
                    "OnMoveMalformedFormatLiterals", "name", &__self_0),
            AttributeLintKind::OnMoveMalformedAttrExpectedLiteralOrDelimiter
                =>
                ::core::fmt::Formatter::write_str(f,
                    "OnMoveMalformedAttrExpectedLiteralOrDelimiter"),
            AttributeLintKind::RenamedLint {
                name: __self_0, replace: __self_1, suggestion: __self_2 } =>
                ::core::fmt::Formatter::debug_struct_field3_finish(f,
                    "RenamedLint", "name", __self_0, "replace", __self_1,
                    "suggestion", &__self_2),
            AttributeLintKind::DeprecatedLintName {
                name: __self_0, suggestion: __self_1, replace: __self_2 } =>
                ::core::fmt::Formatter::debug_struct_field3_finish(f,
                    "DeprecatedLintName", "name", __self_0, "suggestion",
                    __self_1, "replace", &__self_2),
            AttributeLintKind::RemovedLint { name: __self_0, reason: __self_1
                } =>
                ::core::fmt::Formatter::debug_struct_field2_finish(f,
                    "RemovedLint", "name", __self_0, "reason", &__self_1),
            AttributeLintKind::UnknownLint {
                name: __self_0, span: __self_1, suggestion: __self_2 } =>
                ::core::fmt::Formatter::debug_struct_field3_finish(f,
                    "UnknownLint", "name", __self_0, "span", __self_1,
                    "suggestion", &__self_2),
            AttributeLintKind::IgnoredUnlessCrateSpecified {
                level: __self_0, name: __self_1 } =>
                ::core::fmt::Formatter::debug_struct_field2_finish(f,
                    "IgnoredUnlessCrateSpecified", "level", __self_0, "name",
                    &__self_1),
        }
    }
}Debug, const _: () =
    {
        impl<__CTX> ::rustc_data_structures::stable_hasher::HashStable<__CTX>
            for AttributeLintKind where __CTX: ::rustc_span::HashStableContext
            {
            #[inline]
            fn hash_stable(&self, __hcx: &mut __CTX,
                __hasher:
                    &mut ::rustc_data_structures::stable_hasher::StableHasher) {
                ::std::mem::discriminant(self).hash_stable(__hcx, __hasher);
                match *self {
                    AttributeLintKind::UnusedDuplicate {
                        this: ref __binding_0,
                        other: ref __binding_1,
                        warning: ref __binding_2 } => {
                        { __binding_0.hash_stable(__hcx, __hasher); }
                        { __binding_1.hash_stable(__hcx, __hasher); }
                        { __binding_2.hash_stable(__hcx, __hasher); }
                    }
                    AttributeLintKind::IllFormedAttributeInput {
                        suggestions: ref __binding_0,
                        docs: ref __binding_1,
                        help: ref __binding_2 } => {
                        { __binding_0.hash_stable(__hcx, __hasher); }
                        { __binding_1.hash_stable(__hcx, __hasher); }
                        { __binding_2.hash_stable(__hcx, __hasher); }
                    }
                    AttributeLintKind::EmptyAttribute {
                        first_span: ref __binding_0,
                        attr_path: ref __binding_1,
                        valid_without_list: ref __binding_2 } => {
                        { __binding_0.hash_stable(__hcx, __hasher); }
                        { __binding_1.hash_stable(__hcx, __hasher); }
                        { __binding_2.hash_stable(__hcx, __hasher); }
                    }
                    AttributeLintKind::InvalidTarget {
                        name: ref __binding_0,
                        target: ref __binding_1,
                        applied: ref __binding_2,
                        only: ref __binding_3,
                        attr_span: ref __binding_4 } => {
                        { __binding_0.hash_stable(__hcx, __hasher); }
                        { __binding_1.hash_stable(__hcx, __hasher); }
                        { __binding_2.hash_stable(__hcx, __hasher); }
                        { __binding_3.hash_stable(__hcx, __hasher); }
                        { __binding_4.hash_stable(__hcx, __hasher); }
                    }
                    AttributeLintKind::InvalidStyle {
                        name: ref __binding_0,
                        is_used_as_inner: ref __binding_1,
                        target: ref __binding_2,
                        target_span: ref __binding_3 } => {
                        { __binding_0.hash_stable(__hcx, __hasher); }
                        { __binding_1.hash_stable(__hcx, __hasher); }
                        { __binding_2.hash_stable(__hcx, __hasher); }
                        { __binding_3.hash_stable(__hcx, __hasher); }
                    }
                    AttributeLintKind::UnsafeAttrOutsideUnsafe {
                        attribute_name_span: ref __binding_0,
                        sugg_spans: ref __binding_1 } => {
                        { __binding_0.hash_stable(__hcx, __hasher); }
                        { __binding_1.hash_stable(__hcx, __hasher); }
                    }
                    AttributeLintKind::UnexpectedCfgName(ref __binding_0,
                        ref __binding_1) => {
                        { __binding_0.hash_stable(__hcx, __hasher); }
                        { __binding_1.hash_stable(__hcx, __hasher); }
                    }
                    AttributeLintKind::UnexpectedCfgValue(ref __binding_0,
                        ref __binding_1) => {
                        { __binding_0.hash_stable(__hcx, __hasher); }
                        { __binding_1.hash_stable(__hcx, __hasher); }
                    }
                    AttributeLintKind::DuplicateDocAlias {
                        first_definition: ref __binding_0 } => {
                        { __binding_0.hash_stable(__hcx, __hasher); }
                    }
                    AttributeLintKind::DocAutoCfgExpectsHideOrShow => {}
                    AttributeLintKind::DocAutoCfgHideShowUnexpectedItem {
                        attr_name: ref __binding_0 } => {
                        { __binding_0.hash_stable(__hcx, __hasher); }
                    }
                    AttributeLintKind::DocAutoCfgHideShowExpectsList {
                        attr_name: ref __binding_0 } => {
                        { __binding_0.hash_stable(__hcx, __hasher); }
                    }
                    AttributeLintKind::DocInvalid => {}
                    AttributeLintKind::AmbiguousDeriveHelpers => {}
                    AttributeLintKind::DocUnknownInclude {
                        span: ref __binding_0,
                        inner: ref __binding_1,
                        value: ref __binding_2 } => {
                        { __binding_0.hash_stable(__hcx, __hasher); }
                        { __binding_1.hash_stable(__hcx, __hasher); }
                        { __binding_2.hash_stable(__hcx, __hasher); }
                    }
                    AttributeLintKind::DocUnknownSpotlight {
                        span: ref __binding_0 } => {
                        { __binding_0.hash_stable(__hcx, __hasher); }
                    }
                    AttributeLintKind::DocUnknownPasses {
                        name: ref __binding_0, span: ref __binding_1 } => {
                        { __binding_0.hash_stable(__hcx, __hasher); }
                        { __binding_1.hash_stable(__hcx, __hasher); }
                    }
                    AttributeLintKind::DocUnknownPlugins { span: ref __binding_0
                        } => {
                        { __binding_0.hash_stable(__hcx, __hasher); }
                    }
                    AttributeLintKind::DocUnknownAny { name: ref __binding_0 }
                        => {
                        { __binding_0.hash_stable(__hcx, __hasher); }
                    }
                    AttributeLintKind::DocAutoCfgWrongLiteral => {}
                    AttributeLintKind::DocTestTakesList => {}
                    AttributeLintKind::DocTestUnknown { name: ref __binding_0 }
                        => {
                        { __binding_0.hash_stable(__hcx, __hasher); }
                    }
                    AttributeLintKind::DocTestLiteral => {}
                    AttributeLintKind::AttrCrateLevelOnly => {}
                    AttributeLintKind::DoNotRecommendDoesNotExpectArgs => {}
                    AttributeLintKind::CrateTypeUnknown {
                        span: ref __binding_0, suggested: ref __binding_1 } => {
                        { __binding_0.hash_stable(__hcx, __hasher); }
                        { __binding_1.hash_stable(__hcx, __hasher); }
                    }
                    AttributeLintKind::MalformedDoc => {}
                    AttributeLintKind::ExpectedNoArgs => {}
                    AttributeLintKind::ExpectedNameValue => {}
                    AttributeLintKind::MalformedOnUnimplementedAttr {
                        span: ref __binding_0 } => {
                        { __binding_0.hash_stable(__hcx, __hasher); }
                    }
                    AttributeLintKind::MalformedOnConstAttr {
                        span: ref __binding_0 } => {
                        { __binding_0.hash_stable(__hcx, __hasher); }
                    }
                    AttributeLintKind::MalformedOnMoveAttr {
                        span: ref __binding_0 } => {
                        { __binding_0.hash_stable(__hcx, __hasher); }
                    }
                    AttributeLintKind::MalformedDiagnosticFormat {
                        warning: ref __binding_0 } => {
                        { __binding_0.hash_stable(__hcx, __hasher); }
                    }
                    AttributeLintKind::DiagnosticWrappedParserError {
                        description: ref __binding_0,
                        label: ref __binding_1,
                        span: ref __binding_2 } => {
                        { __binding_0.hash_stable(__hcx, __hasher); }
                        { __binding_1.hash_stable(__hcx, __hasher); }
                        { __binding_2.hash_stable(__hcx, __hasher); }
                    }
                    AttributeLintKind::IgnoredDiagnosticOption {
                        option_name: ref __binding_0,
                        first_span: ref __binding_1,
                        later_span: ref __binding_2 } => {
                        { __binding_0.hash_stable(__hcx, __hasher); }
                        { __binding_1.hash_stable(__hcx, __hasher); }
                        { __binding_2.hash_stable(__hcx, __hasher); }
                    }
                    AttributeLintKind::MissingOptionsForOnUnimplemented => {}
                    AttributeLintKind::MissingOptionsForOnConst => {}
                    AttributeLintKind::MissingOptionsForOnMove => {}
                    AttributeLintKind::OnMoveMalformedFormatLiterals {
                        name: ref __binding_0 } => {
                        { __binding_0.hash_stable(__hcx, __hasher); }
                    }
                    AttributeLintKind::OnMoveMalformedAttrExpectedLiteralOrDelimiter
                        => {}
                    AttributeLintKind::RenamedLint {
                        name: ref __binding_0,
                        replace: ref __binding_1,
                        suggestion: ref __binding_2 } => {
                        { __binding_0.hash_stable(__hcx, __hasher); }
                        { __binding_1.hash_stable(__hcx, __hasher); }
                        { __binding_2.hash_stable(__hcx, __hasher); }
                    }
                    AttributeLintKind::DeprecatedLintName {
                        name: ref __binding_0,
                        suggestion: ref __binding_1,
                        replace: ref __binding_2 } => {
                        { __binding_0.hash_stable(__hcx, __hasher); }
                        { __binding_1.hash_stable(__hcx, __hasher); }
                        { __binding_2.hash_stable(__hcx, __hasher); }
                    }
                    AttributeLintKind::RemovedLint {
                        name: ref __binding_0, reason: ref __binding_1 } => {
                        { __binding_0.hash_stable(__hcx, __hasher); }
                        { __binding_1.hash_stable(__hcx, __hasher); }
                    }
                    AttributeLintKind::UnknownLint {
                        name: ref __binding_0,
                        span: ref __binding_1,
                        suggestion: ref __binding_2 } => {
                        { __binding_0.hash_stable(__hcx, __hasher); }
                        { __binding_1.hash_stable(__hcx, __hasher); }
                        { __binding_2.hash_stable(__hcx, __hasher); }
                    }
                    AttributeLintKind::IgnoredUnlessCrateSpecified {
                        level: ref __binding_0, name: ref __binding_1 } => {
                        { __binding_0.hash_stable(__hcx, __hasher); }
                        { __binding_1.hash_stable(__hcx, __hasher); }
                    }
                }
            }
        }
    };HashStable_Generic)]
656pub enum AttributeLintKind {
657    UnusedDuplicate {
658        this: Span,
659        other: Span,
660        warning: bool,
661    },
662    IllFormedAttributeInput {
663        suggestions: Vec<String>,
664        docs: Option<&'static str>,
665        help: Option<String>,
666    },
667    EmptyAttribute {
668        first_span: Span,
669        attr_path: String,
670        valid_without_list: bool,
671    },
672    InvalidTarget {
673        name: String,
674        target: &'static str,
675        applied: Vec<String>,
676        only: &'static str,
677        attr_span: Span,
678    },
679    InvalidStyle {
680        name: String,
681        is_used_as_inner: bool,
682        target: &'static str,
683        target_span: Span,
684    },
685    UnsafeAttrOutsideUnsafe {
686        attribute_name_span: Span,
687        sugg_spans: Option<(Span, Span)>,
688    },
689    UnexpectedCfgName((Symbol, Span), Option<(Symbol, Span)>),
690    UnexpectedCfgValue((Symbol, Span), Option<(Symbol, Span)>),
691    DuplicateDocAlias {
692        first_definition: Span,
693    },
694    DocAutoCfgExpectsHideOrShow,
695    DocAutoCfgHideShowUnexpectedItem {
696        attr_name: Symbol,
697    },
698    DocAutoCfgHideShowExpectsList {
699        attr_name: Symbol,
700    },
701    DocInvalid,
702    AmbiguousDeriveHelpers,
703    DocUnknownInclude {
704        span: Span,
705        inner: &'static str,
706        value: Symbol,
707    },
708    DocUnknownSpotlight {
709        span: Span,
710    },
711    DocUnknownPasses {
712        name: Symbol,
713        span: Span,
714    },
715    DocUnknownPlugins {
716        span: Span,
717    },
718    DocUnknownAny {
719        name: Symbol,
720    },
721    DocAutoCfgWrongLiteral,
722    DocTestTakesList,
723    DocTestUnknown {
724        name: Symbol,
725    },
726    DocTestLiteral,
727    AttrCrateLevelOnly,
728    DoNotRecommendDoesNotExpectArgs,
729    CrateTypeUnknown {
730        span: Span,
731        suggested: Option<Symbol>,
732    },
733    MalformedDoc,
734    ExpectedNoArgs,
735    ExpectedNameValue,
736    MalformedOnUnimplementedAttr {
737        span: Span,
738    },
739    MalformedOnConstAttr {
740        span: Span,
741    },
742    MalformedOnMoveAttr {
743        span: Span,
744    },
745    MalformedDiagnosticFormat {
746        warning: FormatWarning,
747    },
748    DiagnosticWrappedParserError {
749        description: String,
750        label: String,
751        span: Span,
752    },
753    IgnoredDiagnosticOption {
754        option_name: Symbol,
755        first_span: Span,
756        later_span: Span,
757    },
758    MissingOptionsForOnUnimplemented,
759    MissingOptionsForOnConst,
760    MissingOptionsForOnMove,
761    OnMoveMalformedFormatLiterals {
762        name: Symbol,
763    },
764    OnMoveMalformedAttrExpectedLiteralOrDelimiter,
765    RenamedLint {
766        name: Symbol,
767        replace: Symbol,
768        suggestion: Span,
769    },
770    DeprecatedLintName {
771        name: Symbol,
772        suggestion: Span,
773        replace: Symbol,
774    },
775    RemovedLint {
776        name: Symbol,
777        reason: String,
778    },
779    UnknownLint {
780        name: Symbol,
781        span: Span,
782        suggestion: Option<(Symbol, bool)>,
783    },
784    IgnoredUnlessCrateSpecified {
785        level: Symbol,
786        name: Symbol,
787    },
788}
789
790#[derive(#[automatically_derived]
impl ::core::fmt::Debug for FormatWarning {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        match self {
            FormatWarning::PositionalArgument { span: __self_0, help: __self_1
                } =>
                ::core::fmt::Formatter::debug_struct_field2_finish(f,
                    "PositionalArgument", "span", __self_0, "help", &__self_1),
            FormatWarning::InvalidSpecifier { name: __self_0, span: __self_1 }
                =>
                ::core::fmt::Formatter::debug_struct_field2_finish(f,
                    "InvalidSpecifier", "name", __self_0, "span", &__self_1),
        }
    }
}Debug, #[automatically_derived]
impl ::core::clone::Clone for FormatWarning {
    #[inline]
    fn clone(&self) -> FormatWarning {
        match self {
            FormatWarning::PositionalArgument { span: __self_0, help: __self_1
                } =>
                FormatWarning::PositionalArgument {
                    span: ::core::clone::Clone::clone(__self_0),
                    help: ::core::clone::Clone::clone(__self_1),
                },
            FormatWarning::InvalidSpecifier { name: __self_0, span: __self_1 }
                =>
                FormatWarning::InvalidSpecifier {
                    name: ::core::clone::Clone::clone(__self_0),
                    span: ::core::clone::Clone::clone(__self_1),
                },
        }
    }
}Clone, const _: () =
    {
        impl<__CTX> ::rustc_data_structures::stable_hasher::HashStable<__CTX>
            for FormatWarning where __CTX: ::rustc_span::HashStableContext {
            #[inline]
            fn hash_stable(&self, __hcx: &mut __CTX,
                __hasher:
                    &mut ::rustc_data_structures::stable_hasher::StableHasher) {
                ::std::mem::discriminant(self).hash_stable(__hcx, __hasher);
                match *self {
                    FormatWarning::PositionalArgument {
                        span: ref __binding_0, help: ref __binding_1 } => {
                        { __binding_0.hash_stable(__hcx, __hasher); }
                        { __binding_1.hash_stable(__hcx, __hasher); }
                    }
                    FormatWarning::InvalidSpecifier {
                        name: ref __binding_0, span: ref __binding_1 } => {
                        { __binding_0.hash_stable(__hcx, __hasher); }
                        { __binding_1.hash_stable(__hcx, __hasher); }
                    }
                }
            }
        }
    };HashStable_Generic)]
791pub enum FormatWarning {
792    PositionalArgument { span: Span, help: String },
793    InvalidSpecifier { name: String, span: Span },
794}
795
796#[derive(#[automatically_derived]
impl<'a> ::core::fmt::Debug for CheckLintNameResult<'a> {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        match self {
            CheckLintNameResult::Ok(__self_0) =>
                ::core::fmt::Formatter::debug_tuple_field1_finish(f, "Ok",
                    &__self_0),
            CheckLintNameResult::NoLint(__self_0) =>
                ::core::fmt::Formatter::debug_tuple_field1_finish(f, "NoLint",
                    &__self_0),
            CheckLintNameResult::NoTool =>
                ::core::fmt::Formatter::write_str(f, "NoTool"),
            CheckLintNameResult::Renamed(__self_0) =>
                ::core::fmt::Formatter::debug_tuple_field1_finish(f,
                    "Renamed", &__self_0),
            CheckLintNameResult::RenamedToolLint(__self_0) =>
                ::core::fmt::Formatter::debug_tuple_field1_finish(f,
                    "RenamedToolLint", &__self_0),
            CheckLintNameResult::Removed(__self_0) =>
                ::core::fmt::Formatter::debug_tuple_field1_finish(f,
                    "Removed", &__self_0),
            CheckLintNameResult::Tool(__self_0, __self_1) =>
                ::core::fmt::Formatter::debug_tuple_field2_finish(f, "Tool",
                    __self_0, &__self_1),
            CheckLintNameResult::MissingTool =>
                ::core::fmt::Formatter::write_str(f, "MissingTool"),
        }
    }
}Debug)]
797pub enum CheckLintNameResult<'a> {
798    Ok(&'a [LintId]),
799    /// Lint doesn't exist. Potentially contains a suggestion for a correct lint name.
800    NoLint(Option<(Symbol, bool)>),
801    /// The lint refers to a tool that has not been registered.
802    NoTool,
803    /// The lint has been renamed to a new name.
804    Renamed(Symbol),
805    /// Lint that previously was part of rustc, but now is part of external lint tool
806    RenamedToolLint(Symbol),
807    /// The lint has been removed due to the given reason.
808    Removed(String),
809
810    /// The lint is from a tool. The `LintId` will be returned as if it were a
811    /// rustc lint. The `Option<String>` indicates if the lint has been
812    /// renamed.
813    Tool(&'a [LintId], Option<String>),
814
815    /// The lint is from a tool. Either the lint does not exist in the tool or
816    /// the code was not compiled with the tool and therefore the lint was
817    /// never added to the `LintStore`.
818    MissingTool,
819}
820
821pub type RegisteredTools = FxIndexSet<Ident>;
822
823/// Declares a static item of type `&'static Lint`.
824///
825/// See <https://rustc-dev-guide.rust-lang.org/diagnostics.html> for
826/// documentation and guidelines on writing lints.
827///
828/// The macro call should start with a doc comment explaining the lint
829/// which will be embedded in the rustc user documentation book. It should
830/// be written in markdown and have a format that looks like this:
831///
832/// ```rust,ignore (doc-example)
833/// /// The `my_lint_name` lint detects [short explanation here].
834/// ///
835/// /// ### Example
836/// ///
837/// /// ```rust
838/// /// [insert a concise example that triggers the lint]
839/// /// ```
840/// ///
841/// /// {{produces}}
842/// ///
843/// /// ### Explanation
844/// ///
845/// /// This should be a detailed explanation of *why* the lint exists,
846/// /// and also include suggestions on how the user should fix the problem.
847/// /// Try to keep the text simple enough that a beginner can understand,
848/// /// and include links to other documentation for terminology that a
849/// /// beginner may not be familiar with. If this is "allow" by default,
850/// /// it should explain why (are there false positives or other issues?). If
851/// /// this is a future-incompatible lint, it should say so, with text that
852/// /// looks roughly like this:
853/// ///
854/// /// This is a [future-incompatible] lint to transition this to a hard
855/// /// error in the future. See [issue #xxxxx] for more details.
856/// ///
857/// /// [issue #xxxxx]: https://github.com/rust-lang/rust/issues/xxxxx
858/// ```
859///
860/// The `{{produces}}` tag will be automatically replaced with the output from
861/// the example by the build system. If the lint example is too complex to run
862/// as a simple example (for example, it needs an extern crate), mark the code
863/// block with `ignore` and manually replace the `{{produces}}` line with the
864/// expected output in a `text` code block.
865///
866/// If this is a rustdoc-only lint, then only include a brief introduction
867/// with a link with the text `[rustdoc book]` so that the validator knows
868/// that this is for rustdoc only (see BROKEN_INTRA_DOC_LINKS as an example).
869///
870/// Commands to view and test the documentation:
871///
872/// * `./x.py doc --stage=1 src/doc/rustc --open`: Builds the rustc book and opens it.
873/// * `./x.py test src/tools/lint-docs`: Validates that the lint docs have the
874///   correct style, and that the code example actually emits the expected
875///   lint.
876///
877/// If you have already built the compiler, and you want to make changes to
878/// just the doc comments, then use the `--keep-stage=0` flag with the above
879/// commands to avoid rebuilding the compiler.
880#[macro_export]
881macro_rules! declare_lint {
882    ($(#[$attr:meta])* $vis: vis $NAME: ident, $Level: ident, $desc: expr) => (
883        $crate::declare_lint!(
884            $(#[$attr])* $vis $NAME, $Level, $desc,
885        );
886    );
887    ($(#[$attr:meta])* $vis: vis $NAME: ident, $Level: ident, $desc: expr,
888     $(@eval_always = $eval_always:literal)?
889     $(@feature_gate = $gate:ident;)?
890     $(@future_incompatible = FutureIncompatibleInfo {
891        reason: $reason:expr,
892        $($field:ident : $val:expr),* $(,)*
893     }; )?
894     $(@edition $lint_edition:ident => $edition_level:ident;)?
895     $($v:ident),*) => (
896        $(#[$attr])*
897        $vis static $NAME: &$crate::Lint = &$crate::Lint {
898            name: stringify!($NAME),
899            default_level: $crate::$Level,
900            desc: $desc,
901            is_externally_loaded: false,
902            $($v: true,)*
903            $(feature_gate: Some(rustc_span::sym::$gate),)?
904            $(future_incompatible: Some($crate::FutureIncompatibleInfo {
905                reason: $reason,
906                $($field: $val,)*
907                ..$crate::FutureIncompatibleInfo::default_fields_for_macro()
908            }),)?
909            $(edition_lint_opts: Some(($crate::Edition::$lint_edition, $crate::$edition_level)),)?
910            $(eval_always: $eval_always,)?
911            ..$crate::Lint::default_fields_for_macro()
912        };
913    );
914}
915
916#[macro_export]
917macro_rules! declare_tool_lint {
918    (
919        $(#[$attr:meta])* $vis:vis $tool:ident ::$NAME:ident, $Level: ident, $desc: expr
920        $(, @eval_always = $eval_always:literal)?
921        $(, @feature_gate = $gate:ident;)?
922    ) => (
923        $crate::declare_tool_lint!{$(#[$attr])* $vis $tool::$NAME, $Level, $desc, false $(, @eval_always = $eval_always)? $(, @feature_gate = $gate;)?}
924    );
925    (
926        $(#[$attr:meta])* $vis:vis $tool:ident ::$NAME:ident, $Level:ident, $desc:expr,
927        report_in_external_macro: $rep:expr
928        $(, @eval_always = $eval_always: literal)?
929        $(, @feature_gate = $gate:ident;)?
930    ) => (
931         $crate::declare_tool_lint!{$(#[$attr])* $vis $tool::$NAME, $Level, $desc, $rep  $(, @eval_always = $eval_always)? $(, @feature_gate = $gate;)?}
932    );
933    (
934        $(#[$attr:meta])* $vis:vis $tool:ident ::$NAME:ident, $Level:ident, $desc:expr,
935        $external:expr
936        $(, @eval_always = $eval_always: literal)?
937        $(, @feature_gate = $gate:ident;)?
938    ) => (
939        $(#[$attr])*
940        $vis static $NAME: &$crate::Lint = &$crate::Lint {
941            name: &concat!(stringify!($tool), "::", stringify!($NAME)),
942            default_level: $crate::$Level,
943            desc: $desc,
944            edition_lint_opts: None,
945            report_in_external_macro: $external,
946            future_incompatible: None,
947            is_externally_loaded: true,
948            $(feature_gate: Some(rustc_span::sym::$gate),)?
949            crate_level_only: false,
950            $(eval_always: $eval_always,)?
951            ..$crate::Lint::default_fields_for_macro()
952        };
953    );
954}
955
956pub type LintVec = Vec<&'static Lint>;
957
958pub trait LintPass {
959    fn name(&self) -> &'static str;
960    fn get_lints(&self) -> LintVec;
961}
962
963/// Implements `LintPass for $ty` with the given list of `Lint` statics.
964#[macro_export]
965macro_rules! impl_lint_pass {
966    ($ty:ty => [$($lint:expr),* $(,)?]) => {
967        impl $crate::LintPass for $ty {
968            fn name(&self) -> &'static str { stringify!($ty) }
969            fn get_lints(&self) -> $crate::LintVec { vec![$($lint),*] }
970        }
971        impl $ty {
972            #[allow(unused)]
973            pub fn lint_vec() -> $crate::LintVec { vec![$($lint),*] }
974        }
975    };
976}
977
978/// Declares a type named `$name` which implements `LintPass`.
979/// To the right of `=>` a comma separated list of `Lint` statics is given.
980#[macro_export]
981macro_rules! declare_lint_pass {
982    ($(#[$m:meta])* $name:ident => [$($lint:expr),* $(,)?]) => {
983        $(#[$m])* #[derive(Copy, Clone)] pub struct $name;
984        $crate::impl_lint_pass!($name => [$($lint),*]);
985    };
986}
987
988#[macro_export]
989macro_rules! fcw {
990    (FutureReleaseError # $issue_number: literal) => {
991       $crate:: FutureIncompatibilityReason::FutureReleaseError($crate::ReleaseFcw { issue_number: $issue_number })
992    };
993    (FutureReleaseSemanticsChange # $issue_number: literal) => {
994        $crate::FutureIncompatibilityReason::FutureReleaseSemanticsChange($crate::ReleaseFcw {
995            issue_number: $issue_number,
996        })
997    };
998    ($description: literal # $issue_number: literal) => {
999        $crate::FutureIncompatibilityReason::Custom($description, $crate::ReleaseFcw {
1000            issue_number: $issue_number,
1001        })
1002    };
1003    (EditionError $edition_name: tt $page_slug: literal) => {
1004        $crate::FutureIncompatibilityReason::EditionError($crate::EditionFcw {
1005            edition: fcw!(@edition $edition_name),
1006            page_slug: $page_slug,
1007        })
1008    };
1009    (EditionSemanticsChange $edition_name: tt $page_slug: literal) => {
1010        $crate::FutureIncompatibilityReason::EditionSemanticsChange($crate::EditionFcw {
1011            edition: fcw!(@edition $edition_name),
1012            page_slug: $page_slug,
1013        })
1014    };
1015    (EditionAndFutureReleaseSemanticsChange $edition_name: tt $page_slug: literal) => {
1016        $crate::FutureIncompatibilityReason::EditionAndFutureReleaseSemanticsChange($crate::EditionFcw {
1017            edition: fcw!(@edition $edition_name),
1018            page_slug: $page_slug,
1019        })
1020    };
1021    (EditionAndFutureReleaseError $edition_name: tt $page_slug: literal) => {
1022        $crate::FutureIncompatibilityReason::EditionAndFutureReleaseError($crate::EditionFcw {
1023            edition: fcw!(@edition $edition_name),
1024            page_slug: $page_slug,
1025        })
1026    };
1027    (@edition 2024) => {
1028        rustc_span::edition::Edition::Edition2024
1029    };
1030    (@edition 2021) => {
1031        rustc_span::edition::Edition::Edition2021
1032    };
1033    (@edition 2018) => {
1034        rustc_span::edition::Edition::Edition2018
1035    };
1036}