Skip to main content

rustc_lint_defs/
lib.rs

1// tidy-alphabetical-start
2#![allow(internal_features)]
3#![feature(allow_internal_unstable)]
4#![feature(default_field_values)]
5// tidy-alphabetical-end
6
7use std::borrow::Cow;
8use std::fmt::Display;
9
10pub use lint_name::LintName;
11use rustc_ast::attr::version::RustcVersion;
12use rustc_data_structures::fx::FxIndexMap;
13use rustc_data_structures::stable_hash::{StableCompare, StableHash, StableHashCtxt, StableHasher};
14use rustc_error_messages::{DiagArgValue, IntoDiagArg};
15use rustc_hir_id::HirId;
16use rustc_macros::{Decodable, Encodable, StableHash};
17use rustc_span::edition::Edition;
18use rustc_span::{AttrId, Ident, Symbol, sym};
19use serde::{Deserialize, Serialize};
20
21pub use self::Level::*;
22use crate::Reflectiveness::{NonReflective, Reflective};
23
24pub mod builtin;
25mod lint_name;
26
27#[macro_export]
28macro_rules! pluralize {
29    // Pluralize based on count (e.g., apples)
30    ($x:expr) => {
31        if $x == 1 { "" } else { "s" }
32    };
33    ("has", $x:expr) => {
34        if $x == 1 { "has" } else { "have" }
35    };
36    ("is", $x:expr) => {
37        if $x == 1 { "is" } else { "are" }
38    };
39    ("was", $x:expr) => {
40        if $x == 1 { "was" } else { "were" }
41    };
42    ("this", $x:expr) => {
43        if $x == 1 { "this" } else { "these" }
44    };
45}
46
47/// Grammatical tool for displaying messages to end users in a nice form.
48///
49/// Take a list of items and a function to turn those items into a `String`, and output a display
50/// friendly comma separated list of those items.
51// FIXME(estebank): this needs to be changed to go through the translation machinery.
52pub fn listify<T>(list: &[T], fmt: impl Fn(&T) -> String) -> Option<String> {
53    Some(match list {
54        [only] => fmt(&only),
55        [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!(
56            "{} and {}",
57            others.iter().map(|i| fmt(i)).collect::<Vec<_>>().join(", "),
58            fmt(&last),
59        ),
60        [] => return None,
61    })
62}
63
64/// Indicates the confidence in the correctness of a suggestion.
65///
66/// All suggestions are marked with an `Applicability`. Tools use the applicability of a suggestion
67/// to determine whether it should be automatically applied or if the user should be consulted
68/// before applying the suggestion.
69#[derive(#[automatically_derived]impl ::core::marker::Copy for Applicability { }Copy, #[automatically_derived]#[doc(hidden)]unsafe impl ::core::clone::TrivialClone
    for Applicability {
}
#[automatically_derived]impl ::core::clone::Clone for Applicability {
    #[inline]
    #[rustc_trivial_field_reads]
    fn clone(&self) -> Self { *self }
}Clone, #[automatically_derived]impl ::core::fmt::Debug for Applicability {
    #[inline]
    #[rustc_trivial_field_reads]
    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) {
        ::core::hash::Hash::hash(&::core::intrinsics::discriminant_value(self),
            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);
            }
        }
    };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)]
70#[derive(#[automatically_derived]impl ::core::marker::StructuralPartialEq for
    Applicability {
}
#[automatically_derived]impl ::core::cmp::PartialEq for Applicability {
    #[inline]
    fn eq(&self, other: &Self) -> bool {
        ::core::intrinsics::discriminant_value(self) ==
            ::core::intrinsics::discriminant_value(other)
    }
}PartialEq, #[automatically_derived]impl ::core::cmp::Eq for Applicability { }Eq, #[automatically_derived]impl ::core::cmp::PartialOrd for Applicability {
    #[inline]
    fn partial_cmp(&self, other: &Self)
        -> ::core::option::Option<::core::cmp::Ordering> {
        ::core::option::Option::Some(::core::cmp::Ord::cmp(self, other))
    }
}PartialOrd, #[automatically_derived]impl ::core::cmp::Ord for Applicability {
    #[inline]
    fn cmp(&self, other: &Self) -> ::core::cmp::Ordering {
        ::core::cmp::Ord::cmp(&::core::intrinsics::discriminant_value(self),
            &::core::intrinsics::discriminant_value(other))
    }
}Ord)]
71pub enum Applicability {
72    /// The suggestion is definitely what the user intended, or maintains the exact meaning of the code.
73    /// This suggestion should be automatically applied.
74    ///
75    /// In case of multiple `MachineApplicable` suggestions (whether as part of
76    /// the same `multipart_suggestion` or not), all of them should be
77    /// automatically applied.
78    MachineApplicable,
79
80    /// The suggestion may be what the user intended, but it is uncertain. The suggestion should
81    /// result in valid Rust code if it is applied.
82    MaybeIncorrect,
83
84    /// The suggestion contains placeholders like `(...)` or `{ /* fields */ }`. The suggestion
85    /// cannot be applied automatically because it will not result in valid Rust code. The user
86    /// will need to fill in the placeholders.
87    HasPlaceholders,
88
89    /// The applicability of the suggestion is unknown.
90    Unspecified,
91}
92
93/// Each lint expectation has a `LintExpectationId` assigned by the `LintLevelsBuilder`.
94/// Expected diagnostics get the lint level `Expect` which stores the `LintExpectationId`
95/// to match it with the actual expectation later on.
96///
97/// The `LintExpectationId` has to be stable between compilations, as diagnostic
98/// instances might be loaded from cache. Lint messages can be emitted during an
99/// `EarlyLintPass` operating on the AST and during a `LateLintPass` traversing the
100/// HIR tree. The AST doesn't have enough information to create a stable id. The
101/// `LintExpectationId` will instead store the [`AttrId`] defining the expectation.
102/// These `LintExpectationId` will be updated to use the stable [`HirId`] once the
103/// AST has been lowered. The transformation is done by the `LintLevelsBuilder`
104///
105/// Each lint inside the `expect` attribute is tracked individually, the `lint_index`
106/// identifies the lint inside the attribute and ensures that the IDs are unique.
107///
108/// The index values have a type of `u16` to reduce the size of the `LintExpectationId`.
109/// It's reasonable to assume that no user will define 2^16 attributes on one node or
110/// have that amount of lints listed. `u16` values should therefore suffice.
111#[derive(#[automatically_derived]#[doc(hidden)]unsafe impl ::core::clone::TrivialClone
    for LintExpectationId {
}
#[automatically_derived]impl ::core::clone::Clone for LintExpectationId {
    #[inline]
    #[rustc_trivial_field_reads]
    fn clone(&self) -> Self {
        let _: ::core::clone::AssertParamIsClone<UnstableLintExpectationId>;
        let _: ::core::clone::AssertParamIsClone<StableLintExpectationId>;
        *self
    }
}Clone, #[automatically_derived]impl ::core::marker::Copy for LintExpectationId { }Copy, #[automatically_derived]impl ::core::marker::StructuralPartialEq for
    LintExpectationId {
}
#[automatically_derived]impl ::core::cmp::PartialEq for LintExpectationId {
    #[inline]
    fn eq(&self, other: &Self) -> bool {
        ::core::intrinsics::discriminant_value(self) ==
                ::core::intrinsics::discriminant_value(other) &&
            match (self, other) {
                (Self::Unstable(__self_0), Self::Unstable(__arg1_0)) =>
                    __self_0 == __arg1_0,
                (Self::Stable(__self_0), Self::Stable(__arg1_0)) =>
                    __self_0 == __arg1_0,
                _ => 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<UnstableLintExpectationId>;
        let _: ::core::cmp::AssertParamIsEq<StableLintExpectationId>;
    }
}Eq, #[automatically_derived]impl ::core::fmt::Debug for LintExpectationId {
    #[inline]
    #[rustc_trivial_field_reads]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        match self {
            Self::Unstable(__self_0) =>
                ::core::fmt::Formatter::debug_struct_field1_finish(f,
                    "Unstable", &__self_0),
            Self::Stable(__self_0) =>
                ::core::fmt::Formatter::debug_struct_field1_finish(f,
                    "Stable", &__self_0),
        }
    }
}Debug, #[automatically_derived]impl ::core::hash::Hash for LintExpectationId {
    #[inline]
    fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) {
        ::core::hash::Hash::hash(&::core::intrinsics::discriminant_value(self),
            state);
        match self {
            Self::Unstable(__self_0) =>
                ::core::hash::Hash::hash(__self_0, state),
            Self::Stable(__self_0) =>
                ::core::hash::Hash::hash(__self_0, 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(ref __binding_0) => { 0usize }
                        LintExpectationId::Stable(ref __binding_0) => { 1usize }
                    };
                ::rustc_serialize::Encoder::emit_u8(__encoder, disc as u8);
                match *self {
                    LintExpectationId::Unstable(ref __binding_0) => {
                        ::rustc_serialize::Encodable::<__E>::encode(__binding_0,
                            __encoder);
                    }
                    LintExpectationId::Stable(ref __binding_0) => {
                        ::rustc_serialize::Encodable::<__E>::encode(__binding_0,
                            __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(::rustc_serialize::Decodable::decode(__decoder))
                    }
                    1usize => {
                        LintExpectationId::Stable(::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)]
112pub enum LintExpectationId {
113    Unstable(UnstableLintExpectationId),
114    Stable(StableLintExpectationId),
115}
116
117/// Used for lints emitted during the `EarlyLintPass`. This id is not hash
118/// stable and should not be cached.
119#[derive(#[automatically_derived]#[doc(hidden)]unsafe impl ::core::clone::TrivialClone
    for UnstableLintExpectationId {
}
#[automatically_derived]impl ::core::clone::Clone for
    UnstableLintExpectationId {
    #[inline]
    #[rustc_trivial_field_reads]
    fn clone(&self) -> Self {
        let _: ::core::clone::AssertParamIsClone<AttrId>;
        let _: ::core::clone::AssertParamIsClone<u16>;
        *self
    }
}Clone, #[automatically_derived]impl ::core::marker::Copy for
    UnstableLintExpectationId {
}Copy, #[automatically_derived]impl ::core::marker::StructuralPartialEq for
    UnstableLintExpectationId {
}
#[automatically_derived]impl ::core::cmp::PartialEq for
    UnstableLintExpectationId {
    #[inline]
    fn eq(&self, other: &Self) -> bool {
        self.lint_index == other.lint_index && self.attr_id == other.attr_id
    }
}PartialEq, #[automatically_derived]impl ::core::cmp::Eq for UnstableLintExpectationId {
    #[inline]
    #[doc(hidden)]
    #[coverage(off)]
    fn assert_fields_are_eq(&self) {
        let _: ::core::cmp::AssertParamIsEq<AttrId>;
        let _: ::core::cmp::AssertParamIsEq<u16>;
    }
}Eq, #[automatically_derived]impl ::core::fmt::Debug for UnstableLintExpectationId
    {
    #[inline]
    #[rustc_trivial_field_reads]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::debug_struct_field2_finish(f,
            "UnstableLintExpectationId attr_id lint_index", &self.attr_id,
            &&self.lint_index)
    }
}Debug, #[automatically_derived]impl ::core::hash::Hash for UnstableLintExpectationId
    {
    #[inline]
    fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) {
        ::core::hash::Hash::hash(&self.attr_id, state);
        ::core::hash::Hash::hash(&self.lint_index, state)
    }
}Hash, const _: () =
    {
        impl<__E: ::rustc_span::SpanEncoder> ::rustc_serialize::Encodable<__E>
            for UnstableLintExpectationId {
            fn encode(&self, __encoder: &mut __E) {
                let UnstableLintExpectationId {
                        attr_id: ref __binding_0, lint_index: ref __binding_1 } =
                    *self;
                ::rustc_serialize::Encodable::<__E>::encode(__binding_0,
                    __encoder);
                ::rustc_serialize::Encodable::<__E>::encode(__binding_1,
                    __encoder);
            }
        }
    };Encodable, const _: () =
    {
        impl<__D: ::rustc_span::SpanDecoder> ::rustc_serialize::Decodable<__D>
            for UnstableLintExpectationId {
            fn decode(__decoder: &mut __D) -> Self {
                UnstableLintExpectationId {
                    attr_id: ::rustc_serialize::Decodable::decode(__decoder),
                    lint_index: ::rustc_serialize::Decodable::decode(__decoder),
                }
            }
        }
    };Decodable)]
120pub struct UnstableLintExpectationId {
121    pub attr_id: AttrId,
122    pub lint_index: u16,
123}
124
125impl From<UnstableLintExpectationId> for LintExpectationId {
126    fn from(id: UnstableLintExpectationId) -> LintExpectationId {
127        LintExpectationId::Unstable(id)
128    }
129}
130
131/// The [`HirId`] that the lint expectation is attached to. This id is stable
132/// and can be cached. The additional index ensures that nodes with several
133/// expectations can correctly match diagnostics to the individual expectation.
134#[derive(#[automatically_derived]#[doc(hidden)]unsafe impl ::core::clone::TrivialClone
    for StableLintExpectationId {
}
#[automatically_derived]impl ::core::clone::Clone for StableLintExpectationId
    {
    #[inline]
    #[rustc_trivial_field_reads]
    fn clone(&self) -> Self {
        let _: ::core::clone::AssertParamIsClone<HirId>;
        let _: ::core::clone::AssertParamIsClone<u16>;
        *self
    }
}Clone, #[automatically_derived]impl ::core::marker::Copy for StableLintExpectationId
    {
}Copy, #[automatically_derived]impl ::core::marker::StructuralPartialEq for
    StableLintExpectationId {
}
#[automatically_derived]impl ::core::cmp::PartialEq for
    StableLintExpectationId {
    #[inline]
    fn eq(&self, other: &Self) -> bool {
        self.lint_index == other.lint_index && self.hir_id == other.hir_id
    }
}PartialEq, #[automatically_derived]impl ::core::cmp::Eq for StableLintExpectationId {
    #[inline]
    #[doc(hidden)]
    #[coverage(off)]
    fn assert_fields_are_eq(&self) {
        let _: ::core::cmp::AssertParamIsEq<HirId>;
        let _: ::core::cmp::AssertParamIsEq<u16>;
    }
}Eq, #[automatically_derived]impl ::core::fmt::Debug for StableLintExpectationId {
    #[inline]
    #[rustc_trivial_field_reads]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::debug_struct_field2_finish(f,
            "StableLintExpectationId hir_id lint_index", &self.hir_id,
            &&self.lint_index)
    }
}Debug, #[automatically_derived]impl ::core::hash::Hash for StableLintExpectationId {
    #[inline]
    fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) {
        ::core::hash::Hash::hash(&self.hir_id, state);
        ::core::hash::Hash::hash(&self.lint_index, state)
    }
}Hash, const _: () =
    {
        impl<__E: ::rustc_span::SpanEncoder> ::rustc_serialize::Encodable<__E>
            for StableLintExpectationId {
            fn encode(&self, __encoder: &mut __E) {
                let StableLintExpectationId {
                        hir_id: ref __binding_0, lint_index: ref __binding_1 } =
                    *self;
                ::rustc_serialize::Encodable::<__E>::encode(__binding_0,
                    __encoder);
                ::rustc_serialize::Encodable::<__E>::encode(__binding_1,
                    __encoder);
            }
        }
    };Encodable, const _: () =
    {
        impl<__D: ::rustc_span::SpanDecoder> ::rustc_serialize::Decodable<__D>
            for StableLintExpectationId {
            fn decode(__decoder: &mut __D) -> Self {
                StableLintExpectationId {
                    hir_id: ::rustc_serialize::Decodable::decode(__decoder),
                    lint_index: ::rustc_serialize::Decodable::decode(__decoder),
                }
            }
        }
    };Decodable)]
135pub struct StableLintExpectationId {
136    pub hir_id: HirId,
137    pub lint_index: u16,
138}
139
140impl StableHash for StableLintExpectationId {
141    #[inline]
142    fn stable_hash<Hcx: StableHashCtxt>(&self, hcx: &mut Hcx, hasher: &mut StableHasher) {
143        let StableLintExpectationId { hir_id, lint_index } = self;
144
145        hir_id.stable_hash(hcx, hasher);
146        lint_index.stable_hash(hcx, hasher);
147    }
148}
149
150impl From<StableLintExpectationId> for LintExpectationId {
151    fn from(id: StableLintExpectationId) -> LintExpectationId {
152        LintExpectationId::Stable(id)
153    }
154}
155
156/// Setting for how to handle a lint.
157///
158/// See: <https://doc.rust-lang.org/rustc/lints/levels.html>
159#[derive(#[automatically_derived]#[doc(hidden)]unsafe impl ::core::clone::TrivialClone
    for Level {
}
#[automatically_derived]impl ::core::clone::Clone for Level {
    #[inline]
    #[rustc_trivial_field_reads]
    fn clone(&self) -> Self { *self }
}Clone, #[automatically_derived]impl ::core::marker::Copy for Level { }Copy, #[automatically_derived]impl ::core::marker::StructuralPartialEq for Level { }
#[automatically_derived]impl ::core::cmp::PartialEq for Level {
    #[inline]
    fn eq(&self, other: &Self) -> bool {
        ::core::intrinsics::discriminant_value(self) ==
            ::core::intrinsics::discriminant_value(other)
    }
}PartialEq, #[automatically_derived]impl ::core::cmp::PartialOrd for Level {
    #[inline]
    fn partial_cmp(&self, other: &Self)
        -> ::core::option::Option<::core::cmp::Ordering> {
        ::core::option::Option::Some(::core::cmp::Ord::cmp(self, other))
    }
}PartialOrd, #[automatically_derived]impl ::core::cmp::Eq for Level { }Eq, #[automatically_derived]impl ::core::cmp::Ord for Level {
    #[inline]
    fn cmp(&self, other: &Self) -> ::core::cmp::Ordering {
        ::core::cmp::Ord::cmp(&::core::intrinsics::discriminant_value(self),
            &::core::intrinsics::discriminant_value(other))
    }
}Ord, #[automatically_derived]impl ::core::fmt::Debug for Level {
    #[inline]
    #[rustc_trivial_field_reads]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::debug_c_like_enum_write_str(f,
            "Allow Expect Warn ForceWarn Deny Forbid",
            match self {
                Level::Allow => 0usize,
                Level::Expect => 6usize,
                Level::Warn => 13usize,
                Level::ForceWarn => 18usize,
                Level::Deny => 28usize,
                Level::Forbid => 33usize,
            })
    }
}Debug, #[automatically_derived]impl ::core::hash::Hash for Level {
    #[inline]
    fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) {
        ::core::hash::Hash::hash(&::core::intrinsics::discriminant_value(self),
            state)
    }
}Hash)]
160#[derive(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);
            }
        }
    };Encodable, 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, const _: () =
    {
        impl ::rustc_data_structures::stable_hash::StableHash for Level {
            #[inline]
            fn stable_hash<__Hcx: ::rustc_data_structures::stable_hash::StableHashCtxt>(&self,
                __hcx: &mut __Hcx,
                __hasher:
                    &mut ::rustc_data_structures::stable_hash::StableHasher) {
                match *self {
                    Level::Allow => 0u8.stable_hash(__hcx, __hasher),
                    Level::Expect => 1u8.stable_hash(__hcx, __hasher),
                    Level::Warn => 2u8.stable_hash(__hcx, __hasher),
                    Level::ForceWarn => 3u8.stable_hash(__hcx, __hasher),
                    Level::Deny => 4u8.stable_hash(__hcx, __hasher),
                    Level::Forbid => 5u8.stable_hash(__hcx, __hasher),
                }
                match *self {
                    Level::Allow => {}
                    Level::Expect => {}
                    Level::Warn => {}
                    Level::ForceWarn => {}
                    Level::Deny => {}
                    Level::Forbid => {}
                }
            }
        }
    };StableHash)]
161pub enum Level {
162    /// The `allow` level will not issue any message.
163    Allow,
164    /// The `expect` level will suppress the lint message but in turn produce a message
165    /// if the lint wasn't issued in the expected scope. `Expect` should not be used as
166    /// an initial level for a lint.
167    ///
168    /// Note that this still means that the lint is enabled in this position and should
169    /// be emitted, this will in turn fulfill the expectation and suppress the lint.
170    ///
171    /// See RFC 2383.
172    ///
173    /// Requires a [`LintExpectationId`] to later link a lint emission to the actual
174    /// expectation. It can be ignored in most cases.
175    Expect,
176    /// The `warn` level will produce a warning if the lint was violated, however the
177    /// compiler will continue with its execution.
178    Warn,
179    /// This lint level is a special case of [`Warn`], that can't be overridden. This is used
180    /// to ensure that a lint can't be suppressed. This lint level can currently only be set
181    /// via the console and is therefore session specific.
182    ///
183    /// Requires a [`LintExpectationId`] to fulfill expectations marked via the
184    /// `#[expect]` attribute, that will still be suppressed due to the level.
185    ForceWarn,
186    /// The `deny` level will produce an error and stop further execution after the lint
187    /// pass is complete.
188    Deny,
189    /// `Forbid` is equivalent to the `deny` level but can't be overwritten like the previous
190    /// levels.
191    Forbid,
192}
193
194impl Level {
195    /// Converts a level to a lower-case string.
196    pub fn as_str(self) -> &'static str {
197        match self {
198            Level::Allow => "allow",
199            Level::Expect => "expect",
200            Level::Warn => "warn",
201            Level::ForceWarn => "force-warn",
202            Level::Deny => "deny",
203            Level::Forbid => "forbid",
204        }
205    }
206
207    /// Converts a lower-case string to a level. This will never construct the expect
208    /// level as that would require a [`LintExpectationId`].
209    pub fn from_str(x: &str) -> Option<Self> {
210        match x {
211            "allow" => Some(Level::Allow),
212            "warn" => Some(Level::Warn),
213            "deny" => Some(Level::Deny),
214            "forbid" => Some(Level::Forbid),
215            "expect" | _ => None,
216        }
217    }
218
219    /// Converts an `Option<Symbol>` to a level.
220    pub fn from_opt_symbol(s: Option<Symbol>) -> Option<Self> {
221        s.and_then(Self::from_symbol)
222    }
223
224    /// Converts a `Symbol` to a level.
225    pub fn from_symbol(s: Symbol) -> Option<Self> {
226        match s {
227            sym::allow => Some(Level::Allow),
228            sym::expect => Some(Level::Expect),
229            sym::warn => Some(Level::Warn),
230            sym::deny => Some(Level::Deny),
231            sym::forbid => Some(Level::Forbid),
232            _ => None,
233        }
234    }
235
236    pub fn to_cmd_flag(self) -> &'static str {
237        match self {
238            Level::Warn => "-W",
239            Level::Deny => "-D",
240            Level::Forbid => "-F",
241            Level::Allow => "-A",
242            Level::ForceWarn => "--force-warn",
243            Level::Expect => {
244                {
    ::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")
245            }
246        }
247    }
248
249    pub fn is_error(self) -> bool {
250        match self {
251            Level::Allow | Level::Expect | Level::Warn | Level::ForceWarn => false,
252            Level::Deny | Level::Forbid => true,
253        }
254    }
255}
256
257impl IntoDiagArg for Level {
258    fn into_diag_arg(self, _: &mut Option<std::path::PathBuf>) -> DiagArgValue {
259        DiagArgValue::Str(Cow::Borrowed(self.to_cmd_flag()))
260    }
261}
262
263/// Specification of a single lint.
264#[derive(#[automatically_derived]impl ::core::marker::Copy for Lint { }Copy, #[automatically_derived]#[doc(hidden)]unsafe impl ::core::clone::TrivialClone
    for Lint {
}
#[automatically_derived]impl ::core::clone::Clone for Lint {
    #[inline]
    #[rustc_trivial_field_reads]
    fn clone(&self) -> Self {
        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>>;
        let _: ::core::clone::AssertParamIsClone<Option<RustcVersion>>;
        *self
    }
}Clone, #[automatically_derived]impl ::core::fmt::Debug for Lint {
    #[inline]
    #[rustc_trivial_field_reads]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::debug_struct_fields_finish(f,
            "Lint name default_level desc edition_lint_opts report_in_external_macro future_incompatible is_externally_loaded feature_gate crate_level_only eval_always ignore_deny_warnings rust_version",
            &[&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, &self.ignore_deny_warnings,
                        &&self.rust_version])
    }
}Debug)]
265pub struct Lint {
266    /// A string identifier for the lint.
267    ///
268    /// This identifies the lint in attributes and in command-line arguments.
269    /// In those contexts it is always lowercase, but this field is compared
270    /// in a way which is case-insensitive for ASCII characters. This allows
271    /// `declare_lint!()` invocations to follow the convention of upper-case
272    /// statics without repeating the name.
273    ///
274    /// The name is written with underscores, e.g., "unused_imports".
275    /// On the command line, underscores become dashes.
276    ///
277    /// See <https://rustc-dev-guide.rust-lang.org/diagnostics.html#lint-naming>
278    /// for naming guidelines.
279    pub name: &'static str,
280
281    /// Default level for the lint.
282    ///
283    /// See <https://rustc-dev-guide.rust-lang.org/diagnostics.html#diagnostic-levels>
284    /// for guidelines on choosing a default level.
285    pub default_level: Level,
286
287    /// Description of the lint or the issue it detects.
288    ///
289    /// e.g., "imports that are never used"
290    pub desc: &'static str,
291
292    /// Starting at the given edition, default to the given lint level. If this is `None`, then use
293    /// `default_level`.
294    pub edition_lint_opts: Option<(Edition, Level)> = None,
295
296    /// `true` if this lint is reported even inside expansions of external macros.
297    pub report_in_external_macro: bool = false,
298
299    pub future_incompatible: Option<FutureIncompatibleInfo> = None,
300
301    /// `true` if this lint is being loaded by another tool (e.g. Clippy).
302    pub is_externally_loaded: bool = false,
303
304    /// `Some` if this lint is feature gated, otherwise `None`.
305    pub feature_gate: Option<Symbol> = None,
306
307    pub crate_level_only: bool = false,
308
309    /// `true` if this lint should not be filtered out under any circustamces
310    /// (e.g. the unknown_attributes lint)
311    pub eval_always: bool = false,
312
313    /// `true` if this lint is unaffected by `-D warnings`
314    pub ignore_deny_warnings: bool = false,
315
316    /// Used to avoid lints which would affect MSRV
317    pub rust_version: Option<RustcVersion> = None,
318}
319
320/// Extra information for a future incompatibility lint.
321#[derive(#[automatically_derived]impl ::core::marker::Copy for FutureIncompatibleInfo {
}Copy, #[automatically_derived]#[doc(hidden)]unsafe impl ::core::clone::TrivialClone
    for FutureIncompatibleInfo {
}
#[automatically_derived]impl ::core::clone::Clone for FutureIncompatibleInfo {
    #[inline]
    #[rustc_trivial_field_reads]
    fn clone(&self) -> Self {
        let _: ::core::clone::AssertParamIsClone<FutureIncompatibilityReason>;
        let _: ::core::clone::AssertParamIsClone<bool>;
        *self
    }
}Clone, #[automatically_derived]impl ::core::fmt::Debug for FutureIncompatibleInfo {
    #[inline]
    #[rustc_trivial_field_reads]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::debug_struct_field3_finish(f,
            "FutureIncompatibleInfo reason explain_reason report_in_deps",
            &self.reason, &self.explain_reason, &&self.report_in_deps)
    }
}Debug)]
322pub struct FutureIncompatibleInfo {
323    /// The reason for the lint used by diagnostics to provide
324    /// the right help message
325    pub reason: FutureIncompatibilityReason,
326    /// Whether to explain the reason to the user.
327    ///
328    /// Set to false for lints that already include a more detailed
329    /// explanation.
330    pub explain_reason: bool = true,
331    /// If set to `true`, this will make future incompatibility warnings show up in cargo's
332    /// reports.
333    ///
334    /// When a future incompatibility warning is first inroduced, set this to `false`
335    /// (or, rather, don't override the default). This allows crate developers an opportunity
336    /// to fix the warning before blasting all dependents with a warning they can't fix
337    /// (dependents have to wait for a new release of the affected crate to be published).
338    ///
339    /// After a lint has been in this state for a while, consider setting this to true, so it
340    /// warns for everyone. It is a good signal that it is ready if you can determine that all
341    /// or most affected crates on crates.io have been updated.
342    pub report_in_deps: bool = false,
343}
344
345#[derive(#[automatically_derived]impl ::core::marker::Copy for EditionFcw { }Copy, #[automatically_derived]#[doc(hidden)]unsafe impl ::core::clone::TrivialClone
    for EditionFcw {
}
#[automatically_derived]impl ::core::clone::Clone for EditionFcw {
    #[inline]
    #[rustc_trivial_field_reads]
    fn clone(&self) -> Self {
        let _: ::core::clone::AssertParamIsClone<Edition>;
        let _: ::core::clone::AssertParamIsClone<&'static str>;
        *self
    }
}Clone, #[automatically_derived]impl ::core::fmt::Debug for EditionFcw {
    #[inline]
    #[rustc_trivial_field_reads]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::debug_struct_field2_finish(f,
            "EditionFcw edition page_slug", &self.edition, &&self.page_slug)
    }
}Debug)]
346pub struct EditionFcw {
347    pub edition: Edition,
348    pub page_slug: &'static str,
349}
350
351#[derive(#[automatically_derived]impl ::core::marker::Copy for ReleaseFcw { }Copy, #[automatically_derived]#[doc(hidden)]unsafe impl ::core::clone::TrivialClone
    for ReleaseFcw {
}
#[automatically_derived]impl ::core::clone::Clone for ReleaseFcw {
    #[inline]
    #[rustc_trivial_field_reads]
    fn clone(&self) -> Self {
        let _: ::core::clone::AssertParamIsClone<usize>;
        *self
    }
}Clone, #[automatically_derived]impl ::core::fmt::Debug for ReleaseFcw {
    #[inline]
    #[rustc_trivial_field_reads]
    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)]
352pub struct ReleaseFcw {
353    pub issue_number: usize,
354}
355
356/// The reason for future incompatibility
357///
358/// Future-incompatible lints come in roughly two categories:
359///
360/// 1. There was a mistake in the compiler (such as a soundness issue), and
361///    we're trying to fix it, but it may be a breaking change.
362/// 2. A change across an Edition boundary, typically used for the
363///    introduction of new language features that can't otherwise be
364///    introduced in a backwards-compatible way.
365///
366/// See <https://rustc-dev-guide.rust-lang.org/bug-fix-procedure.html> and
367/// <https://rustc-dev-guide.rust-lang.org/diagnostics.html#future-incompatible-lints>
368/// for more information.
369#[derive(#[automatically_derived]impl ::core::marker::Copy for
    FutureIncompatibilityReason {
}Copy, #[automatically_derived]#[doc(hidden)]unsafe impl ::core::clone::TrivialClone
    for FutureIncompatibilityReason {
}
#[automatically_derived]impl ::core::clone::Clone for
    FutureIncompatibilityReason {
    #[inline]
    #[rustc_trivial_field_reads]
    fn clone(&self) -> Self {
        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]
    #[rustc_trivial_field_reads]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        match self {
            Self::FutureReleaseError(__self_0) =>
                ::core::fmt::Formatter::debug_struct_field1_finish(f,
                    "FutureReleaseError", &__self_0),
            Self::FutureReleaseSemanticsChange(__self_0) =>
                ::core::fmt::Formatter::debug_struct_field1_finish(f,
                    "FutureReleaseSemanticsChange", &__self_0),
            Self::EditionError(__self_0) =>
                ::core::fmt::Formatter::debug_struct_field1_finish(f,
                    "EditionError", &__self_0),
            Self::EditionSemanticsChange(__self_0) =>
                ::core::fmt::Formatter::debug_struct_field1_finish(f,
                    "EditionSemanticsChange", &__self_0),
            Self::EditionAndFutureReleaseError(__self_0) =>
                ::core::fmt::Formatter::debug_struct_field1_finish(f,
                    "EditionAndFutureReleaseError", &__self_0),
            Self::EditionAndFutureReleaseSemanticsChange(__self_0) =>
                ::core::fmt::Formatter::debug_struct_field1_finish(f,
                    "EditionAndFutureReleaseSemanticsChange", &__self_0),
            Self::Custom(__self_0, __self_1) =>
                ::core::fmt::Formatter::debug_struct_field2_finish(f,
                    "Custom", __self_0, &__self_1),
        }
    }
}Debug)]
370pub enum FutureIncompatibilityReason {
371    /// This will be an error in a future release for all editions
372    ///
373    /// Choose this variant when you are first introducing a "future
374    /// incompatible" warning that is intended to eventually be fixed in the
375    /// future.
376    ///
377    /// After a lint has been in this state for a while and you feel like it is ready to graduate
378    /// to warning everyone, consider setting [`FutureIncompatibleInfo::report_in_deps`] to true.
379    /// (see its documentation for more guidance)
380    ///
381    /// After some period of time, lints with this variant can be turned into
382    /// hard errors (and the lint removed). Preferably when there is some
383    /// confidence that the number of impacted projects is very small (few
384    /// should have a broken dependency in their dependency tree).
385    FutureReleaseError(ReleaseFcw),
386    /// Code that changes meaning in some way in a
387    /// future release.
388    ///
389    /// Choose this variant when the semantics of existing code is changing,
390    /// (as opposed to [`FutureIncompatibilityReason::FutureReleaseError`],
391    /// which is for when code is going to be rejected in the future).
392    FutureReleaseSemanticsChange(ReleaseFcw),
393    /// Previously accepted code that will become an
394    /// error in the provided edition
395    ///
396    /// Choose this variant for code that you want to start rejecting across
397    /// an edition boundary. This will automatically include the lint in the
398    /// `rust-20xx-compatibility` lint group, which is used by `cargo fix
399    /// --edition` to do migrations. The lint *should* be auto-fixable with
400    /// [`Applicability::MachineApplicable`].
401    ///
402    /// The lint can either be `Allow` or `Warn` by default. If it is `Allow`,
403    /// users usually won't see this warning unless they are doing an edition
404    /// migration manually or there is a problem during the migration (cargo's
405    /// automatic migrations will force the level to `Warn`). If it is `Warn`
406    /// by default, users on all editions will see this warning (only do this
407    /// if you think it is important for everyone to be aware of the change,
408    /// and to encourage people to update their code on all editions).
409    ///
410    /// See also [`FutureIncompatibilityReason::EditionSemanticsChange`] if
411    /// you have code that is changing semantics across the edition (as
412    /// opposed to being rejected).
413    EditionError(EditionFcw),
414    /// Code that changes meaning in some way in
415    /// the provided edition
416    ///
417    /// This is the same as [`FutureIncompatibilityReason::EditionError`],
418    /// except for situations where the semantics change across an edition. It
419    /// slightly changes the text of the diagnostic, but is otherwise the
420    /// same.
421    EditionSemanticsChange(EditionFcw),
422    /// This will be an error in the provided edition *and* in a future
423    /// release.
424    ///
425    /// This variant a combination of [`FutureReleaseError`] and [`EditionError`].
426    /// This is useful in rare cases when we want to have "preview" of a breaking
427    /// change in an edition, but do a breaking change later on all editions anyway.
428    ///
429    /// [`EditionError`]: FutureIncompatibilityReason::EditionError
430    /// [`FutureReleaseError`]: FutureIncompatibilityReason::FutureReleaseError
431    EditionAndFutureReleaseError(EditionFcw),
432    /// This will change meaning in the provided edition *and* in a future
433    /// release.
434    ///
435    /// This variant a combination of [`FutureReleaseSemanticsChange`]
436    /// and [`EditionSemanticsChange`]. This is useful in rare cases when we
437    /// want to have "preview" of a breaking change in an edition, but do a
438    /// breaking change later on all editions anyway.
439    ///
440    /// [`EditionSemanticsChange`]: FutureIncompatibilityReason::EditionSemanticsChange
441    /// [`FutureReleaseSemanticsChange`]: FutureIncompatibilityReason::FutureReleaseSemanticsChange
442    EditionAndFutureReleaseSemanticsChange(EditionFcw),
443    /// A custom reason.
444    ///
445    /// Choose this variant if the built-in text of the diagnostic of the
446    /// other variants doesn't match your situation. This is behaviorally
447    /// equivalent to
448    /// [`FutureIncompatibilityReason::FutureReleaseError`].
449    Custom(&'static str, ReleaseFcw),
450}
451
452impl FutureIncompatibilityReason {
453    pub fn edition(self) -> Option<Edition> {
454        match self {
455            Self::EditionError(e)
456            | Self::EditionSemanticsChange(e)
457            | Self::EditionAndFutureReleaseError(e)
458            | Self::EditionAndFutureReleaseSemanticsChange(e) => Some(e.edition),
459
460            FutureIncompatibilityReason::FutureReleaseError(_)
461            | FutureIncompatibilityReason::FutureReleaseSemanticsChange(_)
462            | FutureIncompatibilityReason::Custom(_, _) => None,
463        }
464    }
465
466    pub fn reference(&self) -> String {
467        match self {
468            Self::FutureReleaseSemanticsChange(release_fcw)
469            | Self::FutureReleaseError(release_fcw)
470            | Self::Custom(_, release_fcw) => release_fcw.to_string(),
471            Self::EditionError(edition_fcw)
472            | Self::EditionSemanticsChange(edition_fcw)
473            | Self::EditionAndFutureReleaseError(edition_fcw)
474            | Self::EditionAndFutureReleaseSemanticsChange(edition_fcw) => edition_fcw.to_string(),
475        }
476    }
477}
478
479impl Display for ReleaseFcw {
480    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
481        let issue_number = self.issue_number;
482        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}>")
483    }
484}
485
486impl Display for EditionFcw {
487    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
488        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!(
489            f,
490            "<https://doc.rust-lang.org/edition-guide/{}/{}.html>",
491            match self.edition {
492                Edition::Edition2015 => "rust-2015",
493                Edition::Edition2018 => "rust-2018",
494                Edition::Edition2021 => "rust-2021",
495                Edition::Edition2024 => "rust-2024",
496                Edition::EditionFuture => "future",
497            },
498            self.page_slug,
499        )
500    }
501}
502
503impl Lint {
504    // FIXME(const-hack): This is used so that `declare_lint` can declare an MSRV statically.
505    // `RustcVersion::parse_str_strict` should ideally be used instead.
506    pub const fn parse_rust_version(version: &str) -> RustcVersion {
507        const fn parse_part(input: &mut &[u8]) -> u16 {
508            let mut val = 0;
509            let mut idx = 0;
510            while idx < input.len() {
511                let v = input[idx];
512                match v {
513                    b'0'..=b'9' => {
514                        val = val * 10 + (v - b'0') as u16;
515                    }
516                    b'.' => {
517                        idx += 1;
518                        break;
519                    }
520                    _ => {
    ::core::panicking::panic_fmt(format_args!("invalid character in version"));
}panic!("invalid character in version"),
521                }
522                idx += 1;
523            }
524            *input = input.split_at(idx).1;
525            val
526        }
527
528        let mut bytes = version.as_bytes();
529        let major = parse_part(&mut bytes);
530        let minor = parse_part(&mut bytes);
531        let patch = parse_part(&mut bytes);
532        if !bytes.is_empty() {
    ::core::panicking::panic("assertion failed: bytes.is_empty()")
};assert!(bytes.is_empty());
533        RustcVersion { major, minor, patch }
534    }
535
536    /// Gets the lint's name, with ASCII letters converted to lowercase.
537    pub fn name_lower(&self) -> String {
538        self.name.to_ascii_lowercase()
539    }
540
541    pub fn default_level(&self, edition: Edition) -> Level {
542        self.edition_lint_opts
543            .filter(|(e, _)| *e <= edition)
544            .map(|(_, l)| l)
545            .unwrap_or(self.default_level)
546    }
547}
548
549/// Identifies a lint known to the compiler.
550#[derive(#[automatically_derived]#[doc(hidden)]unsafe impl ::core::clone::TrivialClone
    for LintId {
}
#[automatically_derived]impl ::core::clone::Clone for LintId {
    #[inline]
    #[rustc_trivial_field_reads]
    fn clone(&self) -> Self {
        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]
    #[rustc_trivial_field_reads]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::debug_struct_field1_finish(f, "LintId lint",
            &&self.lint)
    }
}Debug)]
551pub struct LintId {
552    // Identity is based on pointer equality of this field.
553    pub lint: &'static Lint,
554}
555
556impl PartialEq for LintId {
557    fn eq(&self, other: &LintId) -> bool {
558        std::ptr::eq(self.lint, other.lint)
559    }
560}
561
562impl Eq for LintId {}
563
564impl std::hash::Hash for LintId {
565    fn hash<H: std::hash::Hasher>(&self, state: &mut H) {
566        let ptr = self.lint as *const Lint;
567        ptr.hash(state);
568    }
569}
570
571impl LintId {
572    /// Gets the `LintId` for a `Lint`.
573    pub fn of(lint: &'static Lint) -> LintId {
574        LintId { lint }
575    }
576
577    pub fn lint_name_raw(&self) -> &'static str {
578        self.lint.name
579    }
580
581    /// Gets the name of the lint.
582    pub fn to_string(&self) -> String {
583        self.lint.name_lower()
584    }
585}
586
587impl StableHash for LintId {
588    #[inline]
589    fn stable_hash<Hcx: StableHashCtxt>(&self, hcx: &mut Hcx, hasher: &mut StableHasher) {
590        self.lint_name_raw().stable_hash(hcx, hasher);
591    }
592}
593
594impl StableCompare for LintId {
595    const CAN_USE_UNSTABLE_SORT: bool = true;
596
597    fn stable_cmp(&self, other: &Self) -> std::cmp::Ordering {
598        self.lint_name_raw().cmp(&other.lint_name_raw())
599    }
600}
601
602#[derive(#[automatically_derived]impl ::core::fmt::Debug for DeprecatedSinceKind {
    #[inline]
    #[rustc_trivial_field_reads]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        match self {
            Self::InEffect =>
                ::core::fmt::Formatter::write_str(f, "InEffect"),
            Self::InFuture =>
                ::core::fmt::Formatter::write_str(f, "InFuture"),
            Self::InVersion(__self_0) =>
                ::core::fmt::Formatter::debug_struct_field1_finish(f,
                    "InVersion", &__self_0),
        }
    }
}Debug, #[automatically_derived]impl ::core::clone::Clone for DeprecatedSinceKind {
    #[inline]
    #[rustc_trivial_field_reads]
    fn clone(&self) -> Self {
        match self {
            Self::InEffect => DeprecatedSinceKind::InEffect,
            Self::InFuture => DeprecatedSinceKind::InFuture,
            Self::InVersion(__self_0) =>
                DeprecatedSinceKind::InVersion(::core::clone::Clone::clone(__self_0)),
        }
    }
}Clone)]
603pub enum DeprecatedSinceKind {
604    InEffect,
605    InFuture,
606    InVersion(String),
607}
608
609/// Tool attributes from this tool can be queried using reflection
610#[derive(const _: () =
    {
        impl<__E: ::rustc_span::SpanEncoder> ::rustc_serialize::Encodable<__E>
            for Reflectiveness {
            fn encode(&self, __encoder: &mut __E) {
                let disc =
                    match *self {
                        Reflectiveness::NonReflective => { 0usize }
                        Reflectiveness::Reflective => { 1usize }
                    };
                ::rustc_serialize::Encoder::emit_u8(__encoder, disc as u8);
            }
        }
    };Encodable, const _: () =
    {
        impl<__D: ::rustc_span::SpanDecoder> ::rustc_serialize::Decodable<__D>
            for Reflectiveness {
            fn decode(__decoder: &mut __D) -> Self {
                match ::rustc_serialize::Decoder::read_u8(__decoder) as usize
                    {
                    0usize => { Reflectiveness::NonReflective }
                    1usize => { Reflectiveness::Reflective }
                    n => {
                        ::core::panicking::panic_fmt(format_args!("invalid enum variant tag while decoding `Reflectiveness`, expected 0..2, actual {0}",
                                n));
                    }
                }
            }
        }
    };Decodable, #[automatically_derived]impl ::core::marker::Copy for Reflectiveness { }Copy, #[automatically_derived]#[doc(hidden)]unsafe impl ::core::clone::TrivialClone
    for Reflectiveness {
}
#[automatically_derived]impl ::core::clone::Clone for Reflectiveness {
    #[inline]
    #[rustc_trivial_field_reads]
    fn clone(&self) -> Self { *self }
}Clone, #[automatically_derived]impl ::core::fmt::Debug for Reflectiveness {
    #[inline]
    #[rustc_trivial_field_reads]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::write_str(f,
            match self {
                Reflectiveness::NonReflective => "NonReflective",
                Reflectiveness::Reflective => "Reflective",
            })
    }
}Debug, #[automatically_derived]impl ::core::marker::StructuralPartialEq for
    Reflectiveness {
}
#[automatically_derived]impl ::core::cmp::PartialEq for Reflectiveness {
    #[inline]
    fn eq(&self, other: &Self) -> bool {
        ::core::intrinsics::discriminant_value(self) ==
            ::core::intrinsics::discriminant_value(other)
    }
}PartialEq, #[automatically_derived]impl ::core::cmp::Eq for Reflectiveness { }Eq, #[automatically_derived]impl ::core::hash::Hash for Reflectiveness {
    #[inline]
    fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) {
        ::core::hash::Hash::hash(&::core::intrinsics::discriminant_value(self),
            state)
    }
}Hash)]
611#[derive(const _: () =
    {
        impl ::rustc_data_structures::stable_hash::StableHash for
            Reflectiveness {
            #[inline]
            fn stable_hash<__Hcx: ::rustc_data_structures::stable_hash::StableHashCtxt>(&self,
                __hcx: &mut __Hcx,
                __hasher:
                    &mut ::rustc_data_structures::stable_hash::StableHasher) {
                match *self {
                    Reflectiveness::NonReflective =>
                        0u8.stable_hash(__hcx, __hasher),
                    Reflectiveness::Reflective =>
                        1u8.stable_hash(__hcx, __hasher),
                }
                match *self {
                    Reflectiveness::NonReflective => {}
                    Reflectiveness::Reflective => {}
                }
            }
        }
    };StableHash)]
612pub enum Reflectiveness {
613    NonReflective,
614    Reflective,
615}
616
617/// Configured options for a registered tool
618#[derive(const _: () =
    {
        impl<__E: ::rustc_span::SpanEncoder> ::rustc_serialize::Encodable<__E>
            for ToolOptions {
            fn encode(&self, __encoder: &mut __E) {
                let ToolOptions { reflectiveness: ref __binding_0 } = *self;
                ::rustc_serialize::Encodable::<__E>::encode(__binding_0,
                    __encoder);
            }
        }
    };Encodable, const _: () =
    {
        impl<__D: ::rustc_span::SpanDecoder> ::rustc_serialize::Decodable<__D>
            for ToolOptions {
            fn decode(__decoder: &mut __D) -> Self {
                ToolOptions {
                    reflectiveness: ::rustc_serialize::Decodable::decode(__decoder),
                }
            }
        }
    };Decodable, #[automatically_derived]impl ::core::marker::Copy for ToolOptions { }Copy, #[automatically_derived]#[doc(hidden)]unsafe impl ::core::clone::TrivialClone
    for ToolOptions {
}
#[automatically_derived]impl ::core::clone::Clone for ToolOptions {
    #[inline]
    #[rustc_trivial_field_reads]
    fn clone(&self) -> Self {
        let _: ::core::clone::AssertParamIsClone<Reflectiveness>;
        *self
    }
}Clone, #[automatically_derived]impl ::core::fmt::Debug for ToolOptions {
    #[inline]
    #[rustc_trivial_field_reads]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::debug_struct_field1_finish(f,
            "ToolOptions reflectiveness", &&self.reflectiveness)
    }
}Debug, #[automatically_derived]impl ::core::marker::StructuralPartialEq for
    ToolOptions {
}
#[automatically_derived]impl ::core::cmp::PartialEq for ToolOptions {
    #[inline]
    fn eq(&self, other: &Self) -> bool {
        self.reflectiveness == other.reflectiveness
    }
}PartialEq, #[automatically_derived]impl ::core::cmp::Eq for ToolOptions {
    #[inline]
    #[doc(hidden)]
    #[coverage(off)]
    fn assert_fields_are_eq(&self) {
        let _: ::core::cmp::AssertParamIsEq<Reflectiveness>;
    }
}Eq, #[automatically_derived]impl ::core::hash::Hash for ToolOptions {
    #[inline]
    fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) {
        ::core::hash::Hash::hash(&self.reflectiveness, state)
    }
}Hash)]
619#[derive(const _: () =
    {
        impl ::rustc_data_structures::stable_hash::StableHash for ToolOptions
            {
            #[inline]
            fn stable_hash<__Hcx: ::rustc_data_structures::stable_hash::StableHashCtxt>(&self,
                __hcx: &mut __Hcx,
                __hasher:
                    &mut ::rustc_data_structures::stable_hash::StableHasher) {
                match *self {
                    ToolOptions { reflectiveness: ref __binding_0 } => {
                        { __binding_0.stable_hash(__hcx, __hasher); }
                    }
                }
            }
        }
    };StableHash)]
620pub struct ToolOptions {
621    pub reflectiveness: Reflectiveness,
622}
623
624impl ToolOptions {
625    pub fn union(self, other: ToolOptions) -> Self {
626        ToolOptions {
627            reflectiveness: if self.reflectiveness == Reflective
628                || other.reflectiveness == Reflective
629            {
630                Reflective
631            } else {
632                NonReflective
633            },
634        }
635    }
636}
637
638pub type RegisteredTools = FxIndexMap<Ident, ToolOptions>;
639
640#[derive(#[automatically_derived]impl<'a> ::core::fmt::Debug for
    CheckLintNameResult<'a> {
    #[inline]
    #[rustc_trivial_field_reads]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        match self {
            Self::Ok(__self_0) =>
                ::core::fmt::Formatter::debug_struct_field1_finish(f, "Ok",
                    &__self_0),
            Self::NoLint(__self_0) =>
                ::core::fmt::Formatter::debug_struct_field1_finish(f,
                    "NoLint", &__self_0),
            Self::NoTool(__self_0) =>
                ::core::fmt::Formatter::debug_struct_field1_finish(f,
                    "NoTool", &__self_0),
            Self::Renamed(__self_0) =>
                ::core::fmt::Formatter::debug_struct_field1_finish(f,
                    "Renamed", &__self_0),
            Self::Removed(__self_0) =>
                ::core::fmt::Formatter::debug_struct_field1_finish(f,
                    "Removed", &__self_0),
            Self::Tool(__self_0, __self_1) =>
                ::core::fmt::Formatter::debug_struct_field2_finish(f, "Tool",
                    __self_0, &__self_1),
            Self::MissingTool =>
                ::core::fmt::Formatter::write_str(f, "MissingTool"),
        }
    }
}Debug)]
641pub enum CheckLintNameResult<'a> {
642    Ok(&'a [LintId]),
643    /// Lint doesn't exist. Potentially contains a suggestion for a correct lint name.
644    NoLint(Option<(LintName, bool)>),
645    /// The lint refers to a tool that has not been registered.
646    NoTool(Symbol),
647    /// The lint has been renamed to a new name.
648    Renamed(LintName),
649    /// The lint has been removed due to the given reason.
650    Removed(String),
651
652    /// The lint is from a tool. The `LintId` will be returned as if it were a
653    /// rustc lint. The `Option<String>` indicates if the lint has been
654    /// renamed.
655    Tool(&'a [LintId], Option<LintName>),
656
657    /// The lint is from a tool. Either the lint does not exist in the tool or
658    /// the code was not compiled with the tool and therefore the lint was
659    /// never added to the `LintStore`.
660    MissingTool,
661}
662
663/// Declares a static item of type `&'static Lint`.
664///
665/// See <https://rustc-dev-guide.rust-lang.org/diagnostics.html> for
666/// documentation and guidelines on writing lints.
667///
668/// The macro call should start with a doc comment explaining the lint
669/// which will be embedded in the rustc user documentation book. It should
670/// be written in markdown and have a format that looks like this:
671///
672/// ```rust,ignore (doc-example)
673/// /// The `my_lint_name` lint detects [short explanation here].
674/// ///
675/// /// ### Example
676/// ///
677/// /// ```rust
678/// /// [insert a concise example that triggers the lint]
679/// /// ```
680/// ///
681/// /// {{produces}}
682/// ///
683/// /// ### Explanation
684/// ///
685/// /// This should be a detailed explanation of *why* the lint exists,
686/// /// and also include suggestions on how the user should fix the problem.
687/// /// Try to keep the text simple enough that a beginner can understand,
688/// /// and include links to other documentation for terminology that a
689/// /// beginner may not be familiar with. If this is "allow" by default,
690/// /// it should explain why (are there false positives or other issues?). If
691/// /// this is a future-incompatible lint, it should say so, with text that
692/// /// looks roughly like this:
693/// ///
694/// /// This is a [future-incompatible] lint to transition this to a hard
695/// /// error in the future. See [issue #xxxxx] for more details.
696/// ///
697/// /// [issue #xxxxx]: https://github.com/rust-lang/rust/issues/xxxxx
698/// ```
699///
700/// The `{{produces}}` tag will be automatically replaced with the output from
701/// the example by the build system. If the lint example is too complex to run
702/// as a simple example (for example, it needs an extern crate), mark the code
703/// block with `ignore` and manually replace the `{{produces}}` line with the
704/// expected output in a `text` code block.
705///
706/// If this is a rustdoc-only lint, then only include a brief introduction
707/// with a link with the text `[rustdoc book]` so that the validator knows
708/// that this is for rustdoc only (see BROKEN_INTRA_DOC_LINKS as an example).
709///
710/// Commands to view and test the documentation:
711///
712/// * `./x.py doc --stage=1 src/doc/rustc --open`: Builds the rustc book and opens it.
713/// * `./x.py test src/tools/lint-docs`: Validates that the lint docs have the
714///   correct style, and that the code example actually emits the expected
715///   lint.
716///
717/// If you have already built the compiler, and you want to make changes to
718/// just the doc comments, then use the `--keep-stage=0` flag with the above
719/// commands to avoid rebuilding the compiler.
720#[macro_export]
721macro_rules! declare_lint {
722    ($(#[$attr:meta])* $vis: vis $NAME: ident, $Level: ident, $desc: expr) => (
723        $crate::declare_lint!(
724            $(#[$attr])* $vis $NAME, $Level, $desc,
725        );
726    );
727    ($(#[$attr:meta])* $vis: vis $NAME: ident, $Level: ident, $desc: expr,
728     $(@eval_always = $eval_always:literal)?
729     $(@feature_gate = $gate:ident;)?
730     $(@future_incompatible = FutureIncompatibleInfo {
731        reason: $reason:expr,
732        $($field:ident : $val:expr),* $(,)*
733     }; )?
734     $(@edition $lint_edition:ident => $edition_level:ident;)?
735     $(@msrv = $msrv:literal;)?
736     $($v:ident),*) => (
737        $(#[$attr])*
738        $vis static $NAME: &$crate::Lint = &$crate::Lint {
739            name: stringify!($NAME),
740            default_level: $crate::$Level,
741            desc: $desc,
742            $($v: true,)*
743            $(feature_gate: Some(rustc_span::sym::$gate),)?
744            $(future_incompatible: Some($crate::FutureIncompatibleInfo {
745                reason: $reason,
746                $($field: $val,)*
747                ..
748            }),)?
749            $(edition_lint_opts: Some((::rustc_span::edition::Edition::$lint_edition, $crate::$edition_level)),)?
750            $(eval_always: $eval_always,)?
751            $(rust_version: Some($crate::Lint::parse_rust_version($msrv)),)?
752            ..
753        };
754    );
755}
756
757#[macro_export]
758#[allow_internal_unstable(default_field_values)]
759macro_rules! declare_tool_lint {
760    (
761        $(#[$attr:meta])* $vis:vis $tool:ident ::$NAME:ident, $Level:ident, $desc:expr
762        $(, @report_in_external_macro = $external:literal)?
763        $(, @eval_always = $eval_always: literal)?
764        $(, @feature_gate = $gate:ident;)?
765    ) => (
766        $(#[$attr])*
767        $vis static $NAME: &$crate::Lint = &$crate::Lint {
768            name: &concat!(stringify!($tool), "::", stringify!($NAME)),
769            default_level: $crate::$Level,
770            desc: $desc,
771            $(report_in_external_macro: $external,)?
772            is_externally_loaded: true,
773            $(feature_gate: Some(rustc_span::sym::$gate),)?
774            $(eval_always: $eval_always,)?
775            ..
776        };
777    );
778}
779
780pub type LintVec = Vec<&'static Lint>;
781
782pub trait LintPass {
783    fn name(&self) -> &'static str;
784    fn get_lints(&self) -> LintVec;
785}
786
787/// Implements `LintPass for $ty` with the given list of `Lint` statics.
788#[macro_export]
789macro_rules! impl_lint_pass {
790    ($ty:ty => [$($lint:expr),* $(,)?]) => {
791        impl $crate::LintPass for $ty {
792            fn name(&self) -> &'static str { stringify!($ty) }
793            fn get_lints(&self) -> $crate::LintVec { vec![$($lint),*] }
794        }
795        impl $ty {
796            #[allow(unused)]
797            pub fn lint_vec() -> $crate::LintVec { vec![$($lint),*] }
798        }
799    };
800}
801
802/// Declares a type named `$name` which implements `LintPass`.
803/// To the right of `=>` a comma separated list of `Lint` statics is given.
804#[macro_export]
805macro_rules! declare_lint_pass {
806    ($(#[$m:meta])* $name:ident => [$($lint:expr),* $(,)?]) => {
807        $(#[$m])* #[derive(Copy, Clone)] pub struct $name;
808        $crate::impl_lint_pass!($name => [$($lint),*]);
809    };
810}
811
812#[macro_export]
813macro_rules! fcw {
814    (FutureReleaseError # $issue_number: literal) => {
815       $crate::FutureIncompatibilityReason::FutureReleaseError($crate::ReleaseFcw { issue_number: $issue_number })
816    };
817    (FutureReleaseSemanticsChange # $issue_number: literal) => {
818        $crate::FutureIncompatibilityReason::FutureReleaseSemanticsChange($crate::ReleaseFcw {
819            issue_number: $issue_number,
820        })
821    };
822    ($description: literal # $issue_number: literal) => {
823        $crate::FutureIncompatibilityReason::Custom($description, $crate::ReleaseFcw {
824            issue_number: $issue_number,
825        })
826    };
827    (EditionError $edition_name: tt $page_slug: literal) => {
828        $crate::FutureIncompatibilityReason::EditionError($crate::EditionFcw {
829            edition: fcw!(@edition $edition_name),
830            page_slug: $page_slug,
831        })
832    };
833    (EditionSemanticsChange $edition_name: tt $page_slug: literal) => {
834        $crate::FutureIncompatibilityReason::EditionSemanticsChange($crate::EditionFcw {
835            edition: fcw!(@edition $edition_name),
836            page_slug: $page_slug,
837        })
838    };
839    (EditionAndFutureReleaseSemanticsChange $edition_name: tt $page_slug: literal) => {
840        $crate::FutureIncompatibilityReason::EditionAndFutureReleaseSemanticsChange($crate::EditionFcw {
841            edition: fcw!(@edition $edition_name),
842            page_slug: $page_slug,
843        })
844    };
845    (EditionAndFutureReleaseError $edition_name: tt $page_slug: literal) => {
846        $crate::FutureIncompatibilityReason::EditionAndFutureReleaseError($crate::EditionFcw {
847            edition: fcw!(@edition $edition_name),
848            page_slug: $page_slug,
849        })
850    };
851    (@edition future) => { rustc_span::edition::Edition::EditionFuture };
852    (@edition 2024) => { rustc_span::edition::Edition::Edition2024 };
853    (@edition 2021) => { rustc_span::edition::Edition::Edition2021 };
854    (@edition 2018) => { rustc_span::edition::Edition::Edition2018 };
855}