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, LazyLock};
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_ir::find_attr;
49use rustc_attr_ir::lang_items::LangItem;
50use rustc_attr_ir::target::Target;
51use rustc_attr_parsing::{AttributeParser, Recovery, ShouldEmit};
52use rustc_data_structures::fx::FxIndexMap;
53use rustc_data_structures::sorted_map::SortedMap;
54use rustc_data_structures::stable_hash::{StableHash, StableHasher};
55use rustc_data_structures::steal::Steal;
56use rustc_data_structures::tagged_ptr::TaggedRef;
57use rustc_errors::codes::*;
58use rustc_errors::{DiagArgFromDisplay, DiagCtxtHandle, ErrorGuaranteed};
59use rustc_hir::def::{CtorKind, DefKind, Namespace, PerNS, Res};
60use rustc_hir::def_id::{DefId, LOCAL_CRATE, LocalDefId, LocalDefIdMap};
61use rustc_hir::definitions::PerParentDisambiguatorState;
62use rustc_hir::lints::DelayedLint;
63use rustc_hir::{
64    self as hir, AngleBrackets, CRATE_OWNER_ID, ConstArg, GenericArg, HirId, ItemLocalMap,
65    LifetimeSource, LifetimeSyntax, MissingLifetimeKind, ParamName, TraitCandidate,
66};
67use rustc_index::{Idx, IndexSlice, IndexVec};
68use rustc_macros::extension;
69use rustc_middle::middle::resolve::{
70    AstOwner, LifetimeRes, PartialRes, PerOwnerResolverData, ResolverAstLowering,
71};
72use rustc_middle::queries::Providers;
73use rustc_middle::ty::TyCtxt;
74use rustc_session::diagnostics::add_feature_diagnostics;
75use rustc_span::symbol::{Ident, Symbol, kw, sym};
76use rustc_span::{DUMMY_SP, DesugaringKind, Span, span_bug};
77use smallvec::{SmallVec, smallvec};
78use thin_vec::ThinVec;
79use tracing::{debug, instrument, trace};
80
81use crate::diagnostics::{AssocTyParentheses, AssocTyParenthesesSub, MisplacedImplTrait};
82
83macro_rules! arena_vec {
84    ($this:expr; $($x:expr),*) => (
85        $this.arena.alloc_from_iter([$($x),*])
86    );
87}
88
89mod asm;
90mod block;
91mod contract;
92mod delegation;
93mod diagnostics;
94mod expr;
95mod format;
96mod index;
97mod item;
98mod pat;
99mod path;
100pub mod stability;
101
102pub fn provide(providers: &mut Providers) {
103    providers.index_ast = index_ast;
104    providers.lower_to_hir = lower_to_hir;
105    providers.resolve_type_relative_delegations =
106        delegation::resolution::resolve_type_relative_delegations;
107}
108
109#[cfg(debug_assertions)]
110pub(crate) mod re_lowering {
111    use rustc_ast::NodeId;
112    use rustc_ast::node_id::NodeMap;
113    use rustc_hir as hir;
114
115    use crate::LoweringContext;
116
117    #[derive(#[automatically_derived]
impl ::core::fmt::Debug for ReloweringChecker {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::debug_struct_field2_finish(f,
            "ReloweringChecker", "node_id_to_local_id",
            &self.node_id_to_local_id, "can_relower", &&self.can_relower)
    }
}Debug, #[automatically_derived]
impl ::core::default::Default for ReloweringChecker {
    #[inline]
    fn default() -> Self {
        Self {
            node_id_to_local_id: ::core::default::Default::default(),
            can_relower: ::core::default::Default::default(),
        }
    }
}Default)]
118    pub(crate) struct ReloweringChecker {
119        node_id_to_local_id: NodeMap<hir::ItemLocalId>,
120        can_relower: bool,
121    }
122
123    impl ReloweringChecker {
124        pub(crate) fn assert_node_is_not_relowered(
125            &mut self,
126            ast_node_id: NodeId,
127            local_id: hir::ItemLocalId,
128        ) {
129            if !self.can_relower {
130                let old = self.node_id_to_local_id.insert(ast_node_id, local_id);
131                {
    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);
            }
        }
    }
};assert_eq!(old, None);
132            }
133        }
134
135        pub(crate) fn allow_relowering<'a, 'hir, TRes>(
136            ctx: &mut LoweringContext<'a, 'hir>,
137            op: impl FnOnce(&mut LoweringContext<'a, 'hir>) -> TRes,
138        ) -> TRes {
139            if !!ctx.curr_owner.relowering_checker.can_relower {
    {
        ::core::panicking::panic_fmt(format_args!("reentrant relowering is not supported"));
    }
};assert!(
140                !ctx.curr_owner.relowering_checker.can_relower,
141                "reentrant relowering is not supported"
142            );
143
144            ctx.curr_owner.relowering_checker.can_relower = true;
145
146            let res = op(ctx);
147
148            ctx.curr_owner.relowering_checker.can_relower = false;
149
150            res
151        }
152    }
153}
154
155struct PerOwnerLoweringState<'a, 'hir> {
156    // -- Identity --
157    owner: &'a PerOwnerResolverData<'hir>,
158    disambiguator: PerParentDisambiguatorState,
159
160    // -- HirId allocation --
161    item_local_id_counter: hir::ItemLocalId,
162    /// NodeIds of pattern identifiers and labelled nodes that are lowered inside the current HIR
163    /// owner.
164    ident_and_label_to_local_id: NodeMap<hir::ItemLocalId>,
165    /// NodeIds that are lowered inside the current HIR owner. Only used for duplicate lowering
166    /// check.
167    #[cfg(debug_assertions)]
168    relowering_checker: re_lowering::ReloweringChecker,
169
170    // -- Accumulated outputs --
171    /// Attributes inside the owner being lowered.
172    attrs: SortedMap<hir::ItemLocalId, &'hir [rustc_attr_ir::Attribute]>,
173    /// Bodies inside the owner being lowered.
174    bodies: Vec<(hir::ItemLocalId, &'hir hir::Body<'hir>)>,
175    /// `#[define_opaque]` attributes
176    define_opaque: Option<&'hir [(Span, LocalDefId)]>,
177    trait_map: ItemLocalMap<&'hir [TraitCandidate<'hir>]>,
178    delayed_lints: Vec<DelayedLint>,
179    /// Collect items that were created by lowering the current owner.
180    children: LocalDefIdMap<hir::MaybeOwner<'hir>>,
181
182    // -- Transient --
183    impl_trait_defs: Vec<hir::GenericParam<'hir>>,
184    impl_trait_bounds: Vec<hir::WherePredicate<'hir>>,
185}
186
187impl<'a, 'hir> PerOwnerLoweringState<'a, 'hir> {
188    fn new(resolver: &'a ResolverAstLowering<'hir>, owner: NodeId) -> Self {
189        let owner = &resolver.owners[&owner];
190
191        let disambiguator = resolver
192            .disambiguators
193            .get(&owner.def_id)
194            .map(|s| s.steal())
195            .unwrap_or_else(|| PerParentDisambiguatorState::new(owner.def_id));
196
197        PerOwnerLoweringState {
198            owner,
199            disambiguator,
200            // 0 corresponds to `owner` lowered as `owner_id`, and we never call
201            // `lower_node_id(owner)`.
202            item_local_id_counter: hir::ItemLocalId::new(1),
203            ident_and_label_to_local_id: Default::default(),
204            #[cfg(debug_assertions)]
205            relowering_checker: Default::default(),
206            attrs: SortedMap::default(),
207            bodies: Vec::new(),
208            define_opaque: None,
209            trait_map: Default::default(),
210            delayed_lints: Vec::new(),
211            children: LocalDefIdMap::default(),
212            impl_trait_defs: Vec::new(),
213            impl_trait_bounds: Vec::new(),
214        }
215    }
216
217    fn owner_id(&self) -> hir::OwnerId {
218        hir::OwnerId { def_id: self.owner.def_id }
219    }
220
221    fn into_owner_info(
222        self,
223        tcx: TyCtxt<'hir>,
224        node: hir::OwnerNode<'hir>,
225    ) -> &'hir hir::OwnerInfo<'hir> {
226        {
    match (&self.owner_id(), &node.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);
            }
        }
    }
};assert_eq!(self.owner_id(), node.def_id());
227        if !self.impl_trait_defs.is_empty() {
    ::core::panicking::panic("assertion failed: self.impl_trait_defs.is_empty()")
};assert!(self.impl_trait_defs.is_empty());
228        if !self.impl_trait_bounds.is_empty() {
    ::core::panicking::panic("assertion failed: self.impl_trait_bounds.is_empty()")
};assert!(self.impl_trait_bounds.is_empty());
229
230        let attrs = self.attrs;
231        let mut bodies = self.bodies;
232        let define_opaque = self.define_opaque;
233        let trait_map = self.trait_map;
234        let delayed_lints = Steal::new(self.delayed_lints.into_boxed_slice());
235        let children = self.children;
236
237        #[cfg(debug_assertions)]
238        for (id, attrs) in attrs.iter() {
239            // Verify that we do not store empty slices in the map.
240            if attrs.is_empty() {
241                {
    ::core::panicking::panic_fmt(format_args!("Stored empty attributes for {0:?}",
            id));
};panic!("Stored empty attributes for {:?}", id);
242            }
243        }
244
245        bodies.sort_by_key(|(k, _)| *k);
246        let bodies = SortedMap::from_presorted_elements(bodies);
247
248        // Don't hash unless necessary, because it's expensive.
249        let rustc_middle::hir::Hashes { bodies_hash, attrs_hash } =
250            tcx.hash_owner_nodes(node, &bodies, &attrs, define_opaque);
251        let num_nodes = self.item_local_id_counter.as_usize();
252        let (nodes, parenting) = index::index_hir(tcx, node, &bodies, num_nodes);
253        let nodes = hir::OwnerNodes { opt_hash: bodies_hash, nodes, bodies };
254        let attrs = hir::AttributeMap { map: attrs, opt_hash: attrs_hash, define_opaque };
255
256        let opt_hash = tcx.needs_owner_info_hash().then(|| {
257            tcx.with_stable_hashing_context(|mut hcx| {
258                let mut stable_hasher = StableHasher::new();
259                bodies_hash.unwrap().stable_hash(&mut hcx, &mut stable_hasher);
260                attrs_hash.unwrap().stable_hash(&mut hcx, &mut stable_hasher);
261                // Do not hash delayed_lints.
262                parenting.stable_hash(&mut hcx, &mut stable_hasher);
263                trait_map.stable_hash(&mut hcx, &mut stable_hasher);
264                children.stable_hash(&mut hcx, &mut stable_hasher);
265                stable_hasher.finish()
266            })
267        });
268
269        tcx.hir_arena.alloc(hir::OwnerInfo {
270            opt_hash,
271            nodes,
272            parenting,
273            attrs,
274            trait_map,
275            delayed_lints,
276            children,
277        })
278    }
279}
280
281struct LoweringContext<'a, 'hir> {
282    tcx: TyCtxt<'hir>,
283    resolver: &'a ResolverAstLowering<'hir>,
284
285    curr_owner: PerOwnerLoweringState<'a, 'hir>,
286
287    /// Used to allocate HIR nodes.
288    arena: &'hir hir::Arena<'hir>,
289
290    contract_ensures: Option<(Span, Ident, HirId)>,
291
292    coroutine_kind: Option<hir::CoroutineKind>,
293
294    /// When inside an `async` context, this is the `HirId` of the
295    /// `task_context` local bound to the resume argument of the coroutine.
296    task_context: Option<HirId>,
297
298    /// Used to get the current `fn`'s def span to point to when using `await`
299    /// outside of an `async fn`.
300    current_item_span: Option<Span>,
301
302    try_block_scope: TryBlockScope,
303    loop_scope: Option<HirId>,
304    is_in_loop_condition: bool,
305    is_in_dyn_type: bool,
306
307    /// The `NodeId` space is split in two.
308    /// `0..resolver.next_node_id` are created by the resolver on the AST.
309    /// The higher part `resolver.next_node_id..next_node_id` are created during lowering.
310    next_node_id: NodeId,
311    /// Maps the `NodeId`s created during lowering to `LocalDefId`s.
312    node_id_to_def_id: NodeMap<LocalDefId>,
313    /// Overlay over resolver's `partial_res_map` used by delegation.
314    /// This only contains `PartialRes::new(Res::Local(self_param_id))`,
315    /// so we only store `self_param_id`.
316    partial_res_overrides: NodeMap<NodeId>,
317
318    /// Stack of `move(...)` collection states. A closure-like body pushes
319    /// `Some`, so `move(...)` expressions can record the generated locals they
320    /// should lower to. Nested bodies that cannot use `move(...)` push `None`.
321    move_expr_bindings: Vec<Option<expr::MoveExprState<'hir>>>,
322
323    /// Whether an initializer for a recorded `move(...)` is currently being lowered.
324    lowering_move_expr_initializer: bool,
325
326    attribute_parser: AttributeParser<'hir>,
327}
328
329macro_rules! allow {
330    ($($name:ident: $list:expr;)*) => {
331        $( static $name: LazyLock<Arc<[Symbol]>> = LazyLock::new(|| $list.into()); )*
332    }
333}
334
335static ALLOW_CONTRACTS: LazyLock<Arc<[Symbol]>> =
    LazyLock::new(|| [sym::contracts_internals].into());
static ALLOW_TRY_TRAIT: LazyLock<Arc<[Symbol]>> =
    LazyLock::new(||
            [sym::try_trait_v2, sym::try_trait_v2_residual,
                        sym::yeet_desugar_details].into());
static ALLOW_PATTERN_TYPE: LazyLock<Arc<[Symbol]>> =
    LazyLock::new(||
            [sym::pattern_types, sym::pattern_type_range_trait].into());
static ALLOW_GEN_FUTURE: LazyLock<Arc<[Symbol]>> =
    LazyLock::new(|| [sym::gen_future].into());
static ALLOW_GEN_FUTURE_WITH_ASYNC_FN_TRACK_CALLER: LazyLock<Arc<[Symbol]>> =
    LazyLock::new(|| [sym::gen_future, sym::closure_track_caller].into());
static ALLOW_FOR_AWAIT: LazyLock<Arc<[Symbol]>> =
    LazyLock::new(|| [sym::async_gen_internals, sym::async_iterator].into());
static ALLOW_ASYNC_FN_TRAITS: LazyLock<Arc<[Symbol]>> =
    LazyLock::new(|| [sym::async_fn_traits].into());
static ALLOW_ASYNC_GEN: LazyLock<Arc<[Symbol]>> =
    LazyLock::new(|| [sym::async_gen_internals].into());
static ALLOW_ASYNC_ITERATOR: LazyLock<Arc<[Symbol]>> =
    LazyLock::new(|| [sym::gen_future, sym::async_iterator].into());allow! {
336    ALLOW_CONTRACTS: [sym::contracts_internals];
337    ALLOW_TRY_TRAIT: [sym::try_trait_v2, sym::try_trait_v2_residual, sym::yeet_desugar_details];
338    ALLOW_PATTERN_TYPE: [sym::pattern_types, sym::pattern_type_range_trait];
339    ALLOW_GEN_FUTURE: [sym::gen_future];
340    ALLOW_GEN_FUTURE_WITH_ASYNC_FN_TRACK_CALLER: [sym::gen_future, sym::closure_track_caller];
341    ALLOW_FOR_AWAIT: [sym::async_gen_internals, sym::async_iterator];
342    ALLOW_ASYNC_FN_TRAITS: [sym::async_fn_traits];
343    ALLOW_ASYNC_GEN: [sym::async_gen_internals];
344    // FIXME(gen_blocks): how does `closure_track_caller`/`async_fn_track_caller`
345    // interact with `gen`/`async gen` blocks
346    ALLOW_ASYNC_ITERATOR: [sym::gen_future, sym::async_iterator];
347}
348
349impl<'a, 'hir> LoweringContext<'a, 'hir> {
350    fn new(tcx: TyCtxt<'hir>, resolver: &'a ResolverAstLowering<'hir>, owner: NodeId) -> Self {
351        Self {
352            tcx,
353            resolver,
354            curr_owner: PerOwnerLoweringState::new(resolver, owner),
355            arena: tcx.hir_arena,
356
357            contract_ensures: None,
358
359            next_node_id: resolver.next_node_id,
360            node_id_to_def_id: NodeMap::default(),
361            partial_res_overrides: NodeMap::default(),
362
363            // Lowering state.
364            try_block_scope: TryBlockScope::Function,
365            loop_scope: None,
366            is_in_loop_condition: false,
367            is_in_dyn_type: false,
368            coroutine_kind: None,
369            task_context: None,
370            current_item_span: None,
371
372            move_expr_bindings: Vec::new(),
373            lowering_move_expr_initializer: false,
374            attribute_parser: AttributeParser::new(
375                tcx.sess,
376                tcx.features(),
377                tcx.registered_attr_tools(()),
378                ShouldEmit::ErrorsAndLints { recovery: Recovery::Allowed },
379            ),
380        }
381    }
382
383    pub(crate) fn dcx(&self) -> DiagCtxtHandle<'hir> {
384        self.tcx.dcx()
385    }
386
387    fn allow_gen_future(&self) -> &Arc<[Symbol]> {
388        if self.tcx.features().async_fn_track_caller() {
389            &ALLOW_GEN_FUTURE_WITH_ASYNC_FN_TRACK_CALLER
390        } else {
391            &ALLOW_GEN_FUTURE
392        }
393    }
394}
395
396struct SpanLowerer {
397    is_incremental: bool,
398    def_id: LocalDefId,
399}
400
401impl SpanLowerer {
402    fn lower(&self, span: Span) -> Span {
403        if self.is_incremental {
404            span.with_parent(Some(self.def_id))
405        } else {
406            // Do not make spans relative when not using incremental compilation.
407            span
408        }
409    }
410}
411
412trait ResolverAstLoweringExt<'tcx> {
    fn legacy_const_generic_args(&self, expr: &Expr, tcx: TyCtxt<'tcx>)
    -> Option<Vec<usize>>;
}
impl<'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_attr_ir::HasAttrs::get_attrs(def_id, &tcx)
                            {
                            #[allow(unused_imports)]
                            use ::rustc_attr_ir::AttributeKind::*;
                            let i: &::rustc_attr_ir::Attribute = i;
                            match i {
                                ::rustc_attr_ir::Attribute::Parsed(RustcLegacyConstGenerics {
                                    fn_indexes, .. }) => {
                                    break 'done Some(fn_indexes);
                                }
                                ::rustc_attr_ir::Attribute::Unparsed(..) =>
                                    {}
                                    #[deny(unreachable_patterns)]
                                    _ => {}
                            }
                        }
                        None
                    }
                }
            }.map(|fn_indexes|
                fn_indexes.iter().map(|(num, _)| *num).collect())
    }
}#[extension(trait ResolverAstLoweringExt<'tcx>)]
413impl<'tcx> ResolverAstLowering<'tcx> {
414    fn legacy_const_generic_args(&self, expr: &Expr, tcx: TyCtxt<'tcx>) -> Option<Vec<usize>> {
415        let ExprKind::Path(None, path) = &expr.kind else {
416            return None;
417        };
418
419        // Don't perform legacy const generics rewriting if the path already
420        // has generic arguments.
421        if path.segments.last().unwrap().args.is_some() {
422            return None;
423        }
424
425        // We do not need to look at `partial_res_overrides`. That map only contains overrides for
426        // `self_param` locals. And here we are looking for the function definition that `expr`
427        // resolves to.
428        let def_id = self.partial_res_map.get(&expr.id)?.full_res()?.opt_def_id()?;
429
430        // We only support cross-crate argument rewriting. Uses
431        // within the same crate should be updated to use the new
432        // const generics style.
433        if def_id.is_local() {
434            return None;
435        }
436
437        // we can use parsed attrs here since for other crates they're already available
438        find_attr!(
439            tcx, def_id,
440            RustcLegacyConstGenerics{fn_indexes,..} => fn_indexes
441        )
442        .map(|fn_indexes| fn_indexes.iter().map(|(num, _)| *num).collect())
443    }
444}
445
446/// How relaxed bounds `?Trait` should be treated.
447///
448/// Relaxed bounds should only be allowed in places where we later
449/// (namely during HIR ty lowering) perform *sized elaboration*.
450#[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 {
            Self::Allowed(__self_0) =>
                ::core::fmt::Formatter::debug_tuple_field1_finish(f,
                    "Allowed", &__self_0),
            Self::Forbidden(__self_0) =>
                ::core::fmt::Formatter::debug_tuple_field1_finish(f,
                    "Forbidden", &__self_0),
        }
    }
}Debug)]
451enum RelaxedBoundPolicy<'a> {
452    /// The `DefId` refers to the trait that is being relaxed.
453    Allowed(&'a mut FxIndexMap<DefId, Span>),
454    Forbidden(RelaxedBoundForbiddenReason),
455}
456impl RelaxedBoundPolicy<'_> {
457    fn reborrow(&mut self) -> RelaxedBoundPolicy<'_> {
458        match self {
459            RelaxedBoundPolicy::Allowed(m) => RelaxedBoundPolicy::Allowed(m),
460            RelaxedBoundPolicy::Forbidden(reason) => RelaxedBoundPolicy::Forbidden(*reason),
461        }
462    }
463}
464
465#[derive(#[automatically_derived]
#[doc(hidden)]
unsafe impl ::core::clone::TrivialClone for RelaxedBoundForbiddenReason { }
#[automatically_derived]
impl ::core::clone::Clone for RelaxedBoundForbiddenReason {
    #[inline]
    fn clone(&self) -> Self { *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)]
466enum RelaxedBoundForbiddenReason {
467    TraitObjectTy,
468    SuperTrait,
469    TraitAlias,
470    AssocTyBounds,
471    /// We do not allow where bounds doing relaxed bounds,
472    /// except if it's for generic parameters of the current item.
473    WhereBound,
474}
475
476/// Context of `impl Trait` in code, which determines whether it is allowed in an HIR subtree,
477/// and if so, what meaning it has.
478#[derive(#[automatically_derived]
impl ::core::fmt::Debug for ImplTraitContext {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        match self {
            Self::Universal =>
                ::core::fmt::Formatter::write_str(f, "Universal"),
            Self::OpaqueTy { origin: __self_0 } =>
                ::core::fmt::Formatter::debug_struct_field1_finish(f,
                    "OpaqueTy", "origin", &__self_0),
            Self::InBinding =>
                ::core::fmt::Formatter::write_str(f, "InBinding"),
            Self::FeatureGated(__self_0, __self_1) =>
                ::core::fmt::Formatter::debug_tuple_field2_finish(f,
                    "FeatureGated", __self_0, &__self_1),
            Self::Disallowed(__self_0) =>
                ::core::fmt::Formatter::debug_tuple_field1_finish(f,
                    "Disallowed", &__self_0),
            Self::AlreadyErrored(__self_0) =>
                ::core::fmt::Formatter::debug_tuple_field1_finish(f,
                    "AlreadyErrored", &__self_0),
        }
    }
}Debug, #[automatically_derived]
impl ::core::marker::Copy for ImplTraitContext { }Copy, #[automatically_derived]
#[doc(hidden)]
unsafe impl ::core::clone::TrivialClone for ImplTraitContext { }
#[automatically_derived]
impl ::core::clone::Clone for ImplTraitContext {
    #[inline]
    fn clone(&self) -> Self {
        let _:
                ::core::clone::AssertParamIsClone<hir::OpaqueTyOrigin<LocalDefId>>;
        let _: ::core::clone::AssertParamIsClone<ImplTraitPosition>;
        let _: ::core::clone::AssertParamIsClone<Symbol>;
        let _: ::core::clone::AssertParamIsClone<ErrorGuaranteed>;
        *self
    }
}Clone, #[automatically_derived]
impl ::core::marker::StructuralPartialEq for ImplTraitContext { }
#[automatically_derived]
impl ::core::cmp::PartialEq for ImplTraitContext {
    #[inline]
    fn eq(&self, other: &Self) -> bool {
        ::core::intrinsics::discriminant_value(self) ==
                ::core::intrinsics::discriminant_value(other) &&
            match (self, other) {
                (Self::OpaqueTy { origin: __self_0 }, Self::OpaqueTy {
                    origin: __arg1_0 }) => __self_0 == __arg1_0,
                (Self::FeatureGated(__self_0, __self_1),
                    Self::FeatureGated(__arg1_0, __arg1_1)) =>
                    __self_0 == __arg1_0 && __self_1 == __arg1_1,
                (Self::Disallowed(__self_0), Self::Disallowed(__arg1_0)) =>
                    __self_0 == __arg1_0,
                (Self::AlreadyErrored(__self_0),
                    Self::AlreadyErrored(__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>;
        let _: ::core::cmp::AssertParamIsEq<ErrorGuaranteed>;
    }
}Eq)]
479enum ImplTraitContext {
480    /// Treat `impl Trait` as shorthand for a new universal generic parameter.
481    /// Example: `fn foo(x: impl Debug)`, where `impl Debug` is conceptually
482    /// equivalent to a fresh universal parameter like `fn foo<T: Debug>(x: T)`.
483    ///
484    /// Newly generated parameters should be inserted into the given `Vec`.
485    Universal,
486
487    /// Treat `impl Trait` as shorthand for a new opaque type.
488    /// Example: `fn foo() -> impl Debug`, where `impl Debug` is conceptually
489    /// equivalent to a new opaque type like `type T = impl Debug; fn foo() -> T`.
490    ///
491    OpaqueTy { origin: hir::OpaqueTyOrigin<LocalDefId> },
492
493    /// Treat `impl Trait` as a "trait ascription", which is like a type
494    /// variable but that also enforces that a set of trait goals hold.
495    ///
496    /// This is useful to guide inference for unnameable types.
497    InBinding,
498
499    /// `impl Trait` is unstably accepted in this position.
500    FeatureGated(ImplTraitPosition, Symbol),
501    /// `impl Trait` is not accepted in this position.
502    Disallowed(ImplTraitPosition),
503
504    /// An error has already been emitted for this type.
505    AlreadyErrored(ErrorGuaranteed),
506}
507
508/// Position in which `impl Trait` is disallowed.
509#[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]
#[doc(hidden)]
unsafe impl ::core::clone::TrivialClone for ImplTraitPosition { }
#[automatically_derived]
impl ::core::clone::Clone for ImplTraitPosition {
    #[inline]
    fn clone(&self) -> Self { *self }
}Clone, #[automatically_derived]
impl ::core::marker::StructuralPartialEq for ImplTraitPosition { }
#[automatically_derived]
impl ::core::cmp::PartialEq for ImplTraitPosition {
    #[inline]
    fn eq(&self, other: &Self) -> bool {
        ::core::intrinsics::discriminant_value(self) ==
            ::core::intrinsics::discriminant_value(other)
    }
}PartialEq, #[automatically_derived]
impl ::core::cmp::Eq for ImplTraitPosition { }Eq)]
510enum ImplTraitPosition {
511    Path,
512    Variable,
513    Trait,
514    Bound,
515    Generic,
516    ExternFnParam,
517    ClosureParam,
518    PointerParam,
519    FnTraitParam,
520    ExternFnReturn,
521    ClosureReturn,
522    PointerReturn,
523    FnTraitReturn,
524    GenericDefault,
525    ConstTy,
526    StaticTy,
527    AssocTy,
528    FieldTy,
529    Cast,
530    ImplSelf,
531    OffsetOf,
532}
533
534impl std::fmt::Display for ImplTraitPosition {
535    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
536        let name = match self {
537            ImplTraitPosition::Path => "paths",
538            ImplTraitPosition::Variable => "the type of variable bindings",
539            ImplTraitPosition::Trait => "traits",
540            ImplTraitPosition::Bound => "bounds",
541            ImplTraitPosition::Generic => "generics",
542            ImplTraitPosition::ExternFnParam => "`extern fn` parameters",
543            ImplTraitPosition::ClosureParam => "closure parameters",
544            ImplTraitPosition::PointerParam => "`fn` pointer parameters",
545            ImplTraitPosition::FnTraitParam => "the parameters of `Fn` trait bounds",
546            ImplTraitPosition::ExternFnReturn => "`extern fn` return types",
547            ImplTraitPosition::ClosureReturn => "closure return types",
548            ImplTraitPosition::PointerReturn => "`fn` pointer return types",
549            ImplTraitPosition::FnTraitReturn => "the return type of `Fn` trait bounds",
550            ImplTraitPosition::GenericDefault => "generic parameter defaults",
551            ImplTraitPosition::ConstTy => "const types",
552            ImplTraitPosition::StaticTy => "static types",
553            ImplTraitPosition::AssocTy => "associated types",
554            ImplTraitPosition::FieldTy => "field types",
555            ImplTraitPosition::Cast => "cast expression types",
556            ImplTraitPosition::ImplSelf => "impl headers",
557            ImplTraitPosition::OffsetOf => "`offset_of!` parameters",
558        };
559
560        f.write_fmt(format_args!("{0}", name))write!(f, "{name}")
561    }
562}
563
564#[derive(#[automatically_derived]
impl ::core::marker::Copy for FnDeclKind { }Copy, #[automatically_derived]
#[doc(hidden)]
unsafe impl ::core::clone::TrivialClone for FnDeclKind { }
#[automatically_derived]
impl ::core::clone::Clone for FnDeclKind {
    #[inline]
    fn clone(&self) -> Self { *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::marker::StructuralPartialEq for FnDeclKind { }
#[automatically_derived]
impl ::core::cmp::PartialEq for FnDeclKind {
    #[inline]
    fn eq(&self, other: &Self) -> bool {
        ::core::intrinsics::discriminant_value(self) ==
            ::core::intrinsics::discriminant_value(other)
    }
}PartialEq, #[automatically_derived]
impl ::core::cmp::Eq for FnDeclKind { }Eq)]
565enum FnDeclKind {
566    Fn,
567    Inherent,
568    ExternFn,
569    Closure,
570    Pointer,
571    Trait,
572    Impl,
573}
574
575#[derive(#[automatically_derived]
impl ::core::marker::Copy for TryBlockScope { }Copy, #[automatically_derived]
#[doc(hidden)]
unsafe impl ::core::clone::TrivialClone for TryBlockScope { }
#[automatically_derived]
impl ::core::clone::Clone for TryBlockScope {
    #[inline]
    fn clone(&self) -> Self {
        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 {
            Self::Function =>
                ::core::fmt::Formatter::write_str(f, "Function"),
            Self::Homogeneous(__self_0) =>
                ::core::fmt::Formatter::debug_tuple_field1_finish(f,
                    "Homogeneous", &__self_0),
            Self::Heterogeneous(__self_0) =>
                ::core::fmt::Formatter::debug_tuple_field1_finish(f,
                    "Heterogeneous", &__self_0),
        }
    }
}Debug)]
576enum TryBlockScope {
577    /// There isn't a `try` block, so a `?` will use `return`.
578    Function,
579    /// We're inside a `try { … }` block, so a `?` will block-break
580    /// from that block using a type depending only on the argument.
581    Homogeneous(HirId),
582    /// We're inside a `try as _ { … }` block, so a `?` will block-break
583    /// from that block using the type specified.
584    Heterogeneous(HirId),
585}
586
587fn index_ast<'tcx>(
588    tcx: TyCtxt<'tcx>,
589    (): (),
590) -> &'tcx IndexSlice<LocalDefId, Steal<(Arc<ResolverAstLowering<'tcx>>, AstOwner)>> {
591    // Queries that borrow `resolver_for_lowering`.
592    tcx.ensure_done().output_filenames(());
593    tcx.ensure_done().early_lint_checks(());
594    tcx.ensure_done().get_lang_items(());
595    tcx.ensure_done().debugger_visualizers(LOCAL_CRATE);
596
597    let (resolver, krate) = tcx.resolver_for_lowering();
598    let mut resolver = resolver.steal();
599    let mut krate = krate.steal();
600
601    let mut indexer = Indexer {
602        owners: &resolver.owners,
603        index: IndexVec::new(),
604        next_node_id: resolver.next_node_id,
605    };
606    indexer.visit_crate(&mut krate);
607    indexer.insert(CRATE_NODE_ID, AstOwner::Crate(Box::new(krate)));
608    resolver.next_node_id = indexer.next_node_id;
609
610    let index = indexer.index;
611    let resolver = Arc::new(resolver);
612    return tcx.arena.alloc_index_slice_from_iter::<LocalDefId, _, _>(
613        index.into_iter().map(|owner| Steal::new((Arc::clone(&resolver), owner))),
614    );
615
616    struct Indexer<'s, 'hir> {
617        owners: &'s NodeMap<PerOwnerResolverData<'hir>>,
618        index: IndexVec<LocalDefId, AstOwner>,
619        next_node_id: NodeId,
620    }
621
622    impl Indexer<'_, '_> {
623        fn insert(&mut self, id: NodeId, node: AstOwner) {
624            let def_id = self.owners[&id].def_id;
625            self.index.ensure_contains_elem(def_id, || AstOwner::NonOwner);
626            self.index[def_id] = node;
627        }
628
629        fn make_dummy<K>(
630            &mut self,
631            id: NodeId,
632            span: Span,
633            dummy: impl FnOnce(Box<MacCall>) -> K,
634        ) -> Box<Item<K>> {
635            use rustc_ast::token::Delimiter;
636            use rustc_ast::tokenstream::{DelimSpan, TokenStream};
637            use thin_vec::thin_vec;
638
639            Box::new(Item {
640                attrs: AttrVec::default(),
641                id,
642                span,
643                vis: Visibility { kind: VisibilityKind::Public, span },
644                // Lacking a better choice, we replace the contents with a macro call.
645                // Unexpanded macros should never reach lowering, so this is not confusing.
646                kind: dummy(Box::new(MacCall {
647                    path: Path { span, segments: ::thin_vec::ThinVec::new()thin_vec![] },
648                    args: Box::new(DelimArgs {
649                        dspan: DelimSpan::from_single(span),
650                        delim: Delimiter::Parenthesis,
651                        tokens: TokenStream::new(Vec::new()),
652                    }),
653                })),
654                tokens: None,
655            })
656        }
657
658        fn replace_with_dummy<K>(
659            &mut self,
660            item: &mut ast::Item<K>,
661            dummy: impl FnOnce(Box<MacCall>) -> K,
662            node: impl FnOnce(Box<Item<K>>) -> AstOwner,
663        ) {
664            let dummy = self.make_dummy(item.id, item.span, dummy);
665            let item = mem::replace(item, *dummy);
666            self.insert(item.id, node(Box::new(item)));
667        }
668    }
669
670    impl MutVisitor for Indexer<'_, '_> {
671        fn visit_attribute(&mut self, _: &mut Attribute) {
672            // We do not want to lower expressions that appear in attributes,
673            // as they are not accessible to the rest of the HIR.
674        }
675
676        fn flat_map_item(&mut self, mut item: Box<Item>) -> SmallVec<[Box<Item>; 1]> {
677            mut_visit::walk_item(self, &mut *item);
678            let dummy = self.make_dummy(item.id, item.span, ItemKind::MacCall);
679            let 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];
680            self.insert(item.id, AstOwner::Item(item));
681            items
682        }
683
684        fn visit_assoc_item(&mut self, item: &mut AssocItem, ctxt: visit::AssocCtxt) {
685            mut_visit::walk_assoc_item(self, item, ctxt);
686            match ctxt {
687                visit::AssocCtxt::Trait => {
688                    self.replace_with_dummy(item, AssocItemKind::MacCall, AstOwner::TraitItem)
689                }
690                visit::AssocCtxt::Impl { .. } => {
691                    self.replace_with_dummy(item, AssocItemKind::MacCall, AstOwner::ImplItem)
692                }
693            }
694        }
695
696        fn visit_foreign_item(&mut self, item: &mut ForeignItem) {
697            mut_visit::walk_item(self, item);
698            self.replace_with_dummy(item, ForeignItemKind::MacCall, AstOwner::ForeignItem);
699        }
700    }
701}
702
703{}
#[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("/rustc-dev/ea137335b78829b4514bf1b4c16302f74fab8581/compiler/rustc_ast_lowering/src/lib.rs"),
                                    ::tracing_core::__macro_support::Option::Some(703u32),
                                    ::tracing_core::__macro_support::Option::Some("rustc_ast_lowering"),
                                    ::tracing_core::field::FieldSet::new(&[{
                                                        const NAME:
                                                            ::tracing::__macro_support::FieldName<{
                                                                ::tracing::__macro_support::FieldName::len("def_id")
                                                            }> =
                                                            ::tracing::__macro_support::FieldName::new("def_id");
                                                        NAME.as_str()
                                                    }], ::tracing_core::callsite::Identifier(&__CALLSITE)),
                                    ::tracing::metadata::Kind::SPAN)
                            };
                        ::tracing::callsite::DefaultCallsite::new(&META)
                    };
                let mut interest = ::tracing::subscriber::Interest::never();
                if ::tracing::Level::TRACE <=
                                    ::tracing::level_filters::STATIC_MAX_LEVEL &&
                                ::tracing::Level::TRACE <=
                                    ::tracing::level_filters::LevelFilter::current() &&
                            { interest = __CALLSITE.interest(); !interest.is_never() }
                        &&
                        ::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
                            interest) {
                    let meta = __CALLSITE.metadata();
                    ::tracing::Span::new(meta,
                        &{
                                #[allow(unused_imports)]
                                use ::tracing::field::{debug, display, Value};
                                meta.fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&def_id)
                                                            as &dyn ::tracing::field::Value))])
                            })
                } else {
                    let span =
                        ::tracing::__macro_support::__disabled_span(__CALLSITE.metadata());
                    {};
                    span
                }
            };
        __tracing_attr_guard = __tracing_attr_span.enter();
    }

    #[warn(clippy :: suspicious_else_formatting)]
    {

        #[allow(unknown_lints, unreachable_code, clippy ::
        diverging_sub_expression, clippy :: empty_loop, clippy ::
        let_unit_value, clippy :: let_with_type_underscore, clippy ::
        needless_return, clippy :: unreachable)]
        if false {
            let __tracing_attr_fake_return: hir::MaybeOwner<'_> = loop {};
            return __tracing_attr_fake_return;
        }
        {
            tcx.ensure_done().resolve_type_relative_delegations(());
            let ast_index = tcx.index_ast(());
            let resolver_and_node = ast_index.get(def_id).map(Steal::steal);
            let fallback_to_ancestor =
                ||
                    {
                        let parent_id = tcx.local_parent(def_id);
                        let mut parent_info = tcx.lower_to_hir(parent_id);
                        while 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(||
                                    {
                                        ::rustc_span::macros::bug_impl(Some(tcx.source_span(def_id)),
                                            format_args!("{0:?} does not appear in children of {1:?}",
                                                def_id, parent_info.nodes.node().def_id()),
                                            Location::caller())
                                    })
                    };
            let Some((resolver, node)) =
                resolver_and_node else { return fallback_to_ancestor(); };
            fn with_lctx<'hir>(tcx: TyCtxt<'hir>,
                resolver: &ResolverAstLowering<'hir>, owner: NodeId,
                f:
                    impl FnOnce(&mut LoweringContext<'_, 'hir>)
                    -> hir::OwnerNode<'hir>) -> hir::MaybeOwner<'hir> {
                let mut lctx = LoweringContext::new(tcx, resolver, owner);
                let item = f(&mut lctx);
                hir::MaybeOwner::Owner(lctx.curr_owner.into_owner_info(tcx,
                        item))
            }
            let item =
                match &node {
                    AstOwner::Crate(c) =>
                        with_lctx(tcx, &*resolver, CRATE_NODE_ID,
                            |lctx|
                                {
                                    if true {
                                        {
                                            match (&lctx.curr_owner.owner_id(), &CRATE_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);
                                                    }
                                                }
                                            }
                                        };
                                    };
                                    let module = lctx.lower_mod(&c.items, &c.spans);
                                    lctx.lower_attrs(hir::CRATE_HIR_ID, &c.attrs,
                                        c.spans.inner_span, Target::Crate);
                                    hir::OwnerNode::Crate(module)
                                }),
                    AstOwner::Item(item) => {
                        with_lctx(tcx, &*resolver, item.id,
                            |lctx| hir::OwnerNode::Item(lctx.lower_item(item)))
                    }
                    AstOwner::TraitItem(item) =>
                        with_lctx(tcx, &*resolver, item.id,
                            |lctx|
                                { hir::OwnerNode::TraitItem(lctx.lower_trait_item(item)) }),
                    AstOwner::ImplItem(item) =>
                        with_lctx(tcx, &*resolver, item.id,
                            |lctx|
                                { hir::OwnerNode::ImplItem(lctx.lower_impl_item(item)) }),
                    AstOwner::ForeignItem(item) =>
                        with_lctx(tcx, &*resolver, item.id,
                            |lctx|
                                {
                                    hir::OwnerNode::ForeignItem(lctx.lower_foreign_item(item))
                                }),
                    AstOwner::NonOwner => fallback_to_ancestor(),
                };
            tcx.sess.time("drop_ast", || mem::drop(node));
            item
        }
    }
}#[instrument(level = "trace", skip(tcx))]
704fn lower_to_hir(tcx: TyCtxt<'_>, def_id: LocalDefId) -> hir::MaybeOwner<'_> {
705    tcx.ensure_done().resolve_type_relative_delegations(());
706
707    let ast_index = tcx.index_ast(());
708    let resolver_and_node = ast_index.get(def_id).map(Steal::steal);
709
710    let fallback_to_ancestor = || {
711        // The item did not exist in the AST, it was created while lowering another item.
712
713        let parent_id = tcx.local_parent(def_id);
714        let mut parent_info = tcx.lower_to_hir(parent_id);
715        while let hir::MaybeOwner::NonOwner(hir_id) = parent_info {
716            // `parent_id` could also not be a owner either.
717            // For instance if `def_id` is an enum variant field,
718            // the direct parent is the enum variant.
719            // In that case `hir_id.owner` point to the actual HIR owner
720            // and skips all non-owner parents, so fetch the HIR associated to it.
721            parent_info = tcx.lower_to_hir(hir_id.owner);
722        }
723
724        let parent_info = parent_info.unwrap();
725        *parent_info.children.get(&def_id).unwrap_or_else(|| {
726            span_bug!(
727                tcx.source_span(def_id),
728                "{:?} does not appear in children of {:?}",
729                def_id,
730                parent_info.nodes.node().def_id()
731            )
732        })
733    };
734
735    let Some((resolver, node)) = resolver_and_node else {
736        // `ast_index` does not contain all definitions, only up-to the highest
737        // `LocalDefId` which has a non-trivial `AstOwner`. Gracefully handle
738        // other definitions, in particular those nested inside this highest definition.
739        return fallback_to_ancestor();
740    };
741
742    fn with_lctx<'hir>(
743        tcx: TyCtxt<'hir>,
744        resolver: &ResolverAstLowering<'hir>,
745        owner: NodeId,
746        f: impl FnOnce(&mut LoweringContext<'_, 'hir>) -> hir::OwnerNode<'hir>,
747    ) -> hir::MaybeOwner<'hir> {
748        let mut lctx = LoweringContext::new(tcx, resolver, owner);
749        let item = f(&mut lctx);
750        hir::MaybeOwner::Owner(lctx.curr_owner.into_owner_info(tcx, item))
751    }
752
753    let item = match &node {
754        // The item existed in the AST.
755        AstOwner::Crate(c) => with_lctx(tcx, &*resolver, CRATE_NODE_ID, |lctx| {
756            debug_assert_eq!(lctx.curr_owner.owner_id(), CRATE_OWNER_ID);
757            let module = lctx.lower_mod(&c.items, &c.spans);
758            lctx.lower_attrs(hir::CRATE_HIR_ID, &c.attrs, c.spans.inner_span, Target::Crate);
759            hir::OwnerNode::Crate(module)
760        }),
761        AstOwner::Item(item) => {
762            with_lctx(tcx, &*resolver, item.id, |lctx| hir::OwnerNode::Item(lctx.lower_item(item)))
763        }
764        AstOwner::TraitItem(item) => with_lctx(tcx, &*resolver, item.id, |lctx| {
765            hir::OwnerNode::TraitItem(lctx.lower_trait_item(item))
766        }),
767        AstOwner::ImplItem(item) => with_lctx(tcx, &*resolver, item.id, |lctx| {
768            hir::OwnerNode::ImplItem(lctx.lower_impl_item(item))
769        }),
770        AstOwner::ForeignItem(item) => with_lctx(tcx, &*resolver, item.id, |lctx| {
771            hir::OwnerNode::ForeignItem(lctx.lower_foreign_item(item))
772        }),
773        // The item existed in the AST, but is not a HIR owner.
774        // Fetch the correct information from its parent.
775        AstOwner::NonOwner => fallback_to_ancestor(),
776    };
777
778    tcx.sess.time("drop_ast", || mem::drop(node));
779
780    item
781}
782
783#[derive(#[automatically_derived]
impl ::core::marker::Copy for ParamMode { }Copy, #[automatically_derived]
#[doc(hidden)]
unsafe impl ::core::clone::TrivialClone for ParamMode { }
#[automatically_derived]
impl ::core::clone::Clone for ParamMode {
    #[inline]
    fn clone(&self) -> Self { *self }
}Clone, #[automatically_derived]
impl ::core::marker::StructuralPartialEq for ParamMode { }
#[automatically_derived]
impl ::core::cmp::PartialEq for ParamMode {
    #[inline]
    fn eq(&self, other: &Self) -> bool {
        ::core::intrinsics::discriminant_value(self) ==
            ::core::intrinsics::discriminant_value(other)
    }
}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)]
784enum ParamMode {
785    /// Any path in a type context.
786    Explicit,
787    /// The `module::Type` in `module::Type::method` in an expression.
788    Optional,
789}
790
791#[derive(#[automatically_derived]
impl ::core::marker::Copy for AllowReturnTypeNotation { }Copy, #[automatically_derived]
#[doc(hidden)]
unsafe impl ::core::clone::TrivialClone for AllowReturnTypeNotation { }
#[automatically_derived]
impl ::core::clone::Clone for AllowReturnTypeNotation {
    #[inline]
    fn clone(&self) -> Self { *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)]
792enum AllowReturnTypeNotation {
793    /// Only in types, since RTN is denied later during HIR lowering.
794    Yes,
795    /// All other positions (path expr, method, use tree).
796    No,
797}
798
799enum GenericArgsMode {
800    /// Allow paren sugar, don't allow RTN.
801    ParenSugar,
802    /// Allow RTN, don't allow paren sugar.
803    ReturnTypeNotation,
804    /// Error if parenthesized generics or RTN are encountered.
805    Err,
806    /// Silence errors when lowering generics. Only used with `Res::Err`.
807    Silence,
808}
809
810#[derive(#[automatically_derived]
impl ::core::fmt::Debug for DiscardParams {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::write_str(f,
            match self {
                DiscardParams::Yes => "Yes",
                DiscardParams::No => "No",
            })
    }
}Debug, #[automatically_derived]
impl ::core::marker::Copy for DiscardParams { }Copy, #[automatically_derived]
#[doc(hidden)]
unsafe impl ::core::clone::TrivialClone for DiscardParams { }
#[automatically_derived]
impl ::core::clone::Clone for DiscardParams {
    #[inline]
    fn clone(&self) -> Self { *self }
}Clone)]
811enum DiscardParams {
812    /// Should be used for functions without a body. Lowers the attributes on the parameter and then discards them.
813    Yes,
814    /// Should be used for functions with a body. Does not lower the attributes, as lowering of the parameters is done by `lower_body`.
815    No,
816}
817
818impl<'hir> LoweringContext<'_, 'hir> {
819    fn create_def(
820        &mut self,
821        node_id: NodeId,
822        name: Option<Symbol>,
823        def_kind: DefKind,
824        span: Span,
825    ) -> LocalDefId {
826        let parent = self.curr_owner.owner_id().def_id;
827        {
    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);
828        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!(
829            self.opt_local_def_id(node_id).is_none(),
830            "adding a def'n for node-id {:?} and def kind {:?} but a previous def'n exists: {:?}",
831            node_id,
832            def_kind,
833            self.tcx.hir_def_key(self.local_def_id(node_id)),
834        );
835
836        let def_id = self
837            .tcx
838            .at(span)
839            .create_def(parent, name, def_kind, None, &mut self.curr_owner.disambiguator)
840            .def_id();
841
842        {
    use ::tracing::__macro_support::Callsite as _;
    static __CALLSITE: ::tracing::callsite::DefaultCallsite =
        {
            static META: ::tracing::Metadata<'static> =
                {
                    ::tracing_core::metadata::Metadata::new("event /rustc-dev/ea137335b78829b4514bf1b4c16302f74fab8581/compiler/rustc_ast_lowering/src/lib.rs:842",
                        "rustc_ast_lowering", ::tracing::Level::DEBUG,
                        ::tracing_core::__macro_support::Option::Some("/rustc-dev/ea137335b78829b4514bf1b4c16302f74fab8581/compiler/rustc_ast_lowering/src/lib.rs"),
                        ::tracing_core::__macro_support::Option::Some(842u32),
                        ::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};
                __CALLSITE.metadata().fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&format_args!("create_def: def_id_to_node_id[{0:?}] <-> {1:?}",
                                                    def_id, node_id) as &dyn ::tracing::field::Value))])
            });
    } else { ; }
};debug!("create_def: def_id_to_node_id[{:?}] <-> {:?}", def_id, node_id);
843        self.node_id_to_def_id.insert(node_id, def_id);
844
845        def_id
846    }
847
848    fn next_node_id(&mut self) -> NodeId {
849        let start = self.next_node_id;
850        let next = start.as_u32().checked_add(1).expect("input too large; ran out of NodeIds");
851        self.next_node_id = NodeId::from_u32(next);
852        start
853    }
854
855    /// Given the id of some node in the AST, finds the `LocalDefId` associated with it by the name
856    /// resolver (if any).
857    {}
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("opt_local_def_id",
                                "rustc_ast_lowering", ::tracing::Level::TRACE,
                                ::tracing_core::__macro_support::Option::Some("/rustc-dev/ea137335b78829b4514bf1b4c16302f74fab8581/compiler/rustc_ast_lowering/src/lib.rs"),
                                ::tracing_core::__macro_support::Option::Some(857u32),
                                ::tracing_core::__macro_support::Option::Some("rustc_ast_lowering"),
                                ::tracing_core::field::FieldSet::new(&[{
                                                    const NAME:
                                                        ::tracing::__macro_support::FieldName<{
                                                            ::tracing::__macro_support::FieldName::len("node")
                                                        }> =
                                                        ::tracing::__macro_support::FieldName::new("node");
                                                    NAME.as_str()
                                                }], ::tracing_core::callsite::Identifier(&__CALLSITE)),
                                ::tracing::metadata::Kind::SPAN)
                        };
                    ::tracing::callsite::DefaultCallsite::new(&META)
                };
            let mut interest = ::tracing::subscriber::Interest::never();
            if ::tracing::Level::TRACE <=
                                ::tracing::level_filters::STATIC_MAX_LEVEL &&
                            ::tracing::Level::TRACE <=
                                ::tracing::level_filters::LevelFilter::current() &&
                        { interest = __CALLSITE.interest(); !interest.is_never() }
                    &&
                    ::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
                        interest) {
                let meta = __CALLSITE.metadata();
                ::tracing::Span::new(meta,
                    &{
                            #[allow(unused_imports)]
                            use ::tracing::field::{debug, display, Value};
                            meta.fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&node)
                                                        as &dyn ::tracing::field::Value))])
                        })
            } else {
                let span =
                    ::tracing::__macro_support::__disabled_span(__CALLSITE.metadata());
                {};
                span
            }
        };
    __tracing_attr_guard = __tracing_attr_span.enter();
}
#[allow(clippy :: redundant_closure_call)]
let x =
    (move ||
                {

                    #[allow(unknown_lints, unreachable_code, clippy ::
                    diverging_sub_expression, clippy :: empty_loop, clippy ::
                    let_unit_value, clippy :: let_with_type_underscore, clippy
                    :: needless_return, clippy :: unreachable)]
                    if false {
                        let __tracing_attr_fake_return: Option<LocalDefId> =
                            loop {};
                        return __tracing_attr_fake_return;
                    }
                    {
                        self.node_id_to_def_id.get(&node).or_else(||
                                    self.curr_owner.owner.node_id_to_def_id.get(&node)).copied()
                    }
                })();
{
    use ::tracing::__macro_support::Callsite as _;
    static __CALLSITE: ::tracing::callsite::DefaultCallsite =
        {
            static META: ::tracing::Metadata<'static> =
                {
                    ::tracing_core::metadata::Metadata::new("event /rustc-dev/ea137335b78829b4514bf1b4c16302f74fab8581/compiler/rustc_ast_lowering/src/lib.rs:857",
                        "rustc_ast_lowering", ::tracing::Level::TRACE,
                        ::tracing_core::__macro_support::Option::Some("/rustc-dev/ea137335b78829b4514bf1b4c16302f74fab8581/compiler/rustc_ast_lowering/src/lib.rs"),
                        ::tracing_core::__macro_support::Option::Some(857u32),
                        ::tracing_core::__macro_support::Option::Some("rustc_ast_lowering"),
                        ::tracing_core::field::FieldSet::new(&[{
                                            const NAME:
                                                ::tracing::__macro_support::FieldName<{
                                                    ::tracing::__macro_support::FieldName::len("return")
                                                }> =
                                                ::tracing::__macro_support::FieldName::new("return");
                                            NAME.as_str()
                                        }], ::tracing_core::callsite::Identifier(&__CALLSITE)),
                        ::tracing::metadata::Kind::EVENT)
                };
            ::tracing::callsite::DefaultCallsite::new(&META)
        };
    let enabled =
        ::tracing::Level::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};
                __CALLSITE.metadata().fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&x)
                                            as &dyn ::tracing::field::Value))])
            });
    } else { ; }
};
x;#[instrument(level = "trace", skip(self), ret)]
858    fn opt_local_def_id(&self, node: NodeId) -> Option<LocalDefId> {
859        self.node_id_to_def_id
860            .get(&node)
861            .or_else(|| self.curr_owner.owner.node_id_to_def_id.get(&node))
862            .copied()
863    }
864
865    fn local_def_id(&self, node: NodeId) -> LocalDefId {
866        self.opt_local_def_id(node).unwrap_or_else(|| {
867            self.resolver.owners.items().any(|(id, items)| {
868                items.node_id_to_def_id.items().any(|(node_id, def_id)| {
869                    if *node_id == node {
870                        let actual_owner = items.node_id_to_def_id.get(id);
871                        {
    ::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})",)
872                    }
873                    false
874                })
875            });
876            {
    ::core::panicking::panic_fmt(format_args!("no entry for node id: `{0:?}`",
            node));
};panic!("no entry for node id: `{node:?}`");
877        })
878    }
879
880    fn get_partial_res(&self, id: NodeId) -> Option<PartialRes> {
881        match self.partial_res_overrides.get(&id) {
882            Some(self_param_id) => Some(PartialRes::new(Res::Local(*self_param_id))),
883            None => self.resolver.partial_res_map.get(&id).copied(),
884        }
885    }
886
887    /// Given the id of an owner node in the AST, returns the corresponding `OwnerId`.
888    fn owner_id(&self, node: NodeId) -> hir::OwnerId {
889        hir::OwnerId { def_id: self.resolver.owners[&node].def_id }
890    }
891
892    /// This method allocates a new `HirId` for the given `NodeId`.
893    /// Take care not to call this method if the resulting `HirId` is then not
894    /// actually used in the HIR, as that would trigger an assertion in the
895    /// `HirIdValidator` later on, which makes sure that all `NodeId`s got mapped
896    /// properly. Calling the method twice with the same `NodeId` is also forbidden.
897    {}
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_node_id",
                                "rustc_ast_lowering", ::tracing::Level::DEBUG,
                                ::tracing_core::__macro_support::Option::Some("/rustc-dev/ea137335b78829b4514bf1b4c16302f74fab8581/compiler/rustc_ast_lowering/src/lib.rs"),
                                ::tracing_core::__macro_support::Option::Some(897u32),
                                ::tracing_core::__macro_support::Option::Some("rustc_ast_lowering"),
                                ::tracing_core::field::FieldSet::new(&[{
                                                    const NAME:
                                                        ::tracing::__macro_support::FieldName<{
                                                            ::tracing::__macro_support::FieldName::len("ast_node_id")
                                                        }> =
                                                        ::tracing::__macro_support::FieldName::new("ast_node_id");
                                                    NAME.as_str()
                                                }], ::tracing_core::callsite::Identifier(&__CALLSITE)),
                                ::tracing::metadata::Kind::SPAN)
                        };
                    ::tracing::callsite::DefaultCallsite::new(&META)
                };
            let mut interest = ::tracing::subscriber::Interest::never();
            if ::tracing::Level::DEBUG <=
                                ::tracing::level_filters::STATIC_MAX_LEVEL &&
                            ::tracing::Level::DEBUG <=
                                ::tracing::level_filters::LevelFilter::current() &&
                        { interest = __CALLSITE.interest(); !interest.is_never() }
                    &&
                    ::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
                        interest) {
                let meta = __CALLSITE.metadata();
                ::tracing::Span::new(meta,
                    &{
                            #[allow(unused_imports)]
                            use ::tracing::field::{debug, display, Value};
                            meta.fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&ast_node_id)
                                                        as &dyn ::tracing::field::Value))])
                        })
            } else {
                let span =
                    ::tracing::__macro_support::__disabled_span(__CALLSITE.metadata());
                {};
                span
            }
        };
    __tracing_attr_guard = __tracing_attr_span.enter();
}
#[allow(clippy :: redundant_closure_call)]
let x =
    (move ||
                {

                    #[allow(unknown_lints, unreachable_code, clippy ::
                    diverging_sub_expression, clippy :: empty_loop, clippy ::
                    let_unit_value, clippy :: let_with_type_underscore, clippy
                    :: needless_return, clippy :: unreachable)]
                    if false {
                        let __tracing_attr_fake_return: HirId = loop {};
                        return __tracing_attr_fake_return;
                    }
                    {
                        {
                            match (&ast_node_id, &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);
                                    }
                                }
                            }
                        };
                        let owner = self.curr_owner.owner_id();
                        let local_id = self.curr_owner.item_local_id_counter;
                        {
                            match (&local_id, &hir::ItemLocalId::ZERO) {
                                (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);
                                    }
                                }
                            }
                        };
                        self.curr_owner.item_local_id_counter.increment_by(1);
                        let hir_id = HirId { owner, local_id };
                        if let Some(def_id) = self.opt_local_def_id(ast_node_id) {
                            self.curr_owner.children.insert(def_id,
                                hir::MaybeOwner::NonOwner(hir_id));
                        }
                        if let Some(traits) =
                                self.curr_owner.owner.trait_map.get(&ast_node_id) {
                            self.curr_owner.trait_map.insert(hir_id.local_id, *traits);
                        }
                        self.curr_owner.relowering_checker.assert_node_is_not_relowered(ast_node_id,
                            local_id);
                        hir_id
                    }
                })();
{
    use ::tracing::__macro_support::Callsite as _;
    static __CALLSITE: ::tracing::callsite::DefaultCallsite =
        {
            static META: ::tracing::Metadata<'static> =
                {
                    ::tracing_core::metadata::Metadata::new("event /rustc-dev/ea137335b78829b4514bf1b4c16302f74fab8581/compiler/rustc_ast_lowering/src/lib.rs:897",
                        "rustc_ast_lowering", ::tracing::Level::DEBUG,
                        ::tracing_core::__macro_support::Option::Some("/rustc-dev/ea137335b78829b4514bf1b4c16302f74fab8581/compiler/rustc_ast_lowering/src/lib.rs"),
                        ::tracing_core::__macro_support::Option::Some(897u32),
                        ::tracing_core::__macro_support::Option::Some("rustc_ast_lowering"),
                        ::tracing_core::field::FieldSet::new(&[{
                                            const NAME:
                                                ::tracing::__macro_support::FieldName<{
                                                    ::tracing::__macro_support::FieldName::len("return")
                                                }> =
                                                ::tracing::__macro_support::FieldName::new("return");
                                            NAME.as_str()
                                        }], ::tracing_core::callsite::Identifier(&__CALLSITE)),
                        ::tracing::metadata::Kind::EVENT)
                };
            ::tracing::callsite::DefaultCallsite::new(&META)
        };
    let enabled =
        ::tracing::Level::DEBUG <= ::tracing::level_filters::STATIC_MAX_LEVEL
                &&
                ::tracing::Level::DEBUG <=
                    ::tracing::level_filters::LevelFilter::current() &&
            {
                let interest = __CALLSITE.interest();
                !interest.is_never() &&
                    ::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
                        interest)
            };
    if enabled {
        (|value_set: ::tracing::field::ValueSet|
                    {
                        let meta = __CALLSITE.metadata();
                        ::tracing::Event::dispatch(meta, &value_set);
                        ;
                    })({
                #[allow(unused_imports)]
                use ::tracing::field::{debug, display, Value};
                __CALLSITE.metadata().fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&x)
                                            as &dyn ::tracing::field::Value))])
            });
    } else { ; }
};
x;#[instrument(level = "debug", skip(self), ret)]
898    fn lower_node_id(&mut self, ast_node_id: NodeId) -> HirId {
899        assert_ne!(ast_node_id, DUMMY_NODE_ID);
900
901        let owner = self.curr_owner.owner_id();
902        let local_id = self.curr_owner.item_local_id_counter;
903        assert_ne!(local_id, hir::ItemLocalId::ZERO);
904        self.curr_owner.item_local_id_counter.increment_by(1);
905        let hir_id = HirId { owner, local_id };
906
907        if let Some(def_id) = self.opt_local_def_id(ast_node_id) {
908            self.curr_owner.children.insert(def_id, hir::MaybeOwner::NonOwner(hir_id));
909        }
910
911        if let Some(traits) = self.curr_owner.owner.trait_map.get(&ast_node_id) {
912            self.curr_owner.trait_map.insert(hir_id.local_id, *traits);
913        }
914
915        // Check whether the same `NodeId` is lowered more than once.
916        #[cfg(debug_assertions)]
917        self.curr_owner.relowering_checker.assert_node_is_not_relowered(ast_node_id, local_id);
918
919        hir_id
920    }
921
922    /// Generate a new `HirId` without a backing `NodeId`.
923    {}
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("next_id",
                                "rustc_ast_lowering", ::tracing::Level::DEBUG,
                                ::tracing_core::__macro_support::Option::Some("/rustc-dev/ea137335b78829b4514bf1b4c16302f74fab8581/compiler/rustc_ast_lowering/src/lib.rs"),
                                ::tracing_core::__macro_support::Option::Some(923u32),
                                ::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_all(&[]) })
            } else {
                let span =
                    ::tracing::__macro_support::__disabled_span(__CALLSITE.metadata());
                {};
                span
            }
        };
    __tracing_attr_guard = __tracing_attr_span.enter();
}
#[allow(clippy :: redundant_closure_call)]
let x =
    (move ||
                {

                    #[allow(unknown_lints, unreachable_code, clippy ::
                    diverging_sub_expression, clippy :: empty_loop, clippy ::
                    let_unit_value, clippy :: let_with_type_underscore, clippy
                    :: needless_return, clippy :: unreachable)]
                    if false {
                        let __tracing_attr_fake_return: HirId = loop {};
                        return __tracing_attr_fake_return;
                    }
                    {
                        let owner = self.curr_owner.owner_id();
                        let local_id = self.curr_owner.item_local_id_counter;
                        {
                            match (&local_id, &hir::ItemLocalId::ZERO) {
                                (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);
                                    }
                                }
                            }
                        };
                        self.curr_owner.item_local_id_counter.increment_by(1);
                        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 /rustc-dev/ea137335b78829b4514bf1b4c16302f74fab8581/compiler/rustc_ast_lowering/src/lib.rs:923",
                        "rustc_ast_lowering", ::tracing::Level::DEBUG,
                        ::tracing_core::__macro_support::Option::Some("/rustc-dev/ea137335b78829b4514bf1b4c16302f74fab8581/compiler/rustc_ast_lowering/src/lib.rs"),
                        ::tracing_core::__macro_support::Option::Some(923u32),
                        ::tracing_core::__macro_support::Option::Some("rustc_ast_lowering"),
                        ::tracing_core::field::FieldSet::new(&[{
                                            const NAME:
                                                ::tracing::__macro_support::FieldName<{
                                                    ::tracing::__macro_support::FieldName::len("return")
                                                }> =
                                                ::tracing::__macro_support::FieldName::new("return");
                                            NAME.as_str()
                                        }], ::tracing_core::callsite::Identifier(&__CALLSITE)),
                        ::tracing::metadata::Kind::EVENT)
                };
            ::tracing::callsite::DefaultCallsite::new(&META)
        };
    let enabled =
        ::tracing::Level::DEBUG <= ::tracing::level_filters::STATIC_MAX_LEVEL
                &&
                ::tracing::Level::DEBUG <=
                    ::tracing::level_filters::LevelFilter::current() &&
            {
                let interest = __CALLSITE.interest();
                !interest.is_never() &&
                    ::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
                        interest)
            };
    if enabled {
        (|value_set: ::tracing::field::ValueSet|
                    {
                        let meta = __CALLSITE.metadata();
                        ::tracing::Event::dispatch(meta, &value_set);
                        ;
                    })({
                #[allow(unused_imports)]
                use ::tracing::field::{debug, display, Value};
                __CALLSITE.metadata().fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&x)
                                            as &dyn ::tracing::field::Value))])
            });
    } else { ; }
};
x;#[instrument(level = "debug", skip(self), ret)]
924    fn next_id(&mut self) -> HirId {
925        let owner = self.curr_owner.owner_id();
926        let local_id = self.curr_owner.item_local_id_counter;
927        assert_ne!(local_id, hir::ItemLocalId::ZERO);
928        self.curr_owner.item_local_id_counter.increment_by(1);
929        HirId { owner, local_id }
930    }
931
932    {}
#[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("/rustc-dev/ea137335b78829b4514bf1b4c16302f74fab8581/compiler/rustc_ast_lowering/src/lib.rs"),
                                    ::tracing_core::__macro_support::Option::Some(932u32),
                                    ::tracing_core::__macro_support::Option::Some("rustc_ast_lowering"),
                                    ::tracing_core::field::FieldSet::new(&[{
                                                        const NAME:
                                                            ::tracing::__macro_support::FieldName<{
                                                                ::tracing::__macro_support::FieldName::len("res")
                                                            }> =
                                                            ::tracing::__macro_support::FieldName::new("res");
                                                        NAME.as_str()
                                                    }], ::tracing_core::callsite::Identifier(&__CALLSITE)),
                                    ::tracing::metadata::Kind::SPAN)
                            };
                        ::tracing::callsite::DefaultCallsite::new(&META)
                    };
                let mut interest = ::tracing::subscriber::Interest::never();
                if ::tracing::Level::TRACE <=
                                    ::tracing::level_filters::STATIC_MAX_LEVEL &&
                                ::tracing::Level::TRACE <=
                                    ::tracing::level_filters::LevelFilter::current() &&
                            { interest = __CALLSITE.interest(); !interest.is_never() }
                        &&
                        ::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
                            interest) {
                    let meta = __CALLSITE.metadata();
                    ::tracing::Span::new(meta,
                        &{
                                #[allow(unused_imports)]
                                use ::tracing::field::{debug, display, Value};
                                meta.fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&res)
                                                            as &dyn ::tracing::field::Value))])
                            })
                } else {
                    let span =
                        ::tracing::__macro_support::__disabled_span(__CALLSITE.metadata());
                    {};
                    span
                }
            };
        __tracing_attr_guard = __tracing_attr_span.enter();
    }

    #[warn(clippy :: suspicious_else_formatting)]
    {

        #[allow(unknown_lints, unreachable_code, clippy ::
        diverging_sub_expression, clippy :: empty_loop, clippy ::
        let_unit_value, clippy :: let_with_type_underscore, clippy ::
        needless_return, clippy :: unreachable)]
        if false {
            let __tracing_attr_fake_return: Res = loop {};
            return __tracing_attr_fake_return;
        }
        {
            let res: Result<Res, ()> =
                res.apply_id(|id|
                        {
                            let owner = self.curr_owner.owner_id();
                            let local_id =
                                self.curr_owner.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 /rustc-dev/ea137335b78829b4514bf1b4c16302f74fab8581/compiler/rustc_ast_lowering/src/lib.rs:940",
                                    "rustc_ast_lowering", ::tracing::Level::TRACE,
                                    ::tracing_core::__macro_support::Option::Some("/rustc-dev/ea137335b78829b4514bf1b4c16302f74fab8581/compiler/rustc_ast_lowering/src/lib.rs"),
                                    ::tracing_core::__macro_support::Option::Some(940u32),
                                    ::tracing_core::__macro_support::Option::Some("rustc_ast_lowering"),
                                    ::tracing_core::field::FieldSet::new(&[{
                                                        const NAME:
                                                            ::tracing::__macro_support::FieldName<{
                                                                ::tracing::__macro_support::FieldName::len("res")
                                                            }> =
                                                            ::tracing::__macro_support::FieldName::new("res");
                                                        NAME.as_str()
                                                    }], ::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};
                            __CALLSITE.metadata().fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&res)
                                                        as &dyn ::tracing::field::Value))])
                        });
                } else { ; }
            };
            res.unwrap_or(Res::Err)
        }
    }
}#[instrument(level = "trace", skip(self))]
933    fn lower_res(&self, res: Res<NodeId>) -> Res {
934        let res: Result<Res, ()> = res.apply_id(|id| {
935            let owner = self.curr_owner.owner_id();
936            let local_id =
937                self.curr_owner.ident_and_label_to_local_id.get(&id).copied().ok_or(())?;
938            Ok(HirId { owner, local_id })
939        });
940        trace!(?res);
941
942        // We may fail to find a HirId when the Res points to a Local from an enclosing HIR owner.
943        // This can happen when trying to lower the return type `x` in erroneous code like
944        //   async fn foo(x: u8) -> x {}
945        // In that case, `x` is lowered as a function parameter, and the return type is lowered as
946        // an opaque type as a synthesized HIR owner.
947        res.unwrap_or(Res::Err)
948    }
949
950    fn expect_full_res(&self, id: NodeId) -> Res<NodeId> {
951        self.get_partial_res(id).map_or(Res::Err, |pr| pr.expect_full_res())
952    }
953
954    fn lower_import_res(&self, id: NodeId, span: Span) -> PerNS<Option<Res>> {
955        let per_ns = self
956            .curr_owner
957            .owner
958            .import_res
959            .get(&id)
960            .unwrap_or_else(|| {
961                let sp = self.tcx.source_span(self.curr_owner.owner.def_id);
962                self.tcx.dcx().span_delayed_bug(
963                    sp,
964                    "no import_res entry for import, \
965                        this should only happen if it already errored in resolve",
966                );
967                &PerNS { value_ns: None, type_ns: None, macro_ns: None }
968            })
969            .map(|res| res.map(|res| self.lower_res(res)));
970
971        if per_ns.is_empty() {
972            // Propagate the error to all namespaces, just to be sure.
973            self.dcx().span_delayed_bug(span, "no resolution for an import");
974            let err = Some(Res::Err);
975            return PerNS { type_ns: err, value_ns: err, macro_ns: err };
976        }
977        per_ns
978    }
979
980    fn make_lang_item_qpath(
981        &mut self,
982        lang_item: LangItem,
983        span: Span,
984        args: Option<&'hir hir::GenericArgs<'hir>>,
985    ) -> hir::QPath<'hir> {
986        hir::QPath::Resolved(None, self.make_lang_item_path(lang_item, span, args))
987    }
988
989    fn make_lang_item_path(
990        &mut self,
991        lang_item: LangItem,
992        span: Span,
993        args: Option<&'hir hir::GenericArgs<'hir>>,
994    ) -> &'hir hir::Path<'hir> {
995        let def_id = self.tcx.require_lang_item(lang_item, span);
996        let def_kind = self.tcx.def_kind(def_id);
997        let res = Res::Def(def_kind, def_id);
998        self.arena.alloc(hir::Path {
999            span,
1000            res,
1001            segments: self.arena.alloc_from_iter([hir::PathSegment {
1002                ident: Ident::new(lang_item.name(), span),
1003                hir_id: self.next_id(),
1004                res,
1005                args,
1006                infer_args: args.is_none(),
1007                delegation_child_segment: false,
1008            }]),
1009        })
1010    }
1011
1012    /// Reuses the span but adds information like the kind of the desugaring and features that are
1013    /// allowed inside this span.
1014    fn mark_span_with_reason(
1015        &self,
1016        reason: DesugaringKind,
1017        span: Span,
1018        allow_internal_unstable: Option<Arc<[Symbol]>>,
1019    ) -> Span {
1020        self.tcx.with_stable_hashing_context(|hcx| {
1021            span.mark_with_reason(allow_internal_unstable, reason, span.edition(), hcx)
1022        })
1023    }
1024
1025    fn span_lowerer(&self) -> SpanLowerer {
1026        SpanLowerer {
1027            is_incremental: self.tcx.sess.opts.incremental.is_some(),
1028            def_id: self.curr_owner.owner_id().def_id,
1029        }
1030    }
1031
1032    /// Intercept all spans entering HIR.
1033    /// Mark a span as relative to the current owning item.
1034    fn lower_span(&self, span: Span) -> Span {
1035        self.span_lowerer().lower(span)
1036    }
1037
1038    fn lower_ident(&self, ident: Ident) -> Ident {
1039        Ident::new(ident.name, self.lower_span(ident.span))
1040    }
1041
1042    /// Converts a lifetime into a new generic parameter.
1043    {}
#[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("/rustc-dev/ea137335b78829b4514bf1b4c16302f74fab8581/compiler/rustc_ast_lowering/src/lib.rs"),
                                    ::tracing_core::__macro_support::Option::Some(1043u32),
                                    ::tracing_core::__macro_support::Option::Some("rustc_ast_lowering"),
                                    ::tracing_core::field::FieldSet::new(&[{
                                                        const NAME:
                                                            ::tracing::__macro_support::FieldName<{
                                                                ::tracing::__macro_support::FieldName::len("ident")
                                                            }> =
                                                            ::tracing::__macro_support::FieldName::new("ident");
                                                        NAME.as_str()
                                                    },
                                                    {
                                                        const NAME:
                                                            ::tracing::__macro_support::FieldName<{
                                                                ::tracing::__macro_support::FieldName::len("node_id")
                                                            }> =
                                                            ::tracing::__macro_support::FieldName::new("node_id");
                                                        NAME.as_str()
                                                    },
                                                    {
                                                        const NAME:
                                                            ::tracing::__macro_support::FieldName<{
                                                                ::tracing::__macro_support::FieldName::len("kind")
                                                            }> =
                                                            ::tracing::__macro_support::FieldName::new("kind");
                                                        NAME.as_str()
                                                    },
                                                    {
                                                        const NAME:
                                                            ::tracing::__macro_support::FieldName<{
                                                                ::tracing::__macro_support::FieldName::len("source")
                                                            }> =
                                                            ::tracing::__macro_support::FieldName::new("source");
                                                        NAME.as_str()
                                                    }], ::tracing_core::callsite::Identifier(&__CALLSITE)),
                                    ::tracing::metadata::Kind::SPAN)
                            };
                        ::tracing::callsite::DefaultCallsite::new(&META)
                    };
                let mut interest = ::tracing::subscriber::Interest::never();
                if ::tracing::Level::DEBUG <=
                                    ::tracing::level_filters::STATIC_MAX_LEVEL &&
                                ::tracing::Level::DEBUG <=
                                    ::tracing::level_filters::LevelFilter::current() &&
                            { interest = __CALLSITE.interest(); !interest.is_never() }
                        &&
                        ::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
                            interest) {
                    let meta = __CALLSITE.metadata();
                    ::tracing::Span::new(meta,
                        &{
                                #[allow(unused_imports)]
                                use ::tracing::field::{debug, display, Value};
                                meta.fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&ident)
                                                            as &dyn ::tracing::field::Value)),
                                                (::tracing::__macro_support::Option::Some(&::tracing::field::debug(&node_id)
                                                            as &dyn ::tracing::field::Value)),
                                                (::tracing::__macro_support::Option::Some(&::tracing::field::debug(&kind)
                                                            as &dyn ::tracing::field::Value)),
                                                (::tracing::__macro_support::Option::Some(&::tracing::field::debug(&source)
                                                            as &dyn ::tracing::field::Value))])
                            })
                } else {
                    let span =
                        ::tracing::__macro_support::__disabled_span(__CALLSITE.metadata());
                    {};
                    span
                }
            };
        __tracing_attr_guard = __tracing_attr_span.enter();
    }

    #[warn(clippy :: suspicious_else_formatting)]
    {

        #[allow(unknown_lints, unreachable_code, clippy ::
        diverging_sub_expression, clippy :: empty_loop, clippy ::
        let_unit_value, clippy :: let_with_type_underscore, clippy ::
        needless_return, clippy :: unreachable)]
        if false {
            let __tracing_attr_fake_return: 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 /rustc-dev/ea137335b78829b4514bf1b4c16302f74fab8581/compiler/rustc_ast_lowering/src/lib.rs:1058",
                                    "rustc_ast_lowering", ::tracing::Level::DEBUG,
                                    ::tracing_core::__macro_support::Option::Some("/rustc-dev/ea137335b78829b4514bf1b4c16302f74fab8581/compiler/rustc_ast_lowering/src/lib.rs"),
                                    ::tracing_core::__macro_support::Option::Some(1058u32),
                                    ::tracing_core::__macro_support::Option::Some("rustc_ast_lowering"),
                                    ::tracing_core::field::FieldSet::new(&[{
                                                        const NAME:
                                                            ::tracing::__macro_support::FieldName<{
                                                                ::tracing::__macro_support::FieldName::len("_def_id")
                                                            }> =
                                                            ::tracing::__macro_support::FieldName::new("_def_id");
                                                        NAME.as_str()
                                                    }], ::tracing_core::callsite::Identifier(&__CALLSITE)),
                                    ::tracing::metadata::Kind::EVENT)
                            };
                        ::tracing::callsite::DefaultCallsite::new(&META)
                    };
                let enabled =
                    ::tracing::Level::DEBUG <=
                                ::tracing::level_filters::STATIC_MAX_LEVEL &&
                            ::tracing::Level::DEBUG <=
                                ::tracing::level_filters::LevelFilter::current() &&
                        {
                            let interest = __CALLSITE.interest();
                            !interest.is_never() &&
                                ::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
                                    interest)
                        };
                if enabled {
                    (|value_set: ::tracing::field::ValueSet|
                                {
                                    let meta = __CALLSITE.metadata();
                                    ::tracing::Event::dispatch(meta, &value_set);
                                    ;
                                })({
                            #[allow(unused_imports)]
                            use ::tracing::field::{debug, display, Value};
                            __CALLSITE.metadata().fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&_def_id)
                                                        as &dyn ::tracing::field::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))]
1044    fn lifetime_res_to_generic_param(
1045        &mut self,
1046        ident: Ident,
1047        node_id: NodeId,
1048        kind: MissingLifetimeKind,
1049        source: hir::GenericParamSource,
1050    ) -> hir::GenericParam<'hir> {
1051        // Late resolution delegates to us the creation of the `LocalDefId`.
1052        let _def_id = self.create_def(
1053            node_id,
1054            Some(kw::UnderscoreLifetime),
1055            DefKind::LifetimeParam,
1056            ident.span,
1057        );
1058        debug!(?_def_id);
1059
1060        let hir_id = self.lower_node_id(node_id);
1061        let def_id = self.local_def_id(node_id);
1062        hir::GenericParam {
1063            hir_id,
1064            def_id,
1065            name: hir::ParamName::Fresh,
1066            span: self.lower_span(ident.span),
1067            pure_wrt_drop: false,
1068            kind: hir::GenericParamKind::Lifetime { kind: hir::LifetimeParamKind::Elided(kind) },
1069            colon_span: None,
1070            source,
1071        }
1072    }
1073
1074    /// Lowers a lifetime binder that defines `generic_params`, returning the corresponding HIR
1075    /// nodes. The returned list includes any "extra" lifetime parameters that were added by the
1076    /// name resolver owing to lifetime elision; this also populates the resolver's node-id->def-id
1077    /// map, so that later calls to `opt_node_id_to_def_id` that refer to these extra lifetime
1078    /// parameters will be successful.
1079    {}
let __tracing_attr_span;
let __tracing_attr_guard;
if ::tracing::Level::DEBUG <= ::tracing::level_filters::STATIC_MAX_LEVEL &&
            ::tracing::Level::DEBUG <=
                ::tracing::level_filters::LevelFilter::current() || { false }
    {
    __tracing_attr_span =
        {
            use ::tracing::__macro_support::Callsite as _;
            static __CALLSITE: ::tracing::callsite::DefaultCallsite =
                {
                    static META: ::tracing::Metadata<'static> =
                        {
                            ::tracing_core::metadata::Metadata::new("lower_lifetime_binder",
                                "rustc_ast_lowering", ::tracing::Level::DEBUG,
                                ::tracing_core::__macro_support::Option::Some("/rustc-dev/ea137335b78829b4514bf1b4c16302f74fab8581/compiler/rustc_ast_lowering/src/lib.rs"),
                                ::tracing_core::__macro_support::Option::Some(1079u32),
                                ::tracing_core::__macro_support::Option::Some("rustc_ast_lowering"),
                                ::tracing_core::field::FieldSet::new(&[{
                                                    const NAME:
                                                        ::tracing::__macro_support::FieldName<{
                                                            ::tracing::__macro_support::FieldName::len("binder")
                                                        }> =
                                                        ::tracing::__macro_support::FieldName::new("binder");
                                                    NAME.as_str()
                                                },
                                                {
                                                    const NAME:
                                                        ::tracing::__macro_support::FieldName<{
                                                            ::tracing::__macro_support::FieldName::len("generic_params")
                                                        }> =
                                                        ::tracing::__macro_support::FieldName::new("generic_params");
                                                    NAME.as_str()
                                                }], ::tracing_core::callsite::Identifier(&__CALLSITE)),
                                ::tracing::metadata::Kind::SPAN)
                        };
                    ::tracing::callsite::DefaultCallsite::new(&META)
                };
            let mut interest = ::tracing::subscriber::Interest::never();
            if ::tracing::Level::DEBUG <=
                                ::tracing::level_filters::STATIC_MAX_LEVEL &&
                            ::tracing::Level::DEBUG <=
                                ::tracing::level_filters::LevelFilter::current() &&
                        { interest = __CALLSITE.interest(); !interest.is_never() }
                    &&
                    ::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
                        interest) {
                let meta = __CALLSITE.metadata();
                ::tracing::Span::new(meta,
                    &{
                            #[allow(unused_imports)]
                            use ::tracing::field::{debug, display, Value};
                            meta.fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&binder)
                                                        as &dyn ::tracing::field::Value)),
                                            (::tracing::__macro_support::Option::Some(&::tracing::field::debug(&generic_params)
                                                        as &dyn ::tracing::field::Value))])
                        })
            } else {
                let span =
                    ::tracing::__macro_support::__disabled_span(__CALLSITE.metadata());
                {};
                span
            }
        };
    __tracing_attr_guard = __tracing_attr_span.enter();
}
#[allow(clippy :: redundant_closure_call)]
let x =
    (move ||
                {

                    #[allow(unknown_lints, unreachable_code, clippy ::
                    diverging_sub_expression, clippy :: empty_loop, clippy ::
                    let_unit_value, clippy :: let_with_type_underscore, clippy
                    :: needless_return, clippy :: unreachable)]
                    if false {
                        let __tracing_attr_fake_return:
                                &'hir [hir::GenericParam<'hir>] = loop {};
                        return __tracing_attr_fake_return;
                    }
                    {
                        let extra_lifetimes =
                            self.curr_owner.owner.extra_lifetime_params(binder);
                        {
                            use ::tracing::__macro_support::Callsite as _;
                            static __CALLSITE: ::tracing::callsite::DefaultCallsite =
                                {
                                    static META: ::tracing::Metadata<'static> =
                                        {
                                            ::tracing_core::metadata::Metadata::new("event /rustc-dev/ea137335b78829b4514bf1b4c16302f74fab8581/compiler/rustc_ast_lowering/src/lib.rs:1089",
                                                "rustc_ast_lowering", ::tracing::Level::DEBUG,
                                                ::tracing_core::__macro_support::Option::Some("/rustc-dev/ea137335b78829b4514bf1b4c16302f74fab8581/compiler/rustc_ast_lowering/src/lib.rs"),
                                                ::tracing_core::__macro_support::Option::Some(1089u32),
                                                ::tracing_core::__macro_support::Option::Some("rustc_ast_lowering"),
                                                ::tracing_core::field::FieldSet::new(&[{
                                                                    const NAME:
                                                                        ::tracing::__macro_support::FieldName<{
                                                                            ::tracing::__macro_support::FieldName::len("extra_lifetimes")
                                                                        }> =
                                                                        ::tracing::__macro_support::FieldName::new("extra_lifetimes");
                                                                    NAME.as_str()
                                                                }], ::tracing_core::callsite::Identifier(&__CALLSITE)),
                                                ::tracing::metadata::Kind::EVENT)
                                        };
                                    ::tracing::callsite::DefaultCallsite::new(&META)
                                };
                            let enabled =
                                ::tracing::Level::DEBUG <=
                                            ::tracing::level_filters::STATIC_MAX_LEVEL &&
                                        ::tracing::Level::DEBUG <=
                                            ::tracing::level_filters::LevelFilter::current() &&
                                    {
                                        let interest = __CALLSITE.interest();
                                        !interest.is_never() &&
                                            ::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
                                                interest)
                                    };
                            if enabled {
                                (|value_set: ::tracing::field::ValueSet|
                                            {
                                                let meta = __CALLSITE.metadata();
                                                ::tracing::Event::dispatch(meta, &value_set);
                                                ;
                                            })({
                                        #[allow(unused_imports)]
                                        use ::tracing::field::{debug, display, Value};
                                        __CALLSITE.metadata().fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&extra_lifetimes)
                                                                    as &dyn ::tracing::field::Value))])
                                    });
                            } else { ; }
                        };
                        let extra_lifetimes: Vec<_> =
                            extra_lifetimes.iter().map(|&(ident, node_id, res)|
                                        {
                                            self.lifetime_res_to_generic_param(ident, node_id, res,
                                                hir::GenericParamSource::Binder)
                                        }).collect();
                        let arena = self.arena;
                        let explicit_generic_params =
                            self.lower_generic_params_mut(generic_params,
                                hir::GenericParamSource::Binder);
                        arena.alloc_from_iter(explicit_generic_params.chain(extra_lifetimes.into_iter()))
                    }
                })();
{
    use ::tracing::__macro_support::Callsite as _;
    static __CALLSITE: ::tracing::callsite::DefaultCallsite =
        {
            static META: ::tracing::Metadata<'static> =
                {
                    ::tracing_core::metadata::Metadata::new("event /rustc-dev/ea137335b78829b4514bf1b4c16302f74fab8581/compiler/rustc_ast_lowering/src/lib.rs:1079",
                        "rustc_ast_lowering", ::tracing::Level::DEBUG,
                        ::tracing_core::__macro_support::Option::Some("/rustc-dev/ea137335b78829b4514bf1b4c16302f74fab8581/compiler/rustc_ast_lowering/src/lib.rs"),
                        ::tracing_core::__macro_support::Option::Some(1079u32),
                        ::tracing_core::__macro_support::Option::Some("rustc_ast_lowering"),
                        ::tracing_core::field::FieldSet::new(&[{
                                            const NAME:
                                                ::tracing::__macro_support::FieldName<{
                                                    ::tracing::__macro_support::FieldName::len("return")
                                                }> =
                                                ::tracing::__macro_support::FieldName::new("return");
                                            NAME.as_str()
                                        }], ::tracing_core::callsite::Identifier(&__CALLSITE)),
                        ::tracing::metadata::Kind::EVENT)
                };
            ::tracing::callsite::DefaultCallsite::new(&META)
        };
    let enabled =
        ::tracing::Level::DEBUG <= ::tracing::level_filters::STATIC_MAX_LEVEL
                &&
                ::tracing::Level::DEBUG <=
                    ::tracing::level_filters::LevelFilter::current() &&
            {
                let interest = __CALLSITE.interest();
                !interest.is_never() &&
                    ::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
                        interest)
            };
    if enabled {
        (|value_set: ::tracing::field::ValueSet|
                    {
                        let meta = __CALLSITE.metadata();
                        ::tracing::Event::dispatch(meta, &value_set);
                        ;
                    })({
                #[allow(unused_imports)]
                use ::tracing::field::{debug, display, Value};
                __CALLSITE.metadata().fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&x)
                                            as &dyn ::tracing::field::Value))])
            });
    } else { ; }
};
x;#[instrument(level = "debug", skip(self), ret)]
1080    #[inline]
1081    fn lower_lifetime_binder(
1082        &mut self,
1083        binder: NodeId,
1084        generic_params: &[GenericParam],
1085    ) -> &'hir [hir::GenericParam<'hir>] {
1086        // Start by creating params for extra lifetimes params, as this creates the definitions
1087        // that may be referred to by the AST inside `generic_params`.
1088        let extra_lifetimes = self.curr_owner.owner.extra_lifetime_params(binder);
1089        debug!(?extra_lifetimes);
1090        let extra_lifetimes: Vec<_> = extra_lifetimes
1091            .iter()
1092            .map(|&(ident, node_id, res)| {
1093                self.lifetime_res_to_generic_param(
1094                    ident,
1095                    node_id,
1096                    res,
1097                    hir::GenericParamSource::Binder,
1098                )
1099            })
1100            .collect();
1101        let arena = self.arena;
1102        let explicit_generic_params =
1103            self.lower_generic_params_mut(generic_params, hir::GenericParamSource::Binder);
1104        arena.alloc_from_iter(explicit_generic_params.chain(extra_lifetimes.into_iter()))
1105    }
1106
1107    fn with_dyn_type_scope<T>(&mut self, in_scope: bool, f: impl FnOnce(&mut Self) -> T) -> T {
1108        let was_in_dyn_type = self.is_in_dyn_type;
1109        self.is_in_dyn_type = in_scope;
1110
1111        let result = f(self);
1112
1113        self.is_in_dyn_type = was_in_dyn_type;
1114
1115        result
1116    }
1117
1118    fn with_new_scopes<T>(&mut self, scope_span: Span, f: impl FnOnce(&mut Self) -> T) -> T {
1119        let current_item_span = self.current_item_span;
1120        self.current_item_span = Some(scope_span);
1121
1122        let was_in_loop_condition = self.is_in_loop_condition;
1123        self.is_in_loop_condition = false;
1124
1125        let old_contract = self.contract_ensures.take();
1126
1127        let try_block_scope = mem::replace(&mut self.try_block_scope, TryBlockScope::Function);
1128        let loop_scope = self.loop_scope.take();
1129        let ret = f(self);
1130        self.try_block_scope = try_block_scope;
1131        self.loop_scope = loop_scope;
1132
1133        self.contract_ensures = old_contract;
1134
1135        self.is_in_loop_condition = was_in_loop_condition;
1136
1137        self.current_item_span = current_item_span;
1138
1139        ret
1140    }
1141
1142    fn lower_attrs(
1143        &mut self,
1144        id: HirId,
1145        attrs: &[Attribute],
1146        target_span: Span,
1147        target: Target,
1148    ) -> &'hir [rustc_attr_ir::Attribute] {
1149        self.lower_attrs_with_extra(id, attrs, target_span, target, None, &[])
1150    }
1151
1152    fn lower_attrs_with_extra(
1153        &mut self,
1154        id: HirId,
1155        attrs: &[Attribute],
1156        target_span: Span,
1157        target: Target,
1158        target_item: Option<&ast::Item>,
1159        extra_hir_attributes: &[rustc_attr_ir::Attribute],
1160    ) -> &'hir [rustc_attr_ir::Attribute] {
1161        if attrs.is_empty() && extra_hir_attributes.is_empty() {
1162            &[]
1163        } else {
1164            let mut lowered_attrs =
1165                self.lower_attrs_vec(attrs, self.lower_span(target_span), id, target, target_item);
1166            lowered_attrs.extend(extra_hir_attributes.iter().cloned());
1167
1168            {
    match (&id.owner, &self.curr_owner.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);
            }
        }
    }
};assert_eq!(id.owner, self.curr_owner.owner_id());
1169            let ret = self.arena.alloc_from_iter(lowered_attrs);
1170
1171            // this is possible if an item contained syntactical attribute,
1172            // but none of them parse successfully or all of them were ignored
1173            // for not being built-in attributes at all. They could be remaining
1174            // unexpanded attributes used as markers in proc-macro derives for example.
1175            // This will have emitted some diagnostics for the misparse, but will then
1176            // not emit the attribute making the list empty.
1177            if ret.is_empty() {
1178                &[]
1179            } else {
1180                self.curr_owner.attrs.insert(id.local_id, ret);
1181                ret
1182            }
1183        }
1184    }
1185
1186    fn lower_attrs_vec(
1187        &mut self,
1188        attrs: &[Attribute],
1189        target_span: Span,
1190        target_hir_id: HirId,
1191        target: Target,
1192        target_item: Option<&ast::Item>,
1193    ) -> Vec<rustc_attr_ir::Attribute> {
1194        let l = self.span_lowerer();
1195        self.attribute_parser.parse_attribute_list(
1196            attrs,
1197            target_span,
1198            target,
1199            target_item,
1200            |s| l.lower(s),
1201            |lint_id, span, kind| {
1202                self.curr_owner.delayed_lints.push(DelayedLint {
1203                    lint_id,
1204                    id: target_hir_id,
1205                    span,
1206                    callback: Box::new(move |dcx, level, sess: &dyn std::any::Any| {
1207                        let sess = sess
1208                            .downcast_ref::<rustc_session::Session>()
1209                            .expect("expected `Session`");
1210                        (kind.0)(dcx, level, sess)
1211                    }),
1212                });
1213            },
1214        )
1215    }
1216
1217    fn alias_attrs(&mut self, id: HirId, target_id: HirId) {
1218        {
    match (&id.owner, &self.curr_owner.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);
            }
        }
    }
};assert_eq!(id.owner, self.curr_owner.owner_id());
1219        {
    match (&target_id.owner, &self.curr_owner.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);
            }
        }
    }
};assert_eq!(target_id.owner, self.curr_owner.owner_id());
1220        if let Some(&a) = self.curr_owner.attrs.get(&target_id.local_id) {
1221            if !!a.is_empty() {
    ::core::panicking::panic("assertion failed: !a.is_empty()")
};assert!(!a.is_empty());
1222            self.curr_owner.attrs.insert(id.local_id, a);
1223        }
1224    }
1225
1226    /// Lower an associated item constraint.
1227    {}
#[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("/rustc-dev/ea137335b78829b4514bf1b4c16302f74fab8581/compiler/rustc_ast_lowering/src/lib.rs"),
                                    ::tracing_core::__macro_support::Option::Some(1227u32),
                                    ::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_all(&[]) })
                } else {
                    let span =
                        ::tracing::__macro_support::__disabled_span(__CALLSITE.metadata());
                    {};
                    span
                }
            };
        __tracing_attr_guard = __tracing_attr_span.enter();
    }

    #[warn(clippy :: suspicious_else_formatting)]
    {

        #[allow(unknown_lints, unreachable_code, clippy ::
        diverging_sub_expression, clippy :: empty_loop, clippy ::
        let_unit_value, clippy :: let_with_type_underscore, clippy ::
        needless_return, clippy :: unreachable)]
        if false {
            let __tracing_attr_fake_return: 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 /rustc-dev/ea137335b78829b4514bf1b4c16302f74fab8581/compiler/rustc_ast_lowering/src/lib.rs:1233",
                                    "rustc_ast_lowering", ::tracing::Level::DEBUG,
                                    ::tracing_core::__macro_support::Option::Some("/rustc-dev/ea137335b78829b4514bf1b4c16302f74fab8581/compiler/rustc_ast_lowering/src/lib.rs"),
                                    ::tracing_core::__macro_support::Option::Some(1233u32),
                                    ::tracing_core::__macro_support::Option::Some("rustc_ast_lowering"),
                                    ::tracing_core::field::FieldSet::new(&[{
                                                        const NAME:
                                                            ::tracing::__macro_support::FieldName<{
                                                                ::tracing::__macro_support::FieldName::len("constraint")
                                                            }> =
                                                            ::tracing::__macro_support::FieldName::new("constraint");
                                                        NAME.as_str()
                                                    },
                                                    {
                                                        const NAME:
                                                            ::tracing::__macro_support::FieldName<{
                                                                ::tracing::__macro_support::FieldName::len("itctx")
                                                            }> =
                                                            ::tracing::__macro_support::FieldName::new("itctx");
                                                        NAME.as_str()
                                                    }], ::tracing_core::callsite::Identifier(&__CALLSITE)),
                                    ::tracing::metadata::Kind::EVENT)
                            };
                        ::tracing::callsite::DefaultCallsite::new(&META)
                    };
                let enabled =
                    ::tracing::Level::DEBUG <=
                                ::tracing::level_filters::STATIC_MAX_LEVEL &&
                            ::tracing::Level::DEBUG <=
                                ::tracing::level_filters::LevelFilter::current() &&
                        {
                            let interest = __CALLSITE.interest();
                            !interest.is_never() &&
                                ::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
                                    interest)
                        };
                if enabled {
                    (|value_set: ::tracing::field::ValueSet|
                                {
                                    let meta = __CALLSITE.metadata();
                                    ::tracing::Event::dispatch(meta, &value_set);
                                    ;
                                })({
                            #[allow(unused_imports)]
                            use ::tracing::field::{debug, display, Value};
                            __CALLSITE.metadata().fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&constraint)
                                                        as &dyn ::tracing::field::Value)),
                                            (::tracing::__macro_support::Option::Some(&::tracing::field::debug(&itctx)
                                                        as &dyn ::tracing::field::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 {
                                    let guar =
                                        self.emit_bad_parenthesized_trait_in_assoc_ty(data);
                                    self.lower_angle_bracketed_parameter_data(&data.as_angle_bracketed_args(),
                                            ParamMode::Explicit,
                                            ImplTraitContext::AlreadyErrored(guar)).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)]
1228    fn lower_assoc_item_constraint(
1229        &mut self,
1230        constraint: &AssocItemConstraint,
1231        itctx: ImplTraitContext,
1232    ) -> hir::AssocItemConstraint<'hir> {
1233        debug!(?constraint, ?itctx);
1234        // Lower the generic arguments for the associated item.
1235        let gen_args = if let Some(gen_args) = &constraint.gen_args {
1236            let gen_args_ctor = match gen_args {
1237                GenericArgs::AngleBracketed(data) => {
1238                    self.lower_angle_bracketed_parameter_data(data, ParamMode::Explicit, itctx).0
1239                }
1240                GenericArgs::Parenthesized(data) => {
1241                    if let Some(first_char) = constraint.ident.as_str().chars().next()
1242                        && first_char.is_ascii_lowercase()
1243                    {
1244                        let err = match (&data.inputs[..], &data.output) {
1245                            ([_, ..], FnRetTy::Default(_)) => {
1246                                diagnostics::BadReturnTypeNotation::Inputs {
1247                                    span: data.inputs_span,
1248                                }
1249                            }
1250                            ([], FnRetTy::Default(_)) => {
1251                                diagnostics::BadReturnTypeNotation::NeedsDots {
1252                                    span: data.inputs_span,
1253                                }
1254                            }
1255                            // The case `T: Trait<method(..) -> Ret>` is handled in the parser.
1256                            (_, FnRetTy::Ty(ty)) => {
1257                                let span = data.inputs_span.shrink_to_hi().to(ty.span);
1258                                diagnostics::BadReturnTypeNotation::Output {
1259                                    span,
1260                                    suggestion: diagnostics::RTNSuggestion {
1261                                        output: span,
1262                                        input: data.inputs_span,
1263                                    },
1264                                }
1265                            }
1266                        };
1267                        let mut err = self.dcx().create_err(err);
1268                        if !self.tcx.features().return_type_notation()
1269                            && self.tcx.sess.is_nightly_build()
1270                        {
1271                            add_feature_diagnostics(
1272                                &mut err,
1273                                &self.tcx.sess,
1274                                sym::return_type_notation,
1275                            );
1276                        }
1277                        err.emit();
1278                        GenericArgsCtor {
1279                            args: Default::default(),
1280                            constraints: &[],
1281                            parenthesized: hir::GenericArgsParentheses::ReturnTypeNotation,
1282                            span: data.span,
1283                        }
1284                    } else {
1285                        let guar = self.emit_bad_parenthesized_trait_in_assoc_ty(data);
1286                        self.lower_angle_bracketed_parameter_data(
1287                            &data.as_angle_bracketed_args(),
1288                            ParamMode::Explicit,
1289                            ImplTraitContext::AlreadyErrored(guar),
1290                        )
1291                        .0
1292                    }
1293                }
1294                GenericArgs::ParenthesizedElided(span) => GenericArgsCtor {
1295                    args: Default::default(),
1296                    constraints: &[],
1297                    parenthesized: hir::GenericArgsParentheses::ReturnTypeNotation,
1298                    span: *span,
1299                },
1300            };
1301            gen_args_ctor.into_generic_args(self)
1302        } else {
1303            hir::GenericArgs::NONE
1304        };
1305        let kind = match &constraint.kind {
1306            AssocItemConstraintKind::Equality { term } => {
1307                let term = match term {
1308                    Term::Ty(ty) => self.lower_ty_alloc(ty, itctx).into(),
1309                    Term::Const(c) => self.lower_anon_const_to_const_arg_and_alloc(c).into(),
1310                };
1311                hir::AssocItemConstraintKind::Equality { term }
1312            }
1313            AssocItemConstraintKind::Bound { bounds } => {
1314                // Disallow ATB in dyn types
1315                if self.is_in_dyn_type {
1316                    let suggestion = match itctx {
1317                        ImplTraitContext::OpaqueTy { .. } | ImplTraitContext::Universal => {
1318                            let bound_end_span = constraint
1319                                .gen_args
1320                                .as_ref()
1321                                .map_or(constraint.ident.span, |args| args.span());
1322                            if bound_end_span.eq_ctxt(constraint.span) {
1323                                Some(self.tcx.sess.source_map().next_point(bound_end_span))
1324                            } else {
1325                                None
1326                            }
1327                        }
1328                        _ => None,
1329                    };
1330
1331                    let guar = self.dcx().emit_err(diagnostics::MisplacedAssocTyBinding {
1332                        span: constraint.span,
1333                        suggestion,
1334                    });
1335                    let err_ty =
1336                        &*self.arena.alloc(self.ty(constraint.span, hir::TyKind::Err(guar)));
1337                    hir::AssocItemConstraintKind::Equality { term: err_ty.into() }
1338                } else {
1339                    let bounds = self.lower_param_bounds(
1340                        bounds,
1341                        RelaxedBoundPolicy::Forbidden(RelaxedBoundForbiddenReason::AssocTyBounds),
1342                        itctx,
1343                    );
1344                    hir::AssocItemConstraintKind::Bound { bounds }
1345                }
1346            }
1347        };
1348
1349        hir::AssocItemConstraint {
1350            hir_id: self.lower_node_id(constraint.id),
1351            ident: self.lower_ident(constraint.ident),
1352            gen_args,
1353            kind,
1354            span: self.lower_span(constraint.span),
1355        }
1356    }
1357
1358    fn emit_bad_parenthesized_trait_in_assoc_ty(
1359        &self,
1360        data: &ParenthesizedArgs,
1361    ) -> ErrorGuaranteed {
1362        // Suggest removing empty parentheses: "Trait()" -> "Trait"
1363        let sub = if data.inputs.is_empty() {
1364            let parentheses_span =
1365                data.inputs_span.shrink_to_lo().to(data.inputs_span.shrink_to_hi());
1366            AssocTyParenthesesSub::Empty { parentheses_span }
1367        }
1368        // Suggest replacing parentheses with angle brackets `Trait(params...)` to `Trait<params...>`
1369        else {
1370            // Start of parameters to the 1st argument
1371            let open_param = data.inputs_span.shrink_to_lo().to(data
1372                .inputs
1373                .first()
1374                .unwrap()
1375                .span
1376                .shrink_to_lo());
1377            // End of last argument to end of parameters
1378            let close_param =
1379                data.inputs.last().unwrap().span.shrink_to_hi().to(data.inputs_span.shrink_to_hi());
1380            AssocTyParenthesesSub::NotEmpty { open_param, close_param }
1381        };
1382        self.dcx().emit_err(AssocTyParentheses { span: data.span, sub })
1383    }
1384
1385    {}
#[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("/rustc-dev/ea137335b78829b4514bf1b4c16302f74fab8581/compiler/rustc_ast_lowering/src/lib.rs"),
                                    ::tracing_core::__macro_support::Option::Some(1385u32),
                                    ::tracing_core::__macro_support::Option::Some("rustc_ast_lowering"),
                                    ::tracing_core::field::FieldSet::new(&[{
                                                        const NAME:
                                                            ::tracing::__macro_support::FieldName<{
                                                                ::tracing::__macro_support::FieldName::len("arg")
                                                            }> =
                                                            ::tracing::__macro_support::FieldName::new("arg");
                                                        NAME.as_str()
                                                    },
                                                    {
                                                        const NAME:
                                                            ::tracing::__macro_support::FieldName<{
                                                                ::tracing::__macro_support::FieldName::len("itctx")
                                                            }> =
                                                            ::tracing::__macro_support::FieldName::new("itctx");
                                                        NAME.as_str()
                                                    }], ::tracing_core::callsite::Identifier(&__CALLSITE)),
                                    ::tracing::metadata::Kind::SPAN)
                            };
                        ::tracing::callsite::DefaultCallsite::new(&META)
                    };
                let mut interest = ::tracing::subscriber::Interest::never();
                if ::tracing::Level::DEBUG <=
                                    ::tracing::level_filters::STATIC_MAX_LEVEL &&
                                ::tracing::Level::DEBUG <=
                                    ::tracing::level_filters::LevelFilter::current() &&
                            { interest = __CALLSITE.interest(); !interest.is_never() }
                        &&
                        ::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
                            interest) {
                    let meta = __CALLSITE.metadata();
                    ::tracing::Span::new(meta,
                        &{
                                #[allow(unused_imports)]
                                use ::tracing::field::{debug, display, Value};
                                meta.fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&arg)
                                                            as &dyn ::tracing::field::Value)),
                                                (::tracing::__macro_support::Option::Some(&::tracing::field::debug(&itctx)
                                                            as &dyn ::tracing::field::Value))])
                            })
                } else {
                    let span =
                        ::tracing::__macro_support::__disabled_span(__CALLSITE.metadata());
                    {};
                    span
                }
            };
        __tracing_attr_guard = __tracing_attr_span.enter();
    }

    #[warn(clippy :: suspicious_else_formatting)]
    {

        #[allow(unknown_lints, unreachable_code, clippy ::
        diverging_sub_expression, clippy :: empty_loop, clippy ::
        let_unit_value, clippy :: let_with_type_underscore, clippy ::
        needless_return, clippy :: unreachable)]
        if false {
            let __tracing_attr_fake_return: 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(self.arena.alloc(hir::InferArg {
                                        hir_id: self.lower_node_id(ty.id),
                                        span: self.lower_span(ty.span),
                                        kind: hir::InferArgKind::TypeOrConst,
                                    }));
                    }
                    match &ty.kind {
                        TyKind::Path(None, path) if
                            path.is_single_argless_ident() &&
                                    let Some(res) =
                                        self.get_partial_res(ty.id).and_then(|partial_res|
                                                partial_res.full_res()) &&
                                !res.matches_ns(Namespace::TypeNS) => {
                            let ct =
                                self.lower_const_path_to_const_arg(&None, path, res, ty.id,
                                    ty.span);
                            let ct = self.arena.alloc(ct);
                            return GenericArg::Const(ct.try_as_ambig_ct().unwrap());
                        }
                        TyKind::GcaMacro(expr) if self.tcx.features().gca() => {
                            let ct =
                                match self.can_lower_expr_to_const_arg_direct(expr,
                                        self.direct_const_arg_context_enabled_by_gca_macro()) {
                                    Ok(()) => self.lower_expr_to_const_arg_direct(expr, None),
                                    Err(e) => e.emit(self),
                                };
                            let ct = self.arena.alloc(ct);
                            return match ct.try_as_ambig_ct() {
                                    Some(ct) => GenericArg::Const(ct),
                                    None =>
                                        GenericArg::Infer(self.arena.alloc(hir::InferArg {
                                                    hir_id: ct.hir_id,
                                                    span: ct.span,
                                                    kind: hir::InferArgKind::Const,
                                                })),
                                };
                        }
                        _ => {}
                    }
                    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(self.arena.alloc(hir::InferArg {
                                        hir_id: ct.hir_id,
                                        span: ct.span,
                                        kind: hir::InferArgKind::Const,
                                    })),
                    }
                }
            }
        }
    }
}#[instrument(level = "debug", skip(self))]
1386    fn lower_generic_arg(
1387        &mut self,
1388        arg: &ast::GenericArg,
1389        itctx: ImplTraitContext,
1390    ) -> hir::GenericArg<'hir> {
1391        match arg {
1392            ast::GenericArg::Lifetime(lt) => GenericArg::Lifetime(self.lower_lifetime(
1393                lt,
1394                LifetimeSource::Path { angle_brackets: hir::AngleBrackets::Full },
1395                lt.ident.into(),
1396            )),
1397            ast::GenericArg::Type(ty) => {
1398                // We cannot just match on `TyKind::Infer` as `(_)` is represented as
1399                // `TyKind::Paren(TyKind::Infer)` and should also be lowered to `GenericArg::Infer`
1400                if ty.is_maybe_parenthesised_infer() {
1401                    return GenericArg::Infer(self.arena.alloc(hir::InferArg {
1402                        hir_id: self.lower_node_id(ty.id),
1403                        span: self.lower_span(ty.span),
1404                        kind: hir::InferArgKind::TypeOrConst,
1405                    }));
1406                }
1407
1408                match &ty.kind {
1409                    // We parse const arguments as path types as we cannot distinguish them during
1410                    // parsing. We try to resolve that ambiguity by attempting resolution in both the
1411                    // type and value namespaces. If we resolved the path in the value namespace, we
1412                    // transform it into a generic const argument.
1413                    //
1414                    // Note that even under `#![feature(gca_min_const_items)]`, only plain paths
1415                    // to constants are allowed - e.g. `A::<T::ASSOC_CONST>` and
1416                    // `A::<CONST_WITH_PARAM::<2>>` are disallowed (they must be wrapped in `{ }`).
1417                    //
1418                    // FIXME: Should we be handling `(PATH_TO_CONST)`?
1419                    TyKind::Path(None, path)
1420                        if path.is_single_argless_ident()
1421                            && let Some(res) = self
1422                                .get_partial_res(ty.id)
1423                                .and_then(|partial_res| partial_res.full_res())
1424                            && !res.matches_ns(Namespace::TypeNS) =>
1425                    {
1426                        let ct =
1427                            self.lower_const_path_to_const_arg(&None, path, res, ty.id, ty.span);
1428                        let ct = self.arena.alloc(ct);
1429                        return GenericArg::Const(ct.try_as_ambig_ct().unwrap());
1430                    }
1431                    TyKind::GcaMacro(expr) if self.tcx.features().gca() => {
1432                        let ct = match self.can_lower_expr_to_const_arg_direct(
1433                            expr,
1434                            self.direct_const_arg_context_enabled_by_gca_macro(),
1435                        ) {
1436                            Ok(()) => self.lower_expr_to_const_arg_direct(expr, None),
1437                            Err(e) => e.emit(self),
1438                        };
1439                        let ct = self.arena.alloc(ct);
1440                        return match ct.try_as_ambig_ct() {
1441                            Some(ct) => GenericArg::Const(ct),
1442                            None => GenericArg::Infer(self.arena.alloc(hir::InferArg {
1443                                hir_id: ct.hir_id,
1444                                span: ct.span,
1445                                kind: hir::InferArgKind::Const,
1446                            })),
1447                        };
1448                    }
1449                    _ => {}
1450                }
1451                GenericArg::Type(self.lower_ty_alloc(ty, itctx).try_as_ambig_ty().unwrap())
1452            }
1453            ast::GenericArg::Const(ct) => {
1454                let ct = self.lower_anon_const_to_const_arg_and_alloc(ct);
1455                match ct.try_as_ambig_ct() {
1456                    Some(ct) => GenericArg::Const(ct),
1457                    None => GenericArg::Infer(self.arena.alloc(hir::InferArg {
1458                        hir_id: ct.hir_id,
1459                        span: ct.span,
1460                        kind: hir::InferArgKind::Const,
1461                    })),
1462                }
1463            }
1464        }
1465    }
1466
1467    {}
#[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("/rustc-dev/ea137335b78829b4514bf1b4c16302f74fab8581/compiler/rustc_ast_lowering/src/lib.rs"),
                                    ::tracing_core::__macro_support::Option::Some(1467u32),
                                    ::tracing_core::__macro_support::Option::Some("rustc_ast_lowering"),
                                    ::tracing_core::field::FieldSet::new(&[{
                                                        const NAME:
                                                            ::tracing::__macro_support::FieldName<{
                                                                ::tracing::__macro_support::FieldName::len("t")
                                                            }> =
                                                            ::tracing::__macro_support::FieldName::new("t");
                                                        NAME.as_str()
                                                    },
                                                    {
                                                        const NAME:
                                                            ::tracing::__macro_support::FieldName<{
                                                                ::tracing::__macro_support::FieldName::len("itctx")
                                                            }> =
                                                            ::tracing::__macro_support::FieldName::new("itctx");
                                                        NAME.as_str()
                                                    }], ::tracing_core::callsite::Identifier(&__CALLSITE)),
                                    ::tracing::metadata::Kind::SPAN)
                            };
                        ::tracing::callsite::DefaultCallsite::new(&META)
                    };
                let mut interest = ::tracing::subscriber::Interest::never();
                if ::tracing::Level::DEBUG <=
                                    ::tracing::level_filters::STATIC_MAX_LEVEL &&
                                ::tracing::Level::DEBUG <=
                                    ::tracing::level_filters::LevelFilter::current() &&
                            { interest = __CALLSITE.interest(); !interest.is_never() }
                        &&
                        ::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
                            interest) {
                    let meta = __CALLSITE.metadata();
                    ::tracing::Span::new(meta,
                        &{
                                #[allow(unused_imports)]
                                use ::tracing::field::{debug, display, Value};
                                meta.fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&t)
                                                            as &dyn ::tracing::field::Value)),
                                                (::tracing::__macro_support::Option::Some(&::tracing::field::debug(&itctx)
                                                            as &dyn ::tracing::field::Value))])
                            })
                } else {
                    let span =
                        ::tracing::__macro_support::__disabled_span(__CALLSITE.metadata());
                    {};
                    span
                }
            };
        __tracing_attr_guard = __tracing_attr_span.enter();
    }

    #[warn(clippy :: suspicious_else_formatting)]
    {

        #[allow(unknown_lints, unreachable_code, clippy ::
        diverging_sub_expression, clippy :: empty_loop, clippy ::
        let_unit_value, clippy :: let_with_type_underscore, clippy ::
        needless_return, clippy :: unreachable)]
        if false {
            let __tracing_attr_fake_return: &'hir hir::Ty<'hir> = loop {};
            return __tracing_attr_fake_return;
        }
        { self.arena.alloc(self.lower_ty(t, itctx)) }
    }
}#[instrument(level = "debug", skip(self))]
1468    fn lower_ty_alloc(&mut self, t: &Ty, itctx: ImplTraitContext) -> &'hir hir::Ty<'hir> {
1469        self.arena.alloc(self.lower_ty(t, itctx))
1470    }
1471
1472    fn lower_path_ty(
1473        &mut self,
1474        t: &Ty,
1475        qself: &Option<Box<QSelf>>,
1476        path: &Path,
1477        param_mode: ParamMode,
1478        itctx: ImplTraitContext,
1479    ) -> hir::Ty<'hir> {
1480        // Check whether we should interpret this as a bare trait object.
1481        // This check mirrors the one in late resolution. We only introduce this special case in
1482        // the rare occurrence we need to lower `Fresh` anonymous lifetimes.
1483        // The other cases when a qpath should be opportunistically made a trait object are handled
1484        // by `ty_path`.
1485        if qself.is_none()
1486            && let Some(partial_res) = self.get_partial_res(t.id)
1487            && let Some(Res::Def(DefKind::Trait | DefKind::TraitAlias, _)) = partial_res.full_res()
1488        {
1489            let (bounds, lifetime_bound) = self.with_dyn_type_scope(true, |this| {
1490                let bound = this.lower_poly_trait_ref(
1491                    &PolyTraitRef {
1492                        bound_generic_params: ThinVec::new(),
1493                        modifiers: TraitBoundModifiers::NONE,
1494                        trait_ref: TraitRef { path: path.clone(), ref_id: t.id },
1495                        span: t.span,
1496                        parens: ast::Parens::No,
1497                    },
1498                    RelaxedBoundPolicy::Forbidden(RelaxedBoundForbiddenReason::TraitObjectTy),
1499                    itctx,
1500                );
1501                let bounds = this.arena.alloc_from_iter([bound]);
1502                let lifetime_bound = this.elided_dyn_bound(t.span);
1503                (bounds, lifetime_bound)
1504            });
1505            let kind = hir::TyKind::TraitObject(
1506                bounds,
1507                TaggedRef::new(lifetime_bound, TraitObjectSyntax::None),
1508            );
1509            return hir::Ty { kind, span: self.lower_span(t.span), hir_id: self.next_id() };
1510        }
1511
1512        let id = self.lower_node_id(t.id);
1513        let qpath = self.lower_qpath(
1514            t.id,
1515            qself,
1516            path,
1517            param_mode,
1518            AllowReturnTypeNotation::Yes,
1519            itctx,
1520            None,
1521        );
1522        self.ty_path(id, t.span, qpath)
1523    }
1524
1525    fn ty(&mut self, span: Span, kind: hir::TyKind<'hir>) -> hir::Ty<'hir> {
1526        hir::Ty { hir_id: self.next_id(), kind, span: self.lower_span(span) }
1527    }
1528
1529    fn ty_tup(&mut self, span: Span, tys: &'hir [hir::Ty<'hir>]) -> hir::Ty<'hir> {
1530        self.ty(span, hir::TyKind::Tup(tys))
1531    }
1532
1533    fn lower_ty(&mut self, t: &Ty, itctx: ImplTraitContext) -> hir::Ty<'hir> {
1534        let kind = match &t.kind {
1535            TyKind::Infer => hir::TyKind::Infer(()),
1536            TyKind::Err(guar) => hir::TyKind::Err(*guar),
1537            TyKind::Slice(ty) => hir::TyKind::Slice(self.lower_ty_alloc(ty, itctx)),
1538            TyKind::Ptr(ty, mutbl) => hir::TyKind::Ptr(self.lower_ty_alloc(ty, itctx), *mutbl),
1539            TyKind::Ref(region, ty, mutbl) => {
1540                let lifetime = self.lower_ty_direct_lifetime(t, *region);
1541                hir::TyKind::Ref(lifetime, self.lower_ty_alloc(ty, itctx), *mutbl)
1542            }
1543            TyKind::PinnedRef(region, ty, mutbl) => {
1544                let lifetime = self.lower_ty_direct_lifetime(t, *region);
1545                let kind = hir::TyKind::Ref(lifetime, self.lower_ty_alloc(ty, itctx), *mutbl);
1546                let span = self.lower_span(t.span);
1547                let arg = hir::Ty { kind, span, hir_id: self.next_id() };
1548                let args = self.arena.alloc(hir::GenericArgs {
1549                    args: self.arena.alloc([hir::GenericArg::Type(self.arena.alloc(arg))]),
1550                    constraints: &[],
1551                    parenthesized: hir::GenericArgsParentheses::No,
1552                    span_ext: span,
1553                });
1554                let path = self.make_lang_item_qpath(LangItem::Pin, span, Some(args));
1555                hir::TyKind::Path(path)
1556            }
1557            TyKind::FnPtr(f) => {
1558                let hir_id = self.lower_node_id(t.id);
1559                let generic_params = self.lower_lifetime_binder(t.id, &f.generic_params);
1560                let kind = hir::TyKind::FnPtr(self.arena.alloc(hir::FnPtrTy {
1561                    generic_params,
1562                    safety: self.lower_safety(f.safety, hir::Safety::Safe),
1563                    abi: self.lower_extern(f.ext),
1564                    decl: self.lower_fn_decl(
1565                        &f.decl,
1566                        t.id,
1567                        hir_id,
1568                        FnDeclKind::Pointer,
1569                        None,
1570                        DiscardParams::Yes,
1571                    ),
1572                    param_idents: self.lower_fn_params_to_idents(&f.decl),
1573                }));
1574                return hir::Ty { kind, span: self.lower_span(t.span), hir_id };
1575            }
1576            TyKind::UnsafeBinder(f) => {
1577                let generic_params = self.lower_lifetime_binder(t.id, &f.generic_params);
1578                hir::TyKind::UnsafeBinder(self.arena.alloc(hir::UnsafeBinderTy {
1579                    generic_params,
1580                    inner_ty: self.lower_ty_alloc(&f.inner_ty, itctx),
1581                }))
1582            }
1583            TyKind::Never => hir::TyKind::Never,
1584            TyKind::Tup(tys) => hir::TyKind::Tup(
1585                self.arena.alloc_from_iter(tys.iter().map(|ty| self.lower_ty(ty, itctx))),
1586            ),
1587            TyKind::Paren(ty) => {
1588                return self.lower_ty(ty, itctx);
1589            }
1590            TyKind::Path(qself, path) => {
1591                return self.lower_path_ty(t, qself, path, ParamMode::Explicit, itctx);
1592            }
1593            TyKind::ImplicitSelf => {
1594                let hir_id = self.next_id();
1595                let res = self.expect_full_res(t.id);
1596                let res = self.lower_res(res);
1597                hir::TyKind::Path(hir::QPath::Resolved(
1598                    None,
1599                    self.arena.alloc(hir::Path {
1600                        res,
1601                        segments: self.arena.alloc_from_iter([hir::PathSegment::new(Ident::with_dummy_span(kw::SelfUpper),
                hir_id, res)])arena_vec![self; hir::PathSegment::new(
1602                            Ident::with_dummy_span(kw::SelfUpper),
1603                            hir_id,
1604                            res
1605                        )],
1606                        span: self.lower_span(t.span),
1607                    }),
1608                ))
1609            }
1610            TyKind::Array(ty, length) => hir::TyKind::Array(
1611                self.lower_ty_alloc(ty, itctx),
1612                self.lower_array_length_to_const_arg(length),
1613            ),
1614            TyKind::TraitObject(bounds, kind) => {
1615                let (bounds, lifetime_bound) = self.with_dyn_type_scope(true, |this| {
1616                    let mut lifetime_bound = None;
1617                    let bounds =
1618                        this.arena.alloc_from_iter(bounds.iter().filter_map(|bound| match bound {
1619                            // We can safely ignore constness here since AST validation
1620                            // takes care of rejecting invalid modifier combinations and
1621                            // const trait bounds in trait object types.
1622                            GenericBound::Trait(ty) => {
1623                                let trait_ref = this.lower_poly_trait_ref(
1624                                    ty,
1625                                    RelaxedBoundPolicy::Forbidden(
1626                                        RelaxedBoundForbiddenReason::TraitObjectTy,
1627                                    ),
1628                                    itctx,
1629                                );
1630                                Some(trait_ref)
1631                            }
1632                            GenericBound::Outlives(lifetime) => {
1633                                if lifetime_bound.is_none() {
1634                                    lifetime_bound = Some(this.lower_lifetime(
1635                                        lifetime,
1636                                        LifetimeSource::Other,
1637                                        lifetime.ident.into(),
1638                                    ));
1639                                }
1640                                None
1641                            }
1642                            // Ignore `use` syntax since that is not valid in objects.
1643                            GenericBound::Use(_, span) => {
1644                                this.dcx()
1645                                    .span_delayed_bug(*span, "use<> not allowed in dyn types");
1646                                None
1647                            }
1648                        }));
1649                    (bounds, lifetime_bound.unwrap_or_else(|| this.elided_dyn_bound(t.span)))
1650                });
1651                hir::TyKind::TraitObject(bounds, TaggedRef::new(lifetime_bound, *kind))
1652            }
1653            TyKind::ImplTrait(def_node_id, bounds) => {
1654                let span = t.span;
1655                match itctx {
1656                    ImplTraitContext::OpaqueTy { origin } => {
1657                        self.lower_opaque_impl_trait(span, origin, *def_node_id, bounds, itctx)
1658                    }
1659                    ImplTraitContext::Universal => {
1660                        if let Some(span) = bounds.iter().find_map(|bound| match *bound {
1661                            ast::GenericBound::Use(_, span) => Some(span),
1662                            _ => None,
1663                        }) {
1664                            self.tcx.dcx().emit_err(diagnostics::NoPreciseCapturesOnApit { span });
1665                        }
1666
1667                        let def_id = self.local_def_id(*def_node_id);
1668                        let name = self.tcx.item_name(def_id.to_def_id());
1669                        let ident = Ident::new(name, span);
1670                        let (param, bounds, path) = self.lower_universal_param_and_bounds(
1671                            *def_node_id,
1672                            span,
1673                            ident,
1674                            bounds,
1675                        );
1676                        self.curr_owner.impl_trait_defs.push(param);
1677                        if let Some(bounds) = bounds {
1678                            self.curr_owner.impl_trait_bounds.push(bounds);
1679                        }
1680                        path
1681                    }
1682                    ImplTraitContext::InBinding => {
1683                        hir::TyKind::TraitAscription(self.lower_param_bounds(
1684                            bounds,
1685                            RelaxedBoundPolicy::Allowed(&mut Default::default()),
1686                            itctx,
1687                        ))
1688                    }
1689                    ImplTraitContext::FeatureGated(position, feature) => {
1690                        let guar = self
1691                            .tcx
1692                            .sess
1693                            .create_feature_err(
1694                                MisplacedImplTrait {
1695                                    span: t.span,
1696                                    position: DiagArgFromDisplay(&position),
1697                                },
1698                                feature,
1699                            )
1700                            .emit_err();
1701                        hir::TyKind::Err(guar)
1702                    }
1703                    ImplTraitContext::Disallowed(position) => {
1704                        let guar = self.dcx().emit_err(MisplacedImplTrait {
1705                            span: t.span,
1706                            position: DiagArgFromDisplay(&position),
1707                        });
1708                        hir::TyKind::Err(guar)
1709                    }
1710                    ImplTraitContext::AlreadyErrored(guar) => {
1711                        // `GenericArgs::Parenthesized` stores its inputs as `Param`s, so the def
1712                        // collector visits `impl Trait` in a universal context and creates a
1713                        // `DefKind::TyParam`. During recovery we reinterpret these arguments as
1714                        // angle-bracketed, where lowering may otherwise expect an opaque type.
1715                        // The parenthesized syntax has already been rejected, so avoid lowering
1716                        // this `impl Trait` with the inconsistent `DefKind`.
1717                        hir::TyKind::Err(guar)
1718                    }
1719                }
1720            }
1721            TyKind::Pat(ty, pat) => {
1722                hir::TyKind::Pat(self.lower_ty_alloc(ty, itctx), self.lower_ty_pat(pat, ty.span))
1723            }
1724            TyKind::FieldOf(ty, variant, field) => hir::TyKind::FieldOf(
1725                self.lower_ty_alloc(ty, itctx),
1726                self.arena.alloc(hir::TyFieldPath {
1727                    variant: variant.map(|variant| self.lower_ident(variant)),
1728                    field: self.lower_ident(*field),
1729                }),
1730            ),
1731            TyKind::MacCall(_) => {
1732                ::rustc_span::macros::bug_impl(Some(t.span),
    format_args!("`TyKind::MacCall` should have been expanded by now"),
    Location::caller())span_bug!(t.span, "`TyKind::MacCall` should have been expanded by now")
1733            }
1734            TyKind::CVarArgs => {
1735                let guar = self.dcx().span_delayed_bug(
1736                    t.span,
1737                    "`TyKind::CVarArgs` should have been handled elsewhere",
1738                );
1739                hir::TyKind::Err(guar)
1740            }
1741            TyKind::View(ty, fields) => {
1742                let ty = self.lower_ty_alloc(ty, itctx);
1743                let fields = self.arena.alloc_slice(fields);
1744                hir::TyKind::View(ty, fields)
1745            }
1746            TyKind::GcaMacro(expr) => {
1747                let e = self.emit_bad_gca_macro(t.span, expr, "type");
1748                hir::TyKind::Err(e)
1749            }
1750            TyKind::Dummy => {
    ::core::panicking::panic_fmt(format_args!("`TyKind::Dummy` should never be lowered"));
}panic!("`TyKind::Dummy` should never be lowered"),
1751        };
1752
1753        hir::Ty { kind, span: self.lower_span(t.span), hir_id: self.lower_node_id(t.id) }
1754    }
1755
1756    pub(crate) fn emit_bad_gca_macro(
1757        &mut self,
1758        span: Span,
1759        expr: &Expr,
1760        expected: &'static str,
1761    ) -> ErrorGuaranteed {
1762        let msg = ::alloc::__export::must_use({
        ::alloc::fmt::format(format_args!("expected {0}, found `gca!()` constant",
                expected))
    })format!("expected {expected}, found `gca!()` constant");
1763        if expr::WillCreateDefIdsVisitor.visit_expr(expr).is_break() {
1764            // FIXME(mgca): make this non-fatal once we have a better way to handle
1765            // nested items in invalid `gca!()` arguments.
1766            self.dcx().span_fatal(span, msg)
1767        } else {
1768            self.dcx().span_err(span, msg)
1769        }
1770    }
1771
1772    fn lower_ty_direct_lifetime(
1773        &mut self,
1774        t: &Ty,
1775        region: Option<Lifetime>,
1776    ) -> &'hir hir::Lifetime {
1777        let (region, syntax) = match region {
1778            Some(region) => (region, region.ident.into()),
1779
1780            None => {
1781                let id = if let Some(LifetimeRes::ElidedAnchor { start, end }) =
1782                    self.curr_owner.owner.get_lifetime_res(t.id)
1783                {
1784                    {
    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);
1785                    start
1786                } else {
1787                    self.next_node_id()
1788                };
1789                let span = self.tcx.sess.source_map().start_point(t.span).shrink_to_hi();
1790                let region = Lifetime { ident: Ident::new(kw::UnderscoreLifetime, span), id };
1791                (region, LifetimeSyntax::Implicit)
1792            }
1793        };
1794        self.lower_lifetime(&region, LifetimeSource::Reference, syntax)
1795    }
1796
1797    /// Lowers a `ReturnPositionOpaqueTy` (`-> impl Trait`) or a `TypeAliasesOpaqueTy` (`type F =
1798    /// impl Trait`): this creates the associated Opaque Type (TAIT) definition and then returns a
1799    /// HIR type that references the TAIT.
1800    ///
1801    /// Given a function definition like:
1802    ///
1803    /// ```rust
1804    /// use std::fmt::Debug;
1805    ///
1806    /// fn test<'a, T: Debug>(x: &'a T) -> impl Debug + 'a {
1807    ///     x
1808    /// }
1809    /// ```
1810    ///
1811    /// we will create a TAIT definition in the HIR like
1812    ///
1813    /// ```rust,ignore (pseudo-Rust)
1814    /// type TestReturn<'a, T, 'x> = impl Debug + 'x
1815    /// ```
1816    ///
1817    /// and return a type like `TestReturn<'static, T, 'a>`, so that the function looks like:
1818    ///
1819    /// ```rust,ignore (pseudo-Rust)
1820    /// fn test<'a, T: Debug>(x: &'a T) -> TestReturn<'static, T, 'a>
1821    /// ```
1822    ///
1823    /// Note the subtlety around type parameters! The new TAIT, `TestReturn`, inherits all the
1824    /// type parameters from the function `test` (this is implemented in the query layer, they aren't
1825    /// added explicitly in the HIR). But this includes all the lifetimes, and we only want to
1826    /// capture the lifetimes that are referenced in the bounds. Therefore, we add *extra* lifetime parameters
1827    /// for the lifetimes that get captured (`'x`, in our example above) and reference those.
1828    {}
let __tracing_attr_span;
let __tracing_attr_guard;
if ::tracing::Level::DEBUG <= ::tracing::level_filters::STATIC_MAX_LEVEL &&
            ::tracing::Level::DEBUG <=
                ::tracing::level_filters::LevelFilter::current() || { false }
    {
    __tracing_attr_span =
        {
            use ::tracing::__macro_support::Callsite as _;
            static __CALLSITE: ::tracing::callsite::DefaultCallsite =
                {
                    static META: ::tracing::Metadata<'static> =
                        {
                            ::tracing_core::metadata::Metadata::new("lower_opaque_impl_trait",
                                "rustc_ast_lowering", ::tracing::Level::DEBUG,
                                ::tracing_core::__macro_support::Option::Some("/rustc-dev/ea137335b78829b4514bf1b4c16302f74fab8581/compiler/rustc_ast_lowering/src/lib.rs"),
                                ::tracing_core::__macro_support::Option::Some(1828u32),
                                ::tracing_core::__macro_support::Option::Some("rustc_ast_lowering"),
                                ::tracing_core::field::FieldSet::new(&[{
                                                    const NAME:
                                                        ::tracing::__macro_support::FieldName<{
                                                            ::tracing::__macro_support::FieldName::len("span")
                                                        }> =
                                                        ::tracing::__macro_support::FieldName::new("span");
                                                    NAME.as_str()
                                                },
                                                {
                                                    const NAME:
                                                        ::tracing::__macro_support::FieldName<{
                                                            ::tracing::__macro_support::FieldName::len("origin")
                                                        }> =
                                                        ::tracing::__macro_support::FieldName::new("origin");
                                                    NAME.as_str()
                                                },
                                                {
                                                    const NAME:
                                                        ::tracing::__macro_support::FieldName<{
                                                            ::tracing::__macro_support::FieldName::len("opaque_ty_node_id")
                                                        }> =
                                                        ::tracing::__macro_support::FieldName::new("opaque_ty_node_id");
                                                    NAME.as_str()
                                                },
                                                {
                                                    const NAME:
                                                        ::tracing::__macro_support::FieldName<{
                                                            ::tracing::__macro_support::FieldName::len("bounds")
                                                        }> =
                                                        ::tracing::__macro_support::FieldName::new("bounds");
                                                    NAME.as_str()
                                                },
                                                {
                                                    const NAME:
                                                        ::tracing::__macro_support::FieldName<{
                                                            ::tracing::__macro_support::FieldName::len("itctx")
                                                        }> =
                                                        ::tracing::__macro_support::FieldName::new("itctx");
                                                    NAME.as_str()
                                                }], ::tracing_core::callsite::Identifier(&__CALLSITE)),
                                ::tracing::metadata::Kind::SPAN)
                        };
                    ::tracing::callsite::DefaultCallsite::new(&META)
                };
            let mut interest = ::tracing::subscriber::Interest::never();
            if ::tracing::Level::DEBUG <=
                                ::tracing::level_filters::STATIC_MAX_LEVEL &&
                            ::tracing::Level::DEBUG <=
                                ::tracing::level_filters::LevelFilter::current() &&
                        { interest = __CALLSITE.interest(); !interest.is_never() }
                    &&
                    ::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
                        interest) {
                let meta = __CALLSITE.metadata();
                ::tracing::Span::new(meta,
                    &{
                            #[allow(unused_imports)]
                            use ::tracing::field::{debug, display, Value};
                            meta.fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&span)
                                                        as &dyn ::tracing::field::Value)),
                                            (::tracing::__macro_support::Option::Some(&::tracing::field::debug(&origin)
                                                        as &dyn ::tracing::field::Value)),
                                            (::tracing::__macro_support::Option::Some(&::tracing::field::debug(&opaque_ty_node_id)
                                                        as &dyn ::tracing::field::Value)),
                                            (::tracing::__macro_support::Option::Some(&::tracing::field::debug(&bounds)
                                                        as &dyn ::tracing::field::Value)),
                                            (::tracing::__macro_support::Option::Some(&::tracing::field::debug(&itctx)
                                                        as &dyn ::tracing::field::Value))])
                        })
            } else {
                let span =
                    ::tracing::__macro_support::__disabled_span(__CALLSITE.metadata());
                {};
                span
            }
        };
    __tracing_attr_guard = __tracing_attr_span.enter();
}
#[allow(clippy :: redundant_closure_call)]
let x =
    (move ||
                {

                    #[allow(unknown_lints, unreachable_code, clippy ::
                    diverging_sub_expression, clippy :: empty_loop, clippy ::
                    let_unit_value, clippy :: let_with_type_underscore, clippy
                    :: needless_return, clippy :: unreachable)]
                    if false {
                        let __tracing_attr_fake_return: hir::TyKind<'hir> = loop {};
                        return __tracing_attr_fake_return;
                    }
                    {
                        let opaque_ty_span =
                            self.mark_span_with_reason(DesugaringKind::OpaqueTy, span,
                                None);
                        self.lower_opaque_inner(opaque_ty_node_id, origin,
                            opaque_ty_span,
                            |this|
                                {
                                    this.lower_param_bounds(bounds,
                                        RelaxedBoundPolicy::Allowed(&mut Default::default()), itctx)
                                })
                    }
                })();
{
    use ::tracing::__macro_support::Callsite as _;
    static __CALLSITE: ::tracing::callsite::DefaultCallsite =
        {
            static META: ::tracing::Metadata<'static> =
                {
                    ::tracing_core::metadata::Metadata::new("event /rustc-dev/ea137335b78829b4514bf1b4c16302f74fab8581/compiler/rustc_ast_lowering/src/lib.rs:1828",
                        "rustc_ast_lowering", ::tracing::Level::DEBUG,
                        ::tracing_core::__macro_support::Option::Some("/rustc-dev/ea137335b78829b4514bf1b4c16302f74fab8581/compiler/rustc_ast_lowering/src/lib.rs"),
                        ::tracing_core::__macro_support::Option::Some(1828u32),
                        ::tracing_core::__macro_support::Option::Some("rustc_ast_lowering"),
                        ::tracing_core::field::FieldSet::new(&[{
                                            const NAME:
                                                ::tracing::__macro_support::FieldName<{
                                                    ::tracing::__macro_support::FieldName::len("return")
                                                }> =
                                                ::tracing::__macro_support::FieldName::new("return");
                                            NAME.as_str()
                                        }], ::tracing_core::callsite::Identifier(&__CALLSITE)),
                        ::tracing::metadata::Kind::EVENT)
                };
            ::tracing::callsite::DefaultCallsite::new(&META)
        };
    let enabled =
        ::tracing::Level::DEBUG <= ::tracing::level_filters::STATIC_MAX_LEVEL
                &&
                ::tracing::Level::DEBUG <=
                    ::tracing::level_filters::LevelFilter::current() &&
            {
                let interest = __CALLSITE.interest();
                !interest.is_never() &&
                    ::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
                        interest)
            };
    if enabled {
        (|value_set: ::tracing::field::ValueSet|
                    {
                        let meta = __CALLSITE.metadata();
                        ::tracing::Event::dispatch(meta, &value_set);
                        ;
                    })({
                #[allow(unused_imports)]
                use ::tracing::field::{debug, display, Value};
                __CALLSITE.metadata().fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&x)
                                            as &dyn ::tracing::field::Value))])
            });
    } else { ; }
};
x;#[instrument(level = "debug", skip(self), ret)]
1829    fn lower_opaque_impl_trait(
1830        &mut self,
1831        span: Span,
1832        origin: hir::OpaqueTyOrigin<LocalDefId>,
1833        opaque_ty_node_id: NodeId,
1834        bounds: &GenericBounds,
1835        itctx: ImplTraitContext,
1836    ) -> hir::TyKind<'hir> {
1837        // Make sure we know that some funky desugaring has been going on here.
1838        // This is a first: there is code in other places like for loop
1839        // desugaring that explicitly states that we don't want to track that.
1840        // Not tracking it makes lints in rustc and clippy very fragile, as
1841        // frequently opened issues show.
1842        let opaque_ty_span = self.mark_span_with_reason(DesugaringKind::OpaqueTy, span, None);
1843
1844        self.lower_opaque_inner(opaque_ty_node_id, origin, opaque_ty_span, |this| {
1845            this.lower_param_bounds(
1846                bounds,
1847                RelaxedBoundPolicy::Allowed(&mut Default::default()),
1848                itctx,
1849            )
1850        })
1851    }
1852
1853    fn lower_opaque_inner(
1854        &mut self,
1855        opaque_ty_node_id: NodeId,
1856        origin: hir::OpaqueTyOrigin<LocalDefId>,
1857        opaque_ty_span: Span,
1858        lower_item_bounds: impl FnOnce(&mut Self) -> &'hir [hir::GenericBound<'hir>],
1859    ) -> hir::TyKind<'hir> {
1860        let opaque_ty_def_id = self.local_def_id(opaque_ty_node_id);
1861        let opaque_ty_hir_id = self.lower_node_id(opaque_ty_node_id);
1862        {
    use ::tracing::__macro_support::Callsite as _;
    static __CALLSITE: ::tracing::callsite::DefaultCallsite =
        {
            static META: ::tracing::Metadata<'static> =
                {
                    ::tracing_core::metadata::Metadata::new("event /rustc-dev/ea137335b78829b4514bf1b4c16302f74fab8581/compiler/rustc_ast_lowering/src/lib.rs:1862",
                        "rustc_ast_lowering", ::tracing::Level::DEBUG,
                        ::tracing_core::__macro_support::Option::Some("/rustc-dev/ea137335b78829b4514bf1b4c16302f74fab8581/compiler/rustc_ast_lowering/src/lib.rs"),
                        ::tracing_core::__macro_support::Option::Some(1862u32),
                        ::tracing_core::__macro_support::Option::Some("rustc_ast_lowering"),
                        ::tracing_core::field::FieldSet::new(&[{
                                            const NAME:
                                                ::tracing::__macro_support::FieldName<{
                                                    ::tracing::__macro_support::FieldName::len("opaque_ty_def_id")
                                                }> =
                                                ::tracing::__macro_support::FieldName::new("opaque_ty_def_id");
                                            NAME.as_str()
                                        },
                                        {
                                            const NAME:
                                                ::tracing::__macro_support::FieldName<{
                                                    ::tracing::__macro_support::FieldName::len("opaque_ty_hir_id")
                                                }> =
                                                ::tracing::__macro_support::FieldName::new("opaque_ty_hir_id");
                                            NAME.as_str()
                                        }], ::tracing_core::callsite::Identifier(&__CALLSITE)),
                        ::tracing::metadata::Kind::EVENT)
                };
            ::tracing::callsite::DefaultCallsite::new(&META)
        };
    let enabled =
        ::tracing::Level::DEBUG <= ::tracing::level_filters::STATIC_MAX_LEVEL
                &&
                ::tracing::Level::DEBUG <=
                    ::tracing::level_filters::LevelFilter::current() &&
            {
                let interest = __CALLSITE.interest();
                !interest.is_never() &&
                    ::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
                        interest)
            };
    if enabled {
        (|value_set: ::tracing::field::ValueSet|
                    {
                        let meta = __CALLSITE.metadata();
                        ::tracing::Event::dispatch(meta, &value_set);
                        ;
                    })({
                #[allow(unused_imports)]
                use ::tracing::field::{debug, display, Value};
                __CALLSITE.metadata().fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&opaque_ty_def_id)
                                            as &dyn ::tracing::field::Value)),
                                (::tracing::__macro_support::Option::Some(&::tracing::field::debug(&opaque_ty_hir_id)
                                            as &dyn ::tracing::field::Value))])
            });
    } else { ; }
};debug!(?opaque_ty_def_id, ?opaque_ty_hir_id);
1863
1864        let bounds = lower_item_bounds(self);
1865        let opaque_ty_def = hir::OpaqueTy {
1866            hir_id: opaque_ty_hir_id,
1867            def_id: opaque_ty_def_id,
1868            bounds,
1869            origin,
1870            span: self.lower_span(opaque_ty_span),
1871        };
1872        let opaque_ty_def = self.arena.alloc(opaque_ty_def);
1873
1874        hir::TyKind::OpaqueDef(opaque_ty_def)
1875    }
1876
1877    fn lower_precise_capturing_args(
1878        &mut self,
1879        precise_capturing_args: &[PreciseCapturingArg],
1880    ) -> &'hir [hir::PreciseCapturingArg<'hir>] {
1881        self.arena.alloc_from_iter(precise_capturing_args.iter().map(|arg| match arg {
1882            PreciseCapturingArg::Lifetime(lt) => hir::PreciseCapturingArg::Lifetime(
1883                self.lower_lifetime(lt, LifetimeSource::PreciseCapturing, lt.ident.into()),
1884            ),
1885            PreciseCapturingArg::Arg(path, id) => {
1886                let [segment] = path.segments.as_slice() else {
1887                    ::core::panicking::panic("explicit panic");panic!();
1888                };
1889                let res = self.get_partial_res(*id).map_or(Res::Err, |partial_res| {
1890                    partial_res.full_res().expect("no partial res expected for precise capture arg")
1891                });
1892                hir::PreciseCapturingArg::Param(hir::PreciseCapturingNonLifetimeArg {
1893                    hir_id: self.lower_node_id(*id),
1894                    ident: self.lower_ident(segment.ident),
1895                    res: self.lower_res(res),
1896                })
1897            }
1898        }))
1899    }
1900
1901    fn lower_fn_params_to_idents(&mut self, decl: &FnDecl) -> &'hir [Option<Ident>] {
1902        self.arena.alloc_from_iter(decl.inputs.iter().map(|param| match param.pat.kind {
1903            PatKind::Missing => None,
1904            PatKind::Ident(_, ident, _) => Some(self.lower_ident(ident)),
1905            PatKind::Wild => Some(Ident::new(kw::Underscore, self.lower_span(param.pat.span))),
1906            _ => {
1907                self.dcx().span_delayed_bug(
1908                    param.pat.span,
1909                    "non-missing/ident/wild param pat must trigger an error",
1910                );
1911                None
1912            }
1913        }))
1914    }
1915
1916    /// Lowers a function declaration.
1917    ///
1918    /// `decl`: the unlowered (AST) function declaration.
1919    ///
1920    /// `fn_node_id`: Node Id of the function.
1921    ///
1922    /// `fn_hir_id`: Hir Id of the function. Used for attribute parsing.
1923    ///
1924    /// `kind`: The kind of function.
1925    ///
1926    /// `coro`: If the function is a coroutine, information about the coroutine.
1927    ///
1928    /// `discard_params`: if `DiscardParams::Yes`, the parameters are lowered and then discarded. Set this to `DiscardParams::Yes`
1929    /// for functions without bodies, as attributes on parameters are otherwise not validated.
1930    /// Set this to `DiscardParams::No` for functions with bodies, as lowering of the parameters is done by `lower_body`.
1931    {}
#[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("/rustc-dev/ea137335b78829b4514bf1b4c16302f74fab8581/compiler/rustc_ast_lowering/src/lib.rs"),
                                    ::tracing_core::__macro_support::Option::Some(1931u32),
                                    ::tracing_core::__macro_support::Option::Some("rustc_ast_lowering"),
                                    ::tracing_core::field::FieldSet::new(&[{
                                                        const NAME:
                                                            ::tracing::__macro_support::FieldName<{
                                                                ::tracing::__macro_support::FieldName::len("decl")
                                                            }> =
                                                            ::tracing::__macro_support::FieldName::new("decl");
                                                        NAME.as_str()
                                                    },
                                                    {
                                                        const NAME:
                                                            ::tracing::__macro_support::FieldName<{
                                                                ::tracing::__macro_support::FieldName::len("fn_node_id")
                                                            }> =
                                                            ::tracing::__macro_support::FieldName::new("fn_node_id");
                                                        NAME.as_str()
                                                    },
                                                    {
                                                        const NAME:
                                                            ::tracing::__macro_support::FieldName<{
                                                                ::tracing::__macro_support::FieldName::len("fn_hir_id")
                                                            }> =
                                                            ::tracing::__macro_support::FieldName::new("fn_hir_id");
                                                        NAME.as_str()
                                                    },
                                                    {
                                                        const NAME:
                                                            ::tracing::__macro_support::FieldName<{
                                                                ::tracing::__macro_support::FieldName::len("kind")
                                                            }> =
                                                            ::tracing::__macro_support::FieldName::new("kind");
                                                        NAME.as_str()
                                                    },
                                                    {
                                                        const NAME:
                                                            ::tracing::__macro_support::FieldName<{
                                                                ::tracing::__macro_support::FieldName::len("coro")
                                                            }> =
                                                            ::tracing::__macro_support::FieldName::new("coro");
                                                        NAME.as_str()
                                                    },
                                                    {
                                                        const NAME:
                                                            ::tracing::__macro_support::FieldName<{
                                                                ::tracing::__macro_support::FieldName::len("discard_params")
                                                            }> =
                                                            ::tracing::__macro_support::FieldName::new("discard_params");
                                                        NAME.as_str()
                                                    }], ::tracing_core::callsite::Identifier(&__CALLSITE)),
                                    ::tracing::metadata::Kind::SPAN)
                            };
                        ::tracing::callsite::DefaultCallsite::new(&META)
                    };
                let mut interest = ::tracing::subscriber::Interest::never();
                if ::tracing::Level::DEBUG <=
                                    ::tracing::level_filters::STATIC_MAX_LEVEL &&
                                ::tracing::Level::DEBUG <=
                                    ::tracing::level_filters::LevelFilter::current() &&
                            { interest = __CALLSITE.interest(); !interest.is_never() }
                        &&
                        ::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
                            interest) {
                    let meta = __CALLSITE.metadata();
                    ::tracing::Span::new(meta,
                        &{
                                #[allow(unused_imports)]
                                use ::tracing::field::{debug, display, Value};
                                meta.fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&decl)
                                                            as &dyn ::tracing::field::Value)),
                                                (::tracing::__macro_support::Option::Some(&::tracing::field::debug(&fn_node_id)
                                                            as &dyn ::tracing::field::Value)),
                                                (::tracing::__macro_support::Option::Some(&::tracing::field::debug(&fn_hir_id)
                                                            as &dyn ::tracing::field::Value)),
                                                (::tracing::__macro_support::Option::Some(&::tracing::field::debug(&kind)
                                                            as &dyn ::tracing::field::Value)),
                                                (::tracing::__macro_support::Option::Some(&::tracing::field::debug(&coro)
                                                            as &dyn ::tracing::field::Value)),
                                                (::tracing::__macro_support::Option::Some(&::tracing::field::debug(&discard_params)
                                                            as &dyn ::tracing::field::Value))])
                            })
                } else {
                    let span =
                        ::tracing::__macro_support::__disabled_span(__CALLSITE.metadata());
                    {};
                    span
                }
            };
        __tracing_attr_guard = __tracing_attr_span.enter();
    }

    #[warn(clippy :: suspicious_else_formatting)]
    {

        #[allow(unknown_lints, unreachable_code, clippy ::
        diverging_sub_expression, clippy :: empty_loop, clippy ::
        let_unit_value, clippy :: let_with_type_underscore, clippy ::
        needless_return, clippy :: unreachable)]
        if false {
            let __tracing_attr_fake_return: &'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|
                            {
                                if let DiscardParams::Yes = discard_params {
                                    self.lower_attrs(fn_hir_id, &param.attrs, param.span,
                                        Target::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.curr_owner.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.curr_owner.owner.def_id,
                                                    in_trait_or_impl: None,
                                                },
                                            },
                                        FnDeclKind::Trait =>
                                            ImplTraitContext::OpaqueTy {
                                                origin: hir::OpaqueTyOrigin::FnReturn {
                                                    parent: self.curr_owner.owner.def_id,
                                                    in_trait_or_impl: Some(hir::RpitContext::Trait),
                                                },
                                            },
                                        FnDeclKind::Impl =>
                                            ImplTraitContext::OpaqueTy {
                                                origin: hir::OpaqueTyOrigin::FnReturn {
                                                    parent: self.curr_owner.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(_, ty, mutbl) | TyKind::PinnedRef(_, ty, mutbl)
                                                        if ty.kind.is_implicit_self() => {
                                                        match mutbl {
                                                            hir::Mutability::Not => hir::ImplicitSelfKind::RefImm,
                                                            hir::Mutability::Mut => hir::ImplicitSelfKind::RefMut,
                                                        }
                                                    }
                                                    _ => hir::ImplicitSelfKind::None,
                                                }
                                            })).set_lifetime_elision_allowed(self.curr_owner.owner.id ==
                                        fn_node_id &&
                                    self.curr_owner.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))]
1932    fn lower_fn_decl(
1933        &mut self,
1934        decl: &FnDecl,
1935        fn_node_id: NodeId,
1936        fn_hir_id: HirId,
1937        kind: FnDeclKind,
1938        coro: Option<CoroutineMarker>,
1939        discard_params: DiscardParams,
1940    ) -> &'hir hir::FnDecl<'hir> {
1941        let c_variadic = decl.c_variadic();
1942        let mut splatted = decl.splatted();
1943
1944        // Skip the `...` (`CVarArgs`) trailing arguments from the AST,
1945        // as they are not explicit in HIR/Ty function signatures.
1946        // (instead, the `c_variadic` flag is set to `true`)
1947        let mut inputs = &decl.inputs[..];
1948        if decl.c_variadic() {
1949            // Splat + variadic errors in AST validation, so just ignore one of them here.
1950            splatted = None;
1951            inputs = &inputs[..inputs.len() - 1];
1952        }
1953        let inputs = self.arena.alloc_from_iter(inputs.iter().map(|param| {
1954            if let DiscardParams::Yes = discard_params {
1955                // FIXME This uses `fn_hir_id`, which is not correct, it should use the parameter hir id instead
1956                // The parameter is currently not lowered for functions without bodies, so there is no place to store the lowered hir id
1957                // This should be fixed by storing function parameters in the `hir::FnSig` instead of `hir::Body`
1958                self.lower_attrs(fn_hir_id, &param.attrs, param.span, Target::Param);
1959            }
1960            let itctx = match kind {
1961                FnDeclKind::Fn | FnDeclKind::Inherent | FnDeclKind::Impl | FnDeclKind::Trait => {
1962                    ImplTraitContext::Universal
1963                }
1964                FnDeclKind::ExternFn => {
1965                    ImplTraitContext::Disallowed(ImplTraitPosition::ExternFnParam)
1966                }
1967                FnDeclKind::Closure => {
1968                    ImplTraitContext::Disallowed(ImplTraitPosition::ClosureParam)
1969                }
1970                FnDeclKind::Pointer => {
1971                    ImplTraitContext::Disallowed(ImplTraitPosition::PointerParam)
1972                }
1973            };
1974            self.lower_ty(&param.ty, itctx)
1975        }));
1976
1977        let output = match coro {
1978            Some(coro) => {
1979                let fn_def_id = self.curr_owner.owner.def_id;
1980                self.lower_coroutine_fn_ret_ty(&decl.output, fn_def_id, coro, kind)
1981            }
1982            None => match &decl.output {
1983                FnRetTy::Ty(ty) => {
1984                    let itctx = match kind {
1985                        FnDeclKind::Fn | FnDeclKind::Inherent => ImplTraitContext::OpaqueTy {
1986                            origin: hir::OpaqueTyOrigin::FnReturn {
1987                                parent: self.curr_owner.owner.def_id,
1988                                in_trait_or_impl: None,
1989                            },
1990                        },
1991                        FnDeclKind::Trait => ImplTraitContext::OpaqueTy {
1992                            origin: hir::OpaqueTyOrigin::FnReturn {
1993                                parent: self.curr_owner.owner.def_id,
1994                                in_trait_or_impl: Some(hir::RpitContext::Trait),
1995                            },
1996                        },
1997                        FnDeclKind::Impl => ImplTraitContext::OpaqueTy {
1998                            origin: hir::OpaqueTyOrigin::FnReturn {
1999                                parent: self.curr_owner.owner.def_id,
2000                                in_trait_or_impl: Some(hir::RpitContext::TraitImpl),
2001                            },
2002                        },
2003                        FnDeclKind::ExternFn => {
2004                            ImplTraitContext::Disallowed(ImplTraitPosition::ExternFnReturn)
2005                        }
2006                        FnDeclKind::Closure => {
2007                            ImplTraitContext::Disallowed(ImplTraitPosition::ClosureReturn)
2008                        }
2009                        FnDeclKind::Pointer => {
2010                            ImplTraitContext::Disallowed(ImplTraitPosition::PointerReturn)
2011                        }
2012                    };
2013                    hir::FnRetTy::Return(self.lower_ty_alloc(ty, itctx))
2014                }
2015                FnRetTy::Default(span) => hir::FnRetTy::DefaultReturn(self.lower_span(*span)),
2016            },
2017        };
2018
2019        let fn_decl_kind = hir::FnDeclFlags::default()
2020            .set_implicit_self(decl.inputs.get(0).map_or(hir::ImplicitSelfKind::None, |arg| {
2021                let is_mutable_pat = matches!(
2022                    arg.pat.kind,
2023                    PatKind::Ident(hir::BindingMode(_, Mutability::Mut), ..)
2024                );
2025
2026                match &arg.ty.kind {
2027                    TyKind::ImplicitSelf if is_mutable_pat => hir::ImplicitSelfKind::Mut,
2028                    TyKind::ImplicitSelf => hir::ImplicitSelfKind::Imm,
2029                    // Given we are only considering `ImplicitSelf` types, we needn't consider
2030                    // the case where we have a mutable pattern to a reference as that would
2031                    // no longer be an `ImplicitSelf`.
2032                    TyKind::Ref(_, ty, mutbl) | TyKind::PinnedRef(_, ty, mutbl)
2033                        if ty.kind.is_implicit_self() =>
2034                    {
2035                        match mutbl {
2036                            hir::Mutability::Not => hir::ImplicitSelfKind::RefImm,
2037                            hir::Mutability::Mut => hir::ImplicitSelfKind::RefMut,
2038                        }
2039                    }
2040                    _ => hir::ImplicitSelfKind::None,
2041                }
2042            }))
2043            .set_lifetime_elision_allowed(
2044                self.curr_owner.owner.id == fn_node_id
2045                    && self.curr_owner.owner.lifetime_elision_allowed,
2046            )
2047            .set_c_variadic(c_variadic)
2048            .set_splatted(splatted, inputs.len())
2049            .unwrap();
2050
2051        self.arena.alloc(hir::FnDecl { inputs, output, fn_decl_kind })
2052    }
2053
2054    // Transforms `-> T` for `async fn` into `-> OpaqueTy { .. }`
2055    // combined with the following definition of `OpaqueTy`:
2056    //
2057    //     type OpaqueTy<generics_from_parent_fn> = impl Future<Output = T>;
2058    //
2059    // `output`: unlowered output type (`T` in `-> T`)
2060    // `fn_node_id`: `NodeId` of the parent function (used to create child impl trait definition)
2061    // `opaque_ty_node_id`: `NodeId` of the opaque `impl Trait` type that should be created
2062    {}
#[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("/rustc-dev/ea137335b78829b4514bf1b4c16302f74fab8581/compiler/rustc_ast_lowering/src/lib.rs"),
                                    ::tracing_core::__macro_support::Option::Some(2062u32),
                                    ::tracing_core::__macro_support::Option::Some("rustc_ast_lowering"),
                                    ::tracing_core::field::FieldSet::new(&[{
                                                        const NAME:
                                                            ::tracing::__macro_support::FieldName<{
                                                                ::tracing::__macro_support::FieldName::len("output")
                                                            }> =
                                                            ::tracing::__macro_support::FieldName::new("output");
                                                        NAME.as_str()
                                                    },
                                                    {
                                                        const NAME:
                                                            ::tracing::__macro_support::FieldName<{
                                                                ::tracing::__macro_support::FieldName::len("fn_def_id")
                                                            }> =
                                                            ::tracing::__macro_support::FieldName::new("fn_def_id");
                                                        NAME.as_str()
                                                    },
                                                    {
                                                        const NAME:
                                                            ::tracing::__macro_support::FieldName<{
                                                                ::tracing::__macro_support::FieldName::len("coro")
                                                            }> =
                                                            ::tracing::__macro_support::FieldName::new("coro");
                                                        NAME.as_str()
                                                    },
                                                    {
                                                        const NAME:
                                                            ::tracing::__macro_support::FieldName<{
                                                                ::tracing::__macro_support::FieldName::len("fn_kind")
                                                            }> =
                                                            ::tracing::__macro_support::FieldName::new("fn_kind");
                                                        NAME.as_str()
                                                    }], ::tracing_core::callsite::Identifier(&__CALLSITE)),
                                    ::tracing::metadata::Kind::SPAN)
                            };
                        ::tracing::callsite::DefaultCallsite::new(&META)
                    };
                let mut interest = ::tracing::subscriber::Interest::never();
                if ::tracing::Level::DEBUG <=
                                    ::tracing::level_filters::STATIC_MAX_LEVEL &&
                                ::tracing::Level::DEBUG <=
                                    ::tracing::level_filters::LevelFilter::current() &&
                            { interest = __CALLSITE.interest(); !interest.is_never() }
                        &&
                        ::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
                            interest) {
                    let meta = __CALLSITE.metadata();
                    ::tracing::Span::new(meta,
                        &{
                                #[allow(unused_imports)]
                                use ::tracing::field::{debug, display, Value};
                                meta.fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&output)
                                                            as &dyn ::tracing::field::Value)),
                                                (::tracing::__macro_support::Option::Some(&::tracing::field::debug(&fn_def_id)
                                                            as &dyn ::tracing::field::Value)),
                                                (::tracing::__macro_support::Option::Some(&::tracing::field::debug(&coro)
                                                            as &dyn ::tracing::field::Value)),
                                                (::tracing::__macro_support::Option::Some(&::tracing::field::debug(&fn_kind)
                                                            as &dyn ::tracing::field::Value))])
                            })
                } else {
                    let span =
                        ::tracing::__macro_support::__disabled_span(__CALLSITE.metadata());
                    {};
                    span
                }
            };
        __tracing_attr_guard = __tracing_attr_span.enter();
    }

    #[warn(clippy :: suspicious_else_formatting)]
    {

        #[allow(unknown_lints, unreachable_code, clippy ::
        diverging_sub_expression, clippy :: empty_loop, clippy ::
        let_unit_value, clippy :: let_with_type_underscore, clippy ::
        needless_return, clippy :: unreachable)]
        if false {
            let __tracing_attr_fake_return: 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.kind {
                    CoroutineKind::Async | CoroutineKind::Gen =>
                        (coro.return_impl_trait_id, None),
                    CoroutineKind::AsyncGen => {
                        (coro.return_impl_trait_id,
                            Some(Arc::clone(&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))]
2063    fn lower_coroutine_fn_ret_ty(
2064        &mut self,
2065        output: &FnRetTy,
2066        fn_def_id: LocalDefId,
2067        coro: CoroutineMarker,
2068        fn_kind: FnDeclKind,
2069    ) -> hir::FnRetTy<'hir> {
2070        let span = self.lower_span(output.span());
2071
2072        let (opaque_ty_node_id, allowed_features) = match coro.kind {
2073            CoroutineKind::Async | CoroutineKind::Gen => (coro.return_impl_trait_id, None),
2074            CoroutineKind::AsyncGen => {
2075                (coro.return_impl_trait_id, Some(Arc::clone(&ALLOW_ASYNC_ITERATOR)))
2076            }
2077        };
2078
2079        let opaque_ty_span =
2080            self.mark_span_with_reason(DesugaringKind::Async, span, allowed_features);
2081
2082        let in_trait_or_impl = match fn_kind {
2083            FnDeclKind::Trait => Some(hir::RpitContext::Trait),
2084            FnDeclKind::Impl => Some(hir::RpitContext::TraitImpl),
2085            FnDeclKind::Fn | FnDeclKind::Inherent => None,
2086            FnDeclKind::ExternFn | FnDeclKind::Closure | FnDeclKind::Pointer => unreachable!(),
2087        };
2088
2089        let opaque_ty_ref = self.lower_opaque_inner(
2090            opaque_ty_node_id,
2091            hir::OpaqueTyOrigin::AsyncFn { parent: fn_def_id, in_trait_or_impl },
2092            opaque_ty_span,
2093            |this| {
2094                let bound = this.lower_coroutine_fn_output_type_to_bound(
2095                    output,
2096                    coro,
2097                    opaque_ty_span,
2098                    ImplTraitContext::OpaqueTy {
2099                        origin: hir::OpaqueTyOrigin::FnReturn {
2100                            parent: fn_def_id,
2101                            in_trait_or_impl,
2102                        },
2103                    },
2104                );
2105                arena_vec![this; bound]
2106            },
2107        );
2108
2109        let opaque_ty = self.ty(opaque_ty_span, opaque_ty_ref);
2110        hir::FnRetTy::Return(self.arena.alloc(opaque_ty))
2111    }
2112
2113    /// Transforms `-> T` into `Future<Output = T>`.
2114    fn lower_coroutine_fn_output_type_to_bound(
2115        &mut self,
2116        output: &FnRetTy,
2117        coro: CoroutineMarker,
2118        opaque_ty_span: Span,
2119        itctx: ImplTraitContext,
2120    ) -> hir::GenericBound<'hir> {
2121        // Compute the `T` in `Future<Output = T>` from the return type.
2122        let output_ty = match output {
2123            FnRetTy::Ty(ty) => {
2124                // Not `OpaqueTyOrigin::AsyncFn`: that's only used for the
2125                // `impl Future` opaque type that `async fn` implicitly
2126                // generates.
2127                self.lower_ty_alloc(ty, itctx)
2128            }
2129            FnRetTy::Default(ret_ty_span) => self.arena.alloc(self.ty_tup(*ret_ty_span, &[])),
2130        };
2131
2132        // "<$assoc_ty_name = T>"
2133        let (assoc_ty_name, trait_lang_item) = match coro.kind {
2134            CoroutineKind::Async => (sym::Output, LangItem::Future),
2135            CoroutineKind::Gen => (sym::Item, LangItem::Iterator),
2136            CoroutineKind::AsyncGen => (sym::Item, LangItem::AsyncIterator),
2137        };
2138
2139        let bound_args = self.arena.alloc(hir::GenericArgs {
2140            args: &[],
2141            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)],
2142            parenthesized: hir::GenericArgsParentheses::No,
2143            span_ext: DUMMY_SP,
2144        });
2145
2146        hir::GenericBound::Trait(hir::PolyTraitRef {
2147            bound_generic_params: &[],
2148            modifiers: hir::TraitBoundModifiers::NONE,
2149            trait_ref: hir::TraitRef {
2150                path: self.make_lang_item_path(trait_lang_item, opaque_ty_span, Some(bound_args)),
2151                hir_ref_id: self.next_id(),
2152            },
2153            span: opaque_ty_span,
2154        })
2155    }
2156
2157    {}
#[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("/rustc-dev/ea137335b78829b4514bf1b4c16302f74fab8581/compiler/rustc_ast_lowering/src/lib.rs"),
                                    ::tracing_core::__macro_support::Option::Some(2157u32),
                                    ::tracing_core::__macro_support::Option::Some("rustc_ast_lowering"),
                                    ::tracing_core::field::FieldSet::new(&[{
                                                        const NAME:
                                                            ::tracing::__macro_support::FieldName<{
                                                                ::tracing::__macro_support::FieldName::len("tpb")
                                                            }> =
                                                            ::tracing::__macro_support::FieldName::new("tpb");
                                                        NAME.as_str()
                                                    },
                                                    {
                                                        const NAME:
                                                            ::tracing::__macro_support::FieldName<{
                                                                ::tracing::__macro_support::FieldName::len("rbp")
                                                            }> =
                                                            ::tracing::__macro_support::FieldName::new("rbp");
                                                        NAME.as_str()
                                                    },
                                                    {
                                                        const NAME:
                                                            ::tracing::__macro_support::FieldName<{
                                                                ::tracing::__macro_support::FieldName::len("itctx")
                                                            }> =
                                                            ::tracing::__macro_support::FieldName::new("itctx");
                                                        NAME.as_str()
                                                    }], ::tracing_core::callsite::Identifier(&__CALLSITE)),
                                    ::tracing::metadata::Kind::SPAN)
                            };
                        ::tracing::callsite::DefaultCallsite::new(&META)
                    };
                let mut interest = ::tracing::subscriber::Interest::never();
                if ::tracing::Level::TRACE <=
                                    ::tracing::level_filters::STATIC_MAX_LEVEL &&
                                ::tracing::Level::TRACE <=
                                    ::tracing::level_filters::LevelFilter::current() &&
                            { interest = __CALLSITE.interest(); !interest.is_never() }
                        &&
                        ::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
                            interest) {
                    let meta = __CALLSITE.metadata();
                    ::tracing::Span::new(meta,
                        &{
                                #[allow(unused_imports)]
                                use ::tracing::field::{debug, display, Value};
                                meta.fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&tpb)
                                                            as &dyn ::tracing::field::Value)),
                                                (::tracing::__macro_support::Option::Some(&::tracing::field::debug(&rbp)
                                                            as &dyn ::tracing::field::Value)),
                                                (::tracing::__macro_support::Option::Some(&::tracing::field::debug(&itctx)
                                                            as &dyn ::tracing::field::Value))])
                            })
                } else {
                    let span =
                        ::tracing::__macro_support::__disabled_span(__CALLSITE.metadata());
                    {};
                    span
                }
            };
        __tracing_attr_guard = __tracing_attr_span.enter();
    }

    #[warn(clippy :: suspicious_else_formatting)]
    {

        #[allow(unknown_lints, unreachable_code, clippy ::
        diverging_sub_expression, clippy :: empty_loop, clippy ::
        let_unit_value, clippy :: let_with_type_underscore, clippy ::
        needless_return, clippy :: unreachable)]
        if false {
            let __tracing_attr_fake_return: 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))]
2158    fn lower_param_bound(
2159        &mut self,
2160        tpb: &GenericBound,
2161        rbp: RelaxedBoundPolicy<'_>,
2162        itctx: ImplTraitContext,
2163    ) -> hir::GenericBound<'hir> {
2164        match tpb {
2165            GenericBound::Trait(p) => {
2166                hir::GenericBound::Trait(self.lower_poly_trait_ref(p, rbp, itctx))
2167            }
2168            GenericBound::Outlives(lifetime) => hir::GenericBound::Outlives(self.lower_lifetime(
2169                lifetime,
2170                LifetimeSource::OutlivesBound,
2171                lifetime.ident.into(),
2172            )),
2173            GenericBound::Use(args, span) => hir::GenericBound::Use(
2174                self.lower_precise_capturing_args(args),
2175                self.lower_span(*span),
2176            ),
2177        }
2178    }
2179
2180    fn lower_lifetime(
2181        &mut self,
2182        l: &Lifetime,
2183        source: LifetimeSource,
2184        syntax: LifetimeSyntax,
2185    ) -> &'hir hir::Lifetime {
2186        self.new_named_lifetime(l.id, l.id, l.ident, source, syntax)
2187    }
2188
2189    fn lower_lifetime_hidden_in_path(
2190        &mut self,
2191        id: NodeId,
2192        span: Span,
2193        angle_brackets: AngleBrackets,
2194    ) -> &'hir hir::Lifetime {
2195        self.new_named_lifetime(
2196            id,
2197            id,
2198            Ident::new(kw::UnderscoreLifetime, span),
2199            LifetimeSource::Path { angle_brackets },
2200            LifetimeSyntax::Implicit,
2201        )
2202    }
2203
2204    {}
#[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("/rustc-dev/ea137335b78829b4514bf1b4c16302f74fab8581/compiler/rustc_ast_lowering/src/lib.rs"),
                                    ::tracing_core::__macro_support::Option::Some(2204u32),
                                    ::tracing_core::__macro_support::Option::Some("rustc_ast_lowering"),
                                    ::tracing_core::field::FieldSet::new(&[{
                                                        const NAME:
                                                            ::tracing::__macro_support::FieldName<{
                                                                ::tracing::__macro_support::FieldName::len("id")
                                                            }> =
                                                            ::tracing::__macro_support::FieldName::new("id");
                                                        NAME.as_str()
                                                    },
                                                    {
                                                        const NAME:
                                                            ::tracing::__macro_support::FieldName<{
                                                                ::tracing::__macro_support::FieldName::len("new_id")
                                                            }> =
                                                            ::tracing::__macro_support::FieldName::new("new_id");
                                                        NAME.as_str()
                                                    },
                                                    {
                                                        const NAME:
                                                            ::tracing::__macro_support::FieldName<{
                                                                ::tracing::__macro_support::FieldName::len("ident")
                                                            }> =
                                                            ::tracing::__macro_support::FieldName::new("ident");
                                                        NAME.as_str()
                                                    },
                                                    {
                                                        const NAME:
                                                            ::tracing::__macro_support::FieldName<{
                                                                ::tracing::__macro_support::FieldName::len("source")
                                                            }> =
                                                            ::tracing::__macro_support::FieldName::new("source");
                                                        NAME.as_str()
                                                    },
                                                    {
                                                        const NAME:
                                                            ::tracing::__macro_support::FieldName<{
                                                                ::tracing::__macro_support::FieldName::len("syntax")
                                                            }> =
                                                            ::tracing::__macro_support::FieldName::new("syntax");
                                                        NAME.as_str()
                                                    }], ::tracing_core::callsite::Identifier(&__CALLSITE)),
                                    ::tracing::metadata::Kind::SPAN)
                            };
                        ::tracing::callsite::DefaultCallsite::new(&META)
                    };
                let mut interest = ::tracing::subscriber::Interest::never();
                if ::tracing::Level::DEBUG <=
                                    ::tracing::level_filters::STATIC_MAX_LEVEL &&
                                ::tracing::Level::DEBUG <=
                                    ::tracing::level_filters::LevelFilter::current() &&
                            { interest = __CALLSITE.interest(); !interest.is_never() }
                        &&
                        ::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
                            interest) {
                    let meta = __CALLSITE.metadata();
                    ::tracing::Span::new(meta,
                        &{
                                #[allow(unused_imports)]
                                use ::tracing::field::{debug, display, Value};
                                meta.fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&id)
                                                            as &dyn ::tracing::field::Value)),
                                                (::tracing::__macro_support::Option::Some(&::tracing::field::debug(&new_id)
                                                            as &dyn ::tracing::field::Value)),
                                                (::tracing::__macro_support::Option::Some(&::tracing::field::debug(&ident)
                                                            as &dyn ::tracing::field::Value)),
                                                (::tracing::__macro_support::Option::Some(&::tracing::field::debug(&source)
                                                            as &dyn ::tracing::field::Value)),
                                                (::tracing::__macro_support::Option::Some(&::tracing::field::debug(&syntax)
                                                            as &dyn ::tracing::field::Value))])
                            })
                } else {
                    let span =
                        ::tracing::__macro_support::__disabled_span(__CALLSITE.metadata());
                    {};
                    span
                }
            };
        __tracing_attr_guard = __tracing_attr_span.enter();
    }

    #[warn(clippy :: suspicious_else_formatting)]
    {

        #[allow(unknown_lints, unreachable_code, clippy ::
        diverging_sub_expression, clippy :: empty_loop, clippy ::
        let_unit_value, clippy :: let_with_type_underscore, clippy ::
        needless_return, clippy :: unreachable)]
        if false {
            let __tracing_attr_fake_return: &'hir hir::Lifetime = loop {};
            return __tracing_attr_fake_return;
        }
        {
            let res =
                if let Some(res) = self.curr_owner.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 /rustc-dev/ea137335b78829b4514bf1b4c16302f74fab8581/compiler/rustc_ast_lowering/src/lib.rs:2238",
                                    "rustc_ast_lowering", ::tracing::Level::DEBUG,
                                    ::tracing_core::__macro_support::Option::Some("/rustc-dev/ea137335b78829b4514bf1b4c16302f74fab8581/compiler/rustc_ast_lowering/src/lib.rs"),
                                    ::tracing_core::__macro_support::Option::Some(2238u32),
                                    ::tracing_core::__macro_support::Option::Some("rustc_ast_lowering"),
                                    ::tracing_core::field::FieldSet::new(&[{
                                                        const NAME:
                                                            ::tracing::__macro_support::FieldName<{
                                                                ::tracing::__macro_support::FieldName::len("res")
                                                            }> =
                                                            ::tracing::__macro_support::FieldName::new("res");
                                                        NAME.as_str()
                                                    }], ::tracing_core::callsite::Identifier(&__CALLSITE)),
                                    ::tracing::metadata::Kind::EVENT)
                            };
                        ::tracing::callsite::DefaultCallsite::new(&META)
                    };
                let enabled =
                    ::tracing::Level::DEBUG <=
                                ::tracing::level_filters::STATIC_MAX_LEVEL &&
                            ::tracing::Level::DEBUG <=
                                ::tracing::level_filters::LevelFilter::current() &&
                        {
                            let interest = __CALLSITE.interest();
                            !interest.is_never() &&
                                ::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
                                    interest)
                        };
                if enabled {
                    (|value_set: ::tracing::field::ValueSet|
                                {
                                    let meta = __CALLSITE.metadata();
                                    ::tracing::Event::dispatch(meta, &value_set);
                                    ;
                                })({
                            #[allow(unused_imports)]
                            use ::tracing::field::{debug, display, Value};
                            __CALLSITE.metadata().fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&res)
                                                        as &dyn ::tracing::field::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))]
2205    fn new_named_lifetime(
2206        &mut self,
2207        id: NodeId,
2208        new_id: NodeId,
2209        ident: Ident,
2210        source: LifetimeSource,
2211        syntax: LifetimeSyntax,
2212    ) -> &'hir hir::Lifetime {
2213        let res = if let Some(res) = self.curr_owner.owner.get_lifetime_res(id) {
2214            match res {
2215                LifetimeRes::Param { param, .. } => hir::LifetimeKind::Param(param),
2216                LifetimeRes::Fresh { param, .. } => {
2217                    assert_eq!(ident.name, kw::UnderscoreLifetime);
2218                    let param = self.local_def_id(param);
2219                    hir::LifetimeKind::Param(param)
2220                }
2221                LifetimeRes::Infer => {
2222                    assert_eq!(ident.name, kw::UnderscoreLifetime);
2223                    hir::LifetimeKind::Infer
2224                }
2225                LifetimeRes::Static { .. } => {
2226                    assert!(matches!(ident.name, kw::StaticLifetime | kw::UnderscoreLifetime));
2227                    hir::LifetimeKind::Static
2228                }
2229                LifetimeRes::Error(guar) => hir::LifetimeKind::Error(guar),
2230                LifetimeRes::ElidedAnchor { .. } => {
2231                    panic!("Unexpected `ElidedAnchar` {:?} at {:?}", ident, ident.span);
2232                }
2233            }
2234        } else {
2235            hir::LifetimeKind::Error(self.dcx().span_delayed_bug(ident.span, "unresolved lifetime"))
2236        };
2237
2238        debug!(?res);
2239        self.arena.alloc(hir::Lifetime::new(
2240            self.lower_node_id(new_id),
2241            self.lower_ident(ident),
2242            res,
2243            source,
2244            syntax,
2245        ))
2246    }
2247
2248    fn lower_generic_params_mut(
2249        &mut self,
2250        params: &[GenericParam],
2251        source: hir::GenericParamSource,
2252    ) -> impl Iterator<Item = hir::GenericParam<'hir>> {
2253        params.iter().map(move |param| self.lower_generic_param(param, source))
2254    }
2255
2256    fn lower_generic_params(
2257        &mut self,
2258        params: &[GenericParam],
2259        source: hir::GenericParamSource,
2260    ) -> &'hir [hir::GenericParam<'hir>] {
2261        self.arena.alloc_from_iter(self.lower_generic_params_mut(params, source))
2262    }
2263
2264    {}
#[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("/rustc-dev/ea137335b78829b4514bf1b4c16302f74fab8581/compiler/rustc_ast_lowering/src/lib.rs"),
                                    ::tracing_core::__macro_support::Option::Some(2264u32),
                                    ::tracing_core::__macro_support::Option::Some("rustc_ast_lowering"),
                                    ::tracing_core::field::FieldSet::new(&[{
                                                        const NAME:
                                                            ::tracing::__macro_support::FieldName<{
                                                                ::tracing::__macro_support::FieldName::len("param")
                                                            }> =
                                                            ::tracing::__macro_support::FieldName::new("param");
                                                        NAME.as_str()
                                                    },
                                                    {
                                                        const NAME:
                                                            ::tracing::__macro_support::FieldName<{
                                                                ::tracing::__macro_support::FieldName::len("source")
                                                            }> =
                                                            ::tracing::__macro_support::FieldName::new("source");
                                                        NAME.as_str()
                                                    }], ::tracing_core::callsite::Identifier(&__CALLSITE)),
                                    ::tracing::metadata::Kind::SPAN)
                            };
                        ::tracing::callsite::DefaultCallsite::new(&META)
                    };
                let mut interest = ::tracing::subscriber::Interest::never();
                if ::tracing::Level::TRACE <=
                                    ::tracing::level_filters::STATIC_MAX_LEVEL &&
                                ::tracing::Level::TRACE <=
                                    ::tracing::level_filters::LevelFilter::current() &&
                            { interest = __CALLSITE.interest(); !interest.is_never() }
                        &&
                        ::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
                            interest) {
                    let meta = __CALLSITE.metadata();
                    ::tracing::Span::new(meta,
                        &{
                                #[allow(unused_imports)]
                                use ::tracing::field::{debug, display, Value};
                                meta.fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&param)
                                                            as &dyn ::tracing::field::Value)),
                                                (::tracing::__macro_support::Option::Some(&::tracing::field::debug(&source)
                                                            as &dyn ::tracing::field::Value))])
                            })
                } else {
                    let span =
                        ::tracing::__macro_support::__disabled_span(__CALLSITE.metadata());
                    {};
                    span
                }
            };
        __tracing_attr_guard = __tracing_attr_span.enter();
    }

    #[warn(clippy :: suspicious_else_formatting)]
    {

        #[allow(unknown_lints, unreachable_code, clippy ::
        diverging_sub_expression, clippy :: empty_loop, clippy ::
        let_unit_value, clippy :: let_with_type_underscore, clippy ::
        needless_return, clippy :: unreachable)]
        if false {
            let __tracing_attr_fake_return: 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(&param));
            param
        }
    }
}#[instrument(level = "trace", skip(self))]
2265    fn lower_generic_param(
2266        &mut self,
2267        param: &GenericParam,
2268        source: hir::GenericParamSource,
2269    ) -> hir::GenericParam<'hir> {
2270        let (name, kind) = self.lower_generic_param_kind(param, source);
2271
2272        let hir_id = self.lower_node_id(param.id);
2273        let param_attrs = &param.attrs;
2274        let param_span = param.span();
2275        let param = hir::GenericParam {
2276            hir_id,
2277            def_id: self.local_def_id(param.id),
2278            name,
2279            span: self.lower_span(param.span()),
2280            pure_wrt_drop: attr::contains_name(&param.attrs, sym::may_dangle),
2281            kind,
2282            colon_span: param.colon_span.map(|s| self.lower_span(s)),
2283            source,
2284        };
2285        self.lower_attrs(hir_id, param_attrs, param_span, Target::from(&param));
2286        param
2287    }
2288
2289    fn lower_generic_param_kind(
2290        &mut self,
2291        param: &GenericParam,
2292        source: hir::GenericParamSource,
2293    ) -> (hir::ParamName, hir::GenericParamKind<'hir>) {
2294        match &param.kind {
2295            GenericParamKind::Lifetime => {
2296                // AST resolution emitted an error on those parameters, so we lower them using
2297                // `ParamName::Error`.
2298                let ident = self.lower_ident(param.ident);
2299                let param_name = if let Some(LifetimeRes::Error(..)) =
2300                    self.curr_owner.owner.get_lifetime_res(param.id)
2301                {
2302                    ParamName::Error(ident)
2303                } else {
2304                    ParamName::Plain(ident)
2305                };
2306                let kind =
2307                    hir::GenericParamKind::Lifetime { kind: hir::LifetimeParamKind::Explicit };
2308
2309                (param_name, kind)
2310            }
2311            GenericParamKind::Type { default, .. } => {
2312                // Not only do we deny type param defaults in binders but we also map them to `None`
2313                // since later compiler stages cannot handle them (and shouldn't need to be able to).
2314                let default = default
2315                    .as_ref()
2316                    .filter(|_| match source {
2317                        hir::GenericParamSource::Generics => true,
2318                        hir::GenericParamSource::Binder => {
2319                            self.dcx().emit_err(diagnostics::GenericParamDefaultInBinder {
2320                                span: param.span(),
2321                            });
2322
2323                            false
2324                        }
2325                    })
2326                    .map(|def| {
2327                        self.lower_ty_alloc(
2328                            def,
2329                            ImplTraitContext::Disallowed(ImplTraitPosition::GenericDefault),
2330                        )
2331                    });
2332
2333                let kind = hir::GenericParamKind::Type { default, synthetic: false };
2334
2335                (hir::ParamName::Plain(self.lower_ident(param.ident)), kind)
2336            }
2337            GenericParamKind::Const { ty, span: _, default } => {
2338                let ty = self.lower_ty_alloc(
2339                    ty,
2340                    ImplTraitContext::Disallowed(ImplTraitPosition::GenericDefault),
2341                );
2342
2343                // Not only do we deny const param defaults in binders but we also map them to `None`
2344                // since later compiler stages cannot handle them (and shouldn't need to be able to).
2345                let default = default
2346                    .as_ref()
2347                    .filter(|anon_const| match source {
2348                        hir::GenericParamSource::Generics => true,
2349                        hir::GenericParamSource::Binder => {
2350                            let err =
2351                                diagnostics::GenericParamDefaultInBinder { span: param.span() };
2352                            if expr::WillCreateDefIdsVisitor
2353                                .visit_expr(&anon_const.value)
2354                                .is_break()
2355                            {
2356                                // FIXME(mgca): make this non-fatal once we have a better way
2357                                // to handle nested items in anno const from binder
2358                                // Issue: https://github.com/rust-lang/rust/issues/123629
2359                                self.dcx().emit_fatal(err)
2360                            } else {
2361                                self.dcx().emit_err(err);
2362                                false
2363                            }
2364                        }
2365                    })
2366                    .map(|def| self.lower_anon_const_to_const_arg_and_alloc(def));
2367
2368                (
2369                    hir::ParamName::Plain(self.lower_ident(param.ident)),
2370                    hir::GenericParamKind::Const { ty, default },
2371                )
2372            }
2373        }
2374    }
2375
2376    fn lower_trait_ref(
2377        &mut self,
2378        modifiers: ast::TraitBoundModifiers,
2379        p: &TraitRef,
2380        itctx: ImplTraitContext,
2381    ) -> hir::TraitRef<'hir> {
2382        let path = match self.lower_qpath(
2383            p.ref_id,
2384            &None,
2385            &p.path,
2386            ParamMode::Explicit,
2387            AllowReturnTypeNotation::No,
2388            itctx,
2389            Some(modifiers),
2390        ) {
2391            hir::QPath::Resolved(None, path) => path,
2392            qpath => {
    ::core::panicking::panic_fmt(format_args!("lower_trait_ref: unexpected QPath `{0:?}`",
            qpath));
}panic!("lower_trait_ref: unexpected QPath `{qpath:?}`"),
2393        };
2394        hir::TraitRef { path, hir_ref_id: self.lower_node_id(p.ref_id) }
2395    }
2396
2397    {}
#[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("/rustc-dev/ea137335b78829b4514bf1b4c16302f74fab8581/compiler/rustc_ast_lowering/src/lib.rs"),
                                    ::tracing_core::__macro_support::Option::Some(2397u32),
                                    ::tracing_core::__macro_support::Option::Some("rustc_ast_lowering"),
                                    ::tracing_core::field::FieldSet::new(&[{
                                                        const NAME:
                                                            ::tracing::__macro_support::FieldName<{
                                                                ::tracing::__macro_support::FieldName::len("bound_generic_params")
                                                            }> =
                                                            ::tracing::__macro_support::FieldName::new("bound_generic_params");
                                                        NAME.as_str()
                                                    },
                                                    {
                                                        const NAME:
                                                            ::tracing::__macro_support::FieldName<{
                                                                ::tracing::__macro_support::FieldName::len("modifiers")
                                                            }> =
                                                            ::tracing::__macro_support::FieldName::new("modifiers");
                                                        NAME.as_str()
                                                    },
                                                    {
                                                        const NAME:
                                                            ::tracing::__macro_support::FieldName<{
                                                                ::tracing::__macro_support::FieldName::len("trait_ref")
                                                            }> =
                                                            ::tracing::__macro_support::FieldName::new("trait_ref");
                                                        NAME.as_str()
                                                    },
                                                    {
                                                        const NAME:
                                                            ::tracing::__macro_support::FieldName<{
                                                                ::tracing::__macro_support::FieldName::len("span")
                                                            }> =
                                                            ::tracing::__macro_support::FieldName::new("span");
                                                        NAME.as_str()
                                                    },
                                                    {
                                                        const NAME:
                                                            ::tracing::__macro_support::FieldName<{
                                                                ::tracing::__macro_support::FieldName::len("rbp")
                                                            }> =
                                                            ::tracing::__macro_support::FieldName::new("rbp");
                                                        NAME.as_str()
                                                    },
                                                    {
                                                        const NAME:
                                                            ::tracing::__macro_support::FieldName<{
                                                                ::tracing::__macro_support::FieldName::len("itctx")
                                                            }> =
                                                            ::tracing::__macro_support::FieldName::new("itctx");
                                                        NAME.as_str()
                                                    }], ::tracing_core::callsite::Identifier(&__CALLSITE)),
                                    ::tracing::metadata::Kind::SPAN)
                            };
                        ::tracing::callsite::DefaultCallsite::new(&META)
                    };
                let mut interest = ::tracing::subscriber::Interest::never();
                if ::tracing::Level::DEBUG <=
                                    ::tracing::level_filters::STATIC_MAX_LEVEL &&
                                ::tracing::Level::DEBUG <=
                                    ::tracing::level_filters::LevelFilter::current() &&
                            { interest = __CALLSITE.interest(); !interest.is_never() }
                        &&
                        ::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
                            interest) {
                    let meta = __CALLSITE.metadata();
                    ::tracing::Span::new(meta,
                        &{
                                #[allow(unused_imports)]
                                use ::tracing::field::{debug, display, Value};
                                meta.fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&bound_generic_params)
                                                            as &dyn ::tracing::field::Value)),
                                                (::tracing::__macro_support::Option::Some(&::tracing::field::debug(&modifiers)
                                                            as &dyn ::tracing::field::Value)),
                                                (::tracing::__macro_support::Option::Some(&::tracing::field::debug(&trait_ref)
                                                            as &dyn ::tracing::field::Value)),
                                                (::tracing::__macro_support::Option::Some(&::tracing::field::debug(&span)
                                                            as &dyn ::tracing::field::Value)),
                                                (::tracing::__macro_support::Option::Some(&::tracing::field::debug(&rbp)
                                                            as &dyn ::tracing::field::Value)),
                                                (::tracing::__macro_support::Option::Some(&::tracing::field::debug(&itctx)
                                                            as &dyn ::tracing::field::Value))])
                            })
                } else {
                    let span =
                        ::tracing::__macro_support::__disabled_span(__CALLSITE.metadata());
                    {};
                    span
                }
            };
        __tracing_attr_guard = __tracing_attr_span.enter();
    }

    #[warn(clippy :: suspicious_else_formatting)]
    {

        #[allow(unknown_lints, unreachable_code, clippy ::
        diverging_sub_expression, clippy :: empty_loop, clippy ::
        let_unit_value, clippy :: let_with_type_underscore, clippy ::
        needless_return, clippy :: unreachable)]
        if false {
            let __tracing_attr_fake_return: 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))]
2398    fn lower_poly_trait_ref(
2399        &mut self,
2400        PolyTraitRef { bound_generic_params, modifiers, trait_ref, span, parens: _ }: &PolyTraitRef,
2401        rbp: RelaxedBoundPolicy<'_>,
2402        itctx: ImplTraitContext,
2403    ) -> hir::PolyTraitRef<'hir> {
2404        let bound_generic_params =
2405            self.lower_lifetime_binder(trait_ref.ref_id, bound_generic_params);
2406        let trait_ref = self.lower_trait_ref(*modifiers, trait_ref, itctx);
2407        let modifiers = self.lower_trait_bound_modifiers(*modifiers);
2408
2409        if let ast::BoundPolarity::Maybe(_) = modifiers.polarity {
2410            self.validate_relaxed_bound(trait_ref, *span, rbp);
2411        }
2412
2413        hir::PolyTraitRef {
2414            bound_generic_params,
2415            modifiers,
2416            trait_ref,
2417            span: self.lower_span(*span),
2418        }
2419    }
2420
2421    fn validate_relaxed_bound(
2422        &self,
2423        trait_ref: hir::TraitRef<'_>,
2424        span: Span,
2425        rbp: RelaxedBoundPolicy<'_>,
2426    ) {
2427        // Even though feature `more_maybe_bounds` enables the user to relax all default bounds
2428        // other than `Sized` in a lot more positions (thereby bypassing the given policy), we don't
2429        // want to advertise it to the user (via a feature gate error) since it's super internal.
2430        //
2431        // FIXME(more_maybe_bounds): Moreover, if we actually were to add proper default traits
2432        // (like a hypothetical `Move` or `Leak`) we would want to validate the location according
2433        // to default trait elaboration in HIR ty lowering (which depends on the specific trait in
2434        // question: E.g., `?Sized` & `?Move` most likely won't be allowed in all the same places).
2435
2436        match rbp {
2437            RelaxedBoundPolicy::Allowed(dedup_map) => {
2438                // `trait_def_id` only returns `None` for errors during resolution.
2439                let Some(trait_def_id) = trait_ref.trait_def_id() else { return };
2440                let tcx = self.tcx;
2441                let err = |s| {
2442                    let name = tcx.item_name(trait_def_id);
2443                    tcx.dcx()
2444                        .struct_span_err(
2445                            ::alloc::boxed::box_assume_init_into_vec_unsafe(::alloc::intrinsics::write_box_via_move(::alloc::boxed::Box::new_uninit(),
        [span, s]))vec![span, s],
2446                            ::alloc::__export::must_use({
        ::alloc::fmt::format(format_args!("duplicate relaxed `{0}` bounds",
                name))
    })format!("duplicate relaxed `{name}` bounds"),
2447                        )
2448                        .with_code(E0203)
2449                        .emit();
2450                };
2451                dedup_map.entry(trait_def_id).and_modify(|&mut s| err(s)).or_insert(span);
2452                return;
2453            }
2454            RelaxedBoundPolicy::Forbidden(reason) => {
2455                let gate = |context, subject| {
2456                    let extended = self.tcx.features().more_maybe_bounds();
2457                    let is_sized = trait_ref
2458                        .trait_def_id()
2459                        .is_some_and(|def_id| self.tcx.is_lang_item(def_id, LangItem::Sized));
2460
2461                    if extended && !is_sized {
2462                        return;
2463                    }
2464
2465                    let prefix = if extended { "`Sized` " } else { "" };
2466                    let mut diag = self.dcx().struct_span_err(
2467                        span,
2468                        ::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}"),
2469                    );
2470                    if is_sized {
2471                        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!(
2472                            "{subject} are not implicitly bounded by `Sized`, \
2473                             so there is nothing to relax"
2474                        ));
2475                    }
2476                    diag.emit();
2477                };
2478
2479                match reason {
2480                    RelaxedBoundForbiddenReason::TraitObjectTy => {
2481                        gate("trait object types", "trait object types");
2482                        return;
2483                    }
2484                    RelaxedBoundForbiddenReason::SuperTrait => {
2485                        gate("supertrait bounds", "traits");
2486                        return;
2487                    }
2488                    RelaxedBoundForbiddenReason::TraitAlias => {
2489                        gate("trait alias bounds", "trait aliases");
2490                        return;
2491                    }
2492                    RelaxedBoundForbiddenReason::AssocTyBounds
2493                    | RelaxedBoundForbiddenReason::WhereBound => {}
2494                };
2495            }
2496        }
2497
2498        self.dcx()
2499            .struct_span_err(span, "this relaxed bound is not permitted here")
2500            .with_note(
2501                "in this context, relaxed bounds are only allowed on \
2502                 type parameters defined on the closest item",
2503            )
2504            .emit();
2505    }
2506
2507    {}
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_param_bounds",
                                "rustc_ast_lowering", ::tracing::Level::DEBUG,
                                ::tracing_core::__macro_support::Option::Some("/rustc-dev/ea137335b78829b4514bf1b4c16302f74fab8581/compiler/rustc_ast_lowering/src/lib.rs"),
                                ::tracing_core::__macro_support::Option::Some(2507u32),
                                ::tracing_core::__macro_support::Option::Some("rustc_ast_lowering"),
                                ::tracing_core::field::FieldSet::new(&[{
                                                    const NAME:
                                                        ::tracing::__macro_support::FieldName<{
                                                            ::tracing::__macro_support::FieldName::len("bounds")
                                                        }> =
                                                        ::tracing::__macro_support::FieldName::new("bounds");
                                                    NAME.as_str()
                                                },
                                                {
                                                    const NAME:
                                                        ::tracing::__macro_support::FieldName<{
                                                            ::tracing::__macro_support::FieldName::len("rbp")
                                                        }> =
                                                        ::tracing::__macro_support::FieldName::new("rbp");
                                                    NAME.as_str()
                                                },
                                                {
                                                    const NAME:
                                                        ::tracing::__macro_support::FieldName<{
                                                            ::tracing::__macro_support::FieldName::len("itctx")
                                                        }> =
                                                        ::tracing::__macro_support::FieldName::new("itctx");
                                                    NAME.as_str()
                                                }], ::tracing_core::callsite::Identifier(&__CALLSITE)),
                                ::tracing::metadata::Kind::SPAN)
                        };
                    ::tracing::callsite::DefaultCallsite::new(&META)
                };
            let mut interest = ::tracing::subscriber::Interest::never();
            if ::tracing::Level::DEBUG <=
                                ::tracing::level_filters::STATIC_MAX_LEVEL &&
                            ::tracing::Level::DEBUG <=
                                ::tracing::level_filters::LevelFilter::current() &&
                        { interest = __CALLSITE.interest(); !interest.is_never() }
                    &&
                    ::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
                        interest) {
                let meta = __CALLSITE.metadata();
                ::tracing::Span::new(meta,
                    &{
                            #[allow(unused_imports)]
                            use ::tracing::field::{debug, display, Value};
                            meta.fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&bounds)
                                                        as &dyn ::tracing::field::Value)),
                                            (::tracing::__macro_support::Option::Some(&::tracing::field::debug(&rbp)
                                                        as &dyn ::tracing::field::Value)),
                                            (::tracing::__macro_support::Option::Some(&::tracing::field::debug(&itctx)
                                                        as &dyn ::tracing::field::Value))])
                        })
            } else {
                let span =
                    ::tracing::__macro_support::__disabled_span(__CALLSITE.metadata());
                {};
                span
            }
        };
    __tracing_attr_guard = __tracing_attr_span.enter();
}
#[allow(clippy :: redundant_closure_call)]
let x =
    (move ||
                {

                    #[allow(unknown_lints, unreachable_code, clippy ::
                    diverging_sub_expression, clippy :: empty_loop, clippy ::
                    let_unit_value, clippy :: let_with_type_underscore, clippy
                    :: needless_return, clippy :: unreachable)]
                    if false {
                        let __tracing_attr_fake_return: hir::GenericBounds<'hir> =
                            loop {};
                        return __tracing_attr_fake_return;
                    }
                    {
                        self.arena.alloc_from_iter(self.lower_param_bounds_mut(bounds,
                                rbp, itctx))
                    }
                })();
{
    use ::tracing::__macro_support::Callsite as _;
    static __CALLSITE: ::tracing::callsite::DefaultCallsite =
        {
            static META: ::tracing::Metadata<'static> =
                {
                    ::tracing_core::metadata::Metadata::new("event /rustc-dev/ea137335b78829b4514bf1b4c16302f74fab8581/compiler/rustc_ast_lowering/src/lib.rs:2507",
                        "rustc_ast_lowering", ::tracing::Level::DEBUG,
                        ::tracing_core::__macro_support::Option::Some("/rustc-dev/ea137335b78829b4514bf1b4c16302f74fab8581/compiler/rustc_ast_lowering/src/lib.rs"),
                        ::tracing_core::__macro_support::Option::Some(2507u32),
                        ::tracing_core::__macro_support::Option::Some("rustc_ast_lowering"),
                        ::tracing_core::field::FieldSet::new(&[{
                                            const NAME:
                                                ::tracing::__macro_support::FieldName<{
                                                    ::tracing::__macro_support::FieldName::len("return")
                                                }> =
                                                ::tracing::__macro_support::FieldName::new("return");
                                            NAME.as_str()
                                        }], ::tracing_core::callsite::Identifier(&__CALLSITE)),
                        ::tracing::metadata::Kind::EVENT)
                };
            ::tracing::callsite::DefaultCallsite::new(&META)
        };
    let enabled =
        ::tracing::Level::DEBUG <= ::tracing::level_filters::STATIC_MAX_LEVEL
                &&
                ::tracing::Level::DEBUG <=
                    ::tracing::level_filters::LevelFilter::current() &&
            {
                let interest = __CALLSITE.interest();
                !interest.is_never() &&
                    ::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
                        interest)
            };
    if enabled {
        (|value_set: ::tracing::field::ValueSet|
                    {
                        let meta = __CALLSITE.metadata();
                        ::tracing::Event::dispatch(meta, &value_set);
                        ;
                    })({
                #[allow(unused_imports)]
                use ::tracing::field::{debug, display, Value};
                __CALLSITE.metadata().fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&x)
                                            as &dyn ::tracing::field::Value))])
            });
    } else { ; }
};
x;#[instrument(level = "debug", skip(self), ret)]
2508    fn lower_param_bounds(
2509        &mut self,
2510        bounds: &[GenericBound],
2511        rbp: RelaxedBoundPolicy<'_>,
2512        itctx: ImplTraitContext,
2513    ) -> hir::GenericBounds<'hir> {
2514        self.arena.alloc_from_iter(self.lower_param_bounds_mut(bounds, rbp, itctx))
2515    }
2516
2517    fn lower_param_bounds_mut(
2518        &mut self,
2519        bounds: &[GenericBound],
2520        mut rbp: RelaxedBoundPolicy<'_>,
2521        itctx: ImplTraitContext,
2522    ) -> impl Iterator<Item = hir::GenericBound<'hir>> {
2523        bounds.iter().map(move |bound| self.lower_param_bound(bound, rbp.reborrow(), itctx))
2524    }
2525
2526    {}
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_universal_param_and_bounds",
                                "rustc_ast_lowering", ::tracing::Level::DEBUG,
                                ::tracing_core::__macro_support::Option::Some("/rustc-dev/ea137335b78829b4514bf1b4c16302f74fab8581/compiler/rustc_ast_lowering/src/lib.rs"),
                                ::tracing_core::__macro_support::Option::Some(2526u32),
                                ::tracing_core::__macro_support::Option::Some("rustc_ast_lowering"),
                                ::tracing_core::field::FieldSet::new(&[{
                                                    const NAME:
                                                        ::tracing::__macro_support::FieldName<{
                                                            ::tracing::__macro_support::FieldName::len("node_id")
                                                        }> =
                                                        ::tracing::__macro_support::FieldName::new("node_id");
                                                    NAME.as_str()
                                                },
                                                {
                                                    const NAME:
                                                        ::tracing::__macro_support::FieldName<{
                                                            ::tracing::__macro_support::FieldName::len("span")
                                                        }> =
                                                        ::tracing::__macro_support::FieldName::new("span");
                                                    NAME.as_str()
                                                },
                                                {
                                                    const NAME:
                                                        ::tracing::__macro_support::FieldName<{
                                                            ::tracing::__macro_support::FieldName::len("ident")
                                                        }> =
                                                        ::tracing::__macro_support::FieldName::new("ident");
                                                    NAME.as_str()
                                                },
                                                {
                                                    const NAME:
                                                        ::tracing::__macro_support::FieldName<{
                                                            ::tracing::__macro_support::FieldName::len("bounds")
                                                        }> =
                                                        ::tracing::__macro_support::FieldName::new("bounds");
                                                    NAME.as_str()
                                                }], ::tracing_core::callsite::Identifier(&__CALLSITE)),
                                ::tracing::metadata::Kind::SPAN)
                        };
                    ::tracing::callsite::DefaultCallsite::new(&META)
                };
            let mut interest = ::tracing::subscriber::Interest::never();
            if ::tracing::Level::DEBUG <=
                                ::tracing::level_filters::STATIC_MAX_LEVEL &&
                            ::tracing::Level::DEBUG <=
                                ::tracing::level_filters::LevelFilter::current() &&
                        { interest = __CALLSITE.interest(); !interest.is_never() }
                    &&
                    ::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
                        interest) {
                let meta = __CALLSITE.metadata();
                ::tracing::Span::new(meta,
                    &{
                            #[allow(unused_imports)]
                            use ::tracing::field::{debug, display, Value};
                            meta.fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&node_id)
                                                        as &dyn ::tracing::field::Value)),
                                            (::tracing::__macro_support::Option::Some(&::tracing::field::debug(&span)
                                                        as &dyn ::tracing::field::Value)),
                                            (::tracing::__macro_support::Option::Some(&::tracing::field::debug(&ident)
                                                        as &dyn ::tracing::field::Value)),
                                            (::tracing::__macro_support::Option::Some(&::tracing::field::debug(&bounds)
                                                        as &dyn ::tracing::field::Value))])
                        })
            } else {
                let span =
                    ::tracing::__macro_support::__disabled_span(__CALLSITE.metadata());
                {};
                span
            }
        };
    __tracing_attr_guard = __tracing_attr_span.enter();
}
#[allow(clippy :: redundant_closure_call)]
let x =
    (move ||
                {

                    #[allow(unknown_lints, unreachable_code, clippy ::
                    diverging_sub_expression, clippy :: empty_loop, clippy ::
                    let_unit_value, clippy :: let_with_type_underscore, clippy
                    :: needless_return, clippy :: unreachable)]
                    if false {
                        let __tracing_attr_fake_return:
                                (hir::GenericParam<'hir>, Option<hir::WherePredicate<'hir>>,
                                hir::TyKind<'hir>) = loop {};
                        return __tracing_attr_fake_return;
                    }
                    {
                        let def_id = self.local_def_id(node_id);
                        let span = self.lower_span(span);
                        let param =
                            hir::GenericParam {
                                hir_id: self.lower_node_id(node_id),
                                def_id,
                                name: ParamName::Plain(self.lower_ident(ident)),
                                pure_wrt_drop: false,
                                span,
                                kind: hir::GenericParamKind::Type {
                                    default: None,
                                    synthetic: true,
                                },
                                colon_span: None,
                                source: hir::GenericParamSource::Generics,
                            };
                        let preds =
                            self.lower_generic_bound_predicate(ident, node_id,
                                &GenericParamKind::Type { default: None }, bounds, None,
                                span, RelaxedBoundPolicy::Allowed(&mut Default::default()),
                                ImplTraitContext::Universal,
                                hir::PredicateOrigin::ImplTrait);
                        let hir_id = self.next_id();
                        let res = Res::Def(DefKind::TyParam, def_id.to_def_id());
                        let ty =
                            hir::TyKind::Path(hir::QPath::Resolved(None,
                                    self.arena.alloc(hir::Path {
                                            span,
                                            res,
                                            segments: self.arena.alloc_from_iter([hir::PathSegment::new(self.lower_ident(ident),
                                                            hir_id, res)]),
                                        })));
                        (param, preds, ty)
                    }
                })();
{
    use ::tracing::__macro_support::Callsite as _;
    static __CALLSITE: ::tracing::callsite::DefaultCallsite =
        {
            static META: ::tracing::Metadata<'static> =
                {
                    ::tracing_core::metadata::Metadata::new("event /rustc-dev/ea137335b78829b4514bf1b4c16302f74fab8581/compiler/rustc_ast_lowering/src/lib.rs:2526",
                        "rustc_ast_lowering", ::tracing::Level::DEBUG,
                        ::tracing_core::__macro_support::Option::Some("/rustc-dev/ea137335b78829b4514bf1b4c16302f74fab8581/compiler/rustc_ast_lowering/src/lib.rs"),
                        ::tracing_core::__macro_support::Option::Some(2526u32),
                        ::tracing_core::__macro_support::Option::Some("rustc_ast_lowering"),
                        ::tracing_core::field::FieldSet::new(&[{
                                            const NAME:
                                                ::tracing::__macro_support::FieldName<{
                                                    ::tracing::__macro_support::FieldName::len("return")
                                                }> =
                                                ::tracing::__macro_support::FieldName::new("return");
                                            NAME.as_str()
                                        }], ::tracing_core::callsite::Identifier(&__CALLSITE)),
                        ::tracing::metadata::Kind::EVENT)
                };
            ::tracing::callsite::DefaultCallsite::new(&META)
        };
    let enabled =
        ::tracing::Level::DEBUG <= ::tracing::level_filters::STATIC_MAX_LEVEL
                &&
                ::tracing::Level::DEBUG <=
                    ::tracing::level_filters::LevelFilter::current() &&
            {
                let interest = __CALLSITE.interest();
                !interest.is_never() &&
                    ::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
                        interest)
            };
    if enabled {
        (|value_set: ::tracing::field::ValueSet|
                    {
                        let meta = __CALLSITE.metadata();
                        ::tracing::Event::dispatch(meta, &value_set);
                        ;
                    })({
                #[allow(unused_imports)]
                use ::tracing::field::{debug, display, Value};
                __CALLSITE.metadata().fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&x)
                                            as &dyn ::tracing::field::Value))])
            });
    } else { ; }
};
x;#[instrument(level = "debug", skip(self), ret)]
2527    fn lower_universal_param_and_bounds(
2528        &mut self,
2529        node_id: NodeId,
2530        span: Span,
2531        ident: Ident,
2532        bounds: &[GenericBound],
2533    ) -> (hir::GenericParam<'hir>, Option<hir::WherePredicate<'hir>>, hir::TyKind<'hir>) {
2534        // Add a definition for the in-band `Param`.
2535        let def_id = self.local_def_id(node_id);
2536        let span = self.lower_span(span);
2537
2538        // Set the name to `impl Bound1 + Bound2`.
2539        let param = hir::GenericParam {
2540            hir_id: self.lower_node_id(node_id),
2541            def_id,
2542            name: ParamName::Plain(self.lower_ident(ident)),
2543            pure_wrt_drop: false,
2544            span,
2545            kind: hir::GenericParamKind::Type { default: None, synthetic: true },
2546            colon_span: None,
2547            source: hir::GenericParamSource::Generics,
2548        };
2549
2550        let preds = self.lower_generic_bound_predicate(
2551            ident,
2552            node_id,
2553            &GenericParamKind::Type { default: None },
2554            bounds,
2555            /* colon_span */ None,
2556            span,
2557            RelaxedBoundPolicy::Allowed(&mut Default::default()),
2558            ImplTraitContext::Universal,
2559            hir::PredicateOrigin::ImplTrait,
2560        );
2561
2562        let hir_id = self.next_id();
2563        let res = Res::Def(DefKind::TyParam, def_id.to_def_id());
2564        let ty = hir::TyKind::Path(hir::QPath::Resolved(
2565            None,
2566            self.arena.alloc(hir::Path {
2567                span,
2568                res,
2569                segments:
2570                    arena_vec![self; hir::PathSegment::new(self.lower_ident(ident), hir_id, res)],
2571            }),
2572        ));
2573
2574        (param, preds, ty)
2575    }
2576
2577    /// Lowers a block directly to an expression, presuming that it
2578    /// has no attributes and is not targeted by a `break`.
2579    fn lower_block_expr(&mut self, b: &Block) -> hir::Expr<'hir> {
2580        let block = self.lower_block(b, false);
2581        self.expr_block(block)
2582    }
2583
2584    fn lower_array_length_to_const_arg(&mut self, c: &AnonConst) -> &'hir hir::ConstArg<'hir> {
2585        // We cannot just match on `ExprKind::Underscore` as `(_)` is represented as
2586        // `ExprKind::Paren(ExprKind::Underscore)` and should also be lowered to `GenericArg::Infer`
2587        //
2588        // FIXME(gca_macroless_args): Handling of underscores should be moved into
2589        // lower_expr_to_const_arg_direct. It is left here as retaining compatibility of what is
2590        // currently allowed on stable gets hairy and annoying otherwise.
2591        match c.value.peel_parens().kind {
2592            ExprKind::Underscore => {
2593                let ct_kind = hir::ConstArgKind::Infer(());
2594                self.arena.alloc(hir::ConstArg {
2595                    hir_id: self.lower_node_id(c.id),
2596                    kind: ct_kind,
2597                    span: self.lower_span(c.value.span),
2598                })
2599            }
2600            _ => self.lower_anon_const_to_const_arg_and_alloc(c),
2601        }
2602    }
2603
2604    /// Used when lowering a type argument that turned out to actually be a const argument.
2605    ///
2606    /// Only use for that purpose since otherwise it will create a duplicate def.
2607    {}
#[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("/rustc-dev/ea137335b78829b4514bf1b4c16302f74fab8581/compiler/rustc_ast_lowering/src/lib.rs"),
                                    ::tracing_core::__macro_support::Option::Some(2607u32),
                                    ::tracing_core::__macro_support::Option::Some("rustc_ast_lowering"),
                                    ::tracing_core::field::FieldSet::new(&[{
                                                        const NAME:
                                                            ::tracing::__macro_support::FieldName<{
                                                                ::tracing::__macro_support::FieldName::len("qself")
                                                            }> =
                                                            ::tracing::__macro_support::FieldName::new("qself");
                                                        NAME.as_str()
                                                    },
                                                    {
                                                        const NAME:
                                                            ::tracing::__macro_support::FieldName<{
                                                                ::tracing::__macro_support::FieldName::len("path")
                                                            }> =
                                                            ::tracing::__macro_support::FieldName::new("path");
                                                        NAME.as_str()
                                                    },
                                                    {
                                                        const NAME:
                                                            ::tracing::__macro_support::FieldName<{
                                                                ::tracing::__macro_support::FieldName::len("res")
                                                            }> =
                                                            ::tracing::__macro_support::FieldName::new("res");
                                                        NAME.as_str()
                                                    },
                                                    {
                                                        const NAME:
                                                            ::tracing::__macro_support::FieldName<{
                                                                ::tracing::__macro_support::FieldName::len("id")
                                                            }> =
                                                            ::tracing::__macro_support::FieldName::new("id");
                                                        NAME.as_str()
                                                    },
                                                    {
                                                        const NAME:
                                                            ::tracing::__macro_support::FieldName<{
                                                                ::tracing::__macro_support::FieldName::len("span")
                                                            }> =
                                                            ::tracing::__macro_support::FieldName::new("span");
                                                        NAME.as_str()
                                                    }], ::tracing_core::callsite::Identifier(&__CALLSITE)),
                                    ::tracing::metadata::Kind::SPAN)
                            };
                        ::tracing::callsite::DefaultCallsite::new(&META)
                    };
                let mut interest = ::tracing::subscriber::Interest::never();
                if ::tracing::Level::DEBUG <=
                                    ::tracing::level_filters::STATIC_MAX_LEVEL &&
                                ::tracing::Level::DEBUG <=
                                    ::tracing::level_filters::LevelFilter::current() &&
                            { interest = __CALLSITE.interest(); !interest.is_never() }
                        &&
                        ::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
                            interest) {
                    let meta = __CALLSITE.metadata();
                    ::tracing::Span::new(meta,
                        &{
                                #[allow(unused_imports)]
                                use ::tracing::field::{debug, display, Value};
                                meta.fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&qself)
                                                            as &dyn ::tracing::field::Value)),
                                                (::tracing::__macro_support::Option::Some(&::tracing::field::debug(&path)
                                                            as &dyn ::tracing::field::Value)),
                                                (::tracing::__macro_support::Option::Some(&::tracing::field::debug(&res)
                                                            as &dyn ::tracing::field::Value)),
                                                (::tracing::__macro_support::Option::Some(&::tracing::field::debug(&id)
                                                            as &dyn ::tracing::field::Value)),
                                                (::tracing::__macro_support::Option::Some(&::tracing::field::debug(&span)
                                                            as &dyn ::tracing::field::Value))])
                            })
                } else {
                    let span =
                        ::tracing::__macro_support::__disabled_span(__CALLSITE.metadata());
                    {};
                    span
                }
            };
        __tracing_attr_guard = __tracing_attr_span.enter();
    }

    #[warn(clippy :: suspicious_else_formatting)]
    {

        #[allow(unknown_lints, unreachable_code, clippy ::
        diverging_sub_expression, clippy :: empty_loop, clippy ::
        let_unit_value, clippy :: let_with_type_underscore, clippy ::
        needless_return, clippy :: unreachable)]
        if false {
            let __tracing_attr_fake_return: hir::ConstArg<'hir> = loop {};
            return __tracing_attr_fake_return;
        }
        {
            let context = self.ambient_direct_const_arg_context();
            if self.can_lower_path_to_const_arg_direct(qself, path, span,
                        Some(res), context).is_ok() {
                let span = self.lower_span(span);
                self.lower_path_to_const_arg_direct(id, None, qself, path,
                    span)
            } 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,
                        kind: ExprKind::Path(qself.clone(), 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::ConstArg {
                    hir_id: self.next_id(),
                    kind: hir::ConstArgKind::Anon(ct),
                    span: self.lower_span(span),
                }
            }
        }
    }
}#[instrument(level = "debug", skip(self))]
2608    fn lower_const_path_to_const_arg(
2609        &mut self,
2610        qself: &Option<Box<QSelf>>,
2611        path: &Path,
2612        res: Res<NodeId>,
2613        id: NodeId,
2614        span: Span,
2615    ) -> hir::ConstArg<'hir> {
2616        let context = self.ambient_direct_const_arg_context();
2617        if self.can_lower_path_to_const_arg_direct(qself, path, span, Some(res), context).is_ok() {
2618            let span = self.lower_span(span);
2619            self.lower_path_to_const_arg_direct(id, None, qself, path, span)
2620        } else {
2621            // Construct an AnonConst where the expr is the "ty"'s path.
2622            let node_id = self.next_node_id();
2623            let span = self.lower_span(span);
2624
2625            // Add a definition for the in-band const def.
2626            // We're lowering a const argument that was originally thought to be a type argument,
2627            // so the def collector didn't create the def ahead of time. That's why we have to do
2628            // it here.
2629            let def_id = self.create_def(node_id, None, DefKind::AnonConst, span);
2630            let hir_id = self.lower_node_id(node_id);
2631
2632            let path_expr = Expr {
2633                id,
2634                kind: ExprKind::Path(qself.clone(), path.clone()),
2635                span,
2636                attrs: AttrVec::new(),
2637                tokens: None,
2638            };
2639
2640            let ct = self.with_new_scopes(span, |this| {
2641                self.arena.alloc(hir::AnonConst {
2642                    def_id,
2643                    hir_id,
2644                    body: this.lower_const_body(path_expr.span, Some(&path_expr)),
2645                    span,
2646                })
2647            });
2648            hir::ConstArg {
2649                hir_id: self.next_id(),
2650                kind: hir::ConstArgKind::Anon(ct),
2651                span: self.lower_span(span),
2652            }
2653        }
2654    }
2655
2656    fn lower_const_item_rhs(
2657        &mut self,
2658        body: &Option<Box<Expr>>,
2659        span: Span,
2660    ) -> hir::ConstItemRhs<'hir> {
2661        let is_direct = |body| {
2662            let context = if self.tcx.features().gca_macroless_items() {
2663                self.direct_const_arg_context_enabled_by_gca_macro()
2664            } else {
2665                DirectConstArgContext::GCA_MACRO
2666            };
2667            self.can_lower_expr_to_const_arg_direct(body, context).is_ok()
2668        };
2669        if self.tcx.features().gca_min_const_items()
2670            && let Some(body) = body
2671            && is_direct(body)
2672        {
2673            hir::ConstItemRhs::Direct(
2674                self.arena.alloc(self.lower_expr_to_const_arg_direct(&body, None)),
2675            )
2676        } else {
2677            hir::ConstItemRhs::Body(self.lower_const_body(span, body.as_deref()))
2678        }
2679    }
2680
2681    fn direct_const_arg_context_enabled_by_gca_macro(&self) -> DirectConstArgContext {
2682        let mut result = DirectConstArgContext::GCA_BASE_FEATURES;
2683        if self.tcx.features().gca_min_const_items() {
2684            result |= DirectConstArgContext::GCA_MIN_CONST_ITEMS;
2685        }
2686        if self.tcx.features().gca_adts() {
2687            result |= DirectConstArgContext::GCA_ADTS;
2688        }
2689        result
2690    }
2691
2692    /// Only valid for const *arg* contexts, not const *item* contexts.
2693    fn ambient_direct_const_arg_context(&self) -> DirectConstArgContext {
2694        if self.tcx.features().gca_macroless_args() {
2695            self.direct_const_arg_context_enabled_by_gca_macro()
2696        } else if self.tcx.features().gca() {
2697            DirectConstArgContext::GCA
2698        } else {
2699            DirectConstArgContext::STABLE
2700        }
2701    }
2702
2703    fn can_lower_path_to_const_arg_direct(
2704        &self,
2705        qself: &Option<Box<QSelf>>,
2706        path: &Path,
2707        span: Span,
2708        res: Option<Res<NodeId>>,
2709        context: DirectConstArgContext,
2710    ) -> Result<(), UnrepresentableConstArgError> {
2711        if context.contains(DirectConstArgContext::PATH_ANY) {
2712            Ok(())
2713        } else if context.contains(DirectConstArgContext::PATH_CONST_CTOR)
2714            && #[allow(non_exhaustive_omitted_patterns)] match res {
    Some(Res::Def(DefKind::Ctor(_, CtorKind::Const), _)) => true,
    _ => false,
}matches!(res, Some(Res::Def(DefKind::Ctor(_, CtorKind::Const), _)))
2715        {
2716            // FIXME(gca_adts): This check is incomplete. Type-relative paths and other complicating
2717            // factors make things very difficult - e.g. `<Option<T>>::None`
2718            Ok(())
2719        } else if context.contains(DirectConstArgContext::PATH_PLAIN_PARAM)
2720            && qself.is_none()
2721            && path.is_single_argless_ident()
2722            && #[allow(non_exhaustive_omitted_patterns)] match res {
    Some(Res::Def(DefKind::ConstParam, _)) => true,
    _ => false,
}matches!(res, Some(Res::Def(DefKind::ConstParam, _)))
2723        {
2724            Ok(())
2725        } else {
2726            Err(UnrepresentableConstArgError { span, will_create_def_ids: false })
2727        }
2728    }
2729
2730    {}
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("can_lower_expr_to_const_arg_direct",
                                "rustc_ast_lowering", ::tracing::Level::DEBUG,
                                ::tracing_core::__macro_support::Option::Some("/rustc-dev/ea137335b78829b4514bf1b4c16302f74fab8581/compiler/rustc_ast_lowering/src/lib.rs"),
                                ::tracing_core::__macro_support::Option::Some(2730u32),
                                ::tracing_core::__macro_support::Option::Some("rustc_ast_lowering"),
                                ::tracing_core::field::FieldSet::new(&[{
                                                    const NAME:
                                                        ::tracing::__macro_support::FieldName<{
                                                            ::tracing::__macro_support::FieldName::len("expr")
                                                        }> =
                                                        ::tracing::__macro_support::FieldName::new("expr");
                                                    NAME.as_str()
                                                },
                                                {
                                                    const NAME:
                                                        ::tracing::__macro_support::FieldName<{
                                                            ::tracing::__macro_support::FieldName::len("context")
                                                        }> =
                                                        ::tracing::__macro_support::FieldName::new("context");
                                                    NAME.as_str()
                                                }], ::tracing_core::callsite::Identifier(&__CALLSITE)),
                                ::tracing::metadata::Kind::SPAN)
                        };
                    ::tracing::callsite::DefaultCallsite::new(&META)
                };
            let mut interest = ::tracing::subscriber::Interest::never();
            if ::tracing::Level::DEBUG <=
                                ::tracing::level_filters::STATIC_MAX_LEVEL &&
                            ::tracing::Level::DEBUG <=
                                ::tracing::level_filters::LevelFilter::current() &&
                        { interest = __CALLSITE.interest(); !interest.is_never() }
                    &&
                    ::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
                        interest) {
                let meta = __CALLSITE.metadata();
                ::tracing::Span::new(meta,
                    &{
                            #[allow(unused_imports)]
                            use ::tracing::field::{debug, display, Value};
                            meta.fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&expr)
                                                        as &dyn ::tracing::field::Value)),
                                            (::tracing::__macro_support::Option::Some(&::tracing::field::debug(&context)
                                                        as &dyn ::tracing::field::Value))])
                        })
            } else {
                let span =
                    ::tracing::__macro_support::__disabled_span(__CALLSITE.metadata());
                {};
                span
            }
        };
    __tracing_attr_guard = __tracing_attr_span.enter();
}
#[allow(clippy :: redundant_closure_call)]
let x =
    (move ||
                {

                    #[allow(unknown_lints, unreachable_code, clippy ::
                    diverging_sub_expression, clippy :: empty_loop, clippy ::
                    let_unit_value, clippy :: let_with_type_underscore, clippy
                    :: needless_return, clippy :: unreachable)]
                    if false {
                        let __tracing_attr_fake_return:
                                Result<(), UnrepresentableConstArgError> = loop {};
                        return __tracing_attr_fake_return;
                    }
                    {
                        match &expr.kind {
                            ExprKind::Call(Expr { kind: ExprKind::Path(_, _), .. },
                                args) if context.contains(DirectConstArgContext::TUPLE_CALL)
                                => {
                                for arg in args {
                                    self.can_lower_expr_to_const_arg_direct(arg, context)?;
                                }
                                Ok(())
                            }
                            ExprKind::Tup(exprs) if
                                context.contains(DirectConstArgContext::TUPLE) => {
                                for expr in exprs {
                                    self.can_lower_expr_to_const_arg_direct(expr, context)?;
                                }
                                Ok(())
                            }
                            ExprKind::Path(qself, path) => {
                                let res =
                                    self.get_partial_res(expr.id).and_then(|partial_res|
                                            partial_res.full_res());
                                self.can_lower_path_to_const_arg_direct(qself, path,
                                    expr.span, res, context)
                            }
                            ExprKind::Struct(se) if
                                context.contains(DirectConstArgContext::STRUCT) => {
                                for f in &se.fields {
                                    self.can_lower_expr_to_const_arg_direct(&f.expr, context)?;
                                }
                                Ok(())
                            }
                            ExprKind::Array(elements) if
                                context.contains(DirectConstArgContext::ARRAY) => {
                                for element in elements {
                                    self.can_lower_expr_to_const_arg_direct(element, context)?;
                                }
                                Ok(())
                            }
                            ExprKind::Underscore if
                                context.contains(DirectConstArgContext::UNDERSCORE) =>
                                Ok(()),
                            ExprKind::Paren(expr) if
                                context.contains(DirectConstArgContext::PAREN) => {
                                self.can_lower_expr_to_const_arg_direct(expr, context)
                            }
                            ExprKind::Block(block, _) if
                                context.contains(DirectConstArgContext::BLOCK) &&
                                        let [stmt] = block.stmts.as_slice() &&
                                    let StmtKind::Expr(expr) = &stmt.kind => {
                                self.can_lower_expr_to_const_arg_direct(expr, context)
                            }
                            ExprKind::Lit(_) if
                                context.contains(DirectConstArgContext::LIT) => Ok(()),
                            ExprKind::Unary(UnOp::Neg, inner_expr) if
                                context.contains(DirectConstArgContext::LIT) &&
                                    let ExprKind::Lit(_) = &inner_expr.kind => {
                                Ok(())
                            }
                            ExprKind::ConstBlock(_) if
                                context.contains(DirectConstArgContext::CONST_BLOCK) => {
                                Ok(())
                            }
                            ExprKind::GcaMacro(_) if
                                context.contains(DirectConstArgContext::GCA_MACRO) => {
                                Ok(())
                            }
                            _ => Err(UnrepresentableConstArgError::new(expr)),
                        }
                    }
                })();
{
    use ::tracing::__macro_support::Callsite as _;
    static __CALLSITE: ::tracing::callsite::DefaultCallsite =
        {
            static META: ::tracing::Metadata<'static> =
                {
                    ::tracing_core::metadata::Metadata::new("event /rustc-dev/ea137335b78829b4514bf1b4c16302f74fab8581/compiler/rustc_ast_lowering/src/lib.rs:2730",
                        "rustc_ast_lowering", ::tracing::Level::DEBUG,
                        ::tracing_core::__macro_support::Option::Some("/rustc-dev/ea137335b78829b4514bf1b4c16302f74fab8581/compiler/rustc_ast_lowering/src/lib.rs"),
                        ::tracing_core::__macro_support::Option::Some(2730u32),
                        ::tracing_core::__macro_support::Option::Some("rustc_ast_lowering"),
                        ::tracing_core::field::FieldSet::new(&[{
                                            const NAME:
                                                ::tracing::__macro_support::FieldName<{
                                                    ::tracing::__macro_support::FieldName::len("return")
                                                }> =
                                                ::tracing::__macro_support::FieldName::new("return");
                                            NAME.as_str()
                                        }], ::tracing_core::callsite::Identifier(&__CALLSITE)),
                        ::tracing::metadata::Kind::EVENT)
                };
            ::tracing::callsite::DefaultCallsite::new(&META)
        };
    let enabled =
        ::tracing::Level::DEBUG <= ::tracing::level_filters::STATIC_MAX_LEVEL
                &&
                ::tracing::Level::DEBUG <=
                    ::tracing::level_filters::LevelFilter::current() &&
            {
                let interest = __CALLSITE.interest();
                !interest.is_never() &&
                    ::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
                        interest)
            };
    if enabled {
        (|value_set: ::tracing::field::ValueSet|
                    {
                        let meta = __CALLSITE.metadata();
                        ::tracing::Event::dispatch(meta, &value_set);
                        ;
                    })({
                #[allow(unused_imports)]
                use ::tracing::field::{debug, display, Value};
                __CALLSITE.metadata().fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&x)
                                            as &dyn ::tracing::field::Value))])
            });
    } else { ; }
};
x;#[instrument(level = "debug", skip(self), ret)]
2731    fn can_lower_expr_to_const_arg_direct(
2732        &self,
2733        expr: &Expr,
2734        context: DirectConstArgContext,
2735    ) -> Result<(), UnrepresentableConstArgError> {
2736        // Note the only stable case is currently ExprKind::Path
2737        match &expr.kind {
2738            ExprKind::Call(Expr { kind: ExprKind::Path(_, _), .. }, args)
2739                if context.contains(DirectConstArgContext::TUPLE_CALL) =>
2740            {
2741                for arg in args {
2742                    self.can_lower_expr_to_const_arg_direct(arg, context)?;
2743                }
2744                Ok(())
2745            }
2746            ExprKind::Tup(exprs) if context.contains(DirectConstArgContext::TUPLE) => {
2747                for expr in exprs {
2748                    self.can_lower_expr_to_const_arg_direct(expr, context)?;
2749                }
2750                Ok(())
2751            }
2752            ExprKind::Path(qself, path) => {
2753                let res =
2754                    self.get_partial_res(expr.id).and_then(|partial_res| partial_res.full_res());
2755                self.can_lower_path_to_const_arg_direct(qself, path, expr.span, res, context)
2756            }
2757            ExprKind::Struct(se) if context.contains(DirectConstArgContext::STRUCT) => {
2758                for f in &se.fields {
2759                    self.can_lower_expr_to_const_arg_direct(&f.expr, context)?;
2760                }
2761                Ok(())
2762            }
2763            ExprKind::Array(elements) if context.contains(DirectConstArgContext::ARRAY) => {
2764                for element in elements {
2765                    self.can_lower_expr_to_const_arg_direct(element, context)?;
2766                }
2767                Ok(())
2768            }
2769            ExprKind::Underscore if context.contains(DirectConstArgContext::UNDERSCORE) => Ok(()),
2770            ExprKind::Paren(expr) if context.contains(DirectConstArgContext::PAREN) => {
2771                self.can_lower_expr_to_const_arg_direct(expr, context)
2772            }
2773            ExprKind::Block(block, _)
2774                if context.contains(DirectConstArgContext::BLOCK)
2775                    && let [stmt] = block.stmts.as_slice()
2776                    && let StmtKind::Expr(expr) = &stmt.kind =>
2777            {
2778                self.can_lower_expr_to_const_arg_direct(expr, context)
2779            }
2780            ExprKind::Lit(_) if context.contains(DirectConstArgContext::LIT) => Ok(()),
2781            ExprKind::Unary(UnOp::Neg, inner_expr)
2782                if context.contains(DirectConstArgContext::LIT)
2783                    && let ExprKind::Lit(_) = &inner_expr.kind =>
2784            {
2785                Ok(())
2786            }
2787            ExprKind::ConstBlock(_) if context.contains(DirectConstArgContext::CONST_BLOCK) => {
2788                Ok(())
2789            }
2790            ExprKind::GcaMacro(_) if context.contains(DirectConstArgContext::GCA_MACRO) => {
2791                // Always report this as able to be represented directly. If it turns out not to be,
2792                // `lower_expr_to_const_arg_direct` will report an error.
2793                Ok(())
2794            }
2795            _ => Err(UnrepresentableConstArgError::new(expr)),
2796        }
2797    }
2798
2799    /// It is not allowed to call this function without checking can_lower_path_to_const_arg_direct
2800    /// first, as we assume all feature gates/etc. have been checked already.
2801    fn lower_path_to_const_arg_direct(
2802        &mut self,
2803        id: NodeId,
2804        id_override: Option<NodeId>,
2805        qself: &Option<Box<QSelf>>,
2806        path: &Path,
2807        span: Span,
2808    ) -> hir::ConstArg<'hir> {
2809        let qpath = self.lower_qpath(
2810            id,
2811            qself,
2812            path,
2813            ParamMode::Explicit,
2814            AllowReturnTypeNotation::No,
2815            // FIXME(mgca): update for `fn foo() -> Bar<FOO<impl Trait>>` support
2816            ImplTraitContext::Disallowed(ImplTraitPosition::Path),
2817            None,
2818        );
2819
2820        let node_id = id_override.unwrap_or(id);
2821        ConstArg { hir_id: self.lower_node_id(node_id), kind: hir::ConstArgKind::Path(qpath), span }
2822    }
2823
2824    /// It is not allowed to call this function without checking can_lower_expr_to_const_arg_direct
2825    /// first, as we assume all feature gates/etc. have been checked already.
2826    {}
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_expr_to_const_arg_direct",
                                "rustc_ast_lowering", ::tracing::Level::DEBUG,
                                ::tracing_core::__macro_support::Option::Some("/rustc-dev/ea137335b78829b4514bf1b4c16302f74fab8581/compiler/rustc_ast_lowering/src/lib.rs"),
                                ::tracing_core::__macro_support::Option::Some(2826u32),
                                ::tracing_core::__macro_support::Option::Some("rustc_ast_lowering"),
                                ::tracing_core::field::FieldSet::new(&[{
                                                    const NAME:
                                                        ::tracing::__macro_support::FieldName<{
                                                            ::tracing::__macro_support::FieldName::len("expr")
                                                        }> =
                                                        ::tracing::__macro_support::FieldName::new("expr");
                                                    NAME.as_str()
                                                },
                                                {
                                                    const NAME:
                                                        ::tracing::__macro_support::FieldName<{
                                                            ::tracing::__macro_support::FieldName::len("id_override")
                                                        }> =
                                                        ::tracing::__macro_support::FieldName::new("id_override");
                                                    NAME.as_str()
                                                }], ::tracing_core::callsite::Identifier(&__CALLSITE)),
                                ::tracing::metadata::Kind::SPAN)
                        };
                    ::tracing::callsite::DefaultCallsite::new(&META)
                };
            let mut interest = ::tracing::subscriber::Interest::never();
            if ::tracing::Level::DEBUG <=
                                ::tracing::level_filters::STATIC_MAX_LEVEL &&
                            ::tracing::Level::DEBUG <=
                                ::tracing::level_filters::LevelFilter::current() &&
                        { interest = __CALLSITE.interest(); !interest.is_never() }
                    &&
                    ::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
                        interest) {
                let meta = __CALLSITE.metadata();
                ::tracing::Span::new(meta,
                    &{
                            #[allow(unused_imports)]
                            use ::tracing::field::{debug, display, Value};
                            meta.fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&expr)
                                                        as &dyn ::tracing::field::Value)),
                                            (::tracing::__macro_support::Option::Some(&::tracing::field::debug(&id_override)
                                                        as &dyn ::tracing::field::Value))])
                        })
            } else {
                let span =
                    ::tracing::__macro_support::__disabled_span(__CALLSITE.metadata());
                {};
                span
            }
        };
    __tracing_attr_guard = __tracing_attr_span.enter();
}
#[allow(clippy :: redundant_closure_call)]
let x =
    (move ||
                {

                    #[allow(unknown_lints, unreachable_code, clippy ::
                    diverging_sub_expression, clippy :: empty_loop, clippy ::
                    let_unit_value, clippy :: let_with_type_underscore, clippy
                    :: needless_return, clippy :: unreachable)]
                    if false {
                        let __tracing_attr_fake_return: hir::ConstArg<'hir> =
                            loop {};
                        return __tracing_attr_fake_return;
                    }
                    {
                        let span = self.lower_span(expr.span);
                        let node_id = id_override.unwrap_or(expr.id);
                        match &expr.kind {
                            ExprKind::Call(func, args) if
                                let ExprKind::Path(qself, path) = &func.kind => {
                                let qpath =
                                    self.lower_qpath(func.id, qself, path, ParamMode::Explicit,
                                        AllowReturnTypeNotation::No,
                                        ImplTraitContext::Disallowed(ImplTraitPosition::Path),
                                        None);
                                let lowered_args =
                                    self.arena.alloc_from_iter(args.iter().map(|arg|
                                                {
                                                    let const_arg =
                                                        self.lower_expr_to_const_arg_direct(arg, None);
                                                    &*self.arena.alloc(const_arg)
                                                }));
                                ConstArg {
                                    hir_id: self.lower_node_id(node_id),
                                    kind: hir::ConstArgKind::TupleCall(qpath, lowered_args),
                                    span,
                                }
                            }
                            ExprKind::Tup(exprs) => {
                                let exprs =
                                    self.arena.alloc_from_iter(exprs.iter().map(|expr|
                                                {
                                                    let expr = self.lower_expr_to_const_arg_direct(expr, None);
                                                    &*self.arena.alloc(expr)
                                                }));
                                ConstArg {
                                    hir_id: self.lower_node_id(node_id),
                                    kind: hir::ConstArgKind::Tup(exprs),
                                    span,
                                }
                            }
                            ExprKind::Path(qself, path) => {
                                self.lower_path_to_const_arg_direct(expr.id, id_override,
                                    qself, path, span)
                            }
                            ExprKind::Struct(se) => {
                                let path =
                                    self.lower_qpath(expr.id, &se.qself, &se.path,
                                        ParamMode::Explicit, AllowReturnTypeNotation::No,
                                        ImplTraitContext::Disallowed(ImplTraitPosition::Path),
                                        None);
                                let fields =
                                    self.arena.alloc_from_iter(se.fields.iter().map(|f|
                                                {
                                                    let hir_id = self.lower_node_id(f.id);
                                                    self.lower_attrs(hir_id, &f.attrs, f.span,
                                                        Target::ExprField);
                                                    let expr =
                                                        self.lower_expr_to_const_arg_direct(&f.expr, None);
                                                    &*self.arena.alloc(hir::ConstArgExprField {
                                                                    hir_id,
                                                                    field: self.lower_ident(f.ident),
                                                                    expr: self.arena.alloc(expr),
                                                                    span: self.lower_span(f.span),
                                                                })
                                                }));
                                ConstArg {
                                    hir_id: self.lower_node_id(node_id),
                                    kind: hir::ConstArgKind::Struct(path, fields),
                                    span,
                                }
                            }
                            ExprKind::Array(elements) => {
                                let lowered_elems =
                                    self.arena.alloc_from_iter(elements.iter().map(|element|
                                                {
                                                    let const_arg =
                                                        self.lower_expr_to_const_arg_direct(element, None);
                                                    &*self.arena.alloc(const_arg)
                                                }));
                                let array_expr =
                                    self.arena.alloc(hir::ConstArgArrayExpr {
                                            span: self.lower_span(expr.span),
                                            elems: lowered_elems,
                                        });
                                ConstArg {
                                    hir_id: self.lower_node_id(node_id),
                                    kind: hir::ConstArgKind::Array(array_expr),
                                    span,
                                }
                            }
                            ExprKind::Underscore =>
                                ConstArg {
                                    hir_id: self.lower_node_id(node_id),
                                    kind: hir::ConstArgKind::Infer(()),
                                    span,
                                },
                            ExprKind::Paren(expr) =>
                                self.lower_expr_to_const_arg_direct(expr, id_override),
                            ExprKind::Block(block, _) if
                                let [stmt] = block.stmts.as_slice() &&
                                    let StmtKind::Expr(expr) = &stmt.kind => {
                                self.lower_expr_to_const_arg_direct(expr, id_override)
                            }
                            ExprKind::Lit(literal) => {
                                let span = self.lower_span(expr.span);
                                let literal = self.lower_lit(literal, span);
                                ConstArg {
                                    hir_id: self.lower_node_id(node_id),
                                    kind: hir::ConstArgKind::Literal {
                                        lit: literal.node,
                                        negated: false,
                                    },
                                    span,
                                }
                            }
                            ExprKind::Unary(UnOp::Neg, inner_expr) if
                                let ExprKind::Lit(literal) = &inner_expr.kind => {
                                let span = self.lower_span(expr.span);
                                let literal = self.lower_lit(literal, span);
                                let kind =
                                    if !#[allow(non_exhaustive_omitted_patterns)] match literal.node
                                                {
                                                LitKind::Int(..) => true,
                                                _ => false,
                                            } {
                                        let err =
                                            self.dcx().span_err(expr.span,
                                                "negated literal must be an integer");
                                        hir::ConstArgKind::Error(err)
                                    } else {
                                        hir::ConstArgKind::Literal {
                                            lit: literal.node,
                                            negated: true,
                                        }
                                    };
                                ConstArg { hir_id: self.lower_node_id(node_id), kind, span }
                            }
                            ExprKind::ConstBlock(anon_const) => {
                                let def_id = self.local_def_id(anon_const.id);
                                {
                                    match (&DefKind::AnonConst, &self.tcx.def_kind(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);
                                            }
                                        }
                                    }
                                };
                                let lowered_anon =
                                    self.lower_anon_const_to_anon_const(anon_const, span);
                                ConstArg {
                                    hir_id: self.lower_node_id(node_id),
                                    kind: hir::ConstArgKind::Anon(lowered_anon),
                                    span,
                                }
                            }
                            ExprKind::GcaMacro(expr) => {
                                match self.can_lower_expr_to_const_arg_direct(expr,
                                        self.direct_const_arg_context_enabled_by_gca_macro()) {
                                    Ok(()) =>
                                        self.lower_expr_to_const_arg_direct(expr, id_override),
                                    Err(err) => err.emit(self),
                                }
                            }
                            _ => {
                                ::rustc_span::macros::bug_impl(Some(expr.span),
                                    format_args!("lower_expr_to_const_arg_direct encountered an unlowerable expression, either can_lower_expr_to_const_arg_direct returned Ok() on something it shouldn\'t have, or you forgot to check can_lower_expr_to_const_arg_direct first"),
                                    Location::caller());
                            }
                        }
                    }
                })();
{
    use ::tracing::__macro_support::Callsite as _;
    static __CALLSITE: ::tracing::callsite::DefaultCallsite =
        {
            static META: ::tracing::Metadata<'static> =
                {
                    ::tracing_core::metadata::Metadata::new("event /rustc-dev/ea137335b78829b4514bf1b4c16302f74fab8581/compiler/rustc_ast_lowering/src/lib.rs:2826",
                        "rustc_ast_lowering", ::tracing::Level::DEBUG,
                        ::tracing_core::__macro_support::Option::Some("/rustc-dev/ea137335b78829b4514bf1b4c16302f74fab8581/compiler/rustc_ast_lowering/src/lib.rs"),
                        ::tracing_core::__macro_support::Option::Some(2826u32),
                        ::tracing_core::__macro_support::Option::Some("rustc_ast_lowering"),
                        ::tracing_core::field::FieldSet::new(&[{
                                            const NAME:
                                                ::tracing::__macro_support::FieldName<{
                                                    ::tracing::__macro_support::FieldName::len("return")
                                                }> =
                                                ::tracing::__macro_support::FieldName::new("return");
                                            NAME.as_str()
                                        }], ::tracing_core::callsite::Identifier(&__CALLSITE)),
                        ::tracing::metadata::Kind::EVENT)
                };
            ::tracing::callsite::DefaultCallsite::new(&META)
        };
    let enabled =
        ::tracing::Level::DEBUG <= ::tracing::level_filters::STATIC_MAX_LEVEL
                &&
                ::tracing::Level::DEBUG <=
                    ::tracing::level_filters::LevelFilter::current() &&
            {
                let interest = __CALLSITE.interest();
                !interest.is_never() &&
                    ::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
                        interest)
            };
    if enabled {
        (|value_set: ::tracing::field::ValueSet|
                    {
                        let meta = __CALLSITE.metadata();
                        ::tracing::Event::dispatch(meta, &value_set);
                        ;
                    })({
                #[allow(unused_imports)]
                use ::tracing::field::{debug, display, Value};
                __CALLSITE.metadata().fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&x)
                                            as &dyn ::tracing::field::Value))])
            });
    } else { ; }
};
x;#[instrument(level = "debug", skip(self), ret)]
2827    fn lower_expr_to_const_arg_direct(
2828        &mut self,
2829        expr: &Expr,
2830        id_override: Option<NodeId>,
2831    ) -> hir::ConstArg<'hir> {
2832        let span = self.lower_span(expr.span);
2833        let node_id = id_override.unwrap_or(expr.id);
2834        match &expr.kind {
2835            ExprKind::Call(func, args) if let ExprKind::Path(qself, path) = &func.kind => {
2836                let qpath = self.lower_qpath(
2837                    func.id,
2838                    qself,
2839                    path,
2840                    ParamMode::Explicit,
2841                    AllowReturnTypeNotation::No,
2842                    ImplTraitContext::Disallowed(ImplTraitPosition::Path),
2843                    None,
2844                );
2845
2846                let lowered_args = self.arena.alloc_from_iter(args.iter().map(|arg| {
2847                    let const_arg = self.lower_expr_to_const_arg_direct(arg, None);
2848                    &*self.arena.alloc(const_arg)
2849                }));
2850
2851                ConstArg {
2852                    hir_id: self.lower_node_id(node_id),
2853                    kind: hir::ConstArgKind::TupleCall(qpath, lowered_args),
2854                    span,
2855                }
2856            }
2857            ExprKind::Tup(exprs) => {
2858                let exprs = self.arena.alloc_from_iter(exprs.iter().map(|expr| {
2859                    let expr = self.lower_expr_to_const_arg_direct(expr, None);
2860                    &*self.arena.alloc(expr)
2861                }));
2862
2863                ConstArg {
2864                    hir_id: self.lower_node_id(node_id),
2865                    kind: hir::ConstArgKind::Tup(exprs),
2866                    span,
2867                }
2868            }
2869            ExprKind::Path(qself, path) => {
2870                self.lower_path_to_const_arg_direct(expr.id, id_override, qself, path, span)
2871            }
2872            ExprKind::Struct(se) => {
2873                let path = self.lower_qpath(
2874                    expr.id,
2875                    &se.qself,
2876                    &se.path,
2877                    // FIXME(mgca): we may want this to be `Optional` instead, but
2878                    // we would also need to make sure that HIR ty lowering errors
2879                    // when these paths wind up in signatures.
2880                    ParamMode::Explicit,
2881                    AllowReturnTypeNotation::No,
2882                    ImplTraitContext::Disallowed(ImplTraitPosition::Path),
2883                    None,
2884                );
2885
2886                let fields = self.arena.alloc_from_iter(se.fields.iter().map(|f| {
2887                    let hir_id = self.lower_node_id(f.id);
2888                    // FIXME(mgca): This might result in lowering attributes that
2889                    // then go unused as the `Target::ExprField` is not actually
2890                    // corresponding to `Node::ExprField`.
2891                    self.lower_attrs(hir_id, &f.attrs, f.span, Target::ExprField);
2892                    let expr = self.lower_expr_to_const_arg_direct(&f.expr, None);
2893
2894                    &*self.arena.alloc(hir::ConstArgExprField {
2895                        hir_id,
2896                        field: self.lower_ident(f.ident),
2897                        expr: self.arena.alloc(expr),
2898                        span: self.lower_span(f.span),
2899                    })
2900                }));
2901
2902                ConstArg {
2903                    hir_id: self.lower_node_id(node_id),
2904                    kind: hir::ConstArgKind::Struct(path, fields),
2905                    span,
2906                }
2907            }
2908            ExprKind::Array(elements) => {
2909                let lowered_elems = self.arena.alloc_from_iter(elements.iter().map(|element| {
2910                    let const_arg = self.lower_expr_to_const_arg_direct(element, None);
2911                    &*self.arena.alloc(const_arg)
2912                }));
2913                let array_expr = self.arena.alloc(hir::ConstArgArrayExpr {
2914                    span: self.lower_span(expr.span),
2915                    elems: lowered_elems,
2916                });
2917
2918                ConstArg {
2919                    hir_id: self.lower_node_id(node_id),
2920                    kind: hir::ConstArgKind::Array(array_expr),
2921                    span,
2922                }
2923            }
2924            ExprKind::Underscore => ConstArg {
2925                hir_id: self.lower_node_id(node_id),
2926                kind: hir::ConstArgKind::Infer(()),
2927                span,
2928            },
2929            ExprKind::Paren(expr) => self.lower_expr_to_const_arg_direct(expr, id_override),
2930            ExprKind::Block(block, _)
2931                if let [stmt] = block.stmts.as_slice()
2932                    && let StmtKind::Expr(expr) = &stmt.kind =>
2933            {
2934                self.lower_expr_to_const_arg_direct(expr, id_override)
2935            }
2936            ExprKind::Lit(literal) => {
2937                let span = self.lower_span(expr.span);
2938                let literal = self.lower_lit(literal, span);
2939
2940                ConstArg {
2941                    hir_id: self.lower_node_id(node_id),
2942                    kind: hir::ConstArgKind::Literal { lit: literal.node, negated: false },
2943                    span,
2944                }
2945            }
2946            ExprKind::Unary(UnOp::Neg, inner_expr)
2947                if let ExprKind::Lit(literal) = &inner_expr.kind =>
2948            {
2949                let span = self.lower_span(expr.span);
2950                let literal = self.lower_lit(literal, span);
2951
2952                let kind = if !matches!(literal.node, LitKind::Int(..)) {
2953                    let err = self.dcx().span_err(expr.span, "negated literal must be an integer");
2954                    hir::ConstArgKind::Error(err)
2955                } else {
2956                    hir::ConstArgKind::Literal { lit: literal.node, negated: true }
2957                };
2958                ConstArg { hir_id: self.lower_node_id(node_id), kind, span }
2959            }
2960            ExprKind::ConstBlock(anon_const) => {
2961                // Do not use lower_anon_const_to_const_arg, as that attempts to represent the body
2962                // directly. Instead, force an anon const.
2963                let def_id = self.local_def_id(anon_const.id);
2964                assert_eq!(DefKind::AnonConst, self.tcx.def_kind(def_id));
2965                let lowered_anon = self.lower_anon_const_to_anon_const(anon_const, span);
2966                ConstArg {
2967                    hir_id: self.lower_node_id(node_id),
2968                    kind: hir::ConstArgKind::Anon(lowered_anon),
2969                    span,
2970                }
2971            }
2972            ExprKind::GcaMacro(expr) => {
2973                // `can_lower_expr_to_const_arg_direct` always returns success upon encountering a
2974                // ExprKind::GcaMacro, which effectively forces the expression to be lowered as a
2975                // direct arg. If it actually turns out to not be possible, emit an error instead.
2976                match self.can_lower_expr_to_const_arg_direct(
2977                    expr,
2978                    self.direct_const_arg_context_enabled_by_gca_macro(),
2979                ) {
2980                    Ok(()) => self.lower_expr_to_const_arg_direct(expr, id_override),
2981                    Err(err) => err.emit(self),
2982                }
2983            }
2984            _ => {
2985                span_bug!(
2986                    expr.span,
2987                    "lower_expr_to_const_arg_direct encountered an unlowerable expression, either \
2988                    can_lower_expr_to_const_arg_direct returned Ok() on something it shouldn't \
2989                    have, or you forgot to check can_lower_expr_to_const_arg_direct first"
2990                );
2991            }
2992        }
2993    }
2994
2995    /// See [`hir::ConstArg`] for when to use this function vs
2996    /// [`Self::lower_anon_const_to_anon_const`].
2997    fn lower_anon_const_to_const_arg_and_alloc(
2998        &mut self,
2999        anon: &AnonConst,
3000    ) -> &'hir hir::ConstArg<'hir> {
3001        self.arena.alloc(self.lower_anon_const_to_const_arg(anon))
3002    }
3003
3004    {}
#[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("/rustc-dev/ea137335b78829b4514bf1b4c16302f74fab8581/compiler/rustc_ast_lowering/src/lib.rs"),
                                    ::tracing_core::__macro_support::Option::Some(3004u32),
                                    ::tracing_core::__macro_support::Option::Some("rustc_ast_lowering"),
                                    ::tracing_core::field::FieldSet::new(&[{
                                                        const NAME:
                                                            ::tracing::__macro_support::FieldName<{
                                                                ::tracing::__macro_support::FieldName::len("anon")
                                                            }> =
                                                            ::tracing::__macro_support::FieldName::new("anon");
                                                        NAME.as_str()
                                                    }], ::tracing_core::callsite::Identifier(&__CALLSITE)),
                                    ::tracing::metadata::Kind::SPAN)
                            };
                        ::tracing::callsite::DefaultCallsite::new(&META)
                    };
                let mut interest = ::tracing::subscriber::Interest::never();
                if ::tracing::Level::DEBUG <=
                                    ::tracing::level_filters::STATIC_MAX_LEVEL &&
                                ::tracing::Level::DEBUG <=
                                    ::tracing::level_filters::LevelFilter::current() &&
                            { interest = __CALLSITE.interest(); !interest.is_never() }
                        &&
                        ::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
                            interest) {
                    let meta = __CALLSITE.metadata();
                    ::tracing::Span::new(meta,
                        &{
                                #[allow(unused_imports)]
                                use ::tracing::field::{debug, display, Value};
                                meta.fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&anon)
                                                            as &dyn ::tracing::field::Value))])
                            })
                } else {
                    let span =
                        ::tracing::__macro_support::__disabled_span(__CALLSITE.metadata());
                    {};
                    span
                }
            };
        __tracing_attr_guard = __tracing_attr_span.enter();
    }

    #[warn(clippy :: suspicious_else_formatting)]
    {

        #[allow(unknown_lints, unreachable_code, clippy ::
        diverging_sub_expression, clippy :: empty_loop, clippy ::
        let_unit_value, clippy :: let_with_type_underscore, clippy ::
        needless_return, clippy :: unreachable)]
        if false {
            let __tracing_attr_fake_return: hir::ConstArg<'hir> = loop {};
            return __tracing_attr_fake_return;
        }
        {
            let expr =
                if self.tcx.features().gca_macroless_args() {
                    &anon.value
                } else { anon.value.maybe_unwrap_block() };
            let context = self.ambient_direct_const_arg_context();
            if self.can_lower_expr_to_const_arg_direct(expr, context).is_ok()
                {
                return self.lower_expr_to_const_arg_direct(expr,
                        Some(anon.id));
            }
            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(anon.value.span),
            }
        }
    }
}#[instrument(level = "debug", skip(self))]
3005    fn lower_anon_const_to_const_arg(&mut self, anon: &AnonConst) -> hir::ConstArg<'hir> {
3006        // Stable only allows one nesting of blocks for directly represented paths. mGCA allows
3007        // arbitrarily many, and are handled inside lower_expr_to_const_arg_direct for consistency.
3008        let expr = if self.tcx.features().gca_macroless_args() {
3009            &anon.value
3010        } else {
3011            anon.value.maybe_unwrap_block()
3012        };
3013
3014        let context = self.ambient_direct_const_arg_context();
3015        if self.can_lower_expr_to_const_arg_direct(expr, context).is_ok() {
3016            return self.lower_expr_to_const_arg_direct(expr, Some(anon.id));
3017        }
3018
3019        let lowered_anon = self.lower_anon_const_to_anon_const(anon, anon.value.span);
3020        ConstArg {
3021            hir_id: self.next_id(),
3022            kind: hir::ConstArgKind::Anon(lowered_anon),
3023            span: self.lower_span(anon.value.span),
3024        }
3025    }
3026
3027    /// See [`hir::ConstArg`] for when to use this function vs
3028    /// [`Self::lower_anon_const_to_const_arg`].
3029    fn lower_anon_const_to_anon_const(
3030        &mut self,
3031        c: &AnonConst,
3032        span: Span,
3033    ) -> &'hir hir::AnonConst {
3034        self.arena.alloc(self.with_new_scopes(c.value.span, |this| {
3035            let def_id = this.local_def_id(c.id);
3036            let hir_id = this.lower_node_id(c.id);
3037            hir::AnonConst {
3038                def_id,
3039                hir_id,
3040                body: this.lower_const_body(c.value.span, Some(&c.value)),
3041                span: this.lower_span(span),
3042            }
3043        }))
3044    }
3045
3046    fn lower_unsafe_source(&self, u: UnsafeSource) -> hir::UnsafeSource {
3047        match u {
3048            CompilerGenerated => hir::UnsafeSource::CompilerGenerated,
3049            UserProvided => hir::UnsafeSource::UserProvided,
3050        }
3051    }
3052
3053    fn lower_trait_bound_modifiers(
3054        &self,
3055        modifiers: TraitBoundModifiers,
3056    ) -> hir::TraitBoundModifiers {
3057        let constness = match modifiers.constness {
3058            BoundConstness::Never => BoundConstness::Never,
3059            BoundConstness::Always(span) => BoundConstness::Always(self.lower_span(span)),
3060            BoundConstness::Maybe(span) => BoundConstness::Maybe(self.lower_span(span)),
3061        };
3062        let polarity = match modifiers.polarity {
3063            BoundPolarity::Positive => BoundPolarity::Positive,
3064            BoundPolarity::Negative(span) => BoundPolarity::Negative(self.lower_span(span)),
3065            BoundPolarity::Maybe(span) => BoundPolarity::Maybe(self.lower_span(span)),
3066        };
3067        hir::TraitBoundModifiers { constness, polarity }
3068    }
3069
3070    // Helper methods for building HIR.
3071
3072    fn stmt(&mut self, span: Span, kind: hir::StmtKind<'hir>) -> hir::Stmt<'hir> {
3073        hir::Stmt { span: self.lower_span(span), kind, hir_id: self.next_id() }
3074    }
3075
3076    fn stmt_expr(&mut self, span: Span, expr: hir::Expr<'hir>) -> hir::Stmt<'hir> {
3077        self.stmt(span, hir::StmtKind::Expr(self.arena.alloc(expr)))
3078    }
3079
3080    fn stmt_let_pat(
3081        &mut self,
3082        attrs: Option<&'hir [rustc_attr_ir::Attribute]>,
3083        span: Span,
3084        init: Option<&'hir hir::Expr<'hir>>,
3085        pat: &'hir hir::Pat<'hir>,
3086        source: hir::LocalSource,
3087    ) -> hir::Stmt<'hir> {
3088        let hir_id = self.next_id();
3089        if let Some(a) = attrs {
3090            if !!a.is_empty() {
    ::core::panicking::panic("assertion failed: !a.is_empty()")
};assert!(!a.is_empty());
3091            self.curr_owner.attrs.insert(hir_id.local_id, a);
3092        }
3093        let local = hir::LetStmt {
3094            super_: None,
3095            hir_id,
3096            init,
3097            pat,
3098            els: None,
3099            source,
3100            span: self.lower_span(span),
3101            ty: None,
3102        };
3103        self.stmt(span, hir::StmtKind::Let(self.arena.alloc(local)))
3104    }
3105
3106    fn stmt_super_let_pat(
3107        &mut self,
3108        span: Span,
3109        pat: &'hir hir::Pat<'hir>,
3110        init: Option<&'hir hir::Expr<'hir>>,
3111    ) -> hir::Stmt<'hir> {
3112        let hir_id = self.next_id();
3113        let span = self.lower_span(span);
3114        let local = hir::LetStmt {
3115            super_: Some(span),
3116            hir_id,
3117            init,
3118            pat,
3119            els: None,
3120            source: hir::LocalSource::Normal,
3121            span,
3122            ty: None,
3123        };
3124        self.stmt(span, hir::StmtKind::Let(self.arena.alloc(local)))
3125    }
3126
3127    fn block_expr(&mut self, expr: &'hir hir::Expr<'hir>) -> &'hir hir::Block<'hir> {
3128        self.block_all(expr.span, &[], Some(expr))
3129    }
3130
3131    fn block_all(
3132        &mut self,
3133        span: Span,
3134        stmts: &'hir [hir::Stmt<'hir>],
3135        expr: Option<&'hir hir::Expr<'hir>>,
3136    ) -> &'hir hir::Block<'hir> {
3137        let blk = hir::Block {
3138            stmts,
3139            expr,
3140            hir_id: self.next_id(),
3141            rules: hir::BlockCheckMode::DefaultBlock,
3142            span: self.lower_span(span),
3143            targeted_by_break: false,
3144        };
3145        self.arena.alloc(blk)
3146    }
3147
3148    fn pat_cf_continue(&mut self, span: Span, pat: &'hir hir::Pat<'hir>) -> &'hir hir::Pat<'hir> {
3149        let field = self.single_pat_field(span, pat);
3150        self.pat_lang_item_variant(span, LangItem::ControlFlowContinue, field)
3151    }
3152
3153    fn pat_cf_break(&mut self, span: Span, pat: &'hir hir::Pat<'hir>) -> &'hir hir::Pat<'hir> {
3154        let field = self.single_pat_field(span, pat);
3155        self.pat_lang_item_variant(span, LangItem::ControlFlowBreak, field)
3156    }
3157
3158    fn pat_some(&mut self, span: Span, pat: &'hir hir::Pat<'hir>) -> &'hir hir::Pat<'hir> {
3159        let field = self.single_pat_field(span, pat);
3160        self.pat_lang_item_variant(span, LangItem::OptionSome, field)
3161    }
3162
3163    fn pat_none(&mut self, span: Span) -> &'hir hir::Pat<'hir> {
3164        self.pat_lang_item_variant(span, LangItem::OptionNone, &[])
3165    }
3166
3167    fn single_pat_field(
3168        &mut self,
3169        span: Span,
3170        pat: &'hir hir::Pat<'hir>,
3171    ) -> &'hir [hir::PatField<'hir>] {
3172        let field = hir::PatField {
3173            hir_id: self.next_id(),
3174            ident: Ident::new(sym::integer(0), self.lower_span(span)),
3175            is_shorthand: false,
3176            pat,
3177            span: self.lower_span(span),
3178        };
3179        self.arena.alloc_from_iter([field])arena_vec![self; field]
3180    }
3181
3182    fn pat_lang_item_variant(
3183        &mut self,
3184        span: Span,
3185        lang_item: LangItem,
3186        fields: &'hir [hir::PatField<'hir>],
3187    ) -> &'hir hir::Pat<'hir> {
3188        let path = self.make_lang_item_qpath(lang_item, self.lower_span(span), None);
3189        self.pat(span, hir::PatKind::Struct(path, fields, None))
3190    }
3191
3192    fn pat_ident(&mut self, span: Span, ident: Ident) -> (&'hir hir::Pat<'hir>, HirId) {
3193        self.pat_ident_binding_mode(span, ident, hir::BindingMode::NONE)
3194    }
3195
3196    fn pat_ident_mut(&mut self, span: Span, ident: Ident) -> (hir::Pat<'hir>, HirId) {
3197        self.pat_ident_binding_mode_mut(span, ident, hir::BindingMode::NONE)
3198    }
3199
3200    fn pat_ident_binding_mode(
3201        &mut self,
3202        span: Span,
3203        ident: Ident,
3204        bm: hir::BindingMode,
3205    ) -> (&'hir hir::Pat<'hir>, HirId) {
3206        let (pat, hir_id) = self.pat_ident_binding_mode_mut(span, ident, bm);
3207        (self.arena.alloc(pat), hir_id)
3208    }
3209
3210    fn pat_ident_binding_mode_mut(
3211        &mut self,
3212        span: Span,
3213        ident: Ident,
3214        bm: hir::BindingMode,
3215    ) -> (hir::Pat<'hir>, HirId) {
3216        let hir_id = self.next_id();
3217
3218        (
3219            hir::Pat {
3220                hir_id,
3221                kind: hir::PatKind::Binding(bm, hir_id, self.lower_ident(ident), None),
3222                span: self.lower_span(span),
3223                default_binding_modes: true,
3224            },
3225            hir_id,
3226        )
3227    }
3228
3229    fn pat(&mut self, span: Span, kind: hir::PatKind<'hir>) -> &'hir hir::Pat<'hir> {
3230        self.arena.alloc(hir::Pat {
3231            hir_id: self.next_id(),
3232            kind,
3233            span: self.lower_span(span),
3234            default_binding_modes: true,
3235        })
3236    }
3237
3238    fn pat_without_dbm(&mut self, span: Span, kind: hir::PatKind<'hir>) -> hir::Pat<'hir> {
3239        hir::Pat {
3240            hir_id: self.next_id(),
3241            kind,
3242            span: self.lower_span(span),
3243            default_binding_modes: false,
3244        }
3245    }
3246
3247    fn ty_path(&mut self, mut hir_id: HirId, span: Span, qpath: hir::QPath<'hir>) -> hir::Ty<'hir> {
3248        let kind = match qpath {
3249            hir::QPath::Resolved(None, path) => {
3250                // Turn trait object paths into `TyKind::TraitObject` instead.
3251                match path.res {
3252                    Res::Def(DefKind::Trait | DefKind::TraitAlias, _) => {
3253                        let principal = hir::PolyTraitRef {
3254                            bound_generic_params: &[],
3255                            modifiers: hir::TraitBoundModifiers::NONE,
3256                            trait_ref: hir::TraitRef { path, hir_ref_id: hir_id },
3257                            span: self.lower_span(span),
3258                        };
3259
3260                        // The original ID is taken by the `PolyTraitRef`,
3261                        // so the `Ty` itself needs a different one.
3262                        hir_id = self.next_id();
3263                        hir::TyKind::TraitObject(
3264                            self.arena.alloc_from_iter([principal])arena_vec![self; principal],
3265                            TaggedRef::new(self.elided_dyn_bound(span), TraitObjectSyntax::None),
3266                        )
3267                    }
3268                    _ => hir::TyKind::Path(hir::QPath::Resolved(None, path)),
3269                }
3270            }
3271            _ => hir::TyKind::Path(qpath),
3272        };
3273
3274        hir::Ty { hir_id, kind, span: self.lower_span(span) }
3275    }
3276
3277    /// Invoked to create the lifetime argument(s) for an elided trait object
3278    /// bound, like the bound in `Box<dyn Debug>`. This method is not invoked
3279    /// when the bound is written, even if it is written with `'_` like in
3280    /// `Box<dyn Debug + '_>`. In those cases, `lower_lifetime` is invoked.
3281    fn elided_dyn_bound(&mut self, span: Span) -> &'hir hir::Lifetime {
3282        let r = hir::Lifetime::new(
3283            self.next_id(),
3284            Ident::new(kw::UnderscoreLifetime, self.lower_span(span)),
3285            hir::LifetimeKind::ImplicitObjectLifetimeDefault,
3286            LifetimeSource::Other,
3287            LifetimeSyntax::Implicit,
3288        );
3289        {
    use ::tracing::__macro_support::Callsite as _;
    static __CALLSITE: ::tracing::callsite::DefaultCallsite =
        {
            static META: ::tracing::Metadata<'static> =
                {
                    ::tracing_core::metadata::Metadata::new("event /rustc-dev/ea137335b78829b4514bf1b4c16302f74fab8581/compiler/rustc_ast_lowering/src/lib.rs:3289",
                        "rustc_ast_lowering", ::tracing::Level::DEBUG,
                        ::tracing_core::__macro_support::Option::Some("/rustc-dev/ea137335b78829b4514bf1b4c16302f74fab8581/compiler/rustc_ast_lowering/src/lib.rs"),
                        ::tracing_core::__macro_support::Option::Some(3289u32),
                        ::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};
                __CALLSITE.metadata().fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&format_args!("elided_dyn_bound: r={0:?}",
                                                    r) as &dyn ::tracing::field::Value))])
            });
    } else { ; }
};debug!("elided_dyn_bound: r={:?}", r);
3290        self.arena.alloc(r)
3291    }
3292}
3293
3294/// Helper struct for the delayed construction of [`hir::GenericArgs`].
3295struct GenericArgsCtor<'hir> {
3296    args: SmallVec<[hir::GenericArg<'hir>; 4]>,
3297    constraints: &'hir [hir::AssocItemConstraint<'hir>],
3298    parenthesized: hir::GenericArgsParentheses,
3299    span: Span,
3300}
3301
3302impl<'hir> GenericArgsCtor<'hir> {
3303    fn is_empty(&self) -> bool {
3304        self.args.is_empty()
3305            && self.constraints.is_empty()
3306            && self.parenthesized == hir::GenericArgsParentheses::No
3307    }
3308
3309    fn into_generic_args(self, this: &LoweringContext<'_, 'hir>) -> &'hir hir::GenericArgs<'hir> {
3310        let ga = hir::GenericArgs {
3311            args: this.arena.alloc_from_iter(self.args),
3312            constraints: self.constraints,
3313            parenthesized: self.parenthesized,
3314            span_ext: this.lower_span(self.span),
3315        };
3316        this.arena.alloc(ga)
3317    }
3318}
3319
3320struct DirectConstArgContext(<DirectConstArgContext as
    ::bitflags::__private::PublicFlags>::Internal);
#[automatically_derived]
impl ::core::marker::Copy for DirectConstArgContext { }
#[automatically_derived]
#[doc(hidden)]
unsafe impl ::core::clone::TrivialClone for DirectConstArgContext { }
#[automatically_derived]
impl ::core::clone::Clone for DirectConstArgContext {
    #[inline]
    fn clone(&self) -> Self {
        let _:
                ::core::clone::AssertParamIsClone<<DirectConstArgContext as
                ::bitflags::__private::PublicFlags>::Internal>;
        *self
    }
}
#[automatically_derived]
impl ::core::fmt::Debug for DirectConstArgContext {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::debug_tuple_field1_finish(f,
            "DirectConstArgContext", &&self.0)
    }
}
impl DirectConstArgContext {
    #[allow(deprecated, non_upper_case_globals,)]
    pub const TUPLE_CALL: Self = Self::from_bits_retain(1 << 0);
    #[allow(deprecated, non_upper_case_globals,)]
    pub const TUPLE: Self = Self::from_bits_retain(1 << 1);
    #[allow(deprecated, non_upper_case_globals,)]
    pub const PATH_PLAIN_PARAM: Self = Self::from_bits_retain(1 << 2);
    #[allow(deprecated, non_upper_case_globals,)]
    pub const PATH_CONST_CTOR: Self = Self::from_bits_retain(1 << 3);
    #[allow(deprecated, non_upper_case_globals,)]
    pub const PATH_ANY: Self = Self::from_bits_retain(1 << 4);
    #[allow(deprecated, non_upper_case_globals,)]
    pub const STRUCT: Self = Self::from_bits_retain(1 << 5);
    #[allow(deprecated, non_upper_case_globals,)]
    pub const ARRAY: Self = Self::from_bits_retain(1 << 6);
    #[allow(deprecated, non_upper_case_globals,)]
    pub const UNDERSCORE: Self = Self::from_bits_retain(1 << 7);
    #[allow(deprecated, non_upper_case_globals,)]
    pub const PAREN: Self = Self::from_bits_retain(1 << 8);
    #[allow(deprecated, non_upper_case_globals,)]
    pub const BLOCK: Self = Self::from_bits_retain(1 << 9);
    #[allow(deprecated, non_upper_case_globals,)]
    pub const LIT: Self = Self::from_bits_retain(1 << 10);
    #[allow(deprecated, non_upper_case_globals,)]
    pub const CONST_BLOCK: Self = Self::from_bits_retain(1 << 11);
    #[allow(deprecated, non_upper_case_globals,)]
    pub const GCA_MACRO: Self = Self::from_bits_retain(1 << 12);
}
impl ::bitflags::Flags for DirectConstArgContext {
    const FLAGS: &'static [::bitflags::Flag<DirectConstArgContext>] =
        &[{

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

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

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

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

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

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

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

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

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

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

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

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

                        #[allow(deprecated, non_upper_case_globals,)]
                        ::bitflags::Flag::new("GCA_MACRO",
                            DirectConstArgContext::GCA_MACRO)
                    }];
    type Bits = u16;
    fn bits(&self) -> u16 { DirectConstArgContext::bits(self) }
    fn from_bits_retain(bits: u16) -> DirectConstArgContext {
        DirectConstArgContext::from_bits_retain(bits)
    }
}
#[allow(dead_code, deprecated, unused_doc_comments, unused_attributes,
unused_mut, unused_imports, non_upper_case_globals, clippy ::
assign_op_pattern, clippy :: indexing_slicing, clippy :: same_name_method,
clippy :: iter_without_into_iter,)]
const _: () =
    {
        #[repr(transparent)]
        struct InternalBitFlags(u16);
        #[automatically_derived]
        #[doc(hidden)]
        unsafe impl ::core::clone::TrivialClone for InternalBitFlags { }
        #[automatically_derived]
        impl ::core::clone::Clone for InternalBitFlags {
            #[inline]
            fn clone(&self) -> Self {
                let _: ::core::clone::AssertParamIsClone<u16>;
                *self
            }
        }
        #[automatically_derived]
        impl ::core::marker::Copy for InternalBitFlags { }
        #[automatically_derived]
        impl ::core::marker::StructuralPartialEq for InternalBitFlags { }
        #[automatically_derived]
        impl ::core::cmp::PartialEq for InternalBitFlags {
            #[inline]
            fn eq(&self, other: &Self) -> bool { self.0 == other.0 }
        }
        #[automatically_derived]
        impl ::core::cmp::Eq for InternalBitFlags {
            #[inline]
            #[doc(hidden)]
            #[coverage(off)]
            fn assert_fields_are_eq(&self) {
                let _: ::core::cmp::AssertParamIsEq<u16>;
            }
        }
        #[automatically_derived]
        impl ::core::cmp::PartialOrd for InternalBitFlags {
            #[inline]
            fn partial_cmp(&self, other: &Self)
                -> ::core::option::Option<::core::cmp::Ordering> {
                ::core::option::Option::Some(::core::cmp::Ord::cmp(self,
                        other))
            }
        }
        #[automatically_derived]
        impl ::core::cmp::Ord for InternalBitFlags {
            #[inline]
            fn cmp(&self, other: &Self) -> ::core::cmp::Ordering {
                ::core::cmp::Ord::cmp(&self.0, &other.0)
            }
        }
        #[automatically_derived]
        impl ::core::hash::Hash for InternalBitFlags {
            #[inline]
            fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) {
                ::core::hash::Hash::hash(&self.0, state)
            }
        }
        impl ::bitflags::__private::PublicFlags for DirectConstArgContext {
            type Primitive = u16;
            type Internal = InternalBitFlags;
        }
        impl ::bitflags::__private::core::default::Default for
            InternalBitFlags {
            #[inline]
            fn default() -> Self { InternalBitFlags::empty() }
        }
        impl ::bitflags::__private::core::fmt::Debug for InternalBitFlags {
            fn fmt(&self,
                f: &mut ::bitflags::__private::core::fmt::Formatter<'_>)
                -> ::bitflags::__private::core::fmt::Result {
                if self.is_empty() {
                    f.write_fmt(format_args!("{0:#x}",
                            <u16 as ::bitflags::Bits>::EMPTY))
                } else {
                    ::bitflags::__private::core::fmt::Display::fmt(self, f)
                }
            }
        }
        impl ::bitflags::__private::core::fmt::Display for InternalBitFlags {
            fn fmt(&self,
                f: &mut ::bitflags::__private::core::fmt::Formatter<'_>)
                -> ::bitflags::__private::core::fmt::Result {
                ::bitflags::parser::to_writer(&DirectConstArgContext(*self),
                    f)
            }
        }
        impl ::bitflags::__private::core::str::FromStr for InternalBitFlags {
            type Err = ::bitflags::parser::ParseError;
            fn from_str(s: &str)
                ->
                    ::bitflags::__private::core::result::Result<Self,
                    Self::Err> {
                ::bitflags::parser::from_str::<DirectConstArgContext>(s).map(|flags|
                        flags.0)
            }
        }
        impl ::bitflags::__private::core::convert::AsRef<u16> for
            InternalBitFlags {
            fn as_ref(&self) -> &u16 { &self.0 }
        }
        impl ::bitflags::__private::core::convert::From<u16> for
            InternalBitFlags {
            fn from(bits: u16) -> Self { Self::from_bits_retain(bits) }
        }
        #[allow(dead_code, deprecated, unused_attributes)]
        impl InternalBitFlags {
            /// Get a flags value with all bits unset.
            #[inline]
            pub const fn empty() -> Self {
                Self(<u16 as ::bitflags::Bits>::EMPTY)
            }
            /// Get a flags value with all known bits set.
            #[inline]
            pub const fn all() -> Self {
                let mut truncated = <u16 as ::bitflags::Bits>::EMPTY;
                let mut i = 0;
                {
                    {
                        let flag =
                            <DirectConstArgContext as
                                            ::bitflags::Flags>::FLAGS[i].value().bits();
                        truncated = truncated | flag;
                        i += 1;
                    }
                };
                {
                    {
                        let flag =
                            <DirectConstArgContext as
                                            ::bitflags::Flags>::FLAGS[i].value().bits();
                        truncated = truncated | flag;
                        i += 1;
                    }
                };
                {
                    {
                        let flag =
                            <DirectConstArgContext as
                                            ::bitflags::Flags>::FLAGS[i].value().bits();
                        truncated = truncated | flag;
                        i += 1;
                    }
                };
                {
                    {
                        let flag =
                            <DirectConstArgContext as
                                            ::bitflags::Flags>::FLAGS[i].value().bits();
                        truncated = truncated | flag;
                        i += 1;
                    }
                };
                {
                    {
                        let flag =
                            <DirectConstArgContext as
                                            ::bitflags::Flags>::FLAGS[i].value().bits();
                        truncated = truncated | flag;
                        i += 1;
                    }
                };
                {
                    {
                        let flag =
                            <DirectConstArgContext as
                                            ::bitflags::Flags>::FLAGS[i].value().bits();
                        truncated = truncated | flag;
                        i += 1;
                    }
                };
                {
                    {
                        let flag =
                            <DirectConstArgContext as
                                            ::bitflags::Flags>::FLAGS[i].value().bits();
                        truncated = truncated | flag;
                        i += 1;
                    }
                };
                {
                    {
                        let flag =
                            <DirectConstArgContext as
                                            ::bitflags::Flags>::FLAGS[i].value().bits();
                        truncated = truncated | flag;
                        i += 1;
                    }
                };
                {
                    {
                        let flag =
                            <DirectConstArgContext as
                                            ::bitflags::Flags>::FLAGS[i].value().bits();
                        truncated = truncated | flag;
                        i += 1;
                    }
                };
                {
                    {
                        let flag =
                            <DirectConstArgContext as
                                            ::bitflags::Flags>::FLAGS[i].value().bits();
                        truncated = truncated | flag;
                        i += 1;
                    }
                };
                {
                    {
                        let flag =
                            <DirectConstArgContext as
                                            ::bitflags::Flags>::FLAGS[i].value().bits();
                        truncated = truncated | flag;
                        i += 1;
                    }
                };
                {
                    {
                        let flag =
                            <DirectConstArgContext as
                                            ::bitflags::Flags>::FLAGS[i].value().bits();
                        truncated = truncated | flag;
                        i += 1;
                    }
                };
                {
                    {
                        let flag =
                            <DirectConstArgContext as
                                            ::bitflags::Flags>::FLAGS[i].value().bits();
                        truncated = truncated | flag;
                        i += 1;
                    }
                };
                let _ = i;
                Self(truncated)
            }
            /// Get the underlying bits value.
            ///
            /// The returned value is exactly the bits set in this flags value.
            #[inline]
            pub const fn bits(&self) -> u16 { self.0 }
            /// Convert from a bits value.
            ///
            /// This method will return `None` if any unknown bits are set.
            #[inline]
            pub const fn from_bits(bits: u16)
                -> ::bitflags::__private::core::option::Option<Self> {
                let truncated = Self::from_bits_truncate(bits).0;
                if truncated == bits {
                    ::bitflags::__private::core::option::Option::Some(Self(bits))
                } else { ::bitflags::__private::core::option::Option::None }
            }
            /// Convert from a bits value, unsetting any unknown bits.
            #[inline]
            pub const fn from_bits_truncate(bits: u16) -> Self {
                Self(bits & Self::all().0)
            }
            /// Convert from a bits value exactly.
            #[inline]
            pub const fn from_bits_retain(bits: u16) -> Self { Self(bits) }
            /// Get a flags value with the bits of a flag with the given name set.
            ///
            /// This method will return `None` if `name` is empty or doesn't
            /// correspond to any named flag.
            #[inline]
            pub fn from_name(name: &str)
                -> ::bitflags::__private::core::option::Option<Self> {
                {
                    if name == "TUPLE_CALL" {
                        return ::bitflags::__private::core::option::Option::Some(Self(DirectConstArgContext::TUPLE_CALL.bits()));
                    }
                };
                ;
                {
                    if name == "TUPLE" {
                        return ::bitflags::__private::core::option::Option::Some(Self(DirectConstArgContext::TUPLE.bits()));
                    }
                };
                ;
                {
                    if name == "PATH_PLAIN_PARAM" {
                        return ::bitflags::__private::core::option::Option::Some(Self(DirectConstArgContext::PATH_PLAIN_PARAM.bits()));
                    }
                };
                ;
                {
                    if name == "PATH_CONST_CTOR" {
                        return ::bitflags::__private::core::option::Option::Some(Self(DirectConstArgContext::PATH_CONST_CTOR.bits()));
                    }
                };
                ;
                {
                    if name == "PATH_ANY" {
                        return ::bitflags::__private::core::option::Option::Some(Self(DirectConstArgContext::PATH_ANY.bits()));
                    }
                };
                ;
                {
                    if name == "STRUCT" {
                        return ::bitflags::__private::core::option::Option::Some(Self(DirectConstArgContext::STRUCT.bits()));
                    }
                };
                ;
                {
                    if name == "ARRAY" {
                        return ::bitflags::__private::core::option::Option::Some(Self(DirectConstArgContext::ARRAY.bits()));
                    }
                };
                ;
                {
                    if name == "UNDERSCORE" {
                        return ::bitflags::__private::core::option::Option::Some(Self(DirectConstArgContext::UNDERSCORE.bits()));
                    }
                };
                ;
                {
                    if name == "PAREN" {
                        return ::bitflags::__private::core::option::Option::Some(Self(DirectConstArgContext::PAREN.bits()));
                    }
                };
                ;
                {
                    if name == "BLOCK" {
                        return ::bitflags::__private::core::option::Option::Some(Self(DirectConstArgContext::BLOCK.bits()));
                    }
                };
                ;
                {
                    if name == "LIT" {
                        return ::bitflags::__private::core::option::Option::Some(Self(DirectConstArgContext::LIT.bits()));
                    }
                };
                ;
                {
                    if name == "CONST_BLOCK" {
                        return ::bitflags::__private::core::option::Option::Some(Self(DirectConstArgContext::CONST_BLOCK.bits()));
                    }
                };
                ;
                {
                    if name == "GCA_MACRO" {
                        return ::bitflags::__private::core::option::Option::Some(Self(DirectConstArgContext::GCA_MACRO.bits()));
                    }
                };
                ;
                let _ = name;
                ::bitflags::__private::core::option::Option::None
            }
            /// Whether all bits in this flags value are unset.
            #[inline]
            pub const fn is_empty(&self) -> bool {
                self.0 == <u16 as ::bitflags::Bits>::EMPTY
            }
            /// Whether all known bits in this flags value are set.
            #[inline]
            pub const fn is_all(&self) -> bool {
                Self::all().0 | self.0 == self.0
            }
            /// Whether any set bits in a source flags value are also set in a target flags value.
            #[inline]
            pub const fn intersects(&self, other: Self) -> bool {
                self.0 & other.0 != <u16 as ::bitflags::Bits>::EMPTY
            }
            /// Whether all set bits in a source flags value are also set in a target flags value.
            #[inline]
            pub const fn contains(&self, other: Self) -> bool {
                self.0 & other.0 == other.0
            }
            /// The bitwise or (`|`) of the bits in two flags values.
            #[inline]
            pub fn insert(&mut self, other: Self) {
                *self = Self(self.0).union(other);
            }
            /// The intersection of a source flags value with the complement of a target flags
            /// value (`&!`).
            ///
            /// This method is not equivalent to `self & !other` when `other` has unknown bits set.
            /// `remove` won't truncate `other`, but the `!` operator will.
            #[inline]
            pub fn remove(&mut self, other: Self) {
                *self = Self(self.0).difference(other);
            }
            /// The bitwise exclusive-or (`^`) of the bits in two flags values.
            #[inline]
            pub fn toggle(&mut self, other: Self) {
                *self = Self(self.0).symmetric_difference(other);
            }
            /// Call `insert` when `value` is `true` or `remove` when `value` is `false`.
            #[inline]
            pub fn set(&mut self, other: Self, value: bool) {
                if value { self.insert(other); } else { self.remove(other); }
            }
            /// The bitwise and (`&`) of the bits in two flags values.
            #[inline]
            #[must_use]
            pub const fn intersection(self, other: Self) -> Self {
                Self(self.0 & other.0)
            }
            /// The bitwise or (`|`) of the bits in two flags values.
            #[inline]
            #[must_use]
            pub const fn union(self, other: Self) -> Self {
                Self(self.0 | other.0)
            }
            /// The intersection of a source flags value with the complement of a target flags
            /// value (`&!`).
            ///
            /// This method is not equivalent to `self & !other` when `other` has unknown bits set.
            /// `difference` won't truncate `other`, but the `!` operator will.
            #[inline]
            #[must_use]
            pub const fn difference(self, other: Self) -> Self {
                Self(self.0 & !other.0)
            }
            /// The bitwise exclusive-or (`^`) of the bits in two flags values.
            #[inline]
            #[must_use]
            pub const fn symmetric_difference(self, other: Self) -> Self {
                Self(self.0 ^ other.0)
            }
            /// The bitwise negation (`!`) of the bits in a flags value, truncating the result.
            #[inline]
            #[must_use]
            pub const fn complement(self) -> Self {
                Self::from_bits_truncate(!self.0)
            }
        }
        impl ::bitflags::__private::core::fmt::Binary for InternalBitFlags {
            fn fmt(&self, f: &mut ::bitflags::__private::core::fmt::Formatter)
                -> ::bitflags::__private::core::fmt::Result {
                let inner = self.0;
                ::bitflags::__private::core::fmt::Binary::fmt(&inner, f)
            }
        }
        impl ::bitflags::__private::core::fmt::Octal for InternalBitFlags {
            fn fmt(&self, f: &mut ::bitflags::__private::core::fmt::Formatter)
                -> ::bitflags::__private::core::fmt::Result {
                let inner = self.0;
                ::bitflags::__private::core::fmt::Octal::fmt(&inner, f)
            }
        }
        impl ::bitflags::__private::core::fmt::LowerHex for InternalBitFlags {
            fn fmt(&self, f: &mut ::bitflags::__private::core::fmt::Formatter)
                -> ::bitflags::__private::core::fmt::Result {
                let inner = self.0;
                ::bitflags::__private::core::fmt::LowerHex::fmt(&inner, f)
            }
        }
        impl ::bitflags::__private::core::fmt::UpperHex for InternalBitFlags {
            fn fmt(&self, f: &mut ::bitflags::__private::core::fmt::Formatter)
                -> ::bitflags::__private::core::fmt::Result {
                let inner = self.0;
                ::bitflags::__private::core::fmt::UpperHex::fmt(&inner, f)
            }
        }
        impl ::bitflags::__private::core::ops::BitOr for InternalBitFlags {
            type Output = Self;
            /// The bitwise or (`|`) of the bits in two flags values.
            #[inline]
            fn bitor(self, other: InternalBitFlags) -> Self {
                self.union(other)
            }
        }
        impl ::bitflags::__private::core::ops::BitOrAssign for
            InternalBitFlags {
            /// The bitwise or (`|`) of the bits in two flags values.
            #[inline]
            fn bitor_assign(&mut self, other: Self) { self.insert(other); }
        }
        impl ::bitflags::__private::core::ops::BitXor for InternalBitFlags {
            type Output = Self;
            /// The bitwise exclusive-or (`^`) of the bits in two flags values.
            #[inline]
            fn bitxor(self, other: Self) -> Self {
                self.symmetric_difference(other)
            }
        }
        impl ::bitflags::__private::core::ops::BitXorAssign for
            InternalBitFlags {
            /// The bitwise exclusive-or (`^`) of the bits in two flags values.
            #[inline]
            fn bitxor_assign(&mut self, other: Self) { self.toggle(other); }
        }
        impl ::bitflags::__private::core::ops::BitAnd for InternalBitFlags {
            type Output = Self;
            /// The bitwise and (`&`) of the bits in two flags values.
            #[inline]
            fn bitand(self, other: Self) -> Self { self.intersection(other) }
        }
        impl ::bitflags::__private::core::ops::BitAndAssign for
            InternalBitFlags {
            /// The bitwise and (`&`) of the bits in two flags values.
            #[inline]
            fn bitand_assign(&mut self, other: Self) {
                *self =
                    Self::from_bits_retain(self.bits()).intersection(other);
            }
        }
        impl ::bitflags::__private::core::ops::Sub for InternalBitFlags {
            type Output = Self;
            /// The intersection of a source flags value with the complement of a target flags value (`&!`).
            ///
            /// This method is not equivalent to `self & !other` when `other` has unknown bits set.
            /// `difference` won't truncate `other`, but the `!` operator will.
            #[inline]
            fn sub(self, other: Self) -> Self { self.difference(other) }
        }
        impl ::bitflags::__private::core::ops::SubAssign for InternalBitFlags
            {
            /// The intersection of a source flags value with the complement of a target flags value (`&!`).
            ///
            /// This method is not equivalent to `self & !other` when `other` has unknown bits set.
            /// `difference` won't truncate `other`, but the `!` operator will.
            #[inline]
            fn sub_assign(&mut self, other: Self) { self.remove(other); }
        }
        impl ::bitflags::__private::core::ops::Not for InternalBitFlags {
            type Output = Self;
            /// The bitwise negation (`!`) of the bits in a flags value, truncating the result.
            #[inline]
            fn not(self) -> Self { self.complement() }
        }
        impl ::bitflags::__private::core::iter::Extend<InternalBitFlags> for
            InternalBitFlags {
            /// The bitwise or (`|`) of the bits in each flags value.
            fn extend<T: ::bitflags::__private::core::iter::IntoIterator<Item
                = Self>>(&mut self, iterator: T) {
                for item in iterator { self.insert(item) }
            }
        }
        impl ::bitflags::__private::core::iter::FromIterator<InternalBitFlags>
            for InternalBitFlags {
            /// The bitwise or (`|`) of the bits in each flags value.
            fn from_iter<T: ::bitflags::__private::core::iter::IntoIterator<Item
                = Self>>(iterator: T) -> Self {
                use ::bitflags::__private::core::iter::Extend;
                let mut result = Self::empty();
                result.extend(iterator);
                result
            }
        }
        impl InternalBitFlags {
            /// Yield a set of contained flags values.
            ///
            /// Each yielded flags value will correspond to a defined named flag. Any unknown bits
            /// will be yielded together as a final flags value.
            #[inline]
            pub const fn iter(&self)
                -> ::bitflags::iter::Iter<DirectConstArgContext> {
                ::bitflags::iter::Iter::__private_const_new(<DirectConstArgContext
                        as ::bitflags::Flags>::FLAGS,
                    DirectConstArgContext::from_bits_retain(self.bits()),
                    DirectConstArgContext::from_bits_retain(self.bits()))
            }
            /// Yield a set of contained named flags values.
            ///
            /// This method is like [`iter`](#method.iter), except only yields bits in contained named flags.
            /// Any unknown bits, or bits not corresponding to a contained flag will not be yielded.
            #[inline]
            pub const fn iter_names(&self)
                -> ::bitflags::iter::IterNames<DirectConstArgContext> {
                ::bitflags::iter::IterNames::__private_const_new(<DirectConstArgContext
                        as ::bitflags::Flags>::FLAGS,
                    DirectConstArgContext::from_bits_retain(self.bits()),
                    DirectConstArgContext::from_bits_retain(self.bits()))
            }
        }
        impl ::bitflags::__private::core::iter::IntoIterator for
            InternalBitFlags {
            type Item = DirectConstArgContext;
            type IntoIter = ::bitflags::iter::Iter<DirectConstArgContext>;
            fn into_iter(self) -> Self::IntoIter { self.iter() }
        }
        impl InternalBitFlags {
            /// Returns a mutable reference to the raw value of the flags currently stored.
            #[inline]
            pub fn bits_mut(&mut self) -> &mut u16 { &mut self.0 }
        }
        #[allow(dead_code, deprecated, unused_attributes)]
        impl DirectConstArgContext {
            /// Get a flags value with all bits unset.
            #[inline]
            pub const fn empty() -> Self { Self(InternalBitFlags::empty()) }
            /// Get a flags value with all known bits set.
            #[inline]
            pub const fn all() -> Self { Self(InternalBitFlags::all()) }
            /// Get the underlying bits value.
            ///
            /// The returned value is exactly the bits set in this flags value.
            #[inline]
            pub const fn bits(&self) -> u16 { self.0.bits() }
            /// Convert from a bits value.
            ///
            /// This method will return `None` if any unknown bits are set.
            #[inline]
            pub const fn from_bits(bits: u16)
                -> ::bitflags::__private::core::option::Option<Self> {
                match InternalBitFlags::from_bits(bits) {
                    ::bitflags::__private::core::option::Option::Some(bits) =>
                        ::bitflags::__private::core::option::Option::Some(Self(bits)),
                    ::bitflags::__private::core::option::Option::None =>
                        ::bitflags::__private::core::option::Option::None,
                }
            }
            /// Convert from a bits value, unsetting any unknown bits.
            #[inline]
            pub const fn from_bits_truncate(bits: u16) -> Self {
                Self(InternalBitFlags::from_bits_truncate(bits))
            }
            /// Convert from a bits value exactly.
            #[inline]
            pub const fn from_bits_retain(bits: u16) -> Self {
                Self(InternalBitFlags::from_bits_retain(bits))
            }
            /// Get a flags value with the bits of a flag with the given name set.
            ///
            /// This method will return `None` if `name` is empty or doesn't
            /// correspond to any named flag.
            #[inline]
            pub fn from_name(name: &str)
                -> ::bitflags::__private::core::option::Option<Self> {
                match InternalBitFlags::from_name(name) {
                    ::bitflags::__private::core::option::Option::Some(bits) =>
                        ::bitflags::__private::core::option::Option::Some(Self(bits)),
                    ::bitflags::__private::core::option::Option::None =>
                        ::bitflags::__private::core::option::Option::None,
                }
            }
            /// Whether all bits in this flags value are unset.
            #[inline]
            pub const fn is_empty(&self) -> bool { self.0.is_empty() }
            /// Whether all known bits in this flags value are set.
            #[inline]
            pub const fn is_all(&self) -> bool { self.0.is_all() }
            /// Whether any set bits in a source flags value are also set in a target flags value.
            #[inline]
            pub const fn intersects(&self, other: Self) -> bool {
                self.0.intersects(other.0)
            }
            /// Whether all set bits in a source flags value are also set in a target flags value.
            #[inline]
            pub const fn contains(&self, other: Self) -> bool {
                self.0.contains(other.0)
            }
            /// The bitwise or (`|`) of the bits in two flags values.
            #[inline]
            pub fn insert(&mut self, other: Self) { self.0.insert(other.0) }
            /// The intersection of a source flags value with the complement of a target flags
            /// value (`&!`).
            ///
            /// This method is not equivalent to `self & !other` when `other` has unknown bits set.
            /// `remove` won't truncate `other`, but the `!` operator will.
            #[inline]
            pub fn remove(&mut self, other: Self) { self.0.remove(other.0) }
            /// The bitwise exclusive-or (`^`) of the bits in two flags values.
            #[inline]
            pub fn toggle(&mut self, other: Self) { self.0.toggle(other.0) }
            /// Call `insert` when `value` is `true` or `remove` when `value` is `false`.
            #[inline]
            pub fn set(&mut self, other: Self, value: bool) {
                self.0.set(other.0, value)
            }
            /// The bitwise and (`&`) of the bits in two flags values.
            #[inline]
            #[must_use]
            pub const fn intersection(self, other: Self) -> Self {
                Self(self.0.intersection(other.0))
            }
            /// The bitwise or (`|`) of the bits in two flags values.
            #[inline]
            #[must_use]
            pub const fn union(self, other: Self) -> Self {
                Self(self.0.union(other.0))
            }
            /// The intersection of a source flags value with the complement of a target flags
            /// value (`&!`).
            ///
            /// This method is not equivalent to `self & !other` when `other` has unknown bits set.
            /// `difference` won't truncate `other`, but the `!` operator will.
            #[inline]
            #[must_use]
            pub const fn difference(self, other: Self) -> Self {
                Self(self.0.difference(other.0))
            }
            /// The bitwise exclusive-or (`^`) of the bits in two flags values.
            #[inline]
            #[must_use]
            pub const fn symmetric_difference(self, other: Self) -> Self {
                Self(self.0.symmetric_difference(other.0))
            }
            /// The bitwise negation (`!`) of the bits in a flags value, truncating the result.
            #[inline]
            #[must_use]
            pub const fn complement(self) -> Self {
                Self(self.0.complement())
            }
        }
        impl ::bitflags::__private::core::fmt::Binary for
            DirectConstArgContext {
            fn fmt(&self, f: &mut ::bitflags::__private::core::fmt::Formatter)
                -> ::bitflags::__private::core::fmt::Result {
                let inner = self.0;
                ::bitflags::__private::core::fmt::Binary::fmt(&inner, f)
            }
        }
        impl ::bitflags::__private::core::fmt::Octal for DirectConstArgContext
            {
            fn fmt(&self, f: &mut ::bitflags::__private::core::fmt::Formatter)
                -> ::bitflags::__private::core::fmt::Result {
                let inner = self.0;
                ::bitflags::__private::core::fmt::Octal::fmt(&inner, f)
            }
        }
        impl ::bitflags::__private::core::fmt::LowerHex for
            DirectConstArgContext {
            fn fmt(&self, f: &mut ::bitflags::__private::core::fmt::Formatter)
                -> ::bitflags::__private::core::fmt::Result {
                let inner = self.0;
                ::bitflags::__private::core::fmt::LowerHex::fmt(&inner, f)
            }
        }
        impl ::bitflags::__private::core::fmt::UpperHex for
            DirectConstArgContext {
            fn fmt(&self, f: &mut ::bitflags::__private::core::fmt::Formatter)
                -> ::bitflags::__private::core::fmt::Result {
                let inner = self.0;
                ::bitflags::__private::core::fmt::UpperHex::fmt(&inner, f)
            }
        }
        impl ::bitflags::__private::core::ops::BitOr for DirectConstArgContext
            {
            type Output = Self;
            /// The bitwise or (`|`) of the bits in two flags values.
            #[inline]
            fn bitor(self, other: DirectConstArgContext) -> Self {
                self.union(other)
            }
        }
        impl ::bitflags::__private::core::ops::BitOrAssign for
            DirectConstArgContext {
            /// The bitwise or (`|`) of the bits in two flags values.
            #[inline]
            fn bitor_assign(&mut self, other: Self) { self.insert(other); }
        }
        impl ::bitflags::__private::core::ops::BitXor for
            DirectConstArgContext {
            type Output = Self;
            /// The bitwise exclusive-or (`^`) of the bits in two flags values.
            #[inline]
            fn bitxor(self, other: Self) -> Self {
                self.symmetric_difference(other)
            }
        }
        impl ::bitflags::__private::core::ops::BitXorAssign for
            DirectConstArgContext {
            /// The bitwise exclusive-or (`^`) of the bits in two flags values.
            #[inline]
            fn bitxor_assign(&mut self, other: Self) { self.toggle(other); }
        }
        impl ::bitflags::__private::core::ops::BitAnd for
            DirectConstArgContext {
            type Output = Self;
            /// The bitwise and (`&`) of the bits in two flags values.
            #[inline]
            fn bitand(self, other: Self) -> Self { self.intersection(other) }
        }
        impl ::bitflags::__private::core::ops::BitAndAssign for
            DirectConstArgContext {
            /// The bitwise and (`&`) of the bits in two flags values.
            #[inline]
            fn bitand_assign(&mut self, other: Self) {
                *self =
                    Self::from_bits_retain(self.bits()).intersection(other);
            }
        }
        impl ::bitflags::__private::core::ops::Sub for DirectConstArgContext {
            type Output = Self;
            /// The intersection of a source flags value with the complement of a target flags value (`&!`).
            ///
            /// This method is not equivalent to `self & !other` when `other` has unknown bits set.
            /// `difference` won't truncate `other`, but the `!` operator will.
            #[inline]
            fn sub(self, other: Self) -> Self { self.difference(other) }
        }
        impl ::bitflags::__private::core::ops::SubAssign for
            DirectConstArgContext {
            /// The intersection of a source flags value with the complement of a target flags value (`&!`).
            ///
            /// This method is not equivalent to `self & !other` when `other` has unknown bits set.
            /// `difference` won't truncate `other`, but the `!` operator will.
            #[inline]
            fn sub_assign(&mut self, other: Self) { self.remove(other); }
        }
        impl ::bitflags::__private::core::ops::Not for DirectConstArgContext {
            type Output = Self;
            /// The bitwise negation (`!`) of the bits in a flags value, truncating the result.
            #[inline]
            fn not(self) -> Self { self.complement() }
        }
        impl ::bitflags::__private::core::iter::Extend<DirectConstArgContext>
            for DirectConstArgContext {
            /// The bitwise or (`|`) of the bits in each flags value.
            fn extend<T: ::bitflags::__private::core::iter::IntoIterator<Item
                = Self>>(&mut self, iterator: T) {
                for item in iterator { self.insert(item) }
            }
        }
        impl ::bitflags::__private::core::iter::FromIterator<DirectConstArgContext>
            for DirectConstArgContext {
            /// The bitwise or (`|`) of the bits in each flags value.
            fn from_iter<T: ::bitflags::__private::core::iter::IntoIterator<Item
                = Self>>(iterator: T) -> Self {
                use ::bitflags::__private::core::iter::Extend;
                let mut result = Self::empty();
                result.extend(iterator);
                result
            }
        }
        impl DirectConstArgContext {
            /// Yield a set of contained flags values.
            ///
            /// Each yielded flags value will correspond to a defined named flag. Any unknown bits
            /// will be yielded together as a final flags value.
            #[inline]
            pub const fn iter(&self)
                -> ::bitflags::iter::Iter<DirectConstArgContext> {
                ::bitflags::iter::Iter::__private_const_new(<DirectConstArgContext
                        as ::bitflags::Flags>::FLAGS,
                    DirectConstArgContext::from_bits_retain(self.bits()),
                    DirectConstArgContext::from_bits_retain(self.bits()))
            }
            /// Yield a set of contained named flags values.
            ///
            /// This method is like [`iter`](#method.iter), except only yields bits in contained named flags.
            /// Any unknown bits, or bits not corresponding to a contained flag will not be yielded.
            #[inline]
            pub const fn iter_names(&self)
                -> ::bitflags::iter::IterNames<DirectConstArgContext> {
                ::bitflags::iter::IterNames::__private_const_new(<DirectConstArgContext
                        as ::bitflags::Flags>::FLAGS,
                    DirectConstArgContext::from_bits_retain(self.bits()),
                    DirectConstArgContext::from_bits_retain(self.bits()))
            }
        }
        impl ::bitflags::__private::core::iter::IntoIterator for
            DirectConstArgContext {
            type Item = DirectConstArgContext;
            type IntoIter = ::bitflags::iter::Iter<DirectConstArgContext>;
            fn into_iter(self) -> Self::IntoIter { self.iter() }
        }
    };bitflags::bitflags! {
3321    #[derive(Copy, Clone, Debug)]
3322    struct DirectConstArgContext: u16 {
3323        const TUPLE_CALL = 1 << 0;
3324        const TUPLE = 1 << 1;
3325        const PATH_PLAIN_PARAM = 1 << 2;
3326        const PATH_CONST_CTOR = 1 << 3;
3327        const PATH_ANY = 1 << 4;
3328        const STRUCT = 1 << 5;
3329        const ARRAY = 1 << 6;
3330        const UNDERSCORE = 1 << 7;
3331        const PAREN = 1 << 8;
3332        const BLOCK = 1 << 9;
3333        const LIT = 1 << 10;
3334        const CONST_BLOCK = 1 << 11;
3335        const GCA_MACRO = 1 << 12;
3336    }
3337}
3338
3339impl DirectConstArgContext {
3340    /// The only allowed direct const arg representation is simple paths that nameres to generic
3341    /// const parameters.
3342    const STABLE: DirectConstArgContext = Self::PATH_PLAIN_PARAM;
3343
3344    /// The allowed representations are what is allowed on stable, plus the `gca!` macro.
3345    const GCA: DirectConstArgContext = Self::STABLE.union(Self::GCA_MACRO);
3346
3347    /// These expressions are allowed inside the `gca!` macro, regardless of what feature is
3348    /// enabling the base `gca!` functionality.
3349    ///
3350    /// These are also allowed under macroless features without a `gca!` macro.
3351    const GCA_BASE_FEATURES: DirectConstArgContext = Self::GCA
3352        .union(DirectConstArgContext::UNDERSCORE)
3353        .union(DirectConstArgContext::PAREN)
3354        .union(DirectConstArgContext::BLOCK)
3355        .union(DirectConstArgContext::LIT)
3356        .union(DirectConstArgContext::CONST_BLOCK);
3357
3358    /// These are allowed under `#![feature(gca_min_const_items)]`
3359    const GCA_MIN_CONST_ITEMS: DirectConstArgContext = DirectConstArgContext::PATH_ANY;
3360
3361    /// These are allowed under `#![feature(gca_adts)]`
3362    const GCA_ADTS: DirectConstArgContext = DirectConstArgContext::PATH_CONST_CTOR
3363        .union(DirectConstArgContext::TUPLE_CALL)
3364        .union(DirectConstArgContext::TUPLE)
3365        .union(DirectConstArgContext::STRUCT)
3366        .union(DirectConstArgContext::ARRAY);
3367}
3368
3369#[derive(#[automatically_derived]
impl ::core::fmt::Debug for UnrepresentableConstArgError {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::debug_struct_field2_finish(f,
            "UnrepresentableConstArgError", "span", &self.span,
            "will_create_def_ids", &&self.will_create_def_ids)
    }
}Debug)]
3370struct UnrepresentableConstArgError {
3371    span: Span,
3372    will_create_def_ids: bool,
3373}
3374
3375impl UnrepresentableConstArgError {
3376    fn new(expr: &Expr) -> Self {
3377        Self {
3378            span: expr.span,
3379            will_create_def_ids: expr::WillCreateDefIdsVisitor.visit_expr(expr).is_break(),
3380        }
3381    }
3382
3383    fn emit<'hir>(self, lowering_context: &mut LoweringContext<'_, 'hir>) -> ConstArg<'hir> {
3384        let msg = "complex const arguments must be placed inside of a `const` block";
3385        let e = if self.will_create_def_ids {
3386            // FIXME(mgca): make this non-fatal once we have a better way to handle
3387            // nested items in const args
3388            // Issue: https://github.com/rust-lang/rust/issues/154539
3389            lowering_context.dcx().span_fatal(self.span, msg)
3390        } else {
3391            lowering_context.dcx().span_err(self.span, msg)
3392        };
3393
3394        ConstArg {
3395            hir_id: lowering_context.next_id(),
3396            kind: hir::ConstArgKind::Error(e),
3397            span: lowering_context.lower_span(self.span),
3398        }
3399    }
3400}