Skip to main content

rustc_hir/
hir.rs

1// ignore-tidy-filelength
2use std::borrow::Cow;
3use std::fmt;
4use std::ops::Not;
5
6use rustc_abi::ExternAbi;
7use rustc_ast::attr::AttributeExt;
8use rustc_ast::token::DocFragmentKind;
9use rustc_ast::util::parser::ExprPrecedence;
10use rustc_ast::{
11    self as ast, FloatTy, InlineAsmOptions, InlineAsmTemplatePiece, IntTy, Label, LitIntType,
12    LitKind, TraitObjectSyntax, UintTy, UnsafeBinderCastKind, join_path_idents,
13};
14pub use rustc_ast::{
15    AssignOp, AssignOpKind, AttrId, AttrStyle, BinOp, BinOpKind, BindingMode, BorrowKind,
16    BoundConstness, BoundPolarity, ByRef, CaptureBy, DelimArgs, ImplPolarity, IsAuto,
17    MetaItemInner, MetaItemLit, Movability, Mutability, Pinnedness, UnOp,
18};
19use rustc_data_structures::fingerprint::Fingerprint;
20use rustc_data_structures::sorted_map::SortedMap;
21use rustc_data_structures::tagged_ptr::TaggedRef;
22use rustc_error_messages::{DiagArgValue, IntoDiagArg};
23use rustc_index::IndexVec;
24use rustc_macros::{Decodable, Encodable, HashStable_Generic};
25use rustc_span::def_id::LocalDefId;
26use rustc_span::source_map::Spanned;
27use rustc_span::{
28    BytePos, DUMMY_SP, DesugaringKind, ErrorGuaranteed, Ident, Span, Symbol, kw, sym,
29};
30use rustc_target::asm::InlineAsmRegOrRegClass;
31use smallvec::SmallVec;
32use thin_vec::ThinVec;
33use tracing::debug;
34
35use crate::attrs::AttributeKind;
36use crate::def::{CtorKind, DefKind, MacroKinds, PerNS, Res};
37use crate::def_id::{DefId, LocalDefIdMap};
38pub(crate) use crate::hir_id::{HirId, ItemLocalId, ItemLocalMap, OwnerId};
39use crate::intravisit::{FnKind, VisitorExt};
40use crate::lints::DelayedLints;
41
42#[derive(#[automatically_derived]
impl ::core::fmt::Debug for AngleBrackets {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::write_str(f,
            match self {
                AngleBrackets::Missing => "Missing",
                AngleBrackets::Empty => "Empty",
                AngleBrackets::Full => "Full",
            })
    }
}Debug, #[automatically_derived]
impl ::core::marker::Copy for AngleBrackets { }Copy, #[automatically_derived]
impl ::core::clone::Clone for AngleBrackets {
    #[inline]
    fn clone(&self) -> AngleBrackets { *self }
}Clone, #[automatically_derived]
impl ::core::cmp::PartialEq for AngleBrackets {
    #[inline]
    fn eq(&self, other: &AngleBrackets) -> 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 AngleBrackets {
    #[inline]
    #[doc(hidden)]
    #[coverage(off)]
    fn assert_fields_are_eq(&self) {}
}Eq, const _: () =
    {
        impl<__CTX> ::rustc_data_structures::stable_hasher::HashStable<__CTX>
            for AngleBrackets where __CTX: crate::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 {
                    AngleBrackets::Missing => {}
                    AngleBrackets::Empty => {}
                    AngleBrackets::Full => {}
                }
            }
        }
    };HashStable_Generic)]
43pub enum AngleBrackets {
44    /// E.g. `Path`.
45    Missing,
46    /// E.g. `Path<>`.
47    Empty,
48    /// E.g. `Path<T>`.
49    Full,
50}
51
52#[derive(#[automatically_derived]
impl ::core::fmt::Debug for LifetimeSource {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        match self {
            LifetimeSource::Reference =>
                ::core::fmt::Formatter::write_str(f, "Reference"),
            LifetimeSource::Path { angle_brackets: __self_0 } =>
                ::core::fmt::Formatter::debug_struct_field1_finish(f, "Path",
                    "angle_brackets", &__self_0),
            LifetimeSource::OutlivesBound =>
                ::core::fmt::Formatter::write_str(f, "OutlivesBound"),
            LifetimeSource::PreciseCapturing =>
                ::core::fmt::Formatter::write_str(f, "PreciseCapturing"),
            LifetimeSource::Other =>
                ::core::fmt::Formatter::write_str(f, "Other"),
        }
    }
}Debug, #[automatically_derived]
impl ::core::marker::Copy for LifetimeSource { }Copy, #[automatically_derived]
impl ::core::clone::Clone for LifetimeSource {
    #[inline]
    fn clone(&self) -> LifetimeSource {
        let _: ::core::clone::AssertParamIsClone<AngleBrackets>;
        *self
    }
}Clone, #[automatically_derived]
impl ::core::cmp::PartialEq for LifetimeSource {
    #[inline]
    fn eq(&self, other: &LifetimeSource) -> bool {
        let __self_discr = ::core::intrinsics::discriminant_value(self);
        let __arg1_discr = ::core::intrinsics::discriminant_value(other);
        __self_discr == __arg1_discr &&
            match (self, other) {
                (LifetimeSource::Path { angle_brackets: __self_0 },
                    LifetimeSource::Path { angle_brackets: __arg1_0 }) =>
                    __self_0 == __arg1_0,
                _ => true,
            }
    }
}PartialEq, #[automatically_derived]
impl ::core::cmp::Eq for LifetimeSource {
    #[inline]
    #[doc(hidden)]
    #[coverage(off)]
    fn assert_fields_are_eq(&self) {
        let _: ::core::cmp::AssertParamIsEq<AngleBrackets>;
    }
}Eq, const _: () =
    {
        impl<__CTX> ::rustc_data_structures::stable_hasher::HashStable<__CTX>
            for LifetimeSource where __CTX: crate::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 {
                    LifetimeSource::Reference => {}
                    LifetimeSource::Path { angle_brackets: ref __binding_0 } =>
                        {
                        { __binding_0.hash_stable(__hcx, __hasher); }
                    }
                    LifetimeSource::OutlivesBound => {}
                    LifetimeSource::PreciseCapturing => {}
                    LifetimeSource::Other => {}
                }
            }
        }
    };HashStable_Generic)]
53pub enum LifetimeSource {
54    /// E.g. `&Type`, `&'_ Type`, `&'a Type`, `&mut Type`, `&'_ mut Type`, `&'a mut Type`
55    Reference,
56
57    /// E.g. `ContainsLifetime`, `ContainsLifetime<>`, `ContainsLifetime<'_>`,
58    /// `ContainsLifetime<'a>`
59    Path { angle_brackets: AngleBrackets },
60
61    /// E.g. `impl Trait + '_`, `impl Trait + 'a`
62    OutlivesBound,
63
64    /// E.g. `impl Trait + use<'_>`, `impl Trait + use<'a>`
65    PreciseCapturing,
66
67    /// Other usages which have not yet been categorized. Feel free to
68    /// add new sources that you find useful.
69    ///
70    /// Some non-exhaustive examples:
71    /// - `where T: 'a`
72    /// - `fn(_: dyn Trait + 'a)`
73    Other,
74}
75
76#[derive(#[automatically_derived]
impl ::core::fmt::Debug for LifetimeSyntax {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::write_str(f,
            match self {
                LifetimeSyntax::Implicit => "Implicit",
                LifetimeSyntax::ExplicitAnonymous => "ExplicitAnonymous",
                LifetimeSyntax::ExplicitBound => "ExplicitBound",
            })
    }
}Debug, #[automatically_derived]
impl ::core::marker::Copy for LifetimeSyntax { }Copy, #[automatically_derived]
impl ::core::clone::Clone for LifetimeSyntax {
    #[inline]
    fn clone(&self) -> LifetimeSyntax { *self }
}Clone, #[automatically_derived]
impl ::core::cmp::PartialEq for LifetimeSyntax {
    #[inline]
    fn eq(&self, other: &LifetimeSyntax) -> 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 LifetimeSyntax {
    #[inline]
    #[doc(hidden)]
    #[coverage(off)]
    fn assert_fields_are_eq(&self) {}
}Eq, const _: () =
    {
        impl<__CTX> ::rustc_data_structures::stable_hasher::HashStable<__CTX>
            for LifetimeSyntax where __CTX: crate::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 {
                    LifetimeSyntax::Implicit => {}
                    LifetimeSyntax::ExplicitAnonymous => {}
                    LifetimeSyntax::ExplicitBound => {}
                }
            }
        }
    };HashStable_Generic)]
77pub enum LifetimeSyntax {
78    /// E.g. `&Type`, `ContainsLifetime`
79    Implicit,
80
81    /// E.g. `&'_ Type`, `ContainsLifetime<'_>`, `impl Trait + '_`, `impl Trait + use<'_>`
82    ExplicitAnonymous,
83
84    /// E.g. `&'a Type`, `ContainsLifetime<'a>`, `impl Trait + 'a`, `impl Trait + use<'a>`
85    ExplicitBound,
86}
87
88impl From<Ident> for LifetimeSyntax {
89    fn from(ident: Ident) -> Self {
90        let name = ident.name;
91
92        if name == sym::empty {
93            {
    ::core::panicking::panic_fmt(format_args!("internal error: entered unreachable code: {0}",
            format_args!("A lifetime name should never be empty")));
};unreachable!("A lifetime name should never be empty");
94        } else if name == kw::UnderscoreLifetime {
95            LifetimeSyntax::ExplicitAnonymous
96        } else {
97            if true {
    if !name.as_str().starts_with('\'') {
        ::core::panicking::panic("assertion failed: name.as_str().starts_with(\'\\\'\')")
    };
};debug_assert!(name.as_str().starts_with('\''));
98            LifetimeSyntax::ExplicitBound
99        }
100    }
101}
102
103/// A lifetime. The valid field combinations are non-obvious and not all
104/// combinations are possible. The following example shows some of
105/// them. See also the comments on `LifetimeKind` and `LifetimeSource`.
106///
107/// ```
108/// #[repr(C)]
109/// struct S<'a>(&'a u32);       // res=Param, name='a, source=Reference, syntax=ExplicitBound
110/// unsafe extern "C" {
111///     fn f1(s: S);             // res=Param, name='_, source=Path, syntax=Implicit
112///     fn f2(s: S<'_>);         // res=Param, name='_, source=Path, syntax=ExplicitAnonymous
113///     fn f3<'a>(s: S<'a>);     // res=Param, name='a, source=Path, syntax=ExplicitBound
114/// }
115///
116/// struct St<'a> { x: &'a u32 } // res=Param, name='a, source=Reference, syntax=ExplicitBound
117/// fn f() {
118///     _ = St { x: &0 };        // res=Infer, name='_, source=Path, syntax=Implicit
119///     _ = St::<'_> { x: &0 };  // res=Infer, name='_, source=Path, syntax=ExplicitAnonymous
120/// }
121///
122/// struct Name<'a>(&'a str);    // res=Param,  name='a, source=Reference, syntax=ExplicitBound
123/// const A: Name = Name("a");   // res=Static, name='_, source=Path, syntax=Implicit
124/// const B: &str = "";          // res=Static, name='_, source=Reference, syntax=Implicit
125/// static C: &'_ str = "";      // res=Static, name='_, source=Reference, syntax=ExplicitAnonymous
126/// static D: &'static str = ""; // res=Static, name='static, source=Reference, syntax=ExplicitBound
127///
128/// trait Tr {}
129/// fn tr(_: Box<dyn Tr>) {}     // res=ImplicitObjectLifetimeDefault, name='_, source=Other, syntax=Implicit
130///
131/// fn capture_outlives<'a>() ->
132///     impl FnOnce() + 'a       // res=Param, ident='a, source=OutlivesBound, syntax=ExplicitBound
133/// {
134///     || {}
135/// }
136///
137/// fn capture_precise<'a>() ->
138///     impl FnOnce() + use<'a>  // res=Param, ident='a, source=PreciseCapturing, syntax=ExplicitBound
139/// {
140///     || {}
141/// }
142///
143/// // (commented out because these cases trigger errors)
144/// // struct S1<'a>(&'a str);   // res=Param, name='a, source=Reference, syntax=ExplicitBound
145/// // struct S2(S1);            // res=Error, name='_, source=Path, syntax=Implicit
146/// // struct S3(S1<'_>);        // res=Error, name='_, source=Path, syntax=ExplicitAnonymous
147/// // struct S4(S1<'a>);        // res=Error, name='a, source=Path, syntax=ExplicitBound
148/// ```
149///
150/// Some combinations that cannot occur are `LifetimeSyntax::Implicit` with
151/// `LifetimeSource::OutlivesBound` or `LifetimeSource::PreciseCapturing`
152/// — there's no way to "elide" these lifetimes.
153#[derive(#[automatically_derived]
impl ::core::fmt::Debug for Lifetime {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::debug_struct_field5_finish(f, "Lifetime",
            "hir_id", &self.hir_id, "ident", &self.ident, "kind", &self.kind,
            "source", &self.source, "syntax", &&self.syntax)
    }
}Debug, #[automatically_derived]
impl ::core::marker::Copy for Lifetime { }Copy, #[automatically_derived]
impl ::core::clone::Clone for Lifetime {
    #[inline]
    fn clone(&self) -> Lifetime {
        let _: ::core::clone::AssertParamIsClone<HirId>;
        let _: ::core::clone::AssertParamIsClone<Ident>;
        let _: ::core::clone::AssertParamIsClone<LifetimeKind>;
        let _: ::core::clone::AssertParamIsClone<LifetimeSource>;
        let _: ::core::clone::AssertParamIsClone<LifetimeSyntax>;
        *self
    }
}Clone, const _: () =
    {
        impl<__CTX> ::rustc_data_structures::stable_hasher::HashStable<__CTX>
            for Lifetime where __CTX: crate::HashStableContext {
            #[inline]
            fn hash_stable(&self, __hcx: &mut __CTX,
                __hasher:
                    &mut ::rustc_data_structures::stable_hasher::StableHasher) {
                match *self {
                    Lifetime {
                        hir_id: ref __binding_0,
                        ident: ref __binding_1,
                        kind: ref __binding_2,
                        source: ref __binding_3,
                        syntax: ref __binding_4 } => {
                        {}
                        { __binding_1.hash_stable(__hcx, __hasher); }
                        { __binding_2.hash_stable(__hcx, __hasher); }
                        { __binding_3.hash_stable(__hcx, __hasher); }
                        { __binding_4.hash_stable(__hcx, __hasher); }
                    }
                }
            }
        }
    };HashStable_Generic)]
154// Raise the alignment to at least 4 bytes.
155// This is relied on in other parts of the compiler (for pointer tagging):
156// <https://github.com/rust-lang/rust/blob/ce5fdd7d42aba9a2925692e11af2bd39cf37798a/compiler/rustc_data_structures/src/tagged_ptr.rs#L163>
157// Removing this `repr(4)` will cause the compiler to not build on platforms
158// like `m68k` Linux, where the alignment of u32 and usize is only 2.
159// Since `repr(align)` may only raise alignment, this has no effect on
160// platforms where the alignment is already sufficient.
161#[repr(align(4))]
162pub struct Lifetime {
163    #[stable_hasher(ignore)]
164    pub hir_id: HirId,
165
166    /// Either a named lifetime definition (e.g. `'a`, `'static`) or an
167    /// anonymous lifetime (`'_`, either explicitly written, or inserted for
168    /// things like `&type`).
169    pub ident: Ident,
170
171    /// Semantics of this lifetime.
172    pub kind: LifetimeKind,
173
174    /// The context in which the lifetime occurred. See `Lifetime::suggestion`
175    /// for example use.
176    pub source: LifetimeSource,
177
178    /// The syntax that the user used to declare this lifetime. See
179    /// `Lifetime::suggestion` for example use.
180    pub syntax: LifetimeSyntax,
181}
182
183#[derive(#[automatically_derived]
impl ::core::fmt::Debug for ParamName {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        match self {
            ParamName::Plain(__self_0) =>
                ::core::fmt::Formatter::debug_tuple_field1_finish(f, "Plain",
                    &__self_0),
            ParamName::Error(__self_0) =>
                ::core::fmt::Formatter::debug_tuple_field1_finish(f, "Error",
                    &__self_0),
            ParamName::Fresh => ::core::fmt::Formatter::write_str(f, "Fresh"),
        }
    }
}Debug, #[automatically_derived]
impl ::core::marker::Copy for ParamName { }Copy, #[automatically_derived]
impl ::core::clone::Clone for ParamName {
    #[inline]
    fn clone(&self) -> ParamName {
        let _: ::core::clone::AssertParamIsClone<Ident>;
        *self
    }
}Clone, const _: () =
    {
        impl<__CTX> ::rustc_data_structures::stable_hasher::HashStable<__CTX>
            for ParamName where __CTX: crate::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 {
                    ParamName::Plain(ref __binding_0) => {
                        { __binding_0.hash_stable(__hcx, __hasher); }
                    }
                    ParamName::Error(ref __binding_0) => {
                        { __binding_0.hash_stable(__hcx, __hasher); }
                    }
                    ParamName::Fresh => {}
                }
            }
        }
    };HashStable_Generic)]
184pub enum ParamName {
185    /// Some user-given name like `T` or `'x`.
186    Plain(Ident),
187
188    /// Indicates an illegal name was given and an error has been
189    /// reported (so we should squelch other derived errors).
190    ///
191    /// Occurs when, e.g., `'_` is used in the wrong place, or a
192    /// lifetime name is duplicated.
193    Error(Ident),
194
195    /// Synthetic name generated when user elided a lifetime in an impl header.
196    ///
197    /// E.g., the lifetimes in cases like these:
198    /// ```ignore (fragment)
199    /// impl Foo for &u32
200    /// impl Foo<'_> for u32
201    /// ```
202    /// in that case, we rewrite to
203    /// ```ignore (fragment)
204    /// impl<'f> Foo for &'f u32
205    /// impl<'f> Foo<'f> for u32
206    /// ```
207    /// where `'f` is something like `Fresh(0)`. The indices are
208    /// unique per impl, but not necessarily continuous.
209    Fresh,
210}
211
212impl ParamName {
213    pub fn ident(&self) -> Ident {
214        match *self {
215            ParamName::Plain(ident) | ParamName::Error(ident) => ident,
216            ParamName::Fresh => Ident::with_dummy_span(kw::UnderscoreLifetime),
217        }
218    }
219}
220
221#[derive(#[automatically_derived]
impl ::core::fmt::Debug for LifetimeKind {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        match self {
            LifetimeKind::Param(__self_0) =>
                ::core::fmt::Formatter::debug_tuple_field1_finish(f, "Param",
                    &__self_0),
            LifetimeKind::ImplicitObjectLifetimeDefault =>
                ::core::fmt::Formatter::write_str(f,
                    "ImplicitObjectLifetimeDefault"),
            LifetimeKind::Error(__self_0) =>
                ::core::fmt::Formatter::debug_tuple_field1_finish(f, "Error",
                    &__self_0),
            LifetimeKind::Infer =>
                ::core::fmt::Formatter::write_str(f, "Infer"),
            LifetimeKind::Static =>
                ::core::fmt::Formatter::write_str(f, "Static"),
        }
    }
}Debug, #[automatically_derived]
impl ::core::marker::Copy for LifetimeKind { }Copy, #[automatically_derived]
impl ::core::clone::Clone for LifetimeKind {
    #[inline]
    fn clone(&self) -> LifetimeKind {
        let _: ::core::clone::AssertParamIsClone<LocalDefId>;
        let _: ::core::clone::AssertParamIsClone<ErrorGuaranteed>;
        *self
    }
}Clone, #[automatically_derived]
impl ::core::cmp::PartialEq for LifetimeKind {
    #[inline]
    fn eq(&self, other: &LifetimeKind) -> bool {
        let __self_discr = ::core::intrinsics::discriminant_value(self);
        let __arg1_discr = ::core::intrinsics::discriminant_value(other);
        __self_discr == __arg1_discr &&
            match (self, other) {
                (LifetimeKind::Param(__self_0), LifetimeKind::Param(__arg1_0))
                    => __self_0 == __arg1_0,
                (LifetimeKind::Error(__self_0), LifetimeKind::Error(__arg1_0))
                    => __self_0 == __arg1_0,
                _ => true,
            }
    }
}PartialEq, #[automatically_derived]
impl ::core::cmp::Eq for LifetimeKind {
    #[inline]
    #[doc(hidden)]
    #[coverage(off)]
    fn assert_fields_are_eq(&self) {
        let _: ::core::cmp::AssertParamIsEq<LocalDefId>;
        let _: ::core::cmp::AssertParamIsEq<ErrorGuaranteed>;
    }
}Eq, #[automatically_derived]
impl ::core::hash::Hash for LifetimeKind {
    #[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 {
            LifetimeKind::Param(__self_0) =>
                ::core::hash::Hash::hash(__self_0, state),
            LifetimeKind::Error(__self_0) =>
                ::core::hash::Hash::hash(__self_0, state),
            _ => {}
        }
    }
}Hash, const _: () =
    {
        impl<__CTX> ::rustc_data_structures::stable_hasher::HashStable<__CTX>
            for LifetimeKind where __CTX: crate::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 {
                    LifetimeKind::Param(ref __binding_0) => {
                        { __binding_0.hash_stable(__hcx, __hasher); }
                    }
                    LifetimeKind::ImplicitObjectLifetimeDefault => {}
                    LifetimeKind::Error(ref __binding_0) => {
                        { __binding_0.hash_stable(__hcx, __hasher); }
                    }
                    LifetimeKind::Infer => {}
                    LifetimeKind::Static => {}
                }
            }
        }
    };HashStable_Generic)]
222pub enum LifetimeKind {
223    /// User-given names or fresh (synthetic) names.
224    Param(LocalDefId),
225
226    /// Implicit lifetime in a context like `dyn Foo`. This is
227    /// distinguished from implicit lifetimes elsewhere because the
228    /// lifetime that they default to must appear elsewhere within the
229    /// enclosing type. This means that, in an `impl Trait` context, we
230    /// don't have to create a parameter for them. That is, `impl
231    /// Trait<Item = &u32>` expands to an opaque type like `type
232    /// Foo<'a> = impl Trait<Item = &'a u32>`, but `impl Trait<item =
233    /// dyn Bar>` expands to `type Foo = impl Trait<Item = dyn Bar +
234    /// 'static>`. The latter uses `ImplicitObjectLifetimeDefault` so
235    /// that surrounding code knows not to create a lifetime
236    /// parameter.
237    ImplicitObjectLifetimeDefault,
238
239    /// Indicates an error during lowering (usually `'_` in wrong place)
240    /// that was already reported.
241    Error(ErrorGuaranteed),
242
243    /// User wrote an anonymous lifetime, either `'_` or nothing (which gets
244    /// converted to `'_`). The semantics of this lifetime should be inferred
245    /// by typechecking code.
246    Infer,
247
248    /// User wrote `'static` or nothing (which gets converted to `'_`).
249    Static,
250}
251
252impl LifetimeKind {
253    fn is_elided(&self) -> bool {
254        match self {
255            LifetimeKind::ImplicitObjectLifetimeDefault | LifetimeKind::Infer => true,
256
257            // It might seem surprising that `Fresh` counts as not *elided*
258            // -- but this is because, as far as the code in the compiler is
259            // concerned -- `Fresh` variants act equivalently to "some fresh name".
260            // They correspond to early-bound regions on an impl, in other words.
261            LifetimeKind::Error(..) | LifetimeKind::Param(..) | LifetimeKind::Static => false,
262        }
263    }
264}
265
266impl fmt::Display for Lifetime {
267    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
268        self.ident.name.fmt(f)
269    }
270}
271
272impl Lifetime {
273    pub fn new(
274        hir_id: HirId,
275        ident: Ident,
276        kind: LifetimeKind,
277        source: LifetimeSource,
278        syntax: LifetimeSyntax,
279    ) -> Lifetime {
280        let lifetime = Lifetime { hir_id, ident, kind, source, syntax };
281
282        // Sanity check: elided lifetimes form a strict subset of anonymous lifetimes.
283        #[cfg(debug_assertions)]
284        match (lifetime.is_elided(), lifetime.is_anonymous()) {
285            (false, false) => {} // e.g. `'a`
286            (false, true) => {}  // e.g. explicit `'_`
287            (true, true) => {}   // e.g. `&x`
288            (true, false) => { ::core::panicking::panic_fmt(format_args!("bad Lifetime")); }panic!("bad Lifetime"),
289        }
290
291        lifetime
292    }
293
294    pub fn is_elided(&self) -> bool {
295        self.kind.is_elided()
296    }
297
298    pub fn is_anonymous(&self) -> bool {
299        self.ident.name == kw::UnderscoreLifetime
300    }
301
302    pub fn is_implicit(&self) -> bool {
303        #[allow(non_exhaustive_omitted_patterns)] match self.syntax {
    LifetimeSyntax::Implicit => true,
    _ => false,
}matches!(self.syntax, LifetimeSyntax::Implicit)
304    }
305
306    pub fn is_static(&self) -> bool {
307        self.kind == LifetimeKind::Static
308    }
309
310    pub fn suggestion(&self, new_lifetime: &str) -> (Span, String) {
311        use LifetimeSource::*;
312        use LifetimeSyntax::*;
313
314        if true {
    if !new_lifetime.starts_with('\'') {
        ::core::panicking::panic("assertion failed: new_lifetime.starts_with(\'\\\'\')")
    };
};debug_assert!(new_lifetime.starts_with('\''));
315
316        match (self.syntax, self.source) {
317            // The user wrote `'a` or `'_`.
318            (ExplicitBound | ExplicitAnonymous, _) => (self.ident.span, ::alloc::__export::must_use({
        ::alloc::fmt::format(format_args!("{0}", new_lifetime))
    })format!("{new_lifetime}")),
319
320            // The user wrote `Path<T>`, and omitted the `'_,`.
321            (Implicit, Path { angle_brackets: AngleBrackets::Full }) => {
322                (self.ident.span, ::alloc::__export::must_use({
        ::alloc::fmt::format(format_args!("{0}, ", new_lifetime))
    })format!("{new_lifetime}, "))
323            }
324
325            // The user wrote `Path<>`, and omitted the `'_`..
326            (Implicit, Path { angle_brackets: AngleBrackets::Empty }) => {
327                (self.ident.span, ::alloc::__export::must_use({
        ::alloc::fmt::format(format_args!("{0}", new_lifetime))
    })format!("{new_lifetime}"))
328            }
329
330            // The user wrote `Path` and omitted the `<'_>`.
331            (Implicit, Path { angle_brackets: AngleBrackets::Missing }) => {
332                (self.ident.span.shrink_to_hi(), ::alloc::__export::must_use({
        ::alloc::fmt::format(format_args!("<{0}>", new_lifetime))
    })format!("<{new_lifetime}>"))
333            }
334
335            // The user wrote `&type` or `&mut type`.
336            (Implicit, Reference) => (self.ident.span, ::alloc::__export::must_use({
        ::alloc::fmt::format(format_args!("{0} ", new_lifetime))
    })format!("{new_lifetime} ")),
337
338            (Implicit, source) => {
339                {
    ::core::panicking::panic_fmt(format_args!("internal error: entered unreachable code: {0}",
            format_args!("can\'t suggest for a implicit lifetime of {0:?}",
                source)));
}unreachable!("can't suggest for a implicit lifetime of {source:?}")
340            }
341        }
342    }
343}
344
345/// A `Path` is essentially Rust's notion of a name; for instance,
346/// `std::cmp::PartialEq`. It's represented as a sequence of identifiers,
347/// along with a bunch of supporting information.
348#[derive(#[automatically_derived]
impl<'hir, R: ::core::fmt::Debug> ::core::fmt::Debug for Path<'hir, R> {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::debug_struct_field3_finish(f, "Path", "span",
            &self.span, "res", &self.res, "segments", &&self.segments)
    }
}Debug, #[automatically_derived]
impl<'hir, R: ::core::clone::Clone> ::core::clone::Clone for Path<'hir, R> {
    #[inline]
    fn clone(&self) -> Path<'hir, R> {
        Path {
            span: ::core::clone::Clone::clone(&self.span),
            res: ::core::clone::Clone::clone(&self.res),
            segments: ::core::clone::Clone::clone(&self.segments),
        }
    }
}Clone, #[automatically_derived]
impl<'hir, R: ::core::marker::Copy> ::core::marker::Copy for Path<'hir, R> { }Copy, const _: () =
    {
        impl<'hir, R, __CTX>
            ::rustc_data_structures::stable_hasher::HashStable<__CTX> for
            Path<'hir, R> where __CTX: crate::HashStableContext,
            R: ::rustc_data_structures::stable_hasher::HashStable<__CTX> {
            #[inline]
            fn hash_stable(&self, __hcx: &mut __CTX,
                __hasher:
                    &mut ::rustc_data_structures::stable_hasher::StableHasher) {
                match *self {
                    Path {
                        span: ref __binding_0,
                        res: ref __binding_1,
                        segments: ref __binding_2 } => {
                        { __binding_0.hash_stable(__hcx, __hasher); }
                        { __binding_1.hash_stable(__hcx, __hasher); }
                        { __binding_2.hash_stable(__hcx, __hasher); }
                    }
                }
            }
        }
    };HashStable_Generic)]
349pub struct Path<'hir, R = Res> {
350    pub span: Span,
351    /// The resolution for the path.
352    pub res: R,
353    /// The segments in the path: the things separated by `::`.
354    pub segments: &'hir [PathSegment<'hir>],
355}
356
357/// Up to three resolutions for type, value and macro namespaces.
358pub type UsePath<'hir> = Path<'hir, PerNS<Option<Res>>>;
359
360impl Path<'_> {
361    pub fn is_global(&self) -> bool {
362        self.segments.first().is_some_and(|segment| segment.ident.name == kw::PathRoot)
363    }
364}
365
366/// A segment of a path: an identifier, an optional lifetime, and a set of
367/// types.
368#[derive(#[automatically_derived]
impl<'hir> ::core::fmt::Debug for PathSegment<'hir> {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::debug_struct_field5_finish(f, "PathSegment",
            "ident", &self.ident, "hir_id", &self.hir_id, "res", &self.res,
            "args", &self.args, "infer_args", &&self.infer_args)
    }
}Debug, #[automatically_derived]
impl<'hir> ::core::clone::Clone for PathSegment<'hir> {
    #[inline]
    fn clone(&self) -> PathSegment<'hir> {
        let _: ::core::clone::AssertParamIsClone<Ident>;
        let _: ::core::clone::AssertParamIsClone<HirId>;
        let _: ::core::clone::AssertParamIsClone<Res>;
        let _:
                ::core::clone::AssertParamIsClone<Option<&'hir GenericArgs<'hir>>>;
        let _: ::core::clone::AssertParamIsClone<bool>;
        *self
    }
}Clone, #[automatically_derived]
impl<'hir> ::core::marker::Copy for PathSegment<'hir> { }Copy, const _: () =
    {
        impl<'hir, __CTX>
            ::rustc_data_structures::stable_hasher::HashStable<__CTX> for
            PathSegment<'hir> where __CTX: crate::HashStableContext {
            #[inline]
            fn hash_stable(&self, __hcx: &mut __CTX,
                __hasher:
                    &mut ::rustc_data_structures::stable_hasher::StableHasher) {
                match *self {
                    PathSegment {
                        ident: ref __binding_0,
                        hir_id: ref __binding_1,
                        res: ref __binding_2,
                        args: ref __binding_3,
                        infer_args: ref __binding_4 } => {
                        { __binding_0.hash_stable(__hcx, __hasher); }
                        {}
                        { __binding_2.hash_stable(__hcx, __hasher); }
                        { __binding_3.hash_stable(__hcx, __hasher); }
                        { __binding_4.hash_stable(__hcx, __hasher); }
                    }
                }
            }
        }
    };HashStable_Generic)]
369pub struct PathSegment<'hir> {
370    /// The identifier portion of this path segment.
371    pub ident: Ident,
372    #[stable_hasher(ignore)]
373    pub hir_id: HirId,
374    pub res: Res,
375
376    /// Type/lifetime parameters attached to this path. They come in
377    /// two flavors: `Path<A,B,C>` and `Path(A,B) -> C`. Note that
378    /// this is more than just simple syntactic sugar; the use of
379    /// parens affects the region binding rules, so we preserve the
380    /// distinction.
381    pub args: Option<&'hir GenericArgs<'hir>>,
382
383    /// Whether to infer remaining type parameters, if any.
384    /// This only applies to expression and pattern paths, and
385    /// out of those only the segments with no type parameters
386    /// to begin with, e.g., `Vec::new` is `<Vec<..>>::new::<..>`.
387    pub infer_args: bool,
388}
389
390impl<'hir> PathSegment<'hir> {
391    /// Converts an identifier to the corresponding segment.
392    pub fn new(ident: Ident, hir_id: HirId, res: Res) -> PathSegment<'hir> {
393        PathSegment { ident, hir_id, res, infer_args: true, args: None }
394    }
395
396    pub fn invalid() -> Self {
397        Self::new(Ident::dummy(), HirId::INVALID, Res::Err)
398    }
399
400    pub fn args(&self) -> &GenericArgs<'hir> {
401        if let Some(ref args) = self.args {
402            args
403        } else {
404            const DUMMY: &GenericArgs<'_> = &GenericArgs::none();
405            DUMMY
406        }
407    }
408}
409
410#[derive(#[automatically_derived]
impl<'hir> ::core::clone::Clone for ConstItemRhs<'hir> {
    #[inline]
    fn clone(&self) -> ConstItemRhs<'hir> {
        let _: ::core::clone::AssertParamIsClone<BodyId>;
        let _: ::core::clone::AssertParamIsClone<&'hir ConstArg<'hir>>;
        *self
    }
}Clone, #[automatically_derived]
impl<'hir> ::core::marker::Copy for ConstItemRhs<'hir> { }Copy, #[automatically_derived]
impl<'hir> ::core::fmt::Debug for ConstItemRhs<'hir> {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        match self {
            ConstItemRhs::Body(__self_0) =>
                ::core::fmt::Formatter::debug_tuple_field1_finish(f, "Body",
                    &__self_0),
            ConstItemRhs::TypeConst(__self_0) =>
                ::core::fmt::Formatter::debug_tuple_field1_finish(f,
                    "TypeConst", &__self_0),
        }
    }
}Debug, const _: () =
    {
        impl<'hir, __CTX>
            ::rustc_data_structures::stable_hasher::HashStable<__CTX> for
            ConstItemRhs<'hir> where __CTX: crate::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 {
                    ConstItemRhs::Body(ref __binding_0) => {
                        { __binding_0.hash_stable(__hcx, __hasher); }
                    }
                    ConstItemRhs::TypeConst(ref __binding_0) => {
                        { __binding_0.hash_stable(__hcx, __hasher); }
                    }
                }
            }
        }
    };HashStable_Generic)]
411pub enum ConstItemRhs<'hir> {
412    Body(BodyId),
413    TypeConst(&'hir ConstArg<'hir>),
414}
415
416impl<'hir> ConstItemRhs<'hir> {
417    pub fn hir_id(&self) -> HirId {
418        match self {
419            ConstItemRhs::Body(body_id) => body_id.hir_id,
420            ConstItemRhs::TypeConst(ct_arg) => ct_arg.hir_id,
421        }
422    }
423
424    pub fn span<'tcx>(&self, tcx: impl crate::intravisit::HirTyCtxt<'tcx>) -> Span {
425        match self {
426            ConstItemRhs::Body(body_id) => tcx.hir_body(*body_id).value.span,
427            ConstItemRhs::TypeConst(ct_arg) => ct_arg.span,
428        }
429    }
430}
431
432/// A constant that enters the type system, used for arguments to const generics (e.g. array lengths).
433///
434/// These are distinct from [`AnonConst`] as anon consts in the type system are not allowed
435/// to use any generic parameters, therefore we must represent `N` differently. Additionally
436/// future designs for supporting generic parameters in const arguments will likely not use
437/// an anon const based design.
438///
439/// So, `ConstArg` (specifically, [`ConstArgKind`]) distinguishes between const args
440/// that are [just paths](ConstArgKind::Path) (currently just bare const params)
441/// versus const args that are literals or have arbitrary computations (e.g., `{ 1 + 3 }`).
442///
443/// For an explanation of the `Unambig` generic parameter see the dev-guide:
444/// <https://rustc-dev-guide.rust-lang.org/ambig-unambig-ty-and-consts.html>
445#[derive(#[automatically_derived]
impl<'hir, Unambig: ::core::clone::Clone> ::core::clone::Clone for
    ConstArg<'hir, Unambig> {
    #[inline]
    fn clone(&self) -> ConstArg<'hir, Unambig> {
        ConstArg {
            hir_id: ::core::clone::Clone::clone(&self.hir_id),
            kind: ::core::clone::Clone::clone(&self.kind),
            span: ::core::clone::Clone::clone(&self.span),
        }
    }
}Clone, #[automatically_derived]
impl<'hir, Unambig: ::core::marker::Copy> ::core::marker::Copy for
    ConstArg<'hir, Unambig> {
}Copy, #[automatically_derived]
impl<'hir, Unambig: ::core::fmt::Debug> ::core::fmt::Debug for
    ConstArg<'hir, Unambig> {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::debug_struct_field3_finish(f, "ConstArg",
            "hir_id", &self.hir_id, "kind", &self.kind, "span", &&self.span)
    }
}Debug, const _: () =
    {
        impl<'hir, Unambig, __CTX>
            ::rustc_data_structures::stable_hasher::HashStable<__CTX> for
            ConstArg<'hir, Unambig> where __CTX: crate::HashStableContext,
            Unambig: ::rustc_data_structures::stable_hasher::HashStable<__CTX>
            {
            #[inline]
            fn hash_stable(&self, __hcx: &mut __CTX,
                __hasher:
                    &mut ::rustc_data_structures::stable_hasher::StableHasher) {
                match *self {
                    ConstArg {
                        hir_id: ref __binding_0,
                        kind: ref __binding_1,
                        span: ref __binding_2 } => {
                        {}
                        { __binding_1.hash_stable(__hcx, __hasher); }
                        { __binding_2.hash_stable(__hcx, __hasher); }
                    }
                }
            }
        }
    };HashStable_Generic)]
446#[repr(C)]
447pub struct ConstArg<'hir, Unambig = ()> {
448    #[stable_hasher(ignore)]
449    pub hir_id: HirId,
450    pub kind: ConstArgKind<'hir, Unambig>,
451    pub span: Span,
452}
453
454impl<'hir> ConstArg<'hir, AmbigArg> {
455    /// Converts a `ConstArg` in an ambiguous position to one in an unambiguous position.
456    ///
457    /// Functions accepting unambiguous consts may expect the [`ConstArgKind::Infer`] variant
458    /// to be used. Care should be taken to separately handle infer consts when calling this
459    /// function as it cannot be handled by downstream code making use of the returned const.
460    ///
461    /// In practice this may mean overriding the [`Visitor::visit_infer`][visit_infer] method on hir visitors, or
462    /// specifically matching on [`GenericArg::Infer`] when handling generic arguments.
463    ///
464    /// [visit_infer]: [rustc_hir::intravisit::Visitor::visit_infer]
465    pub fn as_unambig_ct(&self) -> &ConstArg<'hir> {
466        // SAFETY: `ConstArg` is `repr(C)` and `ConstArgKind` is marked `repr(u8)` so that the
467        // layout is the same across different ZST type arguments.
468        let ptr = self as *const ConstArg<'hir, AmbigArg> as *const ConstArg<'hir, ()>;
469        unsafe { &*ptr }
470    }
471}
472
473impl<'hir> ConstArg<'hir> {
474    /// Converts a `ConstArg` in an unambiguous position to one in an ambiguous position. This is
475    /// fallible as the [`ConstArgKind::Infer`] variant is not present in ambiguous positions.
476    ///
477    /// Functions accepting ambiguous consts will not handle the [`ConstArgKind::Infer`] variant, if
478    /// infer consts are relevant to you then care should be taken to handle them separately.
479    pub fn try_as_ambig_ct(&self) -> Option<&ConstArg<'hir, AmbigArg>> {
480        if let ConstArgKind::Infer(()) = self.kind {
481            return None;
482        }
483
484        // SAFETY: `ConstArg` is `repr(C)` and `ConstArgKind` is marked `repr(u8)` so that the layout is
485        // the same across different ZST type arguments. We also asserted that the `self` is
486        // not a `ConstArgKind::Infer` so there is no risk of transmuting a `()` to `AmbigArg`.
487        let ptr = self as *const ConstArg<'hir> as *const ConstArg<'hir, AmbigArg>;
488        Some(unsafe { &*ptr })
489    }
490}
491
492impl<'hir, Unambig> ConstArg<'hir, Unambig> {
493    pub fn anon_const_hir_id(&self) -> Option<HirId> {
494        match self.kind {
495            ConstArgKind::Anon(ac) => Some(ac.hir_id),
496            _ => None,
497        }
498    }
499}
500
501/// See [`ConstArg`].
502#[derive(#[automatically_derived]
impl<'hir, Unambig: ::core::clone::Clone> ::core::clone::Clone for
    ConstArgKind<'hir, Unambig> {
    #[inline]
    fn clone(&self) -> ConstArgKind<'hir, Unambig> {
        match self {
            ConstArgKind::Tup(__self_0) =>
                ConstArgKind::Tup(::core::clone::Clone::clone(__self_0)),
            ConstArgKind::Path(__self_0) =>
                ConstArgKind::Path(::core::clone::Clone::clone(__self_0)),
            ConstArgKind::Anon(__self_0) =>
                ConstArgKind::Anon(::core::clone::Clone::clone(__self_0)),
            ConstArgKind::Struct(__self_0, __self_1) =>
                ConstArgKind::Struct(::core::clone::Clone::clone(__self_0),
                    ::core::clone::Clone::clone(__self_1)),
            ConstArgKind::TupleCall(__self_0, __self_1) =>
                ConstArgKind::TupleCall(::core::clone::Clone::clone(__self_0),
                    ::core::clone::Clone::clone(__self_1)),
            ConstArgKind::Array(__self_0) =>
                ConstArgKind::Array(::core::clone::Clone::clone(__self_0)),
            ConstArgKind::Error(__self_0) =>
                ConstArgKind::Error(::core::clone::Clone::clone(__self_0)),
            ConstArgKind::Infer(__self_0) =>
                ConstArgKind::Infer(::core::clone::Clone::clone(__self_0)),
            ConstArgKind::Literal { lit: __self_0, negated: __self_1 } =>
                ConstArgKind::Literal {
                    lit: ::core::clone::Clone::clone(__self_0),
                    negated: ::core::clone::Clone::clone(__self_1),
                },
        }
    }
}Clone, #[automatically_derived]
impl<'hir, Unambig: ::core::marker::Copy> ::core::marker::Copy for
    ConstArgKind<'hir, Unambig> {
}Copy, #[automatically_derived]
impl<'hir, Unambig: ::core::fmt::Debug> ::core::fmt::Debug for
    ConstArgKind<'hir, Unambig> {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        match self {
            ConstArgKind::Tup(__self_0) =>
                ::core::fmt::Formatter::debug_tuple_field1_finish(f, "Tup",
                    &__self_0),
            ConstArgKind::Path(__self_0) =>
                ::core::fmt::Formatter::debug_tuple_field1_finish(f, "Path",
                    &__self_0),
            ConstArgKind::Anon(__self_0) =>
                ::core::fmt::Formatter::debug_tuple_field1_finish(f, "Anon",
                    &__self_0),
            ConstArgKind::Struct(__self_0, __self_1) =>
                ::core::fmt::Formatter::debug_tuple_field2_finish(f, "Struct",
                    __self_0, &__self_1),
            ConstArgKind::TupleCall(__self_0, __self_1) =>
                ::core::fmt::Formatter::debug_tuple_field2_finish(f,
                    "TupleCall", __self_0, &__self_1),
            ConstArgKind::Array(__self_0) =>
                ::core::fmt::Formatter::debug_tuple_field1_finish(f, "Array",
                    &__self_0),
            ConstArgKind::Error(__self_0) =>
                ::core::fmt::Formatter::debug_tuple_field1_finish(f, "Error",
                    &__self_0),
            ConstArgKind::Infer(__self_0) =>
                ::core::fmt::Formatter::debug_tuple_field1_finish(f, "Infer",
                    &__self_0),
            ConstArgKind::Literal { lit: __self_0, negated: __self_1 } =>
                ::core::fmt::Formatter::debug_struct_field2_finish(f,
                    "Literal", "lit", __self_0, "negated", &__self_1),
        }
    }
}Debug, const _: () =
    {
        impl<'hir, Unambig, __CTX>
            ::rustc_data_structures::stable_hasher::HashStable<__CTX> for
            ConstArgKind<'hir, Unambig> where __CTX: crate::HashStableContext,
            Unambig: ::rustc_data_structures::stable_hasher::HashStable<__CTX>
            {
            #[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 {
                    ConstArgKind::Tup(ref __binding_0) => {
                        { __binding_0.hash_stable(__hcx, __hasher); }
                    }
                    ConstArgKind::Path(ref __binding_0) => {
                        { __binding_0.hash_stable(__hcx, __hasher); }
                    }
                    ConstArgKind::Anon(ref __binding_0) => {
                        { __binding_0.hash_stable(__hcx, __hasher); }
                    }
                    ConstArgKind::Struct(ref __binding_0, ref __binding_1) => {
                        { __binding_0.hash_stable(__hcx, __hasher); }
                        { __binding_1.hash_stable(__hcx, __hasher); }
                    }
                    ConstArgKind::TupleCall(ref __binding_0, ref __binding_1) =>
                        {
                        { __binding_0.hash_stable(__hcx, __hasher); }
                        { __binding_1.hash_stable(__hcx, __hasher); }
                    }
                    ConstArgKind::Array(ref __binding_0) => {
                        { __binding_0.hash_stable(__hcx, __hasher); }
                    }
                    ConstArgKind::Error(ref __binding_0) => {
                        { __binding_0.hash_stable(__hcx, __hasher); }
                    }
                    ConstArgKind::Infer(ref __binding_0) => {
                        { __binding_0.hash_stable(__hcx, __hasher); }
                    }
                    ConstArgKind::Literal {
                        lit: ref __binding_0, negated: ref __binding_1 } => {
                        { __binding_0.hash_stable(__hcx, __hasher); }
                        { __binding_1.hash_stable(__hcx, __hasher); }
                    }
                }
            }
        }
    };HashStable_Generic)]
503#[repr(u8, C)]
504pub enum ConstArgKind<'hir, Unambig = ()> {
505    Tup(&'hir [&'hir ConstArg<'hir, Unambig>]),
506    /// **Note:** Currently this is only used for bare const params
507    /// (`N` where `fn foo<const N: usize>(...)`),
508    /// not paths to any const (`N` where `const N: usize = ...`).
509    ///
510    /// However, in the future, we'll be using it for all of those.
511    Path(QPath<'hir>),
512    Anon(&'hir AnonConst),
513    /// Represents construction of struct/struct variants
514    Struct(QPath<'hir>, &'hir [&'hir ConstArgExprField<'hir>]),
515    /// Tuple constructor variant
516    TupleCall(QPath<'hir>, &'hir [&'hir ConstArg<'hir>]),
517    /// Array literal argument
518    Array(&'hir ConstArgArrayExpr<'hir>),
519    /// Error const
520    Error(ErrorGuaranteed),
521    /// This variant is not always used to represent inference consts, sometimes
522    /// [`GenericArg::Infer`] is used instead.
523    Infer(Unambig),
524    Literal {
525        lit: LitKind,
526        negated: bool,
527    },
528}
529
530#[derive(#[automatically_derived]
impl<'hir> ::core::clone::Clone for ConstArgExprField<'hir> {
    #[inline]
    fn clone(&self) -> ConstArgExprField<'hir> {
        let _: ::core::clone::AssertParamIsClone<HirId>;
        let _: ::core::clone::AssertParamIsClone<Span>;
        let _: ::core::clone::AssertParamIsClone<Ident>;
        let _: ::core::clone::AssertParamIsClone<&'hir ConstArg<'hir>>;
        *self
    }
}Clone, #[automatically_derived]
impl<'hir> ::core::marker::Copy for ConstArgExprField<'hir> { }Copy, #[automatically_derived]
impl<'hir> ::core::fmt::Debug for ConstArgExprField<'hir> {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::debug_struct_field4_finish(f,
            "ConstArgExprField", "hir_id", &self.hir_id, "span", &self.span,
            "field", &self.field, "expr", &&self.expr)
    }
}Debug, const _: () =
    {
        impl<'hir, __CTX>
            ::rustc_data_structures::stable_hasher::HashStable<__CTX> for
            ConstArgExprField<'hir> where __CTX: crate::HashStableContext {
            #[inline]
            fn hash_stable(&self, __hcx: &mut __CTX,
                __hasher:
                    &mut ::rustc_data_structures::stable_hasher::StableHasher) {
                match *self {
                    ConstArgExprField {
                        hir_id: ref __binding_0,
                        span: ref __binding_1,
                        field: ref __binding_2,
                        expr: 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); }
                    }
                }
            }
        }
    };HashStable_Generic)]
531pub struct ConstArgExprField<'hir> {
532    pub hir_id: HirId,
533    pub span: Span,
534    pub field: Ident,
535    pub expr: &'hir ConstArg<'hir>,
536}
537
538#[derive(#[automatically_derived]
impl<'hir> ::core::clone::Clone for ConstArgArrayExpr<'hir> {
    #[inline]
    fn clone(&self) -> ConstArgArrayExpr<'hir> {
        let _: ::core::clone::AssertParamIsClone<Span>;
        let _:
                ::core::clone::AssertParamIsClone<&'hir [&'hir ConstArg<'hir>]>;
        *self
    }
}Clone, #[automatically_derived]
impl<'hir> ::core::marker::Copy for ConstArgArrayExpr<'hir> { }Copy, #[automatically_derived]
impl<'hir> ::core::fmt::Debug for ConstArgArrayExpr<'hir> {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::debug_struct_field2_finish(f,
            "ConstArgArrayExpr", "span", &self.span, "elems", &&self.elems)
    }
}Debug, const _: () =
    {
        impl<'hir, __CTX>
            ::rustc_data_structures::stable_hasher::HashStable<__CTX> for
            ConstArgArrayExpr<'hir> where __CTX: crate::HashStableContext {
            #[inline]
            fn hash_stable(&self, __hcx: &mut __CTX,
                __hasher:
                    &mut ::rustc_data_structures::stable_hasher::StableHasher) {
                match *self {
                    ConstArgArrayExpr {
                        span: ref __binding_0, elems: ref __binding_1 } => {
                        { __binding_0.hash_stable(__hcx, __hasher); }
                        { __binding_1.hash_stable(__hcx, __hasher); }
                    }
                }
            }
        }
    };HashStable_Generic)]
539pub struct ConstArgArrayExpr<'hir> {
540    pub span: Span,
541    pub elems: &'hir [&'hir ConstArg<'hir>],
542}
543
544#[derive(#[automatically_derived]
impl ::core::clone::Clone for InferArg {
    #[inline]
    fn clone(&self) -> InferArg {
        let _: ::core::clone::AssertParamIsClone<HirId>;
        let _: ::core::clone::AssertParamIsClone<Span>;
        *self
    }
}Clone, #[automatically_derived]
impl ::core::marker::Copy for InferArg { }Copy, #[automatically_derived]
impl ::core::fmt::Debug for InferArg {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::debug_struct_field2_finish(f, "InferArg",
            "hir_id", &self.hir_id, "span", &&self.span)
    }
}Debug, const _: () =
    {
        impl<__CTX> ::rustc_data_structures::stable_hasher::HashStable<__CTX>
            for InferArg where __CTX: crate::HashStableContext {
            #[inline]
            fn hash_stable(&self, __hcx: &mut __CTX,
                __hasher:
                    &mut ::rustc_data_structures::stable_hasher::StableHasher) {
                match *self {
                    InferArg { hir_id: ref __binding_0, span: ref __binding_1 }
                        => {
                        {}
                        { __binding_1.hash_stable(__hcx, __hasher); }
                    }
                }
            }
        }
    };HashStable_Generic)]
545pub struct InferArg {
546    #[stable_hasher(ignore)]
547    pub hir_id: HirId,
548    pub span: Span,
549}
550
551impl InferArg {
552    pub fn to_ty(&self) -> Ty<'static> {
553        Ty { kind: TyKind::Infer(()), span: self.span, hir_id: self.hir_id }
554    }
555}
556
557#[derive(#[automatically_derived]
impl<'hir> ::core::fmt::Debug for GenericArg<'hir> {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        match self {
            GenericArg::Lifetime(__self_0) =>
                ::core::fmt::Formatter::debug_tuple_field1_finish(f,
                    "Lifetime", &__self_0),
            GenericArg::Type(__self_0) =>
                ::core::fmt::Formatter::debug_tuple_field1_finish(f, "Type",
                    &__self_0),
            GenericArg::Const(__self_0) =>
                ::core::fmt::Formatter::debug_tuple_field1_finish(f, "Const",
                    &__self_0),
            GenericArg::Infer(__self_0) =>
                ::core::fmt::Formatter::debug_tuple_field1_finish(f, "Infer",
                    &__self_0),
        }
    }
}Debug, #[automatically_derived]
impl<'hir> ::core::clone::Clone for GenericArg<'hir> {
    #[inline]
    fn clone(&self) -> GenericArg<'hir> {
        let _: ::core::clone::AssertParamIsClone<&'hir Lifetime>;
        let _: ::core::clone::AssertParamIsClone<&'hir Ty<'hir, AmbigArg>>;
        let _:
                ::core::clone::AssertParamIsClone<&'hir ConstArg<'hir,
                AmbigArg>>;
        let _: ::core::clone::AssertParamIsClone<InferArg>;
        *self
    }
}Clone, #[automatically_derived]
impl<'hir> ::core::marker::Copy for GenericArg<'hir> { }Copy, const _: () =
    {
        impl<'hir, __CTX>
            ::rustc_data_structures::stable_hasher::HashStable<__CTX> for
            GenericArg<'hir> where __CTX: crate::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 {
                    GenericArg::Lifetime(ref __binding_0) => {
                        { __binding_0.hash_stable(__hcx, __hasher); }
                    }
                    GenericArg::Type(ref __binding_0) => {
                        { __binding_0.hash_stable(__hcx, __hasher); }
                    }
                    GenericArg::Const(ref __binding_0) => {
                        { __binding_0.hash_stable(__hcx, __hasher); }
                    }
                    GenericArg::Infer(ref __binding_0) => {
                        { __binding_0.hash_stable(__hcx, __hasher); }
                    }
                }
            }
        }
    };HashStable_Generic)]
558pub enum GenericArg<'hir> {
559    Lifetime(&'hir Lifetime),
560    Type(&'hir Ty<'hir, AmbigArg>),
561    Const(&'hir ConstArg<'hir, AmbigArg>),
562    /// Inference variables in [`GenericArg`] are always represented by
563    /// `GenericArg::Infer` instead of the `Infer` variants on [`TyKind`] and
564    /// [`ConstArgKind`] as it is not clear until hir ty lowering whether a
565    /// `_` argument is a type or const argument.
566    ///
567    /// However, some builtin types' generic arguments are represented by [`TyKind`]
568    /// without a [`GenericArg`], instead directly storing a [`Ty`] or [`ConstArg`]. In
569    /// such cases they *are* represented by the `Infer` variants on [`TyKind`] and
570    /// [`ConstArgKind`] as it is not ambiguous whether the argument is a type or const.
571    Infer(InferArg),
572}
573
574impl GenericArg<'_> {
575    pub fn span(&self) -> Span {
576        match self {
577            GenericArg::Lifetime(l) => l.ident.span,
578            GenericArg::Type(t) => t.span,
579            GenericArg::Const(c) => c.span,
580            GenericArg::Infer(i) => i.span,
581        }
582    }
583
584    pub fn hir_id(&self) -> HirId {
585        match self {
586            GenericArg::Lifetime(l) => l.hir_id,
587            GenericArg::Type(t) => t.hir_id,
588            GenericArg::Const(c) => c.hir_id,
589            GenericArg::Infer(i) => i.hir_id,
590        }
591    }
592
593    pub fn descr(&self) -> &'static str {
594        match self {
595            GenericArg::Lifetime(_) => "lifetime",
596            GenericArg::Type(_) => "type",
597            GenericArg::Const(_) => "constant",
598            GenericArg::Infer(_) => "placeholder",
599        }
600    }
601
602    pub fn to_ord(&self) -> ast::ParamKindOrd {
603        match self {
604            GenericArg::Lifetime(_) => ast::ParamKindOrd::Lifetime,
605            GenericArg::Type(_) | GenericArg::Const(_) | GenericArg::Infer(_) => {
606                ast::ParamKindOrd::TypeOrConst
607            }
608        }
609    }
610
611    pub fn is_ty_or_const(&self) -> bool {
612        match self {
613            GenericArg::Lifetime(_) => false,
614            GenericArg::Type(_) | GenericArg::Const(_) | GenericArg::Infer(_) => true,
615        }
616    }
617}
618
619/// The generic arguments and associated item constraints of a path segment.
620#[derive(#[automatically_derived]
impl<'hir> ::core::fmt::Debug for GenericArgs<'hir> {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::debug_struct_field4_finish(f, "GenericArgs",
            "args", &self.args, "constraints", &self.constraints,
            "parenthesized", &self.parenthesized, "span_ext", &&self.span_ext)
    }
}Debug, #[automatically_derived]
impl<'hir> ::core::clone::Clone for GenericArgs<'hir> {
    #[inline]
    fn clone(&self) -> GenericArgs<'hir> {
        let _: ::core::clone::AssertParamIsClone<&'hir [GenericArg<'hir>]>;
        let _:
                ::core::clone::AssertParamIsClone<&'hir [AssocItemConstraint<'hir>]>;
        let _: ::core::clone::AssertParamIsClone<GenericArgsParentheses>;
        let _: ::core::clone::AssertParamIsClone<Span>;
        *self
    }
}Clone, #[automatically_derived]
impl<'hir> ::core::marker::Copy for GenericArgs<'hir> { }Copy, const _: () =
    {
        impl<'hir, __CTX>
            ::rustc_data_structures::stable_hasher::HashStable<__CTX> for
            GenericArgs<'hir> where __CTX: crate::HashStableContext {
            #[inline]
            fn hash_stable(&self, __hcx: &mut __CTX,
                __hasher:
                    &mut ::rustc_data_structures::stable_hasher::StableHasher) {
                match *self {
                    GenericArgs {
                        args: ref __binding_0,
                        constraints: ref __binding_1,
                        parenthesized: ref __binding_2,
                        span_ext: 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); }
                    }
                }
            }
        }
    };HashStable_Generic)]
621pub struct GenericArgs<'hir> {
622    /// The generic arguments for this path segment.
623    pub args: &'hir [GenericArg<'hir>],
624    /// The associated item constraints for this path segment.
625    pub constraints: &'hir [AssocItemConstraint<'hir>],
626    /// Whether the arguments were written in parenthesized form (e.g., `Fn(T) -> U`).
627    ///
628    /// This is required mostly for pretty-printing and diagnostics,
629    /// but also for changing lifetime elision rules to be "function-like".
630    pub parenthesized: GenericArgsParentheses,
631    /// The span encompassing the arguments, constraints and the surrounding brackets (`<>` or `()`).
632    ///
633    /// For example:
634    ///
635    /// ```ignore (illustrative)
636    ///       Foo<A, B, AssocTy = D>           Fn(T, U, V) -> W
637    ///          ^^^^^^^^^^^^^^^^^^^             ^^^^^^^^^
638    /// ```
639    ///
640    /// Note that this may be:
641    /// - empty, if there are no generic brackets (but there may be hidden lifetimes)
642    /// - dummy, if this was generated during desugaring
643    pub span_ext: Span,
644}
645
646impl<'hir> GenericArgs<'hir> {
647    pub const fn none() -> Self {
648        Self {
649            args: &[],
650            constraints: &[],
651            parenthesized: GenericArgsParentheses::No,
652            span_ext: DUMMY_SP,
653        }
654    }
655
656    /// Obtain the list of input types and the output type if the generic arguments are parenthesized.
657    ///
658    /// Returns the `Ty0, Ty1, ...` and the `RetTy` in `Trait(Ty0, Ty1, ...) -> RetTy`.
659    /// Panics if the parenthesized arguments have an incorrect form (this shouldn't happen).
660    pub fn paren_sugar_inputs_output(&self) -> Option<(&[Ty<'hir>], &Ty<'hir>)> {
661        if self.parenthesized != GenericArgsParentheses::ParenSugar {
662            return None;
663        }
664
665        let inputs = self
666            .args
667            .iter()
668            .find_map(|arg| {
669                let GenericArg::Type(ty) = arg else { return None };
670                let TyKind::Tup(tys) = &ty.kind else { return None };
671                Some(tys)
672            })
673            .unwrap();
674
675        Some((inputs, self.paren_sugar_output_inner()))
676    }
677
678    /// Obtain the output type if the generic arguments are parenthesized.
679    ///
680    /// Returns the `RetTy` in `Trait(Ty0, Ty1, ...) -> RetTy`.
681    /// Panics if the parenthesized arguments have an incorrect form (this shouldn't happen).
682    pub fn paren_sugar_output(&self) -> Option<&Ty<'hir>> {
683        (self.parenthesized == GenericArgsParentheses::ParenSugar)
684            .then(|| self.paren_sugar_output_inner())
685    }
686
687    fn paren_sugar_output_inner(&self) -> &Ty<'hir> {
688        let [constraint] = self.constraints.try_into().unwrap();
689        if true {
    match (&constraint.ident.name, &sym::Output) {
        (left_val, right_val) => {
            if !(*left_val == *right_val) {
                let kind = ::core::panicking::AssertKind::Eq;
                ::core::panicking::assert_failed(kind, &*left_val,
                    &*right_val, ::core::option::Option::None);
            }
        }
    };
};debug_assert_eq!(constraint.ident.name, sym::Output);
690        constraint.ty().unwrap()
691    }
692
693    pub fn has_err(&self) -> Option<ErrorGuaranteed> {
694        self.args
695            .iter()
696            .find_map(|arg| {
697                let GenericArg::Type(ty) = arg else { return None };
698                let TyKind::Err(guar) = ty.kind else { return None };
699                Some(guar)
700            })
701            .or_else(|| {
702                self.constraints.iter().find_map(|constraint| {
703                    let TyKind::Err(guar) = constraint.ty()?.kind else { return None };
704                    Some(guar)
705                })
706            })
707    }
708
709    #[inline]
710    pub fn num_lifetime_params(&self) -> usize {
711        self.args.iter().filter(|arg| #[allow(non_exhaustive_omitted_patterns)] match arg {
    GenericArg::Lifetime(_) => true,
    _ => false,
}matches!(arg, GenericArg::Lifetime(_))).count()
712    }
713
714    #[inline]
715    pub fn has_lifetime_params(&self) -> bool {
716        self.args.iter().any(|arg| #[allow(non_exhaustive_omitted_patterns)] match arg {
    GenericArg::Lifetime(_) => true,
    _ => false,
}matches!(arg, GenericArg::Lifetime(_)))
717    }
718
719    #[inline]
720    /// This function returns the number of type and const generic params.
721    /// It should only be used for diagnostics.
722    pub fn num_generic_params(&self) -> usize {
723        self.args.iter().filter(|arg| !#[allow(non_exhaustive_omitted_patterns)] match arg {
    GenericArg::Lifetime(_) => true,
    _ => false,
}matches!(arg, GenericArg::Lifetime(_))).count()
724    }
725
726    /// The span encompassing the arguments and constraints[^1] inside the surrounding brackets.
727    ///
728    /// Returns `None` if the span is empty (i.e., no brackets) or dummy.
729    ///
730    /// [^1]: Unless of the form `-> Ty` (see [`GenericArgsParentheses`]).
731    pub fn span(&self) -> Option<Span> {
732        let span_ext = self.span_ext()?;
733        Some(span_ext.with_lo(span_ext.lo() + BytePos(1)).with_hi(span_ext.hi() - BytePos(1)))
734    }
735
736    /// Returns span encompassing arguments and their surrounding `<>` or `()`
737    pub fn span_ext(&self) -> Option<Span> {
738        Some(self.span_ext).filter(|span| !span.is_empty())
739    }
740
741    pub fn is_empty(&self) -> bool {
742        self.args.is_empty()
743    }
744}
745
746#[derive(#[automatically_derived]
impl ::core::marker::Copy for GenericArgsParentheses { }Copy, #[automatically_derived]
impl ::core::clone::Clone for GenericArgsParentheses {
    #[inline]
    fn clone(&self) -> GenericArgsParentheses { *self }
}Clone, #[automatically_derived]
impl ::core::cmp::PartialEq for GenericArgsParentheses {
    #[inline]
    fn eq(&self, other: &GenericArgsParentheses) -> 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 GenericArgsParentheses {
    #[inline]
    #[doc(hidden)]
    #[coverage(off)]
    fn assert_fields_are_eq(&self) {}
}Eq, #[automatically_derived]
impl ::core::fmt::Debug for GenericArgsParentheses {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::write_str(f,
            match self {
                GenericArgsParentheses::No => "No",
                GenericArgsParentheses::ReturnTypeNotation =>
                    "ReturnTypeNotation",
                GenericArgsParentheses::ParenSugar => "ParenSugar",
            })
    }
}Debug, const _: () =
    {
        impl<__CTX> ::rustc_data_structures::stable_hasher::HashStable<__CTX>
            for GenericArgsParentheses where __CTX: crate::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 {
                    GenericArgsParentheses::No => {}
                    GenericArgsParentheses::ReturnTypeNotation => {}
                    GenericArgsParentheses::ParenSugar => {}
                }
            }
        }
    };HashStable_Generic)]
747pub enum GenericArgsParentheses {
748    No,
749    /// Bounds for `feature(return_type_notation)`, like `T: Trait<method(..): Send>`,
750    /// where the args are explicitly elided with `..`
751    ReturnTypeNotation,
752    /// parenthesized function-family traits, like `T: Fn(u32) -> i32`
753    ParenSugar,
754}
755
756/// The modifiers on a trait bound.
757#[derive(#[automatically_derived]
impl ::core::marker::Copy for TraitBoundModifiers { }Copy, #[automatically_derived]
impl ::core::clone::Clone for TraitBoundModifiers {
    #[inline]
    fn clone(&self) -> TraitBoundModifiers {
        let _: ::core::clone::AssertParamIsClone<BoundConstness>;
        let _: ::core::clone::AssertParamIsClone<BoundPolarity>;
        *self
    }
}Clone, #[automatically_derived]
impl ::core::cmp::PartialEq for TraitBoundModifiers {
    #[inline]
    fn eq(&self, other: &TraitBoundModifiers) -> bool {
        self.constness == other.constness && self.polarity == other.polarity
    }
}PartialEq, #[automatically_derived]
impl ::core::cmp::Eq for TraitBoundModifiers {
    #[inline]
    #[doc(hidden)]
    #[coverage(off)]
    fn assert_fields_are_eq(&self) {
        let _: ::core::cmp::AssertParamIsEq<BoundConstness>;
        let _: ::core::cmp::AssertParamIsEq<BoundPolarity>;
    }
}Eq, #[automatically_derived]
impl ::core::hash::Hash for TraitBoundModifiers {
    #[inline]
    fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) {
        ::core::hash::Hash::hash(&self.constness, state);
        ::core::hash::Hash::hash(&self.polarity, state)
    }
}Hash, #[automatically_derived]
impl ::core::fmt::Debug for TraitBoundModifiers {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::debug_struct_field2_finish(f,
            "TraitBoundModifiers", "constness", &self.constness, "polarity",
            &&self.polarity)
    }
}Debug, const _: () =
    {
        impl<__CTX> ::rustc_data_structures::stable_hasher::HashStable<__CTX>
            for TraitBoundModifiers where __CTX: crate::HashStableContext {
            #[inline]
            fn hash_stable(&self, __hcx: &mut __CTX,
                __hasher:
                    &mut ::rustc_data_structures::stable_hasher::StableHasher) {
                match *self {
                    TraitBoundModifiers {
                        constness: ref __binding_0, polarity: ref __binding_1 } => {
                        { __binding_0.hash_stable(__hcx, __hasher); }
                        { __binding_1.hash_stable(__hcx, __hasher); }
                    }
                }
            }
        }
    };HashStable_Generic)]
758pub struct TraitBoundModifiers {
759    pub constness: BoundConstness,
760    pub polarity: BoundPolarity,
761}
762
763impl TraitBoundModifiers {
764    pub const NONE: Self =
765        TraitBoundModifiers { constness: BoundConstness::Never, polarity: BoundPolarity::Positive };
766}
767
768#[derive(#[automatically_derived]
impl<'hir> ::core::clone::Clone for GenericBound<'hir> {
    #[inline]
    fn clone(&self) -> GenericBound<'hir> {
        let _: ::core::clone::AssertParamIsClone<PolyTraitRef<'hir>>;
        let _: ::core::clone::AssertParamIsClone<&'hir Lifetime>;
        let _:
                ::core::clone::AssertParamIsClone<&'hir [PreciseCapturingArg<'hir>]>;
        let _: ::core::clone::AssertParamIsClone<Span>;
        *self
    }
}Clone, #[automatically_derived]
impl<'hir> ::core::marker::Copy for GenericBound<'hir> { }Copy, #[automatically_derived]
impl<'hir> ::core::fmt::Debug for GenericBound<'hir> {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        match self {
            GenericBound::Trait(__self_0) =>
                ::core::fmt::Formatter::debug_tuple_field1_finish(f, "Trait",
                    &__self_0),
            GenericBound::Outlives(__self_0) =>
                ::core::fmt::Formatter::debug_tuple_field1_finish(f,
                    "Outlives", &__self_0),
            GenericBound::Use(__self_0, __self_1) =>
                ::core::fmt::Formatter::debug_tuple_field2_finish(f, "Use",
                    __self_0, &__self_1),
        }
    }
}Debug, const _: () =
    {
        impl<'hir, __CTX>
            ::rustc_data_structures::stable_hasher::HashStable<__CTX> for
            GenericBound<'hir> where __CTX: crate::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 {
                    GenericBound::Trait(ref __binding_0) => {
                        { __binding_0.hash_stable(__hcx, __hasher); }
                    }
                    GenericBound::Outlives(ref __binding_0) => {
                        { __binding_0.hash_stable(__hcx, __hasher); }
                    }
                    GenericBound::Use(ref __binding_0, ref __binding_1) => {
                        { __binding_0.hash_stable(__hcx, __hasher); }
                        { __binding_1.hash_stable(__hcx, __hasher); }
                    }
                }
            }
        }
    };HashStable_Generic)]
769pub enum GenericBound<'hir> {
770    Trait(PolyTraitRef<'hir>),
771    Outlives(&'hir Lifetime),
772    Use(&'hir [PreciseCapturingArg<'hir>], Span),
773}
774
775impl GenericBound<'_> {
776    pub fn trait_ref(&self) -> Option<&TraitRef<'_>> {
777        match self {
778            GenericBound::Trait(data) => Some(&data.trait_ref),
779            _ => None,
780        }
781    }
782
783    pub fn span(&self) -> Span {
784        match self {
785            GenericBound::Trait(t, ..) => t.span,
786            GenericBound::Outlives(l) => l.ident.span,
787            GenericBound::Use(_, span) => *span,
788        }
789    }
790}
791
792pub type GenericBounds<'hir> = &'hir [GenericBound<'hir>];
793
794#[derive(#[automatically_derived]
impl ::core::marker::Copy for MissingLifetimeKind { }Copy, #[automatically_derived]
impl ::core::clone::Clone for MissingLifetimeKind {
    #[inline]
    fn clone(&self) -> MissingLifetimeKind { *self }
}Clone, #[automatically_derived]
impl ::core::cmp::PartialEq for MissingLifetimeKind {
    #[inline]
    fn eq(&self, other: &MissingLifetimeKind) -> 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 MissingLifetimeKind {
    #[inline]
    #[doc(hidden)]
    #[coverage(off)]
    fn assert_fields_are_eq(&self) {}
}Eq, #[automatically_derived]
impl ::core::cmp::PartialOrd for MissingLifetimeKind {
    #[inline]
    fn partial_cmp(&self, other: &MissingLifetimeKind)
        -> ::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 MissingLifetimeKind {
    #[inline]
    fn cmp(&self, other: &MissingLifetimeKind) -> ::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, #[automatically_derived]
impl ::core::hash::Hash for MissingLifetimeKind {
    #[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<__CTX> ::rustc_data_structures::stable_hasher::HashStable<__CTX>
            for MissingLifetimeKind where __CTX: crate::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 {
                    MissingLifetimeKind::Underscore => {}
                    MissingLifetimeKind::Ampersand => {}
                    MissingLifetimeKind::Comma => {}
                    MissingLifetimeKind::Brackets => {}
                }
            }
        }
    };HashStable_Generic, #[automatically_derived]
impl ::core::fmt::Debug for MissingLifetimeKind {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::write_str(f,
            match self {
                MissingLifetimeKind::Underscore => "Underscore",
                MissingLifetimeKind::Ampersand => "Ampersand",
                MissingLifetimeKind::Comma => "Comma",
                MissingLifetimeKind::Brackets => "Brackets",
            })
    }
}Debug)]
795pub enum MissingLifetimeKind {
796    /// An explicit `'_`.
797    Underscore,
798    /// An elided lifetime `&' ty`.
799    Ampersand,
800    /// An elided lifetime in brackets with written brackets.
801    Comma,
802    /// An elided lifetime with elided brackets.
803    Brackets,
804}
805
806#[derive(#[automatically_derived]
impl ::core::marker::Copy for LifetimeParamKind { }Copy, #[automatically_derived]
impl ::core::clone::Clone for LifetimeParamKind {
    #[inline]
    fn clone(&self) -> LifetimeParamKind {
        let _: ::core::clone::AssertParamIsClone<MissingLifetimeKind>;
        *self
    }
}Clone, #[automatically_derived]
impl ::core::fmt::Debug for LifetimeParamKind {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        match self {
            LifetimeParamKind::Explicit =>
                ::core::fmt::Formatter::write_str(f, "Explicit"),
            LifetimeParamKind::Elided(__self_0) =>
                ::core::fmt::Formatter::debug_tuple_field1_finish(f, "Elided",
                    &__self_0),
            LifetimeParamKind::Error =>
                ::core::fmt::Formatter::write_str(f, "Error"),
        }
    }
}Debug, const _: () =
    {
        impl<__CTX> ::rustc_data_structures::stable_hasher::HashStable<__CTX>
            for LifetimeParamKind where __CTX: crate::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 {
                    LifetimeParamKind::Explicit => {}
                    LifetimeParamKind::Elided(ref __binding_0) => {
                        { __binding_0.hash_stable(__hcx, __hasher); }
                    }
                    LifetimeParamKind::Error => {}
                }
            }
        }
    };HashStable_Generic)]
807pub enum LifetimeParamKind {
808    // Indicates that the lifetime definition was explicitly declared (e.g., in
809    // `fn foo<'a>(x: &'a u8) -> &'a u8 { x }`).
810    Explicit,
811
812    // Indication that the lifetime was elided (e.g., in both cases in
813    // `fn foo(x: &u8) -> &'_ u8 { x }`).
814    Elided(MissingLifetimeKind),
815
816    // Indication that the lifetime name was somehow in error.
817    Error,
818}
819
820#[derive(#[automatically_derived]
impl<'hir> ::core::fmt::Debug for GenericParamKind<'hir> {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        match self {
            GenericParamKind::Lifetime { kind: __self_0 } =>
                ::core::fmt::Formatter::debug_struct_field1_finish(f,
                    "Lifetime", "kind", &__self_0),
            GenericParamKind::Type { default: __self_0, synthetic: __self_1 }
                =>
                ::core::fmt::Formatter::debug_struct_field2_finish(f, "Type",
                    "default", __self_0, "synthetic", &__self_1),
            GenericParamKind::Const { ty: __self_0, default: __self_1 } =>
                ::core::fmt::Formatter::debug_struct_field2_finish(f, "Const",
                    "ty", __self_0, "default", &__self_1),
        }
    }
}Debug, #[automatically_derived]
impl<'hir> ::core::clone::Clone for GenericParamKind<'hir> {
    #[inline]
    fn clone(&self) -> GenericParamKind<'hir> {
        let _: ::core::clone::AssertParamIsClone<LifetimeParamKind>;
        let _: ::core::clone::AssertParamIsClone<Option<&'hir Ty<'hir>>>;
        let _: ::core::clone::AssertParamIsClone<bool>;
        let _: ::core::clone::AssertParamIsClone<&'hir Ty<'hir>>;
        let _:
                ::core::clone::AssertParamIsClone<Option<&'hir ConstArg<'hir>>>;
        *self
    }
}Clone, #[automatically_derived]
impl<'hir> ::core::marker::Copy for GenericParamKind<'hir> { }Copy, const _: () =
    {
        impl<'hir, __CTX>
            ::rustc_data_structures::stable_hasher::HashStable<__CTX> for
            GenericParamKind<'hir> where __CTX: crate::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 {
                    GenericParamKind::Lifetime { kind: ref __binding_0 } => {
                        { __binding_0.hash_stable(__hcx, __hasher); }
                    }
                    GenericParamKind::Type {
                        default: ref __binding_0, synthetic: ref __binding_1 } => {
                        { __binding_0.hash_stable(__hcx, __hasher); }
                        { __binding_1.hash_stable(__hcx, __hasher); }
                    }
                    GenericParamKind::Const {
                        ty: ref __binding_0, default: ref __binding_1 } => {
                        { __binding_0.hash_stable(__hcx, __hasher); }
                        { __binding_1.hash_stable(__hcx, __hasher); }
                    }
                }
            }
        }
    };HashStable_Generic)]
821pub enum GenericParamKind<'hir> {
822    /// A lifetime definition (e.g., `'a: 'b + 'c + 'd`).
823    Lifetime {
824        kind: LifetimeParamKind,
825    },
826    Type {
827        default: Option<&'hir Ty<'hir>>,
828        synthetic: bool,
829    },
830    Const {
831        ty: &'hir Ty<'hir>,
832        /// Optional default value for the const generic param
833        default: Option<&'hir ConstArg<'hir>>,
834    },
835}
836
837#[derive(#[automatically_derived]
impl<'hir> ::core::fmt::Debug for GenericParam<'hir> {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        let names: &'static _ =
            &["hir_id", "def_id", "name", "span", "pure_wrt_drop", "kind",
                        "colon_span", "source"];
        let values: &[&dyn ::core::fmt::Debug] =
            &[&self.hir_id, &self.def_id, &self.name, &self.span,
                        &self.pure_wrt_drop, &self.kind, &self.colon_span,
                        &&self.source];
        ::core::fmt::Formatter::debug_struct_fields_finish(f, "GenericParam",
            names, values)
    }
}Debug, #[automatically_derived]
impl<'hir> ::core::clone::Clone for GenericParam<'hir> {
    #[inline]
    fn clone(&self) -> GenericParam<'hir> {
        let _: ::core::clone::AssertParamIsClone<HirId>;
        let _: ::core::clone::AssertParamIsClone<LocalDefId>;
        let _: ::core::clone::AssertParamIsClone<ParamName>;
        let _: ::core::clone::AssertParamIsClone<Span>;
        let _: ::core::clone::AssertParamIsClone<bool>;
        let _: ::core::clone::AssertParamIsClone<GenericParamKind<'hir>>;
        let _: ::core::clone::AssertParamIsClone<Option<Span>>;
        let _: ::core::clone::AssertParamIsClone<GenericParamSource>;
        *self
    }
}Clone, #[automatically_derived]
impl<'hir> ::core::marker::Copy for GenericParam<'hir> { }Copy, const _: () =
    {
        impl<'hir, __CTX>
            ::rustc_data_structures::stable_hasher::HashStable<__CTX> for
            GenericParam<'hir> where __CTX: crate::HashStableContext {
            #[inline]
            fn hash_stable(&self, __hcx: &mut __CTX,
                __hasher:
                    &mut ::rustc_data_structures::stable_hasher::StableHasher) {
                match *self {
                    GenericParam {
                        hir_id: ref __binding_0,
                        def_id: ref __binding_1,
                        name: ref __binding_2,
                        span: ref __binding_3,
                        pure_wrt_drop: ref __binding_4,
                        kind: ref __binding_5,
                        colon_span: ref __binding_6,
                        source: ref __binding_7 } => {
                        {}
                        { __binding_1.hash_stable(__hcx, __hasher); }
                        { __binding_2.hash_stable(__hcx, __hasher); }
                        { __binding_3.hash_stable(__hcx, __hasher); }
                        { __binding_4.hash_stable(__hcx, __hasher); }
                        { __binding_5.hash_stable(__hcx, __hasher); }
                        { __binding_6.hash_stable(__hcx, __hasher); }
                        { __binding_7.hash_stable(__hcx, __hasher); }
                    }
                }
            }
        }
    };HashStable_Generic)]
838pub struct GenericParam<'hir> {
839    #[stable_hasher(ignore)]
840    pub hir_id: HirId,
841    pub def_id: LocalDefId,
842    pub name: ParamName,
843    pub span: Span,
844    pub pure_wrt_drop: bool,
845    pub kind: GenericParamKind<'hir>,
846    pub colon_span: Option<Span>,
847    pub source: GenericParamSource,
848}
849
850impl<'hir> GenericParam<'hir> {
851    /// Synthetic type-parameters are inserted after normal ones.
852    /// In order for normal parameters to be able to refer to synthetic ones,
853    /// scans them first.
854    pub fn is_impl_trait(&self) -> bool {
855        #[allow(non_exhaustive_omitted_patterns)] match self.kind {
    GenericParamKind::Type { synthetic: true, .. } => true,
    _ => false,
}matches!(self.kind, GenericParamKind::Type { synthetic: true, .. })
856    }
857
858    /// This can happen for `async fn`, e.g. `async fn f<'_>(&'_ self)`.
859    ///
860    /// See `lifetime_to_generic_param` in `rustc_ast_lowering` for more information.
861    pub fn is_elided_lifetime(&self) -> bool {
862        #[allow(non_exhaustive_omitted_patterns)] match self.kind {
    GenericParamKind::Lifetime { kind: LifetimeParamKind::Elided(_) } => true,
    _ => false,
}matches!(self.kind, GenericParamKind::Lifetime { kind: LifetimeParamKind::Elided(_) })
863    }
864
865    pub fn is_lifetime(&self) -> bool {
866        #[allow(non_exhaustive_omitted_patterns)] match self.kind {
    GenericParamKind::Lifetime { .. } => true,
    _ => false,
}matches!(self.kind, GenericParamKind::Lifetime { .. })
867    }
868}
869
870/// Records where the generic parameter originated from.
871///
872/// This can either be from an item's generics, in which case it's typically
873/// early-bound (but can be a late-bound lifetime in functions, for example),
874/// or from a `for<...>` binder, in which case it's late-bound (and notably,
875/// does not show up in the parent item's generics).
876#[derive(#[automatically_derived]
impl ::core::fmt::Debug for GenericParamSource {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::write_str(f,
            match self {
                GenericParamSource::Generics => "Generics",
                GenericParamSource::Binder => "Binder",
            })
    }
}Debug, #[automatically_derived]
impl ::core::clone::Clone for GenericParamSource {
    #[inline]
    fn clone(&self) -> GenericParamSource { *self }
}Clone, #[automatically_derived]
impl ::core::marker::Copy for GenericParamSource { }Copy, const _: () =
    {
        impl<__CTX> ::rustc_data_structures::stable_hasher::HashStable<__CTX>
            for GenericParamSource where __CTX: crate::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 {
                    GenericParamSource::Generics => {}
                    GenericParamSource::Binder => {}
                }
            }
        }
    };HashStable_Generic)]
877pub enum GenericParamSource {
878    // Early or late-bound parameters defined on an item
879    Generics,
880    // Late-bound parameters defined via a `for<...>`
881    Binder,
882}
883
884#[derive(#[automatically_derived]
impl ::core::default::Default for GenericParamCount {
    #[inline]
    fn default() -> GenericParamCount {
        GenericParamCount {
            lifetimes: ::core::default::Default::default(),
            types: ::core::default::Default::default(),
            consts: ::core::default::Default::default(),
            infer: ::core::default::Default::default(),
        }
    }
}Default)]
885pub struct GenericParamCount {
886    pub lifetimes: usize,
887    pub types: usize,
888    pub consts: usize,
889    pub infer: usize,
890}
891
892/// Represents lifetimes and type parameters attached to a declaration
893/// of a function, enum, trait, etc.
894#[derive(#[automatically_derived]
impl<'hir> ::core::fmt::Debug for Generics<'hir> {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::debug_struct_field5_finish(f, "Generics",
            "params", &self.params, "predicates", &self.predicates,
            "has_where_clause_predicates", &self.has_where_clause_predicates,
            "where_clause_span", &self.where_clause_span, "span", &&self.span)
    }
}Debug, #[automatically_derived]
impl<'hir> ::core::clone::Clone for Generics<'hir> {
    #[inline]
    fn clone(&self) -> Generics<'hir> {
        let _: ::core::clone::AssertParamIsClone<&'hir [GenericParam<'hir>]>;
        let _:
                ::core::clone::AssertParamIsClone<&'hir [WherePredicate<'hir>]>;
        let _: ::core::clone::AssertParamIsClone<bool>;
        let _: ::core::clone::AssertParamIsClone<Span>;
        *self
    }
}Clone, #[automatically_derived]
impl<'hir> ::core::marker::Copy for Generics<'hir> { }Copy, const _: () =
    {
        impl<'hir, __CTX>
            ::rustc_data_structures::stable_hasher::HashStable<__CTX> for
            Generics<'hir> where __CTX: crate::HashStableContext {
            #[inline]
            fn hash_stable(&self, __hcx: &mut __CTX,
                __hasher:
                    &mut ::rustc_data_structures::stable_hasher::StableHasher) {
                match *self {
                    Generics {
                        params: ref __binding_0,
                        predicates: ref __binding_1,
                        has_where_clause_predicates: ref __binding_2,
                        where_clause_span: ref __binding_3,
                        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); }
                    }
                }
            }
        }
    };HashStable_Generic)]
895pub struct Generics<'hir> {
896    pub params: &'hir [GenericParam<'hir>],
897    pub predicates: &'hir [WherePredicate<'hir>],
898    pub has_where_clause_predicates: bool,
899    pub where_clause_span: Span,
900    pub span: Span,
901}
902
903impl<'hir> Generics<'hir> {
904    pub const fn empty() -> &'hir Generics<'hir> {
905        const NOPE: Generics<'_> = Generics {
906            params: &[],
907            predicates: &[],
908            has_where_clause_predicates: false,
909            where_clause_span: DUMMY_SP,
910            span: DUMMY_SP,
911        };
912        &NOPE
913    }
914
915    pub fn get_named(&self, name: Symbol) -> Option<&GenericParam<'hir>> {
916        self.params.iter().find(|&param| name == param.name.ident().name)
917    }
918
919    /// If there are generic parameters, return where to introduce a new one.
920    pub fn span_for_lifetime_suggestion(&self) -> Option<Span> {
921        if let Some(first) = self.params.first()
922            && self.span.contains(first.span)
923        {
924            // `fn foo<A>(t: impl Trait)`
925            //         ^ suggest `'a, ` here
926            Some(first.span.shrink_to_lo())
927        } else {
928            None
929        }
930    }
931
932    /// If there are generic parameters, return where to introduce a new one.
933    pub fn span_for_param_suggestion(&self) -> Option<Span> {
934        self.params.iter().any(|p| self.span.contains(p.span)).then(|| {
935            // `fn foo<A>(t: impl Trait)`
936            //          ^ suggest `, T: Trait` here
937            self.span.with_lo(self.span.hi() - BytePos(1)).shrink_to_lo()
938        })
939    }
940
941    /// `Span` where further predicates would be suggested, accounting for trailing commas, like
942    ///  in `fn foo<T>(t: T) where T: Foo,` so we don't suggest two trailing commas.
943    pub fn tail_span_for_predicate_suggestion(&self) -> Span {
944        let end = self.where_clause_span.shrink_to_hi();
945        if self.has_where_clause_predicates {
946            self.predicates
947                .iter()
948                .rfind(|&p| p.kind.in_where_clause())
949                .map_or(end, |p| p.span)
950                .shrink_to_hi()
951                .to(end)
952        } else {
953            end
954        }
955    }
956
957    pub fn add_where_or_trailing_comma(&self) -> &'static str {
958        if self.has_where_clause_predicates {
959            ","
960        } else if self.where_clause_span.is_empty() {
961            " where"
962        } else {
963            // No where clause predicates, but we have `where` token
964            ""
965        }
966    }
967
968    pub fn bounds_for_param(
969        &self,
970        param_def_id: LocalDefId,
971    ) -> impl Iterator<Item = &WhereBoundPredicate<'hir>> {
972        self.predicates.iter().filter_map(move |pred| match pred.kind {
973            WherePredicateKind::BoundPredicate(bp)
974                if bp.is_param_bound(param_def_id.to_def_id()) =>
975            {
976                Some(bp)
977            }
978            _ => None,
979        })
980    }
981
982    pub fn outlives_for_param(
983        &self,
984        param_def_id: LocalDefId,
985    ) -> impl Iterator<Item = &WhereRegionPredicate<'_>> {
986        self.predicates.iter().filter_map(move |pred| match pred.kind {
987            WherePredicateKind::RegionPredicate(rp) if rp.is_param_bound(param_def_id) => Some(rp),
988            _ => None,
989        })
990    }
991
992    /// Returns a suggestable empty span right after the "final" bound of the generic parameter.
993    ///
994    /// If that bound needs to be wrapped in parentheses to avoid ambiguity with
995    /// subsequent bounds, it also returns an empty span for an open parenthesis
996    /// as the second component.
997    ///
998    /// E.g., adding `+ 'static` after `Fn() -> dyn Future<Output = ()>` or
999    /// `Fn() -> &'static dyn Debug` requires parentheses:
1000    /// `Fn() -> (dyn Future<Output = ()>) + 'static` and
1001    /// `Fn() -> &'static (dyn Debug) + 'static`, respectively.
1002    pub fn bounds_span_for_suggestions(
1003        &self,
1004        param_def_id: LocalDefId,
1005    ) -> Option<(Span, Option<Span>)> {
1006        self.bounds_for_param(param_def_id).flat_map(|bp| bp.bounds.iter().rev()).find_map(
1007            |bound| {
1008                let span_for_parentheses = if let Some(trait_ref) = bound.trait_ref()
1009                    && let [.., segment] = trait_ref.path.segments
1010                    && let Some(ret_ty) = segment.args().paren_sugar_output()
1011                    && let ret_ty = ret_ty.peel_refs()
1012                    && let TyKind::TraitObject(_, tagged_ptr) = ret_ty.kind
1013                    && let TraitObjectSyntax::Dyn = tagged_ptr.tag()
1014                    && ret_ty.span.can_be_used_for_suggestions()
1015                {
1016                    Some(ret_ty.span)
1017                } else {
1018                    None
1019                };
1020
1021                span_for_parentheses.map_or_else(
1022                    || {
1023                        // We include bounds that come from a `#[derive(_)]` but point at the user's
1024                        // code, as we use this method to get a span appropriate for suggestions.
1025                        let bs = bound.span();
1026                        // We use `from_expansion` instead of `can_be_used_for_suggestions` because
1027                        // the trait bound from imperfect derives do point at the type parameter,
1028                        // but expanded to a where clause, so we want to ignore those. This is only
1029                        // true for derive intrinsics.
1030                        bs.from_expansion().not().then(|| (bs.shrink_to_hi(), None))
1031                    },
1032                    |span| Some((span.shrink_to_hi(), Some(span.shrink_to_lo()))),
1033                )
1034            },
1035        )
1036    }
1037
1038    pub fn span_for_predicate_removal(&self, pos: usize) -> Span {
1039        let predicate = &self.predicates[pos];
1040        let span = predicate.span;
1041
1042        if !predicate.kind.in_where_clause() {
1043            // <T: ?Sized, U>
1044            //   ^^^^^^^^
1045            return span;
1046        }
1047
1048        // We need to find out which comma to remove.
1049        if pos < self.predicates.len() - 1 {
1050            let next_pred = &self.predicates[pos + 1];
1051            if next_pred.kind.in_where_clause() {
1052                // where T: ?Sized, Foo: Bar,
1053                //       ^^^^^^^^^^^
1054                return span.until(next_pred.span);
1055            }
1056        }
1057
1058        if pos > 0 {
1059            let prev_pred = &self.predicates[pos - 1];
1060            if prev_pred.kind.in_where_clause() {
1061                // where Foo: Bar, T: ?Sized,
1062                //               ^^^^^^^^^^^
1063                return prev_pred.span.shrink_to_hi().to(span);
1064            }
1065        }
1066
1067        // This is the only predicate in the where clause.
1068        // where T: ?Sized
1069        // ^^^^^^^^^^^^^^^
1070        self.where_clause_span
1071    }
1072
1073    pub fn span_for_bound_removal(&self, predicate_pos: usize, bound_pos: usize) -> Span {
1074        let predicate = &self.predicates[predicate_pos];
1075        let bounds = predicate.kind.bounds();
1076
1077        if bounds.len() == 1 {
1078            return self.span_for_predicate_removal(predicate_pos);
1079        }
1080
1081        let bound_span = bounds[bound_pos].span();
1082        if bound_pos < bounds.len() - 1 {
1083            // If there's another bound after the current bound
1084            // include the following '+' e.g.:
1085            //
1086            //  `T: Foo + CurrentBound + Bar`
1087            //            ^^^^^^^^^^^^^^^
1088            bound_span.to(bounds[bound_pos + 1].span().shrink_to_lo())
1089        } else {
1090            // If the current bound is the last bound
1091            // include the preceding '+' E.g.:
1092            //
1093            //  `T: Foo + Bar + CurrentBound`
1094            //               ^^^^^^^^^^^^^^^
1095            bound_span.with_lo(bounds[bound_pos - 1].span().hi())
1096        }
1097    }
1098}
1099
1100/// A single predicate in a where-clause.
1101#[derive(#[automatically_derived]
impl<'hir> ::core::fmt::Debug for WherePredicate<'hir> {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::debug_struct_field3_finish(f,
            "WherePredicate", "hir_id", &self.hir_id, "span", &self.span,
            "kind", &&self.kind)
    }
}Debug, #[automatically_derived]
impl<'hir> ::core::clone::Clone for WherePredicate<'hir> {
    #[inline]
    fn clone(&self) -> WherePredicate<'hir> {
        let _: ::core::clone::AssertParamIsClone<HirId>;
        let _: ::core::clone::AssertParamIsClone<Span>;
        let _:
                ::core::clone::AssertParamIsClone<&'hir WherePredicateKind<'hir>>;
        *self
    }
}Clone, #[automatically_derived]
impl<'hir> ::core::marker::Copy for WherePredicate<'hir> { }Copy, const _: () =
    {
        impl<'hir, __CTX>
            ::rustc_data_structures::stable_hasher::HashStable<__CTX> for
            WherePredicate<'hir> where __CTX: crate::HashStableContext {
            #[inline]
            fn hash_stable(&self, __hcx: &mut __CTX,
                __hasher:
                    &mut ::rustc_data_structures::stable_hasher::StableHasher) {
                match *self {
                    WherePredicate {
                        hir_id: ref __binding_0,
                        span: ref __binding_1,
                        kind: ref __binding_2 } => {
                        {}
                        { __binding_1.hash_stable(__hcx, __hasher); }
                        { __binding_2.hash_stable(__hcx, __hasher); }
                    }
                }
            }
        }
    };HashStable_Generic)]
1102pub struct WherePredicate<'hir> {
1103    #[stable_hasher(ignore)]
1104    pub hir_id: HirId,
1105    pub span: Span,
1106    pub kind: &'hir WherePredicateKind<'hir>,
1107}
1108
1109/// The kind of a single predicate in a where-clause.
1110#[derive(#[automatically_derived]
impl<'hir> ::core::fmt::Debug for WherePredicateKind<'hir> {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        match self {
            WherePredicateKind::BoundPredicate(__self_0) =>
                ::core::fmt::Formatter::debug_tuple_field1_finish(f,
                    "BoundPredicate", &__self_0),
            WherePredicateKind::RegionPredicate(__self_0) =>
                ::core::fmt::Formatter::debug_tuple_field1_finish(f,
                    "RegionPredicate", &__self_0),
            WherePredicateKind::EqPredicate(__self_0) =>
                ::core::fmt::Formatter::debug_tuple_field1_finish(f,
                    "EqPredicate", &__self_0),
        }
    }
}Debug, #[automatically_derived]
impl<'hir> ::core::clone::Clone for WherePredicateKind<'hir> {
    #[inline]
    fn clone(&self) -> WherePredicateKind<'hir> {
        let _: ::core::clone::AssertParamIsClone<WhereBoundPredicate<'hir>>;
        let _: ::core::clone::AssertParamIsClone<WhereRegionPredicate<'hir>>;
        let _: ::core::clone::AssertParamIsClone<WhereEqPredicate<'hir>>;
        *self
    }
}Clone, #[automatically_derived]
impl<'hir> ::core::marker::Copy for WherePredicateKind<'hir> { }Copy, const _: () =
    {
        impl<'hir, __CTX>
            ::rustc_data_structures::stable_hasher::HashStable<__CTX> for
            WherePredicateKind<'hir> where __CTX: crate::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 {
                    WherePredicateKind::BoundPredicate(ref __binding_0) => {
                        { __binding_0.hash_stable(__hcx, __hasher); }
                    }
                    WherePredicateKind::RegionPredicate(ref __binding_0) => {
                        { __binding_0.hash_stable(__hcx, __hasher); }
                    }
                    WherePredicateKind::EqPredicate(ref __binding_0) => {
                        { __binding_0.hash_stable(__hcx, __hasher); }
                    }
                }
            }
        }
    };HashStable_Generic)]
1111pub enum WherePredicateKind<'hir> {
1112    /// A type bound (e.g., `for<'c> Foo: Send + Clone + 'c`).
1113    BoundPredicate(WhereBoundPredicate<'hir>),
1114    /// A lifetime predicate (e.g., `'a: 'b + 'c`).
1115    RegionPredicate(WhereRegionPredicate<'hir>),
1116    /// An equality predicate (unsupported).
1117    EqPredicate(WhereEqPredicate<'hir>),
1118}
1119
1120impl<'hir> WherePredicateKind<'hir> {
1121    pub fn in_where_clause(&self) -> bool {
1122        match self {
1123            WherePredicateKind::BoundPredicate(p) => p.origin == PredicateOrigin::WhereClause,
1124            WherePredicateKind::RegionPredicate(p) => p.in_where_clause,
1125            WherePredicateKind::EqPredicate(_) => false,
1126        }
1127    }
1128
1129    pub fn bounds(&self) -> GenericBounds<'hir> {
1130        match self {
1131            WherePredicateKind::BoundPredicate(p) => p.bounds,
1132            WherePredicateKind::RegionPredicate(p) => p.bounds,
1133            WherePredicateKind::EqPredicate(_) => &[],
1134        }
1135    }
1136}
1137
1138#[derive(#[automatically_derived]
impl ::core::marker::Copy for PredicateOrigin { }Copy, #[automatically_derived]
impl ::core::clone::Clone for PredicateOrigin {
    #[inline]
    fn clone(&self) -> PredicateOrigin { *self }
}Clone, #[automatically_derived]
impl ::core::fmt::Debug for PredicateOrigin {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::write_str(f,
            match self {
                PredicateOrigin::WhereClause => "WhereClause",
                PredicateOrigin::GenericParam => "GenericParam",
                PredicateOrigin::ImplTrait => "ImplTrait",
            })
    }
}Debug, const _: () =
    {
        impl<__CTX> ::rustc_data_structures::stable_hasher::HashStable<__CTX>
            for PredicateOrigin where __CTX: crate::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 {
                    PredicateOrigin::WhereClause => {}
                    PredicateOrigin::GenericParam => {}
                    PredicateOrigin::ImplTrait => {}
                }
            }
        }
    };HashStable_Generic, #[automatically_derived]
impl ::core::cmp::PartialEq for PredicateOrigin {
    #[inline]
    fn eq(&self, other: &PredicateOrigin) -> 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 PredicateOrigin {
    #[inline]
    #[doc(hidden)]
    #[coverage(off)]
    fn assert_fields_are_eq(&self) {}
}Eq)]
1139pub enum PredicateOrigin {
1140    WhereClause,
1141    GenericParam,
1142    ImplTrait,
1143}
1144
1145/// A type bound (e.g., `for<'c> Foo: Send + Clone + 'c`).
1146#[derive(#[automatically_derived]
impl<'hir> ::core::fmt::Debug for WhereBoundPredicate<'hir> {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::debug_struct_field4_finish(f,
            "WhereBoundPredicate", "origin", &self.origin,
            "bound_generic_params", &self.bound_generic_params, "bounded_ty",
            &self.bounded_ty, "bounds", &&self.bounds)
    }
}Debug, #[automatically_derived]
impl<'hir> ::core::clone::Clone for WhereBoundPredicate<'hir> {
    #[inline]
    fn clone(&self) -> WhereBoundPredicate<'hir> {
        let _: ::core::clone::AssertParamIsClone<PredicateOrigin>;
        let _: ::core::clone::AssertParamIsClone<&'hir [GenericParam<'hir>]>;
        let _: ::core::clone::AssertParamIsClone<&'hir Ty<'hir>>;
        let _: ::core::clone::AssertParamIsClone<GenericBounds<'hir>>;
        *self
    }
}Clone, #[automatically_derived]
impl<'hir> ::core::marker::Copy for WhereBoundPredicate<'hir> { }Copy, const _: () =
    {
        impl<'hir, __CTX>
            ::rustc_data_structures::stable_hasher::HashStable<__CTX> for
            WhereBoundPredicate<'hir> where __CTX: crate::HashStableContext {
            #[inline]
            fn hash_stable(&self, __hcx: &mut __CTX,
                __hasher:
                    &mut ::rustc_data_structures::stable_hasher::StableHasher) {
                match *self {
                    WhereBoundPredicate {
                        origin: ref __binding_0,
                        bound_generic_params: ref __binding_1,
                        bounded_ty: ref __binding_2,
                        bounds: 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); }
                    }
                }
            }
        }
    };HashStable_Generic)]
1147pub struct WhereBoundPredicate<'hir> {
1148    /// Origin of the predicate.
1149    pub origin: PredicateOrigin,
1150    /// Any generics from a `for` binding.
1151    pub bound_generic_params: &'hir [GenericParam<'hir>],
1152    /// The type being bounded.
1153    pub bounded_ty: &'hir Ty<'hir>,
1154    /// Trait and lifetime bounds (e.g., `Clone + Send + 'static`).
1155    pub bounds: GenericBounds<'hir>,
1156}
1157
1158impl<'hir> WhereBoundPredicate<'hir> {
1159    /// Returns `true` if `param_def_id` matches the `bounded_ty` of this predicate.
1160    pub fn is_param_bound(&self, param_def_id: DefId) -> bool {
1161        self.bounded_ty.as_generic_param().is_some_and(|(def_id, _)| def_id == param_def_id)
1162    }
1163}
1164
1165/// A lifetime predicate (e.g., `'a: 'b + 'c`).
1166#[derive(#[automatically_derived]
impl<'hir> ::core::fmt::Debug for WhereRegionPredicate<'hir> {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::debug_struct_field3_finish(f,
            "WhereRegionPredicate", "in_where_clause", &self.in_where_clause,
            "lifetime", &self.lifetime, "bounds", &&self.bounds)
    }
}Debug, #[automatically_derived]
impl<'hir> ::core::clone::Clone for WhereRegionPredicate<'hir> {
    #[inline]
    fn clone(&self) -> WhereRegionPredicate<'hir> {
        let _: ::core::clone::AssertParamIsClone<bool>;
        let _: ::core::clone::AssertParamIsClone<&'hir Lifetime>;
        let _: ::core::clone::AssertParamIsClone<GenericBounds<'hir>>;
        *self
    }
}Clone, #[automatically_derived]
impl<'hir> ::core::marker::Copy for WhereRegionPredicate<'hir> { }Copy, const _: () =
    {
        impl<'hir, __CTX>
            ::rustc_data_structures::stable_hasher::HashStable<__CTX> for
            WhereRegionPredicate<'hir> where __CTX: crate::HashStableContext {
            #[inline]
            fn hash_stable(&self, __hcx: &mut __CTX,
                __hasher:
                    &mut ::rustc_data_structures::stable_hasher::StableHasher) {
                match *self {
                    WhereRegionPredicate {
                        in_where_clause: ref __binding_0,
                        lifetime: ref __binding_1,
                        bounds: ref __binding_2 } => {
                        { __binding_0.hash_stable(__hcx, __hasher); }
                        { __binding_1.hash_stable(__hcx, __hasher); }
                        { __binding_2.hash_stable(__hcx, __hasher); }
                    }
                }
            }
        }
    };HashStable_Generic)]
1167pub struct WhereRegionPredicate<'hir> {
1168    pub in_where_clause: bool,
1169    pub lifetime: &'hir Lifetime,
1170    pub bounds: GenericBounds<'hir>,
1171}
1172
1173impl<'hir> WhereRegionPredicate<'hir> {
1174    /// Returns `true` if `param_def_id` matches the `lifetime` of this predicate.
1175    fn is_param_bound(&self, param_def_id: LocalDefId) -> bool {
1176        self.lifetime.kind == LifetimeKind::Param(param_def_id)
1177    }
1178}
1179
1180/// An equality predicate (e.g., `T = int`); currently unsupported.
1181#[derive(#[automatically_derived]
impl<'hir> ::core::fmt::Debug for WhereEqPredicate<'hir> {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::debug_struct_field2_finish(f,
            "WhereEqPredicate", "lhs_ty", &self.lhs_ty, "rhs_ty",
            &&self.rhs_ty)
    }
}Debug, #[automatically_derived]
impl<'hir> ::core::clone::Clone for WhereEqPredicate<'hir> {
    #[inline]
    fn clone(&self) -> WhereEqPredicate<'hir> {
        let _: ::core::clone::AssertParamIsClone<&'hir Ty<'hir>>;
        let _: ::core::clone::AssertParamIsClone<&'hir Ty<'hir>>;
        *self
    }
}Clone, #[automatically_derived]
impl<'hir> ::core::marker::Copy for WhereEqPredicate<'hir> { }Copy, const _: () =
    {
        impl<'hir, __CTX>
            ::rustc_data_structures::stable_hasher::HashStable<__CTX> for
            WhereEqPredicate<'hir> where __CTX: crate::HashStableContext {
            #[inline]
            fn hash_stable(&self, __hcx: &mut __CTX,
                __hasher:
                    &mut ::rustc_data_structures::stable_hasher::StableHasher) {
                match *self {
                    WhereEqPredicate {
                        lhs_ty: ref __binding_0, rhs_ty: ref __binding_1 } => {
                        { __binding_0.hash_stable(__hcx, __hasher); }
                        { __binding_1.hash_stable(__hcx, __hasher); }
                    }
                }
            }
        }
    };HashStable_Generic)]
1182pub struct WhereEqPredicate<'hir> {
1183    pub lhs_ty: &'hir Ty<'hir>,
1184    pub rhs_ty: &'hir Ty<'hir>,
1185}
1186
1187/// HIR node coupled with its parent's id in the same HIR owner.
1188///
1189/// The parent is trash when the node is a HIR owner.
1190#[derive(#[automatically_derived]
impl<'tcx> ::core::clone::Clone for ParentedNode<'tcx> {
    #[inline]
    fn clone(&self) -> ParentedNode<'tcx> {
        let _: ::core::clone::AssertParamIsClone<ItemLocalId>;
        let _: ::core::clone::AssertParamIsClone<Node<'tcx>>;
        *self
    }
}Clone, #[automatically_derived]
impl<'tcx> ::core::marker::Copy for ParentedNode<'tcx> { }Copy, #[automatically_derived]
impl<'tcx> ::core::fmt::Debug for ParentedNode<'tcx> {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::debug_struct_field2_finish(f, "ParentedNode",
            "parent", &self.parent, "node", &&self.node)
    }
}Debug)]
1191pub struct ParentedNode<'tcx> {
1192    pub parent: ItemLocalId,
1193    pub node: Node<'tcx>,
1194}
1195
1196/// Arguments passed to an attribute macro.
1197#[derive(#[automatically_derived]
impl ::core::clone::Clone for AttrArgs {
    #[inline]
    fn clone(&self) -> AttrArgs {
        match self {
            AttrArgs::Empty => AttrArgs::Empty,
            AttrArgs::Delimited(__self_0) =>
                AttrArgs::Delimited(::core::clone::Clone::clone(__self_0)),
            AttrArgs::Eq { eq_span: __self_0, expr: __self_1 } =>
                AttrArgs::Eq {
                    eq_span: ::core::clone::Clone::clone(__self_0),
                    expr: ::core::clone::Clone::clone(__self_1),
                },
        }
    }
}Clone, #[automatically_derived]
impl ::core::fmt::Debug for AttrArgs {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        match self {
            AttrArgs::Empty => ::core::fmt::Formatter::write_str(f, "Empty"),
            AttrArgs::Delimited(__self_0) =>
                ::core::fmt::Formatter::debug_tuple_field1_finish(f,
                    "Delimited", &__self_0),
            AttrArgs::Eq { eq_span: __self_0, expr: __self_1 } =>
                ::core::fmt::Formatter::debug_struct_field2_finish(f, "Eq",
                    "eq_span", __self_0, "expr", &__self_1),
        }
    }
}Debug, const _: () =
    {
        impl<__CTX> ::rustc_data_structures::stable_hasher::HashStable<__CTX>
            for AttrArgs where __CTX: crate::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 {
                    AttrArgs::Empty => {}
                    AttrArgs::Delimited(ref __binding_0) => {
                        { __binding_0.hash_stable(__hcx, __hasher); }
                    }
                    AttrArgs::Eq {
                        eq_span: ref __binding_0, expr: ref __binding_1 } => {
                        { __binding_0.hash_stable(__hcx, __hasher); }
                        { __binding_1.hash_stable(__hcx, __hasher); }
                    }
                }
            }
        }
    };HashStable_Generic, const _: () =
    {
        impl<__E: ::rustc_span::SpanEncoder> ::rustc_serialize::Encodable<__E>
            for AttrArgs {
            fn encode(&self, __encoder: &mut __E) {
                let disc =
                    match *self {
                        AttrArgs::Empty => { 0usize }
                        AttrArgs::Delimited(ref __binding_0) => { 1usize }
                        AttrArgs::Eq {
                            eq_span: ref __binding_0, expr: ref __binding_1 } => {
                            2usize
                        }
                    };
                ::rustc_serialize::Encoder::emit_u8(__encoder, disc as u8);
                match *self {
                    AttrArgs::Empty => {}
                    AttrArgs::Delimited(ref __binding_0) => {
                        ::rustc_serialize::Encodable::<__E>::encode(__binding_0,
                            __encoder);
                    }
                    AttrArgs::Eq {
                        eq_span: ref __binding_0, expr: ref __binding_1 } => {
                        ::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 AttrArgs {
            fn decode(__decoder: &mut __D) -> Self {
                match ::rustc_serialize::Decoder::read_u8(__decoder) as usize
                    {
                    0usize => { AttrArgs::Empty }
                    1usize => {
                        AttrArgs::Delimited(::rustc_serialize::Decodable::decode(__decoder))
                    }
                    2usize => {
                        AttrArgs::Eq {
                            eq_span: ::rustc_serialize::Decodable::decode(__decoder),
                            expr: ::rustc_serialize::Decodable::decode(__decoder),
                        }
                    }
                    n => {
                        ::core::panicking::panic_fmt(format_args!("invalid enum variant tag while decoding `AttrArgs`, expected 0..3, actual {0}",
                                n));
                    }
                }
            }
        }
    };Decodable)]
1198pub enum AttrArgs {
1199    /// No arguments: `#[attr]`.
1200    Empty,
1201    /// Delimited arguments: `#[attr()/[]/{}]`.
1202    Delimited(DelimArgs),
1203    /// Arguments of a key-value attribute: `#[attr = "value"]`.
1204    Eq {
1205        /// Span of the `=` token.
1206        eq_span: Span,
1207        /// The "value".
1208        expr: MetaItemLit,
1209    },
1210}
1211
1212#[derive(#[automatically_derived]
impl ::core::clone::Clone for AttrPath {
    #[inline]
    fn clone(&self) -> AttrPath {
        AttrPath {
            segments: ::core::clone::Clone::clone(&self.segments),
            span: ::core::clone::Clone::clone(&self.span),
        }
    }
}Clone, #[automatically_derived]
impl ::core::fmt::Debug for AttrPath {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::debug_struct_field2_finish(f, "AttrPath",
            "segments", &self.segments, "span", &&self.span)
    }
}Debug, const _: () =
    {
        impl<__CTX> ::rustc_data_structures::stable_hasher::HashStable<__CTX>
            for AttrPath where __CTX: crate::HashStableContext {
            #[inline]
            fn hash_stable(&self, __hcx: &mut __CTX,
                __hasher:
                    &mut ::rustc_data_structures::stable_hasher::StableHasher) {
                match *self {
                    AttrPath { segments: ref __binding_0, span: ref __binding_1
                        } => {
                        { __binding_0.hash_stable(__hcx, __hasher); }
                        { __binding_1.hash_stable(__hcx, __hasher); }
                    }
                }
            }
        }
    };HashStable_Generic, const _: () =
    {
        impl<__E: ::rustc_span::SpanEncoder> ::rustc_serialize::Encodable<__E>
            for AttrPath {
            fn encode(&self, __encoder: &mut __E) {
                match *self {
                    AttrPath { segments: ref __binding_0, span: ref __binding_1
                        } => {
                        ::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 AttrPath {
            fn decode(__decoder: &mut __D) -> Self {
                AttrPath {
                    segments: ::rustc_serialize::Decodable::decode(__decoder),
                    span: ::rustc_serialize::Decodable::decode(__decoder),
                }
            }
        }
    };Decodable)]
1213pub struct AttrPath {
1214    pub segments: Box<[Symbol]>,
1215    pub span: Span,
1216}
1217
1218impl IntoDiagArg for AttrPath {
1219    fn into_diag_arg(self, path: &mut Option<std::path::PathBuf>) -> DiagArgValue {
1220        self.to_string().into_diag_arg(path)
1221    }
1222}
1223
1224impl AttrPath {
1225    pub fn from_ast(path: &ast::Path, lower_span: impl Copy + Fn(Span) -> Span) -> Self {
1226        AttrPath {
1227            segments: path
1228                .segments
1229                .iter()
1230                .map(|i| i.ident.name)
1231                .collect::<Vec<_>>()
1232                .into_boxed_slice(),
1233            span: lower_span(path.span),
1234        }
1235    }
1236}
1237
1238impl fmt::Display for AttrPath {
1239    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
1240        f.write_fmt(format_args!("{0}",
        join_path_idents(self.segments.iter().map(|i|
                    Ident { name: *i, span: DUMMY_SP }))))write!(
1241            f,
1242            "{}",
1243            join_path_idents(self.segments.iter().map(|i| Ident { name: *i, span: DUMMY_SP }))
1244        )
1245    }
1246}
1247
1248#[derive(#[automatically_derived]
impl ::core::clone::Clone for AttrItem {
    #[inline]
    fn clone(&self) -> AttrItem {
        AttrItem {
            path: ::core::clone::Clone::clone(&self.path),
            args: ::core::clone::Clone::clone(&self.args),
            id: ::core::clone::Clone::clone(&self.id),
            style: ::core::clone::Clone::clone(&self.style),
            span: ::core::clone::Clone::clone(&self.span),
        }
    }
}Clone, #[automatically_derived]
impl ::core::fmt::Debug for AttrItem {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::debug_struct_field5_finish(f, "AttrItem",
            "path", &self.path, "args", &self.args, "id", &self.id, "style",
            &self.style, "span", &&self.span)
    }
}Debug, const _: () =
    {
        impl<__CTX> ::rustc_data_structures::stable_hasher::HashStable<__CTX>
            for AttrItem where __CTX: crate::HashStableContext {
            #[inline]
            fn hash_stable(&self, __hcx: &mut __CTX,
                __hasher:
                    &mut ::rustc_data_structures::stable_hasher::StableHasher) {
                match *self {
                    AttrItem {
                        path: ref __binding_0,
                        args: ref __binding_1,
                        id: ref __binding_2,
                        style: ref __binding_3,
                        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); }
                    }
                }
            }
        }
    };HashStable_Generic, const _: () =
    {
        impl<__E: ::rustc_span::SpanEncoder> ::rustc_serialize::Encodable<__E>
            for AttrItem {
            fn encode(&self, __encoder: &mut __E) {
                match *self {
                    AttrItem {
                        path: ref __binding_0,
                        args: ref __binding_1,
                        id: ref __binding_2,
                        style: ref __binding_3,
                        span: ref __binding_4 } => {
                        ::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);
                        ::rustc_serialize::Encodable::<__E>::encode(__binding_4,
                            __encoder);
                    }
                }
            }
        }
    };Encodable, const _: () =
    {
        impl<__D: ::rustc_span::SpanDecoder> ::rustc_serialize::Decodable<__D>
            for AttrItem {
            fn decode(__decoder: &mut __D) -> Self {
                AttrItem {
                    path: ::rustc_serialize::Decodable::decode(__decoder),
                    args: ::rustc_serialize::Decodable::decode(__decoder),
                    id: ::rustc_serialize::Decodable::decode(__decoder),
                    style: ::rustc_serialize::Decodable::decode(__decoder),
                    span: ::rustc_serialize::Decodable::decode(__decoder),
                }
            }
        }
    };Decodable)]
1249pub struct AttrItem {
1250    // Not lowered to hir::Path because we have no NodeId to resolve to.
1251    pub path: AttrPath,
1252    pub args: AttrArgs,
1253    pub id: HashIgnoredAttrId,
1254    /// Denotes if the attribute decorates the following construct (outer)
1255    /// or the construct this attribute is contained within (inner).
1256    pub style: AttrStyle,
1257    /// Span of the entire attribute
1258    pub span: Span,
1259}
1260
1261/// The derived implementation of [`HashStable_Generic`] on [`Attribute`]s shouldn't hash
1262/// [`AttrId`]s. By wrapping them in this, we make sure we never do.
1263#[derive(#[automatically_derived]
impl ::core::marker::Copy for HashIgnoredAttrId { }Copy, #[automatically_derived]
impl ::core::fmt::Debug for HashIgnoredAttrId {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::debug_struct_field1_finish(f,
            "HashIgnoredAttrId", "attr_id", &&self.attr_id)
    }
}Debug, const _: () =
    {
        impl<__E: ::rustc_span::SpanEncoder> ::rustc_serialize::Encodable<__E>
            for HashIgnoredAttrId {
            fn encode(&self, __encoder: &mut __E) {
                match *self {
                    HashIgnoredAttrId { attr_id: ref __binding_0 } => {
                        ::rustc_serialize::Encodable::<__E>::encode(__binding_0,
                            __encoder);
                    }
                }
            }
        }
    };Encodable, const _: () =
    {
        impl<__D: ::rustc_span::SpanDecoder> ::rustc_serialize::Decodable<__D>
            for HashIgnoredAttrId {
            fn decode(__decoder: &mut __D) -> Self {
                HashIgnoredAttrId {
                    attr_id: ::rustc_serialize::Decodable::decode(__decoder),
                }
            }
        }
    };Decodable, #[automatically_derived]
impl ::core::clone::Clone for HashIgnoredAttrId {
    #[inline]
    fn clone(&self) -> HashIgnoredAttrId {
        let _: ::core::clone::AssertParamIsClone<AttrId>;
        *self
    }
}Clone)]
1264pub struct HashIgnoredAttrId {
1265    pub attr_id: AttrId,
1266}
1267
1268#[derive(#[automatically_derived]
impl ::core::clone::Clone for Attribute {
    #[inline]
    fn clone(&self) -> Attribute {
        match self {
            Attribute::Parsed(__self_0) =>
                Attribute::Parsed(::core::clone::Clone::clone(__self_0)),
            Attribute::Unparsed(__self_0) =>
                Attribute::Unparsed(::core::clone::Clone::clone(__self_0)),
        }
    }
}Clone, #[automatically_derived]
impl ::core::fmt::Debug for Attribute {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        match self {
            Attribute::Parsed(__self_0) =>
                ::core::fmt::Formatter::debug_tuple_field1_finish(f, "Parsed",
                    &__self_0),
            Attribute::Unparsed(__self_0) =>
                ::core::fmt::Formatter::debug_tuple_field1_finish(f,
                    "Unparsed", &__self_0),
        }
    }
}Debug, const _: () =
    {
        impl<__E: ::rustc_span::SpanEncoder> ::rustc_serialize::Encodable<__E>
            for Attribute {
            fn encode(&self, __encoder: &mut __E) {
                let disc =
                    match *self {
                        Attribute::Parsed(ref __binding_0) => { 0usize }
                        Attribute::Unparsed(ref __binding_0) => { 1usize }
                    };
                ::rustc_serialize::Encoder::emit_u8(__encoder, disc as u8);
                match *self {
                    Attribute::Parsed(ref __binding_0) => {
                        ::rustc_serialize::Encodable::<__E>::encode(__binding_0,
                            __encoder);
                    }
                    Attribute::Unparsed(ref __binding_0) => {
                        ::rustc_serialize::Encodable::<__E>::encode(__binding_0,
                            __encoder);
                    }
                }
            }
        }
    };Encodable, const _: () =
    {
        impl<__D: ::rustc_span::SpanDecoder> ::rustc_serialize::Decodable<__D>
            for Attribute {
            fn decode(__decoder: &mut __D) -> Self {
                match ::rustc_serialize::Decoder::read_u8(__decoder) as usize
                    {
                    0usize => {
                        Attribute::Parsed(::rustc_serialize::Decodable::decode(__decoder))
                    }
                    1usize => {
                        Attribute::Unparsed(::rustc_serialize::Decodable::decode(__decoder))
                    }
                    n => {
                        ::core::panicking::panic_fmt(format_args!("invalid enum variant tag while decoding `Attribute`, expected 0..2, actual {0}",
                                n));
                    }
                }
            }
        }
    };Decodable, const _: () =
    {
        impl<__CTX> ::rustc_data_structures::stable_hasher::HashStable<__CTX>
            for Attribute where __CTX: crate::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 {
                    Attribute::Parsed(ref __binding_0) => {
                        { __binding_0.hash_stable(__hcx, __hasher); }
                    }
                    Attribute::Unparsed(ref __binding_0) => {
                        { __binding_0.hash_stable(__hcx, __hasher); }
                    }
                }
            }
        }
    };HashStable_Generic)]
1269pub enum Attribute {
1270    /// A parsed built-in attribute.
1271    ///
1272    /// Each attribute has a span connected to it. However, you must be somewhat careful using it.
1273    /// That's because sometimes we merge multiple attributes together, like when an item has
1274    /// multiple `repr` attributes. In this case the span might not be very useful.
1275    Parsed(AttributeKind),
1276
1277    /// An attribute that could not be parsed, out of a token-like representation.
1278    /// This is the case for custom tool attributes.
1279    Unparsed(Box<AttrItem>),
1280}
1281
1282impl Attribute {
1283    pub fn get_normal_item(&self) -> &AttrItem {
1284        match &self {
1285            Attribute::Unparsed(normal) => &normal,
1286            _ => { ::core::panicking::panic_fmt(format_args!("unexpected parsed attribute")); }panic!("unexpected parsed attribute"),
1287        }
1288    }
1289
1290    pub fn unwrap_normal_item(self) -> AttrItem {
1291        match self {
1292            Attribute::Unparsed(normal) => *normal,
1293            _ => { ::core::panicking::panic_fmt(format_args!("unexpected parsed attribute")); }panic!("unexpected parsed attribute"),
1294        }
1295    }
1296
1297    pub fn value_lit(&self) -> Option<&MetaItemLit> {
1298        match &self {
1299            Attribute::Unparsed(n) => match n.as_ref() {
1300                AttrItem { args: AttrArgs::Eq { eq_span: _, expr }, .. } => Some(expr),
1301                _ => None,
1302            },
1303            _ => None,
1304        }
1305    }
1306
1307    pub fn is_parsed_attr(&self) -> bool {
1308        match self {
1309            Attribute::Parsed(_) => true,
1310            Attribute::Unparsed(_) => false,
1311        }
1312    }
1313}
1314
1315impl AttributeExt for Attribute {
1316    #[inline]
1317    fn id(&self) -> AttrId {
1318        match &self {
1319            Attribute::Unparsed(u) => u.id.attr_id,
1320            _ => ::core::panicking::panic("explicit panic")panic!(),
1321        }
1322    }
1323
1324    #[inline]
1325    fn meta_item_list(&self) -> Option<ThinVec<ast::MetaItemInner>> {
1326        match &self {
1327            Attribute::Unparsed(n) => match n.as_ref() {
1328                AttrItem { args: AttrArgs::Delimited(d), .. } => {
1329                    ast::MetaItemKind::list_from_tokens(d.tokens.clone())
1330                }
1331                _ => None,
1332            },
1333            _ => None,
1334        }
1335    }
1336
1337    #[inline]
1338    fn value_str(&self) -> Option<Symbol> {
1339        self.value_lit().and_then(|x| x.value_str())
1340    }
1341
1342    #[inline]
1343    fn value_span(&self) -> Option<Span> {
1344        self.value_lit().map(|i| i.span)
1345    }
1346
1347    /// For a single-segment attribute, returns its name; otherwise, returns `None`.
1348    #[inline]
1349    fn name(&self) -> Option<Symbol> {
1350        match &self {
1351            Attribute::Unparsed(n) => {
1352                if let [ident] = n.path.segments.as_ref() {
1353                    Some(*ident)
1354                } else {
1355                    None
1356                }
1357            }
1358            _ => None,
1359        }
1360    }
1361
1362    #[inline]
1363    fn path_matches(&self, name: &[Symbol]) -> bool {
1364        match &self {
1365            Attribute::Unparsed(n) => n.path.segments.iter().eq(name),
1366            _ => false,
1367        }
1368    }
1369
1370    #[inline]
1371    fn is_doc_comment(&self) -> Option<Span> {
1372        if let Attribute::Parsed(AttributeKind::DocComment { span, .. }) = self {
1373            Some(*span)
1374        } else {
1375            None
1376        }
1377    }
1378
1379    #[inline]
1380    fn span(&self) -> Span {
1381        match &self {
1382            Attribute::Unparsed(u) => u.span,
1383            // FIXME: should not be needed anymore when all attrs are parsed
1384            Attribute::Parsed(AttributeKind::DocComment { span, .. }) => *span,
1385            Attribute::Parsed(AttributeKind::Deprecated { span, .. }) => *span,
1386            Attribute::Parsed(AttributeKind::CfgTrace(cfgs)) => cfgs[0].1,
1387            a => {
    ::core::panicking::panic_fmt(format_args!("can\'t get the span of an arbitrary parsed attribute: {0:?}",
            a));
}panic!("can't get the span of an arbitrary parsed attribute: {a:?}"),
1388        }
1389    }
1390
1391    #[inline]
1392    fn is_word(&self) -> bool {
1393        match &self {
1394            Attribute::Unparsed(n) => {
1395                #[allow(non_exhaustive_omitted_patterns)] match n.args {
    AttrArgs::Empty => true,
    _ => false,
}matches!(n.args, AttrArgs::Empty)
1396            }
1397            _ => false,
1398        }
1399    }
1400
1401    #[inline]
1402    fn symbol_path(&self) -> Option<SmallVec<[Symbol; 1]>> {
1403        match &self {
1404            Attribute::Unparsed(n) => Some(n.path.segments.iter().copied().collect()),
1405            _ => None,
1406        }
1407    }
1408
1409    fn path_span(&self) -> Option<Span> {
1410        match &self {
1411            Attribute::Unparsed(attr) => Some(attr.path.span),
1412            Attribute::Parsed(_) => None,
1413        }
1414    }
1415
1416    #[inline]
1417    fn doc_str(&self) -> Option<Symbol> {
1418        match &self {
1419            Attribute::Parsed(AttributeKind::DocComment { comment, .. }) => Some(*comment),
1420            _ => None,
1421        }
1422    }
1423
1424    #[inline]
1425    fn deprecation_note(&self) -> Option<Ident> {
1426        match &self {
1427            Attribute::Parsed(AttributeKind::Deprecated { deprecation, .. }) => deprecation.note,
1428            _ => None,
1429        }
1430    }
1431
1432    fn is_automatically_derived_attr(&self) -> bool {
1433        #[allow(non_exhaustive_omitted_patterns)] match self {
    Attribute::Parsed(AttributeKind::AutomaticallyDerived(..)) => true,
    _ => false,
}matches!(self, Attribute::Parsed(AttributeKind::AutomaticallyDerived(..)))
1434    }
1435
1436    #[inline]
1437    fn doc_str_and_fragment_kind(&self) -> Option<(Symbol, DocFragmentKind)> {
1438        match &self {
1439            Attribute::Parsed(AttributeKind::DocComment { kind, comment, .. }) => {
1440                Some((*comment, *kind))
1441            }
1442            _ => None,
1443        }
1444    }
1445
1446    fn doc_resolution_scope(&self) -> Option<AttrStyle> {
1447        match self {
1448            Attribute::Parsed(AttributeKind::DocComment { style, .. }) => Some(*style),
1449            Attribute::Unparsed(attr) if self.has_name(sym::doc) && self.value_str().is_some() => {
1450                Some(attr.style)
1451            }
1452            _ => None,
1453        }
1454    }
1455
1456    fn is_proc_macro_attr(&self) -> bool {
1457        #[allow(non_exhaustive_omitted_patterns)] match self {
    Attribute::Parsed(AttributeKind::ProcMacro(..) |
        AttributeKind::ProcMacroAttribute(..) |
        AttributeKind::ProcMacroDerive { .. }) => true,
    _ => false,
}matches!(
1458            self,
1459            Attribute::Parsed(
1460                AttributeKind::ProcMacro(..)
1461                    | AttributeKind::ProcMacroAttribute(..)
1462                    | AttributeKind::ProcMacroDerive { .. }
1463            )
1464        )
1465    }
1466
1467    fn is_doc_hidden(&self) -> bool {
1468        #[allow(non_exhaustive_omitted_patterns)] match self {
    Attribute::Parsed(AttributeKind::Doc(d)) if d.hidden.is_some() => true,
    _ => false,
}matches!(self, Attribute::Parsed(AttributeKind::Doc(d)) if d.hidden.is_some())
1469    }
1470
1471    fn is_doc_keyword_or_attribute(&self) -> bool {
1472        #[allow(non_exhaustive_omitted_patterns)] match self {
    Attribute::Parsed(AttributeKind::Doc(d)) if
        d.attribute.is_some() || d.keyword.is_some() => true,
    _ => false,
}matches!(self, Attribute::Parsed(AttributeKind::Doc(d)) if d.attribute.is_some() || d.keyword.is_some())
1473    }
1474
1475    fn is_rustc_doc_primitive(&self) -> bool {
1476        #[allow(non_exhaustive_omitted_patterns)] match self {
    Attribute::Parsed(AttributeKind::RustcDocPrimitive(..)) => true,
    _ => false,
}matches!(self, Attribute::Parsed(AttributeKind::RustcDocPrimitive(..)))
1477    }
1478}
1479
1480// FIXME(fn_delegation): use function delegation instead of manually forwarding
1481impl Attribute {
1482    #[inline]
1483    pub fn id(&self) -> AttrId {
1484        AttributeExt::id(self)
1485    }
1486
1487    #[inline]
1488    pub fn name(&self) -> Option<Symbol> {
1489        AttributeExt::name(self)
1490    }
1491
1492    #[inline]
1493    pub fn meta_item_list(&self) -> Option<ThinVec<MetaItemInner>> {
1494        AttributeExt::meta_item_list(self)
1495    }
1496
1497    #[inline]
1498    pub fn value_str(&self) -> Option<Symbol> {
1499        AttributeExt::value_str(self)
1500    }
1501
1502    #[inline]
1503    pub fn value_span(&self) -> Option<Span> {
1504        AttributeExt::value_span(self)
1505    }
1506
1507    #[inline]
1508    pub fn path_matches(&self, name: &[Symbol]) -> bool {
1509        AttributeExt::path_matches(self, name)
1510    }
1511
1512    #[inline]
1513    pub fn is_doc_comment(&self) -> Option<Span> {
1514        AttributeExt::is_doc_comment(self)
1515    }
1516
1517    #[inline]
1518    pub fn has_name(&self, name: Symbol) -> bool {
1519        AttributeExt::has_name(self, name)
1520    }
1521
1522    #[inline]
1523    pub fn has_any_name(&self, names: &[Symbol]) -> bool {
1524        AttributeExt::has_any_name(self, names)
1525    }
1526
1527    #[inline]
1528    pub fn span(&self) -> Span {
1529        AttributeExt::span(self)
1530    }
1531
1532    #[inline]
1533    pub fn is_word(&self) -> bool {
1534        AttributeExt::is_word(self)
1535    }
1536
1537    #[inline]
1538    pub fn path(&self) -> SmallVec<[Symbol; 1]> {
1539        AttributeExt::path(self)
1540    }
1541
1542    #[inline]
1543    pub fn doc_str(&self) -> Option<Symbol> {
1544        AttributeExt::doc_str(self)
1545    }
1546
1547    #[inline]
1548    pub fn is_proc_macro_attr(&self) -> bool {
1549        AttributeExt::is_proc_macro_attr(self)
1550    }
1551
1552    #[inline]
1553    pub fn doc_str_and_fragment_kind(&self) -> Option<(Symbol, DocFragmentKind)> {
1554        AttributeExt::doc_str_and_fragment_kind(self)
1555    }
1556}
1557
1558/// Attributes owned by a HIR owner.
1559#[derive(#[automatically_derived]
impl<'tcx> ::core::fmt::Debug for AttributeMap<'tcx> {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::debug_struct_field3_finish(f, "AttributeMap",
            "map", &self.map, "define_opaque", &self.define_opaque,
            "opt_hash", &&self.opt_hash)
    }
}Debug)]
1560pub struct AttributeMap<'tcx> {
1561    pub map: SortedMap<ItemLocalId, &'tcx [Attribute]>,
1562    /// Preprocessed `#[define_opaque]` attribute.
1563    pub define_opaque: Option<&'tcx [(Span, LocalDefId)]>,
1564    // Only present when the crate hash is needed.
1565    pub opt_hash: Option<Fingerprint>,
1566}
1567
1568impl<'tcx> AttributeMap<'tcx> {
1569    pub const EMPTY: &'static AttributeMap<'static> = &AttributeMap {
1570        map: SortedMap::new(),
1571        opt_hash: Some(Fingerprint::ZERO),
1572        define_opaque: None,
1573    };
1574
1575    #[inline]
1576    pub fn get(&self, id: ItemLocalId) -> &'tcx [Attribute] {
1577        self.map.get(&id).copied().unwrap_or(&[])
1578    }
1579}
1580
1581/// Map of all HIR nodes inside the current owner.
1582/// These nodes are mapped by `ItemLocalId` alongside the index of their parent node.
1583/// The HIR tree, including bodies, is pre-hashed.
1584pub struct OwnerNodes<'tcx> {
1585    /// Pre-computed hash of the full HIR. Used in the crate hash. Only present
1586    /// when incr. comp. is enabled.
1587    pub opt_hash_including_bodies: Option<Fingerprint>,
1588    /// Full HIR for the current owner.
1589    // The zeroth node's parent should never be accessed: the owner's parent is computed by the
1590    // hir_owner_parent query. It is set to `ItemLocalId::INVALID` to force an ICE if accidentally
1591    // used.
1592    pub nodes: IndexVec<ItemLocalId, ParentedNode<'tcx>>,
1593    /// Content of local bodies.
1594    pub bodies: SortedMap<ItemLocalId, &'tcx Body<'tcx>>,
1595}
1596
1597impl<'tcx> OwnerNodes<'tcx> {
1598    pub fn node(&self) -> OwnerNode<'tcx> {
1599        // Indexing must ensure it is an OwnerNode.
1600        self.nodes[ItemLocalId::ZERO].node.as_owner().unwrap()
1601    }
1602}
1603
1604impl fmt::Debug for OwnerNodes<'_> {
1605    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
1606        f.debug_struct("OwnerNodes")
1607            // Do not print all the pointers to all the nodes, as it would be unreadable.
1608            .field("node", &self.nodes[ItemLocalId::ZERO])
1609            .field(
1610                "parents",
1611                &fmt::from_fn(|f| {
1612                    f.debug_list()
1613                        .entries(self.nodes.iter_enumerated().map(|(id, parented_node)| {
1614                            fmt::from_fn(move |f| f.write_fmt(format_args!("({1:?}, {0:?})", parented_node.parent, id))write!(f, "({id:?}, {:?})", parented_node.parent))
1615                        }))
1616                        .finish()
1617                }),
1618            )
1619            .field("bodies", &self.bodies)
1620            .field("opt_hash_including_bodies", &self.opt_hash_including_bodies)
1621            .finish()
1622    }
1623}
1624
1625/// Full information resulting from lowering an AST node.
1626#[derive(#[automatically_derived]
impl<'hir> ::core::fmt::Debug for OwnerInfo<'hir> {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::debug_struct_field5_finish(f, "OwnerInfo",
            "nodes", &self.nodes, "parenting", &self.parenting, "attrs",
            &self.attrs, "trait_map", &self.trait_map, "delayed_lints",
            &&self.delayed_lints)
    }
}Debug, const _: () =
    {
        impl<'hir, __CTX>
            ::rustc_data_structures::stable_hasher::HashStable<__CTX> for
            OwnerInfo<'hir> where __CTX: crate::HashStableContext {
            #[inline]
            fn hash_stable(&self, __hcx: &mut __CTX,
                __hasher:
                    &mut ::rustc_data_structures::stable_hasher::StableHasher) {
                match *self {
                    OwnerInfo {
                        nodes: ref __binding_0,
                        parenting: ref __binding_1,
                        attrs: ref __binding_2,
                        trait_map: ref __binding_3,
                        delayed_lints: 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); }
                    }
                }
            }
        }
    };HashStable_Generic)]
1627pub struct OwnerInfo<'hir> {
1628    /// Contents of the HIR.
1629    pub nodes: OwnerNodes<'hir>,
1630    /// Map from each nested owner to its parent's local id.
1631    pub parenting: LocalDefIdMap<ItemLocalId>,
1632    /// Collected attributes of the HIR nodes.
1633    pub attrs: AttributeMap<'hir>,
1634    /// Map indicating what traits are in scope for places where this
1635    /// is relevant; generated by resolve.
1636    pub trait_map: ItemLocalMap<Box<[TraitCandidate]>>,
1637
1638    /// Lints delayed during ast lowering to be emitted
1639    /// after hir has completely built
1640    pub delayed_lints: DelayedLints,
1641}
1642
1643impl<'tcx> OwnerInfo<'tcx> {
1644    #[inline]
1645    pub fn node(&self) -> OwnerNode<'tcx> {
1646        self.nodes.node()
1647    }
1648}
1649
1650#[derive(#[automatically_derived]
impl<'tcx> ::core::marker::Copy for MaybeOwner<'tcx> { }Copy, #[automatically_derived]
impl<'tcx> ::core::clone::Clone for MaybeOwner<'tcx> {
    #[inline]
    fn clone(&self) -> MaybeOwner<'tcx> {
        let _: ::core::clone::AssertParamIsClone<&'tcx OwnerInfo<'tcx>>;
        let _: ::core::clone::AssertParamIsClone<HirId>;
        *self
    }
}Clone, #[automatically_derived]
impl<'tcx> ::core::fmt::Debug for MaybeOwner<'tcx> {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        match self {
            MaybeOwner::Owner(__self_0) =>
                ::core::fmt::Formatter::debug_tuple_field1_finish(f, "Owner",
                    &__self_0),
            MaybeOwner::NonOwner(__self_0) =>
                ::core::fmt::Formatter::debug_tuple_field1_finish(f,
                    "NonOwner", &__self_0),
            MaybeOwner::Phantom =>
                ::core::fmt::Formatter::write_str(f, "Phantom"),
        }
    }
}Debug, const _: () =
    {
        impl<'tcx, __CTX>
            ::rustc_data_structures::stable_hasher::HashStable<__CTX> for
            MaybeOwner<'tcx> where __CTX: crate::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 {
                    MaybeOwner::Owner(ref __binding_0) => {
                        { __binding_0.hash_stable(__hcx, __hasher); }
                    }
                    MaybeOwner::NonOwner(ref __binding_0) => {
                        { __binding_0.hash_stable(__hcx, __hasher); }
                    }
                    MaybeOwner::Phantom => {}
                }
            }
        }
    };HashStable_Generic)]
1651pub enum MaybeOwner<'tcx> {
1652    Owner(&'tcx OwnerInfo<'tcx>),
1653    NonOwner(HirId),
1654    /// Used as a placeholder for unused LocalDefId.
1655    Phantom,
1656}
1657
1658impl<'tcx> MaybeOwner<'tcx> {
1659    pub fn as_owner(self) -> Option<&'tcx OwnerInfo<'tcx>> {
1660        match self {
1661            MaybeOwner::Owner(i) => Some(i),
1662            MaybeOwner::NonOwner(_) | MaybeOwner::Phantom => None,
1663        }
1664    }
1665
1666    pub fn unwrap(self) -> &'tcx OwnerInfo<'tcx> {
1667        self.as_owner().unwrap_or_else(|| { ::core::panicking::panic_fmt(format_args!("Not a HIR owner")); }panic!("Not a HIR owner"))
1668    }
1669}
1670
1671/// The top-level data structure that stores the entire contents of
1672/// the crate currently being compiled.
1673///
1674/// For more details, see the [rustc dev guide].
1675///
1676/// [rustc dev guide]: https://rustc-dev-guide.rust-lang.org/hir.html
1677#[derive(#[automatically_derived]
impl<'hir> ::core::fmt::Debug for Crate<'hir> {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::debug_struct_field2_finish(f, "Crate",
            "owners", &self.owners, "opt_hir_hash", &&self.opt_hir_hash)
    }
}Debug)]
1678pub struct Crate<'hir> {
1679    pub owners: IndexVec<LocalDefId, MaybeOwner<'hir>>,
1680    // Only present when incr. comp. is enabled.
1681    pub opt_hir_hash: Option<Fingerprint>,
1682}
1683
1684#[derive(#[automatically_derived]
impl<'hir> ::core::fmt::Debug for Closure<'hir> {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        let names: &'static _ =
            &["def_id", "binder", "constness", "capture_clause",
                        "bound_generic_params", "fn_decl", "body", "fn_decl_span",
                        "fn_arg_span", "kind"];
        let values: &[&dyn ::core::fmt::Debug] =
            &[&self.def_id, &self.binder, &self.constness,
                        &self.capture_clause, &self.bound_generic_params,
                        &self.fn_decl, &self.body, &self.fn_decl_span,
                        &self.fn_arg_span, &&self.kind];
        ::core::fmt::Formatter::debug_struct_fields_finish(f, "Closure",
            names, values)
    }
}Debug, #[automatically_derived]
impl<'hir> ::core::clone::Clone for Closure<'hir> {
    #[inline]
    fn clone(&self) -> Closure<'hir> {
        let _: ::core::clone::AssertParamIsClone<LocalDefId>;
        let _: ::core::clone::AssertParamIsClone<ClosureBinder>;
        let _: ::core::clone::AssertParamIsClone<Constness>;
        let _: ::core::clone::AssertParamIsClone<CaptureBy>;
        let _: ::core::clone::AssertParamIsClone<&'hir [GenericParam<'hir>]>;
        let _: ::core::clone::AssertParamIsClone<&'hir FnDecl<'hir>>;
        let _: ::core::clone::AssertParamIsClone<BodyId>;
        let _: ::core::clone::AssertParamIsClone<Span>;
        let _: ::core::clone::AssertParamIsClone<Option<Span>>;
        let _: ::core::clone::AssertParamIsClone<ClosureKind>;
        *self
    }
}Clone, #[automatically_derived]
impl<'hir> ::core::marker::Copy for Closure<'hir> { }Copy, const _: () =
    {
        impl<'hir, __CTX>
            ::rustc_data_structures::stable_hasher::HashStable<__CTX> for
            Closure<'hir> where __CTX: crate::HashStableContext {
            #[inline]
            fn hash_stable(&self, __hcx: &mut __CTX,
                __hasher:
                    &mut ::rustc_data_structures::stable_hasher::StableHasher) {
                match *self {
                    Closure {
                        def_id: ref __binding_0,
                        binder: ref __binding_1,
                        constness: ref __binding_2,
                        capture_clause: ref __binding_3,
                        bound_generic_params: ref __binding_4,
                        fn_decl: ref __binding_5,
                        body: ref __binding_6,
                        fn_decl_span: ref __binding_7,
                        fn_arg_span: ref __binding_8,
                        kind: ref __binding_9 } => {
                        { __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); }
                        { __binding_5.hash_stable(__hcx, __hasher); }
                        { __binding_6.hash_stable(__hcx, __hasher); }
                        { __binding_7.hash_stable(__hcx, __hasher); }
                        { __binding_8.hash_stable(__hcx, __hasher); }
                        { __binding_9.hash_stable(__hcx, __hasher); }
                    }
                }
            }
        }
    };HashStable_Generic)]
1685pub struct Closure<'hir> {
1686    pub def_id: LocalDefId,
1687    pub binder: ClosureBinder,
1688    pub constness: Constness,
1689    pub capture_clause: CaptureBy,
1690    pub bound_generic_params: &'hir [GenericParam<'hir>],
1691    pub fn_decl: &'hir FnDecl<'hir>,
1692    pub body: BodyId,
1693    /// The span of the declaration block: 'move |...| -> ...'
1694    pub fn_decl_span: Span,
1695    /// The span of the argument block `|...|`
1696    pub fn_arg_span: Option<Span>,
1697    pub kind: ClosureKind,
1698}
1699
1700#[derive(#[automatically_derived]
impl ::core::clone::Clone for ClosureKind {
    #[inline]
    fn clone(&self) -> ClosureKind {
        let _: ::core::clone::AssertParamIsClone<CoroutineKind>;
        let _: ::core::clone::AssertParamIsClone<CoroutineDesugaring>;
        *self
    }
}Clone, #[automatically_derived]
impl ::core::cmp::PartialEq for ClosureKind {
    #[inline]
    fn eq(&self, other: &ClosureKind) -> bool {
        let __self_discr = ::core::intrinsics::discriminant_value(self);
        let __arg1_discr = ::core::intrinsics::discriminant_value(other);
        __self_discr == __arg1_discr &&
            match (self, other) {
                (ClosureKind::Coroutine(__self_0),
                    ClosureKind::Coroutine(__arg1_0)) => __self_0 == __arg1_0,
                (ClosureKind::CoroutineClosure(__self_0),
                    ClosureKind::CoroutineClosure(__arg1_0)) =>
                    __self_0 == __arg1_0,
                _ => true,
            }
    }
}PartialEq, #[automatically_derived]
impl ::core::cmp::Eq for ClosureKind {
    #[inline]
    #[doc(hidden)]
    #[coverage(off)]
    fn assert_fields_are_eq(&self) {
        let _: ::core::cmp::AssertParamIsEq<CoroutineKind>;
        let _: ::core::cmp::AssertParamIsEq<CoroutineDesugaring>;
    }
}Eq, #[automatically_derived]
impl ::core::fmt::Debug for ClosureKind {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        match self {
            ClosureKind::Closure =>
                ::core::fmt::Formatter::write_str(f, "Closure"),
            ClosureKind::Coroutine(__self_0) =>
                ::core::fmt::Formatter::debug_tuple_field1_finish(f,
                    "Coroutine", &__self_0),
            ClosureKind::CoroutineClosure(__self_0) =>
                ::core::fmt::Formatter::debug_tuple_field1_finish(f,
                    "CoroutineClosure", &__self_0),
        }
    }
}Debug, #[automatically_derived]
impl ::core::marker::Copy for ClosureKind { }Copy, #[automatically_derived]
impl ::core::hash::Hash for ClosureKind {
    #[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 {
            ClosureKind::Coroutine(__self_0) =>
                ::core::hash::Hash::hash(__self_0, state),
            ClosureKind::CoroutineClosure(__self_0) =>
                ::core::hash::Hash::hash(__self_0, state),
            _ => {}
        }
    }
}Hash, const _: () =
    {
        impl<__CTX> ::rustc_data_structures::stable_hasher::HashStable<__CTX>
            for ClosureKind where __CTX: crate::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 {
                    ClosureKind::Closure => {}
                    ClosureKind::Coroutine(ref __binding_0) => {
                        { __binding_0.hash_stable(__hcx, __hasher); }
                    }
                    ClosureKind::CoroutineClosure(ref __binding_0) => {
                        { __binding_0.hash_stable(__hcx, __hasher); }
                    }
                }
            }
        }
    };HashStable_Generic, const _: () =
    {
        impl<__E: ::rustc_span::SpanEncoder> ::rustc_serialize::Encodable<__E>
            for ClosureKind {
            fn encode(&self, __encoder: &mut __E) {
                let disc =
                    match *self {
                        ClosureKind::Closure => { 0usize }
                        ClosureKind::Coroutine(ref __binding_0) => { 1usize }
                        ClosureKind::CoroutineClosure(ref __binding_0) => { 2usize }
                    };
                ::rustc_serialize::Encoder::emit_u8(__encoder, disc as u8);
                match *self {
                    ClosureKind::Closure => {}
                    ClosureKind::Coroutine(ref __binding_0) => {
                        ::rustc_serialize::Encodable::<__E>::encode(__binding_0,
                            __encoder);
                    }
                    ClosureKind::CoroutineClosure(ref __binding_0) => {
                        ::rustc_serialize::Encodable::<__E>::encode(__binding_0,
                            __encoder);
                    }
                }
            }
        }
    };Encodable, const _: () =
    {
        impl<__D: ::rustc_span::SpanDecoder> ::rustc_serialize::Decodable<__D>
            for ClosureKind {
            fn decode(__decoder: &mut __D) -> Self {
                match ::rustc_serialize::Decoder::read_u8(__decoder) as usize
                    {
                    0usize => { ClosureKind::Closure }
                    1usize => {
                        ClosureKind::Coroutine(::rustc_serialize::Decodable::decode(__decoder))
                    }
                    2usize => {
                        ClosureKind::CoroutineClosure(::rustc_serialize::Decodable::decode(__decoder))
                    }
                    n => {
                        ::core::panicking::panic_fmt(format_args!("invalid enum variant tag while decoding `ClosureKind`, expected 0..3, actual {0}",
                                n));
                    }
                }
            }
        }
    };Decodable)]
1701pub enum ClosureKind {
1702    /// This is a plain closure expression.
1703    Closure,
1704    /// This is a coroutine expression -- i.e. a closure expression in which
1705    /// we've found a `yield`. These can arise either from "plain" coroutine
1706    ///  usage (e.g. `let x = || { yield (); }`) or from a desugared expression
1707    /// (e.g. `async` and `gen` blocks).
1708    Coroutine(CoroutineKind),
1709    /// This is a coroutine-closure, which is a special sugared closure that
1710    /// returns one of the sugared coroutine (`async`/`gen`/`async gen`). It
1711    /// additionally allows capturing the coroutine's upvars by ref, and therefore
1712    /// needs to be specially treated during analysis and borrowck.
1713    CoroutineClosure(CoroutineDesugaring),
1714}
1715
1716/// A block of statements `{ .. }`, which may have a label (in this case the
1717/// `targeted_by_break` field will be `true`) and may be `unsafe` by means of
1718/// the `rules` being anything but `DefaultBlock`.
1719#[derive(#[automatically_derived]
impl<'hir> ::core::fmt::Debug for Block<'hir> {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        let names: &'static _ =
            &["stmts", "expr", "hir_id", "rules", "span",
                        "targeted_by_break"];
        let values: &[&dyn ::core::fmt::Debug] =
            &[&self.stmts, &self.expr, &self.hir_id, &self.rules, &self.span,
                        &&self.targeted_by_break];
        ::core::fmt::Formatter::debug_struct_fields_finish(f, "Block", names,
            values)
    }
}Debug, #[automatically_derived]
impl<'hir> ::core::clone::Clone for Block<'hir> {
    #[inline]
    fn clone(&self) -> Block<'hir> {
        let _: ::core::clone::AssertParamIsClone<&'hir [Stmt<'hir>]>;
        let _: ::core::clone::AssertParamIsClone<Option<&'hir Expr<'hir>>>;
        let _: ::core::clone::AssertParamIsClone<HirId>;
        let _: ::core::clone::AssertParamIsClone<BlockCheckMode>;
        let _: ::core::clone::AssertParamIsClone<Span>;
        let _: ::core::clone::AssertParamIsClone<bool>;
        *self
    }
}Clone, #[automatically_derived]
impl<'hir> ::core::marker::Copy for Block<'hir> { }Copy, const _: () =
    {
        impl<'hir, __CTX>
            ::rustc_data_structures::stable_hasher::HashStable<__CTX> for
            Block<'hir> where __CTX: crate::HashStableContext {
            #[inline]
            fn hash_stable(&self, __hcx: &mut __CTX,
                __hasher:
                    &mut ::rustc_data_structures::stable_hasher::StableHasher) {
                match *self {
                    Block {
                        stmts: ref __binding_0,
                        expr: ref __binding_1,
                        hir_id: ref __binding_2,
                        rules: ref __binding_3,
                        span: ref __binding_4,
                        targeted_by_break: ref __binding_5 } => {
                        { __binding_0.hash_stable(__hcx, __hasher); }
                        { __binding_1.hash_stable(__hcx, __hasher); }
                        {}
                        { __binding_3.hash_stable(__hcx, __hasher); }
                        { __binding_4.hash_stable(__hcx, __hasher); }
                        { __binding_5.hash_stable(__hcx, __hasher); }
                    }
                }
            }
        }
    };HashStable_Generic)]
1720pub struct Block<'hir> {
1721    /// Statements in a block.
1722    pub stmts: &'hir [Stmt<'hir>],
1723    /// An expression at the end of the block
1724    /// without a semicolon, if any.
1725    pub expr: Option<&'hir Expr<'hir>>,
1726    #[stable_hasher(ignore)]
1727    pub hir_id: HirId,
1728    /// Distinguishes between `unsafe { ... }` and `{ ... }`.
1729    pub rules: BlockCheckMode,
1730    /// The span includes the curly braces `{` and `}` around the block.
1731    pub span: Span,
1732    /// If true, then there may exist `break 'a` values that aim to
1733    /// break out of this block early.
1734    /// Used by `'label: {}` blocks and by `try {}` blocks.
1735    pub targeted_by_break: bool,
1736}
1737
1738impl<'hir> Block<'hir> {
1739    pub fn innermost_block(&self) -> &Block<'hir> {
1740        let mut block = self;
1741        while let Some(Expr { kind: ExprKind::Block(inner_block, _), .. }) = block.expr {
1742            block = inner_block;
1743        }
1744        block
1745    }
1746}
1747
1748#[derive(#[automatically_derived]
impl ::core::fmt::Debug for TyFieldPath {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::debug_struct_field2_finish(f, "TyFieldPath",
            "variant", &self.variant, "field", &&self.field)
    }
}Debug, #[automatically_derived]
impl ::core::clone::Clone for TyFieldPath {
    #[inline]
    fn clone(&self) -> TyFieldPath {
        let _: ::core::clone::AssertParamIsClone<Option<Ident>>;
        let _: ::core::clone::AssertParamIsClone<Ident>;
        *self
    }
}Clone, #[automatically_derived]
impl ::core::marker::Copy for TyFieldPath { }Copy, const _: () =
    {
        impl<__CTX> ::rustc_data_structures::stable_hasher::HashStable<__CTX>
            for TyFieldPath where __CTX: crate::HashStableContext {
            #[inline]
            fn hash_stable(&self, __hcx: &mut __CTX,
                __hasher:
                    &mut ::rustc_data_structures::stable_hasher::StableHasher) {
                match *self {
                    TyFieldPath {
                        variant: ref __binding_0, field: ref __binding_1 } => {
                        { __binding_0.hash_stable(__hcx, __hasher); }
                        { __binding_1.hash_stable(__hcx, __hasher); }
                    }
                }
            }
        }
    };HashStable_Generic)]
1749pub struct TyFieldPath {
1750    pub variant: Option<Ident>,
1751    pub field: Ident,
1752}
1753
1754#[derive(#[automatically_derived]
impl<'hir> ::core::fmt::Debug for TyPat<'hir> {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::debug_struct_field3_finish(f, "TyPat",
            "hir_id", &self.hir_id, "kind", &self.kind, "span", &&self.span)
    }
}Debug, #[automatically_derived]
impl<'hir> ::core::clone::Clone for TyPat<'hir> {
    #[inline]
    fn clone(&self) -> TyPat<'hir> {
        let _: ::core::clone::AssertParamIsClone<HirId>;
        let _: ::core::clone::AssertParamIsClone<TyPatKind<'hir>>;
        let _: ::core::clone::AssertParamIsClone<Span>;
        *self
    }
}Clone, #[automatically_derived]
impl<'hir> ::core::marker::Copy for TyPat<'hir> { }Copy, const _: () =
    {
        impl<'hir, __CTX>
            ::rustc_data_structures::stable_hasher::HashStable<__CTX> for
            TyPat<'hir> where __CTX: crate::HashStableContext {
            #[inline]
            fn hash_stable(&self, __hcx: &mut __CTX,
                __hasher:
                    &mut ::rustc_data_structures::stable_hasher::StableHasher) {
                match *self {
                    TyPat {
                        hir_id: ref __binding_0,
                        kind: ref __binding_1,
                        span: ref __binding_2 } => {
                        {}
                        { __binding_1.hash_stable(__hcx, __hasher); }
                        { __binding_2.hash_stable(__hcx, __hasher); }
                    }
                }
            }
        }
    };HashStable_Generic)]
1755pub struct TyPat<'hir> {
1756    #[stable_hasher(ignore)]
1757    pub hir_id: HirId,
1758    pub kind: TyPatKind<'hir>,
1759    pub span: Span,
1760}
1761
1762#[derive(#[automatically_derived]
impl<'hir> ::core::fmt::Debug for Pat<'hir> {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::debug_struct_field4_finish(f, "Pat", "hir_id",
            &self.hir_id, "kind", &self.kind, "span", &self.span,
            "default_binding_modes", &&self.default_binding_modes)
    }
}Debug, #[automatically_derived]
impl<'hir> ::core::clone::Clone for Pat<'hir> {
    #[inline]
    fn clone(&self) -> Pat<'hir> {
        let _: ::core::clone::AssertParamIsClone<HirId>;
        let _: ::core::clone::AssertParamIsClone<PatKind<'hir>>;
        let _: ::core::clone::AssertParamIsClone<Span>;
        let _: ::core::clone::AssertParamIsClone<bool>;
        *self
    }
}Clone, #[automatically_derived]
impl<'hir> ::core::marker::Copy for Pat<'hir> { }Copy, const _: () =
    {
        impl<'hir, __CTX>
            ::rustc_data_structures::stable_hasher::HashStable<__CTX> for
            Pat<'hir> where __CTX: crate::HashStableContext {
            #[inline]
            fn hash_stable(&self, __hcx: &mut __CTX,
                __hasher:
                    &mut ::rustc_data_structures::stable_hasher::StableHasher) {
                match *self {
                    Pat {
                        hir_id: ref __binding_0,
                        kind: ref __binding_1,
                        span: ref __binding_2,
                        default_binding_modes: ref __binding_3 } => {
                        {}
                        { __binding_1.hash_stable(__hcx, __hasher); }
                        { __binding_2.hash_stable(__hcx, __hasher); }
                        { __binding_3.hash_stable(__hcx, __hasher); }
                    }
                }
            }
        }
    };HashStable_Generic)]
1763pub struct Pat<'hir> {
1764    #[stable_hasher(ignore)]
1765    pub hir_id: HirId,
1766    pub kind: PatKind<'hir>,
1767    pub span: Span,
1768    /// Whether to use default binding modes.
1769    /// At present, this is false only for destructuring assignment.
1770    pub default_binding_modes: bool,
1771}
1772
1773impl<'hir> Pat<'hir> {
1774    fn walk_short_(&self, it: &mut impl FnMut(&Pat<'hir>) -> bool) -> bool {
1775        if !it(self) {
1776            return false;
1777        }
1778
1779        use PatKind::*;
1780        match self.kind {
1781            Missing => ::core::panicking::panic("internal error: entered unreachable code")unreachable!(),
1782            Wild | Never | Expr(_) | Range(..) | Binding(.., None) | Err(_) => true,
1783            Box(s) | Deref(s) | Ref(s, _, _) | Binding(.., Some(s)) | Guard(s, _) => {
1784                s.walk_short_(it)
1785            }
1786            Struct(_, fields, _) => fields.iter().all(|field| field.pat.walk_short_(it)),
1787            TupleStruct(_, s, _) | Tuple(s, _) | Or(s) => s.iter().all(|p| p.walk_short_(it)),
1788            Slice(before, slice, after) => {
1789                before.iter().chain(slice).chain(after.iter()).all(|p| p.walk_short_(it))
1790            }
1791        }
1792    }
1793
1794    /// Walk the pattern in left-to-right order,
1795    /// short circuiting (with `.all(..)`) if `false` is returned.
1796    ///
1797    /// Note that when visiting e.g. `Tuple(ps)`,
1798    /// if visiting `ps[0]` returns `false`,
1799    /// then `ps[1]` will not be visited.
1800    pub fn walk_short(&self, mut it: impl FnMut(&Pat<'hir>) -> bool) -> bool {
1801        self.walk_short_(&mut it)
1802    }
1803
1804    fn walk_(&self, it: &mut impl FnMut(&Pat<'hir>) -> bool) {
1805        if !it(self) {
1806            return;
1807        }
1808
1809        use PatKind::*;
1810        match self.kind {
1811            Missing | Wild | Never | Expr(_) | Range(..) | Binding(.., None) | Err(_) => {}
1812            Box(s) | Deref(s) | Ref(s, _, _) | Binding(.., Some(s)) | Guard(s, _) => s.walk_(it),
1813            Struct(_, fields, _) => fields.iter().for_each(|field| field.pat.walk_(it)),
1814            TupleStruct(_, s, _) | Tuple(s, _) | Or(s) => s.iter().for_each(|p| p.walk_(it)),
1815            Slice(before, slice, after) => {
1816                before.iter().chain(slice).chain(after.iter()).for_each(|p| p.walk_(it))
1817            }
1818        }
1819    }
1820
1821    /// Walk the pattern in left-to-right order.
1822    ///
1823    /// If `it(pat)` returns `false`, the children are not visited.
1824    pub fn walk(&self, mut it: impl FnMut(&Pat<'hir>) -> bool) {
1825        self.walk_(&mut it)
1826    }
1827
1828    /// Walk the pattern in left-to-right order.
1829    ///
1830    /// If you always want to recurse, prefer this method over `walk`.
1831    pub fn walk_always(&self, mut it: impl FnMut(&Pat<'_>)) {
1832        self.walk(|p| {
1833            it(p);
1834            true
1835        })
1836    }
1837
1838    /// Whether this a never pattern.
1839    pub fn is_never_pattern(&self) -> bool {
1840        let mut is_never_pattern = false;
1841        self.walk(|pat| match &pat.kind {
1842            PatKind::Never => {
1843                is_never_pattern = true;
1844                false
1845            }
1846            PatKind::Or(s) => {
1847                is_never_pattern = s.iter().all(|p| p.is_never_pattern());
1848                false
1849            }
1850            _ => true,
1851        });
1852        is_never_pattern
1853    }
1854
1855    /// Whether this pattern constitutes a read of value of the scrutinee that
1856    /// it is matching against. This is used to determine whether we should
1857    /// perform `NeverToAny` coercions.
1858    ///
1859    /// See [`expr_guaranteed_to_constitute_read_for_never`][m] for the nuances of
1860    /// what happens when this returns true.
1861    ///
1862    /// [m]: ../../rustc_middle/ty/struct.TyCtxt.html#method.expr_guaranteed_to_constitute_read_for_never
1863    pub fn is_guaranteed_to_constitute_read_for_never(&self) -> bool {
1864        match self.kind {
1865            // Does not constitute a read.
1866            PatKind::Wild => false,
1867
1868            // The guard cannot affect if we make a read or not (it runs after the inner pattern
1869            // has matched), therefore it's irrelevant.
1870            PatKind::Guard(pat, _) => pat.is_guaranteed_to_constitute_read_for_never(),
1871
1872            // This is unnecessarily restrictive when the pattern that doesn't
1873            // constitute a read is unreachable.
1874            //
1875            // For example `match *never_ptr { value => {}, _ => {} }` or
1876            // `match *never_ptr { _ if false => {}, value => {} }`.
1877            //
1878            // It is however fine to be restrictive here; only returning `true`
1879            // can lead to unsoundness.
1880            PatKind::Or(subpats) => {
1881                subpats.iter().all(|pat| pat.is_guaranteed_to_constitute_read_for_never())
1882            }
1883
1884            // Does constitute a read, since it is equivalent to a discriminant read.
1885            PatKind::Never => true,
1886
1887            // All of these constitute a read, or match on something that isn't `!`,
1888            // which would require a `NeverToAny` coercion.
1889            PatKind::Missing
1890            | PatKind::Binding(_, _, _, _)
1891            | PatKind::Struct(_, _, _)
1892            | PatKind::TupleStruct(_, _, _)
1893            | PatKind::Tuple(_, _)
1894            | PatKind::Box(_)
1895            | PatKind::Ref(_, _, _)
1896            | PatKind::Deref(_)
1897            | PatKind::Expr(_)
1898            | PatKind::Range(_, _, _)
1899            | PatKind::Slice(_, _, _)
1900            | PatKind::Err(_) => true,
1901        }
1902    }
1903}
1904
1905/// A single field in a struct pattern.
1906///
1907/// Patterns like the fields of Foo `{ x, ref y, ref mut z }`
1908/// are treated the same as` x: x, y: ref y, z: ref mut z`,
1909/// except `is_shorthand` is true.
1910#[derive(#[automatically_derived]
impl<'hir> ::core::fmt::Debug for PatField<'hir> {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::debug_struct_field5_finish(f, "PatField",
            "hir_id", &self.hir_id, "ident", &self.ident, "pat", &self.pat,
            "is_shorthand", &self.is_shorthand, "span", &&self.span)
    }
}Debug, #[automatically_derived]
impl<'hir> ::core::clone::Clone for PatField<'hir> {
    #[inline]
    fn clone(&self) -> PatField<'hir> {
        let _: ::core::clone::AssertParamIsClone<HirId>;
        let _: ::core::clone::AssertParamIsClone<Ident>;
        let _: ::core::clone::AssertParamIsClone<&'hir Pat<'hir>>;
        let _: ::core::clone::AssertParamIsClone<bool>;
        let _: ::core::clone::AssertParamIsClone<Span>;
        *self
    }
}Clone, #[automatically_derived]
impl<'hir> ::core::marker::Copy for PatField<'hir> { }Copy, const _: () =
    {
        impl<'hir, __CTX>
            ::rustc_data_structures::stable_hasher::HashStable<__CTX> for
            PatField<'hir> where __CTX: crate::HashStableContext {
            #[inline]
            fn hash_stable(&self, __hcx: &mut __CTX,
                __hasher:
                    &mut ::rustc_data_structures::stable_hasher::StableHasher) {
                match *self {
                    PatField {
                        hir_id: ref __binding_0,
                        ident: ref __binding_1,
                        pat: ref __binding_2,
                        is_shorthand: ref __binding_3,
                        span: ref __binding_4 } => {
                        {}
                        { __binding_1.hash_stable(__hcx, __hasher); }
                        { __binding_2.hash_stable(__hcx, __hasher); }
                        { __binding_3.hash_stable(__hcx, __hasher); }
                        { __binding_4.hash_stable(__hcx, __hasher); }
                    }
                }
            }
        }
    };HashStable_Generic)]
1911pub struct PatField<'hir> {
1912    #[stable_hasher(ignore)]
1913    pub hir_id: HirId,
1914    /// The identifier for the field.
1915    pub ident: Ident,
1916    /// The pattern the field is destructured to.
1917    pub pat: &'hir Pat<'hir>,
1918    pub is_shorthand: bool,
1919    pub span: Span,
1920}
1921
1922#[derive(#[automatically_derived]
impl ::core::marker::Copy for RangeEnd { }Copy, #[automatically_derived]
impl ::core::clone::Clone for RangeEnd {
    #[inline]
    fn clone(&self) -> RangeEnd { *self }
}Clone, #[automatically_derived]
impl ::core::cmp::PartialEq for RangeEnd {
    #[inline]
    fn eq(&self, other: &RangeEnd) -> 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::fmt::Debug for RangeEnd {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::write_str(f,
            match self {
                RangeEnd::Included => "Included",
                RangeEnd::Excluded => "Excluded",
            })
    }
}Debug, const _: () =
    {
        impl<__CTX> ::rustc_data_structures::stable_hasher::HashStable<__CTX>
            for RangeEnd where __CTX: crate::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 {
                    RangeEnd::Included => {}
                    RangeEnd::Excluded => {}
                }
            }
        }
    };HashStable_Generic, #[automatically_derived]
impl ::core::hash::Hash for RangeEnd {
    #[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, #[automatically_derived]
impl ::core::cmp::Eq for RangeEnd {
    #[inline]
    #[doc(hidden)]
    #[coverage(off)]
    fn assert_fields_are_eq(&self) {}
}Eq, const _: () =
    {
        impl<__E: ::rustc_span::SpanEncoder> ::rustc_serialize::Encodable<__E>
            for RangeEnd {
            fn encode(&self, __encoder: &mut __E) {
                let disc =
                    match *self {
                        RangeEnd::Included => { 0usize }
                        RangeEnd::Excluded => { 1usize }
                    };
                ::rustc_serialize::Encoder::emit_u8(__encoder, disc as u8);
                match *self {
                    RangeEnd::Included => {}
                    RangeEnd::Excluded => {}
                }
            }
        }
    };Encodable, const _: () =
    {
        impl<__D: ::rustc_span::SpanDecoder> ::rustc_serialize::Decodable<__D>
            for RangeEnd {
            fn decode(__decoder: &mut __D) -> Self {
                match ::rustc_serialize::Decoder::read_u8(__decoder) as usize
                    {
                    0usize => { RangeEnd::Included }
                    1usize => { RangeEnd::Excluded }
                    n => {
                        ::core::panicking::panic_fmt(format_args!("invalid enum variant tag while decoding `RangeEnd`, expected 0..2, actual {0}",
                                n));
                    }
                }
            }
        }
    };Decodable)]
1923pub enum RangeEnd {
1924    Included,
1925    Excluded,
1926}
1927
1928impl fmt::Display for RangeEnd {
1929    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
1930        f.write_str(match self {
1931            RangeEnd::Included => "..=",
1932            RangeEnd::Excluded => "..",
1933        })
1934    }
1935}
1936
1937// Equivalent to `Option<usize>`. That type takes up 16 bytes on 64-bit, but
1938// this type only takes up 4 bytes, at the cost of being restricted to a
1939// maximum value of `u32::MAX - 1`. In practice, this is more than enough.
1940#[derive(#[automatically_derived]
impl ::core::clone::Clone for DotDotPos {
    #[inline]
    fn clone(&self) -> DotDotPos {
        let _: ::core::clone::AssertParamIsClone<u32>;
        *self
    }
}Clone, #[automatically_derived]
impl ::core::marker::Copy for DotDotPos { }Copy, #[automatically_derived]
impl ::core::cmp::PartialEq for DotDotPos {
    #[inline]
    fn eq(&self, other: &DotDotPos) -> bool { self.0 == other.0 }
}PartialEq, #[automatically_derived]
impl ::core::cmp::Eq for DotDotPos {
    #[inline]
    #[doc(hidden)]
    #[coverage(off)]
    fn assert_fields_are_eq(&self) {
        let _: ::core::cmp::AssertParamIsEq<u32>;
    }
}Eq, #[automatically_derived]
impl ::core::hash::Hash for DotDotPos {
    #[inline]
    fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) {
        ::core::hash::Hash::hash(&self.0, state)
    }
}Hash, const _: () =
    {
        impl<__CTX> ::rustc_data_structures::stable_hasher::HashStable<__CTX>
            for DotDotPos where __CTX: crate::HashStableContext {
            #[inline]
            fn hash_stable(&self, __hcx: &mut __CTX,
                __hasher:
                    &mut ::rustc_data_structures::stable_hasher::StableHasher) {
                match *self {
                    DotDotPos(ref __binding_0) => {
                        { __binding_0.hash_stable(__hcx, __hasher); }
                    }
                }
            }
        }
    };HashStable_Generic)]
1941pub struct DotDotPos(u32);
1942
1943impl DotDotPos {
1944    /// Panics if n >= u32::MAX.
1945    pub fn new(n: Option<usize>) -> Self {
1946        match n {
1947            Some(n) => {
1948                if !(n < u32::MAX as usize) {
    ::core::panicking::panic("assertion failed: n < u32::MAX as usize")
};assert!(n < u32::MAX as usize);
1949                Self(n as u32)
1950            }
1951            None => Self(u32::MAX),
1952        }
1953    }
1954
1955    pub fn as_opt_usize(&self) -> Option<usize> {
1956        if self.0 == u32::MAX { None } else { Some(self.0 as usize) }
1957    }
1958}
1959
1960impl fmt::Debug for DotDotPos {
1961    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
1962        self.as_opt_usize().fmt(f)
1963    }
1964}
1965
1966#[derive(#[automatically_derived]
impl<'hir> ::core::fmt::Debug for PatExpr<'hir> {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::debug_struct_field3_finish(f, "PatExpr",
            "hir_id", &self.hir_id, "span", &self.span, "kind", &&self.kind)
    }
}Debug, #[automatically_derived]
impl<'hir> ::core::clone::Clone for PatExpr<'hir> {
    #[inline]
    fn clone(&self) -> PatExpr<'hir> {
        let _: ::core::clone::AssertParamIsClone<HirId>;
        let _: ::core::clone::AssertParamIsClone<Span>;
        let _: ::core::clone::AssertParamIsClone<PatExprKind<'hir>>;
        *self
    }
}Clone, #[automatically_derived]
impl<'hir> ::core::marker::Copy for PatExpr<'hir> { }Copy, const _: () =
    {
        impl<'hir, __CTX>
            ::rustc_data_structures::stable_hasher::HashStable<__CTX> for
            PatExpr<'hir> where __CTX: crate::HashStableContext {
            #[inline]
            fn hash_stable(&self, __hcx: &mut __CTX,
                __hasher:
                    &mut ::rustc_data_structures::stable_hasher::StableHasher) {
                match *self {
                    PatExpr {
                        hir_id: ref __binding_0,
                        span: ref __binding_1,
                        kind: ref __binding_2 } => {
                        {}
                        { __binding_1.hash_stable(__hcx, __hasher); }
                        { __binding_2.hash_stable(__hcx, __hasher); }
                    }
                }
            }
        }
    };HashStable_Generic)]
1967pub struct PatExpr<'hir> {
1968    #[stable_hasher(ignore)]
1969    pub hir_id: HirId,
1970    pub span: Span,
1971    pub kind: PatExprKind<'hir>,
1972}
1973
1974#[derive(#[automatically_derived]
impl<'hir> ::core::fmt::Debug for PatExprKind<'hir> {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        match self {
            PatExprKind::Lit { lit: __self_0, negated: __self_1 } =>
                ::core::fmt::Formatter::debug_struct_field2_finish(f, "Lit",
                    "lit", __self_0, "negated", &__self_1),
            PatExprKind::Path(__self_0) =>
                ::core::fmt::Formatter::debug_tuple_field1_finish(f, "Path",
                    &__self_0),
        }
    }
}Debug, #[automatically_derived]
impl<'hir> ::core::clone::Clone for PatExprKind<'hir> {
    #[inline]
    fn clone(&self) -> PatExprKind<'hir> {
        let _: ::core::clone::AssertParamIsClone<Lit>;
        let _: ::core::clone::AssertParamIsClone<bool>;
        let _: ::core::clone::AssertParamIsClone<QPath<'hir>>;
        *self
    }
}Clone, #[automatically_derived]
impl<'hir> ::core::marker::Copy for PatExprKind<'hir> { }Copy, const _: () =
    {
        impl<'hir, __CTX>
            ::rustc_data_structures::stable_hasher::HashStable<__CTX> for
            PatExprKind<'hir> where __CTX: crate::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 {
                    PatExprKind::Lit {
                        lit: ref __binding_0, negated: ref __binding_1 } => {
                        { __binding_0.hash_stable(__hcx, __hasher); }
                        { __binding_1.hash_stable(__hcx, __hasher); }
                    }
                    PatExprKind::Path(ref __binding_0) => {
                        { __binding_0.hash_stable(__hcx, __hasher); }
                    }
                }
            }
        }
    };HashStable_Generic)]
1975pub enum PatExprKind<'hir> {
1976    Lit {
1977        lit: Lit,
1978        negated: bool,
1979    },
1980    /// A path pattern for a unit struct/variant or a (maybe-associated) constant.
1981    Path(QPath<'hir>),
1982}
1983
1984#[derive(#[automatically_derived]
impl<'hir> ::core::fmt::Debug for TyPatKind<'hir> {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        match self {
            TyPatKind::Range(__self_0, __self_1) =>
                ::core::fmt::Formatter::debug_tuple_field2_finish(f, "Range",
                    __self_0, &__self_1),
            TyPatKind::NotNull =>
                ::core::fmt::Formatter::write_str(f, "NotNull"),
            TyPatKind::Or(__self_0) =>
                ::core::fmt::Formatter::debug_tuple_field1_finish(f, "Or",
                    &__self_0),
            TyPatKind::Err(__self_0) =>
                ::core::fmt::Formatter::debug_tuple_field1_finish(f, "Err",
                    &__self_0),
        }
    }
}Debug, #[automatically_derived]
impl<'hir> ::core::clone::Clone for TyPatKind<'hir> {
    #[inline]
    fn clone(&self) -> TyPatKind<'hir> {
        let _: ::core::clone::AssertParamIsClone<&'hir ConstArg<'hir>>;
        let _: ::core::clone::AssertParamIsClone<&'hir ConstArg<'hir>>;
        let _: ::core::clone::AssertParamIsClone<&'hir [TyPat<'hir>]>;
        let _: ::core::clone::AssertParamIsClone<ErrorGuaranteed>;
        *self
    }
}Clone, #[automatically_derived]
impl<'hir> ::core::marker::Copy for TyPatKind<'hir> { }Copy, const _: () =
    {
        impl<'hir, __CTX>
            ::rustc_data_structures::stable_hasher::HashStable<__CTX> for
            TyPatKind<'hir> where __CTX: crate::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 {
                    TyPatKind::Range(ref __binding_0, ref __binding_1) => {
                        { __binding_0.hash_stable(__hcx, __hasher); }
                        { __binding_1.hash_stable(__hcx, __hasher); }
                    }
                    TyPatKind::NotNull => {}
                    TyPatKind::Or(ref __binding_0) => {
                        { __binding_0.hash_stable(__hcx, __hasher); }
                    }
                    TyPatKind::Err(ref __binding_0) => {
                        { __binding_0.hash_stable(__hcx, __hasher); }
                    }
                }
            }
        }
    };HashStable_Generic)]
1985pub enum TyPatKind<'hir> {
1986    /// A range pattern (e.g., `1..=2` or `1..2`).
1987    Range(&'hir ConstArg<'hir>, &'hir ConstArg<'hir>),
1988
1989    /// A pattern that excludes null pointers
1990    NotNull,
1991
1992    /// A list of patterns where only one needs to be satisfied
1993    Or(&'hir [TyPat<'hir>]),
1994
1995    /// A placeholder for a pattern that wasn't well formed in some way.
1996    Err(ErrorGuaranteed),
1997}
1998
1999#[derive(#[automatically_derived]
impl<'hir> ::core::fmt::Debug for PatKind<'hir> {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        match self {
            PatKind::Missing =>
                ::core::fmt::Formatter::write_str(f, "Missing"),
            PatKind::Wild => ::core::fmt::Formatter::write_str(f, "Wild"),
            PatKind::Binding(__self_0, __self_1, __self_2, __self_3) =>
                ::core::fmt::Formatter::debug_tuple_field4_finish(f,
                    "Binding", __self_0, __self_1, __self_2, &__self_3),
            PatKind::Struct(__self_0, __self_1, __self_2) =>
                ::core::fmt::Formatter::debug_tuple_field3_finish(f, "Struct",
                    __self_0, __self_1, &__self_2),
            PatKind::TupleStruct(__self_0, __self_1, __self_2) =>
                ::core::fmt::Formatter::debug_tuple_field3_finish(f,
                    "TupleStruct", __self_0, __self_1, &__self_2),
            PatKind::Or(__self_0) =>
                ::core::fmt::Formatter::debug_tuple_field1_finish(f, "Or",
                    &__self_0),
            PatKind::Never => ::core::fmt::Formatter::write_str(f, "Never"),
            PatKind::Tuple(__self_0, __self_1) =>
                ::core::fmt::Formatter::debug_tuple_field2_finish(f, "Tuple",
                    __self_0, &__self_1),
            PatKind::Box(__self_0) =>
                ::core::fmt::Formatter::debug_tuple_field1_finish(f, "Box",
                    &__self_0),
            PatKind::Deref(__self_0) =>
                ::core::fmt::Formatter::debug_tuple_field1_finish(f, "Deref",
                    &__self_0),
            PatKind::Ref(__self_0, __self_1, __self_2) =>
                ::core::fmt::Formatter::debug_tuple_field3_finish(f, "Ref",
                    __self_0, __self_1, &__self_2),
            PatKind::Expr(__self_0) =>
                ::core::fmt::Formatter::debug_tuple_field1_finish(f, "Expr",
                    &__self_0),
            PatKind::Guard(__self_0, __self_1) =>
                ::core::fmt::Formatter::debug_tuple_field2_finish(f, "Guard",
                    __self_0, &__self_1),
            PatKind::Range(__self_0, __self_1, __self_2) =>
                ::core::fmt::Formatter::debug_tuple_field3_finish(f, "Range",
                    __self_0, __self_1, &__self_2),
            PatKind::Slice(__self_0, __self_1, __self_2) =>
                ::core::fmt::Formatter::debug_tuple_field3_finish(f, "Slice",
                    __self_0, __self_1, &__self_2),
            PatKind::Err(__self_0) =>
                ::core::fmt::Formatter::debug_tuple_field1_finish(f, "Err",
                    &__self_0),
        }
    }
}Debug, #[automatically_derived]
impl<'hir> ::core::clone::Clone for PatKind<'hir> {
    #[inline]
    fn clone(&self) -> PatKind<'hir> {
        let _: ::core::clone::AssertParamIsClone<BindingMode>;
        let _: ::core::clone::AssertParamIsClone<HirId>;
        let _: ::core::clone::AssertParamIsClone<Ident>;
        let _: ::core::clone::AssertParamIsClone<Option<&'hir Pat<'hir>>>;
        let _: ::core::clone::AssertParamIsClone<QPath<'hir>>;
        let _: ::core::clone::AssertParamIsClone<&'hir [PatField<'hir>]>;
        let _: ::core::clone::AssertParamIsClone<Option<Span>>;
        let _: ::core::clone::AssertParamIsClone<QPath<'hir>>;
        let _: ::core::clone::AssertParamIsClone<&'hir [Pat<'hir>]>;
        let _: ::core::clone::AssertParamIsClone<DotDotPos>;
        let _: ::core::clone::AssertParamIsClone<&'hir [Pat<'hir>]>;
        let _: ::core::clone::AssertParamIsClone<&'hir [Pat<'hir>]>;
        let _: ::core::clone::AssertParamIsClone<&'hir Pat<'hir>>;
        let _: ::core::clone::AssertParamIsClone<&'hir Pat<'hir>>;
        let _: ::core::clone::AssertParamIsClone<&'hir Pat<'hir>>;
        let _: ::core::clone::AssertParamIsClone<Pinnedness>;
        let _: ::core::clone::AssertParamIsClone<Mutability>;
        let _: ::core::clone::AssertParamIsClone<&'hir PatExpr<'hir>>;
        let _: ::core::clone::AssertParamIsClone<&'hir Pat<'hir>>;
        let _: ::core::clone::AssertParamIsClone<&'hir Expr<'hir>>;
        let _: ::core::clone::AssertParamIsClone<Option<&'hir PatExpr<'hir>>>;
        let _: ::core::clone::AssertParamIsClone<Option<&'hir PatExpr<'hir>>>;
        let _: ::core::clone::AssertParamIsClone<RangeEnd>;
        let _: ::core::clone::AssertParamIsClone<&'hir [Pat<'hir>]>;
        let _: ::core::clone::AssertParamIsClone<Option<&'hir Pat<'hir>>>;
        let _: ::core::clone::AssertParamIsClone<&'hir [Pat<'hir>]>;
        let _: ::core::clone::AssertParamIsClone<ErrorGuaranteed>;
        *self
    }
}Clone, #[automatically_derived]
impl<'hir> ::core::marker::Copy for PatKind<'hir> { }Copy, const _: () =
    {
        impl<'hir, __CTX>
            ::rustc_data_structures::stable_hasher::HashStable<__CTX> for
            PatKind<'hir> where __CTX: crate::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 {
                    PatKind::Missing => {}
                    PatKind::Wild => {}
                    PatKind::Binding(ref __binding_0, ref __binding_1,
                        ref __binding_2, 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); }
                    }
                    PatKind::Struct(ref __binding_0, ref __binding_1,
                        ref __binding_2) => {
                        { __binding_0.hash_stable(__hcx, __hasher); }
                        { __binding_1.hash_stable(__hcx, __hasher); }
                        { __binding_2.hash_stable(__hcx, __hasher); }
                    }
                    PatKind::TupleStruct(ref __binding_0, ref __binding_1,
                        ref __binding_2) => {
                        { __binding_0.hash_stable(__hcx, __hasher); }
                        { __binding_1.hash_stable(__hcx, __hasher); }
                        { __binding_2.hash_stable(__hcx, __hasher); }
                    }
                    PatKind::Or(ref __binding_0) => {
                        { __binding_0.hash_stable(__hcx, __hasher); }
                    }
                    PatKind::Never => {}
                    PatKind::Tuple(ref __binding_0, ref __binding_1) => {
                        { __binding_0.hash_stable(__hcx, __hasher); }
                        { __binding_1.hash_stable(__hcx, __hasher); }
                    }
                    PatKind::Box(ref __binding_0) => {
                        { __binding_0.hash_stable(__hcx, __hasher); }
                    }
                    PatKind::Deref(ref __binding_0) => {
                        { __binding_0.hash_stable(__hcx, __hasher); }
                    }
                    PatKind::Ref(ref __binding_0, ref __binding_1,
                        ref __binding_2) => {
                        { __binding_0.hash_stable(__hcx, __hasher); }
                        { __binding_1.hash_stable(__hcx, __hasher); }
                        { __binding_2.hash_stable(__hcx, __hasher); }
                    }
                    PatKind::Expr(ref __binding_0) => {
                        { __binding_0.hash_stable(__hcx, __hasher); }
                    }
                    PatKind::Guard(ref __binding_0, ref __binding_1) => {
                        { __binding_0.hash_stable(__hcx, __hasher); }
                        { __binding_1.hash_stable(__hcx, __hasher); }
                    }
                    PatKind::Range(ref __binding_0, ref __binding_1,
                        ref __binding_2) => {
                        { __binding_0.hash_stable(__hcx, __hasher); }
                        { __binding_1.hash_stable(__hcx, __hasher); }
                        { __binding_2.hash_stable(__hcx, __hasher); }
                    }
                    PatKind::Slice(ref __binding_0, ref __binding_1,
                        ref __binding_2) => {
                        { __binding_0.hash_stable(__hcx, __hasher); }
                        { __binding_1.hash_stable(__hcx, __hasher); }
                        { __binding_2.hash_stable(__hcx, __hasher); }
                    }
                    PatKind::Err(ref __binding_0) => {
                        { __binding_0.hash_stable(__hcx, __hasher); }
                    }
                }
            }
        }
    };HashStable_Generic)]
2000pub enum PatKind<'hir> {
2001    /// A missing pattern, e.g. for an anonymous param in a bare fn like `fn f(u32)`.
2002    Missing,
2003
2004    /// Represents a wildcard pattern (i.e., `_`).
2005    Wild,
2006
2007    /// A fresh binding `ref mut binding @ OPT_SUBPATTERN`.
2008    /// The `HirId` is the canonical ID for the variable being bound,
2009    /// (e.g., in `Ok(x) | Err(x)`, both `x` use the same canonical ID),
2010    /// which is the pattern ID of the first `x`.
2011    ///
2012    /// The `BindingMode` is what's provided by the user, before match
2013    /// ergonomics are applied. For the binding mode actually in use,
2014    /// see [`TypeckResults::extract_binding_mode`].
2015    ///
2016    /// [`TypeckResults::extract_binding_mode`]: ../../rustc_middle/ty/struct.TypeckResults.html#method.extract_binding_mode
2017    Binding(BindingMode, HirId, Ident, Option<&'hir Pat<'hir>>),
2018
2019    /// A struct or struct variant pattern (e.g., `Variant {x, y, ..}`).
2020    /// The `Option` contains the span of a possible `..`.
2021    Struct(QPath<'hir>, &'hir [PatField<'hir>], Option<Span>),
2022
2023    /// A tuple struct/variant pattern `Variant(x, y, .., z)`.
2024    /// If the `..` pattern fragment is present, then `DotDotPos` denotes its position.
2025    /// `0 <= position <= subpats.len()`
2026    TupleStruct(QPath<'hir>, &'hir [Pat<'hir>], DotDotPos),
2027
2028    /// An or-pattern `A | B | C`.
2029    /// Invariant: `pats.len() >= 2`.
2030    Or(&'hir [Pat<'hir>]),
2031
2032    /// A never pattern `!`.
2033    Never,
2034
2035    /// A tuple pattern (e.g., `(a, b)`).
2036    /// If the `..` pattern fragment is present, then `DotDotPos` denotes its position.
2037    /// `0 <= position <= subpats.len()`
2038    Tuple(&'hir [Pat<'hir>], DotDotPos),
2039
2040    /// A `box` pattern.
2041    Box(&'hir Pat<'hir>),
2042
2043    /// A `deref` pattern (currently `deref!()` macro-based syntax).
2044    Deref(&'hir Pat<'hir>),
2045
2046    /// A reference pattern (e.g., `&mut (a, b)`).
2047    Ref(&'hir Pat<'hir>, Pinnedness, Mutability),
2048
2049    /// A literal, const block or path.
2050    Expr(&'hir PatExpr<'hir>),
2051
2052    /// A guard pattern (e.g., `x if guard(x)`).
2053    Guard(&'hir Pat<'hir>, &'hir Expr<'hir>),
2054
2055    /// A range pattern (e.g., `1..=2` or `1..2`).
2056    Range(Option<&'hir PatExpr<'hir>>, Option<&'hir PatExpr<'hir>>, RangeEnd),
2057
2058    /// A slice pattern, `[before_0, ..., before_n, (slice, after_0, ..., after_n)?]`.
2059    ///
2060    /// Here, `slice` is lowered from the syntax `($binding_mode $ident @)? ..`.
2061    /// If `slice` exists, then `after` can be non-empty.
2062    ///
2063    /// The representation for e.g., `[a, b, .., c, d]` is:
2064    /// ```ignore (illustrative)
2065    /// PatKind::Slice([Binding(a), Binding(b)], Some(Wild), [Binding(c), Binding(d)])
2066    /// ```
2067    Slice(&'hir [Pat<'hir>], Option<&'hir Pat<'hir>>, &'hir [Pat<'hir>]),
2068
2069    /// A placeholder for a pattern that wasn't well formed in some way.
2070    Err(ErrorGuaranteed),
2071}
2072
2073/// A statement.
2074#[derive(#[automatically_derived]
impl<'hir> ::core::fmt::Debug for Stmt<'hir> {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::debug_struct_field3_finish(f, "Stmt",
            "hir_id", &self.hir_id, "kind", &self.kind, "span", &&self.span)
    }
}Debug, #[automatically_derived]
impl<'hir> ::core::clone::Clone for Stmt<'hir> {
    #[inline]
    fn clone(&self) -> Stmt<'hir> {
        let _: ::core::clone::AssertParamIsClone<HirId>;
        let _: ::core::clone::AssertParamIsClone<StmtKind<'hir>>;
        let _: ::core::clone::AssertParamIsClone<Span>;
        *self
    }
}Clone, #[automatically_derived]
impl<'hir> ::core::marker::Copy for Stmt<'hir> { }Copy, const _: () =
    {
        impl<'hir, __CTX>
            ::rustc_data_structures::stable_hasher::HashStable<__CTX> for
            Stmt<'hir> where __CTX: crate::HashStableContext {
            #[inline]
            fn hash_stable(&self, __hcx: &mut __CTX,
                __hasher:
                    &mut ::rustc_data_structures::stable_hasher::StableHasher) {
                match *self {
                    Stmt {
                        hir_id: ref __binding_0,
                        kind: ref __binding_1,
                        span: ref __binding_2 } => {
                        {}
                        { __binding_1.hash_stable(__hcx, __hasher); }
                        { __binding_2.hash_stable(__hcx, __hasher); }
                    }
                }
            }
        }
    };HashStable_Generic)]
2075pub struct Stmt<'hir> {
2076    #[stable_hasher(ignore)]
2077    pub hir_id: HirId,
2078    pub kind: StmtKind<'hir>,
2079    pub span: Span,
2080}
2081
2082/// The contents of a statement.
2083#[derive(#[automatically_derived]
impl<'hir> ::core::fmt::Debug for StmtKind<'hir> {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        match self {
            StmtKind::Let(__self_0) =>
                ::core::fmt::Formatter::debug_tuple_field1_finish(f, "Let",
                    &__self_0),
            StmtKind::Item(__self_0) =>
                ::core::fmt::Formatter::debug_tuple_field1_finish(f, "Item",
                    &__self_0),
            StmtKind::Expr(__self_0) =>
                ::core::fmt::Formatter::debug_tuple_field1_finish(f, "Expr",
                    &__self_0),
            StmtKind::Semi(__self_0) =>
                ::core::fmt::Formatter::debug_tuple_field1_finish(f, "Semi",
                    &__self_0),
        }
    }
}Debug, #[automatically_derived]
impl<'hir> ::core::clone::Clone for StmtKind<'hir> {
    #[inline]
    fn clone(&self) -> StmtKind<'hir> {
        let _: ::core::clone::AssertParamIsClone<&'hir LetStmt<'hir>>;
        let _: ::core::clone::AssertParamIsClone<ItemId>;
        let _: ::core::clone::AssertParamIsClone<&'hir Expr<'hir>>;
        let _: ::core::clone::AssertParamIsClone<&'hir Expr<'hir>>;
        *self
    }
}Clone, #[automatically_derived]
impl<'hir> ::core::marker::Copy for StmtKind<'hir> { }Copy, const _: () =
    {
        impl<'hir, __CTX>
            ::rustc_data_structures::stable_hasher::HashStable<__CTX> for
            StmtKind<'hir> where __CTX: crate::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 {
                    StmtKind::Let(ref __binding_0) => {
                        { __binding_0.hash_stable(__hcx, __hasher); }
                    }
                    StmtKind::Item(ref __binding_0) => {
                        { __binding_0.hash_stable(__hcx, __hasher); }
                    }
                    StmtKind::Expr(ref __binding_0) => {
                        { __binding_0.hash_stable(__hcx, __hasher); }
                    }
                    StmtKind::Semi(ref __binding_0) => {
                        { __binding_0.hash_stable(__hcx, __hasher); }
                    }
                }
            }
        }
    };HashStable_Generic)]
2084pub enum StmtKind<'hir> {
2085    /// A local (`let`) binding.
2086    Let(&'hir LetStmt<'hir>),
2087
2088    /// An item binding.
2089    Item(ItemId),
2090
2091    /// An expression without a trailing semi-colon (must have unit type).
2092    Expr(&'hir Expr<'hir>),
2093
2094    /// An expression with a trailing semi-colon (may have any type).
2095    Semi(&'hir Expr<'hir>),
2096}
2097
2098/// Represents a `let` statement (i.e., `let <pat>:<ty> = <init>;`).
2099#[derive(#[automatically_derived]
impl<'hir> ::core::fmt::Debug for LetStmt<'hir> {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        let names: &'static _ =
            &["super_", "pat", "ty", "init", "els", "hir_id", "span",
                        "source"];
        let values: &[&dyn ::core::fmt::Debug] =
            &[&self.super_, &self.pat, &self.ty, &self.init, &self.els,
                        &self.hir_id, &self.span, &&self.source];
        ::core::fmt::Formatter::debug_struct_fields_finish(f, "LetStmt",
            names, values)
    }
}Debug, #[automatically_derived]
impl<'hir> ::core::clone::Clone for LetStmt<'hir> {
    #[inline]
    fn clone(&self) -> LetStmt<'hir> {
        let _: ::core::clone::AssertParamIsClone<Option<Span>>;
        let _: ::core::clone::AssertParamIsClone<&'hir Pat<'hir>>;
        let _: ::core::clone::AssertParamIsClone<Option<&'hir Ty<'hir>>>;
        let _: ::core::clone::AssertParamIsClone<Option<&'hir Expr<'hir>>>;
        let _: ::core::clone::AssertParamIsClone<Option<&'hir Block<'hir>>>;
        let _: ::core::clone::AssertParamIsClone<HirId>;
        let _: ::core::clone::AssertParamIsClone<Span>;
        let _: ::core::clone::AssertParamIsClone<LocalSource>;
        *self
    }
}Clone, #[automatically_derived]
impl<'hir> ::core::marker::Copy for LetStmt<'hir> { }Copy, const _: () =
    {
        impl<'hir, __CTX>
            ::rustc_data_structures::stable_hasher::HashStable<__CTX> for
            LetStmt<'hir> where __CTX: crate::HashStableContext {
            #[inline]
            fn hash_stable(&self, __hcx: &mut __CTX,
                __hasher:
                    &mut ::rustc_data_structures::stable_hasher::StableHasher) {
                match *self {
                    LetStmt {
                        super_: ref __binding_0,
                        pat: ref __binding_1,
                        ty: ref __binding_2,
                        init: ref __binding_3,
                        els: ref __binding_4,
                        hir_id: ref __binding_5,
                        span: ref __binding_6,
                        source: ref __binding_7 } => {
                        { __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); }
                        {}
                        { __binding_6.hash_stable(__hcx, __hasher); }
                        { __binding_7.hash_stable(__hcx, __hasher); }
                    }
                }
            }
        }
    };HashStable_Generic)]
2100pub struct LetStmt<'hir> {
2101    /// Span of `super` in `super let`.
2102    pub super_: Option<Span>,
2103    pub pat: &'hir Pat<'hir>,
2104    /// Type annotation, if any (otherwise the type will be inferred).
2105    pub ty: Option<&'hir Ty<'hir>>,
2106    /// Initializer expression to set the value, if any.
2107    pub init: Option<&'hir Expr<'hir>>,
2108    /// Else block for a `let...else` binding.
2109    pub els: Option<&'hir Block<'hir>>,
2110    #[stable_hasher(ignore)]
2111    pub hir_id: HirId,
2112    pub span: Span,
2113    /// Can be `ForLoopDesugar` if the `let` statement is part of a `for` loop
2114    /// desugaring, or `AssignDesugar` if it is the result of a complex
2115    /// assignment desugaring. Otherwise will be `Normal`.
2116    pub source: LocalSource,
2117}
2118
2119/// Represents a single arm of a `match` expression, e.g.
2120/// `<pat> (if <guard>) => <body>`.
2121#[derive(#[automatically_derived]
impl<'hir> ::core::fmt::Debug for Arm<'hir> {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::debug_struct_field5_finish(f, "Arm", "hir_id",
            &self.hir_id, "span", &self.span, "pat", &self.pat, "guard",
            &self.guard, "body", &&self.body)
    }
}Debug, #[automatically_derived]
impl<'hir> ::core::clone::Clone for Arm<'hir> {
    #[inline]
    fn clone(&self) -> Arm<'hir> {
        let _: ::core::clone::AssertParamIsClone<HirId>;
        let _: ::core::clone::AssertParamIsClone<Span>;
        let _: ::core::clone::AssertParamIsClone<&'hir Pat<'hir>>;
        let _: ::core::clone::AssertParamIsClone<Option<&'hir Expr<'hir>>>;
        let _: ::core::clone::AssertParamIsClone<&'hir Expr<'hir>>;
        *self
    }
}Clone, #[automatically_derived]
impl<'hir> ::core::marker::Copy for Arm<'hir> { }Copy, const _: () =
    {
        impl<'hir, __CTX>
            ::rustc_data_structures::stable_hasher::HashStable<__CTX> for
            Arm<'hir> where __CTX: crate::HashStableContext {
            #[inline]
            fn hash_stable(&self, __hcx: &mut __CTX,
                __hasher:
                    &mut ::rustc_data_structures::stable_hasher::StableHasher) {
                match *self {
                    Arm {
                        hir_id: ref __binding_0,
                        span: ref __binding_1,
                        pat: ref __binding_2,
                        guard: ref __binding_3,
                        body: ref __binding_4 } => {
                        {}
                        { __binding_1.hash_stable(__hcx, __hasher); }
                        { __binding_2.hash_stable(__hcx, __hasher); }
                        { __binding_3.hash_stable(__hcx, __hasher); }
                        { __binding_4.hash_stable(__hcx, __hasher); }
                    }
                }
            }
        }
    };HashStable_Generic)]
2122pub struct Arm<'hir> {
2123    #[stable_hasher(ignore)]
2124    pub hir_id: HirId,
2125    pub span: Span,
2126    /// If this pattern and the optional guard matches, then `body` is evaluated.
2127    pub pat: &'hir Pat<'hir>,
2128    /// Optional guard clause.
2129    pub guard: Option<&'hir Expr<'hir>>,
2130    /// The expression the arm evaluates to if this arm matches.
2131    pub body: &'hir Expr<'hir>,
2132}
2133
2134/// Represents a `let <pat>[: <ty>] = <expr>` expression (not a [`LetStmt`]), occurring in an `if-let`
2135/// or `let-else`, evaluating to a boolean. Typically the pattern is refutable.
2136///
2137/// In an `if let`, imagine it as `if (let <pat> = <expr>) { ... }`; in a let-else, it is part of
2138/// the desugaring to if-let. Only let-else supports the type annotation at present.
2139#[derive(#[automatically_derived]
impl<'hir> ::core::fmt::Debug for LetExpr<'hir> {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::debug_struct_field5_finish(f, "LetExpr",
            "span", &self.span, "pat", &self.pat, "ty", &self.ty, "init",
            &self.init, "recovered", &&self.recovered)
    }
}Debug, #[automatically_derived]
impl<'hir> ::core::clone::Clone for LetExpr<'hir> {
    #[inline]
    fn clone(&self) -> LetExpr<'hir> {
        let _: ::core::clone::AssertParamIsClone<Span>;
        let _: ::core::clone::AssertParamIsClone<&'hir Pat<'hir>>;
        let _: ::core::clone::AssertParamIsClone<Option<&'hir Ty<'hir>>>;
        let _: ::core::clone::AssertParamIsClone<&'hir Expr<'hir>>;
        let _: ::core::clone::AssertParamIsClone<ast::Recovered>;
        *self
    }
}Clone, #[automatically_derived]
impl<'hir> ::core::marker::Copy for LetExpr<'hir> { }Copy, const _: () =
    {
        impl<'hir, __CTX>
            ::rustc_data_structures::stable_hasher::HashStable<__CTX> for
            LetExpr<'hir> where __CTX: crate::HashStableContext {
            #[inline]
            fn hash_stable(&self, __hcx: &mut __CTX,
                __hasher:
                    &mut ::rustc_data_structures::stable_hasher::StableHasher) {
                match *self {
                    LetExpr {
                        span: ref __binding_0,
                        pat: ref __binding_1,
                        ty: ref __binding_2,
                        init: ref __binding_3,
                        recovered: 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); }
                    }
                }
            }
        }
    };HashStable_Generic)]
2140pub struct LetExpr<'hir> {
2141    pub span: Span,
2142    pub pat: &'hir Pat<'hir>,
2143    pub ty: Option<&'hir Ty<'hir>>,
2144    pub init: &'hir Expr<'hir>,
2145    /// `Recovered::Yes` when this let expressions is not in a syntactically valid location.
2146    /// Used to prevent building MIR in such situations.
2147    pub recovered: ast::Recovered,
2148}
2149
2150#[derive(#[automatically_derived]
impl<'hir> ::core::fmt::Debug for ExprField<'hir> {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::debug_struct_field5_finish(f, "ExprField",
            "hir_id", &self.hir_id, "ident", &self.ident, "expr", &self.expr,
            "span", &self.span, "is_shorthand", &&self.is_shorthand)
    }
}Debug, #[automatically_derived]
impl<'hir> ::core::clone::Clone for ExprField<'hir> {
    #[inline]
    fn clone(&self) -> ExprField<'hir> {
        let _: ::core::clone::AssertParamIsClone<HirId>;
        let _: ::core::clone::AssertParamIsClone<Ident>;
        let _: ::core::clone::AssertParamIsClone<&'hir Expr<'hir>>;
        let _: ::core::clone::AssertParamIsClone<Span>;
        let _: ::core::clone::AssertParamIsClone<bool>;
        *self
    }
}Clone, #[automatically_derived]
impl<'hir> ::core::marker::Copy for ExprField<'hir> { }Copy, const _: () =
    {
        impl<'hir, __CTX>
            ::rustc_data_structures::stable_hasher::HashStable<__CTX> for
            ExprField<'hir> where __CTX: crate::HashStableContext {
            #[inline]
            fn hash_stable(&self, __hcx: &mut __CTX,
                __hasher:
                    &mut ::rustc_data_structures::stable_hasher::StableHasher) {
                match *self {
                    ExprField {
                        hir_id: ref __binding_0,
                        ident: ref __binding_1,
                        expr: ref __binding_2,
                        span: ref __binding_3,
                        is_shorthand: ref __binding_4 } => {
                        {}
                        { __binding_1.hash_stable(__hcx, __hasher); }
                        { __binding_2.hash_stable(__hcx, __hasher); }
                        { __binding_3.hash_stable(__hcx, __hasher); }
                        { __binding_4.hash_stable(__hcx, __hasher); }
                    }
                }
            }
        }
    };HashStable_Generic)]
2151pub struct ExprField<'hir> {
2152    #[stable_hasher(ignore)]
2153    pub hir_id: HirId,
2154    pub ident: Ident,
2155    pub expr: &'hir Expr<'hir>,
2156    pub span: Span,
2157    pub is_shorthand: bool,
2158}
2159
2160#[derive(#[automatically_derived]
impl ::core::marker::Copy for BlockCheckMode { }Copy, #[automatically_derived]
impl ::core::clone::Clone for BlockCheckMode {
    #[inline]
    fn clone(&self) -> BlockCheckMode {
        let _: ::core::clone::AssertParamIsClone<UnsafeSource>;
        *self
    }
}Clone, #[automatically_derived]
impl ::core::cmp::PartialEq for BlockCheckMode {
    #[inline]
    fn eq(&self, other: &BlockCheckMode) -> bool {
        let __self_discr = ::core::intrinsics::discriminant_value(self);
        let __arg1_discr = ::core::intrinsics::discriminant_value(other);
        __self_discr == __arg1_discr &&
            match (self, other) {
                (BlockCheckMode::UnsafeBlock(__self_0),
                    BlockCheckMode::UnsafeBlock(__arg1_0)) =>
                    __self_0 == __arg1_0,
                _ => true,
            }
    }
}PartialEq, #[automatically_derived]
impl ::core::fmt::Debug for BlockCheckMode {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        match self {
            BlockCheckMode::DefaultBlock =>
                ::core::fmt::Formatter::write_str(f, "DefaultBlock"),
            BlockCheckMode::UnsafeBlock(__self_0) =>
                ::core::fmt::Formatter::debug_tuple_field1_finish(f,
                    "UnsafeBlock", &__self_0),
        }
    }
}Debug, const _: () =
    {
        impl<__CTX> ::rustc_data_structures::stable_hasher::HashStable<__CTX>
            for BlockCheckMode where __CTX: crate::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 {
                    BlockCheckMode::DefaultBlock => {}
                    BlockCheckMode::UnsafeBlock(ref __binding_0) => {
                        { __binding_0.hash_stable(__hcx, __hasher); }
                    }
                }
            }
        }
    };HashStable_Generic)]
2161pub enum BlockCheckMode {
2162    DefaultBlock,
2163    UnsafeBlock(UnsafeSource),
2164}
2165
2166#[derive(#[automatically_derived]
impl ::core::marker::Copy for UnsafeSource { }Copy, #[automatically_derived]
impl ::core::clone::Clone for UnsafeSource {
    #[inline]
    fn clone(&self) -> UnsafeSource { *self }
}Clone, #[automatically_derived]
impl ::core::cmp::PartialEq for UnsafeSource {
    #[inline]
    fn eq(&self, other: &UnsafeSource) -> 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::fmt::Debug for UnsafeSource {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::write_str(f,
            match self {
                UnsafeSource::CompilerGenerated => "CompilerGenerated",
                UnsafeSource::UserProvided => "UserProvided",
            })
    }
}Debug, const _: () =
    {
        impl<__CTX> ::rustc_data_structures::stable_hasher::HashStable<__CTX>
            for UnsafeSource where __CTX: crate::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 {
                    UnsafeSource::CompilerGenerated => {}
                    UnsafeSource::UserProvided => {}
                }
            }
        }
    };HashStable_Generic)]
2167pub enum UnsafeSource {
2168    CompilerGenerated,
2169    UserProvided,
2170}
2171
2172#[derive(#[automatically_derived]
impl ::core::marker::Copy for BodyId { }Copy, #[automatically_derived]
impl ::core::clone::Clone for BodyId {
    #[inline]
    fn clone(&self) -> BodyId {
        let _: ::core::clone::AssertParamIsClone<HirId>;
        *self
    }
}Clone, #[automatically_derived]
impl ::core::cmp::PartialEq for BodyId {
    #[inline]
    fn eq(&self, other: &BodyId) -> bool { self.hir_id == other.hir_id }
}PartialEq, #[automatically_derived]
impl ::core::cmp::Eq for BodyId {
    #[inline]
    #[doc(hidden)]
    #[coverage(off)]
    fn assert_fields_are_eq(&self) {
        let _: ::core::cmp::AssertParamIsEq<HirId>;
    }
}Eq, #[automatically_derived]
impl ::core::hash::Hash for BodyId {
    #[inline]
    fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) {
        ::core::hash::Hash::hash(&self.hir_id, state)
    }
}Hash, #[automatically_derived]
impl ::core::fmt::Debug for BodyId {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::debug_struct_field1_finish(f, "BodyId",
            "hir_id", &&self.hir_id)
    }
}Debug, const _: () =
    {
        impl<__CTX> ::rustc_data_structures::stable_hasher::HashStable<__CTX>
            for BodyId where __CTX: crate::HashStableContext {
            #[inline]
            fn hash_stable(&self, __hcx: &mut __CTX,
                __hasher:
                    &mut ::rustc_data_structures::stable_hasher::StableHasher) {
                match *self {
                    BodyId { hir_id: ref __binding_0 } => {
                        { __binding_0.hash_stable(__hcx, __hasher); }
                    }
                }
            }
        }
    };HashStable_Generic)]
2173pub struct BodyId {
2174    pub hir_id: HirId,
2175}
2176
2177/// The body of a function, closure, or constant value. In the case of
2178/// a function, the body contains not only the function body itself
2179/// (which is an expression), but also the argument patterns, since
2180/// those are something that the caller doesn't really care about.
2181///
2182/// # Examples
2183///
2184/// ```
2185/// fn foo((x, y): (u32, u32)) -> u32 {
2186///     x + y
2187/// }
2188/// ```
2189///
2190/// Here, the `Body` associated with `foo()` would contain:
2191///
2192/// - an `params` array containing the `(x, y)` pattern
2193/// - a `value` containing the `x + y` expression (maybe wrapped in a block)
2194/// - `coroutine_kind` would be `None`
2195///
2196/// All bodies have an **owner**, which can be accessed via the HIR
2197/// map using `body_owner_def_id()`.
2198#[derive(#[automatically_derived]
impl<'hir> ::core::fmt::Debug for Body<'hir> {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::debug_struct_field2_finish(f, "Body",
            "params", &self.params, "value", &&self.value)
    }
}Debug, #[automatically_derived]
impl<'hir> ::core::clone::Clone for Body<'hir> {
    #[inline]
    fn clone(&self) -> Body<'hir> {
        let _: ::core::clone::AssertParamIsClone<&'hir [Param<'hir>]>;
        let _: ::core::clone::AssertParamIsClone<&'hir Expr<'hir>>;
        *self
    }
}Clone, #[automatically_derived]
impl<'hir> ::core::marker::Copy for Body<'hir> { }Copy, const _: () =
    {
        impl<'hir, __CTX>
            ::rustc_data_structures::stable_hasher::HashStable<__CTX> for
            Body<'hir> where __CTX: crate::HashStableContext {
            #[inline]
            fn hash_stable(&self, __hcx: &mut __CTX,
                __hasher:
                    &mut ::rustc_data_structures::stable_hasher::StableHasher) {
                match *self {
                    Body { params: ref __binding_0, value: ref __binding_1 } =>
                        {
                        { __binding_0.hash_stable(__hcx, __hasher); }
                        { __binding_1.hash_stable(__hcx, __hasher); }
                    }
                }
            }
        }
    };HashStable_Generic)]
2199pub struct Body<'hir> {
2200    pub params: &'hir [Param<'hir>],
2201    pub value: &'hir Expr<'hir>,
2202}
2203
2204impl<'hir> Body<'hir> {
2205    pub fn id(&self) -> BodyId {
2206        BodyId { hir_id: self.value.hir_id }
2207    }
2208}
2209
2210/// The type of source expression that caused this coroutine to be created.
2211#[derive(#[automatically_derived]
impl ::core::clone::Clone for CoroutineKind {
    #[inline]
    fn clone(&self) -> CoroutineKind {
        let _: ::core::clone::AssertParamIsClone<CoroutineDesugaring>;
        let _: ::core::clone::AssertParamIsClone<CoroutineSource>;
        let _: ::core::clone::AssertParamIsClone<Movability>;
        *self
    }
}Clone, #[automatically_derived]
impl ::core::cmp::PartialEq for CoroutineKind {
    #[inline]
    fn eq(&self, other: &CoroutineKind) -> bool {
        let __self_discr = ::core::intrinsics::discriminant_value(self);
        let __arg1_discr = ::core::intrinsics::discriminant_value(other);
        __self_discr == __arg1_discr &&
            match (self, other) {
                (CoroutineKind::Desugared(__self_0, __self_1),
                    CoroutineKind::Desugared(__arg1_0, __arg1_1)) =>
                    __self_0 == __arg1_0 && __self_1 == __arg1_1,
                (CoroutineKind::Coroutine(__self_0),
                    CoroutineKind::Coroutine(__arg1_0)) => __self_0 == __arg1_0,
                _ => unsafe { ::core::intrinsics::unreachable() }
            }
    }
}PartialEq, #[automatically_derived]
impl ::core::cmp::Eq for CoroutineKind {
    #[inline]
    #[doc(hidden)]
    #[coverage(off)]
    fn assert_fields_are_eq(&self) {
        let _: ::core::cmp::AssertParamIsEq<CoroutineDesugaring>;
        let _: ::core::cmp::AssertParamIsEq<CoroutineSource>;
        let _: ::core::cmp::AssertParamIsEq<Movability>;
    }
}Eq, #[automatically_derived]
impl ::core::fmt::Debug for CoroutineKind {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        match self {
            CoroutineKind::Desugared(__self_0, __self_1) =>
                ::core::fmt::Formatter::debug_tuple_field2_finish(f,
                    "Desugared", __self_0, &__self_1),
            CoroutineKind::Coroutine(__self_0) =>
                ::core::fmt::Formatter::debug_tuple_field1_finish(f,
                    "Coroutine", &__self_0),
        }
    }
}Debug, #[automatically_derived]
impl ::core::marker::Copy for CoroutineKind { }Copy, #[automatically_derived]
impl ::core::hash::Hash for CoroutineKind {
    #[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 {
            CoroutineKind::Desugared(__self_0, __self_1) => {
                ::core::hash::Hash::hash(__self_0, state);
                ::core::hash::Hash::hash(__self_1, state)
            }
            CoroutineKind::Coroutine(__self_0) =>
                ::core::hash::Hash::hash(__self_0, state),
        }
    }
}Hash, const _: () =
    {
        impl<__CTX> ::rustc_data_structures::stable_hasher::HashStable<__CTX>
            for CoroutineKind where __CTX: crate::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 {
                    CoroutineKind::Desugared(ref __binding_0, ref __binding_1)
                        => {
                        { __binding_0.hash_stable(__hcx, __hasher); }
                        { __binding_1.hash_stable(__hcx, __hasher); }
                    }
                    CoroutineKind::Coroutine(ref __binding_0) => {
                        { __binding_0.hash_stable(__hcx, __hasher); }
                    }
                }
            }
        }
    };HashStable_Generic, const _: () =
    {
        impl<__E: ::rustc_span::SpanEncoder> ::rustc_serialize::Encodable<__E>
            for CoroutineKind {
            fn encode(&self, __encoder: &mut __E) {
                let disc =
                    match *self {
                        CoroutineKind::Desugared(ref __binding_0, ref __binding_1)
                            => {
                            0usize
                        }
                        CoroutineKind::Coroutine(ref __binding_0) => { 1usize }
                    };
                ::rustc_serialize::Encoder::emit_u8(__encoder, disc as u8);
                match *self {
                    CoroutineKind::Desugared(ref __binding_0, ref __binding_1)
                        => {
                        ::rustc_serialize::Encodable::<__E>::encode(__binding_0,
                            __encoder);
                        ::rustc_serialize::Encodable::<__E>::encode(__binding_1,
                            __encoder);
                    }
                    CoroutineKind::Coroutine(ref __binding_0) => {
                        ::rustc_serialize::Encodable::<__E>::encode(__binding_0,
                            __encoder);
                    }
                }
            }
        }
    };Encodable, const _: () =
    {
        impl<__D: ::rustc_span::SpanDecoder> ::rustc_serialize::Decodable<__D>
            for CoroutineKind {
            fn decode(__decoder: &mut __D) -> Self {
                match ::rustc_serialize::Decoder::read_u8(__decoder) as usize
                    {
                    0usize => {
                        CoroutineKind::Desugared(::rustc_serialize::Decodable::decode(__decoder),
                            ::rustc_serialize::Decodable::decode(__decoder))
                    }
                    1usize => {
                        CoroutineKind::Coroutine(::rustc_serialize::Decodable::decode(__decoder))
                    }
                    n => {
                        ::core::panicking::panic_fmt(format_args!("invalid enum variant tag while decoding `CoroutineKind`, expected 0..2, actual {0}",
                                n));
                    }
                }
            }
        }
    };Decodable)]
2212pub enum CoroutineKind {
2213    /// A coroutine that comes from a desugaring.
2214    Desugared(CoroutineDesugaring, CoroutineSource),
2215
2216    /// A coroutine literal created via a `yield` inside a closure.
2217    Coroutine(Movability),
2218}
2219
2220impl CoroutineKind {
2221    pub fn movability(self) -> Movability {
2222        match self {
2223            CoroutineKind::Desugared(CoroutineDesugaring::Async, _)
2224            | CoroutineKind::Desugared(CoroutineDesugaring::AsyncGen, _) => Movability::Static,
2225            CoroutineKind::Desugared(CoroutineDesugaring::Gen, _) => Movability::Movable,
2226            CoroutineKind::Coroutine(mov) => mov,
2227        }
2228    }
2229
2230    pub fn is_fn_like(self) -> bool {
2231        #[allow(non_exhaustive_omitted_patterns)] match self {
    CoroutineKind::Desugared(_, CoroutineSource::Fn) => true,
    _ => false,
}matches!(self, CoroutineKind::Desugared(_, CoroutineSource::Fn))
2232    }
2233
2234    pub fn to_plural_string(&self) -> String {
2235        match self {
2236            CoroutineKind::Desugared(d, CoroutineSource::Fn) => ::alloc::__export::must_use({
        ::alloc::fmt::format(format_args!("{0:#}fn bodies", d))
    })format!("{d:#}fn bodies"),
2237            CoroutineKind::Desugared(d, CoroutineSource::Block) => ::alloc::__export::must_use({
        ::alloc::fmt::format(format_args!("{0:#}blocks", d))
    })format!("{d:#}blocks"),
2238            CoroutineKind::Desugared(d, CoroutineSource::Closure) => ::alloc::__export::must_use({
        ::alloc::fmt::format(format_args!("{0:#}closure bodies", d))
    })format!("{d:#}closure bodies"),
2239            CoroutineKind::Coroutine(_) => "coroutines".to_string(),
2240        }
2241    }
2242}
2243
2244impl fmt::Display for CoroutineKind {
2245    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
2246        match self {
2247            CoroutineKind::Desugared(d, k) => {
2248                d.fmt(f)?;
2249                k.fmt(f)
2250            }
2251            CoroutineKind::Coroutine(_) => f.write_str("coroutine"),
2252        }
2253    }
2254}
2255
2256/// In the case of a coroutine created as part of an async/gen construct,
2257/// which kind of async/gen construct caused it to be created?
2258///
2259/// This helps error messages but is also used to drive coercions in
2260/// type-checking (see #60424).
2261#[derive(#[automatically_derived]
impl ::core::clone::Clone for CoroutineSource {
    #[inline]
    fn clone(&self) -> CoroutineSource { *self }
}Clone, #[automatically_derived]
impl ::core::cmp::PartialEq for CoroutineSource {
    #[inline]
    fn eq(&self, other: &CoroutineSource) -> 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 CoroutineSource {
    #[inline]
    #[doc(hidden)]
    #[coverage(off)]
    fn assert_fields_are_eq(&self) {}
}Eq, #[automatically_derived]
impl ::core::hash::Hash for CoroutineSource {
    #[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, #[automatically_derived]
impl ::core::fmt::Debug for CoroutineSource {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::write_str(f,
            match self {
                CoroutineSource::Block => "Block",
                CoroutineSource::Closure => "Closure",
                CoroutineSource::Fn => "Fn",
            })
    }
}Debug, #[automatically_derived]
impl ::core::marker::Copy for CoroutineSource { }Copy, const _: () =
    {
        impl<__CTX> ::rustc_data_structures::stable_hasher::HashStable<__CTX>
            for CoroutineSource where __CTX: crate::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 {
                    CoroutineSource::Block => {}
                    CoroutineSource::Closure => {}
                    CoroutineSource::Fn => {}
                }
            }
        }
    };HashStable_Generic, const _: () =
    {
        impl<__E: ::rustc_span::SpanEncoder> ::rustc_serialize::Encodable<__E>
            for CoroutineSource {
            fn encode(&self, __encoder: &mut __E) {
                let disc =
                    match *self {
                        CoroutineSource::Block => { 0usize }
                        CoroutineSource::Closure => { 1usize }
                        CoroutineSource::Fn => { 2usize }
                    };
                ::rustc_serialize::Encoder::emit_u8(__encoder, disc as u8);
                match *self {
                    CoroutineSource::Block => {}
                    CoroutineSource::Closure => {}
                    CoroutineSource::Fn => {}
                }
            }
        }
    };Encodable, const _: () =
    {
        impl<__D: ::rustc_span::SpanDecoder> ::rustc_serialize::Decodable<__D>
            for CoroutineSource {
            fn decode(__decoder: &mut __D) -> Self {
                match ::rustc_serialize::Decoder::read_u8(__decoder) as usize
                    {
                    0usize => { CoroutineSource::Block }
                    1usize => { CoroutineSource::Closure }
                    2usize => { CoroutineSource::Fn }
                    n => {
                        ::core::panicking::panic_fmt(format_args!("invalid enum variant tag while decoding `CoroutineSource`, expected 0..3, actual {0}",
                                n));
                    }
                }
            }
        }
    };Decodable)]
2262pub enum CoroutineSource {
2263    /// An explicit `async`/`gen` block written by the user.
2264    Block,
2265
2266    /// An explicit `async`/`gen` closure written by the user.
2267    Closure,
2268
2269    /// The `async`/`gen` block generated as the body of an async/gen function.
2270    Fn,
2271}
2272
2273impl fmt::Display for CoroutineSource {
2274    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
2275        match self {
2276            CoroutineSource::Block => "block",
2277            CoroutineSource::Closure => "closure body",
2278            CoroutineSource::Fn => "fn body",
2279        }
2280        .fmt(f)
2281    }
2282}
2283
2284#[derive(#[automatically_derived]
impl ::core::clone::Clone for CoroutineDesugaring {
    #[inline]
    fn clone(&self) -> CoroutineDesugaring { *self }
}Clone, #[automatically_derived]
impl ::core::cmp::PartialEq for CoroutineDesugaring {
    #[inline]
    fn eq(&self, other: &CoroutineDesugaring) -> 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 CoroutineDesugaring {
    #[inline]
    #[doc(hidden)]
    #[coverage(off)]
    fn assert_fields_are_eq(&self) {}
}Eq, #[automatically_derived]
impl ::core::fmt::Debug for CoroutineDesugaring {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::write_str(f,
            match self {
                CoroutineDesugaring::Async => "Async",
                CoroutineDesugaring::Gen => "Gen",
                CoroutineDesugaring::AsyncGen => "AsyncGen",
            })
    }
}Debug, #[automatically_derived]
impl ::core::marker::Copy for CoroutineDesugaring { }Copy, #[automatically_derived]
impl ::core::hash::Hash for CoroutineDesugaring {
    #[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<__CTX> ::rustc_data_structures::stable_hasher::HashStable<__CTX>
            for CoroutineDesugaring where __CTX: crate::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 {
                    CoroutineDesugaring::Async => {}
                    CoroutineDesugaring::Gen => {}
                    CoroutineDesugaring::AsyncGen => {}
                }
            }
        }
    };HashStable_Generic, const _: () =
    {
        impl<__E: ::rustc_span::SpanEncoder> ::rustc_serialize::Encodable<__E>
            for CoroutineDesugaring {
            fn encode(&self, __encoder: &mut __E) {
                let disc =
                    match *self {
                        CoroutineDesugaring::Async => { 0usize }
                        CoroutineDesugaring::Gen => { 1usize }
                        CoroutineDesugaring::AsyncGen => { 2usize }
                    };
                ::rustc_serialize::Encoder::emit_u8(__encoder, disc as u8);
                match *self {
                    CoroutineDesugaring::Async => {}
                    CoroutineDesugaring::Gen => {}
                    CoroutineDesugaring::AsyncGen => {}
                }
            }
        }
    };Encodable, const _: () =
    {
        impl<__D: ::rustc_span::SpanDecoder> ::rustc_serialize::Decodable<__D>
            for CoroutineDesugaring {
            fn decode(__decoder: &mut __D) -> Self {
                match ::rustc_serialize::Decoder::read_u8(__decoder) as usize
                    {
                    0usize => { CoroutineDesugaring::Async }
                    1usize => { CoroutineDesugaring::Gen }
                    2usize => { CoroutineDesugaring::AsyncGen }
                    n => {
                        ::core::panicking::panic_fmt(format_args!("invalid enum variant tag while decoding `CoroutineDesugaring`, expected 0..3, actual {0}",
                                n));
                    }
                }
            }
        }
    };Decodable)]
2285pub enum CoroutineDesugaring {
2286    /// An explicit `async` block or the body of an `async` function.
2287    Async,
2288
2289    /// An explicit `gen` block or the body of a `gen` function.
2290    Gen,
2291
2292    /// An explicit `async gen` block or the body of an `async gen` function,
2293    /// which is able to both `yield` and `.await`.
2294    AsyncGen,
2295}
2296
2297impl fmt::Display for CoroutineDesugaring {
2298    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
2299        match self {
2300            CoroutineDesugaring::Async => {
2301                if f.alternate() {
2302                    f.write_str("`async` ")?;
2303                } else {
2304                    f.write_str("async ")?
2305                }
2306            }
2307            CoroutineDesugaring::Gen => {
2308                if f.alternate() {
2309                    f.write_str("`gen` ")?;
2310                } else {
2311                    f.write_str("gen ")?
2312                }
2313            }
2314            CoroutineDesugaring::AsyncGen => {
2315                if f.alternate() {
2316                    f.write_str("`async gen` ")?;
2317                } else {
2318                    f.write_str("async gen ")?
2319                }
2320            }
2321        }
2322
2323        Ok(())
2324    }
2325}
2326
2327#[derive(#[automatically_derived]
impl ::core::marker::Copy for BodyOwnerKind { }Copy, #[automatically_derived]
impl ::core::clone::Clone for BodyOwnerKind {
    #[inline]
    fn clone(&self) -> BodyOwnerKind {
        let _: ::core::clone::AssertParamIsClone<bool>;
        let _: ::core::clone::AssertParamIsClone<Mutability>;
        *self
    }
}Clone, #[automatically_derived]
impl ::core::fmt::Debug for BodyOwnerKind {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        match self {
            BodyOwnerKind::Fn => ::core::fmt::Formatter::write_str(f, "Fn"),
            BodyOwnerKind::Closure =>
                ::core::fmt::Formatter::write_str(f, "Closure"),
            BodyOwnerKind::Const { inline: __self_0 } =>
                ::core::fmt::Formatter::debug_struct_field1_finish(f, "Const",
                    "inline", &__self_0),
            BodyOwnerKind::Static(__self_0) =>
                ::core::fmt::Formatter::debug_tuple_field1_finish(f, "Static",
                    &__self_0),
            BodyOwnerKind::GlobalAsm =>
                ::core::fmt::Formatter::write_str(f, "GlobalAsm"),
        }
    }
}Debug)]
2328pub enum BodyOwnerKind {
2329    /// Functions and methods.
2330    Fn,
2331
2332    /// Closures
2333    Closure,
2334
2335    /// Constants and associated constants, also including inline constants.
2336    Const { inline: bool },
2337
2338    /// Initializer of a `static` item.
2339    Static(Mutability),
2340
2341    /// Fake body for a global asm to store its const-like value types.
2342    GlobalAsm,
2343}
2344
2345impl BodyOwnerKind {
2346    pub fn is_fn_or_closure(self) -> bool {
2347        match self {
2348            BodyOwnerKind::Fn | BodyOwnerKind::Closure => true,
2349            BodyOwnerKind::Const { .. } | BodyOwnerKind::Static(_) | BodyOwnerKind::GlobalAsm => {
2350                false
2351            }
2352        }
2353    }
2354}
2355
2356/// The kind of an item that requires const-checking.
2357#[derive(#[automatically_derived]
impl ::core::clone::Clone for ConstContext {
    #[inline]
    fn clone(&self) -> ConstContext {
        let _: ::core::clone::AssertParamIsClone<Mutability>;
        let _: ::core::clone::AssertParamIsClone<bool>;
        *self
    }
}Clone, #[automatically_derived]
impl ::core::marker::Copy for ConstContext { }Copy, #[automatically_derived]
impl ::core::fmt::Debug for ConstContext {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        match self {
            ConstContext::ConstFn =>
                ::core::fmt::Formatter::write_str(f, "ConstFn"),
            ConstContext::Static(__self_0) =>
                ::core::fmt::Formatter::debug_tuple_field1_finish(f, "Static",
                    &__self_0),
            ConstContext::Const { inline: __self_0 } =>
                ::core::fmt::Formatter::debug_struct_field1_finish(f, "Const",
                    "inline", &__self_0),
        }
    }
}Debug, #[automatically_derived]
impl ::core::cmp::PartialEq for ConstContext {
    #[inline]
    fn eq(&self, other: &ConstContext) -> bool {
        let __self_discr = ::core::intrinsics::discriminant_value(self);
        let __arg1_discr = ::core::intrinsics::discriminant_value(other);
        __self_discr == __arg1_discr &&
            match (self, other) {
                (ConstContext::Static(__self_0),
                    ConstContext::Static(__arg1_0)) => __self_0 == __arg1_0,
                (ConstContext::Const { inline: __self_0 },
                    ConstContext::Const { inline: __arg1_0 }) =>
                    __self_0 == __arg1_0,
                _ => true,
            }
    }
}PartialEq, #[automatically_derived]
impl ::core::cmp::Eq for ConstContext {
    #[inline]
    #[doc(hidden)]
    #[coverage(off)]
    fn assert_fields_are_eq(&self) {
        let _: ::core::cmp::AssertParamIsEq<Mutability>;
        let _: ::core::cmp::AssertParamIsEq<bool>;
    }
}Eq)]
2358pub enum ConstContext {
2359    /// A `const fn`.
2360    ConstFn,
2361
2362    /// A `static` or `static mut`.
2363    Static(Mutability),
2364
2365    /// A `const`, associated `const`, or other const context.
2366    ///
2367    /// Other contexts include:
2368    /// - Array length expressions
2369    /// - Enum discriminants
2370    /// - Const generics
2371    ///
2372    /// For the most part, other contexts are treated just like a regular `const`, so they are
2373    /// lumped into the same category.
2374    Const { inline: bool },
2375}
2376
2377impl ConstContext {
2378    /// A description of this const context that can appear between backticks in an error message.
2379    ///
2380    /// E.g. `const` or `static mut`.
2381    pub fn keyword_name(self) -> &'static str {
2382        match self {
2383            Self::Const { .. } => "const",
2384            Self::Static(Mutability::Not) => "static",
2385            Self::Static(Mutability::Mut) => "static mut",
2386            Self::ConstFn => "const fn",
2387        }
2388    }
2389}
2390
2391/// A colloquial, trivially pluralizable description of this const context for use in error
2392/// messages.
2393impl fmt::Display for ConstContext {
2394    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
2395        match *self {
2396            Self::Const { .. } => f.write_fmt(format_args!("constant"))write!(f, "constant"),
2397            Self::Static(_) => f.write_fmt(format_args!("static"))write!(f, "static"),
2398            Self::ConstFn => f.write_fmt(format_args!("constant function"))write!(f, "constant function"),
2399        }
2400    }
2401}
2402
2403impl IntoDiagArg for ConstContext {
2404    fn into_diag_arg(self, _: &mut Option<std::path::PathBuf>) -> DiagArgValue {
2405        DiagArgValue::Str(Cow::Borrowed(match self {
2406            ConstContext::ConstFn => "const_fn",
2407            ConstContext::Static(_) => "static",
2408            ConstContext::Const { .. } => "const",
2409        }))
2410    }
2411}
2412
2413/// A literal.
2414pub type Lit = Spanned<LitKind>;
2415
2416/// A constant (expression) that's not an item or associated item,
2417/// but needs its own `DefId` for type-checking, const-eval, etc.
2418/// These are usually found nested inside types (e.g., array lengths)
2419/// or expressions (e.g., repeat counts), and also used to define
2420/// explicit discriminant values for enum variants.
2421///
2422/// You can check if this anon const is a default in a const param
2423/// `const N: usize = { ... }` with `tcx.hir_opt_const_param_default_param_def_id(..)`
2424#[derive(#[automatically_derived]
impl ::core::marker::Copy for AnonConst { }Copy, #[automatically_derived]
impl ::core::clone::Clone for AnonConst {
    #[inline]
    fn clone(&self) -> AnonConst {
        let _: ::core::clone::AssertParamIsClone<HirId>;
        let _: ::core::clone::AssertParamIsClone<LocalDefId>;
        let _: ::core::clone::AssertParamIsClone<BodyId>;
        let _: ::core::clone::AssertParamIsClone<Span>;
        *self
    }
}Clone, #[automatically_derived]
impl ::core::fmt::Debug for AnonConst {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::debug_struct_field4_finish(f, "AnonConst",
            "hir_id", &self.hir_id, "def_id", &self.def_id, "body",
            &self.body, "span", &&self.span)
    }
}Debug, const _: () =
    {
        impl<__CTX> ::rustc_data_structures::stable_hasher::HashStable<__CTX>
            for AnonConst where __CTX: crate::HashStableContext {
            #[inline]
            fn hash_stable(&self, __hcx: &mut __CTX,
                __hasher:
                    &mut ::rustc_data_structures::stable_hasher::StableHasher) {
                match *self {
                    AnonConst {
                        hir_id: ref __binding_0,
                        def_id: ref __binding_1,
                        body: ref __binding_2,
                        span: ref __binding_3 } => {
                        {}
                        { __binding_1.hash_stable(__hcx, __hasher); }
                        { __binding_2.hash_stable(__hcx, __hasher); }
                        { __binding_3.hash_stable(__hcx, __hasher); }
                    }
                }
            }
        }
    };HashStable_Generic)]
2425pub struct AnonConst {
2426    #[stable_hasher(ignore)]
2427    pub hir_id: HirId,
2428    pub def_id: LocalDefId,
2429    pub body: BodyId,
2430    pub span: Span,
2431}
2432
2433/// An inline constant expression `const { something }`.
2434#[derive(#[automatically_derived]
impl ::core::marker::Copy for ConstBlock { }Copy, #[automatically_derived]
impl ::core::clone::Clone for ConstBlock {
    #[inline]
    fn clone(&self) -> ConstBlock {
        let _: ::core::clone::AssertParamIsClone<HirId>;
        let _: ::core::clone::AssertParamIsClone<LocalDefId>;
        let _: ::core::clone::AssertParamIsClone<BodyId>;
        *self
    }
}Clone, #[automatically_derived]
impl ::core::fmt::Debug for ConstBlock {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::debug_struct_field3_finish(f, "ConstBlock",
            "hir_id", &self.hir_id, "def_id", &self.def_id, "body",
            &&self.body)
    }
}Debug, const _: () =
    {
        impl<__CTX> ::rustc_data_structures::stable_hasher::HashStable<__CTX>
            for ConstBlock where __CTX: crate::HashStableContext {
            #[inline]
            fn hash_stable(&self, __hcx: &mut __CTX,
                __hasher:
                    &mut ::rustc_data_structures::stable_hasher::StableHasher) {
                match *self {
                    ConstBlock {
                        hir_id: ref __binding_0,
                        def_id: ref __binding_1,
                        body: ref __binding_2 } => {
                        {}
                        { __binding_1.hash_stable(__hcx, __hasher); }
                        { __binding_2.hash_stable(__hcx, __hasher); }
                    }
                }
            }
        }
    };HashStable_Generic)]
2435pub struct ConstBlock {
2436    #[stable_hasher(ignore)]
2437    pub hir_id: HirId,
2438    pub def_id: LocalDefId,
2439    pub body: BodyId,
2440}
2441
2442/// An expression.
2443///
2444/// For more details, see the [rust lang reference].
2445/// Note that the reference does not document nightly-only features.
2446/// There may be also slight differences in the names and representation of AST nodes between
2447/// the compiler and the reference.
2448///
2449/// [rust lang reference]: https://doc.rust-lang.org/reference/expressions.html
2450#[derive(#[automatically_derived]
impl<'hir> ::core::fmt::Debug for Expr<'hir> {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::debug_struct_field3_finish(f, "Expr",
            "hir_id", &self.hir_id, "kind", &self.kind, "span", &&self.span)
    }
}Debug, #[automatically_derived]
impl<'hir> ::core::clone::Clone for Expr<'hir> {
    #[inline]
    fn clone(&self) -> Expr<'hir> {
        let _: ::core::clone::AssertParamIsClone<HirId>;
        let _: ::core::clone::AssertParamIsClone<ExprKind<'hir>>;
        let _: ::core::clone::AssertParamIsClone<Span>;
        *self
    }
}Clone, #[automatically_derived]
impl<'hir> ::core::marker::Copy for Expr<'hir> { }Copy, const _: () =
    {
        impl<'hir, __CTX>
            ::rustc_data_structures::stable_hasher::HashStable<__CTX> for
            Expr<'hir> where __CTX: crate::HashStableContext {
            #[inline]
            fn hash_stable(&self, __hcx: &mut __CTX,
                __hasher:
                    &mut ::rustc_data_structures::stable_hasher::StableHasher) {
                match *self {
                    Expr {
                        hir_id: ref __binding_0,
                        kind: ref __binding_1,
                        span: ref __binding_2 } => {
                        {}
                        { __binding_1.hash_stable(__hcx, __hasher); }
                        { __binding_2.hash_stable(__hcx, __hasher); }
                    }
                }
            }
        }
    };HashStable_Generic)]
2451pub struct Expr<'hir> {
2452    #[stable_hasher(ignore)]
2453    pub hir_id: HirId,
2454    pub kind: ExprKind<'hir>,
2455    pub span: Span,
2456}
2457
2458impl Expr<'_> {
2459    pub fn precedence(&self, has_attr: &dyn Fn(HirId) -> bool) -> ExprPrecedence {
2460        let prefix_attrs_precedence = || -> ExprPrecedence {
2461            if has_attr(self.hir_id) { ExprPrecedence::Prefix } else { ExprPrecedence::Unambiguous }
2462        };
2463
2464        match &self.kind {
2465            ExprKind::Closure(closure) => {
2466                match closure.fn_decl.output {
2467                    FnRetTy::DefaultReturn(_) => ExprPrecedence::Jump,
2468                    FnRetTy::Return(_) => prefix_attrs_precedence(),
2469                }
2470            }
2471
2472            ExprKind::Break(..)
2473            | ExprKind::Ret(..)
2474            | ExprKind::Yield(..)
2475            | ExprKind::Become(..) => ExprPrecedence::Jump,
2476
2477            // Binop-like expr kinds, handled by `AssocOp`.
2478            ExprKind::Binary(op, ..) => op.node.precedence(),
2479            ExprKind::Cast(..) => ExprPrecedence::Cast,
2480
2481            ExprKind::Assign(..) |
2482            ExprKind::AssignOp(..) => ExprPrecedence::Assign,
2483
2484            // Unary, prefix
2485            ExprKind::AddrOf(..)
2486            // Here `let pats = expr` has `let pats =` as a "unary" prefix of `expr`.
2487            // However, this is not exactly right. When `let _ = a` is the LHS of a binop we
2488            // need parens sometimes. E.g. we can print `(let _ = a) && b` as `let _ = a && b`
2489            // but we need to print `(let _ = a) < b` as-is with parens.
2490            | ExprKind::Let(..)
2491            | ExprKind::Unary(..) => ExprPrecedence::Prefix,
2492
2493            // Need parens if and only if there are prefix attributes.
2494            ExprKind::Array(_)
2495            | ExprKind::Block(..)
2496            | ExprKind::Call(..)
2497            | ExprKind::ConstBlock(_)
2498            | ExprKind::Continue(..)
2499            | ExprKind::Field(..)
2500            | ExprKind::If(..)
2501            | ExprKind::Index(..)
2502            | ExprKind::InlineAsm(..)
2503            | ExprKind::Lit(_)
2504            | ExprKind::Loop(..)
2505            | ExprKind::Match(..)
2506            | ExprKind::MethodCall(..)
2507            | ExprKind::OffsetOf(..)
2508            | ExprKind::Path(..)
2509            | ExprKind::Repeat(..)
2510            | ExprKind::Struct(..)
2511            | ExprKind::Tup(_)
2512            | ExprKind::Type(..)
2513            | ExprKind::UnsafeBinderCast(..)
2514            | ExprKind::Use(..)
2515            | ExprKind::Err(_) => prefix_attrs_precedence(),
2516
2517            ExprKind::DropTemps(expr, ..) => expr.precedence(has_attr),
2518        }
2519    }
2520
2521    /// Whether this looks like a place expr, without checking for deref
2522    /// adjustments.
2523    /// This will return `true` in some potentially surprising cases such as
2524    /// `CONSTANT.field`.
2525    pub fn is_syntactic_place_expr(&self) -> bool {
2526        self.is_place_expr(|_| true)
2527    }
2528
2529    /// Whether this is a place expression.
2530    ///
2531    /// `allow_projections_from` should return `true` if indexing a field or index expression based
2532    /// on the given expression should be considered a place expression.
2533    pub fn is_place_expr(&self, mut allow_projections_from: impl FnMut(&Self) -> bool) -> bool {
2534        match self.kind {
2535            ExprKind::Path(QPath::Resolved(_, ref path)) => {
2536                #[allow(non_exhaustive_omitted_patterns)] match path.res {
    Res::Local(..) | Res::Def(DefKind::Static { .. }, _) | Res::Err => true,
    _ => false,
}matches!(path.res, Res::Local(..) | Res::Def(DefKind::Static { .. }, _) | Res::Err)
2537            }
2538
2539            // Type ascription inherits its place expression kind from its
2540            // operand. See:
2541            // https://github.com/rust-lang/rfcs/blob/master/text/0803-type-ascription.md#type-ascription-and-temporaries
2542            ExprKind::Type(ref e, _) => e.is_place_expr(allow_projections_from),
2543
2544            // Unsafe binder cast preserves place-ness of the sub-expression.
2545            ExprKind::UnsafeBinderCast(_, e, _) => e.is_place_expr(allow_projections_from),
2546
2547            ExprKind::Unary(UnOp::Deref, _) => true,
2548
2549            ExprKind::Field(ref base, _) | ExprKind::Index(ref base, _, _) => {
2550                allow_projections_from(base) || base.is_place_expr(allow_projections_from)
2551            }
2552
2553            // Suppress errors for bad expressions.
2554            ExprKind::Err(_guar)
2555            | ExprKind::Let(&LetExpr { recovered: ast::Recovered::Yes(_guar), .. }) => true,
2556
2557            // Partially qualified paths in expressions can only legally
2558            // refer to associated items which are always rvalues.
2559            ExprKind::Path(QPath::TypeRelative(..))
2560            | ExprKind::Call(..)
2561            | ExprKind::MethodCall(..)
2562            | ExprKind::Use(..)
2563            | ExprKind::Struct(..)
2564            | ExprKind::Tup(..)
2565            | ExprKind::If(..)
2566            | ExprKind::Match(..)
2567            | ExprKind::Closure { .. }
2568            | ExprKind::Block(..)
2569            | ExprKind::Repeat(..)
2570            | ExprKind::Array(..)
2571            | ExprKind::Break(..)
2572            | ExprKind::Continue(..)
2573            | ExprKind::Ret(..)
2574            | ExprKind::Become(..)
2575            | ExprKind::Let(..)
2576            | ExprKind::Loop(..)
2577            | ExprKind::Assign(..)
2578            | ExprKind::InlineAsm(..)
2579            | ExprKind::OffsetOf(..)
2580            | ExprKind::AssignOp(..)
2581            | ExprKind::Lit(_)
2582            | ExprKind::ConstBlock(..)
2583            | ExprKind::Unary(..)
2584            | ExprKind::AddrOf(..)
2585            | ExprKind::Binary(..)
2586            | ExprKind::Yield(..)
2587            | ExprKind::Cast(..)
2588            | ExprKind::DropTemps(..) => false,
2589        }
2590    }
2591
2592    /// If this is a desugared range expression,
2593    /// returns the span of the range without desugaring context.
2594    pub fn range_span(&self) -> Option<Span> {
2595        is_range_literal(self).then(|| self.span.parent_callsite().unwrap())
2596    }
2597
2598    /// Check if expression is an integer literal that can be used
2599    /// where `usize` is expected.
2600    pub fn is_size_lit(&self) -> bool {
2601        #[allow(non_exhaustive_omitted_patterns)] match self.kind {
    ExprKind::Lit(Lit {
        node: LitKind::Int(_,
            LitIntType::Unsuffixed | LitIntType::Unsigned(UintTy::Usize)), ..
        }) => true,
    _ => false,
}matches!(
2602            self.kind,
2603            ExprKind::Lit(Lit {
2604                node: LitKind::Int(_, LitIntType::Unsuffixed | LitIntType::Unsigned(UintTy::Usize)),
2605                ..
2606            })
2607        )
2608    }
2609
2610    /// If `Self.kind` is `ExprKind::DropTemps(expr)`, drill down until we get a non-`DropTemps`
2611    /// `Expr`. This is used in suggestions to ignore this `ExprKind` as it is semantically
2612    /// silent, only signaling the ownership system. By doing this, suggestions that check the
2613    /// `ExprKind` of any given `Expr` for presentation don't have to care about `DropTemps`
2614    /// beyond remembering to call this function before doing analysis on it.
2615    pub fn peel_drop_temps(&self) -> &Self {
2616        let mut expr = self;
2617        while let ExprKind::DropTemps(inner) = &expr.kind {
2618            expr = inner;
2619        }
2620        expr
2621    }
2622
2623    pub fn peel_blocks(&self) -> &Self {
2624        let mut expr = self;
2625        while let ExprKind::Block(Block { expr: Some(inner), .. }, _) = &expr.kind {
2626            expr = inner;
2627        }
2628        expr
2629    }
2630
2631    pub fn peel_borrows(&self) -> &Self {
2632        let mut expr = self;
2633        while let ExprKind::AddrOf(.., inner) = &expr.kind {
2634            expr = inner;
2635        }
2636        expr
2637    }
2638
2639    pub fn can_have_side_effects(&self) -> bool {
2640        match self.peel_drop_temps().kind {
2641            ExprKind::Path(_) | ExprKind::Lit(_) | ExprKind::OffsetOf(..) | ExprKind::Use(..) => {
2642                false
2643            }
2644            ExprKind::Type(base, _)
2645            | ExprKind::Unary(_, base)
2646            | ExprKind::Field(base, _)
2647            | ExprKind::Index(base, _, _)
2648            | ExprKind::AddrOf(.., base)
2649            | ExprKind::Cast(base, _)
2650            | ExprKind::UnsafeBinderCast(_, base, _) => {
2651                // This isn't exactly true for `Index` and all `Unary`, but we are using this
2652                // method exclusively for diagnostics and there's a *cultural* pressure against
2653                // them being used only for its side-effects.
2654                base.can_have_side_effects()
2655            }
2656            ExprKind::Binary(_, lhs, rhs) => {
2657                // This isn't exactly true for all `Binary`, but we are using this
2658                // method exclusively for diagnostics and there's a *cultural* pressure against
2659                // them being used only for its side-effects.
2660                lhs.can_have_side_effects() || rhs.can_have_side_effects()
2661            }
2662            ExprKind::Struct(_, fields, init) => {
2663                let init_side_effects = match init {
2664                    StructTailExpr::Base(init) => init.can_have_side_effects(),
2665                    StructTailExpr::DefaultFields(_)
2666                    | StructTailExpr::None
2667                    | StructTailExpr::NoneWithError(_) => false,
2668                };
2669                fields.iter().map(|field| field.expr).any(|e| e.can_have_side_effects())
2670                    || init_side_effects
2671            }
2672
2673            ExprKind::Array(args)
2674            | ExprKind::Tup(args)
2675            | ExprKind::Call(
2676                Expr {
2677                    kind:
2678                        ExprKind::Path(QPath::Resolved(
2679                            None,
2680                            Path { res: Res::Def(DefKind::Ctor(_, CtorKind::Fn), _), .. },
2681                        )),
2682                    ..
2683                },
2684                args,
2685            ) => args.iter().any(|arg| arg.can_have_side_effects()),
2686            ExprKind::Repeat(arg, _) => arg.can_have_side_effects(),
2687            ExprKind::If(..)
2688            | ExprKind::Match(..)
2689            | ExprKind::MethodCall(..)
2690            | ExprKind::Call(..)
2691            | ExprKind::Closure { .. }
2692            | ExprKind::Block(..)
2693            | ExprKind::Break(..)
2694            | ExprKind::Continue(..)
2695            | ExprKind::Ret(..)
2696            | ExprKind::Become(..)
2697            | ExprKind::Let(..)
2698            | ExprKind::Loop(..)
2699            | ExprKind::Assign(..)
2700            | ExprKind::InlineAsm(..)
2701            | ExprKind::AssignOp(..)
2702            | ExprKind::ConstBlock(..)
2703            | ExprKind::Yield(..)
2704            | ExprKind::DropTemps(..)
2705            | ExprKind::Err(_) => true,
2706        }
2707    }
2708
2709    /// To a first-order approximation, is this a pattern?
2710    pub fn is_approximately_pattern(&self) -> bool {
2711        match &self.kind {
2712            ExprKind::Array(_)
2713            | ExprKind::Call(..)
2714            | ExprKind::Tup(_)
2715            | ExprKind::Lit(_)
2716            | ExprKind::Path(_)
2717            | ExprKind::Struct(..) => true,
2718            _ => false,
2719        }
2720    }
2721
2722    /// Whether this and the `other` expression are the same for purposes of an indexing operation.
2723    ///
2724    /// This is only used for diagnostics to see if we have things like `foo[i]` where `foo` is
2725    /// borrowed multiple times with `i`.
2726    pub fn equivalent_for_indexing(&self, other: &Expr<'_>) -> bool {
2727        match (self.kind, other.kind) {
2728            (ExprKind::Lit(lit1), ExprKind::Lit(lit2)) => lit1.node == lit2.node,
2729            (
2730                ExprKind::Path(QPath::Resolved(None, path1)),
2731                ExprKind::Path(QPath::Resolved(None, path2)),
2732            ) => path1.res == path2.res,
2733            (
2734                ExprKind::Struct(
2735                    &QPath::Resolved(None, &Path { res: Res::Def(_, path1_def_id), .. }),
2736                    args1,
2737                    StructTailExpr::None,
2738                ),
2739                ExprKind::Struct(
2740                    &QPath::Resolved(None, &Path { res: Res::Def(_, path2_def_id), .. }),
2741                    args2,
2742                    StructTailExpr::None,
2743                ),
2744            ) => {
2745                path2_def_id == path1_def_id
2746                    && is_range_literal(self)
2747                    && is_range_literal(other)
2748                    && std::iter::zip(args1, args2)
2749                        .all(|(a, b)| a.expr.equivalent_for_indexing(b.expr))
2750            }
2751            _ => false,
2752        }
2753    }
2754
2755    pub fn method_ident(&self) -> Option<Ident> {
2756        match self.kind {
2757            ExprKind::MethodCall(receiver_method, ..) => Some(receiver_method.ident),
2758            ExprKind::Unary(_, expr) | ExprKind::AddrOf(.., expr) => expr.method_ident(),
2759            _ => None,
2760        }
2761    }
2762}
2763
2764/// Checks if the specified expression is a built-in range literal.
2765/// (See: `LoweringContext::lower_expr()`).
2766pub fn is_range_literal(expr: &Expr<'_>) -> bool {
2767    if let ExprKind::Struct(QPath::Resolved(None, path), _, StructTailExpr::None) = expr.kind
2768        && let [.., segment] = path.segments
2769        && let sym::RangeFrom
2770        | sym::RangeFull
2771        | sym::Range
2772        | sym::RangeToInclusive
2773        | sym::RangeTo
2774        | sym::RangeFromCopy
2775        | sym::RangeCopy
2776        | sym::RangeInclusiveCopy
2777        | sym::RangeToInclusiveCopy = segment.ident.name
2778        && expr.span.is_desugaring(DesugaringKind::RangeExpr)
2779    {
2780        true
2781    } else if let ExprKind::Call(func, _) = &expr.kind
2782        && let ExprKind::Path(QPath::Resolved(None, path)) = func.kind
2783        && let [.., segment] = path.segments
2784        && let sym::range_inclusive_new = segment.ident.name
2785        && expr.span.is_desugaring(DesugaringKind::RangeExpr)
2786    {
2787        true
2788    } else {
2789        false
2790    }
2791}
2792
2793/// Checks if the specified expression needs parentheses for prefix
2794/// or postfix suggestions to be valid.
2795/// For example, `a + b` requires parentheses to suggest `&(a + b)`,
2796/// but just `a` does not.
2797/// Similarly, `(a + b).c()` also requires parentheses.
2798/// This should not be used for other types of suggestions.
2799pub fn expr_needs_parens(expr: &Expr<'_>) -> bool {
2800    match expr.kind {
2801        // parenthesize if needed (Issue #46756)
2802        ExprKind::Cast(_, _) | ExprKind::Binary(_, _, _) => true,
2803        // parenthesize borrows of range literals (Issue #54505)
2804        _ if is_range_literal(expr) => true,
2805        _ => false,
2806    }
2807}
2808
2809#[derive(#[automatically_derived]
impl<'hir> ::core::fmt::Debug for ExprKind<'hir> {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        match self {
            ExprKind::ConstBlock(__self_0) =>
                ::core::fmt::Formatter::debug_tuple_field1_finish(f,
                    "ConstBlock", &__self_0),
            ExprKind::Array(__self_0) =>
                ::core::fmt::Formatter::debug_tuple_field1_finish(f, "Array",
                    &__self_0),
            ExprKind::Call(__self_0, __self_1) =>
                ::core::fmt::Formatter::debug_tuple_field2_finish(f, "Call",
                    __self_0, &__self_1),
            ExprKind::MethodCall(__self_0, __self_1, __self_2, __self_3) =>
                ::core::fmt::Formatter::debug_tuple_field4_finish(f,
                    "MethodCall", __self_0, __self_1, __self_2, &__self_3),
            ExprKind::Use(__self_0, __self_1) =>
                ::core::fmt::Formatter::debug_tuple_field2_finish(f, "Use",
                    __self_0, &__self_1),
            ExprKind::Tup(__self_0) =>
                ::core::fmt::Formatter::debug_tuple_field1_finish(f, "Tup",
                    &__self_0),
            ExprKind::Binary(__self_0, __self_1, __self_2) =>
                ::core::fmt::Formatter::debug_tuple_field3_finish(f, "Binary",
                    __self_0, __self_1, &__self_2),
            ExprKind::Unary(__self_0, __self_1) =>
                ::core::fmt::Formatter::debug_tuple_field2_finish(f, "Unary",
                    __self_0, &__self_1),
            ExprKind::Lit(__self_0) =>
                ::core::fmt::Formatter::debug_tuple_field1_finish(f, "Lit",
                    &__self_0),
            ExprKind::Cast(__self_0, __self_1) =>
                ::core::fmt::Formatter::debug_tuple_field2_finish(f, "Cast",
                    __self_0, &__self_1),
            ExprKind::Type(__self_0, __self_1) =>
                ::core::fmt::Formatter::debug_tuple_field2_finish(f, "Type",
                    __self_0, &__self_1),
            ExprKind::DropTemps(__self_0) =>
                ::core::fmt::Formatter::debug_tuple_field1_finish(f,
                    "DropTemps", &__self_0),
            ExprKind::Let(__self_0) =>
                ::core::fmt::Formatter::debug_tuple_field1_finish(f, "Let",
                    &__self_0),
            ExprKind::If(__self_0, __self_1, __self_2) =>
                ::core::fmt::Formatter::debug_tuple_field3_finish(f, "If",
                    __self_0, __self_1, &__self_2),
            ExprKind::Loop(__self_0, __self_1, __self_2, __self_3) =>
                ::core::fmt::Formatter::debug_tuple_field4_finish(f, "Loop",
                    __self_0, __self_1, __self_2, &__self_3),
            ExprKind::Match(__self_0, __self_1, __self_2) =>
                ::core::fmt::Formatter::debug_tuple_field3_finish(f, "Match",
                    __self_0, __self_1, &__self_2),
            ExprKind::Closure(__self_0) =>
                ::core::fmt::Formatter::debug_tuple_field1_finish(f,
                    "Closure", &__self_0),
            ExprKind::Block(__self_0, __self_1) =>
                ::core::fmt::Formatter::debug_tuple_field2_finish(f, "Block",
                    __self_0, &__self_1),
            ExprKind::Assign(__self_0, __self_1, __self_2) =>
                ::core::fmt::Formatter::debug_tuple_field3_finish(f, "Assign",
                    __self_0, __self_1, &__self_2),
            ExprKind::AssignOp(__self_0, __self_1, __self_2) =>
                ::core::fmt::Formatter::debug_tuple_field3_finish(f,
                    "AssignOp", __self_0, __self_1, &__self_2),
            ExprKind::Field(__self_0, __self_1) =>
                ::core::fmt::Formatter::debug_tuple_field2_finish(f, "Field",
                    __self_0, &__self_1),
            ExprKind::Index(__self_0, __self_1, __self_2) =>
                ::core::fmt::Formatter::debug_tuple_field3_finish(f, "Index",
                    __self_0, __self_1, &__self_2),
            ExprKind::Path(__self_0) =>
                ::core::fmt::Formatter::debug_tuple_field1_finish(f, "Path",
                    &__self_0),
            ExprKind::AddrOf(__self_0, __self_1, __self_2) =>
                ::core::fmt::Formatter::debug_tuple_field3_finish(f, "AddrOf",
                    __self_0, __self_1, &__self_2),
            ExprKind::Break(__self_0, __self_1) =>
                ::core::fmt::Formatter::debug_tuple_field2_finish(f, "Break",
                    __self_0, &__self_1),
            ExprKind::Continue(__self_0) =>
                ::core::fmt::Formatter::debug_tuple_field1_finish(f,
                    "Continue", &__self_0),
            ExprKind::Ret(__self_0) =>
                ::core::fmt::Formatter::debug_tuple_field1_finish(f, "Ret",
                    &__self_0),
            ExprKind::Become(__self_0) =>
                ::core::fmt::Formatter::debug_tuple_field1_finish(f, "Become",
                    &__self_0),
            ExprKind::InlineAsm(__self_0) =>
                ::core::fmt::Formatter::debug_tuple_field1_finish(f,
                    "InlineAsm", &__self_0),
            ExprKind::OffsetOf(__self_0, __self_1) =>
                ::core::fmt::Formatter::debug_tuple_field2_finish(f,
                    "OffsetOf", __self_0, &__self_1),
            ExprKind::Struct(__self_0, __self_1, __self_2) =>
                ::core::fmt::Formatter::debug_tuple_field3_finish(f, "Struct",
                    __self_0, __self_1, &__self_2),
            ExprKind::Repeat(__self_0, __self_1) =>
                ::core::fmt::Formatter::debug_tuple_field2_finish(f, "Repeat",
                    __self_0, &__self_1),
            ExprKind::Yield(__self_0, __self_1) =>
                ::core::fmt::Formatter::debug_tuple_field2_finish(f, "Yield",
                    __self_0, &__self_1),
            ExprKind::UnsafeBinderCast(__self_0, __self_1, __self_2) =>
                ::core::fmt::Formatter::debug_tuple_field3_finish(f,
                    "UnsafeBinderCast", __self_0, __self_1, &__self_2),
            ExprKind::Err(__self_0) =>
                ::core::fmt::Formatter::debug_tuple_field1_finish(f, "Err",
                    &__self_0),
        }
    }
}Debug, #[automatically_derived]
impl<'hir> ::core::clone::Clone for ExprKind<'hir> {
    #[inline]
    fn clone(&self) -> ExprKind<'hir> {
        let _: ::core::clone::AssertParamIsClone<ConstBlock>;
        let _: ::core::clone::AssertParamIsClone<&'hir [Expr<'hir>]>;
        let _: ::core::clone::AssertParamIsClone<&'hir Expr<'hir>>;
        let _: ::core::clone::AssertParamIsClone<&'hir [Expr<'hir>]>;
        let _: ::core::clone::AssertParamIsClone<&'hir PathSegment<'hir>>;
        let _: ::core::clone::AssertParamIsClone<&'hir Expr<'hir>>;
        let _: ::core::clone::AssertParamIsClone<&'hir [Expr<'hir>]>;
        let _: ::core::clone::AssertParamIsClone<Span>;
        let _: ::core::clone::AssertParamIsClone<&'hir Expr<'hir>>;
        let _: ::core::clone::AssertParamIsClone<&'hir [Expr<'hir>]>;
        let _: ::core::clone::AssertParamIsClone<BinOp>;
        let _: ::core::clone::AssertParamIsClone<&'hir Expr<'hir>>;
        let _: ::core::clone::AssertParamIsClone<&'hir Expr<'hir>>;
        let _: ::core::clone::AssertParamIsClone<UnOp>;
        let _: ::core::clone::AssertParamIsClone<&'hir Expr<'hir>>;
        let _: ::core::clone::AssertParamIsClone<Lit>;
        let _: ::core::clone::AssertParamIsClone<&'hir Expr<'hir>>;
        let _: ::core::clone::AssertParamIsClone<&'hir Ty<'hir>>;
        let _: ::core::clone::AssertParamIsClone<&'hir Expr<'hir>>;
        let _: ::core::clone::AssertParamIsClone<&'hir Ty<'hir>>;
        let _: ::core::clone::AssertParamIsClone<&'hir Expr<'hir>>;
        let _: ::core::clone::AssertParamIsClone<&'hir LetExpr<'hir>>;
        let _: ::core::clone::AssertParamIsClone<&'hir Expr<'hir>>;
        let _: ::core::clone::AssertParamIsClone<&'hir Expr<'hir>>;
        let _: ::core::clone::AssertParamIsClone<Option<&'hir Expr<'hir>>>;
        let _: ::core::clone::AssertParamIsClone<&'hir Block<'hir>>;
        let _: ::core::clone::AssertParamIsClone<Option<Label>>;
        let _: ::core::clone::AssertParamIsClone<LoopSource>;
        let _: ::core::clone::AssertParamIsClone<&'hir Expr<'hir>>;
        let _: ::core::clone::AssertParamIsClone<&'hir [Arm<'hir>]>;
        let _: ::core::clone::AssertParamIsClone<MatchSource>;
        let _: ::core::clone::AssertParamIsClone<&'hir Closure<'hir>>;
        let _: ::core::clone::AssertParamIsClone<&'hir Block<'hir>>;
        let _: ::core::clone::AssertParamIsClone<Option<Label>>;
        let _: ::core::clone::AssertParamIsClone<&'hir Expr<'hir>>;
        let _: ::core::clone::AssertParamIsClone<&'hir Expr<'hir>>;
        let _: ::core::clone::AssertParamIsClone<AssignOp>;
        let _: ::core::clone::AssertParamIsClone<&'hir Expr<'hir>>;
        let _: ::core::clone::AssertParamIsClone<&'hir Expr<'hir>>;
        let _: ::core::clone::AssertParamIsClone<&'hir Expr<'hir>>;
        let _: ::core::clone::AssertParamIsClone<Ident>;
        let _: ::core::clone::AssertParamIsClone<&'hir Expr<'hir>>;
        let _: ::core::clone::AssertParamIsClone<&'hir Expr<'hir>>;
        let _: ::core::clone::AssertParamIsClone<QPath<'hir>>;
        let _: ::core::clone::AssertParamIsClone<BorrowKind>;
        let _: ::core::clone::AssertParamIsClone<Mutability>;
        let _: ::core::clone::AssertParamIsClone<&'hir Expr<'hir>>;
        let _: ::core::clone::AssertParamIsClone<Destination>;
        let _: ::core::clone::AssertParamIsClone<Option<&'hir Expr<'hir>>>;
        let _: ::core::clone::AssertParamIsClone<Option<&'hir Expr<'hir>>>;
        let _: ::core::clone::AssertParamIsClone<&'hir Expr<'hir>>;
        let _: ::core::clone::AssertParamIsClone<&'hir InlineAsm<'hir>>;
        let _: ::core::clone::AssertParamIsClone<&'hir Ty<'hir>>;
        let _: ::core::clone::AssertParamIsClone<&'hir [Ident]>;
        let _: ::core::clone::AssertParamIsClone<&'hir QPath<'hir>>;
        let _: ::core::clone::AssertParamIsClone<&'hir [ExprField<'hir>]>;
        let _: ::core::clone::AssertParamIsClone<StructTailExpr<'hir>>;
        let _: ::core::clone::AssertParamIsClone<&'hir Expr<'hir>>;
        let _: ::core::clone::AssertParamIsClone<&'hir ConstArg<'hir>>;
        let _: ::core::clone::AssertParamIsClone<&'hir Expr<'hir>>;
        let _: ::core::clone::AssertParamIsClone<YieldSource>;
        let _: ::core::clone::AssertParamIsClone<UnsafeBinderCastKind>;
        let _: ::core::clone::AssertParamIsClone<&'hir Expr<'hir>>;
        let _: ::core::clone::AssertParamIsClone<Option<&'hir Ty<'hir>>>;
        let _: ::core::clone::AssertParamIsClone<rustc_span::ErrorGuaranteed>;
        *self
    }
}Clone, #[automatically_derived]
impl<'hir> ::core::marker::Copy for ExprKind<'hir> { }Copy, const _: () =
    {
        impl<'hir, __CTX>
            ::rustc_data_structures::stable_hasher::HashStable<__CTX> for
            ExprKind<'hir> where __CTX: crate::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 {
                    ExprKind::ConstBlock(ref __binding_0) => {
                        { __binding_0.hash_stable(__hcx, __hasher); }
                    }
                    ExprKind::Array(ref __binding_0) => {
                        { __binding_0.hash_stable(__hcx, __hasher); }
                    }
                    ExprKind::Call(ref __binding_0, ref __binding_1) => {
                        { __binding_0.hash_stable(__hcx, __hasher); }
                        { __binding_1.hash_stable(__hcx, __hasher); }
                    }
                    ExprKind::MethodCall(ref __binding_0, ref __binding_1,
                        ref __binding_2, 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); }
                    }
                    ExprKind::Use(ref __binding_0, ref __binding_1) => {
                        { __binding_0.hash_stable(__hcx, __hasher); }
                        { __binding_1.hash_stable(__hcx, __hasher); }
                    }
                    ExprKind::Tup(ref __binding_0) => {
                        { __binding_0.hash_stable(__hcx, __hasher); }
                    }
                    ExprKind::Binary(ref __binding_0, ref __binding_1,
                        ref __binding_2) => {
                        { __binding_0.hash_stable(__hcx, __hasher); }
                        { __binding_1.hash_stable(__hcx, __hasher); }
                        { __binding_2.hash_stable(__hcx, __hasher); }
                    }
                    ExprKind::Unary(ref __binding_0, ref __binding_1) => {
                        { __binding_0.hash_stable(__hcx, __hasher); }
                        { __binding_1.hash_stable(__hcx, __hasher); }
                    }
                    ExprKind::Lit(ref __binding_0) => {
                        { __binding_0.hash_stable(__hcx, __hasher); }
                    }
                    ExprKind::Cast(ref __binding_0, ref __binding_1) => {
                        { __binding_0.hash_stable(__hcx, __hasher); }
                        { __binding_1.hash_stable(__hcx, __hasher); }
                    }
                    ExprKind::Type(ref __binding_0, ref __binding_1) => {
                        { __binding_0.hash_stable(__hcx, __hasher); }
                        { __binding_1.hash_stable(__hcx, __hasher); }
                    }
                    ExprKind::DropTemps(ref __binding_0) => {
                        { __binding_0.hash_stable(__hcx, __hasher); }
                    }
                    ExprKind::Let(ref __binding_0) => {
                        { __binding_0.hash_stable(__hcx, __hasher); }
                    }
                    ExprKind::If(ref __binding_0, ref __binding_1,
                        ref __binding_2) => {
                        { __binding_0.hash_stable(__hcx, __hasher); }
                        { __binding_1.hash_stable(__hcx, __hasher); }
                        { __binding_2.hash_stable(__hcx, __hasher); }
                    }
                    ExprKind::Loop(ref __binding_0, ref __binding_1,
                        ref __binding_2, 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); }
                    }
                    ExprKind::Match(ref __binding_0, ref __binding_1,
                        ref __binding_2) => {
                        { __binding_0.hash_stable(__hcx, __hasher); }
                        { __binding_1.hash_stable(__hcx, __hasher); }
                        { __binding_2.hash_stable(__hcx, __hasher); }
                    }
                    ExprKind::Closure(ref __binding_0) => {
                        { __binding_0.hash_stable(__hcx, __hasher); }
                    }
                    ExprKind::Block(ref __binding_0, ref __binding_1) => {
                        { __binding_0.hash_stable(__hcx, __hasher); }
                        { __binding_1.hash_stable(__hcx, __hasher); }
                    }
                    ExprKind::Assign(ref __binding_0, ref __binding_1,
                        ref __binding_2) => {
                        { __binding_0.hash_stable(__hcx, __hasher); }
                        { __binding_1.hash_stable(__hcx, __hasher); }
                        { __binding_2.hash_stable(__hcx, __hasher); }
                    }
                    ExprKind::AssignOp(ref __binding_0, ref __binding_1,
                        ref __binding_2) => {
                        { __binding_0.hash_stable(__hcx, __hasher); }
                        { __binding_1.hash_stable(__hcx, __hasher); }
                        { __binding_2.hash_stable(__hcx, __hasher); }
                    }
                    ExprKind::Field(ref __binding_0, ref __binding_1) => {
                        { __binding_0.hash_stable(__hcx, __hasher); }
                        { __binding_1.hash_stable(__hcx, __hasher); }
                    }
                    ExprKind::Index(ref __binding_0, ref __binding_1,
                        ref __binding_2) => {
                        { __binding_0.hash_stable(__hcx, __hasher); }
                        { __binding_1.hash_stable(__hcx, __hasher); }
                        { __binding_2.hash_stable(__hcx, __hasher); }
                    }
                    ExprKind::Path(ref __binding_0) => {
                        { __binding_0.hash_stable(__hcx, __hasher); }
                    }
                    ExprKind::AddrOf(ref __binding_0, ref __binding_1,
                        ref __binding_2) => {
                        { __binding_0.hash_stable(__hcx, __hasher); }
                        { __binding_1.hash_stable(__hcx, __hasher); }
                        { __binding_2.hash_stable(__hcx, __hasher); }
                    }
                    ExprKind::Break(ref __binding_0, ref __binding_1) => {
                        { __binding_0.hash_stable(__hcx, __hasher); }
                        { __binding_1.hash_stable(__hcx, __hasher); }
                    }
                    ExprKind::Continue(ref __binding_0) => {
                        { __binding_0.hash_stable(__hcx, __hasher); }
                    }
                    ExprKind::Ret(ref __binding_0) => {
                        { __binding_0.hash_stable(__hcx, __hasher); }
                    }
                    ExprKind::Become(ref __binding_0) => {
                        { __binding_0.hash_stable(__hcx, __hasher); }
                    }
                    ExprKind::InlineAsm(ref __binding_0) => {
                        { __binding_0.hash_stable(__hcx, __hasher); }
                    }
                    ExprKind::OffsetOf(ref __binding_0, ref __binding_1) => {
                        { __binding_0.hash_stable(__hcx, __hasher); }
                        { __binding_1.hash_stable(__hcx, __hasher); }
                    }
                    ExprKind::Struct(ref __binding_0, ref __binding_1,
                        ref __binding_2) => {
                        { __binding_0.hash_stable(__hcx, __hasher); }
                        { __binding_1.hash_stable(__hcx, __hasher); }
                        { __binding_2.hash_stable(__hcx, __hasher); }
                    }
                    ExprKind::Repeat(ref __binding_0, ref __binding_1) => {
                        { __binding_0.hash_stable(__hcx, __hasher); }
                        { __binding_1.hash_stable(__hcx, __hasher); }
                    }
                    ExprKind::Yield(ref __binding_0, ref __binding_1) => {
                        { __binding_0.hash_stable(__hcx, __hasher); }
                        { __binding_1.hash_stable(__hcx, __hasher); }
                    }
                    ExprKind::UnsafeBinderCast(ref __binding_0, ref __binding_1,
                        ref __binding_2) => {
                        { __binding_0.hash_stable(__hcx, __hasher); }
                        { __binding_1.hash_stable(__hcx, __hasher); }
                        { __binding_2.hash_stable(__hcx, __hasher); }
                    }
                    ExprKind::Err(ref __binding_0) => {
                        { __binding_0.hash_stable(__hcx, __hasher); }
                    }
                }
            }
        }
    };HashStable_Generic)]
2810pub enum ExprKind<'hir> {
2811    /// Allow anonymous constants from an inline `const` block
2812    ConstBlock(ConstBlock),
2813    /// An array (e.g., `[a, b, c, d]`).
2814    Array(&'hir [Expr<'hir>]),
2815    /// A function call.
2816    ///
2817    /// The first field resolves to the function itself (usually an `ExprKind::Path`),
2818    /// and the second field is the list of arguments.
2819    /// This also represents calling the constructor of
2820    /// tuple-like ADTs such as tuple structs and enum variants.
2821    Call(&'hir Expr<'hir>, &'hir [Expr<'hir>]),
2822    /// A method call (e.g., `x.foo::<'static, Bar, Baz>(a, b, c, d)`).
2823    ///
2824    /// The `PathSegment` represents the method name and its generic arguments
2825    /// (within the angle brackets).
2826    /// The `&Expr` is the expression that evaluates
2827    /// to the object on which the method is being called on (the receiver),
2828    /// and the `&[Expr]` is the rest of the arguments.
2829    /// Thus, `x.foo::<Bar, Baz>(a, b, c, d)` is represented as
2830    /// `ExprKind::MethodCall(PathSegment { foo, [Bar, Baz] }, x, [a, b, c, d], span)`.
2831    /// The final `Span` represents the span of the function and arguments
2832    /// (e.g. `foo::<Bar, Baz>(a, b, c, d)` in `x.foo::<Bar, Baz>(a, b, c, d)`
2833    ///
2834    /// To resolve the called method to a `DefId`, call [`type_dependent_def_id`] with
2835    /// the `hir_id` of the `MethodCall` node itself.
2836    ///
2837    /// [`type_dependent_def_id`]: ../../rustc_middle/ty/struct.TypeckResults.html#method.type_dependent_def_id
2838    MethodCall(&'hir PathSegment<'hir>, &'hir Expr<'hir>, &'hir [Expr<'hir>], Span),
2839    /// An use expression (e.g., `var.use`).
2840    Use(&'hir Expr<'hir>, Span),
2841    /// A tuple (e.g., `(a, b, c, d)`).
2842    Tup(&'hir [Expr<'hir>]),
2843    /// A binary operation (e.g., `a + b`, `a * b`).
2844    Binary(BinOp, &'hir Expr<'hir>, &'hir Expr<'hir>),
2845    /// A unary operation (e.g., `!x`, `*x`).
2846    Unary(UnOp, &'hir Expr<'hir>),
2847    /// A literal (e.g., `1`, `"foo"`).
2848    Lit(Lit),
2849    /// A cast (e.g., `foo as f64`).
2850    Cast(&'hir Expr<'hir>, &'hir Ty<'hir>),
2851    /// A type ascription (e.g., `x: Foo`). See RFC 3307.
2852    Type(&'hir Expr<'hir>, &'hir Ty<'hir>),
2853    /// Wraps the expression in a terminating scope.
2854    /// This makes it semantically equivalent to `{ let _t = expr; _t }`.
2855    ///
2856    /// This construct only exists to tweak the drop order in AST lowering.
2857    /// An example of that is the desugaring of `for` loops.
2858    DropTemps(&'hir Expr<'hir>),
2859    /// A `let $pat = $expr` expression.
2860    ///
2861    /// These are not [`LetStmt`] and only occur as expressions.
2862    /// The `let Some(x) = foo()` in `if let Some(x) = foo()` is an example of `Let(..)`.
2863    Let(&'hir LetExpr<'hir>),
2864    /// An `if` block, with an optional else block.
2865    ///
2866    /// I.e., `if <expr> { <expr> } else { <expr> }`.
2867    ///
2868    /// The "then" expr is always `ExprKind::Block`. If present, the "else" expr is always
2869    /// `ExprKind::Block` (for `else`) or `ExprKind::If` (for `else if`).
2870    /// Note that using an `Expr` instead of a `Block` for the "then" part is intentional,
2871    /// as it simplifies the type coercion machinery.
2872    If(&'hir Expr<'hir>, &'hir Expr<'hir>, Option<&'hir Expr<'hir>>),
2873    /// A conditionless loop (can be exited with `break`, `continue`, or `return`).
2874    ///
2875    /// I.e., `'label: loop { <block> }`.
2876    ///
2877    /// The `Span` is the loop header (`for x in y`/`while let pat = expr`).
2878    Loop(&'hir Block<'hir>, Option<Label>, LoopSource, Span),
2879    /// A `match` block, with a source that indicates whether or not it is
2880    /// the result of a desugaring, and if so, which kind.
2881    Match(&'hir Expr<'hir>, &'hir [Arm<'hir>], MatchSource),
2882    /// A closure (e.g., `move |a, b, c| {a + b + c}`).
2883    ///
2884    /// The `Span` is the argument block `|...|`.
2885    ///
2886    /// This may also be a coroutine literal or an `async block` as indicated by the
2887    /// `Option<Movability>`.
2888    Closure(&'hir Closure<'hir>),
2889    /// A block (e.g., `'label: { ... }`).
2890    Block(&'hir Block<'hir>, Option<Label>),
2891
2892    /// An assignment (e.g., `a = foo()`).
2893    Assign(&'hir Expr<'hir>, &'hir Expr<'hir>, Span),
2894    /// An assignment with an operator.
2895    ///
2896    /// E.g., `a += 1`.
2897    AssignOp(AssignOp, &'hir Expr<'hir>, &'hir Expr<'hir>),
2898    /// Access of a named (e.g., `obj.foo`) or unnamed (e.g., `obj.0`) struct or tuple field.
2899    Field(&'hir Expr<'hir>, Ident),
2900    /// An indexing operation (`foo[2]`).
2901    /// Similar to [`ExprKind::MethodCall`], the final `Span` represents the span of the brackets
2902    /// and index.
2903    Index(&'hir Expr<'hir>, &'hir Expr<'hir>, Span),
2904
2905    /// Path to a definition, possibly containing lifetime or type parameters.
2906    Path(QPath<'hir>),
2907
2908    /// A referencing operation (i.e., `&a` or `&mut a`).
2909    AddrOf(BorrowKind, Mutability, &'hir Expr<'hir>),
2910    /// A `break`, with an optional label to break.
2911    Break(Destination, Option<&'hir Expr<'hir>>),
2912    /// A `continue`, with an optional label.
2913    Continue(Destination),
2914    /// A `return`, with an optional value to be returned.
2915    Ret(Option<&'hir Expr<'hir>>),
2916    /// A `become`, with the value to be returned.
2917    Become(&'hir Expr<'hir>),
2918
2919    /// Inline assembly (from `asm!`), with its outputs and inputs.
2920    InlineAsm(&'hir InlineAsm<'hir>),
2921
2922    /// Field offset (`offset_of!`)
2923    OffsetOf(&'hir Ty<'hir>, &'hir [Ident]),
2924
2925    /// A struct or struct-like variant literal expression.
2926    ///
2927    /// E.g., `Foo {x: 1, y: 2}`, or `Foo {x: 1, .. base}`,
2928    /// where `base` is the `Option<Expr>`.
2929    Struct(&'hir QPath<'hir>, &'hir [ExprField<'hir>], StructTailExpr<'hir>),
2930
2931    /// An array literal constructed from one repeated element.
2932    ///
2933    /// E.g., `[1; 5]`. The first expression is the element
2934    /// to be repeated; the second is the number of times to repeat it.
2935    Repeat(&'hir Expr<'hir>, &'hir ConstArg<'hir>),
2936
2937    /// A suspension point for coroutines (i.e., `yield <expr>`).
2938    Yield(&'hir Expr<'hir>, YieldSource),
2939
2940    /// Operators which can be used to interconvert `unsafe` binder types.
2941    /// e.g. `unsafe<'a> &'a i32` <=> `&i32`.
2942    UnsafeBinderCast(UnsafeBinderCastKind, &'hir Expr<'hir>, Option<&'hir Ty<'hir>>),
2943
2944    /// A placeholder for an expression that wasn't syntactically well formed in some way.
2945    Err(rustc_span::ErrorGuaranteed),
2946}
2947
2948#[derive(#[automatically_derived]
impl<'hir> ::core::fmt::Debug for StructTailExpr<'hir> {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        match self {
            StructTailExpr::None =>
                ::core::fmt::Formatter::write_str(f, "None"),
            StructTailExpr::Base(__self_0) =>
                ::core::fmt::Formatter::debug_tuple_field1_finish(f, "Base",
                    &__self_0),
            StructTailExpr::DefaultFields(__self_0) =>
                ::core::fmt::Formatter::debug_tuple_field1_finish(f,
                    "DefaultFields", &__self_0),
            StructTailExpr::NoneWithError(__self_0) =>
                ::core::fmt::Formatter::debug_tuple_field1_finish(f,
                    "NoneWithError", &__self_0),
        }
    }
}Debug, #[automatically_derived]
impl<'hir> ::core::clone::Clone for StructTailExpr<'hir> {
    #[inline]
    fn clone(&self) -> StructTailExpr<'hir> {
        let _: ::core::clone::AssertParamIsClone<&'hir Expr<'hir>>;
        let _: ::core::clone::AssertParamIsClone<Span>;
        let _: ::core::clone::AssertParamIsClone<ErrorGuaranteed>;
        *self
    }
}Clone, #[automatically_derived]
impl<'hir> ::core::marker::Copy for StructTailExpr<'hir> { }Copy, const _: () =
    {
        impl<'hir, __CTX>
            ::rustc_data_structures::stable_hasher::HashStable<__CTX> for
            StructTailExpr<'hir> where __CTX: crate::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 {
                    StructTailExpr::None => {}
                    StructTailExpr::Base(ref __binding_0) => {
                        { __binding_0.hash_stable(__hcx, __hasher); }
                    }
                    StructTailExpr::DefaultFields(ref __binding_0) => {
                        { __binding_0.hash_stable(__hcx, __hasher); }
                    }
                    StructTailExpr::NoneWithError(ref __binding_0) => {
                        { __binding_0.hash_stable(__hcx, __hasher); }
                    }
                }
            }
        }
    };HashStable_Generic)]
2949pub enum StructTailExpr<'hir> {
2950    /// A struct expression where all the fields are explicitly enumerated: `Foo { a, b }`.
2951    None,
2952    /// A struct expression with a "base", an expression of the same type as the outer struct that
2953    /// will be used to populate any fields not explicitly mentioned: `Foo { ..base }`
2954    Base(&'hir Expr<'hir>),
2955    /// A struct expression with a `..` tail but no "base" expression. The values from the struct
2956    /// fields' default values will be used to populate any fields not explicitly mentioned:
2957    /// `Foo { .. }`.
2958    DefaultFields(Span),
2959    /// No trailing `..` was written, and also, a parse error occurred inside the struct braces.
2960    ///
2961    /// This struct should be treated similarly to as if it had an `..` in it,
2962    /// in particular rather than reporting missing fields, because the parse error
2963    /// makes which fields the struct was intended to have not fully known.
2964    NoneWithError(ErrorGuaranteed),
2965}
2966
2967/// Represents an optionally `Self`-qualified value/type path or associated extension.
2968///
2969/// To resolve the path to a `DefId`, call [`qpath_res`].
2970///
2971/// [`qpath_res`]: ../../rustc_middle/ty/struct.TypeckResults.html#method.qpath_res
2972#[derive(#[automatically_derived]
impl<'hir> ::core::fmt::Debug for QPath<'hir> {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        match self {
            QPath::Resolved(__self_0, __self_1) =>
                ::core::fmt::Formatter::debug_tuple_field2_finish(f,
                    "Resolved", __self_0, &__self_1),
            QPath::TypeRelative(__self_0, __self_1) =>
                ::core::fmt::Formatter::debug_tuple_field2_finish(f,
                    "TypeRelative", __self_0, &__self_1),
        }
    }
}Debug, #[automatically_derived]
impl<'hir> ::core::clone::Clone for QPath<'hir> {
    #[inline]
    fn clone(&self) -> QPath<'hir> {
        let _: ::core::clone::AssertParamIsClone<Option<&'hir Ty<'hir>>>;
        let _: ::core::clone::AssertParamIsClone<&'hir Path<'hir>>;
        let _: ::core::clone::AssertParamIsClone<&'hir Ty<'hir>>;
        let _: ::core::clone::AssertParamIsClone<&'hir PathSegment<'hir>>;
        *self
    }
}Clone, #[automatically_derived]
impl<'hir> ::core::marker::Copy for QPath<'hir> { }Copy, const _: () =
    {
        impl<'hir, __CTX>
            ::rustc_data_structures::stable_hasher::HashStable<__CTX> for
            QPath<'hir> where __CTX: crate::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 {
                    QPath::Resolved(ref __binding_0, ref __binding_1) => {
                        { __binding_0.hash_stable(__hcx, __hasher); }
                        { __binding_1.hash_stable(__hcx, __hasher); }
                    }
                    QPath::TypeRelative(ref __binding_0, ref __binding_1) => {
                        { __binding_0.hash_stable(__hcx, __hasher); }
                        { __binding_1.hash_stable(__hcx, __hasher); }
                    }
                }
            }
        }
    };HashStable_Generic)]
2973pub enum QPath<'hir> {
2974    /// Path to a definition, optionally "fully-qualified" with a `Self`
2975    /// type, if the path points to an associated item in a trait.
2976    ///
2977    /// E.g., an unqualified path like `Clone::clone` has `None` for `Self`,
2978    /// while `<Vec<T> as Clone>::clone` has `Some(Vec<T>)` for `Self`,
2979    /// even though they both have the same two-segment `Clone::clone` `Path`.
2980    Resolved(Option<&'hir Ty<'hir>>, &'hir Path<'hir>),
2981
2982    /// Type-related paths (e.g., `<T>::default` or `<T>::Output`).
2983    /// Will be resolved by type-checking to an associated item.
2984    ///
2985    /// UFCS source paths can desugar into this, with `Vec::new` turning into
2986    /// `<Vec>::new`, and `T::X::Y::method` into `<<<T>::X>::Y>::method`,
2987    /// the `X` and `Y` nodes each being a `TyKind::Path(QPath::TypeRelative(..))`.
2988    TypeRelative(&'hir Ty<'hir>, &'hir PathSegment<'hir>),
2989}
2990
2991impl<'hir> QPath<'hir> {
2992    /// Returns the span of this `QPath`.
2993    pub fn span(&self) -> Span {
2994        match *self {
2995            QPath::Resolved(_, path) => path.span,
2996            QPath::TypeRelative(qself, ps) => qself.span.to(ps.ident.span),
2997        }
2998    }
2999
3000    /// Returns the span of the qself of this `QPath`. For example, `()` in
3001    /// `<() as Trait>::method`.
3002    pub fn qself_span(&self) -> Span {
3003        match *self {
3004            QPath::Resolved(_, path) => path.span,
3005            QPath::TypeRelative(qself, _) => qself.span,
3006        }
3007    }
3008}
3009
3010/// Hints at the original code for a let statement.
3011#[derive(#[automatically_derived]
impl ::core::marker::Copy for LocalSource { }Copy, #[automatically_derived]
impl ::core::clone::Clone for LocalSource {
    #[inline]
    fn clone(&self) -> LocalSource { *self }
}Clone, #[automatically_derived]
impl ::core::fmt::Debug for LocalSource {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::write_str(f,
            match self {
                LocalSource::Normal => "Normal",
                LocalSource::AsyncFn => "AsyncFn",
                LocalSource::AwaitDesugar => "AwaitDesugar",
                LocalSource::AssignDesugar => "AssignDesugar",
                LocalSource::Contract => "Contract",
            })
    }
}Debug, const _: () =
    {
        impl<__CTX> ::rustc_data_structures::stable_hasher::HashStable<__CTX>
            for LocalSource where __CTX: crate::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 {
                    LocalSource::Normal => {}
                    LocalSource::AsyncFn => {}
                    LocalSource::AwaitDesugar => {}
                    LocalSource::AssignDesugar => {}
                    LocalSource::Contract => {}
                }
            }
        }
    };HashStable_Generic)]
3012pub enum LocalSource {
3013    /// A `match _ { .. }`.
3014    Normal,
3015    /// When lowering async functions, we create locals within the `async move` so that
3016    /// all parameters are dropped after the future is polled.
3017    ///
3018    /// ```ignore (pseudo-Rust)
3019    /// async fn foo(<pattern> @ x: Type) {
3020    ///     async move {
3021    ///         let <pattern> = x;
3022    ///     }
3023    /// }
3024    /// ```
3025    AsyncFn,
3026    /// A desugared `<expr>.await`.
3027    AwaitDesugar,
3028    /// A desugared `expr = expr`, where the LHS is a tuple, struct, array or underscore expression.
3029    AssignDesugar,
3030    /// A contract `#[ensures(..)]` attribute injects a let binding for the check that runs at point of return.
3031    Contract,
3032}
3033
3034/// Hints at the original code for a `match _ { .. }`.
3035#[derive(#[automatically_derived]
impl ::core::marker::Copy for MatchSource { }Copy, #[automatically_derived]
impl ::core::clone::Clone for MatchSource {
    #[inline]
    fn clone(&self) -> MatchSource {
        let _: ::core::clone::AssertParamIsClone<HirId>;
        *self
    }
}Clone, #[automatically_derived]
impl ::core::cmp::PartialEq for MatchSource {
    #[inline]
    fn eq(&self, other: &MatchSource) -> bool {
        let __self_discr = ::core::intrinsics::discriminant_value(self);
        let __arg1_discr = ::core::intrinsics::discriminant_value(other);
        __self_discr == __arg1_discr &&
            match (self, other) {
                (MatchSource::TryDesugar(__self_0),
                    MatchSource::TryDesugar(__arg1_0)) => __self_0 == __arg1_0,
                _ => true,
            }
    }
}PartialEq, #[automatically_derived]
impl ::core::cmp::Eq for MatchSource {
    #[inline]
    #[doc(hidden)]
    #[coverage(off)]
    fn assert_fields_are_eq(&self) {
        let _: ::core::cmp::AssertParamIsEq<HirId>;
    }
}Eq, #[automatically_derived]
impl ::core::hash::Hash for MatchSource {
    #[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 {
            MatchSource::TryDesugar(__self_0) =>
                ::core::hash::Hash::hash(__self_0, state),
            _ => {}
        }
    }
}Hash, #[automatically_derived]
impl ::core::fmt::Debug for MatchSource {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        match self {
            MatchSource::Normal =>
                ::core::fmt::Formatter::write_str(f, "Normal"),
            MatchSource::Postfix =>
                ::core::fmt::Formatter::write_str(f, "Postfix"),
            MatchSource::ForLoopDesugar =>
                ::core::fmt::Formatter::write_str(f, "ForLoopDesugar"),
            MatchSource::TryDesugar(__self_0) =>
                ::core::fmt::Formatter::debug_tuple_field1_finish(f,
                    "TryDesugar", &__self_0),
            MatchSource::AwaitDesugar =>
                ::core::fmt::Formatter::write_str(f, "AwaitDesugar"),
            MatchSource::FormatArgs =>
                ::core::fmt::Formatter::write_str(f, "FormatArgs"),
        }
    }
}Debug, const _: () =
    {
        impl<__CTX> ::rustc_data_structures::stable_hasher::HashStable<__CTX>
            for MatchSource where __CTX: crate::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 {
                    MatchSource::Normal => {}
                    MatchSource::Postfix => {}
                    MatchSource::ForLoopDesugar => {}
                    MatchSource::TryDesugar(ref __binding_0) => {
                        { __binding_0.hash_stable(__hcx, __hasher); }
                    }
                    MatchSource::AwaitDesugar => {}
                    MatchSource::FormatArgs => {}
                }
            }
        }
    };HashStable_Generic, const _: () =
    {
        impl<__E: ::rustc_span::SpanEncoder> ::rustc_serialize::Encodable<__E>
            for MatchSource {
            fn encode(&self, __encoder: &mut __E) {
                let disc =
                    match *self {
                        MatchSource::Normal => { 0usize }
                        MatchSource::Postfix => { 1usize }
                        MatchSource::ForLoopDesugar => { 2usize }
                        MatchSource::TryDesugar(ref __binding_0) => { 3usize }
                        MatchSource::AwaitDesugar => { 4usize }
                        MatchSource::FormatArgs => { 5usize }
                    };
                ::rustc_serialize::Encoder::emit_u8(__encoder, disc as u8);
                match *self {
                    MatchSource::Normal => {}
                    MatchSource::Postfix => {}
                    MatchSource::ForLoopDesugar => {}
                    MatchSource::TryDesugar(ref __binding_0) => {
                        ::rustc_serialize::Encodable::<__E>::encode(__binding_0,
                            __encoder);
                    }
                    MatchSource::AwaitDesugar => {}
                    MatchSource::FormatArgs => {}
                }
            }
        }
    };Encodable, const _: () =
    {
        impl<__D: ::rustc_span::SpanDecoder> ::rustc_serialize::Decodable<__D>
            for MatchSource {
            fn decode(__decoder: &mut __D) -> Self {
                match ::rustc_serialize::Decoder::read_u8(__decoder) as usize
                    {
                    0usize => { MatchSource::Normal }
                    1usize => { MatchSource::Postfix }
                    2usize => { MatchSource::ForLoopDesugar }
                    3usize => {
                        MatchSource::TryDesugar(::rustc_serialize::Decodable::decode(__decoder))
                    }
                    4usize => { MatchSource::AwaitDesugar }
                    5usize => { MatchSource::FormatArgs }
                    n => {
                        ::core::panicking::panic_fmt(format_args!("invalid enum variant tag while decoding `MatchSource`, expected 0..6, actual {0}",
                                n));
                    }
                }
            }
        }
    };Decodable)]
3036pub enum MatchSource {
3037    /// A `match _ { .. }`.
3038    Normal,
3039    /// A `expr.match { .. }`.
3040    Postfix,
3041    /// A desugared `for _ in _ { .. }` loop.
3042    ForLoopDesugar,
3043    /// A desugared `?` operator.
3044    TryDesugar(HirId),
3045    /// A desugared `<expr>.await`.
3046    AwaitDesugar,
3047    /// A desugared `format_args!()`.
3048    FormatArgs,
3049}
3050
3051impl MatchSource {
3052    #[inline]
3053    pub const fn name(self) -> &'static str {
3054        use MatchSource::*;
3055        match self {
3056            Normal => "match",
3057            Postfix => ".match",
3058            ForLoopDesugar => "for",
3059            TryDesugar(_) => "?",
3060            AwaitDesugar => ".await",
3061            FormatArgs => "format_args!()",
3062        }
3063    }
3064}
3065
3066/// The loop type that yielded an `ExprKind::Loop`.
3067#[derive(#[automatically_derived]
impl ::core::marker::Copy for LoopSource { }Copy, #[automatically_derived]
impl ::core::clone::Clone for LoopSource {
    #[inline]
    fn clone(&self) -> LoopSource { *self }
}Clone, #[automatically_derived]
impl ::core::cmp::PartialEq for LoopSource {
    #[inline]
    fn eq(&self, other: &LoopSource) -> 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::fmt::Debug for LoopSource {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::write_str(f,
            match self {
                LoopSource::Loop => "Loop",
                LoopSource::While => "While",
                LoopSource::ForLoop => "ForLoop",
            })
    }
}Debug, const _: () =
    {
        impl<__CTX> ::rustc_data_structures::stable_hasher::HashStable<__CTX>
            for LoopSource where __CTX: crate::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 {
                    LoopSource::Loop => {}
                    LoopSource::While => {}
                    LoopSource::ForLoop => {}
                }
            }
        }
    };HashStable_Generic)]
3068pub enum LoopSource {
3069    /// A `loop { .. }` loop.
3070    Loop,
3071    /// A `while _ { .. }` loop.
3072    While,
3073    /// A `for _ in _ { .. }` loop.
3074    ForLoop,
3075}
3076
3077impl LoopSource {
3078    pub fn name(self) -> &'static str {
3079        match self {
3080            LoopSource::Loop => "loop",
3081            LoopSource::While => "while",
3082            LoopSource::ForLoop => "for",
3083        }
3084    }
3085}
3086
3087#[derive(#[automatically_derived]
impl ::core::marker::Copy for LoopIdError { }Copy, #[automatically_derived]
impl ::core::clone::Clone for LoopIdError {
    #[inline]
    fn clone(&self) -> LoopIdError { *self }
}Clone, #[automatically_derived]
impl ::core::fmt::Debug for LoopIdError {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::write_str(f,
            match self {
                LoopIdError::OutsideLoopScope => "OutsideLoopScope",
                LoopIdError::UnlabeledCfInWhileCondition =>
                    "UnlabeledCfInWhileCondition",
                LoopIdError::UnresolvedLabel => "UnresolvedLabel",
            })
    }
}Debug, #[automatically_derived]
impl ::core::cmp::PartialEq for LoopIdError {
    #[inline]
    fn eq(&self, other: &LoopIdError) -> bool {
        let __self_discr = ::core::intrinsics::discriminant_value(self);
        let __arg1_discr = ::core::intrinsics::discriminant_value(other);
        __self_discr == __arg1_discr
    }
}PartialEq, const _: () =
    {
        impl<__CTX> ::rustc_data_structures::stable_hasher::HashStable<__CTX>
            for LoopIdError where __CTX: crate::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 {
                    LoopIdError::OutsideLoopScope => {}
                    LoopIdError::UnlabeledCfInWhileCondition => {}
                    LoopIdError::UnresolvedLabel => {}
                }
            }
        }
    };HashStable_Generic)]
3088pub enum LoopIdError {
3089    OutsideLoopScope,
3090    UnlabeledCfInWhileCondition,
3091    UnresolvedLabel,
3092}
3093
3094impl fmt::Display for LoopIdError {
3095    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
3096        f.write_str(match self {
3097            LoopIdError::OutsideLoopScope => "not inside loop scope",
3098            LoopIdError::UnlabeledCfInWhileCondition => {
3099                "unlabeled control flow (break or continue) in while condition"
3100            }
3101            LoopIdError::UnresolvedLabel => "label not found",
3102        })
3103    }
3104}
3105
3106#[derive(#[automatically_derived]
impl ::core::marker::Copy for Destination { }Copy, #[automatically_derived]
impl ::core::clone::Clone for Destination {
    #[inline]
    fn clone(&self) -> Destination {
        let _: ::core::clone::AssertParamIsClone<Option<Label>>;
        let _: ::core::clone::AssertParamIsClone<Result<HirId, LoopIdError>>;
        *self
    }
}Clone, #[automatically_derived]
impl ::core::fmt::Debug for Destination {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::debug_struct_field2_finish(f, "Destination",
            "label", &self.label, "target_id", &&self.target_id)
    }
}Debug, #[automatically_derived]
impl ::core::cmp::PartialEq for Destination {
    #[inline]
    fn eq(&self, other: &Destination) -> bool {
        self.label == other.label && self.target_id == other.target_id
    }
}PartialEq, const _: () =
    {
        impl<__CTX> ::rustc_data_structures::stable_hasher::HashStable<__CTX>
            for Destination where __CTX: crate::HashStableContext {
            #[inline]
            fn hash_stable(&self, __hcx: &mut __CTX,
                __hasher:
                    &mut ::rustc_data_structures::stable_hasher::StableHasher) {
                match *self {
                    Destination {
                        label: ref __binding_0, target_id: ref __binding_1 } => {
                        { __binding_0.hash_stable(__hcx, __hasher); }
                        { __binding_1.hash_stable(__hcx, __hasher); }
                    }
                }
            }
        }
    };HashStable_Generic)]
3107pub struct Destination {
3108    /// This is `Some(_)` iff there is an explicit user-specified 'label
3109    pub label: Option<Label>,
3110
3111    /// These errors are caught and then reported during the diagnostics pass in
3112    /// `librustc_passes/loops.rs`
3113    pub target_id: Result<HirId, LoopIdError>,
3114}
3115
3116/// The yield kind that caused an `ExprKind::Yield`.
3117#[derive(#[automatically_derived]
impl ::core::marker::Copy for YieldSource { }Copy, #[automatically_derived]
impl ::core::clone::Clone for YieldSource {
    #[inline]
    fn clone(&self) -> YieldSource {
        let _: ::core::clone::AssertParamIsClone<Option<HirId>>;
        *self
    }
}Clone, #[automatically_derived]
impl ::core::fmt::Debug for YieldSource {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        match self {
            YieldSource::Await { expr: __self_0 } =>
                ::core::fmt::Formatter::debug_struct_field1_finish(f, "Await",
                    "expr", &__self_0),
            YieldSource::Yield =>
                ::core::fmt::Formatter::write_str(f, "Yield"),
        }
    }
}Debug, const _: () =
    {
        impl<__CTX> ::rustc_data_structures::stable_hasher::HashStable<__CTX>
            for YieldSource where __CTX: crate::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 {
                    YieldSource::Await { expr: ref __binding_0 } => {
                        { __binding_0.hash_stable(__hcx, __hasher); }
                    }
                    YieldSource::Yield => {}
                }
            }
        }
    };HashStable_Generic)]
3118pub enum YieldSource {
3119    /// An `<expr>.await`.
3120    Await { expr: Option<HirId> },
3121    /// A plain `yield`.
3122    Yield,
3123}
3124
3125impl fmt::Display for YieldSource {
3126    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
3127        f.write_str(match self {
3128            YieldSource::Await { .. } => "`await`",
3129            YieldSource::Yield => "`yield`",
3130        })
3131    }
3132}
3133
3134// N.B., if you change this, you'll probably want to change the corresponding
3135// type structure in middle/ty.rs as well.
3136#[derive(#[automatically_derived]
impl<'hir> ::core::fmt::Debug for MutTy<'hir> {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::debug_struct_field2_finish(f, "MutTy", "ty",
            &self.ty, "mutbl", &&self.mutbl)
    }
}Debug, #[automatically_derived]
impl<'hir> ::core::clone::Clone for MutTy<'hir> {
    #[inline]
    fn clone(&self) -> MutTy<'hir> {
        let _: ::core::clone::AssertParamIsClone<&'hir Ty<'hir>>;
        let _: ::core::clone::AssertParamIsClone<Mutability>;
        *self
    }
}Clone, #[automatically_derived]
impl<'hir> ::core::marker::Copy for MutTy<'hir> { }Copy, const _: () =
    {
        impl<'hir, __CTX>
            ::rustc_data_structures::stable_hasher::HashStable<__CTX> for
            MutTy<'hir> where __CTX: crate::HashStableContext {
            #[inline]
            fn hash_stable(&self, __hcx: &mut __CTX,
                __hasher:
                    &mut ::rustc_data_structures::stable_hasher::StableHasher) {
                match *self {
                    MutTy { ty: ref __binding_0, mutbl: ref __binding_1 } => {
                        { __binding_0.hash_stable(__hcx, __hasher); }
                        { __binding_1.hash_stable(__hcx, __hasher); }
                    }
                }
            }
        }
    };HashStable_Generic)]
3137pub struct MutTy<'hir> {
3138    pub ty: &'hir Ty<'hir>,
3139    pub mutbl: Mutability,
3140}
3141
3142/// Represents a function's signature in a trait declaration,
3143/// trait implementation, or a free function.
3144#[derive(#[automatically_derived]
impl<'hir> ::core::fmt::Debug for FnSig<'hir> {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::debug_struct_field3_finish(f, "FnSig",
            "header", &self.header, "decl", &self.decl, "span", &&self.span)
    }
}Debug, #[automatically_derived]
impl<'hir> ::core::clone::Clone for FnSig<'hir> {
    #[inline]
    fn clone(&self) -> FnSig<'hir> {
        let _: ::core::clone::AssertParamIsClone<FnHeader>;
        let _: ::core::clone::AssertParamIsClone<&'hir FnDecl<'hir>>;
        let _: ::core::clone::AssertParamIsClone<Span>;
        *self
    }
}Clone, #[automatically_derived]
impl<'hir> ::core::marker::Copy for FnSig<'hir> { }Copy, const _: () =
    {
        impl<'hir, __CTX>
            ::rustc_data_structures::stable_hasher::HashStable<__CTX> for
            FnSig<'hir> where __CTX: crate::HashStableContext {
            #[inline]
            fn hash_stable(&self, __hcx: &mut __CTX,
                __hasher:
                    &mut ::rustc_data_structures::stable_hasher::StableHasher) {
                match *self {
                    FnSig {
                        header: ref __binding_0,
                        decl: 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); }
                    }
                }
            }
        }
    };HashStable_Generic)]
3145pub struct FnSig<'hir> {
3146    pub header: FnHeader,
3147    pub decl: &'hir FnDecl<'hir>,
3148    pub span: Span,
3149}
3150
3151// The bodies for items are stored "out of line", in a separate
3152// hashmap in the `Crate`. Here we just record the hir-id of the item
3153// so it can fetched later.
3154#[derive(#[automatically_derived]
impl ::core::marker::Copy for TraitItemId { }Copy, #[automatically_derived]
impl ::core::clone::Clone for TraitItemId {
    #[inline]
    fn clone(&self) -> TraitItemId {
        let _: ::core::clone::AssertParamIsClone<OwnerId>;
        *self
    }
}Clone, #[automatically_derived]
impl ::core::cmp::PartialEq for TraitItemId {
    #[inline]
    fn eq(&self, other: &TraitItemId) -> bool {
        self.owner_id == other.owner_id
    }
}PartialEq, #[automatically_derived]
impl ::core::cmp::Eq for TraitItemId {
    #[inline]
    #[doc(hidden)]
    #[coverage(off)]
    fn assert_fields_are_eq(&self) {
        let _: ::core::cmp::AssertParamIsEq<OwnerId>;
    }
}Eq, const _: () =
    {
        impl<__E: ::rustc_span::SpanEncoder> ::rustc_serialize::Encodable<__E>
            for TraitItemId {
            fn encode(&self, __encoder: &mut __E) {
                match *self {
                    TraitItemId { owner_id: ref __binding_0 } => {
                        ::rustc_serialize::Encodable::<__E>::encode(__binding_0,
                            __encoder);
                    }
                }
            }
        }
    };Encodable, const _: () =
    {
        impl<__D: ::rustc_span::SpanDecoder> ::rustc_serialize::Decodable<__D>
            for TraitItemId {
            fn decode(__decoder: &mut __D) -> Self {
                TraitItemId {
                    owner_id: ::rustc_serialize::Decodable::decode(__decoder),
                }
            }
        }
    };Decodable, #[automatically_derived]
impl ::core::fmt::Debug for TraitItemId {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::debug_struct_field1_finish(f, "TraitItemId",
            "owner_id", &&self.owner_id)
    }
}Debug, const _: () =
    {
        impl<__CTX> ::rustc_data_structures::stable_hasher::HashStable<__CTX>
            for TraitItemId where __CTX: crate::HashStableContext {
            #[inline]
            fn hash_stable(&self, __hcx: &mut __CTX,
                __hasher:
                    &mut ::rustc_data_structures::stable_hasher::StableHasher) {
                match *self {
                    TraitItemId { owner_id: ref __binding_0 } => {
                        { __binding_0.hash_stable(__hcx, __hasher); }
                    }
                }
            }
        }
    };HashStable_Generic)]
3155pub struct TraitItemId {
3156    pub owner_id: OwnerId,
3157}
3158
3159impl TraitItemId {
3160    #[inline]
3161    pub fn hir_id(&self) -> HirId {
3162        // Items are always HIR owners.
3163        HirId::make_owner(self.owner_id.def_id)
3164    }
3165}
3166
3167/// Represents an item declaration within a trait declaration,
3168/// possibly including a default implementation. A trait item is
3169/// either required (meaning it doesn't have an implementation, just a
3170/// signature) or provided (meaning it has a default implementation).
3171#[derive(#[automatically_derived]
impl<'hir> ::core::fmt::Debug for TraitItem<'hir> {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        let names: &'static _ =
            &["ident", "owner_id", "generics", "kind", "span", "defaultness",
                        "has_delayed_lints"];
        let values: &[&dyn ::core::fmt::Debug] =
            &[&self.ident, &self.owner_id, &self.generics, &self.kind,
                        &self.span, &self.defaultness, &&self.has_delayed_lints];
        ::core::fmt::Formatter::debug_struct_fields_finish(f, "TraitItem",
            names, values)
    }
}Debug, #[automatically_derived]
impl<'hir> ::core::clone::Clone for TraitItem<'hir> {
    #[inline]
    fn clone(&self) -> TraitItem<'hir> {
        let _: ::core::clone::AssertParamIsClone<Ident>;
        let _: ::core::clone::AssertParamIsClone<OwnerId>;
        let _: ::core::clone::AssertParamIsClone<&'hir Generics<'hir>>;
        let _: ::core::clone::AssertParamIsClone<TraitItemKind<'hir>>;
        let _: ::core::clone::AssertParamIsClone<Span>;
        let _: ::core::clone::AssertParamIsClone<Defaultness>;
        let _: ::core::clone::AssertParamIsClone<bool>;
        *self
    }
}Clone, #[automatically_derived]
impl<'hir> ::core::marker::Copy for TraitItem<'hir> { }Copy, const _: () =
    {
        impl<'hir, __CTX>
            ::rustc_data_structures::stable_hasher::HashStable<__CTX> for
            TraitItem<'hir> where __CTX: crate::HashStableContext {
            #[inline]
            fn hash_stable(&self, __hcx: &mut __CTX,
                __hasher:
                    &mut ::rustc_data_structures::stable_hasher::StableHasher) {
                match *self {
                    TraitItem {
                        ident: ref __binding_0,
                        owner_id: ref __binding_1,
                        generics: ref __binding_2,
                        kind: ref __binding_3,
                        span: ref __binding_4,
                        defaultness: ref __binding_5,
                        has_delayed_lints: ref __binding_6 } => {
                        { __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); }
                        { __binding_5.hash_stable(__hcx, __hasher); }
                        { __binding_6.hash_stable(__hcx, __hasher); }
                    }
                }
            }
        }
    };HashStable_Generic)]
3172pub struct TraitItem<'hir> {
3173    pub ident: Ident,
3174    pub owner_id: OwnerId,
3175    pub generics: &'hir Generics<'hir>,
3176    pub kind: TraitItemKind<'hir>,
3177    pub span: Span,
3178    pub defaultness: Defaultness,
3179    pub has_delayed_lints: bool,
3180}
3181
3182macro_rules! expect_methods_self_kind {
3183    ( $( $name:ident, $ret_ty:ty, $pat:pat, $ret_val:expr; )* ) => {
3184        $(
3185            #[track_caller]
3186            pub fn $name(&self) -> $ret_ty {
3187                let $pat = &self.kind else { expect_failed(stringify!($name), self) };
3188                $ret_val
3189            }
3190        )*
3191    }
3192}
3193
3194macro_rules! expect_methods_self {
3195    ( $( $name:ident, $ret_ty:ty, $pat:pat, $ret_val:expr; )* ) => {
3196        $(
3197            #[track_caller]
3198            pub fn $name(&self) -> $ret_ty {
3199                let $pat = self else { expect_failed(stringify!($name), self) };
3200                $ret_val
3201            }
3202        )*
3203    }
3204}
3205
3206#[track_caller]
3207fn expect_failed<T: fmt::Debug>(ident: &'static str, found: T) -> ! {
3208    {
    ::core::panicking::panic_fmt(format_args!("{0}: found {1:?}", ident,
            found));
}panic!("{ident}: found {found:?}")
3209}
3210
3211impl<'hir> TraitItem<'hir> {
3212    #[inline]
3213    pub fn hir_id(&self) -> HirId {
3214        // Items are always HIR owners.
3215        HirId::make_owner(self.owner_id.def_id)
3216    }
3217
3218    pub fn trait_item_id(&self) -> TraitItemId {
3219        TraitItemId { owner_id: self.owner_id }
3220    }
3221
3222    self
let TraitItemKind::Type(bounds, ty) =
    &self.kind else { expect_failed("expect_type", self) };
(bounds, *ty);expect_methods_self_kind! {
3223        expect_const, (&'hir Ty<'hir>, Option<ConstItemRhs<'hir>>),
3224            TraitItemKind::Const(ty, rhs, _), (ty, *rhs);
3225
3226        expect_fn, (&FnSig<'hir>, &TraitFn<'hir>),
3227            TraitItemKind::Fn(ty, trfn), (ty, trfn);
3228
3229        expect_type, (GenericBounds<'hir>, Option<&'hir Ty<'hir>>),
3230            TraitItemKind::Type(bounds, ty), (bounds, *ty);
3231    }
3232}
3233
3234/// Represents a trait method's body (or just argument names).
3235#[derive(#[automatically_derived]
impl<'hir> ::core::fmt::Debug for TraitFn<'hir> {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        match self {
            TraitFn::Required(__self_0) =>
                ::core::fmt::Formatter::debug_tuple_field1_finish(f,
                    "Required", &__self_0),
            TraitFn::Provided(__self_0) =>
                ::core::fmt::Formatter::debug_tuple_field1_finish(f,
                    "Provided", &__self_0),
        }
    }
}Debug, #[automatically_derived]
impl<'hir> ::core::clone::Clone for TraitFn<'hir> {
    #[inline]
    fn clone(&self) -> TraitFn<'hir> {
        let _: ::core::clone::AssertParamIsClone<&'hir [Option<Ident>]>;
        let _: ::core::clone::AssertParamIsClone<BodyId>;
        *self
    }
}Clone, #[automatically_derived]
impl<'hir> ::core::marker::Copy for TraitFn<'hir> { }Copy, const _: () =
    {
        impl<'hir, __CTX>
            ::rustc_data_structures::stable_hasher::HashStable<__CTX> for
            TraitFn<'hir> where __CTX: crate::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 {
                    TraitFn::Required(ref __binding_0) => {
                        { __binding_0.hash_stable(__hcx, __hasher); }
                    }
                    TraitFn::Provided(ref __binding_0) => {
                        { __binding_0.hash_stable(__hcx, __hasher); }
                    }
                }
            }
        }
    };HashStable_Generic)]
3236pub enum TraitFn<'hir> {
3237    /// No default body in the trait, just a signature.
3238    Required(&'hir [Option<Ident>]),
3239
3240    /// Both signature and body are provided in the trait.
3241    Provided(BodyId),
3242}
3243
3244#[derive(#[automatically_derived]
impl ::core::fmt::Debug for IsTypeConst {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::write_str(f,
            match self {
                IsTypeConst::No => "No",
                IsTypeConst::Yes => "Yes",
            })
    }
}Debug, #[automatically_derived]
impl ::core::clone::Clone for IsTypeConst {
    #[inline]
    fn clone(&self) -> IsTypeConst { *self }
}Clone, #[automatically_derived]
impl ::core::marker::Copy for IsTypeConst { }Copy, #[automatically_derived]
impl ::core::cmp::PartialEq for IsTypeConst {
    #[inline]
    fn eq(&self, other: &IsTypeConst) -> 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 IsTypeConst {
    #[inline]
    #[doc(hidden)]
    #[coverage(off)]
    fn assert_fields_are_eq(&self) {}
}Eq, const _: () =
    {
        impl<__CTX> ::rustc_data_structures::stable_hasher::HashStable<__CTX>
            for IsTypeConst where __CTX: crate::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 { IsTypeConst::No => {} IsTypeConst::Yes => {} }
            }
        }
    };HashStable_Generic)]
3245pub enum IsTypeConst {
3246    No,
3247    Yes,
3248}
3249
3250impl From<bool> for IsTypeConst {
3251    fn from(value: bool) -> Self {
3252        if value { Self::Yes } else { Self::No }
3253    }
3254}
3255
3256impl From<IsTypeConst> for bool {
3257    fn from(value: IsTypeConst) -> Self {
3258        #[allow(non_exhaustive_omitted_patterns)] match value {
    IsTypeConst::Yes => true,
    _ => false,
}matches!(value, IsTypeConst::Yes)
3259    }
3260}
3261
3262/// Represents a trait method or associated constant or type
3263#[derive(#[automatically_derived]
impl<'hir> ::core::fmt::Debug for TraitItemKind<'hir> {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        match self {
            TraitItemKind::Const(__self_0, __self_1, __self_2) =>
                ::core::fmt::Formatter::debug_tuple_field3_finish(f, "Const",
                    __self_0, __self_1, &__self_2),
            TraitItemKind::Fn(__self_0, __self_1) =>
                ::core::fmt::Formatter::debug_tuple_field2_finish(f, "Fn",
                    __self_0, &__self_1),
            TraitItemKind::Type(__self_0, __self_1) =>
                ::core::fmt::Formatter::debug_tuple_field2_finish(f, "Type",
                    __self_0, &__self_1),
        }
    }
}Debug, #[automatically_derived]
impl<'hir> ::core::clone::Clone for TraitItemKind<'hir> {
    #[inline]
    fn clone(&self) -> TraitItemKind<'hir> {
        let _: ::core::clone::AssertParamIsClone<&'hir Ty<'hir>>;
        let _: ::core::clone::AssertParamIsClone<Option<ConstItemRhs<'hir>>>;
        let _: ::core::clone::AssertParamIsClone<IsTypeConst>;
        let _: ::core::clone::AssertParamIsClone<FnSig<'hir>>;
        let _: ::core::clone::AssertParamIsClone<TraitFn<'hir>>;
        let _: ::core::clone::AssertParamIsClone<GenericBounds<'hir>>;
        let _: ::core::clone::AssertParamIsClone<Option<&'hir Ty<'hir>>>;
        *self
    }
}Clone, #[automatically_derived]
impl<'hir> ::core::marker::Copy for TraitItemKind<'hir> { }Copy, const _: () =
    {
        impl<'hir, __CTX>
            ::rustc_data_structures::stable_hasher::HashStable<__CTX> for
            TraitItemKind<'hir> where __CTX: crate::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 {
                    TraitItemKind::Const(ref __binding_0, ref __binding_1,
                        ref __binding_2) => {
                        { __binding_0.hash_stable(__hcx, __hasher); }
                        { __binding_1.hash_stable(__hcx, __hasher); }
                        { __binding_2.hash_stable(__hcx, __hasher); }
                    }
                    TraitItemKind::Fn(ref __binding_0, ref __binding_1) => {
                        { __binding_0.hash_stable(__hcx, __hasher); }
                        { __binding_1.hash_stable(__hcx, __hasher); }
                    }
                    TraitItemKind::Type(ref __binding_0, ref __binding_1) => {
                        { __binding_0.hash_stable(__hcx, __hasher); }
                        { __binding_1.hash_stable(__hcx, __hasher); }
                    }
                }
            }
        }
    };HashStable_Generic)]
3264pub enum TraitItemKind<'hir> {
3265    // FIXME(mgca) eventually want to move the option that is around `ConstItemRhs<'hir>`
3266    // into `ConstItemRhs`, much like `ast::ConstItemRhsKind`, but for now mark whether
3267    // this node is a TypeConst with a flag.
3268    /// An associated constant with an optional value (otherwise `impl`s must contain a value).
3269    Const(&'hir Ty<'hir>, Option<ConstItemRhs<'hir>>, IsTypeConst),
3270    /// An associated function with an optional body.
3271    Fn(FnSig<'hir>, TraitFn<'hir>),
3272    /// An associated type with (possibly empty) bounds and optional concrete
3273    /// type.
3274    Type(GenericBounds<'hir>, Option<&'hir Ty<'hir>>),
3275}
3276
3277// The bodies for items are stored "out of line", in a separate
3278// hashmap in the `Crate`. Here we just record the hir-id of the item
3279// so it can fetched later.
3280#[derive(#[automatically_derived]
impl ::core::marker::Copy for ImplItemId { }Copy, #[automatically_derived]
impl ::core::clone::Clone for ImplItemId {
    #[inline]
    fn clone(&self) -> ImplItemId {
        let _: ::core::clone::AssertParamIsClone<OwnerId>;
        *self
    }
}Clone, #[automatically_derived]
impl ::core::cmp::PartialEq for ImplItemId {
    #[inline]
    fn eq(&self, other: &ImplItemId) -> bool {
        self.owner_id == other.owner_id
    }
}PartialEq, #[automatically_derived]
impl ::core::cmp::Eq for ImplItemId {
    #[inline]
    #[doc(hidden)]
    #[coverage(off)]
    fn assert_fields_are_eq(&self) {
        let _: ::core::cmp::AssertParamIsEq<OwnerId>;
    }
}Eq, const _: () =
    {
        impl<__E: ::rustc_span::SpanEncoder> ::rustc_serialize::Encodable<__E>
            for ImplItemId {
            fn encode(&self, __encoder: &mut __E) {
                match *self {
                    ImplItemId { owner_id: ref __binding_0 } => {
                        ::rustc_serialize::Encodable::<__E>::encode(__binding_0,
                            __encoder);
                    }
                }
            }
        }
    };Encodable, const _: () =
    {
        impl<__D: ::rustc_span::SpanDecoder> ::rustc_serialize::Decodable<__D>
            for ImplItemId {
            fn decode(__decoder: &mut __D) -> Self {
                ImplItemId {
                    owner_id: ::rustc_serialize::Decodable::decode(__decoder),
                }
            }
        }
    };Decodable, #[automatically_derived]
impl ::core::fmt::Debug for ImplItemId {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::debug_struct_field1_finish(f, "ImplItemId",
            "owner_id", &&self.owner_id)
    }
}Debug, const _: () =
    {
        impl<__CTX> ::rustc_data_structures::stable_hasher::HashStable<__CTX>
            for ImplItemId where __CTX: crate::HashStableContext {
            #[inline]
            fn hash_stable(&self, __hcx: &mut __CTX,
                __hasher:
                    &mut ::rustc_data_structures::stable_hasher::StableHasher) {
                match *self {
                    ImplItemId { owner_id: ref __binding_0 } => {
                        { __binding_0.hash_stable(__hcx, __hasher); }
                    }
                }
            }
        }
    };HashStable_Generic)]
3281pub struct ImplItemId {
3282    pub owner_id: OwnerId,
3283}
3284
3285impl ImplItemId {
3286    #[inline]
3287    pub fn hir_id(&self) -> HirId {
3288        // Items are always HIR owners.
3289        HirId::make_owner(self.owner_id.def_id)
3290    }
3291}
3292
3293/// Represents an associated item within an impl block.
3294///
3295/// Refer to [`Impl`] for an impl block declaration.
3296#[derive(#[automatically_derived]
impl<'hir> ::core::fmt::Debug for ImplItem<'hir> {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        let names: &'static _ =
            &["ident", "owner_id", "generics", "kind", "impl_kind", "span",
                        "has_delayed_lints"];
        let values: &[&dyn ::core::fmt::Debug] =
            &[&self.ident, &self.owner_id, &self.generics, &self.kind,
                        &self.impl_kind, &self.span, &&self.has_delayed_lints];
        ::core::fmt::Formatter::debug_struct_fields_finish(f, "ImplItem",
            names, values)
    }
}Debug, #[automatically_derived]
impl<'hir> ::core::clone::Clone for ImplItem<'hir> {
    #[inline]
    fn clone(&self) -> ImplItem<'hir> {
        let _: ::core::clone::AssertParamIsClone<Ident>;
        let _: ::core::clone::AssertParamIsClone<OwnerId>;
        let _: ::core::clone::AssertParamIsClone<&'hir Generics<'hir>>;
        let _: ::core::clone::AssertParamIsClone<ImplItemKind<'hir>>;
        let _: ::core::clone::AssertParamIsClone<ImplItemImplKind>;
        let _: ::core::clone::AssertParamIsClone<Span>;
        let _: ::core::clone::AssertParamIsClone<bool>;
        *self
    }
}Clone, #[automatically_derived]
impl<'hir> ::core::marker::Copy for ImplItem<'hir> { }Copy, const _: () =
    {
        impl<'hir, __CTX>
            ::rustc_data_structures::stable_hasher::HashStable<__CTX> for
            ImplItem<'hir> where __CTX: crate::HashStableContext {
            #[inline]
            fn hash_stable(&self, __hcx: &mut __CTX,
                __hasher:
                    &mut ::rustc_data_structures::stable_hasher::StableHasher) {
                match *self {
                    ImplItem {
                        ident: ref __binding_0,
                        owner_id: ref __binding_1,
                        generics: ref __binding_2,
                        kind: ref __binding_3,
                        impl_kind: ref __binding_4,
                        span: ref __binding_5,
                        has_delayed_lints: ref __binding_6 } => {
                        { __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); }
                        { __binding_5.hash_stable(__hcx, __hasher); }
                        { __binding_6.hash_stable(__hcx, __hasher); }
                    }
                }
            }
        }
    };HashStable_Generic)]
3297pub struct ImplItem<'hir> {
3298    pub ident: Ident,
3299    pub owner_id: OwnerId,
3300    pub generics: &'hir Generics<'hir>,
3301    pub kind: ImplItemKind<'hir>,
3302    pub impl_kind: ImplItemImplKind,
3303    pub span: Span,
3304    pub has_delayed_lints: bool,
3305}
3306
3307#[derive(#[automatically_derived]
impl ::core::fmt::Debug for ImplItemImplKind {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        match self {
            ImplItemImplKind::Inherent { vis_span: __self_0 } =>
                ::core::fmt::Formatter::debug_struct_field1_finish(f,
                    "Inherent", "vis_span", &__self_0),
            ImplItemImplKind::Trait {
                defaultness: __self_0, trait_item_def_id: __self_1 } =>
                ::core::fmt::Formatter::debug_struct_field2_finish(f, "Trait",
                    "defaultness", __self_0, "trait_item_def_id", &__self_1),
        }
    }
}Debug, #[automatically_derived]
impl ::core::clone::Clone for ImplItemImplKind {
    #[inline]
    fn clone(&self) -> ImplItemImplKind {
        let _: ::core::clone::AssertParamIsClone<Span>;
        let _: ::core::clone::AssertParamIsClone<Defaultness>;
        let _:
                ::core::clone::AssertParamIsClone<Result<DefId,
                ErrorGuaranteed>>;
        *self
    }
}Clone, #[automatically_derived]
impl ::core::marker::Copy for ImplItemImplKind { }Copy, const _: () =
    {
        impl<__CTX> ::rustc_data_structures::stable_hasher::HashStable<__CTX>
            for ImplItemImplKind where __CTX: crate::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 {
                    ImplItemImplKind::Inherent { vis_span: ref __binding_0 } =>
                        {
                        { __binding_0.hash_stable(__hcx, __hasher); }
                    }
                    ImplItemImplKind::Trait {
                        defaultness: ref __binding_0,
                        trait_item_def_id: ref __binding_1 } => {
                        { __binding_0.hash_stable(__hcx, __hasher); }
                        { __binding_1.hash_stable(__hcx, __hasher); }
                    }
                }
            }
        }
    };HashStable_Generic)]
3308pub enum ImplItemImplKind {
3309    Inherent {
3310        vis_span: Span,
3311    },
3312    Trait {
3313        defaultness: Defaultness,
3314        /// Item in the trait that this item implements
3315        trait_item_def_id: Result<DefId, ErrorGuaranteed>,
3316    },
3317}
3318
3319impl<'hir> ImplItem<'hir> {
3320    #[inline]
3321    pub fn hir_id(&self) -> HirId {
3322        // Items are always HIR owners.
3323        HirId::make_owner(self.owner_id.def_id)
3324    }
3325
3326    pub fn impl_item_id(&self) -> ImplItemId {
3327        ImplItemId { owner_id: self.owner_id }
3328    }
3329
3330    pub fn vis_span(&self) -> Option<Span> {
3331        match self.impl_kind {
3332            ImplItemImplKind::Trait { .. } => None,
3333            ImplItemImplKind::Inherent { vis_span, .. } => Some(vis_span),
3334        }
3335    }
3336
3337    self
let ImplItemKind::Type(ty) =
    &self.kind else { expect_failed("expect_type", self) };
ty;expect_methods_self_kind! {
3338        expect_const, (&'hir Ty<'hir>, ConstItemRhs<'hir>), ImplItemKind::Const(ty, rhs), (ty, *rhs);
3339        expect_fn,    (&FnSig<'hir>, BodyId),               ImplItemKind::Fn(ty, body),   (ty, *body);
3340        expect_type,  &'hir Ty<'hir>,                       ImplItemKind::Type(ty),       ty;
3341    }
3342}
3343
3344/// Represents various kinds of content within an `impl`.
3345#[derive(#[automatically_derived]
impl<'hir> ::core::fmt::Debug for ImplItemKind<'hir> {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        match self {
            ImplItemKind::Const(__self_0, __self_1) =>
                ::core::fmt::Formatter::debug_tuple_field2_finish(f, "Const",
                    __self_0, &__self_1),
            ImplItemKind::Fn(__self_0, __self_1) =>
                ::core::fmt::Formatter::debug_tuple_field2_finish(f, "Fn",
                    __self_0, &__self_1),
            ImplItemKind::Type(__self_0) =>
                ::core::fmt::Formatter::debug_tuple_field1_finish(f, "Type",
                    &__self_0),
        }
    }
}Debug, #[automatically_derived]
impl<'hir> ::core::clone::Clone for ImplItemKind<'hir> {
    #[inline]
    fn clone(&self) -> ImplItemKind<'hir> {
        let _: ::core::clone::AssertParamIsClone<&'hir Ty<'hir>>;
        let _: ::core::clone::AssertParamIsClone<ConstItemRhs<'hir>>;
        let _: ::core::clone::AssertParamIsClone<FnSig<'hir>>;
        let _: ::core::clone::AssertParamIsClone<BodyId>;
        let _: ::core::clone::AssertParamIsClone<&'hir Ty<'hir>>;
        *self
    }
}Clone, #[automatically_derived]
impl<'hir> ::core::marker::Copy for ImplItemKind<'hir> { }Copy, const _: () =
    {
        impl<'hir, __CTX>
            ::rustc_data_structures::stable_hasher::HashStable<__CTX> for
            ImplItemKind<'hir> where __CTX: crate::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 {
                    ImplItemKind::Const(ref __binding_0, ref __binding_1) => {
                        { __binding_0.hash_stable(__hcx, __hasher); }
                        { __binding_1.hash_stable(__hcx, __hasher); }
                    }
                    ImplItemKind::Fn(ref __binding_0, ref __binding_1) => {
                        { __binding_0.hash_stable(__hcx, __hasher); }
                        { __binding_1.hash_stable(__hcx, __hasher); }
                    }
                    ImplItemKind::Type(ref __binding_0) => {
                        { __binding_0.hash_stable(__hcx, __hasher); }
                    }
                }
            }
        }
    };HashStable_Generic)]
3346pub enum ImplItemKind<'hir> {
3347    /// An associated constant of the given type, set to the constant result
3348    /// of the expression.
3349    Const(&'hir Ty<'hir>, ConstItemRhs<'hir>),
3350    /// An associated function implementation with the given signature and body.
3351    Fn(FnSig<'hir>, BodyId),
3352    /// An associated type.
3353    Type(&'hir Ty<'hir>),
3354}
3355
3356/// A constraint on an associated item.
3357///
3358/// ### Examples
3359///
3360/// * the `A = Ty` and `B = Ty` in `Trait<A = Ty, B = Ty>`
3361/// * the `G<Ty> = Ty` in `Trait<G<Ty> = Ty>`
3362/// * the `A: Bound` in `Trait<A: Bound>`
3363/// * the `RetTy` in `Trait(ArgTy, ArgTy) -> RetTy`
3364/// * the `C = { Ct }` in `Trait<C = { Ct }>` (feature `min_generic_const_args`)
3365/// * the `f(..): Bound` in `Trait<f(..): Bound>` (feature `return_type_notation`)
3366#[derive(#[automatically_derived]
impl<'hir> ::core::fmt::Debug for AssocItemConstraint<'hir> {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::debug_struct_field5_finish(f,
            "AssocItemConstraint", "hir_id", &self.hir_id, "ident",
            &self.ident, "gen_args", &self.gen_args, "kind", &self.kind,
            "span", &&self.span)
    }
}Debug, #[automatically_derived]
impl<'hir> ::core::clone::Clone for AssocItemConstraint<'hir> {
    #[inline]
    fn clone(&self) -> AssocItemConstraint<'hir> {
        let _: ::core::clone::AssertParamIsClone<HirId>;
        let _: ::core::clone::AssertParamIsClone<Ident>;
        let _: ::core::clone::AssertParamIsClone<&'hir GenericArgs<'hir>>;
        let _:
                ::core::clone::AssertParamIsClone<AssocItemConstraintKind<'hir>>;
        let _: ::core::clone::AssertParamIsClone<Span>;
        *self
    }
}Clone, #[automatically_derived]
impl<'hir> ::core::marker::Copy for AssocItemConstraint<'hir> { }Copy, const _: () =
    {
        impl<'hir, __CTX>
            ::rustc_data_structures::stable_hasher::HashStable<__CTX> for
            AssocItemConstraint<'hir> where __CTX: crate::HashStableContext {
            #[inline]
            fn hash_stable(&self, __hcx: &mut __CTX,
                __hasher:
                    &mut ::rustc_data_structures::stable_hasher::StableHasher) {
                match *self {
                    AssocItemConstraint {
                        hir_id: ref __binding_0,
                        ident: ref __binding_1,
                        gen_args: ref __binding_2,
                        kind: ref __binding_3,
                        span: ref __binding_4 } => {
                        {}
                        { __binding_1.hash_stable(__hcx, __hasher); }
                        { __binding_2.hash_stable(__hcx, __hasher); }
                        { __binding_3.hash_stable(__hcx, __hasher); }
                        { __binding_4.hash_stable(__hcx, __hasher); }
                    }
                }
            }
        }
    };HashStable_Generic)]
3367pub struct AssocItemConstraint<'hir> {
3368    #[stable_hasher(ignore)]
3369    pub hir_id: HirId,
3370    pub ident: Ident,
3371    pub gen_args: &'hir GenericArgs<'hir>,
3372    pub kind: AssocItemConstraintKind<'hir>,
3373    pub span: Span,
3374}
3375
3376impl<'hir> AssocItemConstraint<'hir> {
3377    /// Obtain the type on the RHS of an assoc ty equality constraint if applicable.
3378    pub fn ty(self) -> Option<&'hir Ty<'hir>> {
3379        match self.kind {
3380            AssocItemConstraintKind::Equality { term: Term::Ty(ty) } => Some(ty),
3381            _ => None,
3382        }
3383    }
3384
3385    /// Obtain the const on the RHS of an assoc const equality constraint if applicable.
3386    pub fn ct(self) -> Option<&'hir ConstArg<'hir>> {
3387        match self.kind {
3388            AssocItemConstraintKind::Equality { term: Term::Const(ct) } => Some(ct),
3389            _ => None,
3390        }
3391    }
3392}
3393
3394#[derive(#[automatically_derived]
impl<'hir> ::core::fmt::Debug for Term<'hir> {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        match self {
            Term::Ty(__self_0) =>
                ::core::fmt::Formatter::debug_tuple_field1_finish(f, "Ty",
                    &__self_0),
            Term::Const(__self_0) =>
                ::core::fmt::Formatter::debug_tuple_field1_finish(f, "Const",
                    &__self_0),
        }
    }
}Debug, #[automatically_derived]
impl<'hir> ::core::clone::Clone for Term<'hir> {
    #[inline]
    fn clone(&self) -> Term<'hir> {
        let _: ::core::clone::AssertParamIsClone<&'hir Ty<'hir>>;
        let _: ::core::clone::AssertParamIsClone<&'hir ConstArg<'hir>>;
        *self
    }
}Clone, #[automatically_derived]
impl<'hir> ::core::marker::Copy for Term<'hir> { }Copy, const _: () =
    {
        impl<'hir, __CTX>
            ::rustc_data_structures::stable_hasher::HashStable<__CTX> for
            Term<'hir> where __CTX: crate::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 {
                    Term::Ty(ref __binding_0) => {
                        { __binding_0.hash_stable(__hcx, __hasher); }
                    }
                    Term::Const(ref __binding_0) => {
                        { __binding_0.hash_stable(__hcx, __hasher); }
                    }
                }
            }
        }
    };HashStable_Generic)]
3395pub enum Term<'hir> {
3396    Ty(&'hir Ty<'hir>),
3397    Const(&'hir ConstArg<'hir>),
3398}
3399
3400impl<'hir> From<&'hir Ty<'hir>> for Term<'hir> {
3401    fn from(ty: &'hir Ty<'hir>) -> Self {
3402        Term::Ty(ty)
3403    }
3404}
3405
3406impl<'hir> From<&'hir ConstArg<'hir>> for Term<'hir> {
3407    fn from(c: &'hir ConstArg<'hir>) -> Self {
3408        Term::Const(c)
3409    }
3410}
3411
3412/// The kind of [associated item constraint][AssocItemConstraint].
3413#[derive(#[automatically_derived]
impl<'hir> ::core::fmt::Debug for AssocItemConstraintKind<'hir> {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        match self {
            AssocItemConstraintKind::Equality { term: __self_0 } =>
                ::core::fmt::Formatter::debug_struct_field1_finish(f,
                    "Equality", "term", &__self_0),
            AssocItemConstraintKind::Bound { bounds: __self_0 } =>
                ::core::fmt::Formatter::debug_struct_field1_finish(f, "Bound",
                    "bounds", &__self_0),
        }
    }
}Debug, #[automatically_derived]
impl<'hir> ::core::clone::Clone for AssocItemConstraintKind<'hir> {
    #[inline]
    fn clone(&self) -> AssocItemConstraintKind<'hir> {
        let _: ::core::clone::AssertParamIsClone<Term<'hir>>;
        let _: ::core::clone::AssertParamIsClone<&'hir [GenericBound<'hir>]>;
        *self
    }
}Clone, #[automatically_derived]
impl<'hir> ::core::marker::Copy for AssocItemConstraintKind<'hir> { }Copy, const _: () =
    {
        impl<'hir, __CTX>
            ::rustc_data_structures::stable_hasher::HashStable<__CTX> for
            AssocItemConstraintKind<'hir> where
            __CTX: crate::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 {
                    AssocItemConstraintKind::Equality { term: ref __binding_0 }
                        => {
                        { __binding_0.hash_stable(__hcx, __hasher); }
                    }
                    AssocItemConstraintKind::Bound { bounds: ref __binding_0 }
                        => {
                        { __binding_0.hash_stable(__hcx, __hasher); }
                    }
                }
            }
        }
    };HashStable_Generic)]
3414pub enum AssocItemConstraintKind<'hir> {
3415    /// An equality constraint for an associated item (e.g., `AssocTy = Ty` in `Trait<AssocTy = Ty>`).
3416    ///
3417    /// Also known as an *associated item binding* (we *bind* an associated item to a term).
3418    ///
3419    /// Furthermore, associated type equality constraints can also be referred to as *associated type
3420    /// bindings*. Similarly with associated const equality constraints and *associated const bindings*.
3421    Equality { term: Term<'hir> },
3422    /// A bound on an associated type (e.g., `AssocTy: Bound` in `Trait<AssocTy: Bound>`).
3423    Bound { bounds: &'hir [GenericBound<'hir>] },
3424}
3425
3426impl<'hir> AssocItemConstraintKind<'hir> {
3427    pub fn descr(&self) -> &'static str {
3428        match self {
3429            AssocItemConstraintKind::Equality { .. } => "binding",
3430            AssocItemConstraintKind::Bound { .. } => "constraint",
3431        }
3432    }
3433}
3434
3435/// An uninhabited enum used to make `Infer` variants on [`Ty`] and [`ConstArg`] be
3436/// unreachable. Zero-Variant enums are guaranteed to have the same layout as the never
3437/// type.
3438#[derive(#[automatically_derived]
impl ::core::fmt::Debug for AmbigArg {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        match *self {}
    }
}Debug, #[automatically_derived]
impl ::core::clone::Clone for AmbigArg {
    #[inline]
    fn clone(&self) -> AmbigArg { *self }
}Clone, #[automatically_derived]
impl ::core::marker::Copy for AmbigArg { }Copy, const _: () =
    {
        impl<__CTX> ::rustc_data_structures::stable_hasher::HashStable<__CTX>
            for AmbigArg where __CTX: crate::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 {}
            }
        }
    };HashStable_Generic)]
3439pub enum AmbigArg {}
3440
3441/// Represents a type in the `HIR`.
3442///
3443/// For an explanation of the `Unambig` generic parameter see the dev-guide:
3444/// <https://rustc-dev-guide.rust-lang.org/ambig-unambig-ty-and-consts.html>
3445#[derive(#[automatically_derived]
impl<'hir, Unambig: ::core::fmt::Debug> ::core::fmt::Debug for
    Ty<'hir, Unambig> {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::debug_struct_field3_finish(f, "Ty", "hir_id",
            &self.hir_id, "span", &self.span, "kind", &&self.kind)
    }
}Debug, #[automatically_derived]
impl<'hir, Unambig: ::core::clone::Clone> ::core::clone::Clone for
    Ty<'hir, Unambig> {
    #[inline]
    fn clone(&self) -> Ty<'hir, Unambig> {
        Ty {
            hir_id: ::core::clone::Clone::clone(&self.hir_id),
            span: ::core::clone::Clone::clone(&self.span),
            kind: ::core::clone::Clone::clone(&self.kind),
        }
    }
}Clone, #[automatically_derived]
impl<'hir, Unambig: ::core::marker::Copy> ::core::marker::Copy for
    Ty<'hir, Unambig> {
}Copy, const _: () =
    {
        impl<'hir, Unambig, __CTX>
            ::rustc_data_structures::stable_hasher::HashStable<__CTX> for
            Ty<'hir, Unambig> where __CTX: crate::HashStableContext,
            Unambig: ::rustc_data_structures::stable_hasher::HashStable<__CTX>
            {
            #[inline]
            fn hash_stable(&self, __hcx: &mut __CTX,
                __hasher:
                    &mut ::rustc_data_structures::stable_hasher::StableHasher) {
                match *self {
                    Ty {
                        hir_id: ref __binding_0,
                        span: ref __binding_1,
                        kind: ref __binding_2 } => {
                        {}
                        { __binding_1.hash_stable(__hcx, __hasher); }
                        { __binding_2.hash_stable(__hcx, __hasher); }
                    }
                }
            }
        }
    };HashStable_Generic)]
3446#[repr(C)]
3447pub struct Ty<'hir, Unambig = ()> {
3448    #[stable_hasher(ignore)]
3449    pub hir_id: HirId,
3450    pub span: Span,
3451    pub kind: TyKind<'hir, Unambig>,
3452}
3453
3454impl<'hir> Ty<'hir, AmbigArg> {
3455    /// Converts a `Ty` in an ambiguous position to one in an unambiguous position.
3456    ///
3457    /// Functions accepting an unambiguous types may expect the [`TyKind::Infer`] variant
3458    /// to be used. Care should be taken to separately handle infer types when calling this
3459    /// function as it cannot be handled by downstream code making use of the returned ty.
3460    ///
3461    /// In practice this may mean overriding the [`Visitor::visit_infer`][visit_infer] method on hir visitors, or
3462    /// specifically matching on [`GenericArg::Infer`] when handling generic arguments.
3463    ///
3464    /// [visit_infer]: [rustc_hir::intravisit::Visitor::visit_infer]
3465    pub fn as_unambig_ty(&self) -> &Ty<'hir> {
3466        // SAFETY: `Ty` is `repr(C)` and `TyKind` is marked `repr(u8)` so that the layout is
3467        // the same across different ZST type arguments.
3468        let ptr = self as *const Ty<'hir, AmbigArg> as *const Ty<'hir, ()>;
3469        unsafe { &*ptr }
3470    }
3471}
3472
3473impl<'hir> Ty<'hir> {
3474    /// Converts a `Ty` in an unambiguous position to one in an ambiguous position. This is
3475    /// fallible as the [`TyKind::Infer`] variant is not present in ambiguous positions.
3476    ///
3477    /// Functions accepting ambiguous types will not handle the [`TyKind::Infer`] variant, if
3478    /// infer types are relevant to you then care should be taken to handle them separately.
3479    pub fn try_as_ambig_ty(&self) -> Option<&Ty<'hir, AmbigArg>> {
3480        if let TyKind::Infer(()) = self.kind {
3481            return None;
3482        }
3483
3484        // SAFETY: `Ty` is `repr(C)` and `TyKind` is marked `repr(u8)` so that the layout is
3485        // the same across different ZST type arguments. We also asserted that the `self` is
3486        // not a `TyKind::Infer` so there is no risk of transmuting a `()` to `AmbigArg`.
3487        let ptr = self as *const Ty<'hir> as *const Ty<'hir, AmbigArg>;
3488        Some(unsafe { &*ptr })
3489    }
3490}
3491
3492impl<'hir> Ty<'hir, AmbigArg> {
3493    pub fn peel_refs(&self) -> &Ty<'hir> {
3494        let mut final_ty = self.as_unambig_ty();
3495        while let TyKind::Ref(_, MutTy { ty, .. }) = &final_ty.kind {
3496            final_ty = ty;
3497        }
3498        final_ty
3499    }
3500}
3501
3502impl<'hir> Ty<'hir> {
3503    pub fn peel_refs(&self) -> &Self {
3504        let mut final_ty = self;
3505        while let TyKind::Ref(_, MutTy { ty, .. }) = &final_ty.kind {
3506            final_ty = ty;
3507        }
3508        final_ty
3509    }
3510
3511    /// Returns `true` if `param_def_id` matches the `bounded_ty` of this predicate.
3512    pub fn as_generic_param(&self) -> Option<(DefId, Ident)> {
3513        let TyKind::Path(QPath::Resolved(None, path)) = self.kind else {
3514            return None;
3515        };
3516        let [segment] = &path.segments else {
3517            return None;
3518        };
3519        match path.res {
3520            Res::Def(DefKind::TyParam, def_id) | Res::SelfTyParam { trait_: def_id } => {
3521                Some((def_id, segment.ident))
3522            }
3523            _ => None,
3524        }
3525    }
3526
3527    pub fn find_self_aliases(&self) -> Vec<Span> {
3528        use crate::intravisit::Visitor;
3529        struct MyVisitor(Vec<Span>);
3530        impl<'v> Visitor<'v> for MyVisitor {
3531            fn visit_ty(&mut self, t: &'v Ty<'v, AmbigArg>) {
3532                if #[allow(non_exhaustive_omitted_patterns)] match &t.kind {
    TyKind::Path(QPath::Resolved(_, Path {
        res: crate::def::Res::SelfTyAlias { .. }, .. })) => true,
    _ => false,
}matches!(
3533                    &t.kind,
3534                    TyKind::Path(QPath::Resolved(
3535                        _,
3536                        Path { res: crate::def::Res::SelfTyAlias { .. }, .. },
3537                    ))
3538                ) {
3539                    self.0.push(t.span);
3540                    return;
3541                }
3542                crate::intravisit::walk_ty(self, t);
3543            }
3544        }
3545
3546        let mut my_visitor = MyVisitor(::alloc::vec::Vec::new()vec![]);
3547        my_visitor.visit_ty_unambig(self);
3548        my_visitor.0
3549    }
3550
3551    /// Whether `ty` is a type with `_` placeholders that can be inferred. Used in diagnostics only to
3552    /// use inference to provide suggestions for the appropriate type if possible.
3553    pub fn is_suggestable_infer_ty(&self) -> bool {
3554        fn are_suggestable_generic_args(generic_args: &[GenericArg<'_>]) -> bool {
3555            generic_args.iter().any(|arg| match arg {
3556                GenericArg::Type(ty) => ty.as_unambig_ty().is_suggestable_infer_ty(),
3557                GenericArg::Infer(_) => true,
3558                _ => false,
3559            })
3560        }
3561        {
    use ::tracing::__macro_support::Callsite as _;
    static __CALLSITE: ::tracing::callsite::DefaultCallsite =
        {
            static META: ::tracing::Metadata<'static> =
                {
                    ::tracing_core::metadata::Metadata::new("event compiler/rustc_hir/src/hir.rs:3561",
                        "rustc_hir::hir", ::tracing::Level::DEBUG,
                        ::tracing_core::__macro_support::Option::Some("compiler/rustc_hir/src/hir.rs"),
                        ::tracing_core::__macro_support::Option::Some(3561u32),
                        ::tracing_core::__macro_support::Option::Some("rustc_hir::hir"),
                        ::tracing_core::field::FieldSet::new(&["self"],
                            ::tracing_core::callsite::Identifier(&__CALLSITE)),
                        ::tracing::metadata::Kind::EVENT)
                };
            ::tracing::callsite::DefaultCallsite::new(&META)
        };
    let enabled =
        ::tracing::Level::DEBUG <= ::tracing::level_filters::STATIC_MAX_LEVEL
                &&
                ::tracing::Level::DEBUG <=
                    ::tracing::level_filters::LevelFilter::current() &&
            {
                let interest = __CALLSITE.interest();
                !interest.is_never() &&
                    ::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
                        interest)
            };
    if enabled {
        (|value_set: ::tracing::field::ValueSet|
                    {
                        let meta = __CALLSITE.metadata();
                        ::tracing::Event::dispatch(meta, &value_set);
                        ;
                    })({
                #[allow(unused_imports)]
                use ::tracing::field::{debug, display, Value};
                let mut iter = __CALLSITE.metadata().fields().iter();
                __CALLSITE.metadata().fields().value_set(&[(&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
                                    ::tracing::__macro_support::Option::Some(&debug(&self) as
                                            &dyn Value))])
            });
    } else { ; }
};debug!(?self);
3562        match &self.kind {
3563            TyKind::Infer(()) => true,
3564            TyKind::Slice(ty) => ty.is_suggestable_infer_ty(),
3565            TyKind::Array(ty, length) => {
3566                ty.is_suggestable_infer_ty() || #[allow(non_exhaustive_omitted_patterns)] match length.kind {
    ConstArgKind::Infer(..) => true,
    _ => false,
}matches!(length.kind, ConstArgKind::Infer(..))
3567            }
3568            TyKind::Tup(tys) => tys.iter().any(Self::is_suggestable_infer_ty),
3569            TyKind::Ptr(mut_ty) | TyKind::Ref(_, mut_ty) => mut_ty.ty.is_suggestable_infer_ty(),
3570            TyKind::Path(QPath::TypeRelative(ty, segment)) => {
3571                ty.is_suggestable_infer_ty() || are_suggestable_generic_args(segment.args().args)
3572            }
3573            TyKind::Path(QPath::Resolved(ty_opt, Path { segments, .. })) => {
3574                ty_opt.is_some_and(Self::is_suggestable_infer_ty)
3575                    || segments
3576                        .iter()
3577                        .any(|segment| are_suggestable_generic_args(segment.args().args))
3578            }
3579            _ => false,
3580        }
3581    }
3582}
3583
3584/// Not represented directly in the AST; referred to by name through a `ty_path`.
3585#[derive(#[automatically_derived]
impl ::core::marker::Copy for PrimTy { }Copy, #[automatically_derived]
impl ::core::clone::Clone for PrimTy {
    #[inline]
    fn clone(&self) -> PrimTy {
        let _: ::core::clone::AssertParamIsClone<IntTy>;
        let _: ::core::clone::AssertParamIsClone<UintTy>;
        let _: ::core::clone::AssertParamIsClone<FloatTy>;
        *self
    }
}Clone, #[automatically_derived]
impl ::core::cmp::PartialEq for PrimTy {
    #[inline]
    fn eq(&self, other: &PrimTy) -> bool {
        let __self_discr = ::core::intrinsics::discriminant_value(self);
        let __arg1_discr = ::core::intrinsics::discriminant_value(other);
        __self_discr == __arg1_discr &&
            match (self, other) {
                (PrimTy::Int(__self_0), PrimTy::Int(__arg1_0)) =>
                    __self_0 == __arg1_0,
                (PrimTy::Uint(__self_0), PrimTy::Uint(__arg1_0)) =>
                    __self_0 == __arg1_0,
                (PrimTy::Float(__self_0), PrimTy::Float(__arg1_0)) =>
                    __self_0 == __arg1_0,
                _ => true,
            }
    }
}PartialEq, #[automatically_derived]
impl ::core::cmp::Eq for PrimTy {
    #[inline]
    #[doc(hidden)]
    #[coverage(off)]
    fn assert_fields_are_eq(&self) {
        let _: ::core::cmp::AssertParamIsEq<IntTy>;
        let _: ::core::cmp::AssertParamIsEq<UintTy>;
        let _: ::core::cmp::AssertParamIsEq<FloatTy>;
    }
}Eq, const _: () =
    {
        impl<__E: ::rustc_span::SpanEncoder> ::rustc_serialize::Encodable<__E>
            for PrimTy {
            fn encode(&self, __encoder: &mut __E) {
                let disc =
                    match *self {
                        PrimTy::Int(ref __binding_0) => { 0usize }
                        PrimTy::Uint(ref __binding_0) => { 1usize }
                        PrimTy::Float(ref __binding_0) => { 2usize }
                        PrimTy::Str => { 3usize }
                        PrimTy::Bool => { 4usize }
                        PrimTy::Char => { 5usize }
                    };
                ::rustc_serialize::Encoder::emit_u8(__encoder, disc as u8);
                match *self {
                    PrimTy::Int(ref __binding_0) => {
                        ::rustc_serialize::Encodable::<__E>::encode(__binding_0,
                            __encoder);
                    }
                    PrimTy::Uint(ref __binding_0) => {
                        ::rustc_serialize::Encodable::<__E>::encode(__binding_0,
                            __encoder);
                    }
                    PrimTy::Float(ref __binding_0) => {
                        ::rustc_serialize::Encodable::<__E>::encode(__binding_0,
                            __encoder);
                    }
                    PrimTy::Str => {}
                    PrimTy::Bool => {}
                    PrimTy::Char => {}
                }
            }
        }
    };Encodable, const _: () =
    {
        impl<__D: ::rustc_span::SpanDecoder> ::rustc_serialize::Decodable<__D>
            for PrimTy {
            fn decode(__decoder: &mut __D) -> Self {
                match ::rustc_serialize::Decoder::read_u8(__decoder) as usize
                    {
                    0usize => {
                        PrimTy::Int(::rustc_serialize::Decodable::decode(__decoder))
                    }
                    1usize => {
                        PrimTy::Uint(::rustc_serialize::Decodable::decode(__decoder))
                    }
                    2usize => {
                        PrimTy::Float(::rustc_serialize::Decodable::decode(__decoder))
                    }
                    3usize => { PrimTy::Str }
                    4usize => { PrimTy::Bool }
                    5usize => { PrimTy::Char }
                    n => {
                        ::core::panicking::panic_fmt(format_args!("invalid enum variant tag while decoding `PrimTy`, expected 0..6, actual {0}",
                                n));
                    }
                }
            }
        }
    };Decodable, #[automatically_derived]
impl ::core::hash::Hash for PrimTy {
    #[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 {
            PrimTy::Int(__self_0) =>
                ::core::hash::Hash::hash(__self_0, state),
            PrimTy::Uint(__self_0) =>
                ::core::hash::Hash::hash(__self_0, state),
            PrimTy::Float(__self_0) =>
                ::core::hash::Hash::hash(__self_0, state),
            _ => {}
        }
    }
}Hash, #[automatically_derived]
impl ::core::fmt::Debug for PrimTy {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        match self {
            PrimTy::Int(__self_0) =>
                ::core::fmt::Formatter::debug_tuple_field1_finish(f, "Int",
                    &__self_0),
            PrimTy::Uint(__self_0) =>
                ::core::fmt::Formatter::debug_tuple_field1_finish(f, "Uint",
                    &__self_0),
            PrimTy::Float(__self_0) =>
                ::core::fmt::Formatter::debug_tuple_field1_finish(f, "Float",
                    &__self_0),
            PrimTy::Str => ::core::fmt::Formatter::write_str(f, "Str"),
            PrimTy::Bool => ::core::fmt::Formatter::write_str(f, "Bool"),
            PrimTy::Char => ::core::fmt::Formatter::write_str(f, "Char"),
        }
    }
}Debug, const _: () =
    {
        impl<__CTX> ::rustc_data_structures::stable_hasher::HashStable<__CTX>
            for PrimTy where __CTX: crate::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 {
                    PrimTy::Int(ref __binding_0) => {
                        { __binding_0.hash_stable(__hcx, __hasher); }
                    }
                    PrimTy::Uint(ref __binding_0) => {
                        { __binding_0.hash_stable(__hcx, __hasher); }
                    }
                    PrimTy::Float(ref __binding_0) => {
                        { __binding_0.hash_stable(__hcx, __hasher); }
                    }
                    PrimTy::Str => {}
                    PrimTy::Bool => {}
                    PrimTy::Char => {}
                }
            }
        }
    };HashStable_Generic)]
3586pub enum PrimTy {
3587    Int(IntTy),
3588    Uint(UintTy),
3589    Float(FloatTy),
3590    Str,
3591    Bool,
3592    Char,
3593}
3594
3595impl PrimTy {
3596    /// All of the primitive types
3597    pub const ALL: [Self; 19] = [
3598        // any changes here should also be reflected in `PrimTy::from_name`
3599        Self::Int(IntTy::I8),
3600        Self::Int(IntTy::I16),
3601        Self::Int(IntTy::I32),
3602        Self::Int(IntTy::I64),
3603        Self::Int(IntTy::I128),
3604        Self::Int(IntTy::Isize),
3605        Self::Uint(UintTy::U8),
3606        Self::Uint(UintTy::U16),
3607        Self::Uint(UintTy::U32),
3608        Self::Uint(UintTy::U64),
3609        Self::Uint(UintTy::U128),
3610        Self::Uint(UintTy::Usize),
3611        Self::Float(FloatTy::F16),
3612        Self::Float(FloatTy::F32),
3613        Self::Float(FloatTy::F64),
3614        Self::Float(FloatTy::F128),
3615        Self::Bool,
3616        Self::Char,
3617        Self::Str,
3618    ];
3619
3620    /// Like [`PrimTy::name`], but returns a &str instead of a symbol.
3621    ///
3622    /// Used by clippy.
3623    pub fn name_str(self) -> &'static str {
3624        match self {
3625            PrimTy::Int(i) => i.name_str(),
3626            PrimTy::Uint(u) => u.name_str(),
3627            PrimTy::Float(f) => f.name_str(),
3628            PrimTy::Str => "str",
3629            PrimTy::Bool => "bool",
3630            PrimTy::Char => "char",
3631        }
3632    }
3633
3634    pub fn name(self) -> Symbol {
3635        match self {
3636            PrimTy::Int(i) => i.name(),
3637            PrimTy::Uint(u) => u.name(),
3638            PrimTy::Float(f) => f.name(),
3639            PrimTy::Str => sym::str,
3640            PrimTy::Bool => sym::bool,
3641            PrimTy::Char => sym::char,
3642        }
3643    }
3644
3645    /// Returns the matching `PrimTy` for a `Symbol` such as "str" or "i32".
3646    /// Returns `None` if no matching type is found.
3647    pub fn from_name(name: Symbol) -> Option<Self> {
3648        let ty = match name {
3649            // any changes here should also be reflected in `PrimTy::ALL`
3650            sym::i8 => Self::Int(IntTy::I8),
3651            sym::i16 => Self::Int(IntTy::I16),
3652            sym::i32 => Self::Int(IntTy::I32),
3653            sym::i64 => Self::Int(IntTy::I64),
3654            sym::i128 => Self::Int(IntTy::I128),
3655            sym::isize => Self::Int(IntTy::Isize),
3656            sym::u8 => Self::Uint(UintTy::U8),
3657            sym::u16 => Self::Uint(UintTy::U16),
3658            sym::u32 => Self::Uint(UintTy::U32),
3659            sym::u64 => Self::Uint(UintTy::U64),
3660            sym::u128 => Self::Uint(UintTy::U128),
3661            sym::usize => Self::Uint(UintTy::Usize),
3662            sym::f16 => Self::Float(FloatTy::F16),
3663            sym::f32 => Self::Float(FloatTy::F32),
3664            sym::f64 => Self::Float(FloatTy::F64),
3665            sym::f128 => Self::Float(FloatTy::F128),
3666            sym::bool => Self::Bool,
3667            sym::char => Self::Char,
3668            sym::str => Self::Str,
3669            _ => return None,
3670        };
3671        Some(ty)
3672    }
3673}
3674
3675#[derive(#[automatically_derived]
impl<'hir> ::core::fmt::Debug for FnPtrTy<'hir> {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::debug_struct_field5_finish(f, "FnPtrTy",
            "safety", &self.safety, "abi", &self.abi, "generic_params",
            &self.generic_params, "decl", &self.decl, "param_idents",
            &&self.param_idents)
    }
}Debug, #[automatically_derived]
impl<'hir> ::core::clone::Clone for FnPtrTy<'hir> {
    #[inline]
    fn clone(&self) -> FnPtrTy<'hir> {
        let _: ::core::clone::AssertParamIsClone<Safety>;
        let _: ::core::clone::AssertParamIsClone<ExternAbi>;
        let _: ::core::clone::AssertParamIsClone<&'hir [GenericParam<'hir>]>;
        let _: ::core::clone::AssertParamIsClone<&'hir FnDecl<'hir>>;
        let _: ::core::clone::AssertParamIsClone<&'hir [Option<Ident>]>;
        *self
    }
}Clone, #[automatically_derived]
impl<'hir> ::core::marker::Copy for FnPtrTy<'hir> { }Copy, const _: () =
    {
        impl<'hir, __CTX>
            ::rustc_data_structures::stable_hasher::HashStable<__CTX> for
            FnPtrTy<'hir> where __CTX: crate::HashStableContext {
            #[inline]
            fn hash_stable(&self, __hcx: &mut __CTX,
                __hasher:
                    &mut ::rustc_data_structures::stable_hasher::StableHasher) {
                match *self {
                    FnPtrTy {
                        safety: ref __binding_0,
                        abi: ref __binding_1,
                        generic_params: ref __binding_2,
                        decl: ref __binding_3,
                        param_idents: 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); }
                    }
                }
            }
        }
    };HashStable_Generic)]
3676pub struct FnPtrTy<'hir> {
3677    pub safety: Safety,
3678    pub abi: ExternAbi,
3679    pub generic_params: &'hir [GenericParam<'hir>],
3680    pub decl: &'hir FnDecl<'hir>,
3681    // `Option` because bare fn parameter identifiers are optional. We also end up
3682    // with `None` in some error cases, e.g. invalid parameter patterns.
3683    pub param_idents: &'hir [Option<Ident>],
3684}
3685
3686#[derive(#[automatically_derived]
impl<'hir> ::core::fmt::Debug for UnsafeBinderTy<'hir> {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::debug_struct_field2_finish(f,
            "UnsafeBinderTy", "generic_params", &self.generic_params,
            "inner_ty", &&self.inner_ty)
    }
}Debug, #[automatically_derived]
impl<'hir> ::core::clone::Clone for UnsafeBinderTy<'hir> {
    #[inline]
    fn clone(&self) -> UnsafeBinderTy<'hir> {
        let _: ::core::clone::AssertParamIsClone<&'hir [GenericParam<'hir>]>;
        let _: ::core::clone::AssertParamIsClone<&'hir Ty<'hir>>;
        *self
    }
}Clone, #[automatically_derived]
impl<'hir> ::core::marker::Copy for UnsafeBinderTy<'hir> { }Copy, const _: () =
    {
        impl<'hir, __CTX>
            ::rustc_data_structures::stable_hasher::HashStable<__CTX> for
            UnsafeBinderTy<'hir> where __CTX: crate::HashStableContext {
            #[inline]
            fn hash_stable(&self, __hcx: &mut __CTX,
                __hasher:
                    &mut ::rustc_data_structures::stable_hasher::StableHasher) {
                match *self {
                    UnsafeBinderTy {
                        generic_params: ref __binding_0, inner_ty: ref __binding_1 }
                        => {
                        { __binding_0.hash_stable(__hcx, __hasher); }
                        { __binding_1.hash_stable(__hcx, __hasher); }
                    }
                }
            }
        }
    };HashStable_Generic)]
3687pub struct UnsafeBinderTy<'hir> {
3688    pub generic_params: &'hir [GenericParam<'hir>],
3689    pub inner_ty: &'hir Ty<'hir>,
3690}
3691
3692#[derive(#[automatically_derived]
impl<'hir> ::core::fmt::Debug for OpaqueTy<'hir> {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::debug_struct_field5_finish(f, "OpaqueTy",
            "hir_id", &self.hir_id, "def_id", &self.def_id, "bounds",
            &self.bounds, "origin", &self.origin, "span", &&self.span)
    }
}Debug, #[automatically_derived]
impl<'hir> ::core::clone::Clone for OpaqueTy<'hir> {
    #[inline]
    fn clone(&self) -> OpaqueTy<'hir> {
        let _: ::core::clone::AssertParamIsClone<HirId>;
        let _: ::core::clone::AssertParamIsClone<LocalDefId>;
        let _: ::core::clone::AssertParamIsClone<GenericBounds<'hir>>;
        let _: ::core::clone::AssertParamIsClone<OpaqueTyOrigin<LocalDefId>>;
        let _: ::core::clone::AssertParamIsClone<Span>;
        *self
    }
}Clone, #[automatically_derived]
impl<'hir> ::core::marker::Copy for OpaqueTy<'hir> { }Copy, const _: () =
    {
        impl<'hir, __CTX>
            ::rustc_data_structures::stable_hasher::HashStable<__CTX> for
            OpaqueTy<'hir> where __CTX: crate::HashStableContext {
            #[inline]
            fn hash_stable(&self, __hcx: &mut __CTX,
                __hasher:
                    &mut ::rustc_data_structures::stable_hasher::StableHasher) {
                match *self {
                    OpaqueTy {
                        hir_id: ref __binding_0,
                        def_id: ref __binding_1,
                        bounds: ref __binding_2,
                        origin: ref __binding_3,
                        span: ref __binding_4 } => {
                        {}
                        { __binding_1.hash_stable(__hcx, __hasher); }
                        { __binding_2.hash_stable(__hcx, __hasher); }
                        { __binding_3.hash_stable(__hcx, __hasher); }
                        { __binding_4.hash_stable(__hcx, __hasher); }
                    }
                }
            }
        }
    };HashStable_Generic)]
3693pub struct OpaqueTy<'hir> {
3694    #[stable_hasher(ignore)]
3695    pub hir_id: HirId,
3696    pub def_id: LocalDefId,
3697    pub bounds: GenericBounds<'hir>,
3698    pub origin: OpaqueTyOrigin<LocalDefId>,
3699    pub span: Span,
3700}
3701
3702#[derive(#[automatically_derived]
impl<T: ::core::fmt::Debug, U: ::core::fmt::Debug> ::core::fmt::Debug for
    PreciseCapturingArgKind<T, U> {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        match self {
            PreciseCapturingArgKind::Lifetime(__self_0) =>
                ::core::fmt::Formatter::debug_tuple_field1_finish(f,
                    "Lifetime", &__self_0),
            PreciseCapturingArgKind::Param(__self_0) =>
                ::core::fmt::Formatter::debug_tuple_field1_finish(f, "Param",
                    &__self_0),
        }
    }
}Debug, #[automatically_derived]
impl<T: ::core::clone::Clone, U: ::core::clone::Clone> ::core::clone::Clone
    for PreciseCapturingArgKind<T, U> {
    #[inline]
    fn clone(&self) -> PreciseCapturingArgKind<T, U> {
        match self {
            PreciseCapturingArgKind::Lifetime(__self_0) =>
                PreciseCapturingArgKind::Lifetime(::core::clone::Clone::clone(__self_0)),
            PreciseCapturingArgKind::Param(__self_0) =>
                PreciseCapturingArgKind::Param(::core::clone::Clone::clone(__self_0)),
        }
    }
}Clone, #[automatically_derived]
impl<T: ::core::marker::Copy, U: ::core::marker::Copy> ::core::marker::Copy
    for PreciseCapturingArgKind<T, U> {
}Copy, const _: () =
    {
        impl<T, U, __CTX>
            ::rustc_data_structures::stable_hasher::HashStable<__CTX> for
            PreciseCapturingArgKind<T, U> where
            __CTX: crate::HashStableContext,
            T: ::rustc_data_structures::stable_hasher::HashStable<__CTX>,
            U: ::rustc_data_structures::stable_hasher::HashStable<__CTX> {
            #[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 {
                    PreciseCapturingArgKind::Lifetime(ref __binding_0) => {
                        { __binding_0.hash_stable(__hcx, __hasher); }
                    }
                    PreciseCapturingArgKind::Param(ref __binding_0) => {
                        { __binding_0.hash_stable(__hcx, __hasher); }
                    }
                }
            }
        }
    };HashStable_Generic, const _: () =
    {
        impl<T, U, __E: ::rustc_span::SpanEncoder>
            ::rustc_serialize::Encodable<__E> for
            PreciseCapturingArgKind<T, U> where
            T: ::rustc_serialize::Encodable<__E>,
            U: ::rustc_serialize::Encodable<__E> {
            fn encode(&self, __encoder: &mut __E) {
                let disc =
                    match *self {
                        PreciseCapturingArgKind::Lifetime(ref __binding_0) => {
                            0usize
                        }
                        PreciseCapturingArgKind::Param(ref __binding_0) => {
                            1usize
                        }
                    };
                ::rustc_serialize::Encoder::emit_u8(__encoder, disc as u8);
                match *self {
                    PreciseCapturingArgKind::Lifetime(ref __binding_0) => {
                        ::rustc_serialize::Encodable::<__E>::encode(__binding_0,
                            __encoder);
                    }
                    PreciseCapturingArgKind::Param(ref __binding_0) => {
                        ::rustc_serialize::Encodable::<__E>::encode(__binding_0,
                            __encoder);
                    }
                }
            }
        }
    };Encodable, const _: () =
    {
        impl<T, U, __D: ::rustc_span::SpanDecoder>
            ::rustc_serialize::Decodable<__D> for
            PreciseCapturingArgKind<T, U> where
            T: ::rustc_serialize::Decodable<__D>,
            U: ::rustc_serialize::Decodable<__D> {
            fn decode(__decoder: &mut __D) -> Self {
                match ::rustc_serialize::Decoder::read_u8(__decoder) as usize
                    {
                    0usize => {
                        PreciseCapturingArgKind::Lifetime(::rustc_serialize::Decodable::decode(__decoder))
                    }
                    1usize => {
                        PreciseCapturingArgKind::Param(::rustc_serialize::Decodable::decode(__decoder))
                    }
                    n => {
                        ::core::panicking::panic_fmt(format_args!("invalid enum variant tag while decoding `PreciseCapturingArgKind`, expected 0..2, actual {0}",
                                n));
                    }
                }
            }
        }
    };Decodable)]
3703pub enum PreciseCapturingArgKind<T, U> {
3704    Lifetime(T),
3705    /// Non-lifetime argument (type or const)
3706    Param(U),
3707}
3708
3709pub type PreciseCapturingArg<'hir> =
3710    PreciseCapturingArgKind<&'hir Lifetime, PreciseCapturingNonLifetimeArg>;
3711
3712impl PreciseCapturingArg<'_> {
3713    pub fn hir_id(self) -> HirId {
3714        match self {
3715            PreciseCapturingArg::Lifetime(lt) => lt.hir_id,
3716            PreciseCapturingArg::Param(param) => param.hir_id,
3717        }
3718    }
3719
3720    pub fn name(self) -> Symbol {
3721        match self {
3722            PreciseCapturingArg::Lifetime(lt) => lt.ident.name,
3723            PreciseCapturingArg::Param(param) => param.ident.name,
3724        }
3725    }
3726}
3727
3728/// We need to have a [`Node`] for the [`HirId`] that we attach the type/const param
3729/// resolution to. Lifetimes don't have this problem, and for them, it's actually
3730/// kind of detrimental to use a custom node type versus just using [`Lifetime`],
3731/// since resolve_bound_vars operates on `Lifetime`s.
3732#[derive(#[automatically_derived]
impl ::core::fmt::Debug for PreciseCapturingNonLifetimeArg {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::debug_struct_field3_finish(f,
            "PreciseCapturingNonLifetimeArg", "hir_id", &self.hir_id, "ident",
            &self.ident, "res", &&self.res)
    }
}Debug, #[automatically_derived]
impl ::core::clone::Clone for PreciseCapturingNonLifetimeArg {
    #[inline]
    fn clone(&self) -> PreciseCapturingNonLifetimeArg {
        let _: ::core::clone::AssertParamIsClone<HirId>;
        let _: ::core::clone::AssertParamIsClone<Ident>;
        let _: ::core::clone::AssertParamIsClone<Res>;
        *self
    }
}Clone, #[automatically_derived]
impl ::core::marker::Copy for PreciseCapturingNonLifetimeArg { }Copy, const _: () =
    {
        impl<__CTX> ::rustc_data_structures::stable_hasher::HashStable<__CTX>
            for PreciseCapturingNonLifetimeArg where
            __CTX: crate::HashStableContext {
            #[inline]
            fn hash_stable(&self, __hcx: &mut __CTX,
                __hasher:
                    &mut ::rustc_data_structures::stable_hasher::StableHasher) {
                match *self {
                    PreciseCapturingNonLifetimeArg {
                        hir_id: ref __binding_0,
                        ident: ref __binding_1,
                        res: ref __binding_2 } => {
                        {}
                        { __binding_1.hash_stable(__hcx, __hasher); }
                        { __binding_2.hash_stable(__hcx, __hasher); }
                    }
                }
            }
        }
    };HashStable_Generic)]
3733pub struct PreciseCapturingNonLifetimeArg {
3734    #[stable_hasher(ignore)]
3735    pub hir_id: HirId,
3736    pub ident: Ident,
3737    pub res: Res,
3738}
3739
3740#[derive(#[automatically_derived]
impl ::core::marker::Copy for RpitContext { }Copy, #[automatically_derived]
impl ::core::clone::Clone for RpitContext {
    #[inline]
    fn clone(&self) -> RpitContext { *self }
}Clone, #[automatically_derived]
impl ::core::cmp::PartialEq for RpitContext {
    #[inline]
    fn eq(&self, other: &RpitContext) -> 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 RpitContext {
    #[inline]
    #[doc(hidden)]
    #[coverage(off)]
    fn assert_fields_are_eq(&self) {}
}Eq, #[automatically_derived]
impl ::core::fmt::Debug for RpitContext {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::write_str(f,
            match self {
                RpitContext::Trait => "Trait",
                RpitContext::TraitImpl => "TraitImpl",
            })
    }
}Debug)]
3741#[derive(const _: () =
    {
        impl<__CTX> ::rustc_data_structures::stable_hasher::HashStable<__CTX>
            for RpitContext where __CTX: crate::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 {
                    RpitContext::Trait => {}
                    RpitContext::TraitImpl => {}
                }
            }
        }
    };HashStable_Generic, const _: () =
    {
        impl<__E: ::rustc_span::SpanEncoder> ::rustc_serialize::Encodable<__E>
            for RpitContext {
            fn encode(&self, __encoder: &mut __E) {
                let disc =
                    match *self {
                        RpitContext::Trait => { 0usize }
                        RpitContext::TraitImpl => { 1usize }
                    };
                ::rustc_serialize::Encoder::emit_u8(__encoder, disc as u8);
                match *self {
                    RpitContext::Trait => {}
                    RpitContext::TraitImpl => {}
                }
            }
        }
    };Encodable, const _: () =
    {
        impl<__D: ::rustc_span::SpanDecoder> ::rustc_serialize::Decodable<__D>
            for RpitContext {
            fn decode(__decoder: &mut __D) -> Self {
                match ::rustc_serialize::Decoder::read_u8(__decoder) as usize
                    {
                    0usize => { RpitContext::Trait }
                    1usize => { RpitContext::TraitImpl }
                    n => {
                        ::core::panicking::panic_fmt(format_args!("invalid enum variant tag while decoding `RpitContext`, expected 0..2, actual {0}",
                                n));
                    }
                }
            }
        }
    };Decodable)]
3742pub enum RpitContext {
3743    Trait,
3744    TraitImpl,
3745}
3746
3747/// From whence the opaque type came.
3748#[derive(#[automatically_derived]
impl<D: ::core::marker::Copy> ::core::marker::Copy for OpaqueTyOrigin<D> { }Copy, #[automatically_derived]
impl<D: ::core::clone::Clone> ::core::clone::Clone for OpaqueTyOrigin<D> {
    #[inline]
    fn clone(&self) -> OpaqueTyOrigin<D> {
        match self {
            OpaqueTyOrigin::FnReturn {
                parent: __self_0, in_trait_or_impl: __self_1 } =>
                OpaqueTyOrigin::FnReturn {
                    parent: ::core::clone::Clone::clone(__self_0),
                    in_trait_or_impl: ::core::clone::Clone::clone(__self_1),
                },
            OpaqueTyOrigin::AsyncFn {
                parent: __self_0, in_trait_or_impl: __self_1 } =>
                OpaqueTyOrigin::AsyncFn {
                    parent: ::core::clone::Clone::clone(__self_0),
                    in_trait_or_impl: ::core::clone::Clone::clone(__self_1),
                },
            OpaqueTyOrigin::TyAlias { parent: __self_0, in_assoc_ty: __self_1
                } =>
                OpaqueTyOrigin::TyAlias {
                    parent: ::core::clone::Clone::clone(__self_0),
                    in_assoc_ty: ::core::clone::Clone::clone(__self_1),
                },
        }
    }
}Clone, #[automatically_derived]
impl<D: ::core::cmp::PartialEq> ::core::cmp::PartialEq for OpaqueTyOrigin<D> {
    #[inline]
    fn eq(&self, other: &OpaqueTyOrigin<D>) -> bool {
        let __self_discr = ::core::intrinsics::discriminant_value(self);
        let __arg1_discr = ::core::intrinsics::discriminant_value(other);
        __self_discr == __arg1_discr &&
            match (self, other) {
                (OpaqueTyOrigin::FnReturn {
                    parent: __self_0, in_trait_or_impl: __self_1 },
                    OpaqueTyOrigin::FnReturn {
                    parent: __arg1_0, in_trait_or_impl: __arg1_1 }) =>
                    __self_0 == __arg1_0 && __self_1 == __arg1_1,
                (OpaqueTyOrigin::AsyncFn {
                    parent: __self_0, in_trait_or_impl: __self_1 },
                    OpaqueTyOrigin::AsyncFn {
                    parent: __arg1_0, in_trait_or_impl: __arg1_1 }) =>
                    __self_0 == __arg1_0 && __self_1 == __arg1_1,
                (OpaqueTyOrigin::TyAlias {
                    parent: __self_0, in_assoc_ty: __self_1 },
                    OpaqueTyOrigin::TyAlias {
                    parent: __arg1_0, in_assoc_ty: __arg1_1 }) =>
                    __self_1 == __arg1_1 && __self_0 == __arg1_0,
                _ => unsafe { ::core::intrinsics::unreachable() }
            }
    }
}PartialEq, #[automatically_derived]
impl<D: ::core::cmp::Eq> ::core::cmp::Eq for OpaqueTyOrigin<D> {
    #[inline]
    #[doc(hidden)]
    #[coverage(off)]
    fn assert_fields_are_eq(&self) {
        let _: ::core::cmp::AssertParamIsEq<D>;
        let _: ::core::cmp::AssertParamIsEq<Option<RpitContext>>;
        let _: ::core::cmp::AssertParamIsEq<Option<RpitContext>>;
        let _: ::core::cmp::AssertParamIsEq<bool>;
    }
}Eq, #[automatically_derived]
impl<D: ::core::fmt::Debug> ::core::fmt::Debug for OpaqueTyOrigin<D> {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        match self {
            OpaqueTyOrigin::FnReturn {
                parent: __self_0, in_trait_or_impl: __self_1 } =>
                ::core::fmt::Formatter::debug_struct_field2_finish(f,
                    "FnReturn", "parent", __self_0, "in_trait_or_impl",
                    &__self_1),
            OpaqueTyOrigin::AsyncFn {
                parent: __self_0, in_trait_or_impl: __self_1 } =>
                ::core::fmt::Formatter::debug_struct_field2_finish(f,
                    "AsyncFn", "parent", __self_0, "in_trait_or_impl",
                    &__self_1),
            OpaqueTyOrigin::TyAlias { parent: __self_0, in_assoc_ty: __self_1
                } =>
                ::core::fmt::Formatter::debug_struct_field2_finish(f,
                    "TyAlias", "parent", __self_0, "in_assoc_ty", &__self_1),
        }
    }
}Debug)]
3749#[derive(const _: () =
    {
        impl<D, __CTX>
            ::rustc_data_structures::stable_hasher::HashStable<__CTX> for
            OpaqueTyOrigin<D> where __CTX: crate::HashStableContext,
            D: ::rustc_data_structures::stable_hasher::HashStable<__CTX> {
            #[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 {
                    OpaqueTyOrigin::FnReturn {
                        parent: ref __binding_0, in_trait_or_impl: ref __binding_1 }
                        => {
                        { __binding_0.hash_stable(__hcx, __hasher); }
                        { __binding_1.hash_stable(__hcx, __hasher); }
                    }
                    OpaqueTyOrigin::AsyncFn {
                        parent: ref __binding_0, in_trait_or_impl: ref __binding_1 }
                        => {
                        { __binding_0.hash_stable(__hcx, __hasher); }
                        { __binding_1.hash_stable(__hcx, __hasher); }
                    }
                    OpaqueTyOrigin::TyAlias {
                        parent: ref __binding_0, in_assoc_ty: ref __binding_1 } => {
                        { __binding_0.hash_stable(__hcx, __hasher); }
                        { __binding_1.hash_stable(__hcx, __hasher); }
                    }
                }
            }
        }
    };HashStable_Generic, const _: () =
    {
        impl<D, __E: ::rustc_span::SpanEncoder>
            ::rustc_serialize::Encodable<__E> for OpaqueTyOrigin<D> where
            D: ::rustc_serialize::Encodable<__E> {
            fn encode(&self, __encoder: &mut __E) {
                let disc =
                    match *self {
                        OpaqueTyOrigin::FnReturn {
                            parent: ref __binding_0, in_trait_or_impl: ref __binding_1 }
                            => {
                            0usize
                        }
                        OpaqueTyOrigin::AsyncFn {
                            parent: ref __binding_0, in_trait_or_impl: ref __binding_1 }
                            => {
                            1usize
                        }
                        OpaqueTyOrigin::TyAlias {
                            parent: ref __binding_0, in_assoc_ty: ref __binding_1 } => {
                            2usize
                        }
                    };
                ::rustc_serialize::Encoder::emit_u8(__encoder, disc as u8);
                match *self {
                    OpaqueTyOrigin::FnReturn {
                        parent: ref __binding_0, in_trait_or_impl: ref __binding_1 }
                        => {
                        ::rustc_serialize::Encodable::<__E>::encode(__binding_0,
                            __encoder);
                        ::rustc_serialize::Encodable::<__E>::encode(__binding_1,
                            __encoder);
                    }
                    OpaqueTyOrigin::AsyncFn {
                        parent: ref __binding_0, in_trait_or_impl: ref __binding_1 }
                        => {
                        ::rustc_serialize::Encodable::<__E>::encode(__binding_0,
                            __encoder);
                        ::rustc_serialize::Encodable::<__E>::encode(__binding_1,
                            __encoder);
                    }
                    OpaqueTyOrigin::TyAlias {
                        parent: ref __binding_0, in_assoc_ty: ref __binding_1 } => {
                        ::rustc_serialize::Encodable::<__E>::encode(__binding_0,
                            __encoder);
                        ::rustc_serialize::Encodable::<__E>::encode(__binding_1,
                            __encoder);
                    }
                }
            }
        }
    };Encodable, const _: () =
    {
        impl<D, __D: ::rustc_span::SpanDecoder>
            ::rustc_serialize::Decodable<__D> for OpaqueTyOrigin<D> where
            D: ::rustc_serialize::Decodable<__D> {
            fn decode(__decoder: &mut __D) -> Self {
                match ::rustc_serialize::Decoder::read_u8(__decoder) as usize
                    {
                    0usize => {
                        OpaqueTyOrigin::FnReturn {
                            parent: ::rustc_serialize::Decodable::decode(__decoder),
                            in_trait_or_impl: ::rustc_serialize::Decodable::decode(__decoder),
                        }
                    }
                    1usize => {
                        OpaqueTyOrigin::AsyncFn {
                            parent: ::rustc_serialize::Decodable::decode(__decoder),
                            in_trait_or_impl: ::rustc_serialize::Decodable::decode(__decoder),
                        }
                    }
                    2usize => {
                        OpaqueTyOrigin::TyAlias {
                            parent: ::rustc_serialize::Decodable::decode(__decoder),
                            in_assoc_ty: ::rustc_serialize::Decodable::decode(__decoder),
                        }
                    }
                    n => {
                        ::core::panicking::panic_fmt(format_args!("invalid enum variant tag while decoding `OpaqueTyOrigin`, expected 0..3, actual {0}",
                                n));
                    }
                }
            }
        }
    };Decodable)]
3750pub enum OpaqueTyOrigin<D> {
3751    /// `-> impl Trait`
3752    FnReturn {
3753        /// The defining function.
3754        parent: D,
3755        // Whether this is an RPITIT (return position impl trait in trait)
3756        in_trait_or_impl: Option<RpitContext>,
3757    },
3758    /// `async fn`
3759    AsyncFn {
3760        /// The defining function.
3761        parent: D,
3762        // Whether this is an AFIT (async fn in trait)
3763        in_trait_or_impl: Option<RpitContext>,
3764    },
3765    /// type aliases: `type Foo = impl Trait;`
3766    TyAlias {
3767        /// The type alias or associated type parent of the TAIT/ATPIT
3768        parent: D,
3769        /// associated types in impl blocks for traits.
3770        in_assoc_ty: bool,
3771    },
3772}
3773
3774// Ids of parent (or child) path segment that contains user-specified args
3775#[derive(#[automatically_derived]
impl ::core::fmt::Debug for DelegationGenerics {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::debug_struct_field2_finish(f,
            "DelegationGenerics", "parent_args_segment_id",
            &self.parent_args_segment_id, "child_args_segment_id",
            &&self.child_args_segment_id)
    }
}Debug, #[automatically_derived]
impl ::core::clone::Clone for DelegationGenerics {
    #[inline]
    fn clone(&self) -> DelegationGenerics {
        let _: ::core::clone::AssertParamIsClone<Option<HirId>>;
        let _: ::core::clone::AssertParamIsClone<Option<HirId>>;
        *self
    }
}Clone, #[automatically_derived]
impl ::core::marker::Copy for DelegationGenerics { }Copy, #[automatically_derived]
impl ::core::cmp::PartialEq for DelegationGenerics {
    #[inline]
    fn eq(&self, other: &DelegationGenerics) -> bool {
        self.parent_args_segment_id == other.parent_args_segment_id &&
            self.child_args_segment_id == other.child_args_segment_id
    }
}PartialEq, #[automatically_derived]
impl ::core::cmp::Eq for DelegationGenerics {
    #[inline]
    #[doc(hidden)]
    #[coverage(off)]
    fn assert_fields_are_eq(&self) {
        let _: ::core::cmp::AssertParamIsEq<Option<HirId>>;
        let _: ::core::cmp::AssertParamIsEq<Option<HirId>>;
    }
}Eq, const _: () =
    {
        impl<__CTX> ::rustc_data_structures::stable_hasher::HashStable<__CTX>
            for DelegationGenerics where __CTX: crate::HashStableContext {
            #[inline]
            fn hash_stable(&self, __hcx: &mut __CTX,
                __hasher:
                    &mut ::rustc_data_structures::stable_hasher::StableHasher) {
                match *self {
                    DelegationGenerics {
                        parent_args_segment_id: ref __binding_0,
                        child_args_segment_id: ref __binding_1 } => {
                        { __binding_0.hash_stable(__hcx, __hasher); }
                        { __binding_1.hash_stable(__hcx, __hasher); }
                    }
                }
            }
        }
    };HashStable_Generic)]
3776pub struct DelegationGenerics {
3777    pub parent_args_segment_id: Option<HirId>,
3778    pub child_args_segment_id: Option<HirId>,
3779}
3780
3781#[derive(#[automatically_derived]
impl<'hir> ::core::fmt::Debug for InferDelegationKind<'hir> {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        match self {
            InferDelegationKind::Input(__self_0) =>
                ::core::fmt::Formatter::debug_tuple_field1_finish(f, "Input",
                    &__self_0),
            InferDelegationKind::Output(__self_0) =>
                ::core::fmt::Formatter::debug_tuple_field1_finish(f, "Output",
                    &__self_0),
        }
    }
}Debug, #[automatically_derived]
impl<'hir> ::core::clone::Clone for InferDelegationKind<'hir> {
    #[inline]
    fn clone(&self) -> InferDelegationKind<'hir> {
        let _: ::core::clone::AssertParamIsClone<usize>;
        let _: ::core::clone::AssertParamIsClone<&'hir DelegationGenerics>;
        *self
    }
}Clone, #[automatically_derived]
impl<'hir> ::core::marker::Copy for InferDelegationKind<'hir> { }Copy, #[automatically_derived]
impl<'hir> ::core::cmp::PartialEq for InferDelegationKind<'hir> {
    #[inline]
    fn eq(&self, other: &InferDelegationKind<'hir>) -> bool {
        let __self_discr = ::core::intrinsics::discriminant_value(self);
        let __arg1_discr = ::core::intrinsics::discriminant_value(other);
        __self_discr == __arg1_discr &&
            match (self, other) {
                (InferDelegationKind::Input(__self_0),
                    InferDelegationKind::Input(__arg1_0)) =>
                    __self_0 == __arg1_0,
                (InferDelegationKind::Output(__self_0),
                    InferDelegationKind::Output(__arg1_0)) =>
                    __self_0 == __arg1_0,
                _ => unsafe { ::core::intrinsics::unreachable() }
            }
    }
}PartialEq, #[automatically_derived]
impl<'hir> ::core::cmp::Eq for InferDelegationKind<'hir> {
    #[inline]
    #[doc(hidden)]
    #[coverage(off)]
    fn assert_fields_are_eq(&self) {
        let _: ::core::cmp::AssertParamIsEq<usize>;
        let _: ::core::cmp::AssertParamIsEq<&'hir DelegationGenerics>;
    }
}Eq, const _: () =
    {
        impl<'hir, __CTX>
            ::rustc_data_structures::stable_hasher::HashStable<__CTX> for
            InferDelegationKind<'hir> where __CTX: crate::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 {
                    InferDelegationKind::Input(ref __binding_0) => {
                        { __binding_0.hash_stable(__hcx, __hasher); }
                    }
                    InferDelegationKind::Output(ref __binding_0) => {
                        { __binding_0.hash_stable(__hcx, __hasher); }
                    }
                }
            }
        }
    };HashStable_Generic)]
3782pub enum InferDelegationKind<'hir> {
3783    Input(usize),
3784    // Place generics info here, as we always specify output type for delegations.
3785    Output(&'hir DelegationGenerics),
3786}
3787
3788/// The various kinds of types recognized by the compiler.
3789///
3790/// For an explanation of the `Unambig` generic parameter see the dev-guide:
3791/// <https://rustc-dev-guide.rust-lang.org/ambig-unambig-ty-and-consts.html>
3792// SAFETY: `repr(u8)` is required so that `TyKind<()>` and `TyKind<!>` are layout compatible
3793#[repr(u8, C)]
3794#[derive(#[automatically_derived]
impl<'hir, Unambig: ::core::fmt::Debug> ::core::fmt::Debug for
    TyKind<'hir, Unambig> {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        match self {
            TyKind::InferDelegation(__self_0, __self_1) =>
                ::core::fmt::Formatter::debug_tuple_field2_finish(f,
                    "InferDelegation", __self_0, &__self_1),
            TyKind::Slice(__self_0) =>
                ::core::fmt::Formatter::debug_tuple_field1_finish(f, "Slice",
                    &__self_0),
            TyKind::Array(__self_0, __self_1) =>
                ::core::fmt::Formatter::debug_tuple_field2_finish(f, "Array",
                    __self_0, &__self_1),
            TyKind::Ptr(__self_0) =>
                ::core::fmt::Formatter::debug_tuple_field1_finish(f, "Ptr",
                    &__self_0),
            TyKind::Ref(__self_0, __self_1) =>
                ::core::fmt::Formatter::debug_tuple_field2_finish(f, "Ref",
                    __self_0, &__self_1),
            TyKind::FnPtr(__self_0) =>
                ::core::fmt::Formatter::debug_tuple_field1_finish(f, "FnPtr",
                    &__self_0),
            TyKind::UnsafeBinder(__self_0) =>
                ::core::fmt::Formatter::debug_tuple_field1_finish(f,
                    "UnsafeBinder", &__self_0),
            TyKind::Never => ::core::fmt::Formatter::write_str(f, "Never"),
            TyKind::Tup(__self_0) =>
                ::core::fmt::Formatter::debug_tuple_field1_finish(f, "Tup",
                    &__self_0),
            TyKind::Path(__self_0) =>
                ::core::fmt::Formatter::debug_tuple_field1_finish(f, "Path",
                    &__self_0),
            TyKind::OpaqueDef(__self_0) =>
                ::core::fmt::Formatter::debug_tuple_field1_finish(f,
                    "OpaqueDef", &__self_0),
            TyKind::TraitAscription(__self_0) =>
                ::core::fmt::Formatter::debug_tuple_field1_finish(f,
                    "TraitAscription", &__self_0),
            TyKind::TraitObject(__self_0, __self_1) =>
                ::core::fmt::Formatter::debug_tuple_field2_finish(f,
                    "TraitObject", __self_0, &__self_1),
            TyKind::Err(__self_0) =>
                ::core::fmt::Formatter::debug_tuple_field1_finish(f, "Err",
                    &__self_0),
            TyKind::Pat(__self_0, __self_1) =>
                ::core::fmt::Formatter::debug_tuple_field2_finish(f, "Pat",
                    __self_0, &__self_1),
            TyKind::FieldOf(__self_0, __self_1) =>
                ::core::fmt::Formatter::debug_tuple_field2_finish(f,
                    "FieldOf", __self_0, &__self_1),
            TyKind::Infer(__self_0) =>
                ::core::fmt::Formatter::debug_tuple_field1_finish(f, "Infer",
                    &__self_0),
        }
    }
}Debug, #[automatically_derived]
impl<'hir, Unambig: ::core::clone::Clone> ::core::clone::Clone for
    TyKind<'hir, Unambig> {
    #[inline]
    fn clone(&self) -> TyKind<'hir, Unambig> {
        match self {
            TyKind::InferDelegation(__self_0, __self_1) =>
                TyKind::InferDelegation(::core::clone::Clone::clone(__self_0),
                    ::core::clone::Clone::clone(__self_1)),
            TyKind::Slice(__self_0) =>
                TyKind::Slice(::core::clone::Clone::clone(__self_0)),
            TyKind::Array(__self_0, __self_1) =>
                TyKind::Array(::core::clone::Clone::clone(__self_0),
                    ::core::clone::Clone::clone(__self_1)),
            TyKind::Ptr(__self_0) =>
                TyKind::Ptr(::core::clone::Clone::clone(__self_0)),
            TyKind::Ref(__self_0, __self_1) =>
                TyKind::Ref(::core::clone::Clone::clone(__self_0),
                    ::core::clone::Clone::clone(__self_1)),
            TyKind::FnPtr(__self_0) =>
                TyKind::FnPtr(::core::clone::Clone::clone(__self_0)),
            TyKind::UnsafeBinder(__self_0) =>
                TyKind::UnsafeBinder(::core::clone::Clone::clone(__self_0)),
            TyKind::Never => TyKind::Never,
            TyKind::Tup(__self_0) =>
                TyKind::Tup(::core::clone::Clone::clone(__self_0)),
            TyKind::Path(__self_0) =>
                TyKind::Path(::core::clone::Clone::clone(__self_0)),
            TyKind::OpaqueDef(__self_0) =>
                TyKind::OpaqueDef(::core::clone::Clone::clone(__self_0)),
            TyKind::TraitAscription(__self_0) =>
                TyKind::TraitAscription(::core::clone::Clone::clone(__self_0)),
            TyKind::TraitObject(__self_0, __self_1) =>
                TyKind::TraitObject(::core::clone::Clone::clone(__self_0),
                    ::core::clone::Clone::clone(__self_1)),
            TyKind::Err(__self_0) =>
                TyKind::Err(::core::clone::Clone::clone(__self_0)),
            TyKind::Pat(__self_0, __self_1) =>
                TyKind::Pat(::core::clone::Clone::clone(__self_0),
                    ::core::clone::Clone::clone(__self_1)),
            TyKind::FieldOf(__self_0, __self_1) =>
                TyKind::FieldOf(::core::clone::Clone::clone(__self_0),
                    ::core::clone::Clone::clone(__self_1)),
            TyKind::Infer(__self_0) =>
                TyKind::Infer(::core::clone::Clone::clone(__self_0)),
        }
    }
}Clone, #[automatically_derived]
impl<'hir, Unambig: ::core::marker::Copy> ::core::marker::Copy for
    TyKind<'hir, Unambig> {
}Copy, const _: () =
    {
        impl<'hir, Unambig, __CTX>
            ::rustc_data_structures::stable_hasher::HashStable<__CTX> for
            TyKind<'hir, Unambig> where __CTX: crate::HashStableContext,
            Unambig: ::rustc_data_structures::stable_hasher::HashStable<__CTX>
            {
            #[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 {
                    TyKind::InferDelegation(ref __binding_0, ref __binding_1) =>
                        {
                        { __binding_0.hash_stable(__hcx, __hasher); }
                        { __binding_1.hash_stable(__hcx, __hasher); }
                    }
                    TyKind::Slice(ref __binding_0) => {
                        { __binding_0.hash_stable(__hcx, __hasher); }
                    }
                    TyKind::Array(ref __binding_0, ref __binding_1) => {
                        { __binding_0.hash_stable(__hcx, __hasher); }
                        { __binding_1.hash_stable(__hcx, __hasher); }
                    }
                    TyKind::Ptr(ref __binding_0) => {
                        { __binding_0.hash_stable(__hcx, __hasher); }
                    }
                    TyKind::Ref(ref __binding_0, ref __binding_1) => {
                        { __binding_0.hash_stable(__hcx, __hasher); }
                        { __binding_1.hash_stable(__hcx, __hasher); }
                    }
                    TyKind::FnPtr(ref __binding_0) => {
                        { __binding_0.hash_stable(__hcx, __hasher); }
                    }
                    TyKind::UnsafeBinder(ref __binding_0) => {
                        { __binding_0.hash_stable(__hcx, __hasher); }
                    }
                    TyKind::Never => {}
                    TyKind::Tup(ref __binding_0) => {
                        { __binding_0.hash_stable(__hcx, __hasher); }
                    }
                    TyKind::Path(ref __binding_0) => {
                        { __binding_0.hash_stable(__hcx, __hasher); }
                    }
                    TyKind::OpaqueDef(ref __binding_0) => {
                        { __binding_0.hash_stable(__hcx, __hasher); }
                    }
                    TyKind::TraitAscription(ref __binding_0) => {
                        { __binding_0.hash_stable(__hcx, __hasher); }
                    }
                    TyKind::TraitObject(ref __binding_0, ref __binding_1) => {
                        { __binding_0.hash_stable(__hcx, __hasher); }
                        { __binding_1.hash_stable(__hcx, __hasher); }
                    }
                    TyKind::Err(ref __binding_0) => {
                        { __binding_0.hash_stable(__hcx, __hasher); }
                    }
                    TyKind::Pat(ref __binding_0, ref __binding_1) => {
                        { __binding_0.hash_stable(__hcx, __hasher); }
                        { __binding_1.hash_stable(__hcx, __hasher); }
                    }
                    TyKind::FieldOf(ref __binding_0, ref __binding_1) => {
                        { __binding_0.hash_stable(__hcx, __hasher); }
                        { __binding_1.hash_stable(__hcx, __hasher); }
                    }
                    TyKind::Infer(ref __binding_0) => {
                        { __binding_0.hash_stable(__hcx, __hasher); }
                    }
                }
            }
        }
    };HashStable_Generic)]
3795pub enum TyKind<'hir, Unambig = ()> {
3796    /// Actual type should be inherited from `DefId` signature
3797    InferDelegation(DefId, InferDelegationKind<'hir>),
3798    /// A variable length slice (i.e., `[T]`).
3799    Slice(&'hir Ty<'hir>),
3800    /// A fixed length array (i.e., `[T; n]`).
3801    Array(&'hir Ty<'hir>, &'hir ConstArg<'hir>),
3802    /// A raw pointer (i.e., `*const T` or `*mut T`).
3803    Ptr(MutTy<'hir>),
3804    /// A reference (i.e., `&'a T` or `&'a mut T`).
3805    Ref(&'hir Lifetime, MutTy<'hir>),
3806    /// A function pointer (e.g., `fn(usize) -> bool`).
3807    FnPtr(&'hir FnPtrTy<'hir>),
3808    /// An unsafe binder type (e.g. `unsafe<'a> Foo<'a>`).
3809    UnsafeBinder(&'hir UnsafeBinderTy<'hir>),
3810    /// The never type (`!`).
3811    Never,
3812    /// A tuple (`(A, B, C, D, ...)`).
3813    Tup(&'hir [Ty<'hir>]),
3814    /// A path to a type definition (`module::module::...::Type`), or an
3815    /// associated type (e.g., `<Vec<T> as Trait>::Type` or `<T>::Target`).
3816    ///
3817    /// Type parameters may be stored in each `PathSegment`.
3818    Path(QPath<'hir>),
3819    /// An opaque type definition itself. This is only used for `impl Trait`.
3820    OpaqueDef(&'hir OpaqueTy<'hir>),
3821    /// A trait ascription type, which is `impl Trait` within a local binding.
3822    TraitAscription(GenericBounds<'hir>),
3823    /// A trait object type `Bound1 + Bound2 + Bound3`
3824    /// where `Bound` is a trait or a lifetime.
3825    ///
3826    /// We use pointer tagging to represent a `&'hir Lifetime` and `TraitObjectSyntax` pair
3827    /// as otherwise this type being `repr(C)` would result in `TyKind` increasing in size.
3828    TraitObject(&'hir [PolyTraitRef<'hir>], TaggedRef<'hir, Lifetime, TraitObjectSyntax>),
3829    /// Placeholder for a type that has failed to be defined.
3830    Err(rustc_span::ErrorGuaranteed),
3831    /// Pattern types (`pattern_type!(u32 is 1..)`)
3832    Pat(&'hir Ty<'hir>, &'hir TyPat<'hir>),
3833    /// Field representing type (`field_of!(Struct, field)`).
3834    ///
3835    /// The optional ident is the variant when an enum is passed `field_of!(Enum, Variant.field)`.
3836    FieldOf(&'hir Ty<'hir>, &'hir TyFieldPath),
3837    /// `TyKind::Infer` means the type should be inferred instead of it having been
3838    /// specified. This can appear anywhere in a type.
3839    ///
3840    /// This variant is not always used to represent inference types, sometimes
3841    /// [`GenericArg::Infer`] is used instead.
3842    Infer(Unambig),
3843}
3844
3845#[derive(#[automatically_derived]
impl<'hir> ::core::fmt::Debug for InlineAsmOperand<'hir> {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        match self {
            InlineAsmOperand::In { reg: __self_0, expr: __self_1 } =>
                ::core::fmt::Formatter::debug_struct_field2_finish(f, "In",
                    "reg", __self_0, "expr", &__self_1),
            InlineAsmOperand::Out {
                reg: __self_0, late: __self_1, expr: __self_2 } =>
                ::core::fmt::Formatter::debug_struct_field3_finish(f, "Out",
                    "reg", __self_0, "late", __self_1, "expr", &__self_2),
            InlineAsmOperand::InOut {
                reg: __self_0, late: __self_1, expr: __self_2 } =>
                ::core::fmt::Formatter::debug_struct_field3_finish(f, "InOut",
                    "reg", __self_0, "late", __self_1, "expr", &__self_2),
            InlineAsmOperand::SplitInOut {
                reg: __self_0,
                late: __self_1,
                in_expr: __self_2,
                out_expr: __self_3 } =>
                ::core::fmt::Formatter::debug_struct_field4_finish(f,
                    "SplitInOut", "reg", __self_0, "late", __self_1, "in_expr",
                    __self_2, "out_expr", &__self_3),
            InlineAsmOperand::Const { anon_const: __self_0 } =>
                ::core::fmt::Formatter::debug_struct_field1_finish(f, "Const",
                    "anon_const", &__self_0),
            InlineAsmOperand::SymFn { expr: __self_0 } =>
                ::core::fmt::Formatter::debug_struct_field1_finish(f, "SymFn",
                    "expr", &__self_0),
            InlineAsmOperand::SymStatic { path: __self_0, def_id: __self_1 }
                =>
                ::core::fmt::Formatter::debug_struct_field2_finish(f,
                    "SymStatic", "path", __self_0, "def_id", &__self_1),
            InlineAsmOperand::Label { block: __self_0 } =>
                ::core::fmt::Formatter::debug_struct_field1_finish(f, "Label",
                    "block", &__self_0),
        }
    }
}Debug, #[automatically_derived]
impl<'hir> ::core::clone::Clone for InlineAsmOperand<'hir> {
    #[inline]
    fn clone(&self) -> InlineAsmOperand<'hir> {
        let _: ::core::clone::AssertParamIsClone<InlineAsmRegOrRegClass>;
        let _: ::core::clone::AssertParamIsClone<&'hir Expr<'hir>>;
        let _: ::core::clone::AssertParamIsClone<bool>;
        let _: ::core::clone::AssertParamIsClone<Option<&'hir Expr<'hir>>>;
        let _: ::core::clone::AssertParamIsClone<&'hir Expr<'hir>>;
        let _: ::core::clone::AssertParamIsClone<&'hir Expr<'hir>>;
        let _: ::core::clone::AssertParamIsClone<Option<&'hir Expr<'hir>>>;
        let _: ::core::clone::AssertParamIsClone<ConstBlock>;
        let _: ::core::clone::AssertParamIsClone<&'hir Expr<'hir>>;
        let _: ::core::clone::AssertParamIsClone<QPath<'hir>>;
        let _: ::core::clone::AssertParamIsClone<DefId>;
        let _: ::core::clone::AssertParamIsClone<&'hir Block<'hir>>;
        *self
    }
}Clone, #[automatically_derived]
impl<'hir> ::core::marker::Copy for InlineAsmOperand<'hir> { }Copy, const _: () =
    {
        impl<'hir, __CTX>
            ::rustc_data_structures::stable_hasher::HashStable<__CTX> for
            InlineAsmOperand<'hir> where __CTX: crate::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 {
                    InlineAsmOperand::In {
                        reg: ref __binding_0, expr: ref __binding_1 } => {
                        { __binding_0.hash_stable(__hcx, __hasher); }
                        { __binding_1.hash_stable(__hcx, __hasher); }
                    }
                    InlineAsmOperand::Out {
                        reg: ref __binding_0,
                        late: ref __binding_1,
                        expr: ref __binding_2 } => {
                        { __binding_0.hash_stable(__hcx, __hasher); }
                        { __binding_1.hash_stable(__hcx, __hasher); }
                        { __binding_2.hash_stable(__hcx, __hasher); }
                    }
                    InlineAsmOperand::InOut {
                        reg: ref __binding_0,
                        late: ref __binding_1,
                        expr: ref __binding_2 } => {
                        { __binding_0.hash_stable(__hcx, __hasher); }
                        { __binding_1.hash_stable(__hcx, __hasher); }
                        { __binding_2.hash_stable(__hcx, __hasher); }
                    }
                    InlineAsmOperand::SplitInOut {
                        reg: ref __binding_0,
                        late: ref __binding_1,
                        in_expr: ref __binding_2,
                        out_expr: 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); }
                    }
                    InlineAsmOperand::Const { anon_const: ref __binding_0 } => {
                        { __binding_0.hash_stable(__hcx, __hasher); }
                    }
                    InlineAsmOperand::SymFn { expr: ref __binding_0 } => {
                        { __binding_0.hash_stable(__hcx, __hasher); }
                    }
                    InlineAsmOperand::SymStatic {
                        path: ref __binding_0, def_id: ref __binding_1 } => {
                        { __binding_0.hash_stable(__hcx, __hasher); }
                        { __binding_1.hash_stable(__hcx, __hasher); }
                    }
                    InlineAsmOperand::Label { block: ref __binding_0 } => {
                        { __binding_0.hash_stable(__hcx, __hasher); }
                    }
                }
            }
        }
    };HashStable_Generic)]
3846pub enum InlineAsmOperand<'hir> {
3847    In {
3848        reg: InlineAsmRegOrRegClass,
3849        expr: &'hir Expr<'hir>,
3850    },
3851    Out {
3852        reg: InlineAsmRegOrRegClass,
3853        late: bool,
3854        expr: Option<&'hir Expr<'hir>>,
3855    },
3856    InOut {
3857        reg: InlineAsmRegOrRegClass,
3858        late: bool,
3859        expr: &'hir Expr<'hir>,
3860    },
3861    SplitInOut {
3862        reg: InlineAsmRegOrRegClass,
3863        late: bool,
3864        in_expr: &'hir Expr<'hir>,
3865        out_expr: Option<&'hir Expr<'hir>>,
3866    },
3867    Const {
3868        anon_const: ConstBlock,
3869    },
3870    SymFn {
3871        expr: &'hir Expr<'hir>,
3872    },
3873    SymStatic {
3874        path: QPath<'hir>,
3875        def_id: DefId,
3876    },
3877    Label {
3878        block: &'hir Block<'hir>,
3879    },
3880}
3881
3882impl<'hir> InlineAsmOperand<'hir> {
3883    pub fn reg(&self) -> Option<InlineAsmRegOrRegClass> {
3884        match *self {
3885            Self::In { reg, .. }
3886            | Self::Out { reg, .. }
3887            | Self::InOut { reg, .. }
3888            | Self::SplitInOut { reg, .. } => Some(reg),
3889            Self::Const { .. }
3890            | Self::SymFn { .. }
3891            | Self::SymStatic { .. }
3892            | Self::Label { .. } => None,
3893        }
3894    }
3895
3896    pub fn is_clobber(&self) -> bool {
3897        #[allow(non_exhaustive_omitted_patterns)] match self {
    InlineAsmOperand::Out {
        reg: InlineAsmRegOrRegClass::Reg(_), late: _, expr: None } => true,
    _ => false,
}matches!(
3898            self,
3899            InlineAsmOperand::Out { reg: InlineAsmRegOrRegClass::Reg(_), late: _, expr: None }
3900        )
3901    }
3902}
3903
3904#[derive(#[automatically_derived]
impl<'hir> ::core::fmt::Debug for InlineAsm<'hir> {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        let names: &'static _ =
            &["asm_macro", "template", "template_strs", "operands", "options",
                        "line_spans"];
        let values: &[&dyn ::core::fmt::Debug] =
            &[&self.asm_macro, &self.template, &self.template_strs,
                        &self.operands, &self.options, &&self.line_spans];
        ::core::fmt::Formatter::debug_struct_fields_finish(f, "InlineAsm",
            names, values)
    }
}Debug, #[automatically_derived]
impl<'hir> ::core::clone::Clone for InlineAsm<'hir> {
    #[inline]
    fn clone(&self) -> InlineAsm<'hir> {
        let _: ::core::clone::AssertParamIsClone<ast::AsmMacro>;
        let _:
                ::core::clone::AssertParamIsClone<&'hir [InlineAsmTemplatePiece]>;
        let _:
                ::core::clone::AssertParamIsClone<&'hir [(Symbol,
                Option<Symbol>, Span)]>;
        let _:
                ::core::clone::AssertParamIsClone<&'hir [(InlineAsmOperand<'hir>,
                Span)]>;
        let _: ::core::clone::AssertParamIsClone<InlineAsmOptions>;
        let _: ::core::clone::AssertParamIsClone<&'hir [Span]>;
        *self
    }
}Clone, #[automatically_derived]
impl<'hir> ::core::marker::Copy for InlineAsm<'hir> { }Copy, const _: () =
    {
        impl<'hir, __CTX>
            ::rustc_data_structures::stable_hasher::HashStable<__CTX> for
            InlineAsm<'hir> where __CTX: crate::HashStableContext {
            #[inline]
            fn hash_stable(&self, __hcx: &mut __CTX,
                __hasher:
                    &mut ::rustc_data_structures::stable_hasher::StableHasher) {
                match *self {
                    InlineAsm {
                        asm_macro: ref __binding_0,
                        template: ref __binding_1,
                        template_strs: ref __binding_2,
                        operands: ref __binding_3,
                        options: ref __binding_4,
                        line_spans: ref __binding_5 } => {
                        { __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); }
                        { __binding_5.hash_stable(__hcx, __hasher); }
                    }
                }
            }
        }
    };HashStable_Generic)]
3905pub struct InlineAsm<'hir> {
3906    pub asm_macro: ast::AsmMacro,
3907    pub template: &'hir [InlineAsmTemplatePiece],
3908    pub template_strs: &'hir [(Symbol, Option<Symbol>, Span)],
3909    pub operands: &'hir [(InlineAsmOperand<'hir>, Span)],
3910    pub options: InlineAsmOptions,
3911    pub line_spans: &'hir [Span],
3912}
3913
3914impl InlineAsm<'_> {
3915    pub fn contains_label(&self) -> bool {
3916        self.operands.iter().any(|x| #[allow(non_exhaustive_omitted_patterns)] match x.0 {
    InlineAsmOperand::Label { .. } => true,
    _ => false,
}matches!(x.0, InlineAsmOperand::Label { .. }))
3917    }
3918}
3919
3920/// Represents a parameter in a function header.
3921#[derive(#[automatically_derived]
impl<'hir> ::core::fmt::Debug for Param<'hir> {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::debug_struct_field4_finish(f, "Param",
            "hir_id", &self.hir_id, "pat", &self.pat, "ty_span",
            &self.ty_span, "span", &&self.span)
    }
}Debug, #[automatically_derived]
impl<'hir> ::core::clone::Clone for Param<'hir> {
    #[inline]
    fn clone(&self) -> Param<'hir> {
        let _: ::core::clone::AssertParamIsClone<HirId>;
        let _: ::core::clone::AssertParamIsClone<&'hir Pat<'hir>>;
        let _: ::core::clone::AssertParamIsClone<Span>;
        *self
    }
}Clone, #[automatically_derived]
impl<'hir> ::core::marker::Copy for Param<'hir> { }Copy, const _: () =
    {
        impl<'hir, __CTX>
            ::rustc_data_structures::stable_hasher::HashStable<__CTX> for
            Param<'hir> where __CTX: crate::HashStableContext {
            #[inline]
            fn hash_stable(&self, __hcx: &mut __CTX,
                __hasher:
                    &mut ::rustc_data_structures::stable_hasher::StableHasher) {
                match *self {
                    Param {
                        hir_id: ref __binding_0,
                        pat: ref __binding_1,
                        ty_span: ref __binding_2,
                        span: ref __binding_3 } => {
                        {}
                        { __binding_1.hash_stable(__hcx, __hasher); }
                        { __binding_2.hash_stable(__hcx, __hasher); }
                        { __binding_3.hash_stable(__hcx, __hasher); }
                    }
                }
            }
        }
    };HashStable_Generic)]
3922pub struct Param<'hir> {
3923    #[stable_hasher(ignore)]
3924    pub hir_id: HirId,
3925    pub pat: &'hir Pat<'hir>,
3926    pub ty_span: Span,
3927    pub span: Span,
3928}
3929
3930/// Represents the header (not the body) of a function declaration.
3931#[derive(#[automatically_derived]
impl<'hir> ::core::fmt::Debug for FnDecl<'hir> {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::debug_struct_field5_finish(f, "FnDecl",
            "inputs", &self.inputs, "output", &self.output, "c_variadic",
            &self.c_variadic, "implicit_self", &self.implicit_self,
            "lifetime_elision_allowed", &&self.lifetime_elision_allowed)
    }
}Debug, #[automatically_derived]
impl<'hir> ::core::clone::Clone for FnDecl<'hir> {
    #[inline]
    fn clone(&self) -> FnDecl<'hir> {
        let _: ::core::clone::AssertParamIsClone<&'hir [Ty<'hir>]>;
        let _: ::core::clone::AssertParamIsClone<FnRetTy<'hir>>;
        let _: ::core::clone::AssertParamIsClone<bool>;
        let _: ::core::clone::AssertParamIsClone<ImplicitSelfKind>;
        *self
    }
}Clone, #[automatically_derived]
impl<'hir> ::core::marker::Copy for FnDecl<'hir> { }Copy, const _: () =
    {
        impl<'hir, __CTX>
            ::rustc_data_structures::stable_hasher::HashStable<__CTX> for
            FnDecl<'hir> where __CTX: crate::HashStableContext {
            #[inline]
            fn hash_stable(&self, __hcx: &mut __CTX,
                __hasher:
                    &mut ::rustc_data_structures::stable_hasher::StableHasher) {
                match *self {
                    FnDecl {
                        inputs: ref __binding_0,
                        output: ref __binding_1,
                        c_variadic: ref __binding_2,
                        implicit_self: ref __binding_3,
                        lifetime_elision_allowed: 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); }
                    }
                }
            }
        }
    };HashStable_Generic)]
3932pub struct FnDecl<'hir> {
3933    /// The types of the function's parameters.
3934    ///
3935    /// Additional argument data is stored in the function's [body](Body::params).
3936    pub inputs: &'hir [Ty<'hir>],
3937    pub output: FnRetTy<'hir>,
3938    pub c_variadic: bool,
3939    /// Does the function have an implicit self?
3940    pub implicit_self: ImplicitSelfKind,
3941    /// Is lifetime elision allowed.
3942    pub lifetime_elision_allowed: bool,
3943}
3944
3945impl<'hir> FnDecl<'hir> {
3946    pub fn opt_delegation_sig_id(&self) -> Option<DefId> {
3947        if let FnRetTy::Return(ty) = self.output
3948            && let TyKind::InferDelegation(sig_id, _) = ty.kind
3949        {
3950            return Some(sig_id);
3951        }
3952        None
3953    }
3954
3955    pub fn opt_delegation_generics(&self) -> Option<&'hir DelegationGenerics> {
3956        if let FnRetTy::Return(ty) = self.output
3957            && let TyKind::InferDelegation(_, kind) = ty.kind
3958            && let InferDelegationKind::Output(generics) = kind
3959        {
3960            return Some(generics);
3961        }
3962
3963        None
3964    }
3965}
3966
3967/// Represents what type of implicit self a function has, if any.
3968#[derive(#[automatically_derived]
impl ::core::marker::Copy for ImplicitSelfKind { }Copy, #[automatically_derived]
impl ::core::clone::Clone for ImplicitSelfKind {
    #[inline]
    fn clone(&self) -> ImplicitSelfKind { *self }
}Clone, #[automatically_derived]
impl ::core::cmp::PartialEq for ImplicitSelfKind {
    #[inline]
    fn eq(&self, other: &ImplicitSelfKind) -> 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 ImplicitSelfKind {
    #[inline]
    #[doc(hidden)]
    #[coverage(off)]
    fn assert_fields_are_eq(&self) {}
}Eq, const _: () =
    {
        impl<__E: ::rustc_span::SpanEncoder> ::rustc_serialize::Encodable<__E>
            for ImplicitSelfKind {
            fn encode(&self, __encoder: &mut __E) {
                let disc =
                    match *self {
                        ImplicitSelfKind::Imm => { 0usize }
                        ImplicitSelfKind::Mut => { 1usize }
                        ImplicitSelfKind::RefImm => { 2usize }
                        ImplicitSelfKind::RefMut => { 3usize }
                        ImplicitSelfKind::None => { 4usize }
                    };
                ::rustc_serialize::Encoder::emit_u8(__encoder, disc as u8);
                match *self {
                    ImplicitSelfKind::Imm => {}
                    ImplicitSelfKind::Mut => {}
                    ImplicitSelfKind::RefImm => {}
                    ImplicitSelfKind::RefMut => {}
                    ImplicitSelfKind::None => {}
                }
            }
        }
    };Encodable, const _: () =
    {
        impl<__D: ::rustc_span::SpanDecoder> ::rustc_serialize::Decodable<__D>
            for ImplicitSelfKind {
            fn decode(__decoder: &mut __D) -> Self {
                match ::rustc_serialize::Decoder::read_u8(__decoder) as usize
                    {
                    0usize => { ImplicitSelfKind::Imm }
                    1usize => { ImplicitSelfKind::Mut }
                    2usize => { ImplicitSelfKind::RefImm }
                    3usize => { ImplicitSelfKind::RefMut }
                    4usize => { ImplicitSelfKind::None }
                    n => {
                        ::core::panicking::panic_fmt(format_args!("invalid enum variant tag while decoding `ImplicitSelfKind`, expected 0..5, actual {0}",
                                n));
                    }
                }
            }
        }
    };Decodable, #[automatically_derived]
impl ::core::fmt::Debug for ImplicitSelfKind {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::write_str(f,
            match self {
                ImplicitSelfKind::Imm => "Imm",
                ImplicitSelfKind::Mut => "Mut",
                ImplicitSelfKind::RefImm => "RefImm",
                ImplicitSelfKind::RefMut => "RefMut",
                ImplicitSelfKind::None => "None",
            })
    }
}Debug, const _: () =
    {
        impl<__CTX> ::rustc_data_structures::stable_hasher::HashStable<__CTX>
            for ImplicitSelfKind where __CTX: crate::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 {
                    ImplicitSelfKind::Imm => {}
                    ImplicitSelfKind::Mut => {}
                    ImplicitSelfKind::RefImm => {}
                    ImplicitSelfKind::RefMut => {}
                    ImplicitSelfKind::None => {}
                }
            }
        }
    };HashStable_Generic)]
3969pub enum ImplicitSelfKind {
3970    /// Represents a `fn x(self);`.
3971    Imm,
3972    /// Represents a `fn x(mut self);`.
3973    Mut,
3974    /// Represents a `fn x(&self);`.
3975    RefImm,
3976    /// Represents a `fn x(&mut self);`.
3977    RefMut,
3978    /// Represents when a function does not have a self argument or
3979    /// when a function has a `self: X` argument.
3980    None,
3981}
3982
3983impl ImplicitSelfKind {
3984    /// Does this represent an implicit self?
3985    pub fn has_implicit_self(&self) -> bool {
3986        !#[allow(non_exhaustive_omitted_patterns)] match *self {
    ImplicitSelfKind::None => true,
    _ => false,
}matches!(*self, ImplicitSelfKind::None)
3987    }
3988}
3989
3990#[derive(#[automatically_derived]
impl ::core::marker::Copy for IsAsync { }Copy, #[automatically_derived]
impl ::core::clone::Clone for IsAsync {
    #[inline]
    fn clone(&self) -> IsAsync {
        let _: ::core::clone::AssertParamIsClone<Span>;
        *self
    }
}Clone, #[automatically_derived]
impl ::core::cmp::PartialEq for IsAsync {
    #[inline]
    fn eq(&self, other: &IsAsync) -> bool {
        let __self_discr = ::core::intrinsics::discriminant_value(self);
        let __arg1_discr = ::core::intrinsics::discriminant_value(other);
        __self_discr == __arg1_discr &&
            match (self, other) {
                (IsAsync::Async(__self_0), IsAsync::Async(__arg1_0)) =>
                    __self_0 == __arg1_0,
                _ => true,
            }
    }
}PartialEq, #[automatically_derived]
impl ::core::cmp::Eq for IsAsync {
    #[inline]
    #[doc(hidden)]
    #[coverage(off)]
    fn assert_fields_are_eq(&self) {
        let _: ::core::cmp::AssertParamIsEq<Span>;
    }
}Eq, const _: () =
    {
        impl<__E: ::rustc_span::SpanEncoder> ::rustc_serialize::Encodable<__E>
            for IsAsync {
            fn encode(&self, __encoder: &mut __E) {
                let disc =
                    match *self {
                        IsAsync::Async(ref __binding_0) => { 0usize }
                        IsAsync::NotAsync => { 1usize }
                    };
                ::rustc_serialize::Encoder::emit_u8(__encoder, disc as u8);
                match *self {
                    IsAsync::Async(ref __binding_0) => {
                        ::rustc_serialize::Encodable::<__E>::encode(__binding_0,
                            __encoder);
                    }
                    IsAsync::NotAsync => {}
                }
            }
        }
    };Encodable, const _: () =
    {
        impl<__D: ::rustc_span::SpanDecoder> ::rustc_serialize::Decodable<__D>
            for IsAsync {
            fn decode(__decoder: &mut __D) -> Self {
                match ::rustc_serialize::Decoder::read_u8(__decoder) as usize
                    {
                    0usize => {
                        IsAsync::Async(::rustc_serialize::Decodable::decode(__decoder))
                    }
                    1usize => { IsAsync::NotAsync }
                    n => {
                        ::core::panicking::panic_fmt(format_args!("invalid enum variant tag while decoding `IsAsync`, expected 0..2, actual {0}",
                                n));
                    }
                }
            }
        }
    };Decodable, #[automatically_derived]
impl ::core::fmt::Debug for IsAsync {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        match self {
            IsAsync::Async(__self_0) =>
                ::core::fmt::Formatter::debug_tuple_field1_finish(f, "Async",
                    &__self_0),
            IsAsync::NotAsync =>
                ::core::fmt::Formatter::write_str(f, "NotAsync"),
        }
    }
}Debug, const _: () =
    {
        impl<__CTX> ::rustc_data_structures::stable_hasher::HashStable<__CTX>
            for IsAsync where __CTX: crate::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 {
                    IsAsync::Async(ref __binding_0) => {
                        { __binding_0.hash_stable(__hcx, __hasher); }
                    }
                    IsAsync::NotAsync => {}
                }
            }
        }
    };HashStable_Generic)]
3991pub enum IsAsync {
3992    Async(Span),
3993    NotAsync,
3994}
3995
3996impl IsAsync {
3997    pub fn is_async(self) -> bool {
3998        #[allow(non_exhaustive_omitted_patterns)] match self {
    IsAsync::Async(_) => true,
    _ => false,
}matches!(self, IsAsync::Async(_))
3999    }
4000}
4001
4002#[derive(#[automatically_derived]
impl ::core::marker::Copy for Defaultness { }Copy, #[automatically_derived]
impl ::core::clone::Clone for Defaultness {
    #[inline]
    fn clone(&self) -> Defaultness {
        let _: ::core::clone::AssertParamIsClone<bool>;
        *self
    }
}Clone, #[automatically_derived]
impl ::core::cmp::PartialEq for Defaultness {
    #[inline]
    fn eq(&self, other: &Defaultness) -> bool {
        let __self_discr = ::core::intrinsics::discriminant_value(self);
        let __arg1_discr = ::core::intrinsics::discriminant_value(other);
        __self_discr == __arg1_discr &&
            match (self, other) {
                (Defaultness::Default { has_value: __self_0 },
                    Defaultness::Default { has_value: __arg1_0 }) =>
                    __self_0 == __arg1_0,
                _ => true,
            }
    }
}PartialEq, #[automatically_derived]
impl ::core::cmp::Eq for Defaultness {
    #[inline]
    #[doc(hidden)]
    #[coverage(off)]
    fn assert_fields_are_eq(&self) {
        let _: ::core::cmp::AssertParamIsEq<bool>;
    }
}Eq, #[automatically_derived]
impl ::core::fmt::Debug for Defaultness {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        match self {
            Defaultness::Default { has_value: __self_0 } =>
                ::core::fmt::Formatter::debug_struct_field1_finish(f,
                    "Default", "has_value", &__self_0),
            Defaultness::Final =>
                ::core::fmt::Formatter::write_str(f, "Final"),
        }
    }
}Debug, const _: () =
    {
        impl<__E: ::rustc_span::SpanEncoder> ::rustc_serialize::Encodable<__E>
            for Defaultness {
            fn encode(&self, __encoder: &mut __E) {
                let disc =
                    match *self {
                        Defaultness::Default { has_value: ref __binding_0 } => {
                            0usize
                        }
                        Defaultness::Final => { 1usize }
                    };
                ::rustc_serialize::Encoder::emit_u8(__encoder, disc as u8);
                match *self {
                    Defaultness::Default { has_value: ref __binding_0 } => {
                        ::rustc_serialize::Encodable::<__E>::encode(__binding_0,
                            __encoder);
                    }
                    Defaultness::Final => {}
                }
            }
        }
    };Encodable, const _: () =
    {
        impl<__D: ::rustc_span::SpanDecoder> ::rustc_serialize::Decodable<__D>
            for Defaultness {
            fn decode(__decoder: &mut __D) -> Self {
                match ::rustc_serialize::Decoder::read_u8(__decoder) as usize
                    {
                    0usize => {
                        Defaultness::Default {
                            has_value: ::rustc_serialize::Decodable::decode(__decoder),
                        }
                    }
                    1usize => { Defaultness::Final }
                    n => {
                        ::core::panicking::panic_fmt(format_args!("invalid enum variant tag while decoding `Defaultness`, expected 0..2, actual {0}",
                                n));
                    }
                }
            }
        }
    };Decodable, const _: () =
    {
        impl<__CTX> ::rustc_data_structures::stable_hasher::HashStable<__CTX>
            for Defaultness where __CTX: crate::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 {
                    Defaultness::Default { has_value: ref __binding_0 } => {
                        { __binding_0.hash_stable(__hcx, __hasher); }
                    }
                    Defaultness::Final => {}
                }
            }
        }
    };HashStable_Generic)]
4003#[derive(#[automatically_derived]
impl ::core::default::Default for Defaultness {
    #[inline]
    fn default() -> Defaultness { Self::Final }
}Default)]
4004pub enum Defaultness {
4005    Default {
4006        has_value: bool,
4007    },
4008    #[default]
4009    Final,
4010}
4011
4012impl Defaultness {
4013    pub fn has_value(&self) -> bool {
4014        match *self {
4015            Defaultness::Default { has_value } => has_value,
4016            Defaultness::Final => true,
4017        }
4018    }
4019
4020    pub fn is_final(&self) -> bool {
4021        *self == Defaultness::Final
4022    }
4023
4024    pub fn is_default(&self) -> bool {
4025        #[allow(non_exhaustive_omitted_patterns)] match *self {
    Defaultness::Default { .. } => true,
    _ => false,
}matches!(*self, Defaultness::Default { .. })
4026    }
4027}
4028
4029#[derive(#[automatically_derived]
impl<'hir> ::core::fmt::Debug for FnRetTy<'hir> {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        match self {
            FnRetTy::DefaultReturn(__self_0) =>
                ::core::fmt::Formatter::debug_tuple_field1_finish(f,
                    "DefaultReturn", &__self_0),
            FnRetTy::Return(__self_0) =>
                ::core::fmt::Formatter::debug_tuple_field1_finish(f, "Return",
                    &__self_0),
        }
    }
}Debug, #[automatically_derived]
impl<'hir> ::core::clone::Clone for FnRetTy<'hir> {
    #[inline]
    fn clone(&self) -> FnRetTy<'hir> {
        let _: ::core::clone::AssertParamIsClone<Span>;
        let _: ::core::clone::AssertParamIsClone<&'hir Ty<'hir>>;
        *self
    }
}Clone, #[automatically_derived]
impl<'hir> ::core::marker::Copy for FnRetTy<'hir> { }Copy, const _: () =
    {
        impl<'hir, __CTX>
            ::rustc_data_structures::stable_hasher::HashStable<__CTX> for
            FnRetTy<'hir> where __CTX: crate::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 {
                    FnRetTy::DefaultReturn(ref __binding_0) => {
                        { __binding_0.hash_stable(__hcx, __hasher); }
                    }
                    FnRetTy::Return(ref __binding_0) => {
                        { __binding_0.hash_stable(__hcx, __hasher); }
                    }
                }
            }
        }
    };HashStable_Generic)]
4030pub enum FnRetTy<'hir> {
4031    /// Return type is not specified.
4032    ///
4033    /// Functions default to `()` and
4034    /// closures default to inference. Span points to where return
4035    /// type would be inserted.
4036    DefaultReturn(Span),
4037    /// Everything else.
4038    Return(&'hir Ty<'hir>),
4039}
4040
4041impl<'hir> FnRetTy<'hir> {
4042    #[inline]
4043    pub fn span(&self) -> Span {
4044        match *self {
4045            Self::DefaultReturn(span) => span,
4046            Self::Return(ref ty) => ty.span,
4047        }
4048    }
4049
4050    pub fn is_suggestable_infer_ty(&self) -> Option<&'hir Ty<'hir>> {
4051        if let Self::Return(ty) = self
4052            && ty.is_suggestable_infer_ty()
4053        {
4054            return Some(*ty);
4055        }
4056        None
4057    }
4058}
4059
4060/// Represents `for<...>` binder before a closure
4061#[derive(#[automatically_derived]
impl ::core::marker::Copy for ClosureBinder { }Copy, #[automatically_derived]
impl ::core::clone::Clone for ClosureBinder {
    #[inline]
    fn clone(&self) -> ClosureBinder {
        let _: ::core::clone::AssertParamIsClone<Span>;
        *self
    }
}Clone, #[automatically_derived]
impl ::core::fmt::Debug for ClosureBinder {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        match self {
            ClosureBinder::Default =>
                ::core::fmt::Formatter::write_str(f, "Default"),
            ClosureBinder::For { span: __self_0 } =>
                ::core::fmt::Formatter::debug_struct_field1_finish(f, "For",
                    "span", &__self_0),
        }
    }
}Debug, const _: () =
    {
        impl<__CTX> ::rustc_data_structures::stable_hasher::HashStable<__CTX>
            for ClosureBinder where __CTX: crate::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 {
                    ClosureBinder::Default => {}
                    ClosureBinder::For { span: ref __binding_0 } => {
                        { __binding_0.hash_stable(__hcx, __hasher); }
                    }
                }
            }
        }
    };HashStable_Generic)]
4062pub enum ClosureBinder {
4063    /// Binder is not specified.
4064    Default,
4065    /// Binder is specified.
4066    ///
4067    /// Span points to the whole `for<...>`.
4068    For { span: Span },
4069}
4070
4071#[derive(#[automatically_derived]
impl<'hir> ::core::fmt::Debug for Mod<'hir> {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::debug_struct_field2_finish(f, "Mod", "spans",
            &self.spans, "item_ids", &&self.item_ids)
    }
}Debug, #[automatically_derived]
impl<'hir> ::core::clone::Clone for Mod<'hir> {
    #[inline]
    fn clone(&self) -> Mod<'hir> {
        let _: ::core::clone::AssertParamIsClone<ModSpans>;
        let _: ::core::clone::AssertParamIsClone<&'hir [ItemId]>;
        *self
    }
}Clone, #[automatically_derived]
impl<'hir> ::core::marker::Copy for Mod<'hir> { }Copy, const _: () =
    {
        impl<'hir, __CTX>
            ::rustc_data_structures::stable_hasher::HashStable<__CTX> for
            Mod<'hir> where __CTX: crate::HashStableContext {
            #[inline]
            fn hash_stable(&self, __hcx: &mut __CTX,
                __hasher:
                    &mut ::rustc_data_structures::stable_hasher::StableHasher) {
                match *self {
                    Mod { spans: ref __binding_0, item_ids: ref __binding_1 } =>
                        {
                        { __binding_0.hash_stable(__hcx, __hasher); }
                        { __binding_1.hash_stable(__hcx, __hasher); }
                    }
                }
            }
        }
    };HashStable_Generic)]
4072pub struct Mod<'hir> {
4073    pub spans: ModSpans,
4074    pub item_ids: &'hir [ItemId],
4075}
4076
4077#[derive(#[automatically_derived]
impl ::core::marker::Copy for ModSpans { }Copy, #[automatically_derived]
impl ::core::clone::Clone for ModSpans {
    #[inline]
    fn clone(&self) -> ModSpans {
        let _: ::core::clone::AssertParamIsClone<Span>;
        *self
    }
}Clone, #[automatically_derived]
impl ::core::fmt::Debug for ModSpans {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::debug_struct_field2_finish(f, "ModSpans",
            "inner_span", &self.inner_span, "inject_use_span",
            &&self.inject_use_span)
    }
}Debug, const _: () =
    {
        impl<__CTX> ::rustc_data_structures::stable_hasher::HashStable<__CTX>
            for ModSpans where __CTX: crate::HashStableContext {
            #[inline]
            fn hash_stable(&self, __hcx: &mut __CTX,
                __hasher:
                    &mut ::rustc_data_structures::stable_hasher::StableHasher) {
                match *self {
                    ModSpans {
                        inner_span: ref __binding_0,
                        inject_use_span: ref __binding_1 } => {
                        { __binding_0.hash_stable(__hcx, __hasher); }
                        { __binding_1.hash_stable(__hcx, __hasher); }
                    }
                }
            }
        }
    };HashStable_Generic)]
4078pub struct ModSpans {
4079    /// A span from the first token past `{` to the last token until `}`.
4080    /// For `mod foo;`, the inner span ranges from the first token
4081    /// to the last token in the external file.
4082    pub inner_span: Span,
4083    pub inject_use_span: Span,
4084}
4085
4086#[derive(#[automatically_derived]
impl<'hir> ::core::fmt::Debug for EnumDef<'hir> {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::debug_struct_field1_finish(f, "EnumDef",
            "variants", &&self.variants)
    }
}Debug, #[automatically_derived]
impl<'hir> ::core::clone::Clone for EnumDef<'hir> {
    #[inline]
    fn clone(&self) -> EnumDef<'hir> {
        let _: ::core::clone::AssertParamIsClone<&'hir [Variant<'hir>]>;
        *self
    }
}Clone, #[automatically_derived]
impl<'hir> ::core::marker::Copy for EnumDef<'hir> { }Copy, const _: () =
    {
        impl<'hir, __CTX>
            ::rustc_data_structures::stable_hasher::HashStable<__CTX> for
            EnumDef<'hir> where __CTX: crate::HashStableContext {
            #[inline]
            fn hash_stable(&self, __hcx: &mut __CTX,
                __hasher:
                    &mut ::rustc_data_structures::stable_hasher::StableHasher) {
                match *self {
                    EnumDef { variants: ref __binding_0 } => {
                        { __binding_0.hash_stable(__hcx, __hasher); }
                    }
                }
            }
        }
    };HashStable_Generic)]
4087pub struct EnumDef<'hir> {
4088    pub variants: &'hir [Variant<'hir>],
4089}
4090
4091#[derive(#[automatically_derived]
impl<'hir> ::core::fmt::Debug for Variant<'hir> {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        let names: &'static _ =
            &["ident", "hir_id", "def_id", "data", "disr_expr", "span"];
        let values: &[&dyn ::core::fmt::Debug] =
            &[&self.ident, &self.hir_id, &self.def_id, &self.data,
                        &self.disr_expr, &&self.span];
        ::core::fmt::Formatter::debug_struct_fields_finish(f, "Variant",
            names, values)
    }
}Debug, #[automatically_derived]
impl<'hir> ::core::clone::Clone for Variant<'hir> {
    #[inline]
    fn clone(&self) -> Variant<'hir> {
        let _: ::core::clone::AssertParamIsClone<Ident>;
        let _: ::core::clone::AssertParamIsClone<HirId>;
        let _: ::core::clone::AssertParamIsClone<LocalDefId>;
        let _: ::core::clone::AssertParamIsClone<VariantData<'hir>>;
        let _: ::core::clone::AssertParamIsClone<Option<&'hir AnonConst>>;
        let _: ::core::clone::AssertParamIsClone<Span>;
        *self
    }
}Clone, #[automatically_derived]
impl<'hir> ::core::marker::Copy for Variant<'hir> { }Copy, const _: () =
    {
        impl<'hir, __CTX>
            ::rustc_data_structures::stable_hasher::HashStable<__CTX> for
            Variant<'hir> where __CTX: crate::HashStableContext {
            #[inline]
            fn hash_stable(&self, __hcx: &mut __CTX,
                __hasher:
                    &mut ::rustc_data_structures::stable_hasher::StableHasher) {
                match *self {
                    Variant {
                        ident: ref __binding_0,
                        hir_id: ref __binding_1,
                        def_id: ref __binding_2,
                        data: ref __binding_3,
                        disr_expr: ref __binding_4,
                        span: ref __binding_5 } => {
                        { __binding_0.hash_stable(__hcx, __hasher); }
                        {}
                        { __binding_2.hash_stable(__hcx, __hasher); }
                        { __binding_3.hash_stable(__hcx, __hasher); }
                        { __binding_4.hash_stable(__hcx, __hasher); }
                        { __binding_5.hash_stable(__hcx, __hasher); }
                    }
                }
            }
        }
    };HashStable_Generic)]
4092pub struct Variant<'hir> {
4093    /// Name of the variant.
4094    pub ident: Ident,
4095    /// Id of the variant (not the constructor, see `VariantData::ctor_hir_id()`).
4096    #[stable_hasher(ignore)]
4097    pub hir_id: HirId,
4098    pub def_id: LocalDefId,
4099    /// Fields and constructor id of the variant.
4100    pub data: VariantData<'hir>,
4101    /// Explicit discriminant (e.g., `Foo = 1`).
4102    pub disr_expr: Option<&'hir AnonConst>,
4103    /// Span
4104    pub span: Span,
4105}
4106
4107#[derive(#[automatically_derived]
impl ::core::marker::Copy for UseKind { }Copy, #[automatically_derived]
impl ::core::clone::Clone for UseKind {
    #[inline]
    fn clone(&self) -> UseKind {
        let _: ::core::clone::AssertParamIsClone<Ident>;
        *self
    }
}Clone, #[automatically_derived]
impl ::core::cmp::PartialEq for UseKind {
    #[inline]
    fn eq(&self, other: &UseKind) -> bool {
        let __self_discr = ::core::intrinsics::discriminant_value(self);
        let __arg1_discr = ::core::intrinsics::discriminant_value(other);
        __self_discr == __arg1_discr &&
            match (self, other) {
                (UseKind::Single(__self_0), UseKind::Single(__arg1_0)) =>
                    __self_0 == __arg1_0,
                _ => true,
            }
    }
}PartialEq, #[automatically_derived]
impl ::core::fmt::Debug for UseKind {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        match self {
            UseKind::Single(__self_0) =>
                ::core::fmt::Formatter::debug_tuple_field1_finish(f, "Single",
                    &__self_0),
            UseKind::Glob => ::core::fmt::Formatter::write_str(f, "Glob"),
            UseKind::ListStem =>
                ::core::fmt::Formatter::write_str(f, "ListStem"),
        }
    }
}Debug, const _: () =
    {
        impl<__CTX> ::rustc_data_structures::stable_hasher::HashStable<__CTX>
            for UseKind where __CTX: crate::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 {
                    UseKind::Single(ref __binding_0) => {
                        { __binding_0.hash_stable(__hcx, __hasher); }
                    }
                    UseKind::Glob => {}
                    UseKind::ListStem => {}
                }
            }
        }
    };HashStable_Generic)]
4108pub enum UseKind {
4109    /// One import, e.g., `use foo::bar` or `use foo::bar as baz`.
4110    /// Also produced for each element of a list `use`, e.g.
4111    /// `use foo::{a, b}` lowers to `use foo::a; use foo::b;`.
4112    ///
4113    /// The identifier is the name defined by the import. E.g. for `use
4114    /// foo::bar` it is `bar`, for `use foo::bar as baz` it is `baz`.
4115    Single(Ident),
4116
4117    /// Glob import, e.g., `use foo::*`.
4118    Glob,
4119
4120    /// Degenerate list import, e.g., `use foo::{a, b}` produces
4121    /// an additional `use foo::{}` for performing checks such as
4122    /// unstable feature gating. May be removed in the future.
4123    ListStem,
4124}
4125
4126/// References to traits in impls.
4127///
4128/// `resolve` maps each `TraitRef`'s `ref_id` to its defining trait; that's all
4129/// that the `ref_id` is for. Note that `ref_id`'s value is not the `HirId` of the
4130/// trait being referred to but just a unique `HirId` that serves as a key
4131/// within the resolution map.
4132#[derive(#[automatically_derived]
impl<'hir> ::core::clone::Clone for TraitRef<'hir> {
    #[inline]
    fn clone(&self) -> TraitRef<'hir> {
        let _: ::core::clone::AssertParamIsClone<&'hir Path<'hir>>;
        let _: ::core::clone::AssertParamIsClone<HirId>;
        *self
    }
}Clone, #[automatically_derived]
impl<'hir> ::core::fmt::Debug for TraitRef<'hir> {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::debug_struct_field2_finish(f, "TraitRef",
            "path", &self.path, "hir_ref_id", &&self.hir_ref_id)
    }
}Debug, #[automatically_derived]
impl<'hir> ::core::marker::Copy for TraitRef<'hir> { }Copy, const _: () =
    {
        impl<'hir, __CTX>
            ::rustc_data_structures::stable_hasher::HashStable<__CTX> for
            TraitRef<'hir> where __CTX: crate::HashStableContext {
            #[inline]
            fn hash_stable(&self, __hcx: &mut __CTX,
                __hasher:
                    &mut ::rustc_data_structures::stable_hasher::StableHasher) {
                match *self {
                    TraitRef {
                        path: ref __binding_0, hir_ref_id: ref __binding_1 } => {
                        { __binding_0.hash_stable(__hcx, __hasher); }
                        {}
                    }
                }
            }
        }
    };HashStable_Generic)]
4133pub struct TraitRef<'hir> {
4134    pub path: &'hir Path<'hir>,
4135    // Don't hash the `ref_id`. It is tracked via the thing it is used to access.
4136    #[stable_hasher(ignore)]
4137    pub hir_ref_id: HirId,
4138}
4139
4140impl TraitRef<'_> {
4141    /// Gets the `DefId` of the referenced trait. It _must_ actually be a trait or trait alias.
4142    pub fn trait_def_id(&self) -> Option<DefId> {
4143        match self.path.res {
4144            Res::Def(DefKind::Trait | DefKind::TraitAlias, did) => Some(did),
4145            Res::Err => None,
4146            res => {
    ::core::panicking::panic_fmt(format_args!("{0:?} did not resolve to a trait or trait alias",
            res));
}panic!("{res:?} did not resolve to a trait or trait alias"),
4147        }
4148    }
4149}
4150
4151#[derive(#[automatically_derived]
impl<'hir> ::core::clone::Clone for PolyTraitRef<'hir> {
    #[inline]
    fn clone(&self) -> PolyTraitRef<'hir> {
        let _: ::core::clone::AssertParamIsClone<&'hir [GenericParam<'hir>]>;
        let _: ::core::clone::AssertParamIsClone<TraitBoundModifiers>;
        let _: ::core::clone::AssertParamIsClone<TraitRef<'hir>>;
        let _: ::core::clone::AssertParamIsClone<Span>;
        *self
    }
}Clone, #[automatically_derived]
impl<'hir> ::core::fmt::Debug for PolyTraitRef<'hir> {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::debug_struct_field4_finish(f, "PolyTraitRef",
            "bound_generic_params", &self.bound_generic_params, "modifiers",
            &self.modifiers, "trait_ref", &self.trait_ref, "span",
            &&self.span)
    }
}Debug, #[automatically_derived]
impl<'hir> ::core::marker::Copy for PolyTraitRef<'hir> { }Copy, const _: () =
    {
        impl<'hir, __CTX>
            ::rustc_data_structures::stable_hasher::HashStable<__CTX> for
            PolyTraitRef<'hir> where __CTX: crate::HashStableContext {
            #[inline]
            fn hash_stable(&self, __hcx: &mut __CTX,
                __hasher:
                    &mut ::rustc_data_structures::stable_hasher::StableHasher) {
                match *self {
                    PolyTraitRef {
                        bound_generic_params: ref __binding_0,
                        modifiers: ref __binding_1,
                        trait_ref: ref __binding_2,
                        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); }
                    }
                }
            }
        }
    };HashStable_Generic)]
4152pub struct PolyTraitRef<'hir> {
4153    /// The `'a` in `for<'a> Foo<&'a T>`.
4154    pub bound_generic_params: &'hir [GenericParam<'hir>],
4155
4156    /// The constness and polarity of the trait ref.
4157    ///
4158    /// The `async` modifier is lowered directly into a different trait for now.
4159    pub modifiers: TraitBoundModifiers,
4160
4161    /// The `Foo<&'a T>` in `for<'a> Foo<&'a T>`.
4162    pub trait_ref: TraitRef<'hir>,
4163
4164    pub span: Span,
4165}
4166
4167#[derive(#[automatically_derived]
impl<'hir> ::core::fmt::Debug for FieldDef<'hir> {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        let names: &'static _ =
            &["span", "vis_span", "ident", "hir_id", "def_id", "ty", "safety",
                        "default"];
        let values: &[&dyn ::core::fmt::Debug] =
            &[&self.span, &self.vis_span, &self.ident, &self.hir_id,
                        &self.def_id, &self.ty, &self.safety, &&self.default];
        ::core::fmt::Formatter::debug_struct_fields_finish(f, "FieldDef",
            names, values)
    }
}Debug, #[automatically_derived]
impl<'hir> ::core::clone::Clone for FieldDef<'hir> {
    #[inline]
    fn clone(&self) -> FieldDef<'hir> {
        let _: ::core::clone::AssertParamIsClone<Span>;
        let _: ::core::clone::AssertParamIsClone<Ident>;
        let _: ::core::clone::AssertParamIsClone<HirId>;
        let _: ::core::clone::AssertParamIsClone<LocalDefId>;
        let _: ::core::clone::AssertParamIsClone<&'hir Ty<'hir>>;
        let _: ::core::clone::AssertParamIsClone<Safety>;
        let _: ::core::clone::AssertParamIsClone<Option<&'hir AnonConst>>;
        *self
    }
}Clone, #[automatically_derived]
impl<'hir> ::core::marker::Copy for FieldDef<'hir> { }Copy, const _: () =
    {
        impl<'hir, __CTX>
            ::rustc_data_structures::stable_hasher::HashStable<__CTX> for
            FieldDef<'hir> where __CTX: crate::HashStableContext {
            #[inline]
            fn hash_stable(&self, __hcx: &mut __CTX,
                __hasher:
                    &mut ::rustc_data_structures::stable_hasher::StableHasher) {
                match *self {
                    FieldDef {
                        span: ref __binding_0,
                        vis_span: ref __binding_1,
                        ident: ref __binding_2,
                        hir_id: ref __binding_3,
                        def_id: ref __binding_4,
                        ty: ref __binding_5,
                        safety: ref __binding_6,
                        default: ref __binding_7 } => {
                        { __binding_0.hash_stable(__hcx, __hasher); }
                        { __binding_1.hash_stable(__hcx, __hasher); }
                        { __binding_2.hash_stable(__hcx, __hasher); }
                        {}
                        { __binding_4.hash_stable(__hcx, __hasher); }
                        { __binding_5.hash_stable(__hcx, __hasher); }
                        { __binding_6.hash_stable(__hcx, __hasher); }
                        { __binding_7.hash_stable(__hcx, __hasher); }
                    }
                }
            }
        }
    };HashStable_Generic)]
4168pub struct FieldDef<'hir> {
4169    pub span: Span,
4170    pub vis_span: Span,
4171    pub ident: Ident,
4172    #[stable_hasher(ignore)]
4173    pub hir_id: HirId,
4174    pub def_id: LocalDefId,
4175    pub ty: &'hir Ty<'hir>,
4176    pub safety: Safety,
4177    pub default: Option<&'hir AnonConst>,
4178}
4179
4180impl FieldDef<'_> {
4181    // Still necessary in couple of places
4182    pub fn is_positional(&self) -> bool {
4183        self.ident.as_str().as_bytes()[0].is_ascii_digit()
4184    }
4185}
4186
4187/// Fields and constructor IDs of enum variants and structs.
4188#[derive(#[automatically_derived]
impl<'hir> ::core::fmt::Debug for VariantData<'hir> {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        match self {
            VariantData::Struct { fields: __self_0, recovered: __self_1 } =>
                ::core::fmt::Formatter::debug_struct_field2_finish(f,
                    "Struct", "fields", __self_0, "recovered", &__self_1),
            VariantData::Tuple(__self_0, __self_1, __self_2) =>
                ::core::fmt::Formatter::debug_tuple_field3_finish(f, "Tuple",
                    __self_0, __self_1, &__self_2),
            VariantData::Unit(__self_0, __self_1) =>
                ::core::fmt::Formatter::debug_tuple_field2_finish(f, "Unit",
                    __self_0, &__self_1),
        }
    }
}Debug, #[automatically_derived]
impl<'hir> ::core::clone::Clone for VariantData<'hir> {
    #[inline]
    fn clone(&self) -> VariantData<'hir> {
        let _: ::core::clone::AssertParamIsClone<&'hir [FieldDef<'hir>]>;
        let _: ::core::clone::AssertParamIsClone<ast::Recovered>;
        let _: ::core::clone::AssertParamIsClone<&'hir [FieldDef<'hir>]>;
        let _: ::core::clone::AssertParamIsClone<HirId>;
        let _: ::core::clone::AssertParamIsClone<LocalDefId>;
        *self
    }
}Clone, #[automatically_derived]
impl<'hir> ::core::marker::Copy for VariantData<'hir> { }Copy, const _: () =
    {
        impl<'hir, __CTX>
            ::rustc_data_structures::stable_hasher::HashStable<__CTX> for
            VariantData<'hir> where __CTX: crate::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 {
                    VariantData::Struct {
                        fields: ref __binding_0, recovered: ref __binding_1 } => {
                        { __binding_0.hash_stable(__hcx, __hasher); }
                        { __binding_1.hash_stable(__hcx, __hasher); }
                    }
                    VariantData::Tuple(ref __binding_0, ref __binding_1,
                        ref __binding_2) => {
                        { __binding_0.hash_stable(__hcx, __hasher); }
                        {}
                        { __binding_2.hash_stable(__hcx, __hasher); }
                    }
                    VariantData::Unit(ref __binding_0, ref __binding_1) => {
                        {}
                        { __binding_1.hash_stable(__hcx, __hasher); }
                    }
                }
            }
        }
    };HashStable_Generic)]
4189pub enum VariantData<'hir> {
4190    /// A struct variant.
4191    ///
4192    /// E.g., `Bar { .. }` as in `enum Foo { Bar { .. } }`.
4193    Struct { fields: &'hir [FieldDef<'hir>], recovered: ast::Recovered },
4194    /// A tuple variant.
4195    ///
4196    /// E.g., `Bar(..)` as in `enum Foo { Bar(..) }`.
4197    Tuple(&'hir [FieldDef<'hir>], #[stable_hasher(ignore)] HirId, LocalDefId),
4198    /// A unit variant.
4199    ///
4200    /// E.g., `Bar = ..` as in `enum Foo { Bar = .. }`.
4201    Unit(#[stable_hasher(ignore)] HirId, LocalDefId),
4202}
4203
4204impl<'hir> VariantData<'hir> {
4205    /// Return the fields of this variant.
4206    pub fn fields(&self) -> &'hir [FieldDef<'hir>] {
4207        match *self {
4208            VariantData::Struct { fields, .. } | VariantData::Tuple(fields, ..) => fields,
4209            _ => &[],
4210        }
4211    }
4212
4213    pub fn ctor(&self) -> Option<(CtorKind, HirId, LocalDefId)> {
4214        match *self {
4215            VariantData::Tuple(_, hir_id, def_id) => Some((CtorKind::Fn, hir_id, def_id)),
4216            VariantData::Unit(hir_id, def_id) => Some((CtorKind::Const, hir_id, def_id)),
4217            VariantData::Struct { .. } => None,
4218        }
4219    }
4220
4221    #[inline]
4222    pub fn ctor_kind(&self) -> Option<CtorKind> {
4223        self.ctor().map(|(kind, ..)| kind)
4224    }
4225
4226    /// Return the `HirId` of this variant's constructor, if it has one.
4227    #[inline]
4228    pub fn ctor_hir_id(&self) -> Option<HirId> {
4229        self.ctor().map(|(_, hir_id, _)| hir_id)
4230    }
4231
4232    /// Return the `LocalDefId` of this variant's constructor, if it has one.
4233    #[inline]
4234    pub fn ctor_def_id(&self) -> Option<LocalDefId> {
4235        self.ctor().map(|(.., def_id)| def_id)
4236    }
4237}
4238
4239// The bodies for items are stored "out of line", in a separate
4240// hashmap in the `Crate`. Here we just record the hir-id of the item
4241// so it can fetched later.
4242#[derive(#[automatically_derived]
impl ::core::marker::Copy for ItemId { }Copy, #[automatically_derived]
impl ::core::clone::Clone for ItemId {
    #[inline]
    fn clone(&self) -> ItemId {
        let _: ::core::clone::AssertParamIsClone<OwnerId>;
        *self
    }
}Clone, #[automatically_derived]
impl ::core::cmp::PartialEq for ItemId {
    #[inline]
    fn eq(&self, other: &ItemId) -> bool { self.owner_id == other.owner_id }
}PartialEq, #[automatically_derived]
impl ::core::cmp::Eq for ItemId {
    #[inline]
    #[doc(hidden)]
    #[coverage(off)]
    fn assert_fields_are_eq(&self) {
        let _: ::core::cmp::AssertParamIsEq<OwnerId>;
    }
}Eq, const _: () =
    {
        impl<__E: ::rustc_span::SpanEncoder> ::rustc_serialize::Encodable<__E>
            for ItemId {
            fn encode(&self, __encoder: &mut __E) {
                match *self {
                    ItemId { owner_id: ref __binding_0 } => {
                        ::rustc_serialize::Encodable::<__E>::encode(__binding_0,
                            __encoder);
                    }
                }
            }
        }
    };Encodable, const _: () =
    {
        impl<__D: ::rustc_span::SpanDecoder> ::rustc_serialize::Decodable<__D>
            for ItemId {
            fn decode(__decoder: &mut __D) -> Self {
                ItemId {
                    owner_id: ::rustc_serialize::Decodable::decode(__decoder),
                }
            }
        }
    };Decodable, #[automatically_derived]
impl ::core::fmt::Debug for ItemId {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::debug_struct_field1_finish(f, "ItemId",
            "owner_id", &&self.owner_id)
    }
}Debug, #[automatically_derived]
impl ::core::hash::Hash for ItemId {
    #[inline]
    fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) {
        ::core::hash::Hash::hash(&self.owner_id, state)
    }
}Hash, const _: () =
    {
        impl<__CTX> ::rustc_data_structures::stable_hasher::HashStable<__CTX>
            for ItemId where __CTX: crate::HashStableContext {
            #[inline]
            fn hash_stable(&self, __hcx: &mut __CTX,
                __hasher:
                    &mut ::rustc_data_structures::stable_hasher::StableHasher) {
                match *self {
                    ItemId { owner_id: ref __binding_0 } => {
                        { __binding_0.hash_stable(__hcx, __hasher); }
                    }
                }
            }
        }
    };HashStable_Generic)]
4243pub struct ItemId {
4244    pub owner_id: OwnerId,
4245}
4246
4247impl ItemId {
4248    #[inline]
4249    pub fn hir_id(&self) -> HirId {
4250        // Items are always HIR owners.
4251        HirId::make_owner(self.owner_id.def_id)
4252    }
4253}
4254
4255/// An item
4256///
4257/// For more details, see the [rust lang reference].
4258/// Note that the reference does not document nightly-only features.
4259/// There may be also slight differences in the names and representation of AST nodes between
4260/// the compiler and the reference.
4261///
4262/// [rust lang reference]: https://doc.rust-lang.org/reference/items.html
4263#[derive(#[automatically_derived]
impl<'hir> ::core::fmt::Debug for Item<'hir> {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        let names: &'static _ =
            &["owner_id", "kind", "span", "vis_span", "has_delayed_lints",
                        "eii"];
        let values: &[&dyn ::core::fmt::Debug] =
            &[&self.owner_id, &self.kind, &self.span, &self.vis_span,
                        &self.has_delayed_lints, &&self.eii];
        ::core::fmt::Formatter::debug_struct_fields_finish(f, "Item", names,
            values)
    }
}Debug, #[automatically_derived]
impl<'hir> ::core::clone::Clone for Item<'hir> {
    #[inline]
    fn clone(&self) -> Item<'hir> {
        let _: ::core::clone::AssertParamIsClone<OwnerId>;
        let _: ::core::clone::AssertParamIsClone<ItemKind<'hir>>;
        let _: ::core::clone::AssertParamIsClone<Span>;
        let _: ::core::clone::AssertParamIsClone<bool>;
        *self
    }
}Clone, #[automatically_derived]
impl<'hir> ::core::marker::Copy for Item<'hir> { }Copy, const _: () =
    {
        impl<'hir, __CTX>
            ::rustc_data_structures::stable_hasher::HashStable<__CTX> for
            Item<'hir> where __CTX: crate::HashStableContext {
            #[inline]
            fn hash_stable(&self, __hcx: &mut __CTX,
                __hasher:
                    &mut ::rustc_data_structures::stable_hasher::StableHasher) {
                match *self {
                    Item {
                        owner_id: ref __binding_0,
                        kind: ref __binding_1,
                        span: ref __binding_2,
                        vis_span: ref __binding_3,
                        has_delayed_lints: ref __binding_4,
                        eii: ref __binding_5 } => {
                        { __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); }
                        { __binding_5.hash_stable(__hcx, __hasher); }
                    }
                }
            }
        }
    };HashStable_Generic)]
4264pub struct Item<'hir> {
4265    pub owner_id: OwnerId,
4266    pub kind: ItemKind<'hir>,
4267    pub span: Span,
4268    pub vis_span: Span,
4269    pub has_delayed_lints: bool,
4270    /// hint to speed up collection: true if the item is a static or function and has
4271    /// either an `EiiImpls` or `EiiExternTarget` attribute
4272    pub eii: bool,
4273}
4274
4275impl<'hir> Item<'hir> {
4276    #[inline]
4277    pub fn hir_id(&self) -> HirId {
4278        // Items are always HIR owners.
4279        HirId::make_owner(self.owner_id.def_id)
4280    }
4281
4282    pub fn item_id(&self) -> ItemId {
4283        ItemId { owner_id: self.owner_id }
4284    }
4285
4286    /// Check if this is an [`ItemKind::Enum`], [`ItemKind::Struct`] or
4287    /// [`ItemKind::Union`].
4288    pub fn is_adt(&self) -> bool {
4289        #[allow(non_exhaustive_omitted_patterns)] match self.kind {
    ItemKind::Enum(..) | ItemKind::Struct(..) | ItemKind::Union(..) => true,
    _ => false,
}matches!(self.kind, ItemKind::Enum(..) | ItemKind::Struct(..) | ItemKind::Union(..))
4290    }
4291
4292    /// Check if this is an [`ItemKind::Struct`] or [`ItemKind::Union`].
4293    pub fn is_struct_or_union(&self) -> bool {
4294        #[allow(non_exhaustive_omitted_patterns)] match self.kind {
    ItemKind::Struct(..) | ItemKind::Union(..) => true,
    _ => false,
}matches!(self.kind, ItemKind::Struct(..) | ItemKind::Union(..))
4295    }
4296
4297    self
let ItemKind::Impl(imp) =
    &self.kind else { expect_failed("expect_impl", self) };
imp;expect_methods_self_kind! {
4298        expect_extern_crate, (Option<Symbol>, Ident),
4299            ItemKind::ExternCrate(s, ident), (*s, *ident);
4300
4301        expect_use, (&'hir UsePath<'hir>, UseKind), ItemKind::Use(p, uk), (p, *uk);
4302
4303        expect_static, (Mutability, Ident, &'hir Ty<'hir>, BodyId),
4304            ItemKind::Static(mutbl, ident, ty, body), (*mutbl, *ident, ty, *body);
4305
4306        expect_const, (Ident, &'hir Generics<'hir>, &'hir Ty<'hir>, ConstItemRhs<'hir>),
4307            ItemKind::Const(ident, generics, ty, rhs), (*ident, generics, ty, *rhs);
4308
4309        expect_fn, (Ident, &FnSig<'hir>, &'hir Generics<'hir>, BodyId),
4310            ItemKind::Fn { ident, sig, generics, body, .. }, (*ident, sig, generics, *body);
4311
4312        expect_macro, (Ident, &ast::MacroDef, MacroKinds),
4313            ItemKind::Macro(ident, def, mk), (*ident, def, *mk);
4314
4315        expect_mod, (Ident, &'hir Mod<'hir>), ItemKind::Mod(ident, m), (*ident, m);
4316
4317        expect_foreign_mod, (ExternAbi, &'hir [ForeignItemId]),
4318            ItemKind::ForeignMod { abi, items }, (*abi, items);
4319
4320        expect_global_asm, &'hir InlineAsm<'hir>, ItemKind::GlobalAsm { asm, .. }, asm;
4321
4322        expect_ty_alias, (Ident, &'hir Generics<'hir>, &'hir Ty<'hir>),
4323            ItemKind::TyAlias(ident, generics, ty), (*ident, generics, ty);
4324
4325        expect_enum, (Ident, &'hir Generics<'hir>, &EnumDef<'hir>),
4326            ItemKind::Enum(ident, generics, def), (*ident, generics, def);
4327
4328        expect_struct, (Ident, &'hir Generics<'hir>, &VariantData<'hir>),
4329            ItemKind::Struct(ident, generics, data), (*ident, generics, data);
4330
4331        expect_union, (Ident, &'hir Generics<'hir>, &VariantData<'hir>),
4332            ItemKind::Union(ident, generics, data), (*ident, generics, data);
4333
4334        expect_trait,
4335            (
4336                Constness,
4337                IsAuto,
4338                Safety,
4339                Ident,
4340                &'hir Generics<'hir>,
4341                GenericBounds<'hir>,
4342                &'hir [TraitItemId]
4343            ),
4344            ItemKind::Trait(constness, is_auto, safety, ident, generics, bounds, items),
4345            (*constness, *is_auto, *safety, *ident, generics, bounds, items);
4346
4347        expect_trait_alias, (Constness, Ident, &'hir Generics<'hir>, GenericBounds<'hir>),
4348            ItemKind::TraitAlias(constness, ident, generics, bounds), (*constness, *ident, generics, bounds);
4349
4350        expect_impl, &Impl<'hir>, ItemKind::Impl(imp), imp;
4351    }
4352}
4353
4354#[derive(#[automatically_derived]
impl ::core::marker::Copy for Safety { }Copy, #[automatically_derived]
impl ::core::clone::Clone for Safety {
    #[inline]
    fn clone(&self) -> Safety { *self }
}Clone, #[automatically_derived]
impl ::core::cmp::PartialEq for Safety {
    #[inline]
    fn eq(&self, other: &Safety) -> 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 Safety {
    #[inline]
    #[doc(hidden)]
    #[coverage(off)]
    fn assert_fields_are_eq(&self) {}
}Eq, #[automatically_derived]
impl ::core::cmp::PartialOrd for Safety {
    #[inline]
    fn partial_cmp(&self, other: &Safety)
        -> ::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 Safety {
    #[inline]
    fn cmp(&self, other: &Safety) -> ::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, #[automatically_derived]
impl ::core::hash::Hash for Safety {
    #[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, #[automatically_derived]
impl ::core::fmt::Debug for Safety {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::write_str(f,
            match self {
                Safety::Unsafe => "Unsafe",
                Safety::Safe => "Safe",
            })
    }
}Debug)]
4355#[derive(const _: () =
    {
        impl<__E: ::rustc_span::SpanEncoder> ::rustc_serialize::Encodable<__E>
            for Safety {
            fn encode(&self, __encoder: &mut __E) {
                let disc =
                    match *self {
                        Safety::Unsafe => { 0usize }
                        Safety::Safe => { 1usize }
                    };
                ::rustc_serialize::Encoder::emit_u8(__encoder, disc as u8);
                match *self { Safety::Unsafe => {} Safety::Safe => {} }
            }
        }
    };Encodable, const _: () =
    {
        impl<__D: ::rustc_span::SpanDecoder> ::rustc_serialize::Decodable<__D>
            for Safety {
            fn decode(__decoder: &mut __D) -> Self {
                match ::rustc_serialize::Decoder::read_u8(__decoder) as usize
                    {
                    0usize => { Safety::Unsafe }
                    1usize => { Safety::Safe }
                    n => {
                        ::core::panicking::panic_fmt(format_args!("invalid enum variant tag while decoding `Safety`, expected 0..2, actual {0}",
                                n));
                    }
                }
            }
        }
    };Decodable, const _: () =
    {
        impl<__CTX> ::rustc_data_structures::stable_hasher::HashStable<__CTX>
            for Safety where __CTX: crate::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 { Safety::Unsafe => {} Safety::Safe => {} }
            }
        }
    };HashStable_Generic, #[automatically_derived]
impl ::core::default::Default for Safety {
    #[inline]
    fn default() -> Safety { Self::Unsafe }
}Default)]
4356pub enum Safety {
4357    /// This is the default variant, because the compiler messing up
4358    /// metadata encoding and failing to encode a `Safe` flag, means
4359    /// downstream crates think a thing is `Unsafe` instead of silently
4360    /// treating an unsafe thing as safe.
4361    #[default]
4362    Unsafe,
4363    Safe,
4364}
4365
4366impl Safety {
4367    pub fn prefix_str(self) -> &'static str {
4368        match self {
4369            Self::Unsafe => "unsafe ",
4370            Self::Safe => "",
4371        }
4372    }
4373
4374    #[inline]
4375    pub fn is_unsafe(self) -> bool {
4376        !self.is_safe()
4377    }
4378
4379    #[inline]
4380    pub fn is_safe(self) -> bool {
4381        match self {
4382            Self::Unsafe => false,
4383            Self::Safe => true,
4384        }
4385    }
4386}
4387
4388impl fmt::Display for Safety {
4389    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
4390        f.write_str(match *self {
4391            Self::Unsafe => "unsafe",
4392            Self::Safe => "safe",
4393        })
4394    }
4395}
4396
4397#[derive(#[automatically_derived]
impl ::core::marker::Copy for Constness { }Copy, #[automatically_derived]
impl ::core::clone::Clone for Constness {
    #[inline]
    fn clone(&self) -> Constness { *self }
}Clone, #[automatically_derived]
impl ::core::cmp::PartialEq for Constness {
    #[inline]
    fn eq(&self, other: &Constness) -> 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 Constness {
    #[inline]
    #[doc(hidden)]
    #[coverage(off)]
    fn assert_fields_are_eq(&self) {}
}Eq, #[automatically_derived]
impl ::core::fmt::Debug for Constness {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::write_str(f,
            match self {
                Constness::Const => "Const",
                Constness::NotConst => "NotConst",
            })
    }
}Debug, const _: () =
    {
        impl<__E: ::rustc_span::SpanEncoder> ::rustc_serialize::Encodable<__E>
            for Constness {
            fn encode(&self, __encoder: &mut __E) {
                let disc =
                    match *self {
                        Constness::Const => { 0usize }
                        Constness::NotConst => { 1usize }
                    };
                ::rustc_serialize::Encoder::emit_u8(__encoder, disc as u8);
                match *self {
                    Constness::Const => {}
                    Constness::NotConst => {}
                }
            }
        }
    };Encodable, const _: () =
    {
        impl<__D: ::rustc_span::SpanDecoder> ::rustc_serialize::Decodable<__D>
            for Constness {
            fn decode(__decoder: &mut __D) -> Self {
                match ::rustc_serialize::Decoder::read_u8(__decoder) as usize
                    {
                    0usize => { Constness::Const }
                    1usize => { Constness::NotConst }
                    n => {
                        ::core::panicking::panic_fmt(format_args!("invalid enum variant tag while decoding `Constness`, expected 0..2, actual {0}",
                                n));
                    }
                }
            }
        }
    };Decodable, const _: () =
    {
        impl<__CTX> ::rustc_data_structures::stable_hasher::HashStable<__CTX>
            for Constness where __CTX: crate::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 {
                    Constness::Const => {}
                    Constness::NotConst => {}
                }
            }
        }
    };HashStable_Generic)]
4398#[derive(#[automatically_derived]
impl ::core::default::Default for Constness {
    #[inline]
    fn default() -> Constness { Self::Const }
}Default)]
4399pub enum Constness {
4400    #[default]
4401    Const,
4402    NotConst,
4403}
4404
4405impl fmt::Display for Constness {
4406    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
4407        f.write_str(match *self {
4408            Self::Const => "const",
4409            Self::NotConst => "non-const",
4410        })
4411    }
4412}
4413
4414/// The actual safety specified in syntax. We may treat
4415/// its safety different within the type system to create a
4416/// "sound by default" system that needs checking this enum
4417/// explicitly to allow unsafe operations.
4418#[derive(#[automatically_derived]
impl ::core::marker::Copy for HeaderSafety { }Copy, #[automatically_derived]
impl ::core::clone::Clone for HeaderSafety {
    #[inline]
    fn clone(&self) -> HeaderSafety {
        let _: ::core::clone::AssertParamIsClone<Safety>;
        *self
    }
}Clone, #[automatically_derived]
impl ::core::fmt::Debug for HeaderSafety {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        match self {
            HeaderSafety::SafeTargetFeatures =>
                ::core::fmt::Formatter::write_str(f, "SafeTargetFeatures"),
            HeaderSafety::Normal(__self_0) =>
                ::core::fmt::Formatter::debug_tuple_field1_finish(f, "Normal",
                    &__self_0),
        }
    }
}Debug, const _: () =
    {
        impl<__CTX> ::rustc_data_structures::stable_hasher::HashStable<__CTX>
            for HeaderSafety where __CTX: crate::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 {
                    HeaderSafety::SafeTargetFeatures => {}
                    HeaderSafety::Normal(ref __binding_0) => {
                        { __binding_0.hash_stable(__hcx, __hasher); }
                    }
                }
            }
        }
    };HashStable_Generic, #[automatically_derived]
impl ::core::cmp::PartialEq for HeaderSafety {
    #[inline]
    fn eq(&self, other: &HeaderSafety) -> bool {
        let __self_discr = ::core::intrinsics::discriminant_value(self);
        let __arg1_discr = ::core::intrinsics::discriminant_value(other);
        __self_discr == __arg1_discr &&
            match (self, other) {
                (HeaderSafety::Normal(__self_0),
                    HeaderSafety::Normal(__arg1_0)) => __self_0 == __arg1_0,
                _ => true,
            }
    }
}PartialEq, #[automatically_derived]
impl ::core::cmp::Eq for HeaderSafety {
    #[inline]
    #[doc(hidden)]
    #[coverage(off)]
    fn assert_fields_are_eq(&self) {
        let _: ::core::cmp::AssertParamIsEq<Safety>;
    }
}Eq)]
4419pub enum HeaderSafety {
4420    /// A safe function annotated with `#[target_features]`.
4421    /// The type system treats this function as an unsafe function,
4422    /// but safety checking will check this enum to treat it as safe
4423    /// and allowing calling other safe target feature functions with
4424    /// the same features without requiring an additional unsafe block.
4425    SafeTargetFeatures,
4426    Normal(Safety),
4427}
4428
4429impl From<Safety> for HeaderSafety {
4430    fn from(v: Safety) -> Self {
4431        Self::Normal(v)
4432    }
4433}
4434
4435#[derive(#[automatically_derived]
impl ::core::marker::Copy for FnHeader { }Copy, #[automatically_derived]
impl ::core::clone::Clone for FnHeader {
    #[inline]
    fn clone(&self) -> FnHeader {
        let _: ::core::clone::AssertParamIsClone<HeaderSafety>;
        let _: ::core::clone::AssertParamIsClone<Constness>;
        let _: ::core::clone::AssertParamIsClone<IsAsync>;
        let _: ::core::clone::AssertParamIsClone<ExternAbi>;
        *self
    }
}Clone, #[automatically_derived]
impl ::core::fmt::Debug for FnHeader {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::debug_struct_field4_finish(f, "FnHeader",
            "safety", &self.safety, "constness", &self.constness, "asyncness",
            &self.asyncness, "abi", &&self.abi)
    }
}Debug, const _: () =
    {
        impl<__CTX> ::rustc_data_structures::stable_hasher::HashStable<__CTX>
            for FnHeader where __CTX: crate::HashStableContext {
            #[inline]
            fn hash_stable(&self, __hcx: &mut __CTX,
                __hasher:
                    &mut ::rustc_data_structures::stable_hasher::StableHasher) {
                match *self {
                    FnHeader {
                        safety: ref __binding_0,
                        constness: ref __binding_1,
                        asyncness: ref __binding_2,
                        abi: 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); }
                    }
                }
            }
        }
    };HashStable_Generic)]
4436pub struct FnHeader {
4437    pub safety: HeaderSafety,
4438    pub constness: Constness,
4439    pub asyncness: IsAsync,
4440    pub abi: ExternAbi,
4441}
4442
4443impl FnHeader {
4444    pub fn is_async(&self) -> bool {
4445        #[allow(non_exhaustive_omitted_patterns)] match self.asyncness {
    IsAsync::Async(_) => true,
    _ => false,
}matches!(self.asyncness, IsAsync::Async(_))
4446    }
4447
4448    pub fn is_const(&self) -> bool {
4449        #[allow(non_exhaustive_omitted_patterns)] match self.constness {
    Constness::Const => true,
    _ => false,
}matches!(self.constness, Constness::Const)
4450    }
4451
4452    pub fn is_unsafe(&self) -> bool {
4453        self.safety().is_unsafe()
4454    }
4455
4456    pub fn is_safe(&self) -> bool {
4457        self.safety().is_safe()
4458    }
4459
4460    pub fn safety(&self) -> Safety {
4461        match self.safety {
4462            HeaderSafety::SafeTargetFeatures => Safety::Unsafe,
4463            HeaderSafety::Normal(safety) => safety,
4464        }
4465    }
4466}
4467
4468#[derive(#[automatically_derived]
impl<'hir> ::core::fmt::Debug for ItemKind<'hir> {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        match self {
            ItemKind::ExternCrate(__self_0, __self_1) =>
                ::core::fmt::Formatter::debug_tuple_field2_finish(f,
                    "ExternCrate", __self_0, &__self_1),
            ItemKind::Use(__self_0, __self_1) =>
                ::core::fmt::Formatter::debug_tuple_field2_finish(f, "Use",
                    __self_0, &__self_1),
            ItemKind::Static(__self_0, __self_1, __self_2, __self_3) =>
                ::core::fmt::Formatter::debug_tuple_field4_finish(f, "Static",
                    __self_0, __self_1, __self_2, &__self_3),
            ItemKind::Const(__self_0, __self_1, __self_2, __self_3) =>
                ::core::fmt::Formatter::debug_tuple_field4_finish(f, "Const",
                    __self_0, __self_1, __self_2, &__self_3),
            ItemKind::Fn {
                sig: __self_0,
                ident: __self_1,
                generics: __self_2,
                body: __self_3,
                has_body: __self_4 } =>
                ::core::fmt::Formatter::debug_struct_field5_finish(f, "Fn",
                    "sig", __self_0, "ident", __self_1, "generics", __self_2,
                    "body", __self_3, "has_body", &__self_4),
            ItemKind::Macro(__self_0, __self_1, __self_2) =>
                ::core::fmt::Formatter::debug_tuple_field3_finish(f, "Macro",
                    __self_0, __self_1, &__self_2),
            ItemKind::Mod(__self_0, __self_1) =>
                ::core::fmt::Formatter::debug_tuple_field2_finish(f, "Mod",
                    __self_0, &__self_1),
            ItemKind::ForeignMod { abi: __self_0, items: __self_1 } =>
                ::core::fmt::Formatter::debug_struct_field2_finish(f,
                    "ForeignMod", "abi", __self_0, "items", &__self_1),
            ItemKind::GlobalAsm { asm: __self_0, fake_body: __self_1 } =>
                ::core::fmt::Formatter::debug_struct_field2_finish(f,
                    "GlobalAsm", "asm", __self_0, "fake_body", &__self_1),
            ItemKind::TyAlias(__self_0, __self_1, __self_2) =>
                ::core::fmt::Formatter::debug_tuple_field3_finish(f,
                    "TyAlias", __self_0, __self_1, &__self_2),
            ItemKind::Enum(__self_0, __self_1, __self_2) =>
                ::core::fmt::Formatter::debug_tuple_field3_finish(f, "Enum",
                    __self_0, __self_1, &__self_2),
            ItemKind::Struct(__self_0, __self_1, __self_2) =>
                ::core::fmt::Formatter::debug_tuple_field3_finish(f, "Struct",
                    __self_0, __self_1, &__self_2),
            ItemKind::Union(__self_0, __self_1, __self_2) =>
                ::core::fmt::Formatter::debug_tuple_field3_finish(f, "Union",
                    __self_0, __self_1, &__self_2),
            ItemKind::Trait(__self_0, __self_1, __self_2, __self_3, __self_4,
                __self_5, __self_6) => {
                let values: &[&dyn ::core::fmt::Debug] =
                    &[__self_0, __self_1, __self_2, __self_3, __self_4,
                                __self_5, &__self_6];
                ::core::fmt::Formatter::debug_tuple_fields_finish(f, "Trait",
                    values)
            }
            ItemKind::TraitAlias(__self_0, __self_1, __self_2, __self_3) =>
                ::core::fmt::Formatter::debug_tuple_field4_finish(f,
                    "TraitAlias", __self_0, __self_1, __self_2, &__self_3),
            ItemKind::Impl(__self_0) =>
                ::core::fmt::Formatter::debug_tuple_field1_finish(f, "Impl",
                    &__self_0),
        }
    }
}Debug, #[automatically_derived]
impl<'hir> ::core::clone::Clone for ItemKind<'hir> {
    #[inline]
    fn clone(&self) -> ItemKind<'hir> {
        let _: ::core::clone::AssertParamIsClone<Option<Symbol>>;
        let _: ::core::clone::AssertParamIsClone<Ident>;
        let _: ::core::clone::AssertParamIsClone<&'hir UsePath<'hir>>;
        let _: ::core::clone::AssertParamIsClone<UseKind>;
        let _: ::core::clone::AssertParamIsClone<Mutability>;
        let _: ::core::clone::AssertParamIsClone<&'hir Ty<'hir>>;
        let _: ::core::clone::AssertParamIsClone<BodyId>;
        let _: ::core::clone::AssertParamIsClone<&'hir Generics<'hir>>;
        let _: ::core::clone::AssertParamIsClone<&'hir Ty<'hir>>;
        let _: ::core::clone::AssertParamIsClone<ConstItemRhs<'hir>>;
        let _: ::core::clone::AssertParamIsClone<FnSig<'hir>>;
        let _: ::core::clone::AssertParamIsClone<&'hir Generics<'hir>>;
        let _: ::core::clone::AssertParamIsClone<bool>;
        let _: ::core::clone::AssertParamIsClone<&'hir ast::MacroDef>;
        let _: ::core::clone::AssertParamIsClone<MacroKinds>;
        let _: ::core::clone::AssertParamIsClone<&'hir Mod<'hir>>;
        let _: ::core::clone::AssertParamIsClone<ExternAbi>;
        let _: ::core::clone::AssertParamIsClone<&'hir [ForeignItemId]>;
        let _: ::core::clone::AssertParamIsClone<&'hir InlineAsm<'hir>>;
        let _: ::core::clone::AssertParamIsClone<&'hir Generics<'hir>>;
        let _: ::core::clone::AssertParamIsClone<&'hir Ty<'hir>>;
        let _: ::core::clone::AssertParamIsClone<&'hir Generics<'hir>>;
        let _: ::core::clone::AssertParamIsClone<EnumDef<'hir>>;
        let _: ::core::clone::AssertParamIsClone<&'hir Generics<'hir>>;
        let _: ::core::clone::AssertParamIsClone<VariantData<'hir>>;
        let _: ::core::clone::AssertParamIsClone<&'hir Generics<'hir>>;
        let _: ::core::clone::AssertParamIsClone<VariantData<'hir>>;
        let _: ::core::clone::AssertParamIsClone<Constness>;
        let _: ::core::clone::AssertParamIsClone<IsAuto>;
        let _: ::core::clone::AssertParamIsClone<Safety>;
        let _: ::core::clone::AssertParamIsClone<&'hir Generics<'hir>>;
        let _: ::core::clone::AssertParamIsClone<GenericBounds<'hir>>;
        let _: ::core::clone::AssertParamIsClone<&'hir [TraitItemId]>;
        let _: ::core::clone::AssertParamIsClone<&'hir Generics<'hir>>;
        let _: ::core::clone::AssertParamIsClone<GenericBounds<'hir>>;
        let _: ::core::clone::AssertParamIsClone<Impl<'hir>>;
        *self
    }
}Clone, #[automatically_derived]
impl<'hir> ::core::marker::Copy for ItemKind<'hir> { }Copy, const _: () =
    {
        impl<'hir, __CTX>
            ::rustc_data_structures::stable_hasher::HashStable<__CTX> for
            ItemKind<'hir> where __CTX: crate::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 {
                    ItemKind::ExternCrate(ref __binding_0, ref __binding_1) => {
                        { __binding_0.hash_stable(__hcx, __hasher); }
                        { __binding_1.hash_stable(__hcx, __hasher); }
                    }
                    ItemKind::Use(ref __binding_0, ref __binding_1) => {
                        { __binding_0.hash_stable(__hcx, __hasher); }
                        { __binding_1.hash_stable(__hcx, __hasher); }
                    }
                    ItemKind::Static(ref __binding_0, ref __binding_1,
                        ref __binding_2, 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); }
                    }
                    ItemKind::Const(ref __binding_0, ref __binding_1,
                        ref __binding_2, 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); }
                    }
                    ItemKind::Fn {
                        sig: ref __binding_0,
                        ident: ref __binding_1,
                        generics: ref __binding_2,
                        body: ref __binding_3,
                        has_body: 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); }
                    }
                    ItemKind::Macro(ref __binding_0, ref __binding_1,
                        ref __binding_2) => {
                        { __binding_0.hash_stable(__hcx, __hasher); }
                        { __binding_1.hash_stable(__hcx, __hasher); }
                        { __binding_2.hash_stable(__hcx, __hasher); }
                    }
                    ItemKind::Mod(ref __binding_0, ref __binding_1) => {
                        { __binding_0.hash_stable(__hcx, __hasher); }
                        { __binding_1.hash_stable(__hcx, __hasher); }
                    }
                    ItemKind::ForeignMod {
                        abi: ref __binding_0, items: ref __binding_1 } => {
                        { __binding_0.hash_stable(__hcx, __hasher); }
                        { __binding_1.hash_stable(__hcx, __hasher); }
                    }
                    ItemKind::GlobalAsm {
                        asm: ref __binding_0, fake_body: ref __binding_1 } => {
                        { __binding_0.hash_stable(__hcx, __hasher); }
                        { __binding_1.hash_stable(__hcx, __hasher); }
                    }
                    ItemKind::TyAlias(ref __binding_0, ref __binding_1,
                        ref __binding_2) => {
                        { __binding_0.hash_stable(__hcx, __hasher); }
                        { __binding_1.hash_stable(__hcx, __hasher); }
                        { __binding_2.hash_stable(__hcx, __hasher); }
                    }
                    ItemKind::Enum(ref __binding_0, ref __binding_1,
                        ref __binding_2) => {
                        { __binding_0.hash_stable(__hcx, __hasher); }
                        { __binding_1.hash_stable(__hcx, __hasher); }
                        { __binding_2.hash_stable(__hcx, __hasher); }
                    }
                    ItemKind::Struct(ref __binding_0, ref __binding_1,
                        ref __binding_2) => {
                        { __binding_0.hash_stable(__hcx, __hasher); }
                        { __binding_1.hash_stable(__hcx, __hasher); }
                        { __binding_2.hash_stable(__hcx, __hasher); }
                    }
                    ItemKind::Union(ref __binding_0, ref __binding_1,
                        ref __binding_2) => {
                        { __binding_0.hash_stable(__hcx, __hasher); }
                        { __binding_1.hash_stable(__hcx, __hasher); }
                        { __binding_2.hash_stable(__hcx, __hasher); }
                    }
                    ItemKind::Trait(ref __binding_0, ref __binding_1,
                        ref __binding_2, ref __binding_3, ref __binding_4,
                        ref __binding_5, ref __binding_6) => {
                        { __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); }
                        { __binding_5.hash_stable(__hcx, __hasher); }
                        { __binding_6.hash_stable(__hcx, __hasher); }
                    }
                    ItemKind::TraitAlias(ref __binding_0, ref __binding_1,
                        ref __binding_2, 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); }
                    }
                    ItemKind::Impl(ref __binding_0) => {
                        { __binding_0.hash_stable(__hcx, __hasher); }
                    }
                }
            }
        }
    };HashStable_Generic)]
4469pub enum ItemKind<'hir> {
4470    /// An `extern crate` item, with optional *original* crate name if the crate was renamed.
4471    ///
4472    /// E.g., `extern crate foo` or `extern crate foo_bar as foo`.
4473    ExternCrate(Option<Symbol>, Ident),
4474
4475    /// `use foo::bar::*;` or `use foo::bar::baz as quux;`
4476    ///
4477    /// or just
4478    ///
4479    /// `use foo::bar::baz;` (with `as baz` implicitly on the right).
4480    Use(&'hir UsePath<'hir>, UseKind),
4481
4482    /// A `static` item.
4483    Static(Mutability, Ident, &'hir Ty<'hir>, BodyId),
4484    /// A `const` item.
4485    Const(Ident, &'hir Generics<'hir>, &'hir Ty<'hir>, ConstItemRhs<'hir>),
4486    /// A function declaration.
4487    Fn {
4488        sig: FnSig<'hir>,
4489        ident: Ident,
4490        generics: &'hir Generics<'hir>,
4491        body: BodyId,
4492        /// Whether this function actually has a body.
4493        /// For functions without a body, `body` is synthesized (to avoid ICEs all over the
4494        /// compiler), but that code should never be translated.
4495        has_body: bool,
4496    },
4497    /// A MBE macro definition (`macro_rules!` or `macro`).
4498    Macro(Ident, &'hir ast::MacroDef, MacroKinds),
4499    /// A module.
4500    Mod(Ident, &'hir Mod<'hir>),
4501    /// An external module, e.g. `extern { .. }`.
4502    ForeignMod { abi: ExternAbi, items: &'hir [ForeignItemId] },
4503    /// Module-level inline assembly (from `global_asm!`).
4504    GlobalAsm {
4505        asm: &'hir InlineAsm<'hir>,
4506        /// A fake body which stores typeck results for the global asm's sym_fn
4507        /// operands, which are represented as path expressions. This body contains
4508        /// a single [`ExprKind::InlineAsm`] which points to the asm in the field
4509        /// above, and which is typechecked like a inline asm expr just for the
4510        /// typeck results.
4511        fake_body: BodyId,
4512    },
4513    /// A type alias, e.g., `type Foo = Bar<u8>`.
4514    TyAlias(Ident, &'hir Generics<'hir>, &'hir Ty<'hir>),
4515    /// An enum definition, e.g., `enum Foo<A, B> { C<A>, D<B> }`.
4516    Enum(Ident, &'hir Generics<'hir>, EnumDef<'hir>),
4517    /// A struct definition, e.g., `struct Foo<A> {x: A}`.
4518    Struct(Ident, &'hir Generics<'hir>, VariantData<'hir>),
4519    /// A union definition, e.g., `union Foo<A, B> {x: A, y: B}`.
4520    Union(Ident, &'hir Generics<'hir>, VariantData<'hir>),
4521    /// A trait definition.
4522    Trait(
4523        Constness,
4524        IsAuto,
4525        Safety,
4526        Ident,
4527        &'hir Generics<'hir>,
4528        GenericBounds<'hir>,
4529        &'hir [TraitItemId],
4530    ),
4531    /// A trait alias.
4532    TraitAlias(Constness, Ident, &'hir Generics<'hir>, GenericBounds<'hir>),
4533
4534    /// An implementation, e.g., `impl<A> Trait for Foo { .. }`.
4535    Impl(Impl<'hir>),
4536}
4537
4538/// Represents an impl block declaration.
4539///
4540/// E.g., `impl $Type { .. }` or `impl $Trait for $Type { .. }`
4541/// Refer to [`ImplItem`] for an associated item within an impl block.
4542#[derive(#[automatically_derived]
impl<'hir> ::core::fmt::Debug for Impl<'hir> {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::debug_struct_field5_finish(f, "Impl",
            "generics", &self.generics, "of_trait", &self.of_trait, "self_ty",
            &self.self_ty, "items", &self.items, "constness",
            &&self.constness)
    }
}Debug, #[automatically_derived]
impl<'hir> ::core::clone::Clone for Impl<'hir> {
    #[inline]
    fn clone(&self) -> Impl<'hir> {
        let _: ::core::clone::AssertParamIsClone<&'hir Generics<'hir>>;
        let _:
                ::core::clone::AssertParamIsClone<Option<&'hir TraitImplHeader<'hir>>>;
        let _: ::core::clone::AssertParamIsClone<&'hir Ty<'hir>>;
        let _: ::core::clone::AssertParamIsClone<&'hir [ImplItemId]>;
        let _: ::core::clone::AssertParamIsClone<Constness>;
        *self
    }
}Clone, #[automatically_derived]
impl<'hir> ::core::marker::Copy for Impl<'hir> { }Copy, const _: () =
    {
        impl<'hir, __CTX>
            ::rustc_data_structures::stable_hasher::HashStable<__CTX> for
            Impl<'hir> where __CTX: crate::HashStableContext {
            #[inline]
            fn hash_stable(&self, __hcx: &mut __CTX,
                __hasher:
                    &mut ::rustc_data_structures::stable_hasher::StableHasher) {
                match *self {
                    Impl {
                        generics: ref __binding_0,
                        of_trait: ref __binding_1,
                        self_ty: ref __binding_2,
                        items: ref __binding_3,
                        constness: 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); }
                    }
                }
            }
        }
    };HashStable_Generic)]
4543pub struct Impl<'hir> {
4544    pub generics: &'hir Generics<'hir>,
4545    pub of_trait: Option<&'hir TraitImplHeader<'hir>>,
4546    pub self_ty: &'hir Ty<'hir>,
4547    pub items: &'hir [ImplItemId],
4548    pub constness: Constness,
4549}
4550
4551#[derive(#[automatically_derived]
impl<'hir> ::core::fmt::Debug for TraitImplHeader<'hir> {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::debug_struct_field5_finish(f,
            "TraitImplHeader", "safety", &self.safety, "polarity",
            &self.polarity, "defaultness", &self.defaultness,
            "defaultness_span", &self.defaultness_span, "trait_ref",
            &&self.trait_ref)
    }
}Debug, #[automatically_derived]
impl<'hir> ::core::clone::Clone for TraitImplHeader<'hir> {
    #[inline]
    fn clone(&self) -> TraitImplHeader<'hir> {
        let _: ::core::clone::AssertParamIsClone<Safety>;
        let _: ::core::clone::AssertParamIsClone<ImplPolarity>;
        let _: ::core::clone::AssertParamIsClone<Defaultness>;
        let _: ::core::clone::AssertParamIsClone<Option<Span>>;
        let _: ::core::clone::AssertParamIsClone<TraitRef<'hir>>;
        *self
    }
}Clone, #[automatically_derived]
impl<'hir> ::core::marker::Copy for TraitImplHeader<'hir> { }Copy, const _: () =
    {
        impl<'hir, __CTX>
            ::rustc_data_structures::stable_hasher::HashStable<__CTX> for
            TraitImplHeader<'hir> where __CTX: crate::HashStableContext {
            #[inline]
            fn hash_stable(&self, __hcx: &mut __CTX,
                __hasher:
                    &mut ::rustc_data_structures::stable_hasher::StableHasher) {
                match *self {
                    TraitImplHeader {
                        safety: ref __binding_0,
                        polarity: ref __binding_1,
                        defaultness: ref __binding_2,
                        defaultness_span: ref __binding_3,
                        trait_ref: 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); }
                    }
                }
            }
        }
    };HashStable_Generic)]
4552pub struct TraitImplHeader<'hir> {
4553    pub safety: Safety,
4554    pub polarity: ImplPolarity,
4555    pub defaultness: Defaultness,
4556    // We do not put a `Span` in `Defaultness` because it breaks foreign crate metadata
4557    // decoding as `Span`s cannot be decoded when a `Session` is not available.
4558    pub defaultness_span: Option<Span>,
4559    pub trait_ref: TraitRef<'hir>,
4560}
4561
4562impl ItemKind<'_> {
4563    pub fn ident(&self) -> Option<Ident> {
4564        match *self {
4565            ItemKind::ExternCrate(_, ident)
4566            | ItemKind::Use(_, UseKind::Single(ident))
4567            | ItemKind::Static(_, ident, ..)
4568            | ItemKind::Const(ident, ..)
4569            | ItemKind::Fn { ident, .. }
4570            | ItemKind::Macro(ident, ..)
4571            | ItemKind::Mod(ident, ..)
4572            | ItemKind::TyAlias(ident, ..)
4573            | ItemKind::Enum(ident, ..)
4574            | ItemKind::Struct(ident, ..)
4575            | ItemKind::Union(ident, ..)
4576            | ItemKind::Trait(_, _, _, ident, ..)
4577            | ItemKind::TraitAlias(_, ident, ..) => Some(ident),
4578
4579            ItemKind::Use(_, UseKind::Glob | UseKind::ListStem)
4580            | ItemKind::ForeignMod { .. }
4581            | ItemKind::GlobalAsm { .. }
4582            | ItemKind::Impl(_) => None,
4583        }
4584    }
4585
4586    pub fn generics(&self) -> Option<&Generics<'_>> {
4587        Some(match self {
4588            ItemKind::Fn { generics, .. }
4589            | ItemKind::TyAlias(_, generics, _)
4590            | ItemKind::Const(_, generics, _, _)
4591            | ItemKind::Enum(_, generics, _)
4592            | ItemKind::Struct(_, generics, _)
4593            | ItemKind::Union(_, generics, _)
4594            | ItemKind::Trait(_, _, _, _, generics, _, _)
4595            | ItemKind::TraitAlias(_, _, generics, _)
4596            | ItemKind::Impl(Impl { generics, .. }) => generics,
4597            _ => return None,
4598        })
4599    }
4600
4601    pub fn recovered(&self) -> bool {
4602        match self {
4603            ItemKind::Struct(
4604                _,
4605                _,
4606                VariantData::Struct { recovered: ast::Recovered::Yes(_), .. },
4607            ) => true,
4608            ItemKind::Union(
4609                _,
4610                _,
4611                VariantData::Struct { recovered: ast::Recovered::Yes(_), .. },
4612            ) => true,
4613            ItemKind::Enum(_, _, def) => def.variants.iter().any(|v| match v.data {
4614                VariantData::Struct { recovered: ast::Recovered::Yes(_), .. } => true,
4615                _ => false,
4616            }),
4617            _ => false,
4618        }
4619    }
4620}
4621
4622// The bodies for items are stored "out of line", in a separate
4623// hashmap in the `Crate`. Here we just record the hir-id of the item
4624// so it can fetched later.
4625#[derive(#[automatically_derived]
impl ::core::marker::Copy for ForeignItemId { }Copy, #[automatically_derived]
impl ::core::clone::Clone for ForeignItemId {
    #[inline]
    fn clone(&self) -> ForeignItemId {
        let _: ::core::clone::AssertParamIsClone<OwnerId>;
        *self
    }
}Clone, #[automatically_derived]
impl ::core::cmp::PartialEq for ForeignItemId {
    #[inline]
    fn eq(&self, other: &ForeignItemId) -> bool {
        self.owner_id == other.owner_id
    }
}PartialEq, #[automatically_derived]
impl ::core::cmp::Eq for ForeignItemId {
    #[inline]
    #[doc(hidden)]
    #[coverage(off)]
    fn assert_fields_are_eq(&self) {
        let _: ::core::cmp::AssertParamIsEq<OwnerId>;
    }
}Eq, const _: () =
    {
        impl<__E: ::rustc_span::SpanEncoder> ::rustc_serialize::Encodable<__E>
            for ForeignItemId {
            fn encode(&self, __encoder: &mut __E) {
                match *self {
                    ForeignItemId { owner_id: ref __binding_0 } => {
                        ::rustc_serialize::Encodable::<__E>::encode(__binding_0,
                            __encoder);
                    }
                }
            }
        }
    };Encodable, const _: () =
    {
        impl<__D: ::rustc_span::SpanDecoder> ::rustc_serialize::Decodable<__D>
            for ForeignItemId {
            fn decode(__decoder: &mut __D) -> Self {
                ForeignItemId {
                    owner_id: ::rustc_serialize::Decodable::decode(__decoder),
                }
            }
        }
    };Decodable, #[automatically_derived]
impl ::core::fmt::Debug for ForeignItemId {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::debug_struct_field1_finish(f, "ForeignItemId",
            "owner_id", &&self.owner_id)
    }
}Debug, const _: () =
    {
        impl<__CTX> ::rustc_data_structures::stable_hasher::HashStable<__CTX>
            for ForeignItemId where __CTX: crate::HashStableContext {
            #[inline]
            fn hash_stable(&self, __hcx: &mut __CTX,
                __hasher:
                    &mut ::rustc_data_structures::stable_hasher::StableHasher) {
                match *self {
                    ForeignItemId { owner_id: ref __binding_0 } => {
                        { __binding_0.hash_stable(__hcx, __hasher); }
                    }
                }
            }
        }
    };HashStable_Generic)]
4626pub struct ForeignItemId {
4627    pub owner_id: OwnerId,
4628}
4629
4630impl ForeignItemId {
4631    #[inline]
4632    pub fn hir_id(&self) -> HirId {
4633        // Items are always HIR owners.
4634        HirId::make_owner(self.owner_id.def_id)
4635    }
4636}
4637
4638#[derive(#[automatically_derived]
impl<'hir> ::core::fmt::Debug for ForeignItem<'hir> {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        let names: &'static _ =
            &["ident", "kind", "owner_id", "span", "vis_span",
                        "has_delayed_lints"];
        let values: &[&dyn ::core::fmt::Debug] =
            &[&self.ident, &self.kind, &self.owner_id, &self.span,
                        &self.vis_span, &&self.has_delayed_lints];
        ::core::fmt::Formatter::debug_struct_fields_finish(f, "ForeignItem",
            names, values)
    }
}Debug, #[automatically_derived]
impl<'hir> ::core::clone::Clone for ForeignItem<'hir> {
    #[inline]
    fn clone(&self) -> ForeignItem<'hir> {
        let _: ::core::clone::AssertParamIsClone<Ident>;
        let _: ::core::clone::AssertParamIsClone<ForeignItemKind<'hir>>;
        let _: ::core::clone::AssertParamIsClone<OwnerId>;
        let _: ::core::clone::AssertParamIsClone<Span>;
        let _: ::core::clone::AssertParamIsClone<bool>;
        *self
    }
}Clone, #[automatically_derived]
impl<'hir> ::core::marker::Copy for ForeignItem<'hir> { }Copy, const _: () =
    {
        impl<'hir, __CTX>
            ::rustc_data_structures::stable_hasher::HashStable<__CTX> for
            ForeignItem<'hir> where __CTX: crate::HashStableContext {
            #[inline]
            fn hash_stable(&self, __hcx: &mut __CTX,
                __hasher:
                    &mut ::rustc_data_structures::stable_hasher::StableHasher) {
                match *self {
                    ForeignItem {
                        ident: ref __binding_0,
                        kind: ref __binding_1,
                        owner_id: ref __binding_2,
                        span: ref __binding_3,
                        vis_span: ref __binding_4,
                        has_delayed_lints: ref __binding_5 } => {
                        { __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); }
                        { __binding_5.hash_stable(__hcx, __hasher); }
                    }
                }
            }
        }
    };HashStable_Generic)]
4639pub struct ForeignItem<'hir> {
4640    pub ident: Ident,
4641    pub kind: ForeignItemKind<'hir>,
4642    pub owner_id: OwnerId,
4643    pub span: Span,
4644    pub vis_span: Span,
4645    pub has_delayed_lints: bool,
4646}
4647
4648impl ForeignItem<'_> {
4649    #[inline]
4650    pub fn hir_id(&self) -> HirId {
4651        // Items are always HIR owners.
4652        HirId::make_owner(self.owner_id.def_id)
4653    }
4654
4655    pub fn foreign_item_id(&self) -> ForeignItemId {
4656        ForeignItemId { owner_id: self.owner_id }
4657    }
4658}
4659
4660/// An item within an `extern` block.
4661#[derive(#[automatically_derived]
impl<'hir> ::core::fmt::Debug for ForeignItemKind<'hir> {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        match self {
            ForeignItemKind::Fn(__self_0, __self_1, __self_2) =>
                ::core::fmt::Formatter::debug_tuple_field3_finish(f, "Fn",
                    __self_0, __self_1, &__self_2),
            ForeignItemKind::Static(__self_0, __self_1, __self_2) =>
                ::core::fmt::Formatter::debug_tuple_field3_finish(f, "Static",
                    __self_0, __self_1, &__self_2),
            ForeignItemKind::Type =>
                ::core::fmt::Formatter::write_str(f, "Type"),
        }
    }
}Debug, #[automatically_derived]
impl<'hir> ::core::clone::Clone for ForeignItemKind<'hir> {
    #[inline]
    fn clone(&self) -> ForeignItemKind<'hir> {
        let _: ::core::clone::AssertParamIsClone<FnSig<'hir>>;
        let _: ::core::clone::AssertParamIsClone<&'hir [Option<Ident>]>;
        let _: ::core::clone::AssertParamIsClone<&'hir Generics<'hir>>;
        let _: ::core::clone::AssertParamIsClone<&'hir Ty<'hir>>;
        let _: ::core::clone::AssertParamIsClone<Mutability>;
        let _: ::core::clone::AssertParamIsClone<Safety>;
        *self
    }
}Clone, #[automatically_derived]
impl<'hir> ::core::marker::Copy for ForeignItemKind<'hir> { }Copy, const _: () =
    {
        impl<'hir, __CTX>
            ::rustc_data_structures::stable_hasher::HashStable<__CTX> for
            ForeignItemKind<'hir> where __CTX: crate::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 {
                    ForeignItemKind::Fn(ref __binding_0, ref __binding_1,
                        ref __binding_2) => {
                        { __binding_0.hash_stable(__hcx, __hasher); }
                        { __binding_1.hash_stable(__hcx, __hasher); }
                        { __binding_2.hash_stable(__hcx, __hasher); }
                    }
                    ForeignItemKind::Static(ref __binding_0, ref __binding_1,
                        ref __binding_2) => {
                        { __binding_0.hash_stable(__hcx, __hasher); }
                        { __binding_1.hash_stable(__hcx, __hasher); }
                        { __binding_2.hash_stable(__hcx, __hasher); }
                    }
                    ForeignItemKind::Type => {}
                }
            }
        }
    };HashStable_Generic)]
4662pub enum ForeignItemKind<'hir> {
4663    /// A foreign function.
4664    ///
4665    /// All argument idents are actually always present (i.e. `Some`), but
4666    /// `&[Option<Ident>]` is used because of code paths shared with `TraitFn`
4667    /// and `FnPtrTy`. The sharing is due to all of these cases not allowing
4668    /// arbitrary patterns for parameters.
4669    Fn(FnSig<'hir>, &'hir [Option<Ident>], &'hir Generics<'hir>),
4670    /// A foreign static item (`static ext: u8`).
4671    Static(&'hir Ty<'hir>, Mutability, Safety),
4672    /// A foreign type.
4673    Type,
4674}
4675
4676/// A variable captured by a closure.
4677#[derive(#[automatically_derived]
impl ::core::fmt::Debug for Upvar {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::debug_struct_field1_finish(f, "Upvar", "span",
            &&self.span)
    }
}Debug, #[automatically_derived]
impl ::core::marker::Copy for Upvar { }Copy, #[automatically_derived]
impl ::core::clone::Clone for Upvar {
    #[inline]
    fn clone(&self) -> Upvar {
        let _: ::core::clone::AssertParamIsClone<Span>;
        *self
    }
}Clone, const _: () =
    {
        impl<__CTX> ::rustc_data_structures::stable_hasher::HashStable<__CTX>
            for Upvar where __CTX: crate::HashStableContext {
            #[inline]
            fn hash_stable(&self, __hcx: &mut __CTX,
                __hasher:
                    &mut ::rustc_data_structures::stable_hasher::StableHasher) {
                match *self {
                    Upvar { span: ref __binding_0 } => {
                        { __binding_0.hash_stable(__hcx, __hasher); }
                    }
                }
            }
        }
    };HashStable_Generic)]
4678pub struct Upvar {
4679    /// First span where it is accessed (there can be multiple).
4680    pub span: Span,
4681}
4682
4683// The TraitCandidate's import_ids is empty if the trait is defined in the same module, and
4684// has length > 0 if the trait is found through an chain of imports, starting with the
4685// import/use statement in the scope where the trait is used.
4686#[derive(#[automatically_derived]
impl ::core::fmt::Debug for TraitCandidate {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::debug_struct_field3_finish(f,
            "TraitCandidate", "def_id", &self.def_id, "import_ids",
            &self.import_ids, "lint_ambiguous", &&self.lint_ambiguous)
    }
}Debug, #[automatically_derived]
impl ::core::clone::Clone for TraitCandidate {
    #[inline]
    fn clone(&self) -> TraitCandidate {
        TraitCandidate {
            def_id: ::core::clone::Clone::clone(&self.def_id),
            import_ids: ::core::clone::Clone::clone(&self.import_ids),
            lint_ambiguous: ::core::clone::Clone::clone(&self.lint_ambiguous),
        }
    }
}Clone, const _: () =
    {
        impl<__CTX> ::rustc_data_structures::stable_hasher::HashStable<__CTX>
            for TraitCandidate where __CTX: crate::HashStableContext {
            #[inline]
            fn hash_stable(&self, __hcx: &mut __CTX,
                __hasher:
                    &mut ::rustc_data_structures::stable_hasher::StableHasher) {
                match *self {
                    TraitCandidate {
                        def_id: ref __binding_0,
                        import_ids: ref __binding_1,
                        lint_ambiguous: ref __binding_2 } => {
                        { __binding_0.hash_stable(__hcx, __hasher); }
                        { __binding_1.hash_stable(__hcx, __hasher); }
                        { __binding_2.hash_stable(__hcx, __hasher); }
                    }
                }
            }
        }
    };HashStable_Generic)]
4687pub struct TraitCandidate {
4688    pub def_id: DefId,
4689    pub import_ids: SmallVec<[LocalDefId; 1]>,
4690    // Indicates whether this trait candidate is ambiguously glob imported
4691    // in it's scope. Related to the AMBIGUOUS_GLOB_IMPORTED_TRAITS lint.
4692    // If this is set to true and the trait is used as a result of method lookup, this
4693    // lint is thrown.
4694    pub lint_ambiguous: bool,
4695}
4696
4697#[derive(#[automatically_derived]
impl<'hir> ::core::marker::Copy for OwnerNode<'hir> { }Copy, #[automatically_derived]
impl<'hir> ::core::clone::Clone for OwnerNode<'hir> {
    #[inline]
    fn clone(&self) -> OwnerNode<'hir> {
        let _: ::core::clone::AssertParamIsClone<&'hir Item<'hir>>;
        let _: ::core::clone::AssertParamIsClone<&'hir ForeignItem<'hir>>;
        let _: ::core::clone::AssertParamIsClone<&'hir TraitItem<'hir>>;
        let _: ::core::clone::AssertParamIsClone<&'hir ImplItem<'hir>>;
        let _: ::core::clone::AssertParamIsClone<&'hir Mod<'hir>>;
        *self
    }
}Clone, #[automatically_derived]
impl<'hir> ::core::fmt::Debug for OwnerNode<'hir> {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        match self {
            OwnerNode::Item(__self_0) =>
                ::core::fmt::Formatter::debug_tuple_field1_finish(f, "Item",
                    &__self_0),
            OwnerNode::ForeignItem(__self_0) =>
                ::core::fmt::Formatter::debug_tuple_field1_finish(f,
                    "ForeignItem", &__self_0),
            OwnerNode::TraitItem(__self_0) =>
                ::core::fmt::Formatter::debug_tuple_field1_finish(f,
                    "TraitItem", &__self_0),
            OwnerNode::ImplItem(__self_0) =>
                ::core::fmt::Formatter::debug_tuple_field1_finish(f,
                    "ImplItem", &__self_0),
            OwnerNode::Crate(__self_0) =>
                ::core::fmt::Formatter::debug_tuple_field1_finish(f, "Crate",
                    &__self_0),
            OwnerNode::Synthetic =>
                ::core::fmt::Formatter::write_str(f, "Synthetic"),
        }
    }
}Debug, const _: () =
    {
        impl<'hir, __CTX>
            ::rustc_data_structures::stable_hasher::HashStable<__CTX> for
            OwnerNode<'hir> where __CTX: crate::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 {
                    OwnerNode::Item(ref __binding_0) => {
                        { __binding_0.hash_stable(__hcx, __hasher); }
                    }
                    OwnerNode::ForeignItem(ref __binding_0) => {
                        { __binding_0.hash_stable(__hcx, __hasher); }
                    }
                    OwnerNode::TraitItem(ref __binding_0) => {
                        { __binding_0.hash_stable(__hcx, __hasher); }
                    }
                    OwnerNode::ImplItem(ref __binding_0) => {
                        { __binding_0.hash_stable(__hcx, __hasher); }
                    }
                    OwnerNode::Crate(ref __binding_0) => {
                        { __binding_0.hash_stable(__hcx, __hasher); }
                    }
                    OwnerNode::Synthetic => {}
                }
            }
        }
    };HashStable_Generic)]
4698pub enum OwnerNode<'hir> {
4699    Item(&'hir Item<'hir>),
4700    ForeignItem(&'hir ForeignItem<'hir>),
4701    TraitItem(&'hir TraitItem<'hir>),
4702    ImplItem(&'hir ImplItem<'hir>),
4703    Crate(&'hir Mod<'hir>),
4704    Synthetic,
4705}
4706
4707impl<'hir> OwnerNode<'hir> {
4708    pub fn span(&self) -> Span {
4709        match self {
4710            OwnerNode::Item(Item { span, .. })
4711            | OwnerNode::ForeignItem(ForeignItem { span, .. })
4712            | OwnerNode::ImplItem(ImplItem { span, .. })
4713            | OwnerNode::TraitItem(TraitItem { span, .. }) => *span,
4714            OwnerNode::Crate(Mod { spans: ModSpans { inner_span, .. }, .. }) => *inner_span,
4715            OwnerNode::Synthetic => ::core::panicking::panic("internal error: entered unreachable code")unreachable!(),
4716        }
4717    }
4718
4719    pub fn fn_sig(self) -> Option<&'hir FnSig<'hir>> {
4720        match self {
4721            OwnerNode::TraitItem(TraitItem { kind: TraitItemKind::Fn(fn_sig, _), .. })
4722            | OwnerNode::ImplItem(ImplItem { kind: ImplItemKind::Fn(fn_sig, _), .. })
4723            | OwnerNode::Item(Item { kind: ItemKind::Fn { sig: fn_sig, .. }, .. })
4724            | OwnerNode::ForeignItem(ForeignItem {
4725                kind: ForeignItemKind::Fn(fn_sig, _, _), ..
4726            }) => Some(fn_sig),
4727            _ => None,
4728        }
4729    }
4730
4731    pub fn fn_decl(self) -> Option<&'hir FnDecl<'hir>> {
4732        match self {
4733            OwnerNode::TraitItem(TraitItem { kind: TraitItemKind::Fn(fn_sig, _), .. })
4734            | OwnerNode::ImplItem(ImplItem { kind: ImplItemKind::Fn(fn_sig, _), .. })
4735            | OwnerNode::Item(Item { kind: ItemKind::Fn { sig: fn_sig, .. }, .. })
4736            | OwnerNode::ForeignItem(ForeignItem {
4737                kind: ForeignItemKind::Fn(fn_sig, _, _), ..
4738            }) => Some(fn_sig.decl),
4739            _ => None,
4740        }
4741    }
4742
4743    pub fn body_id(&self) -> Option<BodyId> {
4744        match self {
4745            OwnerNode::Item(Item {
4746                kind:
4747                    ItemKind::Static(_, _, _, body)
4748                    | ItemKind::Const(.., ConstItemRhs::Body(body))
4749                    | ItemKind::Fn { body, .. },
4750                ..
4751            })
4752            | OwnerNode::TraitItem(TraitItem {
4753                kind:
4754                    TraitItemKind::Fn(_, TraitFn::Provided(body))
4755                    | TraitItemKind::Const(_, Some(ConstItemRhs::Body(body)), _),
4756                ..
4757            })
4758            | OwnerNode::ImplItem(ImplItem {
4759                kind: ImplItemKind::Fn(_, body) | ImplItemKind::Const(_, ConstItemRhs::Body(body)),
4760                ..
4761            }) => Some(*body),
4762            _ => None,
4763        }
4764    }
4765
4766    pub fn generics(self) -> Option<&'hir Generics<'hir>> {
4767        Node::generics(self.into())
4768    }
4769
4770    pub fn def_id(self) -> OwnerId {
4771        match self {
4772            OwnerNode::Item(Item { owner_id, .. })
4773            | OwnerNode::TraitItem(TraitItem { owner_id, .. })
4774            | OwnerNode::ImplItem(ImplItem { owner_id, .. })
4775            | OwnerNode::ForeignItem(ForeignItem { owner_id, .. }) => *owner_id,
4776            OwnerNode::Crate(..) => crate::CRATE_HIR_ID.owner,
4777            OwnerNode::Synthetic => ::core::panicking::panic("internal error: entered unreachable code")unreachable!(),
4778        }
4779    }
4780
4781    /// Check if node is an impl block.
4782    pub fn is_impl_block(&self) -> bool {
4783        #[allow(non_exhaustive_omitted_patterns)] match self {
    OwnerNode::Item(Item { kind: ItemKind::Impl(_), .. }) => true,
    _ => false,
}matches!(self, OwnerNode::Item(Item { kind: ItemKind::Impl(_), .. }))
4784    }
4785
4786    self
let OwnerNode::TraitItem(n) =
    self else { expect_failed("expect_trait_item", self) };
n;expect_methods_self! {
4787        expect_item,         &'hir Item<'hir>,        OwnerNode::Item(n),        n;
4788        expect_foreign_item, &'hir ForeignItem<'hir>, OwnerNode::ForeignItem(n), n;
4789        expect_impl_item,    &'hir ImplItem<'hir>,    OwnerNode::ImplItem(n),    n;
4790        expect_trait_item,   &'hir TraitItem<'hir>,   OwnerNode::TraitItem(n),   n;
4791    }
4792}
4793
4794impl<'hir> From<&'hir Item<'hir>> for OwnerNode<'hir> {
4795    fn from(val: &'hir Item<'hir>) -> Self {
4796        OwnerNode::Item(val)
4797    }
4798}
4799
4800impl<'hir> From<&'hir ForeignItem<'hir>> for OwnerNode<'hir> {
4801    fn from(val: &'hir ForeignItem<'hir>) -> Self {
4802        OwnerNode::ForeignItem(val)
4803    }
4804}
4805
4806impl<'hir> From<&'hir ImplItem<'hir>> for OwnerNode<'hir> {
4807    fn from(val: &'hir ImplItem<'hir>) -> Self {
4808        OwnerNode::ImplItem(val)
4809    }
4810}
4811
4812impl<'hir> From<&'hir TraitItem<'hir>> for OwnerNode<'hir> {
4813    fn from(val: &'hir TraitItem<'hir>) -> Self {
4814        OwnerNode::TraitItem(val)
4815    }
4816}
4817
4818impl<'hir> From<OwnerNode<'hir>> for Node<'hir> {
4819    fn from(val: OwnerNode<'hir>) -> Self {
4820        match val {
4821            OwnerNode::Item(n) => Node::Item(n),
4822            OwnerNode::ForeignItem(n) => Node::ForeignItem(n),
4823            OwnerNode::ImplItem(n) => Node::ImplItem(n),
4824            OwnerNode::TraitItem(n) => Node::TraitItem(n),
4825            OwnerNode::Crate(n) => Node::Crate(n),
4826            OwnerNode::Synthetic => Node::Synthetic,
4827        }
4828    }
4829}
4830
4831#[derive(#[automatically_derived]
impl<'hir> ::core::marker::Copy for Node<'hir> { }Copy, #[automatically_derived]
impl<'hir> ::core::clone::Clone for Node<'hir> {
    #[inline]
    fn clone(&self) -> Node<'hir> {
        let _: ::core::clone::AssertParamIsClone<&'hir Param<'hir>>;
        let _: ::core::clone::AssertParamIsClone<&'hir Item<'hir>>;
        let _: ::core::clone::AssertParamIsClone<&'hir ForeignItem<'hir>>;
        let _: ::core::clone::AssertParamIsClone<&'hir TraitItem<'hir>>;
        let _: ::core::clone::AssertParamIsClone<&'hir ImplItem<'hir>>;
        let _: ::core::clone::AssertParamIsClone<&'hir Variant<'hir>>;
        let _: ::core::clone::AssertParamIsClone<&'hir FieldDef<'hir>>;
        let _: ::core::clone::AssertParamIsClone<&'hir AnonConst>;
        let _: ::core::clone::AssertParamIsClone<&'hir ConstBlock>;
        let _: ::core::clone::AssertParamIsClone<&'hir ConstArg<'hir>>;
        let _: ::core::clone::AssertParamIsClone<&'hir Expr<'hir>>;
        let _: ::core::clone::AssertParamIsClone<&'hir ExprField<'hir>>;
        let _:
                ::core::clone::AssertParamIsClone<&'hir ConstArgExprField<'hir>>;
        let _: ::core::clone::AssertParamIsClone<&'hir Stmt<'hir>>;
        let _: ::core::clone::AssertParamIsClone<&'hir PathSegment<'hir>>;
        let _: ::core::clone::AssertParamIsClone<&'hir Ty<'hir>>;
        let _:
                ::core::clone::AssertParamIsClone<&'hir AssocItemConstraint<'hir>>;
        let _: ::core::clone::AssertParamIsClone<&'hir TraitRef<'hir>>;
        let _: ::core::clone::AssertParamIsClone<&'hir OpaqueTy<'hir>>;
        let _: ::core::clone::AssertParamIsClone<&'hir TyPat<'hir>>;
        let _: ::core::clone::AssertParamIsClone<&'hir Pat<'hir>>;
        let _: ::core::clone::AssertParamIsClone<&'hir PatField<'hir>>;
        let _: ::core::clone::AssertParamIsClone<&'hir PatExpr<'hir>>;
        let _: ::core::clone::AssertParamIsClone<&'hir Arm<'hir>>;
        let _: ::core::clone::AssertParamIsClone<&'hir Block<'hir>>;
        let _: ::core::clone::AssertParamIsClone<&'hir LetStmt<'hir>>;
        let _: ::core::clone::AssertParamIsClone<&'hir VariantData<'hir>>;
        let _: ::core::clone::AssertParamIsClone<&'hir Lifetime>;
        let _: ::core::clone::AssertParamIsClone<&'hir GenericParam<'hir>>;
        let _: ::core::clone::AssertParamIsClone<&'hir Mod<'hir>>;
        let _: ::core::clone::AssertParamIsClone<&'hir InferArg>;
        let _: ::core::clone::AssertParamIsClone<&'hir WherePredicate<'hir>>;
        let _:
                ::core::clone::AssertParamIsClone<&'hir PreciseCapturingNonLifetimeArg>;
        let _: ::core::clone::AssertParamIsClone<Span>;
        *self
    }
}Clone, #[automatically_derived]
impl<'hir> ::core::fmt::Debug for Node<'hir> {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        match self {
            Node::Param(__self_0) =>
                ::core::fmt::Formatter::debug_tuple_field1_finish(f, "Param",
                    &__self_0),
            Node::Item(__self_0) =>
                ::core::fmt::Formatter::debug_tuple_field1_finish(f, "Item",
                    &__self_0),
            Node::ForeignItem(__self_0) =>
                ::core::fmt::Formatter::debug_tuple_field1_finish(f,
                    "ForeignItem", &__self_0),
            Node::TraitItem(__self_0) =>
                ::core::fmt::Formatter::debug_tuple_field1_finish(f,
                    "TraitItem", &__self_0),
            Node::ImplItem(__self_0) =>
                ::core::fmt::Formatter::debug_tuple_field1_finish(f,
                    "ImplItem", &__self_0),
            Node::Variant(__self_0) =>
                ::core::fmt::Formatter::debug_tuple_field1_finish(f,
                    "Variant", &__self_0),
            Node::Field(__self_0) =>
                ::core::fmt::Formatter::debug_tuple_field1_finish(f, "Field",
                    &__self_0),
            Node::AnonConst(__self_0) =>
                ::core::fmt::Formatter::debug_tuple_field1_finish(f,
                    "AnonConst", &__self_0),
            Node::ConstBlock(__self_0) =>
                ::core::fmt::Formatter::debug_tuple_field1_finish(f,
                    "ConstBlock", &__self_0),
            Node::ConstArg(__self_0) =>
                ::core::fmt::Formatter::debug_tuple_field1_finish(f,
                    "ConstArg", &__self_0),
            Node::Expr(__self_0) =>
                ::core::fmt::Formatter::debug_tuple_field1_finish(f, "Expr",
                    &__self_0),
            Node::ExprField(__self_0) =>
                ::core::fmt::Formatter::debug_tuple_field1_finish(f,
                    "ExprField", &__self_0),
            Node::ConstArgExprField(__self_0) =>
                ::core::fmt::Formatter::debug_tuple_field1_finish(f,
                    "ConstArgExprField", &__self_0),
            Node::Stmt(__self_0) =>
                ::core::fmt::Formatter::debug_tuple_field1_finish(f, "Stmt",
                    &__self_0),
            Node::PathSegment(__self_0) =>
                ::core::fmt::Formatter::debug_tuple_field1_finish(f,
                    "PathSegment", &__self_0),
            Node::Ty(__self_0) =>
                ::core::fmt::Formatter::debug_tuple_field1_finish(f, "Ty",
                    &__self_0),
            Node::AssocItemConstraint(__self_0) =>
                ::core::fmt::Formatter::debug_tuple_field1_finish(f,
                    "AssocItemConstraint", &__self_0),
            Node::TraitRef(__self_0) =>
                ::core::fmt::Formatter::debug_tuple_field1_finish(f,
                    "TraitRef", &__self_0),
            Node::OpaqueTy(__self_0) =>
                ::core::fmt::Formatter::debug_tuple_field1_finish(f,
                    "OpaqueTy", &__self_0),
            Node::TyPat(__self_0) =>
                ::core::fmt::Formatter::debug_tuple_field1_finish(f, "TyPat",
                    &__self_0),
            Node::Pat(__self_0) =>
                ::core::fmt::Formatter::debug_tuple_field1_finish(f, "Pat",
                    &__self_0),
            Node::PatField(__self_0) =>
                ::core::fmt::Formatter::debug_tuple_field1_finish(f,
                    "PatField", &__self_0),
            Node::PatExpr(__self_0) =>
                ::core::fmt::Formatter::debug_tuple_field1_finish(f,
                    "PatExpr", &__self_0),
            Node::Arm(__self_0) =>
                ::core::fmt::Formatter::debug_tuple_field1_finish(f, "Arm",
                    &__self_0),
            Node::Block(__self_0) =>
                ::core::fmt::Formatter::debug_tuple_field1_finish(f, "Block",
                    &__self_0),
            Node::LetStmt(__self_0) =>
                ::core::fmt::Formatter::debug_tuple_field1_finish(f,
                    "LetStmt", &__self_0),
            Node::Ctor(__self_0) =>
                ::core::fmt::Formatter::debug_tuple_field1_finish(f, "Ctor",
                    &__self_0),
            Node::Lifetime(__self_0) =>
                ::core::fmt::Formatter::debug_tuple_field1_finish(f,
                    "Lifetime", &__self_0),
            Node::GenericParam(__self_0) =>
                ::core::fmt::Formatter::debug_tuple_field1_finish(f,
                    "GenericParam", &__self_0),
            Node::Crate(__self_0) =>
                ::core::fmt::Formatter::debug_tuple_field1_finish(f, "Crate",
                    &__self_0),
            Node::Infer(__self_0) =>
                ::core::fmt::Formatter::debug_tuple_field1_finish(f, "Infer",
                    &__self_0),
            Node::WherePredicate(__self_0) =>
                ::core::fmt::Formatter::debug_tuple_field1_finish(f,
                    "WherePredicate", &__self_0),
            Node::PreciseCapturingNonLifetimeArg(__self_0) =>
                ::core::fmt::Formatter::debug_tuple_field1_finish(f,
                    "PreciseCapturingNonLifetimeArg", &__self_0),
            Node::Synthetic =>
                ::core::fmt::Formatter::write_str(f, "Synthetic"),
            Node::Err(__self_0) =>
                ::core::fmt::Formatter::debug_tuple_field1_finish(f, "Err",
                    &__self_0),
        }
    }
}Debug, const _: () =
    {
        impl<'hir, __CTX>
            ::rustc_data_structures::stable_hasher::HashStable<__CTX> for
            Node<'hir> where __CTX: crate::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 {
                    Node::Param(ref __binding_0) => {
                        { __binding_0.hash_stable(__hcx, __hasher); }
                    }
                    Node::Item(ref __binding_0) => {
                        { __binding_0.hash_stable(__hcx, __hasher); }
                    }
                    Node::ForeignItem(ref __binding_0) => {
                        { __binding_0.hash_stable(__hcx, __hasher); }
                    }
                    Node::TraitItem(ref __binding_0) => {
                        { __binding_0.hash_stable(__hcx, __hasher); }
                    }
                    Node::ImplItem(ref __binding_0) => {
                        { __binding_0.hash_stable(__hcx, __hasher); }
                    }
                    Node::Variant(ref __binding_0) => {
                        { __binding_0.hash_stable(__hcx, __hasher); }
                    }
                    Node::Field(ref __binding_0) => {
                        { __binding_0.hash_stable(__hcx, __hasher); }
                    }
                    Node::AnonConst(ref __binding_0) => {
                        { __binding_0.hash_stable(__hcx, __hasher); }
                    }
                    Node::ConstBlock(ref __binding_0) => {
                        { __binding_0.hash_stable(__hcx, __hasher); }
                    }
                    Node::ConstArg(ref __binding_0) => {
                        { __binding_0.hash_stable(__hcx, __hasher); }
                    }
                    Node::Expr(ref __binding_0) => {
                        { __binding_0.hash_stable(__hcx, __hasher); }
                    }
                    Node::ExprField(ref __binding_0) => {
                        { __binding_0.hash_stable(__hcx, __hasher); }
                    }
                    Node::ConstArgExprField(ref __binding_0) => {
                        { __binding_0.hash_stable(__hcx, __hasher); }
                    }
                    Node::Stmt(ref __binding_0) => {
                        { __binding_0.hash_stable(__hcx, __hasher); }
                    }
                    Node::PathSegment(ref __binding_0) => {
                        { __binding_0.hash_stable(__hcx, __hasher); }
                    }
                    Node::Ty(ref __binding_0) => {
                        { __binding_0.hash_stable(__hcx, __hasher); }
                    }
                    Node::AssocItemConstraint(ref __binding_0) => {
                        { __binding_0.hash_stable(__hcx, __hasher); }
                    }
                    Node::TraitRef(ref __binding_0) => {
                        { __binding_0.hash_stable(__hcx, __hasher); }
                    }
                    Node::OpaqueTy(ref __binding_0) => {
                        { __binding_0.hash_stable(__hcx, __hasher); }
                    }
                    Node::TyPat(ref __binding_0) => {
                        { __binding_0.hash_stable(__hcx, __hasher); }
                    }
                    Node::Pat(ref __binding_0) => {
                        { __binding_0.hash_stable(__hcx, __hasher); }
                    }
                    Node::PatField(ref __binding_0) => {
                        { __binding_0.hash_stable(__hcx, __hasher); }
                    }
                    Node::PatExpr(ref __binding_0) => {
                        { __binding_0.hash_stable(__hcx, __hasher); }
                    }
                    Node::Arm(ref __binding_0) => {
                        { __binding_0.hash_stable(__hcx, __hasher); }
                    }
                    Node::Block(ref __binding_0) => {
                        { __binding_0.hash_stable(__hcx, __hasher); }
                    }
                    Node::LetStmt(ref __binding_0) => {
                        { __binding_0.hash_stable(__hcx, __hasher); }
                    }
                    Node::Ctor(ref __binding_0) => {
                        { __binding_0.hash_stable(__hcx, __hasher); }
                    }
                    Node::Lifetime(ref __binding_0) => {
                        { __binding_0.hash_stable(__hcx, __hasher); }
                    }
                    Node::GenericParam(ref __binding_0) => {
                        { __binding_0.hash_stable(__hcx, __hasher); }
                    }
                    Node::Crate(ref __binding_0) => {
                        { __binding_0.hash_stable(__hcx, __hasher); }
                    }
                    Node::Infer(ref __binding_0) => {
                        { __binding_0.hash_stable(__hcx, __hasher); }
                    }
                    Node::WherePredicate(ref __binding_0) => {
                        { __binding_0.hash_stable(__hcx, __hasher); }
                    }
                    Node::PreciseCapturingNonLifetimeArg(ref __binding_0) => {
                        { __binding_0.hash_stable(__hcx, __hasher); }
                    }
                    Node::Synthetic => {}
                    Node::Err(ref __binding_0) => {
                        { __binding_0.hash_stable(__hcx, __hasher); }
                    }
                }
            }
        }
    };HashStable_Generic)]
4832pub enum Node<'hir> {
4833    Param(&'hir Param<'hir>),
4834    Item(&'hir Item<'hir>),
4835    ForeignItem(&'hir ForeignItem<'hir>),
4836    TraitItem(&'hir TraitItem<'hir>),
4837    ImplItem(&'hir ImplItem<'hir>),
4838    Variant(&'hir Variant<'hir>),
4839    Field(&'hir FieldDef<'hir>),
4840    AnonConst(&'hir AnonConst),
4841    ConstBlock(&'hir ConstBlock),
4842    ConstArg(&'hir ConstArg<'hir>),
4843    Expr(&'hir Expr<'hir>),
4844    ExprField(&'hir ExprField<'hir>),
4845    ConstArgExprField(&'hir ConstArgExprField<'hir>),
4846    Stmt(&'hir Stmt<'hir>),
4847    PathSegment(&'hir PathSegment<'hir>),
4848    Ty(&'hir Ty<'hir>),
4849    AssocItemConstraint(&'hir AssocItemConstraint<'hir>),
4850    TraitRef(&'hir TraitRef<'hir>),
4851    OpaqueTy(&'hir OpaqueTy<'hir>),
4852    TyPat(&'hir TyPat<'hir>),
4853    Pat(&'hir Pat<'hir>),
4854    PatField(&'hir PatField<'hir>),
4855    /// Needed as its own node with its own HirId for tracking
4856    /// the unadjusted type of literals within patterns
4857    /// (e.g. byte str literals not being of slice type).
4858    PatExpr(&'hir PatExpr<'hir>),
4859    Arm(&'hir Arm<'hir>),
4860    Block(&'hir Block<'hir>),
4861    LetStmt(&'hir LetStmt<'hir>),
4862    /// `Ctor` refers to the constructor of an enum variant or struct. Only tuple or unit variants
4863    /// with synthesized constructors.
4864    Ctor(&'hir VariantData<'hir>),
4865    Lifetime(&'hir Lifetime),
4866    GenericParam(&'hir GenericParam<'hir>),
4867    Crate(&'hir Mod<'hir>),
4868    Infer(&'hir InferArg),
4869    WherePredicate(&'hir WherePredicate<'hir>),
4870    PreciseCapturingNonLifetimeArg(&'hir PreciseCapturingNonLifetimeArg),
4871    // Created by query feeding
4872    Synthetic,
4873    Err(Span),
4874}
4875
4876impl<'hir> Node<'hir> {
4877    /// Get the identifier of this `Node`, if applicable.
4878    ///
4879    /// # Edge cases
4880    ///
4881    /// Calling `.ident()` on a [`Node::Ctor`] will return `None`
4882    /// because `Ctor`s do not have identifiers themselves.
4883    /// Instead, call `.ident()` on the parent struct/variant, like so:
4884    ///
4885    /// ```ignore (illustrative)
4886    /// ctor
4887    ///     .ctor_hir_id()
4888    ///     .map(|ctor_id| tcx.parent_hir_node(ctor_id))
4889    ///     .and_then(|parent| parent.ident())
4890    /// ```
4891    pub fn ident(&self) -> Option<Ident> {
4892        match self {
4893            Node::Item(item) => item.kind.ident(),
4894            Node::TraitItem(TraitItem { ident, .. })
4895            | Node::ImplItem(ImplItem { ident, .. })
4896            | Node::ForeignItem(ForeignItem { ident, .. })
4897            | Node::Field(FieldDef { ident, .. })
4898            | Node::Variant(Variant { ident, .. })
4899            | Node::PathSegment(PathSegment { ident, .. }) => Some(*ident),
4900            Node::Lifetime(lt) => Some(lt.ident),
4901            Node::GenericParam(p) => Some(p.name.ident()),
4902            Node::AssocItemConstraint(c) => Some(c.ident),
4903            Node::PatField(f) => Some(f.ident),
4904            Node::ExprField(f) => Some(f.ident),
4905            Node::ConstArgExprField(f) => Some(f.field),
4906            Node::PreciseCapturingNonLifetimeArg(a) => Some(a.ident),
4907            Node::Param(..)
4908            | Node::AnonConst(..)
4909            | Node::ConstBlock(..)
4910            | Node::ConstArg(..)
4911            | Node::Expr(..)
4912            | Node::Stmt(..)
4913            | Node::Block(..)
4914            | Node::Ctor(..)
4915            | Node::Pat(..)
4916            | Node::TyPat(..)
4917            | Node::PatExpr(..)
4918            | Node::Arm(..)
4919            | Node::LetStmt(..)
4920            | Node::Crate(..)
4921            | Node::Ty(..)
4922            | Node::TraitRef(..)
4923            | Node::OpaqueTy(..)
4924            | Node::Infer(..)
4925            | Node::WherePredicate(..)
4926            | Node::Synthetic
4927            | Node::Err(..) => None,
4928        }
4929    }
4930
4931    pub fn fn_decl(self) -> Option<&'hir FnDecl<'hir>> {
4932        match self {
4933            Node::TraitItem(TraitItem { kind: TraitItemKind::Fn(fn_sig, _), .. })
4934            | Node::ImplItem(ImplItem { kind: ImplItemKind::Fn(fn_sig, _), .. })
4935            | Node::Item(Item { kind: ItemKind::Fn { sig: fn_sig, .. }, .. })
4936            | Node::ForeignItem(ForeignItem { kind: ForeignItemKind::Fn(fn_sig, _, _), .. }) => {
4937                Some(fn_sig.decl)
4938            }
4939            Node::Expr(Expr { kind: ExprKind::Closure(Closure { fn_decl, .. }), .. }) => {
4940                Some(fn_decl)
4941            }
4942            _ => None,
4943        }
4944    }
4945
4946    /// Get a `hir::Impl` if the node is an impl block for the given `trait_def_id`.
4947    pub fn impl_block_of_trait(self, trait_def_id: DefId) -> Option<&'hir Impl<'hir>> {
4948        if let Node::Item(Item { kind: ItemKind::Impl(impl_block), .. }) = self
4949            && let Some(of_trait) = impl_block.of_trait
4950            && let Some(trait_id) = of_trait.trait_ref.trait_def_id()
4951            && trait_id == trait_def_id
4952        {
4953            Some(impl_block)
4954        } else {
4955            None
4956        }
4957    }
4958
4959    pub fn fn_sig(self) -> Option<&'hir FnSig<'hir>> {
4960        match self {
4961            Node::TraitItem(TraitItem { kind: TraitItemKind::Fn(fn_sig, _), .. })
4962            | Node::ImplItem(ImplItem { kind: ImplItemKind::Fn(fn_sig, _), .. })
4963            | Node::Item(Item { kind: ItemKind::Fn { sig: fn_sig, .. }, .. })
4964            | Node::ForeignItem(ForeignItem { kind: ForeignItemKind::Fn(fn_sig, _, _), .. }) => {
4965                Some(fn_sig)
4966            }
4967            _ => None,
4968        }
4969    }
4970
4971    /// Get the type for constants, assoc types, type aliases and statics.
4972    pub fn ty(self) -> Option<&'hir Ty<'hir>> {
4973        match self {
4974            Node::Item(it) => match it.kind {
4975                ItemKind::TyAlias(_, _, ty)
4976                | ItemKind::Static(_, _, ty, _)
4977                | ItemKind::Const(_, _, ty, _) => Some(ty),
4978                ItemKind::Impl(impl_item) => Some(&impl_item.self_ty),
4979                _ => None,
4980            },
4981            Node::TraitItem(it) => match it.kind {
4982                TraitItemKind::Const(ty, _, _) => Some(ty),
4983                TraitItemKind::Type(_, ty) => ty,
4984                _ => None,
4985            },
4986            Node::ImplItem(it) => match it.kind {
4987                ImplItemKind::Const(ty, _) => Some(ty),
4988                ImplItemKind::Type(ty) => Some(ty),
4989                _ => None,
4990            },
4991            Node::ForeignItem(it) => match it.kind {
4992                ForeignItemKind::Static(ty, ..) => Some(ty),
4993                _ => None,
4994            },
4995            Node::GenericParam(param) => match param.kind {
4996                GenericParamKind::Lifetime { .. } => None,
4997                GenericParamKind::Type { default, .. } => default,
4998                GenericParamKind::Const { ty, .. } => Some(ty),
4999            },
5000            _ => None,
5001        }
5002    }
5003
5004    pub fn alias_ty(self) -> Option<&'hir Ty<'hir>> {
5005        match self {
5006            Node::Item(Item { kind: ItemKind::TyAlias(_, _, ty), .. }) => Some(ty),
5007            _ => None,
5008        }
5009    }
5010
5011    #[inline]
5012    pub fn associated_body(&self) -> Option<(LocalDefId, BodyId)> {
5013        match self {
5014            Node::Item(Item {
5015                owner_id,
5016                kind:
5017                    ItemKind::Const(.., ConstItemRhs::Body(body))
5018                    | ItemKind::Static(.., body)
5019                    | ItemKind::Fn { body, .. },
5020                ..
5021            })
5022            | Node::TraitItem(TraitItem {
5023                owner_id,
5024                kind:
5025                    TraitItemKind::Const(_, Some(ConstItemRhs::Body(body)), _)
5026                    | TraitItemKind::Fn(_, TraitFn::Provided(body)),
5027                ..
5028            })
5029            | Node::ImplItem(ImplItem {
5030                owner_id,
5031                kind: ImplItemKind::Const(.., ConstItemRhs::Body(body)) | ImplItemKind::Fn(_, body),
5032                ..
5033            }) => Some((owner_id.def_id, *body)),
5034
5035            Node::Item(Item {
5036                owner_id, kind: ItemKind::GlobalAsm { asm: _, fake_body }, ..
5037            }) => Some((owner_id.def_id, *fake_body)),
5038
5039            Node::Expr(Expr { kind: ExprKind::Closure(Closure { def_id, body, .. }), .. }) => {
5040                Some((*def_id, *body))
5041            }
5042
5043            Node::AnonConst(constant) => Some((constant.def_id, constant.body)),
5044            Node::ConstBlock(constant) => Some((constant.def_id, constant.body)),
5045
5046            _ => None,
5047        }
5048    }
5049
5050    pub fn body_id(&self) -> Option<BodyId> {
5051        Some(self.associated_body()?.1)
5052    }
5053
5054    pub fn generics(self) -> Option<&'hir Generics<'hir>> {
5055        match self {
5056            Node::ForeignItem(ForeignItem {
5057                kind: ForeignItemKind::Fn(_, _, generics), ..
5058            })
5059            | Node::TraitItem(TraitItem { generics, .. })
5060            | Node::ImplItem(ImplItem { generics, .. }) => Some(generics),
5061            Node::Item(item) => item.kind.generics(),
5062            _ => None,
5063        }
5064    }
5065
5066    pub fn as_owner(self) -> Option<OwnerNode<'hir>> {
5067        match self {
5068            Node::Item(i) => Some(OwnerNode::Item(i)),
5069            Node::ForeignItem(i) => Some(OwnerNode::ForeignItem(i)),
5070            Node::TraitItem(i) => Some(OwnerNode::TraitItem(i)),
5071            Node::ImplItem(i) => Some(OwnerNode::ImplItem(i)),
5072            Node::Crate(i) => Some(OwnerNode::Crate(i)),
5073            Node::Synthetic => Some(OwnerNode::Synthetic),
5074            _ => None,
5075        }
5076    }
5077
5078    pub fn fn_kind(self) -> Option<FnKind<'hir>> {
5079        match self {
5080            Node::Item(i) => match i.kind {
5081                ItemKind::Fn { ident, sig, generics, .. } => {
5082                    Some(FnKind::ItemFn(ident, generics, sig.header))
5083                }
5084                _ => None,
5085            },
5086            Node::TraitItem(ti) => match ti.kind {
5087                TraitItemKind::Fn(ref sig, _) => Some(FnKind::Method(ti.ident, sig)),
5088                _ => None,
5089            },
5090            Node::ImplItem(ii) => match ii.kind {
5091                ImplItemKind::Fn(ref sig, _) => Some(FnKind::Method(ii.ident, sig)),
5092                _ => None,
5093            },
5094            Node::Expr(e) => match e.kind {
5095                ExprKind::Closure { .. } => Some(FnKind::Closure),
5096                _ => None,
5097            },
5098            _ => None,
5099        }
5100    }
5101
5102    self
let Node::Expr(Expr { kind: ExprKind::Closure(n), .. }) =
    self else { expect_failed("expect_closure", self) };
n;expect_methods_self! {
5103        expect_param,         &'hir Param<'hir>,        Node::Param(n),        n;
5104        expect_item,          &'hir Item<'hir>,         Node::Item(n),         n;
5105        expect_foreign_item,  &'hir ForeignItem<'hir>,  Node::ForeignItem(n),  n;
5106        expect_trait_item,    &'hir TraitItem<'hir>,    Node::TraitItem(n),    n;
5107        expect_impl_item,     &'hir ImplItem<'hir>,     Node::ImplItem(n),     n;
5108        expect_variant,       &'hir Variant<'hir>,      Node::Variant(n),      n;
5109        expect_field,         &'hir FieldDef<'hir>,     Node::Field(n),        n;
5110        expect_anon_const,    &'hir AnonConst,          Node::AnonConst(n),    n;
5111        expect_inline_const,  &'hir ConstBlock,         Node::ConstBlock(n),   n;
5112        expect_expr,          &'hir Expr<'hir>,         Node::Expr(n),         n;
5113        expect_expr_field,    &'hir ExprField<'hir>,    Node::ExprField(n),    n;
5114        expect_stmt,          &'hir Stmt<'hir>,         Node::Stmt(n),         n;
5115        expect_path_segment,  &'hir PathSegment<'hir>,  Node::PathSegment(n),  n;
5116        expect_ty,            &'hir Ty<'hir>,           Node::Ty(n),           n;
5117        expect_assoc_item_constraint,  &'hir AssocItemConstraint<'hir>,  Node::AssocItemConstraint(n),  n;
5118        expect_trait_ref,     &'hir TraitRef<'hir>,     Node::TraitRef(n),     n;
5119        expect_opaque_ty,     &'hir OpaqueTy<'hir>,     Node::OpaqueTy(n),     n;
5120        expect_pat,           &'hir Pat<'hir>,          Node::Pat(n),          n;
5121        expect_pat_field,     &'hir PatField<'hir>,     Node::PatField(n),     n;
5122        expect_arm,           &'hir Arm<'hir>,          Node::Arm(n),          n;
5123        expect_block,         &'hir Block<'hir>,        Node::Block(n),        n;
5124        expect_let_stmt,      &'hir LetStmt<'hir>,      Node::LetStmt(n),      n;
5125        expect_ctor,          &'hir VariantData<'hir>,  Node::Ctor(n),         n;
5126        expect_lifetime,      &'hir Lifetime,           Node::Lifetime(n),     n;
5127        expect_generic_param, &'hir GenericParam<'hir>, Node::GenericParam(n), n;
5128        expect_crate,         &'hir Mod<'hir>,          Node::Crate(n),        n;
5129        expect_infer,         &'hir InferArg,           Node::Infer(n),        n;
5130        expect_closure,       &'hir Closure<'hir>, Node::Expr(Expr { kind: ExprKind::Closure(n), .. }), n;
5131    }
5132}
5133
5134// Some nodes are used a lot. Make sure they don't unintentionally get bigger.
5135#[cfg(target_pointer_width = "64")]
5136mod size_asserts {
5137    use rustc_data_structures::static_assert_size;
5138
5139    use super::*;
5140    // tidy-alphabetical-start
5141    const _: [(); 48] = [(); ::std::mem::size_of::<Block<'_>>()];static_assert_size!(Block<'_>, 48);
5142    const _: [(); 24] = [(); ::std::mem::size_of::<Body<'_>>()];static_assert_size!(Body<'_>, 24);
5143    const _: [(); 64] = [(); ::std::mem::size_of::<Expr<'_>>()];static_assert_size!(Expr<'_>, 64);
5144    const _: [(); 48] = [(); ::std::mem::size_of::<ExprKind<'_>>()];static_assert_size!(ExprKind<'_>, 48);
5145    const _: [(); 40] = [(); ::std::mem::size_of::<FnDecl<'_>>()];static_assert_size!(FnDecl<'_>, 40);
5146    const _: [(); 96] = [(); ::std::mem::size_of::<ForeignItem<'_>>()];static_assert_size!(ForeignItem<'_>, 96);
5147    const _: [(); 56] = [(); ::std::mem::size_of::<ForeignItemKind<'_>>()];static_assert_size!(ForeignItemKind<'_>, 56);
5148    const _: [(); 16] = [(); ::std::mem::size_of::<GenericArg<'_>>()];static_assert_size!(GenericArg<'_>, 16);
5149    const _: [(); 64] = [(); ::std::mem::size_of::<GenericBound<'_>>()];static_assert_size!(GenericBound<'_>, 64);
5150    const _: [(); 56] = [(); ::std::mem::size_of::<Generics<'_>>()];static_assert_size!(Generics<'_>, 56);
5151    const _: [(); 48] = [(); ::std::mem::size_of::<Impl<'_>>()];static_assert_size!(Impl<'_>, 48);
5152    const _: [(); 88] = [(); ::std::mem::size_of::<ImplItem<'_>>()];static_assert_size!(ImplItem<'_>, 88);
5153    const _: [(); 40] = [(); ::std::mem::size_of::<ImplItemKind<'_>>()];static_assert_size!(ImplItemKind<'_>, 40);
5154    const _: [(); 88] = [(); ::std::mem::size_of::<Item<'_>>()];static_assert_size!(Item<'_>, 88);
5155    const _: [(); 64] = [(); ::std::mem::size_of::<ItemKind<'_>>()];static_assert_size!(ItemKind<'_>, 64);
5156    const _: [(); 64] = [(); ::std::mem::size_of::<LetStmt<'_>>()];static_assert_size!(LetStmt<'_>, 64);
5157    const _: [(); 32] = [(); ::std::mem::size_of::<Param<'_>>()];static_assert_size!(Param<'_>, 32);
5158    const _: [(); 80] = [(); ::std::mem::size_of::<Pat<'_>>()];static_assert_size!(Pat<'_>, 80);
5159    const _: [(); 56] = [(); ::std::mem::size_of::<PatKind<'_>>()];static_assert_size!(PatKind<'_>, 56);
5160    const _: [(); 40] = [(); ::std::mem::size_of::<Path<'_>>()];static_assert_size!(Path<'_>, 40);
5161    const _: [(); 48] = [(); ::std::mem::size_of::<PathSegment<'_>>()];static_assert_size!(PathSegment<'_>, 48);
5162    const _: [(); 24] = [(); ::std::mem::size_of::<QPath<'_>>()];static_assert_size!(QPath<'_>, 24);
5163    const _: [(); 12] = [(); ::std::mem::size_of::<Res>()];static_assert_size!(Res, 12);
5164    const _: [(); 32] = [(); ::std::mem::size_of::<Stmt<'_>>()];static_assert_size!(Stmt<'_>, 32);
5165    const _: [(); 16] = [(); ::std::mem::size_of::<StmtKind<'_>>()];static_assert_size!(StmtKind<'_>, 16);
5166    const _: [(); 48] = [(); ::std::mem::size_of::<TraitImplHeader<'_>>()];static_assert_size!(TraitImplHeader<'_>, 48);
5167    const _: [(); 88] = [(); ::std::mem::size_of::<TraitItem<'_>>()];static_assert_size!(TraitItem<'_>, 88);
5168    const _: [(); 48] = [(); ::std::mem::size_of::<TraitItemKind<'_>>()];static_assert_size!(TraitItemKind<'_>, 48);
5169    const _: [(); 48] = [(); ::std::mem::size_of::<Ty<'_>>()];static_assert_size!(Ty<'_>, 48);
5170    const _: [(); 32] = [(); ::std::mem::size_of::<TyKind<'_>>()];static_assert_size!(TyKind<'_>, 32);
5171    // tidy-alphabetical-end
5172}
5173
5174#[cfg(test)]
5175mod tests;