Skip to main content

rustc_ast_lowering/
lib.rs

1//! Lowers the AST to the HIR.
2//!
3//! Since the AST and HIR are fairly similar, this is mostly a simple procedure,
4//! much like a fold. Where lowering involves a bit more work things get more
5//! interesting and there are some invariants you should know about. These mostly
6//! concern spans and IDs.
7//!
8//! Spans are assigned to AST nodes during parsing and then are modified during
9//! expansion to indicate the origin of a node and the process it went through
10//! being expanded. IDs are assigned to AST nodes just before lowering.
11//!
12//! For the simpler lowering steps, IDs and spans should be preserved. Unlike
13//! expansion we do not preserve the process of lowering in the spans, so spans
14//! should not be modified here. When creating a new node (as opposed to
15//! "folding" an existing one), create a new ID using `next_id()`.
16//!
17//! You must ensure that IDs are unique. That means that you should only use the
18//! ID from an AST node in a single HIR node (you can assume that AST node-IDs
19//! are unique). Every new node must have a unique ID. Avoid cloning HIR nodes.
20//! If you do, you must then set the new node's ID to a fresh one.
21//!
22//! Spans are used for error messages and for tools to map semantics back to
23//! source code. It is therefore not as important with spans as IDs to be strict
24//! about use (you can't break the compiler by screwing up a span). Obviously, a
25//! HIR node can only have a single span. But multiple nodes can have the same
26//! span and spans don't need to be kept in order, etc. Where code is preserved
27//! by lowering, it should have the same span as in the AST. Where HIR nodes are
28//! new it is probably best to give a span for the whole AST node being lowered.
29//! All nodes should have real spans; don't use dummy spans. Tools are likely to
30//! get confused if the spans from leaf AST nodes occur in multiple places
31//! in the HIR, especially for multiple identifiers.
32
33// tidy-alphabetical-start
34#![feature(const_default)]
35#![feature(const_trait_impl)]
36#![feature(default_field_values)]
37#![feature(deref_patterns)]
38#![recursion_limit = "256"]
39// tidy-alphabetical-end
40
41use std::mem;
42use std::sync::Arc;
43
44use rustc_ast::mut_visit::{self, MutVisitor};
45use rustc_ast::node_id::NodeMap;
46use rustc_ast::visit::{self, Visitor};
47use rustc_ast::{self as ast, *};
48use rustc_attr_parsing::{AttributeParser, Recovery, ShouldEmit};
49use rustc_data_structures::fx::FxIndexMap;
50use rustc_data_structures::sorted_map::SortedMap;
51use rustc_data_structures::stable_hash::{StableHash, StableHasher};
52use rustc_data_structures::steal::Steal;
53use rustc_data_structures::tagged_ptr::TaggedRef;
54use rustc_data_structures::unord::ExtendUnord;
55use rustc_errors::codes::*;
56use rustc_errors::{DiagArgFromDisplay, DiagCtxtHandle, ErrorGuaranteed};
57use rustc_hir::attrs::lang_items::LangItem;
58use rustc_hir::def::{DefKind, Namespace, PerNS, Res};
59use rustc_hir::def_id::{DefId, LOCAL_CRATE, LocalDefId, LocalDefIdMap};
60use rustc_hir::definitions::PerParentDisambiguatorState;
61use rustc_hir::lints::DelayedLint;
62use rustc_hir::{
63    self as hir, AngleBrackets, ConstArg, GenericArg, HirId, ItemLocalMap, LifetimeSource,
64    LifetimeSyntax, MissingLifetimeKind, ParamName, Target, TraitCandidate, find_attr,
65};
66use rustc_index::{Idx, IndexSlice, IndexVec};
67use rustc_macros::extension;
68use rustc_middle::middle::resolve::{
69    AstOwner, LifetimeRes, PartialRes, PerOwnerResolverData, ResolverAstLowering,
70};
71use rustc_middle::queries::Providers;
72use rustc_middle::ty::TyCtxt;
73use rustc_session::diagnostics::add_feature_diagnostics;
74use rustc_span::symbol::{Ident, Symbol, kw, sym};
75use rustc_span::{DUMMY_SP, DesugaringKind, Span, span_bug};
76use smallvec::{SmallVec, smallvec};
77use thin_vec::ThinVec;
78use tracing::{debug, instrument, trace};
79
80use crate::diagnostics::{AssocTyParentheses, AssocTyParenthesesSub, MisplacedImplTrait};
81
82macro_rules! arena_vec {
83    ($this:expr; $($x:expr),*) => (
84        $this.arena.alloc_from_iter([$($x),*])
85    );
86}
87
88mod asm;
89mod block;
90mod contract;
91mod delegation;
92mod diagnostics;
93mod expr;
94mod format;
95mod index;
96mod item;
97mod pat;
98mod path;
99pub mod stability;
100
101pub fn provide(providers: &mut Providers) {
102    providers.index_ast = index_ast;
103    providers.lower_to_hir = lower_to_hir;
104    providers.resolve_type_relative_delegations =
105        delegation::resolution::resolve_type_relative_delegations;
106}
107
108#[cfg(debug_assertions)]
109pub(crate) mod re_lowering {
110    use rustc_ast::NodeId;
111    use rustc_ast::node_id::NodeMap;
112    use rustc_hir as hir;
113
114    use crate::LoweringContext;
115
116    #[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() -> ReloweringChecker {
        ReloweringChecker {
            node_id_to_local_id: ::core::default::Default::default(),
            can_relower: ::core::default::Default::default(),
        }
    }
}Default)]
117    pub(crate) struct ReloweringChecker {
118        node_id_to_local_id: NodeMap<hir::ItemLocalId>,
119        can_relower: bool,
120    }
121
122    impl ReloweringChecker {
123        pub(crate) fn assert_node_is_not_relowered(
124            &mut self,
125            ast_node_id: NodeId,
126            local_id: hir::ItemLocalId,
127        ) {
128            if !self.can_relower {
129                let old = self.node_id_to_local_id.insert(ast_node_id, local_id);
130                {
    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);
131            }
132        }
133
134        pub(crate) fn allow_relowering<'a, 'hir, TRes>(
135            ctx: &mut LoweringContext<'a, 'hir>,
136            op: impl FnOnce(&mut LoweringContext<'a, 'hir>) -> TRes,
137        ) -> TRes {
138            if !!ctx.curr_owner.relowering_checker.can_relower {
    {
        ::core::panicking::panic_fmt(format_args!("reentrant relowering is not supported"));
    }
};assert!(
139                !ctx.curr_owner.relowering_checker.can_relower,
140                "reentrant relowering is not supported"
141            );
142
143            ctx.curr_owner.relowering_checker.can_relower = true;
144
145            let res = op(ctx);
146
147            ctx.curr_owner.relowering_checker.can_relower = false;
148
149            res
150        }
151    }
152}
153
154struct PerOwnerLoweringState<'a, 'hir> {
155    // -- Identity --
156    owner: &'a PerOwnerResolverData<'hir>,
157    owner_id: hir::OwnerId,
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 [hir::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            owner_id: hir::OwnerId { def_id: owner.def_id },
200            disambiguator,
201            // 0 corresponds to `owner` lowered as `owner_id`, and we never call
202            // `lower_node_id(owner)`.
203            item_local_id_counter: hir::ItemLocalId::new(1),
204            ident_and_label_to_local_id: Default::default(),
205            #[cfg(debug_assertions)]
206            relowering_checker: Default::default(),
207            attrs: SortedMap::default(),
208            bodies: Vec::new(),
209            define_opaque: None,
210            trait_map: Default::default(),
211            delayed_lints: Vec::new(),
212            children: LocalDefIdMap::default(),
213            impl_trait_defs: Vec::new(),
214            impl_trait_bounds: Vec::new(),
215        }
216    }
217
218    fn into_owner_info(
219        self,
220        tcx: TyCtxt<'hir>,
221        node: hir::OwnerNode<'hir>,
222    ) -> &'hir hir::OwnerInfo<'hir> {
223        {
    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());
224        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());
225        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());
226
227        let attrs = self.attrs;
228        let mut bodies = self.bodies;
229        let define_opaque = self.define_opaque;
230        let trait_map = self.trait_map;
231        let delayed_lints = Steal::new(self.delayed_lints.into_boxed_slice());
232        let children = self.children;
233
234        #[cfg(debug_assertions)]
235        for (id, attrs) in attrs.iter() {
236            // Verify that we do not store empty slices in the map.
237            if attrs.is_empty() {
238                {
    ::core::panicking::panic_fmt(format_args!("Stored empty attributes for {0:?}",
            id));
};panic!("Stored empty attributes for {:?}", id);
239            }
240        }
241
242        bodies.sort_by_key(|(k, _)| *k);
243        let bodies = SortedMap::from_presorted_elements(bodies);
244
245        // Don't hash unless necessary, because it's expensive.
246        let rustc_middle::hir::Hashes { bodies_hash, attrs_hash } =
247            tcx.hash_owner_nodes(node, &bodies, &attrs, define_opaque);
248        let num_nodes = self.item_local_id_counter.as_usize();
249        let (nodes, parenting) = index::index_hir(tcx, node, &bodies, num_nodes);
250        let nodes = hir::OwnerNodes { opt_hash: bodies_hash, nodes, bodies };
251        let attrs = hir::AttributeMap { map: attrs, opt_hash: attrs_hash, define_opaque };
252
253        let opt_hash = tcx.needs_hir_hash().then(|| {
254            tcx.with_stable_hashing_context(|mut hcx| {
255                let mut stable_hasher = StableHasher::new();
256                bodies_hash.unwrap().stable_hash(&mut hcx, &mut stable_hasher);
257                attrs_hash.unwrap().stable_hash(&mut hcx, &mut stable_hasher);
258                // Do not hash delayed_lints.
259                parenting.stable_hash(&mut hcx, &mut stable_hasher);
260                trait_map.stable_hash(&mut hcx, &mut stable_hasher);
261                children.stable_hash(&mut hcx, &mut stable_hasher);
262                stable_hasher.finish()
263            })
264        });
265
266        tcx.hir_arena.alloc(hir::OwnerInfo {
267            opt_hash,
268            nodes,
269            parenting,
270            attrs,
271            trait_map,
272            delayed_lints,
273            children,
274        })
275    }
276}
277
278struct LoweringContext<'a, 'hir> {
279    tcx: TyCtxt<'hir>,
280    resolver: &'a ResolverAstLowering<'hir>,
281
282    curr_owner: PerOwnerLoweringState<'a, 'hir>,
283
284    /// Used to allocate HIR nodes.
285    arena: &'hir hir::Arena<'hir>,
286
287    contract_ensures: Option<(Span, Ident, HirId)>,
288
289    coroutine_kind: Option<hir::CoroutineKind>,
290
291    /// When inside an `async` context, this is the `HirId` of the
292    /// `task_context` local bound to the resume argument of the coroutine.
293    task_context: Option<HirId>,
294
295    /// Used to get the current `fn`'s def span to point to when using `await`
296    /// outside of an `async fn`.
297    current_item: Option<Span>,
298
299    try_block_scope: TryBlockScope,
300    loop_scope: Option<HirId>,
301    is_in_loop_condition: bool,
302    is_in_dyn_type: bool,
303
304    /// The `NodeId` space is split in two.
305    /// `0..resolver.next_node_id` are created by the resolver on the AST.
306    /// The higher part `resolver.next_node_id..next_node_id` are created during lowering.
307    next_node_id: NodeId,
308    /// Maps the `NodeId`s created during lowering to `LocalDefId`s.
309    node_id_to_def_id: NodeMap<LocalDefId>,
310    /// Overlay over resolver's `partial_res_map` used by delegation.
311    /// This only contains `PartialRes::new(Res::Local(self_param_id))`,
312    /// so we only store `self_param_id`.
313    partial_res_overrides: NodeMap<NodeId>,
314
315    allow_contracts: Arc<[Symbol]>,
316    allow_try_trait: Arc<[Symbol]>,
317    allow_gen_future: Arc<[Symbol]>,
318    allow_pattern_type: Arc<[Symbol]>,
319    allow_async_gen: Arc<[Symbol]>,
320    allow_async_iterator: Arc<[Symbol]>,
321    allow_for_await: Arc<[Symbol]>,
322    allow_async_fn_traits: Arc<[Symbol]>,
323
324    /// Stack of `move(...)` collection states. A closure-like body pushes
325    /// `Some`, so `move(...)` expressions can record the generated locals they
326    /// should lower to. Nested bodies that cannot use `move(...)` push `None`.
327    move_expr_bindings: Vec<Option<expr::MoveExprState<'hir>>>,
328
329    /// Whether an initializer for a recorded `move(...)` is currently being lowered.
330    lowering_move_expr_initializer: bool,
331
332    attribute_parser: AttributeParser<'hir>,
333}
334
335impl<'a, 'hir> LoweringContext<'a, 'hir> {
336    fn new(tcx: TyCtxt<'hir>, resolver: &'a ResolverAstLowering<'hir>, owner: NodeId) -> Self {
337        Self {
338            tcx,
339            resolver,
340            curr_owner: PerOwnerLoweringState::new(resolver, owner),
341            arena: tcx.hir_arena,
342
343            contract_ensures: None,
344
345            next_node_id: resolver.next_node_id,
346            node_id_to_def_id: NodeMap::default(),
347            partial_res_overrides: NodeMap::default(),
348
349            // Lowering state.
350            try_block_scope: TryBlockScope::Function,
351            loop_scope: None,
352            is_in_loop_condition: false,
353            is_in_dyn_type: false,
354            coroutine_kind: None,
355            task_context: None,
356            current_item: None,
357            allow_contracts: [sym::contracts_internals].into(),
358            allow_try_trait: [
359                sym::try_trait_v2,
360                sym::try_trait_v2_residual,
361                sym::yeet_desugar_details,
362            ]
363            .into(),
364            allow_pattern_type: [sym::pattern_types, sym::pattern_type_range_trait].into(),
365            allow_gen_future: if tcx.features().async_fn_track_caller() {
366                [sym::gen_future, sym::closure_track_caller].into()
367            } else {
368                [sym::gen_future].into()
369            },
370            allow_for_await: [sym::async_gen_internals, sym::async_iterator].into(),
371            allow_async_fn_traits: [sym::async_fn_traits].into(),
372            allow_async_gen: [sym::async_gen_internals].into(),
373            // FIXME(gen_blocks): how does `closure_track_caller`/`async_fn_track_caller`
374            // interact with `gen`/`async gen` blocks
375            allow_async_iterator: [sym::gen_future, sym::async_iterator].into(),
376
377            move_expr_bindings: Vec::new(),
378            lowering_move_expr_initializer: false,
379            attribute_parser: AttributeParser::new(
380                tcx.sess,
381                tcx.features(),
382                tcx.registered_attr_tools(()),
383                ShouldEmit::ErrorsAndLints { recovery: Recovery::Allowed },
384            ),
385        }
386    }
387
388    pub(crate) fn dcx(&self) -> DiagCtxtHandle<'hir> {
389        self.tcx.dcx()
390    }
391}
392
393struct SpanLowerer {
394    is_incremental: bool,
395    def_id: LocalDefId,
396}
397
398impl SpanLowerer {
399    fn lower(&self, span: Span) -> Span {
400        if self.is_incremental {
401            span.with_parent(Some(self.def_id))
402        } else {
403            // Do not make spans relative when not using incremental compilation.
404            span
405        }
406    }
407}
408
409trait 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>)]
410impl<'tcx> ResolverAstLowering<'tcx> {
411    fn legacy_const_generic_args(&self, expr: &Expr, tcx: TyCtxt<'tcx>) -> Option<Vec<usize>> {
412        let ExprKind::Path(None, path) = &expr.kind else {
413            return None;
414        };
415
416        // Don't perform legacy const generics rewriting if the path already
417        // has generic arguments.
418        if path.segments.last().unwrap().args.is_some() {
419            return None;
420        }
421
422        // We do not need to look at `partial_res_overrides`. That map only contains overrides for
423        // `self_param` locals. And here we are looking for the function definition that `expr`
424        // resolves to.
425        let def_id = self.partial_res_map.get(&expr.id)?.full_res()?.opt_def_id()?;
426
427        // We only support cross-crate argument rewriting. Uses
428        // within the same crate should be updated to use the new
429        // const generics style.
430        if def_id.is_local() {
431            return None;
432        }
433
434        // we can use parsed attrs here since for other crates they're already available
435        find_attr!(
436            tcx, def_id,
437            RustcLegacyConstGenerics{fn_indexes,..} => fn_indexes
438        )
439        .map(|fn_indexes| fn_indexes.iter().map(|(num, _)| *num).collect())
440    }
441}
442
443/// How relaxed bounds `?Trait` should be treated.
444///
445/// Relaxed bounds should only be allowed in places where we later
446/// (namely during HIR ty lowering) perform *sized elaboration*.
447#[derive(#[automatically_derived]
impl<'a> ::core::fmt::Debug for RelaxedBoundPolicy<'a> {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        match self {
            RelaxedBoundPolicy::Allowed(__self_0) =>
                ::core::fmt::Formatter::debug_tuple_field1_finish(f,
                    "Allowed", &__self_0),
            RelaxedBoundPolicy::Forbidden(__self_0) =>
                ::core::fmt::Formatter::debug_tuple_field1_finish(f,
                    "Forbidden", &__self_0),
        }
    }
}Debug)]
448enum RelaxedBoundPolicy<'a> {
449    /// The `DefId` refers to the trait that is being relaxed.
450    Allowed(&'a mut FxIndexMap<DefId, Span>),
451    Forbidden(RelaxedBoundForbiddenReason),
452}
453impl RelaxedBoundPolicy<'_> {
454    fn reborrow(&mut self) -> RelaxedBoundPolicy<'_> {
455        match self {
456            RelaxedBoundPolicy::Allowed(m) => RelaxedBoundPolicy::Allowed(m),
457            RelaxedBoundPolicy::Forbidden(reason) => RelaxedBoundPolicy::Forbidden(*reason),
458        }
459    }
460}
461
462#[derive(#[automatically_derived]
#[doc(hidden)]
unsafe impl ::core::clone::TrivialClone for RelaxedBoundForbiddenReason { }
#[automatically_derived]
impl ::core::clone::Clone for RelaxedBoundForbiddenReason {
    #[inline]
    fn clone(&self) -> RelaxedBoundForbiddenReason { *self }
}Clone, #[automatically_derived]
impl ::core::marker::Copy for RelaxedBoundForbiddenReason { }Copy, #[automatically_derived]
impl ::core::fmt::Debug for RelaxedBoundForbiddenReason {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::write_str(f,
            match self {
                RelaxedBoundForbiddenReason::TraitObjectTy => "TraitObjectTy",
                RelaxedBoundForbiddenReason::SuperTrait => "SuperTrait",
                RelaxedBoundForbiddenReason::TraitAlias => "TraitAlias",
                RelaxedBoundForbiddenReason::AssocTyBounds => "AssocTyBounds",
                RelaxedBoundForbiddenReason::WhereBound => "WhereBound",
            })
    }
}Debug)]
463enum RelaxedBoundForbiddenReason {
464    TraitObjectTy,
465    SuperTrait,
466    TraitAlias,
467    AssocTyBounds,
468    /// We do not allow where bounds doing relaxed bounds,
469    /// except if it's for generic parameters of the current item.
470    WhereBound,
471}
472
473/// Context of `impl Trait` in code, which determines whether it is allowed in an HIR subtree,
474/// and if so, what meaning it has.
475#[derive(#[automatically_derived]
impl ::core::fmt::Debug for ImplTraitContext {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        match self {
            ImplTraitContext::Universal =>
                ::core::fmt::Formatter::write_str(f, "Universal"),
            ImplTraitContext::OpaqueTy { origin: __self_0 } =>
                ::core::fmt::Formatter::debug_struct_field1_finish(f,
                    "OpaqueTy", "origin", &__self_0),
            ImplTraitContext::InBinding =>
                ::core::fmt::Formatter::write_str(f, "InBinding"),
            ImplTraitContext::FeatureGated(__self_0, __self_1) =>
                ::core::fmt::Formatter::debug_tuple_field2_finish(f,
                    "FeatureGated", __self_0, &__self_1),
            ImplTraitContext::Disallowed(__self_0) =>
                ::core::fmt::Formatter::debug_tuple_field1_finish(f,
                    "Disallowed", &__self_0),
            ImplTraitContext::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) -> ImplTraitContext {
        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: &ImplTraitContext) -> bool {
        let __self_discr = ::core::intrinsics::discriminant_value(self);
        let __arg1_discr = ::core::intrinsics::discriminant_value(other);
        __self_discr == __arg1_discr &&
            match (self, other) {
                (ImplTraitContext::OpaqueTy { origin: __self_0 },
                    ImplTraitContext::OpaqueTy { origin: __arg1_0 }) =>
                    __self_0 == __arg1_0,
                (ImplTraitContext::FeatureGated(__self_0, __self_1),
                    ImplTraitContext::FeatureGated(__arg1_0, __arg1_1)) =>
                    __self_0 == __arg1_0 && __self_1 == __arg1_1,
                (ImplTraitContext::Disallowed(__self_0),
                    ImplTraitContext::Disallowed(__arg1_0)) =>
                    __self_0 == __arg1_0,
                (ImplTraitContext::AlreadyErrored(__self_0),
                    ImplTraitContext::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)]
476enum ImplTraitContext {
477    /// Treat `impl Trait` as shorthand for a new universal generic parameter.
478    /// Example: `fn foo(x: impl Debug)`, where `impl Debug` is conceptually
479    /// equivalent to a fresh universal parameter like `fn foo<T: Debug>(x: T)`.
480    ///
481    /// Newly generated parameters should be inserted into the given `Vec`.
482    Universal,
483
484    /// Treat `impl Trait` as shorthand for a new opaque type.
485    /// Example: `fn foo() -> impl Debug`, where `impl Debug` is conceptually
486    /// equivalent to a new opaque type like `type T = impl Debug; fn foo() -> T`.
487    ///
488    OpaqueTy { origin: hir::OpaqueTyOrigin<LocalDefId> },
489
490    /// Treat `impl Trait` as a "trait ascription", which is like a type
491    /// variable but that also enforces that a set of trait goals hold.
492    ///
493    /// This is useful to guide inference for unnameable types.
494    InBinding,
495
496    /// `impl Trait` is unstably accepted in this position.
497    FeatureGated(ImplTraitPosition, Symbol),
498    /// `impl Trait` is not accepted in this position.
499    Disallowed(ImplTraitPosition),
500
501    /// An error has already been emitted for this type.
502    AlreadyErrored(ErrorGuaranteed),
503}
504
505/// Position in which `impl Trait` is disallowed.
506#[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) -> ImplTraitPosition { *self }
}Clone, #[automatically_derived]
impl ::core::marker::StructuralPartialEq for ImplTraitPosition { }
#[automatically_derived]
impl ::core::cmp::PartialEq for ImplTraitPosition {
    #[inline]
    fn eq(&self, other: &ImplTraitPosition) -> bool {
        let __self_discr = ::core::intrinsics::discriminant_value(self);
        let __arg1_discr = ::core::intrinsics::discriminant_value(other);
        __self_discr == __arg1_discr
    }
}PartialEq, #[automatically_derived]
impl ::core::cmp::Eq for ImplTraitPosition { }Eq)]
507enum ImplTraitPosition {
508    Path,
509    Variable,
510    Trait,
511    Bound,
512    Generic,
513    ExternFnParam,
514    ClosureParam,
515    PointerParam,
516    FnTraitParam,
517    ExternFnReturn,
518    ClosureReturn,
519    PointerReturn,
520    FnTraitReturn,
521    GenericDefault,
522    ConstTy,
523    StaticTy,
524    AssocTy,
525    FieldTy,
526    Cast,
527    ImplSelf,
528    OffsetOf,
529}
530
531impl std::fmt::Display for ImplTraitPosition {
532    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
533        let name = match self {
534            ImplTraitPosition::Path => "paths",
535            ImplTraitPosition::Variable => "the type of variable bindings",
536            ImplTraitPosition::Trait => "traits",
537            ImplTraitPosition::Bound => "bounds",
538            ImplTraitPosition::Generic => "generics",
539            ImplTraitPosition::ExternFnParam => "`extern fn` parameters",
540            ImplTraitPosition::ClosureParam => "closure parameters",
541            ImplTraitPosition::PointerParam => "`fn` pointer parameters",
542            ImplTraitPosition::FnTraitParam => "the parameters of `Fn` trait bounds",
543            ImplTraitPosition::ExternFnReturn => "`extern fn` return types",
544            ImplTraitPosition::ClosureReturn => "closure return types",
545            ImplTraitPosition::PointerReturn => "`fn` pointer return types",
546            ImplTraitPosition::FnTraitReturn => "the return type of `Fn` trait bounds",
547            ImplTraitPosition::GenericDefault => "generic parameter defaults",
548            ImplTraitPosition::ConstTy => "const types",
549            ImplTraitPosition::StaticTy => "static types",
550            ImplTraitPosition::AssocTy => "associated types",
551            ImplTraitPosition::FieldTy => "field types",
552            ImplTraitPosition::Cast => "cast expression types",
553            ImplTraitPosition::ImplSelf => "impl headers",
554            ImplTraitPosition::OffsetOf => "`offset_of!` parameters",
555        };
556
557        f.write_fmt(format_args!("{0}", name))write!(f, "{name}")
558    }
559}
560
561#[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) -> FnDeclKind { *self }
}Clone, #[automatically_derived]
impl ::core::fmt::Debug for FnDeclKind {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::write_str(f,
            match self {
                FnDeclKind::Fn => "Fn",
                FnDeclKind::Inherent => "Inherent",
                FnDeclKind::ExternFn => "ExternFn",
                FnDeclKind::Closure => "Closure",
                FnDeclKind::Pointer => "Pointer",
                FnDeclKind::Trait => "Trait",
                FnDeclKind::Impl => "Impl",
            })
    }
}Debug, #[automatically_derived]
impl ::core::marker::StructuralPartialEq for FnDeclKind { }
#[automatically_derived]
impl ::core::cmp::PartialEq for FnDeclKind {
    #[inline]
    fn eq(&self, other: &FnDeclKind) -> bool {
        let __self_discr = ::core::intrinsics::discriminant_value(self);
        let __arg1_discr = ::core::intrinsics::discriminant_value(other);
        __self_discr == __arg1_discr
    }
}PartialEq, #[automatically_derived]
impl ::core::cmp::Eq for FnDeclKind { }Eq)]
562enum FnDeclKind {
563    Fn,
564    Inherent,
565    ExternFn,
566    Closure,
567    Pointer,
568    Trait,
569    Impl,
570}
571
572#[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) -> TryBlockScope {
        let _: ::core::clone::AssertParamIsClone<HirId>;
        *self
    }
}Clone, #[automatically_derived]
impl ::core::fmt::Debug for TryBlockScope {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        match self {
            TryBlockScope::Function =>
                ::core::fmt::Formatter::write_str(f, "Function"),
            TryBlockScope::Homogeneous(__self_0) =>
                ::core::fmt::Formatter::debug_tuple_field1_finish(f,
                    "Homogeneous", &__self_0),
            TryBlockScope::Heterogeneous(__self_0) =>
                ::core::fmt::Formatter::debug_tuple_field1_finish(f,
                    "Heterogeneous", &__self_0),
        }
    }
}Debug)]
573enum TryBlockScope {
574    /// There isn't a `try` block, so a `?` will use `return`.
575    Function,
576    /// We're inside a `try { … }` block, so a `?` will block-break
577    /// from that block using a type depending only on the argument.
578    Homogeneous(HirId),
579    /// We're inside a `try as _ { … }` block, so a `?` will block-break
580    /// from that block using the type specified.
581    Heterogeneous(HirId),
582}
583
584fn index_ast<'tcx>(
585    tcx: TyCtxt<'tcx>,
586    (): (),
587) -> &'tcx IndexSlice<LocalDefId, Steal<(Arc<ResolverAstLowering<'tcx>>, AstOwner)>> {
588    // Queries that borrow `resolver_for_lowering`.
589    tcx.ensure_done().output_filenames(());
590    tcx.ensure_done().early_lint_checks(());
591    tcx.ensure_done().get_lang_items(());
592    tcx.ensure_done().debugger_visualizers(LOCAL_CRATE);
593
594    let (resolver, krate) = tcx.resolver_for_lowering();
595    let mut resolver = resolver.steal();
596    let mut krate = krate.steal();
597
598    let mut indexer = Indexer {
599        owners: &resolver.owners,
600        index: IndexVec::new(),
601        next_node_id: resolver.next_node_id,
602    };
603    indexer.visit_crate(&mut krate);
604    indexer.insert(CRATE_NODE_ID, AstOwner::Crate(Box::new(krate)));
605    resolver.next_node_id = indexer.next_node_id;
606
607    let index = indexer.index;
608    let resolver = Arc::new(resolver);
609    return tcx.arena.alloc_index_slice_from_iter::<LocalDefId, _, _>(
610        index.into_iter().map(|owner| Steal::new((Arc::clone(&resolver), owner))),
611    );
612
613    struct Indexer<'s, 'hir> {
614        owners: &'s NodeMap<PerOwnerResolverData<'hir>>,
615        index: IndexVec<LocalDefId, AstOwner>,
616        next_node_id: NodeId,
617    }
618
619    impl Indexer<'_, '_> {
620        fn insert(&mut self, id: NodeId, node: AstOwner) {
621            let def_id = self.owners[&id].def_id;
622            self.index.ensure_contains_elem(def_id, || AstOwner::NonOwner);
623            self.index[def_id] = node;
624        }
625
626        fn make_dummy<K>(
627            &mut self,
628            id: NodeId,
629            span: Span,
630            dummy: impl FnOnce(Box<MacCall>) -> K,
631        ) -> Box<Item<K>> {
632            use rustc_ast::token::Delimiter;
633            use rustc_ast::tokenstream::{DelimSpan, TokenStream};
634            use thin_vec::thin_vec;
635
636            Box::new(Item {
637                attrs: AttrVec::default(),
638                id,
639                span,
640                vis: Visibility { kind: VisibilityKind::Public, span },
641                // Lacking a better choice, we replace the contents with a macro call.
642                // Unexpanded macros should never reach lowering, so this is not confusing.
643                kind: dummy(Box::new(MacCall {
644                    path: Path { span, segments: ::thin_vec::ThinVec::new()thin_vec![] },
645                    args: Box::new(DelimArgs {
646                        dspan: DelimSpan::from_single(span),
647                        delim: Delimiter::Parenthesis,
648                        tokens: TokenStream::new(Vec::new()),
649                    }),
650                })),
651                tokens: None,
652            })
653        }
654
655        fn replace_with_dummy<K>(
656            &mut self,
657            item: &mut ast::Item<K>,
658            dummy: impl FnOnce(Box<MacCall>) -> K,
659            node: impl FnOnce(Box<Item<K>>) -> AstOwner,
660        ) {
661            let dummy = self.make_dummy(item.id, item.span, dummy);
662            let item = mem::replace(item, *dummy);
663            self.insert(item.id, node(Box::new(item)));
664        }
665
666        {}
#[allow(clippy :: suspicious_else_formatting)]
{
    let __tracing_attr_span;
    let __tracing_attr_guard;
    if ::tracing::Level::TRACE <= ::tracing::level_filters::STATIC_MAX_LEVEL
                &&
                ::tracing::Level::TRACE <=
                    ::tracing::level_filters::LevelFilter::current() ||
            { false } {
        __tracing_attr_span =
            {
                use ::tracing::__macro_support::Callsite as _;
                static __CALLSITE: ::tracing::callsite::DefaultCallsite =
                    {
                        static META: ::tracing::Metadata<'static> =
                            {
                                ::tracing_core::metadata::Metadata::new("visit_item_id_use_tree",
                                    "rustc_ast_lowering", ::tracing::Level::TRACE,
                                    ::tracing_core::__macro_support::Option::Some("/rustc-dev/923c95cdf5ba65cea505aa2ea829f578e1506ed8/compiler/rustc_ast_lowering/src/lib.rs"),
                                    ::tracing_core::__macro_support::Option::Some(666u32),
                                    ::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("tree")
                                                            }> =
                                                            ::tracing::__macro_support::FieldName::new("tree");
                                                        NAME.as_str()
                                                    },
                                                    {
                                                        const NAME:
                                                            ::tracing::__macro_support::FieldName<{
                                                                ::tracing::__macro_support::FieldName::len("parent")
                                                            }> =
                                                            ::tracing::__macro_support::FieldName::new("parent");
                                                        NAME.as_str()
                                                    },
                                                    {
                                                        const NAME:
                                                            ::tracing::__macro_support::FieldName<{
                                                                ::tracing::__macro_support::FieldName::len("items")
                                                            }> =
                                                            ::tracing::__macro_support::FieldName::new("items");
                                                        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(&tree)
                                                            as &dyn ::tracing::field::Value)),
                                                (::tracing::__macro_support::Option::Some(&::tracing::field::debug(&parent)
                                                            as &dyn ::tracing::field::Value)),
                                                (::tracing::__macro_support::Option::Some(&::tracing::field::debug(&items)
                                                            as &dyn ::tracing::field::Value))])
                            })
                } else {
                    let span =
                        ::tracing::__macro_support::__disabled_span(__CALLSITE.metadata());
                    {};
                    span
                }
            };
        __tracing_attr_guard = __tracing_attr_span.enter();
    }

    #[warn(clippy :: suspicious_else_formatting)]
    {

        #[allow(unknown_lints, unreachable_code, clippy ::
        diverging_sub_expression, clippy :: empty_loop, clippy ::
        let_unit_value, clippy :: let_with_type_underscore, clippy ::
        needless_return, clippy :: unreachable)]
        if false {
            let __tracing_attr_fake_return: () = loop {};
            return __tracing_attr_fake_return;
        }
        {
            match tree.kind {
                UseTreeKind::Glob(_) | UseTreeKind::Simple(_) => {}
                UseTreeKind::Nested { items: ref nested_vec, span } => {
                    for nested in nested_vec {
                        let id = nested.id;
                        self.insert(id, AstOwner::NestedUseTree(parent));
                        items.push(self.make_dummy(id, span, ItemKind::MacCall));
                        let def_id = self.owners[&id].def_id;
                        self.visit_item_id_use_tree(&nested.inner, def_id, items);
                    }
                }
            }
        }
    }
}#[tracing::instrument(level = "trace", skip(self))]
667        fn visit_item_id_use_tree(
668            &mut self,
669            tree: &UseTree,
670            parent: LocalDefId,
671            items: &mut SmallVec<[Box<Item>; 1]>,
672        ) {
673            match tree.kind {
674                UseTreeKind::Glob(_) | UseTreeKind::Simple(_) => {}
675                UseTreeKind::Nested { items: ref nested_vec, span } => {
676                    for nested in nested_vec {
677                        let id = nested.id;
678                        self.insert(id, AstOwner::NestedUseTree(parent));
679                        items.push(self.make_dummy(id, span, ItemKind::MacCall));
680
681                        let def_id = self.owners[&id].def_id;
682                        self.visit_item_id_use_tree(&nested.inner, def_id, items);
683                    }
684                }
685            }
686        }
687    }
688
689    impl MutVisitor for Indexer<'_, '_> {
690        fn visit_attribute(&mut self, _: &mut Attribute) {
691            // We do not want to lower expressions that appear in attributes,
692            // as they are not accessible to the rest of the HIR.
693        }
694
695        fn flat_map_item(&mut self, mut item: Box<Item>) -> SmallVec<[Box<Item>; 1]> {
696            let def_id = self.owners[&item.id].def_id;
697            mut_visit::walk_item(self, &mut *item);
698            let dummy = self.make_dummy(item.id, item.span, ItemKind::MacCall);
699            let mut items = {
    let count = 0usize + 1usize;
    let mut vec = ::smallvec::SmallVec::new();
    if count <= vec.inline_size() {
        vec.push(dummy);
        vec
    } else {
        ::smallvec::SmallVec::from_vec(::alloc::boxed::box_assume_init_into_vec_unsafe(::alloc::intrinsics::write_box_via_move(::alloc::boxed::Box::new_uninit(),
                    [dummy])))
    }
}smallvec![dummy];
700            if let ItemKind::Use(ref use_tree) = item.kind {
701                self.visit_item_id_use_tree(use_tree, def_id, &mut items);
702            }
703            self.insert(item.id, AstOwner::Item(item));
704            items
705        }
706
707        fn flat_map_stmt(&mut self, stmt: Stmt) -> SmallVec<[Stmt; 1]> {
708            let Stmt { id, span, kind } = stmt;
709            let mut id = Some(id);
710            mut_visit::walk_flat_map_stmt_kind(self, kind)
711                .into_iter()
712                .map(|kind| {
713                    // Expanding the current statement is a nested `use` item,
714                    // it is expanded into several flat `use` items.
715                    // Create new NodeIds for the corresponding statements
716                    // as two statements cannot have the same.
717                    let id = id.take().unwrap_or_else(|| {
718                        let next = self.next_node_id;
719                        self.next_node_id.increment_by(1);
720                        next
721                    });
722                    Stmt { id, kind, span }
723                })
724                .collect()
725        }
726
727        fn visit_assoc_item(&mut self, item: &mut AssocItem, ctxt: visit::AssocCtxt) {
728            mut_visit::walk_assoc_item(self, item, ctxt);
729            match ctxt {
730                visit::AssocCtxt::Trait => {
731                    self.replace_with_dummy(item, AssocItemKind::MacCall, AstOwner::TraitItem)
732                }
733                visit::AssocCtxt::Impl { .. } => {
734                    self.replace_with_dummy(item, AssocItemKind::MacCall, AstOwner::ImplItem)
735                }
736            }
737        }
738
739        fn visit_foreign_item(&mut self, item: &mut ForeignItem) {
740            mut_visit::walk_item(self, item);
741            self.replace_with_dummy(item, ForeignItemKind::MacCall, AstOwner::ForeignItem);
742        }
743    }
744}
745
746{}
#[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/923c95cdf5ba65cea505aa2ea829f578e1506ed8/compiler/rustc_ast_lowering/src/lib.rs"),
                                    ::tracing_core::__macro_support::Option::Some(746u32),
                                    ::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 =
                |parent_id|
                    {
                        let mut parent_info = tcx.lower_to_hir(parent_id);
                        if let hir::MaybeOwner::NonOwner(hir_id) = parent_info {
                            parent_info = tcx.lower_to_hir(hir_id.owner);
                        }
                        let parent_info = parent_info.unwrap();
                        *parent_info.children.get(&def_id).unwrap_or_else(||
                                    {
                                        {
                                            ::core::panicking::panic_fmt(format_args!("{0:?} does not appear in children of {1:?}",
                                                    def_id, parent_info.nodes.node().def_id()));
                                        }
                                    })
                    };
            let Some((resolver, node)) =
                resolver_and_node else {
                    return fallback_to_ancestor(tcx.local_parent(def_id));
                };
            let mut item_lowerer =
                item::ItemLowerer { tcx, resolver: &*resolver };
            let item =
                match &node {
                    AstOwner::Crate(c) => item_lowerer.lower_crate(&c),
                    AstOwner::Item(item) => item_lowerer.lower_item(&item),
                    AstOwner::TraitItem(item) =>
                        item_lowerer.lower_trait_item(&item),
                    AstOwner::ImplItem(item) =>
                        item_lowerer.lower_impl_item(&item),
                    AstOwner::ForeignItem(item) =>
                        item_lowerer.lower_foreign_item(&item),
                    AstOwner::NestedUseTree(owner_id) =>
                        fallback_to_ancestor(*owner_id),
                    AstOwner::NonOwner =>
                        fallback_to_ancestor(tcx.local_parent(def_id)),
                };
            tcx.sess.time("drop_ast", || mem::drop(node));
            item
        }
    }
}#[instrument(level = "trace", skip(tcx))]
747fn lower_to_hir(tcx: TyCtxt<'_>, def_id: LocalDefId) -> hir::MaybeOwner<'_> {
748    tcx.ensure_done().resolve_type_relative_delegations(());
749
750    let ast_index = tcx.index_ast(());
751    let resolver_and_node = ast_index.get(def_id).map(Steal::steal);
752
753    let fallback_to_ancestor = |parent_id| {
754        // The item did not exist in the AST, it was created while lowering another item.
755        // `parent_id` may be different from the direct parent of `def_id`,
756        // for instance use-trees are lowered by the first sibling.
757        let mut parent_info = tcx.lower_to_hir(parent_id);
758        if let hir::MaybeOwner::NonOwner(hir_id) = parent_info {
759            // `parent_id` could also not be a owner either.
760            // For instance if `def_id` is an enum variant field,
761            // the direct parent is the enum variant.
762            // In that case `hir_id.owner` point to the actual HIR owner
763            // and skips all non-owner parents, so fetch the HIR associated to it.
764            parent_info = tcx.lower_to_hir(hir_id.owner);
765        }
766
767        let parent_info = parent_info.unwrap();
768        *parent_info.children.get(&def_id).unwrap_or_else(|| {
769            panic!(
770                "{:?} does not appear in children of {:?}",
771                def_id,
772                parent_info.nodes.node().def_id()
773            )
774        })
775    };
776
777    let Some((resolver, node)) = resolver_and_node else {
778        // `ast_index` does not contain all definitions, only up-to the highest
779        // `LocalDefId` which has a non-trivial `AstOwner`. Gracefully handle
780        // other definitions, in particular those nested inside this highest definition.
781        return fallback_to_ancestor(tcx.local_parent(def_id));
782    };
783
784    let mut item_lowerer = item::ItemLowerer { tcx, resolver: &*resolver };
785
786    let item = match &node {
787        // The item existed in the AST.
788        AstOwner::Crate(c) => item_lowerer.lower_crate(&c),
789        AstOwner::Item(item) => item_lowerer.lower_item(&item),
790        AstOwner::TraitItem(item) => item_lowerer.lower_trait_item(&item),
791        AstOwner::ImplItem(item) => item_lowerer.lower_impl_item(&item),
792        AstOwner::ForeignItem(item) => item_lowerer.lower_foreign_item(&item),
793        AstOwner::NestedUseTree(owner_id) => fallback_to_ancestor(*owner_id),
794        // The item existed in the AST, but is not a HIR owner.
795        // Fetch the correct information from its parent.
796        AstOwner::NonOwner => fallback_to_ancestor(tcx.local_parent(def_id)),
797    };
798
799    tcx.sess.time("drop_ast", || mem::drop(node));
800
801    item
802}
803
804#[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) -> ParamMode { *self }
}Clone, #[automatically_derived]
impl ::core::marker::StructuralPartialEq for ParamMode { }
#[automatically_derived]
impl ::core::cmp::PartialEq for ParamMode {
    #[inline]
    fn eq(&self, other: &ParamMode) -> bool {
        let __self_discr = ::core::intrinsics::discriminant_value(self);
        let __arg1_discr = ::core::intrinsics::discriminant_value(other);
        __self_discr == __arg1_discr
    }
}PartialEq, #[automatically_derived]
impl ::core::fmt::Debug for ParamMode {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::write_str(f,
            match self {
                ParamMode::Explicit => "Explicit",
                ParamMode::Optional => "Optional",
            })
    }
}Debug)]
805enum ParamMode {
806    /// Any path in a type context.
807    Explicit,
808    /// The `module::Type` in `module::Type::method` in an expression.
809    Optional,
810}
811
812#[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) -> AllowReturnTypeNotation { *self }
}Clone, #[automatically_derived]
impl ::core::fmt::Debug for AllowReturnTypeNotation {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::write_str(f,
            match self {
                AllowReturnTypeNotation::Yes => "Yes",
                AllowReturnTypeNotation::No => "No",
            })
    }
}Debug)]
813enum AllowReturnTypeNotation {
814    /// Only in types, since RTN is denied later during HIR lowering.
815    Yes,
816    /// All other positions (path expr, method, use tree).
817    No,
818}
819
820enum GenericArgsMode {
821    /// Allow paren sugar, don't allow RTN.
822    ParenSugar,
823    /// Allow RTN, don't allow paren sugar.
824    ReturnTypeNotation,
825    // Error if parenthesized generics or RTN are encountered.
826    Err,
827    /// Silence errors when lowering generics. Only used with `Res::Err`.
828    Silence,
829}
830
831impl<'hir> LoweringContext<'_, 'hir> {
832    fn create_def(
833        &mut self,
834        node_id: NodeId,
835        name: Option<Symbol>,
836        def_kind: DefKind,
837        span: Span,
838    ) -> LocalDefId {
839        let parent = self.curr_owner.owner_id.def_id;
840        {
    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);
841        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!(
842            self.opt_local_def_id(node_id).is_none(),
843            "adding a def'n for node-id {:?} and def kind {:?} but a previous def'n exists: {:?}",
844            node_id,
845            def_kind,
846            self.tcx.hir_def_key(self.local_def_id(node_id)),
847        );
848
849        let def_id = self
850            .tcx
851            .at(span)
852            .create_def(parent, name, def_kind, None, &mut self.curr_owner.disambiguator)
853            .def_id();
854
855        {
    use ::tracing::__macro_support::Callsite as _;
    static __CALLSITE: ::tracing::callsite::DefaultCallsite =
        {
            static META: ::tracing::Metadata<'static> =
                {
                    ::tracing_core::metadata::Metadata::new("event /rustc-dev/923c95cdf5ba65cea505aa2ea829f578e1506ed8/compiler/rustc_ast_lowering/src/lib.rs:855",
                        "rustc_ast_lowering", ::tracing::Level::DEBUG,
                        ::tracing_core::__macro_support::Option::Some("/rustc-dev/923c95cdf5ba65cea505aa2ea829f578e1506ed8/compiler/rustc_ast_lowering/src/lib.rs"),
                        ::tracing_core::__macro_support::Option::Some(855u32),
                        ::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);
856        self.node_id_to_def_id.insert(node_id, def_id);
857
858        def_id
859    }
860
861    fn next_node_id(&mut self) -> NodeId {
862        let start = self.next_node_id;
863        let next = start.as_u32().checked_add(1).expect("input too large; ran out of NodeIds");
864        self.next_node_id = NodeId::from_u32(next);
865        start
866    }
867
868    /// Given the id of some node in the AST, finds the `LocalDefId` associated with it by the name
869    /// resolver (if any).
870    {}
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/923c95cdf5ba65cea505aa2ea829f578e1506ed8/compiler/rustc_ast_lowering/src/lib.rs"),
                                ::tracing_core::__macro_support::Option::Some(870u32),
                                ::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/923c95cdf5ba65cea505aa2ea829f578e1506ed8/compiler/rustc_ast_lowering/src/lib.rs:870",
                        "rustc_ast_lowering", ::tracing::Level::TRACE,
                        ::tracing_core::__macro_support::Option::Some("/rustc-dev/923c95cdf5ba65cea505aa2ea829f578e1506ed8/compiler/rustc_ast_lowering/src/lib.rs"),
                        ::tracing_core::__macro_support::Option::Some(870u32),
                        ::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)]
871    fn opt_local_def_id(&self, node: NodeId) -> Option<LocalDefId> {
872        self.node_id_to_def_id
873            .get(&node)
874            .or_else(|| self.curr_owner.owner.node_id_to_def_id.get(&node))
875            .copied()
876    }
877
878    fn local_def_id(&self, node: NodeId) -> LocalDefId {
879        self.opt_local_def_id(node).unwrap_or_else(|| {
880            self.resolver.owners.items().any(|(id, items)| {
881                items.node_id_to_def_id.items().any(|(node_id, def_id)| {
882                    if *node_id == node {
883                        let actual_owner = items.node_id_to_def_id.get(id);
884                        {
    ::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})",)
885                    }
886                    false
887                })
888            });
889            {
    ::core::panicking::panic_fmt(format_args!("no entry for node id: `{0:?}`",
            node));
};panic!("no entry for node id: `{node:?}`");
890        })
891    }
892
893    fn get_partial_res(&self, id: NodeId) -> Option<PartialRes> {
894        match self.partial_res_overrides.get(&id) {
895            Some(self_param_id) => Some(PartialRes::new(Res::Local(*self_param_id))),
896            None => self.resolver.partial_res_map.get(&id).copied(),
897        }
898    }
899
900    /// Given the id of an owner node in the AST, returns the corresponding `OwnerId`.
901    fn owner_id(&self, node: NodeId) -> hir::OwnerId {
902        hir::OwnerId { def_id: self.resolver.owners[&node].def_id }
903    }
904
905    /// Freshen the `LoweringContext` and ready it to lower a nested item.
906    /// The lowered item is registered into `self.curr_owner.children`.
907    ///
908    /// This function sets up `HirId` lowering infrastructure,
909    /// and stashes the per-owner state to avoid pollution by the closure.
910    {}
#[allow(clippy :: suspicious_else_formatting)]
{
    let __tracing_attr_span;
    let __tracing_attr_guard;
    if ::tracing::Level::DEBUG <= ::tracing::level_filters::STATIC_MAX_LEVEL
                &&
                ::tracing::Level::DEBUG <=
                    ::tracing::level_filters::LevelFilter::current() ||
            { false } {
        __tracing_attr_span =
            {
                use ::tracing::__macro_support::Callsite as _;
                static __CALLSITE: ::tracing::callsite::DefaultCallsite =
                    {
                        static META: ::tracing::Metadata<'static> =
                            {
                                ::tracing_core::metadata::Metadata::new("with_hir_id_owner",
                                    "rustc_ast_lowering", ::tracing::Level::DEBUG,
                                    ::tracing_core::__macro_support::Option::Some("/rustc-dev/923c95cdf5ba65cea505aa2ea829f578e1506ed8/compiler/rustc_ast_lowering/src/lib.rs"),
                                    ::tracing_core::__macro_support::Option::Some(910u32),
                                    ::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("owner")
                                                            }> =
                                                            ::tracing::__macro_support::FieldName::new("owner");
                                                        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(&owner)
                                                            as &dyn ::tracing::field::Value))])
                            })
                } else {
                    let span =
                        ::tracing::__macro_support::__disabled_span(__CALLSITE.metadata());
                    {};
                    span
                }
            };
        __tracing_attr_guard = __tracing_attr_span.enter();
    }

    #[warn(clippy :: suspicious_else_formatting)]
    {

        #[allow(unknown_lints, unreachable_code, clippy ::
        diverging_sub_expression, clippy :: empty_loop, clippy ::
        let_unit_value, clippy :: let_with_type_underscore, clippy ::
        needless_return, clippy :: unreachable)]
        if false {
            let __tracing_attr_fake_return: () = loop {};
            return __tracing_attr_fake_return;
        }
        {
            let child_owner =
                PerOwnerLoweringState::new(self.resolver, owner);
            let parent_owner =
                mem::replace(&mut self.curr_owner, child_owner);
            self.curr_owner.relowering_checker.assert_node_is_not_relowered(owner,
                hir::ItemLocalId::ZERO);
            let item = f(self);
            let completed_child_owner =
                mem::replace(&mut self.curr_owner, parent_owner);
            let owner_id = completed_child_owner.owner_id;
            let info = completed_child_owner.into_owner_info(self.tcx, item);
            self.curr_owner.children.extend_unord(info.children.items().map(|(&def_id,
                            &info)| (def_id, info)));
            if true {
                if !!self.curr_owner.children.contains_key(&owner_id.def_id) {
                    ::core::panicking::panic("assertion failed: !self.curr_owner.children.contains_key(&owner_id.def_id)")
                };
            };
            self.curr_owner.children.insert(owner_id.def_id,
                hir::MaybeOwner::Owner(info));
        }
    }
}#[instrument(level = "debug", skip(self, f))]
911    fn with_hir_id_owner(
912        &mut self,
913        owner: NodeId,
914        f: impl FnOnce(&mut Self) -> hir::OwnerNode<'hir>,
915    ) {
916        let child_owner = PerOwnerLoweringState::new(self.resolver, owner);
917        let parent_owner = mem::replace(&mut self.curr_owner, child_owner);
918
919        // Do not reset `next_node_id` and `node_id_to_def_id`:
920        // we want `f` to be able to refer to the `LocalDefId`s that the caller created.
921        // and the caller to refer to some of the subdefinitions' nodes' `LocalDefId`s.
922
923        // Always allocate the first `HirId` for the owner itself.
924        #[cfg(debug_assertions)]
925        self.curr_owner
926            .relowering_checker
927            .assert_node_is_not_relowered(owner, hir::ItemLocalId::ZERO);
928
929        let item = f(self);
930        let completed_child_owner = mem::replace(&mut self.curr_owner, parent_owner);
931        let owner_id = completed_child_owner.owner_id;
932        let info = completed_child_owner.into_owner_info(self.tcx, item);
933
934        self.curr_owner
935            .children
936            .extend_unord(info.children.items().map(|(&def_id, &info)| (def_id, info)));
937
938        debug_assert!(!self.curr_owner.children.contains_key(&owner_id.def_id));
939        self.curr_owner.children.insert(owner_id.def_id, hir::MaybeOwner::Owner(info));
940    }
941
942    /// This method allocates a new `HirId` for the given `NodeId`.
943    /// Take care not to call this method if the resulting `HirId` is then not
944    /// actually used in the HIR, as that would trigger an assertion in the
945    /// `HirIdValidator` later on, which makes sure that all `NodeId`s got mapped
946    /// properly. Calling the method twice with the same `NodeId` is also forbidden.
947    {}
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/923c95cdf5ba65cea505aa2ea829f578e1506ed8/compiler/rustc_ast_lowering/src/lib.rs"),
                                ::tracing_core::__macro_support::Option::Some(947u32),
                                ::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/923c95cdf5ba65cea505aa2ea829f578e1506ed8/compiler/rustc_ast_lowering/src/lib.rs:947",
                        "rustc_ast_lowering", ::tracing::Level::DEBUG,
                        ::tracing_core::__macro_support::Option::Some("/rustc-dev/923c95cdf5ba65cea505aa2ea829f578e1506ed8/compiler/rustc_ast_lowering/src/lib.rs"),
                        ::tracing_core::__macro_support::Option::Some(947u32),
                        ::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)]
948    fn lower_node_id(&mut self, ast_node_id: NodeId) -> HirId {
949        assert_ne!(ast_node_id, DUMMY_NODE_ID);
950
951        let owner = self.curr_owner.owner_id;
952        let local_id = self.curr_owner.item_local_id_counter;
953        assert_ne!(local_id, hir::ItemLocalId::ZERO);
954        self.curr_owner.item_local_id_counter.increment_by(1);
955        let hir_id = HirId { owner, local_id };
956
957        if let Some(def_id) = self.opt_local_def_id(ast_node_id) {
958            self.curr_owner.children.insert(def_id, hir::MaybeOwner::NonOwner(hir_id));
959        }
960
961        if let Some(traits) = self.curr_owner.owner.trait_map.get(&ast_node_id) {
962            self.curr_owner.trait_map.insert(hir_id.local_id, *traits);
963        }
964
965        // Check whether the same `NodeId` is lowered more than once.
966        #[cfg(debug_assertions)]
967        self.curr_owner.relowering_checker.assert_node_is_not_relowered(ast_node_id, local_id);
968
969        hir_id
970    }
971
972    /// Generate a new `HirId` without a backing `NodeId`.
973    {}
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/923c95cdf5ba65cea505aa2ea829f578e1506ed8/compiler/rustc_ast_lowering/src/lib.rs"),
                                ::tracing_core::__macro_support::Option::Some(973u32),
                                ::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/923c95cdf5ba65cea505aa2ea829f578e1506ed8/compiler/rustc_ast_lowering/src/lib.rs:973",
                        "rustc_ast_lowering", ::tracing::Level::DEBUG,
                        ::tracing_core::__macro_support::Option::Some("/rustc-dev/923c95cdf5ba65cea505aa2ea829f578e1506ed8/compiler/rustc_ast_lowering/src/lib.rs"),
                        ::tracing_core::__macro_support::Option::Some(973u32),
                        ::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)]
974    fn next_id(&mut self) -> HirId {
975        let owner = self.curr_owner.owner_id;
976        let local_id = self.curr_owner.item_local_id_counter;
977        assert_ne!(local_id, hir::ItemLocalId::ZERO);
978        self.curr_owner.item_local_id_counter.increment_by(1);
979        HirId { owner, local_id }
980    }
981
982    {}
#[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/923c95cdf5ba65cea505aa2ea829f578e1506ed8/compiler/rustc_ast_lowering/src/lib.rs"),
                                    ::tracing_core::__macro_support::Option::Some(982u32),
                                    ::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/923c95cdf5ba65cea505aa2ea829f578e1506ed8/compiler/rustc_ast_lowering/src/lib.rs:990",
                                    "rustc_ast_lowering", ::tracing::Level::TRACE,
                                    ::tracing_core::__macro_support::Option::Some("/rustc-dev/923c95cdf5ba65cea505aa2ea829f578e1506ed8/compiler/rustc_ast_lowering/src/lib.rs"),
                                    ::tracing_core::__macro_support::Option::Some(990u32),
                                    ::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))]
983    fn lower_res(&mut self, res: Res<NodeId>) -> Res {
984        let res: Result<Res, ()> = res.apply_id(|id| {
985            let owner = self.curr_owner.owner_id;
986            let local_id =
987                self.curr_owner.ident_and_label_to_local_id.get(&id).copied().ok_or(())?;
988            Ok(HirId { owner, local_id })
989        });
990        trace!(?res);
991
992        // We may fail to find a HirId when the Res points to a Local from an enclosing HIR owner.
993        // This can happen when trying to lower the return type `x` in erroneous code like
994        //   async fn foo(x: u8) -> x {}
995        // In that case, `x` is lowered as a function parameter, and the return type is lowered as
996        // an opaque type as a synthesized HIR owner.
997        res.unwrap_or(Res::Err)
998    }
999
1000    fn expect_full_res(&mut self, id: NodeId) -> Res<NodeId> {
1001        self.get_partial_res(id).map_or(Res::Err, |pr| pr.expect_full_res())
1002    }
1003
1004    fn lower_import_res(&mut self, id: NodeId, span: Span) -> PerNS<Option<Res>> {
1005        if true {
    {
        match (&id, &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);
                }
            }
        }
    };
};debug_assert_eq!(id, self.curr_owner.owner.id);
1006        let per_ns = self.curr_owner.owner.import_res.map(|res| res.map(|res| self.lower_res(res)));
1007        if per_ns.is_empty() {
1008            // Propagate the error to all namespaces, just to be sure.
1009            self.dcx().span_delayed_bug(span, "no resolution for an import");
1010            let err = Some(Res::Err);
1011            return PerNS { type_ns: err, value_ns: err, macro_ns: err };
1012        }
1013        per_ns
1014    }
1015
1016    fn make_lang_item_qpath(
1017        &mut self,
1018        lang_item: LangItem,
1019        span: Span,
1020        args: Option<&'hir hir::GenericArgs<'hir>>,
1021    ) -> hir::QPath<'hir> {
1022        hir::QPath::Resolved(None, self.make_lang_item_path(lang_item, span, args))
1023    }
1024
1025    fn make_lang_item_path(
1026        &mut self,
1027        lang_item: LangItem,
1028        span: Span,
1029        args: Option<&'hir hir::GenericArgs<'hir>>,
1030    ) -> &'hir hir::Path<'hir> {
1031        let def_id = self.tcx.require_lang_item(lang_item, span);
1032        let def_kind = self.tcx.def_kind(def_id);
1033        let res = Res::Def(def_kind, def_id);
1034        self.arena.alloc(hir::Path {
1035            span,
1036            res,
1037            segments: self.arena.alloc_from_iter([hir::PathSegment {
1038                ident: Ident::new(lang_item.name(), span),
1039                hir_id: self.next_id(),
1040                res,
1041                args,
1042                infer_args: args.is_none(),
1043                delegation_child_segment: false,
1044            }]),
1045        })
1046    }
1047
1048    /// Reuses the span but adds information like the kind of the desugaring and features that are
1049    /// allowed inside this span.
1050    fn mark_span_with_reason(
1051        &self,
1052        reason: DesugaringKind,
1053        span: Span,
1054        allow_internal_unstable: Option<Arc<[Symbol]>>,
1055    ) -> Span {
1056        self.tcx.with_stable_hashing_context(|hcx| {
1057            span.mark_with_reason(allow_internal_unstable, reason, span.edition(), hcx)
1058        })
1059    }
1060
1061    fn span_lowerer(&self) -> SpanLowerer {
1062        SpanLowerer {
1063            is_incremental: self.tcx.sess.opts.incremental.is_some(),
1064            def_id: self.curr_owner.owner_id.def_id,
1065        }
1066    }
1067
1068    /// Intercept all spans entering HIR.
1069    /// Mark a span as relative to the current owning item.
1070    fn lower_span(&self, span: Span) -> Span {
1071        self.span_lowerer().lower(span)
1072    }
1073
1074    fn lower_ident(&self, ident: Ident) -> Ident {
1075        Ident::new(ident.name, self.lower_span(ident.span))
1076    }
1077
1078    /// Converts a lifetime into a new generic parameter.
1079    {}
#[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/923c95cdf5ba65cea505aa2ea829f578e1506ed8/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("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/923c95cdf5ba65cea505aa2ea829f578e1506ed8/compiler/rustc_ast_lowering/src/lib.rs:1094",
                                    "rustc_ast_lowering", ::tracing::Level::DEBUG,
                                    ::tracing_core::__macro_support::Option::Some("/rustc-dev/923c95cdf5ba65cea505aa2ea829f578e1506ed8/compiler/rustc_ast_lowering/src/lib.rs"),
                                    ::tracing_core::__macro_support::Option::Some(1094u32),
                                    ::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))]
1080    fn lifetime_res_to_generic_param(
1081        &mut self,
1082        ident: Ident,
1083        node_id: NodeId,
1084        kind: MissingLifetimeKind,
1085        source: hir::GenericParamSource,
1086    ) -> hir::GenericParam<'hir> {
1087        // Late resolution delegates to us the creation of the `LocalDefId`.
1088        let _def_id = self.create_def(
1089            node_id,
1090            Some(kw::UnderscoreLifetime),
1091            DefKind::LifetimeParam,
1092            ident.span,
1093        );
1094        debug!(?_def_id);
1095
1096        let hir_id = self.lower_node_id(node_id);
1097        let def_id = self.local_def_id(node_id);
1098        hir::GenericParam {
1099            hir_id,
1100            def_id,
1101            name: hir::ParamName::Fresh,
1102            span: self.lower_span(ident.span),
1103            pure_wrt_drop: false,
1104            kind: hir::GenericParamKind::Lifetime { kind: hir::LifetimeParamKind::Elided(kind) },
1105            colon_span: None,
1106            source,
1107        }
1108    }
1109
1110    /// Lowers a lifetime binder that defines `generic_params`, returning the corresponding HIR
1111    /// nodes. The returned list includes any "extra" lifetime parameters that were added by the
1112    /// name resolver owing to lifetime elision; this also populates the resolver's node-id->def-id
1113    /// map, so that later calls to `opt_node_id_to_def_id` that refer to these extra lifetime
1114    /// parameters will be successful.
1115    {}
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/923c95cdf5ba65cea505aa2ea829f578e1506ed8/compiler/rustc_ast_lowering/src/lib.rs"),
                                ::tracing_core::__macro_support::Option::Some(1115u32),
                                ::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/923c95cdf5ba65cea505aa2ea829f578e1506ed8/compiler/rustc_ast_lowering/src/lib.rs:1125",
                                                "rustc_ast_lowering", ::tracing::Level::DEBUG,
                                                ::tracing_core::__macro_support::Option::Some("/rustc-dev/923c95cdf5ba65cea505aa2ea829f578e1506ed8/compiler/rustc_ast_lowering/src/lib.rs"),
                                                ::tracing_core::__macro_support::Option::Some(1125u32),
                                                ::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/923c95cdf5ba65cea505aa2ea829f578e1506ed8/compiler/rustc_ast_lowering/src/lib.rs:1115",
                        "rustc_ast_lowering", ::tracing::Level::DEBUG,
                        ::tracing_core::__macro_support::Option::Some("/rustc-dev/923c95cdf5ba65cea505aa2ea829f578e1506ed8/compiler/rustc_ast_lowering/src/lib.rs"),
                        ::tracing_core::__macro_support::Option::Some(1115u32),
                        ::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)]
1116    #[inline]
1117    fn lower_lifetime_binder(
1118        &mut self,
1119        binder: NodeId,
1120        generic_params: &[GenericParam],
1121    ) -> &'hir [hir::GenericParam<'hir>] {
1122        // Start by creating params for extra lifetimes params, as this creates the definitions
1123        // that may be referred to by the AST inside `generic_params`.
1124        let extra_lifetimes = self.curr_owner.owner.extra_lifetime_params(binder);
1125        debug!(?extra_lifetimes);
1126        let extra_lifetimes: Vec<_> = extra_lifetimes
1127            .iter()
1128            .map(|&(ident, node_id, res)| {
1129                self.lifetime_res_to_generic_param(
1130                    ident,
1131                    node_id,
1132                    res,
1133                    hir::GenericParamSource::Binder,
1134                )
1135            })
1136            .collect();
1137        let arena = self.arena;
1138        let explicit_generic_params =
1139            self.lower_generic_params_mut(generic_params, hir::GenericParamSource::Binder);
1140        arena.alloc_from_iter(explicit_generic_params.chain(extra_lifetimes.into_iter()))
1141    }
1142
1143    fn with_dyn_type_scope<T>(&mut self, in_scope: bool, f: impl FnOnce(&mut Self) -> T) -> T {
1144        let was_in_dyn_type = self.is_in_dyn_type;
1145        self.is_in_dyn_type = in_scope;
1146
1147        let result = f(self);
1148
1149        self.is_in_dyn_type = was_in_dyn_type;
1150
1151        result
1152    }
1153
1154    fn with_new_scopes<T>(&mut self, scope_span: Span, f: impl FnOnce(&mut Self) -> T) -> T {
1155        let current_item = self.current_item;
1156        self.current_item = Some(scope_span);
1157
1158        let was_in_loop_condition = self.is_in_loop_condition;
1159        self.is_in_loop_condition = false;
1160
1161        let old_contract = self.contract_ensures.take();
1162
1163        let try_block_scope = mem::replace(&mut self.try_block_scope, TryBlockScope::Function);
1164        let loop_scope = self.loop_scope.take();
1165        let ret = f(self);
1166        self.try_block_scope = try_block_scope;
1167        self.loop_scope = loop_scope;
1168
1169        self.contract_ensures = old_contract;
1170
1171        self.is_in_loop_condition = was_in_loop_condition;
1172
1173        self.current_item = current_item;
1174
1175        ret
1176    }
1177
1178    fn lower_attrs(
1179        &mut self,
1180        id: HirId,
1181        attrs: &[Attribute],
1182        target_span: Span,
1183        target: Target,
1184    ) -> &'hir [hir::Attribute] {
1185        self.lower_attrs_with_extra(id, attrs, target_span, target, None, &[])
1186    }
1187
1188    fn lower_attrs_with_extra(
1189        &mut self,
1190        id: HirId,
1191        attrs: &[Attribute],
1192        target_span: Span,
1193        target: Target,
1194        target_item: Option<&ast::Item>,
1195        extra_hir_attributes: &[hir::Attribute],
1196    ) -> &'hir [hir::Attribute] {
1197        if attrs.is_empty() && extra_hir_attributes.is_empty() {
1198            &[]
1199        } else {
1200            let mut lowered_attrs =
1201                self.lower_attrs_vec(attrs, self.lower_span(target_span), id, target, target_item);
1202            lowered_attrs.extend(extra_hir_attributes.iter().cloned());
1203
1204            {
    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);
1205            let ret = self.arena.alloc_from_iter(lowered_attrs);
1206
1207            // this is possible if an item contained syntactical attribute,
1208            // but none of them parse successfully or all of them were ignored
1209            // for not being built-in attributes at all. They could be remaining
1210            // unexpanded attributes used as markers in proc-macro derives for example.
1211            // This will have emitted some diagnostics for the misparse, but will then
1212            // not emit the attribute making the list empty.
1213            if ret.is_empty() {
1214                &[]
1215            } else {
1216                self.curr_owner.attrs.insert(id.local_id, ret);
1217                ret
1218            }
1219        }
1220    }
1221
1222    fn lower_attrs_vec(
1223        &mut self,
1224        attrs: &[Attribute],
1225        target_span: Span,
1226        target_hir_id: HirId,
1227        target: Target,
1228        target_item: Option<&ast::Item>,
1229    ) -> Vec<hir::Attribute> {
1230        let l = self.span_lowerer();
1231        self.attribute_parser.parse_attribute_list(
1232            attrs,
1233            target_span,
1234            target,
1235            target_item,
1236            |s| l.lower(s),
1237            |lint_id, span, kind| {
1238                self.curr_owner.delayed_lints.push(DelayedLint {
1239                    lint_id,
1240                    id: target_hir_id,
1241                    span,
1242                    callback: Box::new(move |dcx, level, sess: &dyn std::any::Any| {
1243                        let sess = sess
1244                            .downcast_ref::<rustc_session::Session>()
1245                            .expect("expected `Session`");
1246                        (kind.0)(dcx, level, sess)
1247                    }),
1248                });
1249            },
1250        )
1251    }
1252
1253    fn alias_attrs(&mut self, id: HirId, target_id: HirId) {
1254        {
    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);
1255        {
    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);
1256        if let Some(&a) = self.curr_owner.attrs.get(&target_id.local_id) {
1257            if !!a.is_empty() {
    ::core::panicking::panic("assertion failed: !a.is_empty()")
};assert!(!a.is_empty());
1258            self.curr_owner.attrs.insert(id.local_id, a);
1259        }
1260    }
1261
1262    fn lower_delim_args(&self, args: &DelimArgs) -> DelimArgs {
1263        args.clone()
1264    }
1265
1266    /// Lower an associated item constraint.
1267    {}
#[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/923c95cdf5ba65cea505aa2ea829f578e1506ed8/compiler/rustc_ast_lowering/src/lib.rs"),
                                    ::tracing_core::__macro_support::Option::Some(1267u32),
                                    ::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/923c95cdf5ba65cea505aa2ea829f578e1506ed8/compiler/rustc_ast_lowering/src/lib.rs:1273",
                                    "rustc_ast_lowering", ::tracing::Level::DEBUG,
                                    ::tracing_core::__macro_support::Option::Some("/rustc-dev/923c95cdf5ba65cea505aa2ea829f578e1506ed8/compiler/rustc_ast_lowering/src/lib.rs"),
                                    ::tracing_core::__macro_support::Option::Some(1273u32),
                                    ::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)]
1268    fn lower_assoc_item_constraint(
1269        &mut self,
1270        constraint: &AssocItemConstraint,
1271        itctx: ImplTraitContext,
1272    ) -> hir::AssocItemConstraint<'hir> {
1273        debug!(?constraint, ?itctx);
1274        // Lower the generic arguments for the associated item.
1275        let gen_args = if let Some(gen_args) = &constraint.gen_args {
1276            let gen_args_ctor = match gen_args {
1277                GenericArgs::AngleBracketed(data) => {
1278                    self.lower_angle_bracketed_parameter_data(data, ParamMode::Explicit, itctx).0
1279                }
1280                GenericArgs::Parenthesized(data) => {
1281                    if let Some(first_char) = constraint.ident.as_str().chars().next()
1282                        && first_char.is_ascii_lowercase()
1283                    {
1284                        let err = match (&data.inputs[..], &data.output) {
1285                            ([_, ..], FnRetTy::Default(_)) => {
1286                                diagnostics::BadReturnTypeNotation::Inputs {
1287                                    span: data.inputs_span,
1288                                }
1289                            }
1290                            ([], FnRetTy::Default(_)) => {
1291                                diagnostics::BadReturnTypeNotation::NeedsDots {
1292                                    span: data.inputs_span,
1293                                }
1294                            }
1295                            // The case `T: Trait<method(..) -> Ret>` is handled in the parser.
1296                            (_, FnRetTy::Ty(ty)) => {
1297                                let span = data.inputs_span.shrink_to_hi().to(ty.span);
1298                                diagnostics::BadReturnTypeNotation::Output {
1299                                    span,
1300                                    suggestion: diagnostics::RTNSuggestion {
1301                                        output: span,
1302                                        input: data.inputs_span,
1303                                    },
1304                                }
1305                            }
1306                        };
1307                        let mut err = self.dcx().create_err(err);
1308                        if !self.tcx.features().return_type_notation()
1309                            && self.tcx.sess.is_nightly_build()
1310                        {
1311                            add_feature_diagnostics(
1312                                &mut err,
1313                                &self.tcx.sess,
1314                                sym::return_type_notation,
1315                            );
1316                        }
1317                        err.emit();
1318                        GenericArgsCtor {
1319                            args: Default::default(),
1320                            constraints: &[],
1321                            parenthesized: hir::GenericArgsParentheses::ReturnTypeNotation,
1322                            span: data.span,
1323                        }
1324                    } else {
1325                        let guar = self.emit_bad_parenthesized_trait_in_assoc_ty(data);
1326                        self.lower_angle_bracketed_parameter_data(
1327                            &data.as_angle_bracketed_args(),
1328                            ParamMode::Explicit,
1329                            ImplTraitContext::AlreadyErrored(guar),
1330                        )
1331                        .0
1332                    }
1333                }
1334                GenericArgs::ParenthesizedElided(span) => GenericArgsCtor {
1335                    args: Default::default(),
1336                    constraints: &[],
1337                    parenthesized: hir::GenericArgsParentheses::ReturnTypeNotation,
1338                    span: *span,
1339                },
1340            };
1341            gen_args_ctor.into_generic_args(self)
1342        } else {
1343            hir::GenericArgs::NONE
1344        };
1345        let kind = match &constraint.kind {
1346            AssocItemConstraintKind::Equality { term } => {
1347                let term = match term {
1348                    Term::Ty(ty) => self.lower_ty_alloc(ty, itctx).into(),
1349                    Term::Const(c) => self.lower_anon_const_to_const_arg_and_alloc(c).into(),
1350                };
1351                hir::AssocItemConstraintKind::Equality { term }
1352            }
1353            AssocItemConstraintKind::Bound { bounds } => {
1354                // Disallow ATB in dyn types
1355                if self.is_in_dyn_type {
1356                    let suggestion = match itctx {
1357                        ImplTraitContext::OpaqueTy { .. } | ImplTraitContext::Universal => {
1358                            let bound_end_span = constraint
1359                                .gen_args
1360                                .as_ref()
1361                                .map_or(constraint.ident.span, |args| args.span());
1362                            if bound_end_span.eq_ctxt(constraint.span) {
1363                                Some(self.tcx.sess.source_map().next_point(bound_end_span))
1364                            } else {
1365                                None
1366                            }
1367                        }
1368                        _ => None,
1369                    };
1370
1371                    let guar = self.dcx().emit_err(diagnostics::MisplacedAssocTyBinding {
1372                        span: constraint.span,
1373                        suggestion,
1374                    });
1375                    let err_ty =
1376                        &*self.arena.alloc(self.ty(constraint.span, hir::TyKind::Err(guar)));
1377                    hir::AssocItemConstraintKind::Equality { term: err_ty.into() }
1378                } else {
1379                    let bounds = self.lower_param_bounds(
1380                        bounds,
1381                        RelaxedBoundPolicy::Forbidden(RelaxedBoundForbiddenReason::AssocTyBounds),
1382                        itctx,
1383                    );
1384                    hir::AssocItemConstraintKind::Bound { bounds }
1385                }
1386            }
1387        };
1388
1389        hir::AssocItemConstraint {
1390            hir_id: self.lower_node_id(constraint.id),
1391            ident: self.lower_ident(constraint.ident),
1392            gen_args,
1393            kind,
1394            span: self.lower_span(constraint.span),
1395        }
1396    }
1397
1398    fn emit_bad_parenthesized_trait_in_assoc_ty(
1399        &self,
1400        data: &ParenthesizedArgs,
1401    ) -> ErrorGuaranteed {
1402        // Suggest removing empty parentheses: "Trait()" -> "Trait"
1403        let sub = if data.inputs.is_empty() {
1404            let parentheses_span =
1405                data.inputs_span.shrink_to_lo().to(data.inputs_span.shrink_to_hi());
1406            AssocTyParenthesesSub::Empty { parentheses_span }
1407        }
1408        // Suggest replacing parentheses with angle brackets `Trait(params...)` to `Trait<params...>`
1409        else {
1410            // Start of parameters to the 1st argument
1411            let open_param = data.inputs_span.shrink_to_lo().to(data
1412                .inputs
1413                .first()
1414                .unwrap()
1415                .span
1416                .shrink_to_lo());
1417            // End of last argument to end of parameters
1418            let close_param =
1419                data.inputs.last().unwrap().span.shrink_to_hi().to(data.inputs_span.shrink_to_hi());
1420            AssocTyParenthesesSub::NotEmpty { open_param, close_param }
1421        };
1422        self.dcx().emit_err(AssocTyParentheses { span: data.span, sub })
1423    }
1424
1425    {}
#[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/923c95cdf5ba65cea505aa2ea829f578e1506ed8/compiler/rustc_ast_lowering/src/lib.rs"),
                                    ::tracing_core::__macro_support::Option::Some(1425u32),
                                    ::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::DirectConstArg(expr) if
                            self.tcx.features().min_generic_const_args() => {
                            let ct =
                                match self.can_lower_expr_to_const_arg_direct(expr,
                                        DirectConstArgContext::MacrolessMinGenericConstArgs) {
                                    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))]
1426    fn lower_generic_arg(
1427        &mut self,
1428        arg: &ast::GenericArg,
1429        itctx: ImplTraitContext,
1430    ) -> hir::GenericArg<'hir> {
1431        match arg {
1432            ast::GenericArg::Lifetime(lt) => GenericArg::Lifetime(self.lower_lifetime(
1433                lt,
1434                LifetimeSource::Path { angle_brackets: hir::AngleBrackets::Full },
1435                lt.ident.into(),
1436            )),
1437            ast::GenericArg::Type(ty) => {
1438                // We cannot just match on `TyKind::Infer` as `(_)` is represented as
1439                // `TyKind::Paren(TyKind::Infer)` and should also be lowered to `GenericArg::Infer`
1440                if ty.is_maybe_parenthesised_infer() {
1441                    return GenericArg::Infer(self.arena.alloc(hir::InferArg {
1442                        hir_id: self.lower_node_id(ty.id),
1443                        span: self.lower_span(ty.span),
1444                        kind: hir::InferArgKind::TypeOrConst,
1445                    }));
1446                }
1447
1448                match &ty.kind {
1449                    // We parse const arguments as path types as we cannot distinguish them during
1450                    // parsing. We try to resolve that ambiguity by attempting resolution in both the
1451                    // type and value namespaces. If we resolved the path in the value namespace, we
1452                    // transform it into a generic const argument.
1453                    //
1454                    // Note that even under `#![feature(min_generic_const_args)]`, only plain paths
1455                    // to constants are allowed - e.g. `A::<T::ASSOC_CONST>` and
1456                    // `A::<CONST_WITH_PARAM::<2>>` are disallowed (they must be wrapped in `{ }`).
1457                    //
1458                    // FIXME: Should we be handling `(PATH_TO_CONST)`?
1459                    TyKind::Path(None, path)
1460                        if path.is_single_argless_ident()
1461                            && let Some(res) = self
1462                                .get_partial_res(ty.id)
1463                                .and_then(|partial_res| partial_res.full_res())
1464                            && !res.matches_ns(Namespace::TypeNS) =>
1465                    {
1466                        let ct =
1467                            self.lower_const_path_to_const_arg(&None, path, res, ty.id, ty.span);
1468                        let ct = self.arena.alloc(ct);
1469                        return GenericArg::Const(ct.try_as_ambig_ct().unwrap());
1470                    }
1471                    TyKind::DirectConstArg(expr)
1472                        if self.tcx.features().min_generic_const_args() =>
1473                    {
1474                        let ct = match self.can_lower_expr_to_const_arg_direct(
1475                            expr,
1476                            DirectConstArgContext::MacrolessMinGenericConstArgs,
1477                        ) {
1478                            Ok(()) => self.lower_expr_to_const_arg_direct(expr, None),
1479                            Err(e) => e.emit(self),
1480                        };
1481                        let ct = self.arena.alloc(ct);
1482                        return match ct.try_as_ambig_ct() {
1483                            Some(ct) => GenericArg::Const(ct),
1484                            None => GenericArg::Infer(self.arena.alloc(hir::InferArg {
1485                                hir_id: ct.hir_id,
1486                                span: ct.span,
1487                                kind: hir::InferArgKind::Const,
1488                            })),
1489                        };
1490                    }
1491                    _ => {}
1492                }
1493                GenericArg::Type(self.lower_ty_alloc(ty, itctx).try_as_ambig_ty().unwrap())
1494            }
1495            ast::GenericArg::Const(ct) => {
1496                let ct = self.lower_anon_const_to_const_arg_and_alloc(ct);
1497                match ct.try_as_ambig_ct() {
1498                    Some(ct) => GenericArg::Const(ct),
1499                    None => GenericArg::Infer(self.arena.alloc(hir::InferArg {
1500                        hir_id: ct.hir_id,
1501                        span: ct.span,
1502                        kind: hir::InferArgKind::Const,
1503                    })),
1504                }
1505            }
1506        }
1507    }
1508
1509    {}
#[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/923c95cdf5ba65cea505aa2ea829f578e1506ed8/compiler/rustc_ast_lowering/src/lib.rs"),
                                    ::tracing_core::__macro_support::Option::Some(1509u32),
                                    ::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))]
1510    fn lower_ty_alloc(&mut self, t: &Ty, itctx: ImplTraitContext) -> &'hir hir::Ty<'hir> {
1511        self.arena.alloc(self.lower_ty(t, itctx))
1512    }
1513
1514    fn lower_path_ty(
1515        &mut self,
1516        t: &Ty,
1517        qself: &Option<Box<QSelf>>,
1518        path: &Path,
1519        param_mode: ParamMode,
1520        itctx: ImplTraitContext,
1521    ) -> hir::Ty<'hir> {
1522        // Check whether we should interpret this as a bare trait object.
1523        // This check mirrors the one in late resolution. We only introduce this special case in
1524        // the rare occurrence we need to lower `Fresh` anonymous lifetimes.
1525        // The other cases when a qpath should be opportunistically made a trait object are handled
1526        // by `ty_path`.
1527        if qself.is_none()
1528            && let Some(partial_res) = self.get_partial_res(t.id)
1529            && let Some(Res::Def(DefKind::Trait | DefKind::TraitAlias, _)) = partial_res.full_res()
1530        {
1531            let (bounds, lifetime_bound) = self.with_dyn_type_scope(true, |this| {
1532                let bound = this.lower_poly_trait_ref(
1533                    &PolyTraitRef {
1534                        bound_generic_params: ThinVec::new(),
1535                        modifiers: TraitBoundModifiers::NONE,
1536                        trait_ref: TraitRef { path: path.clone(), ref_id: t.id },
1537                        span: t.span,
1538                        parens: ast::Parens::No,
1539                    },
1540                    RelaxedBoundPolicy::Forbidden(RelaxedBoundForbiddenReason::TraitObjectTy),
1541                    itctx,
1542                );
1543                let bounds = this.arena.alloc_from_iter([bound]);
1544                let lifetime_bound = this.elided_dyn_bound(t.span);
1545                (bounds, lifetime_bound)
1546            });
1547            let kind = hir::TyKind::TraitObject(
1548                bounds,
1549                TaggedRef::new(lifetime_bound, TraitObjectSyntax::None),
1550            );
1551            return hir::Ty { kind, span: self.lower_span(t.span), hir_id: self.next_id() };
1552        }
1553
1554        let id = self.lower_node_id(t.id);
1555        let qpath = self.lower_qpath(
1556            t.id,
1557            qself,
1558            path,
1559            param_mode,
1560            AllowReturnTypeNotation::Yes,
1561            itctx,
1562            None,
1563        );
1564        self.ty_path(id, t.span, qpath)
1565    }
1566
1567    fn ty(&mut self, span: Span, kind: hir::TyKind<'hir>) -> hir::Ty<'hir> {
1568        hir::Ty { hir_id: self.next_id(), kind, span: self.lower_span(span) }
1569    }
1570
1571    fn ty_tup(&mut self, span: Span, tys: &'hir [hir::Ty<'hir>]) -> hir::Ty<'hir> {
1572        self.ty(span, hir::TyKind::Tup(tys))
1573    }
1574
1575    fn lower_ty(&mut self, t: &Ty, itctx: ImplTraitContext) -> hir::Ty<'hir> {
1576        let kind = match &t.kind {
1577            TyKind::Infer => hir::TyKind::Infer(()),
1578            TyKind::Err(guar) => hir::TyKind::Err(*guar),
1579            TyKind::Slice(ty) => hir::TyKind::Slice(self.lower_ty_alloc(ty, itctx)),
1580            TyKind::Ptr(mt) => hir::TyKind::Ptr(self.lower_mt(mt, itctx)),
1581            TyKind::Ref(region, mt) => {
1582                let lifetime = self.lower_ty_direct_lifetime(t, *region);
1583                hir::TyKind::Ref(lifetime, self.lower_mt(mt, itctx))
1584            }
1585            TyKind::PinnedRef(region, mt) => {
1586                let lifetime = self.lower_ty_direct_lifetime(t, *region);
1587                let kind = hir::TyKind::Ref(lifetime, self.lower_mt(mt, itctx));
1588                let span = self.lower_span(t.span);
1589                let arg = hir::Ty { kind, span, hir_id: self.next_id() };
1590                let args = self.arena.alloc(hir::GenericArgs {
1591                    args: self.arena.alloc([hir::GenericArg::Type(self.arena.alloc(arg))]),
1592                    constraints: &[],
1593                    parenthesized: hir::GenericArgsParentheses::No,
1594                    span_ext: span,
1595                });
1596                let path = self.make_lang_item_qpath(LangItem::Pin, span, Some(args));
1597                hir::TyKind::Path(path)
1598            }
1599            TyKind::FnPtr(f) => {
1600                let generic_params = self.lower_lifetime_binder(t.id, &f.generic_params);
1601                hir::TyKind::FnPtr(self.arena.alloc(hir::FnPtrTy {
1602                    generic_params,
1603                    safety: self.lower_safety(f.safety, hir::Safety::Safe),
1604                    abi: self.lower_extern(f.ext),
1605                    decl: self.lower_fn_decl(&f.decl, t.id, FnDeclKind::Pointer, None),
1606                    param_idents: self.lower_fn_params_to_idents(&f.decl),
1607                }))
1608            }
1609            TyKind::UnsafeBinder(f) => {
1610                let generic_params = self.lower_lifetime_binder(t.id, &f.generic_params);
1611                hir::TyKind::UnsafeBinder(self.arena.alloc(hir::UnsafeBinderTy {
1612                    generic_params,
1613                    inner_ty: self.lower_ty_alloc(&f.inner_ty, itctx),
1614                }))
1615            }
1616            TyKind::Never => hir::TyKind::Never,
1617            TyKind::Tup(tys) => hir::TyKind::Tup(
1618                self.arena.alloc_from_iter(tys.iter().map(|ty| self.lower_ty(ty, itctx))),
1619            ),
1620            TyKind::Paren(ty) => {
1621                return self.lower_ty(ty, itctx);
1622            }
1623            TyKind::Path(qself, path) => {
1624                return self.lower_path_ty(t, qself, path, ParamMode::Explicit, itctx);
1625            }
1626            TyKind::ImplicitSelf => {
1627                let hir_id = self.next_id();
1628                let res = self.expect_full_res(t.id);
1629                let res = self.lower_res(res);
1630                hir::TyKind::Path(hir::QPath::Resolved(
1631                    None,
1632                    self.arena.alloc(hir::Path {
1633                        res,
1634                        segments: self.arena.alloc_from_iter([hir::PathSegment::new(Ident::with_dummy_span(kw::SelfUpper),
                hir_id, res)])arena_vec![self; hir::PathSegment::new(
1635                            Ident::with_dummy_span(kw::SelfUpper),
1636                            hir_id,
1637                            res
1638                        )],
1639                        span: self.lower_span(t.span),
1640                    }),
1641                ))
1642            }
1643            TyKind::Array(ty, length) => hir::TyKind::Array(
1644                self.lower_ty_alloc(ty, itctx),
1645                self.lower_array_length_to_const_arg(length),
1646            ),
1647            TyKind::TraitObject(bounds, kind) => {
1648                let mut lifetime_bound = None;
1649                let (bounds, lifetime_bound) = self.with_dyn_type_scope(true, |this| {
1650                    let bounds =
1651                        this.arena.alloc_from_iter(bounds.iter().filter_map(|bound| match bound {
1652                            // We can safely ignore constness here since AST validation
1653                            // takes care of rejecting invalid modifier combinations and
1654                            // const trait bounds in trait object types.
1655                            GenericBound::Trait(ty) => {
1656                                let trait_ref = this.lower_poly_trait_ref(
1657                                    ty,
1658                                    RelaxedBoundPolicy::Forbidden(
1659                                        RelaxedBoundForbiddenReason::TraitObjectTy,
1660                                    ),
1661                                    itctx,
1662                                );
1663                                Some(trait_ref)
1664                            }
1665                            GenericBound::Outlives(lifetime) => {
1666                                if lifetime_bound.is_none() {
1667                                    lifetime_bound = Some(this.lower_lifetime(
1668                                        lifetime,
1669                                        LifetimeSource::Other,
1670                                        lifetime.ident.into(),
1671                                    ));
1672                                }
1673                                None
1674                            }
1675                            // Ignore `use` syntax since that is not valid in objects.
1676                            GenericBound::Use(_, span) => {
1677                                this.dcx()
1678                                    .span_delayed_bug(*span, "use<> not allowed in dyn types");
1679                                None
1680                            }
1681                        }));
1682                    let lifetime_bound =
1683                        lifetime_bound.unwrap_or_else(|| this.elided_dyn_bound(t.span));
1684                    (bounds, lifetime_bound)
1685                });
1686                hir::TyKind::TraitObject(bounds, TaggedRef::new(lifetime_bound, *kind))
1687            }
1688            TyKind::ImplTrait(def_node_id, bounds) => {
1689                let span = t.span;
1690                match itctx {
1691                    ImplTraitContext::OpaqueTy { origin } => {
1692                        self.lower_opaque_impl_trait(span, origin, *def_node_id, bounds, itctx)
1693                    }
1694                    ImplTraitContext::Universal => {
1695                        if let Some(span) = bounds.iter().find_map(|bound| match *bound {
1696                            ast::GenericBound::Use(_, span) => Some(span),
1697                            _ => None,
1698                        }) {
1699                            self.tcx.dcx().emit_err(diagnostics::NoPreciseCapturesOnApit { span });
1700                        }
1701
1702                        let def_id = self.local_def_id(*def_node_id);
1703                        let name = self.tcx.item_name(def_id.to_def_id());
1704                        let ident = Ident::new(name, span);
1705                        let (param, bounds, path) = self.lower_universal_param_and_bounds(
1706                            *def_node_id,
1707                            span,
1708                            ident,
1709                            bounds,
1710                        );
1711                        self.curr_owner.impl_trait_defs.push(param);
1712                        if let Some(bounds) = bounds {
1713                            self.curr_owner.impl_trait_bounds.push(bounds);
1714                        }
1715                        path
1716                    }
1717                    ImplTraitContext::InBinding => {
1718                        hir::TyKind::TraitAscription(self.lower_param_bounds(
1719                            bounds,
1720                            RelaxedBoundPolicy::Allowed(&mut Default::default()),
1721                            itctx,
1722                        ))
1723                    }
1724                    ImplTraitContext::FeatureGated(position, feature) => {
1725                        let guar = self
1726                            .tcx
1727                            .sess
1728                            .create_feature_err(
1729                                MisplacedImplTrait {
1730                                    span: t.span,
1731                                    position: DiagArgFromDisplay(&position),
1732                                },
1733                                feature,
1734                            )
1735                            .emit();
1736                        hir::TyKind::Err(guar)
1737                    }
1738                    ImplTraitContext::Disallowed(position) => {
1739                        let guar = self.dcx().emit_err(MisplacedImplTrait {
1740                            span: t.span,
1741                            position: DiagArgFromDisplay(&position),
1742                        });
1743                        hir::TyKind::Err(guar)
1744                    }
1745                    ImplTraitContext::AlreadyErrored(guar) => {
1746                        // `GenericArgs::Parenthesized` stores its inputs as `Param`s, so the def
1747                        // collector visits `impl Trait` in a universal context and creates a
1748                        // `DefKind::TyParam`. During recovery we reinterpret these arguments as
1749                        // angle-bracketed, where lowering may otherwise expect an opaque type.
1750                        // The parenthesized syntax has already been rejected, so avoid lowering
1751                        // this `impl Trait` with the inconsistent `DefKind`.
1752                        hir::TyKind::Err(guar)
1753                    }
1754                }
1755            }
1756            TyKind::Pat(ty, pat) => {
1757                hir::TyKind::Pat(self.lower_ty_alloc(ty, itctx), self.lower_ty_pat(pat, ty.span))
1758            }
1759            TyKind::FieldOf(ty, variant, field) => hir::TyKind::FieldOf(
1760                self.lower_ty_alloc(ty, itctx),
1761                self.arena.alloc(hir::TyFieldPath {
1762                    variant: variant.map(|variant| self.lower_ident(variant)),
1763                    field: self.lower_ident(*field),
1764                }),
1765            ),
1766            TyKind::MacCall(_) => {
1767                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")
1768            }
1769            TyKind::CVarArgs => {
1770                let guar = self.dcx().span_delayed_bug(
1771                    t.span,
1772                    "`TyKind::CVarArgs` should have been handled elsewhere",
1773                );
1774                hir::TyKind::Err(guar)
1775            }
1776            TyKind::View(ty, fields) => {
1777                let ty = self.lower_ty_alloc(ty, itctx);
1778                let fields = self.arena.alloc_slice(fields);
1779                hir::TyKind::View(ty, fields)
1780            }
1781            TyKind::DirectConstArg(expr) => {
1782                let e = self.emit_bad_direct_const_arg(t.span, expr, "type");
1783                hir::TyKind::Err(e)
1784            }
1785            TyKind::Dummy => {
    ::core::panicking::panic_fmt(format_args!("`TyKind::Dummy` should never be lowered"));
}panic!("`TyKind::Dummy` should never be lowered"),
1786        };
1787
1788        hir::Ty { kind, span: self.lower_span(t.span), hir_id: self.lower_node_id(t.id) }
1789    }
1790
1791    pub(crate) fn emit_bad_direct_const_arg(
1792        &mut self,
1793        span: Span,
1794        expr: &Expr,
1795        expected: &'static str,
1796    ) -> ErrorGuaranteed {
1797        let msg = ::alloc::__export::must_use({
        ::alloc::fmt::format(format_args!("expected {0}, found `direct_const_arg!()` constant",
                expected))
    })format!("expected {expected}, found `direct_const_arg!()` constant");
1798        if expr::WillCreateDefIdsVisitor.visit_expr(expr).is_break() {
1799            // FIXME(mgca): make this non-fatal once we have a better way to handle
1800            // nested items in invalid `direct_const_arg!()` arguments.
1801            self.dcx().span_fatal(span, msg)
1802        } else {
1803            self.dcx().span_err(span, msg)
1804        }
1805    }
1806
1807    fn lower_ty_direct_lifetime(
1808        &mut self,
1809        t: &Ty,
1810        region: Option<Lifetime>,
1811    ) -> &'hir hir::Lifetime {
1812        let (region, syntax) = match region {
1813            Some(region) => (region, region.ident.into()),
1814
1815            None => {
1816                let id = if let Some(LifetimeRes::ElidedAnchor { start, end }) =
1817                    self.curr_owner.owner.get_lifetime_res(t.id)
1818                {
1819                    {
    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);
1820                    start
1821                } else {
1822                    self.next_node_id()
1823                };
1824                let span = self.tcx.sess.source_map().start_point(t.span).shrink_to_hi();
1825                let region = Lifetime { ident: Ident::new(kw::UnderscoreLifetime, span), id };
1826                (region, LifetimeSyntax::Implicit)
1827            }
1828        };
1829        self.lower_lifetime(&region, LifetimeSource::Reference, syntax)
1830    }
1831
1832    /// Lowers a `ReturnPositionOpaqueTy` (`-> impl Trait`) or a `TypeAliasesOpaqueTy` (`type F =
1833    /// impl Trait`): this creates the associated Opaque Type (TAIT) definition and then returns a
1834    /// HIR type that references the TAIT.
1835    ///
1836    /// Given a function definition like:
1837    ///
1838    /// ```rust
1839    /// use std::fmt::Debug;
1840    ///
1841    /// fn test<'a, T: Debug>(x: &'a T) -> impl Debug + 'a {
1842    ///     x
1843    /// }
1844    /// ```
1845    ///
1846    /// we will create a TAIT definition in the HIR like
1847    ///
1848    /// ```rust,ignore (pseudo-Rust)
1849    /// type TestReturn<'a, T, 'x> = impl Debug + 'x
1850    /// ```
1851    ///
1852    /// and return a type like `TestReturn<'static, T, 'a>`, so that the function looks like:
1853    ///
1854    /// ```rust,ignore (pseudo-Rust)
1855    /// fn test<'a, T: Debug>(x: &'a T) -> TestReturn<'static, T, 'a>
1856    /// ```
1857    ///
1858    /// Note the subtlety around type parameters! The new TAIT, `TestReturn`, inherits all the
1859    /// type parameters from the function `test` (this is implemented in the query layer, they aren't
1860    /// added explicitly in the HIR). But this includes all the lifetimes, and we only want to
1861    /// capture the lifetimes that are referenced in the bounds. Therefore, we add *extra* lifetime parameters
1862    /// for the lifetimes that get captured (`'x`, in our example above) and reference those.
1863    {}
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/923c95cdf5ba65cea505aa2ea829f578e1506ed8/compiler/rustc_ast_lowering/src/lib.rs"),
                                ::tracing_core::__macro_support::Option::Some(1863u32),
                                ::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/923c95cdf5ba65cea505aa2ea829f578e1506ed8/compiler/rustc_ast_lowering/src/lib.rs:1863",
                        "rustc_ast_lowering", ::tracing::Level::DEBUG,
                        ::tracing_core::__macro_support::Option::Some("/rustc-dev/923c95cdf5ba65cea505aa2ea829f578e1506ed8/compiler/rustc_ast_lowering/src/lib.rs"),
                        ::tracing_core::__macro_support::Option::Some(1863u32),
                        ::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)]
1864    fn lower_opaque_impl_trait(
1865        &mut self,
1866        span: Span,
1867        origin: hir::OpaqueTyOrigin<LocalDefId>,
1868        opaque_ty_node_id: NodeId,
1869        bounds: &GenericBounds,
1870        itctx: ImplTraitContext,
1871    ) -> hir::TyKind<'hir> {
1872        // Make sure we know that some funky desugaring has been going on here.
1873        // This is a first: there is code in other places like for loop
1874        // desugaring that explicitly states that we don't want to track that.
1875        // Not tracking it makes lints in rustc and clippy very fragile, as
1876        // frequently opened issues show.
1877        let opaque_ty_span = self.mark_span_with_reason(DesugaringKind::OpaqueTy, span, None);
1878
1879        self.lower_opaque_inner(opaque_ty_node_id, origin, opaque_ty_span, |this| {
1880            this.lower_param_bounds(
1881                bounds,
1882                RelaxedBoundPolicy::Allowed(&mut Default::default()),
1883                itctx,
1884            )
1885        })
1886    }
1887
1888    fn lower_opaque_inner(
1889        &mut self,
1890        opaque_ty_node_id: NodeId,
1891        origin: hir::OpaqueTyOrigin<LocalDefId>,
1892        opaque_ty_span: Span,
1893        lower_item_bounds: impl FnOnce(&mut Self) -> &'hir [hir::GenericBound<'hir>],
1894    ) -> hir::TyKind<'hir> {
1895        let opaque_ty_def_id = self.local_def_id(opaque_ty_node_id);
1896        let opaque_ty_hir_id = self.lower_node_id(opaque_ty_node_id);
1897        {
    use ::tracing::__macro_support::Callsite as _;
    static __CALLSITE: ::tracing::callsite::DefaultCallsite =
        {
            static META: ::tracing::Metadata<'static> =
                {
                    ::tracing_core::metadata::Metadata::new("event /rustc-dev/923c95cdf5ba65cea505aa2ea829f578e1506ed8/compiler/rustc_ast_lowering/src/lib.rs:1897",
                        "rustc_ast_lowering", ::tracing::Level::DEBUG,
                        ::tracing_core::__macro_support::Option::Some("/rustc-dev/923c95cdf5ba65cea505aa2ea829f578e1506ed8/compiler/rustc_ast_lowering/src/lib.rs"),
                        ::tracing_core::__macro_support::Option::Some(1897u32),
                        ::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);
1898
1899        let bounds = lower_item_bounds(self);
1900        let opaque_ty_def = hir::OpaqueTy {
1901            hir_id: opaque_ty_hir_id,
1902            def_id: opaque_ty_def_id,
1903            bounds,
1904            origin,
1905            span: self.lower_span(opaque_ty_span),
1906        };
1907        let opaque_ty_def = self.arena.alloc(opaque_ty_def);
1908
1909        hir::TyKind::OpaqueDef(opaque_ty_def)
1910    }
1911
1912    fn lower_precise_capturing_args(
1913        &mut self,
1914        precise_capturing_args: &[PreciseCapturingArg],
1915    ) -> &'hir [hir::PreciseCapturingArg<'hir>] {
1916        self.arena.alloc_from_iter(precise_capturing_args.iter().map(|arg| match arg {
1917            PreciseCapturingArg::Lifetime(lt) => hir::PreciseCapturingArg::Lifetime(
1918                self.lower_lifetime(lt, LifetimeSource::PreciseCapturing, lt.ident.into()),
1919            ),
1920            PreciseCapturingArg::Arg(path, id) => {
1921                let [segment] = path.segments.as_slice() else {
1922                    ::core::panicking::panic("explicit panic");panic!();
1923                };
1924                let res = self.get_partial_res(*id).map_or(Res::Err, |partial_res| {
1925                    partial_res.full_res().expect("no partial res expected for precise capture arg")
1926                });
1927                hir::PreciseCapturingArg::Param(hir::PreciseCapturingNonLifetimeArg {
1928                    hir_id: self.lower_node_id(*id),
1929                    ident: self.lower_ident(segment.ident),
1930                    res: self.lower_res(res),
1931                })
1932            }
1933        }))
1934    }
1935
1936    fn lower_fn_params_to_idents(&mut self, decl: &FnDecl) -> &'hir [Option<Ident>] {
1937        self.arena.alloc_from_iter(decl.inputs.iter().map(|param| match param.pat.kind {
1938            PatKind::Missing => None,
1939            PatKind::Ident(_, ident, _) => Some(self.lower_ident(ident)),
1940            PatKind::Wild => Some(Ident::new(kw::Underscore, self.lower_span(param.pat.span))),
1941            _ => {
1942                self.dcx().span_delayed_bug(
1943                    param.pat.span,
1944                    "non-missing/ident/wild param pat must trigger an error",
1945                );
1946                None
1947            }
1948        }))
1949    }
1950
1951    /// Lowers a function declaration.
1952    ///
1953    /// `decl`: the unlowered (AST) function declaration.
1954    ///
1955    /// `fn_node_id`: `impl Trait` arguments are lowered into generic parameters on the given
1956    /// `NodeId`.
1957    ///
1958    /// `transform_return_type`: if `Some`, applies some conversion to the return type, such as is
1959    /// needed for `async fn` and `gen fn`. See [`CoroutineKind`] for more details.
1960    {}
#[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/923c95cdf5ba65cea505aa2ea829f578e1506ed8/compiler/rustc_ast_lowering/src/lib.rs"),
                                    ::tracing_core::__macro_support::Option::Some(1960u32),
                                    ::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("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()
                                                    }], ::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(&kind)
                                                            as &dyn ::tracing::field::Value)),
                                                (::tracing::__macro_support::Option::Some(&::tracing::field::debug(&coro)
                                                            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|
                            {
                                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(_, mt) | TyKind::PinnedRef(_, mt) if
                                                        mt.ty.kind.is_implicit_self() => {
                                                        match mt.mutbl {
                                                            hir::Mutability::Not => hir::ImplicitSelfKind::RefImm,
                                                            hir::Mutability::Mut => hir::ImplicitSelfKind::RefMut,
                                                        }
                                                    }
                                                    _ => hir::ImplicitSelfKind::None,
                                                }
                                            })).set_lifetime_elision_allowed(self.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))]
1961    fn lower_fn_decl(
1962        &mut self,
1963        decl: &FnDecl,
1964        fn_node_id: NodeId,
1965        kind: FnDeclKind,
1966        coro: Option<CoroutineMarker>,
1967    ) -> &'hir hir::FnDecl<'hir> {
1968        let c_variadic = decl.c_variadic();
1969        let mut splatted = decl.splatted();
1970
1971        // Skip the `...` (`CVarArgs`) trailing arguments from the AST,
1972        // as they are not explicit in HIR/Ty function signatures.
1973        // (instead, the `c_variadic` flag is set to `true`)
1974        let mut inputs = &decl.inputs[..];
1975        if decl.c_variadic() {
1976            // Splat + variadic errors in AST validation, so just ignore one of them here.
1977            splatted = None;
1978            inputs = &inputs[..inputs.len() - 1];
1979        }
1980        let inputs = self.arena.alloc_from_iter(inputs.iter().map(|param| {
1981            let itctx = match kind {
1982                FnDeclKind::Fn | FnDeclKind::Inherent | FnDeclKind::Impl | FnDeclKind::Trait => {
1983                    ImplTraitContext::Universal
1984                }
1985                FnDeclKind::ExternFn => {
1986                    ImplTraitContext::Disallowed(ImplTraitPosition::ExternFnParam)
1987                }
1988                FnDeclKind::Closure => {
1989                    ImplTraitContext::Disallowed(ImplTraitPosition::ClosureParam)
1990                }
1991                FnDeclKind::Pointer => {
1992                    ImplTraitContext::Disallowed(ImplTraitPosition::PointerParam)
1993                }
1994            };
1995            self.lower_ty(&param.ty, itctx)
1996        }));
1997
1998        let output = match coro {
1999            Some(coro) => {
2000                let fn_def_id = self.curr_owner.owner.def_id;
2001                self.lower_coroutine_fn_ret_ty(&decl.output, fn_def_id, coro, kind)
2002            }
2003            None => match &decl.output {
2004                FnRetTy::Ty(ty) => {
2005                    let itctx = match kind {
2006                        FnDeclKind::Fn | FnDeclKind::Inherent => ImplTraitContext::OpaqueTy {
2007                            origin: hir::OpaqueTyOrigin::FnReturn {
2008                                parent: self.curr_owner.owner.def_id,
2009                                in_trait_or_impl: None,
2010                            },
2011                        },
2012                        FnDeclKind::Trait => ImplTraitContext::OpaqueTy {
2013                            origin: hir::OpaqueTyOrigin::FnReturn {
2014                                parent: self.curr_owner.owner.def_id,
2015                                in_trait_or_impl: Some(hir::RpitContext::Trait),
2016                            },
2017                        },
2018                        FnDeclKind::Impl => ImplTraitContext::OpaqueTy {
2019                            origin: hir::OpaqueTyOrigin::FnReturn {
2020                                parent: self.curr_owner.owner.def_id,
2021                                in_trait_or_impl: Some(hir::RpitContext::TraitImpl),
2022                            },
2023                        },
2024                        FnDeclKind::ExternFn => {
2025                            ImplTraitContext::Disallowed(ImplTraitPosition::ExternFnReturn)
2026                        }
2027                        FnDeclKind::Closure => {
2028                            ImplTraitContext::Disallowed(ImplTraitPosition::ClosureReturn)
2029                        }
2030                        FnDeclKind::Pointer => {
2031                            ImplTraitContext::Disallowed(ImplTraitPosition::PointerReturn)
2032                        }
2033                    };
2034                    hir::FnRetTy::Return(self.lower_ty_alloc(ty, itctx))
2035                }
2036                FnRetTy::Default(span) => hir::FnRetTy::DefaultReturn(self.lower_span(*span)),
2037            },
2038        };
2039
2040        let fn_decl_kind = hir::FnDeclFlags::default()
2041            .set_implicit_self(decl.inputs.get(0).map_or(hir::ImplicitSelfKind::None, |arg| {
2042                let is_mutable_pat = matches!(
2043                    arg.pat.kind,
2044                    PatKind::Ident(hir::BindingMode(_, Mutability::Mut), ..)
2045                );
2046
2047                match &arg.ty.kind {
2048                    TyKind::ImplicitSelf if is_mutable_pat => hir::ImplicitSelfKind::Mut,
2049                    TyKind::ImplicitSelf => hir::ImplicitSelfKind::Imm,
2050                    // Given we are only considering `ImplicitSelf` types, we needn't consider
2051                    // the case where we have a mutable pattern to a reference as that would
2052                    // no longer be an `ImplicitSelf`.
2053                    TyKind::Ref(_, mt) | TyKind::PinnedRef(_, mt)
2054                        if mt.ty.kind.is_implicit_self() =>
2055                    {
2056                        match mt.mutbl {
2057                            hir::Mutability::Not => hir::ImplicitSelfKind::RefImm,
2058                            hir::Mutability::Mut => hir::ImplicitSelfKind::RefMut,
2059                        }
2060                    }
2061                    _ => hir::ImplicitSelfKind::None,
2062                }
2063            }))
2064            .set_lifetime_elision_allowed(
2065                self.curr_owner.owner.id == fn_node_id
2066                    && self.curr_owner.owner.lifetime_elision_allowed,
2067            )
2068            .set_c_variadic(c_variadic)
2069            .set_splatted(splatted, inputs.len())
2070            .unwrap();
2071
2072        self.arena.alloc(hir::FnDecl { inputs, output, fn_decl_kind })
2073    }
2074
2075    // Transforms `-> T` for `async fn` into `-> OpaqueTy { .. }`
2076    // combined with the following definition of `OpaqueTy`:
2077    //
2078    //     type OpaqueTy<generics_from_parent_fn> = impl Future<Output = T>;
2079    //
2080    // `output`: unlowered output type (`T` in `-> T`)
2081    // `fn_node_id`: `NodeId` of the parent function (used to create child impl trait definition)
2082    // `opaque_ty_node_id`: `NodeId` of the opaque `impl Trait` type that should be created
2083    {}
#[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/923c95cdf5ba65cea505aa2ea829f578e1506ed8/compiler/rustc_ast_lowering/src/lib.rs"),
                                    ::tracing_core::__macro_support::Option::Some(2083u32),
                                    ::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(&self.allow_async_iterator)))
                    }
                };
            let opaque_ty_span =
                self.mark_span_with_reason(DesugaringKind::Async, span,
                    allowed_features);
            let in_trait_or_impl =
                match fn_kind {
                    FnDeclKind::Trait => Some(hir::RpitContext::Trait),
                    FnDeclKind::Impl => Some(hir::RpitContext::TraitImpl),
                    FnDeclKind::Fn | FnDeclKind::Inherent => None,
                    FnDeclKind::ExternFn | FnDeclKind::Closure |
                        FnDeclKind::Pointer =>
                        ::core::panicking::panic("internal error: entered unreachable code"),
                };
            let opaque_ty_ref =
                self.lower_opaque_inner(opaque_ty_node_id,
                    hir::OpaqueTyOrigin::AsyncFn {
                        parent: fn_def_id,
                        in_trait_or_impl,
                    }, opaque_ty_span,
                    |this|
                        {
                            let bound =
                                this.lower_coroutine_fn_output_type_to_bound(output, coro,
                                    opaque_ty_span,
                                    ImplTraitContext::OpaqueTy {
                                        origin: hir::OpaqueTyOrigin::FnReturn {
                                            parent: fn_def_id,
                                            in_trait_or_impl,
                                        },
                                    });
                            this.arena.alloc_from_iter([bound])
                        });
            let opaque_ty = self.ty(opaque_ty_span, opaque_ty_ref);
            hir::FnRetTy::Return(self.arena.alloc(opaque_ty))
        }
    }
}#[instrument(level = "debug", skip(self))]
2084    fn lower_coroutine_fn_ret_ty(
2085        &mut self,
2086        output: &FnRetTy,
2087        fn_def_id: LocalDefId,
2088        coro: CoroutineMarker,
2089        fn_kind: FnDeclKind,
2090    ) -> hir::FnRetTy<'hir> {
2091        let span = self.lower_span(output.span());
2092
2093        let (opaque_ty_node_id, allowed_features) = match coro.kind {
2094            CoroutineKind::Async | CoroutineKind::Gen => (coro.return_impl_trait_id, None),
2095            CoroutineKind::AsyncGen => {
2096                (coro.return_impl_trait_id, Some(Arc::clone(&self.allow_async_iterator)))
2097            }
2098        };
2099
2100        let opaque_ty_span =
2101            self.mark_span_with_reason(DesugaringKind::Async, span, allowed_features);
2102
2103        let in_trait_or_impl = match fn_kind {
2104            FnDeclKind::Trait => Some(hir::RpitContext::Trait),
2105            FnDeclKind::Impl => Some(hir::RpitContext::TraitImpl),
2106            FnDeclKind::Fn | FnDeclKind::Inherent => None,
2107            FnDeclKind::ExternFn | FnDeclKind::Closure | FnDeclKind::Pointer => unreachable!(),
2108        };
2109
2110        let opaque_ty_ref = self.lower_opaque_inner(
2111            opaque_ty_node_id,
2112            hir::OpaqueTyOrigin::AsyncFn { parent: fn_def_id, in_trait_or_impl },
2113            opaque_ty_span,
2114            |this| {
2115                let bound = this.lower_coroutine_fn_output_type_to_bound(
2116                    output,
2117                    coro,
2118                    opaque_ty_span,
2119                    ImplTraitContext::OpaqueTy {
2120                        origin: hir::OpaqueTyOrigin::FnReturn {
2121                            parent: fn_def_id,
2122                            in_trait_or_impl,
2123                        },
2124                    },
2125                );
2126                arena_vec![this; bound]
2127            },
2128        );
2129
2130        let opaque_ty = self.ty(opaque_ty_span, opaque_ty_ref);
2131        hir::FnRetTy::Return(self.arena.alloc(opaque_ty))
2132    }
2133
2134    /// Transforms `-> T` into `Future<Output = T>`.
2135    fn lower_coroutine_fn_output_type_to_bound(
2136        &mut self,
2137        output: &FnRetTy,
2138        coro: CoroutineMarker,
2139        opaque_ty_span: Span,
2140        itctx: ImplTraitContext,
2141    ) -> hir::GenericBound<'hir> {
2142        // Compute the `T` in `Future<Output = T>` from the return type.
2143        let output_ty = match output {
2144            FnRetTy::Ty(ty) => {
2145                // Not `OpaqueTyOrigin::AsyncFn`: that's only used for the
2146                // `impl Future` opaque type that `async fn` implicitly
2147                // generates.
2148                self.lower_ty_alloc(ty, itctx)
2149            }
2150            FnRetTy::Default(ret_ty_span) => self.arena.alloc(self.ty_tup(*ret_ty_span, &[])),
2151        };
2152
2153        // "<$assoc_ty_name = T>"
2154        let (assoc_ty_name, trait_lang_item) = match coro.kind {
2155            CoroutineKind::Async => (sym::Output, LangItem::Future),
2156            CoroutineKind::Gen => (sym::Item, LangItem::Iterator),
2157            CoroutineKind::AsyncGen => (sym::Item, LangItem::AsyncIterator),
2158        };
2159
2160        let bound_args = self.arena.alloc(hir::GenericArgs {
2161            args: &[],
2162            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)],
2163            parenthesized: hir::GenericArgsParentheses::No,
2164            span_ext: DUMMY_SP,
2165        });
2166
2167        hir::GenericBound::Trait(hir::PolyTraitRef {
2168            bound_generic_params: &[],
2169            modifiers: hir::TraitBoundModifiers::NONE,
2170            trait_ref: hir::TraitRef {
2171                path: self.make_lang_item_path(trait_lang_item, opaque_ty_span, Some(bound_args)),
2172                hir_ref_id: self.next_id(),
2173            },
2174            span: opaque_ty_span,
2175        })
2176    }
2177
2178    {}
#[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/923c95cdf5ba65cea505aa2ea829f578e1506ed8/compiler/rustc_ast_lowering/src/lib.rs"),
                                    ::tracing_core::__macro_support::Option::Some(2178u32),
                                    ::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))]
2179    fn lower_param_bound(
2180        &mut self,
2181        tpb: &GenericBound,
2182        rbp: RelaxedBoundPolicy<'_>,
2183        itctx: ImplTraitContext,
2184    ) -> hir::GenericBound<'hir> {
2185        match tpb {
2186            GenericBound::Trait(p) => {
2187                hir::GenericBound::Trait(self.lower_poly_trait_ref(p, rbp, itctx))
2188            }
2189            GenericBound::Outlives(lifetime) => hir::GenericBound::Outlives(self.lower_lifetime(
2190                lifetime,
2191                LifetimeSource::OutlivesBound,
2192                lifetime.ident.into(),
2193            )),
2194            GenericBound::Use(args, span) => hir::GenericBound::Use(
2195                self.lower_precise_capturing_args(args),
2196                self.lower_span(*span),
2197            ),
2198        }
2199    }
2200
2201    fn lower_lifetime(
2202        &mut self,
2203        l: &Lifetime,
2204        source: LifetimeSource,
2205        syntax: LifetimeSyntax,
2206    ) -> &'hir hir::Lifetime {
2207        self.new_named_lifetime(l.id, l.id, l.ident, source, syntax)
2208    }
2209
2210    fn lower_lifetime_hidden_in_path(
2211        &mut self,
2212        id: NodeId,
2213        span: Span,
2214        angle_brackets: AngleBrackets,
2215    ) -> &'hir hir::Lifetime {
2216        self.new_named_lifetime(
2217            id,
2218            id,
2219            Ident::new(kw::UnderscoreLifetime, span),
2220            LifetimeSource::Path { angle_brackets },
2221            LifetimeSyntax::Implicit,
2222        )
2223    }
2224
2225    {}
#[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/923c95cdf5ba65cea505aa2ea829f578e1506ed8/compiler/rustc_ast_lowering/src/lib.rs"),
                                    ::tracing_core::__macro_support::Option::Some(2225u32),
                                    ::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/923c95cdf5ba65cea505aa2ea829f578e1506ed8/compiler/rustc_ast_lowering/src/lib.rs:2259",
                                    "rustc_ast_lowering", ::tracing::Level::DEBUG,
                                    ::tracing_core::__macro_support::Option::Some("/rustc-dev/923c95cdf5ba65cea505aa2ea829f578e1506ed8/compiler/rustc_ast_lowering/src/lib.rs"),
                                    ::tracing_core::__macro_support::Option::Some(2259u32),
                                    ::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))]
2226    fn new_named_lifetime(
2227        &mut self,
2228        id: NodeId,
2229        new_id: NodeId,
2230        ident: Ident,
2231        source: LifetimeSource,
2232        syntax: LifetimeSyntax,
2233    ) -> &'hir hir::Lifetime {
2234        let res = if let Some(res) = self.curr_owner.owner.get_lifetime_res(id) {
2235            match res {
2236                LifetimeRes::Param { param, .. } => hir::LifetimeKind::Param(param),
2237                LifetimeRes::Fresh { param, .. } => {
2238                    assert_eq!(ident.name, kw::UnderscoreLifetime);
2239                    let param = self.local_def_id(param);
2240                    hir::LifetimeKind::Param(param)
2241                }
2242                LifetimeRes::Infer => {
2243                    assert_eq!(ident.name, kw::UnderscoreLifetime);
2244                    hir::LifetimeKind::Infer
2245                }
2246                LifetimeRes::Static { .. } => {
2247                    assert!(matches!(ident.name, kw::StaticLifetime | kw::UnderscoreLifetime));
2248                    hir::LifetimeKind::Static
2249                }
2250                LifetimeRes::Error(guar) => hir::LifetimeKind::Error(guar),
2251                LifetimeRes::ElidedAnchor { .. } => {
2252                    panic!("Unexpected `ElidedAnchar` {:?} at {:?}", ident, ident.span);
2253                }
2254            }
2255        } else {
2256            hir::LifetimeKind::Error(self.dcx().span_delayed_bug(ident.span, "unresolved lifetime"))
2257        };
2258
2259        debug!(?res);
2260        self.arena.alloc(hir::Lifetime::new(
2261            self.lower_node_id(new_id),
2262            self.lower_ident(ident),
2263            res,
2264            source,
2265            syntax,
2266        ))
2267    }
2268
2269    fn lower_generic_params_mut(
2270        &mut self,
2271        params: &[GenericParam],
2272        source: hir::GenericParamSource,
2273    ) -> impl Iterator<Item = hir::GenericParam<'hir>> {
2274        params.iter().map(move |param| self.lower_generic_param(param, source))
2275    }
2276
2277    fn lower_generic_params(
2278        &mut self,
2279        params: &[GenericParam],
2280        source: hir::GenericParamSource,
2281    ) -> &'hir [hir::GenericParam<'hir>] {
2282        self.arena.alloc_from_iter(self.lower_generic_params_mut(params, source))
2283    }
2284
2285    {}
#[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/923c95cdf5ba65cea505aa2ea829f578e1506ed8/compiler/rustc_ast_lowering/src/lib.rs"),
                                    ::tracing_core::__macro_support::Option::Some(2285u32),
                                    ::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))]
2286    fn lower_generic_param(
2287        &mut self,
2288        param: &GenericParam,
2289        source: hir::GenericParamSource,
2290    ) -> hir::GenericParam<'hir> {
2291        let (name, kind) = self.lower_generic_param_kind(param, source);
2292
2293        let hir_id = self.lower_node_id(param.id);
2294        let param_attrs = &param.attrs;
2295        let param_span = param.span();
2296        let param = hir::GenericParam {
2297            hir_id,
2298            def_id: self.local_def_id(param.id),
2299            name,
2300            span: self.lower_span(param.span()),
2301            pure_wrt_drop: attr::contains_name(&param.attrs, sym::may_dangle),
2302            kind,
2303            colon_span: param.colon_span.map(|s| self.lower_span(s)),
2304            source,
2305        };
2306        self.lower_attrs(hir_id, param_attrs, param_span, Target::from(&param));
2307        param
2308    }
2309
2310    fn lower_generic_param_kind(
2311        &mut self,
2312        param: &GenericParam,
2313        source: hir::GenericParamSource,
2314    ) -> (hir::ParamName, hir::GenericParamKind<'hir>) {
2315        match &param.kind {
2316            GenericParamKind::Lifetime => {
2317                // AST resolution emitted an error on those parameters, so we lower them using
2318                // `ParamName::Error`.
2319                let ident = self.lower_ident(param.ident);
2320                let param_name = if let Some(LifetimeRes::Error(..)) =
2321                    self.curr_owner.owner.get_lifetime_res(param.id)
2322                {
2323                    ParamName::Error(ident)
2324                } else {
2325                    ParamName::Plain(ident)
2326                };
2327                let kind =
2328                    hir::GenericParamKind::Lifetime { kind: hir::LifetimeParamKind::Explicit };
2329
2330                (param_name, kind)
2331            }
2332            GenericParamKind::Type { default, .. } => {
2333                // Not only do we deny type param defaults in binders but we also map them to `None`
2334                // since later compiler stages cannot handle them (and shouldn't need to be able to).
2335                let default = default
2336                    .as_ref()
2337                    .filter(|_| match source {
2338                        hir::GenericParamSource::Generics => true,
2339                        hir::GenericParamSource::Binder => {
2340                            self.dcx().emit_err(diagnostics::GenericParamDefaultInBinder {
2341                                span: param.span(),
2342                            });
2343
2344                            false
2345                        }
2346                    })
2347                    .map(|def| {
2348                        self.lower_ty_alloc(
2349                            def,
2350                            ImplTraitContext::Disallowed(ImplTraitPosition::GenericDefault),
2351                        )
2352                    });
2353
2354                let kind = hir::GenericParamKind::Type { default, synthetic: false };
2355
2356                (hir::ParamName::Plain(self.lower_ident(param.ident)), kind)
2357            }
2358            GenericParamKind::Const { ty, span: _, default } => {
2359                let ty = self.lower_ty_alloc(
2360                    ty,
2361                    ImplTraitContext::Disallowed(ImplTraitPosition::GenericDefault),
2362                );
2363
2364                // Not only do we deny const param defaults in binders but we also map them to `None`
2365                // since later compiler stages cannot handle them (and shouldn't need to be able to).
2366                let default = default
2367                    .as_ref()
2368                    .filter(|anon_const| match source {
2369                        hir::GenericParamSource::Generics => true,
2370                        hir::GenericParamSource::Binder => {
2371                            let err =
2372                                diagnostics::GenericParamDefaultInBinder { span: param.span() };
2373                            if expr::WillCreateDefIdsVisitor
2374                                .visit_expr(&anon_const.value)
2375                                .is_break()
2376                            {
2377                                // FIXME(mgca): make this non-fatal once we have a better way
2378                                // to handle nested items in anno const from binder
2379                                // Issue: https://github.com/rust-lang/rust/issues/123629
2380                                self.dcx().emit_fatal(err)
2381                            } else {
2382                                self.dcx().emit_err(err);
2383                                false
2384                            }
2385                        }
2386                    })
2387                    .map(|def| self.lower_anon_const_to_const_arg_and_alloc(def));
2388
2389                (
2390                    hir::ParamName::Plain(self.lower_ident(param.ident)),
2391                    hir::GenericParamKind::Const { ty, default },
2392                )
2393            }
2394        }
2395    }
2396
2397    fn lower_trait_ref(
2398        &mut self,
2399        modifiers: ast::TraitBoundModifiers,
2400        p: &TraitRef,
2401        itctx: ImplTraitContext,
2402    ) -> hir::TraitRef<'hir> {
2403        let path = match self.lower_qpath(
2404            p.ref_id,
2405            &None,
2406            &p.path,
2407            ParamMode::Explicit,
2408            AllowReturnTypeNotation::No,
2409            itctx,
2410            Some(modifiers),
2411        ) {
2412            hir::QPath::Resolved(None, path) => path,
2413            qpath => {
    ::core::panicking::panic_fmt(format_args!("lower_trait_ref: unexpected QPath `{0:?}`",
            qpath));
}panic!("lower_trait_ref: unexpected QPath `{qpath:?}`"),
2414        };
2415        hir::TraitRef { path, hir_ref_id: self.lower_node_id(p.ref_id) }
2416    }
2417
2418    {}
#[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/923c95cdf5ba65cea505aa2ea829f578e1506ed8/compiler/rustc_ast_lowering/src/lib.rs"),
                                    ::tracing_core::__macro_support::Option::Some(2418u32),
                                    ::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))]
2419    fn lower_poly_trait_ref(
2420        &mut self,
2421        PolyTraitRef { bound_generic_params, modifiers, trait_ref, span, parens: _ }: &PolyTraitRef,
2422        rbp: RelaxedBoundPolicy<'_>,
2423        itctx: ImplTraitContext,
2424    ) -> hir::PolyTraitRef<'hir> {
2425        let bound_generic_params =
2426            self.lower_lifetime_binder(trait_ref.ref_id, bound_generic_params);
2427        let trait_ref = self.lower_trait_ref(*modifiers, trait_ref, itctx);
2428        let modifiers = self.lower_trait_bound_modifiers(*modifiers);
2429
2430        if let ast::BoundPolarity::Maybe(_) = modifiers.polarity {
2431            self.validate_relaxed_bound(trait_ref, *span, rbp);
2432        }
2433
2434        hir::PolyTraitRef {
2435            bound_generic_params,
2436            modifiers,
2437            trait_ref,
2438            span: self.lower_span(*span),
2439        }
2440    }
2441
2442    fn validate_relaxed_bound(
2443        &self,
2444        trait_ref: hir::TraitRef<'_>,
2445        span: Span,
2446        rbp: RelaxedBoundPolicy<'_>,
2447    ) {
2448        // Even though feature `more_maybe_bounds` enables the user to relax all default bounds
2449        // other than `Sized` in a lot more positions (thereby bypassing the given policy), we don't
2450        // want to advertise it to the user (via a feature gate error) since it's super internal.
2451        //
2452        // FIXME(more_maybe_bounds): Moreover, if we actually were to add proper default traits
2453        // (like a hypothetical `Move` or `Leak`) we would want to validate the location according
2454        // to default trait elaboration in HIR ty lowering (which depends on the specific trait in
2455        // question: E.g., `?Sized` & `?Move` most likely won't be allowed in all the same places).
2456
2457        match rbp {
2458            RelaxedBoundPolicy::Allowed(dedup_map) => {
2459                // `trait_def_id` only returns `None` for errors during resolution.
2460                let Some(trait_def_id) = trait_ref.trait_def_id() else { return };
2461                let tcx = self.tcx;
2462                let err = |s| {
2463                    let name = tcx.item_name(trait_def_id);
2464                    tcx.dcx()
2465                        .struct_span_err(
2466                            ::alloc::boxed::box_assume_init_into_vec_unsafe(::alloc::intrinsics::write_box_via_move(::alloc::boxed::Box::new_uninit(),
        [span, s]))vec![span, s],
2467                            ::alloc::__export::must_use({
        ::alloc::fmt::format(format_args!("duplicate relaxed `{0}` bounds",
                name))
    })format!("duplicate relaxed `{name}` bounds"),
2468                        )
2469                        .with_code(E0203)
2470                        .emit();
2471                };
2472                dedup_map.entry(trait_def_id).and_modify(|&mut s| err(s)).or_insert(span);
2473                return;
2474            }
2475            RelaxedBoundPolicy::Forbidden(reason) => {
2476                let gate = |context, subject| {
2477                    let extended = self.tcx.features().more_maybe_bounds();
2478                    let is_sized = trait_ref
2479                        .trait_def_id()
2480                        .is_some_and(|def_id| self.tcx.is_lang_item(def_id, LangItem::Sized));
2481
2482                    if extended && !is_sized {
2483                        return;
2484                    }
2485
2486                    let prefix = if extended { "`Sized` " } else { "" };
2487                    let mut diag = self.dcx().struct_span_err(
2488                        span,
2489                        ::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}"),
2490                    );
2491                    if is_sized {
2492                        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!(
2493                            "{subject} are not implicitly bounded by `Sized`, \
2494                             so there is nothing to relax"
2495                        ));
2496                    }
2497                    diag.emit();
2498                };
2499
2500                match reason {
2501                    RelaxedBoundForbiddenReason::TraitObjectTy => {
2502                        gate("trait object types", "trait object types");
2503                        return;
2504                    }
2505                    RelaxedBoundForbiddenReason::SuperTrait => {
2506                        gate("supertrait bounds", "traits");
2507                        return;
2508                    }
2509                    RelaxedBoundForbiddenReason::TraitAlias => {
2510                        gate("trait alias bounds", "trait aliases");
2511                        return;
2512                    }
2513                    RelaxedBoundForbiddenReason::AssocTyBounds
2514                    | RelaxedBoundForbiddenReason::WhereBound => {}
2515                };
2516            }
2517        }
2518
2519        self.dcx()
2520            .struct_span_err(span, "this relaxed bound is not permitted here")
2521            .with_note(
2522                "in this context, relaxed bounds are only allowed on \
2523                 type parameters defined on the closest item",
2524            )
2525            .emit();
2526    }
2527
2528    fn lower_mt(&mut self, mt: &MutTy, itctx: ImplTraitContext) -> hir::MutTy<'hir> {
2529        hir::MutTy { ty: self.lower_ty_alloc(&mt.ty, itctx), mutbl: mt.mutbl }
2530    }
2531
2532    {}
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/923c95cdf5ba65cea505aa2ea829f578e1506ed8/compiler/rustc_ast_lowering/src/lib.rs"),
                                ::tracing_core::__macro_support::Option::Some(2532u32),
                                ::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/923c95cdf5ba65cea505aa2ea829f578e1506ed8/compiler/rustc_ast_lowering/src/lib.rs:2532",
                        "rustc_ast_lowering", ::tracing::Level::DEBUG,
                        ::tracing_core::__macro_support::Option::Some("/rustc-dev/923c95cdf5ba65cea505aa2ea829f578e1506ed8/compiler/rustc_ast_lowering/src/lib.rs"),
                        ::tracing_core::__macro_support::Option::Some(2532u32),
                        ::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)]
2533    fn lower_param_bounds(
2534        &mut self,
2535        bounds: &[GenericBound],
2536        rbp: RelaxedBoundPolicy<'_>,
2537        itctx: ImplTraitContext,
2538    ) -> hir::GenericBounds<'hir> {
2539        self.arena.alloc_from_iter(self.lower_param_bounds_mut(bounds, rbp, itctx))
2540    }
2541
2542    fn lower_param_bounds_mut(
2543        &mut self,
2544        bounds: &[GenericBound],
2545        mut rbp: RelaxedBoundPolicy<'_>,
2546        itctx: ImplTraitContext,
2547    ) -> impl Iterator<Item = hir::GenericBound<'hir>> {
2548        bounds.iter().map(move |bound| self.lower_param_bound(bound, rbp.reborrow(), itctx))
2549    }
2550
2551    {}
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/923c95cdf5ba65cea505aa2ea829f578e1506ed8/compiler/rustc_ast_lowering/src/lib.rs"),
                                ::tracing_core::__macro_support::Option::Some(2551u32),
                                ::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/923c95cdf5ba65cea505aa2ea829f578e1506ed8/compiler/rustc_ast_lowering/src/lib.rs:2551",
                        "rustc_ast_lowering", ::tracing::Level::DEBUG,
                        ::tracing_core::__macro_support::Option::Some("/rustc-dev/923c95cdf5ba65cea505aa2ea829f578e1506ed8/compiler/rustc_ast_lowering/src/lib.rs"),
                        ::tracing_core::__macro_support::Option::Some(2551u32),
                        ::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)]
2552    fn lower_universal_param_and_bounds(
2553        &mut self,
2554        node_id: NodeId,
2555        span: Span,
2556        ident: Ident,
2557        bounds: &[GenericBound],
2558    ) -> (hir::GenericParam<'hir>, Option<hir::WherePredicate<'hir>>, hir::TyKind<'hir>) {
2559        // Add a definition for the in-band `Param`.
2560        let def_id = self.local_def_id(node_id);
2561        let span = self.lower_span(span);
2562
2563        // Set the name to `impl Bound1 + Bound2`.
2564        let param = hir::GenericParam {
2565            hir_id: self.lower_node_id(node_id),
2566            def_id,
2567            name: ParamName::Plain(self.lower_ident(ident)),
2568            pure_wrt_drop: false,
2569            span,
2570            kind: hir::GenericParamKind::Type { default: None, synthetic: true },
2571            colon_span: None,
2572            source: hir::GenericParamSource::Generics,
2573        };
2574
2575        let preds = self.lower_generic_bound_predicate(
2576            ident,
2577            node_id,
2578            &GenericParamKind::Type { default: None },
2579            bounds,
2580            /* colon_span */ None,
2581            span,
2582            RelaxedBoundPolicy::Allowed(&mut Default::default()),
2583            ImplTraitContext::Universal,
2584            hir::PredicateOrigin::ImplTrait,
2585        );
2586
2587        let hir_id = self.next_id();
2588        let res = Res::Def(DefKind::TyParam, def_id.to_def_id());
2589        let ty = hir::TyKind::Path(hir::QPath::Resolved(
2590            None,
2591            self.arena.alloc(hir::Path {
2592                span,
2593                res,
2594                segments:
2595                    arena_vec![self; hir::PathSegment::new(self.lower_ident(ident), hir_id, res)],
2596            }),
2597        ));
2598
2599        (param, preds, ty)
2600    }
2601
2602    /// Lowers a block directly to an expression, presuming that it
2603    /// has no attributes and is not targeted by a `break`.
2604    fn lower_block_expr(&mut self, b: &Block) -> hir::Expr<'hir> {
2605        let block = self.lower_block(b, false);
2606        self.expr_block(block)
2607    }
2608
2609    fn lower_array_length_to_const_arg(&mut self, c: &AnonConst) -> &'hir hir::ConstArg<'hir> {
2610        // We cannot just match on `ExprKind::Underscore` as `(_)` is represented as
2611        // `ExprKind::Paren(ExprKind::Underscore)` and should also be lowered to `GenericArg::Infer`
2612        //
2613        // FIXME(macroless_generic_const_args): Handling of underscores should be moved into
2614        // lower_expr_to_const_arg_direct. It is left here as retaining compatibility of what is
2615        // currently allowed on stable gets hairy and annoying otherwise.
2616        match c.value.peel_parens().kind {
2617            ExprKind::Underscore => {
2618                let ct_kind = hir::ConstArgKind::Infer(());
2619                self.arena.alloc(hir::ConstArg {
2620                    hir_id: self.lower_node_id(c.id),
2621                    kind: ct_kind,
2622                    span: self.lower_span(c.value.span),
2623                })
2624            }
2625            _ => self.lower_anon_const_to_const_arg_and_alloc(c),
2626        }
2627    }
2628
2629    /// Used when lowering a type argument that turned out to actually be a const argument.
2630    ///
2631    /// Only use for that purpose since otherwise it will create a duplicate def.
2632    {}
#[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/923c95cdf5ba65cea505aa2ea829f578e1506ed8/compiler/rustc_ast_lowering/src/lib.rs"),
                                    ::tracing_core::__macro_support::Option::Some(2632u32),
                                    ::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))]
2633    fn lower_const_path_to_const_arg(
2634        &mut self,
2635        qself: &Option<Box<QSelf>>,
2636        path: &Path,
2637        res: Res<NodeId>,
2638        id: NodeId,
2639        span: Span,
2640    ) -> hir::ConstArg<'hir> {
2641        let context = self.ambient_direct_const_arg_context();
2642        if self.can_lower_path_to_const_arg_direct(qself, path, span, Some(res), context).is_ok() {
2643            let span = self.lower_span(span);
2644            self.lower_path_to_const_arg_direct(id, None, qself, path, span)
2645        } else {
2646            // Construct an AnonConst where the expr is the "ty"'s path.
2647            let node_id = self.next_node_id();
2648            let span = self.lower_span(span);
2649
2650            // Add a definition for the in-band const def.
2651            // We're lowering a const argument that was originally thought to be a type argument,
2652            // so the def collector didn't create the def ahead of time. That's why we have to do
2653            // it here.
2654            let def_id = self.create_def(node_id, None, DefKind::AnonConst, span);
2655            let hir_id = self.lower_node_id(node_id);
2656
2657            let path_expr = Expr {
2658                id,
2659                kind: ExprKind::Path(qself.clone(), path.clone()),
2660                span,
2661                attrs: AttrVec::new(),
2662                tokens: None,
2663            };
2664
2665            let ct = self.with_new_scopes(span, |this| {
2666                self.arena.alloc(hir::AnonConst {
2667                    def_id,
2668                    hir_id,
2669                    body: this.lower_const_body(path_expr.span, Some(&path_expr)),
2670                    span,
2671                })
2672            });
2673            hir::ConstArg {
2674                hir_id: self.next_id(),
2675                kind: hir::ConstArgKind::Anon(ct),
2676                span: self.lower_span(span),
2677            }
2678        }
2679    }
2680
2681    fn lower_const_item_rhs(
2682        &mut self,
2683        body: &Option<Box<Expr>>,
2684        span: Span,
2685    ) -> hir::ConstItemRhs<'hir> {
2686        let is_direct = |body| {
2687            if self.tcx.features().macroless_const_item_generic_const_args() {
2688                self.can_lower_expr_to_const_arg_direct(
2689                    body,
2690                    DirectConstArgContext::MacrolessMinGenericConstArgs,
2691                )
2692                .is_ok()
2693            } else {
2694                // do not check can_lower_expr_to_const_arg_direct, but rather just
2695                // ExprKind::DirectConstArg, because we don't want e.g.
2696                // `impl<const N: u8> { const C: u8 = N; }` to be a direct-rhs const
2697                #[allow(non_exhaustive_omitted_patterns)] match body {
    Expr { kind: ExprKind::DirectConstArg(_), .. } => true,
    _ => false,
}matches!(body, Expr { kind: ExprKind::DirectConstArg(_), .. })
2698            }
2699        };
2700        if self.tcx.features().min_generic_const_args()
2701            && let Some(body) = body
2702            && is_direct(body)
2703        {
2704            hir::ConstItemRhs::Direct(
2705                self.arena.alloc(self.lower_expr_to_const_arg_direct(&body, None)),
2706            )
2707        } else {
2708            hir::ConstItemRhs::Body(self.lower_const_body(span, body.as_deref()))
2709        }
2710    }
2711
2712    fn ambient_direct_const_arg_context(&self) -> DirectConstArgContext {
2713        if self.tcx.features().macroless_generic_const_args() {
2714            DirectConstArgContext::MacrolessMinGenericConstArgs
2715        } else if self.tcx.features().min_generic_const_args() {
2716            DirectConstArgContext::MinGenericConstArgs
2717        } else {
2718            DirectConstArgContext::Stable
2719        }
2720    }
2721
2722    fn can_lower_path_to_const_arg_direct(
2723        &self,
2724        qself: &Option<Box<QSelf>>,
2725        path: &Path,
2726        span: Span,
2727        res: Option<Res<NodeId>>,
2728        context: DirectConstArgContext,
2729    ) -> Result<(), UnrepresentableConstArgError> {
2730        if let DirectConstArgContext::MacrolessMinGenericConstArgs = context {
2731            Ok(())
2732        } else if qself.is_none()
2733            && path.is_single_argless_ident()
2734            && #[allow(non_exhaustive_omitted_patterns)] match res {
    Some(Res::Def(DefKind::ConstParam, _)) => true,
    _ => false,
}matches!(res, Some(Res::Def(DefKind::ConstParam, _)))
2735        {
2736            Ok(())
2737        } else {
2738            Err(UnrepresentableConstArgError { span, will_create_def_ids: false })
2739        }
2740    }
2741
2742    {}
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/923c95cdf5ba65cea505aa2ea829f578e1506ed8/compiler/rustc_ast_lowering/src/lib.rs"),
                                ::tracing_core::__macro_support::Option::Some(2742u32),
                                ::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;
                    }
                    {
                        use DirectConstArgContext::*;
                        match (&expr.kind, context) {
                            (ExprKind::Call(Expr { kind: ExprKind::Path(_, _), .. },
                                args), MacrolessMinGenericConstArgs) => {
                                for arg in args {
                                    self.can_lower_expr_to_const_arg_direct(arg, context)?;
                                }
                                Ok(())
                            }
                            (ExprKind::Tup(exprs), MacrolessMinGenericConstArgs) => {
                                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), MacrolessMinGenericConstArgs) => {
                                for f in &se.fields {
                                    self.can_lower_expr_to_const_arg_direct(&f.expr, context)?;
                                }
                                Ok(())
                            }
                            (ExprKind::Array(elements), MacrolessMinGenericConstArgs) =>
                                {
                                for element in elements {
                                    self.can_lower_expr_to_const_arg_direct(element, context)?;
                                }
                                Ok(())
                            }
                            (ExprKind::Underscore, MacrolessMinGenericConstArgs) =>
                                Ok(()),
                            (ExprKind::Paren(expr), MacrolessMinGenericConstArgs) => {
                                self.can_lower_expr_to_const_arg_direct(expr, context)
                            }
                            (ExprKind::Block(block, _), MacrolessMinGenericConstArgs) if
                                let [stmt] = block.stmts.as_slice() &&
                                    let StmtKind::Expr(expr) = &stmt.kind => {
                                self.can_lower_expr_to_const_arg_direct(expr, context)
                            }
                            (ExprKind::Lit(_), MacrolessMinGenericConstArgs) => Ok(()),
                            (ExprKind::Unary(UnOp::Neg, inner_expr),
                                MacrolessMinGenericConstArgs) if
                                let ExprKind::Lit(_) = &inner_expr.kind => {
                                Ok(())
                            }
                            (ExprKind::ConstBlock(_), MacrolessMinGenericConstArgs) =>
                                Ok(()),
                            (ExprKind::DirectConstArg(_),
                                MacrolessMinGenericConstArgs | MinGenericConstArgs) => {
                                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/923c95cdf5ba65cea505aa2ea829f578e1506ed8/compiler/rustc_ast_lowering/src/lib.rs:2742",
                        "rustc_ast_lowering", ::tracing::Level::DEBUG,
                        ::tracing_core::__macro_support::Option::Some("/rustc-dev/923c95cdf5ba65cea505aa2ea829f578e1506ed8/compiler/rustc_ast_lowering/src/lib.rs"),
                        ::tracing_core::__macro_support::Option::Some(2742u32),
                        ::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)]
2743    fn can_lower_expr_to_const_arg_direct(
2744        &self,
2745        expr: &Expr,
2746        context: DirectConstArgContext,
2747    ) -> Result<(), UnrepresentableConstArgError> {
2748        use DirectConstArgContext::*;
2749        // Note the only stable case is currently ExprKind::Path
2750        match (&expr.kind, context) {
2751            (
2752                ExprKind::Call(Expr { kind: ExprKind::Path(_, _), .. }, args),
2753                MacrolessMinGenericConstArgs,
2754            ) => {
2755                for arg in args {
2756                    self.can_lower_expr_to_const_arg_direct(arg, context)?;
2757                }
2758                Ok(())
2759            }
2760            (ExprKind::Tup(exprs), MacrolessMinGenericConstArgs) => {
2761                for expr in exprs {
2762                    self.can_lower_expr_to_const_arg_direct(expr, context)?;
2763                }
2764                Ok(())
2765            }
2766            (ExprKind::Path(qself, path), _) => {
2767                let res =
2768                    self.get_partial_res(expr.id).and_then(|partial_res| partial_res.full_res());
2769                self.can_lower_path_to_const_arg_direct(qself, path, expr.span, res, context)
2770            }
2771            (ExprKind::Struct(se), MacrolessMinGenericConstArgs) => {
2772                for f in &se.fields {
2773                    self.can_lower_expr_to_const_arg_direct(&f.expr, context)?;
2774                }
2775                Ok(())
2776            }
2777            (ExprKind::Array(elements), MacrolessMinGenericConstArgs) => {
2778                for element in elements {
2779                    self.can_lower_expr_to_const_arg_direct(element, context)?;
2780                }
2781                Ok(())
2782            }
2783            (ExprKind::Underscore, MacrolessMinGenericConstArgs) => Ok(()),
2784            (ExprKind::Paren(expr), MacrolessMinGenericConstArgs) => {
2785                self.can_lower_expr_to_const_arg_direct(expr, context)
2786            }
2787            (ExprKind::Block(block, _), MacrolessMinGenericConstArgs)
2788                if let [stmt] = block.stmts.as_slice()
2789                    && let StmtKind::Expr(expr) = &stmt.kind =>
2790            {
2791                self.can_lower_expr_to_const_arg_direct(expr, context)
2792            }
2793            (ExprKind::Lit(_), MacrolessMinGenericConstArgs) => Ok(()),
2794            (ExprKind::Unary(UnOp::Neg, inner_expr), MacrolessMinGenericConstArgs)
2795                if let ExprKind::Lit(_) = &inner_expr.kind =>
2796            {
2797                Ok(())
2798            }
2799            (ExprKind::ConstBlock(_), MacrolessMinGenericConstArgs) => Ok(()),
2800            (ExprKind::DirectConstArg(_), MacrolessMinGenericConstArgs | MinGenericConstArgs) => {
2801                // Always report this as able to be represented directly. If it turns out not to be,
2802                // `lower_expr_to_const_arg_direct` will report an error.
2803                Ok(())
2804            }
2805            _ => Err(UnrepresentableConstArgError::new(expr)),
2806        }
2807    }
2808
2809    /// It is not allowed to call this function without checking can_lower_path_to_const_arg_direct
2810    /// first, as we assume all feature gates/etc. have been checked already.
2811    fn lower_path_to_const_arg_direct(
2812        &mut self,
2813        id: NodeId,
2814        id_override: Option<NodeId>,
2815        qself: &Option<Box<QSelf>>,
2816        path: &Path,
2817        span: Span,
2818    ) -> hir::ConstArg<'hir> {
2819        let qpath = self.lower_qpath(
2820            id,
2821            qself,
2822            path,
2823            ParamMode::Explicit,
2824            AllowReturnTypeNotation::No,
2825            // FIXME(mgca): update for `fn foo() -> Bar<FOO<impl Trait>>` support
2826            ImplTraitContext::Disallowed(ImplTraitPosition::Path),
2827            None,
2828        );
2829
2830        let node_id = id_override.unwrap_or(id);
2831        ConstArg { hir_id: self.lower_node_id(node_id), kind: hir::ConstArgKind::Path(qpath), span }
2832    }
2833
2834    /// It is not allowed to call this function without checking can_lower_expr_to_const_arg_direct
2835    /// first, as we assume all feature gates/etc. have been checked already.
2836    {}
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/923c95cdf5ba65cea505aa2ea829f578e1506ed8/compiler/rustc_ast_lowering/src/lib.rs"),
                                ::tracing_core::__macro_support::Option::Some(2836u32),
                                ::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::DirectConstArg(expr) => {
                                match self.can_lower_expr_to_const_arg_direct(expr,
                                        DirectConstArgContext::MacrolessMinGenericConstArgs) {
                                    Ok(()) =>
                                        self.lower_expr_to_const_arg_direct(expr, id_override),
                                    Err(err) => err.emit(self),
                                }
                            }
                            _ => {
                                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/923c95cdf5ba65cea505aa2ea829f578e1506ed8/compiler/rustc_ast_lowering/src/lib.rs:2836",
                        "rustc_ast_lowering", ::tracing::Level::DEBUG,
                        ::tracing_core::__macro_support::Option::Some("/rustc-dev/923c95cdf5ba65cea505aa2ea829f578e1506ed8/compiler/rustc_ast_lowering/src/lib.rs"),
                        ::tracing_core::__macro_support::Option::Some(2836u32),
                        ::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)]
2837    fn lower_expr_to_const_arg_direct(
2838        &mut self,
2839        expr: &Expr,
2840        id_override: Option<NodeId>,
2841    ) -> hir::ConstArg<'hir> {
2842        let span = self.lower_span(expr.span);
2843        let node_id = id_override.unwrap_or(expr.id);
2844        match &expr.kind {
2845            ExprKind::Call(func, args) if let ExprKind::Path(qself, path) = &func.kind => {
2846                let qpath = self.lower_qpath(
2847                    func.id,
2848                    qself,
2849                    path,
2850                    ParamMode::Explicit,
2851                    AllowReturnTypeNotation::No,
2852                    ImplTraitContext::Disallowed(ImplTraitPosition::Path),
2853                    None,
2854                );
2855
2856                let lowered_args = self.arena.alloc_from_iter(args.iter().map(|arg| {
2857                    let const_arg = self.lower_expr_to_const_arg_direct(arg, None);
2858                    &*self.arena.alloc(const_arg)
2859                }));
2860
2861                ConstArg {
2862                    hir_id: self.lower_node_id(node_id),
2863                    kind: hir::ConstArgKind::TupleCall(qpath, lowered_args),
2864                    span,
2865                }
2866            }
2867            ExprKind::Tup(exprs) => {
2868                let exprs = self.arena.alloc_from_iter(exprs.iter().map(|expr| {
2869                    let expr = self.lower_expr_to_const_arg_direct(expr, None);
2870                    &*self.arena.alloc(expr)
2871                }));
2872
2873                ConstArg {
2874                    hir_id: self.lower_node_id(node_id),
2875                    kind: hir::ConstArgKind::Tup(exprs),
2876                    span,
2877                }
2878            }
2879            ExprKind::Path(qself, path) => {
2880                self.lower_path_to_const_arg_direct(expr.id, id_override, qself, path, span)
2881            }
2882            ExprKind::Struct(se) => {
2883                let path = self.lower_qpath(
2884                    expr.id,
2885                    &se.qself,
2886                    &se.path,
2887                    // FIXME(mgca): we may want this to be `Optional` instead, but
2888                    // we would also need to make sure that HIR ty lowering errors
2889                    // when these paths wind up in signatures.
2890                    ParamMode::Explicit,
2891                    AllowReturnTypeNotation::No,
2892                    ImplTraitContext::Disallowed(ImplTraitPosition::Path),
2893                    None,
2894                );
2895
2896                let fields = self.arena.alloc_from_iter(se.fields.iter().map(|f| {
2897                    let hir_id = self.lower_node_id(f.id);
2898                    // FIXME(mgca): This might result in lowering attributes that
2899                    // then go unused as the `Target::ExprField` is not actually
2900                    // corresponding to `Node::ExprField`.
2901                    self.lower_attrs(hir_id, &f.attrs, f.span, Target::ExprField);
2902                    let expr = self.lower_expr_to_const_arg_direct(&f.expr, None);
2903
2904                    &*self.arena.alloc(hir::ConstArgExprField {
2905                        hir_id,
2906                        field: self.lower_ident(f.ident),
2907                        expr: self.arena.alloc(expr),
2908                        span: self.lower_span(f.span),
2909                    })
2910                }));
2911
2912                ConstArg {
2913                    hir_id: self.lower_node_id(node_id),
2914                    kind: hir::ConstArgKind::Struct(path, fields),
2915                    span,
2916                }
2917            }
2918            ExprKind::Array(elements) => {
2919                let lowered_elems = self.arena.alloc_from_iter(elements.iter().map(|element| {
2920                    let const_arg = self.lower_expr_to_const_arg_direct(element, None);
2921                    &*self.arena.alloc(const_arg)
2922                }));
2923                let array_expr = self.arena.alloc(hir::ConstArgArrayExpr {
2924                    span: self.lower_span(expr.span),
2925                    elems: lowered_elems,
2926                });
2927
2928                ConstArg {
2929                    hir_id: self.lower_node_id(node_id),
2930                    kind: hir::ConstArgKind::Array(array_expr),
2931                    span,
2932                }
2933            }
2934            ExprKind::Underscore => ConstArg {
2935                hir_id: self.lower_node_id(node_id),
2936                kind: hir::ConstArgKind::Infer(()),
2937                span,
2938            },
2939            ExprKind::Paren(expr) => self.lower_expr_to_const_arg_direct(expr, id_override),
2940            ExprKind::Block(block, _)
2941                if let [stmt] = block.stmts.as_slice()
2942                    && let StmtKind::Expr(expr) = &stmt.kind =>
2943            {
2944                self.lower_expr_to_const_arg_direct(expr, id_override)
2945            }
2946            ExprKind::Lit(literal) => {
2947                let span = self.lower_span(expr.span);
2948                let literal = self.lower_lit(literal, span);
2949
2950                ConstArg {
2951                    hir_id: self.lower_node_id(node_id),
2952                    kind: hir::ConstArgKind::Literal { lit: literal.node, negated: false },
2953                    span,
2954                }
2955            }
2956            ExprKind::Unary(UnOp::Neg, inner_expr)
2957                if let ExprKind::Lit(literal) = &inner_expr.kind =>
2958            {
2959                let span = self.lower_span(expr.span);
2960                let literal = self.lower_lit(literal, span);
2961
2962                let kind = if !matches!(literal.node, LitKind::Int(..)) {
2963                    let err = self.dcx().span_err(expr.span, "negated literal must be an integer");
2964                    hir::ConstArgKind::Error(err)
2965                } else {
2966                    hir::ConstArgKind::Literal { lit: literal.node, negated: true }
2967                };
2968                ConstArg { hir_id: self.lower_node_id(node_id), kind, span }
2969            }
2970            ExprKind::ConstBlock(anon_const) => {
2971                // Do not use lower_anon_const_to_const_arg, as that attempts to represent the body
2972                // directly. Instead, force an anon const.
2973                let def_id = self.local_def_id(anon_const.id);
2974                assert_eq!(DefKind::AnonConst, self.tcx.def_kind(def_id));
2975                let lowered_anon = self.lower_anon_const_to_anon_const(anon_const, span);
2976                ConstArg {
2977                    hir_id: self.lower_node_id(node_id),
2978                    kind: hir::ConstArgKind::Anon(lowered_anon),
2979                    span,
2980                }
2981            }
2982            ExprKind::DirectConstArg(expr) => {
2983                // `can_lower_expr_to_const_arg_direct` always returns success upon encountering a
2984                // ExprKind::DirectConstArg, which effectively forces the expression to be lowered
2985                // as a direct arg. If it actually turns out to not be possible, emit an error
2986                // instead.
2987                // Always use MacrolessMinGenericConstArgs, even if we're under regular GCA, because
2988                // that's what the macro means: to enter a context that is like macroless GCA.
2989                match self.can_lower_expr_to_const_arg_direct(
2990                    expr,
2991                    DirectConstArgContext::MacrolessMinGenericConstArgs,
2992                ) {
2993                    Ok(()) => self.lower_expr_to_const_arg_direct(expr, id_override),
2994                    Err(err) => err.emit(self),
2995                }
2996            }
2997            _ => {
2998                span_bug!(
2999                    expr.span,
3000                    "lower_expr_to_const_arg_direct encountered an unlowerable expression, either \
3001                    can_lower_expr_to_const_arg_direct returned Ok() on something it shouldn't \
3002                    have, or you forgot to check can_lower_expr_to_const_arg_direct first"
3003                );
3004            }
3005        }
3006    }
3007
3008    /// See [`hir::ConstArg`] for when to use this function vs
3009    /// [`Self::lower_anon_const_to_anon_const`].
3010    fn lower_anon_const_to_const_arg_and_alloc(
3011        &mut self,
3012        anon: &AnonConst,
3013    ) -> &'hir hir::ConstArg<'hir> {
3014        self.arena.alloc(self.lower_anon_const_to_const_arg(anon))
3015    }
3016
3017    {}
#[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/923c95cdf5ba65cea505aa2ea829f578e1506ed8/compiler/rustc_ast_lowering/src/lib.rs"),
                                    ::tracing_core::__macro_support::Option::Some(3017u32),
                                    ::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().macroless_generic_const_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))]
3018    fn lower_anon_const_to_const_arg(&mut self, anon: &AnonConst) -> hir::ConstArg<'hir> {
3019        // Stable only allows one nesting of blocks for directly represented paths. mGCA allows
3020        // arbitrarily many, and are handled inside lower_expr_to_const_arg_direct for consistency.
3021        let expr = if self.tcx.features().macroless_generic_const_args() {
3022            &anon.value
3023        } else {
3024            anon.value.maybe_unwrap_block()
3025        };
3026
3027        let context = self.ambient_direct_const_arg_context();
3028        if self.can_lower_expr_to_const_arg_direct(expr, context).is_ok() {
3029            return self.lower_expr_to_const_arg_direct(expr, Some(anon.id));
3030        }
3031
3032        let lowered_anon = self.lower_anon_const_to_anon_const(anon, anon.value.span);
3033        ConstArg {
3034            hir_id: self.next_id(),
3035            kind: hir::ConstArgKind::Anon(lowered_anon),
3036            span: self.lower_span(anon.value.span),
3037        }
3038    }
3039
3040    /// See [`hir::ConstArg`] for when to use this function vs
3041    /// [`Self::lower_anon_const_to_const_arg`].
3042    fn lower_anon_const_to_anon_const(
3043        &mut self,
3044        c: &AnonConst,
3045        span: Span,
3046    ) -> &'hir hir::AnonConst {
3047        self.arena.alloc(self.with_new_scopes(c.value.span, |this| {
3048            let def_id = this.local_def_id(c.id);
3049            let hir_id = this.lower_node_id(c.id);
3050            hir::AnonConst {
3051                def_id,
3052                hir_id,
3053                body: this.lower_const_body(c.value.span, Some(&c.value)),
3054                span: this.lower_span(span),
3055            }
3056        }))
3057    }
3058
3059    fn lower_unsafe_source(&mut self, u: UnsafeSource) -> hir::UnsafeSource {
3060        match u {
3061            CompilerGenerated => hir::UnsafeSource::CompilerGenerated,
3062            UserProvided => hir::UnsafeSource::UserProvided,
3063        }
3064    }
3065
3066    fn lower_trait_bound_modifiers(
3067        &mut self,
3068        modifiers: TraitBoundModifiers,
3069    ) -> hir::TraitBoundModifiers {
3070        let constness = match modifiers.constness {
3071            BoundConstness::Never => BoundConstness::Never,
3072            BoundConstness::Always(span) => BoundConstness::Always(self.lower_span(span)),
3073            BoundConstness::Maybe(span) => BoundConstness::Maybe(self.lower_span(span)),
3074        };
3075        let polarity = match modifiers.polarity {
3076            BoundPolarity::Positive => BoundPolarity::Positive,
3077            BoundPolarity::Negative(span) => BoundPolarity::Negative(self.lower_span(span)),
3078            BoundPolarity::Maybe(span) => BoundPolarity::Maybe(self.lower_span(span)),
3079        };
3080        hir::TraitBoundModifiers { constness, polarity }
3081    }
3082
3083    // Helper methods for building HIR.
3084
3085    fn stmt(&mut self, span: Span, kind: hir::StmtKind<'hir>) -> hir::Stmt<'hir> {
3086        hir::Stmt { span: self.lower_span(span), kind, hir_id: self.next_id() }
3087    }
3088
3089    fn stmt_expr(&mut self, span: Span, expr: hir::Expr<'hir>) -> hir::Stmt<'hir> {
3090        self.stmt(span, hir::StmtKind::Expr(self.arena.alloc(expr)))
3091    }
3092
3093    fn stmt_let_pat(
3094        &mut self,
3095        attrs: Option<&'hir [hir::Attribute]>,
3096        span: Span,
3097        init: Option<&'hir hir::Expr<'hir>>,
3098        pat: &'hir hir::Pat<'hir>,
3099        source: hir::LocalSource,
3100    ) -> hir::Stmt<'hir> {
3101        let hir_id = self.next_id();
3102        if let Some(a) = attrs {
3103            if !!a.is_empty() {
    ::core::panicking::panic("assertion failed: !a.is_empty()")
};assert!(!a.is_empty());
3104            self.curr_owner.attrs.insert(hir_id.local_id, a);
3105        }
3106        let local = hir::LetStmt {
3107            super_: None,
3108            hir_id,
3109            init,
3110            pat,
3111            els: None,
3112            source,
3113            span: self.lower_span(span),
3114            ty: None,
3115        };
3116        self.stmt(span, hir::StmtKind::Let(self.arena.alloc(local)))
3117    }
3118
3119    fn stmt_super_let_pat(
3120        &mut self,
3121        span: Span,
3122        pat: &'hir hir::Pat<'hir>,
3123        init: Option<&'hir hir::Expr<'hir>>,
3124    ) -> hir::Stmt<'hir> {
3125        let hir_id = self.next_id();
3126        let span = self.lower_span(span);
3127        let local = hir::LetStmt {
3128            super_: Some(span),
3129            hir_id,
3130            init,
3131            pat,
3132            els: None,
3133            source: hir::LocalSource::Normal,
3134            span,
3135            ty: None,
3136        };
3137        self.stmt(span, hir::StmtKind::Let(self.arena.alloc(local)))
3138    }
3139
3140    fn block_expr(&mut self, expr: &'hir hir::Expr<'hir>) -> &'hir hir::Block<'hir> {
3141        self.block_all(expr.span, &[], Some(expr))
3142    }
3143
3144    fn block_all(
3145        &mut self,
3146        span: Span,
3147        stmts: &'hir [hir::Stmt<'hir>],
3148        expr: Option<&'hir hir::Expr<'hir>>,
3149    ) -> &'hir hir::Block<'hir> {
3150        let blk = hir::Block {
3151            stmts,
3152            expr,
3153            hir_id: self.next_id(),
3154            rules: hir::BlockCheckMode::DefaultBlock,
3155            span: self.lower_span(span),
3156            targeted_by_break: false,
3157        };
3158        self.arena.alloc(blk)
3159    }
3160
3161    fn pat_cf_continue(&mut self, span: Span, pat: &'hir hir::Pat<'hir>) -> &'hir hir::Pat<'hir> {
3162        let field = self.single_pat_field(span, pat);
3163        self.pat_lang_item_variant(span, LangItem::ControlFlowContinue, field)
3164    }
3165
3166    fn pat_cf_break(&mut self, span: Span, pat: &'hir hir::Pat<'hir>) -> &'hir hir::Pat<'hir> {
3167        let field = self.single_pat_field(span, pat);
3168        self.pat_lang_item_variant(span, LangItem::ControlFlowBreak, field)
3169    }
3170
3171    fn pat_some(&mut self, span: Span, pat: &'hir hir::Pat<'hir>) -> &'hir hir::Pat<'hir> {
3172        let field = self.single_pat_field(span, pat);
3173        self.pat_lang_item_variant(span, LangItem::OptionSome, field)
3174    }
3175
3176    fn pat_none(&mut self, span: Span) -> &'hir hir::Pat<'hir> {
3177        self.pat_lang_item_variant(span, LangItem::OptionNone, &[])
3178    }
3179
3180    fn single_pat_field(
3181        &mut self,
3182        span: Span,
3183        pat: &'hir hir::Pat<'hir>,
3184    ) -> &'hir [hir::PatField<'hir>] {
3185        let field = hir::PatField {
3186            hir_id: self.next_id(),
3187            ident: Ident::new(sym::integer(0), self.lower_span(span)),
3188            is_shorthand: false,
3189            pat,
3190            span: self.lower_span(span),
3191        };
3192        self.arena.alloc_from_iter([field])arena_vec![self; field]
3193    }
3194
3195    fn pat_lang_item_variant(
3196        &mut self,
3197        span: Span,
3198        lang_item: LangItem,
3199        fields: &'hir [hir::PatField<'hir>],
3200    ) -> &'hir hir::Pat<'hir> {
3201        let path = self.make_lang_item_qpath(lang_item, self.lower_span(span), None);
3202        self.pat(span, hir::PatKind::Struct(path, fields, None))
3203    }
3204
3205    fn pat_ident(&mut self, span: Span, ident: Ident) -> (&'hir hir::Pat<'hir>, HirId) {
3206        self.pat_ident_binding_mode(span, ident, hir::BindingMode::NONE)
3207    }
3208
3209    fn pat_ident_mut(&mut self, span: Span, ident: Ident) -> (hir::Pat<'hir>, HirId) {
3210        self.pat_ident_binding_mode_mut(span, ident, hir::BindingMode::NONE)
3211    }
3212
3213    fn pat_ident_binding_mode(
3214        &mut self,
3215        span: Span,
3216        ident: Ident,
3217        bm: hir::BindingMode,
3218    ) -> (&'hir hir::Pat<'hir>, HirId) {
3219        let (pat, hir_id) = self.pat_ident_binding_mode_mut(span, ident, bm);
3220        (self.arena.alloc(pat), hir_id)
3221    }
3222
3223    fn pat_ident_binding_mode_mut(
3224        &mut self,
3225        span: Span,
3226        ident: Ident,
3227        bm: hir::BindingMode,
3228    ) -> (hir::Pat<'hir>, HirId) {
3229        let hir_id = self.next_id();
3230
3231        (
3232            hir::Pat {
3233                hir_id,
3234                kind: hir::PatKind::Binding(bm, hir_id, self.lower_ident(ident), None),
3235                span: self.lower_span(span),
3236                default_binding_modes: true,
3237            },
3238            hir_id,
3239        )
3240    }
3241
3242    fn pat(&mut self, span: Span, kind: hir::PatKind<'hir>) -> &'hir hir::Pat<'hir> {
3243        self.arena.alloc(hir::Pat {
3244            hir_id: self.next_id(),
3245            kind,
3246            span: self.lower_span(span),
3247            default_binding_modes: true,
3248        })
3249    }
3250
3251    fn pat_without_dbm(&mut self, span: Span, kind: hir::PatKind<'hir>) -> hir::Pat<'hir> {
3252        hir::Pat {
3253            hir_id: self.next_id(),
3254            kind,
3255            span: self.lower_span(span),
3256            default_binding_modes: false,
3257        }
3258    }
3259
3260    fn ty_path(&mut self, mut hir_id: HirId, span: Span, qpath: hir::QPath<'hir>) -> hir::Ty<'hir> {
3261        let kind = match qpath {
3262            hir::QPath::Resolved(None, path) => {
3263                // Turn trait object paths into `TyKind::TraitObject` instead.
3264                match path.res {
3265                    Res::Def(DefKind::Trait | DefKind::TraitAlias, _) => {
3266                        let principal = hir::PolyTraitRef {
3267                            bound_generic_params: &[],
3268                            modifiers: hir::TraitBoundModifiers::NONE,
3269                            trait_ref: hir::TraitRef { path, hir_ref_id: hir_id },
3270                            span: self.lower_span(span),
3271                        };
3272
3273                        // The original ID is taken by the `PolyTraitRef`,
3274                        // so the `Ty` itself needs a different one.
3275                        hir_id = self.next_id();
3276                        hir::TyKind::TraitObject(
3277                            self.arena.alloc_from_iter([principal])arena_vec![self; principal],
3278                            TaggedRef::new(self.elided_dyn_bound(span), TraitObjectSyntax::None),
3279                        )
3280                    }
3281                    _ => hir::TyKind::Path(hir::QPath::Resolved(None, path)),
3282                }
3283            }
3284            _ => hir::TyKind::Path(qpath),
3285        };
3286
3287        hir::Ty { hir_id, kind, span: self.lower_span(span) }
3288    }
3289
3290    /// Invoked to create the lifetime argument(s) for an elided trait object
3291    /// bound, like the bound in `Box<dyn Debug>`. This method is not invoked
3292    /// when the bound is written, even if it is written with `'_` like in
3293    /// `Box<dyn Debug + '_>`. In those cases, `lower_lifetime` is invoked.
3294    fn elided_dyn_bound(&mut self, span: Span) -> &'hir hir::Lifetime {
3295        let r = hir::Lifetime::new(
3296            self.next_id(),
3297            Ident::new(kw::UnderscoreLifetime, self.lower_span(span)),
3298            hir::LifetimeKind::ImplicitObjectLifetimeDefault,
3299            LifetimeSource::Other,
3300            LifetimeSyntax::Implicit,
3301        );
3302        {
    use ::tracing::__macro_support::Callsite as _;
    static __CALLSITE: ::tracing::callsite::DefaultCallsite =
        {
            static META: ::tracing::Metadata<'static> =
                {
                    ::tracing_core::metadata::Metadata::new("event /rustc-dev/923c95cdf5ba65cea505aa2ea829f578e1506ed8/compiler/rustc_ast_lowering/src/lib.rs:3302",
                        "rustc_ast_lowering", ::tracing::Level::DEBUG,
                        ::tracing_core::__macro_support::Option::Some("/rustc-dev/923c95cdf5ba65cea505aa2ea829f578e1506ed8/compiler/rustc_ast_lowering/src/lib.rs"),
                        ::tracing_core::__macro_support::Option::Some(3302u32),
                        ::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);
3303        self.arena.alloc(r)
3304    }
3305}
3306
3307/// Helper struct for the delayed construction of [`hir::GenericArgs`].
3308struct GenericArgsCtor<'hir> {
3309    args: SmallVec<[hir::GenericArg<'hir>; 4]>,
3310    constraints: &'hir [hir::AssocItemConstraint<'hir>],
3311    parenthesized: hir::GenericArgsParentheses,
3312    span: Span,
3313}
3314
3315impl<'hir> GenericArgsCtor<'hir> {
3316    fn is_empty(&self) -> bool {
3317        self.args.is_empty()
3318            && self.constraints.is_empty()
3319            && self.parenthesized == hir::GenericArgsParentheses::No
3320    }
3321
3322    fn into_generic_args(self, this: &LoweringContext<'_, 'hir>) -> &'hir hir::GenericArgs<'hir> {
3323        let ga = hir::GenericArgs {
3324            args: this.arena.alloc_from_iter(self.args),
3325            constraints: self.constraints,
3326            parenthesized: self.parenthesized,
3327            span_ext: this.lower_span(self.span),
3328        };
3329        this.arena.alloc(ga)
3330    }
3331}
3332
3333#[derive(#[automatically_derived]
impl ::core::marker::Copy for DirectConstArgContext { }Copy, #[automatically_derived]
#[doc(hidden)]
unsafe impl ::core::clone::TrivialClone for DirectConstArgContext { }
#[automatically_derived]
impl ::core::clone::Clone for DirectConstArgContext {
    #[inline]
    fn clone(&self) -> DirectConstArgContext { *self }
}Clone, #[automatically_derived]
impl ::core::fmt::Debug for DirectConstArgContext {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::write_str(f,
            match self {
                DirectConstArgContext::Stable => "Stable",
                DirectConstArgContext::MinGenericConstArgs =>
                    "MinGenericConstArgs",
                DirectConstArgContext::MacrolessMinGenericConstArgs =>
                    "MacrolessMinGenericConstArgs",
            })
    }
}Debug)]
3334enum DirectConstArgContext {
3335    /// The only allowed direct const arg representation is simple paths that nameres to generic
3336    /// const parameters.
3337    Stable,
3338    /// The allowed representations are what is allowed on stable, plus the `direct_const_arg!` macro.
3339    MinGenericConstArgs,
3340    /// Expressions attempt to be lowered directly, and if that fails, the expression falls back to
3341    /// being represented as an anon const.
3342    ///
3343    /// This context is also used under MinGenericConstArgs inside a `direct_const_arg!` macro, for
3344    /// simplicity, as they allow the same code.
3345    MacrolessMinGenericConstArgs,
3346}
3347
3348#[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)]
3349struct UnrepresentableConstArgError {
3350    span: Span,
3351    will_create_def_ids: bool,
3352}
3353
3354impl UnrepresentableConstArgError {
3355    fn new(expr: &Expr) -> Self {
3356        Self {
3357            span: expr.span,
3358            will_create_def_ids: expr::WillCreateDefIdsVisitor.visit_expr(expr).is_break(),
3359        }
3360    }
3361
3362    fn emit<'hir>(self, lowering_context: &mut LoweringContext<'_, 'hir>) -> ConstArg<'hir> {
3363        let msg = "complex const arguments must be placed inside of a `const` block";
3364        let e = if self.will_create_def_ids {
3365            // FIXME(mgca): make this non-fatal once we have a better way to handle
3366            // nested items in const args
3367            // Issue: https://github.com/rust-lang/rust/issues/154539
3368            lowering_context.dcx().span_fatal(self.span, msg)
3369        } else {
3370            lowering_context.dcx().span_err(self.span, msg)
3371        };
3372
3373        ConstArg {
3374            hir_id: lowering_context.next_id(),
3375            kind: hir::ConstArgKind::Error(e),
3376            span: self.span,
3377        }
3378    }
3379}