Skip to main content

rustc_ast_lowering/
lib.rs

1//! Lowers the AST to the HIR.
2//!
3//! Since the AST and HIR are fairly similar, this is mostly a simple procedure,
4//! much like a fold. Where lowering involves a bit more work things get more
5//! interesting and there are some invariants you should know about. These mostly
6//! concern spans and IDs.
7//!
8//! Spans are assigned to AST nodes during parsing and then are modified during
9//! expansion to indicate the origin of a node and the process it went through
10//! being expanded. IDs are assigned to AST nodes just before lowering.
11//!
12//! For the simpler lowering steps, IDs and spans should be preserved. Unlike
13//! expansion we do not preserve the process of lowering in the spans, so spans
14//! should not be modified here. When creating a new node (as opposed to
15//! "folding" an existing one), create a new ID using `next_id()`.
16//!
17//! You must ensure that IDs are unique. That means that you should only use the
18//! ID from an AST node in a single HIR node (you can assume that AST node-IDs
19//! are unique). Every new node must have a unique ID. Avoid cloning HIR nodes.
20//! If you do, you must then set the new node's ID to a fresh one.
21//!
22//! Spans are used for error messages and for tools to map semantics back to
23//! source code. It is therefore not as important with spans as IDs to be strict
24//! about use (you can't break the compiler by screwing up a span). Obviously, a
25//! HIR node can only have a single span. But multiple nodes can have the same
26//! span and spans don't need to be kept in order, etc. Where code is preserved
27//! by lowering, it should have the same span as in the AST. Where HIR nodes are
28//! new it is probably best to give a span for the whole AST node being lowered.
29//! All nodes should have real spans; don't use dummy spans. Tools are likely to
30//! get confused if the spans from leaf AST nodes occur in multiple places
31//! in the HIR, especially for multiple identifiers.
32
33// tidy-alphabetical-start
34#![feature(const_default)]
35#![feature(const_trait_impl)]
36#![feature(default_field_values)]
37#![feature(deref_patterns)]
38#![recursion_limit = "256"]
39// tidy-alphabetical-end
40
41use std::mem;
42use std::sync::Arc;
43
44use rustc_ast::mut_visit::{self, MutVisitor};
45use rustc_ast::node_id::NodeMap;
46use rustc_ast::visit::{self, Visitor};
47use rustc_ast::{self as ast, *};
48use rustc_attr_parsing::{AttributeParser, OmitDoc, Recovery, ShouldEmit};
49use rustc_data_structures::fx::FxIndexMap;
50use rustc_data_structures::sorted_map::SortedMap;
51use rustc_data_structures::stable_hash::{StableHash, StableHasher};
52use rustc_data_structures::steal::Steal;
53use rustc_data_structures::tagged_ptr::TaggedRef;
54use rustc_data_structures::unord::ExtendUnord;
55use rustc_errors::codes::*;
56use rustc_errors::{DiagArgFromDisplay, DiagCtxtHandle};
57use rustc_hir::def::{DefKind, LifetimeRes, Namespace, PartialRes, PerNS, Res};
58use rustc_hir::def_id::{DefId, LOCAL_CRATE, LocalDefId, LocalDefIdMap};
59use rustc_hir::definitions::PerParentDisambiguatorState;
60use rustc_hir::lints::DelayedLint;
61use rustc_hir::{
62    self as hir, AngleBrackets, ConstArg, GenericArg, HirId, ItemLocalMap, LifetimeSource,
63    LifetimeSyntax, MissingLifetimeKind, ParamName, Target, TraitCandidate, find_attr,
64};
65use rustc_index::{Idx, IndexVec};
66use rustc_macros::extension;
67use rustc_middle::queries::Providers;
68use rustc_middle::span_bug;
69use rustc_middle::ty::{PerOwnerResolverData, ResolverAstLowering, TyCtxt};
70use rustc_session::errors::add_feature_diagnostics;
71use rustc_span::symbol::{Ident, Symbol, kw, sym};
72use rustc_span::{DUMMY_SP, DesugaringKind, Span};
73use smallvec::{SmallVec, smallvec};
74use thin_vec::ThinVec;
75use tracing::{debug, instrument, trace};
76
77use crate::diagnostics::{AssocTyParentheses, AssocTyParenthesesSub, MisplacedImplTrait};
78
79macro_rules! arena_vec {
80    ($this:expr; $($x:expr),*) => (
81        $this.arena.alloc_from_iter([$($x),*])
82    );
83}
84
85mod asm;
86mod block;
87mod contract;
88mod delegation;
89mod diagnostics;
90mod expr;
91mod format;
92mod index;
93mod item;
94mod pat;
95mod path;
96pub mod stability;
97
98pub fn provide(providers: &mut Providers) {
99    providers.index_ast = index_ast;
100    providers.lower_to_hir = lower_to_hir;
101}
102
103struct LoweringContext<'a, 'hir> {
104    tcx: TyCtxt<'hir>,
105    resolver: &'a ResolverAstLowering<'hir>,
106    current_disambiguator: PerParentDisambiguatorState,
107
108    /// Used to allocate HIR nodes.
109    arena: &'hir hir::Arena<'hir>,
110
111    /// Bodies inside the owner being lowered.
112    bodies: Vec<(hir::ItemLocalId, &'hir hir::Body<'hir>)>,
113    /// `#[define_opaque]` attributes
114    define_opaque: Option<&'hir [(Span, LocalDefId)]>,
115    /// Attributes inside the owner being lowered.
116    attrs: SortedMap<hir::ItemLocalId, &'hir [hir::Attribute]>,
117    /// Collect items that were created by lowering the current owner.
118    children: LocalDefIdMap<hir::MaybeOwner<'hir>>,
119
120    contract_ensures: Option<(Span, Ident, HirId)>,
121
122    coroutine_kind: Option<hir::CoroutineKind>,
123
124    /// When inside an `async` context, this is the `HirId` of the
125    /// `task_context` local bound to the resume argument of the coroutine.
126    task_context: Option<HirId>,
127
128    /// Used to get the current `fn`'s def span to point to when using `await`
129    /// outside of an `async fn`.
130    current_item: Option<Span>,
131
132    try_block_scope: TryBlockScope,
133    loop_scope: Option<HirId>,
134    is_in_loop_condition: bool,
135    is_in_dyn_type: bool,
136
137    current_hir_id_owner: hir::OwnerId,
138    owner: &'a PerOwnerResolverData<'hir>,
139    item_local_id_counter: hir::ItemLocalId,
140    trait_map: ItemLocalMap<&'hir [TraitCandidate<'hir>]>,
141
142    impl_trait_defs: Vec<hir::GenericParam<'hir>>,
143    impl_trait_bounds: Vec<hir::WherePredicate<'hir>>,
144
145    /// NodeIds of pattern identifiers and labelled nodes that are lowered inside the current HIR owner.
146    ident_and_label_to_local_id: NodeMap<hir::ItemLocalId>,
147    /// NodeIds that are lowered inside the current HIR owner. Only used for duplicate lowering check.
148    #[cfg(debug_assertions)]
149    node_id_to_local_id: NodeMap<hir::ItemLocalId>,
150    /// The `NodeId` space is split in two.
151    /// `0..resolver.next_node_id` are created by the resolver on the AST.
152    /// The higher part `resolver.next_node_id..next_node_id` are created during lowering.
153    next_node_id: NodeId,
154    /// Maps the `NodeId`s created during lowering to `LocalDefId`s.
155    node_id_to_def_id: NodeMap<LocalDefId>,
156    /// Overlay over resolver's `partial_res_map` used by delegation.
157    /// This only contains `PartialRes::new(Res::Local(self_param_id))`,
158    /// so we only store `self_param_id`.
159    partial_res_overrides: NodeMap<NodeId>,
160
161    allow_contracts: Arc<[Symbol]>,
162    allow_try_trait: Arc<[Symbol]>,
163    allow_gen_future: Arc<[Symbol]>,
164    allow_pattern_type: Arc<[Symbol]>,
165    allow_async_gen: Arc<[Symbol]>,
166    allow_async_iterator: Arc<[Symbol]>,
167    allow_for_await: Arc<[Symbol]>,
168    allow_async_fn_traits: Arc<[Symbol]>,
169
170    delayed_lints: Vec<DelayedLint>,
171
172    /// Stack of `move(...)` collection states. A plain closure body pushes
173    /// `Some`, so `move(...)` expressions can record the generated locals they
174    /// should lower to. Nested bodies that cannot use `move(...)` push `None`.
175    move_expr_bindings: Vec<Option<expr::MoveExprState<'hir>>>,
176
177    attribute_parser: AttributeParser<'hir>,
178}
179
180impl<'a, 'hir> LoweringContext<'a, 'hir> {
181    fn new(tcx: TyCtxt<'hir>, resolver: &'a ResolverAstLowering<'hir>, owner: NodeId) -> Self {
182        let current_ast_owner = &resolver.owners[&owner];
183        let current_hir_id_owner = hir::OwnerId { def_id: current_ast_owner.def_id };
184        let current_disambiguator = resolver
185            .disambiguators
186            .get(&current_hir_id_owner.def_id)
187            .map(|s| s.steal())
188            .unwrap_or_else(|| PerParentDisambiguatorState::new(current_hir_id_owner.def_id));
189
190        Self {
191            tcx,
192            resolver,
193            current_disambiguator,
194            owner: current_ast_owner,
195            arena: tcx.hir_arena,
196
197            // HirId handling.
198            bodies: Vec::new(),
199            define_opaque: None,
200            attrs: SortedMap::default(),
201            children: LocalDefIdMap::default(),
202            contract_ensures: None,
203            current_hir_id_owner,
204            // 0 corresponds to `owner` lowered as `current_hir_id_owner`,
205            // and we never call `lower_node_id(owner)`.
206            item_local_id_counter: hir::ItemLocalId::new(1),
207            ident_and_label_to_local_id: Default::default(),
208            #[cfg(debug_assertions)]
209            node_id_to_local_id: Default::default(),
210            trait_map: Default::default(),
211            next_node_id: resolver.next_node_id,
212            node_id_to_def_id: NodeMap::default(),
213            partial_res_overrides: NodeMap::default(),
214
215            // Lowering state.
216            try_block_scope: TryBlockScope::Function,
217            loop_scope: None,
218            is_in_loop_condition: false,
219            is_in_dyn_type: false,
220            coroutine_kind: None,
221            task_context: None,
222            current_item: None,
223            impl_trait_defs: Vec::new(),
224            impl_trait_bounds: Vec::new(),
225            allow_contracts: [sym::contracts_internals].into(),
226            allow_try_trait: [
227                sym::try_trait_v2,
228                sym::try_trait_v2_residual,
229                sym::yeet_desugar_details,
230            ]
231            .into(),
232            allow_pattern_type: [sym::pattern_types, sym::pattern_type_range_trait].into(),
233            allow_gen_future: if tcx.features().async_fn_track_caller() {
234                [sym::gen_future, sym::closure_track_caller].into()
235            } else {
236                [sym::gen_future].into()
237            },
238            allow_for_await: [sym::async_gen_internals, sym::async_iterator].into(),
239            allow_async_fn_traits: [sym::async_fn_traits].into(),
240            allow_async_gen: [sym::async_gen_internals].into(),
241            // FIXME(gen_blocks): how does `closure_track_caller`/`async_fn_track_caller`
242            // interact with `gen`/`async gen` blocks
243            allow_async_iterator: [sym::gen_future, sym::async_iterator].into(),
244
245            move_expr_bindings: Vec::new(),
246            attribute_parser: AttributeParser::new(
247                tcx.sess,
248                tcx.features(),
249                tcx.registered_tools(()),
250                ShouldEmit::ErrorsAndLints { recovery: Recovery::Allowed },
251            ),
252            delayed_lints: Vec::new(),
253        }
254    }
255
256    pub(crate) fn dcx(&self) -> DiagCtxtHandle<'hir> {
257        self.tcx.dcx()
258    }
259}
260
261struct SpanLowerer {
262    is_incremental: bool,
263    def_id: LocalDefId,
264}
265
266impl SpanLowerer {
267    fn lower(&self, span: Span) -> Span {
268        if self.is_incremental {
269            span.with_parent(Some(self.def_id))
270        } else {
271            // Do not make spans relative when not using incremental compilation.
272            span
273        }
274    }
275}
276
277impl<'tcx> ResolverAstLoweringExt<'tcx> for ResolverAstLowering<'tcx> {
    fn legacy_const_generic_args(&self, expr: &Expr, tcx: TyCtxt<'tcx>)
        -> Option<Vec<usize>> {
        let ExprKind::Path(None, path) = &expr.kind else { return None; };
        if path.segments.last().unwrap().args.is_some() { return None; }
        let def_id =
            self.partial_res_map.get(&expr.id)?.full_res()?.opt_def_id()?;
        if def_id.is_local() { return None; }
        {
                {
                    'done:
                        {
                        for i in
                            ::rustc_hir::attrs::HasAttrs::get_attrs(def_id, &tcx) {
                            #[allow(unused_imports)]
                            use rustc_hir::attrs::AttributeKind::*;
                            let i: &rustc_hir::Attribute = i;
                            match i {
                                rustc_hir::Attribute::Parsed(RustcLegacyConstGenerics {
                                    fn_indexes, .. }) => {
                                    break 'done Some(fn_indexes);
                                }
                                rustc_hir::Attribute::Unparsed(..) =>
                                    {}
                                    #[deny(unreachable_patterns)]
                                    _ => {}
                            }
                        }
                        None
                    }
                }
            }.map(|fn_indexes|
                fn_indexes.iter().map(|(num, _)| *num).collect())
    }
    #[doc = " Obtain the list of lifetimes parameters to add to an item."]
    #[doc = ""]
    #[doc =
    " Extra lifetime parameters should only be added in places that can appear"]
    #[doc = " as a `binder` in `LifetimeRes`."]
    #[doc = ""]
    #[doc =
    " The extra lifetimes that appear from the parenthesized `Fn`-trait desugaring"]
    #[doc = " should appear at the enclosing `PolyTraitRef`."]
    fn extra_lifetime_params(&self, id: NodeId)
        -> &[(Ident, NodeId, MissingLifetimeKind)] {
        self.extra_lifetime_params_map.get(&id).map_or(&[], |v| &v[..])
    }
}#[extension(trait ResolverAstLoweringExt<'tcx>)]
278impl<'tcx> ResolverAstLowering<'tcx> {
279    fn legacy_const_generic_args(&self, expr: &Expr, tcx: TyCtxt<'tcx>) -> Option<Vec<usize>> {
280        let ExprKind::Path(None, path) = &expr.kind else {
281            return None;
282        };
283
284        // Don't perform legacy const generics rewriting if the path already
285        // has generic arguments.
286        if path.segments.last().unwrap().args.is_some() {
287            return None;
288        }
289
290        // We do not need to look at `partial_res_overrides`. That map only contains overrides for
291        // `self_param` locals. And here we are looking for the function definition that `expr`
292        // resolves to.
293        let def_id = self.partial_res_map.get(&expr.id)?.full_res()?.opt_def_id()?;
294
295        // We only support cross-crate argument rewriting. Uses
296        // within the same crate should be updated to use the new
297        // const generics style.
298        if def_id.is_local() {
299            return None;
300        }
301
302        // we can use parsed attrs here since for other crates they're already available
303        find_attr!(
304            tcx, def_id,
305            RustcLegacyConstGenerics{fn_indexes,..} => fn_indexes
306        )
307        .map(|fn_indexes| fn_indexes.iter().map(|(num, _)| *num).collect())
308    }
309
310    /// Obtain the list of lifetimes parameters to add to an item.
311    ///
312    /// Extra lifetime parameters should only be added in places that can appear
313    /// as a `binder` in `LifetimeRes`.
314    ///
315    /// The extra lifetimes that appear from the parenthesized `Fn`-trait desugaring
316    /// should appear at the enclosing `PolyTraitRef`.
317    fn extra_lifetime_params(&self, id: NodeId) -> &[(Ident, NodeId, MissingLifetimeKind)] {
318        self.extra_lifetime_params_map.get(&id).map_or(&[], |v| &v[..])
319    }
320}
321
322/// How relaxed bounds `?Trait` should be treated.
323///
324/// Relaxed bounds should only be allowed in places where we later
325/// (namely during HIR ty lowering) perform *sized elaboration*.
326#[derive(#[automatically_derived]
impl<'a> ::core::fmt::Debug for RelaxedBoundPolicy<'a> {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        match self {
            RelaxedBoundPolicy::Allowed(__self_0) =>
                ::core::fmt::Formatter::debug_tuple_field1_finish(f,
                    "Allowed", &__self_0),
            RelaxedBoundPolicy::Forbidden(__self_0) =>
                ::core::fmt::Formatter::debug_tuple_field1_finish(f,
                    "Forbidden", &__self_0),
        }
    }
}Debug)]
327enum RelaxedBoundPolicy<'a> {
328    /// The `DefId` refers to the trait that is being relaxed.
329    Allowed(&'a mut FxIndexMap<DefId, Span>),
330    Forbidden(RelaxedBoundForbiddenReason),
331}
332impl RelaxedBoundPolicy<'_> {
333    fn reborrow(&mut self) -> RelaxedBoundPolicy<'_> {
334        match self {
335            RelaxedBoundPolicy::Allowed(m) => RelaxedBoundPolicy::Allowed(m),
336            RelaxedBoundPolicy::Forbidden(reason) => RelaxedBoundPolicy::Forbidden(*reason),
337        }
338    }
339}
340
341#[derive(#[automatically_derived]
impl ::core::clone::Clone for RelaxedBoundForbiddenReason {
    #[inline]
    fn clone(&self) -> RelaxedBoundForbiddenReason { *self }
}Clone, #[automatically_derived]
impl ::core::marker::Copy for RelaxedBoundForbiddenReason { }Copy, #[automatically_derived]
impl ::core::fmt::Debug for RelaxedBoundForbiddenReason {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::write_str(f,
            match self {
                RelaxedBoundForbiddenReason::TraitObjectTy => "TraitObjectTy",
                RelaxedBoundForbiddenReason::SuperTrait => "SuperTrait",
                RelaxedBoundForbiddenReason::TraitAlias => "TraitAlias",
                RelaxedBoundForbiddenReason::AssocTyBounds => "AssocTyBounds",
                RelaxedBoundForbiddenReason::WhereBound => "WhereBound",
            })
    }
}Debug)]
342enum RelaxedBoundForbiddenReason {
343    TraitObjectTy,
344    SuperTrait,
345    TraitAlias,
346    AssocTyBounds,
347    /// We do not allow where bounds doing relaxed bounds,
348    /// except if it's for generic parameters of the current item.
349    WhereBound,
350}
351
352/// Context of `impl Trait` in code, which determines whether it is allowed in an HIR subtree,
353/// and if so, what meaning it has.
354#[derive(#[automatically_derived]
impl ::core::fmt::Debug for ImplTraitContext {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        match self {
            ImplTraitContext::Universal =>
                ::core::fmt::Formatter::write_str(f, "Universal"),
            ImplTraitContext::OpaqueTy { origin: __self_0 } =>
                ::core::fmt::Formatter::debug_struct_field1_finish(f,
                    "OpaqueTy", "origin", &__self_0),
            ImplTraitContext::InBinding =>
                ::core::fmt::Formatter::write_str(f, "InBinding"),
            ImplTraitContext::FeatureGated(__self_0, __self_1) =>
                ::core::fmt::Formatter::debug_tuple_field2_finish(f,
                    "FeatureGated", __self_0, &__self_1),
            ImplTraitContext::Disallowed(__self_0) =>
                ::core::fmt::Formatter::debug_tuple_field1_finish(f,
                    "Disallowed", &__self_0),
        }
    }
}Debug, #[automatically_derived]
impl ::core::marker::Copy for ImplTraitContext { }Copy, #[automatically_derived]
impl ::core::clone::Clone for ImplTraitContext {
    #[inline]
    fn clone(&self) -> ImplTraitContext {
        let _:
                ::core::clone::AssertParamIsClone<hir::OpaqueTyOrigin<LocalDefId>>;
        let _: ::core::clone::AssertParamIsClone<ImplTraitPosition>;
        let _: ::core::clone::AssertParamIsClone<Symbol>;
        *self
    }
}Clone, #[automatically_derived]
impl ::core::cmp::PartialEq for ImplTraitContext {
    #[inline]
    fn eq(&self, other: &ImplTraitContext) -> bool {
        let __self_discr = ::core::intrinsics::discriminant_value(self);
        let __arg1_discr = ::core::intrinsics::discriminant_value(other);
        __self_discr == __arg1_discr &&
            match (self, other) {
                (ImplTraitContext::OpaqueTy { origin: __self_0 },
                    ImplTraitContext::OpaqueTy { origin: __arg1_0 }) =>
                    __self_0 == __arg1_0,
                (ImplTraitContext::FeatureGated(__self_0, __self_1),
                    ImplTraitContext::FeatureGated(__arg1_0, __arg1_1)) =>
                    __self_0 == __arg1_0 && __self_1 == __arg1_1,
                (ImplTraitContext::Disallowed(__self_0),
                    ImplTraitContext::Disallowed(__arg1_0)) =>
                    __self_0 == __arg1_0,
                _ => true,
            }
    }
}PartialEq, #[automatically_derived]
impl ::core::cmp::Eq for ImplTraitContext {
    #[inline]
    #[doc(hidden)]
    #[coverage(off)]
    fn assert_fields_are_eq(&self) {
        let _: ::core::cmp::AssertParamIsEq<hir::OpaqueTyOrigin<LocalDefId>>;
        let _: ::core::cmp::AssertParamIsEq<ImplTraitPosition>;
        let _: ::core::cmp::AssertParamIsEq<Symbol>;
    }
}Eq)]
355enum ImplTraitContext {
356    /// Treat `impl Trait` as shorthand for a new universal generic parameter.
357    /// Example: `fn foo(x: impl Debug)`, where `impl Debug` is conceptually
358    /// equivalent to a fresh universal parameter like `fn foo<T: Debug>(x: T)`.
359    ///
360    /// Newly generated parameters should be inserted into the given `Vec`.
361    Universal,
362
363    /// Treat `impl Trait` as shorthand for a new opaque type.
364    /// Example: `fn foo() -> impl Debug`, where `impl Debug` is conceptually
365    /// equivalent to a new opaque type like `type T = impl Debug; fn foo() -> T`.
366    ///
367    OpaqueTy { origin: hir::OpaqueTyOrigin<LocalDefId> },
368
369    /// Treat `impl Trait` as a "trait ascription", which is like a type
370    /// variable but that also enforces that a set of trait goals hold.
371    ///
372    /// This is useful to guide inference for unnameable types.
373    InBinding,
374
375    /// `impl Trait` is unstably accepted in this position.
376    FeatureGated(ImplTraitPosition, Symbol),
377    /// `impl Trait` is not accepted in this position.
378    Disallowed(ImplTraitPosition),
379}
380
381/// Position in which `impl Trait` is disallowed.
382#[derive(#[automatically_derived]
impl ::core::fmt::Debug for ImplTraitPosition {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::write_str(f,
            match self {
                ImplTraitPosition::Path => "Path",
                ImplTraitPosition::Variable => "Variable",
                ImplTraitPosition::Trait => "Trait",
                ImplTraitPosition::Bound => "Bound",
                ImplTraitPosition::Generic => "Generic",
                ImplTraitPosition::ExternFnParam => "ExternFnParam",
                ImplTraitPosition::ClosureParam => "ClosureParam",
                ImplTraitPosition::PointerParam => "PointerParam",
                ImplTraitPosition::FnTraitParam => "FnTraitParam",
                ImplTraitPosition::ExternFnReturn => "ExternFnReturn",
                ImplTraitPosition::ClosureReturn => "ClosureReturn",
                ImplTraitPosition::PointerReturn => "PointerReturn",
                ImplTraitPosition::FnTraitReturn => "FnTraitReturn",
                ImplTraitPosition::GenericDefault => "GenericDefault",
                ImplTraitPosition::ConstTy => "ConstTy",
                ImplTraitPosition::StaticTy => "StaticTy",
                ImplTraitPosition::AssocTy => "AssocTy",
                ImplTraitPosition::FieldTy => "FieldTy",
                ImplTraitPosition::Cast => "Cast",
                ImplTraitPosition::ImplSelf => "ImplSelf",
                ImplTraitPosition::OffsetOf => "OffsetOf",
            })
    }
}Debug, #[automatically_derived]
impl ::core::marker::Copy for ImplTraitPosition { }Copy, #[automatically_derived]
impl ::core::clone::Clone for ImplTraitPosition {
    #[inline]
    fn clone(&self) -> ImplTraitPosition { *self }
}Clone, #[automatically_derived]
impl ::core::cmp::PartialEq for ImplTraitPosition {
    #[inline]
    fn eq(&self, other: &ImplTraitPosition) -> bool {
        let __self_discr = ::core::intrinsics::discriminant_value(self);
        let __arg1_discr = ::core::intrinsics::discriminant_value(other);
        __self_discr == __arg1_discr
    }
}PartialEq, #[automatically_derived]
impl ::core::cmp::Eq for ImplTraitPosition {
    #[inline]
    #[doc(hidden)]
    #[coverage(off)]
    fn assert_fields_are_eq(&self) {}
}Eq)]
383enum ImplTraitPosition {
384    Path,
385    Variable,
386    Trait,
387    Bound,
388    Generic,
389    ExternFnParam,
390    ClosureParam,
391    PointerParam,
392    FnTraitParam,
393    ExternFnReturn,
394    ClosureReturn,
395    PointerReturn,
396    FnTraitReturn,
397    GenericDefault,
398    ConstTy,
399    StaticTy,
400    AssocTy,
401    FieldTy,
402    Cast,
403    ImplSelf,
404    OffsetOf,
405}
406
407impl std::fmt::Display for ImplTraitPosition {
408    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
409        let name = match self {
410            ImplTraitPosition::Path => "paths",
411            ImplTraitPosition::Variable => "the type of variable bindings",
412            ImplTraitPosition::Trait => "traits",
413            ImplTraitPosition::Bound => "bounds",
414            ImplTraitPosition::Generic => "generics",
415            ImplTraitPosition::ExternFnParam => "`extern fn` parameters",
416            ImplTraitPosition::ClosureParam => "closure parameters",
417            ImplTraitPosition::PointerParam => "`fn` pointer parameters",
418            ImplTraitPosition::FnTraitParam => "the parameters of `Fn` trait bounds",
419            ImplTraitPosition::ExternFnReturn => "`extern fn` return types",
420            ImplTraitPosition::ClosureReturn => "closure return types",
421            ImplTraitPosition::PointerReturn => "`fn` pointer return types",
422            ImplTraitPosition::FnTraitReturn => "the return type of `Fn` trait bounds",
423            ImplTraitPosition::GenericDefault => "generic parameter defaults",
424            ImplTraitPosition::ConstTy => "const types",
425            ImplTraitPosition::StaticTy => "static types",
426            ImplTraitPosition::AssocTy => "associated types",
427            ImplTraitPosition::FieldTy => "field types",
428            ImplTraitPosition::Cast => "cast expression types",
429            ImplTraitPosition::ImplSelf => "impl headers",
430            ImplTraitPosition::OffsetOf => "`offset_of!` parameters",
431        };
432
433        f.write_fmt(format_args!("{0}", name))write!(f, "{name}")
434    }
435}
436
437#[derive(#[automatically_derived]
impl ::core::marker::Copy for FnDeclKind { }Copy, #[automatically_derived]
impl ::core::clone::Clone for FnDeclKind {
    #[inline]
    fn clone(&self) -> FnDeclKind { *self }
}Clone, #[automatically_derived]
impl ::core::fmt::Debug for FnDeclKind {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::write_str(f,
            match self {
                FnDeclKind::Fn => "Fn",
                FnDeclKind::Inherent => "Inherent",
                FnDeclKind::ExternFn => "ExternFn",
                FnDeclKind::Closure => "Closure",
                FnDeclKind::Pointer => "Pointer",
                FnDeclKind::Trait => "Trait",
                FnDeclKind::Impl => "Impl",
            })
    }
}Debug, #[automatically_derived]
impl ::core::cmp::PartialEq for FnDeclKind {
    #[inline]
    fn eq(&self, other: &FnDeclKind) -> bool {
        let __self_discr = ::core::intrinsics::discriminant_value(self);
        let __arg1_discr = ::core::intrinsics::discriminant_value(other);
        __self_discr == __arg1_discr
    }
}PartialEq, #[automatically_derived]
impl ::core::cmp::Eq for FnDeclKind {
    #[inline]
    #[doc(hidden)]
    #[coverage(off)]
    fn assert_fields_are_eq(&self) {}
}Eq)]
438enum FnDeclKind {
439    Fn,
440    Inherent,
441    ExternFn,
442    Closure,
443    Pointer,
444    Trait,
445    Impl,
446}
447
448#[derive(#[automatically_derived]
impl ::core::marker::Copy for TryBlockScope { }Copy, #[automatically_derived]
impl ::core::clone::Clone for TryBlockScope {
    #[inline]
    fn clone(&self) -> TryBlockScope {
        let _: ::core::clone::AssertParamIsClone<HirId>;
        *self
    }
}Clone, #[automatically_derived]
impl ::core::fmt::Debug for TryBlockScope {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        match self {
            TryBlockScope::Function =>
                ::core::fmt::Formatter::write_str(f, "Function"),
            TryBlockScope::Homogeneous(__self_0) =>
                ::core::fmt::Formatter::debug_tuple_field1_finish(f,
                    "Homogeneous", &__self_0),
            TryBlockScope::Heterogeneous(__self_0) =>
                ::core::fmt::Formatter::debug_tuple_field1_finish(f,
                    "Heterogeneous", &__self_0),
        }
    }
}Debug)]
449enum TryBlockScope {
450    /// There isn't a `try` block, so a `?` will use `return`.
451    Function,
452    /// We're inside a `try { … }` block, so a `?` will block-break
453    /// from that block using a type depending only on the argument.
454    Homogeneous(HirId),
455    /// We're inside a `try as _ { … }` block, so a `?` will block-break
456    /// from that block using the type specified.
457    Heterogeneous(HirId),
458}
459
460fn index_ast<'tcx>(
461    tcx: TyCtxt<'tcx>,
462    (): (),
463) -> IndexVec<LocalDefId, Steal<(Arc<ResolverAstLowering<'tcx>>, AstOwner)>> {
464    // Queries that borrow `resolver_for_lowering`.
465    tcx.ensure_done().output_filenames(());
466    tcx.ensure_done().early_lint_checks(());
467    tcx.ensure_done().get_lang_items(());
468    tcx.ensure_done().debugger_visualizers(LOCAL_CRATE);
469
470    let (resolver, krate) = tcx.resolver_for_lowering();
471    let mut resolver = resolver.steal();
472    let mut krate = krate.steal();
473
474    let mut indexer = Indexer {
475        owners: &resolver.owners,
476        index: IndexVec::new(),
477        next_node_id: resolver.next_node_id,
478    };
479    indexer.visit_crate(&mut krate);
480    indexer.insert(CRATE_NODE_ID, AstOwner::Crate(Box::new(krate)));
481    resolver.next_node_id = indexer.next_node_id;
482
483    let index = indexer.index;
484    let resolver = Arc::new(resolver);
485    let index = index.into_iter().map(|owner| Steal::new((Arc::clone(&resolver), owner))).collect();
486    return index;
487
488    struct Indexer<'s, 'hir> {
489        owners: &'s NodeMap<PerOwnerResolverData<'hir>>,
490        index: IndexVec<LocalDefId, AstOwner>,
491        next_node_id: NodeId,
492    }
493
494    impl Indexer<'_, '_> {
495        fn insert(&mut self, id: NodeId, node: AstOwner) {
496            let def_id = self.owners[&id].def_id;
497            self.index.ensure_contains_elem(def_id, || AstOwner::NonOwner);
498            self.index[def_id] = node;
499        }
500
501        fn make_dummy<K>(
502            &mut self,
503            id: NodeId,
504            span: Span,
505            dummy: impl FnOnce(Box<MacCall>) -> K,
506        ) -> Box<Item<K>> {
507            use rustc_ast::token::Delimiter;
508            use rustc_ast::tokenstream::{DelimSpan, TokenStream};
509            use thin_vec::thin_vec;
510
511            Box::new(Item {
512                attrs: AttrVec::default(),
513                id,
514                span,
515                vis: Visibility { kind: VisibilityKind::Public, span, tokens: None },
516                // Lacking a better choice, we replace the contents with a macro call.
517                // Unexpanded macros should never reach lowering, so this is not confusing.
518                kind: dummy(Box::new(MacCall {
519                    path: Path { span, segments: ::thin_vec::ThinVec::new()thin_vec![], tokens: None },
520                    args: Box::new(DelimArgs {
521                        dspan: DelimSpan::from_single(span),
522                        delim: Delimiter::Parenthesis,
523                        tokens: TokenStream::new(Vec::new()),
524                    }),
525                })),
526                tokens: None,
527            })
528        }
529
530        fn replace_with_dummy<K>(
531            &mut self,
532            item: &mut ast::Item<K>,
533            dummy: impl FnOnce(Box<MacCall>) -> K,
534            node: impl FnOnce(Box<Item<K>>) -> AstOwner,
535        ) {
536            let dummy = self.make_dummy(item.id, item.span, dummy);
537            let item = mem::replace(item, *dummy);
538            self.insert(item.id, node(Box::new(item)));
539        }
540
541        #[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("visit_item_id_use_tree",
                                    "rustc_ast_lowering", ::tracing::Level::TRACE,
                                    ::tracing_core::__macro_support::Option::Some("compiler/rustc_ast_lowering/src/lib.rs"),
                                    ::tracing_core::__macro_support::Option::Some(541u32),
                                    ::tracing_core::__macro_support::Option::Some("rustc_ast_lowering"),
                                    ::tracing_core::field::FieldSet::new(&["tree", "parent",
                                                    "items"],
                                        ::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};
                                let mut iter = meta.fields().iter();
                                meta.fields().value_set(&[(&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
                                                    ::tracing::__macro_support::Option::Some(&::tracing::field::debug(&tree)
                                                            as &dyn Value)),
                                                (&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
                                                    ::tracing::__macro_support::Option::Some(&::tracing::field::debug(&parent)
                                                            as &dyn Value)),
                                                (&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
                                                    ::tracing::__macro_support::Option::Some(&::tracing::field::debug(&items)
                                                            as &dyn Value))])
                            })
                } else {
                    let span =
                        ::tracing::__macro_support::__disabled_span(__CALLSITE.metadata());
                    {};
                    span
                }
            };
        __tracing_attr_guard = __tracing_attr_span.enter();
    }

    #[warn(clippy :: suspicious_else_formatting)]
    {

        #[allow(unknown_lints, unreachable_code, clippy ::
        diverging_sub_expression, clippy :: empty_loop, clippy ::
        let_unit_value, clippy :: let_with_type_underscore, clippy ::
        needless_return, clippy :: unreachable)]
        if false {
            let __tracing_attr_fake_return: () = loop {};
            return __tracing_attr_fake_return;
        }
        {
            match tree.kind {
                UseTreeKind::Glob(_) | UseTreeKind::Simple(_) => {}
                UseTreeKind::Nested { items: ref nested_vec, span } => {
                    for &(ref nested, id) in nested_vec {
                        self.insert(id, AstOwner::NestedUseTree(parent));
                        items.push(self.make_dummy(id, span, ItemKind::MacCall));
                        let def_id = self.owners[&id].def_id;
                        self.visit_item_id_use_tree(nested, def_id, items);
                    }
                }
            }
        }
    }
}#[tracing::instrument(level = "trace", skip(self))]
542        fn visit_item_id_use_tree(
543            &mut self,
544            tree: &UseTree,
545            parent: LocalDefId,
546            items: &mut SmallVec<[Box<Item>; 1]>,
547        ) {
548            match tree.kind {
549                UseTreeKind::Glob(_) | UseTreeKind::Simple(_) => {}
550                UseTreeKind::Nested { items: ref nested_vec, span } => {
551                    for &(ref nested, id) in nested_vec {
552                        self.insert(id, AstOwner::NestedUseTree(parent));
553                        items.push(self.make_dummy(id, span, ItemKind::MacCall));
554
555                        let def_id = self.owners[&id].def_id;
556                        self.visit_item_id_use_tree(nested, def_id, items);
557                    }
558                }
559            }
560        }
561    }
562
563    impl MutVisitor for Indexer<'_, '_> {
564        fn visit_attribute(&mut self, _: &mut Attribute) {
565            // We do not want to lower expressions that appear in attributes,
566            // as they are not accessible to the rest of the HIR.
567        }
568
569        fn flat_map_item(&mut self, mut item: Box<Item>) -> SmallVec<[Box<Item>; 1]> {
570            let def_id = self.owners[&item.id].def_id;
571            mut_visit::walk_item(self, &mut *item);
572            let dummy = self.make_dummy(item.id, item.span, ItemKind::MacCall);
573            let mut items = {
    let count = 0usize + 1usize;
    let mut vec = ::smallvec::SmallVec::new();
    if count <= vec.inline_size() {
        vec.push(dummy);
        vec
    } else {
        ::smallvec::SmallVec::from_vec(::alloc::boxed::box_assume_init_into_vec_unsafe(::alloc::intrinsics::write_box_via_move(::alloc::boxed::Box::new_uninit(),
                    [dummy])))
    }
}smallvec![dummy];
574            if let ItemKind::Use(ref use_tree) = item.kind {
575                self.visit_item_id_use_tree(use_tree, def_id, &mut items);
576            }
577            self.insert(item.id, AstOwner::Item(item));
578            items
579        }
580
581        fn flat_map_stmt(&mut self, stmt: Stmt) -> SmallVec<[Stmt; 1]> {
582            let Stmt { id, span, kind } = stmt;
583            let mut id = Some(id);
584            mut_visit::walk_flat_map_stmt_kind(self, kind)
585                .into_iter()
586                .map(|kind| {
587                    // Expanding the current statement is a nested `use` item,
588                    // it is expanded into several flat `use` items.
589                    // Create new NodeIds for the corresponding statements
590                    // as two statements cannot have the same.
591                    let id = id.take().unwrap_or_else(|| {
592                        let next = self.next_node_id;
593                        self.next_node_id.increment_by(1);
594                        next
595                    });
596                    Stmt { id, kind, span }
597                })
598                .collect()
599        }
600
601        fn visit_assoc_item(&mut self, item: &mut AssocItem, ctxt: visit::AssocCtxt) {
602            mut_visit::walk_assoc_item(self, item, ctxt);
603            match ctxt {
604                visit::AssocCtxt::Trait => {
605                    self.replace_with_dummy(item, AssocItemKind::MacCall, AstOwner::TraitItem)
606                }
607                visit::AssocCtxt::Impl { .. } => {
608                    self.replace_with_dummy(item, AssocItemKind::MacCall, AstOwner::ImplItem)
609                }
610            }
611        }
612
613        fn visit_foreign_item(&mut self, item: &mut ForeignItem) {
614            mut_visit::walk_item(self, item);
615            self.replace_with_dummy(item, ForeignItemKind::MacCall, AstOwner::ForeignItem);
616        }
617    }
618}
619
620#[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("lower_to_hir",
                                    "rustc_ast_lowering", ::tracing::Level::TRACE,
                                    ::tracing_core::__macro_support::Option::Some("compiler/rustc_ast_lowering/src/lib.rs"),
                                    ::tracing_core::__macro_support::Option::Some(620u32),
                                    ::tracing_core::__macro_support::Option::Some("rustc_ast_lowering"),
                                    ::tracing_core::field::FieldSet::new(&["def_id"],
                                        ::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};
                                let mut iter = meta.fields().iter();
                                meta.fields().value_set(&[(&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
                                                    ::tracing::__macro_support::Option::Some(&::tracing::field::debug(&def_id)
                                                            as &dyn Value))])
                            })
                } else {
                    let span =
                        ::tracing::__macro_support::__disabled_span(__CALLSITE.metadata());
                    {};
                    span
                }
            };
        __tracing_attr_guard = __tracing_attr_span.enter();
    }

    #[warn(clippy :: suspicious_else_formatting)]
    {

        #[allow(unknown_lints, unreachable_code, clippy ::
        diverging_sub_expression, clippy :: empty_loop, clippy ::
        let_unit_value, clippy :: let_with_type_underscore, clippy ::
        needless_return, clippy :: unreachable)]
        if false {
            let __tracing_attr_fake_return: hir::MaybeOwner<'_> = loop {};
            return __tracing_attr_fake_return;
        }
        {
            tcx.ensure_done().output_filenames(());
            tcx.ensure_done().early_lint_checks(());
            tcx.ensure_done().debugger_visualizers(LOCAL_CRATE);
            tcx.ensure_done().get_lang_items(());
            let ast_index = tcx.index_ast(());
            let resolver_and_node = ast_index.get(def_id).map(Steal::steal);
            let fallback_to_ancestor =
                |parent_id|
                    {
                        let mut parent_info = tcx.lower_to_hir(parent_id);
                        if let hir::MaybeOwner::NonOwner(hir_id) = parent_info {
                            parent_info = tcx.lower_to_hir(hir_id.owner);
                        }
                        let parent_info = parent_info.unwrap();
                        *parent_info.children.get(&def_id).unwrap_or_else(||
                                    {
                                        {
                                            ::core::panicking::panic_fmt(format_args!("{0:?} does not appear in children of {1:?}",
                                                    def_id, parent_info.nodes.node().def_id()));
                                        }
                                    })
                    };
            let Some((resolver, node)) =
                resolver_and_node else {
                    return fallback_to_ancestor(tcx.local_parent(def_id));
                };
            let mut item_lowerer =
                item::ItemLowerer { tcx, resolver: &*resolver };
            let item =
                match &node {
                    AstOwner::Crate(c) => item_lowerer.lower_crate(&c),
                    AstOwner::Item(item) => item_lowerer.lower_item(&item),
                    AstOwner::TraitItem(item) =>
                        item_lowerer.lower_trait_item(&item),
                    AstOwner::ImplItem(item) =>
                        item_lowerer.lower_impl_item(&item),
                    AstOwner::ForeignItem(item) =>
                        item_lowerer.lower_foreign_item(&item),
                    AstOwner::NestedUseTree(owner_id) =>
                        fallback_to_ancestor(*owner_id),
                    AstOwner::NonOwner =>
                        fallback_to_ancestor(tcx.local_parent(def_id)),
                };
            tcx.sess.time("drop_ast", || mem::drop(node));
            item
        }
    }
}#[instrument(level = "trace", skip(tcx))]
621fn lower_to_hir(tcx: TyCtxt<'_>, def_id: LocalDefId) -> hir::MaybeOwner<'_> {
622    // Queries that borrow `resolver_for_lowering`.
623    tcx.ensure_done().output_filenames(());
624    tcx.ensure_done().early_lint_checks(());
625    tcx.ensure_done().debugger_visualizers(LOCAL_CRATE);
626    tcx.ensure_done().get_lang_items(());
627    let ast_index = tcx.index_ast(());
628    let resolver_and_node = ast_index.get(def_id).map(Steal::steal);
629
630    let fallback_to_ancestor = |parent_id| {
631        // The item did not exist in the AST, it was created while lowering another item.
632        // `parent_id` may be different from the direct parent of `def_id`,
633        // for instance use-trees are lowered by the first sibling.
634        let mut parent_info = tcx.lower_to_hir(parent_id);
635        if let hir::MaybeOwner::NonOwner(hir_id) = parent_info {
636            // `parent_id` could also not be a owner either.
637            // For instance if `def_id` is an enum variant field,
638            // the direct parent is the enum variant.
639            // In that case `hir_id.owner` point to the actual HIR owner
640            // and skips all non-owner parents, so fetch the HIR associated to it.
641            parent_info = tcx.lower_to_hir(hir_id.owner);
642        }
643
644        let parent_info = parent_info.unwrap();
645        *parent_info.children.get(&def_id).unwrap_or_else(|| {
646            panic!(
647                "{:?} does not appear in children of {:?}",
648                def_id,
649                parent_info.nodes.node().def_id()
650            )
651        })
652    };
653
654    let Some((resolver, node)) = resolver_and_node else {
655        // `ast_index` does not contain all definitions, only up-to the highest
656        // `LocalDefId` which has a non-trivial `AstOwner`. Gracefully handle
657        // other definitions, in particular those nested inside this highest definition.
658        return fallback_to_ancestor(tcx.local_parent(def_id));
659    };
660
661    let mut item_lowerer = item::ItemLowerer { tcx, resolver: &*resolver };
662
663    let item = match &node {
664        // The item existed in the AST.
665        AstOwner::Crate(c) => item_lowerer.lower_crate(&c),
666        AstOwner::Item(item) => item_lowerer.lower_item(&item),
667        AstOwner::TraitItem(item) => item_lowerer.lower_trait_item(&item),
668        AstOwner::ImplItem(item) => item_lowerer.lower_impl_item(&item),
669        AstOwner::ForeignItem(item) => item_lowerer.lower_foreign_item(&item),
670        AstOwner::NestedUseTree(owner_id) => fallback_to_ancestor(*owner_id),
671        // The item existed in the AST, but is not a HIR owner.
672        // Fetch the correct information from its parent.
673        AstOwner::NonOwner => fallback_to_ancestor(tcx.local_parent(def_id)),
674    };
675
676    tcx.sess.time("drop_ast", || mem::drop(node));
677
678    item
679}
680
681#[derive(#[automatically_derived]
impl ::core::marker::Copy for ParamMode { }Copy, #[automatically_derived]
impl ::core::clone::Clone for ParamMode {
    #[inline]
    fn clone(&self) -> ParamMode { *self }
}Clone, #[automatically_derived]
impl ::core::cmp::PartialEq for ParamMode {
    #[inline]
    fn eq(&self, other: &ParamMode) -> 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 ParamMode {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::write_str(f,
            match self {
                ParamMode::Explicit => "Explicit",
                ParamMode::Optional => "Optional",
            })
    }
}Debug)]
682enum ParamMode {
683    /// Any path in a type context.
684    Explicit,
685    /// The `module::Type` in `module::Type::method` in an expression.
686    Optional,
687}
688
689#[derive(#[automatically_derived]
impl ::core::marker::Copy for AllowReturnTypeNotation { }Copy, #[automatically_derived]
impl ::core::clone::Clone for AllowReturnTypeNotation {
    #[inline]
    fn clone(&self) -> AllowReturnTypeNotation { *self }
}Clone, #[automatically_derived]
impl ::core::fmt::Debug for AllowReturnTypeNotation {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::write_str(f,
            match self {
                AllowReturnTypeNotation::Yes => "Yes",
                AllowReturnTypeNotation::No => "No",
            })
    }
}Debug)]
690enum AllowReturnTypeNotation {
691    /// Only in types, since RTN is denied later during HIR lowering.
692    Yes,
693    /// All other positions (path expr, method, use tree).
694    No,
695}
696
697enum GenericArgsMode {
698    /// Allow paren sugar, don't allow RTN.
699    ParenSugar,
700    /// Allow RTN, don't allow paren sugar.
701    ReturnTypeNotation,
702    // Error if parenthesized generics or RTN are encountered.
703    Err,
704    /// Silence errors when lowering generics. Only used with `Res::Err`.
705    Silence,
706}
707
708impl<'hir> LoweringContext<'_, 'hir> {
709    fn create_def(
710        &mut self,
711        node_id: NodeId,
712        name: Option<Symbol>,
713        def_kind: DefKind,
714        span: Span,
715    ) -> LocalDefId {
716        let parent = self.current_hir_id_owner.def_id;
717        {
    match (&node_id, &ast::DUMMY_NODE_ID) {
        (left_val, right_val) => {
            if *left_val == *right_val {
                let kind = ::core::panicking::AssertKind::Ne;
                ::core::panicking::assert_failed(kind, &*left_val,
                    &*right_val, ::core::option::Option::None);
            }
        }
    }
};assert_ne!(node_id, ast::DUMMY_NODE_ID);
718        if !self.opt_local_def_id(node_id).is_none() {
    {
        ::core::panicking::panic_fmt(format_args!("adding a def\'n for node-id {0:?} and def kind {1:?} but a previous def\'n exists: {2:?}",
                node_id, def_kind,
                self.tcx.hir_def_key(self.local_def_id(node_id))));
    }
};assert!(
719            self.opt_local_def_id(node_id).is_none(),
720            "adding a def'n for node-id {:?} and def kind {:?} but a previous def'n exists: {:?}",
721            node_id,
722            def_kind,
723            self.tcx.hir_def_key(self.local_def_id(node_id)),
724        );
725
726        let def_id = self
727            .tcx
728            .at(span)
729            .create_def(parent, name, def_kind, None, &mut self.current_disambiguator)
730            .def_id();
731
732        {
    use ::tracing::__macro_support::Callsite as _;
    static __CALLSITE: ::tracing::callsite::DefaultCallsite =
        {
            static META: ::tracing::Metadata<'static> =
                {
                    ::tracing_core::metadata::Metadata::new("event compiler/rustc_ast_lowering/src/lib.rs:732",
                        "rustc_ast_lowering", ::tracing::Level::DEBUG,
                        ::tracing_core::__macro_support::Option::Some("compiler/rustc_ast_lowering/src/lib.rs"),
                        ::tracing_core::__macro_support::Option::Some(732u32),
                        ::tracing_core::__macro_support::Option::Some("rustc_ast_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};
                let mut iter = __CALLSITE.metadata().fields().iter();
                __CALLSITE.metadata().fields().value_set(&[(&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
                                    ::tracing::__macro_support::Option::Some(&format_args!("create_def: def_id_to_node_id[{0:?}] <-> {1:?}",
                                                    def_id, node_id) as &dyn Value))])
            });
    } else { ; }
};debug!("create_def: def_id_to_node_id[{:?}] <-> {:?}", def_id, node_id);
733        self.node_id_to_def_id.insert(node_id, def_id);
734
735        def_id
736    }
737
738    fn next_node_id(&mut self) -> NodeId {
739        let start = self.next_node_id;
740        let next = start.as_u32().checked_add(1).expect("input too large; ran out of NodeIds");
741        self.next_node_id = NodeId::from_u32(next);
742        start
743    }
744
745    /// Given the id of some node in the AST, finds the `LocalDefId` associated with it by the name
746    /// resolver (if any).
747    x;#[instrument(level = "trace", skip(self), ret)]
748    fn opt_local_def_id(&self, node: NodeId) -> Option<LocalDefId> {
749        self.node_id_to_def_id
750            .get(&node)
751            .or_else(|| self.owner.node_id_to_def_id.get(&node))
752            .copied()
753    }
754
755    fn local_def_id(&self, node: NodeId) -> LocalDefId {
756        self.opt_local_def_id(node).unwrap_or_else(|| {
757            self.resolver.owners.items().any(|(id, items)| {
758                items.node_id_to_def_id.items().any(|(node_id, def_id)| {
759                    if *node_id == node {
760                        let actual_owner = items.node_id_to_def_id.get(id);
761                        {
    ::core::panicking::panic_fmt(format_args!("{0:?} ({1}) was found in {2:?} ({3})",
            def_id, node_id, actual_owner, id));
}panic!("{def_id:?} ({node_id}) was found in {actual_owner:?} ({id})",)
762                    }
763                    false
764                })
765            });
766            {
    ::core::panicking::panic_fmt(format_args!("no entry for node id: `{0:?}`",
            node));
};panic!("no entry for node id: `{node:?}`");
767        })
768    }
769
770    fn get_partial_res(&self, id: NodeId) -> Option<PartialRes> {
771        match self.partial_res_overrides.get(&id) {
772            Some(self_param_id) => Some(PartialRes::new(Res::Local(*self_param_id))),
773            None => self.resolver.partial_res_map.get(&id).copied(),
774        }
775    }
776
777    /// Given the id of an owner node in the AST, returns the corresponding `OwnerId`.
778    fn owner_id(&self, node: NodeId) -> hir::OwnerId {
779        hir::OwnerId { def_id: self.resolver.owners[&node].def_id }
780    }
781
782    /// Freshen the `LoweringContext` and ready it to lower a nested item.
783    /// The lowered item is registered into `self.children`.
784    ///
785    /// This function sets up `HirId` lowering infrastructure,
786    /// and stashes the shared mutable state to avoid pollution by the closure.
787    #[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("with_hir_id_owner",
                                    "rustc_ast_lowering", ::tracing::Level::DEBUG,
                                    ::tracing_core::__macro_support::Option::Some("compiler/rustc_ast_lowering/src/lib.rs"),
                                    ::tracing_core::__macro_support::Option::Some(787u32),
                                    ::tracing_core::__macro_support::Option::Some("rustc_ast_lowering"),
                                    ::tracing_core::field::FieldSet::new(&["owner"],
                                        ::tracing_core::callsite::Identifier(&__CALLSITE)),
                                    ::tracing::metadata::Kind::SPAN)
                            };
                        ::tracing::callsite::DefaultCallsite::new(&META)
                    };
                let mut interest = ::tracing::subscriber::Interest::never();
                if ::tracing::Level::DEBUG <=
                                    ::tracing::level_filters::STATIC_MAX_LEVEL &&
                                ::tracing::Level::DEBUG <=
                                    ::tracing::level_filters::LevelFilter::current() &&
                            { interest = __CALLSITE.interest(); !interest.is_never() }
                        &&
                        ::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
                            interest) {
                    let meta = __CALLSITE.metadata();
                    ::tracing::Span::new(meta,
                        &{
                                #[allow(unused_imports)]
                                use ::tracing::field::{debug, display, Value};
                                let mut iter = meta.fields().iter();
                                meta.fields().value_set(&[(&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
                                                    ::tracing::__macro_support::Option::Some(&::tracing::field::debug(&owner)
                                                            as &dyn Value))])
                            })
                } else {
                    let span =
                        ::tracing::__macro_support::__disabled_span(__CALLSITE.metadata());
                    {};
                    span
                }
            };
        __tracing_attr_guard = __tracing_attr_span.enter();
    }

    #[warn(clippy :: suspicious_else_formatting)]
    {

        #[allow(unknown_lints, unreachable_code, clippy ::
        diverging_sub_expression, clippy :: empty_loop, clippy ::
        let_unit_value, clippy :: let_with_type_underscore, clippy ::
        needless_return, clippy :: unreachable)]
        if false {
            let __tracing_attr_fake_return: () = loop {};
            return __tracing_attr_fake_return;
        }
        {
            let owner_id = self.owner_id(owner);
            let def_id = owner_id.def_id;
            let new_disambig =
                self.resolver.disambiguators.get(&def_id).map(|s|
                            s.steal()).unwrap_or_else(||
                        PerParentDisambiguatorState::new(def_id));
            let disambiguator =
                mem::replace(&mut self.current_disambiguator, new_disambig);
            let current_ast_owner =
                mem::replace(&mut self.owner, &self.resolver.owners[&owner]);
            let current_attrs = mem::take(&mut self.attrs);
            let current_bodies = mem::take(&mut self.bodies);
            let current_define_opaque = mem::take(&mut self.define_opaque);
            let current_ident_and_label_to_local_id =
                mem::take(&mut self.ident_and_label_to_local_id);
            let current_node_id_to_local_id =
                mem::take(&mut self.node_id_to_local_id);
            let current_trait_map = mem::take(&mut self.trait_map);
            let current_owner =
                mem::replace(&mut self.current_hir_id_owner, owner_id);
            let current_local_counter =
                mem::replace(&mut self.item_local_id_counter,
                    hir::ItemLocalId::new(1));
            let current_impl_trait_defs =
                mem::take(&mut self.impl_trait_defs);
            let current_impl_trait_bounds =
                mem::take(&mut self.impl_trait_bounds);
            let current_delayed_lints = mem::take(&mut self.delayed_lints);
            let current_children = mem::take(&mut self.children);
            {
                let _old =
                    self.node_id_to_local_id.insert(owner,
                        hir::ItemLocalId::ZERO);
                if true {
                    {
                        match (&_old, &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 item = f(self);
            {
                match (&owner_id, &item.def_id()) {
                    (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);
                        }
                    }
                }
            };
            if !self.impl_trait_defs.is_empty() {
                ::core::panicking::panic("assertion failed: self.impl_trait_defs.is_empty()")
            };
            if !self.impl_trait_bounds.is_empty() {
                ::core::panicking::panic("assertion failed: self.impl_trait_bounds.is_empty()")
            };
            let info = self.make_owner_info(item);
            self.current_disambiguator = disambiguator;
            self.owner = current_ast_owner;
            self.attrs = current_attrs;
            self.bodies = current_bodies;
            self.define_opaque = current_define_opaque;
            self.ident_and_label_to_local_id =
                current_ident_and_label_to_local_id;
            { self.node_id_to_local_id = current_node_id_to_local_id; }
            self.trait_map = current_trait_map;
            self.current_hir_id_owner = current_owner;
            self.item_local_id_counter = current_local_counter;
            self.impl_trait_defs = current_impl_trait_defs;
            self.impl_trait_bounds = current_impl_trait_bounds;
            self.delayed_lints = current_delayed_lints;
            self.children = current_children;
            self.children.extend_unord(info.children.items().map(|(&def_id,
                            &info)| (def_id, info)));
            if true {
                if !!self.children.contains_key(&owner_id.def_id) {
                    ::core::panicking::panic("assertion failed: !self.children.contains_key(&owner_id.def_id)")
                };
            };
            self.children.insert(owner_id.def_id,
                hir::MaybeOwner::Owner(info));
        }
    }
}#[instrument(level = "debug", skip(self, f))]
788    fn with_hir_id_owner(
789        &mut self,
790        owner: NodeId,
791        f: impl FnOnce(&mut Self) -> hir::OwnerNode<'hir>,
792    ) {
793        let owner_id = self.owner_id(owner);
794        let def_id = owner_id.def_id;
795
796        let new_disambig = self
797            .resolver
798            .disambiguators
799            .get(&def_id)
800            .map(|s| s.steal())
801            .unwrap_or_else(|| PerParentDisambiguatorState::new(def_id));
802
803        let disambiguator = mem::replace(&mut self.current_disambiguator, new_disambig);
804        let current_ast_owner = mem::replace(&mut self.owner, &self.resolver.owners[&owner]);
805        let current_attrs = mem::take(&mut self.attrs);
806        let current_bodies = mem::take(&mut self.bodies);
807        let current_define_opaque = mem::take(&mut self.define_opaque);
808        let current_ident_and_label_to_local_id = mem::take(&mut self.ident_and_label_to_local_id);
809
810        #[cfg(debug_assertions)]
811        let current_node_id_to_local_id = mem::take(&mut self.node_id_to_local_id);
812        let current_trait_map = mem::take(&mut self.trait_map);
813        let current_owner = mem::replace(&mut self.current_hir_id_owner, owner_id);
814        let current_local_counter =
815            mem::replace(&mut self.item_local_id_counter, hir::ItemLocalId::new(1));
816        let current_impl_trait_defs = mem::take(&mut self.impl_trait_defs);
817        let current_impl_trait_bounds = mem::take(&mut self.impl_trait_bounds);
818        let current_delayed_lints = mem::take(&mut self.delayed_lints);
819        let current_children = mem::take(&mut self.children);
820
821        // Do not reset `next_node_id` and `node_id_to_def_id`:
822        // we want `f` to be able to refer to the `LocalDefId`s that the caller created.
823        // and the caller to refer to some of the subdefinitions' nodes' `LocalDefId`s.
824
825        // Always allocate the first `HirId` for the owner itself.
826        #[cfg(debug_assertions)]
827        {
828            let _old = self.node_id_to_local_id.insert(owner, hir::ItemLocalId::ZERO);
829            debug_assert_eq!(_old, None);
830        }
831
832        let item = f(self);
833        assert_eq!(owner_id, item.def_id());
834        // `f` should have consumed all the elements in these vectors when constructing `item`.
835        assert!(self.impl_trait_defs.is_empty());
836        assert!(self.impl_trait_bounds.is_empty());
837        let info = self.make_owner_info(item);
838
839        self.current_disambiguator = disambiguator;
840        self.owner = current_ast_owner;
841        self.attrs = current_attrs;
842        self.bodies = current_bodies;
843        self.define_opaque = current_define_opaque;
844        self.ident_and_label_to_local_id = current_ident_and_label_to_local_id;
845
846        #[cfg(debug_assertions)]
847        {
848            self.node_id_to_local_id = current_node_id_to_local_id;
849        }
850        self.trait_map = current_trait_map;
851        self.current_hir_id_owner = current_owner;
852        self.item_local_id_counter = current_local_counter;
853        self.impl_trait_defs = current_impl_trait_defs;
854        self.impl_trait_bounds = current_impl_trait_bounds;
855        self.delayed_lints = current_delayed_lints;
856        self.children = current_children;
857        self.children.extend_unord(info.children.items().map(|(&def_id, &info)| (def_id, info)));
858
859        debug_assert!(!self.children.contains_key(&owner_id.def_id));
860        self.children.insert(owner_id.def_id, hir::MaybeOwner::Owner(info));
861    }
862
863    fn make_owner_info(&mut self, node: hir::OwnerNode<'hir>) -> &'hir hir::OwnerInfo<'hir> {
864        let attrs = mem::take(&mut self.attrs);
865        let mut bodies = mem::take(&mut self.bodies);
866        let define_opaque = mem::take(&mut self.define_opaque);
867        let trait_map = mem::take(&mut self.trait_map);
868        let delayed_lints = Steal::new(mem::take(&mut self.delayed_lints).into_boxed_slice());
869        let children = mem::take(&mut self.children);
870
871        #[cfg(debug_assertions)]
872        for (id, attrs) in attrs.iter() {
873            // Verify that we do not store empty slices in the map.
874            if attrs.is_empty() {
875                {
    ::core::panicking::panic_fmt(format_args!("Stored empty attributes for {0:?}",
            id));
};panic!("Stored empty attributes for {:?}", id);
876            }
877        }
878
879        bodies.sort_by_key(|(k, _)| *k);
880        let bodies = SortedMap::from_presorted_elements(bodies);
881
882        // Don't hash unless necessary, because it's expensive.
883        let rustc_middle::hir::Hashes { bodies_hash, attrs_hash } =
884            self.tcx.hash_owner_nodes(node, &bodies, &attrs, define_opaque);
885        let num_nodes = self.item_local_id_counter.as_usize();
886        let (nodes, parenting) = index::index_hir(self.tcx, node, &bodies, num_nodes);
887        let nodes = hir::OwnerNodes { opt_hash: bodies_hash, nodes, bodies };
888        let attrs = hir::AttributeMap { map: attrs, opt_hash: attrs_hash, define_opaque };
889
890        let opt_hash = self.tcx.needs_hir_hash().then(|| {
891            self.tcx.with_stable_hashing_context(|mut hcx| {
892                let mut stable_hasher = StableHasher::new();
893                bodies_hash.unwrap().stable_hash(&mut hcx, &mut stable_hasher);
894                attrs_hash.unwrap().stable_hash(&mut hcx, &mut stable_hasher);
895                // Do not hash delayed_lints.
896                parenting.stable_hash(&mut hcx, &mut stable_hasher);
897                trait_map.stable_hash(&mut hcx, &mut stable_hasher);
898                children.stable_hash(&mut hcx, &mut stable_hasher);
899                stable_hasher.finish()
900            })
901        });
902
903        self.arena.alloc(hir::OwnerInfo {
904            opt_hash,
905            nodes,
906            parenting,
907            attrs,
908            trait_map,
909            delayed_lints,
910            children,
911        })
912    }
913
914    /// This method allocates a new `HirId` for the given `NodeId`.
915    /// Take care not to call this method if the resulting `HirId` is then not
916    /// actually used in the HIR, as that would trigger an assertion in the
917    /// `HirIdValidator` later on, which makes sure that all `NodeId`s got mapped
918    /// properly. Calling the method twice with the same `NodeId` is also forbidden.
919    x;#[instrument(level = "debug", skip(self), ret)]
920    fn lower_node_id(&mut self, ast_node_id: NodeId) -> HirId {
921        assert_ne!(ast_node_id, DUMMY_NODE_ID);
922
923        let owner = self.current_hir_id_owner;
924        let local_id = self.item_local_id_counter;
925        assert_ne!(local_id, hir::ItemLocalId::ZERO);
926        self.item_local_id_counter.increment_by(1);
927        let hir_id = HirId { owner, local_id };
928
929        if let Some(def_id) = self.opt_local_def_id(ast_node_id) {
930            self.children.insert(def_id, hir::MaybeOwner::NonOwner(hir_id));
931        }
932
933        if let Some(traits) = self.owner.trait_map.get(&ast_node_id) {
934            self.trait_map.insert(hir_id.local_id, *traits);
935        }
936
937        // Check whether the same `NodeId` is lowered more than once.
938        #[cfg(debug_assertions)]
939        {
940            let old = self.node_id_to_local_id.insert(ast_node_id, local_id);
941            assert_eq!(old, None);
942        }
943
944        hir_id
945    }
946
947    /// Generate a new `HirId` without a backing `NodeId`.
948    x;#[instrument(level = "debug", skip(self), ret)]
949    fn next_id(&mut self) -> HirId {
950        let owner = self.current_hir_id_owner;
951        let local_id = self.item_local_id_counter;
952        assert_ne!(local_id, hir::ItemLocalId::ZERO);
953        self.item_local_id_counter.increment_by(1);
954        HirId { owner, local_id }
955    }
956
957    #[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("lower_res",
                                    "rustc_ast_lowering", ::tracing::Level::TRACE,
                                    ::tracing_core::__macro_support::Option::Some("compiler/rustc_ast_lowering/src/lib.rs"),
                                    ::tracing_core::__macro_support::Option::Some(957u32),
                                    ::tracing_core::__macro_support::Option::Some("rustc_ast_lowering"),
                                    ::tracing_core::field::FieldSet::new(&["res"],
                                        ::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};
                                let mut iter = meta.fields().iter();
                                meta.fields().value_set(&[(&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
                                                    ::tracing::__macro_support::Option::Some(&::tracing::field::debug(&res)
                                                            as &dyn Value))])
                            })
                } else {
                    let span =
                        ::tracing::__macro_support::__disabled_span(__CALLSITE.metadata());
                    {};
                    span
                }
            };
        __tracing_attr_guard = __tracing_attr_span.enter();
    }

    #[warn(clippy :: suspicious_else_formatting)]
    {

        #[allow(unknown_lints, unreachable_code, clippy ::
        diverging_sub_expression, clippy :: empty_loop, clippy ::
        let_unit_value, clippy :: let_with_type_underscore, clippy ::
        needless_return, clippy :: unreachable)]
        if false {
            let __tracing_attr_fake_return: Res = loop {};
            return __tracing_attr_fake_return;
        }
        {
            let res: Result<Res, ()> =
                res.apply_id(|id|
                        {
                            let owner = self.current_hir_id_owner;
                            let local_id =
                                self.ident_and_label_to_local_id.get(&id).copied().ok_or(())?;
                            Ok(HirId { owner, local_id })
                        });
            {
                use ::tracing::__macro_support::Callsite as _;
                static __CALLSITE: ::tracing::callsite::DefaultCallsite =
                    {
                        static META: ::tracing::Metadata<'static> =
                            {
                                ::tracing_core::metadata::Metadata::new("event compiler/rustc_ast_lowering/src/lib.rs:964",
                                    "rustc_ast_lowering", ::tracing::Level::TRACE,
                                    ::tracing_core::__macro_support::Option::Some("compiler/rustc_ast_lowering/src/lib.rs"),
                                    ::tracing_core::__macro_support::Option::Some(964u32),
                                    ::tracing_core::__macro_support::Option::Some("rustc_ast_lowering"),
                                    ::tracing_core::field::FieldSet::new(&["res"],
                                        ::tracing_core::callsite::Identifier(&__CALLSITE)),
                                    ::tracing::metadata::Kind::EVENT)
                            };
                        ::tracing::callsite::DefaultCallsite::new(&META)
                    };
                let enabled =
                    ::tracing::Level::TRACE <=
                                ::tracing::level_filters::STATIC_MAX_LEVEL &&
                            ::tracing::Level::TRACE <=
                                ::tracing::level_filters::LevelFilter::current() &&
                        {
                            let interest = __CALLSITE.interest();
                            !interest.is_never() &&
                                ::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
                                    interest)
                        };
                if enabled {
                    (|value_set: ::tracing::field::ValueSet|
                                {
                                    let meta = __CALLSITE.metadata();
                                    ::tracing::Event::dispatch(meta, &value_set);
                                    ;
                                })({
                            #[allow(unused_imports)]
                            use ::tracing::field::{debug, display, Value};
                            let mut iter = __CALLSITE.metadata().fields().iter();
                            __CALLSITE.metadata().fields().value_set(&[(&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
                                                ::tracing::__macro_support::Option::Some(&debug(&res) as
                                                        &dyn Value))])
                        });
                } else { ; }
            };
            res.unwrap_or(Res::Err)
        }
    }
}#[instrument(level = "trace", skip(self))]
958    fn lower_res(&mut self, res: Res<NodeId>) -> Res {
959        let res: Result<Res, ()> = res.apply_id(|id| {
960            let owner = self.current_hir_id_owner;
961            let local_id = self.ident_and_label_to_local_id.get(&id).copied().ok_or(())?;
962            Ok(HirId { owner, local_id })
963        });
964        trace!(?res);
965
966        // We may fail to find a HirId when the Res points to a Local from an enclosing HIR owner.
967        // This can happen when trying to lower the return type `x` in erroneous code like
968        //   async fn foo(x: u8) -> x {}
969        // In that case, `x` is lowered as a function parameter, and the return type is lowered as
970        // an opaque type as a synthesized HIR owner.
971        res.unwrap_or(Res::Err)
972    }
973
974    fn expect_full_res(&mut self, id: NodeId) -> Res<NodeId> {
975        self.get_partial_res(id).map_or(Res::Err, |pr| pr.expect_full_res())
976    }
977
978    fn lower_import_res(&mut self, id: NodeId, span: Span) -> PerNS<Option<Res>> {
979        if true {
    {
        match (&id, &self.owner.id) {
            (left_val, right_val) => {
                if !(*left_val == *right_val) {
                    let kind = ::core::panicking::AssertKind::Eq;
                    ::core::panicking::assert_failed(kind, &*left_val,
                        &*right_val, ::core::option::Option::None);
                }
            }
        }
    };
};debug_assert_eq!(id, self.owner.id);
980        let per_ns = self.owner.import_res.map(|res| res.map(|res| self.lower_res(res)));
981        if per_ns.is_empty() {
982            // Propagate the error to all namespaces, just to be sure.
983            self.dcx().span_delayed_bug(span, "no resolution for an import");
984            let err = Some(Res::Err);
985            return PerNS { type_ns: err, value_ns: err, macro_ns: err };
986        }
987        per_ns
988    }
989
990    fn make_lang_item_qpath(
991        &mut self,
992        lang_item: hir::LangItem,
993        span: Span,
994        args: Option<&'hir hir::GenericArgs<'hir>>,
995    ) -> hir::QPath<'hir> {
996        hir::QPath::Resolved(None, self.make_lang_item_path(lang_item, span, args))
997    }
998
999    fn make_lang_item_path(
1000        &mut self,
1001        lang_item: hir::LangItem,
1002        span: Span,
1003        args: Option<&'hir hir::GenericArgs<'hir>>,
1004    ) -> &'hir hir::Path<'hir> {
1005        let def_id = self.tcx.require_lang_item(lang_item, span);
1006        let def_kind = self.tcx.def_kind(def_id);
1007        let res = Res::Def(def_kind, def_id);
1008        self.arena.alloc(hir::Path {
1009            span,
1010            res,
1011            segments: self.arena.alloc_from_iter([hir::PathSegment {
1012                ident: Ident::new(lang_item.name(), span),
1013                hir_id: self.next_id(),
1014                res,
1015                args,
1016                infer_args: args.is_none(),
1017            }]),
1018        })
1019    }
1020
1021    /// Reuses the span but adds information like the kind of the desugaring and features that are
1022    /// allowed inside this span.
1023    fn mark_span_with_reason(
1024        &self,
1025        reason: DesugaringKind,
1026        span: Span,
1027        allow_internal_unstable: Option<Arc<[Symbol]>>,
1028    ) -> Span {
1029        self.tcx.with_stable_hashing_context(|hcx| {
1030            span.mark_with_reason(allow_internal_unstable, reason, span.edition(), hcx)
1031        })
1032    }
1033
1034    fn span_lowerer(&self) -> SpanLowerer {
1035        SpanLowerer {
1036            is_incremental: self.tcx.sess.opts.incremental.is_some(),
1037            def_id: self.current_hir_id_owner.def_id,
1038        }
1039    }
1040
1041    /// Intercept all spans entering HIR.
1042    /// Mark a span as relative to the current owning item.
1043    fn lower_span(&self, span: Span) -> Span {
1044        self.span_lowerer().lower(span)
1045    }
1046
1047    fn lower_ident(&self, ident: Ident) -> Ident {
1048        Ident::new(ident.name, self.lower_span(ident.span))
1049    }
1050
1051    /// Converts a lifetime into a new generic parameter.
1052    #[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("lifetime_res_to_generic_param",
                                    "rustc_ast_lowering", ::tracing::Level::DEBUG,
                                    ::tracing_core::__macro_support::Option::Some("compiler/rustc_ast_lowering/src/lib.rs"),
                                    ::tracing_core::__macro_support::Option::Some(1052u32),
                                    ::tracing_core::__macro_support::Option::Some("rustc_ast_lowering"),
                                    ::tracing_core::field::FieldSet::new(&["ident", "node_id",
                                                    "kind", "source"],
                                        ::tracing_core::callsite::Identifier(&__CALLSITE)),
                                    ::tracing::metadata::Kind::SPAN)
                            };
                        ::tracing::callsite::DefaultCallsite::new(&META)
                    };
                let mut interest = ::tracing::subscriber::Interest::never();
                if ::tracing::Level::DEBUG <=
                                    ::tracing::level_filters::STATIC_MAX_LEVEL &&
                                ::tracing::Level::DEBUG <=
                                    ::tracing::level_filters::LevelFilter::current() &&
                            { interest = __CALLSITE.interest(); !interest.is_never() }
                        &&
                        ::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
                            interest) {
                    let meta = __CALLSITE.metadata();
                    ::tracing::Span::new(meta,
                        &{
                                #[allow(unused_imports)]
                                use ::tracing::field::{debug, display, Value};
                                let mut iter = meta.fields().iter();
                                meta.fields().value_set(&[(&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
                                                    ::tracing::__macro_support::Option::Some(&::tracing::field::debug(&ident)
                                                            as &dyn Value)),
                                                (&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
                                                    ::tracing::__macro_support::Option::Some(&::tracing::field::debug(&node_id)
                                                            as &dyn Value)),
                                                (&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
                                                    ::tracing::__macro_support::Option::Some(&::tracing::field::debug(&kind)
                                                            as &dyn Value)),
                                                (&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
                                                    ::tracing::__macro_support::Option::Some(&::tracing::field::debug(&source)
                                                            as &dyn Value))])
                            })
                } else {
                    let span =
                        ::tracing::__macro_support::__disabled_span(__CALLSITE.metadata());
                    {};
                    span
                }
            };
        __tracing_attr_guard = __tracing_attr_span.enter();
    }

    #[warn(clippy :: suspicious_else_formatting)]
    {

        #[allow(unknown_lints, unreachable_code, clippy ::
        diverging_sub_expression, clippy :: empty_loop, clippy ::
        let_unit_value, clippy :: let_with_type_underscore, clippy ::
        needless_return, clippy :: unreachable)]
        if false {
            let __tracing_attr_fake_return: hir::GenericParam<'hir> = loop {};
            return __tracing_attr_fake_return;
        }
        {
            let _def_id =
                self.create_def(node_id, Some(kw::UnderscoreLifetime),
                    DefKind::LifetimeParam, ident.span);
            {
                use ::tracing::__macro_support::Callsite as _;
                static __CALLSITE: ::tracing::callsite::DefaultCallsite =
                    {
                        static META: ::tracing::Metadata<'static> =
                            {
                                ::tracing_core::metadata::Metadata::new("event compiler/rustc_ast_lowering/src/lib.rs:1067",
                                    "rustc_ast_lowering", ::tracing::Level::DEBUG,
                                    ::tracing_core::__macro_support::Option::Some("compiler/rustc_ast_lowering/src/lib.rs"),
                                    ::tracing_core::__macro_support::Option::Some(1067u32),
                                    ::tracing_core::__macro_support::Option::Some("rustc_ast_lowering"),
                                    ::tracing_core::field::FieldSet::new(&["_def_id"],
                                        ::tracing_core::callsite::Identifier(&__CALLSITE)),
                                    ::tracing::metadata::Kind::EVENT)
                            };
                        ::tracing::callsite::DefaultCallsite::new(&META)
                    };
                let enabled =
                    ::tracing::Level::DEBUG <=
                                ::tracing::level_filters::STATIC_MAX_LEVEL &&
                            ::tracing::Level::DEBUG <=
                                ::tracing::level_filters::LevelFilter::current() &&
                        {
                            let interest = __CALLSITE.interest();
                            !interest.is_never() &&
                                ::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
                                    interest)
                        };
                if enabled {
                    (|value_set: ::tracing::field::ValueSet|
                                {
                                    let meta = __CALLSITE.metadata();
                                    ::tracing::Event::dispatch(meta, &value_set);
                                    ;
                                })({
                            #[allow(unused_imports)]
                            use ::tracing::field::{debug, display, Value};
                            let mut iter = __CALLSITE.metadata().fields().iter();
                            __CALLSITE.metadata().fields().value_set(&[(&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
                                                ::tracing::__macro_support::Option::Some(&debug(&_def_id) as
                                                        &dyn Value))])
                        });
                } else { ; }
            };
            let hir_id = self.lower_node_id(node_id);
            let def_id = self.local_def_id(node_id);
            hir::GenericParam {
                hir_id,
                def_id,
                name: hir::ParamName::Fresh,
                span: self.lower_span(ident.span),
                pure_wrt_drop: false,
                kind: hir::GenericParamKind::Lifetime {
                    kind: hir::LifetimeParamKind::Elided(kind),
                },
                colon_span: None,
                source,
            }
        }
    }
}#[instrument(level = "debug", skip(self))]
1053    fn lifetime_res_to_generic_param(
1054        &mut self,
1055        ident: Ident,
1056        node_id: NodeId,
1057        kind: MissingLifetimeKind,
1058        source: hir::GenericParamSource,
1059    ) -> hir::GenericParam<'hir> {
1060        // Late resolution delegates to us the creation of the `LocalDefId`.
1061        let _def_id = self.create_def(
1062            node_id,
1063            Some(kw::UnderscoreLifetime),
1064            DefKind::LifetimeParam,
1065            ident.span,
1066        );
1067        debug!(?_def_id);
1068
1069        let hir_id = self.lower_node_id(node_id);
1070        let def_id = self.local_def_id(node_id);
1071        hir::GenericParam {
1072            hir_id,
1073            def_id,
1074            name: hir::ParamName::Fresh,
1075            span: self.lower_span(ident.span),
1076            pure_wrt_drop: false,
1077            kind: hir::GenericParamKind::Lifetime { kind: hir::LifetimeParamKind::Elided(kind) },
1078            colon_span: None,
1079            source,
1080        }
1081    }
1082
1083    /// Lowers a lifetime binder that defines `generic_params`, returning the corresponding HIR
1084    /// nodes. The returned list includes any "extra" lifetime parameters that were added by the
1085    /// name resolver owing to lifetime elision; this also populates the resolver's node-id->def-id
1086    /// map, so that later calls to `opt_node_id_to_def_id` that refer to these extra lifetime
1087    /// parameters will be successful.
1088    x;#[instrument(level = "debug", skip(self), ret)]
1089    #[inline]
1090    fn lower_lifetime_binder(
1091        &mut self,
1092        binder: NodeId,
1093        generic_params: &[GenericParam],
1094    ) -> &'hir [hir::GenericParam<'hir>] {
1095        // Start by creating params for extra lifetimes params, as this creates the definitions
1096        // that may be referred to by the AST inside `generic_params`.
1097        let extra_lifetimes = self.resolver.extra_lifetime_params(binder);
1098        debug!(?extra_lifetimes);
1099        let extra_lifetimes: Vec<_> = extra_lifetimes
1100            .iter()
1101            .map(|&(ident, node_id, res)| {
1102                self.lifetime_res_to_generic_param(
1103                    ident,
1104                    node_id,
1105                    res,
1106                    hir::GenericParamSource::Binder,
1107                )
1108            })
1109            .collect();
1110        let arena = self.arena;
1111        let explicit_generic_params =
1112            self.lower_generic_params_mut(generic_params, hir::GenericParamSource::Binder);
1113        arena.alloc_from_iter(explicit_generic_params.chain(extra_lifetimes.into_iter()))
1114    }
1115
1116    fn with_dyn_type_scope<T>(&mut self, in_scope: bool, f: impl FnOnce(&mut Self) -> T) -> T {
1117        let was_in_dyn_type = self.is_in_dyn_type;
1118        self.is_in_dyn_type = in_scope;
1119
1120        let result = f(self);
1121
1122        self.is_in_dyn_type = was_in_dyn_type;
1123
1124        result
1125    }
1126
1127    fn with_new_scopes<T>(&mut self, scope_span: Span, f: impl FnOnce(&mut Self) -> T) -> T {
1128        let current_item = self.current_item;
1129        self.current_item = Some(scope_span);
1130
1131        let was_in_loop_condition = self.is_in_loop_condition;
1132        self.is_in_loop_condition = false;
1133
1134        let old_contract = self.contract_ensures.take();
1135
1136        let try_block_scope = mem::replace(&mut self.try_block_scope, TryBlockScope::Function);
1137        let loop_scope = self.loop_scope.take();
1138        let ret = f(self);
1139        self.try_block_scope = try_block_scope;
1140        self.loop_scope = loop_scope;
1141
1142        self.contract_ensures = old_contract;
1143
1144        self.is_in_loop_condition = was_in_loop_condition;
1145
1146        self.current_item = current_item;
1147
1148        ret
1149    }
1150
1151    fn lower_attrs(
1152        &mut self,
1153        id: HirId,
1154        attrs: &[Attribute],
1155        target_span: Span,
1156        target: Target,
1157    ) -> &'hir [hir::Attribute] {
1158        self.lower_attrs_with_extra(id, attrs, target_span, target, &[])
1159    }
1160
1161    fn lower_attrs_with_extra(
1162        &mut self,
1163        id: HirId,
1164        attrs: &[Attribute],
1165        target_span: Span,
1166        target: Target,
1167        extra_hir_attributes: &[hir::Attribute],
1168    ) -> &'hir [hir::Attribute] {
1169        if attrs.is_empty() && extra_hir_attributes.is_empty() {
1170            &[]
1171        } else {
1172            let mut lowered_attrs =
1173                self.lower_attrs_vec(attrs, self.lower_span(target_span), id, target);
1174            lowered_attrs.extend(extra_hir_attributes.iter().cloned());
1175
1176            {
    match (&id.owner, &self.current_hir_id_owner) {
        (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!(id.owner, self.current_hir_id_owner);
1177            let ret = self.arena.alloc_from_iter(lowered_attrs);
1178
1179            // this is possible if an item contained syntactical attribute,
1180            // but none of them parse successfully or all of them were ignored
1181            // for not being built-in attributes at all. They could be remaining
1182            // unexpanded attributes used as markers in proc-macro derives for example.
1183            // This will have emitted some diagnostics for the misparse, but will then
1184            // not emit the attribute making the list empty.
1185            if ret.is_empty() {
1186                &[]
1187            } else {
1188                self.attrs.insert(id.local_id, ret);
1189                ret
1190            }
1191        }
1192    }
1193
1194    fn lower_attrs_vec(
1195        &mut self,
1196        attrs: &[Attribute],
1197        target_span: Span,
1198        target_hir_id: HirId,
1199        target: Target,
1200    ) -> Vec<hir::Attribute> {
1201        let l = self.span_lowerer();
1202        self.attribute_parser.parse_attribute_list(
1203            attrs,
1204            target_span,
1205            target,
1206            OmitDoc::Lower,
1207            |s| l.lower(s),
1208            |lint_id, span, kind| {
1209                self.delayed_lints.push(DelayedLint {
1210                    lint_id,
1211                    id: target_hir_id,
1212                    span,
1213                    callback: Box::new(move |dcx, level, sess: &dyn std::any::Any| {
1214                        let sess = sess
1215                            .downcast_ref::<rustc_session::Session>()
1216                            .expect("expected `Session`");
1217                        (kind.0)(dcx, level, sess)
1218                    }),
1219                });
1220            },
1221        )
1222    }
1223
1224    fn alias_attrs(&mut self, id: HirId, target_id: HirId) {
1225        {
    match (&id.owner, &self.current_hir_id_owner) {
        (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!(id.owner, self.current_hir_id_owner);
1226        {
    match (&target_id.owner, &self.current_hir_id_owner) {
        (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!(target_id.owner, self.current_hir_id_owner);
1227        if let Some(&a) = self.attrs.get(&target_id.local_id) {
1228            if !!a.is_empty() {
    ::core::panicking::panic("assertion failed: !a.is_empty()")
};assert!(!a.is_empty());
1229            self.attrs.insert(id.local_id, a);
1230        }
1231    }
1232
1233    fn lower_delim_args(&self, args: &DelimArgs) -> DelimArgs {
1234        args.clone()
1235    }
1236
1237    /// Lower an associated item constraint.
1238    #[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_assoc_item_constraint",
                                    "rustc_ast_lowering", ::tracing::Level::DEBUG,
                                    ::tracing_core::__macro_support::Option::Some("compiler/rustc_ast_lowering/src/lib.rs"),
                                    ::tracing_core::__macro_support::Option::Some(1238u32),
                                    ::tracing_core::__macro_support::Option::Some("rustc_ast_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(&[]) })
                } 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: hir::AssocItemConstraint<'hir> =
                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 compiler/rustc_ast_lowering/src/lib.rs:1244",
                                    "rustc_ast_lowering", ::tracing::Level::DEBUG,
                                    ::tracing_core::__macro_support::Option::Some("compiler/rustc_ast_lowering/src/lib.rs"),
                                    ::tracing_core::__macro_support::Option::Some(1244u32),
                                    ::tracing_core::__macro_support::Option::Some("rustc_ast_lowering"),
                                    ::tracing_core::field::FieldSet::new(&["constraint",
                                                    "itctx"],
                                        ::tracing_core::callsite::Identifier(&__CALLSITE)),
                                    ::tracing::metadata::Kind::EVENT)
                            };
                        ::tracing::callsite::DefaultCallsite::new(&META)
                    };
                let enabled =
                    ::tracing::Level::DEBUG <=
                                ::tracing::level_filters::STATIC_MAX_LEVEL &&
                            ::tracing::Level::DEBUG <=
                                ::tracing::level_filters::LevelFilter::current() &&
                        {
                            let interest = __CALLSITE.interest();
                            !interest.is_never() &&
                                ::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
                                    interest)
                        };
                if enabled {
                    (|value_set: ::tracing::field::ValueSet|
                                {
                                    let meta = __CALLSITE.metadata();
                                    ::tracing::Event::dispatch(meta, &value_set);
                                    ;
                                })({
                            #[allow(unused_imports)]
                            use ::tracing::field::{debug, display, Value};
                            let mut iter = __CALLSITE.metadata().fields().iter();
                            __CALLSITE.metadata().fields().value_set(&[(&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
                                                ::tracing::__macro_support::Option::Some(&debug(&constraint)
                                                        as &dyn Value)),
                                            (&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
                                                ::tracing::__macro_support::Option::Some(&debug(&itctx) as
                                                        &dyn Value))])
                        });
                } else { ; }
            };
            let gen_args =
                if let Some(gen_args) = &constraint.gen_args {
                    let gen_args_ctor =
                        match gen_args {
                            GenericArgs::AngleBracketed(data) => {
                                self.lower_angle_bracketed_parameter_data(data,
                                        ParamMode::Explicit, itctx).0
                            }
                            GenericArgs::Parenthesized(data) => {
                                if let Some(first_char) =
                                            constraint.ident.as_str().chars().next() &&
                                        first_char.is_ascii_lowercase() {
                                    let err =
                                        match (&data.inputs[..], &data.output) {
                                            ([_, ..], FnRetTy::Default(_)) => {
                                                diagnostics::BadReturnTypeNotation::Inputs {
                                                    span: data.inputs_span,
                                                }
                                            }
                                            ([], FnRetTy::Default(_)) => {
                                                diagnostics::BadReturnTypeNotation::NeedsDots {
                                                    span: data.inputs_span,
                                                }
                                            }
                                            (_, FnRetTy::Ty(ty)) => {
                                                let span = data.inputs_span.shrink_to_hi().to(ty.span);
                                                diagnostics::BadReturnTypeNotation::Output {
                                                    span,
                                                    suggestion: diagnostics::RTNSuggestion {
                                                        output: span,
                                                        input: data.inputs_span,
                                                    },
                                                }
                                            }
                                        };
                                    let mut err = self.dcx().create_err(err);
                                    if !self.tcx.features().return_type_notation() &&
                                            self.tcx.sess.is_nightly_build() {
                                        add_feature_diagnostics(&mut err, &self.tcx.sess,
                                            sym::return_type_notation);
                                    }
                                    err.emit();
                                    GenericArgsCtor {
                                        args: Default::default(),
                                        constraints: &[],
                                        parenthesized: hir::GenericArgsParentheses::ReturnTypeNotation,
                                        span: data.span,
                                    }
                                } else {
                                    self.emit_bad_parenthesized_trait_in_assoc_ty(data);
                                    self.lower_angle_bracketed_parameter_data(&data.as_angle_bracketed_args(),
                                            ParamMode::Explicit, itctx).0
                                }
                            }
                            GenericArgs::ParenthesizedElided(span) =>
                                GenericArgsCtor {
                                    args: Default::default(),
                                    constraints: &[],
                                    parenthesized: hir::GenericArgsParentheses::ReturnTypeNotation,
                                    span: *span,
                                },
                        };
                    gen_args_ctor.into_generic_args(self)
                } else { hir::GenericArgs::NONE };
            let kind =
                match &constraint.kind {
                    AssocItemConstraintKind::Equality { term } => {
                        let term =
                            match term {
                                Term::Ty(ty) => self.lower_ty_alloc(ty, itctx).into(),
                                Term::Const(c) =>
                                    self.lower_anon_const_to_const_arg_and_alloc(c).into(),
                            };
                        hir::AssocItemConstraintKind::Equality { term }
                    }
                    AssocItemConstraintKind::Bound { bounds } => {
                        if self.is_in_dyn_type {
                            let suggestion =
                                match itctx {
                                    ImplTraitContext::OpaqueTy { .. } |
                                        ImplTraitContext::Universal => {
                                        let bound_end_span =
                                            constraint.gen_args.as_ref().map_or(constraint.ident.span,
                                                |args| args.span());
                                        if bound_end_span.eq_ctxt(constraint.span) {
                                            Some(self.tcx.sess.source_map().next_point(bound_end_span))
                                        } else { None }
                                    }
                                    _ => None,
                                };
                            let guar =
                                self.dcx().emit_err(diagnostics::MisplacedAssocTyBinding {
                                        span: constraint.span,
                                        suggestion,
                                    });
                            let err_ty =
                                &*self.arena.alloc(self.ty(constraint.span,
                                                hir::TyKind::Err(guar)));
                            hir::AssocItemConstraintKind::Equality {
                                term: err_ty.into(),
                            }
                        } else {
                            let bounds =
                                self.lower_param_bounds(bounds,
                                    RelaxedBoundPolicy::Forbidden(RelaxedBoundForbiddenReason::AssocTyBounds),
                                    itctx);
                            hir::AssocItemConstraintKind::Bound { bounds }
                        }
                    }
                };
            hir::AssocItemConstraint {
                hir_id: self.lower_node_id(constraint.id),
                ident: self.lower_ident(constraint.ident),
                gen_args,
                kind,
                span: self.lower_span(constraint.span),
            }
        }
    }
}#[instrument(level = "debug", skip_all)]
1239    fn lower_assoc_item_constraint(
1240        &mut self,
1241        constraint: &AssocItemConstraint,
1242        itctx: ImplTraitContext,
1243    ) -> hir::AssocItemConstraint<'hir> {
1244        debug!(?constraint, ?itctx);
1245        // Lower the generic arguments for the associated item.
1246        let gen_args = if let Some(gen_args) = &constraint.gen_args {
1247            let gen_args_ctor = match gen_args {
1248                GenericArgs::AngleBracketed(data) => {
1249                    self.lower_angle_bracketed_parameter_data(data, ParamMode::Explicit, itctx).0
1250                }
1251                GenericArgs::Parenthesized(data) => {
1252                    if let Some(first_char) = constraint.ident.as_str().chars().next()
1253                        && first_char.is_ascii_lowercase()
1254                    {
1255                        let err = match (&data.inputs[..], &data.output) {
1256                            ([_, ..], FnRetTy::Default(_)) => {
1257                                diagnostics::BadReturnTypeNotation::Inputs {
1258                                    span: data.inputs_span,
1259                                }
1260                            }
1261                            ([], FnRetTy::Default(_)) => {
1262                                diagnostics::BadReturnTypeNotation::NeedsDots {
1263                                    span: data.inputs_span,
1264                                }
1265                            }
1266                            // The case `T: Trait<method(..) -> Ret>` is handled in the parser.
1267                            (_, FnRetTy::Ty(ty)) => {
1268                                let span = data.inputs_span.shrink_to_hi().to(ty.span);
1269                                diagnostics::BadReturnTypeNotation::Output {
1270                                    span,
1271                                    suggestion: diagnostics::RTNSuggestion {
1272                                        output: span,
1273                                        input: data.inputs_span,
1274                                    },
1275                                }
1276                            }
1277                        };
1278                        let mut err = self.dcx().create_err(err);
1279                        if !self.tcx.features().return_type_notation()
1280                            && self.tcx.sess.is_nightly_build()
1281                        {
1282                            add_feature_diagnostics(
1283                                &mut err,
1284                                &self.tcx.sess,
1285                                sym::return_type_notation,
1286                            );
1287                        }
1288                        err.emit();
1289                        GenericArgsCtor {
1290                            args: Default::default(),
1291                            constraints: &[],
1292                            parenthesized: hir::GenericArgsParentheses::ReturnTypeNotation,
1293                            span: data.span,
1294                        }
1295                    } else {
1296                        self.emit_bad_parenthesized_trait_in_assoc_ty(data);
1297                        self.lower_angle_bracketed_parameter_data(
1298                            &data.as_angle_bracketed_args(),
1299                            ParamMode::Explicit,
1300                            itctx,
1301                        )
1302                        .0
1303                    }
1304                }
1305                GenericArgs::ParenthesizedElided(span) => GenericArgsCtor {
1306                    args: Default::default(),
1307                    constraints: &[],
1308                    parenthesized: hir::GenericArgsParentheses::ReturnTypeNotation,
1309                    span: *span,
1310                },
1311            };
1312            gen_args_ctor.into_generic_args(self)
1313        } else {
1314            hir::GenericArgs::NONE
1315        };
1316        let kind = match &constraint.kind {
1317            AssocItemConstraintKind::Equality { term } => {
1318                let term = match term {
1319                    Term::Ty(ty) => self.lower_ty_alloc(ty, itctx).into(),
1320                    Term::Const(c) => self.lower_anon_const_to_const_arg_and_alloc(c).into(),
1321                };
1322                hir::AssocItemConstraintKind::Equality { term }
1323            }
1324            AssocItemConstraintKind::Bound { bounds } => {
1325                // Disallow ATB in dyn types
1326                if self.is_in_dyn_type {
1327                    let suggestion = match itctx {
1328                        ImplTraitContext::OpaqueTy { .. } | ImplTraitContext::Universal => {
1329                            let bound_end_span = constraint
1330                                .gen_args
1331                                .as_ref()
1332                                .map_or(constraint.ident.span, |args| args.span());
1333                            if bound_end_span.eq_ctxt(constraint.span) {
1334                                Some(self.tcx.sess.source_map().next_point(bound_end_span))
1335                            } else {
1336                                None
1337                            }
1338                        }
1339                        _ => None,
1340                    };
1341
1342                    let guar = self.dcx().emit_err(diagnostics::MisplacedAssocTyBinding {
1343                        span: constraint.span,
1344                        suggestion,
1345                    });
1346                    let err_ty =
1347                        &*self.arena.alloc(self.ty(constraint.span, hir::TyKind::Err(guar)));
1348                    hir::AssocItemConstraintKind::Equality { term: err_ty.into() }
1349                } else {
1350                    let bounds = self.lower_param_bounds(
1351                        bounds,
1352                        RelaxedBoundPolicy::Forbidden(RelaxedBoundForbiddenReason::AssocTyBounds),
1353                        itctx,
1354                    );
1355                    hir::AssocItemConstraintKind::Bound { bounds }
1356                }
1357            }
1358        };
1359
1360        hir::AssocItemConstraint {
1361            hir_id: self.lower_node_id(constraint.id),
1362            ident: self.lower_ident(constraint.ident),
1363            gen_args,
1364            kind,
1365            span: self.lower_span(constraint.span),
1366        }
1367    }
1368
1369    fn emit_bad_parenthesized_trait_in_assoc_ty(&self, data: &ParenthesizedArgs) {
1370        // Suggest removing empty parentheses: "Trait()" -> "Trait"
1371        let sub = if data.inputs.is_empty() {
1372            let parentheses_span =
1373                data.inputs_span.shrink_to_lo().to(data.inputs_span.shrink_to_hi());
1374            AssocTyParenthesesSub::Empty { parentheses_span }
1375        }
1376        // Suggest replacing parentheses with angle brackets `Trait(params...)` to `Trait<params...>`
1377        else {
1378            // Start of parameters to the 1st argument
1379            let open_param = data.inputs_span.shrink_to_lo().to(data
1380                .inputs
1381                .first()
1382                .unwrap()
1383                .span
1384                .shrink_to_lo());
1385            // End of last argument to end of parameters
1386            let close_param =
1387                data.inputs.last().unwrap().span.shrink_to_hi().to(data.inputs_span.shrink_to_hi());
1388            AssocTyParenthesesSub::NotEmpty { open_param, close_param }
1389        };
1390        self.dcx().emit_err(AssocTyParentheses { span: data.span, sub });
1391    }
1392
1393    #[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_arg",
                                    "rustc_ast_lowering", ::tracing::Level::DEBUG,
                                    ::tracing_core::__macro_support::Option::Some("compiler/rustc_ast_lowering/src/lib.rs"),
                                    ::tracing_core::__macro_support::Option::Some(1393u32),
                                    ::tracing_core::__macro_support::Option::Some("rustc_ast_lowering"),
                                    ::tracing_core::field::FieldSet::new(&["arg", "itctx"],
                                        ::tracing_core::callsite::Identifier(&__CALLSITE)),
                                    ::tracing::metadata::Kind::SPAN)
                            };
                        ::tracing::callsite::DefaultCallsite::new(&META)
                    };
                let mut interest = ::tracing::subscriber::Interest::never();
                if ::tracing::Level::DEBUG <=
                                    ::tracing::level_filters::STATIC_MAX_LEVEL &&
                                ::tracing::Level::DEBUG <=
                                    ::tracing::level_filters::LevelFilter::current() &&
                            { interest = __CALLSITE.interest(); !interest.is_never() }
                        &&
                        ::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
                            interest) {
                    let meta = __CALLSITE.metadata();
                    ::tracing::Span::new(meta,
                        &{
                                #[allow(unused_imports)]
                                use ::tracing::field::{debug, display, Value};
                                let mut iter = meta.fields().iter();
                                meta.fields().value_set(&[(&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
                                                    ::tracing::__macro_support::Option::Some(&::tracing::field::debug(&arg)
                                                            as &dyn Value)),
                                                (&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
                                                    ::tracing::__macro_support::Option::Some(&::tracing::field::debug(&itctx)
                                                            as &dyn Value))])
                            })
                } else {
                    let span =
                        ::tracing::__macro_support::__disabled_span(__CALLSITE.metadata());
                    {};
                    span
                }
            };
        __tracing_attr_guard = __tracing_attr_span.enter();
    }

    #[warn(clippy :: suspicious_else_formatting)]
    {

        #[allow(unknown_lints, unreachable_code, clippy ::
        diverging_sub_expression, clippy :: empty_loop, clippy ::
        let_unit_value, clippy :: let_with_type_underscore, clippy ::
        needless_return, clippy :: unreachable)]
        if false {
            let __tracing_attr_fake_return: hir::GenericArg<'hir> = loop {};
            return __tracing_attr_fake_return;
        }
        {
            match arg {
                ast::GenericArg::Lifetime(lt) =>
                    GenericArg::Lifetime(self.lower_lifetime(lt,
                            LifetimeSource::Path {
                                angle_brackets: hir::AngleBrackets::Full,
                            }, lt.ident.into())),
                ast::GenericArg::Type(ty) => {
                    if ty.is_maybe_parenthesised_infer() {
                        return GenericArg::Infer(hir::InferArg {
                                    hir_id: self.lower_node_id(ty.id),
                                    span: self.lower_span(ty.span),
                                });
                    }
                    match &ty.kind {
                        TyKind::Path(None, path) => {
                            if let Some(res) =
                                    self.get_partial_res(ty.id).and_then(|partial_res|
                                            partial_res.full_res()) {
                                if !res.matches_ns(Namespace::TypeNS) &&
                                        path.is_potential_trivial_const_arg() {
                                    {
                                        use ::tracing::__macro_support::Callsite as _;
                                        static __CALLSITE: ::tracing::callsite::DefaultCallsite =
                                            {
                                                static META: ::tracing::Metadata<'static> =
                                                    {
                                                        ::tracing_core::metadata::Metadata::new("event compiler/rustc_ast_lowering/src/lib.rs:1430",
                                                            "rustc_ast_lowering", ::tracing::Level::DEBUG,
                                                            ::tracing_core::__macro_support::Option::Some("compiler/rustc_ast_lowering/src/lib.rs"),
                                                            ::tracing_core::__macro_support::Option::Some(1430u32),
                                                            ::tracing_core::__macro_support::Option::Some("rustc_ast_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};
                                                    let mut iter = __CALLSITE.metadata().fields().iter();
                                                    __CALLSITE.metadata().fields().value_set(&[(&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
                                                                        ::tracing::__macro_support::Option::Some(&format_args!("lower_generic_arg: Lowering type argument as const argument: {0:?}",
                                                                                        ty) as &dyn Value))])
                                                });
                                        } else { ; }
                                    };
                                    let ct =
                                        self.lower_const_path_to_const_arg(path, res, ty.id,
                                            ty.span);
                                    return GenericArg::Const(ct.try_as_ambig_ct().unwrap());
                                }
                            }
                        }
                        _ => {}
                    }
                    GenericArg::Type(self.lower_ty_alloc(ty,
                                    itctx).try_as_ambig_ty().unwrap())
                }
                ast::GenericArg::Const(ct) => {
                    let ct = self.lower_anon_const_to_const_arg_and_alloc(ct);
                    match ct.try_as_ambig_ct() {
                        Some(ct) => GenericArg::Const(ct),
                        None =>
                            GenericArg::Infer(hir::InferArg {
                                    hir_id: ct.hir_id,
                                    span: ct.span,
                                }),
                    }
                }
            }
        }
    }
}#[instrument(level = "debug", skip(self))]
1394    fn lower_generic_arg(
1395        &mut self,
1396        arg: &ast::GenericArg,
1397        itctx: ImplTraitContext,
1398    ) -> hir::GenericArg<'hir> {
1399        match arg {
1400            ast::GenericArg::Lifetime(lt) => GenericArg::Lifetime(self.lower_lifetime(
1401                lt,
1402                LifetimeSource::Path { angle_brackets: hir::AngleBrackets::Full },
1403                lt.ident.into(),
1404            )),
1405            ast::GenericArg::Type(ty) => {
1406                // We cannot just match on `TyKind::Infer` as `(_)` is represented as
1407                // `TyKind::Paren(TyKind::Infer)` and should also be lowered to `GenericArg::Infer`
1408                if ty.is_maybe_parenthesised_infer() {
1409                    return GenericArg::Infer(hir::InferArg {
1410                        hir_id: self.lower_node_id(ty.id),
1411                        span: self.lower_span(ty.span),
1412                    });
1413                }
1414
1415                match &ty.kind {
1416                    // We parse const arguments as path types as we cannot distinguish them during
1417                    // parsing. We try to resolve that ambiguity by attempting resolution in both the
1418                    // type and value namespaces. If we resolved the path in the value namespace, we
1419                    // transform it into a generic const argument.
1420                    //
1421                    // FIXME: Should we be handling `(PATH_TO_CONST)`?
1422                    TyKind::Path(None, path) => {
1423                        if let Some(res) = self
1424                            .get_partial_res(ty.id)
1425                            .and_then(|partial_res| partial_res.full_res())
1426                        {
1427                            if !res.matches_ns(Namespace::TypeNS)
1428                                && path.is_potential_trivial_const_arg()
1429                            {
1430                                debug!(
1431                                    "lower_generic_arg: Lowering type argument as const argument: {:?}",
1432                                    ty,
1433                                );
1434
1435                                let ct =
1436                                    self.lower_const_path_to_const_arg(path, res, ty.id, ty.span);
1437                                return GenericArg::Const(ct.try_as_ambig_ct().unwrap());
1438                            }
1439                        }
1440                    }
1441                    _ => {}
1442                }
1443                GenericArg::Type(self.lower_ty_alloc(ty, itctx).try_as_ambig_ty().unwrap())
1444            }
1445            ast::GenericArg::Const(ct) => {
1446                let ct = self.lower_anon_const_to_const_arg_and_alloc(ct);
1447                match ct.try_as_ambig_ct() {
1448                    Some(ct) => GenericArg::Const(ct),
1449                    None => GenericArg::Infer(hir::InferArg { hir_id: ct.hir_id, span: ct.span }),
1450                }
1451            }
1452        }
1453    }
1454
1455    #[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_ty_alloc",
                                    "rustc_ast_lowering", ::tracing::Level::DEBUG,
                                    ::tracing_core::__macro_support::Option::Some("compiler/rustc_ast_lowering/src/lib.rs"),
                                    ::tracing_core::__macro_support::Option::Some(1455u32),
                                    ::tracing_core::__macro_support::Option::Some("rustc_ast_lowering"),
                                    ::tracing_core::field::FieldSet::new(&["t", "itctx"],
                                        ::tracing_core::callsite::Identifier(&__CALLSITE)),
                                    ::tracing::metadata::Kind::SPAN)
                            };
                        ::tracing::callsite::DefaultCallsite::new(&META)
                    };
                let mut interest = ::tracing::subscriber::Interest::never();
                if ::tracing::Level::DEBUG <=
                                    ::tracing::level_filters::STATIC_MAX_LEVEL &&
                                ::tracing::Level::DEBUG <=
                                    ::tracing::level_filters::LevelFilter::current() &&
                            { interest = __CALLSITE.interest(); !interest.is_never() }
                        &&
                        ::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
                            interest) {
                    let meta = __CALLSITE.metadata();
                    ::tracing::Span::new(meta,
                        &{
                                #[allow(unused_imports)]
                                use ::tracing::field::{debug, display, Value};
                                let mut iter = meta.fields().iter();
                                meta.fields().value_set(&[(&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
                                                    ::tracing::__macro_support::Option::Some(&::tracing::field::debug(&t)
                                                            as &dyn Value)),
                                                (&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
                                                    ::tracing::__macro_support::Option::Some(&::tracing::field::debug(&itctx)
                                                            as &dyn Value))])
                            })
                } else {
                    let span =
                        ::tracing::__macro_support::__disabled_span(__CALLSITE.metadata());
                    {};
                    span
                }
            };
        __tracing_attr_guard = __tracing_attr_span.enter();
    }

    #[warn(clippy :: suspicious_else_formatting)]
    {

        #[allow(unknown_lints, unreachable_code, clippy ::
        diverging_sub_expression, clippy :: empty_loop, clippy ::
        let_unit_value, clippy :: let_with_type_underscore, clippy ::
        needless_return, clippy :: unreachable)]
        if false {
            let __tracing_attr_fake_return: &'hir hir::Ty<'hir> = loop {};
            return __tracing_attr_fake_return;
        }
        { self.arena.alloc(self.lower_ty(t, itctx)) }
    }
}#[instrument(level = "debug", skip(self))]
1456    fn lower_ty_alloc(&mut self, t: &Ty, itctx: ImplTraitContext) -> &'hir hir::Ty<'hir> {
1457        self.arena.alloc(self.lower_ty(t, itctx))
1458    }
1459
1460    fn lower_path_ty(
1461        &mut self,
1462        t: &Ty,
1463        qself: &Option<Box<QSelf>>,
1464        path: &Path,
1465        param_mode: ParamMode,
1466        itctx: ImplTraitContext,
1467    ) -> hir::Ty<'hir> {
1468        // Check whether we should interpret this as a bare trait object.
1469        // This check mirrors the one in late resolution. We only introduce this special case in
1470        // the rare occurrence we need to lower `Fresh` anonymous lifetimes.
1471        // The other cases when a qpath should be opportunistically made a trait object are handled
1472        // by `ty_path`.
1473        if qself.is_none()
1474            && let Some(partial_res) = self.get_partial_res(t.id)
1475            && let Some(Res::Def(DefKind::Trait | DefKind::TraitAlias, _)) = partial_res.full_res()
1476        {
1477            let (bounds, lifetime_bound) = self.with_dyn_type_scope(true, |this| {
1478                let bound = this.lower_poly_trait_ref(
1479                    &PolyTraitRef {
1480                        bound_generic_params: ThinVec::new(),
1481                        modifiers: TraitBoundModifiers::NONE,
1482                        trait_ref: TraitRef { path: path.clone(), ref_id: t.id },
1483                        span: t.span,
1484                        parens: ast::Parens::No,
1485                    },
1486                    RelaxedBoundPolicy::Forbidden(RelaxedBoundForbiddenReason::TraitObjectTy),
1487                    itctx,
1488                );
1489                let bounds = this.arena.alloc_from_iter([bound]);
1490                let lifetime_bound = this.elided_dyn_bound(t.span);
1491                (bounds, lifetime_bound)
1492            });
1493            let kind = hir::TyKind::TraitObject(
1494                bounds,
1495                TaggedRef::new(lifetime_bound, TraitObjectSyntax::None),
1496            );
1497            return hir::Ty { kind, span: self.lower_span(t.span), hir_id: self.next_id() };
1498        }
1499
1500        let id = self.lower_node_id(t.id);
1501        let qpath = self.lower_qpath(
1502            t.id,
1503            qself,
1504            path,
1505            param_mode,
1506            AllowReturnTypeNotation::Yes,
1507            itctx,
1508            None,
1509        );
1510        self.ty_path(id, t.span, qpath)
1511    }
1512
1513    fn ty(&mut self, span: Span, kind: hir::TyKind<'hir>) -> hir::Ty<'hir> {
1514        hir::Ty { hir_id: self.next_id(), kind, span: self.lower_span(span) }
1515    }
1516
1517    fn ty_tup(&mut self, span: Span, tys: &'hir [hir::Ty<'hir>]) -> hir::Ty<'hir> {
1518        self.ty(span, hir::TyKind::Tup(tys))
1519    }
1520
1521    fn lower_ty(&mut self, t: &Ty, itctx: ImplTraitContext) -> hir::Ty<'hir> {
1522        let kind = match &t.kind {
1523            TyKind::Infer => hir::TyKind::Infer(()),
1524            TyKind::Err(guar) => hir::TyKind::Err(*guar),
1525            TyKind::Slice(ty) => hir::TyKind::Slice(self.lower_ty_alloc(ty, itctx)),
1526            TyKind::Ptr(mt) => hir::TyKind::Ptr(self.lower_mt(mt, itctx)),
1527            TyKind::Ref(region, mt) => {
1528                let lifetime = self.lower_ty_direct_lifetime(t, *region);
1529                hir::TyKind::Ref(lifetime, self.lower_mt(mt, itctx))
1530            }
1531            TyKind::PinnedRef(region, mt) => {
1532                let lifetime = self.lower_ty_direct_lifetime(t, *region);
1533                let kind = hir::TyKind::Ref(lifetime, self.lower_mt(mt, itctx));
1534                let span = self.lower_span(t.span);
1535                let arg = hir::Ty { kind, span, hir_id: self.next_id() };
1536                let args = self.arena.alloc(hir::GenericArgs {
1537                    args: self.arena.alloc([hir::GenericArg::Type(self.arena.alloc(arg))]),
1538                    constraints: &[],
1539                    parenthesized: hir::GenericArgsParentheses::No,
1540                    span_ext: span,
1541                });
1542                let path = self.make_lang_item_qpath(hir::LangItem::Pin, span, Some(args));
1543                hir::TyKind::Path(path)
1544            }
1545            TyKind::FnPtr(f) => {
1546                let generic_params = self.lower_lifetime_binder(t.id, &f.generic_params);
1547                hir::TyKind::FnPtr(self.arena.alloc(hir::FnPtrTy {
1548                    generic_params,
1549                    safety: self.lower_safety(f.safety, hir::Safety::Safe),
1550                    abi: self.lower_extern(f.ext),
1551                    decl: self.lower_fn_decl(&f.decl, t.id, t.span, FnDeclKind::Pointer, None),
1552                    param_idents: self.lower_fn_params_to_idents(&f.decl),
1553                }))
1554            }
1555            TyKind::UnsafeBinder(f) => {
1556                let generic_params = self.lower_lifetime_binder(t.id, &f.generic_params);
1557                hir::TyKind::UnsafeBinder(self.arena.alloc(hir::UnsafeBinderTy {
1558                    generic_params,
1559                    inner_ty: self.lower_ty_alloc(&f.inner_ty, itctx),
1560                }))
1561            }
1562            TyKind::Never => hir::TyKind::Never,
1563            TyKind::Tup(tys) => hir::TyKind::Tup(
1564                self.arena.alloc_from_iter(tys.iter().map(|ty| self.lower_ty(ty, itctx))),
1565            ),
1566            TyKind::Paren(ty) => {
1567                return self.lower_ty(ty, itctx);
1568            }
1569            TyKind::Path(qself, path) => {
1570                return self.lower_path_ty(t, qself, path, ParamMode::Explicit, itctx);
1571            }
1572            TyKind::ImplicitSelf => {
1573                let hir_id = self.next_id();
1574                let res = self.expect_full_res(t.id);
1575                let res = self.lower_res(res);
1576                hir::TyKind::Path(hir::QPath::Resolved(
1577                    None,
1578                    self.arena.alloc(hir::Path {
1579                        res,
1580                        segments: self.arena.alloc_from_iter([hir::PathSegment::new(Ident::with_dummy_span(kw::SelfUpper),
                hir_id, res)])arena_vec![self; hir::PathSegment::new(
1581                            Ident::with_dummy_span(kw::SelfUpper),
1582                            hir_id,
1583                            res
1584                        )],
1585                        span: self.lower_span(t.span),
1586                    }),
1587                ))
1588            }
1589            TyKind::Array(ty, length) => hir::TyKind::Array(
1590                self.lower_ty_alloc(ty, itctx),
1591                self.lower_array_length_to_const_arg(length),
1592            ),
1593            TyKind::TraitObject(bounds, kind) => {
1594                let mut lifetime_bound = None;
1595                let (bounds, lifetime_bound) = self.with_dyn_type_scope(true, |this| {
1596                    let bounds =
1597                        this.arena.alloc_from_iter(bounds.iter().filter_map(|bound| match bound {
1598                            // We can safely ignore constness here since AST validation
1599                            // takes care of rejecting invalid modifier combinations and
1600                            // const trait bounds in trait object types.
1601                            GenericBound::Trait(ty) => {
1602                                let trait_ref = this.lower_poly_trait_ref(
1603                                    ty,
1604                                    RelaxedBoundPolicy::Forbidden(
1605                                        RelaxedBoundForbiddenReason::TraitObjectTy,
1606                                    ),
1607                                    itctx,
1608                                );
1609                                Some(trait_ref)
1610                            }
1611                            GenericBound::Outlives(lifetime) => {
1612                                if lifetime_bound.is_none() {
1613                                    lifetime_bound = Some(this.lower_lifetime(
1614                                        lifetime,
1615                                        LifetimeSource::Other,
1616                                        lifetime.ident.into(),
1617                                    ));
1618                                }
1619                                None
1620                            }
1621                            // Ignore `use` syntax since that is not valid in objects.
1622                            GenericBound::Use(_, span) => {
1623                                this.dcx()
1624                                    .span_delayed_bug(*span, "use<> not allowed in dyn types");
1625                                None
1626                            }
1627                        }));
1628                    let lifetime_bound =
1629                        lifetime_bound.unwrap_or_else(|| this.elided_dyn_bound(t.span));
1630                    (bounds, lifetime_bound)
1631                });
1632                hir::TyKind::TraitObject(bounds, TaggedRef::new(lifetime_bound, *kind))
1633            }
1634            TyKind::ImplTrait(def_node_id, bounds) => {
1635                let span = t.span;
1636                match itctx {
1637                    ImplTraitContext::OpaqueTy { origin } => {
1638                        self.lower_opaque_impl_trait(span, origin, *def_node_id, bounds, itctx)
1639                    }
1640                    ImplTraitContext::Universal => {
1641                        if let Some(span) = bounds.iter().find_map(|bound| match *bound {
1642                            ast::GenericBound::Use(_, span) => Some(span),
1643                            _ => None,
1644                        }) {
1645                            self.tcx.dcx().emit_err(diagnostics::NoPreciseCapturesOnApit { span });
1646                        }
1647
1648                        let def_id = self.local_def_id(*def_node_id);
1649                        let name = self.tcx.item_name(def_id.to_def_id());
1650                        let ident = Ident::new(name, span);
1651                        let (param, bounds, path) = self.lower_universal_param_and_bounds(
1652                            *def_node_id,
1653                            span,
1654                            ident,
1655                            bounds,
1656                        );
1657                        self.impl_trait_defs.push(param);
1658                        if let Some(bounds) = bounds {
1659                            self.impl_trait_bounds.push(bounds);
1660                        }
1661                        path
1662                    }
1663                    ImplTraitContext::InBinding => {
1664                        hir::TyKind::TraitAscription(self.lower_param_bounds(
1665                            bounds,
1666                            RelaxedBoundPolicy::Allowed(&mut Default::default()),
1667                            itctx,
1668                        ))
1669                    }
1670                    ImplTraitContext::FeatureGated(position, feature) => {
1671                        let guar = self
1672                            .tcx
1673                            .sess
1674                            .create_feature_err(
1675                                MisplacedImplTrait {
1676                                    span: t.span,
1677                                    position: DiagArgFromDisplay(&position),
1678                                },
1679                                feature,
1680                            )
1681                            .emit();
1682                        hir::TyKind::Err(guar)
1683                    }
1684                    ImplTraitContext::Disallowed(position) => {
1685                        let guar = self.dcx().emit_err(MisplacedImplTrait {
1686                            span: t.span,
1687                            position: DiagArgFromDisplay(&position),
1688                        });
1689                        hir::TyKind::Err(guar)
1690                    }
1691                }
1692            }
1693            TyKind::Pat(ty, pat) => {
1694                hir::TyKind::Pat(self.lower_ty_alloc(ty, itctx), self.lower_ty_pat(pat, ty.span))
1695            }
1696            TyKind::FieldOf(ty, variant, field) => hir::TyKind::FieldOf(
1697                self.lower_ty_alloc(ty, itctx),
1698                self.arena.alloc(hir::TyFieldPath {
1699                    variant: variant.map(|variant| self.lower_ident(variant)),
1700                    field: self.lower_ident(*field),
1701                }),
1702            ),
1703            TyKind::MacCall(_) => {
1704                ::rustc_middle::util::bug::span_bug_fmt(t.span,
    format_args!("`TyKind::MacCall` should have been expanded by now"))span_bug!(t.span, "`TyKind::MacCall` should have been expanded by now")
1705            }
1706            TyKind::CVarArgs => {
1707                let guar = self.dcx().span_delayed_bug(
1708                    t.span,
1709                    "`TyKind::CVarArgs` should have been handled elsewhere",
1710                );
1711                hir::TyKind::Err(guar)
1712            }
1713            TyKind::Dummy => {
    ::core::panicking::panic_fmt(format_args!("`TyKind::Dummy` should never be lowered"));
}panic!("`TyKind::Dummy` should never be lowered"),
1714        };
1715
1716        hir::Ty { kind, span: self.lower_span(t.span), hir_id: self.lower_node_id(t.id) }
1717    }
1718
1719    fn lower_ty_direct_lifetime(
1720        &mut self,
1721        t: &Ty,
1722        region: Option<Lifetime>,
1723    ) -> &'hir hir::Lifetime {
1724        let (region, syntax) = match region {
1725            Some(region) => (region, region.ident.into()),
1726
1727            None => {
1728                let id = if let Some(LifetimeRes::ElidedAnchor { start, end }) =
1729                    self.owner.get_lifetime_res(t.id)
1730                {
1731                    {
    match (&start.plus(1), &end) {
        (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!(start.plus(1), end);
1732                    start
1733                } else {
1734                    self.next_node_id()
1735                };
1736                let span = self.tcx.sess.source_map().start_point(t.span).shrink_to_hi();
1737                let region = Lifetime { ident: Ident::new(kw::UnderscoreLifetime, span), id };
1738                (region, LifetimeSyntax::Implicit)
1739            }
1740        };
1741        self.lower_lifetime(&region, LifetimeSource::Reference, syntax)
1742    }
1743
1744    /// Lowers a `ReturnPositionOpaqueTy` (`-> impl Trait`) or a `TypeAliasesOpaqueTy` (`type F =
1745    /// impl Trait`): this creates the associated Opaque Type (TAIT) definition and then returns a
1746    /// HIR type that references the TAIT.
1747    ///
1748    /// Given a function definition like:
1749    ///
1750    /// ```rust
1751    /// use std::fmt::Debug;
1752    ///
1753    /// fn test<'a, T: Debug>(x: &'a T) -> impl Debug + 'a {
1754    ///     x
1755    /// }
1756    /// ```
1757    ///
1758    /// we will create a TAIT definition in the HIR like
1759    ///
1760    /// ```rust,ignore (pseudo-Rust)
1761    /// type TestReturn<'a, T, 'x> = impl Debug + 'x
1762    /// ```
1763    ///
1764    /// and return a type like `TestReturn<'static, T, 'a>`, so that the function looks like:
1765    ///
1766    /// ```rust,ignore (pseudo-Rust)
1767    /// fn test<'a, T: Debug>(x: &'a T) -> TestReturn<'static, T, 'a>
1768    /// ```
1769    ///
1770    /// Note the subtlety around type parameters! The new TAIT, `TestReturn`, inherits all the
1771    /// type parameters from the function `test` (this is implemented in the query layer, they aren't
1772    /// added explicitly in the HIR). But this includes all the lifetimes, and we only want to
1773    /// capture the lifetimes that are referenced in the bounds. Therefore, we add *extra* lifetime parameters
1774    /// for the lifetimes that get captured (`'x`, in our example above) and reference those.
1775    x;#[instrument(level = "debug", skip(self), ret)]
1776    fn lower_opaque_impl_trait(
1777        &mut self,
1778        span: Span,
1779        origin: hir::OpaqueTyOrigin<LocalDefId>,
1780        opaque_ty_node_id: NodeId,
1781        bounds: &GenericBounds,
1782        itctx: ImplTraitContext,
1783    ) -> hir::TyKind<'hir> {
1784        // Make sure we know that some funky desugaring has been going on here.
1785        // This is a first: there is code in other places like for loop
1786        // desugaring that explicitly states that we don't want to track that.
1787        // Not tracking it makes lints in rustc and clippy very fragile, as
1788        // frequently opened issues show.
1789        let opaque_ty_span = self.mark_span_with_reason(DesugaringKind::OpaqueTy, span, None);
1790
1791        self.lower_opaque_inner(opaque_ty_node_id, origin, opaque_ty_span, |this| {
1792            this.lower_param_bounds(
1793                bounds,
1794                RelaxedBoundPolicy::Allowed(&mut Default::default()),
1795                itctx,
1796            )
1797        })
1798    }
1799
1800    fn lower_opaque_inner(
1801        &mut self,
1802        opaque_ty_node_id: NodeId,
1803        origin: hir::OpaqueTyOrigin<LocalDefId>,
1804        opaque_ty_span: Span,
1805        lower_item_bounds: impl FnOnce(&mut Self) -> &'hir [hir::GenericBound<'hir>],
1806    ) -> hir::TyKind<'hir> {
1807        let opaque_ty_def_id = self.local_def_id(opaque_ty_node_id);
1808        let opaque_ty_hir_id = self.lower_node_id(opaque_ty_node_id);
1809        {
    use ::tracing::__macro_support::Callsite as _;
    static __CALLSITE: ::tracing::callsite::DefaultCallsite =
        {
            static META: ::tracing::Metadata<'static> =
                {
                    ::tracing_core::metadata::Metadata::new("event compiler/rustc_ast_lowering/src/lib.rs:1809",
                        "rustc_ast_lowering", ::tracing::Level::DEBUG,
                        ::tracing_core::__macro_support::Option::Some("compiler/rustc_ast_lowering/src/lib.rs"),
                        ::tracing_core::__macro_support::Option::Some(1809u32),
                        ::tracing_core::__macro_support::Option::Some("rustc_ast_lowering"),
                        ::tracing_core::field::FieldSet::new(&["opaque_ty_def_id",
                                        "opaque_ty_hir_id"],
                            ::tracing_core::callsite::Identifier(&__CALLSITE)),
                        ::tracing::metadata::Kind::EVENT)
                };
            ::tracing::callsite::DefaultCallsite::new(&META)
        };
    let enabled =
        ::tracing::Level::DEBUG <= ::tracing::level_filters::STATIC_MAX_LEVEL
                &&
                ::tracing::Level::DEBUG <=
                    ::tracing::level_filters::LevelFilter::current() &&
            {
                let interest = __CALLSITE.interest();
                !interest.is_never() &&
                    ::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
                        interest)
            };
    if enabled {
        (|value_set: ::tracing::field::ValueSet|
                    {
                        let meta = __CALLSITE.metadata();
                        ::tracing::Event::dispatch(meta, &value_set);
                        ;
                    })({
                #[allow(unused_imports)]
                use ::tracing::field::{debug, display, Value};
                let mut iter = __CALLSITE.metadata().fields().iter();
                __CALLSITE.metadata().fields().value_set(&[(&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
                                    ::tracing::__macro_support::Option::Some(&debug(&opaque_ty_def_id)
                                            as &dyn Value)),
                                (&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
                                    ::tracing::__macro_support::Option::Some(&debug(&opaque_ty_hir_id)
                                            as &dyn Value))])
            });
    } else { ; }
};debug!(?opaque_ty_def_id, ?opaque_ty_hir_id);
1810
1811        let bounds = lower_item_bounds(self);
1812        let opaque_ty_def = hir::OpaqueTy {
1813            hir_id: opaque_ty_hir_id,
1814            def_id: opaque_ty_def_id,
1815            bounds,
1816            origin,
1817            span: self.lower_span(opaque_ty_span),
1818        };
1819        let opaque_ty_def = self.arena.alloc(opaque_ty_def);
1820
1821        hir::TyKind::OpaqueDef(opaque_ty_def)
1822    }
1823
1824    fn lower_precise_capturing_args(
1825        &mut self,
1826        precise_capturing_args: &[PreciseCapturingArg],
1827    ) -> &'hir [hir::PreciseCapturingArg<'hir>] {
1828        self.arena.alloc_from_iter(precise_capturing_args.iter().map(|arg| match arg {
1829            PreciseCapturingArg::Lifetime(lt) => hir::PreciseCapturingArg::Lifetime(
1830                self.lower_lifetime(lt, LifetimeSource::PreciseCapturing, lt.ident.into()),
1831            ),
1832            PreciseCapturingArg::Arg(path, id) => {
1833                let [segment] = path.segments.as_slice() else {
1834                    ::core::panicking::panic("explicit panic");panic!();
1835                };
1836                let res = self.get_partial_res(*id).map_or(Res::Err, |partial_res| {
1837                    partial_res.full_res().expect("no partial res expected for precise capture arg")
1838                });
1839                hir::PreciseCapturingArg::Param(hir::PreciseCapturingNonLifetimeArg {
1840                    hir_id: self.lower_node_id(*id),
1841                    ident: self.lower_ident(segment.ident),
1842                    res: self.lower_res(res),
1843                })
1844            }
1845        }))
1846    }
1847
1848    fn lower_fn_params_to_idents(&mut self, decl: &FnDecl) -> &'hir [Option<Ident>] {
1849        self.arena.alloc_from_iter(decl.inputs.iter().map(|param| match param.pat.kind {
1850            PatKind::Missing => None,
1851            PatKind::Ident(_, ident, _) => Some(self.lower_ident(ident)),
1852            PatKind::Wild => Some(Ident::new(kw::Underscore, self.lower_span(param.pat.span))),
1853            _ => {
1854                self.dcx().span_delayed_bug(
1855                    param.pat.span,
1856                    "non-missing/ident/wild param pat must trigger an error",
1857                );
1858                None
1859            }
1860        }))
1861    }
1862
1863    /// Lowers a function declaration.
1864    ///
1865    /// `decl`: the unlowered (AST) function declaration.
1866    ///
1867    /// `fn_node_id`: `impl Trait` arguments are lowered into generic parameters on the given
1868    /// `NodeId`.
1869    ///
1870    /// `transform_return_type`: if `Some`, applies some conversion to the return type, such as is
1871    /// needed for `async fn` and `gen fn`. See [`CoroutineKind`] for more details.
1872    #[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_fn_decl",
                                    "rustc_ast_lowering", ::tracing::Level::DEBUG,
                                    ::tracing_core::__macro_support::Option::Some("compiler/rustc_ast_lowering/src/lib.rs"),
                                    ::tracing_core::__macro_support::Option::Some(1872u32),
                                    ::tracing_core::__macro_support::Option::Some("rustc_ast_lowering"),
                                    ::tracing_core::field::FieldSet::new(&["decl", "fn_node_id",
                                                    "fn_span", "kind", "coro"],
                                        ::tracing_core::callsite::Identifier(&__CALLSITE)),
                                    ::tracing::metadata::Kind::SPAN)
                            };
                        ::tracing::callsite::DefaultCallsite::new(&META)
                    };
                let mut interest = ::tracing::subscriber::Interest::never();
                if ::tracing::Level::DEBUG <=
                                    ::tracing::level_filters::STATIC_MAX_LEVEL &&
                                ::tracing::Level::DEBUG <=
                                    ::tracing::level_filters::LevelFilter::current() &&
                            { interest = __CALLSITE.interest(); !interest.is_never() }
                        &&
                        ::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
                            interest) {
                    let meta = __CALLSITE.metadata();
                    ::tracing::Span::new(meta,
                        &{
                                #[allow(unused_imports)]
                                use ::tracing::field::{debug, display, Value};
                                let mut iter = meta.fields().iter();
                                meta.fields().value_set(&[(&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
                                                    ::tracing::__macro_support::Option::Some(&::tracing::field::debug(&decl)
                                                            as &dyn Value)),
                                                (&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
                                                    ::tracing::__macro_support::Option::Some(&::tracing::field::debug(&fn_node_id)
                                                            as &dyn Value)),
                                                (&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
                                                    ::tracing::__macro_support::Option::Some(&::tracing::field::debug(&fn_span)
                                                            as &dyn Value)),
                                                (&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
                                                    ::tracing::__macro_support::Option::Some(&::tracing::field::debug(&kind)
                                                            as &dyn Value)),
                                                (&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
                                                    ::tracing::__macro_support::Option::Some(&::tracing::field::debug(&coro)
                                                            as &dyn Value))])
                            })
                } else {
                    let span =
                        ::tracing::__macro_support::__disabled_span(__CALLSITE.metadata());
                    {};
                    span
                }
            };
        __tracing_attr_guard = __tracing_attr_span.enter();
    }

    #[warn(clippy :: suspicious_else_formatting)]
    {

        #[allow(unknown_lints, unreachable_code, clippy ::
        diverging_sub_expression, clippy :: empty_loop, clippy ::
        let_unit_value, clippy :: let_with_type_underscore, clippy ::
        needless_return, clippy :: unreachable)]
        if false {
            let __tracing_attr_fake_return: &'hir hir::FnDecl<'hir> = loop {};
            return __tracing_attr_fake_return;
        }
        {
            let c_variadic = decl.c_variadic();
            let mut splatted = decl.splatted();
            let mut inputs = &decl.inputs[..];
            if decl.c_variadic() {
                splatted = None;
                inputs = &inputs[..inputs.len() - 1];
            }
            let inputs =
                self.arena.alloc_from_iter(inputs.iter().map(|param|
                            {
                                let itctx =
                                    match kind {
                                        FnDeclKind::Fn | FnDeclKind::Inherent | FnDeclKind::Impl |
                                            FnDeclKind::Trait => {
                                            ImplTraitContext::Universal
                                        }
                                        FnDeclKind::ExternFn => {
                                            ImplTraitContext::Disallowed(ImplTraitPosition::ExternFnParam)
                                        }
                                        FnDeclKind::Closure => {
                                            ImplTraitContext::Disallowed(ImplTraitPosition::ClosureParam)
                                        }
                                        FnDeclKind::Pointer => {
                                            ImplTraitContext::Disallowed(ImplTraitPosition::PointerParam)
                                        }
                                    };
                                self.lower_ty(&param.ty, itctx)
                            }));
            let output =
                match coro {
                    Some(coro) => {
                        let fn_def_id = self.owner.def_id;
                        self.lower_coroutine_fn_ret_ty(&decl.output, fn_def_id,
                            coro, kind)
                    }
                    None =>
                        match &decl.output {
                            FnRetTy::Ty(ty) => {
                                let itctx =
                                    match kind {
                                        FnDeclKind::Fn | FnDeclKind::Inherent =>
                                            ImplTraitContext::OpaqueTy {
                                                origin: hir::OpaqueTyOrigin::FnReturn {
                                                    parent: self.owner.def_id,
                                                    in_trait_or_impl: None,
                                                },
                                            },
                                        FnDeclKind::Trait =>
                                            ImplTraitContext::OpaqueTy {
                                                origin: hir::OpaqueTyOrigin::FnReturn {
                                                    parent: self.owner.def_id,
                                                    in_trait_or_impl: Some(hir::RpitContext::Trait),
                                                },
                                            },
                                        FnDeclKind::Impl =>
                                            ImplTraitContext::OpaqueTy {
                                                origin: hir::OpaqueTyOrigin::FnReturn {
                                                    parent: self.owner.def_id,
                                                    in_trait_or_impl: Some(hir::RpitContext::TraitImpl),
                                                },
                                            },
                                        FnDeclKind::ExternFn => {
                                            ImplTraitContext::Disallowed(ImplTraitPosition::ExternFnReturn)
                                        }
                                        FnDeclKind::Closure => {
                                            ImplTraitContext::Disallowed(ImplTraitPosition::ClosureReturn)
                                        }
                                        FnDeclKind::Pointer => {
                                            ImplTraitContext::Disallowed(ImplTraitPosition::PointerReturn)
                                        }
                                    };
                                hir::FnRetTy::Return(self.lower_ty_alloc(ty, itctx))
                            }
                            FnRetTy::Default(span) =>
                                hir::FnRetTy::DefaultReturn(self.lower_span(*span)),
                        },
                };
            let fn_decl_kind =
                hir::FnDeclFlags::default().set_implicit_self(decl.inputs.get(0).map_or(hir::ImplicitSelfKind::None,
                                        |arg|
                                            {
                                                let is_mutable_pat =
                                                    #[allow(non_exhaustive_omitted_patterns)] match arg.pat.kind
                                                        {
                                                        PatKind::Ident(hir::BindingMode(_, Mutability::Mut), ..) =>
                                                            true,
                                                        _ => false,
                                                    };
                                                match &arg.ty.kind {
                                                    TyKind::ImplicitSelf if is_mutable_pat =>
                                                        hir::ImplicitSelfKind::Mut,
                                                    TyKind::ImplicitSelf => hir::ImplicitSelfKind::Imm,
                                                    TyKind::Ref(_, mt) | TyKind::PinnedRef(_, mt) if
                                                        mt.ty.kind.is_implicit_self() => {
                                                        match mt.mutbl {
                                                            hir::Mutability::Not => hir::ImplicitSelfKind::RefImm,
                                                            hir::Mutability::Mut => hir::ImplicitSelfKind::RefMut,
                                                        }
                                                    }
                                                    _ => hir::ImplicitSelfKind::None,
                                                }
                                            })).set_lifetime_elision_allowed(self.owner.id == fn_node_id
                                    &&
                                    self.owner.lifetime_elision_allowed).set_c_variadic(c_variadic).set_splatted(splatted,
                        inputs.len()).unwrap();
            self.arena.alloc(hir::FnDecl { inputs, output, fn_decl_kind })
        }
    }
}#[instrument(level = "debug", skip(self))]
1873    fn lower_fn_decl(
1874        &mut self,
1875        decl: &FnDecl,
1876        fn_node_id: NodeId,
1877        fn_span: Span,
1878        kind: FnDeclKind,
1879        coro: Option<CoroutineKind>,
1880    ) -> &'hir hir::FnDecl<'hir> {
1881        let c_variadic = decl.c_variadic();
1882        let mut splatted = decl.splatted();
1883
1884        // Skip the `...` (`CVarArgs`) trailing arguments from the AST,
1885        // as they are not explicit in HIR/Ty function signatures.
1886        // (instead, the `c_variadic` flag is set to `true`)
1887        let mut inputs = &decl.inputs[..];
1888        if decl.c_variadic() {
1889            // Splat + variadic errors in AST validation, so just ignore one of them here.
1890            splatted = None;
1891            inputs = &inputs[..inputs.len() - 1];
1892        }
1893        let inputs = self.arena.alloc_from_iter(inputs.iter().map(|param| {
1894            let itctx = match kind {
1895                FnDeclKind::Fn | FnDeclKind::Inherent | FnDeclKind::Impl | FnDeclKind::Trait => {
1896                    ImplTraitContext::Universal
1897                }
1898                FnDeclKind::ExternFn => {
1899                    ImplTraitContext::Disallowed(ImplTraitPosition::ExternFnParam)
1900                }
1901                FnDeclKind::Closure => {
1902                    ImplTraitContext::Disallowed(ImplTraitPosition::ClosureParam)
1903                }
1904                FnDeclKind::Pointer => {
1905                    ImplTraitContext::Disallowed(ImplTraitPosition::PointerParam)
1906                }
1907            };
1908            self.lower_ty(&param.ty, itctx)
1909        }));
1910
1911        let output = match coro {
1912            Some(coro) => {
1913                let fn_def_id = self.owner.def_id;
1914                self.lower_coroutine_fn_ret_ty(&decl.output, fn_def_id, coro, kind)
1915            }
1916            None => match &decl.output {
1917                FnRetTy::Ty(ty) => {
1918                    let itctx = match kind {
1919                        FnDeclKind::Fn | FnDeclKind::Inherent => ImplTraitContext::OpaqueTy {
1920                            origin: hir::OpaqueTyOrigin::FnReturn {
1921                                parent: self.owner.def_id,
1922                                in_trait_or_impl: None,
1923                            },
1924                        },
1925                        FnDeclKind::Trait => ImplTraitContext::OpaqueTy {
1926                            origin: hir::OpaqueTyOrigin::FnReturn {
1927                                parent: self.owner.def_id,
1928                                in_trait_or_impl: Some(hir::RpitContext::Trait),
1929                            },
1930                        },
1931                        FnDeclKind::Impl => ImplTraitContext::OpaqueTy {
1932                            origin: hir::OpaqueTyOrigin::FnReturn {
1933                                parent: self.owner.def_id,
1934                                in_trait_or_impl: Some(hir::RpitContext::TraitImpl),
1935                            },
1936                        },
1937                        FnDeclKind::ExternFn => {
1938                            ImplTraitContext::Disallowed(ImplTraitPosition::ExternFnReturn)
1939                        }
1940                        FnDeclKind::Closure => {
1941                            ImplTraitContext::Disallowed(ImplTraitPosition::ClosureReturn)
1942                        }
1943                        FnDeclKind::Pointer => {
1944                            ImplTraitContext::Disallowed(ImplTraitPosition::PointerReturn)
1945                        }
1946                    };
1947                    hir::FnRetTy::Return(self.lower_ty_alloc(ty, itctx))
1948                }
1949                FnRetTy::Default(span) => hir::FnRetTy::DefaultReturn(self.lower_span(*span)),
1950            },
1951        };
1952
1953        let fn_decl_kind = hir::FnDeclFlags::default()
1954            .set_implicit_self(decl.inputs.get(0).map_or(hir::ImplicitSelfKind::None, |arg| {
1955                let is_mutable_pat = matches!(
1956                    arg.pat.kind,
1957                    PatKind::Ident(hir::BindingMode(_, Mutability::Mut), ..)
1958                );
1959
1960                match &arg.ty.kind {
1961                    TyKind::ImplicitSelf if is_mutable_pat => hir::ImplicitSelfKind::Mut,
1962                    TyKind::ImplicitSelf => hir::ImplicitSelfKind::Imm,
1963                    // Given we are only considering `ImplicitSelf` types, we needn't consider
1964                    // the case where we have a mutable pattern to a reference as that would
1965                    // no longer be an `ImplicitSelf`.
1966                    TyKind::Ref(_, mt) | TyKind::PinnedRef(_, mt)
1967                        if mt.ty.kind.is_implicit_self() =>
1968                    {
1969                        match mt.mutbl {
1970                            hir::Mutability::Not => hir::ImplicitSelfKind::RefImm,
1971                            hir::Mutability::Mut => hir::ImplicitSelfKind::RefMut,
1972                        }
1973                    }
1974                    _ => hir::ImplicitSelfKind::None,
1975                }
1976            }))
1977            .set_lifetime_elision_allowed(
1978                self.owner.id == fn_node_id && self.owner.lifetime_elision_allowed,
1979            )
1980            .set_c_variadic(c_variadic)
1981            .set_splatted(splatted, inputs.len())
1982            .unwrap();
1983
1984        self.arena.alloc(hir::FnDecl { inputs, output, fn_decl_kind })
1985    }
1986
1987    // Transforms `-> T` for `async fn` into `-> OpaqueTy { .. }`
1988    // combined with the following definition of `OpaqueTy`:
1989    //
1990    //     type OpaqueTy<generics_from_parent_fn> = impl Future<Output = T>;
1991    //
1992    // `output`: unlowered output type (`T` in `-> T`)
1993    // `fn_node_id`: `NodeId` of the parent function (used to create child impl trait definition)
1994    // `opaque_ty_node_id`: `NodeId` of the opaque `impl Trait` type that should be created
1995    #[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_coroutine_fn_ret_ty",
                                    "rustc_ast_lowering", ::tracing::Level::DEBUG,
                                    ::tracing_core::__macro_support::Option::Some("compiler/rustc_ast_lowering/src/lib.rs"),
                                    ::tracing_core::__macro_support::Option::Some(1995u32),
                                    ::tracing_core::__macro_support::Option::Some("rustc_ast_lowering"),
                                    ::tracing_core::field::FieldSet::new(&["output",
                                                    "fn_def_id", "coro", "fn_kind"],
                                        ::tracing_core::callsite::Identifier(&__CALLSITE)),
                                    ::tracing::metadata::Kind::SPAN)
                            };
                        ::tracing::callsite::DefaultCallsite::new(&META)
                    };
                let mut interest = ::tracing::subscriber::Interest::never();
                if ::tracing::Level::DEBUG <=
                                    ::tracing::level_filters::STATIC_MAX_LEVEL &&
                                ::tracing::Level::DEBUG <=
                                    ::tracing::level_filters::LevelFilter::current() &&
                            { interest = __CALLSITE.interest(); !interest.is_never() }
                        &&
                        ::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
                            interest) {
                    let meta = __CALLSITE.metadata();
                    ::tracing::Span::new(meta,
                        &{
                                #[allow(unused_imports)]
                                use ::tracing::field::{debug, display, Value};
                                let mut iter = meta.fields().iter();
                                meta.fields().value_set(&[(&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
                                                    ::tracing::__macro_support::Option::Some(&::tracing::field::debug(&output)
                                                            as &dyn Value)),
                                                (&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
                                                    ::tracing::__macro_support::Option::Some(&::tracing::field::debug(&fn_def_id)
                                                            as &dyn Value)),
                                                (&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
                                                    ::tracing::__macro_support::Option::Some(&::tracing::field::debug(&coro)
                                                            as &dyn Value)),
                                                (&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
                                                    ::tracing::__macro_support::Option::Some(&::tracing::field::debug(&fn_kind)
                                                            as &dyn Value))])
                            })
                } else {
                    let span =
                        ::tracing::__macro_support::__disabled_span(__CALLSITE.metadata());
                    {};
                    span
                }
            };
        __tracing_attr_guard = __tracing_attr_span.enter();
    }

    #[warn(clippy :: suspicious_else_formatting)]
    {

        #[allow(unknown_lints, unreachable_code, clippy ::
        diverging_sub_expression, clippy :: empty_loop, clippy ::
        let_unit_value, clippy :: let_with_type_underscore, clippy ::
        needless_return, clippy :: unreachable)]
        if false {
            let __tracing_attr_fake_return: hir::FnRetTy<'hir> = loop {};
            return __tracing_attr_fake_return;
        }
        {
            let span = self.lower_span(output.span());
            let (opaque_ty_node_id, allowed_features) =
                match coro {
                    CoroutineKind::Async { return_impl_trait_id, .. } =>
                        (return_impl_trait_id, None),
                    CoroutineKind::Gen { return_impl_trait_id, .. } =>
                        (return_impl_trait_id, None),
                    CoroutineKind::AsyncGen { return_impl_trait_id, .. } => {
                        (return_impl_trait_id,
                            Some(Arc::clone(&self.allow_async_iterator)))
                    }
                };
            let opaque_ty_span =
                self.mark_span_with_reason(DesugaringKind::Async, span,
                    allowed_features);
            let in_trait_or_impl =
                match fn_kind {
                    FnDeclKind::Trait => Some(hir::RpitContext::Trait),
                    FnDeclKind::Impl => Some(hir::RpitContext::TraitImpl),
                    FnDeclKind::Fn | FnDeclKind::Inherent => None,
                    FnDeclKind::ExternFn | FnDeclKind::Closure |
                        FnDeclKind::Pointer =>
                        ::core::panicking::panic("internal error: entered unreachable code"),
                };
            let opaque_ty_ref =
                self.lower_opaque_inner(opaque_ty_node_id,
                    hir::OpaqueTyOrigin::AsyncFn {
                        parent: fn_def_id,
                        in_trait_or_impl,
                    }, opaque_ty_span,
                    |this|
                        {
                            let bound =
                                this.lower_coroutine_fn_output_type_to_bound(output, coro,
                                    opaque_ty_span,
                                    ImplTraitContext::OpaqueTy {
                                        origin: hir::OpaqueTyOrigin::FnReturn {
                                            parent: fn_def_id,
                                            in_trait_or_impl,
                                        },
                                    });
                            this.arena.alloc_from_iter([bound])
                        });
            let opaque_ty = self.ty(opaque_ty_span, opaque_ty_ref);
            hir::FnRetTy::Return(self.arena.alloc(opaque_ty))
        }
    }
}#[instrument(level = "debug", skip(self))]
1996    fn lower_coroutine_fn_ret_ty(
1997        &mut self,
1998        output: &FnRetTy,
1999        fn_def_id: LocalDefId,
2000        coro: CoroutineKind,
2001        fn_kind: FnDeclKind,
2002    ) -> hir::FnRetTy<'hir> {
2003        let span = self.lower_span(output.span());
2004
2005        let (opaque_ty_node_id, allowed_features) = match coro {
2006            CoroutineKind::Async { return_impl_trait_id, .. } => (return_impl_trait_id, None),
2007            CoroutineKind::Gen { return_impl_trait_id, .. } => (return_impl_trait_id, None),
2008            CoroutineKind::AsyncGen { return_impl_trait_id, .. } => {
2009                (return_impl_trait_id, Some(Arc::clone(&self.allow_async_iterator)))
2010            }
2011        };
2012
2013        let opaque_ty_span =
2014            self.mark_span_with_reason(DesugaringKind::Async, span, allowed_features);
2015
2016        let in_trait_or_impl = match fn_kind {
2017            FnDeclKind::Trait => Some(hir::RpitContext::Trait),
2018            FnDeclKind::Impl => Some(hir::RpitContext::TraitImpl),
2019            FnDeclKind::Fn | FnDeclKind::Inherent => None,
2020            FnDeclKind::ExternFn | FnDeclKind::Closure | FnDeclKind::Pointer => unreachable!(),
2021        };
2022
2023        let opaque_ty_ref = self.lower_opaque_inner(
2024            opaque_ty_node_id,
2025            hir::OpaqueTyOrigin::AsyncFn { parent: fn_def_id, in_trait_or_impl },
2026            opaque_ty_span,
2027            |this| {
2028                let bound = this.lower_coroutine_fn_output_type_to_bound(
2029                    output,
2030                    coro,
2031                    opaque_ty_span,
2032                    ImplTraitContext::OpaqueTy {
2033                        origin: hir::OpaqueTyOrigin::FnReturn {
2034                            parent: fn_def_id,
2035                            in_trait_or_impl,
2036                        },
2037                    },
2038                );
2039                arena_vec![this; bound]
2040            },
2041        );
2042
2043        let opaque_ty = self.ty(opaque_ty_span, opaque_ty_ref);
2044        hir::FnRetTy::Return(self.arena.alloc(opaque_ty))
2045    }
2046
2047    /// Transforms `-> T` into `Future<Output = T>`.
2048    fn lower_coroutine_fn_output_type_to_bound(
2049        &mut self,
2050        output: &FnRetTy,
2051        coro: CoroutineKind,
2052        opaque_ty_span: Span,
2053        itctx: ImplTraitContext,
2054    ) -> hir::GenericBound<'hir> {
2055        // Compute the `T` in `Future<Output = T>` from the return type.
2056        let output_ty = match output {
2057            FnRetTy::Ty(ty) => {
2058                // Not `OpaqueTyOrigin::AsyncFn`: that's only used for the
2059                // `impl Future` opaque type that `async fn` implicitly
2060                // generates.
2061                self.lower_ty_alloc(ty, itctx)
2062            }
2063            FnRetTy::Default(ret_ty_span) => self.arena.alloc(self.ty_tup(*ret_ty_span, &[])),
2064        };
2065
2066        // "<$assoc_ty_name = T>"
2067        let (assoc_ty_name, trait_lang_item) = match coro {
2068            CoroutineKind::Async { .. } => (sym::Output, hir::LangItem::Future),
2069            CoroutineKind::Gen { .. } => (sym::Item, hir::LangItem::Iterator),
2070            CoroutineKind::AsyncGen { .. } => (sym::Item, hir::LangItem::AsyncIterator),
2071        };
2072
2073        let bound_args = self.arena.alloc(hir::GenericArgs {
2074            args: &[],
2075            constraints: self.arena.alloc_from_iter([self.assoc_ty_binding(assoc_ty_name,
                opaque_ty_span, output_ty)])arena_vec![self; self.assoc_ty_binding(assoc_ty_name, opaque_ty_span, output_ty)],
2076            parenthesized: hir::GenericArgsParentheses::No,
2077            span_ext: DUMMY_SP,
2078        });
2079
2080        hir::GenericBound::Trait(hir::PolyTraitRef {
2081            bound_generic_params: &[],
2082            modifiers: hir::TraitBoundModifiers::NONE,
2083            trait_ref: hir::TraitRef {
2084                path: self.make_lang_item_path(trait_lang_item, opaque_ty_span, Some(bound_args)),
2085                hir_ref_id: self.next_id(),
2086            },
2087            span: opaque_ty_span,
2088        })
2089    }
2090
2091    #[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("lower_param_bound",
                                    "rustc_ast_lowering", ::tracing::Level::TRACE,
                                    ::tracing_core::__macro_support::Option::Some("compiler/rustc_ast_lowering/src/lib.rs"),
                                    ::tracing_core::__macro_support::Option::Some(2091u32),
                                    ::tracing_core::__macro_support::Option::Some("rustc_ast_lowering"),
                                    ::tracing_core::field::FieldSet::new(&["tpb", "rbp",
                                                    "itctx"],
                                        ::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};
                                let mut iter = meta.fields().iter();
                                meta.fields().value_set(&[(&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
                                                    ::tracing::__macro_support::Option::Some(&::tracing::field::debug(&tpb)
                                                            as &dyn Value)),
                                                (&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
                                                    ::tracing::__macro_support::Option::Some(&::tracing::field::debug(&rbp)
                                                            as &dyn Value)),
                                                (&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
                                                    ::tracing::__macro_support::Option::Some(&::tracing::field::debug(&itctx)
                                                            as &dyn Value))])
                            })
                } else {
                    let span =
                        ::tracing::__macro_support::__disabled_span(__CALLSITE.metadata());
                    {};
                    span
                }
            };
        __tracing_attr_guard = __tracing_attr_span.enter();
    }

    #[warn(clippy :: suspicious_else_formatting)]
    {

        #[allow(unknown_lints, unreachable_code, clippy ::
        diverging_sub_expression, clippy :: empty_loop, clippy ::
        let_unit_value, clippy :: let_with_type_underscore, clippy ::
        needless_return, clippy :: unreachable)]
        if false {
            let __tracing_attr_fake_return: hir::GenericBound<'hir> = loop {};
            return __tracing_attr_fake_return;
        }
        {
            match tpb {
                GenericBound::Trait(p) => {
                    hir::GenericBound::Trait(self.lower_poly_trait_ref(p, rbp,
                            itctx))
                }
                GenericBound::Outlives(lifetime) =>
                    hir::GenericBound::Outlives(self.lower_lifetime(lifetime,
                            LifetimeSource::OutlivesBound, lifetime.ident.into())),
                GenericBound::Use(args, span) =>
                    hir::GenericBound::Use(self.lower_precise_capturing_args(args),
                        self.lower_span(*span)),
            }
        }
    }
}#[instrument(level = "trace", skip(self))]
2092    fn lower_param_bound(
2093        &mut self,
2094        tpb: &GenericBound,
2095        rbp: RelaxedBoundPolicy<'_>,
2096        itctx: ImplTraitContext,
2097    ) -> hir::GenericBound<'hir> {
2098        match tpb {
2099            GenericBound::Trait(p) => {
2100                hir::GenericBound::Trait(self.lower_poly_trait_ref(p, rbp, itctx))
2101            }
2102            GenericBound::Outlives(lifetime) => hir::GenericBound::Outlives(self.lower_lifetime(
2103                lifetime,
2104                LifetimeSource::OutlivesBound,
2105                lifetime.ident.into(),
2106            )),
2107            GenericBound::Use(args, span) => hir::GenericBound::Use(
2108                self.lower_precise_capturing_args(args),
2109                self.lower_span(*span),
2110            ),
2111        }
2112    }
2113
2114    fn lower_lifetime(
2115        &mut self,
2116        l: &Lifetime,
2117        source: LifetimeSource,
2118        syntax: LifetimeSyntax,
2119    ) -> &'hir hir::Lifetime {
2120        self.new_named_lifetime(l.id, l.id, l.ident, source, syntax)
2121    }
2122
2123    fn lower_lifetime_hidden_in_path(
2124        &mut self,
2125        id: NodeId,
2126        span: Span,
2127        angle_brackets: AngleBrackets,
2128    ) -> &'hir hir::Lifetime {
2129        self.new_named_lifetime(
2130            id,
2131            id,
2132            Ident::new(kw::UnderscoreLifetime, span),
2133            LifetimeSource::Path { angle_brackets },
2134            LifetimeSyntax::Implicit,
2135        )
2136    }
2137
2138    #[allow(clippy :: suspicious_else_formatting)]
{
    let __tracing_attr_span;
    let __tracing_attr_guard;
    if ::tracing::Level::DEBUG <= ::tracing::level_filters::STATIC_MAX_LEVEL
                &&
                ::tracing::Level::DEBUG <=
                    ::tracing::level_filters::LevelFilter::current() ||
            { false } {
        __tracing_attr_span =
            {
                use ::tracing::__macro_support::Callsite as _;
                static __CALLSITE: ::tracing::callsite::DefaultCallsite =
                    {
                        static META: ::tracing::Metadata<'static> =
                            {
                                ::tracing_core::metadata::Metadata::new("new_named_lifetime",
                                    "rustc_ast_lowering", ::tracing::Level::DEBUG,
                                    ::tracing_core::__macro_support::Option::Some("compiler/rustc_ast_lowering/src/lib.rs"),
                                    ::tracing_core::__macro_support::Option::Some(2138u32),
                                    ::tracing_core::__macro_support::Option::Some("rustc_ast_lowering"),
                                    ::tracing_core::field::FieldSet::new(&["id", "new_id",
                                                    "ident", "source", "syntax"],
                                        ::tracing_core::callsite::Identifier(&__CALLSITE)),
                                    ::tracing::metadata::Kind::SPAN)
                            };
                        ::tracing::callsite::DefaultCallsite::new(&META)
                    };
                let mut interest = ::tracing::subscriber::Interest::never();
                if ::tracing::Level::DEBUG <=
                                    ::tracing::level_filters::STATIC_MAX_LEVEL &&
                                ::tracing::Level::DEBUG <=
                                    ::tracing::level_filters::LevelFilter::current() &&
                            { interest = __CALLSITE.interest(); !interest.is_never() }
                        &&
                        ::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
                            interest) {
                    let meta = __CALLSITE.metadata();
                    ::tracing::Span::new(meta,
                        &{
                                #[allow(unused_imports)]
                                use ::tracing::field::{debug, display, Value};
                                let mut iter = meta.fields().iter();
                                meta.fields().value_set(&[(&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
                                                    ::tracing::__macro_support::Option::Some(&::tracing::field::debug(&id)
                                                            as &dyn Value)),
                                                (&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
                                                    ::tracing::__macro_support::Option::Some(&::tracing::field::debug(&new_id)
                                                            as &dyn Value)),
                                                (&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
                                                    ::tracing::__macro_support::Option::Some(&::tracing::field::debug(&ident)
                                                            as &dyn Value)),
                                                (&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
                                                    ::tracing::__macro_support::Option::Some(&::tracing::field::debug(&source)
                                                            as &dyn Value)),
                                                (&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
                                                    ::tracing::__macro_support::Option::Some(&::tracing::field::debug(&syntax)
                                                            as &dyn Value))])
                            })
                } else {
                    let span =
                        ::tracing::__macro_support::__disabled_span(__CALLSITE.metadata());
                    {};
                    span
                }
            };
        __tracing_attr_guard = __tracing_attr_span.enter();
    }

    #[warn(clippy :: suspicious_else_formatting)]
    {

        #[allow(unknown_lints, unreachable_code, clippy ::
        diverging_sub_expression, clippy :: empty_loop, clippy ::
        let_unit_value, clippy :: let_with_type_underscore, clippy ::
        needless_return, clippy :: unreachable)]
        if false {
            let __tracing_attr_fake_return: &'hir hir::Lifetime = loop {};
            return __tracing_attr_fake_return;
        }
        {
            let res =
                if let Some(res) = self.owner.get_lifetime_res(id) {
                    match res {
                        LifetimeRes::Param { param, .. } =>
                            hir::LifetimeKind::Param(param),
                        LifetimeRes::Fresh { param, .. } => {
                            {
                                match (&ident.name, &kw::UnderscoreLifetime) {
                                    (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 param = self.local_def_id(param);
                            hir::LifetimeKind::Param(param)
                        }
                        LifetimeRes::Infer => {
                            {
                                match (&ident.name, &kw::UnderscoreLifetime) {
                                    (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);
                                        }
                                    }
                                }
                            };
                            hir::LifetimeKind::Infer
                        }
                        LifetimeRes::Static { .. } => {
                            if !#[allow(non_exhaustive_omitted_patterns)] match ident.name
                                        {
                                        kw::StaticLifetime | kw::UnderscoreLifetime => true,
                                        _ => false,
                                    } {
                                ::core::panicking::panic("assertion failed: matches!(ident.name, kw::StaticLifetime | kw::UnderscoreLifetime)")
                            };
                            hir::LifetimeKind::Static
                        }
                        LifetimeRes::Error(guar) => hir::LifetimeKind::Error(guar),
                        LifetimeRes::ElidedAnchor { .. } => {
                            {
                                ::core::panicking::panic_fmt(format_args!("Unexpected `ElidedAnchar` {0:?} at {1:?}",
                                        ident, ident.span));
                            };
                        }
                    }
                } else {
                    hir::LifetimeKind::Error(self.dcx().span_delayed_bug(ident.span,
                            "unresolved lifetime"))
                };
            {
                use ::tracing::__macro_support::Callsite as _;
                static __CALLSITE: ::tracing::callsite::DefaultCallsite =
                    {
                        static META: ::tracing::Metadata<'static> =
                            {
                                ::tracing_core::metadata::Metadata::new("event compiler/rustc_ast_lowering/src/lib.rs:2172",
                                    "rustc_ast_lowering", ::tracing::Level::DEBUG,
                                    ::tracing_core::__macro_support::Option::Some("compiler/rustc_ast_lowering/src/lib.rs"),
                                    ::tracing_core::__macro_support::Option::Some(2172u32),
                                    ::tracing_core::__macro_support::Option::Some("rustc_ast_lowering"),
                                    ::tracing_core::field::FieldSet::new(&["res"],
                                        ::tracing_core::callsite::Identifier(&__CALLSITE)),
                                    ::tracing::metadata::Kind::EVENT)
                            };
                        ::tracing::callsite::DefaultCallsite::new(&META)
                    };
                let enabled =
                    ::tracing::Level::DEBUG <=
                                ::tracing::level_filters::STATIC_MAX_LEVEL &&
                            ::tracing::Level::DEBUG <=
                                ::tracing::level_filters::LevelFilter::current() &&
                        {
                            let interest = __CALLSITE.interest();
                            !interest.is_never() &&
                                ::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
                                    interest)
                        };
                if enabled {
                    (|value_set: ::tracing::field::ValueSet|
                                {
                                    let meta = __CALLSITE.metadata();
                                    ::tracing::Event::dispatch(meta, &value_set);
                                    ;
                                })({
                            #[allow(unused_imports)]
                            use ::tracing::field::{debug, display, Value};
                            let mut iter = __CALLSITE.metadata().fields().iter();
                            __CALLSITE.metadata().fields().value_set(&[(&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
                                                ::tracing::__macro_support::Option::Some(&debug(&res) as
                                                        &dyn Value))])
                        });
                } else { ; }
            };
            self.arena.alloc(hir::Lifetime::new(self.lower_node_id(new_id),
                    self.lower_ident(ident), res, source, syntax))
        }
    }
}#[instrument(level = "debug", skip(self))]
2139    fn new_named_lifetime(
2140        &mut self,
2141        id: NodeId,
2142        new_id: NodeId,
2143        ident: Ident,
2144        source: LifetimeSource,
2145        syntax: LifetimeSyntax,
2146    ) -> &'hir hir::Lifetime {
2147        let res = if let Some(res) = self.owner.get_lifetime_res(id) {
2148            match res {
2149                LifetimeRes::Param { param, .. } => hir::LifetimeKind::Param(param),
2150                LifetimeRes::Fresh { param, .. } => {
2151                    assert_eq!(ident.name, kw::UnderscoreLifetime);
2152                    let param = self.local_def_id(param);
2153                    hir::LifetimeKind::Param(param)
2154                }
2155                LifetimeRes::Infer => {
2156                    assert_eq!(ident.name, kw::UnderscoreLifetime);
2157                    hir::LifetimeKind::Infer
2158                }
2159                LifetimeRes::Static { .. } => {
2160                    assert!(matches!(ident.name, kw::StaticLifetime | kw::UnderscoreLifetime));
2161                    hir::LifetimeKind::Static
2162                }
2163                LifetimeRes::Error(guar) => hir::LifetimeKind::Error(guar),
2164                LifetimeRes::ElidedAnchor { .. } => {
2165                    panic!("Unexpected `ElidedAnchar` {:?} at {:?}", ident, ident.span);
2166                }
2167            }
2168        } else {
2169            hir::LifetimeKind::Error(self.dcx().span_delayed_bug(ident.span, "unresolved lifetime"))
2170        };
2171
2172        debug!(?res);
2173        self.arena.alloc(hir::Lifetime::new(
2174            self.lower_node_id(new_id),
2175            self.lower_ident(ident),
2176            res,
2177            source,
2178            syntax,
2179        ))
2180    }
2181
2182    fn lower_generic_params_mut(
2183        &mut self,
2184        params: &[GenericParam],
2185        source: hir::GenericParamSource,
2186    ) -> impl Iterator<Item = hir::GenericParam<'hir>> {
2187        params.iter().map(move |param| self.lower_generic_param(param, source))
2188    }
2189
2190    fn lower_generic_params(
2191        &mut self,
2192        params: &[GenericParam],
2193        source: hir::GenericParamSource,
2194    ) -> &'hir [hir::GenericParam<'hir>] {
2195        self.arena.alloc_from_iter(self.lower_generic_params_mut(params, source))
2196    }
2197
2198    #[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("lower_generic_param",
                                    "rustc_ast_lowering", ::tracing::Level::TRACE,
                                    ::tracing_core::__macro_support::Option::Some("compiler/rustc_ast_lowering/src/lib.rs"),
                                    ::tracing_core::__macro_support::Option::Some(2198u32),
                                    ::tracing_core::__macro_support::Option::Some("rustc_ast_lowering"),
                                    ::tracing_core::field::FieldSet::new(&["param", "source"],
                                        ::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};
                                let mut iter = meta.fields().iter();
                                meta.fields().value_set(&[(&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
                                                    ::tracing::__macro_support::Option::Some(&::tracing::field::debug(&param)
                                                            as &dyn Value)),
                                                (&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
                                                    ::tracing::__macro_support::Option::Some(&::tracing::field::debug(&source)
                                                            as &dyn Value))])
                            })
                } else {
                    let span =
                        ::tracing::__macro_support::__disabled_span(__CALLSITE.metadata());
                    {};
                    span
                }
            };
        __tracing_attr_guard = __tracing_attr_span.enter();
    }

    #[warn(clippy :: suspicious_else_formatting)]
    {

        #[allow(unknown_lints, unreachable_code, clippy ::
        diverging_sub_expression, clippy :: empty_loop, clippy ::
        let_unit_value, clippy :: let_with_type_underscore, clippy ::
        needless_return, clippy :: unreachable)]
        if false {
            let __tracing_attr_fake_return: hir::GenericParam<'hir> = loop {};
            return __tracing_attr_fake_return;
        }
        {
            let (name, kind) = self.lower_generic_param_kind(param, source);
            let hir_id = self.lower_node_id(param.id);
            let param_attrs = &param.attrs;
            let param_span = param.span();
            let param =
                hir::GenericParam {
                    hir_id,
                    def_id: self.local_def_id(param.id),
                    name,
                    span: self.lower_span(param.span()),
                    pure_wrt_drop: attr::contains_name(&param.attrs,
                        sym::may_dangle),
                    kind,
                    colon_span: param.colon_span.map(|s| self.lower_span(s)),
                    source,
                };
            self.lower_attrs(hir_id, param_attrs, param_span,
                Target::from_generic_param(&param));
            param
        }
    }
}#[instrument(level = "trace", skip(self))]
2199    fn lower_generic_param(
2200        &mut self,
2201        param: &GenericParam,
2202        source: hir::GenericParamSource,
2203    ) -> hir::GenericParam<'hir> {
2204        let (name, kind) = self.lower_generic_param_kind(param, source);
2205
2206        let hir_id = self.lower_node_id(param.id);
2207        let param_attrs = &param.attrs;
2208        let param_span = param.span();
2209        let param = hir::GenericParam {
2210            hir_id,
2211            def_id: self.local_def_id(param.id),
2212            name,
2213            span: self.lower_span(param.span()),
2214            pure_wrt_drop: attr::contains_name(&param.attrs, sym::may_dangle),
2215            kind,
2216            colon_span: param.colon_span.map(|s| self.lower_span(s)),
2217            source,
2218        };
2219        self.lower_attrs(hir_id, param_attrs, param_span, Target::from_generic_param(&param));
2220        param
2221    }
2222
2223    fn lower_generic_param_kind(
2224        &mut self,
2225        param: &GenericParam,
2226        source: hir::GenericParamSource,
2227    ) -> (hir::ParamName, hir::GenericParamKind<'hir>) {
2228        match &param.kind {
2229            GenericParamKind::Lifetime => {
2230                // AST resolution emitted an error on those parameters, so we lower them using
2231                // `ParamName::Error`.
2232                let ident = self.lower_ident(param.ident);
2233                let param_name =
2234                    if let Some(LifetimeRes::Error(..)) = self.owner.get_lifetime_res(param.id) {
2235                        ParamName::Error(ident)
2236                    } else {
2237                        ParamName::Plain(ident)
2238                    };
2239                let kind =
2240                    hir::GenericParamKind::Lifetime { kind: hir::LifetimeParamKind::Explicit };
2241
2242                (param_name, kind)
2243            }
2244            GenericParamKind::Type { default, .. } => {
2245                // Not only do we deny type param defaults in binders but we also map them to `None`
2246                // since later compiler stages cannot handle them (and shouldn't need to be able to).
2247                let default = default
2248                    .as_ref()
2249                    .filter(|_| match source {
2250                        hir::GenericParamSource::Generics => true,
2251                        hir::GenericParamSource::Binder => {
2252                            self.dcx().emit_err(diagnostics::GenericParamDefaultInBinder {
2253                                span: param.span(),
2254                            });
2255
2256                            false
2257                        }
2258                    })
2259                    .map(|def| {
2260                        self.lower_ty_alloc(
2261                            def,
2262                            ImplTraitContext::Disallowed(ImplTraitPosition::GenericDefault),
2263                        )
2264                    });
2265
2266                let kind = hir::GenericParamKind::Type { default, synthetic: false };
2267
2268                (hir::ParamName::Plain(self.lower_ident(param.ident)), kind)
2269            }
2270            GenericParamKind::Const { ty, span: _, default } => {
2271                let ty = self.lower_ty_alloc(
2272                    ty,
2273                    ImplTraitContext::Disallowed(ImplTraitPosition::GenericDefault),
2274                );
2275
2276                // Not only do we deny const param defaults in binders but we also map them to `None`
2277                // since later compiler stages cannot handle them (and shouldn't need to be able to).
2278                let default = default
2279                    .as_ref()
2280                    .filter(|anon_const| match source {
2281                        hir::GenericParamSource::Generics => true,
2282                        hir::GenericParamSource::Binder => {
2283                            let err =
2284                                diagnostics::GenericParamDefaultInBinder { span: param.span() };
2285                            if expr::WillCreateDefIdsVisitor
2286                                .visit_expr(&anon_const.value)
2287                                .is_break()
2288                            {
2289                                // FIXME(mgca): make this non-fatal once we have a better way
2290                                // to handle nested items in anno const from binder
2291                                // Issue: https://github.com/rust-lang/rust/issues/123629
2292                                self.dcx().emit_fatal(err)
2293                            } else {
2294                                self.dcx().emit_err(err);
2295                                false
2296                            }
2297                        }
2298                    })
2299                    .map(|def| self.lower_anon_const_to_const_arg_and_alloc(def));
2300
2301                (
2302                    hir::ParamName::Plain(self.lower_ident(param.ident)),
2303                    hir::GenericParamKind::Const { ty, default },
2304                )
2305            }
2306        }
2307    }
2308
2309    fn lower_trait_ref(
2310        &mut self,
2311        modifiers: ast::TraitBoundModifiers,
2312        p: &TraitRef,
2313        itctx: ImplTraitContext,
2314    ) -> hir::TraitRef<'hir> {
2315        let path = match self.lower_qpath(
2316            p.ref_id,
2317            &None,
2318            &p.path,
2319            ParamMode::Explicit,
2320            AllowReturnTypeNotation::No,
2321            itctx,
2322            Some(modifiers),
2323        ) {
2324            hir::QPath::Resolved(None, path) => path,
2325            qpath => {
    ::core::panicking::panic_fmt(format_args!("lower_trait_ref: unexpected QPath `{0:?}`",
            qpath));
}panic!("lower_trait_ref: unexpected QPath `{qpath:?}`"),
2326        };
2327        hir::TraitRef { path, hir_ref_id: self.lower_node_id(p.ref_id) }
2328    }
2329
2330    #[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_ast_lowering", ::tracing::Level::DEBUG,
                                    ::tracing_core::__macro_support::Option::Some("compiler/rustc_ast_lowering/src/lib.rs"),
                                    ::tracing_core::__macro_support::Option::Some(2330u32),
                                    ::tracing_core::__macro_support::Option::Some("rustc_ast_lowering"),
                                    ::tracing_core::field::FieldSet::new(&["bound_generic_params",
                                                    "modifiers", "trait_ref", "span", "rbp", "itctx"],
                                        ::tracing_core::callsite::Identifier(&__CALLSITE)),
                                    ::tracing::metadata::Kind::SPAN)
                            };
                        ::tracing::callsite::DefaultCallsite::new(&META)
                    };
                let mut interest = ::tracing::subscriber::Interest::never();
                if ::tracing::Level::DEBUG <=
                                    ::tracing::level_filters::STATIC_MAX_LEVEL &&
                                ::tracing::Level::DEBUG <=
                                    ::tracing::level_filters::LevelFilter::current() &&
                            { interest = __CALLSITE.interest(); !interest.is_never() }
                        &&
                        ::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
                            interest) {
                    let meta = __CALLSITE.metadata();
                    ::tracing::Span::new(meta,
                        &{
                                #[allow(unused_imports)]
                                use ::tracing::field::{debug, display, Value};
                                let mut iter = meta.fields().iter();
                                meta.fields().value_set(&[(&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
                                                    ::tracing::__macro_support::Option::Some(&::tracing::field::debug(&bound_generic_params)
                                                            as &dyn Value)),
                                                (&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
                                                    ::tracing::__macro_support::Option::Some(&::tracing::field::debug(&modifiers)
                                                            as &dyn Value)),
                                                (&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
                                                    ::tracing::__macro_support::Option::Some(&::tracing::field::debug(&trait_ref)
                                                            as &dyn Value)),
                                                (&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
                                                    ::tracing::__macro_support::Option::Some(&::tracing::field::debug(&span)
                                                            as &dyn Value)),
                                                (&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
                                                    ::tracing::__macro_support::Option::Some(&::tracing::field::debug(&rbp)
                                                            as &dyn Value)),
                                                (&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
                                                    ::tracing::__macro_support::Option::Some(&::tracing::field::debug(&itctx)
                                                            as &dyn Value))])
                            })
                } else {
                    let span =
                        ::tracing::__macro_support::__disabled_span(__CALLSITE.metadata());
                    {};
                    span
                }
            };
        __tracing_attr_guard = __tracing_attr_span.enter();
    }

    #[warn(clippy :: suspicious_else_formatting)]
    {

        #[allow(unknown_lints, unreachable_code, clippy ::
        diverging_sub_expression, clippy :: empty_loop, clippy ::
        let_unit_value, clippy :: let_with_type_underscore, clippy ::
        needless_return, clippy :: unreachable)]
        if false {
            let __tracing_attr_fake_return: hir::PolyTraitRef<'hir> = loop {};
            return __tracing_attr_fake_return;
        }
        {
            let bound_generic_params =
                self.lower_lifetime_binder(trait_ref.ref_id,
                    bound_generic_params);
            let trait_ref =
                self.lower_trait_ref(*modifiers, trait_ref, itctx);
            let modifiers = self.lower_trait_bound_modifiers(*modifiers);
            if let ast::BoundPolarity::Maybe(_) = modifiers.polarity {
                self.validate_relaxed_bound(trait_ref, *span, rbp);
            }
            hir::PolyTraitRef {
                bound_generic_params,
                modifiers,
                trait_ref,
                span: self.lower_span(*span),
            }
        }
    }
}#[instrument(level = "debug", skip(self))]
2331    fn lower_poly_trait_ref(
2332        &mut self,
2333        PolyTraitRef { bound_generic_params, modifiers, trait_ref, span, parens: _ }: &PolyTraitRef,
2334        rbp: RelaxedBoundPolicy<'_>,
2335        itctx: ImplTraitContext,
2336    ) -> hir::PolyTraitRef<'hir> {
2337        let bound_generic_params =
2338            self.lower_lifetime_binder(trait_ref.ref_id, bound_generic_params);
2339        let trait_ref = self.lower_trait_ref(*modifiers, trait_ref, itctx);
2340        let modifiers = self.lower_trait_bound_modifiers(*modifiers);
2341
2342        if let ast::BoundPolarity::Maybe(_) = modifiers.polarity {
2343            self.validate_relaxed_bound(trait_ref, *span, rbp);
2344        }
2345
2346        hir::PolyTraitRef {
2347            bound_generic_params,
2348            modifiers,
2349            trait_ref,
2350            span: self.lower_span(*span),
2351        }
2352    }
2353
2354    fn validate_relaxed_bound(
2355        &self,
2356        trait_ref: hir::TraitRef<'_>,
2357        span: Span,
2358        rbp: RelaxedBoundPolicy<'_>,
2359    ) {
2360        // Even though feature `more_maybe_bounds` enables the user to relax all default bounds
2361        // other than `Sized` in a lot more positions (thereby bypassing the given policy), we don't
2362        // want to advertise it to the user (via a feature gate error) since it's super internal.
2363        //
2364        // FIXME(more_maybe_bounds): Moreover, if we actually were to add proper default traits
2365        // (like a hypothetical `Move` or `Leak`) we would want to validate the location according
2366        // to default trait elaboration in HIR ty lowering (which depends on the specific trait in
2367        // question: E.g., `?Sized` & `?Move` most likely won't be allowed in all the same places).
2368
2369        match rbp {
2370            RelaxedBoundPolicy::Allowed(dedup_map) => {
2371                // `trait_def_id` only returns `None` for errors during resolution.
2372                let Some(trait_def_id) = trait_ref.trait_def_id() else { return };
2373                let tcx = self.tcx;
2374                let err = |s| {
2375                    let name = tcx.item_name(trait_def_id);
2376                    tcx.dcx()
2377                        .struct_span_err(
2378                            ::alloc::boxed::box_assume_init_into_vec_unsafe(::alloc::intrinsics::write_box_via_move(::alloc::boxed::Box::new_uninit(),
        [span, s]))vec![span, s],
2379                            ::alloc::__export::must_use({
        ::alloc::fmt::format(format_args!("duplicate relaxed `{0}` bounds",
                name))
    })format!("duplicate relaxed `{name}` bounds"),
2380                        )
2381                        .with_code(E0203)
2382                        .emit();
2383                };
2384                dedup_map.entry(trait_def_id).and_modify(|&mut s| err(s)).or_insert(span);
2385                return;
2386            }
2387            RelaxedBoundPolicy::Forbidden(reason) => {
2388                let gate = |context, subject| {
2389                    let extended = self.tcx.features().more_maybe_bounds();
2390                    let is_sized = trait_ref
2391                        .trait_def_id()
2392                        .is_some_and(|def_id| self.tcx.is_lang_item(def_id, hir::LangItem::Sized));
2393
2394                    if extended && !is_sized {
2395                        return;
2396                    }
2397
2398                    let prefix = if extended { "`Sized` " } else { "" };
2399                    let mut diag = self.dcx().struct_span_err(
2400                        span,
2401                        ::alloc::__export::must_use({
        ::alloc::fmt::format(format_args!("relaxed {0}bounds are not permitted in {1}",
                prefix, context))
    })format!("relaxed {prefix}bounds are not permitted in {context}"),
2402                    );
2403                    if is_sized {
2404                        diag.note(::alloc::__export::must_use({
        ::alloc::fmt::format(format_args!("{0} are not implicitly bounded by `Sized`, so there is nothing to relax",
                subject))
    })format!(
2405                            "{subject} are not implicitly bounded by `Sized`, \
2406                             so there is nothing to relax"
2407                        ));
2408                    }
2409                    diag.emit();
2410                };
2411
2412                match reason {
2413                    RelaxedBoundForbiddenReason::TraitObjectTy => {
2414                        gate("trait object types", "trait object types");
2415                        return;
2416                    }
2417                    RelaxedBoundForbiddenReason::SuperTrait => {
2418                        gate("supertrait bounds", "traits");
2419                        return;
2420                    }
2421                    RelaxedBoundForbiddenReason::TraitAlias => {
2422                        gate("trait alias bounds", "trait aliases");
2423                        return;
2424                    }
2425                    RelaxedBoundForbiddenReason::AssocTyBounds
2426                    | RelaxedBoundForbiddenReason::WhereBound => {}
2427                };
2428            }
2429        }
2430
2431        self.dcx()
2432            .struct_span_err(span, "this relaxed bound is not permitted here")
2433            .with_note(
2434                "in this context, relaxed bounds are only allowed on \
2435                 type parameters defined on the closest item",
2436            )
2437            .emit();
2438    }
2439
2440    fn lower_mt(&mut self, mt: &MutTy, itctx: ImplTraitContext) -> hir::MutTy<'hir> {
2441        hir::MutTy { ty: self.lower_ty_alloc(&mt.ty, itctx), mutbl: mt.mutbl }
2442    }
2443
2444    x;#[instrument(level = "debug", skip(self), ret)]
2445    fn lower_param_bounds(
2446        &mut self,
2447        bounds: &[GenericBound],
2448        rbp: RelaxedBoundPolicy<'_>,
2449        itctx: ImplTraitContext,
2450    ) -> hir::GenericBounds<'hir> {
2451        self.arena.alloc_from_iter(self.lower_param_bounds_mut(bounds, rbp, itctx))
2452    }
2453
2454    fn lower_param_bounds_mut(
2455        &mut self,
2456        bounds: &[GenericBound],
2457        mut rbp: RelaxedBoundPolicy<'_>,
2458        itctx: ImplTraitContext,
2459    ) -> impl Iterator<Item = hir::GenericBound<'hir>> {
2460        bounds.iter().map(move |bound| self.lower_param_bound(bound, rbp.reborrow(), itctx))
2461    }
2462
2463    x;#[instrument(level = "debug", skip(self), ret)]
2464    fn lower_universal_param_and_bounds(
2465        &mut self,
2466        node_id: NodeId,
2467        span: Span,
2468        ident: Ident,
2469        bounds: &[GenericBound],
2470    ) -> (hir::GenericParam<'hir>, Option<hir::WherePredicate<'hir>>, hir::TyKind<'hir>) {
2471        // Add a definition for the in-band `Param`.
2472        let def_id = self.local_def_id(node_id);
2473        let span = self.lower_span(span);
2474
2475        // Set the name to `impl Bound1 + Bound2`.
2476        let param = hir::GenericParam {
2477            hir_id: self.lower_node_id(node_id),
2478            def_id,
2479            name: ParamName::Plain(self.lower_ident(ident)),
2480            pure_wrt_drop: false,
2481            span,
2482            kind: hir::GenericParamKind::Type { default: None, synthetic: true },
2483            colon_span: None,
2484            source: hir::GenericParamSource::Generics,
2485        };
2486
2487        let preds = self.lower_generic_bound_predicate(
2488            ident,
2489            node_id,
2490            &GenericParamKind::Type { default: None },
2491            bounds,
2492            /* colon_span */ None,
2493            span,
2494            RelaxedBoundPolicy::Allowed(&mut Default::default()),
2495            ImplTraitContext::Universal,
2496            hir::PredicateOrigin::ImplTrait,
2497        );
2498
2499        let hir_id = self.next_id();
2500        let res = Res::Def(DefKind::TyParam, def_id.to_def_id());
2501        let ty = hir::TyKind::Path(hir::QPath::Resolved(
2502            None,
2503            self.arena.alloc(hir::Path {
2504                span,
2505                res,
2506                segments:
2507                    arena_vec![self; hir::PathSegment::new(self.lower_ident(ident), hir_id, res)],
2508            }),
2509        ));
2510
2511        (param, preds, ty)
2512    }
2513
2514    /// Lowers a block directly to an expression, presuming that it
2515    /// has no attributes and is not targeted by a `break`.
2516    fn lower_block_expr(&mut self, b: &Block) -> hir::Expr<'hir> {
2517        let block = self.lower_block(b, false);
2518        self.expr_block(block)
2519    }
2520
2521    fn lower_array_length_to_const_arg(&mut self, c: &AnonConst) -> &'hir hir::ConstArg<'hir> {
2522        // We cannot just match on `ExprKind::Underscore` as `(_)` is represented as
2523        // `ExprKind::Paren(ExprKind::Underscore)` and should also be lowered to `GenericArg::Infer`
2524        match c.value.peel_parens().kind {
2525            ExprKind::Underscore => {
2526                let ct_kind = hir::ConstArgKind::Infer(());
2527                self.arena.alloc(hir::ConstArg {
2528                    hir_id: self.lower_node_id(c.id),
2529                    kind: ct_kind,
2530                    span: self.lower_span(c.value.span),
2531                })
2532            }
2533            _ => self.lower_anon_const_to_const_arg_and_alloc(c),
2534        }
2535    }
2536
2537    /// Used when lowering a type argument that turned out to actually be a const argument.
2538    ///
2539    /// Only use for that purpose since otherwise it will create a duplicate def.
2540    #[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_path_to_const_arg",
                                    "rustc_ast_lowering", ::tracing::Level::DEBUG,
                                    ::tracing_core::__macro_support::Option::Some("compiler/rustc_ast_lowering/src/lib.rs"),
                                    ::tracing_core::__macro_support::Option::Some(2540u32),
                                    ::tracing_core::__macro_support::Option::Some("rustc_ast_lowering"),
                                    ::tracing_core::field::FieldSet::new(&["path", "res",
                                                    "ty_id", "span"],
                                        ::tracing_core::callsite::Identifier(&__CALLSITE)),
                                    ::tracing::metadata::Kind::SPAN)
                            };
                        ::tracing::callsite::DefaultCallsite::new(&META)
                    };
                let mut interest = ::tracing::subscriber::Interest::never();
                if ::tracing::Level::DEBUG <=
                                    ::tracing::level_filters::STATIC_MAX_LEVEL &&
                                ::tracing::Level::DEBUG <=
                                    ::tracing::level_filters::LevelFilter::current() &&
                            { interest = __CALLSITE.interest(); !interest.is_never() }
                        &&
                        ::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
                            interest) {
                    let meta = __CALLSITE.metadata();
                    ::tracing::Span::new(meta,
                        &{
                                #[allow(unused_imports)]
                                use ::tracing::field::{debug, display, Value};
                                let mut iter = meta.fields().iter();
                                meta.fields().value_set(&[(&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
                                                    ::tracing::__macro_support::Option::Some(&::tracing::field::debug(&path)
                                                            as &dyn Value)),
                                                (&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
                                                    ::tracing::__macro_support::Option::Some(&::tracing::field::debug(&res)
                                                            as &dyn Value)),
                                                (&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
                                                    ::tracing::__macro_support::Option::Some(&::tracing::field::debug(&ty_id)
                                                            as &dyn Value)),
                                                (&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
                                                    ::tracing::__macro_support::Option::Some(&::tracing::field::debug(&span)
                                                            as &dyn Value))])
                            })
                } else {
                    let span =
                        ::tracing::__macro_support::__disabled_span(__CALLSITE.metadata());
                    {};
                    span
                }
            };
        __tracing_attr_guard = __tracing_attr_span.enter();
    }

    #[warn(clippy :: suspicious_else_formatting)]
    {

        #[allow(unknown_lints, unreachable_code, clippy ::
        diverging_sub_expression, clippy :: empty_loop, clippy ::
        let_unit_value, clippy :: let_with_type_underscore, clippy ::
        needless_return, clippy :: unreachable)]
        if false {
            let __tracing_attr_fake_return: &'hir hir::ConstArg<'hir> =
                loop {};
            return __tracing_attr_fake_return;
        }
        {
            let tcx = self.tcx;
            let is_trivial_path =
                path.is_potential_trivial_const_arg() &&
                    #[allow(non_exhaustive_omitted_patterns)] match res {
                        Res::Def(DefKind::ConstParam, _) => true,
                        _ => false,
                    };
            let ct_kind =
                if is_trivial_path || tcx.features().min_generic_const_args()
                    {
                    let qpath =
                        self.lower_qpath(ty_id, &None, path, ParamMode::Explicit,
                            AllowReturnTypeNotation::No,
                            ImplTraitContext::Disallowed(ImplTraitPosition::Path),
                            None);
                    hir::ConstArgKind::Path(qpath)
                } else {
                    let node_id = self.next_node_id();
                    let span = self.lower_span(span);
                    let def_id =
                        self.create_def(node_id, None, DefKind::AnonConst, span);
                    let hir_id = self.lower_node_id(node_id);
                    let path_expr =
                        Expr {
                            id: ty_id,
                            kind: ExprKind::Path(None, path.clone()),
                            span,
                            attrs: AttrVec::new(),
                            tokens: None,
                        };
                    let ct =
                        self.with_new_scopes(span,
                            |this|
                                {
                                    self.arena.alloc(hir::AnonConst {
                                            def_id,
                                            hir_id,
                                            body: this.lower_const_body(path_expr.span,
                                                Some(&path_expr)),
                                            span,
                                        })
                                });
                    hir::ConstArgKind::Anon(ct)
                };
            self.arena.alloc(hir::ConstArg {
                    hir_id: self.next_id(),
                    kind: ct_kind,
                    span: self.lower_span(span),
                })
        }
    }
}#[instrument(level = "debug", skip(self))]
2541    fn lower_const_path_to_const_arg(
2542        &mut self,
2543        path: &Path,
2544        res: Res<NodeId>,
2545        ty_id: NodeId,
2546        span: Span,
2547    ) -> &'hir hir::ConstArg<'hir> {
2548        let tcx = self.tcx;
2549
2550        let is_trivial_path = path.is_potential_trivial_const_arg()
2551            && matches!(res, Res::Def(DefKind::ConstParam, _));
2552        let ct_kind = if is_trivial_path || tcx.features().min_generic_const_args() {
2553            let qpath = self.lower_qpath(
2554                ty_id,
2555                &None,
2556                path,
2557                ParamMode::Explicit,
2558                AllowReturnTypeNotation::No,
2559                // FIXME(mgca): update for `fn foo() -> Bar<FOO<impl Trait>>` support
2560                ImplTraitContext::Disallowed(ImplTraitPosition::Path),
2561                None,
2562            );
2563            hir::ConstArgKind::Path(qpath)
2564        } else {
2565            // Construct an AnonConst where the expr is the "ty"'s path.
2566            let node_id = self.next_node_id();
2567            let span = self.lower_span(span);
2568
2569            // Add a definition for the in-band const def.
2570            // We're lowering a const argument that was originally thought to be a type argument,
2571            // so the def collector didn't create the def ahead of time. That's why we have to do
2572            // it here.
2573            let def_id = self.create_def(node_id, None, DefKind::AnonConst, span);
2574            let hir_id = self.lower_node_id(node_id);
2575
2576            let path_expr = Expr {
2577                id: ty_id,
2578                kind: ExprKind::Path(None, path.clone()),
2579                span,
2580                attrs: AttrVec::new(),
2581                tokens: None,
2582            };
2583
2584            let ct = self.with_new_scopes(span, |this| {
2585                self.arena.alloc(hir::AnonConst {
2586                    def_id,
2587                    hir_id,
2588                    body: this.lower_const_body(path_expr.span, Some(&path_expr)),
2589                    span,
2590                })
2591            });
2592            hir::ConstArgKind::Anon(ct)
2593        };
2594
2595        self.arena.alloc(hir::ConstArg {
2596            hir_id: self.next_id(),
2597            kind: ct_kind,
2598            span: self.lower_span(span),
2599        })
2600    }
2601
2602    fn lower_const_item_rhs(
2603        &mut self,
2604        rhs_kind: &ConstItemRhsKind,
2605        span: Span,
2606    ) -> hir::ConstItemRhs<'hir> {
2607        match rhs_kind {
2608            ConstItemRhsKind::Body { rhs: Some(body) } => {
2609                hir::ConstItemRhs::Body(self.lower_const_body(span, Some(body)))
2610            }
2611            ConstItemRhsKind::Body { rhs: None } => {
2612                hir::ConstItemRhs::Body(self.lower_const_body(span, None))
2613            }
2614            ConstItemRhsKind::TypeConst { rhs: Some(anon) } => {
2615                hir::ConstItemRhs::TypeConst(self.lower_anon_const_to_const_arg_and_alloc(anon))
2616            }
2617            ConstItemRhsKind::TypeConst { rhs: None } => {
2618                let const_arg = ConstArg {
2619                    hir_id: self.next_id(),
2620                    kind: hir::ConstArgKind::Error(
2621                        self.dcx().span_delayed_bug(DUMMY_SP, "no block"),
2622                    ),
2623                    span: DUMMY_SP,
2624                };
2625                hir::ConstItemRhs::TypeConst(self.arena.alloc(const_arg))
2626            }
2627        }
2628    }
2629
2630    x;#[instrument(level = "debug", skip(self), ret)]
2631    fn lower_expr_to_const_arg_direct(&mut self, expr: &Expr) -> hir::ConstArg<'hir> {
2632        let span = self.lower_span(expr.span);
2633
2634        let overly_complex_const = |this: &mut Self| {
2635            let msg = "complex const arguments must be placed inside of a `const` block";
2636            let e = if expr::WillCreateDefIdsVisitor.visit_expr(expr).is_break() {
2637                // FIXME(mgca): make this non-fatal once we have a better way to handle
2638                // nested items in const args
2639                // Issue: https://github.com/rust-lang/rust/issues/154539
2640                this.dcx().struct_span_fatal(expr.span, msg).emit()
2641            } else {
2642                this.dcx().struct_span_err(expr.span, msg).emit()
2643            };
2644
2645            ConstArg { hir_id: this.next_id(), kind: hir::ConstArgKind::Error(e), span }
2646        };
2647
2648        match &expr.kind {
2649            ExprKind::Call(func, args) if let ExprKind::Path(qself, path) = &func.kind => {
2650                let qpath = self.lower_qpath(
2651                    func.id,
2652                    qself,
2653                    path,
2654                    ParamMode::Explicit,
2655                    AllowReturnTypeNotation::No,
2656                    ImplTraitContext::Disallowed(ImplTraitPosition::Path),
2657                    None,
2658                );
2659
2660                let lowered_args = self.arena.alloc_from_iter(args.iter().map(|arg| {
2661                    let const_arg = self.lower_expr_to_const_arg_direct(arg);
2662                    &*self.arena.alloc(const_arg)
2663                }));
2664
2665                ConstArg {
2666                    hir_id: self.next_id(),
2667                    kind: hir::ConstArgKind::TupleCall(qpath, lowered_args),
2668                    span,
2669                }
2670            }
2671            ExprKind::Tup(exprs) => {
2672                let exprs = self.arena.alloc_from_iter(exprs.iter().map(|expr| {
2673                    let expr = self.lower_expr_to_const_arg_direct(&expr);
2674                    &*self.arena.alloc(expr)
2675                }));
2676
2677                ConstArg { hir_id: self.next_id(), kind: hir::ConstArgKind::Tup(exprs), span }
2678            }
2679            ExprKind::Path(qself, path) => {
2680                let qpath = self.lower_qpath(
2681                    expr.id,
2682                    qself,
2683                    path,
2684                    ParamMode::Explicit,
2685                    AllowReturnTypeNotation::No,
2686                    // FIXME(mgca): update for `fn foo() -> Bar<FOO<impl Trait>>` support
2687                    ImplTraitContext::Disallowed(ImplTraitPosition::Path),
2688                    None,
2689                );
2690
2691                ConstArg { hir_id: self.next_id(), kind: hir::ConstArgKind::Path(qpath), span }
2692            }
2693            ExprKind::Struct(se) => {
2694                let path = self.lower_qpath(
2695                    expr.id,
2696                    &se.qself,
2697                    &se.path,
2698                    // FIXME(mgca): we may want this to be `Optional` instead, but
2699                    // we would also need to make sure that HIR ty lowering errors
2700                    // when these paths wind up in signatures.
2701                    ParamMode::Explicit,
2702                    AllowReturnTypeNotation::No,
2703                    ImplTraitContext::Disallowed(ImplTraitPosition::Path),
2704                    None,
2705                );
2706
2707                let fields = self.arena.alloc_from_iter(se.fields.iter().map(|f| {
2708                    let hir_id = self.lower_node_id(f.id);
2709                    // FIXME(mgca): This might result in lowering attributes that
2710                    // then go unused as the `Target::ExprField` is not actually
2711                    // corresponding to `Node::ExprField`.
2712                    self.lower_attrs(hir_id, &f.attrs, f.span, Target::ExprField);
2713                    let expr = self.lower_expr_to_const_arg_direct(&f.expr);
2714
2715                    &*self.arena.alloc(hir::ConstArgExprField {
2716                        hir_id,
2717                        field: self.lower_ident(f.ident),
2718                        expr: self.arena.alloc(expr),
2719                        span: self.lower_span(f.span),
2720                    })
2721                }));
2722
2723                ConstArg {
2724                    hir_id: self.next_id(),
2725                    kind: hir::ConstArgKind::Struct(path, fields),
2726                    span,
2727                }
2728            }
2729            ExprKind::Array(elements) => {
2730                let lowered_elems = self.arena.alloc_from_iter(elements.iter().map(|element| {
2731                    let const_arg = self.lower_expr_to_const_arg_direct(element);
2732                    &*self.arena.alloc(const_arg)
2733                }));
2734                let array_expr = self.arena.alloc(hir::ConstArgArrayExpr {
2735                    span: self.lower_span(expr.span),
2736                    elems: lowered_elems,
2737                });
2738
2739                ConstArg {
2740                    hir_id: self.next_id(),
2741                    kind: hir::ConstArgKind::Array(array_expr),
2742                    span,
2743                }
2744            }
2745            ExprKind::Underscore => ConstArg {
2746                hir_id: self.lower_node_id(expr.id),
2747                kind: hir::ConstArgKind::Infer(()),
2748                span,
2749            },
2750            ExprKind::Block(block, _) => {
2751                if let [stmt] = block.stmts.as_slice()
2752                    && let StmtKind::Expr(expr) = &stmt.kind
2753                {
2754                    return self.lower_expr_to_const_arg_direct(expr);
2755                }
2756
2757                overly_complex_const(self)
2758            }
2759            ExprKind::Lit(literal) => {
2760                let span = self.lower_span(expr.span);
2761                let literal = self.lower_lit(literal, span);
2762
2763                ConstArg {
2764                    hir_id: self.lower_node_id(expr.id),
2765                    kind: hir::ConstArgKind::Literal { lit: literal.node, negated: false },
2766                    span,
2767                }
2768            }
2769            ExprKind::Unary(UnOp::Neg, inner_expr)
2770                if let ExprKind::Lit(literal) = &inner_expr.kind =>
2771            {
2772                let span = self.lower_span(expr.span);
2773                let literal = self.lower_lit(literal, span);
2774
2775                if !matches!(literal.node, LitKind::Int(..)) {
2776                    let err =
2777                        self.dcx().struct_span_err(expr.span, "negated literal must be an integer");
2778
2779                    return ConstArg {
2780                        hir_id: self.next_id(),
2781                        kind: hir::ConstArgKind::Error(err.emit()),
2782                        span,
2783                    };
2784                }
2785
2786                ConstArg {
2787                    hir_id: self.lower_node_id(expr.id),
2788                    kind: hir::ConstArgKind::Literal { lit: literal.node, negated: true },
2789                    span,
2790                }
2791            }
2792            ExprKind::ConstBlock(anon_const) => {
2793                let def_id = self.local_def_id(anon_const.id);
2794                assert_eq!(DefKind::AnonConst, self.tcx.def_kind(def_id));
2795                self.lower_anon_const_to_const_arg(anon_const, span)
2796            }
2797            _ => overly_complex_const(self),
2798        }
2799    }
2800
2801    /// See [`hir::ConstArg`] for when to use this function vs
2802    /// [`Self::lower_anon_const_to_anon_const`].
2803    fn lower_anon_const_to_const_arg_and_alloc(
2804        &mut self,
2805        anon: &AnonConst,
2806    ) -> &'hir hir::ConstArg<'hir> {
2807        self.arena.alloc(self.lower_anon_const_to_const_arg(anon, anon.value.span))
2808    }
2809
2810    #[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_anon_const_to_const_arg",
                                    "rustc_ast_lowering", ::tracing::Level::DEBUG,
                                    ::tracing_core::__macro_support::Option::Some("compiler/rustc_ast_lowering/src/lib.rs"),
                                    ::tracing_core::__macro_support::Option::Some(2810u32),
                                    ::tracing_core::__macro_support::Option::Some("rustc_ast_lowering"),
                                    ::tracing_core::field::FieldSet::new(&["anon", "span"],
                                        ::tracing_core::callsite::Identifier(&__CALLSITE)),
                                    ::tracing::metadata::Kind::SPAN)
                            };
                        ::tracing::callsite::DefaultCallsite::new(&META)
                    };
                let mut interest = ::tracing::subscriber::Interest::never();
                if ::tracing::Level::DEBUG <=
                                    ::tracing::level_filters::STATIC_MAX_LEVEL &&
                                ::tracing::Level::DEBUG <=
                                    ::tracing::level_filters::LevelFilter::current() &&
                            { interest = __CALLSITE.interest(); !interest.is_never() }
                        &&
                        ::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
                            interest) {
                    let meta = __CALLSITE.metadata();
                    ::tracing::Span::new(meta,
                        &{
                                #[allow(unused_imports)]
                                use ::tracing::field::{debug, display, Value};
                                let mut iter = meta.fields().iter();
                                meta.fields().value_set(&[(&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
                                                    ::tracing::__macro_support::Option::Some(&::tracing::field::debug(&anon)
                                                            as &dyn Value)),
                                                (&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
                                                    ::tracing::__macro_support::Option::Some(&::tracing::field::debug(&span)
                                                            as &dyn Value))])
                            })
                } else {
                    let span =
                        ::tracing::__macro_support::__disabled_span(__CALLSITE.metadata());
                    {};
                    span
                }
            };
        __tracing_attr_guard = __tracing_attr_span.enter();
    }

    #[warn(clippy :: suspicious_else_formatting)]
    {

        #[allow(unknown_lints, unreachable_code, clippy ::
        diverging_sub_expression, clippy :: empty_loop, clippy ::
        let_unit_value, clippy :: let_with_type_underscore, clippy ::
        needless_return, clippy :: unreachable)]
        if false {
            let __tracing_attr_fake_return: hir::ConstArg<'hir> = loop {};
            return __tracing_attr_fake_return;
        }
        {
            let tcx = self.tcx;
            if tcx.features().min_generic_const_args() {
                return match anon.mgca_disambiguation {
                        MgcaDisambiguation::AnonConst => {
                            let lowered_anon =
                                self.lower_anon_const_to_anon_const(anon, span);
                            ConstArg {
                                hir_id: self.next_id(),
                                kind: hir::ConstArgKind::Anon(lowered_anon),
                                span: lowered_anon.span,
                            }
                        }
                        MgcaDisambiguation::Direct =>
                            self.lower_expr_to_const_arg_direct(&anon.value),
                    };
            }
            let expr =
                if let ExprKind::Block(block, _) = &anon.value.kind &&
                                let [stmt] = block.stmts.as_slice() &&
                            let StmtKind::Expr(expr) = &stmt.kind &&
                        let ExprKind::Path(..) = &expr.kind {
                    expr
                } else { &anon.value };
            let maybe_res =
                self.get_partial_res(expr.id).and_then(|partial_res|
                        partial_res.full_res());
            if let ExprKind::Path(qself, path) = &expr.kind &&
                        path.is_potential_trivial_const_arg() &&
                    #[allow(non_exhaustive_omitted_patterns)] match maybe_res {
                        Some(Res::Def(DefKind::ConstParam, _)) => true,
                        _ => false,
                    } {
                let qpath =
                    self.lower_qpath(expr.id, qself, path, ParamMode::Explicit,
                        AllowReturnTypeNotation::No,
                        ImplTraitContext::Disallowed(ImplTraitPosition::Path),
                        None);
                return ConstArg {
                        hir_id: self.lower_node_id(anon.id),
                        kind: hir::ConstArgKind::Path(qpath),
                        span: self.lower_span(expr.span),
                    };
            }
            let lowered_anon =
                self.lower_anon_const_to_anon_const(anon, anon.value.span);
            ConstArg {
                hir_id: self.next_id(),
                kind: hir::ConstArgKind::Anon(lowered_anon),
                span: self.lower_span(expr.span),
            }
        }
    }
}#[instrument(level = "debug", skip(self))]
2811    fn lower_anon_const_to_const_arg(
2812        &mut self,
2813        anon: &AnonConst,
2814        span: Span,
2815    ) -> hir::ConstArg<'hir> {
2816        let tcx = self.tcx;
2817
2818        // We cannot change parsing depending on feature gates available,
2819        // we can only require feature gates to be active as a delayed check.
2820        // Thus we just parse anon consts generally and make the real decision
2821        // making in ast lowering.
2822        // FIXME(min_generic_const_args): revisit once stable
2823        if tcx.features().min_generic_const_args() {
2824            return match anon.mgca_disambiguation {
2825                MgcaDisambiguation::AnonConst => {
2826                    let lowered_anon = self.lower_anon_const_to_anon_const(anon, span);
2827                    ConstArg {
2828                        hir_id: self.next_id(),
2829                        kind: hir::ConstArgKind::Anon(lowered_anon),
2830                        span: lowered_anon.span,
2831                    }
2832                }
2833                MgcaDisambiguation::Direct => self.lower_expr_to_const_arg_direct(&anon.value),
2834            };
2835        }
2836
2837        // Unwrap a block, so that e.g. `{ P }` is recognised as a parameter. Const arguments
2838        // currently have to be wrapped in curly brackets, so it's necessary to special-case.
2839        let expr = if let ExprKind::Block(block, _) = &anon.value.kind
2840            && let [stmt] = block.stmts.as_slice()
2841            && let StmtKind::Expr(expr) = &stmt.kind
2842            && let ExprKind::Path(..) = &expr.kind
2843        {
2844            expr
2845        } else {
2846            &anon.value
2847        };
2848
2849        let maybe_res =
2850            self.get_partial_res(expr.id).and_then(|partial_res| partial_res.full_res());
2851        if let ExprKind::Path(qself, path) = &expr.kind
2852            && path.is_potential_trivial_const_arg()
2853            && matches!(maybe_res, Some(Res::Def(DefKind::ConstParam, _)))
2854        {
2855            let qpath = self.lower_qpath(
2856                expr.id,
2857                qself,
2858                path,
2859                ParamMode::Explicit,
2860                AllowReturnTypeNotation::No,
2861                ImplTraitContext::Disallowed(ImplTraitPosition::Path),
2862                None,
2863            );
2864
2865            return ConstArg {
2866                hir_id: self.lower_node_id(anon.id),
2867                kind: hir::ConstArgKind::Path(qpath),
2868                span: self.lower_span(expr.span),
2869            };
2870        }
2871
2872        let lowered_anon = self.lower_anon_const_to_anon_const(anon, anon.value.span);
2873        ConstArg {
2874            hir_id: self.next_id(),
2875            kind: hir::ConstArgKind::Anon(lowered_anon),
2876            span: self.lower_span(expr.span),
2877        }
2878    }
2879
2880    /// See [`hir::ConstArg`] for when to use this function vs
2881    /// [`Self::lower_anon_const_to_const_arg`].
2882    fn lower_anon_const_to_anon_const(
2883        &mut self,
2884        c: &AnonConst,
2885        span: Span,
2886    ) -> &'hir hir::AnonConst {
2887        self.arena.alloc(self.with_new_scopes(c.value.span, |this| {
2888            let def_id = this.local_def_id(c.id);
2889            let hir_id = this.lower_node_id(c.id);
2890            hir::AnonConst {
2891                def_id,
2892                hir_id,
2893                body: this.lower_const_body(c.value.span, Some(&c.value)),
2894                span: this.lower_span(span),
2895            }
2896        }))
2897    }
2898
2899    fn lower_unsafe_source(&mut self, u: UnsafeSource) -> hir::UnsafeSource {
2900        match u {
2901            CompilerGenerated => hir::UnsafeSource::CompilerGenerated,
2902            UserProvided => hir::UnsafeSource::UserProvided,
2903        }
2904    }
2905
2906    fn lower_trait_bound_modifiers(
2907        &mut self,
2908        modifiers: TraitBoundModifiers,
2909    ) -> hir::TraitBoundModifiers {
2910        let constness = match modifiers.constness {
2911            BoundConstness::Never => BoundConstness::Never,
2912            BoundConstness::Always(span) => BoundConstness::Always(self.lower_span(span)),
2913            BoundConstness::Maybe(span) => BoundConstness::Maybe(self.lower_span(span)),
2914        };
2915        let polarity = match modifiers.polarity {
2916            BoundPolarity::Positive => BoundPolarity::Positive,
2917            BoundPolarity::Negative(span) => BoundPolarity::Negative(self.lower_span(span)),
2918            BoundPolarity::Maybe(span) => BoundPolarity::Maybe(self.lower_span(span)),
2919        };
2920        hir::TraitBoundModifiers { constness, polarity }
2921    }
2922
2923    // Helper methods for building HIR.
2924
2925    fn stmt(&mut self, span: Span, kind: hir::StmtKind<'hir>) -> hir::Stmt<'hir> {
2926        hir::Stmt { span: self.lower_span(span), kind, hir_id: self.next_id() }
2927    }
2928
2929    fn stmt_expr(&mut self, span: Span, expr: hir::Expr<'hir>) -> hir::Stmt<'hir> {
2930        self.stmt(span, hir::StmtKind::Expr(self.arena.alloc(expr)))
2931    }
2932
2933    fn stmt_let_pat(
2934        &mut self,
2935        attrs: Option<&'hir [hir::Attribute]>,
2936        span: Span,
2937        init: Option<&'hir hir::Expr<'hir>>,
2938        pat: &'hir hir::Pat<'hir>,
2939        source: hir::LocalSource,
2940    ) -> hir::Stmt<'hir> {
2941        let hir_id = self.next_id();
2942        if let Some(a) = attrs {
2943            if !!a.is_empty() {
    ::core::panicking::panic("assertion failed: !a.is_empty()")
};assert!(!a.is_empty());
2944            self.attrs.insert(hir_id.local_id, a);
2945        }
2946        let local = hir::LetStmt {
2947            super_: None,
2948            hir_id,
2949            init,
2950            pat,
2951            els: None,
2952            source,
2953            span: self.lower_span(span),
2954            ty: None,
2955        };
2956        self.stmt(span, hir::StmtKind::Let(self.arena.alloc(local)))
2957    }
2958
2959    fn stmt_super_let_pat(
2960        &mut self,
2961        span: Span,
2962        pat: &'hir hir::Pat<'hir>,
2963        init: Option<&'hir hir::Expr<'hir>>,
2964    ) -> hir::Stmt<'hir> {
2965        let hir_id = self.next_id();
2966        let span = self.lower_span(span);
2967        let local = hir::LetStmt {
2968            super_: Some(span),
2969            hir_id,
2970            init,
2971            pat,
2972            els: None,
2973            source: hir::LocalSource::Normal,
2974            span,
2975            ty: None,
2976        };
2977        self.stmt(span, hir::StmtKind::Let(self.arena.alloc(local)))
2978    }
2979
2980    fn block_expr(&mut self, expr: &'hir hir::Expr<'hir>) -> &'hir hir::Block<'hir> {
2981        self.block_all(expr.span, &[], Some(expr))
2982    }
2983
2984    fn block_all(
2985        &mut self,
2986        span: Span,
2987        stmts: &'hir [hir::Stmt<'hir>],
2988        expr: Option<&'hir hir::Expr<'hir>>,
2989    ) -> &'hir hir::Block<'hir> {
2990        let blk = hir::Block {
2991            stmts,
2992            expr,
2993            hir_id: self.next_id(),
2994            rules: hir::BlockCheckMode::DefaultBlock,
2995            span: self.lower_span(span),
2996            targeted_by_break: false,
2997        };
2998        self.arena.alloc(blk)
2999    }
3000
3001    fn pat_cf_continue(&mut self, span: Span, pat: &'hir hir::Pat<'hir>) -> &'hir hir::Pat<'hir> {
3002        let field = self.single_pat_field(span, pat);
3003        self.pat_lang_item_variant(span, hir::LangItem::ControlFlowContinue, field)
3004    }
3005
3006    fn pat_cf_break(&mut self, span: Span, pat: &'hir hir::Pat<'hir>) -> &'hir hir::Pat<'hir> {
3007        let field = self.single_pat_field(span, pat);
3008        self.pat_lang_item_variant(span, hir::LangItem::ControlFlowBreak, field)
3009    }
3010
3011    fn pat_some(&mut self, span: Span, pat: &'hir hir::Pat<'hir>) -> &'hir hir::Pat<'hir> {
3012        let field = self.single_pat_field(span, pat);
3013        self.pat_lang_item_variant(span, hir::LangItem::OptionSome, field)
3014    }
3015
3016    fn pat_none(&mut self, span: Span) -> &'hir hir::Pat<'hir> {
3017        self.pat_lang_item_variant(span, hir::LangItem::OptionNone, &[])
3018    }
3019
3020    fn single_pat_field(
3021        &mut self,
3022        span: Span,
3023        pat: &'hir hir::Pat<'hir>,
3024    ) -> &'hir [hir::PatField<'hir>] {
3025        let field = hir::PatField {
3026            hir_id: self.next_id(),
3027            ident: Ident::new(sym::integer(0), self.lower_span(span)),
3028            is_shorthand: false,
3029            pat,
3030            span: self.lower_span(span),
3031        };
3032        self.arena.alloc_from_iter([field])arena_vec![self; field]
3033    }
3034
3035    fn pat_lang_item_variant(
3036        &mut self,
3037        span: Span,
3038        lang_item: hir::LangItem,
3039        fields: &'hir [hir::PatField<'hir>],
3040    ) -> &'hir hir::Pat<'hir> {
3041        let path = self.make_lang_item_qpath(lang_item, self.lower_span(span), None);
3042        self.pat(span, hir::PatKind::Struct(path, fields, None))
3043    }
3044
3045    fn pat_ident(&mut self, span: Span, ident: Ident) -> (&'hir hir::Pat<'hir>, HirId) {
3046        self.pat_ident_binding_mode(span, ident, hir::BindingMode::NONE)
3047    }
3048
3049    fn pat_ident_mut(&mut self, span: Span, ident: Ident) -> (hir::Pat<'hir>, HirId) {
3050        self.pat_ident_binding_mode_mut(span, ident, hir::BindingMode::NONE)
3051    }
3052
3053    fn pat_ident_binding_mode(
3054        &mut self,
3055        span: Span,
3056        ident: Ident,
3057        bm: hir::BindingMode,
3058    ) -> (&'hir hir::Pat<'hir>, HirId) {
3059        let (pat, hir_id) = self.pat_ident_binding_mode_mut(span, ident, bm);
3060        (self.arena.alloc(pat), hir_id)
3061    }
3062
3063    fn pat_ident_binding_mode_mut(
3064        &mut self,
3065        span: Span,
3066        ident: Ident,
3067        bm: hir::BindingMode,
3068    ) -> (hir::Pat<'hir>, HirId) {
3069        let hir_id = self.next_id();
3070
3071        (
3072            hir::Pat {
3073                hir_id,
3074                kind: hir::PatKind::Binding(bm, hir_id, self.lower_ident(ident), None),
3075                span: self.lower_span(span),
3076                default_binding_modes: true,
3077            },
3078            hir_id,
3079        )
3080    }
3081
3082    fn pat(&mut self, span: Span, kind: hir::PatKind<'hir>) -> &'hir hir::Pat<'hir> {
3083        self.arena.alloc(hir::Pat {
3084            hir_id: self.next_id(),
3085            kind,
3086            span: self.lower_span(span),
3087            default_binding_modes: true,
3088        })
3089    }
3090
3091    fn pat_without_dbm(&mut self, span: Span, kind: hir::PatKind<'hir>) -> hir::Pat<'hir> {
3092        hir::Pat {
3093            hir_id: self.next_id(),
3094            kind,
3095            span: self.lower_span(span),
3096            default_binding_modes: false,
3097        }
3098    }
3099
3100    fn ty_path(&mut self, mut hir_id: HirId, span: Span, qpath: hir::QPath<'hir>) -> hir::Ty<'hir> {
3101        let kind = match qpath {
3102            hir::QPath::Resolved(None, path) => {
3103                // Turn trait object paths into `TyKind::TraitObject` instead.
3104                match path.res {
3105                    Res::Def(DefKind::Trait | DefKind::TraitAlias, _) => {
3106                        let principal = hir::PolyTraitRef {
3107                            bound_generic_params: &[],
3108                            modifiers: hir::TraitBoundModifiers::NONE,
3109                            trait_ref: hir::TraitRef { path, hir_ref_id: hir_id },
3110                            span: self.lower_span(span),
3111                        };
3112
3113                        // The original ID is taken by the `PolyTraitRef`,
3114                        // so the `Ty` itself needs a different one.
3115                        hir_id = self.next_id();
3116                        hir::TyKind::TraitObject(
3117                            self.arena.alloc_from_iter([principal])arena_vec![self; principal],
3118                            TaggedRef::new(self.elided_dyn_bound(span), TraitObjectSyntax::None),
3119                        )
3120                    }
3121                    _ => hir::TyKind::Path(hir::QPath::Resolved(None, path)),
3122                }
3123            }
3124            _ => hir::TyKind::Path(qpath),
3125        };
3126
3127        hir::Ty { hir_id, kind, span: self.lower_span(span) }
3128    }
3129
3130    /// Invoked to create the lifetime argument(s) for an elided trait object
3131    /// bound, like the bound in `Box<dyn Debug>`. This method is not invoked
3132    /// when the bound is written, even if it is written with `'_` like in
3133    /// `Box<dyn Debug + '_>`. In those cases, `lower_lifetime` is invoked.
3134    fn elided_dyn_bound(&mut self, span: Span) -> &'hir hir::Lifetime {
3135        let r = hir::Lifetime::new(
3136            self.next_id(),
3137            Ident::new(kw::UnderscoreLifetime, self.lower_span(span)),
3138            hir::LifetimeKind::ImplicitObjectLifetimeDefault,
3139            LifetimeSource::Other,
3140            LifetimeSyntax::Implicit,
3141        );
3142        {
    use ::tracing::__macro_support::Callsite as _;
    static __CALLSITE: ::tracing::callsite::DefaultCallsite =
        {
            static META: ::tracing::Metadata<'static> =
                {
                    ::tracing_core::metadata::Metadata::new("event compiler/rustc_ast_lowering/src/lib.rs:3142",
                        "rustc_ast_lowering", ::tracing::Level::DEBUG,
                        ::tracing_core::__macro_support::Option::Some("compiler/rustc_ast_lowering/src/lib.rs"),
                        ::tracing_core::__macro_support::Option::Some(3142u32),
                        ::tracing_core::__macro_support::Option::Some("rustc_ast_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};
                let mut iter = __CALLSITE.metadata().fields().iter();
                __CALLSITE.metadata().fields().value_set(&[(&::tracing::__macro_support::Iterator::next(&mut iter).expect("FieldSet corrupted (this is a bug)"),
                                    ::tracing::__macro_support::Option::Some(&format_args!("elided_dyn_bound: r={0:?}",
                                                    r) as &dyn Value))])
            });
    } else { ; }
};debug!("elided_dyn_bound: r={:?}", r);
3143        self.arena.alloc(r)
3144    }
3145}
3146
3147/// Helper struct for the delayed construction of [`hir::GenericArgs`].
3148struct GenericArgsCtor<'hir> {
3149    args: SmallVec<[hir::GenericArg<'hir>; 4]>,
3150    constraints: &'hir [hir::AssocItemConstraint<'hir>],
3151    parenthesized: hir::GenericArgsParentheses,
3152    span: Span,
3153}
3154
3155impl<'hir> GenericArgsCtor<'hir> {
3156    fn is_empty(&self) -> bool {
3157        self.args.is_empty()
3158            && self.constraints.is_empty()
3159            && self.parenthesized == hir::GenericArgsParentheses::No
3160    }
3161
3162    fn into_generic_args(self, this: &LoweringContext<'_, 'hir>) -> &'hir hir::GenericArgs<'hir> {
3163        let ga = hir::GenericArgs {
3164            args: this.arena.alloc_from_iter(self.args),
3165            constraints: self.constraints,
3166            parenthesized: self.parenthesized,
3167            span_ext: this.lower_span(self.span),
3168        };
3169        this.arena.alloc(ga)
3170    }
3171}