Skip to main content

rustc_hir_analysis/hir_ty_lowering/
mod.rs

1// ignore-tidy-file-filelength
2
3//! HIR ty lowering: Lowers type-system entities[^1] from the [HIR][hir] to
4//! the [`rustc_middle::ty`] representation.
5//!
6//! Not to be confused with *AST lowering* which lowers AST constructs to HIR ones
7//! or with *THIR* / *MIR* *lowering* / *building* which lowers HIR *bodies*
8//! (i.e., “executable code”) to THIR / MIR.
9//!
10//! Most lowering routines are defined on [`dyn HirTyLowerer`](HirTyLowerer) directly,
11//! like the main routine of this module, `lower_ty`.
12//!
13//! This module used to be called `astconv`.
14//!
15//! [^1]: This includes types, lifetimes / regions, constants in type positions,
16//! trait references and bounds.
17
18mod bounds;
19mod cmse;
20mod dyn_trait;
21pub mod errors;
22pub mod generics;
23
24use std::{assert_matches, slice};
25
26use rustc_abi::FIRST_VARIANT;
27use rustc_ast::LitKind;
28use rustc_data_structures::fx::{FxHashSet, FxIndexMap, FxIndexSet};
29use rustc_data_structures::sso::SsoHashSet;
30use rustc_data_structures::thin_vec::ThinVec;
31use rustc_errors::codes::*;
32use rustc_errors::{
33    Applicability, Diag, DiagCtxtHandle, ErrorGuaranteed, FatalError, StashKey,
34    struct_span_code_err,
35};
36use rustc_hir::attrs::lang_items::LangItem;
37use rustc_hir::def::{CtorKind, CtorOf, DefKind, Res};
38use rustc_hir::def_id::{DefId, LocalDefId};
39use rustc_hir::{self as hir, AnonConst, GenericArg, GenericArgs, HirId};
40use rustc_infer::infer::{InferCtxt, TyCtxtInferExt};
41use rustc_infer::traits::DynCompatibilityViolation;
42use rustc_lint_defs::builtin::AMBIGUOUS_ASSOCIATED_ITEMS;
43use rustc_macros::{TypeFoldable, TypeVisitable};
44use rustc_middle::middle::stability::AllowUnstable;
45use rustc_middle::ty::{
46    self, Const, FnSigKind, GenericArgKind, GenericArgsRef, GenericParamDefKind, LitToConstInput,
47    Ty, TyCtxt, TypeSuperFoldable, TypeVisitableExt, TypingMode, Unnormalized, Upcast,
48    const_lit_matches_ty, fold_regions,
49};
50use rustc_middle::{bug, span_bug};
51use rustc_session::diagnostics::feature_err;
52use rustc_span::def_id::ModId;
53use rustc_span::{DUMMY_SP, Ident, Span, kw, sym};
54use rustc_trait_selection::infer::InferCtxtExt;
55use rustc_trait_selection::traits::{self, FulfillmentError};
56use tracing::{debug, instrument};
57
58use crate::check::check_abi;
59use crate::check_c_variadic_abi;
60use crate::diagnostics::{self, BadReturnTypeNotation, NoFieldOnType, NoVariantNamed};
61use crate::hir_ty_lowering::errors::{
62    GenericsArgsErrExtend, eq_ctxt_suggestion_span, prohibit_assoc_item_constraint,
63};
64use crate::hir_ty_lowering::generics::{check_generic_arg_count, lower_generic_args};
65use crate::middle::resolve_bound_vars as rbv;
66
67/// The context in which an implied bound is being added to a item being lowered (i.e. a sizedness
68/// trait or a default trait)
69#[derive(#[automatically_derived]
#[doc(hidden)]
unsafe impl<'tcx> ::core::clone::TrivialClone for ImpliedBoundsContext<'tcx> {
}
#[automatically_derived]
impl<'tcx> ::core::clone::Clone for ImpliedBoundsContext<'tcx> {
    #[inline]
    fn clone(&self) -> ImpliedBoundsContext<'tcx> {
        let _: ::core::clone::AssertParamIsClone<LocalDefId>;
        let _:
                ::core::clone::AssertParamIsClone<&'tcx [hir::WherePredicate<'tcx>]>;
        *self
    }
}Clone, #[automatically_derived]
impl<'tcx> ::core::marker::Copy for ImpliedBoundsContext<'tcx> { }Copy)]
70pub(crate) enum ImpliedBoundsContext<'tcx> {
71    /// An implied bound is added to a trait definition (i.e. a new supertrait), used when adding
72    /// a default `MetaSized` supertrait
73    TraitDef(LocalDefId),
74    /// An implied bound is added to a type parameter
75    TyParam(LocalDefId, &'tcx [hir::WherePredicate<'tcx>]),
76    /// An implied bound being added in any other context
77    AssociatedTypeOrImplTrait,
78}
79
80/// A path segment that is semantically allowed to have generic arguments.
81#[derive(#[automatically_derived]
impl ::core::fmt::Debug for GenericPathSegment {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::debug_tuple_field2_finish(f,
            "GenericPathSegment", &self.0, &&self.1)
    }
}Debug)]
82pub struct GenericPathSegment(pub DefId, pub usize);
83
84#[derive(#[automatically_derived]
impl ::core::marker::Copy for PredicateFilter { }Copy, #[automatically_derived]
#[doc(hidden)]
unsafe impl ::core::clone::TrivialClone for PredicateFilter { }
#[automatically_derived]
impl ::core::clone::Clone for PredicateFilter {
    #[inline]
    fn clone(&self) -> PredicateFilter {
        let _: ::core::clone::AssertParamIsClone<Ident>;
        *self
    }
}Clone, #[automatically_derived]
impl ::core::fmt::Debug for PredicateFilter {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        match self {
            PredicateFilter::All =>
                ::core::fmt::Formatter::write_str(f, "All"),
            PredicateFilter::SelfOnly =>
                ::core::fmt::Formatter::write_str(f, "SelfOnly"),
            PredicateFilter::SelfTraitThatDefines(__self_0) =>
                ::core::fmt::Formatter::debug_tuple_field1_finish(f,
                    "SelfTraitThatDefines", &__self_0),
            PredicateFilter::SelfAndAssociatedTypeBounds =>
                ::core::fmt::Formatter::write_str(f,
                    "SelfAndAssociatedTypeBounds"),
            PredicateFilter::ConstIfConst =>
                ::core::fmt::Formatter::write_str(f, "ConstIfConst"),
            PredicateFilter::SelfConstIfConst =>
                ::core::fmt::Formatter::write_str(f, "SelfConstIfConst"),
        }
    }
}Debug)]
85pub enum PredicateFilter {
86    /// All predicates may be implied by the trait.
87    All,
88
89    /// Only traits that reference `Self: ..` are implied by the trait.
90    SelfOnly,
91
92    /// Only traits that reference `Self: ..` and define an associated type
93    /// with the given ident are implied by the trait. This mode exists to
94    /// side-step query cycles when lowering associated types.
95    SelfTraitThatDefines(Ident),
96
97    /// Only traits that reference `Self: ..` and their associated type bounds.
98    /// For example, given `Self: Tr<A: B>`, this would expand to `Self: Tr`
99    /// and `<Self as Tr>::A: B`.
100    SelfAndAssociatedTypeBounds,
101
102    /// Filter only the `[const]` bounds, which are lowered into `HostEffect` clauses.
103    ConstIfConst,
104
105    /// Filter only the `[const]` bounds which are *also* in the supertrait position.
106    SelfConstIfConst,
107}
108
109#[derive(#[automatically_derived]
impl<'a> ::core::fmt::Debug for RegionInferReason<'a> {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        match self {
            RegionInferReason::ExplicitObjectLifetime =>
                ::core::fmt::Formatter::write_str(f,
                    "ExplicitObjectLifetime"),
            RegionInferReason::ObjectLifetimeDefault(__self_0) =>
                ::core::fmt::Formatter::debug_tuple_field1_finish(f,
                    "ObjectLifetimeDefault", &__self_0),
            RegionInferReason::Param(__self_0) =>
                ::core::fmt::Formatter::debug_tuple_field1_finish(f, "Param",
                    &__self_0),
            RegionInferReason::RegionPredicate =>
                ::core::fmt::Formatter::write_str(f, "RegionPredicate"),
            RegionInferReason::Reference =>
                ::core::fmt::Formatter::write_str(f, "Reference"),
            RegionInferReason::OutlivesBound =>
                ::core::fmt::Formatter::write_str(f, "OutlivesBound"),
        }
    }
}Debug)]
110pub enum RegionInferReason<'a> {
111    /// Lifetime on a trait object that is spelled explicitly, e.g. `+ 'a` or `+ '_`.
112    ExplicitObjectLifetime,
113    /// A trait object's lifetime when it is elided, e.g. `dyn Any`.
114    ObjectLifetimeDefault(Span),
115    /// Generic lifetime parameter
116    Param(&'a ty::GenericParamDef),
117    RegionPredicate,
118    Reference,
119    OutlivesBound,
120}
121
122#[derive(#[automatically_derived]
impl ::core::marker::Copy for InherentAssocCandidate { }Copy, #[automatically_derived]
#[doc(hidden)]
unsafe impl ::core::clone::TrivialClone for InherentAssocCandidate { }
#[automatically_derived]
impl ::core::clone::Clone for InherentAssocCandidate {
    #[inline]
    fn clone(&self) -> InherentAssocCandidate {
        let _: ::core::clone::AssertParamIsClone<DefId>;
        let _: ::core::clone::AssertParamIsClone<ModId>;
        *self
    }
}Clone, const _: () =
    {
        impl<'tcx>
            ::rustc_middle::ty::TypeFoldable<::rustc_middle::ty::TyCtxt<'tcx>>
            for InherentAssocCandidate {
            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 {
                        InherentAssocCandidate {
                            impl_: __binding_0,
                            assoc_item: __binding_1,
                            scope: __binding_2 } => {
                            InherentAssocCandidate {
                                impl_: ::rustc_middle::ty::TypeFoldable::try_fold_with(__binding_0,
                                        __folder)?,
                                assoc_item: ::rustc_middle::ty::TypeFoldable::try_fold_with(__binding_1,
                                        __folder)?,
                                scope: ::rustc_middle::ty::TypeFoldable::try_fold_with(__binding_2,
                                        __folder)?,
                            }
                        }
                    })
            }
            fn fold_with<__F: ::rustc_middle::ty::TypeFolder<::rustc_middle::ty::TyCtxt<'tcx>>>(self,
                __folder: &mut __F) -> Self {
                match self {
                    InherentAssocCandidate {
                        impl_: __binding_0,
                        assoc_item: __binding_1,
                        scope: __binding_2 } => {
                        InherentAssocCandidate {
                            impl_: ::rustc_middle::ty::TypeFoldable::fold_with(__binding_0,
                                __folder),
                            assoc_item: ::rustc_middle::ty::TypeFoldable::fold_with(__binding_1,
                                __folder),
                            scope: ::rustc_middle::ty::TypeFoldable::fold_with(__binding_2,
                                __folder),
                        }
                    }
                }
            }
        }
    };TypeFoldable, const _: () =
    {
        impl<'tcx>
            ::rustc_middle::ty::TypeVisitable<::rustc_middle::ty::TyCtxt<'tcx>>
            for InherentAssocCandidate {
            fn visit_with<__V: ::rustc_middle::ty::TypeVisitor<::rustc_middle::ty::TyCtxt<'tcx>>>(&self,
                __visitor: &mut __V) -> __V::Result {
                match *self {
                    InherentAssocCandidate {
                        impl_: ref __binding_0,
                        assoc_item: ref __binding_1,
                        scope: ref __binding_2 } => {
                        {
                            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);
                                }
                            }
                        }
                        {
                            match ::rustc_middle::ty::VisitorResult::branch(::rustc_middle::ty::TypeVisitable::visit_with(__binding_2,
                                        __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, #[automatically_derived]
impl ::core::fmt::Debug for InherentAssocCandidate {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::debug_struct_field3_finish(f,
            "InherentAssocCandidate", "impl_", &self.impl_, "assoc_item",
            &self.assoc_item, "scope", &&self.scope)
    }
}Debug)]
123pub struct InherentAssocCandidate {
124    pub impl_: DefId,
125    pub assoc_item: DefId,
126    pub scope: ModId,
127}
128
129pub struct ResolvedStructPath<'tcx> {
130    pub res: Result<Res, ErrorGuaranteed>,
131    pub ty: Ty<'tcx>,
132}
133
134/// A context which can lower type-system entities from the [HIR][hir] to
135/// the [`rustc_middle::ty`] representation.
136///
137/// This trait used to be called `AstConv`.
138pub trait HirTyLowerer<'tcx> {
139    fn tcx(&self) -> TyCtxt<'tcx>;
140
141    fn dcx(&self) -> DiagCtxtHandle<'_>;
142
143    /// Returns the [`LocalDefId`] of the overarching item whose constituents get lowered.
144    fn item_def_id(&self) -> LocalDefId;
145
146    /// Returns the region to use when a lifetime is omitted (and not elided).
147    fn re_infer(&self, span: Span, reason: RegionInferReason<'_>) -> ty::Region<'tcx>;
148
149    /// Returns the type to use when a type is omitted.
150    fn ty_infer(&self, param: Option<&ty::GenericParamDef>, span: Span) -> Ty<'tcx>;
151
152    /// Returns the const to use when a const is omitted.
153    fn ct_infer(&self, param: Option<&ty::GenericParamDef>, span: Span) -> Const<'tcx>;
154
155    fn register_trait_ascription_bounds(
156        &self,
157        bounds: Vec<(ty::Clause<'tcx>, Span)>,
158        hir_id: HirId,
159        span: Span,
160    );
161
162    /// Probe bounds in scope where the bounded type coincides with the given type parameter.
163    ///
164    /// Rephrased, this returns bounds of the form `T: Trait`, where `T` is a type parameter
165    /// with the given `def_id`. This is a subset of the full set of bounds.
166    ///
167    /// This method may use the given `assoc_name` to disregard bounds whose trait reference
168    /// doesn't define an associated item with the provided name.
169    ///
170    /// This is used for one specific purpose: Resolving “short-hand” associated type references
171    /// like `T::Item` where `T` is a type parameter. In principle, we would do that by first
172    /// getting the full set of predicates in scope and then filtering down to find those that
173    /// apply to `T`, but this can lead to cycle errors. The problem is that we have to do this
174    /// resolution *in order to create the predicates in the first place*.
175    /// Hence, we have this “special pass”.
176    fn probe_ty_param_bounds(
177        &self,
178        span: Span,
179        def_id: LocalDefId,
180        assoc_ident: Ident,
181    ) -> ty::EarlyBinder<'tcx, &'tcx [(ty::Clause<'tcx>, Span)]>;
182
183    fn select_inherent_assoc_candidates(
184        &self,
185        span: Span,
186        self_ty: Ty<'tcx>,
187        candidates: Vec<InherentAssocCandidate>,
188    ) -> (Vec<InherentAssocCandidate>, ThinVec<FulfillmentError<'tcx>>);
189
190    /// Lower a path to an associated item (of a trait) to a projection.
191    ///
192    /// This method has to be defined by the concrete lowering context because
193    /// dealing with higher-ranked trait references depends on its capabilities:
194    ///
195    /// If the context can make use of type inference, it can simply instantiate
196    /// any late-bound vars bound by the trait reference with inference variables.
197    /// If it doesn't support type inference, there is nothing reasonable it can
198    /// do except reject the associated type.
199    ///
200    /// The canonical example of this is associated type `T::P` where `T` is a type
201    /// param constrained by `T: for<'a> Trait<'a>` and where `Trait` defines `P`.
202    fn lower_assoc_item_path(
203        &self,
204        span: Span,
205        item_def_id: DefId,
206        item_segment: &hir::PathSegment<'_>,
207        poly_trait_ref: ty::PolyTraitRef<'tcx>,
208    ) -> Result<(DefId, GenericArgsRef<'tcx>), ErrorGuaranteed>;
209
210    fn lower_fn_sig(
211        &self,
212        decl: &hir::FnDecl<'_>,
213        generics: Option<&hir::Generics<'_>>,
214        hir_id: HirId,
215        hir_ty: Option<&hir::Ty<'_>>,
216    ) -> (Vec<Ty<'tcx>>, Ty<'tcx>);
217
218    /// Returns `AdtDef` if `ty` is an ADT.
219    ///
220    /// Note that `ty` might be a alias type that needs normalization.
221    /// This used to get the enum variants in scope of the type.
222    /// For example, `Self::A` could refer to an associated type
223    /// or to an enum variant depending on the result of this function.
224    fn probe_adt(&self, span: Span, ty: Ty<'tcx>) -> Option<ty::AdtDef<'tcx>>;
225
226    /// Record the lowered type of a HIR node in this context.
227    fn record_ty(&self, hir_id: HirId, ty: Ty<'tcx>, span: Span);
228
229    /// The inference context of the lowering context if applicable.
230    fn infcx(&self) -> Option<&InferCtxt<'tcx>>;
231
232    /// Convenience method for coercing the lowering context into a trait object type.
233    ///
234    /// Most lowering routines are defined on the trait object type directly
235    /// necessitating a coercion step from the concrete lowering context.
236    fn lowerer(&self) -> &dyn HirTyLowerer<'tcx>
237    where
238        Self: Sized,
239    {
240        self
241    }
242
243    /// Performs minimalistic dyn compat checks outside of bodies, but full within bodies.
244    /// Outside of bodies we could end up in cycles, so we delay most checks to later phases.
245    fn dyn_compatibility_violations(&self, trait_def_id: DefId) -> Vec<DynCompatibilityViolation>;
246}
247
248/// The "qualified self" of an associated item path.
249///
250/// For diagnostic purposes only.
251enum AssocItemQSelf {
252    Trait(DefId),
253    TyParam(LocalDefId, Span),
254    SelfTyAlias,
255}
256
257impl AssocItemQSelf {
258    fn to_string(&self, tcx: TyCtxt<'_>) -> String {
259        match *self {
260            Self::Trait(def_id) => tcx.def_path_str(def_id),
261            Self::TyParam(def_id, _) => tcx.hir_ty_param_name(def_id).to_string(),
262            Self::SelfTyAlias => kw::SelfUpper.to_string(),
263        }
264    }
265}
266
267#[derive(#[automatically_derived]
impl ::core::fmt::Debug for LowerTypeRelativePathMode {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        match self {
            LowerTypeRelativePathMode::Type(__self_0) =>
                ::core::fmt::Formatter::debug_tuple_field1_finish(f, "Type",
                    &__self_0),
            LowerTypeRelativePathMode::Const =>
                ::core::fmt::Formatter::write_str(f, "Const"),
        }
    }
}Debug, #[automatically_derived]
#[doc(hidden)]
unsafe impl ::core::clone::TrivialClone for LowerTypeRelativePathMode { }
#[automatically_derived]
impl ::core::clone::Clone for LowerTypeRelativePathMode {
    #[inline]
    fn clone(&self) -> LowerTypeRelativePathMode {
        let _: ::core::clone::AssertParamIsClone<PermitVariants>;
        *self
    }
}Clone, #[automatically_derived]
impl ::core::marker::Copy for LowerTypeRelativePathMode { }Copy)]
268enum LowerTypeRelativePathMode {
269    Type(PermitVariants),
270    Const,
271}
272
273impl LowerTypeRelativePathMode {
274    fn assoc_tag(self) -> ty::AssocTag {
275        match self {
276            Self::Type(_) => ty::AssocTag::Type,
277            Self::Const => ty::AssocTag::Const,
278        }
279    }
280
281    ///NOTE: use `assoc_tag` for any important logic
282    fn def_kind_for_diagnostics(self) -> DefKind {
283        match self {
284            Self::Type(_) => DefKind::AssocTy,
285            Self::Const => DefKind::AssocConst { is_type_const: false },
286        }
287    }
288
289    fn permit_variants(self) -> PermitVariants {
290        match self {
291            Self::Type(permit_variants) => permit_variants,
292            // FIXME(mgca): Support paths like `Option::<T>::None` or `Option::<T>::Some` which
293            // resolve to const ctors/fn items respectively.
294            Self::Const => PermitVariants::No,
295        }
296    }
297}
298
299/// Whether to permit a path to resolve to an enum variant.
300#[derive(#[automatically_derived]
impl ::core::fmt::Debug for PermitVariants {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::write_str(f,
            match self {
                PermitVariants::Yes => "Yes",
                PermitVariants::No => "No",
            })
    }
}Debug, #[automatically_derived]
#[doc(hidden)]
unsafe impl ::core::clone::TrivialClone for PermitVariants { }
#[automatically_derived]
impl ::core::clone::Clone for PermitVariants {
    #[inline]
    fn clone(&self) -> PermitVariants { *self }
}Clone, #[automatically_derived]
impl ::core::marker::Copy for PermitVariants { }Copy)]
301pub enum PermitVariants {
302    Yes,
303    No,
304}
305
306#[derive(#[automatically_derived]
impl<'tcx> ::core::fmt::Debug for TypeRelativePath<'tcx> {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        match self {
            TypeRelativePath::AssocItem(__self_0) =>
                ::core::fmt::Formatter::debug_tuple_field1_finish(f,
                    "AssocItem", &__self_0),
            TypeRelativePath::Variant { adt: __self_0, variant_did: __self_1 }
                =>
                ::core::fmt::Formatter::debug_struct_field2_finish(f,
                    "Variant", "adt", __self_0, "variant_did", &__self_1),
            TypeRelativePath::Ctor { ctor_def_id: __self_0, args: __self_1 }
                =>
                ::core::fmt::Formatter::debug_struct_field2_finish(f, "Ctor",
                    "ctor_def_id", __self_0, "args", &__self_1),
        }
    }
}Debug, #[automatically_derived]
#[doc(hidden)]
unsafe impl<'tcx> ::core::clone::TrivialClone for TypeRelativePath<'tcx> { }
#[automatically_derived]
impl<'tcx> ::core::clone::Clone for TypeRelativePath<'tcx> {
    #[inline]
    fn clone(&self) -> TypeRelativePath<'tcx> {
        let _: ::core::clone::AssertParamIsClone<ty::AliasTerm<'tcx>>;
        let _: ::core::clone::AssertParamIsClone<Ty<'tcx>>;
        let _: ::core::clone::AssertParamIsClone<DefId>;
        let _: ::core::clone::AssertParamIsClone<GenericArgsRef<'tcx>>;
        *self
    }
}Clone, #[automatically_derived]
impl<'tcx> ::core::marker::Copy for TypeRelativePath<'tcx> { }Copy)]
307enum TypeRelativePath<'tcx> {
308    AssocItem(ty::AliasTerm<'tcx>),
309    Variant { adt: Ty<'tcx>, variant_did: DefId },
310    Ctor { ctor_def_id: DefId, args: GenericArgsRef<'tcx> },
311}
312
313/// New-typed boolean indicating whether explicit late-bound lifetimes
314/// are present in a set of generic arguments.
315///
316/// For example if we have some method `fn f<'a>(&'a self)` implemented
317/// for some type `T`, although `f` is generic in the lifetime `'a`, `'a`
318/// is late-bound so should not be provided explicitly. Thus, if `f` is
319/// instantiated with some generic arguments providing `'a` explicitly,
320/// we taint those arguments with `ExplicitLateBound::Yes` so that we
321/// can provide an appropriate diagnostic later.
322#[derive(#[automatically_derived]
impl ::core::marker::Copy for ExplicitLateBound { }Copy, #[automatically_derived]
#[doc(hidden)]
unsafe impl ::core::clone::TrivialClone for ExplicitLateBound { }
#[automatically_derived]
impl ::core::clone::Clone for ExplicitLateBound {
    #[inline]
    fn clone(&self) -> ExplicitLateBound { *self }
}Clone, #[automatically_derived]
impl ::core::marker::StructuralPartialEq for ExplicitLateBound { }
#[automatically_derived]
impl ::core::cmp::PartialEq for ExplicitLateBound {
    #[inline]
    fn eq(&self, other: &ExplicitLateBound) -> bool {
        let __self_discr = ::core::intrinsics::discriminant_value(self);
        let __arg1_discr = ::core::intrinsics::discriminant_value(other);
        __self_discr == __arg1_discr
    }
}PartialEq, #[automatically_derived]
impl ::core::fmt::Debug for ExplicitLateBound {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::write_str(f,
            match self {
                ExplicitLateBound::Yes => "Yes",
                ExplicitLateBound::No => "No",
            })
    }
}Debug)]
323pub enum ExplicitLateBound {
324    Yes,
325    No,
326}
327
328#[derive(#[automatically_derived]
impl ::core::fmt::Debug for IsMethodCall {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::write_str(f,
            match self {
                IsMethodCall::Yes => "Yes",
                IsMethodCall::No => "No",
            })
    }
}Debug, #[automatically_derived]
impl ::core::marker::Copy for IsMethodCall { }Copy, #[automatically_derived]
#[doc(hidden)]
unsafe impl ::core::clone::TrivialClone for IsMethodCall { }
#[automatically_derived]
impl ::core::clone::Clone for IsMethodCall {
    #[inline]
    fn clone(&self) -> IsMethodCall { *self }
}Clone, #[automatically_derived]
impl ::core::marker::StructuralPartialEq for IsMethodCall { }
#[automatically_derived]
impl ::core::cmp::PartialEq for IsMethodCall {
    #[inline]
    fn eq(&self, other: &IsMethodCall) -> bool {
        let __self_discr = ::core::intrinsics::discriminant_value(self);
        let __arg1_discr = ::core::intrinsics::discriminant_value(other);
        __self_discr == __arg1_discr
    }
}PartialEq)]
329pub enum IsMethodCall {
330    Yes,
331    No,
332}
333
334/// Denotes the "position" of a generic argument, indicating if it is a generic type,
335/// generic function or generic method call.
336#[derive(#[automatically_derived]
impl ::core::fmt::Debug for GenericArgPosition {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        match self {
            GenericArgPosition::Type =>
                ::core::fmt::Formatter::write_str(f, "Type"),
            GenericArgPosition::Value(__self_0) =>
                ::core::fmt::Formatter::debug_tuple_field1_finish(f, "Value",
                    &__self_0),
        }
    }
}Debug, #[automatically_derived]
impl ::core::marker::Copy for GenericArgPosition { }Copy, #[automatically_derived]
#[doc(hidden)]
unsafe impl ::core::clone::TrivialClone for GenericArgPosition { }
#[automatically_derived]
impl ::core::clone::Clone for GenericArgPosition {
    #[inline]
    fn clone(&self) -> GenericArgPosition {
        let _: ::core::clone::AssertParamIsClone<IsMethodCall>;
        *self
    }
}Clone, #[automatically_derived]
impl ::core::marker::StructuralPartialEq for GenericArgPosition { }
#[automatically_derived]
impl ::core::cmp::PartialEq for GenericArgPosition {
    #[inline]
    fn eq(&self, other: &GenericArgPosition) -> bool {
        let __self_discr = ::core::intrinsics::discriminant_value(self);
        let __arg1_discr = ::core::intrinsics::discriminant_value(other);
        __self_discr == __arg1_discr &&
            match (self, other) {
                (GenericArgPosition::Value(__self_0),
                    GenericArgPosition::Value(__arg1_0)) =>
                    __self_0 == __arg1_0,
                _ => true,
            }
    }
}PartialEq)]
337pub(crate) enum GenericArgPosition {
338    Type,
339    Value(IsMethodCall),
340}
341
342/// Whether to allow duplicate associated iten constraints in a trait ref, e.g.
343/// `Trait<Assoc = Ty, Assoc = Ty>`. This is forbidden in `dyn Trait<...>`
344/// but allowed everywhere else.
345#[derive(#[automatically_derived]
#[doc(hidden)]
unsafe impl ::core::clone::TrivialClone for OverlappingAsssocItemConstraints {
}
#[automatically_derived]
impl ::core::clone::Clone for OverlappingAsssocItemConstraints {
    #[inline]
    fn clone(&self) -> OverlappingAsssocItemConstraints { *self }
}Clone, #[automatically_derived]
impl ::core::marker::Copy for OverlappingAsssocItemConstraints { }Copy, #[automatically_derived]
impl ::core::fmt::Debug for OverlappingAsssocItemConstraints {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::write_str(f,
            match self {
                OverlappingAsssocItemConstraints::Allowed => "Allowed",
                OverlappingAsssocItemConstraints::Forbidden => "Forbidden",
            })
    }
}Debug, #[automatically_derived]
impl ::core::marker::StructuralPartialEq for OverlappingAsssocItemConstraints
    {
}
#[automatically_derived]
impl ::core::cmp::PartialEq for OverlappingAsssocItemConstraints {
    #[inline]
    fn eq(&self, other: &OverlappingAsssocItemConstraints) -> bool {
        let __self_discr = ::core::intrinsics::discriminant_value(self);
        let __arg1_discr = ::core::intrinsics::discriminant_value(other);
        __self_discr == __arg1_discr
    }
}PartialEq)]
346pub(crate) enum OverlappingAsssocItemConstraints {
347    Allowed,
348    Forbidden,
349}
350
351/// A marker denoting that the generic arguments that were
352/// provided did not match the respective generic parameters.
353#[derive(#[automatically_derived]
impl ::core::clone::Clone for GenericArgCountMismatch {
    #[inline]
    fn clone(&self) -> GenericArgCountMismatch {
        GenericArgCountMismatch {
            reported: ::core::clone::Clone::clone(&self.reported),
            invalid_args: ::core::clone::Clone::clone(&self.invalid_args),
        }
    }
}Clone, #[automatically_derived]
impl ::core::fmt::Debug for GenericArgCountMismatch {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::debug_struct_field2_finish(f,
            "GenericArgCountMismatch", "reported", &self.reported,
            "invalid_args", &&self.invalid_args)
    }
}Debug)]
354pub struct GenericArgCountMismatch {
355    pub reported: ErrorGuaranteed,
356    /// A list of indices of arguments provided that were not valid.
357    pub invalid_args: Vec<usize>,
358}
359
360/// Decorates the result of a generic argument count mismatch
361/// check with whether explicit late bounds were provided.
362#[derive(#[automatically_derived]
impl ::core::clone::Clone for GenericArgCountResult {
    #[inline]
    fn clone(&self) -> GenericArgCountResult {
        GenericArgCountResult {
            explicit_late_bound: ::core::clone::Clone::clone(&self.explicit_late_bound),
            correct: ::core::clone::Clone::clone(&self.correct),
        }
    }
}Clone, #[automatically_derived]
impl ::core::fmt::Debug for GenericArgCountResult {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::debug_struct_field2_finish(f,
            "GenericArgCountResult", "explicit_late_bound",
            &self.explicit_late_bound, "correct", &&self.correct)
    }
}Debug)]
363pub struct GenericArgCountResult {
364    pub explicit_late_bound: ExplicitLateBound,
365    pub correct: Result<(), GenericArgCountMismatch>,
366}
367
368/// A context which can lower HIR's [`GenericArg`] to `rustc_middle`'s [`ty::GenericArg`].
369///
370/// Its only consumer is [`generics::lower_generic_args`].
371/// Read its documentation to learn more.
372pub trait GenericArgsLowerer<'a, 'tcx> {
373    fn args_for_def_id(&mut self, def_id: DefId) -> (Option<&'a GenericArgs<'a>>, bool);
374
375    fn provided_kind(
376        &mut self,
377        preceding_args: &[ty::GenericArg<'tcx>],
378        param: &ty::GenericParamDef,
379        arg: &GenericArg<'_>,
380    ) -> ty::GenericArg<'tcx>;
381
382    fn inferred_kind(
383        &mut self,
384        preceding_args: &[ty::GenericArg<'tcx>],
385        param: &ty::GenericParamDef,
386        infer_args: bool,
387    ) -> ty::GenericArg<'tcx>;
388}
389
390/// Context in which `ForbidParamUsesFolder` is being used, to emit appropriate diagnostics.
391enum ForbidParamContext {
392    /// Anon const in a const argument position.
393    ConstArgument,
394    /// Enum discriminant expression.
395    EnumDiscriminant,
396}
397
398struct ForbidParamUsesFolder<'tcx> {
399    tcx: TyCtxt<'tcx>,
400    anon_const_def_id: LocalDefId,
401    span: Span,
402    is_self_alias: bool,
403    context: ForbidParamContext,
404}
405
406impl<'tcx> ForbidParamUsesFolder<'tcx> {
407    fn error(&self) -> ErrorGuaranteed {
408        let msg = match self.context {
409            ForbidParamContext::EnumDiscriminant if self.is_self_alias => {
410                "generic `Self` types are not permitted in enum discriminant values"
411            }
412            ForbidParamContext::EnumDiscriminant => {
413                "generic parameters may not be used in enum discriminant values"
414            }
415            ForbidParamContext::ConstArgument if self.is_self_alias => {
416                "generic `Self` types are currently not permitted in anonymous constants"
417            }
418            ForbidParamContext::ConstArgument => {
419                if self.tcx.features().generic_const_args() {
420                    "generic parameters in const blocks are not allowed; use a named `const` item instead"
421                } else {
422                    "generic parameters may not be used in const operations"
423                }
424            }
425        };
426        let mut diag = self.tcx.dcx().struct_span_err(self.span, msg);
427        if self.is_self_alias && #[allow(non_exhaustive_omitted_patterns)] match self.context {
    ForbidParamContext::ConstArgument => true,
    _ => false,
}matches!(self.context, ForbidParamContext::ConstArgument) {
428            let anon_const_hir_id: HirId = HirId::make_owner(self.anon_const_def_id);
429            let parent_impl = self.tcx.hir_parent_owner_iter(anon_const_hir_id).find_map(
430                |(_, node)| match node {
431                    hir::OwnerNode::Item(hir::Item {
432                        kind: hir::ItemKind::Impl(impl_), ..
433                    }) => Some(impl_),
434                    _ => None,
435                },
436            );
437            if let Some(impl_) = parent_impl {
438                diag.span_note(impl_.self_ty.span, "not a concrete type");
439            }
440        }
441        if #[allow(non_exhaustive_omitted_patterns)] match self.context {
    ForbidParamContext::ConstArgument => true,
    _ => false,
}matches!(self.context, ForbidParamContext::ConstArgument) {
442            if self.tcx.features().generic_const_args() {
443                diag.help("consider factoring the expression into a `type const` item and use it as the const argument instead");
444            } else if self.tcx.features().min_generic_const_args() {
445                diag.help("add `#![feature(generic_const_args)]` and extract the expression into a `type const` item");
446            } else if self.tcx.sess.is_nightly_build() {
447                diag.help(
448                    "add `#![feature(generic_const_exprs)]` to allow generic const expressions",
449                );
450                diag.help("alternatively, you can use `#![feature(generic_const_args)]` and extract the expression into a `type const` item");
451            }
452        }
453        diag.emit()
454    }
455}
456
457impl<'tcx> ty::TypeFolder<TyCtxt<'tcx>> for ForbidParamUsesFolder<'tcx> {
458    fn cx(&self) -> TyCtxt<'tcx> {
459        self.tcx
460    }
461
462    fn fold_ty(&mut self, t: Ty<'tcx>) -> Ty<'tcx> {
463        if #[allow(non_exhaustive_omitted_patterns)] match t.kind() {
    ty::Param(..) => true,
    _ => false,
}matches!(t.kind(), ty::Param(..)) {
464            return Ty::new_error(self.tcx, self.error());
465        }
466        t.super_fold_with(self)
467    }
468
469    fn fold_const(&mut self, c: Const<'tcx>) -> Const<'tcx> {
470        if #[allow(non_exhaustive_omitted_patterns)] match c.kind() {
    ty::ConstKind::Param(..) => true,
    _ => false,
}matches!(c.kind(), ty::ConstKind::Param(..)) {
471            return Const::new_error(self.tcx, self.error());
472        }
473        c.super_fold_with(self)
474    }
475
476    fn fold_region(&mut self, r: ty::Region<'tcx>) -> ty::Region<'tcx> {
477        if #[allow(non_exhaustive_omitted_patterns)] match r.kind() {
    ty::RegionKind::ReEarlyParam(..) | ty::RegionKind::ReLateParam(..) =>
        true,
    _ => false,
}matches!(r.kind(), ty::RegionKind::ReEarlyParam(..) | ty::RegionKind::ReLateParam(..)) {
478            return ty::Region::new_error(self.tcx, self.error());
479        }
480        r
481    }
482}
483
484impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
485    /// See `check_param_uses_if_mcg`.
486    ///
487    /// FIXME(mgca): this is pub only for instantiate_value_path and would be nice to avoid altogether
488    pub fn check_param_res_if_mcg_for_instantiate_value_path(
489        &self,
490        res: Res,
491        span: Span,
492    ) -> Result<(), ErrorGuaranteed> {
493        let tcx = self.tcx();
494        let parent_def_id = self.item_def_id();
495        // In this path, `Some(context)` should be `ConstArgument`: enum
496        // discriminants are handled earlier by resolve. We still use the helper so
497        // nested inline consts are checked in the outer const-argument context.
498        if let Res::Def(DefKind::ConstParam, _) = res
499            && let Some(context) = self.anon_const_forbids_generic_params()
500        {
501            let folder = ForbidParamUsesFolder {
502                tcx,
503                anon_const_def_id: parent_def_id,
504                span,
505                is_self_alias: false,
506                context,
507            };
508            return Err(folder.error());
509        }
510        Ok(())
511    }
512
513    /// Returns the `ForbidParamContext` for the current anon const if it is a context that
514    /// forbids uses of generic parameters. `None` if the current item is not such a context.
515    ///
516    /// Name resolution handles most invalid generic parameter uses in these contexts, but it
517    /// cannot reject `Self` that aliases a generic type, nor generic parameters introduced by
518    /// type-dependent name resolution (e.g. `<Self as Trait>::Assoc` resolving to a type that
519    /// contains params). Those cases are handled by `check_param_uses_if_mcg`.
520    fn anon_const_forbids_generic_params(&self) -> Option<ForbidParamContext> {
521        let tcx = self.tcx();
522        let item_def_id = self.item_def_id();
523
524        // Inline consts and closures can be nested inside anon consts that forbid generic
525        // params (e.g. an enum discriminant). Walk up the def parent chain to find the
526        // nearest enclosing AnonConst and use that to determine the context.
527        let anon_const_def_id = tcx.typeck_root_def_id_local(item_def_id);
528
529        if tcx.def_kind(anon_const_def_id) != DefKind::AnonConst {
530            return None;
531        }
532
533        match tcx.anon_const_kind(anon_const_def_id) {
534            ty::AnonConstKind::MCG => Some(ForbidParamContext::ConstArgument),
535            ty::AnonConstKind::NonTypeSystemAnon => {
536                // NonTypeSystem anon consts only have accessible generic parameters in specific
537                // positions (ty patterns and field defaults — see `generics_of`). In all other
538                // positions (e.g. enum discriminants) generic parameters are not in scope.
539                if tcx.generics_of(anon_const_def_id).count() == 0 {
540                    Some(ForbidParamContext::EnumDiscriminant)
541                } else {
542                    None
543                }
544            }
545            ty::AnonConstKind::NonTypeSystemInline
546            | ty::AnonConstKind::GCE
547            | ty::AnonConstKind::RepeatExprCount => None,
548        }
549    }
550
551    /// Check for uses of generic parameters that are not in scope due to this being
552    /// in a non-generic anon const context (e.g. MCG or an enum discriminant).
553    ///
554    /// Name resolution rejects most invalid uses, but cannot handle `Self` aliasing a
555    /// generic type or generic parameters introduced by type-dependent name resolution.
556    #[must_use = "need to use transformed output"]
557    fn check_param_uses_if_mcg<T>(&self, term: T, span: Span, is_self_alias: bool) -> T
558    where
559        T: ty::TypeFoldable<TyCtxt<'tcx>>,
560    {
561        let tcx = self.tcx();
562        if let Some(context) = self.anon_const_forbids_generic_params()
563            // Fast path if contains no params/escaping bound vars.
564            && (term.has_param() || term.has_escaping_bound_vars())
565        {
566            let anon_const_def_id = self.item_def_id();
567            let mut folder =
568                ForbidParamUsesFolder { tcx, anon_const_def_id, span, is_self_alias, context };
569            term.fold_with(&mut folder)
570        } else {
571            term
572        }
573    }
574
575    /// Lower a lifetime from the HIR to our internal notion of a lifetime called a *region*.
576    {}
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("lower_lifetime",
                                "rustc_hir_analysis::hir_ty_lowering",
                                ::tracing::Level::DEBUG,
                                ::tracing_core::__macro_support::Option::Some("/rustc-dev/a36d05efab632d1ddf902b6a5c33b6d5d3b64131/compiler/rustc_hir_analysis/src/hir_ty_lowering/mod.rs"),
                                ::tracing_core::__macro_support::Option::Some(576u32),
                                ::tracing_core::__macro_support::Option::Some("rustc_hir_analysis::hir_ty_lowering"),
                                ::tracing_core::field::FieldSet::new(&[{
                                                    const NAME:
                                                        ::tracing::__macro_support::FieldName<{
                                                            ::tracing::__macro_support::FieldName::len("lifetime")
                                                        }> =
                                                        ::tracing::__macro_support::FieldName::new("lifetime");
                                                    NAME.as_str()
                                                },
                                                {
                                                    const NAME:
                                                        ::tracing::__macro_support::FieldName<{
                                                            ::tracing::__macro_support::FieldName::len("reason")
                                                        }> =
                                                        ::tracing::__macro_support::FieldName::new("reason");
                                                    NAME.as_str()
                                                }], ::tracing_core::callsite::Identifier(&__CALLSITE)),
                                ::tracing::metadata::Kind::SPAN)
                        };
                    ::tracing::callsite::DefaultCallsite::new(&META)
                };
            let mut interest = ::tracing::subscriber::Interest::never();
            if ::tracing::Level::DEBUG <=
                                ::tracing::level_filters::STATIC_MAX_LEVEL &&
                            ::tracing::Level::DEBUG <=
                                ::tracing::level_filters::LevelFilter::current() &&
                        { interest = __CALLSITE.interest(); !interest.is_never() }
                    &&
                    ::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
                        interest) {
                let meta = __CALLSITE.metadata();
                ::tracing::Span::new(meta,
                    &{
                            #[allow(unused_imports)]
                            use ::tracing::field::{debug, display, Value};
                            meta.fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&lifetime)
                                                        as &dyn ::tracing::field::Value)),
                                            (::tracing::__macro_support::Option::Some(&::tracing::field::debug(&reason)
                                                        as &dyn ::tracing::field::Value))])
                        })
            } else {
                let span =
                    ::tracing::__macro_support::__disabled_span(__CALLSITE.metadata());
                {};
                span
            }
        };
    __tracing_attr_guard = __tracing_attr_span.enter();
}
#[allow(clippy :: redundant_closure_call)]
let x =
    (move ||
                {

                    #[allow(unknown_lints, unreachable_code, clippy ::
                    diverging_sub_expression, clippy :: empty_loop, clippy ::
                    let_unit_value, clippy :: let_with_type_underscore, clippy
                    :: needless_return, clippy :: unreachable)]
                    if false {
                        let __tracing_attr_fake_return: ty::Region<'tcx> = loop {};
                        return __tracing_attr_fake_return;
                    }
                    {
                        if let Some(resolved) =
                                self.tcx().named_bound_var(lifetime.hir_id) {
                            let region = self.lower_resolved_lifetime(resolved);
                            self.check_param_uses_if_mcg(region, lifetime.ident.span,
                                false)
                        } else { self.re_infer(lifetime.ident.span, reason) }
                    }
                })();
{
    use ::tracing::__macro_support::Callsite as _;
    static __CALLSITE: ::tracing::callsite::DefaultCallsite =
        {
            static META: ::tracing::Metadata<'static> =
                {
                    ::tracing_core::metadata::Metadata::new("event /rustc-dev/a36d05efab632d1ddf902b6a5c33b6d5d3b64131/compiler/rustc_hir_analysis/src/hir_ty_lowering/mod.rs:576",
                        "rustc_hir_analysis::hir_ty_lowering",
                        ::tracing::Level::DEBUG,
                        ::tracing_core::__macro_support::Option::Some("/rustc-dev/a36d05efab632d1ddf902b6a5c33b6d5d3b64131/compiler/rustc_hir_analysis/src/hir_ty_lowering/mod.rs"),
                        ::tracing_core::__macro_support::Option::Some(576u32),
                        ::tracing_core::__macro_support::Option::Some("rustc_hir_analysis::hir_ty_lowering"),
                        ::tracing_core::field::FieldSet::new(&[{
                                            const NAME:
                                                ::tracing::__macro_support::FieldName<{
                                                    ::tracing::__macro_support::FieldName::len("return")
                                                }> =
                                                ::tracing::__macro_support::FieldName::new("return");
                                            NAME.as_str()
                                        }], ::tracing_core::callsite::Identifier(&__CALLSITE)),
                        ::tracing::metadata::Kind::EVENT)
                };
            ::tracing::callsite::DefaultCallsite::new(&META)
        };
    let enabled =
        ::tracing::Level::DEBUG <= ::tracing::level_filters::STATIC_MAX_LEVEL
                &&
                ::tracing::Level::DEBUG <=
                    ::tracing::level_filters::LevelFilter::current() &&
            {
                let interest = __CALLSITE.interest();
                !interest.is_never() &&
                    ::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
                        interest)
            };
    if enabled {
        (|value_set: ::tracing::field::ValueSet|
                    {
                        let meta = __CALLSITE.metadata();
                        ::tracing::Event::dispatch(meta, &value_set);
                        ;
                    })({
                #[allow(unused_imports)]
                use ::tracing::field::{debug, display, Value};
                __CALLSITE.metadata().fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&x)
                                            as &dyn ::tracing::field::Value))])
            });
    } else { ; }
};
x;#[instrument(level = "debug", skip(self), ret)]
577    pub fn lower_lifetime(
578        &self,
579        lifetime: &hir::Lifetime,
580        reason: RegionInferReason<'_>,
581    ) -> ty::Region<'tcx> {
582        if let Some(resolved) = self.tcx().named_bound_var(lifetime.hir_id) {
583            let region = self.lower_resolved_lifetime(resolved);
584            self.check_param_uses_if_mcg(region, lifetime.ident.span, false)
585        } else {
586            self.re_infer(lifetime.ident.span, reason)
587        }
588    }
589
590    /// Lower a lifetime from the HIR to our internal notion of a lifetime called a *region*.
591    {}
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("lower_resolved_lifetime",
                                "rustc_hir_analysis::hir_ty_lowering",
                                ::tracing::Level::DEBUG,
                                ::tracing_core::__macro_support::Option::Some("/rustc-dev/a36d05efab632d1ddf902b6a5c33b6d5d3b64131/compiler/rustc_hir_analysis/src/hir_ty_lowering/mod.rs"),
                                ::tracing_core::__macro_support::Option::Some(591u32),
                                ::tracing_core::__macro_support::Option::Some("rustc_hir_analysis::hir_ty_lowering"),
                                ::tracing_core::field::FieldSet::new(&[{
                                                    const NAME:
                                                        ::tracing::__macro_support::FieldName<{
                                                            ::tracing::__macro_support::FieldName::len("resolved")
                                                        }> =
                                                        ::tracing::__macro_support::FieldName::new("resolved");
                                                    NAME.as_str()
                                                }], ::tracing_core::callsite::Identifier(&__CALLSITE)),
                                ::tracing::metadata::Kind::SPAN)
                        };
                    ::tracing::callsite::DefaultCallsite::new(&META)
                };
            let mut interest = ::tracing::subscriber::Interest::never();
            if ::tracing::Level::DEBUG <=
                                ::tracing::level_filters::STATIC_MAX_LEVEL &&
                            ::tracing::Level::DEBUG <=
                                ::tracing::level_filters::LevelFilter::current() &&
                        { interest = __CALLSITE.interest(); !interest.is_never() }
                    &&
                    ::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
                        interest) {
                let meta = __CALLSITE.metadata();
                ::tracing::Span::new(meta,
                    &{
                            #[allow(unused_imports)]
                            use ::tracing::field::{debug, display, Value};
                            meta.fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&resolved)
                                                        as &dyn ::tracing::field::Value))])
                        })
            } else {
                let span =
                    ::tracing::__macro_support::__disabled_span(__CALLSITE.metadata());
                {};
                span
            }
        };
    __tracing_attr_guard = __tracing_attr_span.enter();
}
#[allow(clippy :: redundant_closure_call)]
let x =
    (move ||
                {

                    #[allow(unknown_lints, unreachable_code, clippy ::
                    diverging_sub_expression, clippy :: empty_loop, clippy ::
                    let_unit_value, clippy :: let_with_type_underscore, clippy
                    :: needless_return, clippy :: unreachable)]
                    if false {
                        let __tracing_attr_fake_return: ty::Region<'tcx> = loop {};
                        return __tracing_attr_fake_return;
                    }
                    {
                        let tcx = self.tcx();
                        match resolved {
                            rbv::ResolvedArg::StaticLifetime => tcx.lifetimes.re_static,
                            rbv::ResolvedArg::LateBound(debruijn, index, def_id) => {
                                let br =
                                    ty::BoundRegion {
                                        var: ty::BoundVar::from_u32(index),
                                        kind: ty::BoundRegionKind::Named(def_id.to_def_id()),
                                    };
                                ty::Region::new_bound(tcx, debruijn, br)
                            }
                            rbv::ResolvedArg::EarlyBound(def_id) => {
                                let name = tcx.hir_ty_param_name(def_id);
                                let item_def_id = tcx.hir_ty_param_owner(def_id);
                                let generics = tcx.generics_of(item_def_id);
                                let index =
                                    generics.param_def_id_to_index[&def_id.to_def_id()];
                                ty::Region::new_early_param(tcx,
                                    ty::EarlyParamRegion { index, name })
                            }
                            rbv::ResolvedArg::Free(scope, id) => {
                                ty::Region::new_late_param(tcx, scope.to_def_id(),
                                    ty::LateParamRegionKind::Named(id.to_def_id()))
                            }
                            rbv::ResolvedArg::Error(guar) =>
                                ty::Region::new_error(tcx, guar),
                        }
                    }
                })();
{
    use ::tracing::__macro_support::Callsite as _;
    static __CALLSITE: ::tracing::callsite::DefaultCallsite =
        {
            static META: ::tracing::Metadata<'static> =
                {
                    ::tracing_core::metadata::Metadata::new("event /rustc-dev/a36d05efab632d1ddf902b6a5c33b6d5d3b64131/compiler/rustc_hir_analysis/src/hir_ty_lowering/mod.rs:591",
                        "rustc_hir_analysis::hir_ty_lowering",
                        ::tracing::Level::DEBUG,
                        ::tracing_core::__macro_support::Option::Some("/rustc-dev/a36d05efab632d1ddf902b6a5c33b6d5d3b64131/compiler/rustc_hir_analysis/src/hir_ty_lowering/mod.rs"),
                        ::tracing_core::__macro_support::Option::Some(591u32),
                        ::tracing_core::__macro_support::Option::Some("rustc_hir_analysis::hir_ty_lowering"),
                        ::tracing_core::field::FieldSet::new(&[{
                                            const NAME:
                                                ::tracing::__macro_support::FieldName<{
                                                    ::tracing::__macro_support::FieldName::len("return")
                                                }> =
                                                ::tracing::__macro_support::FieldName::new("return");
                                            NAME.as_str()
                                        }], ::tracing_core::callsite::Identifier(&__CALLSITE)),
                        ::tracing::metadata::Kind::EVENT)
                };
            ::tracing::callsite::DefaultCallsite::new(&META)
        };
    let enabled =
        ::tracing::Level::DEBUG <= ::tracing::level_filters::STATIC_MAX_LEVEL
                &&
                ::tracing::Level::DEBUG <=
                    ::tracing::level_filters::LevelFilter::current() &&
            {
                let interest = __CALLSITE.interest();
                !interest.is_never() &&
                    ::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
                        interest)
            };
    if enabled {
        (|value_set: ::tracing::field::ValueSet|
                    {
                        let meta = __CALLSITE.metadata();
                        ::tracing::Event::dispatch(meta, &value_set);
                        ;
                    })({
                #[allow(unused_imports)]
                use ::tracing::field::{debug, display, Value};
                __CALLSITE.metadata().fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&x)
                                            as &dyn ::tracing::field::Value))])
            });
    } else { ; }
};
x;#[instrument(level = "debug", skip(self), ret)]
592    fn lower_resolved_lifetime(&self, resolved: rbv::ResolvedArg) -> ty::Region<'tcx> {
593        let tcx = self.tcx();
594
595        match resolved {
596            rbv::ResolvedArg::StaticLifetime => tcx.lifetimes.re_static,
597
598            rbv::ResolvedArg::LateBound(debruijn, index, def_id) => {
599                let br = ty::BoundRegion {
600                    var: ty::BoundVar::from_u32(index),
601                    kind: ty::BoundRegionKind::Named(def_id.to_def_id()),
602                };
603                ty::Region::new_bound(tcx, debruijn, br)
604            }
605
606            rbv::ResolvedArg::EarlyBound(def_id) => {
607                let name = tcx.hir_ty_param_name(def_id);
608                let item_def_id = tcx.hir_ty_param_owner(def_id);
609                let generics = tcx.generics_of(item_def_id);
610                let index = generics.param_def_id_to_index[&def_id.to_def_id()];
611                ty::Region::new_early_param(tcx, ty::EarlyParamRegion { index, name })
612            }
613
614            rbv::ResolvedArg::Free(scope, id) => {
615                ty::Region::new_late_param(
616                    tcx,
617                    scope.to_def_id(),
618                    ty::LateParamRegionKind::Named(id.to_def_id()),
619                )
620
621                // (*) -- not late-bound, won't change
622            }
623
624            rbv::ResolvedArg::Error(guar) => ty::Region::new_error(tcx, guar),
625        }
626    }
627
628    pub fn lower_generic_args_of_path_segment(
629        &self,
630        span: Span,
631        def_id: DefId,
632        item_segment: &hir::PathSegment<'_>,
633    ) -> GenericArgsRef<'tcx> {
634        let (args, _) = self.lower_generic_args_of_path(span, def_id, &[], item_segment, None);
635        if let Some(c) = item_segment.args().constraints.first() {
636            prohibit_assoc_item_constraint(self, c, Some((def_id, item_segment, span)));
637        }
638        args
639    }
640
641    /// Lower the generic arguments provided to some path.
642    ///
643    /// If this is a trait reference, you also need to pass the self type `self_ty`.
644    /// The lowering process may involve applying defaulted type parameters.
645    ///
646    /// Associated item constraints are not handled here! They are either lowered via
647    /// `lower_assoc_item_constraint` or rejected via `prohibit_assoc_item_constraint`.
648    ///
649    /// ### Example
650    ///
651    /// ```ignore (illustrative)
652    ///    T: std::ops::Index<usize, Output = u32>
653    /// // ^1 ^^^^^^^^^^^^^^2 ^^^^3  ^^^^^^^^^^^4
654    /// ```
655    ///
656    /// 1. The `self_ty` here would refer to the type `T`.
657    /// 2. The path in question is the path to the trait `std::ops::Index`,
658    ///    which will have been resolved to a `def_id`
659    /// 3. The `generic_args` contains info on the `<...>` contents. The `usize` type
660    ///    parameters are returned in the `GenericArgsRef`
661    /// 4. Associated item constraints like `Output = u32` are contained in `generic_args.constraints`.
662    ///
663    /// Note that the type listing given here is *exactly* what the user provided.
664    ///
665    /// For (generic) associated types
666    ///
667    /// ```ignore (illustrative)
668    /// <Vec<u8> as Iterable<u8>>::Iter::<'a>
669    /// ```
670    ///
671    /// We have the parent args are the args for the parent trait:
672    /// `[Vec<u8>, u8]` and `generic_args` are the arguments for the associated
673    /// type itself: `['a]`. The returned `GenericArgsRef` concatenates these two
674    /// lists: `[Vec<u8>, u8, 'a]`.
675    {}
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("lower_generic_args_of_path",
                                "rustc_hir_analysis::hir_ty_lowering",
                                ::tracing::Level::DEBUG,
                                ::tracing_core::__macro_support::Option::Some("/rustc-dev/a36d05efab632d1ddf902b6a5c33b6d5d3b64131/compiler/rustc_hir_analysis/src/hir_ty_lowering/mod.rs"),
                                ::tracing_core::__macro_support::Option::Some(675u32),
                                ::tracing_core::__macro_support::Option::Some("rustc_hir_analysis::hir_ty_lowering"),
                                ::tracing_core::field::FieldSet::new(&[{
                                                    const NAME:
                                                        ::tracing::__macro_support::FieldName<{
                                                            ::tracing::__macro_support::FieldName::len("def_id")
                                                        }> =
                                                        ::tracing::__macro_support::FieldName::new("def_id");
                                                    NAME.as_str()
                                                },
                                                {
                                                    const NAME:
                                                        ::tracing::__macro_support::FieldName<{
                                                            ::tracing::__macro_support::FieldName::len("parent_args")
                                                        }> =
                                                        ::tracing::__macro_support::FieldName::new("parent_args");
                                                    NAME.as_str()
                                                },
                                                {
                                                    const NAME:
                                                        ::tracing::__macro_support::FieldName<{
                                                            ::tracing::__macro_support::FieldName::len("segment")
                                                        }> =
                                                        ::tracing::__macro_support::FieldName::new("segment");
                                                    NAME.as_str()
                                                },
                                                {
                                                    const NAME:
                                                        ::tracing::__macro_support::FieldName<{
                                                            ::tracing::__macro_support::FieldName::len("self_ty")
                                                        }> =
                                                        ::tracing::__macro_support::FieldName::new("self_ty");
                                                    NAME.as_str()
                                                }], ::tracing_core::callsite::Identifier(&__CALLSITE)),
                                ::tracing::metadata::Kind::SPAN)
                        };
                    ::tracing::callsite::DefaultCallsite::new(&META)
                };
            let mut interest = ::tracing::subscriber::Interest::never();
            if ::tracing::Level::DEBUG <=
                                ::tracing::level_filters::STATIC_MAX_LEVEL &&
                            ::tracing::Level::DEBUG <=
                                ::tracing::level_filters::LevelFilter::current() &&
                        { interest = __CALLSITE.interest(); !interest.is_never() }
                    &&
                    ::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
                        interest) {
                let meta = __CALLSITE.metadata();
                ::tracing::Span::new(meta,
                    &{
                            #[allow(unused_imports)]
                            use ::tracing::field::{debug, display, Value};
                            meta.fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&def_id)
                                                        as &dyn ::tracing::field::Value)),
                                            (::tracing::__macro_support::Option::Some(&::tracing::field::debug(&parent_args)
                                                        as &dyn ::tracing::field::Value)),
                                            (::tracing::__macro_support::Option::Some(&::tracing::field::debug(&segment)
                                                        as &dyn ::tracing::field::Value)),
                                            (::tracing::__macro_support::Option::Some(&::tracing::field::debug(&self_ty)
                                                        as &dyn ::tracing::field::Value))])
                        })
            } else {
                let span =
                    ::tracing::__macro_support::__disabled_span(__CALLSITE.metadata());
                {};
                span
            }
        };
    __tracing_attr_guard = __tracing_attr_span.enter();
}
#[allow(clippy :: redundant_closure_call)]
let x =
    (move ||
                {

                    #[allow(unknown_lints, unreachable_code, clippy ::
                    diverging_sub_expression, clippy :: empty_loop, clippy ::
                    let_unit_value, clippy :: let_with_type_underscore, clippy
                    :: needless_return, clippy :: unreachable)]
                    if false {
                        let __tracing_attr_fake_return:
                                (GenericArgsRef<'tcx>, GenericArgCountResult) = loop {};
                        return __tracing_attr_fake_return;
                    }
                    {
                        let tcx = self.tcx();
                        let generics = tcx.generics_of(def_id);
                        {
                            use ::tracing::__macro_support::Callsite as _;
                            static __CALLSITE: ::tracing::callsite::DefaultCallsite =
                                {
                                    static META: ::tracing::Metadata<'static> =
                                        {
                                            ::tracing_core::metadata::Metadata::new("event /rustc-dev/a36d05efab632d1ddf902b6a5c33b6d5d3b64131/compiler/rustc_hir_analysis/src/hir_ty_lowering/mod.rs:690",
                                                "rustc_hir_analysis::hir_ty_lowering",
                                                ::tracing::Level::DEBUG,
                                                ::tracing_core::__macro_support::Option::Some("/rustc-dev/a36d05efab632d1ddf902b6a5c33b6d5d3b64131/compiler/rustc_hir_analysis/src/hir_ty_lowering/mod.rs"),
                                                ::tracing_core::__macro_support::Option::Some(690u32),
                                                ::tracing_core::__macro_support::Option::Some("rustc_hir_analysis::hir_ty_lowering"),
                                                ::tracing_core::field::FieldSet::new(&[{
                                                                    const NAME:
                                                                        ::tracing::__macro_support::FieldName<{
                                                                            ::tracing::__macro_support::FieldName::len("generics")
                                                                        }> =
                                                                        ::tracing::__macro_support::FieldName::new("generics");
                                                                    NAME.as_str()
                                                                }], ::tracing_core::callsite::Identifier(&__CALLSITE)),
                                                ::tracing::metadata::Kind::EVENT)
                                        };
                                    ::tracing::callsite::DefaultCallsite::new(&META)
                                };
                            let enabled =
                                ::tracing::Level::DEBUG <=
                                            ::tracing::level_filters::STATIC_MAX_LEVEL &&
                                        ::tracing::Level::DEBUG <=
                                            ::tracing::level_filters::LevelFilter::current() &&
                                    {
                                        let interest = __CALLSITE.interest();
                                        !interest.is_never() &&
                                            ::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
                                                interest)
                                    };
                            if enabled {
                                (|value_set: ::tracing::field::ValueSet|
                                            {
                                                let meta = __CALLSITE.metadata();
                                                ::tracing::Event::dispatch(meta, &value_set);
                                                ;
                                            })({
                                        #[allow(unused_imports)]
                                        use ::tracing::field::{debug, display, Value};
                                        __CALLSITE.metadata().fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&generics)
                                                                    as &dyn ::tracing::field::Value))])
                                    });
                            } else { ; }
                        };
                        if generics.has_self {
                            if generics.parent.is_some() {
                                if !!parent_args.is_empty() {
                                    ::core::panicking::panic("assertion failed: !parent_args.is_empty()")
                                }
                            } else {
                                if !self_ty.is_some() {
                                    ::core::panicking::panic("assertion failed: self_ty.is_some()")
                                };
                            }
                        } else {
                            if !self_ty.is_none() {
                                ::core::panicking::panic("assertion failed: self_ty.is_none()")
                            };
                        }
                        let arg_count =
                            check_generic_arg_count(self, def_id, segment, generics,
                                GenericArgPosition::Type, self_ty.is_some());
                        if generics.is_own_empty() {
                            return (tcx.mk_args(parent_args), arg_count);
                        }
                        struct GenericArgsCtxt<'a, 'tcx> {
                            lowerer: &'a dyn HirTyLowerer<'tcx>,
                            def_id: DefId,
                            generic_args: &'a GenericArgs<'a>,
                            span: Span,
                            infer_args: bool,
                            create_synth_args: bool,
                            incorrect_args: &'a Result<(), GenericArgCountMismatch>,
                        }
                        impl<'a, 'tcx> GenericArgsLowerer<'a, 'tcx> for
                            GenericArgsCtxt<'a, 'tcx> {
                            fn args_for_def_id(&mut self, did: DefId)
                                -> (Option<&'a GenericArgs<'a>>, bool) {
                                if did == self.def_id {
                                    (Some(self.generic_args), self.infer_args)
                                } else { (None, false) }
                            }
                            fn provided_kind(&mut self,
                                preceding_args: &[ty::GenericArg<'tcx>],
                                param: &ty::GenericParamDef, arg: &GenericArg<'_>)
                                -> ty::GenericArg<'tcx> {
                                let tcx = self.lowerer.tcx();
                                if let Err(incorrect) = self.incorrect_args {
                                    if incorrect.invalid_args.contains(&(param.index as usize))
                                        {
                                        return param.to_error(tcx);
                                    }
                                }
                                let handle_ty_args =
                                    |has_default, ty: &hir::Ty<'_>|
                                        {
                                            if has_default {
                                                tcx.check_optional_stability(param.def_id,
                                                    Some(arg.hir_id()), arg.span(), None, AllowUnstable::No,
                                                    |_, _| {});
                                            }
                                            self.lowerer.lower_ty(ty).into()
                                        };
                                match (&param.kind, arg) {
                                    (GenericParamDefKind::Lifetime, GenericArg::Lifetime(lt)) =>
                                        {
                                        self.lowerer.lower_lifetime(lt,
                                                RegionInferReason::Param(param)).into()
                                    }
                                    (&GenericParamDefKind::Type { has_default, .. },
                                        GenericArg::Type(ty)) => {
                                        handle_ty_args(has_default, ty.as_unambig_ty())
                                    }
                                    (&GenericParamDefKind::Type { has_default, .. },
                                        GenericArg::Infer(inf)) => {
                                        handle_ty_args(has_default, &inf.to_ty())
                                    }
                                    (GenericParamDefKind::Const { .. }, GenericArg::Const(ct))
                                        =>
                                        self.lowerer.lower_const_arg(ct.as_unambig_ct(),
                                                tcx.type_of(param.def_id).instantiate(tcx,
                                                        preceding_args).skip_norm_wip()).into(),
                                    (&GenericParamDefKind::Const { .. }, GenericArg::Infer(inf))
                                        => {
                                        self.lowerer.ct_infer(Some(param), inf.span).into()
                                    }
                                    (kind, arg) =>
                                        ::rustc_middle::util::bug::span_bug_fmt(self.span,
                                            format_args!("mismatched path argument for kind {0:?}: found arg {1:?}",
                                                kind, arg)),
                                }
                            }
                            fn inferred_kind(&mut self,
                                preceding_args: &[ty::GenericArg<'tcx>],
                                param: &ty::GenericParamDef, infer_args: bool)
                                -> ty::GenericArg<'tcx> {
                                let tcx = self.lowerer.tcx();
                                if let Err(incorrect) = self.incorrect_args {
                                    if incorrect.invalid_args.contains(&(param.index as usize))
                                        {
                                        return param.to_error(tcx);
                                    }
                                }
                                match param.kind {
                                    GenericParamDefKind::Lifetime => {
                                        self.lowerer.re_infer(self.span,
                                                RegionInferReason::Param(param)).into()
                                    }
                                    GenericParamDefKind::Type { has_default, synthetic } => {
                                        if !infer_args && has_default {
                                            if let Some(prev) =
                                                    preceding_args.iter().find_map(|arg|
                                                            match arg.kind() {
                                                                GenericArgKind::Type(ty) => ty.error_reported().err(),
                                                                _ => None,
                                                            }) {
                                                return Ty::new_error(tcx, prev).into();
                                            }
                                            tcx.at(self.span).type_of(param.def_id).instantiate(tcx,
                                                        preceding_args).skip_norm_wip().into()
                                        } else if self.create_synth_args && synthetic {
                                            Ty::new_param(tcx, param.index, param.name).into()
                                        } else if infer_args {
                                            self.lowerer.ty_infer(Some(param), self.span).into()
                                        } else { Ty::new_misc_error(tcx).into() }
                                    }
                                    GenericParamDefKind::Const { has_default, .. } => {
                                        let ty =
                                            tcx.at(self.span).type_of(param.def_id).instantiate(tcx,
                                                    preceding_args).skip_norm_wip();
                                        if let Err(guar) = ty.error_reported() {
                                            return ty::Const::new_error(tcx, guar).into();
                                        }
                                        if !infer_args && has_default {
                                            tcx.const_param_default(param.def_id).instantiate(tcx,
                                                        preceding_args).skip_norm_wip().into()
                                        } else if infer_args {
                                            self.lowerer.ct_infer(Some(param), self.span).into()
                                        } else { ty::Const::new_misc_error(tcx).into() }
                                    }
                                }
                            }
                        }
                        let mut args_ctx =
                            GenericArgsCtxt {
                                lowerer: self,
                                def_id,
                                span,
                                generic_args: segment.args(),
                                infer_args: segment.infer_args,
                                create_synth_args: segment.delegation_child_segment,
                                incorrect_args: &arg_count.correct,
                            };
                        let args =
                            lower_generic_args(self, def_id, parent_args,
                                self_ty.is_some(), self_ty, &arg_count, &mut args_ctx);
                        (args, arg_count)
                    }
                })();
{
    use ::tracing::__macro_support::Callsite as _;
    static __CALLSITE: ::tracing::callsite::DefaultCallsite =
        {
            static META: ::tracing::Metadata<'static> =
                {
                    ::tracing_core::metadata::Metadata::new("event /rustc-dev/a36d05efab632d1ddf902b6a5c33b6d5d3b64131/compiler/rustc_hir_analysis/src/hir_ty_lowering/mod.rs:675",
                        "rustc_hir_analysis::hir_ty_lowering",
                        ::tracing::Level::DEBUG,
                        ::tracing_core::__macro_support::Option::Some("/rustc-dev/a36d05efab632d1ddf902b6a5c33b6d5d3b64131/compiler/rustc_hir_analysis/src/hir_ty_lowering/mod.rs"),
                        ::tracing_core::__macro_support::Option::Some(675u32),
                        ::tracing_core::__macro_support::Option::Some("rustc_hir_analysis::hir_ty_lowering"),
                        ::tracing_core::field::FieldSet::new(&[{
                                            const NAME:
                                                ::tracing::__macro_support::FieldName<{
                                                    ::tracing::__macro_support::FieldName::len("return")
                                                }> =
                                                ::tracing::__macro_support::FieldName::new("return");
                                            NAME.as_str()
                                        }], ::tracing_core::callsite::Identifier(&__CALLSITE)),
                        ::tracing::metadata::Kind::EVENT)
                };
            ::tracing::callsite::DefaultCallsite::new(&META)
        };
    let enabled =
        ::tracing::Level::DEBUG <= ::tracing::level_filters::STATIC_MAX_LEVEL
                &&
                ::tracing::Level::DEBUG <=
                    ::tracing::level_filters::LevelFilter::current() &&
            {
                let interest = __CALLSITE.interest();
                !interest.is_never() &&
                    ::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
                        interest)
            };
    if enabled {
        (|value_set: ::tracing::field::ValueSet|
                    {
                        let meta = __CALLSITE.metadata();
                        ::tracing::Event::dispatch(meta, &value_set);
                        ;
                    })({
                #[allow(unused_imports)]
                use ::tracing::field::{debug, display, Value};
                __CALLSITE.metadata().fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&x)
                                            as &dyn ::tracing::field::Value))])
            });
    } else { ; }
};
x;#[instrument(level = "debug", skip(self, span), ret)]
676    pub(crate) fn lower_generic_args_of_path(
677        &self,
678        span: Span,
679        def_id: DefId,
680        parent_args: &[ty::GenericArg<'tcx>],
681        segment: &hir::PathSegment<'_>,
682        self_ty: Option<Ty<'tcx>>,
683    ) -> (GenericArgsRef<'tcx>, GenericArgCountResult) {
684        // If the type is parameterized by this region, then replace this
685        // region with the current anon region binding (in other words,
686        // whatever & would get replaced with).
687
688        let tcx = self.tcx();
689        let generics = tcx.generics_of(def_id);
690        debug!(?generics);
691
692        if generics.has_self {
693            if generics.parent.is_some() {
694                // The parent is a trait so it should have at least one
695                // generic parameter for the `Self` type.
696                assert!(!parent_args.is_empty())
697            } else {
698                // This item (presumably a trait) needs a self-type.
699                assert!(self_ty.is_some());
700            }
701        } else {
702            assert!(self_ty.is_none());
703        }
704
705        let arg_count = check_generic_arg_count(
706            self,
707            def_id,
708            segment,
709            generics,
710            GenericArgPosition::Type,
711            self_ty.is_some(),
712        );
713
714        // Skip processing if type has no generic parameters.
715        // Traits always have `Self` as a generic parameter, which means they will not return early
716        // here and so associated item constraints will be handled regardless of whether there are
717        // any non-`Self` generic parameters.
718        if generics.is_own_empty() {
719            return (tcx.mk_args(parent_args), arg_count);
720        }
721
722        struct GenericArgsCtxt<'a, 'tcx> {
723            lowerer: &'a dyn HirTyLowerer<'tcx>,
724            def_id: DefId,
725            generic_args: &'a GenericArgs<'a>,
726            span: Span,
727            infer_args: bool,
728            create_synth_args: bool,
729            incorrect_args: &'a Result<(), GenericArgCountMismatch>,
730        }
731
732        impl<'a, 'tcx> GenericArgsLowerer<'a, 'tcx> for GenericArgsCtxt<'a, 'tcx> {
733            fn args_for_def_id(&mut self, did: DefId) -> (Option<&'a GenericArgs<'a>>, bool) {
734                if did == self.def_id {
735                    (Some(self.generic_args), self.infer_args)
736                } else {
737                    // The last component of this tuple is unimportant.
738                    (None, false)
739                }
740            }
741
742            fn provided_kind(
743                &mut self,
744                preceding_args: &[ty::GenericArg<'tcx>],
745                param: &ty::GenericParamDef,
746                arg: &GenericArg<'_>,
747            ) -> ty::GenericArg<'tcx> {
748                let tcx = self.lowerer.tcx();
749
750                if let Err(incorrect) = self.incorrect_args {
751                    if incorrect.invalid_args.contains(&(param.index as usize)) {
752                        return param.to_error(tcx);
753                    }
754                }
755
756                let handle_ty_args = |has_default, ty: &hir::Ty<'_>| {
757                    if has_default {
758                        tcx.check_optional_stability(
759                            param.def_id,
760                            Some(arg.hir_id()),
761                            arg.span(),
762                            None,
763                            AllowUnstable::No,
764                            |_, _| {
765                                // Default generic parameters may not be marked
766                                // with stability attributes, i.e. when the
767                                // default parameter was defined at the same time
768                                // as the rest of the type. As such, we ignore missing
769                                // stability attributes.
770                            },
771                        );
772                    }
773                    self.lowerer.lower_ty(ty).into()
774                };
775
776                match (&param.kind, arg) {
777                    (GenericParamDefKind::Lifetime, GenericArg::Lifetime(lt)) => {
778                        self.lowerer.lower_lifetime(lt, RegionInferReason::Param(param)).into()
779                    }
780                    (&GenericParamDefKind::Type { has_default, .. }, GenericArg::Type(ty)) => {
781                        // We handle the other parts of `Ty` in the match arm below
782                        handle_ty_args(has_default, ty.as_unambig_ty())
783                    }
784                    (&GenericParamDefKind::Type { has_default, .. }, GenericArg::Infer(inf)) => {
785                        handle_ty_args(has_default, &inf.to_ty())
786                    }
787                    (GenericParamDefKind::Const { .. }, GenericArg::Const(ct)) => self
788                        .lowerer
789                        // Ambig portions of `ConstArg` are handled in the match arm below
790                        .lower_const_arg(
791                            ct.as_unambig_ct(),
792                            tcx.type_of(param.def_id)
793                                .instantiate(tcx, preceding_args)
794                                .skip_norm_wip(),
795                        )
796                        .into(),
797                    (&GenericParamDefKind::Const { .. }, GenericArg::Infer(inf)) => {
798                        self.lowerer.ct_infer(Some(param), inf.span).into()
799                    }
800                    (kind, arg) => span_bug!(
801                        self.span,
802                        "mismatched path argument for kind {kind:?}: found arg {arg:?}"
803                    ),
804                }
805            }
806
807            fn inferred_kind(
808                &mut self,
809                preceding_args: &[ty::GenericArg<'tcx>],
810                param: &ty::GenericParamDef,
811                infer_args: bool,
812            ) -> ty::GenericArg<'tcx> {
813                let tcx = self.lowerer.tcx();
814
815                if let Err(incorrect) = self.incorrect_args {
816                    if incorrect.invalid_args.contains(&(param.index as usize)) {
817                        return param.to_error(tcx);
818                    }
819                }
820                match param.kind {
821                    GenericParamDefKind::Lifetime => {
822                        self.lowerer.re_infer(self.span, RegionInferReason::Param(param)).into()
823                    }
824                    GenericParamDefKind::Type { has_default, synthetic } => {
825                        if !infer_args && has_default {
826                            // No type parameter provided, but a default exists.
827                            if let Some(prev) =
828                                preceding_args.iter().find_map(|arg| match arg.kind() {
829                                    GenericArgKind::Type(ty) => ty.error_reported().err(),
830                                    _ => None,
831                                })
832                            {
833                                // Avoid ICE #86756 when type error recovery goes awry.
834                                return Ty::new_error(tcx, prev).into();
835                            }
836                            tcx.at(self.span)
837                                .type_of(param.def_id)
838                                .instantiate(tcx, preceding_args)
839                                .skip_norm_wip()
840                                .into()
841                        } else if self.create_synth_args && synthetic {
842                            Ty::new_param(tcx, param.index, param.name).into()
843                        } else if infer_args {
844                            self.lowerer.ty_infer(Some(param), self.span).into()
845                        } else {
846                            // We've already errored above about the mismatch.
847                            Ty::new_misc_error(tcx).into()
848                        }
849                    }
850                    GenericParamDefKind::Const { has_default, .. } => {
851                        let ty = tcx
852                            .at(self.span)
853                            .type_of(param.def_id)
854                            .instantiate(tcx, preceding_args)
855                            .skip_norm_wip();
856                        if let Err(guar) = ty.error_reported() {
857                            return ty::Const::new_error(tcx, guar).into();
858                        }
859                        if !infer_args && has_default {
860                            tcx.const_param_default(param.def_id)
861                                .instantiate(tcx, preceding_args)
862                                .skip_norm_wip()
863                                .into()
864                        } else if infer_args {
865                            self.lowerer.ct_infer(Some(param), self.span).into()
866                        } else {
867                            // We've already errored above about the mismatch.
868                            ty::Const::new_misc_error(tcx).into()
869                        }
870                    }
871                }
872            }
873        }
874
875        let mut args_ctx = GenericArgsCtxt {
876            lowerer: self,
877            def_id,
878            span,
879            generic_args: segment.args(),
880            infer_args: segment.infer_args,
881            create_synth_args: segment.delegation_child_segment,
882            incorrect_args: &arg_count.correct,
883        };
884
885        let args = lower_generic_args(
886            self,
887            def_id,
888            parent_args,
889            self_ty.is_some(),
890            self_ty,
891            &arg_count,
892            &mut args_ctx,
893        );
894
895        (args, arg_count)
896    }
897
898    {}
#[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("lower_generic_args_of_assoc_item",
                                    "rustc_hir_analysis::hir_ty_lowering",
                                    ::tracing::Level::DEBUG,
                                    ::tracing_core::__macro_support::Option::Some("/rustc-dev/a36d05efab632d1ddf902b6a5c33b6d5d3b64131/compiler/rustc_hir_analysis/src/hir_ty_lowering/mod.rs"),
                                    ::tracing_core::__macro_support::Option::Some(898u32),
                                    ::tracing_core::__macro_support::Option::Some("rustc_hir_analysis::hir_ty_lowering"),
                                    ::tracing_core::field::FieldSet::new(&[{
                                                        const NAME:
                                                            ::tracing::__macro_support::FieldName<{
                                                                ::tracing::__macro_support::FieldName::len("span")
                                                            }> =
                                                            ::tracing::__macro_support::FieldName::new("span");
                                                        NAME.as_str()
                                                    },
                                                    {
                                                        const NAME:
                                                            ::tracing::__macro_support::FieldName<{
                                                                ::tracing::__macro_support::FieldName::len("item_def_id")
                                                            }> =
                                                            ::tracing::__macro_support::FieldName::new("item_def_id");
                                                        NAME.as_str()
                                                    },
                                                    {
                                                        const NAME:
                                                            ::tracing::__macro_support::FieldName<{
                                                                ::tracing::__macro_support::FieldName::len("item_segment")
                                                            }> =
                                                            ::tracing::__macro_support::FieldName::new("item_segment");
                                                        NAME.as_str()
                                                    },
                                                    {
                                                        const NAME:
                                                            ::tracing::__macro_support::FieldName<{
                                                                ::tracing::__macro_support::FieldName::len("parent_args")
                                                            }> =
                                                            ::tracing::__macro_support::FieldName::new("parent_args");
                                                        NAME.as_str()
                                                    }], ::tracing_core::callsite::Identifier(&__CALLSITE)),
                                    ::tracing::metadata::Kind::SPAN)
                            };
                        ::tracing::callsite::DefaultCallsite::new(&META)
                    };
                let mut interest = ::tracing::subscriber::Interest::never();
                if ::tracing::Level::DEBUG <=
                                    ::tracing::level_filters::STATIC_MAX_LEVEL &&
                                ::tracing::Level::DEBUG <=
                                    ::tracing::level_filters::LevelFilter::current() &&
                            { interest = __CALLSITE.interest(); !interest.is_never() }
                        &&
                        ::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
                            interest) {
                    let meta = __CALLSITE.metadata();
                    ::tracing::Span::new(meta,
                        &{
                                #[allow(unused_imports)]
                                use ::tracing::field::{debug, display, Value};
                                meta.fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&span)
                                                            as &dyn ::tracing::field::Value)),
                                                (::tracing::__macro_support::Option::Some(&::tracing::field::debug(&item_def_id)
                                                            as &dyn ::tracing::field::Value)),
                                                (::tracing::__macro_support::Option::Some(&::tracing::field::debug(&item_segment)
                                                            as &dyn ::tracing::field::Value)),
                                                (::tracing::__macro_support::Option::Some(&::tracing::field::debug(&parent_args)
                                                            as &dyn ::tracing::field::Value))])
                            })
                } else {
                    let span =
                        ::tracing::__macro_support::__disabled_span(__CALLSITE.metadata());
                    {};
                    span
                }
            };
        __tracing_attr_guard = __tracing_attr_span.enter();
    }

    #[warn(clippy :: suspicious_else_formatting)]
    {

        #[allow(unknown_lints, unreachable_code, clippy ::
        diverging_sub_expression, clippy :: empty_loop, clippy ::
        let_unit_value, clippy :: let_with_type_underscore, clippy ::
        needless_return, clippy :: unreachable)]
        if false {
            let __tracing_attr_fake_return: GenericArgsRef<'tcx> = loop {};
            return __tracing_attr_fake_return;
        }
        {
            let (args, _) =
                self.lower_generic_args_of_path(span, item_def_id,
                    parent_args, item_segment, None);
            if let Some(c) = item_segment.args().constraints.first() {
                prohibit_assoc_item_constraint(self, c,
                    Some((item_def_id, item_segment, span)));
            }
            args
        }
    }
}#[instrument(level = "debug", skip(self))]
899    pub fn lower_generic_args_of_assoc_item(
900        &self,
901        span: Span,
902        item_def_id: DefId,
903        item_segment: &hir::PathSegment<'_>,
904        parent_args: GenericArgsRef<'tcx>,
905    ) -> GenericArgsRef<'tcx> {
906        let (args, _) =
907            self.lower_generic_args_of_path(span, item_def_id, parent_args, item_segment, None);
908        if let Some(c) = item_segment.args().constraints.first() {
909            prohibit_assoc_item_constraint(self, c, Some((item_def_id, item_segment, span)));
910        }
911        args
912    }
913
914    /// Lower a trait reference as found in an impl header as the implementee.
915    ///
916    /// The self type `self_ty` is the implementer of the trait.
917    pub fn lower_impl_trait_ref(
918        &self,
919        trait_ref: &hir::TraitRef<'tcx>,
920        self_ty: Ty<'tcx>,
921    ) -> ty::TraitRef<'tcx> {
922        let [leading_segments @ .., segment] = trait_ref.path.segments else { ::rustc_middle::util::bug::bug_fmt(format_args!("impossible case reached"))bug!() };
923
924        let _ = self.prohibit_generic_args(leading_segments.iter(), GenericsArgsErrExtend::None);
925
926        self.lower_mono_trait_ref(
927            trait_ref.path.span,
928            trait_ref.trait_def_id().unwrap_or_else(|| FatalError.raise()),
929            self_ty,
930            segment,
931            true,
932        )
933    }
934
935    /// Lower a polymorphic trait reference given a self type into `bounds`.
936    ///
937    /// *Polymorphic* in the sense that it may bind late-bound vars.
938    ///
939    /// This may generate auxiliary bounds iff the trait reference contains associated item constraints.
940    ///
941    /// ### Example
942    ///
943    /// Given the trait ref `Iterator<Item = u32>` and the self type `Ty`, this will add the
944    ///
945    /// 1. *trait predicate* `<Ty as Iterator>` (known as `Ty: Iterator` in the surface syntax) and the
946    /// 2. *projection predicate* `<Ty as Iterator>::Item = u32`
947    ///
948    /// to `bounds`.
949    ///
950    /// ### A Note on Binders
951    ///
952    /// Against our usual convention, there is an implied binder around the `self_ty` and the
953    /// `trait_ref` here. So they may reference late-bound vars.
954    ///
955    /// If for example you had `for<'a> Foo<'a>: Bar<'a>`, then the `self_ty` would be `Foo<'a>`
956    /// where `'a` is a bound region at depth 0. Similarly, the `trait_ref` would be `Bar<'a>`.
957    /// The lowered poly-trait-ref will track this binder explicitly, however.
958    {}
#[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("lower_poly_trait_ref",
                                    "rustc_hir_analysis::hir_ty_lowering",
                                    ::tracing::Level::DEBUG,
                                    ::tracing_core::__macro_support::Option::Some("/rustc-dev/a36d05efab632d1ddf902b6a5c33b6d5d3b64131/compiler/rustc_hir_analysis/src/hir_ty_lowering/mod.rs"),
                                    ::tracing_core::__macro_support::Option::Some(958u32),
                                    ::tracing_core::__macro_support::Option::Some("rustc_hir_analysis::hir_ty_lowering"),
                                    ::tracing_core::field::FieldSet::new(&[{
                                                        const NAME:
                                                            ::tracing::__macro_support::FieldName<{
                                                                ::tracing::__macro_support::FieldName::len("bound_generic_params")
                                                            }> =
                                                            ::tracing::__macro_support::FieldName::new("bound_generic_params");
                                                        NAME.as_str()
                                                    },
                                                    {
                                                        const NAME:
                                                            ::tracing::__macro_support::FieldName<{
                                                                ::tracing::__macro_support::FieldName::len("constness")
                                                            }> =
                                                            ::tracing::__macro_support::FieldName::new("constness");
                                                        NAME.as_str()
                                                    },
                                                    {
                                                        const NAME:
                                                            ::tracing::__macro_support::FieldName<{
                                                                ::tracing::__macro_support::FieldName::len("polarity")
                                                            }> =
                                                            ::tracing::__macro_support::FieldName::new("polarity");
                                                        NAME.as_str()
                                                    },
                                                    {
                                                        const NAME:
                                                            ::tracing::__macro_support::FieldName<{
                                                                ::tracing::__macro_support::FieldName::len("trait_ref")
                                                            }> =
                                                            ::tracing::__macro_support::FieldName::new("trait_ref");
                                                        NAME.as_str()
                                                    },
                                                    {
                                                        const NAME:
                                                            ::tracing::__macro_support::FieldName<{
                                                                ::tracing::__macro_support::FieldName::len("span")
                                                            }> =
                                                            ::tracing::__macro_support::FieldName::new("span");
                                                        NAME.as_str()
                                                    },
                                                    {
                                                        const NAME:
                                                            ::tracing::__macro_support::FieldName<{
                                                                ::tracing::__macro_support::FieldName::len("self_ty")
                                                            }> =
                                                            ::tracing::__macro_support::FieldName::new("self_ty");
                                                        NAME.as_str()
                                                    },
                                                    {
                                                        const NAME:
                                                            ::tracing::__macro_support::FieldName<{
                                                                ::tracing::__macro_support::FieldName::len("predicate_filter")
                                                            }> =
                                                            ::tracing::__macro_support::FieldName::new("predicate_filter");
                                                        NAME.as_str()
                                                    },
                                                    {
                                                        const NAME:
                                                            ::tracing::__macro_support::FieldName<{
                                                                ::tracing::__macro_support::FieldName::len("overlapping_assoc_item_constraints")
                                                            }> =
                                                            ::tracing::__macro_support::FieldName::new("overlapping_assoc_item_constraints");
                                                        NAME.as_str()
                                                    }], ::tracing_core::callsite::Identifier(&__CALLSITE)),
                                    ::tracing::metadata::Kind::SPAN)
                            };
                        ::tracing::callsite::DefaultCallsite::new(&META)
                    };
                let mut interest = ::tracing::subscriber::Interest::never();
                if ::tracing::Level::DEBUG <=
                                    ::tracing::level_filters::STATIC_MAX_LEVEL &&
                                ::tracing::Level::DEBUG <=
                                    ::tracing::level_filters::LevelFilter::current() &&
                            { interest = __CALLSITE.interest(); !interest.is_never() }
                        &&
                        ::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
                            interest) {
                    let meta = __CALLSITE.metadata();
                    ::tracing::Span::new(meta,
                        &{
                                #[allow(unused_imports)]
                                use ::tracing::field::{debug, display, Value};
                                meta.fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&bound_generic_params)
                                                            as &dyn ::tracing::field::Value)),
                                                (::tracing::__macro_support::Option::Some(&::tracing::field::debug(&constness)
                                                            as &dyn ::tracing::field::Value)),
                                                (::tracing::__macro_support::Option::Some(&::tracing::field::debug(&polarity)
                                                            as &dyn ::tracing::field::Value)),
                                                (::tracing::__macro_support::Option::Some(&::tracing::field::debug(&trait_ref)
                                                            as &dyn ::tracing::field::Value)),
                                                (::tracing::__macro_support::Option::Some(&::tracing::field::debug(&span)
                                                            as &dyn ::tracing::field::Value)),
                                                (::tracing::__macro_support::Option::Some(&::tracing::field::debug(&self_ty)
                                                            as &dyn ::tracing::field::Value)),
                                                (::tracing::__macro_support::Option::Some(&::tracing::field::debug(&predicate_filter)
                                                            as &dyn ::tracing::field::Value)),
                                                (::tracing::__macro_support::Option::Some(&::tracing::field::debug(&overlapping_assoc_item_constraints)
                                                            as &dyn ::tracing::field::Value))])
                            })
                } else {
                    let span =
                        ::tracing::__macro_support::__disabled_span(__CALLSITE.metadata());
                    {};
                    span
                }
            };
        __tracing_attr_guard = __tracing_attr_span.enter();
    }

    #[warn(clippy :: suspicious_else_formatting)]
    {

        #[allow(unknown_lints, unreachable_code, clippy ::
        diverging_sub_expression, clippy :: empty_loop, clippy ::
        let_unit_value, clippy :: let_with_type_underscore, clippy ::
        needless_return, clippy :: unreachable)]
        if false {
            let __tracing_attr_fake_return: GenericArgCountResult = loop {};
            return __tracing_attr_fake_return;
        }
        {
            let tcx = self.tcx();
            let _ = bound_generic_params;
            let trait_def_id =
                trait_ref.trait_def_id().unwrap_or_else(||
                        FatalError.raise());
            let transient =
                match polarity {
                    hir::BoundPolarity::Positive => {
                        tcx.is_lang_item(trait_def_id, LangItem::PointeeSized)
                    }
                    hir::BoundPolarity::Negative(_) => false,
                    hir::BoundPolarity::Maybe(_) => {
                        self.require_bound_to_relax_default_trait(trait_ref, span);
                        true
                    }
                };
            let bounds = if transient { &mut Vec::new() } else { bounds };
            let polarity =
                match polarity {
                    hir::BoundPolarity::Positive | hir::BoundPolarity::Maybe(_)
                        => {
                        ty::ClausePolarity::Positive
                    }
                    hir::BoundPolarity::Negative(_) =>
                        ty::ClausePolarity::Negative,
                };
            let [leading_segments @ .., segment] =
                trait_ref.path.segments else {
                    ::rustc_middle::util::bug::bug_fmt(format_args!("impossible case reached"))
                };
            let _ =
                self.prohibit_generic_args(leading_segments.iter(),
                    GenericsArgsErrExtend::None);
            self.report_internal_fn_trait(span, trait_def_id, segment, false);
            let (generic_args, arg_count) =
                self.lower_generic_args_of_path(trait_ref.path.span,
                    trait_def_id, &[], segment, Some(self_ty));
            let constraints = segment.args().constraints;
            if transient &&
                    (!generic_args[1..].is_empty() || !constraints.is_empty()) {
                self.dcx().span_delayed_bug(span,
                    "transient bound should not have args or constraints");
            }
            let bound_vars = tcx.late_bound_vars(trait_ref.hir_ref_id);
            {
                use ::tracing::__macro_support::Callsite as _;
                static __CALLSITE: ::tracing::callsite::DefaultCallsite =
                    {
                        static META: ::tracing::Metadata<'static> =
                            {
                                ::tracing_core::metadata::Metadata::new("event /rustc-dev/a36d05efab632d1ddf902b6a5c33b6d5d3b64131/compiler/rustc_hir_analysis/src/hir_ty_lowering/mod.rs:1038",
                                    "rustc_hir_analysis::hir_ty_lowering",
                                    ::tracing::Level::DEBUG,
                                    ::tracing_core::__macro_support::Option::Some("/rustc-dev/a36d05efab632d1ddf902b6a5c33b6d5d3b64131/compiler/rustc_hir_analysis/src/hir_ty_lowering/mod.rs"),
                                    ::tracing_core::__macro_support::Option::Some(1038u32),
                                    ::tracing_core::__macro_support::Option::Some("rustc_hir_analysis::hir_ty_lowering"),
                                    ::tracing_core::field::FieldSet::new(&[{
                                                        const NAME:
                                                            ::tracing::__macro_support::FieldName<{
                                                                ::tracing::__macro_support::FieldName::len("bound_vars")
                                                            }> =
                                                            ::tracing::__macro_support::FieldName::new("bound_vars");
                                                        NAME.as_str()
                                                    }], ::tracing_core::callsite::Identifier(&__CALLSITE)),
                                    ::tracing::metadata::Kind::EVENT)
                            };
                        ::tracing::callsite::DefaultCallsite::new(&META)
                    };
                let enabled =
                    ::tracing::Level::DEBUG <=
                                ::tracing::level_filters::STATIC_MAX_LEVEL &&
                            ::tracing::Level::DEBUG <=
                                ::tracing::level_filters::LevelFilter::current() &&
                        {
                            let interest = __CALLSITE.interest();
                            !interest.is_never() &&
                                ::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
                                    interest)
                        };
                if enabled {
                    (|value_set: ::tracing::field::ValueSet|
                                {
                                    let meta = __CALLSITE.metadata();
                                    ::tracing::Event::dispatch(meta, &value_set);
                                    ;
                                })({
                            #[allow(unused_imports)]
                            use ::tracing::field::{debug, display, Value};
                            __CALLSITE.metadata().fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&bound_vars)
                                                        as &dyn ::tracing::field::Value))])
                        });
                } else { ; }
            };
            let poly_trait_ref =
                ty::Binder::bind_with_vars(ty::TraitRef::new_from_args(tcx,
                        trait_def_id, generic_args), bound_vars);
            {
                use ::tracing::__macro_support::Callsite as _;
                static __CALLSITE: ::tracing::callsite::DefaultCallsite =
                    {
                        static META: ::tracing::Metadata<'static> =
                            {
                                ::tracing_core::metadata::Metadata::new("event /rustc-dev/a36d05efab632d1ddf902b6a5c33b6d5d3b64131/compiler/rustc_hir_analysis/src/hir_ty_lowering/mod.rs:1045",
                                    "rustc_hir_analysis::hir_ty_lowering",
                                    ::tracing::Level::DEBUG,
                                    ::tracing_core::__macro_support::Option::Some("/rustc-dev/a36d05efab632d1ddf902b6a5c33b6d5d3b64131/compiler/rustc_hir_analysis/src/hir_ty_lowering/mod.rs"),
                                    ::tracing_core::__macro_support::Option::Some(1045u32),
                                    ::tracing_core::__macro_support::Option::Some("rustc_hir_analysis::hir_ty_lowering"),
                                    ::tracing_core::field::FieldSet::new(&[{
                                                        const NAME:
                                                            ::tracing::__macro_support::FieldName<{
                                                                ::tracing::__macro_support::FieldName::len("poly_trait_ref")
                                                            }> =
                                                            ::tracing::__macro_support::FieldName::new("poly_trait_ref");
                                                        NAME.as_str()
                                                    }], ::tracing_core::callsite::Identifier(&__CALLSITE)),
                                    ::tracing::metadata::Kind::EVENT)
                            };
                        ::tracing::callsite::DefaultCallsite::new(&META)
                    };
                let enabled =
                    ::tracing::Level::DEBUG <=
                                ::tracing::level_filters::STATIC_MAX_LEVEL &&
                            ::tracing::Level::DEBUG <=
                                ::tracing::level_filters::LevelFilter::current() &&
                        {
                            let interest = __CALLSITE.interest();
                            !interest.is_never() &&
                                ::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
                                    interest)
                        };
                if enabled {
                    (|value_set: ::tracing::field::ValueSet|
                                {
                                    let meta = __CALLSITE.metadata();
                                    ::tracing::Event::dispatch(meta, &value_set);
                                    ;
                                })({
                            #[allow(unused_imports)]
                            use ::tracing::field::{debug, display, Value};
                            __CALLSITE.metadata().fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&poly_trait_ref)
                                                        as &dyn ::tracing::field::Value))])
                        });
                } else { ; }
            };
            match predicate_filter {
                PredicateFilter::All | PredicateFilter::SelfOnly |
                    PredicateFilter::SelfTraitThatDefines(..) |
                    PredicateFilter::SelfAndAssociatedTypeBounds => {
                    let bound =
                        poly_trait_ref.map_bound(|trait_ref|
                                {
                                    ty::ClauseKind::Trait(ty::TraitClause {
                                            trait_ref,
                                            polarity,
                                        })
                                });
                    let bound = (bound.upcast(tcx), span);
                    if tcx.is_lang_item(trait_def_id, LangItem::Sized) {
                        bounds.insert(0, bound);
                    } else { bounds.push(bound); }
                }
                PredicateFilter::ConstIfConst |
                    PredicateFilter::SelfConstIfConst => {}
            }
            if let hir::BoundConstness::Always(span) |
                        hir::BoundConstness::Maybe(span) = constness &&
                    !tcx.is_const_trait(trait_def_id) {
                let (def_span, suggestion, suggestion_pre) =
                    match (trait_def_id.as_local(), tcx.sess.is_nightly_build())
                        {
                        (Some(trait_def_id), true) => {
                            let span = tcx.hir_expect_item(trait_def_id).vis_span;
                            let span =
                                tcx.sess.source_map().span_extend_while_whitespace(span);
                            (None, Some(span.shrink_to_hi()),
                                if self.tcx().features().const_trait_impl() {
                                    ""
                                } else {
                                    "enable `#![feature(const_trait_impl)]` in your crate and "
                                })
                        }
                        (None, _) | (_, false) =>
                            (Some(tcx.def_span(trait_def_id)), None, ""),
                    };
                self.dcx().emit_err(crate::diagnostics::ConstBoundForNonConstTrait {
                        span,
                        modifier: constness.as_str(),
                        def_span,
                        trait_name: tcx.def_path_str(trait_def_id),
                        suggestion,
                        suggestion_pre,
                    });
            } else {
                match predicate_filter {
                    PredicateFilter::SelfTraitThatDefines(..) => {}
                    PredicateFilter::All | PredicateFilter::SelfOnly |
                        PredicateFilter::SelfAndAssociatedTypeBounds => {
                        match constness {
                            hir::BoundConstness::Always(_) => {
                                if polarity == ty::ClausePolarity::Positive {
                                    bounds.push((poly_trait_ref.to_host_effect_clause(tcx,
                                                ty::BoundConstness::Const), span));
                                }
                            }
                            hir::BoundConstness::Maybe(_) => {}
                            hir::BoundConstness::Never => {}
                        }
                    }
                    PredicateFilter::ConstIfConst |
                        PredicateFilter::SelfConstIfConst => {
                        match constness {
                            hir::BoundConstness::Maybe(_) => {
                                if polarity == ty::ClausePolarity::Positive {
                                    bounds.push((poly_trait_ref.to_host_effect_clause(tcx,
                                                ty::BoundConstness::Maybe), span));
                                }
                            }
                            hir::BoundConstness::Always(_) | hir::BoundConstness::Never
                                => {}
                        }
                    }
                }
            }
            let mut dup_constraints =
                (overlapping_assoc_item_constraints ==
                            OverlappingAsssocItemConstraints::Forbidden).then_some(FxIndexMap::default());
            for constraint in constraints {
                if polarity == ty::ClausePolarity::Negative {
                    self.dcx().span_delayed_bug(constraint.span,
                        "negative trait bounds should not have assoc item constraints");
                    break;
                }
                let _: Result<_, ErrorGuaranteed> =
                    self.lower_assoc_item_constraint(trait_ref.hir_ref_id,
                        poly_trait_ref, constraint, bounds,
                        dup_constraints.as_mut(), constraint.span,
                        predicate_filter);
            }
            arg_count
        }
    }
}#[instrument(level = "debug", skip(self, bounds))]
959    pub(crate) fn lower_poly_trait_ref(
960        &self,
961        &hir::PolyTraitRef {
962            bound_generic_params,
963            modifiers: hir::TraitBoundModifiers { constness, polarity },
964            trait_ref,
965            span,
966        }: &hir::PolyTraitRef<'_>,
967        self_ty: Ty<'tcx>,
968        bounds: &mut Vec<(ty::Clause<'tcx>, Span)>,
969        predicate_filter: PredicateFilter,
970        overlapping_assoc_item_constraints: OverlappingAsssocItemConstraints,
971    ) -> GenericArgCountResult {
972        let tcx = self.tcx();
973
974        // We use the *resolved* bound vars later instead of the HIR ones since the former
975        // also include the bound vars of the overarching predicate if applicable.
976        let _ = bound_generic_params;
977
978        let trait_def_id = trait_ref.trait_def_id().unwrap_or_else(|| FatalError.raise());
979
980        // Relaxed bounds `?Trait` and `PointeeSized` bounds aren't represented in the middle::ty IR
981        // as they denote the *absence* of a default bound. However, we can't bail out early here since
982        // we still need to perform several validation steps (see below). Instead, simply "pour" all
983        // resulting bounds "down the drain", i.e., into a new `Vec` that just gets dropped at the end.
984        let transient = match polarity {
985            hir::BoundPolarity::Positive => {
986                // To elaborate on the comment directly above, regarding `PointeeSized` specifically,
987                // we don't "reify" such bounds to avoid trait system limitations -- namely,
988                // non-global where-clauses being preferred over item bounds (where `PointeeSized`
989                // bounds would be proven) -- which can result in errors when a `PointeeSized`
990                // supertrait / bound / predicate is added to some items.
991                tcx.is_lang_item(trait_def_id, LangItem::PointeeSized)
992            }
993            hir::BoundPolarity::Negative(_) => false,
994            hir::BoundPolarity::Maybe(_) => {
995                self.require_bound_to_relax_default_trait(trait_ref, span);
996                true
997            }
998        };
999        let bounds = if transient { &mut Vec::new() } else { bounds };
1000
1001        let polarity = match polarity {
1002            hir::BoundPolarity::Positive | hir::BoundPolarity::Maybe(_) => {
1003                ty::ClausePolarity::Positive
1004            }
1005            hir::BoundPolarity::Negative(_) => ty::ClausePolarity::Negative,
1006        };
1007
1008        let [leading_segments @ .., segment] = trait_ref.path.segments else { bug!() };
1009
1010        let _ = self.prohibit_generic_args(leading_segments.iter(), GenericsArgsErrExtend::None);
1011        self.report_internal_fn_trait(span, trait_def_id, segment, false);
1012
1013        let (generic_args, arg_count) = self.lower_generic_args_of_path(
1014            trait_ref.path.span,
1015            trait_def_id,
1016            &[],
1017            segment,
1018            Some(self_ty),
1019        );
1020
1021        let constraints = segment.args().constraints;
1022
1023        if transient && (!generic_args[1..].is_empty() || !constraints.is_empty()) {
1024            // Since the bound won't be present in the middle::ty IR as established above, any
1025            // arguments or constraints won't be checked for well-formedness in later passes.
1026            //
1027            // This is only an issue if the trait ref is otherwise valid which can only happen if
1028            // the corresponding default trait has generic parameters or associated items. Such a
1029            // trait would be degenerate. We delay a bug to detect and guard us against these.
1030            //
1031            // E.g: Given `/*default*/ trait Bound<'a: 'static, T, const N: usize> {}`,
1032            // `?Bound<Vec<str>, { panic!() }>` won't be wfchecked.
1033            self.dcx()
1034                .span_delayed_bug(span, "transient bound should not have args or constraints");
1035        }
1036
1037        let bound_vars = tcx.late_bound_vars(trait_ref.hir_ref_id);
1038        debug!(?bound_vars);
1039
1040        let poly_trait_ref = ty::Binder::bind_with_vars(
1041            ty::TraitRef::new_from_args(tcx, trait_def_id, generic_args),
1042            bound_vars,
1043        );
1044
1045        debug!(?poly_trait_ref);
1046
1047        // We deal with const conditions later.
1048        match predicate_filter {
1049            PredicateFilter::All
1050            | PredicateFilter::SelfOnly
1051            | PredicateFilter::SelfTraitThatDefines(..)
1052            | PredicateFilter::SelfAndAssociatedTypeBounds => {
1053                let bound = poly_trait_ref.map_bound(|trait_ref| {
1054                    ty::ClauseKind::Trait(ty::TraitClause { trait_ref, polarity })
1055                });
1056                let bound = (bound.upcast(tcx), span);
1057                // FIXME(-Znext-solver): We can likely remove this hack once the
1058                // new trait solver lands. This fixed an overflow in the old solver.
1059                // This may have performance implications, so please check perf when
1060                // removing it.
1061                // This was added in <https://github.com/rust-lang/rust/pull/123302>.
1062                if tcx.is_lang_item(trait_def_id, LangItem::Sized) {
1063                    bounds.insert(0, bound);
1064                } else {
1065                    bounds.push(bound);
1066                }
1067            }
1068            PredicateFilter::ConstIfConst | PredicateFilter::SelfConstIfConst => {}
1069        }
1070
1071        if let hir::BoundConstness::Always(span) | hir::BoundConstness::Maybe(span) = constness
1072            && !tcx.is_const_trait(trait_def_id)
1073        {
1074            let (def_span, suggestion, suggestion_pre) =
1075                match (trait_def_id.as_local(), tcx.sess.is_nightly_build()) {
1076                    (Some(trait_def_id), true) => {
1077                        let span = tcx.hir_expect_item(trait_def_id).vis_span;
1078                        let span = tcx.sess.source_map().span_extend_while_whitespace(span);
1079
1080                        (
1081                            None,
1082                            Some(span.shrink_to_hi()),
1083                            if self.tcx().features().const_trait_impl() {
1084                                ""
1085                            } else {
1086                                "enable `#![feature(const_trait_impl)]` in your crate and "
1087                            },
1088                        )
1089                    }
1090                    (None, _) | (_, false) => (Some(tcx.def_span(trait_def_id)), None, ""),
1091                };
1092            self.dcx().emit_err(crate::diagnostics::ConstBoundForNonConstTrait {
1093                span,
1094                modifier: constness.as_str(),
1095                def_span,
1096                trait_name: tcx.def_path_str(trait_def_id),
1097                suggestion,
1098                suggestion_pre,
1099            });
1100        } else {
1101            match predicate_filter {
1102                // This is only concerned with trait predicates.
1103                PredicateFilter::SelfTraitThatDefines(..) => {}
1104                PredicateFilter::All
1105                | PredicateFilter::SelfOnly
1106                | PredicateFilter::SelfAndAssociatedTypeBounds => {
1107                    match constness {
1108                        hir::BoundConstness::Always(_) => {
1109                            if polarity == ty::ClausePolarity::Positive {
1110                                bounds.push((
1111                                    poly_trait_ref
1112                                        .to_host_effect_clause(tcx, ty::BoundConstness::Const),
1113                                    span,
1114                                ));
1115                            }
1116                        }
1117                        hir::BoundConstness::Maybe(_) => {
1118                            // We don't emit a const bound here, since that would mean that we
1119                            // unconditionally need to prove a `HostEffect` predicate, even when
1120                            // the predicates are being instantiated in a non-const context. This
1121                            // is instead handled in the `const_conditions` query.
1122                        }
1123                        hir::BoundConstness::Never => {}
1124                    }
1125                }
1126                // On the flip side, when filtering `ConstIfConst` bounds, we only need to convert
1127                // `[const]` bounds. All other predicates are handled in their respective queries.
1128                //
1129                // Note that like `PredicateFilter::SelfOnly`, we don't need to do any filtering
1130                // here because we only call this on self bounds, and deal with the recursive case
1131                // in `lower_assoc_item_constraint`.
1132                PredicateFilter::ConstIfConst | PredicateFilter::SelfConstIfConst => {
1133                    match constness {
1134                        hir::BoundConstness::Maybe(_) => {
1135                            if polarity == ty::ClausePolarity::Positive {
1136                                bounds.push((
1137                                    poly_trait_ref
1138                                        .to_host_effect_clause(tcx, ty::BoundConstness::Maybe),
1139                                    span,
1140                                ));
1141                            }
1142                        }
1143                        hir::BoundConstness::Always(_) | hir::BoundConstness::Never => {}
1144                    }
1145                }
1146            }
1147        }
1148
1149        let mut dup_constraints = (overlapping_assoc_item_constraints
1150            == OverlappingAsssocItemConstraints::Forbidden)
1151            .then_some(FxIndexMap::default());
1152
1153        for constraint in constraints {
1154            // Don't register any associated item constraints for negative bounds,
1155            // since we should have emitted an error for them earlier, and they
1156            // would not be well-formed!
1157            if polarity == ty::ClausePolarity::Negative {
1158                self.dcx().span_delayed_bug(
1159                    constraint.span,
1160                    "negative trait bounds should not have assoc item constraints",
1161                );
1162                break;
1163            }
1164
1165            // Specify type to assert that error was already reported in `Err` case.
1166            let _: Result<_, ErrorGuaranteed> = self.lower_assoc_item_constraint(
1167                trait_ref.hir_ref_id,
1168                poly_trait_ref,
1169                constraint,
1170                bounds,
1171                dup_constraints.as_mut(),
1172                constraint.span,
1173                predicate_filter,
1174            );
1175            // Okay to ignore `Err` because of `ErrorGuaranteed` (see above).
1176        }
1177
1178        arg_count
1179    }
1180
1181    /// Lower a monomorphic trait reference given a self type while prohibiting associated item bindings.
1182    ///
1183    /// *Monomorphic* in the sense that it doesn't bind any late-bound vars.
1184    fn lower_mono_trait_ref(
1185        &self,
1186        span: Span,
1187        trait_def_id: DefId,
1188        self_ty: Ty<'tcx>,
1189        trait_segment: &hir::PathSegment<'_>,
1190        is_impl: bool,
1191    ) -> ty::TraitRef<'tcx> {
1192        self.report_internal_fn_trait(span, trait_def_id, trait_segment, is_impl);
1193
1194        let (generic_args, _) =
1195            self.lower_generic_args_of_path(span, trait_def_id, &[], trait_segment, Some(self_ty));
1196        if let Some(c) = trait_segment.args().constraints.first() {
1197            prohibit_assoc_item_constraint(self, c, Some((trait_def_id, trait_segment, span)));
1198        }
1199        ty::TraitRef::new_from_args(self.tcx(), trait_def_id, generic_args)
1200    }
1201
1202    fn probe_trait_that_defines_assoc_item(
1203        &self,
1204        trait_def_id: DefId,
1205        assoc_tag: ty::AssocTag,
1206        assoc_ident: Ident,
1207    ) -> bool {
1208        self.tcx()
1209            .associated_items(trait_def_id)
1210            .find_by_ident_and_kind(self.tcx(), assoc_ident, assoc_tag, trait_def_id)
1211            .is_some()
1212    }
1213
1214    fn lower_path_segment(
1215        &self,
1216        span: Span,
1217        def_id: DefId,
1218        item_segment: &hir::PathSegment<'_>,
1219    ) -> Ty<'tcx> {
1220        let tcx = self.tcx();
1221        let args = self.lower_generic_args_of_path_segment(span, def_id, item_segment);
1222
1223        if let DefKind::TyAlias = tcx.def_kind(def_id)
1224            && tcx.type_alias_is_checked(def_id)
1225        {
1226            // Type aliases defined in crates that have the
1227            // feature `checked_type_alias` enabled get encoded as a type alias that normalization will
1228            // then actually instantiate the where bounds of.
1229            let alias_ty = ty::AliasTy::new_from_args(tcx, ty::Free { def_id }, args);
1230            Ty::new_alias(tcx, ty::IsRigid::No, alias_ty)
1231        } else {
1232            tcx.at(span).type_of(def_id).instantiate(tcx, args).skip_norm_wip()
1233        }
1234    }
1235
1236    /// Search for a trait bound on a type parameter whose trait defines the associated item
1237    /// given by `assoc_ident` and `kind`.
1238    ///
1239    /// This fails if there is no such bound in the list of candidates or if there are multiple
1240    /// candidates in which case it reports ambiguity.
1241    ///
1242    /// `ty_param_def_id` is the `LocalDefId` of the type parameter.
1243    {}
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("probe_single_ty_param_bound_for_assoc_item",
                                "rustc_hir_analysis::hir_ty_lowering",
                                ::tracing::Level::DEBUG,
                                ::tracing_core::__macro_support::Option::Some("/rustc-dev/a36d05efab632d1ddf902b6a5c33b6d5d3b64131/compiler/rustc_hir_analysis/src/hir_ty_lowering/mod.rs"),
                                ::tracing_core::__macro_support::Option::Some(1243u32),
                                ::tracing_core::__macro_support::Option::Some("rustc_hir_analysis::hir_ty_lowering"),
                                ::tracing_core::field::FieldSet::new(&[],
                                    ::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,
                    &{ meta.fields().value_set_all(&[]) })
            } else {
                let span =
                    ::tracing::__macro_support::__disabled_span(__CALLSITE.metadata());
                {};
                span
            }
        };
    __tracing_attr_guard = __tracing_attr_span.enter();
}
#[allow(clippy :: redundant_closure_call)]
let x =
    (move ||
                {

                    #[allow(unknown_lints, unreachable_code, clippy ::
                    diverging_sub_expression, clippy :: empty_loop, clippy ::
                    let_unit_value, clippy :: let_with_type_underscore, clippy
                    :: needless_return, clippy :: unreachable)]
                    if false {
                        let __tracing_attr_fake_return:
                                Result<ty::PolyTraitRef<'tcx>, ErrorGuaranteed> = loop {};
                        return __tracing_attr_fake_return;
                    }
                    {
                        {
                            use ::tracing::__macro_support::Callsite as _;
                            static __CALLSITE: ::tracing::callsite::DefaultCallsite =
                                {
                                    static META: ::tracing::Metadata<'static> =
                                        {
                                            ::tracing_core::metadata::Metadata::new("event /rustc-dev/a36d05efab632d1ddf902b6a5c33b6d5d3b64131/compiler/rustc_hir_analysis/src/hir_ty_lowering/mod.rs:1252",
                                                "rustc_hir_analysis::hir_ty_lowering",
                                                ::tracing::Level::DEBUG,
                                                ::tracing_core::__macro_support::Option::Some("/rustc-dev/a36d05efab632d1ddf902b6a5c33b6d5d3b64131/compiler/rustc_hir_analysis/src/hir_ty_lowering/mod.rs"),
                                                ::tracing_core::__macro_support::Option::Some(1252u32),
                                                ::tracing_core::__macro_support::Option::Some("rustc_hir_analysis::hir_ty_lowering"),
                                                ::tracing_core::field::FieldSet::new(&[{
                                                                    const NAME:
                                                                        ::tracing::__macro_support::FieldName<{
                                                                            ::tracing::__macro_support::FieldName::len("ty_param_def_id")
                                                                        }> =
                                                                        ::tracing::__macro_support::FieldName::new("ty_param_def_id");
                                                                    NAME.as_str()
                                                                },
                                                                {
                                                                    const NAME:
                                                                        ::tracing::__macro_support::FieldName<{
                                                                            ::tracing::__macro_support::FieldName::len("assoc_ident")
                                                                        }> =
                                                                        ::tracing::__macro_support::FieldName::new("assoc_ident");
                                                                    NAME.as_str()
                                                                },
                                                                {
                                                                    const NAME:
                                                                        ::tracing::__macro_support::FieldName<{
                                                                            ::tracing::__macro_support::FieldName::len("span")
                                                                        }> =
                                                                        ::tracing::__macro_support::FieldName::new("span");
                                                                    NAME.as_str()
                                                                }], ::tracing_core::callsite::Identifier(&__CALLSITE)),
                                                ::tracing::metadata::Kind::EVENT)
                                        };
                                    ::tracing::callsite::DefaultCallsite::new(&META)
                                };
                            let enabled =
                                ::tracing::Level::DEBUG <=
                                            ::tracing::level_filters::STATIC_MAX_LEVEL &&
                                        ::tracing::Level::DEBUG <=
                                            ::tracing::level_filters::LevelFilter::current() &&
                                    {
                                        let interest = __CALLSITE.interest();
                                        !interest.is_never() &&
                                            ::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
                                                interest)
                                    };
                            if enabled {
                                (|value_set: ::tracing::field::ValueSet|
                                            {
                                                let meta = __CALLSITE.metadata();
                                                ::tracing::Event::dispatch(meta, &value_set);
                                                ;
                                            })({
                                        #[allow(unused_imports)]
                                        use ::tracing::field::{debug, display, Value};
                                        __CALLSITE.metadata().fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&ty_param_def_id)
                                                                    as &dyn ::tracing::field::Value)),
                                                        (::tracing::__macro_support::Option::Some(&::tracing::field::debug(&assoc_ident)
                                                                    as &dyn ::tracing::field::Value)),
                                                        (::tracing::__macro_support::Option::Some(&::tracing::field::debug(&span)
                                                                    as &dyn ::tracing::field::Value))])
                                    });
                            } else { ; }
                        };
                        let tcx = self.tcx();
                        let predicates =
                            &self.probe_ty_param_bounds(span, ty_param_def_id,
                                    assoc_ident);
                        {
                            use ::tracing::__macro_support::Callsite as _;
                            static __CALLSITE: ::tracing::callsite::DefaultCallsite =
                                {
                                    static META: ::tracing::Metadata<'static> =
                                        {
                                            ::tracing_core::metadata::Metadata::new("event /rustc-dev/a36d05efab632d1ddf902b6a5c33b6d5d3b64131/compiler/rustc_hir_analysis/src/hir_ty_lowering/mod.rs:1256",
                                                "rustc_hir_analysis::hir_ty_lowering",
                                                ::tracing::Level::DEBUG,
                                                ::tracing_core::__macro_support::Option::Some("/rustc-dev/a36d05efab632d1ddf902b6a5c33b6d5d3b64131/compiler/rustc_hir_analysis/src/hir_ty_lowering/mod.rs"),
                                                ::tracing_core::__macro_support::Option::Some(1256u32),
                                                ::tracing_core::__macro_support::Option::Some("rustc_hir_analysis::hir_ty_lowering"),
                                                ::tracing_core::field::FieldSet::new(&["message"],
                                                    ::tracing_core::callsite::Identifier(&__CALLSITE)),
                                                ::tracing::metadata::Kind::EVENT)
                                        };
                                    ::tracing::callsite::DefaultCallsite::new(&META)
                                };
                            let enabled =
                                ::tracing::Level::DEBUG <=
                                            ::tracing::level_filters::STATIC_MAX_LEVEL &&
                                        ::tracing::Level::DEBUG <=
                                            ::tracing::level_filters::LevelFilter::current() &&
                                    {
                                        let interest = __CALLSITE.interest();
                                        !interest.is_never() &&
                                            ::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
                                                interest)
                                    };
                            if enabled {
                                (|value_set: ::tracing::field::ValueSet|
                                            {
                                                let meta = __CALLSITE.metadata();
                                                ::tracing::Event::dispatch(meta, &value_set);
                                                ;
                                            })({
                                        #[allow(unused_imports)]
                                        use ::tracing::field::{debug, display, Value};
                                        __CALLSITE.metadata().fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&format_args!("predicates={0:#?}",
                                                                            predicates) as &dyn ::tracing::field::Value))])
                                    });
                            } else { ; }
                        };
                        self.probe_single_bound_for_assoc_item(||
                                {
                                    let trait_refs =
                                        predicates.iter_identity_copied().map(Unnormalized::skip_norm_wip).filter_map(|(p,
                                                    _)| Some(p.as_trait_clause()?.map_bound(|t| t.trait_ref)));
                                    traits::transitive_bounds_that_define_assoc_item(tcx,
                                        trait_refs, assoc_ident)
                                }, AssocItemQSelf::TyParam(ty_param_def_id, ty_param_span),
                            assoc_tag, assoc_ident, span, None)
                    }
                })();
{
    use ::tracing::__macro_support::Callsite as _;
    static __CALLSITE: ::tracing::callsite::DefaultCallsite =
        {
            static META: ::tracing::Metadata<'static> =
                {
                    ::tracing_core::metadata::Metadata::new("event /rustc-dev/a36d05efab632d1ddf902b6a5c33b6d5d3b64131/compiler/rustc_hir_analysis/src/hir_ty_lowering/mod.rs:1243",
                        "rustc_hir_analysis::hir_ty_lowering",
                        ::tracing::Level::DEBUG,
                        ::tracing_core::__macro_support::Option::Some("/rustc-dev/a36d05efab632d1ddf902b6a5c33b6d5d3b64131/compiler/rustc_hir_analysis/src/hir_ty_lowering/mod.rs"),
                        ::tracing_core::__macro_support::Option::Some(1243u32),
                        ::tracing_core::__macro_support::Option::Some("rustc_hir_analysis::hir_ty_lowering"),
                        ::tracing_core::field::FieldSet::new(&[{
                                            const NAME:
                                                ::tracing::__macro_support::FieldName<{
                                                    ::tracing::__macro_support::FieldName::len("return")
                                                }> =
                                                ::tracing::__macro_support::FieldName::new("return");
                                            NAME.as_str()
                                        }], ::tracing_core::callsite::Identifier(&__CALLSITE)),
                        ::tracing::metadata::Kind::EVENT)
                };
            ::tracing::callsite::DefaultCallsite::new(&META)
        };
    let enabled =
        ::tracing::Level::DEBUG <= ::tracing::level_filters::STATIC_MAX_LEVEL
                &&
                ::tracing::Level::DEBUG <=
                    ::tracing::level_filters::LevelFilter::current() &&
            {
                let interest = __CALLSITE.interest();
                !interest.is_never() &&
                    ::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
                        interest)
            };
    if enabled {
        (|value_set: ::tracing::field::ValueSet|
                    {
                        let meta = __CALLSITE.metadata();
                        ::tracing::Event::dispatch(meta, &value_set);
                        ;
                    })({
                #[allow(unused_imports)]
                use ::tracing::field::{debug, display, Value};
                __CALLSITE.metadata().fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&x)
                                            as &dyn ::tracing::field::Value))])
            });
    } else { ; }
};
x;#[instrument(level = "debug", skip_all, ret)]
1244    fn probe_single_ty_param_bound_for_assoc_item(
1245        &self,
1246        ty_param_def_id: LocalDefId,
1247        ty_param_span: Span,
1248        assoc_tag: ty::AssocTag,
1249        assoc_ident: Ident,
1250        span: Span,
1251    ) -> Result<ty::PolyTraitRef<'tcx>, ErrorGuaranteed> {
1252        debug!(?ty_param_def_id, ?assoc_ident, ?span);
1253        let tcx = self.tcx();
1254
1255        let predicates = &self.probe_ty_param_bounds(span, ty_param_def_id, assoc_ident);
1256        debug!("predicates={:#?}", predicates);
1257
1258        self.probe_single_bound_for_assoc_item(
1259            || {
1260                let trait_refs = predicates
1261                    .iter_identity_copied()
1262                    .map(Unnormalized::skip_norm_wip)
1263                    .filter_map(|(p, _)| Some(p.as_trait_clause()?.map_bound(|t| t.trait_ref)));
1264                traits::transitive_bounds_that_define_assoc_item(tcx, trait_refs, assoc_ident)
1265            },
1266            AssocItemQSelf::TyParam(ty_param_def_id, ty_param_span),
1267            assoc_tag,
1268            assoc_ident,
1269            span,
1270            None,
1271        )
1272    }
1273
1274    /// When there are multiple traits which contain an identically named
1275    /// associated item, this function eliminates any traits which are a
1276    /// supertrait of another candidate trait.
1277    ///
1278    /// This is the type-level analogue of
1279    /// `rustc_hir_typeck::method::probe::ProbeContext::collapse_candidates_to_subtrait_pick`;
1280    /// keep both implementations in sync.
1281    ///
1282    /// This implements RFC #3624.
1283    fn collapse_candidates_to_subtrait_pick(
1284        &self,
1285        matching_candidates: &[ty::PolyTraitRef<'tcx>],
1286    ) -> Option<ty::PolyTraitRef<'tcx>> {
1287        if !self.tcx().features().supertrait_item_shadowing() {
1288            return None;
1289        }
1290
1291        let mut child_trait = matching_candidates[0];
1292        let mut supertraits: SsoHashSet<_> =
1293            traits::supertrait_def_ids(self.tcx(), child_trait.def_id()).collect();
1294
1295        let mut remaining_candidates: Vec<_> = matching_candidates[1..].iter().copied().collect();
1296        while !remaining_candidates.is_empty() {
1297            let mut made_progress = false;
1298            let mut next_round = ::alloc::vec::Vec::new()vec![];
1299
1300            for remaining_trait in remaining_candidates {
1301                if supertraits.contains(&remaining_trait.def_id()) {
1302                    made_progress = true;
1303                    continue;
1304                }
1305
1306                // This candidate is not a supertrait of the `child_trait`.
1307                // Check if it's a subtrait of the `child_trait`, instead.
1308                // If it is, then it must have been a subtrait of every
1309                // other pick we've eliminated at this point. It will
1310                // take over at this point.
1311                let remaining_trait_supertraits: SsoHashSet<_> =
1312                    traits::supertrait_def_ids(self.tcx(), remaining_trait.def_id()).collect();
1313                if remaining_trait_supertraits.contains(&child_trait.def_id()) {
1314                    child_trait = remaining_trait;
1315                    supertraits = remaining_trait_supertraits;
1316                    made_progress = true;
1317                    continue;
1318                }
1319
1320                // Neither `child_trait` or the current candidate are
1321                // supertraits of each other.
1322                // Don't bail here, since we may be comparing two supertraits
1323                // of a common subtrait. These two supertraits won't be related
1324                // at all, but we will pick them up next round when we find their
1325                // child as we continue iterating in this round.
1326                next_round.push(remaining_trait);
1327            }
1328
1329            if made_progress {
1330                // If we've made progress, iterate again.
1331                remaining_candidates = next_round;
1332            } else {
1333                // Otherwise, we must have at least two candidates which
1334                // are not related to each other at all.
1335                return None;
1336            }
1337        }
1338
1339        Some(child_trait)
1340    }
1341
1342    /// Search for a single trait bound whose trait defines the associated item given by
1343    /// `assoc_ident`.
1344    ///
1345    /// This fails if there is no such bound in the list of candidates or if there are multiple
1346    /// candidates in which case it reports ambiguity.
1347    {}
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("probe_single_bound_for_assoc_item",
                                "rustc_hir_analysis::hir_ty_lowering",
                                ::tracing::Level::DEBUG,
                                ::tracing_core::__macro_support::Option::Some("/rustc-dev/a36d05efab632d1ddf902b6a5c33b6d5d3b64131/compiler/rustc_hir_analysis/src/hir_ty_lowering/mod.rs"),
                                ::tracing_core::__macro_support::Option::Some(1347u32),
                                ::tracing_core::__macro_support::Option::Some("rustc_hir_analysis::hir_ty_lowering"),
                                ::tracing_core::field::FieldSet::new(&[{
                                                    const NAME:
                                                        ::tracing::__macro_support::FieldName<{
                                                            ::tracing::__macro_support::FieldName::len("assoc_tag")
                                                        }> =
                                                        ::tracing::__macro_support::FieldName::new("assoc_tag");
                                                    NAME.as_str()
                                                },
                                                {
                                                    const NAME:
                                                        ::tracing::__macro_support::FieldName<{
                                                            ::tracing::__macro_support::FieldName::len("assoc_ident")
                                                        }> =
                                                        ::tracing::__macro_support::FieldName::new("assoc_ident");
                                                    NAME.as_str()
                                                },
                                                {
                                                    const NAME:
                                                        ::tracing::__macro_support::FieldName<{
                                                            ::tracing::__macro_support::FieldName::len("span")
                                                        }> =
                                                        ::tracing::__macro_support::FieldName::new("span");
                                                    NAME.as_str()
                                                }], ::tracing_core::callsite::Identifier(&__CALLSITE)),
                                ::tracing::metadata::Kind::SPAN)
                        };
                    ::tracing::callsite::DefaultCallsite::new(&META)
                };
            let mut interest = ::tracing::subscriber::Interest::never();
            if ::tracing::Level::DEBUG <=
                                ::tracing::level_filters::STATIC_MAX_LEVEL &&
                            ::tracing::Level::DEBUG <=
                                ::tracing::level_filters::LevelFilter::current() &&
                        { interest = __CALLSITE.interest(); !interest.is_never() }
                    &&
                    ::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
                        interest) {
                let meta = __CALLSITE.metadata();
                ::tracing::Span::new(meta,
                    &{
                            #[allow(unused_imports)]
                            use ::tracing::field::{debug, display, Value};
                            meta.fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&assoc_tag)
                                                        as &dyn ::tracing::field::Value)),
                                            (::tracing::__macro_support::Option::Some(&::tracing::field::debug(&assoc_ident)
                                                        as &dyn ::tracing::field::Value)),
                                            (::tracing::__macro_support::Option::Some(&::tracing::field::debug(&span)
                                                        as &dyn ::tracing::field::Value))])
                        })
            } else {
                let span =
                    ::tracing::__macro_support::__disabled_span(__CALLSITE.metadata());
                {};
                span
            }
        };
    __tracing_attr_guard = __tracing_attr_span.enter();
}
#[allow(clippy :: redundant_closure_call)]
let x =
    (move ||
                {

                    #[allow(unknown_lints, unreachable_code, clippy ::
                    diverging_sub_expression, clippy :: empty_loop, clippy ::
                    let_unit_value, clippy :: let_with_type_underscore, clippy
                    :: needless_return, clippy :: unreachable)]
                    if false {
                        let __tracing_attr_fake_return:
                                Result<ty::PolyTraitRef<'tcx>, ErrorGuaranteed> = loop {};
                        return __tracing_attr_fake_return;
                    }
                    {
                        let mut matching_candidates =
                            all_candidates().filter(|r|
                                    {
                                        self.probe_trait_that_defines_assoc_item(r.def_id(),
                                            assoc_tag, assoc_ident)
                                    });
                        let Some(bound1) =
                            matching_candidates.next() else {
                                return Err(self.report_unresolved_assoc_item(all_candidates,
                                            qself, assoc_tag, assoc_ident, span, constraint));
                            };
                        if let Some(bound2) = matching_candidates.next() {
                            let all_matching_candidates: Vec<_> =
                                [bound1,
                                                    bound2].into_iter().chain(matching_candidates).collect();
                            if let Some(bound) =
                                    self.collapse_candidates_to_subtrait_pick(&all_matching_candidates)
                                {
                                return Ok(bound);
                            }
                            return Err(self.report_ambiguous_assoc_item(&all_matching_candidates,
                                        qself, assoc_tag, assoc_ident, span, constraint));
                        }
                        Ok(bound1)
                    }
                })();
{
    use ::tracing::__macro_support::Callsite as _;
    static __CALLSITE: ::tracing::callsite::DefaultCallsite =
        {
            static META: ::tracing::Metadata<'static> =
                {
                    ::tracing_core::metadata::Metadata::new("event /rustc-dev/a36d05efab632d1ddf902b6a5c33b6d5d3b64131/compiler/rustc_hir_analysis/src/hir_ty_lowering/mod.rs:1347",
                        "rustc_hir_analysis::hir_ty_lowering",
                        ::tracing::Level::DEBUG,
                        ::tracing_core::__macro_support::Option::Some("/rustc-dev/a36d05efab632d1ddf902b6a5c33b6d5d3b64131/compiler/rustc_hir_analysis/src/hir_ty_lowering/mod.rs"),
                        ::tracing_core::__macro_support::Option::Some(1347u32),
                        ::tracing_core::__macro_support::Option::Some("rustc_hir_analysis::hir_ty_lowering"),
                        ::tracing_core::field::FieldSet::new(&[{
                                            const NAME:
                                                ::tracing::__macro_support::FieldName<{
                                                    ::tracing::__macro_support::FieldName::len("return")
                                                }> =
                                                ::tracing::__macro_support::FieldName::new("return");
                                            NAME.as_str()
                                        }], ::tracing_core::callsite::Identifier(&__CALLSITE)),
                        ::tracing::metadata::Kind::EVENT)
                };
            ::tracing::callsite::DefaultCallsite::new(&META)
        };
    let enabled =
        ::tracing::Level::DEBUG <= ::tracing::level_filters::STATIC_MAX_LEVEL
                &&
                ::tracing::Level::DEBUG <=
                    ::tracing::level_filters::LevelFilter::current() &&
            {
                let interest = __CALLSITE.interest();
                !interest.is_never() &&
                    ::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
                        interest)
            };
    if enabled {
        (|value_set: ::tracing::field::ValueSet|
                    {
                        let meta = __CALLSITE.metadata();
                        ::tracing::Event::dispatch(meta, &value_set);
                        ;
                    })({
                #[allow(unused_imports)]
                use ::tracing::field::{debug, display, Value};
                __CALLSITE.metadata().fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&x)
                                            as &dyn ::tracing::field::Value))])
            });
    } else { ; }
};
x;#[instrument(level = "debug", skip(self, all_candidates, qself, constraint), ret)]
1348    fn probe_single_bound_for_assoc_item<I>(
1349        &self,
1350        all_candidates: impl Fn() -> I,
1351        qself: AssocItemQSelf,
1352        assoc_tag: ty::AssocTag,
1353        assoc_ident: Ident,
1354        span: Span,
1355        constraint: Option<&hir::AssocItemConstraint<'_>>,
1356    ) -> Result<ty::PolyTraitRef<'tcx>, ErrorGuaranteed>
1357    where
1358        I: Iterator<Item = ty::PolyTraitRef<'tcx>>,
1359    {
1360        let mut matching_candidates = all_candidates().filter(|r| {
1361            self.probe_trait_that_defines_assoc_item(r.def_id(), assoc_tag, assoc_ident)
1362        });
1363
1364        let Some(bound1) = matching_candidates.next() else {
1365            return Err(self.report_unresolved_assoc_item(
1366                all_candidates,
1367                qself,
1368                assoc_tag,
1369                assoc_ident,
1370                span,
1371                constraint,
1372            ));
1373        };
1374
1375        if let Some(bound2) = matching_candidates.next() {
1376            let all_matching_candidates: Vec<_> =
1377                [bound1, bound2].into_iter().chain(matching_candidates).collect();
1378            if let Some(bound) = self.collapse_candidates_to_subtrait_pick(&all_matching_candidates)
1379            {
1380                return Ok(bound);
1381            }
1382
1383            return Err(self.report_ambiguous_assoc_item(
1384                &all_matching_candidates,
1385                qself,
1386                assoc_tag,
1387                assoc_ident,
1388                span,
1389                constraint,
1390            ));
1391        }
1392
1393        Ok(bound1)
1394    }
1395
1396    /// Lower a [type-relative](hir::QPath::TypeRelative) path in type position to a type.
1397    ///
1398    /// If the path refers to an enum variant and `permit_variants` holds,
1399    /// the returned type is simply the provided self type `qself_ty`.
1400    ///
1401    /// A path like `A::B::C::D` is understood as `<A::B::C>::D`. I.e.,
1402    /// `qself_ty` / `qself` is `A::B::C` and `assoc_segment` is `D`.
1403    /// We return the lowered type and the `DefId` for the whole path.
1404    ///
1405    /// We only support associated type paths whose self type is a type parameter or a `Self`
1406    /// type alias (in a trait impl) like `T::Ty` (where `T` is a ty param) or `Self::Ty`.
1407    /// We **don't** support paths whose self type is an arbitrary type like `Struct::Ty` where
1408    /// struct `Struct` impls an in-scope trait that defines an associated type called `Ty`.
1409    /// For the latter case, we report ambiguity.
1410    /// While desirable to support, the implementation would be non-trivial. Tracked in [#22519].
1411    ///
1412    /// At the time of writing, *inherent associated types* are also resolved here. This however
1413    /// is [problematic][iat]. A proper implementation would be as non-trivial as the one
1414    /// described in the previous paragraph and their modeling of projections would likely be
1415    /// very similar in nature.
1416    ///
1417    /// [#22519]: https://github.com/rust-lang/rust/issues/22519
1418    /// [iat]: https://github.com/rust-lang/rust/issues/8995#issuecomment-1569208403
1419    //
1420    // NOTE: When this function starts resolving `Trait::AssocTy` successfully
1421    // it should also start reporting the `BARE_TRAIT_OBJECTS` lint.
1422    {}
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("lower_type_relative_ty_path",
                                "rustc_hir_analysis::hir_ty_lowering",
                                ::tracing::Level::DEBUG,
                                ::tracing_core::__macro_support::Option::Some("/rustc-dev/a36d05efab632d1ddf902b6a5c33b6d5d3b64131/compiler/rustc_hir_analysis/src/hir_ty_lowering/mod.rs"),
                                ::tracing_core::__macro_support::Option::Some(1422u32),
                                ::tracing_core::__macro_support::Option::Some("rustc_hir_analysis::hir_ty_lowering"),
                                ::tracing_core::field::FieldSet::new(&[],
                                    ::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,
                    &{ meta.fields().value_set_all(&[]) })
            } else {
                let span =
                    ::tracing::__macro_support::__disabled_span(__CALLSITE.metadata());
                {};
                span
            }
        };
    __tracing_attr_guard = __tracing_attr_span.enter();
}
#[allow(clippy :: redundant_closure_call)]
let x =
    (move ||
                {

                    #[allow(unknown_lints, unreachable_code, clippy ::
                    diverging_sub_expression, clippy :: empty_loop, clippy ::
                    let_unit_value, clippy :: let_with_type_underscore, clippy
                    :: needless_return, clippy :: unreachable)]
                    if false {
                        let __tracing_attr_fake_return:
                                Result<(Ty<'tcx>, DefKind, DefId), ErrorGuaranteed> =
                            loop {};
                        return __tracing_attr_fake_return;
                    }
                    {
                        let tcx = self.tcx();
                        match self.lower_type_relative_path(self_ty, hir_self_ty,
                                    segment, qpath_hir_id, span,
                                    LowerTypeRelativePathMode::Type(permit_variants))? {
                            TypeRelativePath::AssocItem(alias_term) => {
                                let alias_ty = alias_term.expect_ty();
                                let def_id =
                                    match alias_ty.kind {
                                        ty::AliasTyKind::Projection { def_id } => def_id,
                                        ty::AliasTyKind::Inherent { def_id } => def_id,
                                        kind =>
                                            ::rustc_middle::util::bug::bug_fmt(format_args!("expected projection or inherent alias, got {0:?}",
                                                    kind)),
                                    };
                                let ty = alias_ty.to_ty(tcx, ty::IsRigid::No);
                                let ty = self.check_param_uses_if_mcg(ty, span, false);
                                Ok((ty, tcx.def_kind(def_id), def_id))
                            }
                            TypeRelativePath::Variant { adt, variant_did } => {
                                let adt = self.check_param_uses_if_mcg(adt, span, false);
                                Ok((adt, DefKind::Variant, variant_did))
                            }
                            TypeRelativePath::Ctor { .. } => {
                                let e =
                                    tcx.dcx().span_err(span,
                                        "expected type, found tuple constructor");
                                Err(e)
                            }
                        }
                    }
                })();
{
    use ::tracing::__macro_support::Callsite as _;
    static __CALLSITE: ::tracing::callsite::DefaultCallsite =
        {
            static META: ::tracing::Metadata<'static> =
                {
                    ::tracing_core::metadata::Metadata::new("event /rustc-dev/a36d05efab632d1ddf902b6a5c33b6d5d3b64131/compiler/rustc_hir_analysis/src/hir_ty_lowering/mod.rs:1422",
                        "rustc_hir_analysis::hir_ty_lowering",
                        ::tracing::Level::DEBUG,
                        ::tracing_core::__macro_support::Option::Some("/rustc-dev/a36d05efab632d1ddf902b6a5c33b6d5d3b64131/compiler/rustc_hir_analysis/src/hir_ty_lowering/mod.rs"),
                        ::tracing_core::__macro_support::Option::Some(1422u32),
                        ::tracing_core::__macro_support::Option::Some("rustc_hir_analysis::hir_ty_lowering"),
                        ::tracing_core::field::FieldSet::new(&[{
                                            const NAME:
                                                ::tracing::__macro_support::FieldName<{
                                                    ::tracing::__macro_support::FieldName::len("return")
                                                }> =
                                                ::tracing::__macro_support::FieldName::new("return");
                                            NAME.as_str()
                                        }], ::tracing_core::callsite::Identifier(&__CALLSITE)),
                        ::tracing::metadata::Kind::EVENT)
                };
            ::tracing::callsite::DefaultCallsite::new(&META)
        };
    let enabled =
        ::tracing::Level::DEBUG <= ::tracing::level_filters::STATIC_MAX_LEVEL
                &&
                ::tracing::Level::DEBUG <=
                    ::tracing::level_filters::LevelFilter::current() &&
            {
                let interest = __CALLSITE.interest();
                !interest.is_never() &&
                    ::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
                        interest)
            };
    if enabled {
        (|value_set: ::tracing::field::ValueSet|
                    {
                        let meta = __CALLSITE.metadata();
                        ::tracing::Event::dispatch(meta, &value_set);
                        ;
                    })({
                #[allow(unused_imports)]
                use ::tracing::field::{debug, display, Value};
                __CALLSITE.metadata().fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&x)
                                            as &dyn ::tracing::field::Value))])
            });
    } else { ; }
};
x;#[instrument(level = "debug", skip_all, ret)]
1423    pub fn lower_type_relative_ty_path(
1424        &self,
1425        self_ty: Ty<'tcx>,
1426        hir_self_ty: &hir::Ty<'_>,
1427        segment: &hir::PathSegment<'_>,
1428        qpath_hir_id: HirId,
1429        span: Span,
1430        permit_variants: PermitVariants,
1431    ) -> Result<(Ty<'tcx>, DefKind, DefId), ErrorGuaranteed> {
1432        let tcx = self.tcx();
1433        match self.lower_type_relative_path(
1434            self_ty,
1435            hir_self_ty,
1436            segment,
1437            qpath_hir_id,
1438            span,
1439            LowerTypeRelativePathMode::Type(permit_variants),
1440        )? {
1441            TypeRelativePath::AssocItem(alias_term) => {
1442                let alias_ty = alias_term.expect_ty();
1443                let def_id = match alias_ty.kind {
1444                    ty::AliasTyKind::Projection { def_id } => def_id,
1445                    ty::AliasTyKind::Inherent { def_id } => def_id,
1446                    kind => bug!("expected projection or inherent alias, got {kind:?}"),
1447                };
1448                let ty = alias_ty.to_ty(tcx, ty::IsRigid::No);
1449                let ty = self.check_param_uses_if_mcg(ty, span, false);
1450                Ok((ty, tcx.def_kind(def_id), def_id))
1451            }
1452            TypeRelativePath::Variant { adt, variant_did } => {
1453                let adt = self.check_param_uses_if_mcg(adt, span, false);
1454                Ok((adt, DefKind::Variant, variant_did))
1455            }
1456            TypeRelativePath::Ctor { .. } => {
1457                let e = tcx.dcx().span_err(span, "expected type, found tuple constructor");
1458                Err(e)
1459            }
1460        }
1461    }
1462
1463    /// Lower a [type-relative][hir::QPath::TypeRelative] path to a (type-level) constant.
1464    {}
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("lower_type_relative_const_path",
                                "rustc_hir_analysis::hir_ty_lowering",
                                ::tracing::Level::DEBUG,
                                ::tracing_core::__macro_support::Option::Some("/rustc-dev/a36d05efab632d1ddf902b6a5c33b6d5d3b64131/compiler/rustc_hir_analysis/src/hir_ty_lowering/mod.rs"),
                                ::tracing_core::__macro_support::Option::Some(1464u32),
                                ::tracing_core::__macro_support::Option::Some("rustc_hir_analysis::hir_ty_lowering"),
                                ::tracing_core::field::FieldSet::new(&[],
                                    ::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,
                    &{ meta.fields().value_set_all(&[]) })
            } else {
                let span =
                    ::tracing::__macro_support::__disabled_span(__CALLSITE.metadata());
                {};
                span
            }
        };
    __tracing_attr_guard = __tracing_attr_span.enter();
}
#[allow(clippy :: redundant_closure_call)]
let x =
    (move ||
                {

                    #[allow(unknown_lints, unreachable_code, clippy ::
                    diverging_sub_expression, clippy :: empty_loop, clippy ::
                    let_unit_value, clippy :: let_with_type_underscore, clippy
                    :: needless_return, clippy :: unreachable)]
                    if false {
                        let __tracing_attr_fake_return:
                                Result<Const<'tcx>, ErrorGuaranteed> = loop {};
                        return __tracing_attr_fake_return;
                    }
                    {
                        let tcx = self.tcx();
                        match self.lower_type_relative_path(self_ty, hir_self_ty,
                                    segment, qpath_hir_id, span,
                                    LowerTypeRelativePathMode::Const)? {
                            TypeRelativePath::AssocItem(alias_term) => {
                                let alias_ct = alias_term.expect_ct();
                                if let Some(def_id) = alias_ct.kind.opt_def_id() {
                                    self.require_type_const_attribute(def_id, span)?;
                                }
                                let ct = Const::new_alias(tcx, ty::IsRigid::No, alias_ct);
                                let ct = self.check_param_uses_if_mcg(ct, span, false);
                                Ok(ct)
                            }
                            TypeRelativePath::Ctor { ctor_def_id, args } =>
                                match tcx.def_kind(ctor_def_id) {
                                    DefKind::Ctor(_, CtorKind::Fn) =>
                                        Ok(ty::Const::zero_sized(tcx,
                                                tcx.type_of(ctor_def_id).instantiate(tcx,
                                                        args).skip_norm_wip())),
                                    DefKind::Ctor(ctor_of, CtorKind::Const) => {
                                        Ok(self.construct_const_ctor_value(ctor_def_id, ctor_of,
                                                args))
                                    }
                                    _ =>
                                        ::core::panicking::panic("internal error: entered unreachable code"),
                                },
                            TypeRelativePath::Variant { .. } => {
                                ::rustc_middle::util::bug::span_bug_fmt(span,
                                    format_args!("unexpected variant res for type associated const path"))
                            }
                        }
                    }
                })();
{
    use ::tracing::__macro_support::Callsite as _;
    static __CALLSITE: ::tracing::callsite::DefaultCallsite =
        {
            static META: ::tracing::Metadata<'static> =
                {
                    ::tracing_core::metadata::Metadata::new("event /rustc-dev/a36d05efab632d1ddf902b6a5c33b6d5d3b64131/compiler/rustc_hir_analysis/src/hir_ty_lowering/mod.rs:1464",
                        "rustc_hir_analysis::hir_ty_lowering",
                        ::tracing::Level::DEBUG,
                        ::tracing_core::__macro_support::Option::Some("/rustc-dev/a36d05efab632d1ddf902b6a5c33b6d5d3b64131/compiler/rustc_hir_analysis/src/hir_ty_lowering/mod.rs"),
                        ::tracing_core::__macro_support::Option::Some(1464u32),
                        ::tracing_core::__macro_support::Option::Some("rustc_hir_analysis::hir_ty_lowering"),
                        ::tracing_core::field::FieldSet::new(&[{
                                            const NAME:
                                                ::tracing::__macro_support::FieldName<{
                                                    ::tracing::__macro_support::FieldName::len("return")
                                                }> =
                                                ::tracing::__macro_support::FieldName::new("return");
                                            NAME.as_str()
                                        }], ::tracing_core::callsite::Identifier(&__CALLSITE)),
                        ::tracing::metadata::Kind::EVENT)
                };
            ::tracing::callsite::DefaultCallsite::new(&META)
        };
    let enabled =
        ::tracing::Level::DEBUG <= ::tracing::level_filters::STATIC_MAX_LEVEL
                &&
                ::tracing::Level::DEBUG <=
                    ::tracing::level_filters::LevelFilter::current() &&
            {
                let interest = __CALLSITE.interest();
                !interest.is_never() &&
                    ::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
                        interest)
            };
    if enabled {
        (|value_set: ::tracing::field::ValueSet|
                    {
                        let meta = __CALLSITE.metadata();
                        ::tracing::Event::dispatch(meta, &value_set);
                        ;
                    })({
                #[allow(unused_imports)]
                use ::tracing::field::{debug, display, Value};
                __CALLSITE.metadata().fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&x)
                                            as &dyn ::tracing::field::Value))])
            });
    } else { ; }
};
x;#[instrument(level = "debug", skip_all, ret)]
1465    fn lower_type_relative_const_path(
1466        &self,
1467        self_ty: Ty<'tcx>,
1468        hir_self_ty: &hir::Ty<'_>,
1469        segment: &hir::PathSegment<'_>,
1470        qpath_hir_id: HirId,
1471        span: Span,
1472    ) -> Result<Const<'tcx>, ErrorGuaranteed> {
1473        let tcx = self.tcx();
1474        match self.lower_type_relative_path(
1475            self_ty,
1476            hir_self_ty,
1477            segment,
1478            qpath_hir_id,
1479            span,
1480            LowerTypeRelativePathMode::Const,
1481        )? {
1482            TypeRelativePath::AssocItem(alias_term) => {
1483                let alias_ct = alias_term.expect_ct();
1484                if let Some(def_id) = alias_ct.kind.opt_def_id() {
1485                    self.require_type_const_attribute(def_id, span)?;
1486                }
1487                let ct = Const::new_alias(tcx, ty::IsRigid::No, alias_ct);
1488                let ct = self.check_param_uses_if_mcg(ct, span, false);
1489                Ok(ct)
1490            }
1491            TypeRelativePath::Ctor { ctor_def_id, args } => match tcx.def_kind(ctor_def_id) {
1492                DefKind::Ctor(_, CtorKind::Fn) => Ok(ty::Const::zero_sized(
1493                    tcx,
1494                    tcx.type_of(ctor_def_id).instantiate(tcx, args).skip_norm_wip(),
1495                )),
1496                DefKind::Ctor(ctor_of, CtorKind::Const) => {
1497                    Ok(self.construct_const_ctor_value(ctor_def_id, ctor_of, args))
1498                }
1499                _ => unreachable!(),
1500            },
1501            // FIXME(mgca): implement support for this once ready to support all adt ctor expressions,
1502            // not just const ctors
1503            TypeRelativePath::Variant { .. } => {
1504                span_bug!(span, "unexpected variant res for type associated const path")
1505            }
1506        }
1507    }
1508
1509    /// Lower a [type-relative][hir::QPath::TypeRelative] (and type-level) path.
1510    {}
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("lower_type_relative_path",
                                "rustc_hir_analysis::hir_ty_lowering",
                                ::tracing::Level::DEBUG,
                                ::tracing_core::__macro_support::Option::Some("/rustc-dev/a36d05efab632d1ddf902b6a5c33b6d5d3b64131/compiler/rustc_hir_analysis/src/hir_ty_lowering/mod.rs"),
                                ::tracing_core::__macro_support::Option::Some(1510u32),
                                ::tracing_core::__macro_support::Option::Some("rustc_hir_analysis::hir_ty_lowering"),
                                ::tracing_core::field::FieldSet::new(&[],
                                    ::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,
                    &{ meta.fields().value_set_all(&[]) })
            } else {
                let span =
                    ::tracing::__macro_support::__disabled_span(__CALLSITE.metadata());
                {};
                span
            }
        };
    __tracing_attr_guard = __tracing_attr_span.enter();
}
#[allow(clippy :: redundant_closure_call)]
let x =
    (move ||
                {

                    #[allow(unknown_lints, unreachable_code, clippy ::
                    diverging_sub_expression, clippy :: empty_loop, clippy ::
                    let_unit_value, clippy :: let_with_type_underscore, clippy
                    :: needless_return, clippy :: unreachable)]
                    if false {
                        let __tracing_attr_fake_return:
                                Result<TypeRelativePath<'tcx>, ErrorGuaranteed> = loop {};
                        return __tracing_attr_fake_return;
                    }
                    {
                        {
                            use ::tracing::__macro_support::Callsite as _;
                            static __CALLSITE: ::tracing::callsite::DefaultCallsite =
                                {
                                    static META: ::tracing::Metadata<'static> =
                                        {
                                            ::tracing_core::metadata::Metadata::new("event /rustc-dev/a36d05efab632d1ddf902b6a5c33b6d5d3b64131/compiler/rustc_hir_analysis/src/hir_ty_lowering/mod.rs:1520",
                                                "rustc_hir_analysis::hir_ty_lowering",
                                                ::tracing::Level::DEBUG,
                                                ::tracing_core::__macro_support::Option::Some("/rustc-dev/a36d05efab632d1ddf902b6a5c33b6d5d3b64131/compiler/rustc_hir_analysis/src/hir_ty_lowering/mod.rs"),
                                                ::tracing_core::__macro_support::Option::Some(1520u32),
                                                ::tracing_core::__macro_support::Option::Some("rustc_hir_analysis::hir_ty_lowering"),
                                                ::tracing_core::field::FieldSet::new(&[{
                                                                    const NAME:
                                                                        ::tracing::__macro_support::FieldName<{
                                                                            ::tracing::__macro_support::FieldName::len("self_ty")
                                                                        }> =
                                                                        ::tracing::__macro_support::FieldName::new("self_ty");
                                                                    NAME.as_str()
                                                                },
                                                                {
                                                                    const NAME:
                                                                        ::tracing::__macro_support::FieldName<{
                                                                            ::tracing::__macro_support::FieldName::len("segment.ident")
                                                                        }> =
                                                                        ::tracing::__macro_support::FieldName::new("segment.ident");
                                                                    NAME.as_str()
                                                                }], ::tracing_core::callsite::Identifier(&__CALLSITE)),
                                                ::tracing::metadata::Kind::EVENT)
                                        };
                                    ::tracing::callsite::DefaultCallsite::new(&META)
                                };
                            let enabled =
                                ::tracing::Level::DEBUG <=
                                            ::tracing::level_filters::STATIC_MAX_LEVEL &&
                                        ::tracing::Level::DEBUG <=
                                            ::tracing::level_filters::LevelFilter::current() &&
                                    {
                                        let interest = __CALLSITE.interest();
                                        !interest.is_never() &&
                                            ::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
                                                interest)
                                    };
                            if enabled {
                                (|value_set: ::tracing::field::ValueSet|
                                            {
                                                let meta = __CALLSITE.metadata();
                                                ::tracing::Event::dispatch(meta, &value_set);
                                                ;
                                            })({
                                        #[allow(unused_imports)]
                                        use ::tracing::field::{debug, display, Value};
                                        __CALLSITE.metadata().fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&::tracing::field::display(&self_ty)
                                                                    as &dyn ::tracing::field::Value)),
                                                        (::tracing::__macro_support::Option::Some(&::tracing::field::debug(&segment.ident)
                                                                    as &dyn ::tracing::field::Value))])
                                    });
                            } else { ; }
                        };
                        let tcx = self.tcx();
                        let mut variant_def_id = None;
                        if let Some(adt_def) = self.probe_adt(span, self_ty) {
                            if adt_def.is_enum() {
                                let variant_def =
                                    adt_def.variants().iter().find(|vd|
                                            tcx.hygienic_eq(segment.ident, vd.ident(tcx),
                                                adt_def.did()));
                                if let Some(variant_def) = variant_def {
                                    if #[allow(non_exhaustive_omitted_patterns)] match mode {
                                                LowerTypeRelativePathMode::Const => true,
                                                _ => false,
                                            } && let Some((_, ctor_def_id)) = variant_def.ctor {
                                        tcx.check_stability(variant_def.def_id, Some(qpath_hir_id),
                                            span, None);
                                        let _ =
                                            self.prohibit_generic_args(slice::from_ref(segment).iter(),
                                                GenericsArgsErrExtend::EnumVariant {
                                                    qself: hir_self_ty,
                                                    assoc_segment: segment,
                                                    adt_def,
                                                });
                                        let ty::Adt(_, enum_args) =
                                            self_ty.kind() else {
                                                ::core::panicking::panic("internal error: entered unreachable code")
                                            };
                                        return Ok(TypeRelativePath::Ctor {
                                                    ctor_def_id,
                                                    args: enum_args,
                                                });
                                    }
                                    if let PermitVariants::Yes = mode.permit_variants() {
                                        tcx.check_stability(variant_def.def_id, Some(qpath_hir_id),
                                            span, None);
                                        let _ =
                                            self.prohibit_generic_args(slice::from_ref(segment).iter(),
                                                GenericsArgsErrExtend::EnumVariant {
                                                    qself: hir_self_ty,
                                                    assoc_segment: segment,
                                                    adt_def,
                                                });
                                        return Ok(TypeRelativePath::Variant {
                                                    adt: self_ty,
                                                    variant_did: variant_def.def_id,
                                                });
                                    } else { variant_def_id = Some(variant_def.def_id); }
                                }
                            }
                            if let Some(alias_term) =
                                    self.probe_inherent_assoc_item(segment, adt_def.did(),
                                            self_ty, qpath_hir_id, span, mode.assoc_tag())? {
                                return Ok(TypeRelativePath::AssocItem(alias_term));
                            }
                        }
                        let (item_def_id, bound) =
                            self.resolve_type_relative_path(self_ty, hir_self_ty,
                                    mode.assoc_tag(), segment, qpath_hir_id, span,
                                    variant_def_id)?;
                        let (item_def_id, args) =
                            self.lower_assoc_item_path(span, item_def_id, segment,
                                    bound)?;
                        if let Some(variant_def_id) = variant_def_id {
                            tcx.emit_node_span_lint(AMBIGUOUS_ASSOCIATED_ITEMS,
                                qpath_hir_id, span,
                                errors::AmbiguityBetweenVariantAndAssocItem {
                                    variant_def_id,
                                    item_def_id,
                                    span,
                                    segment_ident: segment.ident,
                                    bound_def_id: bound.def_id(),
                                    self_ty,
                                    tcx,
                                    mode,
                                });
                        }
                        Ok(TypeRelativePath::AssocItem(ty::AliasTerm::new_from_def_id(tcx,
                                    item_def_id, args,
                                    ty::AliasConstInherentArgsKind::WithSelf)))
                    }
                })();
{
    use ::tracing::__macro_support::Callsite as _;
    static __CALLSITE: ::tracing::callsite::DefaultCallsite =
        {
            static META: ::tracing::Metadata<'static> =
                {
                    ::tracing_core::metadata::Metadata::new("event /rustc-dev/a36d05efab632d1ddf902b6a5c33b6d5d3b64131/compiler/rustc_hir_analysis/src/hir_ty_lowering/mod.rs:1510",
                        "rustc_hir_analysis::hir_ty_lowering",
                        ::tracing::Level::DEBUG,
                        ::tracing_core::__macro_support::Option::Some("/rustc-dev/a36d05efab632d1ddf902b6a5c33b6d5d3b64131/compiler/rustc_hir_analysis/src/hir_ty_lowering/mod.rs"),
                        ::tracing_core::__macro_support::Option::Some(1510u32),
                        ::tracing_core::__macro_support::Option::Some("rustc_hir_analysis::hir_ty_lowering"),
                        ::tracing_core::field::FieldSet::new(&[{
                                            const NAME:
                                                ::tracing::__macro_support::FieldName<{
                                                    ::tracing::__macro_support::FieldName::len("return")
                                                }> =
                                                ::tracing::__macro_support::FieldName::new("return");
                                            NAME.as_str()
                                        }], ::tracing_core::callsite::Identifier(&__CALLSITE)),
                        ::tracing::metadata::Kind::EVENT)
                };
            ::tracing::callsite::DefaultCallsite::new(&META)
        };
    let enabled =
        ::tracing::Level::DEBUG <= ::tracing::level_filters::STATIC_MAX_LEVEL
                &&
                ::tracing::Level::DEBUG <=
                    ::tracing::level_filters::LevelFilter::current() &&
            {
                let interest = __CALLSITE.interest();
                !interest.is_never() &&
                    ::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
                        interest)
            };
    if enabled {
        (|value_set: ::tracing::field::ValueSet|
                    {
                        let meta = __CALLSITE.metadata();
                        ::tracing::Event::dispatch(meta, &value_set);
                        ;
                    })({
                #[allow(unused_imports)]
                use ::tracing::field::{debug, display, Value};
                __CALLSITE.metadata().fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&x)
                                            as &dyn ::tracing::field::Value))])
            });
    } else { ; }
};
x;#[instrument(level = "debug", skip_all, ret)]
1511    fn lower_type_relative_path(
1512        &self,
1513        self_ty: Ty<'tcx>,
1514        hir_self_ty: &hir::Ty<'_>,
1515        segment: &hir::PathSegment<'_>,
1516        qpath_hir_id: HirId,
1517        span: Span,
1518        mode: LowerTypeRelativePathMode,
1519    ) -> Result<TypeRelativePath<'tcx>, ErrorGuaranteed> {
1520        debug!(%self_ty, ?segment.ident);
1521        let tcx = self.tcx();
1522
1523        // Check if we have an enum variant or an inherent associated type.
1524        let mut variant_def_id = None;
1525        if let Some(adt_def) = self.probe_adt(span, self_ty) {
1526            if adt_def.is_enum() {
1527                let variant_def = adt_def
1528                    .variants()
1529                    .iter()
1530                    .find(|vd| tcx.hygienic_eq(segment.ident, vd.ident(tcx), adt_def.did()));
1531                if let Some(variant_def) = variant_def {
1532                    // FIXME(mgca): do we want constructor resolutions to take priority over
1533                    // other possible resolutions?
1534                    if matches!(mode, LowerTypeRelativePathMode::Const)
1535                        && let Some((_, ctor_def_id)) = variant_def.ctor
1536                    {
1537                        tcx.check_stability(variant_def.def_id, Some(qpath_hir_id), span, None);
1538                        let _ = self.prohibit_generic_args(
1539                            slice::from_ref(segment).iter(),
1540                            GenericsArgsErrExtend::EnumVariant {
1541                                qself: hir_self_ty,
1542                                assoc_segment: segment,
1543                                adt_def,
1544                            },
1545                        );
1546                        let ty::Adt(_, enum_args) = self_ty.kind() else { unreachable!() };
1547                        return Ok(TypeRelativePath::Ctor { ctor_def_id, args: enum_args });
1548                    }
1549                    if let PermitVariants::Yes = mode.permit_variants() {
1550                        tcx.check_stability(variant_def.def_id, Some(qpath_hir_id), span, None);
1551                        let _ = self.prohibit_generic_args(
1552                            slice::from_ref(segment).iter(),
1553                            GenericsArgsErrExtend::EnumVariant {
1554                                qself: hir_self_ty,
1555                                assoc_segment: segment,
1556                                adt_def,
1557                            },
1558                        );
1559                        return Ok(TypeRelativePath::Variant {
1560                            adt: self_ty,
1561                            variant_did: variant_def.def_id,
1562                        });
1563                    } else {
1564                        variant_def_id = Some(variant_def.def_id);
1565                    }
1566                }
1567            }
1568
1569            // FIXME(inherent_associated_types, #106719): Support self types other than ADTs.
1570            if let Some(alias_term) = self.probe_inherent_assoc_item(
1571                segment,
1572                adt_def.did(),
1573                self_ty,
1574                qpath_hir_id,
1575                span,
1576                mode.assoc_tag(),
1577            )? {
1578                return Ok(TypeRelativePath::AssocItem(alias_term));
1579            }
1580        }
1581
1582        let (item_def_id, bound) = self.resolve_type_relative_path(
1583            self_ty,
1584            hir_self_ty,
1585            mode.assoc_tag(),
1586            segment,
1587            qpath_hir_id,
1588            span,
1589            variant_def_id,
1590        )?;
1591
1592        let (item_def_id, args) = self.lower_assoc_item_path(span, item_def_id, segment, bound)?;
1593
1594        if let Some(variant_def_id) = variant_def_id {
1595            tcx.emit_node_span_lint(
1596                AMBIGUOUS_ASSOCIATED_ITEMS,
1597                qpath_hir_id,
1598                span,
1599                errors::AmbiguityBetweenVariantAndAssocItem {
1600                    variant_def_id,
1601                    item_def_id,
1602                    span,
1603                    segment_ident: segment.ident,
1604                    bound_def_id: bound.def_id(),
1605                    self_ty,
1606                    tcx,
1607                    mode,
1608                },
1609            );
1610        }
1611
1612        Ok(TypeRelativePath::AssocItem(ty::AliasTerm::new_from_def_id(
1613            tcx,
1614            item_def_id,
1615            args,
1616            ty::AliasConstInherentArgsKind::WithSelf,
1617        )))
1618    }
1619
1620    /// Resolve a [type-relative](hir::QPath::TypeRelative) (and type-level) path.
1621    fn resolve_type_relative_path(
1622        &self,
1623        self_ty: Ty<'tcx>,
1624        hir_self_ty: &hir::Ty<'_>,
1625        assoc_tag: ty::AssocTag,
1626        segment: &hir::PathSegment<'_>,
1627        qpath_hir_id: HirId,
1628        span: Span,
1629        variant_def_id: Option<DefId>,
1630    ) -> Result<(DefId, ty::PolyTraitRef<'tcx>), ErrorGuaranteed> {
1631        let tcx = self.tcx();
1632
1633        let self_ty_res = match hir_self_ty.kind {
1634            hir::TyKind::Path(hir::QPath::Resolved(_, path)) => path.res,
1635            _ => Res::Err,
1636        };
1637
1638        // Find the type of the assoc item, and the trait where the associated item is declared.
1639        let bound = match (self_ty.kind(), self_ty_res) {
1640            (_, Res::SelfTyAlias { alias_to: impl_def_id, is_trait_impl: true, .. }) => {
1641                // `Self` in an impl of a trait -- we have a concrete self type and a
1642                // trait reference.
1643                let trait_ref = tcx.impl_trait_ref(impl_def_id);
1644
1645                self.probe_single_bound_for_assoc_item(
1646                    || {
1647                        let trait_ref =
1648                            ty::Binder::dummy(trait_ref.instantiate_identity().skip_norm_wip());
1649                        traits::supertraits(tcx, trait_ref)
1650                    },
1651                    AssocItemQSelf::SelfTyAlias,
1652                    assoc_tag,
1653                    segment.ident,
1654                    span,
1655                    None,
1656                )?
1657            }
1658            (
1659                &ty::Param(_),
1660                Res::SelfTyParam { trait_: param_did } | Res::Def(DefKind::TyParam, param_did),
1661            ) => self.probe_single_ty_param_bound_for_assoc_item(
1662                param_did.expect_local(),
1663                hir_self_ty.span,
1664                assoc_tag,
1665                segment.ident,
1666                span,
1667            )?,
1668            _ => {
1669                return Err(self.report_unresolved_type_relative_path(
1670                    self_ty,
1671                    hir_self_ty,
1672                    assoc_tag,
1673                    segment.ident,
1674                    qpath_hir_id,
1675                    span,
1676                    variant_def_id,
1677                ));
1678            }
1679        };
1680
1681        let assoc_item = self
1682            .probe_assoc_item(segment.ident, assoc_tag, qpath_hir_id, span, bound.def_id())
1683            .expect("failed to find associated item");
1684
1685        Ok((assoc_item.def_id, bound))
1686    }
1687
1688    /// Search for inherent associated items for use at the type level.
1689    fn probe_inherent_assoc_item(
1690        &self,
1691        segment: &hir::PathSegment<'_>,
1692        adt_did: DefId,
1693        self_ty: Ty<'tcx>,
1694        block: HirId,
1695        span: Span,
1696        assoc_tag: ty::AssocTag,
1697    ) -> Result<Option<ty::AliasTerm<'tcx>>, ErrorGuaranteed> {
1698        let tcx = self.tcx();
1699
1700        if !tcx.features().inherent_associated_types() {
1701            match assoc_tag {
1702                // Don't attempt to look up inherent associated types when the feature is not
1703                // enabled. Theoretically it'd be fine to do so since we feature-gate their
1704                // definition site. However, the current implementation of inherent associated
1705                // items is somewhat brittle, so let's not run it by default.
1706                ty::AssocTag::Type => return Ok(None),
1707                ty::AssocTag::Const => {
1708                    // We also gate the mgca codepath for type-level uses of inherent consts
1709                    // with the inherent_associated_types feature gate since it relies on the
1710                    // same machinery and has similar rough edges.
1711                    return Err(feature_err(
1712                        &tcx.sess,
1713                        sym::inherent_associated_types,
1714                        span,
1715                        "inherent associated types are unstable",
1716                    )
1717                    .emit());
1718                }
1719                ty::AssocTag::Fn => ::core::panicking::panic("internal error: entered unreachable code")unreachable!(),
1720            }
1721        }
1722
1723        let name = segment.ident;
1724        let candidates: Vec<_> = tcx
1725            .inherent_impls(adt_did)
1726            .iter()
1727            .filter_map(|&impl_| {
1728                let (item, scope) = self.probe_assoc_item_unchecked(name, assoc_tag, impl_)?;
1729                Some(InherentAssocCandidate { impl_, assoc_item: item.def_id, scope })
1730            })
1731            .collect();
1732
1733        // At the moment, we actually bail out with a hard error if the selection of an inherent
1734        // associated item fails (see below). This means we never consider trait associated items
1735        // as potential fallback candidates (#142006). To temporarily mask that issue, let's not
1736        // select at all if there are no early inherent candidates.
1737        if candidates.is_empty() {
1738            return Ok(None);
1739        }
1740
1741        let (applicable_candidates, fulfillment_errors) =
1742            self.select_inherent_assoc_candidates(span, self_ty, candidates.clone());
1743
1744        // FIXME(#142006): Don't eagerly error here, there might be applicable trait candidates.
1745        let InherentAssocCandidate { impl_, assoc_item, scope: def_scope } =
1746            match &applicable_candidates[..] {
1747                &[] => Err(self.report_unresolved_inherent_assoc_item(
1748                    name,
1749                    self_ty,
1750                    candidates,
1751                    fulfillment_errors,
1752                    span,
1753                    assoc_tag,
1754                )),
1755
1756                &[applicable_candidate] => Ok(applicable_candidate),
1757
1758                &[_, ..] => Err(self.report_ambiguous_inherent_assoc_item(
1759                    name,
1760                    candidates.into_iter().map(|cand| cand.assoc_item).collect(),
1761                    span,
1762                )),
1763            }?;
1764
1765        // FIXME(#142006): Don't eagerly validate here, there might be trait candidates that are
1766        // accessible (visible and stable) contrary to the inherent candidate.
1767        self.check_assoc_item(assoc_item, name, def_scope, block, span);
1768
1769        // FIXME(fmease): Currently creating throwaway `parent_args` to please
1770        // `lower_generic_args_of_assoc_item`. Modify the latter instead (or sth. similar) to
1771        // not require the parent args logic.
1772        let parent_args = ty::GenericArgs::identity_for_item(tcx, impl_);
1773        let args = self.lower_generic_args_of_assoc_item(span, assoc_item, segment, parent_args);
1774        let args = tcx.mk_args_from_iter(
1775            std::iter::once(ty::GenericArg::from(self_ty))
1776                .chain(args.into_iter().skip(parent_args.len())),
1777        );
1778
1779        let kind = match assoc_tag {
1780            ty::AssocTag::Type => ty::AliasTermKind::InherentTy { def_id: assoc_item },
1781            ty::AssocTag::Const => ty::AliasTermKind::InherentConstSelf { def_id: assoc_item },
1782            ty::AssocTag::Fn => ::core::panicking::panic("internal error: entered unreachable code")unreachable!(),
1783        };
1784
1785        Ok(Some(ty::AliasTerm::new_from_args(tcx, kind, args)))
1786    }
1787
1788    /// Given name and kind search for the assoc item in the provided scope and check if it's accessible[^1].
1789    ///
1790    /// [^1]: I.e., accessible in the provided scope wrt. visibility and stability.
1791    fn probe_assoc_item(
1792        &self,
1793        ident: Ident,
1794        assoc_tag: ty::AssocTag,
1795        block: HirId,
1796        span: Span,
1797        scope: DefId,
1798    ) -> Option<ty::AssocItem> {
1799        let (item, scope) = self.probe_assoc_item_unchecked(ident, assoc_tag, scope)?;
1800        self.check_assoc_item(item.def_id, ident, scope, block, span);
1801        Some(item)
1802    }
1803
1804    /// Given name and kind search for the assoc item in the provided scope
1805    /// *without* checking if it's accessible[^1].
1806    ///
1807    /// [^1]: I.e., accessible in the provided scope wrt. visibility and stability.
1808    fn probe_assoc_item_unchecked(
1809        &self,
1810        ident: Ident,
1811        assoc_tag: ty::AssocTag,
1812        scope: DefId,
1813    ) -> Option<(ty::AssocItem, /*scope*/ ModId)> {
1814        let tcx = self.tcx();
1815
1816        let (ident, def_scope) = tcx.adjust_ident_and_get_scope(ident, scope, self.item_def_id());
1817        // We have already adjusted the item name above, so compare with `.normalize_to_macros_2_0()`
1818        // instead of calling `filter_by_name_and_kind` which would needlessly normalize the
1819        // `ident` again and again.
1820        let item = tcx
1821            .associated_items(scope)
1822            .filter_by_name_unhygienic(ident.name)
1823            .find(|i| i.tag() == assoc_tag && i.ident(tcx).normalize_to_macros_2_0() == ident)?;
1824
1825        Some((*item, def_scope))
1826    }
1827
1828    /// Check if the given assoc item is accessible in the provided scope wrt. visibility and stability.
1829    fn check_assoc_item(
1830        &self,
1831        item_def_id: DefId,
1832        ident: Ident,
1833        scope: ModId,
1834        block: HirId,
1835        span: Span,
1836    ) {
1837        let tcx = self.tcx();
1838
1839        if !tcx.visibility(item_def_id).is_accessible_from(scope, tcx) {
1840            self.dcx().emit_err(crate::diagnostics::AssocItemIsPrivate {
1841                span,
1842                kind: tcx.def_descr(item_def_id),
1843                name: ident,
1844                defined_here_label: tcx.def_span(item_def_id),
1845            });
1846        }
1847
1848        tcx.check_stability(item_def_id, Some(block), span, None);
1849    }
1850
1851    fn probe_traits_that_match_assoc_ty(
1852        &self,
1853        qself_ty: Ty<'tcx>,
1854        assoc_ident: Ident,
1855    ) -> Vec<String> {
1856        let tcx = self.tcx();
1857
1858        // In contexts that have no inference context, just make a new one.
1859        // We do need a local variable to store it, though.
1860        let infcx_;
1861        let infcx = if let Some(infcx) = self.infcx() {
1862            infcx
1863        } else {
1864            if !!qself_ty.has_infer() {
    ::core::panicking::panic("assertion failed: !qself_ty.has_infer()")
};assert!(!qself_ty.has_infer());
1865            infcx_ = tcx.infer_ctxt().build(TypingMode::non_body_analysis());
1866            &infcx_
1867        };
1868
1869        tcx.all_traits_including_private()
1870            .filter(|trait_def_id| {
1871                // Consider only traits with the associated type
1872                tcx.associated_items(*trait_def_id)
1873                        .in_definition_order()
1874                        .any(|i| {
1875                            i.is_type()
1876                                && !i.is_impl_trait_in_trait()
1877                                && i.ident(tcx).normalize_to_macros_2_0() == assoc_ident
1878                        })
1879                    // Consider only accessible traits
1880                    && tcx.visibility(*trait_def_id)
1881                        .is_accessible_from(self.item_def_id(), tcx)
1882                    && tcx.all_impls(*trait_def_id)
1883                        .any(|impl_def_id| {
1884                            let header = tcx.impl_trait_header(impl_def_id);
1885                            let trait_ref = header.trait_ref.instantiate(tcx, infcx.fresh_args_for_item(DUMMY_SP, impl_def_id)).skip_norm_wip();
1886
1887                            let value = fold_regions(tcx, qself_ty, |_, _| tcx.lifetimes.re_erased);
1888                            // FIXME: Don't bother dealing with non-lifetime binders here...
1889                            if value.has_escaping_bound_vars() {
1890                                return false;
1891                            }
1892                            infcx
1893                                .can_eq(
1894                                    ty::ParamEnv::empty(),
1895                                    trait_ref.self_ty(),
1896                                    value,
1897                                ) && header.polarity != ty::ImplPolarity::Negative
1898                        })
1899            })
1900            .map(|trait_def_id| tcx.def_path_str(trait_def_id))
1901            .collect()
1902    }
1903
1904    /// Lower a [resolved][hir::QPath::Resolved] associated type path to a projection.
1905    {}
#[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("lower_resolved_assoc_ty_path",
                                    "rustc_hir_analysis::hir_ty_lowering",
                                    ::tracing::Level::DEBUG,
                                    ::tracing_core::__macro_support::Option::Some("/rustc-dev/a36d05efab632d1ddf902b6a5c33b6d5d3b64131/compiler/rustc_hir_analysis/src/hir_ty_lowering/mod.rs"),
                                    ::tracing_core::__macro_support::Option::Some(1905u32),
                                    ::tracing_core::__macro_support::Option::Some("rustc_hir_analysis::hir_ty_lowering"),
                                    ::tracing_core::field::FieldSet::new(&[],
                                        ::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,
                        &{ meta.fields().value_set_all(&[]) })
                } 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: Ty<'tcx> = loop {};
            return __tracing_attr_fake_return;
        }
        {
            match self.lower_resolved_assoc_item_path(span, opt_self_ty,
                    item_def_id, trait_segment, item_segment,
                    ty::AssocTag::Type) {
                Ok((item_def_id, item_args)) => {
                    Ty::new_projection_from_args(self.tcx(), ty::IsRigid::No,
                        item_def_id, item_args)
                }
                Err(guar) => Ty::new_error(self.tcx(), guar),
            }
        }
    }
}#[instrument(level = "debug", skip_all)]
1906    fn lower_resolved_assoc_ty_path(
1907        &self,
1908        span: Span,
1909        opt_self_ty: Option<Ty<'tcx>>,
1910        item_def_id: DefId,
1911        trait_segment: Option<&hir::PathSegment<'_>>,
1912        item_segment: &hir::PathSegment<'_>,
1913    ) -> Ty<'tcx> {
1914        match self.lower_resolved_assoc_item_path(
1915            span,
1916            opt_self_ty,
1917            item_def_id,
1918            trait_segment,
1919            item_segment,
1920            ty::AssocTag::Type,
1921        ) {
1922            Ok((item_def_id, item_args)) => {
1923                Ty::new_projection_from_args(self.tcx(), ty::IsRigid::No, item_def_id, item_args)
1924            }
1925            Err(guar) => Ty::new_error(self.tcx(), guar),
1926        }
1927    }
1928
1929    /// Lower a [resolved][hir::QPath::Resolved] associated const path to a (type-level) constant.
1930    {}
#[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("lower_resolved_assoc_const_path",
                                    "rustc_hir_analysis::hir_ty_lowering",
                                    ::tracing::Level::DEBUG,
                                    ::tracing_core::__macro_support::Option::Some("/rustc-dev/a36d05efab632d1ddf902b6a5c33b6d5d3b64131/compiler/rustc_hir_analysis/src/hir_ty_lowering/mod.rs"),
                                    ::tracing_core::__macro_support::Option::Some(1930u32),
                                    ::tracing_core::__macro_support::Option::Some("rustc_hir_analysis::hir_ty_lowering"),
                                    ::tracing_core::field::FieldSet::new(&[],
                                        ::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,
                        &{ meta.fields().value_set_all(&[]) })
                } 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:
                    Result<Const<'tcx>, ErrorGuaranteed> = loop {};
            return __tracing_attr_fake_return;
        }
        {
            let tcx = self.tcx();
            let (item_def_id, item_args) =
                self.lower_resolved_assoc_item_path(span, opt_self_ty,
                        item_def_id, trait_segment, item_segment,
                        ty::AssocTag::Const)?;
            self.require_type_const_attribute(item_def_id, span)?;
            let alias_const =
                ty::AliasConst::new(tcx,
                    ty::AliasConstKind::new_from_def_id(tcx, item_def_id,
                        ty::AliasConstInherentArgsKind::WithSelf), item_args);
            Ok(Const::new_alias(tcx, ty::IsRigid::No, alias_const))
        }
    }
}#[instrument(level = "debug", skip_all)]
1931    fn lower_resolved_assoc_const_path(
1932        &self,
1933        span: Span,
1934        opt_self_ty: Option<Ty<'tcx>>,
1935        item_def_id: DefId,
1936        trait_segment: Option<&hir::PathSegment<'_>>,
1937        item_segment: &hir::PathSegment<'_>,
1938    ) -> Result<Const<'tcx>, ErrorGuaranteed> {
1939        let tcx = self.tcx();
1940        let (item_def_id, item_args) = self.lower_resolved_assoc_item_path(
1941            span,
1942            opt_self_ty,
1943            item_def_id,
1944            trait_segment,
1945            item_segment,
1946            ty::AssocTag::Const,
1947        )?;
1948        self.require_type_const_attribute(item_def_id, span)?;
1949        let alias_const = ty::AliasConst::new(
1950            tcx,
1951            ty::AliasConstKind::new_from_def_id(
1952                tcx,
1953                item_def_id,
1954                ty::AliasConstInherentArgsKind::WithSelf,
1955            ),
1956            item_args,
1957        );
1958        Ok(Const::new_alias(tcx, ty::IsRigid::No, alias_const))
1959    }
1960
1961    /// Lower a [resolved][hir::QPath::Resolved] (type-level) associated item path.
1962    {}
#[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("lower_resolved_assoc_item_path",
                                    "rustc_hir_analysis::hir_ty_lowering",
                                    ::tracing::Level::DEBUG,
                                    ::tracing_core::__macro_support::Option::Some("/rustc-dev/a36d05efab632d1ddf902b6a5c33b6d5d3b64131/compiler/rustc_hir_analysis/src/hir_ty_lowering/mod.rs"),
                                    ::tracing_core::__macro_support::Option::Some(1962u32),
                                    ::tracing_core::__macro_support::Option::Some("rustc_hir_analysis::hir_ty_lowering"),
                                    ::tracing_core::field::FieldSet::new(&[],
                                        ::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,
                        &{ meta.fields().value_set_all(&[]) })
                } 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:
                    Result<(DefId, GenericArgsRef<'tcx>), ErrorGuaranteed> =
                loop {};
            return __tracing_attr_fake_return;
        }
        {
            let tcx = self.tcx();
            let trait_def_id = tcx.parent(item_def_id);
            {
                use ::tracing::__macro_support::Callsite as _;
                static __CALLSITE: ::tracing::callsite::DefaultCallsite =
                    {
                        static META: ::tracing::Metadata<'static> =
                            {
                                ::tracing_core::metadata::Metadata::new("event /rustc-dev/a36d05efab632d1ddf902b6a5c33b6d5d3b64131/compiler/rustc_hir_analysis/src/hir_ty_lowering/mod.rs:1975",
                                    "rustc_hir_analysis::hir_ty_lowering",
                                    ::tracing::Level::DEBUG,
                                    ::tracing_core::__macro_support::Option::Some("/rustc-dev/a36d05efab632d1ddf902b6a5c33b6d5d3b64131/compiler/rustc_hir_analysis/src/hir_ty_lowering/mod.rs"),
                                    ::tracing_core::__macro_support::Option::Some(1975u32),
                                    ::tracing_core::__macro_support::Option::Some("rustc_hir_analysis::hir_ty_lowering"),
                                    ::tracing_core::field::FieldSet::new(&[{
                                                        const NAME:
                                                            ::tracing::__macro_support::FieldName<{
                                                                ::tracing::__macro_support::FieldName::len("trait_def_id")
                                                            }> =
                                                            ::tracing::__macro_support::FieldName::new("trait_def_id");
                                                        NAME.as_str()
                                                    }], ::tracing_core::callsite::Identifier(&__CALLSITE)),
                                    ::tracing::metadata::Kind::EVENT)
                            };
                        ::tracing::callsite::DefaultCallsite::new(&META)
                    };
                let enabled =
                    ::tracing::Level::DEBUG <=
                                ::tracing::level_filters::STATIC_MAX_LEVEL &&
                            ::tracing::Level::DEBUG <=
                                ::tracing::level_filters::LevelFilter::current() &&
                        {
                            let interest = __CALLSITE.interest();
                            !interest.is_never() &&
                                ::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
                                    interest)
                        };
                if enabled {
                    (|value_set: ::tracing::field::ValueSet|
                                {
                                    let meta = __CALLSITE.metadata();
                                    ::tracing::Event::dispatch(meta, &value_set);
                                    ;
                                })({
                            #[allow(unused_imports)]
                            use ::tracing::field::{debug, display, Value};
                            __CALLSITE.metadata().fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&trait_def_id)
                                                        as &dyn ::tracing::field::Value))])
                        });
                } else { ; }
            };
            let Some(self_ty) =
                opt_self_ty else {
                    return Err(self.report_missing_self_ty_for_resolved_path(trait_def_id,
                                span, item_segment, assoc_tag));
                };
            {
                use ::tracing::__macro_support::Callsite as _;
                static __CALLSITE: ::tracing::callsite::DefaultCallsite =
                    {
                        static META: ::tracing::Metadata<'static> =
                            {
                                ::tracing_core::metadata::Metadata::new("event /rustc-dev/a36d05efab632d1ddf902b6a5c33b6d5d3b64131/compiler/rustc_hir_analysis/src/hir_ty_lowering/mod.rs:1985",
                                    "rustc_hir_analysis::hir_ty_lowering",
                                    ::tracing::Level::DEBUG,
                                    ::tracing_core::__macro_support::Option::Some("/rustc-dev/a36d05efab632d1ddf902b6a5c33b6d5d3b64131/compiler/rustc_hir_analysis/src/hir_ty_lowering/mod.rs"),
                                    ::tracing_core::__macro_support::Option::Some(1985u32),
                                    ::tracing_core::__macro_support::Option::Some("rustc_hir_analysis::hir_ty_lowering"),
                                    ::tracing_core::field::FieldSet::new(&[{
                                                        const NAME:
                                                            ::tracing::__macro_support::FieldName<{
                                                                ::tracing::__macro_support::FieldName::len("self_ty")
                                                            }> =
                                                            ::tracing::__macro_support::FieldName::new("self_ty");
                                                        NAME.as_str()
                                                    }], ::tracing_core::callsite::Identifier(&__CALLSITE)),
                                    ::tracing::metadata::Kind::EVENT)
                            };
                        ::tracing::callsite::DefaultCallsite::new(&META)
                    };
                let enabled =
                    ::tracing::Level::DEBUG <=
                                ::tracing::level_filters::STATIC_MAX_LEVEL &&
                            ::tracing::Level::DEBUG <=
                                ::tracing::level_filters::LevelFilter::current() &&
                        {
                            let interest = __CALLSITE.interest();
                            !interest.is_never() &&
                                ::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
                                    interest)
                        };
                if enabled {
                    (|value_set: ::tracing::field::ValueSet|
                                {
                                    let meta = __CALLSITE.metadata();
                                    ::tracing::Event::dispatch(meta, &value_set);
                                    ;
                                })({
                            #[allow(unused_imports)]
                            use ::tracing::field::{debug, display, Value};
                            __CALLSITE.metadata().fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&self_ty)
                                                        as &dyn ::tracing::field::Value))])
                        });
                } else { ; }
            };
            let trait_ref =
                self.lower_mono_trait_ref(span, trait_def_id, self_ty,
                    trait_segment.unwrap(), false);
            {
                use ::tracing::__macro_support::Callsite as _;
                static __CALLSITE: ::tracing::callsite::DefaultCallsite =
                    {
                        static META: ::tracing::Metadata<'static> =
                            {
                                ::tracing_core::metadata::Metadata::new("event /rustc-dev/a36d05efab632d1ddf902b6a5c33b6d5d3b64131/compiler/rustc_hir_analysis/src/hir_ty_lowering/mod.rs:1989",
                                    "rustc_hir_analysis::hir_ty_lowering",
                                    ::tracing::Level::DEBUG,
                                    ::tracing_core::__macro_support::Option::Some("/rustc-dev/a36d05efab632d1ddf902b6a5c33b6d5d3b64131/compiler/rustc_hir_analysis/src/hir_ty_lowering/mod.rs"),
                                    ::tracing_core::__macro_support::Option::Some(1989u32),
                                    ::tracing_core::__macro_support::Option::Some("rustc_hir_analysis::hir_ty_lowering"),
                                    ::tracing_core::field::FieldSet::new(&[{
                                                        const NAME:
                                                            ::tracing::__macro_support::FieldName<{
                                                                ::tracing::__macro_support::FieldName::len("trait_ref")
                                                            }> =
                                                            ::tracing::__macro_support::FieldName::new("trait_ref");
                                                        NAME.as_str()
                                                    }], ::tracing_core::callsite::Identifier(&__CALLSITE)),
                                    ::tracing::metadata::Kind::EVENT)
                            };
                        ::tracing::callsite::DefaultCallsite::new(&META)
                    };
                let enabled =
                    ::tracing::Level::DEBUG <=
                                ::tracing::level_filters::STATIC_MAX_LEVEL &&
                            ::tracing::Level::DEBUG <=
                                ::tracing::level_filters::LevelFilter::current() &&
                        {
                            let interest = __CALLSITE.interest();
                            !interest.is_never() &&
                                ::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
                                    interest)
                        };
                if enabled {
                    (|value_set: ::tracing::field::ValueSet|
                                {
                                    let meta = __CALLSITE.metadata();
                                    ::tracing::Event::dispatch(meta, &value_set);
                                    ;
                                })({
                            #[allow(unused_imports)]
                            use ::tracing::field::{debug, display, Value};
                            __CALLSITE.metadata().fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&trait_ref)
                                                        as &dyn ::tracing::field::Value))])
                        });
                } else { ; }
            };
            let item_args =
                self.lower_generic_args_of_assoc_item(span, item_def_id,
                    item_segment, trait_ref.args);
            Ok((item_def_id, item_args))
        }
    }
}#[instrument(level = "debug", skip_all)]
1963    fn lower_resolved_assoc_item_path(
1964        &self,
1965        span: Span,
1966        opt_self_ty: Option<Ty<'tcx>>,
1967        item_def_id: DefId,
1968        trait_segment: Option<&hir::PathSegment<'_>>,
1969        item_segment: &hir::PathSegment<'_>,
1970        assoc_tag: ty::AssocTag,
1971    ) -> Result<(DefId, GenericArgsRef<'tcx>), ErrorGuaranteed> {
1972        let tcx = self.tcx();
1973
1974        let trait_def_id = tcx.parent(item_def_id);
1975        debug!(?trait_def_id);
1976
1977        let Some(self_ty) = opt_self_ty else {
1978            return Err(self.report_missing_self_ty_for_resolved_path(
1979                trait_def_id,
1980                span,
1981                item_segment,
1982                assoc_tag,
1983            ));
1984        };
1985        debug!(?self_ty);
1986
1987        let trait_ref =
1988            self.lower_mono_trait_ref(span, trait_def_id, self_ty, trait_segment.unwrap(), false);
1989        debug!(?trait_ref);
1990
1991        let item_args =
1992            self.lower_generic_args_of_assoc_item(span, item_def_id, item_segment, trait_ref.args);
1993
1994        Ok((item_def_id, item_args))
1995    }
1996
1997    pub fn prohibit_generic_args<'a>(
1998        &self,
1999        segments: impl Iterator<Item = &'a hir::PathSegment<'a>> + Clone,
2000        err_extend: GenericsArgsErrExtend<'a>,
2001    ) -> Result<(), ErrorGuaranteed> {
2002        let args_visitors = segments.clone().flat_map(|segment| segment.args().args);
2003        let mut result = Ok(());
2004        if let Some(_) = args_visitors.clone().next() {
2005            result = Err(self.report_prohibited_generic_args(
2006                segments.clone(),
2007                args_visitors,
2008                err_extend,
2009            ));
2010        }
2011
2012        for segment in segments {
2013            // Only emit the first error to avoid overloading the user with error messages.
2014            if let Some(c) = segment.args().constraints.first() {
2015                return Err(prohibit_assoc_item_constraint(self, c, None));
2016            }
2017        }
2018
2019        result
2020    }
2021
2022    /// Probe path segments that are semantically allowed to have generic arguments.
2023    ///
2024    /// ### Example
2025    ///
2026    /// ```ignore (illustrative)
2027    ///    Option::None::<()>
2028    /// //         ^^^^ permitted to have generic args
2029    ///
2030    /// // ==> [GenericPathSegment(Option_def_id, 1)]
2031    ///
2032    ///    Option::<()>::None
2033    /// // ^^^^^^        ^^^^ *not* permitted to have generic args
2034    /// // permitted to have generic args
2035    ///
2036    /// // ==> [GenericPathSegment(Option_def_id, 0)]
2037    /// ```
2038    // FIXME(eddyb, varkor) handle type paths here too, not just value ones.
2039    pub fn probe_generic_path_segments(
2040        &self,
2041        segments: &[hir::PathSegment<'_>],
2042        self_ty: Option<Ty<'tcx>>,
2043        kind: DefKind,
2044        def_id: DefId,
2045        span: Span,
2046    ) -> Vec<GenericPathSegment> {
2047        // We need to extract the generic arguments supplied by the user in
2048        // the path `path`. Due to the current setup, this is a bit of a
2049        // tricky process; the problem is that resolve only tells us the
2050        // end-point of the path resolution, and not the intermediate steps.
2051        // Luckily, we can (at least for now) deduce the intermediate steps
2052        // just from the end-point.
2053        //
2054        // There are basically five cases to consider:
2055        //
2056        // 1. Reference to a constructor of a struct:
2057        //
2058        //        struct Foo<T>(...)
2059        //
2060        //    In this case, the generic arguments are declared in the type space.
2061        //
2062        // 2. Reference to a constructor of an enum variant:
2063        //
2064        //        enum E<T> { Foo(...) }
2065        //
2066        //    In this case, the generic arguments are defined in the type space,
2067        //    but may be specified either on the type or the variant.
2068        //
2069        // 3. Reference to a free function or constant:
2070        //
2071        //        fn foo<T>() {}
2072        //
2073        //    In this case, the path will again always have the form
2074        //    `a::b::foo::<T>` where only the final segment should have generic
2075        //    arguments. However, in this case, those arguments are declared on
2076        //    a value, and hence are in the value space.
2077        //
2078        // 4. Reference to an associated function or constant:
2079        //
2080        //        impl<A> SomeStruct<A> {
2081        //            fn foo<B>(...) {}
2082        //        }
2083        //
2084        //    Here we can have a path like `a::b::SomeStruct::<A>::foo::<B>`,
2085        //    in which case generic arguments may appear in two places. The
2086        //    penultimate segment, `SomeStruct::<A>`, contains generic arguments
2087        //    in the type space, and the final segment, `foo::<B>` contains
2088        //    generic arguments in value space.
2089        //
2090        // The first step then is to categorize the segments appropriately.
2091
2092        let tcx = self.tcx();
2093
2094        if !!segments.is_empty() {
    ::core::panicking::panic("assertion failed: !segments.is_empty()")
};assert!(!segments.is_empty());
2095        let last = segments.len() - 1;
2096
2097        let mut generic_segments = ::alloc::vec::Vec::new()vec![];
2098
2099        match kind {
2100            // Case 1. Reference to a struct constructor.
2101            DefKind::Ctor(CtorOf::Struct, ..) => {
2102                // Everything but the final segment should have no
2103                // parameters at all.
2104                let generics = tcx.generics_of(def_id);
2105                // Variant and struct constructors use the
2106                // generics of their parent type definition.
2107                let generics_def_id = generics.parent.unwrap_or(def_id);
2108                generic_segments.push(GenericPathSegment(generics_def_id, last));
2109            }
2110
2111            // Case 2. Reference to a variant constructor.
2112            DefKind::Ctor(CtorOf::Variant, ..) | DefKind::Variant => {
2113                let (generics_def_id, index) = if let Some(self_ty) = self_ty {
2114                    // We have something like `<module::Enum>::Variant`.
2115
2116                    let adt_def = self.probe_adt(span, self_ty).unwrap();
2117                    if true {
    if !adt_def.is_enum() {
        ::core::panicking::panic("assertion failed: adt_def.is_enum()")
    };
};debug_assert!(adt_def.is_enum());
2118
2119                    // FIXME: Stating that the last segment (here: `Variant`) is allowed to have
2120                    // generic args is a lie! We should set the index to `None` instead as it's
2121                    // the *self type* that's allowed to have args.
2122                    // HIR typeck's `instantiate_value_path` actually contains a special case to
2123                    // reject args on `DefKind::Ctor` segments (see `is_alias_variant_ctor`).
2124                    // Using `None` here for this should allow us to get rid of that workaround.
2125                    //
2126                    // (For additional context, `DefKind::Variant` segments never actually reach
2127                    // this branch as they're interpreted as `TypeRelative` paths whose lowering
2128                    // routines manually reject args on them).
2129
2130                    (adt_def.did(), last)
2131                } else if let [.., second_to_last, _] = segments
2132                    && second_to_last.args.is_some()
2133                    && let Res::Def(DefKind::Enum, _) = second_to_last.res
2134                {
2135                    // We have something like `module::Enum::<…>::Variant`.
2136                    // No segment other than the penultimate one is allowed to have generic args.
2137
2138                    // We had to check that the second to last segment actually referred to an enum
2139                    // since at this stage it could very well refer to a module in which case we
2140                    // certainly don't want to allow generic args on it!
2141
2142                    // `DefKind::Ctor` -> `DefKind::Variant`
2143                    let def_id = match kind {
2144                        DefKind::Ctor(..) => tcx.parent(def_id),
2145                        _ => def_id,
2146                    };
2147
2148                    // `DefKind::Variant` -> `DefKind::Enum`
2149                    let enum_def_id = tcx.parent(def_id);
2150
2151                    (enum_def_id, last - 1)
2152                } else {
2153                    // We have something like `module::Enum::Variant` or `module::Variant`.
2154                    // No segment other than the final one is allowed to have generic args.
2155
2156                    // FIXME: lint here recommending `Enum::<...>::Variant` form
2157                    // instead of `Enum::Variant::<...>` form.
2158
2159                    let generics = tcx.generics_of(def_id);
2160                    // Variant and struct constructors use the
2161                    // generics of their parent type definition.
2162                    (generics.parent.unwrap_or(def_id), last)
2163                };
2164                generic_segments.push(GenericPathSegment(generics_def_id, index));
2165            }
2166
2167            // Case 3. Reference to a top-level value.
2168            DefKind::Fn | DefKind::Const { .. } | DefKind::ConstParam | DefKind::Static { .. } => {
2169                generic_segments.push(GenericPathSegment(def_id, last));
2170            }
2171
2172            // Case 4. Reference to a method or associated const.
2173            DefKind::AssocFn | DefKind::AssocConst { .. } => {
2174                if segments.len() >= 2 {
2175                    let generics = tcx.generics_of(def_id);
2176                    generic_segments.push(GenericPathSegment(generics.parent.unwrap(), last - 1));
2177                }
2178                generic_segments.push(GenericPathSegment(def_id, last));
2179            }
2180
2181            kind => ::rustc_middle::util::bug::bug_fmt(format_args!("unexpected definition kind {0:?} for {1:?}",
        kind, def_id))bug!("unexpected definition kind {:?} for {:?}", kind, def_id),
2182        }
2183
2184        {
    use ::tracing::__macro_support::Callsite as _;
    static __CALLSITE: ::tracing::callsite::DefaultCallsite =
        {
            static META: ::tracing::Metadata<'static> =
                {
                    ::tracing_core::metadata::Metadata::new("event /rustc-dev/a36d05efab632d1ddf902b6a5c33b6d5d3b64131/compiler/rustc_hir_analysis/src/hir_ty_lowering/mod.rs:2184",
                        "rustc_hir_analysis::hir_ty_lowering",
                        ::tracing::Level::DEBUG,
                        ::tracing_core::__macro_support::Option::Some("/rustc-dev/a36d05efab632d1ddf902b6a5c33b6d5d3b64131/compiler/rustc_hir_analysis/src/hir_ty_lowering/mod.rs"),
                        ::tracing_core::__macro_support::Option::Some(2184u32),
                        ::tracing_core::__macro_support::Option::Some("rustc_hir_analysis::hir_ty_lowering"),
                        ::tracing_core::field::FieldSet::new(&[{
                                            const NAME:
                                                ::tracing::__macro_support::FieldName<{
                                                    ::tracing::__macro_support::FieldName::len("generic_segments")
                                                }> =
                                                ::tracing::__macro_support::FieldName::new("generic_segments");
                                            NAME.as_str()
                                        }], ::tracing_core::callsite::Identifier(&__CALLSITE)),
                        ::tracing::metadata::Kind::EVENT)
                };
            ::tracing::callsite::DefaultCallsite::new(&META)
        };
    let enabled =
        ::tracing::Level::DEBUG <= ::tracing::level_filters::STATIC_MAX_LEVEL
                &&
                ::tracing::Level::DEBUG <=
                    ::tracing::level_filters::LevelFilter::current() &&
            {
                let interest = __CALLSITE.interest();
                !interest.is_never() &&
                    ::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
                        interest)
            };
    if enabled {
        (|value_set: ::tracing::field::ValueSet|
                    {
                        let meta = __CALLSITE.metadata();
                        ::tracing::Event::dispatch(meta, &value_set);
                        ;
                    })({
                #[allow(unused_imports)]
                use ::tracing::field::{debug, display, Value};
                __CALLSITE.metadata().fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&generic_segments)
                                            as &dyn ::tracing::field::Value))])
            });
    } else { ; }
};debug!(?generic_segments);
2185
2186        generic_segments
2187    }
2188
2189    /// Lower a [resolved][hir::QPath::Resolved] path to a type.
2190    {}
#[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("lower_resolved_ty_path",
                                    "rustc_hir_analysis::hir_ty_lowering",
                                    ::tracing::Level::DEBUG,
                                    ::tracing_core::__macro_support::Option::Some("/rustc-dev/a36d05efab632d1ddf902b6a5c33b6d5d3b64131/compiler/rustc_hir_analysis/src/hir_ty_lowering/mod.rs"),
                                    ::tracing_core::__macro_support::Option::Some(2190u32),
                                    ::tracing_core::__macro_support::Option::Some("rustc_hir_analysis::hir_ty_lowering"),
                                    ::tracing_core::field::FieldSet::new(&[],
                                        ::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,
                        &{ meta.fields().value_set_all(&[]) })
                } 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: Ty<'tcx> = loop {};
            return __tracing_attr_fake_return;
        }
        {
            {
                use ::tracing::__macro_support::Callsite as _;
                static __CALLSITE: ::tracing::callsite::DefaultCallsite =
                    {
                        static META: ::tracing::Metadata<'static> =
                            {
                                ::tracing_core::metadata::Metadata::new("event /rustc-dev/a36d05efab632d1ddf902b6a5c33b6d5d3b64131/compiler/rustc_hir_analysis/src/hir_ty_lowering/mod.rs:2198",
                                    "rustc_hir_analysis::hir_ty_lowering",
                                    ::tracing::Level::DEBUG,
                                    ::tracing_core::__macro_support::Option::Some("/rustc-dev/a36d05efab632d1ddf902b6a5c33b6d5d3b64131/compiler/rustc_hir_analysis/src/hir_ty_lowering/mod.rs"),
                                    ::tracing_core::__macro_support::Option::Some(2198u32),
                                    ::tracing_core::__macro_support::Option::Some("rustc_hir_analysis::hir_ty_lowering"),
                                    ::tracing_core::field::FieldSet::new(&[{
                                                        const NAME:
                                                            ::tracing::__macro_support::FieldName<{
                                                                ::tracing::__macro_support::FieldName::len("path.res")
                                                            }> =
                                                            ::tracing::__macro_support::FieldName::new("path.res");
                                                        NAME.as_str()
                                                    },
                                                    {
                                                        const NAME:
                                                            ::tracing::__macro_support::FieldName<{
                                                                ::tracing::__macro_support::FieldName::len("opt_self_ty")
                                                            }> =
                                                            ::tracing::__macro_support::FieldName::new("opt_self_ty");
                                                        NAME.as_str()
                                                    },
                                                    {
                                                        const NAME:
                                                            ::tracing::__macro_support::FieldName<{
                                                                ::tracing::__macro_support::FieldName::len("path.segments")
                                                            }> =
                                                            ::tracing::__macro_support::FieldName::new("path.segments");
                                                        NAME.as_str()
                                                    }], ::tracing_core::callsite::Identifier(&__CALLSITE)),
                                    ::tracing::metadata::Kind::EVENT)
                            };
                        ::tracing::callsite::DefaultCallsite::new(&META)
                    };
                let enabled =
                    ::tracing::Level::DEBUG <=
                                ::tracing::level_filters::STATIC_MAX_LEVEL &&
                            ::tracing::Level::DEBUG <=
                                ::tracing::level_filters::LevelFilter::current() &&
                        {
                            let interest = __CALLSITE.interest();
                            !interest.is_never() &&
                                ::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
                                    interest)
                        };
                if enabled {
                    (|value_set: ::tracing::field::ValueSet|
                                {
                                    let meta = __CALLSITE.metadata();
                                    ::tracing::Event::dispatch(meta, &value_set);
                                    ;
                                })({
                            #[allow(unused_imports)]
                            use ::tracing::field::{debug, display, Value};
                            __CALLSITE.metadata().fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&path.res)
                                                        as &dyn ::tracing::field::Value)),
                                            (::tracing::__macro_support::Option::Some(&::tracing::field::debug(&opt_self_ty)
                                                        as &dyn ::tracing::field::Value)),
                                            (::tracing::__macro_support::Option::Some(&::tracing::field::debug(&path.segments)
                                                        as &dyn ::tracing::field::Value))])
                        });
                } else { ; }
            };
            let tcx = self.tcx();
            let span = path.span;
            match path.res {
                Res::Def(DefKind::OpaqueTy, did) => {
                    {
                        match tcx.opaque_ty_origin(did) {
                            hir::OpaqueTyOrigin::TyAlias { .. } => {}
                            ref left_val => {
                                ::core::panicking::assert_matches_failed(left_val,
                                    "hir::OpaqueTyOrigin::TyAlias { .. }",
                                    ::core::option::Option::None);
                            }
                        }
                    };
                    let [leading_segments @ .., segment] =
                        path.segments else {
                            ::rustc_middle::util::bug::bug_fmt(format_args!("impossible case reached"))
                        };
                    let _ =
                        self.prohibit_generic_args(leading_segments.iter(),
                            GenericsArgsErrExtend::OpaqueTy);
                    let args =
                        self.lower_generic_args_of_path_segment(span, did, segment);
                    Ty::new_opaque(tcx, ty::IsRigid::No, did, args)
                }
                Res::Def(DefKind::Enum | DefKind::TyAlias | DefKind::Struct |
                    DefKind::Union | DefKind::ForeignTy, did) => {
                    {
                        match (&opt_self_ty, &None) {
                            (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);
                                }
                            }
                        }
                    };
                    let [leading_segments @ .., segment] =
                        path.segments else {
                            ::rustc_middle::util::bug::bug_fmt(format_args!("impossible case reached"))
                        };
                    let _ =
                        self.prohibit_generic_args(leading_segments.iter(),
                            GenericsArgsErrExtend::None);
                    self.lower_path_segment(span, did, segment)
                }
                Res::Def(kind @ DefKind::Variant, def_id) if
                    let PermitVariants::Yes = permit_variants => {
                    {
                        match (&opt_self_ty, &None) {
                            (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);
                                }
                            }
                        }
                    };
                    let generic_segments =
                        self.probe_generic_path_segments(path.segments, None, kind,
                            def_id, span);
                    let indices: FxHashSet<_> =
                        generic_segments.iter().map(|GenericPathSegment(_, index)|
                                    index).collect();
                    let _ =
                        self.prohibit_generic_args(path.segments.iter().enumerate().filter_map(|(index,
                                        seg)|
                                    {
                                        if !indices.contains(&index) { Some(seg) } else { None }
                                    }), GenericsArgsErrExtend::DefVariant(&path.segments));
                    let &GenericPathSegment(def_id, index) =
                        generic_segments.last().unwrap();
                    self.lower_path_segment(span, def_id, &path.segments[index])
                }
                Res::Def(DefKind::TyParam, def_id) => {
                    {
                        match (&opt_self_ty, &None) {
                            (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);
                                }
                            }
                        }
                    };
                    let _ =
                        self.prohibit_generic_args(path.segments.iter(),
                            GenericsArgsErrExtend::Param(def_id));
                    self.lower_ty_param(hir_id)
                }
                Res::SelfTyParam { .. } => {
                    {
                        match (&opt_self_ty, &None) {
                            (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);
                                }
                            }
                        }
                    };
                    let _ =
                        self.prohibit_generic_args(path.segments.iter(),
                            if let [hir::PathSegment { args: Some(args), ident, .. }] =
                                    &path.segments {
                                GenericsArgsErrExtend::SelfTyParam(ident.span.shrink_to_hi().to(args.span_ext))
                            } else { GenericsArgsErrExtend::None });
                    self.check_param_uses_if_mcg(tcx.types.self_param, span,
                        false)
                }
                Res::SelfTyAlias { alias_to: def_id, .. } => {
                    {
                        match (&opt_self_ty, &None) {
                            (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);
                                }
                            }
                        }
                    };
                    let ty =
                        tcx.at(span).type_of(def_id).instantiate_identity().skip_norm_wip();
                    let _ =
                        self.prohibit_generic_args(path.segments.iter(),
                            GenericsArgsErrExtend::SelfTyAlias { def_id, span });
                    self.check_param_uses_if_mcg(ty, span, true)
                }
                Res::Def(DefKind::AssocTy, def_id) => {
                    let trait_segment =
                        if let [modules @ .., trait_, _item] = path.segments {
                            let _ =
                                self.prohibit_generic_args(modules.iter(),
                                    GenericsArgsErrExtend::None);
                            Some(trait_)
                        } else { None };
                    self.lower_resolved_assoc_ty_path(span, opt_self_ty, def_id,
                        trait_segment, path.segments.last().unwrap())
                }
                Res::PrimTy(prim_ty) => {
                    {
                        match (&opt_self_ty, &None) {
                            (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);
                                }
                            }
                        }
                    };
                    let _ =
                        self.prohibit_generic_args(path.segments.iter(),
                            GenericsArgsErrExtend::PrimTy(prim_ty));
                    match prim_ty {
                        hir::PrimTy::Bool => tcx.types.bool,
                        hir::PrimTy::Char => tcx.types.char,
                        hir::PrimTy::Int(it) => Ty::new_int(tcx, it),
                        hir::PrimTy::Uint(uit) => Ty::new_uint(tcx, uit),
                        hir::PrimTy::Float(ft) => Ty::new_float(tcx, ft),
                        hir::PrimTy::Str => tcx.types.str_,
                    }
                }
                Res::Err => {
                    let e =
                        self.tcx().dcx().span_delayed_bug(path.span,
                            "path with `Res::Err` but no error emitted");
                    Ty::new_error(tcx, e)
                }
                Res::Def(..) => {
                    {
                        match (&path.segments.get(0).map(|seg| seg.ident.name),
                                &Some(kw::SelfUpper)) {
                            (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::Some(format_args!("only expected incorrect resolution for `Self`")));
                                }
                            }
                        }
                    };
                    Ty::new_error(self.tcx(),
                        self.dcx().span_delayed_bug(span,
                            "incorrect resolution for `Self`"))
                }
                _ =>
                    ::rustc_middle::util::bug::span_bug_fmt(span,
                        format_args!("unexpected resolution: {0:?}", path.res)),
            }
        }
    }
}#[instrument(level = "debug", skip_all)]
2191    pub fn lower_resolved_ty_path(
2192        &self,
2193        opt_self_ty: Option<Ty<'tcx>>,
2194        path: &hir::Path<'_>,
2195        hir_id: HirId,
2196        permit_variants: PermitVariants,
2197    ) -> Ty<'tcx> {
2198        debug!(?path.res, ?opt_self_ty, ?path.segments);
2199        let tcx = self.tcx();
2200
2201        let span = path.span;
2202        match path.res {
2203            Res::Def(DefKind::OpaqueTy, did) => {
2204                // Check for desugared `impl Trait`.
2205                assert_matches!(tcx.opaque_ty_origin(did), hir::OpaqueTyOrigin::TyAlias { .. });
2206                let [leading_segments @ .., segment] = path.segments else { bug!() };
2207                let _ = self.prohibit_generic_args(
2208                    leading_segments.iter(),
2209                    GenericsArgsErrExtend::OpaqueTy,
2210                );
2211                let args = self.lower_generic_args_of_path_segment(span, did, segment);
2212                Ty::new_opaque(tcx, ty::IsRigid::No, did, args)
2213            }
2214            Res::Def(
2215                DefKind::Enum
2216                | DefKind::TyAlias
2217                | DefKind::Struct
2218                | DefKind::Union
2219                | DefKind::ForeignTy,
2220                did,
2221            ) => {
2222                assert_eq!(opt_self_ty, None);
2223                let [leading_segments @ .., segment] = path.segments else { bug!() };
2224                let _ = self
2225                    .prohibit_generic_args(leading_segments.iter(), GenericsArgsErrExtend::None);
2226                self.lower_path_segment(span, did, segment)
2227            }
2228            Res::Def(kind @ DefKind::Variant, def_id)
2229                if let PermitVariants::Yes = permit_variants =>
2230            {
2231                // Lower "variant type" as if it were a real type.
2232                // The resulting `Ty` is type of the variant's enum for now.
2233                assert_eq!(opt_self_ty, None);
2234
2235                let generic_segments =
2236                    self.probe_generic_path_segments(path.segments, None, kind, def_id, span);
2237                let indices: FxHashSet<_> =
2238                    generic_segments.iter().map(|GenericPathSegment(_, index)| index).collect();
2239                let _ = self.prohibit_generic_args(
2240                    path.segments.iter().enumerate().filter_map(|(index, seg)| {
2241                        if !indices.contains(&index) { Some(seg) } else { None }
2242                    }),
2243                    GenericsArgsErrExtend::DefVariant(&path.segments),
2244                );
2245
2246                let &GenericPathSegment(def_id, index) = generic_segments.last().unwrap();
2247                self.lower_path_segment(span, def_id, &path.segments[index])
2248            }
2249            Res::Def(DefKind::TyParam, def_id) => {
2250                assert_eq!(opt_self_ty, None);
2251                let _ = self.prohibit_generic_args(
2252                    path.segments.iter(),
2253                    GenericsArgsErrExtend::Param(def_id),
2254                );
2255                self.lower_ty_param(hir_id)
2256            }
2257            Res::SelfTyParam { .. } => {
2258                // `Self` in trait or type alias.
2259                assert_eq!(opt_self_ty, None);
2260                let _ = self.prohibit_generic_args(
2261                    path.segments.iter(),
2262                    if let [hir::PathSegment { args: Some(args), ident, .. }] = &path.segments {
2263                        GenericsArgsErrExtend::SelfTyParam(
2264                            ident.span.shrink_to_hi().to(args.span_ext),
2265                        )
2266                    } else {
2267                        GenericsArgsErrExtend::None
2268                    },
2269                );
2270                self.check_param_uses_if_mcg(tcx.types.self_param, span, false)
2271            }
2272            Res::SelfTyAlias { alias_to: def_id, .. } => {
2273                // `Self` in impl (we know the concrete type).
2274                assert_eq!(opt_self_ty, None);
2275                // Try to evaluate any array length constants.
2276                let ty = tcx.at(span).type_of(def_id).instantiate_identity().skip_norm_wip();
2277                let _ = self.prohibit_generic_args(
2278                    path.segments.iter(),
2279                    GenericsArgsErrExtend::SelfTyAlias { def_id, span },
2280                );
2281                self.check_param_uses_if_mcg(ty, span, true)
2282            }
2283            Res::Def(DefKind::AssocTy, def_id) => {
2284                let trait_segment = if let [modules @ .., trait_, _item] = path.segments {
2285                    let _ = self.prohibit_generic_args(modules.iter(), GenericsArgsErrExtend::None);
2286                    Some(trait_)
2287                } else {
2288                    None
2289                };
2290                self.lower_resolved_assoc_ty_path(
2291                    span,
2292                    opt_self_ty,
2293                    def_id,
2294                    trait_segment,
2295                    path.segments.last().unwrap(),
2296                )
2297            }
2298            Res::PrimTy(prim_ty) => {
2299                assert_eq!(opt_self_ty, None);
2300                let _ = self.prohibit_generic_args(
2301                    path.segments.iter(),
2302                    GenericsArgsErrExtend::PrimTy(prim_ty),
2303                );
2304                match prim_ty {
2305                    hir::PrimTy::Bool => tcx.types.bool,
2306                    hir::PrimTy::Char => tcx.types.char,
2307                    hir::PrimTy::Int(it) => Ty::new_int(tcx, it),
2308                    hir::PrimTy::Uint(uit) => Ty::new_uint(tcx, uit),
2309                    hir::PrimTy::Float(ft) => Ty::new_float(tcx, ft),
2310                    hir::PrimTy::Str => tcx.types.str_,
2311                }
2312            }
2313            Res::Err => {
2314                let e = self
2315                    .tcx()
2316                    .dcx()
2317                    .span_delayed_bug(path.span, "path with `Res::Err` but no error emitted");
2318                Ty::new_error(tcx, e)
2319            }
2320            Res::Def(..) => {
2321                assert_eq!(
2322                    path.segments.get(0).map(|seg| seg.ident.name),
2323                    Some(kw::SelfUpper),
2324                    "only expected incorrect resolution for `Self`"
2325                );
2326                Ty::new_error(
2327                    self.tcx(),
2328                    self.dcx().span_delayed_bug(span, "incorrect resolution for `Self`"),
2329                )
2330            }
2331            _ => span_bug!(span, "unexpected resolution: {:?}", path.res),
2332        }
2333    }
2334
2335    /// Lower a type parameter from the HIR to our internal notion of a type.
2336    ///
2337    /// Early-bound type parameters get lowered to [`ty::Param`]
2338    /// and late-bound ones to [`ty::Bound`].
2339    pub(crate) fn lower_ty_param(&self, hir_id: HirId) -> Ty<'tcx> {
2340        let tcx = self.tcx();
2341
2342        let ty = match tcx.named_bound_var(hir_id) {
2343            Some(rbv::ResolvedArg::LateBound(debruijn, index, def_id)) => {
2344                let br = ty::BoundTy {
2345                    var: ty::BoundVar::from_u32(index),
2346                    kind: ty::BoundTyKind::Param(def_id.to_def_id()),
2347                };
2348                Ty::new_bound(tcx, debruijn, br)
2349            }
2350            Some(rbv::ResolvedArg::EarlyBound(def_id)) => {
2351                let item_def_id = tcx.hir_ty_param_owner(def_id);
2352                let generics = tcx.generics_of(item_def_id);
2353                let index = generics.param_def_id_to_index[&def_id.to_def_id()];
2354                Ty::new_param(tcx, index, tcx.hir_ty_param_name(def_id))
2355            }
2356            Some(rbv::ResolvedArg::Error(guar)) => Ty::new_error(tcx, guar),
2357            arg => ::rustc_middle::util::bug::bug_fmt(format_args!("unexpected bound var resolution for {0:?}: {1:?}",
        hir_id, arg))bug!("unexpected bound var resolution for {hir_id:?}: {arg:?}"),
2358        };
2359        self.check_param_uses_if_mcg(ty, tcx.hir_span(hir_id), false)
2360    }
2361
2362    /// Lower a const parameter from the HIR to our internal notion of a constant.
2363    ///
2364    /// Early-bound const parameters get lowered to [`ty::ConstKind::Param`]
2365    /// and late-bound ones to [`ty::ConstKind::Bound`].
2366    pub(crate) fn lower_const_param(&self, param_def_id: DefId, path_hir_id: HirId) -> Const<'tcx> {
2367        let tcx = self.tcx();
2368
2369        let ct = match tcx.named_bound_var(path_hir_id) {
2370            Some(rbv::ResolvedArg::EarlyBound(_)) => {
2371                // Find the name and index of the const parameter by indexing the generics of
2372                // the parent item and construct a `ParamConst`.
2373                let item_def_id = tcx.parent(param_def_id);
2374                let generics = tcx.generics_of(item_def_id);
2375                let index = generics.param_def_id_to_index[&param_def_id];
2376                let name = tcx.item_name(param_def_id);
2377                ty::Const::new_param(tcx, ty::ParamConst::new(index, name))
2378            }
2379            Some(rbv::ResolvedArg::LateBound(debruijn, index, _)) => ty::Const::new_bound(
2380                tcx,
2381                debruijn,
2382                ty::BoundConst::new(ty::BoundVar::from_u32(index)),
2383            ),
2384            Some(rbv::ResolvedArg::Error(guar)) => ty::Const::new_error(tcx, guar),
2385            arg => ::rustc_middle::util::bug::bug_fmt(format_args!("unexpected bound var resolution for {0:?}: {1:?}",
        path_hir_id, arg))bug!("unexpected bound var resolution for {:?}: {arg:?}", path_hir_id),
2386        };
2387        self.check_param_uses_if_mcg(ct, tcx.hir_span(path_hir_id), false)
2388    }
2389
2390    /// Lower a [`hir::ConstArg`] to a (type-level) [`ty::Const`].
2391    {}
#[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("lower_const_arg",
                                    "rustc_hir_analysis::hir_ty_lowering",
                                    ::tracing::Level::DEBUG,
                                    ::tracing_core::__macro_support::Option::Some("/rustc-dev/a36d05efab632d1ddf902b6a5c33b6d5d3b64131/compiler/rustc_hir_analysis/src/hir_ty_lowering/mod.rs"),
                                    ::tracing_core::__macro_support::Option::Some(2391u32),
                                    ::tracing_core::__macro_support::Option::Some("rustc_hir_analysis::hir_ty_lowering"),
                                    ::tracing_core::field::FieldSet::new(&[{
                                                        const NAME:
                                                            ::tracing::__macro_support::FieldName<{
                                                                ::tracing::__macro_support::FieldName::len("const_arg")
                                                            }> =
                                                            ::tracing::__macro_support::FieldName::new("const_arg");
                                                        NAME.as_str()
                                                    },
                                                    {
                                                        const NAME:
                                                            ::tracing::__macro_support::FieldName<{
                                                                ::tracing::__macro_support::FieldName::len("ty")
                                                            }> =
                                                            ::tracing::__macro_support::FieldName::new("ty");
                                                        NAME.as_str()
                                                    }], ::tracing_core::callsite::Identifier(&__CALLSITE)),
                                    ::tracing::metadata::Kind::SPAN)
                            };
                        ::tracing::callsite::DefaultCallsite::new(&META)
                    };
                let mut interest = ::tracing::subscriber::Interest::never();
                if ::tracing::Level::DEBUG <=
                                    ::tracing::level_filters::STATIC_MAX_LEVEL &&
                                ::tracing::Level::DEBUG <=
                                    ::tracing::level_filters::LevelFilter::current() &&
                            { interest = __CALLSITE.interest(); !interest.is_never() }
                        &&
                        ::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
                            interest) {
                    let meta = __CALLSITE.metadata();
                    ::tracing::Span::new(meta,
                        &{
                                #[allow(unused_imports)]
                                use ::tracing::field::{debug, display, Value};
                                meta.fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&const_arg)
                                                            as &dyn ::tracing::field::Value)),
                                                (::tracing::__macro_support::Option::Some(&::tracing::field::debug(&ty)
                                                            as &dyn ::tracing::field::Value))])
                            })
                } else {
                    let span =
                        ::tracing::__macro_support::__disabled_span(__CALLSITE.metadata());
                    {};
                    span
                }
            };
        __tracing_attr_guard = __tracing_attr_span.enter();
    }

    #[warn(clippy :: suspicious_else_formatting)]
    {

        #[allow(unknown_lints, unreachable_code, clippy ::
        diverging_sub_expression, clippy :: empty_loop, clippy ::
        let_unit_value, clippy :: let_with_type_underscore, clippy ::
        needless_return, clippy :: unreachable)]
        if false {
            let __tracing_attr_fake_return: Const<'tcx> = loop {};
            return __tracing_attr_fake_return;
        }
        {
            let tcx = self.tcx();
            if let hir::ConstArgKind::Anon(anon) = &const_arg.kind {
                if tcx.features().generic_const_parameter_types() &&
                        (ty.has_free_regions() || ty.has_erased_regions()) {
                    let e =
                        self.dcx().span_err(const_arg.span,
                            "anonymous constants with lifetimes in their type are not yet supported");
                    tcx.feed_anon_const_type(anon.def_id,
                        ty::EarlyBinder::bind(tcx, Ty::new_error(tcx, e)));
                    return ty::Const::new_error(tcx, e);
                }
                if ty.has_non_region_infer() {
                    let e =
                        self.dcx().span_err(const_arg.span,
                            "anonymous constants with inferred types are not yet supported");
                    tcx.feed_anon_const_type(anon.def_id,
                        ty::EarlyBinder::bind(tcx, Ty::new_error(tcx, e)));
                    return ty::Const::new_error(tcx, e);
                }
                if ty.has_non_region_param() {
                    let e =
                        self.dcx().span_err(const_arg.span,
                            "anonymous constants referencing generics are not yet supported");
                    tcx.feed_anon_const_type(anon.def_id,
                        ty::EarlyBinder::bind(tcx, Ty::new_error(tcx, e)));
                    return ty::Const::new_error(tcx, e);
                }
                tcx.feed_anon_const_type(anon.def_id,
                    ty::EarlyBinder::bind(tcx, ty));
            }
            let hir_id = const_arg.hir_id;
            match const_arg.kind {
                hir::ConstArgKind::Tup(exprs) =>
                    self.lower_const_arg_tup(exprs, ty, const_arg.span),
                hir::ConstArgKind::Path(hir::QPath::Resolved(maybe_qself,
                    path)) => {
                    {
                        use ::tracing::__macro_support::Callsite as _;
                        static __CALLSITE: ::tracing::callsite::DefaultCallsite =
                            {
                                static META: ::tracing::Metadata<'static> =
                                    {
                                        ::tracing_core::metadata::Metadata::new("event /rustc-dev/a36d05efab632d1ddf902b6a5c33b6d5d3b64131/compiler/rustc_hir_analysis/src/hir_ty_lowering/mod.rs:2452",
                                            "rustc_hir_analysis::hir_ty_lowering",
                                            ::tracing::Level::DEBUG,
                                            ::tracing_core::__macro_support::Option::Some("/rustc-dev/a36d05efab632d1ddf902b6a5c33b6d5d3b64131/compiler/rustc_hir_analysis/src/hir_ty_lowering/mod.rs"),
                                            ::tracing_core::__macro_support::Option::Some(2452u32),
                                            ::tracing_core::__macro_support::Option::Some("rustc_hir_analysis::hir_ty_lowering"),
                                            ::tracing_core::field::FieldSet::new(&[{
                                                                const NAME:
                                                                    ::tracing::__macro_support::FieldName<{
                                                                        ::tracing::__macro_support::FieldName::len("maybe_qself")
                                                                    }> =
                                                                    ::tracing::__macro_support::FieldName::new("maybe_qself");
                                                                NAME.as_str()
                                                            },
                                                            {
                                                                const NAME:
                                                                    ::tracing::__macro_support::FieldName<{
                                                                        ::tracing::__macro_support::FieldName::len("path")
                                                                    }> =
                                                                    ::tracing::__macro_support::FieldName::new("path");
                                                                NAME.as_str()
                                                            }], ::tracing_core::callsite::Identifier(&__CALLSITE)),
                                            ::tracing::metadata::Kind::EVENT)
                                    };
                                ::tracing::callsite::DefaultCallsite::new(&META)
                            };
                        let enabled =
                            ::tracing::Level::DEBUG <=
                                        ::tracing::level_filters::STATIC_MAX_LEVEL &&
                                    ::tracing::Level::DEBUG <=
                                        ::tracing::level_filters::LevelFilter::current() &&
                                {
                                    let interest = __CALLSITE.interest();
                                    !interest.is_never() &&
                                        ::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
                                            interest)
                                };
                        if enabled {
                            (|value_set: ::tracing::field::ValueSet|
                                        {
                                            let meta = __CALLSITE.metadata();
                                            ::tracing::Event::dispatch(meta, &value_set);
                                            ;
                                        })({
                                    #[allow(unused_imports)]
                                    use ::tracing::field::{debug, display, Value};
                                    __CALLSITE.metadata().fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&maybe_qself)
                                                                as &dyn ::tracing::field::Value)),
                                                    (::tracing::__macro_support::Option::Some(&::tracing::field::debug(&path)
                                                                as &dyn ::tracing::field::Value))])
                                });
                        } else { ; }
                    };
                    let opt_self_ty =
                        maybe_qself.as_ref().map(|qself| self.lower_ty(qself));
                    self.lower_resolved_const_path(opt_self_ty, path, hir_id)
                }
                hir::ConstArgKind::Path(hir::QPath::TypeRelative(hir_self_ty,
                    segment)) => {
                    {
                        use ::tracing::__macro_support::Callsite as _;
                        static __CALLSITE: ::tracing::callsite::DefaultCallsite =
                            {
                                static META: ::tracing::Metadata<'static> =
                                    {
                                        ::tracing_core::metadata::Metadata::new("event /rustc-dev/a36d05efab632d1ddf902b6a5c33b6d5d3b64131/compiler/rustc_hir_analysis/src/hir_ty_lowering/mod.rs:2457",
                                            "rustc_hir_analysis::hir_ty_lowering",
                                            ::tracing::Level::DEBUG,
                                            ::tracing_core::__macro_support::Option::Some("/rustc-dev/a36d05efab632d1ddf902b6a5c33b6d5d3b64131/compiler/rustc_hir_analysis/src/hir_ty_lowering/mod.rs"),
                                            ::tracing_core::__macro_support::Option::Some(2457u32),
                                            ::tracing_core::__macro_support::Option::Some("rustc_hir_analysis::hir_ty_lowering"),
                                            ::tracing_core::field::FieldSet::new(&[{
                                                                const NAME:
                                                                    ::tracing::__macro_support::FieldName<{
                                                                        ::tracing::__macro_support::FieldName::len("hir_self_ty")
                                                                    }> =
                                                                    ::tracing::__macro_support::FieldName::new("hir_self_ty");
                                                                NAME.as_str()
                                                            },
                                                            {
                                                                const NAME:
                                                                    ::tracing::__macro_support::FieldName<{
                                                                        ::tracing::__macro_support::FieldName::len("segment")
                                                                    }> =
                                                                    ::tracing::__macro_support::FieldName::new("segment");
                                                                NAME.as_str()
                                                            }], ::tracing_core::callsite::Identifier(&__CALLSITE)),
                                            ::tracing::metadata::Kind::EVENT)
                                    };
                                ::tracing::callsite::DefaultCallsite::new(&META)
                            };
                        let enabled =
                            ::tracing::Level::DEBUG <=
                                        ::tracing::level_filters::STATIC_MAX_LEVEL &&
                                    ::tracing::Level::DEBUG <=
                                        ::tracing::level_filters::LevelFilter::current() &&
                                {
                                    let interest = __CALLSITE.interest();
                                    !interest.is_never() &&
                                        ::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
                                            interest)
                                };
                        if enabled {
                            (|value_set: ::tracing::field::ValueSet|
                                        {
                                            let meta = __CALLSITE.metadata();
                                            ::tracing::Event::dispatch(meta, &value_set);
                                            ;
                                        })({
                                    #[allow(unused_imports)]
                                    use ::tracing::field::{debug, display, Value};
                                    __CALLSITE.metadata().fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&hir_self_ty)
                                                                as &dyn ::tracing::field::Value)),
                                                    (::tracing::__macro_support::Option::Some(&::tracing::field::debug(&segment)
                                                                as &dyn ::tracing::field::Value))])
                                });
                        } else { ; }
                    };
                    let self_ty = self.lower_ty(hir_self_ty);
                    self.lower_type_relative_const_path(self_ty, hir_self_ty,
                            segment, hir_id,
                            const_arg.span).unwrap_or_else(|guar|
                            Const::new_error(tcx, guar))
                }
                hir::ConstArgKind::Struct(qpath, inits) => {
                    self.lower_const_arg_struct(hir_id, qpath, inits,
                        const_arg.span)
                }
                hir::ConstArgKind::TupleCall(qpath, args) => {
                    self.lower_const_arg_tuple_call(hir_id, qpath, args,
                        const_arg.span)
                }
                hir::ConstArgKind::Array(array_expr) =>
                    self.lower_const_arg_array(array_expr, ty),
                hir::ConstArgKind::Anon(anon) =>
                    self.lower_const_arg_anon(anon),
                hir::ConstArgKind::Infer(()) =>
                    self.ct_infer(None, const_arg.span),
                hir::ConstArgKind::Error(e) => ty::Const::new_error(tcx, e),
                hir::ConstArgKind::Literal { lit, negated } => {
                    self.lower_const_arg_literal(&lit, negated, ty,
                        const_arg.span)
                }
            }
        }
    }
}#[instrument(skip(self), level = "debug")]
2392    pub fn lower_const_arg(&self, const_arg: &hir::ConstArg<'_>, ty: Ty<'tcx>) -> Const<'tcx> {
2393        let tcx = self.tcx();
2394
2395        if let hir::ConstArgKind::Anon(anon) = &const_arg.kind {
2396            // FIXME(generic_const_parameter_types): Ideally we remove these errors below when
2397            // we have the ability to intermix typeck of anon const const args with the parent
2398            // bodies typeck.
2399
2400            // We also error if the type contains any regions as effectively any region will wind
2401            // up as a region variable in mir borrowck. It would also be somewhat concerning if
2402            // hir typeck was using equality but mir borrowck wound up using subtyping as that could
2403            // result in a non-infer in hir typeck but a region variable in borrowck.
2404            if tcx.features().generic_const_parameter_types()
2405                && (ty.has_free_regions() || ty.has_erased_regions())
2406            {
2407                let e = self.dcx().span_err(
2408                    const_arg.span,
2409                    "anonymous constants with lifetimes in their type are not yet supported",
2410                );
2411                tcx.feed_anon_const_type(
2412                    anon.def_id,
2413                    ty::EarlyBinder::bind(tcx, Ty::new_error(tcx, e)),
2414                );
2415                return ty::Const::new_error(tcx, e);
2416            }
2417            // We must error if the instantiated type has any inference variables as we will
2418            // use this type to feed the `type_of` and query results must not contain inference
2419            // variables otherwise we will ICE.
2420            if ty.has_non_region_infer() {
2421                let e = self.dcx().span_err(
2422                    const_arg.span,
2423                    "anonymous constants with inferred types are not yet supported",
2424                );
2425                tcx.feed_anon_const_type(
2426                    anon.def_id,
2427                    ty::EarlyBinder::bind(tcx, Ty::new_error(tcx, e)),
2428                );
2429                return ty::Const::new_error(tcx, e);
2430            }
2431            // We error when the type contains unsubstituted generics since we do not currently
2432            // give the anon const any of the generics from the parent.
2433            if ty.has_non_region_param() {
2434                let e = self.dcx().span_err(
2435                    const_arg.span,
2436                    "anonymous constants referencing generics are not yet supported",
2437                );
2438                tcx.feed_anon_const_type(
2439                    anon.def_id,
2440                    ty::EarlyBinder::bind(tcx, Ty::new_error(tcx, e)),
2441                );
2442                return ty::Const::new_error(tcx, e);
2443            }
2444
2445            tcx.feed_anon_const_type(anon.def_id, ty::EarlyBinder::bind(tcx, ty));
2446        }
2447
2448        let hir_id = const_arg.hir_id;
2449        match const_arg.kind {
2450            hir::ConstArgKind::Tup(exprs) => self.lower_const_arg_tup(exprs, ty, const_arg.span),
2451            hir::ConstArgKind::Path(hir::QPath::Resolved(maybe_qself, path)) => {
2452                debug!(?maybe_qself, ?path);
2453                let opt_self_ty = maybe_qself.as_ref().map(|qself| self.lower_ty(qself));
2454                self.lower_resolved_const_path(opt_self_ty, path, hir_id)
2455            }
2456            hir::ConstArgKind::Path(hir::QPath::TypeRelative(hir_self_ty, segment)) => {
2457                debug!(?hir_self_ty, ?segment);
2458                let self_ty = self.lower_ty(hir_self_ty);
2459                self.lower_type_relative_const_path(
2460                    self_ty,
2461                    hir_self_ty,
2462                    segment,
2463                    hir_id,
2464                    const_arg.span,
2465                )
2466                .unwrap_or_else(|guar| Const::new_error(tcx, guar))
2467            }
2468            hir::ConstArgKind::Struct(qpath, inits) => {
2469                self.lower_const_arg_struct(hir_id, qpath, inits, const_arg.span)
2470            }
2471            hir::ConstArgKind::TupleCall(qpath, args) => {
2472                self.lower_const_arg_tuple_call(hir_id, qpath, args, const_arg.span)
2473            }
2474            hir::ConstArgKind::Array(array_expr) => self.lower_const_arg_array(array_expr, ty),
2475            hir::ConstArgKind::Anon(anon) => self.lower_const_arg_anon(anon),
2476            hir::ConstArgKind::Infer(()) => self.ct_infer(None, const_arg.span),
2477            hir::ConstArgKind::Error(e) => ty::Const::new_error(tcx, e),
2478            hir::ConstArgKind::Literal { lit, negated } => {
2479                self.lower_const_arg_literal(&lit, negated, ty, const_arg.span)
2480            }
2481        }
2482    }
2483
2484    fn lower_const_arg_array(
2485        &self,
2486        array_expr: &hir::ConstArgArrayExpr<'_>,
2487        ty: Ty<'tcx>,
2488    ) -> Const<'tcx> {
2489        let tcx = self.tcx();
2490
2491        let (elem_ty, len) = match ty.kind() {
2492            ty::Array(elem_ty, len) => (elem_ty, len),
2493            ty::Error(e) => return Const::new_error(tcx, *e),
2494            _ => {
2495                let e = tcx
2496                    .dcx()
2497                    .span_err(array_expr.span, ::alloc::__export::must_use({
        ::alloc::fmt::format(format_args!("expected `{0}`, found const array",
                ty))
    })format!("expected `{ty}`, found const array"));
2498                return Const::new_error(tcx, e);
2499            }
2500        };
2501
2502        let elems = array_expr
2503            .elems
2504            .iter()
2505            .map(|elem| self.lower_const_arg(elem, *elem_ty))
2506            .collect::<Vec<_>>();
2507
2508        let len = tcx
2509            .try_normalize_erasing_regions(
2510                ty::TypingEnv::new(ty::ParamEnv::empty(), TypingMode::non_body_analysis()),
2511                Unnormalized::new_wip(*len),
2512            )
2513            .unwrap_or(*len);
2514        if let Some(expected_len) = len.try_to_target_usize(tcx)
2515            && expected_len != elems.len() as u64
2516        {
2517            let e = tcx.dcx().span_err(
2518                array_expr.span,
2519                ::alloc::__export::must_use({
        ::alloc::fmt::format(format_args!("expected array with {1} elements, found {0} elements",
                array_expr.elems.len(), expected_len))
    })format!(
2520                    "expected array with {expected_len} elements, found {} elements",
2521                    array_expr.elems.len()
2522                ),
2523            );
2524            return Const::new_error(tcx, e);
2525        }
2526
2527        let valtree = ty::ValTree::from_branches(tcx, elems);
2528
2529        ty::Const::new_value(tcx, valtree, ty)
2530    }
2531
2532    fn try_recover_misrepresented_function_call(
2533        &self,
2534        hir_self_ty: &hir::Ty<'_>,
2535        span: Span,
2536    ) -> Option<ErrorGuaranteed> {
2537        // Only an enum can host a tuple-variant constructor (`<Option<u32>>::Some(..)`).
2538        // For any other self type, a type-relative call is an associated function, not a
2539        // constructor, and must be wrapped in `const { ... }`. We catch that here, before
2540        // lowering the self type, so a generic struct/union written without its args
2541        // (`FieldName::len()`, from `tracing`'s macros) reports this clear error instead
2542        // of a spurious E0107 "missing generics" (#157152), and a primitive or foreign
2543        // type reports it instead of an opaque downstream resolution error. Enums,
2544        // aliases, `Self` and type parameters are let through: each may resolve to an
2545        // enum, so they must reach constructor lowering.
2546        let self_ty_res = match hir_self_ty.kind {
2547            hir::TyKind::Path(hir::QPath::Resolved(_, path)) => path.res,
2548            _ => Res::Err,
2549        };
2550        #[allow(non_exhaustive_omitted_patterns)] match self_ty_res {
    Res::Def(DefKind::Struct | DefKind::Union | DefKind::ForeignTy, _) |
        Res::PrimTy(_) => true,
    _ => false,
}matches!(
2551            self_ty_res,
2552            Res::Def(DefKind::Struct | DefKind::Union | DefKind::ForeignTy, _) | Res::PrimTy(_)
2553        )
2554        .then(|| self.dcx().emit_err(diagnostics::ComplexConstArg { span }))
2555    }
2556
2557    fn lower_const_arg_tuple_call(
2558        &self,
2559        hir_id: HirId,
2560        qpath: hir::QPath<'_>,
2561        args: &[&hir::ConstArg<'_>],
2562        span: Span,
2563    ) -> Const<'tcx> {
2564        let tcx = self.tcx();
2565
2566        let non_adt_or_variant_res = || {
2567            let e = tcx.dcx().span_err(span, "tuple constructor with invalid base path");
2568            ty::Const::new_error(tcx, e)
2569        };
2570
2571        let ctor_const = match qpath {
2572            hir::QPath::Resolved(maybe_qself, path) => {
2573                let opt_self_ty = maybe_qself.as_ref().map(|qself| self.lower_ty(qself));
2574                self.lower_resolved_const_path(opt_self_ty, path, hir_id)
2575            }
2576            hir::QPath::TypeRelative(hir_self_ty, segment) => {
2577                if let Some(e) = self.try_recover_misrepresented_function_call(hir_self_ty, span) {
2578                    return ty::Const::new_error(tcx, e);
2579                }
2580
2581                let self_ty = self.lower_ty(hir_self_ty);
2582                match self.lower_type_relative_const_path(
2583                    self_ty,
2584                    hir_self_ty,
2585                    segment,
2586                    hir_id,
2587                    span,
2588                ) {
2589                    Ok(c) => c,
2590                    Err(_) => return non_adt_or_variant_res(),
2591                }
2592            }
2593        };
2594
2595        let Some(value) = ctor_const.try_to_value() else {
2596            return non_adt_or_variant_res();
2597        };
2598
2599        let (adt_def, adt_args, variant_did) = match value.ty.kind() {
2600            ty::FnDef(def_id, fn_args)
2601                if let DefKind::Ctor(CtorOf::Variant, _) = tcx.def_kind(*def_id) =>
2602            {
2603                let parent_did = tcx.parent(*def_id);
2604                let enum_did = tcx.parent(parent_did);
2605                (tcx.adt_def(enum_did), fn_args, parent_did)
2606            }
2607            ty::FnDef(def_id, fn_args)
2608                if let DefKind::Ctor(CtorOf::Struct, _) = tcx.def_kind(*def_id) =>
2609            {
2610                let parent_did = tcx.parent(*def_id);
2611                (tcx.adt_def(parent_did), fn_args, parent_did)
2612            }
2613            _ => {
2614                let e = self.dcx().emit_err(diagnostics::ComplexConstArg { span });
2615                return Const::new_error(tcx, e);
2616            }
2617        };
2618
2619        let variant_def = adt_def.variant_with_id(variant_did);
2620        let variant_idx = adt_def.variant_index_with_id(variant_did).as_u32();
2621
2622        if args.len() != variant_def.fields.len() {
2623            let e = tcx.dcx().span_err(
2624                span,
2625                ::alloc::__export::must_use({
        ::alloc::fmt::format(format_args!("tuple constructor has {0} arguments but {1} were provided",
                variant_def.fields.len(), args.len()))
    })format!(
2626                    "tuple constructor has {} arguments but {} were provided",
2627                    variant_def.fields.len(),
2628                    args.len()
2629                ),
2630            );
2631            return ty::Const::new_error(tcx, e);
2632        }
2633
2634        let fields = variant_def
2635            .fields
2636            .iter()
2637            .zip(args)
2638            .map(|(field_def, arg)| {
2639                self.lower_const_arg(
2640                    arg,
2641                    tcx.type_of(field_def.did)
2642                        .instantiate(tcx, adt_args.no_bound_vars().unwrap())
2643                        .skip_norm_wip(),
2644                )
2645            })
2646            .collect::<Vec<_>>();
2647
2648        let opt_discr_const = if adt_def.is_enum() {
2649            let valtree = ty::ValTree::from_scalar_int(tcx, variant_idx.into());
2650            Some(ty::Const::new_value(tcx, valtree, tcx.types.u32))
2651        } else {
2652            None
2653        };
2654
2655        let valtree = ty::ValTree::from_branches(tcx, opt_discr_const.into_iter().chain(fields));
2656        let adt_ty = Ty::new_adt(tcx, adt_def, adt_args.no_bound_vars().unwrap());
2657        ty::Const::new_value(tcx, valtree, adt_ty)
2658    }
2659
2660    fn lower_const_arg_tup(
2661        &self,
2662        exprs: &[&hir::ConstArg<'_>],
2663        ty: Ty<'tcx>,
2664        span: Span,
2665    ) -> Const<'tcx> {
2666        let tcx = self.tcx();
2667
2668        let found_tuple = || {
2669            tcx.sess
2670                .source_map()
2671                .span_to_snippet(span)
2672                .map(|snippet| ::alloc::__export::must_use({
        ::alloc::fmt::format(format_args!("`{0}`", snippet))
    })format!("`{snippet}`"))
2673                .unwrap_or_else(|_| "const tuple".to_string())
2674        };
2675
2676        let tys = match ty.kind() {
2677            ty::Tuple(tys) => tys,
2678            ty::Error(e) => return Const::new_error(tcx, *e),
2679            _ => {
2680                let e =
2681                    tcx.dcx().span_err(span, ::alloc::__export::must_use({
        ::alloc::fmt::format(format_args!("expected `{0}`, found {1}", ty,
                found_tuple()))
    })format!("expected `{}`, found {}", ty, found_tuple()));
2682                return Const::new_error(tcx, e);
2683            }
2684        };
2685
2686        if exprs.len() != tys.len() {
2687            let e = tcx.dcx().span_err(span, ::alloc::__export::must_use({
        ::alloc::fmt::format(format_args!("expected `{0}`, found {1}", ty,
                found_tuple()))
    })format!("expected `{}`, found {}", ty, found_tuple()));
2688            return Const::new_error(tcx, e);
2689        }
2690
2691        let exprs = exprs
2692            .iter()
2693            .zip(tys.iter())
2694            .map(|(expr, ty)| self.lower_const_arg(expr, ty))
2695            .collect::<Vec<_>>();
2696
2697        let valtree = ty::ValTree::from_branches(tcx, exprs);
2698        ty::Const::new_value(tcx, valtree, ty)
2699    }
2700
2701    fn lower_const_arg_struct(
2702        &self,
2703        hir_id: HirId,
2704        qpath: hir::QPath<'_>,
2705        inits: &[&hir::ConstArgExprField<'_>],
2706        span: Span,
2707    ) -> Const<'tcx> {
2708        // FIXME(mgca): try to deduplicate this function with
2709        // the equivalent HIR typeck logic.
2710        let tcx = self.tcx();
2711
2712        let non_adt_or_variant_res = || {
2713            let e = tcx.dcx().span_err(span, "struct expression with invalid base path");
2714            ty::Const::new_error(tcx, e)
2715        };
2716
2717        let ResolvedStructPath { res: opt_res, ty } =
2718            self.lower_path_for_struct_expr(qpath, span, hir_id);
2719
2720        let variant_did = match qpath {
2721            hir::QPath::Resolved(maybe_qself, path) => {
2722                {
    use ::tracing::__macro_support::Callsite as _;
    static __CALLSITE: ::tracing::callsite::DefaultCallsite =
        {
            static META: ::tracing::Metadata<'static> =
                {
                    ::tracing_core::metadata::Metadata::new("event /rustc-dev/a36d05efab632d1ddf902b6a5c33b6d5d3b64131/compiler/rustc_hir_analysis/src/hir_ty_lowering/mod.rs:2722",
                        "rustc_hir_analysis::hir_ty_lowering",
                        ::tracing::Level::DEBUG,
                        ::tracing_core::__macro_support::Option::Some("/rustc-dev/a36d05efab632d1ddf902b6a5c33b6d5d3b64131/compiler/rustc_hir_analysis/src/hir_ty_lowering/mod.rs"),
                        ::tracing_core::__macro_support::Option::Some(2722u32),
                        ::tracing_core::__macro_support::Option::Some("rustc_hir_analysis::hir_ty_lowering"),
                        ::tracing_core::field::FieldSet::new(&[{
                                            const NAME:
                                                ::tracing::__macro_support::FieldName<{
                                                    ::tracing::__macro_support::FieldName::len("maybe_qself")
                                                }> =
                                                ::tracing::__macro_support::FieldName::new("maybe_qself");
                                            NAME.as_str()
                                        },
                                        {
                                            const NAME:
                                                ::tracing::__macro_support::FieldName<{
                                                    ::tracing::__macro_support::FieldName::len("path")
                                                }> =
                                                ::tracing::__macro_support::FieldName::new("path");
                                            NAME.as_str()
                                        }], ::tracing_core::callsite::Identifier(&__CALLSITE)),
                        ::tracing::metadata::Kind::EVENT)
                };
            ::tracing::callsite::DefaultCallsite::new(&META)
        };
    let enabled =
        ::tracing::Level::DEBUG <= ::tracing::level_filters::STATIC_MAX_LEVEL
                &&
                ::tracing::Level::DEBUG <=
                    ::tracing::level_filters::LevelFilter::current() &&
            {
                let interest = __CALLSITE.interest();
                !interest.is_never() &&
                    ::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
                        interest)
            };
    if enabled {
        (|value_set: ::tracing::field::ValueSet|
                    {
                        let meta = __CALLSITE.metadata();
                        ::tracing::Event::dispatch(meta, &value_set);
                        ;
                    })({
                #[allow(unused_imports)]
                use ::tracing::field::{debug, display, Value};
                __CALLSITE.metadata().fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&maybe_qself)
                                            as &dyn ::tracing::field::Value)),
                                (::tracing::__macro_support::Option::Some(&::tracing::field::debug(&path)
                                            as &dyn ::tracing::field::Value))])
            });
    } else { ; }
};debug!(?maybe_qself, ?path);
2723                let variant_did = match path.res {
2724                    Res::Def(DefKind::Variant | DefKind::Struct, did) => did,
2725                    _ => return non_adt_or_variant_res(),
2726                };
2727
2728                variant_did
2729            }
2730            hir::QPath::TypeRelative(hir_self_ty, segment) => {
2731                {
    use ::tracing::__macro_support::Callsite as _;
    static __CALLSITE: ::tracing::callsite::DefaultCallsite =
        {
            static META: ::tracing::Metadata<'static> =
                {
                    ::tracing_core::metadata::Metadata::new("event /rustc-dev/a36d05efab632d1ddf902b6a5c33b6d5d3b64131/compiler/rustc_hir_analysis/src/hir_ty_lowering/mod.rs:2731",
                        "rustc_hir_analysis::hir_ty_lowering",
                        ::tracing::Level::DEBUG,
                        ::tracing_core::__macro_support::Option::Some("/rustc-dev/a36d05efab632d1ddf902b6a5c33b6d5d3b64131/compiler/rustc_hir_analysis/src/hir_ty_lowering/mod.rs"),
                        ::tracing_core::__macro_support::Option::Some(2731u32),
                        ::tracing_core::__macro_support::Option::Some("rustc_hir_analysis::hir_ty_lowering"),
                        ::tracing_core::field::FieldSet::new(&[{
                                            const NAME:
                                                ::tracing::__macro_support::FieldName<{
                                                    ::tracing::__macro_support::FieldName::len("hir_self_ty")
                                                }> =
                                                ::tracing::__macro_support::FieldName::new("hir_self_ty");
                                            NAME.as_str()
                                        },
                                        {
                                            const NAME:
                                                ::tracing::__macro_support::FieldName<{
                                                    ::tracing::__macro_support::FieldName::len("segment")
                                                }> =
                                                ::tracing::__macro_support::FieldName::new("segment");
                                            NAME.as_str()
                                        }], ::tracing_core::callsite::Identifier(&__CALLSITE)),
                        ::tracing::metadata::Kind::EVENT)
                };
            ::tracing::callsite::DefaultCallsite::new(&META)
        };
    let enabled =
        ::tracing::Level::DEBUG <= ::tracing::level_filters::STATIC_MAX_LEVEL
                &&
                ::tracing::Level::DEBUG <=
                    ::tracing::level_filters::LevelFilter::current() &&
            {
                let interest = __CALLSITE.interest();
                !interest.is_never() &&
                    ::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
                        interest)
            };
    if enabled {
        (|value_set: ::tracing::field::ValueSet|
                    {
                        let meta = __CALLSITE.metadata();
                        ::tracing::Event::dispatch(meta, &value_set);
                        ;
                    })({
                #[allow(unused_imports)]
                use ::tracing::field::{debug, display, Value};
                __CALLSITE.metadata().fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&hir_self_ty)
                                            as &dyn ::tracing::field::Value)),
                                (::tracing::__macro_support::Option::Some(&::tracing::field::debug(&segment)
                                            as &dyn ::tracing::field::Value))])
            });
    } else { ; }
};debug!(?hir_self_ty, ?segment);
2732
2733                let res_def_id = match opt_res {
2734                    Ok(r)
2735                        if #[allow(non_exhaustive_omitted_patterns)] match tcx.def_kind(r.def_id()) {
    DefKind::Variant | DefKind::Struct => true,
    _ => false,
}matches!(
2736                            tcx.def_kind(r.def_id()),
2737                            DefKind::Variant | DefKind::Struct
2738                        ) =>
2739                    {
2740                        r.def_id()
2741                    }
2742                    Ok(_) => return non_adt_or_variant_res(),
2743                    Err(e) => return ty::Const::new_error(tcx, e),
2744                };
2745
2746                res_def_id
2747            }
2748        };
2749
2750        let ty::Adt(adt_def, adt_args) = ty.kind() else { ::core::panicking::panic("internal error: entered unreachable code")unreachable!() };
2751
2752        let variant_def = adt_def.variant_with_id(variant_did);
2753        let variant_idx = adt_def.variant_index_with_id(variant_did).as_u32();
2754
2755        for init in inits {
2756            if !variant_def.fields.iter().any(|field_def| field_def.name == init.field.name) {
2757                let mut err = if adt_def.is_enum() {
2758                    {
    tcx.dcx().struct_span_err(init.field.span,
            ::alloc::__export::must_use({
                    ::alloc::fmt::format(format_args!("variant `{0}::{1}` has no field named `{2}`",
                            ty, variant_def.name, init.field))
                })).with_code(E0559)
}struct_span_code_err!(
2759                        tcx.dcx(),
2760                        init.field.span,
2761                        E0559,
2762                        "variant `{}::{}` has no field named `{}`",
2763                        ty,
2764                        variant_def.name,
2765                        init.field
2766                    )
2767                } else {
2768                    {
    tcx.dcx().struct_span_err(init.field.span,
            ::alloc::__export::must_use({
                    ::alloc::fmt::format(format_args!("struct `{0}` has no field named `{1}`",
                            variant_def.name, init.field))
                })).with_code(E0560)
}struct_span_code_err!(
2769                        tcx.dcx(),
2770                        init.field.span,
2771                        E0560,
2772                        "struct `{}` has no field named `{}`",
2773                        variant_def.name,
2774                        init.field
2775                    )
2776                };
2777                if adt_def.is_enum() {
2778                    err.span_label(
2779                        init.field.span,
2780                        ::alloc::__export::must_use({
        ::alloc::fmt::format(format_args!("`{0}::{1}` does not have this field",
                ty, variant_def.name))
    })format!("`{}::{}` does not have this field", ty, variant_def.name),
2781                    );
2782                } else {
2783                    err.span_label(
2784                        init.field.span,
2785                        ::alloc::__export::must_use({
        ::alloc::fmt::format(format_args!("`{0}` does not have this field",
                variant_def.name))
    })format!("`{}` does not have this field", variant_def.name),
2786                    );
2787                }
2788                return ty::Const::new_error(tcx, err.emit());
2789            }
2790        }
2791
2792        let fields = variant_def
2793            .fields
2794            .iter()
2795            .map(|field_def| {
2796                // FIXME(mgca): we aren't really handling privacy, stability,
2797                // or macro hygeniene but we should.
2798                let mut init_expr =
2799                    inits.iter().filter(|init_expr| init_expr.field.name == field_def.name);
2800
2801                match init_expr.next() {
2802                    Some(expr) => {
2803                        if let Some(expr) = init_expr.next() {
2804                            let e = tcx.dcx().span_err(
2805                                expr.span,
2806                                ::alloc::__export::must_use({
        ::alloc::fmt::format(format_args!("struct expression with multiple initialisers for `{0}`",
                field_def.name))
    })format!(
2807                                    "struct expression with multiple initialisers for `{}`",
2808                                    field_def.name,
2809                                ),
2810                            );
2811                            return ty::Const::new_error(tcx, e);
2812                        }
2813
2814                        self.lower_const_arg(
2815                            expr.expr,
2816                            tcx.type_of(field_def.did).instantiate(tcx, adt_args).skip_norm_wip(),
2817                        )
2818                    }
2819                    None => {
2820                        let e = tcx.dcx().span_err(
2821                            span,
2822                            ::alloc::__export::must_use({
        ::alloc::fmt::format(format_args!("struct expression with missing field initialiser for `{0}`",
                field_def.name))
    })format!(
2823                                "struct expression with missing field initialiser for `{}`",
2824                                field_def.name
2825                            ),
2826                        );
2827                        ty::Const::new_error(tcx, e)
2828                    }
2829                }
2830            })
2831            .collect::<Vec<_>>();
2832
2833        let opt_discr_const = if adt_def.is_enum() {
2834            let valtree = ty::ValTree::from_scalar_int(tcx, variant_idx.into());
2835            Some(ty::Const::new_value(tcx, valtree, tcx.types.u32))
2836        } else {
2837            None
2838        };
2839
2840        let valtree = ty::ValTree::from_branches(tcx, opt_discr_const.into_iter().chain(fields));
2841        ty::Const::new_value(tcx, valtree, ty)
2842    }
2843
2844    pub fn lower_path_for_struct_expr(
2845        &self,
2846        qpath: hir::QPath<'_>,
2847        path_span: Span,
2848        hir_id: HirId,
2849    ) -> ResolvedStructPath<'tcx> {
2850        match qpath {
2851            hir::QPath::Resolved(ref maybe_qself, path) => {
2852                let self_ty = maybe_qself.as_ref().map(|qself| self.lower_ty(qself));
2853                let ty = self.lower_resolved_ty_path(self_ty, path, hir_id, PermitVariants::Yes);
2854                ResolvedStructPath { res: Ok(path.res), ty }
2855            }
2856            hir::QPath::TypeRelative(hir_self_ty, segment) => {
2857                let self_ty = self.lower_ty(hir_self_ty);
2858
2859                let result = self.lower_type_relative_ty_path(
2860                    self_ty,
2861                    hir_self_ty,
2862                    segment,
2863                    hir_id,
2864                    path_span,
2865                    PermitVariants::Yes,
2866                );
2867                let ty = result
2868                    .map(|(ty, _, _)| ty)
2869                    .unwrap_or_else(|guar| Ty::new_error(self.tcx(), guar));
2870
2871                ResolvedStructPath {
2872                    res: result.map(|(_, kind, def_id)| Res::Def(kind, def_id)),
2873                    ty,
2874                }
2875            }
2876        }
2877    }
2878
2879    /// Lower a [resolved][hir::QPath::Resolved] path to a (type-level) constant.
2880    fn lower_resolved_const_path(
2881        &self,
2882        opt_self_ty: Option<Ty<'tcx>>,
2883        path: &hir::Path<'_>,
2884        hir_id: HirId,
2885    ) -> Const<'tcx> {
2886        let tcx = self.tcx();
2887        let span = path.span;
2888        let ct = match path.res {
2889            Res::Def(DefKind::ConstParam, def_id) => {
2890                {
    match (&opt_self_ty, &None) {
        (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);
            }
        }
    }
};assert_eq!(opt_self_ty, None);
2891                let _ = self.prohibit_generic_args(
2892                    path.segments.iter(),
2893                    GenericsArgsErrExtend::Param(def_id),
2894                );
2895                self.lower_const_param(def_id, hir_id)
2896            }
2897            Res::Def(DefKind::Const { .. }, did) => {
2898                if let Err(guar) = self.require_type_const_attribute(did, span) {
2899                    return Const::new_error(self.tcx(), guar);
2900                }
2901
2902                {
    match (&opt_self_ty, &None) {
        (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);
            }
        }
    }
};assert_eq!(opt_self_ty, None);
2903                let [leading_segments @ .., segment] = path.segments else { ::rustc_middle::util::bug::bug_fmt(format_args!("impossible case reached"))bug!() };
2904                let _ = self
2905                    .prohibit_generic_args(leading_segments.iter(), GenericsArgsErrExtend::None);
2906                let args = self.lower_generic_args_of_path_segment(span, did, segment);
2907                ty::Const::new_alias(
2908                    tcx,
2909                    ty::IsRigid::No,
2910                    ty::AliasConst::new(
2911                        tcx,
2912                        ty::AliasConstKind::new_from_def_id(
2913                            tcx,
2914                            did,
2915                            ty::AliasConstInherentArgsKind::WithSelf,
2916                        ),
2917                        args,
2918                    ),
2919                )
2920            }
2921            Res::Def(kind @ DefKind::Ctor(ctor_of, CtorKind::Const), did) => {
2922                {
    match (&opt_self_ty, &None) {
        (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);
            }
        }
    }
};assert_eq!(opt_self_ty, None);
2923                let generic_segments =
2924                    self.probe_generic_path_segments(path.segments, opt_self_ty, kind, did, span);
2925                let indices: FxHashSet<_> =
2926                    generic_segments.iter().map(|GenericPathSegment(_, index)| index).collect();
2927                let _ = self.prohibit_generic_args(
2928                    path.segments.iter().enumerate().filter_map(|(index, seg)| {
2929                        if !indices.contains(&index) { Some(seg) } else { None }
2930                    }),
2931                    GenericsArgsErrExtend::DefVariant(&path.segments),
2932                );
2933
2934                let parent_did = tcx.parent(did);
2935                let generics_did = match ctor_of {
2936                    CtorOf::Variant => tcx.parent(parent_did),
2937                    CtorOf::Struct => parent_did,
2938                };
2939                let args = self.lower_generic_args_of_path_segment(
2940                    span,
2941                    generics_did,
2942                    &path.segments[generic_segments[0].1],
2943                );
2944                self.construct_const_ctor_value(did, ctor_of, args)
2945            }
2946            Res::Def(DefKind::Ctor(ctor_of, CtorKind::Fn), did) => {
2947                {
    match (&opt_self_ty, &None) {
        (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);
            }
        }
    }
};assert_eq!(opt_self_ty, None);
2948                let generic_segments = self.probe_generic_path_segments(
2949                    path.segments,
2950                    opt_self_ty,
2951                    DefKind::Ctor(ctor_of, CtorKind::Const),
2952                    did,
2953                    span,
2954                );
2955                let indices: FxHashSet<_> =
2956                    generic_segments.iter().map(|GenericPathSegment(_, index)| index).collect();
2957                let _ = self.prohibit_generic_args(
2958                    path.segments.iter().enumerate().filter_map(|(index, seg)| {
2959                        if !indices.contains(&index) { Some(seg) } else { None }
2960                    }),
2961                    GenericsArgsErrExtend::DefVariant(&path.segments),
2962                );
2963
2964                let parent_did = tcx.parent(did);
2965                let generics_did = if let DefKind::Ctor(CtorOf::Variant, _) = tcx.def_kind(did) {
2966                    tcx.parent(parent_did)
2967                } else {
2968                    parent_did
2969                };
2970                let args = self.lower_generic_args_of_path_segment(
2971                    span,
2972                    generics_did,
2973                    &path.segments[generic_segments[0].1],
2974                );
2975
2976                ty::Const::zero_sized(tcx, tcx.type_of(did).instantiate(tcx, args).skip_norm_wip())
2977            }
2978            Res::Def(DefKind::AssocConst { .. }, did) => {
2979                let trait_segment = if let [modules @ .., trait_, _item] = path.segments {
2980                    let _ = self.prohibit_generic_args(modules.iter(), GenericsArgsErrExtend::None);
2981                    Some(trait_)
2982                } else {
2983                    None
2984                };
2985                self.lower_resolved_assoc_const_path(
2986                    span,
2987                    opt_self_ty,
2988                    did,
2989                    trait_segment,
2990                    path.segments.last().unwrap(),
2991                )
2992                .unwrap_or_else(|guar| Const::new_error(tcx, guar))
2993            }
2994            Res::Def(DefKind::Static { .. }, _) => {
2995                let guar = self
2996                    .dcx()
2997                    .span_err(path.span, "static items cannot be used as const arguments");
2998                return Const::new_error(tcx, guar);
2999            }
3000            // FIXME(const_generics): create real consts to allow fn items as const paths.
3001            // Lowering these to recovered `FnDef` consts currently interacts poorly with WF
3002            // checking: WF of a `FnDef` walks the function signature, so a signature that mentions
3003            // the same function item as a const arg can recurse until it overflows/segfaults.
3004            Res::Def(DefKind::Fn | DefKind::AssocFn, _) => {
3005                let guar = self
3006                    .dcx()
3007                    .struct_span_err(span, "function items cannot be used as const args")
3008                    .emit();
3009                Const::new_error(tcx, guar)
3010            }
3011            // Exhaustive match to be clear about what exactly we're considering to be
3012            // an invalid Res for a const path.
3013            res @ (Res::Def(
3014                DefKind::Mod
3015                | DefKind::Enum
3016                | DefKind::Variant
3017                | DefKind::Struct
3018                | DefKind::OpaqueTy
3019                | DefKind::TyAlias
3020                | DefKind::TraitAlias
3021                | DefKind::AssocTy
3022                | DefKind::Union
3023                | DefKind::Trait
3024                | DefKind::ForeignTy
3025                | DefKind::TyParam
3026                | DefKind::Macro(_)
3027                | DefKind::LifetimeParam
3028                | DefKind::Use
3029                | DefKind::ForeignMod
3030                | DefKind::AnonConst
3031                | DefKind::Field
3032                | DefKind::Impl { .. }
3033                | DefKind::Closure
3034                | DefKind::ExternCrate
3035                | DefKind::GlobalAsm
3036                | DefKind::SyntheticCoroutineBody
3037                | DefKind::TestBinderConstraints,
3038                _,
3039            )
3040            | Res::PrimTy(_)
3041            | Res::SelfTyParam { .. }
3042            | Res::SelfTyAlias { .. }
3043            | Res::SelfCtor(_)
3044            | Res::Local(_)
3045            | Res::ToolMod
3046            | Res::OpenMod(..)
3047            | Res::NonMacroAttr(_)
3048            | Res::Err) => Const::new_error_with_message(
3049                tcx,
3050                span,
3051                ::alloc::__export::must_use({
        ::alloc::fmt::format(format_args!("invalid Res {0:?} for const path",
                res))
    })format!("invalid Res {res:?} for const path"),
3052            ),
3053        };
3054        self.check_param_uses_if_mcg(ct, span, false)
3055    }
3056
3057    /// Literals are eagerly converted to a constant, everything else becomes `ConstKind::Alias`.
3058    {}
#[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("lower_const_arg_anon",
                                    "rustc_hir_analysis::hir_ty_lowering",
                                    ::tracing::Level::DEBUG,
                                    ::tracing_core::__macro_support::Option::Some("/rustc-dev/a36d05efab632d1ddf902b6a5c33b6d5d3b64131/compiler/rustc_hir_analysis/src/hir_ty_lowering/mod.rs"),
                                    ::tracing_core::__macro_support::Option::Some(3058u32),
                                    ::tracing_core::__macro_support::Option::Some("rustc_hir_analysis::hir_ty_lowering"),
                                    ::tracing_core::field::FieldSet::new(&[{
                                                        const NAME:
                                                            ::tracing::__macro_support::FieldName<{
                                                                ::tracing::__macro_support::FieldName::len("anon")
                                                            }> =
                                                            ::tracing::__macro_support::FieldName::new("anon");
                                                        NAME.as_str()
                                                    }], ::tracing_core::callsite::Identifier(&__CALLSITE)),
                                    ::tracing::metadata::Kind::SPAN)
                            };
                        ::tracing::callsite::DefaultCallsite::new(&META)
                    };
                let mut interest = ::tracing::subscriber::Interest::never();
                if ::tracing::Level::DEBUG <=
                                    ::tracing::level_filters::STATIC_MAX_LEVEL &&
                                ::tracing::Level::DEBUG <=
                                    ::tracing::level_filters::LevelFilter::current() &&
                            { interest = __CALLSITE.interest(); !interest.is_never() }
                        &&
                        ::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
                            interest) {
                    let meta = __CALLSITE.metadata();
                    ::tracing::Span::new(meta,
                        &{
                                #[allow(unused_imports)]
                                use ::tracing::field::{debug, display, Value};
                                meta.fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&anon)
                                                            as &dyn ::tracing::field::Value))])
                            })
                } else {
                    let span =
                        ::tracing::__macro_support::__disabled_span(__CALLSITE.metadata());
                    {};
                    span
                }
            };
        __tracing_attr_guard = __tracing_attr_span.enter();
    }

    #[warn(clippy :: suspicious_else_formatting)]
    {

        #[allow(unknown_lints, unreachable_code, clippy ::
        diverging_sub_expression, clippy :: empty_loop, clippy ::
        let_unit_value, clippy :: let_with_type_underscore, clippy ::
        needless_return, clippy :: unreachable)]
        if false {
            let __tracing_attr_fake_return: Const<'tcx> = loop {};
            return __tracing_attr_fake_return;
        }
        {
            let tcx = self.tcx();
            let expr = &tcx.hir_body(anon.body).value;
            {
                use ::tracing::__macro_support::Callsite as _;
                static __CALLSITE: ::tracing::callsite::DefaultCallsite =
                    {
                        static META: ::tracing::Metadata<'static> =
                            {
                                ::tracing_core::metadata::Metadata::new("event /rustc-dev/a36d05efab632d1ddf902b6a5c33b6d5d3b64131/compiler/rustc_hir_analysis/src/hir_ty_lowering/mod.rs:3063",
                                    "rustc_hir_analysis::hir_ty_lowering",
                                    ::tracing::Level::DEBUG,
                                    ::tracing_core::__macro_support::Option::Some("/rustc-dev/a36d05efab632d1ddf902b6a5c33b6d5d3b64131/compiler/rustc_hir_analysis/src/hir_ty_lowering/mod.rs"),
                                    ::tracing_core::__macro_support::Option::Some(3063u32),
                                    ::tracing_core::__macro_support::Option::Some("rustc_hir_analysis::hir_ty_lowering"),
                                    ::tracing_core::field::FieldSet::new(&[{
                                                        const NAME:
                                                            ::tracing::__macro_support::FieldName<{
                                                                ::tracing::__macro_support::FieldName::len("expr")
                                                            }> =
                                                            ::tracing::__macro_support::FieldName::new("expr");
                                                        NAME.as_str()
                                                    }], ::tracing_core::callsite::Identifier(&__CALLSITE)),
                                    ::tracing::metadata::Kind::EVENT)
                            };
                        ::tracing::callsite::DefaultCallsite::new(&META)
                    };
                let enabled =
                    ::tracing::Level::DEBUG <=
                                ::tracing::level_filters::STATIC_MAX_LEVEL &&
                            ::tracing::Level::DEBUG <=
                                ::tracing::level_filters::LevelFilter::current() &&
                        {
                            let interest = __CALLSITE.interest();
                            !interest.is_never() &&
                                ::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
                                    interest)
                        };
                if enabled {
                    (|value_set: ::tracing::field::ValueSet|
                                {
                                    let meta = __CALLSITE.metadata();
                                    ::tracing::Event::dispatch(meta, &value_set);
                                    ;
                                })({
                            #[allow(unused_imports)]
                            use ::tracing::field::{debug, display, Value};
                            __CALLSITE.metadata().fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&expr)
                                                        as &dyn ::tracing::field::Value))])
                        });
                } else { ; }
            };
            let ty =
                tcx.type_of(anon.def_id).instantiate_identity().skip_norm_wip();
            match self.try_lower_anon_const_lit(ty, expr) {
                Some(v) => v,
                None =>
                    ty::Const::new_alias(tcx, ty::IsRigid::No,
                        ty::AliasConst::new(tcx,
                            ty::AliasConstKind::Anon {
                                def_id: anon.def_id.to_def_id(),
                            },
                            ty::GenericArgs::identity_for_item(tcx,
                                anon.def_id.to_def_id()))),
            }
        }
    }
}#[instrument(skip(self), level = "debug")]
3059    fn lower_const_arg_anon(&self, anon: &AnonConst) -> Const<'tcx> {
3060        let tcx = self.tcx();
3061
3062        let expr = &tcx.hir_body(anon.body).value;
3063        debug!(?expr);
3064
3065        // FIXME(generic_const_parameter_types): We should use the proper generic args
3066        // here. It's only used as a hint for literals so doesn't matter too much to use the right
3067        // generic arguments, just weaker type inference.
3068        let ty = tcx.type_of(anon.def_id).instantiate_identity().skip_norm_wip();
3069
3070        match self.try_lower_anon_const_lit(ty, expr) {
3071            Some(v) => v,
3072            None => ty::Const::new_alias(
3073                tcx,
3074                ty::IsRigid::No,
3075                ty::AliasConst::new(
3076                    tcx,
3077                    ty::AliasConstKind::Anon { def_id: anon.def_id.to_def_id() },
3078                    ty::GenericArgs::identity_for_item(tcx, anon.def_id.to_def_id()),
3079                ),
3080            ),
3081        }
3082    }
3083
3084    {}
#[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("lower_const_arg_literal",
                                    "rustc_hir_analysis::hir_ty_lowering",
                                    ::tracing::Level::DEBUG,
                                    ::tracing_core::__macro_support::Option::Some("/rustc-dev/a36d05efab632d1ddf902b6a5c33b6d5d3b64131/compiler/rustc_hir_analysis/src/hir_ty_lowering/mod.rs"),
                                    ::tracing_core::__macro_support::Option::Some(3084u32),
                                    ::tracing_core::__macro_support::Option::Some("rustc_hir_analysis::hir_ty_lowering"),
                                    ::tracing_core::field::FieldSet::new(&[{
                                                        const NAME:
                                                            ::tracing::__macro_support::FieldName<{
                                                                ::tracing::__macro_support::FieldName::len("kind")
                                                            }> =
                                                            ::tracing::__macro_support::FieldName::new("kind");
                                                        NAME.as_str()
                                                    },
                                                    {
                                                        const NAME:
                                                            ::tracing::__macro_support::FieldName<{
                                                                ::tracing::__macro_support::FieldName::len("neg")
                                                            }> =
                                                            ::tracing::__macro_support::FieldName::new("neg");
                                                        NAME.as_str()
                                                    },
                                                    {
                                                        const NAME:
                                                            ::tracing::__macro_support::FieldName<{
                                                                ::tracing::__macro_support::FieldName::len("ty")
                                                            }> =
                                                            ::tracing::__macro_support::FieldName::new("ty");
                                                        NAME.as_str()
                                                    },
                                                    {
                                                        const NAME:
                                                            ::tracing::__macro_support::FieldName<{
                                                                ::tracing::__macro_support::FieldName::len("span")
                                                            }> =
                                                            ::tracing::__macro_support::FieldName::new("span");
                                                        NAME.as_str()
                                                    }], ::tracing_core::callsite::Identifier(&__CALLSITE)),
                                    ::tracing::metadata::Kind::SPAN)
                            };
                        ::tracing::callsite::DefaultCallsite::new(&META)
                    };
                let mut interest = ::tracing::subscriber::Interest::never();
                if ::tracing::Level::DEBUG <=
                                    ::tracing::level_filters::STATIC_MAX_LEVEL &&
                                ::tracing::Level::DEBUG <=
                                    ::tracing::level_filters::LevelFilter::current() &&
                            { interest = __CALLSITE.interest(); !interest.is_never() }
                        &&
                        ::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
                            interest) {
                    let meta = __CALLSITE.metadata();
                    ::tracing::Span::new(meta,
                        &{
                                #[allow(unused_imports)]
                                use ::tracing::field::{debug, display, Value};
                                meta.fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&kind)
                                                            as &dyn ::tracing::field::Value)),
                                                (::tracing::__macro_support::Option::Some(&neg as
                                                            &dyn ::tracing::field::Value)),
                                                (::tracing::__macro_support::Option::Some(&::tracing::field::debug(&ty)
                                                            as &dyn ::tracing::field::Value)),
                                                (::tracing::__macro_support::Option::Some(&::tracing::field::debug(&span)
                                                            as &dyn ::tracing::field::Value))])
                            })
                } else {
                    let span =
                        ::tracing::__macro_support::__disabled_span(__CALLSITE.metadata());
                    {};
                    span
                }
            };
        __tracing_attr_guard = __tracing_attr_span.enter();
    }

    #[warn(clippy :: suspicious_else_formatting)]
    {

        #[allow(unknown_lints, unreachable_code, clippy ::
        diverging_sub_expression, clippy :: empty_loop, clippy ::
        let_unit_value, clippy :: let_with_type_underscore, clippy ::
        needless_return, clippy :: unreachable)]
        if false {
            let __tracing_attr_fake_return: Const<'tcx> = loop {};
            return __tracing_attr_fake_return;
        }
        {
            let tcx = self.tcx();
            let ty = if !ty.has_infer() { Some(ty) } else { None };
            if let LitKind::Err(guar) = *kind {
                return ty::Const::new_error(tcx, guar);
            }
            let input = LitToConstInput { lit: *kind, ty, neg };
            match tcx.at(span).lit_to_const(input) {
                Some(value) =>
                    ty::Const::new_value(tcx, value.valtree, value.ty),
                None => {
                    let e =
                        tcx.dcx().span_err(span,
                            "type annotations needed for the literal");
                    ty::Const::new_error(tcx, e)
                }
            }
        }
    }
}#[instrument(skip(self), level = "debug")]
3085    fn lower_const_arg_literal(
3086        &self,
3087        kind: &LitKind,
3088        neg: bool,
3089        ty: Ty<'tcx>,
3090        span: Span,
3091    ) -> Const<'tcx> {
3092        let tcx = self.tcx();
3093
3094        let ty = if !ty.has_infer() { Some(ty) } else { None };
3095
3096        if let LitKind::Err(guar) = *kind {
3097            return ty::Const::new_error(tcx, guar);
3098        }
3099        let input = LitToConstInput { lit: *kind, ty, neg };
3100        match tcx.at(span).lit_to_const(input) {
3101            Some(value) => ty::Const::new_value(tcx, value.valtree, value.ty),
3102            None => {
3103                let e = tcx.dcx().span_err(span, "type annotations needed for the literal");
3104                ty::Const::new_error(tcx, e)
3105            }
3106        }
3107    }
3108
3109    {}
#[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("try_lower_anon_const_lit",
                                    "rustc_hir_analysis::hir_ty_lowering",
                                    ::tracing::Level::DEBUG,
                                    ::tracing_core::__macro_support::Option::Some("/rustc-dev/a36d05efab632d1ddf902b6a5c33b6d5d3b64131/compiler/rustc_hir_analysis/src/hir_ty_lowering/mod.rs"),
                                    ::tracing_core::__macro_support::Option::Some(3109u32),
                                    ::tracing_core::__macro_support::Option::Some("rustc_hir_analysis::hir_ty_lowering"),
                                    ::tracing_core::field::FieldSet::new(&[{
                                                        const NAME:
                                                            ::tracing::__macro_support::FieldName<{
                                                                ::tracing::__macro_support::FieldName::len("ty")
                                                            }> =
                                                            ::tracing::__macro_support::FieldName::new("ty");
                                                        NAME.as_str()
                                                    },
                                                    {
                                                        const NAME:
                                                            ::tracing::__macro_support::FieldName<{
                                                                ::tracing::__macro_support::FieldName::len("expr")
                                                            }> =
                                                            ::tracing::__macro_support::FieldName::new("expr");
                                                        NAME.as_str()
                                                    }], ::tracing_core::callsite::Identifier(&__CALLSITE)),
                                    ::tracing::metadata::Kind::SPAN)
                            };
                        ::tracing::callsite::DefaultCallsite::new(&META)
                    };
                let mut interest = ::tracing::subscriber::Interest::never();
                if ::tracing::Level::DEBUG <=
                                    ::tracing::level_filters::STATIC_MAX_LEVEL &&
                                ::tracing::Level::DEBUG <=
                                    ::tracing::level_filters::LevelFilter::current() &&
                            { interest = __CALLSITE.interest(); !interest.is_never() }
                        &&
                        ::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
                            interest) {
                    let meta = __CALLSITE.metadata();
                    ::tracing::Span::new(meta,
                        &{
                                #[allow(unused_imports)]
                                use ::tracing::field::{debug, display, Value};
                                meta.fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&ty)
                                                            as &dyn ::tracing::field::Value)),
                                                (::tracing::__macro_support::Option::Some(&::tracing::field::debug(&expr)
                                                            as &dyn ::tracing::field::Value))])
                            })
                } else {
                    let span =
                        ::tracing::__macro_support::__disabled_span(__CALLSITE.metadata());
                    {};
                    span
                }
            };
        __tracing_attr_guard = __tracing_attr_span.enter();
    }

    #[warn(clippy :: suspicious_else_formatting)]
    {

        #[allow(unknown_lints, unreachable_code, clippy ::
        diverging_sub_expression, clippy :: empty_loop, clippy ::
        let_unit_value, clippy :: let_with_type_underscore, clippy ::
        needless_return, clippy :: unreachable)]
        if false {
            let __tracing_attr_fake_return: Option<Const<'tcx>> = loop {};
            return __tracing_attr_fake_return;
        }
        {
            let tcx = self.tcx();
            let expr =
                match &expr.kind {
                    hir::ExprKind::Block(block, _) if
                        block.stmts.is_empty() && block.expr.is_some() => {
                        block.expr.as_ref().unwrap()
                    }
                    _ => expr,
                };
            let lit_input =
                match expr.kind {
                    hir::ExprKind::Lit(lit) => {
                        Some(LitToConstInput {
                                lit: lit.node,
                                ty: Some(ty),
                                neg: false,
                            })
                    }
                    hir::ExprKind::Unary(hir::UnOp::Neg, expr) =>
                        match expr.kind {
                            hir::ExprKind::Lit(lit) => {
                                Some(LitToConstInput {
                                        lit: lit.node,
                                        ty: Some(ty),
                                        neg: true,
                                    })
                            }
                            _ => None,
                        },
                    _ => None,
                };
            lit_input.and_then(|l|
                    {
                        if const_lit_matches_ty(tcx, &l.lit, ty, l.neg) {
                            tcx.at(expr.span).lit_to_const(l).map(|value|
                                    ty::Const::new_value(tcx, value.valtree, value.ty))
                        } else { None }
                    })
        }
    }
}#[instrument(skip(self), level = "debug")]
3110    fn try_lower_anon_const_lit(
3111        &self,
3112        ty: Ty<'tcx>,
3113        expr: &'tcx hir::Expr<'tcx>,
3114    ) -> Option<Const<'tcx>> {
3115        let tcx = self.tcx();
3116
3117        // Unwrap a block, so that e.g. `{ 1 }` is recognised as a literal. This makes the
3118        // performance optimisation of directly lowering anon consts occur more often.
3119        let expr = match &expr.kind {
3120            hir::ExprKind::Block(block, _) if block.stmts.is_empty() && block.expr.is_some() => {
3121                block.expr.as_ref().unwrap()
3122            }
3123            _ => expr,
3124        };
3125
3126        let lit_input = match expr.kind {
3127            hir::ExprKind::Lit(lit) => {
3128                Some(LitToConstInput { lit: lit.node, ty: Some(ty), neg: false })
3129            }
3130            hir::ExprKind::Unary(hir::UnOp::Neg, expr) => match expr.kind {
3131                hir::ExprKind::Lit(lit) => {
3132                    Some(LitToConstInput { lit: lit.node, ty: Some(ty), neg: true })
3133                }
3134                _ => None,
3135            },
3136            _ => None,
3137        };
3138
3139        lit_input.and_then(|l| {
3140            if const_lit_matches_ty(tcx, &l.lit, ty, l.neg) {
3141                tcx.at(expr.span)
3142                    .lit_to_const(l)
3143                    .map(|value| ty::Const::new_value(tcx, value.valtree, value.ty))
3144            } else {
3145                None
3146            }
3147        })
3148    }
3149
3150    fn require_type_const_attribute(
3151        &self,
3152        def_id: DefId,
3153        span: Span,
3154    ) -> Result<(), ErrorGuaranteed> {
3155        let tcx = self.tcx();
3156        if tcx.is_type_const_syntax(def_id) || tcx.features().generic_const_args() {
3157            Ok(())
3158        } else {
3159            let mut err = self.dcx().struct_span_err(
3160                span,
3161                "use of `const` in the type system not defined as `type const`",
3162            );
3163            if let Some(local_def_id) = def_id.as_local() {
3164                let name = tcx.def_path_str(def_id);
3165                let (insertion_span, sugg) = match tcx.hir_node_by_def_id(local_def_id) {
3166                    hir::Node::Item(item) if !item.vis_span.is_empty() => {
3167                        (item.vis_span.shrink_to_hi(), " type")
3168                    }
3169                    hir::Node::ImplItem(impl_item)
3170                        if let Some(vis_span) =
3171                            impl_item.vis_span().filter(|span| !span.is_empty()) =>
3172                    {
3173                        (vis_span.shrink_to_hi(), " type")
3174                    }
3175                    _ => (tcx.def_span(def_id).shrink_to_lo(), "type "),
3176                };
3177
3178                err.span_suggestion_verbose(
3179                    insertion_span,
3180                    ::alloc::__export::must_use({
        ::alloc::fmt::format(format_args!("add `type` before `const` for `{0}`",
                name))
    })format!("add `type` before `const` for `{name}`"),
3181                    sugg,
3182                    Applicability::MaybeIncorrect,
3183                );
3184            } else {
3185                err.note("only consts marked defined as `type const` may be used in types");
3186            }
3187            Err(err.emit())
3188        }
3189    }
3190
3191    fn lower_delegation_ty(&self, infer: hir::InferDelegation<'_>) -> Ty<'tcx> {
3192        match infer {
3193            hir::InferDelegation::DefId(def_id) => {
3194                self.tcx().type_of(def_id).instantiate_identity().skip_norm_wip()
3195            }
3196            rustc_hir::InferDelegation::Sig(_, idx) => {
3197                let delegation_sig = self.tcx().inherit_sig_for_delegation_item(self.item_def_id());
3198
3199                match idx {
3200                    hir::InferDelegationSig::Input(idx) => delegation_sig[idx],
3201                    hir::InferDelegationSig::Output { .. } => *delegation_sig.last().unwrap(),
3202                }
3203            }
3204        }
3205    }
3206
3207    /// Lower a type from the HIR to our internal notion of a type.
3208    {}
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("lower_ty",
                                "rustc_hir_analysis::hir_ty_lowering",
                                ::tracing::Level::DEBUG,
                                ::tracing_core::__macro_support::Option::Some("/rustc-dev/a36d05efab632d1ddf902b6a5c33b6d5d3b64131/compiler/rustc_hir_analysis/src/hir_ty_lowering/mod.rs"),
                                ::tracing_core::__macro_support::Option::Some(3208u32),
                                ::tracing_core::__macro_support::Option::Some("rustc_hir_analysis::hir_ty_lowering"),
                                ::tracing_core::field::FieldSet::new(&[{
                                                    const NAME:
                                                        ::tracing::__macro_support::FieldName<{
                                                            ::tracing::__macro_support::FieldName::len("hir_ty")
                                                        }> =
                                                        ::tracing::__macro_support::FieldName::new("hir_ty");
                                                    NAME.as_str()
                                                }], ::tracing_core::callsite::Identifier(&__CALLSITE)),
                                ::tracing::metadata::Kind::SPAN)
                        };
                    ::tracing::callsite::DefaultCallsite::new(&META)
                };
            let mut interest = ::tracing::subscriber::Interest::never();
            if ::tracing::Level::DEBUG <=
                                ::tracing::level_filters::STATIC_MAX_LEVEL &&
                            ::tracing::Level::DEBUG <=
                                ::tracing::level_filters::LevelFilter::current() &&
                        { interest = __CALLSITE.interest(); !interest.is_never() }
                    &&
                    ::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
                        interest) {
                let meta = __CALLSITE.metadata();
                ::tracing::Span::new(meta,
                    &{
                            #[allow(unused_imports)]
                            use ::tracing::field::{debug, display, Value};
                            meta.fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&hir_ty)
                                                        as &dyn ::tracing::field::Value))])
                        })
            } else {
                let span =
                    ::tracing::__macro_support::__disabled_span(__CALLSITE.metadata());
                {};
                span
            }
        };
    __tracing_attr_guard = __tracing_attr_span.enter();
}
#[allow(clippy :: redundant_closure_call)]
let x =
    (move ||
                {

                    #[allow(unknown_lints, unreachable_code, clippy ::
                    diverging_sub_expression, clippy :: empty_loop, clippy ::
                    let_unit_value, clippy :: let_with_type_underscore, clippy
                    :: needless_return, clippy :: unreachable)]
                    if false {
                        let __tracing_attr_fake_return: Ty<'tcx> = loop {};
                        return __tracing_attr_fake_return;
                    }
                    {
                        let tcx = self.tcx();
                        let result_ty =
                            match &hir_ty.kind {
                                hir::TyKind::InferDelegation(infer) =>
                                    self.lower_delegation_ty(*infer),
                                hir::TyKind::Slice(ty) =>
                                    Ty::new_slice(tcx, self.lower_ty(ty)),
                                hir::TyKind::Ptr(mt) =>
                                    Ty::new_ptr(tcx, self.lower_ty(mt.ty), mt.mutbl),
                                hir::TyKind::Ref(region, mt) => {
                                    let r =
                                        self.lower_lifetime(region, RegionInferReason::Reference);
                                    {
                                        use ::tracing::__macro_support::Callsite as _;
                                        static __CALLSITE: ::tracing::callsite::DefaultCallsite =
                                            {
                                                static META: ::tracing::Metadata<'static> =
                                                    {
                                                        ::tracing_core::metadata::Metadata::new("event /rustc-dev/a36d05efab632d1ddf902b6a5c33b6d5d3b64131/compiler/rustc_hir_analysis/src/hir_ty_lowering/mod.rs:3218",
                                                            "rustc_hir_analysis::hir_ty_lowering",
                                                            ::tracing::Level::DEBUG,
                                                            ::tracing_core::__macro_support::Option::Some("/rustc-dev/a36d05efab632d1ddf902b6a5c33b6d5d3b64131/compiler/rustc_hir_analysis/src/hir_ty_lowering/mod.rs"),
                                                            ::tracing_core::__macro_support::Option::Some(3218u32),
                                                            ::tracing_core::__macro_support::Option::Some("rustc_hir_analysis::hir_ty_lowering"),
                                                            ::tracing_core::field::FieldSet::new(&[{
                                                                                const NAME:
                                                                                    ::tracing::__macro_support::FieldName<{
                                                                                        ::tracing::__macro_support::FieldName::len("r")
                                                                                    }> =
                                                                                    ::tracing::__macro_support::FieldName::new("r");
                                                                                NAME.as_str()
                                                                            }], ::tracing_core::callsite::Identifier(&__CALLSITE)),
                                                            ::tracing::metadata::Kind::EVENT)
                                                    };
                                                ::tracing::callsite::DefaultCallsite::new(&META)
                                            };
                                        let enabled =
                                            ::tracing::Level::DEBUG <=
                                                        ::tracing::level_filters::STATIC_MAX_LEVEL &&
                                                    ::tracing::Level::DEBUG <=
                                                        ::tracing::level_filters::LevelFilter::current() &&
                                                {
                                                    let interest = __CALLSITE.interest();
                                                    !interest.is_never() &&
                                                        ::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
                                                            interest)
                                                };
                                        if enabled {
                                            (|value_set: ::tracing::field::ValueSet|
                                                        {
                                                            let meta = __CALLSITE.metadata();
                                                            ::tracing::Event::dispatch(meta, &value_set);
                                                            ;
                                                        })({
                                                    #[allow(unused_imports)]
                                                    use ::tracing::field::{debug, display, Value};
                                                    __CALLSITE.metadata().fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&r)
                                                                                as &dyn ::tracing::field::Value))])
                                                });
                                        } else { ; }
                                    };
                                    let t = self.lower_ty(mt.ty);
                                    Ty::new_ref(tcx, r, t, mt.mutbl)
                                }
                                hir::TyKind::Never => tcx.types.never,
                                hir::TyKind::Tup(fields) => {
                                    Ty::new_tup_from_iter(tcx,
                                        fields.iter().map(|t| self.lower_ty(t)))
                                }
                                hir::TyKind::FnPtr(bf) => {
                                    check_c_variadic_abi(tcx, bf.decl, bf.abi, hir_ty.span);
                                    Ty::new_fn_ptr(tcx,
                                        self.lower_fn_ty(hir_ty.hir_id, bf.safety, bf.abi, bf.decl,
                                            None, Some(hir_ty)))
                                }
                                hir::TyKind::UnsafeBinder(binder) =>
                                    Ty::new_unsafe_binder(tcx,
                                        ty::Binder::bind_with_vars(self.lower_ty(binder.inner_ty),
                                            tcx.late_bound_vars(hir_ty.hir_id))),
                                hir::TyKind::TraitObject(bounds, tagged_ptr) => {
                                    let lifetime = tagged_ptr.pointer();
                                    let syntax = tagged_ptr.tag();
                                    self.lower_trait_object_ty(hir_ty.span, hir_ty.hir_id,
                                        bounds, lifetime, syntax)
                                }
                                hir::TyKind::Path(hir::QPath::Resolved(_, path)) if
                                    path.segments.last().and_then(|segment|
                                                segment.args).is_some_and(|args|
                                            {

                                                #[allow(non_exhaustive_omitted_patterns)]
                                                match args.parenthesized {
                                                    hir::GenericArgsParentheses::ReturnTypeNotation => true,
                                                    _ => false,
                                                }
                                            }) => {
                                    let guar =
                                        self.dcx().emit_err(BadReturnTypeNotation {
                                                span: hir_ty.span,
                                                suggestion: None,
                                            });
                                    Ty::new_error(tcx, guar)
                                }
                                hir::TyKind::Path(hir::QPath::Resolved(maybe_qself, path))
                                    => {
                                    {
                                        use ::tracing::__macro_support::Callsite as _;
                                        static __CALLSITE: ::tracing::callsite::DefaultCallsite =
                                            {
                                                static META: ::tracing::Metadata<'static> =
                                                    {
                                                        ::tracing_core::metadata::Metadata::new("event /rustc-dev/a36d05efab632d1ddf902b6a5c33b6d5d3b64131/compiler/rustc_hir_analysis/src/hir_ty_lowering/mod.rs:3260",
                                                            "rustc_hir_analysis::hir_ty_lowering",
                                                            ::tracing::Level::DEBUG,
                                                            ::tracing_core::__macro_support::Option::Some("/rustc-dev/a36d05efab632d1ddf902b6a5c33b6d5d3b64131/compiler/rustc_hir_analysis/src/hir_ty_lowering/mod.rs"),
                                                            ::tracing_core::__macro_support::Option::Some(3260u32),
                                                            ::tracing_core::__macro_support::Option::Some("rustc_hir_analysis::hir_ty_lowering"),
                                                            ::tracing_core::field::FieldSet::new(&[{
                                                                                const NAME:
                                                                                    ::tracing::__macro_support::FieldName<{
                                                                                        ::tracing::__macro_support::FieldName::len("maybe_qself")
                                                                                    }> =
                                                                                    ::tracing::__macro_support::FieldName::new("maybe_qself");
                                                                                NAME.as_str()
                                                                            },
                                                                            {
                                                                                const NAME:
                                                                                    ::tracing::__macro_support::FieldName<{
                                                                                        ::tracing::__macro_support::FieldName::len("path")
                                                                                    }> =
                                                                                    ::tracing::__macro_support::FieldName::new("path");
                                                                                NAME.as_str()
                                                                            }], ::tracing_core::callsite::Identifier(&__CALLSITE)),
                                                            ::tracing::metadata::Kind::EVENT)
                                                    };
                                                ::tracing::callsite::DefaultCallsite::new(&META)
                                            };
                                        let enabled =
                                            ::tracing::Level::DEBUG <=
                                                        ::tracing::level_filters::STATIC_MAX_LEVEL &&
                                                    ::tracing::Level::DEBUG <=
                                                        ::tracing::level_filters::LevelFilter::current() &&
                                                {
                                                    let interest = __CALLSITE.interest();
                                                    !interest.is_never() &&
                                                        ::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
                                                            interest)
                                                };
                                        if enabled {
                                            (|value_set: ::tracing::field::ValueSet|
                                                        {
                                                            let meta = __CALLSITE.metadata();
                                                            ::tracing::Event::dispatch(meta, &value_set);
                                                            ;
                                                        })({
                                                    #[allow(unused_imports)]
                                                    use ::tracing::field::{debug, display, Value};
                                                    __CALLSITE.metadata().fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&maybe_qself)
                                                                                as &dyn ::tracing::field::Value)),
                                                                    (::tracing::__macro_support::Option::Some(&::tracing::field::debug(&path)
                                                                                as &dyn ::tracing::field::Value))])
                                                });
                                        } else { ; }
                                    };
                                    let opt_self_ty =
                                        maybe_qself.as_ref().map(|qself| self.lower_ty(qself));
                                    self.lower_resolved_ty_path(opt_self_ty, path,
                                        hir_ty.hir_id, PermitVariants::No)
                                }
                                &hir::TyKind::OpaqueDef(opaque_ty) => {
                                    let in_trait =
                                        match opaque_ty.origin {
                                            hir::OpaqueTyOrigin::FnReturn {
                                                parent, in_trait_or_impl: Some(hir::RpitContext::Trait), ..
                                                } | hir::OpaqueTyOrigin::AsyncFn {
                                                parent, in_trait_or_impl: Some(hir::RpitContext::Trait), ..
                                                } => Some(parent),
                                            hir::OpaqueTyOrigin::FnReturn {
                                                in_trait_or_impl: None | Some(hir::RpitContext::TraitImpl),
                                                .. } | hir::OpaqueTyOrigin::AsyncFn {
                                                in_trait_or_impl: None | Some(hir::RpitContext::TraitImpl),
                                                .. } | hir::OpaqueTyOrigin::TyAlias { .. } => None,
                                        };
                                    self.lower_opaque_ty(opaque_ty.def_id, in_trait)
                                }
                                hir::TyKind::TraitAscription(hir_bounds) => {
                                    let self_ty = self.ty_infer(None, hir_ty.span);
                                    let mut bounds = Vec::new();
                                    self.lower_bounds(self_ty, hir_bounds.iter(), &mut bounds,
                                        ty::List::empty(), PredicateFilter::All,
                                        OverlappingAsssocItemConstraints::Allowed);
                                    self.add_implicit_sizedness_bounds(&mut bounds, self_ty,
                                        hir_bounds, ImpliedBoundsContext::AssociatedTypeOrImplTrait,
                                        hir_ty.span);
                                    self.register_trait_ascription_bounds(bounds, hir_ty.hir_id,
                                        hir_ty.span);
                                    self_ty
                                }
                                hir::TyKind::Path(hir::QPath::TypeRelative(hir_self_ty,
                                    segment)) if
                                    segment.args.is_some_and(|args|
                                            {

                                                #[allow(non_exhaustive_omitted_patterns)]
                                                match args.parenthesized {
                                                    hir::GenericArgsParentheses::ReturnTypeNotation => true,
                                                    _ => false,
                                                }
                                            }) => {
                                    let guar =
                                        if let hir::Node::LetStmt(stmt) =
                                                                tcx.parent_hir_node(hir_ty.hir_id) && let None = stmt.init
                                                        &&
                                                        let hir::TyKind::Path(hir::QPath::Resolved(_, self_ty_path))
                                                            = hir_self_ty.kind &&
                                                    let Res::Def(DefKind::Enum | DefKind::Struct |
                                                        DefKind::Union, def_id) = self_ty_path.res &&
                                                let Some(_) =
                                                    tcx.inherent_impls(def_id).iter().flat_map(|imp|
                                                                    {
                                                                        tcx.associated_items(*imp).filter_by_name_unhygienic(segment.ident.name)
                                                                    }).filter(|assoc|
                                                                {

                                                                    #[allow(non_exhaustive_omitted_patterns)]
                                                                    match assoc.kind {
                                                                        ty::AssocKind::Fn { has_self: false, .. } => true,
                                                                        _ => false,
                                                                    }
                                                                }).next() {
                                            let mut err =
                                                tcx.dcx().struct_span_err(hir_ty.span,
                                                    "expected type, found associated function call");
                                            if let Some(between) =
                                                    eq_ctxt_suggestion_span(stmt.pat.span, hir_ty.span) {
                                                err.span_suggestion_verbose(between,
                                                    "use `=` if you meant to assign", " = ",
                                                    Applicability::MaybeIncorrect);
                                            }
                                            self.dcx().try_steal_replace_and_emit_err(hir_ty.span,
                                                StashKey::ReturnTypeNotation, err)
                                        } else if let hir::Node::LetStmt(stmt) =
                                                                tcx.parent_hir_node(hir_ty.hir_id) && let None = stmt.init
                                                        &&
                                                        let hir::TyKind::Path(hir::QPath::Resolved(_, self_ty_path))
                                                            = hir_self_ty.kind && let Res::PrimTy(_) = self_ty_path.res
                                                &&
                                                self.dcx().has_stashed_diagnostic(hir_ty.span,
                                                    StashKey::ReturnTypeNotation) {
                                            let mut err =
                                                tcx.dcx().struct_span_err(hir_ty.span,
                                                    "expected type, found associated function call");
                                            if let Some(between) =
                                                    eq_ctxt_suggestion_span(stmt.pat.span, hir_ty.span) {
                                                err.span_suggestion_verbose(between,
                                                    "use `=` if you meant to assign", " = ",
                                                    Applicability::MaybeIncorrect);
                                            }
                                            self.dcx().try_steal_replace_and_emit_err(hir_ty.span,
                                                StashKey::ReturnTypeNotation, err)
                                        } else {
                                            let suggestion =
                                                if self.dcx().has_stashed_diagnostic(hir_ty.span,
                                                        StashKey::ReturnTypeNotation) {
                                                    Some(segment.ident.span.shrink_to_hi().with_hi(hir_ty.span.hi()))
                                                } else { None };
                                            let err =
                                                self.dcx().create_err(BadReturnTypeNotation {
                                                        span: hir_ty.span,
                                                        suggestion,
                                                    });
                                            self.dcx().try_steal_replace_and_emit_err(hir_ty.span,
                                                StashKey::ReturnTypeNotation, err)
                                        };
                                    Ty::new_error(tcx, guar)
                                }
                                hir::TyKind::Path(hir::QPath::TypeRelative(hir_self_ty,
                                    segment)) => {
                                    {
                                        use ::tracing::__macro_support::Callsite as _;
                                        static __CALLSITE: ::tracing::callsite::DefaultCallsite =
                                            {
                                                static META: ::tracing::Metadata<'static> =
                                                    {
                                                        ::tracing_core::metadata::Metadata::new("event /rustc-dev/a36d05efab632d1ddf902b6a5c33b6d5d3b64131/compiler/rustc_hir_analysis/src/hir_ty_lowering/mod.rs:3410",
                                                            "rustc_hir_analysis::hir_ty_lowering",
                                                            ::tracing::Level::DEBUG,
                                                            ::tracing_core::__macro_support::Option::Some("/rustc-dev/a36d05efab632d1ddf902b6a5c33b6d5d3b64131/compiler/rustc_hir_analysis/src/hir_ty_lowering/mod.rs"),
                                                            ::tracing_core::__macro_support::Option::Some(3410u32),
                                                            ::tracing_core::__macro_support::Option::Some("rustc_hir_analysis::hir_ty_lowering"),
                                                            ::tracing_core::field::FieldSet::new(&[{
                                                                                const NAME:
                                                                                    ::tracing::__macro_support::FieldName<{
                                                                                        ::tracing::__macro_support::FieldName::len("hir_self_ty")
                                                                                    }> =
                                                                                    ::tracing::__macro_support::FieldName::new("hir_self_ty");
                                                                                NAME.as_str()
                                                                            },
                                                                            {
                                                                                const NAME:
                                                                                    ::tracing::__macro_support::FieldName<{
                                                                                        ::tracing::__macro_support::FieldName::len("segment")
                                                                                    }> =
                                                                                    ::tracing::__macro_support::FieldName::new("segment");
                                                                                NAME.as_str()
                                                                            }], ::tracing_core::callsite::Identifier(&__CALLSITE)),
                                                            ::tracing::metadata::Kind::EVENT)
                                                    };
                                                ::tracing::callsite::DefaultCallsite::new(&META)
                                            };
                                        let enabled =
                                            ::tracing::Level::DEBUG <=
                                                        ::tracing::level_filters::STATIC_MAX_LEVEL &&
                                                    ::tracing::Level::DEBUG <=
                                                        ::tracing::level_filters::LevelFilter::current() &&
                                                {
                                                    let interest = __CALLSITE.interest();
                                                    !interest.is_never() &&
                                                        ::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
                                                            interest)
                                                };
                                        if enabled {
                                            (|value_set: ::tracing::field::ValueSet|
                                                        {
                                                            let meta = __CALLSITE.metadata();
                                                            ::tracing::Event::dispatch(meta, &value_set);
                                                            ;
                                                        })({
                                                    #[allow(unused_imports)]
                                                    use ::tracing::field::{debug, display, Value};
                                                    __CALLSITE.metadata().fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&hir_self_ty)
                                                                                as &dyn ::tracing::field::Value)),
                                                                    (::tracing::__macro_support::Option::Some(&::tracing::field::debug(&segment)
                                                                                as &dyn ::tracing::field::Value))])
                                                });
                                        } else { ; }
                                    };
                                    let self_ty = self.lower_ty(hir_self_ty);
                                    self.lower_type_relative_ty_path(self_ty, hir_self_ty,
                                                segment, hir_ty.hir_id, hir_ty.span,
                                                PermitVariants::No).map(|(ty, _, _)|
                                                ty).unwrap_or_else(|guar| Ty::new_error(tcx, guar))
                                }
                                hir::TyKind::Array(ty, length) => {
                                    let length = self.lower_const_arg(length, tcx.types.usize);
                                    Ty::new_array_with_const_len(tcx, self.lower_ty(ty), length)
                                }
                                hir::TyKind::Infer(()) => {
                                    self.ty_infer(None, hir_ty.span)
                                }
                                hir::TyKind::Pat(ty, pat) => {
                                    let ty_span = ty.span;
                                    let ty = self.lower_ty(ty);
                                    let pat_ty =
                                        match self.lower_pat_ty_pat(ty, ty_span, pat) {
                                            Ok(kind) => Ty::new_pat(tcx, ty, tcx.mk_pat(kind)),
                                            Err(guar) => Ty::new_error(tcx, guar),
                                        };
                                    self.record_ty(pat.hir_id, ty, pat.span);
                                    pat_ty
                                }
                                hir::TyKind::FieldOf(ty, hir::TyFieldPath { variant, field
                                    }) =>
                                    self.lower_field_of(self.lower_ty(ty), self.item_def_id(),
                                        ty.span, hir_ty.hir_id, *variant, *field),
                                hir::TyKind::View(ty, fields) => {
                                    self.lower_view(self.lower_ty(ty), fields, hir_ty.span)
                                }
                                hir::TyKind::Err(guar) => Ty::new_error(tcx, *guar),
                            };
                        self.record_ty(hir_ty.hir_id, result_ty, hir_ty.span);
                        result_ty
                    }
                })();
{
    use ::tracing::__macro_support::Callsite as _;
    static __CALLSITE: ::tracing::callsite::DefaultCallsite =
        {
            static META: ::tracing::Metadata<'static> =
                {
                    ::tracing_core::metadata::Metadata::new("event /rustc-dev/a36d05efab632d1ddf902b6a5c33b6d5d3b64131/compiler/rustc_hir_analysis/src/hir_ty_lowering/mod.rs:3208",
                        "rustc_hir_analysis::hir_ty_lowering",
                        ::tracing::Level::DEBUG,
                        ::tracing_core::__macro_support::Option::Some("/rustc-dev/a36d05efab632d1ddf902b6a5c33b6d5d3b64131/compiler/rustc_hir_analysis/src/hir_ty_lowering/mod.rs"),
                        ::tracing_core::__macro_support::Option::Some(3208u32),
                        ::tracing_core::__macro_support::Option::Some("rustc_hir_analysis::hir_ty_lowering"),
                        ::tracing_core::field::FieldSet::new(&[{
                                            const NAME:
                                                ::tracing::__macro_support::FieldName<{
                                                    ::tracing::__macro_support::FieldName::len("return")
                                                }> =
                                                ::tracing::__macro_support::FieldName::new("return");
                                            NAME.as_str()
                                        }], ::tracing_core::callsite::Identifier(&__CALLSITE)),
                        ::tracing::metadata::Kind::EVENT)
                };
            ::tracing::callsite::DefaultCallsite::new(&META)
        };
    let enabled =
        ::tracing::Level::DEBUG <= ::tracing::level_filters::STATIC_MAX_LEVEL
                &&
                ::tracing::Level::DEBUG <=
                    ::tracing::level_filters::LevelFilter::current() &&
            {
                let interest = __CALLSITE.interest();
                !interest.is_never() &&
                    ::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
                        interest)
            };
    if enabled {
        (|value_set: ::tracing::field::ValueSet|
                    {
                        let meta = __CALLSITE.metadata();
                        ::tracing::Event::dispatch(meta, &value_set);
                        ;
                    })({
                #[allow(unused_imports)]
                use ::tracing::field::{debug, display, Value};
                __CALLSITE.metadata().fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&x)
                                            as &dyn ::tracing::field::Value))])
            });
    } else { ; }
};
x;#[instrument(level = "debug", skip(self), ret)]
3209    pub fn lower_ty(&self, hir_ty: &hir::Ty<'_>) -> Ty<'tcx> {
3210        let tcx = self.tcx();
3211
3212        let result_ty = match &hir_ty.kind {
3213            hir::TyKind::InferDelegation(infer) => self.lower_delegation_ty(*infer),
3214            hir::TyKind::Slice(ty) => Ty::new_slice(tcx, self.lower_ty(ty)),
3215            hir::TyKind::Ptr(mt) => Ty::new_ptr(tcx, self.lower_ty(mt.ty), mt.mutbl),
3216            hir::TyKind::Ref(region, mt) => {
3217                let r = self.lower_lifetime(region, RegionInferReason::Reference);
3218                debug!(?r);
3219                let t = self.lower_ty(mt.ty);
3220                Ty::new_ref(tcx, r, t, mt.mutbl)
3221            }
3222            hir::TyKind::Never => tcx.types.never,
3223            hir::TyKind::Tup(fields) => {
3224                Ty::new_tup_from_iter(tcx, fields.iter().map(|t| self.lower_ty(t)))
3225            }
3226            hir::TyKind::FnPtr(bf) => {
3227                check_c_variadic_abi(tcx, bf.decl, bf.abi, hir_ty.span);
3228
3229                Ty::new_fn_ptr(
3230                    tcx,
3231                    self.lower_fn_ty(hir_ty.hir_id, bf.safety, bf.abi, bf.decl, None, Some(hir_ty)),
3232                )
3233            }
3234            hir::TyKind::UnsafeBinder(binder) => Ty::new_unsafe_binder(
3235                tcx,
3236                ty::Binder::bind_with_vars(
3237                    self.lower_ty(binder.inner_ty),
3238                    tcx.late_bound_vars(hir_ty.hir_id),
3239                ),
3240            ),
3241            hir::TyKind::TraitObject(bounds, tagged_ptr) => {
3242                let lifetime = tagged_ptr.pointer();
3243                let syntax = tagged_ptr.tag();
3244                self.lower_trait_object_ty(hir_ty.span, hir_ty.hir_id, bounds, lifetime, syntax)
3245            }
3246            // If we encounter a fully qualified path with RTN generics, then it must have
3247            // *not* gone through `lower_ty_maybe_return_type_notation`, and therefore
3248            // it's certainly in an illegal position.
3249            hir::TyKind::Path(hir::QPath::Resolved(_, path))
3250                if path.segments.last().and_then(|segment| segment.args).is_some_and(|args| {
3251                    matches!(args.parenthesized, hir::GenericArgsParentheses::ReturnTypeNotation)
3252                }) =>
3253            {
3254                let guar = self
3255                    .dcx()
3256                    .emit_err(BadReturnTypeNotation { span: hir_ty.span, suggestion: None });
3257                Ty::new_error(tcx, guar)
3258            }
3259            hir::TyKind::Path(hir::QPath::Resolved(maybe_qself, path)) => {
3260                debug!(?maybe_qself, ?path);
3261                let opt_self_ty = maybe_qself.as_ref().map(|qself| self.lower_ty(qself));
3262                self.lower_resolved_ty_path(opt_self_ty, path, hir_ty.hir_id, PermitVariants::No)
3263            }
3264            &hir::TyKind::OpaqueDef(opaque_ty) => {
3265                // If this is an RPITIT and we are using the new RPITIT lowering scheme, we
3266                // generate the def_id of an associated type for the trait and return as
3267                // type a projection.
3268                let in_trait = match opaque_ty.origin {
3269                    hir::OpaqueTyOrigin::FnReturn {
3270                        parent,
3271                        in_trait_or_impl: Some(hir::RpitContext::Trait),
3272                        ..
3273                    }
3274                    | hir::OpaqueTyOrigin::AsyncFn {
3275                        parent,
3276                        in_trait_or_impl: Some(hir::RpitContext::Trait),
3277                        ..
3278                    } => Some(parent),
3279                    hir::OpaqueTyOrigin::FnReturn {
3280                        in_trait_or_impl: None | Some(hir::RpitContext::TraitImpl),
3281                        ..
3282                    }
3283                    | hir::OpaqueTyOrigin::AsyncFn {
3284                        in_trait_or_impl: None | Some(hir::RpitContext::TraitImpl),
3285                        ..
3286                    }
3287                    | hir::OpaqueTyOrigin::TyAlias { .. } => None,
3288                };
3289
3290                self.lower_opaque_ty(opaque_ty.def_id, in_trait)
3291            }
3292            hir::TyKind::TraitAscription(hir_bounds) => {
3293                // Impl trait in bindings lower as an infer var with additional
3294                // set of type bounds.
3295                let self_ty = self.ty_infer(None, hir_ty.span);
3296                let mut bounds = Vec::new();
3297                self.lower_bounds(
3298                    self_ty,
3299                    hir_bounds.iter(),
3300                    &mut bounds,
3301                    ty::List::empty(),
3302                    PredicateFilter::All,
3303                    OverlappingAsssocItemConstraints::Allowed,
3304                );
3305                self.add_implicit_sizedness_bounds(
3306                    &mut bounds,
3307                    self_ty,
3308                    hir_bounds,
3309                    ImpliedBoundsContext::AssociatedTypeOrImplTrait,
3310                    hir_ty.span,
3311                );
3312                self.register_trait_ascription_bounds(bounds, hir_ty.hir_id, hir_ty.span);
3313                self_ty
3314            }
3315            // If we encounter a type relative path with RTN generics, then it must have
3316            // *not* gone through `lower_ty_maybe_return_type_notation`, and therefore
3317            // it's certainly in an illegal position.
3318            hir::TyKind::Path(hir::QPath::TypeRelative(hir_self_ty, segment))
3319                if segment.args.is_some_and(|args| {
3320                    matches!(args.parenthesized, hir::GenericArgsParentheses::ReturnTypeNotation)
3321                }) =>
3322            {
3323                let guar = if let hir::Node::LetStmt(stmt) = tcx.parent_hir_node(hir_ty.hir_id)
3324                    && let None = stmt.init
3325                    && let hir::TyKind::Path(hir::QPath::Resolved(_, self_ty_path)) =
3326                        hir_self_ty.kind
3327                    && let Res::Def(DefKind::Enum | DefKind::Struct | DefKind::Union, def_id) =
3328                        self_ty_path.res
3329                    && let Some(_) = tcx
3330                        .inherent_impls(def_id)
3331                        .iter()
3332                        .flat_map(|imp| {
3333                            tcx.associated_items(*imp).filter_by_name_unhygienic(segment.ident.name)
3334                        })
3335                        .filter(|assoc| {
3336                            matches!(assoc.kind, ty::AssocKind::Fn { has_self: false, .. })
3337                        })
3338                        .next()
3339                {
3340                    // `let x: S::new(valid_in_ty_ctxt);` -> `let x = S::new(valid_in_ty_ctxt);`
3341                    let mut err = tcx.dcx().struct_span_err(
3342                        hir_ty.span,
3343                        "expected type, found associated function call",
3344                    );
3345                    if let Some(between) = eq_ctxt_suggestion_span(stmt.pat.span, hir_ty.span) {
3346                        err.span_suggestion_verbose(
3347                            between,
3348                            "use `=` if you meant to assign",
3349                            " = ",
3350                            Applicability::MaybeIncorrect,
3351                        );
3352                    }
3353                    self.dcx().try_steal_replace_and_emit_err(
3354                        hir_ty.span,
3355                        StashKey::ReturnTypeNotation,
3356                        err,
3357                    )
3358                } else if let hir::Node::LetStmt(stmt) = tcx.parent_hir_node(hir_ty.hir_id)
3359                    && let None = stmt.init
3360                    && let hir::TyKind::Path(hir::QPath::Resolved(_, self_ty_path)) =
3361                        hir_self_ty.kind
3362                    && let Res::PrimTy(_) = self_ty_path.res
3363                    && self.dcx().has_stashed_diagnostic(hir_ty.span, StashKey::ReturnTypeNotation)
3364                {
3365                    // `let x: i32::something(valid_in_ty_ctxt);` -> `let x = i32::something(valid_in_ty_ctxt);`
3366                    // FIXME: Check that `something` is a valid function in `i32`.
3367                    let mut err = tcx.dcx().struct_span_err(
3368                        hir_ty.span,
3369                        "expected type, found associated function call",
3370                    );
3371                    if let Some(between) = eq_ctxt_suggestion_span(stmt.pat.span, hir_ty.span) {
3372                        err.span_suggestion_verbose(
3373                            between,
3374                            "use `=` if you meant to assign",
3375                            " = ",
3376                            Applicability::MaybeIncorrect,
3377                        );
3378                    }
3379                    self.dcx().try_steal_replace_and_emit_err(
3380                        hir_ty.span,
3381                        StashKey::ReturnTypeNotation,
3382                        err,
3383                    )
3384                } else {
3385                    let suggestion = if self
3386                        .dcx()
3387                        .has_stashed_diagnostic(hir_ty.span, StashKey::ReturnTypeNotation)
3388                    {
3389                        // We already created a diagnostic complaining that `foo(bar)` is wrong and
3390                        // should have been `foo(..)`. Instead, emit only the current error and
3391                        // include that prior suggestion. Changes are that the problems go further,
3392                        // but keep the suggestion just in case. Either way, we want a single error
3393                        // instead of two.
3394                        Some(segment.ident.span.shrink_to_hi().with_hi(hir_ty.span.hi()))
3395                    } else {
3396                        None
3397                    };
3398                    let err = self
3399                        .dcx()
3400                        .create_err(BadReturnTypeNotation { span: hir_ty.span, suggestion });
3401                    self.dcx().try_steal_replace_and_emit_err(
3402                        hir_ty.span,
3403                        StashKey::ReturnTypeNotation,
3404                        err,
3405                    )
3406                };
3407                Ty::new_error(tcx, guar)
3408            }
3409            hir::TyKind::Path(hir::QPath::TypeRelative(hir_self_ty, segment)) => {
3410                debug!(?hir_self_ty, ?segment);
3411                let self_ty = self.lower_ty(hir_self_ty);
3412                self.lower_type_relative_ty_path(
3413                    self_ty,
3414                    hir_self_ty,
3415                    segment,
3416                    hir_ty.hir_id,
3417                    hir_ty.span,
3418                    PermitVariants::No,
3419                )
3420                .map(|(ty, _, _)| ty)
3421                .unwrap_or_else(|guar| Ty::new_error(tcx, guar))
3422            }
3423            hir::TyKind::Array(ty, length) => {
3424                let length = self.lower_const_arg(length, tcx.types.usize);
3425                Ty::new_array_with_const_len(tcx, self.lower_ty(ty), length)
3426            }
3427            hir::TyKind::Infer(()) => {
3428                // Infer also appears as the type of arguments or return
3429                // values in an ExprKind::Closure, or as
3430                // the type of local variables. Both of these cases are
3431                // handled specially and will not descend into this routine.
3432                self.ty_infer(None, hir_ty.span)
3433            }
3434            hir::TyKind::Pat(ty, pat) => {
3435                let ty_span = ty.span;
3436                let ty = self.lower_ty(ty);
3437                let pat_ty = match self.lower_pat_ty_pat(ty, ty_span, pat) {
3438                    Ok(kind) => Ty::new_pat(tcx, ty, tcx.mk_pat(kind)),
3439                    Err(guar) => Ty::new_error(tcx, guar),
3440                };
3441                self.record_ty(pat.hir_id, ty, pat.span);
3442                pat_ty
3443            }
3444            hir::TyKind::FieldOf(ty, hir::TyFieldPath { variant, field }) => self.lower_field_of(
3445                self.lower_ty(ty),
3446                self.item_def_id(),
3447                ty.span,
3448                hir_ty.hir_id,
3449                *variant,
3450                *field,
3451            ),
3452            hir::TyKind::View(ty, fields) => {
3453                self.lower_view(self.lower_ty(ty), fields, hir_ty.span)
3454            }
3455
3456            hir::TyKind::Err(guar) => Ty::new_error(tcx, *guar),
3457        };
3458
3459        self.record_ty(hir_ty.hir_id, result_ty, hir_ty.span);
3460        result_ty
3461    }
3462
3463    fn lower_pat_ty_pat(
3464        &self,
3465        ty: Ty<'tcx>,
3466        ty_span: Span,
3467        pat: &hir::TyPat<'_>,
3468    ) -> Result<ty::PatternKind<'tcx>, ErrorGuaranteed> {
3469        let tcx = self.tcx();
3470        match pat.kind {
3471            hir::TyPatKind::Range(start, end) => {
3472                match ty.kind() {
3473                    // Keep this list of types in sync with the list of types that
3474                    // the `RangePattern` trait is implemented for.
3475                    ty::Int(_) | ty::Uint(_) | ty::Char => {
3476                        let start = self.lower_const_arg(start, ty);
3477                        let end = self.lower_const_arg(end, ty);
3478                        Ok(ty::PatternKind::Range { start, end })
3479                    }
3480                    _ => Err(self
3481                        .dcx()
3482                        .span_delayed_bug(ty_span, "invalid base type for range pattern")),
3483                }
3484            }
3485            hir::TyPatKind::NotNull => Ok(ty::PatternKind::NotNull),
3486            hir::TyPatKind::Or(patterns) => {
3487                self.tcx()
3488                    .mk_patterns_from_iter(patterns.iter().map(|pat| {
3489                        self.lower_pat_ty_pat(ty, ty_span, pat).map(|pat| tcx.mk_pat(pat))
3490                    }))
3491                    .map(ty::PatternKind::Or)
3492            }
3493            hir::TyPatKind::Err(e) => Err(e),
3494        }
3495    }
3496
3497    fn lower_field_of(
3498        &self,
3499        ty: Ty<'tcx>,
3500        item_def_id: LocalDefId,
3501        ty_span: Span,
3502        hir_id: HirId,
3503        variant: Option<Ident>,
3504        field: Ident,
3505    ) -> Ty<'tcx> {
3506        let dcx = self.dcx();
3507        let tcx = self.tcx();
3508        match ty.kind() {
3509            ty::Adt(def, _) => {
3510                let base_did = def.did();
3511                let kind_name = tcx.def_descr(base_did);
3512                let (variant_idx, variant) = if def.is_enum() {
3513                    let Some(variant) = variant else {
3514                        let err = dcx
3515                            .create_err(NoVariantNamed { span: field.span, ident: field, ty })
3516                            .with_span_help(
3517                                field.span.shrink_to_lo(),
3518                                "you might be missing a variant here: `Variant.`",
3519                            )
3520                            .emit();
3521                        return Ty::new_error(tcx, err);
3522                    };
3523
3524                    if let Some(res) = def
3525                        .variants()
3526                        .iter_enumerated()
3527                        .find(|(_, f)| f.ident(tcx).normalize_to_macros_2_0() == variant)
3528                    {
3529                        res
3530                    } else {
3531                        let err = dcx
3532                            .create_err(NoVariantNamed { span: variant.span, ident: variant, ty })
3533                            .emit();
3534                        return Ty::new_error(tcx, err);
3535                    }
3536                } else {
3537                    if let Some(variant) = variant {
3538                        let adt_path = tcx.def_path_str(base_did);
3539                        {
    dcx.struct_span_err(variant.span,
            ::alloc::__export::must_use({
                    ::alloc::fmt::format(format_args!("{0} `{1}` does not have any variants",
                            kind_name, adt_path))
                })).with_code(E0609)
}struct_span_code_err!(
3540                            dcx,
3541                            variant.span,
3542                            E0609,
3543                            "{kind_name} `{adt_path}` does not have any variants",
3544                        )
3545                        .with_span_label(variant.span, "variant unknown")
3546                        .emit();
3547                    }
3548                    (FIRST_VARIANT, def.non_enum_variant())
3549                };
3550                let (ident, def_scope) =
3551                    tcx.adjust_ident_and_get_scope(field, def.did(), item_def_id);
3552                if let Some((field_idx, field)) = variant
3553                    .fields
3554                    .iter_enumerated()
3555                    .find(|(_, f)| f.ident(tcx).normalize_to_macros_2_0() == ident)
3556                {
3557                    if field.vis.is_accessible_from(def_scope, tcx) {
3558                        tcx.check_stability(field.did, Some(hir_id), ident.span, None);
3559                    } else {
3560                        let adt_path = tcx.def_path_str(base_did);
3561                        {
    dcx.struct_span_err(ident.span,
            ::alloc::__export::must_use({
                    ::alloc::fmt::format(format_args!("field `{0}` of {1} `{2}` is private",
                            ident, kind_name, adt_path))
                })).with_code(E0616)
}struct_span_code_err!(
3562                            dcx,
3563                            ident.span,
3564                            E0616,
3565                            "field `{ident}` of {kind_name} `{adt_path}` is private",
3566                        )
3567                        .with_span_label(ident.span, "private field")
3568                        .emit();
3569                    }
3570                    Ty::new_field_representing_type(tcx, ty, variant_idx, field_idx)
3571                } else {
3572                    let err =
3573                        dcx.create_err(NoFieldOnType { span: ident.span, field: ident, ty }).emit();
3574                    Ty::new_error(tcx, err)
3575                }
3576            }
3577            ty::Tuple(tys) => {
3578                let index = match field.as_str().parse::<usize>() {
3579                    Ok(idx) => idx,
3580                    Err(_) => {
3581                        let err =
3582                            dcx.create_err(NoFieldOnType { span: field.span, field, ty }).emit();
3583                        return Ty::new_error(tcx, err);
3584                    }
3585                };
3586                if field.name != sym::integer(index) {
3587                    ::rustc_middle::util::bug::bug_fmt(format_args!("we parsed above, but now not equal?"));bug!("we parsed above, but now not equal?");
3588                }
3589                if tys.get(index).is_some() {
3590                    Ty::new_field_representing_type(tcx, ty, FIRST_VARIANT, index.into())
3591                } else {
3592                    let err = dcx.create_err(NoFieldOnType { span: field.span, field, ty }).emit();
3593                    Ty::new_error(tcx, err)
3594                }
3595            }
3596            // FIXME(FRTs): support type aliases
3597            /*
3598            ty::Alias(AliasTyKind::Free, ty) => {
3599                return self.lower_field_of(
3600                    ty,
3601                    item_def_id,
3602                    ty_span,
3603                    hir_id,
3604                    variant,
3605                    field,
3606                );
3607            }*/
3608            ty::Alias(..) => Ty::new_error(
3609                tcx,
3610                dcx.span_err(ty_span, ::alloc::__export::must_use({
        ::alloc::fmt::format(format_args!("could not resolve fields of `{0}`",
                ty))
    })format!("could not resolve fields of `{ty}`")),
3611            ),
3612            ty::Error(err) => Ty::new_error(tcx, *err),
3613            ty::Bool
3614            | ty::Char
3615            | ty::Int(_)
3616            | ty::Uint(_)
3617            | ty::Float(_)
3618            | ty::Foreign(_)
3619            | ty::Str
3620            | ty::RawPtr(_, _)
3621            | ty::Ref(_, _, _)
3622            | ty::FnDef(_, _)
3623            | ty::FnPtr(_, _)
3624            | ty::UnsafeBinder(_)
3625            | ty::Dynamic(_, _)
3626            | ty::Closure(_, _)
3627            | ty::CoroutineClosure(_, _)
3628            | ty::Coroutine(_, _)
3629            | ty::CoroutineWitness(_, _)
3630            | ty::Never
3631            | ty::Param(_)
3632            | ty::Bound(_, _)
3633            | ty::Placeholder(_)
3634            | ty::Slice(..) => Ty::new_error(
3635                tcx,
3636                dcx.span_err(ty_span, ::alloc::__export::must_use({
        ::alloc::fmt::format(format_args!("type `{0}` doesn\'t have fields",
                ty))
    })format!("type `{ty}` doesn't have fields")),
3637            ),
3638            ty::Infer(_) => Ty::new_error(
3639                tcx,
3640                dcx.span_err(ty_span, ::alloc::__export::must_use({
        ::alloc::fmt::format(format_args!("cannot use `{0}` in this position",
                ty))
    })format!("cannot use `{ty}` in this position")),
3641            ),
3642            // FIXME(FRTs): support these types?
3643            ty::Array(..) | ty::Pat(..) => Ty::new_error(
3644                tcx,
3645                dcx.span_err(ty_span, ::alloc::__export::must_use({
        ::alloc::fmt::format(format_args!("type `{0}` is not yet supported in `field_of!`",
                ty))
    })format!("type `{ty}` is not yet supported in `field_of!`")),
3646            ),
3647        }
3648    }
3649
3650    /// Lower an opaque type (i.e., an existential impl-Trait type) from the HIR.
3651    {}
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("lower_opaque_ty",
                                "rustc_hir_analysis::hir_ty_lowering",
                                ::tracing::Level::DEBUG,
                                ::tracing_core::__macro_support::Option::Some("/rustc-dev/a36d05efab632d1ddf902b6a5c33b6d5d3b64131/compiler/rustc_hir_analysis/src/hir_ty_lowering/mod.rs"),
                                ::tracing_core::__macro_support::Option::Some(3651u32),
                                ::tracing_core::__macro_support::Option::Some("rustc_hir_analysis::hir_ty_lowering"),
                                ::tracing_core::field::FieldSet::new(&[{
                                                    const NAME:
                                                        ::tracing::__macro_support::FieldName<{
                                                            ::tracing::__macro_support::FieldName::len("def_id")
                                                        }> =
                                                        ::tracing::__macro_support::FieldName::new("def_id");
                                                    NAME.as_str()
                                                },
                                                {
                                                    const NAME:
                                                        ::tracing::__macro_support::FieldName<{
                                                            ::tracing::__macro_support::FieldName::len("in_trait")
                                                        }> =
                                                        ::tracing::__macro_support::FieldName::new("in_trait");
                                                    NAME.as_str()
                                                }], ::tracing_core::callsite::Identifier(&__CALLSITE)),
                                ::tracing::metadata::Kind::SPAN)
                        };
                    ::tracing::callsite::DefaultCallsite::new(&META)
                };
            let mut interest = ::tracing::subscriber::Interest::never();
            if ::tracing::Level::DEBUG <=
                                ::tracing::level_filters::STATIC_MAX_LEVEL &&
                            ::tracing::Level::DEBUG <=
                                ::tracing::level_filters::LevelFilter::current() &&
                        { interest = __CALLSITE.interest(); !interest.is_never() }
                    &&
                    ::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
                        interest) {
                let meta = __CALLSITE.metadata();
                ::tracing::Span::new(meta,
                    &{
                            #[allow(unused_imports)]
                            use ::tracing::field::{debug, display, Value};
                            meta.fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&def_id)
                                                        as &dyn ::tracing::field::Value)),
                                            (::tracing::__macro_support::Option::Some(&::tracing::field::debug(&in_trait)
                                                        as &dyn ::tracing::field::Value))])
                        })
            } else {
                let span =
                    ::tracing::__macro_support::__disabled_span(__CALLSITE.metadata());
                {};
                span
            }
        };
    __tracing_attr_guard = __tracing_attr_span.enter();
}
#[allow(clippy :: redundant_closure_call)]
let x =
    (move ||
                {

                    #[allow(unknown_lints, unreachable_code, clippy ::
                    diverging_sub_expression, clippy :: empty_loop, clippy ::
                    let_unit_value, clippy :: let_with_type_underscore, clippy
                    :: needless_return, clippy :: unreachable)]
                    if false {
                        let __tracing_attr_fake_return: Ty<'tcx> = loop {};
                        return __tracing_attr_fake_return;
                    }
                    {
                        let tcx = self.tcx();
                        let lifetimes = tcx.opaque_captured_lifetimes(def_id);
                        {
                            use ::tracing::__macro_support::Callsite as _;
                            static __CALLSITE: ::tracing::callsite::DefaultCallsite =
                                {
                                    static META: ::tracing::Metadata<'static> =
                                        {
                                            ::tracing_core::metadata::Metadata::new("event /rustc-dev/a36d05efab632d1ddf902b6a5c33b6d5d3b64131/compiler/rustc_hir_analysis/src/hir_ty_lowering/mod.rs:3656",
                                                "rustc_hir_analysis::hir_ty_lowering",
                                                ::tracing::Level::DEBUG,
                                                ::tracing_core::__macro_support::Option::Some("/rustc-dev/a36d05efab632d1ddf902b6a5c33b6d5d3b64131/compiler/rustc_hir_analysis/src/hir_ty_lowering/mod.rs"),
                                                ::tracing_core::__macro_support::Option::Some(3656u32),
                                                ::tracing_core::__macro_support::Option::Some("rustc_hir_analysis::hir_ty_lowering"),
                                                ::tracing_core::field::FieldSet::new(&[{
                                                                    const NAME:
                                                                        ::tracing::__macro_support::FieldName<{
                                                                            ::tracing::__macro_support::FieldName::len("lifetimes")
                                                                        }> =
                                                                        ::tracing::__macro_support::FieldName::new("lifetimes");
                                                                    NAME.as_str()
                                                                }], ::tracing_core::callsite::Identifier(&__CALLSITE)),
                                                ::tracing::metadata::Kind::EVENT)
                                        };
                                    ::tracing::callsite::DefaultCallsite::new(&META)
                                };
                            let enabled =
                                ::tracing::Level::DEBUG <=
                                            ::tracing::level_filters::STATIC_MAX_LEVEL &&
                                        ::tracing::Level::DEBUG <=
                                            ::tracing::level_filters::LevelFilter::current() &&
                                    {
                                        let interest = __CALLSITE.interest();
                                        !interest.is_never() &&
                                            ::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
                                                interest)
                                    };
                            if enabled {
                                (|value_set: ::tracing::field::ValueSet|
                                            {
                                                let meta = __CALLSITE.metadata();
                                                ::tracing::Event::dispatch(meta, &value_set);
                                                ;
                                            })({
                                        #[allow(unused_imports)]
                                        use ::tracing::field::{debug, display, Value};
                                        __CALLSITE.metadata().fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&lifetimes)
                                                                    as &dyn ::tracing::field::Value))])
                                    });
                            } else { ; }
                        };
                        let def_id =
                            if let Some(parent_def_id) = in_trait {
                                *tcx.associated_types_for_impl_traits_in_associated_fn(parent_def_id.to_def_id()).iter().find(|rpitit|
                                                match tcx.opt_rpitit_info(**rpitit) {
                                                    Some(ty::ImplTraitInTraitData::Trait { opaque_def_id, .. })
                                                        => {
                                                        opaque_def_id.expect_local() == def_id
                                                    }
                                                    _ =>
                                                        ::core::panicking::panic("internal error: entered unreachable code"),
                                                }).unwrap()
                            } else { def_id.to_def_id() };
                        let generics = tcx.generics_of(def_id);
                        {
                            use ::tracing::__macro_support::Callsite as _;
                            static __CALLSITE: ::tracing::callsite::DefaultCallsite =
                                {
                                    static META: ::tracing::Metadata<'static> =
                                        {
                                            ::tracing_core::metadata::Metadata::new("event /rustc-dev/a36d05efab632d1ddf902b6a5c33b6d5d3b64131/compiler/rustc_hir_analysis/src/hir_ty_lowering/mod.rs:3676",
                                                "rustc_hir_analysis::hir_ty_lowering",
                                                ::tracing::Level::DEBUG,
                                                ::tracing_core::__macro_support::Option::Some("/rustc-dev/a36d05efab632d1ddf902b6a5c33b6d5d3b64131/compiler/rustc_hir_analysis/src/hir_ty_lowering/mod.rs"),
                                                ::tracing_core::__macro_support::Option::Some(3676u32),
                                                ::tracing_core::__macro_support::Option::Some("rustc_hir_analysis::hir_ty_lowering"),
                                                ::tracing_core::field::FieldSet::new(&[{
                                                                    const NAME:
                                                                        ::tracing::__macro_support::FieldName<{
                                                                            ::tracing::__macro_support::FieldName::len("generics")
                                                                        }> =
                                                                        ::tracing::__macro_support::FieldName::new("generics");
                                                                    NAME.as_str()
                                                                }], ::tracing_core::callsite::Identifier(&__CALLSITE)),
                                                ::tracing::metadata::Kind::EVENT)
                                        };
                                    ::tracing::callsite::DefaultCallsite::new(&META)
                                };
                            let enabled =
                                ::tracing::Level::DEBUG <=
                                            ::tracing::level_filters::STATIC_MAX_LEVEL &&
                                        ::tracing::Level::DEBUG <=
                                            ::tracing::level_filters::LevelFilter::current() &&
                                    {
                                        let interest = __CALLSITE.interest();
                                        !interest.is_never() &&
                                            ::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
                                                interest)
                                    };
                            if enabled {
                                (|value_set: ::tracing::field::ValueSet|
                                            {
                                                let meta = __CALLSITE.metadata();
                                                ::tracing::Event::dispatch(meta, &value_set);
                                                ;
                                            })({
                                        #[allow(unused_imports)]
                                        use ::tracing::field::{debug, display, Value};
                                        __CALLSITE.metadata().fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&generics)
                                                                    as &dyn ::tracing::field::Value))])
                                    });
                            } else { ; }
                        };
                        let offset = generics.count() - lifetimes.len();
                        let args =
                            ty::GenericArgs::for_item(tcx, def_id,
                                |param, _|
                                    {
                                        if let Some(i) = (param.index as usize).checked_sub(offset)
                                            {
                                            let (lifetime, _) = lifetimes[i];
                                            self.lower_resolved_lifetime(lifetime).into()
                                        } else { tcx.mk_param_from_def(param) }
                                    });
                        {
                            use ::tracing::__macro_support::Callsite as _;
                            static __CALLSITE: ::tracing::callsite::DefaultCallsite =
                                {
                                    static META: ::tracing::Metadata<'static> =
                                        {
                                            ::tracing_core::metadata::Metadata::new("event /rustc-dev/a36d05efab632d1ddf902b6a5c33b6d5d3b64131/compiler/rustc_hir_analysis/src/hir_ty_lowering/mod.rs:3692",
                                                "rustc_hir_analysis::hir_ty_lowering",
                                                ::tracing::Level::DEBUG,
                                                ::tracing_core::__macro_support::Option::Some("/rustc-dev/a36d05efab632d1ddf902b6a5c33b6d5d3b64131/compiler/rustc_hir_analysis/src/hir_ty_lowering/mod.rs"),
                                                ::tracing_core::__macro_support::Option::Some(3692u32),
                                                ::tracing_core::__macro_support::Option::Some("rustc_hir_analysis::hir_ty_lowering"),
                                                ::tracing_core::field::FieldSet::new(&[{
                                                                    const NAME:
                                                                        ::tracing::__macro_support::FieldName<{
                                                                            ::tracing::__macro_support::FieldName::len("args")
                                                                        }> =
                                                                        ::tracing::__macro_support::FieldName::new("args");
                                                                    NAME.as_str()
                                                                }], ::tracing_core::callsite::Identifier(&__CALLSITE)),
                                                ::tracing::metadata::Kind::EVENT)
                                        };
                                    ::tracing::callsite::DefaultCallsite::new(&META)
                                };
                            let enabled =
                                ::tracing::Level::DEBUG <=
                                            ::tracing::level_filters::STATIC_MAX_LEVEL &&
                                        ::tracing::Level::DEBUG <=
                                            ::tracing::level_filters::LevelFilter::current() &&
                                    {
                                        let interest = __CALLSITE.interest();
                                        !interest.is_never() &&
                                            ::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
                                                interest)
                                    };
                            if enabled {
                                (|value_set: ::tracing::field::ValueSet|
                                            {
                                                let meta = __CALLSITE.metadata();
                                                ::tracing::Event::dispatch(meta, &value_set);
                                                ;
                                            })({
                                        #[allow(unused_imports)]
                                        use ::tracing::field::{debug, display, Value};
                                        __CALLSITE.metadata().fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&args)
                                                                    as &dyn ::tracing::field::Value))])
                                    });
                            } else { ; }
                        };
                        if in_trait.is_some() {
                            Ty::new_projection_from_args(tcx, ty::IsRigid::No, def_id,
                                args)
                        } else {
                            Ty::new_opaque(tcx, ty::IsRigid::No, def_id, args)
                        }
                    }
                })();
{
    use ::tracing::__macro_support::Callsite as _;
    static __CALLSITE: ::tracing::callsite::DefaultCallsite =
        {
            static META: ::tracing::Metadata<'static> =
                {
                    ::tracing_core::metadata::Metadata::new("event /rustc-dev/a36d05efab632d1ddf902b6a5c33b6d5d3b64131/compiler/rustc_hir_analysis/src/hir_ty_lowering/mod.rs:3651",
                        "rustc_hir_analysis::hir_ty_lowering",
                        ::tracing::Level::DEBUG,
                        ::tracing_core::__macro_support::Option::Some("/rustc-dev/a36d05efab632d1ddf902b6a5c33b6d5d3b64131/compiler/rustc_hir_analysis/src/hir_ty_lowering/mod.rs"),
                        ::tracing_core::__macro_support::Option::Some(3651u32),
                        ::tracing_core::__macro_support::Option::Some("rustc_hir_analysis::hir_ty_lowering"),
                        ::tracing_core::field::FieldSet::new(&[{
                                            const NAME:
                                                ::tracing::__macro_support::FieldName<{
                                                    ::tracing::__macro_support::FieldName::len("return")
                                                }> =
                                                ::tracing::__macro_support::FieldName::new("return");
                                            NAME.as_str()
                                        }], ::tracing_core::callsite::Identifier(&__CALLSITE)),
                        ::tracing::metadata::Kind::EVENT)
                };
            ::tracing::callsite::DefaultCallsite::new(&META)
        };
    let enabled =
        ::tracing::Level::DEBUG <= ::tracing::level_filters::STATIC_MAX_LEVEL
                &&
                ::tracing::Level::DEBUG <=
                    ::tracing::level_filters::LevelFilter::current() &&
            {
                let interest = __CALLSITE.interest();
                !interest.is_never() &&
                    ::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
                        interest)
            };
    if enabled {
        (|value_set: ::tracing::field::ValueSet|
                    {
                        let meta = __CALLSITE.metadata();
                        ::tracing::Event::dispatch(meta, &value_set);
                        ;
                    })({
                #[allow(unused_imports)]
                use ::tracing::field::{debug, display, Value};
                __CALLSITE.metadata().fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&x)
                                            as &dyn ::tracing::field::Value))])
            });
    } else { ; }
};
x;#[instrument(level = "debug", skip(self), ret)]
3652    fn lower_opaque_ty(&self, def_id: LocalDefId, in_trait: Option<LocalDefId>) -> Ty<'tcx> {
3653        let tcx = self.tcx();
3654
3655        let lifetimes = tcx.opaque_captured_lifetimes(def_id);
3656        debug!(?lifetimes);
3657
3658        // If this is an RPITIT and we are using the new RPITIT lowering scheme,
3659        // do a linear search to map this to the synthetic associated type that
3660        // it will be lowered to.
3661        let def_id = if let Some(parent_def_id) = in_trait {
3662            *tcx.associated_types_for_impl_traits_in_associated_fn(parent_def_id.to_def_id())
3663                .iter()
3664                .find(|rpitit| match tcx.opt_rpitit_info(**rpitit) {
3665                    Some(ty::ImplTraitInTraitData::Trait { opaque_def_id, .. }) => {
3666                        opaque_def_id.expect_local() == def_id
3667                    }
3668                    _ => unreachable!(),
3669                })
3670                .unwrap()
3671        } else {
3672            def_id.to_def_id()
3673        };
3674
3675        let generics = tcx.generics_of(def_id);
3676        debug!(?generics);
3677
3678        // We use `generics.count() - lifetimes.len()` here instead of `generics.parent_count`
3679        // since return-position impl trait in trait squashes all of the generics from its source fn
3680        // into its own generics, so the opaque's "own" params isn't always just lifetimes.
3681        let offset = generics.count() - lifetimes.len();
3682
3683        let args = ty::GenericArgs::for_item(tcx, def_id, |param, _| {
3684            if let Some(i) = (param.index as usize).checked_sub(offset) {
3685                let (lifetime, _) = lifetimes[i];
3686                // FIXME(mgca): should we be calling self.check_params_use_if_mcg here too?
3687                self.lower_resolved_lifetime(lifetime).into()
3688            } else {
3689                tcx.mk_param_from_def(param)
3690            }
3691        });
3692        debug!(?args);
3693
3694        if in_trait.is_some() {
3695            Ty::new_projection_from_args(tcx, ty::IsRigid::No, def_id, args)
3696        } else {
3697            Ty::new_opaque(tcx, ty::IsRigid::No, def_id, args)
3698        }
3699    }
3700
3701    /// Lower a function type from the HIR to our internal notion of a function signature.
3702    {}
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("lower_fn_ty",
                                "rustc_hir_analysis::hir_ty_lowering",
                                ::tracing::Level::DEBUG,
                                ::tracing_core::__macro_support::Option::Some("/rustc-dev/a36d05efab632d1ddf902b6a5c33b6d5d3b64131/compiler/rustc_hir_analysis/src/hir_ty_lowering/mod.rs"),
                                ::tracing_core::__macro_support::Option::Some(3702u32),
                                ::tracing_core::__macro_support::Option::Some("rustc_hir_analysis::hir_ty_lowering"),
                                ::tracing_core::field::FieldSet::new(&[],
                                    ::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,
                    &{ meta.fields().value_set_all(&[]) })
            } else {
                let span =
                    ::tracing::__macro_support::__disabled_span(__CALLSITE.metadata());
                {};
                span
            }
        };
    __tracing_attr_guard = __tracing_attr_span.enter();
}
#[allow(clippy :: redundant_closure_call)]
let x =
    (move ||
                {

                    #[allow(unknown_lints, unreachable_code, clippy ::
                    diverging_sub_expression, clippy :: empty_loop, clippy ::
                    let_unit_value, clippy :: let_with_type_underscore, clippy
                    :: needless_return, clippy :: unreachable)]
                    if false {
                        let __tracing_attr_fake_return: ty::PolyFnSig<'tcx> =
                            loop {};
                        return __tracing_attr_fake_return;
                    }
                    {
                        let tcx = self.tcx();
                        let bound_vars = tcx.late_bound_vars(hir_id);
                        {
                            use ::tracing::__macro_support::Callsite as _;
                            static __CALLSITE: ::tracing::callsite::DefaultCallsite =
                                {
                                    static META: ::tracing::Metadata<'static> =
                                        {
                                            ::tracing_core::metadata::Metadata::new("event /rustc-dev/a36d05efab632d1ddf902b6a5c33b6d5d3b64131/compiler/rustc_hir_analysis/src/hir_ty_lowering/mod.rs:3714",
                                                "rustc_hir_analysis::hir_ty_lowering",
                                                ::tracing::Level::DEBUG,
                                                ::tracing_core::__macro_support::Option::Some("/rustc-dev/a36d05efab632d1ddf902b6a5c33b6d5d3b64131/compiler/rustc_hir_analysis/src/hir_ty_lowering/mod.rs"),
                                                ::tracing_core::__macro_support::Option::Some(3714u32),
                                                ::tracing_core::__macro_support::Option::Some("rustc_hir_analysis::hir_ty_lowering"),
                                                ::tracing_core::field::FieldSet::new(&[{
                                                                    const NAME:
                                                                        ::tracing::__macro_support::FieldName<{
                                                                            ::tracing::__macro_support::FieldName::len("bound_vars")
                                                                        }> =
                                                                        ::tracing::__macro_support::FieldName::new("bound_vars");
                                                                    NAME.as_str()
                                                                }], ::tracing_core::callsite::Identifier(&__CALLSITE)),
                                                ::tracing::metadata::Kind::EVENT)
                                        };
                                    ::tracing::callsite::DefaultCallsite::new(&META)
                                };
                            let enabled =
                                ::tracing::Level::DEBUG <=
                                            ::tracing::level_filters::STATIC_MAX_LEVEL &&
                                        ::tracing::Level::DEBUG <=
                                            ::tracing::level_filters::LevelFilter::current() &&
                                    {
                                        let interest = __CALLSITE.interest();
                                        !interest.is_never() &&
                                            ::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
                                                interest)
                                    };
                            if enabled {
                                (|value_set: ::tracing::field::ValueSet|
                                            {
                                                let meta = __CALLSITE.metadata();
                                                ::tracing::Event::dispatch(meta, &value_set);
                                                ;
                                            })({
                                        #[allow(unused_imports)]
                                        use ::tracing::field::{debug, display, Value};
                                        __CALLSITE.metadata().fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&bound_vars)
                                                                    as &dyn ::tracing::field::Value))])
                                    });
                            } else { ; }
                        };
                        let (input_tys, output_ty) =
                            self.lower_fn_sig(decl, generics, hir_id, hir_ty);
                        {
                            use ::tracing::__macro_support::Callsite as _;
                            static __CALLSITE: ::tracing::callsite::DefaultCallsite =
                                {
                                    static META: ::tracing::Metadata<'static> =
                                        {
                                            ::tracing_core::metadata::Metadata::new("event /rustc-dev/a36d05efab632d1ddf902b6a5c33b6d5d3b64131/compiler/rustc_hir_analysis/src/hir_ty_lowering/mod.rs:3718",
                                                "rustc_hir_analysis::hir_ty_lowering",
                                                ::tracing::Level::DEBUG,
                                                ::tracing_core::__macro_support::Option::Some("/rustc-dev/a36d05efab632d1ddf902b6a5c33b6d5d3b64131/compiler/rustc_hir_analysis/src/hir_ty_lowering/mod.rs"),
                                                ::tracing_core::__macro_support::Option::Some(3718u32),
                                                ::tracing_core::__macro_support::Option::Some("rustc_hir_analysis::hir_ty_lowering"),
                                                ::tracing_core::field::FieldSet::new(&[{
                                                                    const NAME:
                                                                        ::tracing::__macro_support::FieldName<{
                                                                            ::tracing::__macro_support::FieldName::len("output_ty")
                                                                        }> =
                                                                        ::tracing::__macro_support::FieldName::new("output_ty");
                                                                    NAME.as_str()
                                                                }], ::tracing_core::callsite::Identifier(&__CALLSITE)),
                                                ::tracing::metadata::Kind::EVENT)
                                        };
                                    ::tracing::callsite::DefaultCallsite::new(&META)
                                };
                            let enabled =
                                ::tracing::Level::DEBUG <=
                                            ::tracing::level_filters::STATIC_MAX_LEVEL &&
                                        ::tracing::Level::DEBUG <=
                                            ::tracing::level_filters::LevelFilter::current() &&
                                    {
                                        let interest = __CALLSITE.interest();
                                        !interest.is_never() &&
                                            ::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
                                                interest)
                                    };
                            if enabled {
                                (|value_set: ::tracing::field::ValueSet|
                                            {
                                                let meta = __CALLSITE.metadata();
                                                ::tracing::Event::dispatch(meta, &value_set);
                                                ;
                                            })({
                                        #[allow(unused_imports)]
                                        use ::tracing::field::{debug, display, Value};
                                        __CALLSITE.metadata().fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&output_ty)
                                                                    as &dyn ::tracing::field::Value))])
                                    });
                            } else { ; }
                        };
                        {
                            use ::tracing::__macro_support::Callsite as _;
                            static __CALLSITE: ::tracing::callsite::DefaultCallsite =
                                {
                                    static META: ::tracing::Metadata<'static> =
                                        {
                                            ::tracing_core::metadata::Metadata::new("event /rustc-dev/a36d05efab632d1ddf902b6a5c33b6d5d3b64131/compiler/rustc_hir_analysis/src/hir_ty_lowering/mod.rs:3720",
                                                "rustc_hir_analysis::hir_ty_lowering",
                                                ::tracing::Level::DEBUG,
                                                ::tracing_core::__macro_support::Option::Some("/rustc-dev/a36d05efab632d1ddf902b6a5c33b6d5d3b64131/compiler/rustc_hir_analysis/src/hir_ty_lowering/mod.rs"),
                                                ::tracing_core::__macro_support::Option::Some(3720u32),
                                                ::tracing_core::__macro_support::Option::Some("rustc_hir_analysis::hir_ty_lowering"),
                                                ::tracing_core::field::FieldSet::new(&[{
                                                                    const NAME:
                                                                        ::tracing::__macro_support::FieldName<{
                                                                            ::tracing::__macro_support::FieldName::len("abi")
                                                                        }> =
                                                                        ::tracing::__macro_support::FieldName::new("abi");
                                                                    NAME.as_str()
                                                                },
                                                                {
                                                                    const NAME:
                                                                        ::tracing::__macro_support::FieldName<{
                                                                            ::tracing::__macro_support::FieldName::len("safety")
                                                                        }> =
                                                                        ::tracing::__macro_support::FieldName::new("safety");
                                                                    NAME.as_str()
                                                                },
                                                                {
                                                                    const NAME:
                                                                        ::tracing::__macro_support::FieldName<{
                                                                            ::tracing::__macro_support::FieldName::len("decl.fn_decl_kind")
                                                                        }> =
                                                                        ::tracing::__macro_support::FieldName::new("decl.fn_decl_kind");
                                                                    NAME.as_str()
                                                                },
                                                                {
                                                                    const NAME:
                                                                        ::tracing::__macro_support::FieldName<{
                                                                            ::tracing::__macro_support::FieldName::len("input_tys_len")
                                                                        }> =
                                                                        ::tracing::__macro_support::FieldName::new("input_tys_len");
                                                                    NAME.as_str()
                                                                }], ::tracing_core::callsite::Identifier(&__CALLSITE)),
                                                ::tracing::metadata::Kind::EVENT)
                                        };
                                    ::tracing::callsite::DefaultCallsite::new(&META)
                                };
                            let enabled =
                                ::tracing::Level::DEBUG <=
                                            ::tracing::level_filters::STATIC_MAX_LEVEL &&
                                        ::tracing::Level::DEBUG <=
                                            ::tracing::level_filters::LevelFilter::current() &&
                                    {
                                        let interest = __CALLSITE.interest();
                                        !interest.is_never() &&
                                            ::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
                                                interest)
                                    };
                            if enabled {
                                (|value_set: ::tracing::field::ValueSet|
                                            {
                                                let meta = __CALLSITE.metadata();
                                                ::tracing::Event::dispatch(meta, &value_set);
                                                ;
                                            })({
                                        #[allow(unused_imports)]
                                        use ::tracing::field::{debug, display, Value};
                                        __CALLSITE.metadata().fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&abi)
                                                                    as &dyn ::tracing::field::Value)),
                                                        (::tracing::__macro_support::Option::Some(&::tracing::field::debug(&safety)
                                                                    as &dyn ::tracing::field::Value)),
                                                        (::tracing::__macro_support::Option::Some(&::tracing::field::debug(&decl.fn_decl_kind)
                                                                    as &dyn ::tracing::field::Value)),
                                                        (::tracing::__macro_support::Option::Some(&::tracing::field::debug(&input_tys.len())
                                                                    as &dyn ::tracing::field::Value))])
                                    });
                            } else { ; }
                        };
                        let fn_sig_kind =
                            FnSigKind::default().set_abi(abi).set_safety(safety).set_c_variadic(decl.fn_decl_kind.c_variadic()).set_splatted(decl.splatted(),
                                    input_tys.len()).unwrap();
                        let fn_ty =
                            tcx.mk_fn_sig(input_tys, output_ty, fn_sig_kind);
                        let fn_ptr_ty =
                            ty::Binder::bind_with_vars(fn_ty, bound_vars);
                        if let Some(hir::Ty {
                                kind: hir::TyKind::FnPtr(fn_ptr_ty), span, .. }) = hir_ty {
                            check_abi(tcx, hir_id, *span, fn_ptr_ty.abi);
                        }
                        cmse::validate_cmse_abi(self.tcx(), self.dcx(), hir_id, abi,
                            fn_ptr_ty);
                        if !fn_ptr_ty.references_error() {
                            let inputs = fn_ptr_ty.inputs();
                            let late_bound_in_args =
                                tcx.collect_constrained_late_bound_regions(inputs.map_bound(|i|
                                            i.to_owned()));
                            let output = fn_ptr_ty.output();
                            let late_bound_in_ret =
                                tcx.collect_referenced_late_bound_regions(output);
                            self.validate_late_bound_regions(late_bound_in_args,
                                late_bound_in_ret,
                                |br_name|
                                    {
                                        {
                                            self.dcx().struct_span_err(decl.output.span(),
                                                    ::alloc::__export::must_use({
                                                            ::alloc::fmt::format(format_args!("return type references {0}, which is not constrained by the fn input types",
                                                                    br_name))
                                                        })).with_code(E0581)
                                        }
                                    });
                        }
                        fn_ptr_ty
                    }
                })();
{
    use ::tracing::__macro_support::Callsite as _;
    static __CALLSITE: ::tracing::callsite::DefaultCallsite =
        {
            static META: ::tracing::Metadata<'static> =
                {
                    ::tracing_core::metadata::Metadata::new("event /rustc-dev/a36d05efab632d1ddf902b6a5c33b6d5d3b64131/compiler/rustc_hir_analysis/src/hir_ty_lowering/mod.rs:3702",
                        "rustc_hir_analysis::hir_ty_lowering",
                        ::tracing::Level::DEBUG,
                        ::tracing_core::__macro_support::Option::Some("/rustc-dev/a36d05efab632d1ddf902b6a5c33b6d5d3b64131/compiler/rustc_hir_analysis/src/hir_ty_lowering/mod.rs"),
                        ::tracing_core::__macro_support::Option::Some(3702u32),
                        ::tracing_core::__macro_support::Option::Some("rustc_hir_analysis::hir_ty_lowering"),
                        ::tracing_core::field::FieldSet::new(&[{
                                            const NAME:
                                                ::tracing::__macro_support::FieldName<{
                                                    ::tracing::__macro_support::FieldName::len("return")
                                                }> =
                                                ::tracing::__macro_support::FieldName::new("return");
                                            NAME.as_str()
                                        }], ::tracing_core::callsite::Identifier(&__CALLSITE)),
                        ::tracing::metadata::Kind::EVENT)
                };
            ::tracing::callsite::DefaultCallsite::new(&META)
        };
    let enabled =
        ::tracing::Level::DEBUG <= ::tracing::level_filters::STATIC_MAX_LEVEL
                &&
                ::tracing::Level::DEBUG <=
                    ::tracing::level_filters::LevelFilter::current() &&
            {
                let interest = __CALLSITE.interest();
                !interest.is_never() &&
                    ::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
                        interest)
            };
    if enabled {
        (|value_set: ::tracing::field::ValueSet|
                    {
                        let meta = __CALLSITE.metadata();
                        ::tracing::Event::dispatch(meta, &value_set);
                        ;
                    })({
                #[allow(unused_imports)]
                use ::tracing::field::{debug, display, Value};
                __CALLSITE.metadata().fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&x)
                                            as &dyn ::tracing::field::Value))])
            });
    } else { ; }
};
x;#[instrument(level = "debug", skip(self, hir_id, safety, abi, decl, generics, hir_ty), ret)]
3703    pub fn lower_fn_ty(
3704        &self,
3705        hir_id: HirId,
3706        safety: hir::Safety,
3707        abi: rustc_abi::ExternAbi,
3708        decl: &hir::FnDecl<'_>,
3709        generics: Option<&hir::Generics<'_>>,
3710        hir_ty: Option<&hir::Ty<'_>>,
3711    ) -> ty::PolyFnSig<'tcx> {
3712        let tcx = self.tcx();
3713        let bound_vars = tcx.late_bound_vars(hir_id);
3714        debug!(?bound_vars);
3715
3716        let (input_tys, output_ty) = self.lower_fn_sig(decl, generics, hir_id, hir_ty);
3717
3718        debug!(?output_ty);
3719
3720        debug!(?abi, ?safety, ?decl.fn_decl_kind, input_tys_len = ?input_tys.len());
3721        let fn_sig_kind = FnSigKind::default()
3722            .set_abi(abi)
3723            .set_safety(safety)
3724            .set_c_variadic(decl.fn_decl_kind.c_variadic())
3725            .set_splatted(decl.splatted(), input_tys.len())
3726            .unwrap();
3727        let fn_ty = tcx.mk_fn_sig(input_tys, output_ty, fn_sig_kind);
3728        let fn_ptr_ty = ty::Binder::bind_with_vars(fn_ty, bound_vars);
3729
3730        if let Some(hir::Ty { kind: hir::TyKind::FnPtr(fn_ptr_ty), span, .. }) = hir_ty {
3731            check_abi(tcx, hir_id, *span, fn_ptr_ty.abi);
3732        }
3733
3734        // reject function types that violate cmse ABI requirements
3735        cmse::validate_cmse_abi(self.tcx(), self.dcx(), hir_id, abi, fn_ptr_ty);
3736
3737        if !fn_ptr_ty.references_error() {
3738            // Find any late-bound regions declared in return type that do
3739            // not appear in the arguments. These are not well-formed.
3740            //
3741            // Example:
3742            //     for<'a> fn() -> &'a str <-- 'a is bad
3743            //     for<'a> fn(&'a String) -> &'a str <-- 'a is ok
3744            let inputs = fn_ptr_ty.inputs();
3745            let late_bound_in_args =
3746                tcx.collect_constrained_late_bound_regions(inputs.map_bound(|i| i.to_owned()));
3747            let output = fn_ptr_ty.output();
3748            let late_bound_in_ret = tcx.collect_referenced_late_bound_regions(output);
3749
3750            self.validate_late_bound_regions(late_bound_in_args, late_bound_in_ret, |br_name| {
3751                struct_span_code_err!(
3752                    self.dcx(),
3753                    decl.output.span(),
3754                    E0581,
3755                    "return type references {}, which is not constrained by the fn input types",
3756                    br_name
3757                )
3758            });
3759        }
3760
3761        fn_ptr_ty
3762    }
3763
3764    /// Given a fn_hir_id for a impl function, suggest the type that is found on the
3765    /// corresponding function in the trait that the impl implements, if it exists.
3766    /// If arg_idx is Some, then it corresponds to an input type index, otherwise it
3767    /// corresponds to the return type.
3768    pub(super) fn suggest_trait_fn_ty_for_impl_fn_infer(
3769        &self,
3770        fn_hir_id: HirId,
3771        arg_idx: Option<usize>,
3772    ) -> Option<Ty<'tcx>> {
3773        let tcx = self.tcx();
3774        let hir::Node::ImplItem(hir::ImplItem { kind: hir::ImplItemKind::Fn(..), ident, .. }) =
3775            tcx.hir_node(fn_hir_id)
3776        else {
3777            return None;
3778        };
3779        let i = tcx.parent_hir_node(fn_hir_id).expect_item().expect_impl();
3780
3781        let trait_ref = self.lower_impl_trait_ref(&i.of_trait?.trait_ref, self.lower_ty(i.self_ty));
3782
3783        let assoc = tcx.associated_items(trait_ref.def_id).find_by_ident_and_kind(
3784            tcx,
3785            *ident,
3786            ty::AssocTag::Fn,
3787            trait_ref.def_id,
3788        )?;
3789
3790        let fn_sig = tcx
3791            .fn_sig(assoc.def_id)
3792            .instantiate(
3793                tcx,
3794                trait_ref
3795                    .args
3796                    .extend_to(tcx, assoc.def_id, |param, _| tcx.mk_param_from_def(param)),
3797            )
3798            .skip_norm_wip();
3799        let fn_sig = tcx.liberate_late_bound_regions(fn_hir_id.expect_owner().to_def_id(), fn_sig);
3800
3801        Some(if let Some(arg_idx) = arg_idx {
3802            *fn_sig.inputs().get(arg_idx)?
3803        } else {
3804            fn_sig.output()
3805        })
3806    }
3807
3808    {}
#[allow(clippy :: suspicious_else_formatting)]
{
    let __tracing_attr_span;
    let __tracing_attr_guard;
    if ::tracing::Level::TRACE <= ::tracing::level_filters::STATIC_MAX_LEVEL
                &&
                ::tracing::Level::TRACE <=
                    ::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("validate_late_bound_regions",
                                    "rustc_hir_analysis::hir_ty_lowering",
                                    ::tracing::Level::TRACE,
                                    ::tracing_core::__macro_support::Option::Some("/rustc-dev/a36d05efab632d1ddf902b6a5c33b6d5d3b64131/compiler/rustc_hir_analysis/src/hir_ty_lowering/mod.rs"),
                                    ::tracing_core::__macro_support::Option::Some(3808u32),
                                    ::tracing_core::__macro_support::Option::Some("rustc_hir_analysis::hir_ty_lowering"),
                                    ::tracing_core::field::FieldSet::new(&[{
                                                        const NAME:
                                                            ::tracing::__macro_support::FieldName<{
                                                                ::tracing::__macro_support::FieldName::len("constrained_regions")
                                                            }> =
                                                            ::tracing::__macro_support::FieldName::new("constrained_regions");
                                                        NAME.as_str()
                                                    },
                                                    {
                                                        const NAME:
                                                            ::tracing::__macro_support::FieldName<{
                                                                ::tracing::__macro_support::FieldName::len("referenced_regions")
                                                            }> =
                                                            ::tracing::__macro_support::FieldName::new("referenced_regions");
                                                        NAME.as_str()
                                                    }], ::tracing_core::callsite::Identifier(&__CALLSITE)),
                                    ::tracing::metadata::Kind::SPAN)
                            };
                        ::tracing::callsite::DefaultCallsite::new(&META)
                    };
                let mut interest = ::tracing::subscriber::Interest::never();
                if ::tracing::Level::TRACE <=
                                    ::tracing::level_filters::STATIC_MAX_LEVEL &&
                                ::tracing::Level::TRACE <=
                                    ::tracing::level_filters::LevelFilter::current() &&
                            { interest = __CALLSITE.interest(); !interest.is_never() }
                        &&
                        ::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
                            interest) {
                    let meta = __CALLSITE.metadata();
                    ::tracing::Span::new(meta,
                        &{
                                #[allow(unused_imports)]
                                use ::tracing::field::{debug, display, Value};
                                meta.fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&constrained_regions)
                                                            as &dyn ::tracing::field::Value)),
                                                (::tracing::__macro_support::Option::Some(&::tracing::field::debug(&referenced_regions)
                                                            as &dyn ::tracing::field::Value))])
                            })
                } else {
                    let span =
                        ::tracing::__macro_support::__disabled_span(__CALLSITE.metadata());
                    {};
                    span
                }
            };
        __tracing_attr_guard = __tracing_attr_span.enter();
    }

    #[warn(clippy :: suspicious_else_formatting)]
    {

        #[allow(unknown_lints, unreachable_code, clippy ::
        diverging_sub_expression, clippy :: empty_loop, clippy ::
        let_unit_value, clippy :: let_with_type_underscore, clippy ::
        needless_return, clippy :: unreachable)]
        if false {
            let __tracing_attr_fake_return: () = loop {};
            return __tracing_attr_fake_return;
        }
        {
            for br in referenced_regions.difference(&constrained_regions) {
                let br_name =
                    if let Some(name) = br.get_name(self.tcx()) {
                        ::alloc::__export::must_use({
                                ::alloc::fmt::format(format_args!("lifetime `{0}`", name))
                            })
                    } else { "an anonymous lifetime".to_string() };
                let mut err = generate_err(&br_name);
                if !br.is_named(self.tcx()) {
                    err.note("lifetimes appearing in an associated or opaque type are not considered constrained");
                    err.note("consider introducing a named lifetime parameter");
                }
                err.emit();
            }
        }
    }
}#[instrument(level = "trace", skip(self, generate_err))]
3809    fn validate_late_bound_regions<'cx>(
3810        &'cx self,
3811        constrained_regions: FxIndexSet<ty::BoundRegionKind<'tcx>>,
3812        referenced_regions: FxIndexSet<ty::BoundRegionKind<'tcx>>,
3813        generate_err: impl Fn(&str) -> Diag<'cx>,
3814    ) {
3815        for br in referenced_regions.difference(&constrained_regions) {
3816            let br_name = if let Some(name) = br.get_name(self.tcx()) {
3817                format!("lifetime `{name}`")
3818            } else {
3819                "an anonymous lifetime".to_string()
3820            };
3821
3822            let mut err = generate_err(&br_name);
3823
3824            if !br.is_named(self.tcx()) {
3825                // The only way for an anonymous lifetime to wind up
3826                // in the return type but **also** be unconstrained is
3827                // if it only appears in "associated types" in the
3828                // input. See #47511 and #62200 for examples. In this case,
3829                // though we can easily give a hint that ought to be
3830                // relevant.
3831                err.note(
3832                    "lifetimes appearing in an associated or opaque type are not considered constrained",
3833                );
3834                err.note("consider introducing a named lifetime parameter");
3835            }
3836
3837            err.emit();
3838        }
3839    }
3840
3841    fn construct_const_ctor_value(
3842        &self,
3843        ctor_def_id: DefId,
3844        ctor_of: CtorOf,
3845        args: GenericArgsRef<'tcx>,
3846    ) -> Const<'tcx> {
3847        let tcx = self.tcx();
3848        let parent_did = tcx.parent(ctor_def_id);
3849
3850        let adt_def = tcx.adt_def(match ctor_of {
3851            CtorOf::Variant => tcx.parent(parent_did),
3852            CtorOf::Struct => parent_did,
3853        });
3854
3855        let variant_idx = adt_def.variant_index_with_id(parent_did);
3856
3857        let valtree = if adt_def.is_enum() {
3858            let discr = ty::ValTree::from_scalar_int(tcx, variant_idx.as_u32().into());
3859            ty::ValTree::from_branches(tcx, [ty::Const::new_value(tcx, discr, tcx.types.u32)])
3860        } else {
3861            ty::ValTree::zst(tcx)
3862        };
3863
3864        let adt_ty = Ty::new_adt(tcx, adt_def, args);
3865        ty::Const::new_value(tcx, valtree, adt_ty)
3866    }
3867
3868    fn lower_view(&self, inner_ty: Ty<'tcx>, fields: &[Ident], ty_span: Span) -> Ty<'tcx> {
3869        // Step 1: check that every field is unique, and keep a list of field that we know are
3870        // unique.
3871        let mut viewed_fields = Vec::<Ident>::with_capacity(fields.len());
3872
3873        for f in fields {
3874            let f = f.normalize_to_macros_2_0();
3875            // PERF: this is quadratic, but ~fine since the amount of fields is very low.
3876            if let Some(previous_field_span) =
3877                viewed_fields.iter().find_map(|f_| (*f_ == f).then_some(f_.span))
3878            {
3879                self.dcx().emit_err(diagnostics::ViewedFieldIsAlreadyPartOfTheView {
3880                    name: f.name,
3881                    span: f.span,
3882                    previous_field_span,
3883                });
3884                continue;
3885            }
3886            viewed_fields.push(f);
3887        }
3888
3889        // Step 2: check that the viewed type is a struct.
3890        let variant = match inner_ty.kind() {
3891            ty::Adt(def, _) if def.is_struct() => def.non_enum_variant(),
3892
3893            ty::Adt(def, _) => {
3894                let guar = self.dcx().emit_err(diagnostics::OnlyStructsCanBeViewedAdt {
3895                    ty: inner_ty,
3896                    span: ty_span,
3897                    article: def.article(),
3898                    kind: def.descr(),
3899                });
3900                return Ty::new_error(self.tcx(), guar);
3901            }
3902
3903            _ => {
3904                let guar = self.dcx().emit_err(diagnostics::OnlyStructsCanBeViewedNonAdt {
3905                    ty: inner_ty,
3906                    span: ty_span,
3907                });
3908                return Ty::new_error(self.tcx(), guar);
3909            }
3910        };
3911
3912        // Step 3: check that every viewed field exists.
3913        let mut viewed_indices = Vec::with_capacity(viewed_fields.len());
3914        let mut error = None;
3915        for field in viewed_fields {
3916            let Some((_, field)) = variant
3917                .fields
3918                .iter_enumerated()
3919                .find(|(_, f)| f.ident(self.tcx()).normalize_to_macros_2_0() == field)
3920            else {
3921                let err =
3922                    self.dcx().emit_err(NoFieldOnType { span: field.span, field, ty: inner_ty });
3923                error = Some(err);
3924                continue;
3925            };
3926
3927            viewed_indices.push(field);
3928        }
3929        if let Some(guar) = error {
3930            return Ty::new_error(self.tcx(), guar);
3931        }
3932
3933        // FIXME(scrabsha): actually lower view types.
3934        inner_ty
3935    }
3936}