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::assert_matches::assert_matches;
15use std::fmt::Debug;
16use std::hash::{Hash, Hasher};
17use std::marker::PhantomData;
18use std::num::NonZero;
19use std::ptr::NonNull;
20use std::{fmt, iter, str};
21
22pub use adt::*;
23pub use assoc::*;
24pub use generic_args::{GenericArgKind, TermKind, *};
25pub use generics::*;
26pub use intrinsic::IntrinsicDef;
27use rustc_abi::{
28    Align, FieldIdx, Integer, IntegerType, ReprFlags, ReprOptions, ScalableElt, VariantIdx,
29};
30use rustc_ast::AttrVec;
31use rustc_ast::expand::typetree::{FncTree, Kind, Type, TypeTree};
32use rustc_ast::node_id::NodeMap;
33pub use rustc_ast_ir::{Movability, Mutability, try_visit};
34use rustc_data_structures::fx::{FxHashSet, FxIndexMap, FxIndexSet};
35use rustc_data_structures::intern::Interned;
36use rustc_data_structures::stable_hasher::{HashStable, StableHasher};
37use rustc_data_structures::steal::Steal;
38use rustc_data_structures::unord::{UnordMap, UnordSet};
39use rustc_errors::{Diag, ErrorGuaranteed, LintBuffer};
40use rustc_hir::attrs::{AttributeKind, 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_query_system::ich::StableHashingContext;
51use rustc_serialize::{Decodable, Encodable};
52pub use rustc_session::lint::RegisteredTools;
53use rustc_span::hygiene::MacroKind;
54use rustc_span::{DUMMY_SP, ExpnId, ExpnKind, Ident, Span, Symbol};
55pub use rustc_type_ir::data_structures::{DelayedMap, DelayedSet};
56pub use rustc_type_ir::fast_reject::DeepRejectCtxt;
57#[allow(
58    hidden_glob_reexports,
59    rustc::usage_of_type_ir_inherent,
60    rustc::non_glob_import_of_type_ir_inherent
61)]
62use rustc_type_ir::inherent;
63pub use rustc_type_ir::relate::VarianceDiagInfo;
64pub use rustc_type_ir::solve::{CandidatePreferenceMode, SizedTraitKind};
65pub use rustc_type_ir::*;
66#[allow(hidden_glob_reexports, unused_imports)]
67use rustc_type_ir::{InferCtxtLike, Interner};
68use tracing::{debug, instrument, trace};
69pub use vtable::*;
70use {rustc_ast as ast, rustc_hir as hir};
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    AnonConstKind, AtomicOrdering, Const, ConstInt, ConstKind, ConstToValTreeResult, Expr,
80    ExprKind, ScalarInt, SimdAlign, UnevaluatedConst, ValTree, ValTreeKindExt, Value,
81};
82pub use self::context::{
83    CtxtInterners, CurrentGcx, Feed, FreeRegionInfo, GlobalCtxt, Lift, TyCtxt, TyCtxtFeed, tls,
84};
85pub use self::fold::*;
86pub use self::instance::{Instance, InstanceKind, ReifyReason, UnusedGenericParams};
87pub use self::list::{List, ListWithCachedTypeInfo};
88pub use self::opaque_types::OpaqueTypeKey;
89pub use self::pattern::{Pattern, PatternKind};
90pub use self::predicate::{
91    AliasTerm, ArgOutlivesPredicate, Clause, ClauseKind, CoercePredicate, ExistentialPredicate,
92    ExistentialPredicateStableCmpExt, ExistentialProjection, ExistentialTraitRef,
93    HostEffectPredicate, NormalizesTo, OutlivesPredicate, PolyCoercePredicate,
94    PolyExistentialPredicate, PolyExistentialProjection, PolyExistentialTraitRef,
95    PolyProjectionPredicate, PolyRegionOutlivesPredicate, PolySubtypePredicate, PolyTraitPredicate,
96    PolyTraitRef, PolyTypeOutlivesPredicate, Predicate, PredicateKind, ProjectionPredicate,
97    RegionOutlivesPredicate, SubtypePredicate, TraitPredicate, TraitRef, TypeOutlivesPredicate,
98};
99pub use self::region::{
100    BoundRegion, BoundRegionKind, EarlyParamRegion, LateParamRegion, LateParamRegionKind, Region,
101    RegionKind, RegionVid,
102};
103pub use self::sty::{
104    AliasTy, Article, Binder, BoundTy, BoundTyKind, BoundVariableKind, CanonicalPolyFnSig,
105    CoroutineArgsExt, EarlyBinder, FnSig, InlineConstArgs, InlineConstArgsParts, ParamConst,
106    ParamTy, PolyFnSig, TyKind, TypeAndMut, TypingMode, UpvarArgs,
107};
108pub use self::trait_def::TraitDef;
109pub use self::typeck_results::{
110    CanonicalUserType, CanonicalUserTypeAnnotation, CanonicalUserTypeAnnotations, IsIdentity,
111    Rust2024IncompatiblePatInfo, TypeckResults, UserType, UserTypeAnnotationIndex, UserTypeKind,
112};
113use crate::error::{OpaqueHiddenTypeMismatch, TypeMismatchReason};
114use crate::metadata::{AmbigModChild, ModChild};
115use crate::middle::privacy::EffectiveVisibilities;
116use crate::mir::{Body, CoroutineLayout, CoroutineSavedLocal, SourceInfo};
117use crate::query::{IntoQueryParam, Providers};
118use crate::ty;
119use crate::ty::codec::{TyDecoder, TyEncoder};
120pub use crate::ty::diagnostics::*;
121use crate::ty::fast_reject::SimplifiedType;
122use crate::ty::layout::LayoutError;
123use crate::ty::util::Discr;
124use crate::ty::walk::TypeWalker;
125
126pub mod abstract_const;
127pub mod adjustment;
128pub mod cast;
129pub mod codec;
130pub mod error;
131pub mod fast_reject;
132pub mod inhabitedness;
133pub mod layout;
134pub mod normalize_erasing_regions;
135pub mod offload_meta;
136pub mod pattern;
137pub mod print;
138pub mod relate;
139pub mod significant_drop_order;
140pub mod trait_def;
141pub mod util;
142pub mod vtable;
143
144mod adt;
145mod assoc;
146mod closure;
147mod consts;
148mod context;
149mod diagnostics;
150mod elaborate_impl;
151mod erase_regions;
152mod fold;
153mod generic_args;
154mod generics;
155mod impls_ty;
156mod instance;
157mod intrinsic;
158mod list;
159mod opaque_types;
160mod predicate;
161mod region;
162mod structural_impls;
163#[allow(hidden_glob_reexports)]
164mod sty;
165mod typeck_results;
166mod visit;
167
168// Data types
169
170#[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_query_system::ich::StableHashingContext<'__ctx>>
            for ResolverGlobalCtxt {
            #[inline]
            fn hash_stable(&self,
                __hcx:
                    &mut ::rustc_query_system::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)]
171pub struct ResolverGlobalCtxt {
172    pub visibilities_for_hashing: Vec<(LocalDefId, Visibility)>,
173    /// Item with a given `LocalDefId` was defined during macro expansion with ID `ExpnId`.
174    pub expn_that_defined: UnordMap<LocalDefId, ExpnId>,
175    pub effective_visibilities: EffectiveVisibilities,
176    pub extern_crate_map: UnordMap<LocalDefId, CrateNum>,
177    pub maybe_unused_trait_imports: FxIndexSet<LocalDefId>,
178    pub module_children: LocalDefIdMap<Vec<ModChild>>,
179    pub ambig_module_children: LocalDefIdMap<Vec<AmbigModChild>>,
180    pub glob_map: FxIndexMap<LocalDefId, FxIndexSet<Symbol>>,
181    pub main_def: Option<MainDefinition>,
182    pub trait_impls: FxIndexMap<DefId, Vec<LocalDefId>>,
183    /// A list of proc macro LocalDefIds, written out in the order in which
184    /// they are declared in the static array generated by proc_macro_harness.
185    pub proc_macros: Vec<LocalDefId>,
186    /// Mapping from ident span to path span for paths that don't exist as written, but that
187    /// exist under `std`. For example, wrote `str::from_utf8` instead of `std::str::from_utf8`.
188    pub confused_type_with_std_module: FxIndexMap<Span, Span>,
189    pub doc_link_resolutions: FxIndexMap<LocalDefId, DocLinkResMap>,
190    pub doc_link_traits_in_scope: FxIndexMap<LocalDefId, Vec<DefId>>,
191    pub all_macro_rules: UnordSet<Symbol>,
192    pub stripped_cfg_items: Vec<StrippedCfgItem>,
193}
194
195/// Resolutions that should only be used for lowering.
196/// This struct is meant to be consumed by lowering.
197#[derive(#[automatically_derived]
impl ::core::fmt::Debug for ResolverAstLowering {
    #[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_fn_sigs", "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_fn_sigs, &&self.delegation_infos];
        ::core::fmt::Formatter::debug_struct_fields_finish(f,
            "ResolverAstLowering", names, values)
    }
}Debug)]
198pub struct ResolverAstLowering {
199    /// Resolutions for nodes that have a single resolution.
200    pub partial_res_map: NodeMap<hir::def::PartialRes>,
201    /// Resolutions for import nodes, which have multiple resolutions in different namespaces.
202    pub import_res_map: NodeMap<hir::def::PerNS<Option<Res<ast::NodeId>>>>,
203    /// Resolutions for labels (node IDs of their corresponding blocks or loops).
204    pub label_res_map: NodeMap<ast::NodeId>,
205    /// Resolutions for lifetimes.
206    pub lifetimes_res_map: NodeMap<LifetimeRes>,
207    /// Lifetime parameters that lowering will have to introduce.
208    pub extra_lifetime_params_map: NodeMap<Vec<(Ident, ast::NodeId, LifetimeRes)>>,
209
210    pub next_node_id: ast::NodeId,
211
212    pub node_id_to_def_id: NodeMap<LocalDefId>,
213
214    pub trait_map: NodeMap<Vec<hir::TraitCandidate>>,
215    /// List functions and methods for which lifetime elision was successful.
216    pub lifetime_elision_allowed: FxHashSet<ast::NodeId>,
217
218    /// Lints that were emitted by the resolver and early lints.
219    pub lint_buffer: Steal<LintBuffer>,
220
221    /// Information about functions signatures for delegation items expansion
222    pub delegation_fn_sigs: LocalDefIdMap<DelegationFnSig>,
223    // Information about delegations which is used when handling recursive delegations
224    pub delegation_infos: LocalDefIdMap<DelegationInfo>,
225}
226
227bitflags::bitflags! {
228    #[derive(#[automatically_derived]
impl ::core::clone::Clone for DelegationFnSigAttrs {
    #[inline]
    fn clone(&self) -> DelegationFnSigAttrs {
        let _:
                ::core::clone::AssertParamIsClone<<DelegationFnSigAttrs as
                ::bitflags::__private::PublicFlags>::Internal>;
        *self
    }
}
impl DelegationFnSigAttrs {
    #[allow(deprecated, non_upper_case_globals,)]
    pub const TARGET_FEATURE: Self = Self::from_bits_retain(1 << 0);
    #[allow(deprecated, non_upper_case_globals,)]
    pub const MUST_USE: Self = Self::from_bits_retain(1 << 1);
}
impl ::bitflags::Flags for DelegationFnSigAttrs {
    const FLAGS: &'static [::bitflags::Flag<DelegationFnSigAttrs>] =
        &[{

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

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