1#![feature(const_default)]
35#![feature(const_trait_impl)]
36#![feature(default_field_values)]
37#![feature(deref_patterns)]
38#![recursion_limit = "256"]
39use std::mem;
42use std::sync::{Arc, LazyLock};
43
44use rustc_ast::mut_visit::{self, MutVisitor};
45use rustc_ast::node_id::NodeMap;
46use rustc_ast::visit::{self, Visitor};
47use rustc_ast::{self as ast, *};
48use rustc_attr_ir::find_attr;
49use rustc_attr_ir::lang_items::LangItem;
50use rustc_attr_ir::target::AstTarget;
51use rustc_attr_parsing::{AttributeParser, Recovery, ShouldEmit};
52use rustc_data_structures::fx::FxIndexMap;
53use rustc_data_structures::sorted_map::SortedMap;
54use rustc_data_structures::stable_hash::{StableHash, StableHasher};
55use rustc_data_structures::steal::Steal;
56use rustc_data_structures::tagged_ptr::TaggedRef;
57use rustc_errors::codes::*;
58use rustc_errors::{DiagArgFromDisplay, DiagCtxtHandle, ErrorGuaranteed};
59use rustc_hir::def::{CtorKind, DefKind, Namespace, PerNS, Res};
60use rustc_hir::def_id::{DefId, LOCAL_CRATE, LocalDefId, LocalDefIdMap};
61use rustc_hir::definitions::PerParentDisambiguatorState;
62use rustc_hir::lints::DelayedLint;
63use rustc_hir::{
64 self as hir, AngleBrackets, CRATE_OWNER_ID, ConstArg, GenericArg, HirId, ItemLocalMap,
65 LifetimeSource, LifetimeSyntax, MissingLifetimeKind, ParamName, TraitCandidate,
66};
67use rustc_index::{Idx, IndexSlice, IndexVec};
68use rustc_macros::extension;
69use rustc_middle::middle::resolve::{
70 AstOwner, LifetimeRes, PartialRes, PerOwnerResolverData, ResolverAstLowering,
71};
72use rustc_middle::queries::Providers;
73use rustc_middle::ty::TyCtxt;
74use rustc_session::diagnostics::add_feature_diagnostics;
75use rustc_span::symbol::{Ident, Symbol, kw, sym};
76use rustc_span::{DUMMY_SP, DesugaringKind, Span, span_bug};
77use smallvec::{SmallVec, smallvec};
78use thin_vec::ThinVec;
79use tracing::{debug, instrument, trace};
80
81use crate::diagnostics::{AssocTyParentheses, AssocTyParenthesesSub, MisplacedImplTrait};
82
83macro_rules! arena_vec {
84 ($this:expr; $($x:expr),*) => (
85 $this.arena.alloc_from_iter([$($x),*])
86 );
87}
88
89mod asm;
90mod block;
91mod contract;
92mod delegation;
93mod diagnostics;
94mod expr;
95mod format;
96mod index;
97mod item;
98mod pat;
99mod path;
100pub mod stability;
101
102pub fn provide(providers: &mut Providers) {
103 providers.index_ast = index_ast;
104 providers.lower_to_hir = lower_to_hir;
105 providers.resolve_type_relative_delegations =
106 delegation::resolution::resolve_type_relative_delegations;
107}
108
109#[cfg(debug_assertions)]
110pub(crate) mod re_lowering {
111 use rustc_ast::NodeId;
112 use rustc_ast::node_id::NodeMap;
113 use rustc_hir as hir;
114
115 use crate::LoweringContext;
116
117 #[derive(#[automatically_derived]impl ::core::fmt::Debug for ReloweringChecker {
#[inline]
#[rustc_trivial_field_reads]
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 can_relower",
&self.node_id_to_local_id, &&self.can_relower)
}
}Debug, #[automatically_derived]impl ::core::default::Default for ReloweringChecker {
#[inline]
fn default() -> Self {
ReloweringChecker {
node_id_to_local_id: ::core::default::Default::default(),
can_relower: ::core::default::Default::default(),
}
}
}Default)]
118 pub(crate) struct ReloweringChecker {
119 node_id_to_local_id: NodeMap<hir::ItemLocalId>,
120 can_relower: bool,
121 }
122
123 impl ReloweringChecker {
124 pub(crate) fn assert_node_is_not_relowered(
125 &mut self,
126 ast_node_id: NodeId,
127 local_id: hir::ItemLocalId,
128 ) {
129 if !self.can_relower {
130 let old = self.node_id_to_local_id.insert(ast_node_id, local_id);
131 {
match (&old, &None) {
(left_val, right_val) => {
if !(*left_val == *right_val) {
let kind = ::core::panicking::AssertKind::Eq;
::core::panicking::assert_failed(kind, &*left_val,
&*right_val, ::core::option::Option::None);
}
}
}
};assert_eq!(old, None);
132 }
133 }
134
135 pub(crate) fn allow_relowering<'a, 'hir, TRes>(
136 ctx: &mut LoweringContext<'a, 'hir>,
137 op: impl FnOnce(&mut LoweringContext<'a, 'hir>) -> TRes,
138 ) -> TRes {
139 if !!ctx.curr_owner.relowering_checker.can_relower {
{
::core::panicking::panic_fmt(format_args!("reentrant relowering is not supported"));
}
};assert!(
140 !ctx.curr_owner.relowering_checker.can_relower,
141 "reentrant relowering is not supported"
142 );
143
144 ctx.curr_owner.relowering_checker.can_relower = true;
145
146 let res = op(ctx);
147
148 ctx.curr_owner.relowering_checker.can_relower = false;
149
150 res
151 }
152 }
153}
154
155struct PerOwnerLoweringState<'a, 'hir> {
156 owner: &'a PerOwnerResolverData<'hir>,
158 disambiguator: PerParentDisambiguatorState,
159
160 item_local_id_counter: hir::ItemLocalId,
162 ident_and_label_to_local_id: NodeMap<hir::ItemLocalId>,
165 #[cfg(debug_assertions)]
168 relowering_checker: re_lowering::ReloweringChecker,
169
170 attrs: SortedMap<hir::ItemLocalId, &'hir [rustc_attr_ir::Attribute]>,
173 bodies: Vec<(hir::ItemLocalId, &'hir hir::Body<'hir>)>,
175 define_opaque: Option<&'hir [(Span, LocalDefId)]>,
177 trait_map: ItemLocalMap<&'hir [TraitCandidate<'hir>]>,
178 delayed_lints: Vec<DelayedLint>,
179 children: LocalDefIdMap<hir::MaybeOwner<'hir>>,
181
182 impl_trait_defs: Vec<hir::GenericParam<'hir>>,
184 impl_trait_bounds: Vec<hir::WherePredicate<'hir>>,
185 const_defs: Vec<hir::GenericParam<'hir>>,
186}
187
188impl<'a, 'hir> PerOwnerLoweringState<'a, 'hir> {
189 fn new(resolver: &'a ResolverAstLowering<'hir>, owner: NodeId) -> Self {
190 let owner = &resolver.owners[&owner];
191
192 let disambiguator = resolver
193 .disambiguators
194 .get(&owner.def_id)
195 .map(|s| s.steal())
196 .unwrap_or_else(|| PerParentDisambiguatorState::new(owner.def_id));
197
198 PerOwnerLoweringState {
199 owner,
200 disambiguator,
201 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 const_defs: Vec::new(),
216 }
217 }
218
219 fn owner_id(&self) -> hir::OwnerId {
220 hir::OwnerId { def_id: self.owner.def_id }
221 }
222
223 fn into_owner_info(
224 self,
225 tcx: TyCtxt<'hir>,
226 node: hir::OwnerNode<'hir>,
227 ) -> &'hir hir::OwnerInfo<'hir> {
228 {
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());
229 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());
230 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());
231 if !self.const_defs.is_empty() {
::core::panicking::panic("assertion failed: self.const_defs.is_empty()")
};assert!(self.const_defs.is_empty());
232
233 let attrs = self.attrs;
234 let mut bodies = self.bodies;
235 let define_opaque = self.define_opaque;
236 let trait_map = self.trait_map;
237 let delayed_lints = Steal::new(self.delayed_lints.into_boxed_slice());
238 let children = self.children;
239
240 #[cfg(debug_assertions)]
241 for (id, attrs) in attrs.iter() {
242 if attrs.is_empty() {
244 {
::core::panicking::panic_fmt(format_args!("Stored empty attributes for {0:?}",
id));
};panic!("Stored empty attributes for {:?}", id);
245 }
246 }
247
248 bodies.sort_by_key(|(k, _)| *k);
249 let bodies = SortedMap::from_presorted_elements(bodies);
250
251 let rustc_middle::hir::Hashes { bodies_hash, attrs_hash } =
253 tcx.hash_owner_nodes(node, &bodies, &attrs, define_opaque);
254 let num_nodes = self.item_local_id_counter.as_usize();
255 let (nodes, parenting) = index::index_hir(tcx, node, &bodies, num_nodes);
256 let nodes = hir::OwnerNodes { opt_hash: bodies_hash, nodes, bodies };
257 let attrs = hir::AttributeMap { map: attrs, opt_hash: attrs_hash, define_opaque };
258
259 let opt_hash = tcx.needs_owner_info_hash().then(|| {
260 tcx.with_stable_hashing_context(|mut hcx| {
261 let mut stable_hasher = StableHasher::new();
262 bodies_hash.unwrap().stable_hash(&mut hcx, &mut stable_hasher);
263 attrs_hash.unwrap().stable_hash(&mut hcx, &mut stable_hasher);
264 parenting.stable_hash(&mut hcx, &mut stable_hasher);
266 trait_map.stable_hash(&mut hcx, &mut stable_hasher);
267 children.stable_hash(&mut hcx, &mut stable_hasher);
268 stable_hasher.finish()
269 })
270 });
271
272 tcx.hir_arena.alloc(hir::OwnerInfo {
273 opt_hash,
274 nodes,
275 parenting,
276 attrs,
277 trait_map,
278 delayed_lints,
279 children,
280 })
281 }
282}
283
284struct LoweringContext<'a, 'hir> {
285 tcx: TyCtxt<'hir>,
286 resolver: &'a ResolverAstLowering<'hir>,
287
288 curr_owner: PerOwnerLoweringState<'a, 'hir>,
289
290 arena: &'hir hir::Arena<'hir>,
292
293 contract_ensures: Option<(Span, Ident, HirId)>,
294
295 coroutine_kind: Option<hir::CoroutineKind>,
296
297 task_context: Option<HirId>,
300
301 current_item_span: Option<Span>,
304
305 try_block_scope: TryBlockScope,
306 loop_scope: Option<HirId>,
307 is_in_loop_condition: bool,
308 is_in_dyn_type: bool,
309
310 next_node_id: NodeId,
314 node_id_to_def_id: NodeMap<LocalDefId>,
316 partial_res_overrides: NodeMap<NodeId>,
320
321 move_expr_bindings: Vec<Option<expr::MoveExprState<'hir>>>,
325
326 lowering_move_expr_initializer: bool,
328
329 attribute_parser: AttributeParser<'hir>,
330}
331
332macro_rules! allow {
333 ($($name:ident: $list:expr;)*) => {
334 $( static $name: LazyLock<Arc<[Symbol]>> = LazyLock::new(|| $list.into()); )*
335 }
336}
337
338static ALLOW_CONTRACTS: LazyLock<Arc<[Symbol]>> =
LazyLock::new(|| [sym::contracts_internals].into());
static ALLOW_TRY_TRAIT: LazyLock<Arc<[Symbol]>> =
LazyLock::new(||
[sym::try_trait_v2, sym::try_trait_v2_residual,
sym::yeet_desugar_details].into());
static ALLOW_PATTERN_TYPE: LazyLock<Arc<[Symbol]>> =
LazyLock::new(||
[sym::pattern_types, sym::pattern_type_range_trait].into());
static ALLOW_GEN_FUTURE: LazyLock<Arc<[Symbol]>> =
LazyLock::new(|| [sym::gen_future].into());
static ALLOW_GEN_FUTURE_WITH_ASYNC_FN_TRACK_CALLER: LazyLock<Arc<[Symbol]>> =
LazyLock::new(|| [sym::gen_future, sym::closure_track_caller].into());
static ALLOW_FOR_AWAIT: LazyLock<Arc<[Symbol]>> =
LazyLock::new(|| [sym::async_gen_internals, sym::async_iterator].into());
static ALLOW_ASYNC_FN_TRAITS: LazyLock<Arc<[Symbol]>> =
LazyLock::new(|| [sym::async_fn_traits].into());
static ALLOW_ASYNC_GEN: LazyLock<Arc<[Symbol]>> =
LazyLock::new(|| [sym::async_gen_internals].into());
static ALLOW_ASYNC_ITERATOR: LazyLock<Arc<[Symbol]>> =
LazyLock::new(|| [sym::gen_future, sym::async_iterator].into());allow! {
339 ALLOW_CONTRACTS: [sym::contracts_internals];
340 ALLOW_TRY_TRAIT: [sym::try_trait_v2, sym::try_trait_v2_residual, sym::yeet_desugar_details];
341 ALLOW_PATTERN_TYPE: [sym::pattern_types, sym::pattern_type_range_trait];
342 ALLOW_GEN_FUTURE: [sym::gen_future];
343 ALLOW_GEN_FUTURE_WITH_ASYNC_FN_TRACK_CALLER: [sym::gen_future, sym::closure_track_caller];
344 ALLOW_FOR_AWAIT: [sym::async_gen_internals, sym::async_iterator];
345 ALLOW_ASYNC_FN_TRAITS: [sym::async_fn_traits];
346 ALLOW_ASYNC_GEN: [sym::async_gen_internals];
347 ALLOW_ASYNC_ITERATOR: [sym::gen_future, sym::async_iterator];
350}
351
352impl<'a, 'hir> LoweringContext<'a, 'hir> {
353 fn new(tcx: TyCtxt<'hir>, resolver: &'a ResolverAstLowering<'hir>, owner: NodeId) -> Self {
354 Self {
355 tcx,
356 resolver,
357 curr_owner: PerOwnerLoweringState::new(resolver, owner),
358 arena: tcx.hir_arena,
359
360 contract_ensures: None,
361
362 next_node_id: resolver.next_node_id,
363 node_id_to_def_id: NodeMap::default(),
364 partial_res_overrides: NodeMap::default(),
365
366 try_block_scope: TryBlockScope::Function,
368 loop_scope: None,
369 is_in_loop_condition: false,
370 is_in_dyn_type: false,
371 coroutine_kind: None,
372 task_context: None,
373 current_item_span: None,
374
375 move_expr_bindings: Vec::new(),
376 lowering_move_expr_initializer: false,
377 attribute_parser: AttributeParser::new(
378 tcx.sess,
379 tcx.features(),
380 tcx.registered_attr_tools(()),
381 ShouldEmit::ErrorsAndLints { recovery: Recovery::Allowed },
382 ),
383 }
384 }
385
386 pub(crate) fn dcx(&self) -> DiagCtxtHandle<'hir> {
387 self.tcx.dcx()
388 }
389
390 fn allow_gen_future(&self) -> &Arc<[Symbol]> {
391 if self.tcx.features().async_fn_track_caller() {
392 &ALLOW_GEN_FUTURE_WITH_ASYNC_FN_TRACK_CALLER
393 } else {
394 &ALLOW_GEN_FUTURE
395 }
396 }
397}
398
399struct SpanLowerer {
400 is_incremental: bool,
401 def_id: LocalDefId,
402}
403
404impl SpanLowerer {
405 fn lower(&self, span: Span) -> Span {
406 if self.is_incremental {
407 span.with_parent(Some(self.def_id))
408 } else {
409 span
411 }
412 }
413}
414
415trait 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::Tool { .. } |
::rustc_attr_ir::Attribute::DeriveHelper(..) =>
{}
#[deny(unreachable_patterns)]
_ => {}
}
}
None
}
}
}.map(|fn_indexes|
fn_indexes.iter().map(|(num, _)| *num).collect())
}
}#[extension(trait ResolverAstLoweringExt<'tcx>)]
416impl<'tcx> ResolverAstLowering<'tcx> {
417 fn legacy_const_generic_args(&self, expr: &Expr, tcx: TyCtxt<'tcx>) -> Option<Vec<usize>> {
418 let ExprKind::Path(None, path) = &expr.kind else {
419 return None;
420 };
421
422 if path.segments.last().unwrap().args.is_some() {
425 return None;
426 }
427
428 let def_id = self.partial_res_map.get(&expr.id)?.full_res()?.opt_def_id()?;
432
433 if def_id.is_local() {
437 return None;
438 }
439
440 find_attr!(
442 tcx, def_id,
443 RustcLegacyConstGenerics{fn_indexes,..} => fn_indexes
444 )
445 .map(|fn_indexes| fn_indexes.iter().map(|(num, _)| *num).collect())
446 }
447}
448
449struct AllowedRelaxedBounds(<AllowedRelaxedBounds as
::bitflags::__private::PublicFlags>::Internal);
#[automatically_derived]impl ::core::marker::Copy for AllowedRelaxedBounds { }
#[automatically_derived]#[doc(hidden)]unsafe impl ::core::clone::TrivialClone
for AllowedRelaxedBounds {
}
#[automatically_derived]impl ::core::clone::Clone for AllowedRelaxedBounds {
#[inline]
#[rustc_trivial_field_reads]
fn clone(&self) -> Self {
let _:
::core::clone::AssertParamIsClone<<AllowedRelaxedBounds as
::bitflags::__private::PublicFlags>::Internal>;
*self
}
}
#[automatically_derived]impl ::core::fmt::Debug for AllowedRelaxedBounds {
#[inline]
#[rustc_trivial_field_reads]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::debug_struct_field1_finish(f,
"AllowedRelaxedBounds", &&self.0)
}
}
impl AllowedRelaxedBounds {
#[allow(deprecated, non_upper_case_globals,)]
pub const SIZED: Self = Self::from_bits_retain(1 << 0);
#[allow(deprecated, non_upper_case_globals,)]
pub const FORGET: Self = Self::from_bits_retain(1 << 1);
#[allow(deprecated, non_upper_case_globals,)]
pub const OTHER: Self = Self::from_bits_retain(1 << 31);
}
impl ::bitflags::Flags for AllowedRelaxedBounds {
const FLAGS: &'static [::bitflags::Flag<AllowedRelaxedBounds>] =
&[{
#[allow(deprecated, non_upper_case_globals,)]
::bitflags::Flag::new("SIZED", AllowedRelaxedBounds::SIZED)
},
{
#[allow(deprecated, non_upper_case_globals,)]
::bitflags::Flag::new("FORGET",
AllowedRelaxedBounds::FORGET)
},
{
#[allow(deprecated, non_upper_case_globals,)]
::bitflags::Flag::new("OTHER", AllowedRelaxedBounds::OTHER)
}];
type Bits = u32;
fn bits(&self) -> u32 { AllowedRelaxedBounds::bits(self) }
fn from_bits_retain(bits: u32) -> AllowedRelaxedBounds {
AllowedRelaxedBounds::from_bits_retain(bits)
}
}
#[allow(dead_code, deprecated, unused_doc_comments, unused_attributes,
unused_mut, unused_imports, non_upper_case_globals, clippy ::
assign_op_pattern, clippy :: indexing_slicing, clippy :: same_name_method,
clippy :: iter_without_into_iter,)]
const _: () =
{
#[repr(transparent)]
struct InternalBitFlags(u32);
#[automatically_derived]
#[doc(hidden)]
unsafe impl ::core::clone::TrivialClone for InternalBitFlags { }
#[automatically_derived]
impl ::core::clone::Clone for InternalBitFlags {
#[inline]
#[rustc_trivial_field_reads]
fn clone(&self) -> Self {
let _: ::core::clone::AssertParamIsClone<u32>;
*self
}
}
#[automatically_derived]
impl ::core::marker::Copy for InternalBitFlags { }
#[automatically_derived]
impl ::core::marker::StructuralPartialEq for InternalBitFlags { }
#[automatically_derived]
impl ::core::cmp::PartialEq for InternalBitFlags {
#[inline]
fn eq(&self, other: &Self) -> bool { self.0 == other.0 }
}
#[automatically_derived]
impl ::core::cmp::Eq for InternalBitFlags {
#[inline]
#[doc(hidden)]
#[coverage(off)]
fn assert_fields_are_eq(&self) {
let _: ::core::cmp::AssertParamIsEq<u32>;
}
}
#[automatically_derived]
impl ::core::cmp::PartialOrd for InternalBitFlags {
#[inline]
fn partial_cmp(&self, other: &Self)
-> ::core::option::Option<::core::cmp::Ordering> {
::core::option::Option::Some(::core::cmp::Ord::cmp(self,
other))
}
}
#[automatically_derived]
impl ::core::cmp::Ord for InternalBitFlags {
#[inline]
fn cmp(&self, other: &Self) -> ::core::cmp::Ordering {
::core::cmp::Ord::cmp(&self.0, &other.0)
}
}
#[automatically_derived]
impl ::core::hash::Hash for InternalBitFlags {
#[inline]
fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) {
::core::hash::Hash::hash(&self.0, state)
}
}
impl ::bitflags::__private::PublicFlags for AllowedRelaxedBounds {
type Primitive = u32;
type Internal = InternalBitFlags;
}
impl ::bitflags::__private::core::default::Default for
InternalBitFlags {
#[inline]
fn default() -> Self { InternalBitFlags::empty() }
}
impl ::bitflags::__private::core::fmt::Debug for InternalBitFlags {
fn fmt(&self,
f: &mut ::bitflags::__private::core::fmt::Formatter<'_>)
-> ::bitflags::__private::core::fmt::Result {
if self.is_empty() {
f.write_fmt(format_args!("{0:#x}",
<u32 as ::bitflags::Bits>::EMPTY))
} else {
::bitflags::__private::core::fmt::Display::fmt(self, f)
}
}
}
impl ::bitflags::__private::core::fmt::Display for InternalBitFlags {
fn fmt(&self,
f: &mut ::bitflags::__private::core::fmt::Formatter<'_>)
-> ::bitflags::__private::core::fmt::Result {
::bitflags::parser::to_writer(&AllowedRelaxedBounds(*self), f)
}
}
impl ::bitflags::__private::core::str::FromStr for InternalBitFlags {
type Err = ::bitflags::parser::ParseError;
fn from_str(s: &str)
->
::bitflags::__private::core::result::Result<Self,
Self::Err> {
::bitflags::parser::from_str::<AllowedRelaxedBounds>(s).map(|flags|
flags.0)
}
}
impl ::bitflags::__private::core::convert::AsRef<u32> for
InternalBitFlags {
fn as_ref(&self) -> &u32 { &self.0 }
}
impl ::bitflags::__private::core::convert::From<u32> for
InternalBitFlags {
fn from(bits: u32) -> Self { Self::from_bits_retain(bits) }
}
#[allow(dead_code, deprecated, unused_attributes)]
impl InternalBitFlags {
#[inline]
pub const fn empty() -> Self {
Self(<u32 as ::bitflags::Bits>::EMPTY)
}
#[inline]
pub const fn all() -> Self {
let mut truncated = <u32 as ::bitflags::Bits>::EMPTY;
let mut i = 0;
{
{
let flag =
<AllowedRelaxedBounds as
::bitflags::Flags>::FLAGS[i].value().bits();
truncated = truncated | flag;
i += 1;
}
};
{
{
let flag =
<AllowedRelaxedBounds as
::bitflags::Flags>::FLAGS[i].value().bits();
truncated = truncated | flag;
i += 1;
}
};
{
{
let flag =
<AllowedRelaxedBounds as
::bitflags::Flags>::FLAGS[i].value().bits();
truncated = truncated | flag;
i += 1;
}
};
let _ = i;
Self(truncated)
}
#[inline]
pub const fn bits(&self) -> u32 { self.0 }
#[inline]
pub const fn from_bits(bits: u32)
-> ::bitflags::__private::core::option::Option<Self> {
let truncated = Self::from_bits_truncate(bits).0;
if truncated == bits {
::bitflags::__private::core::option::Option::Some(Self(bits))
} else { ::bitflags::__private::core::option::Option::None }
}
#[inline]
pub const fn from_bits_truncate(bits: u32) -> Self {
Self(bits & Self::all().0)
}
#[inline]
pub const fn from_bits_retain(bits: u32) -> Self { Self(bits) }
#[inline]
pub fn from_name(name: &str)
-> ::bitflags::__private::core::option::Option<Self> {
{
if name == "SIZED" {
return ::bitflags::__private::core::option::Option::Some(Self(AllowedRelaxedBounds::SIZED.bits()));
}
};
;
{
if name == "FORGET" {
return ::bitflags::__private::core::option::Option::Some(Self(AllowedRelaxedBounds::FORGET.bits()));
}
};
;
{
if name == "OTHER" {
return ::bitflags::__private::core::option::Option::Some(Self(AllowedRelaxedBounds::OTHER.bits()));
}
};
;
let _ = name;
::bitflags::__private::core::option::Option::None
}
#[inline]
pub const fn is_empty(&self) -> bool {
self.0 == <u32 as ::bitflags::Bits>::EMPTY
}
#[inline]
pub const fn is_all(&self) -> bool {
Self::all().0 | self.0 == self.0
}
#[inline]
pub const fn intersects(&self, other: Self) -> bool {
self.0 & other.0 != <u32 as ::bitflags::Bits>::EMPTY
}
#[inline]
pub const fn contains(&self, other: Self) -> bool {
self.0 & other.0 == other.0
}
#[inline]
pub fn insert(&mut self, other: Self) {
*self = Self(self.0).union(other);
}
#[inline]
pub fn remove(&mut self, other: Self) {
*self = Self(self.0).difference(other);
}
#[inline]
pub fn toggle(&mut self, other: Self) {
*self = Self(self.0).symmetric_difference(other);
}
#[inline]
pub fn set(&mut self, other: Self, value: bool) {
if value { self.insert(other); } else { self.remove(other); }
}
#[inline]
#[must_use]
pub const fn intersection(self, other: Self) -> Self {
Self(self.0 & other.0)
}
#[inline]
#[must_use]
pub const fn union(self, other: Self) -> Self {
Self(self.0 | other.0)
}
#[inline]
#[must_use]
pub const fn difference(self, other: Self) -> Self {
Self(self.0 & !other.0)
}
#[inline]
#[must_use]
pub const fn symmetric_difference(self, other: Self) -> Self {
Self(self.0 ^ other.0)
}
#[inline]
#[must_use]
pub const fn complement(self) -> Self {
Self::from_bits_truncate(!self.0)
}
}
impl ::bitflags::__private::core::fmt::Binary for InternalBitFlags {
fn fmt(&self, f: &mut ::bitflags::__private::core::fmt::Formatter)
-> ::bitflags::__private::core::fmt::Result {
let inner = self.0;
::bitflags::__private::core::fmt::Binary::fmt(&inner, f)
}
}
impl ::bitflags::__private::core::fmt::Octal for InternalBitFlags {
fn fmt(&self, f: &mut ::bitflags::__private::core::fmt::Formatter)
-> ::bitflags::__private::core::fmt::Result {
let inner = self.0;
::bitflags::__private::core::fmt::Octal::fmt(&inner, f)
}
}
impl ::bitflags::__private::core::fmt::LowerHex for InternalBitFlags {
fn fmt(&self, f: &mut ::bitflags::__private::core::fmt::Formatter)
-> ::bitflags::__private::core::fmt::Result {
let inner = self.0;
::bitflags::__private::core::fmt::LowerHex::fmt(&inner, f)
}
}
impl ::bitflags::__private::core::fmt::UpperHex for InternalBitFlags {
fn fmt(&self, f: &mut ::bitflags::__private::core::fmt::Formatter)
-> ::bitflags::__private::core::fmt::Result {
let inner = self.0;
::bitflags::__private::core::fmt::UpperHex::fmt(&inner, f)
}
}
impl ::bitflags::__private::core::ops::BitOr for InternalBitFlags {
type Output = Self;
#[inline]
fn bitor(self, other: InternalBitFlags) -> Self {
self.union(other)
}
}
impl ::bitflags::__private::core::ops::BitOrAssign for
InternalBitFlags {
#[inline]
fn bitor_assign(&mut self, other: Self) { self.insert(other); }
}
impl ::bitflags::__private::core::ops::BitXor for InternalBitFlags {
type Output = Self;
#[inline]
fn bitxor(self, other: Self) -> Self {
self.symmetric_difference(other)
}
}
impl ::bitflags::__private::core::ops::BitXorAssign for
InternalBitFlags {
#[inline]
fn bitxor_assign(&mut self, other: Self) { self.toggle(other); }
}
impl ::bitflags::__private::core::ops::BitAnd for InternalBitFlags {
type Output = Self;
#[inline]
fn bitand(self, other: Self) -> Self { self.intersection(other) }
}
impl ::bitflags::__private::core::ops::BitAndAssign for
InternalBitFlags {
#[inline]
fn bitand_assign(&mut self, other: Self) {
*self =
Self::from_bits_retain(self.bits()).intersection(other);
}
}
impl ::bitflags::__private::core::ops::Sub for InternalBitFlags {
type Output = Self;
#[inline]
fn sub(self, other: Self) -> Self { self.difference(other) }
}
impl ::bitflags::__private::core::ops::SubAssign for InternalBitFlags
{
#[inline]
fn sub_assign(&mut self, other: Self) { self.remove(other); }
}
impl ::bitflags::__private::core::ops::Not for InternalBitFlags {
type Output = Self;
#[inline]
fn not(self) -> Self { self.complement() }
}
impl ::bitflags::__private::core::iter::Extend<InternalBitFlags> for
InternalBitFlags {
fn extend<T: ::bitflags::__private::core::iter::IntoIterator<Item
= Self>>(&mut self, iterator: T) {
for item in iterator { self.insert(item) }
}
}
impl ::bitflags::__private::core::iter::FromIterator<InternalBitFlags>
for InternalBitFlags {
fn from_iter<T: ::bitflags::__private::core::iter::IntoIterator<Item
= Self>>(iterator: T) -> Self {
use ::bitflags::__private::core::iter::Extend;
let mut result = Self::empty();
result.extend(iterator);
result
}
}
impl InternalBitFlags {
#[inline]
pub const fn iter(&self)
-> ::bitflags::iter::Iter<AllowedRelaxedBounds> {
::bitflags::iter::Iter::__private_const_new(<AllowedRelaxedBounds
as ::bitflags::Flags>::FLAGS,
AllowedRelaxedBounds::from_bits_retain(self.bits()),
AllowedRelaxedBounds::from_bits_retain(self.bits()))
}
#[inline]
pub const fn iter_names(&self)
-> ::bitflags::iter::IterNames<AllowedRelaxedBounds> {
::bitflags::iter::IterNames::__private_const_new(<AllowedRelaxedBounds
as ::bitflags::Flags>::FLAGS,
AllowedRelaxedBounds::from_bits_retain(self.bits()),
AllowedRelaxedBounds::from_bits_retain(self.bits()))
}
}
impl ::bitflags::__private::core::iter::IntoIterator for
InternalBitFlags {
type Item = AllowedRelaxedBounds;
type IntoIter = ::bitflags::iter::Iter<AllowedRelaxedBounds>;
fn into_iter(self) -> Self::IntoIter { self.iter() }
}
impl InternalBitFlags {
#[inline]
pub fn bits_mut(&mut self) -> &mut u32 { &mut self.0 }
}
#[allow(dead_code, deprecated, unused_attributes)]
impl AllowedRelaxedBounds {
#[inline]
pub const fn empty() -> Self { Self(InternalBitFlags::empty()) }
#[inline]
pub const fn all() -> Self { Self(InternalBitFlags::all()) }
#[inline]
pub const fn bits(&self) -> u32 { self.0.bits() }
#[inline]
pub const fn from_bits(bits: u32)
-> ::bitflags::__private::core::option::Option<Self> {
match InternalBitFlags::from_bits(bits) {
::bitflags::__private::core::option::Option::Some(bits) =>
::bitflags::__private::core::option::Option::Some(Self(bits)),
::bitflags::__private::core::option::Option::None =>
::bitflags::__private::core::option::Option::None,
}
}
#[inline]
pub const fn from_bits_truncate(bits: u32) -> Self {
Self(InternalBitFlags::from_bits_truncate(bits))
}
#[inline]
pub const fn from_bits_retain(bits: u32) -> Self {
Self(InternalBitFlags::from_bits_retain(bits))
}
#[inline]
pub fn from_name(name: &str)
-> ::bitflags::__private::core::option::Option<Self> {
match InternalBitFlags::from_name(name) {
::bitflags::__private::core::option::Option::Some(bits) =>
::bitflags::__private::core::option::Option::Some(Self(bits)),
::bitflags::__private::core::option::Option::None =>
::bitflags::__private::core::option::Option::None,
}
}
#[inline]
pub const fn is_empty(&self) -> bool { self.0.is_empty() }
#[inline]
pub const fn is_all(&self) -> bool { self.0.is_all() }
#[inline]
pub const fn intersects(&self, other: Self) -> bool {
self.0.intersects(other.0)
}
#[inline]
pub const fn contains(&self, other: Self) -> bool {
self.0.contains(other.0)
}
#[inline]
pub fn insert(&mut self, other: Self) { self.0.insert(other.0) }
#[inline]
pub fn remove(&mut self, other: Self) { self.0.remove(other.0) }
#[inline]
pub fn toggle(&mut self, other: Self) { self.0.toggle(other.0) }
#[inline]
pub fn set(&mut self, other: Self, value: bool) {
self.0.set(other.0, value)
}
#[inline]
#[must_use]
pub const fn intersection(self, other: Self) -> Self {
Self(self.0.intersection(other.0))
}
#[inline]
#[must_use]
pub const fn union(self, other: Self) -> Self {
Self(self.0.union(other.0))
}
#[inline]
#[must_use]
pub const fn difference(self, other: Self) -> Self {
Self(self.0.difference(other.0))
}
#[inline]
#[must_use]
pub const fn symmetric_difference(self, other: Self) -> Self {
Self(self.0.symmetric_difference(other.0))
}
#[inline]
#[must_use]
pub const fn complement(self) -> Self {
Self(self.0.complement())
}
}
impl ::bitflags::__private::core::fmt::Binary for AllowedRelaxedBounds
{
fn fmt(&self, f: &mut ::bitflags::__private::core::fmt::Formatter)
-> ::bitflags::__private::core::fmt::Result {
let inner = self.0;
::bitflags::__private::core::fmt::Binary::fmt(&inner, f)
}
}
impl ::bitflags::__private::core::fmt::Octal for AllowedRelaxedBounds
{
fn fmt(&self, f: &mut ::bitflags::__private::core::fmt::Formatter)
-> ::bitflags::__private::core::fmt::Result {
let inner = self.0;
::bitflags::__private::core::fmt::Octal::fmt(&inner, f)
}
}
impl ::bitflags::__private::core::fmt::LowerHex for
AllowedRelaxedBounds {
fn fmt(&self, f: &mut ::bitflags::__private::core::fmt::Formatter)
-> ::bitflags::__private::core::fmt::Result {
let inner = self.0;
::bitflags::__private::core::fmt::LowerHex::fmt(&inner, f)
}
}
impl ::bitflags::__private::core::fmt::UpperHex for
AllowedRelaxedBounds {
fn fmt(&self, f: &mut ::bitflags::__private::core::fmt::Formatter)
-> ::bitflags::__private::core::fmt::Result {
let inner = self.0;
::bitflags::__private::core::fmt::UpperHex::fmt(&inner, f)
}
}
impl ::bitflags::__private::core::ops::BitOr for AllowedRelaxedBounds
{
type Output = Self;
#[inline]
fn bitor(self, other: AllowedRelaxedBounds) -> Self {
self.union(other)
}
}
impl ::bitflags::__private::core::ops::BitOrAssign for
AllowedRelaxedBounds {
#[inline]
fn bitor_assign(&mut self, other: Self) { self.insert(other); }
}
impl ::bitflags::__private::core::ops::BitXor for AllowedRelaxedBounds
{
type Output = Self;
#[inline]
fn bitxor(self, other: Self) -> Self {
self.symmetric_difference(other)
}
}
impl ::bitflags::__private::core::ops::BitXorAssign for
AllowedRelaxedBounds {
#[inline]
fn bitxor_assign(&mut self, other: Self) { self.toggle(other); }
}
impl ::bitflags::__private::core::ops::BitAnd for AllowedRelaxedBounds
{
type Output = Self;
#[inline]
fn bitand(self, other: Self) -> Self { self.intersection(other) }
}
impl ::bitflags::__private::core::ops::BitAndAssign for
AllowedRelaxedBounds {
#[inline]
fn bitand_assign(&mut self, other: Self) {
*self =
Self::from_bits_retain(self.bits()).intersection(other);
}
}
impl ::bitflags::__private::core::ops::Sub for AllowedRelaxedBounds {
type Output = Self;
#[inline]
fn sub(self, other: Self) -> Self { self.difference(other) }
}
impl ::bitflags::__private::core::ops::SubAssign for
AllowedRelaxedBounds {
#[inline]
fn sub_assign(&mut self, other: Self) { self.remove(other); }
}
impl ::bitflags::__private::core::ops::Not for AllowedRelaxedBounds {
type Output = Self;
#[inline]
fn not(self) -> Self { self.complement() }
}
impl ::bitflags::__private::core::iter::Extend<AllowedRelaxedBounds>
for AllowedRelaxedBounds {
fn extend<T: ::bitflags::__private::core::iter::IntoIterator<Item
= Self>>(&mut self, iterator: T) {
for item in iterator { self.insert(item) }
}
}
impl ::bitflags::__private::core::iter::FromIterator<AllowedRelaxedBounds>
for AllowedRelaxedBounds {
fn from_iter<T: ::bitflags::__private::core::iter::IntoIterator<Item
= Self>>(iterator: T) -> Self {
use ::bitflags::__private::core::iter::Extend;
let mut result = Self::empty();
result.extend(iterator);
result
}
}
impl AllowedRelaxedBounds {
#[inline]
pub const fn iter(&self)
-> ::bitflags::iter::Iter<AllowedRelaxedBounds> {
::bitflags::iter::Iter::__private_const_new(<AllowedRelaxedBounds
as ::bitflags::Flags>::FLAGS,
AllowedRelaxedBounds::from_bits_retain(self.bits()),
AllowedRelaxedBounds::from_bits_retain(self.bits()))
}
#[inline]
pub const fn iter_names(&self)
-> ::bitflags::iter::IterNames<AllowedRelaxedBounds> {
::bitflags::iter::IterNames::__private_const_new(<AllowedRelaxedBounds
as ::bitflags::Flags>::FLAGS,
AllowedRelaxedBounds::from_bits_retain(self.bits()),
AllowedRelaxedBounds::from_bits_retain(self.bits()))
}
}
impl ::bitflags::__private::core::iter::IntoIterator for
AllowedRelaxedBounds {
type Item = AllowedRelaxedBounds;
type IntoIter = ::bitflags::iter::Iter<AllowedRelaxedBounds>;
fn into_iter(self) -> Self::IntoIter { self.iter() }
}
};bitflags::bitflags! {
450 #[derive(Copy, Clone, Debug)]
451 struct AllowedRelaxedBounds: u32 {
452 const SIZED = 1 << 0;
453 const FORGET = 1 << 1;
454 const OTHER = 1 << 31;
456 }
457}
458
459#[derive(#[automatically_derived]impl<'a> ::core::fmt::Debug for RelaxedBoundPolicy<'a>
{
#[inline]
#[rustc_trivial_field_reads]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::debug_struct_field3_finish(f,
"RelaxedBoundPolicy dedup reason allowed_bounds", &self.dedup,
&self.reason, &&self.allowed_bounds)
}
}Debug)]
464struct RelaxedBoundPolicy<'a> {
465 dedup: &'a mut FxIndexMap<DefId, Span>,
467 reason: Option<RelaxedBoundForbiddenReason>,
468 allowed_bounds: AllowedRelaxedBounds,
469}
470
471impl<'a> RelaxedBoundPolicy<'a> {
472 fn allow_all(dedup: &'a mut FxIndexMap<DefId, Span>) -> Self {
473 Self { dedup, reason: None, allowed_bounds: AllowedRelaxedBounds::all() }
474 }
475
476 fn forbidden(
477 dedup: &'a mut FxIndexMap<DefId, Span>,
478 reason: RelaxedBoundForbiddenReason,
479 ) -> Self {
480 Self { dedup, reason: Some(reason), allowed_bounds: AllowedRelaxedBounds::empty() }
481 }
482
483 #[expect(unused)]
485 fn allow_some(
486 dedup: &'a mut FxIndexMap<DefId, Span>,
487 reason: RelaxedBoundForbiddenReason,
488 allowed_bounds: AllowedRelaxedBounds,
489 ) -> Self {
490 Self { dedup, reason: Some(reason), allowed_bounds }
491 }
492
493 fn reborrow(&mut self) -> RelaxedBoundPolicy<'_> {
494 let &mut Self { ref mut dedup, reason, allowed_bounds } = self;
495 RelaxedBoundPolicy { dedup, reason, allowed_bounds }
496 }
497}
498
499#[derive(#[automatically_derived]#[doc(hidden)]unsafe impl ::core::clone::TrivialClone
for RelaxedBoundForbiddenReason {
}
#[automatically_derived]impl ::core::clone::Clone for
RelaxedBoundForbiddenReason {
#[inline]
#[rustc_trivial_field_reads]
fn clone(&self) -> Self { *self }
}Clone, #[automatically_derived]impl ::core::marker::Copy for
RelaxedBoundForbiddenReason {
}Copy, #[automatically_derived]impl ::core::fmt::Debug for
RelaxedBoundForbiddenReason {
#[inline]
#[rustc_trivial_field_reads]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::debug_c_like_enum_write_str(f,
"TraitObjectTy SuperTrait TraitAlias AssocTyBounds WhereBound",
match self {
RelaxedBoundForbiddenReason::TraitObjectTy => 0usize,
RelaxedBoundForbiddenReason::SuperTrait => 14usize,
RelaxedBoundForbiddenReason::TraitAlias => 25usize,
RelaxedBoundForbiddenReason::AssocTyBounds => 36usize,
RelaxedBoundForbiddenReason::WhereBound => 50usize,
})
}
}Debug)]
500enum RelaxedBoundForbiddenReason {
501 TraitObjectTy,
502 SuperTrait,
503 TraitAlias,
504 AssocTyBounds,
505 WhereBound,
508}
509
510#[derive(#[automatically_derived]impl ::core::fmt::Debug for ImplTraitContext {
#[inline]
#[rustc_trivial_field_reads]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
match self {
Self::Universal =>
::core::fmt::Formatter::write_str(f, "Universal"),
Self::OpaqueTy { origin: __self_0 } =>
::core::fmt::Formatter::debug_struct_field1_finish(f,
"OpaqueTy origin", &__self_0),
Self::InBinding =>
::core::fmt::Formatter::write_str(f, "InBinding"),
Self::FeatureGated(__self_0, __self_1) =>
::core::fmt::Formatter::debug_struct_field2_finish(f,
"FeatureGated", __self_0, &__self_1),
Self::Disallowed(__self_0) =>
::core::fmt::Formatter::debug_struct_field1_finish(f,
"Disallowed", &__self_0),
Self::AlreadyErrored(__self_0) =>
::core::fmt::Formatter::debug_struct_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]
#[rustc_trivial_field_reads]
fn clone(&self) -> Self {
let _:
::core::clone::AssertParamIsClone<hir::OpaqueTyOrigin<LocalDefId>>;
let _: ::core::clone::AssertParamIsClone<ImplTraitPosition>;
let _: ::core::clone::AssertParamIsClone<Symbol>;
let _: ::core::clone::AssertParamIsClone<ErrorGuaranteed>;
*self
}
}Clone, #[automatically_derived]impl ::core::marker::StructuralPartialEq for
ImplTraitContext {
}
#[automatically_derived]impl ::core::cmp::PartialEq for ImplTraitContext {
#[inline]
fn eq(&self, other: &Self) -> bool {
::core::intrinsics::discriminant_value(self) ==
::core::intrinsics::discriminant_value(other) &&
match (self, other) {
(Self::OpaqueTy { origin: __self_0 }, Self::OpaqueTy {
origin: __arg1_0 }) => __self_0 == __arg1_0,
(Self::FeatureGated(__self_0, __self_1),
Self::FeatureGated(__arg1_0, __arg1_1)) =>
__self_0 == __arg1_0 && __self_1 == __arg1_1,
(Self::Disallowed(__self_0), Self::Disallowed(__arg1_0)) =>
__self_0 == __arg1_0,
(Self::AlreadyErrored(__self_0),
Self::AlreadyErrored(__arg1_0)) => __self_0 == __arg1_0,
_ => true,
}
}
}PartialEq, #[automatically_derived]impl ::core::cmp::Eq for ImplTraitContext {
#[inline]
#[doc(hidden)]
#[coverage(off)]
fn assert_fields_are_eq(&self) {
let _: ::core::cmp::AssertParamIsEq<hir::OpaqueTyOrigin<LocalDefId>>;
let _: ::core::cmp::AssertParamIsEq<ImplTraitPosition>;
let _: ::core::cmp::AssertParamIsEq<Symbol>;
let _: ::core::cmp::AssertParamIsEq<ErrorGuaranteed>;
}
}Eq)]
513enum ImplTraitContext {
514 Universal,
520
521 OpaqueTy { origin: hir::OpaqueTyOrigin<LocalDefId> },
526
527 InBinding,
532
533 FeatureGated(ImplTraitPosition, Symbol),
535 Disallowed(ImplTraitPosition),
537
538 AlreadyErrored(ErrorGuaranteed),
540}
541
542#[derive(#[automatically_derived]impl ::core::fmt::Debug for ImplTraitPosition {
#[inline]
#[rustc_trivial_field_reads]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::debug_c_like_enum_write_str(f,
"Path Variable Trait Bound Generic ExternFnParam ClosureParam PointerParam FnTraitParam ExternFnReturn ClosureReturn PointerReturn FnTraitReturn GenericDefault ConstTy StaticTy AssocTy FieldTy Cast ImplSelf OffsetOf",
match self {
ImplTraitPosition::Path => 0usize,
ImplTraitPosition::Variable => 5usize,
ImplTraitPosition::Trait => 14usize,
ImplTraitPosition::Bound => 20usize,
ImplTraitPosition::Generic => 26usize,
ImplTraitPosition::ExternFnParam => 34usize,
ImplTraitPosition::ClosureParam => 48usize,
ImplTraitPosition::PointerParam => 61usize,
ImplTraitPosition::FnTraitParam => 74usize,
ImplTraitPosition::ExternFnReturn => 87usize,
ImplTraitPosition::ClosureReturn => 102usize,
ImplTraitPosition::PointerReturn => 116usize,
ImplTraitPosition::FnTraitReturn => 130usize,
ImplTraitPosition::GenericDefault => 144usize,
ImplTraitPosition::ConstTy => 159usize,
ImplTraitPosition::StaticTy => 167usize,
ImplTraitPosition::AssocTy => 176usize,
ImplTraitPosition::FieldTy => 184usize,
ImplTraitPosition::Cast => 192usize,
ImplTraitPosition::ImplSelf => 197usize,
ImplTraitPosition::OffsetOf => 206usize,
})
}
}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]
#[rustc_trivial_field_reads]
fn clone(&self) -> Self { *self }
}Clone, #[automatically_derived]impl ::core::marker::StructuralPartialEq for
ImplTraitPosition {
}
#[automatically_derived]impl ::core::cmp::PartialEq for ImplTraitPosition {
#[inline]
fn eq(&self, other: &Self) -> bool {
::core::intrinsics::discriminant_value(self) ==
::core::intrinsics::discriminant_value(other)
}
}PartialEq, #[automatically_derived]impl ::core::cmp::Eq for ImplTraitPosition { }Eq)]
544enum ImplTraitPosition {
545 Path,
546 Variable,
547 Trait,
548 Bound,
549 Generic,
550 ExternFnParam,
551 ClosureParam,
552 PointerParam,
553 FnTraitParam,
554 ExternFnReturn,
555 ClosureReturn,
556 PointerReturn,
557 FnTraitReturn,
558 GenericDefault,
559 ConstTy,
560 StaticTy,
561 AssocTy,
562 FieldTy,
563 Cast,
564 ImplSelf,
565 OffsetOf,
566}
567
568impl std::fmt::Display for ImplTraitPosition {
569 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
570 let name = match self {
571 ImplTraitPosition::Path => "paths",
572 ImplTraitPosition::Variable => "the type of variable bindings",
573 ImplTraitPosition::Trait => "traits",
574 ImplTraitPosition::Bound => "bounds",
575 ImplTraitPosition::Generic => "generics",
576 ImplTraitPosition::ExternFnParam => "`extern fn` parameters",
577 ImplTraitPosition::ClosureParam => "closure parameters",
578 ImplTraitPosition::PointerParam => "`fn` pointer parameters",
579 ImplTraitPosition::FnTraitParam => "the parameters of `Fn` trait bounds",
580 ImplTraitPosition::ExternFnReturn => "`extern fn` return types",
581 ImplTraitPosition::ClosureReturn => "closure return types",
582 ImplTraitPosition::PointerReturn => "`fn` pointer return types",
583 ImplTraitPosition::FnTraitReturn => "the return type of `Fn` trait bounds",
584 ImplTraitPosition::GenericDefault => "generic parameter defaults",
585 ImplTraitPosition::ConstTy => "const types",
586 ImplTraitPosition::StaticTy => "static types",
587 ImplTraitPosition::AssocTy => "associated types",
588 ImplTraitPosition::FieldTy => "field types",
589 ImplTraitPosition::Cast => "cast expression types",
590 ImplTraitPosition::ImplSelf => "impl headers",
591 ImplTraitPosition::OffsetOf => "`offset_of!` parameters",
592 };
593
594 f.write_fmt(format_args!("{0}", name))write!(f, "{name}")
595 }
596}
597
598#[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]
#[rustc_trivial_field_reads]
fn clone(&self) -> Self { *self }
}Clone, #[automatically_derived]impl ::core::fmt::Debug for FnDeclKind {
#[inline]
#[rustc_trivial_field_reads]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::debug_c_like_enum_write_str(f,
"Fn Inherent ExternFn Closure Pointer Trait Impl",
match self {
FnDeclKind::Fn => 0usize,
FnDeclKind::Inherent => 3usize,
FnDeclKind::ExternFn => 12usize,
FnDeclKind::Closure => 21usize,
FnDeclKind::Pointer => 29usize,
FnDeclKind::Trait => 37usize,
FnDeclKind::Impl => 43usize,
})
}
}Debug, #[automatically_derived]impl ::core::marker::StructuralPartialEq for
FnDeclKind {
}
#[automatically_derived]impl ::core::cmp::PartialEq for FnDeclKind {
#[inline]
fn eq(&self, other: &Self) -> bool {
::core::intrinsics::discriminant_value(self) ==
::core::intrinsics::discriminant_value(other)
}
}PartialEq, #[automatically_derived]impl ::core::cmp::Eq for FnDeclKind { }Eq)]
599enum FnDeclKind {
600 Fn,
601 Inherent,
602 ExternFn,
603 Closure,
604 Pointer,
605 Trait,
606 Impl,
607}
608
609#[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]
#[rustc_trivial_field_reads]
fn clone(&self) -> Self {
let _: ::core::clone::AssertParamIsClone<HirId>;
*self
}
}Clone, #[automatically_derived]impl ::core::fmt::Debug for TryBlockScope {
#[inline]
#[rustc_trivial_field_reads]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
match self {
Self::Function =>
::core::fmt::Formatter::write_str(f, "Function"),
Self::Homogeneous(__self_0) =>
::core::fmt::Formatter::debug_struct_field1_finish(f,
"Homogeneous", &__self_0),
Self::Heterogeneous(__self_0) =>
::core::fmt::Formatter::debug_struct_field1_finish(f,
"Heterogeneous", &__self_0),
}
}
}Debug)]
610enum TryBlockScope {
611 Function,
613 Homogeneous(HirId),
616 Heterogeneous(HirId),
619}
620
621fn index_ast<'tcx>(
622 tcx: TyCtxt<'tcx>,
623 (): (),
624) -> &'tcx IndexSlice<LocalDefId, Option<Steal<(Arc<ResolverAstLowering<'tcx>>, AstOwner)>>> {
625 tcx.ensure_done().output_filenames(());
627 tcx.ensure_done().early_lint_checks(());
628 tcx.ensure_done().get_lang_items(());
629 tcx.ensure_done().debugger_visualizers(LOCAL_CRATE);
630
631 let (resolver, krate) = tcx.resolver_for_lowering();
632 let mut resolver = resolver.steal();
633 let mut krate = krate.steal();
634
635 let mut indexer = Indexer {
636 owners: &resolver.owners,
637 index: IndexVec::new(),
638 next_node_id: resolver.next_node_id,
639 };
640 indexer.visit_crate(&mut krate);
641 indexer.insert(CRATE_NODE_ID, AstOwner::Crate(Box::new(krate)));
642 resolver.next_node_id = indexer.next_node_id;
643
644 let index = indexer.index;
645 let resolver = Arc::new(resolver);
646 return tcx.arena.alloc_index_slice_from_iter::<LocalDefId, _, _>(
647 index.into_iter().map(|owner| owner.map(|o| Steal::new((Arc::clone(&resolver), o)))),
648 );
649
650 struct Indexer<'s, 'hir> {
651 owners: &'s NodeMap<PerOwnerResolverData<'hir>>,
652 index: IndexVec<LocalDefId, Option<AstOwner>>,
653 next_node_id: NodeId,
654 }
655
656 impl Indexer<'_, '_> {
657 fn insert(&mut self, id: NodeId, node: AstOwner) {
658 let def_id = self.owners[&id].def_id;
659 self.index.insert(def_id, node);
660 }
661
662 fn make_dummy<K>(
663 &mut self,
664 id: NodeId,
665 span: Span,
666 dummy: impl FnOnce(Box<MacCall>) -> K,
667 ) -> Box<Item<K>> {
668 use rustc_ast::token::Delimiter;
669 use rustc_ast::tokenstream::{DelimSpan, TokenStream};
670 use thin_vec::thin_vec;
671
672 Box::new(Item {
673 attrs: AttrVec::default(),
674 id,
675 span,
676 vis: Visibility { kind: VisibilityKind::Public, span },
677 kind: dummy(Box::new(MacCall {
680 path: Path { span, segments: ::thin_vec::ThinVec::new()thin_vec![] },
681 args: Box::new(DelimArgs {
682 dspan: DelimSpan::from_single(span),
683 delim: Delimiter::Parenthesis,
684 tokens: TokenStream::new(Vec::new()),
685 }),
686 })),
687 tokens: None,
688 })
689 }
690
691 fn replace_with_dummy<K>(
692 &mut self,
693 item: &mut ast::Item<K>,
694 dummy: impl FnOnce(Box<MacCall>) -> K,
695 node: impl FnOnce(Box<Item<K>>) -> AstOwner,
696 ) {
697 let dummy = self.make_dummy(item.id, item.span, dummy);
698 let item = mem::replace(item, *dummy);
699 self.insert(item.id, node(Box::new(item)));
700 }
701 }
702
703 impl MutVisitor for Indexer<'_, '_> {
704 fn visit_attribute(&mut self, _: &mut Attribute) {
705 }
708
709 fn flat_map_item(&mut self, mut item: Box<Item>) -> SmallVec<[Box<Item>; 1]> {
710 mut_visit::walk_item(self, &mut *item);
711 let dummy = self.make_dummy(item.id, item.span, ItemKind::MacCall);
712 let items = {
let count = 0usize + 1usize;
let mut vec = ::smallvec::SmallVec::new();
if count <= vec.inline_size() {
vec.push(dummy);
vec
} else {
::smallvec::SmallVec::from_vec(::alloc::boxed::box_assume_init_into_vec_unsafe(::alloc::intrinsics::write_box_via_move(::alloc::boxed::Box::new_uninit(),
[dummy])))
}
}smallvec![dummy];
713 self.insert(item.id, AstOwner::Item(item));
714 items
715 }
716
717 fn visit_assoc_item(&mut self, item: &mut AssocItem, ctxt: visit::AssocCtxt) {
718 mut_visit::walk_assoc_item(self, item, ctxt);
719 match ctxt {
720 visit::AssocCtxt::Trait => {
721 self.replace_with_dummy(item, AssocItemKind::MacCall, AstOwner::TraitItem)
722 }
723 visit::AssocCtxt::Impl { .. } => {
724 self.replace_with_dummy(item, AssocItemKind::MacCall, AstOwner::ImplItem)
725 }
726 }
727 }
728
729 fn visit_foreign_item(&mut self, item: &mut ForeignItem) {
730 mut_visit::walk_item(self, item);
731 self.replace_with_dummy(item, ForeignItemKind::MacCall, AstOwner::ForeignItem);
732 }
733 }
734}
735
736{}
#[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/6905905bb7727fd0f9223f5fdc9ad4e62236d5a2/compiler/rustc_ast_lowering/src/lib.rs"),
::tracing_core::__macro_support::Option::Some(736u32),
::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);
let fallback_to_ancestor =
||
{
let parent_id = tcx.local_parent(def_id);
let mut parent_info = tcx.lower_to_hir(parent_id);
while let hir::MaybeOwner::NonOwner(hir_id) = parent_info {
parent_info = tcx.lower_to_hir(hir_id.owner);
}
let parent_info = parent_info.unwrap();
*parent_info.children.get(&def_id).unwrap_or_else(||
{
::rustc_span::macros::bug_impl(Some(tcx.source_span(def_id)),
format_args!("{0:?} does not appear in children of {1:?}",
def_id, parent_info.nodes.node().def_id()),
Location::caller())
})
};
let Some(Some(r_and_node)) =
resolver_and_node else { return fallback_to_ancestor(); };
fn with_lctx<'hir>(tcx: TyCtxt<'hir>,
resolver: &ResolverAstLowering<'hir>, owner: NodeId,
f:
impl FnOnce(&mut LoweringContext<'_, 'hir>)
-> hir::OwnerNode<'hir>) -> hir::MaybeOwner<'hir> {
let mut lctx = LoweringContext::new(tcx, resolver, owner);
let item = f(&mut lctx);
hir::MaybeOwner::Owner(lctx.curr_owner.into_owner_info(tcx,
item))
}
let (resolver, node) = r_and_node.steal();
let item =
match &node {
AstOwner::Crate(c) =>
with_lctx(tcx, &*resolver, CRATE_NODE_ID,
|lctx|
{
if true {
{
match (&lctx.curr_owner.owner_id(), &CRATE_OWNER_ID) {
(left_val, right_val) => {
if !(*left_val == *right_val) {
let kind = ::core::panicking::AssertKind::Eq;
::core::panicking::assert_failed(kind, &*left_val,
&*right_val, ::core::option::Option::None);
}
}
}
};
};
let module = lctx.lower_mod(&c.items, &c.spans);
lctx.lower_attrs(hir::CRATE_HIR_ID, &c.attrs,
c.spans.inner_span, AstTarget::Crate(c));
hir::OwnerNode::Crate(module)
}),
AstOwner::Item(item) => {
with_lctx(tcx, &*resolver, item.id,
|lctx| hir::OwnerNode::Item(lctx.lower_item(item)))
}
AstOwner::TraitItem(item) =>
with_lctx(tcx, &*resolver, item.id,
|lctx|
{ hir::OwnerNode::TraitItem(lctx.lower_trait_item(item)) }),
AstOwner::ImplItem(item) =>
with_lctx(tcx, &*resolver, item.id,
|lctx|
{ hir::OwnerNode::ImplItem(lctx.lower_impl_item(item)) }),
AstOwner::ForeignItem(item) =>
with_lctx(tcx, &*resolver, item.id,
|lctx|
{
hir::OwnerNode::ForeignItem(lctx.lower_foreign_item(item))
}),
};
tcx.sess.time("drop_ast", || mem::drop(node));
item
}
}
}#[instrument(level = "trace", skip(tcx))]
737fn lower_to_hir(tcx: TyCtxt<'_>, def_id: LocalDefId) -> hir::MaybeOwner<'_> {
738 tcx.ensure_done().resolve_type_relative_delegations(());
739
740 let ast_index = tcx.index_ast(());
741 let resolver_and_node = ast_index.get(def_id);
742
743 let fallback_to_ancestor = || {
744 let parent_id = tcx.local_parent(def_id);
747 let mut parent_info = tcx.lower_to_hir(parent_id);
748 while let hir::MaybeOwner::NonOwner(hir_id) = parent_info {
749 parent_info = tcx.lower_to_hir(hir_id.owner);
755 }
756
757 let parent_info = parent_info.unwrap();
758 *parent_info.children.get(&def_id).unwrap_or_else(|| {
759 span_bug!(
760 tcx.source_span(def_id),
761 "{:?} does not appear in children of {:?}",
762 def_id,
763 parent_info.nodes.node().def_id()
764 )
765 })
766 };
767
768 let Some(Some(r_and_node)) = resolver_and_node else {
769 return fallback_to_ancestor();
776 };
777
778 fn with_lctx<'hir>(
779 tcx: TyCtxt<'hir>,
780 resolver: &ResolverAstLowering<'hir>,
781 owner: NodeId,
782 f: impl FnOnce(&mut LoweringContext<'_, 'hir>) -> hir::OwnerNode<'hir>,
783 ) -> hir::MaybeOwner<'hir> {
784 let mut lctx = LoweringContext::new(tcx, resolver, owner);
785 let item = f(&mut lctx);
786 hir::MaybeOwner::Owner(lctx.curr_owner.into_owner_info(tcx, item))
787 }
788
789 let (resolver, node) = r_and_node.steal();
790
791 let item = match &node {
792 AstOwner::Crate(c) => with_lctx(tcx, &*resolver, CRATE_NODE_ID, |lctx| {
794 debug_assert_eq!(lctx.curr_owner.owner_id(), CRATE_OWNER_ID);
795 let module = lctx.lower_mod(&c.items, &c.spans);
796 lctx.lower_attrs(hir::CRATE_HIR_ID, &c.attrs, c.spans.inner_span, AstTarget::Crate(c));
797 hir::OwnerNode::Crate(module)
798 }),
799 AstOwner::Item(item) => {
800 with_lctx(tcx, &*resolver, item.id, |lctx| hir::OwnerNode::Item(lctx.lower_item(item)))
801 }
802 AstOwner::TraitItem(item) => with_lctx(tcx, &*resolver, item.id, |lctx| {
803 hir::OwnerNode::TraitItem(lctx.lower_trait_item(item))
804 }),
805 AstOwner::ImplItem(item) => with_lctx(tcx, &*resolver, item.id, |lctx| {
806 hir::OwnerNode::ImplItem(lctx.lower_impl_item(item))
807 }),
808 AstOwner::ForeignItem(item) => with_lctx(tcx, &*resolver, item.id, |lctx| {
809 hir::OwnerNode::ForeignItem(lctx.lower_foreign_item(item))
810 }),
811 };
812
813 tcx.sess.time("drop_ast", || mem::drop(node));
814
815 item
816}
817
818#[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]
#[rustc_trivial_field_reads]
fn clone(&self) -> Self { *self }
}Clone, #[automatically_derived]impl ::core::marker::StructuralPartialEq for ParamMode
{
}
#[automatically_derived]impl ::core::cmp::PartialEq for ParamMode {
#[inline]
fn eq(&self, other: &Self) -> bool {
::core::intrinsics::discriminant_value(self) ==
::core::intrinsics::discriminant_value(other)
}
}PartialEq, #[automatically_derived]impl ::core::fmt::Debug for ParamMode {
#[inline]
#[rustc_trivial_field_reads]
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)]
819enum ParamMode {
820 Explicit,
822 Optional,
824}
825
826#[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]
#[rustc_trivial_field_reads]
fn clone(&self) -> Self { *self }
}Clone, #[automatically_derived]impl ::core::fmt::Debug for AllowReturnTypeNotation {
#[inline]
#[rustc_trivial_field_reads]
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)]
827enum AllowReturnTypeNotation {
828 Yes,
830 No,
832}
833
834enum GenericArgsMode {
835 ParenSugar,
837 ReturnTypeNotation,
839 Err,
841 Silence,
843}
844
845#[derive(#[automatically_derived]impl ::core::fmt::Debug for DiscardParams {
#[inline]
#[rustc_trivial_field_reads]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::write_str(f,
match self {
DiscardParams::Yes => "Yes",
DiscardParams::No => "No",
})
}
}Debug, #[automatically_derived]impl ::core::marker::Copy for DiscardParams { }Copy, #[automatically_derived]#[doc(hidden)]unsafe impl ::core::clone::TrivialClone
for DiscardParams {
}
#[automatically_derived]impl ::core::clone::Clone for DiscardParams {
#[inline]
#[rustc_trivial_field_reads]
fn clone(&self) -> Self { *self }
}Clone)]
846enum DiscardParams {
847 Yes,
849 No,
851}
852
853impl<'hir> LoweringContext<'_, 'hir> {
854 fn create_def(
855 &mut self,
856 node_id: NodeId,
857 name: Option<Symbol>,
858 def_kind: DefKind,
859 span: Span,
860 ) -> LocalDefId {
861 let parent = self.curr_owner.owner_id().def_id;
862 {
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);
863 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!(
864 self.opt_local_def_id(node_id).is_none(),
865 "adding a def'n for node-id {:?} and def kind {:?} but a previous def'n exists: {:?}",
866 node_id,
867 def_kind,
868 self.tcx.hir_def_key(self.local_def_id(node_id)),
869 );
870
871 let def_id = self
872 .tcx
873 .at(span)
874 .create_def(parent, name, def_kind, None, &mut self.curr_owner.disambiguator)
875 .def_id();
876
877 {
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("event /rustc-dev/6905905bb7727fd0f9223f5fdc9ad4e62236d5a2/compiler/rustc_ast_lowering/src/lib.rs:877",
"rustc_ast_lowering", ::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/6905905bb7727fd0f9223f5fdc9ad4e62236d5a2/compiler/rustc_ast_lowering/src/lib.rs"),
::tracing_core::__macro_support::Option::Some(877u32),
::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);
878 self.node_id_to_def_id.insert(node_id, def_id);
879
880 def_id
881 }
882
883 fn next_node_id(&mut self) -> NodeId {
884 let start = self.next_node_id;
885 let next = start.as_u32().checked_add(1).expect("input too large; ran out of NodeIds");
886 self.next_node_id = NodeId::from_u32(next);
887 start
888 }
889
890 {}
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/6905905bb7727fd0f9223f5fdc9ad4e62236d5a2/compiler/rustc_ast_lowering/src/lib.rs"),
::tracing_core::__macro_support::Option::Some(892u32),
::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/6905905bb7727fd0f9223f5fdc9ad4e62236d5a2/compiler/rustc_ast_lowering/src/lib.rs:892",
"rustc_ast_lowering", ::tracing::Level::TRACE,
::tracing_core::__macro_support::Option::Some("/rustc-dev/6905905bb7727fd0f9223f5fdc9ad4e62236d5a2/compiler/rustc_ast_lowering/src/lib.rs"),
::tracing_core::__macro_support::Option::Some(892u32),
::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)]
893 fn opt_local_def_id(&self, node: NodeId) -> Option<LocalDefId> {
894 self.node_id_to_def_id
895 .get(&node)
896 .or_else(|| self.curr_owner.owner.node_id_to_def_id.get(&node))
897 .copied()
898 }
899
900 fn local_def_id(&self, node: NodeId) -> LocalDefId {
901 self.opt_local_def_id(node).unwrap_or_else(|| {
902 self.resolver.owners.items().any(|(id, items)| {
903 items.node_id_to_def_id.items().any(|(node_id, def_id)| {
904 if *node_id == node {
905 let actual_owner = items.node_id_to_def_id.get(id);
906 {
::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})",)
907 }
908 false
909 })
910 });
911 {
::core::panicking::panic_fmt(format_args!("no entry for node id: `{0:?}`",
node));
};panic!("no entry for node id: `{node:?}`");
912 })
913 }
914
915 fn get_partial_res(&self, id: NodeId) -> Option<PartialRes> {
916 match self.partial_res_overrides.get(&id) {
917 Some(self_param_id) => Some(PartialRes::new(Res::Local(*self_param_id))),
918 None => self.resolver.partial_res_map.get(&id).copied(),
919 }
920 }
921
922 fn owner_id(&self, node: NodeId) -> hir::OwnerId {
924 hir::OwnerId { def_id: self.resolver.owners[&node].def_id }
925 }
926
927 {}
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/6905905bb7727fd0f9223f5fdc9ad4e62236d5a2/compiler/rustc_ast_lowering/src/lib.rs"),
::tracing_core::__macro_support::Option::Some(932u32),
::tracing_core::__macro_support::Option::Some("rustc_ast_lowering"),
::tracing_core::field::FieldSet::new(&[{
const NAME:
::tracing::__macro_support::FieldName<{
::tracing::__macro_support::FieldName::len("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/6905905bb7727fd0f9223f5fdc9ad4e62236d5a2/compiler/rustc_ast_lowering/src/lib.rs:932",
"rustc_ast_lowering", ::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/6905905bb7727fd0f9223f5fdc9ad4e62236d5a2/compiler/rustc_ast_lowering/src/lib.rs"),
::tracing_core::__macro_support::Option::Some(932u32),
::tracing_core::__macro_support::Option::Some("rustc_ast_lowering"),
::tracing_core::field::FieldSet::new(&[{
const NAME:
::tracing::__macro_support::FieldName<{
::tracing::__macro_support::FieldName::len("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)]
933 fn lower_node_id(&mut self, ast_node_id: NodeId) -> HirId {
934 assert_ne!(ast_node_id, DUMMY_NODE_ID);
935
936 let owner = self.curr_owner.owner_id();
937 let local_id = self.curr_owner.item_local_id_counter;
938 assert_ne!(local_id, hir::ItemLocalId::ZERO);
939 self.curr_owner.item_local_id_counter.increment_by(1);
940 let hir_id = HirId { owner, local_id };
941
942 if let Some(def_id) = self.opt_local_def_id(ast_node_id) {
943 self.curr_owner.children.insert(def_id, hir::MaybeOwner::NonOwner(hir_id));
944 }
945
946 if let Some(traits) = self.curr_owner.owner.trait_map.get(&ast_node_id) {
947 self.curr_owner.trait_map.insert(hir_id.local_id, *traits);
948 }
949
950 #[cfg(debug_assertions)]
952 self.curr_owner.relowering_checker.assert_node_is_not_relowered(ast_node_id, local_id);
953
954 hir_id
955 }
956
957 {}
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/6905905bb7727fd0f9223f5fdc9ad4e62236d5a2/compiler/rustc_ast_lowering/src/lib.rs"),
::tracing_core::__macro_support::Option::Some(958u32),
::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/6905905bb7727fd0f9223f5fdc9ad4e62236d5a2/compiler/rustc_ast_lowering/src/lib.rs:958",
"rustc_ast_lowering", ::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/6905905bb7727fd0f9223f5fdc9ad4e62236d5a2/compiler/rustc_ast_lowering/src/lib.rs"),
::tracing_core::__macro_support::Option::Some(958u32),
::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)]
959 fn next_id(&mut self) -> HirId {
960 let owner = self.curr_owner.owner_id();
961 let local_id = self.curr_owner.item_local_id_counter;
962 assert_ne!(local_id, hir::ItemLocalId::ZERO);
963 self.curr_owner.item_local_id_counter.increment_by(1);
964 HirId { owner, local_id }
965 }
966
967 {}
#[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/6905905bb7727fd0f9223f5fdc9ad4e62236d5a2/compiler/rustc_ast_lowering/src/lib.rs"),
::tracing_core::__macro_support::Option::Some(967u32),
::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/6905905bb7727fd0f9223f5fdc9ad4e62236d5a2/compiler/rustc_ast_lowering/src/lib.rs:975",
"rustc_ast_lowering", ::tracing::Level::TRACE,
::tracing_core::__macro_support::Option::Some("/rustc-dev/6905905bb7727fd0f9223f5fdc9ad4e62236d5a2/compiler/rustc_ast_lowering/src/lib.rs"),
::tracing_core::__macro_support::Option::Some(975u32),
::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))]
968 fn lower_res(&self, res: Res<NodeId>) -> Res {
969 let res: Result<Res, ()> = res.apply_id(|id| {
970 let owner = self.curr_owner.owner_id();
971 let local_id =
972 self.curr_owner.ident_and_label_to_local_id.get(&id).copied().ok_or(())?;
973 Ok(HirId { owner, local_id })
974 });
975 trace!(?res);
976
977 res.unwrap_or(Res::Err)
983 }
984
985 fn expect_full_res(&self, id: NodeId) -> Res<NodeId> {
986 self.get_partial_res(id).map_or(Res::Err, |pr| pr.expect_full_res())
987 }
988
989 fn lower_import_res(&self, id: NodeId, span: Span) -> PerNS<Option<Res>> {
990 let per_ns = self
991 .curr_owner
992 .owner
993 .import_res
994 .get(&id)
995 .unwrap_or_else(|| {
996 let sp = self.tcx.source_span(self.curr_owner.owner.def_id);
997 self.tcx.dcx().span_delayed_bug(
998 sp,
999 "no import_res entry for import, \
1000 this should only happen if it already errored in resolve",
1001 );
1002 &PerNS { value_ns: None, type_ns: None, macro_ns: None }
1003 })
1004 .map(|res| res.map(|res| self.lower_res(res)));
1005
1006 if per_ns.is_empty() {
1007 self.dcx().span_delayed_bug(span, "no resolution for an import");
1009 let err = Some(Res::Err);
1010 return PerNS { type_ns: err, value_ns: err, macro_ns: err };
1011 }
1012 per_ns
1013 }
1014
1015 fn make_lang_item_qpath(
1016 &mut self,
1017 lang_item: LangItem,
1018 span: Span,
1019 args: Option<&'hir hir::GenericArgs<'hir>>,
1020 ) -> hir::QPath<'hir> {
1021 hir::QPath::Resolved(None, self.make_lang_item_path(lang_item, span, args))
1022 }
1023
1024 fn make_lang_item_path(
1025 &mut self,
1026 lang_item: LangItem,
1027 span: Span,
1028 args: Option<&'hir hir::GenericArgs<'hir>>,
1029 ) -> &'hir hir::Path<'hir> {
1030 let def_id = self.tcx.require_lang_item(lang_item, span);
1031 let def_kind = self.tcx.def_kind(def_id);
1032 let res = Res::Def(def_kind, def_id);
1033 self.arena.alloc(hir::Path {
1034 span,
1035 res,
1036 segments: self.arena.alloc_from_iter([hir::PathSegment {
1037 ident: Ident::new(lang_item.name(), span),
1038 hir_id: self.next_id(),
1039 res,
1040 args,
1041 infer_args: args.is_none(),
1042 delegation_child_segment: false,
1043 }]),
1044 })
1045 }
1046
1047 fn mark_span_with_reason(
1050 &self,
1051 reason: DesugaringKind,
1052 span: Span,
1053 allow_internal_unstable: Option<Arc<[Symbol]>>,
1054 ) -> Span {
1055 self.tcx.with_stable_hashing_context(|hcx| {
1056 span.mark_with_reason(allow_internal_unstable, reason, span.edition(), hcx)
1057 })
1058 }
1059
1060 fn span_lowerer(&self) -> SpanLowerer {
1061 SpanLowerer {
1062 is_incremental: self.tcx.sess.opts.incremental.is_some(),
1063 def_id: self.curr_owner.owner_id().def_id,
1064 }
1065 }
1066
1067 fn lower_span(&self, span: Span) -> Span {
1070 self.span_lowerer().lower(span)
1071 }
1072
1073 fn lower_ident(&self, ident: Ident) -> Ident {
1074 Ident::new(ident.name, self.lower_span(ident.span))
1075 }
1076
1077 {}
#[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/6905905bb7727fd0f9223f5fdc9ad4e62236d5a2/compiler/rustc_ast_lowering/src/lib.rs"),
::tracing_core::__macro_support::Option::Some(1078u32),
::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/6905905bb7727fd0f9223f5fdc9ad4e62236d5a2/compiler/rustc_ast_lowering/src/lib.rs:1093",
"rustc_ast_lowering", ::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/6905905bb7727fd0f9223f5fdc9ad4e62236d5a2/compiler/rustc_ast_lowering/src/lib.rs"),
::tracing_core::__macro_support::Option::Some(1093u32),
::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))]
1079 fn lifetime_res_to_generic_param(
1080 &mut self,
1081 ident: Ident,
1082 node_id: NodeId,
1083 kind: MissingLifetimeKind,
1084 source: hir::GenericParamSource,
1085 ) -> hir::GenericParam<'hir> {
1086 let _def_id = self.create_def(
1088 node_id,
1089 Some(kw::UnderscoreLifetime),
1090 DefKind::LifetimeParam,
1091 ident.span,
1092 );
1093 debug!(?_def_id);
1094
1095 let hir_id = self.lower_node_id(node_id);
1096 let def_id = self.local_def_id(node_id);
1097 hir::GenericParam {
1098 hir_id,
1099 def_id,
1100 name: hir::ParamName::Fresh,
1101 span: self.lower_span(ident.span),
1102 pure_wrt_drop: false,
1103 kind: hir::GenericParamKind::Lifetime { kind: hir::LifetimeParamKind::Elided(kind) },
1104 colon_span: None,
1105 source,
1106 }
1107 }
1108
1109 {}
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/6905905bb7727fd0f9223f5fdc9ad4e62236d5a2/compiler/rustc_ast_lowering/src/lib.rs"),
::tracing_core::__macro_support::Option::Some(1114u32),
::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/6905905bb7727fd0f9223f5fdc9ad4e62236d5a2/compiler/rustc_ast_lowering/src/lib.rs:1124",
"rustc_ast_lowering", ::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/6905905bb7727fd0f9223f5fdc9ad4e62236d5a2/compiler/rustc_ast_lowering/src/lib.rs"),
::tracing_core::__macro_support::Option::Some(1124u32),
::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/6905905bb7727fd0f9223f5fdc9ad4e62236d5a2/compiler/rustc_ast_lowering/src/lib.rs:1114",
"rustc_ast_lowering", ::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/6905905bb7727fd0f9223f5fdc9ad4e62236d5a2/compiler/rustc_ast_lowering/src/lib.rs"),
::tracing_core::__macro_support::Option::Some(1114u32),
::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)]
1115 #[inline]
1116 fn lower_lifetime_binder(
1117 &mut self,
1118 binder: NodeId,
1119 generic_params: &[GenericParam],
1120 ) -> &'hir [hir::GenericParam<'hir>] {
1121 let extra_lifetimes = self.curr_owner.owner.extra_lifetime_params(binder);
1124 debug!(?extra_lifetimes);
1125 let extra_lifetimes: Vec<_> = extra_lifetimes
1126 .iter()
1127 .map(|&(ident, node_id, res)| {
1128 self.lifetime_res_to_generic_param(
1129 ident,
1130 node_id,
1131 res,
1132 hir::GenericParamSource::Binder,
1133 )
1134 })
1135 .collect();
1136 let arena = self.arena;
1137 let explicit_generic_params =
1138 self.lower_generic_params_mut(generic_params, hir::GenericParamSource::Binder);
1139 arena.alloc_from_iter(explicit_generic_params.chain(extra_lifetimes.into_iter()))
1140 }
1141
1142 fn with_dyn_type_scope<T>(&mut self, in_scope: bool, f: impl FnOnce(&mut Self) -> T) -> T {
1143 let was_in_dyn_type = self.is_in_dyn_type;
1144 self.is_in_dyn_type = in_scope;
1145
1146 let result = f(self);
1147
1148 self.is_in_dyn_type = was_in_dyn_type;
1149
1150 result
1151 }
1152
1153 fn with_new_scopes<T>(&mut self, scope_span: Span, f: impl FnOnce(&mut Self) -> T) -> T {
1154 let current_item_span = self.current_item_span;
1155 self.current_item_span = Some(scope_span);
1156
1157 let was_in_loop_condition = self.is_in_loop_condition;
1158 self.is_in_loop_condition = false;
1159
1160 let old_contract = self.contract_ensures.take();
1161
1162 let try_block_scope = mem::replace(&mut self.try_block_scope, TryBlockScope::Function);
1163 let loop_scope = self.loop_scope.take();
1164 let ret = f(self);
1165 self.try_block_scope = try_block_scope;
1166 self.loop_scope = loop_scope;
1167
1168 self.contract_ensures = old_contract;
1169
1170 self.is_in_loop_condition = was_in_loop_condition;
1171
1172 self.current_item_span = current_item_span;
1173
1174 ret
1175 }
1176
1177 fn lower_attrs(
1178 &mut self,
1179 id: HirId,
1180 attrs: &[Attribute],
1181 target_span: Span,
1182 ast_target: AstTarget<'_>,
1183 ) -> &'hir [rustc_attr_ir::Attribute] {
1184 self.lower_attrs_with_extra(id, attrs, target_span, ast_target, &[])
1185 }
1186
1187 fn lower_attrs_with_extra(
1188 &mut self,
1189 id: HirId,
1190 attrs: &[Attribute],
1191 target_span: Span,
1192 ast_target: AstTarget<'_>,
1193 extra_hir_attributes: &[rustc_attr_ir::Attribute],
1194 ) -> &'hir [rustc_attr_ir::Attribute] {
1195 if attrs.is_empty() && extra_hir_attributes.is_empty() {
1196 &[]
1197 } else {
1198 let mut lowered_attrs =
1199 self.lower_attrs_vec(attrs, self.lower_span(target_span), id, ast_target);
1200 lowered_attrs.extend(extra_hir_attributes.iter().cloned());
1201
1202 {
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());
1203 let ret = self.arena.alloc_from_iter(lowered_attrs);
1204
1205 if ret.is_empty() {
1212 &[]
1213 } else {
1214 self.curr_owner.attrs.insert(id.local_id, ret);
1215 ret
1216 }
1217 }
1218 }
1219
1220 fn lower_attrs_vec(
1221 &mut self,
1222 attrs: &[Attribute],
1223 target_span: Span,
1224 target_hir_id: HirId,
1225 ast_target: AstTarget<'_>,
1226 ) -> Vec<rustc_attr_ir::Attribute> {
1227 let l = self.span_lowerer();
1228 self.attribute_parser.parse_attribute_list(
1229 attrs,
1230 target_span,
1231 ast_target,
1232 |s| l.lower(s),
1233 |lint_id, span, kind| {
1234 self.curr_owner.delayed_lints.push(DelayedLint {
1235 lint_id,
1236 id: target_hir_id,
1237 span,
1238 callback: Box::new(move |dcx, level, sess: &dyn std::any::Any| {
1239 let sess = sess
1240 .downcast_ref::<rustc_session::Session>()
1241 .expect("expected `Session`");
1242 (kind.0)(dcx, level, sess)
1243 }),
1244 });
1245 },
1246 )
1247 }
1248
1249 fn alias_attrs(&mut self, id: HirId, target_id: HirId) {
1250 {
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());
1251 {
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());
1252 if let Some(&a) = self.curr_owner.attrs.get(&target_id.local_id) {
1253 if !!a.is_empty() {
::core::panicking::panic("assertion failed: !a.is_empty()")
};assert!(!a.is_empty());
1254 self.curr_owner.attrs.insert(id.local_id, a);
1255 }
1256 }
1257
1258 {}
#[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/6905905bb7727fd0f9223f5fdc9ad4e62236d5a2/compiler/rustc_ast_lowering/src/lib.rs"),
::tracing_core::__macro_support::Option::Some(1259u32),
::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/6905905bb7727fd0f9223f5fdc9ad4e62236d5a2/compiler/rustc_ast_lowering/src/lib.rs:1265",
"rustc_ast_lowering", ::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/6905905bb7727fd0f9223f5fdc9ad4e62236d5a2/compiler/rustc_ast_lowering/src/lib.rs"),
::tracing_core::__macro_support::Option::Some(1265u32),
::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: constraint.ident.span.to(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.ctxt() == constraint.span.ctxt() {
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(&mut Default::default(),
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)]
1260 fn lower_assoc_item_constraint(
1261 &mut self,
1262 constraint: &AssocItemConstraint,
1263 itctx: ImplTraitContext,
1264 ) -> hir::AssocItemConstraint<'hir> {
1265 debug!(?constraint, ?itctx);
1266 let gen_args = if let Some(gen_args) = &constraint.gen_args {
1268 let gen_args_ctor = match gen_args {
1269 GenericArgs::AngleBracketed(data) => {
1270 self.lower_angle_bracketed_parameter_data(data, ParamMode::Explicit, itctx).0
1271 }
1272 GenericArgs::Parenthesized(data) => {
1273 if let Some(first_char) = constraint.ident.as_str().chars().next()
1274 && first_char.is_ascii_lowercase()
1275 {
1276 let err = match (&data.inputs[..], &data.output) {
1277 ([_, ..], FnRetTy::Default(_)) => {
1278 diagnostics::BadReturnTypeNotation::Inputs {
1279 span: data.inputs_span,
1280 }
1281 }
1282 ([], FnRetTy::Default(_)) => {
1283 diagnostics::BadReturnTypeNotation::NeedsDots {
1284 span: data.inputs_span,
1285 }
1286 }
1287 (_, FnRetTy::Ty(ty)) => {
1289 let span = data.inputs_span.shrink_to_hi().to(ty.span);
1290 diagnostics::BadReturnTypeNotation::Output {
1291 span,
1292 suggestion: diagnostics::RTNSuggestion {
1293 output: span,
1294 input: data.inputs_span,
1295 },
1296 }
1297 }
1298 };
1299 let mut err = self.dcx().create_err(err);
1300 if !self.tcx.features().return_type_notation()
1301 && self.tcx.sess.is_nightly_build()
1302 {
1303 add_feature_diagnostics(
1304 &mut err,
1305 &self.tcx.sess,
1306 sym::return_type_notation,
1307 );
1308 }
1309 err.emit();
1310 GenericArgsCtor {
1311 args: Default::default(),
1312 constraints: &[],
1313 parenthesized: hir::GenericArgsParentheses::ReturnTypeNotation,
1314 span: constraint.ident.span.to(data.span),
1315 }
1316 } else {
1317 let guar = self.emit_bad_parenthesized_trait_in_assoc_ty(data);
1318 self.lower_angle_bracketed_parameter_data(
1319 &data.as_angle_bracketed_args(),
1320 ParamMode::Explicit,
1321 ImplTraitContext::AlreadyErrored(guar),
1322 )
1323 .0
1324 }
1325 }
1326 GenericArgs::ParenthesizedElided(span) => GenericArgsCtor {
1327 args: Default::default(),
1328 constraints: &[],
1329 parenthesized: hir::GenericArgsParentheses::ReturnTypeNotation,
1330 span: *span,
1331 },
1332 };
1333 gen_args_ctor.into_generic_args(self)
1334 } else {
1335 hir::GenericArgs::NONE
1336 };
1337 let kind = match &constraint.kind {
1338 AssocItemConstraintKind::Equality { term } => {
1339 let term = match term {
1340 Term::Ty(ty) => self.lower_ty_alloc(ty, itctx).into(),
1341 Term::Const(c) => self.lower_anon_const_to_const_arg_and_alloc(c).into(),
1342 };
1343 hir::AssocItemConstraintKind::Equality { term }
1344 }
1345 AssocItemConstraintKind::Bound { bounds } => {
1346 if self.is_in_dyn_type {
1348 let suggestion = match itctx {
1349 ImplTraitContext::OpaqueTy { .. } | ImplTraitContext::Universal => {
1350 let bound_end_span = constraint
1351 .gen_args
1352 .as_ref()
1353 .map_or(constraint.ident.span, |args| args.span());
1354 if bound_end_span.ctxt() == constraint.span.ctxt() {
1355 Some(self.tcx.sess.source_map().next_point(bound_end_span))
1356 } else {
1357 None
1358 }
1359 }
1360 _ => None,
1361 };
1362
1363 let guar = self.dcx().emit_err(diagnostics::MisplacedAssocTyBinding {
1364 span: constraint.span,
1365 suggestion,
1366 });
1367 let err_ty =
1368 &*self.arena.alloc(self.ty(constraint.span, hir::TyKind::Err(guar)));
1369 hir::AssocItemConstraintKind::Equality { term: err_ty.into() }
1370 } else {
1371 let bounds = self.lower_param_bounds(
1372 bounds,
1373 RelaxedBoundPolicy::forbidden(
1374 &mut Default::default(),
1375 RelaxedBoundForbiddenReason::AssocTyBounds,
1376 ),
1377 itctx,
1378 );
1379 hir::AssocItemConstraintKind::Bound { bounds }
1380 }
1381 }
1382 };
1383
1384 hir::AssocItemConstraint {
1385 hir_id: self.lower_node_id(constraint.id),
1386 ident: self.lower_ident(constraint.ident),
1387 gen_args,
1388 kind,
1389 span: self.lower_span(constraint.span),
1390 }
1391 }
1392
1393 fn emit_bad_parenthesized_trait_in_assoc_ty(
1394 &self,
1395 data: &ParenthesizedArgs,
1396 ) -> ErrorGuaranteed {
1397 let sub = if data.inputs.is_empty() {
1399 let parentheses_span =
1400 data.inputs_span.shrink_to_lo().to(data.inputs_span.shrink_to_hi());
1401 AssocTyParenthesesSub::Empty { parentheses_span }
1402 }
1403 else {
1405 let open_param = data.inputs_span.shrink_to_lo().to(data
1407 .inputs
1408 .first()
1409 .unwrap()
1410 .span
1411 .shrink_to_lo());
1412 let close_param =
1414 data.inputs.last().unwrap().span.shrink_to_hi().to(data.inputs_span.shrink_to_hi());
1415 AssocTyParenthesesSub::NotEmpty { open_param, close_param }
1416 };
1417 self.dcx().emit_err(AssocTyParentheses { span: data.span, sub })
1418 }
1419
1420 {}
#[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/6905905bb7727fd0f9223f5fdc9ad4e62236d5a2/compiler/rustc_ast_lowering/src/lib.rs"),
::tracing_core::__macro_support::Option::Some(1420u32),
::tracing_core::__macro_support::Option::Some("rustc_ast_lowering"),
::tracing_core::field::FieldSet::new(&[{
const NAME:
::tracing::__macro_support::FieldName<{
::tracing::__macro_support::FieldName::len("arg")
}> =
::tracing::__macro_support::FieldName::new("arg");
NAME.as_str()
},
{
const NAME:
::tracing::__macro_support::FieldName<{
::tracing::__macro_support::FieldName::len("itctx")
}> =
::tracing::__macro_support::FieldName::new("itctx");
NAME.as_str()
}], ::tracing_core::callsite::Identifier(&__CALLSITE)),
::tracing::metadata::Kind::SPAN)
};
::tracing::callsite::DefaultCallsite::new(&META)
};
let mut interest = ::tracing::subscriber::Interest::never();
if ::tracing::Level::DEBUG <=
::tracing::level_filters::STATIC_MAX_LEVEL &&
::tracing::Level::DEBUG <=
::tracing::level_filters::LevelFilter::current() &&
{ interest = __CALLSITE.interest(); !interest.is_never() }
&&
::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
interest) {
let meta = __CALLSITE.metadata();
::tracing::Span::new(meta,
&{
#[allow(unused_imports)]
use ::tracing::field::{debug, display, Value};
meta.fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&arg)
as &dyn ::tracing::field::Value)),
(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&itctx)
as &dyn ::tracing::field::Value))])
})
} else {
let span =
::tracing::__macro_support::__disabled_span(__CALLSITE.metadata());
{};
span
}
};
__tracing_attr_guard = __tracing_attr_span.enter();
}
#[warn(clippy :: suspicious_else_formatting)]
{
#[allow(unknown_lints, unreachable_code, clippy ::
diverging_sub_expression, clippy :: empty_loop, clippy ::
let_unit_value, clippy :: let_with_type_underscore, clippy ::
needless_return, clippy :: unreachable)]
if false {
let __tracing_attr_fake_return: hir::GenericArg<'hir> = loop {};
return __tracing_attr_fake_return;
}
{
match arg {
ast::GenericArg::Lifetime(lt) =>
GenericArg::Lifetime(self.lower_lifetime(lt,
LifetimeSource::Path {
angle_brackets: hir::AngleBrackets::Full,
}, lt.ident.into())),
ast::GenericArg::Type(ty) => {
if ty.is_maybe_parenthesised_infer() {
return GenericArg::Infer(self.arena.alloc(hir::InferArg {
hir_id: self.lower_node_id(ty.id),
span: self.lower_span(ty.span),
kind: hir::InferArgKind::TypeOrConst,
}));
}
match &ty.kind {
TyKind::Path(None, path) if
path.is_single_argless_ident() &&
let Some(res) =
self.get_partial_res(ty.id).and_then(|partial_res|
partial_res.full_res()) &&
!res.matches_ns(Namespace::TypeNS) => {
let ct =
self.lower_const_path_to_const_arg(&None, path, res, ty.id,
ty.span);
let ct = self.arena.alloc(ct);
return GenericArg::Const(ct.try_as_ambig_ct().unwrap());
}
TyKind::GcaMacro(expr) if self.tcx.features().gca() => {
let ct =
match self.can_lower_expr_to_const_arg_direct(expr,
self.direct_const_arg_context_enabled_by_gca_macro()) {
Ok(()) => self.lower_expr_to_const_arg_direct(expr, None),
Err(e) => e.emit(self),
};
let ct = self.arena.alloc(ct);
return match ct.try_as_ambig_ct() {
Some(ct) => GenericArg::Const(ct),
None =>
GenericArg::Infer(self.arena.alloc(hir::InferArg {
hir_id: ct.hir_id,
span: ct.span,
kind: hir::InferArgKind::Const,
})),
};
}
_ => {}
}
GenericArg::Type(self.lower_ty_alloc(ty,
itctx).try_as_ambig_ty().unwrap())
}
ast::GenericArg::Const(ct) => {
let ct = self.lower_anon_const_to_const_arg_and_alloc(ct);
match ct.try_as_ambig_ct() {
Some(ct) => GenericArg::Const(ct),
None =>
GenericArg::Infer(self.arena.alloc(hir::InferArg {
hir_id: ct.hir_id,
span: ct.span,
kind: hir::InferArgKind::Const,
})),
}
}
}
}
}
}#[instrument(level = "debug", skip(self))]
1421 fn lower_generic_arg(
1422 &mut self,
1423 arg: &ast::GenericArg,
1424 itctx: ImplTraitContext,
1425 ) -> hir::GenericArg<'hir> {
1426 match arg {
1427 ast::GenericArg::Lifetime(lt) => GenericArg::Lifetime(self.lower_lifetime(
1428 lt,
1429 LifetimeSource::Path { angle_brackets: hir::AngleBrackets::Full },
1430 lt.ident.into(),
1431 )),
1432 ast::GenericArg::Type(ty) => {
1433 if ty.is_maybe_parenthesised_infer() {
1436 return GenericArg::Infer(self.arena.alloc(hir::InferArg {
1437 hir_id: self.lower_node_id(ty.id),
1438 span: self.lower_span(ty.span),
1439 kind: hir::InferArgKind::TypeOrConst,
1440 }));
1441 }
1442
1443 match &ty.kind {
1444 TyKind::Path(None, path)
1455 if path.is_single_argless_ident()
1456 && let Some(res) = self
1457 .get_partial_res(ty.id)
1458 .and_then(|partial_res| partial_res.full_res())
1459 && !res.matches_ns(Namespace::TypeNS) =>
1460 {
1461 let ct =
1462 self.lower_const_path_to_const_arg(&None, path, res, ty.id, ty.span);
1463 let ct = self.arena.alloc(ct);
1464 return GenericArg::Const(ct.try_as_ambig_ct().unwrap());
1465 }
1466 TyKind::GcaMacro(expr) if self.tcx.features().gca() => {
1467 let ct = match self.can_lower_expr_to_const_arg_direct(
1468 expr,
1469 self.direct_const_arg_context_enabled_by_gca_macro(),
1470 ) {
1471 Ok(()) => self.lower_expr_to_const_arg_direct(expr, None),
1472 Err(e) => e.emit(self),
1473 };
1474 let ct = self.arena.alloc(ct);
1475 return match ct.try_as_ambig_ct() {
1476 Some(ct) => GenericArg::Const(ct),
1477 None => GenericArg::Infer(self.arena.alloc(hir::InferArg {
1478 hir_id: ct.hir_id,
1479 span: ct.span,
1480 kind: hir::InferArgKind::Const,
1481 })),
1482 };
1483 }
1484 _ => {}
1485 }
1486 GenericArg::Type(self.lower_ty_alloc(ty, itctx).try_as_ambig_ty().unwrap())
1487 }
1488 ast::GenericArg::Const(ct) => {
1489 let ct = self.lower_anon_const_to_const_arg_and_alloc(ct);
1490 match ct.try_as_ambig_ct() {
1491 Some(ct) => GenericArg::Const(ct),
1492 None => GenericArg::Infer(self.arena.alloc(hir::InferArg {
1493 hir_id: ct.hir_id,
1494 span: ct.span,
1495 kind: hir::InferArgKind::Const,
1496 })),
1497 }
1498 }
1499 }
1500 }
1501
1502 {}
#[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/6905905bb7727fd0f9223f5fdc9ad4e62236d5a2/compiler/rustc_ast_lowering/src/lib.rs"),
::tracing_core::__macro_support::Option::Some(1502u32),
::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))]
1503 fn lower_ty_alloc(&mut self, t: &Ty, itctx: ImplTraitContext) -> &'hir hir::Ty<'hir> {
1504 self.arena.alloc(self.lower_ty(t, itctx))
1505 }
1506
1507 fn lower_path_ty(
1508 &mut self,
1509 t: &Ty,
1510 qself: &Option<Box<QSelf>>,
1511 path: &Path,
1512 param_mode: ParamMode,
1513 itctx: ImplTraitContext,
1514 ) -> hir::Ty<'hir> {
1515 if qself.is_none()
1521 && let Some(partial_res) = self.get_partial_res(t.id)
1522 && let Some(Res::Def(DefKind::Trait | DefKind::TraitAlias, _)) = partial_res.full_res()
1523 {
1524 let (bounds, lifetime_bound) = self.with_dyn_type_scope(true, |this| {
1525 let bound = this.lower_poly_trait_ref(
1526 &PolyTraitRef {
1527 bound_generic_params: ThinVec::new(),
1528 modifiers: TraitBoundModifiers::NONE,
1529 trait_ref: TraitRef { path: path.clone(), ref_id: t.id },
1530 span: t.span,
1531 parens: ast::Parens::No,
1532 },
1533 RelaxedBoundPolicy::forbidden(
1534 &mut Default::default(),
1535 RelaxedBoundForbiddenReason::TraitObjectTy,
1536 ),
1537 itctx,
1538 );
1539 let bounds = this.arena.alloc_from_iter([bound]);
1540 let lifetime_bound = this.elided_dyn_bound(t.span);
1541 (bounds, lifetime_bound)
1542 });
1543 let kind = hir::TyKind::TraitObject(
1544 bounds,
1545 TaggedRef::new(lifetime_bound, TraitObjectSyntax::None),
1546 );
1547 return hir::Ty { kind, span: self.lower_span(t.span), hir_id: self.next_id() };
1548 }
1549
1550 let id = self.lower_node_id(t.id);
1551 let qpath = self.lower_qpath(
1552 t.id,
1553 qself,
1554 path,
1555 param_mode,
1556 AllowReturnTypeNotation::Yes,
1557 itctx,
1558 None,
1559 );
1560 self.ty_path(id, t.span, qpath)
1561 }
1562
1563 fn ty(&mut self, span: Span, kind: hir::TyKind<'hir>) -> hir::Ty<'hir> {
1564 hir::Ty { hir_id: self.next_id(), kind, span: self.lower_span(span) }
1565 }
1566
1567 fn ty_tup(&mut self, span: Span, tys: &'hir [hir::Ty<'hir>]) -> hir::Ty<'hir> {
1568 self.ty(span, hir::TyKind::Tup(tys))
1569 }
1570
1571 fn lower_ty(&mut self, t: &Ty, itctx: ImplTraitContext) -> hir::Ty<'hir> {
1572 let kind = match &t.kind {
1573 TyKind::Infer => hir::TyKind::Infer(()),
1574 TyKind::Err(guar) => hir::TyKind::Err(*guar),
1575 TyKind::Slice(ty) => hir::TyKind::Slice(self.lower_ty_alloc(ty, itctx)),
1576 TyKind::Ptr(ty, mutbl) => hir::TyKind::Ptr(self.lower_ty_alloc(ty, itctx), *mutbl),
1577 TyKind::Ref(region, ty, mutbl) => {
1578 let lifetime = self.lower_ty_direct_lifetime(t, *region);
1579 hir::TyKind::Ref(lifetime, self.lower_ty_alloc(ty, itctx), *mutbl)
1580 }
1581 TyKind::PinnedRef(region, ty, mutbl) => {
1582 let lifetime = self.lower_ty_direct_lifetime(t, *region);
1583 let kind = hir::TyKind::Ref(lifetime, self.lower_ty_alloc(ty, itctx), *mutbl);
1584 let span = self.lower_span(t.span);
1585 let arg = hir::Ty { kind, span, hir_id: self.next_id() };
1586 let args = self.arena.alloc(hir::GenericArgs {
1587 args: self.arena.alloc([hir::GenericArg::Type(self.arena.alloc(arg))]),
1588 constraints: &[],
1589 parenthesized: hir::GenericArgsParentheses::No,
1590 span_ext: span,
1591 });
1592 let path = self.make_lang_item_qpath(LangItem::Pin, span, Some(args));
1593 hir::TyKind::Path(path)
1594 }
1595 TyKind::FnPtr(f) => {
1596 let hir_id = self.lower_node_id(t.id);
1597 let generic_params = self.lower_lifetime_binder(t.id, &f.generic_params);
1598 let kind = hir::TyKind::FnPtr(self.arena.alloc(hir::FnPtrTy {
1599 generic_params,
1600 safety: self.lower_safety(f.safety, hir::Safety::Safe),
1601 abi: self.lower_extern(f.ext),
1602 decl: self.lower_fn_decl(
1603 &f.decl,
1604 t.id,
1605 hir_id,
1606 FnDeclKind::Pointer,
1607 None,
1608 DiscardParams::Yes,
1609 ),
1610 param_idents: self.lower_fn_params_to_idents(&f.decl),
1611 }));
1612 return hir::Ty { kind, span: self.lower_span(t.span), hir_id };
1613 }
1614 TyKind::UnsafeBinder(f) => {
1615 let generic_params = self.lower_lifetime_binder(t.id, &f.generic_params);
1616 hir::TyKind::UnsafeBinder(self.arena.alloc(hir::UnsafeBinderTy {
1617 generic_params,
1618 inner_ty: self.lower_ty_alloc(&f.inner_ty, itctx),
1619 }))
1620 }
1621 TyKind::Never => hir::TyKind::Never,
1622 TyKind::Tup(tys) => hir::TyKind::Tup(
1623 self.arena.alloc_from_iter(tys.iter().map(|ty| self.lower_ty(ty, itctx))),
1624 ),
1625 TyKind::Paren(ty) => {
1626 return self.lower_ty(ty, itctx);
1627 }
1628 TyKind::Path(qself, path) => {
1629 return self.lower_path_ty(t, qself, path, ParamMode::Explicit, itctx);
1630 }
1631 TyKind::ImplicitSelf => {
1632 let hir_id = self.next_id();
1633 let res = self.expect_full_res(t.id);
1634 let res = self.lower_res(res);
1635 hir::TyKind::Path(hir::QPath::Resolved(
1636 None,
1637 self.arena.alloc(hir::Path {
1638 res,
1639 segments: self.arena.alloc_from_iter([hir::PathSegment::new(Ident::with_dummy_span(kw::SelfUpper),
hir_id, res)])arena_vec![self; hir::PathSegment::new(
1640 Ident::with_dummy_span(kw::SelfUpper),
1641 hir_id,
1642 res
1643 )],
1644 span: self.lower_span(t.span),
1645 }),
1646 ))
1647 }
1648 TyKind::Array(ty, length) => hir::TyKind::Array(
1649 self.lower_ty_alloc(ty, itctx),
1650 self.lower_array_length_to_const_arg(length),
1651 ),
1652 TyKind::TraitObject(bounds, kind) => {
1653 let (bounds, lifetime_bound) = self.with_dyn_type_scope(true, |this| {
1654 let mut lifetime_bound = None;
1655 let bounds =
1656 this.arena.alloc_from_iter(bounds.iter().filter_map(|bound| match bound {
1657 GenericBound::Trait(ty) => {
1661 let trait_ref = this.lower_poly_trait_ref(
1662 ty,
1663 RelaxedBoundPolicy::forbidden(
1664 &mut Default::default(),
1665 RelaxedBoundForbiddenReason::TraitObjectTy,
1666 ),
1667 itctx,
1668 );
1669 Some(trait_ref)
1670 }
1671 GenericBound::Outlives(lifetime) => {
1672 if lifetime_bound.is_none() {
1673 lifetime_bound = Some(this.lower_lifetime(
1674 lifetime,
1675 LifetimeSource::Other,
1676 lifetime.ident.into(),
1677 ));
1678 }
1679 None
1680 }
1681 GenericBound::Use(_, span) => {
1683 this.dcx()
1684 .span_delayed_bug(*span, "use<> not allowed in dyn types");
1685 None
1686 }
1687 }));
1688 (bounds, lifetime_bound.unwrap_or_else(|| this.elided_dyn_bound(t.span)))
1689 });
1690 hir::TyKind::TraitObject(bounds, TaggedRef::new(lifetime_bound, *kind))
1691 }
1692 TyKind::ImplTrait(def_node_id, bounds) => {
1693 let span = t.span;
1694 match itctx {
1695 ImplTraitContext::OpaqueTy { origin } => {
1696 self.lower_opaque_impl_trait(span, origin, *def_node_id, bounds, itctx)
1697 }
1698 ImplTraitContext::Universal => {
1699 if let Some(span) = bounds.iter().find_map(|bound| match *bound {
1700 ast::GenericBound::Use(_, span) => Some(span),
1701 _ => None,
1702 }) {
1703 self.tcx.dcx().emit_err(diagnostics::NoPreciseCapturesOnApit { span });
1704 }
1705
1706 let def_id = self.local_def_id(*def_node_id);
1707 let name = self.tcx.item_name(def_id.to_def_id());
1708 let ident = Ident::new(name, span);
1709 let (param, bounds, path) = self.lower_universal_param_and_bounds(
1710 *def_node_id,
1711 span,
1712 ident,
1713 bounds,
1714 );
1715 self.curr_owner.impl_trait_defs.push(param);
1716 if let Some(bounds) = bounds {
1717 self.curr_owner.impl_trait_bounds.push(bounds);
1718 }
1719 path
1720 }
1721 ImplTraitContext::InBinding => {
1722 hir::TyKind::TraitAscription(self.lower_param_bounds(
1723 bounds,
1724 RelaxedBoundPolicy::allow_all(&mut Default::default()),
1725 itctx,
1726 ))
1727 }
1728 ImplTraitContext::FeatureGated(position, feature) => {
1729 let guar = self
1730 .tcx
1731 .sess
1732 .create_feature_err(
1733 MisplacedImplTrait {
1734 span: t.span,
1735 position: DiagArgFromDisplay(&position),
1736 },
1737 feature,
1738 )
1739 .emit_err();
1740 hir::TyKind::Err(guar)
1741 }
1742 ImplTraitContext::Disallowed(position) => {
1743 let guar = self.dcx().emit_err(MisplacedImplTrait {
1744 span: t.span,
1745 position: DiagArgFromDisplay(&position),
1746 });
1747 hir::TyKind::Err(guar)
1748 }
1749 ImplTraitContext::AlreadyErrored(guar) => {
1750 hir::TyKind::Err(guar)
1757 }
1758 }
1759 }
1760 TyKind::Pat(ty, pat) => {
1761 hir::TyKind::Pat(self.lower_ty_alloc(ty, itctx), self.lower_ty_pat(pat, ty.span))
1762 }
1763 TyKind::FieldOf(ty, variant, field) => hir::TyKind::FieldOf(
1764 self.lower_ty_alloc(ty, itctx),
1765 self.arena.alloc(hir::TyFieldPath {
1766 variant: variant.map(|variant| self.lower_ident(variant)),
1767 field: self.lower_ident(*field),
1768 }),
1769 ),
1770 TyKind::MacCall(_) => {
1771 ::rustc_span::macros::bug_impl(Some(t.span),
format_args!("`TyKind::MacCall` should have been expanded by now"),
Location::caller())span_bug!(t.span, "`TyKind::MacCall` should have been expanded by now")
1772 }
1773 TyKind::CVarArgs => {
1774 let guar = self.dcx().span_delayed_bug(
1775 t.span,
1776 "`TyKind::CVarArgs` should have been handled elsewhere",
1777 );
1778 hir::TyKind::Err(guar)
1779 }
1780 TyKind::View(ty, fields) => {
1781 let ty = self.lower_ty_alloc(ty, itctx);
1782 let fields = self.arena.alloc_slice(fields);
1783 hir::TyKind::View(ty, fields)
1784 }
1785 TyKind::GcaMacro(expr) => {
1786 let e = self.emit_bad_gca_macro(t.span, expr, "type");
1787 hir::TyKind::Err(e)
1788 }
1789 TyKind::Dummy => {
::core::panicking::panic_fmt(format_args!("`TyKind::Dummy` should never be lowered"));
}panic!("`TyKind::Dummy` should never be lowered"),
1790 };
1791
1792 hir::Ty { kind, span: self.lower_span(t.span), hir_id: self.lower_node_id(t.id) }
1793 }
1794
1795 pub(crate) fn emit_bad_gca_macro(
1796 &mut self,
1797 span: Span,
1798 expr: &Expr,
1799 expected: &'static str,
1800 ) -> ErrorGuaranteed {
1801 let msg = ::alloc::__export::must_use({
::alloc::fmt::format(format_args!("expected {0}, found `gca!()` constant",
expected))
})format!("expected {expected}, found `gca!()` constant");
1802 if expr::WillCreateDefIdsVisitor.visit_expr(expr).is_break() {
1803 self.dcx().span_fatal(span, msg)
1806 } else {
1807 self.dcx().span_err(span, msg)
1808 }
1809 }
1810
1811 fn lower_ty_direct_lifetime(
1812 &mut self,
1813 t: &Ty,
1814 region: Option<Lifetime>,
1815 ) -> &'hir hir::Lifetime {
1816 let (region, syntax) = match region {
1817 Some(region) => (region, region.ident.into()),
1818
1819 None => {
1820 let id = if let Some(LifetimeRes::ElidedAnchor { start, end }) =
1821 self.curr_owner.owner.get_lifetime_res(t.id)
1822 {
1823 {
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);
1824 start
1825 } else {
1826 self.next_node_id()
1827 };
1828 let span = self.tcx.sess.source_map().start_point(t.span).shrink_to_hi();
1829 let region = Lifetime { ident: Ident::new(kw::UnderscoreLifetime, span), id };
1830 (region, LifetimeSyntax::Implicit)
1831 }
1832 };
1833 self.lower_lifetime(®ion, LifetimeSource::Reference, syntax)
1834 }
1835
1836 {}
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/6905905bb7727fd0f9223f5fdc9ad4e62236d5a2/compiler/rustc_ast_lowering/src/lib.rs"),
::tracing_core::__macro_support::Option::Some(1867u32),
::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::allow_all(&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/6905905bb7727fd0f9223f5fdc9ad4e62236d5a2/compiler/rustc_ast_lowering/src/lib.rs:1867",
"rustc_ast_lowering", ::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/6905905bb7727fd0f9223f5fdc9ad4e62236d5a2/compiler/rustc_ast_lowering/src/lib.rs"),
::tracing_core::__macro_support::Option::Some(1867u32),
::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)]
1868 fn lower_opaque_impl_trait(
1869 &mut self,
1870 span: Span,
1871 origin: hir::OpaqueTyOrigin<LocalDefId>,
1872 opaque_ty_node_id: NodeId,
1873 bounds: &GenericBounds,
1874 itctx: ImplTraitContext,
1875 ) -> hir::TyKind<'hir> {
1876 let opaque_ty_span = self.mark_span_with_reason(DesugaringKind::OpaqueTy, span, None);
1882
1883 self.lower_opaque_inner(opaque_ty_node_id, origin, opaque_ty_span, |this| {
1884 this.lower_param_bounds(
1885 bounds,
1886 RelaxedBoundPolicy::allow_all(&mut Default::default()),
1887 itctx,
1888 )
1889 })
1890 }
1891
1892 fn lower_opaque_inner(
1893 &mut self,
1894 opaque_ty_node_id: NodeId,
1895 origin: hir::OpaqueTyOrigin<LocalDefId>,
1896 opaque_ty_span: Span,
1897 lower_item_bounds: impl FnOnce(&mut Self) -> &'hir [hir::GenericBound<'hir>],
1898 ) -> hir::TyKind<'hir> {
1899 let opaque_ty_def_id = self.local_def_id(opaque_ty_node_id);
1900 let opaque_ty_hir_id = self.lower_node_id(opaque_ty_node_id);
1901 {
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("event /rustc-dev/6905905bb7727fd0f9223f5fdc9ad4e62236d5a2/compiler/rustc_ast_lowering/src/lib.rs:1901",
"rustc_ast_lowering", ::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/6905905bb7727fd0f9223f5fdc9ad4e62236d5a2/compiler/rustc_ast_lowering/src/lib.rs"),
::tracing_core::__macro_support::Option::Some(1901u32),
::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);
1902
1903 let bounds = lower_item_bounds(self);
1904 let opaque_ty_def = hir::OpaqueTy {
1905 hir_id: opaque_ty_hir_id,
1906 def_id: opaque_ty_def_id,
1907 bounds,
1908 origin,
1909 span: self.lower_span(opaque_ty_span),
1910 };
1911 let opaque_ty_def = self.arena.alloc(opaque_ty_def);
1912
1913 hir::TyKind::OpaqueDef(opaque_ty_def)
1914 }
1915
1916 fn lower_precise_capturing_args(
1917 &mut self,
1918 precise_capturing_args: &[PreciseCapturingArg],
1919 ) -> &'hir [hir::PreciseCapturingArg<'hir>] {
1920 self.arena.alloc_from_iter(precise_capturing_args.iter().map(|arg| match arg {
1921 PreciseCapturingArg::Lifetime(lt) => hir::PreciseCapturingArg::Lifetime(
1922 self.lower_lifetime(lt, LifetimeSource::PreciseCapturing, lt.ident.into()),
1923 ),
1924 PreciseCapturingArg::Arg(path, id) => {
1925 let [segment] = path.segments.as_slice() else {
1926 ::core::panicking::panic_default_msg();panic!();
1927 };
1928 let res = self.get_partial_res(*id).map_or(Res::Err, |partial_res| {
1929 partial_res.full_res().expect("no partial res expected for precise capture arg")
1930 });
1931 hir::PreciseCapturingArg::Param(hir::PreciseCapturingNonLifetimeArg {
1932 hir_id: self.lower_node_id(*id),
1933 ident: self.lower_ident(segment.ident),
1934 res: self.lower_res(res),
1935 })
1936 }
1937 }))
1938 }
1939
1940 fn lower_fn_params_to_idents(&mut self, decl: &FnDecl) -> &'hir [Option<Ident>] {
1941 self.arena.alloc_from_iter(decl.inputs.iter().filter(|param| !param.is_const_param()).map(
1942 |param| match param.pat.kind {
1943 PatKind::Missing => None,
1944 PatKind::Ident(_, ident, _) => Some(self.lower_ident(ident)),
1945 PatKind::Wild => Some(Ident::new(kw::Underscore, self.lower_span(param.pat.span))),
1946 _ => {
1947 self.dcx().span_delayed_bug(
1948 param.pat.span,
1949 "non-missing/ident/wild param pat must trigger an error",
1950 );
1951 None
1952 }
1953 },
1954 ))
1955 }
1956
1957 {}
#[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/6905905bb7727fd0f9223f5fdc9ad4e62236d5a2/compiler/rustc_ast_lowering/src/lib.rs"),
::tracing_core::__macro_support::Option::Some(1972u32),
::tracing_core::__macro_support::Option::Some("rustc_ast_lowering"),
::tracing_core::field::FieldSet::new(&[{
const NAME:
::tracing::__macro_support::FieldName<{
::tracing::__macro_support::FieldName::len("decl")
}> =
::tracing::__macro_support::FieldName::new("decl");
NAME.as_str()
},
{
const NAME:
::tracing::__macro_support::FieldName<{
::tracing::__macro_support::FieldName::len("fn_node_id")
}> =
::tracing::__macro_support::FieldName::new("fn_node_id");
NAME.as_str()
},
{
const NAME:
::tracing::__macro_support::FieldName<{
::tracing::__macro_support::FieldName::len("fn_hir_id")
}> =
::tracing::__macro_support::FieldName::new("fn_hir_id");
NAME.as_str()
},
{
const NAME:
::tracing::__macro_support::FieldName<{
::tracing::__macro_support::FieldName::len("kind")
}> =
::tracing::__macro_support::FieldName::new("kind");
NAME.as_str()
},
{
const NAME:
::tracing::__macro_support::FieldName<{
::tracing::__macro_support::FieldName::len("coro")
}> =
::tracing::__macro_support::FieldName::new("coro");
NAME.as_str()
},
{
const NAME:
::tracing::__macro_support::FieldName<{
::tracing::__macro_support::FieldName::len("discard_params")
}> =
::tracing::__macro_support::FieldName::new("discard_params");
NAME.as_str()
}], ::tracing_core::callsite::Identifier(&__CALLSITE)),
::tracing::metadata::Kind::SPAN)
};
::tracing::callsite::DefaultCallsite::new(&META)
};
let mut interest = ::tracing::subscriber::Interest::never();
if ::tracing::Level::DEBUG <=
::tracing::level_filters::STATIC_MAX_LEVEL &&
::tracing::Level::DEBUG <=
::tracing::level_filters::LevelFilter::current() &&
{ interest = __CALLSITE.interest(); !interest.is_never() }
&&
::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
interest) {
let meta = __CALLSITE.metadata();
::tracing::Span::new(meta,
&{
#[allow(unused_imports)]
use ::tracing::field::{debug, display, Value};
meta.fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&decl)
as &dyn ::tracing::field::Value)),
(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&fn_node_id)
as &dyn ::tracing::field::Value)),
(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&fn_hir_id)
as &dyn ::tracing::field::Value)),
(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&kind)
as &dyn ::tracing::field::Value)),
(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&coro)
as &dyn ::tracing::field::Value)),
(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&discard_params)
as &dyn ::tracing::field::Value))])
})
} else {
let span =
::tracing::__macro_support::__disabled_span(__CALLSITE.metadata());
{};
span
}
};
__tracing_attr_guard = __tracing_attr_span.enter();
}
#[warn(clippy :: suspicious_else_formatting)]
{
#[allow(unknown_lints, unreachable_code, clippy ::
diverging_sub_expression, clippy :: empty_loop, clippy ::
let_unit_value, clippy :: let_with_type_underscore, clippy ::
needless_return, clippy :: unreachable)]
if false {
let __tracing_attr_fake_return: &'hir hir::FnDecl<'hir> = loop {};
return __tracing_attr_fake_return;
}
{
let c_variadic = decl.c_variadic();
let mut splatted = decl.splatted();
let input_count =
if decl.c_variadic() {
splatted = None;
decl.inputs.len() - 1
} else { decl.inputs.len() };
let inputs = decl.inputs.iter().enumerate().take(input_count);
let inputs =
self.arena.alloc_from_iter(inputs.filter_map(|(param_idx,
param)|
{
if let Some(ident) = param.const_param_ident() {
if !#[allow(non_exhaustive_omitted_patterns)] match kind {
FnDeclKind::Fn | FnDeclKind::Inherent | FnDeclKind::Impl |
FnDeclKind::Trait => true,
_ => false,
} {
self.dcx().span_delayed_bug(param.span,
"Const args only allowed for Free/Inherent/Impl/Trait methods");
return None;
}
let ty =
self.lower_ty_alloc(¶m.ty,
ImplTraitContext::Disallowed(ImplTraitPosition::GenericDefault));
let hir_id = self.lower_node_id(param.id);
let generic_param =
hir::GenericParam {
hir_id,
def_id: self.local_def_id(param.id),
name: ParamName::Plain(self.lower_ident(ident)),
span: self.lower_span(param.span),
pure_wrt_drop: false,
kind: hir::GenericParamKind::Const {
ty,
default: None,
arg_pos: Some(param_idx as u16),
},
colon_span: None,
source: hir::GenericParamSource::Generics,
};
let ast_generic_param =
ast::GenericParam {
id: param.id,
ident,
attrs: param.attrs.clone(),
bounds: Default::default(),
is_placeholder: false,
kind: ast::GenericParamKind::Const {
ty: param.ty.clone(),
span: param.span,
default: None,
},
colon_span: None,
};
self.lower_attrs(hir_id, ¶m.attrs, param.span,
AstTarget::GenericParam(&ast_generic_param));
self.curr_owner.const_defs.push(generic_param);
return None;
}
if let DiscardParams::Yes = discard_params {
self.lower_attrs(fn_hir_id, ¶m.attrs, param.span,
AstTarget::Param(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)
}
};
Some(self.lower_ty(¶m.ty, itctx))
}));
let output =
match coro {
Some(coro) => {
let fn_def_id = self.curr_owner.owner.def_id;
self.lower_coroutine_fn_ret_ty(&decl.output, fn_def_id,
coro, kind)
}
None =>
match &decl.output {
FnRetTy::Ty(ty) => {
let itctx =
match kind {
FnDeclKind::Fn | FnDeclKind::Inherent =>
ImplTraitContext::OpaqueTy {
origin: hir::OpaqueTyOrigin::FnReturn {
parent: self.curr_owner.owner.def_id,
in_trait_or_impl: None,
},
},
FnDeclKind::Trait =>
ImplTraitContext::OpaqueTy {
origin: hir::OpaqueTyOrigin::FnReturn {
parent: self.curr_owner.owner.def_id,
in_trait_or_impl: Some(hir::RpitContext::Trait),
},
},
FnDeclKind::Impl =>
ImplTraitContext::OpaqueTy {
origin: hir::OpaqueTyOrigin::FnReturn {
parent: self.curr_owner.owner.def_id,
in_trait_or_impl: Some(hir::RpitContext::TraitImpl),
},
},
FnDeclKind::ExternFn => {
ImplTraitContext::Disallowed(ImplTraitPosition::ExternFnReturn)
}
FnDeclKind::Closure => {
ImplTraitContext::Disallowed(ImplTraitPosition::ClosureReturn)
}
FnDeclKind::Pointer => {
ImplTraitContext::Disallowed(ImplTraitPosition::PointerReturn)
}
};
hir::FnRetTy::Return(self.lower_ty_alloc(ty, itctx))
}
FnRetTy::Default(span) =>
hir::FnRetTy::DefaultReturn(self.lower_span(*span)),
},
};
let fn_decl_kind =
hir::FnDeclFlags::default().set_implicit_self(decl.inputs.get(0).map_or(hir::ImplicitSelfKind::None,
|arg|
{
let is_mutable_pat =
#[allow(non_exhaustive_omitted_patterns)] match arg.pat.kind
{
PatKind::Ident(hir::BindingMode(_, Mutability::Mut), ..) =>
true,
_ => false,
};
match &arg.ty.kind {
TyKind::ImplicitSelf if is_mutable_pat =>
hir::ImplicitSelfKind::Mut,
TyKind::ImplicitSelf => hir::ImplicitSelfKind::Imm,
TyKind::Ref(_, ty, mutbl) | TyKind::PinnedRef(_, ty, mutbl)
if ty.kind.is_implicit_self() => {
match mutbl {
hir::Mutability::Not => hir::ImplicitSelfKind::RefImm,
hir::Mutability::Mut => hir::ImplicitSelfKind::RefMut,
}
}
_ => hir::ImplicitSelfKind::None,
}
})).set_lifetime_elision_allowed(self.curr_owner.owner.id ==
fn_node_id &&
self.curr_owner.owner.lifetime_elision_allowed).set_c_variadic(c_variadic).set_splatted(splatted,
inputs.len()).unwrap();
self.arena.alloc(hir::FnDecl { inputs, output, fn_decl_kind })
}
}
}#[instrument(level = "debug", skip(self))]
1973 fn lower_fn_decl(
1974 &mut self,
1975 decl: &FnDecl,
1976 fn_node_id: NodeId,
1977 fn_hir_id: HirId,
1978 kind: FnDeclKind,
1979 coro: Option<CoroutineMarker>,
1980 discard_params: DiscardParams,
1981 ) -> &'hir hir::FnDecl<'hir> {
1982 let c_variadic = decl.c_variadic();
1983 let mut splatted = decl.splatted();
1984
1985 let input_count = if decl.c_variadic() {
1989 splatted = None;
1991 decl.inputs.len() - 1
1992 } else {
1993 decl.inputs.len()
1994 };
1995
1996 let inputs = decl.inputs.iter().enumerate().take(input_count);
1997 let inputs = self.arena.alloc_from_iter(inputs.filter_map(|(param_idx, param)| {
2001 if let Some(ident) = param.const_param_ident() {
2002 if !matches!(
2003 kind,
2004 FnDeclKind::Fn | FnDeclKind::Inherent | FnDeclKind::Impl | FnDeclKind::Trait
2005 ) {
2006 self.dcx().span_delayed_bug(
2007 param.span,
2008 "Const args only allowed for Free/Inherent/Impl/Trait methods",
2009 );
2010 return None;
2011 }
2012 let ty = self.lower_ty_alloc(
2013 ¶m.ty,
2014 ImplTraitContext::Disallowed(ImplTraitPosition::GenericDefault),
2015 );
2016 let hir_id = self.lower_node_id(param.id);
2017 let generic_param = hir::GenericParam {
2018 hir_id,
2019 def_id: self.local_def_id(param.id),
2020 name: ParamName::Plain(self.lower_ident(ident)),
2021 span: self.lower_span(param.span),
2022 pure_wrt_drop: false,
2023 kind: hir::GenericParamKind::Const {
2024 ty,
2025 default: None,
2026 arg_pos: Some(param_idx as u16),
2027 },
2028 colon_span: None,
2029 source: hir::GenericParamSource::Generics,
2030 };
2031 let ast_generic_param = ast::GenericParam {
2032 id: param.id,
2033 ident,
2034 attrs: param.attrs.clone(),
2035 bounds: Default::default(),
2036 is_placeholder: false,
2037 kind: ast::GenericParamKind::Const {
2038 ty: param.ty.clone(),
2039 span: param.span,
2040 default: None,
2041 },
2042 colon_span: None,
2043 };
2044 self.lower_attrs(
2045 hir_id,
2046 ¶m.attrs,
2047 param.span,
2048 AstTarget::GenericParam(&ast_generic_param),
2049 );
2050 self.curr_owner.const_defs.push(generic_param);
2051 return None;
2052 }
2053 if let DiscardParams::Yes = discard_params {
2054 self.lower_attrs(fn_hir_id, ¶m.attrs, param.span, AstTarget::Param(param));
2058 }
2059 let itctx = match kind {
2060 FnDeclKind::Fn | FnDeclKind::Inherent | FnDeclKind::Impl | FnDeclKind::Trait => {
2061 ImplTraitContext::Universal
2062 }
2063 FnDeclKind::ExternFn => {
2064 ImplTraitContext::Disallowed(ImplTraitPosition::ExternFnParam)
2065 }
2066 FnDeclKind::Closure => {
2067 ImplTraitContext::Disallowed(ImplTraitPosition::ClosureParam)
2068 }
2069 FnDeclKind::Pointer => {
2070 ImplTraitContext::Disallowed(ImplTraitPosition::PointerParam)
2071 }
2072 };
2073 Some(self.lower_ty(¶m.ty, itctx))
2074 }));
2075
2076 let output = match coro {
2077 Some(coro) => {
2078 let fn_def_id = self.curr_owner.owner.def_id;
2079 self.lower_coroutine_fn_ret_ty(&decl.output, fn_def_id, coro, kind)
2080 }
2081 None => match &decl.output {
2082 FnRetTy::Ty(ty) => {
2083 let itctx = match kind {
2084 FnDeclKind::Fn | FnDeclKind::Inherent => ImplTraitContext::OpaqueTy {
2085 origin: hir::OpaqueTyOrigin::FnReturn {
2086 parent: self.curr_owner.owner.def_id,
2087 in_trait_or_impl: None,
2088 },
2089 },
2090 FnDeclKind::Trait => ImplTraitContext::OpaqueTy {
2091 origin: hir::OpaqueTyOrigin::FnReturn {
2092 parent: self.curr_owner.owner.def_id,
2093 in_trait_or_impl: Some(hir::RpitContext::Trait),
2094 },
2095 },
2096 FnDeclKind::Impl => ImplTraitContext::OpaqueTy {
2097 origin: hir::OpaqueTyOrigin::FnReturn {
2098 parent: self.curr_owner.owner.def_id,
2099 in_trait_or_impl: Some(hir::RpitContext::TraitImpl),
2100 },
2101 },
2102 FnDeclKind::ExternFn => {
2103 ImplTraitContext::Disallowed(ImplTraitPosition::ExternFnReturn)
2104 }
2105 FnDeclKind::Closure => {
2106 ImplTraitContext::Disallowed(ImplTraitPosition::ClosureReturn)
2107 }
2108 FnDeclKind::Pointer => {
2109 ImplTraitContext::Disallowed(ImplTraitPosition::PointerReturn)
2110 }
2111 };
2112 hir::FnRetTy::Return(self.lower_ty_alloc(ty, itctx))
2113 }
2114 FnRetTy::Default(span) => hir::FnRetTy::DefaultReturn(self.lower_span(*span)),
2115 },
2116 };
2117
2118 let fn_decl_kind = hir::FnDeclFlags::default()
2119 .set_implicit_self(decl.inputs.get(0).map_or(hir::ImplicitSelfKind::None, |arg| {
2120 let is_mutable_pat = matches!(
2121 arg.pat.kind,
2122 PatKind::Ident(hir::BindingMode(_, Mutability::Mut), ..)
2123 );
2124
2125 match &arg.ty.kind {
2126 TyKind::ImplicitSelf if is_mutable_pat => hir::ImplicitSelfKind::Mut,
2127 TyKind::ImplicitSelf => hir::ImplicitSelfKind::Imm,
2128 TyKind::Ref(_, ty, mutbl) | TyKind::PinnedRef(_, ty, mutbl)
2132 if ty.kind.is_implicit_self() =>
2133 {
2134 match mutbl {
2135 hir::Mutability::Not => hir::ImplicitSelfKind::RefImm,
2136 hir::Mutability::Mut => hir::ImplicitSelfKind::RefMut,
2137 }
2138 }
2139 _ => hir::ImplicitSelfKind::None,
2140 }
2141 }))
2142 .set_lifetime_elision_allowed(
2143 self.curr_owner.owner.id == fn_node_id
2144 && self.curr_owner.owner.lifetime_elision_allowed,
2145 )
2146 .set_c_variadic(c_variadic)
2147 .set_splatted(splatted, inputs.len())
2148 .unwrap();
2149
2150 self.arena.alloc(hir::FnDecl { inputs, output, fn_decl_kind })
2151 }
2152
2153 {}
#[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/6905905bb7727fd0f9223f5fdc9ad4e62236d5a2/compiler/rustc_ast_lowering/src/lib.rs"),
::tracing_core::__macro_support::Option::Some(2161u32),
::tracing_core::__macro_support::Option::Some("rustc_ast_lowering"),
::tracing_core::field::FieldSet::new(&[{
const NAME:
::tracing::__macro_support::FieldName<{
::tracing::__macro_support::FieldName::len("output")
}> =
::tracing::__macro_support::FieldName::new("output");
NAME.as_str()
},
{
const NAME:
::tracing::__macro_support::FieldName<{
::tracing::__macro_support::FieldName::len("fn_def_id")
}> =
::tracing::__macro_support::FieldName::new("fn_def_id");
NAME.as_str()
},
{
const NAME:
::tracing::__macro_support::FieldName<{
::tracing::__macro_support::FieldName::len("coro")
}> =
::tracing::__macro_support::FieldName::new("coro");
NAME.as_str()
},
{
const NAME:
::tracing::__macro_support::FieldName<{
::tracing::__macro_support::FieldName::len("fn_kind")
}> =
::tracing::__macro_support::FieldName::new("fn_kind");
NAME.as_str()
}], ::tracing_core::callsite::Identifier(&__CALLSITE)),
::tracing::metadata::Kind::SPAN)
};
::tracing::callsite::DefaultCallsite::new(&META)
};
let mut interest = ::tracing::subscriber::Interest::never();
if ::tracing::Level::DEBUG <=
::tracing::level_filters::STATIC_MAX_LEVEL &&
::tracing::Level::DEBUG <=
::tracing::level_filters::LevelFilter::current() &&
{ interest = __CALLSITE.interest(); !interest.is_never() }
&&
::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
interest) {
let meta = __CALLSITE.metadata();
::tracing::Span::new(meta,
&{
#[allow(unused_imports)]
use ::tracing::field::{debug, display, Value};
meta.fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&output)
as &dyn ::tracing::field::Value)),
(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&fn_def_id)
as &dyn ::tracing::field::Value)),
(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&coro)
as &dyn ::tracing::field::Value)),
(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&fn_kind)
as &dyn ::tracing::field::Value))])
})
} else {
let span =
::tracing::__macro_support::__disabled_span(__CALLSITE.metadata());
{};
span
}
};
__tracing_attr_guard = __tracing_attr_span.enter();
}
#[warn(clippy :: suspicious_else_formatting)]
{
#[allow(unknown_lints, unreachable_code, clippy ::
diverging_sub_expression, clippy :: empty_loop, clippy ::
let_unit_value, clippy :: let_with_type_underscore, clippy ::
needless_return, clippy :: unreachable)]
if false {
let __tracing_attr_fake_return: hir::FnRetTy<'hir> = loop {};
return __tracing_attr_fake_return;
}
{
let span = self.lower_span(output.span());
let (opaque_ty_node_id, allowed_features) =
match coro.kind {
CoroutineKind::Async | CoroutineKind::Gen =>
(coro.return_impl_trait_id, None),
CoroutineKind::AsyncGen => {
(coro.return_impl_trait_id,
Some(Arc::clone(&ALLOW_ASYNC_ITERATOR)))
}
};
let opaque_ty_span =
self.mark_span_with_reason(DesugaringKind::Async, span,
allowed_features);
let in_trait_or_impl =
match fn_kind {
FnDeclKind::Trait => Some(hir::RpitContext::Trait),
FnDeclKind::Impl => Some(hir::RpitContext::TraitImpl),
FnDeclKind::Fn | FnDeclKind::Inherent => None,
FnDeclKind::ExternFn | FnDeclKind::Closure |
FnDeclKind::Pointer =>
::core::panicking::unreachable_default_msg(),
};
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))]
2162 fn lower_coroutine_fn_ret_ty(
2163 &mut self,
2164 output: &FnRetTy,
2165 fn_def_id: LocalDefId,
2166 coro: CoroutineMarker,
2167 fn_kind: FnDeclKind,
2168 ) -> hir::FnRetTy<'hir> {
2169 let span = self.lower_span(output.span());
2170
2171 let (opaque_ty_node_id, allowed_features) = match coro.kind {
2172 CoroutineKind::Async | CoroutineKind::Gen => (coro.return_impl_trait_id, None),
2173 CoroutineKind::AsyncGen => {
2174 (coro.return_impl_trait_id, Some(Arc::clone(&ALLOW_ASYNC_ITERATOR)))
2175 }
2176 };
2177
2178 let opaque_ty_span =
2179 self.mark_span_with_reason(DesugaringKind::Async, span, allowed_features);
2180
2181 let in_trait_or_impl = match fn_kind {
2182 FnDeclKind::Trait => Some(hir::RpitContext::Trait),
2183 FnDeclKind::Impl => Some(hir::RpitContext::TraitImpl),
2184 FnDeclKind::Fn | FnDeclKind::Inherent => None,
2185 FnDeclKind::ExternFn | FnDeclKind::Closure | FnDeclKind::Pointer => unreachable!(),
2186 };
2187
2188 let opaque_ty_ref = self.lower_opaque_inner(
2189 opaque_ty_node_id,
2190 hir::OpaqueTyOrigin::AsyncFn { parent: fn_def_id, in_trait_or_impl },
2191 opaque_ty_span,
2192 |this| {
2193 let bound = this.lower_coroutine_fn_output_type_to_bound(
2194 output,
2195 coro,
2196 opaque_ty_span,
2197 ImplTraitContext::OpaqueTy {
2198 origin: hir::OpaqueTyOrigin::FnReturn {
2199 parent: fn_def_id,
2200 in_trait_or_impl,
2201 },
2202 },
2203 );
2204 arena_vec![this; bound]
2205 },
2206 );
2207
2208 let opaque_ty = self.ty(opaque_ty_span, opaque_ty_ref);
2209 hir::FnRetTy::Return(self.arena.alloc(opaque_ty))
2210 }
2211
2212 fn lower_coroutine_fn_output_type_to_bound(
2214 &mut self,
2215 output: &FnRetTy,
2216 coro: CoroutineMarker,
2217 opaque_ty_span: Span,
2218 itctx: ImplTraitContext,
2219 ) -> hir::GenericBound<'hir> {
2220 let output_ty = match output {
2222 FnRetTy::Ty(ty) => {
2223 self.lower_ty_alloc(ty, itctx)
2227 }
2228 FnRetTy::Default(ret_ty_span) => self.arena.alloc(self.ty_tup(*ret_ty_span, &[])),
2229 };
2230
2231 let (assoc_ty_name, trait_lang_item) = match coro.kind {
2233 CoroutineKind::Async => (sym::Output, LangItem::Future),
2234 CoroutineKind::Gen => (sym::Item, LangItem::Iterator),
2235 CoroutineKind::AsyncGen => (sym::Item, LangItem::AsyncIterator),
2236 };
2237
2238 let bound_args = self.arena.alloc(hir::GenericArgs {
2239 args: &[],
2240 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)],
2241 parenthesized: hir::GenericArgsParentheses::No,
2242 span_ext: DUMMY_SP,
2243 });
2244
2245 hir::GenericBound::Trait(hir::PolyTraitRef {
2246 bound_generic_params: &[],
2247 modifiers: hir::TraitBoundModifiers::NONE,
2248 trait_ref: hir::TraitRef {
2249 path: self.make_lang_item_path(trait_lang_item, opaque_ty_span, Some(bound_args)),
2250 hir_ref_id: self.next_id(),
2251 },
2252 span: opaque_ty_span,
2253 })
2254 }
2255
2256 {}
#[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/6905905bb7727fd0f9223f5fdc9ad4e62236d5a2/compiler/rustc_ast_lowering/src/lib.rs"),
::tracing_core::__macro_support::Option::Some(2256u32),
::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))]
2257 fn lower_param_bound(
2258 &mut self,
2259 tpb: &GenericBound,
2260 rbp: RelaxedBoundPolicy<'_>,
2261 itctx: ImplTraitContext,
2262 ) -> hir::GenericBound<'hir> {
2263 match tpb {
2264 GenericBound::Trait(p) => {
2265 hir::GenericBound::Trait(self.lower_poly_trait_ref(p, rbp, itctx))
2266 }
2267 GenericBound::Outlives(lifetime) => hir::GenericBound::Outlives(self.lower_lifetime(
2268 lifetime,
2269 LifetimeSource::OutlivesBound,
2270 lifetime.ident.into(),
2271 )),
2272 GenericBound::Use(args, span) => hir::GenericBound::Use(
2273 self.lower_precise_capturing_args(args),
2274 self.lower_span(*span),
2275 ),
2276 }
2277 }
2278
2279 fn lower_lifetime(
2280 &mut self,
2281 l: &Lifetime,
2282 source: LifetimeSource,
2283 syntax: LifetimeSyntax,
2284 ) -> &'hir hir::Lifetime {
2285 self.new_named_lifetime(l.id, l.id, l.ident, source, syntax)
2286 }
2287
2288 fn lower_lifetime_hidden_in_path(
2289 &mut self,
2290 id: NodeId,
2291 span: Span,
2292 angle_brackets: AngleBrackets,
2293 ) -> &'hir hir::Lifetime {
2294 self.new_named_lifetime(
2295 id,
2296 id,
2297 Ident::new(kw::UnderscoreLifetime, span),
2298 LifetimeSource::Path { angle_brackets },
2299 LifetimeSyntax::Implicit,
2300 )
2301 }
2302
2303 {}
#[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/6905905bb7727fd0f9223f5fdc9ad4e62236d5a2/compiler/rustc_ast_lowering/src/lib.rs"),
::tracing_core::__macro_support::Option::Some(2303u32),
::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/6905905bb7727fd0f9223f5fdc9ad4e62236d5a2/compiler/rustc_ast_lowering/src/lib.rs:2337",
"rustc_ast_lowering", ::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/6905905bb7727fd0f9223f5fdc9ad4e62236d5a2/compiler/rustc_ast_lowering/src/lib.rs"),
::tracing_core::__macro_support::Option::Some(2337u32),
::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))]
2304 fn new_named_lifetime(
2305 &mut self,
2306 id: NodeId,
2307 new_id: NodeId,
2308 ident: Ident,
2309 source: LifetimeSource,
2310 syntax: LifetimeSyntax,
2311 ) -> &'hir hir::Lifetime {
2312 let res = if let Some(res) = self.curr_owner.owner.get_lifetime_res(id) {
2313 match res {
2314 LifetimeRes::Param { param, .. } => hir::LifetimeKind::Param(param),
2315 LifetimeRes::Fresh { param, .. } => {
2316 assert_eq!(ident.name, kw::UnderscoreLifetime);
2317 let param = self.local_def_id(param);
2318 hir::LifetimeKind::Param(param)
2319 }
2320 LifetimeRes::Infer => {
2321 assert_eq!(ident.name, kw::UnderscoreLifetime);
2322 hir::LifetimeKind::Infer
2323 }
2324 LifetimeRes::Static { .. } => {
2325 assert!(matches!(ident.name, kw::StaticLifetime | kw::UnderscoreLifetime));
2326 hir::LifetimeKind::Static
2327 }
2328 LifetimeRes::Error(guar) => hir::LifetimeKind::Error(guar),
2329 LifetimeRes::ElidedAnchor { .. } => {
2330 panic!("Unexpected `ElidedAnchar` {:?} at {:?}", ident, ident.span);
2331 }
2332 }
2333 } else {
2334 hir::LifetimeKind::Error(self.dcx().span_delayed_bug(ident.span, "unresolved lifetime"))
2335 };
2336
2337 debug!(?res);
2338 self.arena.alloc(hir::Lifetime::new(
2339 self.lower_node_id(new_id),
2340 self.lower_ident(ident),
2341 res,
2342 source,
2343 syntax,
2344 ))
2345 }
2346
2347 fn lower_generic_params_mut(
2348 &mut self,
2349 params: &[GenericParam],
2350 source: hir::GenericParamSource,
2351 ) -> impl Iterator<Item = hir::GenericParam<'hir>> {
2352 params.iter().map(move |param| self.lower_generic_param(param, source))
2353 }
2354
2355 fn lower_generic_params(
2356 &mut self,
2357 params: &[GenericParam],
2358 source: hir::GenericParamSource,
2359 ) -> &'hir [hir::GenericParam<'hir>] {
2360 self.arena.alloc_from_iter(self.lower_generic_params_mut(params, source))
2361 }
2362
2363 {}
#[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/6905905bb7727fd0f9223f5fdc9ad4e62236d5a2/compiler/rustc_ast_lowering/src/lib.rs"),
::tracing_core::__macro_support::Option::Some(2363u32),
::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(¶m)
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 = ¶m.attrs;
let param_span = param.span();
let param_hir =
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(¶m.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,
AstTarget::GenericParam(param));
param_hir
}
}
}#[instrument(level = "trace", skip(self))]
2364 fn lower_generic_param(
2365 &mut self,
2366 param: &GenericParam,
2367 source: hir::GenericParamSource,
2368 ) -> hir::GenericParam<'hir> {
2369 let (name, kind) = self.lower_generic_param_kind(param, source);
2370
2371 let hir_id = self.lower_node_id(param.id);
2372 let param_attrs = ¶m.attrs;
2373 let param_span = param.span();
2374 let param_hir = hir::GenericParam {
2375 hir_id,
2376 def_id: self.local_def_id(param.id),
2377 name,
2378 span: self.lower_span(param.span()),
2379 pure_wrt_drop: attr::contains_name(¶m.attrs, sym::may_dangle),
2380 kind,
2381 colon_span: param.colon_span.map(|s| self.lower_span(s)),
2382 source,
2383 };
2384 self.lower_attrs(hir_id, param_attrs, param_span, AstTarget::GenericParam(param));
2385 param_hir
2386 }
2387
2388 fn lower_generic_param_kind(
2389 &mut self,
2390 param: &GenericParam,
2391 source: hir::GenericParamSource,
2392 ) -> (hir::ParamName, hir::GenericParamKind<'hir>) {
2393 match ¶m.kind {
2394 GenericParamKind::Lifetime => {
2395 let ident = self.lower_ident(param.ident);
2398 let param_name = if let Some(LifetimeRes::Error(..)) =
2399 self.curr_owner.owner.get_lifetime_res(param.id)
2400 {
2401 ParamName::Error(ident)
2402 } else {
2403 ParamName::Plain(ident)
2404 };
2405 let kind =
2406 hir::GenericParamKind::Lifetime { kind: hir::LifetimeParamKind::Explicit };
2407
2408 (param_name, kind)
2409 }
2410 GenericParamKind::Type { default, .. } => {
2411 let default = default
2414 .as_ref()
2415 .filter(|_| match source {
2416 hir::GenericParamSource::Generics => true,
2417 hir::GenericParamSource::Binder => {
2418 self.dcx().emit_err(diagnostics::GenericParamDefaultInBinder {
2419 span: param.span(),
2420 });
2421
2422 false
2423 }
2424 })
2425 .map(|def| {
2426 self.lower_ty_alloc(
2427 def,
2428 ImplTraitContext::Disallowed(ImplTraitPosition::GenericDefault),
2429 )
2430 });
2431
2432 let kind = hir::GenericParamKind::Type { default, synthetic: false };
2433
2434 (hir::ParamName::Plain(self.lower_ident(param.ident)), kind)
2435 }
2436 GenericParamKind::Const { ty, span: _, default } => {
2437 let ty = self.lower_ty_alloc(
2438 ty,
2439 ImplTraitContext::Disallowed(ImplTraitPosition::GenericDefault),
2440 );
2441
2442 let default = default
2445 .as_ref()
2446 .filter(|anon_const| match source {
2447 hir::GenericParamSource::Generics => true,
2448 hir::GenericParamSource::Binder => {
2449 let err =
2450 diagnostics::GenericParamDefaultInBinder { span: param.span() };
2451 if expr::WillCreateDefIdsVisitor
2452 .visit_expr(&anon_const.value)
2453 .is_break()
2454 {
2455 self.dcx().emit_fatal(err)
2459 } else {
2460 self.dcx().emit_err(err);
2461 false
2462 }
2463 }
2464 })
2465 .map(|def| self.lower_anon_const_to_const_arg_and_alloc(def));
2466
2467 (
2468 hir::ParamName::Plain(self.lower_ident(param.ident)),
2469 hir::GenericParamKind::Const { ty, default, arg_pos: None },
2470 )
2471 }
2472 }
2473 }
2474
2475 fn lower_trait_ref(
2476 &mut self,
2477 modifiers: ast::TraitBoundModifiers,
2478 p: &TraitRef,
2479 itctx: ImplTraitContext,
2480 ) -> hir::TraitRef<'hir> {
2481 let path = match self.lower_qpath(
2482 p.ref_id,
2483 &None,
2484 &p.path,
2485 ParamMode::Explicit,
2486 AllowReturnTypeNotation::No,
2487 itctx,
2488 Some(modifiers),
2489 ) {
2490 hir::QPath::Resolved(None, path) => path,
2491 qpath => {
::core::panicking::panic_fmt(format_args!("lower_trait_ref: unexpected QPath `{0:?}`",
qpath));
}panic!("lower_trait_ref: unexpected QPath `{qpath:?}`"),
2492 };
2493 hir::TraitRef { path, hir_ref_id: self.lower_node_id(p.ref_id) }
2494 }
2495
2496 {}
#[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/6905905bb7727fd0f9223f5fdc9ad4e62236d5a2/compiler/rustc_ast_lowering/src/lib.rs"),
::tracing_core::__macro_support::Option::Some(2496u32),
::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))]
2497 fn lower_poly_trait_ref(
2498 &mut self,
2499 PolyTraitRef { bound_generic_params, modifiers, trait_ref, span, parens: _ }: &PolyTraitRef,
2500 rbp: RelaxedBoundPolicy<'_>,
2501 itctx: ImplTraitContext,
2502 ) -> hir::PolyTraitRef<'hir> {
2503 let bound_generic_params =
2504 self.lower_lifetime_binder(trait_ref.ref_id, bound_generic_params);
2505 let trait_ref = self.lower_trait_ref(*modifiers, trait_ref, itctx);
2506 let modifiers = self.lower_trait_bound_modifiers(*modifiers);
2507
2508 if let ast::BoundPolarity::Maybe(_) = modifiers.polarity {
2509 self.validate_relaxed_bound(trait_ref, *span, rbp);
2510 }
2511
2512 hir::PolyTraitRef {
2513 bound_generic_params,
2514 modifiers,
2515 trait_ref,
2516 span: self.lower_span(*span),
2517 }
2518 }
2519
2520 fn validate_relaxed_bound(
2521 &self,
2522 trait_ref: hir::TraitRef<'_>,
2523 span: Span,
2524 rbp: RelaxedBoundPolicy<'_>,
2525 ) {
2526 let tcx = self.tcx;
2527
2528 let deny = |trait_name: Option<&str>| {
2529 let (context, subject) = match rbp.reason {
2530 Some(RelaxedBoundForbiddenReason::TraitObjectTy) => {
2531 ("trait object types", "trait object types")
2532 }
2533 Some(RelaxedBoundForbiddenReason::SuperTrait) => ("supertrait bounds", "traits"),
2534 Some(RelaxedBoundForbiddenReason::TraitAlias) => {
2535 ("trait alias bounds", "trait aliases")
2536 }
2537 Some(RelaxedBoundForbiddenReason::AssocTyBounds)
2538 | Some(RelaxedBoundForbiddenReason::WhereBound)
2539 | None => {
2540 self.dcx()
2541 .struct_span_err(span, "this relaxed bound is not permitted here")
2542 .with_note(
2543 "in this context, relaxed bounds are only allowed on \
2544 type parameters defined on the closest item",
2545 )
2546 .emit();
2547 return;
2548 }
2549 };
2550
2551 let mut diag = self.dcx().struct_span_err(
2552 span,
2553 ::alloc::__export::must_use({
::alloc::fmt::format(format_args!("relaxed {0}bounds are not permitted in {1}",
trait_name.map(|i|
::alloc::__export::must_use({
::alloc::fmt::format(format_args!("`{0}` ", i))
})).unwrap_or_default(), context))
})format!(
2554 "relaxed {}bounds are not permitted in {context}",
2555 trait_name.map(|i| format!("`{i}` ")).unwrap_or_default()
2556 ),
2557 );
2558 if let Some(name) = trait_name {
2559 diag.note(::alloc::__export::must_use({
::alloc::fmt::format(format_args!("{0} are not implicitly bounded by `{1}`, so there is nothing to relax",
subject, name))
})format!(
2560 "{subject} are not implicitly bounded by `{name}`, \
2561 so there is nothing to relax"
2562 ));
2563 }
2564 diag.emit();
2565 };
2566
2567 let Some(trait_def_id) = trait_ref.trait_def_id() else { return };
2570
2571 if self.tcx.is_lang_item(trait_def_id, LangItem::Sized) {
2572 if !rbp.allowed_bounds.contains(AllowedRelaxedBounds::SIZED) {
2573 return deny(Some("Sized"));
2574 }
2575 } else if self.tcx.features().more_maybe_bounds()
2576 && !rbp.allowed_bounds.contains(AllowedRelaxedBounds::OTHER)
2577 {
2578 match rbp.reason {
2582 Some(RelaxedBoundForbiddenReason::TraitObjectTy)
2583 | Some(RelaxedBoundForbiddenReason::SuperTrait)
2584 | Some(RelaxedBoundForbiddenReason::TraitAlias)
2585 | None => {
2586 return;
2587 }
2588 Some(RelaxedBoundForbiddenReason::AssocTyBounds)
2589 | Some(RelaxedBoundForbiddenReason::WhereBound) => return deny(None),
2590 }
2591 }
2592
2593 let err = |s| {
2594 let name = tcx.item_name(trait_def_id);
2595 tcx.dcx()
2596 .struct_span_err(::alloc::boxed::box_assume_init_into_vec_unsafe(::alloc::intrinsics::write_box_via_move(::alloc::boxed::Box::new_uninit(),
[span, s]))vec![span, s], ::alloc::__export::must_use({
::alloc::fmt::format(format_args!("duplicate relaxed `{0}` bounds",
name))
})format!("duplicate relaxed `{name}` bounds"))
2597 .with_code(E0203)
2598 .emit();
2599 };
2600 rbp.dedup.entry(trait_def_id).and_modify(|&mut s| err(s)).or_insert(span);
2601 }
2602
2603 {}
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/6905905bb7727fd0f9223f5fdc9ad4e62236d5a2/compiler/rustc_ast_lowering/src/lib.rs"),
::tracing_core::__macro_support::Option::Some(2603u32),
::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/6905905bb7727fd0f9223f5fdc9ad4e62236d5a2/compiler/rustc_ast_lowering/src/lib.rs:2603",
"rustc_ast_lowering", ::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/6905905bb7727fd0f9223f5fdc9ad4e62236d5a2/compiler/rustc_ast_lowering/src/lib.rs"),
::tracing_core::__macro_support::Option::Some(2603u32),
::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)]
2604 fn lower_param_bounds(
2605 &mut self,
2606 bounds: &[GenericBound],
2607 rbp: RelaxedBoundPolicy<'_>,
2608 itctx: ImplTraitContext,
2609 ) -> hir::GenericBounds<'hir> {
2610 self.arena.alloc_from_iter(self.lower_param_bounds_mut(bounds, rbp, itctx))
2611 }
2612
2613 fn lower_param_bounds_mut(
2614 &mut self,
2615 bounds: &[GenericBound],
2616 mut rbp: RelaxedBoundPolicy<'_>,
2617 itctx: ImplTraitContext,
2618 ) -> impl Iterator<Item = hir::GenericBound<'hir>> {
2619 bounds.iter().map(move |bound| self.lower_param_bound(bound, rbp.reborrow(), itctx))
2620 }
2621
2622 {}
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/6905905bb7727fd0f9223f5fdc9ad4e62236d5a2/compiler/rustc_ast_lowering/src/lib.rs"),
::tracing_core::__macro_support::Option::Some(2622u32),
::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::allow_all(&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/6905905bb7727fd0f9223f5fdc9ad4e62236d5a2/compiler/rustc_ast_lowering/src/lib.rs:2622",
"rustc_ast_lowering", ::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/6905905bb7727fd0f9223f5fdc9ad4e62236d5a2/compiler/rustc_ast_lowering/src/lib.rs"),
::tracing_core::__macro_support::Option::Some(2622u32),
::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)]
2623 fn lower_universal_param_and_bounds(
2624 &mut self,
2625 node_id: NodeId,
2626 span: Span,
2627 ident: Ident,
2628 bounds: &[GenericBound],
2629 ) -> (hir::GenericParam<'hir>, Option<hir::WherePredicate<'hir>>, hir::TyKind<'hir>) {
2630 let def_id = self.local_def_id(node_id);
2632 let span = self.lower_span(span);
2633
2634 let param = hir::GenericParam {
2636 hir_id: self.lower_node_id(node_id),
2637 def_id,
2638 name: ParamName::Plain(self.lower_ident(ident)),
2639 pure_wrt_drop: false,
2640 span,
2641 kind: hir::GenericParamKind::Type { default: None, synthetic: true },
2642 colon_span: None,
2643 source: hir::GenericParamSource::Generics,
2644 };
2645
2646 let preds = self.lower_generic_bound_predicate(
2647 ident,
2648 node_id,
2649 &GenericParamKind::Type { default: None },
2650 bounds,
2651 None,
2652 span,
2653 RelaxedBoundPolicy::allow_all(&mut Default::default()),
2654 ImplTraitContext::Universal,
2655 hir::PredicateOrigin::ImplTrait,
2656 );
2657
2658 let hir_id = self.next_id();
2659 let res = Res::Def(DefKind::TyParam, def_id.to_def_id());
2660 let ty = hir::TyKind::Path(hir::QPath::Resolved(
2661 None,
2662 self.arena.alloc(hir::Path {
2663 span,
2664 res,
2665 segments:
2666 arena_vec![self; hir::PathSegment::new(self.lower_ident(ident), hir_id, res)],
2667 }),
2668 ));
2669
2670 (param, preds, ty)
2671 }
2672
2673 fn lower_block_expr(&mut self, b: &Block) -> hir::Expr<'hir> {
2676 let block = self.lower_block(b, false);
2677 self.expr_block(block)
2678 }
2679
2680 fn lower_array_length_to_const_arg(&mut self, c: &AnonConst) -> &'hir hir::ConstArg<'hir> {
2681 match c.value.peel_parens().kind {
2688 ExprKind::Underscore => {
2689 let ct_kind = hir::ConstArgKind::Infer(());
2690 self.arena.alloc(hir::ConstArg {
2691 hir_id: self.lower_node_id(c.id),
2692 kind: ct_kind,
2693 span: self.lower_span(c.value.span),
2694 })
2695 }
2696 _ => self.lower_anon_const_to_const_arg_and_alloc(c),
2697 }
2698 }
2699
2700 {}
#[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/6905905bb7727fd0f9223f5fdc9ad4e62236d5a2/compiler/rustc_ast_lowering/src/lib.rs"),
::tracing_core::__macro_support::Option::Some(2703u32),
::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))]
2704 fn lower_const_path_to_const_arg(
2705 &mut self,
2706 qself: &Option<Box<QSelf>>,
2707 path: &Path,
2708 res: Res<NodeId>,
2709 id: NodeId,
2710 span: Span,
2711 ) -> hir::ConstArg<'hir> {
2712 let context = self.ambient_direct_const_arg_context();
2713 if self.can_lower_path_to_const_arg_direct(qself, path, span, Some(res), context).is_ok() {
2714 let span = self.lower_span(span);
2715 self.lower_path_to_const_arg_direct(id, None, qself, path, span)
2716 } else {
2717 let node_id = self.next_node_id();
2719 let span = self.lower_span(span);
2720
2721 let def_id = self.create_def(node_id, None, DefKind::AnonConst, span);
2726 let hir_id = self.lower_node_id(node_id);
2727
2728 let path_expr = Expr {
2729 id,
2730 kind: ExprKind::Path(qself.clone(), path.clone()),
2731 span,
2732 attrs: AttrVec::new(),
2733 tokens: None,
2734 };
2735
2736 let ct = self.with_new_scopes(span, |this| {
2737 self.arena.alloc(hir::AnonConst {
2738 def_id,
2739 hir_id,
2740 body: this.lower_const_body(path_expr.span, Some(&path_expr)),
2741 span,
2742 })
2743 });
2744 hir::ConstArg {
2745 hir_id: self.next_id(),
2746 kind: hir::ConstArgKind::Anon(ct),
2747 span: self.lower_span(span),
2748 }
2749 }
2750 }
2751
2752 fn lower_const_item_rhs(
2753 &mut self,
2754 body: &Option<Box<Expr>>,
2755 span: Span,
2756 ) -> hir::ConstItemRhs<'hir> {
2757 let is_direct = |body| {
2758 let context = if self.tcx.features().gca_macroless_items() {
2759 self.direct_const_arg_context_enabled_by_gca_macro()
2760 } else {
2761 DirectConstArgContext::GCA_MACRO
2762 };
2763 self.can_lower_expr_to_const_arg_direct(body, context).is_ok()
2764 };
2765 if self.tcx.features().gca_min_const_items()
2766 && let Some(body) = body
2767 && is_direct(body)
2768 {
2769 hir::ConstItemRhs::Direct(
2770 self.arena.alloc(self.lower_expr_to_const_arg_direct(&body, None)),
2771 )
2772 } else {
2773 hir::ConstItemRhs::Body(self.lower_const_body(span, body.as_deref()))
2774 }
2775 }
2776
2777 fn direct_const_arg_context_enabled_by_gca_macro(&self) -> DirectConstArgContext {
2778 let mut result = DirectConstArgContext::GCA_BASE_FEATURES;
2779 if self.tcx.features().gca_min_const_items() {
2780 result |= DirectConstArgContext::GCA_MIN_CONST_ITEMS;
2781 }
2782 if self.tcx.features().gca_adts() {
2783 result |= DirectConstArgContext::GCA_ADTS;
2784 }
2785 result
2786 }
2787
2788 fn ambient_direct_const_arg_context(&self) -> DirectConstArgContext {
2790 if self.tcx.features().gca_macroless_args() {
2791 self.direct_const_arg_context_enabled_by_gca_macro()
2792 } else if self.tcx.features().gca() {
2793 DirectConstArgContext::GCA
2794 } else {
2795 DirectConstArgContext::STABLE
2796 }
2797 }
2798
2799 fn can_lower_path_to_const_arg_direct(
2800 &self,
2801 qself: &Option<Box<QSelf>>,
2802 path: &Path,
2803 span: Span,
2804 res: Option<Res<NodeId>>,
2805 context: DirectConstArgContext,
2806 ) -> Result<(), UnrepresentableConstArgError> {
2807 if context.contains(DirectConstArgContext::PATH_ANY) {
2808 Ok(())
2809 } else if context.contains(DirectConstArgContext::PATH_CONST_CTOR)
2810 && #[allow(non_exhaustive_omitted_patterns)] match res {
Some(Res::Def(DefKind::Ctor(_, CtorKind::Const), _)) => true,
_ => false,
}matches!(res, Some(Res::Def(DefKind::Ctor(_, CtorKind::Const), _)))
2811 {
2812 Ok(())
2815 } else if context.contains(DirectConstArgContext::PATH_PLAIN_PARAM)
2816 && qself.is_none()
2817 && path.is_single_argless_ident()
2818 && #[allow(non_exhaustive_omitted_patterns)] match res {
Some(Res::Def(DefKind::ConstParam, _)) => true,
_ => false,
}matches!(res, Some(Res::Def(DefKind::ConstParam, _)))
2819 {
2820 Ok(())
2821 } else {
2822 Err(UnrepresentableConstArgError { span, will_create_def_ids: false })
2823 }
2824 }
2825
2826 {}
let __tracing_attr_span;
let __tracing_attr_guard;
if ::tracing::Level::DEBUG <= ::tracing::level_filters::STATIC_MAX_LEVEL &&
::tracing::Level::DEBUG <=
::tracing::level_filters::LevelFilter::current() || { false }
{
__tracing_attr_span =
{
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("can_lower_expr_to_const_arg_direct",
"rustc_ast_lowering", ::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/6905905bb7727fd0f9223f5fdc9ad4e62236d5a2/compiler/rustc_ast_lowering/src/lib.rs"),
::tracing_core::__macro_support::Option::Some(2826u32),
::tracing_core::__macro_support::Option::Some("rustc_ast_lowering"),
::tracing_core::field::FieldSet::new(&[{
const NAME:
::tracing::__macro_support::FieldName<{
::tracing::__macro_support::FieldName::len("expr")
}> =
::tracing::__macro_support::FieldName::new("expr");
NAME.as_str()
},
{
const NAME:
::tracing::__macro_support::FieldName<{
::tracing::__macro_support::FieldName::len("context")
}> =
::tracing::__macro_support::FieldName::new("context");
NAME.as_str()
}], ::tracing_core::callsite::Identifier(&__CALLSITE)),
::tracing::metadata::Kind::SPAN)
};
::tracing::callsite::DefaultCallsite::new(&META)
};
let mut interest = ::tracing::subscriber::Interest::never();
if ::tracing::Level::DEBUG <=
::tracing::level_filters::STATIC_MAX_LEVEL &&
::tracing::Level::DEBUG <=
::tracing::level_filters::LevelFilter::current() &&
{ interest = __CALLSITE.interest(); !interest.is_never() }
&&
::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
interest) {
let meta = __CALLSITE.metadata();
::tracing::Span::new(meta,
&{
#[allow(unused_imports)]
use ::tracing::field::{debug, display, Value};
meta.fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&expr)
as &dyn ::tracing::field::Value)),
(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&context)
as &dyn ::tracing::field::Value))])
})
} else {
let span =
::tracing::__macro_support::__disabled_span(__CALLSITE.metadata());
{};
span
}
};
__tracing_attr_guard = __tracing_attr_span.enter();
}
#[allow(clippy :: redundant_closure_call)]
let x =
(move ||
{
#[allow(unknown_lints, unreachable_code, clippy ::
diverging_sub_expression, clippy :: empty_loop, clippy ::
let_unit_value, clippy :: let_with_type_underscore, clippy
:: needless_return, clippy :: unreachable)]
if false {
let __tracing_attr_fake_return:
Result<(), UnrepresentableConstArgError> = loop {};
return __tracing_attr_fake_return;
}
{
match &expr.kind {
ExprKind::Call(Expr { kind: ExprKind::Path(_, _), .. },
args) if context.contains(DirectConstArgContext::TUPLE_CALL)
=> {
for arg in args {
self.can_lower_expr_to_const_arg_direct(arg, context)?;
}
Ok(())
}
ExprKind::Tup(exprs) if
context.contains(DirectConstArgContext::TUPLE) => {
for expr in exprs {
self.can_lower_expr_to_const_arg_direct(expr, context)?;
}
Ok(())
}
ExprKind::Path(qself, path) => {
let res =
self.get_partial_res(expr.id).and_then(|partial_res|
partial_res.full_res());
self.can_lower_path_to_const_arg_direct(qself, path,
expr.span, res, context)
}
ExprKind::Struct(se) if
context.contains(DirectConstArgContext::STRUCT) => {
for f in &se.fields {
self.can_lower_expr_to_const_arg_direct(&f.expr, context)?;
}
Ok(())
}
ExprKind::Array(elements) if
context.contains(DirectConstArgContext::ARRAY) => {
for element in elements {
self.can_lower_expr_to_const_arg_direct(element, context)?;
}
Ok(())
}
ExprKind::Underscore if
context.contains(DirectConstArgContext::UNDERSCORE) =>
Ok(()),
ExprKind::Paren(expr) if
context.contains(DirectConstArgContext::PAREN) => {
self.can_lower_expr_to_const_arg_direct(expr, context)
}
ExprKind::Block(block, _) if
context.contains(DirectConstArgContext::BLOCK) &&
let [stmt] = block.stmts.as_slice() &&
let StmtKind::Expr(expr) = &stmt.kind => {
self.can_lower_expr_to_const_arg_direct(expr, context)
}
ExprKind::Lit(_) if
context.contains(DirectConstArgContext::LIT) => Ok(()),
ExprKind::Unary(UnOp::Neg, inner_expr) if
context.contains(DirectConstArgContext::LIT) &&
let ExprKind::Lit(_) = &inner_expr.kind => {
Ok(())
}
ExprKind::ConstBlock(_) if
context.contains(DirectConstArgContext::CONST_BLOCK) => {
Ok(())
}
ExprKind::GcaMacro(_) if
context.contains(DirectConstArgContext::GCA_MACRO) => {
Ok(())
}
_ => Err(UnrepresentableConstArgError::new(expr)),
}
}
})();
{
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("event /rustc-dev/6905905bb7727fd0f9223f5fdc9ad4e62236d5a2/compiler/rustc_ast_lowering/src/lib.rs:2826",
"rustc_ast_lowering", ::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/6905905bb7727fd0f9223f5fdc9ad4e62236d5a2/compiler/rustc_ast_lowering/src/lib.rs"),
::tracing_core::__macro_support::Option::Some(2826u32),
::tracing_core::__macro_support::Option::Some("rustc_ast_lowering"),
::tracing_core::field::FieldSet::new(&[{
const NAME:
::tracing::__macro_support::FieldName<{
::tracing::__macro_support::FieldName::len("return")
}> =
::tracing::__macro_support::FieldName::new("return");
NAME.as_str()
}], ::tracing_core::callsite::Identifier(&__CALLSITE)),
::tracing::metadata::Kind::EVENT)
};
::tracing::callsite::DefaultCallsite::new(&META)
};
let enabled =
::tracing::Level::DEBUG <= ::tracing::level_filters::STATIC_MAX_LEVEL
&&
::tracing::Level::DEBUG <=
::tracing::level_filters::LevelFilter::current() &&
{
let interest = __CALLSITE.interest();
!interest.is_never() &&
::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
interest)
};
if enabled {
(|value_set: ::tracing::field::ValueSet|
{
let meta = __CALLSITE.metadata();
::tracing::Event::dispatch(meta, &value_set);
;
})({
#[allow(unused_imports)]
use ::tracing::field::{debug, display, Value};
__CALLSITE.metadata().fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&x)
as &dyn ::tracing::field::Value))])
});
} else { ; }
};
x;#[instrument(level = "debug", skip(self), ret)]
2827 fn can_lower_expr_to_const_arg_direct(
2828 &self,
2829 expr: &Expr,
2830 context: DirectConstArgContext,
2831 ) -> Result<(), UnrepresentableConstArgError> {
2832 match &expr.kind {
2834 ExprKind::Call(Expr { kind: ExprKind::Path(_, _), .. }, args)
2835 if context.contains(DirectConstArgContext::TUPLE_CALL) =>
2836 {
2837 for arg in args {
2838 self.can_lower_expr_to_const_arg_direct(arg, context)?;
2839 }
2840 Ok(())
2841 }
2842 ExprKind::Tup(exprs) if context.contains(DirectConstArgContext::TUPLE) => {
2843 for expr in exprs {
2844 self.can_lower_expr_to_const_arg_direct(expr, context)?;
2845 }
2846 Ok(())
2847 }
2848 ExprKind::Path(qself, path) => {
2849 let res =
2850 self.get_partial_res(expr.id).and_then(|partial_res| partial_res.full_res());
2851 self.can_lower_path_to_const_arg_direct(qself, path, expr.span, res, context)
2852 }
2853 ExprKind::Struct(se) if context.contains(DirectConstArgContext::STRUCT) => {
2854 for f in &se.fields {
2855 self.can_lower_expr_to_const_arg_direct(&f.expr, context)?;
2856 }
2857 Ok(())
2858 }
2859 ExprKind::Array(elements) if context.contains(DirectConstArgContext::ARRAY) => {
2860 for element in elements {
2861 self.can_lower_expr_to_const_arg_direct(element, context)?;
2862 }
2863 Ok(())
2864 }
2865 ExprKind::Underscore if context.contains(DirectConstArgContext::UNDERSCORE) => Ok(()),
2866 ExprKind::Paren(expr) if context.contains(DirectConstArgContext::PAREN) => {
2867 self.can_lower_expr_to_const_arg_direct(expr, context)
2868 }
2869 ExprKind::Block(block, _)
2870 if context.contains(DirectConstArgContext::BLOCK)
2871 && let [stmt] = block.stmts.as_slice()
2872 && let StmtKind::Expr(expr) = &stmt.kind =>
2873 {
2874 self.can_lower_expr_to_const_arg_direct(expr, context)
2875 }
2876 ExprKind::Lit(_) if context.contains(DirectConstArgContext::LIT) => Ok(()),
2877 ExprKind::Unary(UnOp::Neg, inner_expr)
2878 if context.contains(DirectConstArgContext::LIT)
2879 && let ExprKind::Lit(_) = &inner_expr.kind =>
2880 {
2881 Ok(())
2882 }
2883 ExprKind::ConstBlock(_) if context.contains(DirectConstArgContext::CONST_BLOCK) => {
2884 Ok(())
2885 }
2886 ExprKind::GcaMacro(_) if context.contains(DirectConstArgContext::GCA_MACRO) => {
2887 Ok(())
2890 }
2891 _ => Err(UnrepresentableConstArgError::new(expr)),
2892 }
2893 }
2894
2895 fn lower_path_to_const_arg_direct(
2898 &mut self,
2899 id: NodeId,
2900 id_override: Option<NodeId>,
2901 qself: &Option<Box<QSelf>>,
2902 path: &Path,
2903 span: Span,
2904 ) -> hir::ConstArg<'hir> {
2905 let qpath = self.lower_qpath(
2906 id,
2907 qself,
2908 path,
2909 ParamMode::Explicit,
2910 AllowReturnTypeNotation::No,
2911 ImplTraitContext::Disallowed(ImplTraitPosition::Path),
2913 None,
2914 );
2915
2916 let node_id = id_override.unwrap_or(id);
2917 ConstArg { hir_id: self.lower_node_id(node_id), kind: hir::ConstArgKind::Path(qpath), span }
2918 }
2919
2920 {}
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/6905905bb7727fd0f9223f5fdc9ad4e62236d5a2/compiler/rustc_ast_lowering/src/lib.rs"),
::tracing_core::__macro_support::Option::Some(2922u32),
::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|
self.lower_expr_to_const_arg_direct(arg, None)));
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|
self.lower_expr_to_const_arg_direct(expr, None)));
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,
AstTarget::ExprField(f));
let expr =
self.lower_expr_to_const_arg_direct(&f.expr, None);
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|
self.lower_expr_to_const_arg_direct(element, None)));
let array_expr =
self.arena.alloc(hir::ConstArgArrayExpr {
span: self.lower_span(expr.span),
elems: lowered_elems,
});
ConstArg {
hir_id: self.lower_node_id(node_id),
kind: hir::ConstArgKind::Array(array_expr),
span,
}
}
ExprKind::Underscore =>
ConstArg {
hir_id: self.lower_node_id(node_id),
kind: hir::ConstArgKind::Infer(()),
span,
},
ExprKind::Paren(expr) =>
self.lower_expr_to_const_arg_direct(expr, id_override),
ExprKind::Block(block, _) if
let [stmt] = block.stmts.as_slice() &&
let StmtKind::Expr(expr) = &stmt.kind => {
self.lower_expr_to_const_arg_direct(expr, id_override)
}
ExprKind::Lit(literal) => {
let span = self.lower_span(expr.span);
let literal = self.lower_lit(literal, span);
ConstArg {
hir_id: self.lower_node_id(node_id),
kind: hir::ConstArgKind::Literal {
lit: literal.node,
negated: false,
},
span,
}
}
ExprKind::Unary(UnOp::Neg, inner_expr) if
let ExprKind::Lit(literal) = &inner_expr.kind => {
let span = self.lower_span(expr.span);
let literal = self.lower_lit(literal, span);
let kind =
if !#[allow(non_exhaustive_omitted_patterns)] match literal.node
{
LitKind::Int(..) => true,
_ => false,
} {
let err =
self.dcx().span_err(expr.span,
"negated literal must be an integer");
hir::ConstArgKind::Error(err)
} else {
hir::ConstArgKind::Literal {
lit: literal.node,
negated: true,
}
};
ConstArg { hir_id: self.lower_node_id(node_id), kind, span }
}
ExprKind::ConstBlock(anon_const) => {
let def_id = self.local_def_id(anon_const.id);
{
match (&DefKind::AnonConst, &self.tcx.def_kind(def_id)) {
(left_val, right_val) => {
if !(*left_val == *right_val) {
let kind = ::core::panicking::AssertKind::Eq;
::core::panicking::assert_failed(kind, &*left_val,
&*right_val, ::core::option::Option::None);
}
}
}
};
let lowered_anon =
self.lower_anon_const_to_anon_const(anon_const, span);
ConstArg {
hir_id: self.lower_node_id(node_id),
kind: hir::ConstArgKind::Anon(lowered_anon),
span,
}
}
ExprKind::GcaMacro(expr) => {
match self.can_lower_expr_to_const_arg_direct(expr,
self.direct_const_arg_context_enabled_by_gca_macro()) {
Ok(()) =>
self.lower_expr_to_const_arg_direct(expr, id_override),
Err(err) => err.emit(self),
}
}
_ => {
::rustc_span::macros::bug_impl(Some(expr.span),
format_args!("lower_expr_to_const_arg_direct encountered an unlowerable expression, either can_lower_expr_to_const_arg_direct returned Ok() on something it shouldn\'t have, or you forgot to check can_lower_expr_to_const_arg_direct first"),
Location::caller());
}
}
}
})();
{
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("event /rustc-dev/6905905bb7727fd0f9223f5fdc9ad4e62236d5a2/compiler/rustc_ast_lowering/src/lib.rs:2922",
"rustc_ast_lowering", ::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/6905905bb7727fd0f9223f5fdc9ad4e62236d5a2/compiler/rustc_ast_lowering/src/lib.rs"),
::tracing_core::__macro_support::Option::Some(2922u32),
::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)]
2923 fn lower_expr_to_const_arg_direct(
2924 &mut self,
2925 expr: &Expr,
2926 id_override: Option<NodeId>,
2927 ) -> hir::ConstArg<'hir> {
2928 let span = self.lower_span(expr.span);
2929 let node_id = id_override.unwrap_or(expr.id);
2930 match &expr.kind {
2931 ExprKind::Call(func, args) if let ExprKind::Path(qself, path) = &func.kind => {
2932 let qpath = self.lower_qpath(
2933 func.id,
2934 qself,
2935 path,
2936 ParamMode::Explicit,
2937 AllowReturnTypeNotation::No,
2938 ImplTraitContext::Disallowed(ImplTraitPosition::Path),
2939 None,
2940 );
2941
2942 let lowered_args = self.arena.alloc_from_iter(
2943 args.iter().map(|arg| self.lower_expr_to_const_arg_direct(arg, None)),
2944 );
2945
2946 ConstArg {
2947 hir_id: self.lower_node_id(node_id),
2948 kind: hir::ConstArgKind::TupleCall(qpath, lowered_args),
2949 span,
2950 }
2951 }
2952 ExprKind::Tup(exprs) => {
2953 let exprs = self.arena.alloc_from_iter(
2954 exprs.iter().map(|expr| self.lower_expr_to_const_arg_direct(expr, None)),
2955 );
2956
2957 ConstArg {
2958 hir_id: self.lower_node_id(node_id),
2959 kind: hir::ConstArgKind::Tup(exprs),
2960 span,
2961 }
2962 }
2963 ExprKind::Path(qself, path) => {
2964 self.lower_path_to_const_arg_direct(expr.id, id_override, qself, path, span)
2965 }
2966 ExprKind::Struct(se) => {
2967 let path = self.lower_qpath(
2968 expr.id,
2969 &se.qself,
2970 &se.path,
2971 ParamMode::Explicit,
2975 AllowReturnTypeNotation::No,
2976 ImplTraitContext::Disallowed(ImplTraitPosition::Path),
2977 None,
2978 );
2979
2980 let fields = self.arena.alloc_from_iter(se.fields.iter().map(|f| {
2981 let hir_id = self.lower_node_id(f.id);
2982 self.lower_attrs(hir_id, &f.attrs, f.span, AstTarget::ExprField(f));
2986 let expr = self.lower_expr_to_const_arg_direct(&f.expr, None);
2987
2988 hir::ConstArgExprField {
2989 hir_id,
2990 field: self.lower_ident(f.ident),
2991 expr: self.arena.alloc(expr),
2992 span: self.lower_span(f.span),
2993 }
2994 }));
2995
2996 ConstArg {
2997 hir_id: self.lower_node_id(node_id),
2998 kind: hir::ConstArgKind::Struct(path, fields),
2999 span,
3000 }
3001 }
3002 ExprKind::Array(elements) => {
3003 let lowered_elems = self.arena.alloc_from_iter(
3004 elements
3005 .iter()
3006 .map(|element| self.lower_expr_to_const_arg_direct(element, None)),
3007 );
3008 let array_expr = self.arena.alloc(hir::ConstArgArrayExpr {
3009 span: self.lower_span(expr.span),
3010 elems: lowered_elems,
3011 });
3012
3013 ConstArg {
3014 hir_id: self.lower_node_id(node_id),
3015 kind: hir::ConstArgKind::Array(array_expr),
3016 span,
3017 }
3018 }
3019 ExprKind::Underscore => ConstArg {
3020 hir_id: self.lower_node_id(node_id),
3021 kind: hir::ConstArgKind::Infer(()),
3022 span,
3023 },
3024 ExprKind::Paren(expr) => self.lower_expr_to_const_arg_direct(expr, id_override),
3025 ExprKind::Block(block, _)
3026 if let [stmt] = block.stmts.as_slice()
3027 && let StmtKind::Expr(expr) = &stmt.kind =>
3028 {
3029 self.lower_expr_to_const_arg_direct(expr, id_override)
3030 }
3031 ExprKind::Lit(literal) => {
3032 let span = self.lower_span(expr.span);
3033 let literal = self.lower_lit(literal, span);
3034
3035 ConstArg {
3036 hir_id: self.lower_node_id(node_id),
3037 kind: hir::ConstArgKind::Literal { lit: literal.node, negated: false },
3038 span,
3039 }
3040 }
3041 ExprKind::Unary(UnOp::Neg, inner_expr)
3042 if let ExprKind::Lit(literal) = &inner_expr.kind =>
3043 {
3044 let span = self.lower_span(expr.span);
3045 let literal = self.lower_lit(literal, span);
3046
3047 let kind = if !matches!(literal.node, LitKind::Int(..)) {
3048 let err = self.dcx().span_err(expr.span, "negated literal must be an integer");
3049 hir::ConstArgKind::Error(err)
3050 } else {
3051 hir::ConstArgKind::Literal { lit: literal.node, negated: true }
3052 };
3053 ConstArg { hir_id: self.lower_node_id(node_id), kind, span }
3054 }
3055 ExprKind::ConstBlock(anon_const) => {
3056 let def_id = self.local_def_id(anon_const.id);
3059 assert_eq!(DefKind::AnonConst, self.tcx.def_kind(def_id));
3060 let lowered_anon = self.lower_anon_const_to_anon_const(anon_const, span);
3061 ConstArg {
3062 hir_id: self.lower_node_id(node_id),
3063 kind: hir::ConstArgKind::Anon(lowered_anon),
3064 span,
3065 }
3066 }
3067 ExprKind::GcaMacro(expr) => {
3068 match self.can_lower_expr_to_const_arg_direct(
3072 expr,
3073 self.direct_const_arg_context_enabled_by_gca_macro(),
3074 ) {
3075 Ok(()) => self.lower_expr_to_const_arg_direct(expr, id_override),
3076 Err(err) => err.emit(self),
3077 }
3078 }
3079 _ => {
3080 span_bug!(
3081 expr.span,
3082 "lower_expr_to_const_arg_direct encountered an unlowerable expression, either \
3083 can_lower_expr_to_const_arg_direct returned Ok() on something it shouldn't \
3084 have, or you forgot to check can_lower_expr_to_const_arg_direct first"
3085 );
3086 }
3087 }
3088 }
3089
3090 fn lower_anon_const_to_const_arg_and_alloc(
3093 &mut self,
3094 anon: &AnonConst,
3095 ) -> &'hir hir::ConstArg<'hir> {
3096 self.arena.alloc(self.lower_anon_const_to_const_arg(anon))
3097 }
3098
3099 {}
#[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/6905905bb7727fd0f9223f5fdc9ad4e62236d5a2/compiler/rustc_ast_lowering/src/lib.rs"),
::tracing_core::__macro_support::Option::Some(3099u32),
::tracing_core::__macro_support::Option::Some("rustc_ast_lowering"),
::tracing_core::field::FieldSet::new(&[{
const NAME:
::tracing::__macro_support::FieldName<{
::tracing::__macro_support::FieldName::len("anon")
}> =
::tracing::__macro_support::FieldName::new("anon");
NAME.as_str()
}], ::tracing_core::callsite::Identifier(&__CALLSITE)),
::tracing::metadata::Kind::SPAN)
};
::tracing::callsite::DefaultCallsite::new(&META)
};
let mut interest = ::tracing::subscriber::Interest::never();
if ::tracing::Level::DEBUG <=
::tracing::level_filters::STATIC_MAX_LEVEL &&
::tracing::Level::DEBUG <=
::tracing::level_filters::LevelFilter::current() &&
{ interest = __CALLSITE.interest(); !interest.is_never() }
&&
::tracing::__macro_support::__is_enabled(__CALLSITE.metadata(),
interest) {
let meta = __CALLSITE.metadata();
::tracing::Span::new(meta,
&{
#[allow(unused_imports)]
use ::tracing::field::{debug, display, Value};
meta.fields().value_set_all(&[(::tracing::__macro_support::Option::Some(&::tracing::field::debug(&anon)
as &dyn ::tracing::field::Value))])
})
} else {
let span =
::tracing::__macro_support::__disabled_span(__CALLSITE.metadata());
{};
span
}
};
__tracing_attr_guard = __tracing_attr_span.enter();
}
#[warn(clippy :: suspicious_else_formatting)]
{
#[allow(unknown_lints, unreachable_code, clippy ::
diverging_sub_expression, clippy :: empty_loop, clippy ::
let_unit_value, clippy :: let_with_type_underscore, clippy ::
needless_return, clippy :: unreachable)]
if false {
let __tracing_attr_fake_return: hir::ConstArg<'hir> = loop {};
return __tracing_attr_fake_return;
}
{
let expr =
if self.tcx.features().gca_macroless_args() {
&anon.value
} else { anon.value.maybe_unwrap_block() };
let context = self.ambient_direct_const_arg_context();
if self.can_lower_expr_to_const_arg_direct(expr, context).is_ok()
{
return self.lower_expr_to_const_arg_direct(expr,
Some(anon.id));
}
let lowered_anon =
self.lower_anon_const_to_anon_const(anon, anon.value.span);
ConstArg {
hir_id: self.next_id(),
kind: hir::ConstArgKind::Anon(lowered_anon),
span: self.lower_span(anon.value.span),
}
}
}
}#[instrument(level = "debug", skip(self))]
3100 fn lower_anon_const_to_const_arg(&mut self, anon: &AnonConst) -> hir::ConstArg<'hir> {
3101 let expr = if self.tcx.features().gca_macroless_args() {
3104 &anon.value
3105 } else {
3106 anon.value.maybe_unwrap_block()
3107 };
3108
3109 let context = self.ambient_direct_const_arg_context();
3110 if self.can_lower_expr_to_const_arg_direct(expr, context).is_ok() {
3111 return self.lower_expr_to_const_arg_direct(expr, Some(anon.id));
3112 }
3113
3114 let lowered_anon = self.lower_anon_const_to_anon_const(anon, anon.value.span);
3115 ConstArg {
3116 hir_id: self.next_id(),
3117 kind: hir::ConstArgKind::Anon(lowered_anon),
3118 span: self.lower_span(anon.value.span),
3119 }
3120 }
3121
3122 fn lower_anon_const_to_anon_const(
3125 &mut self,
3126 c: &AnonConst,
3127 span: Span,
3128 ) -> &'hir hir::AnonConst {
3129 self.arena.alloc(self.with_new_scopes(c.value.span, |this| {
3130 let def_id = this.local_def_id(c.id);
3131 let hir_id = this.lower_node_id(c.id);
3132 hir::AnonConst {
3133 def_id,
3134 hir_id,
3135 body: this.lower_const_body(c.value.span, Some(&c.value)),
3136 span: this.lower_span(span),
3137 }
3138 }))
3139 }
3140
3141 fn lower_unsafe_source(&self, u: UnsafeSource) -> hir::UnsafeSource {
3142 match u {
3143 CompilerGenerated => hir::UnsafeSource::CompilerGenerated,
3144 UserProvided => hir::UnsafeSource::UserProvided,
3145 }
3146 }
3147
3148 fn lower_trait_bound_modifiers(
3149 &self,
3150 modifiers: TraitBoundModifiers,
3151 ) -> hir::TraitBoundModifiers {
3152 let constness = match modifiers.constness {
3153 BoundConstness::Never => BoundConstness::Never,
3154 BoundConstness::Always(span) => BoundConstness::Always(self.lower_span(span)),
3155 BoundConstness::Maybe(span) => BoundConstness::Maybe(self.lower_span(span)),
3156 };
3157 let polarity = match modifiers.polarity {
3158 BoundPolarity::Positive => BoundPolarity::Positive,
3159 BoundPolarity::Negative(span) => BoundPolarity::Negative(self.lower_span(span)),
3160 BoundPolarity::Maybe(span) => BoundPolarity::Maybe(self.lower_span(span)),
3161 };
3162 hir::TraitBoundModifiers { constness, polarity }
3163 }
3164
3165 fn stmt(&mut self, span: Span, kind: hir::StmtKind<'hir>) -> hir::Stmt<'hir> {
3168 hir::Stmt { span: self.lower_span(span), kind, hir_id: self.next_id() }
3169 }
3170
3171 fn stmt_expr(&mut self, span: Span, expr: hir::Expr<'hir>) -> hir::Stmt<'hir> {
3172 self.stmt(span, hir::StmtKind::Expr(self.arena.alloc(expr)))
3173 }
3174
3175 fn stmt_let_pat(
3176 &mut self,
3177 attrs: Option<&'hir [rustc_attr_ir::Attribute]>,
3178 span: Span,
3179 init: Option<&'hir hir::Expr<'hir>>,
3180 pat: &'hir hir::Pat<'hir>,
3181 source: hir::LocalSource,
3182 ) -> hir::Stmt<'hir> {
3183 let hir_id = self.next_id();
3184 if let Some(a) = attrs {
3185 if !!a.is_empty() {
::core::panicking::panic("assertion failed: !a.is_empty()")
};assert!(!a.is_empty());
3186 self.curr_owner.attrs.insert(hir_id.local_id, a);
3187 }
3188 let local = hir::LetStmt {
3189 super_: None,
3190 hir_id,
3191 init,
3192 pat,
3193 els: None,
3194 source,
3195 span: self.lower_span(span),
3196 ty: None,
3197 };
3198 self.stmt(span, hir::StmtKind::Let(self.arena.alloc(local)))
3199 }
3200
3201 fn stmt_super_let_pat(
3202 &mut self,
3203 span: Span,
3204 pat: &'hir hir::Pat<'hir>,
3205 init: Option<&'hir hir::Expr<'hir>>,
3206 ) -> hir::Stmt<'hir> {
3207 let hir_id = self.next_id();
3208 let span = self.lower_span(span);
3209 let local = hir::LetStmt {
3210 super_: Some(span),
3211 hir_id,
3212 init,
3213 pat,
3214 els: None,
3215 source: hir::LocalSource::Normal,
3216 span,
3217 ty: None,
3218 };
3219 self.stmt(span, hir::StmtKind::Let(self.arena.alloc(local)))
3220 }
3221
3222 fn block_expr(&mut self, expr: &'hir hir::Expr<'hir>) -> &'hir hir::Block<'hir> {
3223 self.block_all(expr.span, &[], Some(expr))
3224 }
3225
3226 fn block_all(
3227 &mut self,
3228 span: Span,
3229 stmts: &'hir [hir::Stmt<'hir>],
3230 expr: Option<&'hir hir::Expr<'hir>>,
3231 ) -> &'hir hir::Block<'hir> {
3232 let blk = hir::Block {
3233 stmts,
3234 expr,
3235 hir_id: self.next_id(),
3236 rules: hir::BlockCheckMode::DefaultBlock,
3237 span: self.lower_span(span),
3238 targeted_by_break: false,
3239 };
3240 self.arena.alloc(blk)
3241 }
3242
3243 fn pat_cf_continue(&mut self, span: Span, pat: &'hir hir::Pat<'hir>) -> &'hir hir::Pat<'hir> {
3244 let field = self.single_pat_field(span, pat);
3245 self.pat_lang_item_variant(span, LangItem::ControlFlowContinue, field)
3246 }
3247
3248 fn pat_cf_break(&mut self, span: Span, pat: &'hir hir::Pat<'hir>) -> &'hir hir::Pat<'hir> {
3249 let field = self.single_pat_field(span, pat);
3250 self.pat_lang_item_variant(span, LangItem::ControlFlowBreak, field)
3251 }
3252
3253 fn pat_some(&mut self, span: Span, pat: &'hir hir::Pat<'hir>) -> &'hir hir::Pat<'hir> {
3254 let field = self.single_pat_field(span, pat);
3255 self.pat_lang_item_variant(span, LangItem::OptionSome, field)
3256 }
3257
3258 fn pat_none(&mut self, span: Span) -> &'hir hir::Pat<'hir> {
3259 self.pat_lang_item_variant(span, LangItem::OptionNone, &[])
3260 }
3261
3262 fn single_pat_field(
3263 &mut self,
3264 span: Span,
3265 pat: &'hir hir::Pat<'hir>,
3266 ) -> &'hir [hir::PatField<'hir>] {
3267 let field = hir::PatField {
3268 hir_id: self.next_id(),
3269 ident: Ident::new(sym::integer(0), self.lower_span(span)),
3270 is_shorthand: false,
3271 pat,
3272 span: self.lower_span(span),
3273 };
3274 self.arena.alloc_from_iter([field])arena_vec![self; field]
3275 }
3276
3277 fn pat_lang_item_variant(
3278 &mut self,
3279 span: Span,
3280 lang_item: LangItem,
3281 fields: &'hir [hir::PatField<'hir>],
3282 ) -> &'hir hir::Pat<'hir> {
3283 let path = self.make_lang_item_qpath(lang_item, self.lower_span(span), None);
3284 self.pat(span, hir::PatKind::Struct(path, fields, None))
3285 }
3286
3287 fn pat_ident(&mut self, span: Span, ident: Ident) -> (&'hir hir::Pat<'hir>, HirId) {
3288 self.pat_ident_binding_mode(span, ident, hir::BindingMode::NONE)
3289 }
3290
3291 fn pat_ident_mut(&mut self, span: Span, ident: Ident) -> (hir::Pat<'hir>, HirId) {
3292 self.pat_ident_binding_mode_mut(span, ident, hir::BindingMode::NONE)
3293 }
3294
3295 fn pat_ident_binding_mode(
3296 &mut self,
3297 span: Span,
3298 ident: Ident,
3299 bm: hir::BindingMode,
3300 ) -> (&'hir hir::Pat<'hir>, HirId) {
3301 let (pat, hir_id) = self.pat_ident_binding_mode_mut(span, ident, bm);
3302 (self.arena.alloc(pat), hir_id)
3303 }
3304
3305 fn pat_ident_binding_mode_mut(
3306 &mut self,
3307 span: Span,
3308 ident: Ident,
3309 bm: hir::BindingMode,
3310 ) -> (hir::Pat<'hir>, HirId) {
3311 let hir_id = self.next_id();
3312
3313 (
3314 hir::Pat {
3315 hir_id,
3316 kind: hir::PatKind::Binding(bm, hir_id, self.lower_ident(ident), None),
3317 span: self.lower_span(span),
3318 default_binding_modes: true,
3319 },
3320 hir_id,
3321 )
3322 }
3323
3324 fn pat(&mut self, span: Span, kind: hir::PatKind<'hir>) -> &'hir hir::Pat<'hir> {
3325 self.arena.alloc(hir::Pat {
3326 hir_id: self.next_id(),
3327 kind,
3328 span: self.lower_span(span),
3329 default_binding_modes: true,
3330 })
3331 }
3332
3333 fn pat_without_dbm(&mut self, span: Span, kind: hir::PatKind<'hir>) -> hir::Pat<'hir> {
3334 hir::Pat {
3335 hir_id: self.next_id(),
3336 kind,
3337 span: self.lower_span(span),
3338 default_binding_modes: false,
3339 }
3340 }
3341
3342 fn ty_path(&mut self, mut hir_id: HirId, span: Span, qpath: hir::QPath<'hir>) -> hir::Ty<'hir> {
3343 let kind = match qpath {
3344 hir::QPath::Resolved(None, path) => {
3345 match path.res {
3347 Res::Def(DefKind::Trait | DefKind::TraitAlias, _) => {
3348 let principal = hir::PolyTraitRef {
3349 bound_generic_params: &[],
3350 modifiers: hir::TraitBoundModifiers::NONE,
3351 trait_ref: hir::TraitRef { path, hir_ref_id: hir_id },
3352 span: self.lower_span(span),
3353 };
3354
3355 hir_id = self.next_id();
3358 hir::TyKind::TraitObject(
3359 self.arena.alloc_from_iter([principal])arena_vec![self; principal],
3360 TaggedRef::new(self.elided_dyn_bound(span), TraitObjectSyntax::None),
3361 )
3362 }
3363 _ => hir::TyKind::Path(hir::QPath::Resolved(None, path)),
3364 }
3365 }
3366 _ => hir::TyKind::Path(qpath),
3367 };
3368
3369 hir::Ty { hir_id, kind, span: self.lower_span(span) }
3370 }
3371
3372 fn elided_dyn_bound(&mut self, span: Span) -> &'hir hir::Lifetime {
3377 let r = hir::Lifetime::new(
3378 self.next_id(),
3379 Ident::new(kw::UnderscoreLifetime, self.lower_span(span)),
3380 hir::LifetimeKind::ImplicitObjectLifetimeDefault,
3381 LifetimeSource::Other,
3382 LifetimeSyntax::Implicit,
3383 );
3384 {
use ::tracing::__macro_support::Callsite as _;
static __CALLSITE: ::tracing::callsite::DefaultCallsite =
{
static META: ::tracing::Metadata<'static> =
{
::tracing_core::metadata::Metadata::new("event /rustc-dev/6905905bb7727fd0f9223f5fdc9ad4e62236d5a2/compiler/rustc_ast_lowering/src/lib.rs:3384",
"rustc_ast_lowering", ::tracing::Level::DEBUG,
::tracing_core::__macro_support::Option::Some("/rustc-dev/6905905bb7727fd0f9223f5fdc9ad4e62236d5a2/compiler/rustc_ast_lowering/src/lib.rs"),
::tracing_core::__macro_support::Option::Some(3384u32),
::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);
3385 self.arena.alloc(r)
3386 }
3387}
3388
3389struct GenericArgsCtor<'hir> {
3391 args: SmallVec<[hir::GenericArg<'hir>; 4]>,
3392 constraints: &'hir [hir::AssocItemConstraint<'hir>],
3393 parenthesized: hir::GenericArgsParentheses,
3394 span: Span,
3395}
3396
3397impl<'hir> GenericArgsCtor<'hir> {
3398 fn is_empty(&self) -> bool {
3399 self.args.is_empty()
3400 && self.constraints.is_empty()
3401 && self.parenthesized == hir::GenericArgsParentheses::No
3402 }
3403
3404 fn into_generic_args(self, this: &LoweringContext<'_, 'hir>) -> &'hir hir::GenericArgs<'hir> {
3405 let ga = hir::GenericArgs {
3406 args: this.arena.alloc_from_iter(self.args),
3407 constraints: self.constraints,
3408 parenthesized: self.parenthesized,
3409 span_ext: this.lower_span(self.span),
3410 };
3411 this.arena.alloc(ga)
3412 }
3413}
3414
3415struct DirectConstArgContext(<DirectConstArgContext as
::bitflags::__private::PublicFlags>::Internal);
#[automatically_derived]impl ::core::marker::Copy for DirectConstArgContext {
}
#[automatically_derived]#[doc(hidden)]unsafe impl ::core::clone::TrivialClone
for DirectConstArgContext {
}
#[automatically_derived]impl ::core::clone::Clone for DirectConstArgContext {
#[inline]
#[rustc_trivial_field_reads]
fn clone(&self) -> Self {
let _:
::core::clone::AssertParamIsClone<<DirectConstArgContext as
::bitflags::__private::PublicFlags>::Internal>;
*self
}
}
#[automatically_derived]impl ::core::fmt::Debug for DirectConstArgContext {
#[inline]
#[rustc_trivial_field_reads]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::debug_struct_field1_finish(f,
"DirectConstArgContext", &&self.0)
}
}
impl DirectConstArgContext {
#[allow(deprecated, non_upper_case_globals,)]
pub const TUPLE_CALL: Self = Self::from_bits_retain(1 << 0);
#[allow(deprecated, non_upper_case_globals,)]
pub const TUPLE: Self = Self::from_bits_retain(1 << 1);
#[allow(deprecated, non_upper_case_globals,)]
pub const PATH_PLAIN_PARAM: Self = Self::from_bits_retain(1 << 2);
#[allow(deprecated, non_upper_case_globals,)]
pub const PATH_CONST_CTOR: Self = Self::from_bits_retain(1 << 3);
#[allow(deprecated, non_upper_case_globals,)]
pub const PATH_ANY: Self = Self::from_bits_retain(1 << 4);
#[allow(deprecated, non_upper_case_globals,)]
pub const STRUCT: Self = Self::from_bits_retain(1 << 5);
#[allow(deprecated, non_upper_case_globals,)]
pub const ARRAY: Self = Self::from_bits_retain(1 << 6);
#[allow(deprecated, non_upper_case_globals,)]
pub const UNDERSCORE: Self = Self::from_bits_retain(1 << 7);
#[allow(deprecated, non_upper_case_globals,)]
pub const PAREN: Self = Self::from_bits_retain(1 << 8);
#[allow(deprecated, non_upper_case_globals,)]
pub const BLOCK: Self = Self::from_bits_retain(1 << 9);
#[allow(deprecated, non_upper_case_globals,)]
pub const LIT: Self = Self::from_bits_retain(1 << 10);
#[allow(deprecated, non_upper_case_globals,)]
pub const CONST_BLOCK: Self = Self::from_bits_retain(1 << 11);
#[allow(deprecated, non_upper_case_globals,)]
pub const GCA_MACRO: Self = Self::from_bits_retain(1 << 12);
}
impl ::bitflags::Flags for DirectConstArgContext {
const FLAGS: &'static [::bitflags::Flag<DirectConstArgContext>] =
&[{
#[allow(deprecated, non_upper_case_globals,)]
::bitflags::Flag::new("TUPLE_CALL",
DirectConstArgContext::TUPLE_CALL)
},
{
#[allow(deprecated, non_upper_case_globals,)]
::bitflags::Flag::new("TUPLE", DirectConstArgContext::TUPLE)
},
{
#[allow(deprecated, non_upper_case_globals,)]
::bitflags::Flag::new("PATH_PLAIN_PARAM",
DirectConstArgContext::PATH_PLAIN_PARAM)
},
{
#[allow(deprecated, non_upper_case_globals,)]
::bitflags::Flag::new("PATH_CONST_CTOR",
DirectConstArgContext::PATH_CONST_CTOR)
},
{
#[allow(deprecated, non_upper_case_globals,)]
::bitflags::Flag::new("PATH_ANY",
DirectConstArgContext::PATH_ANY)
},
{
#[allow(deprecated, non_upper_case_globals,)]
::bitflags::Flag::new("STRUCT",
DirectConstArgContext::STRUCT)
},
{
#[allow(deprecated, non_upper_case_globals,)]
::bitflags::Flag::new("ARRAY", DirectConstArgContext::ARRAY)
},
{
#[allow(deprecated, non_upper_case_globals,)]
::bitflags::Flag::new("UNDERSCORE",
DirectConstArgContext::UNDERSCORE)
},
{
#[allow(deprecated, non_upper_case_globals,)]
::bitflags::Flag::new("PAREN", DirectConstArgContext::PAREN)
},
{
#[allow(deprecated, non_upper_case_globals,)]
::bitflags::Flag::new("BLOCK", DirectConstArgContext::BLOCK)
},
{
#[allow(deprecated, non_upper_case_globals,)]
::bitflags::Flag::new("LIT", DirectConstArgContext::LIT)
},
{
#[allow(deprecated, non_upper_case_globals,)]
::bitflags::Flag::new("CONST_BLOCK",
DirectConstArgContext::CONST_BLOCK)
},
{
#[allow(deprecated, non_upper_case_globals,)]
::bitflags::Flag::new("GCA_MACRO",
DirectConstArgContext::GCA_MACRO)
}];
type Bits = u16;
fn bits(&self) -> u16 { DirectConstArgContext::bits(self) }
fn from_bits_retain(bits: u16) -> DirectConstArgContext {
DirectConstArgContext::from_bits_retain(bits)
}
}
#[allow(dead_code, deprecated, unused_doc_comments, unused_attributes,
unused_mut, unused_imports, non_upper_case_globals, clippy ::
assign_op_pattern, clippy :: indexing_slicing, clippy :: same_name_method,
clippy :: iter_without_into_iter,)]
const _: () =
{
#[repr(transparent)]
struct InternalBitFlags(u16);
#[automatically_derived]
#[doc(hidden)]
unsafe impl ::core::clone::TrivialClone for InternalBitFlags { }
#[automatically_derived]
impl ::core::clone::Clone for InternalBitFlags {
#[inline]
#[rustc_trivial_field_reads]
fn clone(&self) -> Self {
let _: ::core::clone::AssertParamIsClone<u16>;
*self
}
}
#[automatically_derived]
impl ::core::marker::Copy for InternalBitFlags { }
#[automatically_derived]
impl ::core::marker::StructuralPartialEq for InternalBitFlags { }
#[automatically_derived]
impl ::core::cmp::PartialEq for InternalBitFlags {
#[inline]
fn eq(&self, other: &Self) -> bool { self.0 == other.0 }
}
#[automatically_derived]
impl ::core::cmp::Eq for InternalBitFlags {
#[inline]
#[doc(hidden)]
#[coverage(off)]
fn assert_fields_are_eq(&self) {
let _: ::core::cmp::AssertParamIsEq<u16>;
}
}
#[automatically_derived]
impl ::core::cmp::PartialOrd for InternalBitFlags {
#[inline]
fn partial_cmp(&self, other: &Self)
-> ::core::option::Option<::core::cmp::Ordering> {
::core::option::Option::Some(::core::cmp::Ord::cmp(self,
other))
}
}
#[automatically_derived]
impl ::core::cmp::Ord for InternalBitFlags {
#[inline]
fn cmp(&self, other: &Self) -> ::core::cmp::Ordering {
::core::cmp::Ord::cmp(&self.0, &other.0)
}
}
#[automatically_derived]
impl ::core::hash::Hash for InternalBitFlags {
#[inline]
fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) {
::core::hash::Hash::hash(&self.0, state)
}
}
impl ::bitflags::__private::PublicFlags for DirectConstArgContext {
type Primitive = u16;
type Internal = InternalBitFlags;
}
impl ::bitflags::__private::core::default::Default for
InternalBitFlags {
#[inline]
fn default() -> Self { InternalBitFlags::empty() }
}
impl ::bitflags::__private::core::fmt::Debug for InternalBitFlags {
fn fmt(&self,
f: &mut ::bitflags::__private::core::fmt::Formatter<'_>)
-> ::bitflags::__private::core::fmt::Result {
if self.is_empty() {
f.write_fmt(format_args!("{0:#x}",
<u16 as ::bitflags::Bits>::EMPTY))
} else {
::bitflags::__private::core::fmt::Display::fmt(self, f)
}
}
}
impl ::bitflags::__private::core::fmt::Display for InternalBitFlags {
fn fmt(&self,
f: &mut ::bitflags::__private::core::fmt::Formatter<'_>)
-> ::bitflags::__private::core::fmt::Result {
::bitflags::parser::to_writer(&DirectConstArgContext(*self),
f)
}
}
impl ::bitflags::__private::core::str::FromStr for InternalBitFlags {
type Err = ::bitflags::parser::ParseError;
fn from_str(s: &str)
->
::bitflags::__private::core::result::Result<Self,
Self::Err> {
::bitflags::parser::from_str::<DirectConstArgContext>(s).map(|flags|
flags.0)
}
}
impl ::bitflags::__private::core::convert::AsRef<u16> for
InternalBitFlags {
fn as_ref(&self) -> &u16 { &self.0 }
}
impl ::bitflags::__private::core::convert::From<u16> for
InternalBitFlags {
fn from(bits: u16) -> Self { Self::from_bits_retain(bits) }
}
#[allow(dead_code, deprecated, unused_attributes)]
impl InternalBitFlags {
#[inline]
pub const fn empty() -> Self {
Self(<u16 as ::bitflags::Bits>::EMPTY)
}
#[inline]
pub const fn all() -> Self {
let mut truncated = <u16 as ::bitflags::Bits>::EMPTY;
let mut i = 0;
{
{
let flag =
<DirectConstArgContext as
::bitflags::Flags>::FLAGS[i].value().bits();
truncated = truncated | flag;
i += 1;
}
};
{
{
let flag =
<DirectConstArgContext as
::bitflags::Flags>::FLAGS[i].value().bits();
truncated = truncated | flag;
i += 1;
}
};
{
{
let flag =
<DirectConstArgContext as
::bitflags::Flags>::FLAGS[i].value().bits();
truncated = truncated | flag;
i += 1;
}
};
{
{
let flag =
<DirectConstArgContext as
::bitflags::Flags>::FLAGS[i].value().bits();
truncated = truncated | flag;
i += 1;
}
};
{
{
let flag =
<DirectConstArgContext as
::bitflags::Flags>::FLAGS[i].value().bits();
truncated = truncated | flag;
i += 1;
}
};
{
{
let flag =
<DirectConstArgContext as
::bitflags::Flags>::FLAGS[i].value().bits();
truncated = truncated | flag;
i += 1;
}
};
{
{
let flag =
<DirectConstArgContext as
::bitflags::Flags>::FLAGS[i].value().bits();
truncated = truncated | flag;
i += 1;
}
};
{
{
let flag =
<DirectConstArgContext as
::bitflags::Flags>::FLAGS[i].value().bits();
truncated = truncated | flag;
i += 1;
}
};
{
{
let flag =
<DirectConstArgContext as
::bitflags::Flags>::FLAGS[i].value().bits();
truncated = truncated | flag;
i += 1;
}
};
{
{
let flag =
<DirectConstArgContext as
::bitflags::Flags>::FLAGS[i].value().bits();
truncated = truncated | flag;
i += 1;
}
};
{
{
let flag =
<DirectConstArgContext as
::bitflags::Flags>::FLAGS[i].value().bits();
truncated = truncated | flag;
i += 1;
}
};
{
{
let flag =
<DirectConstArgContext as
::bitflags::Flags>::FLAGS[i].value().bits();
truncated = truncated | flag;
i += 1;
}
};
{
{
let flag =
<DirectConstArgContext as
::bitflags::Flags>::FLAGS[i].value().bits();
truncated = truncated | flag;
i += 1;
}
};
let _ = i;
Self(truncated)
}
#[inline]
pub const fn bits(&self) -> u16 { self.0 }
#[inline]
pub const fn from_bits(bits: u16)
-> ::bitflags::__private::core::option::Option<Self> {
let truncated = Self::from_bits_truncate(bits).0;
if truncated == bits {
::bitflags::__private::core::option::Option::Some(Self(bits))
} else { ::bitflags::__private::core::option::Option::None }
}
#[inline]
pub const fn from_bits_truncate(bits: u16) -> Self {
Self(bits & Self::all().0)
}
#[inline]
pub const fn from_bits_retain(bits: u16) -> Self { Self(bits) }
#[inline]
pub fn from_name(name: &str)
-> ::bitflags::__private::core::option::Option<Self> {
{
if name == "TUPLE_CALL" {
return ::bitflags::__private::core::option::Option::Some(Self(DirectConstArgContext::TUPLE_CALL.bits()));
}
};
;
{
if name == "TUPLE" {
return ::bitflags::__private::core::option::Option::Some(Self(DirectConstArgContext::TUPLE.bits()));
}
};
;
{
if name == "PATH_PLAIN_PARAM" {
return ::bitflags::__private::core::option::Option::Some(Self(DirectConstArgContext::PATH_PLAIN_PARAM.bits()));
}
};
;
{
if name == "PATH_CONST_CTOR" {
return ::bitflags::__private::core::option::Option::Some(Self(DirectConstArgContext::PATH_CONST_CTOR.bits()));
}
};
;
{
if name == "PATH_ANY" {
return ::bitflags::__private::core::option::Option::Some(Self(DirectConstArgContext::PATH_ANY.bits()));
}
};
;
{
if name == "STRUCT" {
return ::bitflags::__private::core::option::Option::Some(Self(DirectConstArgContext::STRUCT.bits()));
}
};
;
{
if name == "ARRAY" {
return ::bitflags::__private::core::option::Option::Some(Self(DirectConstArgContext::ARRAY.bits()));
}
};
;
{
if name == "UNDERSCORE" {
return ::bitflags::__private::core::option::Option::Some(Self(DirectConstArgContext::UNDERSCORE.bits()));
}
};
;
{
if name == "PAREN" {
return ::bitflags::__private::core::option::Option::Some(Self(DirectConstArgContext::PAREN.bits()));
}
};
;
{
if name == "BLOCK" {
return ::bitflags::__private::core::option::Option::Some(Self(DirectConstArgContext::BLOCK.bits()));
}
};
;
{
if name == "LIT" {
return ::bitflags::__private::core::option::Option::Some(Self(DirectConstArgContext::LIT.bits()));
}
};
;
{
if name == "CONST_BLOCK" {
return ::bitflags::__private::core::option::Option::Some(Self(DirectConstArgContext::CONST_BLOCK.bits()));
}
};
;
{
if name == "GCA_MACRO" {
return ::bitflags::__private::core::option::Option::Some(Self(DirectConstArgContext::GCA_MACRO.bits()));
}
};
;
let _ = name;
::bitflags::__private::core::option::Option::None
}
#[inline]
pub const fn is_empty(&self) -> bool {
self.0 == <u16 as ::bitflags::Bits>::EMPTY
}
#[inline]
pub const fn is_all(&self) -> bool {
Self::all().0 | self.0 == self.0
}
#[inline]
pub const fn intersects(&self, other: Self) -> bool {
self.0 & other.0 != <u16 as ::bitflags::Bits>::EMPTY
}
#[inline]
pub const fn contains(&self, other: Self) -> bool {
self.0 & other.0 == other.0
}
#[inline]
pub fn insert(&mut self, other: Self) {
*self = Self(self.0).union(other);
}
#[inline]
pub fn remove(&mut self, other: Self) {
*self = Self(self.0).difference(other);
}
#[inline]
pub fn toggle(&mut self, other: Self) {
*self = Self(self.0).symmetric_difference(other);
}
#[inline]
pub fn set(&mut self, other: Self, value: bool) {
if value { self.insert(other); } else { self.remove(other); }
}
#[inline]
#[must_use]
pub const fn intersection(self, other: Self) -> Self {
Self(self.0 & other.0)
}
#[inline]
#[must_use]
pub const fn union(self, other: Self) -> Self {
Self(self.0 | other.0)
}
#[inline]
#[must_use]
pub const fn difference(self, other: Self) -> Self {
Self(self.0 & !other.0)
}
#[inline]
#[must_use]
pub const fn symmetric_difference(self, other: Self) -> Self {
Self(self.0 ^ other.0)
}
#[inline]
#[must_use]
pub const fn complement(self) -> Self {
Self::from_bits_truncate(!self.0)
}
}
impl ::bitflags::__private::core::fmt::Binary for InternalBitFlags {
fn fmt(&self, f: &mut ::bitflags::__private::core::fmt::Formatter)
-> ::bitflags::__private::core::fmt::Result {
let inner = self.0;
::bitflags::__private::core::fmt::Binary::fmt(&inner, f)
}
}
impl ::bitflags::__private::core::fmt::Octal for InternalBitFlags {
fn fmt(&self, f: &mut ::bitflags::__private::core::fmt::Formatter)
-> ::bitflags::__private::core::fmt::Result {
let inner = self.0;
::bitflags::__private::core::fmt::Octal::fmt(&inner, f)
}
}
impl ::bitflags::__private::core::fmt::LowerHex for InternalBitFlags {
fn fmt(&self, f: &mut ::bitflags::__private::core::fmt::Formatter)
-> ::bitflags::__private::core::fmt::Result {
let inner = self.0;
::bitflags::__private::core::fmt::LowerHex::fmt(&inner, f)
}
}
impl ::bitflags::__private::core::fmt::UpperHex for InternalBitFlags {
fn fmt(&self, f: &mut ::bitflags::__private::core::fmt::Formatter)
-> ::bitflags::__private::core::fmt::Result {
let inner = self.0;
::bitflags::__private::core::fmt::UpperHex::fmt(&inner, f)
}
}
impl ::bitflags::__private::core::ops::BitOr for InternalBitFlags {
type Output = Self;
#[inline]
fn bitor(self, other: InternalBitFlags) -> Self {
self.union(other)
}
}
impl ::bitflags::__private::core::ops::BitOrAssign for
InternalBitFlags {
#[inline]
fn bitor_assign(&mut self, other: Self) { self.insert(other); }
}
impl ::bitflags::__private::core::ops::BitXor for InternalBitFlags {
type Output = Self;
#[inline]
fn bitxor(self, other: Self) -> Self {
self.symmetric_difference(other)
}
}
impl ::bitflags::__private::core::ops::BitXorAssign for
InternalBitFlags {
#[inline]
fn bitxor_assign(&mut self, other: Self) { self.toggle(other); }
}
impl ::bitflags::__private::core::ops::BitAnd for InternalBitFlags {
type Output = Self;
#[inline]
fn bitand(self, other: Self) -> Self { self.intersection(other) }
}
impl ::bitflags::__private::core::ops::BitAndAssign for
InternalBitFlags {
#[inline]
fn bitand_assign(&mut self, other: Self) {
*self =
Self::from_bits_retain(self.bits()).intersection(other);
}
}
impl ::bitflags::__private::core::ops::Sub for InternalBitFlags {
type Output = Self;
#[inline]
fn sub(self, other: Self) -> Self { self.difference(other) }
}
impl ::bitflags::__private::core::ops::SubAssign for InternalBitFlags
{
#[inline]
fn sub_assign(&mut self, other: Self) { self.remove(other); }
}
impl ::bitflags::__private::core::ops::Not for InternalBitFlags {
type Output = Self;
#[inline]
fn not(self) -> Self { self.complement() }
}
impl ::bitflags::__private::core::iter::Extend<InternalBitFlags> for
InternalBitFlags {
fn extend<T: ::bitflags::__private::core::iter::IntoIterator<Item
= Self>>(&mut self, iterator: T) {
for item in iterator { self.insert(item) }
}
}
impl ::bitflags::__private::core::iter::FromIterator<InternalBitFlags>
for InternalBitFlags {
fn from_iter<T: ::bitflags::__private::core::iter::IntoIterator<Item
= Self>>(iterator: T) -> Self {
use ::bitflags::__private::core::iter::Extend;
let mut result = Self::empty();
result.extend(iterator);
result
}
}
impl InternalBitFlags {
#[inline]
pub const fn iter(&self)
-> ::bitflags::iter::Iter<DirectConstArgContext> {
::bitflags::iter::Iter::__private_const_new(<DirectConstArgContext
as ::bitflags::Flags>::FLAGS,
DirectConstArgContext::from_bits_retain(self.bits()),
DirectConstArgContext::from_bits_retain(self.bits()))
}
#[inline]
pub const fn iter_names(&self)
-> ::bitflags::iter::IterNames<DirectConstArgContext> {
::bitflags::iter::IterNames::__private_const_new(<DirectConstArgContext
as ::bitflags::Flags>::FLAGS,
DirectConstArgContext::from_bits_retain(self.bits()),
DirectConstArgContext::from_bits_retain(self.bits()))
}
}
impl ::bitflags::__private::core::iter::IntoIterator for
InternalBitFlags {
type Item = DirectConstArgContext;
type IntoIter = ::bitflags::iter::Iter<DirectConstArgContext>;
fn into_iter(self) -> Self::IntoIter { self.iter() }
}
impl InternalBitFlags {
#[inline]
pub fn bits_mut(&mut self) -> &mut u16 { &mut self.0 }
}
#[allow(dead_code, deprecated, unused_attributes)]
impl DirectConstArgContext {
#[inline]
pub const fn empty() -> Self { Self(InternalBitFlags::empty()) }
#[inline]
pub const fn all() -> Self { Self(InternalBitFlags::all()) }
#[inline]
pub const fn bits(&self) -> u16 { self.0.bits() }
#[inline]
pub const fn from_bits(bits: u16)
-> ::bitflags::__private::core::option::Option<Self> {
match InternalBitFlags::from_bits(bits) {
::bitflags::__private::core::option::Option::Some(bits) =>
::bitflags::__private::core::option::Option::Some(Self(bits)),
::bitflags::__private::core::option::Option::None =>
::bitflags::__private::core::option::Option::None,
}
}
#[inline]
pub const fn from_bits_truncate(bits: u16) -> Self {
Self(InternalBitFlags::from_bits_truncate(bits))
}
#[inline]
pub const fn from_bits_retain(bits: u16) -> Self {
Self(InternalBitFlags::from_bits_retain(bits))
}
#[inline]
pub fn from_name(name: &str)
-> ::bitflags::__private::core::option::Option<Self> {
match InternalBitFlags::from_name(name) {
::bitflags::__private::core::option::Option::Some(bits) =>
::bitflags::__private::core::option::Option::Some(Self(bits)),
::bitflags::__private::core::option::Option::None =>
::bitflags::__private::core::option::Option::None,
}
}
#[inline]
pub const fn is_empty(&self) -> bool { self.0.is_empty() }
#[inline]
pub const fn is_all(&self) -> bool { self.0.is_all() }
#[inline]
pub const fn intersects(&self, other: Self) -> bool {
self.0.intersects(other.0)
}
#[inline]
pub const fn contains(&self, other: Self) -> bool {
self.0.contains(other.0)
}
#[inline]
pub fn insert(&mut self, other: Self) { self.0.insert(other.0) }
#[inline]
pub fn remove(&mut self, other: Self) { self.0.remove(other.0) }
#[inline]
pub fn toggle(&mut self, other: Self) { self.0.toggle(other.0) }
#[inline]
pub fn set(&mut self, other: Self, value: bool) {
self.0.set(other.0, value)
}
#[inline]
#[must_use]
pub const fn intersection(self, other: Self) -> Self {
Self(self.0.intersection(other.0))
}
#[inline]
#[must_use]
pub const fn union(self, other: Self) -> Self {
Self(self.0.union(other.0))
}
#[inline]
#[must_use]
pub const fn difference(self, other: Self) -> Self {
Self(self.0.difference(other.0))
}
#[inline]
#[must_use]
pub const fn symmetric_difference(self, other: Self) -> Self {
Self(self.0.symmetric_difference(other.0))
}
#[inline]
#[must_use]
pub const fn complement(self) -> Self {
Self(self.0.complement())
}
}
impl ::bitflags::__private::core::fmt::Binary for
DirectConstArgContext {
fn fmt(&self, f: &mut ::bitflags::__private::core::fmt::Formatter)
-> ::bitflags::__private::core::fmt::Result {
let inner = self.0;
::bitflags::__private::core::fmt::Binary::fmt(&inner, f)
}
}
impl ::bitflags::__private::core::fmt::Octal for DirectConstArgContext
{
fn fmt(&self, f: &mut ::bitflags::__private::core::fmt::Formatter)
-> ::bitflags::__private::core::fmt::Result {
let inner = self.0;
::bitflags::__private::core::fmt::Octal::fmt(&inner, f)
}
}
impl ::bitflags::__private::core::fmt::LowerHex for
DirectConstArgContext {
fn fmt(&self, f: &mut ::bitflags::__private::core::fmt::Formatter)
-> ::bitflags::__private::core::fmt::Result {
let inner = self.0;
::bitflags::__private::core::fmt::LowerHex::fmt(&inner, f)
}
}
impl ::bitflags::__private::core::fmt::UpperHex for
DirectConstArgContext {
fn fmt(&self, f: &mut ::bitflags::__private::core::fmt::Formatter)
-> ::bitflags::__private::core::fmt::Result {
let inner = self.0;
::bitflags::__private::core::fmt::UpperHex::fmt(&inner, f)
}
}
impl ::bitflags::__private::core::ops::BitOr for DirectConstArgContext
{
type Output = Self;
#[inline]
fn bitor(self, other: DirectConstArgContext) -> Self {
self.union(other)
}
}
impl ::bitflags::__private::core::ops::BitOrAssign for
DirectConstArgContext {
#[inline]
fn bitor_assign(&mut self, other: Self) { self.insert(other); }
}
impl ::bitflags::__private::core::ops::BitXor for
DirectConstArgContext {
type Output = Self;
#[inline]
fn bitxor(self, other: Self) -> Self {
self.symmetric_difference(other)
}
}
impl ::bitflags::__private::core::ops::BitXorAssign for
DirectConstArgContext {
#[inline]
fn bitxor_assign(&mut self, other: Self) { self.toggle(other); }
}
impl ::bitflags::__private::core::ops::BitAnd for
DirectConstArgContext {
type Output = Self;
#[inline]
fn bitand(self, other: Self) -> Self { self.intersection(other) }
}
impl ::bitflags::__private::core::ops::BitAndAssign for
DirectConstArgContext {
#[inline]
fn bitand_assign(&mut self, other: Self) {
*self =
Self::from_bits_retain(self.bits()).intersection(other);
}
}
impl ::bitflags::__private::core::ops::Sub for DirectConstArgContext {
type Output = Self;
#[inline]
fn sub(self, other: Self) -> Self { self.difference(other) }
}
impl ::bitflags::__private::core::ops::SubAssign for
DirectConstArgContext {
#[inline]
fn sub_assign(&mut self, other: Self) { self.remove(other); }
}
impl ::bitflags::__private::core::ops::Not for DirectConstArgContext {
type Output = Self;
#[inline]
fn not(self) -> Self { self.complement() }
}
impl ::bitflags::__private::core::iter::Extend<DirectConstArgContext>
for DirectConstArgContext {
fn extend<T: ::bitflags::__private::core::iter::IntoIterator<Item
= Self>>(&mut self, iterator: T) {
for item in iterator { self.insert(item) }
}
}
impl ::bitflags::__private::core::iter::FromIterator<DirectConstArgContext>
for DirectConstArgContext {
fn from_iter<T: ::bitflags::__private::core::iter::IntoIterator<Item
= Self>>(iterator: T) -> Self {
use ::bitflags::__private::core::iter::Extend;
let mut result = Self::empty();
result.extend(iterator);
result
}
}
impl DirectConstArgContext {
#[inline]
pub const fn iter(&self)
-> ::bitflags::iter::Iter<DirectConstArgContext> {
::bitflags::iter::Iter::__private_const_new(<DirectConstArgContext
as ::bitflags::Flags>::FLAGS,
DirectConstArgContext::from_bits_retain(self.bits()),
DirectConstArgContext::from_bits_retain(self.bits()))
}
#[inline]
pub const fn iter_names(&self)
-> ::bitflags::iter::IterNames<DirectConstArgContext> {
::bitflags::iter::IterNames::__private_const_new(<DirectConstArgContext
as ::bitflags::Flags>::FLAGS,
DirectConstArgContext::from_bits_retain(self.bits()),
DirectConstArgContext::from_bits_retain(self.bits()))
}
}
impl ::bitflags::__private::core::iter::IntoIterator for
DirectConstArgContext {
type Item = DirectConstArgContext;
type IntoIter = ::bitflags::iter::Iter<DirectConstArgContext>;
fn into_iter(self) -> Self::IntoIter { self.iter() }
}
};bitflags::bitflags! {
3416 #[derive(Copy, Clone, Debug)]
3417 struct DirectConstArgContext: u16 {
3418 const TUPLE_CALL = 1 << 0;
3419 const TUPLE = 1 << 1;
3420 const PATH_PLAIN_PARAM = 1 << 2;
3421 const PATH_CONST_CTOR = 1 << 3;
3422 const PATH_ANY = 1 << 4;
3423 const STRUCT = 1 << 5;
3424 const ARRAY = 1 << 6;
3425 const UNDERSCORE = 1 << 7;
3426 const PAREN = 1 << 8;
3427 const BLOCK = 1 << 9;
3428 const LIT = 1 << 10;
3429 const CONST_BLOCK = 1 << 11;
3430 const GCA_MACRO = 1 << 12;
3431 }
3432}
3433
3434impl DirectConstArgContext {
3435 const STABLE: DirectConstArgContext = Self::PATH_PLAIN_PARAM;
3438
3439 const GCA: DirectConstArgContext = Self::STABLE.union(Self::GCA_MACRO);
3441
3442 const GCA_BASE_FEATURES: DirectConstArgContext = Self::GCA
3447 .union(DirectConstArgContext::UNDERSCORE)
3448 .union(DirectConstArgContext::PAREN)
3449 .union(DirectConstArgContext::BLOCK)
3450 .union(DirectConstArgContext::LIT)
3451 .union(DirectConstArgContext::CONST_BLOCK);
3452
3453 const GCA_MIN_CONST_ITEMS: DirectConstArgContext = DirectConstArgContext::PATH_ANY;
3455
3456 const GCA_ADTS: DirectConstArgContext = DirectConstArgContext::PATH_CONST_CTOR
3458 .union(DirectConstArgContext::TUPLE_CALL)
3459 .union(DirectConstArgContext::TUPLE)
3460 .union(DirectConstArgContext::STRUCT)
3461 .union(DirectConstArgContext::ARRAY);
3462}
3463
3464#[derive(#[automatically_derived]impl ::core::fmt::Debug for
UnrepresentableConstArgError {
#[inline]
#[rustc_trivial_field_reads]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::debug_struct_field2_finish(f,
"UnrepresentableConstArgError span will_create_def_ids",
&self.span, &&self.will_create_def_ids)
}
}Debug)]
3465struct UnrepresentableConstArgError {
3466 span: Span,
3467 will_create_def_ids: bool,
3468}
3469
3470impl UnrepresentableConstArgError {
3471 fn new(expr: &Expr) -> Self {
3472 Self {
3473 span: expr.span,
3474 will_create_def_ids: expr::WillCreateDefIdsVisitor.visit_expr(expr).is_break(),
3475 }
3476 }
3477
3478 fn emit<'hir>(self, lowering_context: &mut LoweringContext<'_, 'hir>) -> ConstArg<'hir> {
3479 let msg = "complex const arguments must be placed inside of a `const` block";
3480 let e = if self.will_create_def_ids {
3481 lowering_context.dcx().span_fatal(self.span, msg)
3485 } else {
3486 lowering_context.dcx().span_err(self.span, msg)
3487 };
3488
3489 ConstArg {
3490 hir_id: lowering_context.next_id(),
3491 kind: hir::ConstArgKind::Error(e),
3492 span: lowering_context.lower_span(self.span),
3493 }
3494 }
3495}