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::fmt::Debug;
15use std::hash::{Hash, Hasher};
16use std::marker::PhantomData;
17use std::num::NonZero;
18use std::ptr::NonNull;
19use std::{assert_matches, fmt, iter, str};
20
21pub use adt::*;
22pub use assoc::*;
23pub use generic_args::{GenericArgKind, TermKind, *};
24pub use generics::*;
25pub use intrinsic::IntrinsicDef;
26use rustc_abi::{
27    Align, FieldIdx, Integer, IntegerType, ReprFlags, ReprOptions, ScalableElt, VariantIdx,
28};
29use rustc_ast as ast;
30use rustc_ast::expand::typetree::{FncTree, Kind, Type, TypeTree};
31use rustc_ast::node_id::NodeMap;
32pub use rustc_ast_ir::{Movability, Mutability, try_visit};
33use rustc_data_structures::fx::{FxHashSet, FxIndexMap, FxIndexSet};
34use rustc_data_structures::intern::Interned;
35use rustc_data_structures::stable_hasher::{HashStable, StableHasher};
36use rustc_data_structures::steal::Steal;
37use rustc_data_structures::unord::{UnordMap, UnordSet};
38use rustc_errors::{Diag, ErrorGuaranteed, LintBuffer};
39use rustc_hir as hir;
40use rustc_hir::attrs::StrippedCfgItem;
41use rustc_hir::def::{CtorKind, CtorOf, DefKind, DocLinkResMap, LifetimeRes, Res};
42use rustc_hir::def_id::{CrateNum, DefId, DefIdMap, LocalDefId, LocalDefIdMap};
43use rustc_hir::{LangItem, attrs as attr, find_attr};
44use rustc_index::IndexVec;
45use rustc_index::bit_set::BitMatrix;
46use rustc_macros::{
47    BlobDecodable, Decodable, Encodable, HashStable, TyDecodable, TyEncodable, TypeFoldable,
48    TypeVisitable, extension,
49};
50use rustc_serialize::{Decodable, Encodable};
51use rustc_session::config::OptLevel;
52pub use rustc_session::lint::RegisteredTools;
53use rustc_span::hygiene::MacroKind;
54use rustc_span::{DUMMY_SP, ExpnId, ExpnKind, Ident, Span, Symbol};
55use rustc_target::callconv::FnAbi;
56pub use rustc_type_ir::data_structures::{DelayedMap, DelayedSet};
57pub use rustc_type_ir::fast_reject::DeepRejectCtxt;
58#[allow(
59    hidden_glob_reexports,
60    rustc::usage_of_type_ir_inherent,
61    rustc::non_glob_import_of_type_ir_inherent
62)]
63use rustc_type_ir::inherent;
64pub use rustc_type_ir::relate::VarianceDiagInfo;
65pub use rustc_type_ir::solve::{CandidatePreferenceMode, SizedTraitKind};
66pub use rustc_type_ir::*;
67#[allow(hidden_glob_reexports, unused_imports)]
68use rustc_type_ir::{InferCtxtLike, Interner};
69use tracing::{debug, instrument, trace};
70pub use vtable::*;
71
72pub use self::closure::{
73    BorrowKind, CAPTURE_STRUCT_LOCAL, CaptureInfo, CapturedPlace, ClosureTypeInfo,
74    MinCaptureInformationMap, MinCaptureList, RootVariableMinCaptureList, UpvarCapture, UpvarId,
75    UpvarPath, analyze_coroutine_closure_captures, is_ancestor_or_same_capture,
76    place_to_string_for_capture,
77};
78pub use self::consts::{
79    AtomicOrdering, Const, ConstInt, ConstKind, ConstToValTreeResult, Expr, ExprKind,
80    LitToConstInput, ScalarInt, SimdAlign, UnevaluatedConst, ValTree, ValTreeKindExt, Value,
81    const_lit_matches_ty,
82};
83pub use self::context::{
84    CtxtInterners, CurrentGcx, Feed, FreeRegionInfo, GlobalCtxt, Lift, TyCtxt, TyCtxtFeed, tls,
85};
86pub use self::fold::*;
87pub use self::instance::{Instance, InstanceKind, ReifyReason};
88pub(crate) use self::list::RawList;
89pub use self::list::{List, ListWithCachedTypeInfo};
90pub use self::opaque_types::OpaqueTypeKey;
91pub use self::pattern::{Pattern, PatternKind};
92pub use self::predicate::{
93    AliasTerm, ArgOutlivesPredicate, Clause, ClauseKind, CoercePredicate, ExistentialPredicate,
94    ExistentialPredicateStableCmpExt, ExistentialProjection, ExistentialTraitRef,
95    HostEffectPredicate, NormalizesTo, OutlivesPredicate, PolyCoercePredicate,
96    PolyExistentialPredicate, PolyExistentialProjection, PolyExistentialTraitRef,
97    PolyProjectionPredicate, PolyRegionOutlivesPredicate, PolySubtypePredicate, PolyTraitPredicate,
98    PolyTraitRef, PolyTypeOutlivesPredicate, Predicate, PredicateKind, ProjectionPredicate,
99    RegionOutlivesPredicate, SubtypePredicate, TraitPredicate, TraitRef, TypeOutlivesPredicate,
100};
101pub use self::region::{
102    EarlyParamRegion, LateParamRegion, LateParamRegionKind, Region, RegionKind, RegionVid,
103};
104pub use self::sty::{
105    AliasTy, AliasTyKind, Article, Binder, BoundConst, BoundRegion, BoundRegionKind, BoundTy,
106    BoundTyKind, BoundVariableKind, CanonicalPolyFnSig, CoroutineArgsExt, EarlyBinder, FnSig,
107    InlineConstArgs, InlineConstArgsParts, ParamConst, ParamTy, PlaceholderConst,
108    PlaceholderRegion, PlaceholderType, PolyFnSig, TyKind, TypeAndMut, TypingMode,
109    TypingModeEqWrapper, UpvarArgs,
110};
111pub use self::trait_def::TraitDef;
112pub use self::typeck_results::{
113    CanonicalUserType, CanonicalUserTypeAnnotation, CanonicalUserTypeAnnotations, IsIdentity,
114    Rust2024IncompatiblePatInfo, TypeckResults, UserType, UserTypeAnnotationIndex, UserTypeKind,
115};
116use crate::error::{OpaqueHiddenTypeMismatch, TypeMismatchReason};
117use crate::ich::StableHashingContext;
118use crate::metadata::{AmbigModChild, ModChild};
119use crate::middle::privacy::EffectiveVisibilities;
120use crate::mir::{Body, CoroutineLayout, CoroutineSavedLocal, SourceInfo};
121use crate::query::{IntoQueryKey, Providers};
122use crate::ty;
123use crate::ty::codec::{TyDecoder, TyEncoder};
124pub use crate::ty::diagnostics::*;
125use crate::ty::fast_reject::SimplifiedType;
126use crate::ty::layout::{FnAbiError, LayoutError};
127use crate::ty::util::Discr;
128use crate::ty::walk::TypeWalker;
129
130pub mod abstract_const;
131pub mod adjustment;
132pub mod cast;
133pub mod codec;
134pub mod error;
135pub mod fast_reject;
136pub mod inhabitedness;
137pub mod layout;
138pub mod normalize_erasing_regions;
139pub mod offload_meta;
140pub mod pattern;
141pub mod print;
142pub mod relate;
143pub mod significant_drop_order;
144pub mod trait_def;
145pub mod util;
146pub mod vtable;
147
148mod adt;
149mod assoc;
150mod closure;
151mod consts;
152mod context;
153mod diagnostics;
154mod elaborate_impl;
155mod erase_regions;
156mod fold;
157mod generic_args;
158mod generics;
159mod impls_ty;
160mod instance;
161mod intrinsic;
162mod list;
163mod opaque_types;
164mod predicate;
165mod region;
166mod structural_impls;
167#[allow(hidden_glob_reexports)]
168mod sty;
169mod typeck_results;
170mod visit;
171
172// Data types
173
174#[derive(#[automatically_derived]
impl ::core::fmt::Debug for ResolverGlobalCtxt {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        let names: &'static _ =
            &["visibilities_for_hashing", "expn_that_defined",
                        "effective_visibilities", "extern_crate_map",
                        "maybe_unused_trait_imports", "module_children",
                        "ambig_module_children", "glob_map", "main_def",
                        "trait_impls", "proc_macros",
                        "confused_type_with_std_module", "doc_link_resolutions",
                        "doc_link_traits_in_scope", "all_macro_rules",
                        "stripped_cfg_items"];
        let values: &[&dyn ::core::fmt::Debug] =
            &[&self.visibilities_for_hashing, &self.expn_that_defined,
                        &self.effective_visibilities, &self.extern_crate_map,
                        &self.maybe_unused_trait_imports, &self.module_children,
                        &self.ambig_module_children, &self.glob_map, &self.main_def,
                        &self.trait_impls, &self.proc_macros,
                        &self.confused_type_with_std_module,
                        &self.doc_link_resolutions, &self.doc_link_traits_in_scope,
                        &self.all_macro_rules, &&self.stripped_cfg_items];
        ::core::fmt::Formatter::debug_struct_fields_finish(f,
            "ResolverGlobalCtxt", names, values)
    }
}Debug, const _: () =
    {
        impl<'__ctx>
            ::rustc_data_structures::stable_hasher::HashStable<::rustc_middle::ich::StableHashingContext<'__ctx>>
            for ResolverGlobalCtxt {
            #[inline]
            fn hash_stable(&self,
                __hcx: &mut ::rustc_middle::ich::StableHashingContext<'__ctx>,
                __hasher:
                    &mut ::rustc_data_structures::stable_hasher::StableHasher) {
                match *self {
                    ResolverGlobalCtxt {
                        visibilities_for_hashing: ref __binding_0,
                        expn_that_defined: ref __binding_1,
                        effective_visibilities: ref __binding_2,
                        extern_crate_map: ref __binding_3,
                        maybe_unused_trait_imports: ref __binding_4,
                        module_children: ref __binding_5,
                        ambig_module_children: ref __binding_6,
                        glob_map: ref __binding_7,
                        main_def: ref __binding_8,
                        trait_impls: ref __binding_9,
                        proc_macros: ref __binding_10,
                        confused_type_with_std_module: ref __binding_11,
                        doc_link_resolutions: ref __binding_12,
                        doc_link_traits_in_scope: ref __binding_13,
                        all_macro_rules: ref __binding_14,
                        stripped_cfg_items: ref __binding_15 } => {
                        { __binding_0.hash_stable(__hcx, __hasher); }
                        { __binding_1.hash_stable(__hcx, __hasher); }
                        { __binding_2.hash_stable(__hcx, __hasher); }
                        { __binding_3.hash_stable(__hcx, __hasher); }
                        { __binding_4.hash_stable(__hcx, __hasher); }
                        { __binding_5.hash_stable(__hcx, __hasher); }
                        { __binding_6.hash_stable(__hcx, __hasher); }
                        { __binding_7.hash_stable(__hcx, __hasher); }
                        { __binding_8.hash_stable(__hcx, __hasher); }
                        { __binding_9.hash_stable(__hcx, __hasher); }
                        { __binding_10.hash_stable(__hcx, __hasher); }
                        { __binding_11.hash_stable(__hcx, __hasher); }
                        { __binding_12.hash_stable(__hcx, __hasher); }
                        { __binding_13.hash_stable(__hcx, __hasher); }
                        { __binding_14.hash_stable(__hcx, __hasher); }
                        { __binding_15.hash_stable(__hcx, __hasher); }
                    }
                }
            }
        }
    };HashStable)]
175pub struct ResolverGlobalCtxt {
176    pub visibilities_for_hashing: Vec<(LocalDefId, Visibility)>,
177    /// Item with a given `LocalDefId` was defined during macro expansion with ID `ExpnId`.
178    pub expn_that_defined: UnordMap<LocalDefId, ExpnId>,
179    pub effective_visibilities: EffectiveVisibilities,
180    pub extern_crate_map: UnordMap<LocalDefId, CrateNum>,
181    pub maybe_unused_trait_imports: FxIndexSet<LocalDefId>,
182    pub module_children: LocalDefIdMap<Vec<ModChild>>,
183    pub ambig_module_children: LocalDefIdMap<Vec<AmbigModChild>>,
184    pub glob_map: FxIndexMap<LocalDefId, FxIndexSet<Symbol>>,
185    pub main_def: Option<MainDefinition>,
186    pub trait_impls: FxIndexMap<DefId, Vec<LocalDefId>>,
187    /// A list of proc macro LocalDefIds, written out in the order in which
188    /// they are declared in the static array generated by proc_macro_harness.
189    pub proc_macros: Vec<LocalDefId>,
190    /// Mapping from ident span to path span for paths that don't exist as written, but that
191    /// exist under `std`. For example, wrote `str::from_utf8` instead of `std::str::from_utf8`.
192    pub confused_type_with_std_module: FxIndexMap<Span, Span>,
193    pub doc_link_resolutions: FxIndexMap<LocalDefId, DocLinkResMap>,
194    pub doc_link_traits_in_scope: FxIndexMap<LocalDefId, Vec<DefId>>,
195    pub all_macro_rules: UnordSet<Symbol>,
196    pub stripped_cfg_items: Vec<StrippedCfgItem>,
197}
198
199/// Resolutions that should only be used for lowering.
200/// This struct is meant to be consumed by lowering.
201#[derive(#[automatically_derived]
impl<'tcx> ::core::fmt::Debug for ResolverAstLowering<'tcx> {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        let names: &'static _ =
            &["partial_res_map", "import_res_map", "label_res_map",
                        "lifetimes_res_map", "extra_lifetime_params_map",
                        "next_node_id", "node_id_to_def_id", "trait_map",
                        "lifetime_elision_allowed", "lint_buffer",
                        "delegation_infos"];
        let values: &[&dyn ::core::fmt::Debug] =
            &[&self.partial_res_map, &self.import_res_map,
                        &self.label_res_map, &self.lifetimes_res_map,
                        &self.extra_lifetime_params_map, &self.next_node_id,
                        &self.node_id_to_def_id, &self.trait_map,
                        &self.lifetime_elision_allowed, &self.lint_buffer,
                        &&self.delegation_infos];
        ::core::fmt::Formatter::debug_struct_fields_finish(f,
            "ResolverAstLowering", names, values)
    }
}Debug)]
202pub struct ResolverAstLowering<'tcx> {
203    /// Resolutions for nodes that have a single resolution.
204    pub partial_res_map: NodeMap<hir::def::PartialRes>,
205    /// Resolutions for import nodes, which have multiple resolutions in different namespaces.
206    pub import_res_map: NodeMap<hir::def::PerNS<Option<Res<ast::NodeId>>>>,
207    /// Resolutions for labels (node IDs of their corresponding blocks or loops).
208    pub label_res_map: NodeMap<ast::NodeId>,
209    /// Resolutions for lifetimes.
210    pub lifetimes_res_map: NodeMap<LifetimeRes>,
211    /// Lifetime parameters that lowering will have to introduce.
212    pub extra_lifetime_params_map: NodeMap<Vec<(Ident, ast::NodeId, LifetimeRes)>>,
213
214    pub next_node_id: ast::NodeId,
215
216    pub node_id_to_def_id: NodeMap<LocalDefId>,
217
218    pub trait_map: NodeMap<&'tcx [hir::TraitCandidate<'tcx>]>,
219    /// List functions and methods for which lifetime elision was successful.
220    pub lifetime_elision_allowed: FxHashSet<ast::NodeId>,
221
222    /// Lints that were emitted by the resolver and early lints.
223    pub lint_buffer: Steal<LintBuffer>,
224
225    // Information about delegations which is used when handling recursive delegations
226    pub delegation_infos: LocalDefIdMap<DelegationInfo>,
227}
228
229#[derive(#[automatically_derived]
impl ::core::fmt::Debug for DelegationInfo {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::debug_struct_field1_finish(f,
            "DelegationInfo", "resolution_node", &&self.resolution_node)
    }
}Debug)]
230pub struct DelegationInfo {
231    // NodeId (either delegation.id or item_id in case of a trait impl) for signature resolution,
232    // for details see https://github.com/rust-lang/rust/issues/118212#issuecomment-2160686914
233    pub resolution_node: ast::NodeId,
234}
235
236#[derive(#[automatically_derived]
impl ::core::clone::Clone for MainDefinition {
    #[inline]
    fn clone(&self) -> MainDefinition {
        let _: ::core::clone::AssertParamIsClone<Res<ast::NodeId>>;
        let _: ::core::clone::AssertParamIsClone<bool>;
        let _: ::core::clone::AssertParamIsClone<Span>;
        *self
    }
}Clone, #[automatically_derived]
impl ::core::marker::Copy for MainDefinition { }Copy, #[automatically_derived]
impl ::core::fmt::Debug for MainDefinition {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::debug_struct_field3_finish(f,
            "MainDefinition", "res", &self.res, "is_import", &self.is_import,
            "span", &&self.span)
    }
}Debug, const _: () =
    {
        impl<'__ctx>
            ::rustc_data_structures::stable_hasher::HashStable<::rustc_middle::ich::StableHashingContext<'__ctx>>
            for MainDefinition {
            #[inline]
            fn hash_stable(&self,
                __hcx: &mut ::rustc_middle::ich::StableHashingContext<'__ctx>,
                __hasher:
                    &mut ::rustc_data_structures::stable_hasher::StableHasher) {
                match *self {
                    MainDefinition {
                        res: ref __binding_0,
                        is_import: ref __binding_1,
                        span: ref __binding_2 } => {
                        { __binding_0.hash_stable(__hcx, __hasher); }
                        { __binding_1.hash_stable(__hcx, __hasher); }
                        { __binding_2.hash_stable(__hcx, __hasher); }
                    }
                }
            }
        }
    };HashStable)]
237pub struct MainDefinition {
238    pub res: Res<ast::NodeId>,
239    pub is_import: bool,
240    pub span: Span,
241}
242
243impl MainDefinition {
244    pub fn opt_fn_def_id(self) -> Option<DefId> {
245        if let Res::Def(DefKind::Fn, def_id) = self.res { Some(def_id) } else { None }
246    }
247}
248
249#[derive(#[automatically_derived]
impl<'tcx> ::core::marker::Copy for ImplTraitHeader<'tcx> { }Copy, #[automatically_derived]
impl<'tcx> ::core::clone::Clone for ImplTraitHeader<'tcx> {
    #[inline]
    fn clone(&self) -> ImplTraitHeader<'tcx> {
        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]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::debug_struct_field4_finish(f,
            "ImplTraitHeader", "trait_ref", &self.trait_ref, "polarity",
            &self.polarity, "safety", &self.safety, "constness",
            &&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) {
                match *self {
                    ImplTraitHeader {
                        trait_ref: ref __binding_0,
                        polarity: ref __binding_1,
                        safety: ref __binding_2,
                        constness: ref __binding_3 } => {
                        ::rustc_serialize::Encodable::<__E>::encode(__binding_0,
                            __encoder);
                        ::rustc_serialize::Encodable::<__E>::encode(__binding_1,
                            __encoder);
                        ::rustc_serialize::Encodable::<__E>::encode(__binding_2,
                            __encoder);
                        ::rustc_serialize::Encodable::<__E>::encode(__binding_3,
                            __encoder);
                    }
                }
            }
        }
    };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, '__ctx>
            ::rustc_data_structures::stable_hasher::HashStable<::rustc_middle::ich::StableHashingContext<'__ctx>>
            for ImplTraitHeader<'tcx> {
            #[inline]
            fn hash_stable(&self,
                __hcx: &mut ::rustc_middle::ich::StableHashingContext<'__ctx>,
                __hasher:
                    &mut ::rustc_data_structures::stable_hasher::StableHasher) {
                match *self {
                    ImplTraitHeader {
                        trait_ref: ref __binding_0,
                        polarity: ref __binding_1,
                        safety: ref __binding_2,
                        constness: ref __binding_3 } => {
                        { __binding_0.hash_stable(__hcx, __hasher); }
                        { __binding_1.hash_stable(__hcx, __hasher); }
                        { __binding_2.hash_stable(__hcx, __hasher); }
                        { __binding_3.hash_stable(__hcx, __hasher); }
                    }
                }
            }
        }
    };HashStable)]
250pub struct ImplTraitHeader<'tcx> {
251    pub trait_ref: ty::EarlyBinder<'tcx, ty::TraitRef<'tcx>>,
252    pub polarity: ImplPolarity,
253    pub safety: hir::Safety,
254    pub constness: hir::Constness,
255}
256
257#[derive(#[automatically_derived]
impl ::core::marker::Copy for Asyncness { }Copy, #[automatically_derived]
impl ::core::clone::Clone for Asyncness {
    #[inline]
    fn clone(&self) -> Asyncness { *self }
}Clone, #[automatically_derived]
impl ::core::cmp::PartialEq for Asyncness {
    #[inline]
    fn eq(&self, other: &Asyncness) -> bool {
        let __self_discr = ::core::intrinsics::discriminant_value(self);
        let __arg1_discr = ::core::intrinsics::discriminant_value(other);
        __self_discr == __arg1_discr
    }
}PartialEq, #[automatically_derived]
impl ::core::cmp::Eq for Asyncness {
    #[inline]
    #[doc(hidden)]
    #[coverage(off)]
    fn assert_fields_are_eq(&self) {}
}Eq, #[automatically_derived]
impl ::core::hash::Hash for Asyncness {
    #[inline]
    fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) {
        let __self_discr = ::core::intrinsics::discriminant_value(self);
        ::core::hash::Hash::hash(&__self_discr, state)
    }
}Hash, const _: () =
    {
        impl<'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);
                match *self { Asyncness::Yes => {} Asyncness::No => {} }
            }
        }
    };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<'__ctx>
            ::rustc_data_structures::stable_hasher::HashStable<::rustc_middle::ich::StableHashingContext<'__ctx>>
            for Asyncness {
            #[inline]
            fn hash_stable(&self,
                __hcx: &mut ::rustc_middle::ich::StableHashingContext<'__ctx>,
                __hasher:
                    &mut ::rustc_data_structures::stable_hasher::StableHasher) {
                ::std::mem::discriminant(self).hash_stable(__hcx, __hasher);
                match *self { Asyncness::Yes => {} Asyncness::No => {} }
            }
        }
    };HashStable, #[automatically_derived]
impl ::core::fmt::Debug for Asyncness {
    #[inline]
    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)]
258#[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() -> Asyncness { Self::No }
}Default)]
259pub enum Asyncness {
260    Yes,
261    #[default]
262    No,
263}
264
265impl Asyncness {
266    pub fn is_async(self) -> bool {
267        #[allow(non_exhaustive_omitted_patterns)] match self {
    Asyncness::Yes => true,
    _ => false,
}matches!(self, Asyncness::Yes)
268    }
269}
270
271#[derive(#[automatically_derived]
impl<Id: ::core::clone::Clone> ::core::clone::Clone for Visibility<Id> {
    #[inline]
    fn clone(&self) -> Visibility<Id> {
        match self {
            Visibility::Public => Visibility::Public,
            Visibility::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]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        match self {
            Visibility::Public =>
                ::core::fmt::Formatter::write_str(f, "Public"),
            Visibility::Restricted(__self_0) =>
                ::core::fmt::Formatter::debug_tuple_field1_finish(f,
                    "Restricted", &__self_0),
        }
    }
}Debug, #[automatically_derived]
impl<Id: ::core::cmp::PartialEq> ::core::cmp::PartialEq for Visibility<Id> {
    #[inline]
    fn eq(&self, other: &Visibility<Id>) -> bool {
        let __self_discr = ::core::intrinsics::discriminant_value(self);
        let __arg1_discr = ::core::intrinsics::discriminant_value(other);
        __self_discr == __arg1_discr &&
            match (self, other) {
                (Visibility::Restricted(__self_0),
                    Visibility::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) {
        let __self_discr = ::core::intrinsics::discriminant_value(self);
        ::core::hash::Hash::hash(&__self_discr, state);
        match self {
            Visibility::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<'__ctx, Id>
            ::rustc_data_structures::stable_hasher::HashStable<::rustc_middle::ich::StableHashingContext<'__ctx>>
            for Visibility<Id> where
            Id: ::rustc_data_structures::stable_hasher::HashStable<::rustc_middle::ich::StableHashingContext<'__ctx>>
            {
            #[inline]
            fn hash_stable(&self,
                __hcx: &mut ::rustc_middle::ich::StableHashingContext<'__ctx>,
                __hasher:
                    &mut ::rustc_data_structures::stable_hasher::StableHasher) {
                ::std::mem::discriminant(self).hash_stable(__hcx, __hasher);
                match *self {
                    Visibility::Public => {}
                    Visibility::Restricted(ref __binding_0) => {
                        { __binding_0.hash_stable(__hcx, __hasher); }
                    }
                }
            }
        }
    };HashStable)]
272pub enum Visibility<Id = LocalDefId> {
273    /// Visible everywhere (including in other crates).
274    Public,
275    /// Visible only in the given crate-local module.
276    Restricted(Id),
277}
278
279impl Visibility {
280    pub fn to_string(self, def_id: LocalDefId, tcx: TyCtxt<'_>) -> String {
281        match self {
282            ty::Visibility::Restricted(restricted_id) => {
283                if restricted_id.is_top_level_module() {
284                    "pub(crate)".to_string()
285                } else if restricted_id == tcx.parent_module_from_def_id(def_id).to_local_def_id() {
286                    "pub(self)".to_string()
287                } else {
288                    ::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!(
289                        "pub(in crate{})",
290                        tcx.def_path(restricted_id.to_def_id()).to_string_no_crate_verbose()
291                    )
292                }
293            }
294            ty::Visibility::Public => "pub".to_string(),
295        }
296    }
297}
298
299#[derive(#[automatically_derived]
impl<'tcx> ::core::clone::Clone for ClosureSizeProfileData<'tcx> {
    #[inline]
    fn clone(&self) -> ClosureSizeProfileData<'tcx> {
        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]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::debug_struct_field2_finish(f,
            "ClosureSizeProfileData", "before_feature_tys",
            &self.before_feature_tys, "after_feature_tys",
            &&self.after_feature_tys)
    }
}Debug, #[automatically_derived]
impl<'tcx> ::core::cmp::PartialEq for ClosureSizeProfileData<'tcx> {
    #[inline]
    fn eq(&self, other: &ClosureSizeProfileData<'tcx>) -> 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) {
                match *self {
                    ClosureSizeProfileData {
                        before_feature_tys: ref __binding_0,
                        after_feature_tys: ref __binding_1 } => {
                        ::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, '__ctx>
            ::rustc_data_structures::stable_hasher::HashStable<::rustc_middle::ich::StableHashingContext<'__ctx>>
            for ClosureSizeProfileData<'tcx> {
            #[inline]
            fn hash_stable(&self,
                __hcx: &mut ::rustc_middle::ich::StableHashingContext<'__ctx>,
                __hasher:
                    &mut ::rustc_data_structures::stable_hasher::StableHasher) {
                match *self {
                    ClosureSizeProfileData {
                        before_feature_tys: ref __binding_0,
                        after_feature_tys: ref __binding_1 } => {
                        { __binding_0.hash_stable(__hcx, __hasher); }
                        { __binding_1.hash_stable(__hcx, __hasher); }
                    }
                }
            }
        }
    };HashStable)]
300#[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)]
301pub struct ClosureSizeProfileData<'tcx> {
302    /// Tuple containing the types of closure captures before the feature `capture_disjoint_fields`
303    pub before_feature_tys: Ty<'tcx>,
304    /// Tuple containing the types of closure captures after the feature `capture_disjoint_fields`
305    pub after_feature_tys: Ty<'tcx>,
306}
307
308impl TyCtxt<'_> {
309    #[inline]
310    pub fn opt_parent(self, id: DefId) -> Option<DefId> {
311        self.def_key(id).parent.map(|index| DefId { index, ..id })
312    }
313
314    #[inline]
315    #[track_caller]
316    pub fn parent(self, id: DefId) -> DefId {
317        match self.opt_parent(id) {
318            Some(id) => id,
319            // not `unwrap_or_else` to avoid breaking caller tracking
320            None => crate::util::bug::bug_fmt(format_args!("{0:?} doesn\'t have a parent", id))bug!("{id:?} doesn't have a parent"),
321        }
322    }
323
324    #[inline]
325    #[track_caller]
326    pub fn opt_local_parent(self, id: LocalDefId) -> Option<LocalDefId> {
327        self.opt_parent(id.to_def_id()).map(DefId::expect_local)
328    }
329
330    #[inline]
331    #[track_caller]
332    pub fn local_parent(self, id: impl Into<LocalDefId>) -> LocalDefId {
333        self.parent(id.into().to_def_id()).expect_local()
334    }
335
336    pub fn is_descendant_of(self, mut descendant: DefId, ancestor: DefId) -> bool {
337        if descendant.krate != ancestor.krate {
338            return false;
339        }
340
341        while descendant != ancestor {
342            match self.opt_parent(descendant) {
343                Some(parent) => descendant = parent,
344                None => return false,
345            }
346        }
347        true
348    }
349}
350
351impl<Id> Visibility<Id> {
352    pub fn is_public(self) -> bool {
353        #[allow(non_exhaustive_omitted_patterns)] match self {
    Visibility::Public => true,
    _ => false,
}matches!(self, Visibility::Public)
354    }
355
356    pub fn map_id<OutId>(self, f: impl FnOnce(Id) -> OutId) -> Visibility<OutId> {
357        match self {
358            Visibility::Public => Visibility::Public,
359            Visibility::Restricted(id) => Visibility::Restricted(f(id)),
360        }
361    }
362}
363
364impl<Id: Into<DefId>> Visibility<Id> {
365    pub fn to_def_id(self) -> Visibility<DefId> {
366        self.map_id(Into::into)
367    }
368
369    /// Returns `true` if an item with this visibility is accessible from the given module.
370    pub fn is_accessible_from(self, module: impl Into<DefId>, tcx: TyCtxt<'_>) -> bool {
371        match self {
372            // Public items are visible everywhere.
373            Visibility::Public => true,
374            Visibility::Restricted(id) => tcx.is_descendant_of(module.into(), id.into()),
375        }
376    }
377
378    /// Returns `true` if this visibility is at least as accessible as the given visibility
379    pub fn is_at_least(self, vis: Visibility<impl Into<DefId>>, tcx: TyCtxt<'_>) -> bool {
380        match vis {
381            Visibility::Public => self.is_public(),
382            Visibility::Restricted(id) => self.is_accessible_from(id, tcx),
383        }
384    }
385}
386
387impl<Id: Into<DefId> + Copy> Visibility<Id> {
388    pub fn min(self, vis: Visibility<Id>, tcx: TyCtxt<'_>) -> Visibility<Id> {
389        if self.is_at_least(vis, tcx) { vis } else { self }
390    }
391}
392
393impl Visibility<DefId> {
394    pub fn expect_local(self) -> Visibility {
395        self.map_id(|id| id.expect_local())
396    }
397
398    /// Returns `true` if this item is visible anywhere in the local crate.
399    pub fn is_visible_locally(self) -> bool {
400        match self {
401            Visibility::Public => true,
402            Visibility::Restricted(def_id) => def_id.is_local(),
403        }
404    }
405}
406
407/// The crate variances map is computed during typeck and contains the
408/// variance of every item in the local crate. You should not use it
409/// directly, because to do so will make your pass dependent on the
410/// HIR of every item in the local crate. Instead, use
411/// `tcx.variances_of()` to get the variance for a *particular*
412/// item.
413#[derive(const _: () =
    {
        impl<'tcx, '__ctx>
            ::rustc_data_structures::stable_hasher::HashStable<::rustc_middle::ich::StableHashingContext<'__ctx>>
            for CrateVariancesMap<'tcx> {
            #[inline]
            fn hash_stable(&self,
                __hcx: &mut ::rustc_middle::ich::StableHashingContext<'__ctx>,
                __hasher:
                    &mut ::rustc_data_structures::stable_hasher::StableHasher) {
                match *self {
                    CrateVariancesMap { variances: ref __binding_0 } => {
                        { __binding_0.hash_stable(__hcx, __hasher); }
                    }
                }
            }
        }
    };HashStable, #[automatically_derived]
impl<'tcx> ::core::fmt::Debug for CrateVariancesMap<'tcx> {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::debug_struct_field1_finish(f,
            "CrateVariancesMap", "variances", &&self.variances)
    }
}Debug)]
414pub struct CrateVariancesMap<'tcx> {
415    /// For each item with generics, maps to a vector of the variance
416    /// of its generics. If an item has no generics, it will have no
417    /// entry.
418    pub variances: DefIdMap<&'tcx [ty::Variance]>,
419}
420
421// Contains information needed to resolve types and (in the future) look up
422// the types of AST nodes.
423#[derive(#[automatically_derived]
impl ::core::marker::Copy for CReaderCacheKey { }Copy, #[automatically_derived]
impl ::core::clone::Clone for CReaderCacheKey {
    #[inline]
    fn clone(&self) -> CReaderCacheKey {
        let _: ::core::clone::AssertParamIsClone<Option<CrateNum>>;
        let _: ::core::clone::AssertParamIsClone<usize>;
        *self
    }
}Clone, #[automatically_derived]
impl ::core::cmp::PartialEq for CReaderCacheKey {
    #[inline]
    fn eq(&self, other: &CReaderCacheKey) -> 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)]
424pub struct CReaderCacheKey {
425    pub cnum: Option<CrateNum>,
426    pub pos: usize,
427}
428
429/// Use this rather than `TyKind`, whenever possible.
430#[derive(#[automatically_derived]
impl<'tcx> ::core::marker::Copy for Ty<'tcx> { }Copy, #[automatically_derived]
impl<'tcx> ::core::clone::Clone for Ty<'tcx> {
    #[inline]
    fn clone(&self) -> Ty<'tcx> {
        let _:
                ::core::clone::AssertParamIsClone<Interned<'tcx,
                WithCachedTypeInfo<TyKind<'tcx>>>>;
        *self
    }
}Clone, #[automatically_derived]
impl<'tcx> ::core::cmp::PartialEq for Ty<'tcx> {
    #[inline]
    fn eq(&self, other: &Ty<'tcx>) -> 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, '__ctx>
            ::rustc_data_structures::stable_hasher::HashStable<::rustc_middle::ich::StableHashingContext<'__ctx>>
            for Ty<'tcx> {
            #[inline]
            fn hash_stable(&self,
                __hcx: &mut ::rustc_middle::ich::StableHashingContext<'__ctx>,
                __hasher:
                    &mut ::rustc_data_structures::stable_hasher::StableHasher) {
                match *self {
                    Ty(ref __binding_0) => {
                        { __binding_0.hash_stable(__hcx, __hasher); }
                    }
                }
            }
        }
    };HashStable)]
431#[rustc_diagnostic_item = "Ty"]
432#[rustc_pass_by_value]
433pub struct Ty<'tcx>(Interned<'tcx, WithCachedTypeInfo<TyKind<'tcx>>>);
434
435impl<'tcx> rustc_type_ir::inherent::IntoKind for Ty<'tcx> {
436    type Kind = TyKind<'tcx>;
437
438    fn kind(self) -> TyKind<'tcx> {
439        *self.kind()
440    }
441}
442
443impl<'tcx> rustc_type_ir::Flags for Ty<'tcx> {
444    fn flags(&self) -> TypeFlags {
445        self.0.flags
446    }
447
448    fn outer_exclusive_binder(&self) -> DebruijnIndex {
449        self.0.outer_exclusive_binder
450    }
451}
452
453/// The crate outlives map is computed during typeck and contains the
454/// outlives of every item in the local crate. You should not use it
455/// directly, because to do so will make your pass dependent on the
456/// HIR of every item in the local crate. Instead, use
457/// `tcx.inferred_outlives_of()` to get the outlives for a *particular*
458/// item.
459#[derive(const _: () =
    {
        impl<'tcx, '__ctx>
            ::rustc_data_structures::stable_hasher::HashStable<::rustc_middle::ich::StableHashingContext<'__ctx>>
            for CratePredicatesMap<'tcx> {
            #[inline]
            fn hash_stable(&self,
                __hcx: &mut ::rustc_middle::ich::StableHashingContext<'__ctx>,
                __hasher:
                    &mut ::rustc_data_structures::stable_hasher::StableHasher) {
                match *self {
                    CratePredicatesMap { predicates: ref __binding_0 } => {
                        { __binding_0.hash_stable(__hcx, __hasher); }
                    }
                }
            }
        }
    };HashStable, #[automatically_derived]
impl<'tcx> ::core::fmt::Debug for CratePredicatesMap<'tcx> {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::debug_struct_field1_finish(f,
            "CratePredicatesMap", "predicates", &&self.predicates)
    }
}Debug)]
460pub struct CratePredicatesMap<'tcx> {
461    /// For each struct with outlive bounds, maps to a vector of the
462    /// predicate of its outlive bounds. If an item has no outlives
463    /// bounds, it will have no entry.
464    pub predicates: DefIdMap<&'tcx [(Clause<'tcx>, Span)]>,
465}
466
467#[derive(#[automatically_derived]
impl<'tcx> ::core::clone::Clone for Term<'tcx> {
    #[inline]
    fn clone(&self) -> Term<'tcx> {
        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::cmp::PartialEq for Term<'tcx> {
    #[inline]
    fn eq(&self, other: &Term<'tcx>) -> 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: &Term<'tcx>)
        -> ::core::option::Option<::core::cmp::Ordering> {
        match ::core::cmp::PartialOrd::partial_cmp(&self.ptr, &other.ptr) {
            ::core::option::Option::Some(::core::cmp::Ordering::Equal) =>
                ::core::cmp::PartialOrd::partial_cmp(&self.marker,
                    &other.marker),
            cmp => cmp,
        }
    }
}PartialOrd, #[automatically_derived]
impl<'tcx> ::core::cmp::Ord for Term<'tcx> {
    #[inline]
    fn cmp(&self, other: &Term<'tcx>) -> ::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)]
468pub struct Term<'tcx> {
469    ptr: NonNull<()>,
470    marker: PhantomData<(Ty<'tcx>, Const<'tcx>)>,
471}
472
473impl<'tcx> rustc_type_ir::inherent::Term<TyCtxt<'tcx>> for Term<'tcx> {}
474
475impl<'tcx> rustc_type_ir::inherent::IntoKind for Term<'tcx> {
476    type Kind = TermKind<'tcx>;
477
478    fn kind(self) -> Self::Kind {
479        self.kind()
480    }
481}
482
483unsafe impl<'tcx> rustc_data_structures::sync::DynSend for Term<'tcx> where
484    &'tcx (Ty<'tcx>, Const<'tcx>): rustc_data_structures::sync::DynSend
485{
486}
487unsafe impl<'tcx> rustc_data_structures::sync::DynSync for Term<'tcx> where
488    &'tcx (Ty<'tcx>, Const<'tcx>): rustc_data_structures::sync::DynSync
489{
490}
491unsafe impl<'tcx> Send for Term<'tcx> where &'tcx (Ty<'tcx>, Const<'tcx>): Send {}
492unsafe impl<'tcx> Sync for Term<'tcx> where &'tcx (Ty<'tcx>, Const<'tcx>): Sync {}
493
494impl Debug for Term<'_> {
495    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
496        match self.kind() {
497            TermKind::Ty(ty) => f.write_fmt(format_args!("Term::Ty({0:?})", ty))write!(f, "Term::Ty({ty:?})"),
498            TermKind::Const(ct) => f.write_fmt(format_args!("Term::Const({0:?})", ct))write!(f, "Term::Const({ct:?})"),
499        }
500    }
501}
502
503impl<'tcx> From<Ty<'tcx>> for Term<'tcx> {
504    fn from(ty: Ty<'tcx>) -> Self {
505        TermKind::Ty(ty).pack()
506    }
507}
508
509impl<'tcx> From<Const<'tcx>> for Term<'tcx> {
510    fn from(c: Const<'tcx>) -> Self {
511        TermKind::Const(c).pack()
512    }
513}
514
515impl<'a, 'tcx> HashStable<StableHashingContext<'a>> for Term<'tcx> {
516    fn hash_stable(&self, hcx: &mut StableHashingContext<'a>, hasher: &mut StableHasher) {
517        self.kind().hash_stable(hcx, hasher);
518    }
519}
520
521impl<'tcx> TypeFoldable<TyCtxt<'tcx>> for Term<'tcx> {
522    fn try_fold_with<F: FallibleTypeFolder<TyCtxt<'tcx>>>(
523        self,
524        folder: &mut F,
525    ) -> Result<Self, F::Error> {
526        match self.kind() {
527            ty::TermKind::Ty(ty) => ty.try_fold_with(folder).map(Into::into),
528            ty::TermKind::Const(ct) => ct.try_fold_with(folder).map(Into::into),
529        }
530    }
531
532    fn fold_with<F: TypeFolder<TyCtxt<'tcx>>>(self, folder: &mut F) -> Self {
533        match self.kind() {
534            ty::TermKind::Ty(ty) => ty.fold_with(folder).into(),
535            ty::TermKind::Const(ct) => ct.fold_with(folder).into(),
536        }
537    }
538}
539
540impl<'tcx> TypeVisitable<TyCtxt<'tcx>> for Term<'tcx> {
541    fn visit_with<V: TypeVisitor<TyCtxt<'tcx>>>(&self, visitor: &mut V) -> V::Result {
542        match self.kind() {
543            ty::TermKind::Ty(ty) => ty.visit_with(visitor),
544            ty::TermKind::Const(ct) => ct.visit_with(visitor),
545        }
546    }
547}
548
549impl<'tcx, E: TyEncoder<'tcx>> Encodable<E> for Term<'tcx> {
550    fn encode(&self, e: &mut E) {
551        self.kind().encode(e)
552    }
553}
554
555impl<'tcx, D: TyDecoder<'tcx>> Decodable<D> for Term<'tcx> {
556    fn decode(d: &mut D) -> Self {
557        let res: TermKind<'tcx> = Decodable::decode(d);
558        res.pack()
559    }
560}
561
562impl<'tcx> Term<'tcx> {
563    #[inline]
564    pub fn kind(self) -> TermKind<'tcx> {
565        let ptr =
566            unsafe { self.ptr.map_addr(|addr| NonZero::new_unchecked(addr.get() & !TAG_MASK)) };
567        // SAFETY: use of `Interned::new_unchecked` here is ok because these
568        // pointers were originally created from `Interned` types in `pack()`,
569        // and this is just going in the other direction.
570        unsafe {
571            match self.ptr.addr().get() & TAG_MASK {
572                TYPE_TAG => TermKind::Ty(Ty(Interned::new_unchecked(
573                    ptr.cast::<WithCachedTypeInfo<ty::TyKind<'tcx>>>().as_ref(),
574                ))),
575                CONST_TAG => TermKind::Const(ty::Const(Interned::new_unchecked(
576                    ptr.cast::<WithCachedTypeInfo<ty::ConstKind<'tcx>>>().as_ref(),
577                ))),
578                _ => core::intrinsics::unreachable(),
579            }
580        }
581    }
582
583    pub fn as_type(&self) -> Option<Ty<'tcx>> {
584        if let TermKind::Ty(ty) = self.kind() { Some(ty) } else { None }
585    }
586
587    pub fn expect_type(&self) -> Ty<'tcx> {
588        self.as_type().expect("expected a type, but found a const")
589    }
590
591    pub fn as_const(&self) -> Option<Const<'tcx>> {
592        if let TermKind::Const(c) = self.kind() { Some(c) } else { None }
593    }
594
595    pub fn expect_const(&self) -> Const<'tcx> {
596        self.as_const().expect("expected a const, but found a type")
597    }
598
599    pub fn into_arg(self) -> GenericArg<'tcx> {
600        match self.kind() {
601            TermKind::Ty(ty) => ty.into(),
602            TermKind::Const(c) => c.into(),
603        }
604    }
605
606    pub fn to_alias_term(self) -> Option<AliasTerm<'tcx>> {
607        match self.kind() {
608            TermKind::Ty(ty) => match *ty.kind() {
609                ty::Alias(alias_ty) => Some(alias_ty.into()),
610                _ => None,
611            },
612            TermKind::Const(ct) => match ct.kind() {
613                ConstKind::Unevaluated(uv) => Some(uv.into()),
614                _ => None,
615            },
616        }
617    }
618
619    pub fn is_infer(&self) -> bool {
620        match self.kind() {
621            TermKind::Ty(ty) => ty.is_ty_var(),
622            TermKind::Const(ct) => ct.is_ct_infer(),
623        }
624    }
625
626    pub fn is_trivially_wf(&self, tcx: TyCtxt<'tcx>) -> bool {
627        match self.kind() {
628            TermKind::Ty(ty) => ty.is_trivially_wf(tcx),
629            TermKind::Const(ct) => ct.is_trivially_wf(),
630        }
631    }
632
633    /// Iterator that walks `self` and any types reachable from
634    /// `self`, in depth-first order. Note that just walks the types
635    /// that appear in `self`, it does not descend into the fields of
636    /// structs or variants. For example:
637    ///
638    /// ```text
639    /// isize => { isize }
640    /// Foo<Bar<isize>> => { Foo<Bar<isize>>, Bar<isize>, isize }
641    /// [isize] => { [isize], isize }
642    /// ```
643    pub fn walk(self) -> TypeWalker<TyCtxt<'tcx>> {
644        TypeWalker::new(self.into())
645    }
646}
647
648const TAG_MASK: usize = 0b11;
649const TYPE_TAG: usize = 0b00;
650const CONST_TAG: usize = 0b01;
651
652impl<'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>)]
653impl<'tcx> TermKind<'tcx> {
654    #[inline]
655    fn pack(self) -> Term<'tcx> {
656        let (tag, ptr) = match self {
657            TermKind::Ty(ty) => {
658                // Ensure we can use the tag bits.
659                assert_eq!(align_of_val(&*ty.0.0) & TAG_MASK, 0);
660                (TYPE_TAG, NonNull::from(ty.0.0).cast())
661            }
662            TermKind::Const(ct) => {
663                // Ensure we can use the tag bits.
664                assert_eq!(align_of_val(&*ct.0.0) & TAG_MASK, 0);
665                (CONST_TAG, NonNull::from(ct.0.0).cast())
666            }
667        };
668
669        Term { ptr: ptr.map_addr(|addr| addr | tag), marker: PhantomData }
670    }
671}
672
673/// Represents the bounds declared on a particular set of type
674/// parameters. Should eventually be generalized into a flag list of
675/// where-clauses. You can obtain an `InstantiatedPredicates` list from a
676/// `GenericPredicates` by using the `instantiate` method. Note that this method
677/// reflects an important semantic invariant of `InstantiatedPredicates`: while
678/// the `GenericPredicates` are expressed in terms of the bound type
679/// parameters of the impl/trait/whatever, an `InstantiatedPredicates` instance
680/// represented a set of bounds for some particular instantiation,
681/// meaning that the generic parameters have been instantiated with
682/// their values.
683///
684/// Example:
685/// ```ignore (illustrative)
686/// struct Foo<T, U: Bar<T>> { ... }
687/// ```
688/// Here, the `GenericPredicates` for `Foo` would contain a list of bounds like
689/// `[[], [U:Bar<T>]]`. Now if there were some particular reference
690/// like `Foo<isize,usize>`, then the `InstantiatedPredicates` would be `[[],
691/// [usize:Bar<isize>]]`.
692#[derive(#[automatically_derived]
impl<'tcx> ::core::clone::Clone for InstantiatedPredicates<'tcx> {
    #[inline]
    fn clone(&self) -> InstantiatedPredicates<'tcx> {
        InstantiatedPredicates {
            predicates: ::core::clone::Clone::clone(&self.predicates),
            spans: ::core::clone::Clone::clone(&self.spans),
        }
    }
}Clone, #[automatically_derived]
impl<'tcx> ::core::fmt::Debug for InstantiatedPredicates<'tcx> {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::debug_struct_field2_finish(f,
            "InstantiatedPredicates", "predicates", &self.predicates, "spans",
            &&self.spans)
    }
}Debug, const _: () =
    {
        impl<'tcx>
            ::rustc_middle::ty::TypeFoldable<::rustc_middle::ty::TyCtxt<'tcx>>
            for InstantiatedPredicates<'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 {
                        InstantiatedPredicates {
                            predicates: __binding_0, spans: __binding_1 } => {
                            InstantiatedPredicates {
                                predicates: ::rustc_middle::ty::TypeFoldable::try_fold_with(__binding_0,
                                        __folder)?,
                                spans: ::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 {
                    InstantiatedPredicates {
                        predicates: __binding_0, spans: __binding_1 } => {
                        InstantiatedPredicates {
                            predicates: ::rustc_middle::ty::TypeFoldable::fold_with(__binding_0,
                                __folder),
                            spans: ::rustc_middle::ty::TypeFoldable::fold_with(__binding_1,
                                __folder),
                        }
                    }
                }
            }
        }
    };TypeFoldable, const _: () =
    {
        impl<'tcx>
            ::rustc_middle::ty::TypeVisitable<::rustc_middle::ty::TyCtxt<'tcx>>
            for InstantiatedPredicates<'tcx> {
            fn visit_with<__V: ::rustc_middle::ty::TypeVisitor<::rustc_middle::ty::TyCtxt<'tcx>>>(&self,
                __visitor: &mut __V) -> __V::Result {
                match *self {
                    InstantiatedPredicates {
                        predicates: ref __binding_0, spans: 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)]
693pub struct InstantiatedPredicates<'tcx> {
694    pub predicates: Vec<Clause<'tcx>>,
695    pub spans: Vec<Span>,
696}
697
698impl<'tcx> InstantiatedPredicates<'tcx> {
699    pub fn empty() -> InstantiatedPredicates<'tcx> {
700        InstantiatedPredicates { predicates: ::alloc::vec::Vec::new()vec![], spans: ::alloc::vec::Vec::new()vec![] }
701    }
702
703    pub fn is_empty(&self) -> bool {
704        self.predicates.is_empty()
705    }
706
707    pub fn iter(&self) -> <&Self as IntoIterator>::IntoIter {
708        self.into_iter()
709    }
710}
711
712impl<'tcx> IntoIterator for InstantiatedPredicates<'tcx> {
713    type Item = (Clause<'tcx>, Span);
714
715    type IntoIter = std::iter::Zip<std::vec::IntoIter<Clause<'tcx>>, std::vec::IntoIter<Span>>;
716
717    fn into_iter(self) -> Self::IntoIter {
718        if true {
    match (&self.predicates.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.predicates.len(), self.spans.len());
719        std::iter::zip(self.predicates, self.spans)
720    }
721}
722
723impl<'a, 'tcx> IntoIterator for &'a InstantiatedPredicates<'tcx> {
724    type Item = (Clause<'tcx>, Span);
725
726    type IntoIter = std::iter::Zip<
727        std::iter::Copied<std::slice::Iter<'a, Clause<'tcx>>>,
728        std::iter::Copied<std::slice::Iter<'a, Span>>,
729    >;
730
731    fn into_iter(self) -> Self::IntoIter {
732        if true {
    match (&self.predicates.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.predicates.len(), self.spans.len());
733        std::iter::zip(self.predicates.iter().copied(), self.spans.iter().copied())
734    }
735}
736
737#[derive(#[automatically_derived]
impl<'tcx> ::core::marker::Copy for ProvisionalHiddenType<'tcx> { }Copy, #[automatically_derived]
impl<'tcx> ::core::clone::Clone for ProvisionalHiddenType<'tcx> {
    #[inline]
    fn clone(&self) -> ProvisionalHiddenType<'tcx> {
        let _: ::core::clone::AssertParamIsClone<Span>;
        let _: ::core::clone::AssertParamIsClone<Ty<'tcx>>;
        *self
    }
}Clone, #[automatically_derived]
impl<'tcx> ::core::fmt::Debug for ProvisionalHiddenType<'tcx> {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::debug_struct_field2_finish(f,
            "ProvisionalHiddenType", "span", &self.span, "ty", &&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, '__ctx>
            ::rustc_data_structures::stable_hasher::HashStable<::rustc_middle::ich::StableHashingContext<'__ctx>>
            for ProvisionalHiddenType<'tcx> {
            #[inline]
            fn hash_stable(&self,
                __hcx: &mut ::rustc_middle::ich::StableHashingContext<'__ctx>,
                __hasher:
                    &mut ::rustc_data_structures::stable_hasher::StableHasher) {
                match *self {
                    ProvisionalHiddenType {
                        span: ref __binding_0, ty: ref __binding_1 } => {
                        { __binding_0.hash_stable(__hcx, __hasher); }
                        { __binding_1.hash_stable(__hcx, __hasher); }
                    }
                }
            }
        }
    };HashStable, const _: () =
    {
        impl<'tcx, __E: ::rustc_middle::ty::codec::TyEncoder<'tcx>>
            ::rustc_serialize::Encodable<__E> for ProvisionalHiddenType<'tcx>
            {
            fn encode(&self, __encoder: &mut __E) {
                match *self {
                    ProvisionalHiddenType {
                        span: ref __binding_0, ty: ref __binding_1 } => {
                        ::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)]
738pub struct ProvisionalHiddenType<'tcx> {
739    /// The span of this particular definition of the opaque type. So
740    /// for example:
741    ///
742    /// ```ignore (incomplete snippet)
743    /// type Foo = impl Baz;
744    /// fn bar() -> Foo {
745    /// //          ^^^ This is the span we are looking for!
746    /// }
747    /// ```
748    ///
749    /// In cases where the fn returns `(impl Trait, impl Trait)` or
750    /// other such combinations, the result is currently
751    /// over-approximated, but better than nothing.
752    pub span: Span,
753
754    /// The type variable that represents the value of the opaque type
755    /// that we require. In other words, after we compile this function,
756    /// we will be created a constraint like:
757    /// ```ignore (pseudo-rust)
758    /// Foo<'a, T> = ?C
759    /// ```
760    /// where `?C` is the value of this type variable. =) It may
761    /// naturally refer to the type and lifetime parameters in scope
762    /// in this function, though ultimately it should only reference
763    /// those that are arguments to `Foo` in the constraint above. (In
764    /// other words, `?C` should not include `'b`, even though it's a
765    /// lifetime parameter on `foo`.)
766    pub ty: Ty<'tcx>,
767}
768
769/// Whether we're currently in HIR typeck or MIR borrowck.
770#[derive(#[automatically_derived]
impl ::core::fmt::Debug for DefiningScopeKind {
    #[inline]
    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]
impl ::core::clone::Clone for DefiningScopeKind {
    #[inline]
    fn clone(&self) -> DefiningScopeKind { *self }
}Clone, #[automatically_derived]
impl ::core::marker::Copy for DefiningScopeKind { }Copy)]
771pub enum DefiningScopeKind {
772    /// During writeback in typeck, we don't care about regions and simply
773    /// erase them. This means we also don't check whether regions are
774    /// universal in the opaque type key. This will only be checked in
775    /// MIR borrowck.
776    HirTypeck,
777    MirBorrowck,
778}
779
780impl<'tcx> ProvisionalHiddenType<'tcx> {
781    pub fn new_error(tcx: TyCtxt<'tcx>, guar: ErrorGuaranteed) -> ProvisionalHiddenType<'tcx> {
782        ProvisionalHiddenType { span: DUMMY_SP, ty: Ty::new_error(tcx, guar) }
783    }
784
785    pub fn build_mismatch_error(
786        &self,
787        other: &Self,
788        tcx: TyCtxt<'tcx>,
789    ) -> Result<Diag<'tcx>, ErrorGuaranteed> {
790        (self.ty, other.ty).error_reported()?;
791        // Found different concrete types for the opaque type.
792        let sub_diag = if self.span == other.span {
793            TypeMismatchReason::ConflictType { span: self.span }
794        } else {
795            TypeMismatchReason::PreviousUse { span: self.span }
796        };
797        Ok(tcx.dcx().create_err(OpaqueHiddenTypeMismatch {
798            self_ty: self.ty,
799            other_ty: other.ty,
800            other_span: other.span,
801            sub: sub_diag,
802        }))
803    }
804
805    x;#[instrument(level = "debug", skip(tcx), ret)]
806    pub fn remap_generic_params_to_declaration_params(
807        self,
808        opaque_type_key: OpaqueTypeKey<'tcx>,
809        tcx: TyCtxt<'tcx>,
810        defining_scope_kind: DefiningScopeKind,
811    ) -> DefinitionSiteHiddenType<'tcx> {
812        let OpaqueTypeKey { def_id, args } = opaque_type_key;
813
814        // Use args to build up a reverse map from regions to their
815        // identity mappings. This is necessary because of `impl
816        // Trait` lifetimes are computed by replacing existing
817        // lifetimes with 'static and remapping only those used in the
818        // `impl Trait` return type, resulting in the parameters
819        // shifting.
820        let id_args = GenericArgs::identity_for_item(tcx, def_id);
821        debug!(?id_args);
822
823        // This zip may have several times the same lifetime in `args` paired with a different
824        // lifetime from `id_args`. Simply `collect`ing the iterator is the correct behaviour:
825        // it will pick the last one, which is the one we introduced in the impl-trait desugaring.
826        let map = args.iter().zip(id_args).collect();
827        debug!("map = {:#?}", map);
828
829        // Convert the type from the function into a type valid outside by mapping generic
830        // parameters to into the context of the opaque.
831        //
832        // We erase regions when doing this during HIR typeck. We manually use `fold_regions`
833        // here as we do not want to anonymize bound variables.
834        let ty = match defining_scope_kind {
835            DefiningScopeKind::HirTypeck => {
836                fold_regions(tcx, self.ty, |_, _| tcx.lifetimes.re_erased)
837            }
838            DefiningScopeKind::MirBorrowck => self.ty,
839        };
840        let result_ty = ty.fold_with(&mut opaque_types::ReverseMapper::new(tcx, map, self.span));
841        if cfg!(debug_assertions) && matches!(defining_scope_kind, DefiningScopeKind::HirTypeck) {
842            assert_eq!(result_ty, fold_regions(tcx, result_ty, |_, _| tcx.lifetimes.re_erased));
843        }
844        DefinitionSiteHiddenType { span: self.span, ty: ty::EarlyBinder::bind(result_ty) }
845    }
846}
847
848#[derive(#[automatically_derived]
impl<'tcx> ::core::marker::Copy for DefinitionSiteHiddenType<'tcx> { }Copy, #[automatically_derived]
impl<'tcx> ::core::clone::Clone for DefinitionSiteHiddenType<'tcx> {
    #[inline]
    fn clone(&self) -> DefinitionSiteHiddenType<'tcx> {
        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]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::debug_struct_field2_finish(f,
            "DefinitionSiteHiddenType", "span", &self.span, "ty", &&self.ty)
    }
}Debug, const _: () =
    {
        impl<'tcx, '__ctx>
            ::rustc_data_structures::stable_hasher::HashStable<::rustc_middle::ich::StableHashingContext<'__ctx>>
            for DefinitionSiteHiddenType<'tcx> {
            #[inline]
            fn hash_stable(&self,
                __hcx: &mut ::rustc_middle::ich::StableHashingContext<'__ctx>,
                __hasher:
                    &mut ::rustc_data_structures::stable_hasher::StableHasher) {
                match *self {
                    DefinitionSiteHiddenType {
                        span: ref __binding_0, ty: ref __binding_1 } => {
                        { __binding_0.hash_stable(__hcx, __hasher); }
                        { __binding_1.hash_stable(__hcx, __hasher); }
                    }
                }
            }
        }
    };HashStable, const _: () =
    {
        impl<'tcx, __E: ::rustc_middle::ty::codec::TyEncoder<'tcx>>
            ::rustc_serialize::Encodable<__E> for
            DefinitionSiteHiddenType<'tcx> {
            fn encode(&self, __encoder: &mut __E) {
                match *self {
                    DefinitionSiteHiddenType {
                        span: ref __binding_0, ty: ref __binding_1 } => {
                        ::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)]
849pub struct DefinitionSiteHiddenType<'tcx> {
850    /// The span of the definition of the opaque type. So for example:
851    ///
852    /// ```ignore (incomplete snippet)
853    /// type Foo = impl Baz;
854    /// fn bar() -> Foo {
855    /// //          ^^^ This is the span we are looking for!
856    /// }
857    /// ```
858    ///
859    /// In cases where the fn returns `(impl Trait, impl Trait)` or
860    /// other such combinations, the result is currently
861    /// over-approximated, but better than nothing.
862    pub span: Span,
863
864    /// The final type of the opaque.
865    pub ty: ty::EarlyBinder<'tcx, Ty<'tcx>>,
866}
867
868impl<'tcx> DefinitionSiteHiddenType<'tcx> {
869    pub fn new_error(tcx: TyCtxt<'tcx>, guar: ErrorGuaranteed) -> DefinitionSiteHiddenType<'tcx> {
870        DefinitionSiteHiddenType {
871            span: DUMMY_SP,
872            ty: ty::EarlyBinder::bind(Ty::new_error(tcx, guar)),
873        }
874    }
875
876    pub fn build_mismatch_error(
877        &self,
878        other: &Self,
879        tcx: TyCtxt<'tcx>,
880    ) -> Result<Diag<'tcx>, ErrorGuaranteed> {
881        let self_ty = self.ty.instantiate_identity();
882        let other_ty = other.ty.instantiate_identity();
883        (self_ty, other_ty).error_reported()?;
884        // Found different concrete types for the opaque type.
885        let sub_diag = if self.span == other.span {
886            TypeMismatchReason::ConflictType { span: self.span }
887        } else {
888            TypeMismatchReason::PreviousUse { span: self.span }
889        };
890        Ok(tcx.dcx().create_err(OpaqueHiddenTypeMismatch {
891            self_ty,
892            other_ty,
893            other_span: other.span,
894            sub: sub_diag,
895        }))
896    }
897}
898
899pub type Clauses<'tcx> = &'tcx ListWithCachedTypeInfo<Clause<'tcx>>;
900
901impl<'tcx> rustc_type_ir::Flags for Clauses<'tcx> {
902    fn flags(&self) -> TypeFlags {
903        (**self).flags()
904    }
905
906    fn outer_exclusive_binder(&self) -> DebruijnIndex {
907        (**self).outer_exclusive_binder()
908    }
909}
910
911/// When interacting with the type system we must provide information about the
912/// environment. `ParamEnv` is the type that represents this information. See the
913/// [dev guide chapter][param_env_guide] for more information.
914///
915/// [param_env_guide]: https://rustc-dev-guide.rust-lang.org/typing_parameter_envs.html
916#[derive(#[automatically_derived]
impl<'tcx> ::core::fmt::Debug for ParamEnv<'tcx> {
    #[inline]
    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]
impl<'tcx> ::core::clone::Clone for ParamEnv<'tcx> {
    #[inline]
    fn clone(&self) -> ParamEnv<'tcx> {
        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::cmp::PartialEq for ParamEnv<'tcx> {
    #[inline]
    fn eq(&self, other: &ParamEnv<'tcx>) -> 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)]
917#[derive(const _: () =
    {
        impl<'tcx, '__ctx>
            ::rustc_data_structures::stable_hasher::HashStable<::rustc_middle::ich::StableHashingContext<'__ctx>>
            for ParamEnv<'tcx> {
            #[inline]
            fn hash_stable(&self,
                __hcx: &mut ::rustc_middle::ich::StableHashingContext<'__ctx>,
                __hasher:
                    &mut ::rustc_data_structures::stable_hasher::StableHasher) {
                match *self {
                    ParamEnv { caller_bounds: ref __binding_0 } => {
                        { __binding_0.hash_stable(__hcx, __hasher); }
                    }
                }
            }
        }
    };HashStable, 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)]
918pub struct ParamEnv<'tcx> {
919    /// Caller bounds are `Obligation`s that the caller must satisfy. This is
920    /// basically the set of bounds on the in-scope type parameters, translated
921    /// into `Obligation`s, and elaborated and normalized.
922    ///
923    /// Use the `caller_bounds()` method to access.
924    caller_bounds: Clauses<'tcx>,
925}
926
927impl<'tcx> rustc_type_ir::inherent::ParamEnv<TyCtxt<'tcx>> for ParamEnv<'tcx> {
928    fn caller_bounds(self) -> impl inherent::SliceLike<Item = ty::Clause<'tcx>> {
929        self.caller_bounds()
930    }
931}
932
933impl<'tcx> ParamEnv<'tcx> {
934    /// Construct a trait environment suitable for contexts where there are
935    /// no where-clauses in scope. In the majority of cases it is incorrect
936    /// to use an empty environment. See the [dev guide section][param_env_guide]
937    /// for information on what a `ParamEnv` is and how to acquire one.
938    ///
939    /// [param_env_guide]: https://rustc-dev-guide.rust-lang.org/typing_parameter_envs.html
940    #[inline]
941    pub fn empty() -> Self {
942        Self::new(ListWithCachedTypeInfo::empty())
943    }
944
945    #[inline]
946    pub fn caller_bounds(self) -> Clauses<'tcx> {
947        self.caller_bounds
948    }
949
950    /// Construct a trait environment with the given set of predicates.
951    #[inline]
952    pub fn new(caller_bounds: Clauses<'tcx>) -> Self {
953        ParamEnv { caller_bounds }
954    }
955
956    /// Creates a pair of param-env and value for use in queries.
957    pub fn and<T: TypeVisitable<TyCtxt<'tcx>>>(self, value: T) -> ParamEnvAnd<'tcx, T> {
958        ParamEnvAnd { param_env: self, value }
959    }
960}
961
962#[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]
    fn clone(&self) -> ParamEnvAnd<'tcx, T> {
        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]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::debug_struct_field2_finish(f, "ParamEnvAnd",
            "param_env", &self.param_env, "value", &&self.value)
    }
}Debug, #[automatically_derived]
impl<'tcx, T: ::core::cmp::PartialEq> ::core::cmp::PartialEq for
    ParamEnvAnd<'tcx, T> {
    #[inline]
    fn eq(&self, other: &ParamEnvAnd<'tcx, T>) -> 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)]
963#[derive(const _: () =
    {
        impl<'tcx, '__ctx, T>
            ::rustc_data_structures::stable_hasher::HashStable<::rustc_middle::ich::StableHashingContext<'__ctx>>
            for ParamEnvAnd<'tcx, T> where
            T: ::rustc_data_structures::stable_hasher::HashStable<::rustc_middle::ich::StableHashingContext<'__ctx>>
            {
            #[inline]
            fn hash_stable(&self,
                __hcx: &mut ::rustc_middle::ich::StableHashingContext<'__ctx>,
                __hasher:
                    &mut ::rustc_data_structures::stable_hasher::StableHasher) {
                match *self {
                    ParamEnvAnd {
                        param_env: ref __binding_0, value: ref __binding_1 } => {
                        { __binding_0.hash_stable(__hcx, __hasher); }
                        { __binding_1.hash_stable(__hcx, __hasher); }
                    }
                }
            }
        }
    };HashStable)]
964pub struct ParamEnvAnd<'tcx, T> {
965    pub param_env: ParamEnv<'tcx>,
966    pub value: T,
967}
968
969/// The environment in which to do trait solving.
970///
971/// Most of the time you only need to care about the `ParamEnv`
972/// as the `TypingMode` is simply stored in the `InferCtxt`.
973///
974/// However, there are some places which rely on trait solving
975/// without using an `InferCtxt` themselves. For these to be
976/// able to use the trait system they have to be able to initialize
977/// such an `InferCtxt` with the right `typing_mode`, so they need
978/// to track both.
979#[derive(#[automatically_derived]
impl<'tcx> ::core::marker::Copy for TypingEnv<'tcx> { }Copy, #[automatically_derived]
impl<'tcx> ::core::clone::Clone for TypingEnv<'tcx> {
    #[inline]
    fn clone(&self) -> TypingEnv<'tcx> {
        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]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::debug_struct_field2_finish(f, "TypingEnv",
            "typing_mode", &self.typing_mode, "param_env", &&self.param_env)
    }
}Debug, #[automatically_derived]
impl<'tcx> ::core::cmp::PartialEq for TypingEnv<'tcx> {
    #[inline]
    fn eq(&self, other: &TypingEnv<'tcx>) -> 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, '__ctx>
            ::rustc_data_structures::stable_hasher::HashStable<::rustc_middle::ich::StableHashingContext<'__ctx>>
            for TypingEnv<'tcx> {
            #[inline]
            fn hash_stable(&self,
                __hcx: &mut ::rustc_middle::ich::StableHashingContext<'__ctx>,
                __hasher:
                    &mut ::rustc_data_structures::stable_hasher::StableHasher) {
                match *self {
                    TypingEnv {
                        typing_mode: ref __binding_0, param_env: ref __binding_1 }
                        => {
                        { __binding_0.hash_stable(__hcx, __hasher); }
                        { __binding_1.hash_stable(__hcx, __hasher); }
                    }
                }
            }
        }
    };HashStable)]
980#[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)]
981pub struct TypingEnv<'tcx> {
982    #[type_foldable(identity)]
983    #[type_visitable(ignore)]
984    typing_mode: TypingModeEqWrapper<'tcx>,
985    pub param_env: ParamEnv<'tcx>,
986}
987
988impl<'tcx> TypingEnv<'tcx> {
989    pub fn new(param_env: ParamEnv<'tcx>, typing_mode: TypingMode<'tcx>) -> Self {
990        Self { typing_mode: TypingModeEqWrapper(typing_mode), param_env }
991    }
992
993    pub fn typing_mode(&self) -> TypingMode<'tcx> {
994        self.typing_mode.0
995    }
996
997    /// Create a typing environment with no where-clauses in scope
998    /// where all opaque types and default associated items are revealed.
999    ///
1000    /// This is only suitable for monomorphized, post-typeck environments.
1001    /// Do not use this for MIR optimizations, as even though they also
1002    /// use `TypingMode::PostAnalysis`, they may still have where-clauses
1003    /// in scope.
1004    pub fn fully_monomorphized() -> TypingEnv<'tcx> {
1005        Self::new(ParamEnv::empty(), TypingMode::PostAnalysis)
1006    }
1007
1008    /// Create a typing environment for use during analysis outside of a body.
1009    ///
1010    /// Using a typing environment inside of bodies is not supported as the body
1011    /// may define opaque types. In this case the used functions have to be
1012    /// converted to use proper canonical inputs instead.
1013    pub fn non_body_analysis(
1014        tcx: TyCtxt<'tcx>,
1015        def_id: impl IntoQueryKey<DefId>,
1016    ) -> TypingEnv<'tcx> {
1017        let def_id = def_id.into_query_key();
1018        Self::new(tcx.param_env(def_id), TypingMode::non_body_analysis())
1019    }
1020
1021    pub fn post_analysis(tcx: TyCtxt<'tcx>, def_id: impl IntoQueryKey<DefId>) -> TypingEnv<'tcx> {
1022        let def_id = def_id.into_query_key();
1023        tcx.typing_env_normalized_for_post_analysis(def_id)
1024    }
1025
1026    /// Modify the `typing_mode` to `PostAnalysis` and eagerly reveal all
1027    /// opaque types in the `param_env`.
1028    pub fn with_post_analysis_normalized(self, tcx: TyCtxt<'tcx>) -> TypingEnv<'tcx> {
1029        let TypingEnv { typing_mode, param_env } = self;
1030        match typing_mode.0 {
1031            TypingMode::Coherence
1032            | TypingMode::Analysis { .. }
1033            | TypingMode::Borrowck { .. }
1034            | TypingMode::PostBorrowckAnalysis { .. } => {}
1035            TypingMode::PostAnalysis => return self,
1036        }
1037
1038        // No need to reveal opaques with the new solver enabled,
1039        // since we have lazy norm.
1040        let param_env = if tcx.next_trait_solver_globally() {
1041            param_env
1042        } else {
1043            ParamEnv::new(tcx.reveal_opaque_types_in_bounds(param_env.caller_bounds()))
1044        };
1045        TypingEnv { typing_mode: TypingModeEqWrapper(TypingMode::PostAnalysis), param_env }
1046    }
1047
1048    /// Combine this typing environment with the given `value` to be used by
1049    /// not (yet) canonicalized queries. This only works if the value does not
1050    /// contain anything local to some `InferCtxt`, i.e. inference variables or
1051    /// placeholders.
1052    pub fn as_query_input<T>(self, value: T) -> PseudoCanonicalInput<'tcx, T>
1053    where
1054        T: TypeVisitable<TyCtxt<'tcx>>,
1055    {
1056        // FIXME(#132279): We should assert that the value does not contain any placeholders
1057        // as these placeholders are also local to the current inference context. However, we
1058        // currently use pseudo-canonical queries in the trait solver, which replaces params
1059        // with placeholders during canonicalization. We should also simply not use pseudo-
1060        // canonical queries in the trait solver, at which point we can readd this assert.
1061        //
1062        // As of writing this comment, this is only used when normalizing consts that mention
1063        // params.
1064        /* debug_assert!(
1065            !value.has_placeholders(),
1066            "{value:?} which has placeholder shouldn't be pseudo-canonicalized"
1067        ); */
1068        PseudoCanonicalInput { typing_env: self, value }
1069    }
1070}
1071
1072/// Similar to `CanonicalInput`, this carries the `typing_mode` and the environment
1073/// necessary to do any kind of trait solving inside of nested queries.
1074///
1075/// Unlike proper canonicalization, this requires the `param_env` and the `value` to not
1076/// contain anything local to the `infcx` of the caller, so we don't actually canonicalize
1077/// anything.
1078///
1079/// This should be created by using `infcx.pseudo_canonicalize_query(param_env, value)`
1080/// or by using `typing_env.as_query_input(value)`.
1081#[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]
    fn clone(&self) -> PseudoCanonicalInput<'tcx, T> {
        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]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::debug_struct_field2_finish(f,
            "PseudoCanonicalInput", "typing_env", &self.typing_env, "value",
            &&self.value)
    }
}Debug, #[automatically_derived]
impl<'tcx, T: ::core::cmp::PartialEq> ::core::cmp::PartialEq for
    PseudoCanonicalInput<'tcx, T> {
    #[inline]
    fn eq(&self, other: &PseudoCanonicalInput<'tcx, T>) -> 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)]
1082#[derive(const _: () =
    {
        impl<'tcx, '__ctx, T>
            ::rustc_data_structures::stable_hasher::HashStable<::rustc_middle::ich::StableHashingContext<'__ctx>>
            for PseudoCanonicalInput<'tcx, T> where
            T: ::rustc_data_structures::stable_hasher::HashStable<::rustc_middle::ich::StableHashingContext<'__ctx>>
            {
            #[inline]
            fn hash_stable(&self,
                __hcx: &mut ::rustc_middle::ich::StableHashingContext<'__ctx>,
                __hasher:
                    &mut ::rustc_data_structures::stable_hasher::StableHasher) {
                match *self {
                    PseudoCanonicalInput {
                        typing_env: ref __binding_0, value: ref __binding_1 } => {
                        { __binding_0.hash_stable(__hcx, __hasher); }
                        { __binding_1.hash_stable(__hcx, __hasher); }
                    }
                }
            }
        }
    };HashStable, 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)]
1083pub struct PseudoCanonicalInput<'tcx, T> {
1084    pub typing_env: TypingEnv<'tcx>,
1085    pub value: T,
1086}
1087
1088#[derive(#[automatically_derived]
impl ::core::marker::Copy for Destructor { }Copy, #[automatically_derived]
impl ::core::clone::Clone for Destructor {
    #[inline]
    fn clone(&self) -> Destructor {
        let _: ::core::clone::AssertParamIsClone<DefId>;
        *self
    }
}Clone, #[automatically_derived]
impl ::core::fmt::Debug for Destructor {
    #[inline]
    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<'__ctx>
            ::rustc_data_structures::stable_hasher::HashStable<::rustc_middle::ich::StableHashingContext<'__ctx>>
            for Destructor {
            #[inline]
            fn hash_stable(&self,
                __hcx: &mut ::rustc_middle::ich::StableHashingContext<'__ctx>,
                __hasher:
                    &mut ::rustc_data_structures::stable_hasher::StableHasher) {
                match *self {
                    Destructor { did: ref __binding_0 } => {
                        { __binding_0.hash_stable(__hcx, __hasher); }
                    }
                }
            }
        }
    };HashStable, const _: () =
    {
        impl<__E: ::rustc_span::SpanEncoder> ::rustc_serialize::Encodable<__E>
            for Destructor {
            fn encode(&self, __encoder: &mut __E) {
                match *self {
                    Destructor { did: ref __binding_0 } => {
                        ::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)]
1089pub struct Destructor {
1090    /// The `DefId` of the destructor method
1091    pub did: DefId,
1092}
1093
1094// FIXME: consider combining this definition with regular `Destructor`
1095#[derive(#[automatically_derived]
impl ::core::marker::Copy for AsyncDestructor { }Copy, #[automatically_derived]
impl ::core::clone::Clone for AsyncDestructor {
    #[inline]
    fn clone(&self) -> AsyncDestructor {
        let _: ::core::clone::AssertParamIsClone<DefId>;
        *self
    }
}Clone, #[automatically_derived]
impl ::core::fmt::Debug for AsyncDestructor {
    #[inline]
    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<'__ctx>
            ::rustc_data_structures::stable_hasher::HashStable<::rustc_middle::ich::StableHashingContext<'__ctx>>
            for AsyncDestructor {
            #[inline]
            fn hash_stable(&self,
                __hcx: &mut ::rustc_middle::ich::StableHashingContext<'__ctx>,
                __hasher:
                    &mut ::rustc_data_structures::stable_hasher::StableHasher) {
                match *self {
                    AsyncDestructor { impl_did: ref __binding_0 } => {
                        { __binding_0.hash_stable(__hcx, __hasher); }
                    }
                }
            }
        }
    };HashStable, const _: () =
    {
        impl<__E: ::rustc_span::SpanEncoder> ::rustc_serialize::Encodable<__E>
            for AsyncDestructor {
            fn encode(&self, __encoder: &mut __E) {
                match *self {
                    AsyncDestructor { impl_did: ref __binding_0 } => {
                        ::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)]
1096pub struct AsyncDestructor {
1097    /// The `DefId` of the `impl AsyncDrop`
1098    pub impl_did: DefId,
1099}
1100
1101#[derive(#[automatically_derived]
impl ::core::clone::Clone for VariantFlags {
    #[inline]
    fn clone(&self) -> VariantFlags {
        let _: ::core::clone::AssertParamIsClone<u8>;
        *self
    }
}Clone, #[automatically_derived]
impl ::core::marker::Copy for VariantFlags { }Copy, #[automatically_derived]
impl ::core::cmp::PartialEq for VariantFlags {
    #[inline]
    fn eq(&self, other: &VariantFlags) -> 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<'__ctx>
            ::rustc_data_structures::stable_hasher::HashStable<::rustc_middle::ich::StableHashingContext<'__ctx>>
            for VariantFlags {
            #[inline]
            fn hash_stable(&self,
                __hcx: &mut ::rustc_middle::ich::StableHashingContext<'__ctx>,
                __hasher:
                    &mut ::rustc_data_structures::stable_hasher::StableHasher) {
                match *self {
                    VariantFlags(ref __binding_0) => {
                        { __binding_0.hash_stable(__hcx, __hasher); }
                    }
                }
            }
        }
    };HashStable, const _: () =
    {
        impl<'tcx, __E: ::rustc_middle::ty::codec::TyEncoder<'tcx>>
            ::rustc_serialize::Encodable<__E> for VariantFlags {
            fn encode(&self, __encoder: &mut __E) {
                match *self {
                    VariantFlags(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 VariantFlags {
            fn decode(__decoder: &mut __D) -> Self {
                VariantFlags(::rustc_serialize::Decodable::decode(__decoder))
            }
        }
    };TyDecodable)]
1102pub struct VariantFlags(u8);
1103impl 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! {
1104    impl VariantFlags: u8 {
1105        const NO_VARIANT_FLAGS        = 0;
1106        /// Indicates whether the field list of this variant is `#[non_exhaustive]`.
1107        const IS_FIELD_LIST_NON_EXHAUSTIVE = 1 << 0;
1108    }
1109}
1110impl ::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 }
1111
1112/// Definition of a variant -- a struct's fields or an enum variant.
1113#[derive(#[automatically_derived]
impl ::core::fmt::Debug for VariantDef {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        let names: &'static _ =
            &["def_id", "ctor", "name", "discr", "fields", "tainted",
                        "flags"];
        let values: &[&dyn ::core::fmt::Debug] =
            &[&self.def_id, &self.ctor, &self.name, &self.discr, &self.fields,
                        &self.tainted, &&self.flags];
        ::core::fmt::Formatter::debug_struct_fields_finish(f, "VariantDef",
            names, values)
    }
}Debug, const _: () =
    {
        impl<'__ctx>
            ::rustc_data_structures::stable_hasher::HashStable<::rustc_middle::ich::StableHashingContext<'__ctx>>
            for VariantDef {
            #[inline]
            fn hash_stable(&self,
                __hcx: &mut ::rustc_middle::ich::StableHashingContext<'__ctx>,
                __hasher:
                    &mut ::rustc_data_structures::stable_hasher::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.hash_stable(__hcx, __hasher); }
                        { __binding_1.hash_stable(__hcx, __hasher); }
                        { __binding_2.hash_stable(__hcx, __hasher); }
                        { __binding_3.hash_stable(__hcx, __hasher); }
                        { __binding_4.hash_stable(__hcx, __hasher); }
                        { __binding_5.hash_stable(__hcx, __hasher); }
                        { __binding_6.hash_stable(__hcx, __hasher); }
                    }
                }
            }
        }
    };HashStable, const _: () =
    {
        impl<'tcx, __E: ::rustc_middle::ty::codec::TyEncoder<'tcx>>
            ::rustc_serialize::Encodable<__E> for VariantDef {
            fn encode(&self, __encoder: &mut __E) {
                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 } => {
                        ::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)]
1114pub struct VariantDef {
1115    /// `DefId` that identifies the variant itself.
1116    /// If this variant belongs to a struct or union, then this is a copy of its `DefId`.
1117    pub def_id: DefId,
1118    /// `DefId` that identifies the variant's constructor.
1119    /// If this variant is a struct variant, then this is `None`.
1120    pub ctor: Option<(CtorKind, DefId)>,
1121    /// Variant or struct name.
1122    pub name: Symbol,
1123    /// Discriminant of this variant.
1124    pub discr: VariantDiscr,
1125    /// Fields of this variant.
1126    pub fields: IndexVec<FieldIdx, FieldDef>,
1127    /// The error guarantees from parser, if any.
1128    tainted: Option<ErrorGuaranteed>,
1129    /// Flags of the variant (e.g. is field list non-exhaustive)?
1130    flags: VariantFlags,
1131}
1132
1133impl VariantDef {
1134    /// Creates a new `VariantDef`.
1135    ///
1136    /// `variant_did` is the `DefId` that identifies the enum variant (if this `VariantDef`
1137    /// represents an enum variant).
1138    ///
1139    /// `ctor_did` is the `DefId` that identifies the constructor of unit or
1140    /// tuple-variants/structs. If this is a `struct`-variant then this should be `None`.
1141    ///
1142    /// `parent_did` is the `DefId` of the `AdtDef` representing the enum or struct that
1143    /// owns this variant. It is used for checking if a struct has `#[non_exhaustive]` w/out having
1144    /// to go through the redirect of checking the ctor's attributes - but compiling a small crate
1145    /// requires loading the `AdtDef`s for all the structs in the universe (e.g., coherence for any
1146    /// built-in trait), and we do not want to load attributes twice.
1147    ///
1148    /// If someone speeds up attribute loading to not be a performance concern, they can
1149    /// remove this hack and use the constructor `DefId` everywhere.
1150    #[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("compiler/rustc_middle/src/ty/mod.rs"),
                                    ::tracing_core::__macro_support::Option::Some(1150u32),
                                    ::tracing_core::__macro_support::Option::Some("rustc_middle::ty"),
                                    ::tracing_core::field::FieldSet::new(&["name",
                                                    "variant_did", "ctor", "discr", "fields", "parent_did",
                                                    "recover_tainted", "is_field_list_non_exhaustive"],
                                        ::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};
                                let mut iter = meta.fields().iter();
                                meta.fields().value_set(&[(&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
                                                    ::tracing::__macro_support::Option::Some(&::tracing::field::debug(&name)
                                                            as &dyn Value)),
                                                (&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
                                                    ::tracing::__macro_support::Option::Some(&::tracing::field::debug(&variant_did)
                                                            as &dyn Value)),
                                                (&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
                                                    ::tracing::__macro_support::Option::Some(&::tracing::field::debug(&ctor)
                                                            as &dyn Value)),
                                                (&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
                                                    ::tracing::__macro_support::Option::Some(&::tracing::field::debug(&discr)
                                                            as &dyn Value)),
                                                (&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
                                                    ::tracing::__macro_support::Option::Some(&::tracing::field::debug(&fields)
                                                            as &dyn Value)),
                                                (&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
                                                    ::tracing::__macro_support::Option::Some(&::tracing::field::debug(&parent_did)
                                                            as &dyn Value)),
                                                (&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
                                                    ::tracing::__macro_support::Option::Some(&::tracing::field::debug(&recover_tainted)
                                                            as &dyn Value)),
                                                (&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
                                                    ::tracing::__macro_support::Option::Some(&is_field_list_non_exhaustive
                                                            as &dyn 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")]
1151    pub fn new(
1152        name: Symbol,
1153        variant_did: Option<DefId>,
1154        ctor: Option<(CtorKind, DefId)>,
1155        discr: VariantDiscr,
1156        fields: IndexVec<FieldIdx, FieldDef>,
1157        parent_did: DefId,
1158        recover_tainted: Option<ErrorGuaranteed>,
1159        is_field_list_non_exhaustive: bool,
1160    ) -> Self {
1161        let mut flags = VariantFlags::NO_VARIANT_FLAGS;
1162        if is_field_list_non_exhaustive {
1163            flags |= VariantFlags::IS_FIELD_LIST_NON_EXHAUSTIVE;
1164        }
1165
1166        VariantDef {
1167            def_id: variant_did.unwrap_or(parent_did),
1168            ctor,
1169            name,
1170            discr,
1171            fields,
1172            flags,
1173            tainted: recover_tainted,
1174        }
1175    }
1176
1177    /// Returns `true` if the field list of this variant is `#[non_exhaustive]`.
1178    ///
1179    /// Note that this function will return `true` even if the type has been
1180    /// defined in the crate currently being compiled. If that's not what you
1181    /// want, see [`Self::field_list_has_applicable_non_exhaustive`].
1182    #[inline]
1183    pub fn is_field_list_non_exhaustive(&self) -> bool {
1184        self.flags.intersects(VariantFlags::IS_FIELD_LIST_NON_EXHAUSTIVE)
1185    }
1186
1187    /// Returns `true` if the field list of this variant is `#[non_exhaustive]`
1188    /// and the type has been defined in another crate.
1189    #[inline]
1190    pub fn field_list_has_applicable_non_exhaustive(&self) -> bool {
1191        self.is_field_list_non_exhaustive() && !self.def_id.is_local()
1192    }
1193
1194    /// Computes the `Ident` of this variant by looking up the `Span`
1195    pub fn ident(&self, tcx: TyCtxt<'_>) -> Ident {
1196        Ident::new(self.name, tcx.def_ident_span(self.def_id).unwrap())
1197    }
1198
1199    /// Was this variant obtained as part of recovering from a syntactic error?
1200    #[inline]
1201    pub fn has_errors(&self) -> Result<(), ErrorGuaranteed> {
1202        self.tainted.map_or(Ok(()), Err)
1203    }
1204
1205    #[inline]
1206    pub fn ctor_kind(&self) -> Option<CtorKind> {
1207        self.ctor.map(|(kind, _)| kind)
1208    }
1209
1210    #[inline]
1211    pub fn ctor_def_id(&self) -> Option<DefId> {
1212        self.ctor.map(|(_, def_id)| def_id)
1213    }
1214
1215    /// Returns the one field in this variant.
1216    ///
1217    /// `panic!`s if there are no fields or multiple fields.
1218    #[inline]
1219    pub fn single_field(&self) -> &FieldDef {
1220        if !(self.fields.len() == 1) {
    ::core::panicking::panic("assertion failed: self.fields.len() == 1")
};assert!(self.fields.len() == 1);
1221
1222        &self.fields[FieldIdx::ZERO]
1223    }
1224
1225    /// Returns the last field in this variant, if present.
1226    #[inline]
1227    pub fn tail_opt(&self) -> Option<&FieldDef> {
1228        self.fields.raw.last()
1229    }
1230
1231    /// Returns the last field in this variant.
1232    ///
1233    /// # Panics
1234    ///
1235    /// Panics, if the variant has no fields.
1236    #[inline]
1237    pub fn tail(&self) -> &FieldDef {
1238        self.tail_opt().expect("expected unsized ADT to have a tail field")
1239    }
1240
1241    /// Returns whether this variant has unsafe fields.
1242    pub fn has_unsafe_fields(&self) -> bool {
1243        self.fields.iter().any(|x| x.safety.is_unsafe())
1244    }
1245}
1246
1247impl PartialEq for VariantDef {
1248    #[inline]
1249    fn eq(&self, other: &Self) -> bool {
1250        // There should be only one `VariantDef` for each `def_id`, therefore
1251        // it is fine to implement `PartialEq` only based on `def_id`.
1252        //
1253        // Below, we exhaustively destructure `self` and `other` so that if the
1254        // definition of `VariantDef` changes, a compile-error will be produced,
1255        // reminding us to revisit this assumption.
1256
1257        let Self {
1258            def_id: lhs_def_id,
1259            ctor: _,
1260            name: _,
1261            discr: _,
1262            fields: _,
1263            flags: _,
1264            tainted: _,
1265        } = &self;
1266        let Self {
1267            def_id: rhs_def_id,
1268            ctor: _,
1269            name: _,
1270            discr: _,
1271            fields: _,
1272            flags: _,
1273            tainted: _,
1274        } = other;
1275
1276        let res = lhs_def_id == rhs_def_id;
1277
1278        // Double check that implicit assumption detailed above.
1279        if truecfg!(debug_assertions) && res {
1280            let deep = self.ctor == other.ctor
1281                && self.name == other.name
1282                && self.discr == other.discr
1283                && self.fields == other.fields
1284                && self.flags == other.flags;
1285            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");
1286        }
1287
1288        res
1289    }
1290}
1291
1292impl Eq for VariantDef {}
1293
1294impl Hash for VariantDef {
1295    #[inline]
1296    fn hash<H: Hasher>(&self, s: &mut H) {
1297        // There should be only one `VariantDef` for each `def_id`, therefore
1298        // it is fine to implement `Hash` only based on `def_id`.
1299        //
1300        // Below, we exhaustively destructure `self` so that if the definition
1301        // of `VariantDef` changes, a compile-error will be produced, reminding
1302        // us to revisit this assumption.
1303
1304        let Self { def_id, ctor: _, name: _, discr: _, fields: _, flags: _, tainted: _ } = &self;
1305        def_id.hash(s)
1306    }
1307}
1308
1309#[derive(#[automatically_derived]
impl ::core::marker::Copy for VariantDiscr { }Copy, #[automatically_derived]
impl ::core::clone::Clone for VariantDiscr {
    #[inline]
    fn clone(&self) -> VariantDiscr {
        let _: ::core::clone::AssertParamIsClone<DefId>;
        let _: ::core::clone::AssertParamIsClone<u32>;
        *self
    }
}Clone, #[automatically_derived]
impl ::core::fmt::Debug for VariantDiscr {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        match self {
            VariantDiscr::Explicit(__self_0) =>
                ::core::fmt::Formatter::debug_tuple_field1_finish(f,
                    "Explicit", &__self_0),
            VariantDiscr::Relative(__self_0) =>
                ::core::fmt::Formatter::debug_tuple_field1_finish(f,
                    "Relative", &__self_0),
        }
    }
}Debug, #[automatically_derived]
impl ::core::cmp::PartialEq for VariantDiscr {
    #[inline]
    fn eq(&self, other: &VariantDiscr) -> bool {
        let __self_discr = ::core::intrinsics::discriminant_value(self);
        let __arg1_discr = ::core::intrinsics::discriminant_value(other);
        __self_discr == __arg1_discr &&
            match (self, other) {
                (VariantDiscr::Explicit(__self_0),
                    VariantDiscr::Explicit(__arg1_0)) => __self_0 == __arg1_0,
                (VariantDiscr::Relative(__self_0),
                    VariantDiscr::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<'__ctx>
            ::rustc_data_structures::stable_hasher::HashStable<::rustc_middle::ich::StableHashingContext<'__ctx>>
            for VariantDiscr {
            #[inline]
            fn hash_stable(&self,
                __hcx: &mut ::rustc_middle::ich::StableHashingContext<'__ctx>,
                __hasher:
                    &mut ::rustc_data_structures::stable_hasher::StableHasher) {
                ::std::mem::discriminant(self).hash_stable(__hcx, __hasher);
                match *self {
                    VariantDiscr::Explicit(ref __binding_0) => {
                        { __binding_0.hash_stable(__hcx, __hasher); }
                    }
                    VariantDiscr::Relative(ref __binding_0) => {
                        { __binding_0.hash_stable(__hcx, __hasher); }
                    }
                }
            }
        }
    };HashStable)]
1310pub enum VariantDiscr {
1311    /// Explicit value for this variant, i.e., `X = 123`.
1312    /// The `DefId` corresponds to the embedded constant.
1313    Explicit(DefId),
1314
1315    /// The previous variant's discriminant plus one.
1316    /// For efficiency reasons, the distance from the
1317    /// last `Explicit` discriminant is being stored,
1318    /// or `0` for the first variant, if it has none.
1319    Relative(u32),
1320}
1321
1322#[derive(#[automatically_derived]
impl ::core::fmt::Debug for FieldDef {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::debug_struct_field5_finish(f, "FieldDef",
            "did", &self.did, "name", &self.name, "vis", &self.vis, "safety",
            &self.safety, "value", &&self.value)
    }
}Debug, const _: () =
    {
        impl<'__ctx>
            ::rustc_data_structures::stable_hasher::HashStable<::rustc_middle::ich::StableHashingContext<'__ctx>>
            for FieldDef {
            #[inline]
            fn hash_stable(&self,
                __hcx: &mut ::rustc_middle::ich::StableHashingContext<'__ctx>,
                __hasher:
                    &mut ::rustc_data_structures::stable_hasher::StableHasher) {
                match *self {
                    FieldDef {
                        did: ref __binding_0,
                        name: ref __binding_1,
                        vis: ref __binding_2,
                        safety: ref __binding_3,
                        value: ref __binding_4 } => {
                        { __binding_0.hash_stable(__hcx, __hasher); }
                        { __binding_1.hash_stable(__hcx, __hasher); }
                        { __binding_2.hash_stable(__hcx, __hasher); }
                        { __binding_3.hash_stable(__hcx, __hasher); }
                        { __binding_4.hash_stable(__hcx, __hasher); }
                    }
                }
            }
        }
    };HashStable, const _: () =
    {
        impl<'tcx, __E: ::rustc_middle::ty::codec::TyEncoder<'tcx>>
            ::rustc_serialize::Encodable<__E> for FieldDef {
            fn encode(&self, __encoder: &mut __E) {
                match *self {
                    FieldDef {
                        did: ref __binding_0,
                        name: ref __binding_1,
                        vis: ref __binding_2,
                        safety: ref __binding_3,
                        value: ref __binding_4 } => {
                        ::rustc_serialize::Encodable::<__E>::encode(__binding_0,
                            __encoder);
                        ::rustc_serialize::Encodable::<__E>::encode(__binding_1,
                            __encoder);
                        ::rustc_serialize::Encodable::<__E>::encode(__binding_2,
                            __encoder);
                        ::rustc_serialize::Encodable::<__E>::encode(__binding_3,
                            __encoder);
                        ::rustc_serialize::Encodable::<__E>::encode(__binding_4,
                            __encoder);
                    }
                }
            }
        }
    };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),
                    safety: ::rustc_serialize::Decodable::decode(__decoder),
                    value: ::rustc_serialize::Decodable::decode(__decoder),
                }
            }
        }
    };TyDecodable)]
1323pub struct FieldDef {
1324    pub did: DefId,
1325    pub name: Symbol,
1326    pub vis: Visibility<DefId>,
1327    pub safety: hir::Safety,
1328    pub value: Option<DefId>,
1329}
1330
1331impl PartialEq for FieldDef {
1332    #[inline]
1333    fn eq(&self, other: &Self) -> bool {
1334        // There should be only one `FieldDef` for each `did`, therefore it is
1335        // fine to implement `PartialEq` only based on `did`.
1336        //
1337        // Below, we exhaustively destructure `self` so that if the definition
1338        // of `FieldDef` changes, a compile-error will be produced, reminding
1339        // us to revisit this assumption.
1340
1341        let Self { did: lhs_did, name: _, vis: _, safety: _, value: _ } = &self;
1342
1343        let Self { did: rhs_did, name: _, vis: _, safety: _, value: _ } = other;
1344
1345        let res = lhs_did == rhs_did;
1346
1347        // Double check that implicit assumption detailed above.
1348        if truecfg!(debug_assertions) && res {
1349            let deep =
1350                self.name == other.name && self.vis == other.vis && self.safety == other.safety;
1351            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");
1352        }
1353
1354        res
1355    }
1356}
1357
1358impl Eq for FieldDef {}
1359
1360impl Hash for FieldDef {
1361    #[inline]
1362    fn hash<H: Hasher>(&self, s: &mut H) {
1363        // There should be only one `FieldDef` for each `did`, therefore it is
1364        // fine to implement `Hash` only based on `did`.
1365        //
1366        // Below, we exhaustively destructure `self` so that if the definition
1367        // of `FieldDef` changes, a compile-error will be produced, reminding
1368        // us to revisit this assumption.
1369
1370        let Self { did, name: _, vis: _, safety: _, value: _ } = &self;
1371
1372        did.hash(s)
1373    }
1374}
1375
1376impl<'tcx> FieldDef {
1377    /// Returns the type of this field. The resulting type is not normalized. The `arg` is
1378    /// typically obtained via the second field of [`TyKind::Adt`].
1379    pub fn ty(&self, tcx: TyCtxt<'tcx>, args: GenericArgsRef<'tcx>) -> Ty<'tcx> {
1380        tcx.type_of(self.did).instantiate(tcx, args)
1381    }
1382
1383    /// Computes the `Ident` of this variant by looking up the `Span`
1384    pub fn ident(&self, tcx: TyCtxt<'_>) -> Ident {
1385        Ident::new(self.name, tcx.def_ident_span(self.did).unwrap())
1386    }
1387}
1388
1389#[derive(#[automatically_derived]
impl ::core::fmt::Debug for ImplOverlapKind {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        match self {
            ImplOverlapKind::Permitted { marker: __self_0 } =>
                ::core::fmt::Formatter::debug_struct_field1_finish(f,
                    "Permitted", "marker", &__self_0),
        }
    }
}Debug, #[automatically_derived]
impl ::core::cmp::PartialEq for ImplOverlapKind {
    #[inline]
    fn eq(&self, other: &ImplOverlapKind) -> bool {
        match (self, other) {
            (ImplOverlapKind::Permitted { marker: __self_0 },
                ImplOverlapKind::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)]
1390pub enum ImplOverlapKind {
1391    /// These impls are always allowed to overlap.
1392    Permitted {
1393        /// Whether or not the impl is permitted due to the trait being a `#[marker]` trait
1394        marker: bool,
1395    },
1396}
1397
1398/// Useful source information about where a desugared associated type for an
1399/// RPITIT originated from.
1400#[derive(#[automatically_derived]
impl ::core::clone::Clone for ImplTraitInTraitData {
    #[inline]
    fn clone(&self) -> ImplTraitInTraitData {
        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]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        match self {
            ImplTraitInTraitData::Trait {
                fn_def_id: __self_0, opaque_def_id: __self_1 } =>
                ::core::fmt::Formatter::debug_struct_field2_finish(f, "Trait",
                    "fn_def_id", __self_0, "opaque_def_id", &__self_1),
            ImplTraitInTraitData::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::cmp::PartialEq for ImplTraitInTraitData {
    #[inline]
    fn eq(&self, other: &ImplTraitInTraitData) -> bool {
        let __self_discr = ::core::intrinsics::discriminant_value(self);
        let __arg1_discr = ::core::intrinsics::discriminant_value(other);
        __self_discr == __arg1_discr &&
            match (self, other) {
                (ImplTraitInTraitData::Trait {
                    fn_def_id: __self_0, opaque_def_id: __self_1 },
                    ImplTraitInTraitData::Trait {
                    fn_def_id: __arg1_0, opaque_def_id: __arg1_1 }) =>
                    __self_0 == __arg1_0 && __self_1 == __arg1_1,
                (ImplTraitInTraitData::Impl { fn_def_id: __self_0 },
                    ImplTraitInTraitData::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) {
        let __self_discr = ::core::intrinsics::discriminant_value(self);
        ::core::hash::Hash::hash(&__self_discr, state);
        match self {
            ImplTraitInTraitData::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)
            }
            ImplTraitInTraitData::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<'__ctx>
            ::rustc_data_structures::stable_hasher::HashStable<::rustc_middle::ich::StableHashingContext<'__ctx>>
            for ImplTraitInTraitData {
            #[inline]
            fn hash_stable(&self,
                __hcx: &mut ::rustc_middle::ich::StableHashingContext<'__ctx>,
                __hasher:
                    &mut ::rustc_data_structures::stable_hasher::StableHasher) {
                ::std::mem::discriminant(self).hash_stable(__hcx, __hasher);
                match *self {
                    ImplTraitInTraitData::Trait {
                        fn_def_id: ref __binding_0, opaque_def_id: ref __binding_1 }
                        => {
                        { __binding_0.hash_stable(__hcx, __hasher); }
                        { __binding_1.hash_stable(__hcx, __hasher); }
                    }
                    ImplTraitInTraitData::Impl { fn_def_id: ref __binding_0 } =>
                        {
                        { __binding_0.hash_stable(__hcx, __hasher); }
                    }
                }
            }
        }
    };HashStable)]
1401pub enum ImplTraitInTraitData {
1402    Trait { fn_def_id: DefId, opaque_def_id: DefId },
1403    Impl { fn_def_id: DefId },
1404}
1405
1406impl<'tcx> TyCtxt<'tcx> {
1407    pub fn typeck_body(self, body: hir::BodyId) -> &'tcx TypeckResults<'tcx> {
1408        self.typeck(self.hir_body_owner_def_id(body))
1409    }
1410
1411    pub fn provided_trait_methods(self, id: DefId) -> impl 'tcx + Iterator<Item = &'tcx AssocItem> {
1412        self.associated_items(id)
1413            .in_definition_order()
1414            .filter(move |item| item.is_fn() && item.defaultness(self).has_value())
1415    }
1416
1417    pub fn repr_options_of_def(self, did: LocalDefId) -> ReprOptions {
1418        let mut flags = ReprFlags::empty();
1419        let mut size = None;
1420        let mut max_align: Option<Align> = None;
1421        let mut min_pack: Option<Align> = None;
1422
1423        // Generate a deterministically-derived seed from the item's path hash
1424        // to allow for cross-crate compilation to actually work
1425        let mut field_shuffle_seed = self.def_path_hash(did.to_def_id()).0.to_smaller_hash();
1426
1427        // If the user defined a custom seed for layout randomization, xor the item's
1428        // path hash with the user defined seed, this will allowing determinism while
1429        // still allowing users to further randomize layout generation for e.g. fuzzing
1430        if let Some(user_seed) = self.sess.opts.unstable_opts.layout_seed {
1431            field_shuffle_seed ^= user_seed;
1432        }
1433
1434        let elt = {
    {
        'done:
            {
            for i in ::rustc_hir::attrs::HasAttrs::get_attrs(did, &self) {
                #[allow(unused_imports)]
                use rustc_hir::attrs::AttributeKind::*;
                let i: &rustc_hir::Attribute = i;
                match i {
                    rustc_hir::Attribute::Parsed(RustcScalableVector {
                        element_count, .. }) => {
                        break 'done Some(element_count);
                    }
                    rustc_hir::Attribute::Unparsed(..) =>
                        {}
                        #[deny(unreachable_patterns)]
                        _ => {}
                }
            }
            None
        }
    }
}find_attr!(self, did, RustcScalableVector { element_count, .. } => element_count
1435        )
1436        .map(|elt| match elt {
1437            Some(n) => ScalableElt::ElementCount(*n),
1438            None => ScalableElt::Container,
1439        });
1440        if elt.is_some() {
1441            flags.insert(ReprFlags::IS_SCALABLE);
1442        }
1443        if let Some(reprs) = {
    {
        'done:
            {
            for i in ::rustc_hir::attrs::HasAttrs::get_attrs(did, &self) {
                #[allow(unused_imports)]
                use rustc_hir::attrs::AttributeKind::*;
                let i: &rustc_hir::Attribute = i;
                match i {
                    rustc_hir::Attribute::Parsed(Repr { reprs, .. }) => {
                        break 'done Some(reprs);
                    }
                    rustc_hir::Attribute::Unparsed(..) =>
                        {}
                        #[deny(unreachable_patterns)]
                        _ => {}
                }
            }
            None
        }
    }
}find_attr!(self, did, Repr { reprs, .. } => reprs) {
1444            for (r, _) in reprs {
1445                flags.insert(match *r {
1446                    attr::ReprRust => ReprFlags::empty(),
1447                    attr::ReprC => ReprFlags::IS_C,
1448                    attr::ReprPacked(pack) => {
1449                        min_pack = Some(if let Some(min_pack) = min_pack {
1450                            min_pack.min(pack)
1451                        } else {
1452                            pack
1453                        });
1454                        ReprFlags::empty()
1455                    }
1456                    attr::ReprTransparent => ReprFlags::IS_TRANSPARENT,
1457                    attr::ReprSimd => ReprFlags::IS_SIMD,
1458                    attr::ReprInt(i) => {
1459                        size = Some(match i {
1460                            attr::IntType::SignedInt(x) => match x {
1461                                ast::IntTy::Isize => IntegerType::Pointer(true),
1462                                ast::IntTy::I8 => IntegerType::Fixed(Integer::I8, true),
1463                                ast::IntTy::I16 => IntegerType::Fixed(Integer::I16, true),
1464                                ast::IntTy::I32 => IntegerType::Fixed(Integer::I32, true),
1465                                ast::IntTy::I64 => IntegerType::Fixed(Integer::I64, true),
1466                                ast::IntTy::I128 => IntegerType::Fixed(Integer::I128, true),
1467                            },
1468                            attr::IntType::UnsignedInt(x) => match x {
1469                                ast::UintTy::Usize => IntegerType::Pointer(false),
1470                                ast::UintTy::U8 => IntegerType::Fixed(Integer::I8, false),
1471                                ast::UintTy::U16 => IntegerType::Fixed(Integer::I16, false),
1472                                ast::UintTy::U32 => IntegerType::Fixed(Integer::I32, false),
1473                                ast::UintTy::U64 => IntegerType::Fixed(Integer::I64, false),
1474                                ast::UintTy::U128 => IntegerType::Fixed(Integer::I128, false),
1475                            },
1476                        });
1477                        ReprFlags::empty()
1478                    }
1479                    attr::ReprAlign(align) => {
1480                        max_align = max_align.max(Some(align));
1481                        ReprFlags::empty()
1482                    }
1483                });
1484            }
1485        }
1486
1487        // If `-Z randomize-layout` was enabled for the type definition then we can
1488        // consider performing layout randomization
1489        if self.sess.opts.unstable_opts.randomize_layout {
1490            flags.insert(ReprFlags::RANDOMIZE_LAYOUT);
1491        }
1492
1493        // box is special, on the one hand the compiler assumes an ordered layout, with the pointer
1494        // always at offset zero. On the other hand we want scalar abi optimizations.
1495        let is_box = self.is_lang_item(did.to_def_id(), LangItem::OwnedBox);
1496
1497        // This is here instead of layout because the choice must make it into metadata.
1498        if is_box {
1499            flags.insert(ReprFlags::IS_LINEAR);
1500        }
1501
1502        // See `TyAndLayout::pass_indirectly_in_non_rustic_abis` for details.
1503        if {
        {
            'done:
                {
                for i in ::rustc_hir::attrs::HasAttrs::get_attrs(did, &self) {
                    #[allow(unused_imports)]
                    use rustc_hir::attrs::AttributeKind::*;
                    let i: &rustc_hir::Attribute = i;
                    match i {
                        rustc_hir::Attribute::Parsed(RustcPassIndirectlyInNonRusticAbis(..))
                            => {
                            break 'done Some(());
                        }
                        rustc_hir::Attribute::Unparsed(..) =>
                            {}
                            #[deny(unreachable_patterns)]
                            _ => {}
                    }
                }
                None
            }
        }
    }.is_some()find_attr!(self, did, RustcPassIndirectlyInNonRusticAbis(..)) {
1504            flags.insert(ReprFlags::PASS_INDIRECTLY_IN_NON_RUSTIC_ABIS);
1505        }
1506
1507        ReprOptions {
1508            int: size,
1509            align: max_align,
1510            pack: min_pack,
1511            flags,
1512            field_shuffle_seed,
1513            scalable: elt,
1514        }
1515    }
1516
1517    /// Look up the name of a definition across crates. This does not look at HIR.
1518    pub fn opt_item_name(self, def_id: impl IntoQueryKey<DefId>) -> Option<Symbol> {
1519        let def_id = def_id.into_query_key();
1520        if let Some(cnum) = def_id.as_crate_root() {
1521            Some(self.crate_name(cnum))
1522        } else {
1523            let def_key = self.def_key(def_id);
1524            match def_key.disambiguated_data.data {
1525                // The name of a constructor is that of its parent.
1526                rustc_hir::definitions::DefPathData::Ctor => self
1527                    .opt_item_name(DefId { krate: def_id.krate, index: def_key.parent.unwrap() }),
1528                _ => def_key.get_opt_name(),
1529            }
1530        }
1531    }
1532
1533    /// Look up the name of a definition across crates. This does not look at HIR.
1534    ///
1535    /// This method will ICE if the corresponding item does not have a name. In these cases, use
1536    /// [`opt_item_name`] instead.
1537    ///
1538    /// [`opt_item_name`]: Self::opt_item_name
1539    pub fn item_name(self, id: impl IntoQueryKey<DefId>) -> Symbol {
1540        let id = id.into_query_key();
1541        self.opt_item_name(id).unwrap_or_else(|| {
1542            crate::util::bug::bug_fmt(format_args!("item_name: no name for {0:?}",
        self.def_path(id)));bug!("item_name: no name for {:?}", self.def_path(id));
1543        })
1544    }
1545
1546    /// Look up the name and span of a definition.
1547    ///
1548    /// See [`item_name`][Self::item_name] for more information.
1549    pub fn opt_item_ident(self, def_id: impl IntoQueryKey<DefId>) -> Option<Ident> {
1550        let def_id = def_id.into_query_key();
1551        let def = self.opt_item_name(def_id)?;
1552        let span = self
1553            .def_ident_span(def_id)
1554            .unwrap_or_else(|| crate::util::bug::bug_fmt(format_args!("missing ident span for {0:?}",
        def_id))bug!("missing ident span for {def_id:?}"));
1555        Some(Ident::new(def, span))
1556    }
1557
1558    /// Look up the name and span of a definition.
1559    ///
1560    /// See [`item_name`][Self::item_name] for more information.
1561    pub fn item_ident(self, def_id: impl IntoQueryKey<DefId>) -> Ident {
1562        let def_id = def_id.into_query_key();
1563        self.opt_item_ident(def_id).unwrap_or_else(|| {
1564            crate::util::bug::bug_fmt(format_args!("item_ident: no name for {0:?}",
        self.def_path(def_id)));bug!("item_ident: no name for {:?}", self.def_path(def_id));
1565        })
1566    }
1567
1568    pub fn opt_associated_item(self, def_id: DefId) -> Option<AssocItem> {
1569        if let DefKind::AssocConst { .. } | DefKind::AssocFn | DefKind::AssocTy =
1570            self.def_kind(def_id)
1571        {
1572            Some(self.associated_item(def_id))
1573        } else {
1574            None
1575        }
1576    }
1577
1578    /// If the `def_id` is an associated type that was desugared from a
1579    /// return-position `impl Trait` from a trait, then provide the source info
1580    /// about where that RPITIT came from.
1581    pub fn opt_rpitit_info(self, def_id: DefId) -> Option<ImplTraitInTraitData> {
1582        if let DefKind::AssocTy = self.def_kind(def_id)
1583            && let AssocKind::Type { data: AssocTypeData::Rpitit(rpitit_info) } =
1584                self.associated_item(def_id).kind
1585        {
1586            Some(rpitit_info)
1587        } else {
1588            None
1589        }
1590    }
1591
1592    pub fn find_field_index(self, ident: Ident, variant: &VariantDef) -> Option<FieldIdx> {
1593        variant.fields.iter_enumerated().find_map(|(i, field)| {
1594            self.hygienic_eq(ident, field.ident(self), variant.def_id).then_some(i)
1595        })
1596    }
1597
1598    /// Returns `Some` if the impls are the same polarity and the trait either
1599    /// has no items or is annotated `#[marker]` and prevents item overrides.
1600    x;#[instrument(level = "debug", skip(self), ret)]
1601    pub fn impls_are_allowed_to_overlap(
1602        self,
1603        def_id1: DefId,
1604        def_id2: DefId,
1605    ) -> Option<ImplOverlapKind> {
1606        let impl1 = self.impl_trait_header(def_id1);
1607        let impl2 = self.impl_trait_header(def_id2);
1608
1609        let trait_ref1 = impl1.trait_ref.skip_binder();
1610        let trait_ref2 = impl2.trait_ref.skip_binder();
1611
1612        // If either trait impl references an error, they're allowed to overlap,
1613        // as one of them essentially doesn't exist.
1614        if trait_ref1.references_error() || trait_ref2.references_error() {
1615            return Some(ImplOverlapKind::Permitted { marker: false });
1616        }
1617
1618        match (impl1.polarity, impl2.polarity) {
1619            (ImplPolarity::Reservation, _) | (_, ImplPolarity::Reservation) => {
1620                // `#[rustc_reservation_impl]` impls don't overlap with anything
1621                return Some(ImplOverlapKind::Permitted { marker: false });
1622            }
1623            (ImplPolarity::Positive, ImplPolarity::Negative)
1624            | (ImplPolarity::Negative, ImplPolarity::Positive) => {
1625                // `impl AutoTrait for Type` + `impl !AutoTrait for Type`
1626                return None;
1627            }
1628            (ImplPolarity::Positive, ImplPolarity::Positive)
1629            | (ImplPolarity::Negative, ImplPolarity::Negative) => {}
1630        };
1631
1632        let is_marker_impl = |trait_ref: TraitRef<'_>| self.trait_def(trait_ref.def_id).is_marker;
1633        let is_marker_overlap = is_marker_impl(trait_ref1) && is_marker_impl(trait_ref2);
1634
1635        if is_marker_overlap {
1636            return Some(ImplOverlapKind::Permitted { marker: true });
1637        }
1638
1639        None
1640    }
1641
1642    /// Returns `ty::VariantDef` if `res` refers to a struct,
1643    /// or variant or their constructors, panics otherwise.
1644    pub fn expect_variant_res(self, res: Res) -> &'tcx VariantDef {
1645        match res {
1646            Res::Def(DefKind::Variant, did) => {
1647                let enum_did = self.parent(did);
1648                self.adt_def(enum_did).variant_with_id(did)
1649            }
1650            Res::Def(DefKind::Struct | DefKind::Union, did) => self.adt_def(did).non_enum_variant(),
1651            Res::Def(DefKind::Ctor(CtorOf::Variant, ..), variant_ctor_did) => {
1652                let variant_did = self.parent(variant_ctor_did);
1653                let enum_did = self.parent(variant_did);
1654                self.adt_def(enum_did).variant_with_ctor_id(variant_ctor_did)
1655            }
1656            Res::Def(DefKind::Ctor(CtorOf::Struct, ..), ctor_did) => {
1657                let struct_did = self.parent(ctor_did);
1658                self.adt_def(struct_did).non_enum_variant()
1659            }
1660            _ => crate::util::bug::bug_fmt(format_args!("expect_variant_res used with unexpected res {0:?}",
        res))bug!("expect_variant_res used with unexpected res {:?}", res),
1661        }
1662    }
1663
1664    /// Returns the possibly-auto-generated MIR of a [`ty::InstanceKind`].
1665    #[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("compiler/rustc_middle/src/ty/mod.rs"),
                                    ::tracing_core::__macro_support::Option::Some(1665u32),
                                    ::tracing_core::__macro_support::Option::Some("rustc_middle::ty"),
                                    ::tracing_core::field::FieldSet::new(&["instance"],
                                        ::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};
                                let mut iter = meta.fields().iter();
                                meta.fields().value_set(&[(&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
                                                    ::tracing::__macro_support::Option::Some(&::tracing::field::debug(&instance)
                                                            as &dyn 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;
        }
        {
            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 compiler/rustc_middle/src/ty/mod.rs:1669",
                                            "rustc_middle::ty", ::tracing::Level::DEBUG,
                                            ::tracing_core::__macro_support::Option::Some("compiler/rustc_middle/src/ty/mod.rs"),
                                            ::tracing_core::__macro_support::Option::Some(1669u32),
                                            ::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};
                                    let mut iter = __CALLSITE.metadata().fields().iter();
                                    __CALLSITE.metadata().fields().value_set(&[(&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
                                                        ::tracing::__macro_support::Option::Some(&format_args!("calling def_kind on def: {0:?}",
                                                                        def) as &dyn 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 compiler/rustc_middle/src/ty/mod.rs:1671",
                                            "rustc_middle::ty", ::tracing::Level::DEBUG,
                                            ::tracing_core::__macro_support::Option::Some("compiler/rustc_middle/src/ty/mod.rs"),
                                            ::tracing_core::__macro_support::Option::Some(1671u32),
                                            ::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};
                                    let mut iter = __CALLSITE.metadata().fields().iter();
                                    __CALLSITE.metadata().fields().value_set(&[(&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
                                                        ::tracing::__macro_support::Option::Some(&format_args!("returned from def_kind: {0:?}",
                                                                        def_kind) as &dyn Value))])
                                });
                        } else { ; }
                    };
                    match def_kind {
                        DefKind::Const { .. } | DefKind::Static { .. } |
                            DefKind::AssocConst { .. } | DefKind::Ctor(..) |
                            DefKind::AnonConst | DefKind::InlineConst =>
                            self.mir_for_ctfe(def),
                        _ => self.optimized_mir(def),
                    }
                }
                ty::InstanceKind::VTableShim(..) |
                    ty::InstanceKind::ReifyShim(..) |
                    ty::InstanceKind::Intrinsic(..) |
                    ty::InstanceKind::FnPtrShim(..) |
                    ty::InstanceKind::Virtual(..) |
                    ty::InstanceKind::ClosureOnceShim { .. } |
                    ty::InstanceKind::ConstructCoroutineInClosureShim { .. } |
                    ty::InstanceKind::FutureDropPollShim(..) |
                    ty::InstanceKind::DropGlue(..) |
                    ty::InstanceKind::CloneShim(..) |
                    ty::InstanceKind::ThreadLocalShim(..) |
                    ty::InstanceKind::FnPtrAddrShim(..) |
                    ty::InstanceKind::AsyncDropGlueCtorShim(..) |
                    ty::InstanceKind::AsyncDropGlue(..) =>
                    self.mir_shims(instance),
            }
        }
    }
}#[instrument(skip(self), level = "debug")]
1666    pub fn instance_mir(self, instance: ty::InstanceKind<'tcx>) -> &'tcx Body<'tcx> {
1667        match instance {
1668            ty::InstanceKind::Item(def) => {
1669                debug!("calling def_kind on def: {:?}", def);
1670                let def_kind = self.def_kind(def);
1671                debug!("returned from def_kind: {:?}", def_kind);
1672                match def_kind {
1673                    DefKind::Const { .. }
1674                    | DefKind::Static { .. }
1675                    | DefKind::AssocConst { .. }
1676                    | DefKind::Ctor(..)
1677                    | DefKind::AnonConst
1678                    | DefKind::InlineConst => self.mir_for_ctfe(def),
1679                    // If the caller wants `mir_for_ctfe` of a function they should not be using
1680                    // `instance_mir`, so we'll assume const fn also wants the optimized version.
1681                    _ => self.optimized_mir(def),
1682                }
1683            }
1684            ty::InstanceKind::VTableShim(..)
1685            | ty::InstanceKind::ReifyShim(..)
1686            | ty::InstanceKind::Intrinsic(..)
1687            | ty::InstanceKind::FnPtrShim(..)
1688            | ty::InstanceKind::Virtual(..)
1689            | ty::InstanceKind::ClosureOnceShim { .. }
1690            | ty::InstanceKind::ConstructCoroutineInClosureShim { .. }
1691            | ty::InstanceKind::FutureDropPollShim(..)
1692            | ty::InstanceKind::DropGlue(..)
1693            | ty::InstanceKind::CloneShim(..)
1694            | ty::InstanceKind::ThreadLocalShim(..)
1695            | ty::InstanceKind::FnPtrAddrShim(..)
1696            | ty::InstanceKind::AsyncDropGlueCtorShim(..)
1697            | ty::InstanceKind::AsyncDropGlue(..) => self.mir_shims(instance),
1698        }
1699    }
1700
1701    /// Gets all attributes with the given name.
1702    #[deprecated = "Though there are valid usecases for this method, especially when your attribute is not a parsed attribute, usually you want to call rustc_hir::find_attr! instead."]
1703    pub fn get_attrs(
1704        self,
1705        did: impl Into<DefId>,
1706        attr: Symbol,
1707    ) -> impl Iterator<Item = &'tcx hir::Attribute> {
1708        #[allow(deprecated)]
1709        self.get_all_attrs(did).iter().filter(move |a: &&hir::Attribute| a.has_name(attr))
1710    }
1711
1712    /// Gets all attributes.
1713    ///
1714    /// To see if an item has a specific attribute, you should use
1715    /// [`rustc_hir::find_attr!`] so you can use matching.
1716    #[deprecated = "Though there are valid usecases for this method, especially when your attribute is not a parsed attribute, usually you want to call rustc_hir::find_attr! instead."]
1717    pub fn get_all_attrs(self, did: impl Into<DefId>) -> &'tcx [hir::Attribute] {
1718        let did: DefId = did.into();
1719        if let Some(did) = did.as_local() {
1720            self.hir_attrs(self.local_def_id_to_hir_id(did))
1721        } else {
1722            self.attrs_for_def(did)
1723        }
1724    }
1725
1726    pub fn get_attrs_by_path(
1727        self,
1728        did: DefId,
1729        attr: &[Symbol],
1730    ) -> impl Iterator<Item = &'tcx hir::Attribute> {
1731        let filter_fn = move |a: &&hir::Attribute| a.path_matches(attr);
1732        if let Some(did) = did.as_local() {
1733            self.hir_attrs(self.local_def_id_to_hir_id(did)).iter().filter(filter_fn)
1734        } else {
1735            self.attrs_for_def(did).iter().filter(filter_fn)
1736        }
1737    }
1738
1739    #[deprecated = "Though there are valid usecases for this method, especially when your attribute is not a parsed attribute, usually you want to call rustc_hir::find_attr! instead."]
1740    pub fn get_attr(self, did: impl Into<DefId>, attr: Symbol) -> Option<&'tcx hir::Attribute> {
1741        if truecfg!(debug_assertions) && !rustc_feature::is_valid_for_get_attr(attr) {
1742            let did: DefId = did.into();
1743            crate::util::bug::bug_fmt(format_args!("get_attr: unexpected called with DefId `{0:?}`, attr `{1:?}`",
        did, attr));bug!("get_attr: unexpected called with DefId `{:?}`, attr `{:?}`", did, attr);
1744        } else {
1745            #[allow(deprecated)]
1746            self.get_attrs(did, attr).next()
1747        }
1748    }
1749
1750    /// Determines whether an item is annotated with an attribute.
1751    #[deprecated = "Though there are valid usecases for this method, especially when your attribute is not a parsed attribute, usually you want to call rustc_hir::find_attr! instead."]
1752    pub fn has_attr(self, did: impl Into<DefId>, attr: Symbol) -> bool {
1753        #[allow(deprecated)]
1754        self.get_attrs(did, attr).next().is_some()
1755    }
1756
1757    /// Determines whether an item is annotated with a multi-segment attribute
1758    pub fn has_attrs_with_path(self, did: impl Into<DefId>, attrs: &[Symbol]) -> bool {
1759        self.get_attrs_by_path(did.into(), attrs).next().is_some()
1760    }
1761
1762    /// Returns `true` if this is an `auto trait`.
1763    pub fn trait_is_auto(self, trait_def_id: DefId) -> bool {
1764        self.trait_def(trait_def_id).has_auto_impl
1765    }
1766
1767    /// Returns `true` if this is coinductive, either because it is
1768    /// an auto trait or because it has the `#[rustc_coinductive]` attribute.
1769    pub fn trait_is_coinductive(self, trait_def_id: DefId) -> bool {
1770        self.trait_def(trait_def_id).is_coinductive
1771    }
1772
1773    /// Returns `true` if this is a trait alias.
1774    pub fn trait_is_alias(self, trait_def_id: DefId) -> bool {
1775        self.def_kind(trait_def_id) == DefKind::TraitAlias
1776    }
1777
1778    /// Arena-alloc of LayoutError for coroutine layout
1779    fn layout_error(self, err: LayoutError<'tcx>) -> &'tcx LayoutError<'tcx> {
1780        self.arena.alloc(err)
1781    }
1782
1783    /// Returns layout of a non-async-drop coroutine. Layout might be unavailable if the
1784    /// coroutine is tainted by errors.
1785    ///
1786    /// Takes `coroutine_kind` which can be acquired from the `CoroutineArgs::kind_ty`,
1787    /// e.g. `args.as_coroutine().kind_ty()`.
1788    fn ordinary_coroutine_layout(
1789        self,
1790        def_id: DefId,
1791        args: GenericArgsRef<'tcx>,
1792    ) -> Result<&'tcx CoroutineLayout<'tcx>, &'tcx LayoutError<'tcx>> {
1793        let coroutine_kind_ty = args.as_coroutine().kind_ty();
1794        let mir = self.optimized_mir(def_id);
1795        let ty = || Ty::new_coroutine(self, def_id, args);
1796        // Regular coroutine
1797        if coroutine_kind_ty.is_unit() {
1798            mir.coroutine_layout_raw().ok_or_else(|| self.layout_error(LayoutError::Unknown(ty())))
1799        } else {
1800            // If we have a `Coroutine` that comes from an coroutine-closure,
1801            // then it may be a by-move or by-ref body.
1802            let ty::Coroutine(_, identity_args) =
1803                *self.type_of(def_id).instantiate_identity().kind()
1804            else {
1805                ::core::panicking::panic("internal error: entered unreachable code");unreachable!();
1806            };
1807            let identity_kind_ty = identity_args.as_coroutine().kind_ty();
1808            // If the types differ, then we must be getting the by-move body of
1809            // a by-ref coroutine.
1810            if identity_kind_ty == coroutine_kind_ty {
1811                mir.coroutine_layout_raw()
1812                    .ok_or_else(|| self.layout_error(LayoutError::Unknown(ty())))
1813            } else {
1814                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));
1815                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!(
1816                    identity_kind_ty.to_opt_closure_kind(),
1817                    Some(ClosureKind::Fn | ClosureKind::FnMut)
1818                );
1819                self.optimized_mir(self.coroutine_by_move_body_def_id(def_id))
1820                    .coroutine_layout_raw()
1821                    .ok_or_else(|| self.layout_error(LayoutError::Unknown(ty())))
1822            }
1823        }
1824    }
1825
1826    /// Returns layout of a `async_drop_in_place::{closure}` coroutine
1827    ///   (returned from `async fn async_drop_in_place<T>(..)`).
1828    /// Layout might be unavailable if the coroutine is tainted by errors.
1829    fn async_drop_coroutine_layout(
1830        self,
1831        def_id: DefId,
1832        args: GenericArgsRef<'tcx>,
1833    ) -> Result<&'tcx CoroutineLayout<'tcx>, &'tcx LayoutError<'tcx>> {
1834        let ty = || Ty::new_coroutine(self, def_id, args);
1835        if args[0].has_placeholders() || args[0].has_non_region_param() {
1836            return Err(self.layout_error(LayoutError::TooGeneric(ty())));
1837        }
1838        let instance = InstanceKind::AsyncDropGlue(def_id, Ty::new_coroutine(self, def_id, args));
1839        self.mir_shims(instance)
1840            .coroutine_layout_raw()
1841            .ok_or_else(|| self.layout_error(LayoutError::Unknown(ty())))
1842    }
1843
1844    /// Returns layout of a coroutine. Layout might be unavailable if the
1845    /// coroutine is tainted by errors.
1846    pub fn coroutine_layout(
1847        self,
1848        def_id: DefId,
1849        args: GenericArgsRef<'tcx>,
1850    ) -> Result<&'tcx CoroutineLayout<'tcx>, &'tcx LayoutError<'tcx>> {
1851        if self.is_async_drop_in_place_coroutine(def_id) {
1852            // layout of `async_drop_in_place<T>::{closure}` in case,
1853            // when T is a coroutine, contains this internal coroutine's ptr in upvars
1854            // and doesn't require any locals. Here is an `empty coroutine's layout`
1855            let arg_cor_ty = args.first().unwrap().expect_ty();
1856            if arg_cor_ty.is_coroutine() {
1857                let span = self.def_span(def_id);
1858                let source_info = SourceInfo::outermost(span);
1859                // Even minimal, empty coroutine has 3 states (RESERVED_VARIANTS),
1860                // so variant_fields and variant_source_info should have 3 elements.
1861                let variant_fields: IndexVec<VariantIdx, IndexVec<FieldIdx, CoroutineSavedLocal>> =
1862                    iter::repeat(IndexVec::new()).take(CoroutineArgs::RESERVED_VARIANTS).collect();
1863                let variant_source_info: IndexVec<VariantIdx, SourceInfo> =
1864                    iter::repeat(source_info).take(CoroutineArgs::RESERVED_VARIANTS).collect();
1865                let proxy_layout = CoroutineLayout {
1866                    field_tys: [].into(),
1867                    field_names: [].into(),
1868                    variant_fields,
1869                    variant_source_info,
1870                    storage_conflicts: BitMatrix::new(0, 0),
1871                };
1872                return Ok(self.arena.alloc(proxy_layout));
1873            } else {
1874                self.async_drop_coroutine_layout(def_id, args)
1875            }
1876        } else {
1877            self.ordinary_coroutine_layout(def_id, args)
1878        }
1879    }
1880
1881    /// If the given `DefId` is an associated item, returns the `DefId` and `DefKind` of the parent trait or impl.
1882    pub fn assoc_parent(self, def_id: DefId) -> Option<(DefId, DefKind)> {
1883        if !self.def_kind(def_id).is_assoc() {
1884            return None;
1885        }
1886        let parent = self.parent(def_id);
1887        let def_kind = self.def_kind(parent);
1888        Some((parent, def_kind))
1889    }
1890
1891    /// Returns the trait item that is implemented by the given item `DefId`.
1892    pub fn trait_item_of(self, def_id: impl IntoQueryKey<DefId>) -> Option<DefId> {
1893        let def_id = def_id.into_query_key();
1894        self.opt_associated_item(def_id)?.trait_item_def_id()
1895    }
1896
1897    /// If the given `DefId` is an associated item of a trait,
1898    /// returns the `DefId` of the trait; otherwise, returns `None`.
1899    pub fn trait_of_assoc(self, def_id: DefId) -> Option<DefId> {
1900        match self.assoc_parent(def_id) {
1901            Some((id, DefKind::Trait)) => Some(id),
1902            _ => None,
1903        }
1904    }
1905
1906    pub fn impl_is_of_trait(self, def_id: impl IntoQueryKey<DefId>) -> bool {
1907        let def_id = def_id.into_query_key();
1908        let DefKind::Impl { of_trait } = self.def_kind(def_id) else {
1909            {
    ::core::panicking::panic_fmt(format_args!("expected Impl for {0:?}",
            def_id));
};panic!("expected Impl for {def_id:?}");
1910        };
1911        of_trait
1912    }
1913
1914    /// If the given `DefId` is an associated item of an impl,
1915    /// returns the `DefId` of the impl; otherwise returns `None`.
1916    pub fn impl_of_assoc(self, def_id: DefId) -> Option<DefId> {
1917        match self.assoc_parent(def_id) {
1918            Some((id, DefKind::Impl { .. })) => Some(id),
1919            _ => None,
1920        }
1921    }
1922
1923    /// If the given `DefId` is an associated item of an inherent impl,
1924    /// returns the `DefId` of the impl; otherwise, returns `None`.
1925    pub fn inherent_impl_of_assoc(self, def_id: DefId) -> Option<DefId> {
1926        match self.assoc_parent(def_id) {
1927            Some((id, DefKind::Impl { of_trait: false })) => Some(id),
1928            _ => None,
1929        }
1930    }
1931
1932    /// If the given `DefId` is an associated item of a trait impl,
1933    /// returns the `DefId` of the impl; otherwise, returns `None`.
1934    pub fn trait_impl_of_assoc(self, def_id: DefId) -> Option<DefId> {
1935        match self.assoc_parent(def_id) {
1936            Some((id, DefKind::Impl { of_trait: true })) => Some(id),
1937            _ => None,
1938        }
1939    }
1940
1941    pub fn impl_polarity(self, def_id: impl IntoQueryKey<DefId>) -> ty::ImplPolarity {
1942        let def_id = def_id.into_query_key();
1943        self.impl_trait_header(def_id).polarity
1944    }
1945
1946    /// Given an `impl_id`, return the trait it implements.
1947    pub fn impl_trait_ref(
1948        self,
1949        def_id: impl IntoQueryKey<DefId>,
1950    ) -> ty::EarlyBinder<'tcx, ty::TraitRef<'tcx>> {
1951        let def_id = def_id.into_query_key();
1952        self.impl_trait_header(def_id).trait_ref
1953    }
1954
1955    /// Given an `impl_id`, return the trait it implements.
1956    /// Returns `None` if it is an inherent impl.
1957    pub fn impl_opt_trait_ref(
1958        self,
1959        def_id: impl IntoQueryKey<DefId>,
1960    ) -> Option<ty::EarlyBinder<'tcx, ty::TraitRef<'tcx>>> {
1961        let def_id = def_id.into_query_key();
1962        self.impl_is_of_trait(def_id).then(|| self.impl_trait_ref(def_id))
1963    }
1964
1965    /// Given the `DefId` of an impl, returns the `DefId` of the trait it implements.
1966    pub fn impl_trait_id(self, def_id: impl IntoQueryKey<DefId>) -> DefId {
1967        let def_id = def_id.into_query_key();
1968        self.impl_trait_ref(def_id).skip_binder().def_id
1969    }
1970
1971    /// Given the `DefId` of an impl, returns the `DefId` of the trait it implements.
1972    /// Returns `None` if it is an inherent impl.
1973    pub fn impl_opt_trait_id(self, def_id: impl IntoQueryKey<DefId>) -> Option<DefId> {
1974        let def_id = def_id.into_query_key();
1975        self.impl_is_of_trait(def_id).then(|| self.impl_trait_id(def_id))
1976    }
1977
1978    pub fn is_exportable(self, def_id: DefId) -> bool {
1979        self.exportable_items(def_id.krate).contains(&def_id)
1980    }
1981
1982    /// Check if the given `DefId` is `#\[automatically_derived\]`, *and*
1983    /// whether it was produced by expanding a builtin derive macro.
1984    pub fn is_builtin_derived(self, def_id: DefId) -> bool {
1985        if self.is_automatically_derived(def_id)
1986            && let Some(def_id) = def_id.as_local()
1987            && let outer = self.def_span(def_id).ctxt().outer_expn_data()
1988            && #[allow(non_exhaustive_omitted_patterns)] match outer.kind {
    ExpnKind::Macro(MacroKind::Derive, _) => true,
    _ => false,
}matches!(outer.kind, ExpnKind::Macro(MacroKind::Derive, _))
1989            && {
        {
            'done:
                {
                for i in
                    ::rustc_hir::attrs::HasAttrs::get_attrs(outer.macro_def_id.unwrap(),
                        &self) {
                    #[allow(unused_imports)]
                    use rustc_hir::attrs::AttributeKind::*;
                    let i: &rustc_hir::Attribute = i;
                    match i {
                        rustc_hir::Attribute::Parsed(RustcBuiltinMacro { .. }) => {
                            break 'done Some(());
                        }
                        rustc_hir::Attribute::Unparsed(..) =>
                            {}
                            #[deny(unreachable_patterns)]
                            _ => {}
                    }
                }
                None
            }
        }
    }.is_some()find_attr!(self, outer.macro_def_id.unwrap(), RustcBuiltinMacro { .. })
1990        {
1991            true
1992        } else {
1993            false
1994        }
1995    }
1996
1997    /// Check if the given `DefId` is `#\[automatically_derived\]`.
1998    pub fn is_automatically_derived(self, def_id: DefId) -> bool {
1999        {
        {
            'done:
                {
                for i in
                    ::rustc_hir::attrs::HasAttrs::get_attrs(def_id, &self) {
                    #[allow(unused_imports)]
                    use rustc_hir::attrs::AttributeKind::*;
                    let i: &rustc_hir::Attribute = i;
                    match i {
                        rustc_hir::Attribute::Parsed(AutomaticallyDerived(..)) => {
                            break 'done Some(());
                        }
                        rustc_hir::Attribute::Unparsed(..) =>
                            {}
                            #[deny(unreachable_patterns)]
                            _ => {}
                    }
                }
                None
            }
        }
    }.is_some()find_attr!(self, def_id, AutomaticallyDerived(..))
2000    }
2001
2002    /// Looks up the span of `impl_did` if the impl is local; otherwise returns `Err`
2003    /// with the name of the crate containing the impl.
2004    pub fn span_of_impl(self, impl_def_id: DefId) -> Result<Span, Symbol> {
2005        if let Some(impl_def_id) = impl_def_id.as_local() {
2006            Ok(self.def_span(impl_def_id))
2007        } else {
2008            Err(self.crate_name(impl_def_id.krate))
2009        }
2010    }
2011
2012    /// Hygienically compares a use-site name (`use_name`) for a field or an associated item with
2013    /// its supposed definition name (`def_name`). The method also needs `DefId` of the supposed
2014    /// definition's parent/scope to perform comparison.
2015    pub fn hygienic_eq(self, use_ident: Ident, def_ident: Ident, def_parent_def_id: DefId) -> bool {
2016        // We could use `Ident::eq` here, but we deliberately don't. The identifier
2017        // comparison fails frequently, and we want to avoid the expensive
2018        // `normalize_to_macros_2_0()` calls required for the span comparison whenever possible.
2019        use_ident.name == def_ident.name
2020            && use_ident
2021                .span
2022                .ctxt()
2023                .hygienic_eq(def_ident.span.ctxt(), self.expn_that_defined(def_parent_def_id))
2024    }
2025
2026    pub fn adjust_ident(self, mut ident: Ident, scope: DefId) -> Ident {
2027        ident.span.normalize_to_macros_2_0_and_adjust(self.expn_that_defined(scope));
2028        ident
2029    }
2030
2031    // FIXME(vincenzopalazzo): move the HirId to a LocalDefId
2032    pub fn adjust_ident_and_get_scope(
2033        self,
2034        mut ident: Ident,
2035        scope: DefId,
2036        block: hir::HirId,
2037    ) -> (Ident, DefId) {
2038        let scope = ident
2039            .span
2040            .normalize_to_macros_2_0_and_adjust(self.expn_that_defined(scope))
2041            .and_then(|actual_expansion| actual_expansion.expn_data().parent_module)
2042            .unwrap_or_else(|| self.parent_module(block).to_def_id());
2043        (ident, scope)
2044    }
2045
2046    /// Checks whether this is a `const fn`. Returns `false` for non-functions.
2047    ///
2048    /// Even if this returns `true`, constness may still be unstable!
2049    #[inline]
2050    pub fn is_const_fn(self, def_id: DefId) -> bool {
2051        #[allow(non_exhaustive_omitted_patterns)] match self.def_kind(def_id) {
    DefKind::Fn | DefKind::AssocFn | DefKind::Ctor(_, CtorKind::Fn) |
        DefKind::Closure => true,
    _ => false,
}matches!(
2052            self.def_kind(def_id),
2053            DefKind::Fn | DefKind::AssocFn | DefKind::Ctor(_, CtorKind::Fn) | DefKind::Closure
2054        ) && self.constness(def_id) == hir::Constness::Const
2055    }
2056
2057    /// Whether this item is conditionally constant for the purposes of the
2058    /// effects implementation.
2059    ///
2060    /// This roughly corresponds to all const functions and other callable
2061    /// items, along with const impls and traits, and associated types within
2062    /// those impls and traits.
2063    pub fn is_conditionally_const(self, def_id: impl Into<DefId>) -> bool {
2064        let def_id: DefId = def_id.into();
2065        match self.def_kind(def_id) {
2066            DefKind::Impl { of_trait: true } => {
2067                let header = self.impl_trait_header(def_id);
2068                header.constness == hir::Constness::Const
2069                    && self.is_const_trait(header.trait_ref.skip_binder().def_id)
2070            }
2071            DefKind::Impl { of_trait: false } => self.constness(def_id) == hir::Constness::Const,
2072            DefKind::Fn | DefKind::Ctor(_, CtorKind::Fn) => {
2073                self.constness(def_id) == hir::Constness::Const
2074            }
2075            DefKind::TraitAlias | DefKind::Trait => self.is_const_trait(def_id),
2076            DefKind::AssocTy => {
2077                let parent_def_id = self.parent(def_id);
2078                match self.def_kind(parent_def_id) {
2079                    DefKind::Impl { of_trait: false } => false,
2080                    DefKind::Impl { of_trait: true } | DefKind::Trait => {
2081                        self.is_conditionally_const(parent_def_id)
2082                    }
2083                    _ => crate::util::bug::bug_fmt(format_args!("unexpected parent item of associated type: {0:?}",
        parent_def_id))bug!("unexpected parent item of associated type: {parent_def_id:?}"),
2084                }
2085            }
2086            DefKind::AssocFn => {
2087                let parent_def_id = self.parent(def_id);
2088                match self.def_kind(parent_def_id) {
2089                    DefKind::Impl { of_trait: false } => {
2090                        self.constness(def_id) == hir::Constness::Const
2091                    }
2092                    DefKind::Impl { of_trait: true } => {
2093                        let Some(trait_method_did) = self.trait_item_of(def_id) else {
2094                            return false;
2095                        };
2096                        self.constness(trait_method_did) == hir::Constness::Const
2097                            && self.is_conditionally_const(parent_def_id)
2098                    }
2099                    DefKind::Trait => {
2100                        self.constness(def_id) == hir::Constness::Const
2101                            && self.is_conditionally_const(parent_def_id)
2102                    }
2103                    _ => crate::util::bug::bug_fmt(format_args!("unexpected parent item of associated fn: {0:?}",
        parent_def_id))bug!("unexpected parent item of associated fn: {parent_def_id:?}"),
2104                }
2105            }
2106            DefKind::OpaqueTy => match self.opaque_ty_origin(def_id) {
2107                hir::OpaqueTyOrigin::FnReturn { parent, .. } => self.is_conditionally_const(parent),
2108                hir::OpaqueTyOrigin::AsyncFn { .. } => false,
2109                // FIXME(const_trait_impl): ATPITs could be conditionally const?
2110                hir::OpaqueTyOrigin::TyAlias { .. } => false,
2111            },
2112            DefKind::Closure => self.constness(def_id) == hir::Constness::Const,
2113            DefKind::Ctor(_, CtorKind::Const)
2114            | DefKind::Mod
2115            | DefKind::Struct
2116            | DefKind::Union
2117            | DefKind::Enum
2118            | DefKind::Variant
2119            | DefKind::TyAlias
2120            | DefKind::ForeignTy
2121            | DefKind::TyParam
2122            | DefKind::Const { .. }
2123            | DefKind::ConstParam
2124            | DefKind::Static { .. }
2125            | DefKind::AssocConst { .. }
2126            | DefKind::Macro(_)
2127            | DefKind::ExternCrate
2128            | DefKind::Use
2129            | DefKind::ForeignMod
2130            | DefKind::AnonConst
2131            | DefKind::InlineConst
2132            | DefKind::Field
2133            | DefKind::LifetimeParam
2134            | DefKind::GlobalAsm
2135            | DefKind::SyntheticCoroutineBody => false,
2136        }
2137    }
2138
2139    #[inline]
2140    pub fn is_const_trait(self, def_id: DefId) -> bool {
2141        self.trait_def(def_id).constness == hir::Constness::Const
2142    }
2143
2144    pub fn impl_method_has_trait_impl_trait_tys(self, def_id: DefId) -> bool {
2145        if self.def_kind(def_id) != DefKind::AssocFn {
2146            return false;
2147        }
2148
2149        let Some(item) = self.opt_associated_item(def_id) else {
2150            return false;
2151        };
2152
2153        let AssocContainer::TraitImpl(Ok(trait_item_def_id)) = item.container else {
2154            return false;
2155        };
2156
2157        !self.associated_types_for_impl_traits_in_associated_fn(trait_item_def_id).is_empty()
2158    }
2159
2160    /// Compute a `FnAbi` suitable for declaring/defining an `fn` instance, and for direct calls*
2161    /// to an `fn`. Indirectly-passed parameters in the returned ABI will include applicable
2162    /// codegen optimization attributes, including `ReadOnly` and `CapturesNone` -- deduction of
2163    /// which requires inspection of function bodies that can lead to cycles when performed during
2164    /// typeck. During typeck, you should therefore use instead the unoptimized ABI returned by
2165    /// `fn_abi_of_instance_no_deduced_attrs`.
2166    ///
2167    /// For performance reasons, you should prefer to call this inherent method rather than invoke
2168    /// the `fn_abi_of_instance_raw` query: it delegates to that query if necessary, but where
2169    /// possible delegates instead to the `fn_abi_of_instance_no_deduced_attrs` query (thus avoiding
2170    /// unnecessary query system overhead).
2171    ///
2172    /// * that includes virtual calls, which are represented by "direct calls" to an
2173    ///   `InstanceKind::Virtual` instance (of `<dyn Trait as Trait>::fn`).
2174    #[inline]
2175    pub fn fn_abi_of_instance(
2176        self,
2177        query: ty::PseudoCanonicalInput<'tcx, (ty::Instance<'tcx>, &'tcx ty::List<Ty<'tcx>>)>,
2178    ) -> Result<&'tcx FnAbi<'tcx, Ty<'tcx>>, &'tcx FnAbiError<'tcx>> {
2179        // Only deduce attrs in full, optimized builds. Otherwise, avoid the query system overhead
2180        // of ever invoking the `fn_abi_of_instance_raw` query.
2181        if self.sess.opts.optimize != OptLevel::No && self.sess.opts.incremental.is_none() {
2182            self.fn_abi_of_instance_raw(query)
2183        } else {
2184            self.fn_abi_of_instance_no_deduced_attrs(query)
2185        }
2186    }
2187}
2188
2189// `HasAttrs` impls: allow `find_attr!(tcx, id, ...)` to work with both DefId-like types and HirId.
2190
2191impl<'tcx> hir::attrs::HasAttrs<'tcx, TyCtxt<'tcx>> for DefId {
2192    fn get_attrs(self, tcx: &TyCtxt<'tcx>) -> &'tcx [hir::Attribute] {
2193        if let Some(did) = self.as_local() {
2194            tcx.hir_attrs(tcx.local_def_id_to_hir_id(did))
2195        } else {
2196            tcx.attrs_for_def(self)
2197        }
2198    }
2199}
2200
2201impl<'tcx> hir::attrs::HasAttrs<'tcx, TyCtxt<'tcx>> for LocalDefId {
2202    fn get_attrs(self, tcx: &TyCtxt<'tcx>) -> &'tcx [hir::Attribute] {
2203        tcx.hir_attrs(tcx.local_def_id_to_hir_id(self))
2204    }
2205}
2206
2207impl<'tcx> hir::attrs::HasAttrs<'tcx, TyCtxt<'tcx>> for hir::OwnerId {
2208    fn get_attrs(self, tcx: &TyCtxt<'tcx>) -> &'tcx [hir::Attribute] {
2209        hir::attrs::HasAttrs::get_attrs(self.def_id, tcx)
2210    }
2211}
2212
2213impl<'tcx> hir::attrs::HasAttrs<'tcx, TyCtxt<'tcx>> for hir::HirId {
2214    fn get_attrs(self, tcx: &TyCtxt<'tcx>) -> &'tcx [hir::Attribute] {
2215        tcx.hir_attrs(self)
2216    }
2217}
2218
2219pub fn provide(providers: &mut Providers) {
2220    closure::provide(providers);
2221    context::provide(providers);
2222    erase_regions::provide(providers);
2223    inhabitedness::provide(providers);
2224    util::provide(providers);
2225    print::provide(providers);
2226    super::util::bug::provide(providers);
2227    *providers = Providers {
2228        trait_impls_of: trait_def::trait_impls_of_provider,
2229        incoherent_impls: trait_def::incoherent_impls_provider,
2230        trait_impls_in_crate: trait_def::trait_impls_in_crate_provider,
2231        traits: trait_def::traits_provider,
2232        vtable_allocation: vtable::vtable_allocation_provider,
2233        ..*providers
2234    };
2235}
2236
2237/// A map for the local crate mapping each type to a vector of its
2238/// inherent impls. This is not meant to be used outside of coherence;
2239/// rather, you should request the vector for a specific type via
2240/// `tcx.inherent_impls(def_id)` so as to minimize your dependencies
2241/// (constructing this map requires touching the entire crate).
2242#[derive(#[automatically_derived]
impl ::core::clone::Clone for CrateInherentImpls {
    #[inline]
    fn clone(&self) -> CrateInherentImpls {
        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]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::debug_struct_field2_finish(f,
            "CrateInherentImpls", "inherent_impls", &self.inherent_impls,
            "incoherent_impls", &&self.incoherent_impls)
    }
}Debug, #[automatically_derived]
impl ::core::default::Default for CrateInherentImpls {
    #[inline]
    fn default() -> CrateInherentImpls {
        CrateInherentImpls {
            inherent_impls: ::core::default::Default::default(),
            incoherent_impls: ::core::default::Default::default(),
        }
    }
}Default, const _: () =
    {
        impl<'__ctx>
            ::rustc_data_structures::stable_hasher::HashStable<::rustc_middle::ich::StableHashingContext<'__ctx>>
            for CrateInherentImpls {
            #[inline]
            fn hash_stable(&self,
                __hcx: &mut ::rustc_middle::ich::StableHashingContext<'__ctx>,
                __hasher:
                    &mut ::rustc_data_structures::stable_hasher::StableHasher) {
                match *self {
                    CrateInherentImpls {
                        inherent_impls: ref __binding_0,
                        incoherent_impls: ref __binding_1 } => {
                        { __binding_0.hash_stable(__hcx, __hasher); }
                        { __binding_1.hash_stable(__hcx, __hasher); }
                    }
                }
            }
        }
    };HashStable)]
2243pub struct CrateInherentImpls {
2244    pub inherent_impls: FxIndexMap<LocalDefId, Vec<DefId>>,
2245    pub incoherent_impls: FxIndexMap<SimplifiedType, Vec<LocalDefId>>,
2246}
2247
2248#[derive(#[automatically_derived]
impl<'tcx> ::core::clone::Clone for SymbolName<'tcx> {
    #[inline]
    fn clone(&self) -> SymbolName<'tcx> {
        let _: ::core::clone::AssertParamIsClone<&'tcx str>;
        *self
    }
}Clone, #[automatically_derived]
impl<'tcx> ::core::marker::Copy for SymbolName<'tcx> { }Copy, #[automatically_derived]
impl<'tcx> ::core::cmp::PartialEq for SymbolName<'tcx> {
    #[inline]
    fn eq(&self, other: &SymbolName<'tcx>) -> 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: &SymbolName<'tcx>)
        -> ::core::option::Option<::core::cmp::Ordering> {
        ::core::cmp::PartialOrd::partial_cmp(&self.name, &other.name)
    }
}PartialOrd, #[automatically_derived]
impl<'tcx> ::core::cmp::Ord for SymbolName<'tcx> {
    #[inline]
    fn cmp(&self, other: &SymbolName<'tcx>) -> ::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) {
                match *self {
                    SymbolName { name: __binding_0 } => {
                        ::rustc_serialize::Encodable::<__E>::encode(__binding_0,
                            __encoder);
                    }
                }
            }
        }
    };TyEncodable, const _: () =
    {
        impl<'tcx, '__ctx>
            ::rustc_data_structures::stable_hasher::HashStable<::rustc_middle::ich::StableHashingContext<'__ctx>>
            for SymbolName<'tcx> {
            #[inline]
            fn hash_stable(&self,
                __hcx: &mut ::rustc_middle::ich::StableHashingContext<'__ctx>,
                __hasher:
                    &mut ::rustc_data_structures::stable_hasher::StableHasher) {
                match *self {
                    SymbolName { name: ref __binding_0 } => {
                        { __binding_0.hash_stable(__hcx, __hasher); }
                    }
                }
            }
        }
    };HashStable)]
2249pub struct SymbolName<'tcx> {
2250    /// `&str` gives a consistent ordering, which ensures reproducible builds.
2251    pub name: &'tcx str,
2252}
2253
2254impl<'tcx> SymbolName<'tcx> {
2255    pub fn new(tcx: TyCtxt<'tcx>, name: &str) -> SymbolName<'tcx> {
2256        SymbolName { name: tcx.arena.alloc_str(name) }
2257    }
2258}
2259
2260impl<'tcx> fmt::Display for SymbolName<'tcx> {
2261    fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
2262        fmt::Display::fmt(&self.name, fmt)
2263    }
2264}
2265
2266impl<'tcx> fmt::Debug for SymbolName<'tcx> {
2267    fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
2268        fmt::Display::fmt(&self.name, fmt)
2269    }
2270}
2271
2272/// The constituent parts of a type level constant of kind ADT or array.
2273#[derive(#[automatically_derived]
impl<'tcx> ::core::marker::Copy for DestructuredAdtConst<'tcx> { }Copy, #[automatically_derived]
impl<'tcx> ::core::clone::Clone for DestructuredAdtConst<'tcx> {
    #[inline]
    fn clone(&self) -> DestructuredAdtConst<'tcx> {
        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]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::debug_struct_field2_finish(f,
            "DestructuredAdtConst", "variant", &self.variant, "fields",
            &&self.fields)
    }
}Debug, const _: () =
    {
        impl<'tcx, '__ctx>
            ::rustc_data_structures::stable_hasher::HashStable<::rustc_middle::ich::StableHashingContext<'__ctx>>
            for DestructuredAdtConst<'tcx> {
            #[inline]
            fn hash_stable(&self,
                __hcx: &mut ::rustc_middle::ich::StableHashingContext<'__ctx>,
                __hasher:
                    &mut ::rustc_data_structures::stable_hasher::StableHasher) {
                match *self {
                    DestructuredAdtConst {
                        variant: ref __binding_0, fields: ref __binding_1 } => {
                        { __binding_0.hash_stable(__hcx, __hasher); }
                        { __binding_1.hash_stable(__hcx, __hasher); }
                    }
                }
            }
        }
    };HashStable)]
2274pub struct DestructuredAdtConst<'tcx> {
2275    pub variant: VariantIdx,
2276    pub fields: &'tcx [ty::Const<'tcx>],
2277}
2278
2279/// Generate TypeTree information for autodiff.
2280/// This function creates TypeTree metadata that describes the memory layout
2281/// of function parameters and return types for Enzyme autodiff.
2282pub fn fnc_typetrees<'tcx>(tcx: TyCtxt<'tcx>, fn_ty: Ty<'tcx>) -> FncTree {
2283    // Check if TypeTrees are disabled via NoTT flag
2284    if tcx.sess.opts.unstable_opts.autodiff.contains(&rustc_session::config::AutoDiff::NoTT) {
2285        return FncTree { args: ::alloc::vec::Vec::new()vec![], ret: TypeTree::new() };
2286    }
2287
2288    // Check if this is actually a function type
2289    if !fn_ty.is_fn() {
2290        return FncTree { args: ::alloc::vec::Vec::new()vec![], ret: TypeTree::new() };
2291    }
2292
2293    // Get the function signature
2294    let fn_sig = fn_ty.fn_sig(tcx);
2295    let sig = tcx.instantiate_bound_regions_with_erased(fn_sig);
2296
2297    // Create TypeTrees for each input parameter
2298    let mut args = ::alloc::vec::Vec::new()vec![];
2299    for ty in sig.inputs().iter() {
2300        let type_tree = typetree_from_ty(tcx, *ty);
2301        args.push(type_tree);
2302    }
2303
2304    // Create TypeTree for return type
2305    let ret = typetree_from_ty(tcx, sig.output());
2306
2307    FncTree { args, ret }
2308}
2309
2310/// Generate TypeTree for a specific type.
2311/// This function analyzes a Rust type and creates appropriate TypeTree metadata.
2312pub fn typetree_from_ty<'tcx>(tcx: TyCtxt<'tcx>, ty: Ty<'tcx>) -> TypeTree {
2313    let mut visited = Vec::new();
2314    typetree_from_ty_inner(tcx, ty, 0, &mut visited)
2315}
2316
2317/// Maximum recursion depth for TypeTree generation to prevent stack overflow
2318/// from pathological deeply nested types. Combined with cycle detection.
2319const MAX_TYPETREE_DEPTH: usize = 6;
2320
2321/// Internal recursive function for TypeTree generation with cycle detection and depth limiting.
2322fn typetree_from_ty_inner<'tcx>(
2323    tcx: TyCtxt<'tcx>,
2324    ty: Ty<'tcx>,
2325    depth: usize,
2326    visited: &mut Vec<Ty<'tcx>>,
2327) -> TypeTree {
2328    if depth >= MAX_TYPETREE_DEPTH {
2329        {
    use ::tracing::__macro_support::Callsite as _;
    static __CALLSITE: ::tracing::callsite::DefaultCallsite =
        {
            static META: ::tracing::Metadata<'static> =
                {
                    ::tracing_core::metadata::Metadata::new("event compiler/rustc_middle/src/ty/mod.rs:2329",
                        "rustc_middle::ty", ::tracing::Level::TRACE,
                        ::tracing_core::__macro_support::Option::Some("compiler/rustc_middle/src/ty/mod.rs"),
                        ::tracing_core::__macro_support::Option::Some(2329u32),
                        ::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::TRACE <= ::tracing::level_filters::STATIC_MAX_LEVEL
                &&
                ::tracing::Level::TRACE <=
                    ::tracing::level_filters::LevelFilter::current() &&
            {
                let interest = __CALLSITE.interest();
                !interest.is_never() &&
                    ::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
                        interest)
            };
    if enabled {
        (|value_set: ::tracing::field::ValueSet|
                    {
                        let meta = __CALLSITE.metadata();
                        ::tracing::Event::dispatch(meta, &value_set);
                        ;
                    })({
                #[allow(unused_imports)]
                use ::tracing::field::{debug, display, Value};
                let mut iter = __CALLSITE.metadata().fields().iter();
                __CALLSITE.metadata().fields().value_set(&[(&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
                                    ::tracing::__macro_support::Option::Some(&format_args!("typetree depth limit {0} reached for type: {1}",
                                                    MAX_TYPETREE_DEPTH, ty) as &dyn Value))])
            });
    } else { ; }
};trace!("typetree depth limit {} reached for type: {}", MAX_TYPETREE_DEPTH, ty);
2330        return TypeTree::new();
2331    }
2332
2333    if visited.contains(&ty) {
2334        return TypeTree::new();
2335    }
2336
2337    visited.push(ty);
2338    let result = typetree_from_ty_impl(tcx, ty, depth, visited);
2339    visited.pop();
2340    result
2341}
2342
2343/// Implementation of TypeTree generation logic.
2344fn typetree_from_ty_impl<'tcx>(
2345    tcx: TyCtxt<'tcx>,
2346    ty: Ty<'tcx>,
2347    depth: usize,
2348    visited: &mut Vec<Ty<'tcx>>,
2349) -> TypeTree {
2350    typetree_from_ty_impl_inner(tcx, ty, depth, visited, false)
2351}
2352
2353/// Internal implementation with context about whether this is for a reference target.
2354fn typetree_from_ty_impl_inner<'tcx>(
2355    tcx: TyCtxt<'tcx>,
2356    ty: Ty<'tcx>,
2357    depth: usize,
2358    visited: &mut Vec<Ty<'tcx>>,
2359    is_reference_target: bool,
2360) -> TypeTree {
2361    if ty.is_scalar() {
2362        let (kind, size) = if ty.is_integral() || ty.is_char() || ty.is_bool() {
2363            (Kind::Integer, ty.primitive_size(tcx).bytes_usize())
2364        } else if ty.is_floating_point() {
2365            match ty {
2366                x if x == tcx.types.f16 => (Kind::Half, 2),
2367                x if x == tcx.types.f32 => (Kind::Float, 4),
2368                x if x == tcx.types.f64 => (Kind::Double, 8),
2369                x if x == tcx.types.f128 => (Kind::F128, 16),
2370                _ => (Kind::Integer, 0),
2371            }
2372        } else {
2373            (Kind::Integer, 0)
2374        };
2375
2376        // Use offset 0 for scalars that are direct targets of references (like &f64)
2377        // Use offset -1 for scalars used directly (like function return types)
2378        let offset = if is_reference_target && !ty.is_array() { 0 } else { -1 };
2379        return TypeTree(::alloc::boxed::box_assume_init_into_vec_unsafe(::alloc::intrinsics::write_box_via_move(::alloc::boxed::Box::new_uninit(),
        [Type { offset, size, kind, child: TypeTree::new() }]))vec![Type { offset, size, kind, child: TypeTree::new() }]);
2380    }
2381
2382    if ty.is_ref() || ty.is_raw_ptr() || ty.is_box() {
2383        let Some(inner_ty) = ty.builtin_deref(true) else {
2384            return TypeTree::new();
2385        };
2386
2387        let child = typetree_from_ty_impl_inner(tcx, inner_ty, depth + 1, visited, true);
2388        return TypeTree(::alloc::boxed::box_assume_init_into_vec_unsafe(::alloc::intrinsics::write_box_via_move(::alloc::boxed::Box::new_uninit(),
        [Type {
                    offset: -1,
                    size: tcx.data_layout.pointer_size().bytes_usize(),
                    kind: Kind::Pointer,
                    child,
                }]))vec![Type {
2389            offset: -1,
2390            size: tcx.data_layout.pointer_size().bytes_usize(),
2391            kind: Kind::Pointer,
2392            child,
2393        }]);
2394    }
2395
2396    if ty.is_array() {
2397        if let ty::Array(element_ty, len_const) = ty.kind() {
2398            let len = len_const.try_to_target_usize(tcx).unwrap_or(0);
2399            if len == 0 {
2400                return TypeTree::new();
2401            }
2402            let element_tree =
2403                typetree_from_ty_impl_inner(tcx, *element_ty, depth + 1, visited, false);
2404            let mut types = Vec::new();
2405            for elem_type in &element_tree.0 {
2406                types.push(Type {
2407                    offset: -1,
2408                    size: elem_type.size,
2409                    kind: elem_type.kind,
2410                    child: elem_type.child.clone(),
2411                });
2412            }
2413
2414            return TypeTree(types);
2415        }
2416    }
2417
2418    if ty.is_slice() {
2419        if let ty::Slice(element_ty) = ty.kind() {
2420            let element_tree =
2421                typetree_from_ty_impl_inner(tcx, *element_ty, depth + 1, visited, false);
2422            return element_tree;
2423        }
2424    }
2425
2426    if let ty::Tuple(tuple_types) = ty.kind() {
2427        if tuple_types.is_empty() {
2428            return TypeTree::new();
2429        }
2430
2431        let mut types = Vec::new();
2432        let mut current_offset = 0;
2433
2434        for tuple_ty in tuple_types.iter() {
2435            let element_tree =
2436                typetree_from_ty_impl_inner(tcx, tuple_ty, depth + 1, visited, false);
2437
2438            let element_layout = tcx
2439                .layout_of(ty::TypingEnv::fully_monomorphized().as_query_input(tuple_ty))
2440                .ok()
2441                .map(|layout| layout.size.bytes_usize())
2442                .unwrap_or(0);
2443
2444            for elem_type in &element_tree.0 {
2445                types.push(Type {
2446                    offset: if elem_type.offset == -1 {
2447                        current_offset as isize
2448                    } else {
2449                        current_offset as isize + elem_type.offset
2450                    },
2451                    size: elem_type.size,
2452                    kind: elem_type.kind,
2453                    child: elem_type.child.clone(),
2454                });
2455            }
2456
2457            current_offset += element_layout;
2458        }
2459
2460        return TypeTree(types);
2461    }
2462
2463    if let ty::Adt(adt_def, args) = ty.kind() {
2464        if adt_def.is_struct() {
2465            let struct_layout =
2466                tcx.layout_of(ty::TypingEnv::fully_monomorphized().as_query_input(ty));
2467            if let Ok(layout) = struct_layout {
2468                let mut types = Vec::new();
2469
2470                for (field_idx, field_def) in adt_def.all_fields().enumerate() {
2471                    let field_ty = field_def.ty(tcx, args);
2472                    let field_tree =
2473                        typetree_from_ty_impl_inner(tcx, field_ty, depth + 1, visited, false);
2474
2475                    let field_offset = layout.fields.offset(field_idx).bytes_usize();
2476
2477                    for elem_type in &field_tree.0 {
2478                        types.push(Type {
2479                            offset: if elem_type.offset == -1 {
2480                                field_offset as isize
2481                            } else {
2482                                field_offset as isize + elem_type.offset
2483                            },
2484                            size: elem_type.size,
2485                            kind: elem_type.kind,
2486                            child: elem_type.child.clone(),
2487                        });
2488                    }
2489                }
2490
2491                return TypeTree(types);
2492            }
2493        }
2494    }
2495
2496    TypeTree::new()
2497}