Skip to main content

rustc_middle/ty/
mod.rs

1//! Defines how the compiler represents types internally.
2//!
3//! Two important entities in this module are:
4//!
5//! - [`rustc_middle::ty::Ty`], used to represent the semantics of a type.
6//! - [`rustc_middle::ty::TyCtxt`], the central data structure in the compiler.
7//!
8//! For more information, see ["The `ty` module: representing types"] in the rustc-dev-guide.
9//!
10//! ["The `ty` module: representing types"]: https://rustc-dev-guide.rust-lang.org/ty.html
11
12#![allow(rustc::usage_of_ty_tykind)]
13
14use std::cmp::Ordering;
15use std::fmt::Debug;
16use std::hash::{Hash, Hasher};
17use std::marker::PhantomData;
18use std::num::NonZero;
19use std::ops::ControlFlow;
20use std::ptr::NonNull;
21use std::{assert_matches, fmt, iter, str};
22
23pub use adt::*;
24pub use assoc::*;
25pub use generic_args::{GenericArgKind, TermKind, *};
26pub use generics::*;
27pub use intrinsic::{Intrinsic, IntrinsicDef};
28use rustc_abi::{
29    Align, FieldIdx, Integer, IntegerType, ReprFlags, ReprOptions, ScalableElt, Size, VariantIdx,
30};
31use rustc_ast::{self as ast};
32pub use rustc_ast_ir::{Movability, Mutability, try_visit};
33use rustc_attr_ir::lang_items::LangItem;
34use rustc_attr_ir::{self as attr, find_attr};
35use rustc_data_structures::fx::{FxHashSet, FxIndexMap};
36use rustc_data_structures::intern::Interned;
37use rustc_data_structures::stable_hash::{StableHash, StableHashCtxt, StableHasher};
38use rustc_errors::{Diag, ErrorGuaranteed};
39use rustc_hir as hir;
40use rustc_hir::def::{CtorKind, CtorOf, DefKind, Res};
41use rustc_hir::def_id::{CrateNum, DefId, DefIdMap, LocalDefId};
42use rustc_index::bit_set::BitMatrix;
43use rustc_index::{IndexVec, static_assert_size};
44pub use rustc_lint_defs::RegisteredTools;
45use rustc_macros::{
46    BlobDecodable, Decodable, Encodable, StableHash, TyDecodable, TyEncodable, TypeFoldable,
47    TypeVisitable, extension,
48};
49use rustc_serialize::{Decodable, Encodable};
50use rustc_session::config::OptLevel;
51use rustc_span::def_id::{LocalModId, ModId};
52use rustc_span::hygiene::MacroKind;
53use rustc_span::{DUMMY_SP, ExpnKind, Ident, Span, Symbol, bug};
54use rustc_target::callconv::FnAbi;
55pub use rustc_type_ir::data_structures::{DelayedMap, DelayedSet};
56pub use rustc_type_ir::fast_reject::DeepRejectCtxt;
57pub use rustc_type_ir::relate::VarianceDiagInfo;
58pub use rustc_type_ir::search_graph::RequiredDepth;
59pub use rustc_type_ir::solve::{CandidatePreferenceMode, SizedTraitKind, VisibleForLeakCheck};
60pub use rustc_type_ir::*;
61use tracing::{debug, instrument};
62pub use vtable::*;
63
64pub use self::closure::{
65    BorrowKind, CAPTURE_STRUCT_LOCAL, CaptureInfo, CapturedPlace, ClosureTypeInfo,
66    MinCaptureInformationMap, MinCaptureList, RootVariableMinCaptureList, UpvarCapture, UpvarId,
67    UpvarPath, analyze_coroutine_closure_captures, is_ancestor_or_same_capture,
68    place_to_string_for_capture,
69};
70pub use self::consts::{
71    AliasConst, AliasConstKind, AtomicOrdering, Const, ConstInt, ConstKind, ConstToValTreeResult,
72    Expr, ExprKind, LitToConstInput, ScalarInt, SimdAlign, ValTree, ValTreeKindExt, Value,
73    const_lit_matches_ty,
74};
75pub use self::context::{
76    CtxtInterners, CurrentGcx, FreeRegionInfo, GlobalCtxt, Lift, TyCtxt, TyCtxtFeed, tls,
77};
78pub use self::fold::*;
79pub use self::instance::{Instance, InstanceKind, ReifyReason, ShimKind};
80pub(crate) use self::list::RawList;
81pub use self::list::{List, ListWithCachedTypeInfo};
82pub use self::opaque_types::OpaqueTypeKey;
83pub use self::pattern::{Pattern, PatternKind};
84pub use self::predicate::{
85    AliasTerm, AliasTermKind, ArgOutlivesClause, Clause, ClauseKind, CoercePredicate,
86    ExistentialPredicate, ExistentialPredicateStableCmpExt, ExistentialProjection,
87    ExistentialTraitRef, HostEffectClause, NormalizesTo, OutlivesClause, PolyCoercePredicate,
88    PolyExistentialPredicate, PolyExistentialProjection, PolyExistentialTraitRef,
89    PolyProjectionClause, PolyRegionOutlivesClause, PolySubtypePredicate, PolyTraitClause,
90    PolyTraitRef, PolyTypeOutlivesClause, Predicate, PredicateKind, ProjectionClause,
91    RegionConstraint, RegionEqPredicate, RegionOutlivesClause, SubtypePredicate, TraitClause,
92    TraitRef, TypeOutlivesClause,
93};
94pub use self::region::{
95    EarlyParamRegion, LateParamRegion, LateParamRegionKind, Region, RegionKind, RegionVid,
96};
97pub use self::sty::{
98    Alias, AliasTy, AliasTyKind, Article, Binder, BoundConst, BoundRegion, BoundRegionKind,
99    BoundTy, BoundTyKind, BoundVariableKind, CanonicalPolyFnSig, CoroutineArgsExt, EarlyBinder,
100    FnSig, FnSigKind, FreeAliasTy, InherentAliasTy, InlineConstArgs, InlineConstArgsParts,
101    OpaqueAliasTy, ParamConst, ParamTy, PlaceholderConst, PlaceholderRegion, PlaceholderType,
102    PolyFnSig, ProjectionAliasTy, TyKind, TypeAndMut, TypingMode, TypingModeEqWrapper,
103    Unnormalized, UpvarArgs,
104};
105pub use self::trait_def::TraitDef;
106pub use self::typeck_results::{
107    CanonicalUserType, CanonicalUserTypeAnnotation, CanonicalUserTypeAnnotations, IsIdentity,
108    Rust2024IncompatiblePatInfo, SplattedDef, TypeckResults, UserType, UserTypeAnnotationIndex,
109    UserTypeKind,
110};
111use crate::diagnostics::{OpaqueHiddenTypeMismatch, TypeMismatchReason};
112use crate::mir::{Body, CoroutineLayout, CoroutineSavedLocal, MirPhase, SourceInfo};
113use crate::query::{IntoQueryKey, Providers};
114use crate::ty;
115use crate::ty::codec::{TyDecoder, TyEncoder};
116pub use crate::ty::diagnostics::*;
117use crate::ty::fast_reject::SimplifiedType;
118use crate::ty::layout::{FnAbiError, LayoutError};
119use crate::ty::print::{with_crate_prefix, with_no_trimmed_paths};
120use crate::ty::util::Discr;
121use crate::ty::walk::TypeWalker;
122
123pub mod abstract_const;
124pub mod adjustment;
125pub mod cast;
126pub mod codec;
127// FIXME(#159654): This should get deleted soon
128pub mod consts;
129pub mod error;
130pub mod fast_reject;
131pub mod inhabitedness;
132pub mod layout;
133pub mod normalize_erasing_regions;
134pub mod offload_meta;
135pub mod pattern;
136pub mod print;
137pub mod relate;
138pub mod significant_drop_order;
139pub mod sty;
140pub mod trait_def;
141pub mod typetree;
142pub mod util;
143pub mod vtable;
144
145mod adt;
146mod assoc;
147mod closure;
148mod context;
149mod diagnostics;
150mod elaborate_impl;
151mod erase_regions;
152mod fold;
153mod generic_args;
154mod generics;
155mod impls_ty;
156mod instance;
157mod intrinsic;
158mod list;
159mod opaque_types;
160mod predicate;
161mod region;
162mod structural_impls;
163mod typeck_results;
164mod visit;
165
166// Data types
167
168#[derive(#[automatically_derived]impl<'tcx> ::core::marker::Copy for
    ImplTraitHeader<'tcx> {
}Copy, #[automatically_derived]#[doc(hidden)]unsafe impl<'tcx>
    ::core::clone::TrivialClone for ImplTraitHeader<'tcx> {
}
#[automatically_derived]impl<'tcx> ::core::clone::Clone for
    ImplTraitHeader<'tcx> {
    #[inline]
    #[rustc_trivial_field_reads]
    fn clone(&self) -> Self {
        let _:
                ::core::clone::AssertParamIsClone<ty::EarlyBinder<'tcx,
                ty::TraitRef<'tcx>>>;
        let _: ::core::clone::AssertParamIsClone<ImplPolarity>;
        let _: ::core::clone::AssertParamIsClone<hir::Safety>;
        let _: ::core::clone::AssertParamIsClone<hir::Constness>;
        *self
    }
}Clone, #[automatically_derived]impl<'tcx> ::core::fmt::Debug for
    ImplTraitHeader<'tcx> {
    #[inline]
    #[rustc_trivial_field_reads]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::debug_struct_field4_finish(f,
            "ImplTraitHeader trait_ref polarity safety constness",
            &self.trait_ref, &self.polarity, &self.safety, &&self.constness)
    }
}Debug, const _: () =
    {
        impl<'tcx, __E: ::rustc_middle::ty::codec::TyEncoder<'tcx>>
            ::rustc_serialize::Encodable<__E> for ImplTraitHeader<'tcx> {
            fn encode(&self, __encoder: &mut __E) {
                let ImplTraitHeader {
                        trait_ref: ref __binding_0,
                        polarity: ref __binding_1,
                        safety: ref __binding_2,
                        constness: ref __binding_3 } = *self;
                ::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);
            }
        }
    };TyEncodable, const _: () =
    {
        impl<'tcx, __D: ::rustc_middle::ty::codec::TyDecoder<'tcx>>
            ::rustc_serialize::Decodable<__D> for ImplTraitHeader<'tcx> {
            fn decode(__decoder: &mut __D) -> Self {
                ImplTraitHeader {
                    trait_ref: ::rustc_serialize::Decodable::decode(__decoder),
                    polarity: ::rustc_serialize::Decodable::decode(__decoder),
                    safety: ::rustc_serialize::Decodable::decode(__decoder),
                    constness: ::rustc_serialize::Decodable::decode(__decoder),
                }
            }
        }
    };TyDecodable, const _: () =
    {
        impl<'tcx> ::rustc_data_structures::stable_hash::StableHash for
            ImplTraitHeader<'tcx> {
            #[inline]
            fn stable_hash<__Hcx: ::rustc_data_structures::stable_hash::StableHashCtxt>(&self,
                __hcx: &mut __Hcx,
                __hasher:
                    &mut ::rustc_data_structures::stable_hash::StableHasher) {
                match *self {
                    ImplTraitHeader {
                        trait_ref: ref __binding_0,
                        polarity: ref __binding_1,
                        safety: ref __binding_2,
                        constness: ref __binding_3 } => {
                        { __binding_0.stable_hash(__hcx, __hasher); }
                        { __binding_1.stable_hash(__hcx, __hasher); }
                        { __binding_2.stable_hash(__hcx, __hasher); }
                        { __binding_3.stable_hash(__hcx, __hasher); }
                    }
                }
            }
        }
    };StableHash)]
169pub struct ImplTraitHeader<'tcx> {
170    pub trait_ref: ty::EarlyBinder<'tcx, ty::TraitRef<'tcx>>,
171    pub polarity: ImplPolarity,
172    pub safety: hir::Safety,
173    pub constness: hir::Constness,
174}
175
176impl<'tcx> ImplTraitHeader<'tcx> {
177    /// For trait impls, checks whether
178    /// * the type and trait only use generic lifetime arguments (and no concrete ones like `'static`), and
179    /// * uses any generic param (lifetime or type) only once.
180    ///
181    /// This is a pessimistic analysis, so it will reject alias types
182    /// and other types that may be actually ok. We can allow more in the future.
183    ///
184    /// Constants (associated or generic) are irrelevant for this analysis, as their value is neither
185    /// affected by lifetimes, nor do they affect lifetimes.
186    pub fn is_fully_generic_for_reflection(self) -> bool {
187        #[derive(#[automatically_derived]impl ::core::default::Default for ParamFinder {
    #[inline]
    fn default() -> Self {
        ParamFinder { seen: ::core::default::Default::default() }
    }
}Default)]
188        struct ParamFinder {
189            seen: FxHashSet<u32>,
190        }
191
192        impl<'tcx> TypeVisitor<TyCtxt<'tcx>> for ParamFinder {
193            type Result = ControlFlow<()>;
194            fn visit_region(&mut self, r: Region<'tcx>) -> Self::Result {
195                match r.kind() {
196                    RegionKind::ReEarlyParam(param) => {
197                        if self.seen.insert(param.index) {
198                            ControlFlow::Continue(())
199                        } else {
200                            ControlFlow::Break(())
201                        }
202                    }
203                    RegionKind::ReBound(..) => ControlFlow::Continue(()),
204                    RegionKind::ReStatic | RegionKind::ReError(_) => ControlFlow::Break(()),
205                    RegionKind::ReVar(_)
206                    | RegionKind::RePlaceholder(_)
207                    | RegionKind::ReErased
208                    | RegionKind::ReLateParam(_) => ::rustc_span::macros::bug_impl(None,
    format_args!("unexpected lifetime in impl: {0:?}", r), Location::caller())bug!("unexpected lifetime in impl: {r:?}"),
209                }
210            }
211
212            fn visit_ty(&mut self, t: Ty<'tcx>) -> Self::Result {
213                match t.kind() {
214                    TyKind::Param(p) => {
215                        // Reject using a parameter twice (e.g. in `Foo<T, T>`)
216                        if !self.seen.insert(p.index) {
217                            return ControlFlow::Break(());
218                        }
219                    }
220                    TyKind::Alias(..) => return ControlFlow::Break(()),
221                    _ => (),
222                }
223                t.super_visit_with(self)
224            }
225        }
226        self.trait_ref
227            .instantiate_identity()
228            .skip_norm_wip()
229            .visit_with(&mut ParamFinder::default())
230            .is_continue()
231    }
232}
233
234#[derive(#[automatically_derived]impl ::core::marker::Copy for Asyncness { }Copy, #[automatically_derived]#[doc(hidden)]unsafe impl ::core::clone::TrivialClone
    for Asyncness {
}
#[automatically_derived]impl ::core::clone::Clone for Asyncness {
    #[inline]
    #[rustc_trivial_field_reads]
    fn clone(&self) -> Self { *self }
}Clone, #[automatically_derived]impl ::core::marker::StructuralPartialEq for Asyncness
    {
}
#[automatically_derived]impl ::core::cmp::PartialEq for Asyncness {
    #[inline]
    fn eq(&self, other: &Self) -> bool {
        ::core::intrinsics::discriminant_value(self) ==
            ::core::intrinsics::discriminant_value(other)
    }
}PartialEq, #[automatically_derived]impl ::core::cmp::Eq for Asyncness { }Eq, #[automatically_derived]impl ::core::hash::Hash for Asyncness {
    #[inline]
    fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) {
        ::core::hash::Hash::hash(&::core::intrinsics::discriminant_value(self),
            state)
    }
}Hash, const _: () =
    {
        impl<'tcx, __E: ::rustc_middle::ty::codec::TyEncoder<'tcx>>
            ::rustc_serialize::Encodable<__E> for Asyncness {
            fn encode(&self, __encoder: &mut __E) {
                let disc =
                    match *self {
                        Asyncness::Yes => { 0usize }
                        Asyncness::No => { 1usize }
                    };
                ::rustc_serialize::Encoder::emit_u8(__encoder, disc as u8);
            }
        }
    };TyEncodable, const _: () =
    {
        impl<'tcx, __D: ::rustc_middle::ty::codec::TyDecoder<'tcx>>
            ::rustc_serialize::Decodable<__D> for Asyncness {
            fn decode(__decoder: &mut __D) -> Self {
                match ::rustc_serialize::Decoder::read_u8(__decoder) as usize
                    {
                    0usize => { Asyncness::Yes }
                    1usize => { Asyncness::No }
                    n => {
                        ::core::panicking::panic_fmt(format_args!("invalid enum variant tag while decoding `Asyncness`, expected 0..2, actual {0}",
                                n));
                    }
                }
            }
        }
    };TyDecodable, const _: () =
    {
        impl ::rustc_data_structures::stable_hash::StableHash for Asyncness {
            #[inline]
            fn stable_hash<__Hcx: ::rustc_data_structures::stable_hash::StableHashCtxt>(&self,
                __hcx: &mut __Hcx,
                __hasher:
                    &mut ::rustc_data_structures::stable_hash::StableHasher) {
                match *self {
                    Asyncness::Yes => 0u8.stable_hash(__hcx, __hasher),
                    Asyncness::No => 1u8.stable_hash(__hcx, __hasher),
                }
                match *self { Asyncness::Yes => {} Asyncness::No => {} }
            }
        }
    };StableHash, #[automatically_derived]impl ::core::fmt::Debug for Asyncness {
    #[inline]
    #[rustc_trivial_field_reads]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::write_str(f,
            match self { Asyncness::Yes => "Yes", Asyncness::No => "No", })
    }
}Debug)]
235#[derive(const _: () =
    {
        impl<'tcx>
            ::rustc_middle::ty::TypeFoldable<::rustc_middle::ty::TyCtxt<'tcx>>
            for Asyncness {
            fn try_fold_with<__F: ::rustc_middle::ty::FallibleTypeFolder<::rustc_middle::ty::TyCtxt<'tcx>>>(self,
                __folder: &mut __F) -> Result<Self, __F::Error> {
                Ok(match self {
                        Asyncness::Yes => { Asyncness::Yes }
                        Asyncness::No => { Asyncness::No }
                    })
            }
            fn fold_with<__F: ::rustc_middle::ty::TypeFolder<::rustc_middle::ty::TyCtxt<'tcx>>>(self,
                __folder: &mut __F) -> Self {
                match self {
                    Asyncness::Yes => { Asyncness::Yes }
                    Asyncness::No => { Asyncness::No }
                }
            }
        }
    };TypeFoldable, const _: () =
    {
        impl<'tcx>
            ::rustc_middle::ty::TypeVisitable<::rustc_middle::ty::TyCtxt<'tcx>>
            for Asyncness {
            fn visit_with<__V: ::rustc_middle::ty::TypeVisitor<::rustc_middle::ty::TyCtxt<'tcx>>>(&self,
                __visitor: &mut __V) -> __V::Result {
                match *self { Asyncness::Yes => {} Asyncness::No => {} }
                <__V::Result as ::rustc_middle::ty::VisitorResult>::output()
            }
        }
    };TypeVisitable, #[automatically_derived]impl ::core::default::Default for Asyncness {
    #[inline]
    fn default() -> Self { Self::No }
}Default)]
236pub enum Asyncness {
237    Yes,
238    #[default]
239    No,
240}
241
242impl Asyncness {
243    pub fn is_async(self) -> bool {
244        #[allow(non_exhaustive_omitted_patterns)] match self {
    Asyncness::Yes => true,
    _ => false,
}matches!(self, Asyncness::Yes)
245    }
246
247    /// Returns "Async" if [`Self::Yes`], otherwise returns an empty string slice.
248    pub fn as_trait_prefix_str(&self) -> &'static str {
249        match self {
250            Asyncness::Yes => "Async",
251            Asyncness::No => "",
252        }
253    }
254}
255
256#[derive(#[automatically_derived]impl<Id: ::core::clone::Clone> ::core::clone::Clone
    for Visibility<Id> {
    #[inline]
    #[rustc_trivial_field_reads]
    fn clone(&self) -> Self {
        match self {
            Self::Public => Visibility::Public,
            Self::Restricted(__self_0) =>
                Visibility::Restricted(::core::clone::Clone::clone(__self_0)),
        }
    }
}Clone, #[automatically_derived]impl<Id: ::core::fmt::Debug> ::core::fmt::Debug for
    Visibility<Id> {
    #[inline]
    #[rustc_trivial_field_reads]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        match self {
            Self::Public => ::core::fmt::Formatter::write_str(f, "Public"),
            Self::Restricted(__self_0) =>
                ::core::fmt::Formatter::debug_struct_field1_finish(f,
                    "Restricted", &__self_0),
        }
    }
}Debug, #[automatically_derived]impl<Id: ::core::cmp::PartialEq>
    ::core::marker::StructuralPartialEq for Visibility<Id> {
}
#[automatically_derived]impl<Id: ::core::cmp::PartialEq>
    ::core::cmp::PartialEq for Visibility<Id> {
    #[inline]
    fn eq(&self, other: &Self) -> bool {
        ::core::intrinsics::discriminant_value(self) ==
                ::core::intrinsics::discriminant_value(other) &&
            match (self, other) {
                (Self::Restricted(__self_0), Self::Restricted(__arg1_0)) =>
                    __self_0 == __arg1_0,
                _ => true,
            }
    }
}PartialEq, #[automatically_derived]impl<Id: ::core::cmp::Eq> ::core::cmp::Eq for
    Visibility<Id> {
    #[inline]
    #[doc(hidden)]
    #[coverage(off)]
    fn assert_fields_are_eq(&self) {
        let _: ::core::cmp::AssertParamIsEq<Id>;
    }
}Eq, #[automatically_derived]impl<Id: ::core::marker::Copy> ::core::marker::Copy
    for Visibility<Id> {
}Copy, #[automatically_derived]impl<Id: ::core::hash::Hash> ::core::hash::Hash for
    Visibility<Id> {
    #[inline]
    fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) {
        ::core::hash::Hash::hash(&::core::intrinsics::discriminant_value(self),
            state);
        match self {
            Self::Restricted(__self_0) =>
                ::core::hash::Hash::hash(__self_0, state),
            _ => {}
        }
    }
}Hash, const _: () =
    {
        impl<Id, __E: ::rustc_span::SpanEncoder>
            ::rustc_serialize::Encodable<__E> for Visibility<Id> where
            Id: ::rustc_serialize::Encodable<__E> {
            fn encode(&self, __encoder: &mut __E) {
                let disc =
                    match *self {
                        Visibility::Public => { 0usize }
                        Visibility::Restricted(ref __binding_0) => { 1usize }
                    };
                ::rustc_serialize::Encoder::emit_u8(__encoder, disc as u8);
                match *self {
                    Visibility::Public => {}
                    Visibility::Restricted(ref __binding_0) => {
                        ::rustc_serialize::Encodable::<__E>::encode(__binding_0,
                            __encoder);
                    }
                }
            }
        }
    };Encodable, const _: () =
    {
        impl<Id, __D: ::rustc_span::BlobDecoder>
            ::rustc_serialize::Decodable<__D> for Visibility<Id> where
            Id: ::rustc_serialize::Decodable<__D> {
            fn decode(__decoder: &mut __D) -> Self {
                match ::rustc_serialize::Decoder::read_u8(__decoder) as usize
                    {
                    0usize => { Visibility::Public }
                    1usize => {
                        Visibility::Restricted(::rustc_serialize::Decodable::decode(__decoder))
                    }
                    n => {
                        ::core::panicking::panic_fmt(format_args!("invalid enum variant tag while decoding `Visibility`, expected 0..2, actual {0}",
                                n));
                    }
                }
            }
        }
    };BlobDecodable, const _: () =
    {
        impl<Id> ::rustc_data_structures::stable_hash::StableHash for
            Visibility<Id> where
            Id: ::rustc_data_structures::stable_hash::StableHash {
            #[inline]
            fn stable_hash<__Hcx: ::rustc_data_structures::stable_hash::StableHashCtxt>(&self,
                __hcx: &mut __Hcx,
                __hasher:
                    &mut ::rustc_data_structures::stable_hash::StableHasher) {
                match *self {
                    Visibility::Public => 0u8.stable_hash(__hcx, __hasher),
                    Visibility::Restricted(ref __binding_0) =>
                        1u8.stable_hash(__hcx, __hasher),
                }
                match *self {
                    Visibility::Public => {}
                    Visibility::Restricted(ref __binding_0) => {
                        { __binding_0.stable_hash(__hcx, __hasher); }
                    }
                }
            }
        }
    };StableHash)]
257pub enum Visibility<Id = LocalModId> {
258    /// Visible everywhere (including in other crates).
259    Public,
260    /// Visible only in the given crate-local module.
261    Restricted(Id),
262}
263
264impl Visibility {
265    pub fn to_string(self, def_id: LocalDefId, tcx: TyCtxt<'_>) -> String {
266        match self {
267            ty::Visibility::Restricted(restricted_id) => {
268                if restricted_id.is_top_level_module() {
269                    "pub(crate)".to_string()
270                } else if restricted_id == tcx.parent_module_from_def_id(def_id) {
271                    "pub(self)".to_string()
272                } else {
273                    ::alloc::__export::must_use({
        ::alloc::fmt::format(format_args!("pub(in crate{0})",
                tcx.def_path(restricted_id.to_def_id()).to_string_no_crate_verbose()))
    })format!(
274                        "pub(in crate{})",
275                        tcx.def_path(restricted_id.to_def_id()).to_string_no_crate_verbose()
276                    )
277                }
278            }
279            ty::Visibility::Public => "pub".to_string(),
280        }
281    }
282}
283
284#[derive(#[automatically_derived]impl ::core::fmt::Debug for RestrictionKind {
    #[inline]
    #[rustc_trivial_field_reads]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        match self {
            Self::Unrestricted =>
                ::core::fmt::Formatter::write_str(f, "Unrestricted"),
            Self::Restricted(__self_0, __self_1) =>
                ::core::fmt::Formatter::debug_struct_field2_finish(f,
                    "Restricted", __self_0, &__self_1),
        }
    }
}Debug, const _: () =
    {
        impl ::rustc_data_structures::stable_hash::StableHash for
            RestrictionKind {
            #[inline]
            fn stable_hash<__Hcx: ::rustc_data_structures::stable_hash::StableHashCtxt>(&self,
                __hcx: &mut __Hcx,
                __hasher:
                    &mut ::rustc_data_structures::stable_hash::StableHasher) {
                match *self {
                    RestrictionKind::Unrestricted =>
                        0u8.stable_hash(__hcx, __hasher),
                    RestrictionKind::Restricted(ref __binding_0,
                        ref __binding_1) => 1u8.stable_hash(__hcx, __hasher),
                }
                match *self {
                    RestrictionKind::Unrestricted => {}
                    RestrictionKind::Restricted(ref __binding_0,
                        ref __binding_1) => {
                        { __binding_0.stable_hash(__hcx, __hasher); }
                        { __binding_1.stable_hash(__hcx, __hasher); }
                    }
                }
            }
        }
    };StableHash, #[automatically_derived]impl ::core::marker::StructuralPartialEq for
    RestrictionKind {
}
#[automatically_derived]impl ::core::cmp::PartialEq for RestrictionKind {
    #[inline]
    fn eq(&self, other: &Self) -> bool {
        ::core::intrinsics::discriminant_value(self) ==
                ::core::intrinsics::discriminant_value(other) &&
            match (self, other) {
                (Self::Restricted(__self_0, __self_1),
                    Self::Restricted(__arg1_0, __arg1_1)) =>
                    __self_0 == __arg1_0 && __self_1 == __arg1_1,
                _ => true,
            }
    }
}PartialEq, #[automatically_derived]#[doc(hidden)]unsafe impl ::core::clone::TrivialClone
    for RestrictionKind {
}
#[automatically_derived]impl ::core::clone::Clone for RestrictionKind {
    #[inline]
    #[rustc_trivial_field_reads]
    fn clone(&self) -> Self {
        let _: ::core::clone::AssertParamIsClone<DefId>;
        let _: ::core::clone::AssertParamIsClone<Span>;
        *self
    }
}Clone, #[automatically_derived]impl ::core::marker::Copy for RestrictionKind { }Copy, const _: () =
    {
        impl<__E: ::rustc_span::SpanEncoder> ::rustc_serialize::Encodable<__E>
            for RestrictionKind {
            fn encode(&self, __encoder: &mut __E) {
                let disc =
                    match *self {
                        RestrictionKind::Unrestricted => { 0usize }
                        RestrictionKind::Restricted(ref __binding_0,
                            ref __binding_1) => {
                            1usize
                        }
                    };
                ::rustc_serialize::Encoder::emit_u8(__encoder, disc as u8);
                match *self {
                    RestrictionKind::Unrestricted => {}
                    RestrictionKind::Restricted(ref __binding_0,
                        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 RestrictionKind {
            fn decode(__decoder: &mut __D) -> Self {
                match ::rustc_serialize::Decoder::read_u8(__decoder) as usize
                    {
                    0usize => { RestrictionKind::Unrestricted }
                    1usize => {
                        RestrictionKind::Restricted(::rustc_serialize::Decodable::decode(__decoder),
                            ::rustc_serialize::Decodable::decode(__decoder))
                    }
                    n => {
                        ::core::panicking::panic_fmt(format_args!("invalid enum variant tag while decoding `RestrictionKind`, expected 0..2, actual {0}",
                                n));
                    }
                }
            }
        }
    };Decodable)]
285pub enum RestrictionKind {
286    Unrestricted,
287    Restricted(DefId, Span),
288}
289
290impl RestrictionKind {
291    /// Returns `true` if the behavior is allowed/unrestricted in the given module.
292    /// A value of `false` indicates that the behavior is prohibited.
293    pub fn is_allowed_in(self, module: DefId, tcx: TyCtxt<'_>) -> bool {
294        match self {
295            RestrictionKind::Unrestricted => true,
296            RestrictionKind::Restricted(restricted_to, _) => {
297                tcx.is_descendant_of(module, restricted_to)
298            }
299        }
300    }
301
302    /// Obtain the [`Span`] of the restriction. Panics if the restriction is unrestricted.
303    pub fn expect_span(self) -> Span {
304        match self {
305            RestrictionKind::Unrestricted => {
306                ::rustc_span::macros::bug_impl(None,
    format_args!("called `expect_span` on an unrestricted item"),
    Location::caller())bug!("called `expect_span` on an unrestricted item")
307            }
308            RestrictionKind::Restricted(_, span) => span,
309        }
310    }
311
312    /// Obtain the path of the restriction. If unrestricted, an empty string is returned.
313    pub fn restriction_path(self, tcx: TyCtxt<'_>) -> String {
314        match self {
315            RestrictionKind::Unrestricted => String::new(),
316            RestrictionKind::Restricted(restricted_to, _) => {
317                if restricted_to.krate == rustc_hir::def_id::LOCAL_CRATE {
318                    {
    let _guard = CratePrefixGuard::new();
    { let _guard = NoTrimmedGuard::new(); tcx.def_path_str(restricted_to) }
}with_crate_prefix!(with_no_trimmed_paths!(tcx.def_path_str(restricted_to)))
319                } else {
320                    tcx.def_path_str(restricted_to.krate.as_mod_id())
321                }
322            }
323        }
324    }
325
326    /// Obtain the stricter restriction between `self` and `rhs`.
327    /// Panics if the restrictions do not reference the same crate.
328    pub fn stricter_of(self, rhs: Self, tcx: TyCtxt<'_>) -> Self {
329        match (self, rhs) {
330            (RestrictionKind::Unrestricted, r) | (r, RestrictionKind::Unrestricted) => r,
331            (
332                RestrictionKind::Restricted(left_did, _),
333                RestrictionKind::Restricted(right_did, _),
334            ) => {
335                if left_did.krate != right_did.krate {
336                    ::rustc_span::macros::bug_impl(None,
    format_args!("stricter_of: left and right restriction do not reference the same crate"),
    Location::caller());bug!("stricter_of: left and right restriction do not reference the same crate");
337                }
338                if tcx.is_descendant_of(left_did, right_did) { self } else { rhs }
339            }
340        }
341    }
342}
343
344#[derive(#[automatically_derived]#[doc(hidden)]unsafe impl<'tcx>
    ::core::clone::TrivialClone for ClosureSizeProfileData<'tcx> {
}
#[automatically_derived]impl<'tcx> ::core::clone::Clone for
    ClosureSizeProfileData<'tcx> {
    #[inline]
    #[rustc_trivial_field_reads]
    fn clone(&self) -> Self {
        let _: ::core::clone::AssertParamIsClone<Ty<'tcx>>;
        let _: ::core::clone::AssertParamIsClone<Ty<'tcx>>;
        *self
    }
}Clone, #[automatically_derived]impl<'tcx> ::core::fmt::Debug for
    ClosureSizeProfileData<'tcx> {
    #[inline]
    #[rustc_trivial_field_reads]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::debug_struct_field2_finish(f,
            "ClosureSizeProfileData before_feature_tys after_feature_tys",
            &self.before_feature_tys, &&self.after_feature_tys)
    }
}Debug, #[automatically_derived]impl<'tcx> ::core::marker::StructuralPartialEq for
    ClosureSizeProfileData<'tcx> {
}
#[automatically_derived]impl<'tcx> ::core::cmp::PartialEq for
    ClosureSizeProfileData<'tcx> {
    #[inline]
    fn eq(&self, other: &Self) -> bool {
        self.before_feature_tys == other.before_feature_tys &&
            self.after_feature_tys == other.after_feature_tys
    }
}PartialEq, #[automatically_derived]impl<'tcx> ::core::cmp::Eq for
    ClosureSizeProfileData<'tcx> {
    #[inline]
    #[doc(hidden)]
    #[coverage(off)]
    fn assert_fields_are_eq(&self) {
        let _: ::core::cmp::AssertParamIsEq<Ty<'tcx>>;
        let _: ::core::cmp::AssertParamIsEq<Ty<'tcx>>;
    }
}Eq, #[automatically_derived]impl<'tcx> ::core::marker::Copy for
    ClosureSizeProfileData<'tcx> {
}Copy, #[automatically_derived]impl<'tcx> ::core::hash::Hash for
    ClosureSizeProfileData<'tcx> {
    #[inline]
    fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) {
        ::core::hash::Hash::hash(&self.before_feature_tys, state);
        ::core::hash::Hash::hash(&self.after_feature_tys, state)
    }
}Hash, const _: () =
    {
        impl<'tcx, __E: ::rustc_middle::ty::codec::TyEncoder<'tcx>>
            ::rustc_serialize::Encodable<__E> for ClosureSizeProfileData<'tcx>
            {
            fn encode(&self, __encoder: &mut __E) {
                let ClosureSizeProfileData {
                        before_feature_tys: ref __binding_0,
                        after_feature_tys: ref __binding_1 } = *self;
                ::rustc_serialize::Encodable::<__E>::encode(__binding_0,
                    __encoder);
                ::rustc_serialize::Encodable::<__E>::encode(__binding_1,
                    __encoder);
            }
        }
    };TyEncodable, const _: () =
    {
        impl<'tcx, __D: ::rustc_middle::ty::codec::TyDecoder<'tcx>>
            ::rustc_serialize::Decodable<__D> for ClosureSizeProfileData<'tcx>
            {
            fn decode(__decoder: &mut __D) -> Self {
                ClosureSizeProfileData {
                    before_feature_tys: ::rustc_serialize::Decodable::decode(__decoder),
                    after_feature_tys: ::rustc_serialize::Decodable::decode(__decoder),
                }
            }
        }
    };TyDecodable, const _: () =
    {
        impl<'tcx> ::rustc_data_structures::stable_hash::StableHash for
            ClosureSizeProfileData<'tcx> {
            #[inline]
            fn stable_hash<__Hcx: ::rustc_data_structures::stable_hash::StableHashCtxt>(&self,
                __hcx: &mut __Hcx,
                __hasher:
                    &mut ::rustc_data_structures::stable_hash::StableHasher) {
                match *self {
                    ClosureSizeProfileData {
                        before_feature_tys: ref __binding_0,
                        after_feature_tys: ref __binding_1 } => {
                        { __binding_0.stable_hash(__hcx, __hasher); }
                        { __binding_1.stable_hash(__hcx, __hasher); }
                    }
                }
            }
        }
    };StableHash)]
345#[derive(const _: () =
    {
        impl<'tcx>
            ::rustc_middle::ty::TypeFoldable<::rustc_middle::ty::TyCtxt<'tcx>>
            for ClosureSizeProfileData<'tcx> {
            fn try_fold_with<__F: ::rustc_middle::ty::FallibleTypeFolder<::rustc_middle::ty::TyCtxt<'tcx>>>(self,
                __folder: &mut __F) -> Result<Self, __F::Error> {
                Ok(match self {
                        ClosureSizeProfileData {
                            before_feature_tys: __binding_0,
                            after_feature_tys: __binding_1 } => {
                            ClosureSizeProfileData {
                                before_feature_tys: ::rustc_middle::ty::TypeFoldable::try_fold_with(__binding_0,
                                        __folder)?,
                                after_feature_tys: ::rustc_middle::ty::TypeFoldable::try_fold_with(__binding_1,
                                        __folder)?,
                            }
                        }
                    })
            }
            fn fold_with<__F: ::rustc_middle::ty::TypeFolder<::rustc_middle::ty::TyCtxt<'tcx>>>(self,
                __folder: &mut __F) -> Self {
                match self {
                    ClosureSizeProfileData {
                        before_feature_tys: __binding_0,
                        after_feature_tys: __binding_1 } => {
                        ClosureSizeProfileData {
                            before_feature_tys: ::rustc_middle::ty::TypeFoldable::fold_with(__binding_0,
                                __folder),
                            after_feature_tys: ::rustc_middle::ty::TypeFoldable::fold_with(__binding_1,
                                __folder),
                        }
                    }
                }
            }
        }
    };TypeFoldable, const _: () =
    {
        impl<'tcx>
            ::rustc_middle::ty::TypeVisitable<::rustc_middle::ty::TyCtxt<'tcx>>
            for ClosureSizeProfileData<'tcx> {
            fn visit_with<__V: ::rustc_middle::ty::TypeVisitor<::rustc_middle::ty::TyCtxt<'tcx>>>(&self,
                __visitor: &mut __V) -> __V::Result {
                match *self {
                    ClosureSizeProfileData {
                        before_feature_tys: ref __binding_0,
                        after_feature_tys: ref __binding_1 } => {
                        {
                            match ::rustc_middle::ty::VisitorResult::branch(::rustc_middle::ty::TypeVisitable::visit_with(__binding_0,
                                        __visitor)) {
                                ::core::ops::ControlFlow::Continue(()) => {}
                                ::core::ops::ControlFlow::Break(r) => {
                                    return ::rustc_middle::ty::VisitorResult::from_residual(r);
                                }
                            }
                        }
                        {
                            match ::rustc_middle::ty::VisitorResult::branch(::rustc_middle::ty::TypeVisitable::visit_with(__binding_1,
                                        __visitor)) {
                                ::core::ops::ControlFlow::Continue(()) => {}
                                ::core::ops::ControlFlow::Break(r) => {
                                    return ::rustc_middle::ty::VisitorResult::from_residual(r);
                                }
                            }
                        }
                    }
                }
                <__V::Result as ::rustc_middle::ty::VisitorResult>::output()
            }
        }
    };TypeVisitable)]
346pub struct ClosureSizeProfileData<'tcx> {
347    /// Tuple containing the types of closure captures before the feature `capture_disjoint_fields`
348    pub before_feature_tys: Ty<'tcx>,
349    /// Tuple containing the types of closure captures after the feature `capture_disjoint_fields`
350    pub after_feature_tys: Ty<'tcx>,
351}
352
353impl TyCtxt<'_> {
354    #[inline]
355    pub fn opt_parent(self, id: DefId) -> Option<DefId> {
356        self.def_key(id).parent.map(|index| DefId { index, ..id })
357    }
358
359    #[inline]
360    #[track_caller]
361    pub fn parent(self, id: DefId) -> DefId {
362        match self.opt_parent(id) {
363            Some(id) => id,
364            // not `unwrap_or_else` to avoid breaking caller tracking
365            None => ::rustc_span::macros::bug_impl(None,
    format_args!("{0:?} doesn\'t have a parent", id), Location::caller())bug!("{id:?} doesn't have a parent"),
366        }
367    }
368
369    #[inline]
370    #[track_caller]
371    pub fn opt_local_parent(self, id: LocalDefId) -> Option<LocalDefId> {
372        self.opt_parent(id.to_def_id()).map(DefId::expect_local)
373    }
374
375    #[inline]
376    #[track_caller]
377    pub fn local_parent(self, id: impl Into<LocalDefId>) -> LocalDefId {
378        self.parent(id.into().to_def_id()).expect_local()
379    }
380
381    /// Compare def-ids based on their position in def-id tree, ancestor def-ids are considered
382    /// larger than descendant def-ids, and two different def-ids are considered unordered if
383    /// neither of them is an ancestor of the other.
384    pub fn def_id_partial_cmp(self, lhs: DefId, rhs: DefId) -> Option<Ordering> {
385        // Def-ids from different crates are always unordered.
386        if lhs.krate != rhs.krate {
387            return None;
388        }
389
390        // Def-ids of parent nodes are always created before def-ids of child nodes
391        // and have a smaller index, so we only need to search in one direction,
392        // either from lhs to rhs, or vice versa.
393        let search = |mut start: DefId, finish: DefId, ord| {
394            while start.index != finish.index {
395                match self.opt_parent(start) {
396                    Some(parent) => start.index = parent.index,
397                    None => return None,
398                }
399            }
400            Some(ord)
401        };
402        match lhs.index.cmp(&rhs.index) {
403            Ordering::Equal => Some(Ordering::Equal),
404            Ordering::Less => search(rhs, lhs, Ordering::Greater),
405            Ordering::Greater => search(lhs, rhs, Ordering::Less),
406        }
407    }
408
409    pub fn is_descendant_of(
410        self,
411        descendant: impl Into<DefId>,
412        ancestor: impl Into<DefId>,
413    ) -> bool {
414        #[allow(non_exhaustive_omitted_patterns)] match self.def_id_partial_cmp(descendant.into(),
        ancestor.into()) {
    Some(Ordering::Less | Ordering::Equal) => true,
    _ => false,
}matches!(
415            self.def_id_partial_cmp(descendant.into(), ancestor.into()),
416            Some(Ordering::Less | Ordering::Equal)
417        )
418    }
419}
420
421impl<Id> Visibility<Id> {
422    pub fn is_public(self) -> bool {
423        #[allow(non_exhaustive_omitted_patterns)] match self {
    Visibility::Public => true,
    _ => false,
}matches!(self, Visibility::Public)
424    }
425
426    pub fn map_id<OutId>(self, f: impl FnOnce(Id) -> OutId) -> Visibility<OutId> {
427        match self {
428            Visibility::Public => Visibility::Public,
429            Visibility::Restricted(id) => Visibility::Restricted(f(id)),
430        }
431    }
432}
433
434impl Visibility<LocalModId> {
435    pub fn to_mod_id(self) -> Visibility<ModId> {
436        self.map_id(LocalModId::to_mod_id)
437    }
438}
439
440impl<Id: Into<ModId>> Visibility<Id> {
441    /// Returns `true` if an item with this visibility is accessible from the given definition.
442    pub fn is_accessible_from(self, def_id: impl Into<DefId>, tcx: TyCtxt<'_>) -> bool {
443        match self {
444            // Public items are visible everywhere.
445            Visibility::Public => true,
446            Visibility::Restricted(id) => tcx.is_descendant_of(def_id, id.into()),
447        }
448    }
449
450    pub fn partial_cmp(
451        self,
452        vis: Visibility<impl Into<ModId>>,
453        tcx: TyCtxt<'_>,
454    ) -> Option<Ordering> {
455        match (self, vis) {
456            (Visibility::Public, Visibility::Public) => Some(Ordering::Equal),
457            (Visibility::Public, Visibility::Restricted(_)) => Some(Ordering::Greater),
458            (Visibility::Restricted(_), Visibility::Public) => Some(Ordering::Less),
459            (Visibility::Restricted(lhs_id), Visibility::Restricted(rhs_id)) => {
460                let (lhs_id, rhs_id) = (lhs_id.into(), rhs_id.into());
461                tcx.def_id_partial_cmp(lhs_id.to_def_id(), rhs_id.to_def_id())
462            }
463        }
464    }
465}
466
467impl<Id: Into<ModId> + Debug + Copy> Visibility<Id> {
468    /// Returns `true` if this visibility is strictly larger than the given visibility.
469    #[track_caller]
470    pub fn greater_than(
471        self,
472        vis: Visibility<impl Into<ModId> + Debug + Copy>,
473        tcx: TyCtxt<'_>,
474    ) -> bool {
475        match self.partial_cmp(vis, tcx) {
476            Some(ord) => ord.is_gt(),
477            None => {
478                tcx.dcx().delayed_bug(::alloc::__export::must_use({
        ::alloc::fmt::format(format_args!("unordered visibilities: {0:?} and {1:?}",
                self, vis))
    })format!("unordered visibilities: {self:?} and {vis:?}"));
479                false
480            }
481        }
482    }
483}
484
485impl Visibility<ModId> {
486    pub fn expect_local(self) -> Visibility {
487        self.map_id(|id| id.expect_local())
488    }
489
490    /// Returns `true` if this item is visible anywhere in the local crate.
491    pub fn is_visible_locally(self) -> bool {
492        match self {
493            Visibility::Public => true,
494            Visibility::Restricted(mod_id) => mod_id.is_local(),
495        }
496    }
497}
498
499/// The crate variances map is computed during typeck and contains the
500/// variance of every item in the local crate. You should not use it
501/// directly, because to do so will make your pass dependent on the
502/// HIR of every item in the local crate. Instead, use
503/// `tcx.variances_of()` to get the variance for a *particular*
504/// item.
505#[derive(const _: () =
    {
        impl<'tcx> ::rustc_data_structures::stable_hash::StableHash for
            CrateVariancesMap<'tcx> {
            #[inline]
            fn stable_hash<__Hcx: ::rustc_data_structures::stable_hash::StableHashCtxt>(&self,
                __hcx: &mut __Hcx,
                __hasher:
                    &mut ::rustc_data_structures::stable_hash::StableHasher) {
                match *self {
                    CrateVariancesMap { variances: ref __binding_0 } => {
                        { __binding_0.stable_hash(__hcx, __hasher); }
                    }
                }
            }
        }
    };StableHash, #[automatically_derived]impl<'tcx> ::core::fmt::Debug for
    CrateVariancesMap<'tcx> {
    #[inline]
    #[rustc_trivial_field_reads]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::debug_struct_field1_finish(f,
            "CrateVariancesMap variances", &&self.variances)
    }
}Debug)]
506pub struct CrateVariancesMap<'tcx> {
507    /// For each item with generics, maps to a vector of the variance
508    /// of its generics. If an item has no generics, it will have no
509    /// entry.
510    pub variances: DefIdMap<&'tcx [ty::Variance]>,
511}
512
513// Contains information needed to resolve types and (in the future) look up
514// the types of AST nodes.
515#[derive(#[automatically_derived]impl ::core::marker::Copy for CReaderCacheKey { }Copy, #[automatically_derived]#[doc(hidden)]unsafe impl ::core::clone::TrivialClone
    for CReaderCacheKey {
}
#[automatically_derived]impl ::core::clone::Clone for CReaderCacheKey {
    #[inline]
    #[rustc_trivial_field_reads]
    fn clone(&self) -> Self {
        let _: ::core::clone::AssertParamIsClone<Option<CrateNum>>;
        let _: ::core::clone::AssertParamIsClone<usize>;
        *self
    }
}Clone, #[automatically_derived]impl ::core::marker::StructuralPartialEq for
    CReaderCacheKey {
}
#[automatically_derived]impl ::core::cmp::PartialEq for CReaderCacheKey {
    #[inline]
    fn eq(&self, other: &Self) -> bool {
        self.cnum == other.cnum && self.pos == other.pos
    }
}PartialEq, #[automatically_derived]impl ::core::cmp::Eq for CReaderCacheKey {
    #[inline]
    #[doc(hidden)]
    #[coverage(off)]
    fn assert_fields_are_eq(&self) {
        let _: ::core::cmp::AssertParamIsEq<Option<CrateNum>>;
        let _: ::core::cmp::AssertParamIsEq<usize>;
    }
}Eq, #[automatically_derived]impl ::core::hash::Hash for CReaderCacheKey {
    #[inline]
    fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) {
        ::core::hash::Hash::hash(&self.cnum, state);
        ::core::hash::Hash::hash(&self.pos, state)
    }
}Hash)]
516pub struct CReaderCacheKey {
517    pub cnum: Option<CrateNum>,
518    pub pos: usize,
519}
520
521/// Use this rather than `TyKind`, whenever possible.
522#[derive(#[automatically_derived]impl<'tcx> ::core::marker::Copy for Ty<'tcx> { }Copy, #[automatically_derived]#[doc(hidden)]unsafe impl<'tcx>
    ::core::clone::TrivialClone for Ty<'tcx> {
}
#[automatically_derived]impl<'tcx> ::core::clone::Clone for Ty<'tcx> {
    #[inline]
    #[rustc_trivial_field_reads]
    fn clone(&self) -> Self {
        let _:
                ::core::clone::AssertParamIsClone<Interned<'tcx,
                WithCachedTypeInfo<TyKind<'tcx>>>>;
        *self
    }
}Clone, #[automatically_derived]impl<'tcx> ::core::marker::StructuralPartialEq for
    Ty<'tcx> {
}
#[automatically_derived]impl<'tcx> ::core::cmp::PartialEq for Ty<'tcx> {
    #[inline]
    fn eq(&self, other: &Self) -> bool { self.0 == other.0 }
}PartialEq, #[automatically_derived]impl<'tcx> ::core::cmp::Eq for Ty<'tcx> {
    #[inline]
    #[doc(hidden)]
    #[coverage(off)]
    fn assert_fields_are_eq(&self) {
        let _:
                ::core::cmp::AssertParamIsEq<Interned<'tcx,
                WithCachedTypeInfo<TyKind<'tcx>>>>;
    }
}Eq, #[automatically_derived]impl<'tcx> ::core::hash::Hash for Ty<'tcx> {
    #[inline]
    fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) {
        ::core::hash::Hash::hash(&self.0, state)
    }
}Hash, const _: () =
    {
        impl<'tcx> ::rustc_data_structures::stable_hash::StableHash for
            Ty<'tcx> {
            #[inline]
            fn stable_hash<__Hcx: ::rustc_data_structures::stable_hash::StableHashCtxt>(&self,
                __hcx: &mut __Hcx,
                __hasher:
                    &mut ::rustc_data_structures::stable_hash::StableHasher) {
                match *self {
                    Ty(ref __binding_0) => {
                        { __binding_0.stable_hash(__hcx, __hasher); }
                    }
                }
            }
        }
    };StableHash)]
523#[rustc_diagnostic_item = "Ty"]
524#[cfg_attr(bootstrap, rustc_pass_by_value)]
525#[cfg_attr(not(bootstrap), lint::pass_by_value)]
526pub struct Ty<'tcx>(Interned<'tcx, WithCachedTypeInfo<TyKind<'tcx>>>);
527
528impl<'tcx> rustc_type_ir::inherent::IntoKind for Ty<'tcx> {
529    type Kind = TyKind<'tcx>;
530
531    fn kind(self) -> TyKind<'tcx> {
532        *self.kind()
533    }
534}
535
536impl<'tcx> rustc_type_ir::Flags for Ty<'tcx> {
537    fn flags(&self) -> TypeFlags {
538        self.0.flags
539    }
540
541    fn outer_exclusive_binder(&self) -> DebruijnIndex {
542        self.0.outer_exclusive_binder
543    }
544}
545
546/// The crate outlives map is computed during typeck and contains the
547/// outlives of every item in the local crate. You should not use it
548/// directly, because to do so will make your pass dependent on the
549/// HIR of every item in the local crate. Instead, use
550/// `tcx.inferred_outlives_of()` to get the outlives for a *particular*
551/// item.
552#[derive(const _: () =
    {
        impl<'tcx> ::rustc_data_structures::stable_hash::StableHash for
            CrateClausesMap<'tcx> {
            #[inline]
            fn stable_hash<__Hcx: ::rustc_data_structures::stable_hash::StableHashCtxt>(&self,
                __hcx: &mut __Hcx,
                __hasher:
                    &mut ::rustc_data_structures::stable_hash::StableHasher) {
                match *self {
                    CrateClausesMap { clauses: ref __binding_0 } => {
                        { __binding_0.stable_hash(__hcx, __hasher); }
                    }
                }
            }
        }
    };StableHash, #[automatically_derived]impl<'tcx> ::core::fmt::Debug for
    CrateClausesMap<'tcx> {
    #[inline]
    #[rustc_trivial_field_reads]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::debug_struct_field1_finish(f,
            "CrateClausesMap clauses", &&self.clauses)
    }
}Debug)]
553pub struct CrateClausesMap<'tcx> {
554    /// For each struct with outlive bounds, maps to a vector of the
555    /// clause of its outlive bounds. If an item has no outlives
556    /// bounds, it will have no entry.
557    pub clauses: DefIdMap<&'tcx [(Clause<'tcx>, Span)]>,
558}
559
560#[derive(#[automatically_derived]#[doc(hidden)]unsafe impl<'tcx>
    ::core::clone::TrivialClone for Term<'tcx> {
}
#[automatically_derived]impl<'tcx> ::core::clone::Clone for Term<'tcx> {
    #[inline]
    #[rustc_trivial_field_reads]
    fn clone(&self) -> Self {
        let _: ::core::clone::AssertParamIsClone<NonNull<()>>;
        let _:
                ::core::clone::AssertParamIsClone<PhantomData<(Ty<'tcx>,
                Const<'tcx>)>>;
        *self
    }
}Clone, #[automatically_derived]impl<'tcx> ::core::marker::Copy for Term<'tcx> { }Copy, #[automatically_derived]impl<'tcx> ::core::marker::StructuralPartialEq for
    Term<'tcx> {
}
#[automatically_derived]impl<'tcx> ::core::cmp::PartialEq for Term<'tcx> {
    #[inline]
    fn eq(&self, other: &Self) -> bool {
        self.ptr == other.ptr && self.marker == other.marker
    }
}PartialEq, #[automatically_derived]impl<'tcx> ::core::cmp::Eq for Term<'tcx> {
    #[inline]
    #[doc(hidden)]
    #[coverage(off)]
    fn assert_fields_are_eq(&self) {
        let _: ::core::cmp::AssertParamIsEq<NonNull<()>>;
        let _:
                ::core::cmp::AssertParamIsEq<PhantomData<(Ty<'tcx>,
                Const<'tcx>)>>;
    }
}Eq, #[automatically_derived]impl<'tcx> ::core::cmp::PartialOrd for Term<'tcx> {
    #[inline]
    fn partial_cmp(&self, other: &Self)
        -> ::core::option::Option<::core::cmp::Ordering> {
        ::core::option::Option::Some(::core::cmp::Ord::cmp(self, other))
    }
}PartialOrd, #[automatically_derived]impl<'tcx> ::core::cmp::Ord for Term<'tcx> {
    #[inline]
    fn cmp(&self, other: &Self) -> ::core::cmp::Ordering {
        match ::core::cmp::Ord::cmp(&self.ptr, &other.ptr) {
            ::core::cmp::Ordering::Equal =>
                ::core::cmp::Ord::cmp(&self.marker, &other.marker),
            cmp => cmp,
        }
    }
}Ord, #[automatically_derived]impl<'tcx> ::core::hash::Hash for Term<'tcx> {
    #[inline]
    fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) {
        ::core::hash::Hash::hash(&self.ptr, state);
        ::core::hash::Hash::hash(&self.marker, state)
    }
}Hash)]
561pub struct Term<'tcx> {
562    ptr: NonNull<()>,
563    marker: PhantomData<(Ty<'tcx>, Const<'tcx>)>,
564}
565
566impl<'tcx> rustc_type_ir::inherent::Term<TyCtxt<'tcx>> for Term<'tcx> {}
567
568impl<'tcx> rustc_type_ir::inherent::IntoKind for Term<'tcx> {
569    type Kind = TermKind<'tcx>;
570
571    fn kind(self) -> Self::Kind {
572        self.kind()
573    }
574}
575
576unsafe impl<'tcx> rustc_data_structures::sync::DynSend for Term<'tcx> where
577    &'tcx (Ty<'tcx>, Const<'tcx>): rustc_data_structures::sync::DynSend
578{
579}
580unsafe impl<'tcx> rustc_data_structures::sync::DynSync for Term<'tcx> where
581    &'tcx (Ty<'tcx>, Const<'tcx>): rustc_data_structures::sync::DynSync
582{
583}
584unsafe impl<'tcx> Send for Term<'tcx> where &'tcx (Ty<'tcx>, Const<'tcx>): Send {}
585unsafe impl<'tcx> Sync for Term<'tcx> where &'tcx (Ty<'tcx>, Const<'tcx>): Sync {}
586
587impl Debug for Term<'_> {
588    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
589        match self.kind() {
590            TermKind::Ty(ty) => f.write_fmt(format_args!("Term::Ty({0:?})", ty))write!(f, "Term::Ty({ty:?})"),
591            TermKind::Const(ct) => f.write_fmt(format_args!("Term::Const({0:?})", ct))write!(f, "Term::Const({ct:?})"),
592        }
593    }
594}
595
596impl<'tcx> From<Ty<'tcx>> for Term<'tcx> {
597    fn from(ty: Ty<'tcx>) -> Self {
598        TermKind::Ty(ty).pack()
599    }
600}
601
602impl<'tcx> From<Const<'tcx>> for Term<'tcx> {
603    fn from(c: Const<'tcx>) -> Self {
604        TermKind::Const(c).pack()
605    }
606}
607
608impl<'tcx> StableHash for Term<'tcx> {
609    fn stable_hash<Hcx: StableHashCtxt>(&self, hcx: &mut Hcx, hasher: &mut StableHasher) {
610        self.kind().stable_hash(hcx, hasher);
611    }
612}
613
614impl<'tcx> TypeFoldable<TyCtxt<'tcx>> for Term<'tcx> {
615    fn try_fold_with<F: FallibleTypeFolder<TyCtxt<'tcx>>>(
616        self,
617        folder: &mut F,
618    ) -> Result<Self, F::Error> {
619        match self.kind() {
620            ty::TermKind::Ty(ty) => ty.try_fold_with(folder).map(Into::into),
621            ty::TermKind::Const(ct) => ct.try_fold_with(folder).map(Into::into),
622        }
623    }
624
625    fn fold_with<F: TypeFolder<TyCtxt<'tcx>>>(self, folder: &mut F) -> Self {
626        match self.kind() {
627            ty::TermKind::Ty(ty) => ty.fold_with(folder).into(),
628            ty::TermKind::Const(ct) => ct.fold_with(folder).into(),
629        }
630    }
631}
632
633impl<'tcx> TypeVisitable<TyCtxt<'tcx>> for Term<'tcx> {
634    fn visit_with<V: TypeVisitor<TyCtxt<'tcx>>>(&self, visitor: &mut V) -> V::Result {
635        match self.kind() {
636            ty::TermKind::Ty(ty) => ty.visit_with(visitor),
637            ty::TermKind::Const(ct) => ct.visit_with(visitor),
638        }
639    }
640}
641
642impl<'tcx, E: TyEncoder<'tcx>> Encodable<E> for Term<'tcx> {
643    fn encode(&self, e: &mut E) {
644        self.kind().encode(e)
645    }
646}
647
648impl<'tcx, D: TyDecoder<'tcx>> Decodable<D> for Term<'tcx> {
649    fn decode(d: &mut D) -> Self {
650        let res: TermKind<'tcx> = Decodable::decode(d);
651        res.pack()
652    }
653}
654
655impl<'tcx> Term<'tcx> {
656    #[inline]
657    pub fn kind(self) -> TermKind<'tcx> {
658        let ptr =
659            unsafe { self.ptr.map_addr(|addr| NonZero::new_unchecked(addr.get() & !TAG_MASK)) };
660        // SAFETY: use of `Interned::new_unchecked` here is ok because these
661        // pointers were originally created from `Interned` types in `pack()`,
662        // and this is just going in the other direction.
663        unsafe {
664            match self.ptr.addr().get() & TAG_MASK {
665                TYPE_TAG => TermKind::Ty(Ty(Interned::new_unchecked(
666                    ptr.cast::<WithCachedTypeInfo<ty::TyKind<'tcx>>>().as_ref(),
667                ))),
668                CONST_TAG => TermKind::Const(ty::Const(Interned::new_unchecked(
669                    ptr.cast::<WithCachedTypeInfo<ty::ConstKind<'tcx>>>().as_ref(),
670                ))),
671                _ => core::intrinsics::unreachable(),
672            }
673        }
674    }
675
676    pub fn as_type(&self) -> Option<Ty<'tcx>> {
677        if let TermKind::Ty(ty) = self.kind() { Some(ty) } else { None }
678    }
679
680    pub fn expect_type(&self) -> Ty<'tcx> {
681        self.as_type().expect("expected a type, but found a const")
682    }
683
684    pub fn as_const(&self) -> Option<Const<'tcx>> {
685        if let TermKind::Const(c) = self.kind() { Some(c) } else { None }
686    }
687
688    pub fn expect_const(&self) -> Const<'tcx> {
689        self.as_const().expect("expected a const, but found a type")
690    }
691
692    pub fn into_arg(self) -> GenericArg<'tcx> {
693        match self.kind() {
694            TermKind::Ty(ty) => ty.into(),
695            TermKind::Const(c) => c.into(),
696        }
697    }
698
699    pub fn to_alias_term(self) -> Option<AliasTerm<'tcx>> {
700        match self.kind() {
701            TermKind::Ty(ty) => match *ty.kind() {
702                ty::Alias(_, alias_ty) => Some(alias_ty.into()),
703                _ => None,
704            },
705            TermKind::Const(ct) => match ct.kind() {
706                ConstKind::Alias(_, alias_const) => Some(alias_const.into()),
707                _ => None,
708            },
709        }
710    }
711
712    pub fn is_non_rigid_alias(self) -> bool {
713        match self.kind() {
714            ty::TermKind::Ty(ty) => match ty.kind() {
715                ty::Alias(ty::IsRigid::No, _) => true,
716                _ => false,
717            },
718            ty::TermKind::Const(ct) => match ct.kind() {
719                ty::ConstKind::Alias(ty::IsRigid::No, _) => true,
720                _ => false,
721            },
722        }
723    }
724
725    pub fn is_infer(&self) -> bool {
726        match self.kind() {
727            TermKind::Ty(ty) => ty.is_ty_var(),
728            TermKind::Const(ct) => ct.is_ct_infer(),
729        }
730    }
731
732    pub fn is_trivially_wf(&self, tcx: TyCtxt<'tcx>) -> bool {
733        match self.kind() {
734            TermKind::Ty(ty) => ty.is_trivially_wf(tcx),
735            TermKind::Const(ct) => ct.is_trivially_wf(),
736        }
737    }
738
739    /// Iterator that walks `self` and any types reachable from
740    /// `self`, in depth-first order. Note that just walks the types
741    /// that appear in `self`, it does not descend into the fields of
742    /// structs or variants. For example:
743    ///
744    /// ```text
745    /// isize => { isize }
746    /// Foo<Bar<isize>> => { Foo<Bar<isize>>, Bar<isize>, isize }
747    /// [isize] => { [isize], isize }
748    /// ```
749    pub fn walk(self) -> TypeWalker<TyCtxt<'tcx>> {
750        TypeWalker::new(self.into())
751    }
752}
753
754const TAG_MASK: usize = 0b11;
755const TYPE_TAG: usize = 0b00;
756const CONST_TAG: usize = 0b01;
757
758pub trait TermKindPackExt<'tcx> {
    fn pack(self)
    -> Term<'tcx>;
}
impl<'tcx> TermKindPackExt<'tcx> for TermKind<'tcx> {
    #[inline]
    fn pack(self) -> Term<'tcx> {
        let (tag, ptr) =
            match self {
                TermKind::Ty(ty) => {
                    {
                        match (&(align_of_val(&*ty.0.0) & TAG_MASK), &0) {
                            (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);
                                }
                            }
                        }
                    };
                    (TYPE_TAG, NonNull::from(ty.0.0).cast())
                }
                TermKind::Const(ct) => {
                    {
                        match (&(align_of_val(&*ct.0.0) & TAG_MASK), &0) {
                            (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);
                                }
                            }
                        }
                    };
                    (CONST_TAG, NonNull::from(ct.0.0).cast())
                }
            };
        Term { ptr: ptr.map_addr(|addr| addr | tag), marker: PhantomData }
    }
}#[extension(pub trait TermKindPackExt<'tcx>)]
759impl<'tcx> TermKind<'tcx> {
760    #[inline]
761    fn pack(self) -> Term<'tcx> {
762        let (tag, ptr) = match self {
763            TermKind::Ty(ty) => {
764                // Ensure we can use the tag bits.
765                assert_eq!(align_of_val(&*ty.0.0) & TAG_MASK, 0);
766                (TYPE_TAG, NonNull::from(ty.0.0).cast())
767            }
768            TermKind::Const(ct) => {
769                // Ensure we can use the tag bits.
770                assert_eq!(align_of_val(&*ct.0.0) & TAG_MASK, 0);
771                (CONST_TAG, NonNull::from(ct.0.0).cast())
772            }
773        };
774
775        Term { ptr: ptr.map_addr(|addr| addr | tag), marker: PhantomData }
776    }
777}
778
779/// Represents the bounds declared on a particular set of type
780/// parameters. Should eventually be generalized into a flag list of
781/// where-clauses. You can obtain an `InstantiatedClauses` list from a
782/// `GenericClauses` by using the `instantiate` method. Note that this method
783/// reflects an important semantic invariant of `InstantiatedClauses`: while
784/// the `GenericClauses` are expressed in terms of the bound type
785/// parameters of the impl/trait/whatever, an `InstantiatedClauses` instance
786/// represented a set of bounds for some particular instantiation,
787/// meaning that the generic parameters have been instantiated with
788/// their values.
789///
790/// Example:
791/// ```ignore (illustrative)
792/// struct Foo<T, U: Bar<T>> { ... }
793/// ```
794/// Here, the `GenericClauses` for `Foo` would contain a list of bounds like
795/// `[[], [U:Bar<T>]]`. Now if there were some particular reference
796/// like `Foo<isize,usize>`, then the `InstantiatedClauses` would be `[[],
797/// [usize:Bar<isize>]]`.
798#[derive(#[automatically_derived]impl<'tcx> ::core::clone::Clone for
    InstantiatedClauses<'tcx> {
    #[inline]
    #[rustc_trivial_field_reads]
    fn clone(&self) -> Self {
        InstantiatedClauses {
            clauses: ::core::clone::Clone::clone(&self.clauses),
            spans: ::core::clone::Clone::clone(&self.spans),
        }
    }
}Clone, #[automatically_derived]impl<'tcx> ::core::fmt::Debug for
    InstantiatedClauses<'tcx> {
    #[inline]
    #[rustc_trivial_field_reads]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::debug_struct_field2_finish(f,
            "InstantiatedClauses clauses spans", &self.clauses, &&self.spans)
    }
}Debug)]
799pub struct InstantiatedClauses<'tcx> {
800    pub clauses: Vec<Unnormalized<'tcx, Clause<'tcx>>>,
801    pub spans: Vec<Span>,
802}
803
804impl<'tcx> InstantiatedClauses<'tcx> {
805    pub fn empty() -> InstantiatedClauses<'tcx> {
806        InstantiatedClauses { clauses: ::alloc::vec::Vec::new()vec![], spans: ::alloc::vec::Vec::new()vec![] }
807    }
808
809    pub fn is_empty(&self) -> bool {
810        self.clauses.is_empty()
811    }
812
813    pub fn iter(&self) -> <&Self as IntoIterator>::IntoIter {
814        self.into_iter()
815    }
816}
817
818impl<'tcx> IntoIterator for InstantiatedClauses<'tcx> {
819    type Item = (Unnormalized<'tcx, Clause<'tcx>>, Span);
820
821    type IntoIter = std::iter::Zip<
822        std::vec::IntoIter<Unnormalized<'tcx, Clause<'tcx>>>,
823        std::vec::IntoIter<Span>,
824    >;
825
826    fn into_iter(self) -> Self::IntoIter {
827        if true {
    {
        match (&self.clauses.len(), &self.spans.len()) {
            (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!(self.clauses.len(), self.spans.len());
828        std::iter::zip(self.clauses, self.spans)
829    }
830}
831
832impl<'a, 'tcx> IntoIterator for &'a InstantiatedClauses<'tcx> {
833    type Item = (Unnormalized<'tcx, Clause<'tcx>>, Span);
834
835    type IntoIter = std::iter::Zip<
836        std::iter::Copied<std::slice::Iter<'a, Unnormalized<'tcx, Clause<'tcx>>>>,
837        std::iter::Copied<std::slice::Iter<'a, Span>>,
838    >;
839
840    fn into_iter(self) -> Self::IntoIter {
841        if true {
    {
        match (&self.clauses.len(), &self.spans.len()) {
            (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!(self.clauses.len(), self.spans.len());
842        std::iter::zip(self.clauses.iter().copied(), self.spans.iter().copied())
843    }
844}
845
846#[derive(#[automatically_derived]impl<'tcx> ::core::marker::Copy for
    ProvisionalHiddenType<'tcx> {
}Copy, #[automatically_derived]#[doc(hidden)]unsafe impl<'tcx>
    ::core::clone::TrivialClone for ProvisionalHiddenType<'tcx> {
}
#[automatically_derived]impl<'tcx> ::core::clone::Clone for
    ProvisionalHiddenType<'tcx> {
    #[inline]
    #[rustc_trivial_field_reads]
    fn clone(&self) -> Self {
        let _: ::core::clone::AssertParamIsClone<Span>;
        let _: ::core::clone::AssertParamIsClone<Ty<'tcx>>;
        *self
    }
}Clone, #[automatically_derived]impl<'tcx> ::core::fmt::Debug for
    ProvisionalHiddenType<'tcx> {
    #[inline]
    #[rustc_trivial_field_reads]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::debug_struct_field2_finish(f,
            "ProvisionalHiddenType span ty", &self.span, &&self.ty)
    }
}Debug, const _: () =
    {
        impl<'tcx>
            ::rustc_middle::ty::TypeFoldable<::rustc_middle::ty::TyCtxt<'tcx>>
            for ProvisionalHiddenType<'tcx> {
            fn try_fold_with<__F: ::rustc_middle::ty::FallibleTypeFolder<::rustc_middle::ty::TyCtxt<'tcx>>>(self,
                __folder: &mut __F) -> Result<Self, __F::Error> {
                Ok(match self {
                        ProvisionalHiddenType { span: __binding_0, ty: __binding_1 }
                            => {
                            ProvisionalHiddenType {
                                span: ::rustc_middle::ty::TypeFoldable::try_fold_with(__binding_0,
                                        __folder)?,
                                ty: ::rustc_middle::ty::TypeFoldable::try_fold_with(__binding_1,
                                        __folder)?,
                            }
                        }
                    })
            }
            fn fold_with<__F: ::rustc_middle::ty::TypeFolder<::rustc_middle::ty::TyCtxt<'tcx>>>(self,
                __folder: &mut __F) -> Self {
                match self {
                    ProvisionalHiddenType { span: __binding_0, ty: __binding_1 }
                        => {
                        ProvisionalHiddenType {
                            span: ::rustc_middle::ty::TypeFoldable::fold_with(__binding_0,
                                __folder),
                            ty: ::rustc_middle::ty::TypeFoldable::fold_with(__binding_1,
                                __folder),
                        }
                    }
                }
            }
        }
    };TypeFoldable, const _: () =
    {
        impl<'tcx>
            ::rustc_middle::ty::TypeVisitable<::rustc_middle::ty::TyCtxt<'tcx>>
            for ProvisionalHiddenType<'tcx> {
            fn visit_with<__V: ::rustc_middle::ty::TypeVisitor<::rustc_middle::ty::TyCtxt<'tcx>>>(&self,
                __visitor: &mut __V) -> __V::Result {
                match *self {
                    ProvisionalHiddenType {
                        span: ref __binding_0, ty: ref __binding_1 } => {
                        {
                            match ::rustc_middle::ty::VisitorResult::branch(::rustc_middle::ty::TypeVisitable::visit_with(__binding_0,
                                        __visitor)) {
                                ::core::ops::ControlFlow::Continue(()) => {}
                                ::core::ops::ControlFlow::Break(r) => {
                                    return ::rustc_middle::ty::VisitorResult::from_residual(r);
                                }
                            }
                        }
                        {
                            match ::rustc_middle::ty::VisitorResult::branch(::rustc_middle::ty::TypeVisitable::visit_with(__binding_1,
                                        __visitor)) {
                                ::core::ops::ControlFlow::Continue(()) => {}
                                ::core::ops::ControlFlow::Break(r) => {
                                    return ::rustc_middle::ty::VisitorResult::from_residual(r);
                                }
                            }
                        }
                    }
                }
                <__V::Result as ::rustc_middle::ty::VisitorResult>::output()
            }
        }
    };TypeVisitable, const _: () =
    {
        impl<'tcx> ::rustc_data_structures::stable_hash::StableHash for
            ProvisionalHiddenType<'tcx> {
            #[inline]
            fn stable_hash<__Hcx: ::rustc_data_structures::stable_hash::StableHashCtxt>(&self,
                __hcx: &mut __Hcx,
                __hasher:
                    &mut ::rustc_data_structures::stable_hash::StableHasher) {
                match *self {
                    ProvisionalHiddenType {
                        span: ref __binding_0, ty: ref __binding_1 } => {
                        { __binding_0.stable_hash(__hcx, __hasher); }
                        { __binding_1.stable_hash(__hcx, __hasher); }
                    }
                }
            }
        }
    };StableHash, const _: () =
    {
        impl<'tcx, __E: ::rustc_middle::ty::codec::TyEncoder<'tcx>>
            ::rustc_serialize::Encodable<__E> for ProvisionalHiddenType<'tcx>
            {
            fn encode(&self, __encoder: &mut __E) {
                let ProvisionalHiddenType {
                        span: ref __binding_0, ty: ref __binding_1 } = *self;
                ::rustc_serialize::Encodable::<__E>::encode(__binding_0,
                    __encoder);
                ::rustc_serialize::Encodable::<__E>::encode(__binding_1,
                    __encoder);
            }
        }
    };TyEncodable, const _: () =
    {
        impl<'tcx, __D: ::rustc_middle::ty::codec::TyDecoder<'tcx>>
            ::rustc_serialize::Decodable<__D> for ProvisionalHiddenType<'tcx>
            {
            fn decode(__decoder: &mut __D) -> Self {
                ProvisionalHiddenType {
                    span: ::rustc_serialize::Decodable::decode(__decoder),
                    ty: ::rustc_serialize::Decodable::decode(__decoder),
                }
            }
        }
    };TyDecodable)]
847pub struct ProvisionalHiddenType<'tcx> {
848    /// The span of this particular definition of the opaque type. So
849    /// for example:
850    ///
851    /// ```ignore (incomplete snippet)
852    /// type Foo = impl Baz;
853    /// fn bar() -> Foo {
854    /// //          ^^^ This is the span we are looking for!
855    /// }
856    /// ```
857    ///
858    /// In cases where the fn returns `(impl Trait, impl Trait)` or
859    /// other such combinations, the result is currently
860    /// over-approximated, but better than nothing.
861    pub span: Span,
862
863    /// The type variable that represents the value of the opaque type
864    /// that we require. In other words, after we compile this function,
865    /// we will be created a constraint like:
866    /// ```ignore (pseudo-rust)
867    /// Foo<'a, T> = ?C
868    /// ```
869    /// where `?C` is the value of this type variable. =) It may
870    /// naturally refer to the type and lifetime parameters in scope
871    /// in this function, though ultimately it should only reference
872    /// those that are arguments to `Foo` in the constraint above. (In
873    /// other words, `?C` should not include `'b`, even though it's a
874    /// lifetime parameter on `foo`.)
875    pub ty: Ty<'tcx>,
876}
877
878/// Whether we're currently in HIR typeck or MIR borrowck.
879#[derive(#[automatically_derived]impl ::core::fmt::Debug for DefiningScopeKind {
    #[inline]
    #[rustc_trivial_field_reads]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::write_str(f,
            match self {
                DefiningScopeKind::HirTypeck => "HirTypeck",
                DefiningScopeKind::MirBorrowck => "MirBorrowck",
            })
    }
}Debug, #[automatically_derived]#[doc(hidden)]unsafe impl ::core::clone::TrivialClone
    for DefiningScopeKind {
}
#[automatically_derived]impl ::core::clone::Clone for DefiningScopeKind {
    #[inline]
    #[rustc_trivial_field_reads]
    fn clone(&self) -> Self { *self }
}Clone, #[automatically_derived]impl ::core::marker::Copy for DefiningScopeKind { }Copy)]
880pub enum DefiningScopeKind {
881    /// During writeback in typeck, we don't care about regions and simply
882    /// erase them. This means we also don't check whether regions are
883    /// universal in the opaque type key. This will only be checked in
884    /// MIR borrowck.
885    HirTypeck,
886    MirBorrowck,
887}
888
889impl<'tcx> ProvisionalHiddenType<'tcx> {
890    pub fn new_error(tcx: TyCtxt<'tcx>, guar: ErrorGuaranteed) -> ProvisionalHiddenType<'tcx> {
891        ProvisionalHiddenType { span: DUMMY_SP, ty: Ty::new_error(tcx, guar) }
892    }
893
894    pub fn build_mismatch_error(
895        &self,
896        other: &Self,
897        tcx: TyCtxt<'tcx>,
898    ) -> Result<Diag<'tcx>, ErrorGuaranteed> {
899        (self.ty, other.ty).error_reported()?;
900        // Found different concrete types for the opaque type.
901        let sub_diag = if self.span == other.span {
902            TypeMismatchReason::ConflictType { span: self.span }
903        } else {
904            TypeMismatchReason::PreviousUse { span: self.span }
905        };
906        Ok(tcx.dcx().create_err(OpaqueHiddenTypeMismatch {
907            self_ty: self.ty,
908            other_ty: other.ty,
909            other_span: other.span,
910            sub: sub_diag,
911        }))
912    }
913
914    {}
let __tracing_attr_span;
let __tracing_attr_guard;
if ::tracing::Level::DEBUG <= ::tracing::level_filters::STATIC_MAX_LEVEL &&
            ::tracing::Level::DEBUG <=
                ::tracing::level_filters::LevelFilter::current() || { false }
    {
    __tracing_attr_span =
        {
            use ::tracing::__macro_support::Callsite as _;
            static __CALLSITE: ::tracing::callsite::DefaultCallsite =
                {
                    static META: ::tracing::Metadata<'static> =
                        {
                            ::tracing_core::metadata::Metadata::new("remap_generic_params_to_declaration_params",
                                "rustc_middle::ty", ::tracing::Level::DEBUG,
                                ::tracing_core::__macro_support::Option::Some("/rustc-dev/c82ce15637153c025d29abbaff6035a177361788/compiler/rustc_middle/src/ty/mod.rs"),
                                ::tracing_core::__macro_support::Option::Some(914u32),
                                ::tracing_core::__macro_support::Option::Some("rustc_middle::ty"),
                                ::tracing_core::field::FieldSet::new(&[{
                                                    const NAME:
                                                        ::tracing::__macro_support::FieldName<{
                                                            ::tracing::__macro_support::FieldName::len("self")
                                                        }> =
                                                        ::tracing::__macro_support::FieldName::new("self");
                                                    NAME.as_str()
                                                },
                                                {
                                                    const NAME:
                                                        ::tracing::__macro_support::FieldName<{
                                                            ::tracing::__macro_support::FieldName::len("opaque_type_key")
                                                        }> =
                                                        ::tracing::__macro_support::FieldName::new("opaque_type_key");
                                                    NAME.as_str()
                                                },
                                                {
                                                    const NAME:
                                                        ::tracing::__macro_support::FieldName<{
                                                            ::tracing::__macro_support::FieldName::len("defining_scope_kind")
                                                        }> =
                                                        ::tracing::__macro_support::FieldName::new("defining_scope_kind");
                                                    NAME.as_str()
                                                }], ::tracing_core::callsite::Identifier(&__CALLSITE)),
                                ::tracing::metadata::Kind::SPAN)
                        };
                    ::tracing::callsite::DefaultCallsite::new(&META)
                };
            let mut interest = ::tracing::subscriber::Interest::never();
            if ::tracing::Level::DEBUG <=
                                ::tracing::level_filters::STATIC_MAX_LEVEL &&
                            ::tracing::Level::DEBUG <=
                                ::tracing::level_filters::LevelFilter::current() &&
                        { interest = __CALLSITE.interest(); !interest.is_never() }
                    &&
                    ::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
                        interest) {
                let meta = __CALLSITE.metadata();
                ::tracing::Span::new(meta,
                    &{
                            #[allow(unused_imports)]
                            use ::tracing::field::{debug, display, Value};
                            meta.fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&self)
                                                        as &dyn ::tracing::field::Value)),
                                            (::tracing::__macro_support::Option::Some(&::tracing::field::debug(&opaque_type_key)
                                                        as &dyn ::tracing::field::Value)),
                                            (::tracing::__macro_support::Option::Some(&::tracing::field::debug(&defining_scope_kind)
                                                        as &dyn ::tracing::field::Value))])
                        })
            } else {
                let span =
                    ::tracing::__macro_support::__disabled_span(__CALLSITE.metadata());
                {};
                span
            }
        };
    __tracing_attr_guard = __tracing_attr_span.enter();
}
#[allow(clippy :: redundant_closure_call)]
let x =
    (move ||
                {

                    #[allow(unknown_lints, unreachable_code, clippy ::
                    diverging_sub_expression, clippy :: empty_loop, clippy ::
                    let_unit_value, clippy :: let_with_type_underscore, clippy
                    :: needless_return, clippy :: unreachable)]
                    if false {
                        let __tracing_attr_fake_return:
                                DefinitionSiteHiddenType<'tcx> = loop {};
                        return __tracing_attr_fake_return;
                    }
                    {
                        let OpaqueTypeKey { def_id, args } = opaque_type_key;
                        let id_args = GenericArgs::identity_for_item(tcx, def_id);
                        {
                            use ::tracing::__macro_support::Callsite as _;
                            static __CALLSITE: ::tracing::callsite::DefaultCallsite =
                                {
                                    static META: ::tracing::Metadata<'static> =
                                        {
                                            ::tracing_core::metadata::Metadata::new("event /rustc-dev/c82ce15637153c025d29abbaff6035a177361788/compiler/rustc_middle/src/ty/mod.rs:930",
                                                "rustc_middle::ty", ::tracing::Level::DEBUG,
                                                ::tracing_core::__macro_support::Option::Some("/rustc-dev/c82ce15637153c025d29abbaff6035a177361788/compiler/rustc_middle/src/ty/mod.rs"),
                                                ::tracing_core::__macro_support::Option::Some(930u32),
                                                ::tracing_core::__macro_support::Option::Some("rustc_middle::ty"),
                                                ::tracing_core::field::FieldSet::new(&[{
                                                                    const NAME:
                                                                        ::tracing::__macro_support::FieldName<{
                                                                            ::tracing::__macro_support::FieldName::len("id_args")
                                                                        }> =
                                                                        ::tracing::__macro_support::FieldName::new("id_args");
                                                                    NAME.as_str()
                                                                }], ::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};
                                        __CALLSITE.metadata().fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&id_args)
                                                                    as &dyn ::tracing::field::Value))])
                                    });
                            } else { ; }
                        };
                        let map = args.iter().zip(id_args.iter()).collect();
                        {
                            use ::tracing::__macro_support::Callsite as _;
                            static __CALLSITE: ::tracing::callsite::DefaultCallsite =
                                {
                                    static META: ::tracing::Metadata<'static> =
                                        {
                                            ::tracing_core::metadata::Metadata::new("event /rustc-dev/c82ce15637153c025d29abbaff6035a177361788/compiler/rustc_middle/src/ty/mod.rs:936",
                                                "rustc_middle::ty", ::tracing::Level::DEBUG,
                                                ::tracing_core::__macro_support::Option::Some("/rustc-dev/c82ce15637153c025d29abbaff6035a177361788/compiler/rustc_middle/src/ty/mod.rs"),
                                                ::tracing_core::__macro_support::Option::Some(936u32),
                                                ::tracing_core::__macro_support::Option::Some("rustc_middle::ty"),
                                                ::tracing_core::field::FieldSet::new(&["message"],
                                                    ::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};
                                        __CALLSITE.metadata().fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&format_args!("map = {0:#?}",
                                                                            map) as &dyn ::tracing::field::Value))])
                                    });
                            } else { ; }
                        };
                        let ty =
                            match defining_scope_kind {
                                DefiningScopeKind::HirTypeck => {
                                    fold_regions(tcx, self.ty, |_, _| tcx.lifetimes.re_erased)
                                }
                                DefiningScopeKind::MirBorrowck => self.ty,
                            };
                        let result_ty =
                            ty.fold_with(&mut opaque_types::ReverseMapper::new(tcx, map,
                                        self.span));
                        if true &&
                                #[allow(non_exhaustive_omitted_patterns)] match defining_scope_kind
                                    {
                                    DefiningScopeKind::HirTypeck => true,
                                    _ => false,
                                } {
                            {
                                match (&result_ty,
                                        &fold_regions(tcx, result_ty,
                                                |_, _| tcx.lifetimes.re_erased)) {
                                    (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);
                                        }
                                    }
                                }
                            };
                        }
                        DefinitionSiteHiddenType {
                            span: self.span,
                            ty: ty::EarlyBinder::bind(tcx, result_ty),
                        }
                    }
                })();
{
    use ::tracing::__macro_support::Callsite as _;
    static __CALLSITE: ::tracing::callsite::DefaultCallsite =
        {
            static META: ::tracing::Metadata<'static> =
                {
                    ::tracing_core::metadata::Metadata::new("event /rustc-dev/c82ce15637153c025d29abbaff6035a177361788/compiler/rustc_middle/src/ty/mod.rs:914",
                        "rustc_middle::ty", ::tracing::Level::DEBUG,
                        ::tracing_core::__macro_support::Option::Some("/rustc-dev/c82ce15637153c025d29abbaff6035a177361788/compiler/rustc_middle/src/ty/mod.rs"),
                        ::tracing_core::__macro_support::Option::Some(914u32),
                        ::tracing_core::__macro_support::Option::Some("rustc_middle::ty"),
                        ::tracing_core::field::FieldSet::new(&[{
                                            const NAME:
                                                ::tracing::__macro_support::FieldName<{
                                                    ::tracing::__macro_support::FieldName::len("return")
                                                }> =
                                                ::tracing::__macro_support::FieldName::new("return");
                                            NAME.as_str()
                                        }], ::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};
                __CALLSITE.metadata().fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&x)
                                            as &dyn ::tracing::field::Value))])
            });
    } else { ; }
};
x;#[instrument(level = "debug", skip(tcx), ret)]
915    pub fn remap_generic_params_to_declaration_params(
916        self,
917        opaque_type_key: OpaqueTypeKey<'tcx>,
918        tcx: TyCtxt<'tcx>,
919        defining_scope_kind: DefiningScopeKind,
920    ) -> DefinitionSiteHiddenType<'tcx> {
921        let OpaqueTypeKey { def_id, args } = opaque_type_key;
922
923        // Use args to build up a reverse map from regions to their
924        // identity mappings. This is necessary because of `impl
925        // Trait` lifetimes are computed by replacing existing
926        // lifetimes with 'static and remapping only those used in the
927        // `impl Trait` return type, resulting in the parameters
928        // shifting.
929        let id_args = GenericArgs::identity_for_item(tcx, def_id);
930        debug!(?id_args);
931
932        // This zip may have several times the same lifetime in `args` paired with a different
933        // lifetime from `id_args`. Simply `collect`ing the iterator is the correct behaviour:
934        // it will pick the last one, which is the one we introduced in the impl-trait desugaring.
935        let map = args.iter().zip(id_args.iter()).collect();
936        debug!("map = {:#?}", map);
937
938        // Convert the type from the function into a type valid outside by mapping generic
939        // parameters to into the context of the opaque.
940        //
941        // We erase regions when doing this during HIR typeck. We manually use `fold_regions`
942        // here as we do not want to anonymize bound variables.
943        let ty = match defining_scope_kind {
944            DefiningScopeKind::HirTypeck => {
945                fold_regions(tcx, self.ty, |_, _| tcx.lifetimes.re_erased)
946            }
947            DefiningScopeKind::MirBorrowck => self.ty,
948        };
949        let result_ty = ty.fold_with(&mut opaque_types::ReverseMapper::new(tcx, map, self.span));
950        if cfg!(debug_assertions) && matches!(defining_scope_kind, DefiningScopeKind::HirTypeck) {
951            assert_eq!(result_ty, fold_regions(tcx, result_ty, |_, _| tcx.lifetimes.re_erased));
952        }
953        DefinitionSiteHiddenType { span: self.span, ty: ty::EarlyBinder::bind(tcx, result_ty) }
954    }
955}
956
957#[derive(#[automatically_derived]impl<'tcx> ::core::marker::Copy for
    DefinitionSiteHiddenType<'tcx> {
}Copy, #[automatically_derived]#[doc(hidden)]unsafe impl<'tcx>
    ::core::clone::TrivialClone for DefinitionSiteHiddenType<'tcx> {
}
#[automatically_derived]impl<'tcx> ::core::clone::Clone for
    DefinitionSiteHiddenType<'tcx> {
    #[inline]
    #[rustc_trivial_field_reads]
    fn clone(&self) -> Self {
        let _: ::core::clone::AssertParamIsClone<Span>;
        let _:
                ::core::clone::AssertParamIsClone<ty::EarlyBinder<'tcx,
                Ty<'tcx>>>;
        *self
    }
}Clone, #[automatically_derived]impl<'tcx> ::core::fmt::Debug for
    DefinitionSiteHiddenType<'tcx> {
    #[inline]
    #[rustc_trivial_field_reads]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::debug_struct_field2_finish(f,
            "DefinitionSiteHiddenType span ty", &self.span, &&self.ty)
    }
}Debug, const _: () =
    {
        impl<'tcx> ::rustc_data_structures::stable_hash::StableHash for
            DefinitionSiteHiddenType<'tcx> {
            #[inline]
            fn stable_hash<__Hcx: ::rustc_data_structures::stable_hash::StableHashCtxt>(&self,
                __hcx: &mut __Hcx,
                __hasher:
                    &mut ::rustc_data_structures::stable_hash::StableHasher) {
                match *self {
                    DefinitionSiteHiddenType {
                        span: ref __binding_0, ty: ref __binding_1 } => {
                        { __binding_0.stable_hash(__hcx, __hasher); }
                        { __binding_1.stable_hash(__hcx, __hasher); }
                    }
                }
            }
        }
    };StableHash, const _: () =
    {
        impl<'tcx, __E: ::rustc_middle::ty::codec::TyEncoder<'tcx>>
            ::rustc_serialize::Encodable<__E> for
            DefinitionSiteHiddenType<'tcx> {
            fn encode(&self, __encoder: &mut __E) {
                let DefinitionSiteHiddenType {
                        span: ref __binding_0, ty: ref __binding_1 } = *self;
                ::rustc_serialize::Encodable::<__E>::encode(__binding_0,
                    __encoder);
                ::rustc_serialize::Encodable::<__E>::encode(__binding_1,
                    __encoder);
            }
        }
    };TyEncodable, const _: () =
    {
        impl<'tcx, __D: ::rustc_middle::ty::codec::TyDecoder<'tcx>>
            ::rustc_serialize::Decodable<__D> for
            DefinitionSiteHiddenType<'tcx> {
            fn decode(__decoder: &mut __D) -> Self {
                DefinitionSiteHiddenType {
                    span: ::rustc_serialize::Decodable::decode(__decoder),
                    ty: ::rustc_serialize::Decodable::decode(__decoder),
                }
            }
        }
    };TyDecodable)]
958pub struct DefinitionSiteHiddenType<'tcx> {
959    /// The span of the definition of the opaque type. So for example:
960    ///
961    /// ```ignore (incomplete snippet)
962    /// type Foo = impl Baz;
963    /// fn bar() -> Foo {
964    /// //          ^^^ This is the span we are looking for!
965    /// }
966    /// ```
967    ///
968    /// In cases where the fn returns `(impl Trait, impl Trait)` or
969    /// other such combinations, the result is currently
970    /// over-approximated, but better than nothing.
971    pub span: Span,
972
973    /// The final type of the opaque.
974    pub ty: ty::EarlyBinder<'tcx, Ty<'tcx>>,
975}
976
977impl<'tcx> DefinitionSiteHiddenType<'tcx> {
978    pub fn new_error(tcx: TyCtxt<'tcx>, guar: ErrorGuaranteed) -> DefinitionSiteHiddenType<'tcx> {
979        DefinitionSiteHiddenType {
980            span: DUMMY_SP,
981            ty: ty::EarlyBinder::bind(tcx, Ty::new_error(tcx, guar)),
982        }
983    }
984
985    pub fn build_mismatch_error(
986        &self,
987        other: &Self,
988        tcx: TyCtxt<'tcx>,
989    ) -> Result<Diag<'tcx>, ErrorGuaranteed> {
990        let self_ty = self.ty.instantiate_identity().skip_norm_wip();
991        let other_ty = other.ty.instantiate_identity().skip_norm_wip();
992        (self_ty, other_ty).error_reported()?;
993        // Found different concrete types for the opaque type.
994        let sub_diag = if self.span == other.span {
995            TypeMismatchReason::ConflictType { span: self.span }
996        } else {
997            TypeMismatchReason::PreviousUse { span: self.span }
998        };
999        Ok(tcx.dcx().create_err(OpaqueHiddenTypeMismatch {
1000            self_ty,
1001            other_ty,
1002            other_span: other.span,
1003            sub: sub_diag,
1004        }))
1005    }
1006}
1007
1008pub type Clauses<'tcx> = &'tcx ListWithCachedTypeInfo<Clause<'tcx>>;
1009
1010impl<'tcx> rustc_type_ir::Flags for Clauses<'tcx> {
1011    fn flags(&self) -> TypeFlags {
1012        (**self).flags()
1013    }
1014
1015    fn outer_exclusive_binder(&self) -> DebruijnIndex {
1016        (**self).outer_exclusive_binder()
1017    }
1018}
1019
1020/// Efficiently builds a [`ParamEnv`], compressing trait clauses as it is being built,
1021/// and interning only once at the end.
1022pub struct ParamenvBuilder<'tcx> {
1023    tcx: TyCtxt<'tcx>,
1024    compressed_clauses: Vec<CompressedTraitClause<TyCtxt<'tcx>>>,
1025    uncompressed_clauses: Vec<Clause<'tcx>>,
1026}
1027
1028impl<'tcx> ParamenvBuilder<'tcx> {
1029    /// Construct a `ClauseCompressor` from an existing [`ParamEnv`] without decompressing its
1030    /// contents. This is useful when adding clauses to an existing environment without
1031    /// decompressing and re-interning compressed clauses.
1032    fn from_param_env(tcx: TyCtxt<'tcx>, param_env: ParamEnv<'tcx>) -> Self {
1033        let mut compressed_clauses = Vec::new();
1034        let mut uncompressed_clauses = Vec::new();
1035
1036        for clause in param_env.caller_bounds {
1037            match clause.kind().skip_binder() {
1038                ty::ClauseKind::CompressedTrait(c) => compressed_clauses.push(c),
1039                _ => uncompressed_clauses.push(clause),
1040            }
1041        }
1042
1043        Self { tcx, compressed_clauses, uncompressed_clauses }
1044    }
1045
1046    fn new(tcx: TyCtxt<'tcx>) -> Self {
1047        Self { tcx, compressed_clauses: Vec::new(), uncompressed_clauses: Vec::new() }
1048    }
1049
1050    pub fn add_clause(&mut self, clause: Clause<'tcx>) {
1051        // Try to construct a common clause, if the given clause is one of the common clauses
1052        let Some(new_compressed_trait_clause) =
1053            CompressedTraitClause::from_clause(self.tcx, clause)
1054        else {
1055            self.uncompressed_clauses.push(clause);
1056            return;
1057        };
1058
1059        // See if this new common clause can be merged into another already existing
1060        // common clause so they can be interned together.
1061        //
1062        // We're *not* using a hashmap here since this list is not expected to grow
1063        // larger than a couple of elements. Just iterating is faster.
1064        if !self
1065            .compressed_clauses
1066            .iter_mut()
1067            // finishes iteration upon first successful `try_merge`.
1068            .any(|existing| existing.try_merge(new_compressed_trait_clause))
1069        {
1070            self.compressed_clauses.push(new_compressed_trait_clause)
1071        }
1072    }
1073
1074    fn mk_clauses(self) -> Clauses<'tcx> {
1075        let mut res =
1076            Vec::with_capacity(self.uncompressed_clauses.len() + self.compressed_clauses.len());
1077
1078        res.extend(self.compressed_clauses.into_iter().map(|compressed| -> Clause<'tcx> {
1079            {
    match (&compressed.compressed_trait_refs.bits(), &0) {
        (left_val, right_val) => {
            if *left_val == *right_val {
                let kind = ::core::panicking::AssertKind::Ne;
                ::core::panicking::assert_failed(kind, &*left_val,
                    &*right_val, ::core::option::Option::None);
            }
        }
    }
};assert_ne!(compressed.compressed_trait_refs.bits(), 0);
1080            // NOTE: in theory, if there's only one bit set, we could opt not to compress,
1081            // since then we also don't need to decompress. The flip side is, that that
1082            // it's often cheaper to ask "does ty impl trait" for a compressed clause than for an
1083            // arbitrary other clause. Especially if we know in advance that the trait for which
1084            // this question is asked is only ever compressed, and we don't have to look through
1085            // other clauses.
1086            ClauseKind::CompressedTrait(compressed).upcast(self.tcx)
1087        }));
1088        res.extend(self.uncompressed_clauses);
1089
1090        self.tcx.mk_clauses(&res)
1091    }
1092
1093    pub fn build(self) -> ParamEnv<'tcx> {
1094        ParamEnv { caller_bounds: self.mk_clauses() }
1095    }
1096}
1097
1098/// When interacting with the type system we must provide information about the
1099/// environment. `ParamEnv` is the type that represents this information. See the
1100/// [dev guide chapter][param_env_guide] for more information.
1101///
1102/// [param_env_guide]: https://rustc-dev-guide.rust-lang.org/typing_parameter_envs.html
1103#[derive(#[automatically_derived]impl<'tcx> ::core::fmt::Debug for ParamEnv<'tcx> {
    #[inline]
    #[rustc_trivial_field_reads]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::debug_struct_field1_finish(f,
            "ParamEnv caller_bounds", &&self.caller_bounds)
    }
}Debug, #[automatically_derived]impl<'tcx> ::core::marker::Copy for ParamEnv<'tcx> { }Copy, #[automatically_derived]#[doc(hidden)]unsafe impl<'tcx>
    ::core::clone::TrivialClone for ParamEnv<'tcx> {
}
#[automatically_derived]impl<'tcx> ::core::clone::Clone for ParamEnv<'tcx> {
    #[inline]
    #[rustc_trivial_field_reads]
    fn clone(&self) -> Self {
        let _: ::core::clone::AssertParamIsClone<Clauses<'tcx>>;
        *self
    }
}Clone, #[automatically_derived]impl<'tcx> ::core::hash::Hash for ParamEnv<'tcx> {
    #[inline]
    fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) {
        ::core::hash::Hash::hash(&self.caller_bounds, state)
    }
}Hash, #[automatically_derived]impl<'tcx> ::core::marker::StructuralPartialEq for
    ParamEnv<'tcx> {
}
#[automatically_derived]impl<'tcx> ::core::cmp::PartialEq for ParamEnv<'tcx> {
    #[inline]
    fn eq(&self, other: &Self) -> bool {
        self.caller_bounds == other.caller_bounds
    }
}PartialEq, #[automatically_derived]impl<'tcx> ::core::cmp::Eq for ParamEnv<'tcx> {
    #[inline]
    #[doc(hidden)]
    #[coverage(off)]
    fn assert_fields_are_eq(&self) {
        let _: ::core::cmp::AssertParamIsEq<Clauses<'tcx>>;
    }
}Eq)]
1104#[derive(const _: () =
    {
        impl<'tcx> ::rustc_data_structures::stable_hash::StableHash for
            ParamEnv<'tcx> {
            #[inline]
            fn stable_hash<__Hcx: ::rustc_data_structures::stable_hash::StableHashCtxt>(&self,
                __hcx: &mut __Hcx,
                __hasher:
                    &mut ::rustc_data_structures::stable_hash::StableHasher) {
                match *self {
                    ParamEnv { caller_bounds: ref __binding_0 } => {
                        { __binding_0.stable_hash(__hcx, __hasher); }
                    }
                }
            }
        }
    };StableHash, const _: () =
    {
        impl<'tcx>
            ::rustc_middle::ty::TypeVisitable<::rustc_middle::ty::TyCtxt<'tcx>>
            for ParamEnv<'tcx> {
            fn visit_with<__V: ::rustc_middle::ty::TypeVisitor<::rustc_middle::ty::TyCtxt<'tcx>>>(&self,
                __visitor: &mut __V) -> __V::Result {
                match *self {
                    ParamEnv { caller_bounds: ref __binding_0 } => {
                        {
                            match ::rustc_middle::ty::VisitorResult::branch(::rustc_middle::ty::TypeVisitable::visit_with(__binding_0,
                                        __visitor)) {
                                ::core::ops::ControlFlow::Continue(()) => {}
                                ::core::ops::ControlFlow::Break(r) => {
                                    return ::rustc_middle::ty::VisitorResult::from_residual(r);
                                }
                            }
                        }
                    }
                }
                <__V::Result as ::rustc_middle::ty::VisitorResult>::output()
            }
        }
    };TypeVisitable, const _: () =
    {
        impl<'tcx>
            ::rustc_middle::ty::TypeFoldable<::rustc_middle::ty::TyCtxt<'tcx>>
            for ParamEnv<'tcx> {
            fn try_fold_with<__F: ::rustc_middle::ty::FallibleTypeFolder<::rustc_middle::ty::TyCtxt<'tcx>>>(self,
                __folder: &mut __F) -> Result<Self, __F::Error> {
                Ok(match self {
                        ParamEnv { caller_bounds: __binding_0 } => {
                            ParamEnv {
                                caller_bounds: ::rustc_middle::ty::TypeFoldable::try_fold_with(__binding_0,
                                        __folder)?,
                            }
                        }
                    })
            }
            fn fold_with<__F: ::rustc_middle::ty::TypeFolder<::rustc_middle::ty::TyCtxt<'tcx>>>(self,
                __folder: &mut __F) -> Self {
                match self {
                    ParamEnv { caller_bounds: __binding_0 } => {
                        ParamEnv {
                            caller_bounds: ::rustc_middle::ty::TypeFoldable::fold_with(__binding_0,
                                __folder),
                        }
                    }
                }
            }
        }
    };TypeFoldable)]
1105pub struct ParamEnv<'tcx> {
1106    /// Caller bounds are `Obligation`s that the caller must satisfy. This is
1107    /// basically the set of bounds on the in-scope type parameters, translated
1108    /// into `Obligation`s, and elaborated and normalized.
1109    ///
1110    /// Use the `caller_bounds()` method to access.
1111    caller_bounds: Clauses<'tcx>,
1112}
1113
1114// Empty ParamEnv's are super common (like, 100x more common than nonempty pnes),
1115// so we want to not carry around too much data in this common case.
1116// Make sure that a ParamEnv is no bigger than a single pointer, always.
1117const _: [(); std::mem::size_of::<usize>()] =
    [(); ::std::mem::size_of::<ParamEnv<'_>>()];static_assert_size!(ParamEnv<'_>, std::mem::size_of::<usize>());
1118
1119impl<'tcx> rustc_type_ir::inherent::ParamEnv<TyCtxt<'tcx>> for ParamEnv<'tcx> {
1120    #[inline]
1121    fn caller_bounds(
1122        self,
1123    ) -> CallerBoundsAccessor<TyCtxt<'tcx>, impl Iterator<Item = ty::Clause<'tcx>>, NoClauses> {
1124        self.caller_bounds()
1125    }
1126}
1127
1128impl<'tcx> ParamEnv<'tcx> {
1129    /// Construct a trait environment suitable for contexts where there are
1130    /// no where-clauses in scope. In the majority of cases it is incorrect
1131    /// to use an empty environment. See the [dev guide section][param_env_guide]
1132    /// for information on what a `ParamEnv` is and how to acquire one.
1133    ///
1134    /// [param_env_guide]: https://rustc-dev-guide.rust-lang.org/typing_parameter_envs.html
1135    #[inline]
1136    pub fn empty() -> Self {
1137        Self { caller_bounds: ListWithCachedTypeInfo::empty() }
1138    }
1139
1140    #[inline]
1141    pub fn builder(tcx: TyCtxt<'tcx>) -> ParamenvBuilder<'tcx> {
1142        ParamenvBuilder::new(tcx)
1143    }
1144
1145    /// Turn an existing `ParamEnv` into a builder to add bounds to it efficiently.
1146    ///
1147    /// There's also [`extend`](Self::extend) for a single addition.
1148    #[inline]
1149    pub fn into_builder(self, tcx: TyCtxt<'tcx>) -> ParamenvBuilder<'tcx> {
1150        ParamenvBuilder::from_param_env(tcx, self)
1151    }
1152
1153    /// Add clauses to an existing `ParamEnv`, without decompressing existing trait bounds.
1154    /// Note: it's more efficient to use [`ParamEnv::builder`](Self::builder) if you want to
1155    /// add bounds more than once.
1156    #[inline]
1157    pub fn extend(
1158        self,
1159        tcx: TyCtxt<'tcx>,
1160        new_bounds: impl IntoIterator<Item = ty::Clause<'tcx>>,
1161    ) -> Self {
1162        let mut builder = self.into_builder(tcx);
1163        for clause in new_bounds {
1164            builder.add_clause(clause);
1165        }
1166
1167        builder.build()
1168    }
1169
1170    /// Get a [`CallerBoundsAccessor`], which allows customizing the desired bounds
1171    /// from the `ParamEnv` and iterating over *just* those.
1172    #[inline]
1173    pub fn caller_bounds(
1174        self,
1175    ) -> CallerBoundsAccessor<TyCtxt<'tcx>, impl Iterator<Item = ty::Clause<'tcx>>, NoClauses> {
1176        CallerBoundsAccessor::new(self.caller_bounds.iter())
1177    }
1178
1179    #[inline]
1180    pub fn is_empty(self) -> bool {
1181        self.caller_bounds.as_slice().is_empty()
1182    }
1183
1184    /// Construct a trait environment with the given set of predicates.
1185    #[inline]
1186    pub fn new(
1187        tcx: TyCtxt<'tcx>,
1188        caller_bounds: impl IntoIterator<Item = ty::Clause<'tcx>>,
1189    ) -> Self {
1190        let mut builder = Self::builder(tcx);
1191        for clause in caller_bounds {
1192            builder.add_clause(clause);
1193        }
1194
1195        builder.build()
1196    }
1197
1198    /// Creates a pair of param-env and value for use in queries.
1199    pub fn and<T: TypeVisitable<TyCtxt<'tcx>>>(self, value: T) -> ParamEnvAnd<'tcx, T> {
1200        ParamEnvAnd { param_env: self, value }
1201    }
1202
1203    /// Eagerly reveal all opaque types in the `param_env`.
1204    pub fn with_normalized(self, tcx: TyCtxt<'tcx>) -> ParamEnv<'tcx> {
1205        // No need to reveal opaques with the new solver enabled,
1206        // since we have lazy norm.
1207        if tcx.next_trait_solver_globally() {
1208            self
1209        } else {
1210            tcx.reveal_opaque_types_in_bounds(self)
1211        }
1212    }
1213}
1214
1215#[derive(#[automatically_derived]impl<'tcx, T: ::core::marker::Copy>
    ::core::marker::Copy for ParamEnvAnd<'tcx, T> {
}Copy, #[automatically_derived]impl<'tcx, T: ::core::clone::Clone>
    ::core::clone::Clone for ParamEnvAnd<'tcx, T> {
    #[inline]
    #[rustc_trivial_field_reads]
    fn clone(&self) -> Self {
        ParamEnvAnd {
            param_env: ::core::clone::Clone::clone(&self.param_env),
            value: ::core::clone::Clone::clone(&self.value),
        }
    }
}Clone, #[automatically_derived]impl<'tcx, T: ::core::fmt::Debug> ::core::fmt::Debug
    for ParamEnvAnd<'tcx, T> {
    #[inline]
    #[rustc_trivial_field_reads]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::debug_struct_field2_finish(f,
            "ParamEnvAnd param_env value", &self.param_env, &&self.value)
    }
}Debug, #[automatically_derived]impl<'tcx, T: ::core::cmp::PartialEq>
    ::core::marker::StructuralPartialEq for ParamEnvAnd<'tcx, T> {
}
#[automatically_derived]impl<'tcx, T: ::core::cmp::PartialEq>
    ::core::cmp::PartialEq for ParamEnvAnd<'tcx, T> {
    #[inline]
    fn eq(&self, other: &Self) -> bool {
        self.param_env == other.param_env && self.value == other.value
    }
}PartialEq, #[automatically_derived]impl<'tcx, T: ::core::cmp::Eq> ::core::cmp::Eq for
    ParamEnvAnd<'tcx, T> {
    #[inline]
    #[doc(hidden)]
    #[coverage(off)]
    fn assert_fields_are_eq(&self) {
        let _: ::core::cmp::AssertParamIsEq<ParamEnv<'tcx>>;
        let _: ::core::cmp::AssertParamIsEq<T>;
    }
}Eq, #[automatically_derived]impl<'tcx, T: ::core::hash::Hash> ::core::hash::Hash
    for ParamEnvAnd<'tcx, T> {
    #[inline]
    fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) {
        ::core::hash::Hash::hash(&self.param_env, state);
        ::core::hash::Hash::hash(&self.value, state)
    }
}Hash, const _: () =
    {
        impl<'tcx, T>
            ::rustc_middle::ty::TypeFoldable<::rustc_middle::ty::TyCtxt<'tcx>>
            for ParamEnvAnd<'tcx, T> where
            T: ::rustc_middle::ty::TypeFoldable<::rustc_middle::ty::TyCtxt<'tcx>>
            {
            fn try_fold_with<__F: ::rustc_middle::ty::FallibleTypeFolder<::rustc_middle::ty::TyCtxt<'tcx>>>(self,
                __folder: &mut __F) -> Result<Self, __F::Error> {
                Ok(match self {
                        ParamEnvAnd { param_env: __binding_0, value: __binding_1 }
                            => {
                            ParamEnvAnd {
                                param_env: ::rustc_middle::ty::TypeFoldable::try_fold_with(__binding_0,
                                        __folder)?,
                                value: ::rustc_middle::ty::TypeFoldable::try_fold_with(__binding_1,
                                        __folder)?,
                            }
                        }
                    })
            }
            fn fold_with<__F: ::rustc_middle::ty::TypeFolder<::rustc_middle::ty::TyCtxt<'tcx>>>(self,
                __folder: &mut __F) -> Self {
                match self {
                    ParamEnvAnd { param_env: __binding_0, value: __binding_1 }
                        => {
                        ParamEnvAnd {
                            param_env: ::rustc_middle::ty::TypeFoldable::fold_with(__binding_0,
                                __folder),
                            value: ::rustc_middle::ty::TypeFoldable::fold_with(__binding_1,
                                __folder),
                        }
                    }
                }
            }
        }
    };TypeFoldable, const _: () =
    {
        impl<'tcx, T>
            ::rustc_middle::ty::TypeVisitable<::rustc_middle::ty::TyCtxt<'tcx>>
            for ParamEnvAnd<'tcx, T> where
            T: ::rustc_middle::ty::TypeVisitable<::rustc_middle::ty::TyCtxt<'tcx>>
            {
            fn visit_with<__V: ::rustc_middle::ty::TypeVisitor<::rustc_middle::ty::TyCtxt<'tcx>>>(&self,
                __visitor: &mut __V) -> __V::Result {
                match *self {
                    ParamEnvAnd {
                        param_env: ref __binding_0, value: ref __binding_1 } => {
                        {
                            match ::rustc_middle::ty::VisitorResult::branch(::rustc_middle::ty::TypeVisitable::visit_with(__binding_0,
                                        __visitor)) {
                                ::core::ops::ControlFlow::Continue(()) => {}
                                ::core::ops::ControlFlow::Break(r) => {
                                    return ::rustc_middle::ty::VisitorResult::from_residual(r);
                                }
                            }
                        }
                        {
                            match ::rustc_middle::ty::VisitorResult::branch(::rustc_middle::ty::TypeVisitable::visit_with(__binding_1,
                                        __visitor)) {
                                ::core::ops::ControlFlow::Continue(()) => {}
                                ::core::ops::ControlFlow::Break(r) => {
                                    return ::rustc_middle::ty::VisitorResult::from_residual(r);
                                }
                            }
                        }
                    }
                }
                <__V::Result as ::rustc_middle::ty::VisitorResult>::output()
            }
        }
    };TypeVisitable)]
1216#[derive(const _: () =
    {
        impl<'tcx, T> ::rustc_data_structures::stable_hash::StableHash for
            ParamEnvAnd<'tcx, T> where
            T: ::rustc_data_structures::stable_hash::StableHash {
            #[inline]
            fn stable_hash<__Hcx: ::rustc_data_structures::stable_hash::StableHashCtxt>(&self,
                __hcx: &mut __Hcx,
                __hasher:
                    &mut ::rustc_data_structures::stable_hash::StableHasher) {
                match *self {
                    ParamEnvAnd {
                        param_env: ref __binding_0, value: ref __binding_1 } => {
                        { __binding_0.stable_hash(__hcx, __hasher); }
                        { __binding_1.stable_hash(__hcx, __hasher); }
                    }
                }
            }
        }
    };StableHash)]
1217pub struct ParamEnvAnd<'tcx, T> {
1218    pub param_env: ParamEnv<'tcx>,
1219    pub value: T,
1220}
1221
1222/// The environment in which to do trait solving.
1223///
1224/// Most of the time you only need to care about the `ParamEnv`
1225/// as the `TypingMode` is simply stored in the `InferCtxt`.
1226///
1227/// However, there are some places which rely on trait solving
1228/// without using an `InferCtxt` themselves. For these to be
1229/// able to use the trait system they have to be able to initialize
1230/// such an `InferCtxt` with the right `typing_mode`, so they need
1231/// to track both.
1232#[derive(#[automatically_derived]impl<'tcx> ::core::marker::Copy for TypingEnv<'tcx> {
}Copy, #[automatically_derived]#[doc(hidden)]unsafe impl<'tcx>
    ::core::clone::TrivialClone for TypingEnv<'tcx> {
}
#[automatically_derived]impl<'tcx> ::core::clone::Clone for TypingEnv<'tcx> {
    #[inline]
    #[rustc_trivial_field_reads]
    fn clone(&self) -> Self {
        let _: ::core::clone::AssertParamIsClone<TypingModeEqWrapper<'tcx>>;
        let _: ::core::clone::AssertParamIsClone<ParamEnv<'tcx>>;
        *self
    }
}Clone, #[automatically_derived]impl<'tcx> ::core::fmt::Debug for TypingEnv<'tcx> {
    #[inline]
    #[rustc_trivial_field_reads]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::debug_struct_field2_finish(f,
            "TypingEnv typing_mode param_env", &self.typing_mode,
            &&self.param_env)
    }
}Debug, #[automatically_derived]impl<'tcx> ::core::marker::StructuralPartialEq for
    TypingEnv<'tcx> {
}
#[automatically_derived]impl<'tcx> ::core::cmp::PartialEq for TypingEnv<'tcx>
    {
    #[inline]
    fn eq(&self, other: &Self) -> bool {
        self.typing_mode == other.typing_mode &&
            self.param_env == other.param_env
    }
}PartialEq, #[automatically_derived]impl<'tcx> ::core::cmp::Eq for TypingEnv<'tcx> {
    #[inline]
    #[doc(hidden)]
    #[coverage(off)]
    fn assert_fields_are_eq(&self) {
        let _: ::core::cmp::AssertParamIsEq<TypingModeEqWrapper<'tcx>>;
        let _: ::core::cmp::AssertParamIsEq<ParamEnv<'tcx>>;
    }
}Eq, #[automatically_derived]impl<'tcx> ::core::hash::Hash for TypingEnv<'tcx> {
    #[inline]
    fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) {
        ::core::hash::Hash::hash(&self.typing_mode, state);
        ::core::hash::Hash::hash(&self.param_env, state)
    }
}Hash, const _: () =
    {
        impl<'tcx> ::rustc_data_structures::stable_hash::StableHash for
            TypingEnv<'tcx> {
            #[inline]
            fn stable_hash<__Hcx: ::rustc_data_structures::stable_hash::StableHashCtxt>(&self,
                __hcx: &mut __Hcx,
                __hasher:
                    &mut ::rustc_data_structures::stable_hash::StableHasher) {
                match *self {
                    TypingEnv {
                        typing_mode: ref __binding_0, param_env: ref __binding_1 }
                        => {
                        { __binding_0.stable_hash(__hcx, __hasher); }
                        { __binding_1.stable_hash(__hcx, __hasher); }
                    }
                }
            }
        }
    };StableHash)]
1233#[derive(const _: () =
    {
        impl<'tcx>
            ::rustc_middle::ty::TypeVisitable<::rustc_middle::ty::TyCtxt<'tcx>>
            for TypingEnv<'tcx> {
            fn visit_with<__V: ::rustc_middle::ty::TypeVisitor<::rustc_middle::ty::TyCtxt<'tcx>>>(&self,
                __visitor: &mut __V) -> __V::Result {
                match *self {
                    TypingEnv { param_env: ref __binding_1, .. } => {
                        {
                            match ::rustc_middle::ty::VisitorResult::branch(::rustc_middle::ty::TypeVisitable::visit_with(__binding_1,
                                        __visitor)) {
                                ::core::ops::ControlFlow::Continue(()) => {}
                                ::core::ops::ControlFlow::Break(r) => {
                                    return ::rustc_middle::ty::VisitorResult::from_residual(r);
                                }
                            }
                        }
                    }
                }
                <__V::Result as ::rustc_middle::ty::VisitorResult>::output()
            }
        }
    };TypeVisitable, const _: () =
    {
        impl<'tcx>
            ::rustc_middle::ty::TypeFoldable<::rustc_middle::ty::TyCtxt<'tcx>>
            for TypingEnv<'tcx> {
            fn try_fold_with<__F: ::rustc_middle::ty::FallibleTypeFolder<::rustc_middle::ty::TyCtxt<'tcx>>>(self,
                __folder: &mut __F) -> Result<Self, __F::Error> {
                Ok(match self {
                        TypingEnv { typing_mode: __binding_0, param_env: __binding_1
                            } => {
                            TypingEnv {
                                typing_mode: __binding_0,
                                param_env: ::rustc_middle::ty::TypeFoldable::try_fold_with(__binding_1,
                                        __folder)?,
                            }
                        }
                    })
            }
            fn fold_with<__F: ::rustc_middle::ty::TypeFolder<::rustc_middle::ty::TyCtxt<'tcx>>>(self,
                __folder: &mut __F) -> Self {
                match self {
                    TypingEnv { typing_mode: __binding_0, param_env: __binding_1
                        } => {
                        TypingEnv {
                            typing_mode: __binding_0,
                            param_env: ::rustc_middle::ty::TypeFoldable::fold_with(__binding_1,
                                __folder),
                        }
                    }
                }
            }
        }
    };TypeFoldable)]
1234pub struct TypingEnv<'tcx> {
1235    #[type_foldable(identity)]
1236    #[type_visitable(ignore)]
1237    typing_mode: TypingModeEqWrapper<'tcx>,
1238    pub param_env: ParamEnv<'tcx>,
1239}
1240
1241impl<'tcx> rustc_type_ir::inherent::TypingEnv<TyCtxt<'tcx>> for TypingEnv<'tcx> {
1242    fn fully_monomorphized() -> Self {
1243        Self::fully_monomorphized()
1244    }
1245
1246    fn layout_size(self, tcx: TyCtxt<'tcx>, ty: Ty<'tcx>) -> Size {
1247        tcx.layout_of(self.as_query_input(ty))
1248            .unwrap_or_else(|e| {
    ::core::panicking::panic_fmt(format_args!("could not compute layout for {0:?}: {1:?}",
            ty, e));
}panic!("could not compute layout for {ty:?}: {e:?}"))
1249            .size
1250    }
1251
1252    fn post_analysis_no_rigid_aliases(tcx: TyCtxt<'tcx>, def_id: DefId) -> TypingEnv<'tcx> {
1253        Self::post_analysis_no_rigid_aliases(tcx, def_id)
1254    }
1255}
1256
1257impl<'tcx> TypingEnv<'tcx> {
1258    pub fn new(param_env: ParamEnv<'tcx>, typing_mode: TypingMode<'tcx>) -> Self {
1259        Self { typing_mode: TypingModeEqWrapper(typing_mode), param_env }
1260    }
1261
1262    pub fn typing_mode(&self) -> TypingMode<'tcx> {
1263        self.typing_mode.0
1264    }
1265
1266    /// Create a typing environment with no where-clauses in scope
1267    /// where all opaque types and default associated items are revealed.
1268    ///
1269    /// This is only suitable for monomorphized, post-typeck environments.
1270    /// Do not use this for MIR optimizations, as even though they also
1271    /// use `TypingMode::PostAnalysis`, they may still have where-clauses
1272    /// in scope.
1273    pub fn fully_monomorphized() -> TypingEnv<'tcx> {
1274        Self::new(ParamEnv::empty(), TypingMode::Codegen)
1275    }
1276
1277    /// Create a typing environment for use during analysis outside of a body.
1278    ///
1279    /// Using a typing environment inside of bodies is not supported as the body
1280    /// may define opaque types. In this case the used functions have to be
1281    /// converted to use proper canonical inputs instead.
1282    pub fn non_body_analysis(
1283        tcx: TyCtxt<'tcx>,
1284        def_id: impl IntoQueryKey<DefId>,
1285    ) -> TypingEnv<'tcx> {
1286        let def_id = def_id.into_query_key();
1287        Self::new(tcx.param_env(def_id), TypingMode::non_body_analysis())
1288    }
1289
1290    /// The `TypingEnv` which should be for everything happens after HIR typeck
1291    /// up-to and including borrowck itself.
1292    pub fn post_typeck_through_borrowck(tcx: TyCtxt<'tcx>, def_id: LocalDefId) -> TypingEnv<'tcx> {
1293        let param_env = tcx.param_env(def_id.to_def_id());
1294        TypingEnv::new(param_env, ty::TypingMode::borrowck(tcx, def_id))
1295    }
1296
1297    /// Ideally we just use `TypingMode::post_typeck_through_borrowck`.
1298    /// But that's not compatible with the old solver yet.
1299    ///
1300    /// FIXME: this should not be needed in the long term.
1301    pub fn post_typeck_through_borrowck_for_mir_build(
1302        tcx: TyCtxt<'tcx>,
1303        def_id: LocalDefId,
1304    ) -> TypingEnv<'tcx> {
1305        if tcx.use_typing_mode_post_typeck_through_borrowck() {
1306            TypingEnv::new(tcx.param_env(def_id.to_def_id()), ty::TypingMode::borrowck(tcx, def_id))
1307        } else {
1308            // FIXME(#132279): We're in a body, we should use a typing
1309            // mode which reveals the opaque types defined by that body.
1310            TypingEnv::non_body_analysis(tcx, def_id)
1311        }
1312    }
1313
1314    /// Use this when you don't have types/consts from an earlier typing env.
1315    /// See [`Self::with_post_analysis_normalized_invalidating_rigid_aliases`].
1316    pub fn post_analysis_no_rigid_aliases(
1317        tcx: TyCtxt<'tcx>,
1318        def_id: impl IntoQueryKey<DefId>,
1319    ) -> TypingEnv<'tcx> {
1320        TypingEnv::new(tcx.param_env_normalized_for_post_analysis(def_id), TypingMode::PostAnalysis)
1321    }
1322
1323    /// Use this when you have types/consts from an earlier typing env.
1324    /// See [`Self::with_post_analysis_normalized_invalidating_rigid_aliases`].
1325    pub fn post_analysis_invalidating_rigid_aliases<T>(
1326        tcx: TyCtxt<'tcx>,
1327        def_id: impl IntoQueryKey<DefId>,
1328        value: T,
1329    ) -> PseudoCanonicalInput<'tcx, Unnormalized<'tcx, T>>
1330    where
1331        T: TypeFoldable<TyCtxt<'tcx>>,
1332    {
1333        let typing_env = TypingEnv::post_analysis_no_rigid_aliases(tcx, def_id);
1334        typing_env.as_query_input(ty::set_aliases_to_non_rigid(tcx, value))
1335    }
1336
1337    pub fn codegen(tcx: TyCtxt<'tcx>, def_id: impl IntoQueryKey<DefId>) -> TypingEnv<'tcx> {
1338        TypingEnv::new(tcx.param_env_normalized_for_post_analysis(def_id), TypingMode::Codegen)
1339    }
1340
1341    /// Modify the `typing_mode` to `PostAnalysis` or `Codegen` and eagerly reveal all opaque types
1342    /// in the `param_env`.
1343    ///
1344    /// Changing the typing_mode to `PostAnalysis` can result in aliases now being normalizeable,
1345    /// so we need to explicitly renormalize them. This mainly affects opaque types which were
1346    /// previously treated as rigid but can now be normalized to their underlying type, as well as
1347    /// aliases with opaque args.
1348    /// Values that contain types/consts from the previous typing env and that will be used in the
1349    /// new `PostAnalysis` typing env should be folded by this method to allow renormalization.
1350    ///
1351    /// FIXME: we might want to return `Unnormalized` since we force the value to be non-rigid.
1352    pub fn with_post_analysis_normalized_invalidating_rigid_aliases<T>(
1353        self,
1354        tcx: TyCtxt<'tcx>,
1355        value: T,
1356    ) -> PseudoCanonicalInput<'tcx, T>
1357    where
1358        T: TypeFoldable<TyCtxt<'tcx>>,
1359    {
1360        let TypingEnv { typing_mode, param_env } = self;
1361        match typing_mode.0.assert_not_erased() {
1362            TypingMode::Coherence
1363            | TypingMode::Reflection
1364            | TypingMode::Typeck { .. }
1365            | TypingMode::PostTypeckThroughBorrowck { .. }
1366            | TypingMode::PostBorrowck { .. } => {}
1367            TypingMode::PostAnalysis | TypingMode::Codegen => return self.as_query_input(value),
1368        }
1369
1370        let param_env = param_env.with_normalized(tcx);
1371        let value = ty::set_aliases_to_non_rigid(tcx, value).skip_norm_wip();
1372        TypingEnv::new(param_env, TypingMode::PostAnalysis).as_query_input(value)
1373    }
1374
1375    /// Same as `with_post_analysis_normalized_invalidating_rigid_aliases` except that we use
1376    /// the `Codegen` typing mode.
1377    pub fn with_codegen_normalized_invalidating_rigid_aliases<T>(
1378        self,
1379        tcx: TyCtxt<'tcx>,
1380        value: T,
1381    ) -> PseudoCanonicalInput<'tcx, T>
1382    where
1383        T: TypeFoldable<TyCtxt<'tcx>>,
1384    {
1385        let TypingEnv { typing_mode, param_env } = self;
1386        match typing_mode.0.assert_not_erased() {
1387            TypingMode::Coherence
1388            | TypingMode::Reflection
1389            | TypingMode::Typeck { .. }
1390            | TypingMode::PostTypeckThroughBorrowck { .. }
1391            | TypingMode::PostBorrowck { .. }
1392            | TypingMode::PostAnalysis => {}
1393            TypingMode::Codegen => return self.as_query_input(value),
1394        }
1395
1396        let param_env = param_env.with_normalized(tcx);
1397        let value = ty::set_aliases_to_non_rigid(tcx, value).skip_norm_wip();
1398        TypingEnv::new(param_env, TypingMode::Codegen).as_query_input(value)
1399    }
1400
1401    /// Combine this typing environment with the given `value` to be used by
1402    /// not (yet) canonicalized queries. This only works if the value does not
1403    /// contain anything local to some `InferCtxt`, i.e. inference variables or
1404    /// placeholders.
1405    pub fn as_query_input<T>(self, value: T) -> PseudoCanonicalInput<'tcx, T>
1406    where
1407        T: TypeVisitable<TyCtxt<'tcx>>,
1408    {
1409        // FIXME(#132279): We should assert that the value does not contain any placeholders
1410        // as these placeholders are also local to the current inference context. However, we
1411        // currently use pseudo-canonical queries in the trait solver, which replaces params
1412        // with placeholders during canonicalization. We should also simply not use pseudo-
1413        // canonical queries in the trait solver, at which point we can readd this assert.
1414        //
1415        // As of writing this comment, this is only used when normalizing consts that mention
1416        // params.
1417        /* debug_assert!(
1418            !value.has_placeholders(),
1419            "{value:?} which has placeholder shouldn't be pseudo-canonicalized"
1420        ); */
1421        PseudoCanonicalInput { typing_env: self, value }
1422    }
1423}
1424
1425/// Similar to `CanonicalInput`, this carries the `typing_mode` and the environment
1426/// necessary to do any kind of trait solving inside of nested queries.
1427///
1428/// Unlike proper canonicalization, this requires the `param_env` and the `value` to not
1429/// contain anything local to the `infcx` of the caller, so we don't actually canonicalize
1430/// anything.
1431///
1432/// This should be created by using `infcx.pseudo_canonicalize_query(param_env, value)`
1433/// or by using `typing_env.as_query_input(value)`.
1434#[derive(#[automatically_derived]impl<'tcx, T: ::core::marker::Copy>
    ::core::marker::Copy for PseudoCanonicalInput<'tcx, T> {
}Copy, #[automatically_derived]impl<'tcx, T: ::core::clone::Clone>
    ::core::clone::Clone for PseudoCanonicalInput<'tcx, T> {
    #[inline]
    #[rustc_trivial_field_reads]
    fn clone(&self) -> Self {
        PseudoCanonicalInput {
            typing_env: ::core::clone::Clone::clone(&self.typing_env),
            value: ::core::clone::Clone::clone(&self.value),
        }
    }
}Clone, #[automatically_derived]impl<'tcx, T: ::core::fmt::Debug> ::core::fmt::Debug
    for PseudoCanonicalInput<'tcx, T> {
    #[inline]
    #[rustc_trivial_field_reads]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::debug_struct_field2_finish(f,
            "PseudoCanonicalInput typing_env value", &self.typing_env,
            &&self.value)
    }
}Debug, #[automatically_derived]impl<'tcx, T: ::core::cmp::PartialEq>
    ::core::marker::StructuralPartialEq for PseudoCanonicalInput<'tcx, T> {
}
#[automatically_derived]impl<'tcx, T: ::core::cmp::PartialEq>
    ::core::cmp::PartialEq for PseudoCanonicalInput<'tcx, T> {
    #[inline]
    fn eq(&self, other: &Self) -> bool {
        self.typing_env == other.typing_env && self.value == other.value
    }
}PartialEq, #[automatically_derived]impl<'tcx, T: ::core::cmp::Eq> ::core::cmp::Eq for
    PseudoCanonicalInput<'tcx, T> {
    #[inline]
    #[doc(hidden)]
    #[coverage(off)]
    fn assert_fields_are_eq(&self) {
        let _: ::core::cmp::AssertParamIsEq<TypingEnv<'tcx>>;
        let _: ::core::cmp::AssertParamIsEq<T>;
    }
}Eq, #[automatically_derived]impl<'tcx, T: ::core::hash::Hash> ::core::hash::Hash
    for PseudoCanonicalInput<'tcx, T> {
    #[inline]
    fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) {
        ::core::hash::Hash::hash(&self.typing_env, state);
        ::core::hash::Hash::hash(&self.value, state)
    }
}Hash)]
1435#[derive(const _: () =
    {
        impl<'tcx, T> ::rustc_data_structures::stable_hash::StableHash for
            PseudoCanonicalInput<'tcx, T> where
            T: ::rustc_data_structures::stable_hash::StableHash {
            #[inline]
            fn stable_hash<__Hcx: ::rustc_data_structures::stable_hash::StableHashCtxt>(&self,
                __hcx: &mut __Hcx,
                __hasher:
                    &mut ::rustc_data_structures::stable_hash::StableHasher) {
                match *self {
                    PseudoCanonicalInput {
                        typing_env: ref __binding_0, value: ref __binding_1 } => {
                        { __binding_0.stable_hash(__hcx, __hasher); }
                        { __binding_1.stable_hash(__hcx, __hasher); }
                    }
                }
            }
        }
    };StableHash, const _: () =
    {
        impl<'tcx, T>
            ::rustc_middle::ty::TypeVisitable<::rustc_middle::ty::TyCtxt<'tcx>>
            for PseudoCanonicalInput<'tcx, T> where
            T: ::rustc_middle::ty::TypeVisitable<::rustc_middle::ty::TyCtxt<'tcx>>
            {
            fn visit_with<__V: ::rustc_middle::ty::TypeVisitor<::rustc_middle::ty::TyCtxt<'tcx>>>(&self,
                __visitor: &mut __V) -> __V::Result {
                match *self {
                    PseudoCanonicalInput {
                        typing_env: ref __binding_0, value: ref __binding_1 } => {
                        {
                            match ::rustc_middle::ty::VisitorResult::branch(::rustc_middle::ty::TypeVisitable::visit_with(__binding_0,
                                        __visitor)) {
                                ::core::ops::ControlFlow::Continue(()) => {}
                                ::core::ops::ControlFlow::Break(r) => {
                                    return ::rustc_middle::ty::VisitorResult::from_residual(r);
                                }
                            }
                        }
                        {
                            match ::rustc_middle::ty::VisitorResult::branch(::rustc_middle::ty::TypeVisitable::visit_with(__binding_1,
                                        __visitor)) {
                                ::core::ops::ControlFlow::Continue(()) => {}
                                ::core::ops::ControlFlow::Break(r) => {
                                    return ::rustc_middle::ty::VisitorResult::from_residual(r);
                                }
                            }
                        }
                    }
                }
                <__V::Result as ::rustc_middle::ty::VisitorResult>::output()
            }
        }
    };TypeVisitable, const _: () =
    {
        impl<'tcx, T>
            ::rustc_middle::ty::TypeFoldable<::rustc_middle::ty::TyCtxt<'tcx>>
            for PseudoCanonicalInput<'tcx, T> where
            T: ::rustc_middle::ty::TypeFoldable<::rustc_middle::ty::TyCtxt<'tcx>>
            {
            fn try_fold_with<__F: ::rustc_middle::ty::FallibleTypeFolder<::rustc_middle::ty::TyCtxt<'tcx>>>(self,
                __folder: &mut __F) -> Result<Self, __F::Error> {
                Ok(match self {
                        PseudoCanonicalInput {
                            typing_env: __binding_0, value: __binding_1 } => {
                            PseudoCanonicalInput {
                                typing_env: ::rustc_middle::ty::TypeFoldable::try_fold_with(__binding_0,
                                        __folder)?,
                                value: ::rustc_middle::ty::TypeFoldable::try_fold_with(__binding_1,
                                        __folder)?,
                            }
                        }
                    })
            }
            fn fold_with<__F: ::rustc_middle::ty::TypeFolder<::rustc_middle::ty::TyCtxt<'tcx>>>(self,
                __folder: &mut __F) -> Self {
                match self {
                    PseudoCanonicalInput {
                        typing_env: __binding_0, value: __binding_1 } => {
                        PseudoCanonicalInput {
                            typing_env: ::rustc_middle::ty::TypeFoldable::fold_with(__binding_0,
                                __folder),
                            value: ::rustc_middle::ty::TypeFoldable::fold_with(__binding_1,
                                __folder),
                        }
                    }
                }
            }
        }
    };TypeFoldable)]
1436pub struct PseudoCanonicalInput<'tcx, T> {
1437    pub typing_env: TypingEnv<'tcx>,
1438    pub value: T,
1439}
1440
1441#[derive(#[automatically_derived]impl ::core::marker::Copy for Destructor { }Copy, #[automatically_derived]#[doc(hidden)]unsafe impl ::core::clone::TrivialClone
    for Destructor {
}
#[automatically_derived]impl ::core::clone::Clone for Destructor {
    #[inline]
    #[rustc_trivial_field_reads]
    fn clone(&self) -> Self {
        let _: ::core::clone::AssertParamIsClone<DefId>;
        *self
    }
}Clone, #[automatically_derived]impl ::core::fmt::Debug for Destructor {
    #[inline]
    #[rustc_trivial_field_reads]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::debug_struct_field1_finish(f,
            "Destructor did", &&self.did)
    }
}Debug, const _: () =
    {
        impl ::rustc_data_structures::stable_hash::StableHash for Destructor {
            #[inline]
            fn stable_hash<__Hcx: ::rustc_data_structures::stable_hash::StableHashCtxt>(&self,
                __hcx: &mut __Hcx,
                __hasher:
                    &mut ::rustc_data_structures::stable_hash::StableHasher) {
                match *self {
                    Destructor { did: ref __binding_0 } => {
                        { __binding_0.stable_hash(__hcx, __hasher); }
                    }
                }
            }
        }
    };StableHash, const _: () =
    {
        impl<__E: ::rustc_span::SpanEncoder> ::rustc_serialize::Encodable<__E>
            for Destructor {
            fn encode(&self, __encoder: &mut __E) {
                let Destructor { did: ref __binding_0 } = *self;
                ::rustc_serialize::Encodable::<__E>::encode(__binding_0,
                    __encoder);
            }
        }
    };Encodable, const _: () =
    {
        impl<__D: ::rustc_span::SpanDecoder> ::rustc_serialize::Decodable<__D>
            for Destructor {
            fn decode(__decoder: &mut __D) -> Self {
                Destructor {
                    did: ::rustc_serialize::Decodable::decode(__decoder),
                }
            }
        }
    };Decodable)]
1442pub struct Destructor {
1443    /// The `DefId` of the destructor method
1444    pub did: DefId,
1445}
1446
1447// FIXME: consider combining this definition with regular `Destructor`
1448#[derive(#[automatically_derived]impl ::core::marker::Copy for AsyncDestructor { }Copy, #[automatically_derived]#[doc(hidden)]unsafe impl ::core::clone::TrivialClone
    for AsyncDestructor {
}
#[automatically_derived]impl ::core::clone::Clone for AsyncDestructor {
    #[inline]
    #[rustc_trivial_field_reads]
    fn clone(&self) -> Self {
        let _: ::core::clone::AssertParamIsClone<DefId>;
        *self
    }
}Clone, #[automatically_derived]impl ::core::fmt::Debug for AsyncDestructor {
    #[inline]
    #[rustc_trivial_field_reads]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::debug_struct_field1_finish(f,
            "AsyncDestructor impl_did", &&self.impl_did)
    }
}Debug, const _: () =
    {
        impl ::rustc_data_structures::stable_hash::StableHash for
            AsyncDestructor {
            #[inline]
            fn stable_hash<__Hcx: ::rustc_data_structures::stable_hash::StableHashCtxt>(&self,
                __hcx: &mut __Hcx,
                __hasher:
                    &mut ::rustc_data_structures::stable_hash::StableHasher) {
                match *self {
                    AsyncDestructor { impl_did: ref __binding_0 } => {
                        { __binding_0.stable_hash(__hcx, __hasher); }
                    }
                }
            }
        }
    };StableHash, const _: () =
    {
        impl<__E: ::rustc_span::SpanEncoder> ::rustc_serialize::Encodable<__E>
            for AsyncDestructor {
            fn encode(&self, __encoder: &mut __E) {
                let AsyncDestructor { impl_did: ref __binding_0 } = *self;
                ::rustc_serialize::Encodable::<__E>::encode(__binding_0,
                    __encoder);
            }
        }
    };Encodable, const _: () =
    {
        impl<__D: ::rustc_span::SpanDecoder> ::rustc_serialize::Decodable<__D>
            for AsyncDestructor {
            fn decode(__decoder: &mut __D) -> Self {
                AsyncDestructor {
                    impl_did: ::rustc_serialize::Decodable::decode(__decoder),
                }
            }
        }
    };Decodable)]
1449pub struct AsyncDestructor {
1450    /// The `DefId` of the `impl AsyncDrop`
1451    pub impl_did: DefId,
1452}
1453
1454#[derive(#[automatically_derived]#[doc(hidden)]unsafe impl ::core::clone::TrivialClone
    for VariantFlags {
}
#[automatically_derived]impl ::core::clone::Clone for VariantFlags {
    #[inline]
    #[rustc_trivial_field_reads]
    fn clone(&self) -> Self {
        let _: ::core::clone::AssertParamIsClone<u8>;
        *self
    }
}Clone, #[automatically_derived]impl ::core::marker::Copy for VariantFlags { }Copy, #[automatically_derived]impl ::core::marker::StructuralPartialEq for
    VariantFlags {
}
#[automatically_derived]impl ::core::cmp::PartialEq for VariantFlags {
    #[inline]
    fn eq(&self, other: &Self) -> bool { self.0 == other.0 }
}PartialEq, #[automatically_derived]impl ::core::cmp::Eq for VariantFlags {
    #[inline]
    #[doc(hidden)]
    #[coverage(off)]
    fn assert_fields_are_eq(&self) {
        let _: ::core::cmp::AssertParamIsEq<u8>;
    }
}Eq, const _: () =
    {
        impl ::rustc_data_structures::stable_hash::StableHash for VariantFlags
            {
            #[inline]
            fn stable_hash<__Hcx: ::rustc_data_structures::stable_hash::StableHashCtxt>(&self,
                __hcx: &mut __Hcx,
                __hasher:
                    &mut ::rustc_data_structures::stable_hash::StableHasher) {
                match *self {
                    VariantFlags(ref __binding_0) => {
                        { __binding_0.stable_hash(__hcx, __hasher); }
                    }
                }
            }
        }
    };StableHash, const _: () =
    {
        impl<'tcx, __E: ::rustc_middle::ty::codec::TyEncoder<'tcx>>
            ::rustc_serialize::Encodable<__E> for VariantFlags {
            fn encode(&self, __encoder: &mut __E) {
                let VariantFlags(ref __binding_0) = *self;
                ::rustc_serialize::Encodable::<__E>::encode(__binding_0,
                    __encoder);
            }
        }
    };TyEncodable, const _: () =
    {
        impl<'tcx, __D: ::rustc_middle::ty::codec::TyDecoder<'tcx>>
            ::rustc_serialize::Decodable<__D> for VariantFlags {
            fn decode(__decoder: &mut __D) -> Self {
                VariantFlags(::rustc_serialize::Decodable::decode(__decoder))
            }
        }
    };TyDecodable)]
1455pub struct VariantFlags(u8);
1456impl VariantFlags {
    #[allow(deprecated, non_upper_case_globals,)]
    pub const NO_VARIANT_FLAGS: Self = Self::from_bits_retain(0);
    #[doc =
    r" Indicates whether the field list of this variant is `#[non_exhaustive]`."]
    #[allow(deprecated, non_upper_case_globals,)]
    pub const IS_FIELD_LIST_NON_EXHAUSTIVE: Self =
        Self::from_bits_retain(1 << 0);
}
impl ::bitflags::Flags for VariantFlags {
    const FLAGS: &'static [::bitflags::Flag<VariantFlags>] =
        &[{

                        #[allow(deprecated, non_upper_case_globals,)]
                        ::bitflags::Flag::new("NO_VARIANT_FLAGS",
                            VariantFlags::NO_VARIANT_FLAGS)
                    },
                    {

                        #[allow(deprecated, non_upper_case_globals,)]
                        ::bitflags::Flag::new("IS_FIELD_LIST_NON_EXHAUSTIVE",
                            VariantFlags::IS_FIELD_LIST_NON_EXHAUSTIVE)
                    }];
    type Bits = u8;
    fn bits(&self) -> u8 { VariantFlags::bits(self) }
    fn from_bits_retain(bits: u8) -> VariantFlags {
        VariantFlags::from_bits_retain(bits)
    }
}
#[allow(dead_code, deprecated, unused_doc_comments, unused_attributes,
unused_mut, unused_imports, non_upper_case_globals, clippy ::
assign_op_pattern, clippy :: iter_without_into_iter,)]
const _: () =
    {
        #[allow(dead_code, deprecated, unused_attributes)]
        impl VariantFlags {
            /// Get a flags value with all bits unset.
            #[inline]
            pub const fn empty() -> Self {
                Self(<u8 as ::bitflags::Bits>::EMPTY)
            }
            /// Get a flags value with all known bits set.
            #[inline]
            pub const fn all() -> Self {
                let mut truncated = <u8 as ::bitflags::Bits>::EMPTY;
                let mut i = 0;
                {
                    {
                        let flag =
                            <VariantFlags as
                                            ::bitflags::Flags>::FLAGS[i].value().bits();
                        truncated = truncated | flag;
                        i += 1;
                    }
                };
                {
                    {
                        let flag =
                            <VariantFlags as
                                            ::bitflags::Flags>::FLAGS[i].value().bits();
                        truncated = truncated | flag;
                        i += 1;
                    }
                };
                let _ = i;
                Self(truncated)
            }
            /// Get the underlying bits value.
            ///
            /// The returned value is exactly the bits set in this flags value.
            #[inline]
            pub const fn bits(&self) -> u8 { self.0 }
            /// Convert from a bits value.
            ///
            /// This method will return `None` if any unknown bits are set.
            #[inline]
            pub const fn from_bits(bits: u8)
                -> ::bitflags::__private::core::option::Option<Self> {
                let truncated = Self::from_bits_truncate(bits).0;
                if truncated == bits {
                    ::bitflags::__private::core::option::Option::Some(Self(bits))
                } else { ::bitflags::__private::core::option::Option::None }
            }
            /// Convert from a bits value, unsetting any unknown bits.
            #[inline]
            pub const fn from_bits_truncate(bits: u8) -> Self {
                Self(bits & Self::all().0)
            }
            /// Convert from a bits value exactly.
            #[inline]
            pub const fn from_bits_retain(bits: u8) -> Self { Self(bits) }
            /// Get a flags value with the bits of a flag with the given name set.
            ///
            /// This method will return `None` if `name` is empty or doesn't
            /// correspond to any named flag.
            #[inline]
            pub fn from_name(name: &str)
                -> ::bitflags::__private::core::option::Option<Self> {
                {
                    if name == "NO_VARIANT_FLAGS" {
                        return ::bitflags::__private::core::option::Option::Some(Self(VariantFlags::NO_VARIANT_FLAGS.bits()));
                    }
                };
                ;
                {
                    if name == "IS_FIELD_LIST_NON_EXHAUSTIVE" {
                        return ::bitflags::__private::core::option::Option::Some(Self(VariantFlags::IS_FIELD_LIST_NON_EXHAUSTIVE.bits()));
                    }
                };
                ;
                let _ = name;
                ::bitflags::__private::core::option::Option::None
            }
            /// Whether all bits in this flags value are unset.
            #[inline]
            pub const fn is_empty(&self) -> bool {
                self.0 == <u8 as ::bitflags::Bits>::EMPTY
            }
            /// Whether all known bits in this flags value are set.
            #[inline]
            pub const fn is_all(&self) -> bool {
                Self::all().0 | self.0 == self.0
            }
            /// Whether any set bits in a source flags value are also set in a target flags value.
            #[inline]
            pub const fn intersects(&self, other: Self) -> bool {
                self.0 & other.0 != <u8 as ::bitflags::Bits>::EMPTY
            }
            /// Whether all set bits in a source flags value are also set in a target flags value.
            #[inline]
            pub const fn contains(&self, other: Self) -> bool {
                self.0 & other.0 == other.0
            }
            /// The bitwise or (`|`) of the bits in two flags values.
            #[inline]
            pub fn insert(&mut self, other: Self) {
                *self = Self(self.0).union(other);
            }
            /// The intersection of a source flags value with the complement of a target flags
            /// value (`&!`).
            ///
            /// This method is not equivalent to `self & !other` when `other` has unknown bits set.
            /// `remove` won't truncate `other`, but the `!` operator will.
            #[inline]
            pub fn remove(&mut self, other: Self) {
                *self = Self(self.0).difference(other);
            }
            /// The bitwise exclusive-or (`^`) of the bits in two flags values.
            #[inline]
            pub fn toggle(&mut self, other: Self) {
                *self = Self(self.0).symmetric_difference(other);
            }
            /// Call `insert` when `value` is `true` or `remove` when `value` is `false`.
            #[inline]
            pub fn set(&mut self, other: Self, value: bool) {
                if value { self.insert(other); } else { self.remove(other); }
            }
            /// The bitwise and (`&`) of the bits in two flags values.
            #[inline]
            #[must_use]
            pub const fn intersection(self, other: Self) -> Self {
                Self(self.0 & other.0)
            }
            /// The bitwise or (`|`) of the bits in two flags values.
            #[inline]
            #[must_use]
            pub const fn union(self, other: Self) -> Self {
                Self(self.0 | other.0)
            }
            /// The intersection of a source flags value with the complement of a target flags
            /// value (`&!`).
            ///
            /// This method is not equivalent to `self & !other` when `other` has unknown bits set.
            /// `difference` won't truncate `other`, but the `!` operator will.
            #[inline]
            #[must_use]
            pub const fn difference(self, other: Self) -> Self {
                Self(self.0 & !other.0)
            }
            /// The bitwise exclusive-or (`^`) of the bits in two flags values.
            #[inline]
            #[must_use]
            pub const fn symmetric_difference(self, other: Self) -> Self {
                Self(self.0 ^ other.0)
            }
            /// The bitwise negation (`!`) of the bits in a flags value, truncating the result.
            #[inline]
            #[must_use]
            pub const fn complement(self) -> Self {
                Self::from_bits_truncate(!self.0)
            }
        }
        impl ::bitflags::__private::core::fmt::Binary for VariantFlags {
            fn fmt(&self, f: &mut ::bitflags::__private::core::fmt::Formatter)
                -> ::bitflags::__private::core::fmt::Result {
                let inner = self.0;
                ::bitflags::__private::core::fmt::Binary::fmt(&inner, f)
            }
        }
        impl ::bitflags::__private::core::fmt::Octal for VariantFlags {
            fn fmt(&self, f: &mut ::bitflags::__private::core::fmt::Formatter)
                -> ::bitflags::__private::core::fmt::Result {
                let inner = self.0;
                ::bitflags::__private::core::fmt::Octal::fmt(&inner, f)
            }
        }
        impl ::bitflags::__private::core::fmt::LowerHex for VariantFlags {
            fn fmt(&self, f: &mut ::bitflags::__private::core::fmt::Formatter)
                -> ::bitflags::__private::core::fmt::Result {
                let inner = self.0;
                ::bitflags::__private::core::fmt::LowerHex::fmt(&inner, f)
            }
        }
        impl ::bitflags::__private::core::fmt::UpperHex for VariantFlags {
            fn fmt(&self, f: &mut ::bitflags::__private::core::fmt::Formatter)
                -> ::bitflags::__private::core::fmt::Result {
                let inner = self.0;
                ::bitflags::__private::core::fmt::UpperHex::fmt(&inner, f)
            }
        }
        impl ::bitflags::__private::core::ops::BitOr for VariantFlags {
            type Output = Self;
            /// The bitwise or (`|`) of the bits in two flags values.
            #[inline]
            fn bitor(self, other: VariantFlags) -> Self { self.union(other) }
        }
        impl ::bitflags::__private::core::ops::BitOrAssign for VariantFlags {
            /// The bitwise or (`|`) of the bits in two flags values.
            #[inline]
            fn bitor_assign(&mut self, other: Self) { self.insert(other); }
        }
        impl ::bitflags::__private::core::ops::BitXor for VariantFlags {
            type Output = Self;
            /// The bitwise exclusive-or (`^`) of the bits in two flags values.
            #[inline]
            fn bitxor(self, other: Self) -> Self {
                self.symmetric_difference(other)
            }
        }
        impl ::bitflags::__private::core::ops::BitXorAssign for VariantFlags {
            /// The bitwise exclusive-or (`^`) of the bits in two flags values.
            #[inline]
            fn bitxor_assign(&mut self, other: Self) { self.toggle(other); }
        }
        impl ::bitflags::__private::core::ops::BitAnd for VariantFlags {
            type Output = Self;
            /// The bitwise and (`&`) of the bits in two flags values.
            #[inline]
            fn bitand(self, other: Self) -> Self { self.intersection(other) }
        }
        impl ::bitflags::__private::core::ops::BitAndAssign for VariantFlags {
            /// The bitwise and (`&`) of the bits in two flags values.
            #[inline]
            fn bitand_assign(&mut self, other: Self) {
                *self =
                    Self::from_bits_retain(self.bits()).intersection(other);
            }
        }
        impl ::bitflags::__private::core::ops::Sub for VariantFlags {
            type Output = Self;
            /// The intersection of a source flags value with the complement of a target flags value (`&!`).
            ///
            /// This method is not equivalent to `self & !other` when `other` has unknown bits set.
            /// `difference` won't truncate `other`, but the `!` operator will.
            #[inline]
            fn sub(self, other: Self) -> Self { self.difference(other) }
        }
        impl ::bitflags::__private::core::ops::SubAssign for VariantFlags {
            /// The intersection of a source flags value with the complement of a target flags value (`&!`).
            ///
            /// This method is not equivalent to `self & !other` when `other` has unknown bits set.
            /// `difference` won't truncate `other`, but the `!` operator will.
            #[inline]
            fn sub_assign(&mut self, other: Self) { self.remove(other); }
        }
        impl ::bitflags::__private::core::ops::Not for VariantFlags {
            type Output = Self;
            /// The bitwise negation (`!`) of the bits in a flags value, truncating the result.
            #[inline]
            fn not(self) -> Self { self.complement() }
        }
        impl ::bitflags::__private::core::iter::Extend<VariantFlags> for
            VariantFlags {
            /// The bitwise or (`|`) of the bits in each flags value.
            fn extend<T: ::bitflags::__private::core::iter::IntoIterator<Item
                = Self>>(&mut self, iterator: T) {
                for item in iterator { self.insert(item) }
            }
        }
        impl ::bitflags::__private::core::iter::FromIterator<VariantFlags> for
            VariantFlags {
            /// The bitwise or (`|`) of the bits in each flags value.
            fn from_iter<T: ::bitflags::__private::core::iter::IntoIterator<Item
                = Self>>(iterator: T) -> Self {
                use ::bitflags::__private::core::iter::Extend;
                let mut result = Self::empty();
                result.extend(iterator);
                result
            }
        }
        impl VariantFlags {
            /// Yield a set of contained flags values.
            ///
            /// Each yielded flags value will correspond to a defined named flag. Any unknown bits
            /// will be yielded together as a final flags value.
            #[inline]
            pub const fn iter(&self) -> ::bitflags::iter::Iter<VariantFlags> {
                ::bitflags::iter::Iter::__private_const_new(<VariantFlags as
                        ::bitflags::Flags>::FLAGS,
                    VariantFlags::from_bits_retain(self.bits()),
                    VariantFlags::from_bits_retain(self.bits()))
            }
            /// Yield a set of contained named flags values.
            ///
            /// This method is like [`iter`](#method.iter), except only yields bits in contained named flags.
            /// Any unknown bits, or bits not corresponding to a contained flag will not be yielded.
            #[inline]
            pub const fn iter_names(&self)
                -> ::bitflags::iter::IterNames<VariantFlags> {
                ::bitflags::iter::IterNames::__private_const_new(<VariantFlags
                        as ::bitflags::Flags>::FLAGS,
                    VariantFlags::from_bits_retain(self.bits()),
                    VariantFlags::from_bits_retain(self.bits()))
            }
        }
        impl ::bitflags::__private::core::iter::IntoIterator for VariantFlags
            {
            type Item = VariantFlags;
            type IntoIter = ::bitflags::iter::Iter<VariantFlags>;
            fn into_iter(self) -> Self::IntoIter { self.iter() }
        }
    };bitflags::bitflags! {
1457    impl VariantFlags: u8 {
1458        const NO_VARIANT_FLAGS        = 0;
1459        /// Indicates whether the field list of this variant is `#[non_exhaustive]`.
1460        const IS_FIELD_LIST_NON_EXHAUSTIVE = 1 << 0;
1461    }
1462}
1463impl ::std::fmt::Debug for VariantFlags {
    fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
        ::bitflags::parser::to_writer(self, f)
    }
}rustc_data_structures::external_bitflags_debug! { VariantFlags }
1464
1465/// Definition of a variant -- a struct's fields or an enum variant.
1466#[derive(#[automatically_derived]impl ::core::fmt::Debug for VariantDef {
    #[inline]
    #[rustc_trivial_field_reads]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::debug_struct_fields_finish(f,
            "VariantDef def_id ctor name discr fields tainted flags",
            &[&self.def_id, &self.ctor, &self.name, &self.discr, &self.fields,
                        &self.tainted, &&self.flags])
    }
}Debug, const _: () =
    {
        impl ::rustc_data_structures::stable_hash::StableHash for VariantDef {
            #[inline]
            fn stable_hash<__Hcx: ::rustc_data_structures::stable_hash::StableHashCtxt>(&self,
                __hcx: &mut __Hcx,
                __hasher:
                    &mut ::rustc_data_structures::stable_hash::StableHasher) {
                match *self {
                    VariantDef {
                        def_id: ref __binding_0,
                        ctor: ref __binding_1,
                        name: ref __binding_2,
                        discr: ref __binding_3,
                        fields: ref __binding_4,
                        tainted: ref __binding_5,
                        flags: ref __binding_6 } => {
                        { __binding_0.stable_hash(__hcx, __hasher); }
                        { __binding_1.stable_hash(__hcx, __hasher); }
                        { __binding_2.stable_hash(__hcx, __hasher); }
                        { __binding_3.stable_hash(__hcx, __hasher); }
                        { __binding_4.stable_hash(__hcx, __hasher); }
                        { __binding_5.stable_hash(__hcx, __hasher); }
                        { __binding_6.stable_hash(__hcx, __hasher); }
                    }
                }
            }
        }
    };StableHash, const _: () =
    {
        impl<'tcx, __E: ::rustc_middle::ty::codec::TyEncoder<'tcx>>
            ::rustc_serialize::Encodable<__E> for VariantDef {
            fn encode(&self, __encoder: &mut __E) {
                let VariantDef {
                        def_id: ref __binding_0,
                        ctor: ref __binding_1,
                        name: ref __binding_2,
                        discr: ref __binding_3,
                        fields: ref __binding_4,
                        tainted: ref __binding_5,
                        flags: ref __binding_6 } = *self;
                ::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);
                ::rustc_serialize::Encodable::<__E>::encode(__binding_5,
                    __encoder);
                ::rustc_serialize::Encodable::<__E>::encode(__binding_6,
                    __encoder);
            }
        }
    };TyEncodable, const _: () =
    {
        impl<'tcx, __D: ::rustc_middle::ty::codec::TyDecoder<'tcx>>
            ::rustc_serialize::Decodable<__D> for VariantDef {
            fn decode(__decoder: &mut __D) -> Self {
                VariantDef {
                    def_id: ::rustc_serialize::Decodable::decode(__decoder),
                    ctor: ::rustc_serialize::Decodable::decode(__decoder),
                    name: ::rustc_serialize::Decodable::decode(__decoder),
                    discr: ::rustc_serialize::Decodable::decode(__decoder),
                    fields: ::rustc_serialize::Decodable::decode(__decoder),
                    tainted: ::rustc_serialize::Decodable::decode(__decoder),
                    flags: ::rustc_serialize::Decodable::decode(__decoder),
                }
            }
        }
    };TyDecodable)]
1467pub struct VariantDef {
1468    /// `DefId` that identifies the variant itself.
1469    /// If this variant belongs to a struct or union, then this is a copy of its `DefId`.
1470    pub def_id: DefId,
1471    /// `DefId` that identifies the variant's constructor.
1472    /// If this variant is a struct variant, then this is `None`.
1473    pub ctor: Option<(CtorKind, DefId)>,
1474    /// Variant or struct name.
1475    pub name: Symbol,
1476    /// Discriminant of this variant.
1477    pub discr: VariantDiscr,
1478    /// Fields of this variant.
1479    pub fields: IndexVec<FieldIdx, FieldDef>,
1480    /// The error guarantees from parser, if any.
1481    tainted: Option<ErrorGuaranteed>,
1482    /// Flags of the variant (e.g. is field list non-exhaustive)?
1483    flags: VariantFlags,
1484}
1485
1486impl VariantDef {
1487    /// Creates a new `VariantDef`.
1488    ///
1489    /// `variant_did` is the `DefId` that identifies the enum variant (if this `VariantDef`
1490    /// represents an enum variant).
1491    ///
1492    /// `ctor_did` is the `DefId` that identifies the constructor of unit or
1493    /// tuple-variants/structs. If this is a `struct`-variant then this should be `None`.
1494    ///
1495    /// `parent_did` is the `DefId` of the `AdtDef` representing the enum or struct that
1496    /// owns this variant. It is used for checking if a struct has `#[non_exhaustive]` w/out having
1497    /// to go through the redirect of checking the ctor's attributes - but compiling a small crate
1498    /// requires loading the `AdtDef`s for all the structs in the universe (e.g., coherence for any
1499    /// built-in trait), and we do not want to load attributes twice.
1500    ///
1501    /// If someone speeds up attribute loading to not be a performance concern, they can
1502    /// remove this hack and use the constructor `DefId` everywhere.
1503    {}
#[allow(clippy :: suspicious_else_formatting)]
{
    let __tracing_attr_span;
    let __tracing_attr_guard;
    if ::tracing::Level::DEBUG <= ::tracing::level_filters::STATIC_MAX_LEVEL
                &&
                ::tracing::Level::DEBUG <=
                    ::tracing::level_filters::LevelFilter::current() ||
            { false } {
        __tracing_attr_span =
            {
                use ::tracing::__macro_support::Callsite as _;
                static __CALLSITE: ::tracing::callsite::DefaultCallsite =
                    {
                        static META: ::tracing::Metadata<'static> =
                            {
                                ::tracing_core::metadata::Metadata::new("new",
                                    "rustc_middle::ty", ::tracing::Level::DEBUG,
                                    ::tracing_core::__macro_support::Option::Some("/rustc-dev/c82ce15637153c025d29abbaff6035a177361788/compiler/rustc_middle/src/ty/mod.rs"),
                                    ::tracing_core::__macro_support::Option::Some(1503u32),
                                    ::tracing_core::__macro_support::Option::Some("rustc_middle::ty"),
                                    ::tracing_core::field::FieldSet::new(&[{
                                                        const NAME:
                                                            ::tracing::__macro_support::FieldName<{
                                                                ::tracing::__macro_support::FieldName::len("name")
                                                            }> =
                                                            ::tracing::__macro_support::FieldName::new("name");
                                                        NAME.as_str()
                                                    },
                                                    {
                                                        const NAME:
                                                            ::tracing::__macro_support::FieldName<{
                                                                ::tracing::__macro_support::FieldName::len("variant_did")
                                                            }> =
                                                            ::tracing::__macro_support::FieldName::new("variant_did");
                                                        NAME.as_str()
                                                    },
                                                    {
                                                        const NAME:
                                                            ::tracing::__macro_support::FieldName<{
                                                                ::tracing::__macro_support::FieldName::len("ctor")
                                                            }> =
                                                            ::tracing::__macro_support::FieldName::new("ctor");
                                                        NAME.as_str()
                                                    },
                                                    {
                                                        const NAME:
                                                            ::tracing::__macro_support::FieldName<{
                                                                ::tracing::__macro_support::FieldName::len("discr")
                                                            }> =
                                                            ::tracing::__macro_support::FieldName::new("discr");
                                                        NAME.as_str()
                                                    },
                                                    {
                                                        const NAME:
                                                            ::tracing::__macro_support::FieldName<{
                                                                ::tracing::__macro_support::FieldName::len("fields")
                                                            }> =
                                                            ::tracing::__macro_support::FieldName::new("fields");
                                                        NAME.as_str()
                                                    },
                                                    {
                                                        const NAME:
                                                            ::tracing::__macro_support::FieldName<{
                                                                ::tracing::__macro_support::FieldName::len("parent_did")
                                                            }> =
                                                            ::tracing::__macro_support::FieldName::new("parent_did");
                                                        NAME.as_str()
                                                    },
                                                    {
                                                        const NAME:
                                                            ::tracing::__macro_support::FieldName<{
                                                                ::tracing::__macro_support::FieldName::len("recover_tainted")
                                                            }> =
                                                            ::tracing::__macro_support::FieldName::new("recover_tainted");
                                                        NAME.as_str()
                                                    },
                                                    {
                                                        const NAME:
                                                            ::tracing::__macro_support::FieldName<{
                                                                ::tracing::__macro_support::FieldName::len("is_field_list_non_exhaustive")
                                                            }> =
                                                            ::tracing::__macro_support::FieldName::new("is_field_list_non_exhaustive");
                                                        NAME.as_str()
                                                    }], ::tracing_core::callsite::Identifier(&__CALLSITE)),
                                    ::tracing::metadata::Kind::SPAN)
                            };
                        ::tracing::callsite::DefaultCallsite::new(&META)
                    };
                let mut interest = ::tracing::subscriber::Interest::never();
                if ::tracing::Level::DEBUG <=
                                    ::tracing::level_filters::STATIC_MAX_LEVEL &&
                                ::tracing::Level::DEBUG <=
                                    ::tracing::level_filters::LevelFilter::current() &&
                            { interest = __CALLSITE.interest(); !interest.is_never() }
                        &&
                        ::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
                            interest) {
                    let meta = __CALLSITE.metadata();
                    ::tracing::Span::new(meta,
                        &{
                                #[allow(unused_imports)]
                                use ::tracing::field::{debug, display, Value};
                                meta.fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&name)
                                                            as &dyn ::tracing::field::Value)),
                                                (::tracing::__macro_support::Option::Some(&::tracing::field::debug(&variant_did)
                                                            as &dyn ::tracing::field::Value)),
                                                (::tracing::__macro_support::Option::Some(&::tracing::field::debug(&ctor)
                                                            as &dyn ::tracing::field::Value)),
                                                (::tracing::__macro_support::Option::Some(&::tracing::field::debug(&discr)
                                                            as &dyn ::tracing::field::Value)),
                                                (::tracing::__macro_support::Option::Some(&::tracing::field::debug(&fields)
                                                            as &dyn ::tracing::field::Value)),
                                                (::tracing::__macro_support::Option::Some(&::tracing::field::debug(&parent_did)
                                                            as &dyn ::tracing::field::Value)),
                                                (::tracing::__macro_support::Option::Some(&::tracing::field::debug(&recover_tainted)
                                                            as &dyn ::tracing::field::Value)),
                                                (::tracing::__macro_support::Option::Some(&is_field_list_non_exhaustive
                                                            as &dyn ::tracing::field::Value))])
                            })
                } else {
                    let span =
                        ::tracing::__macro_support::__disabled_span(__CALLSITE.metadata());
                    {};
                    span
                }
            };
        __tracing_attr_guard = __tracing_attr_span.enter();
    }

    #[warn(clippy :: suspicious_else_formatting)]
    {

        #[allow(unknown_lints, unreachable_code, clippy ::
        diverging_sub_expression, clippy :: empty_loop, clippy ::
        let_unit_value, clippy :: let_with_type_underscore, clippy ::
        needless_return, clippy :: unreachable)]
        if false {
            let __tracing_attr_fake_return: Self = loop {};
            return __tracing_attr_fake_return;
        }
        {
            let mut flags = VariantFlags::NO_VARIANT_FLAGS;
            if is_field_list_non_exhaustive {
                flags |= VariantFlags::IS_FIELD_LIST_NON_EXHAUSTIVE;
            }
            VariantDef {
                def_id: variant_did.unwrap_or(parent_did),
                ctor,
                name,
                discr,
                fields,
                flags,
                tainted: recover_tainted,
            }
        }
    }
}#[instrument(level = "debug")]
1504    pub fn new(
1505        name: Symbol,
1506        variant_did: Option<DefId>,
1507        ctor: Option<(CtorKind, DefId)>,
1508        discr: VariantDiscr,
1509        fields: IndexVec<FieldIdx, FieldDef>,
1510        parent_did: DefId,
1511        recover_tainted: Option<ErrorGuaranteed>,
1512        is_field_list_non_exhaustive: bool,
1513    ) -> Self {
1514        let mut flags = VariantFlags::NO_VARIANT_FLAGS;
1515        if is_field_list_non_exhaustive {
1516            flags |= VariantFlags::IS_FIELD_LIST_NON_EXHAUSTIVE;
1517        }
1518
1519        VariantDef {
1520            def_id: variant_did.unwrap_or(parent_did),
1521            ctor,
1522            name,
1523            discr,
1524            fields,
1525            flags,
1526            tainted: recover_tainted,
1527        }
1528    }
1529
1530    /// Returns `true` if the field list of this variant is `#[non_exhaustive]`.
1531    ///
1532    /// Note that this function will return `true` even if the type has been
1533    /// defined in the crate currently being compiled. If that's not what you
1534    /// want, see [`Self::field_list_has_applicable_non_exhaustive`].
1535    #[inline]
1536    pub fn is_field_list_non_exhaustive(&self) -> bool {
1537        self.flags.intersects(VariantFlags::IS_FIELD_LIST_NON_EXHAUSTIVE)
1538    }
1539
1540    /// Returns `true` if the field list of this variant is `#[non_exhaustive]`
1541    /// and the type has been defined in another crate.
1542    #[inline]
1543    pub fn field_list_has_applicable_non_exhaustive(&self) -> bool {
1544        self.is_field_list_non_exhaustive() && !self.def_id.is_local()
1545    }
1546
1547    /// Computes the `Ident` of this variant by looking up the `Span`
1548    pub fn ident(&self, tcx: TyCtxt<'_>) -> Ident {
1549        Ident::new(self.name, tcx.def_ident_span(self.def_id).unwrap())
1550    }
1551
1552    /// Was this variant obtained as part of recovering from a syntactic error?
1553    #[inline]
1554    pub fn has_errors(&self) -> Result<(), ErrorGuaranteed> {
1555        self.tainted.map_or(Ok(()), Err)
1556    }
1557
1558    #[inline]
1559    pub fn ctor_kind(&self) -> Option<CtorKind> {
1560        self.ctor.map(|(kind, _)| kind)
1561    }
1562
1563    #[inline]
1564    pub fn ctor_def_id(&self) -> Option<DefId> {
1565        self.ctor.map(|(_, def_id)| def_id)
1566    }
1567
1568    /// Returns the one field in this variant.
1569    ///
1570    /// `panic!`s if there are no fields or multiple fields.
1571    #[inline]
1572    pub fn single_field(&self) -> &FieldDef {
1573        if !(self.fields.len() == 1) {
    ::core::panicking::panic("assertion failed: self.fields.len() == 1")
};assert!(self.fields.len() == 1);
1574
1575        &self.fields[FieldIdx::ZERO]
1576    }
1577
1578    /// Returns the last field in this variant, if present.
1579    #[inline]
1580    pub fn tail_opt(&self) -> Option<&FieldDef> {
1581        self.fields.raw.last()
1582    }
1583
1584    /// Returns the last field in this variant.
1585    ///
1586    /// # Panics
1587    ///
1588    /// Panics, if the variant has no fields.
1589    #[inline]
1590    pub fn tail(&self) -> &FieldDef {
1591        self.tail_opt().expect("expected unsized ADT to have a tail field")
1592    }
1593
1594    /// Returns whether this variant has unsafe fields.
1595    pub fn has_unsafe_fields(&self) -> bool {
1596        self.fields.iter().any(|x| x.safety.is_unsafe())
1597    }
1598}
1599
1600impl PartialEq for VariantDef {
1601    #[inline]
1602    fn eq(&self, other: &Self) -> bool {
1603        // There should be only one `VariantDef` for each `def_id`, therefore
1604        // it is fine to implement `PartialEq` only based on `def_id`.
1605        //
1606        // Below, we exhaustively destructure `self` and `other` so that if the
1607        // definition of `VariantDef` changes, a compile-error will be produced,
1608        // reminding us to revisit this assumption.
1609
1610        let Self {
1611            def_id: lhs_def_id,
1612            ctor: _,
1613            name: _,
1614            discr: _,
1615            fields: _,
1616            flags: _,
1617            tainted: _,
1618        } = &self;
1619        let Self {
1620            def_id: rhs_def_id,
1621            ctor: _,
1622            name: _,
1623            discr: _,
1624            fields: _,
1625            flags: _,
1626            tainted: _,
1627        } = other;
1628
1629        let res = lhs_def_id == rhs_def_id;
1630
1631        // Double check that implicit assumption detailed above.
1632        if truecfg!(debug_assertions) && res {
1633            let deep = self.ctor == other.ctor
1634                && self.name == other.name
1635                && self.discr == other.discr
1636                && self.fields == other.fields
1637                && self.flags == other.flags;
1638            if !deep {
    {
        ::core::panicking::panic_fmt(format_args!("VariantDef for the same def-id has differing data"));
    }
};assert!(deep, "VariantDef for the same def-id has differing data");
1639        }
1640
1641        res
1642    }
1643}
1644
1645impl Eq for VariantDef {}
1646
1647impl Hash for VariantDef {
1648    #[inline]
1649    fn hash<H: Hasher>(&self, s: &mut H) {
1650        // There should be only one `VariantDef` for each `def_id`, therefore
1651        // it is fine to implement `Hash` only based on `def_id`.
1652        //
1653        // Below, we exhaustively destructure `self` so that if the definition
1654        // of `VariantDef` changes, a compile-error will be produced, reminding
1655        // us to revisit this assumption.
1656
1657        let Self { def_id, ctor: _, name: _, discr: _, fields: _, flags: _, tainted: _ } = &self;
1658        def_id.hash(s)
1659    }
1660}
1661
1662#[derive(#[automatically_derived]impl ::core::marker::Copy for VariantDiscr { }Copy, #[automatically_derived]#[doc(hidden)]unsafe impl ::core::clone::TrivialClone
    for VariantDiscr {
}
#[automatically_derived]impl ::core::clone::Clone for VariantDiscr {
    #[inline]
    #[rustc_trivial_field_reads]
    fn clone(&self) -> Self {
        let _: ::core::clone::AssertParamIsClone<DefId>;
        let _: ::core::clone::AssertParamIsClone<u32>;
        *self
    }
}Clone, #[automatically_derived]impl ::core::fmt::Debug for VariantDiscr {
    #[inline]
    #[rustc_trivial_field_reads]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        match self {
            Self::Explicit(__self_0) =>
                ::core::fmt::Formatter::debug_struct_field1_finish(f,
                    "Explicit", &__self_0),
            Self::Relative(__self_0) =>
                ::core::fmt::Formatter::debug_struct_field1_finish(f,
                    "Relative", &__self_0),
        }
    }
}Debug, #[automatically_derived]impl ::core::marker::StructuralPartialEq for
    VariantDiscr {
}
#[automatically_derived]impl ::core::cmp::PartialEq for VariantDiscr {
    #[inline]
    fn eq(&self, other: &Self) -> bool {
        ::core::intrinsics::discriminant_value(self) ==
                ::core::intrinsics::discriminant_value(other) &&
            match (self, other) {
                (Self::Explicit(__self_0), Self::Explicit(__arg1_0)) =>
                    __self_0 == __arg1_0,
                (Self::Relative(__self_0), Self::Relative(__arg1_0)) =>
                    __self_0 == __arg1_0,
                _ => unsafe { ::core::intrinsics::unreachable() }
            }
    }
}PartialEq, #[automatically_derived]impl ::core::cmp::Eq for VariantDiscr {
    #[inline]
    #[doc(hidden)]
    #[coverage(off)]
    fn assert_fields_are_eq(&self) {
        let _: ::core::cmp::AssertParamIsEq<DefId>;
        let _: ::core::cmp::AssertParamIsEq<u32>;
    }
}Eq, const _: () =
    {
        impl<'tcx, __E: ::rustc_middle::ty::codec::TyEncoder<'tcx>>
            ::rustc_serialize::Encodable<__E> for VariantDiscr {
            fn encode(&self, __encoder: &mut __E) {
                let disc =
                    match *self {
                        VariantDiscr::Explicit(ref __binding_0) => { 0usize }
                        VariantDiscr::Relative(ref __binding_0) => { 1usize }
                    };
                ::rustc_serialize::Encoder::emit_u8(__encoder, disc as u8);
                match *self {
                    VariantDiscr::Explicit(ref __binding_0) => {
                        ::rustc_serialize::Encodable::<__E>::encode(__binding_0,
                            __encoder);
                    }
                    VariantDiscr::Relative(ref __binding_0) => {
                        ::rustc_serialize::Encodable::<__E>::encode(__binding_0,
                            __encoder);
                    }
                }
            }
        }
    };TyEncodable, const _: () =
    {
        impl<'tcx, __D: ::rustc_middle::ty::codec::TyDecoder<'tcx>>
            ::rustc_serialize::Decodable<__D> for VariantDiscr {
            fn decode(__decoder: &mut __D) -> Self {
                match ::rustc_serialize::Decoder::read_u8(__decoder) as usize
                    {
                    0usize => {
                        VariantDiscr::Explicit(::rustc_serialize::Decodable::decode(__decoder))
                    }
                    1usize => {
                        VariantDiscr::Relative(::rustc_serialize::Decodable::decode(__decoder))
                    }
                    n => {
                        ::core::panicking::panic_fmt(format_args!("invalid enum variant tag while decoding `VariantDiscr`, expected 0..2, actual {0}",
                                n));
                    }
                }
            }
        }
    };TyDecodable, const _: () =
    {
        impl ::rustc_data_structures::stable_hash::StableHash for VariantDiscr
            {
            #[inline]
            fn stable_hash<__Hcx: ::rustc_data_structures::stable_hash::StableHashCtxt>(&self,
                __hcx: &mut __Hcx,
                __hasher:
                    &mut ::rustc_data_structures::stable_hash::StableHasher) {
                match *self {
                    VariantDiscr::Explicit(ref __binding_0) =>
                        0u8.stable_hash(__hcx, __hasher),
                    VariantDiscr::Relative(ref __binding_0) =>
                        1u8.stable_hash(__hcx, __hasher),
                }
                match *self {
                    VariantDiscr::Explicit(ref __binding_0) => {
                        { __binding_0.stable_hash(__hcx, __hasher); }
                    }
                    VariantDiscr::Relative(ref __binding_0) => {
                        { __binding_0.stable_hash(__hcx, __hasher); }
                    }
                }
            }
        }
    };StableHash)]
1663pub enum VariantDiscr {
1664    /// Explicit value for this variant, i.e., `X = 123`.
1665    /// The `DefId` corresponds to the embedded constant.
1666    Explicit(DefId),
1667
1668    /// The previous variant's discriminant plus one.
1669    /// For efficiency reasons, the distance from the
1670    /// last `Explicit` discriminant is being stored,
1671    /// or `0` for the first variant, if it has none.
1672    Relative(u32),
1673}
1674
1675#[derive(#[automatically_derived]impl ::core::fmt::Debug for FieldDef {
    #[inline]
    #[rustc_trivial_field_reads]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::debug_struct_fields_finish(f,
            "FieldDef did name vis mut_restriction safety value",
            &[&self.did, &self.name, &self.vis, &self.mut_restriction,
                        &self.safety, &&self.value])
    }
}Debug, const _: () =
    {
        impl ::rustc_data_structures::stable_hash::StableHash for FieldDef {
            #[inline]
            fn stable_hash<__Hcx: ::rustc_data_structures::stable_hash::StableHashCtxt>(&self,
                __hcx: &mut __Hcx,
                __hasher:
                    &mut ::rustc_data_structures::stable_hash::StableHasher) {
                match *self {
                    FieldDef {
                        did: ref __binding_0,
                        name: ref __binding_1,
                        vis: ref __binding_2,
                        mut_restriction: ref __binding_3,
                        safety: ref __binding_4,
                        value: ref __binding_5 } => {
                        { __binding_0.stable_hash(__hcx, __hasher); }
                        { __binding_1.stable_hash(__hcx, __hasher); }
                        { __binding_2.stable_hash(__hcx, __hasher); }
                        { __binding_3.stable_hash(__hcx, __hasher); }
                        { __binding_4.stable_hash(__hcx, __hasher); }
                        { __binding_5.stable_hash(__hcx, __hasher); }
                    }
                }
            }
        }
    };StableHash, const _: () =
    {
        impl<'tcx, __E: ::rustc_middle::ty::codec::TyEncoder<'tcx>>
            ::rustc_serialize::Encodable<__E> for FieldDef {
            fn encode(&self, __encoder: &mut __E) {
                let FieldDef {
                        did: ref __binding_0,
                        name: ref __binding_1,
                        vis: ref __binding_2,
                        mut_restriction: ref __binding_3,
                        safety: ref __binding_4,
                        value: ref __binding_5 } = *self;
                ::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);
                ::rustc_serialize::Encodable::<__E>::encode(__binding_5,
                    __encoder);
            }
        }
    };TyEncodable, const _: () =
    {
        impl<'tcx, __D: ::rustc_middle::ty::codec::TyDecoder<'tcx>>
            ::rustc_serialize::Decodable<__D> for FieldDef {
            fn decode(__decoder: &mut __D) -> Self {
                FieldDef {
                    did: ::rustc_serialize::Decodable::decode(__decoder),
                    name: ::rustc_serialize::Decodable::decode(__decoder),
                    vis: ::rustc_serialize::Decodable::decode(__decoder),
                    mut_restriction: ::rustc_serialize::Decodable::decode(__decoder),
                    safety: ::rustc_serialize::Decodable::decode(__decoder),
                    value: ::rustc_serialize::Decodable::decode(__decoder),
                }
            }
        }
    };TyDecodable)]
1676pub struct FieldDef {
1677    pub did: DefId,
1678    pub name: Symbol,
1679    pub vis: Visibility<ModId>,
1680    pub mut_restriction: RestrictionKind,
1681    pub safety: hir::Safety,
1682    pub value: Option<DefId>,
1683}
1684
1685impl PartialEq for FieldDef {
1686    #[inline]
1687    fn eq(&self, other: &Self) -> bool {
1688        // There should be only one `FieldDef` for each `did`, therefore it is
1689        // fine to implement `PartialEq` only based on `did`.
1690        //
1691        // Below, we exhaustively destructure `self` so that if the definition
1692        // of `FieldDef` changes, a compile-error will be produced, reminding
1693        // us to revisit this assumption.
1694
1695        let Self { did: lhs_did, name: _, vis: _, mut_restriction: _, safety: _, value: _ } = &self;
1696
1697        let Self { did: rhs_did, name: _, vis: _, mut_restriction: _, safety: _, value: _ } = other;
1698
1699        let res = lhs_did == rhs_did;
1700
1701        // Double check that implicit assumption detailed above.
1702        if truecfg!(debug_assertions) && res {
1703            let deep = self.name == other.name
1704                && self.vis == other.vis
1705                && self.mut_restriction == other.mut_restriction
1706                && self.safety == other.safety;
1707            if !deep {
    {
        ::core::panicking::panic_fmt(format_args!("FieldDef for the same def-id has differing data"));
    }
};assert!(deep, "FieldDef for the same def-id has differing data");
1708        }
1709
1710        res
1711    }
1712}
1713
1714impl Eq for FieldDef {}
1715
1716impl Hash for FieldDef {
1717    #[inline]
1718    fn hash<H: Hasher>(&self, s: &mut H) {
1719        // There should be only one `FieldDef` for each `did`, therefore it is
1720        // fine to implement `Hash` only based on `did`.
1721        //
1722        // Below, we exhaustively destructure `self` so that if the definition
1723        // of `FieldDef` changes, a compile-error will be produced, reminding
1724        // us to revisit this assumption.
1725
1726        let Self { did, name: _, vis: _, mut_restriction: _, safety: _, value: _ } = &self;
1727
1728        did.hash(s)
1729    }
1730}
1731
1732impl<'tcx> FieldDef {
1733    /// Returns the type of this field. The `args` are typically obtained via
1734    /// the second field of [`TyKind::Adt`].
1735    pub fn ty(&self, tcx: TyCtxt<'tcx>, args: GenericArgs<'tcx>) -> Unnormalized<'tcx, Ty<'tcx>> {
1736        tcx.type_of(self.did).instantiate(tcx, args)
1737    }
1738
1739    /// Computes the `Ident` of this variant by looking up the `Span`
1740    pub fn ident(&self, tcx: TyCtxt<'_>) -> Ident {
1741        Ident::new(self.name, tcx.def_ident_span(self.did).unwrap())
1742    }
1743}
1744
1745#[derive(#[automatically_derived]impl ::core::fmt::Debug for ImplOverlapKind {
    #[inline]
    #[rustc_trivial_field_reads]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        match self {
            Self::Permitted { marker: __self_0 } =>
                ::core::fmt::Formatter::debug_struct_field1_finish(f,
                    "Permitted marker", &__self_0),
        }
    }
}Debug, #[automatically_derived]impl ::core::marker::StructuralPartialEq for
    ImplOverlapKind {
}
#[automatically_derived]impl ::core::cmp::PartialEq for ImplOverlapKind {
    #[inline]
    fn eq(&self, other: &Self) -> bool {
        match (self, other) {
            (Self::Permitted { marker: __self_0 }, Self::Permitted {
                marker: __arg1_0 }) => __self_0 == __arg1_0,
        }
    }
}PartialEq, #[automatically_derived]impl ::core::cmp::Eq for ImplOverlapKind {
    #[inline]
    #[doc(hidden)]
    #[coverage(off)]
    fn assert_fields_are_eq(&self) {
        let _: ::core::cmp::AssertParamIsEq<bool>;
    }
}Eq)]
1746pub enum ImplOverlapKind {
1747    /// These impls are always allowed to overlap.
1748    Permitted {
1749        /// Whether or not the impl is permitted due to the trait being a `#[marker]` trait
1750        marker: bool,
1751    },
1752}
1753
1754/// Useful source information about where a desugared associated type for an
1755/// RPITIT originated from.
1756#[derive(#[automatically_derived]#[doc(hidden)]unsafe impl ::core::clone::TrivialClone
    for ImplTraitInTraitData {
}
#[automatically_derived]impl ::core::clone::Clone for ImplTraitInTraitData {
    #[inline]
    #[rustc_trivial_field_reads]
    fn clone(&self) -> Self {
        let _: ::core::clone::AssertParamIsClone<DefId>;
        *self
    }
}Clone, #[automatically_derived]impl ::core::marker::Copy for ImplTraitInTraitData { }Copy, #[automatically_derived]impl ::core::fmt::Debug for ImplTraitInTraitData {
    #[inline]
    #[rustc_trivial_field_reads]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        match self {
            Self::Trait { fn_def_id: __self_0, opaque_def_id: __self_1 } =>
                ::core::fmt::Formatter::debug_struct_field2_finish(f,
                    "Trait fn_def_id opaque_def_id", __self_0, &__self_1),
            Self::Impl { fn_def_id: __self_0 } =>
                ::core::fmt::Formatter::debug_struct_field1_finish(f,
                    "Impl fn_def_id", &__self_0),
        }
    }
}Debug, #[automatically_derived]impl ::core::marker::StructuralPartialEq for
    ImplTraitInTraitData {
}
#[automatically_derived]impl ::core::cmp::PartialEq for ImplTraitInTraitData {
    #[inline]
    fn eq(&self, other: &Self) -> bool {
        ::core::intrinsics::discriminant_value(self) ==
                ::core::intrinsics::discriminant_value(other) &&
            match (self, other) {
                (Self::Trait { fn_def_id: __self_0, opaque_def_id: __self_1 },
                    Self::Trait { fn_def_id: __arg1_0, opaque_def_id: __arg1_1
                    }) => __self_0 == __arg1_0 && __self_1 == __arg1_1,
                (Self::Impl { fn_def_id: __self_0 }, Self::Impl {
                    fn_def_id: __arg1_0 }) => __self_0 == __arg1_0,
                _ => unsafe { ::core::intrinsics::unreachable() }
            }
    }
}PartialEq, #[automatically_derived]impl ::core::cmp::Eq for ImplTraitInTraitData {
    #[inline]
    #[doc(hidden)]
    #[coverage(off)]
    fn assert_fields_are_eq(&self) {
        let _: ::core::cmp::AssertParamIsEq<DefId>;
    }
}Eq, #[automatically_derived]impl ::core::hash::Hash for ImplTraitInTraitData {
    #[inline]
    fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) {
        ::core::hash::Hash::hash(&::core::intrinsics::discriminant_value(self),
            state);
        match self {
            Self::Trait { fn_def_id: __self_0, opaque_def_id: __self_1 } => {
                ::core::hash::Hash::hash(__self_0, state);
                ::core::hash::Hash::hash(__self_1, state)
            }
            Self::Impl { fn_def_id: __self_0 } =>
                ::core::hash::Hash::hash(__self_0, state),
        }
    }
}Hash, const _: () =
    {
        impl<__E: ::rustc_span::SpanEncoder> ::rustc_serialize::Encodable<__E>
            for ImplTraitInTraitData {
            fn encode(&self, __encoder: &mut __E) {
                let disc =
                    match *self {
                        ImplTraitInTraitData::Trait {
                            fn_def_id: ref __binding_0, opaque_def_id: ref __binding_1 }
                            => {
                            0usize
                        }
                        ImplTraitInTraitData::Impl { fn_def_id: ref __binding_0 } =>
                            {
                            1usize
                        }
                    };
                ::rustc_serialize::Encoder::emit_u8(__encoder, disc as u8);
                match *self {
                    ImplTraitInTraitData::Trait {
                        fn_def_id: ref __binding_0, opaque_def_id: ref __binding_1 }
                        => {
                        ::rustc_serialize::Encodable::<__E>::encode(__binding_0,
                            __encoder);
                        ::rustc_serialize::Encodable::<__E>::encode(__binding_1,
                            __encoder);
                    }
                    ImplTraitInTraitData::Impl { fn_def_id: ref __binding_0 } =>
                        {
                        ::rustc_serialize::Encodable::<__E>::encode(__binding_0,
                            __encoder);
                    }
                }
            }
        }
    };Encodable, const _: () =
    {
        impl<__D: ::rustc_span::SpanDecoder> ::rustc_serialize::Decodable<__D>
            for ImplTraitInTraitData {
            fn decode(__decoder: &mut __D) -> Self {
                match ::rustc_serialize::Decoder::read_u8(__decoder) as usize
                    {
                    0usize => {
                        ImplTraitInTraitData::Trait {
                            fn_def_id: ::rustc_serialize::Decodable::decode(__decoder),
                            opaque_def_id: ::rustc_serialize::Decodable::decode(__decoder),
                        }
                    }
                    1usize => {
                        ImplTraitInTraitData::Impl {
                            fn_def_id: ::rustc_serialize::Decodable::decode(__decoder),
                        }
                    }
                    n => {
                        ::core::panicking::panic_fmt(format_args!("invalid enum variant tag while decoding `ImplTraitInTraitData`, expected 0..2, actual {0}",
                                n));
                    }
                }
            }
        }
    };Decodable, const _: () =
    {
        impl ::rustc_data_structures::stable_hash::StableHash for
            ImplTraitInTraitData {
            #[inline]
            fn stable_hash<__Hcx: ::rustc_data_structures::stable_hash::StableHashCtxt>(&self,
                __hcx: &mut __Hcx,
                __hasher:
                    &mut ::rustc_data_structures::stable_hash::StableHasher) {
                match *self {
                    ImplTraitInTraitData::Trait {
                        fn_def_id: ref __binding_0, opaque_def_id: ref __binding_1 }
                        => 0u8.stable_hash(__hcx, __hasher),
                    ImplTraitInTraitData::Impl { fn_def_id: ref __binding_0 } =>
                        1u8.stable_hash(__hcx, __hasher),
                }
                match *self {
                    ImplTraitInTraitData::Trait {
                        fn_def_id: ref __binding_0, opaque_def_id: ref __binding_1 }
                        => {
                        { __binding_0.stable_hash(__hcx, __hasher); }
                        { __binding_1.stable_hash(__hcx, __hasher); }
                    }
                    ImplTraitInTraitData::Impl { fn_def_id: ref __binding_0 } =>
                        {
                        { __binding_0.stable_hash(__hcx, __hasher); }
                    }
                }
            }
        }
    };StableHash)]
1757pub enum ImplTraitInTraitData {
1758    Trait { fn_def_id: DefId, opaque_def_id: DefId },
1759    Impl { fn_def_id: DefId },
1760}
1761
1762impl<'tcx> TyCtxt<'tcx> {
1763    pub fn typeck_body(self, body: hir::BodyId) -> &'tcx TypeckResults<'tcx> {
1764        self.typeck(self.hir_body_owner_def_id(body))
1765    }
1766
1767    pub fn provided_trait_methods(self, id: DefId) -> impl 'tcx + Iterator<Item = &'tcx AssocItem> {
1768        self.associated_items(id)
1769            .in_definition_order()
1770            .filter(move |item| item.is_fn() && item.defaultness(self).has_value())
1771    }
1772
1773    pub fn repr_options_of_def(self, did: LocalDefId) -> ReprOptions {
1774        let mut flags = ReprFlags::empty();
1775        let mut size = None;
1776        let mut max_align: Option<Align> = None;
1777        let mut min_pack: Option<Align> = None;
1778
1779        // Generate a deterministically-derived seed from the item's path hash
1780        // to allow for cross-crate compilation to actually work
1781        let mut field_shuffle_seed = self.def_path_hash(did.to_def_id()).0.to_smaller_hash();
1782
1783        // If the user defined a custom seed for layout randomization, xor the item's
1784        // path hash with the user defined seed, this will allowing determinism while
1785        // still allowing users to further randomize layout generation for e.g. fuzzing
1786        if let Some(user_seed) = self.sess.opts.unstable_opts.layout_seed {
1787            field_shuffle_seed ^= user_seed;
1788        }
1789
1790        let elt = {
    {
        'done:
            {
            for i in ::rustc_attr_ir::HasAttrs::get_attrs(did, &self) {
                #[allow(unused_imports)]
                use ::rustc_attr_ir::AttributeKind::*;
                let i: &::rustc_attr_ir::Attribute = i;
                match i {
                    ::rustc_attr_ir::Attribute::Parsed(RustcScalableVector {
                        element_count }) => {
                        break 'done Some(element_count);
                    }
                    ::rustc_attr_ir::Attribute::Tool { .. } |
                        ::rustc_attr_ir::Attribute::DeriveHelper(..) =>
                        {}
                        #[deny(unreachable_patterns)]
                        _ => {}
                }
            }
            None
        }
    }
}find_attr!(self, did, RustcScalableVector { element_count } => element_count
1791        )
1792        .map(|elt| match elt {
1793            Some(n) => ScalableElt::ElementCount(*n),
1794            None => ScalableElt::Container,
1795        });
1796        if elt.is_some() {
1797            flags.insert(ReprFlags::IS_SCALABLE);
1798        }
1799        if let Some(reprs) = {
    {
        'done:
            {
            for i in ::rustc_attr_ir::HasAttrs::get_attrs(did, &self) {
                #[allow(unused_imports)]
                use ::rustc_attr_ir::AttributeKind::*;
                let i: &::rustc_attr_ir::Attribute = i;
                match i {
                    ::rustc_attr_ir::Attribute::Parsed(Repr { reprs, .. }) => {
                        break 'done Some(reprs);
                    }
                    ::rustc_attr_ir::Attribute::Tool { .. } |
                        ::rustc_attr_ir::Attribute::DeriveHelper(..) =>
                        {}
                        #[deny(unreachable_patterns)]
                        _ => {}
                }
            }
            None
        }
    }
}find_attr!(self, did, Repr { reprs, .. } => reprs) {
1800            for (r, _) in reprs {
1801                flags.insert(match *r {
1802                    attr::ReprRust => ReprFlags::empty(),
1803                    attr::ReprC => ReprFlags::IS_C,
1804                    attr::ReprPacked(pack) => {
1805                        min_pack = Some(if let Some(min_pack) = min_pack {
1806                            min_pack.min(pack)
1807                        } else {
1808                            pack
1809                        });
1810                        ReprFlags::empty()
1811                    }
1812                    attr::ReprTransparent => ReprFlags::IS_TRANSPARENT,
1813                    attr::ReprSimd => ReprFlags::IS_SIMD,
1814                    attr::ReprInt(i) => {
1815                        size = Some(match i {
1816                            attr::IntType::SignedInt(x) => match x {
1817                                ast::IntTy::Isize => IntegerType::Pointer(true),
1818                                ast::IntTy::I8 => IntegerType::Fixed(Integer::I8, true),
1819                                ast::IntTy::I16 => IntegerType::Fixed(Integer::I16, true),
1820                                ast::IntTy::I32 => IntegerType::Fixed(Integer::I32, true),
1821                                ast::IntTy::I64 => IntegerType::Fixed(Integer::I64, true),
1822                                ast::IntTy::I128 => IntegerType::Fixed(Integer::I128, true),
1823                            },
1824                            attr::IntType::UnsignedInt(x) => match x {
1825                                ast::UintTy::Usize => IntegerType::Pointer(false),
1826                                ast::UintTy::U8 => IntegerType::Fixed(Integer::I8, false),
1827                                ast::UintTy::U16 => IntegerType::Fixed(Integer::I16, false),
1828                                ast::UintTy::U32 => IntegerType::Fixed(Integer::I32, false),
1829                                ast::UintTy::U64 => IntegerType::Fixed(Integer::I64, false),
1830                                ast::UintTy::U128 => IntegerType::Fixed(Integer::I128, false),
1831                            },
1832                        });
1833                        ReprFlags::empty()
1834                    }
1835                    attr::ReprAlign(align) => {
1836                        max_align = max_align.max(Some(align));
1837                        ReprFlags::empty()
1838                    }
1839                });
1840            }
1841        }
1842
1843        // If `-Z randomize-layout` was enabled for the type definition then we can
1844        // consider performing layout randomization
1845        if self.sess.opts.unstable_opts.randomize_layout {
1846            flags.insert(ReprFlags::RANDOMIZE_LAYOUT);
1847        }
1848
1849        // box is special, on the one hand the compiler assumes an ordered layout, with the pointer
1850        // always at offset zero. On the other hand we want scalar abi optimizations.
1851        let is_box = self.is_lang_item(did.to_def_id(), LangItem::OwnedBox);
1852
1853        // This is here instead of layout because the choice must make it into metadata.
1854        if is_box {
1855            flags.insert(ReprFlags::IS_LINEAR);
1856        }
1857
1858        // See `TyAndLayout::pass_indirectly_in_non_rustic_abis` for details.
1859        if {
        {
            'done:
                {
                for i in ::rustc_attr_ir::HasAttrs::get_attrs(did, &self) {
                    #[allow(unused_imports)]
                    use ::rustc_attr_ir::AttributeKind::*;
                    let i: &::rustc_attr_ir::Attribute = i;
                    match i {
                        ::rustc_attr_ir::Attribute::Parsed(RustcPassIndirectlyInNonRusticAbis(..))
                            => {
                            break 'done Some(());
                        }
                        ::rustc_attr_ir::Attribute::Tool { .. } |
                            ::rustc_attr_ir::Attribute::DeriveHelper(..) =>
                            {}
                            #[deny(unreachable_patterns)]
                            _ => {}
                    }
                }
                None
            }
        }
    }.is_some()find_attr!(self, did, RustcPassIndirectlyInNonRusticAbis(..)) {
1860            flags.insert(ReprFlags::PASS_INDIRECTLY_IN_NON_RUSTIC_ABIS);
1861        }
1862
1863        ReprOptions {
1864            int: size,
1865            align: max_align,
1866            pack: min_pack,
1867            flags,
1868            field_shuffle_seed,
1869            scalable: elt,
1870        }
1871    }
1872
1873    /// Look up the name of a definition across crates. This does not look at HIR.
1874    pub fn opt_item_name(self, def_id: impl IntoQueryKey<DefId>) -> Option<Symbol> {
1875        let def_id = def_id.into_query_key();
1876        if let Some(cnum) = def_id.as_crate_root() {
1877            Some(self.crate_name(cnum))
1878        } else {
1879            let def_key = self.def_key(def_id);
1880            match def_key.disambiguated_data.data {
1881                // The name of a constructor is that of its parent.
1882                rustc_hir::definitions::DefPathData::Ctor => self
1883                    .opt_item_name(DefId { krate: def_id.krate, index: def_key.parent.unwrap() }),
1884                _ => def_key.get_opt_name(),
1885            }
1886        }
1887    }
1888
1889    /// Look up the name of a definition across crates. This does not look at HIR.
1890    ///
1891    /// This method will ICE if the corresponding item does not have a name. In these cases, use
1892    /// [`opt_item_name`] instead.
1893    ///
1894    /// [`opt_item_name`]: Self::opt_item_name
1895    pub fn item_name(self, id: impl IntoQueryKey<DefId>) -> Symbol {
1896        let id = id.into_query_key();
1897        self.opt_item_name(id).unwrap_or_else(|| {
1898            ::rustc_span::macros::bug_impl(None,
    format_args!("item_name: no name for {0:?}", self.def_path(id)),
    Location::caller());bug!("item_name: no name for {:?}", self.def_path(id));
1899        })
1900    }
1901
1902    /// Look up the name and span of a definition.
1903    ///
1904    /// See [`item_name`][Self::item_name] for more information.
1905    pub fn opt_item_ident(self, def_id: impl IntoQueryKey<DefId>) -> Option<Ident> {
1906        let def_id = def_id.into_query_key();
1907        let def = self.opt_item_name(def_id)?;
1908        let span = self
1909            .def_ident_span(def_id)
1910            .unwrap_or_else(|| ::rustc_span::macros::bug_impl(None,
    format_args!("missing ident span for {0:?}", def_id), Location::caller())bug!("missing ident span for {def_id:?}"));
1911        Some(Ident::new(def, span))
1912    }
1913
1914    /// Look up the name and span of a definition.
1915    ///
1916    /// See [`item_name`][Self::item_name] for more information.
1917    pub fn item_ident(self, def_id: impl IntoQueryKey<DefId>) -> Ident {
1918        let def_id = def_id.into_query_key();
1919        self.opt_item_ident(def_id).unwrap_or_else(|| {
1920            ::rustc_span::macros::bug_impl(None,
    format_args!("item_ident: no name for {0:?}", self.def_path(def_id)),
    Location::caller());bug!("item_ident: no name for {:?}", self.def_path(def_id));
1921        })
1922    }
1923
1924    pub fn opt_associated_item(self, def_id: DefId) -> Option<AssocItem> {
1925        if let DefKind::AssocConst | DefKind::AssocFn | DefKind::AssocTy = self.def_kind(def_id) {
1926            Some(self.associated_item(def_id))
1927        } else {
1928            None
1929        }
1930    }
1931
1932    /// If the `def_id` is an associated type that was desugared from a
1933    /// return-position `impl Trait` from a trait, then provide the source info
1934    /// about where that RPITIT came from.
1935    pub fn opt_rpitit_info(self, def_id: DefId) -> Option<ImplTraitInTraitData> {
1936        if let DefKind::AssocTy = self.def_kind(def_id)
1937            && let AssocKind::Type { data: AssocTypeData::Rpitit(rpitit_info) } =
1938                self.associated_item(def_id).kind
1939        {
1940            Some(rpitit_info)
1941        } else {
1942            None
1943        }
1944    }
1945
1946    pub fn find_field_index(self, ident: Ident, variant: &VariantDef) -> Option<FieldIdx> {
1947        variant.fields.iter_enumerated().find_map(|(i, field)| {
1948            self.hygienic_eq(ident, field.ident(self), variant.def_id).then_some(i)
1949        })
1950    }
1951
1952    /// Returns `Some` if the impls are the same polarity and the trait either
1953    /// has no items or is annotated `#[marker]` and prevents item overrides.
1954    {}
let __tracing_attr_span;
let __tracing_attr_guard;
if ::tracing::Level::DEBUG <= ::tracing::level_filters::STATIC_MAX_LEVEL &&
            ::tracing::Level::DEBUG <=
                ::tracing::level_filters::LevelFilter::current() || { false }
    {
    __tracing_attr_span =
        {
            use ::tracing::__macro_support::Callsite as _;
            static __CALLSITE: ::tracing::callsite::DefaultCallsite =
                {
                    static META: ::tracing::Metadata<'static> =
                        {
                            ::tracing_core::metadata::Metadata::new("impls_are_allowed_to_overlap",
                                "rustc_middle::ty", ::tracing::Level::DEBUG,
                                ::tracing_core::__macro_support::Option::Some("/rustc-dev/c82ce15637153c025d29abbaff6035a177361788/compiler/rustc_middle/src/ty/mod.rs"),
                                ::tracing_core::__macro_support::Option::Some(1954u32),
                                ::tracing_core::__macro_support::Option::Some("rustc_middle::ty"),
                                ::tracing_core::field::FieldSet::new(&[{
                                                    const NAME:
                                                        ::tracing::__macro_support::FieldName<{
                                                            ::tracing::__macro_support::FieldName::len("def_id1")
                                                        }> =
                                                        ::tracing::__macro_support::FieldName::new("def_id1");
                                                    NAME.as_str()
                                                },
                                                {
                                                    const NAME:
                                                        ::tracing::__macro_support::FieldName<{
                                                            ::tracing::__macro_support::FieldName::len("def_id2")
                                                        }> =
                                                        ::tracing::__macro_support::FieldName::new("def_id2");
                                                    NAME.as_str()
                                                }], ::tracing_core::callsite::Identifier(&__CALLSITE)),
                                ::tracing::metadata::Kind::SPAN)
                        };
                    ::tracing::callsite::DefaultCallsite::new(&META)
                };
            let mut interest = ::tracing::subscriber::Interest::never();
            if ::tracing::Level::DEBUG <=
                                ::tracing::level_filters::STATIC_MAX_LEVEL &&
                            ::tracing::Level::DEBUG <=
                                ::tracing::level_filters::LevelFilter::current() &&
                        { interest = __CALLSITE.interest(); !interest.is_never() }
                    &&
                    ::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
                        interest) {
                let meta = __CALLSITE.metadata();
                ::tracing::Span::new(meta,
                    &{
                            #[allow(unused_imports)]
                            use ::tracing::field::{debug, display, Value};
                            meta.fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&def_id1)
                                                        as &dyn ::tracing::field::Value)),
                                            (::tracing::__macro_support::Option::Some(&::tracing::field::debug(&def_id2)
                                                        as &dyn ::tracing::field::Value))])
                        })
            } else {
                let span =
                    ::tracing::__macro_support::__disabled_span(__CALLSITE.metadata());
                {};
                span
            }
        };
    __tracing_attr_guard = __tracing_attr_span.enter();
}
#[allow(clippy :: redundant_closure_call)]
let x =
    (move ||
                {

                    #[allow(unknown_lints, unreachable_code, clippy ::
                    diverging_sub_expression, clippy :: empty_loop, clippy ::
                    let_unit_value, clippy :: let_with_type_underscore, clippy
                    :: needless_return, clippy :: unreachable)]
                    if false {
                        let __tracing_attr_fake_return: Option<ImplOverlapKind> =
                            loop {};
                        return __tracing_attr_fake_return;
                    }
                    {
                        let impl1 = self.impl_trait_header(def_id1);
                        let impl2 = self.impl_trait_header(def_id2);
                        let trait_ref1 = impl1.trait_ref.skip_binder();
                        let trait_ref2 = impl2.trait_ref.skip_binder();
                        if trait_ref1.references_error() ||
                                trait_ref2.references_error() {
                            return Some(ImplOverlapKind::Permitted { marker: false });
                        }
                        match (impl1.polarity, impl2.polarity) {
                            (ImplPolarity::Positive, ImplPolarity::Negative) |
                                (ImplPolarity::Negative, ImplPolarity::Positive) => {
                                return None;
                            }
                            (ImplPolarity::Positive, ImplPolarity::Positive) |
                                (ImplPolarity::Negative, ImplPolarity::Negative) => {}
                        };
                        let is_marker_impl =
                            |trait_ref: TraitRef<'_>|
                                self.trait_def(trait_ref.def_id).is_marker;
                        let is_marker_overlap =
                            is_marker_impl(trait_ref1) && is_marker_impl(trait_ref2);
                        if is_marker_overlap {
                            return Some(ImplOverlapKind::Permitted { marker: true });
                        }
                        None
                    }
                })();
{
    use ::tracing::__macro_support::Callsite as _;
    static __CALLSITE: ::tracing::callsite::DefaultCallsite =
        {
            static META: ::tracing::Metadata<'static> =
                {
                    ::tracing_core::metadata::Metadata::new("event /rustc-dev/c82ce15637153c025d29abbaff6035a177361788/compiler/rustc_middle/src/ty/mod.rs:1954",
                        "rustc_middle::ty", ::tracing::Level::DEBUG,
                        ::tracing_core::__macro_support::Option::Some("/rustc-dev/c82ce15637153c025d29abbaff6035a177361788/compiler/rustc_middle/src/ty/mod.rs"),
                        ::tracing_core::__macro_support::Option::Some(1954u32),
                        ::tracing_core::__macro_support::Option::Some("rustc_middle::ty"),
                        ::tracing_core::field::FieldSet::new(&[{
                                            const NAME:
                                                ::tracing::__macro_support::FieldName<{
                                                    ::tracing::__macro_support::FieldName::len("return")
                                                }> =
                                                ::tracing::__macro_support::FieldName::new("return");
                                            NAME.as_str()
                                        }], ::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};
                __CALLSITE.metadata().fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&x)
                                            as &dyn ::tracing::field::Value))])
            });
    } else { ; }
};
x;#[instrument(level = "debug", skip(self), ret)]
1955    pub fn impls_are_allowed_to_overlap(
1956        self,
1957        def_id1: DefId,
1958        def_id2: DefId,
1959    ) -> Option<ImplOverlapKind> {
1960        let impl1 = self.impl_trait_header(def_id1);
1961        let impl2 = self.impl_trait_header(def_id2);
1962
1963        let trait_ref1 = impl1.trait_ref.skip_binder();
1964        let trait_ref2 = impl2.trait_ref.skip_binder();
1965
1966        // If either trait impl references an error, they're allowed to overlap,
1967        // as one of them essentially doesn't exist.
1968        if trait_ref1.references_error() || trait_ref2.references_error() {
1969            return Some(ImplOverlapKind::Permitted { marker: false });
1970        }
1971
1972        match (impl1.polarity, impl2.polarity) {
1973            (ImplPolarity::Positive, ImplPolarity::Negative)
1974            | (ImplPolarity::Negative, ImplPolarity::Positive) => {
1975                // `impl AutoTrait for Type` + `impl !AutoTrait for Type`
1976                return None;
1977            }
1978            (ImplPolarity::Positive, ImplPolarity::Positive)
1979            | (ImplPolarity::Negative, ImplPolarity::Negative) => {}
1980        };
1981
1982        let is_marker_impl = |trait_ref: TraitRef<'_>| self.trait_def(trait_ref.def_id).is_marker;
1983        let is_marker_overlap = is_marker_impl(trait_ref1) && is_marker_impl(trait_ref2);
1984
1985        if is_marker_overlap {
1986            return Some(ImplOverlapKind::Permitted { marker: true });
1987        }
1988
1989        None
1990    }
1991
1992    /// Returns `ty::VariantDef` if `res` refers to a struct,
1993    /// or variant or their constructors, panics otherwise.
1994    pub fn expect_variant_res(self, res: Res) -> &'tcx VariantDef {
1995        match res {
1996            Res::Def(DefKind::Variant, did) => {
1997                let enum_did = self.parent(did);
1998                self.adt_def(enum_did).variant_with_id(did)
1999            }
2000            Res::Def(DefKind::Struct | DefKind::Union, did) => self.adt_def(did).non_enum_variant(),
2001            Res::Def(DefKind::Ctor(CtorOf::Variant, ..), variant_ctor_did) => {
2002                let variant_did = self.parent(variant_ctor_did);
2003                let enum_did = self.parent(variant_did);
2004                self.adt_def(enum_did).variant_with_ctor_id(variant_ctor_did)
2005            }
2006            Res::Def(DefKind::Ctor(CtorOf::Struct, ..), ctor_did) => {
2007                let struct_did = self.parent(ctor_did);
2008                self.adt_def(struct_did).non_enum_variant()
2009            }
2010            _ => ::rustc_span::macros::bug_impl(None,
    format_args!("expect_variant_res used with unexpected res {0:?}", res),
    Location::caller())bug!("expect_variant_res used with unexpected res {:?}", res),
2011        }
2012    }
2013
2014    /// Returns the possibly-auto-generated MIR of a [`ty::InstanceKind`].
2015    {}
#[allow(clippy :: suspicious_else_formatting)]
{
    let __tracing_attr_span;
    let __tracing_attr_guard;
    if ::tracing::Level::DEBUG <= ::tracing::level_filters::STATIC_MAX_LEVEL
                &&
                ::tracing::Level::DEBUG <=
                    ::tracing::level_filters::LevelFilter::current() ||
            { false } {
        __tracing_attr_span =
            {
                use ::tracing::__macro_support::Callsite as _;
                static __CALLSITE: ::tracing::callsite::DefaultCallsite =
                    {
                        static META: ::tracing::Metadata<'static> =
                            {
                                ::tracing_core::metadata::Metadata::new("instance_mir",
                                    "rustc_middle::ty", ::tracing::Level::DEBUG,
                                    ::tracing_core::__macro_support::Option::Some("/rustc-dev/c82ce15637153c025d29abbaff6035a177361788/compiler/rustc_middle/src/ty/mod.rs"),
                                    ::tracing_core::__macro_support::Option::Some(2015u32),
                                    ::tracing_core::__macro_support::Option::Some("rustc_middle::ty"),
                                    ::tracing_core::field::FieldSet::new(&[{
                                                        const NAME:
                                                            ::tracing::__macro_support::FieldName<{
                                                                ::tracing::__macro_support::FieldName::len("instance")
                                                            }> =
                                                            ::tracing::__macro_support::FieldName::new("instance");
                                                        NAME.as_str()
                                                    }], ::tracing_core::callsite::Identifier(&__CALLSITE)),
                                    ::tracing::metadata::Kind::SPAN)
                            };
                        ::tracing::callsite::DefaultCallsite::new(&META)
                    };
                let mut interest = ::tracing::subscriber::Interest::never();
                if ::tracing::Level::DEBUG <=
                                    ::tracing::level_filters::STATIC_MAX_LEVEL &&
                                ::tracing::Level::DEBUG <=
                                    ::tracing::level_filters::LevelFilter::current() &&
                            { interest = __CALLSITE.interest(); !interest.is_never() }
                        &&
                        ::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
                            interest) {
                    let meta = __CALLSITE.metadata();
                    ::tracing::Span::new(meta,
                        &{
                                #[allow(unused_imports)]
                                use ::tracing::field::{debug, display, Value};
                                meta.fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&instance)
                                                            as &dyn ::tracing::field::Value))])
                            })
                } else {
                    let span =
                        ::tracing::__macro_support::__disabled_span(__CALLSITE.metadata());
                    {};
                    span
                }
            };
        __tracing_attr_guard = __tracing_attr_span.enter();
    }

    #[warn(clippy :: suspicious_else_formatting)]
    {

        #[allow(unknown_lints, unreachable_code, clippy ::
        diverging_sub_expression, clippy :: empty_loop, clippy ::
        let_unit_value, clippy :: let_with_type_underscore, clippy ::
        needless_return, clippy :: unreachable)]
        if false {
            let __tracing_attr_fake_return: &'tcx Body<'tcx> = loop {};
            return __tracing_attr_fake_return;
        }
        {
            let body =
                match instance {
                    ty::InstanceKind::Item(def) => {
                        {
                            use ::tracing::__macro_support::Callsite as _;
                            static __CALLSITE: ::tracing::callsite::DefaultCallsite =
                                {
                                    static META: ::tracing::Metadata<'static> =
                                        {
                                            ::tracing_core::metadata::Metadata::new("event /rustc-dev/c82ce15637153c025d29abbaff6035a177361788/compiler/rustc_middle/src/ty/mod.rs:2019",
                                                "rustc_middle::ty", ::tracing::Level::DEBUG,
                                                ::tracing_core::__macro_support::Option::Some("/rustc-dev/c82ce15637153c025d29abbaff6035a177361788/compiler/rustc_middle/src/ty/mod.rs"),
                                                ::tracing_core::__macro_support::Option::Some(2019u32),
                                                ::tracing_core::__macro_support::Option::Some("rustc_middle::ty"),
                                                ::tracing_core::field::FieldSet::new(&["message"],
                                                    ::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};
                                        __CALLSITE.metadata().fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&format_args!("calling def_kind on def: {0:?}",
                                                                            def) as &dyn ::tracing::field::Value))])
                                    });
                            } else { ; }
                        };
                        let def_kind = self.def_kind(def);
                        {
                            use ::tracing::__macro_support::Callsite as _;
                            static __CALLSITE: ::tracing::callsite::DefaultCallsite =
                                {
                                    static META: ::tracing::Metadata<'static> =
                                        {
                                            ::tracing_core::metadata::Metadata::new("event /rustc-dev/c82ce15637153c025d29abbaff6035a177361788/compiler/rustc_middle/src/ty/mod.rs:2021",
                                                "rustc_middle::ty", ::tracing::Level::DEBUG,
                                                ::tracing_core::__macro_support::Option::Some("/rustc-dev/c82ce15637153c025d29abbaff6035a177361788/compiler/rustc_middle/src/ty/mod.rs"),
                                                ::tracing_core::__macro_support::Option::Some(2021u32),
                                                ::tracing_core::__macro_support::Option::Some("rustc_middle::ty"),
                                                ::tracing_core::field::FieldSet::new(&["message"],
                                                    ::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};
                                        __CALLSITE.metadata().fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&format_args!("returned from def_kind: {0:?}",
                                                                            def_kind) as &dyn ::tracing::field::Value))])
                                    });
                            } else { ; }
                        };
                        match def_kind {
                            DefKind::Const | DefKind::Static { .. } |
                                DefKind::AssocConst | DefKind::Ctor(..) | DefKind::AnonConst
                                => self.mir_for_ctfe(def),
                            DefKind::Fn | DefKind::AssocFn if
                                #[allow(non_exhaustive_omitted_patterns)] match self.constness(def)
                                    {
                                    hir::Constness::Const { always: true } => true,
                                    _ => false,
                                } => {
                                self.mir_for_ctfe(def)
                            }
                            _ => self.optimized_mir(def),
                        }
                    }
                    ty::InstanceKind::Intrinsic(..) |
                        ty::InstanceKind::LlvmIntrinsic(..) => {
                        ::rustc_span::macros::bug_impl(None,
                            format_args!("intrinsics have no instance MIR"),
                            Location::caller())
                    }
                    ty::InstanceKind::Virtual(..) =>
                        ::rustc_span::macros::bug_impl(None,
                            format_args!("virtual dispatches have no instance MIR"),
                            Location::caller()),
                    ty::InstanceKind::Shim(shim) => self.mir_shims(shim),
                };
            if !#[allow(non_exhaustive_omitted_patterns)] match body.phase {
                        MirPhase::Runtime(_) => true,
                        _ => false,
                    } {
                {
                    ::core::panicking::panic_fmt(format_args!("body: {1:?} instance: {2:?} {0:?}",
                            if let ty::InstanceKind::Item(d) = instance {
                                Some(self.def_kind(d))
                            } else { None }, body, instance));
                }
            };
            body
        }
    }
}#[instrument(skip(self), level = "debug")]
2016    pub fn instance_mir(self, instance: ty::InstanceKind<'tcx>) -> &'tcx Body<'tcx> {
2017        let body = match instance {
2018            ty::InstanceKind::Item(def) => {
2019                debug!("calling def_kind on def: {:?}", def);
2020                let def_kind = self.def_kind(def);
2021                debug!("returned from def_kind: {:?}", def_kind);
2022                match def_kind {
2023                    DefKind::Const
2024                    | DefKind::Static { .. }
2025                    | DefKind::AssocConst
2026                    | DefKind::Ctor(..)
2027                    | DefKind::AnonConst => self.mir_for_ctfe(def),
2028                    DefKind::Fn | DefKind::AssocFn
2029                        if matches!(
2030                            self.constness(def),
2031                            hir::Constness::Const { always: true }
2032                        ) =>
2033                    {
2034                        self.mir_for_ctfe(def)
2035                    }
2036                    // If the caller wants `mir_for_ctfe` of a function they should not be using
2037                    // `instance_mir`, so we'll assume const fn also wants the optimized version.
2038                    _ => self.optimized_mir(def),
2039                }
2040            }
2041            ty::InstanceKind::Intrinsic(..) | ty::InstanceKind::LlvmIntrinsic(..) => {
2042                bug!("intrinsics have no instance MIR")
2043            }
2044            ty::InstanceKind::Virtual(..) => bug!("virtual dispatches have no instance MIR"),
2045            ty::InstanceKind::Shim(shim) => self.mir_shims(shim),
2046        };
2047
2048        assert!(
2049            matches!(body.phase, MirPhase::Runtime(_)),
2050            "body: {body:?} instance: {instance:?} {:?}",
2051            if let ty::InstanceKind::Item(d) = instance { Some(self.def_kind(d)) } else { None },
2052        );
2053
2054        body
2055    }
2056
2057    /// Gets all tool attributes named `name`.
2058    pub fn tool_attrs(
2059        self,
2060        did: impl Into<DefId>,
2061        name: &[Symbol],
2062    ) -> impl Iterator<Item = &'tcx rustc_attr_ir::AttrItem> {
2063        #[expect(deprecated)]
2064        self.get_all_attrs(did).iter().filter_map(|attr| {
2065            if let rustc_attr_ir::Attribute::Tool { item: t, .. } = attr
2066                && *t.path.segments == *name
2067            {
2068                Some(&**t)
2069            } else {
2070                None
2071            }
2072        })
2073    }
2074
2075    /// Gets all attributes.
2076    ///
2077    /// <div class="warning">
2078    ///
2079    /// To see if an item has a specific attribute, you should use
2080    /// [`rustc_attr_ir::find_attr!`] so you can use matching.
2081    ///
2082    /// </div>
2083    ///
2084    #[deprecated = "Though there are valid usecases for this method, usually you want to use `rustc_attr_ir::find_attr!` or `tool_attrs` instead."]
2085    pub fn get_all_attrs(self, did: impl Into<DefId>) -> &'tcx [rustc_attr_ir::Attribute] {
2086        let did: DefId = did.into();
2087        if let Some(did) = did.as_local() {
2088            self.hir_attrs(self.local_def_id_to_hir_id(did))
2089        } else {
2090            self.attrs_for_def(did)
2091        }
2092    }
2093
2094    /// Returns `true` if this is an `auto trait`.
2095    pub fn trait_is_auto(self, trait_def_id: DefId) -> bool {
2096        self.trait_def(trait_def_id).has_auto_impl
2097    }
2098
2099    /// Returns `true` if this is coinductive, either because it is
2100    /// an auto trait or because it has the `#[rustc_coinductive]` attribute.
2101    pub fn trait_is_coinductive(self, trait_def_id: DefId) -> bool {
2102        self.trait_def(trait_def_id).is_coinductive
2103    }
2104
2105    /// Returns `true` if this is a trait alias.
2106    pub fn trait_is_alias(self, trait_def_id: DefId) -> bool {
2107        self.def_kind(trait_def_id) == DefKind::TraitAlias
2108    }
2109
2110    /// Arena-alloc of LayoutError for coroutine layout
2111    fn layout_error(self, err: LayoutError<'tcx>) -> &'tcx LayoutError<'tcx> {
2112        self.arena.alloc(err)
2113    }
2114
2115    /// Returns layout of a non-async-drop coroutine. Layout might be unavailable if the
2116    /// coroutine is tainted by errors.
2117    ///
2118    /// Takes `coroutine_kind` which can be acquired from the `CoroutineArgs::kind_ty`,
2119    /// e.g. `args.as_coroutine().kind_ty()`.
2120    fn ordinary_coroutine_layout(
2121        self,
2122        def_id: DefId,
2123        args: GenericArgs<'tcx>,
2124    ) -> Result<&'tcx CoroutineLayout<'tcx>, &'tcx LayoutError<'tcx>> {
2125        let coroutine_kind_ty = args.as_coroutine().kind_ty();
2126        let mir = self.optimized_mir(def_id);
2127        let ty = || Ty::new_coroutine(self, def_id, args);
2128        // Regular coroutine
2129        if coroutine_kind_ty.is_unit() {
2130            mir.coroutine_layout_raw().ok_or_else(|| self.layout_error(LayoutError::Unknown(ty())))
2131        } else {
2132            // If we have a `Coroutine` that comes from an coroutine-closure,
2133            // then it may be a by-move or by-ref body.
2134            let ty::Coroutine(_, identity_args) =
2135                *self.type_of(def_id).instantiate_identity().skip_norm_wip().kind()
2136            else {
2137                ::core::panicking::unreachable_default_msg();unreachable!();
2138            };
2139            let identity_kind_ty = identity_args.as_coroutine().kind_ty();
2140            // If the types differ, then we must be getting the by-move body of
2141            // a by-ref coroutine.
2142            if identity_kind_ty == coroutine_kind_ty {
2143                mir.coroutine_layout_raw()
2144                    .ok_or_else(|| self.layout_error(LayoutError::Unknown(ty())))
2145            } else {
2146                {
    match coroutine_kind_ty.to_opt_closure_kind() {
        Some(ClosureKind::FnOnce) => {}
        ref left_val => {
            ::core::panicking::assert_matches_failed(left_val,
                "Some(ClosureKind::FnOnce)", ::core::option::Option::None);
        }
    }
};assert_matches!(coroutine_kind_ty.to_opt_closure_kind(), Some(ClosureKind::FnOnce));
2147                {
    match identity_kind_ty.to_opt_closure_kind() {
        Some(ClosureKind::Fn | ClosureKind::FnMut) => {}
        ref left_val => {
            ::core::panicking::assert_matches_failed(left_val,
                "Some(ClosureKind::Fn | ClosureKind::FnMut)",
                ::core::option::Option::None);
        }
    }
};assert_matches!(
2148                    identity_kind_ty.to_opt_closure_kind(),
2149                    Some(ClosureKind::Fn | ClosureKind::FnMut)
2150                );
2151                self.optimized_mir(self.coroutine_by_move_body_def_id(def_id))
2152                    .coroutine_layout_raw()
2153                    .ok_or_else(|| self.layout_error(LayoutError::Unknown(ty())))
2154            }
2155        }
2156    }
2157
2158    /// Returns layout of a `async_drop_in_place::{closure}` coroutine
2159    ///   (returned from `async fn async_drop_in_place<T>(..)`).
2160    /// Layout might be unavailable if the coroutine is tainted by errors.
2161    fn async_drop_coroutine_layout(
2162        self,
2163        def_id: DefId,
2164        args: GenericArgs<'tcx>,
2165    ) -> Result<&'tcx CoroutineLayout<'tcx>, &'tcx LayoutError<'tcx>> {
2166        let ty = || Ty::new_coroutine(self, def_id, args);
2167        if args[0].has_placeholders() || args[0].has_non_region_param() {
2168            return Err(self.layout_error(LayoutError::TooGeneric(ty())));
2169        }
2170        let instance = ShimKind::AsyncDropGlue(def_id, Ty::new_coroutine(self, def_id, args));
2171        self.mir_shims(instance)
2172            .coroutine_layout_raw()
2173            .ok_or_else(|| self.layout_error(LayoutError::Unknown(ty())))
2174    }
2175
2176    /// Returns layout of a coroutine. Layout might be unavailable if the
2177    /// coroutine is tainted by errors.
2178    pub fn coroutine_layout(
2179        self,
2180        def_id: DefId,
2181        args: GenericArgs<'tcx>,
2182    ) -> Result<&'tcx CoroutineLayout<'tcx>, &'tcx LayoutError<'tcx>> {
2183        if self.is_async_drop_in_place_coroutine(def_id) {
2184            // layout of `async_drop_in_place<T>::{closure}` in case,
2185            // when T is a coroutine, contains this internal coroutine's ptr in upvars
2186            // and doesn't require any locals. Here is an `empty coroutine's layout`
2187            let arg_cor_ty = args.first().unwrap().expect_ty();
2188            if arg_cor_ty.is_coroutine() {
2189                let span = self.def_span(def_id);
2190                let source_info = SourceInfo::outermost(span);
2191                // Even minimal, empty coroutine has 3 states (RESERVED_VARIANTS),
2192                // so variant_fields and variant_source_info should have 3 elements.
2193                let variant_fields: IndexVec<VariantIdx, IndexVec<FieldIdx, CoroutineSavedLocal>> =
2194                    iter::repeat(IndexVec::new()).take(CoroutineArgs::RESERVED_VARIANTS).collect();
2195                let variant_source_info: IndexVec<VariantIdx, SourceInfo> =
2196                    iter::repeat(source_info).take(CoroutineArgs::RESERVED_VARIANTS).collect();
2197                let proxy_layout = CoroutineLayout {
2198                    field_tys: [].into(),
2199                    variant_fields,
2200                    variant_source_info,
2201                    storage_conflicts: BitMatrix::new(0, 0),
2202                    // FIXME(-Zpack-coroutine-layout): Stop ignoring the flag here.
2203                    pack: rustc_abi::PackCoroutineLayout::Classic,
2204                };
2205                return Ok(self.arena.alloc(proxy_layout));
2206            } else {
2207                self.async_drop_coroutine_layout(def_id, args)
2208            }
2209        } else {
2210            self.ordinary_coroutine_layout(def_id, args)
2211        }
2212    }
2213
2214    /// If the given `DefId` is an associated item, returns the `DefId` and `DefKind` of the parent trait or impl.
2215    pub fn assoc_parent(self, def_id: DefId) -> Option<(DefId, DefKind)> {
2216        if !self.def_kind(def_id).is_assoc() {
2217            return None;
2218        }
2219        let parent = self.parent(def_id);
2220        let def_kind = self.def_kind(parent);
2221        Some((parent, def_kind))
2222    }
2223
2224    /// Returns the trait item that is implemented by the given item `DefId`.
2225    pub fn trait_item_of(self, def_id: impl IntoQueryKey<DefId>) -> Option<DefId> {
2226        let def_id = def_id.into_query_key();
2227        self.opt_associated_item(def_id)?.trait_item_def_id()
2228    }
2229
2230    /// If the given `DefId` is an associated item of a trait,
2231    /// returns the `DefId` of the trait; otherwise, returns `None`.
2232    pub fn trait_of_assoc(self, def_id: DefId) -> Option<DefId> {
2233        match self.assoc_parent(def_id) {
2234            Some((id, DefKind::Trait)) => Some(id),
2235            _ => None,
2236        }
2237    }
2238
2239    pub fn impl_is_of_trait(self, def_id: impl IntoQueryKey<DefId>) -> bool {
2240        let def_id = def_id.into_query_key();
2241        let DefKind::Impl { of_trait } = self.def_kind(def_id) else {
2242            {
    ::core::panicking::panic_fmt(format_args!("expected Impl for {0:?}",
            def_id));
};panic!("expected Impl for {def_id:?}");
2243        };
2244        of_trait
2245    }
2246
2247    /// If the given `DefId` is an associated item of an impl,
2248    /// returns the `DefId` of the impl; otherwise returns `None`.
2249    pub fn impl_of_assoc(self, def_id: DefId) -> Option<DefId> {
2250        match self.assoc_parent(def_id) {
2251            Some((id, DefKind::Impl { .. })) => Some(id),
2252            _ => None,
2253        }
2254    }
2255
2256    /// If the given `DefId` is an associated item of an inherent impl,
2257    /// returns the `DefId` of the impl; otherwise, returns `None`.
2258    pub fn inherent_impl_of_assoc(self, def_id: DefId) -> Option<DefId> {
2259        match self.assoc_parent(def_id) {
2260            Some((id, DefKind::Impl { of_trait: false })) => Some(id),
2261            _ => None,
2262        }
2263    }
2264
2265    /// If the given `DefId` is an associated item of a trait impl,
2266    /// returns the `DefId` of the impl; otherwise, returns `None`.
2267    pub fn trait_impl_of_assoc(self, def_id: DefId) -> Option<DefId> {
2268        match self.assoc_parent(def_id) {
2269            Some((id, DefKind::Impl { of_trait: true })) => Some(id),
2270            _ => None,
2271        }
2272    }
2273
2274    pub fn impl_polarity(self, def_id: impl IntoQueryKey<DefId>) -> ty::ImplPolarity {
2275        let def_id = def_id.into_query_key();
2276        self.impl_trait_header(def_id).polarity
2277    }
2278
2279    /// Given an `impl_id`, return the trait it implements.
2280    pub fn impl_trait_ref(
2281        self,
2282        def_id: impl IntoQueryKey<DefId>,
2283    ) -> ty::EarlyBinder<'tcx, ty::TraitRef<'tcx>> {
2284        let def_id = def_id.into_query_key();
2285        self.impl_trait_header(def_id).trait_ref
2286    }
2287
2288    /// Given an `impl_id`, return the trait it implements.
2289    /// Returns `None` if it is an inherent impl.
2290    pub fn impl_opt_trait_ref(
2291        self,
2292        def_id: impl IntoQueryKey<DefId>,
2293    ) -> Option<ty::EarlyBinder<'tcx, ty::TraitRef<'tcx>>> {
2294        let def_id = def_id.into_query_key();
2295        self.impl_is_of_trait(def_id).then(|| self.impl_trait_ref(def_id))
2296    }
2297
2298    /// Given the `DefId` of an impl, returns the `DefId` of the trait it implements.
2299    pub fn impl_trait_id(self, def_id: impl IntoQueryKey<DefId>) -> DefId {
2300        let def_id = def_id.into_query_key();
2301        self.impl_trait_ref(def_id).skip_binder().def_id
2302    }
2303
2304    /// Given the `DefId` of an impl, returns the `DefId` of the trait it implements.
2305    /// Returns `None` if it is an inherent impl.
2306    pub fn impl_opt_trait_id(self, def_id: impl IntoQueryKey<DefId>) -> Option<DefId> {
2307        let def_id = def_id.into_query_key();
2308        self.impl_is_of_trait(def_id).then(|| self.impl_trait_id(def_id))
2309    }
2310
2311    pub fn is_exportable(self, def_id: DefId) -> bool {
2312        self.exportable_items(def_id.krate).contains(&def_id)
2313    }
2314
2315    /// Check if the given `DefId` is `#\[automatically_derived\]`, *and*
2316    /// whether it was produced by expanding a builtin derive macro.
2317    pub fn is_builtin_derived(self, def_id: DefId) -> bool {
2318        if self.is_automatically_derived(def_id)
2319            && let Some(def_id) = def_id.as_local()
2320            && let outer = self.def_span(def_id).ctxt().outer_expn_data()
2321            && #[allow(non_exhaustive_omitted_patterns)] match outer.kind {
    ExpnKind::Macro(MacroKind::Derive, _) => true,
    _ => false,
}matches!(outer.kind, ExpnKind::Macro(MacroKind::Derive, _))
2322            && {
        {
            'done:
                {
                for i in
                    ::rustc_attr_ir::HasAttrs::get_attrs(outer.macro_def_id.unwrap(),
                        &self) {
                    #[allow(unused_imports)]
                    use ::rustc_attr_ir::AttributeKind::*;
                    let i: &::rustc_attr_ir::Attribute = i;
                    match i {
                        ::rustc_attr_ir::Attribute::Parsed(RustcBuiltinMacro { .. })
                            => {
                            break 'done Some(());
                        }
                        ::rustc_attr_ir::Attribute::Tool { .. } |
                            ::rustc_attr_ir::Attribute::DeriveHelper(..) =>
                            {}
                            #[deny(unreachable_patterns)]
                            _ => {}
                    }
                }
                None
            }
        }
    }.is_some()find_attr!(self, outer.macro_def_id.unwrap(), RustcBuiltinMacro { .. })
2323        {
2324            true
2325        } else {
2326            false
2327        }
2328    }
2329
2330    /// Check if the given `DefId` is `#\[automatically_derived\]`.
2331    pub fn is_automatically_derived(self, def_id: DefId) -> bool {
2332        {
        {
            'done:
                {
                for i in ::rustc_attr_ir::HasAttrs::get_attrs(def_id, &self) {
                    #[allow(unused_imports)]
                    use ::rustc_attr_ir::AttributeKind::*;
                    let i: &::rustc_attr_ir::Attribute = i;
                    match i {
                        ::rustc_attr_ir::Attribute::Parsed(AutomaticallyDerived) =>
                            {
                            break 'done Some(());
                        }
                        ::rustc_attr_ir::Attribute::Tool { .. } |
                            ::rustc_attr_ir::Attribute::DeriveHelper(..) =>
                            {}
                            #[deny(unreachable_patterns)]
                            _ => {}
                    }
                }
                None
            }
        }
    }.is_some()find_attr!(self, def_id, AutomaticallyDerived)
2333    }
2334
2335    /// Looks up the span of `impl_did` if the impl is local; otherwise returns `Err`
2336    /// with the name of the crate containing the impl.
2337    pub fn span_of_impl(self, impl_def_id: DefId) -> Result<Span, Symbol> {
2338        if let Some(impl_def_id) = impl_def_id.as_local() {
2339            Ok(self.def_span(impl_def_id))
2340        } else {
2341            Err(self.crate_name(impl_def_id.krate))
2342        }
2343    }
2344
2345    /// Hygienically compares a use-site name (`use_name`) for a field or an associated item with
2346    /// its supposed definition name (`def_name`). The method also needs `DefId` of the supposed
2347    /// definition's parent/scope to perform comparison.
2348    pub fn hygienic_eq(self, use_ident: Ident, def_ident: Ident, def_parent_def_id: DefId) -> bool {
2349        // We could use `Ident::eq` here, but we deliberately don't. The identifier
2350        // comparison fails frequently, and we want to avoid the expensive
2351        // `normalize_to_macros_2_0()` calls required for the span comparison whenever possible.
2352        use_ident.name == def_ident.name
2353            && use_ident
2354                .span
2355                .ctxt()
2356                .hygienic_eq(def_ident.span.ctxt(), self.expn_that_defined(def_parent_def_id))
2357    }
2358
2359    pub fn adjust_ident(self, mut ident: Ident, scope: DefId) -> Ident {
2360        ident.span.normalize_to_macros_2_0_and_adjust(self.expn_that_defined(scope));
2361        ident
2362    }
2363
2364    pub fn adjust_ident_and_get_scope(
2365        self,
2366        mut ident: Ident,
2367        scope: DefId,
2368        mod_id: LocalModId,
2369    ) -> (Ident, ModId) {
2370        let scope = ident
2371            .span
2372            .normalize_to_macros_2_0_and_adjust(self.expn_that_defined(scope))
2373            .and_then(|actual_expansion| actual_expansion.expn_data().parent_module)
2374            .unwrap_or(mod_id.to_mod_id());
2375        (ident, scope)
2376    }
2377
2378    /// Checks whether this is a `const fn`. Returns `false` for non-functions.
2379    ///
2380    /// Even if this returns `true`, constness may still be unstable!
2381    #[inline]
2382    pub fn is_const_fn(self, def_id: impl IntoQueryKey<DefId>) -> bool {
2383        let def_id = def_id.into_query_key();
2384        #[allow(non_exhaustive_omitted_patterns)] match self.def_kind(def_id) {
    DefKind::Fn | DefKind::AssocFn | DefKind::Ctor(_, CtorKind::Fn) |
        DefKind::Closure => true,
    _ => false,
}matches!(
2385            self.def_kind(def_id),
2386            DefKind::Fn | DefKind::AssocFn | DefKind::Ctor(_, CtorKind::Fn) | DefKind::Closure
2387        ) && #[allow(non_exhaustive_omitted_patterns)] match self.constness(def_id) {
    hir::Constness::Const { .. } => true,
    _ => false,
}matches!(self.constness(def_id), hir::Constness::Const { .. })
2388    }
2389
2390    /// Whether this item is conditionally constant for the purposes of the
2391    /// effects implementation.
2392    ///
2393    /// This roughly corresponds to all const functions and other callable
2394    /// items, along with const impls and traits, and associated types within
2395    /// those impls and traits.
2396    pub fn is_conditionally_const(self, def_id: impl Into<DefId>) -> bool {
2397        let def_id: DefId = def_id.into();
2398        match self.def_kind(def_id) {
2399            DefKind::Impl { of_trait: true } => {
2400                let header = self.impl_trait_header(def_id);
2401                #[allow(non_exhaustive_omitted_patterns)] match header.constness {
    hir::Constness::Const { always: false } => true,
    _ => false,
}matches!(header.constness, hir::Constness::Const { always: false })
2402                    && self.is_const_trait(header.trait_ref.skip_binder().def_id)
2403            }
2404            DefKind::Impl { of_trait: false } => {
2405                #[allow(non_exhaustive_omitted_patterns)] match self.constness(def_id) {
    hir::Constness::Const { always: false } => true,
    _ => false,
}matches!(self.constness(def_id), hir::Constness::Const { always: false })
2406            }
2407            DefKind::Fn | DefKind::Ctor(_, CtorKind::Fn) => {
2408                #[allow(non_exhaustive_omitted_patterns)] match self.constness(def_id) {
    hir::Constness::Const { always: false } => true,
    _ => false,
}matches!(self.constness(def_id), hir::Constness::Const { always: false })
2409            }
2410            DefKind::TraitAlias | DefKind::Trait => self.is_const_trait(def_id),
2411            DefKind::AssocTy => {
2412                let parent_def_id = self.parent(def_id);
2413                match self.def_kind(parent_def_id) {
2414                    DefKind::Impl { of_trait: false } => false,
2415                    DefKind::Impl { of_trait: true } | DefKind::Trait => {
2416                        self.is_conditionally_const(parent_def_id)
2417                    }
2418                    _ => ::rustc_span::macros::bug_impl(None,
    format_args!("unexpected parent item of associated type: {0:?}",
        parent_def_id), Location::caller())bug!("unexpected parent item of associated type: {parent_def_id:?}"),
2419                }
2420            }
2421            DefKind::AssocFn => {
2422                let parent_def_id = self.parent(def_id);
2423                match self.def_kind(parent_def_id) {
2424                    DefKind::Impl { of_trait: false } => {
2425                        #[allow(non_exhaustive_omitted_patterns)] match self.constness(def_id) {
    hir::Constness::Const { always: false } => true,
    _ => false,
}matches!(self.constness(def_id), hir::Constness::Const { always: false })
2426                    }
2427                    DefKind::Impl { of_trait: true } => {
2428                        let Some(trait_method_did) = self.trait_item_of(def_id) else {
2429                            return false;
2430                        };
2431                        #[allow(non_exhaustive_omitted_patterns)] match self.constness(trait_method_did)
    {
    hir::Constness::Const { always: false } => true,
    _ => false,
}matches!(
2432                            self.constness(trait_method_did),
2433                            hir::Constness::Const { always: false }
2434                        ) && self.is_conditionally_const(parent_def_id)
2435                    }
2436                    DefKind::Trait => {
2437                        #[allow(non_exhaustive_omitted_patterns)] match self.constness(def_id) {
    hir::Constness::Const { always: false } => true,
    _ => false,
}matches!(self.constness(def_id), hir::Constness::Const { always: false })
2438                            && self.is_conditionally_const(parent_def_id)
2439                    }
2440                    _ => ::rustc_span::macros::bug_impl(None,
    format_args!("unexpected parent item of associated fn: {0:?}",
        parent_def_id), Location::caller())bug!("unexpected parent item of associated fn: {parent_def_id:?}"),
2441                }
2442            }
2443            DefKind::OpaqueTy => match self.opaque_ty_origin(def_id) {
2444                hir::OpaqueTyOrigin::FnReturn { parent, .. } => self.is_conditionally_const(parent),
2445                hir::OpaqueTyOrigin::AsyncFn { .. } => false,
2446                // FIXME(const_trait_impl): ATPITs could be conditionally const?
2447                hir::OpaqueTyOrigin::TyAlias { .. } => false,
2448            },
2449            DefKind::Closure => {
2450                #[allow(non_exhaustive_omitted_patterns)] match self.constness(def_id) {
    hir::Constness::Const { always: false } => true,
    _ => false,
}matches!(self.constness(def_id), hir::Constness::Const { always: false })
2451            }
2452            DefKind::Ctor(_, CtorKind::Const)
2453            | DefKind::Mod
2454            | DefKind::Struct
2455            | DefKind::Union
2456            | DefKind::Enum
2457            | DefKind::Variant
2458            | DefKind::TyAlias
2459            | DefKind::ForeignTy
2460            | DefKind::TyParam
2461            | DefKind::Const
2462            | DefKind::ConstParam
2463            | DefKind::Static { .. }
2464            | DefKind::AssocConst
2465            | DefKind::Macro(_)
2466            | DefKind::ExternCrate
2467            | DefKind::Use
2468            | DefKind::ForeignMod
2469            | DefKind::AnonConst
2470            | DefKind::Field
2471            | DefKind::LifetimeParam
2472            | DefKind::GlobalAsm
2473            | DefKind::SyntheticCoroutineBody
2474            | DefKind::TestBinderConstraints => false,
2475        }
2476    }
2477
2478    #[inline]
2479    pub fn is_const_trait(self, def_id: DefId) -> bool {
2480        #[allow(non_exhaustive_omitted_patterns)] match self.trait_def(def_id).constness
    {
    hir::Constness::Const { .. } => true,
    _ => false,
}matches!(self.trait_def(def_id).constness, hir::Constness::Const { .. })
2481    }
2482
2483    pub fn impl_method_has_trait_impl_trait_tys(self, def_id: DefId) -> bool {
2484        if self.def_kind(def_id) != DefKind::AssocFn {
2485            return false;
2486        }
2487
2488        let Some(item) = self.opt_associated_item(def_id) else {
2489            return false;
2490        };
2491
2492        let AssocContainer::TraitImpl(Ok(trait_item_def_id)) = item.container else {
2493            return false;
2494        };
2495
2496        !self.associated_types_for_impl_traits_in_associated_fn(trait_item_def_id).is_empty()
2497    }
2498
2499    /// Compute a `FnAbi` suitable for declaring/defining an `fn` instance, and for direct calls*
2500    /// to an `fn`. Indirectly-passed parameters in the returned ABI will include applicable
2501    /// codegen optimization attributes, including `ReadOnly` and `CapturesNone` -- deduction of
2502    /// which requires inspection of function bodies that can lead to cycles when performed during
2503    /// typeck. During typeck, you should therefore use instead the unoptimized ABI returned by
2504    /// `fn_abi_of_instance_no_deduced_attrs`.
2505    ///
2506    /// For performance reasons, you should prefer to call this inherent method rather than invoke
2507    /// the `fn_abi_of_instance_raw` query: it delegates to that query if necessary, but where
2508    /// possible delegates instead to the `fn_abi_of_instance_no_deduced_attrs` query (thus avoiding
2509    /// unnecessary query system overhead).
2510    ///
2511    /// * that includes virtual calls, which are represented by "direct calls" to an
2512    ///   `InstanceKind::Virtual` instance (of `<dyn Trait as Trait>::fn`).
2513    #[inline]
2514    pub fn fn_abi_of_instance(
2515        self,
2516        query: ty::PseudoCanonicalInput<'tcx, (ty::Instance<'tcx>, &'tcx ty::List<Ty<'tcx>>)>,
2517    ) -> Result<&'tcx FnAbi<'tcx, Ty<'tcx>>, &'tcx FnAbiError<'tcx>> {
2518        // Only deduce attrs in full, optimized builds. Otherwise, avoid the query system overhead
2519        // of ever invoking the `fn_abi_of_instance_raw` query.
2520        if self.sess.opts.optimize != OptLevel::No && self.sess.opts.incremental.is_none() {
2521            self.fn_abi_of_instance_raw(query)
2522        } else {
2523            self.fn_abi_of_instance_no_deduced_attrs(query)
2524        }
2525    }
2526}
2527
2528// `HasAttrs` impls: allow `find_attr!(tcx, id, ...)` to work with both DefId-like types and HirId.
2529
2530impl<'tcx> rustc_attr_ir::HasAttrs<'tcx, TyCtxt<'tcx>> for DefId {
2531    fn get_attrs(self, tcx: &TyCtxt<'tcx>) -> &'tcx [rustc_attr_ir::Attribute] {
2532        if let Some(did) = self.as_local() {
2533            tcx.hir_attrs(tcx.local_def_id_to_hir_id(did))
2534        } else {
2535            tcx.attrs_for_def(self)
2536        }
2537    }
2538}
2539
2540impl<'tcx> rustc_attr_ir::HasAttrs<'tcx, TyCtxt<'tcx>> for LocalDefId {
2541    fn get_attrs(self, tcx: &TyCtxt<'tcx>) -> &'tcx [rustc_attr_ir::Attribute] {
2542        tcx.hir_attrs(tcx.local_def_id_to_hir_id(self))
2543    }
2544}
2545
2546impl<'tcx> rustc_attr_ir::HasAttrs<'tcx, TyCtxt<'tcx>> for hir::OwnerId {
2547    fn get_attrs(self, tcx: &TyCtxt<'tcx>) -> &'tcx [rustc_attr_ir::Attribute] {
2548        rustc_attr_ir::HasAttrs::get_attrs(self.def_id, tcx)
2549    }
2550}
2551
2552impl<'tcx> rustc_attr_ir::HasAttrs<'tcx, TyCtxt<'tcx>> for hir::HirId {
2553    fn get_attrs(self, tcx: &TyCtxt<'tcx>) -> &'tcx [rustc_attr_ir::Attribute] {
2554        tcx.hir_attrs(self)
2555    }
2556}
2557
2558pub fn provide(providers: &mut Providers) {
2559    closure::provide(providers);
2560    context::provide(providers);
2561    erase_regions::provide(providers);
2562    inhabitedness::provide(providers);
2563    util::provide(providers);
2564    print::provide(providers);
2565    super::util::bug::provide(providers);
2566    *providers = Providers {
2567        trait_impls_of: trait_def::trait_impls_of_provider,
2568        incoherent_impls: trait_def::incoherent_impls_provider,
2569        trait_impls_in_crate: trait_def::trait_impls_in_crate_provider,
2570        traits: trait_def::traits_provider,
2571        vtable_allocation: vtable::vtable_allocation_provider,
2572        ..*providers
2573    };
2574}
2575
2576/// A map for the local crate mapping each type to a vector of its
2577/// inherent impls. This is not meant to be used outside of coherence;
2578/// rather, you should request the vector for a specific type via
2579/// `tcx.inherent_impls(def_id)` so as to minimize your dependencies
2580/// (constructing this map requires touching the entire crate).
2581#[derive(#[automatically_derived]impl ::core::clone::Clone for CrateInherentImpls {
    #[inline]
    #[rustc_trivial_field_reads]
    fn clone(&self) -> Self {
        CrateInherentImpls {
            inherent_impls: ::core::clone::Clone::clone(&self.inherent_impls),
            incoherent_impls: ::core::clone::Clone::clone(&self.incoherent_impls),
        }
    }
}Clone, #[automatically_derived]impl ::core::fmt::Debug for CrateInherentImpls {
    #[inline]
    #[rustc_trivial_field_reads]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::debug_struct_field2_finish(f,
            "CrateInherentImpls inherent_impls incoherent_impls",
            &self.inherent_impls, &&self.incoherent_impls)
    }
}Debug, #[automatically_derived]impl ::core::default::Default for CrateInherentImpls {
    #[inline]
    fn default() -> Self {
        CrateInherentImpls {
            inherent_impls: ::core::default::Default::default(),
            incoherent_impls: ::core::default::Default::default(),
        }
    }
}Default, const _: () =
    {
        impl ::rustc_data_structures::stable_hash::StableHash for
            CrateInherentImpls {
            #[inline]
            fn stable_hash<__Hcx: ::rustc_data_structures::stable_hash::StableHashCtxt>(&self,
                __hcx: &mut __Hcx,
                __hasher:
                    &mut ::rustc_data_structures::stable_hash::StableHasher) {
                match *self {
                    CrateInherentImpls {
                        inherent_impls: ref __binding_0,
                        incoherent_impls: ref __binding_1 } => {
                        { __binding_0.stable_hash(__hcx, __hasher); }
                        { __binding_1.stable_hash(__hcx, __hasher); }
                    }
                }
            }
        }
    };StableHash)]
2582pub struct CrateInherentImpls {
2583    pub inherent_impls: FxIndexMap<LocalDefId, Vec<DefId>>,
2584    pub incoherent_impls: FxIndexMap<SimplifiedType, Vec<LocalDefId>>,
2585}
2586
2587#[derive(#[automatically_derived]#[doc(hidden)]unsafe impl<'tcx>
    ::core::clone::TrivialClone for SymbolName<'tcx> {
}
#[automatically_derived]impl<'tcx> ::core::clone::Clone for SymbolName<'tcx> {
    #[inline]
    #[rustc_trivial_field_reads]
    fn clone(&self) -> Self {
        let _: ::core::clone::AssertParamIsClone<&'tcx str>;
        *self
    }
}Clone, #[automatically_derived]impl<'tcx> ::core::marker::Copy for SymbolName<'tcx> {
}Copy, #[automatically_derived]impl<'tcx> ::core::marker::StructuralPartialEq for
    SymbolName<'tcx> {
}
#[automatically_derived]impl<'tcx> ::core::cmp::PartialEq for SymbolName<'tcx>
    {
    #[inline]
    fn eq(&self, other: &Self) -> bool { self.name == other.name }
}PartialEq, #[automatically_derived]impl<'tcx> ::core::cmp::Eq for SymbolName<'tcx> {
    #[inline]
    #[doc(hidden)]
    #[coverage(off)]
    fn assert_fields_are_eq(&self) {
        let _: ::core::cmp::AssertParamIsEq<&'tcx str>;
    }
}Eq, #[automatically_derived]impl<'tcx> ::core::cmp::PartialOrd for
    SymbolName<'tcx> {
    #[inline]
    fn partial_cmp(&self, other: &Self)
        -> ::core::option::Option<::core::cmp::Ordering> {
        ::core::option::Option::Some(::core::cmp::Ord::cmp(self, other))
    }
}PartialOrd, #[automatically_derived]impl<'tcx> ::core::cmp::Ord for SymbolName<'tcx> {
    #[inline]
    fn cmp(&self, other: &Self) -> ::core::cmp::Ordering {
        ::core::cmp::Ord::cmp(&self.name, &other.name)
    }
}Ord, #[automatically_derived]impl<'tcx> ::core::hash::Hash for SymbolName<'tcx> {
    #[inline]
    fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) {
        ::core::hash::Hash::hash(&self.name, state)
    }
}Hash, const _: () =
    {
        impl<'tcx, __E: ::rustc_middle::ty::codec::TyEncoder<'tcx>>
            ::rustc_serialize::Encodable<__E> for SymbolName<'tcx> {
            fn encode(&self, __encoder: &mut __E) {
                let SymbolName { name: __binding_0 } = *self;
                ::rustc_serialize::Encodable::<__E>::encode(__binding_0,
                    __encoder);
            }
        }
    };TyEncodable, const _: () =
    {
        impl<'tcx> ::rustc_data_structures::stable_hash::StableHash for
            SymbolName<'tcx> {
            #[inline]
            fn stable_hash<__Hcx: ::rustc_data_structures::stable_hash::StableHashCtxt>(&self,
                __hcx: &mut __Hcx,
                __hasher:
                    &mut ::rustc_data_structures::stable_hash::StableHasher) {
                match *self {
                    SymbolName { name: ref __binding_0 } => {
                        { __binding_0.stable_hash(__hcx, __hasher); }
                    }
                }
            }
        }
    };StableHash)]
2588pub struct SymbolName<'tcx> {
2589    /// `&str` gives a consistent ordering, which ensures reproducible builds.
2590    pub name: &'tcx str,
2591}
2592
2593impl<'tcx> SymbolName<'tcx> {
2594    pub fn new(tcx: TyCtxt<'tcx>, name: &str) -> SymbolName<'tcx> {
2595        SymbolName { name: tcx.arena.alloc_str(name) }
2596    }
2597}
2598
2599impl<'tcx> fmt::Display for SymbolName<'tcx> {
2600    fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
2601        fmt::Display::fmt(&self.name, fmt)
2602    }
2603}
2604
2605impl<'tcx> fmt::Debug for SymbolName<'tcx> {
2606    fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
2607        fmt::Display::fmt(&self.name, fmt)
2608    }
2609}
2610
2611/// The constituent parts of a type level constant of kind ADT or array.
2612#[derive(#[automatically_derived]impl<'tcx> ::core::marker::Copy for
    DestructuredAdtConst<'tcx> {
}Copy, #[automatically_derived]#[doc(hidden)]unsafe impl<'tcx>
    ::core::clone::TrivialClone for DestructuredAdtConst<'tcx> {
}
#[automatically_derived]impl<'tcx> ::core::clone::Clone for
    DestructuredAdtConst<'tcx> {
    #[inline]
    #[rustc_trivial_field_reads]
    fn clone(&self) -> Self {
        let _: ::core::clone::AssertParamIsClone<VariantIdx>;
        let _: ::core::clone::AssertParamIsClone<&'tcx [ty::Const<'tcx>]>;
        *self
    }
}Clone, #[automatically_derived]impl<'tcx> ::core::fmt::Debug for
    DestructuredAdtConst<'tcx> {
    #[inline]
    #[rustc_trivial_field_reads]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::debug_struct_field2_finish(f,
            "DestructuredAdtConst variant fields", &self.variant,
            &&self.fields)
    }
}Debug, const _: () =
    {
        impl<'tcx> ::rustc_data_structures::stable_hash::StableHash for
            DestructuredAdtConst<'tcx> {
            #[inline]
            fn stable_hash<__Hcx: ::rustc_data_structures::stable_hash::StableHashCtxt>(&self,
                __hcx: &mut __Hcx,
                __hasher:
                    &mut ::rustc_data_structures::stable_hash::StableHasher) {
                match *self {
                    DestructuredAdtConst {
                        variant: ref __binding_0, fields: ref __binding_1 } => {
                        { __binding_0.stable_hash(__hcx, __hasher); }
                        { __binding_1.stable_hash(__hcx, __hasher); }
                    }
                }
            }
        }
    };StableHash)]
2613pub struct DestructuredAdtConst<'tcx> {
2614    pub variant: VariantIdx,
2615    pub fields: &'tcx [ty::Const<'tcx>],
2616}